@testmuai/kane-cli 0.10.3 → 0.10.4

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 (424) hide show
  1. package/dist/ChatSurface-DN7VVN3Y.js +2 -0
  2. package/dist/ChromeProfilePicker-TVGWXTUU.js +2 -0
  3. package/dist/{CliFeedbackPrompt-JWCTMIGI.js → CliFeedbackPrompt-L5ILK66U.js} +1 -1
  4. package/dist/{CliUploadProgress-XFRRFRL4.js → CliUploadProgress-IU6BQLMV.js} +1 -1
  5. package/dist/{ConfigView-6JF4DOJN.js → ConfigView-LU5IRRQU.js} +1 -1
  6. package/dist/EvidenceViewOffer-DNTARDEL.js +2 -0
  7. package/dist/FolderPicker-6E5GE2K2.js +2 -0
  8. package/dist/InfoBox-SFFPLWCV.js +2 -0
  9. package/dist/LinksBox-6YDTIO6I.js +2 -0
  10. package/dist/ProfilesView-6C5HJQ3Y.js +2 -0
  11. package/dist/ProjectPicker-YIQIVXGK.js +2 -0
  12. package/dist/SaveSessionPrompt-X3N6OGYB.js +2 -0
  13. package/dist/SingleShotApp-MXNJPU6A.js +2 -0
  14. package/dist/SummaryBox-T7PDXDKS.js +2 -0
  15. package/dist/TestMdRunView-HRJSBP2C.js +2 -0
  16. package/dist/TestrunEvidenceTable-OGMWTJQF.js +2 -0
  17. package/dist/{WhoamiView-H7JNLLCY.js → WhoamiView-WGCWD7GP.js} +1 -1
  18. package/dist/{app-client-U2YYF65L.js → app-client-2RR5ATI6.js} +1 -1
  19. package/dist/app-download-ZS6ZMX2Z.js +2 -0
  20. package/dist/{assurance-job-F4L3T4VJ.js → assurance-job-QO4VJJCL.js} +1 -1
  21. package/dist/{binary-K3XMILST.js → binary-CCCTW3QQ.js} +1 -1
  22. package/dist/bind-JU4XPDN3.js +2 -0
  23. package/dist/bootstrap-BV7HAARR.js +2 -0
  24. package/dist/{bridge-2UHJOVLX.js → bridge-SPGIYAAG.js} +1 -1
  25. package/dist/{catalog-YCU6OHNV.js → catalog-ZAROGOJA.js} +1 -1
  26. package/dist/{catalog-client-MVEEHTG2.js → catalog-client-QLHCEPPZ.js} +1 -1
  27. package/dist/{changelog-5UB3AQT6.js → changelog-6L7W76ZH.js} +1 -1
  28. package/dist/chat-committer-7E3TRZ6P.js +2 -0
  29. package/dist/chat-controller-5ZBG23L6.js +2 -0
  30. package/dist/child-MNLSG77W.js +2 -0
  31. package/dist/{chunk-LRNUGKYH.js → chunk-2CJ75THZ.js} +1 -1
  32. package/dist/{chunk-UWPG5MWM.js → chunk-2EKLTUY2.js} +1 -1
  33. package/dist/{chunk-C4KAPGBS.js → chunk-2KPJ62RZ.js} +3 -3
  34. package/dist/{chunk-SMGRXKXX.js → chunk-2VLM4L3S.js} +1 -1
  35. package/dist/{chunk-ZHAMVLQZ.js → chunk-3A4KK22B.js} +1 -1
  36. package/dist/{chunk-L3BUPFAQ.js → chunk-3CFAE36M.js} +1 -1
  37. package/dist/{chunk-TU2KPOW2.js → chunk-3DFBFYTD.js} +2 -2
  38. package/dist/{chunk-6FFX4S7N.js → chunk-3HGKFRFL.js} +1 -1
  39. package/dist/{chunk-VKVYT6KZ.js → chunk-3JATEWA5.js} +2 -2
  40. package/dist/{chunk-GXQYFOBD.js → chunk-3O2RPYPM.js} +1 -1
  41. package/dist/chunk-3UY4WPMQ.js +8 -0
  42. package/dist/{chunk-6HRNG4CK.js → chunk-3VSAAB2W.js} +1 -1
  43. package/dist/{chunk-RNHSULQM.js → chunk-454IWKHT.js} +1 -1
  44. package/dist/{chunk-ZMWTRXFH.js → chunk-4DRFMDAW.js} +1 -1
  45. package/dist/{chunk-HRIDAK6Y.js → chunk-4FA44D6S.js} +1 -1
  46. package/dist/{chunk-YVVFXBT5.js → chunk-4G2T54FE.js} +1 -1
  47. package/dist/{chunk-N7IWR45S.js → chunk-4KFSSETE.js} +1 -1
  48. package/dist/chunk-4QV2RL6P.js +34 -0
  49. package/dist/{chunk-ERRIDBE7.js → chunk-4WFN23DE.js} +1 -1
  50. package/dist/{chunk-NPAUSUNM.js → chunk-4WKFM72U.js} +1 -1
  51. package/dist/{chunk-BLVDV3QQ.js → chunk-55W3WAAL.js} +1 -1
  52. package/dist/{chunk-YQZ736IQ.js → chunk-56NUPYFG.js} +1 -1
  53. package/dist/{chunk-PI7OXS62.js → chunk-5EAJO372.js} +1 -1
  54. package/dist/{chunk-35WUYKGO.js → chunk-5HJRYEOT.js} +1 -1
  55. package/dist/{chunk-Y3RJHWNK.js → chunk-5OGYXLOR.js} +1 -1
  56. package/dist/{chunk-CQDCNP7V.js → chunk-5ORBAYTU.js} +1 -1
  57. package/dist/{chunk-KKLCXRW6.js → chunk-642LB5R2.js} +1 -1
  58. package/dist/{chunk-OBNVGD5H.js → chunk-662MCICY.js} +1 -1
  59. package/dist/{chunk-PCQK62MP.js → chunk-6CMBA5SG.js} +1 -1
  60. package/dist/{chunk-X6FCXBXU.js → chunk-6FVGPKVX.js} +1 -1
  61. package/dist/{chunk-32HED7X2.js → chunk-6KUUSONE.js} +1 -1
  62. package/dist/{chunk-VCVEZEVS.js → chunk-6PURZLKM.js} +1 -1
  63. package/dist/{chunk-ZCBOHWN3.js → chunk-73EHVDL5.js} +1 -1
  64. package/dist/{chunk-QHH42RH5.js → chunk-7KASYSFM.js} +1 -1
  65. package/dist/{chunk-SJQTTEXQ.js → chunk-7V6JPZBM.js} +1 -1
  66. package/dist/{chunk-WE7HRAGO.js → chunk-7WWCIS2B.js} +1 -1
  67. package/dist/{chunk-M7A66MSK.js → chunk-A74JRNNX.js} +1 -1
  68. package/dist/{chunk-ENRFXGID.js → chunk-ABAUIIPD.js} +1 -1
  69. package/dist/{chunk-YILRYMMG.js → chunk-ABNQL3PQ.js} +1 -1
  70. package/dist/{chunk-GQAWZEA4.js → chunk-ACBNVGVJ.js} +1 -1
  71. package/dist/{chunk-YPGZ5E4I.js → chunk-AFOP7DVG.js} +1 -1
  72. package/dist/{chunk-JTNEF5ZP.js → chunk-AL6IAMYV.js} +1 -1
  73. package/dist/chunk-APXJRWIJ.js +2 -0
  74. package/dist/{chunk-EBJW6POT.js → chunk-ATCJ7EHL.js} +1 -1
  75. package/dist/{chunk-IZ66FKPC.js → chunk-BIGOLVK6.js} +1 -1
  76. package/dist/{chunk-LHJSIHLC.js → chunk-BIXABKSK.js} +1 -1
  77. package/dist/chunk-BK3LWNKB.js +102 -0
  78. package/dist/{chunk-X2MDL6S4.js → chunk-BPTWMV5L.js} +1 -1
  79. package/dist/{chunk-4CJQ7XZP.js → chunk-BV7NUIRT.js} +1 -1
  80. package/dist/{chunk-UJ37XGSP.js → chunk-BXAPTB2H.js} +3 -3
  81. package/dist/{chunk-X7S7IGCV.js → chunk-BXJNL22L.js} +1 -1
  82. package/dist/{chunk-Z24SD2EJ.js → chunk-C3DMMAFP.js} +1 -1
  83. package/dist/chunk-CBEMXSWF.js +2 -0
  84. package/dist/{chunk-IEHJG6J4.js → chunk-CVVZ6NWR.js} +1 -1
  85. package/dist/{chunk-OZNYQONA.js → chunk-DAV4ONGS.js} +3 -3
  86. package/dist/{chunk-MEBEVHGP.js → chunk-DBMDAWTA.js} +1 -1
  87. package/dist/{chunk-CNHKZE4F.js → chunk-DJ76NDW6.js} +1 -1
  88. package/dist/{chunk-ZPU3WAC4.js → chunk-DRWHVVW6.js} +1 -1
  89. package/dist/{chunk-Z47ZEFH7.js → chunk-DXXHCLFC.js} +1 -1
  90. package/dist/{chunk-35BG2EMW.js → chunk-E3C4OWSD.js} +1 -1
  91. package/dist/{chunk-KQ4XKTIZ.js → chunk-ECPSBI2Z.js} +1 -1
  92. package/dist/{chunk-X45RZIAJ.js → chunk-EG3B52WU.js} +1 -1
  93. package/dist/{chunk-EJGCIGQY.js → chunk-EOLMWSLX.js} +1 -1
  94. package/dist/{chunk-GAKBHNC4.js → chunk-EUGFABAS.js} +1 -1
  95. package/dist/{chunk-OTMHCHH6.js → chunk-EWK3UPEN.js} +1 -1
  96. package/dist/{chunk-NI3TIAD7.js → chunk-EWSNJ3IX.js} +1 -1
  97. package/dist/{chunk-SALZ6WSF.js → chunk-F4XCCOWC.js} +1 -1
  98. package/dist/{chunk-YNDELIXL.js → chunk-FH4FWIET.js} +1 -1
  99. package/dist/chunk-FQ2AMM3E.js +3 -0
  100. package/dist/{chunk-5YYCCM6K.js → chunk-FTP2K6RS.js} +1 -1
  101. package/dist/{chunk-JBKHX5ES.js → chunk-GJYMR4RT.js} +1 -1
  102. package/dist/{chunk-NHGPMYM3.js → chunk-GMSWZIAS.js} +1 -1
  103. package/dist/{chunk-AHT2ORJT.js → chunk-GPIVYCHQ.js} +1 -1
  104. package/dist/{chunk-ZDCXWEQG.js → chunk-GRQKMOKE.js} +1 -1
  105. package/dist/{chunk-E4GIGM5V.js → chunk-H6IPGZTP.js} +1 -1
  106. package/dist/{chunk-7Y55CO42.js → chunk-H6QHG62O.js} +1 -1
  107. package/dist/{chunk-MINDIQET.js → chunk-HBGYEA3O.js} +1 -1
  108. package/dist/{chunk-VO2NNXKR.js → chunk-HGKAUG7L.js} +1 -1
  109. package/dist/{chunk-Q4SMITTV.js → chunk-HMGM4KO6.js} +1 -1
  110. package/dist/{chunk-CTHUX7O4.js → chunk-I3G3IUKY.js} +1 -1
  111. package/dist/{chunk-MD3RABID.js → chunk-IDWAG6L4.js} +1 -1
  112. package/dist/{chunk-TM6VLC6V.js → chunk-IPIARGHE.js} +1 -1
  113. package/dist/chunk-IQMJJN52.js +3 -0
  114. package/dist/{chunk-WEJR2V7R.js → chunk-J3XOEMKO.js} +1 -1
  115. package/dist/{chunk-GJXO6FF7.js → chunk-JBUKEIYL.js} +1 -1
  116. package/dist/{chunk-7RELCXRW.js → chunk-JE5M5QIK.js} +1 -1
  117. package/dist/{chunk-QEM5ZRDN.js → chunk-JJDD4HPX.js} +1 -1
  118. package/dist/{chunk-NRAPCFI2.js → chunk-JM45SLKV.js} +2 -2
  119. package/dist/{chunk-GEZVC4S3.js → chunk-JM6AKCN4.js} +1 -1
  120. package/dist/{chunk-3KY7HHQU.js → chunk-JSSM2TWY.js} +1 -1
  121. package/dist/{chunk-3MD2XLE7.js → chunk-JYSIPTX3.js} +9 -8
  122. package/dist/{chunk-AVLYSNEG.js → chunk-KJZD2ADR.js} +1 -1
  123. package/dist/chunk-KLY6IQD5.js +26 -0
  124. package/dist/{chunk-LTPOMMAB.js → chunk-LB5NIDW6.js} +1 -1
  125. package/dist/{chunk-HV2CDY4K.js → chunk-LCBDNZL3.js} +1 -1
  126. package/dist/{chunk-SIHX5FW5.js → chunk-LJKTIKZY.js} +1 -1
  127. package/dist/{chunk-SXBPUUQ5.js → chunk-LLDEAV3W.js} +1 -1
  128. package/dist/{chunk-PTLOOVV4.js → chunk-LV7OWLJK.js} +1 -1
  129. package/dist/{chunk-TUSG7DIL.js → chunk-MNELOQ4J.js} +1 -1
  130. package/dist/{chunk-3ZC7GSMM.js → chunk-MOAZZKIZ.js} +1 -1
  131. package/dist/{chunk-YWWVF5OU.js → chunk-MQU6EA44.js} +1 -1
  132. package/dist/chunk-MTMHB5LF.js +2 -0
  133. package/dist/{chunk-Q4ALB7SH.js → chunk-MWLRLQ27.js} +1 -1
  134. package/dist/{chunk-OHGL4GEJ.js → chunk-MZ4GTIO2.js} +1 -1
  135. package/dist/chunk-NKJRAQ6L.js +6 -0
  136. package/dist/{chunk-LPJKNX6D.js → chunk-NMCE7VR2.js} +1 -1
  137. package/dist/{chunk-7V34ZMMS.js → chunk-OKCVG7AG.js} +1 -1
  138. package/dist/{chunk-LZGAFKYH.js → chunk-OMCJD4LH.js} +1 -1
  139. package/dist/{chunk-OOGKX4Y6.js → chunk-OSEXVHEN.js} +1 -1
  140. package/dist/{chunk-EZMRWXRT.js → chunk-OVB5GVRB.js} +1 -1
  141. package/dist/{chunk-ND6OP3O2.js → chunk-OX3ZAGCH.js} +1 -1
  142. package/dist/{chunk-LXK4B2FE.js → chunk-P43YHCF3.js} +1 -1
  143. package/dist/{chunk-ZMIKNNO6.js → chunk-P7V24ZXP.js} +1 -1
  144. package/dist/{chunk-3NWUXRSI.js → chunk-PBVNX43X.js} +1 -1
  145. package/dist/{chunk-MEMXFTLD.js → chunk-PEHVBCXM.js} +1 -1
  146. package/dist/{chunk-4UX5N7YI.js → chunk-PHKJIJ7D.js} +1 -1
  147. package/dist/{chunk-BBJAKSA7.js → chunk-PMYN3XMN.js} +2 -2
  148. package/dist/{chunk-R6TFRAMZ.js → chunk-PUNFWBRW.js} +1 -1
  149. package/dist/chunk-Q5B54TR5.js +2 -0
  150. package/dist/{chunk-KCXLRR3Q.js → chunk-QEBVYQNC.js} +1 -1
  151. package/dist/{chunk-PB6RXDWQ.js → chunk-QFA6JPVE.js} +2 -2
  152. package/dist/{chunk-TAY7J5VS.js → chunk-QLGQDNA3.js} +1 -1
  153. package/dist/{chunk-7SU53QGU.js → chunk-QOXUGYEA.js} +1 -1
  154. package/dist/{chunk-LV7224DG.js → chunk-QXZGBYGQ.js} +1 -1
  155. package/dist/{chunk-4KL3TSTT.js → chunk-QYWWL7M7.js} +4 -4
  156. package/dist/{chunk-M2E5CPPV.js → chunk-RG3FNO37.js} +1 -1
  157. package/dist/{chunk-YCVEI7BT.js → chunk-RNKJXVG2.js} +1 -1
  158. package/dist/{chunk-HBLHKQR7.js → chunk-S5PIVHPC.js} +1 -1
  159. package/dist/{chunk-LUA25RYS.js → chunk-S74NLCFZ.js} +1 -1
  160. package/dist/chunk-SBW3QVHN.js +7 -0
  161. package/dist/{chunk-2TK4MDF2.js → chunk-SMSQVGLH.js} +1 -1
  162. package/dist/{chunk-Y2HQMJGS.js → chunk-SO3IXFAJ.js} +1 -1
  163. package/dist/{chunk-T77LTLAD.js → chunk-SULRMI2J.js} +1 -1
  164. package/dist/{chunk-KL7XFNSD.js → chunk-SZQNYDST.js} +1 -1
  165. package/dist/chunk-T5FQRUI2.js +47 -0
  166. package/dist/{chunk-HVOXMCKE.js → chunk-TCK7WR3M.js} +1 -1
  167. package/dist/{chunk-OCMPWCKQ.js → chunk-TELSHQ3W.js} +1 -1
  168. package/dist/{chunk-FOLUB336.js → chunk-TFSWG7AS.js} +1 -1
  169. package/dist/{chunk-2JFRN62I.js → chunk-TLYFHPNM.js} +2 -2
  170. package/dist/{chunk-CB2BWDHG.js → chunk-TO2ROHIJ.js} +4 -4
  171. package/dist/{chunk-PRBWZXFA.js → chunk-TOOJTCON.js} +6 -6
  172. package/dist/{chunk-DQXQJJOP.js → chunk-TXRWH6HL.js} +2 -2
  173. package/dist/chunk-U5V3L5QH.js +2 -0
  174. package/dist/{chunk-WIVKLNIO.js → chunk-UVBPUZC4.js} +1 -1
  175. package/dist/{chunk-23DKB2MT.js → chunk-UVL6XQHU.js} +1 -1
  176. package/dist/{chunk-DC5F2ADJ.js → chunk-UZKVV3LW.js} +1 -1
  177. package/dist/{chunk-YDB72F4K.js → chunk-V4SL74TK.js} +1 -1
  178. package/dist/chunk-V57R4X3O.js +5 -0
  179. package/dist/{chunk-LLQWEGXD.js → chunk-W5EDS4DF.js} +1 -1
  180. package/dist/{chunk-6QH75BPJ.js → chunk-WB4JZ67W.js} +1 -1
  181. package/dist/{chunk-W54BX6HC.js → chunk-WCIRLITM.js} +1 -1
  182. package/dist/{chunk-OCVDMZWB.js → chunk-WHMCVH3T.js} +1 -1
  183. package/dist/{chunk-XKOVEMVZ.js → chunk-WMIR4UXG.js} +1 -1
  184. package/dist/chunk-WMXBRC4B.js +21 -0
  185. package/dist/{chunk-RQKMSNEU.js → chunk-WTMCDYR3.js} +1 -1
  186. package/dist/{chunk-DXIQVBMI.js → chunk-WZ3FE5MT.js} +1 -1
  187. package/dist/{chunk-3RO2YGKH.js → chunk-X3O4VGTM.js} +1 -1
  188. package/dist/{chunk-GLM5UGTF.js → chunk-X66NIHT4.js} +1 -1
  189. package/dist/{chunk-B7ZX5HEN.js → chunk-XDAFRUAJ.js} +1 -1
  190. package/dist/{chunk-JNPFEBUR.js → chunk-XDAHKZ4J.js} +1 -1
  191. package/dist/{chunk-ZCL7XIVS.js → chunk-XKJZG4GR.js} +1 -1
  192. package/dist/chunk-XTQUCCJH.js +2 -0
  193. package/dist/{chunk-SVIIUKJ2.js → chunk-Y7GSOKXS.js} +1 -1
  194. package/dist/chunk-YIBLZIXF.js +13 -0
  195. package/dist/{chunk-J4FIESTB.js → chunk-YKOZBFR3.js} +1 -1
  196. package/dist/{chunk-TM45NPWL.js → chunk-YWQNZRJG.js} +1 -1
  197. package/dist/chunk-YZP4F23B.js +18 -0
  198. package/dist/{chunk-QE4AWNOV.js → chunk-Z4O5HOFX.js} +6 -6
  199. package/dist/{chunk-KBGMQYMD.js → chunk-ZFKR5I3J.js} +1 -1
  200. package/dist/{chunk-6QCCTZO3.js → chunk-ZHENGHYZ.js} +1 -1
  201. package/dist/{chunk-SSOUYKVG.js → chunk-ZIRSTOEV.js} +1 -1
  202. package/dist/{chunk-AT7AT3AR.js → chunk-ZVSZ6DIQ.js} +5 -5
  203. package/dist/command-span-HZSKIZH7.js +2 -0
  204. package/dist/commands-X5T6YANK.js +2 -0
  205. package/dist/{committer-UO3B3S5Y.js → committer-L2HXEODA.js} +1 -1
  206. package/dist/{config-7WTZPMAH.js → config-F5Q6QX27.js} +1 -1
  207. package/dist/cover-cmd-PWUZU4HK.js +2 -0
  208. package/dist/{credentials-5WIFF5DG.js → credentials-D5KQMHCK.js} +1 -1
  209. package/dist/{deps-bundle-BLLJ2BQ4.js → deps-bundle-R7FNIV4M.js} +1 -1
  210. package/dist/{deps-resolve-WQ6J6RLI.js → deps-resolve-IF6P6NWI.js} +1 -1
  211. package/dist/design-chat-HYK3HNIM.js +2 -0
  212. package/dist/{design-committer-7YIPFKMO.js → design-committer-ZKNW5LUS.js} +1 -1
  213. package/dist/design-headless-DR7WB37W.js +2 -0
  214. package/dist/design-remote-TGUNEWEM.js +3 -0
  215. package/dist/device-env-LZB3PKMA.js +2 -0
  216. package/dist/dispatch-BGH5PVZ4.js +2 -0
  217. package/dist/doctor-PLFEA2HM.js +2 -0
  218. package/dist/{docx-convert-DO5AQYD3.js → docx-convert-PA5S2S7P.js} +1 -1
  219. package/dist/{dossier-5XKNAK6Q.js → dossier-B6KBSRJY.js} +1 -1
  220. package/dist/evidence-SRWISQMQ.js +2 -0
  221. package/dist/evolve-cmd-2BALEYZU.js +2 -0
  222. package/dist/evolve-remote-OHOUWO65.js +2 -0
  223. package/dist/exit-manager-UZ7DGXS4.js +2 -0
  224. package/dist/{explain-cmd-KNDORU2D.js → explain-cmd-A5YMPXAJ.js} +1 -1
  225. package/dist/explain-cmd-VTDAMXAW.js +12 -0
  226. package/dist/explore-UZWQRJ7H.js +2 -0
  227. package/dist/explore-context-tty-PAKJVDJU.js +2 -0
  228. package/dist/explore-entry-ZOPO7DBZ.js +6 -0
  229. package/dist/{explore-live-XIWWUV52.js → explore-live-RUAAZGX4.js} +1 -1
  230. package/dist/{explore-run-tty-M56I23IF.js → explore-run-tty-DYLMHI7F.js} +2 -2
  231. package/dist/{extract-bind-LZ22VFKB.js → extract-bind-WPICR4IC.js} +3 -3
  232. package/dist/extract-chat-KVUB5HPM.js +2 -0
  233. package/dist/{extract-cmd-46E2XDWZ.js → extract-cmd-OJ7LXSKL.js} +2 -2
  234. package/dist/extract-headless-OQJSUSG4.js +2 -0
  235. package/dist/{feeder-NGWIPZ26.js → feeder-VAY4NYBX.js} +1 -1
  236. package/dist/folder-flags-MEZUAXTT.js +2 -0
  237. package/dist/gaps-cmd-2R4RMWN6.js +3 -0
  238. package/dist/gate-SM4HPJLA.js +2 -0
  239. package/dist/gate-VJ7W5QIH.js +2 -0
  240. package/dist/{generate-headless-HXAVEAEZ.js → generate-headless-XR3RVULC.js} +3 -3
  241. package/dist/hold-passthrough-ZHOC2Q26.js +2 -0
  242. package/dist/identity-66TGWITQ.js +2 -0
  243. package/dist/{impact-cmd-TJTUFAFO.js → impact-cmd-EL3QSOAF.js} +2 -2
  244. package/dist/index.js +185 -184
  245. package/dist/ingest-6UQGSQYU.js +2 -0
  246. package/dist/ingest-cmd-N3USC7TW.js +8 -0
  247. package/dist/ingest-remote-2VKWAFJZ.js +2 -0
  248. package/dist/install-3IEM3I3X.js +2 -0
  249. package/dist/{interactive-bind-SOD7VTAY.js → interactive-bind-F7QTQOKC.js} +4 -4
  250. package/dist/{interactive-remote-7ZSTI66T.js → interactive-remote-A33J4KMP.js} +2 -2
  251. package/dist/lane-EHU4JRRU.js +2 -0
  252. package/dist/lattice-auth-IJT542IF.js +2 -0
  253. package/dist/lifecycle-cmd-OKUFZKEX.js +2 -0
  254. package/dist/list-cmd-7OTI66MQ.js +3 -0
  255. package/dist/list-commands-FZPVH76I.js +2 -0
  256. package/dist/{list-remote-EFCET42K.js → list-remote-BQ4NILCA.js} +1 -1
  257. package/dist/{locks-cmd-AZKCSGHI.js → locks-cmd-76IU4JB7.js} +1 -1
  258. package/dist/{logical-ids-74PLU3VR.js → logical-ids-YMNV2MDB.js} +1 -1
  259. package/dist/login-flow-BYQ7SYGB.js +2 -0
  260. package/dist/maintenance-cmd-BLV7K4RK.js +2 -0
  261. package/dist/mobile-prompts-5TGLJUBV.js +2 -0
  262. package/dist/onboarding-F4EIJ4GD.js +5 -0
  263. package/dist/open-provider-LXCPVNUU.js +2 -0
  264. package/dist/{pdf-convert-YB6PJFMI.js → pdf-convert-N2C3KB4Q.js} +1 -1
  265. package/dist/persist-recorded-session-WYMOHDTB.js +3 -0
  266. package/dist/phase-seed-G5JSYKSL.js +2 -0
  267. package/dist/pipeline-XYM6HIDZ.js +2 -0
  268. package/dist/{policy-commands-4PUGESCW.js → policy-commands-AOLVAZZD.js} +1 -1
  269. package/dist/prepare-target-P4AZWC37.js +2 -0
  270. package/dist/pull-cmd-C4HMYD4I.js +2 -0
  271. package/dist/pull-route-MHW5PWDW.js +2 -0
  272. package/dist/readmodel-FARAAPUU.js +2 -0
  273. package/dist/real-device-run-WAOWKEFJ.js +2 -0
  274. package/dist/reconcile-cmd-VXY737OT.js +5 -0
  275. package/dist/reconcile-deps-TILDRCHG.js +2 -0
  276. package/dist/{reconcile-remote-3W6ZTO3G.js → reconcile-remote-UGW2433E.js} +2 -2
  277. package/dist/recording-banner-EPOTSMYF.js +2 -0
  278. package/dist/registry-WTWTFRXD.js +2 -0
  279. package/dist/remote-entry-SPA4CSJJ.js +2 -0
  280. package/dist/remote-mode-QO6BDGXM.js +4 -0
  281. package/dist/remote-words-TAZT4YBT.js +2 -0
  282. package/dist/{require-project-folder-3DTI2CVB.js → require-project-folder-WBCAVVMB.js} +1 -1
  283. package/dist/resolve-run-intent-RBOCIYEA.js +2 -0
  284. package/dist/{resolver-CDF7QKVD.js → resolver-3BGIXYYJ.js} +1 -1
  285. package/dist/revert-F6MKJ73M.js +2 -0
  286. package/dist/review-cmd-WE6I5XTY.js +5 -0
  287. package/dist/run-EABFRFOF.js +2 -0
  288. package/dist/run-LX3ARF53.js +2 -0
  289. package/dist/run-remote-6Y62RWMJ.js +2 -0
  290. package/dist/run-startup-gate-Q7FP2IRE.js +2 -0
  291. package/dist/run-test-md-24MBKBC6.js +20 -0
  292. package/dist/session-worker.js +2 -2
  293. package/dist/{sessions-cmd-TLUITRG5.js → sessions-cmd-5NS5P4CP.js} +2 -2
  294. package/dist/{sessions-remote-INO7AWKB.js → sessions-remote-75PDRPOY.js} +1 -1
  295. package/dist/{skill-installer-7JH5QCJF.js → skill-installer-7PK64TZE.js} +1 -1
  296. package/dist/store-AVYBL5HB.js +2 -0
  297. package/dist/store-choice-ZWU3PDNL.js +2 -0
  298. package/dist/store-guard-ETUXXG7X.js +2 -0
  299. package/dist/{store-site-K5NHLI7D.js → store-site-AFXB6SBW.js} +1 -1
  300. package/dist/{stream-warnings-GM7YEOVG.js → stream-warnings-I5LUWVFU.js} +1 -1
  301. package/dist/support-id-RISKXA53.js +2 -0
  302. package/dist/sync-cmd-CSTMT6E6.js +2 -0
  303. package/dist/sync-setup-Y53K6TJ6.js +2 -0
  304. package/dist/tcg-generate-VQLI6NGK.js +2 -0
  305. package/dist/{test-definition-53XNBEDE.js → test-definition-GXEKFRRB.js} +1 -1
  306. package/dist/testmd-actions-BE4YJ6ZZ.js +2 -0
  307. package/dist/{testmd-sync-LYHEXWCT.js → testmd-sync-QZWVWTZZ.js} +1 -1
  308. package/dist/token-refresh-PZ3TOKAL.js +2 -0
  309. package/dist/{use-case-ref-44BPIP4N.js → use-case-ref-E3PJDHQB.js} +1 -1
  310. package/dist/{validate-basic-66XDPA3S.js → validate-basic-QWPESO74.js} +1 -1
  311. package/dist/verdicts-KB6YTIY6.js +2 -0
  312. package/dist/{version-check-SHNVYTMU.js → version-check-EOYWTY3Z.js} +1 -1
  313. package/dist/{view-cmd-QOB3O6YW.js → view-cmd-KG4HI334.js} +1 -1
  314. package/dist/walk-session-WM4S2JMV.js +2 -0
  315. package/dist/with-telemetry-RJM3JKL6.js +2 -0
  316. package/package.json +11 -11
  317. package/dist/ChatSurface-Z26BOE5U.js +0 -2
  318. package/dist/ChromeProfilePicker-ODRIAXL3.js +0 -2
  319. package/dist/EvidenceViewOffer-6344EX74.js +0 -2
  320. package/dist/FolderPicker-4PCYHE75.js +0 -2
  321. package/dist/InfoBox-NJ2DL7YC.js +0 -2
  322. package/dist/LinksBox-HNDNFVUT.js +0 -2
  323. package/dist/ProfilesView-DEJKJOHY.js +0 -2
  324. package/dist/ProjectPicker-DTWMWOH7.js +0 -2
  325. package/dist/SaveSessionPrompt-3GCLB3ZT.js +0 -2
  326. package/dist/SingleShotApp-HMOXO5DW.js +0 -2
  327. package/dist/SummaryBox-7PPDMSSM.js +0 -2
  328. package/dist/TestMdRunView-QLKRUU4V.js +0 -2
  329. package/dist/TestrunEvidenceTable-T2JUB4TE.js +0 -2
  330. package/dist/app-download-GKRF2EIM.js +0 -2
  331. package/dist/bind-SSHAZAB3.js +0 -2
  332. package/dist/bootstrap-XGKU4WXB.js +0 -2
  333. package/dist/chat-committer-ZKEKJA2R.js +0 -2
  334. package/dist/chat-controller-FXRJXUG3.js +0 -2
  335. package/dist/child-JHYENXE7.js +0 -2
  336. package/dist/chunk-2RBMQTYS.js +0 -26
  337. package/dist/chunk-5F5IVART.js +0 -8
  338. package/dist/chunk-6SD4XTYC.js +0 -6
  339. package/dist/chunk-7YV2FCN4.js +0 -3
  340. package/dist/chunk-A2DODRHG.js +0 -2
  341. package/dist/chunk-BJO6J5X2.js +0 -3
  342. package/dist/chunk-DIOK3SER.js +0 -34
  343. package/dist/chunk-DREQ3RAA.js +0 -2
  344. package/dist/chunk-HC6VLPUB.js +0 -5
  345. package/dist/chunk-NZJSGINB.js +0 -47
  346. package/dist/chunk-SXRHKXSE.js +0 -2
  347. package/dist/chunk-UJLULWSR.js +0 -21
  348. package/dist/chunk-ULIIYKZB.js +0 -7
  349. package/dist/chunk-UXGMKRS4.js +0 -102
  350. package/dist/chunk-VO66KP2W.js +0 -2
  351. package/dist/chunk-X52YIWGG.js +0 -13
  352. package/dist/chunk-ZIHQ5JGB.js +0 -18
  353. package/dist/commands-JBFLLT7A.js +0 -2
  354. package/dist/cover-cmd-DU6ZYJFL.js +0 -2
  355. package/dist/design-chat-ZICGVYIH.js +0 -2
  356. package/dist/design-headless-HYWZIIDS.js +0 -2
  357. package/dist/design-remote-HPX4VZ63.js +0 -3
  358. package/dist/device-env-4P4GUVBW.js +0 -2
  359. package/dist/dispatch-BV6XMCN3.js +0 -2
  360. package/dist/doctor-Z2YQ2DBX.js +0 -2
  361. package/dist/evidence-BJIID6VT.js +0 -2
  362. package/dist/evolve-cmd-GZCUSCEK.js +0 -2
  363. package/dist/evolve-remote-LILOAHYH.js +0 -2
  364. package/dist/exit-manager-EGWAZHCR.js +0 -2
  365. package/dist/explain-cmd-LXIVHGN7.js +0 -12
  366. package/dist/explore-SA2P3SGX.js +0 -2
  367. package/dist/explore-context-tty-PERKIWXD.js +0 -2
  368. package/dist/explore-entry-E6EY3VV3.js +0 -6
  369. package/dist/extract-chat-Z64LEAJ5.js +0 -2
  370. package/dist/extract-headless-XLS56LMN.js +0 -2
  371. package/dist/folder-flags-ZIDJVDKX.js +0 -2
  372. package/dist/gaps-cmd-XYOBJVTO.js +0 -3
  373. package/dist/gate-AK44VDHC.js +0 -2
  374. package/dist/gate-NB5CJMTN.js +0 -2
  375. package/dist/hold-passthrough-JGHWMYDM.js +0 -2
  376. package/dist/identity-HL5CJJXR.js +0 -2
  377. package/dist/ingest-ZHHHBUXR.js +0 -2
  378. package/dist/ingest-cmd-OJSKTSQK.js +0 -8
  379. package/dist/ingest-remote-2WM6PYUW.js +0 -2
  380. package/dist/install-JBWBF3WX.js +0 -2
  381. package/dist/lane-CNGO7LH5.js +0 -2
  382. package/dist/lattice-auth-UQPFQSG7.js +0 -2
  383. package/dist/lifecycle-cmd-DGIO3VAO.js +0 -2
  384. package/dist/list-cmd-HQIN3HX4.js +0 -3
  385. package/dist/list-commands-OFRRBU3D.js +0 -2
  386. package/dist/login-flow-SYKXXDLH.js +0 -2
  387. package/dist/maintenance-cmd-X5247RSJ.js +0 -2
  388. package/dist/mobile-prompts-I66ENBDW.js +0 -2
  389. package/dist/onboarding-6HIP3KW6.js +0 -5
  390. package/dist/open-provider-XDJKT3W3.js +0 -2
  391. package/dist/persist-recorded-session-RSSMTVF3.js +0 -3
  392. package/dist/phase-seed-ZZSJME7M.js +0 -2
  393. package/dist/pipeline-NTJDH5TC.js +0 -2
  394. package/dist/prepare-target-AI3GGZF6.js +0 -2
  395. package/dist/pull-cmd-NRVB5ZN7.js +0 -2
  396. package/dist/pull-route-FWCZW76M.js +0 -2
  397. package/dist/readmodel-TRV4E3MW.js +0 -2
  398. package/dist/real-device-run-NQ7RNH7C.js +0 -2
  399. package/dist/reconcile-cmd-7B7THAFJ.js +0 -5
  400. package/dist/reconcile-deps-UDQBWSLE.js +0 -2
  401. package/dist/recording-banner-WVDTWTSE.js +0 -2
  402. package/dist/registry-PFOSXOIH.js +0 -2
  403. package/dist/remote-entry-BZU4NFNS.js +0 -2
  404. package/dist/remote-mode-NXUKDUXG.js +0 -4
  405. package/dist/remote-words-JRDDNOZ6.js +0 -2
  406. package/dist/resolve-run-intent-QCL7QXIB.js +0 -2
  407. package/dist/revert-QKHPCRT6.js +0 -2
  408. package/dist/review-cmd-XBK3TGRE.js +0 -5
  409. package/dist/run-CSYGVV3D.js +0 -2
  410. package/dist/run-YUHHD54J.js +0 -2
  411. package/dist/run-remote-SFR3F2T5.js +0 -2
  412. package/dist/run-startup-gate-QSFJRYUY.js +0 -2
  413. package/dist/run-test-md-ZSREINDQ.js +0 -20
  414. package/dist/store-X4UK4AP7.js +0 -2
  415. package/dist/store-choice-27HDIFTU.js +0 -2
  416. package/dist/store-guard-ZXKB5DQH.js +0 -2
  417. package/dist/sync-cmd-2PCO7LZA.js +0 -2
  418. package/dist/sync-setup-5WQO73Y5.js +0 -2
  419. package/dist/tcg-generate-DGJD5KSM.js +0 -2
  420. package/dist/testmd-actions-XE2JPQHB.js +0 -2
  421. package/dist/token-refresh-E4FTJVHY.js +0 -2
  422. package/dist/verdicts-PVB7TV5S.js +0 -2
  423. package/dist/walk-session-WIEROYOT.js +0 -2
  424. package/dist/with-telemetry-T2PWI5CY.js +0 -2
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as c}from"./chunk-5D7ENQTQ.js";import{a as w}from"./chunk-2XW33VOK.js";import{d as h,h as g}from"./chunk-A7RJQJNT.js";import{c as b,j as v}from"./chunk-J4FIESTB.js";import{readFileSync as C,writeFileSync as k,mkdirSync as x,existsSync as T}from"fs";import{dirname as S}from"path";var f={window_size:{width:1920,height:1080},chrome_profile_path:"",default_url:v,model:"v16-alpha",project_id:null,project_name:null,folder_id:null,folder_name:null,mode:"testing",assertion_mode:"dom",network_ws:!1,network_sse:!1,bug_detection:"off",assertion_failure_mode:"stop",final_validation:!1,code_export:{enabled:!0,language:"python",skip_validation:!0},generate:{scenario_limit:2,per_scenario_limit:3,memory_enabled:!1},last_seen_version:"",hints_enabled:!0},I=f;function E(r){let{mobile:e,...o}=r,t={...o};delete t.target,delete t.device,delete t.device_name,delete t.os_version,delete t.app;let n=e??{};n.tui_target&&(t.target=n.tui_target);let s=n.default_target?.name?.trim(),l=n.default_target?.os_version?.trim();if(s||l)s&&(t.device_name=s),l&&(t.os_version=l);else{let i=n.default_target?.id?.trim();i&&(t.device=i)}n.default_app&&(t.app=n.default_app);let a={};n.no_reset!==void 0&&(a.no_reset=n.no_reset),n.appium_url!==void 0&&(a.appium_url=n.appium_url);for(let i of c)n[i]!==void 0&&(a[i]=n[i]);return Object.keys(a).length>0&&(t.mobile=a),t}function R(r){let e=r.mobile??{},o=typeof r.target=="string"?r.target:void 0,t=typeof r.device=="string"&&r.device.trim()!==""?r.device.trim():void 0,n=d=>typeof d=="string"&&d.trim()!==""?d.trim():void 0,s=n(r.device_name),l=n(r.os_version),a=typeof r.app=="string"&&r.app!==""?r.app:void 0,i={},_=o??e.tui_target;_&&(i.tui_target=_);let p=w(_,void 0).kind,u=h(p)?p:null;u&&(s||l)?i.default_target={platform:g(u),kind:u,...s?{name:s}:{},...l?{os_version:l}:{}}:u&&t?i.default_target={platform:g(u),kind:u,id:t}:(e.default_target?.id?.trim()||e.default_target?.name?.trim())&&(i.default_target=e.default_target);let m=a??e.default_app;m&&(i.default_app=m),e.no_reset!==void 0&&(i.no_reset=e.no_reset),e.appium_url!==void 0&&(i.appium_url=e.appium_url);for(let d of c)e[d]!==void 0&&(i[d]=e[d]);return Object.keys(i).length>0?i:void 0}var y=class{constructor(e=b){this.path=e}exists(){return T(this.path)}load(){try{let e=C(this.path,"utf-8"),o=JSON.parse(e),t=R(o),{target:n,device:s,app:l,...a}=o;return{...f,...a,...t?{mobile:t}:{},code_export:{...f.code_export,...o.code_export??{}},generate:{...f.generate,...o.generate??{}}}}catch{return{...f,code_export:{...f.code_export},generate:{...f.generate}}}}write(e){try{x(S(this.path),{recursive:!0}),k(this.path,JSON.stringify(E(e),null,2)+`
2
+ import{b as c}from"./chunk-5D7ENQTQ.js";import{c as b,j as v}from"./chunk-YKOZBFR3.js";import{a as w}from"./chunk-2XW33VOK.js";import{d as h,h as g}from"./chunk-A7RJQJNT.js";import{readFileSync as C,writeFileSync as k,mkdirSync as x,existsSync as T}from"fs";import{dirname as S}from"path";var f={window_size:{width:1920,height:1080},chrome_profile_path:"",default_url:v,model:"v16-alpha",project_id:null,project_name:null,folder_id:null,folder_name:null,mode:"testing",assertion_mode:"dom",network_ws:!1,network_sse:!1,bug_detection:"off",assertion_failure_mode:"stop",final_validation:!1,code_export:{enabled:!0,language:"python",skip_validation:!0},generate:{scenario_limit:2,per_scenario_limit:3,memory_enabled:!1},last_seen_version:"",hints_enabled:!0},I=f;function E(r){let{mobile:e,...o}=r,t={...o};delete t.target,delete t.device,delete t.device_name,delete t.os_version,delete t.app;let n=e??{};n.tui_target&&(t.target=n.tui_target);let s=n.default_target?.name?.trim(),l=n.default_target?.os_version?.trim();if(s||l)s&&(t.device_name=s),l&&(t.os_version=l);else{let i=n.default_target?.id?.trim();i&&(t.device=i)}n.default_app&&(t.app=n.default_app);let a={};n.no_reset!==void 0&&(a.no_reset=n.no_reset),n.appium_url!==void 0&&(a.appium_url=n.appium_url);for(let i of c)n[i]!==void 0&&(a[i]=n[i]);return Object.keys(a).length>0&&(t.mobile=a),t}function R(r){let e=r.mobile??{},o=typeof r.target=="string"?r.target:void 0,t=typeof r.device=="string"&&r.device.trim()!==""?r.device.trim():void 0,n=d=>typeof d=="string"&&d.trim()!==""?d.trim():void 0,s=n(r.device_name),l=n(r.os_version),a=typeof r.app=="string"&&r.app!==""?r.app:void 0,i={},_=o??e.tui_target;_&&(i.tui_target=_);let p=w(_,void 0).kind,u=h(p)?p:null;u&&(s||l)?i.default_target={platform:g(u),kind:u,...s?{name:s}:{},...l?{os_version:l}:{}}:u&&t?i.default_target={platform:g(u),kind:u,id:t}:(e.default_target?.id?.trim()||e.default_target?.name?.trim())&&(i.default_target=e.default_target);let m=a??e.default_app;m&&(i.default_app=m),e.no_reset!==void 0&&(i.no_reset=e.no_reset),e.appium_url!==void 0&&(i.appium_url=e.appium_url);for(let d of c)e[d]!==void 0&&(i[d]=e[d]);return Object.keys(i).length>0?i:void 0}var y=class{constructor(e=b){this.path=e}exists(){return T(this.path)}load(){try{let e=C(this.path,"utf-8"),o=JSON.parse(e),t=R(o),{target:n,device:s,app:l,...a}=o;return{...f,...a,...t?{mobile:t}:{},code_export:{...f.code_export,...o.code_export??{}},generate:{...f.generate,...o.generate??{}}}}catch{return{...f,code_export:{...f.code_export},generate:{...f.generate}}}}write(e){try{x(S(this.path),{recursive:!0}),k(this.path,JSON.stringify(E(e),null,2)+`
3
3
  `)}catch(o){let t=o instanceof Error?o.message:String(o);process.stderr.write(`[config] Failed to save config: ${t}
4
4
  `)}}set(e,o){let t=this.load();t[e]=o,this.write(t)}save(e){this.write({...this.load(),...e})}getMobile(){return this.load().mobile??{}}setMobile(e){let o={...this.getMobile()};for(let t of Object.keys(e)){let n=e[t];n===void 0?delete o[t]:o[t]=n}this.set("mobile",Object.keys(o).length>0?o:void 0)}writeRaw(e){this.write(e)}};export{I as a,y as b};
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as te,b as re,c as ie,d as se,e as z}from"./chunk-ULIIYKZB.js";import{b as oe,c as ae}from"./chunk-IINZZ4BZ.js";import{g as ne}from"./chunk-F2F257PU.js";import{n as ee,p as j}from"./chunk-UJLULWSR.js";import{a as De}from"./chunk-6YGTRKDT.js";import{e as $e}from"./chunk-UR6MHSHU.js";function Le(r){let e=r==="passed"?"passed":"failed";return{testStatus:e,remark:`kane-cli: ${e}`}}var Fe={testStatus:"failed",remark:"cancelled"};var Ae="https://www.testmuai.com/pricing/",Ue=/Real Mobile App Automation not allowed on your current plan/i,L=class extends Error{code="plan_required";constructor(e){super(e),this.name="RealDevicePlanError"}};function ue(r){return!r||!Ue.test(r)?null:["Real devices aren't included in your TestMu AI plan.","Running on a real device needs the KaneAI Max or Real Device Plus Automation Cloud plan.",`See plans: ${Ae}`].join(`
3
- `)}function de(r){return{command:"start",...r}}function le(r,e,s){return{command:"run",run_id:r,kind:e,...s}}function ce(r){return{command:"cancel",...r?{run_id:r}:{}}}function pe(r){return{command:"ask_user_response",answer:r}}function he(r={}){return{command:"shutdown",...r.testStatus?{test_status:r.testStatus,remark:r.remark??""}:{}}}var W=Symbol("run-queue-end"),J=class{items=[];waiting=null;ended=!1;error=null;push(e){if(this.waiting){let{resolve:s}=this.waiting;this.waiting=null,s(e)}else this.items.push(e)}end(){if(this.ended=!0,this.waiting){let{resolve:e}=this.waiting;this.waiting=null,e(W)}}fail(e){if(this.error=e,this.waiting){let{reject:s}=this.waiting;this.waiting=null,s(e)}}next(){return this.items.length>0?Promise.resolve(this.items.shift()):this.error?Promise.reject(this.error):this.ended?Promise.resolve(W):new Promise((e,s)=>{this.waiting={resolve:e,reject:s}})}},F=class{env;runner;log;sessionId;spawnFn;proc=null;activeRun=null;pendingReady=null;shuttingDown=!1;finalized=!1;exitInfo=null;exitedUnexpectedly=!1;exitResolve;onEvent;exited;constructor(e){this.env=e.env,this.runner=e.runner,this.log=e.log,this.sessionId=e.sessionId,this.spawnFn=e.spawn??re,this.onEvent=e.onEvent;let s;this.exited=new Promise(d=>{s=d}),this.exitResolve=s}async start(e){if(this.proc)throw new Error("PersistentRunner.start called twice");this.proc=this.spawnFn({env:this.env,runner:this.runner,log:this.log,sessionId:this.sessionId}),this.consume();let s=new Promise((d,g)=>{this.pendingReady={resolve:d,reject:g}});this.writeCommand(de(e)),await s}async*run(e,s,d){if(!this.proc)throw new Error("PersistentRunner.run called before start");if(this.finalized)throw new Error(`v16-runner is not running (exited code=${this.exitInfo?.code??"null"}, signal=${this.exitInfo?.signal??"none"}) \u2014 cannot start run '${e}'`);if(this.activeRun)throw new Error(`PersistentRunner.run overlap: '${this.activeRun.runId}' still in flight`);let g=new J,_={runId:e,queue:g};this.activeRun=_,this.writeCommand(le(e,s,d));try{for(;;){let v=await g.next();if(v===W||(yield v,v.type==="run_end"&&(v.run_id===void 0||v.run_id===e)))break}}finally{this.activeRun===_&&(this.activeRun=null)}}sendUserResponse(e){this.writeCommand(pe(e))}cancel(e){this.writeCommand(ce(e))}kill(){this.proc?.child.kill("SIGTERM")}async shutdown(e={}){this.shuttingDown=!0,this.proc&&(this.writeCommand(he(e)),await this.exited)}get stderr(){return this.proc?.getStderr()??""}get diedUnexpectedly(){return this.exitedUnexpectedly}writeCommand(e){let s=JSON.stringify(e)+`
2
+ import{a as te,b as re,c as ie,d as se,e as z}from"./chunk-SBW3QVHN.js";import{b as oe,c as ae}from"./chunk-IINZZ4BZ.js";import{g as ne}from"./chunk-F2F257PU.js";import{m as ee,o as j}from"./chunk-WMXBRC4B.js";import{a as $e}from"./chunk-6YGTRKDT.js";import{e as De}from"./chunk-UR6MHSHU.js";function Le(r){let e=r==="passed"?"passed":"failed";return{testStatus:e,remark:`kane-cli: ${e}`}}var Fe={testStatus:"failed",remark:"cancelled"};var Ae="https://www.testmuai.com/pricing/",Ue=/Real Mobile App Automation not allowed on your current plan/i,L=class extends Error{code="plan_required";constructor(e){super(e),this.name="RealDevicePlanError"}};function ue(r){return!r||!Ue.test(r)?null:["Real devices aren't included in your TestMu AI plan.","Running on a real device needs the KaneAI Max or Real Device Plus Automation Cloud plan.",`See plans: ${Ae}`].join(`
3
+ `)}function de(r){return{command:"start",...r}}function le(r,e,s){return{command:"run",run_id:r,kind:e,...s}}function ce(r){return{command:"cancel",...r?{run_id:r}:{}}}function pe(r){return{command:"ask_user_response",answer:r}}function he(r={}){return{command:"shutdown",...r.testStatus?{test_status:r.testStatus,remark:r.remark??""}:{}}}var W=Symbol("run-queue-end"),H=class{items=[];waiting=null;ended=!1;error=null;push(e){if(this.waiting){let{resolve:s}=this.waiting;this.waiting=null,s(e)}else this.items.push(e)}end(){if(this.ended=!0,this.waiting){let{resolve:e}=this.waiting;this.waiting=null,e(W)}}fail(e){if(this.error=e,this.waiting){let{reject:s}=this.waiting;this.waiting=null,s(e)}}next(){return this.items.length>0?Promise.resolve(this.items.shift()):this.error?Promise.reject(this.error):this.ended?Promise.resolve(W):new Promise((e,s)=>{this.waiting={resolve:e,reject:s}})}},F=class{env;runner;log;sessionId;spawnFn;proc=null;activeRun=null;pendingReady=null;shuttingDown=!1;finalized=!1;realDevice=!1;exitInfo=null;exitedUnexpectedly=!1;exitResolve;onEvent;exited;constructor(e){this.env=e.env,this.runner=e.runner,this.log=e.log,this.sessionId=e.sessionId,this.spawnFn=e.spawn??re,this.onEvent=e.onEvent;let s;this.exited=new Promise(d=>{s=d}),this.exitResolve=s}async start(e){if(this.proc)throw new Error("PersistentRunner.start called twice");this.realDevice=typeof e.device?.device_config_path=="string",this.proc=this.spawnFn({env:this.env,runner:this.runner,log:this.log,sessionId:this.sessionId}),this.consume();let s=new Promise((d,g)=>{this.pendingReady={resolve:d,reject:g}});this.writeCommand(de(e)),await s}async*run(e,s,d){if(!this.proc)throw new Error("PersistentRunner.run called before start");if(this.finalized)throw new Error(`v16-runner is not running (exited code=${this.exitInfo?.code??"null"}, signal=${this.exitInfo?.signal??"none"}) \u2014 cannot start run '${e}'`);if(this.activeRun)throw new Error(`PersistentRunner.run overlap: '${this.activeRun.runId}' still in flight`);let g=new H,_={runId:e,queue:g};this.activeRun=_,this.writeCommand(le(e,s,d));try{for(;;){let v=await g.next();if(v===W||(yield v,v.type==="run_end"&&(v.run_id===void 0||v.run_id===e)))break}}finally{this.activeRun===_&&(this.activeRun=null)}}sendUserResponse(e){this.writeCommand(pe(e))}cancel(e){this.writeCommand(ce(e))}kill(){this.proc?.child.kill("SIGTERM")}async shutdown(e={}){this.shuttingDown=!0,this.proc&&(e.testStatus&&this.realDevice&&this.log?.("info","REAL_DEVICE_SESSION_CLOSE","Hub session closed with the run's verdict",{test_status:e.testStatus}),this.writeCommand(he(e)),await this.exited)}get stderr(){return this.proc?.getStderr()??""}get diedUnexpectedly(){return this.exitedUnexpectedly}writeCommand(e){let s=JSON.stringify(e)+`
4
4
  `;try{this.proc?.child.stdin?.write(s)}catch{}}async consume(){if(!this.proc)return;try{for await(let d of this.proc.events){if(d.type==="ready"){this.onReady();continue}if(d.type==="error"&&this.pendingReady){this.onStartError(d.message);continue}try{this.onEvent?.(d)}catch{}this.routeEvent(d)}}catch(d){this.log?.("error","PERSISTENT_RUNNER_STREAM_ERROR","Runner stdout stream errored",{error:d instanceof Error?d.message:String(d)})}let{code:e,signal:s}=await this.proc.exited;this.onExit(e,s)}onReady(){if(this.pendingReady){let{resolve:e}=this.pendingReady;this.pendingReady=null,e()}}onStartError(e){if(!this.pendingReady)return;let{reject:s}=this.pendingReady;this.pendingReady=null;let d=ue(e);if(d){this.log?.("error","REAL_DEVICE_PLAN_REQUIRED","The mobile hub refused the session over the plan",{reason:e}),s(new L(d));return}s(new Error(ne(e)??`failed to start: ${e??"unknown error"}`))}routeEvent(e){let s=this.activeRun;if(!s){this.log?.("warn","PERSISTENT_RUNNER_ORPHAN_EVENT","Runner event with no active run",{event_type:e.type});return}s.queue.push(e)}onExit(e,s){if(!this.finalized){if(this.finalized=!0,this.exitInfo={code:e,signal:s},this.shuttingDown||(this.exitedUnexpectedly=!0),this.exitResolve({code:e,signal:s}),this.pendingReady){let{reject:d}=this.pendingReady;this.pendingReady=null,d(new Error(`v16-runner exited before ready (code=${e}, signal=${s??"none"})`))}if(this.activeRun){let{queue:d}=this.activeRun;if(this.activeRun=null,this.shuttingDown)d.end();else{let g=this.proc?.getStderr()?.slice(-500)??"";d.fail(new Error(`v16-runner exited unexpectedly mid-run (code=${e}, signal=${s??"none"})${g?`
5
- ${g}`:""}`))}}}}};var p=$e(De(),1);function fe(r){let e={cdp_endpoint:r.cdp_endpoint,ws_endpoint:r.ws_endpoint,width:r.width,height:r.height,headless:r.headless,model:r.model,max_steps:r.max_steps,network_ws:r.network_ws,network_sse:r.network_sse,session_id:r.session_id};return r.device&&(e.device=r.device),r.auth&&(e.auth=r.auth),r.project_id&&(e.project_id=r.project_id),r.disable_ask_user&&(e.disable_ask_user=!0),r.media_upload&&(e.media_upload=r.media_upload),r.username&&(e.username=r.username),r.access_key&&(e.access_key=r.access_key),e}function T(r,e){let s=null,d=(g,_)=>{for(let v=0;v<g.length;v++){let E=g[v],h=[..._,v];e(E)&&(s===null||h.length>s.length)&&(s=h),E.children&&E.children.length>0&&d(E.children,h)}};return d(r,[]),s}function N(r,e,s){if(e.length===0)return[...r];let d=e[0],g=[...r],_=g[d];if(e.length===1)g[d]=s(_);else{let v=e.slice(1),E=N(_.children??[],v,s);g[d]={..._,children:E}}return g}var Me=6e4;function me(){return{steps:[],maxOrdinal:0}}function Oe(r,e){if(e.type==="run_start"&&e.child_id)return e.environment?.resolution?{...r,resolution:e.environment.resolution}:r;if(e.type==="run_start"){let s=ae(r.runnerEnvironment,oe(e.environment));if(s)return{...r,runnerEnvironment:s,...s.resolution?{resolution:s.resolution}:{}}}if(e.type==="step_end"&&typeof e.ordinal=="number"&&e.id){let s={id:e.id,ordinal:e.ordinal,status:e.status,...e.kind?{kind:e.kind}:{},...typeof e.duration=="number"?{duration_ms:Math.round(e.duration*1e3)}:{},...typeof e.action_id=="string"&&e.action_id?{action_id:e.action_id}:{}};return{...r,steps:[...r.steps,s],maxOrdinal:Math.max(r.maxOrdinal,e.ordinal)}}return r}function H(r){let e=r.indexOf(": ");return e>0&&e<15?r.slice(e+2):r}function Q(r){return r.map(e=>{let s=e.children?Q(e.children):e.children;return e.status==="running"?{...e,status:"stopped",phase:void 0,children:s}:s!==e.children?{...e,children:s}:e})}function rn(r,e,s,d,g){let[_,v]=(0,p.useState)(!1),[E,h]=(0,p.useState)([]),[ve,$]=(0,p.useState)(null),[ge,B]=(0,p.useState)(null),[Re,C]=(0,p.useState)(null),[Se,X]=(0,p.useState)(null),[ye,Y]=(0,p.useState)([]),[we,Z]=(0,p.useState)(null),[xe,_e]=(0,p.useState)(void 0),[Ee,D]=(0,p.useState)(0),x=(0,p.useRef)(null),A=(0,p.useRef)(null),k=(0,p.useRef)(null),w=(0,p.useRef)(null),b=(0,p.useRef)(0),V=(0,p.useRef)(!1),U=(0,p.useRef)(me()),M=(0,p.useRef)(null),be=(0,p.useCallback)(async(f,S)=>{let I=M.current;if(I)try{await I}catch{}h([]),$(null),B(null),C(null),X(null),Y([]),Z(null),_e(f.max_steps),v(!0),w.current=null,b.current=0,U.current=me();let y=x.current;if(y&&k.current!==f.session_id){try{y.kill()}catch{}x.current=null,k.current=null,D(n=>n+1),y=null}if(!y){let n=te();if(!n){C("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available."),v(!1);return}let l=se({environment:S?.environment,mode:S?.mode,assertionMode:S?.assertionMode,finalValidation:S?.finalValidation,username:f.username,accessKey:f.access_key,sessionId:f.session_id});f.device?.platform&&await ie(l,f.device);let u=new F({env:l,runner:n,log:S?.log,sessionId:f.session_id,...S?.onRunnerEvent?{onEvent:S.onRunnerEvent}:{}});x.current=u,k.current=f.session_id,y=u,ee("runner",()=>{try{u.kill()}catch{}});let o={...f};z(o,{environment:S?.environment});let a=fe(o);try{await u.start(a)}catch(t){C(t instanceof Error?t.message:String(t)),v(!1),j("runner","Runner start failed"),x.current=null,k.current=null,D(i=>i+1);return}}let q={...f};delete q.run_id,z(q,{environment:S?.environment});let Te=`run-${f.run_index}`,Ne=f.mode==="replay"?"replay":"author",G=y,K=(async()=>{V.current=!1;for await(let n of G.run(Te,Ne,q)){if(V.current)break;switch(U.current=Oe(U.current,n),n.type){case"run_start":if(n.child_id)break;if(w.current&&!w.current.isSingleFlow){let l=b.current;b.current++,h(u=>u.map((o,a)=>a===l?{...o,status:"running"}:o.status==="running"&&!o.children?.some(t=>t.status==="running")?{...o,status:o.children?.some(t=>t.status==="failed")?"failed":"passed"}:o))}break;case"bifurcation":{let l=n.flows??[],u=n.count??l.length,o={flows:l,isSingleFlow:n.is_single_flow??u<=1};X(o),w.current=o,b.current=0,h(l.map((a,t)=>({index:t+1,objective:a??`Flow ${t+1}`,status:"pending"})));break}case"step_start":{e?.("STEP_START",`Step ${n.index} started`,{index:n.index,objective:n.objective,child_id:n.child_id});let l=n.index,u=n.objective??`Step ${l}`,o=n.child_id,a=w.current&&!w.current.isSingleFlow;if(o)h(t=>{let i=T(t,c=>c.branchChildId===o)??T(t,c=>c.status==="running");return i?N(t,i,c=>{let m=(c.children??[]).map(R=>R.status==="running"&&R.childId===o?{...R,status:"stopped",phase:void 0}:R);return m.push({index:l,objective:u,status:"running",childId:o}),{...c,children:m}}):t});else if(a){let t=Math.max(0,b.current-1);h(i=>{let c=[...i];if(t>=c.length)return i;let m={...c[t]},P=[...m.children??[]].map(O=>O.status==="running"&&O.childId===void 0?{...O,status:"stopped",phase:void 0}:O);return P.push({index:l,objective:u,status:"running"}),m.children=P,m.status="running",c[t]=m,c})}else h(t=>{let i=Q(t);return i.some(m=>m.index===l)?i.map(m=>m.index===l?{...m,status:"running",objective:u}:m):[...i,{index:l,objective:u,status:"running"}]});break}case"step_event":{e?.("STEP_EVENT",`Step ${n.index} ${n.event}`,{index:n.index,phase:n.event,action_type:n.action_type,detail:n.detail,child_id:n.child_id});let l=n.child_id,u=w.current&&!w.current.isSingleFlow;if(n.event==="cm_init"&&n.checkpoint_count!=null){Y(o=>[...o,n.checkpoint_count]);break}if(n.event==="replay_started"){Z({recordingLength:n.recording_length??0});break}if(n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&s?.(n.detail),l){let o=t=>{if(t.index!==n.index||t.childId!==l)return t;let i={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(i.objective=n.detail),n.action_type&&(i.actionType=n.action_type),{...t,...i}},a=t=>t.map(i=>{let c=o(i);return c!==i?c:i.children&&i.children.length>0?{...i,children:a(i.children)}:i});h(t=>t.map(i=>i.children?{...i,children:a(i.children)}:i))}else if(u){let o=Math.max(0,b.current-1);h(a=>{let t=[...a];if(o>=t.length)return a;let i={...t[o]},c=[...i.children??[]];if(!c.some(R=>R.index===n.index&&R.childId===void 0))c.push({index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type});else for(let R=0;R<c.length;R++){if(c[R].index!==n.index||c[R].childId!==void 0)continue;let P={phase:n.event};n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(P.objective=n.detail),n.action_type&&(P.actionType=n.action_type),c[R]={...c[R],...P}}return i.children=c,t[o]=i,t})}else h(o=>o.some(t=>t.index===n.index)?o.map(t=>{if(t.index!==n.index)return t;let i={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(i.objective=n.detail),n.action_type&&(i.actionType=n.action_type),{...t,...i}}):[...Q(o),{index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type}]);break}case"step_end":{e?.("STEP_END",`Step ${n.index} ${n.status}`,{index:n.index,status:n.status,duration:n.duration,summary:n.summary,child_id:n.child_id}),d?.();let l=n.child_id,u=w.current&&!w.current.isSingleFlow;if(l){let o=t=>t.index===n.index&&t.childId===l?{...t,status:n.status,duration:n.duration,phase:void 0,objective:t.objective.startsWith("Step ")?H(n.summary||t.objective):t.objective}:t,a=t=>t.map(i=>{let c=o(i);return c!==i?c:i.children&&i.children.length>0?{...i,children:a(i.children)}:i});h(t=>t.map(i=>i.children?{...i,children:a(i.children)}:i))}else if(u){let o=Math.max(0,b.current-1);h(a=>{let t=[...a];if(o>=t.length)return a;let i={...t[o]},c=(i.children??[]).map(m=>m.index===n.index&&m.childId===void 0?{...m,status:n.status,duration:n.duration,phase:void 0,objective:m.objective.startsWith("Step ")?H(n.summary||m.objective):m.objective}:m);return i.children=c,t[o]=i,t})}else h(o=>o.map(a=>a.index===n.index?{...a,status:n.status,duration:n.duration,phase:void 0,objective:a.objective.startsWith("Step ")?H(n.summary||a.objective):a.objective}:a));{let a=w.current&&!w.current.isSingleFlow?Math.max(0,b.current-1):0,t=typeof n.ordinal=="number"&&n.id?{ordinal:n.ordinal,id:n.id}:void 0;r?.(n.index,a,n.child_id,t)}break}case"child_agent_start":{let l=n.objective??"",u=n.child_id;h(o=>{let a=T(o,t=>t.status==="running");return a?N(o,a,t=>({...t,objective:`${l} (branch)`,phase:`child: ${l.slice(0,50)}`,branchObjective:l,branchChildId:u})):o});break}case"child_agent_end":{let l=n.child_id,u=`child ${n.success?"done":"failed"}`;h(o=>{let a=T(o,t=>t.branchChildId===l);return a?N(o,a,t=>({...t,phase:u})):o.map(t=>t.phase?.startsWith("child:")?{...t,phase:u}:t)});break}case"describe_trigger":g?.(n);break;case"ask_user":$(n.question??"");break;case"run_end":h(l=>l.map(u=>u.status==="running"?{...u,status:n.status,phase:void 0}:u)),v(!1),B(n);break;case"error":v(!1),C(n.message??"Runner error"),h(l=>l.map(u=>u.status==="running"?{...u,status:"failed",phase:void 0}:u));break}}})().catch(n=>{if(x.current!==G)return;let u=[n instanceof Error?n.message:String(n)],o=G.stderr;o&&!u.join(`
5
+ ${g}`:""}`))}}}}};var p=De($e(),1);function fe(r){let e={cdp_endpoint:r.cdp_endpoint,ws_endpoint:r.ws_endpoint,width:r.width,height:r.height,headless:r.headless,model:r.model,max_steps:r.max_steps,network_ws:r.network_ws,network_sse:r.network_sse,session_id:r.session_id};return r.device&&(e.device=r.device),r.auth&&(e.auth=r.auth),r.project_id&&(e.project_id=r.project_id),r.disable_ask_user&&(e.disable_ask_user=!0),r.media_upload&&(e.media_upload=r.media_upload),r.username&&(e.username=r.username),r.access_key&&(e.access_key=r.access_key),e}function N(r,e){let s=null,d=(g,_)=>{for(let v=0;v<g.length;v++){let E=g[v],h=[..._,v];e(E)&&(s===null||h.length>s.length)&&(s=h),E.children&&E.children.length>0&&d(E.children,h)}};return d(r,[]),s}function T(r,e,s){if(e.length===0)return[...r];let d=e[0],g=[...r],_=g[d];if(e.length===1)g[d]=s(_);else{let v=e.slice(1),E=T(_.children??[],v,s);g[d]={..._,children:E}}return g}var Me=6e4;function me(){return{steps:[],maxOrdinal:0}}function Oe(r,e){if(e.type==="run_start"&&e.child_id)return e.environment?.resolution?{...r,resolution:e.environment.resolution}:r;if(e.type==="run_start"){let s=ae(r.runnerEnvironment,oe(e.environment));if(s)return{...r,runnerEnvironment:s,...s.resolution?{resolution:s.resolution}:{}}}if(e.type==="step_end"&&typeof e.ordinal=="number"&&e.id){let s={id:e.id,ordinal:e.ordinal,status:e.status,...e.kind?{kind:e.kind}:{},...typeof e.duration=="number"?{duration_ms:Math.round(e.duration*1e3)}:{},...typeof e.action_id=="string"&&e.action_id?{action_id:e.action_id}:{}};return{...r,steps:[...r.steps,s],maxOrdinal:Math.max(r.maxOrdinal,e.ordinal)}}return r}function J(r){let e=r.indexOf(": ");return e>0&&e<15?r.slice(e+2):r}function Q(r){return r.map(e=>{let s=e.children?Q(e.children):e.children;return e.status==="running"?{...e,status:"stopped",phase:void 0,children:s}:s!==e.children?{...e,children:s}:e})}function rn(r,e,s,d,g){let[_,v]=(0,p.useState)(!1),[E,h]=(0,p.useState)([]),[ve,D]=(0,p.useState)(null),[ge,B]=(0,p.useState)(null),[Re,C]=(0,p.useState)(null),[Se,X]=(0,p.useState)(null),[ye,Y]=(0,p.useState)([]),[we,Z]=(0,p.useState)(null),[xe,_e]=(0,p.useState)(void 0),[Ee,$]=(0,p.useState)(0),x=(0,p.useRef)(null),A=(0,p.useRef)(null),k=(0,p.useRef)(null),w=(0,p.useRef)(null),b=(0,p.useRef)(0),V=(0,p.useRef)(!1),U=(0,p.useRef)(me()),M=(0,p.useRef)(null),be=(0,p.useCallback)(async(f,S)=>{let I=M.current;if(I)try{await I}catch{}h([]),D(null),B(null),C(null),X(null),Y([]),Z(null),_e(f.max_steps),v(!0),w.current=null,b.current=0,U.current=me();let y=x.current;if(y&&k.current!==f.session_id){try{y.kill()}catch{}x.current=null,k.current=null,$(n=>n+1),y=null}if(!y){let n=te();if(!n){C("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available."),v(!1);return}let l=se({environment:S?.environment,mode:S?.mode,assertionMode:S?.assertionMode,finalValidation:S?.finalValidation,username:f.username,accessKey:f.access_key,sessionId:f.session_id});f.device?.platform&&await ie(l,f.device);let u=new F({env:l,runner:n,log:S?.log,sessionId:f.session_id,...S?.onRunnerEvent?{onEvent:S.onRunnerEvent}:{}});x.current=u,k.current=f.session_id,y=u,ee("runner",()=>{try{u.kill()}catch{}});let o={...f};z(o,{environment:S?.environment});let a=fe(o);try{await u.start(a)}catch(t){C(t instanceof Error?t.message:String(t)),v(!1),j("runner","Runner start failed"),x.current=null,k.current=null,$(i=>i+1);return}}let q={...f};delete q.run_id,z(q,{environment:S?.environment});let Ne=`run-${f.run_index}`,Te=f.mode==="replay"?"replay":"author",G=y,K=(async()=>{V.current=!1;for await(let n of G.run(Ne,Te,q)){if(V.current)break;switch(U.current=Oe(U.current,n),n.type){case"run_start":if(n.child_id)break;if(w.current&&!w.current.isSingleFlow){let l=b.current;b.current++,h(u=>u.map((o,a)=>a===l?{...o,status:"running"}:o.status==="running"&&!o.children?.some(t=>t.status==="running")?{...o,status:o.children?.some(t=>t.status==="failed")?"failed":"passed"}:o))}break;case"bifurcation":{let l=n.flows??[],u=n.count??l.length,o={flows:l,isSingleFlow:n.is_single_flow??u<=1};X(o),w.current=o,b.current=0,h(l.map((a,t)=>({index:t+1,objective:a??`Flow ${t+1}`,status:"pending"})));break}case"step_start":{e?.("STEP_START",`Step ${n.index} started`,{index:n.index,objective:n.objective,child_id:n.child_id});let l=n.index,u=n.objective??`Step ${l}`,o=n.child_id,a=w.current&&!w.current.isSingleFlow;if(o)h(t=>{let i=N(t,c=>c.branchChildId===o)??N(t,c=>c.status==="running");return i?T(t,i,c=>{let m=(c.children??[]).map(R=>R.status==="running"&&R.childId===o?{...R,status:"stopped",phase:void 0}:R);return m.push({index:l,objective:u,status:"running",childId:o}),{...c,children:m}}):t});else if(a){let t=Math.max(0,b.current-1);h(i=>{let c=[...i];if(t>=c.length)return i;let m={...c[t]},P=[...m.children??[]].map(O=>O.status==="running"&&O.childId===void 0?{...O,status:"stopped",phase:void 0}:O);return P.push({index:l,objective:u,status:"running"}),m.children=P,m.status="running",c[t]=m,c})}else h(t=>{let i=Q(t);return i.some(m=>m.index===l)?i.map(m=>m.index===l?{...m,status:"running",objective:u}:m):[...i,{index:l,objective:u,status:"running"}]});break}case"step_event":{e?.("STEP_EVENT",`Step ${n.index} ${n.event}`,{index:n.index,phase:n.event,action_type:n.action_type,detail:n.detail,child_id:n.child_id});let l=n.child_id,u=w.current&&!w.current.isSingleFlow;if(n.event==="cm_init"&&n.checkpoint_count!=null){Y(o=>[...o,n.checkpoint_count]);break}if(n.event==="replay_started"){Z({recordingLength:n.recording_length??0});break}if(n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&s?.(n.detail),l){let o=t=>{if(t.index!==n.index||t.childId!==l)return t;let i={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(i.objective=n.detail),n.action_type&&(i.actionType=n.action_type),{...t,...i}},a=t=>t.map(i=>{let c=o(i);return c!==i?c:i.children&&i.children.length>0?{...i,children:a(i.children)}:i});h(t=>t.map(i=>i.children?{...i,children:a(i.children)}:i))}else if(u){let o=Math.max(0,b.current-1);h(a=>{let t=[...a];if(o>=t.length)return a;let i={...t[o]},c=[...i.children??[]];if(!c.some(R=>R.index===n.index&&R.childId===void 0))c.push({index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type});else for(let R=0;R<c.length;R++){if(c[R].index!==n.index||c[R].childId!==void 0)continue;let P={phase:n.event};n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(P.objective=n.detail),n.action_type&&(P.actionType=n.action_type),c[R]={...c[R],...P}}return i.children=c,t[o]=i,t})}else h(o=>o.some(t=>t.index===n.index)?o.map(t=>{if(t.index!==n.index)return t;let i={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(i.objective=n.detail),n.action_type&&(i.actionType=n.action_type),{...t,...i}}):[...Q(o),{index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type}]);break}case"step_end":{e?.("STEP_END",`Step ${n.index} ${n.status}`,{index:n.index,status:n.status,duration:n.duration,summary:n.summary,child_id:n.child_id}),d?.();let l=n.child_id,u=w.current&&!w.current.isSingleFlow;if(l){let o=t=>t.index===n.index&&t.childId===l?{...t,status:n.status,duration:n.duration,phase:void 0,objective:t.objective.startsWith("Step ")?J(n.summary||t.objective):t.objective}:t,a=t=>t.map(i=>{let c=o(i);return c!==i?c:i.children&&i.children.length>0?{...i,children:a(i.children)}:i});h(t=>t.map(i=>i.children?{...i,children:a(i.children)}:i))}else if(u){let o=Math.max(0,b.current-1);h(a=>{let t=[...a];if(o>=t.length)return a;let i={...t[o]},c=(i.children??[]).map(m=>m.index===n.index&&m.childId===void 0?{...m,status:n.status,duration:n.duration,phase:void 0,objective:m.objective.startsWith("Step ")?J(n.summary||m.objective):m.objective}:m);return i.children=c,t[o]=i,t})}else h(o=>o.map(a=>a.index===n.index?{...a,status:n.status,duration:n.duration,phase:void 0,objective:a.objective.startsWith("Step ")?J(n.summary||a.objective):a.objective}:a));{let a=w.current&&!w.current.isSingleFlow?Math.max(0,b.current-1):0,t=typeof n.ordinal=="number"&&n.id?{ordinal:n.ordinal,id:n.id}:void 0;r?.(n.index,a,n.child_id,t)}break}case"child_agent_start":{let l=n.objective??"",u=n.child_id;h(o=>{let a=N(o,t=>t.status==="running");return a?T(o,a,t=>({...t,objective:`${l} (branch)`,phase:`child: ${l.slice(0,50)}`,branchObjective:l,branchChildId:u})):o});break}case"child_agent_end":{let l=n.child_id,u=`child ${n.success?"done":"failed"}`;h(o=>{let a=N(o,t=>t.branchChildId===l);return a?T(o,a,t=>({...t,phase:u})):o.map(t=>t.phase?.startsWith("child:")?{...t,phase:u}:t)});break}case"describe_trigger":g?.(n);break;case"ask_user":D(n.question??"");break;case"run_end":h(l=>l.map(u=>u.status==="running"?{...u,status:n.status,phase:void 0}:u)),v(!1),B(n);break;case"error":v(!1),C(n.message??"Runner error"),h(l=>l.map(u=>u.status==="running"?{...u,status:"failed",phase:void 0}:u));break}}})().catch(n=>{if(x.current!==G)return;let u=[n instanceof Error?n.message:String(n)],o=G.stderr;o&&!u.join(`
6
6
  `).includes(o)&&u.push(o),C(u.join(`
7
- `)),v(!1),h(a=>a.map(t=>t.status==="running"?{...t,status:"failed",phase:void 0}:t)),j("runner","Runner died mid-run"),x.current=null,k.current=null,D(a=>a+1)});M.current=K,K.finally(()=>{M.current===K&&(M.current=null)})},[r,e,s,d,g]),ke=(0,p.useCallback)(f=>{x.current?.sendUserResponse(f),$(null)},[]),Ie=(0,p.useCallback)(()=>{let f=x.current;f&&(f.cancel(),v(!1),$(null))},[]),Ce=(0,p.useCallback)((f,S)=>{if(A.current)return A.current;let I=x.current;if(!I)return Promise.resolve();let y=Pe(I,f,S?.timeoutMs).finally(()=>{A.current=null});return A.current=y,y},[]),Pe=async(f,S,I)=>{try{await Promise.race([f.shutdown(S??{}),new Promise(y=>setTimeout(y,I??(S?Me:5e3)))])}catch{}j("runner","Runner shut down"),x.current=null,k.current=null,D(y=>y+1)},je=(0,p.useCallback)(()=>{h([]),B(null),C(null)},[]);return(0,p.useEffect)(()=>()=>{V.current=!0,j("runner","Component unmounted"),x.current=null,k.current=null},[]),{isRunning:_,steps:E,askingUser:ve,lastRunEnd:ge,runError:Re,bifurcationInfo:Se,cmInitCounts:ye,replayInfo:we,maxSteps:xe,sessionGen:Ee,startRun:be,sendAnswer:ke,cancelRun:Ie,shutdownRunner:Ce,clearLastRun:je,getEvidenceState:()=>U.current}}export{Le as a,Fe as b,F as c,fe as d,me as e,Oe as f,rn as g};
7
+ `)),v(!1),h(a=>a.map(t=>t.status==="running"?{...t,status:"failed",phase:void 0}:t)),j("runner","Runner died mid-run"),x.current=null,k.current=null,$(a=>a+1)});M.current=K,K.finally(()=>{M.current===K&&(M.current=null)})},[r,e,s,d,g]),ke=(0,p.useCallback)(f=>{x.current?.sendUserResponse(f),D(null)},[]),Ie=(0,p.useCallback)(()=>{let f=x.current;f&&(f.cancel(),v(!1),D(null))},[]),Ce=(0,p.useCallback)((f,S)=>{if(A.current)return A.current;let I=x.current;if(!I)return Promise.resolve();let y=Pe(I,f,S?.timeoutMs).finally(()=>{A.current=null});return A.current=y,y},[]),Pe=async(f,S,I)=>{try{await Promise.race([f.shutdown(S??{}),new Promise(y=>setTimeout(y,I??(S?Me:5e3)))])}catch{}j("runner","Runner shut down"),x.current=null,k.current=null,$(y=>y+1)},je=(0,p.useCallback)(()=>{h([]),B(null),C(null)},[]);return(0,p.useEffect)(()=>()=>{V.current=!0,j("runner","Component unmounted"),x.current=null,k.current=null},[]),{isRunning:_,steps:E,askingUser:ve,lastRunEnd:ge,runError:Re,bifurcationInfo:Se,cmInitCounts:ye,replayInfo:we,maxSteps:xe,sessionGen:Ee,startRun:be,sendAnswer:ke,cancelRun:Ie,shutdownRunner:Ce,clearLastRun:je,getEvidenceState:()=>U.current}}export{Le as a,Fe as b,F as c,fe as d,me as e,Oe as f,rn as g};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as m}from"./chunk-YCVEI7BT.js";import{a as p}from"./chunk-HCBYKLMW.js";import{a,b as r,i as u}from"./chunk-33DWJV67.js";import{a as b}from"./chunk-6YGTRKDT.js";import{z as t}from"./chunk-J4FIESTB.js";import{e as n}from"./chunk-UR6MHSHU.js";var c=n(b(),1);var e=n(p(),1);function R({onSubmit:l}){let[o,f]=(0,c.useState)(0),s=(0,c.useRef)(!1);return u((x,i)=>{s.current||(i.leftArrow||i.rightArrow?f(d=>d===0?1:0):i.return?(s.current=!0,l(o===0?"positive":"negative")):i.escape&&(s.current=!0,l(null)))}),(0,e.jsxs)(a,{flexDirection:"column",marginTop:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(r,{color:t.secondary,children:"Rate this session: "}),(0,e.jsx)(r,{color:o===0?t.orange:t.dim,children:o===0?"[ \u{1F44D} ]":" \u{1F44D} "}),(0,e.jsx)(r,{children:" "}),(0,e.jsx)(r,{color:o===1?t.orange:t.dim,children:o===1?"[ \u{1F44E} ]":" \u{1F44E} "})]}),(0,e.jsx)(m,{bindings:[{keys:"\u2190/\u2192",label:"select"},{keys:"\u21B5",label:"submit"}],escBackLabel:"skip"})]})}export{R as a};
2
+ import{a as m}from"./chunk-RNKJXVG2.js";import{a as p}from"./chunk-HCBYKLMW.js";import{z as t}from"./chunk-YKOZBFR3.js";import{a,b as r,i as u}from"./chunk-33DWJV67.js";import{a as b}from"./chunk-6YGTRKDT.js";import{e as n}from"./chunk-UR6MHSHU.js";var c=n(b(),1);var e=n(p(),1);function R({onSubmit:l}){let[o,f]=(0,c.useState)(0),s=(0,c.useRef)(!1);return u((x,i)=>{s.current||(i.leftArrow||i.rightArrow?f(d=>d===0?1:0):i.return?(s.current=!0,l(o===0?"positive":"negative")):i.escape&&(s.current=!0,l(null)))}),(0,e.jsxs)(a,{flexDirection:"column",marginTop:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(r,{color:t.secondary,children:"Rate this session: "}),(0,e.jsx)(r,{color:o===0?t.orange:t.dim,children:o===0?"[ \u{1F44D} ]":" \u{1F44D} "}),(0,e.jsx)(r,{children:" "}),(0,e.jsx)(r,{color:o===1?t.orange:t.dim,children:o===1?"[ \u{1F44E} ]":" \u{1F44E} "})]}),(0,e.jsx)(m,{bindings:[{keys:"\u2190/\u2192",label:"select"},{keys:"\u21B5",label:"submit"}],escBackLabel:"skip"})]})}export{R as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as s}from"./chunk-HCBYKLMW.js";import{a as i,b as n}from"./chunk-33DWJV67.js";import{z as a}from"./chunk-J4FIESTB.js";import{e as r}from"./chunk-UR6MHSHU.js";var o=r(s(),1);function g({bindings:c,suppressEscBack:p=!1,escBackLabel:m="back to chat"}){let e=c.map(t=>`${t.keys} ${t.label}`);return p||e.push(`esc \xB7 ${m}`),(0,o.jsx)(i,{marginTop:1,children:(0,o.jsx)(n,{color:a.dim,children:e.join(" \xB7 ")})})}export{g as a};
2
+ import{a as s}from"./chunk-HCBYKLMW.js";import{z as a}from"./chunk-YKOZBFR3.js";import{a as i,b as n}from"./chunk-33DWJV67.js";import{e as r}from"./chunk-UR6MHSHU.js";var o=r(s(),1);function g({bindings:c,suppressEscBack:p=!1,escBackLabel:m="back to chat"}){let e=c.map(t=>`${t.keys} ${t.label}`);return p||e.push(`esc \xB7 ${m}`),(0,o.jsx)(i,{marginTop:1,children:(0,o.jsx)(n,{color:a.dim,children:e.join(" \xB7 ")})})}export{g as a};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as o,e as p}from"./chunk-XMPTFXPW.js";import{a as m}from"./chunk-RQKMSNEU.js";import{d,f as c}from"./chunk-7YV2FCN4.js";import{Ia as a}from"./chunk-PI7OXS62.js";import{resolve as l}from"path";async function g(s,w,t={}){let r=c({verb:s,mode:"cli",contextRoot:l(process.cwd(),".context"),env:d(),write:t.write,sessionId:m()}),n=()=>{o(t.mode??"")!=="ndjson"&&process.stderr.write(r.supportFooter()+`
2
+ import{b as o,e as p}from"./chunk-XMPTFXPW.js";import{Ia as a}from"./chunk-5EAJO372.js";import{e as d,h as c}from"./chunk-IQMJJN52.js";import{a as m}from"./chunk-WTMCDYR3.js";import{resolve as l}from"path";async function g(s,w,t={}){let r=c({verb:s,mode:"cli",contextRoot:l(process.cwd(),".context"),env:d(),write:t.write,sessionId:m()}),n=()=>{o(t.mode??"")!=="ndjson"&&process.stderr.write(r.supportFooter()+`
3
3
  `)};try{let e=await w(r);return t.write&&e===0&&await r.lateBindContext(l(process.cwd(),".context")),e===1&&n(),await r.end({exit_code:e}),e}catch(e){if(e instanceof a){if(o(t.mode??"")==="ndjson"){let i=p("ndjson",t.streamVerb??s,{stdout:y=>process.stdout.write(y),stderr:()=>{}});i.event({type:"sync_error",code:e.code,detail:e.message,remedy:e.remedy}),i.done(2,"refused")}else process.stderr.write(`error: ${e.message}
4
4
  next: ${e.remedy}
5
5
  `);return r.error("rebase_open"),await r.end({exit_code:2}),2}throw r.error("cli_crash"),n(),await r.end({exit_code:1}),e}}export{g as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as m}from"./chunk-LZPYIFHZ.js";import{a as p}from"./chunk-RQKMSNEU.js";import{f as e}from"./chunk-HYJVYYAZ.js";import{a as t,b as i,y as n}from"./chunk-J4FIESTB.js";import{dirname as d}from"path";import{fileURLToPath as l}from"url";import{existsSync as a}from"fs";import{join as c,resolve as f}from"path";function g(r){for(let o of[f(r,".."),f(r,"../..")])if(a(c(o,"package.json")))return o;return null}function u(r=m,o,s=p){e({version:t,baseDir:i,authEnvironments:n,packageRoot:g(d(l(import.meta.url))),wording:r,...o?{warn:o}:{},userSessionId:s})}u();export{g as a,u as b};
2
+ import{a as m}from"./chunk-LZPYIFHZ.js";import{f as e}from"./chunk-HYJVYYAZ.js";import{a as t,b as i,y as n}from"./chunk-YKOZBFR3.js";import{a as p}from"./chunk-WTMCDYR3.js";import{dirname as d}from"path";import{fileURLToPath as l}from"url";import{existsSync as a}from"fs";import{join as c,resolve as f}from"path";function g(r){for(let o of[f(r,".."),f(r,"../..")])if(a(c(o,"package.json")))return o;return null}function u(r=m,o,s=p){e({version:t,baseDir:i,authEnvironments:n,packageRoot:g(d(l(import.meta.url))),wording:r,...o?{warn:o}:{},userSessionId:s})}u();export{g as a,u as b};
@@ -0,0 +1,7 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as x}from"./chunk-TDPWFYTJ.js";import{b as A}from"./chunk-QXZGBYGQ.js";import{d as R}from"./chunk-2KPJ62RZ.js";import{a as S}from"./chunk-MMBBQ4OZ.js";import{a as E}from"./chunk-TD6GCEIK.js";import{a as T}from"./chunk-APXJRWIJ.js";import{a as m}from"./chunk-73EHVDL5.js";import{d as _}from"./chunk-YKOZBFR3.js";import{f as y}from"./chunk-A7RJQJNT.js";import{spawn as U,execSync as L}from"child_process";import{appendFileSync as h,existsSync as f,mkdirSync as C}from"fs";import{homedir as V}from"os";import{join as k,resolve as s,dirname as v,delimiter as P}from"path";import{fileURLToPath as D}from"url";import{createInterface as M}from"readline";async function*N(e){let n=M({input:e,crlfDelay:1/0});for await(let r of n){let i=r.trim();if(i)try{let o=JSON.parse(i);o&&typeof o.type=="string"&&(yield o)}catch{}}}function w(e){return e==="action"?{set:{V16_AGENT_ENABLE_ALL_BLOCKERS:"true",V16_BIFURCATION_PHASES:"1"},unset:["V16_NETWORK_WS","V16_NETWORK_SSE"]}:{set:{V16_BIFURCATION_PHASES:"1"},unset:["V16_AGENT_ENABLE_ALL_BLOCKERS","V16_NETWORK_WS","V16_NETWORK_SSE"]}}function O(e){return e?{set:{},unset:["V16_AGENT_SKIP_CP_FINAL"]}:{set:{V16_AGENT_SKIP_CP_FINAL:"true"},unset:[]}}function b(e){return e==="dom"?{set:{V16_AGENT_ENABLE_TEXTUAL_VISUAL:"true"},unset:[]}:{set:{},unset:["V16_AGENT_ENABLE_TEXTUAL_VISUAL"]}}var c=v(D(import.meta.url));function B(){for(let e of["python3","python"])try{return L(`${e} --version`,{stdio:"ignore"}),e}catch{}return null}function H(){let n=process.platform==="win32"?"v16-runner.exe":"v16-runner",r={"darwin-arm64":["@testmuai/kane-cli-darwin-arm64","@lambdatestincprivate/kane-cli-darwin-arm64"],"darwin-x64":["@testmuai/kane-cli-darwin-x64","@lambdatestincprivate/kane-cli-darwin-x64"],"linux-x64":["@testmuai/kane-cli-linux-x64","@lambdatestincprivate/kane-cli-linux-x64"],"linux-arm64":["@testmuai/kane-cli-linux-arm64","@lambdatestincprivate/kane-cli-linux-arm64"],"win32-x64":["@testmuai/kane-cli-win-x64","@lambdatestincprivate/kane-cli-win-x64"]},i=`${process.platform}-${process.arch}`,o=r[i];if(o)for(let t of o){let a=[s(c,"..","node_modules",t,"bin",n),s(c,"..","..","node_modules",t,"bin",n),s(c,"..","..","..","node_modules",t,"bin",n),s(c,"..","..","..","..","node_modules",t,"bin",n)];for(let u of a)if(f(u))return{cmd:u,args:[]}}let d=[s(c,"bin",n),s(c,"..","bin",n),s(c,"..","..","..","..","v16-runner","dist",n),s(c,"..","..","..","v16-runner","dist",n),s(c,"..","..","v16-runner","dist",n),s(process.cwd(),"v16-runner","dist",n),s(process.cwd(),"..","v16-runner","dist",n)];for(let t of d)if(f(t))return{cmd:t,args:[]};let l=[s(c,"..","..","v16-runner"),s(c,"..","..","..","..","v16-runner"),s(c,"..","..","..","v16-runner"),s(process.cwd(),"v16-runner"),s(process.cwd(),"..","v16-runner")];for(let t of l)if(f(s(t,"main.py"))){for(let u of[s(t,".venv","bin","python"),s(t,"..",".venv","bin","python"),s(t,"..","browser-agent",".venv","bin","python")])if(f(u))return{cmd:u,args:["main.py"],cwd:t};let a=B();if(a)return{cmd:a,args:["main.py"],cwd:t}}return null}function I(e){return e?k(V(),".testmuai","kaneai","sessions",e,"runner-stderr.log"):null}function K(e){let n=U(e.runner.cmd,e.runner.args,{stdio:["pipe","pipe","pipe"],env:e.env,cwd:e.runner.cwd});n.stdin.on("error",()=>{});let r=I(e.sessionId);if(r)try{C(v(r),{recursive:!0})}catch{}let i=1e5,o="";n.stderr.on("data",u=>{if(o+=u.toString(),o.length>i&&(o=o.slice(-i)),r)try{h(r,u)}catch{}}),n.on("error",u=>{e.log?.("error","RUNNER_SPAWN_ERROR","Runner spawn error",{error:u.message})});let d=null,l=null,t=new Promise(u=>{n.on("close",(p,g)=>{d=p,l=g?String(g):null,e.log?.("info","RUNNER_EXIT","Runner exited",{code:p,signal:l??"none"}),u({code:p,signal:l})})}),a=N(n.stdout);return{child:n,events:a,getStderr:()=>o,getExitCode:()=>d,getExitSignal:()=>l,exited:t}}async function G(e,n){if(!n?.platform||!n.target)return;if(y(n.target)){e.TESTMU_RUN_TARGET??="cloud",e.LT_HUB_URL??=m(e.TESTMUAI_ENV==="stage"?"stage":"prod").mobileHubUrl;return}let r=await R(n.platform)?.toolEnv(n.target)??{dirs:[]};if(r.dirs.length>0&&(e.PATH=[...r.dirs,e.PATH??""].filter(Boolean).join(P)),r.appiumHome&&(e.APPIUM_HOME=r.appiumHome),r.wdaRoot&&(e.TESTMU_IOS_WDA_DERIVED_DATA=r.wdaRoot),n.platform==="android"){let i=S();i&&(e.PATH=[i.platformToolsDir,e.PATH??""].filter(Boolean).join(P),e.ANDROID_HOME=i.root,e.ANDROID_SDK_ROOT=i.root)}}function j(e){let n={...process.env,...E(process.env)};e.environment&&(n.TESTMUAI_ENV=e.environment),n.TESTMUAI_SOURCE="kane-cli",process.platform==="win32"&&(n.PYTHONIOENCODING="utf-8",n.PYTHONUTF8="1");let r=m(e.environment);n.V16_SERVER_API_HOST=r.v16ServerHost,n.ATMS_URL=r.tmsBaseUrl.replace(/\/api\/?$/,""),e.username&&e.accessKey&&(n.LT_USERNAME=e.username,n.LT_ACCESS_KEY=e.accessKey),e.sessionId&&(n.TESTMUAI_SESSION_ID=e.sessionId);let i=w(e.mode??"testing");Object.assign(n,i.set);for(let a of i.unset)delete n[a];let o=new A().load(),d=b(e.assertionMode??(o.assertion_mode==="visual"?"visual":"dom"));Object.assign(n,d.set);for(let a of d.unset)delete n[a];let l=e.finalValidation??o.final_validation,t=O(l);Object.assign(n,t.set);for(let a of t.unset)delete n[a];return n}function W(e,n){let r=m(n?.environment),i=x();i!==void 0&&e.ap_mode===void 0&&(e.ap_mode=i),e.telemetry_proxy_url===void 0&&(e.telemetry_proxy_url=T()),e.media_upload===void 0&&e.org_id&&e.username&&e.access_key&&(e.media_upload=$(r,e.org_id))}function $(e,n){return{url:e.shareApiBaseUrl.replace(/\/$/,"")+"/mfs/v1.0/media/upload",artefacts_host:e.mediaArtefactsHost,org_id:n,media_dir:_,files_url:e.tmsBaseUrl.replace(/\/api\/?$/,"")}}async function ce(e,n){let r=H();if(!r)throw new Error("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available.");process.env.KANE_SPAWN_DEBUG&&process.stderr.write(`[spawn-debug] ${JSON.stringify(r)}
3
+ `);let i=j({environment:n?.environment,mode:n?.mode,assertionMode:n?.assertionMode,finalValidation:n?.finalValidation,username:e.username,accessKey:e.access_key,sessionId:e.session_id});e.device?.platform&&await G(i,e.device),W(e,{environment:n?.environment});let o=K({env:i,runner:r,log:n?.log,sessionId:e.session_id}),d=o.child;d.stdin.write(JSON.stringify(e)+`
4
+ `);let l=I(e.session_id);if(l)try{C(v(l),{recursive:!0}),h(l,`--- runner spawn ${new Date().toISOString()} run_index=${e.run_index} ---
5
+ `)}catch{}return{child:d,events:o.events,sendUserResponse(t){let a=JSON.stringify({type:"user_response",answer:t});try{d.stdin.write(a+`
6
+ `)}catch{}},sendCancel(t){let a=JSON.stringify({type:"cancel",reason:t});try{d.stdin.write(a+`
7
+ `)}catch{}},cancel(){d.kill("SIGTERM")},get stderr(){return o.getStderr()},get exitCode(){return o.getExitCode()},get exitSignal(){return o.getExitSignal()},exited:o.exited}}export{H as a,K as b,G as c,j as d,W as e,$ as f,ce as g};
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as $}from"./chunk-MMBBQ4OZ.js";import{j as h}from"./chunk-NRAPCFI2.js";import{a as w}from"./chunk-RZ4F3BHX.js";import{b as v}from"./chunk-J4FIESTB.js";import{spawn as V,spawnSync as _}from"child_process";import{createServer as K}from"net";import{mkdirSync as g,openSync as W,readFileSync as I,renameSync as j,rmSync as x,statSync as Y,writeFileSync as M}from"fs";import{readFile as q}from"fs/promises";import{dirname as l,join as y}from"path";var G=[4723,4724,4725,4726,4727,4728,4729,4730],X={emulator:4750,simulator:4790},z=40,E=2e3,D=3e4,T=500,Ce=["emulator","simulator"];function Q(e){return y(v,"mobile",`appium-server-${e}.log`)}function m(){return y(v,"mobile","appium-servers.json")}function Z(){return y(v,"mobile","appium-servers.lock")}var ee=1e4,re=50;function C(e){let r=Z();try{g(l(r),{recursive:!0})}catch{return e()}let n=!1;for(let o=0;o<re;o++)try{g(r),n=!0;break}catch{try{Date.now()-Y(r).mtimeMs>ee&&x(r,{recursive:!0,force:!0})}catch{}ne(10)}try{return e()}finally{if(n)try{x(r,{recursive:!0,force:!0})}catch{}}}function ne(e){try{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}catch{}}function te(){try{let e=JSON.parse(I(m(),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}function oe(e){let r=m();g(l(r),{recursive:!0});let n=`${r}.tmp`;M(n,JSON.stringify(e,null,2)),j(n,r)}function se(e,r,n){return`Another mobile session is already running${n?` on ${n}`:""}. Wait for it to finish, or close the terminal running it.`}var A=class extends Error{constructor(n,o){super(n);this.port=o;this.name="DeviceBusyError"}};function ie(e){return w(e,{signal:AbortSignal.timeout(E)}).then(r=>r.ok,()=>!1)}async function ae(e,r){try{return(await w(`http://127.0.0.1:${e}/session/${r}`,{method:"DELETE",signal:AbortSignal.timeout(E)})).ok}catch{return!1}}function R(e){let r=e?.value;return Array.isArray(r)?r.map(n=>{let o=n??{},t=o.capabilities??o;return{...typeof o.id=="string"?{id:o.id}:{},caps:t}}):[]}async function ue(e){try{let r=await w(`http://127.0.0.1:${e}/sessions`,{signal:AbortSignal.timeout(E)});return r.ok?R(await r.json()):[]}catch{return[]}}var ce=["udid","appium:udid","deviceUDID","appium:deviceUDID","deviceName","appium:deviceName"];function L(){let e=r=>{try{let n=_("curl",["-s","--noproxy","*","--max-time","2",...r],{encoding:"utf8",timeout:5e3});return{ok:n.status===0,stdout:n.stdout??""}}catch{return{ok:!1,stdout:""}}};return{readState:()=>{try{let r=JSON.parse(I(m(),"utf8"));return Array.isArray(r)?r:[]}catch{return[]}},alive:b,getJson:r=>{let n=e([r]);if(n.ok)try{return JSON.parse(n.stdout)}catch{return}},del:r=>{let n=e(["-o","/dev/null","-w","%{http_code}","-X","DELETE",r]);return n.ok&&/^2\d\d$/.test(n.stdout.trim())}}}function Le(e,r={}){let n={...L(),...r},o=0;try{for(let t of n.readState()){if(!n.alive(t.pid))continue;let i=R(n.getJson(`http://127.0.0.1:${t.port}/sessions`));for(let s of i)s.id&&de(s.caps,e.udid,e.displayName)&&n.del(`http://127.0.0.1:${t.port}/session/${s.id}`)&&(o+=1)}}catch{}return o}function de(e,r,n){let o=[r,n].filter(t=>!!t).map(t=>t.toLowerCase());for(let t of ce){let i=e[t];if(typeof i=="string"&&o.includes(i.toLowerCase()))return!0}return!1}function pe(e,r,n){let o=W(n.logPath,"a"),t=V(e,r,{stdio:["ignore",o,o],detached:!0,env:{...process.env,...n.env}});return t.unref(),t.pid}async function le(e,r){for(let n=e;n<e+r;n++)if(await new Promise(t=>{let i=K();i.once("error",()=>t(!1)),i.once("listening",()=>i.close(()=>t(!0))),i.listen(n)}))return n;throw new Error(`No free port for the managed Appium server in ${e}-${e+r-1}.`)}function b(e){try{return process.kill(e,0),!0}catch{return!1}}function P(e){try{let r=_("ps",["-o","comm=","-p",String(e)],{encoding:"utf8",timeout:2e3});if(r.status!==0)return!1;let n=r.stdout.trim().toLowerCase();return n===""?!0:n.includes("node")||n.includes("kane")}catch{return!0}}function k(e){try{process.kill(e)}catch{}}async function me(){try{let e=JSON.parse(await q(m(),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}async function fe(e){let r=process.pid,n=e.filter(o=>o.owner===r);C(()=>{let o=[];for(let t of te())t.owner!==r&&(Se(t)?o.push(t):b(t.pid)&&k(t.pid));oe([...o,...n])})}function Se(e){return e.owner===void 0?!1:b(e.owner)&&P(e.owner)}function ve(){return{probe:ie,sessions:ue,deleteSession:ae,spawn:pe,freePort:le,alive:b,kill:k,readState:me,writeState:fe,owner:process.pid,depsEnv:e=>h().environment(e),bundleVersion:async e=>(await h().status(e)).version,nodeBinary:process.execPath,env:process.env,os:process.platform,now:()=>Date.now(),sleep:e=>new Promise(r=>setTimeout(r,e))}}function we(e,r,n){if(!e.platformToolsDir)return{};let o=n==="win32"?";":":",t=$(r),i=t?.root??l(e.platformToolsDir),s=t?.platformToolsDir??e.platformToolsDir;return{ANDROID_HOME:i,ANDROID_SDK_ROOT:i,PATH:r.PATH?`${s}${o}${r.PATH}`:s}}async function ge(e){let r=await e.readState(),n=[],o=[];for(let t of r)t.owner!==void 0&&e.alive(t.owner)&&(e.ownerIsOurs??P)(t.owner)?n.push(t):o.push(t);for(let t of o){let i=e.ownerIsOurs??P;e.alive(t.pid)&&i(t.pid)&&e.kill(t.pid)}return o.length>0&&await e.writeState(n),n}async function Je(e,r={}){if(r.appiumUrl)return{result:"external",url:r.appiumUrl};let n={...ve(),...r.deps},o=await ge(n),t=o.filter(a=>a.owner===n.owner),i=new Set(t.map(a=>a.port)),s=new Set(o.map(a=>a.port));if(r.device){let a=await ye(n,s,i,e);if(a!==null)throw new A(se(r.device,a.port,a.device),a.port)}let c=await n.bundleVersion(e),u=t.find(a=>a.deviceClass===e&&(a.bundleVersion??c)===c);if(u&&await n.probe(`http://127.0.0.1:${u.port}/status`))return{result:"reused",url:`http://127.0.0.1:${u.port}`};for(let a of t.filter(S=>S.deviceClass===e&&S!==u))n.kill(a.pid);u&&n.kill(u.pid);let d=await n.depsEnv(e);if(!d.appiumHome)throw new Error(`The managed dependencies for the ${e} class are not installed.
2
+ import{a as $}from"./chunk-MMBBQ4OZ.js";import{j as h}from"./chunk-JM45SLKV.js";import{b as v}from"./chunk-YKOZBFR3.js";import{a as w}from"./chunk-RZ4F3BHX.js";import{spawn as V,spawnSync as _}from"child_process";import{createServer as K}from"net";import{mkdirSync as g,openSync as W,readFileSync as I,renameSync as j,rmSync as x,statSync as Y,writeFileSync as M}from"fs";import{readFile as q}from"fs/promises";import{dirname as l,join as y}from"path";var G=[4723,4724,4725,4726,4727,4728,4729,4730],X={emulator:4750,simulator:4790},z=40,E=2e3,D=3e4,T=500,Ce=["emulator","simulator"];function Q(e){return y(v,"mobile",`appium-server-${e}.log`)}function m(){return y(v,"mobile","appium-servers.json")}function Z(){return y(v,"mobile","appium-servers.lock")}var ee=1e4,re=50;function C(e){let r=Z();try{g(l(r),{recursive:!0})}catch{return e()}let n=!1;for(let o=0;o<re;o++)try{g(r),n=!0;break}catch{try{Date.now()-Y(r).mtimeMs>ee&&x(r,{recursive:!0,force:!0})}catch{}ne(10)}try{return e()}finally{if(n)try{x(r,{recursive:!0,force:!0})}catch{}}}function ne(e){try{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}catch{}}function te(){try{let e=JSON.parse(I(m(),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}function oe(e){let r=m();g(l(r),{recursive:!0});let n=`${r}.tmp`;M(n,JSON.stringify(e,null,2)),j(n,r)}function se(e,r,n){return`Another mobile session is already running${n?` on ${n}`:""}. Wait for it to finish, or close the terminal running it.`}var A=class extends Error{constructor(n,o){super(n);this.port=o;this.name="DeviceBusyError"}};function ie(e){return w(e,{signal:AbortSignal.timeout(E)}).then(r=>r.ok,()=>!1)}async function ae(e,r){try{return(await w(`http://127.0.0.1:${e}/session/${r}`,{method:"DELETE",signal:AbortSignal.timeout(E)})).ok}catch{return!1}}function R(e){let r=e?.value;return Array.isArray(r)?r.map(n=>{let o=n??{},t=o.capabilities??o;return{...typeof o.id=="string"?{id:o.id}:{},caps:t}}):[]}async function ue(e){try{let r=await w(`http://127.0.0.1:${e}/sessions`,{signal:AbortSignal.timeout(E)});return r.ok?R(await r.json()):[]}catch{return[]}}var ce=["udid","appium:udid","deviceUDID","appium:deviceUDID","deviceName","appium:deviceName"];function L(){let e=r=>{try{let n=_("curl",["-s","--noproxy","*","--max-time","2",...r],{encoding:"utf8",timeout:5e3});return{ok:n.status===0,stdout:n.stdout??""}}catch{return{ok:!1,stdout:""}}};return{readState:()=>{try{let r=JSON.parse(I(m(),"utf8"));return Array.isArray(r)?r:[]}catch{return[]}},alive:b,getJson:r=>{let n=e([r]);if(n.ok)try{return JSON.parse(n.stdout)}catch{return}},del:r=>{let n=e(["-o","/dev/null","-w","%{http_code}","-X","DELETE",r]);return n.ok&&/^2\d\d$/.test(n.stdout.trim())}}}function Le(e,r={}){let n={...L(),...r},o=0;try{for(let t of n.readState()){if(!n.alive(t.pid))continue;let i=R(n.getJson(`http://127.0.0.1:${t.port}/sessions`));for(let s of i)s.id&&de(s.caps,e.udid,e.displayName)&&n.del(`http://127.0.0.1:${t.port}/session/${s.id}`)&&(o+=1)}}catch{}return o}function de(e,r,n){let o=[r,n].filter(t=>!!t).map(t=>t.toLowerCase());for(let t of ce){let i=e[t];if(typeof i=="string"&&o.includes(i.toLowerCase()))return!0}return!1}function pe(e,r,n){let o=W(n.logPath,"a"),t=V(e,r,{stdio:["ignore",o,o],detached:!0,env:{...process.env,...n.env}});return t.unref(),t.pid}async function le(e,r){for(let n=e;n<e+r;n++)if(await new Promise(t=>{let i=K();i.once("error",()=>t(!1)),i.once("listening",()=>i.close(()=>t(!0))),i.listen(n)}))return n;throw new Error(`No free port for the managed Appium server in ${e}-${e+r-1}.`)}function b(e){try{return process.kill(e,0),!0}catch{return!1}}function P(e){try{let r=_("ps",["-o","comm=","-p",String(e)],{encoding:"utf8",timeout:2e3});if(r.status!==0)return!1;let n=r.stdout.trim().toLowerCase();return n===""?!0:n.includes("node")||n.includes("kane")}catch{return!0}}function k(e){try{process.kill(e)}catch{}}async function me(){try{let e=JSON.parse(await q(m(),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}async function fe(e){let r=process.pid,n=e.filter(o=>o.owner===r);C(()=>{let o=[];for(let t of te())t.owner!==r&&(Se(t)?o.push(t):b(t.pid)&&k(t.pid));oe([...o,...n])})}function Se(e){return e.owner===void 0?!1:b(e.owner)&&P(e.owner)}function ve(){return{probe:ie,sessions:ue,deleteSession:ae,spawn:pe,freePort:le,alive:b,kill:k,readState:me,writeState:fe,owner:process.pid,depsEnv:e=>h().environment(e),bundleVersion:async e=>(await h().status(e)).version,nodeBinary:process.execPath,env:process.env,os:process.platform,now:()=>Date.now(),sleep:e=>new Promise(r=>setTimeout(r,e))}}function we(e,r,n){if(!e.platformToolsDir)return{};let o=n==="win32"?";":":",t=$(r),i=t?.root??l(e.platformToolsDir),s=t?.platformToolsDir??e.platformToolsDir;return{ANDROID_HOME:i,ANDROID_SDK_ROOT:i,PATH:r.PATH?`${s}${o}${r.PATH}`:s}}async function ge(e){let r=await e.readState(),n=[],o=[];for(let t of r)t.owner!==void 0&&e.alive(t.owner)&&(e.ownerIsOurs??P)(t.owner)?n.push(t):o.push(t);for(let t of o){let i=e.ownerIsOurs??P;e.alive(t.pid)&&i(t.pid)&&e.kill(t.pid)}return o.length>0&&await e.writeState(n),n}async function Je(e,r={}){if(r.appiumUrl)return{result:"external",url:r.appiumUrl};let n={...ve(),...r.deps},o=await ge(n),t=o.filter(a=>a.owner===n.owner),i=new Set(t.map(a=>a.port)),s=new Set(o.map(a=>a.port));if(r.device){let a=await ye(n,s,i,e);if(a!==null)throw new A(se(r.device,a.port,a.device),a.port)}let c=await n.bundleVersion(e),u=t.find(a=>a.deviceClass===e&&(a.bundleVersion??c)===c);if(u&&await n.probe(`http://127.0.0.1:${u.port}/status`))return{result:"reused",url:`http://127.0.0.1:${u.port}`};for(let a of t.filter(S=>S.deviceClass===e&&S!==u))n.kill(a.pid);u&&n.kill(u.pid);let d=await n.depsEnv(e);if(!d.appiumHome)throw new Error(`The managed dependencies for the ${e} class are not installed.
3
3
  Run \`kane-cli doctor --target ${e} --install\` to install them, or pass --appium-url for an external server.`);let p=await n.freePort(X[e],z),O=`http://127.0.0.1:${p}`,J=l(d.appiumHome),U=y(J,"appium","node_modules","appium","index.js"),N=Q(e);r.onProgress?.(`starting the managed Appium server (${e}, port ${p})\u2026`);let f=n.spawn(n.nodeBinary,[U,"--port",String(p),"--allow-insecure=uiautomator2:adb_shell"],{env:{APPIUM_HOME:d.appiumHome,...we(d,n.env,n.os)},logPath:N}),B=n.now()+D,F=Math.ceil(D/T)+1;for(let a=0;a<F&&n.now()<B;a++)if(await n.sleep(T),await n.probe(`${O}/status`)){if(f!==void 0){let S=t.filter(H=>H.deviceClass!==e);await n.writeState([...S,{port:p,pid:f,owner:n.owner,deviceClass:e,...c?{bundleVersion:c}:{},startedAt:new Date(n.now()).toISOString()}])}return r.onProgress?.("Appium server ready"),{result:"started",url:O}}throw f!==void 0&&n.kill(f),new Error(`The managed Appium server (${e}) did not answer on ${p} within ${D/1e3}s.
4
4
  Check its log: ${N}`)}async function ye(e,r=[],n=[],o){let t=new Set(n),i=new Set([...G,...r]);for(let s of i)if(!t.has(s))for(let c of await e.sessions(s)){if(!c.id)continue;if(o){let d=be(c.caps);if(d&&d!==o)continue}let u=De(c.caps);return{port:s,...u?{device:u}:{}}}return null}function be(e){let r=t=>{let i=e[t];return typeof i=="string"?i.toLowerCase():""},n=r("platformName")||r("appium:platformName");if(n.includes("ios"))return"simulator";if(n.includes("android"))return"emulator";let o=r("appium:automationName")||r("automationName");if(o.includes("xcuitest"))return"simulator";if(o.includes("uiautomator"))return"emulator"}var he=["appium:deviceName","deviceName","appium:udid","udid","appium:deviceUDID","deviceUDID"];function De(e){for(let r of he){let n=e[r];if(typeof n=="string"&&n.trim())return n}}function Ue(e={}){let r={...L(),kill:k,writeState:Ae,...e.deps};try{let n=r.readState(),o=e.owner??process.pid,t=n.filter(s=>s.owner===o&&(!e.deviceClass||s.deviceClass===e.deviceClass));for(let s of t){if(!r.alive(s.pid))continue;let c=R(r.getJson(`http://127.0.0.1:${s.port}/sessions`));for(let u of c)u.id&&r.del(`http://127.0.0.1:${s.port}/session/${u.id}`);r.kill(s.pid)}let i=new Set(t.map(s=>`${s.port}:${s.pid}`));C(()=>{r.writeState(r.readState().filter(s=>!i.has(`${s.port}:${s.pid}`)))})}catch{}}function Ae(e){try{let r=m();g(l(r),{recursive:!0}),M(r,JSON.stringify(e,null,2))}catch{}}export{Ce as a,Q as b,se as c,Le as d,ve as e,Je as f,ye as g,Ue as h};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as l}from"./chunk-WD52ZNQY.js";import{b as i,d as p,e as f,g,h as u}from"./chunk-77ZZQJLX.js";import{b as d}from"./chunk-LV7224DG.js";import{existsSync as t,mkdirSync as w,readFileSync as S,renameSync as y,writeFileSync as D}from"fs";import{join as j}from"path";function O(r){l(i(r));let a=i(r);if(!t(a))return;let s=j(a,"meta.json"),n=f(r);if(t(s)&&!t(n))try{w(p(r),{recursive:!0}),y(s,n)}catch(e){process.stderr.write(`warn: meta.json migration failed: ${e.message}
2
+ import{b as l}from"./chunk-WD52ZNQY.js";import{b as i,d as p,e as f,g,h as u}from"./chunk-77ZZQJLX.js";import{b as d}from"./chunk-QXZGBYGQ.js";import{existsSync as t,mkdirSync as w,readFileSync as S,renameSync as y,writeFileSync as D}from"fs";import{join as j}from"path";function O(r){l(i(r));let a=i(r);if(!t(a))return;let s=j(a,"meta.json"),n=f(r);if(t(s)&&!t(n))try{w(p(r),{recursive:!0}),y(s,n)}catch(e){process.stderr.write(`warn: meta.json migration failed: ${e.message}
3
3
  `)}let c=u(r);if(t(c)){let e="python";try{let o=new d().load();o.code_export?.language&&(e=o.code_export.language)}catch{}let m=g(r,"playwright",e);if(!t(m))try{y(c,m)}catch(o){process.stderr.write(`warn: generated-code migration failed: ${o.message}
4
4
  `)}}if(t(n))try{let e=JSON.parse(S(n,"utf8"));"md5sum"in e&&(delete e.md5sum,D(n,JSON.stringify(e,null,2)+`
5
5
  `,"utf8"))}catch(e){process.stderr.write(`warn: meta.json md5sum strip failed: ${e.message}
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as d}from"./chunk-73ZFOJOK.js";import{a as m}from"./chunk-EZMRWXRT.js";import{da as u}from"./chunk-PI7OXS62.js";function h(e,r){return`${e}:hold:${r}`}function g(e,r){let n=[],o=[];for(let i of e.use_cases){let c=i.matches_existing;c?.cid&&r.hasNode(c.cid)?n.push({ref:c.cid,expectedTip:r.tipOf(c.cid)}):o.push({tempRef:i.temp_ref,title:String(i.title??""),probeText:String(i.title??"")})}return{verb:"extract",ucTargets:n,newBuCandidates:o,sourcePins:[{source_id:e.source.source_id,source_cid:e.source.source_cid}],readBasis:e.read_basis??null}}async function b(e){let r=d(e.proposal),n=t=>r.passthrough.use_cases.filter(a=>{let l=a.matches_existing?.cid,s=l?t.resolve(l):null,p=s?t.tipOf(s.cid):null;return p!=null&&(e.matchUnreviewed===!0||(t.trust.get(p)??null)!=="derived")}),o=n(e.graph),i=new Set(o.map(t=>t.temp_ref));return{ok:(await m(e.ctx,{...g({...r.passthrough,use_cases:o},e.graph),eventIds:[h(e.sid,e.proposalId)]},t=>{let a={...r.passthrough,use_cases:n(t.graph).filter(p=>i.has(p.temp_ref))},l=new Map(a.use_cases.map(p=>[p.temp_ref,{resolution:"approved"}])),s=u({store:e.store,graph:t.graph,scope:t.scope,proposal:a,proposalId:e.proposalId,verdicts:l,by:e.by,autoName:!0,allowStaleBasis:!0,eventIds:t.eventIds("extract",1),...e.durable?{sid:t.sid}:{},probeHits:t.probeHits,...e.matchUnreviewed?{matchUnreviewed:!0}:{}});return s.errors!==null?{errors:s.errors}:{result:s,record:s.record}})).ok,skippedAttach:r.passthrough.use_cases.length-o.length}}export{h as a,g as b,b as c};
2
+ import{b as d}from"./chunk-73ZFOJOK.js";import{a as m}from"./chunk-OVB5GVRB.js";import{da as u}from"./chunk-5EAJO372.js";function h(e,r){return`${e}:hold:${r}`}function g(e,r){let n=[],o=[];for(let i of e.use_cases){let c=i.matches_existing;c?.cid&&r.hasNode(c.cid)?n.push({ref:c.cid,expectedTip:r.tipOf(c.cid)}):o.push({tempRef:i.temp_ref,title:String(i.title??""),probeText:String(i.title??"")})}return{verb:"extract",ucTargets:n,newBuCandidates:o,sourcePins:[{source_id:e.source.source_id,source_cid:e.source.source_cid}],readBasis:e.read_basis??null}}async function b(e){let r=d(e.proposal),n=t=>r.passthrough.use_cases.filter(a=>{let l=a.matches_existing?.cid,s=l?t.resolve(l):null,p=s?t.tipOf(s.cid):null;return p!=null&&(e.matchUnreviewed===!0||(t.trust.get(p)??null)!=="derived")}),o=n(e.graph),i=new Set(o.map(t=>t.temp_ref));return{ok:(await m(e.ctx,{...g({...r.passthrough,use_cases:o},e.graph),eventIds:[h(e.sid,e.proposalId)]},t=>{let a={...r.passthrough,use_cases:n(t.graph).filter(p=>i.has(p.temp_ref))},l=new Map(a.use_cases.map(p=>[p.temp_ref,{resolution:"approved"}])),s=u({store:e.store,graph:t.graph,scope:t.scope,proposal:a,proposalId:e.proposalId,verdicts:l,by:e.by,autoName:!0,allowStaleBasis:!0,eventIds:t.eventIds("extract",1),...e.durable?{sid:t.sid}:{},probeHits:t.probeHits,...e.matchUnreviewed?{matchUnreviewed:!0}:{}});return s.errors!==null?{errors:s.errors}:{result:s,record:s.record}})).ok,skippedAttach:r.passthrough.use_cases.length-o.length}}export{h as a,g as b,b as c};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{h as I}from"./chunk-SXRHKXSE.js";import{f as c,h as w,i as y,l,q as f,t as A}from"./chunk-A7RJQJNT.js";import{b as m}from"./chunk-J4FIESTB.js";import{createHash as U}from"crypto";import{createReadStream as F}from"fs";import{mkdir as x,readFile as P,rename as $,writeFile as D}from"fs/promises";import{dirname as b,join as E}from"path";var k=60,S=5;function C(){return{entries:[]}}function v(){return E(m,"mobile","app-cache.json")}async function h(e){let r=U("sha256");for await(let t of F(e))r.update(t);return r.digest("hex")}function N(){return{readFile:e=>P(e,"utf8"),writeFile:async(e,r)=>{await x(b(e),{recursive:!0});let t=`${e}.tmp`;await D(t,r),await $(t,e)},hashFile:h,now:()=>new Date}}function g(e){if(!e)return;let r=/\/(\d{4})\/(\d{2})\/(\d{2})\//.exec(e);if(!r)return;let[,t,a,i]=r,o=new Date(`${t}-${a}-${i}T00:00:00Z`);return Number.isNaN(o.getTime())?void 0:o.toISOString()}function O(e,r){if(!e.storedAt)return!0;let t=new Date(e.storedAt).getTime();return Number.isNaN(t)?!0:(r.getTime()-t)/864e5>=k-S}var d=class{deps;constructor(r={}){this.deps={...N(),...r}}async read(){try{let r=JSON.parse(await this.deps.readFile(v()));if(!r||typeof r!="object")return C();let t=r;return{entries:Array.isArray(t.entries)?t.entries:[]}}catch{return C()}}async write(r){await this.deps.writeFile(v(),JSON.stringify(r,null,2))}async hashOf(r){return this.deps.hashFile(r)}async lookup(r){return(await this.read()).entries.find(a=>a.sha256===r.sha256&&a.env===r.env&&a.orgId===r.orgId&&a.type===r.type)}async remember(r){let t=await this.read();t.entries=[...t.entries.filter(a=>!(a.sha256===r.sha256&&a.env===r.env&&a.orgId===r.orgId&&a.type===r.type)),r],await this.write(t)}async forget(r){let t=await this.read(),a=t.entries.length;t.entries=t.entries.filter(i=>!(i.sha256===r.sha256&&i.env===r.env&&i.orgId===r.orgId&&i.type===r.type)),t.entries.length!==a&&await this.write(t)}isNearExpiry(r){return O(r,this.deps.now())}};import{createHash as j}from"crypto";import{readdir as T,stat as _}from"fs/promises";import{basename as p,extname as B,join as R,relative as Y}from"path";function ae(e){return e.skipped===!0}function H(e,r){return A(r,e)?null:B(e).toLowerCase()===".ipa"&&!c(r)?`${p(e)} is a device build \u2014 .ipa is not accepted for ${r} runs.`:c(r)?`${p(e)} is not an ${y(w(r))} build \u2014 ${l(r)} takes ${f(r).join(" or ")}.`:`${p(e)} cannot be uploaded for ${l(r)} \u2014 expected one of ${f(r).join(", ")}.`}async function J(e,r){if(!(await _(e)).isDirectory())return r.hashOf(e);let a=[],i=async n=>{for(let s of await T(n,{withFileTypes:!0})){let u=R(n,s.name);s.isDirectory()?await i(u):s.isFile()&&a.push(u)}};await i(e),a.sort();let o=j("sha256");for(let n of a)o.update(Y(e,n)),o.update("\0"),o.update(await h(n)),o.update("\0");return o.digest("hex")}async function se(e){let r=H(e.path,e.type);if(r)return{skipped:!0,reason:r};let t=e.cache??new d,a=e.client??new I(e.baseUrl,{...e.auth,orgId:e.orgId}),i;try{i=await J(e.path,t)}catch(s){return{skipped:!0,reason:`could not read ${p(e.path)}: ${s.message}`}}let o={sha256:i,env:e.env,orgId:e.orgId,type:e.type},n=await t.lookup(o);if(n){if(await a.liveness(n.appId)!=="gone")return{appId:n.appId,...n.appUrl?{appUrl:n.appUrl}:{},fromCache:!0};e.onProgress?.(`${n.appId} is no longer in the cloud \u2014 uploading again`),await t.forget(o)}try{e.onProgress?.(`uploading ${p(e.path)}\u2026`);let s=await a.upload(e.path,e.type);return await t.remember({sha256:i,env:e.env,orgId:e.orgId,type:e.type,appId:s.appId,...s.appUrl?{appUrl:s.appUrl}:{},...g(s.url)?{storedAt:g(s.url)}:{},sourcePath:e.path}),e.onProgress?.(s.cached?`${p(e.path)} already in the cloud (${s.appId})`:`${p(e.path)} uploaded (${s.appId})`),{appId:s.appId,...s.appUrl?{appUrl:s.appUrl}:{},fromCache:!1}}catch(s){return{skipped:!0,reason:s.message}}}export{d as a,ae as b,H as c,J as d,se as e};
2
+ import{h as I}from"./chunk-MTMHB5LF.js";import{b as m}from"./chunk-YKOZBFR3.js";import{f as c,h as w,i as y,l,q as f,t as A}from"./chunk-A7RJQJNT.js";import{createHash as U}from"crypto";import{createReadStream as F}from"fs";import{mkdir as x,readFile as P,rename as $,writeFile as D}from"fs/promises";import{dirname as b,join as E}from"path";var k=60,S=5;function C(){return{entries:[]}}function v(){return E(m,"mobile","app-cache.json")}async function h(e){let r=U("sha256");for await(let t of F(e))r.update(t);return r.digest("hex")}function N(){return{readFile:e=>P(e,"utf8"),writeFile:async(e,r)=>{await x(b(e),{recursive:!0});let t=`${e}.tmp`;await D(t,r),await $(t,e)},hashFile:h,now:()=>new Date}}function g(e){if(!e)return;let r=/\/(\d{4})\/(\d{2})\/(\d{2})\//.exec(e);if(!r)return;let[,t,a,i]=r,o=new Date(`${t}-${a}-${i}T00:00:00Z`);return Number.isNaN(o.getTime())?void 0:o.toISOString()}function O(e,r){if(!e.storedAt)return!0;let t=new Date(e.storedAt).getTime();return Number.isNaN(t)?!0:(r.getTime()-t)/864e5>=k-S}var d=class{deps;constructor(r={}){this.deps={...N(),...r}}async read(){try{let r=JSON.parse(await this.deps.readFile(v()));if(!r||typeof r!="object")return C();let t=r;return{entries:Array.isArray(t.entries)?t.entries:[]}}catch{return C()}}async write(r){await this.deps.writeFile(v(),JSON.stringify(r,null,2))}async hashOf(r){return this.deps.hashFile(r)}async lookup(r){return(await this.read()).entries.find(a=>a.sha256===r.sha256&&a.env===r.env&&a.orgId===r.orgId&&a.type===r.type)}async remember(r){let t=await this.read();t.entries=[...t.entries.filter(a=>!(a.sha256===r.sha256&&a.env===r.env&&a.orgId===r.orgId&&a.type===r.type)),r],await this.write(t)}async forget(r){let t=await this.read(),a=t.entries.length;t.entries=t.entries.filter(i=>!(i.sha256===r.sha256&&i.env===r.env&&i.orgId===r.orgId&&i.type===r.type)),t.entries.length!==a&&await this.write(t)}isNearExpiry(r){return O(r,this.deps.now())}};import{createHash as j}from"crypto";import{readdir as T,stat as _}from"fs/promises";import{basename as p,extname as B,join as R,relative as Y}from"path";function ae(e){return e.skipped===!0}function H(e,r){return A(r,e)?null:B(e).toLowerCase()===".ipa"&&!c(r)?`${p(e)} is a device build \u2014 .ipa is not accepted for ${r} runs.`:c(r)?`${p(e)} is not an ${y(w(r))} build \u2014 ${l(r)} takes ${f(r).join(" or ")}.`:`${p(e)} cannot be uploaded for ${l(r)} \u2014 expected one of ${f(r).join(", ")}.`}async function J(e,r){if(!(await _(e)).isDirectory())return r.hashOf(e);let a=[],i=async n=>{for(let s of await T(n,{withFileTypes:!0})){let u=R(n,s.name);s.isDirectory()?await i(u):s.isFile()&&a.push(u)}};await i(e),a.sort();let o=j("sha256");for(let n of a)o.update(Y(e,n)),o.update("\0"),o.update(await h(n)),o.update("\0");return o.digest("hex")}async function se(e){let r=H(e.path,e.type);if(r)return{skipped:!0,reason:r};let t=e.cache??new d,a=e.client??new I(e.baseUrl,{...e.auth,orgId:e.orgId}),i;try{i=await J(e.path,t)}catch(s){return{skipped:!0,reason:`could not read ${p(e.path)}: ${s.message}`}}let o={sha256:i,env:e.env,orgId:e.orgId,type:e.type},n=await t.lookup(o);if(n){if(await a.liveness(n.appId)!=="gone")return{appId:n.appId,...n.appUrl?{appUrl:n.appUrl}:{},fromCache:!0};e.onProgress?.(`${n.appId} is no longer in the cloud \u2014 uploading again`),await t.forget(o)}try{e.onProgress?.(`uploading ${p(e.path)}\u2026`);let s=await a.upload(e.path,e.type);return await t.remember({sha256:i,env:e.env,orgId:e.orgId,type:e.type,appId:s.appId,...s.appUrl?{appUrl:s.appUrl}:{},...g(s.url)?{storedAt:g(s.url)}:{},sourcePath:e.path}),e.onProgress?.(s.cached?`${p(e.path)} already in the cloud (${s.appId})`:`${p(e.path)} uploaded (${s.appId})`),{appId:s.appId,...s.appUrl?{appUrl:s.appUrl}:{},fromCache:!1}}catch(s){return{skipped:!0,reason:s.message}}}export{d as a,ae as b,H as c,J as d,se as e};
@@ -0,0 +1,47 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as kr,c as Rr,d as Er,e as Sr,f as Ir}from"./chunk-4WFN23DE.js";import{a as _r,b as Lr,c as jr,d as Tr,e as Cr}from"./chunk-MOAZZKIZ.js";import{c as Vr}from"./chunk-4KFSSETE.js";import{c as z,d as Pe,f as Pr,g as $r,k as Mr,l as me,m as fe,q as Y,v as Hr}from"./chunk-EWK3UPEN.js";import{b as Te,d as le}from"./chunk-ZUZ6QJRA.js";import{a as de,b as L}from"./chunk-KGNE5CIM.js";import{a as mr,b as fr}from"./chunk-6PURZLKM.js";import{b as Ce,c as gr,d as hr,e as xr,f as ue,g as ce,h as wr,i as br,j as yr,k as vr,m as w,n as Q,o as Br,p as Ae,q as Oe,r as Ue,s as Ne}from"./chunk-P7V24ZXP.js";import{e as J,l as pe,n as $e,q as Ar,r as Or,s as Ur,t as Nr}from"./chunk-4WKFM72U.js";import{d as je,f as D}from"./chunk-OSEXVHEN.js";import{a as cr,b as dr}from"./chunk-FQ2AMM3E.js";import{a as lr}from"./chunk-HMGM4KO6.js";import{l as pr}from"./chunk-BV7NUIRT.js";import{a as ur}from"./chunk-UTM7D4PI.js";import{a as sr,b as Le,d as ir}from"./chunk-SBW3QVHN.js";import{b as or}from"./chunk-QXZGBYGQ.js";import{e as tr}from"./chunk-WHMCVH3T.js";import{b as rr}from"./chunk-F2F257PU.js";import{e as nr}from"./chunk-SB26HQO7.js";import{a as er}from"./chunk-FCD3NYOM.js";import{a as ar}from"./chunk-PVN64537.js";import{b as Se}from"./chunk-IQMJJN52.js";import{g as Ie}from"./chunk-CBEMXSWF.js";import{a as X}from"./chunk-4QTH7VYE.js";import{a as ae}from"./chunk-73EHVDL5.js";import{a as ie}from"./chunk-YWQNZRJG.js";import{a as V,b as se,z as ze}from"./chunk-YKOZBFR3.js";import{m as Qe,n as Ye}from"./chunk-WMXBRC4B.js";import{a as q}from"./chunk-RZ4F3BHX.js";import{a as Ze}from"./chunk-FOJHSG5M.js";import{join as De}from"path";function Dr(e){let r=e.now??Date.now,n=r(),t=!1,o=null,i=null,u=e.hxJobId,h=0,a=null,c=l=>({exploration_id:l?.explorationId??o,run_id:l?.runId??i});return{observe:l=>{switch(l.type){case"explore_run_started":typeof l.exploration_id=="string"&&(o=l.exploration_id),typeof l.run_id=="string"&&(i=l.run_id);return;case"explore_remote_started":typeof l.run_id=="string"&&(i=l.run_id),typeof l.hx_job_id=="string"&&(u=l.hx_job_id);return;case"lease_end":h++;return;case"explore_end":l.totals&&typeof l.totals=="object"&&(a=l.totals);return;default:return}},started:()=>t,markStarted:()=>{t=!0},startFields:()=>({...c(),remote:e.remote,on_vm:e.onVm,hx_job_id:u,policy:e.policy,max_parallel:e.maxParallel,max_leases:e.maxLeases}),endFields:l=>({...c(l),remote:e.remote,on_vm:e.onVm,hx_job_id:u,outcome:l.state==="queued"?"queued":l.remark?.code??(l.exitCode===0?"completed":"error"),stop_reason:l.stopReason??null,exit_code:l.exitCode,duration_ms:r()-n,leases:typeof a?.leases=="number"?a.leases:h,findings:typeof a?.findings=="number"?a.findings:null,committed:l.committed??0,pending:l.pending??0,complete:l.complete??!1,credits_total:l.credits?.total??null,peak_parallel:l.peakParallel??null}),errorFields:l=>{if(l.exitCode===0||l.exitCode===3&&!l.error)return null;let f=l.remark?.code?.startsWith("failed:")?l.remark.code:l.exitCode===2?"usage":l.stopReason??"explore_error";return{...c(l),error_code:f,exit_code:l.exitCode,stage:t?"run":"setup",...l.error?{error:l.error}:{}}}}}import{appendFileSync as dt,mkdirSync as pt}from"fs";import{dirname as mt}from"path";function Fr(e,r,n){if(r)try{pt(mt(r),{recursive:!0})}catch{}let t="",o=u=>{if(!(!r||!u))try{dt(r,n(u))}catch{}};e.child.stderr?.on("data",u=>{t+=u.toString();let h=t.lastIndexOf(`
3
+ `);h<0||(o(t.slice(0,h+1)),t=t.slice(h+1))}),e.child.stderr?.on("end",()=>{o(t),t=""});let i=e.getStderr.bind(e);return Object.assign(e,{getStderr:()=>n(i())})}var ft={seeding:"seeding",replay:"replaying",walking:"walking",settling:"settling",verifying:"verifying"},gt=8,ht=6,S=e=>typeof e=="string"&&e?e:null,F=e=>typeof e=="number"&&Number.isFinite(e)?e:null,ge=class{s={run_id:null,exploration_id:null,status:"running",stop_reason:null,progress:null,browsers:[],version:0,updated_at:0};subs=new Set;now;constructor(r={}){this.now=r.now??Date.now}snapshot(){return structuredClone(this.s)}subscribe(r){return this.subs.add(r),()=>{this.subs.delete(r)}}end(r){this.s.status!=="ended"&&(this.s.status="ended",this.s.stop_reason=r,this.s.browsers=[],this.changed())}apply(r){this.reduce(r)&&this.changed()}changed(){if(this.s.version+=1,this.s.updated_at=this.now(),!this.subs.size)return;let r=this.snapshot();for(let n of this.subs)try{n(r)}catch{}}browser(r,n){let t=this.s.browsers.find(o=>o.worker===r)??null;return!t&&n&&(t={worker:r,state:"opening",since:this.now(),lease:null,step:null,steps:[],trail:[],held:null},this.s.browsers.push(t),this.s.browsers.sort((o,i)=>o.worker-i.worker)),t}setState(r,n){r.state!==n&&(r.state=n,r.since=this.now())}reduce(r){let n=F(r.worker_index);switch(r.type){case"explore_start":return this.s.run_id=S(r.run_id),this.s.exploration_id=S(r.exploration_id),this.s.status="running",!0;case"browser_request":return n===null?!1:(this.browser(n,!0),!0);case"browser_release":{if(n===null)return!1;let t=this.s.browsers.length;return this.s.browsers=this.s.browsers.filter(o=>o.worker!==n),this.s.browsers.length!==t}case"lease_start":{if(n===null||!S(r.lease_id))return!1;let t=this.browser(n,!0),o=r.reach&&typeof r.reach=="object"&&!Array.isArray(r.reach)?r.reach:null;return t.lease={id:String(r.lease_id),kind:String(r.kind??""),target:S(r.target),reach:o,started_at:this.now()},t.step=null,t.steps=[],this.setState(t,"starting"),!0}case"lease_step":{if(n===null)return!1;let t=this.browser(n,!1);if(!t||!t.lease||t.lease.id!==r.lease_id)return!1;let o={ordinal:F(r.ordinal)??t.steps.length,phase:String(r.phase??""),intent:S(r.intent),junction_id:S(r.junction_id),known:r.known===!0,url_pattern:S(r.url_pattern),flow_id:S(r.flow_id),navigated:r.navigated===!0,at:this.now()};return t.step=o,t.steps=[...t.steps,o].slice(-gt),o.junction_id&&t.trail[t.trail.length-1]!==o.junction_id&&(t.trail=[...t.trail,o.junction_id].slice(-ht)),this.setState(t,ft[o.phase]??"walking"),!0}case"lease_end":{let t=this.s.browsers.find(o=>o.lease?.id===r.lease_id);return t?(t.lease=null,t.step=null,t.steps=[],this.setState(t,t.held?"holding":"idle"),!0):!1}case"session_held":{if(n===null)return!1;let t=this.browser(n,!0);return t.held={kind:String(r.kind??""),start_flow:S(r.start_flow),junction_id:S(r.junction_id),url_pattern:S(r.url_pattern)},t.lease||this.setState(t,"holding"),!0}case"session_released":{if(n===null)return!1;let t=this.browser(n,!1);return!t||!t.held?!1:(t.held=null,t.lease||this.setState(t,"idle"),!0)}case"progress":return this.s.progress={frontier:F(r.frontier)??0,visited:F(r.visited)??0,active_workers:F(r.active_workers)??0,elapsed_s:F(r.elapsed_s)??0},!0;case"explore_control":return r.control!=="stop"||this.s.status!=="running"?!1:(this.s.status="paused",!0);case"explore_end":return this.s.status="ended",this.s.stop_reason=S(r.stop_reason),this.s.browsers=[],!0;default:return!1}}};var he=class{link=null;wanted=new Map;source=async(r,n)=>(this.wanted.set(r,n),this.link?.start(r),{stop:async()=>{this.wanted.get(r)===n&&(this.wanted.delete(r),this.link?.stop(r))}});attach(r){if(this.link=r,r)for(let n of this.wanted.keys())r.start(n)}frame(r,n){this.wanted.get(r)?.(n)}};var xt=500,wt=1e4,Gr=5e3,bt=async(e,r)=>{let n=new AbortController,t=()=>n.abort(),o=setTimeout(t,r.timeoutMs);r.signal.addEventListener("abort",t,{once:!0});try{let i=await q(e,{method:"POST",headers:r.headers,body:r.body,signal:n.signal}),u=null;try{u=await i.json()}catch{}return{status:i.status,body:u}}finally{clearTimeout(o),r.signal.removeEventListener("abort",t)}},xe=class{constructor(r){this.opts=r;this.post=r.post??bt,this.unsubscribeModel=r.model.subscribe(()=>this.stateChanged())}post;target=null;off=!1;framesOff=!1;abort=new AbortController;unsubscribeModel;stateInFlight=!1;stateDirty=!1;lastStateAt=0;stateTimer=null;heartbeat=null;watched=new Map;stopAsked=!1;waiting=new Map;sending=new Set;arm(r){this.off||(this.letAllGo(),this.abort.abort(),this.abort=new AbortController,this.stateInFlight=!1,this.target=r,this.framesOff=!1,this.stateDirty=!0,this.sendState())}async close(){this.off=!0,this.unsubscribeModel(),this.clearTimers(),this.letAllGo(),this.abort.abort()}url(r,n=""){let t=this.target;return`${t.baseUrl.replace(/\/+$/,"")}${n}/exploration/${encodeURIComponent(t.explorationId)}/runs/${encodeURIComponent(t.runId)}/live/${r}`}stateChanged(){if(this.off||!this.target||(this.stateDirty=!0,this.stateInFlight||this.stateTimer))return;let r=xt-(Date.now()-this.lastStateAt);r<=0?this.sendState():this.stateTimer=setTimeout(()=>{this.stateTimer=null,this.sendState()},r)}sendState(){if(this.off||!this.target||this.stateInFlight)return;let r=this.target;this.stateDirty=!1,this.stateInFlight=!0,this.lastStateAt=Date.now(),this.heartbeat&&clearTimeout(this.heartbeat),this.heartbeat=null;let n;try{n=JSON.stringify(this.opts.model.snapshot())}catch{this.stateInFlight=!1;return}this.post(this.url("state"),{headers:{Authorization:r.authHeader,"Content-Type":"application/json"},body:n,timeoutMs:Gr,signal:this.abort.signal}).then(t=>{if(this.target===r){if(t.status===404||t.status===403||t.status===401)return this.turnOff(t.status);t.status>=200&&t.status<300&&(this.stopIfAsked(t.body),this.follow(t.body))}},()=>{}).finally(()=>{this.target!==r||this.off||(this.stateInFlight=!1,this.heartbeat=setTimeout(()=>{this.heartbeat=null,this.stateDirty=!0,this.sendState()},wt),this.stateDirty&&this.stateChanged())})}turnOff(r){this.off||(this.off=!0,this.clearTimers(),this.letAllGo(),this.abort.abort(),this.opts.onWarn?.(`live view is off for this run: the controller has no live routes (HTTP ${r})`))}stopIfAsked(r){this.stopAsked||!r||typeof r!="object"||r.stop!==!0||(this.stopAsked=!0,this.opts.onStop?.())}follow(r){let n=r&&typeof r=="object"?r.watched:void 0;if(!Array.isArray(n)||this.framesOff)return;let t=new Set(n.filter(o=>Number.isInteger(o)&&o>=0));for(let o of[...this.watched.keys()])t.has(o)||this.letGo(o);for(let o of t)this.watched.has(o)||this.watched.set(o,this.opts.frames.subscribe(new Map([[o,jr]]),i=>this.frame(i)))}frame(r){r.kind!=="frame"||this.off||!this.watched.has(r.worker)||(this.waiting.set(r.worker,{data:r.data,at:r.at}),this.sendFrame(r.worker))}sendFrame(r){if(this.sending.has(r)||!this.target)return;let n=this.waiting.get(r);if(n===void 0)return;this.waiting.delete(r);let t=this.target;this.sending.add(r);let o=Number.isFinite(n.at)?`&at=${Math.round(n.at)}`:"";this.post(`${this.url("frames","/public")}?worker=${r}${o}`,{headers:{"X-Live-Token":t.liveToken,"Content-Type":"image/jpeg"},body:Buffer.from(n.data,"base64"),timeoutMs:Gr,signal:this.abort.signal}).then(i=>{this.target===t&&(i.status===410?this.letGo(r):i.status===401&&!this.framesOff&&(this.framesOff=!0,this.letAllGo(),this.opts.onWarn?.("live frames are off for this run: the controller refused its live token (HTTP 401)")))},()=>{}).finally(()=>{this.target===t&&(this.sending.delete(r),!this.off&&this.watched.has(r)&&this.sendFrame(r))})}letGo(r){let n=this.watched.get(r);this.watched.delete(r),this.waiting.delete(r),n?.()}letAllGo(){for(let r of[...this.watched.keys()])this.letGo(r);this.sending.clear()}clearTimers(){this.stateTimer&&clearTimeout(this.stateTimer),this.heartbeat&&clearTimeout(this.heartbeat),this.stateTimer=this.heartbeat=null}};function we(e,r){return`watch live: kane-cli explore view --exploration-id ${e}${r?` --env ${r}`:""}`}async function Kr(e){let r=new ge,n=new he,t=new Lr({start:e.startSource??n.source}),o=new xe({model:r,frames:t,post:e.post,onWarn:e.onWarn,onStop:e.onStop}),i=!1,u=!1,h=!1;return{model:r,frames:t,onBrowser(a){u||t.addBrowser(a)},offBrowser(a){t.removeBrowser(a)},attachRunner(a){n.attach(u?null:a)},runnerFrame(a,c){u||n.frame(a,c)},onEvent(a){r.apply(a),a.type==="explore_start"&&!i&&typeof a.exploration_id=="string"&&a.exploration_id&&(i=!0,e.onExploration?.(a.exploration_id))},armRun(a){if(!u){if(!a.liveToken){h||e.onWarn?.("live view is off for this run: the controller handed out no live token"),h=!0;return}o.arm({...e.controller,explorationId:a.explorationId,runId:a.runId,liveToken:a.liveToken})}},async close(a){u||(u=!0,await o.close(),n.attach(null),r.end(a),await t.close())}}}import{readFileSync as vt}from"fs";import{basename as _t}from"path";import{randomUUID as Qr}from"crypto";function Be(e){let r=[];for(let[n,t]of Object.entries(e)){if(t.type==="parameter")continue;let o=n.replace(/^(secrets\.user\.|global\.|environment\.)/,"");r.push({name:o,secret:!!t.secret,value:String(t.value??"")})}return r}async function Wr(e,r){if(r.activeRun){let c=null;try{c=await r.activeRun()}catch{c=null}if(c)return{ok:!1,error:`RUN_ACTIVE: run ${c.runId} is ${c.state} on exploration ${c.explorationId}; stop it or wait for it to end`}}let n=e.variables.filter(c=>c.secret),t=e.variables.filter(c=>!c.secret),o=[["LT_USERNAME",e.login.username],["LT_ACCESS_KEY",e.login.accessKey],...n.map(c=>[c.name,c.value])];for(let[c,l]of o){if(e.dev?.skipPush===c){e.onNote?.(`dev: not pushing secret ${c} (KANE_EXPLORE_DEV_SKIP_SECRET_PUSH)`);continue}try{await r.pushSecret(c,l)}catch(f){return{ok:!1,error:`could not push secret ${c} to HyperExecute Secrets: ${Z(f)}`}}}for(let c of t)try{await r.upsertGlobal(c.name,c.value)}catch(l){return{ok:!1,error:`could not push variable ${c.name} to Test Manager: ${Z(l)}`}}let i=o.map(([c])=>c);if(e.dev?.skipCheck)return e.onNote?.("dev: not checking the HyperExecute secrets list (KANE_EXPLORE_DEV_SKIP_SECRET_CHECK); the VM's check must refuse a missing secret"),a();let u;try{u=await r.hxSecretNames(i)}catch(c){return{ok:!1,error:`could not read your HyperExecute secrets to check them: ${Z(c)}`}}let h=i.filter(c=>!u.includes(c));if(h.length)return{ok:!1,error:`HyperExecute Secrets does not list ${h.join(", ")} after the push; the VM would run without ${h.length===1?"it":"them"}`};return a();async function a(){let c=e.body;if(e.devBundle)try{let{kane_version:l,...f}=e.body;c={...f,dev:await e.devBundle()}}catch(l){return{ok:!1,error:`--dev-bundle: could not upload the bundle: ${Z(l)}`}}try{return{ok:!0,reply:await r.remoteRun({...c,variables:e.variables.map(f=>({name:f.name,secret:f.secret}))})}}catch(l){if(l instanceof de&&l.code==="SECRETS_MISSING"){let f=l.body??{};return{ok:!1,secretsMissing:!0,error:typeof f.error=="string"&&f.error?f.error:"HyperExecute refused the job: a secret it names is missing",explorationId:typeof f.exploration_id=="string"?f.exploration_id:null,runId:typeof f.run_id=="string"?f.run_id:null}}return{ok:!1,error:`could not launch the remote run: ${Z(l)}`}}}}async function qr(e,r,n){let t={Authorization:X(r.username,r.accessKey),Accept:"application/json"},o=new URLSearchParams({username:r.username});for(let a of n)o.append("secretKey",a);let i=await q(`${e}/logistics/v1.0/all-secrets/list?${o}`,{method:"GET",headers:t});if(i.status===404&&(i=await q(`${e}/logistics/v1.0/secrets/list/${encodeURIComponent(r.username)}`,{method:"GET",headers:t})),!i.ok)throw new Error(`HTTP ${i.status}`);let u=null;try{u=await i.json()}catch{u=null}let h=yt(u);return n.filter(a=>h.has(a))}function yt(e){let r=new Set,n=e&&typeof e=="object"?e:{},t=Array.isArray(n.Data)?n.Data:Array.isArray(n.data)?n.data:Array.isArray(e)?e:[];for(let o of t)if(typeof o=="string")r.add(o);else if(o&&typeof o=="object"){let i=o,u=i.key??i.secretKey??i.Key??i.name;typeof u=="string"&&r.add(u)}return r}var Xr=["allowDomain","deny","allowPost","depthCaps","slowBudget","recheck","focus","hpsRegion","tunnel","tunnelName"];function Me(e,r){let n={};r&&(n.deps=r);for(let t of Xr){let o=e[t];o===void 0||Array.isArray(o)&&!o.length||(n[t]=o)}return n}function Jr(e){let r=e.args&&typeof e.args=="object"?e.args:{},n={url:e.url,prompt:e.prompt,browser:"remote",headless:!0};typeof e.max_parallel=="number"&&e.max_parallel>0&&(n.maxParallel=e.max_parallel),typeof e.max_leases=="number"&&e.max_leases>0&&(n.maxLeases=e.max_leases),Array.isArray(e.allowed_domains)&&(n.allowDomain=e.allowed_domains),typeof e.policy=="string"&&e.policy&&(n.policy=e.policy);for(let t of Xr)r[t]!==void 0&&(n[t]=r[t]);return typeof r.deps=="string"&&r.deps&&(n.depsText=r.deps),n}function zr(e,r){let n={},t=[];for(let o of e){if(!o.secret){n[o.name]={value:"",secret:!1};continue}let i=r[o.name];if(!i||i.includes("${{.secrets.")){t.push(o.name);continue}n[o.name]={value:i,secret:!0}}return t.length?{ok:!1,missing:t}:{ok:!0,variables:n}}function Z(e){return e instanceof Error?e.message:String(e)}function Yr(e){let r=Be(e.variables).map(n=>({name:n.name,secret:n.secret}));return{url:e.url,prompt:e.prompt,policy:e.policy??pe,...r.length?{variables:r}:{},...e.maxParallel?{max_parallel:e.maxParallel}:{},...e.maxLeases?{max_leases:e.maxLeases}:{},args:Me({...e.opts,allowDomain:e.allowedDomains},e.depsText)}}function kt(e){let r={},n=(e.KANE_EXPLORE_DEV_SKIP_SECRET_PUSH??"").trim();return n&&(r.skipPush=n),(e.KANE_EXPLORE_DEV_SKIP_SECRET_CHECK??"").trim()==="1"&&(r.skipCheck=!0),r}async function Rt(e,r){let n=vt(r),t=new er(e.controllerBaseUrl,{username:e.basic.username,accessKey:e.basic.access_key}),o=`${Qr()}-${_t(r)}`,u=(await t.getPresignedUrls("explore-dev",Qr(),[{key:"bundle",content_type:"application/gzip",filename:o}])).urls.bundle;if(!u)throw new Error("the presign reply named no URL for the bundle");return await ur(u.upload_url,n,"application/gzip"),u.blob_url}function Et(e){return{project_id:e.projectId,url:e.url,prompt:e.prompt,policy:e.policy??pe,...e.allowedDomains.length?{allowed_domains:e.allowedDomains}:{},...e.contextEnabled===!1?{context_enabled:!1}:{},...e.maxParallel?{max_parallel:e.maxParallel}:{},...e.maxLeases?{max_leases:e.maxLeases}:{},args:Me(e.opts,e.depsText),kane_version:e.kaneVersion}}async function Zr(e,r){let n=new L({baseUrl:e.controllerBaseUrl,auth:e.basic}),t=new cr(e.secretsBaseUrl),o=new dr(e.tmsBaseUrl,e.basic.username,e.basic.access_key),i={username:e.basic.username,accessKey:e.basic.access_key},u=Et(r),h=r.dev,a=await Wr({variables:Be(r.variables),login:i,body:u,...h?{dev:kt(process.env),onNote:c=>e.emit({type:"warning",message:c}),devBundle:async()=>({bundle_url:await Rt(e,h.bundlePath),controller_url:h.controllerUrl})}:{}},{pushSecret:(c,l)=>t.pushSecret({secretKey:c,secretValue:l,username:i.username,accessKey:i.accessKey,orgId:e.orgId}),upsertGlobal:async(c,l)=>{await o.upsertVariable({name:c,value:l})},hxSecretNames:c=>qr(e.secretsBaseUrl,i,c),remoteRun:c=>n.remoteRun(c),activeRun:async()=>{if(!r.projectId)return null;let l=(await n.listExplorations({state:"running",project:r.projectId,limit:1})).explorations.find(f=>f.project_id===r.projectId&&f.current_session);return l&&l.current_session?{explorationId:l.exploration_id,runId:l.current_session.run_id,state:l.current_session.state}:null}});if(!a.ok&&a.secretsMissing)return{ok:!1,error:a.error,exitCode:2,stopped:{explorationId:a.explorationId,runId:a.runId}};if(!a.ok){if(r.contextEnabled===!1&&Sr(a.error))return{ok:!1,error:Er,exitCode:2};let c=/could not launch/.test(a.error)||a.error.startsWith("RUN_ACTIVE:");return{ok:!1,error:a.error,exitCode:c?1:2}}return e.emit({type:"explore_remote_started",exploration_id:a.reply.exploration_id,run_id:a.reply.run_id,state:a.reply.state,hx_job_id:a.reply.hx_job_id,job_link:a.reply.job_link,created:a.reply.created,policy:u.policy??pe}),r.contextEnabled===!1&&!a.reply.created&&e.emit({type:"warning",message:`exploration ${a.reply.exploration_id} already exists; its assurance context is unchanged \u2014 use \`kane-cli explore context off ${a.reply.exploration_id}\``}),e.terminal||(process.stderr.write(`exploration ${a.reply.exploration_id}, run ${a.reply.run_id}: queued on HyperExecute
4
+ `),a.reply.job_link&&process.stderr.write(`job: ${a.reply.job_link}
5
+ `),process.stderr.write(we(a.reply.exploration_id,e.env)+`
6
+ `)),{ok:!0,explorationId:a.reply.exploration_id,runId:a.reply.run_id}}async function et(e,r,n,t){let o=new L({baseUrl:e.controllerBaseUrl,auth:e.basic}),i;try{i=await o.runRequest(r,n)}catch(l){let f=l instanceof de?l.code:"";return{ok:!1,error:`could not read run ${n}'s request${f?` (${f})`:""}: ${l.message}`,exitCode:2,stopped:!1}}let u=i.requested&&typeof i.requested=="object"?i.requested:{},h=Array.isArray(u.variables)?u.variables:[],a=zr(h,t);if(!a.ok){let l=`secret${a.missing.length===1?"":"s"} ${a.missing.join(", ")} not set on this machine (HyperExecute Secrets has no value for ${a.missing.length===1?"it":"them"})`,f=J("secrets_missing",l);try{let y=await o.startRun(r,{run_id:n,sessions:1,client_release:V});await o.endRun(r,n,{remark:f,stop_reason:"secrets_missing",last_seq:y.next_seq-1,complete:!1,totals:{},unacked:0})}catch(y){return{ok:!1,error:`${l}; stopping the run also failed: ${y.message}`,exitCode:1,stopped:!1}}return{ok:!1,error:l,exitCode:1,stopped:!0}}return{ok:!0,opts:{...Jr({...u,url:u.url??i.target_url,prompt:u.prompt??i.prompt}),explorationId:r,claimRunId:n,variables:JSON.stringify(a.variables)}}}import{existsSync as Tt}from"fs";function be(e,r,n){let t=typeof e.explorationId=="string"?e.explorationId.trim():"";return t&&r?{explorationId:t}:n?{projectId:n}:null}function rt(e){let r=e.trim();try{let n=new URL(r);return`${n.protocol}//${n.host}${n.pathname.replace(/\/+$/,"")}${n.search}${n.hash}`}catch{return r.replace(/\/+$/,"").toLowerCase()}}function St(e,r){return rt(e)===rt(r)}var It=10;async function He(e,r){let n;for(let t=0;t<It;t++){let o=await e.listExplorations({state:"all",limit:100,...n?{cursor:n}:{},..."projectId"in r?{project:r.projectId}:{}}),i=o.explorations.find(u=>"projectId"in r?u.project_id===r.projectId:u.exploration_id===r.explorationId);if(i)return i;if(!o.next_cursor)return null;n=o.next_cursor}return null}function Lt(e){return`use a new --project for another site, or kane-cli explore delete ${e} first`}function Ve(e,r){let n=e.target_url??"";return!n||!r.trim()||St(n,r)?null:{error:`--url ${r.trim()} is not exploration ${e.exploration_id}'s URL (${n}): one exploration per project explores one URL`,next:Lt(e.exploration_id)}}var jt=e=>Ze.hex(ze.dim)(e),Ct=`error: --setup and --setup-check were replaced by --deps <plain language> (repeatable, or @file), which the recon runs once as its setup walk; see kane-cli explore run --help
7
+ `,Pt=`
8
+ One project has one exploration, of one URL: a re-run takes the exploration's
9
+ URL, and a different --url is refused (use a new --project for another site,
10
+ or kane-cli explore delete <id> first).
11
+
12
+ Examples:
13
+ # a project's first run, on HyperExecute (exits once the run is queued)
14
+ $ kane-cli explore run --project <id> --url https://example.com \\
15
+ --prompt "Explore checkout"
16
+ # run again: the URL is the project's exploration's
17
+ $ kane-cli explore run --project <id> --max-leases 40
18
+ # a read-only run on this machine
19
+ $ kane-cli explore run --project <id> --policy read_only --local-orchestration
20
+ # a local app, through your LT tunnel (start LT first)
21
+ $ kane-cli explore run --project <id> --url http://localhost:3000 \\
22
+ --tunnel-name dev
23
+ `;function tt(e){let r=Number(e);if(!Number.isInteger(r)||r<1)throw new Te("must be a positive integer");return r}function yo(e){let r=e.command("explore").description("Explore an app into a map of its screens and flows").enablePositionalOptions().option("--exploration-id <id>",Q({purpose:"On a terminal: open this exploration's card",values:"an id from kane-cli explore list --all",dflt:"pick a project first"})).option("--env <name>",Oe).option("--username <user>",Ue).option("--access-key <key>",Ne).option("--agent",Ae).configureHelp({sortSubcommands:!0,...fe([{title:"Target",flags:["--exploration-id"]},{title:"Output",flags:["--agent","--help"]},{title:"Account",flags:["--env","--username","--access-key"]}])}).addHelpText("after",`
24
+ On a terminal, plain \`kane-cli explore\` opens the project picker, then the
25
+ exploration's card (run again, watch, stop, map, sessions, context, delete);
26
+ with --agent or a pipe it prints this help. Each command's --help lists its
27
+ options, grouped, with their values, defaults and examples.
28
+ `).action(async(n,t)=>{if(t.args.length>0&&t.error(`error: unknown command '${t.args[0]}'`,{exitCode:2}),me(n,Mr()))return t.help();let{runExploreEntryAction:o}=await import("./explore-entry-ZOPO7DBZ.js");process.exitCode=await o(n)});r.command("run").description("Run one exploration of an app into its project's map: on HyperExecute by default (exits once the run is queued; stop it with explore stop), or on this machine with --local-orchestration. A terminal opens a setup form and a review first; --agent or a pipe gets NDJSON on stdout, done last").option("--url <url>",w("url")).option("--project <id>",w("project")).option("--exploration-id <id>",w("explorationId")).option("--prompt <text>",w("prompt"),"Explore the app").option("--max-leases <n>",w("maxLeases"),tt).option("--max-parallel <n>",w("maxParallel"),tt).option("--depth-caps <depth:cap,\u2026>",w("depthCaps")).option("--slow-budget <spec>",w("slowBudget")).option("--no-recheck",w("recheck")).option("--policy <policy>",w("policy")).option("--allow-domain <host>",w("allowDomain"),ye,[]).option("--deny <name>",w("deny"),ye,[]).option("--allow-post <host/path>",w("allowPost"),ye,[]).option("--focus <screen>",w("focus")).option("--local-orchestration",w("localOrchestration")).option("--browser <where>",w("browser"),"local").option("--headless",w("headless")).option("--tunnel",w("tunnel")).option("--tunnel-name <name>",w("tunnelName")).option("--deps <text>",w("deps"),ye,[]).option("--variables <json>",w("variables")).option("--variables-file <path>",w("variablesFile")).option("--no-context",w("context")).option("--agent",w("agent")).option("--env <name>",w("env")).option("--username <user>",w("username")).option("--access-key <key>",w("accessKey")).addOption(new le("--claim-run <run-id>","On a HyperExecute VM: take over this queued run (the job's own command; needs --exploration-id)").hideHelp()).addOption(new le("--dev-bundle <tgz>","Dev only: the VM installs this kane-cli bundle and talks to EXPLORE_DEV_CONTROLLER_URL").hideHelp()).addOption(new le("--hps-region <region>",`With remote browsers on prod: the regional host (${ce.join(", ")})`).hideHelp()).configureHelp(fe(Br())).addHelpText("after",Pt).configureOutput({outputError:(n,t)=>t(/\'--setup(?:-check)?(?:=|\')/.test(n)?Ct:n)}).action(async n=>{process.exitCode=await Vt(n)}),r.command("view").description("Serve a live graph of an exploration's map on 127.0.0.1 (polls the service; Ctrl-C to stop)").option("--exploration-id <id>",Q({purpose:"The exploration to view",values:"an id from kane-cli explore list --all"})).option("--project <id>",Q({purpose:"View this project's exploration instead (a project has one)",values:"a project id"})).option("--port <n>",Q({purpose:"The port on 127.0.0.1",values:"1-65535",dflt:"the first free of 7420-7429"}),$t).option("--agent",Ae).option("--env <name>",Oe).option("--username <user>",Ue).option("--access-key <key>",Ne).configureHelp(fe([{title:"Target",flags:["--exploration-id","--project"]},{title:"Server",flags:["--port"]},{title:"Output",flags:["--agent","--help"]},{title:"Account",flags:["--env","--username","--access-key"]}])).addHelpText("after",`
29
+ Name the exploration with --exploration-id or --project, not both.
30
+
31
+ Examples:
32
+ $ kane-cli explore view --project <id>
33
+ $ kane-cli explore view --exploration-id <id> --port 7430
34
+ `).action(async n=>{process.exitCode=await Ft(n)}),Hr(r),Vr(r),r.command("assurance-job",{hidden:!0}).description("One cut of an exploration into its project's assurance (the controller's job; input from the environment)").action(async()=>{let{runAssuranceJob:n}=await import("./assurance-job-QO4VJJCL.js");process.exitCode=await n()})}function $t(e){let r=Number(e);if(!Number.isInteger(r)||r<1||r>65535)throw new Te("must be an integer 1-65535");return r}function ye(e,r){return[...r,e]}function nt(e){let r=new Set;for(let n of e){let t=n.trim().toLowerCase();if(t){try{t.includes("://")&&(t=new URL(t).hostname)}catch{}t=t.replace(/\/.*$/,"").replace(/^www\./,"").replace(/\.$/,""),t&&r.add(t)}}return[...r]}function At(e,r){if(e.some(t=>t.trim()==="*"))return{posts:["*"]};let n=new Set;for(let t of e){let o=t.trim();if(!o)continue;let i=y=>({error:`--allow-post ${JSON.stringify(o)}: ${y}; write it as host/path, e.g. api.example.com/v1/flags`});if(o.includes("://"))return i("no scheme");if(/[?#]/.test(o))return i("no query or fragment (the match is on host and path only)");if(o.includes("*"))return i("no partial wildcards (name the endpoint exactly, or pass a bare * for every POST)");if(/\s/.test(o))return i("no whitespace");let u=o.indexOf("/");if(u<=0)return i("a host followed by a path starting with /");let h=o.slice(0,u).toLowerCase(),a=o.slice(u),c=/^([^:]+?)\.?(?::(\d+))?$/.exec(h);if(!c)return i("an invalid host");let l=c[1],f=c[2]&&c[2]!=="80"&&c[2]!=="443"?`:${c[2]}`:"";if(h=l+f,!r.some(y=>l===y||l.endsWith(`.${y}`)))return i(`host ${l} is outside the run's domains (${r.join(", ")||"none"}); add it with --allow-domain first`);n.add(h+a)}return{posts:[...n]}}function Ot(e){if(e===void 0)return{caps:{}};let r={};for(let n of e.split(",").map(t=>t.trim()).filter(Boolean)){let t=/^(\d+):(\d+)$/.exec(n);if(!t)return{error:`--depth-caps "${e}": each entry is depth:cap with whole numbers, e.g. 0:0,1:3,2:1`};r[String(Number(t[1]))]=Number(t[2])}return Object.keys(r).length?{caps:r}:{error:`--depth-caps "${e}": give at least one depth:cap pair`}}var Ut={response:"response_ms",page:"page_ready_ms",step:"step_ms"};function Nt(e){if(e===void 0)return{budgets:{}};let r={};for(let n of e.split(",").map(t=>t.trim()).filter(Boolean)){let t=/^(response|page|step)=(\d+(?:\.\d+)?)(s|ms)$/.exec(n);if(!t)return{error:`--slow-budget "${e}": each entry is response|page|step=<number>s or ms, e.g. response=3s,page=4s,step=2.5s`};let o=Math.round(Number(t[2])*(t[3]==="s"?1e3:1));if(o<1)return{error:`--slow-budget "${e}": a budget is more than 0`};r[Ut[t[1]]]=o}return Object.keys(r).length?{budgets:r}:{error:`--slow-budget "${e}": give at least one budget`}}function ot(e){return e.context===!1?{contextEnabled:!1}:{}}var Bt="--tunnel on a remote run: the remote browsers reach your apps through the LT tunnel on this machine; keep it (and this machine) up until the run ends, or its pages fail to load";function Fe(e){return async r=>{let n=await Y(e,"explore run");return n.ok?He(new L({baseUrl:n.controllerBaseUrl,auth:n.basic,timeoutMs:5e3}),r):null}}async function at(e){let r=typeof e.project=="string"?e.project:"";if(!r)return null;try{let n=await Y(e,"explore run");if(!n.ok)return null;let t=ae(e.env??new ie().getDefaultEnv()??"prod"),o=new nr(t.tmsBaseUrl,n.basic.username,n.basic.access_key);return await _r((async()=>{try{let u=await o.getProject(r);if(u?.name)return u.name}catch{}return(await o.listProjects()).find(u=>String(u.project_id)===r)?.name??null})(),4e3,()=>null)}catch{return null}}var Mt=async(e,r=Fe(e))=>{let n=null,t=typeof e.project=="string"?e.project:"",o=be(e,!!e.localOrchestration,t||null),i=null;if(o)try{i=await r(o)}catch{i=null}if(i){let h=Ve(i,typeof e.url=="string"?e.url:"");if(h){for(let a of Pe(h.error,h.next))process.stderr.write(a+`
35
+ `);return 2}n=i.target_url??null}let u=await(await import("./explore-run-tty-DYLMHI7F.js")).setupRunOpts(e,n,await at(e));return"opts"in u?u.opts:u.code};function Ht(e){if(e.startsWith("RUN_ACTIVE:"))return"watch it (kane-cli explore view) or stop it (kane-cli explore stop) first \u2014 one run per exploration";if(/HyperExecute Secrets does not list/.test(e))return"check the secret's name in HyperExecute Secrets and your variables files, then launch again; or run it here with --local-orchestration";if(/a secret it names is missing|SECRETS_MISSING/.test(e))return"add the missing secret to your variables files (secret: true) and launch again";if(/REMOTE_UNAVAILABLE|503|could not launch the remote run|could not read your HyperExecute secrets|could not push/.test(e))return"try again in a minute, or run it on this machine with --local-orchestration"}async function Vt(e,r,n={}){let t=me(e,r),o=t?je("explore"):null,i=s=>s,u=null,h=typeof e.claimRun=="string"&&e.claimRun?e.claimRun:null,a=Dr({remote:!e.localOrchestration&&!h,onVm:!!h,hxJobId:Se().jobId??null,policy:typeof e.policy=="string"?e.policy:null,maxParallel:typeof e.maxParallel=="number"?e.maxParallel:null,maxLeases:typeof e.maxLeases=="number"?e.maxLeases:null}),c=()=>{if(!a.started()){a.markStarted();try{Ie()?.event("EXPLORE_START",a.startFields())}catch{}}},l=s=>{try{a.observe(s),s.type==="explore_run_started"&&c()}catch{}},f=s=>{l(s),o?o.emit(i(s)):u?.(i(s))},y=s=>{o?D(i(s)):process.stderr.write(`${s.type}: ${i(s).message}
36
+ `)},_=s=>{try{let d=Ie(),m={...s,error:s.error?i({message:s.error}).message:void 0};a.started()&&d?.event("EXPLORE_END",a.endFields(m));let p=a.errorFields(m);p&&d?.event("EXPLORE_ERROR",p)}catch{}return f({...Rr({state:s.state??null,remark:s.remark??null,exitCode:s.exitCode,explorationId:s.explorationId??null,runId:s.runId??null,committed:s.committed??0,pending:s.pending??0,lastSeq:s.lastSeq??0,stopReason:s.stopReason??null,complete:s.complete??!1,runDir:s.runDir??null,error:s.error}),...s.teardown?{teardown:s.teardown}:{},...s.credits?{credits:s.credits}:{},...typeof s.creditsConsumed=="number"?{credits_consumed:s.creditsConsumed}:{},...s.focus?{focus:s.focus}:{},...s.refused?{refused:s.refused}:{},...s.parallelism?{parallelism:s.parallelism}:typeof s.peakParallel=="number"?{peak_parallel:s.peakParallel}:{}}),s.exitCode},g=(s,d)=>(y({type:"error",message:s}),d&&!o&&process.stderr.write(`next: ${d}
37
+ `),_({exitCode:2,error:s})),b=typeof e.claimRun=="string"&&e.claimRun?e.claimRun:null;if(b&&!t)return g("--claim-run is the HyperExecute VM's own mode; it never runs on a terminal");let G=$e(e);if("error"in G)return g(G.error,G.next);if(!t){let s=await(n.setup??(d=>Mt(d,n.lookupExploration??Fe(d))))(e);if(s===null)return 0;if(typeof s=="number")return s;e=s}if(!b&&!(typeof e.url=="string"&&e.url.trim())){let s=be(e,!!e.localOrchestration,typeof e.project=="string"&&e.project?e.project:null),d=null;if(s)try{d=await(n.lookupExploration??Fe(e))(s)}catch{d=null}d?.target_url&&(e={...e,url:d.target_url})}if(!b&&!(typeof e.url=="string"&&e.url.trim()))return g("required option '--url <url>' not specified");let E=!!e.localOrchestration||!!b;if(b&&e.localOrchestration)return g("--claim-run is the VM's own mode; it takes no --local-orchestration");if(e.devBundle&&E)return g("--dev-bundle is for a remote run (the default), not --local-orchestration or --claim-run");if(b){let s=String(e.explorationId??"").trim();if(!s)return g("--claim-run needs --exploration-id");let d=await Y(e,"explore run --claim-run");if(!d.ok)return g(d.error);let m=String(e.env??new ie().getDefaultEnv()??"prod"),p=await et(it(m,d.basic,"",A=>f(A)),s,b,process.env);if(!p.ok)return D(i({type:"error",message:p.error})),p.stopped?_({exitCode:p.exitCode,error:p.error,state:"stopped",remark:J("secrets_missing",p.error),explorationId:s,runId:b}):_({exitCode:p.exitCode,error:p.error,explorationId:s,runId:b});e={...e,...p.opts,env:e.env,username:e.username,accessKey:e.accessKey}}let O=$e(e);if("error"in O)return g(O.error,O.next);let x=O.policy,k={prompt:"",deps:""},R={},U="";try{let s=typeof e.depsText=="string"?e.depsText:mr(e.deps??[]);U=s;let d=fr({prompt:e.prompt??"Explore the app",deps:s},{globalDir:De(se,"variables"),localDir:De(process.cwd(),".testmuai","variables"),file:e.variablesFile,inline:e.variables,onLoadError:m=>y({type:"warning",message:m})});if("error"in d)return g(d.error);k={prompt:d.prompt,deps:d.deps},R=d.variables}catch(s){return g(`variables: ${s.message}`)}let C=nt(e.allowDomain??[]);if(k.deps&&C.length===0)return g("--deps needs --allow-domain for every host the app signs in or writes on (e.g. --allow-domain testmuai.com --allow-domain lambdatest.com)");let lt=[...new Set([...C,...nt([String(e.url??"")])])],P=E?String(e.browser??"local"):"remote";if(!E&&e.browser!==void 0&&e.browser!=="local")return g("--browser applies to --local-orchestration; a remote run always uses remote browsers");if(P!=="local"&&P!=="remote")return g(`--browser ${P}: local or remote`);let M=e.hpsRegion;if(M!==void 0&&P!=="remote")return g("--hps-region needs --browser remote");if(M!==void 0&&!ce.includes(M))return g(`--hps-region ${M}: one of ${ce.join(", ")}`);let N=rr(e);if("error"in N)return g(N.error);if(N.tunnel&&P!=="remote")return g("--tunnel needs remote browsers (a remote run, or --browser remote): a local Chrome already reaches this machine");let K=e.maxParallel??1;if(P==="local"&&K>Ce)return g(`--max-parallel ${K}: at most ${Ce} browsers run on this machine at once (--browser remote runs up to ${ue})`);if(P==="remote"&&K>ue)return g(`--max-parallel ${K}: at most ${ue} remote browsers at once`);let ve=Ot(e.depthCaps);if("error"in ve)return g(ve.error);let _e=Nt(e.slowBudget);if("error"in _e)return g(_e.error);let ee=At(e.allowPost??[],lt);if("error"in ee)return g(ee.error);x==="mutating"&&ee.posts.length&&y({type:"warning",code:"allow_post_ignored",message:Ar});let re=new ie,I=e.env??re.getDefaultEnv()??"prod",B=ae(I),W=new or().load(),ut=re.loadProfileConfig(re.getActiveProfile()??"default",I)?.project_id??null,j=e.project??W.project_id??ut??null;if(x==="mutating"){let s=Or(String(e.url??"")),d=Ur(String(e.url??""));o?D(i({type:"warning",code:"policy_mutating",policy:x,host:s,message:d})):process.stderr.write((process.stderr.columns?pr(d,process.stderr.columns):d)+`
38
+ `);let m=n.mutatingMemory??Nr();if(!t&&!(j&&m.confirmed(j))){let A=await(n.confirmMutating??(async H=>(await import("./explore-run-tty-DYLMHI7F.js")).confirmMutatingRun({...H,projectName:H.projectName??(H.projectId?await at({...e,project:H.projectId}):null)})))({host:s,projectId:j,projectName:j===W.project_id?W.project_name??null:null});if(A!==!0)return process.stderr.write(`setup discarded; nothing launched
39
+ `),A===null?130:0;j&&m.remember(j)}}if(!t&&n.afterChecks)return n.afterChecks();let Ge=new Set;t||(u=s=>{s.type==="explore_remote_started"?process.stderr.write(z("queued on HyperExecute",` \xB7 run ${String(s.run_id).slice(0,8)}${s.job_link?` \xB7 ${String(s.job_link)}`:""}`,"done")+`
40
+ `):(s.type==="warning"||s.type==="error")&&process.stderr.write(`${String(s.type)}: ${String(s.message)}
41
+ `);for(let d of Ge)d(s)});let Ke=(s,d)=>{if(o)D(i({type:"error",message:s}));else for(let m of Pe(i({message:s}).message,d??Ht(s)))process.stderr.write(m+`
42
+ `)},v,We="";try{let s=await lr({creds:re,env:I,usernameFlag:e.username,accessKeyFlag:e.accessKey,log:()=>{}});v=s.basicAuth,We=String(s.resolvedCreds?.org_id??"")}catch(s){return s instanceof ar&&s.code==="not_authenticated"?g("not authenticated: pass --username/--access-key or run 'kane-cli login'"):g(`auth resolution failed: ${s.message}`)}if(!v)return g("explore needs Basic credentials (username + access key); none resolved");if(!b){let s=be(e,E,j),d=null,m=v;if(s)try{d=await(n.lookupExploration??(A=>He(new L({baseUrl:B.controllerBaseUrl,auth:m,timeoutMs:5e3}),A)))(s)}catch{d=null}let p=d?Ve(d,String(e.url??"")):null;if(p)return Ke(p.error,p.next),_({exitCode:2,error:p.error})}if(n.afterUrlCheck)return n.afterUrlCheck();if(!E){N.tunnel&&f({type:"warning",message:Bt});let s={...it(I,v,We,oe=>f(oe)),terminal:!t},d;if(typeof e.devBundle=="string"&&e.devBundle){let oe=(process.env.EXPLORE_DEV_CONTROLLER_URL??"").trim();if(!oe)return g("--dev-bundle needs EXPLORE_DEV_CONTROLLER_URL (the controller the VM talks to: the tunnel URL)");if(!Tt(e.devBundle))return g(`--dev-bundle ${e.devBundle}: no such file`);d={bundlePath:e.devBundle,controllerUrl:oe}}let m=j;if(!m)return g("a remote run needs a project: pass --project <id> or set one (kane-cli config set-project); one project has one exploration");t||process.stderr.write(z("launching on HyperExecute")+`
43
+ `),c();let p=await Zr(s,{opts:e,variables:R,depsText:U,prompt:e.prompt??"Explore the app",url:String(e.url),projectId:m,allowedDomains:C,policy:x,...ot(e),maxParallel:e.maxParallel,maxLeases:e.maxLeases,kaneVersion:V,...d?{dev:d}:{}});if(!p.ok)return Ke(p.error,p.stopped?"add the missing secret to your variables files (secret: true) or HyperExecute Secrets, then launch again":void 0),p.stopped?_({exitCode:p.exitCode,error:p.error,state:"stopped",remark:J("secrets_missing",p.error),explorationId:p.stopped.explorationId,runId:p.stopped.runId}):_({exitCode:p.exitCode,error:p.error});let A=_({exitCode:0,state:"queued",explorationId:p.explorationId,runId:p.runId});if(t)return A;let{runLiveView:H}=await import("./explore-live-RUAAZGX4.js");return(await H({client:new L({baseUrl:B.controllerBaseUrl,auth:v}),explorationId:p.explorationId,runId:p.runId,mode:"remote",env:I,policy:x})).exitCode}let ke=sr();if(!ke)return g("v16-runner not found");let qe=W.window_size?.width??1280,Xe=W.window_size?.height??800,Je=j,$,te={explorationId:null,runId:null};if(P==="remote"){if(I!=="stage"&&I!=="prod")return g(`--browser remote: no remote browsers for env ${I}`);let s;try{s=wr(I,M??null)}catch(m){return g(m.message)}let d=v;i=xr([d.access_key]),$=vr({hpsBase:s,auth:d,forge:br(B.tmsBaseUrl,d,()=>({exploration_id:te.explorationId,run_id:te.runId,project_id:Je,hx_job_id:Se().jobId??null,kane_version:V,region:M??null,tunnel:!!N.tunnel,tunnel_name:N.tunnel?.name??null})),tunnel:N.tunnel,releaseSync:m=>yr(B.tmsBaseUrl,d,m),onEvent:m=>f({type:"remote_browser",...m})})}else $=gr({launch:tr,width:qe,height:Xe,headless:!!e.headless});Qe("explore-browsers",()=>$.releaseAllSync());let T=null,Re=null;try{T=await Kr({controller:{baseUrl:B.controllerBaseUrl,authHeader:X(v.username,v.access_key)},onWarn:s=>f({type:"warning",message:s}),onExploration:s=>{process.stderr.write(we(s,e.env)+`
44
+ `)},onStop:()=>{f({type:"warning",message:"explore stop: the run is stopping cleanly"}),Re?.()}})}catch(s){f({type:"warning",message:`live mode is off for this run: ${s.message}`})}let Ee=()=>{},ct=new Promise(s=>{Ee=s}),ne=null;t||Ge.add(s=>{s.type!=="explore_run_started"||ne||(ne=import("./explore-live-RUAAZGX4.js").then(({runLiveView:d})=>d({client:new L({baseUrl:B.controllerBaseUrl,auth:v}),explorationId:String(s.exploration_id),runId:String(s.run_id),mode:"local",env:I,policy:x,ended:ct})))});try{let s=await Ir({url:e.url,prompt:k.prompt,maxLeases:e.maxLeases,explorationId:e.explorationId,...typeof e.claimRunId=="string"?{claimRunId:e.claimRunId}:{requested:Yr({opts:e,url:String(e.url),prompt:e.prompt??"Explore the app",depsText:U,variables:R,allowedDomains:C,policy:x,maxParallel:e.maxParallel,maxLeases:e.maxLeases})},projectId:Je,policy:x,context:k,variables:R,allowedDomains:C,...ot(e),allowPosts:x==="read_only"?ee.posts:[],depthCaps:ve.caps,slowBudgets:_e.budgets,recheck:e.recheck!==!1,maxParallel:K,...typeof e.focus=="string"?{focus:e.focus}:{},denyNames:(e.deny??[]).map(m=>m.trim()).filter(Boolean),headless:!!e.headless,width:qe,height:Xe,auth:v,clientRelease:V},{client:new L({baseUrl:B.controllerBaseUrl,auth:v}),spawnRunner:m=>{let p=ir({environment:I,username:v.username,accessKey:v.access_key,sessionId:m});return $.kind==="local"?Le({env:p,runner:ke,sessionId:m}):Fr(Le({env:p,runner:ke}),De(se,"sessions",m,"runner-stderr.log"),hr([v.access_key]))},acquireBrowser:async m=>{let p=await $.acquire(m);return T?.onBrowser(m),{cdpEndpoint:p.cdpEndpoint,release:()=>{T?.offBrowser(m),p.release()}}},releaseBrowsersOnInterrupt:$.kind==="remote",frameLink:m=>T?.attachRunner(m),onFrame:(m,p)=>T?.runnerFrame(m,p),onLiveRun:m=>{te.explorationId=m.explorationId,te.runId=m.runId,T?.armRun(m)},emit:m=>{l(m);let p=i(m);o?o.emit(p):u?.(p),T?.onEvent(p)},baseDir:se,onInterrupt:m=>{Re=m;let p=Kt(m);return()=>{Re=null,p()}}});await $.releaseAll(),await T?.close(s.stopReason??s.remark?.code??"stopped");let d=_(b?{...s,exitCode:kr(s)}:s);return Ee(d),ne&&await ne,d}finally{Ee(1),await T?.close("stopped"),await $.releaseAll(),Ye("explore-browsers")}}var Dt=3e3;async function Ft(e,r={}){let n=r.tty??!me(e),t=r.out??(x=>{process.stdout.write(x+`
45
+ `)}),o=n?null:je("explore"),i=String(e.explorationId??"").trim(),u=String(e.project??"").trim(),h=(x,k,R)=>(o?.emit({type:"done",status:k,exit_code:x,exploration_id:i||null,...R?{error:R}:{}}),x),a=(x,k)=>{if(o)D({type:"error",message:x});else{let R=r.err??(U=>{process.stderr.write(U+`
46
+ `)});R(`error: ${x}`),k&&R(`next: ${k}`)}return h(2,"error",x)};if(i&&u)return a("--exploration-id or --project, not both","kane-cli explore view --exploration-id <id>");if(!i&&!u)return a("name the exploration: --exploration-id or --project","kane-cli explore list --all names them (or plain kane-cli explore to pick one)");let c=await Y(e,"explore view");if(!c.ok)return a(c.error,"kane-cli login");let l=c.basic,f={controllerBaseUrl:c.controllerBaseUrl};if(u){try{i=(await new L({baseUrl:f.controllerBaseUrl,auth:l}).listExplorations({state:"all",project:u})).explorations.find(k=>k.project_id===u)?.exploration_id??""}catch(x){return a(`could not find project ${u}'s exploration: ${x.message}`)}if(!i)return a(`project ${u} has no exploration`,`start one: kane-cli explore run --project ${u} --url <app>`)}let y=X(l.username,l.access_key),_={controllerBaseUrl:f.controllerBaseUrl,authHeader:y,explorationId:i,port:e.port,live:{controller:{baseUrl:f.controllerBaseUrl,authHeader:y}}},g=await Tr(_);if(g.kind==="not_found")return a(`exploration ${i} not found`,"kane-cli explore list --all");if(g.kind==="error")return a(`could not read the map: ${g.message}`);let b;try{b=await Cr(_)}catch(x){return a(`could not bind 127.0.0.1${_.port?`:${_.port}`:""}: ${x.message}`,"pass another --port, or leave it out for the first free one")}let G=r.hold?null:Wt(),E=null;try{E=await new L({baseUrl:f.controllerBaseUrl,auth:l,timeoutMs:Dt}).getContext(i)}catch{}o&&o.emit({type:"explore_view_started",url:b.url,exploration_id:i,context:E});let O=null;if(!o){let x=!r.out&&!!process.stdin.isTTY&&!!process.stdout.isTTY;x&&st(b.url),t(z("map viewer ready",` \xB7 ${b.url}`)),t(jt(` ${x?"opened in your browser \xB7 ":""}live when a run is going`)),t("");let k=g.kind==="ok"&&g.body.counts&&typeof g.body.counts=="object"?g.body.counts:null,R=E?`context ${E.enabled?"on":"off"}${E.last_job?` \xB7 ${E.last_job.status}`:""}`:"";for(let U of Pr({status:z("serving"),meta:["explore",i.slice(0,8),c.environment??""],tallies:[...$r(k).filter(C=>!C.endsWith("findings")&&!C.endsWith("finding")),...R?[R]:[]],keys:[...x?["o open again"]:[],"ctrl+c stop serving"]}))t(U);x&&!r.hold&&(O=Gt(()=>{st(b.url)}))}r.onStarted?.(b);try{await(G??r.hold())}finally{O?.()}return await b.close(),h(0,"stopped")}async function st(e){try{let{default:r}=await import("./open-MQLQKFAW.js");await r(e)}catch{process.stderr.write(`could not open a browser: open ${e}
47
+ `)}}function Gt(e){let r=process.stdin;if(!r.isTTY)return()=>{};let n=t=>{let o=t.toString("utf8");o===""?process.kill(process.pid,"SIGINT"):(o==="o"||o==="O")&&e()};return r.setRawMode(!0),r.resume(),r.on("data",n),()=>{r.off("data",n);try{r.setRawMode(!1)}catch{}r.pause()}}function Kt(e){let r=process.listeners("SIGINT");for(let n of r)process.removeListener("SIGINT",n);return process.on("SIGINT",e),()=>{process.removeListener("SIGINT",e);for(let n of r)process.on("SIGINT",n)}}function Wt(){return new Promise(e=>{let r=process.listeners("SIGINT"),n=process.listeners("SIGTERM");process.removeAllListeners("SIGINT"),process.removeAllListeners("SIGTERM");let t=()=>{process.removeListener("SIGINT",t),process.removeListener("SIGTERM",t);for(let o of r)process.on("SIGINT",o);for(let o of n)process.on("SIGTERM",o);e()};process.once("SIGINT",t),process.once("SIGTERM",t)})}function it(e,r,n,t){let o=ae(e);return{env:e,controllerBaseUrl:o.controllerBaseUrl,secretsBaseUrl:o.secretsBaseUrl,tmsBaseUrl:o.tmsBaseUrl,basic:r,orgId:n,emit:t}}export{Ct as a,Pt as b,yo as c,nt as d,At as e,Ot as f,Nt as g,ot as h,Bt as i,Vt as j,Dt as k,Ft as l,Kt as m};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as ne}from"./chunk-WMGKUERB.js";import{a as y,b as ie,c as oe,d as le,e as ae}from"./chunk-UWPG5MWM.js";import{a as F,b as x,c as D,d as ee,f as re,h as de,i as pe}from"./chunk-GJXO6FF7.js";import{a as se,d as te}from"./chunk-ZCIWQHCO.js";import{a as X,c as Y,d as Z}from"./chunk-CQDCNP7V.js";import{Ba as B,Ea as v,Ja as Q,Pa as w,Va as U,Xa as $,Ya as O,Za as b,_a as G,ab as J,fb as H,i as _,jb as z,kb as W,mb as R,nb as K,ob as T,t as I}from"./chunk-PI7OXS62.js";import{a as C}from"./chunk-YJAQZMJT.js";import{existsSync as Se,readFileSync as Ee}from"fs";import{join as Me}from"path";import{mkdirSync as be,readFileSync as Re,renameSync as Fe,writeFileSync as Ae}from"fs";import{dirname as A,join as M}from"path";function E(r,o){be(A(r),{recursive:!0});let s=M(A(r),`.${process.pid}.tmp`);Ae(s,o),Fe(s,r)}function ue(r){try{return JSON.parse(Re(r,"utf8"))}catch{return null}}function ce(r){let o=s=>M(A(y(r,s)),"verdicts.json");return{read:s=>ue(y(r,s)),write:(s,i)=>E(y(r,s),JSON.stringify(i,null,2)+`
2
+ import{b as ne}from"./chunk-WMGKUERB.js";import{a as y,b as ie,c as oe,d as le,e as ae}from"./chunk-2EKLTUY2.js";import{a as F,b as x,c as D,d as ee,f as re,h as de,i as pe}from"./chunk-JBUKEIYL.js";import{a as se,d as te}from"./chunk-ZCIWQHCO.js";import{a as X,c as Y,d as Z}from"./chunk-5ORBAYTU.js";import{Ba as B,Ea as v,Ja as Q,Pa as w,Va as U,Xa as $,Ya as O,Za as b,_a as G,ab as J,fb as H,i as _,jb as z,kb as W,mb as R,nb as K,ob as T,t as I}from"./chunk-5EAJO372.js";import{a as C}from"./chunk-YJAQZMJT.js";import{existsSync as Se,readFileSync as Ee}from"fs";import{join as Me}from"path";import{mkdirSync as be,readFileSync as Re,renameSync as Fe,writeFileSync as Ae}from"fs";import{dirname as A,join as M}from"path";function E(r,o){be(A(r),{recursive:!0});let s=M(A(r),`.${process.pid}.tmp`);Ae(s,o),Fe(s,r)}function ue(r){try{return JSON.parse(Re(r,"utf8"))}catch{return null}}function ce(r){let o=s=>M(A(y(r,s)),"verdicts.json");return{read:s=>ue(y(r,s)),write:(s,i)=>E(y(r,s),JSON.stringify(i,null,2)+`
3
3
  `),writeReview:(s,i)=>E(M(A(y(r,s)),"review.json"),JSON.stringify(i,null,2)+`
4
4
  `),verdicts:s=>ue(o(s))??{verdicts:{}},saveVerdicts:(s,i)=>E(o(s),JSON.stringify(i,null,2)+`
5
5
  `)}}import{appendFileSync as fe,closeSync as qe,existsSync as V,openSync as Pe,readdirSync as Oe,readFileSync as ge,renameSync as Te,writeFileSync as he}from"fs";import{join as q}from"path";var me=".pending-facts.bad";function ye(r){let o=q(r,ie);return{quarantinePath:q(r,me),park:(s,i)=>{let l=null;try{l=w(r,{deadlineMs:i.deadlineMs})}catch{l=null}try{if(l)return fe(o,s+`
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as s}from"./chunk-KM3YCIDV.js";import{f as c}from"./chunk-PRBWZXFA.js";import{d as g}from"./chunk-ZMWTRXFH.js";import{a as l}from"./chunk-YNDELIXL.js";import{f as a}from"./chunk-CB344EDO.js";import{c as m}from"./chunk-GBQ4K25P.js";import{b as n}from"./chunk-EBJW6POT.js";async function A(p,o,t,e){let i=async()=>{let r=e.auth??{...await a(n),...e.telemetry?.spawnEnv()??{}};return c(g(o.store,p),{store:o.store,projectDir:process.cwd(),...e.testFilesAt?{testFilesAt:e.testFilesAt}:{},agent:e.agent,tracePath:l,credentials:n,onIngestRefusal:s,preflightTurn:e.preflightTurn??(()=>m(r)),ask:async()=>[],out:t.out,emit:t.emit,progress:t.progress,isTTY:!1,auth:r,...e.telemetry?{telemetry:e.telemetry}:{}})};if(!t.channel)return i();let{runWithChannel:u}=await import("./run-channel-IIIYXOIW.js");return u({event:r=>t.emit(r)},i)}export{A as a};
2
+ import{a as s}from"./chunk-KM3YCIDV.js";import{f as c}from"./chunk-TOOJTCON.js";import{d as g}from"./chunk-4DRFMDAW.js";import{a as l}from"./chunk-FH4FWIET.js";import{f as a}from"./chunk-CB344EDO.js";import{c as m}from"./chunk-GBQ4K25P.js";import{b as n}from"./chunk-ATCJ7EHL.js";async function A(p,o,t,e){let i=async()=>{let r=e.auth??{...await a(n),...e.telemetry?.spawnEnv()??{}};return c(g(o.store,p),{store:o.store,projectDir:process.cwd(),...e.testFilesAt?{testFilesAt:e.testFilesAt}:{},agent:e.agent,tracePath:l,credentials:n,onIngestRefusal:s,preflightTurn:e.preflightTurn??(()=>m(r)),ask:async()=>[],out:t.out,emit:t.emit,progress:t.progress,isTTY:!1,auth:r,...e.telemetry?{telemetry:e.telemetry}:{}})};if(!t.channel)return i();let{runWithChannel:u}=await import("./run-channel-IIIYXOIW.js");return u({event:r=>t.emit(r)},i)}export{A as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{N as y}from"./chunk-PI7OXS62.js";import{f as d,g as m}from"./chunk-KU3YHPWZ.js";var b={high:3,med:2,low:1},R={create:0,evolve:1,"reuse-candidate":2},E=.75;function u(e,s){return!e.superseded.has(s)&&e.trust.get(s)!=="archived"}function S(e,s){return e.edgesInto(s).some(n=>n.type===m.VERIFIES&&u(e,n.src))}function p(e,s="med"){let n=e.risk;return n==="high"||n==="med"||n==="low"?n:s}function l(e,s){return e.displayNameOf(s)??s}function g(e,s){return`kane-cli design tests --use-case ${l(e,s)}`}function _(e,s){let n=(r,o)=>{for(let c of e.edgesFrom(o)){let f=c.type===r?y(e,c.dst):null;if(f!==null&&u(e,f))return f}return null},t=n(m.SCOPED_TO,s);if(!t)return null;let i=e.nodeLabel.get(t);return i===d.USECASE?t:i===d.SCENARIO?n(m.BELONGS_TO,t):null}function w(e,s){let n=_(e,s);return n?g(e,n):G(e,s)}function G(e,s){return`kane-cli design explain ${l(e,s)}`}function h(e,s){let n=e.edgesFrom(s).find(i=>i.type===m.AUTOMATES&&u(e,i.dst));if(!n)return null;let t=e.edgesFrom(n.dst).find(i=>i.type===m.BELONGS_TO&&u(e,i.dst));return t?t.dst:null}function x(e){let s=[];for(let{cid:n,content:t}of e.byLabel(d.AC))u(e,n)&&(S(e,n)||s.push({ref:l(e,n),kind:"no-verifies",why:"no live test verifies this acceptance criterion",risk:p(t),stage:"design",tag:"create",ready_command:w(e,n)}));return s}function L(e){let s=[],n=new Map;for(let{cid:t}of e.byLabel(d.SCENARIO))if(u(e,t))for(let i of e.edgesFrom(t)){if(i.type!==m.BELONGS_TO)continue;let r=e.tipOf(i.dst);(n.get(r)??n.set(r,new Set).get(r)).add(t)}for(let{cid:t,content:i}of e.byLabel(d.USECASE)){if(!u(e,t))continue;let r=[...n.get(t)??[]];if(r.length===0){s.push({ref:l(e,t),kind:"zero-scenario",why:"use-case has no scenarios",risk:p(i),stage:"design",tag:"create",ready_command:g(e,t)});continue}r.every(c=>e.getNode(c)?.content.case_type==="happy")&&s.push({ref:l(e,t),kind:"happy-only",why:"use-case is exercised by happy-path scenarios only",risk:p(i),stage:"design",tag:"create",ready_command:g(e,t)})}return s}function C(e){let s=[];for(let{cid:n,content:t}of e.byLabel(d.GAP)){if(!u(e,n))continue;let i=t.ref,r=typeof i=="string"?e.resolve(i):null,o=r&&u(e,r.tip)?r.tip:null,c=o?e.nodeLabel.get(o):null,f=t.kind==="reconcile_deferred"?"kane-cli maintain reconcile":c===d.USECASE?g(e,o):c===d.AC?w(e,o):G(e,n),a=t.question&&typeof t.question=="object"?t.question:void 0,v=typeof t.text=="string"&&t.text||(a&&typeof a.header=="string"?a.header:"")||"design gap";s.push({ref:l(e,n),kind:String(t.kind),why:v,risk:p(t),stage:"design",tag:"create",ready_command:f,...typeof t.risk_rationale=="string"?{risk_rationale:t.risk_rationale}:{},...a?{question:a}:{}})}return s}function O(e){let s=[];for(let{cid:n,content:t}of e.byLabel(d.AC)){if(!u(e,n))continue;let i=e.stale(n);i==="fresh"||i==="superseded"||s.push({ref:l(e,n),kind:"stale-ac",why:`acceptance criterion is ${i} \u2014 its source moved since this was authored \xB7 why: kane-cli design explain ${l(e,n)}`,risk:p(t),stage:"design",tag:"evolve",ready_command:"kane-cli maintain reconcile"})}for(let{cid:n,content:t}of e.byLabel(d.TEST)){if(!u(e,n))continue;let i=e.stale(n);if(i==="fresh"||i==="superseded")continue;let r=e.edgesFrom(n).filter(k=>k.type===m.VERIFIES&&u(e,k.dst)),o=r.map(k=>p(e.getNode(k.dst)?.content??{})),c=o.includes("high")?"high":o.includes("med")?"med":o.includes("low")?"low":"med",f=r[0]?.dst??null,a=f?null:h(e,n),v=f?w(e,f):a?g(e,a):G(e,n);s.push({ref:l(e,n),kind:"stale-test",why:`test is ${i} \u2014 its source moved since this was authored`,risk:c,stage:"design",tag:"evolve",ready_command:v})}return s}async function A(e,s,n){for(let t of e)if(t.tag==="create"){if(!n){t.meta={embed_arm:"skipped"};continue}try{let i=s.resolve(t.ref),r=i?s.getNode(i.tip):null,o=r&&(String(r.content.title??"")||String(r.content.text??""))||t.why,c=r?.label===d.USECASE?"scenario":"test",a=(await n.searchSimilar(o,{label:c,k:1}))[0];a&&a.score>=E?(t.tag="reuse-candidate",t.meta={embed_arm:"used",near_hit:{ref:l(s,a.cid),score:a.score}}):t.meta={embed_arm:"used",near_hit:null}}catch{t.meta={embed_arm:"skipped"}}}}function T(e,s){let n=b[s.risk]-b[e.risk];if(n!==0)return n;let t=R[e.tag]-R[s.tag];return t!==0?t:e.ref<s.ref?-1:e.ref>s.ref?1:0}function N(e,s){let n=[],t=r=>{let o=y(e,r);return o?p(e.getNode(o)?.content??{}):"med"},i=r=>{let o=y(e,r),c=o?_(e,o):null;return c?l(e,c):r};for(let r of s.usecases??[])for(let o of r.acceptance_criteria??[])(o.covered_by??[]).length>0&&(o.execution==="failed"?n.push({ref:o.id,kind:"execution-failed",stage:"cover",tag:"evolve",risk:t(o.id),why:`covering test failed against this AC (tests: ${(o.covered_by??[]).join(", ")})`,ready_command:`kane-cli maintain evolve ${i(o.id)}`}):o.execution==="blocked"?n.push({ref:o.id,kind:"execution-blocked",stage:"cover",tag:"reuse-candidate",risk:t(o.id),why:"the oracle could not run (infrastructure) \u2014 the covering test exists and is reusable",ready_command:"kane-cli testrun run"}):o.execution==="not-run"&&n.push({ref:o.id,kind:"covered-not-run",stage:"cover",tag:"reuse-candidate",risk:t(o.id),why:"a covering test exists but never joined this pack \u2014 run it",ready_command:"kane-cli testrun run"}));return n}async function U(e,s,n,t){if(s!=="design"&&!t)throw new Error(`gaps-engine: stage "${s}" requires a pack's usecases doc`);let i=[];return(s==="design"||s==="all")&&i.push(...x(e),...L(e),...C(e),...O(e)),(s==="cover"||s==="all")&&i.push(...N(e,t)),await A(i,e,n),i.sort(T),i}export{u as a,S as b,_ as c,U as d};
2
+ import{N as y}from"./chunk-5EAJO372.js";import{f as d,g as m}from"./chunk-KU3YHPWZ.js";var b={high:3,med:2,low:1},R={create:0,evolve:1,"reuse-candidate":2},E=.75;function u(e,s){return!e.superseded.has(s)&&e.trust.get(s)!=="archived"}function S(e,s){return e.edgesInto(s).some(n=>n.type===m.VERIFIES&&u(e,n.src))}function p(e,s="med"){let n=e.risk;return n==="high"||n==="med"||n==="low"?n:s}function l(e,s){return e.displayNameOf(s)??s}function g(e,s){return`kane-cli design tests --use-case ${l(e,s)}`}function _(e,s){let n=(r,o)=>{for(let c of e.edgesFrom(o)){let f=c.type===r?y(e,c.dst):null;if(f!==null&&u(e,f))return f}return null},t=n(m.SCOPED_TO,s);if(!t)return null;let i=e.nodeLabel.get(t);return i===d.USECASE?t:i===d.SCENARIO?n(m.BELONGS_TO,t):null}function w(e,s){let n=_(e,s);return n?g(e,n):G(e,s)}function G(e,s){return`kane-cli design explain ${l(e,s)}`}function h(e,s){let n=e.edgesFrom(s).find(i=>i.type===m.AUTOMATES&&u(e,i.dst));if(!n)return null;let t=e.edgesFrom(n.dst).find(i=>i.type===m.BELONGS_TO&&u(e,i.dst));return t?t.dst:null}function x(e){let s=[];for(let{cid:n,content:t}of e.byLabel(d.AC))u(e,n)&&(S(e,n)||s.push({ref:l(e,n),kind:"no-verifies",why:"no live test verifies this acceptance criterion",risk:p(t),stage:"design",tag:"create",ready_command:w(e,n)}));return s}function L(e){let s=[],n=new Map;for(let{cid:t}of e.byLabel(d.SCENARIO))if(u(e,t))for(let i of e.edgesFrom(t)){if(i.type!==m.BELONGS_TO)continue;let r=e.tipOf(i.dst);(n.get(r)??n.set(r,new Set).get(r)).add(t)}for(let{cid:t,content:i}of e.byLabel(d.USECASE)){if(!u(e,t))continue;let r=[...n.get(t)??[]];if(r.length===0){s.push({ref:l(e,t),kind:"zero-scenario",why:"use-case has no scenarios",risk:p(i),stage:"design",tag:"create",ready_command:g(e,t)});continue}r.every(c=>e.getNode(c)?.content.case_type==="happy")&&s.push({ref:l(e,t),kind:"happy-only",why:"use-case is exercised by happy-path scenarios only",risk:p(i),stage:"design",tag:"create",ready_command:g(e,t)})}return s}function C(e){let s=[];for(let{cid:n,content:t}of e.byLabel(d.GAP)){if(!u(e,n))continue;let i=t.ref,r=typeof i=="string"?e.resolve(i):null,o=r&&u(e,r.tip)?r.tip:null,c=o?e.nodeLabel.get(o):null,f=t.kind==="reconcile_deferred"?"kane-cli maintain reconcile":c===d.USECASE?g(e,o):c===d.AC?w(e,o):G(e,n),a=t.question&&typeof t.question=="object"?t.question:void 0,v=typeof t.text=="string"&&t.text||(a&&typeof a.header=="string"?a.header:"")||"design gap";s.push({ref:l(e,n),kind:String(t.kind),why:v,risk:p(t),stage:"design",tag:"create",ready_command:f,...typeof t.risk_rationale=="string"?{risk_rationale:t.risk_rationale}:{},...a?{question:a}:{}})}return s}function O(e){let s=[];for(let{cid:n,content:t}of e.byLabel(d.AC)){if(!u(e,n))continue;let i=e.stale(n);i==="fresh"||i==="superseded"||s.push({ref:l(e,n),kind:"stale-ac",why:`acceptance criterion is ${i} \u2014 its source moved since this was authored \xB7 why: kane-cli design explain ${l(e,n)}`,risk:p(t),stage:"design",tag:"evolve",ready_command:"kane-cli maintain reconcile"})}for(let{cid:n,content:t}of e.byLabel(d.TEST)){if(!u(e,n))continue;let i=e.stale(n);if(i==="fresh"||i==="superseded")continue;let r=e.edgesFrom(n).filter(k=>k.type===m.VERIFIES&&u(e,k.dst)),o=r.map(k=>p(e.getNode(k.dst)?.content??{})),c=o.includes("high")?"high":o.includes("med")?"med":o.includes("low")?"low":"med",f=r[0]?.dst??null,a=f?null:h(e,n),v=f?w(e,f):a?g(e,a):G(e,n);s.push({ref:l(e,n),kind:"stale-test",why:`test is ${i} \u2014 its source moved since this was authored`,risk:c,stage:"design",tag:"evolve",ready_command:v})}return s}async function A(e,s,n){for(let t of e)if(t.tag==="create"){if(!n){t.meta={embed_arm:"skipped"};continue}try{let i=s.resolve(t.ref),r=i?s.getNode(i.tip):null,o=r&&(String(r.content.title??"")||String(r.content.text??""))||t.why,c=r?.label===d.USECASE?"scenario":"test",a=(await n.searchSimilar(o,{label:c,k:1}))[0];a&&a.score>=E?(t.tag="reuse-candidate",t.meta={embed_arm:"used",near_hit:{ref:l(s,a.cid),score:a.score}}):t.meta={embed_arm:"used",near_hit:null}}catch{t.meta={embed_arm:"skipped"}}}}function T(e,s){let n=b[s.risk]-b[e.risk];if(n!==0)return n;let t=R[e.tag]-R[s.tag];return t!==0?t:e.ref<s.ref?-1:e.ref>s.ref?1:0}function N(e,s){let n=[],t=r=>{let o=y(e,r);return o?p(e.getNode(o)?.content??{}):"med"},i=r=>{let o=y(e,r),c=o?_(e,o):null;return c?l(e,c):r};for(let r of s.usecases??[])for(let o of r.acceptance_criteria??[])(o.covered_by??[]).length>0&&(o.execution==="failed"?n.push({ref:o.id,kind:"execution-failed",stage:"cover",tag:"evolve",risk:t(o.id),why:`covering test failed against this AC (tests: ${(o.covered_by??[]).join(", ")})`,ready_command:`kane-cli maintain evolve ${i(o.id)}`}):o.execution==="blocked"?n.push({ref:o.id,kind:"execution-blocked",stage:"cover",tag:"reuse-candidate",risk:t(o.id),why:"the oracle could not run (infrastructure) \u2014 the covering test exists and is reusable",ready_command:"kane-cli testrun run"}):o.execution==="not-run"&&n.push({ref:o.id,kind:"covered-not-run",stage:"cover",tag:"reuse-candidate",risk:t(o.id),why:"a covering test exists but never joined this pack \u2014 run it",ready_command:"kane-cli testrun run"}));return n}async function U(e,s,n,t){if(s!=="design"&&!t)throw new Error(`gaps-engine: stage "${s}" requires a pack's usecases doc`);let i=[];return(s==="design"||s==="all")&&i.push(...x(e),...L(e),...C(e),...O(e)),(s==="cover"||s==="all")&&i.push(...N(e,t)),await A(i,e,n),i.sort(T),i}export{u as a,S as b,_ as c,U as d};
@@ -1,7 +1,7 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{e as C,f as y}from"./chunk-Z36KVIRR.js";import{a as $,g as x,h as g,k as E}from"./chunk-Q4JV4U65.js";import{d as k}from"./chunk-NHGPMYM3.js";import{e as w}from"./chunk-SB26HQO7.js";import{b as h}from"./chunk-VZ7KXRXB.js";import{a as P}from"./chunk-ZCBOHWN3.js";import{a as v}from"./chunk-TM45NPWL.js";import{promises as j}from"fs";import{basename as H,resolve as Z}from"path";import{createHash as J}from"crypto";import{promises as R}from"fs";import{basename as N,extname as O,resolve as B}from"path";var M=64*1024,A=100,Y=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;function K(t){try{let i=h(t);return!i||typeof i!="object"?{gateCount:0}:{id:i.policy,gateCount:Array.isArray(i.gates)?i.gates.length:0}}catch{return{gateCount:0}}}function _(t,i,r){if(t.length>M)return{ok:!1,kind:"invalid",message:`policy ${i} is ${t.length} bytes, over the 64 KB limit`};let o=t.toString("utf8"),e=K(o);if(e.gateCount>A)return{ok:!1,kind:"invalid",message:`policy ${i} has ${e.gateCount} gates, over the ${A} limit`};let n=r;if(typeof e.id=="string"&&e.id.length>0){if(!Y.test(e.id))return{ok:!1,kind:"invalid",message:`policy id "${e.id}" in ${i} must start with a letter or digit and use only letters, digits, '.', '_' and '-' (at most 128)`};n=e.id}return{ok:!0,policy:{source:i,name:n,content:o,sha256:J("sha256").update(t).digest("hex"),gateCount:e.gateCount}}}function U(t){let i=new Set;for(let r of t){if(i.has(r.name))return{ok:!1,kind:"invalid",message:`two policies are named "${r.name}" \u2014 each --policy and --policy-id needs its own policy id`};i.add(r.name)}return null}async function b(t,i){return m({files:t,ids:[]},{cwd:i})}async function m(t,i){let r=[];for(let o of t.files){let e=B(i.cwd,o),n;try{n=await R.readFile(e)}catch(u){return{ok:!1,kind:"io",message:`cannot read policy ${o}: ${u.message}`}}let s=_(n,o,N(e,O(e)));if(!s.ok)return s;r.push({path:e,...s.policy})}for(let o of t.ids){let e=`policy-id ${o}`;if(!i.fetchPolicy)return{ok:!1,kind:"io",message:`cannot fetch ${e}: not signed in to Test Manager`};let n;try{n=await i.fetchPolicy(o)}catch(u){return{ok:!1,kind:"io",message:`cannot fetch ${e}: ${u.message}`}}let s=_(Buffer.from(n.content,"utf8"),e,o);if(!s.ok)return s;if(s.policy.sha256!==n.sha256.toLowerCase())return{ok:!1,kind:"invalid",message:`${e}: Test Manager's content does not match its sha256`};r.push({...s.policy,uid:n.uid,version:n.version})}return U(r)??{ok:!0,policies:r}}var p=(t,i)=>`${i.location||t}: ${i.message} (${i.code})${i.hint?` \u2014 ${i.hint}`:""}`;async function re(t,i){let r=await m(t,{cwd:i.cwd,fetchPolicy:i.fetchPolicy});if(!r.ok)return{ok:!1,message:r.message};let o=i.lint??g,e=[],n=[];for(let s of r.policies){let u;try{u=await o(s.content,{source:s.source,catalogYaml:i.catalogYaml})}catch(c){return{ok:!1,message:`cannot lint policy ${s.source}: ${c.message}`}}for(let c of u)(c.severity==="error"?e:n).push(p(s.source,c))}return e.length?{ok:!1,message:`invalid policy:
2
+ import{e as C,f as y}from"./chunk-Z36KVIRR.js";import{a as $,g as x,h as g,k as E}from"./chunk-Q4JV4U65.js";import{d as k}from"./chunk-GMSWZIAS.js";import{e as w}from"./chunk-SB26HQO7.js";import{b as h}from"./chunk-VZ7KXRXB.js";import{a as P}from"./chunk-73EHVDL5.js";import{a as v}from"./chunk-YWQNZRJG.js";import{promises as j}from"fs";import{basename as H,resolve as Z}from"path";import{createHash as J}from"crypto";import{promises as R}from"fs";import{basename as N,extname as O,resolve as B}from"path";var M=64*1024,A=100,Y=/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;function K(t){try{let i=h(t);return!i||typeof i!="object"?{gateCount:0}:{id:i.policy,gateCount:Array.isArray(i.gates)?i.gates.length:0}}catch{return{gateCount:0}}}function _(t,i,r){if(t.length>M)return{ok:!1,kind:"invalid",message:`policy ${i} is ${t.length} bytes, over the 64 KB limit`};let o=t.toString("utf8"),e=K(o);if(e.gateCount>A)return{ok:!1,kind:"invalid",message:`policy ${i} has ${e.gateCount} gates, over the ${A} limit`};let n=r;if(typeof e.id=="string"&&e.id.length>0){if(!Y.test(e.id))return{ok:!1,kind:"invalid",message:`policy id "${e.id}" in ${i} must start with a letter or digit and use only letters, digits, '.', '_' and '-' (at most 128)`};n=e.id}return{ok:!0,policy:{source:i,name:n,content:o,sha256:J("sha256").update(t).digest("hex"),gateCount:e.gateCount}}}function U(t){let i=new Set;for(let r of t){if(i.has(r.name))return{ok:!1,kind:"invalid",message:`two policies are named "${r.name}" \u2014 each --policy and --policy-id needs its own policy id`};i.add(r.name)}return null}async function b(t,i){return m({files:t,ids:[]},{cwd:i})}async function m(t,i){let r=[];for(let o of t.files){let e=B(i.cwd,o),n;try{n=await R.readFile(e)}catch(u){return{ok:!1,kind:"io",message:`cannot read policy ${o}: ${u.message}`}}let s=_(n,o,N(e,O(e)));if(!s.ok)return s;r.push({path:e,...s.policy})}for(let o of t.ids){let e=`policy-id ${o}`;if(!i.fetchPolicy)return{ok:!1,kind:"io",message:`cannot fetch ${e}: not signed in to Test Manager`};let n;try{n=await i.fetchPolicy(o)}catch(u){return{ok:!1,kind:"io",message:`cannot fetch ${e}: ${u.message}`}}let s=_(Buffer.from(n.content,"utf8"),e,o);if(!s.ok)return s;if(s.policy.sha256!==n.sha256.toLowerCase())return{ok:!1,kind:"invalid",message:`${e}: Test Manager's content does not match its sha256`};r.push({...s.policy,uid:n.uid,version:n.version})}return U(r)??{ok:!0,policies:r}}var p=(t,i)=>`${i.location||t}: ${i.message} (${i.code})${i.hint?` \u2014 ${i.hint}`:""}`;async function re(t,i){let r=await m(t,{cwd:i.cwd,fetchPolicy:i.fetchPolicy});if(!r.ok)return{ok:!1,message:r.message};let o=i.lint??g,e=[],n=[];for(let s of r.policies){let u;try{u=await o(s.content,{source:s.source,catalogYaml:i.catalogYaml})}catch(c){return{ok:!1,message:`cannot lint policy ${s.source}: ${c.message}`}}for(let c of u)(c.severity==="error"?e:n).push(p(s.source,c))}return e.length?{ok:!1,message:`invalid policy:
3
3
  ${e.join(`
4
- `)}`}:{ok:!0,policies:r.policies,warnings:n}}function L(t,i={}){let r=null;return async o=>{r??=X(t,i);let e=await(await r).getPolicy(o);return{uid:e.uid,version:e.version,content:e.content,sha256:e.sha256}}}async function X(t,i){let{resolveTmsBasicAuth:r,formatAuthResolutionError:o}=await import("./list-commands-OFRRBU3D.js"),e=t.profile??new v().getActiveProfile()??"default",n=await(i.resolveAuth??r)(e,t.env,{username:t.username,accessKey:t.accessKey});if(!n.ok)throw new Error(o(e,t.env,n).message.replace(/^error: /,"").trim());let s=P(t.env).tmsBaseUrl;return(i.makeClient??((u,c,a)=>new w(u,c,a)))(s,n.creds.username,n.creds.access_key)}var D={pass:0,fail:1,errored:3};function F(t){let i=t.some(r=>r.result==="errored")?"errored":t.some(r=>r.result==="fail")?"fail":"pass";return{result:i,exit_code:D[i]}}function z(t){return{result:"errored",exit_code:D.errored,verdicts:[],files:[],error:t}}function G(t){return`${t}.verdicts`}function de(t,i){return t!==0||!i?t:i.exit_code}async function T(t,i,r={}){let o;try{o=await(r.judge??x)(t,i.map(e=>({content:e.content,path:e.path})))}catch(e){let n=e,s=(n.problems??[]).flatMap(c=>c.diagnostics.map(a=>`${c.source} ${a.location}: ${a.message} (${a.code})`)),u=s.length?`${n.message}: ${s.join("; ")}`:n.message;return{...z(u),...n.code==="USAGE"?{usage:!0}:{}}}try{let e=await(r.write??E)(o,G(t));return{...F(o),verdicts:o,files:e}}catch(e){return{...F(o),verdicts:o,files:[],filesError:e.message}}}function I(t,i){return{type:"verdict",evidence_id:i,result:t.result,exit_code:t.exit_code,policies:t.verdicts.map((r,o)=>({id:r.policy.id,sha256:r.policy.sha256,result:r.result,exit_code:r.exit_code,counts:{total:r.gates.length,failed:r.gates.filter(e=>e.status==="fail").length,warned:r.gates.filter(e=>e.status==="warn").length,errored:r.gates.filter(e=>e.status==="errored").length},failed_gate_ids:r.gates.filter(e=>e.status==="fail").map(e=>e.id),errored_gate_ids:r.gates.filter(e=>e.status==="errored").map(e=>e.id),...r.error?{error:r.error}:{},...t.files[o]!==void 0?{file:t.files[o]}:{}})),...t.error!==void 0?{error:t.error}:{},...t.filesError!==void 0?{files_error:t.filesError}:{}}}function S(t){if(t.error!==void 0)return`verdict: errored \u2014 ${t.error}`;let i=t.verdicts.map(o=>{let e=o.gates.filter(s=>s.status==="fail"||s.status==="errored").map(s=>s.id),n=o.error?o.error.message:e.join(", ");return`${o.policy.id} ${o.result}${n?` (${n})`:""}`}),r=`verdict: ${t.result} \u2014 ${i.join(", ")}`;return t.filesError===void 0?r:`${r}
4
+ `)}`}:{ok:!0,policies:r.policies,warnings:n}}function L(t,i={}){let r=null;return async o=>{r??=X(t,i);let e=await(await r).getPolicy(o);return{uid:e.uid,version:e.version,content:e.content,sha256:e.sha256}}}async function X(t,i){let{resolveTmsBasicAuth:r,formatAuthResolutionError:o}=await import("./list-commands-FZPVH76I.js"),e=t.profile??new v().getActiveProfile()??"default",n=await(i.resolveAuth??r)(e,t.env,{username:t.username,accessKey:t.accessKey});if(!n.ok)throw new Error(o(e,t.env,n).message.replace(/^error: /,"").trim());let s=P(t.env).tmsBaseUrl;return(i.makeClient??((u,c,a)=>new w(u,c,a)))(s,n.creds.username,n.creds.access_key)}var D={pass:0,fail:1,errored:3};function F(t){let i=t.some(r=>r.result==="errored")?"errored":t.some(r=>r.result==="fail")?"fail":"pass";return{result:i,exit_code:D[i]}}function z(t){return{result:"errored",exit_code:D.errored,verdicts:[],files:[],error:t}}function G(t){return`${t}.verdicts`}function de(t,i){return t!==0||!i?t:i.exit_code}async function T(t,i,r={}){let o;try{o=await(r.judge??x)(t,i.map(e=>({content:e.content,path:e.path})))}catch(e){let n=e,s=(n.problems??[]).flatMap(c=>c.diagnostics.map(a=>`${c.source} ${a.location}: ${a.message} (${a.code})`)),u=s.length?`${n.message}: ${s.join("; ")}`:n.message;return{...z(u),...n.code==="USAGE"?{usage:!0}:{}}}try{let e=await(r.write??E)(o,G(t));return{...F(o),verdicts:o,files:e}}catch(e){return{...F(o),verdicts:o,files:[],filesError:e.message}}}function I(t,i){return{type:"verdict",evidence_id:i,result:t.result,exit_code:t.exit_code,policies:t.verdicts.map((r,o)=>({id:r.policy.id,sha256:r.policy.sha256,result:r.result,exit_code:r.exit_code,counts:{total:r.gates.length,failed:r.gates.filter(e=>e.status==="fail").length,warned:r.gates.filter(e=>e.status==="warn").length,errored:r.gates.filter(e=>e.status==="errored").length},failed_gate_ids:r.gates.filter(e=>e.status==="fail").map(e=>e.id),errored_gate_ids:r.gates.filter(e=>e.status==="errored").map(e=>e.id),...r.error?{error:r.error}:{},...t.files[o]!==void 0?{file:t.files[o]}:{}})),...t.error!==void 0?{error:t.error}:{},...t.filesError!==void 0?{files_error:t.filesError}:{}}}function S(t){if(t.error!==void 0)return`verdict: errored \u2014 ${t.error}`;let i=t.verdicts.map(o=>{let e=o.gates.filter(s=>s.status==="fail"||s.status==="errored").map(s=>s.id),n=o.error?o.error.message:e.join(", ");return`${o.policy.id} ${o.result}${n?` (${n})`:""}`}),r=`verdict: ${t.result} \u2014 ${i.join(", ")}`;return t.filesError===void 0?r:`${r}
5
5
  \u26A0 verdict files not written: ${t.filesError}`}function ue(t,i){return i.verdicts.length===0?{}:{policies:t.map(r=>({name:r.name,content:r.content,sha256:r.sha256})),verdicts:i.verdicts}}async function $e(t,i,r=process.cwd()){let o=await y(t,r);if(!o){let n=`evidence: no pack found for "${t}"`;return i.json?console.log(JSON.stringify({valid:!1,error:"not_found",target:t})):console.error(n),2}let e=await $(o,i.profile??"L1");return i.json?console.log(JSON.stringify({valid:e.valid,status:e.status,diagnostics:e.diagnostics})):console.log(`evidence: ${e.valid?"valid":"INVALID"} (${i.profile??"L1"}, status ${e.status})`),e.valid?0:1}async function xe(t,i,r=process.cwd(),o={}){let e=o.out??(d=>process.stdout.write(d+`
6
6
  `)),n=o.err??(d=>process.stderr.write(d+`
7
7
  `)),s=await(o.catalog??k(i.env??"prod")),u=o.lint??g,c=[];for(let d of t){let l=await b([d],r);if(!l.ok&&l.kind==="io")return n(`evidence lint-policy: ${l.message}`),2;let f;if(l.ok)try{f=await u(l.policies[0].content,{source:d,catalogYaml:s.yaml})}catch(V){return n(`evidence lint-policy: cannot lint ${d}: ${V.message}`),2}else f=[{code:"policy.limits",severity:"error",location:"",message:l.message}];c.push({path:d,diagnostics:f})}let a=c.every(d=>d.diagnostics.every(l=>l.severity!=="error"));if(i.json)e(JSON.stringify({valid:a,files:c}));else for(let d of c){d.diagnostics.length===0&&e(`${d.path}: ok`);for(let l of d.diagnostics)e(`${l.severity}: ${p(d.path,l)}`)}return a?0:1}async function q(t,i=process.cwd()){if(t!=="latest"){let o=Z(i,t);return await j.stat(o).then(()=>!0,()=>!1)?o:y(t,i)}let r=null;for(let o of await C(i)){let e=await j.stat(o).catch(()=>null);e?.isFile()&&(!r||e.mtimeMs>r.mtime)&&(r={path:o,mtime:e.mtimeMs})}return r?.path??null}async function Ee(t,i,r=process.cwd(),o={}){let e=o.out??(l=>process.stdout.write(l+`