mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-11-29 10:43:47 +00:00
Ports the menubar's Kimi flow to the Electron quota module: read-only ~/.kimi-code/credentials (KIMI_CODE_HOME honored), api.kimi.com usages snapshot, terminal expired-login state that never refreshes the CLI's short-lived token, 5-hour/weekly window mapping with over-limit clamp, membership plan label, and the standard per-provider Settings toggle.
41 lines
1.4 KiB
TypeScript
41 lines
1.4 KiB
TypeScript
import type { ProviderName } from './types'
|
|
|
|
export const PROVIDER_NAMES: Record<ProviderName, string> = {
|
|
claude: 'Claude',
|
|
codex: 'Codex',
|
|
gemini: 'Gemini',
|
|
copilot: 'Copilot',
|
|
antigravity: 'Antigravity',
|
|
kimi: 'Kimi Code',
|
|
}
|
|
|
|
/** Company named in honest copy like "Anthropic rate limited the quota endpoint". */
|
|
export const PROVIDER_OWNERS: Record<ProviderName, string> = {
|
|
claude: 'Anthropic',
|
|
codex: 'OpenAI',
|
|
gemini: 'Google',
|
|
copilot: 'GitHub',
|
|
antigravity: 'Google',
|
|
kimi: 'Moonshot AI',
|
|
}
|
|
|
|
const ALL_PROVIDERS = Object.keys(PROVIDER_NAMES) as ProviderName[]
|
|
const DISABLED_KEY = 'codeburn.quotaDisabled'
|
|
|
|
/** Display order for quota rows (matches the electron poll order). */
|
|
export const QUOTA_PROVIDERS = Object.keys(PROVIDER_NAMES) as ProviderName[]
|
|
|
|
export function readDisabledProviders(): ProviderName[] {
|
|
try {
|
|
const raw = globalThis.localStorage?.getItem(DISABLED_KEY)
|
|
if (!raw) return []
|
|
const parsed: unknown = JSON.parse(raw)
|
|
return Array.isArray(parsed) ? parsed.filter((p): p is ProviderName => typeof p === 'string' && ALL_PROVIDERS.includes(p as ProviderName)) : []
|
|
} catch {
|
|
return []
|
|
}
|
|
}
|
|
|
|
export function writeDisabledProviders(disabled: ProviderName[]): void {
|
|
try { globalThis.localStorage?.setItem(DISABLED_KEY, JSON.stringify(disabled)) } catch { /* storage can be unavailable in hardened contexts */ }
|
|
}
|