import { getPaths } from "yt-dlp-transcript-common/lib/paths"; import { getSettings } from "yt-dlp-transcript-common/lib/settings"; import { lookoutReadout } from "yt-dlp-transcript-common/lib/lookoutStore"; import { opsFail } from "../_lib"; import { readRoute } from "../_read"; export const dynamic = "force-dynamic"; // GET /api/ops/lookouts[?id=] — `pnpm ops get lookouts` // // The saved lookouts (settings.lookouts, SETTINGS.md) and what the store holds // for each (common/lib/lookoutStore.ts, `transcripts/.lookouts//`): its // runs, the latest one summarised (when, window, model, calls, seconds, // ideas), how many of that run's ideas have no verdict yet, and the verdicts // given. Reads settings and the store only — never a channel's videos, so it // is cheap to poll; what a lookout would read is `lookout-run` with dryRun. export async function GET(request: Request) { return readRoute(request, ["id"], async (q) => { const { enabled, afterSync, items } = getSettings().lookouts; const id = q.get("id"); const chosen = id === null ? items : items.filter((i) => i.id === id); if (id !== null && chosen.length === 0) { return opsFail(`no lookout "${id}" — settings.lookouts.items names ${items.map((i) => i.id).join(", ") || "none"}`, 404); } const paths = getPaths(); const lookouts = await Promise.all(chosen.map(async (item) => ({ ...item, ...(await lookoutReadout(paths, item.id)) }))); return { enabled, afterSync, lookouts }; }); }