@cortexkit/opencode-antigravity-auth 1.1.0 → 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 (379) hide show
  1. package/README.md +225 -569
  2. package/dist/cli.js +4017 -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 +20742 -14586
  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/account-command-oauth.d.ts +34 -0
  38. package/dist/src/plugin/account-command-oauth.d.ts.map +1 -0
  39. package/dist/src/plugin/account-command-oauth.js +156 -0
  40. package/dist/src/plugin/account-command-oauth.js.map +1 -0
  41. package/dist/src/plugin/accounts.d.ts +7 -256
  42. package/dist/src/plugin/accounts.d.ts.map +1 -1
  43. package/dist/src/plugin/accounts.js +31 -1367
  44. package/dist/src/plugin/accounts.js.map +1 -1
  45. package/dist/src/plugin/agy-request-metadata.d.ts +1 -1
  46. package/dist/src/plugin/agy-request-metadata.js +1 -1
  47. package/dist/src/plugin/agy-transport.d.ts +1 -1
  48. package/dist/src/plugin/agy-transport.js +1 -1
  49. package/dist/src/plugin/auth-doctor.d.ts +6 -6
  50. package/dist/src/plugin/auth-doctor.d.ts.map +1 -1
  51. package/dist/src/plugin/auth-doctor.js +74 -66
  52. package/dist/src/plugin/auth-doctor.js.map +1 -1
  53. package/dist/src/plugin/auth-drift.d.ts +4 -4
  54. package/dist/src/plugin/auth-drift.d.ts.map +1 -1
  55. package/dist/src/plugin/auth-drift.js +15 -15
  56. package/dist/src/plugin/auth-drift.js.map +1 -1
  57. package/dist/src/plugin/auth-loader.d.ts +50 -0
  58. package/dist/src/plugin/auth-loader.d.ts.map +1 -0
  59. package/dist/src/plugin/auth-loader.js +225 -0
  60. package/dist/src/plugin/auth-loader.js.map +1 -0
  61. package/dist/src/plugin/auth.d.ts +1 -1
  62. package/dist/src/plugin/auth.js +1 -1
  63. package/dist/src/plugin/background-quota-refresh.d.ts +146 -0
  64. package/dist/src/plugin/background-quota-refresh.d.ts.map +1 -0
  65. package/dist/src/plugin/background-quota-refresh.js +347 -0
  66. package/dist/src/plugin/background-quota-refresh.js.map +1 -0
  67. package/dist/src/plugin/cache/index.d.ts +1 -1
  68. package/dist/src/plugin/cache/index.d.ts.map +1 -1
  69. package/dist/src/plugin/cache/index.js +1 -1
  70. package/dist/src/plugin/cache/index.js.map +1 -1
  71. package/dist/src/plugin/cache/signature-cache.d.ts +1 -1
  72. package/dist/src/plugin/cache/signature-cache.d.ts.map +1 -1
  73. package/dist/src/plugin/cache/signature-cache.js +23 -24
  74. package/dist/src/plugin/cache/signature-cache.js.map +1 -1
  75. package/dist/src/plugin/cache.d.ts +6 -5
  76. package/dist/src/plugin/cache.d.ts.map +1 -1
  77. package/dist/src/plugin/cache.js +21 -7
  78. package/dist/src/plugin/cache.js.map +1 -1
  79. package/dist/src/plugin/catalog.d.ts +23 -0
  80. package/dist/src/plugin/catalog.d.ts.map +1 -0
  81. package/dist/src/plugin/catalog.js +60 -0
  82. package/dist/src/plugin/catalog.js.map +1 -0
  83. package/dist/src/plugin/cli.d.ts +7 -7
  84. package/dist/src/plugin/cli.d.ts.map +1 -1
  85. package/dist/src/plugin/cli.js +62 -55
  86. package/dist/src/plugin/cli.js.map +1 -1
  87. package/dist/src/plugin/command-data.d.ts +329 -0
  88. package/dist/src/plugin/command-data.d.ts.map +1 -0
  89. package/dist/src/plugin/command-data.js +517 -0
  90. package/dist/src/plugin/command-data.js.map +1 -0
  91. package/dist/src/plugin/commands.d.ts +154 -0
  92. package/dist/src/plugin/commands.d.ts.map +1 -0
  93. package/dist/src/plugin/commands.js +746 -0
  94. package/dist/src/plugin/commands.js.map +1 -0
  95. package/dist/src/plugin/config/index.d.ts +2 -2
  96. package/dist/src/plugin/config/index.d.ts.map +1 -1
  97. package/dist/src/plugin/config/index.js +2 -2
  98. package/dist/src/plugin/config/index.js.map +1 -1
  99. package/dist/src/plugin/config/loader.d.ts +1 -1
  100. package/dist/src/plugin/config/loader.d.ts.map +1 -1
  101. package/dist/src/plugin/config/loader.js +18 -16
  102. package/dist/src/plugin/config/loader.js.map +1 -1
  103. package/dist/src/plugin/config/models.d.ts +2 -2
  104. package/dist/src/plugin/config/models.d.ts.map +1 -1
  105. package/dist/src/plugin/config/models.js +1 -1
  106. package/dist/src/plugin/config/models.js.map +1 -1
  107. package/dist/src/plugin/config/operator-settings-schema.d.ts +29 -0
  108. package/dist/src/plugin/config/operator-settings-schema.d.ts.map +1 -0
  109. package/dist/src/plugin/config/operator-settings-schema.js +28 -0
  110. package/dist/src/plugin/config/operator-settings-schema.js.map +1 -0
  111. package/dist/src/plugin/config/schema.d.ts +23 -2
  112. package/dist/src/plugin/config/schema.d.ts.map +1 -1
  113. package/dist/src/plugin/config/schema.js +109 -25
  114. package/dist/src/plugin/config/schema.js.map +1 -1
  115. package/dist/src/plugin/config/updater.d.ts.map +1 -1
  116. package/dist/src/plugin/config/updater.js +15 -15
  117. package/dist/src/plugin/config/updater.js.map +1 -1
  118. package/dist/src/plugin/config/writer.d.ts +34 -0
  119. package/dist/src/plugin/config/writer.d.ts.map +1 -0
  120. package/dist/src/plugin/config/writer.js +81 -0
  121. package/dist/src/plugin/config/writer.js.map +1 -0
  122. package/dist/src/plugin/core/streaming/index.d.ts +1 -1
  123. package/dist/src/plugin/core/streaming/index.d.ts.map +1 -1
  124. package/dist/src/plugin/core/streaming/index.js +1 -1
  125. package/dist/src/plugin/core/streaming/index.js.map +1 -1
  126. package/dist/src/plugin/core/streaming/transformer.d.ts.map +1 -1
  127. package/dist/src/plugin/core/streaming/transformer.js +85 -44
  128. package/dist/src/plugin/core/streaming/transformer.js.map +1 -1
  129. package/dist/src/plugin/core/streaming/types.d.ts.map +1 -1
  130. package/dist/src/plugin/debug.d.ts +10 -3
  131. package/dist/src/plugin/debug.d.ts.map +1 -1
  132. package/dist/src/plugin/debug.js +110 -47
  133. package/dist/src/plugin/debug.js.map +1 -1
  134. package/dist/src/plugin/dependencies.d.ts +129 -0
  135. package/dist/src/plugin/dependencies.d.ts.map +1 -0
  136. package/dist/src/plugin/dependencies.js +107 -0
  137. package/dist/src/plugin/dependencies.js.map +1 -0
  138. package/dist/src/plugin/errors.d.ts +27 -0
  139. package/dist/src/plugin/errors.d.ts.map +1 -1
  140. package/dist/src/plugin/errors.js +29 -3
  141. package/dist/src/plugin/errors.js.map +1 -1
  142. package/dist/src/plugin/event-handler.d.ts +53 -0
  143. package/dist/src/plugin/event-handler.d.ts.map +1 -0
  144. package/dist/src/plugin/event-handler.js +101 -0
  145. package/dist/src/plugin/event-handler.js.map +1 -0
  146. package/dist/src/plugin/fetch/retry-state.d.ts +61 -0
  147. package/dist/src/plugin/fetch/retry-state.d.ts.map +1 -0
  148. package/dist/src/plugin/fetch/retry-state.js +248 -0
  149. package/dist/src/plugin/fetch/retry-state.js.map +1 -0
  150. package/dist/src/plugin/fetch/warmup.d.ts +30 -0
  151. package/dist/src/plugin/fetch/warmup.d.ts.map +1 -0
  152. package/dist/src/plugin/fetch/warmup.js +76 -0
  153. package/dist/src/plugin/fetch/warmup.js.map +1 -0
  154. package/dist/src/plugin/fetch-interceptor.d.ts +59 -0
  155. package/dist/src/plugin/fetch-interceptor.d.ts.map +1 -0
  156. package/dist/src/plugin/fetch-interceptor.js +1399 -0
  157. package/dist/src/plugin/fetch-interceptor.js.map +1 -0
  158. package/dist/src/plugin/fetch-routing.d.ts +26 -0
  159. package/dist/src/plugin/fetch-routing.d.ts.map +1 -0
  160. package/dist/src/plugin/fetch-routing.js +99 -0
  161. package/dist/src/plugin/fetch-routing.js.map +1 -0
  162. package/dist/src/plugin/fingerprint.d.ts +1 -1
  163. package/dist/src/plugin/fingerprint.js +1 -1
  164. package/dist/src/plugin/gemini-dump.d.ts +5 -5
  165. package/dist/src/plugin/gemini-dump.d.ts.map +1 -1
  166. package/dist/src/plugin/gemini-dump.js +109 -55
  167. package/dist/src/plugin/gemini-dump.js.map +1 -1
  168. package/dist/src/plugin/google-search-tool.d.ts +9 -0
  169. package/dist/src/plugin/google-search-tool.d.ts.map +1 -0
  170. package/dist/src/plugin/google-search-tool.js +56 -0
  171. package/dist/src/plugin/google-search-tool.js.map +1 -0
  172. package/dist/src/plugin/image-saver.d.ts.map +1 -1
  173. package/dist/src/plugin/image-saver.js +16 -16
  174. package/dist/src/plugin/image-saver.js.map +1 -1
  175. package/dist/src/plugin/index.d.ts +30 -0
  176. package/dist/src/plugin/index.d.ts.map +1 -0
  177. package/dist/src/plugin/index.js +411 -0
  178. package/dist/src/plugin/index.js.map +1 -0
  179. package/dist/src/plugin/killswitch.d.ts +94 -0
  180. package/dist/src/plugin/killswitch.d.ts.map +1 -0
  181. package/dist/src/plugin/killswitch.js +197 -0
  182. package/dist/src/plugin/killswitch.js.map +1 -0
  183. package/dist/src/plugin/lifecycle.d.ts +40 -0
  184. package/dist/src/plugin/lifecycle.d.ts.map +1 -0
  185. package/dist/src/plugin/lifecycle.js +73 -0
  186. package/dist/src/plugin/lifecycle.js.map +1 -0
  187. package/dist/src/plugin/logger.d.ts +10 -1
  188. package/dist/src/plugin/logger.d.ts.map +1 -1
  189. package/dist/src/plugin/logger.js +38 -12
  190. package/dist/src/plugin/logger.js.map +1 -1
  191. package/dist/src/plugin/logging-utils.d.ts +35 -1
  192. package/dist/src/plugin/logging-utils.d.ts.map +1 -1
  193. package/dist/src/plugin/logging-utils.js +98 -15
  194. package/dist/src/plugin/logging-utils.js.map +1 -1
  195. package/dist/src/plugin/model-registry.d.ts +1 -1
  196. package/dist/src/plugin/model-registry.js +1 -1
  197. package/dist/src/plugin/oauth-login.d.ts +22 -0
  198. package/dist/src/plugin/oauth-login.d.ts.map +1 -0
  199. package/dist/src/plugin/oauth-login.js +37 -0
  200. package/dist/src/plugin/oauth-login.js.map +1 -0
  201. package/dist/src/plugin/oauth-methods.d.ts +42 -0
  202. package/dist/src/plugin/oauth-methods.d.ts.map +1 -0
  203. package/dist/src/plugin/oauth-methods.js +1276 -0
  204. package/dist/src/plugin/oauth-methods.js.map +1 -0
  205. package/dist/src/plugin/operator-settings.d.ts +40 -0
  206. package/dist/src/plugin/operator-settings.d.ts.map +1 -0
  207. package/dist/src/plugin/operator-settings.js +148 -0
  208. package/dist/src/plugin/operator-settings.js.map +1 -0
  209. package/dist/src/plugin/persist-account-pool.d.ts +37 -0
  210. package/dist/src/plugin/persist-account-pool.d.ts.map +1 -0
  211. package/dist/src/plugin/persist-account-pool.js +142 -0
  212. package/dist/src/plugin/persist-account-pool.js.map +1 -0
  213. package/dist/src/plugin/project.d.ts +1 -1
  214. package/dist/src/plugin/project.js +1 -1
  215. package/dist/src/plugin/prompt-context.d.ts.map +1 -1
  216. package/dist/src/plugin/prompt-context.js +11 -11
  217. package/dist/src/plugin/prompt-context.js.map +1 -1
  218. package/dist/src/plugin/quota.d.ts +138 -41
  219. package/dist/src/plugin/quota.d.ts.map +1 -1
  220. package/dist/src/plugin/quota.js +417 -285
  221. package/dist/src/plugin/quota.js.map +1 -1
  222. package/dist/src/plugin/recovery/constants.d.ts.map +1 -1
  223. package/dist/src/plugin/recovery/constants.js +24 -15
  224. package/dist/src/plugin/recovery/constants.js.map +1 -1
  225. package/dist/src/plugin/recovery/index.d.ts +3 -3
  226. package/dist/src/plugin/recovery/index.d.ts.map +1 -1
  227. package/dist/src/plugin/recovery/index.js +3 -3
  228. package/dist/src/plugin/recovery/index.js.map +1 -1
  229. package/dist/src/plugin/recovery/storage.d.ts +1 -1
  230. package/dist/src/plugin/recovery/storage.d.ts.map +1 -1
  231. package/dist/src/plugin/recovery/storage.js +31 -39
  232. package/dist/src/plugin/recovery/storage.js.map +1 -1
  233. package/dist/src/plugin/recovery/types.d.ts +12 -12
  234. package/dist/src/plugin/recovery/types.d.ts.map +1 -1
  235. package/dist/src/plugin/recovery.d.ts +3 -3
  236. package/dist/src/plugin/recovery.d.ts.map +1 -1
  237. package/dist/src/plugin/recovery.js +62 -58
  238. package/dist/src/plugin/recovery.js.map +1 -1
  239. package/dist/src/plugin/refresh-queue.d.ts +5 -2
  240. package/dist/src/plugin/refresh-queue.d.ts.map +1 -1
  241. package/dist/src/plugin/refresh-queue.js +37 -15
  242. package/dist/src/plugin/refresh-queue.js.map +1 -1
  243. package/dist/src/plugin/request-helpers.d.ts +1 -1
  244. package/dist/src/plugin/request-helpers.d.ts.map +1 -1
  245. package/dist/src/plugin/request-helpers.js +451 -352
  246. package/dist/src/plugin/request-helpers.js.map +1 -1
  247. package/dist/src/plugin/request.d.ts +7 -7
  248. package/dist/src/plugin/request.d.ts.map +1 -1
  249. package/dist/src/plugin/request.js +622 -384
  250. package/dist/src/plugin/request.js.map +1 -1
  251. package/dist/src/plugin/rotation.d.ts +1 -168
  252. package/dist/src/plugin/rotation.d.ts.map +1 -1
  253. package/dist/src/plugin/rotation.js +1 -327
  254. package/dist/src/plugin/rotation.js.map +1 -1
  255. package/dist/src/plugin/search.d.ts.map +1 -1
  256. package/dist/src/plugin/search.js +39 -35
  257. package/dist/src/plugin/search.js.map +1 -1
  258. package/dist/src/plugin/server.d.ts +1 -1
  259. package/dist/src/plugin/server.d.ts.map +1 -1
  260. package/dist/src/plugin/server.js +42 -37
  261. package/dist/src/plugin/server.js.map +1 -1
  262. package/dist/src/plugin/session-context.d.ts +2 -1
  263. package/dist/src/plugin/session-context.d.ts.map +1 -1
  264. package/dist/src/plugin/session-context.js +11 -7
  265. package/dist/src/plugin/session-context.js.map +1 -1
  266. package/dist/src/plugin/storage.d.ts +59 -120
  267. package/dist/src/plugin/storage.d.ts.map +1 -1
  268. package/dist/src/plugin/storage.js +140 -485
  269. package/dist/src/plugin/storage.js.map +1 -1
  270. package/dist/src/plugin/stores/signature-store.d.ts.map +1 -1
  271. package/dist/src/plugin/stores/signature-store.js.map +1 -1
  272. package/dist/src/plugin/thinking-recovery.d.ts.map +1 -1
  273. package/dist/src/plugin/thinking-recovery.js +35 -33
  274. package/dist/src/plugin/thinking-recovery.js.map +1 -1
  275. package/dist/src/plugin/token.d.ts +2 -2
  276. package/dist/src/plugin/token.d.ts.map +1 -1
  277. package/dist/src/plugin/token.js +30 -21
  278. package/dist/src/plugin/token.js.map +1 -1
  279. package/dist/src/plugin/transform/cross-model-sanitizer.d.ts +1 -1
  280. package/dist/src/plugin/transform/cross-model-sanitizer.js +1 -1
  281. package/dist/src/plugin/transform/index.d.ts +1 -1
  282. package/dist/src/plugin/transform/index.js +1 -1
  283. package/dist/src/plugin/transform/model-resolver.d.ts +1 -1
  284. package/dist/src/plugin/transform/model-resolver.js +1 -1
  285. package/dist/src/plugin/transform/types.d.ts +1 -1
  286. package/dist/src/plugin/transform/types.js +1 -1
  287. package/dist/src/plugin/types.d.ts +25 -69
  288. package/dist/src/plugin/types.d.ts.map +1 -1
  289. package/dist/src/plugin/ui/ansi.d.ts.map +1 -1
  290. package/dist/src/plugin/ui/ansi.js.map +1 -1
  291. package/dist/src/plugin/ui/auth-menu.d.ts +1 -1
  292. package/dist/src/plugin/ui/auth-menu.d.ts.map +1 -1
  293. package/dist/src/plugin/ui/auth-menu.js +84 -35
  294. package/dist/src/plugin/ui/auth-menu.js.map +1 -1
  295. package/dist/src/plugin/ui/confirm.d.ts.map +1 -1
  296. package/dist/src/plugin/ui/confirm.js.map +1 -1
  297. package/dist/src/plugin/ui/model-status.d.ts +3 -3
  298. package/dist/src/plugin/ui/model-status.d.ts.map +1 -1
  299. package/dist/src/plugin/ui/model-status.js +3 -3
  300. package/dist/src/plugin/ui/model-status.js.map +1 -1
  301. package/dist/src/plugin/ui/quota-status.d.ts +4 -4
  302. package/dist/src/plugin/ui/quota-status.d.ts.map +1 -1
  303. package/dist/src/plugin/ui/quota-status.js +49 -49
  304. package/dist/src/plugin/ui/quota-status.js.map +1 -1
  305. package/dist/src/plugin/ui/select.d.ts.map +1 -1
  306. package/dist/src/plugin/ui/select.js +22 -12
  307. package/dist/src/plugin/ui/select.js.map +1 -1
  308. package/dist/src/plugin/version.d.ts +1 -1
  309. package/dist/src/plugin/version.js +1 -1
  310. package/dist/src/rpc/notifications.d.ts +6 -0
  311. package/dist/src/rpc/notifications.d.ts.map +1 -0
  312. package/dist/src/rpc/notifications.js +46 -0
  313. package/dist/src/rpc/notifications.js.map +1 -0
  314. package/dist/src/rpc/port-file.d.ts +13 -0
  315. package/dist/src/rpc/port-file.d.ts.map +1 -0
  316. package/dist/src/rpc/port-file.js +109 -0
  317. package/dist/src/rpc/port-file.js.map +1 -0
  318. package/dist/src/rpc/protocol.d.ts +22 -0
  319. package/dist/src/rpc/protocol.d.ts.map +1 -0
  320. package/dist/src/rpc/protocol.js +1 -0
  321. package/dist/src/rpc/protocol.js.map +1 -0
  322. package/dist/src/rpc/rpc-client.d.ts +10 -0
  323. package/dist/src/rpc/rpc-client.d.ts.map +1 -0
  324. package/dist/src/rpc/rpc-client.js +58 -0
  325. package/dist/src/rpc/rpc-client.js.map +1 -0
  326. package/dist/src/rpc/rpc-dir.d.ts +4 -0
  327. package/dist/src/rpc/rpc-dir.d.ts.map +1 -0
  328. package/dist/src/rpc/rpc-dir.js +19 -0
  329. package/dist/src/rpc/rpc-dir.js.map +1 -0
  330. package/dist/src/rpc/rpc-server.d.ts +13 -0
  331. package/dist/src/rpc/rpc-server.d.ts.map +1 -0
  332. package/dist/src/rpc/rpc-server.js +231 -0
  333. package/dist/src/rpc/rpc-server.js.map +1 -0
  334. package/dist/src/sidebar-state.d.ts +357 -0
  335. package/dist/src/sidebar-state.d.ts.map +1 -0
  336. package/dist/src/sidebar-state.js +680 -0
  337. package/dist/src/sidebar-state.js.map +1 -0
  338. package/dist/src/tui/command-dialogs.d.ts +61 -0
  339. package/dist/src/tui/command-dialogs.d.ts.map +1 -0
  340. package/dist/src/tui/command-dialogs.js +595 -0
  341. package/dist/src/tui/command-dialogs.js.map +1 -0
  342. package/dist/src/tui/file-logger.d.ts +41 -0
  343. package/dist/src/tui/file-logger.d.ts.map +1 -0
  344. package/dist/src/tui/file-logger.js +114 -0
  345. package/dist/src/tui/file-logger.js.map +1 -0
  346. package/dist/src/tui-preferences.d.ts +40 -0
  347. package/dist/src/tui-preferences.d.ts.map +1 -0
  348. package/dist/src/tui-preferences.js +328 -0
  349. package/dist/src/tui-preferences.js.map +1 -0
  350. package/dist/src/tui.d.ts +68 -0
  351. package/dist/src/tui.d.ts.map +1 -0
  352. package/dist/src/tui.js +697 -0
  353. package/dist/src/tui.js.map +1 -0
  354. package/package.json +46 -22
  355. package/src/plugin/command-data.ts +931 -0
  356. package/src/rpc/port-file.ts +143 -0
  357. package/src/rpc/protocol.ts +31 -0
  358. package/src/rpc/rpc-client.ts +102 -0
  359. package/src/rpc/rpc-dir.ts +24 -0
  360. package/src/sidebar-state.ts +991 -0
  361. package/src/tui/command-dialogs.tsx +832 -0
  362. package/src/tui/entry.mjs +74 -0
  363. package/src/tui/file-logger.ts +145 -0
  364. package/src/tui-compiled/plugin/command-data.ts +931 -0
  365. package/src/tui-compiled/rpc/port-file.ts +143 -0
  366. package/src/tui-compiled/rpc/protocol.ts +31 -0
  367. package/src/tui-compiled/rpc/rpc-client.ts +102 -0
  368. package/src/tui-compiled/rpc/rpc-dir.ts +24 -0
  369. package/src/tui-compiled/sidebar-state.ts +991 -0
  370. package/src/tui-compiled/tui/command-dialogs.tsx +779 -0
  371. package/src/tui-compiled/tui/file-logger.ts +145 -0
  372. package/src/tui-compiled/tui-preferences.ts +416 -0
  373. package/src/tui-compiled/tui.tsx +1193 -0
  374. package/src/tui-preferences.ts +416 -0
  375. package/src/tui.tsx +1171 -0
  376. package/dist/src/plugin.d.ts +0 -48
  377. package/dist/src/plugin.d.ts.map +0 -1
  378. package/dist/src/plugin.js +0 -3311
  379. package/dist/src/plugin.js.map +0 -1
@@ -0,0 +1,697 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "@opentui/solid/jsx-runtime";
2
+ /** @jsxImportSource @opentui/solid */
3
+ /**
4
+ * Read-only OpenTUI sidebar for the Antigravity plugin.
5
+ *
6
+ * Mirrors the fleet sibling layout (see `anthropic-auth-live` /
7
+ * `openai-auth-live` `packages/opencode/src/tui.tsx`): a single bordered
8
+ * column with a labelled header badge, a Quota section that lists one
9
+ * `AccountBlock` per visible account, a Routing section that surfaces the
10
+ * most recent session route, and a Health section that only appears when
11
+ * something is wrong. The Antigravity data model is richer than the
12
+ * Claude/Codex one (per-account Gemini + Non-Gemini quota pools, a health
13
+ * score, and per-session routing decisions), so the fleet components are
14
+ * adapted rather than copied verbatim:
15
+ *
16
+ * - `QuotaRow` reads `remainingPercent + resetAt` from the Antigravity
17
+ * `SidebarQuotaEntry` shape and colors via `quotaTone` (remaining
18
+ * threshold) instead of `usageTone` (used threshold).
19
+ * - `AccountBlock` derives its status word (`active` / `idle` /
20
+ * `cooling` / `off` / `blocked`) from the Antigravity account state and
21
+ * surfaces health as a muted secondary line rather than a top-level
22
+ * bar — fleet parity for "Quota first, health second".
23
+ * - `Routing` resolves to a single `Route` `StatRow` carrying the most
24
+ * recent `activeRouting` entry, since Antigravity does not maintain a
25
+ * per-session sidebar state alongside the slot-rendered tree.
26
+ *
27
+ * Hard rules for this file:
28
+ *
29
+ * - NO direct writes to the host terminal anywhere in the render path.
30
+ * The host terminal is the frame buffer; one stray byte corrupts every
31
+ * subsequent cell. Errors flow through `createTuiFileLogger()`.
32
+ * - NO imports from `./plugin/storage`, `./plugin/accounts`, OAuth code,
33
+ * or anything that touches tokens.
34
+ * - The component uses Solid's `onCleanup` to release the polling timer
35
+ * on unmount so a route change can never leak an interval.
36
+ */
37
+ import { readFileSync } from 'node:fs';
38
+ import { dirname, join } from 'node:path';
39
+ import { fileURLToPath } from 'node:url';
40
+ import { createSlot } from '@opentui/solid';
41
+ import { createEffect, createSignal, For, onCleanup, onMount, Show, } from 'solid-js';
42
+ import { createRpcClient } from './rpc/rpc-client';
43
+ import { getRpcDir } from './rpc/rpc-dir';
44
+ import { readSidebarState, } from './sidebar-state';
45
+ import { openCommandDialog } from './tui/command-dialogs';
46
+ import { createTuiFileLogger } from './tui/file-logger';
47
+ import { computeEffectiveOrder, DEFAULT_PREFS, DEFAULT_SLOT_ORDER, PLUGIN_KEY, queueTuiPreferenceUpdate, readTuiPreferencesFile, resolveAntigravityAuthPrefs, watchTuiPreferences, } from './tui-preferences';
48
+ const ID = 'cortexkit.antigravity-auth';
49
+ const POLL_INTERVAL_MS = 2000;
50
+ const RPC_POLL_MS = 500;
51
+ const SINGLE_BORDER = { type: 'single' };
52
+ // Read package metadata from either the raw src/ entry or its generated
53
+ // src/tui-compiled/ counterpart. Avoid a JSON import because package.json sits
54
+ // outside the declaration build's rootDir.
55
+ const PLUGIN_VERSION = (() => {
56
+ const here = dirname(fileURLToPath(import.meta.url));
57
+ for (const packageFile of [
58
+ join(here, '..', 'package.json'),
59
+ join(here, '..', '..', 'package.json'),
60
+ ]) {
61
+ try {
62
+ const raw = readFileSync(packageFile, 'utf8');
63
+ const version = JSON.parse(raw).version;
64
+ if (version)
65
+ return version;
66
+ }
67
+ catch {
68
+ // Try the path for the other TUI entry layout.
69
+ }
70
+ }
71
+ return '';
72
+ })();
73
+ // Module-scoped state — TEST ISOLATION CONTRACT:
74
+ //
75
+ // `rpcPollStarted`, notification cursor/deduplication state, `rpcInFlight`, and the lazy
76
+ // `sidebarController` below persist across tests via the cached ES
77
+ // module Bun loads once per `--isolate` file. Tests must NOT assert
78
+ // fresh-process behaviour from these variables — by the time the first
79
+ // `startRpcNotificationPolling` runs, all four carry stale values from
80
+ // prior tests in the same file. Test isolation comes from:
81
+ // 1. fresh-importing `tui.tsx` via a cache-busted dynamic `import`
82
+ // so the module re-evaluates with fresh module-scoped bindings, and
83
+ // 2. constructing a fresh `SidebarController` via
84
+ // `createSidebarController(prefs)` and passing it through
85
+ // `SidebarPanel.props.controller` — never through
86
+ // `getSidebarController()`, which lazily seeds the module-scoped
87
+ // singleton.
88
+ let rpcPollStarted = false;
89
+ const notificationCursorBySession = new Map();
90
+ const dispatchedNotificationIds = new Set();
91
+ let rpcInFlight = false;
92
+ const GLOBAL_NOTIFICATION_CURSOR = '__global__';
93
+ const MAX_NOTIFICATION_CURSORS = 256;
94
+ const QUOTA_LABELS = {
95
+ gemini: 'Gm',
96
+ 'non-gemini': 'NG',
97
+ };
98
+ const QUOTA_ORDER = ['gemini', 'non-gemini'];
99
+ const WINDOW_GUTTER = {
100
+ weekly: '7d',
101
+ '5h': '5h',
102
+ };
103
+ const FALLBACK_THEME = {
104
+ primary: '#3b82f6',
105
+ secondary: '#a855f7',
106
+ accent: '#7c3aed',
107
+ error: '#ef4444',
108
+ warning: '#eab308',
109
+ success: '#22c55e',
110
+ info: '#0ea5e9',
111
+ text: '#e5e7eb',
112
+ textMuted: '#6b7280',
113
+ selectedListItemText: '#ffffff',
114
+ background: '#0b0d12',
115
+ backgroundPanel: '#11131a',
116
+ backgroundElement: '#1a1d27',
117
+ backgroundMenu: '#1a1d27',
118
+ border: '#2a2d3a',
119
+ borderActive: '#7c3aed',
120
+ borderSubtle: '#2a2d3a',
121
+ diffAdded: '#22c55e',
122
+ diffRemoved: '#ef4444',
123
+ diffContext: '#6b7280',
124
+ diffHunkHeader: '#7c3aed',
125
+ diffHighlightAdded: '#166534',
126
+ diffHighlightRemoved: '#7f1d1d',
127
+ diffAddedBg: '#0a1f12',
128
+ diffRemovedBg: '#1f0a0a',
129
+ diffContextBg: '#0b0d12',
130
+ diffLineNumber: '#4b5563',
131
+ diffAddedLineNumberBg: '#0a1f12',
132
+ diffRemovedLineNumberBg: '#1f0a0a',
133
+ markdownText: '#e5e7eb',
134
+ markdownHeading: '#7c3aed',
135
+ markdownLink: '#3b82f6',
136
+ markdownLinkText: '#60a5fa',
137
+ markdownCode: '#22c55e',
138
+ markdownBlockQuote: '#6b7280',
139
+ markdownEmph: '#eab308',
140
+ markdownStrong: '#7c3aed',
141
+ markdownHorizontalRule: '#2a2d3a',
142
+ markdownListItem: '#7c3aed',
143
+ markdownListEnumeration: '#a855f7',
144
+ markdownImage: '#3b82f6',
145
+ markdownImageText: '#60a5fa',
146
+ markdownCodeBlock: '#11131a',
147
+ syntaxComment: '#6b7280',
148
+ syntaxKeyword: '#a855f7',
149
+ syntaxFunction: '#3b82f6',
150
+ syntaxVariable: '#e5e7eb',
151
+ syntaxString: '#22c55e',
152
+ syntaxNumber: '#eab308',
153
+ syntaxType: '#7c3aed',
154
+ syntaxOperator: '#e5e7eb',
155
+ syntaxPunctuation: '#6b7280',
156
+ thinkingOpacity: 0.6,
157
+ };
158
+ // Mirror the fleet siblings' tone chain: every tone falls through to a
159
+ // sibling token, so a sparse custom theme still renders readably.
160
+ function toneColor(theme, tone) {
161
+ switch (tone) {
162
+ case 'ok':
163
+ return theme.success ?? theme.accent;
164
+ case 'warn':
165
+ return theme.warning ?? theme.accent;
166
+ case 'err':
167
+ return theme.error ?? theme.accent;
168
+ case 'muted':
169
+ return theme.textMuted ?? theme.text;
170
+ case 'accent':
171
+ return theme.accent ?? theme.text;
172
+ default:
173
+ return theme.text;
174
+ }
175
+ }
176
+ function quotaTone(usedPct, appearance) {
177
+ if (usedPct < appearance.warnThreshold)
178
+ return 'ok';
179
+ if (usedPct < appearance.errorThreshold)
180
+ return 'warn';
181
+ return 'err';
182
+ }
183
+ function quotaBarSegments(usedPct, appearance) {
184
+ const width = appearance.barWidth;
185
+ const usedCells = Math.max(0, Math.min(Math.round((usedPct / 100) * width), width));
186
+ const tone = quotaTone(usedPct, appearance);
187
+ return [
188
+ { text: appearance.barFilledChar.repeat(usedCells), tone },
189
+ { text: appearance.barEmptyChar.repeat(width - usedCells), tone },
190
+ ].filter((segment) => segment.text.length > 0);
191
+ }
192
+ const EMPTY_STATE = {
193
+ version: 1,
194
+ checkedAt: 0,
195
+ accounts: [],
196
+ activeRouting: {},
197
+ routingAuthoritative: false,
198
+ };
199
+ function resolveLogger(logger) {
200
+ if (logger)
201
+ return logger;
202
+ try {
203
+ return createTuiFileLogger();
204
+ }
205
+ catch {
206
+ // Fall back to a stub that drops everything — the sidebar must still
207
+ // render even if file logging cannot be initialized.
208
+ return noopLogger();
209
+ }
210
+ }
211
+ function noopLogger() {
212
+ const drop = () => undefined;
213
+ return {
214
+ debug: drop,
215
+ info: drop,
216
+ warn: drop,
217
+ error: drop,
218
+ getLogPath: () => undefined,
219
+ };
220
+ }
221
+ // Module-scoped controller singleton, initialized at plugin startup. The
222
+ // watcher is intentionally never disposed — collapse/prefs state survives
223
+ // sidebar remounts (route changes) for the lifetime of the TUI process,
224
+ // mirroring the fleet siblings.
225
+ //
226
+ // TEST ISOLATION: this singleton, like `rpcPollStarted` above, persists
227
+ // across tests via the cached ES module. Tests construct a controller
228
+ // via `createSidebarController(prefs)` and pass it through
229
+ // `SidebarPanel.props.controller` — they MUST NOT rely on this lazy
230
+ // singleton for isolation. See the block above for the full contract.
231
+ let sidebarController = null;
232
+ // The TUI may unmount and remount sidebar_content when the user switches
233
+ // views. A remount re-runs the component body, so any signal created inside
234
+ // the component would reset to its seed. The controller lives in the plugin
235
+ // closure (process lifetime) and owns the durable prefs/collapse signals
236
+ // plus the single shared watcher subscription, so collapse and live pref
237
+ // reloads survive the remount.
238
+ //
239
+ // Exported so tests can construct a controller with a controlled initial
240
+ // prefs snapshot without touching the module-scoped singleton.
241
+ export function createSidebarController(initialPrefs) {
242
+ const [prefs, setPrefs] = createSignal(initialPrefs);
243
+ const seedCollapsed = initialPrefs.rememberCollapsed && initialPrefs.collapsed != null
244
+ ? initialPrefs.collapsed
245
+ : initialPrefs.startCollapsed;
246
+ const [collapsed, setCollapsed] = createSignal(seedCollapsed);
247
+ let lastPersistedCollapsed = initialPrefs.collapsed;
248
+ let lastApplied = JSON.stringify(initialPrefs);
249
+ // The watcher lives for the plugin/process lifetime — it is intentionally
250
+ // never disposed. Collapse guard mirrors the race-fix in toggleCollapsed:
251
+ // lastPersistedCollapsed is advanced only once our own write lands, so
252
+ // watcher echoes of the previous persisted value are rejected by the
253
+ // `!==` check and cannot revert a user click.
254
+ watchTuiPreferences(() => {
255
+ void (async () => {
256
+ const next = resolveAntigravityAuthPrefs(await readTuiPreferencesFile());
257
+ const serialized = JSON.stringify(next);
258
+ if (serialized === lastApplied)
259
+ return;
260
+ lastApplied = serialized;
261
+ setPrefs(next);
262
+ if (next.rememberCollapsed &&
263
+ next.collapsed != null &&
264
+ next.collapsed !== lastPersistedCollapsed) {
265
+ lastPersistedCollapsed = next.collapsed;
266
+ setCollapsed(next.collapsed);
267
+ }
268
+ })();
269
+ });
270
+ function toggleCollapsed() {
271
+ const next = !collapsed();
272
+ setCollapsed(next);
273
+ if (prefs().rememberCollapsed) {
274
+ void queueTuiPreferenceUpdate(PLUGIN_KEY, ['collapsed'], next).then(() => {
275
+ lastPersistedCollapsed = next;
276
+ });
277
+ }
278
+ }
279
+ return { prefs, collapsed, toggleCollapsed };
280
+ }
281
+ // Lazy module-scoped accessor used by the plugin entry. Tests should NOT go
282
+ // through this — they construct their own controller via createSidebarController
283
+ // and pass it via SidebarPanelProps.controller.
284
+ function getSidebarController() {
285
+ if (!sidebarController) {
286
+ sidebarController = createSidebarController(DEFAULT_PREFS);
287
+ }
288
+ return sidebarController;
289
+ }
290
+ // --- Shared helpers (fleet shape, antigravity data) ------------------------
291
+ function clamp(value, min, max) {
292
+ if (value < min)
293
+ return min;
294
+ if (value > max)
295
+ return max;
296
+ return value;
297
+ }
298
+ // Render a "reset in Nm/Nh/NdNh" string from an epoch-ms reset time.
299
+ // Empty string when no resetAt is cached. The fleet's `formatResetIn`
300
+ // reads ISO strings; Antigravity persists resetAt as a numeric epoch, so
301
+ // the wrapper adapts to that without changing the shape of the output.
302
+ function formatResetIn(resetAt, now) {
303
+ if (!resetAt)
304
+ return '';
305
+ const ms = resetAt - now();
306
+ if (ms <= 0)
307
+ return 'now';
308
+ const mins = Math.floor(ms / 60_000);
309
+ if (mins < 60)
310
+ return `${mins}m`;
311
+ const hrs = Math.floor(mins / 60);
312
+ if (hrs < 24) {
313
+ const rm = mins % 60;
314
+ return rm > 0 ? `${hrs}h${rm}m` : `${hrs}h`;
315
+ }
316
+ const days = Math.floor(hrs / 24);
317
+ const rh = hrs % 24;
318
+ return rh > 0 ? `${days}d${rh}h` : `${days}d`;
319
+ }
320
+ function formatError(value) {
321
+ if (value instanceof Error)
322
+ return value.message;
323
+ try {
324
+ return JSON.stringify(value);
325
+ }
326
+ catch {
327
+ return String(value);
328
+ }
329
+ }
330
+ // --- Fleet components (adapted to antigravity data) ------------------------
331
+ // Section header — fleet pattern: bold title, themed text color, top margin
332
+ // for vertical breathing room between sections.
333
+ function SectionHeader(props) {
334
+ return (_jsx("box", { width: '100%', marginTop: 1, children: _jsx("text", { fg: toneColor(props.theme(), 'text'), children: _jsx("b", { children: props.title }) }) }));
335
+ }
336
+ // Fleet StatRow: muted label left, value (optionally tone-tinted, bold)
337
+ // right. Mirrors the layout the Claude/Codex sidebars use for routing
338
+ // rows, plan rows, and "resets N" rows.
339
+ function StatRow(props) {
340
+ return (_jsxs("box", { width: '100%', flexDirection: 'row', justifyContent: 'space-between', children: [_jsx("text", { fg: props.theme().textMuted, children: props.label }), _jsx("text", { fg: toneColor(props.theme(), props.tone ?? 'text'), children: _jsx("b", { children: props.value }) })] }));
341
+ }
342
+ // Fleet CollapsedRow: muted label left, caller-supplied value right. Used
343
+ // for the collapsed sidebar view; the Antigravity adapter renders one
344
+ // CollapsedRow per visible account (Claude's sibling collapses to a
345
+ // single primary-quota line, but Antigravity's multi-quota model fits a
346
+ // per-account row better when the sidebar is collapsed).
347
+ function CollapsedRow(props) {
348
+ return (_jsxs("box", { width: '100%', flexDirection: 'row', justifyContent: 'space-between', children: [_jsx("text", { fg: props.theme().textMuted, children: props.label }), props.children] }));
349
+ }
350
+ // Fleet QuotaRow, adapted to Antigravity's `remainingPercent + resetAt`
351
+ // shape. The left group stacks label + bar + pct in fixed columns so
352
+ // bars line up across rows; the right group carries the reset countdown
353
+ // when the plugin has cached a reset time. Tone is read off the
354
+ // remaining percentage via the antigravity threshold rules — the fleet's
355
+ // `usageTone` would invert the polarity (healthy = high remaining vs
356
+ // healthy = low used), so we keep the antigravity-local `quotaTone`.
357
+ function QuotaRow(props) {
358
+ const used = () => props.entry ? 100 - clamp(props.entry.remainingPercent, 0, 100) : null;
359
+ const reset = () => props.entry ? formatResetIn(props.entry.resetAt, props.now) : '';
360
+ return (_jsx(Show, { when: used() != null, fallback: _jsxs("box", { width: '100%', flexDirection: 'row', justifyContent: 'space-between', children: [_jsx("text", { fg: props.theme().textMuted, children: props.label.padEnd(5) }), _jsx("text", { fg: props.theme().textMuted, children: '\u2014' })] }), children: _jsxs("box", { width: '100%', flexDirection: 'row', justifyContent: 'space-between', children: [_jsxs("box", { flexDirection: 'row', children: [_jsx("text", { width: 5, flexShrink: 0, fg: props.theme().textMuted, children: props.label }), _jsx("box", { width: props.appearance.barWidth, flexShrink: 0, flexDirection: 'row', children: _jsx(For, { each: quotaBarSegments(used() ?? 0, props.appearance), children: (segment) => (_jsx("text", { fg: toneColor(props.theme(), segment.tone), children: segment.text })) }) }), _jsx("text", { fg: toneColor(props.theme(), quotaTone(used() ?? 0, props.appearance)), children: ` ${String(Math.round(used() ?? 0)).padStart(3)}%` })] }), _jsx(Show, { when: reset(), children: _jsx("text", { fg: props.theme().textMuted, children: reset() }) })] }) }));
361
+ }
362
+ // Fleet AccountBlock, adapted to Antigravity's per-account data. Header
363
+ // row is account label (left) + status word (right). The body renders one
364
+ // QuotaRow per present quota group in the fleet's stable order, then a
365
+ // muted secondary line with the account's health score and, when
366
+ // relevant, a cooldown countdown. Status word priorities (first match
367
+ // wins):
368
+ // - `off` when the account is disabled
369
+ // - `cooling` when cooldownUntil is still in the future
370
+ // - `active` when current === true
371
+ // - `idle` for the fallback (current === false) case
372
+ function AccountBlock(props) {
373
+ const active = () => props.active ?? props.account.current;
374
+ const statusWord = () => {
375
+ if (!props.account.enabled)
376
+ return 'off';
377
+ const cd = props.account.cooldownUntil;
378
+ if (typeof cd === 'number' && cd > props.now())
379
+ return 'cooling';
380
+ return active() ? 'active' : 'idle';
381
+ };
382
+ const statusTone = () => {
383
+ if (!props.account.enabled)
384
+ return 'muted';
385
+ const cd = props.account.cooldownUntil;
386
+ if (typeof cd === 'number' && cd > props.now())
387
+ return 'warn';
388
+ return active() ? 'ok' : 'muted';
389
+ };
390
+ const cooldownMs = () => {
391
+ const cd = props.account.cooldownUntil;
392
+ if (typeof cd !== 'number')
393
+ return 0;
394
+ return Math.max(0, cd - props.now());
395
+ };
396
+ const healthText = () => {
397
+ const base = `health ${Math.round(clamp(props.account.health, 0, 100))}`;
398
+ return cooldownMs() > 0
399
+ ? `${base} · cooling ${formatWait(cooldownMs())}`
400
+ : base;
401
+ };
402
+ return (_jsxs("box", { width: '100%', flexDirection: 'column', marginTop: props.marginTop ?? 0, children: [_jsxs("box", { width: '100%', flexDirection: 'row', justifyContent: 'space-between', children: [_jsx("text", { fg: props.theme().text, children: _jsx("b", { children: props.account.label }) }), _jsx("text", { fg: toneColor(props.theme(), statusTone()), children: _jsx("b", { children: statusWord() }) })] }), _jsx(For, { each: QUOTA_ORDER, children: (key) => {
403
+ const poolEntry = props.account.quota[key];
404
+ const windows = poolEntry?.windows;
405
+ // Legacy: no windows array — render a single row with the pool label.
406
+ const hasWindows = windows && windows.length > 0;
407
+ if (!hasWindows) {
408
+ return (_jsx(QuotaRow, { theme: props.theme, appearance: props.appearance, label: QUOTA_LABELS[key], entry: poolEntry, now: props.now }));
409
+ }
410
+ return (_jsx(_Fragment, { children: windows.map((w) => (_jsx(QuotaRow, { theme: props.theme, appearance: props.appearance, label: `${QUOTA_LABELS[key]} ${WINDOW_GUTTER[w.window] ?? w.window}`, entry: {
411
+ remainingPercent: w.remainingPercent,
412
+ resetAt: w.resetAt,
413
+ }, now: props.now }))) }));
414
+ } }), _jsx("box", { width: '100%', flexDirection: 'row', children: _jsx("text", { fg: props.theme().textMuted, children: ` ${healthText()}` }) })] }));
415
+ }
416
+ function formatWait(ms) {
417
+ const seconds = Math.ceil(ms / 1000);
418
+ if (seconds < 60)
419
+ return `${seconds}s`;
420
+ const minutes = Math.floor(seconds / 60);
421
+ const remaining = seconds % 60;
422
+ return remaining > 0 ? `${minutes}m ${remaining}s` : `${minutes}m`;
423
+ }
424
+ export function resolveQuotaDialogActiveId(state, sessionId) {
425
+ return ((sessionId ? state.activeRouting[sessionId]?.accountId : undefined) ??
426
+ state.accounts.find((account) => account.current)?.id);
427
+ }
428
+ export function QuotaDialogContent(props) {
429
+ const prefs = props.controller.prefs;
430
+ const [state, setState] = createSignal(EMPTY_STATE);
431
+ const refresh = () => {
432
+ setState(readSidebarState());
433
+ };
434
+ createEffect(() => {
435
+ const timer = setInterval(refresh, prefs().pollMs);
436
+ onCleanup(() => clearInterval(timer));
437
+ });
438
+ setTimeout(refresh, 0);
439
+ const theme = () => props.api.theme.current;
440
+ const visibleAccounts = () => {
441
+ if (prefs().sections.fallbackAccounts)
442
+ return state().accounts;
443
+ return state().accounts.filter((account) => account.current);
444
+ };
445
+ const activeId = () => resolveQuotaDialogActiveId(state(), props.sessionId);
446
+ return (_jsx("box", { flexDirection: 'column', padding: 2, width: '100%', alignItems: 'center', children: _jsxs("box", { flexDirection: 'column', width: 58, children: [_jsx("box", { width: '100%', justifyContent: 'center', marginBottom: 1, children: _jsx("text", { fg: theme().text, children: _jsx("b", { children: "Antigravity Quota" }) }) }), _jsx(For, { each: visibleAccounts(), children: (account, index) => (_jsx(AccountBlock, { theme: theme, appearance: prefs().appearance, account: account, active: activeId() === account.id, now: () => Date.now(), marginTop: index() === 0 ? 0 : 1 })) })] }) }));
447
+ }
448
+ // --- SidebarPanel ----------------------------------------------------------
449
+ export function SidebarPanel(props) {
450
+ const logger = resolveLogger(props.logger);
451
+ const now = props.now ?? (() => Date.now());
452
+ const pollMs = props.pollIntervalMs ?? POLL_INTERVAL_MS;
453
+ const controller = props.controller ?? getSidebarController();
454
+ const collapsed = controller.collapsed;
455
+ const prefs = controller.prefs;
456
+ // Live host theme — falls back to a sensible dark palette when the host
457
+ // does not expose one. Solid tracks `theme()` so a theme switch re-renders
458
+ // every styled span/border without a manual subscription.
459
+ const theme = () => props.theme?.() ?? FALLBACK_THEME;
460
+ const [state, setState] = createSignal({
461
+ loaded: EMPTY_STATE,
462
+ lastReadAt: 0,
463
+ lastError: null,
464
+ });
465
+ const refresh = () => {
466
+ try {
467
+ const loaded = readSidebarState(props.stateFile);
468
+ setState({
469
+ loaded,
470
+ lastReadAt: now(),
471
+ lastError: null,
472
+ });
473
+ }
474
+ catch (error) {
475
+ logger.warn('sidebar-poll-failed', { error: formatError(error) });
476
+ setState((prev) => ({
477
+ ...prev,
478
+ lastReadAt: now(),
479
+ lastError: formatError(error),
480
+ }));
481
+ }
482
+ };
483
+ onMount(() => {
484
+ refresh();
485
+ const interval = setInterval(refresh, pollMs);
486
+ onCleanup(() => clearInterval(interval));
487
+ });
488
+ const hasData = () => state().loaded.accounts.length > 0;
489
+ const backoffActive = () => {
490
+ const until = state().loaded.quotaBackoffUntil;
491
+ return typeof until === 'number' && until > now();
492
+ };
493
+ const lastError = () => state().lastError ?? state().loaded.lastError;
494
+ const degraded = () => backoffActive() || !!lastError();
495
+ // Honors sections.fallbackAccounts. Both the expanded (AccountBlock list)
496
+ // and the collapsed (CollapsedRow list) paths use the same filter so the
497
+ // user sees the same account set in either mode.
498
+ const visibleAccounts = () => {
499
+ const showFallback = prefs().sections.fallbackAccounts;
500
+ if (showFallback)
501
+ return state().loaded.accounts;
502
+ return state().loaded.accounts.filter((account) => account.current);
503
+ };
504
+ const currentRoute = () => {
505
+ const routes = state().loaded.activeRouting;
506
+ const entry = props.sessionId
507
+ ? routes[props.sessionId]
508
+ : Object.values(routes).sort((a, b) => b.updatedAt - a.updatedAt)[0];
509
+ if (!entry)
510
+ return null;
511
+ return {
512
+ strategy: entry.strategy,
513
+ family: entry.modelFamily,
514
+ style: entry.headerStyle,
515
+ };
516
+ };
517
+ // Header badge: ▼/▶ {label}. The fleet shows the version string on the
518
+ // right when no degraded state is present; the antigravity adapter keeps
519
+ // that right-alignment and surfaces `degraded` as a "LIMITED" badge
520
+ // instead of the "1/1 ready" count the previous revision rendered.
521
+ const headerLabel = () => {
522
+ const name = prefs().header.label;
523
+ return !hasData() ? name : collapsed() ? `\u25b6 ${name}` : `\u25bc ${name}`;
524
+ };
525
+ return (_jsxs("box", { width: '100%', flexDirection: 'column', border: SINGLE_BORDER, borderColor: theme().borderActive, paddingTop: 1, paddingBottom: 1, paddingLeft: 1, paddingRight: 1, children: [_jsxs("box", { width: '100%', flexDirection: 'row', justifyContent: 'space-between', alignItems: 'center', onMouseDown: () => {
526
+ // Mirror the fleet guard: only toggle when there is data to expand
527
+ // into. Without this a click on the empty-awaiting header would just
528
+ // toggle the affordance for nothing.
529
+ if (hasData())
530
+ controller.toggleCollapsed();
531
+ }, children: [_jsx("box", { paddingLeft: 1, paddingRight: 1, backgroundColor: theme().accent, children: _jsx("text", { fg: theme().background, children: _jsx("b", { children: headerLabel() }) }) }), _jsx(Show, { when: degraded(), fallback: _jsx(Show, { when: prefs().header.showVersion && PLUGIN_VERSION !== '', children: _jsx("text", { fg: theme().textMuted, children: `v${PLUGIN_VERSION}` }) }), children: _jsx("box", { paddingLeft: 1, paddingRight: 1, backgroundColor: theme().warning, children: _jsx("text", { fg: theme().background, children: _jsx("b", { children: 'LIMITED' }) }) }) })] }), _jsx(Show, { when: collapsed() && hasData(), children: (() => {
532
+ const account = () => visibleAccounts().find((entry) => entry.current) ??
533
+ visibleAccounts()[0];
534
+ const used = () => {
535
+ const q = account()?.quota;
536
+ // Derive tone from the WORST (most-constrained) pool so a
537
+ // critical non-gemini pool doesn't hide behind a healthy
538
+ // gemini tone. Worst = highest used-percent across available pools.
539
+ const geminiUsed = q?.gemini != null
540
+ ? 100 - clamp(q.gemini.remainingPercent, 0, 100)
541
+ : null;
542
+ const nonGeminiUsed = q?.['non-gemini'] != null
543
+ ? 100 - clamp(q['non-gemini'].remainingPercent, 0, 100)
544
+ : null;
545
+ if (geminiUsed === null && nonGeminiUsed === null)
546
+ return null;
547
+ return Math.max(geminiUsed ?? 0, nonGeminiUsed ?? 0);
548
+ };
549
+ const poolText = (key) => {
550
+ const entry = account()?.quota[key];
551
+ if (!entry)
552
+ return `${QUOTA_LABELS[key]}: —`;
553
+ const pct = Math.round(100 - clamp(entry.remainingPercent, 0, 100));
554
+ // Show binding window when available, else just pool label.
555
+ const bindingWindow = entry.windows?.reduce((best, w) => best === null || w.remainingPercent < best.remainingPercent
556
+ ? w
557
+ : best, null);
558
+ const gutter = bindingWindow
559
+ ? ` ${WINDOW_GUTTER[bindingWindow.window] ?? bindingWindow.window}`
560
+ : '';
561
+ return `${QUOTA_LABELS[key]}${gutter}: ${pct}%`;
562
+ };
563
+ const unavailable = () => {
564
+ const selected = account();
565
+ return (selected != null &&
566
+ (!selected.enabled ||
567
+ (selected.cooldownUntil != null &&
568
+ selected.cooldownUntil > now())));
569
+ };
570
+ return (_jsx(Show, { when: account(), children: (selected) => (_jsx(CollapsedRow, { theme: theme, label: selected().label, children: _jsxs("box", { flexDirection: 'row', children: [_jsx("text", { fg: toneColor(theme(), used() == null
571
+ ? 'muted'
572
+ : quotaTone(used() ?? 0, prefs().appearance)), children: _jsx("b", { children: account()?.quota.gemini == null &&
573
+ account()?.quota['non-gemini'] == null
574
+ ? '—'
575
+ : `${poolText('gemini')} · ${poolText('non-gemini')}` }) }), _jsx("text", { fg: toneColor(theme(), unavailable()
576
+ ? 'err'
577
+ : quotaTone(used() ?? 0, prefs().appearance)), children: unavailable() ? ' ⊘' : ' ●' })] }) })) }));
578
+ })() }), _jsx(Show, { when: !collapsed() || !hasData(), children: _jsxs(Show, { when: hasData(), fallback: _jsx("box", { marginTop: 1, width: '100%', children: _jsx("text", { fg: theme().textMuted, children: 'Waiting for quota\u2026' }) }), children: [_jsxs(Show, { when: prefs().sections.quota, children: [_jsx(SectionHeader, { theme: theme, title: 'Quota' }), _jsx(For, { each: visibleAccounts(), children: (account, index) => (_jsx(AccountBlock, { theme: theme, appearance: prefs().appearance, account: account, now: now, marginTop: index() === 0 ? 0 : 1 })) })] }), _jsxs(Show, { when: prefs().sections.routing, children: [_jsx(SectionHeader, { theme: theme, title: 'Routing' }), _jsx(Show, { when: currentRoute(), fallback: _jsx(StatRow, { theme: theme, label: 'Route', value: '\u2014', tone: 'muted' }), children: (route) => (_jsx(StatRow, { theme: theme, label: 'Route', value: `${route().strategy ? `${route().strategy} · ` : ''}${route().family}: ${route().style}`, tone: 'accent' })) })] }), _jsxs(Show, { when: degraded() && prefs().sections.health, children: [_jsx(SectionHeader, { theme: theme, title: 'Health' }), _jsx(Show, { when: backoffActive(), children: _jsx(StatRow, { theme: theme, label: 'Quota API', value: `backoff ${formatResetIn(state().loaded.quotaBackoffUntil, now)}`, tone: 'warn' }) }), _jsx(Show, { when: lastError(), children: _jsx(StatRow, { theme: theme, label: 'Last error', value: lastError() ?? '', tone: 'err' }) })] })] }) })] }));
579
+ }
580
+ /**
581
+ * Solid slot registry binding exposed for hosts that want to mount the
582
+ * sidebar inside their renderer. Hosts that already own a slot registry can
583
+ * use `createSlot` directly; we re-export for convenience and to keep the
584
+ * contract visible at the module entry point.
585
+ */
586
+ export const sidebar_content = createSlot;
587
+ export function startRpcNotificationPolling(options) {
588
+ if (rpcPollStarted)
589
+ return;
590
+ rpcPollStarted = true;
591
+ options.schedule(async () => {
592
+ if (rpcInFlight)
593
+ return;
594
+ rpcInFlight = true;
595
+ try {
596
+ const sessionId = options.currentSessionId();
597
+ const cursorKey = sessionId ?? GLOBAL_NOTIFICATION_CURSOR;
598
+ let cursor = notificationCursorBySession.get(cursorKey) ?? 0;
599
+ const notifications = await options.pending(cursor, sessionId);
600
+ for (const notification of [...notifications].sort((a, b) => a.id - b.id)) {
601
+ if (notification.id <= cursor)
602
+ continue;
603
+ cursor = Math.max(cursor, notification.id);
604
+ if (dispatchedNotificationIds.has(notification.id))
605
+ continue;
606
+ dispatchedNotificationIds.add(notification.id);
607
+ if (dispatchedNotificationIds.size > 100) {
608
+ const oldestId = dispatchedNotificationIds.values().next().value;
609
+ if (oldestId !== undefined)
610
+ dispatchedNotificationIds.delete(oldestId);
611
+ }
612
+ await options.dispatch(notification);
613
+ }
614
+ if (!notificationCursorBySession.has(cursorKey)) {
615
+ while (notificationCursorBySession.size >= MAX_NOTIFICATION_CURSORS) {
616
+ const oldest = notificationCursorBySession.keys().next().value;
617
+ if (oldest === undefined)
618
+ break;
619
+ notificationCursorBySession.delete(oldest);
620
+ }
621
+ }
622
+ notificationCursorBySession.set(cursorKey, cursor);
623
+ }
624
+ catch (error) {
625
+ // Surface the swallowed error through the file logger rather than
626
+ // stdout/stderr (the host terminal is the frame buffer — any byte
627
+ // written here corrupts every subsequent cell). Without this, a
628
+ // transient RPC outage is invisible to operators. The catch stays
629
+ // because one failed poll must never break the next — the scheduler
630
+ // is a setInterval and a thrown error there would crash the
631
+ // process.
632
+ options.logger.warn('rpc-poll-failed', {
633
+ error: error instanceof Error ? error.message : String(error),
634
+ });
635
+ }
636
+ finally {
637
+ rpcInFlight = false;
638
+ }
639
+ }, RPC_POLL_MS);
640
+ }
641
+ const tui = async (api) => {
642
+ const logger = resolveLogger(undefined);
643
+ const prefsRoot = await readTuiPreferencesFile();
644
+ if (!sidebarController) {
645
+ sidebarController = createSidebarController(resolveAntigravityAuthPrefs(prefsRoot));
646
+ }
647
+ const rpcClient = createRpcClient(getRpcDir(api.state.path.directory ?? ''), process.pid);
648
+ startRpcNotificationPolling({
649
+ pending: (lastReceivedId, sessionId) => rpcClient.pendingNotifications(lastReceivedId, sessionId),
650
+ currentSessionId: () => {
651
+ const current = api.route.current;
652
+ const resolved = typeof current === 'function' ? current() : current;
653
+ return resolved
654
+ ?.params?.sessionID;
655
+ },
656
+ dispatch: async (notification) => {
657
+ logger.debug('rpc-notification-received', {
658
+ command: notification.payload.command,
659
+ id: notification.id,
660
+ sessionId: notification.sessionId,
661
+ });
662
+ // Call the imperative dispatcher directly — the prior
663
+ // two-phase `collectDialogFlow` + `renderDialogFlow` is gone.
664
+ // The dispatcher awaits `apply`, toasts the result, then clears
665
+ // (or replaces for multi-step flows). The RPC `apply` accepts the
666
+ // optional `timeoutMs` knob so account add / refresh can opt into
667
+ // the 120s RPC timeout without the dialog layer having to know
668
+ // about it.
669
+ if (notification.payload.command === 'antigravity-quota') {
670
+ api.ui.dialog.setSize('xlarge');
671
+ api.ui.dialog.replace(() => (_jsx(QuotaDialogContent, { api: api, controller: getSidebarController(), sessionId: notification.sessionId })));
672
+ return;
673
+ }
674
+ openCommandDialog(api, notification.payload, (command, args, options) => rpcClient.apply({ command, arguments: args, sessionId: notification.sessionId }, options));
675
+ },
676
+ schedule: (poll, intervalMs) => {
677
+ setInterval(() => void poll(), intervalMs);
678
+ },
679
+ logger,
680
+ });
681
+ // The host supplies the live theme via `api.theme.current` — the slot
682
+ // callback's closure captures `api` so the accessor always reads the
683
+ // current theme. A Solid re-render follows whenever the user switches.
684
+ const liveTheme = () => api.theme.current;
685
+ api.slots.register({
686
+ order: computeEffectiveOrder(prefsRoot, PLUGIN_KEY, DEFAULT_SLOT_ORDER),
687
+ slots: {
688
+ sidebar_content: (_context, { session_id: sessionId }) => (_jsx(SidebarPanel, { logger: logger, theme: liveTheme, sessionId: sessionId })),
689
+ },
690
+ });
691
+ };
692
+ const plugin = {
693
+ id: ID,
694
+ tui,
695
+ };
696
+ export default plugin;
697
+ //# sourceMappingURL=tui.js.map