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
Update core harnesses automatically with each release (#584)
Deea59e6b847765
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 3927075e8..1a88e1bf8 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -143,6 +143,9 @@ jobs:npm run bundlenode scripts/test-hn-upgrade.mjs+ - name: Verify core harness rollout in the release bundle+ run: node scripts/test-core-harness-upgrade.mjs dist/cli.js+- name: Require complete harness updater coveragerun: npm run test:dsh-updatesdiff --git a/cli/RELEASE.md b/cli/RELEASE.mdindex bbb99b46a..2ee5b1486 100644--- a/cli/RELEASE.md+++ b/cli/RELEASE.md@@ -34,6 +34,14 @@ just needs to outrank what's live.`package.json`'s `version` field is never touched by this script; the published version is baked intothe bundle via `ADAPTER_VERSION` at build time (see "The publishing step" below).+Core app DSHs ship inside that same release: Harness Monitor, Devices and Model Manager are+materialized at daemon startup before viewer restoration. Official older Store installations+migrate automatically, retaining their prior files, workspaces and conversations. Companions+refresh their generated package when the existing collection identity returns. No separate+`harness dsh update` is required for these core tools. Other Store apps retain user-driven updates.+Before uploading, the release script runs `scripts/test-core-harness-upgrade.mjs` against the+compiled bundle to verify existing-install migration, package assets and the Monitor viewer.+## The publishing step`cli/scripts/upload-cli.sh` is the publishing step, and CI is its only caller: `release.yml` runs itdiff --git a/cli/build-bundle.mjs b/cli/build-bundle.mjsindex 3ea933127..cca5fa72b 100644--- a/cli/build-bundle.mjs+++ b/cli/build-bundle.mjs@@ -12,12 +12,13 @@import * as esbuild from 'esbuild'import { readFileSync, copyFileSync, rmSync } from 'fs'import { readDshRegistry } from './scripts/lib/dshRegistry.mjs'-import { readBuiltinBundle, readModelManagerBundle } from './scripts/lib/modelManagerBundle.mjs'+import { readBuiltinBundle, readHarnessMonitorBundle, readModelManagerBundle } from './scripts/lib/modelManagerBundle.mjs'import { plateWorkerSource } from './scripts/lib/plateWorker.mjs'import { memoryWorkerSource } from './scripts/lib/memoryWorker.mjs'import { fileURLToPath } from 'node:url'const modelManagerBundle = JSON.stringify(readModelManagerBundle(fileURLToPath(new URL('../store/agents/autonomous-grid', import.meta.url))))const devicesBundle = JSON.stringify(readBuiltinBundle(fileURLToPath(new URL('../store/agents/devices', import.meta.url)), ['harness.json', 'AGENTS.md', 'LICENSE', 'template']))+const harnessMonitorBundle = JSON.stringify(readHarnessMonitorBundle(fileURLToPath(new URL('../store/agents/harness-monitor', import.meta.url))))const version =process.env.ADAPTER_VERSION ||@@ -46,6 +47,7 @@ await esbuild.build({__DSH_REGISTRY__: JSON.stringify(dshRegistry),__MODEL_MANAGER_BUNDLE__: JSON.stringify(modelManagerBundle),__DEVICES_BUNDLE__: JSON.stringify(devicesBundle),+ __HARNESS_MONITOR_BUNDLE__: JSON.stringify(harnessMonitorBundle),__PLATE_WORKER__: JSON.stringify(plateWorker),__MEMORY_WORKER__: JSON.stringify(memoryWorker),},diff --git a/cli/build.mjs b/cli/build.mjsindex 159fb259c..7b206d767 100644--- a/cli/build.mjs+++ b/cli/build.mjs@@ -2,12 +2,13 @@ import * as esbuild from 'esbuild'import { readdirSync, statSync, readFileSync } from 'fs'import { join } from 'path'import { readDshRegistry } from './scripts/lib/dshRegistry.mjs'-import { readBuiltinBundle, readModelManagerBundle } from './scripts/lib/modelManagerBundle.mjs'+import { readBuiltinBundle, readHarnessMonitorBundle, readModelManagerBundle } from './scripts/lib/modelManagerBundle.mjs'import { plateWorkerSource } from './scripts/lib/plateWorker.mjs'import { memoryWorkerSource } from './scripts/lib/memoryWorker.mjs'import { fileURLToPath } from 'node:url'const modelManagerBundle = JSON.stringify(readModelManagerBundle(fileURLToPath(new URL('../store/agents/autonomous-grid', import.meta.url))))const devicesBundle = JSON.stringify(readBuiltinBundle(fileURLToPath(new URL('../store/agents/devices', import.meta.url)), ['harness.json', 'AGENTS.md', 'LICENSE', 'template']))+const harnessMonitorBundle = JSON.stringify(readHarnessMonitorBundle(fileURLToPath(new URL('../store/agents/harness-monitor', import.meta.url))))// Bake the version in so `node dist/cli.js version` works in the dev/per-file build too (parity with// build-bundle.mjs). The bundle build overrides this from ADAPTER_VERSION at release time.@@ -50,6 +51,7 @@ try {__DSH_REGISTRY__: JSON.stringify(dshRegistry),__MODEL_MANAGER_BUNDLE__: JSON.stringify(modelManagerBundle),__DEVICES_BUNDLE__: JSON.stringify(devicesBundle),+ __HARNESS_MONITOR_BUNDLE__: JSON.stringify(harnessMonitorBundle),__PLATE_WORKER__: JSON.stringify(plateWorker),__MEMORY_WORKER__: JSON.stringify(memoryWorker),},diff --git a/cli/scripts/install.sh b/cli/scripts/install.shindex 417f5cde8..dae7a58fa 100755--- a/cli/scripts/install.sh+++ b/cli/scripts/install.sh@@ -740,7 +740,7 @@ HARNESSJSif [ "$INSTALL_MODE" != "host" ]; thenecho "▸ Installing the managed grid into $RUNTIME_DIR"install_managed_grid || echo " · the grid runtime will be fetched by the daemon on its next start"- "$NODE_BIN" "$HOME/.harness/cli/cli.js" dsh builtins || echo " · Model Manager will be prepared on the next start"+ "$NODE_BIN" "$HOME/.harness/cli/cli.js" dsh builtins || echo " · Core harnesses will be prepared on the next start"fi# 3c. hn's binary (the standalone install; Desktop's CLI fetches it on the first `hn`).diff --git a/cli/scripts/lib/modelManagerBundle.mjs b/cli/scripts/lib/modelManagerBundle.mjsindex 9746b8358..0c0e7b209 100644--- a/cli/scripts/lib/modelManagerBundle.mjs+++ b/cli/scripts/lib/modelManagerBundle.mjs@@ -7,6 +7,10 @@ export function readModelManagerBundle(root) {return readBuiltinBundle(root, ['harness.json', 'AGENTS.md', 'LICENSE', 'VERSIONS', 'viewer.sh', 'viewer.mjs', 'viewer', 'lib', 'toolchain', 'template', 'skills'])}+export function readHarnessMonitorBundle(root) {+ return readBuiltinBundle(root, ['harness.json', 'AGENTS.md', 'LICENSE', 'package.json', 'viewer.sh', 'viewer.mjs', 'viewer', 'lib', 'toolchain', 'template', 'skills'])+}+export function readBuiltinBundle(root, paths) {const files = {}const visit = relative => {@@ -15,7 +19,11 @@ export function readBuiltinBundle(root, paths) {if (stat.isDirectory()) {for (const name of readdirSync(path).sort()) visit(join(relative, name))} else {- files[relative] = { content: readFileSync(path, 'utf8'), executable: Boolean(stat.mode & 0o111) }+ const bytes = readFileSync(path)+ const text = bytes.toString('utf8')+ const binary = !Buffer.from(text, 'utf8').equals(bytes)+ files[relative] = { content: binary ? bytes.toString('base64') : text,+ ...(binary ? { encoding: 'base64' } : {}), executable: Boolean(stat.mode & 0o111) }}}for (const path of paths) visit(path)diff --git a/cli/scripts/test-core-harness-upgrade.mjs b/cli/scripts/test-core-harness-upgrade.mjsnew file mode 100644index 000000000..dbb462c00--- /dev/null+++ b/cli/scripts/test-core-harness-upgrade.mjs@@ -0,0 +1,87 @@+/** Exercise the shipped artifact against an older installation, without an account or network. */+import assert from 'node:assert/strict'+import { execFileSync } from 'node:child_process'+import { mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs'+import { tmpdir } from 'node:os'+import { join, resolve } from 'node:path'+import { fileURLToPath, pathToFileURL } from 'node:url'+import { readBuiltinBundle, readHarnessMonitorBundle, readModelManagerBundle } from './lib/modelManagerBundle.mjs'++const cli = resolve(process.argv[2] || fileURLToPath(new URL('../dist/cli.js', import.meta.url)))+const root = mkdtempSync(join(tmpdir(), 'core-harness-upgrade-'))+const dshDir = join(root, 'dsh')+const workspace = join(root, 'existing-workspace')+const packages = [+ ['autonomous-grid', 'model-manager', readModelManagerBundle],+ ['devices', 'devices', dir => readBuiltinBundle(dir, ['harness.json', 'AGENTS.md', 'LICENSE', 'template'])],+ ['harness-monitor', 'harness-monitor', readHarnessMonitorBundle],+]+const env = { ...process.env, DSH_DIR: dshDir, ADAPTER_DATA_DIR: join(root, 'data'),+ ADAPTER_COMPUTER_ID: 'core-upgrade-test', ADAPTER_COMPUTER_ID_FILE: join(root, 'computer-id') }+const run = (...args) => execFileSync(process.execPath, [cli, 'dsh', ...args], {+ cwd: root, env, encoding: 'utf8', timeout: 30_000, stdio: ['ignore', 'pipe', 'pipe'],+})+const index = () => JSON.parse(readFileSync(join(dshDir, 'installed.json'), 'utf8'))+let viewer+const monitorEnv = { HARNESS_MONITOR_CONFIG: process.env.HARNESS_MONITOR_CONFIG, HARNESS_MONITOR_STATE: process.env.HARNESS_MONITOR_STATE }+try {+ mkdirSync(dshDir)+ mkdirSync(workspace)+ writeFileSync(join(workspace, 'NOTES.md'), 'Keep my workspace and conversation.\n')+ const previous = packages.map(([folder]) => {+ const dir = join(dshDir, 'autonomous', folder)+ mkdirSync(dir, { recursive: true })+ writeFileSync(join(dir, 'AGENTS.md'), 'Previous release resources\n')+ writeFileSync(join(dir, 'harness.json'), JSON.stringify({ spec: 1, id: `autonomous/${folder}`, name: folder, engine: 'opencode' }))+ return { id: `autonomous/${folder}`, dir, source: 'https://github.com/autonomous-ai/autonomous-harness.git',+ path: `store/agents/${folder}`, ref: 'previous-release', commit: 'a'.repeat(40), revision: 'b'.repeat(40),+ linked: false, installedAt: 123 }+ })+ const blender = { ...previous[0], id: 'autonomous/blender', dir: join(dshDir, 'autonomous', 'blender'), path: 'store/agents/blender' }+ writeFileSync(join(dshDir, 'installed.json'), JSON.stringify([...previous, blender]))+ run('builtins')+ const upgraded = index()+ for (const [folder, builtin, readBundle] of packages) {+ const installed = upgraded.find(row => row.id === `autonomous/${folder}`)+ assert(installed, `release bundle is missing ${folder}`)+ assert.equal(installed.source, `builtin:${builtin}`)+ assert.equal(installed.installedAt, 123)+ assert.notEqual(installed.dir, previous.find(row => row.id === installed.id).dir)+ const source = fileURLToPath(new URL(`../../store/agents/${folder}`, import.meta.url))+ for (const [path, file] of Object.entries(readBundle(source))) {+ assert.deepEqual(readFileSync(join(installed.dir, path)), readFileSync(join(source, path)), `${folder}/${path}`)+ if (file.executable) assert(statSync(join(installed.dir, path)).mode & 0o111, `${folder}/${path} must be executable`)+ }+ }+ for (const record of previous) assert.equal(readFileSync(join(record.dir, 'AGENTS.md'), 'utf8'), 'Previous release resources\n')+ assert.equal(readFileSync(join(workspace, 'NOTES.md'), 'utf8'), 'Keep my workspace and conversation.\n')+ assert.deepEqual(upgraded.find(row => row.id === blender.id), blender)+ run('builtins')+ assert.deepEqual(index(), upgraded, 'repeated startup must reuse the installed core revisions')+ console.log('PASS release bundle migrates existing official core packages; prior files, workspaces and Store apps are retained')++ const monitor = upgraded.find(row => row.id === 'autonomous/harness-monitor')+ process.env.HARNESS_MONITOR_CONFIG = join(root, 'policy.jsonc')+ process.env.HARNESS_MONITOR_STATE = join(root, 'monitor-state')+ const { createViewer } = await import(pathToFileURL(join(monitor.dir, 'viewer.mjs')).href)+ viewer = createViewer({ workspace, collect: async () => ({ rows: [], shared: [], machines: [], problems: [], degraded: false }) })+ const port = await viewer.start()+ await viewer.observed+ assert.equal(viewer.snapshot().status, 'ok')+ for (const [route, file] of [['/', 'index.html'], ['/table.js', 'table.js'], ['/icons/codex.png', 'icons/codex.png']]) {+ const response = await fetch(`http://127.0.0.1:${port}${route}`)+ assert.equal(response.status, 200, route)+ const expected = readFileSync(join(monitor.dir, 'viewer', file))+ const served = Buffer.from(await response.arrayBuffer())+ if (route === '/') assert.equal(served.toString(), expected.toString().replace('__HPS_TOKEN__', viewer.token))+ else assert.deepEqual(served, expected, route)+ }+ console.log('PASS migrated Monitor serves the released viewer, table and binary icons')+} finally {+ await viewer?.close()+ for (const [key, value] of Object.entries(monitorEnv)) {+ if (value === undefined) delete process.env[key]+ else process.env[key] = value+ }+ rmSync(root, { recursive: true, force: true })+}diff --git a/cli/scripts/upload-cli.sh b/cli/scripts/upload-cli.shindex a7d6bacd4..7982a2fc8 100755--- a/cli/scripts/upload-cli.sh+++ b/cli/scripts/upload-cli.sh@@ -133,6 +133,7 @@ fi[ -f "$CLI" ] && [ -f "$NOTIFY" ] || { echo "error: dist/cli.js or dist/notify.mjs missing — bundle first (drop --no-build)" >&2; exit 1; }head -1 "$CLI" | grep -q '^#!' || { echo "error: dist/cli.js lost its shebang on line 1 (esbuild change?)" >&2; exit 1; }[ "$(node "$CLI" version)" = "$VER" ] || { echo "error: bundled version != $VER (ADAPTER_VERSION not injected)" >&2; exit 1; }+node "$ADAPTER_DIR/scripts/test-core-harness-upgrade.mjs" "$CLI"# --- Step 3: upload both artifacts + merge the manifest ---CLI_GCS="harness/cli/${VER}/cli.js"diff --git a/cli/src/cli.ts b/cli/src/cli.tsindex 69937b544..7dec0f54a 100644--- a/cli/src/cli.ts+++ b/cli/src/cli.ts@@ -1,7 +1,7 @@#!/usr/bin/env nodeimport './config/loadEnv.js'import { CompanionZoo, readCompanionIdentity, type CompanionIdentity } from './cable/companionIdentity.js'-import { MODEL_MANAGER_ID, ensureBundledDevices, ensureBundledModelManager } from './dsh/builtins.js'+import { MODEL_MANAGER_ID, ensureBundledCoreHarnesses } from './dsh/builtins.js'import { runDevicesCommand } from './devices/client.js'import { createDeviceStore, deviceStoreAgents } from './lib/autonomous-device/storeRuntime.js'import { mutateDsh } from './dsh/service.js'@@ -2228,10 +2228,7 @@ async function runForeground(session: AuthSession | null): Promise<void> {backendRef = backendbackend.viewerTargetProvider = (agentId) => dshViewers.forwardingUrl(agentId)- try { ensureBundledModelManager() }- catch (error) { console.warn('[model-manager] Could not prepare the bundled harness:', error instanceof Error ? error.message : String(error)) }- try { ensureBundledDevices() }- catch (error) { console.warn('[devices] Could not prepare the bundled harness:', error instanceof Error ? error.message : String(error)) }+ ensureBundledCoreHarnesses()// Grid is an add-on (`lib/gridAttach.ts`): nothing on this path installs `grid`, signs this machine in// to it or creates a grid. The first grid feature a person uses — the models picker's Set up, a local@@ -4017,6 +4014,7 @@ async function runForeground(session: AuthSession | null): Promise<void> {let guestCompanion: CompanionIdentity | null = nulllet guestAutonomy: Autonomy | null = nulllet guestConsent = false+ let refreshPairPackage: () => void = () => {}// The autonomy dial rides with the pair: the account's zoo, or a guest window's own (daemon_presence).// Nothing is watched until the person said yes on the first-day consent screen (zoo `consent.watching`,// or a guest window's `consent`): until then the sensor stays off and the dial stays at watch.@@ -4029,6 +4027,7 @@ async function runForeground(session: AuthSession | null): Promise<void> {pairGate.setRequested(pairing.autonomy, { keepConfirmed: !pairing.consented, epoch: pairing.epoch })// A guest window names only a species; the account's zoo names the individual too.pairSensor.setPair(pairing.pair, zooPair.known && pairing.pair === zooPair.pair ? zooPair.name : null)+ refreshPairPackage()// Pairing on or off already refreshed the brain (onPairToggled); another daemon paired, or the dial moved,// reaches the windows attached here now. The brain sends only what they were not already sent.pairBrain?.refresh()@@ -4958,6 +4957,11 @@ async function runForeground(session: AuthSession | null): Promise<void> {now: Date.now,})pairTalk = (text, uid) => pairHarness.talk(text, uid)+ refreshPairPackage = () => {+ try { pairHarness.refreshPackage() }+ catch (error) { console.warn('[core-harnesses] Could not refresh Companions:', error instanceof Error ? error.message : String(error)) }+ }+ refreshPairPackage()isCollectionAgent = (agentId) => agentId === pairHarness.agentId()companionPromptContext = (agentId) => daemons.on() ? pairHarness.context(agentId) : nullpairHarnessActivity = (agentId) => { if (daemons.on()) pairHarness.activity(agentId) }diff --git a/cli/src/dsh/builtins.spec.ts b/cli/src/dsh/builtins.spec.tsindex ecadad5ca..9eeaccda7 100644--- a/cli/src/dsh/builtins.spec.ts+++ b/cli/src/dsh/builtins.spec.ts@@ -1,11 +1,12 @@import { afterEach, beforeEach, expect, it, vi } from 'vitest'-import { existsSync, mkdtempSync, readFileSync, rmSync, statSync } from 'node:fs'+import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, statSync, writeFileSync } from 'node:fs'import { tmpdir } from 'node:os'import { join } from 'node:path'import { env } from '../config/env.js'-import { ensureBundledDevices, ensureBundledModelManager, DEVICES_HARNESS_ID, MODEL_MANAGER_ID } from './builtins.js'+import { ensureBundledCoreHarnesses, ensureBundledDevices, ensureBundledHarnessMonitor, ensureBundledModelManager,+ DEVICES_HARNESS_ID, HARNESS_MONITOR_ID, HARNESS_MONITOR_BUILTIN_SOURCE, MODEL_MANAGER_ID, type BundledFiles } from './builtins.js'import { dshListRows } from './wire.js'-import { installedDsh, invalidateInstalledDsh, upsertInstalledRecord } from './installed.js'+import { installedDsh, invalidateInstalledDsh, readInstalledIndex, upsertInstalledRecord } from './installed.js'import { lockDsh } from './lock.js'let root: string@@ -99,3 +100,92 @@ it('keeps a developer linked package and refuses invalid bundled paths', () => {expect(installedDsh(MODEL_MANAGER_ID)?.source).toBe('/my/checkout')expect(readFileSync(join(first.dir, 'AGENTS.md'), 'utf8')).toBe('Help with local models')})++const coreFiles = (id: string, text = 'release resources'): BundledFiles => ({+ 'harness.json': { content: JSON.stringify({ spec: 1, id, name: 'Core tool', engine: 'opencode' }), executable: false },+ 'AGENTS.md': { content: text, executable: false },+})++it('migrates existing official monitor installations, retaining old files and workspace content', () => {+ const oldDir = join(root, 'autonomous', 'harness-monitor')+ const workspace = join(root, 'existing-workspace')+ mkdirSync(oldDir, { recursive: true }); mkdirSync(workspace)+ for (const [name, file] of Object.entries(coreFiles(HARNESS_MONITOR_ID, 'old instructions'))) writeFileSync(join(oldDir, name), file.content)+ writeFileSync(join(workspace, 'NOTES.md'), 'user notes and history')+ upsertInstalledRecord({ id: HARNESS_MONITOR_ID, dir: oldDir,+ source: 'https://github.com/autonomous-ai/autonomous-harness.git', path: 'store/agents/harness-monitor',+ ref: 'old-release', commit: 'a'.repeat(40), revision: 'b'.repeat(40), linked: false, installedAt: 123 })+ expect(ensureBundledHarnessMonitor(coreFiles(HARNESS_MONITOR_ID))).toBe(true)+ const updated = installedDsh(HARNESS_MONITOR_ID)!+ expect(updated.source).toBe(HARNESS_MONITOR_BUILTIN_SOURCE)+ expect(updated.installedAt).toBe(123)+ expect(updated.dir).not.toBe(oldDir)+ expect(readFileSync(join(updated.dir, 'AGENTS.md'), 'utf8')).toBe('release resources')+ expect(readFileSync(join(oldDir, 'AGENTS.md'), 'utf8')).toBe('old instructions')+ expect(readFileSync(join(workspace, 'NOTES.md'), 'utf8')).toBe('user notes and history')+ expect(dshListRows([updated], [{ id: HARNESS_MONITOR_ID, name: 'Monitor', engine: 'opencode',+ repo: 'https://github.com/autonomous-ai/openharness', path: 'store/agents/harness-monitor', ref: 'c'.repeat(40) }])[0].updateAvailable).toBe(false)+})++it.each([+ { source: '/developer/monitor', path: undefined, linked: true },+ { source: 'https://github.com/example/monitor', path: 'store/agents/harness-monitor', linked: false },+ { source: 'https://github.com/autonomous-ai/openharness', path: 'custom/monitor', linked: false },+])('preserves linked and custom monitor installations, including broken ones: %j', record => {+ upsertInstalledRecord({ id: HARNESS_MONITOR_ID, dir: join(root, 'missing-custom-copy'),+ ref: 'main', commit: null, installedAt: 123, ...record })+ const before = readInstalledIndex()+ expect(ensureBundledHarnessMonitor(coreFiles(HARNESS_MONITOR_ID))).toBe(true)+ expect(readInstalledIndex()).toEqual(before)+})++it('refreshes every bundled core tool together and leaves ordinary Store apps alone', () => {+ const blender = { id: 'autonomous/blender', dir: join(root, 'blender'), source: 'https://github.com/autonomous-ai/openharness',+ path: 'store/agents/blender', ref: 'old-ref', commit: 'a'.repeat(40), linked: false, installedAt: 123 }+ upsertInstalledRecord(blender)+ vi.stubGlobal('__MODEL_MANAGER_BUNDLE__', JSON.stringify(coreFiles(MODEL_MANAGER_ID)))+ vi.stubGlobal('__DEVICES_BUNDLE__', JSON.stringify(coreFiles(DEVICES_HARNESS_ID)))+ vi.stubGlobal('__HARNESS_MONITOR_BUNDLE__', JSON.stringify(coreFiles(HARNESS_MONITOR_ID)))+ expect(ensureBundledCoreHarnesses()).toBe(true)+ const oldDevices = installedDsh(DEVICES_HARNESS_ID)!, oldMonitor = installedDsh(HARNESS_MONITOR_ID)!+ vi.stubGlobal('__DEVICES_BUNDLE__', JSON.stringify(coreFiles(DEVICES_HARNESS_ID, 'next release')))+ vi.stubGlobal('__HARNESS_MONITOR_BUNDLE__', JSON.stringify(coreFiles(HARNESS_MONITOR_ID, 'next release')))+ expect(ensureBundledCoreHarnesses()).toBe(true)+ expect(installedDsh(DEVICES_HARNESS_ID)!.dir).not.toBe(oldDevices.dir)+ expect(installedDsh(HARNESS_MONITOR_ID)!.dir).not.toBe(oldMonitor.dir)+ expect(existsSync(oldDevices.dir)).toBe(true)+ expect(existsSync(oldMonitor.dir)).toBe(true)+ expect(readInstalledIndex().find(row => row.id === blender.id)).toEqual(blender)+ // A CLI rollback restores its corresponding core revision without touching the retained one.+ vi.stubGlobal('__HARNESS_MONITOR_BUNDLE__', JSON.stringify(coreFiles(HARNESS_MONITOR_ID)))+ expect(ensureBundledCoreHarnesses()).toBe(true)+ expect(installedDsh(HARNESS_MONITOR_ID)!.dir).toBe(oldMonitor.dir)+})++it('an unavailable or invalid core bundle does not prevent the remaining tools from updating', () => {+ const log = vi.fn()+ expect(ensureBundledCoreHarnesses(log)).toBe(false)+ vi.stubGlobal('__MODEL_MANAGER_BUNDLE__', 'invalid json')+ vi.stubGlobal('__DEVICES_BUNDLE__', JSON.stringify(coreFiles(DEVICES_HARNESS_ID)))+ vi.stubGlobal('__HARNESS_MONITOR_BUNDLE__', JSON.stringify(coreFiles(HARNESS_MONITOR_ID)))+ expect(ensureBundledCoreHarnesses(log)).toBe(false)+ expect(log).toHaveBeenCalledWith(expect.stringContaining('Model Manager'))+ expect(installedDsh(DEVICES_HARNESS_ID)).toBeDefined()+ expect(installedDsh(HARNESS_MONITOR_ID)).toBeDefined()+})++it('ships a complete monitor viewer with byte-identical binary icons and executable launchers', async () => {+ // @ts-expect-error — production build helper is plain ESM without a declaration file+ const { readHarnessMonitorBundle } = await import('../../scripts/lib/modelManagerBundle.mjs')+ const source = new URL('../../../store/agents/harness-monitor/', import.meta.url)+ const { fileURLToPath } = await import('node:url')+ const files = readHarnessMonitorBundle(fileURLToPath(source)) as BundledFiles+ vi.stubGlobal('__HARNESS_MONITOR_BUNDLE__', JSON.stringify(files))+ expect(ensureBundledHarnessMonitor()).toBe(true)+ const installed = installedDsh(HARNESS_MONITOR_ID)!+ for (const name of ['harness.json', 'viewer.mjs', 'viewer/index.html', 'viewer/table.js', 'lib/bridge.mjs',+ 'toolchain/hps.mjs', 'viewer/icons/codex.png', 'viewer/icons/claude.png', 'skills/fleet-operations/SKILL.md']) {+ expect(readFileSync(join(installed.dir, name))).toEqual(readFileSync(new URL(name, source)))+ }+ for (const name of ['viewer.sh', 'toolchain/hps', 'toolchain/init-workspace.sh']) expect(statSync(join(installed.dir, name)).mode & 0o111).not.toBe(0)+})diff --git a/cli/src/dsh/builtins.ts b/cli/src/dsh/builtins.tsindex f5034b426..9b0c12b4b 100644--- a/cli/src/dsh/builtins.ts+++ b/cli/src/dsh/builtins.ts@@ -1,16 +1,21 @@import { createHash, randomUUID } from 'node:crypto'import { existsSync, mkdirSync, renameSync, rmSync, writeFileSync } from 'node:fs'import { dirname, join } from 'node:path'-import { dshRootDir, installedDsh, upsertInstalledRecord } from './installed.js'+import { dshRootDir, isBrokenDsh, readInstalledIndex, resolveInstalled, upsertInstalledRecord } from './installed.js'import { lockDsh } from './lock.js'import { readDshManifest } from './manifest.js'+import { HARNESS_MONOREPO } from './registry.js'+import { samePackageSource } from './updates.js'declare const __MODEL_MANAGER_BUNDLE__: stringdeclare const __DEVICES_BUNDLE__: string+declare const __HARNESS_MONITOR_BUNDLE__: stringexport const MODEL_MANAGER_ID = 'autonomous/autonomous-grid'export const DEVICES_HARNESS_ID = 'autonomous/devices'export const DEVICES_BUILTIN_SOURCE = 'builtin:devices'-export type BundledFiles = Record<string, { content: string; executable: boolean }>+export const HARNESS_MONITOR_ID = 'autonomous/harness-monitor'+export const HARNESS_MONITOR_BUILTIN_SOURCE = 'builtin:harness-monitor'+export type BundledFiles = Record<string, { content: string; executable: boolean; encoding?: 'base64' }>/** Install the trusted, release-bundled harness. Runtime provisioning remains* owned by the existing managed Grid installer. Versioned package directories@@ -18,14 +23,37 @@ export type BundledFiles = Record<string, { content: string; executable: booleanexport function ensureBundledModelManager(files?: BundledFiles): boolean {files ??= typeof __MODEL_MANAGER_BUNDLE__ === 'string' ? JSON.parse(__MODEL_MANAGER_BUNDLE__) as BundledFiles : undefinedif (!files || !files['harness.json']) return false- return installBuiltin({ id: MODEL_MANAGER_ID, source: 'builtin:model-manager', folder: 'model-manager', files, what: 'Model Manager' })+ return installBuiltin({ id: MODEL_MANAGER_ID, source: 'builtin:model-manager', folder: 'model-manager', files, what: 'Model Manager', legacyPath: 'store/agents/autonomous-grid' })}/** An unlisted first-party DSH. Its viewer is native; its agent uses the same daemon API. */export function ensureBundledDevices(files?: BundledFiles): boolean {files ??= typeof __DEVICES_BUNDLE__ === 'string' ? JSON.parse(__DEVICES_BUNDLE__) as BundledFiles : undefinedif (!files?.['harness.json']) return false- return installBuiltin({ id: DEVICES_HARNESS_ID, source: DEVICES_BUILTIN_SOURCE, folder: 'devices', files, what: 'Devices' })+ return installBuiltin({ id: DEVICES_HARNESS_ID, source: DEVICES_BUILTIN_SOURCE, folder: 'devices', files, what: 'Devices', legacyPath: 'store/agents/devices' })+}++/** The footer's monitor follows the CLI release, including existing official Store installations. */+export function ensureBundledHarnessMonitor(files?: BundledFiles): boolean {+ files ??= typeof __HARNESS_MONITOR_BUNDLE__ === 'string' ? JSON.parse(__HARNESS_MONITOR_BUNDLE__) as BundledFiles : undefined+ if (!files?.['harness.json']) return false+ return installBuiltin({ id: HARNESS_MONITOR_ID, source: HARNESS_MONITOR_BUILTIN_SOURCE, folder: 'harness-monitor', files,+ what: 'Harness Monitor', legacyPath: 'store/agents/harness-monitor' })+}++/** Core app DSHs ship with the release. Store applications keep their explicit Update action. */+export function ensureBundledCoreHarnesses(log: (line: string) => void = console.warn): boolean {+ let ready = true+ for (const [name, install] of [+ ['Model Manager', ensureBundledModelManager], ['Devices', ensureBundledDevices], ['Harness Monitor', ensureBundledHarnessMonitor],+ ] as const) {+ try { if (!install()) ready = false }+ catch (error) {+ ready = false+ log(`[core-harnesses] Could not prepare ${name}: ${error instanceof Error ? error.message : String(error)}`)+ }+ }+ return ready}/** The pair harness (pair/pairHarness.ts): generated on this machine, never listed in the Store or the picker. */@@ -43,13 +71,15 @@ export function isHiddenBuiltin(record: { source?: string | null }): boolean {}/** Materialize `files` under `.bundled/<folder>/<revision>` and point the index at it. Idempotent per revision. */-function installBuiltin(opts: { id: string; source: string; folder: string; files: BundledFiles; what: string }): boolean {+function installBuiltin(opts: { id: string; source: string; folder: string; files: BundledFiles; what: string; legacyPath?: string }): boolean {const { id, source, folder, files } = opts- const current = installedDsh(id)+ const current = readInstalledIndex().find(record => record.id === id)// A developer's linked checkout is theirs. Never replace it with release files.if (current?.linked) return true+ // Adopt only our own old Store package. A matching id does not make a fork or local copy ours.+ if (current && current.source !== source && (!opts.legacyPath || !samePackageSource(current, { repo: HARNESS_MONOREPO, path: opts.legacyPath }))) return trueconst revision = createHash('sha256').update(JSON.stringify(files)).digest('hex')- if (current?.source === source && current.revision === revision) return true+ if (current?.source === source && current.revision === revision && !isBrokenDsh(resolveInstalled(current))) return trueconst unlock = lockDsh(id)if (!unlock) return falseconst dir = join(dshRootDir(), '.bundled', folder, revision)@@ -60,12 +90,15 @@ function installBuiltin(opts: { id: string; source: string; folder: string; fileif (!path || path.startsWith('/') || path.split(/[\\/]/).includes('..')) throw new Error('Invalid built-in package path')const destination = join(staging, path)mkdirSync(dirname(destination), { recursive: true, mode: 0o700 })- writeFileSync(destination, file.content, { mode: file.executable ? 0o700 : 0o600 })+ writeFileSync(destination, file.encoding === 'base64' ? Buffer.from(file.content, 'base64') : file.content,+ { mode: file.executable ? 0o700 : 0o600 })}const manifest = readDshManifest(staging)if (!manifest.ok || manifest.manifest.id !== id) throw new Error(`Invalid bundled ${opts.what}`)renameSync(staging, dir)}+ const manifest = readDshManifest(dir)+ if (!manifest.ok || manifest.manifest.id !== id) throw new Error(`Invalid bundled ${opts.what}`)upsertInstalledRecord({ id, dir, source, ref: null,commit: null, revision, linked: false, installedAt: current?.installedAt ?? Date.now(), updatedAt: Date.now() })return truediff --git a/cli/src/dsh/command.ts b/cli/src/dsh/command.tsindex 1bc998a82..66c93f678 100644--- a/cli/src/dsh/command.ts+++ b/cli/src/dsh/command.ts@@ -2,7 +2,7 @@* `harness dsh …` — the terminal face of domain-specific harnesses, for a server with no desktop* and for the development loop (`--link` a checkout, iterate, no re-clone).*/-import { ensureBundledModelManager } from './builtins.js'+import { ensureBundledCoreHarnesses } from './builtins.js'import { listDshState, installedDsh } from './installed.js'import { DSH_ID_RE, dshTier } from './manifest.js'import { registrySourceUrl } from './registry.js'@@ -37,7 +37,7 @@ export async function dshCommand(verb: string | undefined, rest: readonly stringconst args = rest.filter((arg, at) => !arg.startsWith('-') && !valued.has(rest[at - 1] ?? ''))switch (verb) {case 'builtins':- return ensureBundledModelManager() ? 0 : 1+ return ensureBundledCoreHarnesses() ? 0 : 1case 'list': {const { installed, broken } = listDshState()const registry = await refreshDshRegistry()diff --git a/cli/src/dsh/update.spec.ts b/cli/src/dsh/update.spec.tsindex dbf8722be..1b28c2742 100644--- a/cli/src/dsh/update.spec.ts+++ b/cli/src/dsh/update.spec.ts@@ -92,6 +92,18 @@ describe('package updates', { timeout: 30_000 }, () => {expect(lines).toContain(`${id} is already up to date`)})+ it('keeps release-bundled core packages on the Harness update path without fetching a Store copy', async () => {+ upsertInstalledRecord({ id, dir: join(root, 'bundled'), source: 'builtin:harness-monitor',+ ref: null, commit: null, linked: false, installedAt: 123 })+ const before = readInstalledIndex()+ const registry = vi.fn()+ const result = await updateDsh({ id, registry })+ expect(result).toEqual({ ok: false, error: 'BUNDLED_PACKAGE',+ detail: `${id} updates automatically with Harness. Update Harness to receive the latest core packages.` })+ expect(registry).not.toHaveBeenCalled()+ expect(readInstalledIndex()).toEqual(before)+ })+it('repairs a missing installed directory and a record with unknown commit/ref', async () => {const repo = create()await installDsh({ source: repo })diff --git a/cli/src/dsh/update.ts b/cli/src/dsh/update.tsindex 025cb4b88..c9981c2f4 100644--- a/cli/src/dsh/update.ts+++ b/cli/src/dsh/update.ts@@ -27,6 +27,7 @@ async function updatePackage(opts: DshUpdateOptions): Promise<DshInstallResult>const record = readInstalledIndex().find(row => row.id === opts.id)if (!record) return { ok: false, error: 'NOT_INSTALLED', detail: `${opts.id} is not installed` }if (record.linked) return { ok: false, error: 'LINKED_INSTALL', detail: `${opts.id} is linked to a checkout. Update that checkout directly.` }+ if (record.source.startsWith('builtin:')) return { ok: false, error: 'BUNDLED_PACKAGE', detail: `${opts.id} updates automatically with Harness. Update Harness to receive the latest core packages.` }const unlock = lockDsh(opts.id)if (!unlock) return dshBusy(opts.id)let staged: string | null = nulldiff --git a/cli/src/dsh/updates.ts b/cli/src/dsh/updates.tsindex ef894a445..232e9ae4c 100644--- a/cli/src/dsh/updates.ts+++ b/cli/src/dsh/updates.ts@@ -4,7 +4,7 @@ import { HARNESS_MONOREPO, type DshRegistryEntry } from './registry.js'export const GIT_REVISION_RE = /^[a-f0-9]{40}$/i-export function samePackageSource(installed: InstalledDshRecord, entry: DshRegistryEntry): boolean {+export function samePackageSource(installed: InstalledDshRecord, entry: Pick<DshRegistryEntry, 'repo' | 'path'>): boolean {const normalize = (source: string): string => {const repo = source.replace(/\/$/, '').replace(/\.git$/, '')// This is the same official repository before its rename. Do not infer aliases from idsdiff --git a/cli/src/lib/daemonsSwitch.spec.ts b/cli/src/lib/daemonsSwitch.spec.tsindex e5f76a821..96a31b894 100644--- a/cli/src/lib/daemonsSwitch.spec.ts+++ b/cli/src/lib/daemonsSwitch.spec.ts@@ -459,7 +459,9 @@ describe('cli.ts routes everything daemon-related through the switch', () => {expect(onChanged).toMatch(/applyPair\(\)\s+pairBrain\?\.refresh\(\)\s+\}$/)const pairToggled = source.match(/onPairToggled = \(on\) => \{([\s\S]*?)\n \}/)?.[1] ?? ''expect(pairToggled).toMatch(/if \(on\) questionWatcher\.reset\(\)[\s;]+pairBrain\?\.refresh\(\)/)- expect(source).toMatch(/pairSensor\.setPair\(pairing\.pair, [^\n]+\)\n(\s+\/\/[^\n]*\n)*\s+pairBrain\?\.refresh\(\)\n\s+\}/)+ const applyPair = source.match(/const applyPair = \(\)(?:: void)? => \{([\s\S]*?)\n \}/)?.[1] ?? ''+ expect(applyPair).toMatch(/pairSensor\.setPair\(pairing\.pair, [^\n]+\)[\s\S]*pairBrain\?\.refresh\(\)/)+ expect(applyPair).toContain('refreshPairPackage()')})it('gates the reporters, turns, lessons, the pair harness, the pair request and every daemon_* frame', () => {diff --git a/cli/src/pair/pairHarness.spec.ts b/cli/src/pair/pairHarness.spec.tsindex 8ce9c7696..676532551 100644--- a/cli/src/pair/pairHarness.spec.ts+++ b/cli/src/pair/pairHarness.spec.ts@@ -143,6 +143,36 @@ describe('talking to it', () => {expect(w.deps.create).toHaveBeenCalledTimes(1)})+ it('refreshes an existing companion package on restart without sending, resuming, or rotating its token', async () => {+ const w = world()+ await w.harness.open()+ const saved = readFileSync(w.deps.stateFile, 'utf8')+ const token = readFileSync(w.token.file, 'utf8')+ w.deps.install.mockClear(); w.deps.create.mockClear()+ const restarted = new PairHarness(w.deps)+ expect(restarted.refreshPackage()).toBe(true)+ expect(w.deps.install).toHaveBeenCalledOnce()+ expect(w.deps.create).not.toHaveBeenCalled()+ expect(w.deps.resume).not.toHaveBeenCalled()+ expect(w.deps.send).not.toHaveBeenCalled()+ expect(w.deps.stop).not.toHaveBeenCalled()+ expect(readFileSync(w.deps.stateFile, 'utf8')).toBe(saved)+ expect(readFileSync(w.token.file, 'utf8')).toBe(token)+ expect(restarted.agentId()).toBe('pair-1')+ })++ it('refreshing release files never creates a companion when none was opened or pairing is off', async () => {+ const fresh = world()+ expect(fresh.harness.refreshPackage()).toBe(true)+ expect(fresh.deps.install).not.toHaveBeenCalled()+ expect(fresh.deps.create).not.toHaveBeenCalled()+ await fresh.harness.open()+ fresh.deps.install.mockClear()+ fresh.setPair(null)+ expect(fresh.harness.refreshPackage()).toBe(true)+ expect(fresh.deps.install).not.toHaveBeenCalled()+ })+it('two quick talks start one harness', async () => {const w = world()const [a, b] = await Promise.all([w.harness.talk('one'), w.harness.talk('two')])diff --git a/cli/src/pair/pairHarness.ts b/cli/src/pair/pairHarness.tsindex ab7079913..fbd84df25 100644--- a/cli/src/pair/pairHarness.ts+++ b/cli/src/pair/pairHarness.ts@@ -234,6 +234,19 @@ export class PairHarness {constructor(private readonly deps: PairHarnessDeps) {}+ /** Refresh an existing collection's release files without starting a turn or changing its session. */+ refreshPackage(): boolean {+ const daemonId = this.deps.pairedDaemon()+ const saved = this.saved()+ if (!daemonId || !saved) return true+ const engine = this.deps.find().find(row => row.agentId === saved.agentId)?.engine ?? saved.engine+ if (!engine) return true+ const identity = this.deps.pairedUid?.()+ const uid = identity && /^[A-Za-z0-9_-]{1,64}$/.test(identity) ? identity : undefined+ return this.deps.install(pairPackage({ daemonId, name: this.deps.pairedName?.() ?? null, uid, engine,+ mcpCommand: this.deps.mcpCommand(), tokenFile: this.deps.token.file }))+ }+/** `talk` / `daemon_talk`: one at a time, in order — two quick talks never start two harnesses. */talk(text: string, expectedUid?: string): Promise<Record<string, unknown>> {if (!text.trim()) return Promise.resolve({ ok: false, error: 'EMPTY' })diff --git a/store/README.md b/store/README.mdindex 5fd4414b8..e1458e535 100644--- a/store/README.md+++ b/store/README.md@@ -331,7 +331,15 @@ The sidebar starts with Search, followed by Discover and six broad sections: DesMedia, Science, Games and Code. Cards show Get, Update or Open for each harness; its page manages installationon this computer. Package manifests keep their precise domain labels, grouped only for browsing.-Updates are explicit. The Store shows **Update** when a matching catalog source publishes a different+Core app harnesses are part of each CLI release: Harness Monitor, Devices and Model Manager are+installed or refreshed automatically before their viewers are restored. Existing official Store+copies of these packages move onto this release-managed path on the next CLI update; their previous+files, workspaces and conversations are retained. Companions refresh their generated package when+the saved collection's identity is restored, without sending a prompt or replacing its conversation.+Linked developer checkouts and custom forks remain owner-managed. Core resources are versioned+beside the CLI, so a CLI rollback restores its corresponding core package revision as well.++Other Store applications, such as Blender, keep explicit updates. The Store shows **Update** when a matching catalog source publishes a differentcommit with changed package content. Built-in catalog entries carry their package folder's Git treerevision, so a change elsewhere in the monorepo does not flag every installed harness. Hover over theshort installed version on a package page to see the installed and available commits.