Files
antigravity-claude-proxy/public/js/translations/en.js
Badri Narayanan S 5a85f0cfcc feat: comprehensive rate limit handling overhaul (inspired by opencode-antigravity-auth)
This commit addresses "Max retries exceeded" errors during stress testing where
all accounts would become exhausted simultaneously due to short per-second rate
limits triggering cascading failures.

## Rate Limit Parser (`rate-limit-parser.js`)
- Remove 2s buffer enforcement that caused cascading failures when API returned
  short reset times (200-600ms). Now adds 200ms buffer for sub-500ms resets
- Add `parseRateLimitReason()` for smart backoff based on error type:
  QUOTA_EXHAUSTED, RATE_LIMIT_EXCEEDED, MODEL_CAPACITY_EXHAUSTED, SERVER_ERROR

## Message/Streaming Handlers
- Add per-account+model rate limit state tracking with exponential backoff
- For short rate limits (< 1 second), wait and retry on same account instead
  of switching - prevents thundering herd when all accounts hit per-second limits
- Add throttle wait support for fallback modes (emergency/lastResort)
- Add `calculateSmartBackoff()` with progressive tiers by error type

## HybridStrategy (`hybrid-strategy.js`)
- Refactor `#getCandidates()` to return 4 fallback levels:
  - `normal`: All filters pass (health, tokens, quota)
  - `quota`: Bypass critical quota check
  - `emergency`: Bypass health check when ALL accounts unhealthy
  - `lastResort`: Bypass BOTH health AND token bucket checks
- Add throttle wait times: 500ms for lastResort, 250ms for emergency
- Fix LRU calculation to use seconds (matches opencode-antigravity-auth)

## Health Tracker
- Increase `recoveryPerHour` from 2 to 10 for faster recovery (1 hour vs 5 hours)

## Account Manager
- Add consecutive failure tracking: `getConsecutiveFailures()`,
  `incrementConsecutiveFailures()`, `resetConsecutiveFailures()`
- Add cooldown mechanism separate from rate limits with `CooldownReason`
- Reset consecutive failures on successful request

## Base Strategy
- Add `isAccountCoolingDown()` check in `isAccountUsable()`

## Constants
- Replace fixed `CAPACITY_RETRY_DELAY_MS` with progressive `CAPACITY_BACKOFF_TIERS_MS`
- Add `BACKOFF_BY_ERROR_TYPE` for smart backoff
- Add `QUOTA_EXHAUSTED_BACKOFF_TIERS_MS` for progressive quota backoff
- Add `MIN_BACKOFF_MS` floor to prevent "Available in 0s" loops
- Increase `MAX_CAPACITY_RETRIES` from 3 to 5
- Reduce `RATE_LIMIT_DEDUP_WINDOW_MS` from 5s to 2s

## Frontend
- Remove `capacityRetryDelayMs` config (replaced by progressive tiers)
- Update default `maxCapacityRetries` display from 3 to 5

## Testing
- Add `tests/stress-test.cjs` for concurrent request stress testing

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-24 22:43:53 +05:30

368 lines
16 KiB
JavaScript

/**
* English Translations
*/
window.translations = window.translations || {};
window.translations.en = {
dashboard: "Dashboard",
models: "Models",
accounts: "Accounts",
logs: "Logs",
settings: "Settings",
online: "ONLINE",
offline: "OFFLINE",
totalAccounts: "TOTAL ACCOUNTS",
active: "ACTIVE",
operational: "Operational",
rateLimited: "RATE LIMITED",
quotasDepleted: "{count}/{total} Quotas Depleted",
quotasDepletedTitle: "QUOTAS DEPLETED",
outOfTracked: "Out of {total} Tracked",
cooldown: "Cooldown",
searchPlaceholder: "Search models...",
allAccounts: "All Accounts",
stat: "STAT",
modelIdentity: "MODEL IDENTITY",
globalQuota: "GLOBAL QUOTA",
nextReset: "NEXT RESET",
distribution: "ACCOUNT DISTRIBUTION",
systemConfig: "System Configuration",
language: "Language",
pollingInterval: "Polling Interval",
maxDisplayLogs: "Max Displayed Logs",
showExhausted: "Show Exhausted Models",
showExhaustedDesc: "Display models even if they have 0% remaining quota.",
compactMode: "Compact Mode",
compactModeDesc: "Reduce padding in tables for higher information density.",
saveChanges: "Save Changes",
autoScroll: "Auto-scroll",
clearLogs: "Clear Logs",
accountManagement: "Account Management",
manageTokens: "Manage Google Account tokens and authorization states",
addAccount: "Add Account",
status: "STATUS",
enabled: "ENABLED",
health: "STATUS",
accountEmail: "ACCOUNT (EMAIL)",
source: "SOURCE",
projectId: "PROJECT ID",
sessionState: "SESSION STATE",
operations: "OPERATIONS",
delete: "Delete",
fix: "Fix",
confirmDelete: "Are you sure you want to remove this account?",
cannotDeleteDatabase: "Cannot delete: This account is from Antigravity database (read-only)",
connectGoogle: "Connect Google Account",
reauthenticated: "re-authenticated",
added: "added",
successfully: "successfully",
accountAddedSuccess: "Account added successfully",
accountReauthSuccess: "Account re-authenticated successfully",
failedToGetAuthUrl: "Failed to get auth URL",
failedToStartOAuth: "Failed to start OAuth flow",
oauthInProgress: "OAuth in progress. Please complete authentication in the popup window...",
family: "Family",
model: "Model",
activeSuffix: "Active",
// Tabs
tabInterface: "Interface",
tabClaude: "Claude CLI",
tabModels: "Models",
tabServer: "Server Settings",
// Dashboard
linkedAccounts: "Linked Accounts",
noSignal: "NO SIGNAL DETECTED",
establishingUplink: "ESTABLISHING UPLINK...",
goToAccounts: "Go to Accounts",
// Settings - Models
modelsDesc: "Configure model visibility, pinning, and request routing.",
modelsPageDesc: "Real-time quota and status for all available models.",
showHidden: "Show Hidden Models",
hideHidden: "Hide Hidden Models",
hiddenOn: "Hidden: ON",
hiddenOff: "Hidden: OFF",
modelId: "Model ID",
actions: "Actions",
pinToTop: "Pin to top",
toggleVisibility: "Toggle Visibility",
noModels: "NO MODELS DETECTED",
modelMappingHint: "Server-side model routing. Claude Code users: see 'Claude CLI' tab for client-side setup.",
modelMapping: "Mapping (Target Model ID)",
// Settings - Claude
proxyConnection: "Proxy Connection",
modelSelection: "Model Selection",
defaultModelAliases: "DEFAULT MODEL ALIASES",
opusAlias: "Opus Alias",
sonnetAlias: "Sonnet Alias",
haikuAlias: "Haiku Alias",
claudeSettingsAlertPrefix: "Settings below directly modify",
claudeSettingsAlertSuffix: "Restart Claude CLI to apply.",
applyToClaude: "Apply to Claude CLI",
// Presets
configPresets: "Configuration Presets",
saveAsPreset: "Save as Preset",
deletePreset: "Delete Preset",
loadPreset: "Load preset into form",
load: "Load",
presetHint: "Select a preset to load it. Click \"Apply to Claude CLI\" to save changes.",
presetLoaded: "Preset loaded. Click \"Apply to Claude CLI\" to save.",
presetSaved: "Preset saved",
presetDeleted: "Preset deleted",
unsavedChangesTitle: "Unsaved Changes",
unsavedChangesMessage: "Your current configuration doesn't match any saved preset. If you switch, your current unsaved settings will be lost.",
loadAnyway: "Load Anyway",
savePresetTitle: "Save Preset",
savePresetDesc: "Save the current configuration as a reusable preset.",
presetName: "Preset Name",
presetNamePlaceholder: "e.g., My Work Setup",
savePreset: "Save Preset",
// Settings - Server
port: "Port",
uiVersion: "UI Version",
debugMode: "Debug Mode",
environment: "Environment",
serverReadOnly: "Settings managed via config.json. Restart server to apply changes.",
advancedSettings: "Advanced Settings",
reloadConfigTitle: "Reload Account Config",
reloadConfigDesc: "Force reload accounts.json from disk",
reload: "Reload",
// Config Specific
primaryModel: "Primary Model",
subAgentModel: "Sub-agent Model",
advancedOverrides: "Default Model Overrides",
opusModel: "Opus Model",
sonnetModel: "Sonnet Model",
haikuModel: "Haiku Model",
authToken: "Auth Token",
saveConfig: "Save to Claude CLI settings",
envVar: "Env",
// New Keys
systemName: "ANTIGRAVITY",
systemDesc: "CLAUDE PROXY SYSTEM",
connectGoogleDesc: "Connect a Google Workspace account to increase your API quota limit. The account will be used to proxy Claude requests via Antigravity.",
useCliCommand: "Use CLI Command",
close: "Close",
requestVolume: "Request Volume",
filter: "Filter",
all: "All",
none: "None",
noDataTracked: "No data tracked yet",
selectFamilies: "Select families to display",
selectModels: "Select models to display",
noLogsMatch: "No logs match filter",
connecting: "CONNECTING",
main: "Main",
system: "System",
refreshData: "Refresh Data",
connectionLost: "Connection Lost",
lastUpdated: "Last Updated",
grepLogs: "grep logs...",
noMatchingModels: "No matching models",
typeToSearch: "Type to search or select...",
or: "OR",
refreshingAccount: "Refreshing {email}...",
refreshedAccount: "Refreshed {email}",
refreshFailed: "Refresh failed",
accountToggled: "Account {email} {status}",
toggleFailed: "Toggle failed",
reauthenticating: "Re-authenticating {email}...",
authUrlFailed: "Failed to get auth URL",
deletedAccount: "Deleted {email}",
deleteFailed: "Delete failed",
accountsReloaded: "Accounts reloaded",
reloadFailed: "Reload failed",
claudeConfigSaved: "Claude configuration saved",
claudeConfigRestored: "Claude CLI restored to defaults",
saveConfigFailed: "Failed to save configuration",
restoreConfigFailed: "Failed to restore configuration",
restoreDefault: "Restore Default",
confirmRestoreTitle: "Confirm Restore",
confirmRestoreMessage: "Are you sure you want to restore Claude CLI to default settings? This will remove proxy configuration.",
confirmRestore: "Confirm Restore",
claudeActive: "Claude Active",
claudeEmpty: "Claude Empty",
geminiActive: "Gemini Active",
geminiEmpty: "Gemini Empty",
synced: "SYNCED",
syncing: "SYNCING...",
// Time range labels
last1Hour: "Last 1H",
last6Hours: "Last 6H",
last24Hours: "Last 24H",
last7Days: "Last 7D",
allTime: "All Time",
groupBy: "Group By",
// Additional
reloading: "Reloading...",
reloaded: "Reloaded",
lines: "lines",
enabledSeeLogs: "Enabled (See Logs)",
production: "Production",
configSaved: "Configuration Saved",
enterPassword: "Enter Web UI Password:",
ready: "READY",
depleted: "Depleted",
timeH: "H",
timeM: "M",
familyClaude: "Claude",
familyGemini: "Gemini",
familyOther: "Other",
enabledStatus: "enabled",
disabledStatus: "disabled",
logLevelInfo: "INFO",
logLevelSuccess: "SUCCESS",
logLevelWarn: "WARN",
logLevelError: "ERR",
totalColon: "Total:",
todayColon: "Today:",
hour1Colon: "1H:",
frequentModels: "Frequent",
smartTitle: "Auto-select top 5 most used models (24h)",
activeCount: "{count} Active",
allCaps: "ALL",
claudeCaps: "CLAUDE",
geminiCaps: "GEMINI",
modelMapping: "Mapping (Target Model ID)",
systemInfo: "System Information",
refresh: "Refresh",
runtimeConfig: "Runtime Configuration",
debugDesc: "Enable detailed logging (See Logs tab)",
networkRetry: "Network Retry Settings",
maxRetries: "Max Retries",
retryBaseDelay: "Retry Base Delay (ms)",
retryMaxDelay: "Retry Max Delay (ms)",
persistentSessions: "Persistent Sessions",
persistTokenDesc: "Save OAuth sessions to disk for faster restarts",
rateLimiting: "Account Rate Limiting & Timeouts",
defaultCooldown: "Default Cooldown",
defaultCooldownDesc: "Fallback cooldown when API doesn't provide a reset time.",
maxWaitThreshold: "Max Wait Before Error",
maxWaitDesc: "If all accounts are rate-limited longer than this, error immediately instead of waiting.",
// Error Handling Tuning
errorHandlingTuning: "Error Handling Tuning",
rateLimitDedupWindow: "Rate Limit Dedup Window",
rateLimitDedupWindowDesc: "Prevents concurrent retry storms when multiple requests hit rate limits simultaneously.",
maxConsecutiveFailures: "Max Consecutive Failures",
maxConsecutiveFailuresDesc: "Number of consecutive failures before applying extended cooldown to an account.",
extendedCooldown: "Extended Cooldown",
extendedCooldownDesc: "Cooldown duration applied after max consecutive failures reached.",
maxCapacityRetries: "Max Capacity Retries",
maxCapacityRetriesDesc: "Maximum retries for capacity exhaustion before switching accounts.",
saveConfigServer: "Save Configuration",
serverRestartAlert: "Changes saved to {path}. Restart server to apply some settings.",
changePassword: "Change WebUI Password",
changePasswordDesc: "Update the password for accessing this dashboard",
currentPassword: "Current Password",
newPassword: "New Password",
confirmNewPassword: "Confirm New Password",
passwordEmptyDesc: "Leave empty if no password set",
passwordLengthDesc: "At least 6 characters",
passwordConfirmDesc: "Re-enter new password",
cancel: "Cancel",
passwordsNotMatch: "Passwords do not match",
passwordTooShort: "Password must be at least 6 characters",
// Dashboard drill-down
clickToViewAllAccounts: "Click to view all accounts",
clickToViewModels: "Click to view Models page",
clickToViewLimitedAccounts: "Click to view rate-limited accounts",
clickToFilterClaude: "Click to filter Claude models",
clickToFilterGemini: "Click to filter Gemini models",
// Accounts page
searchAccounts: "Search accounts...",
noAccountsYet: "No Accounts Yet",
noAccountsDesc: "Get started by adding a Google account via OAuth, or use the CLI command to import credentials.",
addFirstAccount: "Add Your First Account",
noSearchResults: "No accounts match your search",
clearSearch: "Clear Search",
disabledAccountsNote: "<strong>Disabled accounts</strong> will not be used for request routing but remain in the configuration. Dashboard statistics only include enabled accounts.",
dangerousOperation: "⚠️ Dangerous Operation",
confirmDeletePrompt: "Are you sure you want to delete account",
deleteWarning: "⚠️ This action cannot be undone. All configuration and historical records will be permanently deleted.",
// OAuth progress
oauthWaiting: "Waiting for OAuth authorization...",
oauthWaitingDesc: "Please complete the authentication in the popup window. This may take up to 2 minutes.",
oauthCancelled: "OAuth authorization cancelled",
oauthTimeout: "⏱️ OAuth authorization timed out. Please try again.",
oauthWindowClosed: "OAuth window was closed. Authorization may be incomplete.",
cancelOAuth: "Cancel",
// MCP CLI & Gemini 1M
mcpCliExperimental: "Experimental MCP CLI",
mcpCliDesc: "Enables experimental MCP integration for reliable tool usage with reduced context consumption.",
gemini1mMode: "Gemini 1M Context Mode",
gemini1mDesc: "Appends [1m] suffix to Gemini models for 1M context window support.",
gemini1mWarning: "⚠ Large context may reduce Gemini-3-Pro performance.",
clickToSet: "Click to configure...",
none: "None",
// Quota Distribution
quotaDistribution: "Quota Distribution",
resetsIn: "Resets in {time}",
noQuotaData: "No quota data available for this account yet.",
// Manual OAuth Mode
manualMode: "Manual Mode",
manualModeDesc: "(for environments where callback cannot reach)",
authLinkLabel: "Authorization Link:",
linkCopied: "Link copied to clipboard",
pasteCallbackLabel: "Paste callback URL or code:",
pasteCallbackPlaceholder: "http://localhost:51121/oauth-callback?code=... or 4/0xxx...",
completeAuth: "Complete Authorization",
authFailed: "Authorization failed",
// Import/Export
export: "Export",
import: "Import",
exportAccounts: "Export Accounts",
importAccounts: "Import Accounts",
exportSuccess: "Exported {count} accounts",
exportFailed: "Export failed",
importSuccess: "Import complete:",
importFailed: "Import failed",
// UI Elements
pageTitle: "Antigravity Console",
live: "Live",
tier: "Tier",
quota: "Quota",
tierUltra: "Ultra",
tierPro: "Pro",
tierFree: "Free",
menu: "Menu",
github: "GitHub",
noData: "No data",
// Error Messages
operationFailed: "Operation failed",
unknownError: "Unknown error",
presetNameRequired: "Preset name is required",
saveFailed: "Save failed",
failedToSavePreset: "Failed to save preset",
noPresetSelected: "No preset selected",
deletePresetConfirm: "Delete preset \"{name}\"?",
failedToDeletePreset: "Failed to delete preset",
failedToChangePassword: "Failed to change password",
passwordChangedSuccess: "Password changed successfully",
debugModeToggled: "Debug mode {status}",
tokenCacheToggled: "Token cache {status}",
failedToUpdateTokenCache: "Failed to update token cache",
failedToUpdateDebugMode: "Failed to update debug mode",
failedToRefreshAccount: "Failed to refresh account",
failedToDeleteAccount: "Failed to delete account",
failedToReloadAccounts: "Failed to reload accounts",
failedToUpdateModelConfig: "Failed to update model config",
fieldUpdated: "{displayName} updated to {value}",
failedToUpdateField: "Failed to update {displayName}",
// Account Selection Strategy
accountSelectionStrategy: "Account Selection Strategy",
selectionStrategy: "Selection Strategy",
strategyStickyLabel: "Sticky (Cache Optimized)",
strategyRoundRobinLabel: "Round Robin (Load Balanced)",
strategyHybridLabel: "Hybrid (Smart Distribution)",
strategyStickyDesc: "Stays on same account until rate-limited. Best for prompt caching.",
strategyRoundRobinDesc: "Rotates to next account on every request. Maximum throughput.",
strategyHybridDesc: "Smart selection based on health, tokens, and freshness.",
strategyUpdated: "Strategy updated to: {strategy}",
failedToUpdateStrategy: "Failed to update strategy",
invalidStrategy: "Invalid strategy selected",
// Validation Messages
mustBeValidNumber: "{fieldName} must be a valid number",
mustBeAtLeast: "{fieldName} must be at least {min}",
mustBeAtMost: "{fieldName} must be at most {max}",
cannotBeEmpty: "{fieldName} cannot be empty",
mustBeTrueOrFalse: "Value must be true or false",
};