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,1409 @@
1
+ import { createRequire as __clikcodeCreateRequire } from 'node:module';
2
+ const require = __clikcodeCreateRequire(import.meta.url);
3
+ import {
4
+ applyToChat,
5
+ interactivePermissionPicker,
6
+ settingLabel
7
+ } from "./chunk-Y7UECI4M.js";
8
+ import {
9
+ interactiveSessionPicker
10
+ } from "./chunk-LPCNRGJ7.js";
11
+ import {
12
+ loginMcpServer,
13
+ mcpServersText,
14
+ mcpSignInUiFor
15
+ } from "./chunk-IC6N4NZA.js";
16
+ import {
17
+ parseCommitArgument,
18
+ updateThisMachine
19
+ } from "./chunk-6CK466BC.js";
20
+ import {
21
+ localMachineName
22
+ } from "./chunk-Z4ZU6T7V.js";
23
+ import {
24
+ enqueueCommandLine
25
+ } from "./chunk-KD5KIVMS.js";
26
+ import {
27
+ replaceWindowBuild
28
+ } from "./chunk-ZGHNNSCT.js";
29
+ import {
30
+ interactiveHostedPicker,
31
+ interactiveModelPicker,
32
+ modelRow
33
+ } from "./chunk-S5JAAF6S.js";
34
+ import {
35
+ aiSessionCommand,
36
+ aiSettingsClearProvider,
37
+ aiSettingsSetGlobal,
38
+ aiSettingsSetProvider,
39
+ capabilitiesText,
40
+ changesPath,
41
+ compactConversation,
42
+ fileTurnRows,
43
+ forkPoint,
44
+ forkPointOptions,
45
+ impliedHarnessCommand,
46
+ initPrompt,
47
+ isChangesPath,
48
+ lastAnswer,
49
+ nativeManagerListing,
50
+ noFileTurns,
51
+ parseSlashInput,
52
+ readMemoryFile,
53
+ reviewPrompt,
54
+ routeSlashInput,
55
+ slashRouteTurn,
56
+ userMessageIndexes
57
+ } from "./chunk-H4THUNBM.js";
58
+ import {
59
+ readTurnChanges,
60
+ turnMessageIndex
61
+ } from "./chunk-32IKAIZC.js";
62
+ import {
63
+ sessionTurnTransport,
64
+ turnEnvironment
65
+ } from "./chunk-M6ND6KBE.js";
66
+ import {
67
+ interactiveEnginePicker
68
+ } from "./chunk-M7H3WQTE.js";
69
+ import {
70
+ TerminalHarnessPrompter,
71
+ lastPickerExit,
72
+ selectProviderConversation
73
+ } from "./chunk-QPQKX2MK.js";
74
+ import {
75
+ chooseOption
76
+ } from "./chunk-ROGXPGYR.js";
77
+ import {
78
+ exportTranscript
79
+ } from "./chunk-ZOU3LV4U.js";
80
+ import {
81
+ GATEWAY_ID,
82
+ accountRow,
83
+ accountUsage,
84
+ chatCostLabel,
85
+ effortChoices,
86
+ harnessCanAddAccount,
87
+ providerRows,
88
+ usageWindows
89
+ } from "./chunk-J6EGFVQX.js";
90
+ import {
91
+ accountHasUsage,
92
+ aiSessionLeave,
93
+ gatewayAgents,
94
+ moveToProvider,
95
+ newConversation,
96
+ resumePromptForPendingTurn,
97
+ sessionProviderHasUsage,
98
+ waitForReset
99
+ } from "./chunk-RJLPTWHW.js";
100
+ import {
101
+ sessionHarness,
102
+ sessionOrProviderHarness,
103
+ slashRouteContextFor
104
+ } from "./chunk-2EOL5PZL.js";
105
+ import {
106
+ aiHarnessSelect
107
+ } from "./chunk-MDT5XDXL.js";
108
+ import {
109
+ forgetMcpOAuth,
110
+ recordSharedMcpServer
111
+ } from "./chunk-UA5K2BTI.js";
112
+ import {
113
+ nextQuotaReset
114
+ } from "./chunk-IF43HIGV.js";
115
+ import {
116
+ verificationNotice
117
+ } from "./chunk-2YPAPAR3.js";
118
+ import {
119
+ searchConversations
120
+ } from "./chunk-WNX5VD7S.js";
121
+ import {
122
+ MentionBrowser,
123
+ mentionOccurrence,
124
+ searchResultsText
125
+ } from "./chunk-34AZEGYW.js";
126
+ import {
127
+ accountUsageLabel,
128
+ accountUsageReading,
129
+ aiAccountLogin,
130
+ aiAccountRemove,
131
+ cachedAccountUsageLabel,
132
+ loginNativeHarness,
133
+ signOutAccount,
134
+ syncAccountIdentityAfterLogin,
135
+ withSignIn
136
+ } from "./chunk-LA6MG4ET.js";
137
+ import {
138
+ NATIVE_USAGE_PROBES
139
+ } from "./chunk-N3SFDYM7.js";
140
+ import {
141
+ emitHarnessOutput
142
+ } from "./chunk-4RHXTL3W.js";
143
+ import {
144
+ gatewayMakerName,
145
+ gatewayModelDetail,
146
+ gatewayModelLabel,
147
+ gatewayModels,
148
+ gatewayModelsByMaker,
149
+ savedGatewayModels
150
+ } from "./chunk-W5AYOICN.js";
151
+ import {
152
+ getApiKeyForUrl,
153
+ getApiUrl
154
+ } from "./chunk-TQDM7S5N.js";
155
+ import {
156
+ localModelLabel
157
+ } from "./chunk-TQDKJHWX.js";
158
+ import {
159
+ preferredAccountId
160
+ } from "./chunk-SQVUDO2O.js";
161
+ import {
162
+ hasLocalDisplay,
163
+ openLoginUrl
164
+ } from "./chunk-RE4TGORR.js";
165
+ import {
166
+ copyToClipboard,
167
+ embeddedImagePaths,
168
+ expandHomePath,
169
+ queueAttachment,
170
+ resolveStandaloneAttachment
171
+ } from "./chunk-DCZ6CIUM.js";
172
+ import {
173
+ discoverHermesChoices,
174
+ nativeModelCatalogForPicker,
175
+ nativeModelLabel
176
+ } from "./chunk-QQRLPY25.js";
177
+ import {
178
+ freePlanModels
179
+ } from "./chunk-DA44ZENT.js";
180
+ import {
181
+ accountQuotaSpent,
182
+ outOfUsageText
183
+ } from "./chunk-XWAC3MKW.js";
184
+ import {
185
+ nativeProfileEnvironment
186
+ } from "./chunk-ZGX3ERAT.js";
187
+ import {
188
+ readState
189
+ } from "./chunk-MXS6S2PY.js";
190
+ import {
191
+ writeState
192
+ } from "./chunk-RKUVLRZI.js";
193
+ import {
194
+ SEND_MODES,
195
+ SEND_MODE_DETAIL,
196
+ VALID_PERMISSION_MODES,
197
+ chatNamed,
198
+ compareProviders,
199
+ conversationPreview,
200
+ integrationLabel,
201
+ isBlankConversation,
202
+ sendModeOf,
203
+ sessionPermissionModes,
204
+ setSessionHarnessOption,
205
+ transcriptWasLoaded,
206
+ vendorFacingOptions
207
+ } from "./chunk-TWCVV2JO.js";
208
+ import {
209
+ turnFacts
210
+ } from "./chunk-PDPEM5VW.js";
211
+ import {
212
+ compactPath
213
+ } from "./chunk-WWLJMP6D.js";
214
+ import {
215
+ GATEWAY_LABEL,
216
+ isClikCodeAgent,
217
+ isGatewayService
218
+ } from "./chunk-CRUVYGO2.js";
219
+ import {
220
+ sessionTranscriptMessages
221
+ } from "./chunk-FF7ZVYJF.js";
222
+ import {
223
+ conversationRows,
224
+ livePendingTurns,
225
+ liveWorkers
226
+ } from "./chunk-BUOPJQP5.js";
227
+ import {
228
+ textTranscript
229
+ } from "./chunk-3B2CHX7M.js";
230
+ import {
231
+ allLocalHarnesses,
232
+ harnessCanRunTurns,
233
+ harnessSupportsModelSelection,
234
+ harnessTierRank,
235
+ localHarnessCapabilityManifest,
236
+ localHarnessForCommand,
237
+ localHarnessForProvider
238
+ } from "./chunk-KYUHIFP3.js";
239
+ import {
240
+ inspectNativeHarnessForPicker,
241
+ runNativeHarnessCommand
242
+ } from "./chunk-DF35KMXM.js";
243
+ import {
244
+ dollars,
245
+ quotaResetPhrase
246
+ } from "./chunk-EE4B6A7W.js";
247
+ import {
248
+ CLIKCODE_USER_AGENT
249
+ } from "./chunk-NAOX3JUB.js";
250
+ import {
251
+ source_default
252
+ } from "./chunk-LVRRWP4W.js";
253
+ import {
254
+ stripAnsi
255
+ } from "./chunk-G3QP67Z7.js";
256
+ import {
257
+ withFileLock
258
+ } from "./chunk-4L2ZZM4Q.js";
259
+ import {
260
+ quiet
261
+ } from "./chunk-RDDWQBEM.js";
262
+ import {
263
+ safeRecordFileName,
264
+ sessionsDirectory,
265
+ stateDirectory
266
+ } from "./chunk-MPAJ446F.js";
267
+
268
+ // src/agent/plan-mode-setting.ts
269
+ function planModeOnChat(session, harness) {
270
+ return isClikCodeAgent(session) || Boolean(harness?.acp?.planModeId);
271
+ }
272
+ async function setAgentPlanMode(id, on) {
273
+ const state = await readState({ transcripts: [] });
274
+ const session = state.sessions.find((item) => item.id === id);
275
+ if (!session) throw new Error(`AI session "${id}" was not found`);
276
+ const harness = !isClikCodeAgent(session) && session.nativeHarness ? localHarnessForCommand(session.nativeHarness) : void 0;
277
+ if (!planModeOnChat(session, harness)) throw new Error("This provider keeps its plan mode among its own options.");
278
+ if (on === (session.planMode === true)) return;
279
+ if (on) session.planMode = true;
280
+ else delete session.planMode;
281
+ await writeState(state);
282
+ }
283
+
284
+ // src/ide/queries.ts
285
+ var IDE_MODEL_DISCOVERY_WAIT_MS = 45e3;
286
+ function harnessOf(session) {
287
+ if (!session || isClikCodeAgent(session)) return void 0;
288
+ return session.nativeHarness ? localHarnessForCommand(session.nativeHarness) : session.provider ? localHarnessForProvider(session.provider) : void 0;
289
+ }
290
+ function accountFor(state, session, harness) {
291
+ const own = session?.accountId ? state.accounts.find((item) => item.id === session.accountId) : void 0;
292
+ if (own && own.provider === harness.provider) return own;
293
+ return state.accounts.find((item) => item.provider === harness.provider && item.status === "ready");
294
+ }
295
+ var providerList = providerRows;
296
+ async function modelList(config, state, session, provider) {
297
+ if (provider === GATEWAY_ID) {
298
+ const onThisComputer = session?.route === "clikcode-local";
299
+ const roster = onThisComputer ? Promise.resolve({ agents: [], agentsError: void 0 }) : gatewayAgents({ config }).then(
300
+ (agents2) => ({ agents: agents2, agentsError: void 0 }),
301
+ (error) => ({ agents: [], agentsError: error instanceof Error ? error.message : String(error) })
302
+ );
303
+ const list = await gatewayModels({ config }).catch(async (error) => {
304
+ const saved = await savedGatewayModels({ config });
305
+ if (saved) return saved;
306
+ if (onThisComputer) return void 0;
307
+ throw error;
308
+ });
309
+ if (!list) return { provider, custom: false, models: [], onThisComputer: localModelLabel(session?.model) ?? session?.model ?? "a model on this computer" };
310
+ const { agents, agentsError } = await roster;
311
+ const current = session && isGatewayService(session) ? session.model ?? void 0 : void 0;
312
+ const currentAgent = session?.route === "gateway" ? session.gatewayAgentId : void 0;
313
+ return {
314
+ provider,
315
+ custom: false,
316
+ ...onThisComputer ? { onThisComputer: localModelLabel(session?.model) ?? session?.model ?? "a model on this computer" } : {},
317
+ agents: agents.map((agent) => ({ id: agent.id, name: agent.name, detail: `Runs on ClikDeploy${agent.description ? ` \xB7 ${agent.description}` : ""}`, current: agent.id === currentAgent })),
318
+ ...agentsError ? { agentsError } : {},
319
+ models: [
320
+ { id: "auto", label: "Automatic", detail: "the Gateway chooses", current: session?.route === "gateway" && !current },
321
+ ...gatewayModelsByMaker(list.models).map((model) => ({ id: model.id, group: gatewayMakerName(model), label: gatewayModelLabel(model), ...gatewayModelDetail(model) ? { detail: gatewayModelDetail(model) } : {}, current: model.id === current }))
322
+ ]
323
+ };
324
+ }
325
+ const harness = localHarnessForCommand(provider);
326
+ if (!harness) throw new Error(`unknown provider "${provider}"`);
327
+ if (!harnessSupportsModelSelection(harness)) return { provider, models: [], custom: false, error: `${harness.displayName} does not publish a model selector.` };
328
+ const onIt = session?.route === "local" && session.nativeHarness === harness.command ? session : void 0;
329
+ const account = accountFor(state, session, harness);
330
+ const catalog = await nativeModelCatalogForPicker(harness, account, IDE_MODEL_DISCOVERY_WAIT_MS);
331
+ const free = freePlanModels(harness, account, catalog);
332
+ const effective = onIt?.model ?? catalog.configured ?? void 0;
333
+ const models = [...catalog.models].sort((left, right) => left === effective ? -1 : right === effective ? 1 : left.localeCompare(right)).map((model) => {
334
+ const row = modelRow(harness, catalog, model, void 0, false, free);
335
+ const detail = row.detail?.replace(/^·\s*/, "").trim();
336
+ return { id: model, label: row.label, ...detail ? { detail } : {}, current: Boolean(onIt) && model === effective };
337
+ });
338
+ return { provider, models, custom: true };
339
+ }
340
+ async function conversationList(state, currentId) {
341
+ const sessions = state.sessions.filter((session) => session.status !== "archived" || session.id === currentId).filter((session) => session.id === currentId || !isBlankConversation(session));
342
+ const workers = await liveWorkers();
343
+ const pending = await livePendingTurns(sessions, workers.isLive, workers.background, workers.runningTurn);
344
+ return conversationRows(sessions, { workerIsLive: workers.isLive, isOpen: workers.isOpen, runningTurn: workers.runningTurn, background: workers.background, awaitingYou: workers.awaitingYou, pending, ...currentId ? { currentId } : {} }).map((row) => {
345
+ const latest = row.latest;
346
+ const opened = transcriptWasLoaded(latest) || latest.messages !== void 0 || latest.pendingTurn !== void 0;
347
+ const messages = opened ? textTranscript(sessionTranscriptMessages(latest)) : [];
348
+ const last = conversationPreview(latest, 140);
349
+ const titled = latest.name?.replace(/\s+\(from [^)]+\)$/i, "").trim() || (opened ? messages.find((message) => message.role === "user")?.content.replace(/\s+/g, " ").trim().slice(0, 80) : latest.listPreview) || "Untitled chat";
350
+ const harness = latest.nativeHarness ? localHarnessForCommand(latest.nativeHarness) : void 0;
351
+ return {
352
+ id: latest.id,
353
+ title: titled,
354
+ workspace: latest.workspace,
355
+ ...latest.route === "gateway" || latest.route === "clikcode-local" ? { provider: GATEWAY_LABEL } : harness ? { provider: harness.displayName } : {},
356
+ updatedAt: latest.updatedAt,
357
+ messages: opened ? messages.length : latest.listMessageCount ?? 0,
358
+ ...last ? { preview: last.slice(0, 140) } : {},
359
+ // Only a live generating turn is `working` (animated). An idle worker
360
+ // still marks the row, but Active vs Past is by recency, not liveness.
361
+ ...row.activity ? { activity: row.activity } : {},
362
+ ...row.activity === "working" && row.pending ? { turn: turnFacts(row.pending) } : {},
363
+ ...row.needsYou ? { needsYou: true } : {},
364
+ ...latest.resumeAt ? { resumeAt: latest.resumeAt.at } : {},
365
+ section: row.section,
366
+ current: row.current
367
+ };
368
+ });
369
+ }
370
+ async function accountList(state, session, network) {
371
+ const now = Date.now();
372
+ const accounts = await Promise.all(state.accounts.map(async (account) => {
373
+ const harness = localHarnessForProvider(account.provider);
374
+ const asked = network && harness && account.authKind === "vendor-cli" && NATIVE_USAGE_PROBES[harness.command] ? await accountUsageReading(account, state, { network: true }).catch(quiet("ide/queries")) : void 0;
375
+ const usage = asked ? { ...asked.label ? { label: asked.label } : {}, windows: usageWindows(asked.windows) } : accountUsage(account, state, now);
376
+ return { ...accountRow(account, harness, session, now), ...usage ? { usage } : {} };
377
+ }));
378
+ accounts.sort((left, right) => left.providerName.localeCompare(right.providerName) || left.label.localeCompare(right.label));
379
+ const addable = allLocalHarnesses().filter((harness) => harnessCanRunTurns(harness) && harnessCanAddAccount(harness)).sort((left, right) => compareProviders({ harness: left }, { harness: right })).map((harness) => ({ provider: harness.command, name: harness.displayName }));
380
+ const chatHarness = session?.route === "local" && session.nativeHarness ? localHarnessForCommand(session.nativeHarness) : void 0;
381
+ return {
382
+ accounts,
383
+ addable,
384
+ ...chatHarness ? { chat: { provider: chatHarness.command, name: chatHarness.displayName } } : {}
385
+ };
386
+ }
387
+ async function chatSettings(state, session) {
388
+ const harness = harnessOf(session);
389
+ const settings = { send: sendModeOf(state.globalSettings) };
390
+ const effort = await effortChoices(state, session, harness);
391
+ if (effort) settings.effort = { ...effort.current ? { current: effort.current } : {}, choices: effort.choices };
392
+ if (isGatewayService(session)) settings.fast = session.speed === "fast";
393
+ const permissions = sessionPermissionModes(session, isClikCodeAgent(session) ? void 0 : harness);
394
+ if (permissions.length) settings.permissions = { current: session.permissionMode ?? "ask", choices: [...permissions] };
395
+ if (planModeOnChat(session, harness)) settings.plan = session.planMode === true;
396
+ else if (harness?.planMode) settings.plan = session.harnessOptions?.[harness.planMode.option] === harness.planMode.value;
397
+ return settings;
398
+ }
399
+ async function gatewayStatus(config, fetchImpl = fetch) {
400
+ const apiUrl = getApiUrl(config);
401
+ const apiKey = getApiKeyForUrl(config, apiUrl);
402
+ if (!apiKey) return { connected: false, apiUrl };
403
+ try {
404
+ const response = await fetchImpl(new URL("/v1/credits", apiUrl), {
405
+ headers: { authorization: `Bearer ${apiKey}`, accept: "application/json", "user-agent": CLIKCODE_USER_AGENT },
406
+ signal: AbortSignal.timeout(1e4)
407
+ });
408
+ const body = await response.json().catch(quiet("ide/queries"));
409
+ if (!response.ok || !body?.data) return { connected: true, apiUrl, error: `the Gateway answered HTTP ${response.status}` };
410
+ return { connected: true, apiUrl, credit: creditOf(body.data) };
411
+ } catch (error) {
412
+ return { connected: true, apiUrl, error: error instanceof Error ? error.message : String(error) };
413
+ }
414
+ }
415
+ function creditOf(data) {
416
+ const number = (value) => {
417
+ const parsed = typeof value === "string" ? Number(value) : typeof value === "number" ? value : Number.NaN;
418
+ return Number.isFinite(parsed) ? parsed : void 0;
419
+ };
420
+ const micro = number(data.balanceMicroUsd) ?? number(data.balance_micro_usd);
421
+ const cents = number(data.balanceCents) ?? number(data.balance_cents);
422
+ const usd = number(data.balanceUsd) ?? number(data.balance_usd);
423
+ const balanceUsd = micro !== void 0 ? micro / 1e6 : cents !== void 0 ? cents / 100 : usd;
424
+ const autoTopUp = data.auto_top_up && typeof data.auto_top_up === "object" ? data.auto_top_up : void 0;
425
+ return {
426
+ unlimited: data.unlimited === true,
427
+ ...balanceUsd !== void 0 ? { balanceUsd } : {},
428
+ ...typeof data.allowed === "boolean" ? { allowed: data.allowed } : {},
429
+ ...typeof data.autoTopUpEnabled === "boolean" ? { autoTopUp: data.autoTopUpEnabled } : typeof autoTopUp?.enabled === "boolean" ? { autoTopUp: autoTopUp.enabled } : {}
430
+ };
431
+ }
432
+ async function gatewayCheckoutUrl(config, fetchImpl = fetch) {
433
+ const apiUrl = getApiUrl(config);
434
+ const apiKey = getApiKeyForUrl(config, apiUrl);
435
+ if (!apiKey) throw new Error("Sign in to ClikDeploy Gateway first.");
436
+ const response = await fetchImpl(new URL("/v1/credits/checkout", apiUrl), {
437
+ method: "POST",
438
+ headers: { authorization: `Bearer ${apiKey}`, accept: "application/json", "content-type": "application/json", "user-agent": CLIKCODE_USER_AGENT },
439
+ body: "{}"
440
+ });
441
+ const body = await response.json().catch(quiet("ide/queries"));
442
+ const url = typeof body?.data?.url === "string" ? body.data.url : void 0;
443
+ if (!response.ok || !url) throw new Error(`ClikDeploy Gateway credit: HTTP ${response.status}`);
444
+ return url;
445
+ }
446
+
447
+ // src/gateway/credit-label.ts
448
+ var CREDIT_TTL_MS = 6e4;
449
+ var cached;
450
+ async function gatewayCreditLabel(config, options = {}) {
451
+ if (options.cachedOnly) return cached?.label;
452
+ if (!options.fresh && cached && Date.now() - cached.at < CREDIT_TTL_MS) return cached.label;
453
+ const fetchImpl = options.fetchImpl ?? fetch;
454
+ const credit = (await gatewayStatus(config, fetchImpl)).credit;
455
+ const left = !credit ? void 0 : credit.unlimited ? "Unlimited" : credit.balanceUsd === void 0 ? void 0 : credit.balanceUsd <= 0 || credit.allowed === false ? "Out of credits" : `${dollars(credit.balanceUsd)} credit left`;
456
+ const label = left === "Unlimited" ? "Unlimited credit" : left;
457
+ cached = { at: Date.now(), label };
458
+ return label;
459
+ }
460
+ function gatewayConversationUsageLabel(costUsd, creditLabel) {
461
+ const parts = [chatCostLabel(costUsd), creditLabel].filter((part) => Boolean(part));
462
+ return parts.length ? parts.join(" \u2022 ") : void 0;
463
+ }
464
+
465
+ // src/worker/warm-policy.ts
466
+ function shouldWarmVendorChat(session) {
467
+ if (session.route !== "local" || !session.nativeHarness || !session.accountId || !session.nativeSessionId && !session.messages?.length) return false;
468
+ const harness = localHarnessForCommand(session.nativeHarness);
469
+ if (!harness) return false;
470
+ const transport = sessionTurnTransport(harness, session);
471
+ return transport === "acp" || transport === "codex-app-server";
472
+ }
473
+
474
+ // src/tui/slash/dispatch.ts
475
+ import { existsSync } from "node:fs";
476
+
477
+ // src/tui/pickers/account.ts
478
+ var ACCOUNT_ACTION_LABELS = { reauthenticate: "Reauthenticate", verified: "I\u2019ve verified it", disconnect: "Disconnect", remove: "Remove" };
479
+ var ACCOUNT_PROBLEM_WORDS = { verify: "verify", "sign-in": "not signed in", reauth: "reauth" };
480
+ function accountPickerOptions(accounts, session, harness) {
481
+ const mine = accounts.filter(({ account }) => account.provider === harness.provider).sort((left, right) => left.account.label.localeCompare(right.account.label));
482
+ return [
483
+ ...mine.map(({ account, usage, usagePending }) => {
484
+ const row = accountRow(account, harness, session);
485
+ const last = row.actions.at(-1);
486
+ const deleteWith = last === "disconnect" || last === "remove" ? last : void 0;
487
+ const actionLabel = (value) => value === "reauthenticate" && row.problem === "sign-in" ? "Sign in" : ACCOUNT_ACTION_LABELS[value];
488
+ return {
489
+ label: row.label,
490
+ // One state per row: a problem outranks usage, so the eye lands on
491
+ // the single thing that matters. Provider/auth kind is not shown.
492
+ detail: [
493
+ row.problem === "out-of-usage" ? source_default.yellow(outOfUsageText(row.backAt)) : row.problem ? source_default.yellow(ACCOUNT_PROBLEM_WORDS[row.problem]) : usage ?? (usagePending ? "\u2026" : ""),
494
+ row.current ? "\xB7 current" : ""
495
+ ].filter(Boolean).join(" "),
496
+ value: { kind: "account", harness: harness.command, accountId: account.id },
497
+ actions: row.actions.filter((value) => value !== deleteWith).map((value) => ({ label: actionLabel(value), value })),
498
+ // Signing out is undone by signing in (/login, or Tab on the row):
499
+ // it runs at once, as /logout does. Removing an account is not, and asks.
500
+ ...deleteWith ? { deleteAction: { label: ACCOUNT_ACTION_LABELS[deleteWith], value: deleteWith, ...deleteWith === "disconnect" ? { undoable: true } : {} } } : {}
501
+ };
502
+ }),
503
+ // The only way to connect a second login from inside /account.
504
+ ...harnessCanAddAccount(harness) ? [{ label: "+ Add account\u2026", detail: `\xB7 ${harness.displayName}`, value: { kind: "add-account", harness: harness.command } }] : []
505
+ ];
506
+ }
507
+ async function useAddedAccount(id, harness, label) {
508
+ const state = await readState({ transcripts: [] });
509
+ const added = state.accounts.find((account) => account.provider === harness.provider && account.label === label);
510
+ if (added) await aiSessionCommand(id, `/settings account ${added.id}`);
511
+ return id;
512
+ }
513
+ async function interactiveAccountPicker(rl, id) {
514
+ for (; ; ) {
515
+ const state = await readState({ transcripts: [id] });
516
+ const session = state.sessions.find((item) => item.id === id);
517
+ if (!session) throw new Error(`AI session "${id}" was not found`);
518
+ const harness = sessionOrProviderHarness(session);
519
+ if (!harness || isClikCodeAgent(session)) {
520
+ rl.panel?.("Accounts", "Choose a local provider before switching accounts.");
521
+ return void 0;
522
+ }
523
+ const providerAccounts = state.accounts.filter((account) => account.provider === harness.provider);
524
+ if (!providerAccounts.length) {
525
+ const added = await addAccountForHarness(rl, harness);
526
+ return added ? useAddedAccount(id, harness, added) : void 0;
527
+ }
528
+ let usagePending = NATIVE_USAGE_PROBES[harness.command] !== void 0;
529
+ const accountOptions = () => accountPickerOptions(
530
+ providerAccounts.map((account) => ({
531
+ account,
532
+ usage: cachedAccountUsageLabel(account, state),
533
+ usagePending: usagePending && account.authKind === "vendor-cli"
534
+ })),
535
+ session,
536
+ harness
537
+ );
538
+ const usageRefresh = Promise.allSettled(providerAccounts.map((account) => accountUsageLabel(account, state, { network: true }))).then(() => {
539
+ usagePending = false;
540
+ });
541
+ let actionPerformed = false;
542
+ let signedIn;
543
+ const selected = await chooseOption(
544
+ rl,
545
+ `${harness.displayName} accounts`,
546
+ accountOptions(),
547
+ async (choice, action) => {
548
+ if (choice.kind !== "account") return;
549
+ actionPerformed = true;
550
+ await manageAccountAction(rl, choice.accountId, action);
551
+ if (action === "reauthenticate") signedIn = choice.accountId;
552
+ },
553
+ // ← is back to whatever opened the list (Settings' row), or closes it,
554
+ // as in every other list.
555
+ { refreshedOptions: accountOptions, refresh: usageRefresh, totalItems: providerAccounts.length }
556
+ );
557
+ if (signedIn) {
558
+ await aiSessionCommand(id, `/settings account ${signedIn}`);
559
+ return id;
560
+ }
561
+ if (actionPerformed) continue;
562
+ if (selected?.kind === "add-account") {
563
+ const added = await addAccountForHarness(rl, harness);
564
+ if (added) return useAddedAccount(id, harness, added);
565
+ continue;
566
+ }
567
+ if (!selected || selected.kind !== "account") return void 0;
568
+ const picked = providerAccounts.find((account) => account.id === selected.accountId);
569
+ if (picked && accountRow(picked, harness, session).problem === "sign-in") await manageAccountAction(rl, picked.id, "reauthenticate");
570
+ const pending = picked?.verification;
571
+ if (pending) {
572
+ if (pending.url && hasLocalDisplay()) openLoginUrl(pending.url);
573
+ rl.panel?.("Verify this account", verificationNotice(pending));
574
+ }
575
+ await aiSessionCommand(id, `/settings account ${selected.accountId}`);
576
+ return id;
577
+ }
578
+ }
579
+ async function addAccountForHarness(rl, harness) {
580
+ if (!harness.loginArgv) throw new Error(`${harness.displayName} doesn't publish a login command -- nothing here can add an account for it.`);
581
+ return withSignIn(rl, harness.displayName, () => aiAccountLogin(harness.command));
582
+ }
583
+ async function manageAccountAction(rl, accountId, action) {
584
+ const state = await readState({ transcripts: [] });
585
+ const account = state.accounts.find((item) => item.id === accountId);
586
+ const harness = account ? localHarnessForProvider(account.provider) : void 0;
587
+ if (!account || !harness) return;
588
+ if (action === "remove") {
589
+ await aiAccountRemove(account.id);
590
+ return;
591
+ }
592
+ if (action === "verified") {
593
+ account.verification = void 0;
594
+ await writeState(state);
595
+ return;
596
+ }
597
+ if (account.authKind !== "vendor-cli") {
598
+ if (action === "disconnect") throw new Error(`${account.label} is an API key, not a sign-in -- remove it from /account (Del) instead.`);
599
+ return;
600
+ }
601
+ const environment = nativeProfileEnvironment(account.nativeProfile);
602
+ if (action === "disconnect") {
603
+ await signOutAccount(account.id);
604
+ } else if (action === "reauthenticate" && harness.loginArgv) {
605
+ await withSignIn(rl, harness.displayName, () => loginNativeHarness(harness, environment));
606
+ await syncAccountIdentityAfterLogin(harness, account, state);
607
+ }
608
+ }
609
+
610
+ // src/tui/pickers/effort.ts
611
+ async function interactiveEffortPicker(rl, id) {
612
+ const state = await readState({ transcripts: [id] });
613
+ const session = state.sessions.find((item) => item.id === id);
614
+ if (!session) throw new Error(`AI session "${id}" was not found`);
615
+ if (session.route === "clikcode-local") throw new Error("A model on this computer has no reasoning-effort control to set.");
616
+ const harness = session.nativeHarness ? localHarnessForCommand(session.nativeHarness) : void 0;
617
+ const effort = await effortChoices(state, session, harness);
618
+ if (!effort) throw new Error(`${harness?.displayName ?? "This provider"} does not publish a configurable reasoning-effort flag.`);
619
+ const decides = effort.gateway ? "the model decides" : `${harness?.displayName ?? "the harness"} decides`;
620
+ const selected = await chooseOption(rl, "Reasoning effort", [
621
+ { label: "Default", detail: `${effort.current ? "" : "\xB7 current "}\xB7 ${decides}`, value: "default" },
622
+ ...effort.choices.map((value) => ({
623
+ label: settingLabel(value),
624
+ detail: value === effort.current ? "\xB7 current" : effort.gateway && value === "none" ? "\xB7 least reasoning the model allows" : void 0,
625
+ value
626
+ }))
627
+ ]);
628
+ if (selected) await applyToChat(id, "effort", selected);
629
+ }
630
+
631
+ // src/tui/pickers/options.ts
632
+ async function interactiveHarnessOptionPicker(rl, id) {
633
+ for (; ; ) {
634
+ if (!await harnessOptionPickerOnce(rl, id) || lastPickerExit === "escape") return;
635
+ }
636
+ }
637
+ async function harnessOptionPickerOnce(rl, id) {
638
+ const state = await readState({ transcripts: [id] });
639
+ const session = state.sessions.find((item) => item.id === id);
640
+ if (!session) throw new Error(`AI session "${id}" was not found`);
641
+ const harness = session.nativeHarness ? localHarnessForCommand(session.nativeHarness) : void 0;
642
+ if (!harness) throw new Error("Choose a provider first.");
643
+ const manifest = localHarnessCapabilityManifest(harness);
644
+ const account = session.accountId ? state.accounts.find((item) => item.id === session.accountId) : void 0;
645
+ const discovered = harness.command === "hermes" ? await discoverHermesChoices(harness, account).catch(quiet("tui/pickers/options")) : void 0;
646
+ const options = manifest.options.map((item) => {
647
+ if (!discovered) return item;
648
+ if (item.id === "toolsets" && discovered.toolsets.length) return { ...item, values: discovered.toolsets };
649
+ return item;
650
+ });
651
+ const current = (item) => session.harnessOptions?.[item.id];
652
+ const save = async (optionId, raw2) => {
653
+ const fresh = await readState({ transcripts: [id] });
654
+ const target = fresh.sessions.find((item) => item.id === id);
655
+ if (!target) return;
656
+ if (raw2 === "default" || raw2 === "-") {
657
+ const { [optionId]: _cleared, ...rest } = target.harnessOptions ?? {};
658
+ target.harnessOptions = rest;
659
+ } else setSessionHarnessOption(target, harness, optionId, raw2);
660
+ target.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
661
+ await writeState(fresh);
662
+ };
663
+ const inlineFor = (item) => {
664
+ if (item.dangerous) return {};
665
+ const values = item.kind === "boolean" ? ["on", "off"] : item.values ?? [];
666
+ if (values.length < 2 || values.length > 4) return {};
667
+ const now = current(item);
668
+ const currentValue = item.kind === "boolean" ? now === true ? "on" : "off" : now === void 0 ? "default" : String(now);
669
+ return {
670
+ inline: {
671
+ choices: [
672
+ ...item.kind === "boolean" ? [] : [{ label: "Default", value: "default" }],
673
+ ...values.map((value) => ({ label: value[0].toUpperCase() + value.slice(1), value }))
674
+ ],
675
+ current: currentValue,
676
+ apply: (value) => save(item.id, value)
677
+ }
678
+ };
679
+ };
680
+ const option = await chooseOption(rl, `${harness.displayName} options`, vendorFacingOptions(options, harness).map((item) => ({
681
+ label: item.label,
682
+ detail: [
683
+ `\xB7 ${item.description}`,
684
+ ...item.kind === "boolean" ? [current(item) === true ? "on" : "off"] : current(item) !== void 0 ? [source_default.cyan(Array.isArray(current(item)) ? current(item).join(", ") : String(current(item)))] : [],
685
+ ...item.dangerous ? [source_default.yellow("dangerous")] : []
686
+ ].join(" \xB7 "),
687
+ value: item,
688
+ ...inlineFor(item)
689
+ })));
690
+ if (!option) return false;
691
+ let raw;
692
+ if (option.kind === "boolean") {
693
+ const turningOn = current(option) !== true;
694
+ raw = turningOn ? await chooseOption(rl, `Turn on ${option.label}?`, [
695
+ // Cancel first, as in every confirmation.
696
+ { label: "Cancel", value: "" },
697
+ { label: "Turn on", detail: `\xB7 ${source_default.yellow("dangerous")}`, value: "on" }
698
+ ]) : "off";
699
+ } else if (option.values?.length) {
700
+ raw = await chooseOption(rl, option.label, [
701
+ { label: "Default", detail: `${current(option) === void 0 ? "\xB7 current " : ""}\xB7 ${harness.displayName} decides`, value: "default" },
702
+ ...option.values.map((entry) => ({ label: entry, detail: current(option) === entry ? "\xB7 current" : void 0, value: entry }))
703
+ ]);
704
+ } else {
705
+ const list = option.kind === "string-list" || option.kind === "path-list";
706
+ raw = (await rl.question(`${option.label}${list ? " (comma-separated)" : ""}${current(option) !== void 0 ? " \xB7 - clears" : ""} \u203A `)).trim();
707
+ }
708
+ if (raw === void 0 || raw === "") return true;
709
+ await save(option.id, raw);
710
+ return true;
711
+ }
712
+
713
+ // src/tui/pickers/tools.ts
714
+ function harnessManagers(harness) {
715
+ const managers = localHarnessCapabilityManifest(harness).managers;
716
+ return Object.entries(managers ?? {}).filter((entry) => Boolean(entry[1]));
717
+ }
718
+ async function interactiveToolsPicker(rl, id, harness) {
719
+ const managers = harnessManagers(harness);
720
+ const choice = await chooseOption(rl, "Tools & integrations", [
721
+ ...managers.map(([name, manager2]) => ({
722
+ label: manager2.label,
723
+ detail: `\xB7 ${[manager2.listArgv ? "list" : "", manager2.manageArgv ? `open ${harness.displayName}'s manager` : ""].filter(Boolean).join(" \xB7 ")}`,
724
+ value: name
725
+ })),
726
+ { label: "Add an MCP server", detail: "\xB7 for ClikCode's own agent", value: "__mcp_everywhere__" }
727
+ ]);
728
+ if (!choice) return;
729
+ if (choice === "__mcp_everywhere__") return addMcpEverywhere(rl);
730
+ const manager = managers.find(([name]) => name === choice)?.[1];
731
+ if (!manager) return;
732
+ const state = await readState({ transcripts: [id] });
733
+ const session = state.sessions.find((item) => item.id === id);
734
+ if (!session) return;
735
+ const action = manager.listArgv && manager.manageArgv ? await chooseOption(rl, manager.label, [
736
+ { label: `Show ${manager.label.toLowerCase()}`, value: "list" },
737
+ { label: `Open ${harness.displayName}'s manager`, value: "manage" }
738
+ ]) : manager.listArgv ? "list" : "manage";
739
+ if (action === "list") {
740
+ const listing = await nativeManagerListing(state, session, choice);
741
+ rl.panel?.(listing.label, listing.text);
742
+ } else if (action === "manage" && manager.manageArgv && rl instanceof TerminalHarnessPrompter) {
743
+ const account = session.accountId ? state.accounts.find((item) => item.id === session.accountId) : void 0;
744
+ await rl.suspend();
745
+ try {
746
+ await runNativeHarnessCommand(harness, manager.manageArgv, turnEnvironment(harness, account));
747
+ } finally {
748
+ rl.resume();
749
+ }
750
+ }
751
+ }
752
+ async function addMcpEverywhere(rl) {
753
+ const name = (await rl.question("Server name \u203A ")).trim();
754
+ if (!name) return;
755
+ const line = (await rl.question("Command to run, or URL \u203A ")).trim();
756
+ if (!line) return;
757
+ const [target, ...args] = line.split(/\s+/);
758
+ await recordSharedMcpServer({ name, target, ...args.length ? { args } : {} });
759
+ rl.panel?.(`MCP server ${name}`, `${name} is recorded for ClikCode's own agent.`);
760
+ }
761
+
762
+ // src/tui/pickers/settings.ts
763
+ var INLINE_MAX_CHOICES = 4;
764
+ function defaultActions(harness, key, hasValue = true) {
765
+ if (!hasValue) return [];
766
+ return [
767
+ ...harness ? [{ label: `Make default for ${harness.displayName}`, value: `provider:${key}` }] : [],
768
+ ...key === "model" ? [] : [{ label: "Make default for every harness", value: `global:${key}` }]
769
+ ];
770
+ }
771
+ async function interactiveSettingsPicker(config, rl, startId) {
772
+ let id = startId;
773
+ let returnTo;
774
+ for (; ; ) {
775
+ const state = await readState({ transcripts: [id] });
776
+ const session = state.sessions.find((item) => item.id === id);
777
+ if (!session) return id;
778
+ const harness = session.nativeHarness ? localHarnessForCommand(session.nativeHarness) : void 0;
779
+ const account = session.accountId ? state.accounts.find((item) => item.id === session.accountId) : void 0;
780
+ const effort = await effortChoices(state, session, harness);
781
+ const permissions = sessionPermissionModes(session, isClikCodeAgent(session) ? void 0 : harness);
782
+ const inline = (choices, current, apply) => choices.length >= 2 && choices.length <= INLINE_MAX_CHOICES ? { inline: { choices, current, apply } } : {};
783
+ const idle = isGatewayService(session) ? await import("./chunk-DKDPZTD3.js").then(async (own) => ({ own, minutes: await own.ownModelIdleMinutes({ config, timeoutMs: 5e3 }) })).catch(quiet("tui/pickers/settings")) : void 0;
784
+ const optionCount = harness ? vendorFacingOptions(localHarnessCapabilityManifest(harness).options, harness).length : 0;
785
+ const setOptions = Object.keys(session.harnessOptions ?? {}).length;
786
+ const values = (of) => ({
787
+ model: of.model ?? void 0,
788
+ effort: of.effort || void 0,
789
+ permissions: of.permissionMode ?? "ask"
790
+ });
791
+ const rows = [
792
+ { label: "Resume", detail: "choose a conversation", value: "resume" },
793
+ {
794
+ label: "Provider",
795
+ detail: harness?.displayName ?? (isClikCodeAgent(session) ? GATEWAY_LABEL : "none chosen"),
796
+ value: "provider",
797
+ ...harness ? { actions: [{ label: `Use global defaults for ${harness.displayName}`, value: "clear-provider" }] } : {}
798
+ },
799
+ ...!harness ? [
800
+ {
801
+ label: "Every harness \xB7 permissions",
802
+ detail: settingLabel(state.globalSettings.permissionMode),
803
+ value: "global-permissions",
804
+ inline: {
805
+ choices: VALID_PERMISSION_MODES.map((value) => ({ label: settingLabel(value), value })),
806
+ current: state.globalSettings.permissionMode,
807
+ apply: (value) => aiSettingsSetGlobal("permissions", value, false)
808
+ }
809
+ }
810
+ ] : [],
811
+ ...harness && harnessSupportsModelSelection(harness) ? [{
812
+ label: "Model",
813
+ detail: session.model ? nativeModelLabel(harness.command, session.model) ?? session.model : "harness default",
814
+ value: "model",
815
+ actions: defaultActions(harness, "model", Boolean(session.model))
816
+ }] : [],
817
+ // Unset until the engine picks on the first turn; the picker says which
818
+ // it would choose.
819
+ ...session.route === "clikcode-local" ? [{
820
+ label: "Model",
821
+ detail: localModelLabel(session.model) ?? "chosen for this machine on the first turn",
822
+ value: "model"
823
+ }] : [],
824
+ ...harness ? [{ label: "Account", detail: account?.label ?? "automatic", value: "account" }] : [],
825
+ ...effort ? [{
826
+ label: "Effort",
827
+ detail: settingLabel(effort.current ?? ""),
828
+ value: "effort",
829
+ actions: defaultActions(harness, "effort"),
830
+ // Default is a real choice: no level sent, the harness decides.
831
+ ...inline(
832
+ [{ label: "Default", value: "default" }, ...effort.choices.map((value) => ({ label: settingLabel(value), value }))],
833
+ effort.current || "default",
834
+ (value) => applyToChat(id, "effort", value)
835
+ )
836
+ }] : [],
837
+ ...permissions.length ? [{
838
+ label: "Permissions",
839
+ detail: settingLabel(session.permissionMode ?? "ask"),
840
+ value: "permissions",
841
+ actions: defaultActions(harness, "permissions"),
842
+ ...inline(permissions.map((value) => ({ label: settingLabel(value), value })), session.permissionMode ?? "ask", (value) => applyToChat(id, "permissions", value))
843
+ }] : [],
844
+ // One Plan mode for every harness that has a read-only planning mode,
845
+ // whatever the vendor calls it.
846
+ ...harness?.planMode ? [{
847
+ label: "Plan mode",
848
+ detail: "read-only: plan, change nothing",
849
+ value: "plan",
850
+ inline: {
851
+ choices: [{ label: "Off", value: "off" }, { label: "On", value: "on" }],
852
+ current: session.harnessOptions?.[harness.planMode.option] === harness.planMode.value ? "on" : "off",
853
+ apply: (value) => aiSessionCommand(id, `/settings option ${harness.planMode.option} ${value === "on" ? String(harness.planMode.value === true ? "on" : harness.planMode.value) : "default"}`).then(() => void 0)
854
+ }
855
+ }] : [],
856
+ // Plan mode kept on the chat: ClikCode's own agent, or a vendor whose
857
+ // plan mode is an ACP session mode (agent/plan-mode-setting.ts).
858
+ ...planModeOnChat(session, harness) ? [{
859
+ label: "Plan mode",
860
+ detail: "read-only: plan, change nothing",
861
+ value: "plan",
862
+ inline: {
863
+ choices: [{ label: "Off", value: "off" }, { label: "On", value: "on" }],
864
+ current: session.planMode === true ? "on" : "off",
865
+ apply: (value) => setAgentPlanMode(id, value === "on")
866
+ }
867
+ }] : [],
868
+ ...idle ? [{
869
+ label: "Your models turn off after",
870
+ detail: `${idle.own.idleWords(idle.minutes)} idle \xB7 GPU released, wakes on the next message`,
871
+ value: "model-idle",
872
+ inline: {
873
+ choices: idle.own.OWN_MODEL_IDLE_CHOICES.map((minutes) => ({ label: minutes ? idle.own.idleWords(minutes) : "Never", value: String(minutes) })),
874
+ current: String(idle.minutes),
875
+ apply: (value) => idle.own.setOwnModelIdleMinutes(Number(value), { config }).then(() => void 0)
876
+ }
877
+ }] : [],
878
+ ...idle ? [{
879
+ label: "Start hosted AI models without asking",
880
+ detail: idle.own.alwaysStartOwnModels(config) ? "On \xB7 saved on this machine" : "Off \xB7 ask before waking a sleeping model",
881
+ value: "own-model-start-confirmation",
882
+ inline: {
883
+ choices: [{ label: "Off", value: "off" }, { label: "On", value: "on" }],
884
+ current: idle.own.alwaysStartOwnModels(config) ? "on" : "off",
885
+ apply: (value) => Promise.resolve(idle.own.setAlwaysStartOwnModels(value === "on", config))
886
+ }
887
+ }] : [],
888
+ ...harness && optionCount ? [{ label: `${harness.displayName} options`, detail: setOptions ? `${setOptions} set` : `${optionCount} available`, value: "options" }] : [],
889
+ ...harness ? [{ label: "Tools & integrations", detail: harnessManagers(harness).map(([, manager]) => manager.label).join(", ") || "MCP servers", value: "tools" }] : []
890
+ ];
891
+ let actedOn;
892
+ const selected = await chooseOption(rl, "Settings", rows, async (row, action) => {
893
+ actedOn = row;
894
+ if (action === "clear-provider" && harness) {
895
+ await aiSettingsClearProvider(harness.command, false);
896
+ return;
897
+ }
898
+ const [scope, key] = action.split(":");
899
+ const now = (await readState({ transcripts: [] })).sessions.find((item) => item.id === id);
900
+ const value = now ? values(now)[key] : void 0;
901
+ if (!value) return;
902
+ if (scope === "global") await aiSettingsSetGlobal(key, value, false);
903
+ else if (harness) await aiSettingsSetProvider(harness.command, key, value, false);
904
+ }, returnTo === void 0 ? void 0 : { startAt: returnTo });
905
+ if (selected === void 0 && actedOn !== void 0 && lastPickerExit === "choose") {
906
+ returnTo = actedOn;
907
+ continue;
908
+ }
909
+ if (selected === void 0) return id;
910
+ returnTo = selected;
911
+ if (selected === "resume") {
912
+ const picked = await interactiveSessionPicker(rl, id);
913
+ if (picked) id = "new" in picked ? await newConversation(id) : picked.id;
914
+ } else if (selected === "provider") id = await interactiveEnginePicker(config, rl, id) ?? id;
915
+ else if (selected === "account") id = await interactiveAccountPicker(rl, id) ?? id;
916
+ else if (selected === "model") await interactiveModelPicker(rl, id);
917
+ else if (selected === "effort") await interactiveEffortPicker(rl, id);
918
+ else if (selected === "permissions") await interactivePermissionPicker(rl, id);
919
+ else if (selected === "options") await interactiveHarnessOptionPicker(rl, id);
920
+ else if (selected === "tools" && harness) await interactiveToolsPicker(rl, id, harness);
921
+ if (lastPickerExit === "escape") return id;
922
+ }
923
+ }
924
+
925
+ // src/tui/doctor-summary.ts
926
+ async function doctorSummary(state) {
927
+ const harnesses = allLocalHarnesses().filter((harness) => harnessCanRunTurns(harness));
928
+ const inspections = await Promise.all(harnesses.map(async (harness) => ({ harness, inspection: await inspectNativeHarnessForPicker(harness) })));
929
+ const installed = inspections.filter((item) => item.inspection.installed);
930
+ return [
931
+ `Installed harnesses (${installed.length}/${inspections.length})`,
932
+ ...installed.map(({ harness, inspection }) => ` ${harness.displayName}${inspection.version ? ` ${inspection.version}` : ""} \xB7 ${integrationLabel(harness)}`),
933
+ "",
934
+ `Accounts (${state.accounts.length})`,
935
+ ...state.accounts.length ? state.accounts.map((account) => ` ${account.label} \xB7 ${account.provider} \xB7 ${account.status === "needs_login" ? "needs reauthentication" : account.status}${accountQuotaSpent(account) ? " \xB7 quota exhausted" : ""}${account.verification ? " \xB7 needs verification" : ""}`) : [" none yet \u2014 /provider adds one"],
936
+ "",
937
+ `State: ${compactPath(stateDirectory())}`
938
+ ].join("\n");
939
+ }
940
+
941
+ // src/tui/slash/dispatch.ts
942
+ function sessionAccount(state, session) {
943
+ return session.accountId ? state.accounts.find((item) => item.id === session.accountId) : void 0;
944
+ }
945
+ async function hasHarness(id) {
946
+ const session = (await readState({ transcripts: [] })).sessions.find((item) => item.id === id);
947
+ return Boolean(session && (session.nativeHarness || isClikCodeAgent(session)));
948
+ }
949
+ async function agentMcpCommand(host, words) {
950
+ const [action, name] = words;
951
+ if ((action === "login" || action === "logout") && !name) throw new Error(`Usage: /mcp ${action} <name>`);
952
+ if (action === "logout") {
953
+ await forgetMcpOAuth(stateDirectory(), name);
954
+ return {};
955
+ }
956
+ if (action === "login") {
957
+ const screen = host.prompter.signInScreen?.(name);
958
+ if (!screen) throw new Error(`Sign in from a terminal: clikcode mcp login ${name}`);
959
+ try {
960
+ await loginMcpServer(name, mcpSignInUiFor(screen));
961
+ } catch (error) {
962
+ if (screen.signal.aborted) return {};
963
+ throw error;
964
+ } finally {
965
+ screen.stop();
966
+ }
967
+ return {};
968
+ }
969
+ if (action) throw new Error("Usage: /mcp [login|logout <name>]");
970
+ const text = await host.withBusy("checking MCP servers\u2026", () => mcpServersText());
971
+ host.panel("mcp", "MCP servers", text, `MCP servers
972
+
973
+ ${stripAnsi(text)}`);
974
+ return {};
975
+ }
976
+ async function dispatchLine(host, id, line, options = {}) {
977
+ const rl = host.prompter;
978
+ const viaHeadless = async (text2) => {
979
+ const resulting = await aiSessionCommand(id, text2);
980
+ return resulting !== id ? { id: resulting } : {};
981
+ };
982
+ const state = await readState({ transcripts: [id] });
983
+ const session = state.sessions.find((item) => item.id === id);
984
+ if (!session) throw new Error(`AI session "${id}" was not found`);
985
+ const workspace = session.workspace ?? process.cwd();
986
+ const attachment = await resolveStandaloneAttachment(line, workspace);
987
+ if (attachment) {
988
+ await queueAttachment(session, attachment);
989
+ session.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
990
+ await writeState(state);
991
+ host.attached?.(session.attachments ?? []);
992
+ return {};
993
+ }
994
+ const harness = sessionHarness(session);
995
+ const route = routeSlashInput(line, slashRouteContextFor(session, harness, (path) => existsSync(expandHomePath(path))));
996
+ if (route.kind === "prompt") {
997
+ const images = await embeddedImagePaths(route.prompt, workspace);
998
+ if (images.length) {
999
+ for (const image of images) await queueAttachment(session, image).catch(quiet("tui/slash/dispatch"));
1000
+ await writeState(state);
1001
+ }
1002
+ if (host.pickProviderBeforeSending && !session.nativeHarness && !isClikCodeAgent(session)) {
1003
+ const chosen = await interactiveEnginePicker(host.config, rl, id) ?? id;
1004
+ return { id: chosen, ...await hasHarness(chosen) ? { prompt: route.prompt, echo: true } : { notice: "Choose a provider to send this." } };
1005
+ }
1006
+ return { prompt: route.prompt, echo: true };
1007
+ }
1008
+ if (isClikCodeAgent(session) && (route.kind === "unknown" ? route.head : route.kind === "manager" ? route.name : void 0) === "mcp") {
1009
+ return agentMcpCommand(host, parseSlashInput(line)?.words ?? []);
1010
+ }
1011
+ if (route.kind === "native" || route.kind === "custom" || route.kind === "unknown") {
1012
+ return slashRouteTurn(route, session, harness) ?? {};
1013
+ }
1014
+ if (route.kind === "harness") {
1015
+ await moveToProvider(id, route.command);
1016
+ return route.args ? { prompt: route.args, echo: true } : {};
1017
+ }
1018
+ if (route.kind === "manager") {
1019
+ const manager = harness ? localHarnessCapabilityManifest(harness).managers?.[route.name] : void 0;
1020
+ if (!harness || !manager) throw new Error("Choose a provider first.");
1021
+ if (manager.listArgv) {
1022
+ const listing = await host.withBusy(`loading ${manager.label}\u2026`, () => nativeManagerListing(state, session, route.name));
1023
+ host.panel(route.name, listing.label, listing.text, `${listing.label}
1024
+
1025
+ ${listing.text}`);
1026
+ } else if (manager.manageArgv && host.runManager) {
1027
+ await host.runManager(harness, manager.label, manager.manageArgv, turnEnvironment(harness, sessionAccount(state, session)));
1028
+ } else throw new Error(`${harness.displayName} requires an interactive terminal for ${manager.label}.`);
1029
+ return {};
1030
+ }
1031
+ const intercepted = await host.intercept?.(route, session, harness);
1032
+ if (intercepted) return intercepted;
1033
+ const availability = route.entry.availability(session, harness, route.args, slashRouteContextFor(session, harness).nativeCommands);
1034
+ if (!availability.available && availability.needs === "provider" && !options.fromQueuedCommand) {
1035
+ const commandLine = `/${route.entry.name}${route.args ? ` ${route.args}` : ""}`;
1036
+ const implied = impliedHarnessCommand(route, state.accounts, localHarnessForProvider);
1037
+ if (implied) {
1038
+ await aiHarnessSelect(implied, id);
1039
+ await enqueueCommandLine(id, commandLine);
1040
+ return {};
1041
+ }
1042
+ if (!host.canPick) throw new Error(availability.reason ?? `/${route.entry.name} is not available here.`);
1043
+ const chosen = await interactiveEnginePicker(host.config, rl, id) ?? id;
1044
+ if (await hasHarness(chosen)) await enqueueCommandLine(chosen, commandLine);
1045
+ return { id: chosen };
1046
+ }
1047
+ if (!availability.available) throw new Error(availability.reason ?? `/${route.entry.name} is not available here.`);
1048
+ const text = `/${route.entry.name}${route.args ? ` ${route.args}` : ""}`;
1049
+ const { args } = route;
1050
+ const progressLine = (panel) => (line2) => {
1051
+ if (host.line) host.line(line2);
1052
+ else if (rl.activity) rl.activity(line2);
1053
+ else emitHarnessOutput({ panel, text: line2 });
1054
+ };
1055
+ const handlers = {
1056
+ exit: async () => {
1057
+ await aiSessionLeave(id);
1058
+ return { exit: true };
1059
+ },
1060
+ restart: async () => {
1061
+ const leaving = replaceWindowBuild();
1062
+ if (!leaving) return { notice: "This window already runs the newest ClikCode." };
1063
+ await leaving;
1064
+ return { exit: true };
1065
+ },
1066
+ new: async () => ({ id: await newConversation(id), ...args ? { prompt: args, echo: true } : {} }),
1067
+ redraw: () => host.redraw(id),
1068
+ provider: async () => ({ id: await interactiveEnginePicker(host.config, rl, id) ?? id }),
1069
+ // This conversation, moved to the Gateway in place -- as choosing it in
1070
+ // /provider does, history and all. (Headless, only a fresh one can be.)
1071
+ gateway: async () => ({ id: await selectProviderConversation(host.config, rl, id, "__gateway__") }),
1072
+ accounts: async () => {
1073
+ const [action, name] = args.split(/\s+/);
1074
+ const target = (action === "login" || action === "add") && name ? localHarnessForCommand(name.toLowerCase()) : void 0;
1075
+ if (target) {
1076
+ const added = await addAccountForHarness(rl, target);
1077
+ if (added && target.provider === session.provider) await useAddedAccount(id, target, added);
1078
+ return {};
1079
+ }
1080
+ return args ? viaHeadless(text) : { id: await interactiveAccountPicker(rl, id) ?? id };
1081
+ },
1082
+ model: async () => {
1083
+ if (!args) return interactiveModelPicker(rl, id);
1084
+ return viaHeadless(text);
1085
+ },
1086
+ hostedModels: async () => {
1087
+ if (args && args.toLowerCase() !== "ai") throw new Error("Usage: /hosted ai");
1088
+ return interactiveHostedPicker(rl, id);
1089
+ },
1090
+ effort: async () => args ? viaHeadless(text) : interactiveEffortPicker(rl, id),
1091
+ permissions: async () => args ? viaHeadless(text) : interactivePermissionPicker(rl, id),
1092
+ sandbox: async () => viaHeadless(text),
1093
+ computer: async () => viaHeadless(text),
1094
+ send: async () => {
1095
+ if (args) return viaHeadless(text);
1096
+ const current = sendModeOf(state.globalSettings);
1097
+ const chosen = await chooseOption(rl, "Messages typed mid-turn", SEND_MODES.map((mode) => ({
1098
+ label: mode[0].toUpperCase() + mode.slice(1),
1099
+ detail: `${mode === current ? "\xB7 current " : ""}\xB7 ${SEND_MODE_DETAIL[mode]}`,
1100
+ value: mode
1101
+ })), void 0, { startAt: current });
1102
+ if (!chosen) return {};
1103
+ await viaHeadless(`/send ${chosen}`);
1104
+ return {};
1105
+ },
1106
+ // Said in the TUI too, where the `copied` panel is a confirmation it
1107
+ // drops: over SSH (OSC 52) nothing else shows it happened.
1108
+ copy: async () => {
1109
+ await copyToClipboard(lastAnswer(session));
1110
+ return {};
1111
+ },
1112
+ options: async () => interactiveHarnessOptionPicker(rl, id),
1113
+ capabilities: async () => {
1114
+ const [title = "Capabilities", ...rest] = capabilitiesText(session).split("\n");
1115
+ host.panel("capabilities", title, rest.join("\n"), [title, ...rest].join("\n"));
1116
+ },
1117
+ settings: async () => {
1118
+ if (args.trim().toLowerCase() === "tools") {
1119
+ if (!harness) throw new Error("Choose a provider first: tools and MCP servers belong to a harness.");
1120
+ await interactiveToolsPicker(rl, id, harness);
1121
+ return {};
1122
+ }
1123
+ return args ? viaHeadless(text) : { id: await interactiveSettingsPicker(host.config, rl, id) ?? id };
1124
+ },
1125
+ sessions: async () => args ? viaHeadless(text) : host.openConversationPicker(id),
1126
+ // Resume reopens the chosen conversation at its source: its account,
1127
+ // harness and native session. `/resume <name>` goes straight there when
1128
+ // the name picks out one conversation.
1129
+ resume: async () => {
1130
+ const named = args ? chatNamed(state.sessions, args, id) : void 0;
1131
+ return named ? { id: named } : host.openConversationPicker(id);
1132
+ },
1133
+ search: async () => {
1134
+ const query = args.trim();
1135
+ if (!query) throw new Error("usage: /search <words>");
1136
+ if (host.browseSearch) return host.browseSearch(query);
1137
+ const result = await host.withBusy("searching conversations\u2026", () => searchConversations(query));
1138
+ if (!result?.hits.length) return { notice: `No conversation mentions "${query}"` };
1139
+ const listed = searchResultsText(result);
1140
+ const [title = "Search", ...rest] = listed.split("\n");
1141
+ host.panel("search", title, rest.join("\n"), listed);
1142
+ },
1143
+ rename: async () => {
1144
+ const name = args || (await host.ask("Conversation name"))?.trim();
1145
+ if (name) await aiSessionCommand(id, `/rename ${name}`);
1146
+ },
1147
+ // `/fork` with nothing after it, where a picker can be shown: which of
1148
+ // the user's messages to fork after, newest first.
1149
+ fork: async () => {
1150
+ const options2 = args || !host.canPick ? [] : forkPointOptions(sessionTranscriptMessages(session));
1151
+ const at = options2.length > 1 ? await chooseOption(rl, "Fork after which message?", options2) : forkPoint(route.words[0]);
1152
+ if (options2.length > 1 && at === void 0) return {};
1153
+ return viaHeadless(options2.length > 1 ? `/fork @${at}` : text);
1154
+ },
1155
+ // `/changes <path>`: the turns, in any conversation, that edited it --
1156
+ // newest first; the chosen one opens at its prompt. `/changes [N]` and a
1157
+ // client that cannot pick get the headless panel.
1158
+ changes: async () => {
1159
+ if (!isChangesPath(args) || !host.canPick) return viaHeadless(text);
1160
+ const file = changesPath(args, workspace);
1161
+ const rows = await host.withBusy("looking through conversations\u2026", () => fileTurnRows(state, file));
1162
+ if (!rows.length) return { notice: noFileTurns(file) };
1163
+ const at = await chooseOption(rl, `Turns that edited ${compactPath(file)}`, rows.map((row, index) => ({ label: row.label, detail: row.detail, value: index })));
1164
+ if (at === void 0) return {};
1165
+ return host.walkTurns ? host.walkTurns(rows, at) : { id: rows[at].sessionId };
1166
+ },
1167
+ // `/redo`: which prompt to go back to (newest first, arrows and Enter),
1168
+ // then whether its edits and later ones are put back; the prompt lands in
1169
+ // the message box to send again, as it was or edited.
1170
+ redo: async () => {
1171
+ const messages = sessionTranscriptMessages(session);
1172
+ let at = forkPoint(route.words[0]);
1173
+ if (at === void 0) {
1174
+ if (!host.canPick) throw new Error("usage: /redo @N [keep]");
1175
+ const options2 = forkPointOptions(messages);
1176
+ if (!options2.length) return { notice: "No prompts to redo yet" };
1177
+ at = await chooseOption(rl, "Redo from which prompt?", options2);
1178
+ if (at === void 0) return {};
1179
+ }
1180
+ let keep = route.words.includes("keep");
1181
+ if (!keep && !route.words.includes("restore") && host.canPick) {
1182
+ const files = await chooseOption(rl, "Its edits and later ones", [
1183
+ { label: "Put files back as they were", value: false },
1184
+ { label: "Keep files as they are", value: true }
1185
+ ]);
1186
+ if (files === void 0) return {};
1187
+ keep = files;
1188
+ }
1189
+ const outcome = await viaHeadless(`/redo @${at}${keep ? " keep" : ""}`);
1190
+ const users = userMessageIndexes(messages);
1191
+ const prompt = messages[users[at - 1] ?? -1]?.content;
1192
+ return prompt === void 0 ? outcome : { ...outcome, draft: prompt };
1193
+ },
1194
+ // No "[y/N]": archiving is undone by resuming it. A confirmation earns
1195
+ // its keypress only for what cannot be taken back -- /delete keeps its own.
1196
+ archive: async () => {
1197
+ await aiSessionCommand(id, "/archive");
1198
+ return { exit: true };
1199
+ },
1200
+ delete: async () => {
1201
+ const confirmed = await chooseOption(rl, "Delete this conversation?", [
1202
+ { label: "Cancel", value: false },
1203
+ { label: "Delete this conversation", value: true }
1204
+ ]);
1205
+ if (!confirmed) return {};
1206
+ await aiSessionCommand(id, "/delete confirm");
1207
+ return { exit: true };
1208
+ },
1209
+ mention: async () => {
1210
+ const path = args || (await host.ask("File to attach"))?.trim();
1211
+ return path ? viaHeadless(`/mention ${path}`) : {};
1212
+ },
1213
+ review: async () => ({ prompt: isClikCodeAgent(session) ? reviewPrompt(args) : `/review${args ? ` ${args}` : ""}`, echo: false }),
1214
+ init: async () => ({ prompt: isClikCodeAgent(session) ? initPrompt(session) : "/init", echo: false }),
1215
+ compact: async () => {
1216
+ const said = await compactConversation(id, session, args, (targetId, promptText) => host.runTurn(targetId, promptText));
1217
+ return said ? { notice: said } : {};
1218
+ },
1219
+ export: async () => {
1220
+ let cancelled = false;
1221
+ const path = await exportTranscript(session, args, async (existing) => {
1222
+ const answer = await host.ask(`${compactPath(existing)} exists. Overwrite? [y/N]`);
1223
+ cancelled = answer === void 0;
1224
+ return ["y", "yes"].includes(answer?.trim().toLowerCase() ?? "");
1225
+ }).catch((error) => {
1226
+ if (cancelled) return void 0;
1227
+ throw error;
1228
+ });
1229
+ if (path === void 0) return {};
1230
+ host.exported?.(path);
1231
+ return { notice: `Transcript written to ${compactPath(path)}` };
1232
+ },
1233
+ memory: async () => {
1234
+ if (route.words[0]?.toLowerCase() !== "edit") return viaHeadless(text);
1235
+ const memory = await readMemoryFile(session);
1236
+ await host.editFile(memory.path, session.workspace ?? process.cwd());
1237
+ return {};
1238
+ },
1239
+ // The chat's machine, like its provider: choosing another moves the chat there.
1240
+ machine: async () => {
1241
+ if (!host.moveToMachine) throw new Error("Choose the machine with the machine chip under the message box: the chat moves there.");
1242
+ return host.moveToMachine(id);
1243
+ },
1244
+ // This machine's ClikCode -- the machine that owns this chat, which is
1245
+ // where this runs (remote/self-update.ts). Busy work, not a turn.
1246
+ update: async () => {
1247
+ const commit = parseCommitArgument(args);
1248
+ const result = await host.withBusy(`updating ClikCode on ${localMachineName()}`, () => updateThisMachine({ ...commit ? { commit } : {}, line: progressLine("update") }));
1249
+ return { notice: result.text };
1250
+ },
1251
+ doctor: async () => {
1252
+ const report = await host.withBusy("checking harnesses\u2026", () => doctorSummary(state));
1253
+ host.panel("doctor", "ClikCode doctor", report, report);
1254
+ },
1255
+ login: async () => {
1256
+ if (!harness) throw new Error("Choose a provider before signing in.");
1257
+ const current = sessionAccount(state, session);
1258
+ if (current?.authKind === "vendor-cli" && (current.status !== "ready" || current.verification)) {
1259
+ await manageAccountAction(rl, current.id, "reauthenticate");
1260
+ return {};
1261
+ }
1262
+ const added = await addAccountForHarness(rl, harness);
1263
+ if (added) await useAddedAccount(id, harness, added);
1264
+ return {};
1265
+ },
1266
+ logout: async () => {
1267
+ if (!session.accountId) throw new Error("This conversation has no account to sign out.");
1268
+ await host.withBusy("signing out\u2026", () => manageAccountAction(rl, session.accountId, "disconnect"));
1269
+ return {};
1270
+ }
1271
+ };
1272
+ const handler = handlers[route.entry.handlerKey];
1273
+ return (handler ? await handler() : await viaHeadless(text)) ?? {};
1274
+ }
1275
+
1276
+ // src/tui/pickers/resume-in.ts
1277
+ import { join } from "node:path";
1278
+ function resumeInCandidates(harnesses, accounts, current, rank) {
1279
+ return harnesses.filter((harness) => harness.command !== current).map((harness) => ({ harness, accounts: accounts.filter((account) => account.provider === harness.provider && accountHasUsage(account)) })).filter((candidate) => candidate.accounts.length > 0).sort((left, right) => rank(left.harness) - rank(right.harness) || left.harness.displayName.localeCompare(right.harness.displayName));
1280
+ }
1281
+ var WAIT_FOR_RESET = "\0wait";
1282
+ function offerResumeIn(rl) {
1283
+ return (id, prompt, sent) => interactiveResumeInPicker(rl, id, prompt, sent);
1284
+ }
1285
+ async function interactiveResumeInPicker(rl, id, prompt, sent = prompt, now = Date.now()) {
1286
+ const state = await readState({ transcripts: [] });
1287
+ const session = state.sessions.find((item) => item.id === id);
1288
+ if (!session) return void 0;
1289
+ if (sessionProviderHasUsage(state.accounts, session.provider)) return void 0;
1290
+ const candidates = resumeInCandidates(allLocalHarnesses().filter(harnessCanRunTurns), state.accounts, session.nativeHarness, harnessTierRank);
1291
+ const spent = state.accounts.filter((account) => account.provider === session.provider);
1292
+ const reset = nextQuotaReset(spent, now);
1293
+ if (!candidates.length && !reset) return void 0;
1294
+ const title = candidates.length ? `All accounts exhausted${reset ? ` \xB7 back ${quotaResetPhrase(reset, now)}` : ""} \u2014 resume in` : `All accounts exhausted \xB7 back ${quotaResetPhrase(reset, now)}`;
1295
+ for (; ; ) {
1296
+ const command = await chooseOption(rl, title, [
1297
+ ...candidates.map(({ harness, accounts }) => ({
1298
+ label: harness.displayName,
1299
+ detail: `\xB7 ${accounts.slice(0, 2).map((account2) => account2.label).join(", ")}${accounts.length > 2 ? ` +${accounts.length - 2}` : ""}`,
1300
+ value: harness.command
1301
+ })),
1302
+ ...reset ? [{ label: `Wait for reset (${quotaResetPhrase(reset, now)})`, detail: "\xB7 sends it again here then", value: WAIT_FOR_RESET }] : []
1303
+ ]);
1304
+ if (command === WAIT_FOR_RESET && reset) return { waiting: await waitForReset(id, reset, prompt, sent, now) };
1305
+ const chosen = candidates.find((candidate) => candidate.harness.command === command);
1306
+ if (!chosen) return void 0;
1307
+ const accountId = preferredAccountId(
1308
+ state,
1309
+ chosen.harness.provider,
1310
+ null,
1311
+ (candidate) => chosen.accounts.some((account2) => account2.id === candidate.id)
1312
+ );
1313
+ const account = chosen.accounts.find((candidate) => candidate.id === accountId);
1314
+ const catalog = await nativeModelCatalogForPicker(chosen.harness, account);
1315
+ const lastUsedModel = [...state.sessions].filter((item) => item.nativeHarness === chosen.harness.command && item.model).sort((left, right) => Date.parse(right.updatedAt ?? "") - Date.parse(left.updatedAt ?? ""))[0]?.model;
1316
+ const model = lastUsedModel ?? state.providerSettings[chosen.harness.provider]?.model ?? catalog.configured ?? null;
1317
+ return resumeIn(id, chosen.harness, account.id, model, prompt, sent, session.nativeHarness);
1318
+ }
1319
+ }
1320
+ async function resumeIn(id, harness, accountId, model, prompt, sent, from) {
1321
+ return withFileLock(join(sessionsDirectory(), `${safeRecordFileName(id)}.resume-in.lock`), async () => {
1322
+ const state = await readState({ transcripts: [id] });
1323
+ const session = state.sessions.find((item) => item.id === id);
1324
+ if (session?.nativeHarness !== from) return { id };
1325
+ const nextPrompt = resumePromptForPendingTurn(session?.pendingTurn, prompt, sent);
1326
+ await moveToProvider(id, harness.command, { accountId, model });
1327
+ return { id, prompt: nextPrompt };
1328
+ });
1329
+ }
1330
+
1331
+ // src/tui/slash/search-browse.ts
1332
+ async function browseSearch(screen, query, withBusy) {
1333
+ const result = await withBusy("searching conversations\u2026", () => searchConversations(query));
1334
+ if (!result?.hits.length) return { notice: `No conversation mentions "${query}"` };
1335
+ const browser = new MentionBrowser(result.hits);
1336
+ const sessions = /* @__PURE__ */ new Map();
1337
+ const load = async (id) => {
1338
+ if (!sessions.has(id)) sessions.set(id, (await readState({ transcripts: [id] })).sessions.find((item) => item.id === id));
1339
+ return sessions.get(id);
1340
+ };
1341
+ let shown;
1342
+ for (; ; ) {
1343
+ const stop = browser.current();
1344
+ const session = await load(stop.mention?.sessionId ?? stop.hit.sessionId);
1345
+ if (session) {
1346
+ shown = session.id;
1347
+ screen.showMention(session, {
1348
+ messageIndex: stop.mention?.messageIndex ?? Math.max(0, (session.messages?.length ?? 1) - 1),
1349
+ occurrence: stop.mention ? await mentionOccurrence(stop.mention, result.query) : 0,
1350
+ words: result.query.words,
1351
+ status: browser.status()
1352
+ });
1353
+ }
1354
+ const key = await screen.mentionKey();
1355
+ if (key === "done") break;
1356
+ if (key === "next") browser.next();
1357
+ else if (key === "previous") browser.previous();
1358
+ else browser.nextChat();
1359
+ }
1360
+ screen.endMention();
1361
+ return shown ? { id: shown } : {};
1362
+ }
1363
+ async function walkTurns(screen, turns, start) {
1364
+ let at = Math.max(0, Math.min(turns.length - 1, start));
1365
+ let shown;
1366
+ for (; ; ) {
1367
+ const turn = turns[at];
1368
+ const session = (await readState({ transcripts: [turn.sessionId] })).sessions.find((item) => item.id === turn.sessionId);
1369
+ if (session) {
1370
+ shown = session.id;
1371
+ const messages = session.messages ?? [];
1372
+ const records = await readTurnChanges(stateDirectory(), session.id);
1373
+ screen.showMention(session, {
1374
+ messageIndex: turnMessageIndex(messages, records, turn.turnsAgo) ?? Math.max(0, messages.length - 1),
1375
+ occurrence: 0,
1376
+ words: [],
1377
+ status: `turn ${at + 1} of ${turns.length} \xB7 \u2191\u2193 next/previous \xB7 esc done`
1378
+ });
1379
+ }
1380
+ const key = await screen.mentionKey();
1381
+ if (key === "done") break;
1382
+ at = key === "previous" ? Math.max(0, at - 1) : Math.min(turns.length - 1, at + 1);
1383
+ }
1384
+ screen.endMention();
1385
+ return shown ? { id: shown } : {};
1386
+ }
1387
+
1388
+ export {
1389
+ planModeOnChat,
1390
+ setAgentPlanMode,
1391
+ harnessOf,
1392
+ providerList,
1393
+ modelList,
1394
+ conversationList,
1395
+ accountList,
1396
+ chatSettings,
1397
+ gatewayStatus,
1398
+ gatewayCheckoutUrl,
1399
+ gatewayCreditLabel,
1400
+ gatewayConversationUsageLabel,
1401
+ useAddedAccount,
1402
+ addAccountForHarness,
1403
+ manageAccountAction,
1404
+ dispatchLine,
1405
+ shouldWarmVendorChat,
1406
+ offerResumeIn,
1407
+ browseSearch,
1408
+ walkTurns
1409
+ };