mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-07-26 09:52:11 +03:00
Introduce runtime-configurable payload mutation/filter rules with file reload support and a settings API so upstream request bodies can be customized per model and protocol without restarts. Expand search support with Google PSE, Linkup, SearchAPI, and SearXNG, including validation, routing, analytics costing, MCP schema updates, and search-type-aware provider selection. Update Pollinations to support anonymous access, endpoint failover, and the latest public model lineup. Add OmniRoute response metadata headers/SSE comments, per-connection model exclusion rules, combo tag-based routing, buffered spend writes, and scheduled daily/weekly/monthly budget resets. Update model catalog and dashboard UIs to surface source labels and hide models excluded by all active connections.
41 lines
971 B
TypeScript
41 lines
971 B
TypeScript
import { syncAllBudgetSchedules } from "@/domain/costRules";
|
|
|
|
const DEFAULT_INTERVAL_MS = 10 * 60 * 1000;
|
|
|
|
let timer: NodeJS.Timeout | null = null;
|
|
|
|
function getIntervalMs() {
|
|
const raw = process.env.OMNIROUTE_BUDGET_RESET_JOB_INTERVAL_MS;
|
|
const parsed = raw ? Number(raw) : Number.NaN;
|
|
return Number.isFinite(parsed) && parsed >= 10_000 ? parsed : DEFAULT_INTERVAL_MS;
|
|
}
|
|
|
|
export function startBudgetResetJob() {
|
|
if (timer) {
|
|
return timer;
|
|
}
|
|
|
|
const run = () => {
|
|
try {
|
|
const result = syncAllBudgetSchedules(Date.now());
|
|
if (result.resetCount > 0) {
|
|
console.log(`[BudgetReset] processed=${result.processed} reset=${result.resetCount}`);
|
|
}
|
|
} catch (error) {
|
|
console.error("[BudgetReset] Job failed:", error);
|
|
}
|
|
};
|
|
|
|
run();
|
|
timer = setInterval(run, getIntervalMs());
|
|
timer.unref?.();
|
|
return timer;
|
|
}
|
|
|
|
export function stopBudgetResetJob() {
|
|
if (timer) {
|
|
clearInterval(timer);
|
|
timer = null;
|
|
}
|
|
}
|