feat: add official subscription quota display for Codex

Read Codex OAuth credentials from ~/.codex/auth.json (with macOS
Keychain fallback) and query chatgpt.com/backend-api/wham/usage to
show rate limit utilization on official Codex provider cards. Reuses
the same tier naming (five_hour, seven_day) for frontend i18n compat.
This commit is contained in:
Jason
2026-04-04 17:47:16 +08:00
parent b30f3c27ad
commit 0200fe79ae
2 changed files with 339 additions and 6 deletions
+12 -5
View File
@@ -56,12 +56,19 @@ interface ProviderCardProps {
onSetAsDefault?: () => void;
}
/** 判断是否为官方供应商(无自定义 base URL,直连官方 API */
/** 判断是否为官方供应商(无自定义 base URL / API key,直连官方 API */
function isOfficialProvider(provider: Provider, appId: AppId): boolean {
if (appId !== "claude") return false;
const baseUrl = (provider.settingsConfig as Record<string, any>)?.env
?.ANTHROPIC_BASE_URL;
return !baseUrl || (typeof baseUrl === "string" && baseUrl.trim() === "");
const config = provider.settingsConfig as Record<string, any>;
if (appId === "claude") {
const baseUrl = config?.env?.ANTHROPIC_BASE_URL;
return !baseUrl || (typeof baseUrl === "string" && baseUrl.trim() === "");
}
if (appId === "codex") {
// 无 OPENAI_API_KEY → 使用 Codex CLI 内置 OAuth(官方)
const apiKey = config?.auth?.OPENAI_API_KEY;
return !apiKey || (typeof apiKey === "string" && apiKey.trim() === "");
}
return false;
}
const extractApiUrl = (provider: Provider, fallbackText: string) => {