Files
OmniRoute/open-sse/services/codexAccount/write.ts
Xiangzhe f060117464 [v3.8.50] refactor(codex): isolate virtual quota pools (#8367)
Merged — locally validated (30/30 focused tests: chatcore-codex-account-pool, codex-account-cooldown-write, codex-account-pool, providers-route-codex-account-pool, resilience-explain-codex-account, sse-auth-codex-account-pool; typecheck:core clean; file-size/complexity/cognitive-complexity/changelog gates all green). Merges clean against the current release tip with zero conflicts. Great refactor — extracting persistCodexQuotaState out of chatCore.ts into a proper codexAccount/ module with virtual quota pool isolation is a solid improvement. Thanks!
2026-08-20 09:46:13 -03:00

24 lines
882 B
TypeScript

import { getCodexModelScope, type CodexQuotaScope } from "../../config/codexQuotaScopes.ts";
import { updateCodexScopeCooldown } from "@/lib/db/providers";
export interface PersistCodexChildCooldownResult {
readonly scope: CodexQuotaScope;
readonly providerSpecificData: Record<string, unknown>;
}
/** Persist one virtual child's cooldown without mutating parent-level health state. */
export async function persistCodexChildCooldown(params: {
connectionId: string;
model: string;
rateLimitedUntil: string;
}): Promise<PersistCodexChildCooldownResult | null> {
if (params.model.trim().length === 0) return null;
const scope = getCodexModelScope(params.model);
const providerSpecificData = await updateCodexScopeCooldown(
params.connectionId,
scope,
params.rateLimitedUntil
);
return providerSpecificData ? { scope, providerSpecificData } : null;
}