Commit Graph

136 Commits

Author SHA1 Message Date
jgor20
5879022dc3 fix: use lightweight /api/config for health checks and simplify UI status logic 2026-01-11 09:46:41 +00:00
jgor20
c3629d660c fix(webui): prevent duplicate visibility change listeners in health check
Ensure the visibility change event listener for health checks is set up only once
and properly removed on destroy to avoid memory leaks and duplicate handlers.
2026-01-10 22:58:11 +00:00
jgor20
69440584fd feat(webui): add health check monitoring for connection status
Implement periodic health checks every 15 seconds to monitor connection status,
pausing when the tab is hidden and resuming on visibility. Update UI bindings
to use data store for connection status instead of global store. Add destroy
method to clean up timers on component teardown.
2026-01-10 22:41:15 +00:00
Badri Narayanan S
6868bf217c Merge pull request #47 from Wha1eChai/feature/webui
feat: Add Web UI for account and quota management
2026-01-10 22:21:57 +05:30
Badri Narayanan S
c6edb1e507 Merge pull request #90 from tiagonrodrigues/fix/fallback-on-5xx-errors
feat: fallback to alternate model when max retries exceeded with 5xx errors
2026-01-10 20:23:42 +05:30
Tiago Rodrigues
0b477c2552 feat: fallback to alternate model when max retries exceeded with 5xx errors
When all accounts fail with HTTP 500/503 errors (e.g., Google API returning
'Unknown Error' for Claude models on large conversations), the proxy now
attempts to use a fallback model if --fallback is enabled.

This enables graceful degradation when:
- All accounts are exhausted due to 5xx errors (not just rate limits)
- Claude models fail on very large conversations
- The API has temporary issues with specific models

The fallback uses the existing MODEL_FALLBACK_MAP configuration:
- claude-opus-4-5-thinking -> gemini-3-pro-high
- claude-sonnet-4-5-thinking -> gemini-3-flash

Relates to #88
2026-01-10 12:08:53 +00:00
Wha1eChai
ee6d222e4d feat(webui): add subscription tier and quota visualization
Backend:
2026-01-10 06:05:17 +08:00
Wha1eChai
369a66e8cf Merge branch 'main' into feature/webui 2026-01-10 04:46:30 +08:00
Wha1eChai
71c7c2e423 feat(webui): enhance settings UI, persistence and documentation
- Update CLAUDE.md with comprehensive WebUI architecture and API documentation
- Improve settings UI with searchable model dropdowns and visual family indicators
- Migrate usage statistics persistence to user config directory with auto-migration
- Refactor server request handling and fix model suffix logic
2026-01-10 04:22:59 +08:00
Badri Narayanan S
ce2cb72563 docs: add custom port instructions to README
Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-10 01:13:56 +05:30
Badri Narayanan S
e0e72ec5d2 add schema sanitizer to test suite, fix interleaved thinking test
- Add test-schema-sanitizer.cjs to run-all.cjs test runner
- Add test:sanitizer npm script for running it individually
- Update test to use renamed cleanSchema function
- Fix interleaved thinking test to not require thinking blocks after
  tool result (model decides when to use visible thinking)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-10 00:47:47 +05:30
Badri Narayanan S
f1e945a7e6 change cleanSchemaForGemini to cleanSchema 2026-01-10 00:35:50 +05:30
Badri Narayanan S
e4145ad277 Merge pull request #83 from tiagonrodrigues/fix/issue-82-schema-type-conversion
fix: convert schema types to Google uppercase format (fixes #82)
2026-01-10 00:34:35 +05:30
Tiago Rodrigues
90214c43b0 fix: convert schema types to Google uppercase format (fixes #82)
The /compact command was failing with 'Proto field is not repeating,
cannot start list' error for Claude models because tool schemas were
sent with lowercase JSON Schema types (array, object, string) but
Google's Cloud Code API expects uppercase protobuf types (ARRAY,
OBJECT, STRING).

Changes:
- Add toGoogleType() function to convert JSON Schema types to Google format
- Add Phase 5 to cleanSchemaForGemini() for type conversion
- Apply cleanSchemaForGemini() for ALL models (not just Gemini) since
  all requests go through Cloud Code API which validates schema format
- Add comprehensive test suite with 10 tests covering nested arrays,
  complex schemas, and real-world Claude Code tool scenarios

Fixes #82
2026-01-09 18:36:19 +00:00
Wha1eChai
98685241e8 feat(webui): update README with comprehensive documentation for WebUI features and usage 2026-01-09 23:22:28 +08:00
Wha1eChai
48ad476b5f feat(dashboard): comprehensive filter enhancement and UI layout fixes
- Add time range selector (1H/6H/24H/7D/All) with preference persistence
- Implement smart X-axis label formatting for multi-day usage data
- Standardize global component spacing and fix CSS @apply limitations
- Add elegant empty state UI for charts when filtered data is absent
- Update i18n translations for all new dashboard features
2026-01-09 22:33:11 +08:00
Wha1eChai
40d3d3f3b6 feat(webui): improve UI display logic for models and accounts pages 2026-01-09 21:48:55 +08:00
Wha1eChai
8e221e3fc7 feat(webui): optimize frontend terminology and i18n keys 2026-01-09 19:59:32 +08:00
Badri Narayanan S
348fdc3f94 Merge pull request #75 from ahmed0magdy/main
docs: add instructions for running multiple Claude Code instances
2026-01-09 17:04:58 +05:30
Wha1eChai
07a9586aee feat(webui): add MCP CLI toggle and Gemini [1m] suffix settings
- Add ENABLE_EXPERIMENTAL_MCP_CLI toggle in Claude CLI settings (default: true)

- Add Gemini 1M Context Mode toggle for [1m] suffix (default: true)

- Auto-apply [1m] suffix to existing Gemini model configurations

- Add i18n translations for both features (English and Chinese)
2026-01-09 18:34:24 +08:00
Wha1eChai
169e18402f merge: sync with origin/feature/webui after upstream merge 2026-01-09 18:23:52 +08:00
Wha1eChai
f2f0a7452e merge: integrate upstream/main (v1.2.15) into feature/webui
- Resolved conflict in src/constants.js: kept config-driven approach

- Adopted upstream 10-second cooldown default

- Added MAX_EMPTY_RESPONSE_RETRIES constant from upstream

- Incorporated new test files and GitHub issue templates
2026-01-09 18:08:45 +08:00
Wha1eChai
a914821d49 perf(webui): refactor dashboard modules and optimize API performance 2026-01-09 17:58:09 +08:00
Badri Narayanan S
4c5236d4b3 fix: filter Antigravity system prompt from model responses
- Add [ignore] tags around system instruction to prevent model from
  identifying as "Antigravity" when asked "Who are you?"
- Replace full system instruction with minimal version used by
  CLIProxyAPI/gcli2api to reduce token usage and improve response quality

Fixes #76

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-09 14:10:41 +05:30
Badri Narayanan S
c49d94ae0d chore: add GitHub issue templates for bug reports and feature requests
Adopts issue template pattern from opencode-antigravity-auth:
- Bug report template with [BUG] prefix and 6-item checklist
- Feature request template with [FEATURE] prefix
- Config disables blank issues, adds links to Google Cloud Support, TOS, and Discussions

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-09 13:46:04 +05:30
Wha1eChai
e909ea6fe3 style(webui): refine UI polish and enhance component interactions 2026-01-09 07:54:50 +08:00
Wha1eChai
40a766ded6 feat(webui): Add Models tab and refactor model configuration
- Add standalone Models tab with real-time quota/status display
- Move model identity table from Dashboard to Models tab
- Slim down Dashboard to KPI cards and charts only
- Dashboard charts now use unfiltered data (independent of Models filters)

Settings > Models improvements:
- Remove redundant Alias column (only Mapping is functional)
- Fix column misalignment bug (empty td)
- Add column widths and hidden row opacity styling
- Single row edit constraint (only one Mapping editable at a time)
- showHiddenModels toggle now only affects Settings (not Models tab)
- Update description text to match current functionality

i18n:
- Add 'models' and 'modelsPageDesc' keys (EN/ZH)
- Add 'modelMappingHint' for Claude CLI guidance
- Update 'modelsDesc' to reflect new functionality
2026-01-09 04:39:05 +08:00
Wha1eChai
a4814b8c34 feat(webui): refactor settings architecture and achieve full i18n coverage 2026-01-09 03:04:10 +08:00
ahmed0magdy
e3be630bfb docs: add instructions for running multiple Claude Code instances 2026-01-08 20:41:05 +02:00
Badri Narayanan S
73e5d13f45 Merge pull request #72 from s21v1d9p/fix/optimistic-rate-limit-retry
fix: add optimistic reset for transient 429 rate limit errors
2026-01-08 22:27:01 +05:30
SvDp
45755bfa18 fix: add optimistic reset for transient 429 rate limit errors
Fixes issue #71 - 'No accounts available' error when API returns 429

The Google Cloud Code API can return 429 RESOURCE_EXHAUSTED errors even
when accounts have quota available due to:
- Temporary API load/throttling
- Per-minute request limits (not per-day quota)
- Transient backend issues

This fix adds:
1. A 500ms buffer after waiting for rate limits to expire
2. Optimistic rate limit reset when all accounts appear stuck
3. Retry logic that clears rate limits and tries again

The fix works in conjunction with the server-level optimistic reset
that already exists, providing multiple layers of protection against
false 'No accounts available' errors.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-08 21:31:50 +05:30
Wha1eChai
c9c5e7d486 feat(webui): add hot-reload account management with OAuth support 2026-01-08 23:52:31 +08:00
Badri Narayanan S
5f6ce1b97d Update daily Cloud Code endpoint to production URL
Remove sandbox subdomain from daily-cloudcode-pa endpoint.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-08 20:24:23 +05:30
Wha1eChai
dc9bea1100 feat(webui): comprehensive UI modernization and server configuration enhancements 2026-01-08 22:18:04 +08:00
Wha1eChai
a7aacdb0ae feat(webui): enhance server configuration and dynamic dashboard analytics 2026-01-08 22:15:03 +08:00
Badri Narayanan S
def3d90581 Add [1m] suffix to gemini 2026-01-08 18:30:54 +05:30
Badri Narayanan S
7375a2ef6d chore: add empty response retry test and fix flaky tests
- Add test:emptyretry script and include in test suite
- Fix test-interleaved-thinking: use complex prompt to force thinking
- Fix test-multiturn-thinking-tools: make Turn 2 lenient (thinking optional)
- Fix test-multiturn-thinking-tools-streaming: same lenient approach
- Use TEST_MODELS helper instead of hardcoded model ID

Models may skip thinking on obvious next steps - this is valid behavior.
Tests now only require thinking on first turn to verify signatures work.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-08 17:54:48 +05:30
Badri Narayanan S
a696ed0872 Merge pull request #64 from BrunoMarc/fix/empty-response-retry
fix: add retry mechanism for empty API responses
2026-01-08 17:38:18 +05:30
Badri Narayanan S
040713ed9a Update npx and npm install commands to use @latest
Ensures users always get the latest version when running via npx or global install.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-08 17:13:48 +05:30
Wha1eChai
217053839f feat(webui): Enhance dashboard, global styles, and settings module
## Dashboard Enhancements
- Add Request Volume trend chart with Chart.js line graph
  - Support Family/Model display modes for aggregation levels
  - Show Total/Today/1H usage statistics
  - Hierarchical filter dropdown with Smart select (Top 5 by 24h usage)
  - Persist chart preferences to localStorage
- Improve account health detection logic
  - Core models (sonnet/opus/pro/flash) require >5% quota to be healthy
  - Dynamic quota ring chart supporting any model family
- Unify table styles with standard-table class

## Global Style Refactoring
- Add CSS variable system for theming
  - Space color scale (950/900/850/800/border)
  - Neon accent colors (purple/green/cyan/yellow/red)
  - Text hierarchy (main/dim/muted/bright)
  - Chart palette (16 colors)
- Add unified component classes
  - .view-container for consistent page layouts
  - .section-header/.section-title/.section-desc
  - .standard-table for table styling
- Update scrollbar, nav-item, progress-bar to use theme variables

## Settings Module Extensions
- Add model mapping column in Models tab
- Enhance model selectors with family color indicators
- Support horizontal scroll for tabs on narrow screens
- Add defaultCooldownMs and maxWaitBeforeErrorMs config options

## New Module
- Add src/modules/usage-stats.js for request tracking
  - Track /v1/messages and /v1/chat/completions endpoints
  - Hierarchical storage: { hour: { family: { model: count } } }
  - Auto-save every minute, 30-day retention
  - GET /api/stats/history endpoint for dashboard chart

## Backend Changes
- Add direct account manipulation helpers (bypass AccountManager)
- Add POST /api/config/password endpoint for WebUI password change
- Auto-reload AccountManager after account operations
- Use CSS variables in OAuth callback pages

## Other
- Update .gitignore for runtime data directory
- Add i18n keys for new UI elements (EN/zh_CN)

Co-Authored-By: Claude <noreply@anthropic.com>
2026-01-08 19:04:43 +08:00
Badri Narayanan S
f34aa50ba4 Antigravity compatibility to fix antigravity usage 2026-01-08 10:24:54 +05:30
BrunoMarc
74cb1689e9 test: add empty response retry test
Adds comprehensive test for the empty response retry mechanism:
- Verifies EmptyResponseError class exists and works correctly
- Tests basic requests still work (no regression)
- Validates error class behavior and detection

All tests pass successfully.

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 20:30:45 -03:00
BrunoMarc
1c80c8ba52 fix: address second round code review feedback
Issues found by Claude Opus 4.5 + Gemini 3 Pro:

HIGH PRIORITY FIXES:
- Mark account rate-limited when 429 occurs during retry (was losing resetMs)
- Add exponential backoff between retries (500ms, 1000ms, 2000ms)
- Fix 5xx handling: don't pass error response to streamer, refetch instead
- Use recognizable error messages (429/401) for isRateLimitError/isAuthError

MEDIUM PRIORITY FIXES:
- Refactor while loop to for loop for clearer retry semantics
- Simplify logic flow with early returns

Code review by: Claude Opus 4.5 + Gemini 3 Pro Preview

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 18:21:25 -03:00
BrunoMarc
05cd80ebb5 fix: address code review feedback
- Move MAX_EMPTY_RESPONSE_RETRIES to constants.js for consistency
- Handle 429/401/5xx errors properly during retry fetch
- Use proper message ID format (crypto.randomBytes) instead of Date.now()
- Add crypto import for UUID generation

Code review by: Gemini 3 Pro Preview + Claude Opus 4.5

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 18:16:09 -03:00
BrunoMarc
49480847b6 fix: add retry mechanism for empty API responses
When Claude Code sends requests with large thinking_budget values,
the model may spend all tokens on "thinking" and return empty responses,
causing Claude Code to stop mid-conversation.

This commit adds a retry mechanism that:
- Throws EmptyResponseError instead of emitting fake message on empty response
- Retries up to 2 times before giving up
- Emits fallback message only after all retries are exhausted

Changes:
- src/errors.js: Added EmptyResponseError class and isEmptyResponseError()
- src/cloudcode/sse-streamer.js: Throw error instead of yielding fake message
- src/cloudcode/streaming-handler.js: Added retry loop with fallback

Tested for 6+ hours with 1,884 API requests and 88% recovery rate
on empty responses.

Fixes #61

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-07 18:11:03 -03:00
Badri Narayanan S
a7ca710249 fix commands bug in readme - replace anthropic api key to anthropic auth token 2026-01-08 01:21:01 +05:30
Badri Narayanan S
7c047a9578 Updated readme to add MCP CLI Flag 2026-01-08 01:19:47 +05:30
Badri Narayanan S
56e5042700 Merge branch 'main' into feature/webui 2026-01-07 02:01:23 +05:30
Badri Narayanan S
992fa700d8 Updated readme to use 2.5 flash lite as the default haiku model 2026-01-07 01:55:49 +05:30
Badri Narayanan S
63fa90c04b set cooldown to 10 seconds 2026-01-07 00:33:42 +05:30