import type { Metadata } from 'next'; import { AdminFilters, AdminTitle, Mono, StatusChip, Trunc } from '@/components/admin/ui'; import { DataTable, EmptyRow, Td, Th } from '@/components/ui/data-table'; import { LiveAgo } from '@/components/ui/live'; import { Unavailable } from '@/components/ui/unavailable'; import { adminApi, load, requireAdmin } from '@/lib/admin/admin-api'; import { fmtDateTime, fmtDuration, fmtInt, num } from '@/lib/format'; export const metadata: Metadata = { title: 'LLM jobs', robots: { index: false, follow: false } }; export const dynamic = 'force-dynamic'; export default async function AdminLlmJobsPage({ searchParams }: { searchParams: Promise> }) { await requireAdmin(); const sp = await searchParams; const limit = Math.min(1000, Math.max(10, Number(sp.limit) || 100)); const [jobs, health] = await Promise.all([load(adminApi.llmJobs({ limit })), load(adminApi.llmHealth())]); const ms = (v: unknown) => (num(v) === null ? '—' : `${fmtInt(Math.round((num(v) ?? 0) / 1000))} s`); return ( <> engine {health.data.engine ?? '—'} {health.data.models && · {Object.entries(health.data.models).map(([k, v]) => `${k}: ${v}`).join(' · ')}} {health.data.embedding_model && · embeddings {health.data.embedding_model}} ) : ( `LLM health unavailable: ${health.error}` ) } /> ({ value: v, label: v })) }]} /> {!jobs.ok ? ( ) : ( <> {jobs.data.totals && jobs.data.totals.length > 0 && (

Totals by stage · model · status

Stage Model Status n Input tokens Output tokens Avg duration {jobs.data.totals.map((t, i) => ( {t.stage} {t.model} {fmtInt(t.n)} {fmtInt(t.input_tokens)} {fmtInt(t.output_tokens)} {ms(t.avg_ms)} ))}
)} Created Task Stage Model Node Schema In Out Duration Status Error Snapshot {jobs.data.items.length === 0 && No LLM jobs recorded.} {jobs.data.items.map((j) => ( {j.task_type ?? '—'} {j.stage ?? '—'} {j.model ?? '—'} {j.schema_name ?? '—'} {fmtInt(j.input_tokens)} {fmtInt(j.output_tokens)} {num(j.duration_ms) === null ? '—' : fmtDuration(Math.round((num(j.duration_ms) ?? 0) / 1000))} {j.snapshot_id ? {j.snapshot_id} : —} ))} )} ); }