clikcode 1.0.3 → 1.0.5

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 (323) hide show
  1. package/README.md +25 -14
  2. package/dist/chunk-23TDEBGZ.js +71 -0
  3. package/dist/chunk-25T3GVS7.js +425 -0
  4. package/dist/chunk-2BBELGHY.js +11 -0
  5. package/dist/chunk-2EOL5PZL.js +208 -0
  6. package/dist/chunk-2GAB36IE.js +26 -0
  7. package/dist/chunk-2OLS7V66.js +2440 -0
  8. package/dist/chunk-2QFO2URB.js +179 -0
  9. package/dist/chunk-2QWPQRSU.js +254 -0
  10. package/dist/chunk-2YPAPAR3.js +184 -0
  11. package/dist/chunk-2ZAG5372.js +33 -0
  12. package/dist/chunk-32IKAIZC.js +12507 -0
  13. package/dist/chunk-34AZEGYW.js +95 -0
  14. package/dist/chunk-34JQYQCA.js +175 -0
  15. package/dist/chunk-34ZISPAO.js +67 -0
  16. package/dist/chunk-3AAAARE6.js +46 -0
  17. package/dist/chunk-3AJ6Q3OY.js +510 -0
  18. package/dist/chunk-3B2CHX7M.js +884 -0
  19. package/dist/chunk-3BUFORRX.js +59 -0
  20. package/dist/chunk-3QLHYYFK.js +30 -0
  21. package/dist/chunk-3RXBMYKZ.js +140 -0
  22. package/dist/chunk-3TFNIJWS.js +52 -0
  23. package/dist/chunk-3W3IPDFP.js +119 -0
  24. package/dist/chunk-3WMS7SEE.js +417 -0
  25. package/dist/chunk-435ZNSZ3.js +23 -0
  26. package/dist/chunk-4AQ5NINV.js +39 -0
  27. package/dist/chunk-4GVEJ5FK.js +168 -0
  28. package/dist/chunk-4GXAO3UY.js +262 -0
  29. package/dist/chunk-4L2ZZM4Q.js +332 -0
  30. package/dist/chunk-4LPDG57B.js +17 -0
  31. package/dist/chunk-4NN3XQQT.js +223 -0
  32. package/dist/chunk-4QZEZME7.js +54 -0
  33. package/dist/chunk-4R6CSC3S.js +38 -0
  34. package/dist/chunk-4RHXTL3W.js +514 -0
  35. package/dist/chunk-4SJMPTVQ.js +18 -0
  36. package/dist/chunk-4VY7G6TX.js +114 -0
  37. package/dist/chunk-5642PBF7.js +124 -0
  38. package/dist/chunk-5B6TVO4A.js +33 -0
  39. package/dist/chunk-5BJLDUPL.js +62 -0
  40. package/dist/chunk-5HMFFJWU.js +19 -0
  41. package/dist/chunk-5IKLK33T.js +69 -0
  42. package/dist/chunk-5NQ5FFMX.js +44 -0
  43. package/dist/chunk-5QNNW5L6.js +176 -0
  44. package/dist/chunk-5SM5UAWN.js +239 -0
  45. package/dist/chunk-5WYJTA6O.js +74 -0
  46. package/dist/chunk-5ZSR2Y5T.js +227 -0
  47. package/dist/chunk-5ZWUM5GH.js +39 -0
  48. package/dist/chunk-64E7D4HY.js +364 -0
  49. package/dist/chunk-6CK466BC.js +99 -0
  50. package/dist/chunk-6ES45HHO.js +138 -0
  51. package/dist/chunk-6HYEZFGL.js +277 -0
  52. package/dist/chunk-6Y7HLXGW.js +29 -0
  53. package/dist/chunk-6YKK4FYR.js +258 -0
  54. package/dist/chunk-74WNMLMS.js +117 -0
  55. package/dist/chunk-7AULZ7OD.js +55 -0
  56. package/dist/chunk-7DOKGSUN.js +101 -0
  57. package/dist/chunk-7IH5LTIZ.js +195 -0
  58. package/dist/chunk-7ISTS5NS.js +21 -0
  59. package/dist/chunk-7NMUTGOW.js +527 -0
  60. package/dist/chunk-7PNHUZEL.js +153 -0
  61. package/dist/chunk-7TSQLONI.js +88 -0
  62. package/dist/chunk-AE7TOLD5.js +30 -0
  63. package/dist/chunk-AEMHSXKA.js +130 -0
  64. package/dist/chunk-AKRYTS2D.js +211 -0
  65. package/dist/chunk-AMNSE36L.js +59 -0
  66. package/dist/chunk-AZVD74ZV.js +23 -0
  67. package/dist/chunk-B35DVOTK.js +1981 -0
  68. package/dist/chunk-B4HNJRAH.js +626 -0
  69. package/dist/chunk-B5WYPPHS.js +13 -0
  70. package/dist/chunk-BBOVDXQM.js +59 -0
  71. package/dist/chunk-BD3ECZLK.js +62 -0
  72. package/dist/chunk-BDGSOT74.js +4578 -0
  73. package/dist/chunk-BF5VEOPK.js +31 -0
  74. package/dist/chunk-BFFRW4XH.js +47 -0
  75. package/dist/chunk-BFPC6PEW.js +208 -0
  76. package/dist/chunk-BGEMY2JJ.js +376 -0
  77. package/dist/chunk-BISGNHKD.js +35 -0
  78. package/dist/chunk-BMRAEBRY.js +21 -0
  79. package/dist/chunk-BNTXAZXW.js +127 -0
  80. package/dist/chunk-BOQBXGSN.js +75 -0
  81. package/dist/chunk-BTJDSTQP.js +213 -0
  82. package/dist/chunk-BUOPJQP5.js +218 -0
  83. package/dist/chunk-BXFJS65Q.js +52 -0
  84. package/dist/chunk-BXPQFSX5.js +59 -0
  85. package/dist/chunk-C57LIWNY.js +1269 -0
  86. package/dist/chunk-C6YVCCWR.js +74 -0
  87. package/dist/chunk-CAADDF6M.js +167 -0
  88. package/dist/chunk-CBANJFBO.js +69 -0
  89. package/dist/chunk-CERF3RIB.js +597 -0
  90. package/dist/chunk-COAS5ETR.js +46 -0
  91. package/dist/chunk-CQ7J6UQ7.js +78 -0
  92. package/dist/chunk-CRUVYGO2.js +26 -0
  93. package/dist/chunk-CVFVFRGN.js +58 -0
  94. package/dist/chunk-D2UK66HM.js +37 -0
  95. package/dist/chunk-D2W7SA4R.js +18 -0
  96. package/dist/chunk-DA44ZENT.js +501 -0
  97. package/dist/chunk-DAJ76TOC.js +99 -0
  98. package/dist/chunk-DCZ6CIUM.js +147 -0
  99. package/dist/chunk-DF35KMXM.js +1314 -0
  100. package/dist/chunk-DGASQT26.js +151 -0
  101. package/dist/chunk-DJT57C5P.js +55 -0
  102. package/dist/chunk-DKDPZTD3.js +44 -0
  103. package/dist/chunk-DQYVQ2N7.js +77 -0
  104. package/dist/chunk-DRTP2RTY.js +266 -0
  105. package/dist/chunk-DW2BMUKY.js +61 -0
  106. package/dist/chunk-DW5T5ZVU.js +307 -0
  107. package/dist/chunk-DXKNDNFC.js +164 -0
  108. package/dist/chunk-DZEQ7UYR.js +291 -0
  109. package/dist/chunk-E4F4OUAC.js +463 -0
  110. package/dist/chunk-EE4B6A7W.js +69 -0
  111. package/dist/chunk-EISKIYWG.js +23 -0
  112. package/dist/chunk-EKAQK7UQ.js +235 -0
  113. package/dist/chunk-EOBTJV32.js +123 -0
  114. package/dist/chunk-ESF3DIZY.js +325 -0
  115. package/dist/chunk-EVOHOZ4U.js +45 -0
  116. package/dist/chunk-EXN4KHLB.js +110 -0
  117. package/dist/chunk-F252T6Y3.js +78 -0
  118. package/dist/chunk-F3DP4ZA2.js +40 -0
  119. package/dist/chunk-F6F47QAY.js +58 -0
  120. package/dist/chunk-FA3Y23ZW.js +57 -0
  121. package/dist/chunk-FBKXE4EJ.js +640 -0
  122. package/dist/chunk-FCGEB3H6.js +23 -0
  123. package/dist/chunk-FF7ZVYJF.js +3732 -0
  124. package/dist/chunk-FFGKN6L3.js +39 -0
  125. package/dist/chunk-FFGU4GCC.js +94 -0
  126. package/dist/chunk-FSFDAOVP.js +74 -0
  127. package/dist/chunk-FT5TX7OX.js +1573 -0
  128. package/dist/chunk-G3QP67Z7.js +232 -0
  129. package/dist/chunk-G5ORJKV2.js +179 -0
  130. package/dist/chunk-GFNC62PE.js +111 -0
  131. package/dist/chunk-GGK43Q3N.js +67 -0
  132. package/dist/chunk-GGYKY4GF.js +11537 -0
  133. package/dist/chunk-GGYNHGNJ.js +55 -0
  134. package/dist/chunk-GLY7RM3C.js +354 -0
  135. package/dist/chunk-GQBZU6EO.js +20 -0
  136. package/dist/chunk-GSXENUZL.js +9 -0
  137. package/dist/chunk-GTOAT5D3.js +40 -0
  138. package/dist/chunk-GWCMDPQU.js +1007 -0
  139. package/dist/chunk-GXYSMYHJ.js +152 -0
  140. package/dist/chunk-GYMAI5NY.js +14 -0
  141. package/dist/chunk-H2VZMKPE.js +30 -0
  142. package/dist/chunk-H4THUNBM.js +2091 -0
  143. package/dist/chunk-HGRVSNUZ.js +361 -0
  144. package/dist/chunk-HI4VY473.js +27 -0
  145. package/dist/chunk-HOJRSD3Q.js +447 -0
  146. package/dist/chunk-HRX25W35.js +82 -0
  147. package/dist/chunk-HSE4AQYV.js +55 -0
  148. package/dist/chunk-HU5SSUFX.js +383 -0
  149. package/dist/chunk-I3GDBJLH.js +196 -0
  150. package/dist/chunk-I75EDU75.js +684 -0
  151. package/dist/chunk-IBA7DMIO.js +20 -0
  152. package/dist/chunk-IC6N4NZA.js +231 -0
  153. package/dist/chunk-IF43HIGV.js +284 -0
  154. package/dist/chunk-IGZ6C2MC.js +439 -0
  155. package/dist/chunk-IMLTL2MY.js +192 -0
  156. package/dist/chunk-IMZL6SGR.js +33 -0
  157. package/dist/chunk-IS4USJPY.js +516 -0
  158. package/dist/chunk-ISFSPN2F.js +82 -0
  159. package/dist/chunk-IXE7GTFI.js +55 -0
  160. package/dist/chunk-IZ77QJQG.js +36 -0
  161. package/dist/chunk-J2PACWRQ.js +34 -0
  162. package/dist/chunk-J6EGFVQX.js +180 -0
  163. package/dist/chunk-JEKOD43D.js +22 -0
  164. package/dist/chunk-JGIWATSG.js +30 -0
  165. package/dist/chunk-JYBONKD4.js +43 -0
  166. package/dist/chunk-K2NLG2HK.js +454 -0
  167. package/dist/chunk-KCQ4TBLS.js +164 -0
  168. package/dist/chunk-KD5KIVMS.js +176 -0
  169. package/dist/chunk-KHW6TX6I.js +63 -0
  170. package/dist/chunk-KI5GZFCE.js +520 -0
  171. package/dist/chunk-KN34B7NO.js +105 -0
  172. package/dist/chunk-KYUHIFP3.js +136 -0
  173. package/dist/chunk-KZL5VS4B.js +300 -0
  174. package/dist/chunk-L3VW3QIH.js +48 -0
  175. package/dist/chunk-LA6MG4ET.js +2110 -0
  176. package/dist/chunk-LAVFOA3S.js +66 -0
  177. package/dist/chunk-LB4OA77N.js +13 -0
  178. package/dist/chunk-LBFRF2K4.js +196 -0
  179. package/dist/chunk-LM6EIA4B.js +93 -0
  180. package/dist/chunk-LPCNRGJ7.js +692 -0
  181. package/dist/chunk-LSLNL5T3.js +168 -0
  182. package/dist/chunk-LVRRWP4W.js +568 -0
  183. package/dist/chunk-LWCFBRHL.js +33 -0
  184. package/dist/chunk-LXFTMGZZ.js +166 -0
  185. package/dist/chunk-M33LVA4M.js +151 -0
  186. package/dist/chunk-M3FO5UMK.js +4944 -0
  187. package/dist/chunk-M5QNDBAY.js +66 -0
  188. package/dist/chunk-M6ND6KBE.js +1291 -0
  189. package/dist/chunk-M7H3WQTE.js +76 -0
  190. package/dist/chunk-MCBRVPA7.js +191 -0
  191. package/dist/chunk-MCSDWZET.js +91 -0
  192. package/dist/chunk-MDT5XDXL.js +289 -0
  193. package/dist/chunk-MJG3IQY4.js +91 -0
  194. package/dist/chunk-MOU3N2UL.js +44 -0
  195. package/dist/chunk-MP4KZOQC.js +3451 -0
  196. package/dist/chunk-MPAJ446F.js +66 -0
  197. package/dist/chunk-MVJZZ6AL.js +16 -0
  198. package/dist/chunk-MXS6S2PY.js +253 -0
  199. package/dist/chunk-N3SFDYM7.js +291 -0
  200. package/dist/chunk-NAOX3JUB.js +13 -0
  201. package/dist/chunk-NEKKIBCX.js +283 -0
  202. package/dist/chunk-NKDATMEM.js +133 -0
  203. package/dist/chunk-NR4FMC4K.js +395 -0
  204. package/dist/chunk-NSOHOJBR.js +221 -0
  205. package/dist/chunk-NTDB6QKF.js +29 -0
  206. package/dist/chunk-NWEYRBWK.js +25 -0
  207. package/dist/chunk-O2YSNYWD.js +23 -0
  208. package/dist/chunk-O3EW7LAY.js +54 -0
  209. package/dist/chunk-O7BNJIXU.js +366 -0
  210. package/dist/chunk-OARL2NXZ.js +116 -0
  211. package/dist/chunk-OHKZUEJW.js +351 -0
  212. package/dist/chunk-OKU45BXA.js +647 -0
  213. package/dist/chunk-OL4JBD3J.js +59 -0
  214. package/dist/chunk-OLUO5DDR.js +192 -0
  215. package/dist/chunk-OQ245JLA.js +196 -0
  216. package/dist/chunk-P72UZAQI.js +289 -0
  217. package/dist/chunk-PAL2ENB6.js +20 -0
  218. package/dist/chunk-PAXYQZH7.js +53 -0
  219. package/dist/chunk-PDPEM5VW.js +51 -0
  220. package/dist/chunk-PEWCDI2C.js +668 -0
  221. package/dist/chunk-PGZ54EDX.js +27 -0
  222. package/dist/chunk-PRWVLDZF.js +73 -0
  223. package/dist/chunk-PSQQ75VJ.js +52 -0
  224. package/dist/chunk-PUOVIFHW.js +118 -0
  225. package/dist/chunk-PWBF2X3V.js +107 -0
  226. package/dist/chunk-PWXII6HF.js +43 -0
  227. package/dist/chunk-Q35VLJRT.js +80 -0
  228. package/dist/chunk-QJP7EYGL.js +128 -0
  229. package/dist/chunk-QPQKX2MK.js +8836 -0
  230. package/dist/chunk-QQRLPY25.js +1053 -0
  231. package/dist/chunk-QUS4ER2W.js +407 -0
  232. package/dist/chunk-QYHI3YET.js +29 -0
  233. package/dist/chunk-QYRU2UQI.js +32 -0
  234. package/dist/chunk-R6XVVQGC.js +13 -0
  235. package/dist/chunk-R7QN6ONS.js +483 -0
  236. package/dist/chunk-RD23MPGC.js +221 -0
  237. package/dist/chunk-RDDWQBEM.js +185 -0
  238. package/dist/chunk-RDLLDYFO.js +104 -0
  239. package/dist/chunk-RE4TGORR.js +84 -0
  240. package/dist/chunk-RJLHVYQY.js +217 -0
  241. package/dist/chunk-RJLPTWHW.js +905 -0
  242. package/dist/chunk-RKUVLRZI.js +295 -0
  243. package/dist/chunk-ROGXPGYR.js +37 -0
  244. package/dist/chunk-RSZGEL5U.js +163 -0
  245. package/dist/chunk-RVUOIJXN.js +909 -0
  246. package/dist/chunk-RW7F4JRP.js +11 -0
  247. package/dist/chunk-S4UO3AO3.js +53 -0
  248. package/dist/chunk-S5JAAF6S.js +585 -0
  249. package/dist/chunk-SNU37TQI.js +56 -0
  250. package/dist/chunk-SQVUDO2O.js +31 -0
  251. package/dist/chunk-SYVHIYQT.js +66 -0
  252. package/dist/chunk-SZBQMTG2.js +85 -0
  253. package/dist/chunk-T5VCXA3J.js +25 -0
  254. package/dist/chunk-TK6NSP56.js +30 -0
  255. package/dist/chunk-TKWVMA6L.js +22 -0
  256. package/dist/chunk-TQDKJHWX.js +59 -0
  257. package/dist/chunk-TQDM7S5N.js +127 -0
  258. package/dist/chunk-TULAXS77.js +23 -0
  259. package/dist/chunk-TVT45XNH.js +4625 -0
  260. package/dist/chunk-TWCVV2JO.js +467 -0
  261. package/dist/chunk-U4DKAD6S.js +47 -0
  262. package/dist/chunk-UA5K2BTI.js +564 -0
  263. package/dist/chunk-UAMKCMOK.js +40 -0
  264. package/dist/chunk-UBMVADBF.js +51 -0
  265. package/dist/chunk-UFQ5A5PW.js +645 -0
  266. package/dist/chunk-UOD2SOLL.js +1301 -0
  267. package/dist/chunk-UTSB4LOW.js +156 -0
  268. package/dist/chunk-UVXNIUTN.js +412 -0
  269. package/dist/chunk-UXVPXYPE.js +90 -0
  270. package/dist/chunk-UYEEMIWR.js +374 -0
  271. package/dist/chunk-VBGM5ZBW.js +54 -0
  272. package/dist/chunk-VEWPCZPG.js +762 -0
  273. package/dist/chunk-VIRDLZ5E.js +108 -0
  274. package/dist/chunk-VMPO7WKN.js +52 -0
  275. package/dist/chunk-W2NVSDO5.js +5122 -0
  276. package/dist/chunk-W3YYPBEA.js +176 -0
  277. package/dist/chunk-W5AYOICN.js +280 -0
  278. package/dist/chunk-W5GZOIUF.js +27 -0
  279. package/dist/chunk-WHKNLZ3C.js +76 -0
  280. package/dist/chunk-WKBEPPQ5.js +1409 -0
  281. package/dist/chunk-WM3Z6QKQ.js +151 -0
  282. package/dist/chunk-WMI2TPMA.js +31 -0
  283. package/dist/chunk-WNX5VD7S.js +150 -0
  284. package/dist/chunk-WOVTYST3.js +60 -0
  285. package/dist/chunk-WPB5WEZJ.js +546 -0
  286. package/dist/chunk-WUO5EOAT.js +44 -0
  287. package/dist/chunk-WWLJMP6D.js +133 -0
  288. package/dist/chunk-WZMLH3XP.js +58 -0
  289. package/dist/chunk-WZYVLUVQ.js +79 -0
  290. package/dist/chunk-X2OCPVU5.js +135 -0
  291. package/dist/chunk-X3CL6DTR.js +95 -0
  292. package/dist/chunk-X6WF7JEV.js +354 -0
  293. package/dist/chunk-XAHGBPWT.js +44 -0
  294. package/dist/chunk-XCKQ5BM2.js +228 -0
  295. package/dist/chunk-XIBYREEY.js +106 -0
  296. package/dist/chunk-XKW5NDMR.js +378 -0
  297. package/dist/chunk-XRDALAO3.js +100 -0
  298. package/dist/chunk-XUP22EAS.js +41 -0
  299. package/dist/chunk-XWAC3MKW.js +243 -0
  300. package/dist/chunk-Y3R7JMXB.js +59 -0
  301. package/dist/chunk-Y54LTP4W.js +82 -0
  302. package/dist/chunk-Y7UECI4M.js +99 -0
  303. package/dist/chunk-YACGDFHC.js +47 -0
  304. package/dist/chunk-YHNIQPKY.js +71 -0
  305. package/dist/chunk-YMBR6HYP.js +111 -0
  306. package/dist/chunk-YMCH3L2S.js +26 -0
  307. package/dist/chunk-Z4ZU6T7V.js +99 -0
  308. package/dist/chunk-ZDPF67ZZ.js +173 -0
  309. package/dist/chunk-ZFC2Q67K.js +101 -0
  310. package/dist/chunk-ZGHNNSCT.js +114 -0
  311. package/dist/chunk-ZGX3ERAT.js +173 -0
  312. package/dist/chunk-ZI3YHEBY.js +37 -0
  313. package/dist/chunk-ZN7G6JLS.js +639 -0
  314. package/dist/chunk-ZNPFQMXT.js +47 -0
  315. package/dist/chunk-ZOU3LV4U.js +63 -0
  316. package/dist/chunk-ZT7B4H2V.js +117 -0
  317. package/dist/chunk-ZZCBDNZI.js +58 -0
  318. package/dist/cli.js +498 -112593
  319. package/dist/computer-tools.js +36642 -21258
  320. package/dist/harness-catalog.cjs +88 -43
  321. package/dist/index.js +1 -1
  322. package/dist/local-model-supervisor.cjs +555 -0
  323. package/package.json +3 -4
@@ -0,0 +1,501 @@
1
+ import { createRequire as __clikcodeCreateRequire } from 'node:module';
2
+ const require = __clikcodeCreateRequire(import.meta.url);
3
+ import {
4
+ usageReading,
5
+ usageWindow
6
+ } from "./chunk-XWAC3MKW.js";
7
+ import {
8
+ acpDiscoverySession,
9
+ queryAcp
10
+ } from "./chunk-ESF3DIZY.js";
11
+ import {
12
+ localHarnessForCommand
13
+ } from "./chunk-KYUHIFP3.js";
14
+ import {
15
+ PROBE_DEADLINE_MS,
16
+ mayRunSignInCapable,
17
+ probeCommand,
18
+ probeFetch,
19
+ probeVendor,
20
+ queryJsonRpc,
21
+ resolveBinaryPath
22
+ } from "./chunk-DF35KMXM.js";
23
+ import {
24
+ stripAnsi
25
+ } from "./chunk-G3QP67Z7.js";
26
+ import {
27
+ quiet
28
+ } from "./chunk-RDDWQBEM.js";
29
+
30
+ // src/harness/accounts/free-plan.ts
31
+ function planIsFree(plan) {
32
+ return Boolean(plan && /free/i.test(plan.name));
33
+ }
34
+ function baseModel(model) {
35
+ return model.replace(/\[[^\]]*\]$/, "");
36
+ }
37
+ function freePlanModels(harness, account, catalog) {
38
+ const free = new Set(catalog.free ?? []);
39
+ const suffix = harness?.freePlan?.suffix;
40
+ if (suffix) {
41
+ for (const model of catalog.models) if (model.endsWith(suffix)) free.add(model);
42
+ }
43
+ if (planIsFree(account?.plan)) {
44
+ const named = account.plan.models;
45
+ for (const model of catalog.models) {
46
+ if (named ? named.includes(baseModel(model)) : harness?.freePlan?.listed) free.add(model);
47
+ }
48
+ }
49
+ return free;
50
+ }
51
+ function preferredFreeModel(free) {
52
+ const listed = [...free];
53
+ return listed.find((id) => /(?:^|[/-])(?:auto|default)\b|\/free$/.test(id)) ?? listed[0];
54
+ }
55
+
56
+ // src/harness/accounts/cli-usage-probes.ts
57
+ import { readFile } from "node:fs/promises";
58
+ import { homedir } from "node:os";
59
+ import { join } from "node:path";
60
+ var AntigravityInvalidCredentialError = class extends Error {
61
+ constructor(file) {
62
+ super(`Antigravity credentials are invalid JSON; sign in to this account again. Usage cannot be read safely. File: ${file}`);
63
+ this.name = "AntigravityInvalidCredentialError";
64
+ }
65
+ };
66
+ function catalogBinary(command, fallback) {
67
+ try {
68
+ return localHarnessForCommand(command)?.binary ?? fallback;
69
+ } catch {
70
+ return fallback;
71
+ }
72
+ }
73
+ function futureReset(value, now) {
74
+ const at = typeof value === "string" ? Date.parse(value) : typeof value === "number" ? value : Number.NaN;
75
+ return Number.isFinite(at) && at > now + 6e4 ? new Date(at).toISOString() : void 0;
76
+ }
77
+ function balanceLabel(amount) {
78
+ return `$${Number.isInteger(amount) ? amount : amount.toFixed(2)} credits left`;
79
+ }
80
+ function copilotQuotaReading(result, now = Date.now()) {
81
+ const snapshots = result?.quotaSnapshots;
82
+ if (!snapshots || typeof snapshots !== "object") return void 0;
83
+ const names = { premium_interactions: "premium", chat: "chat" };
84
+ const windows = Object.entries(names).map(([key, name]) => {
85
+ const snapshot = snapshots[key];
86
+ if (!snapshot || snapshot.isUnlimitedEntitlement === true || !(Number(snapshot.entitlementRequests) > 0)) return void 0;
87
+ const remaining = Number(snapshot.remainingPercentage);
88
+ const used = Number.isFinite(remaining) ? 100 - remaining : Number(snapshot.usedRequests) / Number(snapshot.entitlementRequests) * 100;
89
+ return usageWindow(name, used, futureReset(snapshot.resetDate ?? snapshot.resetDateEpochMs, now));
90
+ });
91
+ return usageReading(windows);
92
+ }
93
+ function contentLengthRequest(binary, argv, environment, method, params) {
94
+ const harness = localHarnessForCommand("copilot");
95
+ if (!harness) return Promise.resolve(void 0);
96
+ return queryJsonRpc(
97
+ { gate: harness, binary, argv, environment, deadlineMs: PROBE_DEADLINE_MS, label: "copilot", framing: "content-length" },
98
+ (peer) => peer.request(method, params)
99
+ );
100
+ }
101
+ async function copilotUsageReading(environment) {
102
+ const binary = await resolveBinaryPath(catalogBinary("copilot", "copilot"));
103
+ if (!binary) return void 0;
104
+ const quota = await contentLengthRequest(binary, ["--headless", "--no-auto-update", "--stdio"], environment, "account.getQuota", {});
105
+ const reading = copilotQuotaReading(quota);
106
+ const chat = quota?.quotaSnapshots?.chat;
107
+ return reading && chat?.isUnlimitedEntitlement === false ? { ...reading, plan: { name: "Copilot Free" } } : reading;
108
+ }
109
+ async function copilotAccountModels(environment) {
110
+ const binary = await resolveBinaryPath(catalogBinary("copilot", "copilot"));
111
+ if (!binary) return void 0;
112
+ const listed = (await contentLengthRequest(binary, ["--headless", "--no-auto-update", "--stdio"], environment, "models.list", {}))?.models;
113
+ if (!Array.isArray(listed)) return void 0;
114
+ const labels = {};
115
+ for (const model of listed) if (typeof model?.id === "string") labels[model.id] = typeof model.name === "string" ? model.name : model.id;
116
+ return Object.keys(labels).length ? { models: Object.keys(labels), labels } : void 0;
117
+ }
118
+ function antigravityQuotaReading(models) {
119
+ if (!models || typeof models !== "object") return void 0;
120
+ const pools = /* @__PURE__ */ new Map();
121
+ for (const [id, model] of Object.entries(models)) {
122
+ const quota = model?.quotaInfo;
123
+ if (typeof quota?.resetTime !== "string" || typeof model.displayName !== "string") continue;
124
+ const left = typeof quota.remainingFraction === "number" ? quota.remainingFraction : 0;
125
+ const pool = pools.get(quota.resetTime) ?? { families: /* @__PURE__ */ new Set(), left, reset: quota.resetTime };
126
+ pool.families.add(model.displayName.split(/\s+/)[0] ?? id);
127
+ pool.left = Math.min(pool.left, left);
128
+ pools.set(quota.resetTime, pool);
129
+ }
130
+ const windows = [...pools.values()].sort((a, b) => a.reset.localeCompare(b.reset)).map((pool) => {
131
+ const window = usageWindow([...pool.families].join("/"), (1 - pool.left) * 100, pool.reset);
132
+ return window ? { ...window, advisory: true } : void 0;
133
+ });
134
+ return usageReading(windows);
135
+ }
136
+ async function antigravityAccessToken(environment) {
137
+ const file = join(environment.HOME ?? homedir(), ".gemini", "antigravity-cli", "antigravity-oauth-token");
138
+ const raw = await readFile(file, "utf8");
139
+ let data;
140
+ try {
141
+ data = JSON.parse(raw);
142
+ } catch {
143
+ throw new AntigravityInvalidCredentialError(file);
144
+ }
145
+ const token = data.token;
146
+ const fresh = typeof token?.expiry === "string" && Date.parse(token.expiry) > Date.now() + 6e4;
147
+ return fresh && typeof token?.access_token === "string" ? token.access_token : void 0;
148
+ }
149
+ async function antigravityUsageReading(environment) {
150
+ try {
151
+ let token = await antigravityAccessToken(environment).catch((error) => {
152
+ if (error.code === "ENOENT") return void 0;
153
+ throw error;
154
+ });
155
+ const harness = localHarnessForCommand("antigravity");
156
+ if (!token && harness && await mayRunSignInCapable(harness, environment)) {
157
+ await probeCommand(harness, ["models"], environment);
158
+ token = await antigravityAccessToken(environment);
159
+ }
160
+ if (!token) return void 0;
161
+ const ask = async (method, body) => {
162
+ const response = await probeFetch(`https://cloudcode-pa.googleapis.com/v1internal:${method}`, {
163
+ method: "POST",
164
+ body: JSON.stringify(body),
165
+ // Any other client is told "This client is no longer supported".
166
+ headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", "User-Agent": "antigravity/1.0.0" }
167
+ });
168
+ return response.ok ? await response.json() : void 0;
169
+ };
170
+ const assist = await ask("loadCodeAssist", { metadata: { ideType: "ANTIGRAVITY", pluginType: "GEMINI" } });
171
+ const tier = assist?.currentTier?.id;
172
+ const project = assist?.cloudaicompanionProject;
173
+ const holds = Array.isArray(assist?.ineligibleTiers) ? assist.ineligibleTiers : [];
174
+ if (typeof tier !== "string" && holds.length) {
175
+ const link = holds.find((entry) => typeof entry?.validationUrl === "string")?.validationUrl;
176
+ return { windows: [], account: link ? { verify: link } : {} };
177
+ }
178
+ if (typeof project !== "string") return void 0;
179
+ const reading = antigravityQuotaReading((await ask("fetchAvailableModels", { project }))?.models);
180
+ return reading && typeof tier === "string" ? { ...reading, plan: { name: tier } } : reading;
181
+ } catch (error) {
182
+ if (error instanceof AntigravityInvalidCredentialError) return { windows: [], account: "signed-out" };
183
+ quiet("harness/accounts/antigravity-usage")(error);
184
+ return void 0;
185
+ }
186
+ }
187
+ function kimiQuotaReading(result) {
188
+ const data = result?.data ?? result;
189
+ if (data?.kind !== "ok") return void 0;
190
+ const usages = data.quota?.usages;
191
+ if (!usages) return void 0;
192
+ const window = (name, entry) => typeof entry?.usedRatio === "number" ? usageWindow(name, entry.usedRatio * 100, entry.resetAt) : void 0;
193
+ return usageReading([window("5h", usages.limit5h), window("weekly", usages.limit7d), window("monthly", usages.monthTotal)]);
194
+ }
195
+ function kimiWebEndpoint(banner) {
196
+ const text = stripAnsi(banner);
197
+ const local = /Local:\s+(http:\/\/127\.0\.0\.1:\d+)\/?#token=([A-Za-z0-9_-]+)/.exec(text);
198
+ if (local) return { url: local[1], token: local[2] };
199
+ const url = /Local:\s+(http:\/\/127\.0\.0\.1:\d+)/.exec(text)?.[1];
200
+ const token = /Token:\s+([A-Za-z0-9_-]+)/.exec(text)?.[1];
201
+ return url && token ? { url, token } : void 0;
202
+ }
203
+ async function kimiUsageReading(environment) {
204
+ const harness = localHarnessForCommand("kimi");
205
+ const binary = harness ? await resolveBinaryPath(harness.binary) : void 0;
206
+ if (!harness || !binary) return void 0;
207
+ return probeVendor({ gate: harness, binary, argv: ["web", "--no-open", "--port", "0"], environment, deadlineMs: PROBE_DEADLINE_MS }, async (child, signal) => {
208
+ const endpoint = await new Promise((resolve) => {
209
+ let banner = "";
210
+ child.stdout.setEncoding("utf8");
211
+ child.stdout.on("data", (chunk) => {
212
+ banner += chunk;
213
+ const found = kimiWebEndpoint(banner);
214
+ if (found) resolve(found);
215
+ });
216
+ child.once("exit", () => resolve(void 0));
217
+ });
218
+ if (!endpoint) return void 0;
219
+ const response = await probeFetch(`${endpoint.url}/api/v1/oauth/usage`, {
220
+ headers: { Authorization: `Bearer ${endpoint.token}` },
221
+ signal
222
+ });
223
+ if (!response.ok) return void 0;
224
+ const body = await response.json();
225
+ const said = body?.data?.kind === "error" && typeof body.data.message === "string" ? body.data.message : "";
226
+ if (/re-?login required|rejected/i.test(said)) return { windows: [], account: "signed-out" };
227
+ return kimiQuotaReading(body);
228
+ });
229
+ }
230
+ function cursorQuotaReading(result, planName) {
231
+ const plan = result?.planUsage;
232
+ if (!plan) return void 0;
233
+ const end = Number(result.billingCycleEnd);
234
+ const reset = Number.isFinite(end) && end > 0 ? end : void 0;
235
+ const api = planName === "Free" ? void 0 : usageWindow("API", plan.apiPercentUsed, reset);
236
+ const auto = plan.autoPercentUsed ?? plan.totalPercentUsed;
237
+ return usageReading([usageWindow("auto", auto, reset), api ? { ...api, advisory: true } : void 0]);
238
+ }
239
+ async function cursorUnnamedModels(environment) {
240
+ const token = await cursorAccessToken(environment);
241
+ if (!token) return void 0;
242
+ const response = await probeFetch("https://api2.cursor.sh/aiserver.v1.AiService/AvailableModels", {
243
+ method: "POST",
244
+ body: "{}",
245
+ headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", "Connect-Protocol-Version": "1" }
246
+ });
247
+ if (!response.ok) return void 0;
248
+ const models = (await response.json()).models;
249
+ return Array.isArray(models) ? models.filter((model) => model?.namedModelSectionIndex === void 0 && typeof model?.name === "string").map((model) => model.name) : void 0;
250
+ }
251
+ async function cursorAccessToken(environment) {
252
+ const home = environment.HOME ?? homedir();
253
+ const config = environment.XDG_CONFIG_HOME ?? process.env.XDG_CONFIG_HOME ?? join(home, ".config");
254
+ const parsed = JSON.parse(await readFile(join(config, "cursor", "auth.json"), "utf8"));
255
+ return typeof parsed.accessToken === "string" && parsed.accessToken ? parsed.accessToken : void 0;
256
+ }
257
+ async function cursorUsageReading(environment) {
258
+ const ask = async (method) => {
259
+ const token = await cursorAccessToken(environment);
260
+ if (!token) return void 0;
261
+ return probeFetch(`https://api2.cursor.sh/aiserver.v1.DashboardService/${method}`, {
262
+ method: "POST",
263
+ body: "{}",
264
+ headers: { Authorization: `Bearer ${token}`, "Content-Type": "application/json", "Connect-Protocol-Version": "1" }
265
+ });
266
+ };
267
+ try {
268
+ let response = await ask("GetCurrentPeriodUsage");
269
+ if (response?.status === 401) {
270
+ const harness = localHarnessForCommand("cursor");
271
+ if (!harness || !await mayRunSignInCapable(harness, environment)) return void 0;
272
+ await probeCommand(harness, ["status"], environment);
273
+ response = await ask("GetCurrentPeriodUsage");
274
+ }
275
+ if (!response?.ok) return void 0;
276
+ const plan = await ask("GetPlanInfo").then(async (answer) => answer?.ok ? (await answer.json()).planInfo?.planName : void 0).catch(quiet("harness/accounts/cli-usage-probes"));
277
+ const reading = cursorQuotaReading(await response.json(), plan);
278
+ if (!reading || !plan) return reading;
279
+ const models = planIsFree({ name: plan }) ? await cursorUnnamedModels(environment).catch(quiet("harness/accounts/cli-usage-probes")) : void 0;
280
+ return { ...reading, plan: { name: plan, ...models?.length ? { models } : {} } };
281
+ } catch {
282
+ return void 0;
283
+ }
284
+ }
285
+ function clineQuotaReading(result) {
286
+ const balance = Number(result?.data?.balance);
287
+ if (!Number.isFinite(balance)) return void 0;
288
+ const dollars = balance / 1e6;
289
+ if (dollars <= 0) return { windows: [{ name: "credits", usedPct: 100, advisory: true }], label: "Out of credits \xB7 free models only", plan: { name: "Free" } };
290
+ return { windows: [], label: `$${dollars.toFixed(2)} credits left`, plan: { name: "Credits" } };
291
+ }
292
+ async function clineUsageReading(environment) {
293
+ try {
294
+ const home = environment.HOME ?? homedir();
295
+ const providers = JSON.parse(await readFile(join(home, ".cline", "data", "settings", "providers.json"), "utf8"));
296
+ const auth = providers?.providers?.cline?.settings?.auth;
297
+ if (typeof auth?.accessToken !== "string" || typeof auth.accountId !== "string") return void 0;
298
+ const response = await probeFetch(`https://api.cline.bot/api/v1/users/${encodeURIComponent(auth.accountId)}/balance`, {
299
+ headers: { Authorization: `Bearer ${auth.accessToken}` }
300
+ });
301
+ return response.ok ? clineQuotaReading(await response.json()) : void 0;
302
+ } catch {
303
+ return void 0;
304
+ }
305
+ }
306
+ function vibeQuotaReading(status, requestsPerMinute) {
307
+ if (status === 429 && requestsPerMinute === "0") return { windows: [{ name: "requests", usedPct: 100 }], label: "No requests allowed on this plan" };
308
+ return void 0;
309
+ }
310
+ async function vibeUsageReading(environment) {
311
+ try {
312
+ const home = environment.VIBE_HOME ?? join(environment.HOME ?? homedir(), ".vibe");
313
+ const key = /^MISTRAL_API_KEY=["']?([^"'\s]+)/m.exec(await readFile(join(home, ".env"), "utf8"))?.[1];
314
+ if (!key) return void 0;
315
+ const response = await probeFetch("https://api.mistral.ai/v1/chat/completions", {
316
+ method: "POST",
317
+ headers: { Authorization: `Bearer ${key}`, "Content-Type": "application/json" },
318
+ body: JSON.stringify({ model: "mistral-small-latest", messages: [] })
319
+ });
320
+ await response.body?.cancel();
321
+ return vibeQuotaReading(response.status, response.headers.get("x-ratelimit-limit-req-minute"));
322
+ } catch {
323
+ return void 0;
324
+ }
325
+ }
326
+ function devinQuotaReading(planStatus) {
327
+ const plan = planStatus;
328
+ if (!plan) return void 0;
329
+ const window = (name, remaining, reset) => {
330
+ const left = Number(remaining);
331
+ const at = Number(reset);
332
+ return Number.isFinite(left) && remaining !== void 0 ? usageWindow(name, 100 - left, Number.isFinite(at) && at > 0 ? at * 1e3 : void 0) : void 0;
333
+ };
334
+ return usageReading([window("daily", plan.dailyQuotaRemainingPercent, plan.dailyQuotaResetAtUnix), window("weekly", plan.weeklyQuotaRemainingPercent, plan.weeklyQuotaResetAtUnix)]);
335
+ }
336
+ async function devinUsageReading(environment) {
337
+ try {
338
+ const data = environment.XDG_DATA_HOME ?? join(environment.HOME ?? homedir(), ".local", "share");
339
+ const credentials = await readFile(join(data, "devin", "credentials.toml"), "utf8");
340
+ const key = /^\s*windsurf_api_key\s*=\s*"([^"]+)"/m.exec(credentials)?.[1];
341
+ const server = /^\s*api_server_url\s*=\s*"([^"]+)"/m.exec(credentials)?.[1] ?? "https://server.codeium.com";
342
+ if (!key) return void 0;
343
+ const response = await probeFetch(`${server}/exa.seat_management_pb.SeatManagementService/GetUserStatus`, {
344
+ method: "POST",
345
+ headers: { "Content-Type": "application/json", "Connect-Protocol-Version": "1" },
346
+ body: JSON.stringify({ metadata: { apiKey: key, ideName: "windsurf", ideVersion: "1.0.0", extensionName: "windsurf", extensionVersion: "1.0.0" } })
347
+ });
348
+ if (!response.ok) return void 0;
349
+ const status = (await response.json()).userStatus;
350
+ const reading = devinQuotaReading(status?.planStatus);
351
+ const plan = status?.planStatus?.planInfo?.planName ?? status?.planInfo?.planName;
352
+ return reading && typeof plan === "string" ? { ...reading, plan: { name: plan } } : reading;
353
+ } catch {
354
+ return void 0;
355
+ }
356
+ }
357
+ function hermesQuotaReading(account) {
358
+ const record = account;
359
+ const access = record?.paid_service_access;
360
+ if (!access) return void 0;
361
+ const credits = Number(access.total_usable_credits ?? record?.purchased_credits_remaining);
362
+ if (access.allowed === false) return { windows: [{ name: "credits", usedPct: 100 }], label: "Out of credits" };
363
+ return Number.isFinite(credits) ? { windows: [], label: `$${credits.toFixed(2)} credits left` } : void 0;
364
+ }
365
+ async function hermesUsageReading(environment) {
366
+ try {
367
+ const home = environment.HERMES_HOME ?? join(environment.HOME ?? homedir(), ".hermes");
368
+ const nous = JSON.parse(await readFile(join(home, "auth.json"), "utf8")).providers?.nous;
369
+ if (typeof nous?.access_token !== "string") return void 0;
370
+ const base = typeof nous.portal_base_url === "string" ? nous.portal_base_url : "https://portal.nousresearch.com";
371
+ const response = await probeFetch(`${base}/api/oauth/account`, { headers: { Authorization: `Bearer ${nous.access_token}` } });
372
+ return response.ok ? hermesQuotaReading(await response.json()) : void 0;
373
+ } catch {
374
+ return void 0;
375
+ }
376
+ }
377
+ function kiroQuotaReading(data) {
378
+ const record = data;
379
+ const breakdowns = Array.isArray(record?.usageBreakdowns) ? record.usageBreakdowns : [];
380
+ const credits = breakdowns.find((item) => item?.resourceType === "CREDIT" && item.hasLimit !== false && Number(item.limit) > 0);
381
+ if (!credits) return void 0;
382
+ return usageReading([usageWindow("monthly", Number(credits.used) / Number(credits.limit) * 100, record?.billingCycleReset)]);
383
+ }
384
+ async function kiroUsageReading(environment) {
385
+ const harness = localHarnessForCommand("kiro");
386
+ if (!harness?.acp) return void 0;
387
+ return queryAcp(harness.acp.binary ?? harness.binary, harness.acp.argv, environment, async (request) => {
388
+ const started = await acpDiscoverySession(request);
389
+ const sessionId = typeof started.sessionId === "string" ? started.sessionId : void 0;
390
+ if (!sessionId) return void 0;
391
+ const answer = await request("_kiro.dev/commands/execute", { sessionId, command: { command: "usage", args: {} } });
392
+ if (answer.success === false) return void 0;
393
+ const reading = kiroQuotaReading(answer.data);
394
+ const plan = answer.data?.planName;
395
+ return reading && typeof plan === "string" ? { ...reading, plan: { name: plan } } : reading;
396
+ }, void 0, { gate: harness, discovery: harness }).catch(quiet("harness/accounts/cli-usage-probes"));
397
+ }
398
+ function commandCodeQuotaReading(result) {
399
+ const record = result;
400
+ const limits = record?.windowLimits;
401
+ const window = (name, entry) => entry && Number(entry.cap) > 0 ? usageWindow(name, Number(entry.used) / Number(entry.cap) * 100, entry.resetAt) : void 0;
402
+ const windows = limits?.limited ? usageReading([window("5h", limits.fiveHour), window("weekly", limits.weekly)]) : void 0;
403
+ if (windows) return windows;
404
+ const credits = record?.credits;
405
+ const balance = ["monthlyCredits", "purchasedCredits", "freeCredits"].reduce((sum, key) => sum + (Number(credits?.[key]) || 0), 0);
406
+ if (credits && balance <= 0) return { windows: [{ name: "credits", usedPct: 100 }], label: "Out of credits" };
407
+ return balance > 0 ? { windows: [], label: `${Number.isInteger(balance) ? balance : balance.toFixed(2)} credits left` } : void 0;
408
+ }
409
+ async function commandCodeUsageReading(environment) {
410
+ try {
411
+ const home = environment.HOME ?? homedir();
412
+ const auth = JSON.parse(await readFile(join(home, ".commandcode", "auth.json"), "utf8"));
413
+ if (typeof auth.apiKey !== "string" || !auth.apiKey) return void 0;
414
+ const response = await probeFetch("https://api.commandcode.ai/alpha/billing/credits", {
415
+ headers: { Authorization: `Bearer ${auth.apiKey}` }
416
+ });
417
+ return response.ok ? commandCodeQuotaReading(await response.json()) : void 0;
418
+ } catch {
419
+ return void 0;
420
+ }
421
+ }
422
+ function ampUsageLabel(output) {
423
+ const amount = /credits:\**\s*\$([\d,]+(?:\.\d+)?)\s+remaining/i.exec(stripAnsi(output))?.[1];
424
+ return amount === void 0 ? void 0 : balanceLabel(Number(amount.replace(/,/g, "")));
425
+ }
426
+ function kiloProfileLabel(output) {
427
+ const amount = /^Balance:\s*\$([\d,]+(?:\.\d+)?)/m.exec(stripAnsi(output))?.[1];
428
+ return amount === void 0 ? void 0 : balanceLabel(Number(amount.replace(/,/g, "")));
429
+ }
430
+ async function captureLabel(command, argv, environment, parse) {
431
+ try {
432
+ const harness = localHarnessForCommand(command);
433
+ const output = harness ? await probeCommand(harness, argv, environment) : void 0;
434
+ return output === void 0 ? void 0 : parse(output);
435
+ } catch {
436
+ return void 0;
437
+ }
438
+ }
439
+ function auggieUsageLabel(raw) {
440
+ let status;
441
+ try {
442
+ status = JSON.parse(raw);
443
+ } catch {
444
+ return void 0;
445
+ }
446
+ const value = status.amountRemaining;
447
+ const remaining = typeof value === "number" ? value : typeof value === "string" && value.trim() ? Number(value.trim()) : Number.NaN;
448
+ if (!Number.isFinite(remaining)) return void 0;
449
+ if (remaining <= 0) return "Out Of Credits";
450
+ const unit = typeof status.usageUnit === "string" ? status.usageUnit : void 0;
451
+ if (unit?.toLowerCase() === "usd") return balanceLabel(remaining);
452
+ return `${Number.isInteger(remaining) ? remaining : remaining.toFixed(2)}${unit ? ` ${unit}` : ""} credits left`;
453
+ }
454
+ async function auggieUsageReading(environment) {
455
+ const harness = localHarnessForCommand("auggie");
456
+ const raw = harness ? await probeCommand(harness, ["account", "status", "--json"], environment) : void 0;
457
+ if (raw === void 0) return void 0;
458
+ const label = auggieUsageLabel(raw);
459
+ if (label === void 0) return void 0;
460
+ let plan;
461
+ try {
462
+ plan = JSON.parse(raw).planName;
463
+ } catch {
464
+ }
465
+ return { windows: [], label, ...typeof plan === "string" && plan ? { plan: { name: plan } } : {} };
466
+ }
467
+ var ampUsageProbe = (environment) => captureLabel("amp", ["usage"], environment, ampUsageLabel);
468
+ function kiloProfileReading(output) {
469
+ const label = kiloProfileLabel(output);
470
+ if (label === void 0) return void 0;
471
+ return { windows: [], label, plan: { name: label === balanceLabel(0) ? "Free" : "Credits" } };
472
+ }
473
+ async function kiloUsageReading(environment) {
474
+ try {
475
+ const harness = localHarnessForCommand("kilo");
476
+ const output = harness ? await probeCommand(harness, ["profile"], environment) : void 0;
477
+ return output === void 0 ? void 0 : kiloProfileReading(output);
478
+ } catch {
479
+ return void 0;
480
+ }
481
+ }
482
+
483
+ export {
484
+ planIsFree,
485
+ freePlanModels,
486
+ preferredFreeModel,
487
+ copilotUsageReading,
488
+ copilotAccountModels,
489
+ antigravityUsageReading,
490
+ kimiUsageReading,
491
+ cursorUsageReading,
492
+ clineUsageReading,
493
+ vibeUsageReading,
494
+ devinUsageReading,
495
+ hermesUsageReading,
496
+ kiroUsageReading,
497
+ commandCodeUsageReading,
498
+ auggieUsageReading,
499
+ ampUsageProbe,
500
+ kiloUsageReading
501
+ };
@@ -0,0 +1,99 @@
1
+ import { createRequire as __clikcodeCreateRequire } from 'node:module';
2
+ const require = __clikcodeCreateRequire(import.meta.url);
3
+ import {
4
+ sleep
5
+ } from "./chunk-YMCH3L2S.js";
6
+ import {
7
+ lifecycle
8
+ } from "./chunk-RDDWQBEM.js";
9
+
10
+ // src/session/move-chat.ts
11
+ function movedChatMessage(session) {
12
+ return session.movedTo ? `This chat moved to ${session.movedTo.machine}; continue it there.` : void 0;
13
+ }
14
+ function chatHasContent(session) {
15
+ return Boolean(session.messages?.length || session.pendingTurn || session.listMessageCount);
16
+ }
17
+ var CHAT_HAVE_REVISION = 5;
18
+ var STALE_BASE = "The copy of this chat there changed: sending all of it.";
19
+ async function moveChat(source, target, sessionId) {
20
+ const startedAt = Date.now();
21
+ const steps = {};
22
+ let step = "chat-have";
23
+ const timed = async (name, work) => {
24
+ step = name;
25
+ const began = Date.now();
26
+ try {
27
+ return await work();
28
+ } finally {
29
+ steps[name] = (steps[name] ?? 0) + Date.now() - began;
30
+ }
31
+ };
32
+ try {
33
+ const outcome = await moveChatSteps(source, target, sessionId, timed);
34
+ lifecycle("remote.move", { session: sessionId, from: source.name, to: target.name, ms: Date.now() - startedAt, steps, sent: outcome.sent, reused: outcome.reused });
35
+ return outcome;
36
+ } catch (error) {
37
+ lifecycle("remote.move.failed", { session: sessionId, from: source.name, to: target.name, step, ms: Date.now() - startedAt, steps, error: String(error?.message ?? error).slice(0, 200) });
38
+ throw error;
39
+ }
40
+ }
41
+ async function moveChatSteps(source, target, sessionId, timed) {
42
+ const names = { source: source.name, target: target.name };
43
+ const have = (target.revision ?? 0) >= CHAT_HAVE_REVISION ? await timed("chat-have", () => target.call({ type: "chat-have", sessionId })).catch(() => null) : null;
44
+ const pack = (target.revision ?? 0) >= CHAT_HAVE_REVISION;
45
+ let chat = await timed("export", () => source.call({ type: "export-chat", sessionId, ...validHave(have) ? { since: have } : {}, ...pack ? { pack } : {} }));
46
+ let imported;
47
+ try {
48
+ imported = await timed("import", () => target.call({ type: "import-chat", chat, names }));
49
+ } catch (error) {
50
+ if (!chat.base || !String(error?.message ?? error).includes(STALE_BASE)) throw error;
51
+ chat = await timed("export", () => source.call({ type: "export-chat", sessionId, ...pack ? { pack } : {} }));
52
+ imported = await timed("import", () => target.call({ type: "import-chat", chat, names }));
53
+ }
54
+ await timed("mark-moved", () => markMovedWithRetry(source, chat.sessionId, { machine: target.name, installationId: imported.installationId, sessionId: imported.sessionId }, target.name));
55
+ return {
56
+ moved: true,
57
+ sessionId: imported.sessionId,
58
+ folder: imported.folder,
59
+ changes: imported.changes,
60
+ reused: chat.base?.messages ?? 0,
61
+ sent: "packed" in chat ? chat.count : chat.messages.length
62
+ };
63
+ }
64
+ var MARK_MOVED_PAUSES_MS = [0, 500, 2e3];
65
+ async function markMovedWithRetry(source, sessionId, movedTo, targetName) {
66
+ let failure;
67
+ for (const pause of MARK_MOVED_PAUSES_MS) {
68
+ if (pause) await sleep(pause);
69
+ try {
70
+ await source.call({ type: "mark-moved", sessionId, movedTo });
71
+ return;
72
+ } catch (error) {
73
+ failure = error;
74
+ }
75
+ }
76
+ const cause = failure instanceof Error ? failure.message : String(failure);
77
+ throw new Error(`The chat is on ${targetName}, but its copy on ${source.name} could not be marked as moved: ${cause}
78
+ Both copies are still writable: carry on in the copy on ${targetName} and leave this one alone.`);
79
+ }
80
+ function validHave(have) {
81
+ const value = have;
82
+ return Boolean(value && Number.isInteger(value.messages) && value.messages > 0 && typeof value.hash === "string" && value.hash);
83
+ }
84
+ function movedChatMachine(movedTo, machines, here) {
85
+ if (movedTo.installationId && movedTo.installationId === here.installationId) return "local";
86
+ const ready = machines.filter((machine2) => machine2.ready !== false);
87
+ const machine = (movedTo.installationId ? ready.find((item) => item.installationId === movedTo.installationId) : void 0) ?? ready.find((item) => item.name === movedTo.machine);
88
+ if (machine) return machine.id;
89
+ return movedTo.machine === here.name ? "local" : void 0;
90
+ }
91
+
92
+ export {
93
+ movedChatMessage,
94
+ chatHasContent,
95
+ CHAT_HAVE_REVISION,
96
+ STALE_BASE,
97
+ moveChat,
98
+ movedChatMachine
99
+ };