opencode-antigravity-auth-tweaked 1.6.0

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