Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
Task A10 report — every client presents its per-node token
Status: COMPLETE
What shipped
All four clients now read <$NODETERM_NODE_TOKEN_DIR>/<$NODETERM_NODE_ID> — a lookup by name,
never a scan — and put its first line on X-Nodeterm-Node-Token for every request. Missing file,
missing dir, pre-v2 endpoint ⇒ empty ⇒ the server's legacy path, unchanged.
src/core/agents/hooks/managed-script.ts(claude/gemini/codex/grok, local + remote)- new
nt_read_node_token()helper + a call right after the endpoint file is sourced; - the header on ALL FOUR curls (request POST socket + port, "answered" POST socket + port);
nt_pick_fallbacknow also clearsNODETERM_NODE_TOKEN_DIRbefore sourcing;nt_send_requestcallsnt_read_node_tokenAFTER a successful fallback, before the re-POST.
- new
src/main/canvas-control-core.ts—CONTROL_SHIM_SCRIPT, both curl branches.src/core/context-link-core.ts—CONTEXT_SHIM_SCRIPT, both curl branches.src/core/agents/hooks/opencode.ts—live()seedstokenDirfromNODETERM_NODE_TOKEN_DIRand a second regex picks the v2 line out of the endpoint file (its prefix differs fromNODETERM_HOOK_*, so widening the existing group was not an option); anodeToken(dir)reader feeds thex-nodeterm-node-tokenheader in the sharedheadersobject, which all three transports (Bun unixfetch, TCPfetch,node:httpsocketPath) use.
codex-identity-proxy.ts untouched (task A12).
Tests — real execution, written RED first
17 new assertions failed before the change, all pass after.
managed-script.test.ts(+1 file-local suite, +7 tests → 38 in the file): a REAL hook server with a REAL secret, the REAL generated script under/bin/shwith the REAL curl, asserting the SERVER's own verdict (meta.verified):- token file present ⇒
verified: true; - dir advertised only by the ENDPOINT FILE ⇒
verified: true(pins "after the source"); - no token file / no dir at all ⇒ one event,
verified: false, exit 0; - dir holding only ANOTHER node's token ⇒ one event,
verified: false(presenting it would beforged⇒ 403 ⇒ NO listener call, so "exactly one unverified event" is the assertion); - failover, real server: dead unix-socket primary whose dir holds a FOREIGN-secret token,
live fallback endpoint advertising its own dir with the real token ⇒
verified: true. - plus two fake-curl fixtures for the header text itself: the retry carries the FALLBACK dir's token and never the primary's, and a pre-v2 fallback (no dir line) leaves the header empty.
- token file present ⇒
canvas-control-shim.test.ts(+5): the real shim, real curl, against header-capturing servers on BOTH transports — present / from the endpoint file / absent / another node's id.context-link.cli.test.ts(+5): same shape forcontext.sh.opencode.test.ts(+8): the generated plugin body imported and executed — TCPfetch, Bun unixfetch, andnode:httpagainst a real unix server; present / absent / no dir / other node / dir learned from the endpoint file.
Mutation-checked (both failover subtleties are proven by tests, not by inspection):
- delete
nt_read_node_tokenfrom the fallback branch ⇒ 3 tests fail (incl. the real-server one); - delete
NODETERM_NODE_TOKEN_DIR=""fromnt_pick_fallback⇒ 1 test fails.
Gates
npx vitest run src/core/agents src/main/canvas-control-shim.test.ts src/core/context-link.cli.test.ts src/core/no-electron.test.ts src/server/no-electron.test.ts→ 21 files, 240 tests, all passing.npm run typecheck→ clean.- Wider regression run (
src/core src/main src/server src/shared test/server): 247 files, 3153 tests — onlysrc/main/node-pty-patch.test.ts(3) fails, and it fails identically at HEAD with all my changes stashed: the clone'snode_modulesis a symlink to an unpatched tree.
Concerns
- curl drops an empty header.
-H "X: ${empty}"sends NOTHING — curl removes a header with no content after the colon (measured). So the sh clients send "absent", not "present but empty". The server reads both aslegacy, so the contract holds exactly, but any later task that wants to DISTINGUISH "client is A10-aware but has no token" from "client predates A10" cannot do it from this header. The opencode plugin does send a literal empty value. /control/*and/context-link/*do not verify the header yet (A7 only armed/hook/*). Those two shims are therefore proven only up to "the header is on the wire with the right value" — asserted against real capturing servers, but not against a real verdict. The managed hook script IS proven against a real verdict.- Every client path is covered by a real-execution test. No path was left to string matching
alone. The one thing not exercised end-to-end is the token file being written by the REMOTE
host writer (control-master's
remoteEndpointFileContentsadvertises the remote dir) — that is the remote-materialisation task's ground, not A10's. spawnSynccannot be used for these tests. It blocks node's event loop, so an in-process hook server never accepts the connection and every POST silently "fails" into the failover path. The new suites spawn asynchronously; the pre-existing fake-curl fixtures still usespawnSyncbecause nothing in-process has to answer them.- This clone is shared with a parallel session. Three commits (
f502f413,bce88091,94e835ac) landed onfeat/node-identitywhile A10 was in progress, and that session has uncommitted work innode-token-service.ts/pty-manager.ts. The A10 commit lists its eight paths explicitly and touches nothing of theirs.