Skip to content

feat: reuse agy CLI token + --no-webui + /anthropic prefix alias + schema fix - #360

Open
AntonIXO wants to merge 1 commit into
badrisnarayanan:mainfrom
AntonIXO:feat/agy-token-import-and-no-webui
Open

feat: reuse agy CLI token + --no-webui + /anthropic prefix alias + schema fix#360
AntonIXO wants to merge 1 commit into
badrisnarayanan:mainfrom
AntonIXO:feat/agy-token-import-and-no-webui

Conversation

@AntonIXO

Copy link
Copy Markdown

Summary

This PR adds three features that make the proxy work headlessly alongside the Antigravity CLI (agy) and third-party tools like Hermes Agent:

1. Reuse agy CLI OAuth Token (source: 'agy')

The standalone Antigravity CLI (agy) stores its Google OAuth token at ~/.gemini/antigravity-cli/antigravity-oauth-token. Crucially, agy uses the same Google OAuth client_id + client_secret that this proxy already hardcodes in OAUTH_CONFIG. This means the proxy can refresh agy's refresh_token directly — no separate browser OAuth flow and no full Antigravity IDE installation required.

This is the same pattern used by hermes-claude-auth (reusing ~/.claude/.credentials.json) and opencode-antigravity-auth.

New CLI command:
```bash
npm run accounts:import-agy
AGY_TOKEN_PATH=/custom/path npm run accounts:import-agy
```

New env vars:

  • AGY_TOKEN_PATH — custom path to agy token file
  • AGY_TOKEN_WRITEBACK=1 — write refreshed access token back to agy token file

2. --no-webui Flag

Disables the WebUI for headless servers. Saves ~30-50MB RAM.

```bash
npm start -- --no-webui
DISABLE_WEBUI=1 npm start
```

3. /anthropic Prefix Alias

Third-party tools (e.g. Hermes Agent) auto-detect Anthropic-compatible endpoints via URL suffix heuristic (/anthropic). This PR adds middleware that rewrites /anthropic/v1/* → /v1/*.

4. Schema Sanitizer Fix

Google's Cloud Code API rejects non-string enum values. The schema sanitizer was converting const: true (boolean) to enum: [true] (boolean array), which Google rejected. This PR converts all enum/const values to strings.

Testing

  • ✅ npm run accounts:import-agy — reads agy token, refreshes, resolves email
  • ✅ POST /v1/messages with gemini-3.5-flash-low — valid response
  • ✅ POST /anthropic/v1/messages — prefix alias works
  • ✅ Hermes Agent end-to-end — hermes chat -q "..." --provider custom:antigravity-proxy
  • ✅ --no-webui — API-only mode, ~37MB RAM
  • ✅ systemd service stable with DISABLE_WEBUI=1

Add support for importing and reusing the Antigravity CLI (agy) OAuth token,
so the proxy can authenticate without a separate browser OAuth flow or a full
Antigravity IDE installation.

Key changes:
- New 'agy' account source: reads ~/.gemini/antigravity-cli/antigravity-oauth-token
  and refreshes the token using the same OAuth client_id/secret the proxy already
  hardcodes (agy uses the same Google OAuth client). Optional write-back of
  refreshed access tokens via AGY_TOKEN_WRITEBACK=1.
- CLI command 'import-agy' (npm run accounts:import-agy) to import the agy token,
  resolve the account email, and save it as source='agy'.
- --no-webui flag (or DISABLE_WEBUI/NO_WEBUI env vars) to disable the WebUI
  for headless/API-only deployments, saving ~30-50MB RAM.
- /anthropic prefix alias: rewrites /anthropic/v1/* → /v1/* so third-party
  tools (e.g. Hermes Agent) that auto-detect Anthropic-compatible endpoints
  via URL suffix heuristic work out of the box.
- Schema sanitizer fix: convert non-string enum/const values to strings
  (Google Cloud Code API rejects boolean/number enum values with
  TYPE_STRING errors).

Co-authored-by: Anton Ivanov <antonix@devpins.org>
@AntonIXO

Copy link
Copy Markdown
Author

Rewrote to golang to better match antigravity patters and performance: https://github.com/AntonIXO/antigravity-claude-proxy-go

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant