import Link from 'next/link'; import { requireAdmin } from '@/lib/admin/auth'; import { dashboard } from '@/lib/admin/queries'; import { queueDepths } from '@/lib/admin/queue'; import { adminLogout } from '@/lib/admin/actions'; import { AdminShell, Kpi, StatusPill, fmtTs, n } from '@/components/admin/shell'; import { Table, th, td, tdNum } from '@/components/ui/primitives'; import { getRouter } from '@rareindex/ai'; export default async function AdminHome() { await requireAdmin(); const [{ counts, recentRuns, recentEvents }, queues] = await Promise.all([dashboard(), queueDepths()]); const c = (counts ?? {}) as Record; const ai = getRouter(); return ( } >
0 ? 'alert' : undefined} /> 1000 ? 'alert' : undefined} /> 0 ? 'loss' : undefined} />

Recent connector runs

Control center →
{recentRuns.length === 0 ? : null} {recentRuns.map((r) => ( ))}
ConnectorStatusTriggerStartedPagesRawNorm.Dup.Error
No runs yet. Trigger one from the control center.
{String(r.connector_id)} {String(r.trigger)} {fmtTs(r.started_at)} {n(r.pages_success)}/{n(r.pages_attempted)} {n(r.records_raw)} {n(r.records_normalized)} {n(r.records_duplicate)} {r.error ? String(r.error) : ''}

Queues (pg-boss)

    {queues.length === 0 ?
  • Queue tables not initialised yet (the worker creates them on first start).
  • : null} {queues.map((q) => (
  • {q.name}{q.queued} queued · {q.active} active · {q.failed} failed
  • ))}

Events (24h)

    {recentEvents.length === 0 ?
  • No events yet.
  • : null} {recentEvents.map((e) => (
  • {String(e.type)}{n(e.n)}
  • ))}

AI model routing

    {ai.table().map((r) => (
  • {r.role}{r.provider ? `${r.provider} · ${r.model}` : 'not configured'}
  • ))}
); }