Skip to content

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.

fix(cli): a Buddy's help offers stdin nowhere, its command entry included (#2399)

0xken158bc7bec58322
diff --git a/cli/src/superTabs/service.spec.ts b/cli/src/superTabs/service.spec.ts
index 55b195b48..ad0cf43f9 100644
--- a/cli/src/superTabs/service.spec.ts
+++ b/cli/src/superTabs/service.spec.ts
@@ -1240,8 +1240,8 @@ describe('a Buddy\'s help', () => {
const buddy = await help(t, { tabId: 'tab', agentId: t.agentId })
expectBuddy(buddy)
expect(await help(t, { tabId: 'tab', harnessId: 'native' })).toEqual(buddy)
- // Only the post line differs: a Buddy reads the same help otherwise, and no Lead option.
- expect({ ...buddy, post: null }).toEqual({ ...plain, post: null })
+ // Only the post and command lines differ: a Buddy reads the same help otherwise, and no Lead option.
+ expect({ ...buddy, post: null, command: null }).toEqual({ ...plain, post: null, command: null })
const lead = setup()
lead.call.mockImplementation(async (_method, path) => ({ status: 200, body: { success: true, data: swarmData(lead.agent, path,
{ agents: [lead.agent], projects: [{ id: 'pilot', leadConversationId: 'pilot' }], conversations: [{ id: 'pilot', leadId: lead.agentId, agentIds: [lead.agentId] }] }) } }))
@@ -1250,6 +1250,26 @@ describe('a Buddy\'s help', () => {
expect(String(leadHelp.post)).toContain('--mention')
})
+ // A Buddy's help kept the command entry's stdin form (- in the JSON's place, a heredoc), which its guard refuses as well:
+ // it offers stdin nowhere, and everyone else's command entry keeps it.
+ it('offers a Buddy stdin nowhere, and keeps the command entry\'s stdin form for a Builder', async () => {
+ const COMMAND_STDIN = "put - in its place and send it on stdin (command OPERATION_ID - <<'JSON' … JSON)"
+ const builder = setup()
+ const plain = await help(builder, { tabId: 'tab', agentId: builder.agentId })
+ expect(String(plain.command)).toContain(COMMAND_STDIN)
+ const t = setup()
+ Object.assign(t.agent, { buddyOf: { personId: 'peer', generation: 'g' } })
+ const buddy = await help(t, { tabId: 'tab', agentId: t.agentId })
+ expect(String(buddy.command)).toMatch(/^command OPERATION_ID JSON: send one of the commands below\. The JSON is one argument, in single quotes/)
+ expect(String(buddy.command)).toContain("command OPERATION_ID '{...}' (an apostrophe inside it as \\u0027). Reuse exactly")
+ // The rest of the entry is everyone's: only how the JSON is passed differs.
+ const tail = (text: unknown) => String(text).slice(String(text).indexOf(' Reuse exactly the same ID'))
+ expect(tail(buddy.command)).toBe(tail(plain.command))
+ // No entry offers stdin: no heredoc, no - in an argument's place, no TEXT|-. Its post may still say stdin is refused.
+ for (const [key, text] of Object.entries(buddy)) expect(JSON.stringify(text), key).not.toMatch(/<<|in its place|send (it|the [a-zA-Z]+) on stdin|\|-/)
+ expect(JSON.stringify(plain)).toMatch(/<<'JSON'/)
+ })
+
it('is a Buddy\'s help for a harness this computer started as a Buddy, as its guard is', async () => {
const t = setup()
localBuddy(t)
diff --git a/cli/src/superTabs/service.ts b/cli/src/superTabs/service.ts
index 4511b0540..0f30a92a7 100644
--- a/cli/src/superTabs/service.ts
+++ b/cli/src/superTabs/service.ts
@@ -42,6 +42,12 @@ const POST_HELP = `${POST_ABOUT} TEXT is one argument: when it holds quotes, or
/** A Buddy's guard refuses TEXT - (#2358): on stdin its message would skip the secret check. A Buddy that followed the stdin
* hint was refused and tried again, so its help passes the message in quotes, as the guard's refusal says. */
const BUDDY_POST_HELP = `${POST_ABOUT} TEXT is one argument, the message itself in quotes: 'your message', or "it's done" when it holds an apostrophe. A Buddy never passes - for TEXT: its message is checked for secrets, so one read from stdin is refused and nothing is posted.`
+/** What the command entry says after how its JSON is passed, the same for everyone. */
+const COMMAND_ABOUT = 'send one of the commands below.'
+const COMMAND_RULES = 'Reuse exactly the same ID and JSON after an interrupted request. On Custom skills, work.assign takes "roleId" too, a role of the agent\'s kind. When your assignment needs a person to decide, set work.status needs_human; when you cannot go on, blocked. Set working again once it moves. rule.set and rule.remove change one project\'s routing rules: only the project owner does (naming projectId), or that project\'s Lead passing on the project owner\'s request, with askedIn naming the project owner\'s message in that project\'s chat. project.skills switches a project between the Default, Harness orchestration and Custom skills (Custom once its owner has made the project\'s roles): only its project owner does, or its Lead passing on that owner\'s own chat message, with askedIn naming it. tab.tidy turns off, or back on, the Swarm\'s tidying: workers idle for 15 minutes stop and finished groups archive once their pull requests are merged or closed. Only the Swarm owner does, or a Lead passing on the owner\'s own chat message, with askedIn naming it. Two failed starts in a row suspend an engine on a machine for up to 6 hours (the route says so); machine.engineResume offers it there again: only the machine\'s owner does, or the Lead passing on the owner\'s chat message, with askedIn naming it. A start, assignment or route that breaks a hard rule (forbidModel, machines, minEffort) is refused for agents; preferEngine, preferIdle and noGridFirst only rank. A build needs a model the policy rates 3 (Opus high, Astra xhigh, Codex) unless a person names the model. A model on the Swarm\'s grid builds only low-risk work of kind docs, tests or fixtures, unless a person asks for a local model or names one, and ranks first there unless the owner set noGridFirst (at medium difficulty a grid model rated 2, such as Kimi K3 or DeepSeek v4.1). A review never runs on a grid model or below quality 2, and never by the agent that built the work; any engine reviews any build. When a grid attempt\'s first review says Ready no, or its grid host never starts the agent, the Swarm closes it and steps the task up (no grid, at the top tier as every build, at most twice) and tells you: route it again, and the route and the server keep to the new floor.'
+/** A Buddy's guard refuses `command` itself and every JSON read from stdin, so its help never offers - and stdin there either
+ * (a Buddy that follows a stdin form is refused and tries again, #2360); it quotes the JSON, as its usage hints do. */
+const BUDDY_COMMAND_HELP = `command OPERATION_ID JSON: ${COMMAND_ABOUT} The JSON is one argument, in single quotes: command OPERATION_ID '{...}' (an apostrophe inside it as \\u0027). ${COMMAND_RULES}`
/** Done or Stopped from an agent finishing its own work carries its session's token totals by model, read from its transcript
* now (core `usageFresh`): its attempt ends with every token it used, not a machine report up to a beat old (backend
* superTabs/costs/attempts.ts endRun; review of #2106). Counts only. No reading, and the status goes without them. */
@@ -77,7 +83,7 @@ const HELP = {
capacity: 'capacity MACHINE_ID JSON: inspect machine, engine and quota headroom. JSON uses the start request fields below. Unknown allowances are not reported as free tokens.',
startRequest: { conversationId: 'GROUP', machineId: 'MACHINE', engine: 'codex', name: 'Builder', cwd: '/absolute/repo/on/that/machine', worktree: true, branchRef: 'refs/remotes/origin/BASE_BRANCH', requirements: START_REQUIREMENTS,
model: 'opus', effort: 'high', routeDecisionId: 'DECISION' },
- command: 'command OPERATION_ID JSON: send one of the commands below. The JSON is one argument: when it holds quotes, put - in its place and send it on stdin (command OPERATION_ID - <<\'JSON\' … JSON). Reuse exactly the same ID and JSON after an interrupted request. On Custom skills, work.assign takes "roleId" too, a role of the agent\'s kind. When your assignment needs a person to decide, set work.status needs_human; when you cannot go on, blocked. Set working again once it moves. rule.set and rule.remove change one project\'s routing rules: only the project owner does (naming projectId), or that project\'s Lead passing on the project owner\'s request, with askedIn naming the project owner\'s message in that project\'s chat. project.skills switches a project between the Default, Harness orchestration and Custom skills (Custom once its owner has made the project\'s roles): only its project owner does, or its Lead passing on that owner\'s own chat message, with askedIn naming it. tab.tidy turns off, or back on, the Swarm\'s tidying: workers idle for 15 minutes stop and finished groups archive once their pull requests are merged or closed. Only the Swarm owner does, or a Lead passing on the owner\'s own chat message, with askedIn naming it. Two failed starts in a row suspend an engine on a machine for up to 6 hours (the route says so); machine.engineResume offers it there again: only the machine\'s owner does, or the Lead passing on the owner\'s chat message, with askedIn naming it. A start, assignment or route that breaks a hard rule (forbidModel, machines, minEffort) is refused for agents; preferEngine, preferIdle and noGridFirst only rank. A build needs a model the policy rates 3 (Opus high, Astra xhigh, Codex) unless a person names the model. A model on the Swarm\'s grid builds only low-risk work of kind docs, tests or fixtures, unless a person asks for a local model or names one, and ranks first there unless the owner set noGridFirst (at medium difficulty a grid model rated 2, such as Kimi K3 or DeepSeek v4.1). A review never runs on a grid model or below quality 2, and never by the agent that built the work; any engine reviews any build. When a grid attempt\'s first review says Ready no, or its grid host never starts the agent, the Swarm closes it and steps the task up (no grid, at the top tier as every build, at most twice) and tells you: route it again, and the route and the server keep to the new floor.',
+ command: `command OPERATION_ID JSON: ${COMMAND_ABOUT} The JSON is one argument: when it holds quotes, put - in its place and send it on stdin (command OPERATION_ID - <<'JSON' … JSON). ${COMMAND_RULES}`,
commands: [
{ type: 'project.report', projectId: 'PROJECT', through: { GROUP: 214031 }, text: 'What changed, what is blocked, and what comes next. Use null when nothing merits repeating.' },
{ type: 'project.repository', projectId: 'PROJECT', repositoryUrl: 'https://github.com/OWNER/REPOSITORY' },
@@ -127,8 +133,9 @@ const LEAD_HELP = { ...HELP, post: `post GROUP TEXT|- OPERATION_ID [--reply-to M
commands: [...HELP.commands, { type: 'decision.ask', conversationId: 'GROUP', personId: 'PERSON', questions: [{ question: 'One question a person decides',
options: ['Option A', 'Option B'], recommended: 0, unblocks: 'What the answer unblocks' }] },
{ type: 'person.tell', personId: 'PERSON', text: 'A line for one person, in their Buddy chat; members watching your terminal see it too' }] }
-/** A Buddy's help: the same, with its post passing the message as TEXT itself (BUDDY_POST_HELP). */
-const BUDDY_HELP = { ...HELP, post: `post GROUP TEXT OPERATION_ID [--reply-to MESSAGE_ID] [--attach PATH]...: ${BUDDY_POST_HELP}` }
+/** A Buddy's help: the same, with its post passing the message as TEXT itself (BUDDY_POST_HELP) and its command the JSON in
+ * quotes (BUDDY_COMMAND_HELP): no stdin anywhere. */
+const BUDDY_HELP = { ...HELP, post: `post GROUP TEXT OPERATION_ID [--reply-to MESSAGE_ID] [--attach PATH]...: ${BUDDY_POST_HELP}`, command: BUDDY_COMMAND_HELP }
const OTHER_WORK_FIELDS = ['conversationId', 'projectName', 'title', 'owns', 'status', 'agentName', 'pr'] as const
/** How old a host form a one-off question about this machine's Swarms may take: the host reads one every second. */
const POOLS_FRESH_MS = 5_000