Prepare desktop 1.15 offline source and release acceptance

This commit is contained in:
Agent Workbench Dev
2026-10-31 11:50:51 +08:00
parent b77783ba67
commit c5c8a84a7b
51 changed files with 6211 additions and 1136 deletions
+16 -1
View File
@@ -2,12 +2,27 @@ import test from 'node:test';
import assert from 'node:assert/strict';
import fs from 'node:fs';
import path from 'node:path';
import { randomBytes } from 'node:crypto';
import { randomBytes, createHash } from 'node:crypto';
import { fixture, workspace, until } from './helpers.mjs';
import { hostProof, verifyHostProof, assertHostStop } from '../src/shared/contracts/desktop-host.mjs';
import { ownedChild, writeState, readState } from '../src/core/desktop/file-state.mjs';
import { HostAuthority } from '../src/core/desktop/host-authority.mjs';
import { Provider } from '../src/server/provider.mjs';
import { inspectHostInstallation } from '../src/core/desktop/app-installation.mjs';
test('a rebuilt source archive binds actual generated client assets and retains its original running identity after disk changes', t => {
const f = fixture(t), root = path.join(f.root, 'owned-source-build'); fs.mkdirSync(root);
for (const directory of ['dist-client', 'dist-server', 'dist-desktop']) fs.cpSync(path.join(workspace, directory), path.join(root, directory), { recursive: true });
const packageBytes = fs.readFileSync(path.join(workspace, 'package.json')); fs.writeFileSync(path.join(root, 'package.json'), packageBytes);
fs.writeFileSync(path.join(root, 'MANIFEST.json'), JSON.stringify({ app: 'agent-workbench', kind: 'source', version: JSON.parse(packageBytes).version,
files: [{ path: 'package.json', bytes: packageBytes.length, sha256: createHash('sha256').update(packageBytes).digest('hex') }] }));
const authority = new HostAuthority({ appDirectory: root, store: f.store, provider: new Provider(), runtime: { appDirectory: root, active: new Map(), waiters: new Map() }, server: { address: () => ({ port: 49998 }) } });
const running = authority.identity(), asset = 'dist-client/assets/' + fs.readdirSync(path.join(root, 'dist-client/assets')).find(name => name.endsWith('.js'));
assert.ok(inspectHostInstallation(root).inputs.some(value => value.path === asset));
fs.appendFileSync(path.join(root, asset), '\n// owned source-archive disk change\n');
assert.equal(authority.identity().runtimeIdentity, running.runtimeIdentity);
assert.notEqual(inspectHostInstallation(root).identitySha256, running.runtimeIdentity);
});
test('host challenge proof rejects a stale challenge, changed identity and changed signature', () => {
const identity = { instanceId: 'owned', pid: 123, createdAt: 'fixed', runtimeIdentity: 'fixed-input' }, secret = randomBytes(32), challenge = randomBytes(32).toString('hex');