diff --git a/src/cliproxy/auth-utils.ts b/src/cliproxy/auth-utils.ts index e4ba226c..77e371b1 100644 --- a/src/cliproxy/auth-utils.ts +++ b/src/cliproxy/auth-utils.ts @@ -9,7 +9,7 @@ * Replaces @ and . with underscores for filesystem compatibility. */ export function sanitizeEmail(email: string): string { - return email.replace(/@/g, '_').replace(/\\./g, '_'); + return email.replace(/@/g, '_').replace(/\./g, '_'); } /** diff --git a/src/cliproxy/quota-fetcher-gemini-cli.ts b/src/cliproxy/quota-fetcher-gemini-cli.ts index 1eca2583..3abb78d9 100644 --- a/src/cliproxy/quota-fetcher-gemini-cli.ts +++ b/src/cliproxy/quota-fetcher-gemini-cli.ts @@ -16,7 +16,10 @@ import type { GeminiCliQuotaResult, GeminiCliBucket } from './quota-types'; const GEMINI_CLI_API_BASE = 'https://cloudcode-pa.googleapis.com'; const GEMINI_CLI_API_VERSION = 'v1internal'; -/** Model groups for quota consolidation */ +/** + * Model groups for quota consolidation. + * Update when Google releases new Gemini models to include them in quota display. + */ const GEMINI_CLI_GROUPS: Record< string, { diff --git a/src/cliproxy/quota-fetcher.ts b/src/cliproxy/quota-fetcher.ts index e9e7fd81..41203461 100644 --- a/src/cliproxy/quota-fetcher.ts +++ b/src/cliproxy/quota-fetcher.ts @@ -16,6 +16,7 @@ import { type AccountInfo, type AccountTier, } from './account-manager'; +import { sanitizeEmail, isTokenExpired } from './auth-utils'; /** Individual model quota info */ export interface ModelQuota { @@ -154,27 +155,6 @@ interface FetchAvailableModelsResponse { models?: Record; } -/** - * Sanitize email to match CLIProxyAPI auth file naming convention - * Replaces @ and . with underscores (matches Go sanitizeAntigravityFileName) - */ -function sanitizeEmail(email: string): string { - return email.replace(/@/g, '_').replace(/\./g, '_'); -} - -/** - * Check if token is expired based on the expired timestamp - */ -function isTokenExpired(expiredStr?: string): boolean { - if (!expiredStr) return false; - try { - const expiredDate = new Date(expiredStr); - return expiredDate.getTime() < Date.now(); - } catch { - return false; - } -} - /** * Refresh access token using refresh_token via Google OAuth * This allows CCS to get fresh tokens independently of CLIProxyAPI diff --git a/src/cliproxy/quota-types.ts b/src/cliproxy/quota-types.ts index fa4c2277..d888bf6c 100644 --- a/src/cliproxy/quota-types.ts +++ b/src/cliproxy/quota-types.ts @@ -5,8 +5,6 @@ * Supports Antigravity, Codex, and Gemini CLI providers. */ -import type { QuotaResult as AntigravityQuotaResult } from './quota-fetcher'; - /** Supported quota providers */ export type QuotaProvider = 'agy' | 'codex' | 'gemini'; @@ -84,26 +82,3 @@ export interface GeminiCliQuotaResult { /** Account ID (email) this quota belongs to */ accountId?: string; } - -/** - * Unified quota result wrapper for CLI/Dashboard - * Contains provider-specific data in nested fields - */ -export interface UnifiedQuotaResult { - /** Provider this result belongs to */ - provider: QuotaProvider; - /** Whether fetch succeeded */ - success: boolean; - /** Timestamp of fetch */ - lastUpdated: number; - /** Error message if fetch failed */ - error?: string; - /** Account ID (email) this quota belongs to */ - accountId?: string; - /** Antigravity-specific quota data */ - antigravity?: AntigravityQuotaResult; - /** Codex-specific quota data */ - codex?: CodexQuotaResult; - /** Gemini CLI-specific quota data */ - geminiCli?: GeminiCliQuotaResult; -}