import fs from "node:fs/promises"; import path from "node:path"; import { guarded, json } from "@/lib/api"; import { env } from "@/lib/env"; /** Serves the Phase Zero benchmark deliverables to the model laboratory. */ export const GET = guarded(async (req) => { const file = req.nextUrl.searchParams.get("file") ?? "capability-matrix.json"; const allowed = ["capability-matrix.json", "benchmark-report.md", "routing-recommendations.md", "routing-recommendations.json", "model-discovery.json", "openai-results.json", "anthropic-results.json", "modality-results.json", "pricing.json"]; if (!allowed.includes(file)) return json({ error: "fichier inconnu" }, { status: 400 }); try { const data = await fs.readFile(path.join(env.BENCHMARKS_DIR, file), "utf8"); return new Response(data, { headers: { "content-type": file.endsWith(".md") ? "text/markdown; charset=utf-8" : "application/json" } }); } catch { return json({ error: "benchmark introuvable" }, { status: 404 }); } });