import { NextResponse } from "next/server"; import { withAuth } from "@/lib/api-auth"; import { listBenchmarks } from "@/lib/benchmarks"; import { modelName, targetName } from "@/lib/benchmark-view"; import { listEndpoints } from "@/lib/endpoints"; import { listLibrary } from "@/lib/library"; import { listTags } from "@/lib/tags"; export const dynamic = "force-dynamic"; /** Everything the ⌘K palette can jump to, compact (it filters in the browser). */ export const GET = withAuth(async () => { const [models, endpoints, runs, tags] = await Promise.all([listLibrary(), listEndpoints(), listBenchmarks({}, { limit: 300 }), listTags()]); return NextResponse.json({ models: models.map((m) => ({ id: m.id, repoId: m.repoId, quants: m.quants, status: m.status, tags: m.tags.map((t) => t.name) })), endpoints: endpoints.map((e) => ({ id: e.id, name: e.name, model: e.model, engine: e.engine ?? e.probe?.engine ?? null })), benchmarks: runs.map((r) => ({ id: r.id, label: r.label, kind: r.kind, state: r.state, target: targetName(r.snapshot), model: modelName(r.snapshot), createdAt: r.createdAt.getTime(), })), tags: tags.map((t) => t.name), }); });