mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 09:07:40 +00:00
* fix(terminal): preserve preparation and discovery for delayed agent launches * refactor(agents): centralize launch intent recognition * refactor(agents): keep launch intent in one module apart from process recognition Move recognizeAgentLaunchCommand next to the sleep-prefix scanner so the strict process-table matcher is untouched, name the module away from the agent-launch funnel files, share one executable-name normalizer, and colocate the preparation tests with their modules.
30 lines
1.1 KiB
TypeScript
30 lines
1.1 KiB
TypeScript
import type { TuiAgent } from './tui-agent'
|
|
import { getAgentLaunchExecutableName } from './agent-command-line-intent'
|
|
|
|
function openCodeCommandAgent(launchCommand: string | undefined): 'opencode' | 'opencode2' | null {
|
|
const binary = getAgentLaunchExecutableName(launchCommand)
|
|
return binary === 'opencode' || binary === 'opencode2' ? binary : null
|
|
}
|
|
|
|
export function isOpenCode2LaunchCommand(launchCommand: string | undefined): boolean {
|
|
return openCodeCommandAgent(launchCommand) === 'opencode2'
|
|
}
|
|
|
|
export function selectOpenCodeHookAgent(
|
|
launchAgent: TuiAgent | undefined,
|
|
launchCommand: string | undefined,
|
|
isEnabled: (agent: 'opencode' | 'opencode2') => boolean
|
|
): 'opencode' | 'opencode2' | null {
|
|
const explicit =
|
|
launchAgent === 'opencode' || launchAgent === 'opencode2'
|
|
? launchAgent
|
|
: launchAgent === undefined
|
|
? openCodeCommandAgent(launchCommand)
|
|
: null
|
|
// An explicit version selects its own integration; disabling it never substitutes the other.
|
|
if (explicit) {
|
|
return isEnabled(explicit) ? explicit : null
|
|
}
|
|
return isEnabled('opencode') ? 'opencode' : isEnabled('opencode2') ? 'opencode2' : null
|
|
}
|