Files
Agent-Workbench/scripts/live-af/initial.mjs
T
2026-11-06 13:40:29 +08:00

37 lines
3.3 KiB
JavaScript

import fs from 'node:fs';
import assert from 'node:assert/strict';
import { execFileSync } from 'node:child_process';
import { purgeEvidence, root, save, client, publicMetadata } from '../live-ad/common.mjs';
import { publicSnapshot } from '../retained-host-state.mjs';
import { inspectorClosed } from '../live-ad/inspector.mjs';
import { resolveControlledInstallation } from '../../src/core/engines/controlled-installation.mjs';
import { resolveOriginalPurgeSource } from '../../src/core/engines/purge-strategy.mjs';
import { order, allowed, goal, purgePrompt, observations } from './contract.mjs';
const ae = JSON.parse(fs.readFileSync('.qa/live-engineering-ae/summary.json'));
assert.ok(ae.samples.length === 2 && ae.samples.every(row => row.success));
const fixturePath = process.argv[2]; assert.ok(fixturePath, 'The completed open native fixture result is required.');
const fixture = JSON.parse(fs.readFileSync(fixturePath)); assert.equal(fixture.success, true); assert.equal(fixture.realModelRequests, 0);
assert.equal(fixture.completeSamples, 4); assert.equal(fixture.originalStateAuditPassed, true); assert.equal(fixture.actualBatchDriverExecuted, true);
purgeEvidence(); assert.equal(fs.existsSync(root), false, 'Never refreeze AF after observing any real result.');
assert.equal(execFileSync('git', ['status', '--porcelain'], { encoding: 'utf8', windowsHide: true }).trim(), '');
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.8'); assert.equal(host.activity.active, false); assert.equal(host.desktopWindows.count, 0);
for (const [key, value] of Object.entries({ executionMode: 'unrestricted', approvalMode: 'full', capacityMode: 'passthrough', historyPolicy: 'preserve',
maxSteps: 0, maxRunTokens: 0, maxTaskTokens: 0, maxRunDurationMs: 0 })) assert.equal(boot.config[key], value);
const connection = center.connections.find(row => row.id === '1a7a55a9-29f2-4b9f-8ea2-5a55afd7eacd');
assert.equal(connection.enabled, true); assert.equal(connection.hasKey, true); assert.equal(connection.model, 'deepseek-flash');
assert.equal(connection.credentialRevision, 1); assert.deepEqual(connection.nativeParameters, {});
const installation = resolveControlledInstallation(process.cwd()), source = resolveOriginalPurgeSource(process.cwd(), undefined, installation);
assert.equal(installation.controlledStatus, 'available'); assert.equal(source.status, 'available');
const baseline = await publicSnapshot('http://127.0.0.1:4318', host.identity.dataRoot);
save('current.json', { host, config: boot.config, center, connection, originalProjects: boot.projects, originalPublicMetadata: publicMetadata(host.identity.dataRoot),
baseline, installation, source, order, allowed, goal, purgePrompt, observations, fixturePath, fixture,
driverCommit: execFileSync('git', ['rev-parse', 'HEAD'], { encoding: 'utf8', windowsHide: true }).trim() });
console.log(JSON.stringify({ frozen: true, requests: 0, driverCommit: JSON.parse(fs.readFileSync(root + '/current.json')).driverCommit,
version: boot.version, pid: host.identity.pid, projects: baseline.projects, sessions: baseline.database.sessionIds.length,
connectionRevision: connection.revision, harnessSha256: installation.controlledSha256, purgeSha256: source.sourceSha256 }));
} finally { await close(); }