Repository navigation
refactor(runtime): read Codex, Claude, OpenCode, Pi, OMP and Gemini readiness from rule files - #24375
Conversation
Replays every recorded agent PTY transcript frame by frame through a real runtime pane (agent-known and agent-unknown, clocked and clockless) and a synthetic evidence matrix for all 43 TuiAgents, and compares each verdict and tui-idle wait outcome to committed run-length-encoded baselines. Refs STA-9098
A census that read TUI_IDLE_QUIESCENCE_MS would move with it; fixed 2999/3000 ms reads and a fixed 2000 ms poll step make a changed window show as changed verdicts. Refs STA-9098
…sible waits - Read each verdict through the runtime's own settle seam (evaluateTuiIdleForLeaf) instead of re-wiring evaluateTuiIdle/leafTuiIdleEvidence/buildTerminalWaitText, so the census is coupled to one runtime method, not to the module STA-9098 rewrites. - Let the runtime finish each chunk (one macrotask turn) before reading. The old read raced work chained on the paint, so 14 frames pinned a microtask-ordering artefact. - Record when a wait settles (@start vs @poll), not just its outcome. - Exit each pane's PTY after reading it so its emulator is freed. - Replace the hand-grouped families, literal fixture list and per-pane split flag with a directory-scanned catalog, one baseline per replayed pane, and size-balanced shards. - Run the synthetic matrix in one file; it takes about 2 s.
…e in the census matrix Blocked detection is position-ordered (design doc 11.5): the later of a blocker and a ready anchor wins. The matrix now paints a workspace-trust dialog after, and before, each agent's ready screen under every title, so a rule engine that loses that ordering fails per agent.
The anti-slop lint rejects Reflect.get on parsed input.
…adiness from rule files Adds agent-state-rules/: a zod-validated JSON file per agent, one priority list of screen rules per agent (idle with strength and requiresQuiet, or hold), and text anchors that feed the shared, position-ordered blocked layer every pane reads first. The three screen-ruled agents and Cursor's approval menu and prompt move to data; the Antigravity text scan stays code as a named anchor. Their old code paths are deleted. Every other agent still runs through the existing lanes, unchanged. The readiness census baselines are untouched and pass. Refs STA-9098
…rows, anchors and lanes Refs STA-9098
…ting group
The load-time regex check only flagged a repeated group whose body held * + or {,
so (a?)* and (a|aa)+ passed though both backtrack exponentially. A repeated
group's body must now be fixed: no quantifier of any kind and no alternation.
The comment states the remaining polynomial gap instead of claiming linearity.
…nswer shape Every rule and text anchor is now when (a region and what it must show) plus answer, each a discriminated union, so part (b) adds title, text and status regions and working or blocked answers as new variants instead of new fields. - Cursor's prompt is two anchors answering working and idle; the one-off workingIfAfter and followedBy fields become a general after test. - Anchor literals and the probe banner must be lowercase, since they are matched against the lowercased tail. - screenProbeBanner moves under profile, the place for non-detection facts. - why is required on every rule and anchor. - A blocked anchor must name a lastOf literal, which the prefilter keys on.
…eadiness from rule files The rule engine gains the regions and answers these agents need, as closed-list entries: - rule regions `title` (the classified title status) and `text` (one of the file's idle text anchors, settled), and a `predicate` form of the screen region for named engine scans; - `withoutClock: skip` for strong quiet rules a clockless pane must not believe; - anchors (renamed from textAnchors) gain a `title` region, and `live` and `hold` answers; - `profile.screenSource` (trusted grid or live screen), and an `unknown-pane` file for panes with no known agent. Codex's header, composer and provisional-startup checks become named predicates referenced from codex.json; its ready header, header and startup hold become shared text anchors. Native idle title markers become shared title anchors; name-only title handling becomes each agent's idle-title rule. The agent-specific branches in terminal-wait-detection.ts and tui-idle-evidence.ts are deleted, and the "later live prompt cancels a blocker" rule now reads only rule-file anchors (plus Muse, which moves in part b2). No behaviour change: the readiness census baselines are untouched and pass. Refs STA-9098
…ons and the bundled anchors Refs STA-9098
|
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed all 30 files in the diff at ac81936, both commits (068cceec03, ac81936522).
- Six agents move to rule files — Codex, Claude, OpenCode, OpenCode2, Pi, OMP and Gemini readiness now lives in
agent-state-rules/*.json; the Codex-only branches interminal-wait-detection.tsandtui-idle-evidence.tsare deleted andcodex-terminal-readiness.tsis renamed toagent-state-rules/codex-screen-predicates.ts. - Engine vocabulary extended as closed-list entries — a
titleregion (classifiedlastAgentStatus), a namedpredicateform of thescreenregion, a settledtextregion,hold/liveanchor answers, andwithoutClock: believe|skip. profile.screenSourcereplaces the structural gate —readsTrustedScreennow decides which screen is read and when a clockless wait probes, decoupling "reads the trusted grid" from "has rules".unknown-pane.json— a null-agent pane reproduces the old "adopt and settle on Codex's live header" path through the same engine.
I traced each agent-specific branch this PR removes against its replacement and found them equivalent:
hasScreenRules→readsTrustedScreen: true today only forantigravity/cline/prime-agent(all now declarescreenSource: "trusted");codex/unknown-panearelive, matching their absence from the base map. Every call site (probe,shouldProbeVisibleScreen,screenReader) follows.hasQuietReadyScreen's gate →hasQuietReadyRules: codex keepsQUIET_READY_SCREEN_AGENTSmembership; the three trusted agents keep it via their strong/quiet/idlecomposer_ready.nameOnlyIdleNeedsCorroboration'sNATIVE_EXPLICIT_IDLE_TITLE_AGENTS+synthetic fallback →idleTitleRequiresQuiet: same answer for claude/codex/pi/omp (true) and gemini/opencode/opencode2 (false); the synthetic fallback still covers cursor/droid/devin/zcode/etc.- The dropped
agent !== 'codex'gate inisKnownReadyPromptBodyand the Codex finders (findCodexHeaderIndex/findCodexScreenReadyPromptIndex/isCodexProvisionalStartupText) are reproduced bycodex.jsonanchors +isSettledAfter's hold veto and thecodex-*-readypredicates, with no cross-agent screen read.
Ran the rule-engine, tui-idle-evidence, terminal-wait-detection, codex header/quiet and antigravity suites: 308 tests pass. Grepped the HEAD tree for every removed symbol/path (hasScreenRules, codex-terminal-readiness, NATIVE_EXPLICIT_IDLE_TITLE_AGENTS, QUIET_READY_SCREEN_AGENTS, the old Codex finders) — no stale references.
ℹ️ engineVersion stays 1 while the schema doc says it should bump
No change is required for a bundled, single-build engine — flagging only so the comment does not drift out of step with the code. agent-state-rules-schema.ts:11 says "adding a region, predicate or answer bumps engineVersion", but this PR adds the title region, four named predicates and the live/hold answers while AGENT_STATE_RULES_ENGINE_VERSION (and every JSON file) stays at 1.
Technical details
# engineVersion invariant
## Affected sites
- src/main/runtime/agent-state-rules/agent-state-rules-schema.ts:11 — doc says bump on a new region/predicate/answer
- src/main/runtime/agent-state-rules/agent-state-rules-schema.ts:13,238 — AGENT_STATE_RULES_ENGINE_VERSION stays 1; all bundled JSON declares 1
## Why it may be intentional
- `engineVersion` is only a `z.literal` and is never read for compatibility; bundled files and the engine ship together, so keeping 1 has no functional effect.
- If v1 is treated as the still-unreleased initial version (its base #24348 is unmerged), this is fine and the doc sentence is the only thing to adjust later.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
A text rule names its anchor by id, so a repeated id let a file pass validation and then throw while compiling. Also states that engineVersion bumps once a version ships; version 1 is still being defined.
The engine treated an anchor's working and live answers identically: both mark a live prompt that cancels an earlier blocker and settles nothing. Cursor's busy prompt now answers live, so anchors have one non-settling prompt answer. Refs STA-9098
Pi and OMP paint the same `π - <session>` rest title, and title anchors apply to every pane, so one copy covers both. Refs STA-9098
…om screenSource alone readsTrustedScreen no longer also asks for a screen rule (every trusted file has one, and the schema requires screenSource where it matters), so rule-less files need no filter. A rule's match is a plain boolean, and compileTitleAnchors is module-private. Refs STA-9098
…eady text No test failed when holdsReadyTextToQuiet was removed; this one does. Refs STA-9098
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the five commits pushed since the prior pullfrog review (ac81936 → 7c90a13); the full diff is 30 files.
- Folded the
workinganchor answer intolive— the anchor answer union,cursor.json's busy prompt and the doc comments now uselive, which the engine already treated identically toworking. - Deduplicated the shared
π -title anchor — OMP's duplicate copy is removed;pi.jsonowns the single anchor that every pane reads. - Rejected duplicate ids in a rule file — a new
hasUniqueIdsrefine stops a repeated anchor or rule id from passing validation and then throwing at compile time. - Decoupled
readsTrustedScreenfrom having screen rules — it now readsprofile.screenSourcealone, and every rule file is keyed (the empty-rules filter is gone). - Pinned the clocked-Codex text gate — a new unit test fails if
holdsReadyTextToQuietis removed.
I traced each change against its call sites. findPromptAnchorIndexes counts every non-blocked/non-hold anchor as live and only idle as ready, so dropping working changes no verdict. Title anchors compile globally across all files, so OMP's copied anchor was redundant. Every screenSource: "trusted" file (antigravity, cline, prime-agent) keeps its screen rules, and cursor.json (empty rules, no profile) now keyed still resolves to false/null/null through readsTrustedScreen, hasQuietReadyRules and evaluateAgentStateRules. pnpm test on the rule-engine, title/text-anchor, tui-idle-evidence, terminal-wait-detection and quiet-Codex suites: 243 pass across 6 files.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
… into jinwoo/agent-state-rules-main-agents
…read the lowercased tail A text anchor's after and lines tests run on the lowercased tail, so an uppercase contains term loaded and then never matched. Build the text test schema from the literal it accepts and give anchors the lowercase one. Also drop a probe-banner early return that no bundled catalog reaches.
…s as plain rules The provisional-startup hold becomes a lastOf anchor with an all/none test, so its TypeScript scan goes. Title anchors drop their status field (every caller already gates on an idle title), and withoutClock keeps only the value a rule can set.
… into jinwoo/agent-state-rules-main-agents # Conflicts: # src/main/runtime/agent-state-rules/agent-state-rules-engine.test.ts # src/main/runtime/agent-state-rules/agent-state-rules-schema.ts
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Reviewed the commits pushed since the prior pullfrog review (7c90a13 → 724c74f): one refactor commit (dc74b4637f) plus two base-branch merges.
- Expressed Codex's provisional-startup hold as a plain rule —
codex.json'sprovisional_startupbecomes alastOf: "openai codex"anchor with anall/nonetail test, andcodex-provisional-startup.tsplus its named text-anchor finder are deleted. - Dropped the
statusfield from title anchors — the shared title classifier already gates every read onidle, soshowsIdleTitleAnchornow takes only the title. - Narrowed
withoutClockto the literalskipand required lowercasecontainsliterals in a text anchor'saftertest.
I traced the rule conversion against the deleted scan and they agree: both take the last openai codex, require model: loading after it, and treat any · after the loading word as the footer that ends the hold (· cannot fall between model: and loading, so the old "at or after the model start" search and the new post-loading regex describe the same span). showsIdleTitleAnchor has a single caller, which already returns early unless the classifier says idle, so dropping the parameter changes no verdict. No bundled file sets withoutClock: "believe", and the engine only ever compares against "skip". Ran the readiness census (218/218, baselines untouched) plus the rule-engine, title/text-anchor, tui-idle-evidence, terminal-wait-detection and quiet-Codex suites (244 tests across 6 files) — all pass.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 🧰 Additional context used📚 Code guidelines (2)No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (19)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 7 remain after this review. 📝 WalkthroughWalkthroughThe change expands agent-state rules to support screen, text, and title regions, adds bundled rules for more agents and unknown panes, and updates rule evaluation to use region-specific matchers. Terminal wait detection and TUI idle evidence now consume shared rule verdicts and trusted-screen metadata. Tests cover schema validation, rule matching, Codex readiness, title detection, and idle-title corroboration. Priority: ➖ Normal Merge Risk: ⚪ Minimal · up to The reviewed readiness paths preserve the examined behavior; no issue identified here needs to be resolved before merging. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to Readiness decisions are consolidated without an established weakening of the existing checks. Risk appears limited, but the consequences for uninspected callers remain unverified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description is detailed and covers the required change summary, rationale, testing, visual proof, review notes, and checklist. However, the Linked Issue section contains only Full details: Docstring CoverageExplanation Docstring coverage is 41.03% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 78 functions across 30 files. (4 skipped: 4 unsupported.)
✨ Finishing Touches 💡 2📝 Generate docstrings 💡
🛠️ Fix failing CI checks 💡
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
…les-main-agents # Conflicts: # src/main/runtime/agent-state-rules/agent-state-rules-catalog.ts # src/main/runtime/agent-state-rules/agent-state-rules-engine.test.ts # src/main/runtime/agent-state-rules/agent-state-rules-engine.ts # src/main/runtime/agent-state-rules/agent-state-rules-schema.ts # src/main/runtime/agent-state-rules/agent-state-text-anchors.test.ts # src/main/runtime/agent-state-rules/agent-state-text-anchors.ts # src/main/runtime/agent-state-rules/antigravity.json # src/main/runtime/agent-state-rules/blocked-text-layer.ts # src/main/runtime/agent-state-rules/cline.json # src/main/runtime/agent-state-rules/cursor.json # src/main/runtime/agent-state-rules/prime-agent.json # src/main/runtime/orca-runtime-start-tui-idle-visible-read-probe.ts # src/main/runtime/runtime-terminal-wait.ts # src/main/runtime/terminal-wait-detection.ts # src/main/runtime/tui-idle-evidence.test.ts # src/main/runtime/tui-idle-evidence.ts
…es' hold anchor Main (#24375) moved Codex's provisional-header check into codex.json's provisional_startup hold anchor and deleted codex-terminal-readiness.ts, so the launch readiness hold now asks showsHoldAnchor, as main's own settled check does.
…and census the zsh fixture Main (#24375) answers a name-only title from each agent's rule file ahead of the sustained-title lane, so gemini.json's name_title settled a launch readiness wait on the shell's auto-title while Gemini was still booting. A launch now asks quiet of every weak idle verdict, as that lane did. Main's readiness census requires a recorder for every runtime fixture; the zsh prompt recording is a non-agent control. Gemini's synthetic baseline is regenerated for this PR's stated change: a bare gemini title is no longer its rest mark, so name-only rows settle weak, and a fresh working or blocked status is no longer overridden.
…hem after readiness (step 1 of 7) (#24257) * feat(agent-launch): host-side prompt delivery for agent.launch The host's agent.launch typed any launch prompt into the shell as part of the launch command. A long or multi-line prompt then ran line by line in the shell, and an agent that never showed readiness or crashed at startup had nothing guarding where its text went. agent.launch now carries a prompt on the typed line only when the line stays one line, control-free and at most 512 bytes; otherwise the agent starts clean and the host pastes the prompt once the agent's own ready signal fires (bracketed paste plus its composer marker or a quiet render, read only after the shell's last hand-off, never while the pane's own shell is proven in front), with main's draft-paste bytes and an Enter 50 ms later. Orchestration worker starts wait on tui-idle as before. A replay-safe launch admits and claims its ledger row in one write, Qwen Code gets a second Enter, the desktop and phone share one launch-refusal classifier, and hosts advertise agent.launch.prompt-carry.v1. Split out of #23748, which moves the desktop source-control buttons onto this path. * fix(agent-launch): keep a short-lined multi-line prompt on a local zsh launch line, as main did #24257 moved every multi-line or over-512-byte prompt off the typed launch line and pasted it after readiness. The phone's AI buttons and review notes, whose multi-line prompts main typed whole into zsh, then reached Claude 0.5-3 s later and their RPC reply waited for the paste. The host now names the shell a local macOS or Linux line is typed into, the way the spawn picks it, and a multi-line prompt rides a zsh line when every line is at most 512 bytes and the whole line at most 8 KB. A real-zsh test types such a line through Orca's own ready barrier and startup write, including when a slow user config makes the write land early. Elsewhere the measured unsafe cases keep the paste: bash 3.2 runs multi-line lines piecemeal, fish drops an early multi-line write, and any shell loses a line over 1 KB written early. * test(agent-launch): keep the real-zsh launch-line test out of the Windows lane's gate scan The Windows lane registration check read `const ZSH_PATH = process.platform === 'win32'` (the head of a multi-line ternary) as a Windows-true flag, so `describe.skipIf(!ZSH_PATH)` looked like a Windows-only suite. The file is POSIX-only; the zsh lookup is now a function. * refactor(protocol): move the agent.launch capabilities into their own module Main's protocol-version.ts sits at the 300-line cap, so the prompt-carry capability pushed it over. The four agent.launch capabilities and their doc move to agent-launch-runtime-capability.ts, re-exported by name and spread into RUNTIME_CAPABILITIES at the same position; the advertised lists and every export are unchanged. * refactor(protocol): import the agent.launch capabilities from their own module `export *` from protocol-version left the four names undefined under the mobile recording loader, which resolves a relative import through a Proxy with no own keys, so 37 phone recordings lost agent.launchReplay. Importers now name agent-launch-runtime-capability directly; protocol-version only spreads its list. * refactor(agent-launch): drop the unshipped viewMode field and trusted local caller id Both were inert in step 1 and existed only for step 2. agent.launch will become a public plugin API, so every wire field is permanent once shipped; a top-level viewMode reads as "choose terminal vs chat", which the host decides. Step 2 introduces placement and view intent under a placement object instead. * fix(agent-launch): read Codex's provisional startup from the rule files' hold anchor Main (#24375) moved Codex's provisional-header check into codex.json's provisional_startup hold anchor and deleted codex-terminal-readiness.ts, so the launch readiness hold now asks showsHoldAnchor, as main's own settled check does. * fix(agent-launch): hold rule-file name titles to quiet for a launch, and census the zsh fixture Main (#24375) answers a name-only title from each agent's rule file ahead of the sustained-title lane, so gemini.json's name_title settled a launch readiness wait on the shell's auto-title while Gemini was still booting. A launch now asks quiet of every weak idle verdict, as that lane did. Main's readiness census requires a recorder for every runtime fixture; the zsh prompt recording is a non-agent control. Gemini's synthetic baseline is regenerated for this PR's stated change: a bare gemini title is no longer its rest mark, so name-only rows settle weak, and a fresh working or blocked status is no longer overridden. * fix(agent-launch): paste a launch prompt only when the launched agent is proven in front A launch pasted its prompt unless a shell was proven in the terminal's foreground, so any read that could not prove one let the prompt through. After an agent exited at startup, its shell turned bracketed paste on at the next prompt, readiness fired on it, and the prompt was typed into the shell: - macOS: a pane runs its shell under login, so the process-group fence's root was never the shell's group and never proved it; the cached foreground name could also still name the exited process. - Windows Git Bash and WSL: the shell-alone-in-its-job check never answers. Now one fresh read of the terminal's foreground decides: agent, shell or unknown. Only 'agent' lets a write through (paste, Enter, second Enter, reused panes too); 'shell' still drops a ready signal. A Windows host never proves the agent, so there the launch line carries the prompt at any size, as on main. * test(agent-launch): cover the Windows QA stub, a grok override that exits at once * fix(agent-launch): keep the local socket alive while a prompted launch waits for its agent A launch with a prompt now waits up to 60 s for the terminal agent to be ready before it writes the prompt, and reports not-delivered when the agent never is. The local runtime socket closes a connection idle for 30 s unless the request is a long poll, so a launch whose agent exited at startup lost its reply and the caller saw 'runtime closed the connection' instead of not-delivered. Classify a prompted agent.launch and agent.launchReplay as a long poll, as orchestration.workerStart already is for the same wait. * refactor(agent-launch): narrow the launch params by 'in' instead of a cast * fix(agent-launch): find a launched agent behind a wrapper that leads its process group A tcsh or nu launch line runs the agent from /bin/sh '<script>', and a wrapper script that does not exec its agent does the same: the wrapper leads the terminal's foreground process group and the agent is a member of it. The fresh foreground read names the group's leader, sh, so a prompted launch was refused or pasted late (M4Air tcsh: 2 of 4 not delivered, 2 pasted ~9 s late). Before that read, take the host's process-group observation as positive proof when it names the launched agent among the foreground group's members and is younger than a ready signal's quiet window. It never proves a shell. * fix(agent-launch): judge the foreground-group proof by when its capture began, not how long ps took The age the host stamps on a process-group observation runs from the start of its whole-machine ps, so on a loaded Mac a capture begun after the read was asked for still read as older than 1 s and the proof was dropped. Count an observation whose capture began after the read was asked for, less the window a shared capture is reused across. * test(agent-launch): keep the crash-guard live test out of the Windows lane's gate scan The Windows-lane registration scan read the const assigned from a platform check as a Windows-only gate, though the suite runs everywhere but Windows; find zsh in a function instead, as the real-zsh typed-line test does. Under load the fresh foreground scan can fail to answer, which lets the shell's prompt settle readiness (2 of 4 paired runs). The guard still refuses that write, so assert the refused write, the property that must always hold. * perf(agent-launch): read a local pane's foreground from its own terminal, not the whole process table The foreground read that gates every launch paste ran the daemon's inspectProcess capture and then a fresh scan, each a whole-machine ps; the fresh one also waits for any capture already running before it starts its own. Measured here at load 5: 1.2 s a read (M4Air QA: 3.4-5.0 s, and worker starts 17.6-32 s against main's 9-12 s at load 25-84). On a local macOS or Linux host, take the pane's root pid from the provider's session inventory and run one ps limited to that pane's terminal. Its foreground process group decides: the launched agent or any non-shell member is the agent (a wrapper that did not exec its agent leads the group), a group of shells alone is the shell. Same pane, same verdict: 2.7 ms a read. SSH hosts keep the relay's observation and name. * test(mobile): re-measure the web app's script sweep after agent.launch's capabilities moved out of protocol-version The mobile web bundle check failed at 124 assets against a ceiling of 123. Main already sat exactly on that ceiling: its sweep table read 69 scripts at 16 routes while the tree builds 73, the whole margin of 4. This branch imports the agent.launch capabilities from their own module, so protocol-version is no longer pulled into the root layout and four other routes. That moves which routes share which modules, and the Qoder capability module, imported by protocol-version and the AI-vault resume path, no longer shares an importer set with anything, so it gets a chunk of its own: 74 scripts. The fence says to re-derive the bound rather than raise it, so the sweep is re-measured on this head (every prefix of the sorted route list). The worst route now adds 10 scripts (session), not 9, which moves the pinned shell crossing from 32 to 30 routes; main re-measured on its own lands on the same crossing. * fix(agent-launch): a worker's brief needs its agent found in front, and Grok's start answers on its composer A paired-server worker start whose agent exited at startup typed its brief into the server's shell, which ran it: the idle wait can settle on a shell back at its prompt, and the brief was written with no foreground read. Both worker-start paths now check before each brief write, as a launch prompt is checked: on a host that can find the agent in front it must be there; on one that cannot (Windows) a shell proven in front still refuses, and anything else writes as before. A Grok worker start waited ~10 s more than main: its only rest signal is its bare name, which a launch holds to quiet output, and Grok animates its logo for ten seconds after its composer glyph. A worker start for an agent whose rest signal is its bare name and whose composer draws a marker (Grok, DSH, mimo-code) now also answers on that marker, whichever comes first.
…ole (step 2 of 7) (#23962) * feat(agent-launch): host-side prompt delivery for agent.launch The host's agent.launch typed any launch prompt into the shell as part of the launch command. A long or multi-line prompt then ran line by line in the shell, and an agent that never showed readiness or crashed at startup had nothing guarding where its text went. agent.launch now carries a prompt on the typed line only when the line stays one line, control-free and at most 512 bytes; otherwise the agent starts clean and the host pastes the prompt once the agent's own ready signal fires (bracketed paste plus its composer marker or a quiet render, read only after the shell's last hand-off, never while the pane's own shell is proven in front), with main's draft-paste bytes and an Enter 50 ms later. Orchestration worker starts wait on tui-idle as before. A replay-safe launch admits and claims its ledger row in one write, Qwen Code gets a second Enter, the desktop and phone share one launch-refusal classifier, and hosts advertise agent.launch.prompt-carry.v1. Split out of #23748, which moves the desktop source-control buttons onto this path. * fix(agent-launch): keep a short-lined multi-line prompt on a local zsh launch line, as main did #24257 moved every multi-line or over-512-byte prompt off the typed launch line and pasted it after readiness. The phone's AI buttons and review notes, whose multi-line prompts main typed whole into zsh, then reached Claude 0.5-3 s later and their RPC reply waited for the paste. The host now names the shell a local macOS or Linux line is typed into, the way the spawn picks it, and a multi-line prompt rides a zsh line when every line is at most 512 bytes and the whole line at most 8 KB. A real-zsh test types such a line through Orca's own ready barrier and startup write, including when a slow user config makes the write land early. Elsewhere the measured unsafe cases keep the paste: bash 3.2 runs multi-line lines piecemeal, fish drops an early multi-line write, and any shell loses a line over 1 KB written early. * test(agent-launch): keep the real-zsh launch-line test out of the Windows lane's gate scan The Windows lane registration check read `const ZSH_PATH = process.platform === 'win32'` (the head of a multi-line ternary) as a Windows-true flag, so `describe.skipIf(!ZSH_PATH)` looked like a Windows-only suite. The file is POSIX-only; the zsh lookup is now a function. * refactor(protocol): move the agent.launch capabilities into their own module Main's protocol-version.ts sits at the 300-line cap, so the prompt-carry capability pushed it over. The four agent.launch capabilities and their doc move to agent-launch-runtime-capability.ts, re-exported by name and spread into RUNTIME_CAPABILITIES at the same position; the advertised lists and every export are unchanged. * refactor(protocol): import the agent.launch capabilities from their own module `export *` from protocol-version left the four names undefined under the mobile recording loader, which resolves a relative import through a Proxy with no own keys, so 37 phone recordings lost agent.launchReplay. Importers now name agent-launch-runtime-capability directly; protocol-version only spreads its list. * refactor(agent-launch): drop the unshipped viewMode field and trusted local caller id Both were inert in step 1 and existed only for step 2. agent.launch will become a public plugin API, so every wire field is permanent once shipped; a top-level viewMode reads as "choose terminal vs chat", which the host decides. Step 2 introduces placement and view intent under a placement object instead. * fix(agent-launch): read Codex's provisional startup from the rule files' hold anchor Main (#24375) moved Codex's provisional-header check into codex.json's provisional_startup hold anchor and deleted codex-terminal-readiness.ts, so the launch readiness hold now asks showsHoldAnchor, as main's own settled check does. * fix(agent-launch): hold rule-file name titles to quiet for a launch, and census the zsh fixture Main (#24375) answers a name-only title from each agent's rule file ahead of the sustained-title lane, so gemini.json's name_title settled a launch readiness wait on the shell's auto-title while Gemini was still booting. A launch now asks quiet of every weak idle verdict, as that lane did. Main's readiness census requires a recorder for every runtime fixture; the zsh prompt recording is a non-agent control. Gemini's synthetic baseline is regenerated for this PR's stated change: a bare gemini title is no longer its rest mark, so name-only rows settle weak, and a fresh working or blocked status is no longer overridden. * fix(launch): stage long or multi-line launch lines so they arrive whole A launch line that is long or has several lines could lose lines or wedge a shell that is still starting, because it was typed into the terminal before the shell could read it whole. The terminal host (local daemon, and the SSH relay) now writes such a line to a script file and types one short line that runs it, for every POSIX shell; a shell that cannot read Orca's quoting runs Orca's own agent lines through /bin/sh. If the script cannot be written, the terminal says so. The SSH background launch path no longer types the line from the renderer; the relay stages it like any other terminal. Bumps the terminal daemon protocol to 40 (main took 39); a v39 daemon keeps its sessions and gets no staged line. Restacked onto #24257 from the version reviewed on top of #23748; carries none of #23748's changes. * fix(launch): run a staged launch line as its own job in fish and ksh fish and ksh run the commands of a sourced file in the shell's own process group, so a staged agent was not a job: Ctrl-Z was dropped (a typed line stops), and the shell-in-front check saw the shell's group in the foreground while the agent ran. fish now runs the script with `eval (string collect < '<path>')`, which runs it as if typed and leaves the shell's job-control mode alone. ksh and mksh run a long Orca-built line through `/bin/sh '<path>'`, a real job; a long command the user wrote is typed as before. The real-shell test now asserts the agent's process group is its own and is the terminal's foreground group. The staging rule also reuses hasControlByte and the 512-byte budget from startup-line-prompt-carry so the carry and staging limits cannot drift. * fix(agent-launch): paste a launch prompt only when the launched agent is proven in front A launch pasted its prompt unless a shell was proven in the terminal's foreground, so any read that could not prove one let the prompt through. After an agent exited at startup, its shell turned bracketed paste on at the next prompt, readiness fired on it, and the prompt was typed into the shell: - macOS: a pane runs its shell under login, so the process-group fence's root was never the shell's group and never proved it; the cached foreground name could also still name the exited process. - Windows Git Bash and WSL: the shell-alone-in-its-job check never answers. Now one fresh read of the terminal's foreground decides: agent, shell or unknown. Only 'agent' lets a write through (paste, Enter, second Enter, reused panes too); 'shell' still drops a ready signal. A Windows host never proves the agent, so there the launch line carries the prompt at any size, as on main. * test(agent-launch): cover the Windows QA stub, a grok override that exits at once * fix(agent-launch): keep the local socket alive while a prompted launch waits for its agent A launch with a prompt now waits up to 60 s for the terminal agent to be ready before it writes the prompt, and reports not-delivered when the agent never is. The local runtime socket closes a connection idle for 30 s unless the request is a long poll, so a launch whose agent exited at startup lost its reply and the caller saw 'runtime closed the connection' instead of not-delivered. Classify a prompted agent.launch and agent.launchReplay as a long poll, as orchestration.workerStart already is for the same wait. * refactor(agent-launch): narrow the launch params by 'in' instead of a cast * fix(agent-launch): find a launched agent behind a wrapper that leads its process group A tcsh or nu launch line runs the agent from /bin/sh '<script>', and a wrapper script that does not exec its agent does the same: the wrapper leads the terminal's foreground process group and the agent is a member of it. The fresh foreground read names the group's leader, sh, so a prompted launch was refused or pasted late (M4Air tcsh: 2 of 4 not delivered, 2 pasted ~9 s late). Before that read, take the host's process-group observation as positive proof when it names the launched agent among the foreground group's members and is younger than a ready signal's quiet window. It never proves a shell. * fix(launch): type a plain Orca agent line as is in tcsh and nu In tcsh and nu, every Orca-built agent line ran through `/bin/sh '<script>'`, so the agent was a child of sh in sh's process group. When the prompt was pasted after the agent was ready, the paste guard read sh in front and, on a loaded Mac, reported the prompt not delivered (4/4 live runs in tcsh). Now only a line that needs it goes through `/bin/sh`: one over 512 bytes, with a control byte, or with a character those shells would not read literally (`!`, backslash, `"`, `$`, backtick). A plain line such as `claude '--dangerously-skip-permissions'` is typed as on main, so the agent is the shell's own job. * fix(agent-launch): judge the foreground-group proof by when its capture began, not how long ps took The age the host stamps on a process-group observation runs from the start of its whole-machine ps, so on a loaded Mac a capture begun after the read was asked for still read as older than 1 s and the proof was dropped. Count an observation whose capture began after the read was asked for, less the window a shared capture is reused across. * test(agent-launch): keep the crash-guard live test out of the Windows lane's gate scan The Windows-lane registration scan read the const assigned from a platform check as a Windows-only gate, though the suite runs everywhere but Windows; find zsh in a function instead, as the real-zsh typed-line test does. Under load the fresh foreground scan can fail to answer, which lets the shell's prompt settle readiness (2 of 4 paired runs). The guard still refuses that write, so assert the refused write, the property that must always hold. * perf(agent-launch): read a local pane's foreground from its own terminal, not the whole process table The foreground read that gates every launch paste ran the daemon's inspectProcess capture and then a fresh scan, each a whole-machine ps; the fresh one also waits for any capture already running before it starts its own. Measured here at load 5: 1.2 s a read (M4Air QA: 3.4-5.0 s, and worker starts 17.6-32 s against main's 9-12 s at load 25-84). On a local macOS or Linux host, take the pane's root pid from the provider's session inventory and run one ps limited to that pane's terminal. Its foreground process group decides: the launched agent or any non-shell member is the agent (a wrapper that did not exec its agent leads the group), a group of shells alone is the shell. Same pane, same verdict: 2.7 ms a read. SSH hosts keep the relay's observation and name. * test(mobile): re-measure the web app's script sweep after agent.launch's capabilities moved out of protocol-version The mobile web bundle check failed at 124 assets against a ceiling of 123. Main already sat exactly on that ceiling: its sweep table read 69 scripts at 16 routes while the tree builds 73, the whole margin of 4. This branch imports the agent.launch capabilities from their own module, so protocol-version is no longer pulled into the root layout and four other routes. That moves which routes share which modules, and the Qoder capability module, imported by protocol-version and the AI-vault resume path, no longer shares an importer set with anything, so it gets a chunk of its own: 74 scripts. The fence says to re-derive the bound rather than raise it, so the sweep is re-measured on this head (every prefix of the sorted route list). The worst route now adds 10 scripts (session), not 9, which moves the pinned shell crossing from 32 to 30 routes; main re-measured on its own lands on the same crossing. * fix(agent-launch): a worker's brief needs its agent found in front, and Grok's start answers on its composer A paired-server worker start whose agent exited at startup typed its brief into the server's shell, which ran it: the idle wait can settle on a shell back at its prompt, and the brief was written with no foreground read. Both worker-start paths now check before each brief write, as a launch prompt is checked: on a host that can find the agent in front it must be there; on one that cannot (Windows) a shell proven in front still refuses, and anything else writes as before. A Grok worker start waited ~10 s more than main: its only rest signal is its bare name, which a launch holds to quiet output, and Grok animates its logo for ten seconds after its composer glyph. A worker start for an agent whose rest signal is its bare name and whose composer draws a marker (Grok, DSH, mimo-code) now also answers on that marker, whichever comes first. * test(startup-staging): expect the CR that submits a typed launch line since #23672

Stacked on #24348 (the agent state rule engine). Review that first; this PR's base is its branch.
ELI5
Orca decides whether an agent in a terminal is ready for input, busy, or waiting on a question. #24348 moved four agents' rules into small JSON files that one shared engine reads. This PR moves the six agents people use most (Codex, Claude, OpenCode, Pi, OMP and Gemini) the same way. Nothing the user sees changes.
What Changed
terminal-wait-detection.ts,tui-idle-evidence.tsandcodex-terminal-readiness.ts. It included title prefixes (Claude's✳, Gemini's◇, Pi'sπ -, OpenCode'sOC |), hard-coded agent lists (which agents' bare name only counts once quiet, which agents read a quiet ready screen), and a set of Codex-only branches.src/main/runtime/agent-state-rules/(codex.json,claude.json,gemini.json,pi.json,omp.json,opencode.json,opencode2.json, plusunknown-pane.json). The agent-specific branches are deleted, andcodex-terminal-readiness.tsis gone.How it works. The engine shape is the same ("when this region shows this, the answer is that"). The new vocabulary is added as entries in its existing closed lists:
title(the status the shared title classifier gave the pane title) andtext(one of the file's own ready text anchors, found with no blocker after it). A screen rule can also name a predicate, an engine scan for a shape rows can't describe (Codex's header and composer).withoutClock: "skip": a strong rule that waits for quiet normally counts at once on a pane with no output clock (restored or adopted). This marks one that must not (Codex's composer).textAnchors) can now read the title: a test (or named predicate) on a title the shared classifier already calls idle. Like text anchors, title anchors apply to every pane, because today an explicit idle title settles a wait whatever the pane launched as, including adopted panes with no known agent. Two new answers:livemeans the agent's UI is up, which proves an earlier dialog was answered, but not that it is ready (Codex's header). It replaces the oldworkinganchor answer, which the engine treated identically (Cursor's busy prompt now answerslive).holdmeans the agent is up but not taking input yet, so no text may settle a wait (Codex 0.157'smodel: loadingheader).profile.screenSource(trustedorlive): the screen a file's rules read. Codex keeps the live screen it was built against; Cline, Antigravity and Prime Agent keep the trusted grid. This also splits "reads the trusted grid", which decides the probe and which screen is read, from "has rules".unknown-pane.json: rules for panes whose agent Orca doesn't know. Today such a pane settles on Codex's header on the live screen at once, so that rule lives here.Per agent:
model: loadingwith no footer·after it) are text anchors (data). Header-ready and composer-ready stay code, as named screen predicates: they find the header box or the last empty composer anywhere on the screen and look at the row above it, which the row-block format cannot state. A text rule, the screen rules and the name-only title rule are data.π -anchor inpi.json; OpenCode's reuses the sharedisOpenCodeNativeTitleas a named predicate, because presence detection reads the same marker). Whether a name-only title must wait for quiet (the terminal wait --for tui-idle returns satisfied:true in ~0s while an agent TUI is actively working #6011 handling) is each agent'sidle_title/name_titlerule.The "a later live prompt cancels an earlier blocker" rule now reads only rule-file anchors, plus Muse, which moves in part (b2).
Why
This keeps each agent's readiness in one readable place and makes the remaining agents a mechanical move. I kept the existing ranking order in
evaluateTuiIdle(11.5 of the design: copy today's order exactly), so each rule's answer slots into the ranking step it replaces. I did not rewrite everything as one priority list, because that would change behaviour; that is a later cleanup. Anything that cannot be data stays code, but under a name that a rule file references, never as an agent check inside the engine.Linked Issue
Refs STA-9098 (part b1: the main agents, with no behaviour change).
Visual Proof
N/A: no UI or behaviour change. The readiness census (#24336) replays every recorded agent session plus a synthetic matrix over all agents, and its committed baselines are untouched and pass.
Testing
pnpm test src/main/runtime/readiness-census: 218/218 passed, three runs, about 20 s each (same as before). No baseline file changed.Mutation check. Each mutation fails the census, a unit test or both:
withoutClock: skip(15 census), no startup hold (24 census + 10 unit), noliveheader anchor (5 unit), text rule not quiet (11 + 19), screen source set to trusted (7 + 2).✳anchor (5 + 3).π -anchor (2 census + 1 unit). OMP: name-only title not quiet (3 census + 1 unit).live(1 unit). Codex: noliveheader anchor (4 transcript + 1 unit). EveryscreenSourceread as trusted (14 census + 2 unit).holdsReadyTextToQuiet) removed: no test caught it, so a new unit test pins it.◇anchor (1 census); name-only title quiet (1 unit).The first version read the screen up to three times per evaluation on unknown panes, which made the census about 50% slower. Each evaluation now reads the screen once, and the census time is back to baseline.
New unit tests: the region schema (what it rejects and accepts), region skipping, named screen predicates, settled text rules,
withoutClock, the Codex anchors (settle, live, hold), the unknown-pane header, and title anchors.pnpm test src/main/runtime src/shared: all pass exceptomp-draft-launch-shell.test.ts(fish). It fails locally because of my own shell config and doesn't touch this code.pnpm tc:node, oxlint on changed files andpnpm run check:code-quality:changed: clean.Platforms: macOS locally. The change is platform-neutral string matching. SSH is unaffected: detection runs on the execution host, as before.
I manually tested these changes locally
Automated tests added/updated, or explained why not below
Review
Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
No security, platform, SSH, mobile or wire-compatibility impact: same verdicts, same blocked reasons. Left for part (b2), unchanged here:
startup-dialog-blocked-signals.ts). The generic "press enter" prompt yields only to dialogs found before it. Moving these dialogs into anchors changes that order for the Cursor menu.ready|idle|donetitle word. It covers every agent's synthetic<Agent> readytitle, and b2 agents depend on it.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)