Spaces:
Running
Running
File size: 1,172 Bytes
249c849 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 | #!/usr/bin/env tsx
/**
* Convert OpenHands JSONL trace → TCG LogEntry[] JSON file.
* Usage: tsx scripts/openhands/tcg-adapter-cli.ts <input.jsonl> [output.json]
*/
import fs from "fs";
import path from "path";
import { adaptOpenHandsTrace, parseOpenHandsJsonl } from "../../src/benchmark/openhands-adapter.ts";
const inputPath = process.argv[2];
const outputPath = process.argv[3] ?? "artifacts/openhands-adapted-logs.json";
if (!inputPath) {
console.error("Usage: tsx scripts/openhands/tcg-adapter-cli.ts <input.jsonl> [output.json]");
process.exit(1);
}
const raw = fs.readFileSync(path.resolve(inputPath), "utf-8");
const events = parseOpenHandsJsonl(raw);
const result = adaptOpenHandsTrace(events);
const payload = {
source: path.basename(inputPath),
log_count: result.logs.length,
metrics: result.metrics,
warnings: result.warnings,
logs: result.logs,
};
const out = path.resolve(outputPath);
fs.mkdirSync(path.dirname(out), { recursive: true });
fs.writeFileSync(out, `${JSON.stringify(payload, null, 2)}\n`, "utf-8");
console.log(JSON.stringify({ ok: true, output: out, log_count: result.logs.length, metrics: result.metrics }, null, 2));
|