Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

882 B
Raw Blame
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;
}