#!/usr/bin/env node // fake-pi.mjs — hermetic PI_BIN stub for e2e tests. // Ignores all argv (the backend passes --mode rpc --approve) and // exec()s the scripted fake-pi-rpc.mjs with the F1 disambiguation scenario. import { fileURLToPath } from "node:url"; import { dirname, resolve } from "node:path"; import { spawnSync } from "node:child_process"; const __dir = dirname(fileURLToPath(import.meta.url)); const fakePiRpc = resolve(__dir, "../../..", "harness/tests/fake_pi/fake_pi_rpc.mjs"); const scenario = resolve(__dir, "../../..", "harness/tests/fake_pi/scripts/f1_disambiguation.json"); // Run the scripted fake-pi-rpc on this process's stdio so the backend's child // handle (stdin/stdout) drives the JSONL protocol directly. const result = spawnSync(process.execPath, [fakePiRpc, scenario], { stdio: "inherit", env: { ...process.env }, }); process.exit(result.status ?? 0);