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
fix(pane-owner): a blank-command custom agent verifies as its builtin base
reviewcf6e37f4e92a
diff --git a/src/core/pty-manager.pane-owner.test.ts b/src/core/pty-manager.pane-owner.test.tsindex 48f86e210..fd059e7fe 100644--- a/src/core/pty-manager.pane-owner.test.ts+++ b/src/core/pty-manager.pane-owner.test.ts@@ -439,6 +439,30 @@ describe('PtyManager.terminateForeground — identity gate', () => {expect(killed).toEqual([-2503294])})+ it('verifies a BLANK-command custom agent by its builtin base (claude), and kills', async () => {+ script.answer = claudeForeground+ const mgr = await killManager({+ customAgents: [{ id: 'custom:proxy', label: 'Proxy', launchCmd: '', baseAgent: 'claude' }]+ })+ expect(await mgr.terminateForeground(NODE, 'custom:proxy')).toBe(true)+ expect(killed).toEqual([-2503294])+ })++ it('REFUSES a blank-command claude-base custom agent when a shell owns the pane', async () => {+ script.answer = (file, args) => {+ if (args.includes(PANE_OWNER_FMT)) return { stdout: `2485382|${TTY}|bash|%3\n` }+ if (args.join(' ').includes('#{pane_pid}')) return { stdout: '2485382|bash' }+ if (args.includes('tpgid=')) return { stdout: '2485382' }+ if (file === 'ps') return { stdout: '2485382 2485382 Ss+ -bash' }+ return { stdout: '' }+ }+ const mgr = await killManager({+ customAgents: [{ id: 'custom:proxy', label: 'Proxy', launchCmd: '', baseAgent: 'claude' }]+ })+ expect(await mgr.terminateForeground(NODE, 'custom:proxy')).toBe(false)+ expect(killed).toEqual([])+ })+it('with no expected id, keeps the legacy shell-only guard (kills a non-shell foreground)', async () => {script.answer = claudeForegroundconst mgr = await killManager()diff --git a/src/shared/agents/pane-owner-predicate.test.ts b/src/shared/agents/pane-owner-predicate.test.tsindex 9b36c1db3..93167c9d0 100644--- a/src/shared/agents/pane-owner-predicate.test.ts+++ b/src/shared/agents/pane-owner-predicate.test.ts@@ -182,6 +182,43 @@ describe('binariesFor', () => {it('treats an unrecognised NON-custom id as its own command, mirroring resolveAgent', () => {expect(binariesFor('aider')).toEqual(['aider'])})++ it('a BLANK launch command with a base harness runs the base binary, mirroring resolveAgentConfig', () => {+ // `resolveAgentConfig`: blank launchCmd + baseAgent ⇒ the base's command (`claude`). The pane+ // therefore runs `claude`, and the predicate must be able to say so — else the common proxy+ // shape (base claude, env-only config) is unverifiable on every surface.+ const list = [+ { id: 'custom:proxy', launchCmd: ' ', baseAgent: 'claude' },+ { id: 'custom:gproxy', launchCmd: '', baseAgent: 'gemini' },+ { id: 'custom:own', launchCmd: 'my-wrapper --x', baseAgent: 'claude' },+ { id: 'custom:bogus', launchCmd: '', baseAgent: 'not-a-harness' },+ { id: 'custom:none', launchCmd: '' }+ ]+ expect(binariesFor('custom:proxy', list)).toEqual(['claude'])+ expect(binariesFor('custom:gproxy', list)).toEqual(['gemini'])+ // An explicit command still wins over the base — it is what actually runs.+ expect(binariesFor('custom:own', list)).toEqual(['my-wrapper'])+ // No (valid) base and no command: nothing honest to name.+ expect(binariesFor('custom:bogus', list)).toBeNull()+ expect(binariesFor('custom:none', list)).toBeNull()+ })++ it('never throws on a hand-edited non-string launch command — blank, same as the mirror builder', () => {+ const list = [+ { id: 'custom:num', launchCmd: 42, baseAgent: 'claude' },+ { id: 'custom:nul', launchCmd: null }+ ] as unknown as { id: string; launchCmd: string; baseAgent?: string }[]+ expect(binariesFor('custom:num', list)).toEqual(['claude'])+ expect(binariesFor('custom:nul', list)).toBeNull()+ })++ it('consumer level: a blank-command claude-base custom node verifies a claude pane, refuses a shell', () => {+ const list = [{ id: 'custom:proxy', launchCmd: '', baseAgent: 'claude' }]+ const b = binariesFor('custom:proxy', list)+ expect(isAgentPane(owner(['-bash', 'node /usr/local/bin/claude --resume x']), 'custom:proxy', b)).toBe('agent')+ expect(isAgentPane(owner(['-bash'], 'bash'), 'custom:proxy', b)).toBe('not-agent')+ expect(isAgentPane(owner(['-bash', 'codex']), 'custom:proxy', b)).toBe('not-agent')+ })})diff --git a/src/shared/agents/pane-owner-predicate.ts b/src/shared/agents/pane-owner-predicate.tsindex 28aac9f70..cd8ea0194 100644--- a/src/shared/agents/pane-owner-predicate.ts+++ b/src/shared/agents/pane-owner-predicate.ts@@ -165,22 +165,38 @@ export function binaryFromLaunchCmd(launchCmd: string | null | undefined): strin* (`src/renderer/state/workspace.ts`) resolves exactly this `launchCmd`, and falls back to the* agent id itself for an id it does not know, which is mirrored here.*- * Still null (⇒ `unknown`, ⇒ refuse) in the two cases where no honest answer exists: a- * `custom:<uuid>` whose definition is not in the list handed to us, and a launch command whose- * program cannot be named without naming something every plain shell also runs. Null is a refusal,- * not a guess — but a caller holding the settings can now avoid it for every configured agent.+ * A custom agent with a BLANK launch command and a builtin `baseAgent` answers that base's binaries,+ * because that is what `resolveAgentConfig` launches (`launchCmd.trim() || base.launchCmd`).+ *+ * Still null (⇒ `unknown`, ⇒ refuse) in the three cases where no honest answer exists: a+ * `custom:<uuid>` whose definition is not in the list handed to us; a launch command whose program+ * cannot be named without naming something every plain shell also runs; and a blank (or non-string)+ * launch command with no valid builtin `baseAgent`. Null is a refusal, not a guess — but a caller+ * holding the settings can now avoid it for every configured agent.** `customAgents` is structural rather than `CustomAgent[]` so this stays a leaf module.*/export function binariesFor(agentId: string,- customAgents?: readonly { id: string; launchCmd: string }[]+ customAgents?: readonly { id: string; launchCmd: string; baseAgent?: string }[]): readonly string[] | null {const builtin = AGENT_BINARIES[agentId]if (builtin) return builtinconst custom = customAgents?.find((c) => c.id === agentId)if (custom) {- const name = binaryFromLaunchCmd(custom.launchCmd)+ // A BLANK command with a base harness runs the base's own command — `resolveAgentConfig`+ // (`shared/agents/custom-agent.ts`) resolves `launchCmd.trim() || base.launchCmd`, so the pane+ // runs e.g. `claude`, and that is what argv will show. Without this the most common custom shape+ // (a claude-compatible proxy configured by env alone) was unverifiable on every surface. Own+ // property only: `baseAgent` is hand-editable JSON, and `constructor` must not index the table.+ // Hand-editable JSON: a non-string command is treated as blank, never dereferenced (a number+ // here used to throw inside the desktop gates). `mirrorCustomAgents` coerces the same way.+ const launchCmd = typeof custom.launchCmd === 'string' ? custom.launchCmd : ''+ if (!launchCmd.trim()) {+ const base = custom.baseAgent+ return base && Object.prototype.hasOwnProperty.call(AGENT_BINARIES, base) ? AGENT_BINARIES[base] : null+ }+ const name = binaryFromLaunchCmd(launchCmd)return name ? [name] : null}// A `custom:` id we were given no definition for is unknowable — deriving from the id would yield