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,597 @@
1
+ import { createRequire as __clikcodeCreateRequire } from 'node:module';
2
+ const require = __clikcodeCreateRequire(import.meta.url);
3
+ import {
4
+ backoffMs
5
+ } from "./chunk-CVFVFRGN.js";
6
+ import {
7
+ failoverPromptRequest,
8
+ isClikCodeOpening,
9
+ normalizeImportedTranscript
10
+ } from "./chunk-FF7ZVYJF.js";
11
+ import {
12
+ jsonMemo
13
+ } from "./chunk-ZT7B4H2V.js";
14
+ import {
15
+ withFileLock
16
+ } from "./chunk-4L2ZZM4Q.js";
17
+ import {
18
+ quiet
19
+ } from "./chunk-RDDWQBEM.js";
20
+ import {
21
+ stateDirectory
22
+ } from "./chunk-MPAJ446F.js";
23
+
24
+ // src/session/discovery/transcript.ts
25
+ function reconcileNativeTranscript(cached, source) {
26
+ cached = normalizeImportedTranscript(cached);
27
+ source = normalizeImportedTranscript(source);
28
+ if (!cached.length) return { messages: [...source], appendedFrom: 0, overlapLength: 0 };
29
+ if (!source.length) return { messages: [...cached], appendedFrom: cached.length, overlapLength: 0 };
30
+ const key = (message) => `${message.role}\0${message.content.replace(/\s+/g, " ").trim()}`;
31
+ const pattern = cached.map(key).reverse();
32
+ const fallback = new Array(pattern.length).fill(0);
33
+ for (let index = 1, matched = 0; index < pattern.length; index += 1) {
34
+ while (matched && pattern[index] !== pattern[matched]) matched = fallback[matched - 1];
35
+ if (pattern[index] === pattern[matched]) matched += 1;
36
+ fallback[index] = matched;
37
+ }
38
+ let length = 0;
39
+ let sourceStart = 0;
40
+ for (let index = source.length - 1, matched = 0; index >= 0; index -= 1) {
41
+ const value = key(source[index]);
42
+ while (matched && value !== pattern[matched]) matched = fallback[matched - 1];
43
+ if (value === pattern[matched]) matched += 1;
44
+ if (matched > length) {
45
+ length = matched;
46
+ sourceStart = index;
47
+ }
48
+ if (matched === pattern.length) break;
49
+ }
50
+ if (length) {
51
+ const prefix = length === cached.length ? source.slice(0, sourceStart) : [];
52
+ return { messages: [...prefix, ...cached, ...source.slice(sourceStart + length)], appendedFrom: prefix.length + cached.length, overlapLength: length };
53
+ }
54
+ return { messages: [...cached], appendedFrom: cached.length, overlapLength: 0 };
55
+ }
56
+ function extractMessageText(content) {
57
+ if (typeof content === "string") return content;
58
+ if (!Array.isArray(content)) return "";
59
+ return content.map((part) => typeof part?.text === "string" ? part.text : "").join(" ").trim();
60
+ }
61
+ function visibleNativeUserText(text) {
62
+ let trimmed = text.trim();
63
+ const envelope = /^<(recommended_plugins|environment_context|user_instructions|developer_instructions|system-reminder|local-command-caveat|local-command-stdout|ide_opened_file|ide_selection|task-notification)\b[^>]*>[\s\S]*?<\/\1>\s*/i;
64
+ while (envelope.test(trimmed)) trimmed = trimmed.replace(envelope, "");
65
+ if (!trimmed) return "";
66
+ if (trimmed.startsWith("# Context from my IDE setup:")) {
67
+ const marker = "\n## My request:\n";
68
+ const requestStart = trimmed.indexOf(marker);
69
+ if (requestStart >= 0) return trimmed.slice(requestStart + marker.length).trim();
70
+ }
71
+ return trimmed;
72
+ }
73
+ function leadingText(line) {
74
+ const match = /"(?:text|content)"\s*:\s*"((?:[^"\\]|\\.)*)/.exec(line);
75
+ if (!match) return void 0;
76
+ const escaped = match[1].replace(/\\u?[0-9a-fA-F]{0,3}$|\\$/, "");
77
+ try {
78
+ return JSON.parse(`"${escaped}"`);
79
+ } catch {
80
+ return escaped;
81
+ }
82
+ }
83
+
84
+ // src/session/discovery/vendors/claude.ts
85
+ import { readdir as readdir3, readFile, stat as stat3 } from "node:fs/promises";
86
+ import { homedir } from "node:os";
87
+ import { basename, join as join3 } from "node:path";
88
+
89
+ // src/session/discovery/cache.ts
90
+ import { readdir, stat } from "node:fs/promises";
91
+ import { join } from "node:path";
92
+ var DISCOVERY_CACHE_MAX_SEEN = 120;
93
+ var EMPTY_LISTING_TTL_MS = 5 * 6e4;
94
+ var SEEN_LISTING_TTL_MS = 2 * 6e4;
95
+ var DISCOVERY_CACHE_MAX_DIRECTORIES = 400;
96
+ var memo = jsonMemo("cache/native-discovery.json", () => ({ v: 1, directories: {} }), (parsed) => {
97
+ const file = parsed;
98
+ if (file.v !== 1 || !file.directories || typeof file.directories !== "object") return void 0;
99
+ return { v: 1, directories: file.directories };
100
+ });
101
+ var listings = jsonMemo("cache/native-listings.json", () => ({ v: 1, seen: {} }), (parsed) => {
102
+ const file = parsed;
103
+ return file.v === 1 && file.seen && typeof file.seen === "object" ? file : void 0;
104
+ });
105
+ async function readListings() {
106
+ return await listings.read() ?? { v: 1, seen: {} };
107
+ }
108
+ var codexPathById = /* @__PURE__ */ new Map();
109
+ function loadDiscoveryCache() {
110
+ return memo.load();
111
+ }
112
+ function discoveryCacheChanged() {
113
+ memo.changed();
114
+ }
115
+ async function saveDiscoveryCache() {
116
+ if (!memo.dirty) return;
117
+ const data = await memo.load();
118
+ const entries = Object.entries(data.directories);
119
+ if (entries.length > DISCOVERY_CACHE_MAX_DIRECTORIES) {
120
+ data.directories = Object.fromEntries(entries.sort(([, left], [, right]) => right.mtimeMs - left.mtimeMs).slice(0, DISCOVERY_CACHE_MAX_DIRECTORIES));
121
+ }
122
+ await memo.save();
123
+ }
124
+ async function cachedDirectory(directory, suffix) {
125
+ const cache = await loadDiscoveryCache();
126
+ const info = await stat(directory).catch(quiet("session/discovery/cache"));
127
+ if (!info?.isDirectory()) {
128
+ if (cache.directories[directory]) {
129
+ delete cache.directories[directory];
130
+ memo.changed();
131
+ }
132
+ return void 0;
133
+ }
134
+ const known = cache.directories[directory];
135
+ if (known && known.mtimeMs === info.mtimeMs) return known;
136
+ let names;
137
+ try {
138
+ names = (await readdir(directory, { withFileTypes: true })).filter((entry) => entry.isFile() && entry.name.endsWith(suffix)).map((entry) => entry.name);
139
+ } catch {
140
+ return void 0;
141
+ }
142
+ const next = { mtimeMs: info.mtimeMs, files: Object.fromEntries(names.map((name) => [name, known?.files[name] ?? {}])) };
143
+ cache.directories[directory] = next;
144
+ memo.changed();
145
+ return next;
146
+ }
147
+ function listingKey(command, workspace, profile) {
148
+ return `${command}\0${workspace ?? ""}\0${profile ?? ""}`;
149
+ }
150
+ var LISTING_LEASE_MS = 9e4;
151
+ function listingLifetime(entry) {
152
+ if (entry.lease) return LISTING_LEASE_MS;
153
+ const answered = entry.sessions.length ? SEEN_LISTING_TTL_MS : EMPTY_LISTING_TTL_MS;
154
+ return entry.failures ? Math.max(answered, backoffMs(entry.failures)) : answered;
155
+ }
156
+ async function rememberListing(command, workspace, profile, sessions, now = Date.now(), build, extra = {}) {
157
+ await withCacheLock("native-listings.json", async () => {
158
+ const file = await readListings();
159
+ file.seen[listingKey(command, workspace, profile)] = { at: now, sessions: [...sessions], ...build ? { build } : {}, ...extra.failures ? { failures: extra.failures } : {} };
160
+ await writeListings(file);
161
+ });
162
+ }
163
+ async function writeListings(file) {
164
+ const newest = Object.entries(file.seen).sort(([, left], [, right]) => right.at - left.at).slice(0, DISCOVERY_CACHE_MAX_SEEN);
165
+ await listings.write({ v: 1, seen: Object.fromEntries(newest) });
166
+ }
167
+ async function claimListing(command, workspace, profile, now = Date.now(), build) {
168
+ return withCacheLock("native-listings.json", async () => {
169
+ const file = await readListings();
170
+ const key = listingKey(command, workspace, profile);
171
+ const entry = file.seen[key];
172
+ if (entry && entry.build === build && now - entry.at < listingLifetime(entry)) return { fresh: entry.sessions };
173
+ const last = entry?.sessions ?? [];
174
+ const failures = entry?.failures ?? 0;
175
+ file.seen[key] = { at: now, sessions: [...last], ...build ? { build } : {}, lease: true, ...failures ? { failures } : {} };
176
+ await writeListings(file);
177
+ return { claimed: { last, failures } };
178
+ });
179
+ }
180
+ function withCacheLock(name, run) {
181
+ if (process.env.VITEST && !process.env.CLIKCODE_HOME?.trim()) return run();
182
+ const directory = stateDirectory();
183
+ return directory ? withFileLock(join(directory, "cache", `${name.replace(/[^A-Za-z0-9_.-]/g, "_")}.lock`), run) : run();
184
+ }
185
+ async function freshListing(command, workspace, profile, now = Date.now(), build) {
186
+ const entry = (await readListings()).seen[listingKey(command, workspace, profile)];
187
+ if (!entry || entry.build !== build || now - entry.at >= listingLifetime(entry)) return void 0;
188
+ return entry.sessions;
189
+ }
190
+ async function lastSeenListing(command, workspace, profile) {
191
+ return (await readListings()).seen[listingKey(command, workspace, profile)]?.sessions ?? [];
192
+ }
193
+
194
+ // src/session/discovery/files.ts
195
+ import { open, readdir as readdir2, stat as stat2 } from "node:fs/promises";
196
+ import { join as join2 } from "node:path";
197
+ async function readFilePrefix(path, maxBytes) {
198
+ const handle = await open(path, "r");
199
+ try {
200
+ const buffer = Buffer.alloc(maxBytes);
201
+ const { bytesRead } = await handle.read(buffer, 0, maxBytes, 0);
202
+ return buffer.toString("utf8", 0, bytesRead);
203
+ } finally {
204
+ await handle.close();
205
+ }
206
+ }
207
+ async function readFileSuffix(path, maxBytes) {
208
+ const handle = await open(path, "r");
209
+ try {
210
+ const { size } = await handle.stat();
211
+ const length = Math.min(maxBytes, size);
212
+ const buffer = Buffer.alloc(length);
213
+ const { bytesRead } = await handle.read(buffer, 0, length, Math.max(0, size - length));
214
+ const text = buffer.toString("utf8", 0, bytesRead);
215
+ if (length >= size) return text;
216
+ const newline = text.indexOf("\n");
217
+ return newline === -1 ? "" : text.slice(newline + 1);
218
+ } finally {
219
+ await handle.close();
220
+ }
221
+ }
222
+ async function walkFilesRecursive(dir, maxDepth, suffix) {
223
+ let entries;
224
+ try {
225
+ entries = await readdir2(dir, { withFileTypes: true });
226
+ } catch {
227
+ return [];
228
+ }
229
+ const files = [];
230
+ for (const entry of entries) {
231
+ const full = join2(dir, entry.name);
232
+ if (entry.isDirectory() && maxDepth > 0) files.push(...await walkFilesRecursive(full, maxDepth - 1, suffix));
233
+ else if (entry.isFile() && entry.name.endsWith(suffix)) files.push(full);
234
+ }
235
+ return files;
236
+ }
237
+ async function newestFiles(paths, limit) {
238
+ const stats = await Promise.all(paths.map(async (path) => {
239
+ const info = await stat2(path).catch(quiet("session/discovery/files"));
240
+ return info ? { path, mtimeMs: info.mtimeMs } : void 0;
241
+ }));
242
+ return stats.filter((item) => Boolean(item)).sort((left, right) => right.mtimeMs - left.mtimeMs).slice(0, limit);
243
+ }
244
+ async function sortedSubdirectories(directory) {
245
+ try {
246
+ return (await readdir2(directory, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name).sort().reverse();
247
+ } catch {
248
+ return [];
249
+ }
250
+ }
251
+
252
+ // src/session/discovery/stores.ts
253
+ function nativeDataRoot(environment, variable, fallback) {
254
+ return environment[variable]?.trim() || fallback;
255
+ }
256
+
257
+ // src/session/discovery/conversation-title.ts
258
+ function conversationTitle(prompt) {
259
+ const title = (failoverPromptRequest(prompt) ?? prompt).replace(/\s+/g, " ").trim();
260
+ return title.length > 64 ? `${title.slice(0, 63).trimEnd()}\u2026` : title;
261
+ }
262
+
263
+ // src/session/discovery/vendors/claude-entry.ts
264
+ function textOf(content) {
265
+ if (typeof content === "string") return content;
266
+ if (!Array.isArray(content)) return "";
267
+ return content.flatMap((block) => block && typeof block === "object" && block.type === "text" ? [String(block.text ?? "")] : []).join("\n");
268
+ }
269
+ function mayHoldClaudeRequest(line) {
270
+ return line.includes('"type":"user"') || line.includes('"queued_command"');
271
+ }
272
+ function claudeTypedRequest(entry) {
273
+ if (entry.isSidechain) return void 0;
274
+ let text;
275
+ let at = typeof entry.timestamp === "string" ? entry.timestamp : void 0;
276
+ if (entry.type === "user") {
277
+ if (entry.isMeta || entry.isCompactSummary) return void 0;
278
+ if (entry.origin?.kind === "task-notification") return void 0;
279
+ text = textOf(entry.message?.content);
280
+ } else if (entry.type === "attachment") {
281
+ const attachment = entry.attachment;
282
+ if (attachment?.type !== "queued_command" || attachment.commandMode !== "prompt") return void 0;
283
+ text = textOf(attachment.prompt);
284
+ if (typeof attachment.timestamp === "string") at = attachment.timestamp;
285
+ } else return void 0;
286
+ if (!text.trim()) return void 0;
287
+ return { text, ...at ? { at } : {} };
288
+ }
289
+
290
+ // src/session/discovery/vendors/claude.ts
291
+ function claudeProjectDirectoryNames(workspace) {
292
+ return [.../* @__PURE__ */ new Set([workspace.replace(/[^a-zA-Z0-9]/g, "-"), workspace.replace(/\//g, "-")])];
293
+ }
294
+ function claudeProjectRoot(environment) {
295
+ return join3(nativeDataRoot(environment, "CLAUDE_CONFIG_DIR", join3(homedir(), ".claude")), "projects");
296
+ }
297
+ function claudeProjectDirectories(workspace, environment) {
298
+ return claudeProjectDirectoryNames(workspace).map((name) => join3(claudeProjectRoot(environment), name));
299
+ }
300
+ async function allClaudeProjectDirectories(environment) {
301
+ const root = claudeProjectRoot(environment);
302
+ const entries = await readdir3(root, { withFileTypes: true }).catch(() => []);
303
+ return entries.filter((entry) => entry.isDirectory()).map((entry) => join3(root, entry.name));
304
+ }
305
+ async function claudeSessionCwd(path) {
306
+ const head = await readFilePrefix(path, 16e3).catch(() => "");
307
+ return /"cwd":"((?:[^"\\]|\\.)+)"/.exec(head)?.[1]?.replace(/\\(.)/g, "$1");
308
+ }
309
+ async function claudeSessionTitle(path) {
310
+ const tail = await readFileSuffix(path, 64e3).catch(() => "");
311
+ let generated;
312
+ for (const line of tail.split("\n")) {
313
+ if (!line.includes("ai-title")) continue;
314
+ try {
315
+ const record = JSON.parse(line);
316
+ if (record.type === "ai-title" && typeof record.aiTitle === "string" && record.aiTitle.trim()) generated = record.aiTitle.trim();
317
+ } catch {
318
+ }
319
+ }
320
+ const prefix = await readFilePrefix(path, 8e3).catch(() => "");
321
+ let first;
322
+ let opening;
323
+ for (const line of prefix.split("\n")) {
324
+ if (!line.trim()) continue;
325
+ let text;
326
+ let queued = false;
327
+ try {
328
+ const record = JSON.parse(line);
329
+ queued = record.type === "queue-operation" && record.operation === "enqueue";
330
+ if (record.type !== "user" && !queued) continue;
331
+ text = visibleNativeUserText(queued ? typeof record.content === "string" ? record.content : "" : extractMessageText(record.message?.content));
332
+ } catch {
333
+ queued = /"type"\s*:\s*"queue-operation"/.test(line) && line.includes('"enqueue"');
334
+ if (!queued && !/"type"\s*:\s*"user"|"role"\s*:\s*"user"/.test(line)) continue;
335
+ text = visibleNativeUserText(leadingText(line) ?? "");
336
+ }
337
+ if (!text) continue;
338
+ opening ??= text;
339
+ if (!queued) {
340
+ first = text;
341
+ break;
342
+ }
343
+ }
344
+ const byClikCode = !!opening && isClikCodeOpening(opening);
345
+ if (generated) return { title: generated, generated: true, byClikCode };
346
+ return { ...first ? { title: conversationTitle(first) } : {}, byClikCode };
347
+ }
348
+ async function discoverClaudeFsSessions(workspace, environment = {}) {
349
+ const sessions = [];
350
+ const everywhere = !workspace;
351
+ for (const dir of everywhere ? await allClaudeProjectDirectories(environment) : claudeProjectDirectories(workspace, environment)) {
352
+ const listing = await cachedDirectory(dir, ".jsonl");
353
+ if (!listing) continue;
354
+ const recent = await newestFiles(Object.keys(listing.files).map((name) => join3(dir, name)), 15);
355
+ for (const file of recent) {
356
+ const name = basename(file.path);
357
+ const facts = listing.files[name] ?? {};
358
+ if (facts.mtimeMs !== file.mtimeMs || everywhere && facts.cwd === void 0 || facts.byClikCode === void 0) {
359
+ const read = await claudeSessionTitle(file.path);
360
+ const cwd = everywhere ? await claudeSessionCwd(file.path) : facts.cwd;
361
+ listing.files[name] = { title: read.title, generated: read.generated, byClikCode: read.byClikCode, mtimeMs: file.mtimeMs, ...cwd ? { cwd } : {} };
362
+ discoveryCacheChanged();
363
+ }
364
+ const known = listing.files[name];
365
+ sessions.push({
366
+ nativeId: name.replace(/\.jsonl$/, ""),
367
+ title: known.title,
368
+ ...known.generated ? { titleIsGenerated: true } : {},
369
+ ...known.byClikCode ? { byClikCode: true } : {},
370
+ updatedAt: new Date(file.mtimeMs).toISOString(),
371
+ updatedAtMs: file.mtimeMs,
372
+ ...known.cwd ? { workspace: known.cwd } : {}
373
+ });
374
+ }
375
+ if (sessions.length && !everywhere) break;
376
+ }
377
+ await saveDiscoveryCache();
378
+ return everywhere ? sessions.sort((left, right) => (right.updatedAtMs ?? 0) - (left.updatedAtMs ?? 0)).slice(0, 30) : sessions;
379
+ }
380
+ async function readClaudeFsTranscript(nativeId, workspace, environment = {}) {
381
+ let raw;
382
+ for (const dir of claudeProjectDirectories(workspace, environment)) {
383
+ raw = await readFile(join3(dir, `${nativeId}.jsonl`), "utf8").catch(quiet("session/discovery/vendors/claude"));
384
+ if (raw !== void 0) break;
385
+ }
386
+ if (raw === void 0) return [];
387
+ return parseClaudeTranscript(raw);
388
+ }
389
+ function parseClaudeTranscript(raw) {
390
+ const messages = [];
391
+ for (const line of raw.split("\n")) {
392
+ if (!line.trim()) continue;
393
+ let record;
394
+ try {
395
+ record = JSON.parse(line);
396
+ } catch {
397
+ continue;
398
+ }
399
+ const typed = claudeTypedRequest(record);
400
+ if (typed) {
401
+ const text2 = visibleNativeUserText(typed.text);
402
+ if (text2) messages.push({ role: "user", content: text2 });
403
+ continue;
404
+ }
405
+ if (record.type !== "assistant" || record.isSidechain) continue;
406
+ const text = extractMessageText(record.message?.content);
407
+ if (!text) continue;
408
+ messages.push({ role: "assistant", content: text });
409
+ }
410
+ return messages;
411
+ }
412
+ async function readClaudeFsTranscriptForSync(nativeId, workspace, cached, environment = {}) {
413
+ if (!cached.length) return readClaudeFsTranscript(nativeId, workspace, environment);
414
+ for (const dir of claudeProjectDirectories(workspace, environment)) {
415
+ const path = join3(dir, `${nativeId}.jsonl`);
416
+ const info = await stat3(path).catch(quiet("session/discovery/vendors/claude"));
417
+ if (!info?.isFile()) continue;
418
+ let bytes = 256 * 1024;
419
+ while (bytes < info.size) {
420
+ const source = parseClaudeTranscript(await readFileSuffix(path, bytes));
421
+ const { overlapLength } = reconcileNativeTranscript(cached, source);
422
+ if (overlapLength > 0 && overlapLength < cached.length) return source;
423
+ bytes *= 2;
424
+ }
425
+ return readClaudeFsTranscript(nativeId, workspace, environment);
426
+ }
427
+ return [];
428
+ }
429
+
430
+ // src/session/discovery/vendors/codex.ts
431
+ import { readdir as readdir4, readFile as readFile2, stat as stat4 } from "node:fs/promises";
432
+ import { homedir as homedir2 } from "node:os";
433
+ import { join as join4 } from "node:path";
434
+ var CODEX_DISCOVERY_LIMIT = 25;
435
+ var CODEX_MIN_DAY_DIRECTORIES = 7;
436
+ var CODEX_MAX_DAY_DIRECTORIES = 180;
437
+ function parseCodexSessionHead(prefix, fileName) {
438
+ const facts = {};
439
+ const opening = (text) => {
440
+ if (facts.byClikCode === void 0 && text) facts.byClikCode = isClikCodeOpening(text);
441
+ };
442
+ for (const line of prefix.split("\n")) {
443
+ if (!line.trim()) continue;
444
+ let record;
445
+ try {
446
+ record = JSON.parse(line);
447
+ } catch {
448
+ if (line.includes('"response_item"') && /"role"\s*:\s*"user"/.test(line)) opening(visibleNativeUserText(leadingText(line) ?? ""));
449
+ if (!facts.id && line.includes('"session_meta"')) {
450
+ const id = /"(?:session_id|id)"\s*:\s*"([^"\\]+)"/.exec(line)?.[1];
451
+ const cwd = /"cwd"\s*:\s*("(?:[^"\\]|\\.)*")/.exec(line)?.[1];
452
+ if (id) facts.id = id;
453
+ if (cwd) {
454
+ try {
455
+ facts.cwd = JSON.parse(cwd);
456
+ } catch {
457
+ }
458
+ }
459
+ }
460
+ continue;
461
+ }
462
+ const payload = record.payload;
463
+ if (record.type === "session_meta") {
464
+ const id = typeof payload?.id === "string" && payload.id ? payload.id : typeof payload?.session_id === "string" && payload.session_id ? payload.session_id : void 0;
465
+ if (id) facts.id = id;
466
+ if (typeof payload?.cwd === "string") facts.cwd = payload.cwd;
467
+ } else if (record.type === "response_item" && payload?.role === "user") {
468
+ const text = visibleNativeUserText(extractMessageText(payload.content));
469
+ opening(text);
470
+ if (text && !facts.title) facts.title = conversationTitle(text);
471
+ }
472
+ }
473
+ facts.byClikCode ??= false;
474
+ if (!facts.id) {
475
+ const fromName = /([0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12})\.jsonl$/i.exec(fileName)?.[1];
476
+ if (fromName) facts.id = fromName;
477
+ }
478
+ return facts;
479
+ }
480
+ async function* codexDayDirectories(root) {
481
+ for (const year of await sortedSubdirectories(root)) {
482
+ for (const month of await sortedSubdirectories(join4(root, year))) {
483
+ for (const day of await sortedSubdirectories(join4(root, year, month))) yield join4(root, year, month, day);
484
+ }
485
+ }
486
+ }
487
+ async function discoverCodexFsSessions(workspace, environment = {}) {
488
+ const root = join4(nativeDataRoot(environment, "CODEX_HOME", join4(homedir2(), ".codex")), "sessions");
489
+ const matches = [];
490
+ let scanned = 0;
491
+ for await (const dir of codexDayDirectories(root)) {
492
+ if (scanned >= CODEX_MAX_DAY_DIRECTORIES) break;
493
+ if (scanned >= CODEX_MIN_DAY_DIRECTORIES && matches.length >= CODEX_DISCOVERY_LIMIT) break;
494
+ scanned += 1;
495
+ const listing = await cachedDirectory(dir, ".jsonl");
496
+ if (!listing) continue;
497
+ for (const name of Object.keys(listing.files)) {
498
+ const path = join4(dir, name);
499
+ let facts = listing.files[name];
500
+ if (!facts.id || !facts.title || facts.byClikCode === void 0) {
501
+ facts = parseCodexSessionHead(await readFilePrefix(path, 64e3).catch(() => ""), name);
502
+ listing.files[name] = facts;
503
+ discoveryCacheChanged();
504
+ }
505
+ if (!facts.id) continue;
506
+ codexPathById.set(`${root}\0${facts.id}`, path);
507
+ if (workspace && facts.cwd && facts.cwd !== workspace) continue;
508
+ const info = await stat4(path).catch(quiet("session/discovery/vendors/codex"));
509
+ if (!info) continue;
510
+ matches.push({ nativeId: facts.id, title: facts.title, ...facts.byClikCode ? { byClikCode: true } : {}, updatedAt: new Date(info.mtimeMs).toISOString(), updatedAtMs: info.mtimeMs, ...facts.cwd ? { workspace: facts.cwd } : {} });
511
+ }
512
+ }
513
+ await saveDiscoveryCache();
514
+ return matches.sort((left, right) => right.updatedAtMs - left.updatedAtMs).slice(0, CODEX_DISCOVERY_LIMIT);
515
+ }
516
+ async function locateCodexRollout(root, nativeId) {
517
+ const remembered = codexPathById.get(`${root}\0${nativeId}`);
518
+ if (remembered && await stat4(remembered).then(() => true, () => false)) return remembered;
519
+ const cache = await loadDiscoveryCache();
520
+ for (const [dir, listing] of Object.entries(cache.directories)) {
521
+ if (!dir.startsWith(root)) continue;
522
+ for (const [name, facts] of Object.entries(listing.files)) {
523
+ if (facts.id !== nativeId && !name.endsWith(`${nativeId}.jsonl`)) continue;
524
+ const path = join4(dir, name);
525
+ if (await stat4(path).then(() => true, () => false)) return path;
526
+ }
527
+ }
528
+ for await (const dir of codexDayDirectories(root)) {
529
+ let names;
530
+ try {
531
+ names = await readdir4(dir);
532
+ } catch {
533
+ continue;
534
+ }
535
+ const name = names.find((candidate) => candidate.endsWith(`${nativeId}.jsonl`));
536
+ if (name) {
537
+ codexPathById.set(`${root}\0${nativeId}`, join4(dir, name));
538
+ return join4(dir, name);
539
+ }
540
+ }
541
+ return void 0;
542
+ }
543
+ async function readCodexFsTranscript(nativeId, workspace, environment = {}) {
544
+ const root = join4(nativeDataRoot(environment, "CODEX_HOME", join4(homedir2(), ".codex")), "sessions");
545
+ const path = await locateCodexRollout(root, nativeId);
546
+ if (!path) return [];
547
+ let raw;
548
+ try {
549
+ raw = await readFile2(path, "utf8");
550
+ } catch {
551
+ return [];
552
+ }
553
+ const messages = [];
554
+ for (const line of raw.split("\n")) {
555
+ if (!line.trim()) continue;
556
+ let record;
557
+ try {
558
+ record = JSON.parse(line);
559
+ } catch {
560
+ continue;
561
+ }
562
+ if (record.type !== "response_item") continue;
563
+ const payload = record.payload;
564
+ const role = payload?.role;
565
+ if (role !== "user" && role !== "assistant") continue;
566
+ const extracted = extractMessageText(payload?.content);
567
+ const text = role === "user" ? visibleNativeUserText(extracted) : extracted;
568
+ if (!text) continue;
569
+ messages.push({ role, content: text });
570
+ }
571
+ void workspace;
572
+ return messages;
573
+ }
574
+
575
+ export {
576
+ reconcileNativeTranscript,
577
+ extractMessageText,
578
+ readFilePrefix,
579
+ readFileSuffix,
580
+ walkFilesRecursive,
581
+ newestFiles,
582
+ nativeDataRoot,
583
+ saveDiscoveryCache,
584
+ rememberListing,
585
+ claimListing,
586
+ freshListing,
587
+ lastSeenListing,
588
+ mayHoldClaudeRequest,
589
+ claudeTypedRequest,
590
+ claudeProjectDirectoryNames,
591
+ discoverClaudeFsSessions,
592
+ readClaudeFsTranscript,
593
+ readClaudeFsTranscriptForSync,
594
+ discoverCodexFsSessions,
595
+ locateCodexRollout,
596
+ readCodexFsTranscript
597
+ };
@@ -0,0 +1,46 @@
1
+ import { createRequire as __clikcodeCreateRequire } from 'node:module';
2
+ const require = __clikcodeCreateRequire(import.meta.url);
3
+ import {
4
+ SLOW_WAIT_MS
5
+ } from "./chunk-XKW5NDMR.js";
6
+
7
+ // src/harness/protocol/slow-wait-gate.ts
8
+ function slowWaitGate(show, hide) {
9
+ let shownAt;
10
+ let ending;
11
+ let markShown;
12
+ const shown = new Promise((resolve) => {
13
+ markShown = resolve;
14
+ });
15
+ const timer = setTimeout(() => {
16
+ if (ending) return;
17
+ shownAt = Date.now();
18
+ show();
19
+ markShown();
20
+ }, SLOW_WAIT_MS);
21
+ timer.unref?.();
22
+ return {
23
+ shown,
24
+ end: () => ending ??= (async () => {
25
+ clearTimeout(timer);
26
+ if (shownAt === void 0) return;
27
+ hide();
28
+ })()
29
+ };
30
+ }
31
+
32
+ // src/tui/slow-wait.ts
33
+ async function withSlowWait(band, label, work, onCancel) {
34
+ if (!band) return work();
35
+ const gate = slowWaitGate(() => band.startWaiting(label, onCancel), () => band.stopWaiting());
36
+ try {
37
+ return await work();
38
+ } finally {
39
+ await gate.end();
40
+ }
41
+ }
42
+
43
+ export {
44
+ slowWaitGate,
45
+ withSlowWait
46
+ };