UNPKG

@bitkyc08/opencodex

Version:

Universal provider proxy for OpenAI Codex & Claude Code — use any LLM with Codex CLI/App/SDK and Claude Code

31 lines (26 loc) • 1.45 kB
/** Shared bookkeeping leaf; lifecycle cleanup must not load warmup/credential owners. */ /** Completed/due markers use epoch milliseconds; persisted legacy markers may use seconds. */ export type CodexQuotaAutoRefreshWindows = { fiveHour?: number; weekly?: number }; /** * Backoff evidence for one account. `generation` names the credential the failure was observed * under; a record from another generation says nothing about the credential in use now. */ export type CodexQuotaRetry = { after: number; delay: number; generation: string }; export const completedByAccount = new Map<string, CodexQuotaAutoRefreshWindows>(); export const retryAfterByAccount = new Map<string, CodexQuotaRetry>(); export const scheduledByAccount = new Map<string, CodexQuotaAutoRefreshWindows>(); export const quotaRefreshAfterByAccount = new Map<string, CodexQuotaRetry>(); /** Drop every activation record when its account is removed. */ export function forgetCodexQuotaAutoRefreshAccount(accountId: string): void { completedByAccount.delete(accountId); retryAfterByAccount.delete(accountId); scheduledByAccount.delete(accountId); quotaRefreshAfterByAccount.delete(accountId); } /** Clear the dependency-free activation bookkeeping for isolated tests. */ export function resetCodexQuotaAutoRefreshStateForTests(): void { completedByAccount.clear(); retryAfterByAccount.clear(); scheduledByAccount.clear(); quotaRefreshAfterByAccount.clear(); }