Files
OmniRoute/src/lib/jobs/reasoningCacheCleanupJob.ts
diegosouzapw f00e9a1272 fix(postinstall): extend native module repair to cover wreq-js for pnpm global installs (#1634)
- Add fixWreqJsBinary() to postinstall.mjs with 3-strategy repair:
  1. Copy platform binary from root node_modules
  2. Copy entire rust/ directory (all platform binaries)
  3. npm rebuild wreq-js fallback
- Fixes macOS arm64 global pnpm installs shipping only Linux binaries
- Adds reasoning replay cache feature for DeepSeek V4 (#1628)
- Updates CHANGELOG.md with both fixes
2026-04-26 20:15:47 -03:00

41 lines
995 B
TypeScript

import { cleanupReasoningCache } from "../../../open-sse/services/reasoningCache.ts";
const DEFAULT_INTERVAL_MS = 30 * 60 * 1000;
let timer: NodeJS.Timeout | null = null;
function getIntervalMs() {
const raw = process.env.OMNIROUTE_REASONING_CACHE_CLEANUP_INTERVAL_MS;
const parsed = raw ? Number(raw) : Number.NaN;
return Number.isFinite(parsed) && parsed >= 60_000 ? parsed : DEFAULT_INTERVAL_MS;
}
export function startReasoningCacheCleanupJob() {
if (timer) {
return timer;
}
const run = () => {
try {
const deleted = cleanupReasoningCache();
if (deleted > 0) {
console.log(`[ReasoningCache] expired entries removed=${deleted}`);
}
} catch (error) {
console.error("[ReasoningCache] Cleanup job failed:", error);
}
};
run();
timer = setInterval(run, getIntervalMs());
timer.unref?.();
return timer;
}
export function stopReasoningCacheCleanupJob() {
if (timer) {
clearInterval(timer);
timer = null;
}
}