@cortexkit/opencode-antigravity-auth 1.1.0 → 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 (371) hide show
  1. package/README.md +225 -569
  2. package/dist/cli.js +3790 -0
  3. package/dist/cli.js.map +7 -0
  4. package/dist/index.d.ts +1 -3
  5. package/dist/index.d.ts.map +1 -1
  6. package/dist/index.js +18767 -13829
  7. package/dist/index.js.map +4 -4
  8. package/dist/src/antigravity/oauth.d.ts +1 -1
  9. package/dist/src/antigravity/oauth.js +1 -1
  10. package/dist/src/cli.d.ts +21 -0
  11. package/dist/src/cli.d.ts.map +1 -0
  12. package/dist/src/cli.js +237 -0
  13. package/dist/src/cli.js.map +1 -0
  14. package/dist/src/constants.d.ts +1 -1
  15. package/dist/src/constants.js +1 -1
  16. package/dist/src/hooks/auto-update-checker/cache.d.ts.map +1 -1
  17. package/dist/src/hooks/auto-update-checker/cache.js +13 -13
  18. package/dist/src/hooks/auto-update-checker/cache.js.map +1 -1
  19. package/dist/src/hooks/auto-update-checker/checker.d.ts +1 -1
  20. package/dist/src/hooks/auto-update-checker/checker.d.ts.map +1 -1
  21. package/dist/src/hooks/auto-update-checker/checker.js +75 -51
  22. package/dist/src/hooks/auto-update-checker/checker.js.map +1 -1
  23. package/dist/src/hooks/auto-update-checker/constants.d.ts.map +1 -1
  24. package/dist/src/hooks/auto-update-checker/constants.js +12 -12
  25. package/dist/src/hooks/auto-update-checker/constants.js.map +1 -1
  26. package/dist/src/hooks/auto-update-checker/index.d.ts +6 -6
  27. package/dist/src/hooks/auto-update-checker/index.d.ts.map +1 -1
  28. package/dist/src/hooks/auto-update-checker/index.js +17 -17
  29. package/dist/src/hooks/auto-update-checker/index.js.map +1 -1
  30. package/dist/src/hooks/auto-update-checker/logging.js +2 -2
  31. package/dist/src/hooks/auto-update-checker/logging.js.map +1 -1
  32. package/dist/src/hooks/auto-update-checker/types.d.ts.map +1 -1
  33. package/dist/src/plugin/account-access.d.ts +99 -0
  34. package/dist/src/plugin/account-access.d.ts.map +1 -0
  35. package/dist/src/plugin/account-access.js +480 -0
  36. package/dist/src/plugin/account-access.js.map +1 -0
  37. package/dist/src/plugin/accounts.d.ts +7 -256
  38. package/dist/src/plugin/accounts.d.ts.map +1 -1
  39. package/dist/src/plugin/accounts.js +31 -1367
  40. package/dist/src/plugin/accounts.js.map +1 -1
  41. package/dist/src/plugin/agy-request-metadata.d.ts +1 -1
  42. package/dist/src/plugin/agy-request-metadata.js +1 -1
  43. package/dist/src/plugin/agy-transport.d.ts +1 -1
  44. package/dist/src/plugin/agy-transport.js +1 -1
  45. package/dist/src/plugin/auth-doctor.d.ts +6 -6
  46. package/dist/src/plugin/auth-doctor.d.ts.map +1 -1
  47. package/dist/src/plugin/auth-doctor.js +74 -66
  48. package/dist/src/plugin/auth-doctor.js.map +1 -1
  49. package/dist/src/plugin/auth-drift.d.ts +4 -4
  50. package/dist/src/plugin/auth-drift.d.ts.map +1 -1
  51. package/dist/src/plugin/auth-drift.js +15 -15
  52. package/dist/src/plugin/auth-drift.js.map +1 -1
  53. package/dist/src/plugin/auth-loader.d.ts +35 -0
  54. package/dist/src/plugin/auth-loader.d.ts.map +1 -0
  55. package/dist/src/plugin/auth-loader.js +144 -0
  56. package/dist/src/plugin/auth-loader.js.map +1 -0
  57. package/dist/src/plugin/auth.d.ts +1 -1
  58. package/dist/src/plugin/auth.js +1 -1
  59. package/dist/src/plugin/cache/index.d.ts +1 -1
  60. package/dist/src/plugin/cache/index.d.ts.map +1 -1
  61. package/dist/src/plugin/cache/index.js +1 -1
  62. package/dist/src/plugin/cache/index.js.map +1 -1
  63. package/dist/src/plugin/cache/signature-cache.d.ts +1 -1
  64. package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -1
  65. package/dist/src/plugin/cache/signature-cache.js +23 -24
  66. package/dist/src/plugin/cache/signature-cache.js.map +1 -1
  67. package/dist/src/plugin/cache.d.ts +6 -5
  68. package/dist/src/plugin/cache.d.ts.map +1 -1
  69. package/dist/src/plugin/cache.js +21 -7
  70. package/dist/src/plugin/cache.js.map +1 -1
  71. package/dist/src/plugin/catalog.d.ts +23 -0
  72. package/dist/src/plugin/catalog.d.ts.map +1 -0
  73. package/dist/src/plugin/catalog.js +60 -0
  74. package/dist/src/plugin/catalog.js.map +1 -0
  75. package/dist/src/plugin/cli.d.ts +7 -7
  76. package/dist/src/plugin/cli.d.ts.map +1 -1
  77. package/dist/src/plugin/cli.js +62 -55
  78. package/dist/src/plugin/cli.js.map +1 -1
  79. package/dist/src/plugin/command-data.d.ts +276 -0
  80. package/dist/src/plugin/command-data.d.ts.map +1 -0
  81. package/dist/src/plugin/command-data.js +325 -0
  82. package/dist/src/plugin/command-data.js.map +1 -0
  83. package/dist/src/plugin/commands.d.ts +151 -0
  84. package/dist/src/plugin/commands.d.ts.map +1 -0
  85. package/dist/src/plugin/commands.js +639 -0
  86. package/dist/src/plugin/commands.js.map +1 -0
  87. package/dist/src/plugin/config/index.d.ts +2 -2
  88. package/dist/src/plugin/config/index.d.ts.map +1 -1
  89. package/dist/src/plugin/config/index.js +2 -2
  90. package/dist/src/plugin/config/index.js.map +1 -1
  91. package/dist/src/plugin/config/loader.d.ts +1 -1
  92. package/dist/src/plugin/config/loader.d.ts.map +1 -1
  93. package/dist/src/plugin/config/loader.js +18 -16
  94. package/dist/src/plugin/config/loader.js.map +1 -1
  95. package/dist/src/plugin/config/models.d.ts +2 -2
  96. package/dist/src/plugin/config/models.d.ts.map +1 -1
  97. package/dist/src/plugin/config/models.js +1 -1
  98. package/dist/src/plugin/config/models.js.map +1 -1
  99. package/dist/src/plugin/config/operator-settings-schema.d.ts +29 -0
  100. package/dist/src/plugin/config/operator-settings-schema.d.ts.map +1 -0
  101. package/dist/src/plugin/config/operator-settings-schema.js +28 -0
  102. package/dist/src/plugin/config/operator-settings-schema.js.map +1 -0
  103. package/dist/src/plugin/config/schema.d.ts +21 -2
  104. package/dist/src/plugin/config/schema.d.ts.map +1 -1
  105. package/dist/src/plugin/config/schema.js +85 -25
  106. package/dist/src/plugin/config/schema.js.map +1 -1
  107. package/dist/src/plugin/config/updater.d.ts.map +1 -1
  108. package/dist/src/plugin/config/updater.js +15 -15
  109. package/dist/src/plugin/config/updater.js.map +1 -1
  110. package/dist/src/plugin/config/writer.d.ts +34 -0
  111. package/dist/src/plugin/config/writer.d.ts.map +1 -0
  112. package/dist/src/plugin/config/writer.js +81 -0
  113. package/dist/src/plugin/config/writer.js.map +1 -0
  114. package/dist/src/plugin/core/streaming/index.d.ts +1 -1
  115. package/dist/src/plugin/core/streaming/index.d.ts.map +1 -1
  116. package/dist/src/plugin/core/streaming/index.js +1 -1
  117. package/dist/src/plugin/core/streaming/index.js.map +1 -1
  118. package/dist/src/plugin/core/streaming/transformer.d.ts.map +1 -1
  119. package/dist/src/plugin/core/streaming/transformer.js +85 -44
  120. package/dist/src/plugin/core/streaming/transformer.js.map +1 -1
  121. package/dist/src/plugin/core/streaming/types.d.ts.map +1 -1
  122. package/dist/src/plugin/debug.d.ts +3 -3
  123. package/dist/src/plugin/debug.d.ts.map +1 -1
  124. package/dist/src/plugin/debug.js +85 -47
  125. package/dist/src/plugin/debug.js.map +1 -1
  126. package/dist/src/plugin/dependencies.d.ts +129 -0
  127. package/dist/src/plugin/dependencies.d.ts.map +1 -0
  128. package/dist/src/plugin/dependencies.js +107 -0
  129. package/dist/src/plugin/dependencies.js.map +1 -0
  130. package/dist/src/plugin/errors.d.ts +27 -0
  131. package/dist/src/plugin/errors.d.ts.map +1 -1
  132. package/dist/src/plugin/errors.js +29 -3
  133. package/dist/src/plugin/errors.js.map +1 -1
  134. package/dist/src/plugin/event-handler.d.ts +53 -0
  135. package/dist/src/plugin/event-handler.d.ts.map +1 -0
  136. package/dist/src/plugin/event-handler.js +101 -0
  137. package/dist/src/plugin/event-handler.js.map +1 -0
  138. package/dist/src/plugin/fetch/retry-state.d.ts +61 -0
  139. package/dist/src/plugin/fetch/retry-state.d.ts.map +1 -0
  140. package/dist/src/plugin/fetch/retry-state.js +248 -0
  141. package/dist/src/plugin/fetch/retry-state.js.map +1 -0
  142. package/dist/src/plugin/fetch/warmup.d.ts +30 -0
  143. package/dist/src/plugin/fetch/warmup.d.ts.map +1 -0
  144. package/dist/src/plugin/fetch/warmup.js +76 -0
  145. package/dist/src/plugin/fetch/warmup.js.map +1 -0
  146. package/dist/src/plugin/fetch-interceptor.d.ts +59 -0
  147. package/dist/src/plugin/fetch-interceptor.d.ts.map +1 -0
  148. package/dist/src/plugin/fetch-interceptor.js +1387 -0
  149. package/dist/src/plugin/fetch-interceptor.js.map +1 -0
  150. package/dist/src/plugin/fetch-routing.d.ts +26 -0
  151. package/dist/src/plugin/fetch-routing.d.ts.map +1 -0
  152. package/dist/src/plugin/fetch-routing.js +99 -0
  153. package/dist/src/plugin/fetch-routing.js.map +1 -0
  154. package/dist/src/plugin/fingerprint.d.ts +1 -1
  155. package/dist/src/plugin/fingerprint.js +1 -1
  156. package/dist/src/plugin/gemini-dump.d.ts +5 -5
  157. package/dist/src/plugin/gemini-dump.d.ts.map +1 -1
  158. package/dist/src/plugin/gemini-dump.js +109 -55
  159. package/dist/src/plugin/gemini-dump.js.map +1 -1
  160. package/dist/src/plugin/google-search-tool.d.ts +9 -0
  161. package/dist/src/plugin/google-search-tool.d.ts.map +1 -0
  162. package/dist/src/plugin/google-search-tool.js +56 -0
  163. package/dist/src/plugin/google-search-tool.js.map +1 -0
  164. package/dist/src/plugin/image-saver.d.ts.map +1 -1
  165. package/dist/src/plugin/image-saver.js +16 -16
  166. package/dist/src/plugin/image-saver.js.map +1 -1
  167. package/dist/src/plugin/index.d.ts +23 -0
  168. package/dist/src/plugin/index.d.ts.map +1 -0
  169. package/dist/src/plugin/index.js +308 -0
  170. package/dist/src/plugin/index.js.map +1 -0
  171. package/dist/src/plugin/killswitch.d.ts +94 -0
  172. package/dist/src/plugin/killswitch.d.ts.map +1 -0
  173. package/dist/src/plugin/killswitch.js +194 -0
  174. package/dist/src/plugin/killswitch.js.map +1 -0
  175. package/dist/src/plugin/lifecycle.d.ts +40 -0
  176. package/dist/src/plugin/lifecycle.d.ts.map +1 -0
  177. package/dist/src/plugin/lifecycle.js +73 -0
  178. package/dist/src/plugin/lifecycle.js.map +1 -0
  179. package/dist/src/plugin/logger.d.ts +10 -1
  180. package/dist/src/plugin/logger.d.ts.map +1 -1
  181. package/dist/src/plugin/logger.js +38 -12
  182. package/dist/src/plugin/logger.js.map +1 -1
  183. package/dist/src/plugin/logging-utils.d.ts +35 -1
  184. package/dist/src/plugin/logging-utils.d.ts.map +1 -1
  185. package/dist/src/plugin/logging-utils.js +98 -15
  186. package/dist/src/plugin/logging-utils.js.map +1 -1
  187. package/dist/src/plugin/model-registry.d.ts +1 -1
  188. package/dist/src/plugin/model-registry.js +1 -1
  189. package/dist/src/plugin/oauth-login.d.ts +22 -0
  190. package/dist/src/plugin/oauth-login.d.ts.map +1 -0
  191. package/dist/src/plugin/oauth-login.js +37 -0
  192. package/dist/src/plugin/oauth-login.js.map +1 -0
  193. package/dist/src/plugin/oauth-methods.d.ts +42 -0
  194. package/dist/src/plugin/oauth-methods.d.ts.map +1 -0
  195. package/dist/src/plugin/oauth-methods.js +1284 -0
  196. package/dist/src/plugin/oauth-methods.js.map +1 -0
  197. package/dist/src/plugin/operator-settings.d.ts +40 -0
  198. package/dist/src/plugin/operator-settings.d.ts.map +1 -0
  199. package/dist/src/plugin/operator-settings.js +148 -0
  200. package/dist/src/plugin/operator-settings.js.map +1 -0
  201. package/dist/src/plugin/persist-account-pool.d.ts +37 -0
  202. package/dist/src/plugin/persist-account-pool.d.ts.map +1 -0
  203. package/dist/src/plugin/persist-account-pool.js +142 -0
  204. package/dist/src/plugin/persist-account-pool.js.map +1 -0
  205. package/dist/src/plugin/project.d.ts +1 -1
  206. package/dist/src/plugin/project.js +1 -1
  207. package/dist/src/plugin/prompt-context.d.ts.map +1 -1
  208. package/dist/src/plugin/prompt-context.js +11 -11
  209. package/dist/src/plugin/prompt-context.js.map +1 -1
  210. package/dist/src/plugin/quota.d.ts +97 -41
  211. package/dist/src/plugin/quota.d.ts.map +1 -1
  212. package/dist/src/plugin/quota.js +273 -285
  213. package/dist/src/plugin/quota.js.map +1 -1
  214. package/dist/src/plugin/recovery/constants.d.ts.map +1 -1
  215. package/dist/src/plugin/recovery/constants.js +24 -15
  216. package/dist/src/plugin/recovery/constants.js.map +1 -1
  217. package/dist/src/plugin/recovery/index.d.ts +3 -3
  218. package/dist/src/plugin/recovery/index.d.ts.map +1 -1
  219. package/dist/src/plugin/recovery/index.js +3 -3
  220. package/dist/src/plugin/recovery/index.js.map +1 -1
  221. package/dist/src/plugin/recovery/storage.d.ts +1 -1
  222. package/dist/src/plugin/recovery/storage.d.ts.map +1 -1
  223. package/dist/src/plugin/recovery/storage.js +31 -39
  224. package/dist/src/plugin/recovery/storage.js.map +1 -1
  225. package/dist/src/plugin/recovery/types.d.ts +12 -12
  226. package/dist/src/plugin/recovery/types.d.ts.map +1 -1
  227. package/dist/src/plugin/recovery.d.ts +3 -3
  228. package/dist/src/plugin/recovery.d.ts.map +1 -1
  229. package/dist/src/plugin/recovery.js +62 -58
  230. package/dist/src/plugin/recovery.js.map +1 -1
  231. package/dist/src/plugin/refresh-queue.d.ts +5 -2
  232. package/dist/src/plugin/refresh-queue.d.ts.map +1 -1
  233. package/dist/src/plugin/refresh-queue.js +37 -15
  234. package/dist/src/plugin/refresh-queue.js.map +1 -1
  235. package/dist/src/plugin/request-helpers.d.ts +1 -1
  236. package/dist/src/plugin/request-helpers.d.ts.map +1 -1
  237. package/dist/src/plugin/request-helpers.js +451 -352
  238. package/dist/src/plugin/request-helpers.js.map +1 -1
  239. package/dist/src/plugin/request.d.ts +7 -7
  240. package/dist/src/plugin/request.d.ts.map +1 -1
  241. package/dist/src/plugin/request.js +622 -384
  242. package/dist/src/plugin/request.js.map +1 -1
  243. package/dist/src/plugin/rotation.d.ts +1 -168
  244. package/dist/src/plugin/rotation.d.ts.map +1 -1
  245. package/dist/src/plugin/rotation.js +1 -327
  246. package/dist/src/plugin/rotation.js.map +1 -1
  247. package/dist/src/plugin/search.d.ts.map +1 -1
  248. package/dist/src/plugin/search.js +39 -35
  249. package/dist/src/plugin/search.js.map +1 -1
  250. package/dist/src/plugin/server.d.ts +1 -1
  251. package/dist/src/plugin/server.d.ts.map +1 -1
  252. package/dist/src/plugin/server.js +42 -37
  253. package/dist/src/plugin/server.js.map +1 -1
  254. package/dist/src/plugin/session-context.d.ts +2 -1
  255. package/dist/src/plugin/session-context.d.ts.map +1 -1
  256. package/dist/src/plugin/session-context.js +11 -7
  257. package/dist/src/plugin/session-context.js.map +1 -1
  258. package/dist/src/plugin/storage.d.ts +59 -120
  259. package/dist/src/plugin/storage.d.ts.map +1 -1
  260. package/dist/src/plugin/storage.js +140 -485
  261. package/dist/src/plugin/storage.js.map +1 -1
  262. package/dist/src/plugin/stores/signature-store.d.ts.map +1 -1
  263. package/dist/src/plugin/stores/signature-store.js.map +1 -1
  264. package/dist/src/plugin/thinking-recovery.d.ts.map +1 -1
  265. package/dist/src/plugin/thinking-recovery.js +35 -33
  266. package/dist/src/plugin/thinking-recovery.js.map +1 -1
  267. package/dist/src/plugin/token.d.ts +2 -2
  268. package/dist/src/plugin/token.d.ts.map +1 -1
  269. package/dist/src/plugin/token.js +30 -21
  270. package/dist/src/plugin/token.js.map +1 -1
  271. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +1 -1
  272. package/dist/src/plugin/transform/cross-model-sanitizer.js +1 -1
  273. package/dist/src/plugin/transform/index.d.ts +1 -1
  274. package/dist/src/plugin/transform/index.js +1 -1
  275. package/dist/src/plugin/transform/model-resolver.d.ts +1 -1
  276. package/dist/src/plugin/transform/model-resolver.js +1 -1
  277. package/dist/src/plugin/transform/types.d.ts +1 -1
  278. package/dist/src/plugin/transform/types.js +1 -1
  279. package/dist/src/plugin/types.d.ts +25 -69
  280. package/dist/src/plugin/types.d.ts.map +1 -1
  281. package/dist/src/plugin/ui/ansi.d.ts.map +1 -1
  282. package/dist/src/plugin/ui/ansi.js.map +1 -1
  283. package/dist/src/plugin/ui/auth-menu.d.ts +1 -1
  284. package/dist/src/plugin/ui/auth-menu.d.ts.map +1 -1
  285. package/dist/src/plugin/ui/auth-menu.js +82 -31
  286. package/dist/src/plugin/ui/auth-menu.js.map +1 -1
  287. package/dist/src/plugin/ui/confirm.d.ts.map +1 -1
  288. package/dist/src/plugin/ui/confirm.js.map +1 -1
  289. package/dist/src/plugin/ui/model-status.d.ts +3 -3
  290. package/dist/src/plugin/ui/model-status.d.ts.map +1 -1
  291. package/dist/src/plugin/ui/model-status.js +3 -3
  292. package/dist/src/plugin/ui/model-status.js.map +1 -1
  293. package/dist/src/plugin/ui/quota-status.d.ts +4 -4
  294. package/dist/src/plugin/ui/quota-status.d.ts.map +1 -1
  295. package/dist/src/plugin/ui/quota-status.js +51 -49
  296. package/dist/src/plugin/ui/quota-status.js.map +1 -1
  297. package/dist/src/plugin/ui/select.d.ts.map +1 -1
  298. package/dist/src/plugin/ui/select.js +22 -12
  299. package/dist/src/plugin/ui/select.js.map +1 -1
  300. package/dist/src/plugin/version.d.ts +1 -1
  301. package/dist/src/plugin/version.js +1 -1
  302. package/dist/src/rpc/notifications.d.ts +6 -0
  303. package/dist/src/rpc/notifications.d.ts.map +1 -0
  304. package/dist/src/rpc/notifications.js +46 -0
  305. package/dist/src/rpc/notifications.js.map +1 -0
  306. package/dist/src/rpc/port-file.d.ts +13 -0
  307. package/dist/src/rpc/port-file.d.ts.map +1 -0
  308. package/dist/src/rpc/port-file.js +109 -0
  309. package/dist/src/rpc/port-file.js.map +1 -0
  310. package/dist/src/rpc/protocol.d.ts +22 -0
  311. package/dist/src/rpc/protocol.d.ts.map +1 -0
  312. package/dist/src/rpc/protocol.js +1 -0
  313. package/dist/src/rpc/protocol.js.map +1 -0
  314. package/dist/src/rpc/rpc-client.d.ts +10 -0
  315. package/dist/src/rpc/rpc-client.d.ts.map +1 -0
  316. package/dist/src/rpc/rpc-client.js +58 -0
  317. package/dist/src/rpc/rpc-client.js.map +1 -0
  318. package/dist/src/rpc/rpc-dir.d.ts +4 -0
  319. package/dist/src/rpc/rpc-dir.d.ts.map +1 -0
  320. package/dist/src/rpc/rpc-dir.js +19 -0
  321. package/dist/src/rpc/rpc-dir.js.map +1 -0
  322. package/dist/src/rpc/rpc-server.d.ts +13 -0
  323. package/dist/src/rpc/rpc-server.d.ts.map +1 -0
  324. package/dist/src/rpc/rpc-server.js +231 -0
  325. package/dist/src/rpc/rpc-server.js.map +1 -0
  326. package/dist/src/sidebar-state.d.ts +240 -0
  327. package/dist/src/sidebar-state.d.ts.map +1 -0
  328. package/dist/src/sidebar-state.js +520 -0
  329. package/dist/src/sidebar-state.js.map +1 -0
  330. package/dist/src/tui/command-dialogs.d.ts +61 -0
  331. package/dist/src/tui/command-dialogs.d.ts.map +1 -0
  332. package/dist/src/tui/command-dialogs.js +497 -0
  333. package/dist/src/tui/command-dialogs.js.map +1 -0
  334. package/dist/src/tui/file-logger.d.ts +41 -0
  335. package/dist/src/tui/file-logger.d.ts.map +1 -0
  336. package/dist/src/tui/file-logger.js +114 -0
  337. package/dist/src/tui/file-logger.js.map +1 -0
  338. package/dist/src/tui-preferences.d.ts +40 -0
  339. package/dist/src/tui-preferences.d.ts.map +1 -0
  340. package/dist/src/tui-preferences.js +328 -0
  341. package/dist/src/tui-preferences.js.map +1 -0
  342. package/dist/src/tui.d.ts +68 -0
  343. package/dist/src/tui.d.ts.map +1 -0
  344. package/dist/src/tui.js +662 -0
  345. package/dist/src/tui.js.map +1 -0
  346. package/package.json +46 -22
  347. package/src/plugin/command-data.ts +651 -0
  348. package/src/rpc/port-file.ts +143 -0
  349. package/src/rpc/protocol.ts +31 -0
  350. package/src/rpc/rpc-client.ts +102 -0
  351. package/src/rpc/rpc-dir.ts +24 -0
  352. package/src/sidebar-state.ts +717 -0
  353. package/src/tui/command-dialogs.tsx +699 -0
  354. package/src/tui/entry.mjs +74 -0
  355. package/src/tui/file-logger.ts +145 -0
  356. package/src/tui-compiled/plugin/command-data.ts +651 -0
  357. package/src/tui-compiled/rpc/port-file.ts +143 -0
  358. package/src/tui-compiled/rpc/protocol.ts +31 -0
  359. package/src/tui-compiled/rpc/rpc-client.ts +102 -0
  360. package/src/tui-compiled/rpc/rpc-dir.ts +24 -0
  361. package/src/tui-compiled/sidebar-state.ts +717 -0
  362. package/src/tui-compiled/tui/command-dialogs.tsx +659 -0
  363. package/src/tui-compiled/tui/file-logger.ts +145 -0
  364. package/src/tui-compiled/tui-preferences.ts +416 -0
  365. package/src/tui-compiled/tui.tsx +1150 -0
  366. package/src/tui-preferences.ts +416 -0
  367. package/src/tui.tsx +1117 -0
  368. package/dist/src/plugin.d.ts +0 -48
  369. package/dist/src/plugin.d.ts.map +0 -1
  370. package/dist/src/plugin.js +0 -3311
  371. package/dist/src/plugin.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../../src/plugin/dependencies.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAA;AAEhC,OAAO,EAEL,wBAAwB,GACzB,MAAM,kCAAkC,CAAA;AAEzC,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAA;AA4FhF;;;;;;;GAOG;AACH,MAAM,UAAU,sBAAsB;IACpC,MAAM,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,eAAe,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,CAAC,CAAA;IAC3E,MAAM,QAAQ,GACZ,OAAO,CAAC,GAAG,CAAC,cAAc,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAA;IAClE,OAAO;QACL,WAAW,EAAE,OAAO,CAAC,GA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AE,IAAI,CAAC;QAAE,OAAM;IACnB,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QAC1C,MAAM,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;YAC5B,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAA;YAC7C,OAAO,EAAE,CAAA;QACX,CAAC,EAAE,EAAE,CAAC,CAAA;QACN,KAAK,CAAC,KAAK,EAAE,EAAE,CAAA;QACf,MAAM,OAAO,GAAG,GAAG,EAAE;YACnB,YAAY,CAAC,KAAK,CAAC,CAAA;YACnB,MAAM,CACJ,MAAM,EAAE,MAAM,YAAY,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,KAAK,CAAC,SAAS,CAAC,CACvE,CAAA;QACH,CAAC,CAAA;QACD,MAAM,EAAE,gBAAgB,CAAC,OAAO,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAA;IAC5D,CAAC,CAAC,CAAA;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAY,KAAK,IAAI,EAAE,CAAC,CAAC;IACtD,IAAI,EAAE,SAAS;IACf,GAAG,EAAE,EAAE;CACR,CAAC,CAAA"}
@@ -25,4 +25,31 @@ export declare class ToolIdMismatchError extends Error {
25
25
  readonly foundIds: string[];
26
26
  constructor(expectedIds: string[], foundIds: string[], message?: string);
27
27
  }
28
+ /**
29
+ * Thrown when the operator killswitch excludes every available account.
30
+ *
31
+ * The killswitch compares each candidate's freshest cached quota
32
+ * remaining-percent against an account-specific override (or the
33
+ * global threshold) and excludes accounts below the floor. When all
34
+ * accounts are excluded, the fetch interceptor throws this error
35
+ * with redacted summaries so the host can surface a useful message
36
+ * without exposing any account identifiers or tokens.
37
+ */
38
+ export declare class AntigravityKillswitchError extends Error {
39
+ readonly family: string;
40
+ readonly model: string;
41
+ readonly thresholdPercent: number;
42
+ readonly summaries: Array<{
43
+ accountKey: string;
44
+ remainingPercent: number | null;
45
+ thresholdPercent: number;
46
+ }>;
47
+ constructor(input: {
48
+ family: string;
49
+ model: string;
50
+ thresholdPercent: number;
51
+ summaries: AntigravityKillswitchError['summaries'];
52
+ message?: string;
53
+ });
54
+ }
28
55
  //# sourceMappingURL=errors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/plugin/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;gBAGxB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM;CAYnB;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,CAAC;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAC;gBAEhB,WAAW,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM;CASxE"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/plugin/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AACH,qBAAa,kBAAmB,SAAQ,KAAK;IAC3C,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;gBAGvB,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,MAAM;CAYnB;AAED;;GAEG;AACH,qBAAa,mBAAoB,SAAQ,KAAK;IAC5C,QAAQ,CAAC,WAAW,EAAE,MAAM,EAAE,CAAA;IAC9B,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;gBAEf,WAAW,EAAE,MAAM,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,OAAO,CAAC,EAAE,MAAM;CASxE;AAED;;;;;;;;;GASG;AACH,qBAAa,0BAA2B,SAAQ,KAAK;IACnD,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAA;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,gBAAgB,EAAE,MAAM,CAAA;IACjC,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC;QACxB,UAAU,EAAE,MAAM,CAAA;QAClB,gBAAgB,EAAE,MAAM,GAAG,IAAI,CAAA;QAC/B,gBAAgB,EAAE,MAAM,CAAA;KACzB,CAAC,CAAA;gBAEU,KAAK,EAAE;QACjB,MAAM,EAAE,MAAM,CAAA;QACd,KAAK,EAAE,MAAM,CAAA;QACb,gBAAgB,EAAE,MAAM,CAAA;QACxB,SAAS,EAAE,0BAA0B,CAAC,WAAW,CAAC,CAAA;QAClD,OAAO,CAAC,EAAE,MAAM,CAAA;KACjB;CAYF"}
@@ -19,7 +19,7 @@ export class EmptyResponseError extends Error {
19
19
  super(message ??
20
20
  `The model returned an empty response after ${attempts} attempts. ` +
21
21
  `This may indicate a temporary service issue. Please try again.`);
22
- this.name = "EmptyResponseError";
22
+ this.name = 'EmptyResponseError';
23
23
  this.provider = provider;
24
24
  this.model = model;
25
25
  this.attempts = attempts;
@@ -33,10 +33,36 @@ export class ToolIdMismatchError extends Error {
33
33
  foundIds;
34
34
  constructor(expectedIds, foundIds, message) {
35
35
  super(message ??
36
- `Tool ID mismatch: expected [${expectedIds.join(", ")}] but found [${foundIds.join(", ")}]`);
37
- this.name = "ToolIdMismatchError";
36
+ `Tool ID mismatch: expected [${expectedIds.join(', ')}] but found [${foundIds.join(', ')}]`);
37
+ this.name = 'ToolIdMismatchError';
38
38
  this.expectedIds = expectedIds;
39
39
  this.foundIds = foundIds;
40
40
  }
41
41
  }
42
+ /**
43
+ * Thrown when the operator killswitch excludes every available account.
44
+ *
45
+ * The killswitch compares each candidate's freshest cached quota
46
+ * remaining-percent against an account-specific override (or the
47
+ * global threshold) and excludes accounts below the floor. When all
48
+ * accounts are excluded, the fetch interceptor throws this error
49
+ * with redacted summaries so the host can surface a useful message
50
+ * without exposing any account identifiers or tokens.
51
+ */
52
+ export class AntigravityKillswitchError extends Error {
53
+ family;
54
+ model;
55
+ thresholdPercent;
56
+ summaries;
57
+ constructor(input) {
58
+ super(input.message ??
59
+ `Antigravity killswitch: all ${input.summaries.length} account(s) under ${input.thresholdPercent}% quota for ${input.family}. ` +
60
+ `Refresh quota or raise the threshold via /antigravity-killswitch.`);
61
+ this.name = 'AntigravityKillswitchError';
62
+ this.family = input.family;
63
+ this.model = input.model;
64
+ this.thresholdPercent = input.thresholdPercent;
65
+ this.summaries = input.summaries;
66
+ }
67
+ }
42
68
  //# sourceMappingURL=errors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/plugin/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH;;;;;;;GAOG;AACH,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IAClC,QAAQ,CAAS;IACjB,KAAK,CAAS;IACd,QAAQ,CAAS;IAE1B,YACE,QAAgB,EAChB,KAAa,EACb,QAAgB,EAChB,OAAgB;QAEhB,KAAK,CACH,OAAO;YACL,8CAA8C,QAAQ,aAAa;gBACnE,gEAAgE,CACnE,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,oBAAoB,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;Q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AAQ,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAC9F,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAA;QACjC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAA;QAC9B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAA;IAC1B,CAAC;CACF;AAED;;;;;;;;;GASG;AACH,MAAM,OAAO,0BAA2B,SAAQ,KAAK;IAC1C,MAAM,CAAQ;IACd,KAAK,CAAQ;IACb,gBAAgB,CAAQ;IACxB,SAAS,CAIhB;IAEF,YAAY,KAMX;QACC,KAAK,CACH,KAAK,CAAC,OAAO;YACX,+BAA+B,KAAK,CAAC,SAAS,CAAC,MAAM,qBAAqB,KAAK,CAAC,gBAAgB,eAAe,KAAK,CAAC,MAAM,IAAI;gBAC7H,mEAAmE,CACxE,CAAA;QACD,IAAI,CAAC,IAAI,GAAG,4BAA4B,CAAA;QACxC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAA;QAC1B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAA;QACxB,IAAI,CAAC,gBAAgB,GAAG,KAAK,CAAC,gBAAgB,CAAA;QAC9C,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAA;IAClC,CAAC;CACF"}
@@ -0,0 +1,53 @@
1
+ import type { AntigravityConfig } from './config';
2
+ import type { Logger } from './logger';
3
+ import type { PluginClient } from './types';
4
+ type EventInput = {
5
+ event: {
6
+ type: string;
7
+ properties?: unknown;
8
+ };
9
+ };
10
+ type SessionSummary = {
11
+ durationMinutes: number;
12
+ totalClaude: number;
13
+ totalGemini: number;
14
+ requestsPerHour: number;
15
+ accountsUsed: number;
16
+ };
17
+ type EventAccountManager = {
18
+ getSessionSummary(): SessionSummary;
19
+ deleteSessionState(sessionId: string): void;
20
+ };
21
+ type EventLifecycle = {
22
+ getAccountManager(): EventAccountManager | null;
23
+ };
24
+ type EventSessionRegistry = {
25
+ register(sessionId: string, parentSessionId: string | null): void;
26
+ delete(sessionId: string): void;
27
+ getParentSessionId(sessionId: string): string | null;
28
+ };
29
+ type EventSessionRecovery = {
30
+ isRecoverableError(error: unknown): boolean;
31
+ handleSessionRecovery(info: {
32
+ id?: string;
33
+ role: 'assistant';
34
+ sessionID?: string;
35
+ error: unknown;
36
+ }): Promise<boolean>;
37
+ };
38
+ type EventUpdateChecker = {
39
+ event(input: EventInput): void | Promise<void>;
40
+ };
41
+ export interface CreateEventHandlerOptions {
42
+ client: PluginClient;
43
+ config: Pick<AntigravityConfig, 'auto_resume' | 'resume_text' | 'toast_scope'>;
44
+ directory: string;
45
+ lifecycle: EventLifecycle;
46
+ sessionRegistry: EventSessionRegistry;
47
+ sessionRecovery: EventSessionRecovery | null;
48
+ updateChecker: EventUpdateChecker;
49
+ logger: Pick<Logger, 'debug'>;
50
+ }
51
+ export declare function createEventHandler({ client, config, directory, lifecycle, sessionRegistry, sessionRecovery, updateChecker, logger, }: CreateEventHandlerOptions): (input: EventInput) => Promise<void>;
52
+ export {};
53
+ //# sourceMappingURL=event-handler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-handler.d.ts","sourceRoot":"","sources":["../../../src/plugin/event-handler.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAA;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAEtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAE3C,KAAK,UAAU,GAAG;IAChB,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,UAAU,CAAC,EAAE,OAAO,CAAA;KAAE,CAAA;CAC9C,CAAA;AAED,KAAK,cAAc,GAAG;IACpB,eAAe,EAAE,MAAM,CAAA;IACvB,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;IACnB,eAAe,EAAE,MAAM,CAAA;IACvB,YAAY,E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ACjC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,OAAO,CAAC,CAAA;CAC9B;AAED,wBAAgB,kBAAkB,CAAC,EACjC,MAAM,EACN,MAAM,EACN,SAAS,EACT,SAAS,EACT,eAAe,EACf,eAAe,EACf,aAAa,EACb,MAAM,GACP,EAAE,yBAAyB,IACZ,OAAO,UAAU,KAAG,OAAO,CAAC,IAAI,CAAC,CAqHhD"}
@@ -0,0 +1,101 @@
1
+ import { removeSidebarActiveRouting } from '../sidebar-state';
2
+ import { getRecoverySuccessToast } from './recovery';
3
+ export function createEventHandler({ client, config, directory, lifecycle, sessionRegistry, sessionRecovery, updateChecker, logger, }) {
4
+ return async (input) => {
5
+ await updateChecker.event(input);
6
+ if (input.event.type === 'session.created') {
7
+ const properties = input.event.properties;
8
+ const sessionId = properties?.info?.id;
9
+ const parentSessionId = properties?.info?.parentID ?? null;
10
+ if (sessionId) {
11
+ sessionRegistry.register(sessionId, parentSessionId);
12
+ }
13
+ if (parentSessionId) {
14
+ logger.debug('child-session-detected', {
15
+ sessionId,
16
+ parentID: parentSessionId,
17
+ });
18
+ }
19
+ else {
20
+ const previousSummary = lifecycle
21
+ .getAccountManager()
22
+ ?.getSessionSummary();
23
+ if (previousSummary &&
24
+ (previousSummary.totalClaude > 0 || previousSummary.totalGemini > 0)) {
25
+ logger.debug('prev-session-quota-summary', {
26
+ durationMinutes: previousSummary.durationMinutes,
27
+ totalClaude: previousSummary.totalClaude,
28
+ totalGemini: previousSummary.totalGemini,
29
+ requestsPerHour: previousSummary.requestsPerHour,
30
+ accountsUsed: previousSummary.accountsUsed,
31
+ });
32
+ }
33
+ logger.debug('root-session-detected', { sessionId });
34
+ }
35
+ }
36
+ if (input.event.type === 'session.deleted') {
37
+ const properties = input.event.properties;
38
+ const sessionId = properties?.sessionID ?? properties?.info?.id;
39
+ if (sessionId) {
40
+ sessionRegistry.delete(sessionId);
41
+ lifecycle.getAccountManager()?.deleteSessionState(sessionId);
42
+ // Drop the session's sidebar route so the TUI does not retain a
43
+ // dead route after the session ends. Fire-and-forget; the next
44
+ // sidebar poll will see the pruned map.
45
+ const eventLogger = logger;
46
+ void removeSidebarActiveRouting(sessionId).catch((error) => {
47
+ eventLogger.debug('sidebar-route-remove-failed', {
48
+ sessionId,
49
+ error: String(error),
50
+ });
51
+ });
52
+ }
53
+ }
54
+ if (!sessionRecovery || input.event.type !== 'session.error') {
55
+ return;
56
+ }
57
+ const properties = input.event.properties;
58
+ const sessionID = properties?.sessionID;
59
+ const messageID = properties?.messageID;
60
+ const error = properties?.error;
61
+ if (!sessionRecovery.isRecoverableError(error)) {
62
+ return;
63
+ }
64
+ const recovered = await sessionRecovery.handleSessionRecovery({
65
+ id: messageID,
66
+ role: 'assistant',
67
+ sessionID,
68
+ error,
69
+ });
70
+ if (!recovered || !sessionID || !config.auto_resume) {
71
+ return;
72
+ }
73
+ await client.session
74
+ .prompt({
75
+ path: { id: sessionID },
76
+ body: { parts: [{ type: 'text', text: config.resume_text }] },
77
+ query: { directory },
78
+ })
79
+ .catch(() => { });
80
+ const successToast = getRecoverySuccessToast();
81
+ const isChildSession = sessionRegistry.getParentSessionId(sessionID) !== null;
82
+ logger.debug('recovery-toast', {
83
+ ...successToast,
84
+ isChildSession,
85
+ toastScope: config.toast_scope,
86
+ });
87
+ if (config.toast_scope === 'root_only' && isChildSession) {
88
+ return;
89
+ }
90
+ await client.tui
91
+ .showToast({
92
+ body: {
93
+ title: successToast.title,
94
+ message: successToast.message,
95
+ variant: 'success',
96
+ },
97
+ })
98
+ .catch(() => { });
99
+ };
100
+ }
101
+ //# sourceMappingURL=event-handler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"event-handler.js","sourceRoot":"","sources":["../../../src/plugin/event-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,0BAA0B,EAAE,MAAM,kBAAkB,CAAA;AAG7D,OAAO,EAAE,uBAAuB,EAAE,MAAM,YAAY,CAAA;AAuDpD,MAAM,UAAU,kBAAkB,CA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E,EAAE,SAAS;YACb,IAAI,EAAE,WAAW;YACjB,SAAS;YACT,KAAK;SACN,CAAC,CAAA;QAEF,IAAI,CAAC,SAAS,IAAI,CAAC,SAAS,IAAI,CAAC,MAAM,CAAC,WAAW,EAAE,CAAC;YACpD,OAAM;QACR,CAAC;QAED,MAAM,MAAM,CAAC,OAAO;aACjB,MAAM,CAAC;YACN,IAAI,EAAE,EAAE,EAAE,EAAE,SAAS,EAAE;YACvB,IAAI,EAAE,EAAE,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,WAAW,EAAE,CAAC,EAAE;YAC7D,KAAK,EAAE,EAAE,SAAS,EAAE;SACrB,CAAC;aACD,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;QAElB,MAAM,YAAY,GAAG,uBAAuB,EAAE,CAAA;QAC9C,MAAM,cAAc,GAClB,eAAe,CAAC,kBAAkB,CAAC,SAAS,CAAC,KAAK,IAAI,CAAA;QACxD,MAAM,CAAC,KAAK,CAAC,gBAAgB,EAAE;YAC7B,GAAG,YAAY;YACf,cAAc;YACd,UAAU,EAAE,MAAM,CAAC,WAAW;SAC/B,CAAC,CAAA;QAEF,IAAI,MAAM,CAAC,WAAW,KAAK,WAAW,IAAI,cAAc,EAAE,CAAC;YACzD,OAAM;QACR,CAAC;QAED,MAAM,MAAM,CAAC,GAAG;aACb,SAAS,CAAC;YACT,IAAI,EAAE;gBACJ,KAAK,EAAE,YAAY,CAAC,KAAK;gBACzB,OAAO,EAAE,YAAY,CAAC,OAAO;gBAC7B,OAAO,EAAE,SAAS;aACnB;SACF,CAAC;aACD,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAA;IACpB,CAAC,CAAA;AACH,CAAC"}
@@ -0,0 +1,61 @@
1
+ import type { HeaderStyle, ModelFamily } from '../accounts';
2
+ export interface AccountFailureResult {
3
+ failures: number;
4
+ shouldCooldown: boolean;
5
+ cooldownMs: number;
6
+ }
7
+ export interface RateLimitBackoffResult {
8
+ attempt: number;
9
+ delayMs: number;
10
+ isDuplicate: boolean;
11
+ }
12
+ /**
13
+ * Diagnostic snapshot of the four internal maps. Exposed for tests and for
14
+ * future diagnostics endpoints; callers must not mutate the returned view.
15
+ */
16
+ export interface RetryStateSizes {
17
+ rateLimitState: number;
18
+ accountFailure: number;
19
+ rateLimitToast: number;
20
+ emptyResponse: number;
21
+ }
22
+ export interface RetryState {
23
+ /** Marks the instance as torn down; subsequent mutations are no-ops. */
24
+ readonly disposed: boolean;
25
+ /** Returns the rate-limit backoff for the given account + quota key. */
26
+ getRateLimitBackoff(accountIndex: number, quotaKey: string, serverRetryAfterMs: number | null, maxBackoffMs?: number): RateLimitBackoffResult;
27
+ /** Resets a single account/quota pair. */
28
+ resetRateLimitState(accountIndex: number, quotaKey: string): void;
29
+ /** Resets every quota key for the given account. */
30
+ resetAllRateLimitStateForAccount(accountIndex: number): void;
31
+ /** Maps header style + family to a deduplication bucket. */
32
+ headerStyleToQuotaKey(headerStyle: HeaderStyle, family: ModelFamily): string;
33
+ /** Records a non-429 failure and returns cooldown state. */
34
+ trackAccountFailure(accountIndex: number): AccountFailureResult;
35
+ /** Clears the failure counter for one account. */
36
+ resetAccountFailureState(accountIndex: number): void;
37
+ /** Returns true when the rate-limit warning toast may be shown. */
38
+ shouldShowRateLimitToast(message: string): boolean;
39
+ /** Marks the "all accounts blocked — soft quota" toast as shown. */
40
+ markSoftQuotaToastShown(): void;
41
+ /** Marks the "all accounts blocked — rate limit" toast as shown. */
42
+ markRateLimitToastShown(): void;
43
+ /** Reads the soft-quota toast guard flag. */
44
+ softQuotaToastShown(): boolean;
45
+ /** Reads the rate-limit toast guard flag. */
46
+ rateLimitToastShown(): boolean;
47
+ /** Clears both blocked-toast guards. */
48
+ resetAllAccountsBlockedToasts(): void;
49
+ /** Increments the per-session empty-response attempt counter. */
50
+ recordEmptyResponseAttempt(key: string): number;
51
+ /** Drops all empty-response attempt counters. */
52
+ clearEmptyResponseAttempts(): void;
53
+ /** Resets every map/flag. */
54
+ clear(): void;
55
+ /** Drops all state and prevents further mutations. */
56
+ dispose(): void;
57
+ /** Diagnostic snapshot of every internal map's current size. */
58
+ sizes(): RetryStateSizes;
59
+ }
60
+ export declare function createRetryState(): RetryState;
61
+ //# sourceMappingURL=retry-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry-state.d.ts","sourceRoot":"","sources":["../../../../src/plugin/fetch/retry-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AA8B3D,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAA;IAChB,cAAc,EAAE,OAAO,CAAA;IACvB,UAAU,EAAE,MAAM,CAAA;CACnB;AAQD,MAAM,WAAW,sBAAsB;IACrC,OAAO,EAAE,MAAM,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,OAAO,CAAA;CACrB;AAED;;;GAGG;AACH,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,cAAc,EAAE,MAAM,CAAA;IACtB,aAAa,EAAE,MAAM,CAAA;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,wEAAwE;IACxE,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B,wEAAwE;IACxE,mBAAmB,CACjB,YAAY,EAAE,MAAM,EACpB,QAAQ,EAAE,MAAM,EAChB,kBAAkB,EAAE,MAAM,GAAG,IAAI,EACjC,YAAY,CAAC,EAAE,MAAM,GACpB,sBAAsB,CAAA;IACzB,0CAA0C;IAC1C,mBAAmB,CAAC,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAA;IACjE,oDAAoD;IACpD,gCAAgC,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC5D,4DAA4D;IAC5D,qBAAqB,CAAC,WAAW,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,GAAG,MAAM,CAAA;IAC5E,4DAA4D;IAC5D,mBAAmB,CAAC,YAAY,EAAE,MAAM,GAAG,oBAAoB,CAAA;IAC/D,kDAAkD;IAClD,wBAAwB,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IACpD,mEAAmE;IACnE,wBAAwB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAA;IAClD,oEAAoE;IACpE,uBAAuB,IAAI,IAAI,CAAA;IAC/B,oEAAoE;IACpE,uBAAuB,IAAI,IAAI,CAAA;IAC/B,6CAA6C;IAC7C,mBAAmB,IAAI,OAAO,CAAA;IAC9B,6CAA6C;IAC7C,mBAAmB,IAAI,OAAO,CAAA;IAC9B,wCAAwC;IACxC,6BAA6B,IAAI,IAAI,CAAA;IACrC,iEAAiE;IACjE,0BAA0B,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAA;IAC/C,iDAAiD;IACjD,0BAA0B,IAAI,IAAI,CAAA;IAClC,6BAA6B;IAC7B,KAAK,IAAI,IAAI,CAAA;IACb,sDAAsD;IACtD,OAAO,IAAI,IAAI,CAAA;IACf,gEAAgE;IAChE,KAAK,IAAI,eAAe,CAAA;CACzB;AA2BD,wBAAgB,gBAAgB,IAAI,UAAU,CA6N7C"}
@@ -0,0 +1,248 @@
1
+ /**
2
+ * Per-interceptor state that was previously module-global.
3
+ *
4
+ * The legacy plugin kept rate-limit cooldowns, account-failure counters, toast
5
+ * dedup flags, and empty-response attempt counters at module scope. That kept
6
+ * state alive across `dispose()`, which leaked warmup/rate-limit telemetry
7
+ * across unrelated plugin lifetimes. This class owns the same bookkeeping but
8
+ * scopes it to a single fetch interceptor instance.
9
+ *
10
+ * Every internal map is bounded by `MAX_MAP_ENTRIES`; once full, the oldest
11
+ * insertion is evicted before the new entry is recorded. This matches the
12
+ * warmup-state eviction policy and keeps long-lived interceptors from
13
+ * accumulating telemetry past the cap.
14
+ *
15
+ * `dispose()` is terminal: every mutating method becomes a no-op (or returns
16
+ * a documented identity value) once `disposed` flips to `true`. The plugin
17
+ * tear-down order may race with an in-flight fetch, so guards must return
18
+ * safe defaults rather than throw.
19
+ */
20
+ const MAX_CONSECUTIVE_FAILURES = 5;
21
+ const FAILURE_COOLDOWN_MS = 30_000;
22
+ const FAILURE_STATE_RESET_MS = 120_000;
23
+ const RATE_LIMIT_DEDUP_WINDOW_MS = 2_000;
24
+ const RATE_LIMIT_STATE_RESET_MS = 120_000;
25
+ const RATE_LIMIT_TOAST_COOLDOWN_MS = 5_000;
26
+ const MAX_MAP_ENTRIES = 100;
27
+ /** Identity values returned by mutating methods once `disposed` flips. */
28
+ const DISPOSED_BACKOFF = {
29
+ attempt: 1,
30
+ delayMs: 1000,
31
+ isDuplicate: false,
32
+ };
33
+ const DISPOSED_FAILURE = {
34
+ failures: 0,
35
+ shouldCooldown: false,
36
+ cooldownMs: 0,
37
+ };
38
+ /**
39
+ * Evicts the oldest entry from `map` if it is at the cap. Maps preserve
40
+ * insertion order, so the first key from the iterator is the oldest. Returns
41
+ * the number of evicted entries (0 or 1).
42
+ */
43
+ function evictOldestIfFull(map, key) {
44
+ if (map.has(key) || map.size < MAX_MAP_ENTRIES)
45
+ return 0;
46
+ const oldest = map.keys().next().value;
47
+ if (oldest === undefined)
48
+ return 0;
49
+ map.delete(oldest);
50
+ return 1;
51
+ }
52
+ export function createRetryState() {
53
+ const rateLimitStateByAccountQuota = new Map();
54
+ const accountFailureState = new Map();
55
+ const rateLimitToastCooldowns = new Map();
56
+ const emptyResponseAttempts = new Map();
57
+ let softQuotaToastShownFlag = false;
58
+ let rateLimitToastShownFlag = false;
59
+ let disposed = false;
60
+ function isDisposed() {
61
+ return disposed;
62
+ }
63
+ function cleanupToastCooldowns() {
64
+ if (rateLimitToastCooldowns.size <= MAX_MAP_ENTRIES)
65
+ return;
66
+ const now = Date.now();
67
+ for (const [key, time] of rateLimitToastCooldowns) {
68
+ if (now - time > RATE_LIMIT_TOAST_COOLDOWN_MS * 2) {
69
+ rateLimitToastCooldowns.delete(key);
70
+ }
71
+ }
72
+ }
73
+ function getRateLimitBackoff(accountIndex, quotaKey, serverRetryAfterMs, maxBackoffMs = 60_000) {
74
+ if (isDisposed())
75
+ return DISPOSED_BACKOFF;
76
+ const now = Date.now();
77
+ const stateKey = `${accountIndex}:${quotaKey}`;
78
+ const previous = rateLimitStateByAccountQuota.get(stateKey);
79
+ if (previous && now - previous.lastAt < RATE_LIMIT_DEDUP_WINDOW_MS) {
80
+ const baseDelay = serverRetryAfterMs ?? 1000;
81
+ const backoffDelay = Math.min(baseDelay * 2 ** (previous.consecutive429 - 1), maxBackoffMs);
82
+ return {
83
+ attempt: previous.consecutive429,
84
+ delayMs: Math.max(baseDelay, backoffDelay),
85
+ isDuplicate: true,
86
+ };
87
+ }
88
+ const attempt = previous && now - previous.lastAt < RATE_LIMIT_STATE_RESET_MS
89
+ ? previous.consecutive429 + 1
90
+ : 1;
91
+ evictOldestIfFull(rateLimitStateByAccountQuota, stateKey);
92
+ rateLimitStateByAccountQuota.set(stateKey, {
93
+ consecutive429: attempt,
94
+ lastAt: now,
95
+ quotaKey,
96
+ });
97
+ const baseDelay = serverRetryAfterMs ?? 1000;
98
+ const backoffDelay = Math.min(baseDelay * 2 ** (attempt - 1), maxBackoffMs);
99
+ return {
100
+ attempt,
101
+ delayMs: Math.max(baseDelay, backoffDelay),
102
+ isDuplicate: false,
103
+ };
104
+ }
105
+ function resetRateLimitState(accountIndex, quotaKey) {
106
+ if (isDisposed())
107
+ return;
108
+ const stateKey = `${accountIndex}:${quotaKey}`;
109
+ rateLimitStateByAccountQuota.delete(stateKey);
110
+ }
111
+ function resetAllRateLimitStateForAccount(accountIndex) {
112
+ if (isDisposed())
113
+ return;
114
+ for (const key of rateLimitStateByAccountQuota.keys()) {
115
+ if (key.startsWith(`${accountIndex}:`)) {
116
+ rateLimitStateByAccountQuota.delete(key);
117
+ }
118
+ }
119
+ }
120
+ function headerStyleToQuotaKey(headerStyle, family) {
121
+ if (family === 'claude')
122
+ return 'claude';
123
+ return headerStyle === 'antigravity' ? 'gemini-antigravity' : 'gemini-cli';
124
+ }
125
+ function trackAccountFailure(accountIndex) {
126
+ if (isDisposed())
127
+ return DISPOSED_FAILURE;
128
+ const now = Date.now();
129
+ const previous = accountFailureState.get(accountIndex);
130
+ const failures = previous && now - previous.lastFailureAt < FAILURE_STATE_RESET_MS
131
+ ? previous.consecutiveFailures + 1
132
+ : 1;
133
+ evictOldestIfFull(accountFailureState, accountIndex);
134
+ accountFailureState.set(accountIndex, {
135
+ consecutiveFailures: failures,
136
+ lastFailureAt: now,
137
+ });
138
+ const shouldCooldown = failures >= MAX_CONSECUTIVE_FAILURES;
139
+ const cooldownMs = shouldCooldown ? FAILURE_COOLDOWN_MS : 0;
140
+ return { failures, shouldCooldown, cooldownMs };
141
+ }
142
+ function resetAccountFailureState(accountIndex) {
143
+ if (isDisposed())
144
+ return;
145
+ accountFailureState.delete(accountIndex);
146
+ }
147
+ function shouldShowRateLimitToast(message) {
148
+ if (isDisposed())
149
+ return false;
150
+ cleanupToastCooldowns();
151
+ const toastKey = message.replace(/\d+/g, 'X');
152
+ const lastShown = rateLimitToastCooldowns.get(toastKey) ?? 0;
153
+ const now = Date.now();
154
+ if (now - lastShown < RATE_LIMIT_TOAST_COOLDOWN_MS) {
155
+ return false;
156
+ }
157
+ evictOldestIfFull(rateLimitToastCooldowns, toastKey);
158
+ rateLimitToastCooldowns.set(toastKey, now);
159
+ return true;
160
+ }
161
+ function markSoftQuotaToastShown() {
162
+ if (isDisposed())
163
+ return;
164
+ softQuotaToastShownFlag = true;
165
+ }
166
+ function markRateLimitToastShown() {
167
+ if (isDisposed())
168
+ return;
169
+ rateLimitToastShownFlag = true;
170
+ }
171
+ function softQuotaToastShown() {
172
+ return !isDisposed() && softQuotaToastShownFlag;
173
+ }
174
+ function rateLimitToastShown() {
175
+ return !isDisposed() && rateLimitToastShownFlag;
176
+ }
177
+ function resetAllAccountsBlockedToasts() {
178
+ if (isDisposed())
179
+ return;
180
+ softQuotaToastShownFlag = false;
181
+ rateLimitToastShownFlag = false;
182
+ }
183
+ function recordEmptyResponseAttempt(key) {
184
+ if (isDisposed())
185
+ return 0;
186
+ const next = (emptyResponseAttempts.get(key) ?? 0) + 1;
187
+ evictOldestIfFull(emptyResponseAttempts, key);
188
+ emptyResponseAttempts.set(key, next);
189
+ return next;
190
+ }
191
+ function clearEmptyResponseAttempts() {
192
+ if (isDisposed())
193
+ return;
194
+ emptyResponseAttempts.clear();
195
+ }
196
+ function clear() {
197
+ if (isDisposed())
198
+ return;
199
+ rateLimitStateByAccountQuota.clear();
200
+ accountFailureState.clear();
201
+ rateLimitToastCooldowns.clear();
202
+ emptyResponseAttempts.clear();
203
+ softQuotaToastShownFlag = false;
204
+ rateLimitToastShownFlag = false;
205
+ }
206
+ function dispose() {
207
+ if (disposed)
208
+ return;
209
+ rateLimitStateByAccountQuota.clear();
210
+ accountFailureState.clear();
211
+ rateLimitToastCooldowns.clear();
212
+ emptyResponseAttempts.clear();
213
+ softQuotaToastShownFlag = false;
214
+ rateLimitToastShownFlag = false;
215
+ disposed = true;
216
+ }
217
+ function sizes() {
218
+ return {
219
+ rateLimitState: rateLimitStateByAccountQuota.size,
220
+ accountFailure: accountFailureState.size,
221
+ rateLimitToast: rateLimitToastCooldowns.size,
222
+ emptyResponse: emptyResponseAttempts.size,
223
+ };
224
+ }
225
+ return {
226
+ get disposed() {
227
+ return disposed;
228
+ },
229
+ getRateLimitBackoff,
230
+ resetRateLimitState,
231
+ resetAllRateLimitStateForAccount,
232
+ headerStyleToQuotaKey,
233
+ trackAccountFailure,
234
+ resetAccountFailureState,
235
+ shouldShowRateLimitToast,
236
+ markSoftQuotaToastShown,
237
+ markRateLimitToastShown,
238
+ softQuotaToastShown,
239
+ rateLimitToastShown,
240
+ resetAllAccountsBlockedToasts,
241
+ recordEmptyResponseAttempt,
242
+ clearEmptyResponseAttempts,
243
+ clear,
244
+ dispose,
245
+ sizes,
246
+ };
247
+ }
248
+ //# sourceMappingURL=retry-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry-state.js","sourceRoot":"","sources":["../../../../src/plugin/fetch/retry-state.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,MAAM,wBAAwB,GAAG,CAAC,CAAA;AAClC,MAAM,mBAAmB,GAAG,MAAM,CAAA;AAClC,MAAM,sBAAsB,GAAG,OAAO,CAAA;AACtC,MAAM,0BAA0B,GAAG,KAAK,CAAA;AACxC,MAAM,yBAAyB,GAAG,OAAO,CAAA;AACzC,MAAM,4BAA4B,GAAG,KAAK,CAAA;AAC1C,MAAM,eAAe,GAAG,GAAG,CAAA;AA2E3B,0EAA0E;AAC1E,MAAM,gBAAgB,GAA2B;IAC/C,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,IAAI;IACb,WAAW,EAAE,KAAK;CACnB,CAAA;AACD,MAAM,gBAAgB,GAAyB;IAC7C,QAAQ,EAAE,CAAC;IACX,cAAc,EAAE,KAAK;IACrB,UAAU,EAAE,CAAC;CACd,CAAA;AAED;;;;GAIG;AACH,SAAS,iBAAiB,CAAO,GAAc,EAAE,GAAM;IACrD,IAAI,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC,IAAI,GAAG,eAAe;QAAE,OAAO,CAAC,CAAA;IACxD,MAAM,MAAM,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAsB,CAAA;IACvD,IAAI,MAAM,KAAK,SAAS;QAAE,OAAO,CAAC,CAAA;IAClC,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAClB,OAAO,CAAC,CAAA;AACV,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,MAAM,4BAA4B,GAAG,IAAI,GAAG,EAA0B,CAAA;IACtE,MAAM,mBAAmB,GAAG,IAAI,GAAG,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ACxB,uBAAuB;QACvB,uBAAuB;QACvB,mBAAmB;QACnB,mBAAmB;QACnB,6BAA6B;QAC7B,0BAA0B;QAC1B,0BAA0B;QAC1B,KAAK;QACL,OAAO;QACP,KAAK;KACN,CAAA;AACH,CAAC"}
@@ -0,0 +1,30 @@
1
+ /**
2
+ * Per-interceptor warmup attempt + success bookkeeping.
3
+ *
4
+ * The plugin used to keep two module-level sets: one for sessions that already
5
+ * attempted a thinking warmup and another for sessions that succeeded. They
6
+ * leaked across plugin lifetimes and across concurrent interceptors. This
7
+ * factory scopes the same sets to a single interceptor; `dispose()` evicts
8
+ * everything so the next interceptor starts clean.
9
+ */
10
+ export interface WarmupState {
11
+ readonly disposed: boolean;
12
+ /**
13
+ * Records an attempt for the given session id. Returns false when the
14
+ * session already succeeded (no further attempts permitted) or when the
15
+ * retry budget is exhausted.
16
+ */
17
+ trackAttempt(sessionId: string): boolean;
18
+ /** Returns the number of tracked attempts for the session. */
19
+ getAttemptCount(sessionId: string): number;
20
+ /** Marks the session as warmed-up; subsequent attempts are rejected. */
21
+ markSuccess(sessionId: string): void;
22
+ /** Drops a single session's attempt counter (used on warmup failure). */
23
+ clearWarmupAttempt(sessionId: string): void;
24
+ /** Drops every session entry. */
25
+ clear(): void;
26
+ /** Marks the instance as torn down; subsequent mutations are no-ops. */
27
+ dispose(): void;
28
+ }
29
+ export declare function createWarmupState(): WarmupState;
30
+ //# sourceMappingURL=warmup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"warmup.d.ts","sourceRoot":"","sources":["../../../../src/plugin/fetch/warmup.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;IAC1B;;;;OAIG;IACH,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAA;IACxC,8DAA8D;IAC9D,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,CAAA;IAC1C,wEAAwE;IACxE,WAAW,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IACpC,yEAAyE;IACzE,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3C,iCAAiC;IACjC,KAAK,IAAI,IAAI,CAAA;IACb,wEAAwE;IACxE,OAAO,IAAI,IAAI,CAAA;CAChB;AAED,wBAAgB,iBAAiB,IAAI,WAAW,CAiE/C"}