Spaces:
Running
Running
| /** | |
| * 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)); | |