Repository navigation
Standalone cua: native runtime, Keychain secret substitution, existing Chrome profiles - #1
Conversation
…er (M1) Adds scripts/probe-runtime.mjs, a read-only probe that launches the pinned runtime from a scratch CUA_HOME with an allowlisted environment, completes the MCP handshake, runs cua.getState() through a no-op trusted sky wrapper, calls turn_ended, and records signatures, process ancestry, the native helper that served, and whether a probe-owned unix socket is reachable from the trusted worker and from untrusted cells with and without a sandbox socket allowance. Pure helpers are unit-tested under the new Node test runner. Sanitized findings are in docs/evidence/m1-runtime-portability.md.
Adds the checked-in 26.928.40906 darwin-arm64 pin and src/runtime: strict pin parsing and installed-runtime resolution, verified archive or official-URL acquisition with staging, ditto extraction of only the pinned components, layout/vendor-manifest/IPC/codesign team checks, atomic activation and `runtime use`, a passive doctor that separates installed-runtime health from live-helper and permission evidence, and the allowlisted launch record with CUA_REPL_ENABLED_SURFACES=computer. bin/cua.mjs routes install, doctor and runtime use. Node-only tests cover mechanics on ditto-built fixture archives; real-archive and download installs are recorded in docs/evidence/m2-installer.md.
… and use (M2 review) An existing release tree is never replaced or deleted: a verified one is a no-op, a damaged one fails installed_release_invalid with offline recovery guidance, and a target that is not a real directory with a valid install record (file, symlink, empty dir, bad install.json) fails target_occupied untouched. Placement claims the target with an exclusive mkdir before the rename. resolveRuntime, runtime use and doctor validate the pin against the host. A JSON-null vendor manifest is a failed check, and doctor's human verdict says live capability is unverified while checks are blocked.
`cua serve` resolves the installed runtime, launches it through buildLaunch in its own process group and an owned 0700 run directory, and serves one connection with a random session ID. The model sees js, js_reset, end_task and secrets_list (unavailable until M4); turn_ended and js_add_node_module_dir stay private. src/mcp/task.mjs is the Idle/Active/Ending/Failed/Closing state machine: serialized work stamped with the task as turn ID, completion only after quiescence plus an acknowledged turn_ended within one 5 s deadline, terminal rejection and exactly-once settlement on any uncertainty, and no revival from late replies. src/mcp/server.mjs routes JSON-RPC with proxy-owned upstream IDs, forwards cancellations and elicitation answers unqueued, keeps MIME correction and approval persistence. src/mcp/upstream.mjs tears down the owned process group (EOF, SIGTERM, SIGKILL within a 5 s budget) and never signals the helper. cua-shim.mjs becomes a thin entry for `cua serve`; the CLI moves to src/cli.mjs. The plugin drops its Stop/SubagentStop turn_ended hooks and the CODEX_HOME override; verify.mjs checks the four-tool surface, task IDs and relocated executables live. Evidence: docs/evidence/m3-mcp-lifecycle.md.
…handling after review
…nd close (M3 review) The runtime's process group is now led by a server-owned anchor (src/mcp/anchor.mjs) that starts the vendor launcher inside the group and stays alive until the last signal. Group signals are sent only while the anchor's exit is unobserved; if its identity is lost, teardown signals nothing and reports cleanup unconfirmed. Teardown waits for the launch before judging membership, confirms SIGKILL against the members listed while the anchor held the group, and leaves no timer behind. Work is dispatched synchronously with its in-flight transition, so a cancel in the same input chunk is forwarded. Losing the client output enters the Closing path like EOF. After the 1 s flush budget the transport is destroyed, and `cua serve` exits after its owned cleanup even if something else holds the loop. Host notes, end_task and the README say that cancellation does not stop a running cell, js_reset waits for it, timeout_ms bounds runaway work, and native cleanup after forced teardown is unconfirmed. The package now ships the helper verify.mjs imports.
…ting (M3 re-review) The anchor now takes `launch` and `stop` messages and acknowledges `stop` only after any launch has been handed to the kernel. Teardown judges group emptiness only after that acknowledgement, so no runtime can be launched after the group was accepted as empty. Confirmation is read-only and covers the whole group. The anchor's exit must be observed, then `pgrep -g` must list the group empty. Failed group signals, a surviving anchor or member, and a failed or timed-out listing all report unconfirmed, with a reason. Nothing is signalled after the final signal or once the anchor's exit has been observed. Every enumeration is bounded by the remaining budget, and its process is killed on timeout. The escalation collapses to one path: release the anchor when only it is left, otherwise SIGTERM then SIGKILL.
…er connection over a private broker (M4) native/keychain: production cua-keychain (hidden terminal set, list, confirmed remove, broker over a 0600 unix socket with a stdin-delivered capability token, framed and bounded wire) and test-owned in-memory test host and pty driver. cua secrets set|list|remove route to it; serve starts one broker per connection before the runtime and stops it with the runtime; secrets_list lists labels through it; doctor reports helper build and signing. npm run build:helper and npm run test:helper exercise the actual helper; npm test stays Node-only; an opt-in live roundtrip touches one disposable Keychain item.
…p secrets usage errors value-free and harden reply decoding (M4 review) - Restoring the terminal flushes unread input, and an early stop (overlong paste, cancel) first drains what is still arriving, so no hidden byte reaches the next reader or is echoed. - The server records the broker socket's device and inode once the helper is ready and removes only that socket; a broker that never became ready, or a replaced path, is left alone. - cua secrets argument errors are fixed messages, never parser text. - The broker client settles any connect/attach/write failure once as disconnected and closes the stream; replies must be valid UTF-8 and exactly one frame.
…nside the trusted sky service (M5) The production trusted sky service (src/services/sky.mjs) is registered for every connection and delegates to the vendor sky service; only the whole text of paste/type_text or value of set_value in their pinned shapes expands, read from the connection's broker over nodeRepl.nativePipe. Invalid or unknown labels, denied or locked Keychain, secrets off or unavailable and unsupported shapes fail before input; a failure after substitution returns a fixed value-free diagnostic. The broker client no longer subscribes to an event the real nativePipe stream rejects. Trusted code is now the vendor modules plus src/services and src/secrets; state/codex is no longer trusted. Adds the opt-in live sentinel probe (scripts/probe-secrets.mjs) and its evidence.
…ole (M5 review) A reference in a request whose method only coerces to paste/type_text/set_value (the vendor looks methods up by property key) or whose fields are not the pinned primitive types now fails closed as unsupported_secret_shape before any read. The live probe's file scan streams every file whole with chunk overlap and fails on unread files instead of skipping files of 4 MiB or more.
…ilure, record unreachable scan roots, and pin test hosts and stop-ack ordering
- doctor: missing files or invalid vendor signatures point at the shared offline recovery (stop servers, remove the
release, reinstall) since install refuses to repair in place
- broker close: an endpoint unlink failure (EACCES) returns {confirmed:false, reason} instead of rejecting
- leak scan: a root behind an inaccessible ancestor is unread; only ENOENT means absent
- runtime-install tests pass the fixture host to resolve/use as well as install
- upstream: a controlled-ordering test that enumeration never judges the group empty before the anchor's stop ack
node_repl records an accepted session approval under the connection's random session id, which no later connection can use; the file now goes with its connection. Other sessions' files are left alone.
…it scenarios, and package the helper sources - scripts/accept-native.mjs: per-item PASS/FAIL/BLOCKED report for acceptance 1-10 (suites, install/reinstall, doctor, verify, lifecycle probe, release-gate inventory, packaging, clean clone of HEAD); metadata only - --live-keychain runs scripts/probe-secrets.mjs, which now also proves fail-closed references (secrets off, no broker) at the controlled target before any input - --live-textedit drives one disposable TextEdit document through cua serve, accepting only the exact TextEdit app approval for the session; combined with --live-keychain it types a disposable secret into it - package files carry the Keychain helper sources and build script; README documents standalone install, plain MCP registration, helper signing and acceptance
…r's pinned shapes The vendor client's FunctionAgentTransport adds client_timeout_ms to every command it sends (the locator's timeoutMs when positive, else undefined). The pinned fill and tab-action shapes omitted it, so the live C2 fill of a secret reference was refused as unsupported_secret_shape (failing closed, nothing entered). It is now an optional positive integer in both shapes; any other value still fails closed before a read.
…closed at the fill on the transport's client_timeout_ms
…p and replaced, doctor names cua's host
…Chrome, round trip blocked by the stale binding, restore verified byte-for-byte
…place gate's host launch and restore
…el mapping proven, 17/17 PASS, restore intact
…onnection, the register undo and the hash-verified restore
…orts, and C3's remove/re-add on the real registry
…s the runtime down instead of throwing
… a survivor cannot hold the process open
…keeps it or register publishes it
…ere first, so the plugin's copy finds it
… as an excluded count
… is unchanged since discovery began
…, refusing registration_contended while another run holds it
…truncated snapshot as contention
…cation and --replace behaviour changes, the remaining narrow races as debt
|
Independent panel review (review-code, max) over All ten are fixed in
Behaviour changes worth noting: |
|
Re-review of the fix range |
Summary
Standalone
cua: an MCP server that lets Claude Code drive OpenAI'scua_replwithout the Codex/ChatGPT desktop app running, with Keychain-backed secret substitution and the user's existing Chrome profiles through the original OpenAI extension route.Spec and record:
docs/doperpowers/specs/2026-10-02-standalone-cua-design.md(Progress, Decision Log, Surprises, Outcomes & Retrospective). Execution reports:2026-10-02-standalone-cua-execution-report.md(A+B) and2026-10-03-phase-c-execution-report.md(C). Evidence per milestone underdocs/evidence/.Phase A — standalone native runtime (M1–M3, M6)
cua installextracts the pinned official release archive (sha256-verified) into~/Library/Application Support/cua/runtimes/<release>/, keeping signatures and sandbox intact;cua doctorre-verifies.cua serveis a per-connection MCP server over the vendornode_replwith a server-owned task id,end_task, and fail-closed teardown.Phase B — secret substitution (M4–M5)
cua-keychainhelper (SecItem) behind a secure TTY prompt;cua secrets add|list|remove.{{secret:<label>}}references inpaste/type_text/set_value(native) andplaywright_locator_fill/tab_ax_action(browser). The REPL never sees the value. Live round trips into TextEdit and into a Chrome page pass with no value in the transport, stderr, screenshots or state.Phase C — existing Chrome profiles (M7–M13)
cua loginin its private CODEX_HOME.cua profiles add|bind|remove,profiles_listtool):personal/work/school→ Chrome profile directories; bind by the user's explicit pick (vendor enrichment never labels a backend on this Mac).cua chrome register [--replace] | unregister: place the release's own Chrome plugin host, replace native-messaging manifests only on explicit--replacewith per-browser backups, and restore byte-for-byte (hash-verified). Live: Chrome launched cua's host; round trip 17/17 through it; all manifests restored to the pre-gate hash.scripts/accept-chrome.mjs --all: C1–C7 PASS on this Mac.Verification
npm test341/341; helper suites Swift 55 + Node 7; probe suites 42/42, 11/11, 15/15; clean clone passesnpm pack --dry-run.reviewer-highreview, all fix waves landed.Known limits / residue
profiles liststill reports it ready until rebound (tracked residue).wip/m8-playwright-transportholds the parked login-free alternative.c5e0e27) carries part of a concurrent spec edit; noted in the Decision Log.