mirror of
https://github.com/stablyai/orca.git
synced 2026-11-16 10:58:10 +00:00
orca server ... replaces orca environment ... and orca host name; --server and --parent-server replace --environment and --parent-environment. Old spellings stay accepted as input only: help, suggestions, errors and printed commands use the new names, and giving both spellings different values is invalid_argument. --host is still parsed but leaves help; orca host list/rm are hidden. Listings name each row's owning server (server: / server=) from data already returned, mapping a stored owner to a saved-server name only from this computer's own store, and print server=unknown instead of guessing local. The ports footer and search hits drop host=. CLI-built JSON uses server keys (server, address.server, parent.server, unknown-server, servers, knownServers, status target kind server). create/set print the same parent line as ps.
56 lines
2.1 KiB
TypeScript
56 lines
2.1 KiB
TypeScript
import type { CommandHandler } from '../dispatch'
|
|
import {
|
|
callAgentLaunch,
|
|
formatAgentLaunch,
|
|
getAgentLaunchCapabilities,
|
|
parseCliAgent,
|
|
readCliAgentLaunch
|
|
} from '../agent-launch-request'
|
|
import { getRequiredStringFlag } from '../flags'
|
|
import { printResult } from '../format'
|
|
import { RuntimeClientError } from '../runtime-client'
|
|
import { getRequiredWorktreeSelector, resolveCurrentWorktreeSelector } from '../selectors'
|
|
|
|
export const AGENT_LAUNCH_HANDLERS: Record<string, CommandHandler> = {
|
|
'agent launch': async ({ flags, client, cwd, json, rawArgs }) => {
|
|
const launch = readCliAgentLaunch(flags, parseCliAgent(getRequiredStringFlag(flags, 'agent')), {
|
|
createsWorktree: false
|
|
})
|
|
if (client.isRemote && !flags.has('worktree')) {
|
|
throw new RuntimeClientError(
|
|
'invalid_argument',
|
|
'Remote agent launch requires --worktree because the client cwd cannot identify a server worktree.'
|
|
)
|
|
}
|
|
const selector = flags.get('worktree')
|
|
const current = selector === undefined || selector === 'active' || selector === 'current'
|
|
const worktree = current
|
|
? await resolveCurrentWorktreeSelector(cwd, client, { agent: launch.agent })
|
|
: await getRequiredWorktreeSelector(flags, 'worktree', cwd, client)
|
|
const capabilities = await getAgentLaunchCapabilities(client)
|
|
if (!capabilities) {
|
|
if (launch.operationId) {
|
|
throw new RuntimeClientError(
|
|
'agent_session_operation_unknown',
|
|
'This server cannot replay the earlier launch. Return to the server that started it; do not retry without --retry-launch.'
|
|
)
|
|
}
|
|
throw new RuntimeClientError(
|
|
'incompatible_runtime',
|
|
'This Orca server cannot start agents from the CLI. Update Orca on that server.'
|
|
)
|
|
}
|
|
const result = await callAgentLaunch(
|
|
client,
|
|
launch,
|
|
{
|
|
target: { kind: 'existing', worktree },
|
|
presentation: flags.get('focus') === true ? 'focused' : 'background'
|
|
},
|
|
capabilities,
|
|
rawArgs
|
|
)
|
|
printResult(result, json, formatAgentLaunch)
|
|
}
|
|
}
|