Repository navigation
Phase E: remote control of a user's Mac (HTTP server mode, launchd agent, relay) - #52
Merged
Merged
Conversation
…nt by --mcp-config, the GUI-session vehicle for the LAN proof
…state readable through ioreg
…eep, signals and one connection
…routing, small resumability, idle, cap and eviction
…ith the agent lock; root package-lock.json
…only streams that carried an id)
…pped before its first response can be resumed
…pending server requests busy only while a stream is open, cancellation keeps a dispatched request's route
…equests busy only with a stream open, cancellation ends only a withdrawn request's stream, release failures logged, listener errors logged
…e server/connection import cycle)
…vanished client does not keep the session busy
…ion and 2025-11-25 (the live client's first contact was refused)
…ssion negotiated with its runtime
…tener; claude -p leaves its session to the idle close
…over cua's own plist reader src/remote/launchd.mjs writes ~/Library/LaunchAgents/com.ssfskim.cua.agent.plist by templating with XML escaping, checks it by reading it back, and loads it with launchctl bootstrap gui/<uid> (an installed job is booted out and waited for first); status reads the plist and launchctl print. src/remote/console.mjs reads the IORegistry root from ioreg -a (IOConsoleUsers, IOConsoleLocked): no compiled helper. launchctl, the user home and the registry read are parameters, so the tests never touch the real launchd domain, LaunchAgents or console.
…p status, cua agent install|uninstall|status js and js_reset over HTTP read the console and answer the tool error console_locked while this user's session is off the console or locked (CUA_AGENT_CONSOLE_CHECK=off turns it off; an unreadable console lets the call through); messages reach a session's connection in POST arrival order while a call waits for the check. Doctor gains agent.installed, agent.running, agent.enrolled and agent.console, and the status skip (never fails ok, never counted as blocked).
…ting 0, agent.console skips on an unenrolled Mac; acceptance 4 observation
…ps on a Mac never enrolled, server requests and their answers in the agent log The launchd job restarts a crash or a refusal but not a deliberate stop (exit 0); cua's plist reader takes a KeepAlive boolean or a dictionary of conditions. On a Mac never enrolled with no job, agent.console reads skip like the other three rows and the console is not read. The HTTP layer logs each server-initiated request when it reaches the client (method and id) and its answer (accept, decline, cancel, result or error, and the wait), never content. plist.mjs drops an unused callback parameter.
…, the job's console setting, a light address module parsePlist refuses a character reference past Unicode as plist_invalid and keeps whitespace-only <string>/<key> text; agent status and doctor report an unreadable plist path as invalid (agent.installed fail with the error code). agent.console reads CUA_AGENT_CONSOLE_CHECK from the installed job's environment when there is a job, and uses the seam's uid for launchd and the console alike. parseAddress moves to src/remote/address.mjs and surfacesFrom to src/mcp/surface.mjs, so launchd.mjs and doctor no longer load the HTTP stack; install refuses port 0. One isDict in plist.mjs. runAgent takes a createHttp seam, and a test pins that it wires the real checkConsole by default.
…est (hashes checked before the device map, 4001/4003, ping with two-miss close)
…handler, watchdog, 1-30 s backoff, stop on 4001/4003), both paths served together, ws loaded only on the relay path; relay README
…dler's stream and its answer waits for a resume
…fic bounds, no-transform, refused upgrade sockets destroyed, install refuses --relay without ws)
…ompleted streams, 4 MB request and 32 MB unsent-response bounds, no-transform on SSE, install refuses --relay without ws, a stop failure never hides the refusal; test hardening
…drops empty-data events, so the in-flight replay hung)
…, so an SSE-normalising proxy keeps it and the client records its id; the relay disconnect test holds with a 1 ms grace; http.mjs lines re-wrapped
…ME Remote control section, relay README rotate step
… GET replaces, pending approvals bounded by their call, wss relay URLs, relay endpoint hint, agent limits into the job)
…); newer GET replaces the standing stream; pending approvals bounded by their call; abandoned mid-task sessions evictable after 60 s; relay URLs wss: or loopback ws:
…how suggest the relay endpoint and say when the job needs install for --relay; doctor fails a relay URL the agent would refuse
…Ls, enroll's relay endpoint line, CUA_AGENT_* set at agent install, abandoned-session eviction; evidence: the LAN address was the mini's en0, not its tailnet address
…ons, connectRelay target)
…gh the relay, on the final code
…tried, rotation ends open sessions, the exhausted-GET eviction case recorded)
…ed, never thrown; a rotated client credential ends every open session; one log line and one terminate per relay URL change
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This was referenced Oct 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #11
Phase E of
docs/doperpowers/specs/2026-10-06-remote-and-linux-design.md. A Mac enrolled withcua remote enrolland runningcua agent installgives a remote agent (for example Claude Code in a cloud VM) the samecua_repltool surface it has locally. It is served over MCP Streamable HTTP, either on the Mac's own address (--http) or throughcua-relay(relay/), which the Mac dials out to.What it includes:
retry:hint and a 90 s replay grace, so a call in flight across a relay restart is delivered byLast-Event-ID.KeepAlive {SuccessfulExit: false}.agent.installed,agent.running,agent.enrolledandagent.console, plus askipstatus.console_lockedrefusal while the screen is locked.The design, every decision taken during execution, and what the live runs found are in the spec's Decision Log, Surprises and Outcomes & Retrospective. The run is reported in
docs/doperpowers/specs/2026-10-06-phase-e-execution-report.md. Phase F (Linux) branched from E1's4595f84and merges after this.Validation Evidence
npm testat 5c6310f gives# tests 635 / # pass 635 / # fail 0(main's baseline is 515/515).node_modules:npm testin agit archive HEADcopy gives# tests 635 / # pass 607 / # fail 0 / # skipped 28. Each skip says "needs the ws package: run npm ci". This is the plugin-copy condition:wsis loaded only on the relay path.docs/evidence/2026-10-06-phase-e-remote-acceptance.md. Highlights:initializereturns 200application/jsonwith anMcp-Session-Id, andtools/listlists the five tools.initializecarrying a session header, 400.DELETEreturns 200, after which the session id returns 404 and itsrun/entry is gone.claude -p --strict-mcp-config --mcp-confignaming the servercua_repl:schoolprofile was bound, a tab opened on this repo's page, the title read, and the tab closed.Allow Computer Use to use "Calculator"?. Accepting it let the call proceed.agent.*rows pass.elicitation/create … answered accept after 90 msand… 264 ms.DELETE.agent.console fail, andjsis answeredconsole_locked.cua-relaybehind a public ngrok TLS tunnel:js, the agent logsconnection lost (code 1006), then 502, 502, thenreconnected. The client then sendsGET … Last-Event-ID: 2-0, the in-flight result is delivered, and the next call runs on the same session.claude -pnor interactive Claude Code sendsDELETEon exit.jscall, a newinitializegets503 cua: session limit reached (1).run/clean.enroll --rotate: the old credential gets 401 and the new one 200, with the agent's pid unchanged.jscall andend_task.Unresolved Review Findings
Each of these was triaged and deliberately left. The first six are in
tech-debt-tracker.md; the last three are recorded in the spec.src/mcp/http.mjs: a POST stream that drops and is never resumed keeps its events, outside the 16 MB server-message cap, until the session ends. The idle close bounds this.src/mcp/server.mjsandsrc/mcp/connection.mjsimport each other. It is documented and safe, because nothing at top level crosses it.src/remote/relay-link.mjs: after it refuses an oversized body, it logs "unknown channel" for each later frame. The shipped relay stops at the same 4 MB first.wsmaxPayload. It stays at the 100 MiB default. A single event over about 75 MB would close the device link.0.0.0.0is accepted by--http. This is guidance only; the bearer guards.relayEndpointloses a relay's path prefix. It deriveshttps://<relay host>/d/<id>/mcp.Residue
relay/README.md.onConsole: falsebranch.scripts/accept-native.mjsrequiresdoctor.ok. On an enrolled Mac with a locked screen,agent.consolenow fails, so that acceptance script refuses. Exempting theagent.*rows, or documenting this, is a small follow-up.