Something went wrong. Try again.
snapcompact for prime agent
Something went wrong. Try again.
1.9 kB · 59 lines
JavaScript
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960import { spawnSync } from "node:child_process";import { fileURLToPath } from "node:url";
const preparation = { firstKeptEntryId: "kept", messagesToSummarize: [{ role: "user", content: "protocol compatibility", timestamp: 1 }], turnPrefixMessages: [], tokensBefore: 100, fileOps: { read: [], written: [], edited: [] },};const common = { preparation, model: { api: "openai-responses", id: "gpt-5.2", provider: "openai" }, maxFrameDataBytes: 3_000_000, maxArchiveTokens: 200_000,};const bun = process.env.PRIME_SNAPCOMPACT_BUN ?? "bun";const cases = [ { file: "../worker.ts", input: { ...common, includeThinking: false } }, { file: "../worker-v2.ts", input: { ...common, protocolVersion: 2, historicalToolResultsToKeep: 3 }, protocolVersion: 2, }, { file: "../worker-v3.ts", input: { ...common, protocolVersion: 3, includeThinking: true, historicalToolResultsToKeep: 3, }, protocolVersion: 3, thinkingIncluded: true, },];const results = [];for (const testCase of cases) { const worker = fileURLToPath(new URL(testCase.file, import.meta.url)); const result = spawnSync(bun, [worker], { input: JSON.stringify(testCase.input), encoding: "utf8", maxBuffer: 16 * 1024 * 1024, }); if (result.status !== 0) { throw new Error(`${testCase.file} rejected its protocol: ${result.stderr || result.stdout}`); } const output = JSON.parse(result.stdout); if ( output.packageVersion !== "18.0.8" || !output.summary?.trim() || (testCase.protocolVersion !== undefined && output.protocolVersion !== testCase.protocolVersion) || (testCase.thinkingIncluded !== undefined && output.thinkingIncluded !== testCase.thinkingIncluded) ) { throw new Error(`${testCase.file} returned invalid output`); } results.push(testCase.file);}console.log(JSON.stringify({ compatibleWorkers: results }));