oh-my-opencode/src/auth/AGENTS.md
YeonGyu-Kim d9ab6ab99b docs: update AGENTS.md hierarchy with latest structure and line counts
- Root: Add Prometheus/Metis/Momus agents, MCP architecture, 82 test files
- agents/: Document 7-section delegation and wisdom notepad
- auth/: Multi-account load balancing (10 accounts), endpoint fallback
- features/: Update background-agent 825 lines, builtin-skills 1230 lines
- hooks/: 22+ hooks with event timing details
- tools/: sisyphus-task 583 lines, LSP client 632 lines
- cli/: config-manager 725 lines, 17+ doctor checks
- shared/: Cross-cutting utilities with usage patterns
2026-01-13 21:00:00 +09:00

2.5 KiB

AUTH KNOWLEDGE BASE

OVERVIEW

Google Antigravity OAuth for Gemini models. Token management, fetch interception, thinking block extraction.

STRUCTURE

auth/
└── antigravity/
    ├── plugin.ts         # Main export, hooks registration (554 lines)
    ├── oauth.ts          # OAuth flow, token acquisition
    ├── token.ts          # Token storage, refresh logic
    ├── fetch.ts          # Fetch interceptor (798 lines)
    ├── response.ts       # Response transformation (598 lines)
    ├── thinking.ts       # Thinking block extraction (755 lines)
    ├── thought-signature-store.ts  # Signature caching
    ├── message-converter.ts        # Format conversion
    ├── accounts.ts       # Multi-account management (up to 10 accounts)
    ├── browser.ts        # Browser automation for OAuth
    ├── cli.ts            # CLI interaction
    ├── request.ts        # Request building
    ├── project.ts        # Project ID management
    ├── storage.ts        # Token persistence
    ├── tools.ts          # OAuth tool registration
    ├── constants.ts      # API endpoints, model mappings
    └── types.ts

KEY COMPONENTS

File Purpose
fetch.ts URL rewriting, multi-account rotation, endpoint fallback
thinking.ts Thinking block extraction, signature management, budget mapping
response.ts Streaming SSE parsing and response transformation
accounts.ts Load balancing across up to 10 Google accounts
thought-signature-store.ts Caching signatures for multi-turn thinking conversations

HOW IT WORKS

  1. Intercept: fetch.ts intercepts Anthropic/Google requests.
  2. Route: Rotates accounts and selects best endpoint (daily → autopush → prod).
  3. Auth: Injects Bearer tokens from token.ts persistence.
  4. Process: response.ts parses SSE; thinking.ts manages thought blocks.
  5. Recovery: Detects GCP permission errors and triggers recovery/rotation.

FEATURES

  • Multi-account load balancing (up to 10 accounts)
  • Strategic endpoint fallback: daily → autopush → prod
  • Persistent thought signatures for continuity in thinking models
  • Automated GCP permission error recovery

ANTI-PATTERNS

  • Hardcoding endpoints: Use constants.ts or let fetch.ts route.
  • Manual token handling: Use token.ts and storage.ts abstraction.
  • Sync OAuth calls: All auth flows must be non-blocking/async.
  • Ignoring account rotation: Let fetch.ts handle load balancing.