Files
orca/src/shared/agent-headless-command.ts
T
Neil ccdb324b63 Add CodeBuddy as a built-in coding agent (#23740)
* feat(agents): integrate CodeBuddy launch, status and session history

* docs: record CodeBuddy lifecycle verification

* fix(codebuddy): backfill scoped history and negotiate remote resume

* test(cli): include CodeBuddy in known search agents
2026-09-28 18:11:25 -07:00

46 lines
2.0 KiB
TypeScript

import { isCodebuddyNonInteractiveCommand } from './codebuddy-headless-command'
import { isQoderHeadlessCommand } from './qoder-headless-command'
import { isAnteHeadlessOneShotCommand } from './ante-headless-command'
import { isDshNonInteractiveCommand } from './dsh-launch-command'
import { isMuseHeadlessOneShotCommand } from './muse-headless-command'
import { isZCodeHeadlessOneShotCommand } from './zcode-headless-command'
import { isPrimeAgentHeadlessOneShotCommand } from './prime-agent-headless-command'
import { isPrintModeHeadlessOneShotCommand } from './print-mode-headless-command'
import type { TuiAgent } from './tui-agent'
// Why: a table (not an if-chain) so adding an agent is one entry; Claude and Trae share
// the same `--print` one-shot contract, Ante's `--prompt` form, Prime Agent's
// `--mode` forms, Muse's `exec` subcommand, and ZCode's `--prompt`/`--target` forms need
// their own matchers. DSH's entry is wider than a one-shot: `dsh` also boots a web server
// and JSON-RPC stdio profiles, and none of those can answer a prompt in the pane either,
// which is what this table gates.
const HEADLESS_ONE_SHOT_MATCHERS: Partial<
Record<TuiAgent, (tokens: readonly string[]) => boolean>
> = {
qoder: isQoderHeadlessCommand,
claude: isPrintModeHeadlessOneShotCommand,
codebuddy: isCodebuddyNonInteractiveCommand,
trae: isPrintModeHeadlessOneShotCommand,
'prime-agent': isPrimeAgentHeadlessOneShotCommand,
ante: isAnteHeadlessOneShotCommand,
muse: isMuseHeadlessOneShotCommand,
zcode: isZCodeHeadlessOneShotCommand,
dsh: isDshNonInteractiveCommand
}
export function isHeadlessOneShotAgentCommand(agent: TuiAgent, tokens: readonly string[]): boolean {
return HEADLESS_ONE_SHOT_MATCHERS[agent]?.(tokens) ?? false
}
type AgentCommandRecognition = { agent: TuiAgent } | null
export function filterHeadlessOneShotAgentCommand<T extends AgentCommandRecognition>(
recognition: T,
tokens: readonly string[]
): T | null {
if (recognition && isHeadlessOneShotAgentCommand(recognition.agent, tokens)) {
return null
}
return recognition
}