{"_id":"@agungabadii/opencode-auth-ag","_rev":"2-d39269e1fbd2d83525a0b944b22a8d95","name":"@agungabadii/opencode-auth-ag","dist-tags":{"latest":"1.7.0"},"versions":{"1.6.3":{"name":"@agungabadii/opencode-auth-ag","version":"1.6.3","keywords":["opencode","google","antigravity","gemini","oauth","plugin","auth","claude"],"author":{"name":"Agung Prasasti Abadi","email":"agungprasastia@gmail.com"},"license":"MIT","_id":"@agungabadii/opencode-auth-ag@1.6.3","maintainers":[{"name":"agungabadii","email":"agungprasastia@gmail.com"}],"homepage":"https://github.com/agungprasastia/opencode-auth-ag#readme","bugs":{"url":"https://github.com/agungprasastia/opencode-auth-ag/issues"},"dist":{"shasum":"a79a29571ad1771200d1abd51c9e5897ae4c39a6","tarball":"https://registry.npmjs.org/@agungabadii/opencode-auth-ag/-/opencode-auth-ag-1.6.3.tgz","fileCount":239,"integrity":"sha512-5iVGZXWIQVrx64MjWVfupN0kvHt3jC/La1DSAy6XFgV4tPfkcAWtrmP+91Zp7lK5e+mxtb7tzruD27dRD/aFaA==","signatures":[{"sig":"MEQCICUIAwMsrkRkIGuezzBuwUgVS3J2xlCvpG7S1gQtwmUrAiAMtGoSduyVlgl8GUvQmU7JInLdCAHaAWnT1TA1Cuxkzw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1510567},"main":"./dist/index.js","type":"module","types":"./dist/index.d.ts","engines":{"node":">=20.0.0"},"gitHead":"0d929bbc6e60a1e9a079e189d0a7101a11304287","scripts":{"test":"vitest run","build":"tsc -p tsconfig.build.json","release":"npm version patch && git push --follow-tags","test:ui":"vitest --ui","typecheck":"tsc --noEmit","test:watch":"vitest","build:schema":"npx tsx script/build-schema.ts","test:coverage":"vitest run --coverage","prepublishOnly":"pnpm run build","test:e2e:models":"npx tsx script/test-models.ts","test:e2e:regression":"npx tsx script/test-regression.ts"},"_npmUser":{"name":"agungabadii","email":"agungprasastia@gmail.com"},"repository":{"url":"git+https://github.com/agungprasastia/opencode-auth-ag.git","type":"git"},"_npmVersion":"11.6.2","description":"Enhanced Google Antigravity IDE OAuth auth plugin for OpenCode - featuring safe mode anti-ban protection, Oh-My-OpenCode integration, strict quota locking, and proxy support.","directories":{},"_nodeVersion":"24.13.0","dependencies":{"zod":"^4.0.0","undici":"^7.22.0","xdg-basedir":"^5.1.0","proper-lockfile":"^4.1.2","@opencode-ai/plugin":"^0.15.30","@openauthjs/openauth":"^0.4.3"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"_hasShrinkwrap":false,"devDependencies":{"vitest":"^3.0.0","@vitest/ui":"^3.0.0","typescript":"^5.0.0","@types/node":"^24.10.1","zod-to-json-schema":"^3.25.1","@vitest/coverage-v8":"^3.0.0","@types/proper-lockfile":"^4.1.4"},"peerDependencies":{"typescript":"^5"},"_npmOperationalInternal":{"tmp":"tmp/opencode-auth-ag_1.6.3_1776857984941_0.23765113341319655","host":"s3://npm-registry-packages-npm-production"}},"1.7.0":{"name":"@agungabadii/opencode-auth-ag","version":"1.7.0","description":"Enhanced Google Antigravity IDE OAuth auth plugin for OpenCode - featuring safe mode anti-ban protection, Oh-My-OpenCode integration, strict quota locking, and proxy support.","main":"./dist/index.js","types":"./dist/index.d.ts","type":"module","license":"MIT","author":{"name":"Agung Prasasti Abadi","email":"agungprasastia@gmail.com"},"repository":{"type":"git","url":"git+https://github.com/agungprasastia/opencode-auth-ag.git"},"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"homepage":"https://github.com/agungprasastia/opencode-auth-ag#readme","bugs":{"url":"https://github.com/agungprasastia/opencode-auth-ag/issues"},"keywords":["opencode","google","antigravity","gemini","oauth","plugin","auth","claude"],"engines":{"node":">=20.0.0"},"scripts":{"build":"tsc -p tsconfig.build.json","build:schema":"npx tsx script/build-schema.ts","typecheck":"tsc --noEmit","test":"vitest run","test:watch":"vitest","test:ui":"vitest --ui","test:coverage":"vitest run --coverage","prepublishOnly":"pnpm run build","test:e2e:models":"npx tsx script/test-models.ts","test:e2e:regression":"npx tsx script/test-regression.ts","release":"npm version patch && git push --follow-tags"},"peerDependencies":{"typescript":"^5"},"devDependencies":{"@types/node":"^24.10.1","@types/proper-lockfile":"^4.1.4","@vitest/coverage-v8":"^3.0.0","@vitest/ui":"^3.0.0","typescript":"^6.0.3","vitest":"^3.0.0","zod-to-json-schema":"^3.25.1"},"dependencies":{"@openauthjs/openauth":"^0.4.3","@opencode-ai/plugin":"^1.14.20","proper-lockfile":"^4.1.2","undici":"^7.25.0","xdg-basedir":"^5.1.0","zod":"^4.0.0"},"gitHead":"dba44b3530410a2ed73185cd31a3d2f5216adf5e","_id":"@agungabadii/opencode-auth-ag@1.7.0","_nodeVersion":"24.13.0","_npmVersion":"11.6.2","dist":{"integrity":"sha512-iiASTMkH0IverPWVvU7bGMosQR5GKXfkJU/NWHPeMXu4mvTCf7rXYaxQuJjE0DAjK1ufqpOfzeGt4o0RJV7SdQ==","shasum":"8681fe327f8461492ebd2123199ff10f0f81523f","tarball":"https://registry.npmjs.org/@agungabadii/opencode-auth-ag/-/opencode-auth-ag-1.7.0.tgz","fileCount":239,"unpackedSize":1513082,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCDQXKrdJY0CT9CzEnUe5YuMGUh0MaEZTKA2C9uVtECBAIhAL2/iA79SekCbR6RK6qbaK/irjCl9HEIFTSSWClF+PVE"}]},"_npmUser":{"name":"agungabadii","email":"agungprasastia@gmail.com"},"directories":{},"maintainers":[{"name":"agungabadii","email":"agungprasastia@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/opencode-auth-ag_1.7.0_1776913341014_0.3499772232606684"},"_hasShrinkwrap":false}},"time":{"created":"2026-04-22T11:39:44.847Z","modified":"2026-04-23T03:02:21.283Z","1.6.3":"2026-04-22T11:39:45.088Z","1.7.0":"2026-04-23T03:02:21.185Z"},"bugs":{"url":"https://github.com/agungprasastia/opencode-auth-ag/issues"},"author":{"name":"Agung Prasasti Abadi","email":"agungprasastia@gmail.com"},"license":"MIT","homepage":"https://github.com/agungprasastia/opencode-auth-ag#readme","keywords":["opencode","google","antigravity","gemini","oauth","plugin","auth","claude"],"repository":{"type":"git","url":"git+https://github.com/agungprasastia/opencode-auth-ag.git"},"description":"Enhanced Google Antigravity IDE OAuth auth plugin for OpenCode - featuring safe mode anti-ban protection, Oh-My-OpenCode integration, strict quota locking, and proxy support.","maintainers":[{"name":"agungabadii","email":"agungprasastia@gmail.com"}],"readme":"# OpenCode AG Auth (Antigravity Guard)\r\n\r\n[![npm version](https://img.shields.io/npm/v/@agungabadii/opencode-auth-ag.svg)](https://www.npmjs.com/package/@agungabadii/opencode-auth-ag)\r\n[![npm beta](https://img.shields.io/npm/v/@agungabadii/opencode-auth-ag/beta.svg?label=beta)](https://www.npmjs.com/package/@agungabadii/opencode-auth-ag)\r\n[![npm downloads](https://img.shields.io/npm/dw/@agungabadii/opencode-auth-ag.svg)](https://www.npmjs.com/package/@agungabadii/opencode-auth-ag)\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)\r\n[![X (Twitter)](https://img.shields.io/badge/X-@dopesalmon-000000?style=flat&logo=x)](https://x.com/dopesalmon)\r\n\r\n**The Hardened, Safety-First Antigravity Plugin for OpenCode.**\r\n\r\nEnable OpenCode to authenticate against **Antigravity** (Google's IDE) with enterprise-grade **account protection** and **session stability**. Access models like `gemini-3.1-pro` and `claude-opus-4-6-thinking` while keeping your accounts safe from bans and your agents running without interruption.\r\n\r\n## Why this Fork?\r\n\r\nThis is a specialized fork of `opencode-antigravity-auth` focused on **Safety** and **Reliability** for power users and autonomous agents.\r\n\r\n### 🛡️ Enhanced Protection\r\n- **Strict Quota Protocol (SQP)**: Enforces a **70% safety buffer** on API usage. Accounts are strictly locked *before* they hit Google's abuse limits.\r\n- **Leak-Proof Locking**: Locked accounts are ignored until their specific reset time passes, preventing \"leaky\" usage from cache expiry.\r\n\r\n### ⚡ Agent Stability\r\n- **Oh-My-OpenCode Integration**: Native support for session recovery. Automatically handles tool crashes and model \"thinking\" blocks without user intervention.\r\n- **Smart Proxy Support**: Enterprise-ready `undici` proxy support for complex network environments.\r\n- **Interactive Pause**: Gracefully pauses execution when quotas run low, allowing human intervention instead of crashing.\r\n\r\n## Key Features\r\n\r\n- **All Antigravity Models**: Claude Opus 4.6, Sonnet 4.6, and Gemini 3.1 Pro/Flash via Google OAuth.\r\n- **Thinking Models**: Configurable thinking budgets for complex reasoning tasks.\r\n- **Multi-Account Rotation**: Add unlimited Google accounts; the plugin auto-rotates based on health and quota.\r\n- **Dual Quota Pools**: Intelligently routes between Antigravity and Gemini CLI quotas.\r\n- **Google Search Grounding**: Enable real-time web search for Gemini models.\r\n\r\n---\r\n\r\n<details open>\r\n<summary><b>⚠️ Terms of Service Warning — Read Before Installing</b></summary>\r\n\r\n> [!CAUTION]\r\n> Using this plugin may violate Google's Terms of Service. A small number of users have reported their Google accounts being **banned** or **shadow-banned** (restricted access without explicit notification).\r\n>\r\n> **High-risk scenarios:**\r\n> - 🚨 **Fresh Google accounts** have a very high chance of getting banned\r\n> - 🚨 **New accounts with Pro/Ultra subscriptions** are frequently flagged and banned\r\n>\r\n> **By using this plugin, you acknowledge:**\r\n> - This is an unofficial tool not endorsed by Google\r\n> - Your account may be suspended or permanently banned\r\n> - You assume all risks associated with using this plugin\r\n>\r\n> **Recommendation:** Use an established Google account that you don't rely on for critical services. Avoid creating new accounts specifically for this plugin.\r\n\r\n</details>\r\n\r\n---\r\n\r\n## Installation\r\n\r\n<details open>\r\n<summary><b>For Humans</b></summary>\r\n\r\n**Option A: Let an LLM do it**\r\n\r\nPaste this into any LLM agent (Claude Code, OpenCode, Cursor, etc.):\r\n\r\n```\r\nInstall the @agungabadii/opencode-auth-ag plugin and add the Antigravity model definitions to ~/.config/opencode/opencode.json by following: https://raw.githubusercontent.com/agungprasastia/opencode-auth-ag/main/README.md\r\n```\r\n\r\n**Option B: Manual setup (NPM)**\r\n\r\n1. **Add the plugin** to `~/.config/opencode/opencode.json` (OpenCode will auto-install from NPM):\r\n\r\n   ```json\r\n   {\r\n     \"plugin\": [\"@agungabadii/opencode-auth-ag@latest\"]\r\n   }\r\n   ```\r\n\r\n   > Want bleeding-edge features? Use `@agungabadii/opencode-auth-ag@beta` instead.\r\n\r\n2. **Login** with your Google account:\r\n\r\n   ```bash\r\n   opencode auth login\r\n   ```\r\n\r\n3. **Add models** — choose one:\r\n   - Run `opencode auth login` → select **\"Configure models in opencode.json\"** (auto-configures all models)\r\n   - Or manually copy the [full configuration](#models) below\r\n\r\n4. **Use it:**\r\n\r\n   ```bash\r\n   opencode run \"Hello\" --model=google/antigravity-claude-sonnet-4-6-thinking --variant=max\r\n   ```\r\n\r\n</details>\r\n\r\n<details>\r\n<summary><b>For LLM Agents</b></summary>\r\n\r\n### Step-by-Step Instructions\r\n\r\n1. Edit the OpenCode configuration file at `~/.config/opencode/opencode.json`\r\n   \r\n   > **Note**: This path works on all platforms. On Windows, `~` resolves to your user home directory (e.g., `C:\\Users\\YourName`).\r\n\r\n2. Add the plugin to the `plugin` array\r\n\r\n3. Add the model definitions from the [Full models configuration](#models) section\r\n\r\n4. Set `provider` to `\"google\"` and choose a model\r\n\r\n### Verification\r\n\r\n```bash\r\nopencode run \"Hello\" --model=google/antigravity-claude-sonnet-4-6-thinking --variant=max\r\n```\r\n\r\n</details>\r\n\r\n\r\nFor a complete installation guide, including manual methods and advanced agent protocols, see [docs/INSTALLATION.md](docs/INSTALLATION.md).\r\n\r\n---\r\n\r\n## Models\r\n\r\n### Model Reference\r\n\r\n**Antigravity quota** (default routing for Claude and Gemini):\r\n\r\n| Model | Variants | Notes |\r\n|-------|----------|-------|\r\n| `antigravity-gemini-3.1-pro` | low, high | Gemini 3.1 Pro with thinking |\r\n| `antigravity-gemini-3-flash` | minimal, low, medium, high | Gemini 3 Flash with thinking |\r\n| `antigravity-claude-sonnet-4-6` | — | Claude Sonnet 4.6 |\r\n| `antigravity-claude-sonnet-4-6-thinking` | low, max | Claude Sonnet with extended thinking |\r\n\r\n| `antigravity-claude-opus-4-6-thinking` | low, max | Claude Opus 4.6 with extended thinking |\r\n\r\n**Gemini CLI quota** (separate from Antigravity; used when `cli_first` is true or as fallback):\r\n\r\n| Model | Notes |\r\n|-------|-------|\r\n| `gemini-2.5-flash` | Gemini 2.5 Flash |\r\n| `gemini-2.5-pro` | Gemini 2.5 Pro |\r\n| `gemini-3-flash-preview` | Gemini 3 Flash (preview) |\r\n| `gemini-3.1-pro-preview` | Gemini 3.1 Pro (preview) |\r\n\r\n> **Routing Behavior:**\r\n> - **Antigravity-first (default):** Gemini models use Antigravity quota across accounts.\r\n> - **CLI-first (`cli_first: true`):** Gemini models use Gemini CLI quota first.\r\n> - When a Gemini quota pool is exhausted, the plugin automatically falls back to the other pool.\r\n> - Claude and image models always use Antigravity.\r\n> Model names are automatically transformed for the target API (e.g., `antigravity-gemini-3-flash` → `gemini-3-flash-preview` for CLI).\r\n\r\n**Using variants:**\r\n```bash\r\nopencode run \"Hello\" --model=google/antigravity-claude-sonnet-4-6-thinking --variant=max\r\n```\r\n\r\nFor details on variant configuration and thinking levels, see [docs/MODEL-VARIANTS.md](docs/MODEL-VARIANTS.md).\r\n\r\n<details>\r\n<summary><b>Full models configuration (copy-paste ready)</b></summary>\r\n\r\nAdd this to your `~/.config/opencode/opencode.json`:\r\n\r\n```json\r\n{\r\n  \"$schema\": \"https://opencode.ai/config.json\",\r\n  \"plugin\": [\"@agungabadii/opencode-auth-ag@latest\"],\r\n  \"provider\": {\r\n    \"google\": {\r\n      \"models\": {\r\n        \"antigravity-gemini-3.1-pro\": {\r\n          \"name\": \"Gemini 3.1 Pro (Antigravity)\",\r\n          \"limit\": { \"context\": 1048576, \"output\": 65535 },\r\n          \"modalities\": { \"input\": [\"text\", \"image\", \"pdf\"], \"output\": [\"text\"] },\r\n          \"variants\": {\r\n            \"low\": { \"thinkingLevel\": \"low\" },\r\n            \"high\": { \"thinkingLevel\": \"high\" }\r\n          }\r\n        },\r\n        \"antigravity-gemini-3-flash\": {\r\n          \"name\": \"Gemini 3 Flash (Antigravity)\",\r\n          \"limit\": { \"context\": 1048576, \"output\": 65536 },\r\n          \"modalities\": { \"input\": [\"text\", \"image\", \"pdf\"], \"output\": [\"text\"] },\r\n          \"variants\": {\r\n            \"minimal\": { \"thinkingLevel\": \"minimal\" },\r\n            \"low\": { \"thinkingLevel\": \"low\" },\r\n            \"medium\": { \"thinkingLevel\": \"medium\" },\r\n            \"high\": { \"thinkingLevel\": \"high\" }\r\n          }\r\n        },\r\n        \"antigravity-claude-sonnet-4-6\": {\r\n          \"name\": \"Claude Sonnet 4.6 (Antigravity)\",\r\n          \"limit\": { \"context\": 200000, \"output\": 64000 },\r\n          \"modalities\": { \"input\": [\"text\", \"image\", \"pdf\"], \"output\": [\"text\"] }\r\n        },\r\n        \"antigravity-claude-sonnet-4-6-thinking\": {\r\n          \"name\": \"Claude Sonnet 4.6 Thinking (Antigravity)\",\r\n          \"limit\": { \"context\": 200000, \"output\": 64000 },\r\n          \"modalities\": { \"input\": [\"text\", \"image\", \"pdf\"], \"output\": [\"text\"] },\r\n          \"variants\": {\r\n            \"low\": { \"thinkingConfig\": { \"thinkingBudget\": 8192 } },\r\n            \"max\": { \"thinkingConfig\": { \"thinkingBudget\": 32768 } }\r\n          }\r\n        },\r\n\r\n        \"antigravity-claude-opus-4-6-thinking\": {\r\n          \"name\": \"Claude Opus 4.6 Thinking (Antigravity)\",\r\n          \"limit\": { \"context\": 200000, \"output\": 64000 },\r\n          \"modalities\": { \"input\": [\"text\", \"image\", \"pdf\"], \"output\": [\"text\"] },\r\n          \"variants\": {\r\n            \"low\": { \"thinkingConfig\": { \"thinkingBudget\": 8192 } },\r\n            \"max\": { \"thinkingConfig\": { \"thinkingBudget\": 32768 } }\r\n          }\r\n        },\r\n        \"gemini-2.5-flash\": {\r\n          \"name\": \"Gemini 2.5 Flash (Gemini CLI)\",\r\n          \"limit\": { \"context\": 1048576, \"output\": 65536 },\r\n          \"modalities\": { \"input\": [\"text\", \"image\", \"pdf\"], \"output\": [\"text\"] }\r\n        },\r\n        \"gemini-2.5-pro\": {\r\n          \"name\": \"Gemini 2.5 Pro (Gemini CLI)\",\r\n          \"limit\": { \"context\": 1048576, \"output\": 65536 },\r\n          \"modalities\": { \"input\": [\"text\", \"image\", \"pdf\"], \"output\": [\"text\"] }\r\n        },\r\n        \"gemini-3-flash-preview\": {\r\n          \"name\": \"Gemini 3 Flash Preview (Gemini CLI)\",\r\n          \"limit\": { \"context\": 1048576, \"output\": 65536 },\r\n          \"modalities\": { \"input\": [\"text\", \"image\", \"pdf\"], \"output\": [\"text\"] }\r\n        },\r\n        \"gemini-3.1-pro-preview\": {\r\n          \"name\": \"Gemini 3.1 Pro Preview (Gemini CLI)\",\r\n          \"limit\": { \"context\": 1048576, \"output\": 65535 },\r\n          \"modalities\": { \"input\": [\"text\", \"image\", \"pdf\"], \"output\": [\"text\"] }\r\n        }\r\n      }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n> **Backward Compatibility:** Legacy model names with `antigravity-` prefix (e.g., `antigravity-gemini-3-flash`) still work. The plugin automatically handles model name transformation for both Antigravity and Gemini CLI APIs.\r\n\r\n</details>\r\n\r\n---\r\n\r\n## Multi-Account Setup\r\n\r\nAdd multiple Google accounts for higher combined quotas. The plugin automatically rotates between accounts when one is rate-limited.\r\n\r\n```bash\r\nopencode auth login  # Run again to add more accounts\r\n```\r\n\r\n**Account management options (via `opencode auth login`):**\r\n- **Configure models** — Auto-configure all plugin models in opencode.json\r\n- **Check quotas** — View remaining API quota for each account\r\n- **Manage accounts** — Enable/disable specific accounts for rotation\r\n\r\nFor details on load balancing, dual quota pools, and account storage, see [docs/MULTI-ACCOUNT.md](docs/MULTI-ACCOUNT.md).\r\n\r\n---\r\n\r\n## Troubleshoot\r\n\r\n> **Quick Reset**: Most issues can be resolved by deleting `~/.config/opencode/antigravity-accounts.json` and running `opencode auth login` again.\r\n\r\n### Configuration Path (All Platforms)\r\n\r\nOpenCode uses `~/.config/opencode/` on **all platforms** including Windows.\r\n\r\n| File | Path |\r\n|------|------|\r\n| Main config | `~/.config/opencode/opencode.json` |\r\n| Accounts | `~/.config/opencode/antigravity-accounts.json` |\r\n| Plugin config | `~/.config/opencode/antigravity.json` |\r\n| Debug logs | `~/.config/opencode/antigravity-logs/` |\r\n\r\n> **Windows users**: `~` resolves to your user home directory (e.g., `C:\\Users\\YourName`). Do NOT use `%APPDATA%`.\r\n\r\n> **Custom path**: Set `OPENCODE_CONFIG_DIR` environment variable to use a custom location.\r\n\r\n> **Windows migration**: If upgrading from plugin v1.3.x or earlier, the plugin will automatically find your existing config in `%APPDATA%\\opencode\\` and use it. New installations use `~/.config/opencode/`.\r\n\r\n---\r\n\r\n### Multi-Account Auth Issues\r\n\r\nIf you encounter authentication issues with multiple accounts:\r\n\r\n1. Delete the accounts file:\r\n   ```bash\r\n   rm ~/.config/opencode/antigravity-accounts.json\r\n   ```\r\n2. Re-authenticate:\r\n   ```bash\r\n   opencode auth login\r\n   ```\r\n\r\n---\r\n\r\n### 403 Permission Denied (`rising-fact-p41fc`)\r\n\r\n**Error:**\r\n```\r\nPermission 'cloudaicompanion.companions.generateChat' denied on resource \r\n'//cloudaicompanion.googleapis.com/projects/rising-fact-p41fc/locations/global'\r\n```\r\n\r\n**Cause:** Plugin falls back to a default project ID when no valid project is found. This works for Antigravity but fails for Gemini CLI models.\r\n\r\n**Solution:**\r\n1. Go to [Google Cloud Console](https://console.cloud.google.com/)\r\n2. Create or select a project\r\n3. Enable the **Gemini for Google Cloud API** (`cloudaicompanion.googleapis.com`)\r\n4. Add `projectId` to your accounts file:\r\n   ```json\r\n   {\r\n     \"accounts\": [\r\n       {\r\n         \"email\": \"your@email.com\",\r\n         \"refreshToken\": \"...\",\r\n         \"projectId\": \"your-project-id\"\r\n       }\r\n     ]\r\n   }\r\n   ```\r\n\r\n> **Note**: Do this for each account in a multi-account setup.\r\n\r\n---\r\n\r\n### Gemini Model Not Found\r\n\r\nAdd this to your `google` provider config:\r\n\r\n```json\r\n{\r\n  \"provider\": {\r\n    \"google\": {\r\n      \"npm\": \"@ai-sdk/google\",\r\n      \"models\": { ... }\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n---\r\n\r\n### Gemini 3 Models 400 Error (\"Unknown name 'parameters'\")\r\n\r\n**Error:**\r\n```\r\nInvalid JSON payload received. Unknown name \"parameters\" at 'request.tools[0]'\r\n```\r\n\r\n**Causes:**\r\n- Tool schema incompatibility with Gemini's strict protobuf validation\r\n- MCP servers with malformed schemas\r\n- Plugin version regression\r\n\r\n**Solutions:**\r\n1. **Update to latest beta:**\r\n   ```json\r\n   { \"plugin\": [\"@agungabadii/opencode-auth-ag@beta\"] }\r\n   ```\r\n\r\n2. **Disable MCP servers** one-by-one to find the problematic one\r\n\r\n3. **Add npm override:**\r\n   ```json\r\n   { \"provider\": { \"google\": { \"npm\": \"@ai-sdk/google\" } } }\r\n   ```\r\n\r\n---\r\n\r\n### MCP Servers Causing Errors\r\n\r\nSome MCP servers have schemas incompatible with Antigravity's strict JSON format.\r\n\r\n**Common symptom:**\r\n```bash\r\nInvalid function name must start with a letter or underscore\r\n```\r\n\r\nSometimes it shows up as:\r\n```bash\r\nGenerateContentRequest.tools[0].function_declarations[12].name: Invalid function name must start with a letter or underscore\r\n```\r\n\r\nThis usually means an MCP tool name starts with a number (for example, a 1mcp key like `1mcp_*`). Rename the MCP key to start with a letter (e.g., `gw`) or disable that MCP entry for Antigravity models.\r\n\r\n**Diagnosis:**\r\n1. Disable all MCP servers in your config\r\n2. Enable one-by-one until error reappears\r\n3. Report the specific MCP in a [GitHub issue](https://github.com/agungprasastia/opencode-auth-ag/issues)\r\n\r\n---\r\n\r\n### \"All Accounts Rate-Limited\" (But Quota Available)\r\n\r\n**Cause:** Cascade bug in `clearExpiredRateLimits()` in hybrid mode (fixed in recent beta).\r\n\r\n**Solutions:**\r\n1. Update to latest beta version\r\n2. If persists, delete accounts file and re-authenticate\r\n3. Try switching `account_selection_strategy` to `\"sticky\"` in `antigravity.json`\r\n\r\n---\r\n\r\n### Session Recovery\r\n\r\nIf you encounter errors during a session:\r\n1. Type `continue` to trigger the recovery mechanism\r\n2. If blocked, use `/undo` to revert to pre-error state\r\n3. Retry the operation\r\n\r\n---\r\n\r\n### Using with Oh-My-OpenCode\r\n\r\n**Important:** Disable the built-in Google auth to prevent conflicts:\r\n\r\n```json\r\n// ~/.config/opencode/oh-my-opencode.json\r\n{\r\n  \"google_auth\": false,\r\n  \"agents\": {\r\n    \"frontend-ui-ux-engineer\": { \"model\": \"google/gemini-3.1-pro\" },\r\n    \"document-writer\": { \"model\": \"google/gemini-3-flash\" },\r\n    \"multimodal-looker\": { \"model\": \"google/gemini-3-flash\" }\r\n  }\r\n}\r\n```\r\n\r\n---\r\n\r\n### Infinite `.tmp` Files Created\r\n\r\n**Cause:** When account is rate-limited and plugin retries infinitely, it creates many temp files.\r\n\r\n**Workaround:**\r\n1. Stop OpenCode\r\n2. Clean up: `rm ~/.config/opencode/*.tmp`\r\n3. Add more accounts or wait for rate limit to expire\r\n\r\n---\r\n\r\n### OAuth Callback Issues\r\n\r\n<details>\r\n<summary><b>Safari OAuth Callback Fails (macOS)</b></summary>\r\n\r\n**Symptoms:**\r\n- \"fail to authorize\" after successful Google login\r\n- Safari shows \"Safari can't open the page\"\r\n\r\n**Cause:** Safari's \"HTTPS-Only Mode\" blocks `http://localhost` callback.\r\n\r\n**Solutions:**\r\n\r\n1. **Use Chrome or Firefox** (easiest):\r\n   Copy the OAuth URL and paste into a different browser.\r\n\r\n2. **Disable HTTPS-Only Mode temporarily:**\r\n   - Safari > Settings (⌘,) > Privacy\r\n   - Uncheck \"Enable HTTPS-Only Mode\"\r\n   - Run `opencode auth login`\r\n   - Re-enable after authentication\r\n\r\n</details>\r\n\r\n<details>\r\n<summary><b>Port Conflict (Address Already in Use)</b></summary>\r\n\r\n**macOS / Linux:**\r\n```bash\r\n# Find process using the port\r\nlsof -i :51121\r\n\r\n# Kill if stale\r\nkill -9 <PID>\r\n\r\n# Retry\r\nopencode auth login\r\n```\r\n\r\n**Windows (PowerShell):**\r\n```powershell\r\nnetstat -ano | findstr :51121\r\ntaskkill /PID <PID> /F\r\nopencode auth login\r\n```\r\n\r\n</details>\r\n\r\n<details>\r\n<summary><b>Docker / WSL2 / Remote Development</b></summary>\r\n\r\nOAuth callback requires browser to reach `localhost` on the machine running OpenCode.\r\n\r\n**WSL2:**\r\n- Use VS Code's port forwarding, or\r\n- Configure Windows → WSL port forwarding\r\n\r\n**SSH / Remote:**\r\n```bash\r\nssh -L 51121:localhost:51121 user@remote\r\n```\r\n\r\n**Docker / Containers:**\r\n- OAuth with localhost redirect doesn't work in containers\r\n- Wait 30s for manual URL flow, or use SSH port forwarding\r\n\r\n</details>\r\n\r\n---\r\n\r\n### Configuration Key Typo: `plugin` not `plugins`\r\n\r\nThe correct key is `plugin` (singular):\r\n\r\n```json\r\n{\r\n  \"plugin\": [\"@agungabadii/opencode-auth-ag@beta\"]\r\n}\r\n```\r\n\r\n**Not** `\"plugins\"` (will cause \"Unrecognized key\" error).\r\n\r\n---\r\n\r\n### Migrating Accounts Between Machines\r\n\r\nWhen copying `antigravity-accounts.json` to a new machine:\r\n1. Ensure the plugin is installed: `\"plugin\": [\"@agungabadii/opencode-auth-ag@beta\"]`\r\n2. Copy `~/.config/opencode/antigravity-accounts.json`\r\n3. If you get \"API key missing\" error, the refresh token may be invalid — re-authenticate\r\n\r\n## Known Plugin Interactions\r\nFor details on load balancing, dual quota pools, and account storage, see [docs/MULTI-ACCOUNT.md](docs/MULTI-ACCOUNT.md).\r\n\r\n---\r\n\r\n## Plugin Compatibility\r\n\r\n### @tarquinen/opencode-dcp\r\n\r\nDCP creates synthetic assistant messages that lack thinking blocks. **List this plugin BEFORE DCP:**\r\n\r\n```json\r\n{\r\n  \"plugin\": [\r\n    \"@agungabadii/opencode-auth-ag@latest\",\r\n    \"@tarquinen/opencode-dcp@latest\"\r\n  ]\r\n}\r\n```\r\n\r\n### oh-my-opencode\r\n\r\nDisable built-in auth and override agent models in `oh-my-opencode.json`:\r\n\r\n```json\r\n{\r\n  \"google_auth\": false,\r\n  \"agents\": {\r\n    \"frontend-ui-ux-engineer\": { \"model\": \"google/antigravity-gemini-3.1-pro\" },\r\n    \"document-writer\": { \"model\": \"google/antigravity-gemini-3-flash\" },\r\n    \"multimodal-looker\": { \"model\": \"google/antigravity-gemini-3-flash\" }\r\n  }\r\n}\r\n```\r\n\r\n> **Tip:** When spawning parallel subagents, enable `pid_offset_enabled: true` in `antigravity.json` to distribute sessions across accounts.\r\n\r\n### Plugins you don't need\r\n\r\n- **gemini-auth plugins** — Not needed. This plugin handles all Google OAuth.\r\n\r\n---\r\n\r\n## Configuration\r\n\r\nCreate `~/.config/opencode/antigravity.json` for optional settings:\r\n\r\n```json\r\n{\r\n  \"$schema\": \"https://raw.githubusercontent.com/agungprasastia/opencode-auth-ag/main/assets/antigravity.schema.json\"\r\n}\r\n```\r\n\r\nMost users don't need to configure anything — defaults work well.\r\n\r\n### Model Behavior\r\n\r\n| Option | Default | What it does |\r\n|--------|---------|--------------\r\n| `keep_thinking` | `false` | Preserve Claude's thinking across turns. **Warning:** enabling may degrade model stability. |\r\n| `session_recovery` | `true` | Auto-recover from tool errors |\r\n| `cli_first` | `false` | Route Gemini models to Gemini CLI first (Claude and image models stay on Antigravity). |\r\n\r\n### Account Rotation\r\n\r\n| Your Setup | Recommended Config |\r\n|------------|-------------------|\r\n| **1 account** | `\"account_selection_strategy\": \"sticky\"` |\r\n| **2-5 accounts** | Default (`\"hybrid\"`) works great |\r\n| **5+ accounts** | `\"account_selection_strategy\": \"round-robin\"` |\r\n| **Parallel agents** | Add `\"pid_offset_enabled\": true` |\r\n\r\n### Quota Protection\r\n\r\n| Option | Default | What it does |\r\n|--------|---------|--------------|\r\n| `soft_quota_threshold_percent` | `90` | Skip account when quota usage exceeds this percentage. Prevents Google from penalizing accounts that fully exhaust quota. Set to `100` to disable. |\r\n| `quota_refresh_interval_minutes` | `15` | Background quota refresh interval. After successful API requests, refreshes quota cache if older than this interval. Set to `0` to disable. |\r\n| `soft_quota_cache_ttl_minutes` | `\"auto\"` | How long quota cache is considered fresh. `\"auto\"` = max(2 × refresh interval, 10 minutes). Set a number (1-120) for fixed TTL. |\r\n\r\n> **How it works**: Quota cache is refreshed automatically after API requests (when older than `quota_refresh_interval_minutes`) and manually via \"Check quotas\" in `opencode auth login`. The threshold check uses `soft_quota_cache_ttl_minutes` to determine cache freshness - if cache is older, the account is considered \"unknown\" and allowed (fail-open). When ALL accounts exceed the threshold, the plugin waits for the earliest quota reset time (like rate limit behavior). If wait time exceeds `max_rate_limit_wait_seconds`, it errors immediately.\r\n\r\n### Rate Limit Scheduling\r\n\r\nControl how the plugin handles rate limits:\r\n\r\n| Option | Default | What it does |\r\n|--------|---------|--------------|\r\n| `scheduling_mode` | `\"cache_first\"` | `\"cache_first\"` = wait for same account (preserves prompt cache), `\"balance\"` = switch immediately, `\"performance_first\"` = round-robin |\r\n| `max_cache_first_wait_seconds` | `60` | Max seconds to wait in cache_first mode before switching accounts |\r\n| `failure_ttl_seconds` | `3600` | Reset failure count after this many seconds (prevents old failures from permanently penalizing accounts) |\r\n\r\n**When to use each mode:**\r\n- **cache_first** (default): Best for long conversations. Waits for the same account to recover, preserving your prompt cache.\r\n- **balance**: Best for quick tasks. Switches accounts immediately when rate-limited for maximum availability.\r\n- **performance_first**: Best for many short requests. Distributes load evenly across all accounts.\r\n\r\n### App Behavior\r\n\r\n| Option | Default | What it does |\r\n|--------|---------|--------------|\r\n| `quiet_mode` | `false` | Hide toast notifications |\r\n| `debug` | `false` | Enable debug logging |\r\n| `auto_update` | `true` | Auto-update plugin |\r\n\r\nFor all options, see [docs/CONFIGURATION.md](docs/CONFIGURATION.md).\r\n\r\n**Environment variables:**\r\n```bash\r\nOPENCODE_CONFIG_DIR=/path/to/config opencode  # Custom config directory\r\nOPENCODE_ANTIGRAVITY_DEBUG=1 opencode         # Enable debug logging\r\nOPENCODE_ANTIGRAVITY_DEBUG=2 opencode         # Verbose logging\r\n```\r\n\r\n---\r\n\r\n## Troubleshooting\r\n\r\nSee the full [Troubleshooting Guide](docs/TROUBLESHOOTING.md) for solutions to common issues including:\r\n\r\n- Auth problems and token refresh\r\n- \"Model not found\" errors\r\n- Session recovery\r\n- Gemini CLI permission errors\r\n- Safari OAuth issues\r\n- Plugin compatibility\r\n- Migration guides\r\n\r\n---\r\n\r\n## Documentation\r\n\r\n- [Configuration](docs/CONFIGURATION.md) — All configuration options\r\n- [Multi-Account](docs/MULTI-ACCOUNT.md) — Load balancing, dual quota pools, account storage\r\n- [Model Variants](docs/MODEL-VARIANTS.md) — Thinking budgets and variant system\r\n- [Troubleshooting](docs/TROUBLESHOOTING.md) — Common issues and fixes\r\n- [Architecture](docs/ARCHITECTURE.md) — How the plugin works\r\n- [API Spec](docs/ANTIGRAVITY_API_SPEC.md) — Antigravity API reference\r\n\r\n---\r\n\r\n## Support & Community\r\n \r\nIf this plugin helps your workflow, consider supporting its development:\r\n\r\n- **[GitHub](https://github.com/agungprasastia/opencode-auth-ag)** — Star the repo!\r\n \r\n---\r\n \r\n## Credits\r\n\r\nThis project is built upon the work of incredible developers:\r\n\r\n- **[jenslys](https://github.com/jenslys)** - Original creator of [opencode-gemini-auth](https://github.com/jenslys/opencode-gemini-auth) (Basis for Gemini CLI auth).\r\n- **[NoeFabris](https://github.com/NoeFabris)** - Added Antigravity support in [opencode-antigravity-auth](https://github.com/NoeFabris/opencode-antigravity-auth) (Multi-account support).\r\n- **[Andy Vandaric](https://github.com/andyvandaric)** - **Enhanced Protection & Stability**:\r\n  - **Strict Quota Protocol**: Custom safety algorithm with **70% usage threshold** (30% safety buffer). Accounts are strictly locked until their specific reset time passes, preventing \"leaky\" usage from cache expiry.\r\n  - **Oh-My-OpenCode Integration**: Full session recovery for tool crashes and thinking block errors.\r\n  - **Enterprise Feat**: Proxy support via `undici`.\r\n  - **UX/Fixes**: Interactive quota pause and Cloud Code API header fixes.\r\n- **[Agung Prasasti Abadi](https://github.com/agungprasastia)** - **Anti-Ban Safe Mode**:\r\n  - **Fingerprint Lock**: Persistent device identity, no regeneration on rate limit.\r\n  - **Single Quota Identity**: Prevents UA flip-flop between Antigravity/Gemini CLI headers.\r\n  - **Prod-Only Endpoints**: Blocks sandbox/autopush access for personal accounts.\r\n  - **Adaptive Request Pacer**: Smart burst detection with zero-delay normal usage.\r\n\r\n### Community Contributors\r\n- **[aaronsewall](https://github.com/aaronsewall)** - Added HTTP/HTTPS proxy support (#301).\r\n- **[sunbos](https://github.com/sunbos)** - Logic for Oh-My-OpenCode integration (#349).\r\n- **[m2m6vrm5fp-source](https://github.com/m2m6vrm5fp-source)** - Fixed Gemini 400 errors for empty properties (#319).\r\n- **[jcromero](https://github.com/jcromero)** - Added interactive pause feature (#443).\r\n- **[mynameistito](https://github.com/mynameistito)** - Cleaned up deprecated models (#437).\r\n\r\nSpecial thanks to [CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI).\r\n\r\n## License\r\n\r\nMIT License. See [LICENSE](LICENSE) for details.\r\n\r\n<details>\r\n<summary><b>Legal</b></summary>\r\n\r\n### Intended Use\r\n\r\n- Personal / internal development only\r\n- Respect internal quotas and data handling policies\r\n- Not for production services or bypassing intended limits\r\n\r\n### Warning\r\n\r\nBy using this plugin, you acknowledge:\r\n\r\n- **Terms of Service risk** — This approach may violate ToS of AI model providers\r\n- **Account risk** — Providers may suspend or ban accounts\r\n- **No guarantees** — APIs may change without notice\r\n- **Assumption of risk** — You assume all legal, financial, and technical risks\r\n\r\n### Disclaimer\r\n\r\n- Not affiliated with Google. This is an independent open-source project.\r\n- \"Antigravity\", \"Gemini\", \"Google Cloud\", and \"Google\" are trademarks of Google LLC.\r\n\r\n</details>\r\n","readmeFilename":"README.md"}