The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
TypeScript 3d-modelingagent-frameworkagent-harnessai-agentscadclaude-codecodexcoding-agentsdeveloper-toolsesp32game-developmentmcp-servermulti-agentopen-hardwareopencodeopenharnesspcbroboticsterminaltmux
harness new: an agent is refused a terminal it could never read or close (#1225)
Dee8f4d5e4be482
diff --git a/cli/e2e/agentClient.e2e.ts b/cli/e2e/agentClient.e2e.tsindex 6afbb878d..3b8b0becf 100644--- a/cli/e2e/agentClient.e2e.ts+++ b/cli/e2e/agentClient.e2e.ts@@ -103,6 +103,12 @@ describe('Harness for agents, end to end', () => {expect(ps.out).toMatch(/^You are "lead" \(/)expect(ps.out).toMatch(/\nlead +Claude Code +\w+ +person \(you\)/)+ // A terminal is the person's: no verb here lists one, so the agent could never read or close it. Refused, none made.+ const shell = await run('new', 'terminal', '--', 'npm run dev')+ expect(shell.code, shell.out).toBe(1)+ expect(shell.err).toContain('An agent cannot start a terminal')+ expect((await client.request<{ agents: unknown[] }>('agents_list', {}, 30_000)).agents).toHaveLength(1)+// It starts a harness with a task, which reads who sent it, in a project Harness makes for it.const started = await run('new', 'claude', 'kid', '--name', 'kid', '--', 'hello kid')expect(started.code, started.err).toBe(0)diff --git a/cli/src/lib/newCommand.spec.ts b/cli/src/lib/newCommand.spec.tsindex c02e275f5..3b8f0e30c 100644--- a/cli/src/lib/newCommand.spec.ts+++ b/cli/src/lib/newCommand.spec.ts@@ -58,6 +58,17 @@ describe('harness new: the words', () => {expect(() => parseNewArgs(['codex', '!!!'], env)).toThrow(/no usable folder name/)})+ it('will not take a project for a terminal, which opens in a folder and makes none', () => {+ // The name used to be dropped: the terminal opened in the home folder and no project was made.+ expect(() => parseNewArgs(['terminal', 'my-game'], env)).toThrow(/does not make a project/)+ expect(() => parseNewArgs(['terminal', '--new'], env)).toThrow(NewUsageError)+ // Here, in a folder, or on another machine (its home): as before.+ expect(parseNewArgs(['terminal'], env)).toMatchObject({ agent: 'terminal', cwd: env.cwd, projectName: null })+ expect(parseNewArgs(['terminal', '~/code'], env)).toMatchObject({ cwd: `${env.home}/code`, projectName: null })+ expect(parseNewArgs(['terminal', '@mini'], env)).toMatchObject({ machine: 'mini', cwd: null, projectName: '' })+ expect(newAgentPayload(parseNewArgs(['terminal', '@mini'], env), null)).not.toHaveProperty('projectSource')+ })+it('sends what the app sends', () => {const here = newAgentPayload(parseNewArgs(['codex', '--plan', '--prompt', 'fix the tests'], env), '/work/repo')expect(here).toMatchObject({ engine: 'codex', cwd: '/work/repo', permissionMode: 'plan', bypassPermission: false, prompt: 'fix the tests' })@@ -452,6 +463,17 @@ describe('harness new: the daemon', () => {const far = deps(['codex', '--', 'go'], new FakeSocket((frame) => frame.type === 'agent_create' ? { state: 'created', agent: { id: 'f1', name: 'far' } } : null), { origin: async () => origin })expect(await newCommand(far)).toBe(0)expect(far.err).toEqual(['its limits start from zero'])+ // A terminal: refused before anything is asked of the machine. No verb of the agent's lists one, so it could+ // never read or close what it started.+ const none = new FakeSocket(() => null)+ const shell = deps(['terminal', '--json', '--', 'npm run dev'], none, { origin: async () => origin })+ expect(await newCommand(shell)).toBe(1)+ expect(JSON.parse(shell.out[0]!)).toMatchObject({ ok: false, error: expect.stringMatching(/^An agent cannot start a terminal.*Nothing was started\.$/) })+ expect(none.sent).toEqual([])+ // The person's own terminal is still made, where they are.+ const own = new FakeSocket((frame) => frame.type === 'agent_create' ? { state: 'created', agent: { id: 't1', name: 'Terminal' } } : null)+ expect(await newCommand(deps(['terminal'], own, { origin: async () => null }))).toBe(0)+ expect(own.sent[1]!.payload).toMatchObject({ engine: 'terminal', cwd: env.cwd })// A person at a terminal: no origin, the old words.const atTerminal = new FakeSocket((frame) => frame.type === 'agent_create' ? { state: 'created', agent: { id: 'c1', name: 'x' } } : null)const person = deps(['codex'], atTerminal, { origin: async () => null })diff --git a/cli/src/lib/newCommand.ts b/cli/src/lib/newCommand.tsindex 05ad29a20..2e22d1ab8 100644--- a/cli/src/lib/newCommand.ts+++ b/cli/src/lib/newCommand.ts@@ -132,6 +132,12 @@ export function parseNewArgs(argv: string[], env: { cwd: string; home: string })if (projectName !== null && projectName !== '' && projectFolderSlug(projectName) === null) {throw new NewUsageError(`“${projectName}” leaves no usable folder name.`)}+ // A terminal opens in a folder and never makes one (the machine's INVALID_PROJECT_SOURCE), so the project was left+ // out of what is sent: `harness new terminal my-game` opened a terminal in the home folder, with no ~/harnesses/my-game+ // and no word about it (CLI 0.3.76, 2026-10-12).+ if (words[0] === 'terminal' && projectName !== null) {+ throw new NewUsageError('A terminal opens in a folder; it does not make a project. Name a folder (harness new terminal ~/code/x), or none to open it here.')+ }let cwd: string | null = nullif (folder !== null) {// `~` is this machine's home only when this machine is the target; for another machine it is@@ -416,6 +422,14 @@ export async function newCommand(deps: NewCommandDeps): Promise<number> {const began = clock()try {const origin = (await deps.origin?.()) ?? null+ // A terminal is the person's: `ps`, `show`, `wait` and `close` never list one (agentClient/model.ts `isAgent`). An+ // agent that started one was told "Read it: harness show vt1", then "No harness named vt1", could not close it, and+ // had it count toward its eight for as long as it stayed open; its task would be typed into a shell, header and all+ // (the released CLI 0.3.76 on a Mac, 2026-10-12).+ if (origin && args.agent === 'terminal') {+ throw new Error('An agent cannot start a terminal: it could not read it, wait for it or close it afterwards. '+ + 'Run the command in your own shell, or start an agent for the work (harness new codex <project> -- <task>). Nothing was started.')+ }let machineId = deps.localMachineIdlet machineLabel = 'this computer'let local = true