import { readRunView } from "@/lib/research/runs"; import { fail, ok } from "../../../_respond"; export const dynamic = "force-dynamic"; // A TRANSPARENT RUN (plans/umtool-redesign.md, R3): GET answers the run's view // (lib/research/runs-types.ts RunView) -- read from the iteration's // trace.jsonl, or projected from its turns.jsonl for a run before the trace. // `?run=` picks one of several runs (the last by default). Read only; the // page polls it while the run is live. // GET /api/research/runs/
/[?run=] -> RunView // 404 no such iteration · 400 a bad address · 409 an iteration.json that does not read export async function GET(request: Request, ctx: { params: Promise<{ article: string; n: string }> }) { try { const { article, n } = await ctx.params; const run = Number(new URL(request.url).searchParams.get("run") ?? ""); return ok(await readRunView(decodeURIComponent(article), Number(n), Number.isInteger(run) && run > 0 ? run : null)); } catch (e) { return fail(e); } }