2026-01-01 21:36:37 +09:00
|
|
|
# AUTH KNOWLEDGE BASE
|
|
|
|
|
|
|
|
|
|
## OVERVIEW
|
|
|
|
|
|
2026-01-02 10:42:38 +09:00
|
|
|
Google Antigravity OAuth for Gemini models. Token management, fetch interception, thinking block extraction.
|
2026-01-01 21:36:37 +09:00
|
|
|
|
|
|
|
|
## STRUCTURE
|
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
auth/
|
|
|
|
|
└── antigravity/
|
2026-01-09 15:44:06 +09:00
|
|
|
├── plugin.ts # Main export, hooks registration (554 lines)
|
2026-01-01 21:36:37 +09:00
|
|
|
├── oauth.ts # OAuth flow, token acquisition
|
|
|
|
|
├── token.ts # Token storage, refresh logic
|
2026-01-09 15:44:06 +09:00
|
|
|
├── fetch.ts # Fetch interceptor (798 lines)
|
|
|
|
|
├── response.ts # Response transformation (599 lines)
|
|
|
|
|
├── thinking.ts # Thinking block extraction (755 lines)
|
2026-01-02 10:42:38 +09:00
|
|
|
├── thought-signature-store.ts # Signature caching
|
|
|
|
|
├── message-converter.ts # Format conversion
|
2026-01-09 15:44:06 +09:00
|
|
|
├── accounts.ts # Multi-account management
|
|
|
|
|
├── browser.ts # Browser automation for OAuth
|
|
|
|
|
├── cli.ts # CLI interaction
|
2026-01-02 10:42:38 +09:00
|
|
|
├── request.ts # Request building
|
2026-01-01 21:36:37 +09:00
|
|
|
├── project.ts # Project ID management
|
2026-01-09 15:44:06 +09:00
|
|
|
├── storage.ts # Token persistence
|
2026-01-02 10:42:38 +09:00
|
|
|
├── tools.ts # OAuth tool registration
|
2026-01-01 21:36:37 +09:00
|
|
|
├── constants.ts # API endpoints, model mappings
|
2026-01-02 10:42:38 +09:00
|
|
|
└── types.ts
|
2026-01-01 21:36:37 +09:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## KEY COMPONENTS
|
|
|
|
|
|
|
|
|
|
| File | Purpose |
|
|
|
|
|
|------|---------|
|
2026-01-02 10:42:38 +09:00
|
|
|
| fetch.ts | URL rewriting, token injection, retries |
|
|
|
|
|
| thinking.ts | Extract `<antThinking>` blocks |
|
|
|
|
|
| response.ts | Streaming SSE parsing |
|
|
|
|
|
| oauth.ts | Browser-based OAuth flow |
|
|
|
|
|
| token.ts | Token persistence, expiry |
|
2026-01-01 21:36:37 +09:00
|
|
|
|
|
|
|
|
## HOW IT WORKS
|
|
|
|
|
|
2026-01-02 10:42:38 +09:00
|
|
|
1. **Intercept**: fetch.ts intercepts Anthropic/Google requests
|
|
|
|
|
2. **Rewrite**: URLs → Antigravity proxy endpoints
|
|
|
|
|
3. **Auth**: Bearer token from stored OAuth credentials
|
|
|
|
|
4. **Response**: Streaming parsed, thinking blocks extracted
|
|
|
|
|
5. **Transform**: Normalized for OpenCode
|
2026-01-01 21:36:37 +09:00
|
|
|
|
2026-01-02 10:42:38 +09:00
|
|
|
## FEATURES
|
2026-01-01 21:36:37 +09:00
|
|
|
|
2026-01-02 10:42:38 +09:00
|
|
|
- Multi-account (up to 10 Google accounts)
|
|
|
|
|
- Auto-fallback on rate limit
|
|
|
|
|
- Thinking blocks preserved
|
|
|
|
|
- Antigravity proxy for AI Studio access
|
2026-01-01 21:36:37 +09:00
|
|
|
|
2026-01-02 10:42:38 +09:00
|
|
|
## ANTI-PATTERNS
|
2026-01-01 21:36:37 +09:00
|
|
|
|
2026-01-02 10:42:38 +09:00
|
|
|
- Direct API calls (use fetch interceptor)
|
|
|
|
|
- Tokens in code (use token.ts storage)
|
|
|
|
|
- Ignoring refresh (check expiry first)
|
|
|
|
|
- Blocking on OAuth (always async)
|