@kamel-ahmed/proxy-claude 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (84) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +622 -0
  3. package/bin/cli.js +124 -0
  4. package/package.json +80 -0
  5. package/public/app.js +228 -0
  6. package/public/css/src/input.css +523 -0
  7. package/public/css/style.css +1 -0
  8. package/public/favicon.svg +10 -0
  9. package/public/index.html +381 -0
  10. package/public/js/components/account-manager.js +245 -0
  11. package/public/js/components/claude-config.js +420 -0
  12. package/public/js/components/dashboard/charts.js +589 -0
  13. package/public/js/components/dashboard/filters.js +362 -0
  14. package/public/js/components/dashboard/stats.js +110 -0
  15. package/public/js/components/dashboard.js +236 -0
  16. package/public/js/components/logs-viewer.js +100 -0
  17. package/public/js/components/models.js +36 -0
  18. package/public/js/components/server-config.js +349 -0
  19. package/public/js/config/constants.js +102 -0
  20. package/public/js/data-store.js +386 -0
  21. package/public/js/settings-store.js +58 -0
  22. package/public/js/store.js +78 -0
  23. package/public/js/translations/en.js +351 -0
  24. package/public/js/translations/id.js +396 -0
  25. package/public/js/translations/pt.js +287 -0
  26. package/public/js/translations/tr.js +342 -0
  27. package/public/js/translations/zh.js +357 -0
  28. package/public/js/utils/account-actions.js +189 -0
  29. package/public/js/utils/error-handler.js +96 -0
  30. package/public/js/utils/model-config.js +42 -0
  31. package/public/js/utils/validators.js +77 -0
  32. package/public/js/utils.js +69 -0
  33. package/public/views/accounts.html +329 -0
  34. package/public/views/dashboard.html +484 -0
  35. package/public/views/logs.html +97 -0
  36. package/public/views/models.html +331 -0
  37. package/public/views/settings.html +1329 -0
  38. package/src/account-manager/credentials.js +243 -0
  39. package/src/account-manager/index.js +380 -0
  40. package/src/account-manager/onboarding.js +117 -0
  41. package/src/account-manager/rate-limits.js +237 -0
  42. package/src/account-manager/storage.js +136 -0
  43. package/src/account-manager/strategies/base-strategy.js +104 -0
  44. package/src/account-manager/strategies/hybrid-strategy.js +195 -0
  45. package/src/account-manager/strategies/index.js +79 -0
  46. package/src/account-manager/strategies/round-robin-strategy.js +76 -0
  47. package/src/account-manager/strategies/sticky-strategy.js +138 -0
  48. package/src/account-manager/strategies/trackers/health-tracker.js +162 -0
  49. package/src/account-manager/strategies/trackers/index.js +8 -0
  50. package/src/account-manager/strategies/trackers/token-bucket-tracker.js +121 -0
  51. package/src/auth/database.js +169 -0
  52. package/src/auth/oauth.js +419 -0
  53. package/src/auth/token-extractor.js +117 -0
  54. package/src/cli/accounts.js +512 -0
  55. package/src/cli/refresh.js +201 -0
  56. package/src/cli/setup.js +338 -0
  57. package/src/cloudcode/index.js +29 -0
  58. package/src/cloudcode/message-handler.js +386 -0
  59. package/src/cloudcode/model-api.js +248 -0
  60. package/src/cloudcode/rate-limit-parser.js +181 -0
  61. package/src/cloudcode/request-builder.js +93 -0
  62. package/src/cloudcode/session-manager.js +47 -0
  63. package/src/cloudcode/sse-parser.js +121 -0
  64. package/src/cloudcode/sse-streamer.js +293 -0
  65. package/src/cloudcode/streaming-handler.js +492 -0
  66. package/src/config.js +107 -0
  67. package/src/constants.js +278 -0
  68. package/src/errors.js +238 -0
  69. package/src/fallback-config.js +29 -0
  70. package/src/format/content-converter.js +193 -0
  71. package/src/format/index.js +20 -0
  72. package/src/format/request-converter.js +248 -0
  73. package/src/format/response-converter.js +120 -0
  74. package/src/format/schema-sanitizer.js +673 -0
  75. package/src/format/signature-cache.js +88 -0
  76. package/src/format/thinking-utils.js +558 -0
  77. package/src/index.js +146 -0
  78. package/src/modules/usage-stats.js +205 -0
  79. package/src/server.js +861 -0
  80. package/src/utils/claude-config.js +245 -0
  81. package/src/utils/helpers.js +51 -0
  82. package/src/utils/logger.js +142 -0
  83. package/src/utils/native-module-helper.js +162 -0
  84. package/src/webui/index.js +707 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Badri Narayanan S
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,622 @@
1
+ # Antigravity Claude Proxy
2
+
3
+ [![npm version](https://img.shields.io/npm/v/antigravity-claude-proxy.svg)](https://www.npmjs.com/package/antigravity-claude-proxy)
4
+ [![npm downloads](https://img.shields.io/npm/dm/antigravity-claude-proxy.svg)](https://www.npmjs.com/package/antigravity-claude-proxy)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+
7
+ <a href="https://buymeacoffee.com/badrinarayanans" target="_blank"><img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="50"></a>
8
+
9
+ A proxy server that exposes an **Anthropic-compatible API** backed by **Antigravity's Cloud Code**, letting you use Claude and Gemini models with **Claude Code CLI**.
10
+
11
+ ![Antigravity Claude Proxy Banner](images/banner.png)
12
+
13
+ ## How It Works
14
+
15
+ ```
16
+ ┌──────────────────┐ ┌─────────────────────┐ ┌────────────────────────────┐
17
+ │ Claude Code │────▶│ This Proxy Server │────▶│ Antigravity Cloud Code │
18
+ │ (Anthropic │ │ (Anthropic → Google│ │ (daily-cloudcode-pa. │
19
+ │ API format) │ │ Generative AI) │ │ sandbox.googleapis.com) │
20
+ └──────────────────┘ └─────────────────────┘ └────────────────────────────┘
21
+ ```
22
+
23
+ 1. Receives requests in **Anthropic Messages API format**
24
+ 2. Uses OAuth tokens from added Google accounts (or Antigravity's local database)
25
+ 3. Transforms to **Google Generative AI format** with Cloud Code wrapping
26
+ 4. Sends to Antigravity's Cloud Code API
27
+ 5. Converts responses back to **Anthropic format** with full thinking/streaming support
28
+
29
+ ## Prerequisites
30
+
31
+ - **Node.js** 18 or later
32
+ - **Antigravity** installed (for single-account mode) OR Google account(s) for multi-account mode
33
+
34
+ ---
35
+
36
+ ## Installation
37
+
38
+ ### Automated Setup (Recommended)
39
+
40
+ Run the setup command to automatically install Claude Code CLI and create a global `proxy-claude` command:
41
+
42
+ ```bash
43
+ # If running via npx
44
+ npx antigravity-claude-proxy@latest setup
45
+
46
+ # If installed globally
47
+ antigravity-claude-proxy setup
48
+
49
+ # If cloned locally
50
+ npm run setup
51
+ ```
52
+
53
+ After setup completes, you can run Claude with the proxy from anywhere:
54
+
55
+ ```bash
56
+ proxy-claude
57
+ ```
58
+
59
+ The `proxy-claude` command will:
60
+ 1. Start the proxy server in the background.
61
+ 2. Wait for the server to be ready.
62
+ 3. Launch `claude` (Claude Code CLI) connected to the proxy.
63
+ 4. Automatically shut down the proxy when you exit Claude.
64
+
65
+ You can also customize the port and pass arguments to Claude:
66
+
67
+ ```bash
68
+ # Use a custom port
69
+ PORT=3000 proxy-claude
70
+
71
+ # Pass arguments to Claude
72
+ proxy-claude --model sonnet
73
+ ```
74
+
75
+ > **Note:** The setup requires write access to `/usr/local/bin`. If prompted, enter your password to allow installation.
76
+
77
+ ### Option 1: npm (Manual)
78
+
79
+ ```bash
80
+ # Run directly with npx (no install needed)
81
+ npx antigravity-claude-proxy@latest start
82
+
83
+ # Or install globally
84
+ npm install -g antigravity-claude-proxy@latest
85
+ antigravity-claude-proxy start
86
+ ```
87
+
88
+ ### Option 2: Clone Repository
89
+
90
+ ```bash
91
+ git clone https://github.com/badri-s2001/antigravity-claude-proxy.git
92
+ cd antigravity-claude-proxy
93
+ npm install
94
+ npm start
95
+ ```
96
+
97
+ ---
98
+
99
+ ## Quick Start
100
+
101
+ ### 1. Start the Proxy Server
102
+
103
+ ```bash
104
+ # If installed via npm
105
+ antigravity-claude-proxy start
106
+
107
+ # If using npx
108
+ npx antigravity-claude-proxy@latest start
109
+
110
+ # If cloned locally
111
+ npm start
112
+ ```
113
+
114
+ The server runs on `http://localhost:8080` by default.
115
+
116
+ ### 2. Link Account(s)
117
+
118
+ Choose one of the following methods to authorize the proxy:
119
+
120
+ #### **Method A: Web Dashboard (Recommended)**
121
+
122
+ 1. With the proxy running, open `http://localhost:8080` in your browser.
123
+ 2. Navigate to the **Accounts** tab and click **Add Account**.
124
+ 3. Complete the Google OAuth authorization in the popup window.
125
+
126
+ #### **Method B: CLI (Desktop or Headless)**
127
+
128
+ If you prefer the terminal or are on a remote server:
129
+
130
+ ```bash
131
+ # Desktop (opens browser)
132
+ antigravity-claude-proxy accounts add
133
+
134
+ # Headless (Docker/SSH)
135
+ antigravity-claude-proxy accounts add --no-browser
136
+ ```
137
+
138
+ > For full CLI account management options, run `antigravity-claude-proxy accounts --help`.
139
+
140
+ #### **Method C: Automatic (Antigravity Users)**
141
+
142
+ If you have the **Antigravity** app installed and logged in, the proxy will automatically detect your local session. No additional setup is required.
143
+
144
+ To use a custom port:
145
+
146
+ ```bash
147
+ PORT=3001 antigravity-claude-proxy start
148
+ ```
149
+
150
+ ### 3. Verify It's Working
151
+
152
+ ```bash
153
+ # Health check
154
+ curl http://localhost:8080/health
155
+
156
+ # Check account status and quota limits
157
+ curl "http://localhost:8080/account-limits?format=table"
158
+ ```
159
+
160
+ ---
161
+
162
+ ## Using with Claude Code CLI
163
+
164
+ ### Configure Claude Code
165
+
166
+ You can configure these settings in two ways:
167
+
168
+ #### **Via Web Console (Recommended)**
169
+
170
+ 1. Open the WebUI at `http://localhost:8080`.
171
+ 2. Go to **Settings** → **Claude CLI**.
172
+ 3. Select your preferred models and click **Apply to Claude CLI**.
173
+
174
+ > [!TIP] > **Configuration Precedence**: System environment variables (set in shell profile like `.zshrc`) take precedence over the `settings.json` file. If you use the Web Console to manage settings, ensure you haven't manually exported conflicting variables in your terminal.
175
+
176
+ #### **Manual Configuration**
177
+
178
+ Create or edit the Claude Code settings file:
179
+
180
+ **macOS:** `~/.claude/settings.json`
181
+ **Linux:** `~/.claude/settings.json`
182
+ **Windows:** `%USERPROFILE%\.claude\settings.json`
183
+
184
+ Add this configuration:
185
+
186
+ ```json
187
+ {
188
+ "env": {
189
+ "ANTHROPIC_AUTH_TOKEN": "test",
190
+ "ANTHROPIC_BASE_URL": "http://localhost:8080",
191
+ "ANTHROPIC_MODEL": "claude-opus-4-5-thinking",
192
+ "ANTHROPIC_DEFAULT_OPUS_MODEL": "claude-opus-4-5-thinking",
193
+ "ANTHROPIC_DEFAULT_SONNET_MODEL": "claude-sonnet-4-5-thinking",
194
+ "ANTHROPIC_DEFAULT_HAIKU_MODEL": "gemini-2.5-flash-lite[1m]",
195
+ "CLAUDE_CODE_SUBAGENT_MODEL": "claude-sonnet-4-5-thinking",
196
+ "ENABLE_EXPERIMENTAL_MCP_CLI": "true"
197
+ }
198
+ }
199
+ ```
200
+
201
+ (Please use **gemini-2.5-flash-lite** as the default haiku model, even if others are claude, as claude code makes several calls via the haiku model for background tasks. If you use claude model for it, you may use you claude usage sooner)
202
+
203
+ Or to use Gemini models:
204
+
205
+ ```json
206
+ {
207
+ "env": {
208
+ "ANTHROPIC_AUTH_TOKEN": "test",
209
+ "ANTHROPIC_BASE_URL": "http://localhost:8080",
210
+ "ANTHROPIC_MODEL": "gemini-3-pro-high[1m]",
211
+ "ANTHROPIC_DEFAULT_OPUS_MODEL": "gemini-3-pro-high[1m]",
212
+ "ANTHROPIC_DEFAULT_SONNET_MODEL": "gemini-3-flash[1m]",
213
+ "ANTHROPIC_DEFAULT_HAIKU_MODEL": "gemini-2.5-flash-lite[1m]",
214
+ "CLAUDE_CODE_SUBAGENT_MODEL": "gemini-3-flash[1m]",
215
+ "ENABLE_EXPERIMENTAL_MCP_CLI": "true"
216
+ }
217
+ }
218
+ ```
219
+
220
+ ### Load Environment Variables
221
+
222
+ Add the proxy settings to your shell profile:
223
+
224
+ **macOS / Linux:**
225
+
226
+ ```bash
227
+ echo 'export ANTHROPIC_BASE_URL="http://localhost:8080"' >> ~/.zshrc
228
+ echo 'export ANTHROPIC_AUTH_TOKEN="test"' >> ~/.zshrc
229
+ source ~/.zshrc
230
+ ```
231
+
232
+ > For Bash users, replace `~/.zshrc` with `~/.bashrc`
233
+
234
+ **Windows (PowerShell):**
235
+
236
+ ```powershell
237
+ Add-Content $PROFILE "`n`$env:ANTHROPIC_BASE_URL = 'http://localhost:8080'"
238
+ Add-Content $PROFILE "`$env:ANTHROPIC_AUTH_TOKEN = 'test'"
239
+ . $PROFILE
240
+ ```
241
+
242
+ **Windows (Command Prompt):**
243
+
244
+ ```cmd
245
+ setx ANTHROPIC_BASE_URL "http://localhost:8080"
246
+ setx ANTHROPIC_AUTH_TOKEN "test"
247
+ ```
248
+
249
+ Restart your terminal for changes to take effect.
250
+
251
+ ### Run Claude Code
252
+
253
+ ```bash
254
+ # Make sure the proxy is running first
255
+ antigravity-claude-proxy start
256
+
257
+ # In another terminal, run Claude Code
258
+ claude
259
+ ```
260
+
261
+ > **Note:** If Claude Code asks you to select a login method, add `"hasCompletedOnboarding": true` to `~/.claude.json` (macOS/Linux) or `%USERPROFILE%\.claude.json` (Windows), then restart your terminal and try again.
262
+
263
+ ### Multiple Claude Code Instances (Optional)
264
+
265
+ To run both the official Claude Code and Antigravity version simultaneously, add this alias:
266
+
267
+ **macOS / Linux:**
268
+
269
+ ```bash
270
+ # Add to ~/.zshrc or ~/.bashrc
271
+ alias claude-antigravity='CLAUDE_CONFIG_DIR=~/.claude-account-antigravity ANTHROPIC_BASE_URL="http://localhost:8080" ANTHROPIC_AUTH_TOKEN="test" command claude'
272
+ ```
273
+
274
+ **Windows (PowerShell):**
275
+
276
+ ```powershell
277
+ # Add to $PROFILE
278
+ function claude-antigravity {
279
+ $env:CLAUDE_CONFIG_DIR = "$env:USERPROFILE\.claude-account-antigravity"
280
+ $env:ANTHROPIC_BASE_URL = "http://localhost:8080"
281
+ $env:ANTHROPIC_AUTH_TOKEN = "test"
282
+ claude
283
+ }
284
+ ```
285
+
286
+ Then run `claude` for official API or `claude-antigravity` for this proxy.
287
+
288
+ ---
289
+
290
+ ## Available Models
291
+
292
+ ### Claude Models
293
+
294
+ | Model ID | Description |
295
+ | ---------------------------- | ---------------------------------------- |
296
+ | `claude-sonnet-4-5-thinking` | Claude Sonnet 4.5 with extended thinking |
297
+ | `claude-opus-4-5-thinking` | Claude Opus 4.5 with extended thinking |
298
+ | `claude-sonnet-4-5` | Claude Sonnet 4.5 without thinking |
299
+
300
+ ### Gemini Models
301
+
302
+ | Model ID | Description |
303
+ | ------------------- | ------------------------------- |
304
+ | `gemini-3-flash` | Gemini 3 Flash with thinking |
305
+ | `gemini-3-pro-low` | Gemini 3 Pro Low with thinking |
306
+ | `gemini-3-pro-high` | Gemini 3 Pro High with thinking |
307
+
308
+ Gemini models include full thinking support with `thoughtSignature` handling for multi-turn conversations.
309
+
310
+ ---
311
+
312
+ ## Multi-Account Load Balancing
313
+
314
+ When you add multiple accounts, the proxy intelligently distributes requests across them using configurable selection strategies.
315
+
316
+ ### Account Selection Strategies
317
+
318
+ Choose a strategy based on your needs:
319
+
320
+ | Strategy | Best For | Description |
321
+ | --- | --- | --- |
322
+ | **Hybrid** (Default) | Most users | Smart selection combining health score, token bucket rate limiting, and LRU freshness |
323
+ | **Sticky** | Prompt caching | Stays on the same account to maximize cache hits, switches only when rate-limited |
324
+ | **Round-Robin** | Even distribution | Cycles through accounts sequentially for balanced load |
325
+
326
+ **Configure via CLI:**
327
+
328
+ ```bash
329
+ antigravity-claude-proxy start --strategy=hybrid # Default: smart distribution
330
+ antigravity-claude-proxy start --strategy=sticky # Cache-optimized
331
+ antigravity-claude-proxy start --strategy=round-robin # Load-balanced
332
+ ```
333
+
334
+ **Or via WebUI:** Settings → Server → Account Selection Strategy
335
+
336
+ ### How It Works
337
+
338
+ - **Health Score Tracking**: Accounts earn points for successful requests and lose points for failures/rate-limits
339
+ - **Token Bucket Rate Limiting**: Client-side throttling with regenerating tokens (50 max, 6/minute)
340
+ - **Automatic Cooldown**: Rate-limited accounts recover automatically after reset time expires
341
+ - **Invalid Account Detection**: Accounts needing re-authentication are marked and skipped
342
+ - **Prompt Caching Support**: Session IDs derived from conversation enable cache hits across turns
343
+
344
+ ### Monitoring
345
+
346
+ Check account status, subscription tiers, and quota anytime:
347
+
348
+ ```bash
349
+ # Web UI: http://localhost:8080/ (Accounts tab - shows tier badges and quota progress)
350
+ # CLI Table:
351
+ curl "http://localhost:8080/account-limits?format=table"
352
+ ```
353
+
354
+ #### CLI Management Reference
355
+
356
+ If you prefer using the terminal for management:
357
+
358
+ ```bash
359
+ # List all accounts
360
+ antigravity-claude-proxy accounts list
361
+
362
+ # Verify account health
363
+ antigravity-claude-proxy accounts verify
364
+
365
+ # Interactive CLI menu
366
+ antigravity-claude-proxy accounts
367
+ ```
368
+
369
+ ---
370
+
371
+ ## Web Management Console
372
+
373
+ The proxy includes a built-in, modern web interface for real-time monitoring and configuration. Access the console at: `http://localhost:8080` (default port).
374
+
375
+ ![Antigravity Console](images/webui-dashboard.png)
376
+
377
+ ### Key Features
378
+
379
+ - **Real-time Dashboard**: Monitor request volume, active accounts, model health, and subscription tier distribution.
380
+ - **Visual Model Quota**: Track per-model usage and next reset times with color-coded progress indicators.
381
+ - **Account Management**: Add/remove Google accounts via OAuth, view subscription tiers (Free/Pro/Ultra) and quota status at a glance.
382
+ - **Claude CLI Configuration**: Edit your `~/.claude/settings.json` directly from the browser.
383
+ - **Persistent History**: Tracks request volume by model family for 30 days, persisting across server restarts.
384
+ - **Time Range Filtering**: Analyze usage trends over 1H, 6H, 24H, 7D, or All Time periods.
385
+ - **Smart Analysis**: Auto-select top 5 most used models or toggle between Family/Model views.
386
+ - **Live Logs**: Stream server logs with level-based filtering and search.
387
+ - **Advanced Tuning**: Configure retries, timeouts, and debug mode on the fly.
388
+ - **Bilingual Interface**: Full support for English and Chinese (switch via Settings).
389
+
390
+ ---
391
+
392
+ ## Advanced Configuration
393
+
394
+ While most users can use the default settings, you can tune the proxy behavior via the **Settings → Server** tab in the WebUI or by creating a `config.json` file.
395
+
396
+ ### Configurable Options
397
+
398
+ - **API Key Authentication**: Protect `/v1/*` API endpoints with `API_KEY` env var or `apiKey` in config.
399
+ - **WebUI Password**: Secure your dashboard with `WEBUI_PASSWORD` env var or in config.
400
+ - **Custom Port**: Change the default `8080` port.
401
+ - **Retry Logic**: Configure `maxRetries`, `retryBaseMs`, and `retryMaxMs`.
402
+ - **Load Balancing**: Adjust `defaultCooldownMs` and `maxWaitBeforeErrorMs`.
403
+ - **Persistence**: Enable `persistTokenCache` to save OAuth sessions across restarts.
404
+
405
+ Refer to `config.example.json` for a complete list of fields and documentation.
406
+
407
+ ---
408
+
409
+ ## macOS Menu Bar App
410
+
411
+ For macOS users who prefer a native experience, there's a companion menu bar app that provides quick access to server controls without touching the terminal. Get it from: [antigravity-claude-proxy-bar](https://github.com/IrvanFza/antigravity-claude-proxy-bar)
412
+
413
+ > **Note:** This is a GUI wrapper only. You still need to install and setup the proxy server first using one of the [installation methods](#installation) above.
414
+
415
+ ![AntiGravity Claude Proxy Bar](https://github.com/IrvanFza/antigravity-claude-proxy-bar/blob/main/images/application.png?raw=true)
416
+
417
+ ### Key Features
418
+
419
+ - **Server Control**: Start/stop the proxy server with a single click or ⌘S shortcut.
420
+ - **Status Indicator**: Menu bar icon shows server running state at a glance.
421
+ - **WebUI Access**: Open the web management console directly from the menu.
422
+ - **Port Configuration**: Customize the proxy server port (default: 8080).
423
+ - **Auto-Start Options**: Launch server on app start and launch app at login.
424
+ - **Native Experience**: Clean, native SwiftUI interface designed for macOS.
425
+
426
+ ---
427
+
428
+ ## API Endpoints
429
+
430
+ | Endpoint | Method | Description |
431
+ | ----------------- | ------ | --------------------------------------------------------------------- |
432
+ | `/health` | GET | Health check |
433
+ | `/account-limits` | GET | Account status and quota limits (add `?format=table` for ASCII table) |
434
+ | `/v1/messages` | POST | Anthropic Messages API |
435
+ | `/v1/models` | GET | List available models |
436
+ | `/refresh-token` | POST | Force token refresh |
437
+
438
+ ---
439
+
440
+ ## Testing
441
+
442
+ Run the test suite (requires server running):
443
+
444
+ ```bash
445
+ # Start server in one terminal
446
+ npm start
447
+
448
+ # Run tests in another terminal
449
+ npm test
450
+ ```
451
+
452
+ Individual tests:
453
+
454
+ ```bash
455
+ npm run test:signatures # Thinking signatures
456
+ npm run test:multiturn # Multi-turn with tools
457
+ npm run test:streaming # Streaming SSE events
458
+ npm run test:interleaved # Interleaved thinking
459
+ npm run test:images # Image processing
460
+ npm run test:caching # Prompt caching
461
+ npm run test:strategies # Account selection strategies
462
+ ```
463
+
464
+ ---
465
+
466
+ ## Troubleshooting
467
+
468
+ ### "Could not extract token from Antigravity"
469
+
470
+ If using single-account mode with Antigravity:
471
+
472
+ 1. Make sure Antigravity app is installed and running
473
+ 2. Ensure you're logged in to Antigravity
474
+
475
+ Or add accounts via OAuth instead: `antigravity-claude-proxy accounts add`
476
+
477
+ ### 401 Authentication Errors
478
+
479
+ The token might have expired. Try:
480
+
481
+ ```bash
482
+ curl -X POST http://localhost:8080/refresh-token
483
+ ```
484
+
485
+ Or re-authenticate the account:
486
+
487
+ ```bash
488
+ antigravity-claude-proxy accounts
489
+ ```
490
+
491
+ ### Rate Limiting (429)
492
+
493
+ With multiple accounts, the proxy automatically switches to the next available account. With a single account, you'll need to wait for the rate limit to reset.
494
+
495
+ ### Account Shows as "Invalid"
496
+
497
+ Re-authenticate the account:
498
+
499
+ ```bash
500
+ antigravity-claude-proxy accounts
501
+ # Choose "Re-authenticate" for the invalid account
502
+ ```
503
+
504
+ ---
505
+
506
+ ## Safety, Usage, and Risk Notices
507
+
508
+ ### Intended Use
509
+
510
+ - Personal / internal development only
511
+ - Respect internal quotas and data handling policies
512
+ - Not for production services or bypassing intended limits
513
+
514
+ ### Not Suitable For
515
+
516
+ - Production application traffic
517
+ - High-volume automated extraction
518
+ - Any use that violates Acceptable Use Policies
519
+
520
+ ### Warning (Assumption of Risk)
521
+
522
+ By using this software, you acknowledge and accept the following:
523
+
524
+ - **Terms of Service risk**: This approach may violate the Terms of Service of AI model providers (Anthropic, Google, etc.). You are solely responsible for ensuring compliance with all applicable terms and policies.
525
+
526
+ - **Account risk**: Providers may detect this usage pattern and take punitive action, including suspension, permanent ban, or loss of access to paid subscriptions.
527
+
528
+ - **No guarantees**: Providers may change APIs, authentication, or policies at any time, which can break this method without notice.
529
+
530
+ - **Assumption of risk**: You assume all legal, financial, and technical risks. The authors and contributors of this project bear no responsibility for any consequences arising from your use.
531
+
532
+ **Use at your own risk. Proceed only if you understand and accept these risks.**
533
+
534
+ ---
535
+
536
+ ## Legal
537
+
538
+ - **Not affiliated with Google or Anthropic.** This is an independent open-source project and is not endorsed by, sponsored by, or affiliated with Google LLC or Anthropic PBC.
539
+
540
+ - "Antigravity", "Gemini", "Google Cloud", and "Google" are trademarks of Google LLC.
541
+
542
+ - "Claude" and "Anthropic" are trademarks of Anthropic PBC.
543
+
544
+ - Software is provided "as is", without warranty. You are responsible for complying with all applicable Terms of Service and Acceptable Use Policies.
545
+
546
+ ---
547
+
548
+ ## Development
549
+
550
+ ### For Developers & Contributors
551
+
552
+ This project uses a local Tailwind CSS build system. CSS is pre-compiled and included in the repository, so you can run the project immediately after cloning.
553
+
554
+ #### Quick Start
555
+
556
+ ```bash
557
+ git clone https://github.com/badri-s2001/antigravity-claude-proxy.git
558
+ cd antigravity-claude-proxy
559
+ npm install # Automatically builds CSS via prepare hook
560
+ npm start # Start server (no rebuild needed)
561
+ ```
562
+
563
+ #### Frontend Development
564
+
565
+ If you need to modify styles in `public/css/src/input.css`:
566
+
567
+ ```bash
568
+ # Option 1: Build once
569
+ npm run build:css
570
+
571
+ # Option 2: Watch for changes (auto-rebuild)
572
+ npm run watch:css
573
+
574
+ # Option 3: Watch both CSS and server (recommended)
575
+ npm run dev:full
576
+ ```
577
+
578
+ **File Structure:**
579
+ - `public/css/src/input.css` - Source CSS with Tailwind `@apply` directives (edit this)
580
+ - `public/css/style.css` - Compiled & minified CSS (auto-generated, don't edit)
581
+ - `tailwind.config.js` - Tailwind configuration
582
+ - `postcss.config.js` - PostCSS configuration
583
+
584
+ #### Backend-Only Development
585
+
586
+ If you're only working on backend code and don't need frontend dev tools:
587
+
588
+ ```bash
589
+ npm install --production # Skip devDependencies (saves ~20MB)
590
+ npm start
591
+ ```
592
+
593
+ **Note:** Pre-compiled CSS is committed to the repository, so you don't need to rebuild unless modifying styles.
594
+
595
+ #### Project Structure
596
+
597
+ See [CLAUDE.md](./CLAUDE.md) for detailed architecture documentation, including:
598
+ - Request flow and module organization
599
+ - Frontend architecture (Alpine.js + Tailwind)
600
+ - Service layer patterns (`ErrorHandler.withLoading`, `AccountActions`)
601
+ - Dashboard module documentation
602
+
603
+ ---
604
+
605
+ ## Credits
606
+
607
+ This project is based on insights and code from:
608
+
609
+ - [opencode-antigravity-auth](https://github.com/NoeFabris/opencode-antigravity-auth) - Antigravity OAuth plugin for OpenCode
610
+ - [claude-code-proxy](https://github.com/1rgs/claude-code-proxy) - Anthropic API proxy using LiteLLM
611
+
612
+ ---
613
+
614
+ ## License
615
+
616
+ MIT
617
+
618
+ ---
619
+
620
+ ## Star History
621
+
622
+ [![Star History Chart](https://api.star-history.com/svg?repos=badrisnarayanan/antigravity-claude-proxy&type=date&legend=top-left&cache-control=no-cache)](https://www.star-history.com/#badrisnarayanan/antigravity-claude-proxy&type=date&legend=top-left)