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.

988 B
Raw Blame
import { isProgramStatusQueryBody, PROGRAM_STATUS_QUERY_REPLY } from './protocol'

type OscHandlerParser = {
  registerOscHandler: (
    ident: number,
    callback: (data: string) => boolean
  ) => { dispose: () => void }
}

/** Share OSC 7501 query replies across visible xterm and hidden-pane emulators; the owning parser must answer before the DA1 sentinel. */
export function installProgramStatusQueryResponder(deps: {
  parser: OscHandlerParser
  /** Must already be gated to the reply owner for the chunk being parsed. */
  emitReply: (reply: string) => void
  /** False while replaying restored bytes, whose queries answer no one. */
  shouldReply?: () => boolean
}): { dispose: () => void } {
  return deps.parser.registerOscHandler(7501, (data) => {
    if (isProgramStatusQueryBody(data) && deps.shouldReply?.() !== false) {
      deps.emitReply(PROGRAM_STATUS_QUERY_REPLY)
    }
    // Reports are read from the PTY stream upstream; nothing here draws.
    return true
  })
}