Improve logging, rate limiting, and error handling (#29)

* feat: apply local user changes and fixes

* ;D

* Clean up PR #28: Remove duplicate code lines and unnecessary file

- Remove pullrequest.md (PR notes file not needed in repo)
- Fix duplicate lines in account-manager.js:
  - rateLimitResetTime assignment
  - saveToDisk() calls in markRateLimited and markInvalid
  - invalidReason/invalidAt assignments
  - double return statement in discoverProject

Original PR by M2noa: fix sticky accs, 500s, logging updates, and rate limit handling

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

Co-Authored-By: M2noa <226494568+M2noa@users.noreply.github.com>
Co-Authored-By: Claude <noreply@anthropic.com>

* chore: replace console.log with logger methods for consistency

- Replace all console.log calls with logger.warn/debug in:
  - src/cloudcode-client.js (4 places)
  - src/format/thinking-utils.js (7 places)

This ensures consistent logging behavior with the new logger utility,
respecting --debug mode for verbose output.

🤖 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: M2noa <226494568+M2noa@users.noreply.github.com>
Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Badri Narayanan S
2026-01-01 14:35:06 +05:30
committed by GitHub
parent d05fb64e29
commit 1d91bc0d30
11 changed files with 351 additions and 108 deletions

View File

@@ -5,26 +5,54 @@
import app from './server.js';
import { DEFAULT_PORT } from './constants.js';
import { logger } from './utils/logger.js';
import path from 'path';
import os from 'os';
// Parse command line arguments
const args = process.argv.slice(2);
const isDebug = args.includes('--debug') || process.env.DEBUG === 'true';
// Initialize logger
logger.setDebug(isDebug);
if (isDebug) {
logger.debug('Debug mode enabled');
}
const PORT = process.env.PORT || DEFAULT_PORT;
// Home directory for account storage
const HOME_DIR = os.homedir();
const CONFIG_DIR = path.join(HOME_DIR, '.antigravity-claude-proxy');
app.listen(PORT, () => {
console.log(`
// Clear console for a clean start
console.clear();
logger.log(`
╔══════════════════════════════════════════════════════════════╗
║ Antigravity Claude Proxy Server ║
╠══════════════════════════════════════════════════════════════╣
║ ║
║ Server running at: http://localhost:${PORT}
║ Server running at: http://localhost:${PORT}
║ ║
║ Control: ║
║ --debug Enable debug logging ║
║ Ctrl+C Stop server ║
║ ║
║ Endpoints: ║
║ POST /v1/messages - Anthropic Messages API ║
║ GET /v1/models - List available models ║
║ GET /health - Health check ║
║ GET /account-limits - Account status & quotas
║ GET /account-limits - Account status & quotas ║
║ POST /refresh-token - Force token refresh ║
║ ║
║ Configuration: ║
║ Storage: ${CONFIG_DIR}
║ ║
║ Usage with Claude Code: ║
║ export ANTHROPIC_BASE_URL=http://localhost:${PORT}
║ export ANTHROPIC_BASE_URL=http://localhost:${PORT}
║ export ANTHROPIC_API_KEY=dummy ║
║ claude ║
║ ║
@@ -37,4 +65,9 @@ app.listen(PORT, () => {
║ ║
╚══════════════════════════════════════════════════════════════╝
`);
logger.success(`Server started successfully on port ${PORT}`);
if (isDebug) {
logger.warn('Running in DEBUG mode - verbose logs enabled');
}
});