import { NextResponse } from "next/server"; import { readModelCallText, readModelLog } from "yt-dlp-transcript-common/lib/llm/callLog-server"; import { JOB_ID, locate } from "../_locate"; export const dynamic = "force-dynamic"; // ONE CALL of a job's model log (demo epic D3): its row with every item and // its whole text (each part kept to 40k characters), when the panel opens it. // GET /api/jobs//model-log/call?id= export async function GET(request: Request, { params }: { params: Promise<{ id: string }> }) { const { id } = await params; const call = new URL(request.url).searchParams.get("id")?.trim() ?? ""; if (!JOB_ID.test(id) || !/^\d+\.\d+$/.test(call)) return NextResponse.json({ error: "Invalid id" }, { status: 400 }); const at = await locate(id); if (!at) return NextResponse.json({ error: "no model call recorded" }, { status: 404 }); const row = (await readModelLog(at.files)).calls.find((c) => c.id === call); if (!row) return NextResponse.json({ error: `no call ${call}` }, { status: 404 }); return NextResponse.json({ call: row, text: await readModelCallText(at.files, call) }, { headers: { "cache-control": "no-store" } }); }