Commit Graph

34 Commits

Author SHA1 Message Date
Badri Narayanan S
ac9ec6b358 Signature handling for fallback 2026-01-03 22:01:57 +05:30
Badri Narayanan S
df6625b531 fallback changes from PR #35 2026-01-03 18:01:21 +05:30
Badri Narayanan S
9c4a712a9a 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>
2026-01-03 15:33:49 +05:30
Badri Narayanan S
2d05dd5b62 Fix: Reset invalid accounts on startup and improve project discovery logging
Fixes #33 - Accounts marked as invalid were permanently stuck because
the isInvalid flag was persisted to disk but never reset on startup.

Changes:
- Reset isInvalid flag for all accounts on server startup, giving them
  a fresh chance to refresh their OAuth tokens
- Add logging for project discovery failures (was silently failing)
- Add success logging when project is discovered
- Add warning message when falling back to default project

Bug introduced in 01cda83 (2025-12-25) when isInvalid persistence was
added without corresponding reset logic on load.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-02 12:34:35 +05:30
Badri Narayanan S
77089e0360 Fix issue where Antigravity auth is not working 2026-01-02 11:47:54 +05:30
Badri Narayanan S
f02364d4ef refactor: Reorganize src/ into modular folder structure
Split large monolithic files into focused modules:
- cloudcode-client.js (1,107 lines) → src/cloudcode/ (9 files)
- account-manager.js (639 lines) → src/account-manager/ (5 files)
- Move auth files to src/auth/ (oauth, token-extractor, database)
- Move CLI to src/cli/accounts.js

Update all import paths and documentation.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-01 15:13:43 +05:30
Badri Narayanan S
1d91bc0d30 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>
2026-01-01 14:35:06 +05:30
Badri Narayanan S
d05fb64e29 Fix: Add Windows support for SQLite database access (Issue #23)
Replace CLI-based sqlite3 extraction with better-sqlite3 library:
- Create shared src/db/database.js module for cross-platform SQLite access
- Remove duplicate extractTokenFromDB functions from token-extractor.js and account-manager.js
- Add better-sqlite3 dependency with prebuilt Windows/Mac/Linux binaries
- Improve error handling with specific messages for common issues

Fixes #23

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-30 18:47:05 +05:30
Badri Narayanan S
ead7632eec Fix: Read Image tool not working 2025-12-30 17:01:01 +05:30
gwizz
306a8891c8 Add count_tokens stub endpoint 2025-12-29 10:57:47 +11:00
Badri Narayanan S
426acc494a Implement Gemini signature caching and thinking recovery
- Add in-memory signature cache to restore thoughtSignatures stripped by Claude Code
- Implement thinking recovery logic to handle interrupted tool loops for Gemini
- Enhance schema sanitizer to preserve constraints and enums as description hints
- Update CLAUDE.md with new architecture details

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-28 14:34:03 +05:30
Badri Narayanan S
1eb2329f7c Gemini schema fix and modularize format converter 2025-12-28 03:28:05 +05:30
Badri Narayanan S
c1e1dbb0ef Added support for Gemini models 2025-12-27 14:09:20 +05:30
Badri Narayanan S
9b7dcf3a6c removing restcting of available models, fixing max tokens issues in test 2025-12-27 12:17:45 +05:30
Badri Narayanan S
07a09c1cb9 fallback to load antigravity default account, even if config file exists but with no accounts 2025-12-26 14:54:43 +05:30
Badri Narayanan S
b8677c9f6b feat: show remaining time for rate-limited accounts
Display rate limit remaining duration in Status column (e.g., "limited (1h23m45s)") instead of just "rate-limited"

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-25 22:00:48 +05:30
Badri Narayanan S
9b0b756e72 feat: consolidate /accounts into /account-limits endpoint
- Remove redundant /accounts endpoint
- Enhance /account-limits table output with account status, last used time, and quota reset time
- Filter model list to show only Claude models
- Use local time format for timestamps
- Update documentation (README.md, CLAUDE.md, index.js)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-25 21:55:03 +05:30
Badri Narayanan S
ed6bd3af2b fix oauth redirect URI not imported 2025-12-25 16:10:11 +05:30
Badri Narayanan S
e55d3ccb20 Merge pull request #1 from 0FL01/linux-support
Add Linux support with cross-platform database path detection
2025-12-25 14:04:25 +05:30
Badri Narayanan S
21f923b4ec docs: replace round-robin references with sticky selection
The account selection is now sticky (stays on same account for cache
continuity), not round-robin. Updated comments and docs to reflect this.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-25 13:37:20 +05:30
Badri Narayanan S
01cda835d9 feat: add prompt caching, sticky account selection, and non-thinking model
- Implement sticky account selection for prompt cache continuity
- Derive stable session ID from first user message (SHA256 hash)
- Return cache_read_input_tokens in usage metadata
- Add claude-sonnet-4-5 model without thinking
- Remove DEFAULT_THINKING_BUDGET (let API use its default)
- Add prompt caching test
- Update README and CLAUDE.md documentation

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-25 13:26:48 +05:30
Andrey Bash
a777f37c3f Add Linux support with cross-platform database path detection
- Add platform-specific database path detection for macOS, Windows, and Linux
- Make User-Agent header dynamic based on current OS and architecture
- Maintain backward compatibility with existing macOS installations
- Tested on Linux: server now correctly finds ~/.config/Antigravity database
2025-12-25 09:35:21 +03:00
Badri Narayanan S
943a4dcb20 Verbose message logging only when debug = true 2025-12-24 20:31:39 +05:30
Badri Narayanan S
0edc718672 refactor: centralize constants, add error classes, and DRY test utilities
- Create src/errors.js with custom error classes (RateLimitError, AuthError, ApiError, etc.)
- Create src/utils/helpers.js with shared utilities (formatDuration, sleep)
- Create tests/helpers/http-client.cjs with shared test utilities (~250 lines deduped)
- Centralize OAuth config and other constants in src/constants.js
- Add JSDoc types to all major exported functions
- Refactor all test files to use shared http-client utilities
- Update CLAUDE.md with new architecture documentation

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-24 18:11:45 +05:30
Badri Narayanan S
712da8f7f2 code quality improvements and refactoring 2025-12-21 22:11:44 +05:30
Badri Narayanan S
f282b36d1e code cleanup and test fix 2025-12-21 20:25:20 +05:30
Badri Narayanan S
c703fb32fb fix where models didnt wait if retrydelay is less than 2 mins for multi account scenario 2025-12-21 19:57:50 +05:30
Badri Narayanan S
8eead9660c reset rate limits in cache only when all accounts are rate limited 2025-12-21 15:43:51 +05:30
Badri Narayanan S
9a35845ceb add ability to remove accounts. ensure accounts are not / added / removed when server is running 2025-12-21 15:05:45 +05:30
Badri Narayanan S
95c08f9d55 handle rate limits gracefully, and add ability to check google server for every request in case they reset rate limits on their end, thereby not relying on local cache alone 2025-12-21 14:49:57 +05:30
Badri Narayanan S
f625377bdf thinking sanitization 2025-12-19 22:41:01 +05:30
Badri Narayanan S
da48b9898b sanitize thinking blocks 2025-12-19 22:02:18 +05:30
Badri Narayanan S
5ae29947b1 initial commit 2025-12-19 19:20:28 +05:30
Badri Narayanan S
52d72b7bff initial commit 2025-12-18 00:06:00 +05:30