UNPKG

openclaw

Version:

Multi-channel AI gateway with extensible messaging integrations

29 lines (28 loc) • 811 B
//#region src/agents/command-poll-backoff.ts const BACKOFF_SCHEDULE_MS = [ 5e3, 1e4, 3e4, 6e4 ]; function recordCommandPoll(e, t, n) { const r = e.commandPollCounts ??= /* @__PURE__ */ new Map(); const i = r.get(t); const a = Date.now(); const o = n ? 0 : (i?.count ?? -1) + 1; r.set(t, { count: o, lastPollAt: a }); return BACKOFF_SCHEDULE_MS[Math.min(o, BACKOFF_SCHEDULE_MS.length - 1)] ?? 6e4; } function resetCommandPollCount(e, t) { e.commandPollCounts?.delete(t); } function pruneStaleCommandPollsCore(e) { if (!e.commandPollCounts) return; const t = Date.now(); for (const [n, r] of e.commandPollCounts.entries()) if (t - r.lastPollAt > 36e5) e.commandPollCounts.delete(n); } //#endregion export { recordCommandPoll as n, resetCommandPollCount as r, pruneStaleCommandPollsCore as t };