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,307 @@
1
+ import { createRequire as __clikcodeCreateRequire } from 'node:module';
2
+ const require = __clikcodeCreateRequire(import.meta.url);
3
+ import {
4
+ formatLatencyTable,
5
+ medianLatencyByHarness,
6
+ turnsLatency
7
+ } from "./chunk-4NN3XQQT.js";
8
+ import {
9
+ isJsonDefaultMode
10
+ } from "./chunk-5B6TVO4A.js";
11
+ import {
12
+ lifecycleLogPath
13
+ } from "./chunk-RDDWQBEM.js";
14
+ import "./chunk-MPAJ446F.js";
15
+ import "./chunk-CBANJFBO.js";
16
+ import "./chunk-PWXII6HF.js";
17
+
18
+ // src/commands/logs.ts
19
+ import { closeSync, createReadStream, existsSync, openSync, readFileSync, readSync, statSync, watch } from "node:fs";
20
+
21
+ // src/commands/logs-check.ts
22
+ var COLD_MIN_INPUT = 2e3;
23
+ var COLD_BELOW = 0.5;
24
+ var CACHE_MIN_STEPS = 10;
25
+ var CACHE_SHARE_FLOOR = 0.7;
26
+ var n = (value) => typeof value === "number" && Number.isFinite(value) ? value : 0;
27
+ var text = (value) => typeof value === "string" && value ? value : void 0;
28
+ var bump = (map, key, by = 1) => {
29
+ map.set(key, (map.get(key) ?? 0) + by);
30
+ };
31
+ var top = (items, count, by) => items.sort((a, b) => by(b) - by(a)).slice(0, count);
32
+ function healthReport(entries, alive = () => true, now = Date.now()) {
33
+ const starts = /* @__PURE__ */ new Map();
34
+ const exited = /* @__PURE__ */ new Set();
35
+ const abnormal = /* @__PURE__ */ new Map();
36
+ const retired = /* @__PURE__ */ new Map();
37
+ const failures = /* @__PURE__ */ new Map();
38
+ const swallowed = /* @__PURE__ */ new Map();
39
+ const children = /* @__PURE__ */ new Map();
40
+ const outcomes = /* @__PURE__ */ new Map();
41
+ const attemptFailures = /* @__PURE__ */ new Map();
42
+ const crashes = /* @__PURE__ */ new Map();
43
+ const signals = /* @__PURE__ */ new Map();
44
+ const cacheByModel = /* @__PURE__ */ new Map();
45
+ const seenRun = /* @__PURE__ */ new Set();
46
+ let tools = 0;
47
+ let toolsFailed = 0;
48
+ let slowWrites = 0;
49
+ let worstWrite = 0;
50
+ let worstLock = 0;
51
+ let started = 0;
52
+ let exits = 0;
53
+ for (const entry of entries) {
54
+ switch (entry.event) {
55
+ case "process.start":
56
+ started += 1;
57
+ starts.set(entry.pid, entry);
58
+ break;
59
+ case "process.exit": {
60
+ exits += 1;
61
+ exited.add(entry.pid);
62
+ const code = n(entry.code);
63
+ if (code === 0) break;
64
+ const start = starts.get(entry.pid);
65
+ const what = text(entry.argv) ?? text(start?.argv) ?? entry.role;
66
+ const parent = text(entry.parent) ?? text(start?.parent);
67
+ const key = `${what}|${code}|${parent ?? ""}`;
68
+ const seen = abnormal.get(key) ?? { what, code, ...parent ? { parent } : {}, count: 0 };
69
+ seen.count += 1;
70
+ abnormal.set(key, seen);
71
+ break;
72
+ }
73
+ case "process.signal":
74
+ exited.add(entry.pid);
75
+ bump(signals, `${text(entry.signal) ?? "signal"} ${text(entry.argv) ?? entry.role}`.trim());
76
+ break;
77
+ case "process.error":
78
+ bump(crashes, text(entry.errno) ?? text(entry.origin) ?? "error");
79
+ break;
80
+ case "mcp.retired.launch": {
81
+ const command = text(entry.command) ?? "?";
82
+ const parent = text(entry.parent);
83
+ const key = `${command}|${parent ?? ""}`;
84
+ const seen = retired.get(key) ?? { command, ...parent ? { parent } : {}, count: 0 };
85
+ seen.count += 1;
86
+ retired.set(key, seen);
87
+ break;
88
+ }
89
+ case "turn.tool": {
90
+ tools += 1;
91
+ if (entry.ok !== false) break;
92
+ toolsFailed += 1;
93
+ const name = text(entry.name) ?? "tool";
94
+ const child = entry.child === true;
95
+ const key = `${name}|${child}`;
96
+ const seen = failures.get(key) ?? { name, child, count: 0 };
97
+ seen.count += 1;
98
+ if (!seen.sample && text(entry.err)) seen.sample = text(entry.err);
99
+ failures.set(key, seen);
100
+ break;
101
+ }
102
+ case "swallowed": {
103
+ const area = text(entry.area) ?? "?";
104
+ const seen = swallowed.get(area) ?? { area, count: 0 };
105
+ seen.count += 1 + n(entry.more);
106
+ if (!seen.errno && text(entry.errno)) seen.errno = text(entry.errno);
107
+ if (!seen.sample && text(entry.message)) seen.sample = text(entry.message);
108
+ swallowed.set(area, seen);
109
+ break;
110
+ }
111
+ case "child.failed": {
112
+ const program = text(entry.program) ?? "?";
113
+ const how = text(entry.errno) ?? (entry.signal ? `signal ${String(entry.signal)}` : `exit ${n(entry.code)}`);
114
+ const key = `${program}|${how}`;
115
+ const seen = children.get(key) ?? { program, how, count: 0 };
116
+ seen.count += 1 + n(entry.more);
117
+ children.set(key, seen);
118
+ break;
119
+ }
120
+ case "turn.step": {
121
+ const input = n(entry.input);
122
+ const model = text(entry.model);
123
+ if (!model || input <= 0 || entry.cached === void 0) break;
124
+ const run = `${entry.pid}|${text(entry.session) ?? ""}`;
125
+ if (!seenRun.has(run)) {
126
+ seenRun.add(run);
127
+ break;
128
+ }
129
+ const row = cacheByModel.get(model) ?? { model, steps: 0, input: 0, cached: 0, coldSteps: 0 };
130
+ row.steps += 1;
131
+ row.input += input;
132
+ row.cached += Math.min(input, n(entry.cached));
133
+ if (input >= COLD_MIN_INPUT && n(entry.cached) / input < COLD_BELOW) row.coldSteps += 1;
134
+ cacheByModel.set(model, row);
135
+ break;
136
+ }
137
+ case "worker.turn.end":
138
+ bump(outcomes, (text(entry.outcome) ?? "?").replace(/^error:.*/, "error"));
139
+ break;
140
+ case "worker.turn.attempt-failed":
141
+ bump(attemptFailures, text(entry.kind) ?? "other");
142
+ break;
143
+ case "state.write.slow":
144
+ slowWrites += 1;
145
+ worstWrite = Math.max(worstWrite, n(entry.ms));
146
+ break;
147
+ case "lock.held":
148
+ worstLock = Math.max(worstLock, n(entry.ms));
149
+ break;
150
+ default:
151
+ break;
152
+ }
153
+ }
154
+ const vanished = [...starts.values()].filter((start) => !exited.has(start.pid) && now - Date.parse(start.t) > 6e4 && !alive(start.pid)).length;
155
+ const report = {
156
+ window: { ...entries[0] ? { from: entries[0].t } : {}, ...entries.at(-1) ? { to: entries.at(-1).t } : {}, entries: entries.length },
157
+ processes: { started, exited: exits, abnormal: top([...abnormal.values()], 8, (item) => item.count), signals: Object.fromEntries(signals), vanished },
158
+ retiredLaunches: top([...retired.values()], 8, (item) => item.count),
159
+ tools: { total: tools, failed: toolsFailed, failures: top([...failures.values()], 8, (item) => item.count) },
160
+ swallowed: top([...swallowed.values()], 10, (item) => item.count),
161
+ children: top([...children.values()], 8, (item) => item.count),
162
+ turns: { outcomes: Object.fromEntries(outcomes), attemptFailures: Object.fromEntries(attemptFailures) },
163
+ state: { slowWrites, worstWriteMs: worstWrite, worstLockHeldMs: worstLock },
164
+ cache: top([...cacheByModel.values()].map((row) => ({ ...row, share: row.input ? row.cached / row.input : 0 })), 8, (row) => row.steps),
165
+ crashes: Object.fromEntries(crashes),
166
+ findings: []
167
+ };
168
+ const findings = report.findings;
169
+ for (const launch of report.retiredLaunches) findings.push(`A vendor config still launches the retired \`${launch.command}\`${launch.parent ? ` (started by ${launch.parent})` : ""}: ${launch.count} time${launch.count === 1 ? "" : "s"}. It answers as an empty server now; remove its entry.`);
170
+ for (const item of report.processes.abnormal) findings.push(`\`${item.what}\` exited ${item.code} ${item.count} time${item.count === 1 ? "" : "s"}${item.parent ? `, started by ${item.parent}` : ""}.`);
171
+ if (report.processes.vanished) findings.push(`${report.processes.vanished} process${report.processes.vanished === 1 ? "" : "es"} started and never said how they ended (killed with SIGKILL, or crashed hard).`);
172
+ for (const item of report.tools.failures) if (item.count >= 3) findings.push(`${item.count} \`${item.name}\` calls failed${item.child ? " inside a sub-agent" : ""}${item.sample ? `: ${item.sample}` : ""}.`);
173
+ for (const item of report.swallowed) if (item.count >= 3) findings.push(`${item.count} errors swallowed in ${item.area}${item.errno ? ` (${item.errno})` : ""}${item.sample ? `: ${item.sample}` : ""}.`);
174
+ for (const item of report.children) if (item.count >= 3) findings.push(`\`${item.program}\` failed ${item.count} times (${item.how}).`);
175
+ if (slowWrites >= 20) findings.push(`${slowWrites} slow state writes, the worst ${worstWrite} ms.`);
176
+ if (worstLock >= 5e3) findings.push(`The shared state lock was held for ${Math.round(worstLock / 1e3)} s once.`);
177
+ for (const row of report.cache) {
178
+ if (row.steps >= CACHE_MIN_STEPS && row.share < CACHE_SHARE_FLOOR) {
179
+ findings.push(`${row.model} had ${Math.round(row.share * 100)}% of its input already read by the server over ${row.steps} steps (${row.coldSteps} steps under ${COLD_BELOW * 100}%): the server is re-reading the conversation, which slows every step.`);
180
+ }
181
+ }
182
+ for (const [kind, count] of attemptFailures) if (kind !== "quota-exhausted" && count >= 3) findings.push(`${count} turn attempts failed as ${kind}.`);
183
+ return report;
184
+ }
185
+ function formatHealth(report) {
186
+ const lines = [];
187
+ const span = report.window.from && report.window.to ? `${report.window.from.slice(11, 19)} to ${report.window.to.slice(11, 19)} UTC` : "no records";
188
+ lines.push(`ClikCode log check \xB7 ${report.window.entries} records \xB7 ${span}`);
189
+ lines.push("");
190
+ lines.push(report.findings.length ? "Needs attention" : "Nothing needs attention.");
191
+ for (const finding of report.findings) lines.push(` - ${finding}`);
192
+ lines.push("");
193
+ const outcomes = Object.entries(report.turns.outcomes).map(([name, count]) => `${count} ${name}`).join(", ") || "none";
194
+ lines.push(`Turns: ${outcomes}`);
195
+ lines.push(`Processes: ${report.processes.started} started, ${report.processes.exited} exited`);
196
+ lines.push(`Tool calls: ${report.tools.total}, ${report.tools.failed} failed`);
197
+ lines.push(`State: ${report.state.slowWrites} slow writes (worst ${report.state.worstWriteMs} ms), shared lock held at most ${report.state.worstLockHeldMs} ms`);
198
+ const swallowed = report.swallowed.reduce((sum, item) => sum + item.count, 0);
199
+ lines.push(`Swallowed errors: ${swallowed}${report.swallowed.length ? ` (${report.swallowed.slice(0, 3).map((item) => `${item.area} ${item.count}`).join(", ")})` : ""}`);
200
+ for (const row of report.cache) lines.push(`Cache: ${row.model} ${Math.round(row.share * 100)}% of input already read over ${row.steps} steps, ${row.coldSteps} cold`);
201
+ const crashes = Object.entries(report.crashes).map(([name, count]) => `${count} ${name}`).join(", ");
202
+ if (crashes) lines.push(`Uncaught errors: ${crashes}`);
203
+ return lines.join("\n");
204
+ }
205
+
206
+ // src/commands/logs.ts
207
+ function sinceCutoff(since, now = Date.now()) {
208
+ const match = since ? /^(\d+)\s*([smhd])$/.exec(since.trim()) : null;
209
+ if (!match) return void 0;
210
+ const unit = { s: 1e3, m: 6e4, h: 36e5, d: 864e5 }[match[2]];
211
+ return now - Number(match[1]) * unit;
212
+ }
213
+ function matches(entry, options, cutoff) {
214
+ if (options.session && !(entry.session ?? "").startsWith(options.session)) return false;
215
+ if (options.role && entry.role !== options.role) return false;
216
+ if (cutoff !== void 0 && Date.parse(entry.t) < cutoff) return false;
217
+ return true;
218
+ }
219
+ function formatEntry(entry) {
220
+ const { t, pid, role, session, event, ...facts } = entry;
221
+ const time = t.slice(11, 23);
222
+ const details = Object.entries(facts).map(([key, value]) => `${key}=${typeof value === "string" && !/\s/.test(value) ? value : JSON.stringify(value)}`).join(" ");
223
+ return `${time} ${role.padEnd(7)} ${String(pid).padStart(7)} ${session ? session.slice(0, 8) : "--------"} ${event}${details ? ` ${details}` : ""}`;
224
+ }
225
+ function parse(line) {
226
+ try {
227
+ const value = JSON.parse(line);
228
+ return typeof value.event === "string" && typeof value.t === "string" ? value : void 0;
229
+ } catch {
230
+ return void 0;
231
+ }
232
+ }
233
+ function readTail(path, maxBytes) {
234
+ if (!existsSync(path)) return "";
235
+ const size = statSync(path).size;
236
+ const start = size > maxBytes ? size - maxBytes : 0;
237
+ const fd = openSync(path, "r");
238
+ try {
239
+ const buf = Buffer.alloc(size - start);
240
+ readSync(fd, buf, 0, buf.length, start);
241
+ const text2 = buf.toString("utf8");
242
+ return start > 0 ? text2.slice(Math.max(0, text2.indexOf("\n") + 1)) : text2;
243
+ } finally {
244
+ closeSync(fd);
245
+ }
246
+ }
247
+ async function showLogs(options) {
248
+ const path = lifecycleLogPath();
249
+ const json = isJsonDefaultMode();
250
+ const cutoff = sinceCutoff(options.since ?? (options.check ? "24h" : void 0));
251
+ const limit = Math.max(1, Number.parseInt(options.lines ?? "100", 10) || 100);
252
+ const print = (entry) => {
253
+ process.stdout.write(`${json ? JSON.stringify(entry) : formatEntry(entry)}
254
+ `);
255
+ };
256
+ const wantAll = Boolean(options.since || options.latency || options.check);
257
+ const text2 = wantAll ? [`${path}.1`, path].filter((file) => existsSync(file)).map((file) => readFileSync(file, "utf8")).join("") : `${readTail(`${path}.1`, 256 * 1024)}${readTail(path, 512 * 1024)}`;
258
+ const entries = text2.split("\n").map(parse).filter((entry) => Boolean(entry) && matches(entry, options, cutoff));
259
+ if (!entries.length && !options.follow) {
260
+ process.stderr.write(existsSync(path) ? "No lifecycle records match.\n" : `No lifecycle log yet (${path}).
261
+ `);
262
+ }
263
+ if (options.check) {
264
+ const { pidIsAlive } = await import("./chunk-WMI2TPMA.js");
265
+ const report = healthReport(entries, pidIsAlive);
266
+ process.stdout.write(`${json ? JSON.stringify(report) : formatHealth(report)}
267
+ `);
268
+ return;
269
+ }
270
+ if (options.latency) {
271
+ const last = Math.max(1, Number.parseInt(options.last ?? "20", 10) || 20);
272
+ const turns = turnsLatency(entries.filter((entry) => entry.event === "turn.mark")).slice(-last);
273
+ process.stdout.write(`${json ? JSON.stringify({ turns, medians: medianLatencyByHarness(turns) }) : formatLatencyTable(turns)}
274
+ `);
275
+ return;
276
+ }
277
+ for (const entry of entries.slice(-limit)) print(entry);
278
+ if (!options.follow) return;
279
+ let offset = existsSync(path) ? statSync(path).size : 0;
280
+ let carry = "";
281
+ const readNew = () => {
282
+ if (!existsSync(path)) return;
283
+ const size = statSync(path).size;
284
+ if (size < offset) offset = 0;
285
+ if (size === offset) return;
286
+ const stream = createReadStream(path, { start: offset, end: size - 1, encoding: "utf8" });
287
+ offset = size;
288
+ stream.on("data", (chunk) => {
289
+ const lines = (carry + chunk).split("\n");
290
+ carry = lines.pop() ?? "";
291
+ for (const line of lines) {
292
+ const entry = parse(line);
293
+ if (entry && matches(entry, options, cutoff)) print(entry);
294
+ }
295
+ });
296
+ };
297
+ await new Promise(() => {
298
+ watch(lifecycleLogPath().replace(/lifecycle\.log$/, ""), () => readNew());
299
+ setInterval(readNew, 2e3);
300
+ });
301
+ }
302
+ export {
303
+ formatEntry,
304
+ matches,
305
+ showLogs,
306
+ sinceCutoff
307
+ };
@@ -0,0 +1,164 @@
1
+ import { createRequire as __clikcodeCreateRequire } from 'node:module';
2
+ const require = __clikcodeCreateRequire(import.meta.url);
3
+ import {
4
+ getApiUrl,
5
+ saveGatewayAuth
6
+ } from "./chunk-TQDM7S5N.js";
7
+ import {
8
+ childEnvironment
9
+ } from "./chunk-GYMAI5NY.js";
10
+ import {
11
+ sleep
12
+ } from "./chunk-YMCH3L2S.js";
13
+ import {
14
+ isJsonDefaultMode
15
+ } from "./chunk-5B6TVO4A.js";
16
+ import {
17
+ CLIKCODE_USER_AGENT
18
+ } from "./chunk-NAOX3JUB.js";
19
+
20
+ // src/commands/gateway.ts
21
+ import { spawn } from "node:child_process";
22
+ import { createHash, randomBytes } from "node:crypto";
23
+ var REQUEST_TIMEOUT_MS = 3e4;
24
+ var POLL_INTERVAL_MS = 2e3;
25
+ var LOGIN_TIMEOUT_MS = 5 * 60 * 1e3;
26
+ var GatewayHttpError = class extends Error {
27
+ constructor(message, status) {
28
+ super(message);
29
+ this.status = status;
30
+ this.name = "GatewayHttpError";
31
+ }
32
+ status;
33
+ };
34
+ function openBrowserDefault(url) {
35
+ let cmd, args;
36
+ if (process.platform === "darwin") {
37
+ cmd = "open";
38
+ args = [url];
39
+ } else if (process.platform === "win32") {
40
+ cmd = "cmd";
41
+ args = ["/c", "start", "", url];
42
+ } else {
43
+ cmd = "xdg-open";
44
+ args = [url];
45
+ }
46
+ const child = spawn(cmd, args, { stdio: "ignore", detached: true, env: childEnvironment(cmd) });
47
+ child.on("error", () => {
48
+ });
49
+ child.unref();
50
+ }
51
+ async function requestJson(fetchImpl, url, init) {
52
+ const response = await fetchImpl(url, {
53
+ method: init.method,
54
+ headers: {
55
+ Accept: "application/json",
56
+ "Content-Type": "application/json",
57
+ "User-Agent": CLIKCODE_USER_AGENT,
58
+ ...init.bearer ? { Authorization: `Bearer ${init.bearer}` } : {}
59
+ },
60
+ ...init.body !== void 0 ? { body: JSON.stringify(init.body) } : {},
61
+ signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS)
62
+ });
63
+ const text = await response.text();
64
+ let payload = null;
65
+ try {
66
+ payload = text ? JSON.parse(text) : null;
67
+ } catch {
68
+ payload = null;
69
+ }
70
+ if (!response.ok) {
71
+ const detail = payload?.error?.message ?? payload?.error ?? payload?.message;
72
+ throw new GatewayHttpError(
73
+ typeof detail === "string" && detail ? detail : `ClikDeploy Gateway request failed with HTTP ${response.status}`,
74
+ response.status
75
+ );
76
+ }
77
+ return payload;
78
+ }
79
+ function extractUser(payload) {
80
+ const data = payload?.data;
81
+ if (data && typeof data === "object" && "user" in data && data.user) return data.user;
82
+ return payload?.user ?? data ?? null;
83
+ }
84
+ function retryable(error) {
85
+ if (!(error instanceof GatewayHttpError)) return true;
86
+ return error.status >= 500 || error.status === 429 || error.status === 408;
87
+ }
88
+ async function gatewayLogin(config, options = {}, deps = {}) {
89
+ const provider = options.github ? "github" : "google";
90
+ const log = deps.log ?? ((line) => {
91
+ if (!isJsonDefaultMode()) console.log(line);
92
+ });
93
+ try {
94
+ const user = await runDeviceFlow(config, provider, { ...deps, log });
95
+ log(`
96
+ Logged in as ${user.email ?? "unknown"}`);
97
+ log("Authentication saved securely.\n");
98
+ return user;
99
+ } catch (error) {
100
+ if (error instanceof GatewayHttpError && error.status === 401) {
101
+ error.message += " (CLIKCODE_GATEWAY_URL must point to the same platform you signed in to)";
102
+ }
103
+ throw error;
104
+ }
105
+ }
106
+ async function runDeviceFlow(config, provider, deps) {
107
+ const fetchImpl = deps.fetch ?? fetch;
108
+ const sleep2 = deps.sleep ?? sleep;
109
+ const now = deps.now ?? Date.now;
110
+ const baseUrl = getApiUrl(config).replace(/\/$/, "");
111
+ const codeVerifier = randomBytes(32).toString("base64url");
112
+ const codeChallenge = createHash("sha256").update(codeVerifier, "ascii").digest("base64url");
113
+ const initResponse = await requestJson(fetchImpl, `${baseUrl}/api/gate/auth/device/init`, {
114
+ method: "POST",
115
+ body: { provider, codeChallenge, codeChallengeMethod: "S256" }
116
+ });
117
+ const initPayload = initResponse?.data ?? initResponse;
118
+ const flowId = String(initPayload?.flowId || "");
119
+ const authUrl = String(initPayload?.authUrl || "");
120
+ if (!flowId || !authUrl) throw new Error("Failed to start auth flow");
121
+ (deps.openBrowser ?? openBrowserDefault)(authUrl);
122
+ deps.log("\nOpening browser for authentication...");
123
+ deps.log(`
124
+ If your browser did not open, visit:
125
+ ${authUrl}
126
+ `);
127
+ deps.log("Waiting for authentication...");
128
+ const deadline = now() + (deps.timeoutMs ?? LOGIN_TIMEOUT_MS);
129
+ while (now() < deadline) {
130
+ await sleep2(deps.pollIntervalMs ?? POLL_INTERVAL_MS);
131
+ let poll;
132
+ try {
133
+ poll = await requestJson(fetchImpl, `${baseUrl}/api/gate/auth/device/poll`, {
134
+ method: "POST",
135
+ body: { flowId, codeVerifier }
136
+ });
137
+ } catch (error) {
138
+ if (!retryable(error)) throw error;
139
+ continue;
140
+ }
141
+ const status = String(poll?.status || "pending");
142
+ if (status === "expired") {
143
+ throw Object.assign(new Error("Authentication session expired. Run the login command again."), { code: "AUTH_EXPIRED" });
144
+ }
145
+ const apiKey = poll?.data?.apiKey ?? poll?.apiKey;
146
+ if (status === "complete" && apiKey) {
147
+ let user;
148
+ try {
149
+ user = extractUser(await requestJson(fetchImpl, `${baseUrl}/api/gate/auth/me`, { method: "GET", bearer: String(apiKey) }));
150
+ } catch (error) {
151
+ if (!retryable(error)) throw error;
152
+ continue;
153
+ }
154
+ if (!user) throw new Error("Authentication verification returned no user");
155
+ saveGatewayAuth(config, String(apiKey), user);
156
+ return user;
157
+ }
158
+ }
159
+ throw new Error("Authentication timed out. Run the login command again.");
160
+ }
161
+
162
+ export {
163
+ gatewayLogin
164
+ };