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(grok): let grok sessions drive the canvas (skill discovery via ~/.claude/skills)
enescbb16ebde304
diff --git a/src/core/agents/hook-server.env.test.ts b/src/core/agents/hook-server.env.test.tsnew file mode 100644index 000000000..2e7875aa3--- /dev/null+++ b/src/core/agents/hook-server.env.test.ts@@ -0,0 +1,49 @@+/**+ * The session env the hook server hands every spawned agent. Only the canvas-control gate is+ * covered here, because it is the one pair that is CONDITIONAL: the shim disables itself on its own+ * `NODETERM_CANVAS_CONTROL` check, so an agent missing from CANVAS_CONTROL_CAPABLE has the skill+ * installed and inert — a failure with no symptom other than the agent saying it cannot do it.+ */+import { describe, it, expect, beforeAll, afterAll } from 'vitest'+import fs from 'node:fs'+import os from 'node:os'+import path from 'node:path'+import { hookServer } from './hook-server'+import { initPlatform, resetPlatformForTests } from '../platform'+import { fakePlatform } from '../platform-fake'++let dir = ''++beforeAll(async () => {+ dir = fs.mkdtempSync(path.join(os.tmpdir(), 'nodeterm-hookenv-'))+ resetPlatformForTests()+ initPlatform(fakePlatform({ userDataDir: dir }))+ // buildPtyEnv returns {} until the server has a port and a token.+ await hookServer.start()+})++afterAll(() => {+ hookServer.stop()+ fs.rmSync(dir, { recursive: true, force: true })+})++describe('hookServer.buildPtyEnv — canvas control gate', () => {+ it('arms canvas control for a grok session', () => {+ expect(hookServer.buildPtyEnv('n1', 'grok').NODETERM_CANVAS_CONTROL).toBe('1')+ })++ it('arms it for the other capable builtins too', () => {+ for (const id of ['claude', 'codex', 'gemini', 'opencode'])+ expect(hookServer.buildPtyEnv('n1', id).NODETERM_CANVAS_CONTROL, id).toBe('1')+ })++ it('leaves the pair absent for a custom agent', () => {+ // Absent, not '0': the shim tests for a non-empty value.+ expect(hookServer.buildPtyEnv('n1', 'custom:abc')).not.toHaveProperty('NODETERM_CANVAS_CONTROL')+ })++ it('still identifies the agent to the hook, whatever the gate says', () => {+ expect(hookServer.buildPtyEnv('n1', 'grok').NODETERM_AGENT_ID).toBe('grok')+ expect(hookServer.buildPtyEnv('n1', 'grok').NODETERM_NODE_ID).toBe('n1')+ })+})diff --git a/src/core/remote-ssh/control-master.test.ts b/src/core/remote-ssh/control-master.test.tsindex a612f9d22..2e2229566 100644--- a/src/core/remote-ssh/control-master.test.ts+++ b/src/core/remote-ssh/control-master.test.ts@@ -247,6 +247,19 @@ describe('hook forwarding', () => {// Guard against a regression that passes sessionName(persistKey) = `nt-<id>`.expect(env).not.toContain(`NODETERM_NODE_ID=nt-${persistKey}`)})+ it('arms canvas control on a remote grok session, and not on a plain terminal', () => {+ // Same gate as the local hookServer.buildPtyEnv, so an SSH grok node gets the shim armed with+ // no extra install: the skill is already written to the host's $HOME/.claude/skills, which grok+ // scans by default.+ expect(remoteHookEnvArgs('/ep', 'n1', '1', 'grok')).toEqual([+ '-e', 'NODETERM_HOOK_ENDPOINT=/ep',+ '-e', 'NODETERM_NODE_ID=n1',+ '-e', 'NODETERM_HOOK_VERSION=1',+ '-e', 'NODETERM_AGENT_ID=grok',+ '-e', 'NODETERM_CANVAS_CONTROL=1'+ ])+ expect(remoteHookEnvArgs('/ep', 'n1', '1')).not.toContain('NODETERM_CANVAS_CONTROL=1')+ })it('remoteEndpointFileContents writes SOCK/TOKEN/VERSION', () => {expect(remoteEndpointFileContents('/r.sock', 'tok', '1')).toBe('NODETERM_HOOK_SOCK=/r.sock\nNODETERM_HOOK_TOKEN=tok\nNODETERM_HOOK_VERSION=1\n'diff --git a/src/main/canvas-control-core.ts b/src/main/canvas-control-core.tsindex 3769d2499..efd1e298f 100644--- a/src/main/canvas-control-core.ts+++ b/src/main/canvas-control-core.ts@@ -273,7 +273,7 @@ exit 1export function buildCanvasSkillBody(shimPath: string): string {return `---name: manage-nodeterm-canvas-description: Create, organize and control nodes on the nodeterm canvas — open Claude Code / Codex / Gemini / terminal nodes, spawn a team of agents that divide up a task, create git worktrees as bound groups, wrap nodes in labeled groups, arrange/align/rename them, link nodes so you can read back what they produced, show an image/video/web page, write to or close a terminal. Use whenever the user says "Build with Nodeterm orchestration", asks to create or open nodes/sessions/terminals, split or parallelize work across subagents/agents/sessions/worktrees, delegate parts of a task to other agents, work on several things at once, build something using multiple Claude (or other agent) sessions, collect or synthesize the results of agents you opened, organize the canvas into groups by topic, or visualize code/output you produced. Only works inside a nodeterm Claude session.+description: Create, organize and control nodes on the nodeterm canvas — open Claude Code / Codex / Gemini / terminal nodes, spawn a team of agents that divide up a task, create git worktrees as bound groups, wrap nodes in labeled groups, arrange/align/rename them, link nodes so you can read back what they produced, show an image/video/web page, write to or close a terminal. Use whenever the user says "Build with Nodeterm orchestration", asks to create or open nodes/sessions/terminals, split or parallelize work across subagents/agents/sessions/worktrees, delegate parts of a task to other agents, work on several things at once, build something using multiple Claude (or other agent) sessions, collect or synthesize the results of agents you opened, organize the canvas into groups by topic, or visualize code/output you produced. Only works inside a nodeterm agent session.---# Manage the nodeterm canvasdiff --git a/src/shared/agents/config.capabilities.test.ts b/src/shared/agents/config.capabilities.test.tsindex c28fe7af2..b458c295c 100644--- a/src/shared/agents/config.capabilities.test.ts+++ b/src/shared/agents/config.capabilities.test.ts@@ -115,9 +115,15 @@ describe('grok capabilities', () => {expect(canRename('grok')).toBe(true)})+ it('drives the canvas, on the skill that is already installed for claude', () => {+ // The only capability grok gets with no per-agent leaf of its own: it scans `~/.claude/skills`+ // by default (Claude Code compat, see its user-guide/08-skills.md), which is where+ // manage-nodeterm-canvas is already written. See config.control.test.ts.+ expect(canControlCanvas('grok')).toBe(true)+ })+it('does not yet claim the capabilities whose per-agent leaf is unwritten', () => {expect(canContextLink('grok')).toBe(false)- expect(canControlCanvas('grok')).toBe(false)expect(hasUsage('grok')).toBe(false)expect(canBranch('grok')).toBe(false)expect(canSubagent('grok')).toBe(false)diff --git a/src/shared/agents/config.control.test.ts b/src/shared/agents/config.control.test.tsindex 01d768323..ad8009df1 100644--- a/src/shared/agents/config.control.test.ts+++ b/src/shared/agents/config.control.test.ts@@ -8,4 +8,14 @@ describe('canControlCanvas', () => {expect(canControlCanvas('gemini')).toBe(true)expect(canControlCanvas('custom:abc')).toBe(false)})++ it('grok may drive the canvas', () => {+ // Discovery needs no new installer: grok scans `~/.claude/skills` by default (its shipped+ // docs, user-guide/08-skills.md — "Claude Code compatibility (configurable)", switched off+ // only by `[compat.claude] skills = false` / GROK_CLAUDE_SKILLS_ENABLED=false), which is where+ // nodeterm already writes manage-nodeterm-canvas — locally and, via+ // RemoteHooks.installCanvasControl, on an SSH host. This list is what sets+ // NODETERM_CANVAS_CONTROL in the session env, i.e. what makes the shim usable at all.+ expect(canControlCanvas('grok')).toBe(true)+ })})diff --git a/src/shared/agents/config.ts b/src/shared/agents/config.tsindex 0b049acca..720901168 100644--- a/src/shared/agents/config.ts+++ b/src/shared/agents/config.ts@@ -108,7 +108,15 @@ export const RENAME_CAPABLE = ['claude', 'grok'] as const// Discovery differs per agent: claude gets the manage-nodeterm-canvas skill; codex/gemini/// opencode a marker block in ~/.codex/AGENTS.md / ~/.gemini/GEMINI.md /// ~/.config/opencode/AGENTS.md (see canvas-control.ts).-export const CANVAS_CONTROL_CAPABLE = ['claude', 'codex', 'gemini', 'opencode'] as const+//+// grok needs NO new installer: it scans `~/.claude/skills` by default for Claude Code+// compatibility (its shipped docs, user-guide/08-skills.md; switched off only by+// `[compat.claude] skills = false` or GROK_CLAUDE_SKILLS_ENABLED=false), and that is exactly+// where the manage-nodeterm-canvas skill is already written — locally, and on an SSH host via+// RemoteHooks.installCanvasControl. Membership here is what sets NODETERM_CANVAS_CONTROL in the+// session env (hook-server's buildPtyEnv, remoteHookEnvArgs), i.e. what makes the shim anything+// other than a no-op.+export const CANVAS_CONTROL_CAPABLE = ['claude', 'codex', 'gemini', 'opencode', 'grok'] as const// Agents whose session start-up permission mode we can set (see AgentPermissionMode below).// claude and grok share the flag SPELLING and the value vocabulary// (`--permission-mode auto|plan|acceptEdits|bypassPermissions`; our `manual` = no flag = grok's own