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
feat(control): register the run verb and --run-now (#925)
review413842a7c0e6
diff --git a/src/core/agents/hook-server.ts b/src/core/agents/hook-server.tsindex 19fa810d2..8c7acc1c4 100644--- a/src/core/agents/hook-server.ts+++ b/src/core/agents/hook-server.ts@@ -240,7 +240,9 @@ export const requiresVerified: ReadonlySet<string> = new Set(['settings',// Publishes text from this machine to a repository. `legacy` means "we cannot judge this// caller", and an unjudgeable caller must never be the one that files.- 'report-issue'+ 'report-issue',+ // Starts a process the user is not watching (#925).+ 'run'])/**@@ -263,6 +265,8 @@ export const OPEN_PROJECT_CONTROL_REFUSAL = 'Project open refused.'export const SETTINGS_CONTROL_REFUSAL = 'Settings access refused.'/** One sentence, names what was refused, no diagnosis — house style for every refusal here. */export const REPORT_ISSUE_CONTROL_REFUSAL = 'Issue reporting refused.'+const RUN_CONTROL_REFUSAL =+ 'Run refused: starting a queued session the user is not watching needs verified node identity.'/** The verified-only refusal, worded for the verb that was refused. */export function verifiedRefusalFor(verb: string): string {@@ -271,6 +275,7 @@ export function verifiedRefusalFor(verb: string): string {if (verb === 'report-issue') return REPORT_ISSUE_CONTROL_REFUSALif (verb === 'sticky') return STICKY_CONTROL_REFUSALif (verb === 'open-project') return OPEN_PROJECT_CONTROL_REFUSAL+ if (verb === 'run') return RUN_CONTROL_REFUSALreturn MESSAGING_CONTROL_REFUSAL}diff --git a/src/core/agents/messaging-verified-only.test.ts b/src/core/agents/messaging-verified-only.test.tsindex ddd5c5eeb..cd845d341 100644--- a/src/core/agents/messaging-verified-only.test.ts+++ b/src/core/agents/messaging-verified-only.test.ts@@ -137,7 +137,7 @@ describe('where the verbs sit in the routing tables', () => {}})- it('the verified-only set is exactly the messaging verbs plus sticky, open-project, settings and report-issue', () => {+ it('the verified-only set is exactly the messaging verbs plus sticky, open-project, settings, report-issue and run', () => {// Pins that nothing ELSE ever drifts in: adding a SHIPPED verb here would strand its legacy// population with no hatch, which is the one thing this set must never be casually grown by.// `notify` (folded in from #98, Task 5.2) is a messaging verb like the other two — it writes@@ -153,17 +153,27 @@ describe('where the verbs sit in the routing tables', () => {// this machine to a repository, with no dialog anywhere on the path — `legacy` means "we// cannot judge this caller", and an unjudgeable caller must never be the one that publishes.// New verb, so fail-closed from day one strands no legacy population either.+ // `run` (#925) is here because it STARTS a process in a session the user is not watching —+ // possibly in another project; new verb, so fail-closed from day one strands nobody.expect([...requiresVerified].sort()).toEqual(['notify','open-project','reply','report-issue',+ 'run','send','settings','sticky'])})+ it('the run refusal is its own sentence, not the messaging one (#925)', () => {+ expect(verifiedRefusalFor('run')).toBe(+ 'Run refused: starting a queued session the user is not watching needs verified node identity.'+ )+ expect(verifiedRefusalFor('run')).not.toBe(MESSAGING_CONTROL_REFUSAL)+ })+it('the report-issue refusal is its own flat sentence, not the messaging one', () => {expect(verifiedRefusalFor('report-issue')).toBe('Issue reporting refused.')expect(verifiedRefusalFor('report-issue')).not.toBe(MESSAGING_CONTROL_REFUSAL)diff --git a/src/core/canvas-control-core.ts b/src/core/canvas-control-core.tsindex 27e8cf003..9616f37ca 100644--- a/src/core/canvas-control-core.ts+++ b/src/core/canvas-control-core.ts@@ -192,6 +192,7 @@ export type ControlVerb =| 'color'| 'write'| 'close'+ | 'run'| 'board'| 'assign'| 'send'@@ -232,6 +233,10 @@ const VERBS: ControlVerb[] = ['color','write','close',+ // #925: start a QUEUED node now: the CLI twin of the node's Run now button. It works on a node in+ // a project the user is not viewing (headless), and takes `--project` through the same grant gate+ // as the open verbs.+ 'run','board','assign','send',@@ -307,6 +312,7 @@ export function parseControlRequest(if (!VERBS.includes(verb as ControlVerb)) return { error: `Unknown verb: ${verb}` }const v = verb as ControlVerbif (v === 'close' && !args.node) return { error: 'close requires --node <id>' }+ if (v === 'run' && !args.node) return { error: 'run requires --node <id>' }if (v === 'write' && !args.node) return { error: 'write requires --node <id>' }if (v === 'write' && !args.text) return { error: 'write requires --text' }if ((v === 'show-image' || v === 'show-video') && !args.path) {@@ -534,6 +540,11 @@ export function buildCanvasControlInstructions(shimPath: string): string {'- `rename --node <id> --title "New Name"` — rename any node (terminals, groups, stickies…).',' Renaming to the title the node ALREADY has is a no-op: nothing is typed into its agent',' session, and the reply says `already named`. Re-assert your own name as often as you like.',+ '- `run --node <id> [--project <id>]` — start a QUEUED node now: the command-line twin of the',+ ' node\'s Run now button. It delivers the node\'s held launch even while the user looks',+ ' elsewhere, and it skips an `--after` wait (a deliberate override). A node in another project',+ ' needs `--project <id>` (your own project, or an id `open-project` returned to you). The reply',+ ' says `started: true`, or `queued: true` with a `reason`; a node with nothing queued is refused.',`- \`color --node <id,id> --color C\` — recolor nodes, frames, or stickies. C is a palette NAME`,` or its hex: ${nodeColorChoices()}. The agent names paint a node its CLI's own brand color.`,'- `write --node <id> --text "..."` / `close --node <id,id>` — type into / close nodes.',@@ -686,7 +697,7 @@ if [ "$nt_verb" = "help" ] || [ "$nt_verb" = "--help" ] || [ "$nt_verb" = "-h" ]fi# Translate \`--flag value\` pairs — plus the one bare positional the show-image/show-video and-# write/close/rename/color/branch/send/reply/sticky forms accept — into curl --data-urlencode arguments. The positional+# write/close/rename/color/branch/send/reply/sticky/run 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@@ -730,7 +741,7 @@ while [ "$nt_i" -lt "$nt_count" ]; dont_seen_pos=1case "$nt_verb" inshow-image|show-video) set -- "$@" --data-urlencode "arg.path=$nt_a" ;;- write|close|rename|color|branch|send|reply|sticky) set -- "$@" --data-urlencode "arg.node=$nt_a" ;;+ write|close|rename|color|branch|send|reply|sticky|run) set -- "$@" --data-urlencode "arg.node=$nt_a" ;;esacfi;;@@ -1044,6 +1055,11 @@ Verbs:- \`rename --node <id> --title "New Name"\` — rename any node (terminals, groups, stickies…).Renaming to the title the node ALREADY has is a no-op: nothing is typed into its agentsession, and the reply says \`already named\`. Re-assert your own name as often as you like.+- \`run --node <id> [--project <id>]\` — start a QUEUED node now: the command-line twin of the+ node's Run now button. It delivers the node's held launch even while the user looks elsewhere,+ and it skips an \`--after\` wait (a deliberate override). A node in another project needs+ \`--project <id>\` (your own project, or an id \`open-project\` returned to you). The reply says+ \`started: true\`, or \`queued: true\` with a \`reason\`; a node with nothing queued is refused.- \`color --node <id,id> --color C\` — recolor nodes, frames, or stickies. C is a palette NAME orits hex (either is accepted, and the hex is case-insensitive): ${nodeColorChoices()}.The agent names are that CLI's own brand color — \`--color claude\` paints a node the color adiff --git a/src/core/project-grants.ts b/src/core/project-grants.tsindex ac754d394..711fe45e2 100644--- a/src/core/project-grants.ts+++ b/src/core/project-grants.ts@@ -60,14 +60,16 @@ export function clearAll(): void {grants.clear()}-/** The verbs that accept `--project` (spec §2.2): the three open verbs, plus `settings`, whose- * per-project keys (@shared/settings-verb) may name a project other than the caller's — own or- * granted only, the same rule, decided here before anything is forwarded. `--project` on any other- * verb is dead weight the gate deliberately ignores (spec §7.5). */+/** The verbs that accept `--project` (spec §2.2): the three open verbs, `run` (#925), plus+ * `settings`, whose per-project keys (@shared/settings-verb) may name a project other than the+ * caller's — own or granted only, the same rule, decided here before anything is forwarded.+ * `--project` on any other verb is dead weight the gate deliberately ignores (spec §7.5). */export const PROJECT_TARGETABLE_VERBS: ReadonlySet<string> = new Set(['open-terminal','open-claude','open-agent',+ // #925: a node in another project is reached only through a granted --project.+ 'run','settings'])diff --git a/src/main/canvas-control-core.test.ts b/src/main/canvas-control-core.test.tsindex 4807696e2..ae8ef4716 100644--- a/src/main/canvas-control-core.test.ts+++ b/src/main/canvas-control-core.test.ts@@ -77,6 +77,22 @@ describe('parseControlRequest', () => {})})+ it('run requires --node (#925)', () => {+ expect(parseControlRequest('run', {})).toEqual({ error: 'run requires --node <id>' })+ expect(parseControlRequest('run', { node: 'n1' })).toEqual({ verb: 'run', args: { node: 'n1' } })+ })++ it('both bodies document the run verb with --project (#925)', () => {+ for (const [name, body] of [+ ['skill', buildCanvasSkillBody('/x/shim.sh')],+ ['instructions', buildCanvasControlInstructions('/x/shim.sh')]+ ] as const) {+ expect(body, name).toMatch(/- `run --node <id> \[--project <id>\]`/)+ expect(body, name).toMatch(/twin of the\s+node'?s Run now button/)+ expect(body, name).toMatch(/nothing queued is refused/)+ }+ })+it('requires a source for show verbs', () => {expect(parseControlRequest('show-video', {})).toEqual({ error: 'show-video requires --path' })expect(parseControlRequest('show-web', {})).toEqual({@@ -300,10 +316,11 @@ describe('parseControlRequest', () => {expect(parseControlRequest('reply', { node: 'n1' })).toEqual({ error: 'reply requires --text' })})- it('the shim maps a bare positional onto arg.node for color/send/reply/sticky too', () => {- // The positional list is a case pattern inside CONTROL_SHIM_SCRIPT; send/reply/sticky take the- // same "first bare word is the node" convenience write/close/rename/color/branch already have.- expect(CONTROL_SHIM_SCRIPT).toContain('write|close|rename|color|branch|send|reply|sticky)')+ it('the shim maps a bare positional onto arg.node for color/send/reply/sticky/run too', () => {+ // The positional list is a case pattern inside CONTROL_SHIM_SCRIPT; send/reply/sticky/run take+ // the same "first bare word is the node" convenience write/close/rename/color/branch already+ // have (run joined for #925; control-shim-parse.test.ts runs it through a real sh).+ expect(CONTROL_SHIM_SCRIPT).toContain('write|close|rename|color|branch|send|reply|sticky|run)')})it('sticky requires --node plus exactly one of --text/--append, and is not destructive', () => {diff --git a/src/main/control-shim-parse.test.ts b/src/main/control-shim-parse.test.tsindex 374e589c9..a7574bd07 100644--- a/src/main/control-shim-parse.test.ts+++ b/src/main/control-shim-parse.test.ts@@ -91,6 +91,22 @@ describe('the control shim translates flags', () => {])})+ it('--run-now last on the line rides as an empty value; =1 carries it explicitly (#925)', () => {+ expect(run(['open-agent', '--agent', 'claude', '--project', 'p2', '--run-now'])).toEqual([+ 'arg.agent=claude',+ 'arg.project=p2',+ 'arg.run-now='+ ])+ expect(run(['open-agent', '--run-now=1', '--agent', 'claude'])).toEqual([+ 'arg.run-now=1',+ 'arg.agent=claude'+ ])+ })++ it('run takes its node positionally, like rename (#925)', () => {+ expect(run(['run', 'n7'])).toEqual(['arg.node=n7'])+ })+// Hyphenated flag names ride through as-is — the loop strips only the leading `--`, so// `--prompt-file` lands as `arg.prompt-file` and the server reads args['prompt-file'].it('a hyphenated flag name (--prompt-file) keeps its hyphen in the arg key', () => {diff --git a/src/shared/control-off-screen.ts b/src/shared/control-off-screen.tsindex 4fade3a69..6e1392a7a 100644--- a/src/shared/control-off-screen.ts+++ b/src/shared/control-off-screen.ts@@ -195,6 +195,7 @@ export function answersOffCanvas(verb: string): boolean {* persisted index, with no live client — see core/remote-end.ts) and drops the node through* the store's `removeNode`. That is the cross-project teardown the sessions sidebar has always* used for a node in a project that is not on screen; `closeStoredNodes` is now the one copy.+ * - `run` starts a node's held launch headless through the owner's serialized copy (#925).* - `rename` / `color` have dedicated store writers (`renameNode` / `recolorNode`) that mutate* the serialized node directly, with no round-trip through the serializers.* - `link` writes persisted `bridges`, which `appendCanvasLinks` appends to a non-active project —@@ -211,6 +212,7 @@ export function answersOffCanvas(verb: string): boolean {const STORED_NODE_VERBS: ReadonlySet<string> = new Set(['write','close',+ 'run','rename','color','link',diff --git a/src/shared/control-verbs.test.ts b/src/shared/control-verbs.test.tsindex 8ee22921b..68e549273 100644--- a/src/shared/control-verbs.test.ts+++ b/src/shared/control-verbs.test.ts@@ -1,5 +1,5 @@import { describe, it, expect } from 'vitest'-import { DRY_RUN_VERBS, dryRunRequested, dryRunRefusal } from './control-verbs'+import { DRY_RUN_VERBS, dryRunRequested, dryRunRefusal, runNowRequested } from './control-verbs'describe('dryRunRequested', () => {it('absent means no dry run', () => {@@ -49,3 +49,15 @@ describe('dryRunRefusal', () => {expect(msg).toContain('Nothing was done')})})++describe('runNowRequested (#925)', () => {+ it('reads presence as on, like --dry-run', () => {+ expect(runNowRequested({})).toBe(false)+ expect(runNowRequested({ 'run-now': '' })).toBe(true)+ expect(runNowRequested({ 'run-now': '1' })).toBe(true)+ expect(runNowRequested({ 'run-now': 'yes' })).toBe(true)+ })+ it('only an explicit false|no|0 turns it off', () => {+ for (const v of ['false', 'NO', '0', ' 0 ']) expect(runNowRequested({ 'run-now': v })).toBe(false)+ })+})diff --git a/src/shared/control-verbs.ts b/src/shared/control-verbs.tsindex b928b1a6e..a39136c78 100644--- a/src/shared/control-verbs.ts+++ b/src/shared/control-verbs.ts@@ -107,6 +107,16 @@ export function dryRunRequested(args: Record<string, string | undefined>): boolereturn !/^(false|no|0)$/i.test(v.trim())}+/**+ * Is `--run-now` on (#925)? Presence means yes, exactly like `--dry-run`: the shim encodes a+ * valueless flag as an empty string, and only an explicit false|no|0 turns it off.+ */+export function runNowRequested(args: Record<string, string | undefined>): boolean {+ const v = args['run-now']+ if (v === undefined) return false+ return !/^(false|no|0)$/i.test(v.trim())+}+/** The refusal for `--dry-run` on a verb outside DRY_RUN_VERBS — derived from the set so the* sentence can never name a verb the gate does not honour. */export function dryRunRefusal(verb: string): string {