@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,1193 @@
1
+ import { memo as _$memo } from "opentui:runtime-module:%40opentui%2Fsolid";
2
+ import { createTextNode as _$createTextNode } from "opentui:runtime-module:%40opentui%2Fsolid";
3
+ import { createComponent as _$createComponent } from "opentui:runtime-module:%40opentui%2Fsolid";
4
+ import { effect as _$effect } from "opentui:runtime-module:%40opentui%2Fsolid";
5
+ import { insertNode as _$insertNode } from "opentui:runtime-module:%40opentui%2Fsolid";
6
+ import { insert as _$insert } from "opentui:runtime-module:%40opentui%2Fsolid";
7
+ import { setProp as _$setProp } from "opentui:runtime-module:%40opentui%2Fsolid";
8
+ import { createElement as _$createElement } from "opentui:runtime-module:%40opentui%2Fsolid";
9
+ /** @jsxImportSource @opentui/solid */
10
+
11
+ /**
12
+ * Read-only OpenTUI sidebar for the Antigravity plugin.
13
+ *
14
+ * Mirrors the fleet sibling layout (see `anthropic-auth-live` /
15
+ * `openai-auth-live` `packages/opencode/src/tui.tsx`): a single bordered
16
+ * column with a labelled header badge, a Quota section that lists one
17
+ * `AccountBlock` per visible account, a Routing section that surfaces the
18
+ * most recent session route, and a Health section that only appears when
19
+ * something is wrong. The Antigravity data model is richer than the
20
+ * Claude/Codex one (per-account Gemini + Non-Gemini quota pools, a health
21
+ * score, and per-session routing decisions), so the fleet components are
22
+ * adapted rather than copied verbatim:
23
+ *
24
+ * - `QuotaRow` reads `remainingPercent + resetAt` from the Antigravity
25
+ * `SidebarQuotaEntry` shape and colors via `quotaTone` (remaining
26
+ * threshold) instead of `usageTone` (used threshold).
27
+ * - `AccountBlock` derives its status word (`active` / `idle` /
28
+ * `cooling` / `off` / `blocked`) from the Antigravity account state and
29
+ * surfaces health as a muted secondary line rather than a top-level
30
+ * bar — fleet parity for "Quota first, health second".
31
+ * - `Routing` resolves to a single `Route` `StatRow` carrying the most
32
+ * recent `activeRouting` entry, since Antigravity does not maintain a
33
+ * per-session sidebar state alongside the slot-rendered tree.
34
+ *
35
+ * Hard rules for this file:
36
+ *
37
+ * - NO direct writes to the host terminal anywhere in the render path.
38
+ * The host terminal is the frame buffer; one stray byte corrupts every
39
+ * subsequent cell. Errors flow through `createTuiFileLogger()`.
40
+ * - NO imports from `./plugin/storage`, `./plugin/accounts`, OAuth code,
41
+ * or anything that touches tokens.
42
+ * - The component uses Solid's `onCleanup` to release the polling timer
43
+ * on unmount so a route change can never leak an interval.
44
+ */
45
+
46
+ import { readFileSync } from "node:fs";
47
+ import { dirname, join } from "node:path";
48
+ import { fileURLToPath } from "node:url";
49
+ import { createSlot } from "opentui:runtime-module:%40opentui%2Fsolid";
50
+ import { createEffect, createSignal, For, onCleanup, onMount, Show } from "opentui:runtime-module:solid-js";
51
+ import { createRpcClient } from "./rpc/rpc-client";
52
+ import { getRpcDir } from "./rpc/rpc-dir";
53
+ import { readSidebarState } from "./sidebar-state";
54
+ import { openCommandDialog } from "./tui/command-dialogs";
55
+ import { createTuiFileLogger } from "./tui/file-logger";
56
+ import { computeEffectiveOrder, DEFAULT_PREFS, DEFAULT_SLOT_ORDER, PLUGIN_KEY, queueTuiPreferenceUpdate, readTuiPreferencesFile, resolveAntigravityAuthPrefs, watchTuiPreferences } from "./tui-preferences";
57
+ const ID = 'cortexkit.antigravity-auth';
58
+ const POLL_INTERVAL_MS = 2000;
59
+ const RPC_POLL_MS = 500;
60
+ const SINGLE_BORDER = {
61
+ type: 'single'
62
+ };
63
+
64
+ // Read package metadata from either the raw src/ entry or its generated
65
+ // src/tui-compiled/ counterpart. Avoid a JSON import because package.json sits
66
+ // outside the declaration build's rootDir.
67
+ const PLUGIN_VERSION = (() => {
68
+ const here = dirname(fileURLToPath(import.meta.url));
69
+ for (const packageFile of [join(here, '..', 'package.json'), join(here, '..', '..', 'package.json')]) {
70
+ try {
71
+ const raw = readFileSync(packageFile, 'utf8');
72
+ const version = JSON.parse(raw).version;
73
+ if (version) return version;
74
+ } catch {
75
+ // Try the path for the other TUI entry layout.
76
+ }
77
+ }
78
+ return '';
79
+ })();
80
+ // Module-scoped state — TEST ISOLATION CONTRACT:
81
+ //
82
+ // `rpcPollStarted`, notification cursor/deduplication state, `rpcInFlight`, and the lazy
83
+ // `sidebarController` below persist across tests via the cached ES
84
+ // module Bun loads once per `--isolate` file. Tests must NOT assert
85
+ // fresh-process behaviour from these variables — by the time the first
86
+ // `startRpcNotificationPolling` runs, all four carry stale values from
87
+ // prior tests in the same file. Test isolation comes from:
88
+ // 1. fresh-importing `tui.tsx` via a cache-busted dynamic `import`
89
+ // so the module re-evaluates with fresh module-scoped bindings, and
90
+ // 2. constructing a fresh `SidebarController` via
91
+ // `createSidebarController(prefs)` and passing it through
92
+ // `SidebarPanel.props.controller` — never through
93
+ // `getSidebarController()`, which lazily seeds the module-scoped
94
+ // singleton.
95
+ let rpcPollStarted = false;
96
+ const notificationCursorBySession = new Map();
97
+ const dispatchedNotificationIds = new Set();
98
+ let rpcInFlight = false;
99
+ const GLOBAL_NOTIFICATION_CURSOR = '__global__';
100
+ const MAX_NOTIFICATION_CURSORS = 256;
101
+ const QUOTA_LABELS = {
102
+ gemini: 'Gm',
103
+ 'non-gemini': 'NG'
104
+ };
105
+ const QUOTA_ORDER = ['gemini', 'non-gemini'];
106
+ const WINDOW_GUTTER = {
107
+ weekly: '7d',
108
+ '5h': '5h'
109
+ };
110
+
111
+ // --- Theme tokens ----------------------------------------------------------
112
+ //
113
+ // The sidebar pulls its colors from the live host theme (`api.theme.current`
114
+ // — a Solid-friendly getter that re-emits when the user switches theme).
115
+ // Every render path resolves through `toneColor(theme, tone)` with a
116
+ // sibling-style `??` fallback chain, so the sidebar always tracks the
117
+ // active theme and never hardcodes an ANSI literal.
118
+ //
119
+ // `FALLBACK_THEME` is the safety net for tests and any future host that
120
+ // does not implement the theme surface. The fields the sidebar actually
121
+ // uses are populated; the rest of the TuiThemeCurrent fields are left
122
+ // undefined and the `??` chain in `toneColor` falls through cleanly.
123
+
124
+ const FALLBACK_THEME = {
125
+ primary: '#3b82f6',
126
+ secondary: '#a855f7',
127
+ accent: '#7c3aed',
128
+ error: '#ef4444',
129
+ warning: '#eab308',
130
+ success: '#22c55e',
131
+ info: '#0ea5e9',
132
+ text: '#e5e7eb',
133
+ textMuted: '#6b7280',
134
+ selectedListItemText: '#ffffff',
135
+ background: '#0b0d12',
136
+ backgroundPanel: '#11131a',
137
+ backgroundElement: '#1a1d27',
138
+ backgroundMenu: '#1a1d27',
139
+ border: '#2a2d3a',
140
+ borderActive: '#7c3aed',
141
+ borderSubtle: '#2a2d3a',
142
+ diffAdded: '#22c55e',
143
+ diffRemoved: '#ef4444',
144
+ diffContext: '#6b7280',
145
+ diffHunkHeader: '#7c3aed',
146
+ diffHighlightAdded: '#166534',
147
+ diffHighlightRemoved: '#7f1d1d',
148
+ diffAddedBg: '#0a1f12',
149
+ diffRemovedBg: '#1f0a0a',
150
+ diffContextBg: '#0b0d12',
151
+ diffLineNumber: '#4b5563',
152
+ diffAddedLineNumberBg: '#0a1f12',
153
+ diffRemovedLineNumberBg: '#1f0a0a',
154
+ markdownText: '#e5e7eb',
155
+ markdownHeading: '#7c3aed',
156
+ markdownLink: '#3b82f6',
157
+ markdownLinkText: '#60a5fa',
158
+ markdownCode: '#22c55e',
159
+ markdownBlockQuote: '#6b7280',
160
+ markdownEmph: '#eab308',
161
+ markdownStrong: '#7c3aed',
162
+ markdownHorizontalRule: '#2a2d3a',
163
+ markdownListItem: '#7c3aed',
164
+ markdownListEnumeration: '#a855f7',
165
+ markdownImage: '#3b82f6',
166
+ markdownImageText: '#60a5fa',
167
+ markdownCodeBlock: '#11131a',
168
+ syntaxComment: '#6b7280',
169
+ syntaxKeyword: '#a855f7',
170
+ syntaxFunction: '#3b82f6',
171
+ syntaxVariable: '#e5e7eb',
172
+ syntaxString: '#22c55e',
173
+ syntaxNumber: '#eab308',
174
+ syntaxType: '#7c3aed',
175
+ syntaxOperator: '#e5e7eb',
176
+ syntaxPunctuation: '#6b7280',
177
+ thinkingOpacity: 0.6
178
+ };
179
+
180
+ // Mirror the fleet siblings' tone chain: every tone falls through to a
181
+ // sibling token, so a sparse custom theme still renders readably.
182
+ function toneColor(theme, tone) {
183
+ switch (tone) {
184
+ case 'ok':
185
+ return theme.success ?? theme.accent;
186
+ case 'warn':
187
+ return theme.warning ?? theme.accent;
188
+ case 'err':
189
+ return theme.error ?? theme.accent;
190
+ case 'muted':
191
+ return theme.textMuted ?? theme.text;
192
+ case 'accent':
193
+ return theme.accent ?? theme.text;
194
+ default:
195
+ return theme.text;
196
+ }
197
+ }
198
+ function quotaTone(usedPct, appearance) {
199
+ if (usedPct < appearance.warnThreshold) return 'ok';
200
+ if (usedPct < appearance.errorThreshold) return 'warn';
201
+ return 'err';
202
+ }
203
+ function quotaBarSegments(usedPct, appearance) {
204
+ const width = appearance.barWidth;
205
+ const usedCells = Math.max(0, Math.min(Math.round(usedPct / 100 * width), width));
206
+ const tone = quotaTone(usedPct, appearance);
207
+ return [{
208
+ text: appearance.barFilledChar.repeat(usedCells),
209
+ tone
210
+ }, {
211
+ text: appearance.barEmptyChar.repeat(width - usedCells),
212
+ tone
213
+ }].filter(segment => segment.text.length > 0);
214
+ }
215
+ const EMPTY_STATE = {
216
+ version: 1,
217
+ checkedAt: 0,
218
+ accounts: [],
219
+ activeRouting: {},
220
+ routingAuthoritative: false
221
+ };
222
+ function resolveLogger(logger) {
223
+ if (logger) return logger;
224
+ try {
225
+ return createTuiFileLogger();
226
+ } catch {
227
+ // Fall back to a stub that drops everything — the sidebar must still
228
+ // render even if file logging cannot be initialized.
229
+ return noopLogger();
230
+ }
231
+ }
232
+ function noopLogger() {
233
+ const drop = () => undefined;
234
+ return {
235
+ debug: drop,
236
+ info: drop,
237
+ warn: drop,
238
+ error: drop,
239
+ getLogPath: () => undefined
240
+ };
241
+ }
242
+
243
+ // Module-scoped controller singleton, initialized at plugin startup. The
244
+ // watcher is intentionally never disposed — collapse/prefs state survives
245
+ // sidebar remounts (route changes) for the lifetime of the TUI process,
246
+ // mirroring the fleet siblings.
247
+ //
248
+ // TEST ISOLATION: this singleton, like `rpcPollStarted` above, persists
249
+ // across tests via the cached ES module. Tests construct a controller
250
+ // via `createSidebarController(prefs)` and pass it through
251
+ // `SidebarPanel.props.controller` — they MUST NOT rely on this lazy
252
+ // singleton for isolation. See the block above for the full contract.
253
+ let sidebarController = null;
254
+
255
+ // The TUI may unmount and remount sidebar_content when the user switches
256
+ // views. A remount re-runs the component body, so any signal created inside
257
+ // the component would reset to its seed. The controller lives in the plugin
258
+ // closure (process lifetime) and owns the durable prefs/collapse signals
259
+ // plus the single shared watcher subscription, so collapse and live pref
260
+ // reloads survive the remount.
261
+ //
262
+ // Exported so tests can construct a controller with a controlled initial
263
+ // prefs snapshot without touching the module-scoped singleton.
264
+ export function createSidebarController(initialPrefs) {
265
+ const [prefs, setPrefs] = createSignal(initialPrefs);
266
+ const seedCollapsed = initialPrefs.rememberCollapsed && initialPrefs.collapsed != null ? initialPrefs.collapsed : initialPrefs.startCollapsed;
267
+ const [collapsed, setCollapsed] = createSignal(seedCollapsed);
268
+ let lastPersistedCollapsed = initialPrefs.collapsed;
269
+ let lastApplied = JSON.stringify(initialPrefs);
270
+
271
+ // The watcher lives for the plugin/process lifetime — it is intentionally
272
+ // never disposed. Collapse guard mirrors the race-fix in toggleCollapsed:
273
+ // lastPersistedCollapsed is advanced only once our own write lands, so
274
+ // watcher echoes of the previous persisted value are rejected by the
275
+ // `!==` check and cannot revert a user click.
276
+ watchTuiPreferences(() => {
277
+ void (async () => {
278
+ const next = resolveAntigravityAuthPrefs(await readTuiPreferencesFile());
279
+ const serialized = JSON.stringify(next);
280
+ if (serialized === lastApplied) return;
281
+ lastApplied = serialized;
282
+ setPrefs(next);
283
+ if (next.rememberCollapsed && next.collapsed != null && next.collapsed !== lastPersistedCollapsed) {
284
+ lastPersistedCollapsed = next.collapsed;
285
+ setCollapsed(next.collapsed);
286
+ }
287
+ })();
288
+ });
289
+ function toggleCollapsed() {
290
+ const next = !collapsed();
291
+ setCollapsed(next);
292
+ if (prefs().rememberCollapsed) {
293
+ void queueTuiPreferenceUpdate(PLUGIN_KEY, ['collapsed'], next).then(() => {
294
+ lastPersistedCollapsed = next;
295
+ });
296
+ }
297
+ }
298
+ return {
299
+ prefs,
300
+ collapsed,
301
+ toggleCollapsed
302
+ };
303
+ }
304
+
305
+ // Lazy module-scoped accessor used by the plugin entry. Tests should NOT go
306
+ // through this — they construct their own controller via createSidebarController
307
+ // and pass it via SidebarPanelProps.controller.
308
+ function getSidebarController() {
309
+ if (!sidebarController) {
310
+ sidebarController = createSidebarController(DEFAULT_PREFS);
311
+ }
312
+ return sidebarController;
313
+ }
314
+
315
+ // --- Shared helpers (fleet shape, antigravity data) ------------------------
316
+
317
+ function clamp(value, min, max) {
318
+ if (value < min) return min;
319
+ if (value > max) return max;
320
+ return value;
321
+ }
322
+
323
+ // Render a "reset in Nm/Nh/NdNh" string from an epoch-ms reset time.
324
+ // Empty string when no resetAt is cached. The fleet's `formatResetIn`
325
+ // reads ISO strings; Antigravity persists resetAt as a numeric epoch, so
326
+ // the wrapper adapts to that without changing the shape of the output.
327
+ function formatResetIn(resetAt, now) {
328
+ if (!resetAt) return '';
329
+ const ms = resetAt - now();
330
+ if (ms <= 0) return 'now';
331
+ const mins = Math.floor(ms / 60_000);
332
+ if (mins < 60) return `${mins}m`;
333
+ const hrs = Math.floor(mins / 60);
334
+ if (hrs < 24) {
335
+ const rm = mins % 60;
336
+ return rm > 0 ? `${hrs}h${rm}m` : `${hrs}h`;
337
+ }
338
+ const days = Math.floor(hrs / 24);
339
+ const rh = hrs % 24;
340
+ return rh > 0 ? `${days}d${rh}h` : `${days}d`;
341
+ }
342
+ function formatError(value) {
343
+ if (value instanceof Error) return value.message;
344
+ try {
345
+ return JSON.stringify(value);
346
+ } catch {
347
+ return String(value);
348
+ }
349
+ }
350
+
351
+ // --- Fleet components (adapted to antigravity data) ------------------------
352
+
353
+ // Section header — fleet pattern: bold title, themed text color, top margin
354
+ // for vertical breathing room between sections.
355
+ function SectionHeader(props) {
356
+ return (() => {
357
+ var _el$ = _$createElement("box"),
358
+ _el$2 = _$createElement("text"),
359
+ _el$3 = _$createElement("b");
360
+ _$insertNode(_el$, _el$2);
361
+ _$setProp(_el$, "width", '100%');
362
+ _$setProp(_el$, "marginTop", 1);
363
+ _$insertNode(_el$2, _el$3);
364
+ _$insert(_el$3, () => props.title);
365
+ _$effect(_$p => _$setProp(_el$2, "fg", toneColor(props.theme(), 'text'), _$p));
366
+ return _el$;
367
+ })();
368
+ }
369
+
370
+ // Fleet StatRow: muted label left, value (optionally tone-tinted, bold)
371
+ // right. Mirrors the layout the Claude/Codex sidebars use for routing
372
+ // rows, plan rows, and "resets N" rows.
373
+ function StatRow(props) {
374
+ return (() => {
375
+ var _el$4 = _$createElement("box"),
376
+ _el$5 = _$createElement("text"),
377
+ _el$6 = _$createElement("text"),
378
+ _el$7 = _$createElement("b");
379
+ _$insertNode(_el$4, _el$5);
380
+ _$insertNode(_el$4, _el$6);
381
+ _$setProp(_el$4, "width", '100%');
382
+ _$setProp(_el$4, "flexDirection", 'row');
383
+ _$setProp(_el$4, "justifyContent", 'space-between');
384
+ _$insert(_el$5, () => props.label);
385
+ _$insertNode(_el$6, _el$7);
386
+ _$insert(_el$7, () => props.value);
387
+ _$effect(_p$ => {
388
+ var _v$ = props.theme().textMuted,
389
+ _v$2 = toneColor(props.theme(), props.tone ?? 'text');
390
+ _v$ !== _p$.e && (_p$.e = _$setProp(_el$5, "fg", _v$, _p$.e));
391
+ _v$2 !== _p$.t && (_p$.t = _$setProp(_el$6, "fg", _v$2, _p$.t));
392
+ return _p$;
393
+ }, {
394
+ e: undefined,
395
+ t: undefined
396
+ });
397
+ return _el$4;
398
+ })();
399
+ }
400
+
401
+ // Fleet CollapsedRow: muted label left, caller-supplied value right. Used
402
+ // for the collapsed sidebar view; the Antigravity adapter renders one
403
+ // CollapsedRow per visible account (Claude's sibling collapses to a
404
+ // single primary-quota line, but Antigravity's multi-quota model fits a
405
+ // per-account row better when the sidebar is collapsed).
406
+ function CollapsedRow(props) {
407
+ return (() => {
408
+ var _el$8 = _$createElement("box"),
409
+ _el$9 = _$createElement("text");
410
+ _$insertNode(_el$8, _el$9);
411
+ _$setProp(_el$8, "width", '100%');
412
+ _$setProp(_el$8, "flexDirection", 'row');
413
+ _$setProp(_el$8, "justifyContent", 'space-between');
414
+ _$insert(_el$9, () => props.label);
415
+ _$insert(_el$8, () => props.children, null);
416
+ _$effect(_$p => _$setProp(_el$9, "fg", props.theme().textMuted, _$p));
417
+ return _el$8;
418
+ })();
419
+ }
420
+
421
+ // Fleet QuotaRow, adapted to Antigravity's `remainingPercent + resetAt`
422
+ // shape. The left group stacks label + bar + pct in fixed columns so
423
+ // bars line up across rows; the right group carries the reset countdown
424
+ // when the plugin has cached a reset time. Tone is read off the
425
+ // remaining percentage via the antigravity threshold rules — the fleet's
426
+ // `usageTone` would invert the polarity (healthy = high remaining vs
427
+ // healthy = low used), so we keep the antigravity-local `quotaTone`.
428
+ function QuotaRow(props) {
429
+ const used = () => props.entry ? 100 - clamp(props.entry.remainingPercent, 0, 100) : null;
430
+ const reset = () => props.entry ? formatResetIn(props.entry.resetAt, props.now) : '';
431
+ return _$createComponent(Show, {
432
+ get when() {
433
+ return used() != null;
434
+ },
435
+ get fallback() {
436
+ return (() => {
437
+ var _el$14 = _$createElement("box"),
438
+ _el$15 = _$createElement("text"),
439
+ _el$16 = _$createElement("text");
440
+ _$insertNode(_el$14, _el$15);
441
+ _$insertNode(_el$14, _el$16);
442
+ _$setProp(_el$14, "width", '100%');
443
+ _$setProp(_el$14, "flexDirection", 'row');
444
+ _$setProp(_el$14, "justifyContent", 'space-between');
445
+ _$insert(_el$15, () => props.label.padEnd(5));
446
+ _$insertNode(_el$16, _$createTextNode(`—`));
447
+ _$effect(_p$ => {
448
+ var _v$6 = props.theme().textMuted,
449
+ _v$7 = props.theme().textMuted;
450
+ _v$6 !== _p$.e && (_p$.e = _$setProp(_el$15, "fg", _v$6, _p$.e));
451
+ _v$7 !== _p$.t && (_p$.t = _$setProp(_el$16, "fg", _v$7, _p$.t));
452
+ return _p$;
453
+ }, {
454
+ e: undefined,
455
+ t: undefined
456
+ });
457
+ return _el$14;
458
+ })();
459
+ },
460
+ get children() {
461
+ var _el$0 = _$createElement("box"),
462
+ _el$1 = _$createElement("box"),
463
+ _el$10 = _$createElement("text"),
464
+ _el$11 = _$createElement("box"),
465
+ _el$12 = _$createElement("text");
466
+ _$insertNode(_el$0, _el$1);
467
+ _$setProp(_el$0, "width", '100%');
468
+ _$setProp(_el$0, "flexDirection", 'row');
469
+ _$setProp(_el$0, "justifyContent", 'space-between');
470
+ _$insertNode(_el$1, _el$10);
471
+ _$insertNode(_el$1, _el$11);
472
+ _$insertNode(_el$1, _el$12);
473
+ _$setProp(_el$1, "flexDirection", 'row');
474
+ _$setProp(_el$10, "width", 5);
475
+ _$setProp(_el$10, "flexShrink", 0);
476
+ _$insert(_el$10, () => props.label);
477
+ _$setProp(_el$11, "flexShrink", 0);
478
+ _$setProp(_el$11, "flexDirection", 'row');
479
+ _$insert(_el$11, _$createComponent(For, {
480
+ get each() {
481
+ return quotaBarSegments(used() ?? 0, props.appearance);
482
+ },
483
+ children: segment => (() => {
484
+ var _el$18 = _$createElement("text");
485
+ _$insert(_el$18, () => segment.text);
486
+ _$effect(_$p => _$setProp(_el$18, "fg", toneColor(props.theme(), segment.tone), _$p));
487
+ return _el$18;
488
+ })()
489
+ }));
490
+ _$insert(_el$12, () => ` ${String(Math.round(used() ?? 0)).padStart(3)}%`);
491
+ _$insert(_el$0, _$createComponent(Show, {
492
+ get when() {
493
+ return reset();
494
+ },
495
+ get children() {
496
+ var _el$13 = _$createElement("text");
497
+ _$insert(_el$13, reset);
498
+ _$effect(_$p => _$setProp(_el$13, "fg", props.theme().textMuted, _$p));
499
+ return _el$13;
500
+ }
501
+ }), null);
502
+ _$effect(_p$ => {
503
+ var _v$3 = props.theme().textMuted,
504
+ _v$4 = props.appearance.barWidth,
505
+ _v$5 = toneColor(props.theme(), quotaTone(used() ?? 0, props.appearance));
506
+ _v$3 !== _p$.e && (_p$.e = _$setProp(_el$10, "fg", _v$3, _p$.e));
507
+ _v$4 !== _p$.t && (_p$.t = _$setProp(_el$11, "width", _v$4, _p$.t));
508
+ _v$5 !== _p$.a && (_p$.a = _$setProp(_el$12, "fg", _v$5, _p$.a));
509
+ return _p$;
510
+ }, {
511
+ e: undefined,
512
+ t: undefined,
513
+ a: undefined
514
+ });
515
+ return _el$0;
516
+ }
517
+ });
518
+ }
519
+
520
+ // Fleet AccountBlock, adapted to Antigravity's per-account data. Header
521
+ // row is account label (left) + status word (right). The body renders one
522
+ // QuotaRow per present quota group in the fleet's stable order, then a
523
+ // muted secondary line with the account's health score and, when
524
+ // relevant, a cooldown countdown. Status word priorities (first match
525
+ // wins):
526
+ // - `off` when the account is disabled
527
+ // - `cooling` when cooldownUntil is still in the future
528
+ // - `active` when current === true
529
+ // - `idle` for the fallback (current === false) case
530
+ function AccountBlock(props) {
531
+ const active = () => props.active ?? props.account.current;
532
+ const statusWord = () => {
533
+ if (!props.account.enabled) return 'off';
534
+ const cd = props.account.cooldownUntil;
535
+ if (typeof cd === 'number' && cd > props.now()) return 'cooling';
536
+ return active() ? 'active' : 'idle';
537
+ };
538
+ const statusTone = () => {
539
+ if (!props.account.enabled) return 'muted';
540
+ const cd = props.account.cooldownUntil;
541
+ if (typeof cd === 'number' && cd > props.now()) return 'warn';
542
+ return active() ? 'ok' : 'muted';
543
+ };
544
+ const cooldownMs = () => {
545
+ const cd = props.account.cooldownUntil;
546
+ if (typeof cd !== 'number') return 0;
547
+ return Math.max(0, cd - props.now());
548
+ };
549
+ const healthText = () => {
550
+ const base = `health ${Math.round(clamp(props.account.health, 0, 100))}`;
551
+ return cooldownMs() > 0 ? `${base} · cooling ${formatWait(cooldownMs())}` : base;
552
+ };
553
+ return (() => {
554
+ var _el$19 = _$createElement("box"),
555
+ _el$20 = _$createElement("box"),
556
+ _el$21 = _$createElement("text"),
557
+ _el$22 = _$createElement("b"),
558
+ _el$23 = _$createElement("text"),
559
+ _el$24 = _$createElement("b"),
560
+ _el$25 = _$createElement("box"),
561
+ _el$26 = _$createElement("text");
562
+ _$insertNode(_el$19, _el$20);
563
+ _$insertNode(_el$19, _el$25);
564
+ _$setProp(_el$19, "width", '100%');
565
+ _$setProp(_el$19, "flexDirection", 'column');
566
+ _$insertNode(_el$20, _el$21);
567
+ _$insertNode(_el$20, _el$23);
568
+ _$setProp(_el$20, "width", '100%');
569
+ _$setProp(_el$20, "flexDirection", 'row');
570
+ _$setProp(_el$20, "justifyContent", 'space-between');
571
+ _$insertNode(_el$21, _el$22);
572
+ _$insert(_el$22, () => props.account.label);
573
+ _$insertNode(_el$23, _el$24);
574
+ _$insert(_el$24, statusWord);
575
+ _$insert(_el$19, _$createComponent(For, {
576
+ each: QUOTA_ORDER,
577
+ children: key => {
578
+ const poolEntry = props.account.quota[key];
579
+ const windows = poolEntry?.windows;
580
+ // Legacy: no windows array — render a single row with the pool label.
581
+ const hasWindows = windows && windows.length > 0;
582
+ if (!hasWindows) {
583
+ return _$createComponent(QuotaRow, {
584
+ get theme() {
585
+ return props.theme;
586
+ },
587
+ get appearance() {
588
+ return props.appearance;
589
+ },
590
+ get label() {
591
+ return QUOTA_LABELS[key];
592
+ },
593
+ entry: poolEntry,
594
+ get now() {
595
+ return props.now;
596
+ }
597
+ });
598
+ }
599
+ return _$memo(() => windows.map(w => _$createComponent(QuotaRow, {
600
+ get theme() {
601
+ return props.theme;
602
+ },
603
+ get appearance() {
604
+ return props.appearance;
605
+ },
606
+ get label() {
607
+ return `${QUOTA_LABELS[key]} ${WINDOW_GUTTER[w.window] ?? w.window}`;
608
+ },
609
+ get entry() {
610
+ return {
611
+ remainingPercent: w.remainingPercent,
612
+ resetAt: w.resetAt
613
+ };
614
+ },
615
+ get now() {
616
+ return props.now;
617
+ }
618
+ })));
619
+ }
620
+ }), _el$25);
621
+ _$insertNode(_el$25, _el$26);
622
+ _$setProp(_el$25, "width", '100%');
623
+ _$setProp(_el$25, "flexDirection", 'row');
624
+ _$insert(_el$26, () => ` ${healthText()}`);
625
+ _$effect(_p$ => {
626
+ var _v$8 = props.marginTop ?? 0,
627
+ _v$9 = props.theme().text,
628
+ _v$0 = toneColor(props.theme(), statusTone()),
629
+ _v$1 = props.theme().textMuted;
630
+ _v$8 !== _p$.e && (_p$.e = _$setProp(_el$19, "marginTop", _v$8, _p$.e));
631
+ _v$9 !== _p$.t && (_p$.t = _$setProp(_el$21, "fg", _v$9, _p$.t));
632
+ _v$0 !== _p$.a && (_p$.a = _$setProp(_el$23, "fg", _v$0, _p$.a));
633
+ _v$1 !== _p$.o && (_p$.o = _$setProp(_el$26, "fg", _v$1, _p$.o));
634
+ return _p$;
635
+ }, {
636
+ e: undefined,
637
+ t: undefined,
638
+ a: undefined,
639
+ o: undefined
640
+ });
641
+ return _el$19;
642
+ })();
643
+ }
644
+ function formatWait(ms) {
645
+ const seconds = Math.ceil(ms / 1000);
646
+ if (seconds < 60) return `${seconds}s`;
647
+ const minutes = Math.floor(seconds / 60);
648
+ const remaining = seconds % 60;
649
+ return remaining > 0 ? `${minutes}m ${remaining}s` : `${minutes}m`;
650
+ }
651
+ export function resolveQuotaDialogActiveId(state, sessionId) {
652
+ return (sessionId ? state.activeRouting[sessionId]?.accountId : undefined) ?? state.accounts.find(account => account.current)?.id;
653
+ }
654
+ export function QuotaDialogContent(props) {
655
+ const prefs = props.controller.prefs;
656
+ const [state, setState] = createSignal(EMPTY_STATE);
657
+ const refresh = () => {
658
+ setState(readSidebarState());
659
+ };
660
+ createEffect(() => {
661
+ const timer = setInterval(refresh, prefs().pollMs);
662
+ onCleanup(() => clearInterval(timer));
663
+ });
664
+ setTimeout(refresh, 0);
665
+ const theme = () => props.api.theme.current;
666
+ const visibleAccounts = () => {
667
+ if (prefs().sections.fallbackAccounts) return state().accounts;
668
+ return state().accounts.filter(account => account.current);
669
+ };
670
+ const activeId = () => resolveQuotaDialogActiveId(state(), props.sessionId);
671
+ return (() => {
672
+ var _el$27 = _$createElement("box"),
673
+ _el$28 = _$createElement("box"),
674
+ _el$29 = _$createElement("box"),
675
+ _el$30 = _$createElement("text"),
676
+ _el$31 = _$createElement("b");
677
+ _$insertNode(_el$27, _el$28);
678
+ _$setProp(_el$27, "flexDirection", 'column');
679
+ _$setProp(_el$27, "padding", 2);
680
+ _$setProp(_el$27, "width", '100%');
681
+ _$setProp(_el$27, "alignItems", 'center');
682
+ _$insertNode(_el$28, _el$29);
683
+ _$setProp(_el$28, "flexDirection", 'column');
684
+ _$setProp(_el$28, "width", 58);
685
+ _$insertNode(_el$29, _el$30);
686
+ _$setProp(_el$29, "width", '100%');
687
+ _$setProp(_el$29, "justifyContent", 'center');
688
+ _$setProp(_el$29, "marginBottom", 1);
689
+ _$insertNode(_el$30, _el$31);
690
+ _$insertNode(_el$31, _$createTextNode(`Antigravity Quota`));
691
+ _$insert(_el$28, _$createComponent(For, {
692
+ get each() {
693
+ return visibleAccounts();
694
+ },
695
+ children: (account, index) => _$createComponent(AccountBlock, {
696
+ theme: theme,
697
+ get appearance() {
698
+ return prefs().appearance;
699
+ },
700
+ account: account,
701
+ get active() {
702
+ return activeId() === account.id;
703
+ },
704
+ now: () => Date.now(),
705
+ get marginTop() {
706
+ return index() === 0 ? 0 : 1;
707
+ }
708
+ })
709
+ }), null);
710
+ _$effect(_$p => _$setProp(_el$30, "fg", theme().text, _$p));
711
+ return _el$27;
712
+ })();
713
+ }
714
+
715
+ // --- SidebarPanel ----------------------------------------------------------
716
+
717
+ export function SidebarPanel(props) {
718
+ const logger = resolveLogger(props.logger);
719
+ const now = props.now ?? (() => Date.now());
720
+ const pollMs = props.pollIntervalMs ?? POLL_INTERVAL_MS;
721
+ const controller = props.controller ?? getSidebarController();
722
+ const collapsed = controller.collapsed;
723
+ const prefs = controller.prefs;
724
+ // Live host theme — falls back to a sensible dark palette when the host
725
+ // does not expose one. Solid tracks `theme()` so a theme switch re-renders
726
+ // every styled span/border without a manual subscription.
727
+ const theme = () => props.theme?.() ?? FALLBACK_THEME;
728
+ const [state, setState] = createSignal({
729
+ loaded: EMPTY_STATE,
730
+ lastReadAt: 0,
731
+ lastError: null
732
+ });
733
+ const refresh = () => {
734
+ try {
735
+ const loaded = readSidebarState(props.stateFile);
736
+ setState({
737
+ loaded,
738
+ lastReadAt: now(),
739
+ lastError: null
740
+ });
741
+ } catch (error) {
742
+ logger.warn('sidebar-poll-failed', {
743
+ error: formatError(error)
744
+ });
745
+ setState(prev => ({
746
+ ...prev,
747
+ lastReadAt: now(),
748
+ lastError: formatError(error)
749
+ }));
750
+ }
751
+ };
752
+ onMount(() => {
753
+ refresh();
754
+ const interval = setInterval(refresh, pollMs);
755
+ onCleanup(() => clearInterval(interval));
756
+ });
757
+ const hasData = () => state().loaded.accounts.length > 0;
758
+ const backoffActive = () => {
759
+ const until = state().loaded.quotaBackoffUntil;
760
+ return typeof until === 'number' && until > now();
761
+ };
762
+ const lastError = () => state().lastError ?? state().loaded.lastError;
763
+ const degraded = () => backoffActive() || !!lastError();
764
+ // Honors sections.fallbackAccounts. Both the expanded (AccountBlock list)
765
+ // and the collapsed (CollapsedRow list) paths use the same filter so the
766
+ // user sees the same account set in either mode.
767
+ const visibleAccounts = () => {
768
+ const showFallback = prefs().sections.fallbackAccounts;
769
+ if (showFallback) return state().loaded.accounts;
770
+ return state().loaded.accounts.filter(account => account.current);
771
+ };
772
+ const currentRoute = () => {
773
+ const routes = state().loaded.activeRouting;
774
+ const entry = props.sessionId ? routes[props.sessionId] : Object.values(routes).sort((a, b) => b.updatedAt - a.updatedAt)[0];
775
+ if (!entry) return null;
776
+ return {
777
+ strategy: entry.strategy,
778
+ family: entry.modelFamily,
779
+ style: entry.headerStyle
780
+ };
781
+ };
782
+
783
+ // Header badge: ▼/▶ {label}. The fleet shows the version string on the
784
+ // right when no degraded state is present; the antigravity adapter keeps
785
+ // that right-alignment and surfaces `degraded` as a "LIMITED" badge
786
+ // instead of the "1/1 ready" count the previous revision rendered.
787
+ const headerLabel = () => {
788
+ const name = prefs().header.label;
789
+ return !hasData() ? name : collapsed() ? `\u25b6 ${name}` : `\u25bc ${name}`;
790
+ };
791
+ return (() => {
792
+ var _el$33 = _$createElement("box"),
793
+ _el$34 = _$createElement("box"),
794
+ _el$35 = _$createElement("box"),
795
+ _el$36 = _$createElement("text"),
796
+ _el$37 = _$createElement("b");
797
+ _$insertNode(_el$33, _el$34);
798
+ _$setProp(_el$33, "width", '100%');
799
+ _$setProp(_el$33, "flexDirection", 'column');
800
+ _$setProp(_el$33, "border", SINGLE_BORDER);
801
+ _$setProp(_el$33, "paddingTop", 1);
802
+ _$setProp(_el$33, "paddingBottom", 1);
803
+ _$setProp(_el$33, "paddingLeft", 1);
804
+ _$setProp(_el$33, "paddingRight", 1);
805
+ _$insertNode(_el$34, _el$35);
806
+ _$setProp(_el$34, "width", '100%');
807
+ _$setProp(_el$34, "flexDirection", 'row');
808
+ _$setProp(_el$34, "justifyContent", 'space-between');
809
+ _$setProp(_el$34, "alignItems", 'center');
810
+ _$setProp(_el$34, "onMouseDown", () => {
811
+ // Mirror the fleet guard: only toggle when there is data to expand
812
+ // into. Without this a click on the empty-awaiting header would just
813
+ // toggle the affordance for nothing.
814
+ if (hasData()) controller.toggleCollapsed();
815
+ });
816
+ _$insertNode(_el$35, _el$36);
817
+ _$setProp(_el$35, "paddingLeft", 1);
818
+ _$setProp(_el$35, "paddingRight", 1);
819
+ _$insertNode(_el$36, _el$37);
820
+ _$insert(_el$37, headerLabel);
821
+ _$insert(_el$34, _$createComponent(Show, {
822
+ get when() {
823
+ return degraded();
824
+ },
825
+ get fallback() {
826
+ return _$createComponent(Show, {
827
+ get when() {
828
+ return prefs().header.showVersion && PLUGIN_VERSION !== '';
829
+ },
830
+ get children() {
831
+ var _el$42 = _$createElement("text");
832
+ _$insert(_el$42, `v${PLUGIN_VERSION}`);
833
+ _$effect(_$p => _$setProp(_el$42, "fg", theme().textMuted, _$p));
834
+ return _el$42;
835
+ }
836
+ });
837
+ },
838
+ get children() {
839
+ var _el$38 = _$createElement("box"),
840
+ _el$39 = _$createElement("text"),
841
+ _el$40 = _$createElement("b");
842
+ _$insertNode(_el$38, _el$39);
843
+ _$setProp(_el$38, "paddingLeft", 1);
844
+ _$setProp(_el$38, "paddingRight", 1);
845
+ _$insertNode(_el$39, _el$40);
846
+ _$insertNode(_el$40, _$createTextNode(`LIMITED`));
847
+ _$effect(_p$ => {
848
+ var _v$10 = theme().warning,
849
+ _v$11 = theme().background;
850
+ _v$10 !== _p$.e && (_p$.e = _$setProp(_el$38, "backgroundColor", _v$10, _p$.e));
851
+ _v$11 !== _p$.t && (_p$.t = _$setProp(_el$39, "fg", _v$11, _p$.t));
852
+ return _p$;
853
+ }, {
854
+ e: undefined,
855
+ t: undefined
856
+ });
857
+ return _el$38;
858
+ }
859
+ }), null);
860
+ _$insert(_el$33, _$createComponent(Show, {
861
+ get when() {
862
+ return _$memo(() => !!collapsed())() && hasData();
863
+ },
864
+ get children() {
865
+ return (() => {
866
+ const account = () => visibleAccounts().find(entry => entry.current) ?? visibleAccounts()[0];
867
+ const used = () => {
868
+ const q = account()?.quota;
869
+ // Derive tone from the WORST (most-constrained) pool so a
870
+ // critical non-gemini pool doesn't hide behind a healthy
871
+ // gemini tone. Worst = highest used-percent across available pools.
872
+ const geminiUsed = q?.gemini != null ? 100 - clamp(q.gemini.remainingPercent, 0, 100) : null;
873
+ const nonGeminiUsed = q?.['non-gemini'] != null ? 100 - clamp(q['non-gemini'].remainingPercent, 0, 100) : null;
874
+ if (geminiUsed === null && nonGeminiUsed === null) return null;
875
+ return Math.max(geminiUsed ?? 0, nonGeminiUsed ?? 0);
876
+ };
877
+ const poolText = key => {
878
+ const entry = account()?.quota[key];
879
+ if (!entry) return `${QUOTA_LABELS[key]}: —`;
880
+ const pct = Math.round(100 - clamp(entry.remainingPercent, 0, 100));
881
+ // Show binding window when available, else just pool label.
882
+ const bindingWindow = entry.windows?.reduce((best, w) => best === null || w.remainingPercent < best.remainingPercent ? w : best, null);
883
+ const gutter = bindingWindow ? ` ${WINDOW_GUTTER[bindingWindow.window] ?? bindingWindow.window}` : '';
884
+ return `${QUOTA_LABELS[key]}${gutter}: ${pct}%`;
885
+ };
886
+ const unavailable = () => {
887
+ const selected = account();
888
+ return selected != null && (!selected.enabled || selected.cooldownUntil != null && selected.cooldownUntil > now());
889
+ };
890
+ return _$createComponent(Show, {
891
+ get when() {
892
+ return account();
893
+ },
894
+ children: selected => _$createComponent(CollapsedRow, {
895
+ theme: theme,
896
+ get label() {
897
+ return selected().label;
898
+ },
899
+ get children() {
900
+ var _el$43 = _$createElement("box"),
901
+ _el$44 = _$createElement("text"),
902
+ _el$45 = _$createElement("b"),
903
+ _el$46 = _$createElement("text");
904
+ _$insertNode(_el$43, _el$44);
905
+ _$insertNode(_el$43, _el$46);
906
+ _$setProp(_el$43, "flexDirection", 'row');
907
+ _$insertNode(_el$44, _el$45);
908
+ _$insert(_el$45, (() => {
909
+ var _c$ = _$memo(() => !!(account()?.quota.gemini == null && account()?.quota['non-gemini'] == null));
910
+ return () => _c$() ? '—' : `${poolText('gemini')} · ${poolText('non-gemini')}`;
911
+ })());
912
+ _$insert(_el$46, () => unavailable() ? ' ⊘' : ' ●');
913
+ _$effect(_p$ => {
914
+ var _v$15 = toneColor(theme(), used() == null ? 'muted' : quotaTone(used() ?? 0, prefs().appearance)),
915
+ _v$16 = toneColor(theme(), unavailable() ? 'err' : quotaTone(used() ?? 0, prefs().appearance));
916
+ _v$15 !== _p$.e && (_p$.e = _$setProp(_el$44, "fg", _v$15, _p$.e));
917
+ _v$16 !== _p$.t && (_p$.t = _$setProp(_el$46, "fg", _v$16, _p$.t));
918
+ return _p$;
919
+ }, {
920
+ e: undefined,
921
+ t: undefined
922
+ });
923
+ return _el$43;
924
+ }
925
+ })
926
+ });
927
+ })();
928
+ }
929
+ }), null);
930
+ _$insert(_el$33, _$createComponent(Show, {
931
+ get when() {
932
+ return !collapsed() || !hasData();
933
+ },
934
+ get children() {
935
+ return _$createComponent(Show, {
936
+ get when() {
937
+ return hasData();
938
+ },
939
+ get fallback() {
940
+ return (() => {
941
+ var _el$47 = _$createElement("box"),
942
+ _el$48 = _$createElement("text");
943
+ _$insertNode(_el$47, _el$48);
944
+ _$setProp(_el$47, "marginTop", 1);
945
+ _$setProp(_el$47, "width", '100%');
946
+ _$insertNode(_el$48, _$createTextNode(`Waiting for quota…`));
947
+ _$effect(_$p => _$setProp(_el$48, "fg", theme().textMuted, _$p));
948
+ return _el$47;
949
+ })();
950
+ },
951
+ get children() {
952
+ return [_$createComponent(Show, {
953
+ get when() {
954
+ return prefs().sections.quota;
955
+ },
956
+ get children() {
957
+ return [_$createComponent(SectionHeader, {
958
+ theme: theme,
959
+ title: "Quota"
960
+ }), _$createComponent(For, {
961
+ get each() {
962
+ return visibleAccounts();
963
+ },
964
+ children: (account, index) => _$createComponent(AccountBlock, {
965
+ theme: theme,
966
+ get appearance() {
967
+ return prefs().appearance;
968
+ },
969
+ account: account,
970
+ now: now,
971
+ get marginTop() {
972
+ return index() === 0 ? 0 : 1;
973
+ }
974
+ })
975
+ })];
976
+ }
977
+ }), _$createComponent(Show, {
978
+ get when() {
979
+ return prefs().sections.routing;
980
+ },
981
+ get children() {
982
+ return [_$createComponent(SectionHeader, {
983
+ theme: theme,
984
+ title: "Routing"
985
+ }), _$createComponent(Show, {
986
+ get when() {
987
+ return currentRoute();
988
+ },
989
+ get fallback() {
990
+ return _$createComponent(StatRow, {
991
+ theme: theme,
992
+ label: "Route",
993
+ value: "\u2014",
994
+ tone: "muted"
995
+ });
996
+ },
997
+ children: route => _$createComponent(StatRow, {
998
+ theme: theme,
999
+ label: "Route",
1000
+ get value() {
1001
+ return `${route().strategy ? `${route().strategy} · ` : ''}${route().family}: ${route().style}`;
1002
+ },
1003
+ tone: "accent"
1004
+ })
1005
+ })];
1006
+ }
1007
+ }), _$createComponent(Show, {
1008
+ get when() {
1009
+ return _$memo(() => !!degraded())() && prefs().sections.health;
1010
+ },
1011
+ get children() {
1012
+ return [_$createComponent(SectionHeader, {
1013
+ theme: theme,
1014
+ title: "Health"
1015
+ }), _$createComponent(Show, {
1016
+ get when() {
1017
+ return backoffActive();
1018
+ },
1019
+ get children() {
1020
+ return _$createComponent(StatRow, {
1021
+ theme: theme,
1022
+ label: "Quota API",
1023
+ get value() {
1024
+ return `backoff ${formatResetIn(state().loaded.quotaBackoffUntil, now)}`;
1025
+ },
1026
+ tone: "warn"
1027
+ });
1028
+ }
1029
+ }), _$createComponent(Show, {
1030
+ get when() {
1031
+ return lastError();
1032
+ },
1033
+ get children() {
1034
+ return _$createComponent(StatRow, {
1035
+ theme: theme,
1036
+ label: "Last error",
1037
+ get value() {
1038
+ return lastError() ?? '';
1039
+ },
1040
+ tone: "err"
1041
+ });
1042
+ }
1043
+ })];
1044
+ }
1045
+ })];
1046
+ }
1047
+ });
1048
+ }
1049
+ }), null);
1050
+ _$effect(_p$ => {
1051
+ var _v$12 = theme().borderActive,
1052
+ _v$13 = theme().accent,
1053
+ _v$14 = theme().background;
1054
+ _v$12 !== _p$.e && (_p$.e = _$setProp(_el$33, "borderColor", _v$12, _p$.e));
1055
+ _v$13 !== _p$.t && (_p$.t = _$setProp(_el$35, "backgroundColor", _v$13, _p$.t));
1056
+ _v$14 !== _p$.a && (_p$.a = _$setProp(_el$36, "fg", _v$14, _p$.a));
1057
+ return _p$;
1058
+ }, {
1059
+ e: undefined,
1060
+ t: undefined,
1061
+ a: undefined
1062
+ });
1063
+ return _el$33;
1064
+ })();
1065
+ }
1066
+
1067
+ /**
1068
+ * Solid slot registry binding exposed for hosts that want to mount the
1069
+ * sidebar inside their renderer. Hosts that already own a slot registry can
1070
+ * use `createSlot` directly; we re-export for convenience and to keep the
1071
+ * contract visible at the module entry point.
1072
+ */
1073
+ export const sidebar_content = createSlot;
1074
+ export function startRpcNotificationPolling(options) {
1075
+ if (rpcPollStarted) return;
1076
+ rpcPollStarted = true;
1077
+ options.schedule(async () => {
1078
+ if (rpcInFlight) return;
1079
+ rpcInFlight = true;
1080
+ try {
1081
+ const sessionId = options.currentSessionId();
1082
+ const cursorKey = sessionId ?? GLOBAL_NOTIFICATION_CURSOR;
1083
+ let cursor = notificationCursorBySession.get(cursorKey) ?? 0;
1084
+ const notifications = await options.pending(cursor, sessionId);
1085
+ for (const notification of [...notifications].sort((a, b) => a.id - b.id)) {
1086
+ if (notification.id <= cursor) continue;
1087
+ cursor = Math.max(cursor, notification.id);
1088
+ if (dispatchedNotificationIds.has(notification.id)) continue;
1089
+ dispatchedNotificationIds.add(notification.id);
1090
+ if (dispatchedNotificationIds.size > 100) {
1091
+ const oldestId = dispatchedNotificationIds.values().next().value;
1092
+ if (oldestId !== undefined) dispatchedNotificationIds.delete(oldestId);
1093
+ }
1094
+ await options.dispatch(notification);
1095
+ }
1096
+ if (!notificationCursorBySession.has(cursorKey)) {
1097
+ while (notificationCursorBySession.size >= MAX_NOTIFICATION_CURSORS) {
1098
+ const oldest = notificationCursorBySession.keys().next().value;
1099
+ if (oldest === undefined) break;
1100
+ notificationCursorBySession.delete(oldest);
1101
+ }
1102
+ }
1103
+ notificationCursorBySession.set(cursorKey, cursor);
1104
+ } catch (error) {
1105
+ // Surface the swallowed error through the file logger rather than
1106
+ // stdout/stderr (the host terminal is the frame buffer — any byte
1107
+ // written here corrupts every subsequent cell). Without this, a
1108
+ // transient RPC outage is invisible to operators. The catch stays
1109
+ // because one failed poll must never break the next — the scheduler
1110
+ // is a setInterval and a thrown error there would crash the
1111
+ // process.
1112
+ options.logger.warn('rpc-poll-failed', {
1113
+ error: error instanceof Error ? error.message : String(error)
1114
+ });
1115
+ } finally {
1116
+ rpcInFlight = false;
1117
+ }
1118
+ }, RPC_POLL_MS);
1119
+ }
1120
+ const tui = async api => {
1121
+ const logger = resolveLogger(undefined);
1122
+ const prefsRoot = await readTuiPreferencesFile();
1123
+ if (!sidebarController) {
1124
+ sidebarController = createSidebarController(resolveAntigravityAuthPrefs(prefsRoot));
1125
+ }
1126
+ const rpcClient = createRpcClient(getRpcDir(api.state.path.directory ?? ''), process.pid);
1127
+ startRpcNotificationPolling({
1128
+ pending: (lastReceivedId, sessionId) => rpcClient.pendingNotifications(lastReceivedId, sessionId),
1129
+ currentSessionId: () => {
1130
+ const current = api.route.current;
1131
+ const resolved = typeof current === 'function' ? current() : current;
1132
+ return resolved?.params?.sessionID;
1133
+ },
1134
+ dispatch: async notification => {
1135
+ logger.debug('rpc-notification-received', {
1136
+ command: notification.payload.command,
1137
+ id: notification.id,
1138
+ sessionId: notification.sessionId
1139
+ });
1140
+ // Call the imperative dispatcher directly — the prior
1141
+ // two-phase `collectDialogFlow` + `renderDialogFlow` is gone.
1142
+ // The dispatcher awaits `apply`, toasts the result, then clears
1143
+ // (or replaces for multi-step flows). The RPC `apply` accepts the
1144
+ // optional `timeoutMs` knob so account add / refresh can opt into
1145
+ // the 120s RPC timeout without the dialog layer having to know
1146
+ // about it.
1147
+ if (notification.payload.command === 'antigravity-quota') {
1148
+ api.ui.dialog.setSize('xlarge');
1149
+ api.ui.dialog.replace(() => _$createComponent(QuotaDialogContent, {
1150
+ api: api,
1151
+ get controller() {
1152
+ return getSidebarController();
1153
+ },
1154
+ get sessionId() {
1155
+ return notification.sessionId;
1156
+ }
1157
+ }));
1158
+ return;
1159
+ }
1160
+ openCommandDialog(api, notification.payload, (command, args, options) => rpcClient.apply({
1161
+ command,
1162
+ arguments: args,
1163
+ sessionId: notification.sessionId
1164
+ }, options));
1165
+ },
1166
+ schedule: (poll, intervalMs) => {
1167
+ setInterval(() => void poll(), intervalMs);
1168
+ },
1169
+ logger
1170
+ });
1171
+
1172
+ // The host supplies the live theme via `api.theme.current` — the slot
1173
+ // callback's closure captures `api` so the accessor always reads the
1174
+ // current theme. A Solid re-render follows whenever the user switches.
1175
+ const liveTheme = () => api.theme.current;
1176
+ api.slots.register({
1177
+ order: computeEffectiveOrder(prefsRoot, PLUGIN_KEY, DEFAULT_SLOT_ORDER),
1178
+ slots: {
1179
+ sidebar_content: (_context, {
1180
+ session_id: sessionId
1181
+ }) => _$createComponent(SidebarPanel, {
1182
+ logger: logger,
1183
+ theme: liveTheme,
1184
+ sessionId: sessionId
1185
+ })
1186
+ }
1187
+ });
1188
+ };
1189
+ const plugin = {
1190
+ id: ID,
1191
+ tui
1192
+ };
1193
+ export default plugin;