The 2026-09 observability wave's type-level foundation, landed before the streams so nothing renders against guessed shapes: - contracts/chat.ts: CallUsage + TurnUsage (per-model-call token accounting, one entry per teacher/wake turn keyed by messageId) and ChatRecord.turns — a DELIBERATELY parallel append-only usage log, not per-message metadata: the client re-POSTs its message list every turn and its copies never carry server-stamped fields, so anything inside messages gets clobbered by the next persist (the wave-3 merge-rule lesson). - contracts/chat.ts: PlanBlockData — the persisted data-plan-block part (full DAG on plan_init, one-level neighborhood on plan updates, snapshot semantics so history renders what was true then). - contracts/jobs.ts: JobUsage + JobRecord.usage — a sub-agent run's accumulated accounting, written by the runner. - core/ports.ts + store/chats.ts: ChatStore.appendTurnUsage — idempotent per messageId (abort replays / wake retries append once); listChats no longer leaks turns into the list payload. - core/prices.ts: PRICES + CONTEXT_LIMITS (generated from OpenRouter's published pricing via scripts/sync-pricing.ts) + pure folds: callCost, turnCost, sessionCost, contextWindow, jobCost. Unknown model or absent fields render as absent, never zero. - server/observability.ts: barrel-approved surface for the transport layer (fixes the import-law violation in the graph status route that slipped through the wave-3 merge verification). Capture wiring (agent onStepFinish -> persist seam, plan-block emission) lands next as master seam work; the streams start against these shapes.
21 lines
718 B
TypeScript
21 lines
718 B
TypeScript
/**
|
|
* GET /api/graph/status — the in-flight background extraction runs
|
|
* (vision §1: the pipeline status must be visible on the home graph).
|
|
* Thin transport over the pipeline's module-level registry: phase
|
|
* (extracting / auditing / merging) per chat, oldest first. Titles joined
|
|
* from the chat store; a missing chat record still reports the run.
|
|
*/
|
|
import { chatStore, extractionStatuses } from "@/src/server";
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
export async function GET() {
|
|
const runs = extractionStatuses().map((run) => ({
|
|
chatId: run.chatId,
|
|
title: chatStore.getChat(run.chatId)?.title ?? run.chatId,
|
|
phase: run.phase,
|
|
startedAt: run.startedAt,
|
|
}));
|
|
return Response.json({ runs });
|
|
}
|