@testmuai/kane-cli 0.8.23 → 0.10.0-rc.1

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 (645) hide show
  1. package/dist/ChatSurface-VPD5G67Q.js +2 -0
  2. package/dist/ChromeProfilePicker-CRKQEFYD.js +2 -0
  3. package/dist/CliFeedbackPrompt-M7BMWLKK.js +2 -0
  4. package/dist/CliUploadProgress-OP7DXMC2.js +2 -0
  5. package/dist/ConfigView-XI74BCCH.js +2 -0
  6. package/dist/EvidenceViewOffer-HAAK6DS5.js +2 -0
  7. package/dist/FolderPicker-W5S6RFCP.js +2 -0
  8. package/dist/InfoBox-OWUEHV2D.js +2 -0
  9. package/dist/LinksBox-PNSESNCU.js +2 -0
  10. package/dist/ProfilesView-PYDZZHKO.js +2 -0
  11. package/dist/ProjectPicker-BGFCUGT5.js +2 -0
  12. package/dist/SaveSessionPrompt-SUJE54GS.js +2 -0
  13. package/dist/ScrollbackTap-4SPXGFMU.js +2 -0
  14. package/dist/SingleShotApp-4TDXZEUA.js +2 -0
  15. package/dist/SummaryBox-FALOODAQ.js +2 -0
  16. package/dist/TestMdRunView-4GPRWHEU.js +2 -0
  17. package/dist/TestrunEvidenceTable-OBVQJ6IO.js +2 -0
  18. package/dist/WhoamiView-6WXGRANY.js +2 -0
  19. package/dist/{agent-parse-2MLJOJTH.js → agent-parse-CAS45UKA.js} +1 -1
  20. package/dist/app-client-U2YYF65L.js +2 -0
  21. package/dist/app-download-RXVZB6MM.js +2 -0
  22. package/dist/assurance-job-C3TXZGLL.js +7 -0
  23. package/dist/auth-7Z54TMQQ.js +2 -0
  24. package/dist/{binary-MOJTQGUV.js → binary-DJCDMGPX.js} +1 -1
  25. package/dist/bind-XVO4CQYV.js +2 -0
  26. package/dist/bootstrap-TY5RANJ7.js +2 -0
  27. package/dist/bridge-T6QMYKED.js +2 -0
  28. package/dist/build-5ZN47FAT.js +2 -0
  29. package/dist/catalog-RRQF4TCA.js +2 -0
  30. package/dist/{changelog-2N6HKKKQ.js → changelog-GBEVIUFJ.js} +1 -1
  31. package/dist/chat-committer-ZCSRJEUB.js +2 -0
  32. package/dist/chat-controller-XINCDH6Z.js +2 -0
  33. package/dist/child-G2GCW73X.js +2 -0
  34. package/dist/chunk-22PIMG52.js +2 -0
  35. package/dist/chunk-252FWF2G.js +19 -0
  36. package/dist/{chunk-AT3RME5W.js → chunk-2IZRPMZN.js} +1 -1
  37. package/dist/chunk-2NFS4KE4.js +2 -0
  38. package/dist/{chunk-LHUW5QDT.js → chunk-2OOFURWD.js} +1 -1
  39. package/dist/chunk-2OSFI33O.js +97 -0
  40. package/dist/chunk-2S3W2JT3.js +5 -0
  41. package/dist/chunk-2SWSVJUP.js +12 -0
  42. package/dist/chunk-2TVPA3LL.js +2 -0
  43. package/dist/chunk-2XW33VOK.js +2 -0
  44. package/dist/chunk-33DWJV67.js +235 -0
  45. package/dist/chunk-34R7BNZ2.js +2 -0
  46. package/dist/chunk-35ECWCCK.js +2 -0
  47. package/dist/chunk-3BSYOCSW.js +3 -0
  48. package/dist/chunk-3G2LSTK5.js +2 -0
  49. package/dist/chunk-3GXN6VF6.js +2 -0
  50. package/dist/chunk-3JLEDSG5.js +4 -0
  51. package/dist/chunk-3QICDXY5.js +5 -0
  52. package/dist/chunk-3UVSAAES.js +10 -0
  53. package/dist/chunk-42PALMW2.js +4 -0
  54. package/dist/chunk-432ZOE42.js +21 -0
  55. package/dist/chunk-44B6THYK.js +2 -0
  56. package/dist/chunk-47WQBG5I.js +6 -0
  57. package/dist/{chunk-J2FJ62K4.js → chunk-4D5PC6QE.js} +1 -1
  58. package/dist/chunk-4I7YN6YY.js +3 -0
  59. package/dist/chunk-4IEQNX7F.js +2 -0
  60. package/dist/{chunk-SYJXTB4J.js → chunk-4LPX2OLV.js} +1 -1
  61. package/dist/chunk-4LTHDJ3D.js +2 -0
  62. package/dist/chunk-4QTH7VYE.js +2 -0
  63. package/dist/chunk-54XA5MZH.js +2 -0
  64. package/dist/chunk-57MDWTON.js +2 -0
  65. package/dist/{chunk-3C32LVLX.js → chunk-5BUIIFLC.js} +1 -1
  66. package/dist/chunk-5D7ENQTQ.js +2 -0
  67. package/dist/chunk-63EKRZKI.js +2 -0
  68. package/dist/{chunk-EHN5HTUD.js → chunk-65VANXOF.js} +51 -51
  69. package/dist/chunk-672CQECV.js +47 -0
  70. package/dist/chunk-6LIC2R22.js +3 -0
  71. package/dist/chunk-6NFOH4AC.js +4 -0
  72. package/dist/chunk-6NWT2TEJ.js +2 -0
  73. package/dist/chunk-6PIIUAZF.js +3 -0
  74. package/dist/{chunk-MBJHS653.js → chunk-6U7ID777.js} +1 -1
  75. package/dist/chunk-6UVIY56J.js +2 -0
  76. package/dist/chunk-72KYMWQ5.js +2 -0
  77. package/dist/chunk-72RC7JSA.js +21 -0
  78. package/dist/chunk-74W4AOT2.js +2 -0
  79. package/dist/chunk-77ZZQJLX.js +2 -0
  80. package/dist/chunk-7DFBOVUB.js +2 -0
  81. package/dist/chunk-7EXDYXXD.js +2 -0
  82. package/dist/chunk-7HO4NX5W.js +1 -0
  83. package/dist/chunk-7KX2BHKG.js +2 -0
  84. package/dist/chunk-7LKCWO2R.js +11 -0
  85. package/dist/{chunk-ULGZPRKU.js → chunk-7NCJMWFX.js} +1 -1
  86. package/dist/chunk-7RPKHKA3.js +2 -0
  87. package/dist/chunk-7RWP4Y3H.js +2 -0
  88. package/dist/chunk-7V4BQSSV.js +2 -0
  89. package/dist/chunk-7XBNMOH4.js +6 -0
  90. package/dist/chunk-A6TJOZ24.js +2 -0
  91. package/dist/chunk-A7RJQJNT.js +2 -0
  92. package/dist/chunk-AA674WLL.js +2 -0
  93. package/dist/chunk-AIXJYMSP.js +9 -0
  94. package/dist/chunk-AJQZ3ST5.js +8 -0
  95. package/dist/chunk-AQ2OG2EF.js +2 -0
  96. package/dist/chunk-AUJSC7PU.js +4 -0
  97. package/dist/chunk-AVI5H4UM.js +13 -0
  98. package/dist/chunk-AZLNLHUA.js +4 -0
  99. package/dist/chunk-B2HXPGIZ.js +26 -0
  100. package/dist/chunk-B7ZX5HEN.js +8 -0
  101. package/dist/{chunk-XQQHSC7G.js → chunk-BJJUKB5K.js} +1 -1
  102. package/dist/{chunk-66MOZKD2.js → chunk-BSRSXYDZ.js} +1 -1
  103. package/dist/{chunk-TONFENRW.js → chunk-BVO4C5F2.js} +1 -1
  104. package/dist/chunk-BWXLZS5O.js +2 -0
  105. package/dist/chunk-BY65QAAN.js +4 -0
  106. package/dist/chunk-BZVNI44O.js +6 -0
  107. package/dist/chunk-C5Z7MQE6.js +2 -0
  108. package/dist/chunk-C6HI6Y3S.js +2 -0
  109. package/dist/chunk-CB4ARIHR.js +2 -0
  110. package/dist/chunk-CPBBYNL7.js +4 -0
  111. package/dist/{chunk-GFNCGN5V.js → chunk-D4FFXCX6.js} +2 -2
  112. package/dist/chunk-D756UWY2.js +6 -0
  113. package/dist/chunk-DBMW3VUN.js +4 -0
  114. package/dist/chunk-DD5TULWQ.js +34 -0
  115. package/dist/{chunk-SY4T44VC.js → chunk-DDJNYQBH.js} +1 -1
  116. package/dist/{chunk-KJIDMW6N.js → chunk-DHQ4SQWA.js} +1 -1
  117. package/dist/chunk-DNGOT65K.js +3 -0
  118. package/dist/chunk-DPGOAFKF.js +2 -0
  119. package/dist/chunk-DREQ3RAA.js +2 -0
  120. package/dist/chunk-DTUPEKEO.js +2 -0
  121. package/dist/chunk-E6KSRQXL.js +8 -0
  122. package/dist/chunk-EF47KRUK.js +2 -0
  123. package/dist/chunk-ENL4XTQ2.js +2 -0
  124. package/dist/chunk-EXFDIVNI.js +9 -0
  125. package/dist/chunk-EZN7CF45.js +4 -0
  126. package/dist/chunk-F3U6T4YD.js +22 -0
  127. package/dist/{chunk-DHJSM5DT.js → chunk-FCD3NYOM.js} +1 -1
  128. package/dist/chunk-FFL55I2M.js +2 -0
  129. package/dist/chunk-FIP5L6LV.js +9 -0
  130. package/dist/chunk-FOJHSG5M.js +6 -0
  131. package/dist/chunk-FSYOTRMC.js +2 -0
  132. package/dist/chunk-GFLB2SHW.js +2 -0
  133. package/dist/chunk-GMTHZUZ3.js +2 -0
  134. package/dist/chunk-GRURFGBP.js +2 -0
  135. package/dist/chunk-GZFLJORM.js +2 -0
  136. package/dist/{chunk-PXHN7SFG.js → chunk-H3HHSTEK.js} +4 -4
  137. package/dist/chunk-HAW5WEKT.js +13 -0
  138. package/dist/chunk-HFJSP4KD.js +2 -0
  139. package/dist/chunk-HHW6MRU3.js +6 -0
  140. package/dist/chunk-HIUAUZNL.js +2 -0
  141. package/dist/chunk-HJLMH7ZM.js +2 -0
  142. package/dist/{chunk-5GUD3CIH.js → chunk-HQ2E2XCU.js} +1 -1
  143. package/dist/chunk-I2KOGINW.js +7 -0
  144. package/dist/chunk-I2MC6VVX.js +2 -0
  145. package/dist/chunk-I5NSJBOZ.js +2 -0
  146. package/dist/chunk-I6OQISK4.js +2 -0
  147. package/dist/chunk-IBBD36FQ.js +2 -0
  148. package/dist/chunk-IINZZ4BZ.js +2 -0
  149. package/dist/{chunk-UYI4WPNQ.js → chunk-IMDMRJQ6.js} +2 -2
  150. package/dist/chunk-IXW7FOGX.js +2 -0
  151. package/dist/chunk-IZ65ZPWY.js +3 -0
  152. package/dist/chunk-JD52IXON.js +9 -0
  153. package/dist/chunk-JGRXMTME.js +15 -0
  154. package/dist/{chunk-NBXYL2JT.js → chunk-JIRNI5TB.js} +7 -7
  155. package/dist/chunk-JNSWKGTB.js +2 -0
  156. package/dist/chunk-JPYW6U4D.js +2 -0
  157. package/dist/chunk-JQSLUGD4.js +3 -0
  158. package/dist/chunk-K45BKGB5.js +8 -0
  159. package/dist/chunk-KF4DKXSS.js +2 -0
  160. package/dist/chunk-KGNE5CIM.js +2 -0
  161. package/dist/chunk-KM3YCIDV.js +3 -0
  162. package/dist/chunk-KU3YHPWZ.js +2 -0
  163. package/dist/chunk-L4UVUFL6.js +3 -0
  164. package/dist/chunk-LCSJ7GOG.js +2 -0
  165. package/dist/chunk-LKQFG4RW.js +5 -0
  166. package/dist/chunk-LNNWCBPQ.js +2 -0
  167. package/dist/chunk-LRS5MGBY.js +3 -0
  168. package/dist/chunk-LRXBJTD4.js +4 -0
  169. package/dist/chunk-LSDJOVWW.js +6 -0
  170. package/dist/chunk-LWJRSUE2.js +2 -0
  171. package/dist/chunk-LX2I4JEH.js +2 -0
  172. package/dist/{chunk-K6VDRR3H.js → chunk-M6MBMRFR.js} +1 -1
  173. package/dist/chunk-MGNRNLBE.js +2 -0
  174. package/dist/chunk-MII3JOO3.js +4 -0
  175. package/dist/chunk-MNBGG4H3.js +16 -0
  176. package/dist/chunk-MYVKUJGS.js +2 -0
  177. package/dist/chunk-MYZHOBS4.js +2 -0
  178. package/dist/chunk-MZOIHUVX.js +27 -0
  179. package/dist/{chunk-OFRYEWZE.js → chunk-N3TCNZSX.js} +1 -1
  180. package/dist/chunk-NC7D7GOM.js +21 -0
  181. package/dist/{chunk-CLQP3DHT.js → chunk-NDEI7R4K.js} +1 -1
  182. package/dist/chunk-NFRA64NU.js +10 -0
  183. package/dist/chunk-NLZZLANH.js +4 -0
  184. package/dist/{chunk-5HOHXV2K.js → chunk-NQTYWHPB.js} +1 -1
  185. package/dist/chunk-NWBLYMH7.js +3 -0
  186. package/dist/chunk-NWD54VV5.js +2 -0
  187. package/dist/chunk-NXRF7FFS.js +2 -0
  188. package/dist/chunk-O3HHTKZ5.js +6 -0
  189. package/dist/{chunk-FPFS6OSR.js → chunk-OAKYUBD3.js} +1 -1
  190. package/dist/chunk-OEWYXCTA.js +7 -0
  191. package/dist/{chunk-BASTDR3M.js → chunk-OF7WPCTQ.js} +1 -1
  192. package/dist/chunk-OFSDB7B4.js +3 -0
  193. package/dist/chunk-OJ33Q6DU.js +2 -0
  194. package/dist/chunk-OQ5G773E.js +2 -0
  195. package/dist/chunk-OVNRRI4E.js +2 -0
  196. package/dist/{chunk-RAARDC2O.js → chunk-OZNBTSW5.js} +1 -1
  197. package/dist/chunk-P2ZQDQDB.js +2 -0
  198. package/dist/chunk-P7MSVLAH.js +6 -0
  199. package/dist/chunk-PUVMC4PX.js +26 -0
  200. package/dist/{chunk-SEEEGDVK.js → chunk-PZA3BSOE.js} +1 -1
  201. package/dist/chunk-Q3C6NDGI.js +2 -0
  202. package/dist/chunk-QCKA665H.js +2 -0
  203. package/dist/chunk-QDFY5GGO.js +5 -0
  204. package/dist/chunk-QHRUBG7J.js +2 -0
  205. package/dist/chunk-QI5RZ7LL.js +2 -0
  206. package/dist/chunk-QNLVC5ZB.js +2 -0
  207. package/dist/{chunk-DSKJ6J7Y.js → chunk-QQ4TKLWP.js} +1 -1
  208. package/dist/chunk-QS5ZJFGF.js +4 -0
  209. package/dist/chunk-QTZBVDPR.js +12 -0
  210. package/dist/chunk-QXQ7KVEN.js +2 -0
  211. package/dist/chunk-R4JUKTDO.js +2 -0
  212. package/dist/chunk-R7KXAISS.js +12 -0
  213. package/dist/chunk-RDP7GWSY.js +2 -0
  214. package/dist/chunk-REKHAN53.js +5 -0
  215. package/dist/{chunk-5RHR4DMF.js → chunk-RFEON5GN.js} +1 -1
  216. package/dist/chunk-RFIIM33J.js +2 -0
  217. package/dist/chunk-RG372DON.js +6 -0
  218. package/dist/chunk-RPRXRKKR.js +2 -0
  219. package/dist/chunk-RTVWQK7I.js +2 -0
  220. package/dist/chunk-RW3Z2HMB.js +7 -0
  221. package/dist/chunk-RX47NRSM.js +2 -0
  222. package/dist/chunk-RX6776AI.js +5 -0
  223. package/dist/chunk-S53AQU7R.js +6 -0
  224. package/dist/{chunk-HJX5PQRD.js → chunk-SA6IKFFD.js} +1 -1
  225. package/dist/{chunk-2MEQTHNI.js → chunk-SLKYD44Y.js} +1 -1
  226. package/dist/chunk-SMTBOSEJ.js +2 -0
  227. package/dist/chunk-SMXABALN.js +2 -0
  228. package/dist/chunk-SONMD3W5.js +5 -0
  229. package/dist/chunk-SWMTXMKB.js +2 -0
  230. package/dist/chunk-SXRHKXSE.js +2 -0
  231. package/dist/chunk-T3HEJASG.js +5 -0
  232. package/dist/chunk-T4AVLJCW.js +6 -0
  233. package/dist/{chunk-J6TBTWW7.js → chunk-T6K2MEWP.js} +1 -1
  234. package/dist/{chunk-D6BULK7E.js → chunk-T7H4LBFK.js} +1 -1
  235. package/dist/chunk-TNORODUF.js +2 -0
  236. package/dist/chunk-TW63WWEN.js +2 -0
  237. package/dist/chunk-UALJTPSA.js +18 -0
  238. package/dist/chunk-UAWWLLTI.js +2 -0
  239. package/dist/chunk-UEE3RZN4.js +14 -0
  240. package/dist/chunk-UTM7D4PI.js +2 -0
  241. package/dist/chunk-UUJIGOEO.js +2 -0
  242. package/dist/chunk-UYDHOHSZ.js +2 -0
  243. package/dist/chunk-V5JGXOV7.js +2 -0
  244. package/dist/chunk-V7S6S5W3.js +2 -0
  245. package/dist/{chunk-HBSYBL6J.js → chunk-VG44B5JD.js} +1 -1
  246. package/dist/chunk-VJGWVBZR.js +1 -0
  247. package/dist/chunk-VLDCHFXF.js +2 -0
  248. package/dist/chunk-VO66KP2W.js +2 -0
  249. package/dist/{chunk-D4XR7EEQ.js → chunk-VQLH63X7.js} +14 -12
  250. package/dist/chunk-VRIZDOO5.js +2 -0
  251. package/dist/chunk-VYHT2IET.js +1397 -0
  252. package/dist/chunk-VZJ6LUXX.js +2 -0
  253. package/dist/chunk-W3OVSDBN.js +29 -0
  254. package/dist/chunk-W7FLXW6Q.js +5 -0
  255. package/dist/{chunk-IEW7AW64.js → chunk-WEM3MOAL.js} +1 -1
  256. package/dist/chunk-WI7K6VKQ.js +2 -0
  257. package/dist/chunk-WMGKUERB.js +6 -0
  258. package/dist/{chunk-DFS4RMVP.js → chunk-WN5VKKJ3.js} +1 -1
  259. package/dist/chunk-WOSANGV6.js +5 -0
  260. package/dist/chunk-WYSZ6TPW.js +15 -0
  261. package/dist/chunk-XB6BJPDL.js +2 -0
  262. package/dist/{chunk-5ESGUPSR.js → chunk-XBEYWXPV.js} +1 -1
  263. package/dist/chunk-XIPKSXRQ.js +16 -0
  264. package/dist/chunk-XJ7HCXKW.js +2 -0
  265. package/dist/chunk-XMPTFXPW.js +5 -0
  266. package/dist/chunk-XZYA7DNH.js +2 -0
  267. package/dist/chunk-Y4T4SLDO.js +2 -0
  268. package/dist/chunk-Y6Y6RAY4.js +2 -0
  269. package/dist/chunk-YDPTSDIJ.js +2 -0
  270. package/dist/chunk-YDSGXB25.js +2 -0
  271. package/dist/chunk-YIKF4ERQ.js +375 -0
  272. package/dist/chunk-Z55KBMYV.js +2 -0
  273. package/dist/chunk-ZCRZFAOT.js +2 -0
  274. package/dist/chunk-ZFM77AQU.js +2 -0
  275. package/dist/{chunk-Q6F23V7L.js → chunk-ZFMRQ57Y.js} +1 -1
  276. package/dist/chunk-ZHWU6L2G.js +5 -0
  277. package/dist/chunk-ZTHYAHDN.js +17 -0
  278. package/dist/chunk-ZZP5SHUV.js +3 -0
  279. package/dist/committer-JGY66PFM.js +2 -0
  280. package/dist/config-5ZOALGKE.js +2 -0
  281. package/dist/controller-client-PB3AZAGG.js +2 -0
  282. package/dist/cover-cmd-UA2SVIZZ.js +2 -0
  283. package/dist/{credentials-PSQWWFGD.js → credentials-MRG452Y6.js} +1 -1
  284. package/dist/{deps-bundle-PPOQHJTB.js → deps-bundle-FWINW4XM.js} +1 -1
  285. package/dist/{deps-resolve-AX6ZAKLH.js → deps-resolve-IET4KIBO.js} +1 -1
  286. package/dist/descriptor-7T32VRMB.js +2 -0
  287. package/dist/design-chat-MM5PJD2N.js +2 -0
  288. package/dist/design-committer-TRYP3LOZ.js +2 -0
  289. package/dist/design-headless-FZONCKHW.js +2 -0
  290. package/dist/design-remote-SPVRIY2H.js +3 -0
  291. package/dist/device-env-LXJ65AVF.js +2 -0
  292. package/dist/dispatch-DVQ3H7EJ.js +2 -0
  293. package/dist/doctor-VAX2BWQF.js +2 -0
  294. package/dist/docx-convert-6IZO5P5K.js +2 -0
  295. package/dist/{dossier-7HVC6BNK.js → dossier-NROC2MCY.js} +1 -1
  296. package/dist/evidence-LVVK7ROT.js +2 -0
  297. package/dist/evidence-presentation-YYTIDCBS.js +2 -0
  298. package/dist/evolve-cmd-AGRKG7T3.js +2 -0
  299. package/dist/evolve-remote-BGHULJTL.js +2 -0
  300. package/dist/{exit-manager-ZLDO54S4.js → exit-manager-EDHCETUN.js} +1 -1
  301. package/dist/explain-DGJ5T6V5.js +2 -0
  302. package/dist/explain-cmd-VYAANFFZ.js +4 -0
  303. package/dist/explain-cmd-WOBGS6KX.js +12 -0
  304. package/dist/explore-LOKNOVNP.js +2 -0
  305. package/dist/explore-context-tty-JTZVZFOE.js +2 -0
  306. package/dist/explore-entry-5OGNLFAU.js +6 -0
  307. package/dist/explore-live-2XZHUYFS.js +5 -0
  308. package/dist/explore-run-tty-LGTIK2NA.js +5 -0
  309. package/dist/extract-bind-NM2BBK4I.js +14 -0
  310. package/dist/extract-chat-HLQMJJIC.js +2 -0
  311. package/dist/extract-cmd-T2TSAC3N.js +6 -0
  312. package/dist/extract-headless-OQTQ3FJK.js +2 -0
  313. package/dist/feeder-NY45UFJK.js +2 -0
  314. package/dist/folder-flags-WXUR6OPJ.js +2 -0
  315. package/dist/gaps-cmd-PTSKPTF7.js +3 -0
  316. package/dist/gate-P57VP4E5.js +2 -0
  317. package/dist/gate-WISOUTHQ.js +2 -0
  318. package/dist/{generate-headless-TEDHS3F2.js → generate-headless-JYZP6VXZ.js} +3 -3
  319. package/dist/headless-io-FFM5T6KL.js +2 -0
  320. package/dist/hold-passthrough-IOWPVB4W.js +2 -0
  321. package/dist/identity-HL5CJJXR.js +2 -0
  322. package/dist/index.js +194 -175
  323. package/dist/ingest-PDGS5ZTL.js +2 -0
  324. package/dist/ingest-cmd-LHCBMO4Z.js +8 -0
  325. package/dist/ingest-remote-D5TO5JQP.js +2 -0
  326. package/dist/ink-screen-RZ7QDIUI.js +2 -0
  327. package/dist/install-Z6K2D2VY.js +2 -0
  328. package/dist/interactive-bind-5EJQUGKI.js +26 -0
  329. package/dist/interactive-remote-D77ULJGL.js +65 -0
  330. package/dist/interrupt-guard-QETBPINI.js +2 -0
  331. package/dist/lane-AQYRIW24.js +2 -0
  332. package/dist/lattice-auth-74XGF77Y.js +2 -0
  333. package/dist/lifecycle-cmd-7SM6UCMH.js +2 -0
  334. package/dist/list-cmd-Z6FZXMFU.js +3 -0
  335. package/dist/list-commands-CZYZ7GIG.js +2 -0
  336. package/dist/list-remote-WOPOC6KK.js +15 -0
  337. package/dist/locks-cmd-JJ2QNTNY.js +2 -0
  338. package/dist/logical-ids-RXAQJZ3T.js +2 -0
  339. package/dist/login-flow-2FZEOVHM.js +2 -0
  340. package/dist/maintenance-cmd-VRTGZVRE.js +2 -0
  341. package/dist/mobile-prompts-KNAHU64X.js +2 -0
  342. package/dist/{next-KZXH4UA4.js → next-O6SUSX3R.js} +1 -1
  343. package/dist/{objective-variable-gate-JALOH6SL.js → objective-variable-gate-3Z7DNVVC.js} +1 -1
  344. package/dist/onboarding-LGT6PMDZ.js +5 -0
  345. package/dist/open-provider-OZAG6WZS.js +2 -0
  346. package/dist/{paths-JCYX6UWL.js → paths-UMIX3RJF.js} +1 -1
  347. package/dist/pdf-convert-447ACUB3.js +2 -0
  348. package/dist/persist-recorded-session-BX7II5P7.js +3 -0
  349. package/dist/phase-seed-LCJ4WSYV.js +2 -0
  350. package/dist/pipeline-IXVTVRS5.js +2 -0
  351. package/dist/prepare-target-ULMKVKMC.js +2 -0
  352. package/dist/pull-cmd-6AL2WYHB.js +2 -0
  353. package/dist/pull-route-TTVARJMV.js +2 -0
  354. package/dist/readmodel-INMP6MNW.js +2 -0
  355. package/dist/real-device-run-2LFS5WE2.js +2 -0
  356. package/dist/reconcile-cmd-R6H37SQR.js +5 -0
  357. package/dist/reconcile-deps-TWJ3FTSU.js +2 -0
  358. package/dist/reconcile-remote-GWDV5CUT.js +13 -0
  359. package/dist/recording-banner-ACC67Q2U.js +2 -0
  360. package/dist/registry-6IJYQXQC.js +2 -0
  361. package/dist/remote-entry-YL7O2NJQ.js +2 -0
  362. package/dist/remote-mode-7G6PLJCW.js +4 -0
  363. package/dist/remote-words-45USLRVN.js +2 -0
  364. package/dist/require-project-folder-A3UDRELU.js +2 -0
  365. package/dist/resolve-run-intent-ZGPSUBXV.js +2 -0
  366. package/dist/resolver-IPM6R7U4.js +2 -0
  367. package/dist/revert-FHOBLZWF.js +2 -0
  368. package/dist/review-cmd-NNT5C5RZ.js +5 -0
  369. package/dist/run-5RQUCNYP.js +2 -0
  370. package/dist/run-PC5YO4AS.js +2 -0
  371. package/dist/run-channel-63SVP5OI.js +2 -0
  372. package/dist/run-remote-3AYYVPKX.js +2 -0
  373. package/dist/run-startup-gate-NKRMKYBB.js +2 -0
  374. package/dist/run-test-md-HE6DUWQR.js +17 -0
  375. package/dist/scrollback-GGNBDFQV.js +2 -0
  376. package/dist/session-target-DD53UXO7.js +2 -0
  377. package/dist/session-worker.js +12 -0
  378. package/dist/sessions-CFV7FOIT.js +2 -0
  379. package/dist/sessions-cmd-GYMETJHG.js +26 -0
  380. package/dist/sessions-remote-GI7GOBMH.js +3 -0
  381. package/dist/shell-arg-FN3MT5U7.js +2 -0
  382. package/dist/{skill-installer-T2IOCPET.js → skill-installer-3QAVQGDH.js} +1 -1
  383. package/dist/spawner-C7NLLM4F.js +2 -0
  384. package/dist/store-X6XPFSKF.js +2 -0
  385. package/dist/store-choice-RT73HAI7.js +2 -0
  386. package/dist/store-guard-SNWKLHQV.js +2 -0
  387. package/dist/store-id-YZ5WKJ25.js +2 -0
  388. package/dist/store-site-KA2DNBGY.js +2 -0
  389. package/dist/stream-warnings-GEQKKJU7.js +2 -0
  390. package/dist/structured-answers-EQ2AP3F7.js +2 -0
  391. package/dist/sync-cmd-NBPPDG3B.js +2 -0
  392. package/dist/sync-setup-5NUCH6N3.js +2 -0
  393. package/dist/{sync-setup-ui-RC727VK6.js → sync-setup-ui-XITPGSO4.js} +2 -2
  394. package/dist/tcg-generate-Z23CUISY.js +2 -0
  395. package/dist/test-definition-VRI4YIYL.js +2 -0
  396. package/dist/testmd-actions-GH5BW5V5.js +2 -0
  397. package/dist/testmd-sync-ACKCIOL3.js +2 -0
  398. package/dist/tms-client-NXAB6VJD.js +2 -0
  399. package/dist/token-refresh-4UCYAG6A.js +2 -0
  400. package/dist/trust-gate-AT2XBWN4.js +2 -0
  401. package/dist/turn-preflight-LHYLRL7G.js +2 -0
  402. package/dist/ui-SNV3FD2G.js +4 -0
  403. package/dist/use-case-ref-NE4X4MZN.js +2 -0
  404. package/dist/validate-basic-RE2WLIGQ.js +2 -0
  405. package/dist/{variable-receipt-F55CSW5Z.js → variable-receipt-BXSZO36E.js} +1 -1
  406. package/dist/verdicts-XK3GAUX3.js +2 -0
  407. package/dist/version-check-4FJVZP3K.js +2 -0
  408. package/dist/{view-cmd-ELDKYRMZ.js → view-cmd-N47BQZPD.js} +4 -3
  409. package/dist/walk-session-DA7QWXSW.js +2 -0
  410. package/dist/with-telemetry-7V4LY2BG.js +2 -0
  411. package/package.json +11 -11
  412. package/dist/ChatSurface-GBZX4LWL.js +0 -8
  413. package/dist/ChromeProfilePicker-UONX2UVC.js +0 -2
  414. package/dist/CliFeedbackPrompt-6BJCNRNG.js +0 -2
  415. package/dist/CliUploadProgress-K4Z22DSY.js +0 -2
  416. package/dist/ConfigView-BB22G7JO.js +0 -2
  417. package/dist/EvidenceViewOffer-25IQF3TX.js +0 -2
  418. package/dist/FolderPicker-65JFR2NW.js +0 -2
  419. package/dist/InfoBox-OU5PLRIL.js +0 -2
  420. package/dist/LinksBox-DH7TSUXW.js +0 -2
  421. package/dist/ProfilesView-MGJKBOF5.js +0 -2
  422. package/dist/ProjectPicker-YFV6K77F.js +0 -2
  423. package/dist/SaveSessionPrompt-64QKQB6B.js +0 -2
  424. package/dist/ScrollbackTap-QHJOFYMC.js +0 -2
  425. package/dist/SingleShotApp-VYKUCRVW.js +0 -2
  426. package/dist/SummaryBox-DGS3LVRF.js +0 -2
  427. package/dist/TestMdRunView-LKAITAA4.js +0 -2
  428. package/dist/TestrunEvidenceTable-PHBAB4XQ.js +0 -2
  429. package/dist/WhoamiView-6HWPYN6Y.js +0 -2
  430. package/dist/app-client-ZCCNE3RV.js +0 -2
  431. package/dist/app-download-SQ2LYYL7.js +0 -2
  432. package/dist/auth-NWBIFCB7.js +0 -2
  433. package/dist/bind-S3IQTPNN.js +0 -15
  434. package/dist/bootstrap-RCV7PNMQ.js +0 -2
  435. package/dist/bridge-O7ENTV4K.js +0 -2
  436. package/dist/build-JIKYOZUH.js +0 -2
  437. package/dist/chat-committer-6D7AQI6Z.js +0 -2
  438. package/dist/chat-controller-UJQ6Z4RE.js +0 -2
  439. package/dist/chunk-2A7OQRAD.js +0 -17
  440. package/dist/chunk-2FH4HJYB.js +0 -5
  441. package/dist/chunk-2KVECC36.js +0 -2
  442. package/dist/chunk-2YEHV2CX.js +0 -2
  443. package/dist/chunk-3OKX64UR.js +0 -2
  444. package/dist/chunk-3UI5VTQS.js +0 -4
  445. package/dist/chunk-3UMVRJX3.js +0 -6
  446. package/dist/chunk-3VAU3PNU.js +0 -2
  447. package/dist/chunk-5EOX4MEY.js +0 -2
  448. package/dist/chunk-5LJRZI7S.js +0 -6
  449. package/dist/chunk-5UHY3PTQ.js +0 -3
  450. package/dist/chunk-5ZFOKYFB.js +0 -5
  451. package/dist/chunk-63DYVWNX.js +0 -2
  452. package/dist/chunk-6YZ3VP3E.js +0 -2
  453. package/dist/chunk-7KRY26OF.js +0 -4
  454. package/dist/chunk-7N6OCHPC.js +0 -7
  455. package/dist/chunk-A2SQD2AY.js +0 -4
  456. package/dist/chunk-AACQE24F.js +0 -2
  457. package/dist/chunk-AGDPEZXT.js +0 -4
  458. package/dist/chunk-AIK7BAME.js +0 -8
  459. package/dist/chunk-ATYXPCM6.js +0 -6
  460. package/dist/chunk-AXTPNZPX.js +0 -2
  461. package/dist/chunk-BB2W35TW.js +0 -2
  462. package/dist/chunk-BKM2LWU2.js +0 -3
  463. package/dist/chunk-BL5QHONU.js +0 -2
  464. package/dist/chunk-C44QQJR4.js +0 -239
  465. package/dist/chunk-C7NWWGLT.js +0 -6
  466. package/dist/chunk-CAJZQQ3G.js +0 -3
  467. package/dist/chunk-CSVPZ33X.js +0 -2
  468. package/dist/chunk-CXF6AZWY.js +0 -2
  469. package/dist/chunk-D6E6KRVX.js +0 -2
  470. package/dist/chunk-D7WG7SRA.js +0 -2
  471. package/dist/chunk-DDHGEJJP.js +0 -2
  472. package/dist/chunk-DUYRCVI5.js +0 -2
  473. package/dist/chunk-DWHF5HUD.js +0 -2
  474. package/dist/chunk-EM3PU2YW.js +0 -2
  475. package/dist/chunk-EVFFDODK.js +0 -5
  476. package/dist/chunk-EYOCNMUM.js +0 -2
  477. package/dist/chunk-F2OBORCG.js +0 -2
  478. package/dist/chunk-FMBPUXWL.js +0 -8
  479. package/dist/chunk-FORNRNHU.js +0 -2
  480. package/dist/chunk-FQJOWUEN.js +0 -2
  481. package/dist/chunk-FQNQVC5O.js +0 -5
  482. package/dist/chunk-FY7TCYPK.js +0 -6
  483. package/dist/chunk-HJGVM6TS.js +0 -370
  484. package/dist/chunk-HPHETGRE.js +0 -2
  485. package/dist/chunk-I7TIGB7K.js +0 -2
  486. package/dist/chunk-IGHK2ENL.js +0 -2
  487. package/dist/chunk-IICT4VOU.js +0 -2
  488. package/dist/chunk-IIDBLJ5A.js +0 -18
  489. package/dist/chunk-JFZA4UON.js +0 -9
  490. package/dist/chunk-K2UJYY2U.js +0 -2
  491. package/dist/chunk-KBM3XHAM.js +0 -2
  492. package/dist/chunk-KDNNMU7Q.js +0 -4
  493. package/dist/chunk-KJQNAOOE.js +0 -6
  494. package/dist/chunk-LF42V6P6.js +0 -7
  495. package/dist/chunk-LNFU4JZ7.js +0 -2
  496. package/dist/chunk-LNSBC32V.js +0 -2
  497. package/dist/chunk-LSDWPG6C.js +0 -2
  498. package/dist/chunk-MKMJOMLX.js +0 -8
  499. package/dist/chunk-MKQ7ZRDW.js +0 -2
  500. package/dist/chunk-MSGW4JDG.js +0 -2
  501. package/dist/chunk-MV3Q335C.js +0 -7
  502. package/dist/chunk-MWIE6LOZ.js +0 -4
  503. package/dist/chunk-MZ7W4WLF.js +0 -4
  504. package/dist/chunk-NIFJJX6N.js +0 -12
  505. package/dist/chunk-NJ4BXZBX.js +0 -2
  506. package/dist/chunk-NLCCBXXV.js +0 -2
  507. package/dist/chunk-ODU2JSMA.js +0 -8
  508. package/dist/chunk-OYKRCDT4.js +0 -15
  509. package/dist/chunk-Q2F5QB2W.js +0 -2
  510. package/dist/chunk-Q4YYAN6E.js +0 -2
  511. package/dist/chunk-Q6AHSGOE.js +0 -5
  512. package/dist/chunk-QAG67DUT.js +0 -2
  513. package/dist/chunk-QGXVQIN5.js +0 -27
  514. package/dist/chunk-QQCEP3QP.js +0 -2
  515. package/dist/chunk-QU7P7B3W.js +0 -4
  516. package/dist/chunk-RAPV3BTA.js +0 -98
  517. package/dist/chunk-RD72POF2.js +0 -2
  518. package/dist/chunk-RDHWNSDP.js +0 -7
  519. package/dist/chunk-RGRFL7XG.js +0 -29
  520. package/dist/chunk-RKXHVP2Z.js +0 -2
  521. package/dist/chunk-RMVASIVL.js +0 -35
  522. package/dist/chunk-RRY5IXOB.js +0 -2
  523. package/dist/chunk-RSSOJ3L2.js +0 -21
  524. package/dist/chunk-SB2SKN34.js +0 -2
  525. package/dist/chunk-SFFDVF3J.js +0 -9
  526. package/dist/chunk-T2ONUKTL.js +0 -5
  527. package/dist/chunk-TAOHYWEO.js +0 -2
  528. package/dist/chunk-U6OTFMIT.js +0 -4
  529. package/dist/chunk-UD7KKHPW.js +0 -5
  530. package/dist/chunk-UF4MU2AZ.js +0 -22
  531. package/dist/chunk-UQSVO7TY.js +0 -9
  532. package/dist/chunk-URWWROLS.js +0 -9
  533. package/dist/chunk-V4B5QA3U.js +0 -4
  534. package/dist/chunk-VACHFCNC.js +0 -21
  535. package/dist/chunk-VAN7ECN6.js +0 -2
  536. package/dist/chunk-VIO7CCFW.js +0 -5
  537. package/dist/chunk-VOYMN2WQ.js +0 -5
  538. package/dist/chunk-VVOKM2VO.js +0 -2
  539. package/dist/chunk-W5TTF7GB.js +0 -6
  540. package/dist/chunk-WESMQEPO.js +0 -2
  541. package/dist/chunk-WICJY6KL.js +0 -6
  542. package/dist/chunk-WJR2FU7S.js +0 -16
  543. package/dist/chunk-WVHMPIDQ.js +0 -2
  544. package/dist/chunk-X4NUVVCJ.js +0 -26
  545. package/dist/chunk-XLSOQLVT.js +0 -2
  546. package/dist/chunk-YCCUBQY4.js +0 -2
  547. package/dist/chunk-YFQGOOF7.js +0 -2
  548. package/dist/chunk-YI3H2UIB.js +0 -2
  549. package/dist/chunk-YKTYVJBN.js +0 -3
  550. package/dist/chunk-YLQHY4A7.js +0 -2
  551. package/dist/chunk-ZIHG6EKH.js +0 -2
  552. package/dist/chunk-ZKSN2SJ7.js +0 -2
  553. package/dist/chunk-ZLWURCJ7.js +0 -2
  554. package/dist/committer-2QPBANRD.js +0 -2
  555. package/dist/config-7E4NS553.js +0 -2
  556. package/dist/controller-client-ZF5IXRUV.js +0 -2
  557. package/dist/cover-cmd-6KZX46S2.js +0 -3
  558. package/dist/descriptor-3JJUOHBM.js +0 -2
  559. package/dist/design-committer-D44GSUXY.js +0 -2
  560. package/dist/device-env-TZQDB5T3.js +0 -2
  561. package/dist/dispatch-KMWEDMKE.js +0 -2
  562. package/dist/doctor-XDF3MA4W.js +0 -2
  563. package/dist/docx-convert-SQRTF7XS.js +0 -2
  564. package/dist/evidence-EUIDOVOR.js +0 -2
  565. package/dist/evidence-presentation-XF23B7F2.js +0 -2
  566. package/dist/evolve-cmd-QVTGTCJ5.js +0 -2
  567. package/dist/explain-NEFBUX5G.js +0 -2
  568. package/dist/explain-cmd-36SVSHU7.js +0 -9
  569. package/dist/explain-cmd-JAOHSI4F.js +0 -3
  570. package/dist/extract-bind-PLMSZKLZ.js +0 -14
  571. package/dist/extract-cmd-RJBHPPF3.js +0 -5
  572. package/dist/feeder-66TUPB2R.js +0 -2
  573. package/dist/gaps-cmd-3WZPDDYS.js +0 -3
  574. package/dist/gate-OYRDJMF6.js +0 -2
  575. package/dist/headless-io-75HUMWZB.js +0 -2
  576. package/dist/identity-ADZ4PAJF.js +0 -2
  577. package/dist/ingest-OSNNM3DH.js +0 -2
  578. package/dist/ingest-cmd-JDIOPJBN.js +0 -2
  579. package/dist/install-Y3VKFBK3.js +0 -2
  580. package/dist/interactive-bind-XUMKEGAN.js +0 -26
  581. package/dist/interrupt-guard-UREUWNRL.js +0 -2
  582. package/dist/lifecycle-cmd-FBDRFIOE.js +0 -2
  583. package/dist/list-cmd-TFUACRAM.js +0 -3
  584. package/dist/list-commands-OHIQFJGQ.js +0 -2
  585. package/dist/locks-cmd-67OHQZNV.js +0 -2
  586. package/dist/logical-ids-GLVM2SVR.js +0 -2
  587. package/dist/login-flow-OHNKSVYZ.js +0 -2
  588. package/dist/maintenance-cmd-7OSUIDL4.js +0 -2
  589. package/dist/mobile-prompts-DEVUZRG3.js +0 -2
  590. package/dist/open-provider-746LLSEO.js +0 -2
  591. package/dist/pdf-convert-RLXSXFWN.js +0 -2
  592. package/dist/persist-recorded-session-GPP6UKN6.js +0 -3
  593. package/dist/phase-seed-MKHEWUN6.js +0 -2
  594. package/dist/pipeline-QPTPZVUJ.js +0 -2
  595. package/dist/prepare-target-N7QRNYOS.js +0 -2
  596. package/dist/readmodel-FVLRQWZ7.js +0 -2
  597. package/dist/reconcile-cmd-SMGLHMLF.js +0 -2
  598. package/dist/reconcile-deps-DVIJK5UZ.js +0 -4
  599. package/dist/reconcile-engine-KL2J5SNQ.js +0 -2
  600. package/dist/recording-banner-TCFFB6KE.js +0 -2
  601. package/dist/records-LMCVKPE5.js +0 -2
  602. package/dist/registry-BFFA4YJK.js +0 -2
  603. package/dist/require-project-folder-2224ZMJ5.js +0 -2
  604. package/dist/resolve-run-intent-HFXGEOYK.js +0 -2
  605. package/dist/resolver-GJR2Z7JY.js +0 -2
  606. package/dist/revert-NOUECRW4.js +0 -2
  607. package/dist/review-cmd-CQE6SBZA.js +0 -5
  608. package/dist/run-BXKWDJFJ.js +0 -2
  609. package/dist/run-HSP2MZPU.js +0 -2
  610. package/dist/run-channel-RGH4WIQX.js +0 -2
  611. package/dist/run-test-md-2ELPAASM.js +0 -17
  612. package/dist/scrollback-JLPJR25X.js +0 -2
  613. package/dist/session-items-2ATN7VXG.js +0 -2
  614. package/dist/session-target-UWROGOCY.js +0 -2
  615. package/dist/sessions-NH7WQWMX.js +0 -2
  616. package/dist/sessions-cmd-IV25N2L7.js +0 -25
  617. package/dist/spawner-HQM2757J.js +0 -2
  618. package/dist/store-guard-NAW26EEQ.js +0 -2
  619. package/dist/store-id-EOSGEKVK.js +0 -2
  620. package/dist/structured-answers-ZI2B6JJE.js +0 -2
  621. package/dist/sync-cmd-Q6ZYEVWI.js +0 -2
  622. package/dist/sync-setup-CA362C5S.js +0 -2
  623. package/dist/tcg-generate-CDB2N5LD.js +0 -2
  624. package/dist/testmd-actions-BDWDE2TG.js +0 -2
  625. package/dist/testmd-sync-EPTUVJYJ.js +0 -2
  626. package/dist/tms-client-KU6HCA23.js +0 -2
  627. package/dist/token-refresh-TKBOHXSD.js +0 -2
  628. package/dist/trust-gate-EX7R2P4Y.js +0 -2
  629. package/dist/turn-preflight-JGYT7LXP.js +0 -2
  630. package/dist/ui-JEJGTURD.js +0 -4
  631. package/dist/validate-basic-V7R4RH5M.js +0 -2
  632. package/dist/verdicts-7IUZFXB4.js +0 -2
  633. package/dist/version-check-PUUSB7AY.js +0 -2
  634. package/dist/walk-session-EGIMA4VG.js +0 -2
  635. package/dist/with-telemetry-LRWWBISP.js +0 -2
  636. /package/dist/{chunk-BKHXPBWN.js → chunk-2RUSXQ3O.js} +0 -0
  637. /package/dist/{chunk-6J5T5FEY.js → chunk-3AGP2BVN.js} +0 -0
  638. /package/dist/{chunk-CH273NAE.js → chunk-73Y6T2UK.js} +0 -0
  639. /package/dist/{chunk-ZMNJBUAO.js → chunk-73ZFOJOK.js} +0 -0
  640. /package/dist/{chunk-N2P4MI32.js → chunk-FWGUISUG.js} +0 -0
  641. /package/dist/{chunk-UJZZDPDY.js → chunk-HD6NR44L.js} +0 -0
  642. /package/dist/{chunk-LDPLJFCV.js → chunk-I6S6DZ2E.js} +0 -0
  643. /package/dist/{chunk-427OQS2N.js → chunk-LD5B3QFW.js} +0 -0
  644. /package/dist/{chunk-2UIHS2FH.js → chunk-PGESS7BW.js} +0 -0
  645. /package/dist/{chunk-BZAGVBCX.js → chunk-ZCIWQHCO.js} +0 -0
@@ -1,98 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as Ur,b as Vo,c as Ko,d as Kt,e as ut,f as Ho,g as Yo,h as Fr,i as $r,j as Br,k as Jo,l as Qo}from"./chunk-LF42V6P6.js";import{b as Mr,c as Vr}from"./chunk-5RHR4DMF.js";import{c as Xo,e as es,f as ts}from"./chunk-DWHF5HUD.js";import{T as ns}from"./chunk-RMVASIVL.js";import{c as rs}from"./chunk-T2ONUKTL.js";import{a as jo}from"./chunk-WD52ZNQY.js";import{a as $t,c as Bt,d as Cr}from"./chunk-ATYXPCM6.js";import{a as Nt,c as po,d as go,e as Ft}from"./chunk-MV3Q335C.js";import{a as mt,b as Go,c as Nr}from"./chunk-BHSHGWBL.js";import{c as qo}from"./chunk-S3DAAAE5.js";import{e as zo,g as Wo}from"./chunk-FMBPUXWL.js";import{c as Zo}from"./chunk-VOYMN2WQ.js";import{a as Tr}from"./chunk-W3USRQX6.js";import{A as Io,B as _o,C as So,E as Ar,F as Ro,H as Ao,Q as xo,R as Po,X as To,Y as Do,g as yo,i as Mt,v as vo,w as wo}from"./chunk-URWWROLS.js";import{c as Eo,d as Co}from"./chunk-WJR2FU7S.js";import{c as ho,e as bo}from"./chunk-YFQGOOF7.js";import{b as Er}from"./chunk-BL5QHONU.js";import{a as xr}from"./chunk-CH273NAE.js";import{b as He}from"./chunk-IIDBLJ5A.js";import{a as dt,b as oo,c as so,d as io,e as ao,f as lo,g as kr,i as co}from"./chunk-JQ64X2TO.js";import{d as Vt,e as Mo}from"./chunk-AGDPEZXT.js";import{a as ct,b as X,c as Lo,e as _e,f as Ge,g as Pr,k as Oo,m as No,n as Fo,o as Dr,p as Lr,q as he,r as Or,t as jr,v as Bo}from"./chunk-OYKRCDT4.js";import{c as $o}from"./chunk-YI3H2UIB.js";import{b as Uo}from"./chunk-NBXYL2JT.js";import{a as Sr}from"./chunk-ZLWURCJ7.js";import{a as Rr}from"./chunk-QSCXXNC2.js";import{a as fo}from"./chunk-2YEHV2CX.js";import{c as ko}from"./chunk-6YZ3VP3E.js";import{i as ro,m as no}from"./chunk-EM3PU2YW.js";import{g as uo,h as mo}from"./chunk-UYI4WPNQ.js";import{a as Ut}from"./chunk-2KVECC36.js";import{j as Zn,l as _r,m as Xn,n as jt,o as eo,p as to}from"./chunk-RSSOJ3L2.js";import{a as Jn}from"./chunk-Z7S3IWUX.js";import{d as Qn}from"./chunk-4JOD47QI.js";import{a as te}from"./chunk-DUYRCVI5.js";import{a as Te}from"./chunk-DHJSM5DT.js";import{a as Lt,b as Ot}from"./chunk-NLCCBXXV.js";import{a as Y}from"./chunk-RZ4F3BHX.js";import{a as Wn}from"./chunk-E47GFYXA.js";import{a as Tt,b as Dt,i as Yn,j as Ke,k as wr,l as Ir}from"./chunk-CXF6AZWY.js";import{join as ye,basename as Ze}from"path";import{existsSync as Wa,readFileSync as yi}from"fs";function os(e,t){if(process.env.KANE_REPLAY_TRACE==="1")for(let r=0;r<e.steps.length;r++){let n=e.steps[r],o=t[r],s=" ".repeat(n.trace.length-1),l=`step ${n.flatIndex}`;if(o.kind==="replay"){let p=o.replayOnly?` [replay-only @${o.replayOnly}]`:"";process.stderr.write(`[replay-trace] ${s}${l}: REPLAY${p} (would skip; v1 always authors)
3
- `)}else process.stderr.write(`[replay-trace] ${s}${l}: AUTHOR (${o.reason})
4
- `)}}function De(e){process.env.KANE_REPLAY_TRACE==="1"&&process.stderr.write(e)}function ss(e,t){let r=e===0?"(none)":`0..${e-1}`,n=e>=t?"(none)":`${e}..${t-1}`;De(`[replay-trace] phase: replay ${r}, author ${n}
5
- `)}function is(e,t){De(`[replay-trace] step ${e}: REPLAY ${t==="ok"?"OK":"FAILED"}
6
- `)}function as(e,t,r){De(`[replay-trace] shrink ${e}/${t} \u2192 new boundary ${r}
7
- `)}function ls(e,t){De(`[replay-trace] complete-reauthor (${e} shrinks exhausted of ${t})
8
- `)}function Kr(){De(`[replay-trace] force-author (--author) \u2014 walker bypassed; identity kept
9
- `)}function ds(e){De(`[replay-trace] cancelled at step ${e}
10
- `)}function Le(e,t){De(`[replay-trace] step ${e}: replay-only @${t} failed \u2014 adaptive heal cannot re-author it; the run fails here
11
- `)}import{join as cs}from"path";function Hr(e){let t=Ho(e.decision),r={objective:e.step.objective,model:"v16-alpha",width:e.windowSize.width,height:e.windowSize.height,session_id:e.sessionId,run_index:e.runIndex,mode:"replay",replay:{recording_path:t[0],...t.length>1?{recording_paths:t}:{},step_label:e.step.objective,...e.investigationAsync?{investigation:"async"}:{}},screenshot_dir:e.evidence?cs(e.sessionDir,"scratch",String(e.runIndex)):cs(e.sessionDir,"runs",String(e.runIndex)),run_id:"run",test_id:"test"};return e.forceNavigateUrl&&(r.url=e.forceNavigateUrl),e.chrome.wsEndpoint?r.ws_endpoint=e.chrome.wsEndpoint:e.chrome.cdpEndpoint&&(r.cdp_endpoint=e.chrome.cdpEndpoint),e.auth.basicAuth?(r.username=e.auth.basicAuth.username,r.access_key=e.auth.basicAuth.access_key):e.auth.token&&(r.auth={type:"bearer",token:e.auth.token}),e.auth.resolvedCreds?.org_id&&(r.org_id=String(e.auth.resolvedCreds.org_id)),e.environmentId&&(r.environment_id=e.environmentId),e.variables&&Object.keys(e.variables).length>0&&(r.variables=e.variables),e.sessionContext&&(r.session_context=e.sessionContext),e.device&&(r.device=e.device),e.evidence&&(r.evidence=Mt(e.evidence.packTestDir,e.evidence.ordinalOffset)),r}async function us(e){let t=e.forceAuthor?0:ut(e.decisions),r=0,n=!1;for(;;){let o=e.session.snapshot(),s=e.accumulator.snapshot(),l=await e.runReplayPhase(t);if(l.cancelled)return n=!0,ds(l.failedAt??0),{authorBoundary:t,cancelledInPhase:n,shrinkCount:r};if(l.failedAt===null)return{authorBoundary:t,cancelledInPhase:n,shrinkCount:r};let p=e.decisions[l.failedAt],i=p?.kind==="replay"?p.replayOnly:void 0,c=Go({failedAt:l.failedAt,shrinkCount:r,hasRetry:e.hasRetry,maxShrinks:e.maxShrinks,failedAtReplayOnly:i});if(c.kind==="fail")return c.replayOnly&&(Le(l.failedAt,c.replayOnly),e.onReplayOnlyFail?.(l.failedAt,c.replayOnly)),{authorBoundary:-1,cancelledInPhase:n,shrinkCount:r};if(e.acquireLockIfNeeded&&!await e.acquireLockIfNeeded())return{authorBoundary:-1,cancelledInPhase:n,shrinkCount:r};if(e.recycleBrowser&&!await e.recycleBrowser())return{authorBoundary:-1,cancelledInPhase:n,shrinkCount:r};if(e.archiveAttempt&&await e.archiveAttempt(l.failedAt),e.session.rollback(o),e.accumulator.rollback(s),c.kind==="complete-reauthor")return ls(r+1,e.maxShrinks),{authorBoundary:0,cancelledInPhase:n,shrinkCount:r};r++,as(r,mt.maxShrinks,c.newAuthorBoundary),t=c.newAuthorBoundary}}var Oi=15e3,Gr=3,ms=[500,1e3];async function qr(e){if(process.env.KANE_LOCK_CONFLICT_SIMULATE==="1")return{ok:!1,reason:"concurrent",httpStatus:409,message:"simulated contention (KANE_LOCK_CONFLICT_SIMULATE=1)"};let t=`${e.baseUrl}/test/${encodeURIComponent(e.testId)}/playground`,r=await Ht(t,{from_commit_id:e.fromCommitId,new_commit_id:e.newCommitId},e.auth);return r.ok?{ok:!0,sessionExpiresAt:J(r.body,"session_expires_at")??""}:{ok:!1,...ji(r)}}function ji(e){let t=J(e.body,"error")??J(e.body,"code")??"",r=J(e.body,"message")??J(e.body,"detail")??e.text??`HTTP ${e.status}`,n;return e.status===0?n="network":e.status===401||e.status===403?n="auth":e.status===409&&t==="PlaygroundBaseCommitMismatch"?n="base_mismatch":e.status===409?n="concurrent":e.status===422?n="disabled":e.status===400&&/no committed/i.test(r)?n="no_commits":e.status===400?n="missing_field":e.status>=500||e.status===408||e.status===429?n="network":n="other",{reason:n,httpStatus:e.status,message:r}}async function ps(e){let t=`${e.baseUrl}/test/${encodeURIComponent(e.testId)}/playground/reserve`,r=await Ht(t,void 0,e.auth);return r.ok?{ok:!0,sessionExpiresAt:J(r.body,"session_expires_at")??""}:{ok:!1,expired:r.status===404,httpStatus:r.status,message:J(r.body,"message")??J(r.body,"detail")??r.text??`HTTP ${r.status}`}}async function zr(e){let t=`${e.baseUrl}/test/${encodeURIComponent(e.testId)}/commit`,r={commit_id:e.body.commitId,from_commit_id:e.body.fromCommitId,commit_message:e.body.commitMessage,total_steps:e.body.totalSteps};e.body.timeTaken!==void 0&&(r.time_taken=e.body.timeTaken),e.body.objectives!==void 0&&(r.objectives=e.body.objectives),e.body.testInstanceId!==void 0&&(r.test_instance_id=e.body.testInstanceId),e.body.trigger!==void 0&&(r.trigger=e.body.trigger);let n=await Ht(t,r,e.auth);return n.ok?{ok:!0,testId:J(n.body,"test_id")??e.testId,testcaseId:J(n.body,"testcase_id")??"",projectId:J(n.body,"project_id"),isTestCaseDeleted:typeof n.body?.is_test_case_deleted=="boolean"?n.body.is_test_case_deleted:void 0}:{ok:!1,...Ui(n)}}function Ui(e){let t=J(e.body,"error")??J(e.body,"code")??"",r=J(e.body,"message")??J(e.body,"detail")??e.text??`HTTP ${e.status}`,n;return e.status===0?n="network":e.status===401||e.status===403?n="auth":e.status===409&&t==="PlaygroundBaseCommitMismatch"?n="base_mismatch":e.status===409&&t==="PlaygroundCommitLockMismatch"?n="lock_mismatch":e.status===409?n="expired":e.status===422?n="not_found":e.status>=500||e.status===408||e.status===429?n="network":n="other",{reason:n,httpStatus:e.status,message:r}}async function Oe(e){let t=`${e.baseUrl}/test/${encodeURIComponent(e.testId)}/commit`,r={discard:!0,commit_id:e.body.commitId,from_commit_id:e.body.fromCommitId,commit_message:"(discarded)",total_steps:1},n=await Ht(t,r,e.auth);return n.ok?{ok:!0}:{ok:!1,reason:J(n.body,"error")??"other",httpStatus:n.status,message:J(n.body,"message")??J(n.body,"detail")??n.text??`HTTP ${n.status}`}}async function Ht(e,t,r){let n=null;for(let o=1;o<=Gr;o++){let s=new AbortController,l=setTimeout(()=>s.abort(),Oi);try{let p=await Y(e,{method:"POST",headers:{Authorization:Lt(r.username,r.accessKey),"Content-Type":"application/json",Accept:"application/json"},...t!==void 0?{body:JSON.stringify(t)}:{},signal:s.signal});clearTimeout(l);let i=await p.text(),c=null;if(i)try{c=JSON.parse(i)}catch{}let v=p.status>=500||p.status===408||p.status===429;if(p.ok||!v)return{ok:p.ok,status:p.status,body:c,text:i};if(o<Gr){await fs(ms[o-1]??1e3);continue}return{ok:!1,status:p.status,body:c,text:i}}catch(p){if(clearTimeout(l),n=p,o<Gr){await fs(ms[o-1]??1e3);continue}}}return{ok:!1,status:0,body:null,text:n?.message??"exhausted retries"}}function fs(e){return new Promise(t=>setTimeout(t,e))}function J(e,t){if(typeof e!="object"||e===null)return;let r=e[t];return typeof r=="string"?r:void 0}var Ni=60*1e3,gs="lock-heartbeat",Ce=new Map,ft=null,Fi={register:(e,t)=>jt(e,t),deregister:e=>eo(e),cleanup:(e,t)=>to(e,t),remoteLogger:null};function hs(e){if(e!==void 0){let t=Ce.get(e);t!==void 0&&(clearInterval(t),Ce.delete(e));return}for(let t of Ce.values())clearInterval(t);Ce.clear()}function Gt(e){if(Ce.has(e.testId))return;let t=e.lifecycle??Fi,r=setInterval(async()=>{let n=await ps({baseUrl:e.baseUrl,testId:e.testId,auth:e.auth});if(!n.ok){let o=n.expired?"session expired":n.message;process.stderr.write(`[lock] heartbeat failed (${e.testId}): ${o}; continuing run
12
- `)}},Ni);Ce.set(e.testId,r),ft===null&&(ft=t,t.register(gs,()=>hs()))}function be(e){Ce.size!==0&&(hs(e),Ce.size===0&&ft!==null&&(ft.deregister(gs),ft=null))}import{readFileSync as bs,readdirSync as ys,existsSync as je,promises as Wr}from"fs";import{join as ce}from"path";async function $i(e,t){let r=ce(e,"steps",`${t.ordinal}-${t.id}`),n,o=null,s=[];try{n=JSON.parse(await Wr.readFile(ce(r,"step.json"),"utf8")),o=n.action_id??null,Array.isArray(n.analyze_action_ids)&&(s=n.analyze_action_ids.filter(l=>typeof l=="string"))}catch{}if(typeof n?.screenshot=="string"&&/^screenshot\.(?:png|jpg)$/i.test(n.screenshot)){let l=n.screenshot;try{return{png:await Wr.readFile(ce(r,l)),filename:l,actionId:o,analyzeActionIds:s}}catch{}}for(let l of["screenshot.png","screenshot.jpg"])try{return{png:await Wr.readFile(ce(r,l)),filename:l,actionId:o,analyzeActionIds:s}}catch{}return null}function Sl(){let e=[];return{track:t=>{e.push(t.catch(()=>{}))},settle:async()=>{await Promise.all(e)}}}async function vs(e,t,r,n){try{let o=await $i(e,t);if(!o){n("warn","SCREENSHOT_SKIP","Pack step folder or screenshot not found",{ordinal:t.ordinal,id:t.id,reason:"pack_step_not_found"});return}let s=new Set;o.actionId&&s.add(o.actionId);for(let l of o.analyzeActionIds)s.add(l);if(s.size===0){n("warn","SCREENSHOT_SKIP","No action_id in step.json",{ordinal:t.ordinal,id:t.id,reason:"no_action_id"});return}for(let l of s)r.enqueue(l,o.png);n("info","SCREENSHOT_ENQUEUED","Screenshot enqueued",{ordinal:t.ordinal,id:t.id,action_id:o.actionId,action_ids:[...s],screenshot:o.filename,size:o.png.length})}catch(o){n("error","SCREENSHOT_DISPATCH_ERROR","Screenshot dispatch error",{ordinal:t.ordinal,id:t.id,error:o instanceof Error?o.message:String(o)})}}function ws(e,t,r,n,o,s){try{let l=ce(e,"runs",String(t),"run-test");if(!je(l)){o("warn","SCREENSHOT_SKIP","Runs dir not found",{step_index:r,reason:"runsDir_not_found",path:l});return}let p=l;if(s){let S=ce(l,`child-${s}`);if(!je(S)){o("warn","SCREENSHOT_SKIP","Child dir not found",{step_index:r,child_id:s,reason:"child_dir_not_found",path:S});return}let E=ys(S).filter(d=>je(ce(S,d,"screenshots")));if(E.length===0){o("warn","SCREENSHOT_SKIP","No screenshots dir under child",{step_index:r,child_id:s,reason:"no_child_screenshots_dir"});return}p=ce(S,E[0])}else if(!je(ce(l,"screenshots"))){let S=ys(l).filter(E=>je(ce(l,E,"screenshots")));if(S.length===0){o("warn","SCREENSHOT_SKIP","No screenshots dir found",{step_index:r,reason:"no_screenshots_dir"});return}p=ce(l,S[0])}let i=ce(p,"screenshots",`step_${String(r).padStart(3,"0")}.png`);if(!je(i)){o("warn","SCREENSHOT_SKIP","Screenshot not found",{step_index:r,child_id:s,reason:"screenshot_not_found",path:i});return}let c=ce(l,"actions.ndjson");if(!je(c)){o("warn","SCREENSHOT_SKIP","NDJSON not found",{step_index:r,reason:"ndjson_not_found"});return}let v=bs(c,"utf-8").trim().split(`
13
- `),m=v[v.length-1];if(!m){o("warn","SCREENSHOT_SKIP","NDJSON empty",{step_index:r,reason:"ndjson_empty"});return}let I=JSON.parse(m).action_id;if(!I){o("warn","SCREENSHOT_SKIP","No action_id in NDJSON",{step_index:r,reason:"no_action_id"});return}let x=bs(i);n.enqueue(I,x),o("info","SCREENSHOT_ENQUEUED","Screenshot enqueued",{step_index:r,child_id:s,action_id:I,size:x.length})}catch(l){o("error","SCREENSHOT_DISPATCH_ERROR","Screenshot dispatch error",{step_index:r,error:l instanceof Error?l.message:String(l)})}}import{dirname as Bi,join as Mi}from"path";function Is(e,t,r){let n=e.total_runs??1,o=e.run_dir,s,l;if(n>1&&o){let p=Bi(o);s=Array.from({length:n},(i,c)=>Mi(p,String(t+c))),r&&r.length===n&&(l=r)}return{allRunDirs:s,flowObjectives:l}}function _s(e,t,r,n){return{index:r,objective:t,summary:e.summary,oneLiner:e.one_liner,status:e.status,resultCode:e.result_code,reasonCode:e.reason_code,perFlowMetadata:e.per_flow_metadata,context:e.context??{memory:{},variables:{},pointer:""},run_dir:e.run_dir,run_dirs:n.allRunDirs,flow_objectives:n.flowObjectives}}var qt=class{constructor(t){this.resolved=t;this.outcomes=t.rootSteps.map(r=>({rootStepIndex:r.index,status:"skipped"}))}outcomes;skipRoot=null;overallHalted=!1;shouldRunFlatStep(t){if(this.overallHalted)return!1;let r=t.trace[0].stepIndex;return!(this.skipRoot!==null&&r===this.skipRoot)}recordStep(t,r){let n=t.trace[0].stepIndex,o=this.outcomes.find(i=>i.rootStepIndex===n),s=this.resolved.rootSteps.find(i=>i.index===n),l=s.body.kind!=="objective";return l&&(o.refKind="import",o.refLabel=s.body.path,o.inlinedCount=(o.inlinedCount??0)+1,o.duration_s=(o.duration_s??0)+r.duration_s),r.status==="passed"?(l?o.status!=="failed"&&(o.status="passed"):(o.status="passed",o.duration_s=r.duration_s),{continueOverall:!0}):t.optional?(o.softFailures=o.softFailures??[],o.softFailures.push({subStepIndex:t.trace[t.trace.length-1].stepIndex,reason:r.reason}),{continueOverall:!0}):(o.status="failed",o.duration_s=l?o.duration_s:r.duration_s,o.failedSubStepIndex=l?t.trace.slice(1).map(i=>i.stepIndex):void 0,o.reason=r.reason,this.skipRoot=n,s.optional??!1?(o.softFailed=!0,{continueOverall:!0}):(this.overallHalted=!0,{continueOverall:!1}))}snapshotOutcomes(){return[...this.outcomes]}snapshot(){return{outcomes:this.outcomes.map(t=>({...t,softFailures:t.softFailures?[...t.softFailures]:void 0})),skipRoot:this.skipRoot,overallHalted:this.overallHalted}}rollback(t){this.outcomes=t.outcomes.map(r=>({...r,softFailures:r.softFailures?[...r.softFailures]:void 0})),this.skipRoot=t.skipRoot,this.overallHalted=t.overallHalted}finalize(){let t=this.outcomes.some(n=>n.status==="failed"&&!n.softFailed)?"failed":"passed",r=this.outcomes.reduce((n,o)=>n+(o.duration_s??0),0);return{overallStatus:t,outcomes:this.outcomes,totalDurationS:r}}};var Pl=Ke;function Yr(e){if(!e)return null;let t=e.trim();return t?/^https?:\/\//i.test(t)?t:`https://${t}`:null}function ks(e){return Yr(e.flag)??Yr(e.frontmatter)??(e.configDefault&&e.configDefault!==Ke?Yr(e.configDefault):null)}function Ss(e){return e.resolvedUrl!==null?!1:!((!!e.local||!!e.allowMissingUrl)&&!e.isTTY)}import{spawn as Vi}from"child_process";async function Rs(e,t,r=100){let n=`${e.replace(/\/+$/,"")}/json/version`,o=await Y(n);if(!o.ok)throw new Error(`CDP /json/version returned ${o.status}`);let s=await o.json();if(!s.webSocketDebuggerUrl)throw new Error("CDP /json/version missing webSocketDebuggerUrl");let l=new Wn(s.webSocketDebuggerUrl);await new Promise((h,C)=>{l.once("open",h),l.once("error",C)});let p=1,i=new Map;l.on("message",h=>{let C;try{C=JSON.parse(h.toString())}catch{return}if(C.id==null)return;let V=i.get(C.id);V&&(i.delete(C.id),C.error?V.reject(new Error(C.error.message)):V.resolve(C.result))});function c(h,C){let V=p++;return new Promise((Ae,oe)=>{i.set(V,{resolve:re=>Ae(re),reject:oe});let se={id:V,method:h};C&&(se.params=C),l.send(JSON.stringify(se))})}let m=(await c("Target.getTargets")).targetInfos.find(h=>h.type==="page");if(!m)throw l.close(),new Error("CDP: no page target found");let I=(await c("Browser.getWindowForTarget",{targetId:m.targetId})).windowId,x="",S=!1,E=null,d=!1;l.on("close",()=>{d=!0}),l.on("error",()=>{d=!0});async function U(){if(!S){if(d){S=!0;return}try{let C=(await c("Browser.getWindowBounds",{windowId:I})).bounds,V=`${C.left}:${C.top}:${C.width}:${C.height}`;V!==x&&(x=V,t({left:C.left,top:C.top,width:C.width,height:C.height}))}catch{}S||(E=setTimeout(U,r))}}return U(),{stop(){if(!S){S=!0,E&&clearTimeout(E);try{l.close()}catch{}}}}}var Ki=new Set(["1","true","yes"]);function Jr(e){if(e?.headless)return null;let t=process.env.KANE_CLI_DISABLE_MARKER;if(t!=null&&Ki.has(t.toLowerCase()))return null;let r=Nt();if(!r)return null;let n=[...r.args,"overlay"];e?.text&&n.push(e.text);let o;try{o=Vi(r.cmd,n,{cwd:r.cwd,stdio:["pipe","ignore","ignore"],detached:!1,windowsHide:!0})}catch{return null}o.stdin?.on("error",()=>{});let s=!1;o.on("exit",()=>{s=!0}),o.on("error",()=>{s=!0});function l(c){if(!(s||!o.stdin||o.stdin.destroyed))try{o.stdin.write(JSON.stringify(c)+`
14
- `)}catch{}}e?.chromePid&&e.chromePid>0&&l({type:"chrome_pid",pid:e.chromePid});let p=null;e?.cdpEndpoint&&Rs(e.cdpEndpoint,c=>l({type:"bounds",...c})).then(c=>{p=c.stop}).catch(()=>{});let i=!1;return{setRunActive(c){i||l({type:"run_active",active:c})},setStepText(c){if(i)return;let v=c.trim();v&&l({type:"step_text",text:v})},setStepComplete(){i||l({type:"step_complete"})},kill(){if(!i){i=!0,p?.();try{o.stdin?.end()}catch{}try{o.kill("SIGTERM")}catch{}}}}}function Es(e,t,r){return`${e}/projects/${t}/test-cases/${r}`}function zt(e,t,r,n){return`${Es(e,t,r)}/dashboard/share/${n}?type=summary&agentView=true&fqdn=summary-page`}function Cs(e,t,r,n){if(!(!t||!r||!n))return zt(e,t,r,n)}function As(e,t,r){return`${Es(e,t,r)}/dashboard?type=summary&agentView=true&fqdn=summary-page`}import{mkdtempSync as ma,rmSync as fa}from"fs";import{join as pa}from"path";import{tmpdir as ga}from"os";import{spawn as Ts,spawnSync as Hi}from"child_process";import{existsSync as Qr}from"fs";import{createConnection as Gi}from"net";import{homedir as qe,platform as gt}from"os";import{join as ze}from"path";var qi=new Set(["1","true","yes"]),Wt=class extends Error{constructor(t){super(t),this.name="ChromeNotFoundError"}};function Wl(e){return e instanceof Wt?e.message:`Chrome failed: ${e instanceof Error?e.message:String(e)}`}var Yt={darwin:["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",ze(qe(),"Applications/Google Chrome.app/Contents/MacOS/Google Chrome"),"/Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing",ze(qe(),"Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing"),"/Applications/Chromium.app/Contents/MacOS/Chromium"],linux:["/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/usr/bin/google-chrome-for-testing","/usr/local/bin/google-chrome-for-testing",ze(qe(),"chrome-for-testing/chrome-linux64/chrome"),"/usr/bin/chromium","/usr/bin/chromium-browser","/snap/bin/chromium"],win32:["C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe","C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",ze(qe(),"AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"),"C:\\chrome-for-testing\\chrome-win64\\chrome.exe",ze(qe(),"AppData\\Local\\chrome-for-testing\\chrome-win64\\chrome.exe"),ze(qe(),"AppData\\Local\\kane-chrome\\chrome.exe")]};function Ds(){let e=process.env.KANE_CLI_CHROME_PATH?.trim();return e||void 0}function zi(){let e=Ds();if(e)return e;let t=gt(),r=Yt[t]??Yt.linux;for(let n of r)if(Qr(n))return n;return t==="win32"?"chrome.exe":"google-chrome"}function Wi(){let e=Ds();if(e)return Qr(e);let t=gt();if((Yt[t]??Yt.linux).some(s=>Qr(s)))return!0;let n=t==="win32"?"chrome.exe":"google-chrome",o=t==="win32"?"where":"which";try{return Hi(o,[n],{stdio:"ignore"}).status===0}catch{return!1}}function Yi(){let e=gt();return e==="darwin"?["Google Chrome is required but was not found at any standard path.","","Install via Homebrew (recommended):"," brew install --cask google-chrome","","Or download:"," https://www.google.com/chrome/","","Then re-run your command. Set KANE_CLI_CHROME_PATH=/path/to/chrome","to point at a non-standard install."].join(`
15
- `):e==="linux"?["Google Chrome is required but was not found at /usr/bin/google-chrome.","(amd64 / x86_64 only \u2014 Google does not ship Chrome for Linux ARM.)","","Debian / Ubuntu (any version):"," wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"," sudo apt install -y ./google-chrome-stable_current_amd64.deb","","Fedora / RHEL / AlmaLinux / Rocky:"," sudo dnf install -y https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm","","Then re-run your command. Set KANE_CLI_CHROME_PATH=/path/to/chrome","to point at a non-standard install."].join(`
16
- `):e==="win32"?["Google Chrome is required but was not found in Program Files or AppData.","","Install via winget (Windows 10 1809+):"," winget install --id Google.Chrome -e --silent","","Or download:"," https://www.google.com/chrome/","","Then re-run your command. Set KANE_CLI_CHROME_PATH=C:\\path\\to\\chrome.exe","to point at a non-standard install."].join(`
17
- `):["Google Chrome is required.","Install from https://www.google.com/chrome/","(Note: no official Chrome builds for BSD or Alpine/musl Linux.)"].join(`
18
- `)}function Ji(e){let t=gt(),r=[`--remote-debugging-port=${e.port}`,`--user-data-dir=${e.userDataDir}`,`--window-size=${e.width},${e.height}`,"--no-first-run","--no-default-browser-check","--disable-blink-features=AutomationControlled","--disable-features=DownloadBubble,DownloadBubbleV2","--safebrowsing-disable-download-protection","--disable-popup-blocking","--disable-notifications","--disable-infobars","--disable-translate","--disable-prompt-on-repost","--disable-background-networking","--disable-client-side-phishing-detection","--disable-default-apps","--disable-hang-monitor","--disable-sync","--metrics-recording-only","--safebrowsing-disable-auto-update","--disable-backgrounding-occluded-windows","--disable-background-timer-throttling","--test-type=webdriver","--allow-pre-commit-input","--enable-logging","--v=1"];return t==="linux"&&(r.push("--no-sandbox"),r.push("--disable-dev-shm-usage"),r.push("--password-store=basic")),t==="darwin"&&r.push("--use-mock-keychain"),e.headless&&r.push("--headless=new"),r}function Qi(e){return new Promise(t=>{let r=Gi({port:e,host:"127.0.0.1"});r.setTimeout(1e3),r.on("connect",()=>{r.destroy(),t(!0)}),r.on("timeout",()=>{r.destroy(),t(!1)}),r.on("error",()=>{r.destroy(),t(!1)})})}async function Zi(){for(let e=wr;e<=Ir;e++)if(!await Qi(e))return e;throw new Error(`All CDP ports ${wr}-${Ir} are in use. Close other Chrome instances.`)}var pt=class extends Error{constructor(t){super(t),this.name="CdpReadinessError"}};async function Xi(e,t){let r=Date.now(),n=`http://127.0.0.1:${e}/json/version`;for(;Date.now()-r<t;){try{if((await Y(n)).ok)return`http://127.0.0.1:${e}`}catch{}await new Promise(o=>setTimeout(o,200))}throw new pt(`Chrome CDP not ready after ${t}ms on port ${e}`)}var ea=3e4,ta=2;function xs(e,t,r){let n=process.env[e];if(n==null||n.trim()==="")return t;let o=Number(n);return!Number.isInteger(o)||o<r?t:o}function ra(e){return Math.min(500*e,3e3)}function Ps(e,t){try{if(e.pid)if(t==="win32")Ts("taskkill",["/pid",String(e.pid),"/T","/F"],{stdio:"ignore"});else try{process.kill(-e.pid,"SIGKILL")}catch{e.kill("SIGKILL")}else e.kill("SIGKILL")}catch{}}async function Ls(e){let t=process.env.KANE_CLI_SKIP_BROWSER_DOWNLOAD;if(!(t!=null&&qi.has(t.toLowerCase()))&&!Wi())throw _r()?.log("error","CHROME_NOT_FOUND","Startup gate: Chrome unavailable at standard system paths",{platform:process.platform,kane_cli_chrome_path:process.env.KANE_CLI_CHROME_PATH??null,skip_browser_download:process.env.KANE_CLI_SKIP_BROWSER_DOWNLOAD??null}),new Wt(Yi());let n=gt(),o=zi(),s=xs("KANE_CLI_CDP_TIMEOUT_MS",ea,1),p=xs("KANE_CLI_CDP_RETRIES",ta,0)+1,i;for(let c=1;c<=p;c++){let v=await Zi(),m=Ji({port:v,...e});e.startUrl&&m.push(e.startUrl);let b=Ts(o,m,{stdio:"ignore",detached:!0});b.unref();try{let I=await new Promise((x,S)=>{b.on("error",E=>{S(new Error(`Failed to launch Chrome: ${E.message}. Is Chrome installed at ${o}?`))}),b.on("close",E=>{E!==null&&E!==0&&S(new pt(`Chrome exited during startup with code ${E}`))}),Xi(v,s).then(x,S)});return{process:b,port:v,cdpEndpoint:I,kill(){Ps(b,n)}}}catch(I){if(i=I,!(I instanceof pt))throw I;Ps(b,n),_r()?.log("warn","CHROME_CDP_LAUNCH_RETRY",`Chrome CDP launch attempt ${c}/${p} failed`,{attempt:c,max_attempts:p,port:v,timeout_ms:s,headless:e.headless??!1,error:I.message}),c<p&&await new Promise(x=>setTimeout(x,ra(c)))}}throw i??new Error("Chrome launch failed after retries")}import{readFileSync as na}from"fs";var oa="wss://cdp.lambdatest.com/playwright",sa="1.57.0",ia=new Set(["chrome","microsoftedge","pw-chromium"]),aa=e=>e==="true"||e==="1",la="KANE_CLI_GRID",Zr="KANE_CLI_GRID_CAPS";function Ue(e=process.env){return aa((e[la]??"").trim().toLowerCase())}function da(){return{browserName:"Chrome",browserVersion:"latest","LT:Options":{platform:"linux",resolution:"1920x1080",video:!0,console:!0,network:!1,"network.full.har":!1,"network.http2":!0,w3c:!0,plugin:"kane-cli",project:"KaneAI-CLI",idleTimeout:1800,hideInternalCommandLogs:!0,"goog:chromeOptions":["--enable-logging","--disable-notifications","--no-sandbox","--log-level=0","--ignore-certificate-errors","--disable-blink-features=AutomationControlled","--password-store=basic","--safebrowsing-disable-auto-update","--disable-sync"]}}}function ca(e=process.env){let t=(e[Zr]??"").trim();if(!t)return da();let r;try{r=JSON.parse(na(t,"utf8"))}catch(s){throw new Error(`${Zr}: cannot read grid capabilities at ${t}: ${s.message}`)}let n=r,o=n?.["LT:Options"];if(!n||typeof n!="object"||!o||typeof o!="object"||Array.isArray(o))throw new Error(`${Zr}: ${t} is not a grid capability object (needs "LT:Options")`);return{browserName:String(n.browserName||"Chrome"),browserVersion:String(n.browserVersion||"latest"),"LT:Options":{...o}}}function Os(e,t=process.env){let r=ca(t);if(!ia.has(r.browserName.toLowerCase()))throw new Error(`LT grid browser "${r.browserName}" is not supported by kane-cli (it drives Chromium: Chrome or Edge)`);let n=r["LT:Options"];n.user=e.username,n.accessKey=e.accessKey,n.build=t.BUILD||n.build||"kane-cli",n.playwrightClientVersion=sa,n.name||(n.name=e.name),!n["tms.tc_id"]&&e.tcId&&(n["tms.tc_id"]=e.tcId);let o=ua(n.customHeaders,t);return o?n.customHeaders=o:delete n.customHeaders,{browserName:r.browserName,browserVersion:r.browserVersion,"LT:Options":n}}function ua(e,t){if(!e||typeof e!="object"||Array.isArray(e))return;let r={};for(let[n,o]of Object.entries(e))typeof o=="string"&&(r[n]=o.replace(/\{\{\s*([^}]+?)\s*\}\}/g,(s,l)=>{let p=l.split(".").pop()??l,i=t[p];return i===void 0?(process.stderr.write(`warn: LT grid custom header ${n}: ${s} has no value
19
- `),s):i}));return Object.keys(r).length?r:void 0}function js(e,t=process.env){let r=(t.HYE_HUB??"").trim().replace(/^[a-z]+:\/\//i,"").replace(/^[^@/]*@/,"").split("/")[0];return`${r?`wss://${r}/playwright`:oa}?capabilities=${encodeURIComponent(JSON.stringify(e))}`}async function Us(e){if(!e)return null;if(e.basicAuth)return{username:e.basicAuth.username,accessKey:e.basicAuth.access_key};let t=e.resolvedCreds??await e.resolver.resolve().catch(()=>null);return t?.username&&t?.access_key?{username:t.username,accessKey:t.access_key}:null}async function Xr(e){if(e.cft)return{instance:null,tempDir:null};if(e.wsEndpoint)return{wsEndpoint:e.wsEndpoint,instance:null,tempDir:null};if(e.cdpEndpoint){let o=await Y(`${e.cdpEndpoint}/json/version`);if(!o.ok)throw new Error(`CDP endpoint not reachable: ${e.cdpEndpoint} (${o.status})`);return{cdpEndpoint:e.cdpEndpoint,instance:null,tempDir:null}}if(Ue()){if(!e.ltGrid)throw new Error("KANE_CLI_GRID is set but no LambdaTest credentials were resolved for the LT browser");let o=js(Os(e.ltGrid));return process.stderr.write(`chrome: KANE_CLI_GRID \u2014 LT grid session "${e.ltGrid.name}"
20
- `),{wsEndpoint:o,instance:null,tempDir:null,...e.startUrl?{startUrl:e.startUrl}:{}}}let t,r=null;if(e.config.chrome_profile_path)t=e.config.chrome_profile_path.replace("~",process.env.HOME??"~");else{r=ma(pa(ga(),"kane-clean-")),t=r;let o=r;jt("tempDir",()=>{try{fa(o,{recursive:!0,force:!0})}catch{}})}let n=await Ls({userDataDir:t,width:e.config.window_size.width,height:e.config.window_size.height,startUrl:e.startUrl,headless:e.headless});return{cdpEndpoint:n.cdpEndpoint,instance:n,tempDir:r}}async function Ns(e,t){if(e==="device"){let{device:r,appRef:n,appId:o}=await t.prepareDevice();return{kind:"device",device:r,...n?{appRef:n}:{},...o?{appId:o}:{}}}return{kind:"web",chrome:await t.prepareWeb()}}function ad(e,t={}){if(e.kind==="device"){let r=e.device.target;return r==="emulator"||r==="simulator"?r:void 0}if(e.chrome.instance)return"chrome";if(t.cdpEndpoint)return"cdp";if(t.wsEndpoint)return"ws"}function ld(e,t){if(!(e.kind!=="device"||e.device.target!=="simulator"))return t?Jn(t):void 0}function dd(e){if(e.kind!=="device")return;let t=e.device.target;if(!(t!=="emulator"&&t!=="simulator"))return e.appRef??""}import{readFileSync as ha}from"fs";import{resolve as ba}from"path";var We="KANE_CLI_DEVICE_CONFIG";function Fs(e=process.env){return(e[We]??"").trim()!==""}function ya(e=process.env){let t=(e[We]??"").trim();if(!t)throw new Error(`a real-device run needs ${We} to name the run's device-config.json, and it is not set.`);let r=ba(t),n;try{n=JSON.parse(ha(r,"utf8"))}catch(o){throw new Error(`${We}: cannot read the device config at ${r}: ${o.message}`)}if(!n||typeof n!="object"||Array.isArray(n))throw new Error(`${We}: ${r} is not a device config object.`);return{path:r,entry:n}}function Jt(e){if(typeof e=="number")return String(e);if(typeof e=="string")return e.trim()||void 0}function $s(e,t=process.env){let{path:r,entry:n}=ya(t),o=Jt(n.platform_name)?.toLowerCase();if(o!==e.platform)throw new Error(`${We}: ${r} describes ${o?`a "${o}" device`:"no platform_name"}, but the test file's target is ${e.platform}.`);if(!e.hasCredentials)throw new Error("a real-device run needs a LambdaTest username and access key to open the mobile hub session, and none were resolved.");let s=Jt(n.device_name),l=Jt(n.platform_version),p=Jt(n.app);return{device:{platform:e.platform,target:e.platform,device_config_path:r},...s?{deviceName:s}:{},...l?{osVersion:l}:{},...p?{app:p}:{}}}function Bs(e){let t=[e.deviceName,e.osVersion].filter(Boolean).join(" \xB7 ");return`Running on: Real device (${e.device.platform})${t?` \xB7 ${t}`:""} \xB7 LambdaTest mobile hub`}function en(e){let t={objective:e.objective,model:e.model,width:e.windowSize.width,height:e.windowSize.height,session_id:e.sessionId,run_index:e.runIndex,max_steps:e.maxSteps??30,headless:e.headless??!1};return e.conditions&&e.conditions.length>0&&(t.conditions=[...e.conditions]),e.url&&(t.url=e.url),e.requireStartUrl&&(t.require_start_url=!0),e.chrome.wsEndpoint?t.ws_endpoint=e.chrome.wsEndpoint:e.chrome.cdpEndpoint&&(t.cdp_endpoint=e.chrome.cdpEndpoint),e.auth.basicAuth?(t.username=e.auth.basicAuth.username,t.access_key=e.auth.basicAuth.access_key):e.auth.token&&(t.auth={type:"bearer",token:e.auth.token}),e.auth.resolvedCreds?.org_id&&(t.org_id=String(e.auth.resolvedCreds.org_id)),e.projectId&&(t.project_id=e.projectId),e.disableAskUser&&(t.disable_ask_user=!0),e.enableTaskSkills&&(t.enable_task_skills=!0),e.networkWs&&(t.network_ws=!0),e.networkSse&&(t.network_sse=!0),(e.bugDetection==="stop"||e.bugDetection==="continue")&&(t.bug_detection=e.bugDetection),e.variables&&Object.keys(e.variables).length>0&&(t.variables=e.variables),e.globalContext&&(t.global_context=e.globalContext),e.localContext&&(t.local_context=e.localContext),e.sessionContext&&(t.session_context=e.sessionContext),e.device&&(t.device=e.device),e.environmentId&&(t.environment_id=e.environmentId),e.evidence&&(t.evidence=Mt(e.evidence.packTestDir,e.evidence.ordinalOffset)),t}import{existsSync as va,readFileSync as wa}from"fs";import{join as Ia}from"path";var Qt={max_retries:5,settle_ms:500,on_exhaust:"fail"},Ye=class{constructor(t,r,n){this.steps=t;this.decisions=r;this.deps=n;for(let o=0;o<t.length;o++){let s=t[o];if(s.controlFlow!=="if"&&s.controlFlow!=="while")continue;let l=s.block,p=t.map((b,I)=>[b,I]).filter(([b])=>b.block?.id===l.id&&b.block.depth===l.depth),i=p.find(([b])=>b.block.branch===-1)[1],c=p.filter(([b])=>b.controlFlow!==void 0&&b.block.branch!==-1).map(([,b])=>b),v=c.filter(b=>t[b].controlFlow!=="else").map(b=>t[b].objective),m={kind:s.controlFlow,opener:o,closer:i,markers:c,conditions:v,hasElse:t[c[c.length-1]].controlFlow==="else"};this.blocks.set(o,m),this.closers.set(i,m)}}blocks=new Map;closers=new Map;skip=new Set;attempts=new Map;taken=new Map;whileRuns=new Map;static hasBlocks(t){return t.some(r=>r.block!==void 0)}reset(){this.skip.clear(),this.attempts.clear(),this.taken.clear(),this.whileRuns.clear()}outcomes(){let t={};for(let[n,o]of this.taken)t[this.steps[n].flatIndex]=o;let r={};for(let[n,o]of this.whileRuns)r[this.steps[n].flatIndex]={...o};return{taken:t,whileRuns:r}}range(t,r){let n=t.markers[r]+1,o=r+1<t.markers.length?t.markers[r+1]:t.closer,s=[];for(let l=n;l<o;l++)s.push(l);return s}skipBranch(t,r){for(let n of this.range(t,r))this.skip.add(n)}unskipBody(t){for(let r=t.opener+1;r<t.closer;r++)this.skip.delete(r)}async judge(t){let r=await this.deps.evaluate(t),n=r.findIndex(o=>o==null);return n!==-1||r.length<t.length?{fail:`condition could not be judged: ${t[n===-1?r.length:n]}`}:r}async before(t){if(this.skip.has(t))return{action:"skip"};let n=this.steps[t].controlFlow;if(n==="if"){let s=this.blocks.get(t),l=await this.judge(s.conditions);if("fail"in l)return{action:"fail",reason:l.fail};let p=l.findIndex(i=>i===!0);p===-1&&s.hasElse&&(p=s.markers.length-1),this.taken.set(t,p);for(let i=0;i<s.markers.length;i++)i!==p&&this.skipBranch(s,i);return{action:"structural"}}if(n==="while"){let s=this.blocks.get(t);this.attempts.set(t,0);let l=await this.judge(s.conditions);return"fail"in l?{action:"fail",reason:l.fail}:(this.whileRuns.set(t,{iterations:l[0]?1:0,condition_met:!l[0]}),l[0]||this.skipBranch(s,0),{action:"structural"})}if(n==="end-while"){let s=this.closers.get(t);if(!(s.opener+1===s.closer)&&this.skip.has(s.opener+1))return{action:"structural"};let p=this.deps.whileConfig(s.opener),i=(this.attempts.get(s.opener)??0)+1;this.attempts.set(s.opener,i);let c=this.whileRuns.get(s.opener)??{iterations:i,condition_met:!1};if(c.iterations=i,this.whileRuns.set(s.opener,c),i>=p.max_retries)return p.on_exhaust==="fail"?{action:"fail",reason:`while exhausted after ${i} iteration(s): ${s.conditions[0]}`}:{action:"structural"};await this.deps.sleep(p.settle_ms);let v=await this.judge(s.conditions);return"fail"in v?{action:"fail",reason:v.fail}:v[0]?(this.unskipBody(s),c.iterations=i+1,{action:"jump",to:s.opener+1}):(c.condition_met=!0,{action:"structural"})}if(n!==void 0)return{action:"structural"};let o=this.decisions[t];return o?.kind==="replay"&&o.unrecorded?{action:"author"}:{action:"run"}}};function tn(e){try{let t=No(e),r=Oo(e.owningFile,e.trace[e.trace.length-1].stepIndex,t.slice(0,8)),n=Ia(r,"flows","0","actions.ndjson");if(!va(n))return null;let o=wa(n,"utf8").split(`
21
- `).find(s=>s.trim().length>0);return o?JSON.parse(o):null}catch{return null}}function Zt(e){let t=tn(e);if(!t||t.action_type!=="while")return{...Qt};let r=t.action_params??{};return{max_retries:typeof r.max_retries=="number"&&r.max_retries>0?r.max_retries:Qt.max_retries,settle_ms:typeof r.settle_ms=="number"&&r.settle_ms>=0?r.settle_ms:Qt.settle_ms,on_exhaust:typeof r.on_exhaust=="string"&&r.on_exhaust?r.on_exhaust:Qt.on_exhaust}}import{readdirSync as _a,readFileSync as Vs,existsSync as Ks}from"fs";import{join as ka}from"path";function rn(e,t){let r=t.type==="parameter";return{value:typeof t.value=="number"?String(t.value):t.value,secret:t.secret??!1,syntax:t.syntax??(r?"${"+e+"}":`{{${e}}}`),...typeof t.type=="string"?{type:t.type}:{},...typeof t.description=="string"?{description:t.description}:{}}}function Ms(e,t){if(!Ks(e))return{};let r={},n;try{n=_a(e).filter(o=>o.endsWith(".json")).sort()}catch{return{}}for(let o of n)try{let s=Vs(ka(e,o),"utf-8"),l=JSON.parse(s);if(l&&typeof l=="object")for(let[p,i]of Object.entries(l))i&&typeof i=="object"&&"value"in i&&(r[p]=rn(p,i))}catch{t?t("warn","VARIABLE_PARSE_FAILED","Skipping invalid variables file",{file:o}):process.stderr.write(`[variables] Warning: skipping invalid variables file: ${o}
22
- `)}return r}function Hs(e){if(!Ks(e))throw new Error(`Variables file not found: ${e}`);let t=Vs(e,"utf-8"),r=JSON.parse(t),n={};if(r&&typeof r=="object")for(let[o,s]of Object.entries(r))s&&typeof s=="object"&&"value"in s&&(n[o]=rn(o,s));return n}function Gs(e){let t;try{t=JSON.parse(e)}catch{throw new Error("Invalid --variables JSON")}let r={};if(t&&typeof t=="object")for(let[n,o]of Object.entries(t))o&&typeof o=="object"&&"value"in o&&(r[n]=rn(n,o));return r}function qs(e,t,r){let n=Ms(e,r),o=Ms(t,r);return{...n,...o}}var Je=class{constructor(t){this.baseUrl=t}async pushSecret(t){let r=Lt(t.username,t.accessKey),n=await Y(`${this.baseUrl}/logistics/v1.0/secrets/create`,{method:"PUT",headers:{Authorization:r,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({secretKey:t.secretKey,secretValue:t.secretValue,orgId:t.orgId,username:t.username,scope:"user",type:"user",accessKey:t.accessKey})});if(!n.ok)throw new Error(`Push secret failed: ${n.status} ${await n.text()}`)}static extractVariableKeys(t){let r=t.matchAll(/\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}/g),n=new Set;for(let o of r)n.add(o[1]);return[...n]}};var Qe=class extends Ot{constructor(t,r,n){super(t,{username:r,accessKey:n})}async upsertVariable(t){let r=t.environmentId??0,n=await Y(`${this.baseUrl}/v1/variables`,{method:"POST",headers:this.headers(),body:JSON.stringify({name:t.name,value:String(t.value),type:"variable",value_type:"string",is_persist:t.isPersist??!1,environment_id:r})});if(n.ok){let i=await n.json().catch(()=>({}));if(i.type==="Success"&&i.id!=null)return{id:Number(i.id)||0}}let o=await Y(`${this.baseUrl}/v1/variables/${encodeURIComponent(t.name)}?environment_id=${r}`,{method:"GET",headers:this.headers()});if(!o.ok)return{id:0};let l=(await o.json().catch(()=>({}))).data?.id;return l==null?{id:0}:(await Y(`${this.baseUrl}/v1/variables/${l}`,{method:"PUT",headers:this.headers(),body:JSON.stringify({value:String(t.value),value_type:"string"})})).ok?{id:Number(l)||0}:{id:0}}};function zs(e,t){if(Object.keys(e).length===0)return{};let r={};for(let[n,o]of Object.entries(e)){let s=o.syntax??`{{${n}}}`;Ra(t,s)&&(r[n]=o)}return r}function Sa(e){let t=e.trim();return t.startsWith("{{")&&t.endsWith("}}")?t.slice(2,-2).trim():t.startsWith("${")&&t.endsWith("}")?t.slice(2,-1).trim():t}function Ra(e,t){if(!t||!e)return!1;if(e.includes(t))return!0;let r=Sa(t);if(!r)return!1;let n=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`(?:\\{\\{|\\$\\{)\\s*${n}(?=\\s*\\}|[.\\[])`).test(e)}function Ws(e){let t=qs(e.globalDir,e.localDir,e.onLoadError),r=e.file?Hs(e.file):{},n=e.inline?Gs(e.inline):{},o={...t,...r,...n,...e.parameters??{}},s=Object.keys(o).length>0,{variables:l,objective:p}=s?He(o,e.objective):{variables:{},objective:e.objective};return{raw:o,auteur:l,auteurObjective:p,...nn(o)}}function nn(e){let t=Object.entries(e),r=t.filter(([,o])=>dt(o)),n=t.filter(([,o])=>!dt(o));return{secretEntries:n.filter(([,o])=>o.secret),nonSecretEntries:n.filter(([,o])=>!o.secret),parameterEntries:r}}async function Ys(e){if(e.localMode)return{};let t=te(e.env);if(e.variables.secretEntries.length>0){let n=new Je(t.secretsBaseUrl);for(let[o,s]of e.variables.secretEntries)n.pushSecret({secretKey:o,secretValue:s.value,username:e.auth.username,accessKey:e.auth.access_key,orgId:e.orgId}).then(()=>e.log("info","SECRET_PUSH_OK","Secret pushed",{key:o})).catch(l=>e.log("error","SECRET_PUSH_FAILED","Secret push failed",{key:o,error:String(l)}))}let r={};if(e.variables.nonSecretEntries.length>0){let n=new Qe(t.tmsBaseUrl,e.auth.username,e.auth.access_key);for(let[o,s]of e.variables.nonSecretEntries)try{let l=await n.upsertVariable({name:o,value:s.value});r[o]=l.id,e.log("info","VAR_PUSH_OK","Variable pushed",{name:o,id:l.id})}catch(l){e.log("error","VAR_PUSH_FAILED","Variable push failed",{name:o,error:String(l)})}}return r}import{mkdirSync as Ea,writeFileSync as Ca}from"fs";import{join as Js}from"path";var Xt=class extends Ot{constructor(t,r,n){super(t,{username:r,accessKey:n})}async getDataset(t,r){let n=`/v1/dataset/${encodeURIComponent(t)}`,o=r?.versionId?`?version_id=${encodeURIComponent(r.versionId)}`:"",s=await Y(`${this.baseUrl}${n}${o}`,{method:"GET",headers:this.headers()}),l=await s.text();if(!s.ok){let c=l.trim();try{let v=JSON.parse(l);typeof v.message=="string"&&v.message&&(c=v.message)}catch{}throw new Error(`GET ${n} failed: ${s.status} ${c}`)}let p;try{p=JSON.parse(l)}catch{throw new Error(`dataset ${t}: response is not JSON`)}let i=p;if(!i||!Array.isArray(i.headers)||!Array.isArray(i.rows))throw new Error(`dataset ${t}: response carries no headers / rows`);return i}};async function Qs(e){let{id:t,version:r,row:n}=e.selection,o=new Xt(e.tmsBaseUrl,e.auth.username,e.auth.access_key),s;try{s=await o.getDataset(t,r?{versionId:r}:void 0)}catch(m){throw new Error(`dataset ${t}: ${m.message}`)}let l=Js(e.saveDir,"dataset"),p=Js(l,`${t}.json`);try{Ea(l,{recursive:!0}),Ca(p,JSON.stringify(s,null,2)+`
23
- `,"utf8")}catch(m){e.log?.("warn","DATASET_SAVE_FAILED","Could not save the fetched dataset",{path:p,error:String(m)})}let i;try{i=oo(s,n)}catch(m){throw new Error(`dataset ${t}: ${m.message}`)}let c=so(s,i.row),v=typeof s.latest_version_id=="string"&&s.latest_version_id?s.latest_version_id:void 0;return e.log?.("info","DATASET_ROW_LOADED","Dataset row loaded as parameters",{dataset_id:t,row_id:i.id,row_index:i.index,columns:Object.keys(c)}),{selection:e.selection,dataset:s,rowIndex:i.index,rowId:i.id,versionId:v,externalId:co(t,i.id,v),evidenceRecord:{dataset_id:t,dataset_name:typeof s.name=="string"&&s.name?s.name:null,dataset_version_id:v??null,row_id:i.id,row_index:i.index,columns:Object.keys(c),values:Object.fromEntries(Object.entries(c).map(([m,b])=>[m,b.value]))},parameters:c,testParams:io(s,i.row),columns:new Set(Object.keys(c)),savedPath:p}}import{readFileSync as Aa,existsSync as xa}from"fs";function on(e){if(!xa(e))return null;try{return Aa(e,"utf-8").trim()||null}catch{return null}}var Pa=()=>{};async function Zs(e,t,r){let n=t.log??Pa,o=e.session.testId??null,s=null,l=null,p=null;if(!r.localMode&&t.performUpload)try{s=await t.performUpload(),s?.success&&(s.testId&&(o=s.testId),s.testcaseId&&e.session.setTestcaseId(s.testcaseId))}catch(i){n("error","FINALIZE_UPLOAD_ERROR","Upload pipeline threw",{error:String(i)})}if(t.renderFeedbackPrompt)try{l=await t.renderFeedbackPrompt(),l&&o&&t.submitFeedback&&t.submitFeedback(o,l).catch(i=>{n("error","FINALIZE_FEEDBACK_SUBMIT_ERROR","Feedback submit failed",{error:String(i)})})}catch(i){n("error","FINALIZE_FEEDBACK_RENDER_ERROR","Feedback prompt threw",{error:String(i)})}if(e.session.flushRecorder(),r.skipLocalWrites)n("info","FINALIZE_SKIP_LOCAL_WRITES","Skipping local writes (testmd flow handles via staging)");else if(r.sourcePath&&r.rootSteps&&r.outcomes){try{p=Ur({sourcePath:r.sourcePath,title:r.title,rootSteps:r.rootSteps,outcomes:r.outcomes,overallStatus:r.overallStatus,startedISO:r.startedISO,durationS:r.durationS,sessionId:e.session.sessionId})}catch(i){n("error","FINALIZE_RESULT_MD_ERROR","_Result.md write failed",{error:String(i)})}try{Or({sourcePath:r.sourcePath,commitId:e.session.sessionId,testId:o??void 0,testcaseId:e.session.testcaseId??void 0,projectId:e.tuiConfig.project_id??void 0,folderId:e.tuiConfig.folder_id??void 0,orgId:e.session.orgId??void 0,sessionName:e.session.sessionName??ct(r.sourcePath),plan:e.session.plan??void 0,media:$r({priorMetaPath:_e(r.sourcePath),recordFiles:Fr(e.session.sessionDir)}),tcId:Dr(r.sourcePath),environmentId:Lr(r.sourcePath)})}catch(i){n("error","FINALIZE_META_WRITE_ERROR","meta.json write failed",{error:String(i)})}if(s?.codeExportDir)try{let i=Tr(e.tuiConfig.code_export?.language??"python",r.mobile);Br(s.codeExportDir,Pr(r.sourcePath,i.framework,i.language))}catch(i){n("error","FINALIZE_CODE_COPY_ERROR","code-export copy failed",{error:String(i)})}}else if(e.session.recorder?.lastWrittenPath){let i=e.session.recorder.lastWrittenPath,c=e.session.getFlows(),v=c.map((I,x)=>({index:x+1,heading:`Step ${x+1}`,verifies:[],headingLine:0,body:{kind:"objective",text:I.objective}})),m=c.map((I,x)=>({rootStepIndex:x+1,status:I.status==="passed"?"passed":I.status==="failed"?"failed":"skipped",duration_s:I.duration,reason:I.reason})),b=m.some(I=>I.status==="failed")?"failed":"passed";try{p=Ur({sourcePath:i,title:e.session.sessionName??"Session",rootSteps:v,outcomes:m,overallStatus:b,startedISO:e.session.startedAt,durationS:m.reduce((I,x)=>I+(x.duration_s??0),0),sessionId:e.session.sessionId})}catch(I){n("error","FINALIZE_TUI_RESULT_MD_ERROR","TUI _Result.md write failed",{error:String(I)})}try{Or({sourcePath:i,commitId:e.session.sessionId,testId:o??void 0,testcaseId:e.session.testcaseId??void 0,sessionName:e.session.sessionName??void 0,projectId:e.tuiConfig.project_id??void 0,folderId:e.tuiConfig.folder_id??void 0,plan:e.session.plan??void 0,media:$r({priorMetaPath:_e(i),recordFiles:Fr(e.session.sessionDir)}),tcId:Dr(i),environmentId:Lr(i)})}catch(I){n("error","FINALIZE_TUI_META_WRITE_ERROR","TUI meta.json write failed",{error:String(I)})}if(s?.codeExportDir)try{let I=Tr(e.tuiConfig.code_export?.language??"python",r.mobile);Br(s.codeExportDir,Pr(i,I.framework,I.language))}catch(I){n("error","FINALIZE_TUI_CODE_COPY_ERROR","TUI code-export copy failed",{error:String(I)})}e.session.recorder.lastCollisionSuffixed&&process.stderr.write(`Saved to ${i} (renamed: ${e.session.sessionName}_test.md already existed)
24
- `)}try{t.runCleanup?.()}catch(i){n("error","FINALIZE_CLEANUP_ERROR","Cleanup hook threw",{error:String(i)})}try{await e.session.finish("complete")}catch(i){n("error","FINALIZE_SESSION_FINISH_ERROR","session.finish threw",{error:String(i)})}return{uploadResult:s,feedbackChoice:l,resultMdPath:p}}import{readFileSync as an,writeFileSync as ln,existsSync as oi}from"fs";function Xs(e,t,r){if(r.forceAuthor)return"re-recorded from scratch";if(r.retryTriggered)return"re-recorded after retry";if(t.length>0&&t.every(l=>l.kind==="author"&&l.reason==="no-result-md"))return"initial recording";if(t.length>0&&t.every(l=>l.kind==="replay"))return r.wantsPush?"re-recorded (no source changes)":"no changes";let n=[];for(let l=0;l<t.length;l++){let p=t[l];if(!p||p.kind!=="author"||p.reason==="downstream-of-divergence"||p.reason==="no-result-md")continue;let i=Ta(e,e.steps[l]);switch(p.reason){case"structure-mismatch":n.push(`added/removed: ${i}`);break;case"md5-mismatch":n.push(`modified: ${i}`);break;case"missing-recording":n.push(`re-recorded: ${i}`);break;case"recorded-failed":n.push(`re-authored after failure: ${i}`);break}}if(n.length===0)return"automated commit";let o=n.filter((l,p)=>p===0||n[p-1]!==l),s=o.slice(0,3).join("; ");return o.length>3?`${s}; +${o.length-3} more`:s}function Ta(e,t){if(!t)return"unknown step";let r=t.trace[0]?.stepIndex;if(r==null)return"unknown step";let o=e.rootSteps[r-1]?.heading?.trim()??"";return t.trace.length>1?o?`imported step in "${o}"`:`imported step ${r}`:o||`step ${r}`}import{existsSync as Da}from"fs";function La(e){return!!e&&typeof e.module_id=="string"&&e.module_id.trim()!==""}function sn(e){return`warn: ${e}: *_module.md without a cloud meta.json module_id \u2014 it ran as a module, but its steps upload as plain blocks (no module_block)`}function ei(e,t,r={}){let n=r.tapePresent??(b=>Da(Lo(b))),o=r.readMeta??(b=>he(b)),s=r.onMissingIdentity??(b=>{process.stderr.write(`${sn(b)}
25
- `)}),l=new Set,p=new Set(e.unitFiles.filter(b=>b.kind==="module").map(b=>b.file)),i=new Map,c=[];for(let b of e.steps){let I=b.flatIndex,x,S="";for(let E=0;E+1<b.trace.length;E++){let d=b.trace[E],U=b.trace[E+1].file;if(S=S?`${S}>${d.file}#${d.stepIndex}`:`${d.file}#${d.stepIndex}`,!p.has(U))continue;let h=i.get(S);if(!h){let C=o(U);if(!La(C)){l.has(U)||(l.add(U),s(U));continue}h={key:S,file:U,meta:C,flatFrom:I,flatTo:I,dirty:!1,children:[]},i.set(S,h),(x?x.children:c).push(h)}h.flatFrom=Math.min(h.flatFrom,I),h.flatTo=Math.max(h.flatTo,I),x=h}}let v=b=>{for(let I=b.flatFrom;I<=b.flatTo;I++)if(t.has(I))return!0;return!1},m=b=>{for(let I of b)I.dirty=n(I.file)&&v(I),m(I.children)};return m(c),c}function ti(e){let t={};for(let r of e)for(let n=0;n<Math.max(1,r.totalRunDirs);n++)t[r.runIndex+n]=r.testmdStepIndex;return t}function ni(e,t){let r=e.steps,n=[],o=[];for(let s=0;s<r.length;s++){let l=r[s],p=l.controlFlow;if(p==="if"||p==="while"){let i=Oa(l,p,t);(o.length?o[o.length-1].children:n).push(i),o.push(i);continue}if(p==="elif"||p==="else"){let i=o[o.length-1];ri(i,l.flatIndex-1),i.branches.push({branch_type:p,condition:p==="else"?"":l.objective,flatFrom:l.flatIndex+1,flatTo:l.flatIndex,taken:!1});continue}if(p==="end-if"||p==="end-while"){let i=o.pop();ri(i,l.flatIndex-1),i.flatTo=l.flatIndex,ja(i,t);continue}}return n}function Oa(e,t,r){let n=tn(e),o=n?.action_params??{},s=typeof o.block_id=="string"?o.block_id:"",l=n?.action_instruction&&n.action_instruction.trim()||e.objective,p={kind:t,blockId:s,instruction:l,flatFrom:e.flatIndex,flatTo:e.flatIndex,branches:[{branch_type:"if",condition:e.objective,flatFrom:e.flatIndex+1,flatTo:e.flatIndex,taken:!1}],children:[]};if(t==="while"){let i=Zt(e),c=r?.whileRuns[e.flatIndex];p.whileCfg={...i,iterations:c?.iterations??0,condition_met:c?.condition_met??!1}}return p}function ri(e,t){let r=e.branches[e.branches.length-1];r.flatTo=t}function ja(e,t){if(e.kind==="while"){e.branches[0].taken=(e.whileCfg?.iterations??0)>0;return}let r=t?.taken[e.flatFrom];typeof r=="number"&&r>=0&&r<e.branches.length&&(e.branches[r].taken=!0)}function Ua(e,t){if(!(!e.shouldReplaceLocalOutput||!e.resolvedTest||!e.sourcePath||!e.stepRunRecords||!e.outcomes||!e.overallStatus))return async()=>{let{changedUnitFiles:r,legacySweep:n}=await Jo({resolvedTest:e.resolvedTest,sessionDir:e.session.sessionDir,stepRunRecords:e.stepRunRecords,outcomes:e.outcomes,overallStatus:e.overallStatus,startedISO:e.startedISO??new Date().toISOString(),durationS:e.durationS??0,sessionId:e.session.sessionId,commitId:e.fromCommitId??"",tmsIds:e.tmsIds??{},codeExportDir:e.codeExportDir,packTestDir:e.evidence?.packTestDir??e.evidenceRead?.packTestDir,authoredFlatIdx:new Set(e.authoredFlatIdx??[])});t.files=r;for(let o of r){let s=X(o);if(oi(`${s}.staging`)){jo(s);let l=n.find(p=>p.unitFile===o);l&&Qo(l.dirs)}}}}function Na(e,t){if(!e.shouldCommit||e.isFirstRun||!e.tmsBaseUrl||!e.testId||!e.fromCommitId||!e.newCommitId||!e.basicAuth||!e.resolvedTest||!e.decisions)return;let r=(o,s)=>Vt({sourcePath:o,testId:s,sessionId:e.session.sessionId,commitId:e.newCommitId,identityOverride:{commit_id:e.newCommitId},controller:new Te(te(e.env).controllerBaseUrl,{username:e.basicAuth.username,accessKey:e.basicAuth.access_key})}),n=(o,s)=>e.onAgentEvent?.({type:"test_md_bundle_sync",status:s.ok?"ok":"failed",commit_id:e.newCommitId,path:o,...s.ok?{bytes:s.bytes}:{stage:s.stage}});return async()=>{let o;if(e.testmdSync===!1)e.log?.("info","BUNDLE_SYNC_SKIPPED","testmd bundle sync skipped",{reason:"flag",commit_id:e.newCommitId});else{if(!e.sourcePath){let m="bundle sync requires a source path";return e.log?.("warn","BUNDLE_SYNC_FAILED","testmd bundle sync failed",{commit_id:e.newCommitId,stage:"collect",error:m}),{ok:!1,reason:"bundle_sync_failed",message:m}}if(o=await r(e.sourcePath,e.testId),!o.ok)return e.log?.("warn","BUNDLE_SYNC_FAILED","testmd bundle sync failed",{commit_id:e.newCommitId,stage:o.stage,error:o.error}),n(e.sourcePath,o),process.stderr.write(` \u26A0 bundle sync failed (${o.stage}): ${o.error} \u2014 commit not attempted; the local tape is kept, run again with --push once fixed
26
- `),{ok:!1,reason:"bundle_sync_failed",message:o.error}}let s=Xs(e.resolvedTest,e.decisions,{wantsPush:e.wantsPush??!1,retryTriggered:e.retryTriggered??!1,forceAuthor:e.forceAuthor??!1}),l=e.resolvedTest.steps.map(m=>m.objective).filter(m=>typeof m=="string"&&m.length>0).slice(0,50),p=e.forceAuthor?"always_reauthor":e.retryTriggered?"adaptive_heal":void 0,i=yo().testInstanceId,c={...i?{testInstanceId:i}:{},...p?{trigger:p}:{}},v=await zr({baseUrl:`${e.tmsBaseUrl}/kane-cli/v1`,testId:e.testId,body:{commitId:e.newCommitId,fromCommitId:e.fromCommitId,commitMessage:s,totalSteps:e.resolvedTest.steps.length,timeTaken:Math.round(e.durationS??0),objectives:l,...c},auth:{username:e.basicAuth.username,accessKey:e.basicAuth.access_key}});if(v.ok&&e.commitBox&&(e.commitBox.committed=!0,e.commitBox.testcaseId=v.testcaseId||void 0),v.ok&&o?.ok&&e.sourcePath&&(e.log?.("info","BUNDLE_SYNC_OK","testmd bundle pushed",{commit_id:e.newCommitId,bytes:o.bytes}),n(e.sourcePath,o)),v.ok&&e.sourcePath){let m=_e(e.sourcePath);try{let b=JSON.parse(an(m,"utf8"));b.commit_id=e.newCommitId,ln(m,JSON.stringify(b,null,2)+`
27
- `,"utf8")}catch(b){process.stderr.write(`warn: failed to update meta.json commit_id: ${b.message}
28
- `)}}if(v.ok)for(let m of e.unitLocks??[]){if(!t.files.includes(m.file)){await Oe({baseUrl:`${e.tmsBaseUrl}/kane-cli/v1`,testId:m.testId,body:{commitId:e.newCommitId,fromCommitId:m.fromCommitId},auth:{username:e.basicAuth.username,accessKey:e.basicAuth.access_key}}),be(m.testId);continue}let b;if(e.testmdSync!==!1&&(b=await r(m.file,m.testId),!b.ok)){e.log?.("warn","BUNDLE_SYNC_FAILED","unit bundle sync failed",{commit_id:e.newCommitId,path:m.file,stage:b.stage,error:b.error}),n(m.file,b),process.stderr.write(`warn: unit bundle sync failed (${m.file}): ${b.stage}: ${b.error} \u2014 unit not committed
29
- `),await Oe({baseUrl:`${e.tmsBaseUrl}/kane-cli/v1`,testId:m.testId,body:{commitId:e.newCommitId,fromCommitId:m.fromCommitId},auth:{username:e.basicAuth.username,accessKey:e.basicAuth.access_key}}),be(m.testId);continue}let I=e.resolvedTest.steps.filter(E=>E.owningFile===m.file),x=I.map(E=>E.objective).filter(E=>typeof E=="string"&&E.length>0).slice(0,50),S=await zr({baseUrl:`${e.tmsBaseUrl}/kane-cli/v1`,testId:m.testId,body:{commitId:e.newCommitId,fromCommitId:m.fromCommitId,commitMessage:`healed via importer ${e.sourcePath??""}`,totalSteps:I.length,timeTaken:0,objectives:x,...c},auth:{username:e.basicAuth.username,accessKey:e.basicAuth.access_key}});if(S.ok){let E=_e(m.file);try{let d=JSON.parse(an(E,"utf8"));d.commit_id=e.newCommitId,ln(E,JSON.stringify(d,null,2)+`
30
- `,"utf8")}catch(d){process.stderr.write(`warn: failed to update unit meta commit_id (${m.file}): ${d.message}
31
- `)}b?.ok&&(e.log?.("info","BUNDLE_SYNC_OK","unit bundle pushed",{commit_id:e.newCommitId,path:m.file,bytes:b.bytes}),n(m.file,b))}else process.stderr.write(`warn: unit self-commit failed (${m.file}): ${S.reason??""} ${S.message??""} \u2014 unit lock released
32
- `),e.log?.("warn","UNIT_COMMIT_FAILED","Imported unit commit failed; lock discarded",{path:m.file,test_id:m.testId,reason:S.reason,message:S.message}),await Oe({baseUrl:`${e.tmsBaseUrl}/kane-cli/v1`,testId:m.testId,body:{commitId:e.newCommitId,fromCommitId:m.fromCommitId},auth:{username:e.basicAuth.username,accessKey:e.basicAuth.access_key}}),be(m.testId)}return v.ok?{...v,...c}:v}}function Fa(e){if(!(!e.isFirstRun||!e.sourcePath))return async t=>{if(!e.sourcePath)return;let r=_e(e.sourcePath);try{let n=oi(r)?JSON.parse(an(r,"utf8")):{};e.session.sessionId&&(n.commit_id=e.session.sessionId),t&&(n.testcase_id=t),e.tmsIds?.testId&&(n.test_id=e.tmsIds.testId),e.tmsIds?.projectId&&(n.project_id=e.tmsIds.projectId),e.tmsIds?.folderId&&(n.folder_id=e.tmsIds.folderId),e.tmsIds?.orgId&&(n.org_id=e.tmsIds.orgId),e.tmsIds?.sessionName&&(n.session_name=e.tmsIds.sessionName),ln(r,JSON.stringify(n,null,2)+`
33
- `,"utf8")}catch(n){process.stderr.write(`warn: failed to update meta.json after endTest: ${n.message}
34
- `)}}}function $a(e){let t=e.decisions,r=e.resolvedTest?.steps,n=e.sourcePath;if(!t||!r||!n)return;let o=[];if(t.forEach((s,l)=>{s.kind==="replay"&&s.replayOnly&&o.push(r[l]?.flatIndex??l+1)}),o.length!==0)return{authoredExecutionPath:Ge(n),flatIndices:o}}function si(e){let t=$a(e),r=te(e.env),n=e.resolvedTest,o=!!n&&Array.isArray(n.unitFiles)&&(e.stepRunRecords?.length??0)>0,s=o?ei(n,new Set(e.authoredFlatIdx??[]),{onMissingIdentity:oe=>{e.log?.("warn","MODULE_IDENTITY_MISSING","*_module.md without a cloud module_id; its blocks upload unfolded",{path:oe}),process.stderr.write(`${sn(oe)}
35
- `)}}):void 0,l=o?ti(e.stepRunRecords):void 0,p=!!n&&n.steps.some(oe=>oe.block!==void 0),i=o&&p?ni(n,e.blockOutcomes):void 0,c=i?.length&&e.sourcePath?Ge(e.sourcePath):void 0,v={files:[]},{session:m,auth:b}=e,I=b.basicAuth?{username:b.basicAuth.username,accessKey:b.basicAuth.access_key}:b.token,x=b.resolvedCreds?.username??b.basicAuth?.username??"",S=b.resolvedCreds?.access_key??b.basicAuth?.access_key??"",E=b.resolvedCreds?.org_id??0,d=b.resolvedCreds?.user_id??0,U=[];for(let oe of Object.keys(m.auteurVariables))oe.startsWith("secrets.user.")&&U.push({key_name:oe.replace("secrets.user.",""),scope:"user"});let C=m.getContext().prior_runs.map(oe=>oe.status),V=m.auteurVariables,Ae=Object.keys(V).length>0;return{controllerBaseUrl:r.controllerBaseUrl,tmsBaseUrl:r.tmsBaseUrl,auth:I,authResolver:b.resolver,sessionId:m.sessionId,sessionDir:m.sessionDir,testId:m.testId,commitId:m.sessionId,apMode:m.apMode,projectId:e.projectId,folderId:e.folderId,firstObjective:m.firstObjective??"KaneAI Test",firstUrl:m.firstUrl??"",runDirs:m.getRunDirs(),runObjectives:m.getRunObjectives(),runMetadata:m.getRunMetadata(),startedAt:m.startedAt,endedAt:new Date().toISOString(),totalSteps:e.totalSteps,totalDuration:e.totalDuration,runStatuses:C,orgId:E,userId:d,tmsUsername:x,tmsAccessKey:S,screenshotBaseUrl:m.screenshotBaseUrl,screenshotExtMap:e.screenshotExtMap,shareApiBaseUrl:r.shareApiBaseUrl,variables:Ae?V:void 0,variableIds:e.variableIds,...e.testParams?{testParams:e.testParams}:{},secrets:U,codeExport:e.codeExport,...e.mobile?{mobile:!0}:{},...e.environmentId?{environmentId:e.environmentId}:{},onProgress:e.onProgress,log:e.log,shouldUploadArtifacts:e.shouldUploadArtifacts,shouldReplaceLocalOutput:e.shouldReplaceLocalOutput,shouldCommit:e.shouldCommit,isFirstRun:e.isFirstRun,onAtomicReplace:Ua(e,v),onCommitLock:Na(e,v),onFinalizeSuccess:Fa(e),evidence:e.evidence,evidenceRead:e.evidenceRead,...s?{moduleSpans:s}:{},...i?.length?{blockSpans:i,blockAuthoredExecutionPath:c}:{},...l?{runFlatIndex:l}:{},authoredExecutionPath:e.authoredExecutionPath,...t?{replayOnlyPassthrough:t}:{}}}function ii(e,t=process.env){return t.KANE_MOBILE_APP_BASE_URL||te(e).mobileAppBaseUrl}var ai=["python","javascript"];function kc(e,t){return e?e.kind==="mobile":t}function Ba(e){if(e!==void 0){if(!ai.includes(e))throw new Error(`--code-language must be one of: ${ai.join(", ")} (got "${e}")`);return e}}function li(e,t,r=!1){if(r&&e.skipCodeValidation===!1)throw new Error("Code export validation is web only: --skip-code-validation=false and --no-skip-code-validation are not supported for mobile. Remove the flag or use --skip-code-validation=true.");let n=Ba(e.codeLanguage);return{enabled:e.codeExport??t.enabled,language:n??t.language,skipValidation:r?!0:e.skipCodeValidation??t.skip_validation}}function di(e){return{platform:e.platform??"",...e.appId?{appId:e.appId}:{},...e.deviceName?{deviceName:e.deviceName}:{},...e.osVersion?{osVersion:e.osVersion}:{},...e.udid?{udid:e.udid}:{}}}async function ci(e){try{let t=new Ut(e.tmsBaseUrl,e.auth.username,e.auth.access_key);if(e.mobile){if(!e.mobile.appId)return e.log("warn","ATM_CREATE_SKIPPED","Mobile test not registered in TMS",{reason:"no cloud app id for the build under test"}),null;let n=await t.createMobileAtmTest({objective:e.objective.slice(0,100),creation_mode:"KANECLI",playground_disabled:e.hasCustomProfile,mobile_browser:!1,os:e.mobile.platform.toLowerCase(),app_id:e.mobile.appId,project_id:e.projectId,folder_id:e.folderId,authoring_version:4,...e.mobile.deviceName?{deviceName:e.mobile.deviceName}:{},...e.mobile.osVersion?{osVersion:e.mobile.osVersion}:{},...e.mobile.udid?{udid:e.mobile.udid}:{}});return e.log("info","ATM_CREATE_OK","Mobile test created",{test_id:n}),n}let r=await t.createAtmTest({objective:e.objective.slice(0,100),creation_mode:"KANECLI",playground_disabled:e.hasCustomProfile,testURL:e.url,project_id:e.projectId,folder_id:e.folderId,authoring_version:4});return e.log("info","ATM_CREATE_OK","Test created",{test_id:r}),r}catch(t){return e.log("error","ATM_CREATE_FAILED","Test creation failed",{error:t instanceof Error?t.message:String(t)}),null}}var Ma=null,Va=()=>Ma??=import("sharp").then(e=>e.default??e).catch(()=>null),er=class{maxWorkers;maxRetries=2;queue=[];activeCount=0;drainResolvers=[];sas;log;uploadedExt=new Map;constructor(t,r=3,n){this.sas=t,this.maxWorkers=r,this.log=n}updateSas(t){this.sas=t}enqueue(t,r){this.queue.push({operationId:t,buffer:r}),this.pump()}async drain(t=3e4){if(!(this.queue.length===0&&this.activeCount===0))return new Promise(r=>{this.drainResolvers.push(r),setTimeout(()=>{r()},t)})}pump(){for(;this.activeCount<this.maxWorkers&&this.queue.length>0;){let t=this.queue.shift();this.activeCount++,this.processJob(t).finally(()=>{if(this.activeCount--,this.pump(),this.queue.length===0&&this.activeCount===0){for(let r of this.drainResolvers)r();this.drainResolvers=[]}})}}async processJob(t){let r,n="image/webp",o=await Va();if(o)try{let i=await o(t.buffer).webp({quality:80}).toBuffer();r=new Uint8Array(i)}catch(i){r=new Uint8Array(t.buffer),n="image/png",this.log?.("warn","SCREENSHOT_CONVERT_FAILED","WebP conversion failed, using PNG",{operation_id:t.operationId,error:i instanceof Error?i.message:String(i)})}else r=new Uint8Array(t.buffer),n="image/png";let s=n==="image/webp"?"webp":"png",l=`test_screenshots/untagged_screenshot/${t.operationId}.${s}`,p=`${this.sas.base_url}/${this.sas.container}/${l}?${this.sas.sas_token}`;for(let i=0;i<=this.maxRetries;i++)try{let c=await Y(p,{method:"PUT",headers:{"Content-Type":n,"x-ms-blob-type":"BlockBlob"},body:r});if(c.ok){this.uploadedExt.set(t.operationId,s);return}if(i<this.maxRetries){await this.backoff(i);continue}this.log?.("warn","SCREENSHOT_UPLOAD_FAILED","Screenshot upload failed after retries",{operation_id:t.operationId,status:c.status,attempts:this.maxRetries+1})}catch{if(i<this.maxRetries){await this.backoff(i);continue}this.log?.("warn","SCREENSHOT_UPLOAD_FAILED","Screenshot upload failed (network error)",{operation_id:t.operationId,error:"network",attempts:this.maxRetries+1})}}backoff(t){let r=t===0?1e3:3e3;return new Promise(n=>setTimeout(n,r))}getExt(t){return this.uploadedExt.get(t)??"png"}getExtMap(){return this.uploadedExt}isNearExpiry(){if(!this.sas.expiry)return!1;let t=new Date(this.sas.expiry).getTime();return Date.now()>t-5*6e4}};import{platform as Ka,arch as Ha}from"os";function ui(e){let t={proxyUrl:Yn,sessionId:e.sessionId,identity:e.identity,device:{cli_version:Tt,platform:Ka(),arch:Ha(),host_agent:Rr(),invocation_mode:e.invocationMode},getToken:e.getToken};return new Sr(t)}async function Ga(e){try{let t=te(e.env),n=await new Te(t.controllerBaseUrl,e.auth).getScreenshotSas();return e.session.setScreenshotSas(n),e.log("info","SCREENSHOT_SAS_OK","Screenshot SAS fetched",{base_url:n.base_url,container:n.container,expiry:n.expiry}),new er(n,3,e.log)}catch(t){return e.log("warn","SCREENSHOT_SAS_FAIL","Screenshot SAS fetch failed",{error:t instanceof Error?t.message:String(t)}),null}}async function qa(e){if(e.session.hasRemoteLogger||!e.tmsCreds)return null;let t=e.tmsCreds,r=ui({sessionId:e.session.sessionId,identity:{org_id:String(t.org_id??""),user_id:String(t.user_id??""),machine_id:fo(),email:t.email??null,email_domain:t.email_domain??"unknown",user_type:t.user_type??"unknown",env:e.env,plan:t.plan??"unknown"},invocationMode:e.invocationMode,getToken:e.getToken});return e.session.setRemoteLogger(r),r.start(),r}async function mn(e){let[t,r]=await Promise.allSettled([e.skipScreenshotQueue?Promise.resolve(null):Ga({env:e.env,auth:e.auth,session:e.session,log:e.log}),qa({env:e.env,tmsCreds:e.tmsCreds,getToken:e.getToken,session:e.session,invocationMode:e.invocationMode})]);return{resolver:e.resolver,screenshotQueue:t.status==="fulfilled"?t.value:null,remoteLogger:r.status==="fulfilled"?r.value:null}}async function dn(e){await Promise.allSettled([e.screenshotQueue?.drain(),e.remoteLogger?.shutdown()])}async function Mc(e,t){switch(e.kind){case"boot":{if(t.state.identityServicesRef.current)return t.state.identityServicesRef.current;let r=t.auth.initResolver(e.env);r.prime(e.tmsCreds),t.state.setTmsCredsCache(e.tmsCreds);let n=await cn(e.env,e.tmsCreds,r,t);return un(n,t),n}case"login":case"switch":{let r=t.state.identityServicesRef.current;r&&(await dn(r),r.resolver.revoke()),t.state.identityServicesRef.current=null,t.state.screenshotQueueRef.current=null,t.state.setTmsCredsCache(null);let n=t.auth.initResolver(e.env),o=await n.resolve(!0).catch(()=>null);if(!o)return t.log("warn","IDENTITY_VALIDATE_FAILED","Identity validation failed",{kind:e.kind,env:e.env}),null;t.state.setTmsCredsCache(o);let s=await cn(e.env,o,n,t);return un(s,t),s}case"logout":{let r=t.state.identityServicesRef.current;return r&&(await dn(r),r.resolver.revoke()),t.state.identityServicesRef.current=null,t.state.screenshotQueueRef.current=null,t.state.setTmsCredsCache(null),null}case"resessionize":{let r=t.state.identityServicesRef.current;r&&await dn(r),t.state.identityServicesRef.current=null,t.state.screenshotQueueRef.current=null;let n=t.state.getTmsCredsCache(),o=t.auth.getResolver(),s=o??t.auth.initResolver(e.env);!o&&n&&s.prime(n);let l=await cn(e.env,n,s,t);return un(l,t),l}}}async function cn(e,t,r,n){!n.options?.localMode&&t?.user_id!==void 0&&n.getSession().setCompletionIdentity(Number(t.user_id));let o=n.auth.getBasicAuth(),s=o?null:await n.auth.getToken(),l=o?{username:o.username,accessKey:o.access_key}:s??null;return l===null?{resolver:r,screenshotQueue:null,remoteLogger:null}:mn({env:e,tmsCreds:t,resolver:r,auth:l,getToken:()=>n.auth.getToken(),session:n.getSession(),log:n.log,skipScreenshotQueue:n.options?.localMode,invocationMode:"tui"})}function un(e,t){t.state.identityServicesRef.current=e,t.state.screenshotQueueRef.current=e.screenshotQueue,e.remoteLogger&&(t.exit.registerCleanup("remote-logger",()=>e.remoteLogger.shutdownSync()),t.exit.setExitRemoteLogger(e.remoteLogger))}function mi(e){if(!e.executionId)return;let t={executionId:e.executionId,published:e.published};return e.testId&&(t.testId=e.testId),e.testcaseId&&(t.testcaseId=e.testcaseId),e.commitId&&(t.commitId=e.commitId),t}import{relative as Ya}from"path";import{readFile as za}from"fs/promises";function fi(e){return e.shouldUploadArtifacts&&!e.lockHeld&&!e.isFirstRun&&e.sealed&&!!e.testId}var fn=e=>e instanceof Error?e.message:String(e);async function pi(e){let{controller:t,tms:r,testId:n,sessionId:o,executionId:s,sealedPackPath:l,projectId:p}=e,i;try{let c={key:"evidence",content_type:"application/zip",filename:`${s}.evidence`},m=(await t.getPresignedUrls(n,o,[c])).urls?.evidence?.upload_url;if(!m)return{ok:!1,stage:"presign",error:"presign response missing evidence upload_url"};i=m}catch(c){return{ok:!1,stage:"presign",error:fn(c)}}try{let c=await za(l);await Uo(i,c,"application/zip")}catch(c){return{ok:!1,stage:"upload",error:fn(c)}}try{await r.ingestEvidence(s,p)}catch(c){return{ok:!1,stage:"ingest",error:fn(c)}}return{ok:!0}}function gi(e){return e.isFirstRun||Kt(e.decisions)||e.push===!0||e.author===!0}function hi(e,t){return{projectId:e?.project_id??t.project_id??null,folderId:e?.folder_id??t.folder_id??null}}function pn(e){return e?"author":"replay"}function Ja(e,t){return e?{session:e,ownsLifecycle:!1}:{session:t,ownsLifecycle:!0}}function tr(e,t){return e?.total_runs??t?.length??1}function Qa(e){let t=(e?.per_flow_metadata??[]).map(r=>({resultCode:r?.result_code!=null?Number(r.result_code):null}));return{resultCode:e?.result_code!=null?Number(e.result_code):null,...t.length?{perFlow:t}:{}}}var rr=["target","chrome_profile","cdp_endpoint","ws_endpoint","headless"];async function fm(e,t,r){let{path:n,cwd:o,opts:s,isAgent:l,disableAskUser:p,resolved:i,resolvedAuth:c,cliOverrides:v,environment:m,envConfig:b,profile:I,model:x,creds:S,configStore:E,session:d}=e,U=!1,h=await rl(n,i,s,{resolvedAuth:c,tmsBaseUrl:b.tmsBaseUrl},d.sessionId,r);if(h.abort)return{overallStatus:"failed",exitCode:h.abort.exitCode,outputDir:X(n),durationS:0,uploadResult:null};let C=h.lockAcquired,V=!1;try{let hr=function(a,u){let f=i.steps[a],y=bi(f.config,v),w=Xe(xe.raw,y.variables,f.objective);return en({objective:w.objective,url:P.kind==="device"?void 0:or(a)?Re??void 0:f.unitEntryUrl,requireStartUrl:P.kind==="web"&&or(a)&&Si,model:x,chrome:q,device:P.kind==="device"?P.device:void 0,auth:c,sessionId:d.sessionId,runIndex:u,projectId:s.local?null:B,windowSize:{width:1920,height:1080},maxSteps:y.max_steps??Ri??30,headless:K.headless??!1,disableAskUser:!0,variables:Object.keys(w.variables).length>0?w.variables:void 0,globalContext:y.global_context??Cn,localContext:y.local_context??An,sessionContext:d.getContext(),environmentId:wt,bugDetection:s.bugDetection??H.bug_detection,evidence:gr()})},at=function(a){let f=i.steps[a].trace[0].stepIndex,y=i.rootSteps.find(g=>g.index===f);i.steps.slice(0,a).some(g=>g.trace[0].stepIndex===f)||t.onAgentEvent({type:"test_md_step_start",step_index:f,heading:y.heading,ref:y.body.kind==="import_ref"?{kind:"import",label:y.body.path,unit_kind:jr(y.body.path)}:null,...y.replayOnly?{replay_only:y.replayOnly}:{}})},Rt=function(a,u,f,y,w,g){let _=i.steps[a],D=_.trace[0].stepIndex,F=!i.steps.slice(a+1).some(M=>M.trace[0].stepIndex===D),R=f?.status==="passed"?"passed":"failed",T=f?.reason??w??void 0,O=f?.duration??g,k=f?.verdict;if(k&&typeof k=="object"){let M=typeof k.one_liner=="string"?k.one_liner:"",N=typeof k.bug_title=="string"&&k.bug_title?k.bug_title:M;if(N&&R==="failed"){let fe=[k.family,k.category].filter(Boolean).join("/"),Pt=typeof k.confidence=="number"?`, confidence ${k.confidence.toFixed(2)}`:"";T=`${T??"failed"} \u2014 bug verdict: ${N}${fe?` [${fe}${Pt}]`:""}`}let lt=typeof k.category_proposal=="string"?k.category_proposal:"";lt&&R==="failed"&&(T=`${T??"failed"}; category proposal: ${lt} \u2014 consider adding to taxonomy`),t.onAgentEvent({type:"test_md_bug_verdict",step_index:_.trace[0].stepIndex,confirmed:k.confirmed===!0,bug_title:N||null,family:k.family??null,category:k.category??null,category_proposal:lt||null,severity:k.severity??null,confidence:typeof k.confidence=="number"?k.confidence:null,one_liner:M||null})}let{continueOverall:$}=le.recordStep(_,{status:R,duration_s:O,reason:T}),W=bi(_.config,v),A=Xe(xe.raw,W.variables,_.objective).objective;if(f){let M=Is(f,u,y);d.addRunResult(_s(f,A,u,M),f.total_runs)}else d.addRunResult({index:u,objective:A,status:R,summary:"",context:{memory:{},variables:{},pointer:""}},1);if(F||!$){let M=le.snapshotOutcomes().find(N=>N.rootStepIndex===D);t.onAgentEvent({type:"test_md_step_end",step_index:D,status:M.status,duration_s:M.duration_s??0,ref_kind:M.refKind??null,unit_kind:M.refKind==="import"?jr(M.refLabel??""):null,inlined_count:M.inlinedCount??null,failed_sub_step_index:M.failedSubStepIndex??null})}return $},Me=function(a,u){let f=i.steps[a],y=f.trace[f.trace.length-1].heading;process.stderr.write(`\u{1FA79} step ${f.flatIndex} "${y}" @${u} broke on replay \u2014 adaptive heal cannot re-author a replay-only step; the run fails here
36
- `),d.log("warn","REPLAY_ONLY_STEP_FAILED","Replay-only step failed on replay; heal not attempted",{flat_index:f.flatIndex,marker:u})};var Ae=hr,oe=at,se=Rt,re=Me;let nr={committed:!1},me=!1,bt=new Set,rt=0,wi=i.steps.some(a=>a.block!==void 0),or=a=>wi?rt===0:a===0,pe=!1,yt=!1,nt=s.author===!0?0:ut(h.decisions),sr=0,ir=0,Ne=0,ot=a=>typeof a?.credits_consumed=="number"&&Number.isFinite(a.credits_consumed)?a.credits_consumed:0;{let a;try{a=typeof s.sessionContext=="string"?JSON.parse(s.sessionContext):void 0}catch{a=void 0}let u=Za({resolved:i,cwd:o,globalDir:ye(Dt,"variables"),opts:s,authorFrom:nt,produced:ts(a)});u&&(l?t.onAgentEvent(u.event):process.stderr.write(u.text))}C&&t.onLockState({phase:"acquired",scope:"preemptive"}),d.start({model:x,environment:m,profile:I}),d.setRecordingEnabled(!1);let vt=0,hn=c.basicAuth?{username:c.basicAuth.username,accessKey:c.basicAuth.access_key}:c.token??null,st=null;if(hn!==null){let a=await mn({env:m,tmsCreds:c.resolvedCreds??null,resolver:c.resolver,auth:hn,getToken:async()=>c.token??null,session:d,log:(u,f,y,w)=>d.log(u,f,y,w),skipScreenshotQueue:!!s.local||!c.basicAuth,invocationMode:l?"agent":"cli"});st=a.screenshotQueue,a.remoteLogger&&(r.register("remote-logger",()=>a.remoteLogger.shutdownSync()),r.remoteLogger=a.remoteLogger,e.skipGlobalRemoteLogger||Zn(a.remoteLogger))}if(s.name){try{qo(s.name)}catch(a){return process.stderr.write(`error: ${a.message}
37
- `),{overallStatus:"failed",exitCode:2,outputDir:X(n),durationS:0,uploadResult:null}}d.setSessionName(s.name)}let ar={};for(let[a,u]of Object.entries(i.rootGlobal))rr.includes(a)||(ar[a]=u);for(let[a,u]of Object.entries(v))rr.includes(a)||u!==void 0&&(ar[a]=u);let K={...i.chrome};for(let a of rr){let u=v[a];u!==void 0&&(K[a]=u)}let Fe={...ar,...K},ke=zo({flags:{target:s.target,deviceName:s.deviceName,osVersion:s.osVersion,app:s.app},file:{target:i.rootGlobal.target,device_name:i.rootGlobal.device_name,os_version:i.rootGlobal.os_version,app:i.rootGlobal.app,no_reset:i.rootGlobal.no_reset},grid:Ue(),deviceConfig:Fs()});if(ke.kind==="invalid")return process.stderr.write(`error: ${ke.message}
38
- `),await d.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:X(n),durationS:0,uploadResult:null};for(let a of ke.warnings)process.stderr.write(`warning: ${a}
39
- `);let ve=ke.kind==="mobile"?ke:null,ge=ke.kind==="real-device"?ke:null;if(ge&&!l)return process.stderr.write(`error: a real-device run is non-interactive \u2014 run it without a terminal attached, or pass --agent.
40
- `),await d.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:X(n),durationS:0,uploadResult:null};if(d.setCompletionMetadata({runType:i.rootGlobal.assurance?.id?"assurance":"testmd",target:ge?ge.platform==="ios"?"simulator":"emulator":ve?.target??"desktop"}),ke.kind==="web"&&i.rootGlobal.target===void 0){let u=i.rootSteps.map(y=>y.body).find(y=>y.kind==="objective")?.text??"",f=/^\s*\[mobile:\s*(emulator|simulator)\]/.exec(u);if(f)return process.stderr.write(`error: this test was designed for a mobile ${f[1]} but its frontmatter has no target: \u2014 add \`target: ${f[1]}\` and \`app: <path-to-build | AppId>\` to the file (or re-design it with the app named in the design chat: kane-cli design tests --use-case <uc> --force), then run again
41
- `),await d.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:X(n),durationS:0,uploadResult:null}}ve?(Fe.target=ve.target,ve.app&&(Fe.app=ve.app)):ge?Fe.target=ge.platform:(i.rootGlobal.target==="emulator"||i.rootGlobal.target==="simulator")&&(delete Fe.app,delete Fe.no_reset),d.setResolvedGlobal(Fe);let we=null;{let a=f=>(process.stderr.write(`error: ${f}
42
- `),{overallStatus:"failed",exitCode:2,outputDir:X(n),durationS:0,uploadResult:null}),u;try{u=ao({datasetId:s.datasetId,datasetVersion:s.datasetVersion,datasetRow:s.datasetRow},i.rootGlobal.dataset)}catch(f){return a(f.message)}if(u){if(!c.basicAuth)return a("--dataset-id needs Test Manager credentials \u2014 run 'kane-cli login' or pass --username/--access-key");try{we=await Qs({selection:u,tmsBaseUrl:te(m).tmsBaseUrl,auth:c.basicAuth,saveDir:d.sessionDir,log:(y,w,g,_)=>d.log(y,w,g,_)})}catch(y){return a(y.message)}d.setResolvedGlobal({dataset:lo(u.id,we.rowId)});let f=Xo(i.steps.filter(y=>y.flatIndex-1>=nt).map(y=>({text:y.objective,usedBy:{file:Ze(y.sourceFile),step:y.flatIndex}})),we.columns,u.id);f.length>0&&(l?t.onAgentEvent(Vr(f,{cwd:o})):process.stderr.write(Mr(f,{cwd:o,entryFile:Ze(i.rootPath)})))}}let bn=S.getActiveProfile()??"default",yn=S.getDefaultEnv(),{rehydrateIfStale:Ii}=await import("./profile-sync-DTTRRIVP.js");Ii(S,E,bn,yn);let H=E.load(),vn=(v.assertion_mode??H.assertion_mode)==="dom"?"dom":"visual",wn=v.final_validation,In=wn===void 0?void 0:wn==="on",B=H.project_id??null,Se=H.folder_id??null,_n=he(n),wt=_n?.environment_id,lr=Fo(_n?.tc_id),kn=async()=>{if(!Ue())return;let a=await Us(c);if(a)return{name:i.rootTitle||Ze(n).replace(/_test\.md$/,""),...lr?{tcId:lr}:{},...a}},Sn=gi({isFirstRun:h.isFirstRun,decisions:h.decisions,push:s.push===!0,author:s.author===!0});if(Sn){if(c.basicAuth){let a=await mo({creds:S,config:E,profile:bn,env:yn,tmsCreds:c.basicAuth,isLocal:!!s.local,log:(u,f,y,w)=>d.log(u,f,y,w),onAnnounce:e.onAnnounce,onFatalExit:e.onFatalExit});if(a.status==="ok"){B=a.projectId,Se=a.folderId,H=E.load();let u=he(n);u?.project_id&&(B=u.project_id,Se=u.folder_id??Se),l&&a.autoDefaulted&&t.onAgentEvent(uo(a.autoDefaulted))}else if(a.status==="cancelled"){process.stderr.write(`error: project/folder configuration failed. See remediation above, or use --local.
43
- `);let{shutdown:u}=await import("./exit-manager-ZLDO54S4.js");return u(2,"project/folder gate failed"),{}}}}else{let a=he(n);({projectId:B,folderId:Se}=hi(a,{project_id:H.project_id??null,folder_id:H.folder_id??null})),d.log("info","GATE_SKIP_REPLAY","Project/folder gate skipped (planned pure replay)",{meta_project:!!a?.project_id,config_project:!!H.project_id})}{let a=Bo(i),u=c.resolvedCreds?.org_id!=null?String(c.resolvedCreds.org_id):void 0,f=a.find(g=>g.project_id&&B&&g.project_id!==String(B)||g.org_id&&u&&g.org_id!==u),y=new Set(a.map(g=>g.project_id).filter(Boolean)),w=new Set(a.map(g=>g.org_id).filter(Boolean));if(f||y.size>1||w.size>1){let g=f??a[0];return process.stderr.write(`error: tenant mismatch \u2014 imported test '${g.file}' was authored under project ${g.project_id??"?"} / org ${g.org_id??"?"}, which differs from the run's project/org (or another imported test). Cross-tenant imports are not allowed.
44
- `),await d.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:X(n),durationS:0,uploadResult:null}}}let ie={},P;try{P=await Ns(ve||ge?"device":"web",{prepareDevice:async()=>{if(ge){let f=$s({platform:ge.platform,hasCredentials:!!c.basicAuth});return f.deviceName&&(ie.deviceName=f.deviceName),f.osVersion&&(ie.osVersion=f.osVersion),f.app&&(ie.app=f.app),process.stderr.write(`${Bs(f)}
45
- `),{device:f.device}}let a=ve,u=await no({platform:a.platform,...a.deviceSelector?{device:a.deviceSelector}:{},...a.app?{app:a.app}:{},...a.noReset!==void 0?{noReset:a.noReset}:{},defaults:H.mobile,interactive:rs()&&!l,agent:l,...!s.local&&c.basicAuth&&c.resolvedCreds?.org_id?{cloudUpload:{env:m,orgId:String(c.resolvedCreds.org_id),userId:String(c.resolvedCreds.user_id??""),baseUrl:ii(m),auth:{username:c.basicAuth.username,accessKey:c.basicAuth.access_key}}}:{},onProgress:f=>process.stderr.write(`${f}
46
- `)});return ie.deviceName=u.target.displayName,u.target.osVersion&&(ie.osVersion=u.target.osVersion),u.target.modelIdentifier&&(ie.modelIdentifier=u.target.modelIdentifier),u.appRef&&(ie.app=u.appRef),{device:u.device,...u.appRef?{appRef:u.appRef}:{},...u.appId?{appId:u.appId}:{}}},prepareWeb:async()=>Xr({config:{chrome_profile_path:K.chrome_profile??null,window_size:{width:1920,height:1080}},startUrl:Ke,headless:K.headless??!1,wsEndpoint:K.ws_endpoint,cdpEndpoint:K.cdp_endpoint,ltGrid:await kn()})})}catch(a){if(ge)process.stderr.write(`error: real-device target preparation failed: ${a.message}
47
- `);else if(ve){let u=a instanceof ro?`${a.doctorText}
48
- ${a.message}`:a.message;process.stderr.write(`error: mobile target preparation failed: ${u}
49
- `)}else process.stderr.write(`error: Chrome launch failed: ${a.message}
50
- `);return await d.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:X(n),durationS:0,uploadResult:null}}if(P.kind==="device"&&!Er(P.device.target)&&!P.device.app_package)return process.stderr.write(`error: ${Wo(ve.target,"app")}
51
- `),await d.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:X(n),durationS:0,uploadResult:null};let q=P.kind==="web"?P.chrome:{instance:null,tempDir:null},Ie=q.instance;Ie&&r.register("chrome",()=>{try{Ie?.kill()}catch{}});let dr=Ar(q.cdpEndpoint),G=null,Rn=!1,It=()=>{if(!G?.diedUnexpectedly)return!1;if(!Rn){Rn=!0;let a=G.stderr.slice(-500);d.log("error","RUNNER_FATAL_DEATH","v16-runner exited unexpectedly mid-session",{stderr_tail:a}),process.stderr.write(`error: v16-runner exited unexpectedly mid-session \u2014 remaining steps skipped.
52
- `)}return!0},z=null,En=q.cdpEndpoint??K.cdp_endpoint;if(En&&!K.ws_endpoint&&!K.headless&&!e.isAgent)try{z=Jr({headless:K.headless??!1,cdpEndpoint:En,chromePid:Ie?.process.pid}),z&&r.register("marker-overlay",()=>z?.kill())}catch(a){d.log("warn","OVERLAY_SPAWN_FAILED","Marker overlay spawn failed",{error:String(a)})}c.resolvedCreds?.org_id!==void 0&&d.setOrgId(String(c.resolvedCreds.org_id)),!s.local&&c.resolvedCreds?.user_id!==void 0&&d.setCompletionIdentity(Number(c.resolvedCreds.user_id)),d.setUserIdentity(c.resolvedCreds?.username??null,c.resolvedCreds?.email??null);let xe=Ws({objective:"",globalDir:ye(Dt,"variables"),localDir:ye(o,".testmuai","variables"),file:s.variablesFile,inline:s.variables,parameters:we?.parameters}),_i=i.rootGlobal.variables??{},ae=Xa(xe.raw,_i);d.setAuteurVariables(ae.auteur);let Cn=on(ye(Dt,"global-memory.md"))??void 0,An=on(ye(o,".testmuai","context.md"))??void 0;s.local?process.stderr.write(`info: --local \u2014 cloud upload skipped
53
- `):c.basicAuth?B||(Sn?process.stderr.write(`warn: cloud upload skipped \u2014 no project configured.
54
- `):process.stderr.write(`warn: evidence publish will be skipped \u2014 no project_id in meta.json or config.
55
- `)):process.stderr.write(`warn: cloud upload skipped \u2014 TMS credentials could not be resolved.
56
- Run 'kane-cli login' (OAuth) or 'kane-cli config set-username/set-access-key' (basic auth).
57
- `);let $e=!s.local&&!!c.basicAuth&&B!=null;if(d.log("info","PIPELINE_GATE_STATE","Initial gate state (run-start)",{phase:"run-start",shouldUploadArtifacts:$e,lockHeld:C,isFirstRun:h.isFirstRun,hasAuth:h.hasAuth}),$e&&h.testId==null&&!h.degradedReadonly){let a=te(m);try{let u=await ci({tmsBaseUrl:a.tmsBaseUrl,auth:c.basicAuth,objective:i.steps[0].objective,url:"",projectId:B,folderId:Se??"",hasCustomProfile:!!K.chrome_profile,...P.kind==="device"?{mobile:di({platform:P.device.platform,appId:P.appId,deviceName:ie.deviceName,osVersion:ie.osVersion,udid:P.device.udid})}:{},log:(f,y,w,g)=>d.log(f,y,w,g)});u&&d.setTestId(u)}catch(u){process.stderr.write(`warn: ATM test creation failed: ${u.message}
58
- `)}}else h.testId&&d.setTestId(h.testId);let _t={};if(c.basicAuth&&!s.local&&(ae.secretEntries.length>0||ae.nonSecretEntries.length>0))try{_t=await Ys({variables:ae,auth:c.basicAuth,orgId:String(c.resolvedCreds?.org_id??""),env:m,localMode:!!s.local,log:(a,u,f,y)=>d.log(a,u,f,y)})}catch(a){process.stderr.write(`warn: variable/secret push failed: ${a.message}
59
- `)}let cr=new Map;for(let[a,u]of ae.nonSecretEntries)cr.set(a,u.value);let ur=new Map;for(let[a,u]of ae.secretEntries)ur.set(a,u.value);async function mr(a){if(!c.basicAuth||s.local)return;let u=[],f=[];for(let[w,g]of Object.entries(a))if(!dt(g))if(g.secret){if(ur.get(w)===g.value)continue;f.push([w,g])}else{if(cr.get(w)===g.value)continue;u.push([w,g])}if(u.length===0&&f.length===0)return;let y=te(m);if(u.length>0){let w=new Qe(y.tmsBaseUrl,c.basicAuth.username,c.basicAuth.access_key);for(let[g,_]of u)try{let D=await w.upsertVariable({name:g,value:_.value});_t[g]=D.id,cr.set(g,_.value),d.log("info","VAR_PUSH_STEP","Variable updated mid-run",{name:g})}catch(D){d.log("warn","VAR_PUSH_STEP_FAILED","Mid-run variable push failed",{name:g,error:String(D)})}}if(f.length>0){let w=new Je(y.secretsBaseUrl);for(let[g,_]of f)try{await w.pushSecret({secretKey:g,secretValue:_.value,username:c.basicAuth.username,accessKey:c.basicAuth.access_key,orgId:String(c.resolvedCreds?.org_id??"")}),ur.set(g,_.value),d.log("info","SECRET_PUSH_STEP","Secret updated mid-run",{name:g})}catch(D){d.log("warn","SECRET_PUSH_STEP_FAILED","Mid-run secret push failed",{name:g,error:String(D)})}}}let it=st?(a,u,f,y)=>{if(!(C||h.isFirstRun))return;if(L&&y){vs(L.packTestDir,y,st,(g,_,D,F)=>d.log(g,_,D,F));return}let w=vt+u;ws(d.sessionDir,w,a,st,(g,_,D,F)=>d.log(g,_,D,F),f)}:void 0,xn=i.rootTitle??i.rootSteps[0]?.heading??Ze(n),ki=Object.keys(ae.raw).length>0?He(ae.raw,xn).objective:xn,Re=ks({flag:s.url,frontmatter:i.rootGlobal?.url,configDefault:E.load().default_url}),Si=Ss({resolvedUrl:Re,local:!!s.local,allowMissingUrl:!!s.allowMissingUrl,isTTY:!l});d.setFirstRun(ki,Re??"");let le=new qt(i),kt=new Date().toISOString(),Pn=Date.now(),fr=e.evidenceAttach?null:new Ro({origin:"testmd",runKind:"author",pid:process.pid,title:i.rootTitle??Ze(n),started:kt,producerVersion:Tt,surfaces:Re?[Re]:void 0,testmdRelPath:Ya(o,n),definition:{path:"test.md",content:yi(n,"utf8")},cwd:o,packRootDir:ye(d.sessionDir,"evidence")}),ee=Ja(e.evidenceAttach,fr),Q=ee.session,L=null;if(e.evidenceAttach)L={executionId:e.evidenceAttach.id,testId:e.evidenceAttach.test,packTestDir:e.evidenceAttach.packTestDir};else if(fr)try{L=await fr.start()}catch(a){d.log("warn","EVIDENCE_START_FAILED","Evidence pack creation failed",{error:String(a)})}let Pe=[],St=[],Tn,Be,pr=(a,u,f,y,w)=>{if(!L)return;Q.noteSpawn(w?.length?{...a,steps:a.steps.map(_=>({..._,verifies:w}))}:a),a.resolution&&(Tn=a.resolution),Be=ho(Be,a.runnerEnvironment),Pe.push(Qa(u));let g=tr(u,y);for(let _=0;_<g;_++)St.push(f+_)},gr=()=>L?{packTestDir:L.packTestDir,ordinalOffset:Q.nextOrdinalOffset()}:void 0,Dn=async a=>{if(!L||!Q)return;let u=vo(Pe.length?Pe:[{resultCode:null}]);await Q.archiveAttempt(u,a,{log:(f,y,w,g)=>d.log(f,y,w,g)}),Pe.length=0,St.length=0},Ri=typeof s.maxSteps=="string"&&s.maxSteps!==""?parseInt(s.maxSteps,10):void 0,br=[],Et=Ye.hasBlocks(i.steps)?new Ye(i.steps,h.decisions,{evaluate:async a=>{let u=d.nextRunIndex(),f=rt===0,w={...en({objective:a.join(`
60
- `),conditions:a,url:f&&P.kind!=="device"?Re??void 0:void 0,model:x,chrome:q,auth:c,sessionId:d.sessionId,runIndex:u,projectId:s.local?null:B,windowSize:{width:1920,height:1080},maxSteps:1,headless:K.headless??!1,disableAskUser:!0})};delete w.run_id,Ft(w,{environment:m});let g=null;try{for await(let _ of G.run(`run-${u}`,"evaluate",w)){if(t.onAgentEvent(_),_.type==="run_end"){g=_;break}if(_.type==="error")break}}catch(_){d.log("error","BLOCK_CONDITION_JUDGE_FAILED","evaluate run failed",{error:_.message})}return f&&g&&rt++,d.log("info","BLOCK_CONDITION_JUDGED","Control-flow conditions judged",{conditions:a,results:g?.condition_results??null,reasons:g?.condition_reasons??null}),g?.condition_results??a.map(()=>null)},whileConfig:a=>Zt(i.steps[a]),sleep:a=>new Promise(u=>setTimeout(u,a))}):null;async function Ln(a){if(!Et)return null;let u=await Et.before(a),f=i.steps[a];switch(u.action){case"run":return null;case"author":return{kind:"author"};case"skip":return{kind:"done",stop:null};case"structural":return at(a),le.recordStep(f,{status:"passed",duration_s:0}),d.log("info","BLOCK_STRUCTURAL_STEP","Control-flow marker step",{step:f.flatIndex,marker:f.controlFlow}),{kind:"done",stop:null};case"jump":return d.log("info","BLOCK_WHILE_REENTER","While condition holds \u2014 re-entering the body",{from:f.flatIndex,to:u.to+1}),{kind:"jump",to:u.to};case"fail":return at(a),le.recordStep(f,{status:"failed",duration_s:0,reason:u.reason}),d.log("error","BLOCK_STEP_FAILED",u.reason,{step:f.flatIndex}),{kind:"done",stop:{failedAt:a,cancelled:!1}}}}async function On(a){let u=i.steps[a];at(a),rt++,me=!0,bt.add(i.steps[a].flatIndex);let f=d.nextRunIndex();vt=f,await mr(Xe(xe.raw,u.config.variables,u.objective).raw);let y=hr(a,f),w=Date.now(),g=null,_=null,D=null,F=!1,R=0,T=Bt(),O={...y};delete O.run_id,Ft(O,{environment:m});let k=`run-${f}`;try{z?.setRunActive(!0);try{for await(let A of G.run(k,"author",O)){if(t.onAgentEvent(A),T=Cr(T,A),A.type==="bifurcation"){let M=A.count??A.flows?.length??0;(A.is_single_flow??M<=1)||(D=A.flows??null,F=!0,R=0)}else if(A.type==="run_start"&&F)R++;else if(A.type==="step_event"&&A.event==="reasoning")z?.setStepText(A.detail);else if(A.type==="step_end"&&(A.status==="passed"&&z?.setStepComplete(),it)){let M=F?Math.max(0,R-1):0;it(A.index,M,A.child_id,typeof A.ordinal=="number"&&A.id?{ordinal:A.ordinal,id:A.id}:void 0)}if(A.type==="run_end"){g=A;break}if(A.type==="error"){_=A.message??"runner error";break}}}finally{z?.setRunActive(!1)}}catch(A){_=A.message}G.diedUnexpectedly&&It();let $=Math.round((Date.now()-w)/1e3),W=Rt(a,f,g,D,_,$);return d.recordStepRun({testmdStepIndex:i.steps[a].flatIndex,runIndex:f,totalRunDirs:tr(g,D)}),ir+=ot(g),Ne+=ot(g),pr(T,g,f,D,i.steps[a].verifies),{continueOverall:W}}async function jn(a){if(U||e.signal?.aborted)return{failedAt:a,cancelled:!0};if(It())return{failedAt:a,cancelled:!1};let u=i.steps[a],f=h.decisions[a];if(f.kind!=="replay")return process.stderr.write(`error: runReplayPhase invoked on a non-replay decision at step ${a}
61
- `),{failedAt:a,cancelled:!1};let y=d.nextRunIndex();vt=y;let w=or(a)?Re??void 0:i.steps[a].unitEntryUrl,g={width:H.window_size.width,height:H.window_size.height},_=Xe(xe.raw,u.config.variables,u.objective),D=Hr({step:u,decision:f,chrome:q,device:P.kind==="device"?P.device:void 0,auth:c,sessionId:d.sessionId,runIndex:y,sessionDir:d.sessionDir,windowSize:g,environmentId:wt,forceNavigateUrl:P.kind==="device"?void 0:w,sessionContext:d.getContext(),variables:Object.keys(_.variables).length>0?_.variables:void 0,evidence:gr(),investigationAsync:!ee.ownsLifecycle});await mr(_.raw),at(a),rt++;let F=Date.now(),R=null,T=null,O=Bt(),k={...D};delete k.run_id,Ft(k,{environment:m});let $=`run-${y}`;try{z?.setRunActive(!0);try{for await(let N of G.run($,"replay",k)){if(t.onAgentEvent(N),O=Cr(O,N),N.type==="step_event"&&N.event==="reasoning"?z?.setStepText(N.detail):N.type==="step_end"&&(N.status==="passed"&&z?.setStepComplete(),it&&it(N.index,0,N.child_id,typeof N.ordinal=="number"&&N.id?{ordinal:N.ordinal,id:N.id}:void 0)),N.type==="run_end"){R=N;break}if(N.type==="error"){T=N.message??"runner error";break}}!ee.ownsLifecycle&&R?.status==="failed"&&br.push({exited:G.exited.then(()=>{}).catch(()=>{}),cancel:()=>{try{G?.cancel()}catch{}}})}finally{z?.setRunActive(!1)}}catch(N){T=N.message}if(G.diedUnexpectedly&&It(),U)return{failedAt:a,cancelled:!0};let W=Math.round((Date.now()-F)/1e3),A=Rt(a,y,R,null,T,W);d.recordStepRun({testmdStepIndex:i.steps[a].flatIndex,runIndex:y,totalRunDirs:tr(R,null)}),pr(O,R,y,null,i.steps[a].verifies),Ne+=ot(R);let M=!!T||R?.status==="failed";return is(a,M?"failed":"ok"),M||!A?{failedAt:a,cancelled:!1}:null}async function Ei(a){ss(a,i.steps.length),Et?.reset();for(let u=0;u<a;u++){let f=await Ln(u);if(f?.kind==="done"){if(f.stop)return f.stop;continue}if(f?.kind==="jump"){u=f.to-1;continue}if(f?.kind==="author"){let w=i.steps[u];if(w.replayOnly)return Le(u,w.replayOnly),Me(u,w.replayOnly),le.recordStep(w,{status:"failed",duration_s:0,reason:`replay-only step @${w.replayOnly} has no recording`}),{failedAt:u,cancelled:!1};if(!(await On(u)).continueOverall)return{failedAt:u,cancelled:!1};continue}let y=await jn(u);if(y)return y}return{failedAt:null,cancelled:!1}}let Un=async()=>{if(C||h.degradedReadonly)return!0;let a=c.basicAuth;if(!a){let g=await c.resolver.resolve(!0);g?.username&&g?.access_key&&(a={username:g.username,access_key:g.access_key},c.basicAuth=a)}if(!h.testId||!h.fromCommitId||!a)return process.stderr.write(`error: cannot acquire lock \u2014 missing required state
62
- `),!1;let u=d.sessionId,f=s.onLockConflict??i.rootGlobal.on_lock_conflict??"readonly",y=await gn({tmsBaseUrl:b.tmsBaseUrl,testId:h.testId,fromCommitId:h.fromCommitId,newCommitId:u,basicAuth:a,onLockConflict:f}),w=y.outcome;if(w==="ok"){C=!0,h.newCommitId=u,d.log("info","MID_RUN_LOCK_ACQUIRED","Mid-run lock acquired",{test_id:h.testId}),l&&t.onLockState({phase:"acquired",scope:"mid_run"}),Gt({baseUrl:et(b.tmsBaseUrl),testId:h.testId,auth:tt(a),lifecycle:r});let g=await vi({resolved:i,decisions:h.decisions,tmsBaseUrl:b.tmsBaseUrl,newCommitId:u,basicAuth:a,mode:f,lifecycle:r,alreadyLocked:h.unitLocks,allUnits:!0});return g.outcome==="ok"?h.unitLocks.push(...g.locks):process.stderr.write(`warn: mid-run unit lock acquisition degraded (${g.outcome}) \u2014 affected units will not self-commit
63
- `),!0}if(y.outcome==="readonly"){h.degradedReadonly=!0;let g=y.reason==="disabled"?"playground disabled for this test":y.reason==="base_mismatch"?"base commit mismatch":"concurrent session";return d.log("warn","MID_RUN_LOCK_READONLY","Mid-run lock unavailable; healing continues in readonly (no commit)",{test_id:h.testId,reason:y.reason}),l&&t.onLockState({phase:"conflict",scope:"mid_run",reason:"readonly"}),process.stderr.write(`[lock] mid-run ${g} \u2014 healing continues in readonly mode (no commit)
64
- `),!0}return d.log("error","MID_RUN_LOCK_CONFLICT","Mid-run lock acquisition failed",{reason:w}),l&&t.onLockState({phase:"conflict",scope:"mid_run",reason:w}),process.stderr.write(`error: mid-run lock acquisition failed (${w})
65
- `),!1},Nn=async()=>{try{z?.kill(),z=null,Ie?.kill(),q=await Xr({config:{chrome_profile_path:K.chrome_profile??null,window_size:{width:1920,height:1080}},startUrl:Ke,headless:K.headless??!1,wsEndpoint:K.ws_endpoint,cdpEndpoint:K.cdp_endpoint,ltGrid:await kn()}),Ie=q.instance,dr=Ar(q.cdpEndpoint);let a=q.cdpEndpoint??K.cdp_endpoint;if(a&&!K.ws_endpoint&&!K.headless&&!e.isAgent)try{z=Jr({headless:K.headless??!1,cdpEndpoint:a,chromePid:Ie?.process.pid})}catch(u){d.log("warn","OVERLAY_SPAWN_FAILED","Marker overlay respawn failed",{error:String(u)})}return d.log("info","BROWSER_RECYCLED","Fresh browser brought up for the replay re-attempt",{cdp_endpoint:q.cdpEndpoint}),!0}catch(a){return d.log("error","RECYCLE_FAILED","Could not bring up a fresh browser for the replay re-attempt",{error:a.message}),process.stderr.write(`error: could not recycle the browser for the replay re-attempt: ${a.message}
66
- `),!1}},Fn=async()=>{if(P.kind!=="device"||P.device.target!=="simulator"||P.device.no_reset===!0||!P.device.udid)return;let a=await Qn("xcrun",["simctl","keychain",P.device.udid,"reset"],{timeoutMs:3e4});a.code===0?d.log("info","SIM_KEYCHAIN_RESET","Simulator keychain reset for the replay re-attempt"):d.log("warn","SIM_KEYCHAIN_RESET_FAILED","Could not reset the simulator keychain; keychain-backed login state may survive the recycle",{error:a.stderr.trim()||a.stdout.trim()})};if(l){let a=Nt();if(!a)return process.stderr.write("error: v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available.\n"),r.cleanup("marker-overlay","v16-runner not found"),r.cleanup("chrome","v16-runner not found"),await d.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:X(n),durationS:0,uploadResult:null};let u=go({environment:m,mode:v.mode??"testing",assertionMode:vn,finalValidation:In,username:c.basicAuth?.username,accessKey:c.basicAuth?.access_key,sessionId:d.sessionId});P.kind==="device"&&await po(u,P.device),G=new $t({env:u,runner:a,log:(R,T,O,k)=>d.log(R,T,O,k),sessionId:d.sessionId}),r.register("runner",()=>{(Xn()||e.signal?.aborted)&&(U=!0);try{G?.kill()}catch{}});let f=R=>{let T={...P.kind==="device"?{device:P.device}:{},cdp_endpoint:R.cdpEndpoint,ws_endpoint:R.wsEndpoint,...R.startUrl?{start_url:R.startUrl}:{},width:H.window_size.width,height:H.window_size.height,headless:K.headless??!1,model:x,session_id:d.sessionId,disable_ask_user:!0},O=Yo(he(i.rootPath));return O.length>0&&(T.media_info=O),!s.local&&B&&(T.project_id=B),c.basicAuth?(T.username=c.basicAuth.username,T.access_key=c.basicAuth.access_key):c.token&&(T.auth={type:"bearer",token:c.token}),T};await G.start(f(q));let y=async()=>{try{await G?.shutdown()}catch{}if(!await Nn())return!1;try{return G=new $t({env:u,runner:a,log:(R,T,O,k)=>d.log(R,T,O,k),sessionId:d.sessionId}),await G.start(f(q)),!0}catch(R){return d.log("error","RECYCLE_FAILED","Could not restart the persistent runner after recycle",{error:R.message}),process.stderr.write(`error: could not restart the runner for the replay re-attempt: ${R.message}
67
- `),!1}},w=async()=>{try{await G?.shutdown()}catch{}await Fn();try{return G=new $t({env:u,runner:a,log:(R,T,O,k)=>d.log(R,T,O,k),sessionId:d.sessionId}),await G.start(f(q)),P.kind==="device"&&P.device.no_reset===!0&&d.log("warn","DEVICE_RECYCLED_DIRTY","no_reset: true \u2014 the re-attempt keeps the app state the broken replay left behind"),d.log("info","DEVICE_RECYCLED","Fresh device session brought up for the replay re-attempt"),!0}catch(R){return d.log("error","RECYCLE_FAILED","Could not bring up a fresh device session for the replay re-attempt",{error:R.message}),process.stderr.write(`error: could not recycle the device session for the replay re-attempt: ${R.message}
68
- `),!1}},g=s.author===!0;g&&(Kr(),d.log("info","FORCE_AUTHOR_RUN","--author flag set; walker bypassed; identity kept"));let{authorBoundary:_,cancelledInPhase:D,shrinkCount:F}=await us({decisions:h.decisions,forceAuthor:g,hasRetry:Nr(s),onReplayOnlyFail:Me,maxShrinks:mt.maxShrinks,runReplayPhase:Ei,session:d,accumulator:le,acquireLockIfNeeded:Un,archiveAttempt:Dn,recycleBrowser:P.kind==="web"&&Ie&&ee.ownsLifecycle?y:P.kind==="device"&&!Er(P.device.target)&&ee.ownsLifecycle?w:void 0});if(yt=F>0,nt=_,sr=F,F>0&&(d.log("info","ADAPTIVE_HEAL_TRIGGERED","Adaptive heal engaged",{shrink_count:F,final_author_boundary:_}),t.onAdaptiveHeal({shrink_count:F,final_author_boundary:_,complete_reauthor:_===0})),_===0&&F>0&&d.log("info","COMPLETE_REAUTHOR_TRIGGERED","Complete reauthor fallback",{shrink_count:F}),!D&&_>=0)for(let R=_;R<i.steps.length&&!e.signal?.aborted;R++){let T=i.steps[R],O=await Ln(R);if(O?.kind==="done"){if(O.stop)break;continue}if(O?.kind==="jump"){R=O.to-1;continue}if(O?.kind==="author"&&T.replayOnly){Le(R,T.replayOnly),Me(R,T.replayOnly),le.recordStep(T,{status:"failed",duration_s:0,reason:`replay-only step @${T.replayOnly} has no recording`});break}if(It()){le.recordStep(T,{status:"failed",duration_s:0,reason:"v16-runner exited unexpectedly mid-session"});break}if(!le.shouldRunFlatStep(T))continue;let k=h.decisions[R];if(k?.kind==="replay"&&k.replayOnly){let W=await jn(R);if(W){W.cancelled||(Le(R,k.replayOnly),Me(R,k.replayOnly));break}continue}let{continueOverall:$}=await On(R);if(!$||U||e.signal?.aborted)break}}else{if(Ye.hasBlocks(i.steps))return process.stderr.write(`error: this test has if/else or while blocks (@if \u2026 @end-if, @while \u2026 @end-while), which run in agent mode only \u2014 re-run with --agent
69
- `),r.cleanup("marker-overlay","control-flow blocks need agent mode"),r.cleanup("chrome","control-flow blocks need agent mode"),await d.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:X(n),durationS:0,uploadResult:null};let{effectiveDecisions:a}=await import("./effective-decisions-UNE2TFVA.js"),{decideRetry:u}=await import("./replay-policy-A62KXE6Y.js"),f=Nr(s),y=mt.maxShrinks,w=s.author===!0;w&&(Kr(),d.log("info","FORCE_AUTHOR_RUN","--author flag set; walker bypassed; identity kept"));let g=w?0:ut(h.decisions),_=0,D=null,F=P.kind==="device"?P.device.no_reset:void 0,R=0,T=()=>R++===0?F??!1:!0,O=h.decisions.filter(A=>A.kind==="replay").length,k=h.decisions.length-O,$=[];s.push&&$.push("--push"),f||$.push("--no-adaptive-heal"),w&&$.push("--author");let W={source:n,steps:{total:h.decisions.length,replay:O,author:k},model:x,viewport:{width:H.window_size.width,height:H.window_size.height},chrome:q.cdpEndpoint??(Ue()?q.wsEndpoint?.split("?")[0]:q.wsEndpoint)??"managed",session:d.sessionName??"ephemeral",variables:{count:Object.keys(ae.raw).length,secrets:Object.values(ae.raw).filter(A=>A.secret).length,names:Object.keys(ae.raw)},flags:$,mode:v.mode??"testing"};for(;;){let A=d.snapshot(),M=le.snapshot();R=0;let N=a(h.decisions,g,w);if(_>=1){let j=g===0?`\u{1FA79} Healing \u2014 full re-author, heal budget exhausted (${_}/${y})`:`\u{1FA79} Healing ${_}/${y} \u2014 replay 0..${g-1}, re-author ${g}..${h.decisions.length-1}
70
- reason: replay miss at step ${(D??0)+1}`;process.stderr.write(j+`
71
- `)}let lt=_>=1&&g>0&&D!==null?{startIdx:0,endIdx:D,count:D}:void 0;z?.setRunActive(!0);let fe=await sl({decisions:N,resolved:i,session:d,accumulator:le,tuiConfig:H,globalConfig:W,buildStepConfigAt:(j,de)=>{let ne=hr(j,de);return P.kind==="device"&&ne.device&&(ne.device={...ne.device,no_reset:T()}),ne},buildReplayConfig:j=>{let de=h.decisions[j];if(de.kind!=="replay")throw new Error("expected replay decision at index "+j);let ne=i.steps[j];return Hr({step:ne,decision:de,chrome:q,device:P.kind==="device"?{...P.device,no_reset:T()}:void 0,auth:c,sessionId:d.sessionId,runIndex:d.nextRunIndex(),sessionDir:d.sessionDir,windowSize:{width:H.window_size.width,height:H.window_size.height},environmentId:wt,forceNavigateUrl:P.kind==="device"?void 0:j===0?Re??void 0:ne.unitEntryUrl,sessionContext:d.getContext(),variables:el(xe.raw,ne.config.variables,ne.objective),evidence:gr()})},onAnyAuthorStep:j=>{me=!0,bt.add(i.steps[j].flatIndex)},onCancel:()=>{pe=!0},topBannerModel:x,topBannerAuth:`${S.getActiveProfile()??"no profile"}/${m}`,spawnOpts:{environment:m,mode:v.mode??"testing",assertionMode:vn,finalValidation:In,log:(j,de,ne,vr)=>d.log(j,de,ne,vr)},priorAttemptRollup:lt,pushStepLevelDelta:(j,de)=>mr(Xe(xe.raw,j,de).raw),onSequencerStepEnd:(j,de,ne,vr)=>{let Ti=Math.round((Date.now()-vr)/1e3),Di=j.hadError?j.reason??"runner error":null,Li=Rt(de,ne,j.runEnd,j.bifurcationFlows??null,Di,Ti);return d.recordStepRun({testmdStepIndex:i.steps[de].flatIndex,runIndex:ne,totalRunDirs:tr(j.runEnd,j.bifurcationFlows)}),pr(j.evidence??Bt(),j.runEnd,ne,j.bifurcationFlows,i.steps[de].verifies),Ne+=ot(j.runEnd),N[de]?.kind==="author"&&(ir+=ot(j.runEnd)),Li},screenshotDispatcher:it,onReasoning:j=>z?.setStepText(j),onStepComplete:()=>z?.setStepComplete(),onSpawnStart:j=>{vt=j},host:t});if(z?.setRunActive(!1),fe.cancelled){r.cleanup("marker-overlay","user cancelled run"),r.cleanup("chrome","user cancelled run");break}if(fe.failedAt===null)break;let Pt=h.decisions[fe.failedAt],Ve=u({failedAt:fe.failedAt,shrinkCount:_,hasRetry:f,maxShrinks:y,failedAtReplayOnly:Pt?.kind==="replay"?Pt.replayOnly:void 0});if(Ve.kind==="fail"){Ve.replayOnly&&(Le(fe.failedAt,Ve.replayOnly),Me(fe.failedAt,Ve.replayOnly));break}if(!C&&!await Un()||P.kind==="web"&&Ie&&ee.ownsLifecycle&&!await Nn())break;P.kind==="device"&&ee.ownsLifecycle&&await Fn(),await Dn(fe.failedAt),d.rollback(A),le.rollback(M),Ve.kind==="complete-reauthor"?g=0:(g=Ve.newAuthorBoundary,_++),yt=!0,d.log("info","RETRY_TRIGGERED","Retry loop triggered (TTY)",{shrink_count:_,failed_at:D}),g===0&&d.log("info","COMPLETE_REAUTHOR_TRIGGERED","Complete reauthor fallback (TTY)",{shrink_count:_}),D=fe.failedAt}nt=g,sr=_}let Z=le.finalize(),Ee=Math.round((Date.now()-Pn)/1e3),Ci={session:d,resolvedAuth:c,chromeResult:q,chromeInstance:Ie??null,testId:d.testId??null,preparedVariables:ae,variableIds:_t,globalContext:Cn,localContext:An,tuiConfig:H,env:m,localMode:!!s.local},$n=!1,Bn=!1,Mn=!1,yr=!1,Vn=async(a={})=>{if(!L)return!1;if(ee.ownsLifecycle?$n:Mn)return!0;try{let u=await dr(),f=pn(me)==="replay",y=Ge(n),w=ye(d.sessionDir,"execution.json"),g=xo(L.packTestDir,f?[y,w]:[w,y],(k,$,W,A)=>d.log(k,$,W,A));we&&Po(L.packTestDir,we.evidenceRecord,(k,$,W,A)=>d.log(k,$,W,A));let{ids:_,linear:D}=g?Do(L.packTestDir):{ids:[],linear:!0},{steps:F,tail:R,unjoined:T}=To(Q.steps,_,f,D);g?T?d.log("warn","SKIPPED_TAIL_UNJOINED","Executed records don't align with the authored blob \u2014 skipped tail withheld",{executed:Q.steps.length,leaves:_.length}):R.length>0&&d.log("info","SKIPPED_TAIL_APPENDED","Unexecuted authored actions recorded as skipped",{count:R.length}):d.log("warn","SKIPPED_TAIL_NO_BLOB","No auteur blob in pack \u2014 unexecuted actions cannot be recorded as skipped",{});let O=await Q.writeResult({steps:[...F,...R],heal:{shrinkCount:sr,authorBoundary:nt,totalSteps:h.decisions.length,forced:s.author===!0,creditsConsumed:ir},spawns:Pe.length?Pe:[{resultCode:null}],tags:i.rootGlobal.tags,externalIdInput:{...we?we.externalId:{},execution_id:L.executionId,session_id:d.sessionId,commit_id:f?h.fromCommitId??d.sessionId:d.sessionId,test_id:h.testId??d.testId??void 0,testcase_id:a.testcaseId||h.testcaseId||d.testcaseId||void 0,tc_id:lr,project_id:B??void 0,folder_id:Se??void 0,org_id:d.orgId!=null?String(d.orgId):void 0,session_name:d.sessionName??ct(n),user_name:d.userName??void 0,user_email:d.userEmail??void 0,sharable_link:Cs(te(m).testManagerUiUrl,B,a.testcaseId??h.testcaseId??d.testcaseId,a.shareId)},runnerEnv:So({cdpBrowser:u,resolution:Tn,runnerEnvironment:Be,deviceName:ie.deviceName,deviceModel:ie.modelIdentifier,deviceApp:ie.app,...ge&&ie.osVersion?{deviceOsVersion:ie.osVersion}:{},pixelResolution:L?await ko(L.packTestDir):void 0}),intentEnv:bo(x,Be,ee.ownsLifecycle?void 0:pn(me)),durationMs:Date.now()-Pn,log:(k,$,W,A)=>d.log(k,$,W,A)});if(!ee.ownsLifecycle)return await Io(Q.pack,L.testId,ye(d.sessionDir,"tui.log"),{requireRealLog:!!Be?.native_platform,appiumMarks:Q.appiumMarks}),Mn=!0,d.log("info","EVIDENCE_RESULT_WRITTEN","Member result.yaml written",{execution_id:L.executionId,verdict:O}),!0;if(!Bn)try{await ns(xr(process.cwd()),$=>d.log("warn","SYNC_BEHIND",$,{}));let k=Co({cwd:process.cwd(),members:[{path:n,verdict:O,executionId:L.executionId,startedAt:new Date().toISOString(),acs:Eo(Q.steps),mode:"testmd",local:!!s.local}]});Bn=!0;for(let $ of k.warnings)d.log("warn","EXEC_SYNC",$,{});k.synced>0&&d.log("info","EXEC_SYNC",`context sync: ${k.synced} fact(s), ${k.superseded} supersession(s)`,{})}catch(k){d.log("warn","EXEC_SYNC",`exec-sync failed: ${k instanceof Error?k.message:String(k)}`,{})}try{let k=Ao(Q.pack,xr(process.cwd()));k.status==="skipped"&&d.log("warn","EVIDENCE_COVERAGE_SKIPPED",`coverage/usecases.yaml not written: ${k.reason}`,{})}catch(k){d.log("warn","EVIDENCE_COVERAGE_SKIPPED","coverage writer threw",{error:String(k)})}return await _o({executionId:L.executionId,testId:L.testId,saved:!0,runKind:pn(me),verdict:O,outputStemDir:X(n),cwd:o,packDir:Q.pack,tuiLogPath:ye(d.sessionDir,"tui.log"),expectStatusDisagrees:(s.bugDetection??H.bug_detection)==="continue",log:(k,$,W,A)=>d.log(k,$,W,A),surface:"testmd",requireRealLog:!!Be?.native_platform,appiumMarks:Q.appiumMarks}),$n=!0,d.log("info","EVIDENCE_SEALED","Evidence pack sealed",{execution_id:L.executionId,verdict:O}),!0}catch(u){return d.log("warn","EVIDENCE_SEAL_FAILED","Evidence pack seal failed",{error:String(u)}),!1}},Ct=$e&&(C||h.isFirstRun)&&!h.degradedReadonly,Ai=async()=>{if(!c.basicAuth)return null;let a=te(m),u=(me||s.push===!0)&&!pe,f=(C||h.isFirstRun)&&!pe&&Z.overallStatus==="passed"&&!h.degradedReadonly;d.log("info","PIPELINE_GATE_STATE","Derived gate state (finalize)",{phase:"finalize",shouldUploadArtifacts:$e,shouldUploadPipeline:Ct,shouldReplaceLocalOutput:u,shouldCommit:f,lockHeld:C,anyAuthorStepRan:me,cancelled:pe,overallStatus:Z.overallStatus});let y=si({mobile:P.kind==="device",environmentId:wt,session:d,env:m,auth:c,variables:ae,variableIds:_t,testParams:we?.testParams,projectId:B,folderId:Se,totalSteps:Z.outcomes.length,totalDuration:Ee,screenshotExtMap:st?.getExtMap(),codeExport:li({codeExport:s.codeExport,codeLanguage:s.codeLanguage,skipCodeValidation:s.skipCodeValidation},H.code_export),onProgress:()=>{},log:(g,_,D,F)=>d.log(g,_,D,F),shouldUploadArtifacts:Ct,shouldReplaceLocalOutput:u,shouldCommit:f,isFirstRun:h.isFirstRun,resolvedTest:i,sourcePath:n,stepRunRecords:d.getStepRunRecords(),authoredFlatIdx:[...bt],blockOutcomes:Et?.outcomes(),unitLocks:h.unitLocks,outcomes:Z.outcomes,overallStatus:Z.overallStatus,fromCommitId:h.fromCommitId,startedISO:kt,durationS:Ee,tmsIds:{testId:h.testId??d.testId??void 0,testcaseId:h.testcaseId??d.testcaseId??void 0,projectId:B??void 0,folderId:Se??void 0,orgId:d.orgId??void 0,sessionName:d.sessionName??ct(n)},tmsBaseUrl:b.tmsBaseUrl,testId:h.testId??void 0,newCommitId:h.newCommitId??void 0,basicAuth:c.basicAuth??void 0,decisions:h.decisions,wantsPush:s.push===!0,retryTriggered:yt,forceAuthor:s.author===!0,commitBox:nr,testmdSync:s.testmdSync!==!1,onAgentEvent:g=>t.onAgentEvent(g),evidence:L&&ee.ownsLifecycle?{executionId:L.executionId,packTestDir:L.packTestDir,sealedPackPath:Q.pack,cwd:o,runIndices:St,sealFn:Vn}:void 0,evidenceRead:L&&!ee.ownsLifecycle?{packTestDir:L.packTestDir,runIndices:St}:void 0,authoredExecutionPath:me?void 0:Ge(n)});h.newCommitId!=null&&(y.skipTmsFinalize=!0);let w=new Zo(y);return l?await w.execute():await t.runUpload(w,g=>{if(g.testcaseId&&g.shareId&&B)return zt(a.testManagerUiUrl,B,g.testcaseId,g.shareId)})};L&&await dr(),G&&(await G.shutdown(Ue()?{testStatus:Z.overallStatus==="passed"?"passed":"failed",remark:pe?"cancelled":`kane-cli: ${Z.overallStatus}`}:{}),r.cleanup("runner","test.md run complete"));let ue=await Zs(Ci,{performUpload:Ai,runCleanup:()=>{r.cleanup("chrome","test.md run complete")},log:(a,u,f,y)=>d.log(a,u,f,y)},{overallStatus:Z.overallStatus,outcomes:Z.outcomes,sourcePath:n,title:i.rootTitle,rootSteps:i.rootSteps,startedISO:kt,durationS:Ee,localMode:!!s.local,skipLocalWrites:!0,mobile:P.kind==="device"});ee.ownsLifecycle&&Ct&&ue.uploadResult?.success&&(yr=!0);let Kn=await Vn({testcaseId:ue.uploadResult?.testcaseId,shareId:ue.uploadResult?.shareId}),Hn=s.evidencePublish===!1,Gn=ee.ownsLifecycle&&!!L&&!!c.basicAuth&&fi({shouldUploadArtifacts:$e,lockHeld:C,isFirstRun:h.isFirstRun,sealed:Kn,testId:h.testId});if(Gn&&Hn)d.log("info","EVIDENCE_PUBLISH_SKIPPED","Replay evidence publish skipped (--no-evidence-publish)",{execution_id:L.executionId}),process.stderr.write(`info: evidence publish skipped (--no-evidence-publish)
72
- `);else if(Hn&&(C||h.isFirstRun))process.stderr.write(`note: --no-evidence-publish has no effect on author/commit runs
73
- `);else if(Gn){let a=c.basicAuth,u=L,f=B,y=await pi({controller:new Te(b.controllerBaseUrl,{username:a.username,accessKey:a.access_key}),tms:new Ut(b.tmsBaseUrl,c.resolvedCreds?.username??a.username,c.resolvedCreds?.access_key??a.access_key),testId:h.testId,sessionId:d.sessionId,executionId:u.executionId,sealedPackPath:Q.pack,projectId:f});yr=y.ok,y.ok?d.log("info","EVIDENCE_INGESTED","Replay evidence uploaded and ingested",{execution_id:u.executionId,project_id:f}):(d.log("warn","EVIDENCE_PUBLISH_FAILED","Replay evidence publish failed",{execution_id:u.executionId,stage:y.stage,error:y.error}),process.stderr.write(` \u26A0 evidence publish failed (${y.stage}): ${y.error}
74
- `)),t.onAgentEvent({type:"test_md_evidence_ingest",status:y.ok?"ok":"failed",evidence_id:u.executionId,...y.ok?{}:{stage:y.stage}})}if(V=!0,await nl(n,h,d,Z.outcomes,Z.overallStatus,kt,Ee,ue.uploadResult,H,s,{resolvedAuth:c,tmsBaseUrl:b.tmsBaseUrl},C,pe,nr.committed),h.isFirstRun&&s.testmdSync!==!1)try{let a=he(n);if(Mo({shouldUploadPipeline:Ct,uploadSucceeded:!!ue.uploadResult?.success,metaCommitId:a?.commit_id,metaTestId:a?.test_id})){let u=await Vt({sourcePath:n,testId:a.test_id,sessionId:d.sessionId,commitId:a.commit_id,controller:new Te(b.controllerBaseUrl,{username:c.basicAuth.username,accessKey:c.basicAuth.access_key})});u.ok?d.log("info","BUNDLE_SYNC_OK","testmd bundle pushed",{commit_id:a.commit_id,bytes:u.bytes}):(d.log("warn","BUNDLE_SYNC_FAILED","testmd bundle sync failed",{commit_id:a.commit_id,stage:u.stage,error:u.error}),process.stderr.write(` \u26A0 bundle sync failed (${u.stage}): ${u.error}
75
- `)),t.onAgentEvent({type:"test_md_bundle_sync",status:u.ok?"ok":"failed",commit_id:a.commit_id,path:n,...u.ok?{bytes:u.bytes}:{stage:u.stage}})}}catch(a){d.log("warn","BUNDLE_SYNC_FAILED","testmd bundle sync threw",{error:a instanceof Error?a.message:String(a)})}else h.isFirstRun&&d.log("info","BUNDLE_SYNC_SKIPPED","testmd bundle sync skipped",{reason:"flag"});let qn=te(m),At=ue.uploadResult?.testcaseId,xt=At&&ue.uploadResult?.shareId&&B?zt(qn.testManagerUiUrl,B,At,ue.uploadResult.shareId):void 0,xi=i.unitFiles.filter(a=>a.file!==i.rootPath).map(a=>{let u=i.steps.filter(g=>g.owningFile===a.file),f=u.filter(g=>bt.has(g.flatIndex)).length,w=(a.kind==="test"?he(a.file):null)?.commit_id===d.sessionId;return{path:a.file,kind:a.kind,replayed:u.length-f,authored:f,committed:w,...w?{commit_id:d.sessionId}:{}}}),zn={overallStatus:Z.overallStatus,durationS:Ee,creditsConsumed:Ne,decisions:h.decisions,outcomes:Z.outcomes,cancelled:pe,retryTriggered:yt,lockHeld:C,anyAuthorStepRan:me,isFirstRun:h.isFirstRun,wantsPush:s.push===!0,uploadResult:ue.uploadResult,shouldUploadArtifacts:$e,shouldReplaceLocalOutput:me&&!pe,shouldCommit:(C||h.isFirstRun)&&!pe&&Z.overallStatus==="passed"&&!h.degradedReadonly,committed:nr.committed,shareUrl:xt,imports:xi},{buildSummaryEvent:Pi}=await import("./SummaryBox-DGS3LVRF.js");if(l?t.onAgentEvent(Pi(zn)):await t.onSummary(zn),!l){let a=At&&B?As(qn.testManagerUiUrl,B,At):void 0;await t.onLinks({recordedTestPath:n,outputDir:X(n),shareableLink:xt,testCaseLink:a,codeExportDir:ue.uploadResult?.codeExportDir})}if(ee.ownsLifecycle&&Q&&Kn&&!e.suppressEvidenceOffer){let{offerEvidenceView:a}=await import("./evidence-EUIDOVOR.js");await a({packPath:Q.pack,env:m,isTTY:!l&&!pe&&!!process.stdin.isTTY&&!!process.stderr.isTTY,log:u=>process.stderr.write(u+`
76
- `)})}return t.onAgentEvent({type:"test_md_done",overall_status:Z.overallStatus,duration_s:Ee,session_id:d.sessionId,...xt?{share_url:xt}:{}}),await d.reportCompletedSession({runsCompleted:d.getStepRunRecords().length,creditsConsumed:Ne,durationSeconds:Ee}),{overallStatus:Z.overallStatus,exitCode:Z.overallStatus==="passed"?0:1,outputDir:X(n),durationS:Ee,creditsConsumed:Ne,uploadResult:ue.uploadResult,anyAuthorStepRan:me,resultCode:wo(Pe),...br.length?{pendingInvestigations:br}:{},ownPack:ee.ownsLifecycle?mi({executionId:L?.executionId,testId:h.testId??L?.testId,testcaseId:ue?.uploadResult?.testcaseId,commitId:d.sessionId,published:yr}):void 0}}finally{!V&&(C||h.unitLocks.length>0)&&await ol(h,d,C,{resolvedAuth:c,tmsBaseUrl:b.tmsBaseUrl})}}function Za(e){if((e.env??process.env).KANE_CLI_MODE==="hyperexecute")return null;let t=$o({globalDir:e.globalDir,localDir:ye(e.cwd,".testmuai","variables"),file:e.opts.variablesFile,inline:e.opts.variables}),r=es(e.resolved,t,{authorFrom:e.authorFrom,produced:e.produced});return r.length===0?null:{text:Mr(r,{cwd:e.cwd,entryFile:Ze(e.resolved.rootPath)}),event:Vr(r,{cwd:e.cwd})}}function Xa(e,t){let r={...e,...t,...kr(e)},n=Object.keys(r).length>0?He(r,""):{variables:{},objective:"",keyMap:{}};return{raw:r,auteur:n.variables,auteurObjective:"",...nn(r)}}function Xe(e,t,r){let n={...e,...t??{},...kr(e)};if(Object.keys(n).length===0)return{raw:n,variables:{},objective:r};let o=He(n,r);return{raw:n,variables:zs(o.variables,o.objective),objective:o.objective}}function el(e,t,r){let n=Xe(e,t,r).variables;return Object.keys(n).length>0?n:void 0}function bi(e,t){let r=new Set(rr),n={...e};for(let[o,s]of Object.entries(t))r.has(o)||o!=="variables"&&s!==void 0&&e[o]===void 0&&(n[o]=s);return n}function tl(e,t){return e.length<=t?e:e.slice(0,t-1)+"\u2026"}async function rl(e,t,r,n,o,s){let l=Ko(t);os(t,l);let p=_e(e),i=Wa(p)?JSON.parse(yi(p,"utf8")):null,c=i?.testcase_id,v=i?.test_id,m=i?.commit_id,b=r.push===!0,I=r.author===!0;b&&!c&&process.stderr.write(`[--push] no meta.json yet \u2014 flag is a no-op on first run
77
- `);let x=n.resolvedAuth.basicAuth;if(!x){let re=await n.resolvedAuth.resolver.resolve(!0);re?.username&&re?.access_key&&(x={username:re.username,access_key:re.access_key},n.resolvedAuth.basicAuth=x)}let S=!!x,E=!r.local&&S&&v!=null&&m!=null&&c!=null,d=E&&(Kt(l)||b||I),U=Vo(t,l);if(U.length>0)return process.stderr.write(`error: replay-only step(s) cannot be replayed \u2014 the agent cannot author them, so the run will not start:
78
- `+U.map(se=>` step ${se.flatIndex} "${se.heading}" @${se.kind} \u2014 ${se.reason} (${se.file})`).join(`
79
- `)+`
80
- Regenerate the test from KaneAI, or drop the marker to let the agent author the step.
81
- `),{resolved:t,decisions:l,testId:v,testcaseId:c,fromCommitId:m,newCommitId:null,isFirstRun:!1,hasAuth:S,canLock:E,lockAcquired:!1,unitLocks:[],degradedReadonly:!1,abort:{exitCode:2}};if(b&&!E)return process.stderr.write(`error: --push requires authenticated credentials for the lock API. Run 'kane-cli login' (OAuth) or pass --username/--access-key inline.
82
- `),{resolved:t,decisions:l,testId:v,testcaseId:c,fromCommitId:m,newCommitId:null,isFirstRun:!1,hasAuth:S,canLock:E,lockAcquired:!1,unitLocks:[],degradedReadonly:!1,abort:{exitCode:2}};if(I&&!S)return process.stderr.write(`error: --author requires authenticated credentials for the TMS API. Run 'kane-cli login' (OAuth) or pass --username/--access-key inline.
83
- `),{resolved:t,decisions:l,testId:v,testcaseId:c,fromCommitId:m,newCommitId:null,isFirstRun:!1,hasAuth:S,canLock:E,lockAcquired:!1,unitLocks:[],degradedReadonly:!1,abort:{exitCode:2}};let h=null,C=!1,V=!1;if(d){h=o;let se=r.onLockConflict??t.rootGlobal.on_lock_conflict??"readonly",re=await gn({tmsBaseUrl:n.tmsBaseUrl,testId:v,fromCommitId:m,newCommitId:h,basicAuth:x,onLockConflict:se});if(re.outcome==="ok")C=!0,Gt({baseUrl:et(n.tmsBaseUrl),testId:v,auth:tt(x),lifecycle:s});else{if(re.outcome==="abort")return{resolved:t,decisions:l,testId:v,testcaseId:c,fromCommitId:m,newCommitId:null,isFirstRun:!1,hasAuth:S,canLock:E,lockAcquired:!1,unitLocks:[],degradedReadonly:!1,abort:{exitCode:2}};h=null,V=!0,I&&process.stderr.write(re.reason==="disabled"?`[lock] --author: re-authoring locally in readonly mode (not committed); this test cannot be evolved, so the changes stay local
84
- `:`[lock] --author: re-authoring locally in readonly mode (not committed); run again with --push once the playground is free
85
- `)}}let Ae=[],oe=d&&!C;if(!r.local&&S&&!oe){let se=r.onLockConflict??t.rootGlobal.on_lock_conflict??"readonly",re=await vi({resolved:t,decisions:l,allUnits:I,tmsBaseUrl:n.tmsBaseUrl,newCommitId:h??o,basicAuth:x,mode:se,lifecycle:s});if(re.outcome==="ok")Ae=re.locks;else{if(C&&v&&m&&h&&await ht(n,v,m,h),be(),re.outcome==="abort")return{resolved:t,decisions:l,testId:v,testcaseId:c,fromCommitId:m,newCommitId:null,isFirstRun:c==null,hasAuth:S,canLock:E,lockAcquired:!1,unitLocks:[],degradedReadonly:!1,abort:{exitCode:2}};process.stderr.write(`[lock] imported-unit conflict \u2014 whole run degrades to readonly (no commits, no uploads)
86
- `),h=null,C=!1,V=!0}}return{resolved:t,decisions:l,testId:v,testcaseId:c,fromCommitId:m,newCommitId:h,isFirstRun:c==null,hasAuth:S,canLock:E,lockAcquired:C,unitLocks:Ae,degradedReadonly:V}}async function vi(e){let t=new Set(e.resolved.steps.filter((n,o)=>e.decisions[o]?.kind==="author").map(n=>n.owningFile)),r=[];for(let n of e.resolved.unitFiles){if(n.kind!=="test"||n.file===e.resolved.rootPath||!e.allUnits&&!t.has(n.file)||e.alreadyLocked?.some(l=>l.file===n.file))continue;let o=he(n.file);if(!o?.test_id||!o?.commit_id)continue;let s=await gn({tmsBaseUrl:e.tmsBaseUrl,testId:String(o.test_id),fromCommitId:String(o.commit_id),newCommitId:e.newCommitId,basicAuth:e.basicAuth,onLockConflict:e.mode});if(s.outcome==="ok"){r.push({file:n.file,testId:String(o.test_id),fromCommitId:String(o.commit_id)}),Gt({baseUrl:et(e.tmsBaseUrl),testId:String(o.test_id),auth:tt(e.basicAuth),lifecycle:e.lifecycle});continue}if(s.outcome==="readonly"&&s.reason==="disabled"){process.stderr.write(`[lock] ${n.file}: playground disabled \u2014 this unit will not be committed
87
- `);continue}for(let l of r)await Oe({baseUrl:et(e.tmsBaseUrl),testId:l.testId,body:{commitId:e.newCommitId,fromCommitId:l.fromCommitId},auth:tt(e.basicAuth)}),be(l.testId);return{outcome:s.outcome,locks:[]}}return{outcome:"ok",locks:r}}function et(e){return`${e}/kane-cli/v1`}function tt(e){return{username:e.username,accessKey:e.access_key}}async function gn(e){let t=et(e.tmsBaseUrl),r=tt(e.basicAuth),n={baseUrl:t,testId:e.testId,fromCommitId:e.fromCommitId,newCommitId:e.newCommitId,auth:r},o=await qr(n);if(o.ok)return{outcome:"ok"};if(o.reason==="disabled")return process.stderr.write(`[lock] ${o.message}
88
- [lock] running in readonly mode (no commit)
89
- `),{outcome:"readonly",reason:"disabled"};if(!(o.reason==="concurrent"||o.reason==="base_mismatch"))return process.stderr.write(`[lock] acquire failed: ${o.reason} (HTTP ${o.httpStatus}): ${o.message}
90
- `),{outcome:"abort"};let l=o.reason,p=o.reason==="concurrent"?"concurrent session":"base commit mismatch (pull latest)";if(e.onLockConflict==="fail")return process.stderr.write(`[lock] ${p}; aborting (--on-lock-conflict fail)
91
- `),{outcome:"abort"};if(e.onLockConflict==="wait"){if(o.reason==="base_mismatch")return process.stderr.write(`[lock] base commit mismatch \u2014 pull latest; aborting
92
- `),{outcome:"abort"};for(;;){process.stderr.write(`[lock] waiting (concurrent session)...
93
- `),await new Promise(c=>setTimeout(c,3e4));let i=await qr(n);if(i.ok)return{outcome:"ok"};if(i.reason!=="concurrent")return process.stderr.write(`[lock] wait drifted to ${i.reason} (HTTP ${i.httpStatus}): ${i.message}; aborting
94
- `),{outcome:"abort"}}}return process.stderr.write(`[lock] ${p} \u2014 running in readonly mode (no commit)
95
- `),{outcome:"readonly",reason:l}}async function nl(e,t,r,n,o,s,l,p,i,c,v,m,b,I){let{decisions:x,testId:S,testcaseId:E,fromCommitId:d,newCommitId:U}=t,h=o==="passed";if(!I){let C=b?"cancelled":h?"commit did not land":o;m&&S&&d&&U&&(process.stderr.write(`[lock] run not committed (${C}); discarding playground lock
96
- `),await ht(v,S,d,U));for(let V of t.unitLocks)await ht(v,V.testId,V.fromCommitId,U??r.sessionId);be();return}be()}async function ol(e,t,r,n){let o=e.newCommitId??t.sessionId,s=e.unitLocks.length;process.stderr.write(`[lock] run exited before finalize; discarding playground lock${s?` + ${s} unit lock${s===1?"":"s"}`:""}
97
- `);try{t.log("warn","LOCKS_RELEASED_EARLY_EXIT","Run exited before finalize; discarding held playground locks",{test_id:e.testId??null,unit_locks:s})}catch{}try{r&&e.testId&&e.fromCommitId&&await ht(n,e.testId,e.fromCommitId,o);for(let l of e.unitLocks)await ht(n,l.testId,l.fromCommitId,o)}finally{be()}}async function ht(e,t,r,n){let o=e.resolvedAuth.basicAuth;if(!o){let l=await e.resolvedAuth.resolver.resolve(!0);l?.username&&l?.access_key&&(o={username:l.username,access_key:l.access_key},e.resolvedAuth.basicAuth=o)}if(!o)return;let s=await Oe({baseUrl:et(e.tmsBaseUrl),testId:t,body:{commitId:n,fromCommitId:r},auth:tt(o)});s.ok||process.stderr.write(`warn: discardLock failed: ${s.reason} (HTTP ${s.httpStatus}): ${s.message}
98
- `)}async function sl(e){let t=null,r=!1,n=0,o=-1,s=-1,l=0,p=async i=>{if(i&&i.status==="failed")return n>0&&e.decisions[n-1].kind==="replay"&&(t=n-1),null;for(;n<e.decisions.length&&!e.accumulator.shouldRunFlatStep(e.resolved.steps[n]);)n++;if(n>=e.decisions.length)return null;let c=e.decisions[n],v=e.resolved.steps[n],m=n;n++;let b=e.session.nextRunIndex();o=m,s=b,l=Date.now(),e.onSpawnStart?.(b),c.kind==="author"&&e.onAnyAuthorStep(m),await e.pushStepLevelDelta(v.config.variables,v.objective);let I=c.kind==="replay"?e.buildReplayConfig(m):e.buildStepConfigAt(m,b),x=c.kind==="replay"?"md5-match":c.reason,S=v.config??{},E={};for(let[d,U]of Object.entries(S))U!=null&&d!=="variables"&&d!=="assurance"&&(E[d]=U);return{config:I,banner:{stepLabel:`Step ${m+1}/${e.decisions.length}`,objective:tl(v.objective,100)},mode:c.kind,modeReason:x,perStepOverrides:Object.keys(E).length>0?E:void 0}};return await e.host.runSteps({topBanner:{model:e.topBannerModel,auth:e.topBannerAuth},globalConfig:e.globalConfig,getNextStep:p,onStepEnd:i=>(i.status==="failed"&&o>=0&&e.decisions[o]?.kind==="replay"&&(t=o),e.onSequencerStepEnd(i,o,s,l)),onAllComplete:()=>{},onCancel:()=>{r=!0,e.onCancel()},spawnOpts:e.spawnOpts,priorAttemptRollup:e.priorAttemptRollup,screenshotDispatcher:e.screenshotDispatcher,onReasoning:e.onReasoning,onStepComplete:e.onStepComplete}),{failedAt:t,cancelled:r}}export{ii as a,Is as b,_s as c,Wt as d,Wl as e,Ls as f,Jr as g,Sl as h,vs as i,ws as j,Pl as k,Yr as l,ks as m,Ss as n,zt as o,Cs as p,As as q,Ue as r,Us as s,Xr as t,Ns as u,ad as v,ld as w,dd as x,en as y,Je as z,zs as A,Ws as B,Ys as C,Qs as D,on as E,si as F,kc as G,li as H,di as I,ci as J,ui as K,mn as L,Mc as M,pi as N,pn as O,fm as P,Xa as Q,Xe as R,el as S,bi as T};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as A}from"./chunk-YCCUBQY4.js";import{a as _}from"./chunk-MKQ7ZRDW.js";import{a as B}from"./chunk-2KVECC36.js";import{a as R}from"./chunk-CSVPZ33X.js";import{a as k}from"./chunk-DUYRCVI5.js";import{y as c}from"./chunk-CXF6AZWY.js";import{a as P}from"./chunk-HCBYKLMW.js";import{a as u,b as l}from"./chunk-C44QQJR4.js";import{a as J}from"./chunk-6YGTRKDT.js";import{e as L}from"./chunk-UR6MHSHU.js";var t=L(J(),1);var e=L(P(),1);function X(n,i,y,m){return{id:n,label:`${i} (${n}) \xB7 ${y} tests`,isActive:n===m}}function W({resolver:n,projectId:i,currentFolderId:y,env:m,onSelect:x,onCancel:w}){let[I,M]=(0,t.useState)([]),[$,d]=(0,t.useState)(!0),[O,g]=(0,t.useState)(!1),[U,N]=(0,t.useState)(null),[p,b]=(0,t.useState)("list"),[S,v]=(0,t.useState)(""),[E,f]=(0,t.useState)(null),h=(0,t.useRef)(!1);(0,t.useEffect)(()=>{if(!n){N("Login first to browse folders"),d(!1);return}let o=new AbortController;return d(!0),g(!0),(async()=>{try{let r=n.cached??await n.resolve();if(!r){N("Login first to browse folders"),d(!1),g(!1);return}let a=k(m),T=new B(a.tmsBaseUrl,r.username,r.access_key),F=(async function*(){if(o.signal.aborted)return;let s=await T.listFolders(i);yield{page:1,folders:s,totalLoaded:s.length,done:!0}})();for await(let s of F){if(d(!1),s.totalLoaded===0){h.current=!0,b("naming"),g(!1);return}M(s.folders.map(C=>X(C.id,C.name,C.test_cases_count,y))),s.done&&g(!1)}}catch(r){if(r?.name==="AbortError")return;N(r instanceof Error?r.message:String(r)),d(!1),g(!1)}})(),()=>o.abort()},[n,i,y,m]);let D=(0,t.useCallback)(o=>{let r=o.trim();if(!r){f("Name cannot be empty");return}if(!i){f("No project selected \u2014 pick a project first");return}f(null),b("creating"),(async()=>{try{if(!n)throw new Error("Not authenticated");let a=n.cached??await n.resolve();if(!a)throw new Error("Not authenticated");let T=k(m),s=await new B(T.tmsBaseUrl,a.username,a.access_key).createFolder(i,r);x(s.id,s.name)}catch(a){f(a instanceof Error?a.message:String(a)),b("naming")}})()},[n,i,m,x]),H=(0,t.useCallback)(()=>{v(""),f(null),h.current?w():b("list")},[w]);return p==="naming"||p==="creating"?(0,e.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:c.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:c.orange,bold:!0,children:"Create new folder"}),h.current&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.dim,children:"No folders yet \u2014 let's create one."})}),(0,e.jsxs)(u,{marginTop:1,children:[(0,e.jsx)(l,{color:c.dim,children:"Name: "}),p==="naming"?(0,e.jsx)(A,{value:S,onChange:o=>{v(o),E&&f(null)},onSubmit:D,onCancel:H}):(0,e.jsx)(l,{children:S})]}),E&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.red,children:E})}),p==="creating"&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.dim,children:"Creating..."})}),p==="naming"&&(0,e.jsx)(R,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:h.current?"cancel":"back"})]}):(0,e.jsx)(_,{title:"Folders",items:I,loading:$,loadingMore:O,preserveSelectionById:!0,error:U,itemNoun:"folders",onTab:()=>{h.current=!1,b("naming")},extraHint:"tab to create new",onSelect:o=>{let r=o.label.split(" (")[0];x(o.id,r)},onCancel:w})}export{X as a,W as b};
@@ -1,7 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as le}from"./chunk-FQNQVC5O.js";import{a as S,g as K,h as C,i as ae,j,k as ce,l as de}from"./chunk-XLSOQLVT.js";import{closeSync as Oe,existsSync as Ae,fsyncSync as qe,mkdirSync as xe,openSync as Ce,readFileSync as R,readdirSync as je,renameSync as re,rmSync as te,writeFileSync as Fe}from"fs";import{dirname as un,join as b}from"path";import{createHash as He}from"crypto";function E(e){if(e===null)return"null";let n=typeof e;if(n==="string")return JSON.stringify(e.normalize("NFC"));if(n==="boolean")return e?"true":"false";if(n==="number"){if(!Number.isFinite(e))throw new Error("non-finite number is not canonicalizable");return JSON.stringify(e)}if(Array.isArray(e))return"["+e.map(t=>t===void 0?"null":E(t)).join(",")+"]";if(n==="object"){let t=e,a=new Map;for(let o of Object.keys(t)){if(t[o]===void 0)continue;let c=o.normalize("NFC");if(a.has(c))throw new Error(`canonicalization collision: NFC-equivalent duplicate key ${JSON.stringify(c)}`);a.set(c,t[o])}return"{"+[...a.keys()].sort((o,c)=>Buffer.compare(Buffer.from(o,"utf8"),Buffer.from(c,"utf8"))).map(o=>JSON.stringify(o)+":"+E(a.get(o))).join(",")+"}"}throw new Error("unsupported type for canonicalization: "+n)}function I(e){return He("sha256").update(e).digest("hex")}function F(e,n){return"sha256:"+I(Buffer.from("assurance."+e+"\0"+E(ce(e,n)),"utf8"))}function Sn(e,n,t,a){return"sha256:"+I(Buffer.from("assurance.edge\0"+E({type:e,src:n,dst:t,props:de(e,a)}),"utf8"))}function kn(e,n){return{source_id:e,blob:n}}function Nn(e){return{...e,derived:!0}}import{existsSync as D,mkdirSync as Ge,readFileSync as X,renameSync as We,rmSync as pe,writeFileSync as ze}from"fs";import{dirname as Ke,join as J}from"path";var B=e=>J(e,"derived"),ge=e=>J(B(e),"index.json");function he(e,n){let t=n.startsWith("sha256:")?n.slice(7):n;if(!/^[A-Za-z0-9_-]{2,}$/.test(t))throw new Error(`${n} is not a fingerprint: it cannot name a node file`);return J(B(e),"nodes",t.slice(0,2),t.slice(2)+".json")}function O(){return{applied:{seq:0,hash:null},heads:{},trust:{},nodeLabel:{},forward:{},extracted:[],design_of:{},design_generation:{},exec:{},superseded:{},names:{},archivedReason:{},appliedEvents:[],eventDigests:{},completeness:{},srcOwner:{},conv:{},media:{},design_phases:{},edgeRetractions:{}}}function M(e){let n=ge(e);if(!D(n))return null;try{let t=JSON.parse(X(n,"utf8"));return t.superseded===void 0||t.names===void 0||t.archivedReason===void 0||t.appliedEvents===void 0||t.conv===void 0||t.media===void 0||t.exec===void 0||t.completeness===void 0||t.srcOwner===void 0||t.design_phases===void 0||t.edgeRetractions===void 0||t.eventDigests===void 0||t.reverse!==void 0?null:t}catch{return null}}function me(e,n){Ge(Ke(e),{recursive:!0});let t=`${e}.tmp-${process.pid}`;ze(t,n),We(t,e)}function k(e,n,t,a,i={}){let o=i.writeNodeFiles!==!1,c=new Set(n.extracted),p=new Set(n.appliedEvents);t.forEach((s,h)=>{for(let r of s.nodes){let d=he(e,r.cid);o&&!D(d)&&me(d,JSON.stringify({label:r.label,content:r.content})+`
3
- `),!(r.cid in n.trust)&&r.content.derived===!0&&(n.trust[r.cid]="derived"),n.nodeLabel[r.cid]=r.label}for(let[r,d]of Object.entries(s.source_head_moves))typeof d=="string"&&(n.srcOwner[d]=r);if(s.proposal_id!=null&&typeof s.extraction_of=="string"){c.add(s.extraction_of);let r=null;for(let d of s.edges)if(d.type===K.DERIVES&&d.props.source_cid===s.extraction_of&&typeof d.props.source_id=="string"){r=d.props.source_id;break}if(r??=n.srcOwner[s.extraction_of]??null,r!==null){let d=n.completeness[r];(!d||s.seq>=d.seq)&&(n.completeness[r]={source_cid:s.extraction_of,completeness:"complete",...s.extractor_version?{extractor_version:s.extractor_version}:{},at:s.ts,seq:s.seq})}else n.completenessSkipped=(n.completenessSkipped??0)+1}else if(s.proposal_id!=null&&Array.isArray(s.extraction_of))for(let r of s.extraction_of){c.add(r.source_cid);let d=n.completeness[r.source_id];(!d||s.seq>=d.seq)&&(n.completeness[r.source_id]={source_cid:r.source_cid,completeness:r.completeness,...r.extractor_version?{extractor_version:r.extractor_version}:{},at:r.at,seq:s.seq})}s.design_of&&((n.design_of??={})[s.design_of.uc_cid]={engine:s.design_of.engine,seq:s.seq}),s.design_generation&&((n.design_generation??={})[s.design_generation.uc_root]={gen:s.design_generation.generation,seq:s.seq});{let r=s.design_phase;r&&typeof r.uc_root=="string"&&typeof r.phase=="string"&&typeof r.generation=="number"&&((n.design_phases??={})[r.uc_root]??=[]).push({phase:r.phase,generation:r.generation,seq:s.seq,completeness:r.completeness==="partial"?"partial":"complete"})}for(let r of s.executions??[])((n.exec??={})[r.about]??=[]).push(r);for(let r of s.edges){let{quote:d,...g}=r.props,u=n.forward[r.src]??=[];u.some(l=>l.ecid===r.ecid)||u.push({...r,props:g}),s.proposal_id!=null&&r.type===K.DERIVES&&typeof r.props.source_cid=="string"&&c.add(r.props.source_cid)}for(let r of s.review)r.resolution==="approved"||r.resolution==="edited"?(n.trust[r.id]="trusted",delete n.archivedReason[r.id]):r.resolution==="rejected"?(n.trust[r.id]="archived",r.reason?n.archivedReason[r.id]=r.reason:delete n.archivedReason[r.id]):r.resolution==="reset"&&(n.trust[r.id]="derived",delete n.archivedReason[r.id]);for(let r of s.supersessions)r.kind==="node"?r.new===r.old?delete n.superseded[r.old]:n.superseded[r.old]=r.new:r.revoke?(delete n.superseded[r.ecid],delete n.edgeRetractions[r.ecid]):(n.superseded[r.ecid]=null,n.edgeRetractions[r.ecid]={at:s.ts,...r.by?{by:r.by}:{},...r.reason?{reason:r.reason}:{}});for(let r of s.names??[])n.names[r.slug]=r.cid;for(let[r,d]of Object.entries(s.source_head_moves))n.heads[r]=d;if((s.event_ids??[]).forEach((r,d)=>{p.add(r),n.eventDigests[r]=s.event_digests?.[d]??""}),s.media)for(let[r,d]of Object.entries(s.media)){let g=s.source_head_moves[r];typeof g=="string"&&(n.media[g]=d)}if(s.conv){let r=s.source_head_moves[s.conv.source_id];if(typeof r=="string"){let d=n.conv[s.conv.source_id],g=d&&d.chain.length>0?d.chain[d.chain.length-1]:null;s.conv.append_of===g?n.conv[s.conv.source_id]={turns:s.conv.turn,chain:[...d?.chain??[],r]}:n.conv[s.conv.source_id]={turns:s.conv.turn,chain:[r]}}}for(let[r,d]of Object.entries(s.source_head_moves))s.conv?.source_id!==r&&n.conv[r]!==void 0&&(n.conv[r]=typeof d=="string"?{turns:n.conv[r].turns,chain:[d]}:{turns:n.conv[r].turns,chain:[]});n.applied={seq:s.seq,hash:a[h]}}),n.extracted=[...c].sort(),n.appliedEvents=[...p].sort()}function fe(e,n){me(ge(e),JSON.stringify(n)+`
4
- `)}function Ye(e){let n=J(e,"meta.json");if(D(n))try{let t=JSON.parse(X(n,"utf8"));if(t.schema!==S||t.canonicalizer!=="v1")throw new f(`schema fence: store is ${t.schema}/${t.canonicalizer}, this build is ${S}/${"v1"} \u2014 migrate explicitly (kane-cli context rebuild after upgrading)`)}catch(t){throw t instanceof f?t:new f(`corrupt meta.json in ${e} \u2014 fix or remove it`)}}function Xe(e){Ye(e);let n=M(e),t=n!==null&&n.applied.seq>0?T(e,n.applied.seq):null;if(n!==null&&t!==null&&t!==n.applied.hash&&(pe(B(e),{recursive:!0,force:!0}),n=null),n===null){n=O();let{records:o,hashes:c}=L(e);return k(e,n,o,c),fe(e,n),n}let{records:a,hashes:i}=A(e,n.applied.seq,n.applied.hash);return a.length>0&&(k(e,n,a,i),fe(e,n)),n}function jn(e){return pe(B(e),{recursive:!0,force:!0}),Xe(e)}var Ze=new Set(["CHAIN_ERROR","DERIVED_MISSING","DERIVED_DRIFT","NODE_FILE_MISSING","NODE_FILE_MISMATCH","NODE_FILE_CORRUPT"]);function Fn(e){return Ze.has(e.code)?e.detail:`${e.code}: ${e.detail}`}function Ln(e){let n=[],t=(u,l)=>{n.push({code:u,detail:l})},a=[],i=[];try{({records:a,hashes:i}=L(e))}catch(u){return{ok:!1,issues:[{code:"CHAIN_ERROR",detail:u instanceof f?u.message:String(u)}],records:0}}let o=O();k(e,o,a,i,{writeNodeFiles:!1});let c=M(e),p=0,s=o;if(c!==null&&c.applied.seq<a.length){let u=c.applied.seq;c.applied.hash===(u===0?null:i[u-1])&&(p=a.length-u,s=O(),k(e,s,a.slice(0,u),i.slice(0,u),{writeNodeFiles:!1}))}if(c===null)t("DERIVED_MISSING","derived/index.json missing or corrupt (run kane-cli context rebuild)");else{let u=l=>JSON.stringify(Y(l));for(let l of["applied","heads","trust","nodeLabel","forward","extracted","superseded","names","archivedReason","appliedEvents","eventDigests","conv","media","design_of","design_generation","design_phases","exec","completeness","srcOwner","edgeRetractions"])u(s[l])!==u(c[l])&&t("DERIVED_DRIFT",`derived drift in index.${l} (run kane-cli context rebuild)`)}let h=new Set;for(let u of Object.values(o.forward))for(let l of u)h.add(l.ecid);let r=new Set,d=new Set;for(let u of a)for(let l of u.supersessions)l.kind==="node"?(l.old in o.nodeLabel||t("SUPERSEDE_UNKNOWN_OLD",`${l.old} (record ${u.seq})`),l.new!==null&&l.new!==l.old&&!(l.new in o.nodeLabel)&&t("SUPERSEDE_UNKNOWN_NEW",`${String(l.new)} (record ${u.seq})`),l.new===l.old?r.delete(l.old):(r.has(l.old)&&t("DOUBLE_SUPERSEDE",`${l.old} re-superseded while live (record ${u.seq})`),r.add(l.old))):(h.has(l.ecid)||t("SUPERSEDE_UNKNOWN_ECID",`${l.ecid} (record ${u.seq})`),l.revoke?(d.has(l.ecid)||t("EDGE_ORPHAN_REVOKE",`${l.ecid} revoked without a standing retraction (record ${u.seq})`),d.delete(l.ecid)):(d.has(l.ecid)&&t("EDGE_DOUBLE_RETRACT",`${l.ecid} re-retracted while already retracted (record ${u.seq})`),d.add(l.ecid)));for(let u of Object.keys(o.superseded)){let l=new Set,y=u;for(;y!==null&&y in o.superseded;){if(l.has(y)){t("SUPERSEDE_CYCLE",`chain from ${u} revisits ${y}`);break}l.add(y),y=o.superseded[y]}}for(let[u,l]of Object.entries(o.names))l in o.nodeLabel||t("NAME_UNKNOWN_TARGET",`slug ${u} \u2192 ${l} not in the graph`);for(let u of a)for(let l of u.edges){let y=o.nodeLabel[l.src]??"(unknown)",w=o.nodeLabel[l.dst]??"(unknown)";for(let m of j(l.type,y,w,l.props))t(m.code,`${l.ecid} ${m.detail}`)}let g=new Map;for(let u of Object.values(o.forward))for(let l of u){if(l.ecid in o.superseded)continue;let y=g.get(l.type)??[];y.push(l),g.set(l.type,y)}for(let[u,l]of g){let y=ae(u);if(y?.acyclic){let w=new Map;for(let v of l)w.set(v.src,[...w.get(v.src)??[],v.dst]);let m=new Map,_=v=>{m.set(v,1);for(let z of w.get(v)??[])if(m.get(z)===1||m.get(z)===void 0&&_(z))return!0;return m.set(v,2),!1};for(let v of w.keys())if(m.get(v)===void 0&&_(v)){t("EDGE_CYCLE",`live ${u} edges form a cycle reachable from ${v}`);break}}if(y?.cardinality==="one-live-per-src"||y?.cardinality==="one-live-per-src-and-dst"){let w=new Map;for(let m of l)m.dst in o.superseded||w.set(m.src,[...w.get(m.src)??[],m]);for(let[m,_]of w)_.length>1&&t("CARDINALITY_VIOLATION",`${_.length} live ${u} edges from ${m} (one-live-per-src): ecids ${_.map(v=>v.ecid).join(",")}`)}if(y?.cardinality==="one-live-per-src-and-dst"){let w=new Map;for(let m of l)m.src in o.superseded||m.dst in o.superseded||w.set(m.dst,[...w.get(m.dst)??[],m]);for(let[m,_]of w)_.length>1&&t("CARDINALITY_VIOLATION",`${_.length} live ${u} edges onto ${m} (one-live-per-dst): ecids ${_.map(v=>v.ecid).join(",")}`)}}for(let[u,l]of Object.entries(s.nodeLabel)){let y=he(e,u);if(!D(y)){t("NODE_FILE_MISSING",`missing node file for ${u} (run kane-cli context rebuild)`);continue}try{let w=JSON.parse(X(y,"utf8"));(w.label!==l||F(w.label,w.content)!==u)&&t("NODE_FILE_MISMATCH",`node file content mismatch for ${u} (run kane-cli context rebuild)`);for(let m of C(w.label,w.content))t(m.code,`${u} ${m.detail}`)}catch{t("NODE_FILE_CORRUPT",`corrupt node file for ${u} (run kane-cli context rebuild)`)}}return{ok:n.length===0,issues:n,records:a.length,...p>0?{pending:p}:{}}}function Y(e){return Array.isArray(e)?e.map(Y):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).sort(([n],[t])=>n<t?-1:1).map(([n,t])=>[n,Y(t)])):e}import{join as Qe}from"path";var ye=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function Z(e){return typeof e=="string"&&e!=="."&&e!==".."&&ye.test(e)}function Dn(e){if(!Z(e))throw new Error(`unsafe logical_id: ${JSON.stringify(e)} \u2014 must match ${String(ye)} (no path separators)`)}function we(e,n){if(!Z(n))throw new Error(`proposal id ${JSON.stringify(n)} is not a plain name (letters, digits, . _ - after a letter or digit)`);return Qe(e,"proposals",n,"proposal.json")}var q=class extends Error{},en=new Set(["UNKNOWN_LABEL","MISSING_FIELD","BAD_ENUM"]),nn=new Set(["UNKNOWN_EDGE_TYPE","ILLEGAL_EDGE","MISSING_SALIENT"]),tn=["nodes","edges","review","supersessions"],rn=/^sha256:[0-9a-f]{64}$/;function sn(e){let n=[];for(let t of e.nodes)n.push(["node cid",t?.cid]);for(let t of e.edges)n.push(["edge ecid",t?.ecid],["edge src",t?.src],["edge dst",t?.dst]);for(let t of e.supersessions)t?.kind==="node"?(n.push(["superseded cid",t.old]),t.new!==null&&n.push(["superseding cid",t.new])):n.push(["retracted ecid",t?.ecid]);for(let t of e.names??[])n.push(["named cid",t?.cid]);return n}function ve(e){let n=M(e),a=n!==null&&(n.applied.seq===0||T(e,n.applied.seq)===n.applied.hash)?n:O(),{records:i,hashes:o}=A(e,a.applied.seq,a.applied.hash);return i.length>0&&k(e,a,i,o,{writeNodeFiles:!1}),a}function be(e,n,t,a){let i=r=>new q(r);for(let r of tn)if(!Array.isArray(t[r]))throw i(`${r} is not a list`);if(typeof t.source_head_moves!="object"||t.source_head_moves===null||Array.isArray(t.source_head_moves))throw i("source_head_moves is not an object");if(t.media!==void 0&&(typeof t.media!="object"||t.media===null||Array.isArray(t.media)))throw i("media is not an object");if(t.names!==void 0&&!Array.isArray(t.names))throw i("names is not a list");for(let[r,d]of sn(t))if(typeof d!="string"||!rn.test(d))throw i(`${r} ${String(d)} is not a sha256 fingerprint`);if(t.proposal_id!=null)try{we(e,t.proposal_id)}catch(r){throw i(r instanceof Error?r.message:String(r))}let o=new Map;for(let r of t.nodes){let d=C(r.label,r.content);for(let g of d)if(en.has(g.code))throw i(`${r.cid} ${g.detail}`);if(!d.some(g=>g.code==="UNKNOWN_FIELD")&&F(r.label,r.content)!==r.cid)throw i(`${r.cid} is not the hash of its content`);o.set(r.cid,r.label)}let c=r=>n.nodeLabel[r]??o.get(r)??"(unknown)",p=r=>r in n.nodeLabel||o.has(r),s=new Set(t.edges.map(r=>r.ecid)),h=r=>s.has(r)||Object.values(n.forward).some(d=>d.some(g=>g.ecid===r));for(let r of t.edges)for(let d of j(r.type,c(r.src),c(r.dst),r.props))if(nn.has(d.code))throw i(`${r.ecid} ${d.detail}`);for(let r of t.supersessions)if(r.kind==="node"){if(!p(r.old))throw i(`supersedes ${r.old}, which the graph does not hold`);if(r.new!==null&&!p(r.new))throw i(`supersedes with ${r.new}, which the graph does not hold`);if(r.new!==r.old&&r.old in n.superseded)throw i(`${r.old} is re-superseded while already superseded`)}else{if(!h(r.ecid))throw i(`retracts edge ${r.ecid}, which the graph does not hold`);if(r.revoke&&!(r.ecid in n.superseded))throw i(`${r.ecid} is revoked without a standing retraction`);if(!r.revoke&&r.ecid in n.superseded)throw i(`${r.ecid} is re-retracted while already retracted`)}for(let r of t.names??[])if(!p(r.cid))throw i(`names ${r.slug} \u2192 ${r.cid}, which the graph does not hold`);k(e,n,[t],[a],{writeNodeFiles:!1});for(let r of t.supersessions){if(r.kind!=="node"||r.new===r.old)continue;let d=new Set,g=r.old;for(;g!==null&&g in n.superseded;){if(d.has(g))throw i(`supersession chain from ${r.old} revisits ${g}`);d.add(g),g=n.superseded[g]}}}import{existsSync as Q,mkdirSync as on,readFileSync as an}from"fs";import{dirname as _e,join as cn}from"path";var ee="unknown",Ee=()=>ee;function Zn(e){ee=e}var dn=["extract","review","pair-merge","names","retire","gap","gap-close","chat","design","execution","parked","exec-supersede","ingest","distill","conv-mint","conv-turn","archive","revert"],Re={extract:{v:1,args:["proposal","proposalId","verdicts","by","flags","judgements","probeHits","eventIds"],pins:["supersedeTarget","matches_existing","conflicts_with","depends_on_hint","read_basis_heads"]},review:{v:1,args:["verdicts","by","holdArchives"],pins:["verdicts","supersedeTarget"]},"pair-merge":{v:1,args:["survivor","merged","reason","by"],pins:["survivor","merged"]},names:{v:1,args:["assignments","by"],pins:["refs"]},retire:{v:1,args:["sourceId","reason","by"],pins:["head"]},gap:{v:1,args:["content","annotates"],pins:["annotates"]},"gap-close":{v:1,args:["targetTip","resolvedBy","sourceId","by"],pins:["gaps"]},chat:{v:1,args:["ops","judgements","by","mintable","sid"],pins:["targets","enhance","redirectTo","retract","conv"]},design:{v:1,args:["ucRef","sections","by","engine","force","forceScope","reason","generationTicket","templateVersion","phase","phaseCompleteness","eventIds","sid"],pins:["ucRef","automates","verifies","reuses","scope","depends_on","exercises","scoped_to_repoints","judgements","body_tags","forceScope"]},execution:{v:1,args:["facts","by","eventIds"],pins:["facts"]},parked:{v:1,args:["line"],pins:["facts"]},"exec-supersede":{v:1,args:["tip","raw","fileId","by"],pins:["tip","imports"]},ingest:{v:1,args:["source_id","blob","label","media","derived_blobs","eventIds"],pins:["prior_head"]},distill:{v:1,args:["watermark","by"],pins:["events"]},"conv-mint":{v:1,args:["sessionStamp","by"],pins:[]},"conv-turn":{v:1,args:["sourceId","text","force","by"],pins:["append_of"]},archive:{v:1,args:["ref","reason","by"],pins:["ref"]},revert:{v:1,args:["seq","reason","by"],pins:["target"]}};function P(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}function V(e){return e===null||typeof e=="string"||typeof e=="boolean"?!0:typeof e=="number"?Number.isFinite(e):Array.isArray(e)?e.every(V):P(e)&&Object.values(e).every(V)}var ln=e=>typeof e=="string"&&dn.includes(e);function $e(e){if(!P(e))return"intent is missing: every append names the intent it fulfils";if(!ln(e.verb))return`intent verb ${String(e.verb)} is not a writer this build knows`;let n=Re[e.verb].v;if(e.v!==n)return`intent ${e.verb} v ${String(e.v)} is not the version this build writes (v ${n})`;if(!P(e.pins)||!V(e.pins))return"intent pins is not a plain JSON object";if(!V(e.args))return"intent args is not JSON";let t=Re[e.verb];for(let a of t.args??[])if(!P(e.args)||!(a in e.args))return`intent ${e.verb} arg ${a} is missing`;for(let a of t.pins??[])if(!(a in e.pins))return`intent ${e.verb} pin ${a} is missing`;return null}function Qn(e){return JSON.parse(JSON.stringify(e))}function Se(e,n){let t=n.slice(7);return cn(e,"intents",t.slice(0,2),`${t}.json`)}function et(e,n){let t=Se(e,n);return Q(t)?JSON.parse(an(t,"utf8")):null}function ke(e,n,t){let a=Se(e,t.hash),i=_e(a),o=_e(i),c=!Q(o),p=c||!Q(i);on(i,{recursive:!0});let s={v:n.v,verb:n.verb,args:n.args,pins:n.pins,born:{...t,build:ee}};return ne(a,JSON.stringify(s)+`
5
- `),p&&U(o),c&&U(e),a}var f=class extends Error{},Le="run kane-cli context sync or kane-cli context pull to continue, or kane-cli context sync doctor --abort to close it",Ne="run kane-cli context sync doctor to see it, and kane-cli context sync doctor --abort to set the unreadable ledger aside; the backup stays";function fn(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let n=e;if(n.state!=="open"&&n.state!=="closed"||!Array.isArray(n.items))return null;let t=["applied","held","skipped","deduped"];for(let a of n.items){if(!a||typeof a!="object"||Array.isArray(a))return null;let i=a.outcome;if(i===void 0)continue;if(!i||typeof i!="object"||Array.isArray(i))return null;let o=Object.keys(i);if(o.length!==1||!t.includes(o[0]))return null;let c=i[o[0]];if(!c||typeof c!="object")return null}return n}var H=class extends f{constructor(t,a=Le){super(t);this.remedy=a}code="SYNC_REBASE_PENDING"};function pn(e){let n=b(e,"sync","replay");if(!Ae(n))return null;let t=je(n).filter(a=>a.endsWith(".json")&&!a.endsWith(".receipt.json")).sort().reverse();for(let a of t){let i=a.slice(0,-5),o;try{o=fn(JSON.parse(R(b(n,a),"utf8")))}catch{o=null}if(o===null)return{id:i,decisions:0,unreadable:!0};if(o.state==="open")return{id:i,decisions:o.items.filter(c=>c.outcome!==void 0&&c.outcome!==null&&"held"in c.outcome).length}}return null}function gn(e){let n=pn(e);if(!n)return;if(n.unreadable)throw new H(`rebase ${n.id} has a ledger this store cannot read (sync/replay/${n.id}.json); this store takes no other change until it is set aside \u2014 ${Ne}`,Ne);let t=n.decisions>0?`a rebase (${n.id}) is open with ${n.decisions} decision${n.decisions===1?"":"s"} unresolved`:`a rebase (${n.id}) is open and not finished`;throw new H(`${t}; this store takes no other change until it is finished \u2014 ${Le}`)}function hn(e){let n=e.args?.by,t=typeof n=="object"&&n!==null&&typeof n.kind=="string"&&typeof n.id=="string";return{build:Ee(),...t?{by:n}:{}}}function mn(e){return"sha256:"+I(Buffer.from(E({verb:e.verb,args:e.args,pins:e.pins})))}function W(e,n){if(e.schema_version!==void 0&&e.schema_version!==S)throw new f(`record ${n} is stamped ${e.schema_version}, this build reads ${S} \u2014 migrate explicitly`);if(e.parents!==void 0&&!(e.prev_hash===null?e.parents.length===0:e.parents.length===1&&e.parents[0]===e.prev_hash))throw new f(`record ${n}: parents does not mirror prev_hash \u2014 multi-parent records need a DAG-aware reader`)}var G=class extends f{},se=class extends f{code="CONTEXT_APPEND_BUSY"};function ie(e,n){xe(e,{recursive:!0});let t=b(e,".lock"),a=Date.now()+(n?n.deadlineMs:2e3);for(;;)try{return Fe(t,`${process.pid}
6
- `,{flag:"wx"}),()=>{try{te(t)}catch{}}}catch(i){if(i.code!=="EEXIST")throw i;if(n){let o=null,c=null;try{c=R(t,"utf8");let p=Number.parseInt(c.trim(),10);o=Number.isInteger(p)?p:null}catch{c=null}if(c!==null&&o!==null&&!le(o)){let p=`${t}.break-${process.pid}-${Date.now()}`;try{re(t,p);let s=null;try{s=R(p,"utf8")}catch{s=null}if(s===null||s===c)te(p,{force:!0});else try{re(p,t)}catch{te(p,{force:!0})}}catch(s){if(s.code!=="ENOENT")throw s}continue}if(Date.now()>a)throw new se(`.context append is busy: ${t} held ${o===null?"by a holder that has not written its pid":`by live pid ${o}`} past the deadline`);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,25+Math.floor(Math.random()*50));continue}if(Date.now()>a)throw new f(`.context is locked by another process \u2014 remove ${t} if that process is gone`);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,25)}}var yn=/^\d{6}-[0-9a-f]{12}\.json$/,wn=999999;function Te(e,n){if(e>wn)throw new f(`${n}: position ${e} is above 999,999, the highest a six-digit record file can name \u2014 the sharded commits layout is a follow-up; nothing was written`)}var $=e=>b(e,"commits");function N(e){return"sha256:"+I(Buffer.from(E(e),"utf8"))}var oe=class extends f{constructor(t){let a=[...new Set(t.map(i=>Number(i.slice(0,6))))];super(`FORKED: more than one record at position${a.length>1?"s":""} ${a.join(", ")} \u2014 another copy of this store was merged into commits/. kane-cli context sync doctor lists the files; move the foreign ones out and rebuild.`);this.duplicates=t}code="CONTEXT_FORKED"},De="000001-000000000000.json",Je="store is mid-reset: run kane-cli context sync doctor";function dt(e){return JSON.stringify({seq:1,prev_hash:null,schema_version:"assurance/context@1 :: mid-reset :: run kane-cli context sync doctor",kane:{fence:"reset",nonce:e,journal:"sync/journal.json"}})}function x(e){let{files:n,midReset:t}=Be(e);if(t)throw new f(Je);return n}function Be(e){let n=$(e);if(!Ae(n))return{files:[],midReset:!1};let t=je(n).filter(o=>yn.test(o)).sort(),a=t.indexOf(De);a>=0&&t.splice(a,1);let i=[];for(let o=0;o<t.length;o++){let c=t[o].slice(0,6);(o>0&&t[o-1].slice(0,6)===c||o+1<t.length&&t[o+1].slice(0,6)===c)&&i.push(t[o])}if(i.length>0)throw new oe(i);return{files:t,midReset:a>=0}}function L(e){let n=x(e),t=[],a=[],i=null;return n.forEach((o,c)=>{let p=R(b($(e),o),"utf8"),s;try{s=JSON.parse(p)}catch(d){throw new f(`corrupt commit record ${o}: ${String(d)}`)}if(s.seq!==c+1)throw new f(`sequence gap: expected seq ${c+1}, ${o} has ${s.seq}`);if(s.prev_hash!==i)throw new f(`broken chain at ${o}: prev_hash ${String(s.prev_hash)} != ${String(i)}`);W(s,o);let h=N(s),r=o.slice(7,19);if(!h.slice(7).startsWith(r))throw new f(`tampered record ${o}: content hash ${h} does not match filename`);t.push(s),a.push(h),i=h}),{records:t,hashes:a}}function Me(e){return Pe(e,x(e))}function Pe(e,n){if(n.length===0)return null;let t=n[n.length-1],a=R(b($(e),t),"utf8"),i;try{i=JSON.parse(a)}catch(c){throw new f(`corrupt tail record ${t}: ${String(c)}`)}W(i,t);let o=N(i);if(!o.slice(7).startsWith(t.slice(7,19)))throw new f(`tampered tail record ${t}: content hash ${o} does not match filename`);if(i.seq!==n.length)throw new f(`sequence gap at tail: ${n.length} record files but tail seq is ${i.seq}`);return{seq:i.seq,hash:o}}function lt(e){return Me(e)?.hash??null}var vn="corrupt";function T(e,n){let t=x(e)[n-1];if(!t)return null;try{return N(JSON.parse(R(b($(e),t),"utf8")))}catch{return vn}}function A(e,n,t){let a=x(e);if(a.length<n)throw new f(`derived state is ahead of the record log (applied seq ${n}, ${a.length} records) \u2014 run kane-cli context rebuild`);let i=[],o=[],c=t;for(let p=n;p<a.length;p++){let s=a[p],h=R(b($(e),s),"utf8"),r;try{r=JSON.parse(h)}catch(g){throw new f(`corrupt commit record ${s}: ${String(g)}`)}if(r.seq!==p+1)throw new f(`sequence gap: expected seq ${p+1}, ${s} has ${r.seq}`);if(r.prev_hash!==c)throw new f(`broken chain at ${s}: prev_hash ${String(r.prev_hash)} != ${String(c)}`);W(r,s);let d=N(r);if(!d.slice(7).startsWith(s.slice(7,19)))throw new f(`tampered record ${s}: content hash ${d} does not match filename`);i.push(r),o.push(d),c=d}return{records:i,hashes:o}}function ut(e,n){if(n.seq===0){if(n.hash!==null)throw new f("watermark not in chain: seq 0 cannot carry a hash");return L(e)}let t=x(e);if(t.length<n.seq)throw new f(`watermark not in chain: seq ${n.seq} is beyond the ${t.length}-record chain`);let a=t[n.seq-1],i;try{i=JSON.parse(R(b($(e),a),"utf8"))}catch(c){throw new f(`watermark record ${a} unreadable: ${String(c)}`)}let o=N(i);if(o!==n.hash)throw new f(`watermark not in chain: seq ${n.seq} hashes ${o}, watermark claims ${String(n.hash)}`);return A(e,n.seq,n.hash)}function ft(e,n,t){let a=$e(t.intent);if(a!==null)throw new f(`append refused: ${a}; nothing was written`);if("replayed_from"in n)throw new f("append refused: replayed_from is stamped by the append layer from opts.provenance; nothing was written");if("event_digests"in n||"intent_verb"in n||"created_by"in n)throw new f("append refused: event_digests, intent_verb and created_by are stamped by the append layer from the intent; nothing was written");let i=ie(e,t.busyRetry);try{return Ve(e,n,t)}finally{i()}}function pt(e,n){let t=ie(e);try{return Ve(e,n,{})}finally{t()}}function Ve(e,n,t){t.provenance||gn(e);let a=Me(e),i=(a?.seq??0)+1;Te(i,"append");let o=a?.hash??null;if(t.expectPrev!==void 0&&t.expectPrev!==o)throw new G(`concurrent append detected: validated against ${String(t.expectPrev)} but the chain head is ${String(o)} \u2014 re-open and retry`);let c={seq:i,prev_hash:o,...n,schema_version:S,parents:o===null?[]:[o],...t.intent?{intent_verb:t.intent.verb,created_by:hn(t.intent)}:{},...t.intent&&n.event_ids&&n.event_ids.length>0?{event_digests:n.event_ids.map(()=>mn(t.intent))}:{},...t.provenance?{replayed_from:t.provenance.replayed_from}:{}},p=N(c);if(t.provenance)try{be(e,ve(e),c,p)}catch(h){throw h instanceof q?new f(`replayed record would not pass this store's checks: ${h.message}; nothing was written`):h}t.intent&&ke(e,t.intent,{seq:i,hash:p,ts:c.ts});let s=Ue(e,i,p,JSON.stringify(c)+`
7
- `);return{seq:i,hash:p,file:s,record:c}}function ne(e,n){let t=`${e}.tmp-${process.pid}`,a=Ce(t,"w");try{Fe(a,n),qe(a)}finally{Oe(a)}re(t,e),U(un(e))}function U(e){try{let n=Ce(e,"r");try{qe(n)}finally{Oe(n)}}catch{}}function Ue(e,n,t,a){let i=$(e);xe(i,{recursive:!0});let o=`${String(n).padStart(6,"0")}-${t.slice(7,19)}.json`,c=b(i,o);return ne(c,a),c}var Ie=100;function gt(e,n,t,a={}){if(n.length===0)return[];if(n.length>Ie)throw new f(`import: batch of ${n.length} exceeds ${Ie} records per lock \u2014 chunk it`);let i=n[0].seq;if(!Number.isInteger(i)||i<1)throw new f(`import: batch starts at seq ${String(i)}, positions start at 1`);Te(i+n.length-1,"import");let o=[],c=t;n.forEach(({seq:s,raw:h},r)=>{let d=i+r;if(s!==d)throw new f(`import: expected seq ${d}, batch carries ${String(s)}`);let g;try{g=JSON.parse(h)}catch(y){throw new f(`import: record ${s} is not JSON: ${String(y)}`)}if(g===null||typeof g!="object"||Array.isArray(g))throw new f(`import: record ${s} is not a JSON object`);let u=g;if(u.seq!==s)throw new f(`import: expected seq ${s}, record carries ${String(u.seq)}`);if(u.prev_hash!==c)throw new f(`import: record ${s} is sealed onto ${String(u.prev_hash)}, local tail is ${String(c)}`);W(u,`import@${s}`);let l=N(u);o.push({seq:s,hash:l,raw:h}),c=l});let p=a.lockHeld?()=>{}:ie(e);try{let s=Be(e);if(s.midReset&&!bn(e,a.underReset))throw new f(Je);let h=Pe(e,s.files);if((h?.hash??null)!==t)throw new G(`import: local tail moved to ${String(h?.seq??0)} ${String(h?.hash??null)} \u2014 re-plan the pull`);if((h?.seq??0)!==i-1)throw new f(`import: batch starts at seq ${i}, local tail is at ${String(h?.seq??0)}`);return o.map(({seq:r,hash:d,raw:g})=>({seq:r,hash:d,file:Ue(e,r,d,g)}))}finally{p()}}function bn(e,n){if(!n)return!1;try{return JSON.parse(R(b($(e),De),"utf8")).kane?.nonce===n.nonce}catch{return!1}}export{E as a,I as b,F as c,Sn as d,kn as e,Nn as f,Dn as g,we as h,q as i,be as j,Zn as k,$e as l,Qn as m,Se as n,et as o,f as p,Le as q,Ne as r,fn as s,H as t,pn as u,gn as v,mn as w,G as x,se as y,ie as z,wn as A,N as B,oe as C,De as D,dt as E,L as F,Me as G,lt as H,vn as I,T as J,A as K,ut as L,ft as M,pt as N,ne as O,U as P,Ie as Q,gt as R,B as S,he as T,O as U,M as V,k as W,Xe as X,jn as Y,Fn as Z,Ln as _};
@@ -1,29 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{d as w}from"./chunk-ODU2JSMA.js";import{b,c as v}from"./chunk-VZ7KXRXB.js";import{b as $}from"./chunk-RDHWNSDP.js";import{b as E}from"./chunk-FQNQVC5O.js";var _=new Set(["delta","state-transition"]),N=/^capture baseline:/i;function R(e){return typeof e=="string"?e:e.text}function j(e){return typeof e=="object"&&e.baseline===!0||N.test(R(e).trim())}function T(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"derived"in e}function M(e,i){if(e.check_prose)return e.check_prose;let t=i.find(o=>o.ref===e.check.verified_against),n=t?.text?` \u2014 the stated promise: ${t.text}`:"",s=String(e.check.operand??e.check.within??e.check.metric??"");return e.check.kind==="forbidden-presence"?`Confirm '${s}' does NOT appear (forbidden-presence)${n}`:`Confirm ${e.check.kind} check: ${s} (${e.check.operator})${n}`}var F=/^## Step \d+ — assert\s*$/;function ae(e,i){let t=e.split(`
3
- `),n=!1;for(let s=0;s<t.length;s++){let o=/^(##\s.*?)\s@verifies\s+(.+?)\s*$/.exec(t[s]);if(!o)continue;n=!0;let c=o[2].split(",").map(a=>a.trim()).filter(Boolean).map(a=>{let r=i(a)??(a.startsWith("ac-")?a:null);if(!r)throw new Error(`@verifies ref '${a}' does not resolve to a committed AC`);return r});t[s]=`${o[1]} @verifies ${c.join(", ")}`}return{md:t.join(`
4
- `),tagged:n}}function de(e,i){if(i.length!==0&&!e.split(`
5
- `).some(t=>/^##\s/.test(t)&&w.test(t)))throw new Error("generated body has no @verifies binding for its ACs \u2014 the emitter contract is broken")}function ue(e){let i=e.split(`
6
- `);if(i[0]?.trim()!=="---")return{};let t=i.slice(1).findIndex(n=>n.trim()==="---");if(t<0)return{};try{return b(i.slice(1,t+1).join(`
7
- `))??{}}catch{return{}}}function le(e,i){if(i.length===0)return e;let t=e.split(`
8
- `);for(let n=t.length-1;n>=0;n--){if(/^## Step \d+ — assert @verifies /.test(t[n]))return e;if(F.test(t[n]))return t[n]=`${t[n].trimEnd()} @verifies ${i.join(", ")}`,t.join(`
9
- `)}return e}function fe(e,i){return i.size===0?e:e.split(`
10
- `).map(t=>{let n=t.match(/^@import\s+(\S+)\s*$/);if(n&&i.has(n[1]))return`@import ${i.get(n[1])}`;let s=t.match(/^## Import: (\S+)\s*$/);return s&&i.has(s[1])?`## Import: ${i.get(s[1])}`:t}).join(`
11
- `)}function I(e){let i=e.expected_mode??(T(e.operand)?"runtime-derived":"inferred");return{kind:e.kind,operator:e.operator,...e.operand!==void 0?{operand:e.operand}:{},..._.has(e.kind)?{baseline:e.baseline??null}:{},...e.within!==void 0?{within:e.within}:{},...e.metric!==void 0?{metric:e.metric}:{},...e.threshold!==void 0?{threshold:e.threshold}:{},...e.unit!==void 0?{unit:e.unit}:{},verified_against:e.verified_against,expected_mode:i,review_required:e.review_required??i==="runtime-derived"}}function pe(e,i,t){if(_.has(e.check.kind)&&!e.steps.some(j))throw new Error(`emitTestMd: check kind '${e.check.kind}' needs a baseline-capture step before the action (a step starting 'capture baseline: <metric>' or { baseline: true }) \u2014 the validator should have caught this`);let n=[];if(e.target){let r=d=>/^[A-Za-z0-9._/@-]+$/.test(d)?d:JSON.stringify(d);n.push("---",`target: ${e.target}`),e.app&&n.push(`app: ${r(e.app)}`),n.push("---","")}n.push(`# ${e.title}`,""),i.intent&&n.push(`> ${i.intent}`,"");for(let r of e.reuses??[])n.push(`## Import: ${r}`,"",`@import ${r}`,"");let s=[],o=e.steps.some(r=>typeof r=="object"&&(r.verifies?.length??0)>0),c=0;for(let r of e.steps){c++;let d=R(r).trim(),l=typeof r=="object"&&r.verifies?.length?` @verifies ${r.verifies.join(", ")}`:"";n.push(`## Step ${c}${l}`,"",d,""),s.push({step:c,objective:d,...j(r)?{baseline:!0}:{},...typeof r=="object"&&r.verifies?.length?{verifies:[...r.verifies]}:{}})}if(o){let r=-1;if(e.steps.forEach((d,l)=>{typeof d=="object"&&d.verifies?.includes(e.check.verified_against)&&(r=l)}),r<0)throw new Error(`emitTestMd: no tagged step claims check.verified_against (${String(e.check.verified_against)}) \u2014 the check would be dropped`);s[r].check=I(e.check)}else{c++;let r=M(e,t);n.push(`## Step ${c} \u2014 assert`,"",r,""),s.push({step:c,objective:r,check:I(e.check)})}let a=v({title:e.title,...i.title?{scenario:i.title}:{},objectives:s},{sortKeys:!0,lineWidth:-1});return{test_md:n.join(`
12
- `),objectives_yaml:a}}function me(e){let t=e.replace(/\r\n/g,`
13
- `).split(`
14
- `).map(o=>o.replace(/[ \t]+$/,""));if(t[0]?.trim()==="---"){let o=t.slice(1).findIndex(c=>c.trim()==="---");if(o>=0){let c=b(t.slice(1,o+1).join(`
15
- `))??{},a="assurance"in c;delete c.assurance,Object.keys(c).length===0&&a?t=t.slice(o+2):t=["---",...v(c,{sortKeys:!0,lineWidth:-1}).trimEnd().split(`
16
- `),"---",...t.slice(o+2)]}}let n=[];for(let o of t)o===""&&n[n.length-1]===""||n.push(o);for(;n[0]==="";)n.shift();for(;n[n.length-1]==="";)n.pop();let s=n.join(`
17
- `)+`
18
- `;return"sha256:"+$(Buffer.from("assurance.testdef\0"+s,"utf8"))}import{existsSync as O,readFileSync as W}from"fs";import{dirname as z,isAbsolute as G,resolve as Q}from"path";var A=/^@import\s+(\S+)\s*$/;function U(e){let i=new Set;for(let t=0;t<e.length;t++)if(A.test(e[t].trim()))for(let n=t-1;n>=0;n--){let s=e[n].trim();if(s!==""){s==="```"&&i.add(t);break}}return i}function q(e,i,t=new Set,n=0){if(n>10)return e;let s=e.split(`
19
- `),o=U(s);return s.map((c,a)=>{let r=A.exec(c.trim());if(!r||o.has(a))return c;let d=i(r[1]);if(!d||t.has(d.cycleKey))return c;let l=new Set(t);return l.add(d.cycleKey),q(d.body.trimEnd(),d.next,l,n+1)}).join(`
20
- `)}function V(e){return i=>{let t=e.resolve(i);if(!t)return null;let n=e.getNode(t.tip)?.content.test_md_blob;return n?{body:n,cycleKey:t.tip,next:V(e)}:null}}function D(e,i){return t=>{let n=G(t)?t:Q(e,t);if(!O(n))return null;let s=W(n,"utf8"),o=P(s);return!o||!i.resolve(o)?null:{body:J(s),cycleKey:n,next:D(z(n),i)}}}function L(e,i){let t=-1;for(let u=1;u<i;u++)if(/^assurance\s*:\s*$/.test(e[u])){t=u;break}if(t<0)return null;let n=i;for(let u=t+1;u<i;u++)if(/^[^\s#]/.test(e[u])){n=u;break}let s,o=t,c,a,r,d,l,f=!1;for(let u=t+1;u<n;u++){let p=e[u].endsWith("\r")?e[u].slice(0,-1):e[u];if(p.trim()===""||/^\s*#/.test(p))continue;o=u;let x=/^(\s+)([^\s:#][^:]*):\s*(.*)$/.exec(p);if(!x){/^\s*["']?base["']?\s*:/.test(p)&&(f=!0);continue}let[,y,B,K]=x,m=B.trimEnd();s===void 0&&(s=y);let h=y===s,k=/^([^#\s]\S*)?\s*(#.*)?$/.exec(K.trim()),S=k?.[1];m==="id"&&h&&c===void 0&&(c=u,a=S),m==="base"&&(h&&r===void 0?(r=u,d=S,l=k?.[2]):h||(f=!0)),m!=="base"&&/^["']base["']$/.test(m)&&(f=!0)}return{start:t,lastChild:o,childIndent:s,idLine:c,id:a,baseLine:r,base:d,baseComment:l,strayBase:f}}function H(e){let i=C(e);if(!i)return null;let t=e.split(`
21
- `),n=L(t,i.endLine);return n?.id?{id:n.id,...n.base!==void 0?{base:n.base}:{}}:null}function P(e){return H(e)?.id??null}function C(e){let i=e.split(`
22
- `);if(i[0]?.trim()!=="---")return null;for(let t=1;t<i.length;t++)if(i[t].trim()==="---")return{text:i.slice(1,t).join(`
23
- `),endLine:t};return null}function J(e){let i=C(e);if(!i)return e;let t=e.split(`
24
- `),n=L(t,i.endLine),s=[],o=!1;for(let a=1;a<i.endLine;a++){let r=t[a];if(n&&a>=n.start&&a<=n.lastChild){o=!1;continue}if(/^assurance\s*:\s*\{/.test(r)){o=!0;continue}o&&/^\s+\S/.test(r)||(o=!1,s.push(r))}let c=t.slice(i.endLine+1).join(`
25
- `);return s.every(a=>a.trim()==="")?c:["---",...s,"---",c].join(`
26
- `)}import{appendFileSync as Z,readdirSync as X,readFileSync as Y,rmSync as ee,statSync as te}from"fs";import{join as g}from"path";import{randomBytes as ne}from"crypto";var ie="pending-facts.ndjson",re=/^pending-facts\.(\d+)-[0-9a-f]+\.ndjson$/,we=()=>`pending-facts.${process.pid}-${ne(4).toString("hex")}.ndjson`;function $e(e,i=1/0){let t=[];for(let n of X(e)){let s=re.exec(n);if(!s)continue;let o=Number(s[1]),c=Date.now()-te(g(e,n)).mtimeMs;if(o!==process.pid&&E(o)&&c<i){t.push(n);continue}let a=Y(g(e,n),"utf8").split(`
27
- `).filter(r=>r!=="");a.length>0&&Z(g(e,ie),a.join(`
28
- `)+`
29
- `),ee(g(e,n))}return t}export{T as a,ae as b,de as c,ue as d,le as e,fe as f,pe as g,me as h,A as i,U as j,q as k,V as l,D as m,L as n,H as o,J as p,ie as q,re as r,we as s,$e as t};
@@ -1,2 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- var R={"use-case":"use-cases",ac:"ACs",scenario:"scenarios",test:"tests",gap:"gaps"},l=n=>R[n]??`${n}s`,k=n=>n==="ac"?"AC":n==="use-case"?"use-case":n,p=n=>n.kind??"use-case",C=n=>`${p(n)}:${n.temp_ref}`;function T(n){let t=n,a=t.badge??n.risk??null,u=t.why??n.summary??n.description??null;return JSON.stringify([n.title,a,u,t.extra??null,n.depends_on_hint??null])}function w(n){return n.filter(t=>t.role==="agent"&&typeof t.turnIndex=="number"&&Array.isArray(t.items)&&t.items.length>0)}function S(n){let t=new Map,a=1;for(let s of w(n)){let r=new Set;for(let o of s.items){let d=C(o);if(r.has(d))continue;r.add(d);let f=t.get(d);t.set(d,{num:f?.num??a++,ref:o.temp_ref,kind:p(o),item:o,turnIndex:s.turnIndex,fingerprint:T(o)})}}let u=[...t.values()].sort((s,r)=>s.num-r.num),c=[];for(let s of u){let r=c.find(o=>o.kind===s.kind);r?r.count++:c.push({kind:s.kind,label:l(s.kind),count:1})}return{entries:u,byRef:t,counts:c}}function $(n,t){let u=w(n).find(e=>e.turnIndex===t);if(!u)return null;let c=n.filter(e=>e.role!=="agent"||typeof e.turnIndex!="number"||e.turnIndex<=t),s=S(c),r=S(n.filter(e=>e.role!=="agent"||typeof e.turnIndex!="number"||e.turnIndex<t)),o=[],d=new Map,f=new Map,y=new Map,b=new Set;for(let e of u.items){let i=C(e);if(b.has(i))continue;b.add(i);let m=r.byRef.get(i),h=e.changed===!0,U=s.byRef.get(i).num,g=p(e);if(m&&!h&&m.fingerprint===T(e)){d.set(g,(d.get(g)??0)+1);continue}let x=!!m||h,I=x?y:f;I.set(g,(I.get(g)??0)+1),o.push({item:e,num:U,updated:x})}let A=[...d.entries()].map(([e,i])=>({label:l(e),count:i})),D=[...[...f.entries()].map(([e,i])=>`${i} new ${i===1?k(e):l(e)}`),...[...y.entries()].map(([e,i])=>`${i} updated ${i===1?k(e):l(e)}`)].join(" \xB7 ");return{fresh:o,unchanged:A,headerStats:D}}function M(n,t){let a=n.entries.filter(s=>s.turnIndex===t);if(a.length===0)return n;let u=new Map(a.map(s=>[s.ref,s])),c=[];for(let s of a){let r=c.find(o=>o.kind===s.kind);r?r.count+=1:c.push({kind:s.kind,label:l(s.kind),count:1})}return{entries:a,byRef:u,counts:c}}export{l as a,C as b,T as c,S as d,$ as e,M as f};