mirror of
https://github.com/stablyai/orca.git
synced 2026-10-21 00:03:46 +00:00
* fix: recover from an alternate shell install, and close the relay echo gap #18768: a startup profile that `exec`s a second install of the same shell keeps the pid but loses the wrapper's ready marker, and the recovery probe rejected the replacement's different canonical path -- costing plain Codex the full 15s barrier. The probe now also accepts an install that the pane's own PATH resolves, so a binary merely named bash/zsh outside it stays rejected. #18767: the SSH relay left plain Codex on early startup delivery, displaying the launch twice under a slow profile. The shell is the host's to know, so the relay now folds it into the same rule the daemon uses, and the SSH background client waits for the marker on any Codex launch. Bracketed paste is now gated on an observed marker rather than on the intent to wait, so a fallback release on a host shell that never publishes one submits raw. The non-daemon local provider needs no change: it hands Codex to the wrapper's own prompt hook and never writes it into the PTY. * review: correct an overclaiming comment, announce a silent skip, drop a shim Readiness review of #18796. The delivery comment claimed waiting "costs nothing", which is only true on a host that arms the marker -- fish, sh, Windows and hosts predating #18767 release on the fallback instead. Say so. The alternate-install recovery tests skip on usrmerge hosts, where /usr/bin/bash resolves back to /bin/bash; announce that rather than reading as coverage that does not exist. Import the line-editor predicate from shared directly instead of through a re-export left on daemon/shell-ready.
98 lines
2.8 KiB
TypeScript
98 lines
2.8 KiB
TypeScript
import { recognizeAgentProcessFromCommandLine } from './agent-process-recognition'
|
|
import { shellReadyMarkerComesFromLineEditor } from './shell-ready-marker-timing'
|
|
|
|
export type StartupCommandDelivery = 'fast' | 'shell-ready'
|
|
|
|
type CommandToken = {
|
|
value: string
|
|
startsQuoted: boolean
|
|
}
|
|
|
|
function tokenizeCommandWithQuoteMetadata(command: string): CommandToken[] {
|
|
const tokens: CommandToken[] = []
|
|
let current = ''
|
|
let inToken = false
|
|
let startsQuoted = false
|
|
let quote: '"' | "'" | null = null
|
|
let escaped = false
|
|
|
|
for (let index = 0; index < command.length; index += 1) {
|
|
const char = command[index]
|
|
if (escaped) {
|
|
current += char
|
|
escaped = false
|
|
continue
|
|
}
|
|
if (char === '\\' && quote !== "'") {
|
|
const next = command[index + 1]
|
|
if (next && (/\s/.test(next) || next === '"' || next === "'" || next === '\\')) {
|
|
escaped = true
|
|
inToken = true
|
|
continue
|
|
}
|
|
}
|
|
if ((char === '"' || char === "'") && quote === null) {
|
|
if (!inToken) {
|
|
startsQuoted = true
|
|
}
|
|
quote = char
|
|
inToken = true
|
|
continue
|
|
}
|
|
if (quote === char) {
|
|
quote = null
|
|
continue
|
|
}
|
|
if (/\s/.test(char) && quote === null) {
|
|
if (inToken) {
|
|
tokens.push({ value: current, startsQuoted })
|
|
current = ''
|
|
inToken = false
|
|
startsQuoted = false
|
|
}
|
|
continue
|
|
}
|
|
current += char
|
|
inToken = true
|
|
}
|
|
|
|
if (inToken) {
|
|
tokens.push({ value: current, startsQuoted })
|
|
}
|
|
return tokens
|
|
}
|
|
|
|
export function hasCodexNativeDraftFlag(command: string | null | undefined): boolean {
|
|
if (recognizeAgentProcessFromCommandLine(command)?.agent !== 'codex' || !command) {
|
|
return false
|
|
}
|
|
const tokens = tokenizeCommandWithQuoteMetadata(command)
|
|
return tokens.some(
|
|
(token, index) =>
|
|
index > 0 &&
|
|
!token.startsQuoted &&
|
|
(token.value === '--prefill' || token.value.startsWith('--prefill='))
|
|
)
|
|
}
|
|
|
|
export function isCodexStartupCommand(command: string | null | undefined): boolean {
|
|
return recognizeAgentProcessFromCommandLine(command)?.agent === 'codex'
|
|
}
|
|
|
|
export function shouldUseShellReadyStartupDelivery(args: {
|
|
command: string | null | undefined
|
|
startupCommandDelivery?: StartupCommandDelivery
|
|
/** The shell that will run the command, when the deciding side knows it. Plain Codex
|
|
* waits for the handshake on shells that publish the marker from their line editor:
|
|
* there the wait ends at the prompt, while an early write double-echoes the launch. */
|
|
shellPath?: string
|
|
}): boolean {
|
|
return (
|
|
args.startupCommandDelivery === 'shell-ready' ||
|
|
hasCodexNativeDraftFlag(args.command) ||
|
|
(args.shellPath !== undefined &&
|
|
shellReadyMarkerComesFromLineEditor(args.shellPath) &&
|
|
isCodexStartupCommand(args.command))
|
|
)
|
|
}
|