import { probeTools } from "./tools.mjs"; import type { DoctorReport } from "./tool-types"; // The app's cache of the tool probe. In memory, ten minutes, and NEVER probed // from a page render: the dashboard reads whatever is here (or nothing) and the // only writer is POST /api/doctor. Probing seven binaries on every request would // be a fork/exec tax on a page whose whole point is being cheap to open. const TTL_MS = 10 * 60 * 1000; let cache: DoctorReport | null = null; /** The last probe, or null when nothing has been probed (or it is stale). */ export function toolsCache(): DoctorReport | null { if (cache && Date.now() - cache.checkedAt < TTL_MS) return cache; return null; } export async function probeNow(): Promise { cache = (await probeTools()) as DoctorReport; return cache; }