42 lines
3.6 KiB
Plaintext
42 lines
3.6 KiB
Plaintext
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import os from 'node:os';
|
|
import assert from 'node:assert/strict';
|
|
import { randomUUID } from 'node:crypto';
|
|
import { ControlledDeepSeekSession } from '../../src/core/engines/controlled-session.mjs';
|
|
import { resolveControlledInstallation } from '../../src/core/engines/controlled-installation.mjs';
|
|
const label = process.argv[2], timeoutMs = Number(process.argv[3] ?? 15000);
|
|
assert.match(label, /^[a-z0-9-]+$/); assert.ok([15000, 45000].includes(timeoutMs));
|
|
const root = path.resolve('.qa/reliability-1.25.2/startup-' + label); assert.equal(fs.existsSync(root), false); fs.mkdirSync(root);
|
|
let cwd = path.join(root, 'project'); fs.mkdirSync(cwd); fs.writeFileSync(path.join(cwd, 'README.md'), '# Owned readiness-only probe\n');
|
|
const failure = JSON.parse(fs.readFileSync('.qa/release-bf42f32d-eeac-47aa-8fa5-5167208d9035/compiled-api-failure.json'));
|
|
const original = failure.sessions.flatMap(session => session.execution.engineRuns ?? [])[0];
|
|
const originalReady = JSON.parse(fs.readFileSync('C:/Users/wangy/AppData/Local/Temp/AgentWorkbench-Engine-Runs/' + original.id + '/ready.json'));
|
|
const variant = process.argv[4] ?? 'normal'; assert.ok(['normal', 'temp', 'temp-original-cwd'].includes(variant));
|
|
if (variant === 'temp-original-cwd') {
|
|
const failureRoot = path.resolve('.qa/release-bf42f32d-eeac-47aa-8fa5-5167208d9035');
|
|
const native = JSON.parse(fs.readFileSync(path.join(failureRoot, 'artifacts', original.reportSha256.slice(0,2), original.reportSha256 + '.blob'))).native;
|
|
cwd = native.launchInputs.cwd;
|
|
}
|
|
const invocation = variant === 'normal' ? path.join(root, 'invocation') : path.join(os.tmpdir(), 'AgentWorkbench-Engine-Runs', randomUUID());
|
|
const installation = resolveControlledInstallation(process.cwd(), original.installation.root); assert.equal(installation.controlledStatus, 'available');
|
|
const driver = new ControlledDeepSeekSession(installation, { timeoutMs });
|
|
const owner = Object.fromEntries(['sessionId', 'projectId', 'taskId', 'runId', 'jobId'].map(name => [name, randomUUID()]));
|
|
const started = Date.now(), observations = []; let result, opened = false;
|
|
try {
|
|
await driver.open({ directory: invocation, cwd, owner, sdkSessionId: randomUUID(), tools: originalReady.catalogue,
|
|
config: { model: 'owned-readiness-probe', contextLimit: 64000, maxOutputTokens: 2048 }, strategy: original.installation.strategy,
|
|
signal: AbortSignal.timeout(timeoutMs + 10000),
|
|
onModel: () => { throw Error('No model request authorized in readiness probe.'); }, onTool: () => { throw Error('No tool execution authorized in readiness probe.'); },
|
|
onState: (state, value) => { observations.push({ state, elapsedMs: Date.now() - started, pid: value?.pid }); console.log(JSON.stringify(observations.at(-1))); } });
|
|
opened = true; result = { success: true, elapsedMs: Date.now() - started };
|
|
} catch (error) { result = { success: false, elapsedMs: Date.now() - started, error: error.stack }; process.exitCode = 1; }
|
|
finally {
|
|
const report = await driver.close({ force: !opened });
|
|
const marker = path.join(invocation, 'ready.json');
|
|
result = { ...result, label, timeoutMs, variant, invocation, cwd, scope: 'Diagnostic only, no product wait change, no remote model; original pure prompt experiment and catalogue.',
|
|
ready: fs.existsSync(marker) ? JSON.parse(fs.readFileSync(marker)) : null, observations, report, realModelRequests: 0 };
|
|
fs.writeFileSync(path.join(root, 'result.json'), JSON.stringify(result, null, 2) + '\n', { flag: 'wx' });
|
|
console.log(JSON.stringify({ success: result.success, label, timeoutMs, elapsedMs: result.elapsedMs, readyAt: result.ready?.readyAt, error: result.error }));
|
|
}
|