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

17 lines
1.1 KiB
JavaScript

import { randomUUID } from 'node:crypto';
import { purgeEvidence, read, save, client, origin } from '../live-ad/common.mjs';
import { inspectorClosed } from '../live-ad/inspector.mjs';
import { auditExperiment } from '../retained-experiment-state.mjs';
purgeEvidence();
const frozen = read('current.json'), owned = read('owned.json'), restoration = read('restoration.json');
const prefix = 'audits/final-' + randomUUID(), { api, boot, close } = await client(); let result;
try {
await inspectorClosed(); const host = await api('/host/status');
const changed = !!restoration.connection;
const audited = await auditExperiment({ origin, host, boot, frozen, owned,
edits: changed ? [{ id: frozen.connection.id, revisionDelta: 2 }] : [], registryRevisionDelta: changed ? 4 : 0, configRevisionDelta: changed ? 2 : 0 });
save(prefix + '/after.json', audited.after); result = { ...audited.result, inspectorClosed: true };
} catch (error) { result = { success: false, error: error.stack }; process.exitCode = 1; }
finally { save(prefix + '/result.json', result); await close(); }
console.log(JSON.stringify({ prefix, ...result }));