import fs from 'node:fs'; import path from 'node:path'; import assert from 'node:assert/strict'; import { execFileSync } from 'node:child_process'; import { publicSnapshot } from './state.mjs'; import { root, origin, connectionId } from './common.mjs'; // Read-only freeze of the formal 1.25.1 state before sample W. 0 model requests. assert.equal(fs.existsSync(root), false, 'Sample W is frozen once; never overwrite.'); assert.equal(execFileSync('git', ['status', '--porcelain'], { encoding: 'utf8', windowsHide: true }).trim(), '', 'Freeze from a committed tree.'); const boot = await (await fetch(origin + '/api/bootstrap', { headers: { Connection: 'close' } })).json(); const api = async route => (await fetch(origin + '/api' + route, { headers: { 'X-Workbench-Token': boot.token, Connection: 'close' } })).json(); const host = await api('/host/status'), center = await api('/model-center'), connection = center.connections.find(c => c.id === connectionId); assert.equal(boot.version, '1.25.1'); assert.equal(host.identity.pid, 36552); assert.equal(host.activity.active, false); assert.equal(host.desktopWindows.count, 0); assert.equal(connection.enabled, true); assert.equal(connection.hasKey, true); assert.equal(connection.credentialRevision, 1); assert.equal(connection.model, 'gpt-6.1-sol'); assert.equal(connection.protocol, 'chat-completions'); assert.equal(connection.streaming, false); assert.equal(connection.contextLimit, 16000); assert.equal(connection.maxOutputTokens, 2048); assert.equal(connection.modelIdentityPolicy ?? 'record', 'record'); assert.equal(center.connections.find(c => c.id === '09b0293b-faad-45c3-832d-7c8b615813aa').enabled, false); assert.deepEqual(center.selected, { type: 'pool', id: '68e30376-b799-445b-a858-db2dba9920a0' }); const baseline = await publicSnapshot(origin, host.identity.dataRoot); assert.deepEqual(baseline.active, []); fs.mkdirSync(root, { recursive: true }); fs.writeFileSync(path.join(root, 'current.json'), JSON.stringify({ host, config: boot.config, projects: boot.projects, center, baseline, connectionRevision: connection.revision, sourceCommit: execFileSync('git', ['rev-parse', 'HEAD'], { encoding: 'utf8' }).trim(), observedAt: new Date().toISOString() }, null, 2), { flag: 'wx' }); console.log(JSON.stringify({ success: true, version: boot.version, pid: host.identity.pid, projects: baseline.projects, sessions: baseline.exports.length, connectionId, connectionRevision: connection.revision, modelRequests: 0 }));