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-06 j0920: #3263 (#3266)
0xken15f4181edb5443
diff --git a/cli/src/superTabs/host.spec.ts b/cli/src/superTabs/host.spec.tsindex 38dc5f14f..1742a5a16 100644--- a/cli/src/superTabs/host.spec.ts+++ b/cli/src/superTabs/host.spec.ts@@ -29,7 +29,7 @@ vi.mock('../lib/buddyGuard.js', async original => {import type { BackendNotice, CoreApi, TurnDelivery } from '../core/api.js'import { fakeCore } from '../testing/fakeCore.js'import type { attachedFiles as attachedFilesType } from './attachments.js'-import { backend, BUDDY_SESSION_GONE_MS, BUDDY_SESSION_IDLE_MS, BUDDY_SESSION_SLEEP_GAP_MS, buddyChatIdOf, swarmListedFor, swarmRoleFor, hostJournalFile, SuperTabHost, type SuperTabHostOptions } from './host.js'+import { backend, writeJournal, BUDDY_SESSION_GONE_MS, BUDDY_SESSION_IDLE_MS, BUDDY_SESSION_SLEEP_GAP_MS, buddyChatIdOf, swarmListedFor, swarmRoleFor, hostJournalFile, SuperTabHost, type SuperTabHostOptions } from './host.js'import { ADDED_MAX } from './deliveryContext.js'import { SWITCH_ADOPT_MS, SWITCH_HOLD_MS } from './leadSwitch.js'import { TerminalHost } from './terminal.js'@@ -1286,6 +1286,47 @@ describe('Super Tab native delivery handoff', () => {expect(t.core.turns.deliver).toHaveBeenCalledTimes(1)})+ // Task #3514: on 11-06 Mac 3's Team host failed to save its journal as it handed each delivery over (ENOENT on the rename of+ // its temporary file). The delivery was left marked as being typed though nothing was typed, so the next pass reported it+ // interrupted (uncertain) and it was never typed: 58 deliveries to idle agents in two hours.+ it('types a delivery whose hand-over save failed on the next pass, never reporting it interrupted', async () => {+ const t = setup()+ let failOnce = true+ const write = (file: string, journal: { entries: Record<string, { stage: string }> }) => {+ if (failOnce && Object.values(journal.entries).some(e => e.stage === 'submitting')) {+ failOnce = false+ throw Object.assign(new Error(`ENOENT: no such file or directory, rename '${file}.next' -> '${file}'`), { code: 'ENOENT' })+ }+ mkdirSync(dirname(file), { recursive: true })+ writeFileSync(file, JSON.stringify(journal))+ }+ const host = t.open({ write: write as never })+ await host.tick()+ // Nothing was typed, and the host said why.+ expect(t.core.turns.deliver).not.toHaveBeenCalled()+ expect(t.log).toHaveBeenCalledWith(expect.stringContaining('Could not hand delivery delivery'))+ t.wait(1_500)+ await host.tick()+ expect(t.core.turns.deliver).toHaveBeenCalledTimes(1)+ expect(t.receipts).toEqual([])+ t.event('delivered')+ await host.tick()+ expect(t.receipts).toEqual([expect.objectContaining({ uncertain: false, receipt: expect.stringContaining('delivered') })])+ })++ it('saves its journal through a temporary file of its own, never one another writer is using', () => {+ const dir = mkdtempSync(join(tmpdir(), 'super-tab-journal-')); roots.push(dir)+ const file = join(dir, 'super-tabs', 'host-machine-1.json')+ mkdirSync(dirname(file), { recursive: true })+ // Another writer's save in progress: its temporary file at the shared name.+ writeFileSync(`${file}.next`, 'theirs')+ writeJournal(file, { version: 1, entries: {} } as never)+ expect(JSON.parse(readFileSync(file, 'utf8'))).toEqual({ version: 1, entries: {} })+ expect(readFileSync(`${file}.next`, 'utf8')).toBe('theirs')+ // Its own temporary file does not stay behind.+ expect(readdirSync(dirname(file)).sort()).toEqual(['host-machine-1.json', 'host-machine-1.json.next'])+ })+it('does not type again after a crash between submission and its native acknowledgement', async () => {const t = setup(), first = t.open()await first.tick(); first.stop()diff --git a/cli/src/superTabs/host.ts b/cli/src/superTabs/host.tsindex 5cfea7d52..d457308c9 100644--- a/cli/src/superTabs/host.ts+++ b/cli/src/superTabs/host.ts@@ -14,7 +14,7 @@ import { CommandRetries, permanentRefusal } from './retries.js'import { NativeRecorder, nativeJournalFile } from './native.js'import { attachedFiles, attachmentsOf, formatSize, type FilesInFlight, type Relink } from './attachments.js'import { createHash, randomUUID } from 'node:crypto'-import { existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, renameSync, writeFileSync } from 'node:fs'+import { existsSync, lstatSync, mkdirSync, readFileSync, realpathSync, renameSync, rmSync, writeFileSync } from 'node:fs'import { readdir, readFile } from 'node:fs/promises'import { basename, dirname, isAbsolute, join, normalize, relative, sep } from 'node:path'import { BUDDY_HOME_MANIFEST, BUDDY_HOMES, buddyHomeDue, buddyHomeHoldsLost, buddyHomeRefreshing, pruneBuddyHome, refreshBuddyHome, removeBuddyHome, stopBuddyHomeRefresh } from './buddyHome.js'@@ -445,11 +445,19 @@ export const BUDDY_SESSION_GONE_MS = 60_000* idle time counts from the wake, so a Mac that slept through 30 minutes never ends a working session as it wakes (security* review 1 of #2345). */export const BUDDY_SESSION_SLEEP_GAP_MS = 2 * 60_000-const writeJournal = (file: string, journal: Journal) => {+/** Saves [journal] whole, through a temporary file of its own: a fixed `.next` name let another writer's save move it away+ * first, and every save then failed (task #3514: Mac 3's Team host, 11-06, ENOENT on the rename). A save that fails leaves+ * no temporary file behind. */+export const writeJournal = (file: string, journal: Journal) => {mkdirSync(dirname(file), { recursive: true, mode: 0o700 })- const temporary = `${file}.next`- writeFileSync(temporary, JSON.stringify(journal), { mode: 0o600, flush: true })- renameSync(temporary, file)+ const temporary = `${file}.${process.pid}.${randomUUID()}.next`+ try {+ writeFileSync(temporary, JSON.stringify(journal), { mode: 0o600, flush: true })+ renameSync(temporary, file)+ } catch (error) {+ rmSync(temporary, { force: true })+ throw error+ }}/** Whether a message asks its reader something: then the answer goes to the one who asked. */@@ -2083,9 +2091,15 @@ export class SuperTabHost {grantBuddyWide(buddyReadsOf(sent.key), wide ? { session: sent.session, wide: true, account: signedIn!, launch: launch! } : { session: sent.session, wide: false })} catch (error) { this.authorized.delete(id); throw error }}- // The durable intent must exist before the core can write. A thrown disk write must not deliver.+ // The durable intent must exist before the core can write. A thrown disk write must not deliver, and leaves the delivery+ // untyped, so the next pass types it: left 'submitting', it was reported interrupted and never typed (task #3514).+ const before = entry.stageentry.stage = 'submitting'- this.persist()+ try { this.persist() } catch (error) {+ entry.stage = before+ this.authorized.delete(id)+ throw error+ }this.active.add(id)const attached = [files.text, sent?.links.length ? ARTIFACT_LINKS(sent.links) : '', elsewhere.length ? LINKS_ELSEWHERE(elsewhere) : ''].filter(Boolean).join('\n\n')