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
Swarm: show why a contributed start waits; Windows: refuse a second daemon behind an access-denied claim (#1642)
0xken151172c4e8a6d9
diff --git a/cli/src/lib/windows/dataFolderClaim.spec.ts b/cli/src/lib/windows/dataFolderClaim.spec.tsindex baa397271..45a41538d 100644--- a/cli/src/lib/windows/dataFolderClaim.spec.ts+++ b/cli/src/lib/windows/dataFolderClaim.spec.ts@@ -2,7 +2,7 @@// listen fails with EADDRINUSE as a pipe's does); the real pipe is checked in dataFolderClaim.real.spec.ts.import { randomBytes } from 'node:crypto'import { connect, createServer, type Server } from 'node:net'-import { mkdirSync, mkdtempSync, realpathSync, rmSync } from 'node:fs'+import { chmodSync, mkdirSync, mkdtempSync, realpathSync, rmSync } from 'node:fs'import { join } from 'node:path'import { afterEach, describe, expect, it } from 'vitest'import { claimDataFolder, dataFolderClaimPipe, type DataFolderClaim, type DataFolderClaimDeps } from './dataFolderClaim.js'@@ -120,6 +120,18 @@ describe.skipIf(process.platform === 'win32')('the data folder claim, a Unix soc}})+ // DESKTOP-0TFH0OJ, 2026-10-23: a core started over ssh as administrator held the claim; the Desktop then started one+ // with an ordinary token, whose ask was refused with EPERM. It read that as "not Harness" and ran beside the first:+ // two hosts wrote one observer file and claimed the same deliveries. A socket nobody may write stands in for that pipe.+ it.skipIf(process.getuid?.() === 0)('refuses the start when the holder of its name may not be asked', async () => {+ const { dataDir, deps } = folder()+ await take(dataDir, TOKEN, { ...deps, holder: { pid: process.pid, corePid: process.pid } })+ const path = deps.pipeFor!(dataDir)+ chmodSync(path, 0)+ await expect(claimDataFolder(dataDir, TOKEN, deps)).rejects.toMatchObject({ code: 'EADDRINUSE',+ message: `${path} is held by something this process may not open, most likely a Harness daemon started as administrator or in another Windows session. Stop it there, then start Harness again.` })+ })+it('starts without the claim when the core holding it proves another token', async () => {const { dataDir, deps } = folder()await take(dataDir, Buffer.alloc(32, 9), { ...deps, holder: { pid: process.pid, corePid: process.pid } })diff --git a/cli/src/lib/windows/dataFolderClaim.ts b/cli/src/lib/windows/dataFolderClaim.tsindex a74891f01..53be4fcb3 100644--- a/cli/src/lib/windows/dataFolderClaim.ts+++ b/cli/src/lib/windows/dataFolderClaim.ts@@ -8,8 +8,11 @@* `\\.\pipe\` is one namespace for the whole computer, and any account may take a name nobody holds. So a start* that finds the name taken asks the holder to prove the daemon's token (pipeAuth.ts `claimProofValue`), the one* thing the claim answers. A core that proves it serves the folder: refused, unless its master is gone, which is- * waited for as `refuseServedDataFolder` waits for one. Anything else (silent, closed, a wrong proof) is not- * Harness: the start goes on without the claim, and says so. Another account cannot keep this user's daemon down.+ * waited for as `refuseServedDataFolder` waits for one. A holder that may not be asked at all (access denied) is+ * refused too: a pipe takes the token of whoever made it, so that is what a daemon started as administrator or in+ * another Windows session looks like to an ordinary start (DESKTOP-0TFH0OJ, 2026-10-23: the second core ran beside+ * the first). Anything else (silent, closed, a wrong proof) is not Harness: the start goes on without the claim,+ * and says so.*/import { createHash, randomBytes } from 'node:crypto'import { mkdirSync, realpathSync } from 'node:fs'@@ -47,7 +50,7 @@ export interface DataFolderClaimDeps {waitMs?: numberpollMs?: number/** Ask the holder of a taken name (`askHolder`); a spec stands in for a name that reads as gone. */- ask?: (path: string, token: Buffer, timeoutMs: number) => Promise<ClaimHolder | 'gone' | null>+ ask?: (path: string, token: Buffer, timeoutMs: number) => Promise<ClaimHolder | 'gone' | 'denied' | null>}const ASK_TIMEOUT_MS = 3_000@@ -98,14 +101,15 @@ function listenClaim(path: string, token: Buffer, holder: ClaimHolder): Promise<})}-/** Ask whoever holds [path] to prove [token]: the holder it names when it does, `gone` when nobody holds it, else null. */-function askHolder(path: string, token: Buffer, timeoutMs: number): Promise<ClaimHolder | 'gone' | null> {+/** Ask whoever holds [path] to prove [token]: the holder it names when it does, `gone` when nobody holds it, `denied`+ * when this process may not open it, else null. */+function askHolder(path: string, token: Buffer, timeoutMs: number): Promise<ClaimHolder | 'gone' | 'denied' | null> {return new Promise((resolve) => {const nonce = randomBytes(32).toString('hex')const socket = connect(path)let answer = ''let done = false- const finish = (result: ClaimHolder | 'gone' | null): void => {+ const finish = (result: ClaimHolder | 'gone' | 'denied' | null): void => {if (done) returndone = truesocket.destroy()@@ -113,7 +117,8 @@ function askHolder(path: string, token: Buffer, timeoutMs: number): Promise<Clai}socket.setTimeout(timeoutMs, () => finish(null))socket.on('connect', () => socket.write(`${nonce}\n`))- socket.on('error', (error: NodeJS.ErrnoException) => finish(error.code === 'ENOENT' || error.code === 'ECONNREFUSED' ? 'gone' : null))+ socket.on('error', (error: NodeJS.ErrnoException) => finish(error.code === 'ENOENT' || error.code === 'ECONNREFUSED' ? 'gone'+ : error.code === 'EPERM' || error.code === 'EACCES' ? 'denied' : null))socket.on('close', () => finish(null))socket.on('data', (chunk) => {answer += chunk.toString('utf8')@@ -152,6 +157,9 @@ export async function claimDataFolder(dataDir: string, token: Buffer, deps: Dataif ((error as NodeJS.ErrnoException).code !== 'EADDRINUSE') throw error}const found = await (deps.ask ?? askHolder)(path, token, deps.askTimeoutMs ?? ASK_TIMEOUT_MS)+ if (found === 'denied') {+ throw Object.assign(new Error(`${path} is held by something this process may not open, most likely a Harness daemon started as administrator or in another Windows session. Stop it there, then start Harness again.`), { code: 'EADDRINUSE' })+ }if (found === null) {log(`[cli] something that is not Harness holds ${path}; starting without the data folder claim`)return { path, held: false, release: () => { /* nothing held */ } }diff --git a/cli/src/superTabs/machines.spec.ts b/cli/src/superTabs/machines.spec.tsindex 1d09c6b02..605818b67 100644--- a/cli/src/superTabs/machines.spec.ts+++ b/cli/src/superTabs/machines.spec.ts@@ -19,8 +19,9 @@ function fixture() {const capabilities = vi.fn(async (_input: { cwd: string; tools: string[]; devices: string[] }) => ({ ok: true, resources: { cpuPercent: 20, memoryTotalBytes: 1000, memoryUsedBytes: 200, projectDiskFreeBytes: 1000 }, tools: { git: true } }))const start = vi.fn(async () => ({ ok: true }))const prepare = vi.fn(async () => {})- const machine = new ContributedMachines(core, 'host', { backend, open, capabilities, start, prepare, now: () => now } as never)- return { machine, pool, core, backend, open, request, close, capabilities, start, prepare, advance: () => { now += 16000 }, step: (ms: number) => { now += ms } }+ const log = vi.fn()+ const machine = new ContributedMachines(core, 'host', { backend, open, capabilities, start, prepare, log, now: () => now } as never)+ return { machine, pool, core, backend, open, request, close, capabilities, start, prepare, log, advance: () => { now += 16000 }, step: (ms: number) => { now += ms } }}describe('contributed machine executor', () => {@@ -154,6 +155,25 @@ describe('contributed machine executor', () => {expect(f.start).toHaveBeenCalledOnce()})+ // DESKTOP-0TFH0OJ, 2026-10-23: CLI 0.4.57 refused every Claude start there as not signed in (Claude ran on an API key+ // set in its settings), and the pass dropped the refusal: two starts stayed "Queued" for hours with nothing in the log.+ it('logs why a waiting start was not started, once per reason', async () => {+ const f = fixture()+ f.start.mockResolvedValue({ error: 'CAPACITY_UNAVAILABLE', startId: 'start', reasons: ['The selected agent engine is not signed in on this machine.'] } as never)+ await f.machine.tick()+ f.advance(); await f.machine.tick()+ expect(f.start).toHaveBeenCalledTimes(2)+ expect(f.log.mock.calls).toEqual([['Swarm start start is waiting: The selected agent engine is not signed in on this machine.']])+ f.start.mockRejectedValue(new Error('Could not reach the Harness backend.'))+ f.advance(); await f.machine.tick()+ f.start.mockResolvedValue({ ok: true, harnessId: 'harness' } as never)+ f.advance(); await f.machine.tick()+ f.start.mockResolvedValue({ error: 'START_PENDING', startId: 'start', detail: 'Waiting for the launched engine.' } as never)+ f.advance(); await f.machine.tick()+ expect(f.log.mock.calls.slice(1)).toEqual([['Swarm start start is waiting: Could not reach the Harness backend.'],+ ['Swarm start start is waiting: Waiting for the launched engine.']])+ })+it('a lead queues a contributed start without connecting to that computer', async () => {const open = vi.fn()const scoped = vi.fn(async () => ({ ok: true, value: { creationId: 'creation', poolGeneration: 'grant', request: { machineId: 'host', engine: 'claude' } } }))diff --git a/cli/src/superTabs/machines.ts b/cli/src/superTabs/machines.tsindex fd204c32d..9e4da3762 100644--- a/cli/src/superTabs/machines.ts+++ b/cli/src/superTabs/machines.ts@@ -39,11 +39,20 @@ export class ContributedMachines {private readonly published = new Map<string, { at: number; signature: string }>()/** Shell tool availability belongs to this machine, not a tab. Resource readings still refresh every heartbeat. */private readonly toolCache = new Map<string, { value: boolean | null; detail?: string; until: number }>()+ /** Per waiting start, why it was last not started, so the log says it once per reason, not every pass. */+ private readonly waiting = new Map<string, string>()constructor(private readonly core: CoreApi, private readonly machineId: string,private readonly deps: { backend: typeof backend; open: typeof openDaemon; capabilities: typeof readCapabilities;- start: typeof startAgent; now: () => number; prepare?: typeof prepareSwarmProject } =+ start: typeof startAgent; now: () => number; prepare?: typeof prepareSwarmProject; log?: (message: string) => void } ={ backend, open: openDaemon, capabilities: readCapabilities, start: startAgent, now: Date.now }) {}stop() { this.stopped = true }+ /** DESKTOP-0TFH0OJ, 2026-10-23: every Claude start there was refused (CLI 0.4.57 took an API-key Claude for one not+ * signed in) and the refusal was dropped, so two starts stayed "Queued" for hours with nothing in the log. */+ private noteWaiting(startId: string, reason: string) {+ if (this.waiting.get(startId) === reason) return+ this.waiting.set(startId, reason)+ ;(this.deps.log ?? (message => console.warn(`[super-tabs] ${message}`)))(`Swarm start ${startId} is waiting: ${reason}`)+ }/** One pass at a time, one [MACHINE_POLL_MS] after the last began (or a beat after one that failed). */tick(): Promise<void> {if (this.stopped || this.deps.now() < this.next) return Promise.resolve()@@ -58,7 +67,9 @@ export class ContributedMachines {private async poll(began: number) {const where = { dataDir: this.core.dataDir, port: this.core.daemon.port, machineId: this.machineId }const pools = list(await this.deps.backend(this.core, 'GET', `/api/super-tabs/hosts/${this.machineId}/pools`)).filter(row => identifier(row.tabId) && object(row.machine).machineId === this.machineId && identifier(object(row.machine).generation))- if (this.stopped || pools.length === 0) { this.published.clear(); return }+ if (this.stopped || pools.length === 0) { this.published.clear(); this.waiting.clear(); return }+ const pendingIds = new Set(pools.flatMap(row => list(row.starts).map(start => start.id)))+ for (const id of this.waiting.keys()) if (!pendingIds.has(id)) this.waiting.delete(id)for (const tab of this.published.keys()) if (!pools.some(row => row.tabId === tab)) this.published.delete(tab)// The local daemon is reached only for a reading to send, never for a pass that has nothing to say.let local: Awaited<ReturnType<typeof openDaemon>> | null = null@@ -164,10 +175,16 @@ export class ContributedMachines {}}const result = await this.deps.start({ tabId: row.tabId, startId: start.id, hostDispatch: true }, scoped, where, this.deps.open)- if (result.ok === true && identifier(result.harnessId)) await scoped({ action: 'command', operationId: `settled-${start.id}`,- command: { type: 'agent.startSettled', startId: start.id, warning: result.modelWarning ?? null } })+ if (result.ok === true && identifier(result.harnessId)) {+ this.waiting.delete(start.id)+ await scoped({ action: 'command', operationId: `settled-${start.id}`,+ command: { type: 'agent.startSettled', startId: start.id, warning: result.modelWarning ?? null } })+ } else if (result.ok !== true) {+ this.noteWaiting(start.id, String(result.detail ?? (Array.isArray(result.reasons) ? result.reasons.join(' ') : result.error)))+ }}- catch { /* Keep its durable receipt; another start must not be starved by this failure. */ }+ // Keep its durable receipt; another start must not be starved by this failure.+ catch (error) { this.noteWaiting(start.id, error instanceof Error ? error.message : String(error)) }}} catch { /* Revocation or one unavailable project cannot block another contribution. */ }}