Skip to content

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.

Merge remote-tracking branch 'origin/main' into fix/server-project-regrant

freshjuiceza919b0d5a429
diff --cc src/core/canvas-control-core.ts
index f31a19a8a,7a169d5c3..9d53d6172
--- a/src/core/canvas-control-core.ts
+++ b/src/core/canvas-control-core.ts
@@@ -292,16 -286,12 +292,17 @@@ export function buildCanvasControlInstr
'starts with `--` (`--cmd=--version`); written as two tokens, a leading `--` is read as the next',
'flag. A flag with no value is allowed anywhere on the line.',
'',
+ 'Server Edition ownership is fail-closed: every request requires verified node identity, and',
+ 'a caller may mutate or message only nodes it opened during the current server run.',
+ 'Restarting the server clears that creator proof; persisted nodes and queued launches are never',
+ 'auto-adopted, relaunched, or controlled at boot. An unowned target receives a named refusal.',
+ '',
'Verbs:',
'- `list` — current nodes (id, kind, title). Start here when you need a node id.',
+ '- `help` — print the verb list. Answered by the shim itself, so it works even if the app is down.',
'- `open-terminal [--count N] [--cwd P] [--cmd C] [--group <id>] [--after <id,id>] [--project <id>]` — open N plain terminals.',
- '- `open-claude [--count N] [--cwd P] [--prompt T] [--group <id>] [--after <id,id>] [--project <id>]` — open N Claude sessions.',
- `- \`open-agent --agent ${agentChoices} [--count N] [--cwd P] [--prompt T] [--group <id>] [--after <id,id>] [--project <id>]\` — open`,
+ '- `open-claude [--count N] [--cwd P] [--prompt T] [--model M] [--group <id>] [--after <id,id>] [--project <id>]` — open N Claude sessions.',
+ `- \`open-agent --agent ${agentChoices} [--count N] [--cwd P] [--prompt T] [--model M] [--group <id>] [--after <id,id>] [--project <id>]\` — open`,
' any agent CLI. `--group` parents the node(s) into a group frame; a worktree-bound group also',
' hands its worktree path down as the cwd. `--after <id,id>` opens the node ARMED: it does not',
' start until every listed station has gone idle, and is context-linked to them so it can read',
@@@ -350,14 -352,12 +366,15 @@@
' the user to confirm deletion.',
'- `branch --node <id>` — branch a Claude node\'s conversation (Claude nodes only).',
'- `rename --node <id> --title "New Name"` — rename any node (terminals, groups, stickies…).',
+ `- \`color --node <id,id> --color C\` — recolor nodes, frames, or stickies. C is one of: ${NODE_COLORS.join(', ')}.`,
'- `write --node <id> --text "..."` / `close --node <id>` — type into / close a node.',
- ' Desktop asks the user to confirm both. Server Edition is narrower: close requires a node this',
- ' caller opened during the current server run, and all node-mutating verbs (link/group/rename/',
- ' color/sticky update) accept only current-run creations; every other',
- ' target receives a named ownership refusal before any partial mutation.',
- ' Both ask the user to confirm a dialog and may be denied. Read WHICH answer came back:',
- ' `denied by user` is a decision and is FINAL — never re-ask — while `no answer within 120s`',
- ' means nobody reached the dialog, which is worth one retry when the user is back.',
++ ' Desktop asks the user to confirm both. `denied by user` is FINAL; `no answer within 120s`',
++ ' means nobody reached the dialog and is worth one retry when the user is back. Server Edition',
++ ' is narrower: close requires a node this caller opened during the current server run, and all',
++ ' node-mutating verbs accept only current-run creations. Every other target receives a named',
++ ' ownership refusal before any partial mutation.',
'- `send --node <id> --text "..."` / `reply --node <id> --text "..."` — deliver a message into',
- ' another AGENT node in this project (no confirm dialog: verified-only, gated by the project\'s',
+ ' an AGENT node the caller opened this run (no confirm dialog: verified-only, gated by the project\'s',
' agent-messaging switch — off by default — and rate-limited). A busy target is not interrupted',
' and does not lose the message: it is queued (bounded, TTL\'d) and delivered when the target',
' next goes idle. An incoming message is framed `--- NODETERM MESSAGE <nonce> ---` with a `reply-to:`',
@@@ -431,7 -431,18 +448,17 @@@
* verbatim and the parity test holds the two ends together (issue #367). */
export const CONTROL_UNREACHABLE_MSG = 'Could not reach nodeterm (control endpoint unreachable).'
+ /** The verb list `help` prints, DERIVED from the registry rather than re-typed — a verb added to
+ * `VERBS` is discoverable from the CLI the day it lands, which is the whole point of the verb.
+ * Names only, deliberately: flags live in the skill body, and a second copy of them here would be
+ * a second thing to keep in sync. */
+ export const helpVerbList = (): string => VERBS.join(' ')
+
+ /** The registry, exposed for the `help` test so it asserts against the source of truth rather than
+ * a copy of the list it is checking. Not for production use — read `VERBS` directly. */
+ export const VERBS_FOR_TEST: readonly ControlVerb[] = VERBS
+
-export const CONTROL_SHIM_SCRIPT = `#!/bin/sh
-# nodeterm canvas-control CLI (auto-generated — do not edit).
+const CONTROL_SHIM_BODY = `# nodeterm canvas-control CLI (auto-generated — do not edit).
if [ -z "$NODETERM_CANVAS_CONTROL" ]; then
echo "Canvas control is not available in this session (not a nodeterm agent node)." >&2
@@@ -462,8 -473,25 +489,25 @@@ ${CODEX_SANDBOX_HINT_SH
nt_verb="list"
if [ $# -gt 0 ]; then nt_verb="$1"; shift; fi
+ # \`help\` is answered HERE, not by the server: a bare invocation defaults to \`list\`, so the verb
+ # set was undiscoverable from the CLI itself — the one place an agent looks when its skill text is
+ # not to hand. Local and free, so it also answers when the app is down.
+ if [ "$nt_verb" = "help" ] || [ "$nt_verb" = "--help" ] || [ "$nt_verb" = "-h" ]; then
+ echo "nodeterm canvas control — usage: sh <this script> <verb> [--flag value]"
+ echo
+ echo "Verbs:"
+ echo " ${helpVerbList()}"
+ echo
+ # Single quotes: a backtick inside a double-quoted echo is command substitution, and the first
+ # word of the verb list is \`list\` — which sh then tried to RUN.
+ echo 'Run with no verb to list the current nodes (same as \`list\`).'
+ echo "Flags take a value: --flag value, or --flag=value when the value starts with '--'."
+ echo "Per-verb flags are documented in the manage-nodeterm-canvas skill / instructions block."
+ exit 0
+ fi
+
# Translate \`--flag value\` pairs — plus the one bare positional the show-image/show-video and
-# write/close/rename/branch/send/reply/sticky forms accept — into curl --data-urlencode arguments. The positional
+# write/close/rename/color/branch/send/reply/sticky forms accept — into curl --data-urlencode arguments. The positional
# list doubles as the accumulator: originals are consumed from the front, translated pairs
# appended at the back, so "$@" holds exactly the curl args once the loop drains.
nt_seen_pos=0
@@@ -644,16 -655,13 +688,18 @@@ starts with \`--\` (\`--cmd=--version\`
next flag, so \`--text --oops\` sends an empty \`--text\` plus a stray \`--oops\`. A flag with no
value is allowed anywhere on the line, not only at the end.
+Server Edition ownership is fail-closed: every request requires verified node identity, and a
+caller may mutate or message only nodes it opened during the current server run. Restarting
+the server clears that creator proof; persisted nodes and queued launches are never auto-adopted,
+relaunched, or controlled at boot. An unowned target receives a named refusal.
+
Verbs:
- \`list\` — list current nodes (id, kind, title). Start here when you need a node id.
+ - \`help\` — print the verb list. The shim answers this itself, without reaching the app, so it
+ is also what to run when you are unsure whether the control endpoint is alive.
- \`open-terminal [--count N] [--cwd P] [--cmd C] [--group <id>] [--after <id,id>] [--project <id>]\` — open N plain terminals (default 1).
- - \`open-claude [--count N] [--cwd P] [--prompt T] [--group <id>] [--after <id,id>] [--project <id>]\` — open N Claude sessions (default 1).
- - \`open-agent --agent ${agentChoices} [--count N] [--cwd P] [--prompt T] [--group <id>] [--after <id,id>] [--project <id>]\` — open N sessions of any agent CLI.
+ - \`open-claude [--count N] [--cwd P] [--prompt T] [--model M] [--group <id>] [--after <id,id>] [--project <id>]\` — open N Claude sessions (default 1).
+ - \`open-agent --agent ${agentChoices} [--count N] [--cwd P] [--prompt T] [--model M] [--group <id>] [--after <id,id>] [--project <id>]\` — open N sessions of any agent CLI.
\`--group\` parents the node(s) into an existing group frame; a worktree-bound group also
hands its worktree path down as the cwd.
\`--after <id,id>\` opens the node **armed**: it does NOT start yet, and launches itself once
@@@ -781,8 -803,10 +850,9 @@@ ${messagingGuidanceLines().join('\n')
${browserGuidanceLines().join('\n')}
Notes:
- - \`write\` requires the user to approve a confirmation dialog. Desktop \`close\` does too;
- Server Edition uses the process-local ownership rule described above instead.
-- \`write\` and \`close\` require the user to approve a confirmation dialog; they may be denied.
- Two different replies, two different follow-ups: \`denied by user\` is a decision and is FINAL —
- never re-ask — whereas \`no answer within 120s\` means the dialog was simply not reached in
- time, which is worth one retry when the user is back at the machine.
++- Desktop \`write\` and \`close\` require the user to approve a confirmation dialog. A
++ \`denied by user\` reply is FINAL; \`no answer within 120s\` is worth one retry when the user
++ is back. Server Edition uses the process-local ownership rule for \`close\` instead.
- \`board\` and \`assign\` act on the CURRENTLY OPEN project's board — the same one you see when you
toggle the kanban view. They need no confirmation.
- If the CLI says canvas control is unavailable, you are not in a controllable nodeterm session — do not retry.
diff --cc src/main/control-shim-help.test.ts
index 000000000,92727bf03..cbf755937
mode 000000,100644..100644
--- a/src/main/control-shim-help.test.ts
+++ b/src/main/control-shim-help.test.ts
@@@ -1,0 -1,55 +1,55 @@@
+ // `help` is answered by the shim itself, so it is tested the same way the flag loop is: the REAL
+ // script under REAL `sh`, with a `curl` that fails the run if it is called at all. A local answer
+ // that quietly round-trips would still pass a test that only inspected stdout.
+ import { describe, it, expect, beforeAll, afterAll } from 'vitest'
+ import { execFileSync } from 'node:child_process'
+ import fs from 'node:fs'
+ import os from 'node:os'
+ import path from 'node:path'
-import { CONTROL_SHIM_SCRIPT, VERBS_FOR_TEST } from './canvas-control-core'
++import { CONTROL_SHIM_SCRIPT, VERBS_FOR_TEST } from '../core/canvas-control-core'
+
+ let dir = ''
+
+ const run = (args: string[]): string =>
+ execFileSync('sh', [path.join(dir, 'shim.sh'), ...args], {
+ env: {
+ PATH: `${path.join(dir, 'bin')}:${process.env.PATH ?? ''}`,
+ NODETERM_CANVAS_CONTROL: '1',
+ NODETERM_HOOK_PORT: '1',
+ NODETERM_NODE_ID: 'n1',
+ HOME: dir
+ },
+ encoding: 'utf8'
+ })
+
+ beforeAll(() => {
+ dir = fs.mkdtempSync(path.join(os.tmpdir(), 'ctlhelp-'))
+ fs.mkdirSync(path.join(dir, 'bin'))
+ fs.writeFileSync(path.join(dir, 'shim.sh'), CONTROL_SHIM_SCRIPT, { mode: 0o755 })
+ // Any invocation is a failure: help must cost no network, so it also works while the app is down.
+ fs.writeFileSync(path.join(dir, 'bin', 'curl'), '#!/bin/sh\nexit 77\n', { mode: 0o755 })
+ })
+
+ afterAll(() => fs.rmSync(dir, { recursive: true, force: true }))
+
+ describe('the control shim answers help locally', () => {
+ it.each(['help', '--help', '-h'])('%s prints usage without calling curl', (flag) => {
+ const out = run([flag])
+ expect(out).toContain('usage:')
+ expect(out).toContain('Verbs:')
+ })
+
+ it('lists every registered verb — the list is derived, not re-typed', () => {
+ // The reason `help` exists is that the verb set was undiscoverable from the CLI. A hand-copied
+ // list would go stale on the first verb added and put us back where we started, so this asserts
+ // against the registry itself.
+ const out = run(['help'])
+ for (const verb of VERBS_FOR_TEST) expect(out).toContain(verb)
+ })
+
+ it('points at the skill for per-verb flags rather than restating them', () => {
+ // Flags are documented once, in the generated bodies. A second copy inside the shim is a second
+ // thing to keep in sync, and the shim is the copy that goes stale on an SSH host until reconnect.
+ expect(run(['help'])).toContain('manage-nodeterm-canvas')
+ })
+ })