@percygfx/opencode-antigravity-auth 0.0.0-stage → 2.0.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 (312) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +896 -3
  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/rpc.d.ts +176 -0
  8. package/dist/rpc.d.ts.map +1 -0
  9. package/dist/rpc.js +91 -0
  10. package/dist/rpc.js.map +1 -0
  11. package/dist/server.d.ts +3 -0
  12. package/dist/server.d.ts.map +1 -0
  13. package/dist/server.js +5 -0
  14. package/dist/server.js.map +1 -0
  15. package/dist/src/antigravity/oauth.d.ts +31 -0
  16. package/dist/src/antigravity/oauth.d.ts.map +1 -0
  17. package/dist/src/antigravity/oauth.js +171 -0
  18. package/dist/src/antigravity/oauth.js.map +1 -0
  19. package/dist/src/constants.d.ts +153 -0
  20. package/dist/src/constants.d.ts.map +1 -0
  21. package/dist/src/constants.js +238 -0
  22. package/dist/src/constants.js.map +1 -0
  23. package/dist/src/core/gateway.d.ts +43 -0
  24. package/dist/src/core/gateway.d.ts.map +1 -0
  25. package/dist/src/core/gateway.js +241 -0
  26. package/dist/src/core/gateway.js.map +1 -0
  27. package/dist/src/core/index.d.ts +8 -0
  28. package/dist/src/core/index.d.ts.map +1 -0
  29. package/dist/src/core/index.js +8 -0
  30. package/dist/src/core/index.js.map +1 -0
  31. package/dist/src/core/types.d.ts +60 -0
  32. package/dist/src/core/types.d.ts.map +1 -0
  33. package/dist/src/core/types.js +5 -0
  34. package/dist/src/core/types.js.map +1 -0
  35. package/dist/src/hooks/auto-update-checker/cache.d.ts +3 -0
  36. package/dist/src/hooks/auto-update-checker/cache.d.ts.map +1 -0
  37. package/dist/src/hooks/auto-update-checker/cache.js +71 -0
  38. package/dist/src/hooks/auto-update-checker/cache.js.map +1 -0
  39. package/dist/src/hooks/auto-update-checker/checker.d.ts +16 -0
  40. package/dist/src/hooks/auto-update-checker/checker.d.ts.map +1 -0
  41. package/dist/src/hooks/auto-update-checker/checker.js +234 -0
  42. package/dist/src/hooks/auto-update-checker/checker.js.map +1 -0
  43. package/dist/src/hooks/auto-update-checker/constants.d.ts +11 -0
  44. package/dist/src/hooks/auto-update-checker/constants.d.ts.map +1 -0
  45. package/dist/src/hooks/auto-update-checker/constants.js +26 -0
  46. package/dist/src/hooks/auto-update-checker/constants.js.map +1 -0
  47. package/dist/src/hooks/auto-update-checker/index.d.ts +34 -0
  48. package/dist/src/hooks/auto-update-checker/index.d.ts.map +1 -0
  49. package/dist/src/hooks/auto-update-checker/index.js +122 -0
  50. package/dist/src/hooks/auto-update-checker/index.js.map +1 -0
  51. package/dist/src/hooks/auto-update-checker/logging.d.ts +3 -0
  52. package/dist/src/hooks/auto-update-checker/logging.d.ts.map +1 -0
  53. package/dist/src/hooks/auto-update-checker/logging.js +9 -0
  54. package/dist/src/hooks/auto-update-checker/logging.js.map +1 -0
  55. package/dist/src/hooks/auto-update-checker/types.d.ts +25 -0
  56. package/dist/src/hooks/auto-update-checker/types.d.ts.map +1 -0
  57. package/dist/src/hooks/auto-update-checker/types.js +1 -0
  58. package/dist/src/hooks/auto-update-checker/types.js.map +1 -0
  59. package/dist/src/opencode-v2/accounts.d.ts +24 -0
  60. package/dist/src/opencode-v2/accounts.d.ts.map +1 -0
  61. package/dist/src/opencode-v2/accounts.js +109 -0
  62. package/dist/src/opencode-v2/accounts.js.map +1 -0
  63. package/dist/src/opencode-v2/catalog.d.ts +31 -0
  64. package/dist/src/opencode-v2/catalog.d.ts.map +1 -0
  65. package/dist/src/opencode-v2/catalog.js +68 -0
  66. package/dist/src/opencode-v2/catalog.js.map +1 -0
  67. package/dist/src/opencode-v2/client-shim.d.ts +9 -0
  68. package/dist/src/opencode-v2/client-shim.d.ts.map +1 -0
  69. package/dist/src/opencode-v2/client-shim.js +42 -0
  70. package/dist/src/opencode-v2/client-shim.js.map +1 -0
  71. package/dist/src/opencode-v2/clipboard.d.ts +7 -0
  72. package/dist/src/opencode-v2/clipboard.d.ts.map +1 -0
  73. package/dist/src/opencode-v2/clipboard.js +54 -0
  74. package/dist/src/opencode-v2/clipboard.js.map +1 -0
  75. package/dist/src/opencode-v2/index.d.ts +5 -0
  76. package/dist/src/opencode-v2/index.d.ts.map +1 -0
  77. package/dist/src/opencode-v2/index.js +4 -0
  78. package/dist/src/opencode-v2/index.js.map +1 -0
  79. package/dist/src/opencode-v2/plugin.d.ts +23 -0
  80. package/dist/src/opencode-v2/plugin.d.ts.map +1 -0
  81. package/dist/src/opencode-v2/plugin.js +466 -0
  82. package/dist/src/opencode-v2/plugin.js.map +1 -0
  83. package/dist/src/opencode-v2/proxy.d.ts +23 -0
  84. package/dist/src/opencode-v2/proxy.d.ts.map +1 -0
  85. package/dist/src/opencode-v2/proxy.js +148 -0
  86. package/dist/src/opencode-v2/proxy.js.map +1 -0
  87. package/dist/src/opencode-v2/quota-format.d.ts +19 -0
  88. package/dist/src/opencode-v2/quota-format.d.ts.map +1 -0
  89. package/dist/src/opencode-v2/quota-format.js +71 -0
  90. package/dist/src/opencode-v2/quota-format.js.map +1 -0
  91. package/dist/src/opencode-v2/quota.d.ts +18 -0
  92. package/dist/src/opencode-v2/quota.d.ts.map +1 -0
  93. package/dist/src/opencode-v2/quota.js +118 -0
  94. package/dist/src/opencode-v2/quota.js.map +1 -0
  95. package/dist/src/opencode-v2/sign-in-attempts.d.ts +52 -0
  96. package/dist/src/opencode-v2/sign-in-attempts.d.ts.map +1 -0
  97. package/dist/src/opencode-v2/sign-in-attempts.js +81 -0
  98. package/dist/src/opencode-v2/sign-in-attempts.js.map +1 -0
  99. package/dist/src/plugin/account-models.d.ts +38 -0
  100. package/dist/src/plugin/account-models.d.ts.map +1 -0
  101. package/dist/src/plugin/account-models.js +78 -0
  102. package/dist/src/plugin/account-models.js.map +1 -0
  103. package/dist/src/plugin/accounts.d.ts +186 -0
  104. package/dist/src/plugin/accounts.d.ts.map +1 -0
  105. package/dist/src/plugin/accounts.js +1045 -0
  106. package/dist/src/plugin/accounts.js.map +1 -0
  107. package/dist/src/plugin/auth.d.ts +21 -0
  108. package/dist/src/plugin/auth.d.ts.map +1 -0
  109. package/dist/src/plugin/auth.js +46 -0
  110. package/dist/src/plugin/auth.js.map +1 -0
  111. package/dist/src/plugin/cache/index.d.ts +5 -0
  112. package/dist/src/plugin/cache/index.d.ts.map +1 -0
  113. package/dist/src/plugin/cache/index.js +5 -0
  114. package/dist/src/plugin/cache/index.js.map +1 -0
  115. package/dist/src/plugin/cache/signature-cache.d.ts +111 -0
  116. package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -0
  117. package/dist/src/plugin/cache/signature-cache.js +375 -0
  118. package/dist/src/plugin/cache/signature-cache.js.map +1 -0
  119. package/dist/src/plugin/cache.d.ts +44 -0
  120. package/dist/src/plugin/cache.d.ts.map +1 -0
  121. package/dist/src/plugin/cache.js +200 -0
  122. package/dist/src/plugin/cache.js.map +1 -0
  123. package/dist/src/plugin/cli.d.ts +26 -0
  124. package/dist/src/plugin/cli.d.ts.map +1 -0
  125. package/dist/src/plugin/cli.js +119 -0
  126. package/dist/src/plugin/cli.js.map +1 -0
  127. package/dist/src/plugin/config/index.d.ts +16 -0
  128. package/dist/src/plugin/config/index.d.ts.map +1 -0
  129. package/dist/src/plugin/config/index.js +16 -0
  130. package/dist/src/plugin/config/index.js.map +1 -0
  131. package/dist/src/plugin/config/loader.d.ts +36 -0
  132. package/dist/src/plugin/config/loader.d.ts.map +1 -0
  133. package/dist/src/plugin/config/loader.js +140 -0
  134. package/dist/src/plugin/config/loader.js.map +1 -0
  135. package/dist/src/plugin/config/models.d.ts +41 -0
  136. package/dist/src/plugin/config/models.d.ts.map +1 -0
  137. package/dist/src/plugin/config/models.js +46 -0
  138. package/dist/src/plugin/config/models.js.map +1 -0
  139. package/dist/src/plugin/config/schema.d.ts +135 -0
  140. package/dist/src/plugin/config/schema.d.ts.map +1 -0
  141. package/dist/src/plugin/config/schema.js +438 -0
  142. package/dist/src/plugin/config/schema.js.map +1 -0
  143. package/dist/src/plugin/config/updater.d.ts +55 -0
  144. package/dist/src/plugin/config/updater.d.ts.map +1 -0
  145. package/dist/src/plugin/config/updater.js +125 -0
  146. package/dist/src/plugin/config/updater.js.map +1 -0
  147. package/dist/src/plugin/core/streaming/index.d.ts +3 -0
  148. package/dist/src/plugin/core/streaming/index.d.ts.map +1 -0
  149. package/dist/src/plugin/core/streaming/index.js +3 -0
  150. package/dist/src/plugin/core/streaming/index.js.map +1 -0
  151. package/dist/src/plugin/core/streaming/transformer.d.ts +10 -0
  152. package/dist/src/plugin/core/streaming/transformer.d.ts.map +1 -0
  153. package/dist/src/plugin/core/streaming/transformer.js +271 -0
  154. package/dist/src/plugin/core/streaming/transformer.js.map +1 -0
  155. package/dist/src/plugin/core/streaming/types.d.ts +27 -0
  156. package/dist/src/plugin/core/streaming/types.d.ts.map +1 -0
  157. package/dist/src/plugin/core/streaming/types.js +1 -0
  158. package/dist/src/plugin/core/streaming/types.js.map +1 -0
  159. package/dist/src/plugin/debug.d.ts +94 -0
  160. package/dist/src/plugin/debug.d.ts.map +1 -0
  161. package/dist/src/plugin/debug.js +382 -0
  162. package/dist/src/plugin/debug.js.map +1 -0
  163. package/dist/src/plugin/errors.d.ts +28 -0
  164. package/dist/src/plugin/errors.d.ts.map +1 -0
  165. package/dist/src/plugin/errors.js +42 -0
  166. package/dist/src/plugin/errors.js.map +1 -0
  167. package/dist/src/plugin/fingerprint.d.ts +70 -0
  168. package/dist/src/plugin/fingerprint.d.ts.map +1 -0
  169. package/dist/src/plugin/fingerprint.js +138 -0
  170. package/dist/src/plugin/fingerprint.js.map +1 -0
  171. package/dist/src/plugin/image-saver.d.ts +25 -0
  172. package/dist/src/plugin/image-saver.d.ts.map +1 -0
  173. package/dist/src/plugin/image-saver.js +86 -0
  174. package/dist/src/plugin/image-saver.js.map +1 -0
  175. package/dist/src/plugin/logger.d.ts +36 -0
  176. package/dist/src/plugin/logger.d.ts.map +1 -0
  177. package/dist/src/plugin/logger.js +71 -0
  178. package/dist/src/plugin/logger.js.map +1 -0
  179. package/dist/src/plugin/logging-utils.d.ts +23 -0
  180. package/dist/src/plugin/logging-utils.d.ts.map +1 -0
  181. package/dist/src/plugin/logging-utils.js +92 -0
  182. package/dist/src/plugin/logging-utils.js.map +1 -0
  183. package/dist/src/plugin/model-discovery.d.ts +28 -0
  184. package/dist/src/plugin/model-discovery.d.ts.map +1 -0
  185. package/dist/src/plugin/model-discovery.js +59 -0
  186. package/dist/src/plugin/model-discovery.js.map +1 -0
  187. package/dist/src/plugin/model-registry.d.ts +108 -0
  188. package/dist/src/plugin/model-registry.d.ts.map +1 -0
  189. package/dist/src/plugin/model-registry.js +304 -0
  190. package/dist/src/plugin/model-registry.js.map +1 -0
  191. package/dist/src/plugin/project.d.ts +33 -0
  192. package/dist/src/plugin/project.d.ts.map +1 -0
  193. package/dist/src/plugin/project.js +235 -0
  194. package/dist/src/plugin/project.js.map +1 -0
  195. package/dist/src/plugin/quota.d.ts +58 -0
  196. package/dist/src/plugin/quota.d.ts.map +1 -0
  197. package/dist/src/plugin/quota.js +296 -0
  198. package/dist/src/plugin/quota.js.map +1 -0
  199. package/dist/src/plugin/recovery/constants.d.ts +22 -0
  200. package/dist/src/plugin/recovery/constants.d.ts.map +1 -0
  201. package/dist/src/plugin/recovery/constants.js +43 -0
  202. package/dist/src/plugin/recovery/constants.js.map +1 -0
  203. package/dist/src/plugin/recovery/index.d.ts +12 -0
  204. package/dist/src/plugin/recovery/index.d.ts.map +1 -0
  205. package/dist/src/plugin/recovery/index.js +12 -0
  206. package/dist/src/plugin/recovery/index.js.map +1 -0
  207. package/dist/src/plugin/recovery/storage.d.ts +24 -0
  208. package/dist/src/plugin/recovery/storage.d.ts.map +1 -0
  209. package/dist/src/plugin/recovery/storage.js +354 -0
  210. package/dist/src/plugin/recovery/storage.js.map +1 -0
  211. package/dist/src/plugin/recovery/types.d.ts +116 -0
  212. package/dist/src/plugin/recovery/types.d.ts.map +1 -0
  213. package/dist/src/plugin/recovery/types.js +6 -0
  214. package/dist/src/plugin/recovery/types.js.map +1 -0
  215. package/dist/src/plugin/recovery.d.ts +61 -0
  216. package/dist/src/plugin/recovery.d.ts.map +1 -0
  217. package/dist/src/plugin/recovery.js +381 -0
  218. package/dist/src/plugin/recovery.js.map +1 -0
  219. package/dist/src/plugin/refresh-queue.d.ts +100 -0
  220. package/dist/src/plugin/refresh-queue.d.ts.map +1 -0
  221. package/dist/src/plugin/refresh-queue.js +247 -0
  222. package/dist/src/plugin/refresh-queue.js.map +1 -0
  223. package/dist/src/plugin/request-helpers.d.ts +282 -0
  224. package/dist/src/plugin/request-helpers.d.ts.map +1 -0
  225. package/dist/src/plugin/request-helpers.js +2343 -0
  226. package/dist/src/plugin/request-helpers.js.map +1 -0
  227. package/dist/src/plugin/request.d.ts +95 -0
  228. package/dist/src/plugin/request.d.ts.map +1 -0
  229. package/dist/src/plugin/request.js +1491 -0
  230. package/dist/src/plugin/request.js.map +1 -0
  231. package/dist/src/plugin/rotation.d.ts +169 -0
  232. package/dist/src/plugin/rotation.d.ts.map +1 -0
  233. package/dist/src/plugin/rotation.js +328 -0
  234. package/dist/src/plugin/rotation.js.map +1 -0
  235. package/dist/src/plugin/search.d.ts +32 -0
  236. package/dist/src/plugin/search.d.ts.map +1 -0
  237. package/dist/src/plugin/search.js +195 -0
  238. package/dist/src/plugin/search.js.map +1 -0
  239. package/dist/src/plugin/server.d.ts +23 -0
  240. package/dist/src/plugin/server.d.ts.map +1 -0
  241. package/dist/src/plugin/server.js +324 -0
  242. package/dist/src/plugin/server.js.map +1 -0
  243. package/dist/src/plugin/storage.d.ts +173 -0
  244. package/dist/src/plugin/storage.d.ts.map +1 -0
  245. package/dist/src/plugin/storage.js +674 -0
  246. package/dist/src/plugin/storage.js.map +1 -0
  247. package/dist/src/plugin/stores/signature-store.d.ts +5 -0
  248. package/dist/src/plugin/stores/signature-store.d.ts.map +1 -0
  249. package/dist/src/plugin/stores/signature-store.js +25 -0
  250. package/dist/src/plugin/stores/signature-store.js.map +1 -0
  251. package/dist/src/plugin/thinking-recovery.d.ts +90 -0
  252. package/dist/src/plugin/thinking-recovery.d.ts.map +1 -0
  253. package/dist/src/plugin/thinking-recovery.js +316 -0
  254. package/dist/src/plugin/thinking-recovery.js.map +1 -0
  255. package/dist/src/plugin/token.d.ts +19 -0
  256. package/dist/src/plugin/token.d.ts.map +1 -0
  257. package/dist/src/plugin/token.js +128 -0
  258. package/dist/src/plugin/token.js.map +1 -0
  259. package/dist/src/plugin/transform/claude.d.ts +80 -0
  260. package/dist/src/plugin/transform/claude.d.ts.map +1 -0
  261. package/dist/src/plugin/transform/claude.js +265 -0
  262. package/dist/src/plugin/transform/claude.js.map +1 -0
  263. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +35 -0
  264. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts.map +1 -0
  265. package/dist/src/plugin/transform/cross-model-sanitizer.js +225 -0
  266. package/dist/src/plugin/transform/cross-model-sanitizer.js.map +1 -0
  267. package/dist/src/plugin/transform/gemini.d.ts +100 -0
  268. package/dist/src/plugin/transform/gemini.d.ts.map +1 -0
  269. package/dist/src/plugin/transform/gemini.js +446 -0
  270. package/dist/src/plugin/transform/gemini.js.map +1 -0
  271. package/dist/src/plugin/transform/index.d.ts +15 -0
  272. package/dist/src/plugin/transform/index.d.ts.map +1 -0
  273. package/dist/src/plugin/transform/index.js +14 -0
  274. package/dist/src/plugin/transform/index.js.map +1 -0
  275. package/dist/src/plugin/transform/model-resolver.d.ts +99 -0
  276. package/dist/src/plugin/transform/model-resolver.d.ts.map +1 -0
  277. package/dist/src/plugin/transform/model-resolver.js +340 -0
  278. package/dist/src/plugin/transform/model-resolver.js.map +1 -0
  279. package/dist/src/plugin/transform/types.d.ts +111 -0
  280. package/dist/src/plugin/transform/types.d.ts.map +1 -0
  281. package/dist/src/plugin/transform/types.js +1 -0
  282. package/dist/src/plugin/transform/types.js.map +1 -0
  283. package/dist/src/plugin/types.d.ts +97 -0
  284. package/dist/src/plugin/types.d.ts.map +1 -0
  285. package/dist/src/plugin/types.js +1 -0
  286. package/dist/src/plugin/types.js.map +1 -0
  287. package/dist/src/plugin/ui/ansi.d.ts +32 -0
  288. package/dist/src/plugin/ui/ansi.d.ts.map +1 -0
  289. package/dist/src/plugin/ui/ansi.js +52 -0
  290. package/dist/src/plugin/ui/ansi.js.map +1 -0
  291. package/dist/src/plugin/ui/auth-menu.d.ts +33 -0
  292. package/dist/src/plugin/ui/auth-menu.d.ts.map +1 -0
  293. package/dist/src/plugin/ui/auth-menu.js +110 -0
  294. package/dist/src/plugin/ui/auth-menu.js.map +1 -0
  295. package/dist/src/plugin/ui/confirm.d.ts +2 -0
  296. package/dist/src/plugin/ui/confirm.d.ts.map +1 -0
  297. package/dist/src/plugin/ui/confirm.js +15 -0
  298. package/dist/src/plugin/ui/confirm.js.map +1 -0
  299. package/dist/src/plugin/ui/select.d.ts +23 -0
  300. package/dist/src/plugin/ui/select.d.ts.map +1 -0
  301. package/dist/src/plugin/ui/select.js +254 -0
  302. package/dist/src/plugin/ui/select.js.map +1 -0
  303. package/dist/src/plugin/version.d.ts +19 -0
  304. package/dist/src/plugin/version.d.ts.map +1 -0
  305. package/dist/src/plugin/version.js +80 -0
  306. package/dist/src/plugin/version.js.map +1 -0
  307. package/dist/src/plugin.d.ts +51 -0
  308. package/dist/src/plugin.d.ts.map +1 -0
  309. package/dist/src/plugin.js +2852 -0
  310. package/dist/src/plugin.js.map +1 -0
  311. package/dist/tui.js +420 -0
  312. package/package.json +99 -6
@@ -0,0 +1,109 @@
1
+ import { formatRefreshParts, parseRefreshParts } from "../plugin/auth";
2
+ import { hashRefreshToken, loadAccounts, retireRefreshTokens, saveAccountsReplace, } from "../plugin/storage";
3
+ export class AccountNotFoundError extends Error {
4
+ constructor(email) {
5
+ super(`Account ${email} is no longer in the pool. Refresh and try again.`);
6
+ this.name = "AccountNotFoundError";
7
+ }
8
+ }
9
+ /** Fallback name for accounts without an email, matching the quota snapshot. */
10
+ export function accountLabel(account, index) {
11
+ return account.email ?? `Account ${index + 1}`;
12
+ }
13
+ /** Finds an account by its position and label; falls back to the label if the list shifted. */
14
+ function findAccount(accounts, index, email) {
15
+ const atIndex = accounts[index];
16
+ if (atIndex && accountLabel(atIndex, index) === email)
17
+ return index;
18
+ return accounts.findIndex((account, position) => accountLabel(account, position) === email);
19
+ }
20
+ async function loadPool() {
21
+ const storage = await loadAccounts();
22
+ if (!storage)
23
+ throw new Error("No Antigravity accounts are signed in.");
24
+ return storage;
25
+ }
26
+ /**
27
+ * Enables or disables an account for rotation. Goes through the running pipeline's account
28
+ * manager when there is one (it owns the pool in memory and would overwrite file edits).
29
+ */
30
+ export async function setAccountEnabled(manager, index, email, enabled) {
31
+ if (manager) {
32
+ const position = findAccount(manager.getAccounts(), index, email);
33
+ if (position < 0 || !manager.setAccountEnabled(position, enabled))
34
+ throw new AccountNotFoundError(email);
35
+ await manager.saveToDisk();
36
+ return;
37
+ }
38
+ const storage = await loadPool();
39
+ const position = findAccount(storage.accounts, index, email);
40
+ const account = storage.accounts[position];
41
+ if (!account)
42
+ throw new AccountNotFoundError(email);
43
+ account.enabled = enabled;
44
+ await saveAccountsReplace(storage);
45
+ }
46
+ function shiftIndex(value, removed, length) {
47
+ if (value === undefined)
48
+ return undefined;
49
+ const shifted = value > removed ? value - 1 : value;
50
+ return length === 0 ? 0 : Math.min(Math.max(shifted, 0), length - 1);
51
+ }
52
+ /** Removes an account from the pool. Returns how many accounts remain. */
53
+ export async function removeAccount(manager, index, email) {
54
+ if (manager) {
55
+ const accounts = manager.getAccounts();
56
+ const account = accounts[findAccount(accounts, index, email)];
57
+ if (!account || !manager.removeAccount(account))
58
+ throw new AccountNotFoundError(email);
59
+ // A merging save would bring the removed account back from the file, and other account
60
+ // managers still holding it would merge it back later: replace the file and retire the token.
61
+ await manager.saveToDisk({ replace: true });
62
+ await retireRefreshTokens([account.parts.refreshToken]);
63
+ return manager.getAccountCount();
64
+ }
65
+ const storage = await loadPool();
66
+ const position = findAccount(storage.accounts, index, email);
67
+ if (position < 0)
68
+ throw new AccountNotFoundError(email);
69
+ const [removed] = storage.accounts.splice(position, 1);
70
+ if (removed) {
71
+ storage.retiredTokenHashes = [...(storage.retiredTokenHashes ?? []), hashRefreshToken(removed.refreshToken)];
72
+ }
73
+ const length = storage.accounts.length;
74
+ storage.activeIndex = shiftIndex(storage.activeIndex, position, length) ?? 0;
75
+ if (storage.activeIndexByFamily) {
76
+ storage.activeIndexByFamily = {
77
+ claude: shiftIndex(storage.activeIndexByFamily.claude, position, length),
78
+ gemini: shiftIndex(storage.activeIndexByFamily.gemini, position, length),
79
+ };
80
+ }
81
+ await saveAccountsReplace(storage);
82
+ return length;
83
+ }
84
+ function toAuth(account) {
85
+ return {
86
+ type: "oauth",
87
+ refresh: formatRefreshParts({
88
+ refreshToken: account.refreshToken,
89
+ projectId: account.projectId,
90
+ managedProjectId: account.managedProjectId,
91
+ }),
92
+ };
93
+ }
94
+ /**
95
+ * The credential handed to the v1 account manager. The manager always adds the account behind
96
+ * that credential to the pool, so passing opencode's login after the user removed its account
97
+ * would bring the account back. Use the login only while its account is still in the pool;
98
+ * otherwise use an enabled pool account.
99
+ */
100
+ export async function poolAuth(auth) {
101
+ const storage = await loadAccounts().catch(() => null);
102
+ const accounts = storage?.accounts ?? [];
103
+ const token = parseRefreshParts(auth.refresh).refreshToken;
104
+ if (accounts.length === 0 || accounts.some((account) => account.refreshToken === token))
105
+ return auth;
106
+ const fallback = accounts.find((account) => account.enabled !== false) ?? accounts[0];
107
+ return fallback ? toAuth(fallback) : auth;
108
+ }
109
+ //# sourceMappingURL=accounts.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"accounts.js","sourceRoot":"","sources":["../../../src/opencode-v2/accounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,i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@ -0,0 +1,31 @@
1
+ import { Model, Provider } from "@opencode/plugin";
2
+ import { type ModelVariant } from "../plugin/config/models";
3
+ import { type RegistryModel } from "../plugin/model-registry";
4
+ /**
5
+ * Antigravity gets its own provider and integration instead of extending `google`: opencode v2
6
+ * keeps one active connection per integration, so an Antigravity OAuth login on `google` would
7
+ * replace a Gemini API key for every Google model.
8
+ */
9
+ export declare const ANTIGRAVITY_PROVIDER_ID = "google-antigravity";
10
+ export declare const ANTIGRAVITY_INTEGRATION_ID = "google-antigravity";
11
+ /** Browser sign-in: the v1 callback page on localhost:51121 catches the redirect. */
12
+ export declare const ANTIGRAVITY_METHOD_ID = "antigravity";
13
+ /** Paste sign-in: no local server; the redirect URL is pasted back (other machine, SSH). */
14
+ export declare const ANTIGRAVITY_PASTE_METHOD_ID = "antigravity-paste";
15
+ export declare function antigravityProviderInfo(baseURL: string): Provider.Info;
16
+ /**
17
+ * Builds the catalog from the model registry: Antigravity's Recommended list from the last
18
+ * discovery, or the built-in snapshot. Tiered models (Low/Medium/High) become one model with
19
+ * variants; the pipeline maps each variant to its own upstream model ID.
20
+ *
21
+ * Every model stays `active` even when Antigravity marks it "Leaving Soon": opencode's model
22
+ * picker hides deprecated models, and retired models drop out of the next discovery anyway.
23
+ */
24
+ export declare function antigravityModels(models?: readonly RegistryModel[]): Model.Info[];
25
+ /**
26
+ * v1 variants carry `thinkingLevel` or `thinkingConfig` options. opencode's native Gemini
27
+ * client reads both from `thinkingConfig` and sends them as `generationConfig.thinkingConfig`,
28
+ * which is where the v1 pipeline picks them up.
29
+ */
30
+ export declare function variantSettings(variant: ModelVariant): Provider.Settings;
31
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/opencode-v2/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAe,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEhE,OAAO,EAAyB,KAAK,YAAY,EAAE,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAqB,KAAK,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAEjF;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,uBAAuB,CAAC;AAC5D,eAAO,MAAM,0BAA0B,uBAAuB,CAAC;AAC/D,qFAAqF;AACrF,eAAO,MAAM,qBAAqB,gBAAgB,CAAC;AACnD,4FAA4F;AAC5F,eAAO,MAAM,2BAA2B,sBAAsB,CAAC;AAK/D,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,QAAQ,CAAC,IAAI,CAUtE;AAED;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,GAAE,SAAS,aAAa,EAAwB,GAAG,KAAK,CAAC,IAAI,EAAE,CAkBtG;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,YAAY,GAAG,QAAQ,CAAC,QAAQ,CAKxE"}
@@ -0,0 +1,68 @@
1
+ import { Integration, Model, Provider } from "@opencode/plugin";
2
+ import { registryModelVariants } from "../plugin/config/models";
3
+ import { getRegistryModels } from "../plugin/model-registry";
4
+ /**
5
+ * Antigravity gets its own provider and integration instead of extending `google`: opencode v2
6
+ * keeps one active connection per integration, so an Antigravity OAuth login on `google` would
7
+ * replace a Gemini API key for every Google model.
8
+ */
9
+ export const ANTIGRAVITY_PROVIDER_ID = "google-antigravity";
10
+ export const ANTIGRAVITY_INTEGRATION_ID = "google-antigravity";
11
+ /** Browser sign-in: the v1 callback page on localhost:51121 catches the redirect. */
12
+ export const ANTIGRAVITY_METHOD_ID = "antigravity";
13
+ /** Paste sign-in: no local server; the redirect URL is pasted back (other machine, SSH). */
14
+ export const ANTIGRAVITY_PASTE_METHOD_ID = "antigravity-paste";
15
+ /** opencode's native Gemini client; it talks the same REST shape the v1 pipeline rewrites. */
16
+ const NATIVE_GOOGLE_PACKAGE = "@opencode/ai/providers/google";
17
+ export function antigravityProviderInfo(baseURL) {
18
+ return {
19
+ id: Provider.ID.make(ANTIGRAVITY_PROVIDER_ID),
20
+ integrationID: Integration.ID.make(ANTIGRAVITY_INTEGRATION_ID),
21
+ name: "Google Antigravity",
22
+ // Listed once the integration has a connection, i.e. after `opencode auth login`.
23
+ activation: "auto",
24
+ package: NATIVE_GOOGLE_PACKAGE,
25
+ settings: { baseURL },
26
+ };
27
+ }
28
+ /**
29
+ * Builds the catalog from the model registry: Antigravity's Recommended list from the last
30
+ * discovery, or the built-in snapshot. Tiered models (Low/Medium/High) become one model with
31
+ * variants; the pipeline maps each variant to its own upstream model ID.
32
+ *
33
+ * Every model stays `active` even when Antigravity marks it "Leaving Soon": opencode's model
34
+ * picker hides deprecated models, and retired models drop out of the next discovery anyway.
35
+ */
36
+ export function antigravityModels(models = getRegistryModels()) {
37
+ const providerID = Provider.ID.make(ANTIGRAVITY_PROVIDER_ID);
38
+ return models.map((model) => ({
39
+ ...Model.Info.default(providerID, Model.ID.make(`antigravity-${model.id}`)),
40
+ name: model.name,
41
+ capabilities: {
42
+ tools: true,
43
+ input: model.supportsImages ? ["text", "image", "pdf"] : ["text"],
44
+ output: ["text"],
45
+ },
46
+ variants: Object.entries(registryModelVariants(model) ?? {}).map(([variantID, variant]) => ({
47
+ id: Model.VariantID.make(variantID),
48
+ settings: variantSettings(variant),
49
+ })),
50
+ // Antigravity usage is quota-based, not billed per token.
51
+ cost: [],
52
+ limit: { context: model.contextLimit, output: model.outputLimit },
53
+ }));
54
+ }
55
+ /**
56
+ * v1 variants carry `thinkingLevel` or `thinkingConfig` options. opencode's native Gemini
57
+ * client reads both from `thinkingConfig` and sends them as `generationConfig.thinkingConfig`,
58
+ * which is where the v1 pipeline picks them up.
59
+ */
60
+ export function variantSettings(variant) {
61
+ const thinkingConfig = {};
62
+ if (variant.thinkingLevel)
63
+ thinkingConfig.thinkingLevel = variant.thinkingLevel;
64
+ if (variant.thinkingConfig)
65
+ thinkingConfig.thinkingBudget = variant.thinkingConfig.thinkingBudget;
66
+ return Object.keys(thinkingConfig).length > 0 ? { thinkingConfig } : {};
67
+ }
68
+ //# sourceMappingURL=catalog.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.js","sourceRoot":"","sources":["../../../src/opencode-v2/catalog.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAEhE,OAAO,EAAE,qBAAqB,EAAqB,MAAM,yBAAyB,CAAC;AACnF,OAAO,EAAE,iBAAiB,EAAsB,MAAM,0BAA0B,CAAC;AAEjF;;;;GAIG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,oBAAoB,CAAC;AAC5D,MAAM,CAAC,MAAM,0BAA0B,GAAG,oBAAoB,CAAC;AAC/D,qFAAqF;AACrF,MAAM,CAAC,MAAM,qBAAqB,GAAG,aAAa,CAAC;AACnD,4FAA4F;AAC5F,MAAM,CAAC,MAAM,2BAA2B,GAAG,mBAAmB,CAAC;AAE/D,8FAA8F;AAC9F,MAAM,qBAAqB,GAAG,+BAA+B,CAAC;AAE9D,MAAM,UAAU,uBAAuB,CAAC,OAAe;IACrD,OAAO;QACL,EAAE,EAAE,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,uBAAuB,CAAC;QAC7C,aAAa,EAAE,WAAW,CAAC,EAAE,CAAC,IAAI,CAAC,0BAA0B,CAAC;QAC9D,IAAI,EAAE,oBAAoB;QAC1B,kFAAkF;QAClF,UAAU,EAAE,MAAM;QAClB,OAAO,EAAE,qBAAqB;QAC9B,QAAQ,EAAE,EAAE,OAAO,EAAE;KACtB,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,iBAAiB,CAAC,SAAmC,iBAAiB,EAAE;IACtF,MAAM,UAAU,GAAG,QAAQ,CAAC,EAAE,CAAC,IAAI,CAAC,uBAAuB,CAAC,CAAC;IAC7D,OAAO,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAA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,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;AAC1E,CAAC"}
@@ -0,0 +1,9 @@
1
+ import type { PluginClient } from "../plugin/types";
2
+ /**
3
+ * opencode v2 gives server plugins no SDK client. The shared v1 request pipeline only touches
4
+ * a few client calls, all best-effort: toasts, clearing the stored credential after every
5
+ * account is revoked, and session recovery (driven by v1 events, which v2 never delivers).
6
+ * This stand-in turns them into log lines so the pipeline runs unchanged under v2.
7
+ */
8
+ export declare function createV2ClientShim(): PluginClient;
9
+ //# sourceMappingURL=client-shim.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-shim.d.ts","sourceRoot":"","sources":["../../../src/opencode-v2/client-shim.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAQpD;;;;;GAKG;AACH,wBAAgB,kBAAkB,IAAI,YAAY,CAkCjD"}
@@ -0,0 +1,42 @@
1
+ import { createLogger } from "../plugin/logger";
2
+ const log = createLogger("opencode-v2");
3
+ /**
4
+ * opencode v2 gives server plugins no SDK client. The shared v1 request pipeline only touches
5
+ * a few client calls, all best-effort: toasts, clearing the stored credential after every
6
+ * account is revoked, and session recovery (driven by v1 events, which v2 never delivers).
7
+ * This stand-in turns them into log lines so the pipeline runs unchanged under v2.
8
+ */
9
+ export function createV2ClientShim() {
10
+ const unavailable = async () => {
11
+ throw new Error("Not available under opencode v2");
12
+ };
13
+ const shim = {
14
+ tui: {
15
+ showToast: async (input) => {
16
+ log.info("toast", {
17
+ title: input.body?.title,
18
+ message: input.body?.message,
19
+ variant: input.body?.variant,
20
+ });
21
+ return true;
22
+ },
23
+ },
24
+ auth: {
25
+ // v1 clears the stored credential when all accounts are revoked. Under v2 the next request
26
+ // fails with a "run opencode auth login" error instead, so there is nothing to clear here.
27
+ set: async () => {
28
+ log.debug("auth.set ignored under opencode v2");
29
+ return true;
30
+ },
31
+ },
32
+ session: {
33
+ prompt: unavailable,
34
+ abort: unavailable,
35
+ messages: unavailable,
36
+ },
37
+ };
38
+ // Only the members above are reachable from the request pipeline; the full v1 SDK client
39
+ // type cannot be satisfied without the v1 server behind it.
40
+ return shim;
41
+ }
42
+ //# sourceMappingURL=client-shim.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client-shim.js","sourceRoot":"","sources":["../../../src/opencode-v2/client-shim.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAGhD,MAAM,GAAG,GAAG,YAAY,CAAC,aAAa,CAAC,CAAC;AAMxC;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB;IAChC,MAAM,WAAW,GAAG,KAAK,IAAoB,EAAE;QAC7C,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC,CAAC;IAEF,MAAM,IAAI,GAAG;QACX,GAAG,EAAE;YACH,SAAS,EAAE,KAAK,EAAE,KAAiB,EAAE,EAAE;gBACrC,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE;oBAChB,KAAK,EAAE,KAAK,CAAC,IAAI,EAAE,KAAK;oBACxB,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO;oBAC5B,OAAO,EAAE,KAAK,CAAC,IAAI,EAAE,OAAO;iBAC7B,CAAC,CAAC;gBACH,OAAO,IAAI,CAAC;YACd,CAAC;SACF;QACD,IAAI,EAAE;YACJ,2FAA2F;YAC3F,2FAA2F;YAC3F,GAAG,EAAE,KAAK,IAAI,EAAE;gBACd,GAAG,CAAC,KAAK,CAAC,oCAAoC,CAAC,CAAC;gBAChD,OAAO,IAAI,CAAC;YACd,CAAC;SACF;QACD,OAAO,EAAE;YACP,MAAM,EAAE,WAAW;YACnB,KAAK,EAAE,WAAW;YAClB,QAAQ,EAAE,WAAW;SACtB;KACF,CAAC;IAEF,yFAAyF;IACzF,4DAA4D;IAC5D,OAAO,IAA+B,CAAC;AACzC,CAAC"}
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Best-effort copy of the sign-in link, so it can go into any browser without opencode opening
3
+ * the default one. Returns false (and the caller falls back to the printed link) over SSH or
4
+ * when no clipboard tool is available.
5
+ */
6
+ export declare function copyToClipboard(text: string, platform?: NodeJS.Platform, env?: NodeJS.ProcessEnv): Promise<boolean>;
7
+ //# sourceMappingURL=clipboard.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clipboard.d.ts","sourceRoot":"","sources":["../../../src/opencode-v2/clipboard.ts"],"names":[],"mappings":"AAyCA;;;;GAIG;AACH,wBAAsB,eAAe,CACnC,IAAI,EAAE,MAAM,EACZ,QAAQ,GAAE,MAAM,CAAC,QAA2B,EAC5C,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,OAAO,CAAC,OAAO,CAAC,CAOlB"}
@@ -0,0 +1,54 @@
1
+ import { spawn } from "node:child_process";
2
+ import { createLogger } from "../plugin/logger";
3
+ const log = createLogger("opencode-v2.clipboard");
4
+ const COPY_TIMEOUT_MS = 3_000;
5
+ function clipboardCommands(platform) {
6
+ if (platform === "win32")
7
+ return [["clip"]];
8
+ if (platform === "darwin")
9
+ return [["pbcopy"]];
10
+ return [["wl-copy"], ["xclip", "-selection", "clipboard"], ["xsel", "--clipboard", "--input"]];
11
+ }
12
+ function isRemoteSession(env) {
13
+ return Boolean(env.SSH_CONNECTION || env.SSH_CLIENT || env.SSH_TTY || env.OPENCODE_HEADLESS);
14
+ }
15
+ function runCopy(command, text) {
16
+ const [program, ...args] = command;
17
+ if (!program)
18
+ return Promise.resolve(false);
19
+ return new Promise((resolve) => {
20
+ let settled = false;
21
+ const finish = (ok) => {
22
+ if (settled)
23
+ return;
24
+ settled = true;
25
+ clearTimeout(timer);
26
+ resolve(ok);
27
+ };
28
+ const child = spawn(program, args, { stdio: ["pipe", "ignore", "ignore"], windowsHide: true });
29
+ const timer = setTimeout(() => {
30
+ child.kill();
31
+ finish(false);
32
+ }, COPY_TIMEOUT_MS);
33
+ child.on("error", () => finish(false));
34
+ child.on("close", (code) => finish(code === 0));
35
+ child.stdin.on("error", () => finish(false));
36
+ child.stdin.end(text);
37
+ });
38
+ }
39
+ /**
40
+ * Best-effort copy of the sign-in link, so it can go into any browser without opencode opening
41
+ * the default one. Returns false (and the caller falls back to the printed link) over SSH or
42
+ * when no clipboard tool is available.
43
+ */
44
+ export async function copyToClipboard(text, platform = process.platform, env = process.env) {
45
+ if (isRemoteSession(env))
46
+ return false;
47
+ for (const command of clipboardCommands(platform)) {
48
+ if (await runCopy(command, text))
49
+ return true;
50
+ }
51
+ log.debug("no clipboard tool succeeded", { platform });
52
+ return false;
53
+ }
54
+ //# sourceMappingURL=clipboard.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"clipboard.js","sourceRoot":"","sources":["../../../src/opencode-v2/clipboard.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAEhD,MAAM,GAAG,GAAG,YAAY,CAAC,uBAAuB,CAAC,CAAC;AAElD,MAAM,eAAe,GAAG,KAAK,CAAC;AAE9B,SAAS,iBAAiB,CAAC,QAAyB;IAClD,IAAI,QAAQ,KAAK,OAAO;QAAE,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;IAC5C,IAAI,QAAQ,KAAK,QAAQ;QAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IAC/C,OAAO,CAAC,CAAC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,YAAY,EAAE,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,CAAC,CAAC,CAAC;AACjG,CAAC;AAED,SAAS,eAAe,CAAC,GAAsB;IAC7C,OAAO,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,GAAG,CAAC,UAAU,IAAI,GAAG,CAAC,OAAO,IAAI,GAAG,CAAC,iBAAiB,CAAC,CAAC;AAC/F,CAAC;AAED,SAAS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AAM,CAAC,KAAK,UAAU,eAAe,CACnC,IAAY,EACZ,WAA4B,OAAO,CAAC,QAAQ,EAC5C,MAAyB,OAAO,CAAC,GAAG;IAEpC,IAAI,eAAe,CAAC,GAAG,CAAC;QAAE,OAAO,KAAK,CAAC;IACvC,KAAK,MAAM,OAAO,IAAI,iBAAiB,CAAC,QAAQ,CAAC,EAAE,CAAC;QAClD,IAAI,MAAM,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;IAChD,CAAC;IACD,GAAG,CAAC,KAAK,CAAC,6BAA6B,EAAE,EAAE,QAAQ,EAAE,CAAC,CAAC;IACvD,OAAO,KAAK,CAAC;AACf,CAAC"}
@@ -0,0 +1,5 @@
1
+ export { ANTIGRAVITY_INTEGRATION_ID, ANTIGRAVITY_METHOD_ID, ANTIGRAVITY_PASTE_METHOD_ID, ANTIGRAVITY_PROVIDER_ID, antigravityModels, antigravityProviderInfo, } from "./catalog";
2
+ export { createAntigravityV2Plugin, ANTIGRAVITY_V2_PLUGIN_ID } from "./plugin";
3
+ export { startLoopbackProxy, ProxyRequestError } from "./proxy";
4
+ export type { LoopbackProxy, ProxyHandler } from "./proxy";
5
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/opencode-v2/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,2BAA2B,EAC3B,uBAAuB,EACvB,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAChE,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { ANTIGRAVITY_INTEGRATION_ID, ANTIGRAVITY_METHOD_ID, ANTIGRAVITY_PASTE_METHOD_ID, ANTIGRAVITY_PROVIDER_ID, antigravityModels, antigravityProviderInfo, } from "./catalog";
2
+ export { createAntigravityV2Plugin, ANTIGRAVITY_V2_PLUGIN_ID } from "./plugin";
3
+ export { startLoopbackProxy, ProxyRequestError } from "./proxy";
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/opencode-v2/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,qBAAqB,EACrB,2BAA2B,EAC3B,uBAAuB,EACvB,iBAAiB,EACjB,uBAAuB,GACxB,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,yBAAyB,EAAE,wBAAwB,EAAE,MAAM,UAAU,CAAC;AAC/E,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { Plugin } from "@opencode/plugin";
2
+ export declare const ANTIGRAVITY_V2_PLUGIN_ID = "opencode-antigravity-auth";
3
+ /** Instructions for the browser flow: the local callback page finishes the sign-in. */
4
+ export declare function buildBrowserSignInInstructions(copied: boolean): string;
5
+ /** Instructions for the paste flow: no local server, the redirect URL is pasted back. */
6
+ export declare function buildPasteSignInInstructions(copied: boolean, reason?: string): string;
7
+ /** Adds Google's `login_hint`, so the sign-in page preselects that account. */
8
+ export declare function withLoginHint(url: string, loginHint: string | undefined): string;
9
+ /**
10
+ * opencode v2 entry point. It reuses the whole v1 pipeline (request rewriting, multi-account
11
+ * rotation, quota fallback, recovery of thinking blocks) and only replaces the opencode-facing
12
+ * glue that v2 changed:
13
+ *
14
+ * - sign-in: OAuth methods on the `google-antigravity` integration. The plugin never opens a
15
+ * browser; the link is copied and either the v1 callback page catches the redirect, or the
16
+ * redirect URL is pasted back;
17
+ * - models: a `google-antigravity` provider listing what Antigravity currently recommends
18
+ * (discovered after sign-in and every few hours; a built-in list until then);
19
+ * - requests: opencode's native Google client is pointed at a loopback proxy that feeds the
20
+ * v1 `fetch(url, init)` interceptor, because v2 no longer accepts a custom `fetch`.
21
+ */
22
+ export declare function createAntigravityV2Plugin(): Plugin.Plugin;
23
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/opencode-v2/plugin.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAqCnE,eAAO,MAAM,wBAAwB,8BAA8B,CAAC;AAoBpE,uFAAuF;AACvF,wBAAgB,8BAA8B,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,CAMtE;AAED,yFAAyF;AACzF,wBAAgB,4BAA4B,CAAC,MAAM,EAAE,OAAO,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAUrF;AAMD,+EAA+E;AAC/E,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAKhF;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAAC,MAAM,CA0YzD"}