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