clikcode 1.0.4 → 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 +494 -112923
  319. package/dist/computer-tools.js +36642 -21259
  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,232 @@
1
+ import { createRequire as __clikcodeCreateRequire } from 'node:module';
2
+ const require = __clikcodeCreateRequire(import.meta.url);
3
+
4
+ // src/tui/render/hyperlinks.ts
5
+ var HYPERLINK_CLOSE = "\x1B]8;;\x1B\\";
6
+ var hyperlinkOpen = (href) => `\x1B]8;;${href}\x1B\\`;
7
+ function hyperlinksSupported(environment = process.env, isTty = Boolean(process.stdout.isTTY)) {
8
+ const flag = (value) => value !== void 0 && value !== "" && value !== "0" && value.toLowerCase() !== "false";
9
+ if (!isTty || (environment.TERM ?? "").toLowerCase() === "dumb") return false;
10
+ if (flag(environment.CLIKCODE_HYPERLINKS) || flag(environment.FORCE_HYPERLINK)) return true;
11
+ if (environment.TMUX || environment.STY || /^(?:screen|tmux)/.test(environment.TERM ?? "")) return false;
12
+ const program = (environment.TERM_PROGRAM ?? "").toLowerCase();
13
+ if (["iterm.app", "wezterm", "vscode", "ghostty", "hyper", "kitty", "rio", "warpterminal", "termius"].includes(program)) return true;
14
+ if (environment.KITTY_WINDOW_ID || environment.WT_SESSION || environment.KONSOLE_VERSION || environment.DOMTERM) return true;
15
+ if (Number(environment.VTE_VERSION ?? 0) >= 5e3) return true;
16
+ return /^(?:xterm-kitty|xterm-ghostty|foot|alacritty|wezterm|contour)/.test(environment.TERM ?? "");
17
+ }
18
+ var hyperlinksEnabled;
19
+ var linksOn = () => hyperlinksEnabled ?? (hyperlinksEnabled = hyperlinksSupported());
20
+ var UNDERLINE_ON = /\u001b\[(?:[0-9;]*;)?4[;m]/;
21
+ function closeOpenHyperlink(row) {
22
+ const last = row.lastIndexOf("\x1B]8;");
23
+ const closedLink = last === -1 || row.startsWith(HYPERLINK_CLOSE, last) ? row : `${row}${HYPERLINK_CLOSE}`;
24
+ if (!UNDERLINE_ON.test(closedLink)) return closedLink;
25
+ let underline = false;
26
+ for (const match of closedLink.matchAll(/\u001b\[([0-9;]*)m/g)) {
27
+ const params = match[1].split(";").filter(Boolean).map(Number);
28
+ if (params.length === 0 || params.includes(0)) {
29
+ underline = false;
30
+ continue;
31
+ }
32
+ if (params.includes(4)) underline = true;
33
+ if (params.includes(24)) underline = false;
34
+ }
35
+ return underline ? `${closedLink}\x1B[24m` : closedLink;
36
+ }
37
+
38
+ // src/tui/render/width.ts
39
+ var OSC8_SEQUENCE = /^\u001b\]8;[^\u0007\u001b\n]*\u001b\\$/;
40
+ var ZERO_WIDTH_SEQUENCES = /\u001b\[[0-9;]*m|\u001b\]8;[^\u0007\u001b\n]*\u001b\\/g;
41
+ var TAB_WIDTH = 4;
42
+ var ANSI_SEQUENCES = /\u001b\[[0-?]*[ -/]*[@-~]|\u001b\][^\u0007\u001b]*(?:\u0007|\u001b\\)|\u001b[@-Z\\-_]/g;
43
+ function stripAnsi(text) {
44
+ return text.includes("\x1B") ? text.replace(ANSI_SEQUENCES, "") : text;
45
+ }
46
+ function visibleSlice(value, width) {
47
+ if (terminalCellWidth(value) <= width) return value;
48
+ const available = Math.max(0, width - 1);
49
+ let rendered = "";
50
+ let renderedWidth = 0;
51
+ let sawAnsi = false;
52
+ const tokens = displayTokens(value);
53
+ let linkOpen = false;
54
+ for (const token of tokens) {
55
+ if (token[0] === "\x1B") {
56
+ rendered += token;
57
+ if (OSC8_SEQUENCE.test(token)) linkOpen = token !== HYPERLINK_CLOSE;
58
+ else sawAnsi = true;
59
+ continue;
60
+ }
61
+ const tokenWidth = terminalCellWidth(token);
62
+ if (renderedWidth + tokenWidth > available) break;
63
+ rendered += token;
64
+ renderedWidth += tokenWidth;
65
+ }
66
+ return `${rendered}${linkOpen ? HYPERLINK_CLOSE : ""}${sawAnsi ? "\x1B[0m" : ""}\u2026`;
67
+ }
68
+ function visibleTail(value, width) {
69
+ if (terminalCellWidth(value) <= width) return value;
70
+ const tokens = displayTokens(value);
71
+ let kept = "";
72
+ let keptWidth = 0;
73
+ for (let index = tokens.length - 1; index >= 0; index -= 1) {
74
+ const tokenWidth = terminalCellWidth(tokens[index]);
75
+ if (keptWidth + tokenWidth > Math.max(0, width - 1)) break;
76
+ kept = tokens[index] + kept;
77
+ keptWidth += tokenWidth;
78
+ }
79
+ return `\u2026${kept}`;
80
+ }
81
+ function visiblePathTail(path, width) {
82
+ if (terminalCellWidth(path) <= width) return path;
83
+ const parts = path.split(/(?=[\\/])/);
84
+ let kept = "";
85
+ for (let index = parts.length - 1; index >= 0; index -= 1) {
86
+ if (terminalCellWidth(`\u2026${parts[index]}${kept}`) > width) break;
87
+ kept = `${parts[index]}${kept}`;
88
+ }
89
+ return kept ? `\u2026${kept}` : visibleSlice(`\u2026${parts[parts.length - 1]}`, width);
90
+ }
91
+ var graphemeSegmenter;
92
+ var graphemes = () => graphemeSegmenter ??= typeof Intl.Segmenter === "function" ? new Intl.Segmenter(void 0, { granularity: "grapheme" }) : fallbackSegmenter;
93
+ var EXTENDS = /^[\p{M}\u{FE00}-\u{FE0F}\u{E0100}-\u{E01EF}\u{1F3FB}-\u{1F3FF}\u{E0020}-\u{E007F}\u200D]$/u;
94
+ var REGIONAL = /^[\u{1F1E6}-\u{1F1FF}]$/u;
95
+ var fallbackSegmenter = {
96
+ segment(text) {
97
+ const out = [];
98
+ let index = 0;
99
+ let joinNext = false;
100
+ for (const char of text) {
101
+ const last = out[out.length - 1];
102
+ const flag = last && REGIONAL.test(char) && [...last.segment].length === 1 && REGIONAL.test(last.segment);
103
+ if (last && (joinNext || EXTENDS.test(char) || flag)) {
104
+ last.segment += char;
105
+ } else {
106
+ out.push({ segment: char, index });
107
+ }
108
+ joinNext = char === "\u200D";
109
+ index += char.length;
110
+ }
111
+ return out;
112
+ }
113
+ };
114
+ var CLUSTER_WINDOW = 32;
115
+ function isWideCodePoint(code) {
116
+ if (code < 4352) return false;
117
+ return code <= 4447 || code === 9001 || code === 9002 || code >= 11904 && code <= 12350 || code >= 12353 && code <= 19903 || code >= 19968 && code <= 42191 || code >= 43360 && code <= 43391 || code >= 44032 && code <= 55203 || code >= 63744 && code <= 64255 || code >= 65040 && code <= 65049 || code >= 65072 && code <= 65135 || code >= 65281 && code <= 65376 || code >= 65504 && code <= 65510 || code >= 127462 && code <= 127487 || code >= 94176 && code <= 94180 || code >= 94208 && code <= 101119 || code >= 110592 && code <= 111359 || code >= 127488 && code <= 127490 || code >= 127504 && code <= 127547 || code >= 127552 && code <= 127560 || code >= 127568 && code <= 127569 || code >= 127584 && code <= 127589 || code >= 127744 && code <= 129791 || code >= 131072 && code <= 262141;
118
+ }
119
+ var FORMAT = new RegExp("\\p{Cf}", "u");
120
+ function drawsNothing(code, character) {
121
+ if (code < 160) return false;
122
+ if (code === 8232 || code === 8233) return true;
123
+ return FORMAT.test(character) && !(code >= 1536 && code <= 1541 || code === 1757 || code === 1807 || code === 2192 || code === 2193 || code === 2274);
124
+ }
125
+ function displayTokens(value) {
126
+ const tokens = [];
127
+ const pushText = (text) => {
128
+ for (const { segment } of graphemes().segment(text)) tokens.push(segment);
129
+ };
130
+ let consumed = 0;
131
+ for (const match of value.matchAll(ZERO_WIDTH_SEQUENCES)) {
132
+ const start = match.index;
133
+ if (start > consumed) pushText(value.slice(consumed, start));
134
+ tokens.push(match[0]);
135
+ consumed = start + match[0].length;
136
+ }
137
+ if (consumed < value.length) pushText(value.slice(consumed));
138
+ return tokens;
139
+ }
140
+ var CONTROLS = /^[\u0000-\u001f\u007f-\u009f]+$/;
141
+ var MARK = new RegExp("\\p{Mark}", "u");
142
+ var EMOJI_PRESENTATION = new RegExp("\\p{Emoji_Presentation}", "u");
143
+ var EMOJI = new RegExp("\\p{Emoji}", "u");
144
+ var KEYCAP_BASE = /^[0-9#*]$/;
145
+ var GRAPHEME_EXTEND = new RegExp("\\p{Grapheme_Extend}", "u");
146
+ var ONE_CELL = new Uint8Array(65536);
147
+ function oneCell(code) {
148
+ let known = ONE_CELL[code];
149
+ if (!known) {
150
+ const character = String.fromCharCode(code);
151
+ const joins = code >= 55296 && code <= 57343 || code >= 4352 && code <= 4607 || code >= 43360 && code <= 43391 || code >= 55216 && code <= 55295 || code >= 1536 && code <= 1541 || code === 1757 || code === 1807 || code === 2192 || code === 2193 || code === 2274 || code === 3406 || code === 3635 || code === 3763 || code === 8205;
152
+ known = joins || isWideCodePoint(code) || MARK.test(character) || GRAPHEME_EXTEND.test(character) || drawsNothing(code, character) || EMOJI_PRESENTATION.test(character) ? 2 : 1;
153
+ ONE_CELL[code] = known;
154
+ }
155
+ return known === 1;
156
+ }
157
+ function simpleWidth(value) {
158
+ let width = 0;
159
+ for (let index = 0; index < value.length; index += 1) {
160
+ const code = value.charCodeAt(index);
161
+ if (code >= 32 && code < 127) width += 1;
162
+ else if (code === 27) {
163
+ const next = value.charCodeAt(index + 1);
164
+ let end = index + 2;
165
+ if (next === 91) {
166
+ while (end < value.length && (value.charCodeAt(end) >= 48 && value.charCodeAt(end) <= 57 || value.charCodeAt(end) === 59)) end += 1;
167
+ if (value.charCodeAt(end) !== 109) return -1;
168
+ } else if (next === 93 && value.startsWith("8;", end)) {
169
+ while (end < value.length && !"\x07\x1B\n".includes(value[end])) end += 1;
170
+ if (value.charCodeAt(end) !== 27 || value.charCodeAt(end + 1) !== 92) return -1;
171
+ end += 1;
172
+ } else return -1;
173
+ index = end;
174
+ } else if (code === 9) width += TAB_WIDTH - width % TAB_WIDTH;
175
+ else if (code < 160) continue;
176
+ else if (oneCell(code)) width += 1;
177
+ else return -1;
178
+ }
179
+ return width;
180
+ }
181
+ function terminalCellWidth(value) {
182
+ const simple = simpleWidth(value);
183
+ if (simple >= 0) return simple;
184
+ const plain = value.includes("\x1B") ? value.replace(ZERO_WIDTH_SEQUENCES, "") : value;
185
+ let width = 0;
186
+ for (const { segment } of graphemes().segment(plain)) {
187
+ if (segment === " ") {
188
+ width += TAB_WIDTH - width % TAB_WIDTH;
189
+ continue;
190
+ }
191
+ if (CONTROLS.test(segment)) continue;
192
+ const code = segment.codePointAt(0) ?? 0;
193
+ if (segment.length === 1 && code < 127) {
194
+ width += 1;
195
+ continue;
196
+ }
197
+ const base = String.fromCodePoint(code);
198
+ if (MARK.test(base) || drawsNothing(code, base)) continue;
199
+ const wide = segment.includes("\uFE0E") ? isWideCodePoint(code) && code >= 126976 : isWideCodePoint(code) || EMOJI_PRESENTATION.test(base) || segment.includes("\uFE0F") && EMOJI.test(base) && !KEYCAP_BASE.test(base) || segment.includes("\u20E3");
200
+ width += wide ? 2 : 1;
201
+ }
202
+ return width;
203
+ }
204
+ function previousCharacterIndex(value, index) {
205
+ if (index <= 0) return 0;
206
+ const start = Math.max(0, index - CLUSTER_WINDOW);
207
+ let boundary = 0;
208
+ for (const { index: offset } of graphemes().segment(value.slice(start, index))) boundary = offset;
209
+ return start + boundary;
210
+ }
211
+ function nextCharacterIndex(value, index) {
212
+ if (index >= value.length) return value.length;
213
+ const [first] = graphemes().segment(value.slice(index, index + CLUSTER_WINDOW));
214
+ return index + (first ? first.segment.length : 1);
215
+ }
216
+
217
+ export {
218
+ HYPERLINK_CLOSE,
219
+ hyperlinkOpen,
220
+ linksOn,
221
+ closeOpenHyperlink,
222
+ OSC8_SEQUENCE,
223
+ TAB_WIDTH,
224
+ stripAnsi,
225
+ visibleSlice,
226
+ visibleTail,
227
+ visiblePathTail,
228
+ displayTokens,
229
+ terminalCellWidth,
230
+ previousCharacterIndex,
231
+ nextCharacterIndex
232
+ };
@@ -0,0 +1,179 @@
1
+ import { createRequire as __clikcodeCreateRequire } from 'node:module';
2
+ const require = __clikcodeCreateRequire(import.meta.url);
3
+ import {
4
+ lifecycle,
5
+ quiet
6
+ } from "./chunk-RDDWQBEM.js";
7
+ import "./chunk-MPAJ446F.js";
8
+ import "./chunk-CBANJFBO.js";
9
+ import "./chunk-PWXII6HF.js";
10
+
11
+ // src/harness/compat/macos-legacy.ts
12
+ import { accessSync, constants, existsSync, realpathSync } from "node:fs";
13
+ import { chmod, copyFile, mkdir, open, readdir, rename, rm, stat, writeFile } from "node:fs/promises";
14
+ import { arch, platform, release } from "node:os";
15
+ import { delimiter, dirname, join } from "node:path";
16
+ import { fileURLToPath } from "node:url";
17
+ var MH_MAGIC_64 = 4277009103;
18
+ var CPU_TYPE_X86_64 = 16777223;
19
+ var LC_SEGMENT_64 = 25;
20
+ var LC_CODE_SIGNATURE = 29;
21
+ var LC_VERSION_MIN_MACOSX = 36;
22
+ var LC_BUILD_VERSION = 50;
23
+ var PLATFORM_MACOS = 1;
24
+ var HEADER_SIZE = 32;
25
+ function readMachO(head) {
26
+ if (head.length < HEADER_SIZE || head.readUInt32LE(0) !== MH_MAGIC_64 || head.readUInt32LE(4) !== CPU_TYPE_X86_64) return void 0;
27
+ const ncmds = head.readUInt32LE(16), sizeofcmds = head.readUInt32LE(20);
28
+ if (HEADER_SIZE + sizeofcmds > head.length) return void 0;
29
+ const commands = [];
30
+ let offset = HEADER_SIZE, minMacos;
31
+ for (let index = 0; index < ncmds; index++) {
32
+ if (offset + 8 > HEADER_SIZE + sizeofcmds) return void 0;
33
+ const cmd = head.readUInt32LE(offset), size = head.readUInt32LE(offset + 4);
34
+ if (size < 8 || offset + size > HEADER_SIZE + sizeofcmds) return void 0;
35
+ commands.push({ cmd, size, offset });
36
+ if (cmd === LC_BUILD_VERSION && size >= 16 && head.readUInt32LE(offset + 8) === PLATFORM_MACOS) minMacos = versionText(head.readUInt32LE(offset + 12));
37
+ else if (cmd === LC_VERSION_MIN_MACOSX && size >= 12) minMacos = versionText(head.readUInt32LE(offset + 8));
38
+ offset += size;
39
+ }
40
+ return { commands, ncmds, sizeofcmds, ...minMacos ? { minMacos } : {} };
41
+ }
42
+ function versionText(packed) {
43
+ const major = packed >>> 16, minor = packed >>> 8 & 255, patch = packed & 255;
44
+ return patch ? `${major}.${minor}.${patch}` : `${major}.${minor}`;
45
+ }
46
+ function compareVersions(left, right) {
47
+ const a = left.split(".").map(Number), b = right.split(".").map(Number);
48
+ for (let index = 0; index < Math.max(a.length, b.length); index++) {
49
+ const difference = (a[index] ?? 0) - (b[index] ?? 0);
50
+ if (difference) return difference < 0 ? -1 : 1;
51
+ }
52
+ return 0;
53
+ }
54
+ function runningMacos(kernelRelease = release()) {
55
+ const major = Number(kernelRelease.split(".")[0]);
56
+ if (!Number.isInteger(major) || major < 9) return void 0;
57
+ return major >= 20 ? `${major - 9}.0` : `10.${major - 4}`;
58
+ }
59
+ async function stripCodeSignature(file) {
60
+ const handle = await open(file, "r+");
61
+ try {
62
+ const { size: fileSize } = await handle.stat();
63
+ const head = Buffer.alloc(Math.min(fileSize, 1 << 16));
64
+ await handle.read(head, 0, head.length, 0);
65
+ const layout = readMachO(head);
66
+ const signature = layout?.commands.find((command) => command.cmd === LC_CODE_SIGNATURE);
67
+ if (!layout || !signature || signature.size !== 16) return false;
68
+ const dataoff = head.readUInt32LE(signature.offset + 8), datasize = head.readUInt32LE(signature.offset + 12);
69
+ if (dataoff + datasize !== fileSize) return false;
70
+ const linkedit = layout.commands.find((command) => command.cmd === LC_SEGMENT_64 && head.toString("latin1", command.offset + 8, command.offset + 24).replace(/\0+$/, "") === "__LINKEDIT");
71
+ if (!linkedit) return false;
72
+ const editStart = Number(head.readBigUInt64LE(linkedit.offset + 40));
73
+ if (dataoff < editStart) return false;
74
+ head.writeBigUInt64LE(BigInt(dataoff - editStart), linkedit.offset + 48);
75
+ const end = HEADER_SIZE + layout.sizeofcmds;
76
+ head.copy(head, signature.offset, signature.offset + signature.size, end);
77
+ head.fill(0, end - signature.size, end);
78
+ head.writeUInt32LE(layout.ncmds - 1, 16);
79
+ head.writeUInt32LE(layout.sizeofcmds - signature.size, 20);
80
+ await handle.write(head, 0, end, 0);
81
+ await handle.truncate(dataoff);
82
+ return true;
83
+ } finally {
84
+ await handle.close();
85
+ }
86
+ }
87
+ var LIBRARY = "libclikcode-compat-x64.dylib";
88
+ function compatLibrary(from = fileURLToPath(import.meta.url)) {
89
+ const here = dirname(from);
90
+ return [join(here, LIBRARY), join(here, "..", "..", "..", "native", "macos-compat", LIBRARY)].find(existsSync);
91
+ }
92
+ function findOnPath(name, path = process.env.PATH ?? "") {
93
+ for (const directory of path.split(delimiter)) {
94
+ if (!directory) continue;
95
+ const candidate = join(directory, name);
96
+ try {
97
+ accessSync(candidate, constants.X_OK);
98
+ return realpathSync(candidate);
99
+ } catch {
100
+ }
101
+ }
102
+ return void 0;
103
+ }
104
+ function defaultDeps(stateDir) {
105
+ return { platform: platform(), arch: arch(), macos: runningMacos(), find: (name) => findOnPath(name), library: () => compatLibrary(), stateDir };
106
+ }
107
+ async function tooNew(binary, macos) {
108
+ const handle = await open(binary, "r").catch(quiet("harness/compat/macos-legacy"));
109
+ if (!handle) return void 0;
110
+ try {
111
+ const head = Buffer.alloc(1 << 16);
112
+ const { bytesRead } = await handle.read(head, 0, head.length, 0);
113
+ const layout = readMachO(head.subarray(0, bytesRead));
114
+ return layout?.minMacos && compareVersions(layout.minMacos, macos) > 0 ? layout : void 0;
115
+ } finally {
116
+ await handle.close();
117
+ }
118
+ }
119
+ var key = (stats) => `${stats.size}-${Math.floor(stats.mtimeMs)}`;
120
+ async function prepareMacosCompat(program = "claude", deps = defaultDeps(join(process.env.HOME ?? "", ".clikcode"))) {
121
+ try {
122
+ if (deps.platform !== "darwin" || deps.arch !== "x64" || !deps.macos) return void 0;
123
+ const original = deps.find(program);
124
+ if (!original) return void 0;
125
+ const layout = await tooNew(original, deps.macos);
126
+ const library = deps.library();
127
+ if (!layout?.minMacos || !library) return void 0;
128
+ const stats = await stat(original);
129
+ const root = join(deps.stateDir, "compat");
130
+ const copyDirectory = join(root, `${program}-${key(stats)}`);
131
+ const copy = join(copyDirectory, `${program}.bin`);
132
+ if (!existsSync(copy)) {
133
+ const temporary = `${copyDirectory}.${process.pid}.tmp`;
134
+ await rm(temporary, { recursive: true, force: true });
135
+ await mkdir(temporary, { recursive: true, mode: 448 });
136
+ await copyFile(original, join(temporary, `${program}.bin`), constants.COPYFILE_FICLONE);
137
+ await chmod(join(temporary, `${program}.bin`), 493);
138
+ if (!await stripCodeSignature(join(temporary, `${program}.bin`))) {
139
+ await rm(temporary, { recursive: true, force: true });
140
+ return void 0;
141
+ }
142
+ await rename(temporary, copyDirectory).catch(async () => {
143
+ await rm(temporary, { recursive: true, force: true });
144
+ });
145
+ for (const entry of await readdir(root).catch(() => [])) if (entry.startsWith(`${program}-`) && join(root, entry) !== copyDirectory) await rm(join(root, entry), { recursive: true, force: true }).catch(quiet("harness/compat/macos-legacy"));
146
+ }
147
+ const directory = join(root, "bin");
148
+ const launcher = join(directory, program);
149
+ await mkdir(directory, { recursive: true, mode: 448 });
150
+ const script = `#!/bin/sh
151
+ # ClikCode: ${program} on a Mac older than it was built for (see src/harness/compat/macos-legacy.ts).
152
+ DYLD_INSERT_LIBRARIES='${library.replace(/'/g, `'\\''`)}' DYLD_FORCE_FLAT_NAMESPACE=1 exec '${copy.replace(/'/g, `'\\''`)}' "$@"
153
+ `;
154
+ const temporaryLauncher = `${launcher}.${process.pid}.tmp`;
155
+ await writeFile(temporaryLauncher, script, { mode: 493 });
156
+ await rename(temporaryLauncher, launcher);
157
+ return { launcher, directory, original, minMacos: layout.minMacos, macos: deps.macos };
158
+ } catch (error) {
159
+ quiet("harness/compat/macos-legacy")(error);
160
+ return void 0;
161
+ }
162
+ }
163
+ async function activateMacosCompat(env = process.env, deps) {
164
+ if (!deps && (platform() !== "darwin" || arch() !== "x64")) return void 0;
165
+ const launch = await prepareMacosCompat("claude", deps);
166
+ if (!launch) return void 0;
167
+ env.PATH = `${launch.directory}${delimiter}${(env.PATH ?? "").split(delimiter).filter((directory) => directory !== launch.directory).join(delimiter)}`;
168
+ env.CLAUDE_CODE_EXECUTABLE = launch.launcher;
169
+ lifecycle("compat.macos", { program: "claude", builtFor: launch.minMacos, running: launch.macos });
170
+ return launch;
171
+ }
172
+ export {
173
+ activateMacosCompat,
174
+ compareVersions,
175
+ prepareMacosCompat,
176
+ readMachO,
177
+ runningMacos,
178
+ stripCodeSignature
179
+ };
@@ -0,0 +1,111 @@
1
+ import { createRequire as __clikcodeCreateRequire } from 'node:module';
2
+ const require = __clikcodeCreateRequire(import.meta.url);
3
+ import {
4
+ getApiKeyForUrl,
5
+ getApiUrl
6
+ } from "./chunk-TQDM7S5N.js";
7
+ import "./chunk-TULAXS77.js";
8
+ import {
9
+ harnessCommand
10
+ } from "./chunk-NWEYRBWK.js";
11
+ import {
12
+ sleep
13
+ } from "./chunk-YMCH3L2S.js";
14
+ import {
15
+ emitResult
16
+ } from "./chunk-JGIWATSG.js";
17
+ import "./chunk-5B6TVO4A.js";
18
+ import {
19
+ CLIKCODE_USER_AGENT
20
+ } from "./chunk-NAOX3JUB.js";
21
+ import {
22
+ quiet
23
+ } from "./chunk-RDDWQBEM.js";
24
+ import "./chunk-MPAJ446F.js";
25
+ import "./chunk-CBANJFBO.js";
26
+ import "./chunk-PWXII6HF.js";
27
+
28
+ // src/commands/ai/finetune.ts
29
+ import { readFile, stat } from "node:fs/promises";
30
+ import { basename } from "node:path";
31
+ var MAX_DATASET_BYTES = 50 * 1024 * 1024;
32
+ var POLL_MS = 15e3;
33
+ var FINISHED = /* @__PURE__ */ new Set(["COMPLETE", "ERROR", "CANCELLED"]);
34
+ function reasonOf(body, status) {
35
+ const error = body?.error;
36
+ if (typeof error === "string" && error) return error;
37
+ if (error && typeof error === "object" && typeof error.message === "string") return error.message;
38
+ return `HTTP ${status}`;
39
+ }
40
+ async function aiGatewayFineTune(config, datasetPath, options = {}, deps = {}) {
41
+ const fetchImpl = deps.fetchImpl ?? fetch;
42
+ const sleep2 = deps.sleep ?? sleep;
43
+ const progress = deps.progress ?? ((line) => {
44
+ process.stderr.write(`${line}
45
+ `);
46
+ });
47
+ const apiUrl = getApiUrl(config);
48
+ const apiKey = getApiKeyForUrl(config, apiUrl);
49
+ if (!apiKey) throw new Error(`Not signed in to ClikDeploy Gateway. Run \`${harnessCommand()} gateway login\`.`);
50
+ if (!options.base) throw new Error("Name the base model with --base, e.g. --base Qwen/Qwen2.5-0.5B-Instruct.");
51
+ const hardware = options.hardware ?? "gpu";
52
+ if (hardware !== "gpu" && hardware !== "cpu") throw new Error("--hardware must be gpu or cpu");
53
+ const epochs = options.epochs === void 0 ? void 0 : Number(options.epochs);
54
+ if (epochs !== void 0 && (!Number.isInteger(epochs) || epochs < 1 || epochs > 10)) throw new Error("--epochs must be a whole number from 1 to 10");
55
+ const info = await stat(datasetPath).catch(quiet("commands/ai/finetune"));
56
+ if (!info?.isFile()) throw new Error(`No dataset file at ${datasetPath}.`);
57
+ if (info.size > MAX_DATASET_BYTES) throw new Error("The dataset is over 50 MB: upload it to your ClikDeploy data pool and name it there.");
58
+ const auth = { authorization: `Bearer ${apiKey}`, accept: "application/json", "user-agent": CLIKCODE_USER_AGENT };
59
+ const call = async (path, init = {}) => {
60
+ const response = await fetchImpl(new URL(path, apiUrl), { ...init, headers: { ...auth, ...init.headers } });
61
+ const body = await response.json().catch(quiet("commands/ai/finetune"));
62
+ if (!response.ok || body?.success === false || body?.data === void 0) throw new Error(`ClikDeploy fine-tune: ${reasonOf(body, response.status)}`);
63
+ return body.data;
64
+ };
65
+ const json = (body) => ({ method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) });
66
+ const form = new FormData();
67
+ form.set("file", new Blob([await readFile(datasetPath)]), basename(datasetPath));
68
+ form.set("name", options.name ? `${options.name} (data)` : basename(datasetPath));
69
+ const dataset = await call("/api/datasets", { method: "POST", body: form });
70
+ const hyperparams = epochs === void 0 ? void 0 : { epochs };
71
+ const request = { baseModelId: options.base, datasetId: dataset.id, hardware, ...hyperparams ? { hyperparams } : {} };
72
+ const quote = await call("/api/training/quote", json(request));
73
+ const shown = {
74
+ dataset: { id: dataset.id, rows: dataset.rowCount, tokens: dataset.tokenCount, format: dataset.format },
75
+ quote: { hardware: quote.hardware, machine: quote.sku?.displayName, summary: quote.summary, mostItCanCostUsd: quote.costHigh, warnings: quote.warnings ?? [] }
76
+ };
77
+ if (!options.yes) {
78
+ emitResult({ ...shown, started: false, next: `Run it again with --yes to start at this price (the job stops at ${quote.costHigh > 0 ? `about $${(Number(quote.suggestedCeilingMicroUsd) / 1e6).toFixed(2)}` : "its ceiling"}).` });
79
+ return;
80
+ }
81
+ const job = await call("/api/training/jobs", json({
82
+ ...request,
83
+ name: options.name,
84
+ placement: "capacity",
85
+ acceptedQuoteMicroUsd: quote.costHighMicroUsd,
86
+ spendCeilingMicroUsd: quote.suggestedCeilingMicroUsd
87
+ }));
88
+ progress(`fine-tune ${job.id} started (${quote.summary})`);
89
+ if (options.wait === false) {
90
+ emitResult({ ...shown, started: true, job: { id: job.id, status: job.status } });
91
+ return;
92
+ }
93
+ let last = "";
94
+ for (; ; ) {
95
+ const now = await call(`/api/training/jobs/${encodeURIComponent(job.id)}`);
96
+ const line = `${now.status}${now.statusDetail ? ` \xB7 ${now.statusDetail}` : ""}`;
97
+ if (line !== last) {
98
+ progress(line);
99
+ last = line;
100
+ }
101
+ if (FINISHED.has(now.status)) {
102
+ emitResult({ ...shown, started: true, job: { id: now.id, status: now.status, detail: now.statusDetail, loss: now.loss, spentUsd: Number(now.spendMicroUsd ?? 0) / 1e6, weights: now.status === "COMPLETE" ? "stored with ClikDeploy; they are yours to keep (storage is billed hourly)" : void 0 } });
103
+ if (now.status !== "COMPLETE") process.exitCode = 1;
104
+ return;
105
+ }
106
+ await sleep2(POLL_MS);
107
+ }
108
+ }
109
+ export {
110
+ aiGatewayFineTune
111
+ };
@@ -0,0 +1,67 @@
1
+ import { createRequire as __clikcodeCreateRequire } from 'node:module';
2
+ const require = __clikcodeCreateRequire(import.meta.url);
3
+ import {
4
+ allLocalHarnesses,
5
+ builtInHarnesses,
6
+ harnessAcpLaunch,
7
+ harnessAdapterVersion,
8
+ harnessCanRunTurns,
9
+ harnessIntegrationLevel,
10
+ harnessLoginArgvForModel,
11
+ harnessPreferredTransport,
12
+ harnessReplyError,
13
+ harnessSupportsEffort,
14
+ harnessSupportsImages,
15
+ harnessSupportsModelSelection,
16
+ harnessSupportsPermissionMode,
17
+ harnessTierRank,
18
+ homeRedirectEnvironment,
19
+ isDirectModelProvider,
20
+ keyProviders,
21
+ localHarnessCapabilityManifest,
22
+ localHarnessForCommand,
23
+ localHarnessForProvider,
24
+ maxPromptArgvBytes,
25
+ modelDisplayId,
26
+ modelIdFromDisplay,
27
+ modelProvider,
28
+ nativeHarnessTurnArgv,
29
+ promptExceedsArgvLimit,
30
+ streamLocalAiTurn
31
+ } from "./chunk-KYUHIFP3.js";
32
+ import "./chunk-RSZGEL5U.js";
33
+ import "./chunk-WZYVLUVQ.js";
34
+ import "./chunk-F6F47QAY.js";
35
+ import "./chunk-RDDWQBEM.js";
36
+ import "./chunk-MPAJ446F.js";
37
+ import "./chunk-CBANJFBO.js";
38
+ import "./chunk-PWXII6HF.js";
39
+ export {
40
+ allLocalHarnesses,
41
+ builtInHarnesses,
42
+ harnessAcpLaunch,
43
+ harnessAdapterVersion,
44
+ harnessCanRunTurns,
45
+ harnessIntegrationLevel,
46
+ harnessLoginArgvForModel,
47
+ harnessPreferredTransport,
48
+ harnessReplyError,
49
+ harnessSupportsEffort,
50
+ harnessSupportsImages,
51
+ harnessSupportsModelSelection,
52
+ harnessSupportsPermissionMode,
53
+ harnessTierRank,
54
+ homeRedirectEnvironment,
55
+ isDirectModelProvider,
56
+ keyProviders,
57
+ localHarnessCapabilityManifest,
58
+ localHarnessForCommand,
59
+ localHarnessForProvider,
60
+ maxPromptArgvBytes,
61
+ modelDisplayId,
62
+ modelIdFromDisplay,
63
+ modelProvider,
64
+ nativeHarnessTurnArgv,
65
+ promptExceedsArgvLimit,
66
+ streamLocalAiTurn
67
+ };