2026-09-09 01:26:49 +03:00
|
|
|
/**
|
|
|
|
|
* 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
|
2026-09-29 00:34:21 +03:00
|
|
|
* (queued / extracting / waiting / auditing / merging) per job, oldest
|
|
|
|
|
* first — a multi-chunk source shows one row PER CHUNK ("· i/N" suffix,
|
|
|
|
|
* per-chunk jobs, owner 2026-09-28). Titles joined from the chat store;
|
|
|
|
|
* a missing chat record still reports the run.
|
2026-09-09 01:26:49 +03:00
|
|
|
*/
|
2026-09-11 02:43:35 +03:00
|
|
|
import { chatStore, extractionStatuses } from "@/src/server";
|
2026-09-09 01:26:49 +03:00
|
|
|
|
|
|
|
|
export const dynamic = "force-dynamic";
|
|
|
|
|
|
|
|
|
|
export async function GET() {
|
|
|
|
|
const runs = extractionStatuses().map((run) => ({
|
|
|
|
|
chatId: run.chatId,
|
2026-09-13 02:08:55 +03:00
|
|
|
// The run's own label (the file path for notes imports) wins; chat
|
2026-09-29 00:34:21 +03:00
|
|
|
// runs fall back to the chat store's title. Chunk jobs append their
|
|
|
|
|
// part ("· 2/5") — one row per chunk of the fan-out.
|
|
|
|
|
title:
|
|
|
|
|
(run.label ?? chatStore.getChat(run.chatId)?.title ?? run.chatId) +
|
|
|
|
|
(run.part ? ` · ${run.part.i}/${run.part.n}` : ""),
|
2026-09-09 01:26:49 +03:00
|
|
|
phase: run.phase,
|
|
|
|
|
startedAt: run.startedAt,
|
2026-09-11 03:25:25 +03:00
|
|
|
// Live per-stage usage (the money channel): model + per-step CallUsage,
|
|
|
|
|
// accumulated as steps bill. Cost and context-window folds are the
|
|
|
|
|
// consumer's (core/prices.ts helpers — nothing stores dollars).
|
|
|
|
|
usage: run.usage,
|
2026-09-09 01:26:49 +03:00
|
|
|
}));
|
|
|
|
|
return Response.json({ runs });
|
|
|
|
|
}
|