mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-22 15:12:23 +03:00
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!
24 lines
882 B
TypeScript
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;
|
|
}
|