mirror of
https://github.com/stablyai/orca.git
synced 2026-11-03 02:27:43 +00:00
`orca worktree ps --agent-wait --json` now reports, on each terminal-backed agent row of the returned page, the same agentWait verdict `orca terminal show --json` gives for that terminal. The lookup is opt-in (RPC `includeAgentWait: true`) because it reads screens and may probe PTYs, which is too costly for default pollers. Hook rows use their terminal handle only when a connected PTY confirms it, and pane-only hook rows resolve the live terminal by pane key. Structured-worker rows and older hosts omit the field (absent = not evaluated; null = looked, no wait). Fixes #23921 Co-authored-by: Neil <neil@stably.ai>
114 lines
2.5 KiB
TypeScript
114 lines
2.5 KiB
TypeScript
export const CLI_GLOBAL_VALUE_FLAGS: readonly string[] = ['pairing-code', 'environment']
|
|
export const CLI_GLOBAL_FLAGS: readonly string[] = ['help', 'json', ...CLI_GLOBAL_VALUE_FLAGS]
|
|
|
|
export const CLI_BOOLEAN_FLAGS = new Set([
|
|
'accept-changed-state',
|
|
'agent-wait',
|
|
'all',
|
|
'allow-failed-archive-hook',
|
|
'attachments',
|
|
'children',
|
|
'comments',
|
|
'connect',
|
|
'current',
|
|
'current-json',
|
|
'current-sqlite',
|
|
'debug',
|
|
'dry-run',
|
|
'enter',
|
|
'focus',
|
|
'grant-desktop-control',
|
|
'force',
|
|
'fresh',
|
|
'full',
|
|
'help',
|
|
'inject',
|
|
'include-archived',
|
|
'include-remote',
|
|
'include-visual-layouts',
|
|
'index-status',
|
|
'interrupt',
|
|
'json',
|
|
'latest-json',
|
|
'local',
|
|
'messages',
|
|
'me',
|
|
'mobile',
|
|
'mobile-pairing',
|
|
'no-pairing',
|
|
'screen',
|
|
'parent-current',
|
|
'provision',
|
|
'ready',
|
|
'recipe-json',
|
|
'reclaim-stale-lock',
|
|
'references',
|
|
'relations',
|
|
'removed',
|
|
'reinstall',
|
|
'restore-window',
|
|
'return-preamble',
|
|
'run-hooks',
|
|
'show-profile',
|
|
'staged',
|
|
'supervise',
|
|
'tab',
|
|
'takeover-legacy',
|
|
'tasks',
|
|
'text-stdin',
|
|
'unread',
|
|
'value-stdin',
|
|
'wait',
|
|
'yes'
|
|
])
|
|
|
|
function commandPathStartsAt(
|
|
argv: readonly string[],
|
|
tokenIndex: number,
|
|
path: readonly string[]
|
|
): boolean {
|
|
let cursor = tokenIndex
|
|
for (const part of path) {
|
|
while (argv[cursor]?.startsWith('--')) {
|
|
const assignment = argv[cursor].slice(2)
|
|
const flag = assignment.split('=', 1)[0]
|
|
cursor += assignment.includes('=') || CLI_BOOLEAN_FLAGS.has(flag) ? 1 : 2
|
|
}
|
|
if (argv[cursor] !== part) {
|
|
return false
|
|
}
|
|
cursor += 1
|
|
}
|
|
return true
|
|
}
|
|
|
|
export function findCliCommandIndex(
|
|
argv: readonly string[],
|
|
commandPaths: readonly (readonly string[])[],
|
|
knownValueFlags: readonly string[] = []
|
|
): number {
|
|
const startsCommandAt = (index: number): boolean =>
|
|
commandPaths.some((path) => commandPathStartsAt(argv, index, path))
|
|
|
|
for (let index = 0; index < argv.length;) {
|
|
const token = argv[index]
|
|
if (!token.startsWith('--')) {
|
|
return startsCommandAt(index) ? index : -1
|
|
}
|
|
|
|
const assignment = token.slice(2)
|
|
const flag = assignment.split('=', 1)[0]
|
|
const next = argv[index + 1]
|
|
const takesNext =
|
|
!assignment.includes('=') &&
|
|
!CLI_BOOLEAN_FLAGS.has(flag) &&
|
|
next !== undefined &&
|
|
!next.startsWith('--') &&
|
|
(knownValueFlags.includes(flag) ||
|
|
!(startsCommandAt(index + 1) && !startsCommandAt(index + 2)))
|
|
|
|
index += takesNext ? 2 : 1
|
|
}
|
|
return -1
|
|
}
|