@benjamolina/opencode-antigravity-guard 1.0.0 → 1.1.1

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.
package/README.md CHANGED
@@ -1,773 +1,773 @@
1
- # Antigravity + Gemini CLI OAuth Plugin for Opencode
2
-
3
- [![npm version](https://img.shields.io/npm/v/opencode-antigravity-auth-updated.svg)](https://www.npmjs.com/package/opencode-antigravity-auth-updated)
4
- [![npm beta](https://img.shields.io/npm/v/opencode-antigravity-auth-updated/beta.svg?label=beta)](https://www.npmjs.com/package/opencode-antigravity-auth-updated)
5
- [![npm downloads](https://img.shields.io/npm/dw/opencode-antigravity-auth-updated.svg)](https://www.npmjs.com/package/opencode-antigravity-auth-updated)
6
- [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
7
- [![X (Twitter)](https://img.shields.io/badge/X-@dopesalmon-000000?style=flat&logo=x)](https://x.com/dopesalmon)
8
-
9
- Enable Opencode to authenticate against **Antigravity** (Google's IDE) via OAuth so you can use Antigravity rate limits and access models like `gemini-3.1-pro` and `claude-opus-4-6-thinking` with your Google credentials.
10
-
11
- ## What You Get
12
-
13
- - **Claude Opus 4.6, Sonnet 4.6** and **Gemini 3.1 Pro/Flash** via Google OAuth
14
- - **Multi-account support** — add multiple Google accounts, auto-rotates when rate-limited
15
- - **Modern Gemini API support** — use Antigravity SDK-style API keys / Cloud Projects as Gemini backups or opt-in primary routing
16
- - **Legacy Gemini CLI quota support** — still available for compatibility and quota fallback
17
- - **Thinking models** — extended thinking for Claude and Gemini 3 with configurable budgets
18
- - **Google Search grounding** — enable web search for Gemini models (auto or always-on)
19
- - **Auto-recovery** — handles session errors and tool failures automatically
20
- - **Plugin compatible** — works alongside other OpenCode plugins (oh-my-opencode, dcp, etc.)
21
-
22
- ---
23
-
24
- <details open>
25
- <summary><b>⚠️ Terms of Service Warning — Read Before Installing</b></summary>
26
-
27
- > [!CAUTION]
28
- > Using this plugin (and any proxy for Antigravity) violates Google's Terms of Service. A number of users have reported their Google accounts being **banned** or **shadow-banned** (restricted access without explicit notification).
29
- >
30
- > **By using this plugin, you acknowledge:**
31
- > - This is an unofficial tool not endorsed by Google
32
- > - Your account may be suspended or permanently banned
33
- > - You assume all risks associated with using this plugin
34
- >
35
-
36
- </details>
37
-
38
- ---
39
-
40
- ## Installation
41
-
42
- <details open>
43
- <summary><b>For Humans</b></summary>
44
-
45
- **Option A: Let an LLM do it**
46
-
47
- Paste this into any LLM agent (Claude Code, OpenCode, Cursor, etc.):
48
-
49
- ```
50
- Install the opencode-antigravity-auth-updated plugin and add the Antigravity model definitions to ~/.config/opencode/opencode.json by following: https://raw.githubusercontent.com/insign/opencode-antigravity-auth-updated/main/README.md
51
- ```
52
-
53
- **Option B: Manual setup**
54
-
55
- 1. **Add the plugin** to `~/.config/opencode/opencode.json`:
56
-
57
- ```json
58
- {
59
- "plugin": ["opencode-antigravity-auth-updated@latest"]
60
- }
61
- ```
62
-
63
- > Want bleeding-edge features? Use `opencode-antigravity-auth-updated@beta` instead.
64
-
65
- 2. **Login** with your Google account:
66
-
67
- ```bash
68
- opencode auth login
69
- ```
70
-
71
- 3. **Models** — current OpenCode versions can load plugin models dynamically at runtime. If your OpenCode version still requires static provider config, choose one:
72
- - Run `opencode auth login` → Google → OAuth with Google (Antigravity) → select **"Configure models in opencode.json"** (auto-configures all models)
73
- - Or manually copy the [full configuration](#models) below
74
-
75
- 4. **Use it:**
76
-
77
- ```bash
78
- opencode run "Hello" --model=google/antigravity-claude-opus-4-6-thinking --variant=max
79
- ```
80
-
81
- </details>
82
-
83
- <details>
84
- <summary><b>For LLM Agents</b></summary>
85
-
86
- ### Step-by-Step Instructions
87
-
88
- 1. Edit the OpenCode configuration file at `~/.config/opencode/opencode.json`
89
-
90
- > **Note**: This path works on all platforms. On Windows, `~` resolves to your user home directory (e.g., `C:\Users\YourName`).
91
-
92
- 2. Add the plugin to the `plugin` array
93
-
94
- 3. Add the model definitions from the [Full models configuration](#models) section
95
-
96
- 4. Set `provider` to `"google"` and choose a model
97
-
98
- ### Verification
99
-
100
- ```bash
101
- opencode run "Hello" --model=google/antigravity-claude-opus-4-6-thinking --variant=max
102
- ```
103
-
104
- </details>
105
-
106
- ---
107
-
108
- ## Models
109
-
110
- ### Model Reference
111
-
112
- **Antigravity quota** (default routing for Claude and Gemini):
113
-
114
- | Model | Variants | Notes |
115
- |-------|----------|-------|
116
- | `antigravity-gemini-3-pro` | low, high | Gemini 3 Pro with thinking |
117
- | `antigravity-gemini-3.1-pro` | low, high | Gemini 3.1 Pro with thinking (rollout-dependent) |
118
- | `antigravity-gemini-3-flash` | minimal, low, medium, high | Gemini 3 Flash with thinking |
119
- | `antigravity-gemini-3.5-flash` | minimal, low, medium, high | Gemini 3.5 Flash with thinking (rollout-dependent) |
120
- | `antigravity-claude-sonnet-4-6` | — | Claude Sonnet 4.6 |
121
- | `antigravity-claude-opus-4-6-thinking` | low, max | Claude Opus 4.6 with extended thinking |
122
-
123
- **Antigravity SDK / Gemini API projects** (API-key backed; used by API-key auth, or as OAuth fallback when configured):
124
-
125
- The official Antigravity SDK uses `GEMINI_API_KEY` for local Gemini access. This plugin now supports that path directly for Gemini models while keeping OAuth accounts for Antigravity and Claude.
126
-
127
- **Legacy Gemini CLI quota** (separate from Antigravity; used when `cli_first` is true or as fallback):
128
-
129
- | Model | Notes |
130
- |-------|-------|
131
- | `gemini-2.5-flash` | Gemini 2.5 Flash |
132
- | `gemini-2.5-pro` | Gemini 2.5 Pro |
133
- | `gemini-3-flash-preview` | Gemini 3 Flash (preview) |
134
- | `gemini-3.5-flash` | Gemini 3.5 Flash (rollout-dependent) |
135
- | `gemini-3-pro-preview` | Gemini 3 Pro (preview) |
136
- | `gemini-3.1-pro` | Gemini 3.1 Pro |
137
- | `gemini-3.1-pro-preview-customtools` | Gemini 3.1 Pro Preview Custom Tools |
138
-
139
- > **Routing Behavior:**
140
- > - **OAuth Antigravity-first (default):** Gemini models use Antigravity quota across OAuth accounts.
141
- > - **Antigravity SDK / Gemini API:** API-key auth, `GEMINI_API_KEY`, or configured `agy_sdk.cloud_projects` route Gemini requests through the public Gemini API.
142
- > - **Legacy CLI-first (`cli_first: true`):** Gemini models use the legacy Gemini CLI quota first.
143
- > - When OAuth quota pools are exhausted, configured `agy_sdk.cloud_projects` are used as backup capacity before failing if `agy_sdk.enabled: true`, `agy_sdk.api_key_fallback: true`, and usable API-key credentials are present.
144
- > - Claude and image models always use Antigravity.
145
- > Model names are automatically transformed for the target API (e.g., `antigravity-gemini-3-flash` → `gemini-3-flash-preview` for CLI).
146
-
147
- **Using variants:**
148
- ```bash
149
- opencode run "Hello" --model=google/antigravity-claude-opus-4-6-thinking --variant=max
150
- ```
151
-
152
- For details on variant configuration and thinking levels, see [docs/MODEL-VARIANTS.md](docs/MODEL-VARIANTS.md).
153
-
154
- <details>
155
- <summary><b>Full models configuration (copy-paste ready)</b></summary>
156
-
157
- Add this to your `~/.config/opencode/opencode.json`:
158
-
159
- ```json
160
- {
161
- "$schema": "https://opencode.ai/config.json",
162
- "plugin": ["opencode-antigravity-auth-updated@latest"],
163
- "provider": {
164
- "google": {
165
- "models": {
166
- "antigravity-gemini-3-pro": {
167
- "name": "Gemini 3 Pro (Antigravity)",
168
- "limit": { "context": 1048576, "output": 65535 },
169
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
170
- "variants": {
171
- "low": { "thinkingLevel": "low" },
172
- "high": { "thinkingLevel": "high" }
173
- }
174
- },
175
- "antigravity-gemini-3.1-pro": {
176
- "name": "Gemini 3.1 Pro (Antigravity)",
177
- "limit": { "context": 1048576, "output": 65535 },
178
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
179
- "variants": {
180
- "low": { "thinkingLevel": "low" },
181
- "high": { "thinkingLevel": "high" }
182
- }
183
- },
184
- "antigravity-gemini-3-flash": {
185
- "name": "Gemini 3 Flash (Antigravity)",
186
- "limit": { "context": 1048576, "output": 65536 },
187
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
188
- "variants": {
189
- "minimal": { "thinkingLevel": "minimal" },
190
- "low": { "thinkingLevel": "low" },
191
- "medium": { "thinkingLevel": "medium" },
192
- "high": { "thinkingLevel": "high" }
193
- }
194
- },
195
- "antigravity-gemini-3.5-flash": {
196
- "name": "Gemini 3.5 Flash (Antigravity)",
197
- "limit": { "context": 1048576, "output": 65536 },
198
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
199
- "variants": {
200
- "minimal": { "thinkingLevel": "minimal" },
201
- "low": { "thinkingLevel": "low" },
202
- "medium": { "thinkingLevel": "medium" },
203
- "high": { "thinkingLevel": "high" }
204
- }
205
- },
206
- "antigravity-claude-sonnet-4-6": {
207
- "name": "Claude Sonnet 4.6 (Antigravity)",
208
- "limit": { "context": 200000, "output": 64000 },
209
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
210
- },
211
- "antigravity-claude-opus-4-6-thinking": {
212
- "name": "Claude Opus 4.6 Thinking (Antigravity)",
213
- "limit": { "context": 200000, "output": 64000 },
214
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
215
- "variants": {
216
- "low": { "thinkingConfig": { "thinkingBudget": 8192 } },
217
- "max": { "thinkingConfig": { "thinkingBudget": 32768 } }
218
- }
219
- },
220
- "gemini-2.5-flash": {
221
- "name": "Gemini 2.5 Flash (Gemini CLI)",
222
- "limit": { "context": 1048576, "output": 65536 },
223
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
224
- },
225
- "gemini-2.5-pro": {
226
- "name": "Gemini 2.5 Pro (Gemini CLI)",
227
- "limit": { "context": 1048576, "output": 65536 },
228
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
229
- },
230
- "gemini-3-flash-preview": {
231
- "name": "Gemini 3 Flash Preview (Gemini CLI)",
232
- "limit": { "context": 1048576, "output": 65536 },
233
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
234
- },
235
- "gemini-3.5-flash": {
236
- "name": "Gemini 3.5 Flash (Gemini CLI)",
237
- "limit": { "context": 1048576, "output": 65536 },
238
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
239
- },
240
- "gemini-3-pro-preview": {
241
- "name": "Gemini 3 Pro Preview (Gemini CLI)",
242
- "limit": { "context": 1048576, "output": 65535 },
243
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
244
- },
245
- "gemini-3.1-pro": {
246
- "name": "Gemini 3.1 Pro (Gemini CLI)",
247
- "limit": { "context": 1048576, "output": 65535 },
248
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
249
- },
250
- "gemini-3.1-pro-preview-customtools": {
251
- "name": "Gemini 3.1 Pro Preview Custom Tools (Gemini CLI)",
252
- "limit": { "context": 1048576, "output": 65535 },
253
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
254
- }
255
- }
256
- }
257
- }
258
- }
259
- ```
260
-
261
- > **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.
262
-
263
- </details>
264
-
265
- ---
266
-
267
- ## Multi-Account Setup
268
-
269
- Add multiple Google accounts for a higher combined quota. The plugin automatically rotates between accounts when one is rate-limited.
270
-
271
- ```bash
272
- opencode auth login # Run again to add more accounts
273
- ```
274
-
275
- **Account management options (via `opencode auth login`):**
276
- - **Configure models** — Auto-configure all plugin models in opencode.json
277
- - **Check quotas** — View remaining API quota for each account
278
- - **Manage accounts** — Enable/disable specific accounts for rotation
279
-
280
- For details on load balancing, dual quota pools, and account storage, see [docs/MULTI-ACCOUNT.md](docs/MULTI-ACCOUNT.md).
281
-
282
- ---
283
-
284
- ## Troubleshooting
285
-
286
- > **Quick Reset**: Most issues can be resolved by deleting `~/.config/opencode/antigravity-accounts.json` and running `opencode auth login` again.
287
-
288
- ### Configuration Path (All Platforms)
289
-
290
- OpenCode uses `~/.config/opencode/` on **all platforms** including Windows.
291
-
292
- | File | Path |
293
- |------|------|
294
- | Main config | `~/.config/opencode/opencode.json` |
295
- | Accounts | `~/.config/opencode/antigravity-accounts.json` |
296
- | Plugin config | `~/.config/opencode/antigravity.json` |
297
- | Debug logs | `~/.config/opencode/antigravity-logs/` |
298
-
299
- > **Windows users**: `~` resolves to your user home directory (e.g., `C:\Users\YourName`). Do NOT use `%APPDATA%`.
300
-
301
- > **Custom path**: Set `OPENCODE_CONFIG_DIR` environment variable to use a custom location.
302
-
303
- > **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/`.
304
-
305
- ---
306
-
307
- ### Multi-Account Auth Issues
308
-
309
- If you encounter authentication issues with multiple accounts:
310
-
311
- 1. Delete the accounts file:
312
- ```bash
313
- rm ~/.config/opencode/antigravity-accounts.json
314
- ```
315
- 2. Re-authenticate:
316
- ```bash
317
- opencode auth login
318
- ```
319
-
320
- ---
321
-
322
- ### 403 Permission Denied (`rising-fact-p41fc`)
323
-
324
- **Error:**
325
- ```
326
- Permission 'cloudaicompanion.companions.generateChat' denied on resource
327
- '//cloudaicompanion.googleapis.com/projects/rising-fact-p41fc/locations/global'
328
- ```
329
-
330
- **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.
331
-
332
- **Solution:**
333
- 1. Go to [Google Cloud Console](https://console.cloud.google.com/)
334
- 2. Create or select a project
335
- 3. Enable the **Gemini for Google Cloud API** (`cloudaicompanion.googleapis.com`)
336
- 4. Add `projectId` to your accounts file:
337
- ```json
338
- {
339
- "accounts": [
340
- {
341
- "email": "your@email.com",
342
- "refreshToken": "...",
343
- "projectId": "your-project-id"
344
- }
345
- ]
346
- }
347
- ```
348
-
349
- > **Note**: Do this for each account in a multi-account setup.
350
-
351
- ---
352
-
353
- ### Gemini Model Not Found
354
-
355
- Add this to your `google` provider config:
356
-
357
- ```json
358
- {
359
- "provider": {
360
- "google": {
361
- "npm": "@ai-sdk/google",
362
- "models": { ... }
363
- }
364
- }
365
- }
366
- ```
367
-
368
- ---
369
-
370
- ### Gemini 3 Models 400 Error ("Unknown name 'parameters'")
371
-
372
- **Error:**
373
- ```
374
- Invalid JSON payload received. Unknown name "parameters" at 'request.tools[0]'
375
- ```
376
-
377
- **Causes:**
378
- - Tool schema incompatibility with Gemini's strict protobuf validation
379
- - MCP servers with malformed schemas
380
- - Plugin version regression
381
-
382
- **Solutions:**
383
- 1. **Update to latest beta:**
384
- ```json
385
- { "plugin": ["opencode-antigravity-auth-updated@beta"] }
386
- ```
387
-
388
- 2. **Disable MCP servers** one-by-one to find the problematic one
389
-
390
- 3. **Add npm override:**
391
- ```json
392
- { "provider": { "google": { "npm": "@ai-sdk/google" } } }
393
- ```
394
-
395
- ---
396
-
397
- ### MCP Servers Causing Errors
398
-
399
- Some MCP servers have schemas incompatible with Antigravity's strict JSON format.
400
-
401
- **Common symptom:**
402
- ```bash
403
- Invalid function name must start with a letter or underscore
404
- ```
405
-
406
- Sometimes it shows up as:
407
- ```bash
408
- GenerateContentRequest.tools[0].function_declarations[12].name: Invalid function name must start with a letter or underscore
409
- ```
410
-
411
- This 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.
412
-
413
- **Diagnosis:**
414
- 1. Disable all MCP servers in your config
415
- 2. Enable one-by-one until error reappears
416
- 3. Report the specific MCP in a [GitHub issue](https://github.com/insign/opencode-antigravity-auth-updated/issues)
417
-
418
- ---
419
-
420
- ### "All Accounts Rate-Limited" (But Quota Available)
421
-
422
- **Cause:** Cascade bug in `clearExpiredRateLimits()` in hybrid mode (fixed in recent beta).
423
-
424
- **Solutions:**
425
- 1. Update to latest beta version
426
- 2. If persists, delete accounts file and re-authenticate
427
- 3. Try switching `account_selection_strategy` to `"sticky"` in `antigravity.json`
428
-
429
- ---
430
-
431
- ### Session Recovery
432
-
433
- If you encounter errors during a session:
434
- 1. Type `continue` to trigger the recovery mechanism
435
- 2. If blocked, use `/undo` to revert to pre-error state
436
- 3. Retry the operation
437
-
438
- ---
439
-
440
- ### Using with Oh-My-OpenCode
441
-
442
- **Important:** Disable the built-in Google auth to prevent conflicts:
443
-
444
- ```json
445
- // ~/.config/opencode/oh-my-opencode.json
446
- {
447
- "google_auth": false,
448
- "categories": {
449
- "visual-engineering": { "model": "google/gemini-3-pro" },
450
- "writing": { "model": "google/gemini-3-flash" }
451
- }
452
- }
453
- ```
454
-
455
- ---
456
-
457
- ### Infinite `.tmp` Files Created
458
-
459
- **Cause:** When account is rate-limited and plugin retries infinitely, it creates many temp files.
460
-
461
- **Workaround:**
462
- 1. Stop OpenCode
463
- 2. Clean up: `rm ~/.config/opencode/*.tmp`
464
- 3. Add more accounts or wait for rate limit to expire
465
-
466
- ---
467
-
468
- ### OAuth Callback Issues
469
-
470
- <details>
471
- <summary><b>Safari OAuth Callback Fails (macOS)</b></summary>
472
-
473
- **Symptoms:**
474
- - "fail to authorize" after successful Google login
475
- - Safari shows "Safari can't open the page"
476
-
477
- **Cause:** Safari's "HTTPS-Only Mode" blocks `http://localhost` callback.
478
-
479
- **Solutions:**
480
-
481
- 1. **Use Chrome or Firefox** (easiest):
482
- Copy the OAuth URL and paste into a different browser.
483
-
484
- 2. **Disable HTTPS-Only Mode temporarily:**
485
- - Safari > Settings (⌘,) > Privacy
486
- - Uncheck "Enable HTTPS-Only Mode"
487
- - Run `opencode auth login`
488
- - Re-enable after authentication
489
-
490
- </details>
491
-
492
- <details>
493
- <summary><b>Port Conflict (Address Already in Use)</b></summary>
494
-
495
- **macOS / Linux:**
496
- ```bash
497
- # Find process using the port
498
- lsof -i :51121
499
-
500
- # Kill if stale
501
- kill -9 <PID>
502
-
503
- # Retry
504
- opencode auth login
505
- ```
506
-
507
- **Windows (PowerShell):**
508
- ```powershell
509
- netstat -ano | findstr :51121
510
- taskkill /PID <PID> /F
511
- opencode auth login
512
- ```
513
-
514
- </details>
515
-
516
- <details>
517
- <summary><b>Docker / WSL2 / Remote Development</b></summary>
518
-
519
- OAuth callback requires browser to reach `localhost` on the machine running OpenCode.
520
-
521
- **WSL2:**
522
- - Use VS Code's port forwarding, or
523
- - Configure Windows → WSL port forwarding
524
-
525
- **SSH / Remote:**
526
- ```bash
527
- ssh -L 51121:localhost:51121 user@remote
528
- ```
529
-
530
- **Docker / Containers:**
531
- - OAuth with localhost redirect doesn't work in containers
532
- - Wait 30s for manual URL flow, or use SSH port forwarding
533
-
534
- </details>
535
-
536
- ---
537
-
538
- ### Configuration Key Typo: `plugin` not `plugins`
539
-
540
- The correct key is `plugin` (singular):
541
-
542
- ```json
543
- {
544
- "plugin": ["opencode-antigravity-auth-updated@beta"]
545
- }
546
- ```
547
-
548
- **Not** `"plugins"` (will cause "Unrecognized key" error).
549
-
550
- ---
551
-
552
- ### Migrating Accounts Between Machines
553
-
554
- When copying `antigravity-accounts.json` to a new machine:
555
- 1. Ensure the plugin is installed: `"plugin": ["opencode-antigravity-auth-updated@beta"]`
556
- 2. Copy `~/.config/opencode/antigravity-accounts.json`
557
- 3. If you get "API key missing" error, the refresh token may be invalid — re-authenticate
558
-
559
- ## Known Plugin Interactions
560
- For details on load balancing, dual quota pools, and account storage, see [docs/MULTI-ACCOUNT.md](docs/MULTI-ACCOUNT.md).
561
-
562
- ---
563
-
564
- ## Plugin Compatibility
565
-
566
- ### @tarquinen/opencode-dcp
567
-
568
- DCP creates synthetic assistant messages that lack thinking blocks. **List this plugin BEFORE DCP:**
569
-
570
- ```json
571
- {
572
- "plugin": [
573
- "opencode-antigravity-auth-updated@latest",
574
- "@tarquinen/opencode-dcp@latest"
575
- ]
576
- }
577
- ```
578
-
579
- ### oh-my-opencode
580
-
581
- Disable built-in auth and override agent models in `oh-my-opencode.json`:
582
-
583
- ```json
584
- {
585
- "google_auth": false,
586
- "agents": {
587
- "frontend-ui-ux-engineer": { "model": "google/antigravity-gemini-3-pro" },
588
- "document-writer": { "model": "google/antigravity-gemini-3-flash" },
589
- "multimodal-looker": { "model": "google/antigravity-gemini-3-flash" }
590
- }
591
- }
592
- ```
593
-
594
- > **Tip:** When spawning parallel subagents, enable `pid_offset_enabled: true` in `antigravity.json` to distribute sessions across accounts.
595
-
596
- ### Plugins you don't need
597
-
598
- - **gemini-auth plugins** — Not needed. This plugin handles all Google OAuth.
599
-
600
- ---
601
-
602
- ## Configuration
603
-
604
- Create `~/.config/opencode/antigravity.json` for optional settings:
605
-
606
- ```json
607
- {
608
- "$schema": "https://raw.githubusercontent.com/insign/opencode-antigravity-auth-updated/main/assets/antigravity.schema.json"
609
- }
610
- ```
611
-
612
- Most users don't need to configure anything — defaults work well.
613
-
614
- ### Model Behavior
615
-
616
- | Option | Default | What it does |
617
- |--------|---------|--------------
618
- | `keep_thinking` | `false` | Preserve Claude's thinking across turns. **Warning:** enabling may degrade model stability. |
619
- | `session_recovery` | `true` | Auto-recover from tool errors |
620
- | `cli_first` | `false` | Route Gemini models to the legacy Gemini CLI path first (Claude and image models stay on Antigravity). |
621
- | `agy_sdk.enabled` | `true` | Enables the Antigravity SDK / Gemini API key route for Gemini requests. |
622
- | `agy_sdk.prefer_for_gemini` | `false` | When API keys are configured, use the Gemini API route before OAuth-backed Antigravity for Gemini models. |
623
- | `agy_sdk.api_key_fallback` | `true` | Use configured API keys / Cloud Projects when OAuth Antigravity and legacy Gemini CLI quotas are unavailable. |
624
- | `model_discovery.enabled` | `true` | Load provider models dynamically from Gemini API / Antigravity model APIs, with bundled static definitions as fallback. |
625
-
626
- ### Antigravity SDK / Gemini API keys
627
-
628
- The official Antigravity SDK quickstart uses `GEMINI_API_KEY`. You can provide one key via environment variable:
629
-
630
- ```bash
631
- GEMINI_API_KEY=your-key opencode run "Hello" --model=google/gemini-3-pro
632
- ```
633
-
634
- For multiple Cloud Projects / API keys, add them to `~/.config/opencode/antigravity.json`:
635
-
636
- ```json
637
- {
638
- "agy_sdk": {
639
- "api_key_fallback": true,
640
- "prefer_for_gemini": false,
641
- "cloud_projects": [
642
- { "label": "primary", "project_id": "my-project", "api_key": "..." },
643
- { "label": "backup", "project_id": "my-backup-project", "api_key": "..." }
644
- ]
645
- }
646
- }
647
- ```
648
-
649
- Keep this file private: API keys are stored in your local OpenCode config and are sent to Gemini with the `x-goog-api-key` header, never in the request URL. Do not commit `antigravity.json` with real keys.
650
-
651
- Set `prefer_for_gemini: true` if you want Gemini models to use the newer Gemini API path before OAuth-backed Antigravity. OAuth multi-account rotation remains active for Antigravity/Claude and as fallback when `prefer_for_gemini` keys are unavailable. `cli_first` remains the legacy Gemini CLI compatibility mode.
652
-
653
- ### Account Rotation
654
-
655
- | Your Setup | Recommended Config |
656
- |------------|-------------------|
657
- | **1 account** | `"account_selection_strategy": "sticky"` |
658
- | **2-5 accounts** | Default (`"hybrid"`) works great |
659
- | **5+ accounts** | `"account_selection_strategy": "round-robin"` |
660
- | **Parallel agents** | Add `"pid_offset_enabled": true` |
661
-
662
- ### Quota Protection
663
-
664
- | Option | Default | What it does |
665
- |--------|---------|--------------|
1
+ # Antigravity + Gemini CLI OAuth Plugin for Opencode
2
+
3
+ [![npm version](https://img.shields.io/npm/v/opencode-antigravity-auth-updated.svg)](https://www.npmjs.com/package/opencode-antigravity-auth-updated)
4
+ [![npm beta](https://img.shields.io/npm/v/opencode-antigravity-auth-updated/beta.svg?label=beta)](https://www.npmjs.com/package/opencode-antigravity-auth-updated)
5
+ [![npm downloads](https://img.shields.io/npm/dw/opencode-antigravity-auth-updated.svg)](https://www.npmjs.com/package/opencode-antigravity-auth-updated)
6
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
7
+ [![X (Twitter)](https://img.shields.io/badge/X-@dopesalmon-000000?style=flat&logo=x)](https://x.com/dopesalmon)
8
+
9
+ Enable Opencode to authenticate against **Antigravity** (Google's IDE) via OAuth so you can use Antigravity rate limits and access models like `gemini-3.1-pro` and `claude-opus-4-6-thinking` with your Google credentials.
10
+
11
+ ## What You Get
12
+
13
+ - **Claude Opus 4.6, Sonnet 4.6** and **Gemini 3.1 Pro/Flash** via Google OAuth
14
+ - **Multi-account support** — add multiple Google accounts, auto-rotates when rate-limited
15
+ - **Modern Gemini API support** — use Antigravity SDK-style API keys / Cloud Projects as Gemini backups or opt-in primary routing
16
+ - **Legacy Gemini CLI quota support** — still available for compatibility and quota fallback
17
+ - **Thinking models** — extended thinking for Claude and Gemini 3 with configurable budgets
18
+ - **Google Search grounding** — enable web search for Gemini models (auto or always-on)
19
+ - **Auto-recovery** — handles session errors and tool failures automatically
20
+ - **Plugin compatible** — works alongside other OpenCode plugins (oh-my-opencode, dcp, etc.)
21
+
22
+ ---
23
+
24
+ <details open>
25
+ <summary><b>⚠️ Terms of Service Warning — Read Before Installing</b></summary>
26
+
27
+ > [!CAUTION]
28
+ > Using this plugin (and any proxy for Antigravity) violates Google's Terms of Service. A number of users have reported their Google accounts being **banned** or **shadow-banned** (restricted access without explicit notification).
29
+ >
30
+ > **By using this plugin, you acknowledge:**
31
+ > - This is an unofficial tool not endorsed by Google
32
+ > - Your account may be suspended or permanently banned
33
+ > - You assume all risks associated with using this plugin
34
+ >
35
+
36
+ </details>
37
+
38
+ ---
39
+
40
+ ## Installation
41
+
42
+ <details open>
43
+ <summary><b>For Humans</b></summary>
44
+
45
+ **Option A: Let an LLM do it**
46
+
47
+ Paste this into any LLM agent (Claude Code, OpenCode, Cursor, etc.):
48
+
49
+ ```
50
+ Install the opencode-antigravity-auth-updated plugin and add the Antigravity model definitions to ~/.config/opencode/opencode.json by following: https://raw.githubusercontent.com/insign/opencode-antigravity-auth-updated/main/README.md
51
+ ```
52
+
53
+ **Option B: Manual setup**
54
+
55
+ 1. **Add the plugin** to `~/.config/opencode/opencode.json`:
56
+
57
+ ```json
58
+ {
59
+ "plugin": ["opencode-antigravity-auth-updated@latest"]
60
+ }
61
+ ```
62
+
63
+ > Want bleeding-edge features? Use `opencode-antigravity-auth-updated@beta` instead.
64
+
65
+ 2. **Login** with your Google account:
66
+
67
+ ```bash
68
+ opencode auth login
69
+ ```
70
+
71
+ 3. **Models** — current OpenCode versions can load plugin models dynamically at runtime. If your OpenCode version still requires static provider config, choose one:
72
+ - Run `opencode auth login` → Google → OAuth with Google (Antigravity) → select **"Configure models in opencode.json"** (auto-configures all models)
73
+ - Or manually copy the [full configuration](#models) below
74
+
75
+ 4. **Use it:**
76
+
77
+ ```bash
78
+ opencode run "Hello" --model=google/antigravity-claude-opus-4-6-thinking --variant=max
79
+ ```
80
+
81
+ </details>
82
+
83
+ <details>
84
+ <summary><b>For LLM Agents</b></summary>
85
+
86
+ ### Step-by-Step Instructions
87
+
88
+ 1. Edit the OpenCode configuration file at `~/.config/opencode/opencode.json`
89
+
90
+ > **Note**: This path works on all platforms. On Windows, `~` resolves to your user home directory (e.g., `C:\Users\YourName`).
91
+
92
+ 2. Add the plugin to the `plugin` array
93
+
94
+ 3. Add the model definitions from the [Full models configuration](#models) section
95
+
96
+ 4. Set `provider` to `"google"` and choose a model
97
+
98
+ ### Verification
99
+
100
+ ```bash
101
+ opencode run "Hello" --model=google/antigravity-claude-opus-4-6-thinking --variant=max
102
+ ```
103
+
104
+ </details>
105
+
106
+ ---
107
+
108
+ ## Models
109
+
110
+ ### Model Reference
111
+
112
+ **Antigravity quota** (default routing for Claude and Gemini):
113
+
114
+ | Model | Variants | Notes |
115
+ |-------|----------|-------|
116
+ | `antigravity-gemini-3-pro` | low, high | Gemini 3 Pro with thinking |
117
+ | `antigravity-gemini-3.1-pro` | low, high | Gemini 3.1 Pro with thinking (rollout-dependent) |
118
+ | `antigravity-gemini-3-flash` | minimal, low, medium, high | Gemini 3 Flash with thinking |
119
+ | `antigravity-gemini-3.5-flash` | minimal, low, medium, high | Gemini 3.5 Flash with thinking (rollout-dependent) |
120
+ | `antigravity-claude-sonnet-4-6` | — | Claude Sonnet 4.6 |
121
+ | `antigravity-claude-opus-4-6-thinking` | low, max | Claude Opus 4.6 with extended thinking |
122
+
123
+ **Antigravity SDK / Gemini API projects** (API-key backed; used by API-key auth, or as OAuth fallback when configured):
124
+
125
+ The official Antigravity SDK uses `GEMINI_API_KEY` for local Gemini access. This plugin now supports that path directly for Gemini models while keeping OAuth accounts for Antigravity and Claude.
126
+
127
+ **Legacy Gemini CLI quota** (separate from Antigravity; used when `cli_first` is true or as fallback):
128
+
129
+ | Model | Notes |
130
+ |-------|-------|
131
+ | `gemini-2.5-flash` | Gemini 2.5 Flash |
132
+ | `gemini-2.5-pro` | Gemini 2.5 Pro |
133
+ | `gemini-3-flash-preview` | Gemini 3 Flash (preview) |
134
+ | `gemini-3.5-flash` | Gemini 3.5 Flash (rollout-dependent) |
135
+ | `gemini-3-pro-preview` | Gemini 3 Pro (preview) |
136
+ | `gemini-3.1-pro` | Gemini 3.1 Pro |
137
+ | `gemini-3.1-pro-preview-customtools` | Gemini 3.1 Pro Preview Custom Tools |
138
+
139
+ > **Routing Behavior:**
140
+ > - **OAuth Antigravity-first (default):** Gemini models use Antigravity quota across OAuth accounts.
141
+ > - **Antigravity SDK / Gemini API:** API-key auth, `GEMINI_API_KEY`, or configured `agy_sdk.cloud_projects` route Gemini requests through the public Gemini API.
142
+ > - **Legacy CLI-first (`cli_first: true`):** Gemini models use the legacy Gemini CLI quota first.
143
+ > - When OAuth quota pools are exhausted, configured `agy_sdk.cloud_projects` are used as backup capacity before failing if `agy_sdk.enabled: true`, `agy_sdk.api_key_fallback: true`, and usable API-key credentials are present.
144
+ > - Claude and image models always use Antigravity.
145
+ > Model names are automatically transformed for the target API (e.g., `antigravity-gemini-3-flash` → `gemini-3-flash-preview` for CLI).
146
+
147
+ **Using variants:**
148
+ ```bash
149
+ opencode run "Hello" --model=google/antigravity-claude-opus-4-6-thinking --variant=max
150
+ ```
151
+
152
+ For details on variant configuration and thinking levels, see [docs/MODEL-VARIANTS.md](docs/MODEL-VARIANTS.md).
153
+
154
+ <details>
155
+ <summary><b>Full models configuration (copy-paste ready)</b></summary>
156
+
157
+ Add this to your `~/.config/opencode/opencode.json`:
158
+
159
+ ```json
160
+ {
161
+ "$schema": "https://opencode.ai/config.json",
162
+ "plugin": ["opencode-antigravity-auth-updated@latest"],
163
+ "provider": {
164
+ "google": {
165
+ "models": {
166
+ "antigravity-gemini-3-pro": {
167
+ "name": "Gemini 3 Pro (Antigravity)",
168
+ "limit": { "context": 1048576, "output": 65535 },
169
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
170
+ "variants": {
171
+ "low": { "thinkingLevel": "low" },
172
+ "high": { "thinkingLevel": "high" }
173
+ }
174
+ },
175
+ "antigravity-gemini-3.1-pro": {
176
+ "name": "Gemini 3.1 Pro (Antigravity)",
177
+ "limit": { "context": 1048576, "output": 65535 },
178
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
179
+ "variants": {
180
+ "low": { "thinkingLevel": "low" },
181
+ "high": { "thinkingLevel": "high" }
182
+ }
183
+ },
184
+ "antigravity-gemini-3-flash": {
185
+ "name": "Gemini 3 Flash (Antigravity)",
186
+ "limit": { "context": 1048576, "output": 65536 },
187
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
188
+ "variants": {
189
+ "minimal": { "thinkingLevel": "minimal" },
190
+ "low": { "thinkingLevel": "low" },
191
+ "medium": { "thinkingLevel": "medium" },
192
+ "high": { "thinkingLevel": "high" }
193
+ }
194
+ },
195
+ "antigravity-gemini-3.5-flash": {
196
+ "name": "Gemini 3.5 Flash (Antigravity)",
197
+ "limit": { "context": 1048576, "output": 65536 },
198
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
199
+ "variants": {
200
+ "minimal": { "thinkingLevel": "minimal" },
201
+ "low": { "thinkingLevel": "low" },
202
+ "medium": { "thinkingLevel": "medium" },
203
+ "high": { "thinkingLevel": "high" }
204
+ }
205
+ },
206
+ "antigravity-claude-sonnet-4-6": {
207
+ "name": "Claude Sonnet 4.6 (Antigravity)",
208
+ "limit": { "context": 200000, "output": 64000 },
209
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
210
+ },
211
+ "antigravity-claude-opus-4-6-thinking": {
212
+ "name": "Claude Opus 4.6 Thinking (Antigravity)",
213
+ "limit": { "context": 200000, "output": 64000 },
214
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
215
+ "variants": {
216
+ "low": { "thinkingConfig": { "thinkingBudget": 8192 } },
217
+ "max": { "thinkingConfig": { "thinkingBudget": 32768 } }
218
+ }
219
+ },
220
+ "gemini-2.5-flash": {
221
+ "name": "Gemini 2.5 Flash (Gemini CLI)",
222
+ "limit": { "context": 1048576, "output": 65536 },
223
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
224
+ },
225
+ "gemini-2.5-pro": {
226
+ "name": "Gemini 2.5 Pro (Gemini CLI)",
227
+ "limit": { "context": 1048576, "output": 65536 },
228
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
229
+ },
230
+ "gemini-3-flash-preview": {
231
+ "name": "Gemini 3 Flash Preview (Gemini CLI)",
232
+ "limit": { "context": 1048576, "output": 65536 },
233
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
234
+ },
235
+ "gemini-3.5-flash": {
236
+ "name": "Gemini 3.5 Flash (Gemini CLI)",
237
+ "limit": { "context": 1048576, "output": 65536 },
238
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
239
+ },
240
+ "gemini-3-pro-preview": {
241
+ "name": "Gemini 3 Pro Preview (Gemini CLI)",
242
+ "limit": { "context": 1048576, "output": 65535 },
243
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
244
+ },
245
+ "gemini-3.1-pro": {
246
+ "name": "Gemini 3.1 Pro (Gemini CLI)",
247
+ "limit": { "context": 1048576, "output": 65535 },
248
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
249
+ },
250
+ "gemini-3.1-pro-preview-customtools": {
251
+ "name": "Gemini 3.1 Pro Preview Custom Tools (Gemini CLI)",
252
+ "limit": { "context": 1048576, "output": 65535 },
253
+ "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
254
+ }
255
+ }
256
+ }
257
+ }
258
+ }
259
+ ```
260
+
261
+ > **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.
262
+
263
+ </details>
264
+
265
+ ---
266
+
267
+ ## Multi-Account Setup
268
+
269
+ Add multiple Google accounts for a higher combined quota. The plugin automatically rotates between accounts when one is rate-limited.
270
+
271
+ ```bash
272
+ opencode auth login # Run again to add more accounts
273
+ ```
274
+
275
+ **Account management options (via `opencode auth login`):**
276
+ - **Configure models** — Auto-configure all plugin models in opencode.json
277
+ - **Check quotas** — View remaining API quota for each account
278
+ - **Manage accounts** — Enable/disable specific accounts for rotation
279
+
280
+ For details on load balancing, dual quota pools, and account storage, see [docs/MULTI-ACCOUNT.md](docs/MULTI-ACCOUNT.md).
281
+
282
+ ---
283
+
284
+ ## Troubleshooting
285
+
286
+ > **Quick Reset**: Most issues can be resolved by deleting `~/.config/opencode/antigravity-accounts.json` and running `opencode auth login` again.
287
+
288
+ ### Configuration Path (All Platforms)
289
+
290
+ OpenCode uses `~/.config/opencode/` on **all platforms** including Windows.
291
+
292
+ | File | Path |
293
+ |------|------|
294
+ | Main config | `~/.config/opencode/opencode.json` |
295
+ | Accounts | `~/.config/opencode/antigravity-accounts.json` |
296
+ | Plugin config | `~/.config/opencode/antigravity.json` |
297
+ | Debug logs | `~/.config/opencode/antigravity-logs/` |
298
+
299
+ > **Windows users**: `~` resolves to your user home directory (e.g., `C:\Users\YourName`). Do NOT use `%APPDATA%`.
300
+
301
+ > **Custom path**: Set `OPENCODE_CONFIG_DIR` environment variable to use a custom location.
302
+
303
+ > **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/`.
304
+
305
+ ---
306
+
307
+ ### Multi-Account Auth Issues
308
+
309
+ If you encounter authentication issues with multiple accounts:
310
+
311
+ 1. Delete the accounts file:
312
+ ```bash
313
+ rm ~/.config/opencode/antigravity-accounts.json
314
+ ```
315
+ 2. Re-authenticate:
316
+ ```bash
317
+ opencode auth login
318
+ ```
319
+
320
+ ---
321
+
322
+ ### 403 Permission Denied (`rising-fact-p41fc`)
323
+
324
+ **Error:**
325
+ ```
326
+ Permission 'cloudaicompanion.companions.generateChat' denied on resource
327
+ '//cloudaicompanion.googleapis.com/projects/rising-fact-p41fc/locations/global'
328
+ ```
329
+
330
+ **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.
331
+
332
+ **Solution:**
333
+ 1. Go to [Google Cloud Console](https://console.cloud.google.com/)
334
+ 2. Create or select a project
335
+ 3. Enable the **Gemini for Google Cloud API** (`cloudaicompanion.googleapis.com`)
336
+ 4. Add `projectId` to your accounts file:
337
+ ```json
338
+ {
339
+ "accounts": [
340
+ {
341
+ "email": "your@email.com",
342
+ "refreshToken": "...",
343
+ "projectId": "your-project-id"
344
+ }
345
+ ]
346
+ }
347
+ ```
348
+
349
+ > **Note**: Do this for each account in a multi-account setup.
350
+
351
+ ---
352
+
353
+ ### Gemini Model Not Found
354
+
355
+ Add this to your `google` provider config:
356
+
357
+ ```json
358
+ {
359
+ "provider": {
360
+ "google": {
361
+ "npm": "@ai-sdk/google",
362
+ "models": { ... }
363
+ }
364
+ }
365
+ }
366
+ ```
367
+
368
+ ---
369
+
370
+ ### Gemini 3 Models 400 Error ("Unknown name 'parameters'")
371
+
372
+ **Error:**
373
+ ```
374
+ Invalid JSON payload received. Unknown name "parameters" at 'request.tools[0]'
375
+ ```
376
+
377
+ **Causes:**
378
+ - Tool schema incompatibility with Gemini's strict protobuf validation
379
+ - MCP servers with malformed schemas
380
+ - Plugin version regression
381
+
382
+ **Solutions:**
383
+ 1. **Update to latest beta:**
384
+ ```json
385
+ { "plugin": ["opencode-antigravity-auth-updated@beta"] }
386
+ ```
387
+
388
+ 2. **Disable MCP servers** one-by-one to find the problematic one
389
+
390
+ 3. **Add npm override:**
391
+ ```json
392
+ { "provider": { "google": { "npm": "@ai-sdk/google" } } }
393
+ ```
394
+
395
+ ---
396
+
397
+ ### MCP Servers Causing Errors
398
+
399
+ Some MCP servers have schemas incompatible with Antigravity's strict JSON format.
400
+
401
+ **Common symptom:**
402
+ ```bash
403
+ Invalid function name must start with a letter or underscore
404
+ ```
405
+
406
+ Sometimes it shows up as:
407
+ ```bash
408
+ GenerateContentRequest.tools[0].function_declarations[12].name: Invalid function name must start with a letter or underscore
409
+ ```
410
+
411
+ This 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.
412
+
413
+ **Diagnosis:**
414
+ 1. Disable all MCP servers in your config
415
+ 2. Enable one-by-one until error reappears
416
+ 3. Report the specific MCP in a [GitHub issue](https://github.com/insign/opencode-antigravity-auth-updated/issues)
417
+
418
+ ---
419
+
420
+ ### "All Accounts Rate-Limited" (But Quota Available)
421
+
422
+ **Cause:** Cascade bug in `clearExpiredRateLimits()` in hybrid mode (fixed in recent beta).
423
+
424
+ **Solutions:**
425
+ 1. Update to latest beta version
426
+ 2. If persists, delete accounts file and re-authenticate
427
+ 3. Try switching `account_selection_strategy` to `"sticky"` in `antigravity.json`
428
+
429
+ ---
430
+
431
+ ### Session Recovery
432
+
433
+ If you encounter errors during a session:
434
+ 1. Type `continue` to trigger the recovery mechanism
435
+ 2. If blocked, use `/undo` to revert to pre-error state
436
+ 3. Retry the operation
437
+
438
+ ---
439
+
440
+ ### Using with Oh-My-OpenCode
441
+
442
+ **Important:** Disable the built-in Google auth to prevent conflicts:
443
+
444
+ ```json
445
+ // ~/.config/opencode/oh-my-opencode.json
446
+ {
447
+ "google_auth": false,
448
+ "categories": {
449
+ "visual-engineering": { "model": "google/gemini-3-pro" },
450
+ "writing": { "model": "google/gemini-3-flash" }
451
+ }
452
+ }
453
+ ```
454
+
455
+ ---
456
+
457
+ ### Infinite `.tmp` Files Created
458
+
459
+ **Cause:** When account is rate-limited and plugin retries infinitely, it creates many temp files.
460
+
461
+ **Workaround:**
462
+ 1. Stop OpenCode
463
+ 2. Clean up: `rm ~/.config/opencode/*.tmp`
464
+ 3. Add more accounts or wait for rate limit to expire
465
+
466
+ ---
467
+
468
+ ### OAuth Callback Issues
469
+
470
+ <details>
471
+ <summary><b>Safari OAuth Callback Fails (macOS)</b></summary>
472
+
473
+ **Symptoms:**
474
+ - "fail to authorize" after successful Google login
475
+ - Safari shows "Safari can't open the page"
476
+
477
+ **Cause:** Safari's "HTTPS-Only Mode" blocks `http://localhost` callback.
478
+
479
+ **Solutions:**
480
+
481
+ 1. **Use Chrome or Firefox** (easiest):
482
+ Copy the OAuth URL and paste into a different browser.
483
+
484
+ 2. **Disable HTTPS-Only Mode temporarily:**
485
+ - Safari > Settings (⌘,) > Privacy
486
+ - Uncheck "Enable HTTPS-Only Mode"
487
+ - Run `opencode auth login`
488
+ - Re-enable after authentication
489
+
490
+ </details>
491
+
492
+ <details>
493
+ <summary><b>Port Conflict (Address Already in Use)</b></summary>
494
+
495
+ **macOS / Linux:**
496
+ ```bash
497
+ # Find process using the port
498
+ lsof -i :51121
499
+
500
+ # Kill if stale
501
+ kill -9 <PID>
502
+
503
+ # Retry
504
+ opencode auth login
505
+ ```
506
+
507
+ **Windows (PowerShell):**
508
+ ```powershell
509
+ netstat -ano | findstr :51121
510
+ taskkill /PID <PID> /F
511
+ opencode auth login
512
+ ```
513
+
514
+ </details>
515
+
516
+ <details>
517
+ <summary><b>Docker / WSL2 / Remote Development</b></summary>
518
+
519
+ OAuth callback requires browser to reach `localhost` on the machine running OpenCode.
520
+
521
+ **WSL2:**
522
+ - Use VS Code's port forwarding, or
523
+ - Configure Windows → WSL port forwarding
524
+
525
+ **SSH / Remote:**
526
+ ```bash
527
+ ssh -L 51121:localhost:51121 user@remote
528
+ ```
529
+
530
+ **Docker / Containers:**
531
+ - OAuth with localhost redirect doesn't work in containers
532
+ - Wait 30s for manual URL flow, or use SSH port forwarding
533
+
534
+ </details>
535
+
536
+ ---
537
+
538
+ ### Configuration Key Typo: `plugin` not `plugins`
539
+
540
+ The correct key is `plugin` (singular):
541
+
542
+ ```json
543
+ {
544
+ "plugin": ["opencode-antigravity-auth-updated@beta"]
545
+ }
546
+ ```
547
+
548
+ **Not** `"plugins"` (will cause "Unrecognized key" error).
549
+
550
+ ---
551
+
552
+ ### Migrating Accounts Between Machines
553
+
554
+ When copying `antigravity-accounts.json` to a new machine:
555
+ 1. Ensure the plugin is installed: `"plugin": ["opencode-antigravity-auth-updated@beta"]`
556
+ 2. Copy `~/.config/opencode/antigravity-accounts.json`
557
+ 3. If you get "API key missing" error, the refresh token may be invalid — re-authenticate
558
+
559
+ ## Known Plugin Interactions
560
+ For details on load balancing, dual quota pools, and account storage, see [docs/MULTI-ACCOUNT.md](docs/MULTI-ACCOUNT.md).
561
+
562
+ ---
563
+
564
+ ## Plugin Compatibility
565
+
566
+ ### @tarquinen/opencode-dcp
567
+
568
+ DCP creates synthetic assistant messages that lack thinking blocks. **List this plugin BEFORE DCP:**
569
+
570
+ ```json
571
+ {
572
+ "plugin": [
573
+ "opencode-antigravity-auth-updated@latest",
574
+ "@tarquinen/opencode-dcp@latest"
575
+ ]
576
+ }
577
+ ```
578
+
579
+ ### oh-my-opencode
580
+
581
+ Disable built-in auth and override agent models in `oh-my-opencode.json`:
582
+
583
+ ```json
584
+ {
585
+ "google_auth": false,
586
+ "agents": {
587
+ "frontend-ui-ux-engineer": { "model": "google/antigravity-gemini-3-pro" },
588
+ "document-writer": { "model": "google/antigravity-gemini-3-flash" },
589
+ "multimodal-looker": { "model": "google/antigravity-gemini-3-flash" }
590
+ }
591
+ }
592
+ ```
593
+
594
+ > **Tip:** When spawning parallel subagents, enable `pid_offset_enabled: true` in `antigravity.json` to distribute sessions across accounts.
595
+
596
+ ### Plugins you don't need
597
+
598
+ - **gemini-auth plugins** — Not needed. This plugin handles all Google OAuth.
599
+
600
+ ---
601
+
602
+ ## Configuration
603
+
604
+ Create `~/.config/opencode/antigravity.json` for optional settings:
605
+
606
+ ```json
607
+ {
608
+ "$schema": "https://raw.githubusercontent.com/insign/opencode-antigravity-auth-updated/main/assets/antigravity.schema.json"
609
+ }
610
+ ```
611
+
612
+ Most users don't need to configure anything — defaults work well.
613
+
614
+ ### Model Behavior
615
+
616
+ | Option | Default | What it does |
617
+ |--------|---------|--------------
618
+ | `keep_thinking` | `false` | Preserve Claude's thinking across turns. **Warning:** enabling may degrade model stability. |
619
+ | `session_recovery` | `true` | Auto-recover from tool errors |
620
+ | `cli_first` | `false` | Route Gemini models to the legacy Gemini CLI path first (Claude and image models stay on Antigravity). |
621
+ | `agy_sdk.enabled` | `true` | Enables the Antigravity SDK / Gemini API key route for Gemini requests. |
622
+ | `agy_sdk.prefer_for_gemini` | `false` | When API keys are configured, use the Gemini API route before OAuth-backed Antigravity for Gemini models. |
623
+ | `agy_sdk.api_key_fallback` | `true` | Use configured API keys / Cloud Projects when OAuth Antigravity and legacy Gemini CLI quotas are unavailable. |
624
+ | `model_discovery.enabled` | `true` | Load provider models dynamically from Gemini API / Antigravity model APIs, with bundled static definitions as fallback. |
625
+
626
+ ### Antigravity SDK / Gemini API keys
627
+
628
+ The official Antigravity SDK quickstart uses `GEMINI_API_KEY`. You can provide one key via environment variable:
629
+
630
+ ```bash
631
+ GEMINI_API_KEY=your-key opencode run "Hello" --model=google/gemini-3-pro
632
+ ```
633
+
634
+ For multiple Cloud Projects / API keys, add them to `~/.config/opencode/antigravity.json`:
635
+
636
+ ```json
637
+ {
638
+ "agy_sdk": {
639
+ "api_key_fallback": true,
640
+ "prefer_for_gemini": false,
641
+ "cloud_projects": [
642
+ { "label": "primary", "project_id": "my-project", "api_key": "..." },
643
+ { "label": "backup", "project_id": "my-backup-project", "api_key": "..." }
644
+ ]
645
+ }
646
+ }
647
+ ```
648
+
649
+ Keep this file private: API keys are stored in your local OpenCode config and are sent to Gemini with the `x-goog-api-key` header, never in the request URL. Do not commit `antigravity.json` with real keys.
650
+
651
+ Set `prefer_for_gemini: true` if you want Gemini models to use the newer Gemini API path before OAuth-backed Antigravity. OAuth multi-account rotation remains active for Antigravity/Claude and as fallback when `prefer_for_gemini` keys are unavailable. `cli_first` remains the legacy Gemini CLI compatibility mode.
652
+
653
+ ### Account Rotation
654
+
655
+ | Your Setup | Recommended Config |
656
+ |------------|-------------------|
657
+ | **1 account** | `"account_selection_strategy": "sticky"` |
658
+ | **2-5 accounts** | Default (`"hybrid"`) works great |
659
+ | **5+ accounts** | `"account_selection_strategy": "round-robin"` |
660
+ | **Parallel agents** | Add `"pid_offset_enabled": true` |
661
+
662
+ ### Quota Protection
663
+
664
+ | Option | Default | What it does |
665
+ |--------|---------|--------------|
666
666
  | `soft_quota_threshold_percent` | `70` | Skip account when quota usage reaches this percentage. Prevents Google from penalizing accounts that fully exhaust quota. Set to `100` to disable. |
667
- | `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. |
668
- | `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. |
669
-
667
+ | `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. |
668
+ | `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. |
669
+
670
670
  > **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`. If an account reaches the threshold and has a valid future `resetTime`, it remains skipped even after the normal cache TTL expires. Missing or invalid reset metadata remains fail-open once the cache is stale. 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.
671
-
672
- ### Rate Limit Scheduling
673
-
674
- Control how the plugin handles rate limits:
675
-
676
- | Option | Default | What it does |
677
- |--------|---------|--------------|
678
- | `scheduling_mode` | `"cache_first"` | `"cache_first"` = wait for same account (preserves prompt cache), `"balance"` = switch immediately, `"performance_first"` = round-robin |
679
- | `max_cache_first_wait_seconds` | `60` | Max seconds to wait in cache_first mode before switching accounts |
680
- | `failure_ttl_seconds` | `3600` | Reset failure count after this many seconds (prevents old failures from permanently penalizing accounts) |
681
-
682
- **When to use each mode:**
683
- - **cache_first** (default): Best for long conversations. Waits for the same account to recover, preserving your prompt cache.
684
- - **balance**: Best for quick tasks. Switches accounts immediately when rate-limited for maximum availability.
685
- - **performance_first**: Best for many short requests. Distributes load evenly across all accounts.
686
-
687
- ### App Behavior
688
-
689
- | Option | Default | What it does |
690
- |--------|---------|--------------|
691
- | `quiet_mode` | `false` | Hide toast notifications |
692
- | `debug` | `false` | Enable debug file logging (`~/.config/opencode/antigravity-logs/`) |
693
- | `debug_tui` | `false` | Show debug logs in the TUI log panel (independent from `debug`) |
694
- | `auto_update` | `true` | Auto-update plugin |
695
-
696
- For all options, see [docs/CONFIGURATION.md](docs/CONFIGURATION.md).
697
-
698
- **Environment variables:**
699
- ```bash
700
- OPENCODE_CONFIG_DIR=/path/to/config opencode # Custom config directory
701
- OPENCODE_ANTIGRAVITY_DEBUG=1 opencode # Enable debug file logging
702
- OPENCODE_ANTIGRAVITY_DEBUG=2 opencode # Verbose debug file logging
703
- OPENCODE_ANTIGRAVITY_DEBUG_TUI=1 opencode # Enable TUI log panel debug output
704
- ```
705
-
706
- ---
707
-
708
- ## Troubleshooting
709
-
710
- See the full [Troubleshooting Guide](docs/TROUBLESHOOTING.md) for solutions to common issues including:
711
-
712
- - Auth problems and token refresh
713
- - "Model not found" errors
714
- - Session recovery
715
- - Gemini CLI permission errors
716
- - Safari OAuth issues
717
- - Plugin compatibility
718
- - Migration guides
719
-
720
- ---
721
-
722
- ## Documentation
723
-
724
- - [Configuration](docs/CONFIGURATION.md) — All configuration options
725
- - [Multi-Account](docs/MULTI-ACCOUNT.md) — Load balancing, dual quota pools, account storage
726
- - [Model Variants](docs/MODEL-VARIANTS.md) — Thinking budgets and variant system
727
- - [Troubleshooting](docs/TROUBLESHOOTING.md) — Common issues and fixes
728
- - [Architecture](docs/ARCHITECTURE.md) — How the plugin works
729
- - [API Spec](docs/ANTIGRAVITY_API_SPEC.md) — Antigravity API reference
730
-
731
- ---
732
-
733
- ## Support
734
-
735
- If this plugin saves you time, consider supporting its development:
736
-
737
- [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/S6S81QBOIR)
738
-
739
- ---
740
-
741
- ## Credits
742
-
743
- - [opencode-gemini-auth](https://github.com/jenslys/opencode-gemini-auth) by [@jenslys](https://github.com/jenslys)
744
- - [CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI)
745
-
746
- ## License
747
-
748
- MIT License. See [LICENSE](LICENSE) for details.
749
-
750
- <details>
751
- <summary><b>Legal</b></summary>
752
-
753
- ### Intended Use
754
-
755
- - Personal / internal development only
756
- - Respect internal quotas and data handling policies
757
- - Not for production services or bypassing intended limits
758
-
759
- ### Warning
760
-
761
- By using this plugin, you acknowledge:
762
-
763
- - **Terms of Service risk** — This approach may violate ToS of AI model providers
764
- - **Account risk** — Providers may suspend or ban accounts
765
- - **No guarantees** — APIs may change without notice
766
- - **Assumption of risk** — You assume all legal, financial, and technical risks
767
-
768
- ### Disclaimer
769
-
770
- - Not affiliated with Google. This is an independent open-source project.
771
- - "Antigravity", "Gemini", "Google Cloud", and "Google" are trademarks of Google LLC.
772
-
773
- </details>
671
+
672
+ ### Rate Limit Scheduling
673
+
674
+ Control how the plugin handles rate limits:
675
+
676
+ | Option | Default | What it does |
677
+ |--------|---------|--------------|
678
+ | `scheduling_mode` | `"cache_first"` | `"cache_first"` = wait for same account (preserves prompt cache), `"balance"` = switch immediately, `"performance_first"` = round-robin |
679
+ | `max_cache_first_wait_seconds` | `60` | Max seconds to wait in cache_first mode before switching accounts |
680
+ | `failure_ttl_seconds` | `3600` | Reset failure count after this many seconds (prevents old failures from permanently penalizing accounts) |
681
+
682
+ **When to use each mode:**
683
+ - **cache_first** (default): Best for long conversations. Waits for the same account to recover, preserving your prompt cache.
684
+ - **balance**: Best for quick tasks. Switches accounts immediately when rate-limited for maximum availability.
685
+ - **performance_first**: Best for many short requests. Distributes load evenly across all accounts.
686
+
687
+ ### App Behavior
688
+
689
+ | Option | Default | What it does |
690
+ |--------|---------|--------------|
691
+ | `quiet_mode` | `false` | Hide toast notifications |
692
+ | `debug` | `false` | Enable debug file logging (`~/.config/opencode/antigravity-logs/`) |
693
+ | `debug_tui` | `false` | Show debug logs in the TUI log panel (independent from `debug`) |
694
+ | `auto_update` | `true` | Auto-update plugin |
695
+
696
+ For all options, see [docs/CONFIGURATION.md](docs/CONFIGURATION.md).
697
+
698
+ **Environment variables:**
699
+ ```bash
700
+ OPENCODE_CONFIG_DIR=/path/to/config opencode # Custom config directory
701
+ OPENCODE_ANTIGRAVITY_DEBUG=1 opencode # Enable debug file logging
702
+ OPENCODE_ANTIGRAVITY_DEBUG=2 opencode # Verbose debug file logging
703
+ OPENCODE_ANTIGRAVITY_DEBUG_TUI=1 opencode # Enable TUI log panel debug output
704
+ ```
705
+
706
+ ---
707
+
708
+ ## Troubleshooting
709
+
710
+ See the full [Troubleshooting Guide](docs/TROUBLESHOOTING.md) for solutions to common issues including:
711
+
712
+ - Auth problems and token refresh
713
+ - "Model not found" errors
714
+ - Session recovery
715
+ - Gemini CLI permission errors
716
+ - Safari OAuth issues
717
+ - Plugin compatibility
718
+ - Migration guides
719
+
720
+ ---
721
+
722
+ ## Documentation
723
+
724
+ - [Configuration](docs/CONFIGURATION.md) — All configuration options
725
+ - [Multi-Account](docs/MULTI-ACCOUNT.md) — Load balancing, dual quota pools, account storage
726
+ - [Model Variants](docs/MODEL-VARIANTS.md) — Thinking budgets and variant system
727
+ - [Troubleshooting](docs/TROUBLESHOOTING.md) — Common issues and fixes
728
+ - [Architecture](docs/ARCHITECTURE.md) — How the plugin works
729
+ - [API Spec](docs/ANTIGRAVITY_API_SPEC.md) — Antigravity API reference
730
+
731
+ ---
732
+
733
+ ## Support
734
+
735
+ If this plugin saves you time, consider supporting its development:
736
+
737
+ [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/S6S81QBOIR)
738
+
739
+ ---
740
+
741
+ ## Credits
742
+
743
+ - [opencode-gemini-auth](https://github.com/jenslys/opencode-gemini-auth) by [@jenslys](https://github.com/jenslys)
744
+ - [CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI)
745
+
746
+ ## License
747
+
748
+ MIT License. See [LICENSE](LICENSE) for details.
749
+
750
+ <details>
751
+ <summary><b>Legal</b></summary>
752
+
753
+ ### Intended Use
754
+
755
+ - Personal / internal development only
756
+ - Respect internal quotas and data handling policies
757
+ - Not for production services or bypassing intended limits
758
+
759
+ ### Warning
760
+
761
+ By using this plugin, you acknowledge:
762
+
763
+ - **Terms of Service risk** — This approach may violate ToS of AI model providers
764
+ - **Account risk** — Providers may suspend or ban accounts
765
+ - **No guarantees** — APIs may change without notice
766
+ - **Assumption of risk** — You assume all legal, financial, and technical risks
767
+
768
+ ### Disclaimer
769
+
770
+ - Not affiliated with Google. This is an independent open-source project.
771
+ - "Antigravity", "Gemini", "Google Cloud", and "Google" are trademarks of Google LLC.
772
+
773
+ </details>