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

970 B
Raw Blame
/**
 * Codex subscription plan label (e.g. "Plus", "Pro", "Team"), persisted on the
 * connection's providerSpecificData.chatgptPlanType at OAuth import time (see
 * src/lib/oauth/services/codexImport.ts). Returns "" when the connection is
 * not Codex or the value is missing/blank — callers gate rendering on that.
 *
 * Kept in its own module (not providerPageHelpers.ts) because that file is
 * frozen at its file-size ratchet cap (config/quality/file-size-baseline.json)
 * and this helper is fully self-contained.
 */
export function getCodexPlanLabel(isCodex: boolean, providerSpecificData: unknown): string {
  if (!isCodex) return "";
  const record =
    providerSpecificData && typeof providerSpecificData === "object"
      ? (providerSpecificData as Record<string, unknown>)
      : {};
  const trimmed = (value: unknown) => (typeof value === "string" ? value.trim() : "");
  return trimmed(record.chatgptPlanType) || trimmed(record.workspacePlanType);
}