mirror of
https://github.com/stablyai/orca.git
synced 2026-10-31 17:17:38 +00:00
* feat(serve): supervised mode for orca serve --supervise Restart the server with jittered backoff instead of exiting when it dies, with a crash-loop brake whose exhaustion is durable per profile and build, an install hold while the executable is missing or ShipIt replaces the bundle, and standby while another Orca serves the profile. Only an explicit --supervise turns it on; Windows refuses it for now. * fix(serve): let a supervised orcad serve wait for a live peer instead of counting it * fix(serve): gate update replacements on the install hold, honor stop during the bundle wait, keep a give-up while the executable is missing * fix(serve): hand a removed executable back to the service manager and key the brake on the app archive --------- Co-authored-by: m4air <m4air@Mac.localdomain>
110 lines
2.4 KiB
TypeScript
110 lines
2.4 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',
|
|
'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',
|
|
'references',
|
|
'relations',
|
|
'reinstall',
|
|
'restore-window',
|
|
'return-preamble',
|
|
'run-hooks',
|
|
'show-profile',
|
|
'staged',
|
|
'supervise',
|
|
'tab',
|
|
'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
|
|
}
|