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
Merge batch 11-05 i1710b: #3156 (#3162)
0xken15197cc242de51
diff --git a/cli/src/lib/swarmSkills.ts b/cli/src/lib/swarmSkills.tsindex 8f6aa6c22..5eca1560f 100644--- a/cli/src/lib/swarmSkills.ts+++ b/cli/src/lib/swarmSkills.ts@@ -842,9 +842,9 @@ function prepareBuddyFolder(root: string, key: string): void {ignoreBuddyFiles(root)}/** Why a Buddy is not prepared in a Harness Team account: the server's own words (backend buddyContract.ts). */-const BUDDY_NOT_HERE = 'A Buddy runs only on its owner\'s own machine, signed in as them. It is not started here.'+export const BUDDY_NOT_HERE = 'A Buddy runs only on its owner\'s own machine, signed in as them. It is not started here.'/** Why a Buddy saved before its start recorded its owner is not relaunched: its owner starts it again, and that start checks. */-const BUDDY_START_AGAIN = 'This Buddy was started before Harness checked its machine at each launch. Start your Buddy again.'+export const BUDDY_START_AGAIN = 'This Buddy was started before Harness checked its machine at each launch. Start your Buddy again.'/** Which built-in text a session's skill file holds and of which mode, how many times the file was rewritten, and the text,* mode and rewrite its agent was last confirmed told about (the launch prompt is rewrite 0). A file from before this recorddiff --git a/cli/src/superTabs/buddyModel.spec.ts b/cli/src/superTabs/buddyModel.spec.tsindex 86a5122c6..94363794e 100644--- a/cli/src/superTabs/buddyModel.spec.ts+++ b/cli/src/superTabs/buddyModel.spec.ts@@ -5,6 +5,7 @@ import { mkdtempSync } from 'node:fs'import { tmpdir } from 'node:os'import { join } from 'node:path'import { describe, expect, it } from 'vitest'+import { BUDDY_NOT_HERE, BUDDY_START_AGAIN } from '../lib/swarmSkills.js'import { BuddyModelRequests, type BuddyModelRow } from './buddyModel.js'const GRID = 'swarm-0123456789ab'@@ -85,6 +86,25 @@ describe('carrying out a Buddy\'s model request', () => {}})+ // Task #3256: a switch relaunches the Buddy, and the Buddy guard (lib/swarmSkills.ts prepareBuddyFolder) holds one started+ // before its owner was recorded, or one not on its owner's machine. The launch reports SWARM_SKILL_FAILED with the guard's+ // sentence as its detail (lib/launchOverrides.ts); its owner reads what to do, never the code or the detail.+ it("says Start your Buddy again when the Buddy guard holds the relaunch, and never the guard's detail", async () => {+ const held = (sentence: string) => ({ error: 'SWARM_SKILL_FAILED', detail: String(new Error(sentence)) })+ const cases: Array<[Record<string, unknown>, string]> = [+ [held(BUDDY_START_AGAIN), 'Start your Buddy again to switch its model'],+ [held(BUDDY_NOT_HERE), 'Your Buddy runs only on your own computer, signed in as you'],+ [{ error: 'SWARM_SKILL_FAILED', detail: 'Error: EACCES /Users/someone/.claude' }, 'its computer could not switch it (SWARM_SKILL_FAILED)'],+ [{ error: 'RESPAWN_FAILED', detail: String(new Error(BUDDY_START_AGAIN)) }, 'its computer could not switch it (RESPAWN_FAILED)'],+ ]+ for (const [answer, error] of cases) {+ const f = fixture({ answers: [answer] })+ await f.runner.serve(main(), [thread('h-a')])+ expect(f.frames).toHaveLength(1)+ expect(f.posts).toEqual([{ asAgentId: 'buddy', type: 'buddy.modelResult', agentId: 'buddy', requestId: 'req1', ok: false, error }])+ }+ })+it('waits for the turn to end before sending a Buddy home by itself, then moves it', async () => {const f = fixture({ answers: [{ error: 'AGENT_BUSY' }, { retargeted: true }] })const home = main(request({ gridModel: null, gridName: undefined, reason: 'limit' }))diff --git a/cli/src/superTabs/buddyModel.ts b/cli/src/superTabs/buddyModel.tsindex 5cb4f1a26..233628deb 100644--- a/cli/src/superTabs/buddyModel.ts+++ b/cli/src/superTabs/buddyModel.ts@@ -13,6 +13,7 @@ import { existsSync, renameSync, writeFileSync } from 'node:fs'import { join } from 'node:path'import type { Daemon } from '../agentClient/daemon.js'import { readPrivateStateFile, secureStateDirectory } from '../lib/secureState.js'+import { BUDDY_NOT_HERE, BUDDY_START_AGAIN } from '../lib/swarmSkills.js'import { identifier, object } from './wire.js'/** A conversation this share of the model's window or more starts fresh: the rest is the room its next turns need. */@@ -51,9 +52,14 @@ function requestOf(value: unknown): ModelRequest | null {...(typeof r.reason === 'string' ? { reason: r.reason } : {}) }}-/** Why a move was refused, in words its owner can act on: never the daemon's detail, which can name paths on this machine. */-function refusal(code: string, request: ModelRequest): string {+/** Why a move was refused, in words its owner can act on: never the daemon's detail, which can name paths on this machine.+ * The detail is only read for the Buddy guard's two holds (lib/swarmSkills.ts prepareBuddyFolder), which every relaunch runs+ * and the launch reports as SWARM_SKILL_FAILED with the guard's own sentence (lib/launchOverrides.ts). Task #3256: Scholes's+ * switch to his saved API, on a Buddy started before its owner was recorded, said only the code. */+function refusal(code: string, request: ModelRequest, detail?: string): string {if (code === 'AGENT_BUSY') return 'Your Buddy is answering. Try again when it has finished'+ if (code === 'SWARM_SKILL_FAILED' && detail?.includes(BUDDY_START_AGAIN)) return 'Start your Buddy again to switch its model'+ if (code === 'SWARM_SKILL_FAILED' && detail?.includes(BUDDY_NOT_HERE)) return 'Your Buddy runs only on your own computer, signed in as you'if ((code === 'GRID_UNAVAILABLE' || code === 'API_UNAVAILABLE') && request.gridModel) {const name = request.name ?? request.gridModelreturn request.servedBy?.length ? `${request.servedBy.join(', ')} isn't serving ${name} now` : `Nobody serves ${name} now`@@ -101,23 +107,24 @@ export class BuddyModelRequests {private async carryOut(row: BuddyModelRow, sessions: readonly BuddyModelRow[], request: ModelRequest): Promise<Outcome | 'wait'> {const daemon = await this.deps.open()try {- const move = async (harnessId: string): Promise<{ error?: string; fresh: boolean }> => {+ const move = async (harnessId: string): Promise<{ error?: string; detail?: string; fresh: boolean }> => {const fresh = await this.tooLong(harnessId, request)const frame = request.gridModel === null ? { agentId: harnessId, clearGrid: true }: { agentId: harnessId, gridModel: request.gridModel, gridName: request.gridName, ...(fresh ? { fresh: true } : {}) }- const reply = await daemon.request('agent_retarget', frame, MOVE_TIMEOUT_MS).catch(() => ({ error: 'TIMEOUT' }))- return { ...(typeof reply.error === 'string' ? { error: reply.error } : {}), fresh }+ const reply = await daemon.request('agent_retarget', frame, MOVE_TIMEOUT_MS).catch((): Record<string, unknown> => ({ error: 'TIMEOUT' }))+ return { ...(typeof reply.error === 'string' ? { error: reply.error } : {}),+ ...(typeof reply.detail === 'string' ? { detail: reply.detail } : {}), fresh }}const moved = await move(row.agent.harnessId)if (moved.error) {// Sent home by the Swarm (a limit, a model gone) while it answers: moved once the turn ends, within the request's lease.if (moved.error === 'AGENT_BUSY' && request.reason) return 'wait'- return { ok: false, error: refusal(moved.error, request) }+ return { ok: false, error: refusal(moved.error, request, moved.detail) }}const stayed: string[] = []for (const session of sessions) {const result = await move(session.agent.harnessId)- if (result.error) stayed.push(result.error === 'AGENT_BUSY' ? 'it was answering' : refusal(result.error, request))+ if (result.error) stayed.push(result.error === 'AGENT_BUSY' ? 'it was answering' : refusal(result.error, request, result.detail))}return { ok: true, ...(moved.fresh ? { fresh: true as const } : {}),...(stayed.length === 1 ? { error: `A thread session stayed where it was: ${stayed[0]}` }diff --git a/docs/plans/2026-11-05-buddy-switch-start-again-plan.md b/docs/plans/2026-11-05-buddy-switch-start-again-plan.mdnew file mode 100644index 000000000..c8cee3e9b--- /dev/null+++ b/docs/plans/2026-11-05-buddy-switch-start-again-plan.md@@ -0,0 +1,43 @@+# A Buddy model switch that can't run says why and offers Start again — Plan++**Goal:** When a Buddy's model switch is refused by the Buddy guard, its owner reads why in plain words ("Start your Buddy+again to switch its model") instead of `its computer could not switch it (SWARM_SKILL_FAILED)`, and Desktop offers a+one-click Start again.+**Architecture:** The switch relaunches the Buddy through the daemon's `agent_retarget`; the relaunch's launch overrides+(cli/src/lib/launchOverrides.ts) run `prepareBuddyFolder` (cli/src/lib/swarmSkills.ts), whose guard throws one of two fixed+sentences, and return `SWARM_SKILL_FAILED` with that sentence as the detail. `refusal()` in cli/src/superTabs/buddyModel.ts+reads only the code. It now also recognises the guard's two sentences in the detail (the constants exported from+swarmSkills.ts, unchanged) and maps each to its own sentence; the detail itself is still never forwarded. The launch error+code stays `SWARM_SKILL_FAILED`, so the launch telemetry families and every other relaunch caller keep their contract.+**Tech Stack:** TypeScript CLI, vitest; Flutter Desktop, flutter_test.+**Spec:** Task #3256 (Scholes, 11-05; Guide2's evidence from task #3069). This plan is implemented by its Engineer, test first,+with no execution handoff.++## Global Constraints+- The Buddy guard stays as strict: no condition in `prepareBuddyFolder` changes, only which words reach the owner.+- No path or daemon detail reaches the owner: refusals are fixed sentences.+- Swarm code stays out of cli/src/core. Two security reviews (Buddy guard).+- Part 2 (Desktop) is built only after Scholes approves the mockup posted in the task.++## Review Focus+- The guard's conditions are unchanged (only `export` added to its two sentences).+- A detail that merely mentions a sentence cannot make any other failure look like success: it only changes refusal words.++## Tasks++### 1. Plain refusal words for the guard's two holds+**Files:** cli/src/superTabs/buddyModel.ts, cli/src/superTabs/buddyModel.spec.ts, cli/src/lib/swarmSkills.ts (export only)+**Interfaces:** `export const BUDDY_START_AGAIN`, `export const BUDDY_NOT_HERE` (swarmSkills.ts).+- [ ] Failing test: an `agent_retarget` answer `{ error: 'SWARM_SKILL_FAILED', detail: String(new Error(BUDDY_START_AGAIN)) }`+ reports `Start your Buddy again to switch its model`; with `BUDDY_NOT_HERE` it reports+ `Your Buddy runs only on your own computer, signed in as you`; any other `SWARM_SKILL_FAILED` keeps the code sentence.+- [ ] Watch it fail, commit.+- [ ] `refusal()` reads the detail of a `SWARM_SKILL_FAILED` answer for the two sentences. Test passes, commit.++### 2. Desktop offers Start again before a switch (after Scholes's yes)+**Files:** desktop/lib/super_tabs/buddies.dart, desktop/test/+- [ ] Failing widget test: a Swarm Buddy bar whose Buddy's owner isn't recorded shows "Start your Buddy again to switch its+ model." with a Start again button that calls `addBuddy` for its machine and engine, and no model picker.+- [ ] Watch it fail, commit; build the row; test passes, commit.+- The signal Desktop reads for "owner not recorded" is decided with the PM in the task (it needs the Buddy's machine to+ report it, outside this task's files today).