TypeScript 97.4%
SQL 1%
JavaScript 0.9%
CSS 0.6%
1/**2 * Next.js instrumentation hook — runs once per server process.3 * Schedules the model registry refresh (startup + interval) using the owner keys from the4 * environment. Users additionally trigger syncs with their own keys when they add a provider.5 */6export async function register() {7 if (process.env.NEXT_RUNTIME !== "nodejs") return;8 if (process.env.POLYLLM_DISABLE_SCHEDULER === "1") return;9 const { syncAllWithEnvKeys } = await import("@/lib/ai/registry");10 const { log } = await import("@/lib/log");11 const minutes = Number(process.env.MODEL_SYNC_INTERVAL_MINUTES ?? 360);1213 const run = async (why: string) => {14 try {15 const results = await syncAllWithEnvKeys(why);16 log.info("scheduled model sync", { why, results: results.map((r) => ({ provider: r.provider, ok: r.ok, found: r.found, added: r.added, removed: r.removed })) });17 } catch (e) {18 log.warn("scheduled model sync failed", { error: (e as Error).message });19 }20 };2122 // Startup sync (delayed so the DB pool and migrations are ready).23 setTimeout(() => void run("startup"), 5_000).unref?.();24 if (minutes > 0) setInterval(() => void run("schedule"), minutes * 60_000).unref?.();25}26