@percygfx/opencode-antigravity-auth 0.0.0-stage → 2.0.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 (296) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +876 -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 +148 -0
  20. package/dist/src/constants.d.ts.map +1 -0
  21. package/dist/src/constants.js +233 -0
  22. package/dist/src/constants.js.map +1 -0
  23. package/dist/src/hooks/auto-update-checker/cache.d.ts +3 -0
  24. package/dist/src/hooks/auto-update-checker/cache.d.ts.map +1 -0
  25. package/dist/src/hooks/auto-update-checker/cache.js +71 -0
  26. package/dist/src/hooks/auto-update-checker/cache.js.map +1 -0
  27. package/dist/src/hooks/auto-update-checker/checker.d.ts +16 -0
  28. package/dist/src/hooks/auto-update-checker/checker.d.ts.map +1 -0
  29. package/dist/src/hooks/auto-update-checker/checker.js +234 -0
  30. package/dist/src/hooks/auto-update-checker/checker.js.map +1 -0
  31. package/dist/src/hooks/auto-update-checker/constants.d.ts +11 -0
  32. package/dist/src/hooks/auto-update-checker/constants.d.ts.map +1 -0
  33. package/dist/src/hooks/auto-update-checker/constants.js +26 -0
  34. package/dist/src/hooks/auto-update-checker/constants.js.map +1 -0
  35. package/dist/src/hooks/auto-update-checker/index.d.ts +34 -0
  36. package/dist/src/hooks/auto-update-checker/index.d.ts.map +1 -0
  37. package/dist/src/hooks/auto-update-checker/index.js +122 -0
  38. package/dist/src/hooks/auto-update-checker/index.js.map +1 -0
  39. package/dist/src/hooks/auto-update-checker/logging.d.ts +3 -0
  40. package/dist/src/hooks/auto-update-checker/logging.d.ts.map +1 -0
  41. package/dist/src/hooks/auto-update-checker/logging.js +9 -0
  42. package/dist/src/hooks/auto-update-checker/logging.js.map +1 -0
  43. package/dist/src/hooks/auto-update-checker/types.d.ts +25 -0
  44. package/dist/src/hooks/auto-update-checker/types.d.ts.map +1 -0
  45. package/dist/src/hooks/auto-update-checker/types.js +1 -0
  46. package/dist/src/hooks/auto-update-checker/types.js.map +1 -0
  47. package/dist/src/opencode-v2/accounts.d.ts +24 -0
  48. package/dist/src/opencode-v2/accounts.d.ts.map +1 -0
  49. package/dist/src/opencode-v2/accounts.js +109 -0
  50. package/dist/src/opencode-v2/accounts.js.map +1 -0
  51. package/dist/src/opencode-v2/catalog.d.ts +31 -0
  52. package/dist/src/opencode-v2/catalog.d.ts.map +1 -0
  53. package/dist/src/opencode-v2/catalog.js +68 -0
  54. package/dist/src/opencode-v2/catalog.js.map +1 -0
  55. package/dist/src/opencode-v2/client-shim.d.ts +9 -0
  56. package/dist/src/opencode-v2/client-shim.d.ts.map +1 -0
  57. package/dist/src/opencode-v2/client-shim.js +42 -0
  58. package/dist/src/opencode-v2/client-shim.js.map +1 -0
  59. package/dist/src/opencode-v2/clipboard.d.ts +7 -0
  60. package/dist/src/opencode-v2/clipboard.d.ts.map +1 -0
  61. package/dist/src/opencode-v2/clipboard.js +54 -0
  62. package/dist/src/opencode-v2/clipboard.js.map +1 -0
  63. package/dist/src/opencode-v2/index.d.ts +5 -0
  64. package/dist/src/opencode-v2/index.d.ts.map +1 -0
  65. package/dist/src/opencode-v2/index.js +4 -0
  66. package/dist/src/opencode-v2/index.js.map +1 -0
  67. package/dist/src/opencode-v2/plugin.d.ts +23 -0
  68. package/dist/src/opencode-v2/plugin.d.ts.map +1 -0
  69. package/dist/src/opencode-v2/plugin.js +401 -0
  70. package/dist/src/opencode-v2/plugin.js.map +1 -0
  71. package/dist/src/opencode-v2/proxy.d.ts +23 -0
  72. package/dist/src/opencode-v2/proxy.d.ts.map +1 -0
  73. package/dist/src/opencode-v2/proxy.js +148 -0
  74. package/dist/src/opencode-v2/proxy.js.map +1 -0
  75. package/dist/src/opencode-v2/quota-format.d.ts +19 -0
  76. package/dist/src/opencode-v2/quota-format.d.ts.map +1 -0
  77. package/dist/src/opencode-v2/quota-format.js +71 -0
  78. package/dist/src/opencode-v2/quota-format.js.map +1 -0
  79. package/dist/src/opencode-v2/quota.d.ts +18 -0
  80. package/dist/src/opencode-v2/quota.d.ts.map +1 -0
  81. package/dist/src/opencode-v2/quota.js +118 -0
  82. package/dist/src/opencode-v2/quota.js.map +1 -0
  83. package/dist/src/opencode-v2/sign-in-attempts.d.ts +52 -0
  84. package/dist/src/opencode-v2/sign-in-attempts.d.ts.map +1 -0
  85. package/dist/src/opencode-v2/sign-in-attempts.js +81 -0
  86. package/dist/src/opencode-v2/sign-in-attempts.js.map +1 -0
  87. package/dist/src/plugin/accounts.d.ts +179 -0
  88. package/dist/src/plugin/accounts.d.ts.map +1 -0
  89. package/dist/src/plugin/accounts.js +1004 -0
  90. package/dist/src/plugin/accounts.js.map +1 -0
  91. package/dist/src/plugin/auth.d.ts +21 -0
  92. package/dist/src/plugin/auth.d.ts.map +1 -0
  93. package/dist/src/plugin/auth.js +46 -0
  94. package/dist/src/plugin/auth.js.map +1 -0
  95. package/dist/src/plugin/cache/index.d.ts +5 -0
  96. package/dist/src/plugin/cache/index.d.ts.map +1 -0
  97. package/dist/src/plugin/cache/index.js +5 -0
  98. package/dist/src/plugin/cache/index.js.map +1 -0
  99. package/dist/src/plugin/cache/signature-cache.d.ts +111 -0
  100. package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -0
  101. package/dist/src/plugin/cache/signature-cache.js +375 -0
  102. package/dist/src/plugin/cache/signature-cache.js.map +1 -0
  103. package/dist/src/plugin/cache.d.ts +44 -0
  104. package/dist/src/plugin/cache.d.ts.map +1 -0
  105. package/dist/src/plugin/cache.js +200 -0
  106. package/dist/src/plugin/cache.js.map +1 -0
  107. package/dist/src/plugin/cli.d.ts +26 -0
  108. package/dist/src/plugin/cli.d.ts.map +1 -0
  109. package/dist/src/plugin/cli.js +119 -0
  110. package/dist/src/plugin/cli.js.map +1 -0
  111. package/dist/src/plugin/config/index.d.ts +16 -0
  112. package/dist/src/plugin/config/index.d.ts.map +1 -0
  113. package/dist/src/plugin/config/index.js +16 -0
  114. package/dist/src/plugin/config/index.js.map +1 -0
  115. package/dist/src/plugin/config/loader.d.ts +36 -0
  116. package/dist/src/plugin/config/loader.d.ts.map +1 -0
  117. package/dist/src/plugin/config/loader.js +140 -0
  118. package/dist/src/plugin/config/loader.js.map +1 -0
  119. package/dist/src/plugin/config/models.d.ts +41 -0
  120. package/dist/src/plugin/config/models.d.ts.map +1 -0
  121. package/dist/src/plugin/config/models.js +46 -0
  122. package/dist/src/plugin/config/models.js.map +1 -0
  123. package/dist/src/plugin/config/schema.d.ts +135 -0
  124. package/dist/src/plugin/config/schema.d.ts.map +1 -0
  125. package/dist/src/plugin/config/schema.js +438 -0
  126. package/dist/src/plugin/config/schema.js.map +1 -0
  127. package/dist/src/plugin/config/updater.d.ts +55 -0
  128. package/dist/src/plugin/config/updater.d.ts.map +1 -0
  129. package/dist/src/plugin/config/updater.js +125 -0
  130. package/dist/src/plugin/config/updater.js.map +1 -0
  131. package/dist/src/plugin/core/streaming/index.d.ts +3 -0
  132. package/dist/src/plugin/core/streaming/index.d.ts.map +1 -0
  133. package/dist/src/plugin/core/streaming/index.js +3 -0
  134. package/dist/src/plugin/core/streaming/index.js.map +1 -0
  135. package/dist/src/plugin/core/streaming/transformer.d.ts +10 -0
  136. package/dist/src/plugin/core/streaming/transformer.d.ts.map +1 -0
  137. package/dist/src/plugin/core/streaming/transformer.js +271 -0
  138. package/dist/src/plugin/core/streaming/transformer.js.map +1 -0
  139. package/dist/src/plugin/core/streaming/types.d.ts +27 -0
  140. package/dist/src/plugin/core/streaming/types.d.ts.map +1 -0
  141. package/dist/src/plugin/core/streaming/types.js +1 -0
  142. package/dist/src/plugin/core/streaming/types.js.map +1 -0
  143. package/dist/src/plugin/debug.d.ts +94 -0
  144. package/dist/src/plugin/debug.d.ts.map +1 -0
  145. package/dist/src/plugin/debug.js +382 -0
  146. package/dist/src/plugin/debug.js.map +1 -0
  147. package/dist/src/plugin/errors.d.ts +28 -0
  148. package/dist/src/plugin/errors.d.ts.map +1 -0
  149. package/dist/src/plugin/errors.js +42 -0
  150. package/dist/src/plugin/errors.js.map +1 -0
  151. package/dist/src/plugin/fingerprint.d.ts +70 -0
  152. package/dist/src/plugin/fingerprint.d.ts.map +1 -0
  153. package/dist/src/plugin/fingerprint.js +138 -0
  154. package/dist/src/plugin/fingerprint.js.map +1 -0
  155. package/dist/src/plugin/image-saver.d.ts +25 -0
  156. package/dist/src/plugin/image-saver.d.ts.map +1 -0
  157. package/dist/src/plugin/image-saver.js +86 -0
  158. package/dist/src/plugin/image-saver.js.map +1 -0
  159. package/dist/src/plugin/logger.d.ts +36 -0
  160. package/dist/src/plugin/logger.d.ts.map +1 -0
  161. package/dist/src/plugin/logger.js +71 -0
  162. package/dist/src/plugin/logger.js.map +1 -0
  163. package/dist/src/plugin/logging-utils.d.ts +23 -0
  164. package/dist/src/plugin/logging-utils.d.ts.map +1 -0
  165. package/dist/src/plugin/logging-utils.js +92 -0
  166. package/dist/src/plugin/logging-utils.js.map +1 -0
  167. package/dist/src/plugin/model-discovery.d.ts +16 -0
  168. package/dist/src/plugin/model-discovery.d.ts.map +1 -0
  169. package/dist/src/plugin/model-discovery.js +50 -0
  170. package/dist/src/plugin/model-discovery.js.map +1 -0
  171. package/dist/src/plugin/model-registry.d.ts +92 -0
  172. package/dist/src/plugin/model-registry.d.ts.map +1 -0
  173. package/dist/src/plugin/model-registry.js +248 -0
  174. package/dist/src/plugin/model-registry.js.map +1 -0
  175. package/dist/src/plugin/project.d.ts +33 -0
  176. package/dist/src/plugin/project.d.ts.map +1 -0
  177. package/dist/src/plugin/project.js +234 -0
  178. package/dist/src/plugin/project.js.map +1 -0
  179. package/dist/src/plugin/quota.d.ts +58 -0
  180. package/dist/src/plugin/quota.d.ts.map +1 -0
  181. package/dist/src/plugin/quota.js +296 -0
  182. package/dist/src/plugin/quota.js.map +1 -0
  183. package/dist/src/plugin/recovery/constants.d.ts +22 -0
  184. package/dist/src/plugin/recovery/constants.d.ts.map +1 -0
  185. package/dist/src/plugin/recovery/constants.js +43 -0
  186. package/dist/src/plugin/recovery/constants.js.map +1 -0
  187. package/dist/src/plugin/recovery/index.d.ts +12 -0
  188. package/dist/src/plugin/recovery/index.d.ts.map +1 -0
  189. package/dist/src/plugin/recovery/index.js +12 -0
  190. package/dist/src/plugin/recovery/index.js.map +1 -0
  191. package/dist/src/plugin/recovery/storage.d.ts +24 -0
  192. package/dist/src/plugin/recovery/storage.d.ts.map +1 -0
  193. package/dist/src/plugin/recovery/storage.js +354 -0
  194. package/dist/src/plugin/recovery/storage.js.map +1 -0
  195. package/dist/src/plugin/recovery/types.d.ts +116 -0
  196. package/dist/src/plugin/recovery/types.d.ts.map +1 -0
  197. package/dist/src/plugin/recovery/types.js +6 -0
  198. package/dist/src/plugin/recovery/types.js.map +1 -0
  199. package/dist/src/plugin/recovery.d.ts +61 -0
  200. package/dist/src/plugin/recovery.d.ts.map +1 -0
  201. package/dist/src/plugin/recovery.js +381 -0
  202. package/dist/src/plugin/recovery.js.map +1 -0
  203. package/dist/src/plugin/refresh-queue.d.ts +100 -0
  204. package/dist/src/plugin/refresh-queue.d.ts.map +1 -0
  205. package/dist/src/plugin/refresh-queue.js +247 -0
  206. package/dist/src/plugin/refresh-queue.js.map +1 -0
  207. package/dist/src/plugin/request-helpers.d.ts +282 -0
  208. package/dist/src/plugin/request-helpers.d.ts.map +1 -0
  209. package/dist/src/plugin/request-helpers.js +2343 -0
  210. package/dist/src/plugin/request-helpers.js.map +1 -0
  211. package/dist/src/plugin/request.d.ts +95 -0
  212. package/dist/src/plugin/request.d.ts.map +1 -0
  213. package/dist/src/plugin/request.js +1500 -0
  214. package/dist/src/plugin/request.js.map +1 -0
  215. package/dist/src/plugin/rotation.d.ts +169 -0
  216. package/dist/src/plugin/rotation.d.ts.map +1 -0
  217. package/dist/src/plugin/rotation.js +328 -0
  218. package/dist/src/plugin/rotation.js.map +1 -0
  219. package/dist/src/plugin/search.d.ts +32 -0
  220. package/dist/src/plugin/search.d.ts.map +1 -0
  221. package/dist/src/plugin/search.js +195 -0
  222. package/dist/src/plugin/search.js.map +1 -0
  223. package/dist/src/plugin/server.d.ts +23 -0
  224. package/dist/src/plugin/server.d.ts.map +1 -0
  225. package/dist/src/plugin/server.js +324 -0
  226. package/dist/src/plugin/server.js.map +1 -0
  227. package/dist/src/plugin/storage.d.ts +155 -0
  228. package/dist/src/plugin/storage.d.ts.map +1 -0
  229. package/dist/src/plugin/storage.js +650 -0
  230. package/dist/src/plugin/storage.js.map +1 -0
  231. package/dist/src/plugin/stores/signature-store.d.ts +5 -0
  232. package/dist/src/plugin/stores/signature-store.d.ts.map +1 -0
  233. package/dist/src/plugin/stores/signature-store.js +25 -0
  234. package/dist/src/plugin/stores/signature-store.js.map +1 -0
  235. package/dist/src/plugin/thinking-recovery.d.ts +90 -0
  236. package/dist/src/plugin/thinking-recovery.d.ts.map +1 -0
  237. package/dist/src/plugin/thinking-recovery.js +316 -0
  238. package/dist/src/plugin/thinking-recovery.js.map +1 -0
  239. package/dist/src/plugin/token.d.ts +19 -0
  240. package/dist/src/plugin/token.d.ts.map +1 -0
  241. package/dist/src/plugin/token.js +128 -0
  242. package/dist/src/plugin/token.js.map +1 -0
  243. package/dist/src/plugin/transform/claude.d.ts +80 -0
  244. package/dist/src/plugin/transform/claude.d.ts.map +1 -0
  245. package/dist/src/plugin/transform/claude.js +265 -0
  246. package/dist/src/plugin/transform/claude.js.map +1 -0
  247. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +35 -0
  248. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts.map +1 -0
  249. package/dist/src/plugin/transform/cross-model-sanitizer.js +225 -0
  250. package/dist/src/plugin/transform/cross-model-sanitizer.js.map +1 -0
  251. package/dist/src/plugin/transform/gemini.d.ts +100 -0
  252. package/dist/src/plugin/transform/gemini.d.ts.map +1 -0
  253. package/dist/src/plugin/transform/gemini.js +446 -0
  254. package/dist/src/plugin/transform/gemini.js.map +1 -0
  255. package/dist/src/plugin/transform/index.d.ts +15 -0
  256. package/dist/src/plugin/transform/index.d.ts.map +1 -0
  257. package/dist/src/plugin/transform/index.js +14 -0
  258. package/dist/src/plugin/transform/index.js.map +1 -0
  259. package/dist/src/plugin/transform/model-resolver.d.ts +99 -0
  260. package/dist/src/plugin/transform/model-resolver.d.ts.map +1 -0
  261. package/dist/src/plugin/transform/model-resolver.js +340 -0
  262. package/dist/src/plugin/transform/model-resolver.js.map +1 -0
  263. package/dist/src/plugin/transform/types.d.ts +111 -0
  264. package/dist/src/plugin/transform/types.d.ts.map +1 -0
  265. package/dist/src/plugin/transform/types.js +1 -0
  266. package/dist/src/plugin/transform/types.js.map +1 -0
  267. package/dist/src/plugin/types.d.ts +97 -0
  268. package/dist/src/plugin/types.d.ts.map +1 -0
  269. package/dist/src/plugin/types.js +1 -0
  270. package/dist/src/plugin/types.js.map +1 -0
  271. package/dist/src/plugin/ui/ansi.d.ts +32 -0
  272. package/dist/src/plugin/ui/ansi.d.ts.map +1 -0
  273. package/dist/src/plugin/ui/ansi.js +52 -0
  274. package/dist/src/plugin/ui/ansi.js.map +1 -0
  275. package/dist/src/plugin/ui/auth-menu.d.ts +33 -0
  276. package/dist/src/plugin/ui/auth-menu.d.ts.map +1 -0
  277. package/dist/src/plugin/ui/auth-menu.js +110 -0
  278. package/dist/src/plugin/ui/auth-menu.js.map +1 -0
  279. package/dist/src/plugin/ui/confirm.d.ts +2 -0
  280. package/dist/src/plugin/ui/confirm.d.ts.map +1 -0
  281. package/dist/src/plugin/ui/confirm.js +15 -0
  282. package/dist/src/plugin/ui/confirm.js.map +1 -0
  283. package/dist/src/plugin/ui/select.d.ts +23 -0
  284. package/dist/src/plugin/ui/select.d.ts.map +1 -0
  285. package/dist/src/plugin/ui/select.js +254 -0
  286. package/dist/src/plugin/ui/select.js.map +1 -0
  287. package/dist/src/plugin/version.d.ts +19 -0
  288. package/dist/src/plugin/version.d.ts.map +1 -0
  289. package/dist/src/plugin/version.js +80 -0
  290. package/dist/src/plugin/version.js.map +1 -0
  291. package/dist/src/plugin.d.ts +45 -0
  292. package/dist/src/plugin.d.ts.map +1 -0
  293. package/dist/src/plugin.js +2817 -0
  294. package/dist/src/plugin.js.map +1 -0
  295. package/dist/tui.js +420 -0
  296. package/package.json +98 -5
@@ -0,0 +1,4 @@
1
+ export { AntigravityCLIOAuthPlugin, GoogleOAuthPlugin, } from "./src/plugin";
2
+ export { authorizeAntigravity, exchangeAntigravity, } from "./src/antigravity/oauth";
3
+ export type { AntigravityAuthorization, AntigravityTokenExchangeResult, } from "./src/antigravity/oauth";
4
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC;AAEjC,YAAY,EACV,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,yBAAyB,CAAC"}
package/dist/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export { AntigravityCLIOAuthPlugin, GoogleOAuthPlugin, } from "./src/plugin";
2
+ export { authorizeAntigravity, exchangeAntigravity, } from "./src/antigravity/oauth";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,yBAAyB,CAAC"}
package/dist/rpc.d.ts ADDED
@@ -0,0 +1,176 @@
1
+ import { z } from "zod";
2
+ /** One quota window (5-hour or weekly) of a model group. */
3
+ export declare const QuotaWindowSchema: z.ZodObject<{
4
+ remainingPercent: z.ZodNullable<z.ZodNumber>;
5
+ resetAt: z.ZodNullable<z.ZodNumber>;
6
+ }, z.core.$strip>;
7
+ /** A group of models sharing limits, e.g. "Gemini" or "Claude & GPT". */
8
+ export declare const QuotaLimitSchema: z.ZodObject<{
9
+ name: z.ZodString;
10
+ fiveHour: z.ZodNullable<z.ZodObject<{
11
+ remainingPercent: z.ZodNullable<z.ZodNumber>;
12
+ resetAt: z.ZodNullable<z.ZodNumber>;
13
+ }, z.core.$strip>>;
14
+ weekly: z.ZodNullable<z.ZodObject<{
15
+ remainingPercent: z.ZodNullable<z.ZodNumber>;
16
+ resetAt: z.ZodNullable<z.ZodNumber>;
17
+ }, z.core.$strip>>;
18
+ }, z.core.$strip>;
19
+ export declare const QuotaAccountSchema: z.ZodObject<{
20
+ index: z.ZodNumber;
21
+ email: z.ZodString;
22
+ enabled: z.ZodBoolean;
23
+ inUse: z.ZodArray<z.ZodString>;
24
+ limits: z.ZodArray<z.ZodObject<{
25
+ name: z.ZodString;
26
+ fiveHour: z.ZodNullable<z.ZodObject<{
27
+ remainingPercent: z.ZodNullable<z.ZodNumber>;
28
+ resetAt: z.ZodNullable<z.ZodNumber>;
29
+ }, z.core.$strip>>;
30
+ weekly: z.ZodNullable<z.ZodObject<{
31
+ remainingPercent: z.ZodNullable<z.ZodNumber>;
32
+ resetAt: z.ZodNullable<z.ZodNumber>;
33
+ }, z.core.$strip>>;
34
+ }, z.core.$strip>>;
35
+ error: z.ZodOptional<z.ZodString>;
36
+ }, z.core.$strip>;
37
+ export declare const QuotaSnapshotSchema: z.ZodObject<{
38
+ fetchedAt: z.ZodNumber;
39
+ accounts: z.ZodArray<z.ZodObject<{
40
+ index: z.ZodNumber;
41
+ email: z.ZodString;
42
+ enabled: z.ZodBoolean;
43
+ inUse: z.ZodArray<z.ZodString>;
44
+ limits: z.ZodArray<z.ZodObject<{
45
+ name: z.ZodString;
46
+ fiveHour: z.ZodNullable<z.ZodObject<{
47
+ remainingPercent: z.ZodNullable<z.ZodNumber>;
48
+ resetAt: z.ZodNullable<z.ZodNumber>;
49
+ }, z.core.$strip>>;
50
+ weekly: z.ZodNullable<z.ZodObject<{
51
+ remainingPercent: z.ZodNullable<z.ZodNumber>;
52
+ resetAt: z.ZodNullable<z.ZodNumber>;
53
+ }, z.core.$strip>>;
54
+ }, z.core.$strip>>;
55
+ error: z.ZodOptional<z.ZodString>;
56
+ }, z.core.$strip>>;
57
+ }, z.core.$strip>;
58
+ export type QuotaWindow = z.infer<typeof QuotaWindowSchema>;
59
+ export type QuotaLimit = z.infer<typeof QuotaLimitSchema>;
60
+ export type QuotaAccount = z.infer<typeof QuotaAccountSchema>;
61
+ export type QuotaSnapshot = z.infer<typeof QuotaSnapshotSchema>;
62
+ export declare const AntigravityRpc: {
63
+ readonly id: "antigravity";
64
+ readonly methods: {
65
+ /** Per-account quota for the signed-in Antigravity accounts. */
66
+ readonly quota: {
67
+ readonly input: z.ZodObject<{
68
+ refresh: z.ZodOptional<z.ZodBoolean>;
69
+ }, z.core.$strip>;
70
+ readonly output: z.ZodObject<{
71
+ fetchedAt: z.ZodNumber;
72
+ accounts: z.ZodArray<z.ZodObject<{
73
+ index: z.ZodNumber;
74
+ email: z.ZodString;
75
+ enabled: z.ZodBoolean;
76
+ inUse: z.ZodArray<z.ZodString>;
77
+ limits: z.ZodArray<z.ZodObject<{
78
+ name: z.ZodString;
79
+ fiveHour: z.ZodNullable<z.ZodObject<{
80
+ remainingPercent: z.ZodNullable<z.ZodNumber>;
81
+ resetAt: z.ZodNullable<z.ZodNumber>;
82
+ }, z.core.$strip>>;
83
+ weekly: z.ZodNullable<z.ZodObject<{
84
+ remainingPercent: z.ZodNullable<z.ZodNumber>;
85
+ resetAt: z.ZodNullable<z.ZodNumber>;
86
+ }, z.core.$strip>>;
87
+ }, z.core.$strip>>;
88
+ error: z.ZodOptional<z.ZodString>;
89
+ }, z.core.$strip>>;
90
+ }, z.core.$strip>;
91
+ };
92
+ /** Takes an account out of rotation, or puts it back. */
93
+ readonly setAccountEnabled: {
94
+ readonly input: z.ZodObject<{
95
+ index: z.ZodNumber;
96
+ email: z.ZodString;
97
+ enabled: z.ZodBoolean;
98
+ }, z.core.$strip>;
99
+ readonly output: z.ZodObject<{}, z.core.$strip>;
100
+ readonly errors: {
101
+ failed: z.ZodObject<{}, z.core.$strip>;
102
+ };
103
+ };
104
+ /** Removes an account from the pool; reports how many remain. */
105
+ readonly removeAccount: {
106
+ readonly input: z.ZodObject<{
107
+ index: z.ZodNumber;
108
+ email: z.ZodString;
109
+ }, z.core.$strip>;
110
+ readonly output: z.ZodObject<{
111
+ remaining: z.ZodNumber;
112
+ }, z.core.$strip>;
113
+ readonly errors: {
114
+ failed: z.ZodObject<{}, z.core.$strip>;
115
+ };
116
+ };
117
+ /**
118
+ * Starts a sign-in the plugin runs itself (re-authenticate / add account): it updates the
119
+ * account pool without adding another opencode login. `email` preselects that account.
120
+ */
121
+ readonly signInStart: {
122
+ readonly input: z.ZodObject<{
123
+ email: z.ZodOptional<z.ZodString>;
124
+ }, z.core.$strip>;
125
+ readonly output: z.ZodObject<{
126
+ attemptID: z.ZodString;
127
+ mode: z.ZodEnum<{
128
+ auto: "auto";
129
+ code: "code";
130
+ }>;
131
+ url: z.ZodString;
132
+ instructions: z.ZodString;
133
+ }, z.core.$strip>;
134
+ readonly errors: {
135
+ failed: z.ZodObject<{}, z.core.$strip>;
136
+ };
137
+ };
138
+ /** Progress of a browser sign-in ("auto" mode). */
139
+ readonly signInStatus: {
140
+ readonly input: z.ZodObject<{
141
+ attemptID: z.ZodString;
142
+ }, z.core.$strip>;
143
+ readonly output: z.ZodObject<{
144
+ status: z.ZodEnum<{
145
+ complete: "complete";
146
+ failed: "failed";
147
+ expired: "expired";
148
+ pending: "pending";
149
+ }>;
150
+ message: z.ZodOptional<z.ZodString>;
151
+ email: z.ZodOptional<z.ZodString>;
152
+ }, z.core.$strip>;
153
+ };
154
+ /** Finishes a paste sign-in ("code" mode) with the redirect URL or code. */
155
+ readonly signInComplete: {
156
+ readonly input: z.ZodObject<{
157
+ attemptID: z.ZodString;
158
+ code: z.ZodString;
159
+ }, z.core.$strip>;
160
+ readonly output: z.ZodObject<{
161
+ email: z.ZodOptional<z.ZodString>;
162
+ }, z.core.$strip>;
163
+ readonly errors: {
164
+ failed: z.ZodObject<{}, z.core.$strip>;
165
+ };
166
+ };
167
+ readonly signInCancel: {
168
+ readonly input: z.ZodObject<{
169
+ attemptID: z.ZodString;
170
+ }, z.core.$strip>;
171
+ readonly output: z.ZodObject<{}, z.core.$strip>;
172
+ };
173
+ };
174
+ readonly events: {};
175
+ };
176
+ //# sourceMappingURL=rpc.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../rpc.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAKxB,4DAA4D;AAC5D,eAAO,MAAM,iBAAiB;;;iBAK5B,CAAC;AAEH,yEAAyE;AACzE,eAAO,MAAM,gBAAgB;;;;;;;;;;iBAM3B,CAAC;AAEH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;iBAS7B,CAAC;AAEH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;iBAG9B,CAAC;AAEH,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAC;AAC5D,MAAM,MAAM,UAAU,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC;AAC1D,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAC9D,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAC;AAEhE,eAAO,MAAM,cAAc;;;QAGvB,gEAAgE;;;;;;;;;;;;;;;;;;;;;;;;;;;QAKhE,yDAAyD;;;;;;;;;;;;QAMzD,iEAAiE;;;;;;;;;;;;;QAMjE;;;WAGG;;;;;;;;;;;;;;;;;;QAWH,mDAAmD;;;;;;;;;;;;;;;;QASnD,4EAA4E;;;;;;;;;;;;;;;;;;;;;CAY9E,CAAC"}
package/dist/rpc.js ADDED
@@ -0,0 +1,91 @@
1
+ // RPC shared by the OpenCode 2 server plugin (server.ts) and the TUI plugin (tui.tsx).
2
+ import { Rpc } from "@opencode/plugin/rpc";
3
+ import { z } from "zod";
4
+ /** Declared so the user sees why an account action failed (undeclared errors are masked). */
5
+ const ActionErrors = { failed: z.object({}) };
6
+ /** One quota window (5-hour or weekly) of a model group. */
7
+ export const QuotaWindowSchema = z.object({
8
+ /** 0–100, or null when Antigravity did not report it. */
9
+ remainingPercent: z.number().nullable(),
10
+ /** When the window fully refreshes (epoch ms), or null when unknown. */
11
+ resetAt: z.number().nullable(),
12
+ });
13
+ /** A group of models sharing limits, e.g. "Gemini" or "Claude & GPT". */
14
+ export const QuotaLimitSchema = z.object({
15
+ name: z.string(),
16
+ /** The 5-hour limit, which smooths demand across all users. */
17
+ fiveHour: QuotaWindowSchema.nullable(),
18
+ /** The weekly limit, tied to the account's plan; null when Antigravity did not report it. */
19
+ weekly: QuotaWindowSchema.nullable(),
20
+ });
21
+ export const QuotaAccountSchema = z.object({
22
+ /** Position in the account pool; account actions pass it back with the email. */
23
+ index: z.number(),
24
+ email: z.string(),
25
+ enabled: z.boolean(),
26
+ /** Model groups this account is currently serving, e.g. ["Gemini"]. */
27
+ inUse: z.array(z.string()),
28
+ limits: z.array(QuotaLimitSchema),
29
+ error: z.string().optional(),
30
+ });
31
+ export const QuotaSnapshotSchema = z.object({
32
+ fetchedAt: z.number(),
33
+ accounts: z.array(QuotaAccountSchema),
34
+ });
35
+ export const AntigravityRpc = Rpc.define({
36
+ id: "antigravity",
37
+ methods: {
38
+ /** Per-account quota for the signed-in Antigravity accounts. */
39
+ quota: {
40
+ input: z.object({ refresh: z.boolean().optional() }),
41
+ output: QuotaSnapshotSchema,
42
+ },
43
+ /** Takes an account out of rotation, or puts it back. */
44
+ setAccountEnabled: {
45
+ input: z.object({ index: z.number(), email: z.string(), enabled: z.boolean() }),
46
+ output: z.object({}),
47
+ errors: ActionErrors,
48
+ },
49
+ /** Removes an account from the pool; reports how many remain. */
50
+ removeAccount: {
51
+ input: z.object({ index: z.number(), email: z.string() }),
52
+ output: z.object({ remaining: z.number() }),
53
+ errors: ActionErrors,
54
+ },
55
+ /**
56
+ * Starts a sign-in the plugin runs itself (re-authenticate / add account): it updates the
57
+ * account pool without adding another opencode login. `email` preselects that account.
58
+ */
59
+ signInStart: {
60
+ input: z.object({ email: z.string().optional() }),
61
+ output: z.object({
62
+ attemptID: z.string(),
63
+ mode: z.enum(["auto", "code"]),
64
+ url: z.string(),
65
+ instructions: z.string(),
66
+ }),
67
+ errors: ActionErrors,
68
+ },
69
+ /** Progress of a browser sign-in ("auto" mode). */
70
+ signInStatus: {
71
+ input: z.object({ attemptID: z.string() }),
72
+ output: z.object({
73
+ status: z.enum(["pending", "complete", "failed", "expired"]),
74
+ message: z.string().optional(),
75
+ email: z.string().optional(),
76
+ }),
77
+ },
78
+ /** Finishes a paste sign-in ("code" mode) with the redirect URL or code. */
79
+ signInComplete: {
80
+ input: z.object({ attemptID: z.string(), code: z.string() }),
81
+ output: z.object({ email: z.string().optional() }),
82
+ errors: ActionErrors,
83
+ },
84
+ signInCancel: {
85
+ input: z.object({ attemptID: z.string() }),
86
+ output: z.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EAAE,CAAC;SACrB;KACF;IACD,MAAM,EAAE,EAAE;CACX,CAAC,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("@opencode/plugin/promise/plugin").Plugin;
2
+ export default _default;
3
+ //# sourceMappingURL=server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../server.ts"],"names":[],"mappings":";AAIA,wBAA2C"}
package/dist/server.js ADDED
@@ -0,0 +1,5 @@
1
+ // opencode v2 entry point. v2 loads a plugin package's `server` export (or a plugin directory's
2
+ // `server.*` file) and accepts only a default export; v1 keeps loading `index.ts` as before.
3
+ import { createAntigravityV2Plugin } from "./src/opencode-v2";
4
+ export default createAntigravityV2Plugin();
5
+ //# sourceMappingURL=server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"server.js","sourceRoot":"","sources":["../server.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,6FAA6F;AAC7F,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAE9D,eAAe,yBAAyB,EAAE,CAAC"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Result returned to the caller after constructing an OAuth authorization URL.
3
+ */
4
+ export interface AntigravityAuthorization {
5
+ url: string;
6
+ verifier: string;
7
+ projectId: string;
8
+ }
9
+ interface AntigravityTokenExchangeSuccess {
10
+ type: "success";
11
+ refresh: string;
12
+ access: string;
13
+ expires: number;
14
+ email?: string;
15
+ projectId: string;
16
+ }
17
+ interface AntigravityTokenExchangeFailure {
18
+ type: "failed";
19
+ error: string;
20
+ }
21
+ export type AntigravityTokenExchangeResult = AntigravityTokenExchangeSuccess | AntigravityTokenExchangeFailure;
22
+ /**
23
+ * Build the Antigravity OAuth authorization URL including PKCE and optional project metadata.
24
+ */
25
+ export declare function authorizeAntigravity(projectId?: string): Promise<AntigravityAuthorization>;
26
+ /**
27
+ * Exchange an authorization code for Antigravity CLI access and refresh tokens.
28
+ */
29
+ export declare function exchangeAntigravity(code: string, state: string): Promise<AntigravityTokenExchangeResult>;
30
+ export {};
31
+ //# sourceMappingURL=oauth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../src/antigravity/oauth.ts"],"names":[],"mappings":"AA2BA;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,+BAA+B;IACvC,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,UAAU,+BAA+B;IACvC,IAAI,EAAE,QAAQ,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,8BAA8B,GACtC,+BAA+B,GAC/B,+BAA+B,CAAC;AAoCpC;;GAEG;AACH,wBAAsB,oBAAoB,CAAC,SAAS,SAAK,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAsB5F;AAoFD;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,8BAA8B,CAAC,CAsEzC"}
@@ -0,0 +1,171 @@
1
+ import { generatePKCE } from "@openauthjs/openauth/pkce";
2
+ import { ANTIGRAVITY_CLIENT_ID, ANTIGRAVITY_CLIENT_SECRET, ANTIGRAVITY_REDIRECT_URI, ANTIGRAVITY_SCOPES, ANTIGRAVITY_ENDPOINT_FALLBACKS, ANTIGRAVITY_LOAD_ENDPOINTS, getAntigravityHeaders, GEMINI_CLI_HEADERS, } from "../constants";
3
+ import { createLogger } from "../plugin/logger";
4
+ import { calculateTokenExpiry } from "../plugin/auth";
5
+ const log = createLogger("oauth");
6
+ /**
7
+ * Encode an object into a URL-safe base64 string.
8
+ */
9
+ function encodeState(payload) {
10
+ return Buffer.from(JSON.stringify(payload), "utf8").toString("base64url");
11
+ }
12
+ /**
13
+ * Decode an OAuth state parameter back into its structured representation.
14
+ */
15
+ function decodeState(state) {
16
+ const normalized = state.replace(/-/g, "+").replace(/_/g, "/");
17
+ const padded = normalized.padEnd(normalized.length + ((4 - normalized.length % 4) % 4), "=");
18
+ const json = Buffer.from(padded, "base64").toString("utf8");
19
+ const parsed = JSON.parse(json);
20
+ if (typeof parsed.verifier !== "string") {
21
+ throw new Error("Missing PKCE verifier in state");
22
+ }
23
+ return {
24
+ verifier: parsed.verifier,
25
+ projectId: typeof parsed.projectId === "string" ? parsed.projectId : "",
26
+ };
27
+ }
28
+ /**
29
+ * Build the Antigravity OAuth authorization URL including PKCE and optional project metadata.
30
+ */
31
+ export async function authorizeAntigravity(projectId = "") {
32
+ const pkce = (await generatePKCE());
33
+ const url = new URL("https://accounts.google.com/o/oauth2/v2/auth");
34
+ url.searchParams.set("client_id", ANTIGRAVITY_CLIENT_ID);
35
+ url.searchParams.set("response_type", "code");
36
+ url.searchParams.set("redirect_uri", ANTIGRAVITY_REDIRECT_URI);
37
+ url.searchParams.set("scope", ANTIGRAVITY_SCOPES.join(" "));
38
+ url.searchParams.set("code_challenge", pkce.challenge);
39
+ url.searchParams.set("code_challenge_method", "S256");
40
+ url.searchParams.set("state", encodeState({ verifier: pkce.verifier, projectId: projectId || "" }));
41
+ url.searchParams.set("access_type", "offline");
42
+ url.searchParams.set("prompt", "consent");
43
+ return {
44
+ url: url.toString(),
45
+ verifier: pkce.verifier,
46
+ projectId: projectId || "",
47
+ };
48
+ }
49
+ const FETCH_TIMEOUT_MS = 10000;
50
+ async function fetchWithTimeout(url, options, timeoutMs = FETCH_TIMEOUT_MS) {
51
+ const controller = new AbortController();
52
+ const timeout = setTimeout(() => controller.abort(), timeoutMs);
53
+ try {
54
+ return await fetch(url, { ...options, signal: controller.signal });
55
+ }
56
+ finally {
57
+ clearTimeout(timeout);
58
+ }
59
+ }
60
+ async function fetchProjectID(accessToken) {
61
+ const errors = [];
62
+ const loadHeaders = {
63
+ Authorization: `Bearer ${accessToken}`,
64
+ "Content-Type": "application/json",
65
+ "User-Agent": GEMINI_CLI_HEADERS["User-Agent"],
66
+ "Client-Metadata": getAntigravityHeaders()["Client-Metadata"],
67
+ };
68
+ const loadEndpoints = Array.from(new Set([...ANTIGRAVITY_LOAD_ENDPOINTS, ...ANTIGRAVITY_ENDPOINT_FALLBACKS]));
69
+ for (const baseEndpoint of loadEndpoints) {
70
+ try {
71
+ const url = `${baseEndpoint}/v1internal:loadCodeAssist`;
72
+ const response = await fetchWithTimeout(url, {
73
+ method: "POST",
74
+ headers: loadHeaders,
75
+ body: JSON.stringify({
76
+ metadata: {
77
+ ideType: "ANTIGRAVITY",
78
+ platform: process.platform === "win32" ? "WINDOWS" : "MACOS",
79
+ pluginType: "GEMINI",
80
+ },
81
+ }),
82
+ });
83
+ if (!response.ok) {
84
+ const message = await response.text().catch(() => "");
85
+ errors.push(`loadCodeAssist ${response.status} at ${baseEndpoint}${message ? `: ${message}` : ""}`);
86
+ continue;
87
+ }
88
+ const data = await response.json();
89
+ if (typeof data.cloudaicompanionProject === "string" && data.cloudaicompanionProject) {
90
+ return data.cloudaicompanionProject;
91
+ }
92
+ if (data.cloudaicompanionProject &&
93
+ typeof data.cloudaicompanionProject.id === "string" &&
94
+ data.cloudaicompanionProject.id) {
95
+ return data.cloudaicompanionProject.id;
96
+ }
97
+ errors.push(`loadCodeAssist missing project id at ${baseEndpoint}`);
98
+ }
99
+ catch (e) {
100
+ errors.push(`loadCodeAssist error at ${baseEndpoint}: ${e instanceof Error ? e.message : String(e)}`);
101
+ }
102
+ }
103
+ if (errors.length) {
104
+ log.warn("Failed to resolve Antigravity project via loadCodeAssist", { errors: errors.join("; ") });
105
+ }
106
+ return "";
107
+ }
108
+ /**
109
+ * Exchange an authorization code for Antigravity CLI access and refresh tokens.
110
+ */
111
+ export async function exchangeAntigravity(code, state) {
112
+ try {
113
+ const { verifier, projectId } = decodeState(state);
114
+ const startTime = Date.now();
115
+ const tokenResponse = await fetch("https://oauth2.googleapis.com/token", {
116
+ method: "POST",
117
+ headers: {
118
+ "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
119
+ "Accept": "*/*",
120
+ "Accept-Encoding": "gzip, deflate, br",
121
+ "User-Agent": GEMINI_CLI_HEADERS["User-Agent"],
122
+ },
123
+ body: new URLSearchParams({
124
+ client_id: ANTIGRAVITY_CLIENT_ID,
125
+ client_secret: ANTIGRAVITY_CLIENT_SECRET,
126
+ code,
127
+ grant_type: "authorization_code",
128
+ redirect_uri: ANTIGRAVITY_REDIRECT_URI,
129
+ code_verifier: verifier,
130
+ }),
131
+ });
132
+ if (!tokenResponse.ok) {
133
+ const errorText = await tokenResponse.text();
134
+ return { type: "failed", error: errorText };
135
+ }
136
+ const tokenPayload = (await tokenResponse.json());
137
+ const userInfoResponse = await fetch("https://www.googleapis.com/oauth2/v1/userinfo?alt=json", {
138
+ headers: {
139
+ Authorization: `Bearer ${tokenPayload.access_token}`,
140
+ "User-Agent": GEMINI_CLI_HEADERS["User-Agent"],
141
+ },
142
+ });
143
+ const userInfo = userInfoResponse.ok
144
+ ? (await userInfoResponse.json())
145
+ : {};
146
+ const refreshToken = tokenPayload.refresh_token;
147
+ if (!refreshToken) {
148
+ return { type: "failed", error: "Missing refresh token in response" };
149
+ }
150
+ let effectiveProjectId = projectId;
151
+ if (!effectiveProjectId) {
152
+ effectiveProjectId = await fetchProjectID(tokenPayload.access_token);
153
+ }
154
+ const storedRefresh = `${refreshToken}|${effectiveProjectId || ""}`;
155
+ return {
156
+ type: "success",
157
+ refresh: storedRefresh,
158
+ access: tokenPayload.access_token,
159
+ expires: calculateTokenExpiry(startTime, tokenPayload.expires_in),
160
+ email: userInfo.email,
161
+ projectId: effectiveProjectId || "",
162
+ };
163
+ }
164
+ catch (error) {
165
+ return {
166
+ type: "failed",
167
+ error: error instanceof Error ? error.message : "Unknown error",
168
+ };
169
+ }
170
+ }
171
+ //# sourceMappingURL=oauth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth.js","sourceRoot":"","sources":["../../../src/antigravity/oauth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AAEzD,OAAO,EACL,qBAAqB,EACrB,yBAAyB,EACzB,wBAAwB,EACxB,kBAAkB,EAClB,8BAA8B,EAC9B,0BAA0B,EAC1B,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AAEtD,MAAM,GAAG,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;AAiDlC;;GAEG;AACH,SAAS,WAAW,CAAC,OAA6B;IAChD,OAAO,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AAC5E,CAAC;AAED;;GAEG;AACH,SAAS,WAAW,CAAC,KAAa;IAChC,MAAM,UAAU,GAAG,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAC;IAC/D,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;IAC7F,MAAM,IAAI,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC5D,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAA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