import fs from 'node:fs'; import assert from 'node:assert/strict'; import { execFileSync } from 'node:child_process'; import { root, origin, save, client, expectedOutputFields } from './common.mjs'; import { publicSnapshot } from '../retained-host-state.mjs'; import { inspectorClosed } from './inspector.mjs'; assert.ok(fs.existsSync(root)); assert.equal(fs.existsSync(root + '/frozen.json'), false, 'Freeze this batch once.'); assert.equal(execFileSync('git', ['status', '--porcelain'], { encoding: 'utf8', windowsHide: true }).trim(), '', 'Commit and verify the new driver before real requests.'); const { api, boot, close } = await client(); try { await inspectorClosed(); const host = await api('/host/status'), center = await api('/model-center'); assert.equal(boot.version, '1.25.13'); assert.equal(host.activity.active, false); for (const [key, expected] of Object.entries({ executionMode: 'unrestricted', capacityMode: 'passthrough', approvalMode: 'full', maxSteps: 0, maxRunTokens: 0, maxTaskTokens: 0 })) assert.equal(boot.config[key], expected, key); const connections = center.connections.filter(value => value.enabled && value.hasKey); assert.ok(connections.length > 0, 'Restore credentials in Model Center before freezing.'); const priority = connections.slice().sort((a, b) => { const rank = value => new URL(value.baseUrl).hostname === 'api.deepseek.com' ? 0 : value.protocol === 'responses' ? 1 : value.protocol === 'chat-completions' ? 2 : 3; return rank(a) - rank(b) || a.id.localeCompare(b.id); }).map(value => value.id); const baseline = await publicSnapshot(origin, host.identity.dataRoot); save('frozen.json', { observedAt: new Date().toISOString(), host, config: boot.config, center, connections, baseline, originalProjects: boot.projects, engineeringPriority: priority, outputFields: Object.fromEntries(connections.map(value => [value.id, expectedOutputFields(value)])), driverCommit: execFileSync('git', ['rev-parse', 'HEAD'], { encoding: 'utf8', windowsHide: true }).trim(), modelRequests: 0, historicalSamplesReplayed: false, keysReadOrResaved: false }); console.log(JSON.stringify({ frozen: true, version: boot.version, pid: host.identity.pid, connections: connections.map(value => ({ id: value.id, name: value.name, protocol: value.protocol, model: value.model, revision: value.revision })), priority, modelRequests: 0 })); } finally { await close(); }