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-04 b2225: #3039 #3042 (#3044)
0xken15350b14ab2492
diff --git a/backend/integration/superTabRead.test.ts b/backend/integration/superTabRead.test.tsindex 7b2aa6bf2..9a581fe5f 100644--- a/backend/integration/superTabRead.test.ts+++ b/backend/integration/superTabRead.test.ts@@ -1310,7 +1310,10 @@ describe('the summary only when it changed (derivedEtag)', () => {describe('routes given only a store', () => {it('read from that store\'s database, not the app-wide client', async () => {- const s = await scene()+ // On a machine of its own: the full host read loads every Swarm of the machine, and 'host' holds one for each test before this.+ const machineId = `m-${randomUUID().slice(0, 8)}`+ await db.machine.create({ data: { machineId, userId: owner.sub, apiKey: 'fixture-only', managerId: 'fixture', autonomousEnv: 'prod', authMode: 'remote' } })+ const s = await scene(f => { f.contribute(machineId, 'swarm') }, machineId)const plain = Fastify()plain.setErrorHandler(errorHandler)plain.addHook('onRequest', async request => { request.user = owner })@@ -1318,7 +1321,10 @@ describe('routes given only a store', () => {await plain.ready()try {expect((await plain.inject({ method: 'GET', url: `/api/super-tabs/${s.tabId}/parts` })).statusCode).toBe(200)- expect((await plain.inject({ method: 'GET', url: '/api/super-tabs/hosts/host/changes?full=1' })).statusCode).toBe(200)+ const hosts = await plain.inject({ method: 'GET', url: `/api/super-tabs/hosts/${machineId}/changes?full=1` })+ expect(hosts.statusCode).toBe(200)+ // Only this test's own Swarm: a machine shared with every earlier test's Swarm made this read take 4 s here and 10 s on CI.+ expect(hosts.json().data.tabs.map((t: { tabId: string }) => t.tabId)).toEqual([s.tabId])} finally { await plain.close() }}, 10_000)})@@ -1329,7 +1335,22 @@ describe('what a read costs the database (group 3b)', () => {const out = ((await db.$runCommandRaw({ serverStatus: 1 })) as { network: { bytesOut: unknown } }).network.bytesOutreturn typeof out === 'number' ? out : Number((out as { $numberLong?: string; $numberInt?: string }).$numberLong ?? (out as { $numberInt?: string }).$numberInt)}+ /** Waits until nothing else is reading or writing: what MongoDB sends in a tenth of a second (the first read's own answer+ * and whatever else lands meanwhile) is the same four times running. Earlier tests' background work (a command's notices+ * and wakes, a read a timed-out test left going) would otherwise land in the next test's count. */+ const quiet = async () => {+ let last = -1, steady = 0+ for (let tries = 0; tries < 300 && steady < 4; tries++) {+ const before = await sent()+ await new Promise(done => setTimeout(done, 100))+ const sentSince = await sent() - before+ steady = sentSince === last ? steady + 1 : 0+ last = sentSince+ }+ if (steady < 4) throw new Error('The database never went quiet: something keeps reading or writing.')+ }async function databaseBytes(call: () => Promise<unknown>): Promise<number> {+ await quiet()const before = await sent(), own = await sent() - beforeconst start = await sent()await call()@@ -1345,6 +1366,14 @@ describe('what a read costs the database (group 3b)', () => {for (let i = 0; i < 60; i++) s.run({ type: 'conversation.create', title: `Old work ${i}`, brief: `${'Long brief text. '.repeat(470)}${i}`, checks: [] })}+ it('counts none of the reads an earlier test left running', async () => {+ const s = await scene(f => bulky(f))+ // What a test that ends before its own background work does: reads of the whole Swarm, still going into the next one.+ const leftover = (async () => { for (let i = 0; i < 40; i++) await db.$transaction(tx => parts.loadAll(tx, s.tabId)) })()+ expect(await databaseBytes(() => new Promise(done => setTimeout(done, 200)))).toBeLessThan(1_000)+ await leftover+ })+it('a Desktop change read with nothing changed loads a few tens of KB, not the Swarm', async () => {const s = await scene(f => bulky(f))const whole = await swarmBytes(s.tabId)diff --git a/backend/src/superTabs/liveness.test.ts b/backend/src/superTabs/liveness.test.tsindex a7b7ba031..890c76a67 100644--- a/backend/src/superTabs/liveness.test.ts+++ b/backend/src/superTabs/liveness.test.ts@@ -44,6 +44,61 @@ describe('the lease on a worker\'s task', () => {})})+describe('a task waiting on a person (task #2969)', () => {+ // 2026-11-04: an Engineer asked Huy, set needs_human with a 10:00 default, printed nothing, and lost its task after 30 minutes.+ const asked = 1_000_000, HOUR = 60 * MINUTE+ const waiting = (patch: Partial<Assignment> = {}, report: { receivedAt: number; harnessProgress?: Record<string, number> } | undefined = { receivedAt: asked + 2 * HOUR, harnessProgress: { h: asked } }) =>+ swarm(assignment({ status: 'needs_human', result: 'Mockup OK?', leaseUntil: asked + LEASE_MS, progressAt: asked, ...patch }), report)++ it('stays its agent\'s for 2 hours while the agent is alive on its machine, whatever its screen does', () => {+ for (const status of ['needs_human', 'blocked'] as const) {+ const idle = waiting({ status })+ expect(sweepLiveness(idle, asked + 2 * HOUR)).toEqual([])+ expect(idle.conversations[1]!.assignment!.status).toBe(status)+ // Even a session that reports no progress at all.+ expect(sweepLiveness(waiting({ status }, { receivedAt: asked + 2 * HOUR, harnessProgress: {} }), asked + 2 * HOUR)).toEqual([])+ }+ })++ it('is lost once its session is stopped, its machine is offline past the grace, or it is no longer running', () => {+ const stopped = waiting()+ stopped.machines![0]!.observation!.stoppedHarnessIds = ['h']+ expect(status(stopped, asked + 2 * HOUR).status).toBe('lost')+ const offline = waiting()+ expect(status(offline, asked + 2 * HOUR + 3 * MINUTE).status).toBe('lost')+ const gone = waiting()+ gone.machines![0]!.observation!.runningHarnessIds = []+ expect(status(gone, asked + 2 * HOUR).status).toBe('lost')+ })++ it('is lost when no report ever showed its session, as before', () => {+ const unseen = waiting()+ unseen.machines = []+ expect(status(unseen, asked + 2 * HOUR).status).toBe('lost')+ })++ it('runs 30 minutes from the person\'s answer, then is lost if the agent stays quiet', () => {+ const answeredAt = asked + HOUR+ const answered = (now: number) => {+ const state = waiting({}, { receivedAt: now, harnessProgress: { h: asked } })+ state.conversations[1]!.ledger = { waiting: { assignmentId: 'a1', since: asked, messageId: 'm', answeredAt } } as never+ return state+ }+ expect(status(answered(answeredAt + QUIET_RUNNING_MS), answeredAt + QUIET_RUNNING_MS).status).toBe('needs_human')+ expect(status(answered(answeredAt + QUIET_RUNNING_MS + 1), answeredAt + QUIET_RUNNING_MS + 1)).toMatchObject({ status: 'lost', lost: { reason: expect.stringContaining('no progress') } })+ })++ it('keeps today\'s 30-minute rule for a working assignment', () => {+ const working = (now: number) => swarm(assignment({ leaseUntil: asked + LEASE_MS, progressAt: asked }), { receivedAt: now, harnessProgress: { h: asked } })+ expect(status(working(asked + QUIET_RUNNING_MS), asked + QUIET_RUNNING_MS).status).toBe('working')+ expect(status(working(asked + QUIET_RUNNING_MS + 1), asked + QUIET_RUNNING_MS + 1).status).toBe('lost')+ })++ it('has no loss time while it waits for the person, so a machine\'s report is not scheduled for it', () => {+ expect(nextLossAt(waiting(), 'm')).toBeUndefined()+ })+})+describe('a task waiting for review', () => {// 2026-10-29: five Engineers who had pushed and handed over lost their tasks after 30 quiet minutes waiting for a Reviewer.const handedOver = 1_000_000diff --git a/backend/src/superTabs/liveness.ts b/backend/src/superTabs/liveness.tsindex 8aeb1b54f..0e4f01c1a 100644--- a/backend/src/superTabs/liveness.ts+++ b/backend/src/superTabs/liveness.ts@@ -248,10 +248,28 @@ function reportRenewedAt(state: SuperTabState, worker: Agent): number | undefinereturn progress === undefined ? undefined : Math.min(report.receivedAt, progress + PROGRESS_FRESH_MS)}+/** When the person its agent asked answered, while the assignment still says needs_human (the agent has not set working yet). */+function answeredAt(group: Conversation, assignment: Assignment): number | undefined {+ const waiting = group.ledger?.waiting+ return assignment.status === 'needs_human' && waiting?.assignmentId === assignment.id ? waiting.answeredAt ?? undefined : undefined+}++/** A task waits on a person (needs_human, or blocked: its agent cannot go on) and its agent is alive: its machine's last report+ * lists the session running. Its terminal prints nothing while it waits, so quiet time does not count (Ken, 2026-11-04, #2969:+ * a task waiting on Huy was lost after 30 quiet minutes, twice). Not once the person answered (the agent then has 30 minutes+ * from the answer, leaseEnd), and not for an agent no report shows running: that one is gone and loses it as before. */+function waitingOnPerson(state: SuperTabState, group: Conversation, worker: Agent, assignment: Assignment): boolean {+ return (assignment.status === 'needs_human' || assignment.status === 'blocked') && answeredAt(group, assignment) === undefined+ && !!state.machines?.find(m => m.machineId === worker.machineId)?.observation?.runningHarnessIds.includes(worker.harnessId)+}+/** When a worker's lease ends: from its own last status, check or post (for an assignment from before leases, its group's- * last message), or from its machine's reports, whichever is later. Undefined when nothing ever renewed it. */+ * last message), or from its machine's reports, whichever is later; a person's answer to its question starts its quiet+ * time too. Undefined when nothing ever renewed it. */function leaseEnd(group: Conversation, assignment: Assignment, renewed: number | undefined): number | undefined {- const own = assignment.leaseUntil ?? (group.lastActivityAt ? Date.parse(group.lastActivityAt) + LEASE_MS : undefined)+ const answered = answeredAt(group, assignment)+ const lease = assignment.leaseUntil ?? (group.lastActivityAt ? Date.parse(group.lastActivityAt) + LEASE_MS : undefined)+ const own = answered === undefined ? lease : Math.max(lease ?? 0, answered + QUIET_RUNNING_MS)const reported = renewed === undefined ? undefined : renewed + LEASE_MSreturn own === undefined ? reported : reported === undefined ? own : Math.max(own, reported)}@@ -275,7 +293,7 @@ export function nextLossAt(state: SuperTabState, machineId: string): number | unconst steps = stepIndex(state)const ends = workerTasks(state).filter(({ group, worker, assignment }) => worker.machineId === machineId && !waitingForReview(assignment) && !waitingForRevision(state, group)- && !waitingOnSteps(state, group, steps))+ && !waitingOnSteps(state, group, steps) && !waitingOnPerson(state, group, worker, assignment)).map(({ group, assignment, worker }) => leaseEnd(group, assignment, reportRenewedAt(state, worker))).filter((end): end is number => end !== undefined)return ends.length ? Math.min(...ends) : undefined@@ -291,7 +309,7 @@ function lostReason(state: SuperTabState, group: Conversation, worker: Agent, as// Its host alerts only after ten minutes of retries without an answer (cli superTabs/terminal.ts MODEL_WAIT_MS), so a// short burst of failures that recovers never gets here.if (worker.alerting?.includes('model')) return 'its model keeps failing'- if (waitingForReview(assignment) || waitingForRevision(state, group) || waitingOnSteps(state, group, steps)) return null+ if (waitingForReview(assignment) || waitingForRevision(state, group) || waitingOnSteps(state, group, steps) || waitingOnPerson(state, group, worker, assignment)) return nullconst end = leaseEnd(group, assignment, reportRenewedAt(state, worker))if (end !== undefined && now > end) {const progress = lastProgress(state, worker, assignment)