Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

877 B
Raw Blame
import type { PtyStartupReplyDelivery } from './pty-startup-reply-delivery'
import {
  extractOnlyTerminalQueryReplies,
  needsCookedEchoSafeQueryReply
} from './terminal-query-reply'

/** Return true only after writing the whole payload. Cooked-echo-risk-only replies arm echo protection and bypass startup gating.
 * Keep CPR/DA/mixed payloads on the host’s ordered path so replies cannot splice into buffered startup commands; accepted writes retain caller order. */
export function deliverTerminalQueryReplyPayload(
  data: string,
  delivery: Pick<PtyStartupReplyDelivery, 'answer'>
): boolean {
  const replies = extractOnlyTerminalQueryReplies(data)
  if (!replies || !replies.every(needsCookedEchoSafeQueryReply)) {
    return false
  }
  let accepted = false
  for (const reply of replies) {
    accepted = delivery.answer(reply) || accepted
  }
  return accepted
}