Skip to content

One server, every device: devices_list / devices_use in the plugin's cua_repl (plugin 0.3.0) - #71

Merged
SSFSKIM merged 33 commits into
mainfrom
feat/device-multiplexing
Oct 7, 2026
Merged

SSFSKIM merged 33 commits into
mainfrom
feat/device-multiplexing

Conversation

@SSFSKIM

@SSFSKIM SSFSKIM commented Oct 7, 2026

Copy link
Copy Markdown
Owner

Closes #70
Closes #69

One server, every device: the plugin's own cua_repl (stdio cua serve) reaches every enrolled device itself, so a client needs no per-device claude mcp add. Tool names stay mcp__plugin_cua_cua_repl__*; which machine they drive is a per-connection target.

  • devices_list / devices_use. devices_list probes each registered device without opening a session (one authenticated session-less ping: relay 503 offline, 401 unauthorized, the device's 400 online, Cua-Console: locked locked). devices_use <name> switches js, js_reset, end_task, profiles_list and secrets_list to that device, and devices_use local switches back. A switch is refused with task_open while a task is open. The device session is DELETEd after end_task, on switching away and at close. js's schema is unchanged.
  • src/remote/client.mjs. An MCP Streamable HTTP client over Node's fetch, with no new dependency.
    • It forwards the local client's initialize params, holds a standing GET and resumes a dropped POST stream by Last-Event-ID (1 s doubling to 15 s within 90 s).
    • It never resends a call that may have run.
    • It remaps the device's elicitations to cua-device-<n> ids, so the local approval hook answers them.
    • Errors are classified: device_offline, device_unauthorized, session_limit, device_session_ended, device_failed, device_protocol.
  • Registry and CLI. The registry is ~/.config/cua/devices.json (0600). The CLI is cua devices add|remove|list|import; import takes today's *.mcp.json client configs and writes the credential to the secret store itself. The credential stays in the store under CUA_DEVICE_<id, - as _> and is read by the server process only.
  • Reserved CUA_DEVICE_ prefix, in any letter case (Secrets: should relay client credentials stored via /secret be substitutable; fixture temp-home cleanup; accept-native PASS on macOS #69). Those keys are hidden from secrets_list, and {{secret:…}} refuses them with secret_reserved in both trusted services. cua secrets list still shows them.
  • Docs and version. Plugin 0.3.0. The README leads remote control with the plugin route and keeps the standalone HTTP registration second, still supported. The cua-remote skill's Part B is collapsed. The host notes gain the devices rule within the 2,048-character budget.
  • Spec. New "Phase G: one server, every device" section in docs/doperpowers/specs/2026-10-06-remote-and-linux-design.md, with its Decision Log entries, Surprises and Outcomes.

Validation Evidence

Claim Command / source Result
Suite green npm test at 92e879b # tests 780 # pass 779 # fail 0 # skipped 1 (704 pass before)
Registry import, credential never printed (item 13) node bin/cua.mjs devices import ~/.config/cua-relay/mini.mcp.json, run twice; devices list credential stored under CUA_DEVICE_nuadM_…, then credential unchanged; mini … credential stored; the credential appears 0 times in the output (counted, never printed)
One plugin-route session, MacBook → mini (item 14) claude -p --strict-mcp-config --mcp-config /tmp/g70-accept.mcp.json … (worktree cua-shim.mjs as cua_repl) devices_list mini online; devices_use mini ok with the mini's notes; TextEdit marker typed and read back; school tab opened, read and closed; devices_use local before end_task → {"status":"error","code":"task_open"}; after end_task, local js read the MacBook; the mini's run/ is clean
In-flight result across a relay restart (item 15) systemctl restart cua-relay 12 s into a 45 s js; Caddy access log GET 503 Last-Event-Id: 1-0 (twice, device not back yet), then GET 200 Last-Event-Id: 1-0, 25.7 s carrying the answer; no new initialize. Same in reverse through Last-Event-Id: 2-0
Reserved keys (item 16) secrets_list; typeText("{{secret:CUA_DEVICE_…}}") Reserved key omitted; [secret_reserved], nothing typed
Credential nowhere in transcripts (items 14–17) grep -c -F "$(jq -r … mini.mcp.json | sed 's/^Bearer //')" over every stream-json output, stderr and session transcript 0 on both Macs
Mini → MacBook (item 17) the same runs from a branch worktree on the mini, importing macbook.mcp.json All pass, item 15 included
Standalone registration unchanged (item 18) claude -p with ~/.config/cua-relay/mini.mcp.json as-is js read the mini's host name; tab opened

The full record is in docs/evidence/2026-10-07-device-multiplexing-acceptance.md.

Reviews:

  • Task reviews of G1, G2 and G3 ran on opus. Each found real defects, and each was fixed and re-reviewed clean:
    • G1: the prefix check was case-sensitive, so it could be bypassed on macOS's case-insensitive file system.
    • G2: a request whose signal was already aborted was still sent.
    • G3: a stale tool count would have failed the chrome-all acceptance, and task_open could race a lazy open.
  • The whole-branch review on opus with the reviewer-high brief found two seam defects:
    • A call pipelined between two devices_use calls ran on the later device.
    • A close during a device-to-device switch leaked the new device's session.
      Both are fixed with tests (cbcca48) and re-reviewed as correct. Its review of the last stretch (G4's fix, docs, version) left one doc clause, fixed in 92e879b.

Unresolved Review Findings

These are deferred Minors from the task reviews and the branch review. They are logged in tech-debt-tracker.md under "Phase G task-review minors left".

  • src/cli.mjs is past 700 lines with the devices handler. Splitting it by command family is a refactor outside this ticket.
  • test/remote-devices.test.mjs: the test named "unsafe or unreadable" exercises only an insecure-mode file. The behaviour is correct; only the title overstates it.
  • src/mcp/target.mjs: a device end_task that fails because the session was lost says both "the next call opens a new session" and "devices_use still works". This is redundant but accurate.
  • src/mcp/target.mjs: a connection that closes while devices_use re-awaits in-flight calls answers task_open rather than connection_closing. The client is leaving, so nothing acts on the answer.
  • src/mcp/surface.mjs: the Linux computer,browser host notes are at 2,045 of 2,048 characters. Every rule fits today, but the next rule needs another tightening.

Residue

  • Local profiles_list guidance is invisible to the model. Claude Code 2.1.292 shows only structuredContent for a successful result. profiles_list's "not ready, tell the user; do not pick a profile" text has therefore never reached the model since Phase C. It is in the tech-debt tracker; it deserves a fix that puts the guidance into the structured content.
  • Update both launchd agents to 0.3.0 after merge. The device side of the reserved prefix and the Cua-Console: locked probe header take effect only when each device's agent runs this version. Both agents ran main during acceptance by design. Until then, the mini's 0.2.3 plugin still lists the CUA_DEVICE_jMTkLnzn_… key this acceptance stored there.
  • The host-notes budget is effectively exhausted. With 3 characters left on Linux, the next operating rule has nowhere to go. Moving some rules into tool descriptions (which have no shared budget) or into a first-call document is worth a design ticket.

SSFSKIM added 30 commits October 6, 2026 20:00
…3-18, interfaces, milestones G1-G4, Decision Log)
…usted services refuse it with secret_reserved (#69)
…nds; an empty mcpServers says so; tests for an unlistable store and an unsafe credential file (G1 review)
…t, a cancellation waits for its request's head, the open and a request's head are bounded at 30 s, an open takes a signal, an unanswered DELETE says its outcome is unknown; tests for the untested branches (#70 G2)
…(sent: false), and an unanswered request reads as one sentence (#70 G3)
…e tools routed to a device session, the device's requests remapped, cancellation, DELETE on end_task, on switching away and at close, the 404 rules, the devices rule in the host notes (#70 G3)
…e tools); the usage test captures its usage line instead of printing it (#70 G3 review)
…task open, stray cua-device ids and device cancellations dropped, a failed end_task says the target is free, the new-session note once per session, a call queued behind a switch is cancellable, calls cut by the close answer connection_closing; src/remote/targets.mjs renamed directory.mjs (#70 G3 review)
…devices, devices_list, devices_use) and keeps the standalone registration second; cua-remote Part B collapsed; relay README names both client routes (#70 G4)
…tured content, and a new session's note joins a structured device result: Claude Code shows the model only the structured content of a successful result (#70 G4 live run)
…h the hosted relay, the structured-content fix the run required, the mini's network outage; tech debt: success-result text Claude Code never shows (#70 G4)
…ain, so it runs on that switch's target and a later devices_use sees its task; a switch that finds the connection closing after the previous device's DELETE ends the new session too (#70 branch review)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant