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-03 bp: #2719 (#2722)
0xken15633eb0c79563
diff --git a/cli/src/core/api.ts b/cli/src/core/api.tsindex 20b1c07f3..ef4fb8bf8 100644--- a/cli/src/core/api.ts+++ b/cli/src/core/api.ts@@ -868,7 +868,11 @@ export const EXPERIMENTS: Readonly<Record<string, { requests: readonly string[];memory: { requests: MEMORY_REQUESTS, state: [] },// Request-only too: it keeps nothing, and asks Jev only when a client asks it.router: { requests: ROUTER_REQUESTS, state: [] },- superTabs: { requests: SUPER_TAB_REQUESTS, state: ['super-tabs/host-*.json'] },+ // A Swarm host here, or the Harness Team account's relay grant (team/relay.ts TEAM_RELAY_GRANT_FILE), kept while a Team+ // account exists on this Mac: the relay runs in this service, and running Team agents need it back at once after an+ // update. Woken by the journal alone, a Mac that only lent its Team account restarted it at the first request that+ // happened to come, and its Team agents got "Connection refused" for four hours (Pro-9 and Pro-10, 2026-11-03).+ superTabs: { requests: SUPER_TAB_REQUESTS, state: ['super-tabs/host-*.json', 'team-relay-grant.json'] },// Cloud agents. Its harnesses: one was started here, and is watched again as the daemon starts. A New Harness// for one, an answer or a message to one wakes it too (its port's calls, core/agents/cloud.ts).cloud: { requests: CLOUD_REQUESTS, state: ['cloud/harnesses.json'] },diff --git a/cli/src/superTabs/terminal.spec.ts b/cli/src/superTabs/terminal.spec.tsindex eb4d75f8f..fe9817f7a 100644--- a/cli/src/superTabs/terminal.spec.ts+++ b/cli/src/superTabs/terminal.spec.ts@@ -472,4 +472,16 @@ describe('reading a model that keeps failing off a screen', () => {expect(modelFailing('I will handle the case where the API response is slow.\n> ')).toBe(false)expect(modelFailing(`Waiting for API response\n${'line\n'.repeat(30)}> `)).toBe(false)})++ it('knows a relay that is gone: Claude Code\'s connection lines and Codex\'s reconnect', () => {+ // Claude Code 2.1 names the connection's failure in place of "Connection error." (Pro-10's Team agent, 2026-11-03).+ for (const line of ['⎿ API Error: Unable to connect to API (ECONNREFUSED)', ' ⎿ Unable to connect to API (ECONNREFUSED) · Retrying in 4s · attempt 3/10',+ '⎿ API Error: No internet route — check your connection or VPN (ENETUNREACH)']) {+ expect(modelFailing(`work\n${line}\n> `)).toBe(true)+ }+ // Pro-9's Team Codex agents, four hours after the update.+ expect(modelFailing('• Reconnecting... waiting for network (4h 21m 27s • esc to interrupt)\n └ Connection failed: error sending request\n› Ask Codex to do anything')).toBe(true)+ expect(modelFailing('work\n └ Connection failed: error sending request\n› ')).toBe(true)+ expect(modelFailing(`I will make the client say "Unable to connect to API" when the relay is down.\n${'line\n'.repeat(30)}> `)).toBe(false)+ })})diff --git a/cli/src/superTabs/terminal.ts b/cli/src/superTabs/terminal.tsindex d1a9ca56f..952559167 100644--- a/cli/src/superTabs/terminal.ts+++ b/cli/src/superTabs/terminal.ts@@ -77,8 +77,10 @@ const MONTHS = ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', '/** An engine retrying a model that does not answer: Claude Code's "Waiting for API response · will retry in 2m 38s · check* your network" and its "API Error: 503 …", "Request timed out" or "Connection error", and Codex's "stream disconnected -* retrying" and "Reconnecting…". 2026-10-24: a Builder on a small local model retried for an hour, the relay giving up on- * every answer, while its Lead waited on it. Only near the prompt, as a limit is. */-const MODEL_LINE = /waiting for api response|api error:\s*(?:5\d\d|overloaded|request timed out|connection)|stream (?:error|disconnected)[^\n]*retrying|^\W*reconnecting\b/i+ * every answer, while its Lead waited on it. Only near the prompt, as a limit is. Claude Code 2.1 names a connection's+ * failure instead ("Unable to connect to API (ECONNREFUSED)", "No internet route — …"), and Codex says "Connection+ * failed: error sending request" under its reconnect: Team agents whose relay was gone after an update (2026-11-03). */+const MODEL_LINE = /waiting for api response|api error:\s*(?:5\d\d|overloaded|request timed out|connection)|unable to connect to api\b|no internet route\b|connection failed: error sending request|stream (?:error|disconnected)[^\n]*retrying|^\W*reconnecting\b/i/** Retries come and go on a busy model; ten minutes of them is a model the work cannot get answers from. */const MODEL_WAIT_MS = 10 * 60_000/** How long a screen must stay clear of retries before its model counts as answering again. Between retries the enginediff --git a/cli/src/team/relayRestart.spec.ts b/cli/src/team/relayRestart.spec.tsnew file mode 100644index 000000000..f7321906a--- /dev/null+++ b/cli/src/team/relayRestart.spec.ts@@ -0,0 +1,75 @@+/**+ * The owner's daemon restarting (a CLI update) under a running Harness Team session: its engine holds the relay's address+ * and token from its launch, and its next model request must find the relay there again with no person acting.+ *+ * 2026-11-03: after the 0.5.26 update every running Team agent on Pro-9 and Pro-10 got "Connection refused" for four hours.+ * The relay runs in the owner's Swarm service, which the core started at a restart only for a Mac hosting a Swarm of its own+ * (core/api.ts EXPERIMENTS); a Mac that only lends its Team account started it at the first request that woke it.+ */+import { mkdtempSync, rmSync, writeFileSync } from 'node:fs'+import { createServer } from 'node:http'+import type { AddressInfo } from 'node:net'+import { tmpdir } from 'node:os'+import { join } from 'node:path'+import { afterEach, describe, expect, it, onTestFinished } from 'vitest'+import { EXPERIMENTS } from '../core/api.js'+import { wakeExperiments } from '../core/experiments.js'+import { startSubscriptionRelay } from '../lib/subscriptionRelay.js'+import type { TeamConfig } from './config.js'+import { readRememberedGrant, TEAM_RELAY_GRANT_FILE, TeamRelayPublisher, writeRememberedGrant, type TeamRelayGrant } from './relay.js'++const config = { user: 'harnessteam', owner: 'owner', ownerHome: '/Users/owner' } as TeamConfig+const cleanup: string[] = []+afterEach(() => { for (const dir of cleanup.splice(0)) rmSync(dir, { recursive: true, force: true }) })+const dataDir = () => { const dir = mkdtempSync(join(tmpdir(), 'team-relay-restart-')); cleanup.push(dir); return dir }+/** What the core asks for as it starts, the Swarm service running in a process of its own as it does under a master. */+const woken = (dir: string) => wakeExperiments({ dataDir: dir, experiments: EXPERIMENTS, outOfProcess: new Set(Object.keys(EXPERIMENTS)), want: () => {} })++describe('restarting the owner\'s daemon under a running Team session', () => {+ it('wakes the Swarm service at start while a Team relay is kept here, and the session\'s next model request succeeds', async () => {+ const dir = dataDir()+ const file = join(dir, TEAM_RELAY_GRANT_FILE)+ const owner = { read: async () => ({ provider: 'claude' as const, accessToken: 'owner-fixture', expiresAt: null, accountId: null }), refresh: async () => null }+ const upstream = createServer((_req, res) => { res.writeHead(200); res.end('{}') })+ await new Promise<void>(resolve => upstream.listen(0, '127.0.0.1', resolve))+ onTestFinished(() => { upstream.closeAllConnections(); upstream.close() })+ const claude = `http://127.0.0.1:${(upstream.address() as AddressInfo).port}`+ // The Swarm service's relay, as superTabs/service.ts wires it, on this data folder's kept grant.+ const service = () => {+ let present = false+ const published: TeamRelayGrant[] = []+ const p = new TeamRelayPublisher({ config: () => config, user: () => 'owner', team: () => false,+ startRelay: port => startSubscriptionRelay({ owner, upstream: { claude }, ...(port ? { port } : {}) }),+ publish: async (_c, grant) => { present = true; published.push(grant) }, published: () => present, withdraw: () => { present = false }, log: () => {},+ remembered: () => readRememberedGrant(file), remember: grant => writeRememberedGrant(file, grant), forget: () => rmSync(file, { force: true }), wait: async () => {} })+ return { p, published }+ }+ const before = service()+ await before.p.tick()+ // The running session: Claude Code launched with the grant's address and token in its environment.+ const session = before.published[0]!+ const ask = async () => (await fetch(`${session.url}/claude/v1/messages`, { method: 'POST', headers: { authorization: `Bearer ${session.token}` }, body: '{}' })).status+ expect(await ask()).toBe(200)++ // The update: the daemon stops, and with it the relay.+ await before.p.stop()+ await expect(ask()).rejects.toThrow()++ // The new daemon's core starts the Swarm service only if it asks for it; this Mac hosts no Swarm of its own.+ const after = woken(dir).includes('superTabs') ? service() : null+ await after?.p.tick()+ onTestFinished(() => after?.p.stop())+ expect(await ask().catch((error: Error) => `refused: ${(error.cause as Error | undefined)?.message ?? error.message}`)).toBe(200)+ })++ it('wakes nothing for a data folder with neither the grant nor a host journal', () => {+ expect(woken(dataDir())).toEqual([])+ })++ it('names the kept grant by the name the publisher writes, beside the host journal', () => {+ expect(EXPERIMENTS.superTabs!.state).toEqual(expect.arrayContaining([TEAM_RELAY_GRANT_FILE, 'super-tabs/host-*.json']))+ const dir = dataDir()+ writeFileSync(join(dir, TEAM_RELAY_GRANT_FILE), '{}')+ expect(woken(dir)).toEqual(['superTabs'])+ })+})diff --git a/docs/plans/2026-11-03-team-relay-survives-update-plan.md b/docs/plans/2026-11-03-team-relay-survives-update-plan.mdnew file mode 100644index 000000000..e17d29635--- /dev/null+++ b/docs/plans/2026-11-03-team-relay-survives-update-plan.md@@ -0,0 +1,122 @@+# Team Agents Keep Their Model Across a CLI Update Implementation Plan++> **How this is worked:** by the project's instructions, task by task, each failing test committed before its code.++**Goal:** A Harness Team agent started before a CLI update keeps getting answers from its model after it with no person+acting, and one whose engine can't reach its model for 10 minutes is reported to the PM once.++**Architecture:** Team agents reach the owner's subscriptions through a relay the owner's daemon runs in its Swarm service+(`team/relay.ts` `TeamRelayPublisher`, wired in `superTabs/service.ts`). Since #2587 (first in CLI 0.5.26) a restarted+publisher comes back on the same port with the same token, so what a running agent holds keeps working. Two gaps remain:++1. The owner's Swarm service runs on demand, and the core wakes it as it starts only when a Swarm host journal is there+ (`core/api.ts` `EXPERIMENTS.superTabs.state`). An owner's account that only lends its Team account has none, so after an+ update nothing starts the relay until a request happens to wake the service: running Team agents get "Connection+ refused" for hours. The kept grant (`team-relay-grant.json`, which the publisher writes while a Team account exists and+ removes when it is gone) becomes saved state of the Swarm service: the core asks for the service at start, the service+ connects, and the publisher opens the relay on the kept port.+2. The host's 10-minute model alert (`superTabs/terminal.ts` `MODEL_LINE`) misses Claude Code's connection failures as it+ now writes them ("Unable to connect to API (ECONNREFUSED)", "No internet route — … (ENETUNREACH)"). Those lines are+ added, and the Codex screen from the incident is pinned by a test.++The 0.5.25 to 0.5.26 update on 2026-11-03 cut every running Team agent off once whatever this change does: the build+before it kept no grant to come back with.++**Tech Stack:** TypeScript, Vitest.++**Spec:** Task #2306 (Dee's daily improvement), brief by the PM; incident screens in the task's thread (2026-11-03).++## Global Constraints++- The PR body starts with: `Requested by [email protected] through Harness.`+- Two independent security reviews: the relay carries the owner's subscription; the owner's credential never reaches the+ Team user. This change adds no new path for the token: the same file, the same relay, the same checks.+- Never run a test that signs this Mac out of the real CLI; tests use temporary data folders and a fake upstream.+- Swarm code stays out of `cli/src/core`: the only core change is one data entry in the Swarm row of `EXPERIMENTS`, a file+ name, with no Swarm import.+- Stop only processes started here, by id. Temporary files only in `mkdtemp` folders.++## Review Focus++1. An owner's Mac whose Team account was removed: the grant file is forgotten at the first pass, so the Swarm service is+ woken once more and then no longer. (Task 1 test: a data folder without the file wakes nothing.)+2. A grant file another local user planted in the owner's data folder: the data folder is the owner's and closed; waking+ only starts the owner's own service, and `readRememberedGrant` still refuses a file not the owner's alone.+3. An agent writing about connection errors in its own words is not a failing model: the new lines are matched only near+ the prompt, as the old ones are. (Task 2 test.)+4. The host journal still wakes the service on its own: an owner who hosts a Swarm and has no Team account keeps today's+ behaviour. (Task 1 test.)+5. A Codex agent at "Reconnecting... waiting for network" is matched by the existing line; pinned so a later change to it+ cannot drop it. (Task 2 test.)++## Design++- **Growth:** nothing new is stored. The grant file already exists and is removed when the Team account is gone.+- **Concurrency:** N/A because the wake is one read at the core's start, as for the other experiments.+- **Read cost:** one more `existsSync` at the core's start.+- **Scale:** N/A because it is one file per Mac; the Swarm service's process (about 60 MiB) now also runs on owners' Macs+ that keep a Team account, which needs it for the relay anyway.+- **Compatibility:** an older core ignores the file and keeps today's behaviour; a newer one wakes the service.+- **Migration and rollback:** none. A Mac whose owner's Swarm service ran on 0.5.26 or later already has the file. Rolling+ back returns to waking on the host journal only.+- **Audience:** N/A because no data is exposed; the relay's own checks (owner-only folder, ACL for the Team user) are unchanged.+- **Identity:** the owner's daemon starts the owner's own service, as before.+- **Failure:** a relay that cannot start is logged and tried on the next pass (unchanged); an agent that still can't reach+ its model is reported to the PM after 10 minutes, now for Claude Code's connection lines too.+- **Platforms:** macOS, Linux and Windows alike: the file name is the same on each and the wake reads the data folder.++---++### Task 1: The owner's Swarm service starts again after a restart while a Team relay is kept++**Files:**+- Create: `cli/src/team/relayRestart.spec.ts`+- Modify: `cli/src/core/api.ts` (`EXPERIMENTS.superTabs.state`)++**Interfaces:**+- Consumes: `wakeExperiments` (`core/experiments.ts`), `EXPERIMENTS` (`core/api.ts`), `TeamRelayPublisher`,+ `readRememberedGrant`, `writeRememberedGrant`, `TEAM_RELAY_GRANT_FILE` (`team/relay.ts`), `startSubscriptionRelay`.+- Produces: `EXPERIMENTS.superTabs.state` includes `'team-relay-grant.json'`.++- [ ] **Step 1: Write the failing test** `restarting the owner's daemon under a running Team session`:+ - `it('wakes the Swarm service at start while a Team relay is kept here, and the session's next model request succeeds')`:+ a real relay over a fake upstream; a "session" holds the published grant and gets 200; the publisher stops (the+ daemon stops) and the request is refused; the "restart" asks `wakeExperiments` with the real `EXPERIMENTS`, a data+ folder holding only the kept grant and `outOfProcess` with `superTabs`; only if it asked for `superTabs` a new+ publisher runs; the session's same request then returns 200.+ - `it('wakes nothing for a data folder with neither the grant nor a host journal')`.+ - `it('names the kept grant by the same name the publisher writes')`: `EXPERIMENTS.superTabs.state` contains+ `TEAM_RELAY_GRANT_FILE`, and still `super-tabs/host-*.json`.+- [ ] **Step 2: Run it and watch it fail:** `npx vitest run src/team/relayRestart.spec.ts` (in `cli/`): the first and third+ fail (the service is never asked for; the state has no grant file).+- [ ] **Step 3: Add `'team-relay-grant.json'` to `EXPERIMENTS.superTabs.state`** with a comment naming the incident.+- [ ] **Step 4: Run it and see it pass**, plus `src/core/experiments.spec.ts` and `src/team/relay.spec.ts`.+- [ ] **Step 5: Commit** the test first, then the code.++### Task 2: The model alert knows Claude Code's connection failures++**Files:**+- Modify: `cli/src/superTabs/terminal.ts` (`MODEL_LINE`)+- Test: `cli/src/superTabs/terminal.spec.ts` (`reading a model that keeps failing off a screen`)++**Interfaces:**+- Consumes: `modelFailing(text: string): boolean`.+- Produces: nothing new.++- [ ] **Step 1: Write the failing test** `it('knows a relay that is gone: Claude Code's connection lines and Codex's reconnect')`:+ `modelFailing` is true for `⎿ API Error: Unable to connect to API (ECONNREFUSED)\n> `,+ ` ⎿ Unable to connect to API (ECONNREFUSED) · Retrying in 4s · attempt 3/10\n> `,+ `⎿ API Error: No internet route — check your connection or VPN (ENETUNREACH)\n> ` and the incident's Codex screen+ (`• Reconnecting... waiting for network (4h 21m 27s • esc to interrupt)\n └ Connection failed: error sending request\n› Ask Codex to do anything`);+ false for `I will make the client say "Unable to connect to API" when the relay is down.` far above the prompt+ (`\n` + 30 lines + `> `).+- [ ] **Step 2: Run it and watch it fail:** `npx vitest run src/superTabs/terminal.spec.ts -t "relay that is gone"`.+- [ ] **Step 3: Extend `MODEL_LINE`** with `unable to connect to api`, `no internet route` and `connection failed: error sending request`.+- [ ] **Step 4: Run the file and see it pass.**+- [ ] **Step 5: Commit** the test first, then the code.++### Finish++- [ ] `npm run typecheck`, `npx vitest run src/team src/superTabs/terminal.spec.ts src/core/experiments.spec.ts`, and+ `npm run test:core` (the core file changed).+- [ ] Red/green evidence in a PR comment; mark Ready; two security review steps.