import { listRuns, listWorkers, overviewCounts } from "@autoscholar/core"; import { papers, securityEvents } from "@autoscholar/db"; import { desc, sql } from "drizzle-orm"; import Link from "next/link"; import { StatusBadge } from "@/components/StatusBadge"; import { ago, fmtDateTime, fmtUsd } from "@/lib/format"; import { db } from "@/lib/server/db"; export const dynamic = "force-dynamic"; export default async function Overview() { const d = db(); const counts = await overviewCounts(d); const workers = await listWorkers(d); const [pubs] = await d.select({ n: sql`count(*)::int` }).from(papers); const alerts = await d.select().from(securityEvents).orderBy(desc(securityEvents.createdAt)).limit(8); const recent = await listRuns(d, { limit: 8 }); const tiles: Array<[string, number]> = [ ["Running", (counts.byStatus.running ?? 0) + (counts.byStatus.provisioning ?? 0)], ["Queued", (counts.byStatus.queued ?? 0) + (counts.byStatus.retrying ?? 0)], ["Blocked", (counts.byStatus.quality_failed ?? 0) + (counts.byStatus.awaiting_approval ?? 0)], ["Completed", counts.byStatus.published ?? 0], ["Failed", (counts.byStatus.failed ?? 0) + (counts.byStatus.cancelled ?? 0)], ]; const online = workers.filter((w) => w.status === "online" || w.status === "draining"); return (

Command center

Overview

New research
{tiles.map(([l, n]) => (

{l}

{n}

))}

Provider spend

{fmtUsd(counts.totalCostUsd)}

client-side estimate

MacLustr workers

Details

{online.length} of {workers.length} online · {pubs?.n ?? 0} publications

    {workers.length === 0 && (
  • No worker has enrolled yet. Install the worker daemon on a MacLustr node (docs/OPERATIONS.md).
  • )} {workers.map((w) => (
  • {w.name} {w.running}/{w.capacity} · {ago(w.lastHeartbeatAt)}
  • ))}

Security alerts

Audit log
    {alerts.length === 0 &&
  • No security events recorded.
  • } {alerts.map((a) => (
  • {a.kind}{" "} {JSON.stringify(a.detail).slice(0, 80)} {fmtDateTime(a.createdAt)}
  • ))}

Recent runs

All runs
{recent.length === 0 && ( )} {recent.map((r) => ( ))}
Title Status Stage Attempt Cost Updated
No runs yet. Upload a research instruction to start.
{r.title} {r.currentStage ?? "—"} {r.currentAttemptNo}/{r.maxAttempts} {fmtUsd(r.totalCostUsd)} {ago(r.updatedAt)}
); }