opencode-antigravity-auth 1.2.9-beta.4 → 1.2.9-beta.5

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 (33) hide show
  1. package/README.md +126 -630
  2. package/dist/src/plugin/config/loader.d.ts.map +1 -1
  3. package/dist/src/plugin/config/loader.js +13 -0
  4. package/dist/src/plugin/config/loader.js.map +1 -1
  5. package/dist/src/plugin/config/schema.d.ts +30 -0
  6. package/dist/src/plugin/config/schema.d.ts.map +1 -1
  7. package/dist/src/plugin/config/schema.js +23 -0
  8. package/dist/src/plugin/config/schema.js.map +1 -1
  9. package/dist/src/plugin/request-helpers.d.ts +3 -0
  10. package/dist/src/plugin/request-helpers.d.ts.map +1 -1
  11. package/dist/src/plugin/request-helpers.js +17 -8
  12. package/dist/src/plugin/request-helpers.js.map +1 -1
  13. package/dist/src/plugin/request.d.ts +3 -0
  14. package/dist/src/plugin/request.d.ts.map +1 -1
  15. package/dist/src/plugin/request.js +12 -102
  16. package/dist/src/plugin/request.js.map +1 -1
  17. package/dist/src/plugin/transform/gemini.d.ts +3 -1
  18. package/dist/src/plugin/transform/gemini.d.ts.map +1 -1
  19. package/dist/src/plugin/transform/gemini.js +23 -2
  20. package/dist/src/plugin/transform/gemini.js.map +1 -1
  21. package/dist/src/plugin/transform/index.d.ts +1 -1
  22. package/dist/src/plugin/transform/index.d.ts.map +1 -1
  23. package/dist/src/plugin/transform/index.js.map +1 -1
  24. package/dist/src/plugin/transform/model-resolver.d.ts +2 -1
  25. package/dist/src/plugin/transform/model-resolver.d.ts.map +1 -1
  26. package/dist/src/plugin/transform/model-resolver.js +9 -1
  27. package/dist/src/plugin/transform/model-resolver.js.map +1 -1
  28. package/dist/src/plugin/transform/types.d.ts +9 -0
  29. package/dist/src/plugin/transform/types.d.ts.map +1 -1
  30. package/dist/src/plugin.d.ts.map +1 -1
  31. package/dist/src/plugin.js +4 -0
  32. package/dist/src/plugin.js.map +1 -1
  33. package/package.json +1 -1
package/README.md CHANGED
@@ -2,24 +2,28 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/opencode-antigravity-auth.svg)](https://www.npmjs.com/package/opencode-antigravity-auth)
4
4
  [![npm beta](https://img.shields.io/npm/v/opencode-antigravity-auth/beta.svg?label=beta)](https://www.npmjs.com/package/opencode-antigravity-auth)
5
+ [![npm downloads](https://img.shields.io/npm/dw/opencode-antigravity-auth.svg)](https://www.npmjs.com/package/opencode-antigravity-auth)
5
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)
6
8
 
7
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-pro` and `claude-opus-4-5-thinking` with your Google credentials.
8
10
 
9
- ## What you get
11
+ ## What You Get
10
12
 
11
- - **Google OAuth sign-in** with automatic token refresh via `opencode auth login`
12
- - **Dual Quota System** - Access both Antigravity quota (Claude, Gemini 3) and Gemini CLI quota from a single plugin
13
- - **Multi-Account Rotation** - Add multiple Google accounts; automatically rotates when one is rate-limited
14
- - **Real-time SSE streaming** including thinking blocks and incremental output
15
- - **Model Variants** - Configure thinking budget dynamically via OpenCode's variant system
16
- - **Extended Thinking** - Native support for Claude thinking budgets and Gemini 3 thinking levels
17
- - **Auto Recovery** - Automatic session recovery from Claude tool_result_missing errors
18
- - **Plugin Compatible** - Works alongside other OpenCode plugins (opencodesync, etc.)
13
+ - **Claude Opus 4.5, Sonnet 4.5** and **Gemini 3 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.)
20
+
21
+ ---
19
22
 
20
23
  ## Installation
21
24
 
22
- ### For Humans
25
+ <details open>
26
+ <summary><b>For Humans</b></summary>
23
27
 
24
28
  **Option A: Let an LLM do it**
25
29
 
@@ -31,42 +35,23 @@ Install the opencode-antigravity-auth plugin and add the Antigravity model defin
31
35
 
32
36
  **Option B: Manual setup**
33
37
 
34
- 1. **Add the plugin to your config** (`~/.config/opencode/opencode.json`):
38
+ 1. **Add the plugin** to `~/.config/opencode/opencode.json`:
35
39
 
36
40
  ```json
37
41
  {
38
- "plugin": ["opencode-antigravity-auth@beta"]
42
+ "plugin": ["opencode-antigravity-auth@latest"]
39
43
  }
40
44
  ```
41
45
 
42
- 2. **Authenticate:**
46
+ > Want bleeding edge features? Use `opencode-antigravity-auth@beta` instead.
47
+
48
+ 2. **Login** with your Google account:
43
49
 
44
50
  ```bash
45
51
  opencode auth login
46
52
  ```
47
53
 
48
- 3. **Add models** (see [Available Models](#available-models) for full list):
49
-
50
- ```json
51
- {
52
- "plugin": ["opencode-antigravity-auth@beta"],
53
- "provider": {
54
- "google": {
55
- "models": {
56
- "antigravity-claude-sonnet-4-5-thinking": {
57
- "name": "Claude Sonnet 4.5 Thinking",
58
- "limit": { "context": 200000, "output": 64000 },
59
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
60
- "variants": {
61
- "low": { "thinkingConfig": { "thinkingBudget": 8192 } },
62
- "max": { "thinkingConfig": { "thinkingBudget": 32768 } }
63
- }
64
- }
65
- }
66
- }
67
- }
68
- }
69
- ```
54
+ 3. **Add models** copy the [full configuration](#models) below
70
55
 
71
56
  4. **Use it:**
72
57
 
@@ -74,8 +59,10 @@ Install the opencode-antigravity-auth plugin and add the Antigravity model defin
74
59
  opencode run "Hello" --model=google/antigravity-claude-sonnet-4-5-thinking --variant=max
75
60
  ```
76
61
 
62
+ </details>
63
+
77
64
  <details>
78
- <summary><b>Installation Guide for LLM Agents</b></summary>
65
+ <summary><b>For LLM Agents</b></summary>
79
66
 
80
67
  ### Step-by-Step Instructions
81
68
 
@@ -83,88 +70,16 @@ Install the opencode-antigravity-auth plugin and add the Antigravity model defin
83
70
  - Linux/Mac: `~/.config/opencode/opencode.json`
84
71
  - Windows: `%APPDATA%\opencode\opencode.json`
85
72
 
86
- 2. Add the plugin to the `plugins` array
73
+ 2. Add the plugin to the `plugins` array:
74
+ ```json
75
+ {
76
+ "plugin": ["opencode-antigravity-auth@latest"]
77
+ }
78
+ ```
87
79
 
88
- 3. Set `provider` to `"google"` and choose a model
80
+ 3. Add the model definitions from the [Full models configuration](#models) section
89
81
 
90
- ### Complete Configuration Example
91
-
92
- Create `~/.config/opencode/opencode.json`:
93
- ```json
94
- {
95
- "$schema": "https://opencode.ai/config.json",
96
- "plugin": ["opencode-antigravity-auth@beta"],
97
- "provider": {
98
- "google": {
99
- "models": {
100
- "antigravity-gemini-3-pro": {
101
- "name": "Gemini 3 Pro (Antigravity)",
102
- "limit": { "context": 1048576, "output": 65535 },
103
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
104
- "variants": {
105
- "low": { "thinkingLevel": "low" },
106
- "high": { "thinkingLevel": "high" }
107
- }
108
- },
109
- "antigravity-gemini-3-flash": {
110
- "name": "Gemini 3 Flash (Antigravity)",
111
- "limit": { "context": 1048576, "output": 65536 },
112
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
113
- "variants": {
114
- "minimal": { "thinkingLevel": "minimal" },
115
- "low": { "thinkingLevel": "low" },
116
- "medium": { "thinkingLevel": "medium" },
117
- "high": { "thinkingLevel": "high" }
118
- }
119
- },
120
- "antigravity-claude-sonnet-4-5": {
121
- "name": "Claude Sonnet 4.5 (Antigravity)",
122
- "limit": { "context": 200000, "output": 64000 },
123
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
124
- },
125
- "antigravity-claude-sonnet-4-5-thinking": {
126
- "name": "Claude Sonnet 4.5 Thinking (Antigravity)",
127
- "limit": { "context": 200000, "output": 64000 },
128
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
129
- "variants": {
130
- "low": { "thinkingConfig": { "thinkingBudget": 8192 } },
131
- "max": { "thinkingConfig": { "thinkingBudget": 32768 } }
132
- }
133
- },
134
- "antigravity-claude-opus-4-5-thinking": {
135
- "name": "Claude Opus 4.5 Thinking (Antigravity)",
136
- "limit": { "context": 200000, "output": 64000 },
137
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
138
- "variants": {
139
- "low": { "thinkingConfig": { "thinkingBudget": 8192 } },
140
- "max": { "thinkingConfig": { "thinkingBudget": 32768 } }
141
- }
142
- },
143
- "gemini-2.5-flash": {
144
- "name": "Gemini 2.5 Flash (Gemini CLI)",
145
- "limit": { "context": 1048576, "output": 65536 },
146
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
147
- },
148
- "gemini-2.5-pro": {
149
- "name": "Gemini 2.5 Pro (Gemini CLI)",
150
- "limit": { "context": 1048576, "output": 65536 },
151
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
152
- },
153
- "gemini-3-flash-preview": {
154
- "name": "Gemini 3 Flash Preview (Gemini CLI)",
155
- "limit": { "context": 1048576, "output": 65536 },
156
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
157
- },
158
- "gemini-3-pro-preview": {
159
- "name": "Gemini 3 Pro Preview (Gemini CLI)",
160
- "limit": { "context": 1048576, "output": 65535 },
161
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
162
- }
163
- }
164
- }
165
- }
166
- }
167
- ```
82
+ 4. Set `provider` to `"google"` and choose a model
168
83
 
169
84
  ### Verification
170
85
 
@@ -174,47 +89,47 @@ opencode run "Hello" --model=google/antigravity-claude-sonnet-4-5-thinking --var
174
89
 
175
90
  </details>
176
91
 
177
- ## Available Models
92
+ ---
93
+
94
+ ## Models
178
95
 
179
- ### Antigravity Quota (with Variants)
96
+ ### Model Reference
180
97
 
181
- Models with `antigravity-` prefix use Antigravity quota. **Thinking models support variants** for dynamic thinking budget configuration:
98
+ **Antigravity quota** (Claude + Gemini 3):
182
99
 
183
- | Model | Variants | Description |
184
- |-------|----------|-------------|
185
- | `google/antigravity-gemini-3-pro` | low, high | Gemini 3 Pro with configurable thinking |
186
- | `google/antigravity-gemini-3-flash` | minimal, low, medium, high | Gemini 3 Flash with configurable thinking |
187
- | `google/antigravity-claude-sonnet-4-5` | - | Claude Sonnet 4.5 (no thinking) |
188
- | `google/antigravity-claude-sonnet-4-5-thinking` | low, max | Claude Sonnet with configurable thinking |
189
- | `google/antigravity-claude-opus-4-5-thinking` | low, max | Claude Opus with configurable thinking |
100
+ | Model | Variants | Notes |
101
+ |-------|----------|-------|
102
+ | `antigravity-gemini-3-pro` | low, high | Gemini 3 Pro with thinking |
103
+ | `antigravity-gemini-3-flash` | minimal, low, medium, high | Gemini 3 Flash with thinking |
104
+ | `antigravity-claude-sonnet-4-5` | | Claude Sonnet 4.5 |
105
+ | `antigravity-claude-sonnet-4-5-thinking` | low, max | Claude Sonnet with extended thinking |
106
+ | `antigravity-claude-opus-4-5-thinking` | low, max | Claude Opus with extended thinking |
190
107
 
191
- **Variant configuration:**
192
- - **Gemini 3**: Uses `thinkingLevel` string (`"low"`, `"medium"`, `"high"`)
193
- - **Claude**: Uses `thinkingBudget` number (8192, 32768 tokens)
108
+ **Gemini CLI quota** (separate from Antigravity):
194
109
 
195
- **Usage:**
110
+ | Model | Notes |
111
+ |-------|-------|
112
+ | `gemini-2.5-flash` | Gemini 2.5 Flash |
113
+ | `gemini-2.5-pro` | Gemini 2.5 Pro |
114
+ | `gemini-3-flash-preview` | Gemini 3 Flash (preview) |
115
+ | `gemini-3-pro-preview` | Gemini 3 Pro (preview) |
116
+
117
+ **Using variants:**
196
118
  ```bash
197
119
  opencode run "Hello" --model=google/antigravity-claude-sonnet-4-5-thinking --variant=max
198
120
  ```
199
121
 
200
- ### Gemini CLI Quota
201
-
202
- Models with `-preview` suffix use Gemini CLI quota:
203
-
204
- | Model | Description |
205
- |-------|-------------|
206
- | `google/gemini-2.5-flash` | Gemini 2.5 Flash |
207
- | `google/gemini-2.5-pro` | Gemini 2.5 Pro |
208
- | `google/gemini-3-flash-preview` | Gemini 3 Flash (preview) |
209
- | `google/gemini-3-pro-preview` | Gemini 3 Pro (preview) |
122
+ For details on variant configuration and thinking levels, see [docs/MODEL-VARIANTS.md](docs/MODEL-VARIANTS.md).
210
123
 
211
124
  <details>
212
125
  <summary><b>Full models configuration (copy-paste ready)</b></summary>
213
126
 
127
+ Add this to your `~/.config/opencode/opencode.json`:
128
+
214
129
  ```json
215
130
  {
216
131
  "$schema": "https://opencode.ai/config.json",
217
- "plugin": ["opencode-antigravity-auth@beta"],
132
+ "plugin": ["opencode-antigravity-auth@latest"],
218
133
  "provider": {
219
134
  "google": {
220
135
  "models": {
@@ -239,7 +154,7 @@ Models with `-preview` suffix use Gemini CLI quota:
239
154
  }
240
155
  },
241
156
  "antigravity-claude-sonnet-4-5": {
242
- "name": "Claude Sonnet 4.5 (no thinking) (Antigravity)",
157
+ "name": "Claude Sonnet 4.5 (Antigravity)",
243
158
  "limit": { "context": 200000, "output": 64000 },
244
159
  "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] }
245
160
  },
@@ -289,533 +204,132 @@ Models with `-preview` suffix use Gemini CLI quota:
289
204
 
290
205
  </details>
291
206
 
292
- ## Model Variants
293
-
294
- OpenCode's variant system allows you to configure thinking budget dynamically instead of defining separate models for each thinking level.
295
-
296
- ### How Variants Work
297
-
298
- When you define a model with `variants`, OpenCode will show variant options in the model picker. Selecting a variant passes the `providerOptions` to the plugin, which extracts the thinking configuration.
299
-
300
- ### Variant Configuration
301
-
302
- ```json
303
- {
304
- "antigravity-claude-sonnet-4-5-thinking": {
305
- "name": "Claude Sonnet 4.5 Thinking",
306
- "limit": { "context": 200000, "output": 64000 },
307
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
308
- "variants": {
309
- "low": { "thinkingConfig": { "thinkingBudget": 8192 } },
310
- "max": { "thinkingConfig": { "thinkingBudget": 32768 } }
311
- }
312
- }
313
- }
314
- ```
315
-
316
- ### Supported Variant Formats
317
-
318
- The plugin accepts different variant formats depending on the model family:
319
-
320
- | Model Family | Variant Format |
321
- |--------------|----------------|
322
- | **Gemini 3** | `{ "thinkingLevel": "low" \| "medium" \| "high" }` |
323
- | **Claude** | `{ "thinkingConfig": { "thinkingBudget": N } }` |
324
- | **Gemini 2.5** | `{ "thinkingConfig": { "thinkingBudget": N } }` |
325
-
326
- ### Gemini 3 Thinking Levels
327
-
328
- Gemini 3 models use string-based thinking levels. Available levels differ by model:
329
-
330
- | Level | Flash | Pro | Description |
331
- |-------|-------|-----|-------------|
332
- | `minimal` | Yes | No | Minimal thinking, lowest latency |
333
- | `low` | Yes | Yes | Light thinking |
334
- | `medium` | Yes | No | Balanced thinking |
335
- | `high` | Yes | Yes | Maximum thinking (default for both Pro and Flash) |
336
-
337
- > **Note:** The API will reject invalid levels (e.g., `"minimal"` on Pro). Configure variants accordingly.
338
-
339
- ### Legacy Budget Format (Deprecated)
340
-
341
- For Gemini 3 models, the old `thinkingBudget` format is still supported but deprecated:
342
-
343
- | Budget Range | Maps to Level |
344
- |--------------|---------------|
345
- | ≤ 8192 | low |
346
- | ≤ 16384 | medium |
347
- | > 16384 | high |
348
-
349
- ### Backward Compatibility
350
-
351
- Legacy tier-suffixed models still work:
352
- - `antigravity-claude-sonnet-4-5-thinking-low`
353
- - `antigravity-claude-sonnet-4-5-thinking-medium`
354
- - `antigravity-claude-sonnet-4-5-thinking-high`
355
- - `antigravity-gemini-3-pro-low`
356
- - `antigravity-gemini-3-pro-high`
357
-
358
- However, **we recommend using variants** for a cleaner model picker and more flexibility.
207
+ ---
359
208
 
360
209
  ## Multi-Account Setup
361
210
 
362
211
  Add multiple Google accounts for higher combined quotas. The plugin automatically rotates between accounts when one is rate-limited.
363
212
 
364
213
  ```bash
365
- opencode auth login
366
- ```
367
-
368
- <details>
369
- <summary><b>How multi-account works</b></summary>
370
-
371
- ### Load Balancing Behavior
372
-
373
- - **Sticky account selection** - Sticks to the same account until rate-limited (preserves Anthropic's prompt cache)
374
- - **Per-model-family limits** - Rate limits tracked separately for Claude and Gemini models
375
- - **Dual quota pools for Gemini** - Automatic fallback between Antigravity quota and Gemini CLI quota before switching accounts
376
- - **Smart retry threshold** - Short rate limits (≤5s) are retried on same account
377
- - **Exponential backoff** - Increasing delays for consecutive rate limits
378
-
379
- ### Dual Quota Pools (Gemini only)
380
-
381
- For Gemini models, the plugin accesses **two independent quota pools** per account:
382
-
383
- | Quota Pool | When Used |
384
- |------------|-----------|
385
- | **Antigravity** | Primary (tried first) |
386
- | **Gemini CLI** | Fallback when Antigravity is rate-limited |
387
-
388
- This effectively **doubles your Gemini quota** per account.
389
-
390
- ### Adding Accounts
391
-
392
- When running `opencode auth login` with existing accounts:
393
-
394
- ```
395
- 2 account(s) saved:
396
- 1. user1@gmail.com
397
- 2. user2@gmail.com
398
-
399
- (a)dd new account(s) or (f)resh start? [a/f]:
400
- ```
401
-
402
- ### Account Storage
403
-
404
- - Stored in `~/.config/opencode/antigravity-accounts.json`
405
- - Contains OAuth refresh tokens - **treat like a password**
406
- - If Google revokes a token (`invalid_grant`), that account is automatically removed
407
-
408
- </details>
409
-
410
- ## Configuration
411
-
412
- Create `~/.config/opencode/antigravity.json` (or `.opencode/antigravity.json` in project root):
413
-
414
- ### General Settings
415
-
416
- | Option | Default | Description |
417
- |--------|---------|-------------|
418
- | `quiet_mode` | `false` | Suppress toast notifications (except recovery) |
419
- | `debug` | `false` | Enable debug logging to file |
420
- | `log_dir` | OS default | Custom directory for debug logs |
421
- | `auto_update` | `true` | Enable automatic plugin updates |
422
- | `keep_thinking` | `false` | ⚠️ **Experimental.** Preserve Claude's thinking blocks via signature caching. Required for conversation continuity when using thinking models. See [Signature Cache](#signature-cache) for cache settings. |
423
-
424
- ### Session Recovery
425
-
426
- | Option | Default | Description |
427
- |--------|---------|-------------|
428
- | `session_recovery` | `true` | Auto-recover from tool_result_missing errors |
429
- | `auto_resume` | `true` | Auto-send resume prompt after recovery |
430
- | `resume_text` | `"continue"` | Text to send when auto-resuming |
431
-
432
- ### Error Recovery
433
-
434
- | Option | Default | Description |
435
- |--------|---------|-------------|
436
- | `empty_response_max_attempts` | `4` | Retries for empty API responses |
437
- | `empty_response_retry_delay_ms` | `2000` | Delay between retries |
438
- | `tool_id_recovery` | `true` | Fix mismatched tool IDs from context compaction |
439
- | `claude_tool_hardening` | `true` | Prevent tool parameter hallucination |
440
-
441
- ### Signature Cache
442
-
443
- > ⚠️ **Experimental Feature** - Signature caching is experimental and may have edge cases. Please report issues.
444
-
445
- When `keep_thinking` is enabled, the plugin caches thinking block signatures to preserve conversation continuity across requests.
446
-
447
- | Option | Default | Description |
448
- |--------|---------|-------------|
449
- | `signature_cache.enabled` | `true` | Enable disk caching of thinking block signatures |
450
- | `signature_cache.memory_ttl_seconds` | `3600` | In-memory cache TTL (1 hour) |
451
- | `signature_cache.disk_ttl_seconds` | `172800` | Disk cache TTL (48 hours) |
452
- | `signature_cache.write_interval_seconds` | `60` | Background write interval |
453
-
454
- ### Token Management
455
-
456
- | Option | Default | Description |
457
- |--------|---------|-------------|
458
- | `proactive_token_refresh` | `true` | Refresh tokens before expiry |
459
- | `proactive_refresh_buffer_seconds` | `1800` | Refresh 30min before expiry |
460
- | `max_rate_limit_wait_seconds` | `300` | Max wait time when rate limited (0=unlimited) |
461
- | `quota_fallback` | `false` | **Gemini only.** When rate-limited on primary quota pool (Antigravity or Gemini CLI), automatically try the alternate pool before switching accounts. Effectively doubles retry attempts per account. See [Dual Quota Pools](#dual-quota-pools-gemini-only). |
462
- | `switch_on_first_rate_limit` | `true` | Switch account immediately on first 429 (after 1s) |
463
-
464
- ### Account Selection
465
-
466
- | Option | Default | Description |
467
- |--------|---------|-------------|
468
- | `account_selection_strategy` | `"sticky"` | Strategy for distributing requests across accounts |
469
- | `pid_offset_enabled` | `false` | Use PID-based offset for multi-session distribution |
470
-
471
- **Available strategies:**
472
-
473
- | Strategy | Behavior | Best For |
474
- |----------|----------|----------|
475
- | `sticky` | Same account until rate-limited | Prompt cache preservation |
476
- | `round-robin` | Rotate to next account on every request | Maximum throughput |
477
- | `hybrid` | Touch all fresh accounts first, then sticky | Sync reset timers + cache |
478
-
479
- **Error handling:**
480
-
481
- | Error Type | Behavior |
482
- |------------|----------|
483
- | `MODEL_CAPACITY_EXHAUSTED` | Wait (escalating 5s→60s) and retry same account |
484
- | `QUOTA_EXCEEDED` | Switch to next available account immediately |
485
-
486
- This prevents unnecessary account switching when server-side capacity issues affect all accounts equally.
487
-
488
- ### Environment Overrides
489
-
490
- ```bash
491
- OPENCODE_ANTIGRAVITY_QUIET=1 # quiet_mode
492
- OPENCODE_ANTIGRAVITY_DEBUG=1 # debug
493
- OPENCODE_ANTIGRAVITY_LOG_DIR=/path # log_dir
494
- OPENCODE_ANTIGRAVITY_KEEP_THINKING=1 # keep_thinking
495
- OPENCODE_ANTIGRAVITY_ACCOUNT_SELECTION_STRATEGY=round-robin # account_selection_strategy
496
- OPENCODE_ANTIGRAVITY_PID_OFFSET_ENABLED=1 # pid_offset_enabled
497
- ```
498
-
499
- <details>
500
- <summary><b>Full configuration example</b></summary>
501
-
502
- ```json
503
- {
504
- "$schema": "https://raw.githubusercontent.com/NoeFabris/opencode-antigravity-auth/main/assets/antigravity.schema.json",
505
- "quiet_mode": false,
506
- "debug": false,
507
- "log_dir": "/custom/log/path",
508
- "auto_update": true,
509
- "keep_thinking": false,
510
- "session_recovery": true,
511
- "auto_resume": true,
512
- "resume_text": "continue",
513
- "empty_response_max_attempts": 4,
514
- "empty_response_retry_delay_ms": 2000,
515
- "tool_id_recovery": true,
516
- "claude_tool_hardening": true,
517
- "proactive_token_refresh": true,
518
- "proactive_refresh_buffer_seconds": 1800,
519
- "proactive_refresh_check_interval_seconds": 300,
520
- "max_rate_limit_wait_seconds": 300,
521
- "quota_fallback": false,
522
- "account_selection_strategy": "sticky",
523
- "pid_offset_enabled": false,
524
- "signature_cache": {
525
- "enabled": true,
526
- "memory_ttl_seconds": 3600,
527
- "disk_ttl_seconds": 172800,
528
- "write_interval_seconds": 60
529
- }
530
- }
214
+ opencode auth login # Run again to add more accounts
531
215
  ```
532
216
 
533
- </details>
534
-
535
- ## Troubleshoot
536
-
537
- ### Multi account auth issues
538
- If you encounter auth issue please try remove `antigravity-account.json` and auth again
539
-
540
- ### Gemini model not found
541
- Try add this line to in `google` field under `provider`
542
- `"npm": "@ai-sdk/google"`
543
-
544
- ### Error during the session
545
- If you encounter error during the session, try chat `continue` the recover session mechanism should be trigger and you can continue the session, if the error blocked the session please workaround by use command `/undo` to revert to the state before the error and try again it should work
217
+ For details on load balancing, dual quota pools, and account storage, see [docs/MULTI-ACCOUNT.md](docs/MULTI-ACCOUNT.md).
546
218
 
547
- ### Error using Gemini CLI models
548
- When using Gemini CLI models, you may come across an error with the below text:
549
- > Permission 'cloudaicompanion.companions.generateChat' denied on resource '//cloudaicompanion.googleapis.com/projects/rising-fact-p41fc/locations/global' (or it may not exist).
219
+ ---
550
220
 
551
- The plugin attempts to provision or find a suitable Google Cloud project when authenticating with Antigravity. If none is found, it defaults to a predefined project ID set by the `ANTIGRAVITY_DEFAULT_PROJECT_ID` variable in this project. While this works for Antigravity, Gemini CLI throws an error because this project ID does not exist in your Google Cloud account.
552
-
553
- For it to work, you can follow similar steps in [opencode-gemini-auth](https://github.com/jenslys/opencode-gemini-auth?tab=readme-ov-file#manual-google-cloud-setup):
554
- * Go to the [Google Cloud Console](https://console.cloud.google.com/).
555
- * Create or select a project.
556
- * Enable the Gemini for Google Cloud API (cloudaicompanion.googleapis.com).
557
- * Configure the projectId in your Opencode config as shown above.
558
-
559
- Then you add the project ID to your `~/.config/opencode/antigravity-accounts.json` setup under your account, you can add it as a `projectId` field:
560
- ```json
561
- {
562
- "version": 3,
563
- "accounts": [
564
- {
565
- "email": "<<your email>>",
566
- "refreshToken": "<<your refresher token>>",
567
- "projectId": "<<place project ID here>>"
568
- }
569
- ],
570
- "activeIndex": 0,
571
- "activeIndexByFamily": {
572
- "claude": 0,
573
- "gemini": 0
574
- }
575
- }
576
- ```
577
-
578
- **Note**: This would have to be done per account if you have a multi-account setup.
579
-
580
- <details>
581
- <summary><b>Safari OAuth Callback Fails (macOS)</b></summary>
582
-
583
- **Symptoms:**
584
- - "fail to authorize" after successful Google login in browser
585
- - Safari shows "Safari can't open the page" or connection refused
586
- - Callback appears to succeed in browser but plugin reports failure
587
-
588
- **Cause:** Safari's "HTTPS-Only Mode" (enabled by default in recent macOS versions) blocks the `http://localhost` callback URL used during OAuth authentication.
589
-
590
- **Solutions (choose one):**
591
-
592
- 1. **Use a different browser** (easiest):
593
- Copy the URL printed by `opencode auth login` and paste it into Chrome or Firefox instead of Safari.
594
-
595
- 2. **Temporarily disable HTTPS-Only Mode:**
596
- - Safari > Settings (⌘,) > Privacy
597
- - Uncheck "Enable HTTPS-Only Mode"
598
- - Run `opencode auth login`
599
- - Re-enable after successful authentication
600
-
601
- 3. **Manual callback URL extraction** (advanced):
602
- - When Safari shows the error, look at the address bar
603
- - The URL should contain `?code=...&scope=...`
604
- - This auth code can be used manually (see [issue #119](https://github.com/NoeFabris/opencode-antigravity-auth/issues/119) for updates on manual auth support)
605
-
606
- </details>
607
-
608
- <details>
609
- <summary><b>Port Already in Use</b></summary>
610
-
611
- If OAuth fails with "Address already in use" or similar port binding errors:
612
-
613
- **macOS / Linux:**
614
- ```bash
615
- # Find what's using the OAuth callback port (usually 8080 or dynamic)
616
- # Try common ports (8080, 3000, 5000) or omit port for a full list
617
- lsof -i :8080 # or: lsof -i -P -n | grep LISTEN
618
-
619
- # If a stale process is found, terminate it
620
- kill -9 <PID>
621
-
622
- # Retry authentication
623
- opencode auth login
624
- ```
625
-
626
- **Windows (PowerShell / Command Prompt):**
627
- ```powershell
628
- # Find what's using the port
629
- netstat -ano | findstr :8080
630
-
631
- # Terminate the process (replace <PID> with the actual process ID)
632
- taskkill /PID <PID> /F
633
-
634
- # Retry authentication
635
- opencode auth login
636
- ```
637
-
638
- </details>
639
-
640
- <details>
641
- <summary><b>WSL2 / Remote Development</b></summary>
642
-
643
- For users running OpenCode in WSL2 or over SSH:
644
- - The OAuth callback requires the browser to reach `localhost` on the machine running OpenCode
645
- - For WSL2: Ensure port forwarding is configured, or use VS Code's port forwarding
646
- - For SSH: Use SSH port forwarding: `ssh -L 8080:localhost:8080 user@remote`
647
- - For headless servers: See [issue #119](https://github.com/NoeFabris/opencode-antigravity-auth/issues/119) for manual URL auth (in development)
648
-
649
- </details>
650
-
651
- ## Known Plugin Interactions
221
+ ## Plugin Compatibility
652
222
 
653
223
  ### @tarquinen/opencode-dcp
654
224
 
655
- DCP creates synthetic assistant messages that lack thinking blocks. **Our plugin must be listed BEFORE DCP:**
225
+ DCP creates synthetic assistant messages that lack thinking blocks. **List this plugin BEFORE DCP:**
656
226
 
657
227
  ```json
658
228
  {
659
229
  "plugin": [
660
- "opencode-antigravity-auth@beta",
661
- "@tarquinen/opencode-dcp@latest",
230
+ "opencode-antigravity-auth@latest",
231
+ "@tarquinen/opencode-dcp@latest"
662
232
  ]
663
233
  }
664
234
  ```
665
235
 
666
236
  ### oh-my-opencode
667
- When using opencode-antigravity-auth, disable the built-in auth and override agent models in oh-my-opencode.json:
237
+
238
+ Disable built-in auth and override agent models in `oh-my-opencode.json`:
239
+
668
240
  ```json
669
241
  {
670
242
  "google_auth": false,
671
243
  "agents": {
672
- "frontend-ui-ux-engineer": { "model": "google/gemini-3-pro-high" },
673
- "document-writer": { "model": "google/gemini-3-flash" },
674
- "multimodal-looker": { "model": "google/gemini-3-flash" }
244
+ "frontend-ui-ux-engineer": { "model": "google/antigravity-gemini-3-pro" },
245
+ "document-writer": { "model": "google/antigravity-gemini-3-flash" },
246
+ "multimodal-looker": { "model": "google/antigravity-gemini-3-flash" }
675
247
  }
676
248
  }
677
249
  ```
678
250
 
679
- When spawning parallel subagents, multiple processes may select the same account causing rate limit errors. **Workaround:** Enable `pid_offset_enabled: true` to distribute sessions across accounts, or add more accounts via `opencode auth login`.
680
-
681
- ### Plugins You Don't Need
682
-
683
- - **gemini-auth plugins** - Not needed. This plugin handles all Google OAuth authentication.
684
-
685
- <details>
686
- <summary><b>Migration Guide (v1.2.8+ - Variants)</b></summary>
251
+ > **Tip:** When spawning parallel subagents, enable `pid_offset_enabled: true` in `antigravity.json` to distribute sessions across accounts.
687
252
 
688
- ### What Changed
253
+ ### Plugins you don't need
689
254
 
690
- v1.2.8+ introduces **model variants** for dynamic thinking configuration. Instead of separate models for each thinking level, you now define one model with variants.
255
+ - **gemini-auth plugins** Not needed. This plugin handles all Google OAuth.
691
256
 
692
- ### Before (v1.2.7)
257
+ ---
693
258
 
694
- ```json
695
- {
696
- "antigravity-claude-sonnet-4-5-thinking-low": { ... },
697
- "antigravity-claude-sonnet-4-5-thinking-medium": { ... },
698
- "antigravity-claude-sonnet-4-5-thinking-high": { ... }
699
- }
700
- ```
259
+ ## Configuration
701
260
 
702
- ### After (v1.2.8+)
261
+ Create `~/.config/opencode/antigravity.json` for advanced settings:
703
262
 
704
263
  ```json
705
264
  {
706
- "antigravity-claude-sonnet-4-5-thinking": {
707
- "name": "Claude Sonnet 4.5 Thinking",
708
- "limit": { "context": 200000, "output": 64000 },
709
- "modalities": { "input": ["text", "image", "pdf"], "output": ["text"] },
710
- "variants": {
711
- "low": { "thinkingConfig": { "thinkingBudget": 8192 } },
712
- "max": { "thinkingConfig": { "thinkingBudget": 32768 } }
713
- }
714
- }
265
+ "$schema": "https://raw.githubusercontent.com/NoeFabris/opencode-antigravity-auth/main/assets/antigravity.schema.json",
266
+ "quiet_mode": false,
267
+ "debug": false
715
268
  }
716
269
  ```
717
270
 
718
- ### Benefits
719
-
720
- - **Cleaner model picker** - 4 models instead of 12+
721
- - **Flexible budgets** - Define any budget, not just low/max
722
- - **Future-proof** - Works with OpenCode's native variant system
723
-
724
- ### Backward Compatibility
725
-
726
- Old tier-suffixed models (`antigravity-claude-sonnet-4-5-thinking-low`, etc.) still work. No action required if you prefer the old style.
727
-
728
- </details>
729
-
730
- <details>
731
- <summary><b>Migration Guide (v1.2.7 - Prefix)</b></summary>
732
-
733
- If upgrading from v1.2.6 or earlier:
734
-
735
- ### What Changed
736
-
737
- v1.2.7+ uses explicit prefixes to distinguish quota sources:
738
-
739
- | Model Type | New Name (Recommended) | Old Name (Still Works) |
740
- |------------|------------------------|------------------------|
741
- | Gemini 3 (Antigravity) | `antigravity-gemini-3-pro` | `gemini-3-pro-low` |
742
- | Gemini 3 (CLI) | `gemini-3-pro-preview` | N/A |
743
- | Claude | `antigravity-claude-sonnet-4-5` | `claude-sonnet-4-5` |
744
-
745
- ### Action Required
746
-
747
- **Update your config to use `antigravity-` prefix:**
748
-
749
- ```diff
750
- - "gemini-3-pro-low": { ... }
751
- + "antigravity-gemini-3-pro": { ... }
752
- ```
753
-
754
- > **Why update?** Old names work now as a fallback, but this depends on Gemini CLI using `-preview` suffix. If Google removes `-preview` in the future, old names may route to the wrong quota. The `antigravity-` prefix is explicit and stable.
271
+ | Option | Default | What it does |
272
+ |--------|---------|--------------|
273
+ | `quiet_mode` | `false` | Hide toast notifications |
274
+ | `debug` | `false` | Enable debug logging |
275
+ | `session_recovery` | `true` | Auto-recover from tool errors |
276
+ | `auto_resume` | `true` | Auto-send "continue" after recovery |
277
+ | `web_search.default_mode` | `"off"` | Google Search grounding: `"auto"` or `"off"` |
755
278
 
756
- ### Step 1: Clear Old Tokens (Optional - do this if you have issues calling models)
279
+ For all options, see [docs/CONFIGURATION.md](docs/CONFIGURATION.md).
757
280
 
281
+ **Environment variables:**
758
282
  ```bash
759
- rm -rf ~/.config/opencode/antigravity-account.json
760
- opencode auth login
283
+ OPENCODE_ANTIGRAVITY_DEBUG=1 opencode # Enable debug logging
284
+ OPENCODE_ANTIGRAVITY_DEBUG=2 opencode # Verbose logging
761
285
  ```
762
286
 
763
- ### Step 2: Update opencode.json
764
-
765
- Models now use `antigravity-` prefix for Antigravity quota. See [Available Models](#available-models).
766
-
767
- ### Step 3: Create antigravity.json (Optional)
287
+ ---
768
288
 
769
- ```json
770
- {
771
- "$schema": "https://raw.githubusercontent.com/NoeFabris/opencode-antigravity-auth/main/assets/antigravity.schema.json",
772
- "quiet_mode": false,
773
- "debug": false
774
- }
775
- ```
289
+ ## Troubleshooting
776
290
 
777
- </details>
291
+ See the full [Troubleshooting Guide](docs/TROUBLESHOOTING.md) for solutions to common issues including:
778
292
 
779
- <details>
780
- <summary><b>E2E Testing</b></summary>
293
+ - Auth problems and token refresh
294
+ - "Model not found" errors
295
+ - Session recovery
296
+ - Gemini CLI permission errors
297
+ - Safari OAuth issues
298
+ - Plugin compatibility
299
+ - Migration guides
781
300
 
782
- The plugin includes regression tests for stability verification. Tests consume API quota.
301
+ ---
783
302
 
784
- ```bash
785
- # Sanity tests (7 tests, ~5 min)
786
- npx tsx script/test-regression.ts --sanity
303
+ ## Documentation
787
304
 
788
- # Heavy tests (4 tests, ~30 min)
789
- npx tsx script/test-regression.ts --heavy
305
+ - [Configuration](docs/CONFIGURATION.md) All configuration options
306
+ - [Multi-Account](docs/MULTI-ACCOUNT.md) — Load balancing, dual quota pools, account storage
307
+ - [Model Variants](docs/MODEL-VARIANTS.md) — Thinking budgets and variant system
308
+ - [Troubleshooting](docs/TROUBLESHOOTING.md) — Common issues and fixes
309
+ - [Architecture](docs/ARCHITECTURE.md) — How the plugin works
310
+ - [API Spec](docs/ANTIGRAVITY_API_SPEC.md) — Antigravity API reference
790
311
 
791
- # Concurrent tests (3 tests)
792
- npx tsx script/test-regression.ts --category concurrency
312
+ ---
793
313
 
794
- # Run specific test
795
- npx tsx script/test-regression.ts --test thinking-tool-use
314
+ ## Support
796
315
 
797
- # List tests without running
798
- npx tsx script/test-regression.ts --dry-run
799
- ```
316
+ If this plugin helps you, consider supporting its maintenance:
800
317
 
801
- </details>
318
+ [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/S6S81QBOIR)
802
319
 
803
- ## Debugging
320
+ ---
804
321
 
805
- ```bash
806
- OPENCODE_ANTIGRAVITY_DEBUG=1 opencode # Basic logging
807
- OPENCODE_ANTIGRAVITY_DEBUG=2 opencode # Verbose (full request/response bodies)
808
- ```
322
+ ## Credits
809
323
 
810
- Logs are written to `~/.config/opencode/antigravity-logs/`.
324
+ - [opencode-gemini-auth](https://github.com/jenslys/opencode-gemini-auth) by [@jenslys](https://github.com/jenslys)
325
+ - [CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI)
811
326
 
812
- ## Documentation
327
+ ## License
813
328
 
814
- - [Architecture](docs/ARCHITECTURE.md) - Plugin internals and request flow
815
- - [API Spec](docs/ANTIGRAVITY_API_SPEC.md) - Antigravity API reference
329
+ MIT License. See [LICENSE](LICENSE) for details.
816
330
 
817
331
  <details>
818
- <summary><b>Safety, Usage & Legal</b></summary>
332
+ <summary><b>Legal</b></summary>
819
333
 
820
334
  ### Intended Use
821
335
 
@@ -823,36 +337,18 @@ Logs are written to `~/.config/opencode/antigravity-logs/`.
823
337
  - Respect internal quotas and data handling policies
824
338
  - Not for production services or bypassing intended limits
825
339
 
826
- ### Warning (Assumption of Risk)
340
+ ### Warning
827
341
 
828
342
  By using this plugin, you acknowledge:
829
343
 
830
- - **Terms of Service risk** - This approach may violate ToS of AI model providers
831
- - **Account risk** - Providers may suspend or ban accounts
832
- - **No guarantees** - APIs may change without notice
833
- - **Assumption of risk** - You assume all legal, financial, and technical risks
344
+ - **Terms of Service risk** This approach may violate ToS of AI model providers
345
+ - **Account risk** Providers may suspend or ban accounts
346
+ - **No guarantees** APIs may change without notice
347
+ - **Assumption of risk** You assume all legal, financial, and technical risks
834
348
 
835
- ### Legal
349
+ ### Disclaimer
836
350
 
837
351
  - Not affiliated with Google. This is an independent open-source project.
838
352
  - "Antigravity", "Gemini", "Google Cloud", and "Google" are trademarks of Google LLC.
839
- - Software is provided "as is", without warranty.
840
353
 
841
354
  </details>
842
-
843
- ## Credits
844
-
845
- Built with help from:
846
-
847
- - [opencode-gemini-auth](https://github.com/jenslys/opencode-gemini-auth) - Gemini OAuth groundwork by [@jenslys](https://github.com/jenslys)
848
- - [CLIProxyAPI](https://github.com/router-for-me/CLIProxyAPI) - Antigravity API reference
849
-
850
- ## Support
851
-
852
- If this plugin helps you, consider supporting its continued maintenance:
853
-
854
- [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/S6S81QBOIR)
855
-
856
- ## License
857
-
858
- MIT