Selective fixes from PR #35: Model-specific rate limits & robustness improvements (#37)

* feat: apply local user changes and fixes

* ;D

* Implement OpenAI support, model-specific rate limiting, and robustness fixes

* docs: update pr title

* feat: ensure unique openai models endpoint

* fix: startup banner alignment and removed duplicates

* feat: add model fallback system with --fallback flag

* fix: accounts cli hanging after completion

* feat: add exit option to accounts cli menu

* fix: remove circular dependency warning for fallback flag

* feat: show active modes in banner and hide their flags

* Remove OpenAI compatibility and fallback features from PR #35

Cherry-picked selective fixes from PR #35 while removing:
- OpenAI-compatible API endpoints (/openai/v1/*)
- Model fallback system (fallback-config.js)
- Thinking block skip for Gemini models
- Unnecessary files (pullrequest.md, test-fix.js, test-openai.js)

Retained improvements:
- Network error handling with retry logic
- Model-specific rate limiting
- Enhanced health check with quota info
- CLI fixes (exit option, process.exit)
- Startup banner alignment (debug mode only)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* banner alignment fix

* Refactor: Model-specific rate limits and cleanup deprecated code

- Remove global rate limit fields (isRateLimited, rateLimitResetTime) in favor of model-specific limits (modelRateLimits[modelId])
- Remove deprecated wrapper functions (is429Error, isAuthInvalidError) from handlers
- Filter fetchAvailableModels to only return Claude and Gemini models
- Fix getCurrentStickyAccount() to pass model param after waiting
- Update /account-limits endpoint to show model-specific limits
- Remove multi-account OAuth flow to avoid state mismatch errors

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* fix: show (x/y) limited status in account-limits table

- Status is now "ok" only when all models are available
- Shows "(x/y) limited" when x out of y models are exhausted
- Provides better visibility into partial rate limiting

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

* docs: update CLAUDE.md with model-specific rate limiting

- Document modelRateLimits[modelId] for per-model rate tracking
- Add isNetworkError() helper to utilities section

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

---------

Co-authored-by: M1noa <minoa@minoa.cat>
Co-authored-by: Minoa <altgithub@minoa.cat>
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Badri Narayanan S
2026-01-03 15:33:49 +05:30
committed by GitHub
parent 2d05dd5b62
commit 9c4a712a9a
15 changed files with 474 additions and 194 deletions

View File

@@ -30,29 +30,47 @@ app.listen(PORT, () => {
// Clear console for a clean start
console.clear();
const border = '║';
// align for 2-space indent (60 chars), align4 for 4-space indent (58 chars)
const align = (text) => text + ' '.repeat(Math.max(0, 60 - text.length));
const align4 = (text) => text + ' '.repeat(Math.max(0, 58 - text.length));
// Build Control section dynamically
let controlSection = '║ Control: ║\n';
if (!isDebug) {
controlSection += '║ --debug Enable debug logging ║\n';
}
controlSection += '║ Ctrl+C Stop server ║';
// Build status section if debug mode is active
let statusSection = '';
if (isDebug) {
statusSection = '║ ║\n';
statusSection += '║ Active Modes: ║\n';
statusSection += '║ ✓ Debug mode enabled ║\n';
}
logger.log(`
╔══════════════════════════════════════════════════════════════╗
║ Antigravity Claude Proxy Server ║
╠══════════════════════════════════════════════════════════════╣
║ ║
Server running at: http://localhost:${PORT}
║ ║
║ Control: ║
║ --debug Enable debug logging ║
║ Ctrl+C Stop server ║
${border} ${align(`Server running at: http://localhost:${PORT}`)}${border}
${statusSection}║ ║
${controlSection}
║ ║
║ Endpoints: ║
║ POST /v1/messages - Anthropic Messages API
║ GET /v1/models - List available models
║ GET /health - Health check
║ GET /account-limits - Account status & quotas
║ POST /refresh-token - Force token refresh
║ POST /v1/messages - Anthropic Messages API ║
║ GET /v1/models - List available models ║
║ GET /health - Health check ║
║ GET /account-limits - Account status & quotas ║
║ POST /refresh-token - Force token refresh ║
║ ║
║ Configuration: ║
║ Storage: ${CONFIG_DIR}
${border} ${align(`Configuration:`)}${border}
${border} ${align4(`Storage: ${CONFIG_DIR}`)}${border}
║ ║
║ Usage with Claude Code: ║
export ANTHROPIC_BASE_URL=http://localhost:${PORT}
${border} ${align4(`export ANTHROPIC_BASE_URL=http://localhost:${PORT}`)}${border}
║ export ANTHROPIC_API_KEY=dummy ║
║ claude ║
║ ║