22 lines
1.2 KiB
JavaScript
22 lines
1.2 KiB
JavaScript
import fs from 'node:fs';
|
|
import path from 'node:path';
|
|
import { Store } from '../../src/server/store.mjs';
|
|
import { Provider } from '../../src/server/provider.mjs';
|
|
import { Runtime } from '../../src/server/runtime.mjs';
|
|
|
|
const [data, sessionId] = process.argv.slice(2);
|
|
const store = new Store(data), provider = new Provider();
|
|
provider.setKey('owned-mcp-key-canary');
|
|
const runtime = new Runtime(store, provider), session = store.session(sessionId);
|
|
runtime.start(sessionId, 'Owned MCP crash fixture: invoke exactly the registered tool.');
|
|
const timer = setInterval(() => {
|
|
const approval = session.approvals.find(value => value.status === 'pending');
|
|
if (approval) runtime.decide(session.id, approval.id, true);
|
|
const job = [...store.core.mcp_job.values()].find(value => value.sessionId === session.id && value.operation === 'call' && value.status === 'calling');
|
|
if (job?.directory && fs.existsSync(path.join(job.directory, 'owned-call-dispatched.txt'))) {
|
|
console.log(JSON.stringify({ crashAfterDispatched: true, jobId: job.id, invocationId: job.invocationId }));
|
|
process.exit(85);
|
|
}
|
|
}, 10);
|
|
setTimeout(() => { clearInterval(timer); console.error('Owned MCP crash fixture deadline.'); process.exit(86); }, 12000);
|