@testmuai/kane-cli 0.10.0-rc.3 → 0.10.2

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 (421) hide show
  1. package/dist/ChatSurface-FIYDTZSI.js +2 -0
  2. package/dist/{ChromeProfilePicker-M4WXOB5O.js → ChromeProfilePicker-Q6FIGVYU.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-6MJA7DF6.js → CliFeedbackPrompt-2NV2G65E.js} +1 -1
  4. package/dist/{CliUploadProgress-6NLS7XHH.js → CliUploadProgress-JZ5FXODE.js} +1 -1
  5. package/dist/{ConfigView-O4WKZ5PU.js → ConfigView-TZ4YINOE.js} +1 -1
  6. package/dist/EvidenceViewOffer-LKPN5BHX.js +2 -0
  7. package/dist/FolderPicker-H5K74PCH.js +2 -0
  8. package/dist/InfoBox-DNSOAK5L.js +2 -0
  9. package/dist/{LinksBox-DXP66H3H.js → LinksBox-32TZOANP.js} +1 -1
  10. package/dist/{ProfilesView-TWOY5PVC.js → ProfilesView-UC4MPM54.js} +1 -1
  11. package/dist/ProjectPicker-ZJ5RW6XL.js +2 -0
  12. package/dist/SaveSessionPrompt-F327WC7A.js +2 -0
  13. package/dist/SingleShotApp-OMLRYOSI.js +2 -0
  14. package/dist/{SummaryBox-IA2KS6GT.js → SummaryBox-XGFO5X76.js} +1 -1
  15. package/dist/TestMdRunView-ZZ77QTAQ.js +2 -0
  16. package/dist/TestrunEvidenceTable-G7MPF55X.js +2 -0
  17. package/dist/{WhoamiView-SNL75TEF.js → WhoamiView-4XIJXMTU.js} +1 -1
  18. package/dist/{app-download-UI4ABEIX.js → app-download-XEDO3EMV.js} +1 -1
  19. package/dist/{assurance-job-FFSSS4XV.js → assurance-job-MD65GQLC.js} +1 -1
  20. package/dist/{auth-7Z54TMQQ.js → auth-WBIEHHDS.js} +1 -1
  21. package/dist/{binary-THPLXCOD.js → binary-NVYLR36K.js} +1 -1
  22. package/dist/bind-H3ALI2NG.js +2 -0
  23. package/dist/bootstrap-JEVSVPQ2.js +2 -0
  24. package/dist/bridge-2UHJOVLX.js +2 -0
  25. package/dist/{catalog-MYPS2BXY.js → catalog-5UYBWA4W.js} +1 -1
  26. package/dist/catalog-client-VVKV4JKW.js +2 -0
  27. package/dist/{changelog-SU674BVE.js → changelog-FPWJXERY.js} +1 -1
  28. package/dist/chat-committer-ZKEKJA2R.js +2 -0
  29. package/dist/chat-controller-FXRJXUG3.js +2 -0
  30. package/dist/child-JHYENXE7.js +2 -0
  31. package/dist/chunk-226AGYHB.js +87 -0
  32. package/dist/{chunk-MNBGG4H3.js → chunk-23DKB2MT.js} +1 -1
  33. package/dist/{chunk-EECDDDSB.js → chunk-2COXO5LQ.js} +1 -1
  34. package/dist/{chunk-LUR7JFPP.js → chunk-2GEAKFAV.js} +1 -1
  35. package/dist/{chunk-7SY34IIL.js → chunk-2QKBXRLI.js} +1 -1
  36. package/dist/{chunk-AVSMXDTX.js → chunk-2ULYGALF.js} +1 -1
  37. package/dist/{chunk-JNSWKGTB.js → chunk-32HED7X2.js} +1 -1
  38. package/dist/{chunk-GRURFGBP.js → chunk-32MFECUA.js} +1 -1
  39. package/dist/{chunk-MYVKUJGS.js → chunk-35BG2EMW.js} +1 -1
  40. package/dist/{chunk-3GXN6VF6.js → chunk-3KY7HHQU.js} +1 -1
  41. package/dist/{chunk-7NPTL66J.js → chunk-3V4J65GN.js} +1 -1
  42. package/dist/{chunk-457Y5TEC.js → chunk-3YIA3DSL.js} +1 -1
  43. package/dist/{chunk-36N3EHW5.js → chunk-44SIFDNY.js} +1 -1
  44. package/dist/{chunk-MEKPGQAM.js → chunk-45NM23EQ.js} +2 -2
  45. package/dist/{chunk-I2MC6VVX.js → chunk-4C7WVQOD.js} +1 -1
  46. package/dist/{chunk-TU42YZOJ.js → chunk-4HARMERK.js} +1 -1
  47. package/dist/{chunk-ICLUC44J.js → chunk-4HYPMGDF.js} +1 -1
  48. package/dist/{chunk-7KX2BHKG.js → chunk-4KCYNP2K.js} +1 -1
  49. package/dist/{chunk-IJ2AHSWW.js → chunk-4LGQHTXM.js} +1 -1
  50. package/dist/{chunk-ETZMFRD6.js → chunk-4NEPHIAO.js} +1 -1
  51. package/dist/{chunk-3E4ZO73O.js → chunk-54NJJVG5.js} +1 -1
  52. package/dist/{chunk-734ORT6O.js → chunk-5F44KH3R.js} +1 -1
  53. package/dist/{chunk-E6KSRQXL.js → chunk-5F5IVART.js} +1 -1
  54. package/dist/{chunk-EBPRPNSA.js → chunk-5KJU4MG4.js} +1 -1
  55. package/dist/{chunk-JZP3Y4ZM.js → chunk-5MFPQYW3.js} +1 -1
  56. package/dist/{chunk-QENCC2ZS.js → chunk-5WLXAQ4H.js} +1 -1
  57. package/dist/{chunk-RFEON5GN.js → chunk-5XVWT6UK.js} +1 -1
  58. package/dist/{chunk-W4QSZNMB.js → chunk-6CS23F3E.js} +1 -1
  59. package/dist/{chunk-DZOYYWOW.js → chunk-6JUS2ULI.js} +1 -1
  60. package/dist/chunk-6K5BEEAJ.js +2 -0
  61. package/dist/{chunk-4QFTHUJA.js → chunk-6LEHGRRG.js} +1 -1
  62. package/dist/{chunk-LSDJOVWW.js → chunk-6SD4XTYC.js} +1 -1
  63. package/dist/{chunk-TW5AA5A7.js → chunk-6SWHEBPR.js} +1 -1
  64. package/dist/{chunk-URH4FX3H.js → chunk-6YBH3WUW.js} +1 -1
  65. package/dist/{chunk-ZAFJQ3SM.js → chunk-73HMW2WA.js} +1 -1
  66. package/dist/{chunk-NXAJBSIF.js → chunk-75FF7J5R.js} +1 -1
  67. package/dist/{chunk-P3JXJ4BW.js → chunk-7DLDADQR.js} +1 -1
  68. package/dist/{chunk-7NCJMWFX.js → chunk-7LYLJ75Z.js} +1 -1
  69. package/dist/chunk-7O2FIZB7.js +9 -0
  70. package/dist/chunk-7PCLHURF.js +101 -0
  71. package/dist/{chunk-PUVMC4PX.js → chunk-7V34ZMMS.js} +1 -1
  72. package/dist/{chunk-AEWNWAXW.js → chunk-7XJNYLQW.js} +2 -2
  73. package/dist/{chunk-WEIPY3CI.js → chunk-7ZR5CQY3.js} +1 -1
  74. package/dist/{chunk-2DYHAP4E.js → chunk-A474TUCE.js} +1 -1
  75. package/dist/chunk-A4ZV2SHL.js +5 -0
  76. package/dist/chunk-A7IMHUFY.js +27 -0
  77. package/dist/{chunk-XLEGGC4Y.js → chunk-ABMM37L2.js} +1 -1
  78. package/dist/{chunk-NIVFEACM.js → chunk-AUSLHNXQ.js} +1 -1
  79. package/dist/{chunk-YPFQ4UGF.js → chunk-B226SFOV.js} +1 -1
  80. package/dist/{chunk-DJC7NTLA.js → chunk-B57ZRHEQ.js} +1 -1
  81. package/dist/{chunk-CGITGJ3I.js → chunk-BHQIH2FE.js} +1 -1
  82. package/dist/{chunk-FWUPJORV.js → chunk-BJT6PZXL.js} +1 -1
  83. package/dist/{chunk-VX657KIK.js → chunk-C6P6YUCR.js} +1 -1
  84. package/dist/chunk-CB344EDO.js +2 -0
  85. package/dist/chunk-CCOD4GQJ.js +2 -0
  86. package/dist/{chunk-ZFM77AQU.js → chunk-CQDCNP7V.js} +1 -1
  87. package/dist/{chunk-VUFIL5VR.js → chunk-D4QXYAYA.js} +2 -2
  88. package/dist/{chunk-Y7E5L42F.js → chunk-DLP5S3TO.js} +1 -1
  89. package/dist/{chunk-35ECWCCK.js → chunk-DXIQVBMI.js} +1 -1
  90. package/dist/chunk-DXLZCJH5.js +7 -0
  91. package/dist/{chunk-OJ33Q6DU.js → chunk-E4GIGM5V.js} +1 -1
  92. package/dist/{chunk-I4WXALQR.js → chunk-EAWU2TOG.js} +1 -1
  93. package/dist/{chunk-ACMBMZDQ.js → chunk-EEOAU43D.js} +1 -1
  94. package/dist/{chunk-MYZHOBS4.js → chunk-EHB55V23.js} +1 -1
  95. package/dist/{chunk-UYDHOHSZ.js → chunk-ENRFXGID.js} +1 -1
  96. package/dist/{chunk-RTVHJ23A.js → chunk-ET5EK2CM.js} +1 -1
  97. package/dist/{chunk-EF47KRUK.js → chunk-EZMRWXRT.js} +1 -1
  98. package/dist/chunk-FAMQ4DHU.js +2 -0
  99. package/dist/{chunk-C2RUDJ46.js → chunk-FI2DVNRT.js} +1 -1
  100. package/dist/{chunk-AUJSC7PU.js → chunk-FNUGDPTS.js} +1 -1
  101. package/dist/{chunk-VLDCHFXF.js → chunk-FOLUB336.js} +1 -1
  102. package/dist/{chunk-NZ6AV2TA.js → chunk-FYPIF3BE.js} +1 -1
  103. package/dist/{chunk-HHW6MRU3.js → chunk-G4K3TP2I.js} +1 -1
  104. package/dist/{chunk-P2ZQDQDB.js → chunk-GAKBHNC4.js} +1 -1
  105. package/dist/{chunk-DPGOAFKF.js → chunk-GBQ4K25P.js} +1 -1
  106. package/dist/{chunk-O3HHTKZ5.js → chunk-GEZVC4S3.js} +1 -1
  107. package/dist/chunk-GJ7MO2FW.js +9 -0
  108. package/dist/{chunk-EZN7CF45.js → chunk-GJXO6FF7.js} +1 -1
  109. package/dist/{chunk-QDFY5GGO.js → chunk-GLM5UGTF.js} +1 -1
  110. package/dist/{chunk-HK62JVQM.js → chunk-GQARXS6F.js} +1 -1
  111. package/dist/{chunk-I4RVVBG3.js → chunk-GT3JDX5H.js} +1 -1
  112. package/dist/{chunk-YLXWAY7D.js → chunk-GZQAETB2.js} +1 -1
  113. package/dist/{chunk-7HMSMAUG.js → chunk-H4TIVILC.js} +5 -5
  114. package/dist/{chunk-VXGN3IV7.js → chunk-HG2ILWCE.js} +1 -1
  115. package/dist/{chunk-M43WH5DQ.js → chunk-HHOVANJ7.js} +1 -1
  116. package/dist/{chunk-CM4CHYSN.js → chunk-HM6LZ2KM.js} +1 -1
  117. package/dist/{chunk-QDXKEOKI.js → chunk-HNF3PWF3.js} +6 -6
  118. package/dist/{chunk-R7KXAISS.js → chunk-HVOXMCKE.js} +1 -1
  119. package/dist/{chunk-D7U2M26S.js → chunk-HWPWCCEV.js} +1 -1
  120. package/dist/{chunk-XRNQSXOM.js → chunk-HX5OLRKU.js} +2 -2
  121. package/dist/{chunk-4I7YN6YY.js → chunk-HYJVYYAZ.js} +2 -2
  122. package/dist/{chunk-CUXY6KQ2.js → chunk-I52NWH4U.js} +1 -1
  123. package/dist/{chunk-IGEAET7M.js → chunk-IB5WG5YY.js} +1 -1
  124. package/dist/{chunk-LAOTVZHV.js → chunk-IH73ZCBB.js} +1 -1
  125. package/dist/{chunk-TU7TVFBK.js → chunk-IT5JVCZN.js} +1 -1
  126. package/dist/{chunk-54XA5MZH.js → chunk-IZ66FKPC.js} +1 -1
  127. package/dist/{chunk-44B6THYK.js → chunk-JNPFEBUR.js} +1 -1
  128. package/dist/{chunk-RX6776AI.js → chunk-JTNEF5ZP.js} +1 -1
  129. package/dist/{chunk-QBYENBMB.js → chunk-JUVY6PHY.js} +1 -1
  130. package/dist/{chunk-5AKJPYUW.js → chunk-K4K2BGQC.js} +3 -3
  131. package/dist/{chunk-HJMCXSUJ.js → chunk-K75WIRI5.js} +1 -1
  132. package/dist/{chunk-FSYOTRMC.js → chunk-KKLCXRW6.js} +1 -1
  133. package/dist/{chunk-7YT4TTKL.js → chunk-KN7GZWKK.js} +1 -1
  134. package/dist/{chunk-ZTHYAHDN.js → chunk-L3BUPFAQ.js} +4 -4
  135. package/dist/{chunk-7XBNMOH4.js → chunk-LLQWEGXD.js} +1 -1
  136. package/dist/chunk-LTPOMMAB.js +2 -0
  137. package/dist/{chunk-CCP4X75B.js → chunk-LWCP4GLY.js} +1 -1
  138. package/dist/chunk-LXCTV75T.js +12 -0
  139. package/dist/{chunk-RDP7GWSY.js → chunk-LZGAFKYH.js} +1 -1
  140. package/dist/{chunk-3QICDXY5.js → chunk-LZPYIFHZ.js} +1 -1
  141. package/dist/{chunk-3OQW2GTA.js → chunk-M3TFOFUQ.js} +1 -1
  142. package/dist/{chunk-V7USCQWO.js → chunk-M7Y5GGVJ.js} +1 -1
  143. package/dist/{chunk-SMTBOSEJ.js → chunk-MEMXFTLD.js} +1 -1
  144. package/dist/{chunk-D756UWY2.js → chunk-MINDIQET.js} +1 -1
  145. package/dist/{chunk-ZTRRFG52.js → chunk-MP6NCJFE.js} +1 -1
  146. package/dist/{chunk-GXKY5A46.js → chunk-MSYRAPDK.js} +1 -1
  147. package/dist/{chunk-HJLMH7ZM.js → chunk-MUX2A37P.js} +1 -1
  148. package/dist/{chunk-YHFZFV3A.js → chunk-NCP54AIQ.js} +9 -9
  149. package/dist/{chunk-ZU4W2QGM.js → chunk-NVD2MXHQ.js} +1 -1
  150. package/dist/{chunk-FWDUVFS6.js → chunk-O2Y46A3G.js} +17 -17
  151. package/dist/{chunk-XZGEN4NU.js → chunk-O3TXAMFW.js} +1 -1
  152. package/dist/{chunk-YGRULEZY.js → chunk-O5KTMDTH.js} +1 -1
  153. package/dist/{chunk-PAWQ4AKN.js → chunk-OK6NLITG.js} +1 -1
  154. package/dist/{chunk-7AET4JKQ.js → chunk-OKA6FPJM.js} +1 -1
  155. package/dist/{chunk-3YTCKCBG.js → chunk-OVNTCBNS.js} +1 -1
  156. package/dist/{chunk-YQ5C6UDG.js → chunk-P4VFC6HO.js} +1 -1
  157. package/dist/{chunk-LQQNPMOD.js → chunk-PC22QRIY.js} +1 -1
  158. package/dist/{chunk-XQMWHPZI.js → chunk-PEUIHME2.js} +1 -1
  159. package/dist/{chunk-UEE3RZN4.js → chunk-PI7OXS62.js} +1 -1
  160. package/dist/{chunk-D7TKE7LK.js → chunk-POA336CU.js} +1 -1
  161. package/dist/{chunk-WZXPF3BI.js → chunk-PR5EGLEI.js} +1 -1
  162. package/dist/{chunk-YIKF4ERQ.js → chunk-PRBWZXFA.js} +2 -2
  163. package/dist/{chunk-XZYA7DNH.js → chunk-PVN64537.js} +1 -1
  164. package/dist/{chunk-VSVWNRI2.js → chunk-PWNYTIVA.js} +1 -1
  165. package/dist/chunk-Q4JV4U65.js +161 -0
  166. package/dist/{chunk-LUZBGTYB.js → chunk-Q5AKIQIE.js} +1 -1
  167. package/dist/{chunk-6EB5VRAN.js → chunk-QB77LRF4.js} +1 -1
  168. package/dist/{chunk-GQRU3B54.js → chunk-QUNIY6NN.js} +1 -1
  169. package/dist/{chunk-KODJVOCN.js → chunk-QVMXL675.js} +1 -1
  170. package/dist/{chunk-LCSJ7GOG.js → chunk-R6TFRAMZ.js} +1 -1
  171. package/dist/{chunk-4YW767UV.js → chunk-RAVAJZV2.js} +7 -7
  172. package/dist/{chunk-DDZLCAEO.js → chunk-RDAIOJCR.js} +1 -1
  173. package/dist/{chunk-RPRXRKKR.js → chunk-RQKMSNEU.js} +1 -1
  174. package/dist/{chunk-ECPFI75W.js → chunk-RRKYHUOD.js} +1 -1
  175. package/dist/{chunk-3RJHXOZH.js → chunk-S7XCOBYD.js} +1 -1
  176. package/dist/{chunk-Q3C6NDGI.js → chunk-SALZ6WSF.js} +1 -1
  177. package/dist/{chunk-ZFMRQ57Y.js → chunk-SIHX5FW5.js} +1 -1
  178. package/dist/{chunk-FIP5L6LV.js → chunk-SSOUYKVG.js} +1 -1
  179. package/dist/{chunk-TNORODUF.js → chunk-SVIIUKJ2.js} +1 -1
  180. package/dist/{chunk-7RWP4Y3H.js → chunk-T77LTLAD.js} +1 -1
  181. package/dist/{chunk-NLZZLANH.js → chunk-TAY7J5VS.js} +1 -1
  182. package/dist/chunk-TD6GCEIK.js +2 -0
  183. package/dist/{chunk-LKQFG4RW.js → chunk-TM6VLC6V.js} +1 -1
  184. package/dist/{chunk-YAW6JW6D.js → chunk-TMH4TPMB.js} +1 -1
  185. package/dist/{chunk-OFSDB7B4.js → chunk-TU2KPOW2.js} +2 -2
  186. package/dist/{chunk-3BSYOCSW.js → chunk-U2VYTVKV.js} +1 -1
  187. package/dist/{chunk-LIGTP3A3.js → chunk-UCVP7ZY4.js} +1 -1
  188. package/dist/{chunk-RHGW7B5Q.js → chunk-UICJ2KLJ.js} +1 -1
  189. package/dist/chunk-UJLULWSR.js +21 -0
  190. package/dist/{chunk-OCDBTAYS.js → chunk-UMNCM4RJ.js} +2 -2
  191. package/dist/{chunk-WOSANGV6.js → chunk-UWPG5MWM.js} +1 -1
  192. package/dist/{chunk-W6HZF56M.js → chunk-V3OZJO7Y.js} +1 -1
  193. package/dist/{chunk-3F5FMH76.js → chunk-VE4HLIGA.js} +1 -1
  194. package/dist/{chunk-RF37IJNN.js → chunk-W2HRX3DR.js} +1 -1
  195. package/dist/{chunk-NXRF7FFS.js → chunk-W54BX6HC.js} +1 -1
  196. package/dist/{chunk-IZ65ZPWY.js → chunk-W5HFUBXD.js} +1 -1
  197. package/dist/{chunk-HAW5WEKT.js → chunk-WEJR2V7R.js} +1 -1
  198. package/dist/{chunk-F5NHG7VB.js → chunk-X3A4QPA3.js} +1 -1
  199. package/dist/{chunk-AVI5H4UM.js → chunk-X52YIWGG.js} +1 -1
  200. package/dist/{chunk-72RC7JSA.js → chunk-X6FCXBXU.js} +1 -1
  201. package/dist/{chunk-PZA3BSOE.js → chunk-X7S7IGCV.js} +1 -1
  202. package/dist/{chunk-6DZX5HLZ.js → chunk-XCUF5AVM.js} +1 -1
  203. package/dist/{chunk-F22K3RRX.js → chunk-XHFU5TGS.js} +1 -1
  204. package/dist/chunk-XNXJXGVB.js +4 -0
  205. package/dist/{chunk-C62QWG4B.js → chunk-XZ6J3Y2W.js} +1 -1
  206. package/dist/{chunk-JGRXMTME.js → chunk-YDB72F4K.js} +1 -1
  207. package/dist/{chunk-7DFBOVUB.js → chunk-YJAQZMJT.js} +1 -1
  208. package/dist/chunk-YO6SNXBJ.js +2 -0
  209. package/dist/{chunk-AZLNLHUA.js → chunk-Z24SD2EJ.js} +1 -1
  210. package/dist/{chunk-HQ2E2XCU.js → chunk-Z36KVIRR.js} +1 -1
  211. package/dist/{chunk-WAOUE7MP.js → chunk-Z6SI7YNV.js} +1 -1
  212. package/dist/{chunk-6NFOH4AC.js → chunk-ZAQGIC33.js} +1 -1
  213. package/dist/{chunk-6UVIY56J.js → chunk-ZCL7XIVS.js} +1 -1
  214. package/dist/{chunk-UUJIGOEO.js → chunk-ZDCXWEQG.js} +1 -1
  215. package/dist/{chunk-SGPAM5DZ.js → chunk-ZDQYGLCZ.js} +1 -1
  216. package/dist/{chunk-42PALMW2.js → chunk-ZHAMVLQZ.js} +1 -1
  217. package/dist/{chunk-W7FLXW6Q.js → chunk-ZMWTRXFH.js} +1 -1
  218. package/dist/{chunk-KXHJMAZU.js → chunk-ZO3ZAMUU.js} +2 -2
  219. package/dist/{chunk-L5DALV5N.js → chunk-ZZZGTDYE.js} +1 -1
  220. package/dist/commands-R5AYK6XM.js +2 -0
  221. package/dist/{committer-JGY66PFM.js → committer-UO3B3S5Y.js} +1 -1
  222. package/dist/{config-754B73XK.js → config-YMHI3H3Y.js} +1 -1
  223. package/dist/cover-cmd-DVQIGFDY.js +2 -0
  224. package/dist/{credentials-F7DYLVWY.js → credentials-BCR73VGS.js} +1 -1
  225. package/dist/{deps-bundle-PW3WEQJ7.js → deps-bundle-6WLX44OA.js} +1 -1
  226. package/dist/{deps-resolve-SQYVN76L.js → deps-resolve-DSAKPZ3T.js} +1 -1
  227. package/dist/{design-chat-F3OEZPNJ.js → design-chat-YUI2JPO6.js} +1 -1
  228. package/dist/design-committer-7YIPFKMO.js +2 -0
  229. package/dist/design-headless-KIP6R7UV.js +2 -0
  230. package/dist/{design-remote-2BEGCVCX.js → design-remote-XMSHDDUX.js} +2 -2
  231. package/dist/device-env-K7J5NN66.js +2 -0
  232. package/dist/dispatch-BV6XMCN3.js +2 -0
  233. package/dist/{doctor-XY26Z35T.js → doctor-PGTNOMSP.js} +1 -1
  234. package/dist/{docx-convert-6IZO5P5K.js → docx-convert-DO5AQYD3.js} +1 -1
  235. package/dist/{dossier-NROC2MCY.js → dossier-5XKNAK6Q.js} +1 -1
  236. package/dist/evidence-RO3RDZXO.js +2 -0
  237. package/dist/evidence-presentation-LSFOZGLH.js +2 -0
  238. package/dist/evolve-cmd-U2ALVGMT.js +2 -0
  239. package/dist/evolve-remote-K2MCCVMM.js +2 -0
  240. package/dist/{exit-manager-EDHCETUN.js → exit-manager-EGWAZHCR.js} +1 -1
  241. package/dist/{explain-cmd-VYAANFFZ.js → explain-cmd-KNDORU2D.js} +1 -1
  242. package/dist/{explain-cmd-OP5I5W3O.js → explain-cmd-UWK5YVXG.js} +1 -1
  243. package/dist/explore-S2BGQUIF.js +2 -0
  244. package/dist/{explore-context-tty-RZ7D2TBV.js → explore-context-tty-WJHUSP3A.js} +1 -1
  245. package/dist/{explore-entry-EKXJ67BD.js → explore-entry-3EX2T3NS.js} +4 -4
  246. package/dist/{explore-live-2YVRAQZO.js → explore-live-TRY5A2ME.js} +1 -1
  247. package/dist/{explore-run-tty-D47FGPX7.js → explore-run-tty-ZV5XFKZA.js} +2 -2
  248. package/dist/{extract-bind-W2NET364.js → extract-bind-TXUBMK3T.js} +3 -3
  249. package/dist/extract-chat-VPYDGQKO.js +2 -0
  250. package/dist/{extract-cmd-FTFLETOP.js → extract-cmd-YUOYMVF5.js} +2 -2
  251. package/dist/extract-headless-UWTAPOET.js +2 -0
  252. package/dist/{feeder-NY45UFJK.js → feeder-NGWIPZ26.js} +1 -1
  253. package/dist/folder-flags-WV7UV3JG.js +2 -0
  254. package/dist/gaps-cmd-PFV3FZCM.js +3 -0
  255. package/dist/gate-7ALXLCNB.js +2 -0
  256. package/dist/gate-NB5CJMTN.js +2 -0
  257. package/dist/{generate-headless-RURIEKVS.js → generate-headless-KMBBZTLS.js} +2 -2
  258. package/dist/hold-passthrough-JGHWMYDM.js +2 -0
  259. package/dist/impact-cmd-PW33L5RF.js +11 -0
  260. package/dist/index.js +4150 -180
  261. package/dist/ingest-ZHHHBUXR.js +2 -0
  262. package/dist/{ingest-cmd-4G2AK4Y2.js → ingest-cmd-MXYILQLV.js} +3 -3
  263. package/dist/ingest-remote-2EEJP6ML.js +2 -0
  264. package/dist/install-7J34AYB6.js +2 -0
  265. package/dist/{interactive-bind-SI2ZS55Q.js → interactive-bind-FDWJUTI6.js} +4 -4
  266. package/dist/{interactive-remote-J56EWJGA.js → interactive-remote-O2Q2FNOH.js} +2 -2
  267. package/dist/lane-CNGO7LH5.js +2 -0
  268. package/dist/lattice-auth-TXNDLHM6.js +2 -0
  269. package/dist/{lifecycle-cmd-HJ37LTXE.js → lifecycle-cmd-GFHDBRXX.js} +1 -1
  270. package/dist/{list-cmd-6XL2FYLQ.js → list-cmd-RR75PMPE.js} +1 -1
  271. package/dist/list-commands-3QGZWJ5P.js +2 -0
  272. package/dist/{list-remote-LXPQNXYN.js → list-remote-AA3VSWOI.js} +1 -1
  273. package/dist/{locks-cmd-JJ2QNTNY.js → locks-cmd-AZKCSGHI.js} +1 -1
  274. package/dist/{logical-ids-RXAQJZ3T.js → logical-ids-74PLU3VR.js} +1 -1
  275. package/dist/login-flow-ZQ6UFTS2.js +2 -0
  276. package/dist/{maintenance-cmd-BXXHP36K.js → maintenance-cmd-OHGVARQ2.js} +1 -1
  277. package/dist/{mobile-prompts-CECJ5UY2.js → mobile-prompts-FZRKLLTN.js} +1 -1
  278. package/dist/{objective-variable-gate-3Z7DNVVC.js → objective-variable-gate-V5HHFOUS.js} +1 -1
  279. package/dist/{onboarding-PDVYMTY5.js → onboarding-NXGMV3VG.js} +1 -1
  280. package/dist/open-provider-XDJKT3W3.js +2 -0
  281. package/dist/pdf-convert-YB6PJFMI.js +2 -0
  282. package/dist/persist-recorded-session-INFN4JZT.js +3 -0
  283. package/dist/phase-seed-ZZSJME7M.js +2 -0
  284. package/dist/pipeline-MVZRI6YZ.js +2 -0
  285. package/dist/policy-commands-3YJ6YCDN.js +8 -0
  286. package/dist/prepare-target-DII5WZCX.js +2 -0
  287. package/dist/{pull-cmd-UPFQYUND.js → pull-cmd-XZN53XFZ.js} +1 -1
  288. package/dist/pull-route-R33BVADE.js +2 -0
  289. package/dist/readmodel-TRV4E3MW.js +2 -0
  290. package/dist/real-device-run-DGENHGUV.js +2 -0
  291. package/dist/{reconcile-cmd-JBH365JL.js → reconcile-cmd-KFPRCCJB.js} +4 -4
  292. package/dist/reconcile-deps-UDQBWSLE.js +2 -0
  293. package/dist/{reconcile-remote-BCX6SWFC.js → reconcile-remote-6WISFGRG.js} +2 -2
  294. package/dist/{recording-banner-YKBAL6UB.js → recording-banner-XOX2CDCF.js} +1 -1
  295. package/dist/registry-NV3EMDMK.js +2 -0
  296. package/dist/remote-entry-BCTFT643.js +2 -0
  297. package/dist/remote-mode-4HN27MD4.js +4 -0
  298. package/dist/{remote-words-YVB66R3F.js → remote-words-LFDYKIZ7.js} +1 -1
  299. package/dist/{require-project-folder-MLMEQJYP.js → require-project-folder-ZK4JJCDB.js} +1 -1
  300. package/dist/{resolve-run-intent-PC7TQZUL.js → resolve-run-intent-LYLVNNDZ.js} +1 -1
  301. package/dist/{resolver-EID34LQE.js → resolver-RMHGGYRP.js} +1 -1
  302. package/dist/revert-QKHPCRT6.js +2 -0
  303. package/dist/{review-cmd-EUHFLFMY.js → review-cmd-UGF2FC5Y.js} +1 -1
  304. package/dist/run-CSYGVV3D.js +2 -0
  305. package/dist/run-YUHHD54J.js +2 -0
  306. package/dist/{run-channel-63SVP5OI.js → run-channel-IIIYXOIW.js} +1 -1
  307. package/dist/run-remote-BGKQDAOA.js +2 -0
  308. package/dist/{run-startup-gate-YO66G6LS.js → run-startup-gate-4XE73OON.js} +1 -1
  309. package/dist/run-test-md-G6U3RU2Q.js +19 -0
  310. package/dist/session-worker.js +2 -2
  311. package/dist/{sessions-CFV7FOIT.js → sessions-NH2EG7BP.js} +1 -1
  312. package/dist/{sessions-cmd-S7WZBUCN.js → sessions-cmd-CABAX7BO.js} +2 -2
  313. package/dist/{sessions-remote-IWHWIQ2T.js → sessions-remote-Y4FTZL7Y.js} +1 -1
  314. package/dist/{skill-installer-MAVQY6GW.js → skill-installer-FS2AV7GX.js} +1 -1
  315. package/dist/spawner-MQ4XEHIX.js +2 -0
  316. package/dist/{store-MSA7KASS.js → store-PLKJZTGC.js} +1 -1
  317. package/dist/store-choice-UAB6Z4AL.js +2 -0
  318. package/dist/store-guard-DUN2X3SR.js +2 -0
  319. package/dist/{store-site-KA2DNBGY.js → store-site-K5NHLI7D.js} +1 -1
  320. package/dist/stream-warnings-GM7YEOVG.js +2 -0
  321. package/dist/sync-cmd-AGTOGPYM.js +2 -0
  322. package/dist/{sync-setup-RBRDUV7Q.js → sync-setup-4KIY3PDO.js} +1 -1
  323. package/dist/tcg-generate-CUY4AZ2V.js +2 -0
  324. package/dist/{test-definition-VRI4YIYL.js → test-definition-53XNBEDE.js} +1 -1
  325. package/dist/testmd-actions-UD6PAWUX.js +2 -0
  326. package/dist/{testmd-sync-UPAA5UMD.js → testmd-sync-EEJ7GPLR.js} +1 -1
  327. package/dist/tms-client-XWCR7O7J.js +2 -0
  328. package/dist/token-refresh-K6PVBBFE.js +2 -0
  329. package/dist/{trust-gate-AT2XBWN4.js → trust-gate-674C2NZS.js} +1 -1
  330. package/dist/{turn-preflight-LHYLRL7G.js → turn-preflight-R4PU6NYY.js} +1 -1
  331. package/dist/{use-case-ref-NE4X4MZN.js → use-case-ref-44BPIP4N.js} +1 -1
  332. package/dist/{validate-basic-M5JHHNZA.js → validate-basic-3JZRZL45.js} +1 -1
  333. package/dist/{variable-receipt-BXSZO36E.js → variable-receipt-7PRKDTRJ.js} +1 -1
  334. package/dist/verdicts-PVB7TV5S.js +2 -0
  335. package/dist/{version-check-Q737BE65.js → version-check-IY3YSQIP.js} +1 -1
  336. package/dist/{view-cmd-XSNL5DGI.js → view-cmd-WUIGTRFX.js} +1 -1
  337. package/dist/{walk-session-SHGYLFRB.js → walk-session-EH7227WR.js} +1 -1
  338. package/dist/with-telemetry-7JMZUBUZ.js +2 -0
  339. package/package.json +17 -17
  340. package/dist/ChatSurface-6NZGMNHL.js +0 -2
  341. package/dist/EvidenceViewOffer-WIEWCZUP.js +0 -2
  342. package/dist/FolderPicker-AF7ZMV3M.js +0 -2
  343. package/dist/InfoBox-D7GGZJU4.js +0 -2
  344. package/dist/ProjectPicker-OBYHJJLU.js +0 -2
  345. package/dist/SaveSessionPrompt-7XSHS4NL.js +0 -2
  346. package/dist/SingleShotApp-XQUDR36R.js +0 -2
  347. package/dist/TestMdRunView-LS2QUFWR.js +0 -2
  348. package/dist/TestrunEvidenceTable-HNDVJDIF.js +0 -2
  349. package/dist/bind-4XWK3DG2.js +0 -2
  350. package/dist/bootstrap-6ACT4ALI.js +0 -2
  351. package/dist/bridge-T6QMYKED.js +0 -2
  352. package/dist/chat-committer-ZCSRJEUB.js +0 -2
  353. package/dist/chat-controller-XINCDH6Z.js +0 -2
  354. package/dist/child-G2GCW73X.js +0 -2
  355. package/dist/chunk-34R7BNZ2.js +0 -2
  356. package/dist/chunk-65VANXOF.js +0 -147
  357. package/dist/chunk-C6HI6Y3S.js +0 -2
  358. package/dist/chunk-D36V5OX6.js +0 -2
  359. package/dist/chunk-HCJ2N3XB.js +0 -12
  360. package/dist/chunk-IUQOG7Z5.js +0 -5
  361. package/dist/chunk-KF4DKXSS.js +0 -2
  362. package/dist/chunk-NC7D7GOM.js +0 -21
  363. package/dist/chunk-OGFU4YY4.js +0 -2
  364. package/dist/chunk-R4JUKTDO.js +0 -2
  365. package/dist/chunk-VZ4A6WMK.js +0 -97
  366. package/dist/chunk-W54OT2FU.js +0 -9
  367. package/dist/chunk-W72ACCFL.js +0 -27
  368. package/dist/chunk-WXJCJL5L.js +0 -7
  369. package/dist/cover-cmd-NBNZCR6C.js +0 -2
  370. package/dist/design-committer-TRYP3LOZ.js +0 -2
  371. package/dist/design-headless-OTHYOX3E.js +0 -2
  372. package/dist/device-env-CHFRRV6W.js +0 -2
  373. package/dist/dispatch-DVQ3H7EJ.js +0 -2
  374. package/dist/evidence-P6FFKC7B.js +0 -2
  375. package/dist/evidence-presentation-YYTIDCBS.js +0 -2
  376. package/dist/evolve-cmd-WWOB3QJR.js +0 -2
  377. package/dist/evolve-remote-WLVY3QID.js +0 -2
  378. package/dist/explore-K5YBGHK6.js +0 -2
  379. package/dist/extract-chat-M65NWGUK.js +0 -2
  380. package/dist/extract-headless-G6W6JQ27.js +0 -2
  381. package/dist/folder-flags-KKIH654K.js +0 -2
  382. package/dist/gaps-cmd-OIDDLRYL.js +0 -3
  383. package/dist/gate-7AKRPRMK.js +0 -2
  384. package/dist/gate-WISOUTHQ.js +0 -2
  385. package/dist/hold-passthrough-IOWPVB4W.js +0 -2
  386. package/dist/ingest-PDGS5ZTL.js +0 -2
  387. package/dist/ingest-remote-SSLUHQVG.js +0 -2
  388. package/dist/install-ZVBHPXGP.js +0 -2
  389. package/dist/lane-AQYRIW24.js +0 -2
  390. package/dist/lattice-auth-6FEVSR7E.js +0 -2
  391. package/dist/list-commands-5DCCKU3L.js +0 -2
  392. package/dist/login-flow-WEK3E476.js +0 -2
  393. package/dist/open-provider-OZAG6WZS.js +0 -2
  394. package/dist/pdf-convert-447ACUB3.js +0 -2
  395. package/dist/persist-recorded-session-A3ID7JFA.js +0 -3
  396. package/dist/phase-seed-LCJ4WSYV.js +0 -2
  397. package/dist/pipeline-GX3LKPI5.js +0 -2
  398. package/dist/prepare-target-FMT6QFHZ.js +0 -2
  399. package/dist/pull-route-FWBXJMR7.js +0 -2
  400. package/dist/readmodel-INMP6MNW.js +0 -2
  401. package/dist/real-device-run-X7JJWOIK.js +0 -2
  402. package/dist/reconcile-deps-TWJ3FTSU.js +0 -2
  403. package/dist/registry-VQC757MJ.js +0 -2
  404. package/dist/remote-entry-X6JMPC2K.js +0 -2
  405. package/dist/remote-mode-FDPA7EWG.js +0 -4
  406. package/dist/revert-FHOBLZWF.js +0 -2
  407. package/dist/run-5RQUCNYP.js +0 -2
  408. package/dist/run-PC5YO4AS.js +0 -2
  409. package/dist/run-remote-SJCRTL7O.js +0 -2
  410. package/dist/run-test-md-BLNBK4MH.js +0 -17
  411. package/dist/spawner-C7NLLM4F.js +0 -2
  412. package/dist/store-choice-3OJCV26J.js +0 -2
  413. package/dist/store-guard-OOSDLMEC.js +0 -2
  414. package/dist/stream-warnings-GEQKKJU7.js +0 -2
  415. package/dist/sync-cmd-RDFDMVKQ.js +0 -2
  416. package/dist/tcg-generate-KIECTZ2C.js +0 -2
  417. package/dist/testmd-actions-CMAG6HWI.js +0 -2
  418. package/dist/tms-client-NXAB6VJD.js +0 -2
  419. package/dist/token-refresh-KP3AYMYK.js +0 -2
  420. package/dist/verdicts-XK3GAUX3.js +0 -2
  421. package/dist/with-telemetry-PM2HVN2B.js +0 -2
@@ -0,0 +1,5 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as et,c as nt}from"./chunk-W3USRQX6.js";import{R as tt}from"./chunk-7O2FIZB7.js";import{a as Z}from"./chunk-JQ64X2TO.js";import{a as Lt}from"./chunk-JIRNI5TB.js";import{a as k}from"./chunk-UTM7D4PI.js";import{b as Q}from"./chunk-Z36KVIRR.js";import{b as W,e as X}from"./chunk-6K5BEEAJ.js";import{a as Y}from"./chunk-FCD3NYOM.js";import{a as J}from"./chunk-4QTH7VYE.js";import{a as R}from"./chunk-RZ4F3BHX.js";import{e as Nt}from"./chunk-UR6MHSHU.js";import{readFileSync as T,existsSync as G,readdirSync as be,mkdirSync as K,writeFileSync as w}from"fs";import{readFile as Ot,unlink as ye}from"fs/promises";import{join as y}from"path";import{existsSync as ae,mkdirSync as ce,readdirSync as At,writeFileSync as ue}from"fs";import{join as S}from"path";import{randomUUID as v}from"crypto";var it=["children","instructions","branches","module_content","true_branch","false_branch"];function D(e){let t=new Map,n=r=>{if(!r||typeof r!="object")return;let o=r;if(Array.isArray(o.operations))for(let i of o.operations){let s=i.operation_id;if(typeof s!="string"||!s)continue;let a=t.get(s)??[];a.includes(o)||a.push(o),t.set(s,a)}for(let i of it){let s=o[i];Array.isArray(s)?s.forEach(n):s&&typeof s=="object"&&n(s)}};return e.forEach(n),t}function Tt(e,t){if(!t||t.length===0)return;if(t.length===1)return t[0];let n=e.action_params?.script;if(typeof n=="string"&&n.trim()){let r=n.trim(),o=t.find(i=>jt(i)?.trim()===r);if(o)return o}return t[0]}function jt(e){let t=e,n=t.script_content??t.js_snippet;return typeof n=="string"?n:void 0}function U(e,t){let n=new Map;for(let r of e){let o=Tt(r,r.action_id?t.get(r.action_id):void 0);if(!o)continue;let i=n.get(o)??[];i.push(r),n.set(o,i)}return n.size===0?null:[...n].map(([r,o])=>Bt(r,o))}function ot(e,t){let n=D(t.authoredInstructions),r=[];for(let o of e){if(o.flatIndex===void 0||!t.replayOnlyFlatIndices.has(o.flatIndex))continue;let i=U(o.records,n);i&&r.push(...i)}return r}function st(e,t){let n=new Map(t.map(a=>[a.instruction_id,a])),r=[],o=a=>{if(!a||typeof a!="object")return;let c=a.instruction_id,u=typeof c=="string"?n.get(c):void 0;return u&&r.push(c),u},i=a=>{if(!a||typeof a!="object")return;let c=a;for(let u of it){let l=c[u];if(Array.isArray(l))s(l);else if(l&&typeof l=="object"){let _=o(l);_&&(c[u]=_),i(_??l)}}},s=a=>{for(let c=0;c<a.length;c++){let u=o(a[c]);u&&(a[c]=u),i(u??a[c])}};return s(e),r}function Ct(e){if(!e.timestamp||e.duration_ms==null)return"";let t=new Date(e.timestamp);return isNaN(t.getTime())?"":new Date(t.getTime()+e.duration_ms).toISOString()}function j(e){if(e!=null)try{return JSON.parse(e)}catch{return e}}function Dt(e){return typeof e=="string"?"string":typeof e=="boolean"?"bool":typeof e=="number"?Number.isInteger(e)?"int":"float":Array.isArray(e)?"list":e==null?"NoneType":"JSON"}function C(e,t,n){let r=e.user_variables,o=typeof r=="string",i;try{i=o?JSON.parse(r):r??[]}catch{return}if(!Array.isArray(i)||i.length===0)return;let s=i.find(a=>t&&a.name===t)??(i.length===1?i[0]:void 0);s&&(s.value=n,s.value_type=Dt(n),e.user_variables=o?JSON.stringify(i):i)}function rt(e){e.user_variables!==void 0&&(e.user_variables=typeof e.user_variables=="string"?"[]":[])}function Ut(e,t){let n=e.operations??[],r=new Set(t.map(i=>i.action_id).filter(Boolean)),o=n.filter(i=>r.has(i.operation_id));return o.length>0?o:n.length===1?n:[]}function Ft(e){let t=e.error??"Script execution failed";return{error:t,error_code:"SCRIPT_EXECUTION_ERROR",error_message:t,reason:t}}function Bt(e,t){let n=structuredClone(e),r=t[0],o=t[t.length-1];n.status=t.find(s=>s.status!=="success")?.status??r.status,n.start_timestamp=r.timestamp??n.start_timestamp,n.end_timestamp=Ct(o)||n.end_timestamp;let i=Ut(n,t);for(let s of i)s.status=n.status,s.operation_start=n.start_timestamp,s.operation_end=n.end_timestamp;switch(n.content_type){case"api":{let s=o.action_params?.api_data?.response;if(s&&typeof s=="object")for(let a of[n,...i])a.api_data={...a.api_data??{},response:s},C(a,o.output_variable,s);break}case"script":{let s=o.output_variable??n.output_variable_name;if(n.status!=="success"){let a=Ft(o);n.code_error=a,rt(n);for(let c of i)c.execution_result=a,c.code_error=a,rt(c)}else if(o.output_value!=null){let a=j(o.output_value);C(n,s,a);for(let c of i)c.execution_result={value:a},C(c,s,a)}break}case"db_query":{o.output_value!=null&&(n.db_details={...n.db_details??{},carried_out_query:j(o.output_value)});break}case"screenshot_command":{let s=j(o.output_value);s&&typeof s=="object"&&(n.smartui_results=s);break}case"network_assertion":case"network_query":break;default:break}return n}var Mt="/home/kaneai/Downloads";function O(e){return`${Mt}/${e}`}function ut(e){return"FILE__"+e.replace(/[^A-Za-z0-9]/g,"_")}function M(e){return"file."+e}function N(e){let t=e?.media;return!t||!t.name||!t.media_url?null:{media_id:t.media_id??"",name:t.name,media_url:t.media_url,type:t.type??"doc",...t.alias?{alias:t.alias}:{}}}function lt(e){return e?e.includes(`
3
+ `)?e.split(`
4
+ `).map(t=>t.trim()).filter(Boolean):e.split(". ").map(t=>t.trim()).filter(Boolean).map(t=>t.endsWith(".")?t:t+"."):[]}function F(e){return typeof e=="string"&&e.includes("{{secrets.")}var zt={click:"CLICK",double_click:"CLICK",type:"TYPE",fill:"TYPE",clear:"CLEAR",select:"SELECT",hover:"HOVER",drag:"DRAG_DROP",upload_files:"UPLOAD_FILE",navigate:"OPEN",go_back:"NAVIGATE",go_forward:"NAVIGATE",refresh:"REFRESH",press_key:"SENDKEYS",scroll:"SCROLL_PIXELS",scroll_into_view:"SCROLL_UNTIL_ELEMENT",js_dialog:"JS_DIALOG",wait:"WAIT",wait_until:"WAIT_UNTIL",wait_for_load:"WAIT_FOR_LOAD",switch_tab:"SWITCH_TAB",new_tab:"NEW_TAB",close_tab:"CLOSE_TAB",api:"API",evaluate_js:"EVALUATE_JS",vision_query:"VISION_QUERY",textual_query:"TEXTUAL_QUERY",get_url:"GET_URL",get_title:"GET_TITLE",assert:"ASSERTION",math:"MATHEMATICAL_OPERATION",set_cookies:"SET_COOKIES",delete_cookies:"DELETE_COOKIES",clear_cookies:"CLEAR_COOKIES",set_local_storage:"SET_LOCAL_STORAGE",delete_local_storage:"DELETE_LOCAL_STORAGE",clear_local_storage:"CLEAR_LOCAL_STORAGE",set_clipboard:"SET_CLIPBOARD",paste_clipboard:"PASTE_CLIPBOARD",clear_clipboard:"CLEAR_CLIPBOARD",device_control:"DEVICE_CONTROL",device_control_query:"DEVICE_CONTROL_QUERY"},dt={literal:"SET_VARIABLE",condition:"SET_VARIABLE",visual:"VISION_QUERY",dom:"TEXTUAL_QUERY",url:"GET_URL",title:"GET_TITLE",devtool_network:"DEVTOOLS_NETWORK_QUERY",devtool_console:"DEVTOOLS_CONSOLE_QUERY",devtool_cookies:"DEVTOOLS_COOKIES_QUERY",devtool_storage:"DEVTOOLS_STORAGE_QUERY",devtool_performance:"DEVTOOLS_PERFORMANCE",api_response:"API_CALLS_QUERY",textual_visual:"TEXTUAL_ANALYZER"},Vt=new Set(["CLICK","TYPE","FILL","HOVER","SCROLL_UNTIL_ELEMENT","UPLOAD_FILE","VISION_QUERY","DRAG_DROP","SELECT"]);function _t(e,t){if(e==="analyze"){let r=t?.action_params?.analyzer_type??"";return dt[r]}if(e==="scroll"&&t?.action_params?.into_view===!0)return"SCROLL_UNTIL_ELEMENT";let n=zt[e];return n||console.warn(`[migrator] UNKNOWN action_type "${e}" \u2014 falling back to "${e.toUpperCase()}"; explicit mapping required`),n??e.toUpperCase()}function pt(e,t){if(!e||!t)return"";try{let n=new Date(e);return isNaN(n.getTime())?"":new Date(n.getTime()+t).toISOString()}catch{return""}}function gt(e){try{return JSON.parse(e.output_value??"{}")}catch{return{}}}function $t(e){let t=e.output_variable??"";if(!t)return"[]";let r={...gt(e)};return delete r.body,JSON.stringify([{name:t,unique_key:(e.action_id??"").replace(/-/g,"").slice(0,8)||v().replace(/-/g,"").slice(0,8),value:r,variable_description:"API Response"}])}function qt(e,t,n){let r=e.action_params??{},o=Vt.has(t)?"Vision Agent":"Operation Agent",i={operation_type:t};t==="OPEN"&&(i.url=r.url??""),t==="SET_VARIABLE"&&(i.variable_name=e.output_variable??r.key??"",i.variable_value=e.output_value??"");let s=t==="UPLOAD_FILE"?N(r):null;s&&(i.value=O(s.name));let a={},c={},u=e.action_instruction??"",l=r.text??"",_=r.url??"",p=[["intent",u],["value",l],["url",_]];for(let[h,A]of Object.entries(n)){let I=String(A);if(h.startsWith("secrets."))for(let[b,E]of p)E.includes(I)&&(c[b]=h);for(let[b,E]of p)E.includes(I)&&!(b in a)&&(a[b]=E)}s?.alias&&(a.value=`{{${M(s.alias)}}}`);let d=e.action_type,g={operation:e.action_instruction??"",agent:o,operation_dict:i,reasoning:d==="analyze"?r.query??"":e.intent??e.action_instruction??"",variable:a,secrets:c,params:{}};d==="analyze"&&typeof r.code=="string"&&r.code&&(g.code=r.code),d==="analyze"&&typeof r.code_js=="string"&&r.code_js&&(g.code_js=r.code_js),d==="analyze"&&typeof r.condition_expression=="string"&&r.condition_expression&&(g.condition_expression=r.condition_expression),r.uses_websocket===!0&&(g.uses_websocket=!0),r.uses_sse===!0&&(g.uses_sse=!0),d==="analyze"&&r.analyzer_type==="textual_visual"&&(typeof r.wrapped_js=="string"&&(g.wrapped_js=r.wrapped_js),Array.isArray(r.locators)&&(g.locators=r.locators),typeof r.operator=="string"&&(g.operator=r.operator),Array.isArray(r.transforms)&&(g.transforms=r.transforms),typeof r.query=="string"&&(g.query=r.query),typeof r.expected_value=="string"&&(g.expected_value=r.expected_value),typeof r.needs_unit_conversion=="boolean"&&(g.needs_unit_conversion=r.needs_unit_conversion),typeof r.condition=="string"&&(g.condition=r.condition));let m={set_cookies:"cookies",set_clipboard:"text",delete_cookies:"names",set_local_storage:"items",delete_local_storage:"keys"}[d];return m&&r[m]!==void 0&&(g[m]=r[m]),d==="set_clipboard"&&typeof r.html=="string"&&r.html&&(g.html=r.html),g}function L(e){let t=e.assertion_tree;return t&&typeof t=="object"&&Object.keys(t).length>0?t:Array.isArray(e.sub_results)?e:{}}function Gt(e){let t=L(e);if(typeof t.passed=="boolean")return t.passed;let n=t.sub_results??[];return n.length===0?t.status==="passed":(t.composite_operator??"and")==="or"?n.some(o=>o.passed===!0):n.every(o=>o.passed===!0)}function ft(e){return e.map(t=>({description:t.description??"",store_key:t.store_key??"",expected_value:t.expected??"",extracted_value:t.extracted_value??"",operator:t.operator??"equals",transforms:t.transforms??[]}))}function Kt(e){let t=L(e),n=t.sub_results??[],r=ft(n);return{operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[],sub_results:n,sub_checks:r,composite_operator:t.composite_operator??"and",verification:t.verification??"",claim:t.description??""}}function Ht(e){let t=e.action_params??{},n=L(t),r=n.sub_results??[],o=ft(r);return[{operation:e.action_instruction??"",agent:"Operation Agent",operation_dict:{operation_type:"ASSERTION",assertion_tree:{sub_results:r,sub_checks:o,composite_operator:n.composite_operator??"and",verification:"",claim:n.description??e.action_instruction??"",operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[]}},variable:{},secrets:{},params:{}}]}function Jt(e,t,n,r){let o=e.visual_data;if(!o||o.x==null||o.y==null)return null;let i=t?`${t}/test_screenshots`:"";return{x:o.x,y:o.y,confidence:0,bbox:o.bbox??null,bbox_source:o.bbox?"accessibility_tree":"fallback",viewport_width:o.viewport_width??1280,viewport_height:o.viewport_height??800,scale_factor:null,raw_image_url:i?`${i}/untagged_screenshot/${n}.${r?.get(n)??"png"}`:"",raw_image_sas_url:"",annotated_image_url:"",annotated_image_sas_url:""}}function Yt(e){if(!e)return"";let t=e;return typeof e=="object"&&!Array.isArray(e)&&Array.isArray(e.frameInfo)&&(t=e.frameInfo),!Array.isArray(t)||t.length===0?"":JSON.stringify(t)}function Wt(e){return/^(android|ios)_native$/i.test(e.platform??"")}function mt(e,t){return e.map(n=>({...n,type:t?n.strategy??n.type??"native":n.isXPath?"xpath":"css"}))}function Xt(e,t,n){let r={selector_target:"",drag_displacement:{},hold_duration_ms:null,move_duration_ms:null,hold_at_destination_ms:null};if(e!=="drag")return r;let o=t.target_selectors,i={};typeof t.direction=="string"&&t.direction&&(i.direction=t.direction,typeof t.fraction=="number"&&(i.fraction=t.fraction));let s=a=>typeof t[a]=="number"?Math.trunc(t[a]):null;return{selector_target:Array.isArray(o)&&o.length>0?mt(o,n):"",drag_displacement:i,hold_duration_ms:s("hold_duration_ms"),move_duration_ms:s("move_duration_ms"),hold_at_destination_ms:s("hold_at_destination_ms")}}function at(e,t="",n){let r=e.action_type,o=_t(r,e),i=e.action_params??{},s=e.coordinates??null,a=e.selectors??null,c=!!(a&&a.length>0),u=Wt(e),l=Xt(r,i,u),_=e.timestamp??"",p=e.duration_ms??0,d=e.variables_used??{},g=e.action_id??v(),f=v(),m=pt(_,p),h="",A="";if(r==="navigate")A=i.url??"",h=A;else if(r==="type"||r==="fill")h=i.text??"";else if(r==="press_key")h=i.key??"";else if(r==="wait")h=String(i.ms??i.timeout_ms??"");else if(r==="evaluate_js")h=i.script??"";else if(r==="js_dialog")h=i.prompt_text??"";else if(r==="upload_files"){let H=N(i);H&&(h=O(H.name))}else r==="analyze"&&o==="SET_VARIABLE"&&(h=e.output_value??"");let I="";r==="go_back"?I="back":r==="go_forward"&&(I="forward");let b=e.action_instruction??"",E=F(h)||F(A)||F(b),x=qt(e,o,d);return{operation_id:g,instruction_id:f,instruction:b,intent:b,operation_start:_,operation_end:m,status:e.status??"",command:o,name:"",target:"",value:h,message:"",operation_dict:"",frame:Yt(e.frame_info),surface:typeof i.surface=="string"?i.surface:"",frame_path:typeof i.frame_path=="string"?i.frame_path:"",grounded_by:typeof i.grounded_by=="string"?i.grounded_by:"",error_message:e.error??"",code_snippet:"",sub_instruction_obj:JSON.stringify(x),test_id:"",test_version:"",action:"",string_to_float:!1,feedback_msg:"",time_taken:"",create_time_stamp:"",update_time_stamp:"",locator_variable:"",locator_variable_name:"",image_url:t&&r!=="js_dialog"?`${t}/test_screenshots/untagged_screenshot/${g}.${n?.get(g)??"png"}`:"",alternative_xpaths:[],attribute:"",value_description:"",url:A,navigation_direction:I,tagified_image_url:"",query_variable_name:e.output_variable??"",query_variable_value:e.output_value??"",query_variable_type:"",expected_value:"",queried_value:"",operator:"",assertion_status:o==="ASSERTION"?Gt(i):"",query_info_dict:{},query_content_confidence:"none",debugging_logs:[],locator_index:0,query_html:"",user_variables:"[]",optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,tab_index:String(i.tab_index??""),tab_identifier:String(i.tab_identifier??""),scroll_value:i.amount??1,scroll_direction:i.direction??"",mi_scroll_payload:{},sleep_duration:0,app_id:"",manual_interaction_tag:"",string_to_float_list:[],js_snippet:r==="evaluate_js"?i.script??"":"",code_error:"",hide:E,dismiss_dialog:!1,use_v2_mobile_tagging:u,multiple_inputs:!1,dialog_action:r==="js_dialog"?i.action??"":"",dialog_type:r==="js_dialog"?i.dialog_type??"":"",is_coordinates_used_for_interaction:s!==null&&!c,element_coordinates_ratio:[],element_bounds_ratio:[],x_coord:c?null:s?.x??null,y_coord:c?null:s?.y??null,target_x_coord:i.target_x??null,target_y_coord:i.target_y??null,source_description:i.source_description??null,target_description:i.target_description??null,use_coordinates:s!==null&&!c,kaneaiMobileTaggingImageLimit:1,clicks_order_code:"se_js_ac",selector:c?mt(a,u):"",selector_target:l.selector_target,math_result_variable_name:"",math_result_variable_value:"",expression_tree:o==="ASSERTION"?Kt(i):i.expression_tree??{},assertion_tree:o==="ASSERTION"?L(i):i.assertion_tree??{},assertion_tree_simplified:{},network_throttle:{},is_mobile_offline:!1,autoheal:!1,reprobe:e.reprobe??!1,click_modifier:(i.click_count??1)>=2?{kind:"multi_click",frequency:i.click_count}:null,db_query:"",db_details:{},db_query_decoded:"",is_global_variable:!1,is_global_variable_persist:!1,global_variable_id:"",wait_for_element_timeout:0,failure_condition:o==="ASSERTION"?"Fail test immediately":"",screenshot_command:"",smartui_contents:{},smartui_results:{},result_type:"",result_hint:"",drag_offset:{},drag_displacement:l.drag_displacement,hold_duration_ms:l.hold_duration_ms,move_duration_ms:l.move_duration_ms,hold_at_destination_ms:l.hold_at_destination_ms,start_coordinates:i.source_coordinates?{x:i.source_coordinates[0],y:i.source_coordinates[1]}:{},end_coordinates:i.target_coordinates?{x:i.target_coordinates[0],y:i.target_coordinates[1]}:{},element_rect:null,is_canvas:!1,until_condition:"",until_max_retries:0,until_settle_ms:0,api_data:r==="api"?{request:e.action_params?.api_data?.request??{}}:{},output_variables:r==="api"?e.output_variable?{[e.output_variable]:null}:{}:e.output_variable?{[e.output_variable]:e.output_value??""}:{},visual_context:Jt(e,t,g,n),reasoning:r==="analyze"?i.query??"":e.intent??e.action_instruction??""}}function ct(e,t){let n=e.action_type,r=_t(n,e),o=e.timestamp??"",i=e.duration_ms??0,s=pt(o,i),a=r==="ASSERTION"||r==="MATHEMATICAL_OPERATION";return{instruction_id:t.instruction_id,instruction_class:a?"non_driver_action":"driver_action",module_id:"",instruction:e.action_instruction??"",command:r,error:null,parent_instruction_id:"",classification_layer_resp:r==="ASSERTION"?Ht(e):[],classification_error:{},operations:[t],status:e.status??"",start_timestamp:o,end_timestamp:s,type:"agent_generated",tags:[],html_paths:[],optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,content_type:n==="api"?"api":n==="analyze"&&e.action_params?.analyzer_type==="api_response"?"api_calls_query":n==="analyze"&&e.action_params?.analyzer_type?.startsWith("devtool_")?e.action_params.analyzer_type.replace("devtool_","devtools_"):"instruction",js_snippet:n==="evaluate_js"?e.action_params?.script??"":"",user_variables:n==="api"?$t(e):"[]",api_data:n==="api"?{request:e.action_params?.api_data?.request??{},response:gt(e)}:{},params_used:!1,hard_assertion:r==="ASSERTION"?e.action_params?.failure_condition==="hard":!1,expected_outcome:"",module_execution_index:0,module_version:null,network_throttle:{},isEdited:!1,use_query_assertion_v2:!1,db_query:"",db_details:{},network_assertion_content:{},screenshot_command:"",smartui_contents:{},generative_id:"",plan_id:"",generative_objective:"",error_message:"",error_code:"",reason:"",title:"",used_variables:[],reasoning:n==="analyze"?e.action_params?.query??"":e.intent??e.action_instruction??""}}function Zt(e,t=[]){let n=e.action_params??{},r=n.branches??[],o=n.winning_index??-1,i=n.sub_results??[],s={};for(let c of i){let u=c.sub_results;if(u)for(let l of u){let _=l.store_key;_&&(s[_]=l)}}let a=r.map((c,u)=>{let l=u===o,_=(c.sub_checks??[]).map(p=>{let d=s[p.store_key];return{description:p.description,store_key:p.store_key,expected_value:p.expected_value,stored_value:d?.extracted_value??p.stored_value,operator:p.operator??d?.operator??"equals",transforms:p.transforms??d?.transforms??[]}});if(_.length===0&&c.condition&&i.length>0){let d=i.find(g=>g.branch_index===u)?.sub_results??[];d.length>0&&(_=d.map(g=>({description:g.description??c.condition,store_key:g.store_key??"",expected_value:g.expected??"true",stored_value:g.extracted_value??void 0,operator:g.operator??"equals",transforms:g.transforms??[]})))}return{branch_index:u,condition:c.condition??null,branch_type:c.branch_type??"sub_objective",passed:l,sub_objective:null,custom_event:c.custom_event??null,children:l?t:[],sub_checks:c.condition?_:[],composite_operator:c.composite_operator??"and"}});return{content_type:"conditional_block",instruction_id:`if_else_${v().slice(0,8)}`,instruction:e.action_instruction??"",instruction_class:"driver_action",command:"",status:e.status??"success",resolved_branch_index:o,branches:a,generative_id:"",generative_objective:"",variables_used:{},classification_layer_resp:[],classification_error:{},used_variables:[],user_variables:"[]",module_id:"",module_execution_index:0,module_version:"",plan_id:"",optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,error:null,error_message:"",error_code:"",reason:"",start_timestamp:e.timestamp??"",end_timestamp:"",type:"agent_generated",hook:null,hook_type:null,evaluation_context:{},query_variables:{}}}function ht(e,t,n){for(let r of e)r.content_type==="instruction"&&"generative_id"in r&&(r.generative_id=t,r.generative_objective=n)}function B(e,t="",n,r){let o=[],i=0;for(;i<e.length;){let s=e[i],a=s.action_type;if(!r?.keepFailedActions&&s.status==="error"&&a!=="assert"&&a!=="if_else"&&a!=="child_agent_start"&&a!=="child_agent_end"&&a!=="js_dialog"&&!(s.until_condition&&!s.error)){i+=1;continue}if(a==="analyze"&&(!dt[s.action_params?.analyzer_type??""]||s.action_params?.analyzer_type==="textual_visual"&&s.action_params?.code)){i+=1;continue}if(a==="child_agent_start"){let c=s.action_params?.child_id??"",u=s.action_params?.objective??"",l=[];i+=1;let _=1,p="error",d;for(;i<e.length&&_>0;){let E=e[i],x=E.action_type;if(x==="child_agent_start")_+=1;else if(x==="child_agent_end"&&(_-=1,_===0)){p=E.status??"success",d=E,i+=1;break}_>0&&l.push(E),i+=1}let g=B(l,t,n);ht(g,c,u);let f=d?.action_params?.result_code??null,m=d?.action_params?.reason_code??null,h=d?.action_params?.error_message??null,A=d?.action_params?.summary??null,I=d?.action_params?.one_liner??null,b=p==="error";o.push({content_type:"generative_block",instruction_id:`generative_block_${c}`,generative_id:c,objective:u,status:p,children:g,error_message:b?h??null:null,error_code:b?m??null:null,result_code:f??null,bifurcation_context:[],approach_reason:lt(A),one_liner:I??null});continue}else if(a==="child_agent_end"){i+=1;continue}else if(a==="if_else"){i+=1;let c=[];for(;i<e.length&&e[i].action_type==="child_agent_start";){let u=e[i],l=u.action_params?.child_id??"",_=u.action_params?.objective??"",p=[];i+=1;let d=1,g="error";for(;i<e.length&&d>0;){let m=e[i];if(m.action_type==="child_agent_start")d+=1;else if(m.action_type==="child_agent_end"&&(d-=1,d===0)){g=m.status??"success",i+=1;break}d>0&&p.push(m),i+=1}let f=B(p,t,n);c.push(...f)}o.push(Zt(s,c));continue}else if(a==="query_tool"){i+=1;continue}else if(s.until_condition){let c=at(s,t,n),u=ct(s,c),l=typeof s.until_condition_met=="boolean"?s.until_condition_met:s.status==="success";o.push({content_type:"until_block",instruction_id:`until_${v().slice(0,8)}`,condition:s.until_condition,max_retries:s.until_max_retries??10,settle_ms:s.until_settle_ms??500,current_count:0,condition_met:l,children:[u],generative_id:"",generative_objective:"",variables_used:{},status:s.status??"success"})}else{let c=at(s,t,n),u=ct(s,c);o.push(u)}i+=1}return o}function P(e,t="",n,r){let o=[],i=[],s=r?.passthrough,a=s?D(s.authoredInstructions):null;for(let d of e){if(s&&a&&d.flatIndex!==void 0&&s.replayOnlyFlatIndices.has(d.flatIndex)){let b=U(d.records,a);if(b){for(let E of b)o.push(E),i.push(d.flatIndex);continue}console.warn(`[migrator] replay-only passthrough: no authored operation matched step ${d.flatIndex} (action_id \u2260 any operation_id in the authored blob) \u2014 falling back to this run's records`)}let g=B(d.records,t,n,r);if(g.length===0)continue;let f=v().replace(/-/g,"");ht(g,f,d.objective);let m=g.some(b=>"status"in b&&typeof b.status=="string"?b.status==="error"||b.status==="failed":!1),h=d.resultCode?parseInt(d.resultCode,10):null,A=h!==null&&!isNaN(h)&&h>=200,I=m||A?"error":"success";o.push({content_type:"generative_block",instruction_id:`generative_block_${f}`,generative_id:f,objective:d.objective,status:I,children:g,error_message:I==="error"?d.errorMessage??null:null,error_code:I==="error"?d.reasonCode??null:null,result_code:d.resultCode??null,bifurcation_context:[],approach_reason:lt(d.summary),one_liner:d.oneLiner??null}),i.push(d.flatIndex)}let c=o.map((d,g)=>({block:d,flat:i[g]})),u=r?.moduleSpans??[],l=r?.blockSpans??[],_=r?.authoredBlocks??[];u.length>0&&(c=bt(c,u,l,_));let p=It(l,u);return p.length>0&&(c=z(c,p,_)),{instructions:c.map(d=>d.block)}}function bt(e,t,n,r){let o=[],i=a=>a===void 0?void 0:t.find(c=>a>=c.flatFrom&&a<=c.flatTo),s=0;for(;s<e.length;){let a=i(e[s].flat);if(!a){o.push(e[s]),s++;continue}let c=[];for(;s<e.length&&i(e[s].flat)===a;)c.push(e[s++]);let u=bt(c,a.children,n,r),l=It(Et(n,a),a.children);l.length>0&&(u=z(u,l,r)),o.push({block:se(a,u.map(_=>_.block)),flat:c[0].flat})}return o}function yt(e,t){return e.flatFrom>=t.flatFrom&&e.flatTo<=t.flatTo}function Et(e,t){let n=[];for(let r of e)yt(r,t)?n.push(r):n.push(...Et(r.children,t));return n}function It(e,t){let n=[],r=i=>{for(let s of i)n.push(s),r(s.children)};r(t);let o=i=>i.filter(s=>!n.some(a=>yt(s,a))).map(s=>({...s,children:o(s.children)}));return n.length>0?o(e):e}function z(e,t,n){let r=[...t].sort((u,l)=>u.flatFrom-l.flatFrom),o=[],i=(u,l)=>{o.push({block:re(u,l,n),flat:u.flatFrom})},s=(u,l)=>u!==void 0&&u>=l.flatFrom&&u<=l.flatTo,a=0,c=0;for(;c<e.length;){let u=e[c].flat;for(;a<r.length&&u!==void 0&&r[a].flatTo<u;)i(r[a++],[]);let l=a<r.length&&s(u,r[a])?r[a]:void 0;if(!l){o.push(e[c]),c++;continue}let _=[];for(;c<e.length&&s(e[c].flat,l);)_.push(e[c++]);i(l,_),a++}for(;a<r.length;)i(r[a++],[]);return o}function Qt(e){let t=new Map;for(let n of e)t.set(n.flat,n);return e.filter(n=>t.get(n.flat)===n)}var te=["children","instructions","branches","module_content","true_branch","false_branch"];function ee(e,t){if(!t)return;let n=[...e];for(;n.length>0;){let r=n.pop();if(!r||typeof r!="object")continue;let o=r;if(o.instruction_id===t&&(o.content_type==="conditional_block"||o.content_type==="until_block"))return o;for(let i of te){let s=o[i];Array.isArray(s)?n.push(...s):s&&typeof s=="object"&&n.push(s)}}}function ne(e,t,n){if(!e)return[];if(t==="while")return Array.isArray(e.children)?e.children:[];let o=(Array.isArray(e.branches)?e.branches:[])[n];return o&&Array.isArray(o.children)?o.children:[]}function re(e,t,n){let r=ee(n,e.blockId),o=e.branches.map((i,s)=>{let a=t.filter(l=>l.flat!==void 0&&l.flat>=i.flatFrom&&l.flat<=i.flatTo);e.kind==="while"&&(a=Qt(a));let c=z(a,e.children,n).map(l=>l.block);if(c.length>0)return c;let u=ne(r,e.kind,s);return u.length===0&&!i.taken&&console.warn(`[migrator] control-flow: branch ${s} of block ${e.blockId||e.instruction} did not run and no authored block matched \u2014 emitted empty`),u});return e.kind==="if"?ie(e,o,r):oe(e,o[0]??[],r)}function ie(e,t,n){let r=Array.isArray(n?.branches)?n.branches:[],o=V(t.flat()),i=e.branches.map((s,a)=>{let c=r[a];return{branch_index:a,condition:s.branch_type==="else"?null:s.condition,branch_type:s.branch_type,passed:s.taken,sub_objective:null,custom_event:c?.custom_event??null,children:t[a],sub_checks:Array.isArray(c?.sub_checks)?c.sub_checks:[],composite_operator:c?.composite_operator??"and"}});return{content_type:"conditional_block",instruction_id:e.blockId||`if_else_${v().slice(0,8)}`,instruction:e.instruction,instruction_class:"driver_action",command:"",status:o?"error":"success",resolved_branch_index:e.branches.findIndex(s=>s.taken),branches:i,generative_id:"",generative_objective:"",variables_used:{},classification_layer_resp:[],classification_error:{},used_variables:[],user_variables:"[]",module_id:"",module_execution_index:0,module_version:"",plan_id:"",optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,error:null,error_message:o?.message??"",error_code:o?.code??"",reason:"",start_timestamp:"",end_timestamp:"",type:"agent_generated",hook:null,hook_type:null,evaluation_context:{},query_variables:{}}}function oe(e,t,n){let r=e.whileCfg??{max_retries:5,settle_ms:500,on_exhaust:"fail",iterations:0,condition_met:!1},o=V(t),i=(s,a)=>n&&n[s]!==void 0?n[s]:a;return{content_type:"until_block",instruction_id:e.blockId||`until_${v().slice(0,8)}`,condition:e.instruction,max_retries:r.max_retries,settle_ms:r.settle_ms,current_count:r.iterations,condition_met:r.condition_met,children:t,generative_id:"",generative_objective:"",variables_used:{},status:o?"error":"success",on_exhaust:i("on_exhaust",r.on_exhaust),mode:i("mode",""),check:i("check",""),conditions:i("conditions",[]),connectors:i("connectors",[]),sub_checks:i("sub_checks",[]),composite_operator:i("composite_operator","and")}}function V(e){for(let t of e){let n="status"in t&&typeof t.status=="string"?t.status:"";if(n==="error"||n==="failed"){let r="error_message"in t?t.error_message:void 0,o="error_code"in t?t.error_code:void 0;return{message:r??null,code:o??null}}}return null}function se(e,t){let n=e.meta,r=(u,l="")=>typeof n[u]=="string"?n[u]:l,o=(u,l=!1)=>typeof n[u]=="boolean"?n[u]:l,i=u=>Array.isArray(n[u])?n[u]:[],s=typeof n.module_version=="number"||typeof n.module_version=="string"?n.module_version:null,a=r("module_id"),c=V(t);return{content_type:tt,instruction_id:`module_block_${a}`,module_id:a,module_version:s,module_instance_id:v(),module_name:r("module_name"),module_description:r("module_description"),module_platform:r("module_platform"),creation_mode:r("creation_mode","Agent"),tms_status:r("tms_status","active"),is_validated:o("is_validated"),is_dirty:e.dirty,enrichment_id:r("enrichment_id"),tags:i("tags"),project_ids:i("project_ids"),link_to_all:o("link_to_all"),status:c?"error":"success",children:t,error_message:c?.message??null,error_code:c?.code??null,update_available:!1,update_info:{}}}function vt(e,t){let n;try{n=At(e)}catch{return 0}let r=0,o=n.filter(i=>/^\d+$/.test(i)).sort((i,s)=>Number(i)-Number(s));for(let i of o){let s=S(e,i),a=S(s,"logs");if(!ae(a))continue;let c;try{c=At(a)}catch{continue}let u=c.filter(p=>p.endsWith("-actions.ndjson")).sort((p,d)=>(parseInt(p,10)||0)-(parseInt(d,10)||0)),l=[];for(let p of u){let d=t.readActions(S(a,p));d.length&&l.push({objective:t.objective??"",records:d})}if(l.length===0)continue;let{instructions:_}=P(l,t.screenshotBaseUrl??"",t.extMap,{keepFailedActions:!0});if(_.length!==0)try{let p=S(s,"auteur");ce(p,{recursive:!0}),ue(S(p,"execution.json"),JSON.stringify(t.buildBlob(_),null,2)),r++,t.log?.("info","EVIDENCE_ARCHIVED_ATTEMPT_BLOB","Derived nested attempt blob",{attempt:i,instructions:_.length})}catch(p){t.log?.("debug","EVIDENCE_ARCHIVED_ATTEMPT_BLOB_FAILED","Nested attempt blob derivation failed",{attempt:i,error:p instanceof Error?p.message:String(p)})}}return r}import{existsSync as le,readFileSync as de}from"fs";function kt(e){try{return le(e)?JSON.parse(de(e,"utf-8")):void 0}catch{return}}function $(e,t){if(!e||typeof e!="object")return;let n=e,r=n.project_token;if(typeof r!="string"||!r)return;let o={project_token:r},i=n[t];typeof i=="string"&&i&&(o.project_name=i);let s=n.project_id;return typeof s=="string"&&s&&(o.project_id=s),o}function q(e){if(Array.isArray(e)){for(let r of e){let o=q(r);if(o)return o}return}if(!e||typeof e!="object")return;let t=e,n=t.smartui_results;if(n&&typeof n=="object"){let r=$(n.project,"name");if(r)return r}for(let r of Object.values(t)){let o=q(r);if(o)return o}}function Rt(e){for(let t of e.runMetaPaths){let n=kt(t),r=$(n?.smartui,"project_name");if(r)return r}if(e.authoredBlobPath){let t=kt(e.authoredBlobPath),n=$(t?.smartui,"project_name");if(n)return n}return q(e.instructions)??{}}var Pt=Nt(Lt(),1);import{createWriteStream as _e}from"fs";import{readFile as pe}from"fs/promises";import{join as ge,basename as fe}from"path";import{tmpdir as me}from"os";var he=["**/screenshots/**","**/annotated/**","**/tcg/**","**/bifurcation/**"];async function St(e){let t=ge(me(),`${fe(e)}_artifacts.zip`);return new Promise((n,r)=>{let o=_e(t),i=(0,Pt.default)("zip",{zlib:{level:6}});o.on("close",()=>n(t)),i.on("error",r),i.pipe(o),i.glob("**/*",{cwd:e,ignore:he}),i.finalize()})}async function wt(e){return pe(e)}async function Ee(e,t){return Ot(Q(e,t))}function Ie(e){return{key:"artifacts",content_type:"application/zip",filename:`${e}.evidence`}}var Ae=[1e3,2e3,4e3],xt=class{config;controller;testId;constructor(t){this.config=t,this.controller=new Y(t.controllerBaseUrl,t.auth),this.testId=t.testId}log(t,n,r,o){this.config.log?.(t,n,r,o)}async execute(){let{onProgress:t}=this.config;try{if(!this.testId)return this.log("error","PIPELINE_ABORT","No test_id available"),{success:!1,testId:null,error:"No test_id available"};let n=this.config.evidence,r=null;if(this.config.shouldUploadArtifacts!==!1){t("convert","running");let a=this.collectNdjsonPerRun(),c=a.reduce((f,m)=>f+m.records.length,0);this.log("info","PIPELINE_CONVERT","Collected NDJSON records",{total_records:c,run_groups:a.length});let u=this.loadReplayOnlyPassthrough(),{instructions:l}=a.length>0?P(a,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap,{moduleSpans:this.config.moduleSpans,...u?{passthrough:u}:{},...this.config.blockSpans?.length?{blockSpans:this.config.blockSpans,authoredBlocks:this.loadAuthoredBlocks()}:{}}):{instructions:[]};this.log("info","PIPELINE_CONVERT_INSTRUCTIONS","Auteur instructions produced",{count:l.length});let _=this.buildExecutionEnvelope(l),p=Buffer.from(JSON.stringify(_));this.log("info","PIPELINE_CONVERT_BLOB","Blob created",{size_kb:+(p.length/1024).toFixed(1)});let d=y(this.config.sessionDir,"execution.json");w(d,JSON.stringify(_,null,2)),this.log("info","PIPELINE_CONVERT_LOCAL_SAVE","Execution blob saved locally",{path:d});let g=n?.packTestDir??this.config.evidenceRead?.packTestDir;if(g){let f=y(g,"auteur");K(f,{recursive:!0}),w(y(f,"execution.json"),JSON.stringify(_,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack",{path:y(f,"execution.json")}),this.deriveArchivedAttemptBlobs(g)}if(t("convert","done"),n)r=p;else{t("zip","running"),this.log("info","PIPELINE_ZIP_START","Zipping session",{session_dir:this.config.sessionDir});let f=null,m;try{f=await St(this.config.sessionDir),m=await wt(f),this.log("info","PIPELINE_ZIP_DONE","Zip complete",{size_mb:+(m.length/1024/1024).toFixed(1),path:f}),t("zip","done",`${(m.length/1024/1024).toFixed(1)}MB`)}finally{f&&await ye(f).catch(()=>{})}t("presign","running"),this.log("info","PIPELINE_PRESIGN_START","Requesting presigned URLs",{url:`${this.config.controllerBaseUrl}/upload/presign`,test_id:this.testId,session_id:this.config.sessionId});let h=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[{key:"artifacts",content_type:"application/zip",filename:`${this.config.sessionId}_artifacts.zip`},{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);this.log("info","PIPELINE_PRESIGN_OK","Presigned URLs received",{artifacts_url:h.urls.artifacts?.blob_url,blob_url:h.urls.blob?.blob_url}),t("presign","done"),t("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading artifacts and blob",{artifact_size_mb:+(m.length/1024/1024).toFixed(1),blob_size_kb:+(p.length/1024).toFixed(1)}),await Promise.all([k(h.urls.artifacts.upload_url,m,"application/zip"),k(h.urls.blob.upload_url,p,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),t("upload","done")}}else{let a=this.collectNdjsonPerRun(),c=this.loadReplayOnlyPassthrough(),{instructions:u}=a.length>0?P(a,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap,{keepFailedActions:!0,moduleSpans:this.config.moduleSpans,...c?{passthrough:c}:{},...this.config.blockSpans?.length?{blockSpans:this.config.blockSpans,authoredBlocks:this.loadAuthoredBlocks()}:{}}):{instructions:[]},l=this.buildExecutionEnvelope(u),_=y(this.config.sessionDir,"execution.json");w(_,JSON.stringify(l,null,2)),this.log("info","PIPELINE_LOCAL_SAVE","Execution blob saved locally (no upload)",{path:_});let p=this.config.evidence?.packTestDir??this.config.evidenceRead?.packTestDir;if(p){let d=y(p,"auteur");K(d,{recursive:!0});let g=this.readAuthoredExecution(),f=g?this.refreshReplayOnlyInPack(g,a,c):null;w(y(d,"execution.json"),f?.raw??JSON.stringify(l,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack (gated)",{path:y(d,"execution.json"),source:f?f.refreshed.length>0?"authored+replay_results":"authored":"run_envelope",...f&&f.refreshed.length>0?{refreshed_instruction_ids:f.refreshed}:{}}),this.deriveArchivedAttemptBlobs(p)}t("convert","skipped"),t("zip","skipped"),t("presign","skipped"),t("upload","skipped"),this.log("info","PIPELINE_UPLOAD_SKIPPED","Upload steps skipped (gate disabled)")}if(this.config.shouldReplaceLocalOutput&&this.config.onAtomicReplace){t("atomic_replace","running");try{await this.config.onAtomicReplace(),this.log("info","PIPELINE_ATOMIC_REPLACE_OK","Local output replaced"),t("atomic_replace","done")}catch(a){let c=a instanceof Error?a.message:String(a);throw this.log("error","PIPELINE_ATOMIC_REPLACE_FAILED","Atomic-replace failed",{error:c}),t("atomic_replace","failed",c),a}}else t("atomic_replace","skipped");let o,i;if(this.config.shouldCommit&&!this.config.isFirstRun&&this.config.onCommitLock){t("commit_lock","running");let a=await this.config.onCommitLock();if(a.ok)o=a.testcaseId||void 0,this.log("info","PIPELINE_COMMIT_LOCK_OK","Commit lock acquired",{testcase_id:o??"none",trigger:a.trigger??null,test_instance_id:a.testInstanceId??null}),t("commit_lock","done");else return this.log("error","PIPELINE_COMMIT_LOCK_FAILED","Commit lock failed",{reason:a.reason,message:a.message}),t("commit_lock","failed",`${a.reason??"unknown"}: ${a.message??""}`),{success:!1,testId:this.testId,error:`commit-lock failed: ${a.reason??"unknown"}`}}else t("commit_lock","skipped");if(this.config.isFirstRun&&!this.config.skipTmsFinalize){t("finalize","running"),this.log("info","PIPELINE_FINALIZE_START","Finalizing test (first-run)",{test_id:this.testId,commit_id:this.config.commitId});let a=new X(this.config.tmsBaseUrl,this.config.tmsUsername,this.config.tmsAccessKey),c=this.config.runObjectives&&this.config.runObjectives.length>0?this.config.runObjectives:[this.config.firstObjective],u={commit_id:this.config.commitId,time_taken:Math.round(this.config.totalDuration),steps_count:this.config.totalSteps,commit_message:this.config.firstObjective.slice(0,255),objectives:c,...this.config.assuranceStamp?{assurance:this.config.assuranceStamp}:{}},l;try{l=await this.stop(a,u)}catch(_){if(!this.config.attachedStop)throw _;let p=_ instanceof Error?_.message:String(_);this.log("error","PIPELINE_FINALIZE_NOT_SAVED","Attached test's stop did not finalize after its retries",{test_id:this.testId,error:p}),t("finalize","failed",p);try{await this.config.onFinalizeGaveUp?.()}catch(d){this.log("warn","PIPELINE_FINALIZE_META_FAILED","Meta-rewrite after a stop that did not finalize failed",{error:String(d)})}return{success:!1,testId:this.testId,error:`finalize failed: ${p}`,notSaved:!0}}if(o=l.testcase_id||void 0,this.log("info","PIPELINE_FINALIZE_OK","Test finalized",{testcase_id:o??"none",commit_id:l.commit_id??null}),this.config.onFinalizeSuccess)try{await this.config.onFinalizeSuccess(o,l.commit_id)}catch(_){this.log("warn","PIPELINE_FINALIZE_META_FAILED","Meta-rewrite after endTest failed",{error:String(_)})}t("finalize","done")}else t("finalize","skipped"),this.log("info","PIPELINE_FINALIZE_SKIPPED","Finalize skipped (evolve flow or first-run disabled)");if(o&&this.config.shareApiBaseUrl)try{i=await this.generateShareLink(o),this.log("info","PIPELINE_SHARE_OK","Share link generated",{share_id:i})}catch(a){this.log("warn","PIPELINE_SHARE_FAILED","Share link failed",{error:String(a)})}if(n&&r){let a=null;t("zip","running");try{await n.sealFn({testcaseId:o,shareId:i}),a=n.sealedPackPath?await Ot(n.sealedPackPath):await Ee(n.executionId,n.cwd),this.log("info","PIPELINE_EVIDENCE_SEALED","Evidence pack sealed",{execution_id:n.executionId}),this.log("info","PIPELINE_PACK_READ","Sealed pack read",{size_mb:+(a.length/1024/1024).toFixed(1)})}catch(c){let u=c instanceof Error?c.message:String(c);this.log("warn","PIPELINE_EVIDENCE_UPLOAD_SKIPPED","Evidence seal/read failed \u2014 uploading blob only",{execution_id:n.executionId,error:u})}if(a){t("zip","done",`${(a.length/1024/1024).toFixed(1)}MB`),t("presign","running");let c=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[Ie(n.executionId),{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);this.log("info","PIPELINE_PRESIGN_OK","Presigned URLs received",{artifacts_url:c.urls.artifacts?.blob_url,blob_url:c.urls.blob?.blob_url}),t("presign","done"),t("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading pack and blob",{artifact_size_mb:+(a.length/1024/1024).toFixed(1),blob_size_kb:+(r.length/1024).toFixed(1)}),await Promise.all([k(c.urls.artifacts.upload_url,a,"application/zip"),k(c.urls.blob.upload_url,r,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),t("upload","done")}else{t("zip","skipped"),t("presign","running");let c=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);t("presign","done"),t("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading blob only (evidence skipped)",{blob_size_kb:+(r.length/1024).toFixed(1)}),await k(c.urls.blob.upload_url,r,"application/json"),this.log("info","PIPELINE_UPLOAD_OK","Blob upload complete (pack skipped)"),t("upload","done")}}let s;if(this.config.codeExport?.enabled&&o){let a=!1;try{await this.triggerCodeExport(o),this.log("info","PIPELINE_CODE_EXPORT_START","Code export triggered"),a=!0}catch(c){let u=c instanceof Error?c.message:String(c);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export trigger failed; skipping poll",{error:u}),t("code_export","failed",`trigger failed: ${u}`)}if(a){t("code_export","running","Waiting for code generation\u2026");try{s=await this.pollAndDownloadCode(o,t),this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:s}),t("code_export","done",s)}catch(c){let u=c instanceof Error?c.message:String(c);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:u}),t("code_export","failed",u)}}}else t("code_export","skipped");return this.log("info","PIPELINE_COMPLETE","Pipeline complete"),{success:!0,testId:this.testId,testcaseId:o,shareId:i,codeExportDir:s}}catch(n){return{success:!1,testId:this.testId,error:n instanceof Error?n.message:String(n)}}}async stop(t,n){let r=this.config.attachedStop?this.config.stopRetryDelaysMs??Ae:[];for(let o=0;;o++)try{return await t.endTest(this.testId,n)}catch(i){if(!(i instanceof W&&(i.status===null||i.status>=500)&&o<r.length))throw i;this.log("warn","PIPELINE_FINALIZE_RETRY","Attached test's stop sent again",{attempt:o+1,status:i.status}),await new Promise(a=>setTimeout(a,r[o]))}}async runCodeExport(t,n){let r=n??this.config.onProgress,o=!1;try{await this.triggerCodeExport(t),this.log("info","PIPELINE_CODE_EXPORT_TRIGGER","Code export triggered",{testcase_id:t}),o=!0}catch(i){let s=i instanceof Error?i.message:String(i);this.log("error","PIPELINE_CODE_EXPORT_TRIGGER_FAILED","Code export trigger failed; skipping poll",{error:s}),r("code_export","failed",`trigger failed: ${s}`)}if(o){r("code_export","running","Waiting for code generation\u2026");try{let i=await this.pollAndDownloadCode(t,r);return this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:i}),r("code_export","done",i),i}catch(i){let s=i instanceof Error?i.message:String(i);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:s}),r("code_export","failed",s);return}}}deriveArchivedAttemptBlobs(t){try{let n=vt(t,{readActions:r=>this.readNdjsonFromFile(r),buildBlob:r=>this.buildExecutionEnvelope(r),objective:this.config.firstObjective,screenshotBaseUrl:this.config.screenshotBaseUrl??"",extMap:this.config.screenshotExtMap,log:(r,o,i,s)=>this.log(r,o,i,s)});n>0&&this.log("info","PIPELINE_ARCHIVED_ATTEMPTS","Nested retry-attempt blobs derived",{count:n})}catch(n){this.log("debug","PIPELINE_ARCHIVED_ATTEMPTS_FAILED","Nested attempt blob pass failed",{error:n instanceof Error?n.message:String(n)})}}collectNdjsonPerRun(){let t=[],n=this.config.runObjectives??[],r=this.config.runMetadata??[],o=this.config.evidence??this.config.evidenceRead;for(let i=0;i<this.config.runDirs.length;i++){let s=this.config.runDirs[i],a=n[i]||this.config.firstObjective,c=r[i],u=o?this.readNdjsonFromFile(y(o.packTestDir,"logs",`${o.runIndices?.[i]??i}-actions.ndjson`)):this.readNdjsonFromDir(s);if(u.length>0){let l=o?.runIndices?.[i]??i,_=this.config.runFlatIndex?.[l];t.push({objective:a,records:u,..._!==void 0?{flatIndex:_}:{},resultCode:c?.resultCode,reasonCode:c?.reasonCode,errorMessage:c?.errorMessage,summary:c?.summary,oneLiner:c?.oneLiner})}}if(t.length===0){let i=y(this.config.sessionDir,"runs");if(G(i))try{let a=be(i,{withFileTypes:!0}).filter(c=>c.isDirectory()).map(c=>c.name).sort();for(let c of a){let u=y(i,c),l=this.readNdjsonFromDir(u);l.length>0&&t.push({objective:this.config.firstObjective,records:l})}}catch{}}return t}readNdjsonFromDir(t){let n=[y(t,"run-test","actions.ndjson"),y(t,"actions.ndjson")];for(let r of n)if(G(r))return this.readNdjsonFromFile(r);return[]}readNdjsonFromFile(t){let n=[];if(!G(t))return n;this.log("debug","PIPELINE_COLLECT_READ","Reading NDJSON file",{path:t});let r=T(t,"utf-8");for(let o of r.split(`
5
+ `)){let i=o.trim();if(i)try{n.push(JSON.parse(i))}catch{}}return n}async generateShareLink(t){let n=`${this.config.shareApiBaseUrl}/lshs/api/v1.0/share-item/generate-sharable-link`;this.log("info","PIPELINE_SHARE_START","Requesting share link",{url:n,testcase_id:t});let r={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({entityIds:[t],entityType:"Test Case Details",expiresAt:7})},o=!!this.config.authResolver;this.log("debug","PIPELINE_SHARE_AUTH","Share link auth config",{resolver:o,fallback_auth_type:typeof this.config.auth=="string"?"bearer":"basic",tms_user:this.config.tmsUsername});let i=o?await this.config.authResolver.fetch(n,r):await R(n,{...r,headers:{...r.headers,Authorization:this.buildAuthHeader()}});if(!i.ok)throw new Error(`Share link API failed: ${i.status} ${await i.text()}`);let s=await i.json();if(!s.shareId)throw new Error("Share link API returned no shareId");return s.shareId}async triggerCodeExport(t){if(!this.config.codeExport)throw new Error("triggerCodeExport called without resolved codeExport config");let{url:n,body:r}=et({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:t,codeExport:this.config.codeExport,mobile:this.config.mobile});this.log("info","PIPELINE_CODE_EXPORT_POST","Triggering code export",{url:n});let o={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(r)},i=this.config.authResolver?await this.config.authResolver.fetch(n,o):await R(n,{...o,headers:{...o.headers,Authorization:this.buildAuthHeader()}});if(!i.ok)throw new Error(`Code export failed: ${i.status} ${await i.text()}`)}async pollAndDownloadCode(t,n){let r=nt({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:t}),o=this.config.exitTimeoutMs??3e5,i=5e3,s=Date.now()+o;this.log("info","PIPELINE_CODE_EXPORT_POLL","Polling for code export",{url:r,timeout_ms:o});let a=(c,u)=>this.config.authResolver?this.config.authResolver.fetch(c,u):R(c,{...u,headers:{...u?.headers,Authorization:this.buildAuthHeader()}});for(;Date.now()<s;){let c=await a(r,{method:"GET",headers:{Accept:"application/json"}});if(!c.ok){let d=await c.text().catch(()=>"");throw this.log("warn","PIPELINE_CODE_EXPORT_POLL_FAILED","Code export poll non-200; skipping",{status:c.status,body:d.slice(0,200)}),new Error(`code export poll skipped: HTTP ${c.status}`)}let l=(await c.json()).data?.find(d=>d.code_name==="kane-cli-trigger");if(!l){this.log("debug","PIPELINE_CODE_EXPORT_WAITING","No kane-cli-trigger entry yet"),n("code_export","running","Waiting for code generation\u2026"),await this.sleep(i);continue}let _=l.status.toLowerCase();if(_==="in progress"||_==="in_progress"||_==="pending"){this.log("debug","PIPELINE_CODE_EXPORT_IN_PROGRESS","Code export in progress",{status:l.status}),n("code_export","running","Generating code\u2026"),await this.sleep(i);continue}if(!l.url||l.url.length===0)throw new Error(`Code export status=${l.status} but no files returned`);let p=this.config.codeExportDir??y(this.config.sessionDir,"code-export");K(p,{recursive:!0}),this.log("info","PIPELINE_CODE_EXPORT_DOWNLOAD","Downloading code files",{file_count:l.url.length,dir:p}),n("code_export","running",`Downloading ${l.url.length} files\u2026`);for(let d of l.url){let g=y(p,d.file_name),f=await R(d.file_url);if(!f.ok){this.log("warn","PIPELINE_CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:d.file_name,status:f.status});continue}let m=await f.text();w(g,m,"utf-8"),this.log("info","PIPELINE_CODE_EXPORT_FILE_SAVED","File saved",{file_name:d.file_name,size_bytes:m.length})}return p}throw new Error("Code export timed out")}sleep(t){return new Promise(n=>setTimeout(n,t))}buildAuthHeader(){return typeof this.config.auth=="string"?`Bearer ${this.config.auth}`:J(this.config.auth.username,this.config.auth.accessKey)}readAuthoredExecution(){let t=this.config.authoredExecutionPath;if(!t)return null;try{let n=T(t,"utf8");return JSON.parse(n),n}catch{return this.log("warn","PIPELINE_AUTHORED_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 pack gets this run's envelope",{path:t}),null}}refreshReplayOnlyInPack(t,n,r){if(!r)return{raw:t,refreshed:[]};let o=ot(n,r);if(o.length===0)return{raw:t,refreshed:[]};let i=JSON.parse(t);if(!Array.isArray(i.instructions))return{raw:t,refreshed:[]};let s=st(i.instructions,o);return s.length===0?{raw:t,refreshed:s}:{raw:JSON.stringify(i,null,2),refreshed:s}}loadAuthoredBlocks(){let t=this.config.blockAuthoredExecutionPath;if(!t)return[];try{let n=JSON.parse(T(t,"utf8"));return Array.isArray(n.instructions)?n.instructions:[]}catch(n){return this.log("warn","PIPELINE_AUTHORED_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 branches that did not run this time upload empty",{path:t,error:n instanceof Error?n.message:String(n)}),[]}}loadReplayOnlyPassthrough(){let t=this.config.replayOnlyPassthrough;if(!(!t||t.flatIndices.length===0))try{let n=JSON.parse(T(t.authoredExecutionPath,"utf8"));if(!Array.isArray(n.instructions))throw new Error("no instructions array");return{authoredInstructions:n.instructions,replayOnlyFlatIndices:new Set(t.flatIndices)}}catch(n){this.log("warn","PIPELINE_PASSTHROUGH_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 replay-only steps convert from this run's records",{path:t.authoredExecutionPath,flat_indices:t.flatIndices,error:n instanceof Error?n.message:String(n)});return}}smartuiProject(t){let n=this.config.evidence??this.config.evidenceRead,r=this.config.runDirs.map((i,s)=>n?y(n.packTestDir,"logs",`${n.runIndices?.[s]??s}-run_meta.json`):y(i,"run_meta.json"));return{...Rt({runMetaPaths:r,authoredBlobPath:this.config.replayOnlyPassthrough?.authoredExecutionPath??this.config.authoredExecutionPath,instructions:t})}}buildExecutionEnvelope(t){let n=this.config.runStatuses.every(u=>u==="passed")?"success":"error",r=this.config.variableIds??{},o=[];if(this.config.variables)for(let[u,l]of Object.entries(this.config.variables)){if(l.secret||Z(l))continue;let _=u.startsWith("global.")?u.slice(7):u;o.push({id:r[_]??0,name:_,value:l.value,session_value:l.value,is_persist:!1,environment_id:0,environment_name:"No Env"})}let i=[],s=u=>{let l=i.find(_=>_.name===u.name);l?l.value=u.value:i.push(u)},a=[],c=new Set;for(let u of this.collectNdjsonPerRun())for(let l of u.records)if(l.output_variable&&l.output_value!=null&&s({name:l.output_variable,value:String(l.output_value),value_type:"test_level",variable_description:"ANALYZE result"}),l.action_type==="upload_files"){let _=N(l.action_params);if(_){let p=_.media_id||_.media_url;if(!c.has(p)){c.add(p),a.push({media_url:_.media_url,media_id:_.media_id,name:_.name,type:_.type,..._.alias?{alias:_.alias}:{}});let d=O(_.name);_.alias?s({name:M(_.alias),type:"file",value:d,value_type:"string",scope:_.alias.startsWith("local.")?"local":"global",media_id:_.media_id}):s({name:ut(_.name),value:d,value_type:"string",variable_description:`variable for ${d}`})}}}return{test_id:this.testId,version:"v4",auto_heal_version:this.config.apMode==="v2"?"AH2":"",session_id:this.config.sessionId,org_id:String(this.config.orgId),user_id:String(this.config.userId),url:this.config.firstUrl??"",start_timestamp:this.config.startedAt,end_timestamp:this.config.endedAt,status:n,commit_id:this.config.commitId,instructions:t,modules:[],uploaded_files:a,test_params:this.config.testParams??[],test_level_variables:JSON.stringify(i),test_global_variables:o,max_network_wait:0,wait_buffer:0,network_throttle:{},secrets:this.config.secrets??[],totp:[],environment_id:this.config.environmentId??0,environment:"",mobile_browser:!1,native_popups:[],smartui:this.smartuiProject(t),module_index:0}}};export{Ee as a,Ie as b,Ae as c,xt as d};
@@ -0,0 +1,27 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as B}from"./chunk-4HARMERK.js";import{a as N}from"./chunk-A474TUCE.js";import{a as ie,b as ae,c as ce}from"./chunk-W3USRQX6.js";import{b as oe}from"./chunk-NVD2MXHQ.js";import{a as H}from"./chunk-6YBH3WUW.js";import{d as le}from"./chunk-FYPIF3BE.js";import{a as $,b as X,e as M,g as se}from"./chunk-77ZZQJLX.js";import{b as L}from"./chunk-BHQIH2FE.js";import{a as te}from"./chunk-73HMW2WA.js";import{a as ee}from"./chunk-FCD3NYOM.js";import{a as re,b as ne}from"./chunk-B7ZX5HEN.js";import{a as j}from"./chunk-PVN64537.js";import{a as K}from"./chunk-FI2DVNRT.js";import{a as A}from"./chunk-RZ4F3BHX.js";import{a as O}from"./chunk-K75WIRI5.js";import{a as F}from"./chunk-HCBYKLMW.js";import{a as b,b as p,i as Z}from"./chunk-33DWJV67.js";import{a as q}from"./chunk-6YGTRKDT.js";import{z as y}from"./chunk-FAMQ4DHU.js";import{e as S}from"./chunk-UR6MHSHU.js";var D=S(q(),1);import{existsSync as P,readFileSync as Ye,rmSync as we,unlinkSync as ze}from"fs";import{resolve as Q}from"path";import{promises as ue,realpathSync as Re}from"fs";import{homedir as Pe}from"os";import{join as V,parse as Me,relative as de,resolve as fe}from"path";var me=new Set(["node_modules",".git","dist","build",".next",".venv","venv","target","__pycache__"]),R=class extends Error{constructor(s){super(`refusing to scan '${s}'. Run from your project root, or pass --root <dir>.`);this.cwd=s;this.name="HomeRefusedError"}};function ge(e){try{return Re(fe(e))}catch{return fe(e)}}function De(e){let r=ge(e),s=ge(Pe()),n=Me(r).root;if(process.platform==="win32"){let o=t=>t.toLowerCase();return o(r)===o(s)||o(r)===o(n)}return r===s||r===n}async function U(e){if(De(e.root))throw new R(e.root);let r=e.maxEntries??5e4,s=e.maxResults??5e3,n=new Set(e.ignore??[]),o=[],t=0,i=0,a=!1,u,c=[e.root];for(;c.length>0&&!a;){let l=c.shift(),g;try{g=await ue.readdir(l,{withFileTypes:!0})}catch{continue}i++;for(let _ of g){if(t++,t>r){a=!0,u="max_entries";break}let m=_.name,T=V(l,m);if(_.isDirectory()){if(me.has(m)||m.startsWith(".")||m.startsWith("output-")||n.has(m))continue;c.push(T)}else if(_.isFile()&&m.endsWith("_test.md")&&(o.push({path:T,relPath:de(e.root,T),source:"cwd"}),o.length>=s)){a=!0,u="max_results";break}}e.onProgress?.(i,o.length)}if(!a){let g=[{dir:V(e.root,".testmuai","tests"),depth:0}];for(;g.length>0&&!a;){let{dir:_,depth:m}=g.shift(),T;try{T=await ue.readdir(_,{withFileTypes:!0})}catch{continue}i++;for(let d of T){if(t++,t>r){a=!0,u="max_entries";break}let k=d.name,w=V(_,k);if(d.isDirectory()){if(m>=20||k.startsWith(".")||k.startsWith("output-")||me.has(k))continue;g.push({dir:w,depth:m+1})}else if(d.isFile()&&k.endsWith("_test.md")&&(o.push({path:w,relPath:de(e.root,w),source:"tests-dir"}),o.length>=s)){a=!0,u="max_results";break}}}}return{results:o,aborted:a,abortReason:u,dirsScanned:i}}import{readFileSync as Ce}from"fs";function Y(e){let r;try{r=Ce(e,"utf8")}catch{return{tags:[]}}try{let{global:s}=re(e,r),n=ne(s);return{tags:s.tags??[],...n?{mobileTarget:n}:{}}}catch{let s=$e(r);return{tags:[],...s?{mobileTarget:s}:{}}}}var pe={platform:"",app:""};function $e(e){let r=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);if(!r)return;let s=r[1].split(/\r?\n/);for(let o of s){let t=/^target:\s*['"]?(emulator|simulator|android|ios)['"]?\s*$/.exec(o);if(t)return t[1]==="android"||t[1]==="ios"?{platform:t[1],app:"",realDevice:!0}:pe}let n=s.findIndex(o=>/^target:\s*$/.test(o));if(!(n<0))return s.slice(n+1).some(o=>/^\s+\S/.test(o))?pe:void 0}function W(e){return Y(e).tags}import{mkdirSync as Ie,writeFileSync as Fe}from"fs";import{join as Oe}from"path";function he(e,r){return`Basic ${Buffer.from(`${e}:${r}`).toString("base64")}`}async function Ae(e){let r=ae({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId,codeExport:{enabled:!0,language:e.language,skipValidation:e.skipValidation},mobile:e.framework==="appium"}),s=await A(r.url,{method:"POST",headers:{"content-type":"application/json",authorization:he(e.auth.username,e.auth.access_key)},body:JSON.stringify(r.body)});if(!s.ok)throw new Error(`code-export trigger failed: ${s.status} ${await s.text()}`);e.log("info","CODE_EXPORT_TRIGGERED","Code export triggered",{testcase_id:e.testcaseId})}async function Le(e){let r=ce({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId}),s=e.pollIntervalMs??5e3,n=e.timeoutMs??3e5,o=Date.now()+n;for(;Date.now()<o;){let t=await A(r,{headers:{authorization:he(e.auth.username,e.auth.access_key),accept:"application/json"}});if(!t.ok){await new Promise(c=>setTimeout(c,s));continue}let a=(await t.json()).data?.find(c=>c.code_name==="kane-cli-trigger");if(!a){await new Promise(c=>setTimeout(c,s));continue}let u=(a.status??"").toLowerCase();if(u==="in progress"||u==="in_progress"||u==="pending"){await new Promise(c=>setTimeout(c,s));continue}if(!a.url||a.url.length===0)throw new Error(`code-export status=${a.status} but no files returned`);Ie(e.outDir,{recursive:!0});for(let c of a.url){let l=Oe(e.outDir,c.file_name),g=await A(c.file_url);if(!g.ok){e.log("warn","CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:c.file_name,status:g.status});continue}let _=await g.text();Fe(l,_,"utf-8")}return e.log("info","CODE_EXPORT_DOWNLOADED","Code export saved",{out_dir:e.outDir,file_count:a.url.length}),e.outDir}throw new Error("code-export polling timed out")}async function _e(e){return await Ae(e),await Le(e)}var E=S(q(),1);import{existsSync as je,readFileSync as Be}from"fs";var h=S(F(),1);function Ne(e){B(e);let r=M(e);if(!je(r))return null;try{return JSON.parse(Be(r,"utf8"))}catch{return{}}}function Ue(e){return e===null?"never_run":e.testcase_id?"synced":"local_only"}function We(e){return e==="synced"?"\u2601":e==="local_only"?"\u25A3":"\u25CB"}function Je(e){return e==="tests-dir"?"\u2726":" "}function Ge(e,r){return r==="all"?!0:r==="synced"?e.status==="synced":r==="local"?e.status==="local_only":r==="never_run"?e.status==="never_run":r==="cli"?e.source==="tests-dir":r==="hand"?e.source==="cwd":!0}var z=["all","synced","local","never_run","cli","hand"];function qe(e){let r=z.indexOf(e);return z[(r+1)%z.length]}function ye({root:e,currentOrgId:r,onSelect:s,onCancel:n}){let[o,t]=(0,E.useState)([]),[i,a]=(0,E.useState)(null),[u,c]=(0,E.useState)(!0),[l,g]=(0,E.useState)("all");(0,E.useEffect)(()=>{(async()=>{try{let d=await U({root:e}),k=[];for(let w of d.results){let G=Ne(w.path);G?.org_id!==void 0&&G.org_id!==r||k.push({path:w.path,relPath:w.relPath,name:$(w.path),status:Ue(G),source:w.source,tags:W(w.path)})}t(k),c(!1)}catch(d){d instanceof R,a(d.message),c(!1)}})()},[e,r]);let _=(0,E.useMemo)(()=>o.filter(d=>Ge(d,l)).map(d=>({id:d.path,label:`${We(d.status)} ${Je(d.source)} ${d.relPath}${d.tags.length>0?` [${d.tags.join(", ")}]`:""}`})),[o,l]),m=(0,E.useMemo)(()=>Xe(l,o),[l,o]);if(i)return(0,h.jsxs)(b,{flexDirection:"column",borderStyle:"round",borderColor:y.red,paddingX:2,paddingY:1,children:[(0,h.jsx)(p,{color:y.red,bold:!0,children:"testmd"}),(0,h.jsx)(b,{marginTop:1,children:(0,h.jsx)(p,{color:y.red,children:i})})]});let T=l==="all"?"all":Ke(l);return(0,h.jsx)(te,{title:`testmd \xB7 filter: ${T}`,items:_,loading:u,itemNoun:"tests",onSelect:d=>{let k=o.find(w=>w.path===d.id);k&&s(k)},onCancel:n,onTab:()=>g(d=>qe(d)),extraHint:"cycle filter",footer:m})}function Ke(e){return e==="synced"?"synced (\u2601)":e==="local"?"local (\u25A3)":e==="never_run"?"never run (\u25CB)":e==="cli"?"cli-generated (\u2726)":e==="hand"?"hand-written":"all"}function Xe(e,r){let s={synced:r.filter(o=>o.status==="synced").length,local:r.filter(o=>o.status==="local_only").length,never:r.filter(o=>o.status==="never_run").length,cli:r.filter(o=>o.source==="tests-dir").length,hand:r.filter(o=>o.source==="cwd").length},n=o=>o?y.orange:y.dim;return(0,h.jsxs)(b,{flexDirection:"column",children:[(0,h.jsx)(p,{color:y.dim,children:"legend:"}),(0,h.jsxs)(b,{children:[(0,h.jsx)(p,{color:n(e==="synced"),children:` \u2601 synced (${s.synced}) `}),(0,h.jsx)(p,{color:n(e==="local"),children:`\u25A3 local (${s.local}) `}),(0,h.jsx)(p,{color:n(e==="never_run"),children:`\u25CB never run (${s.never})`})]}),(0,h.jsxs)(b,{children:[(0,h.jsx)(p,{color:n(e==="cli"),children:` \u2726 cli-generated (${s.cli}) `}),(0,h.jsx)(p,{color:n(e==="hand"),children:` hand-written (${s.hand})`})]})]})}var I=S(q(),1);import{existsSync as He,readFileSync as Ve}from"fs";var f=S(F(),1);function xe({path:e,relPath:r,onAction:s,onBack:n,onView:o}){let[t,i]=(0,I.useState)(null),[a,u]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let l=M(e);if(He(l))try{i(JSON.parse(Ve(l,"utf8")))}catch{i(null)}},[e]),Z((l,g)=>{if(g.escape){if(a){u(!1);return}n();return}if(a){l==="y"||l==="Y"?(u(!1),s("delete")):(l==="n"||l==="N")&&u(!1);return}l==="r"&&s("run"),l==="e"&&t?.testcase_id&&s("export"),l==="d"&&u(!0),l==="v"&&o&&o()});let c=({k:l,v:g})=>g?(0,f.jsxs)(p,{children:[(0,f.jsx)(p,{color:y.dim,children:l.padEnd(14)}),g]}):null;return(0,f.jsxs)(b,{flexDirection:"column",borderStyle:"round",borderColor:y.orange,paddingX:2,paddingY:1,children:[(0,f.jsx)(p,{color:y.orange,bold:!0,children:r}),(0,f.jsx)(b,{marginTop:1,flexDirection:"column",children:t?(0,f.jsxs)(f.Fragment,{children:[(0,f.jsx)(c,{k:"test_id",v:t.test_id}),(0,f.jsx)(c,{k:"testcase_id",v:t.testcase_id}),(0,f.jsx)(c,{k:"project_id",v:t.project_id}),(0,f.jsx)(c,{k:"folder_id",v:t.folder_id}),(0,f.jsx)(c,{k:"org_id",v:t.org_id}),(0,f.jsx)(c,{k:"session_name",v:t.session_name}),(0,f.jsx)(c,{k:"commit_id",v:t.commit_id})]}):(0,f.jsx)(p,{color:y.dim,children:"(never run \u2014 no meta.json)"})}),a?(0,f.jsx)(b,{marginTop:1,children:(0,f.jsxs)(p,{color:y.red,bold:!0,children:["Delete ",r," and its output dir? [y/n]"]})}):(0,f.jsx)(b,{marginTop:1,children:(0,f.jsxs)(p,{color:y.dim,children:["[r] run [e] export",t?.testcase_id?"":" (need testcase_id)"," [d] delete",o?" [v] view":""," [Esc] back"]})})]})}function C(e){B(e);let r=M(e);if(!P(r))return null;try{return JSON.parse(Ye(r,"utf8"))}catch{return null}}function ke(e,r){return!e||e.org_id===void 0?!0:e.org_id===r}function J(e,r){return ke(e,r)?null:(process.stderr.write(`error: this test belongs to org ${e.org_id}; you are logged in as org ${r}.
3
+ Switch profiles with \`kane-cli profiles switch\` to act on it.
4
+ `),2)}function be(){return oe(process.cwd()).kind==="remote"?{authOnly:!0}:{}}async function zt(e={}){let r=!!process.stdin.isTTY&&!e.json,s=new O,n=new L;await H({isInteractive:r,creds:s,config:n,...be()});let o=s.getDefaultEnv()??"prod";try{let t=await N({creds:s,env:o,log:()=>{}});return t.resolvedCreds?.org_id===void 0?(process.stderr.write("error: TMS did not return an org_id. Run `kane-cli login` again.\n"),{ok:!1,code:2}):{ok:!0,orgId:String(t.resolvedCreds.org_id)}}catch(t){if(t instanceof j)return process.stderr.write("error: not authenticated. Run `kane-cli login` first.\n"),{ok:!1,code:2};throw t}}async function Qt(e,r){if(process.stdin.isTTY&&!e.json)return await et(r,e.root);let s=e.root??process.cwd(),n;try{n=await U({root:s,ignore:e.ignore})}catch(o){if(o instanceof R)return process.stderr.write(`error: ${o.message}
5
+ `),2;throw o}for(let o of n.results){let t=C(o.path);if(!ke(t,r))continue;let i={path:o.relPath.startsWith(".")?o.relPath:`./${o.relPath}`,name:$(o.path),has_meta:t!==null,source:o.source,synced:!!t?.testcase_id,tags:W(o.path)};t&&(t.test_id&&(i.test_id=t.test_id),t.testcase_id&&(i.testcase_id=t.testcase_id),t.org_id&&(i.org_id=t.org_id),t.project_id&&(i.project_id=t.project_id),t.folder_id&&(i.folder_id=t.folder_id)),process.stdout.write(JSON.stringify(i)+`
6
+ `)}return n.aborted&&process.stderr.write(`warn: walk aborted (${n.abortReason}). Pass --root or --ignore to narrow.
7
+ `),0}var Te=-1001,Ee=-1002,ve=-1003,x={action:null,path:null};function Qe(e,r){return x.action=e,x.path=r,e==="run"?Te:e==="export"?Ee:ve}function Ze({root:e,currentOrgId:r,onComplete:s}){let[n,o]=D.default.useState({kind:"list"});return D.default.useEffect(()=>{n.kind==="exiting"&&s(n.code)},[n,s]),n.kind==="list"?D.default.createElement(ye,{root:e,currentOrgId:r,onSelect:t=>o({kind:"inspect",path:t.path,relPath:t.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?D.default.createElement(xe,{path:n.path,relPath:n.relPath,onAction:async t=>{o({kind:"exiting",code:Qe(t,n.path)})},onBack:()=>o({kind:"list"})}):null}async function et(e,r){let s=r??process.cwd(),{render:n}=await import("./build-5ZN47FAT.js"),o=await new Promise(t=>{let{unmount:i,waitUntilExit:a}=n(D.default.createElement(Ze,{root:s,currentOrgId:e,onComplete:u=>{i(),t(u)}}),{stdout:process.stderr,exitOnCtrlC:!0});a().then(()=>t(0)).catch(()=>t(0))});if(o===Te&&x.path){let{runTestMdFile:t}=await import("./run-test-md-G6U3RU2Q.js"),i=await t(x.path,{});return x.action=null,x.path=null,i}if(o===Ee&&x.path){let t=await rt(x.path,{},e);return x.action=null,x.path=null,t}if(o===ve&&x.path){let t=await tt(x.path,!0,e);return x.action=null,x.path=null,t}return o}async function Zt(e,r){let s=Q(e);if(!P(s))return process.stderr.write(`error: file not found: ${s}
8
+ `),2;let n=C(s),o=J(n,r);if(o!==null)return o;let t={path:s,name:$(s),has_meta:n!==null};return n&&(n.commit_id&&(t.commit_id=n.commit_id),n.test_id&&(t.test_id=n.test_id),n.testcase_id&&(t.testcase_id=n.testcase_id),n.project_id&&(t.project_id=n.project_id),n.folder_id&&(t.folder_id=n.folder_id),n.org_id&&(t.org_id=n.org_id),n.session_name&&(t.session_name=n.session_name)),process.stdout.write(JSON.stringify(t)+`
9
+ `),0}async function tt(e,r,s){let n=Q(e);if(!P(n))return process.stderr.write(`error: file not found: ${n}
10
+ `),2;let o=C(n),t=J(o,s);if(t!==null)return t;if(!r)return process.stderr.write(`error: refusing to delete without --yes.
11
+ This will remove '${n}' and '${X(n)}/'.
12
+ `),2;let i=X(n);if(P(i))try{we(i,{recursive:!0,force:!0})}catch(a){return process.stderr.write(`error: failed to remove ${i}: ${a.message}
13
+ `),2}try{ze(n)}catch(a){return process.stderr.write(`error: failed to remove ${n}: ${a.message}
14
+ `),2}return process.stderr.write(`removed ${n} and ${i}/
15
+ `),0}var v=class extends Error{kind;constructor(r,s){super(s),this.name="ExportError",this.kind=r}};async function er(e,r){let{codeDir:s}=await Se(e,r);return{codeDir:s}}async function Se(e,r){let s=C(e);if(!s?.testcase_id)throw new v("not-synced","this test has not been synced to TMS \u2014 run `kane-cli testmd run` first.");let n=new L().load(),o=Y(e).mobileTarget!==void 0;if(o&&r.language?.toLowerCase()==="javascript")throw new v("js-on-mobile","--language javascript is not supported on a mobile target \u2014 mobile code export is Appium + Python only. Drop the flag, or pass --language python.");let t=r.language??n.code_export?.language;if(!o&&!t)throw new v("no-language","--language not provided and no default in tui-config.");let{framework:i,language:a}=ie(t??"python",o),u=r.output??se(e,i,a),c=P(u);if(c&&!r.force){let m=!1;try{let{readdirSync:T}=await import("fs");m=T(u).length>0}catch{}if(m)return{kind:"reused",codeDir:u}}c&&r.force&&we(u,{recursive:!0,force:!0});let l=new O,g=r.env??l.getDefaultEnv()??"prod",_;try{_=await N({creds:l,env:g,log:()=>{}})}catch(m){throw m instanceof j?new v("auth-fail","not authenticated. Run `kane-cli login` first."):m}if(!_.basicAuth)throw new v("auth-incomplete","TMS basic auth could not be resolved. Run `kane-cli login` again.");try{let m=K(g);await _e({tmsBaseUrl:m.tmsBaseUrl,testcaseId:s.testcase_id,auth:_.basicAuth,language:a,framework:i,skipValidation:n.code_export?.skip_validation??!0,outDir:u,log:()=>{}})}catch(m){throw new v("export-fail",`code export failed: ${m.message}`)}return{kind:"exported",codeDir:u}}async function rt(e,r,s){let n=Q(e);if(!P(n))return process.stderr.write(`error: file not found: ${n}
16
+ `),2;let o=C(n),t=J(o,s);if(t!==null)return t;try{let i=await Se(n,r);return i.kind==="reused"?process.stderr.write(`reusing existing export at ${i.codeDir}
17
+ `):process.stderr.write(`exported to ${i.codeDir}
18
+ `),0}catch(i){if(i instanceof v)return i.kind==="not-synced"?(process.stderr.write("error: this test has not been synced to TMS \u2014 run `kane-cli testmd run` first.\n"),2):i.kind==="no-language"?(process.stderr.write(`error: --language not provided and no default in tui-config.
19
+ `),2):i.kind==="js-on-mobile"?(process.stderr.write(`error: ${i.message}
20
+ `),2):i.kind==="auth-fail"?(process.stderr.write("error: not authenticated. Run `kane-cli login` first.\n"),2):i.kind==="auth-incomplete"?(process.stderr.write("error: TMS basic auth could not be resolved. Run `kane-cli login` again.\n"),2):(process.stderr.write(`error: ${i.message}
21
+ `),2);throw i}}async function tr(e={}){let r=!!process.stdin.isTTY,s=new O,n=new L;await H({isInteractive:r,creds:s,config:n,...be()});let o=e.env??s.getDefaultEnv()??"prod";try{let t=await N({creds:s,env:o,usernameFlag:e.username,accessKeyFlag:e.accessKey,log:()=>{}});return t.resolvedCreds?.org_id===void 0||!t.basicAuth?(process.stderr.write("error: could not resolve TMS credentials. Run `kane-cli login` again.\n"),{ok:!1,code:2}):{ok:!0,orgId:String(t.resolvedCreds.org_id),basicAuth:t.basicAuth,controllerBaseUrl:K(o).controllerBaseUrl}}catch(t){if(t instanceof j)return process.stderr.write("error: not authenticated. Run `kane-cli login` first.\n"),{ok:!1,code:2};throw t}}async function rr(e,r,s=le){if(!P(e))return process.stderr.write(`error: file not found: ${e}
22
+ `),2;if(!e.endsWith("_test.md"))return process.stderr.write(`error: not a *_test.md file: ${e}
23
+ `),2;let n=C(e),o=J(n,r.orgId);if(o!==null)return o;if(!n?.commit_id||!n?.test_id)return process.stderr.write(`error: ${e} is not authored \u2014 run \`kane-cli testmd run ${e}\` first.
24
+ `),2;let t=await s({sourcePath:e,testId:n.test_id,sessionId:n.commit_id,commitId:n.commit_id,controller:new ee(r.controllerBaseUrl,{username:r.basicAuth.username,accessKey:r.basicAuth.access_key})}),i={type:"test_md_bundle_sync",status:t.ok?"ok":"failed",commit_id:n.commit_id,...t.ok?{bytes:t.bytes}:{stage:t.stage}};return process.stdout.write(JSON.stringify(i)+`
25
+ `),t.ok?(process.stderr.write(`synced: ${n.commit_id}-testmd.zip (${t.bytes} bytes)
26
+ `),0):(process.stderr.write(`error: bundle sync failed at ${t.stage}: ${t.error}
27
+ `),t.stage==="collect"?2:1)}export{U as a,Y as b,ye as c,xe as d,C as e,ke as f,J as g,zt as h,Qt as i,et as j,Zt as k,tt as l,v as m,er as n,rt as o,tr as p,rr as q};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{c as k}from"./chunk-RFHMDQXZ.js";import{a as b}from"./chunk-LUR7JFPP.js";import{a as C}from"./chunk-HJMCXSUJ.js";import{q as m,r as u,s as f,t as x,u as y}from"./chunk-D36V5OX6.js";import{createServer as S}from"http";import{randomBytes as A}from"crypto";import{URL as L}from"url";var P=class{profile;environment;creds;oauth;constructor(r="default",o="prod",e){this.profile=r,this.environment=o,this.creds=e??new C,this.oauth=new b(o)}async login(){let{server:r,port:o}=await this.startCallbackServer(),e=y(o);try{let t=this.creds.loadClient(this.profile,this.environment),i=t?.redirect_uris;(!t||!i?.includes(e))&&(t=await this.oauth.registerClient(e),this.creds.saveClient(this.profile,this.environment,t));let c=t.client_id,[h,d]=b.generatePkce(),a=A(32).toString("hex"),n=this.oauth.buildAuthorizationUrl(c,d,a,e),l=await this.waitForCallback(r,o,n,a);if(!l)throw new Error("Login cancelled or timed out");let p=await this.oauth.exchangeCode(l,c,h,e),g={access_token:p.access_token,refresh_token:p.refresh_token,expires_at:Math.floor(Date.now()/1e3)+p.expires_in,scope:p.scope??"*"};return this.creds.saveCredentials(this.profile,this.environment,g),this.creds.setActiveProfile(this.profile),g}catch(t){throw r.close(),t}}startCallbackServer(){return new Promise((r,o)=>{let e=u,t=()=>{let i=S();i.on("error",c=>{c.code==="EADDRINUSE"&&e<f?(e++,t()):o(new Error(`Failed to start callback server: ${c.message}. Ports ${u}-${f} are all in use.`))}),i.listen(e,m,()=>{r({server:i,port:e})})};t()})}waitForCallback(r,o,e,t){return new Promise(i=>{let c=!1,h=setTimeout(()=>d(null),12e4),d=a=>{c||(c=!0,clearTimeout(h),r.close(),i(a))};r.on("request",(a,n)=>{let l=new L(a.url??"/",`http://${m}:${o}`);if(l.pathname!==x){n.writeHead(404),n.end();return}let p=l.searchParams.get("state"),g=l.searchParams.get("code");if(l.searchParams.get("error")){n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Login failed",message:"We couldn't complete the sign-in. You can close this tab and try again from your terminal."})),d(null);return}if(p!==t){n.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Invalid state",message:"The sign-in response didn't match this session. Please return to your terminal and try again."})),d(null);return}n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"success",title:"You're signed in",message:"Head back to your terminal \u2014 KaneAI is ready when you are.",autoClose:!0})),d(g)}),k(e).catch(a=>{let n=a instanceof Error?a.message:String(a);process.stderr.write(`[auth] Could not open browser: ${n}
2
+ import{c as k}from"./chunk-RFHMDQXZ.js";import{a as b}from"./chunk-2GEAKFAV.js";import{a as C}from"./chunk-K75WIRI5.js";import{r as m,s as u,t as f,u as x,v as y}from"./chunk-FAMQ4DHU.js";import{createServer as S}from"http";import{randomBytes as A}from"crypto";import{URL as L}from"url";var P=class{profile;environment;creds;oauth;constructor(r="default",o="prod",e){this.profile=r,this.environment=o,this.creds=e??new C,this.oauth=new b(o)}async login(){let{server:r,port:o}=await this.startCallbackServer(),e=y(o);try{let t=this.creds.loadClient(this.profile,this.environment),i=t?.redirect_uris;(!t||!i?.includes(e))&&(t=await this.oauth.registerClient(e),this.creds.saveClient(this.profile,this.environment,t));let c=t.client_id,[h,d]=b.generatePkce(),a=A(32).toString("hex"),n=this.oauth.buildAuthorizationUrl(c,d,a,e),l=await this.waitForCallback(r,o,n,a);if(!l)throw new Error("Login cancelled or timed out");let p=await this.oauth.exchangeCode(l,c,h,e),g={access_token:p.access_token,refresh_token:p.refresh_token,expires_at:Math.floor(Date.now()/1e3)+p.expires_in,scope:p.scope??"*"};return this.creds.saveCredentials(this.profile,this.environment,g),this.creds.setActiveProfile(this.profile),g}catch(t){throw r.close(),t}}startCallbackServer(){return new Promise((r,o)=>{let e=u,t=()=>{let i=S();i.on("error",c=>{c.code==="EADDRINUSE"&&e<f?(e++,t()):o(new Error(`Failed to start callback server: ${c.message}. Ports ${u}-${f} are all in use.`))}),i.listen(e,m,()=>{r({server:i,port:e})})};t()})}waitForCallback(r,o,e,t){return new Promise(i=>{let c=!1,h=setTimeout(()=>d(null),12e4),d=a=>{c||(c=!0,clearTimeout(h),r.close(),i(a))};r.on("request",(a,n)=>{let l=new L(a.url??"/",`http://${m}:${o}`);if(l.pathname!==x){n.writeHead(404),n.end();return}let p=l.searchParams.get("state"),g=l.searchParams.get("code");if(l.searchParams.get("error")){n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Login failed",message:"We couldn't complete the sign-in. You can close this tab and try again from your terminal."})),d(null);return}if(p!==t){n.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Invalid state",message:"The sign-in response didn't match this session. Please return to your terminal and try again."})),d(null);return}n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"success",title:"You're signed in",message:"Head back to your terminal \u2014 KaneAI is ready when you are.",autoClose:!0})),d(g)}),k(e).catch(a=>{let n=a instanceof Error?a.message:String(a);process.stderr.write(`[auth] Could not open browser: ${n}
3
3
  Please open this URL manually: ${e}
4
4
  `)})})}};function v(s){let r=s.state==="success",o=r?"#22c55e":"#ef4444",e=r?"rgba(34, 197, 94, 0.12)":"rgba(239, 68, 68, 0.12)",t=r?'<svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7"/></svg>':'<svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg>',i=s.autoClose?"<script>setTimeout(function(){try{window.close();}catch(e){}}, 1500);</script>":"";return`<!doctype html>
5
5
  <html lang="en">
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{e as L}from"./chunk-457Y5TEC.js";async function T(n,i,c){let[h,d,l,m,a]=await Promise.all([c.includes("source")?n.sources(i):Promise.resolve([]),c.includes("usecase")?n.nodes(i,"usecase"):Promise.resolve([]),c.includes("usecase")?n.stale(i):Promise.resolve([]),c.includes("scenario")?n.nodes(i,"scenario"):Promise.resolve([]),c.includes("test")?n.nodes(i,"test"):Promise.resolve([])]),o=new Set;for(let e of l.filter(s=>s.label==="scenario"&&(s.freshness==="stale"||s.freshness==="orphaned"))){let s=await n.mainNode(i,e.cid);for(let t of s.edgesOut)t.type==="belongs_to"&&t.other?.name&&(t.other.freshness==="superseded"||t.other.supersededBy)&&o.add(t.other.name)}let r=h.filter(e=>e.head!==null).map(e=>{let s=L(e.origin);return{id:e.sourceId,label:"source",title:e.sourceId,trust:"-",fresh:"fresh",upToDate:"yes",...s?{shown:s}:{}}}),R=d.map(e=>{let s=e.name??"-";if(e.trust==="archived")return{id:s,label:"usecase",title:e.title??"",trust:e.trust,fresh:"-",upToDate:"archived"};let t=e.name!==null&&o.has(e.name),u=e.freshness??"fresh",f=u==="stale"?"source_changed":u==="orphaned"?"source_removed":t?"tests_out_of_date":"yes";return{id:s,label:"usecase",title:e.title??"",trust:e.trust,fresh:u,...t?{testsFresh:"stale"}:{},upToDate:f}}),g=(e,s)=>e.map(t=>{let u=t.name??"-",f=t.title??"";if(t.trust==="archived")return{id:u,label:s,title:f,trust:t.trust,fresh:"-",upToDate:"archived"};let w=t.freshness??"fresh",b=w==="stale"?"designed_from_changed":w==="orphaned"?"source_removed":"yes";return{id:u,label:s,title:f,trust:t.trust,fresh:w,upToDate:b}}),y=g(m,"scenario"),_=g(a,"test"),v=e=>Number(/^[a-z]+-(\d+)$/i.exec(e.id)?.[1]??Number.MAX_SAFE_INTEGER),p=(e,s)=>v(e)-v(s)||e.title.localeCompare(s.title);return r.sort((e,s)=>e.id.localeCompare(s.id)),R.sort(p),y.sort(p),_.sort(p),[...r,...R,...y,..._]}async function P(n,i){let c=(await n.nodes(i,"test")).filter(a=>a.trust!=="archived"),h=new Set((await n.nodes(i,"scenario")).filter(a=>a.trust==="archived").map(a=>a.cid)),d=new Set;for(let a of c){let o=await n.mainNode(i,a.cid);for(let r of o.edgesOut)r.type==="automates"&&r.other!==null&&d.add(r.other.cid)}let l=new Set,m=new Set;for(let a of d){let o=await n.mainNode(i,a);for(let r=0;o.supersededBy!==null&&o.supersededBy!==""&&r<64;r++)o=await n.mainNode(i,o.supersededBy);if(!(o.supersededBy===""||m.has(o.cid))&&(m.add(o.cid),!h.has(o.cid)))for(let r of o.edgesOut)r.type==="belongs_to"&&r.other?.name&&l.add(r.other.name)}return l}export{T as a,P as b};
2
+ import{e as L}from"./chunk-3YIA3DSL.js";async function T(n,i,c){let[h,d,l,m,a]=await Promise.all([c.includes("source")?n.sources(i):Promise.resolve([]),c.includes("usecase")?n.nodes(i,"usecase"):Promise.resolve([]),c.includes("usecase")?n.stale(i):Promise.resolve([]),c.includes("scenario")?n.nodes(i,"scenario"):Promise.resolve([]),c.includes("test")?n.nodes(i,"test"):Promise.resolve([])]),o=new Set;for(let e of l.filter(s=>s.label==="scenario"&&(s.freshness==="stale"||s.freshness==="orphaned"))){let s=await n.mainNode(i,e.cid);for(let t of s.edgesOut)t.type==="belongs_to"&&t.other?.name&&(t.other.freshness==="superseded"||t.other.supersededBy)&&o.add(t.other.name)}let r=h.filter(e=>e.head!==null).map(e=>{let s=L(e.origin);return{id:e.sourceId,label:"source",title:e.sourceId,trust:"-",fresh:"fresh",upToDate:"yes",...s?{shown:s}:{}}}),R=d.map(e=>{let s=e.name??"-";if(e.trust==="archived")return{id:s,label:"usecase",title:e.title??"",trust:e.trust,fresh:"-",upToDate:"archived"};let t=e.name!==null&&o.has(e.name),u=e.freshness??"fresh",f=u==="stale"?"source_changed":u==="orphaned"?"source_removed":t?"tests_out_of_date":"yes";return{id:s,label:"usecase",title:e.title??"",trust:e.trust,fresh:u,...t?{testsFresh:"stale"}:{},upToDate:f}}),g=(e,s)=>e.map(t=>{let u=t.name??"-",f=t.title??"";if(t.trust==="archived")return{id:u,label:s,title:f,trust:t.trust,fresh:"-",upToDate:"archived"};let w=t.freshness??"fresh",b=w==="stale"?"designed_from_changed":w==="orphaned"?"source_removed":"yes";return{id:u,label:s,title:f,trust:t.trust,fresh:w,upToDate:b}}),y=g(m,"scenario"),_=g(a,"test"),v=e=>Number(/^[a-z]+-(\d+)$/i.exec(e.id)?.[1]??Number.MAX_SAFE_INTEGER),p=(e,s)=>v(e)-v(s)||e.title.localeCompare(s.title);return r.sort((e,s)=>e.id.localeCompare(s.id)),R.sort(p),y.sort(p),_.sort(p),[...r,...R,...y,..._]}async function P(n,i){let c=(await n.nodes(i,"test")).filter(a=>a.trust!=="archived"),h=new Set((await n.nodes(i,"scenario")).filter(a=>a.trust==="archived").map(a=>a.cid)),d=new Set;for(let a of c){let o=await n.mainNode(i,a.cid);for(let r of o.edgesOut)r.type==="automates"&&r.other!==null&&d.add(r.other.cid)}let l=new Set,m=new Set;for(let a of d){let o=await n.mainNode(i,a);for(let r=0;o.supersededBy!==null&&o.supersededBy!==""&&r<64;r++)o=await n.mainNode(i,o.supersededBy);if(!(o.supersededBy===""||m.has(o.cid))&&(m.add(o.cid),!h.has(o.cid)))for(let r of o.edgesOut)r.type==="belongs_to"&&r.other?.name&&l.add(r.other.name)}return l}export{T as a,P as b};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as B,c as S,d as T}from"./chunk-YQ5C6UDG.js";import{c as g}from"./chunk-RFHMDQXZ.js";import{a as E}from"./chunk-3OQW2GTA.js";import{a as h}from"./chunk-HCBYKLMW.js";import{a as i,b as c,c as w,i as x}from"./chunk-33DWJV67.js";import{a as L}from"./chunk-6YGTRKDT.js";import{y as n}from"./chunk-D36V5OX6.js";import{e as u}from"./chunk-UR6MHSHU.js";var l=u(L(),1);var r=u(h(),1);function y(e){return new Map(e.map((o,s)=>[`${s}-${o.label}`,o.packPath]))}async function H(e){let o=e.deps?.viewerBase??S(e.env),s=e.deps?.startServer??B,a=e.deps?.openUrl??(m=>g(m).then(()=>{})),t=y(e.rows),d;try{d=await s({packs:t,allowedOrigins:[new URL(o).origin]});let m=d,D=async p=>{let v=[...t.keys()][p];await a(T(m.urlFor(v),o))};if(e.deps?.hold){await e.deps.hold();return}await new Promise(p=>{let v=w(l.default.createElement(P,{rows:e.rows,onOpen:D,onDone:()=>{v.unmount(),p()}}),{stdout:process.stderr,exitOnCtrlC:!1})})}finally{await d?.close()}}function I(e){return e==="passed"?n.green:e==="failed"||e==="broken"||e==="cancelled"?n.red:n.dim}var b=40,R=9,k=20;function f(e,o){return e.length>o?e.slice(0,o-1)+"\u2026":e.padEnd(o)}function O({row:e,selected:o}){let s=e.testId??e.commitId??"";return(0,r.jsxs)(i,{children:[(0,r.jsx)(i,{width:2,flexShrink:0,children:(0,r.jsx)(c,{color:n.orange,children:o?"\u25B8":" "})}),(0,r.jsx)(i,{width:2,flexShrink:0,children:(0,r.jsx)(c,{color:e.kind==="execution"?n.orange:n.muted,children:e.kind==="execution"?"\u25CF":"\u25CB"})}),(0,r.jsx)(i,{width:b,flexShrink:0,children:(0,r.jsx)(c,{color:o?n.orange:void 0,bold:o,wrap:"truncate-end",children:f(e.label,b)})}),(0,r.jsx)(i,{width:R,flexShrink:0,children:(0,r.jsx)(c,{color:I(e.status),bold:o,wrap:"truncate-end",children:f(e.status,R)})}),(0,r.jsx)(i,{width:k,flexShrink:0,children:(0,r.jsx)(c,{color:n.dim,wrap:"truncate-end",children:f(s,k)})})]})}function P(e){let[o,s]=(0,l.useState)(0);return x((a,t)=>{t.upArrow?s(d=>Math.max(0,d-1)):t.downArrow?s(d=>Math.min(e.rows.length-1,d+1)):t.return||a==="o"?e.onOpen(o):(a==="q"||t.escape)&&e.onDone()}),(0,r.jsx)(E,{title:"Evidence",borderColor:n.muted,children:(0,r.jsxs)(i,{flexDirection:"column",children:[e.rows.map((a,t)=>(0,r.jsx)(O,{row:a,selected:t===o},t)),(0,r.jsx)(i,{marginTop:1,children:(0,r.jsx)(c,{color:n.dim,children:"\u2191/\u2193 move \xB7 enter/o open \xB7 q quit"})})]})})}export{y as a,H as b};
2
+ import{b as B,c as S,d as T}from"./chunk-P4VFC6HO.js";import{c as g}from"./chunk-RFHMDQXZ.js";import{a as E}from"./chunk-M3TFOFUQ.js";import{a as h}from"./chunk-HCBYKLMW.js";import{a as i,b as c,c as w,i as x}from"./chunk-33DWJV67.js";import{a as L}from"./chunk-6YGTRKDT.js";import{z as n}from"./chunk-FAMQ4DHU.js";import{e as u}from"./chunk-UR6MHSHU.js";var l=u(L(),1);var r=u(h(),1);function y(e){return new Map(e.map((o,s)=>[`${s}-${o.label}`,o.packPath]))}async function H(e){let o=e.deps?.viewerBase??S(e.env),s=e.deps?.startServer??B,a=e.deps?.openUrl??(m=>g(m).then(()=>{})),t=y(e.rows),d;try{d=await s({packs:t,allowedOrigins:[new URL(o).origin]});let m=d,D=async p=>{let v=[...t.keys()][p];await a(T(m.urlFor(v),o))};if(e.deps?.hold){await e.deps.hold();return}await new Promise(p=>{let v=w(l.default.createElement(P,{rows:e.rows,onOpen:D,onDone:()=>{v.unmount(),p()}}),{stdout:process.stderr,exitOnCtrlC:!1})})}finally{await d?.close()}}function I(e){return e==="passed"?n.green:e==="failed"||e==="broken"||e==="cancelled"?n.red:n.dim}var b=40,R=9,k=20;function f(e,o){return e.length>o?e.slice(0,o-1)+"\u2026":e.padEnd(o)}function O({row:e,selected:o}){let s=e.testId??e.commitId??"";return(0,r.jsxs)(i,{children:[(0,r.jsx)(i,{width:2,flexShrink:0,children:(0,r.jsx)(c,{color:n.orange,children:o?"\u25B8":" "})}),(0,r.jsx)(i,{width:2,flexShrink:0,children:(0,r.jsx)(c,{color:e.kind==="execution"?n.orange:n.muted,children:e.kind==="execution"?"\u25CF":"\u25CB"})}),(0,r.jsx)(i,{width:b,flexShrink:0,children:(0,r.jsx)(c,{color:o?n.orange:void 0,bold:o,wrap:"truncate-end",children:f(e.label,b)})}),(0,r.jsx)(i,{width:R,flexShrink:0,children:(0,r.jsx)(c,{color:I(e.status),bold:o,wrap:"truncate-end",children:f(e.status,R)})}),(0,r.jsx)(i,{width:k,flexShrink:0,children:(0,r.jsx)(c,{color:n.dim,wrap:"truncate-end",children:f(s,k)})})]})}function P(e){let[o,s]=(0,l.useState)(0);return x((a,t)=>{t.upArrow?s(d=>Math.max(0,d-1)):t.downArrow?s(d=>Math.min(e.rows.length-1,d+1)):t.return||a==="o"?e.onOpen(o):(a==="q"||t.escape)&&e.onDone()}),(0,r.jsx)(E,{title:"Evidence",borderColor:n.muted,children:(0,r.jsxs)(i,{flexDirection:"column",children:[e.rows.map((a,t)=>(0,r.jsx)(O,{row:a,selected:t===o},t)),(0,r.jsx)(i,{marginTop:1,children:(0,r.jsx)(c,{color:n.dim,children:"\u2191/\u2193 move \xB7 enter/o open \xB7 q quit"})})]})})}export{y as a,H as b};
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as O}from"./chunk-QSCXXNC2.js";import{b as A}from"./chunk-VO66KP2W.js";import{n as L}from"./chunk-HHW6MRU3.js";import{a as k,b as P}from"./chunk-6PIIUAZF.js";import{a as b,b as R,c as x,d as y,e as T,g as I,h as f}from"./chunk-NC7D7GOM.js";import{d as w,g as p}from"./chunk-ZCRZFAOT.js";import{a as v}from"./chunk-RZ4F3BHX.js";import{a as m,i as S}from"./chunk-D36V5OX6.js";var h=class{config;buffer=[];stepBuffer=new Map;flushTimer=null;currentRunIndex=null;stopped=!1;_inFlightFlush=null;_stoppingFast=!1;_droppedBatches=0;_droppedEntries=0;constructor(e){this.config=e}start(){if(this.flushTimer)return;let e=this.config.flushIntervalMs??5e3;this.flushTimer=setInterval(()=>{this.flush().catch(()=>{})},e),this.flushTimer.unref&&this.flushTimer.unref()}setRunIndex(e){this.currentRunIndex=e}log(e,t,n,s={}){if(this.stopped)return;let o=this.buildEntry(e,t,n,s);this.buffer.push(o)}logStep(e,t,n,s={}){if(this.stopped)return;let o=this.buildEntry("debug",t,n,s);o.run_index=e,this.stepBuffer.has(e)||this.stepBuffer.set(e,[]),this.stepBuffer.get(e).push(o)}escalate(e){let t=this.stepBuffer.get(e);t&&t.length>0&&this.buffer.push(...t),this.stepBuffer.delete(e)}discardSteps(e){this.stepBuffer.delete(e)}async flush(){if(this.buffer.length===0)return;let e=this._flushBody();this._inFlightFlush=e;try{await e}finally{this._inFlightFlush===e&&(this._inFlightFlush=null)}}async _flushBody(){let e=this.buffer.splice(0),t=null;try{t=await this.config.getToken()}catch{this.buffer.unshift(...e);return}let n={"Content-Type":"application/json"};t&&(n.Authorization=`Bearer ${t}`);let s=JSON.stringify(e);for(let o=0;o<3;o++){try{let l=new AbortController,a=setTimeout(()=>l.abort(),1e4),c=await v(this.config.proxyUrl,{method:"POST",headers:n,body:s,signal:l.signal});if(clearTimeout(a),c.ok)return}catch{}if(this._stoppingFast){this.buffer.unshift(...e);return}o<2&&await new Promise(l=>setTimeout(l,1e3*Math.pow(2,o)))}this._droppedBatches++,this._droppedEntries+=e.length}async flushOnce(e){if(this.buffer.length===0)return"empty";let t=this.buffer.splice(0),n=Date.now()+e,s=!1,o,l=null;try{l=await Promise.race([this.config.getToken(),new Promise(d=>{o=setTimeout(()=>{s=!0,d(null)},e),o.unref&&o.unref()})])}catch{l=null}finally{o&&clearTimeout(o)}let a=n-Date.now();if(s||a<=0)return this.buffer.unshift(...t),"timeout";let c={"Content-Type":"application/json"};l&&(c.Authorization=`Bearer ${l}`);try{let d=new AbortController,u=setTimeout(()=>d.abort(),a);u.unref&&u.unref();let r=await v(this.config.proxyUrl,{method:"POST",headers:c,body:JSON.stringify(t),signal:d.signal});return clearTimeout(u),r.ok?"sent":(this.buffer.unshift(...t),"failed")}catch{return this.buffer.unshift(...t),Date.now()>=n?"timeout":"failed"}}async stopAndFlushOnce(e){let t=Date.now()+e;this._stoppingFast=!0,this.stopped=!0,this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null);let n=this._inFlightFlush;if(n){let o;await Promise.race([n.catch(()=>{}),new Promise(l=>{o=setTimeout(l,e),o.unref&&o.unref()})]),o&&clearTimeout(o)}if(this.buffer.length===0)return"empty";let s=t-Date.now();if(s<=0)return"timeout";try{return await this.flushOnce(s)}catch{return"failed"}}drainBuffer(){return this.buffer.splice(0)}get droppedBatches(){return this._droppedBatches}get droppedEntries(){return this._droppedEntries}async shutdown(){this._droppedBatches>0&&this.log("warn","LOG_DROPS",`Dropped ${this._droppedEntries} entries in ${this._droppedBatches} batches`,{dropped_batches:this._droppedBatches,dropped_entries:this._droppedEntries}),this.stopped=!0,this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),await this.flush()}shutdownSync(){this.stopped=!0,this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null)}get bufferSize(){return this.buffer.length}stepBufferSize(e){return this.stepBuffer.get(e)?.length??0}buildEntry(e,t,n,s){return{hostname:"kane-cli",service:"kane-cli",ddsource:"kane-cli",ddtags:`version:${this.config.device.cli_version}`,level:e,event:t,message:n,session_id:this.config.sessionId,run_index:t.startsWith("tcg_")?null:this.currentRunIndex,identity:this.config.identity,device:this.config.device,context:s,timestamp:new Date().toISOString()}}};import{platform as $,arch as V}from"os";import M from"fs";import B from"fs";import U from"path";var F=1e3,_=0,j=new Set([130,3]),g=class i{ids;logger;opts;ended=!1;createdAt=Date.now();errorState;constructor(e,t={emitted:!1}){this.ids=e.envelope,this.logger=e.logger,this.opts=e,this.errorState=t}get enabled(){return this.logger!==null}event(e,t={}){if(!this.logger)return;e==="ASR_ERROR"&&(this.errorState.emitted=!0);let n=y(this.ids,e,t);this.logger.log(x[e],e,e,C(n))}error(e,t={}){this.logger&&(this.logger.escalate(_),this.event("ASR_ERROR",{...t,error_code:e}))}child(e,t){return new i({...this.opts,envelope:{...this.ids,operation_id:t,parent_operation_id:this.ids.operation_id,verb:"design"}},this.errorState)}async lateBindContext(e){if(!(!this.logger||this.ids.context_instance_id))try{let{ensureStoreIds:t}=await import("./store-id-YZ5WKJ25.js"),{ids:n,cloned:s}=t(e,p());this.ids.context_lineage_id=n.context_lineage_id,this.ids.context_instance_id=n.context_instance_id,s&&this.event("ASR_CONTEXT_CLONED")}catch{}}spoolError(e,t={}){this.logger&&(this.event("ASR_ERROR",{...t,error_code:e}),T(this.logger.drainBuffer()))}agentSession(e){this.ids.agent_session_id=e}spawnEnv(){if(!this.opts.telemetryEnabled)return{};let e={TESTMUAI_USER_SESSION_ID:this.ids.session_id,TESTMUAI_OPERATION_ID:this.ids.operation_id,TESTMUAI_CLIENT_VERSION:this.opts.clientVersion,TESTMUAI_TELEMETRY_PROXY_URL:this.opts.proxyUrl};return this.ids.context_instance_id&&(e.TESTMUAI_CONTEXT_INSTANCE_ID=this.ids.context_instance_id),e}traceTee(){return e=>{if(!this.logger)return;let t=typeof e.kind=="string"?e.kind.slice(0,64):"trace",n={...C(y(this.ids,"ASR_CMD_START",{})),trace_kind:t};typeof e.code=="string"&&(n.trace_code=e.code.slice(0,64)),delete n.event,this.logger.logStep(_,`trace_${t}`,t,n)}}wireTrace(e,t,n){if(!this.logger)return;n&&this.agentSession(n);let s=t&&typeof t=="object"?t:{};switch(e){case"spawn":this.event("ASR_AGENT_SPAWN",{tier:s.tier});break;case"session_paused":this.event("ASR_SESSION_PAUSED",s);break;case"commit":this.event("ASR_COMMIT",s);break;case"design_phase_committed":this.event("ASR_COMMIT",{phase:s.phase,duration_ms:s.ms});break;default:this.traceTee()({kind:e,code:typeof s.code=="string"?s.code:void 0})}}banner(){return`session: ${this.ids.session_id}`}supportFooter(){return`if this keeps failing, share this id with support: ${this.ids.session_id}`}async end(e){if(!this.ended){if(this.ended=!0,e.duration_ms===void 0&&(e={...e,duration_ms:Date.now()-this.createdAt}),this.logger)if(e.exit_code===0?this.logger.discardSteps(_):this.logger.escalate(_),e.exit_code>0&&!j.has(e.exit_code)&&!this.errorState.emitted&&this.event("ASR_ERROR",{error_code:e.exit_code===2?"usage_exit_unattributed":`exit_${e.exit_code}_unattributed`,exit_code:e.exit_code}),this.event("ASR_CMD_END",e),this.opts.longSession)await this.logger.shutdown();else{let t=await this.logger.flushOnce(F);(t==="failed"||t==="timeout")&&T(this.logger.drainBuffer())}this.logger&&this.writeManifestLine(e.exit_code),f(null)}}writeManifestLine(e){try{let t=w(this.ids.context_instance_id??null);B.mkdirSync(U.dirname(t),{recursive:!0});let n={ts:new Date().toISOString(),session_id:this.ids.session_id,operation_id:this.ids.operation_id,agent_session_id:this.ids.agent_session_id,verb:this.ids.verb,mode:this.ids.mode,exit_code:e};B.appendFileSync(t,JSON.stringify(n)+`
2
+ import{a as O}from"./chunk-QSCXXNC2.js";import{a as k,b as P}from"./chunk-6PIIUAZF.js";import{b as A}from"./chunk-VO66KP2W.js";import{n as L}from"./chunk-G4K3TP2I.js";import{a as b,b as R,c as x,d as y,e as T,g as I,h as f}from"./chunk-UJLULWSR.js";import{d as w,g as p}from"./chunk-ZCRZFAOT.js";import{a as v}from"./chunk-RZ4F3BHX.js";import{a as m,i as S}from"./chunk-FAMQ4DHU.js";var h=class{config;buffer=[];stepBuffer=new Map;flushTimer=null;currentRunIndex=null;stopped=!1;_inFlightFlush=null;_stoppingFast=!1;_droppedBatches=0;_droppedEntries=0;constructor(e){this.config=e}start(){if(this.flushTimer)return;let e=this.config.flushIntervalMs??5e3;this.flushTimer=setInterval(()=>{this.flush().catch(()=>{})},e),this.flushTimer.unref&&this.flushTimer.unref()}setRunIndex(e){this.currentRunIndex=e}log(e,t,n,s={}){if(this.stopped)return;let o=this.buildEntry(e,t,n,s);this.buffer.push(o)}logStep(e,t,n,s={}){if(this.stopped)return;let o=this.buildEntry("debug",t,n,s);o.run_index=e,this.stepBuffer.has(e)||this.stepBuffer.set(e,[]),this.stepBuffer.get(e).push(o)}escalate(e){let t=this.stepBuffer.get(e);t&&t.length>0&&this.buffer.push(...t),this.stepBuffer.delete(e)}discardSteps(e){this.stepBuffer.delete(e)}async flush(){if(this.buffer.length===0)return;let e=this._flushBody();this._inFlightFlush=e;try{await e}finally{this._inFlightFlush===e&&(this._inFlightFlush=null)}}async _flushBody(){let e=this.buffer.splice(0),t=null;try{t=await this.config.getToken()}catch{this.buffer.unshift(...e);return}let n={"Content-Type":"application/json"};t&&(n.Authorization=`Bearer ${t}`);let s=JSON.stringify(e);for(let o=0;o<3;o++){try{let l=new AbortController,a=setTimeout(()=>l.abort(),1e4),c=await v(this.config.proxyUrl,{method:"POST",headers:n,body:s,signal:l.signal});if(clearTimeout(a),c.ok)return}catch{}if(this._stoppingFast){this.buffer.unshift(...e);return}o<2&&await new Promise(l=>setTimeout(l,1e3*Math.pow(2,o)))}this._droppedBatches++,this._droppedEntries+=e.length}async flushOnce(e){if(this.buffer.length===0)return"empty";let t=this.buffer.splice(0),n=Date.now()+e,s=!1,o,l=null;try{l=await Promise.race([this.config.getToken(),new Promise(d=>{o=setTimeout(()=>{s=!0,d(null)},e),o.unref&&o.unref()})])}catch{l=null}finally{o&&clearTimeout(o)}let a=n-Date.now();if(s||a<=0)return this.buffer.unshift(...t),"timeout";let c={"Content-Type":"application/json"};l&&(c.Authorization=`Bearer ${l}`);try{let d=new AbortController,u=setTimeout(()=>d.abort(),a);u.unref&&u.unref();let r=await v(this.config.proxyUrl,{method:"POST",headers:c,body:JSON.stringify(t),signal:d.signal});return clearTimeout(u),r.ok?"sent":(this.buffer.unshift(...t),"failed")}catch{return this.buffer.unshift(...t),Date.now()>=n?"timeout":"failed"}}async stopAndFlushOnce(e){let t=Date.now()+e;this._stoppingFast=!0,this.stopped=!0,this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null);let n=this._inFlightFlush;if(n){let o;await Promise.race([n.catch(()=>{}),new Promise(l=>{o=setTimeout(l,e),o.unref&&o.unref()})]),o&&clearTimeout(o)}if(this.buffer.length===0)return"empty";let s=t-Date.now();if(s<=0)return"timeout";try{return await this.flushOnce(s)}catch{return"failed"}}drainBuffer(){return this.buffer.splice(0)}get droppedBatches(){return this._droppedBatches}get droppedEntries(){return this._droppedEntries}async shutdown(){this._droppedBatches>0&&this.log("warn","LOG_DROPS",`Dropped ${this._droppedEntries} entries in ${this._droppedBatches} batches`,{dropped_batches:this._droppedBatches,dropped_entries:this._droppedEntries}),this.stopped=!0,this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),await this.flush()}shutdownSync(){this.stopped=!0,this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null)}get bufferSize(){return this.buffer.length}stepBufferSize(e){return this.stepBuffer.get(e)?.length??0}buildEntry(e,t,n,s){return{hostname:"kane-cli",service:"kane-cli",ddsource:"kane-cli",ddtags:`version:${this.config.device.cli_version}`,level:e,event:t,message:n,session_id:this.config.sessionId,run_index:t.startsWith("tcg_")?null:this.currentRunIndex,identity:this.config.identity,device:this.config.device,context:s,timestamp:new Date().toISOString()}}};import{platform as $,arch as V}from"os";import M from"fs";import B from"fs";import U from"path";var F=1e3,_=0,j=new Set([130,3]),g=class i{ids;logger;opts;ended=!1;createdAt=Date.now();errorState;constructor(e,t={emitted:!1}){this.ids=e.envelope,this.logger=e.logger,this.opts=e,this.errorState=t}get enabled(){return this.logger!==null}event(e,t={}){if(!this.logger)return;e==="ASR_ERROR"&&(this.errorState.emitted=!0);let n=y(this.ids,e,t);this.logger.log(x[e],e,e,C(n))}error(e,t={}){this.logger&&(this.logger.escalate(_),this.event("ASR_ERROR",{...t,error_code:e}))}child(e,t){return new i({...this.opts,envelope:{...this.ids,operation_id:t,parent_operation_id:this.ids.operation_id,verb:"design"}},this.errorState)}async lateBindContext(e){if(!(!this.logger||this.ids.context_instance_id))try{let{ensureStoreIds:t}=await import("./store-id-YZ5WKJ25.js"),{ids:n,cloned:s}=t(e,p());this.ids.context_lineage_id=n.context_lineage_id,this.ids.context_instance_id=n.context_instance_id,s&&this.event("ASR_CONTEXT_CLONED")}catch{}}spoolError(e,t={}){this.logger&&(this.event("ASR_ERROR",{...t,error_code:e}),T(this.logger.drainBuffer()))}agentSession(e){this.ids.agent_session_id=e}spawnEnv(){if(!this.opts.telemetryEnabled)return{};let e={TESTMUAI_USER_SESSION_ID:this.ids.session_id,TESTMUAI_OPERATION_ID:this.ids.operation_id,TESTMUAI_CLIENT_VERSION:this.opts.clientVersion,TESTMUAI_TELEMETRY_PROXY_URL:this.opts.proxyUrl};return this.ids.context_instance_id&&(e.TESTMUAI_CONTEXT_INSTANCE_ID=this.ids.context_instance_id),e}traceTee(){return e=>{if(!this.logger)return;let t=typeof e.kind=="string"?e.kind.slice(0,64):"trace",n={...C(y(this.ids,"ASR_CMD_START",{})),trace_kind:t};typeof e.code=="string"&&(n.trace_code=e.code.slice(0,64)),delete n.event,this.logger.logStep(_,`trace_${t}`,t,n)}}wireTrace(e,t,n){if(!this.logger)return;n&&this.agentSession(n);let s=t&&typeof t=="object"?t:{};switch(e){case"spawn":this.event("ASR_AGENT_SPAWN",{tier:s.tier});break;case"session_paused":this.event("ASR_SESSION_PAUSED",s);break;case"commit":this.event("ASR_COMMIT",s);break;case"design_phase_committed":this.event("ASR_COMMIT",{phase:s.phase,duration_ms:s.ms});break;default:this.traceTee()({kind:e,code:typeof s.code=="string"?s.code:void 0})}}banner(){return`session: ${this.ids.session_id}`}supportFooter(){return`if this keeps failing, share this id with support: ${this.ids.session_id}`}async end(e){if(!this.ended){if(this.ended=!0,e.duration_ms===void 0&&(e={...e,duration_ms:Date.now()-this.createdAt}),this.logger)if(e.exit_code===0?this.logger.discardSteps(_):this.logger.escalate(_),e.exit_code>0&&!j.has(e.exit_code)&&!this.errorState.emitted&&this.event("ASR_ERROR",{error_code:e.exit_code===2?"usage_exit_unattributed":`exit_${e.exit_code}_unattributed`,exit_code:e.exit_code}),this.event("ASR_CMD_END",e),this.opts.longSession)await this.logger.shutdown();else{let t=await this.logger.flushOnce(F);(t==="failed"||t==="timeout")&&T(this.logger.drainBuffer())}this.logger&&this.writeManifestLine(e.exit_code),f(null)}}writeManifestLine(e){try{let t=w(this.ids.context_instance_id??null);B.mkdirSync(U.dirname(t),{recursive:!0});let n={ts:new Date().toISOString(),session_id:this.ids.session_id,operation_id:this.ids.operation_id,agent_session_id:this.ids.agent_session_id,verb:this.ids.verb,mode:this.ids.mode,exit_code:e};B.appendFileSync(t,JSON.stringify(n)+`
3
3
  `,{flag:"a",mode:384})}catch{}}};function C(i){let e={event:i.event,session_id:i.session_id,operation_id:i.operation_id,verb:i.verb,mode:i.mode,component:i.component,seq:i.seq,context_lineage_id:i.context_lineage_id,context_instance_id:i.context_instance_id};i.parent_operation_id&&(e.parent_operation_id=i.parent_operation_id),i.agent_session_id&&(e.agent_session_id=i.agent_session_id),i.lattice_session_id&&(e.lattice_session_id=i.lattice_session_id),i.project_id&&(e.project_id=i.project_id);for(let[t,n]of Object.entries(i.context))e[t]=n;return e}import{isMainThread as X}from"worker_threads";var E=()=>process.env.KANE_TELEMETRY_URL||S;function Y(){return process.env.TESTMUAI_BASE_URL?"custom":process.env.TESTMUAI_ENV==="stage"?"stage":"prod"}function z(){return process.env.KANE_TELEMETRY!=="0"&&(!process.env.VITEST||process.env.KANE_TELEMETRY==="1")}function me(i){let e=z(),t=i.env??Y(),n=i.sessionId??null;if(!n&&i.resumeSid&&i.contextRoot)try{let r=L(i.contextRoot,i.resumeSid);r?.user_session_id&&(n=r.user_session_id)}catch{}if(!n&&i.applyPlanPath)try{let r=JSON.parse(M.readFileSync(i.applyPlanPath,"utf8"));r.telemetry?.user_session_id&&(n=r.telemetry.user_session_id)}catch{}let s=i.sessionId===void 0?n!==null:i.resumeSid!==void 0;n||(n=b());let o=null,l=null,a=!1;if(i.contextRoot&&M.existsSync(i.contextRoot))if(i.write&&e){let r=P(i.contextRoot,p());o=r.ids.context_lineage_id,l=r.ids.context_instance_id,a=r.cloned}else{let r=k(i.contextRoot);o=r?.context_lineage_id??null,l=r?.context_instance_id??null}let c={session_id:n,operation_id:R(),context_lineage_id:o,context_instance_id:l,...i.remote?{lattice_session_id:i.remote.sessionId,project_id:i.remote.projectId}:{},verb:i.verb,mode:i.mode,component:"kane-cli"},d=null;if(e){let r=A(t),N={org_id:r.org_id??"",user_id:r.user_id??"",machine_id:r.machine_id,email:null,email_domain:"",user_type:r.user_type??"unknown",env:r.env,plan:r.plan??"unknown"},D=i.mode==="interactive"||i.mode==="cli"?"cli":"agent";d=new h({proxyUrl:E(),sessionId:n,identity:N,device:{cli_version:m,platform:$(),arch:V(),host_agent:O(),invocation_mode:D},getToken:async()=>null}),i.longSession&&d.start()}let u=new g({envelope:c,logger:d,longSession:!!i.longSession,proxyUrl:E(),clientVersion:`kane-cli/${m}`,telemetryEnabled:e});return e&&!i.errorsOnly&&(f(c),u.event("ASR_CMD_START",{resumed:s,applied_plan:!!i.applyPlanPath}),a&&u.event("ASR_CONTEXT_CLONED"),X&&I(E()).catch(()=>{})),u}export{h as a,F as b,E as c,Y as d,z as e,me as f};
@@ -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-D36V5OX6.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{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-FAMQ4DHU.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,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{l as E}from"./chunk-NC7D7GOM.js";import{a as x}from"./chunk-RZ4F3BHX.js";import{k as _,l as A}from"./chunk-D36V5OX6.js";import{spawn as S,spawnSync as T}from"child_process";import{existsSync as y,mkdirSync as I,readFileSync as M,writeFileSync as v}from"fs";import{createConnection as G}from"net";import{homedir as m,platform as h}from"os";import{join as i}from"path";var H=new Set(["1","true","yes"]),f=class extends Error{constructor(o){super(o),this.name="ChromeNotFoundError"}};function ie(e){return e instanceof f?e.message:`Chrome failed: ${e instanceof Error?e.message:String(e)}`}var w={darwin:["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",i(m(),"Applications/Google Chrome.app/Contents/MacOS/Google Chrome"),"/Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing",i(m(),"Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing"),"/Applications/Chromium.app/Contents/MacOS/Chromium"],linux:["/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/usr/bin/google-chrome-for-testing","/usr/local/bin/google-chrome-for-testing",i(m(),"chrome-for-testing/chrome-linux64/chrome"),"/usr/bin/chromium","/usr/bin/chromium-browser","/snap/bin/chromium"],win32:["C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe","C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",i(m(),"AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"),"C:\\chrome-for-testing\\chrome-win64\\chrome.exe",i(m(),"AppData\\Local\\chrome-for-testing\\chrome-win64\\chrome.exe"),i(m(),"AppData\\Local\\kane-chrome\\chrome.exe")]};function L(){let e=process.env.KANE_CLI_CHROME_PATH?.trim();return e||void 0}function N(){let e=L();if(e)return e;let o=h(),r=w[o]??w.linux;for(let t of r)if(y(t))return t;return o==="win32"?"chrome.exe":"google-chrome"}function $(){let e=L();if(e)return y(e);let o=h();if((w[o]??w.linux).some(s=>y(s)))return!0;let t=o==="win32"?"chrome.exe":"google-chrome",n=o==="win32"?"where":"which";try{return T(n,[t],{stdio:"ignore"}).status===0}catch{return!1}}function F(){let e=h();return e==="darwin"?["Google Chrome is required but was not found at any standard path.","","Install via Homebrew (recommended):"," brew install --cask google-chrome","","Or download:"," https://www.google.com/chrome/","","Then re-run your command. Set KANE_CLI_CHROME_PATH=/path/to/chrome","to point at a non-standard install."].join(`
2
+ import{l as E}from"./chunk-UJLULWSR.js";import{a as x}from"./chunk-RZ4F3BHX.js";import{k as _,l as A}from"./chunk-FAMQ4DHU.js";import{spawn as S,spawnSync as T}from"child_process";import{existsSync as y,mkdirSync as I,readFileSync as M,writeFileSync as v}from"fs";import{createConnection as G}from"net";import{homedir as m,platform as h}from"os";import{join as i}from"path";var H=new Set(["1","true","yes"]),f=class extends Error{constructor(o){super(o),this.name="ChromeNotFoundError"}};function ie(e){return e instanceof f?e.message:`Chrome failed: ${e instanceof Error?e.message:String(e)}`}var w={darwin:["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",i(m(),"Applications/Google Chrome.app/Contents/MacOS/Google Chrome"),"/Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing",i(m(),"Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing"),"/Applications/Chromium.app/Contents/MacOS/Chromium"],linux:["/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/usr/bin/google-chrome-for-testing","/usr/local/bin/google-chrome-for-testing",i(m(),"chrome-for-testing/chrome-linux64/chrome"),"/usr/bin/chromium","/usr/bin/chromium-browser","/snap/bin/chromium"],win32:["C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe","C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",i(m(),"AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"),"C:\\chrome-for-testing\\chrome-win64\\chrome.exe",i(m(),"AppData\\Local\\chrome-for-testing\\chrome-win64\\chrome.exe"),i(m(),"AppData\\Local\\kane-chrome\\chrome.exe")]};function L(){let e=process.env.KANE_CLI_CHROME_PATH?.trim();return e||void 0}function N(){let e=L();if(e)return e;let o=h(),r=w[o]??w.linux;for(let t of r)if(y(t))return t;return o==="win32"?"chrome.exe":"google-chrome"}function $(){let e=L();if(e)return y(e);let o=h();if((w[o]??w.linux).some(s=>y(s)))return!0;let t=o==="win32"?"chrome.exe":"google-chrome",n=o==="win32"?"where":"which";try{return T(n,[t],{stdio:"ignore"}).status===0}catch{return!1}}function F(){let e=h();return e==="darwin"?["Google Chrome is required but was not found at any standard path.","","Install via Homebrew (recommended):"," brew install --cask google-chrome","","Or download:"," https://www.google.com/chrome/","","Then re-run your command. Set KANE_CLI_CHROME_PATH=/path/to/chrome","to point at a non-standard install."].join(`
3
3
  `):e==="linux"?["Google Chrome is required but was not found at /usr/bin/google-chrome.","(amd64 / x86_64 only \u2014 Google does not ship Chrome for Linux ARM.)","","Debian / Ubuntu (any version):"," wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"," sudo apt install -y ./google-chrome-stable_current_amd64.deb","","Fedora / RHEL / AlmaLinux / Rocky:"," sudo dnf install -y https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm","","Then re-run your command. Set KANE_CLI_CHROME_PATH=/path/to/chrome","to point at a non-standard install."].join(`
4
4
  `):e==="win32"?["Google Chrome is required but was not found in Program Files or AppData.","","Install via winget (Windows 10 1809+):"," winget install --id Google.Chrome -e --silent","","Or download:"," https://www.google.com/chrome/","","Then re-run your command. Set KANE_CLI_CHROME_PATH=C:\\path\\to\\chrome.exe","to point at a non-standard install."].join(`
5
5
  `):["Google Chrome is required.","Install from https://www.google.com/chrome/","(Note: no official Chrome builds for BSD or Alpine/musl Linux.)"].join(`
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{h as m,i as h,j as _,o as w,p as E,q as l,r as f,s as u,t as d,u as x}from"./chunk-OCDBTAYS.js";import{a as g,b as y}from"./chunk-KGNE5CIM.js";function C(t,e){let r=typeof t.body?.retry_after_s=="number"?t.body.retry_after_s:null;if(t.code==="TOO_SOON")return`${r!==null?`in ${Math.max(1,Math.ceil(r/60))} min, `:"later, "}kane-cli explore context sync ${e}`;if(t.code==="CONTEXT_OFF")return`kane-cli explore context on ${e}`}async function b(t,e,r){if(r.out&&!r.projectNames)return;let s=await new y({baseUrl:t.controllerBaseUrl,auth:t.basic,timeoutMs:w}).viewSummary(e),n=typeof s?.project_id=="string"?s.project_id:"";if(n)return(await E(r,t)([n]))[n]??n.slice(0,8)}function k(t){let e=typeof t.body?.retry_after_s=="number"?t.body.retry_after_s:null;return t.code==="TOO_SOON"&&e!==null?`TOO_SOON: the last cut was taken too recently (a run's end takes one too); the next can start in ${Math.max(1,Math.ceil(e/60))} min`:t.code==="CONTEXT_OFF"?`CONTEXT_OFF: assurance context is off for this exploration${typeof t.body?.off_reason=="string"?` (${t.body.off_reason})`:""}; turn it on with explore context on`:u(t)}async function N(t,e,r,s={}){let n=f(s,e,r),i=await l(r,`explore context ${t}`);if(!i.ok)return n.fail(i.error);let a=d(i);try{if(t==="sync"){let o=await a.syncContext(e);if(!n.tty)n.event({type:"explore_context_sync",exploration_id:e,state:o.state,job_id:o.job_id??null,cut:o.cut??null,trigger:o.trigger??null,running_job_id:o.running_job_id??null,hx_job_link:o.hx_job_link??null,...o.state==="failed"?{error:o.error??null}:{}});else if(o.state!=="failed")for(let O of h(e,o))n.out(O);return o.state==="failed"?n.fail(T(e,o),1,j(e,o)):n.ok()}let c=t==="status"?await a.getContext(e):await a.setContext(e,t==="on");if(!n.tty)n.event({type:"explore_context",exploration_id:e,action:t,context:c});else if(t==="status")for(let o of m(c,{project:await b(i,e,s)}))n.out(o);else for(let o of _(e,c,t,await b(i,e,s)))n.out(o);return n.ok()}catch(c){let o=A(c,t,e);return n.fail(o.message,o.code,o.next)}}function A(t,e,r){if(t instanceof g){if(t.code==="NO_ENDED_RUN")return{message:"NO_ENDED_RUN: no run of this exploration has ended yet; the first assurance job runs when one ends",code:1,next:"run it first: kane-cli explore run \u2026, then sync"};if(t.status===404)return{message:`exploration ${r} not found, or this service has no assurance context yet`,code:2};if(t.status===501)return{message:`this service has no assurance context yet (exploration ${r})`,code:2};if(t.code==="NOT_CONFIGURED")return{message:"NOT_CONFIGURED: assurance jobs are not set up on this service (no HyperExecute or report URL); context stays on and runs once they are",code:1};if(t.status===401||t.status===403)return{message:u(t),code:2};if(t.status<500){let s=C(t,r);return{message:k(t),code:1,...s?{next:s}:{}}}}return{message:`could not ${e==="status"?"read":e==="sync"?"sync":"change"} the assurance context: ${u(t)}`,code:1}}function T(t,e){return`${e.error?.code??"LAUNCH_FAILED"}: the assurance job could not launch${e.error?.message?` (${e.error.message})`:""}; explore context status ${t} shows it`}function j(t,e){let r=e.error?.code??"LAUNCH_FAILED";return`try again: kane-cli explore context sync ${t}${r==="HX_TRIGGER_FAILED"?"; or run with --local-orchestration":""}`}var $="usage: kane-cli explore context <status|on|off|sync> <exploration-id> (or explore context <exploration-id> on a terminal for the panel)";async function F(t,e,r={}){let s=f(r,t??null,e);if(!s.tty||!t)return s.fail($);let n=await l(e,"explore context");if(!n.ok)return s.fail(n.error);let{runContextPanel:i}=await import("./explore-context-tty-RZ7D2TBV.js"),a=typeof e.env=="string"?e.env:"prod";return await i({client:d(n),explorationId:t,env:a})==="exit"?130:0}function p(t){return Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0))}function U(t){let e=x(t.command("context").description("An exploration's assurance context (on by default): on, off, status, sync; with only the id, the panel on a terminal").argument("[exploration-id]","The exploration (no action: the context panel on a terminal)")).action(async(s,n)=>{process.exitCode=await F(s,p(n))}),r=[["status","Whether context is on, what is pending or running, and what the last assurance job did"],["on","Turn assurance context on (catches up from the newest ended run)"],["off","Turn assurance context off: the next cut is skipped; nothing already saved is deleted"],["sync","Ask for an assurance job now: launched, pending behind a running job, or up to date"]];for(let[s,n]of r)x(e.command(s).description(n).argument("<exploration-id>","The exploration")).action(async(i,a)=>{process.exitCode=await N(s,i,{...p(e.opts()),...p(a)})})}export{A as a,T as b,U as c};
2
+ import{h as m,i as h,j as _,o as w,p as E,q as l,r as f,s as u,t as d,u as x}from"./chunk-UMNCM4RJ.js";import{a as g,b as y}from"./chunk-KGNE5CIM.js";function C(t,e){let r=typeof t.body?.retry_after_s=="number"?t.body.retry_after_s:null;if(t.code==="TOO_SOON")return`${r!==null?`in ${Math.max(1,Math.ceil(r/60))} min, `:"later, "}kane-cli explore context sync ${e}`;if(t.code==="CONTEXT_OFF")return`kane-cli explore context on ${e}`}async function b(t,e,r){if(r.out&&!r.projectNames)return;let s=await new y({baseUrl:t.controllerBaseUrl,auth:t.basic,timeoutMs:w}).viewSummary(e),n=typeof s?.project_id=="string"?s.project_id:"";if(n)return(await E(r,t)([n]))[n]??n.slice(0,8)}function k(t){let e=typeof t.body?.retry_after_s=="number"?t.body.retry_after_s:null;return t.code==="TOO_SOON"&&e!==null?`TOO_SOON: the last cut was taken too recently (a run's end takes one too); the next can start in ${Math.max(1,Math.ceil(e/60))} min`:t.code==="CONTEXT_OFF"?`CONTEXT_OFF: assurance context is off for this exploration${typeof t.body?.off_reason=="string"?` (${t.body.off_reason})`:""}; turn it on with explore context on`:u(t)}async function N(t,e,r,s={}){let n=f(s,e,r),i=await l(r,`explore context ${t}`);if(!i.ok)return n.fail(i.error);let a=d(i);try{if(t==="sync"){let o=await a.syncContext(e);if(!n.tty)n.event({type:"explore_context_sync",exploration_id:e,state:o.state,job_id:o.job_id??null,cut:o.cut??null,trigger:o.trigger??null,running_job_id:o.running_job_id??null,hx_job_link:o.hx_job_link??null,...o.state==="failed"?{error:o.error??null}:{}});else if(o.state!=="failed")for(let O of h(e,o))n.out(O);return o.state==="failed"?n.fail(T(e,o),1,j(e,o)):n.ok()}let c=t==="status"?await a.getContext(e):await a.setContext(e,t==="on");if(!n.tty)n.event({type:"explore_context",exploration_id:e,action:t,context:c});else if(t==="status")for(let o of m(c,{project:await b(i,e,s)}))n.out(o);else for(let o of _(e,c,t,await b(i,e,s)))n.out(o);return n.ok()}catch(c){let o=A(c,t,e);return n.fail(o.message,o.code,o.next)}}function A(t,e,r){if(t instanceof g){if(t.code==="NO_ENDED_RUN")return{message:"NO_ENDED_RUN: no run of this exploration has ended yet; the first assurance job runs when one ends",code:1,next:"run it first: kane-cli explore run \u2026, then sync"};if(t.status===404)return{message:`exploration ${r} not found, or this service has no assurance context yet`,code:2};if(t.status===501)return{message:`this service has no assurance context yet (exploration ${r})`,code:2};if(t.code==="NOT_CONFIGURED")return{message:"NOT_CONFIGURED: assurance jobs are not set up on this service (no HyperExecute or report URL); context stays on and runs once they are",code:1};if(t.status===401||t.status===403)return{message:u(t),code:2};if(t.status<500){let s=C(t,r);return{message:k(t),code:1,...s?{next:s}:{}}}}return{message:`could not ${e==="status"?"read":e==="sync"?"sync":"change"} the assurance context: ${u(t)}`,code:1}}function T(t,e){return`${e.error?.code??"LAUNCH_FAILED"}: the assurance job could not launch${e.error?.message?` (${e.error.message})`:""}; explore context status ${t} shows it`}function j(t,e){let r=e.error?.code??"LAUNCH_FAILED";return`try again: kane-cli explore context sync ${t}${r==="HX_TRIGGER_FAILED"?"; or run with --local-orchestration":""}`}var $="usage: kane-cli explore context <status|on|off|sync> <exploration-id> (or explore context <exploration-id> on a terminal for the panel)";async function F(t,e,r={}){let s=f(r,t??null,e);if(!s.tty||!t)return s.fail($);let n=await l(e,"explore context");if(!n.ok)return s.fail(n.error);let{runContextPanel:i}=await import("./explore-context-tty-WJHUSP3A.js"),a=typeof e.env=="string"?e.env:"prod";return await i({client:d(n),explorationId:t,env:a})==="exit"?130:0}function p(t){return Object.fromEntries(Object.entries(t).filter(([,e])=>e!==void 0))}function U(t){let e=x(t.command("context").description("An exploration's assurance context (on by default): on, off, status, sync; with only the id, the panel on a terminal").argument("[exploration-id]","The exploration (no action: the context panel on a terminal)")).action(async(s,n)=>{process.exitCode=await F(s,p(n))}),r=[["status","Whether context is on, what is pending or running, and what the last assurance job did"],["on","Turn assurance context on (catches up from the newest ended run)"],["off","Turn assurance context off: the next cut is skipped; nothing already saved is deleted"],["sync","Ask for an assurance job now: launched, pending behind a running job, or up to date"]];for(let[s,n]of r)x(e.command(s).description(n).argument("<exploration-id>","The exploration")).action(async(i,a)=>{process.exitCode=await N(s,i,{...p(e.opts()),...p(a)})})}export{A as a,T as b,U as c};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as f}from"./chunk-FNUGDPTS.js";import{a as d}from"./chunk-TD6GCEIK.js";import{c as p}from"./chunk-4C7WVQOD.js";import{g}from"./chunk-HYJVYYAZ.js";import{existsSync as i}from"fs";import{resolve as a}from"path";function A(){let n=g().packageRoot;return n===null?[]:[n]}function S(n){return{"darwin-arm64":"kane-cli-darwin-arm64","darwin-x64":"kane-cli-darwin-x64","linux-x64":"kane-cli-linux-x64","linux-arm64":"kane-cli-linux-arm64","win32-x64":"kane-cli-win-x64"}[n]??null}function _(n){return{"darwin-arm64":"kane-cli-assurance-darwin-arm64","darwin-x64":"kane-cli-assurance-darwin-x64","linux-x64":"kane-cli-assurance-linux-x64","linux-arm64":"kane-cli-assurance-linux-arm64","win32-x64":"kane-cli-assurance-win-x64"}[n]??null}function C(n=A()){let e=S(`${process.platform}-${process.arch}`),c=_(`${process.platform}-${process.arch}`),t=process.platform==="win32"?"assurance-agent.exe":"assurance-agent";for(let r of n){for(let s of c?["@testmuai","@lambdatestincprivate"]:[]){let o=a(r,"node_modules",s,c,"bin",t);if(i(o))return{cmd:o,args:[],tier:"platform"}}for(let s of e?["@testmuai","@lambdatestincprivate"]:[]){let o=a(r,"node_modules",s,e,"bin",t);if(i(o))return{cmd:o,args:[],tier:"platform"}}let m=a(r,"dist","bin",t);if(i(m))return{cmd:m,args:[],tier:"embedded"};let u=a(r,"../assurance-agent/dist",t);if(i(u))return{cmd:u,args:[],tier:"sibling"};let l=a(r,"../assurance-agent/main.py");if(i(l)){let s=a(r,"../assurance-agent/.venv/bin/python");return{cmd:i(s)?s:"python3",args:[l],tier:"dev-python"}}}return null}var x=12e4+p;function U(n,e={}){return{...process.env,...d(process.env),...e,...f(),TESTMUAI_SOURCE:"kane-cli",TESTMUAI_SESSION_ID:n,ASSURANCE_LOG_LEVEL:process.env.ASSURANCE_LOG_LEVEL??"info",PYTHONIOENCODING:"utf-8",PYTHONUTF8:"1",ASSURANCE_CHECKPOINT_SAVE_DEADLINE_S:String(x/1e3)}}async function w(n,e=process.env){if(e.TESTMUAI_API_KEY||e.TESTMUAI_BASIC_AUTH)return{};try{let t={TESTMUAI_ENV:e.TESTMUAI_ENV==="stage"?"stage":"prod"},r=await n.controller();return r.basic?(t.TESTMUAI_BASIC_AUTH=Buffer.from(`${r.basic.username}:${r.basic.accessKey}`,"utf8").toString("base64"),t):r.token?(t.TESTMUAI_API_KEY=r.token,t):{}}catch{return{}}}export{S as a,_ as b,C as c,x as d,U as e,w as f};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ var r=new Set,s=[];function i(){let e=new Set;for(let t of r){e.add(t);let o=JSON.stringify(t).slice(1,-1);e.add(o),e.add(encodeURIComponent(t)),e.add(encodeURIComponent(t).replace(/%20/g,"+")),e.add(Buffer.from(t,"utf8").toString("base64"))}let n=[...r];for(let t of n)for(let o of n)t!==o&&e.add(Buffer.from(`${t}:${o}`,"utf8").toString("base64"));s=[...e].filter(t=>t.length>=4).sort((t,o)=>o.length-t.length)}function c(e){let n=!1;for(let t of e)typeof t!="string"||t.length<4||r.has(t)||(r.add(t),n=!0);n&&i()}function a(e){if(s.length===0||!e)return e;let n=e;for(let t of s)n.includes(t)&&(n=n.split(t).join("***"));return n}var f=64*1024*1024;export{c as a,a as b};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{eb as u,fb as c}from"./chunk-UEE3RZN4.js";import{b as f}from"./chunk-7V4BQSSV.js";import{existsSync as o,mkdirSync as g,readFileSync as b}from"fs";import{dirname as l,join as m}from"path";function s(t,r){let n=r.startsWith("sha256:")?r.slice(7):r;return m(t,"blobs",n.slice(0,2),n.slice(2))}function F(t,r){return s(t,r)}function p(t){let r=Buffer.concat([Buffer.from("assurance.blob\0","utf8"),t]);return"sha256:"+f(r)}function y(t,r){let n=p(r),i=s(t,n);if(!o(i)){let e=l(i),a=!o(e);g(e,{recursive:!0}),u(i,r),a&&c(l(e))}return n}function S(t,r){let n=s(t,r);return o(n)?b(n):null}export{F as a,p as b,y as c,S as d};
2
+ import{eb as u,fb as c}from"./chunk-PI7OXS62.js";import{b as f}from"./chunk-7V4BQSSV.js";import{existsSync as o,mkdirSync as g,readFileSync as b}from"fs";import{dirname as l,join as m}from"path";function s(t,r){let n=r.startsWith("sha256:")?r.slice(7):r;return m(t,"blobs",n.slice(0,2),n.slice(2))}function F(t,r){return s(t,r)}function p(t){let r=Buffer.concat([Buffer.from("assurance.blob\0","utf8"),t]);return"sha256:"+f(r)}function y(t,r){let n=p(r),i=s(t,n);if(!o(i)){let e=l(i),a=!o(e);g(e,{recursive:!0}),u(i,r),a&&c(l(e))}return n}function S(t,r){let n=s(t,r);return o(n)?b(n):null}export{F as a,p as b,y as c,S as d};
@@ -1,6 +1,6 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{N as v,O as x,Q as g}from"./chunk-MEKPGQAM.js";import{a as p}from"./chunk-R7KXAISS.js";import{a as b}from"./chunk-YDSGXB25.js";import{d as h,i as C}from"./chunk-LKQFG4RW.js";import{b as y}from"./chunk-HD6NR44L.js";import{M as E}from"./chunk-UEE3RZN4.js";async function O(o,e,n,t={},i=process.cwd()){let u=e.mode==="agent";if(o&&e.fromStale)return v(n,"pass a <ref> OR --from-stale, not both"),2;if(!o&&!e.fromStale)return v(n,"evolve needs a <ref> or --from-stale"),2;if(!u&&(e.answer?.length??0)>0)return v(n,"--answer rides --mode agent: the blast-radius question is asked on the stream and answered on the next call. In a terminal, answer the prompt instead"),2;let s=x(i,n);if(!s)return 2;let a=()=>h(E(p(s))).targets.length===0;if(!e.yes&&!n.isTTY&&!u&&!(e.fromStale&&a()))return v(n,"evolve needs a TTY \u2014 the blast-radius confirm is the point; headless, run with --mode agent (the question rides the stream and is answered with --answer on the next call) or let kane-cli maintain reconcile drive it"),2;let d=u?b(e.answer):null,m=t.emitEvent;return C(p(s),{...o?{ref:o}:{},...e.because?{because:e.because}:{},...e.mode?{mode:e.mode}:{},...e.yes?{yes:!0}:{}},{io:n,asks:{blast:d??{ask:async(c,l)=>await n.confirm(`proceed with the re-design of ${l}?`)?"proceed":"decline"}},runDesign:t.runDesignForUc??I,...t.onChild?{onChild:t.onChild}:!m&&n.isTTY?{onChild:$(n)}:{},...m?{emit:m}:{},by:{kind:"human",id:process.env.USER??"operator"}})}function $(o){let e="",n="evolve";return t=>{t.kind==="start"?(e=t.subject,n=t.verb,o.out(`\u25CF ${y(t.verb).ing} ${t.subject}`)):t.kind==="end"&&o.out(t.ok?`\u25CF ${y(n).ed} ${e} \u2014 ${t.durS}s`:`\u25CF ${n} failed \u2014 ${t.exitCode!=null?`exited ${t.exitCode}`:"error"}${t.fixCmd?` \xB7 ${t.fixCmd}`:""}`)}}var I=async(o,e)=>{let{designTestsCommand:n}=await import("./bind-4XWK3DG2.js"),t=a=>n({useCase:o,force:!0,...e.mode?{mode:e.mode}:e.yes?{mode:"override"}:{},...e.because?{because:e.because}:{},...e.changeDelta!==void 0?{changeDelta:e.changeDelta}:{},...e.priorDesign!==void 0?{priorDesign:e.priorDesign}:{},...e.repinsKept?{repinsKept:!0}:{},...e.statement?{statement:e.statement}:{},...a?{onEvent:a}:{}});if(e.mode!=="agent")return t(e.onChildEvent);let i=e.onChildEvent,u=process.stdout.write,s="";process.stdout.write=((a,d,m)=>{if(i){s+=typeof a=="string"?a:Buffer.isBuffer(a)?a.toString("utf8"):String(a);let l=s.indexOf(`
2
+ import{N as v,O as x,Q as g}from"./chunk-45NM23EQ.js";import{a as p}from"./chunk-HVOXMCKE.js";import{a as b}from"./chunk-YDSGXB25.js";import{d as h,i as C}from"./chunk-TM6VLC6V.js";import{b as y}from"./chunk-HD6NR44L.js";import{M as E}from"./chunk-PI7OXS62.js";async function O(o,e,n,t={},i=process.cwd()){let u=e.mode==="agent";if(o&&e.fromStale)return v(n,"pass a <ref> OR --from-stale, not both"),2;if(!o&&!e.fromStale)return v(n,"evolve needs a <ref> or --from-stale"),2;if(!u&&(e.answer?.length??0)>0)return v(n,"--answer rides --mode agent: the blast-radius question is asked on the stream and answered on the next call. In a terminal, answer the prompt instead"),2;let s=x(i,n);if(!s)return 2;let a=()=>h(E(p(s))).targets.length===0;if(!e.yes&&!n.isTTY&&!u&&!(e.fromStale&&a()))return v(n,"evolve needs a TTY \u2014 the blast-radius confirm is the point; headless, run with --mode agent (the question rides the stream and is answered with --answer on the next call) or let kane-cli maintain reconcile drive it"),2;let d=u?b(e.answer):null,m=t.emitEvent;return C(p(s),{...o?{ref:o}:{},...e.because?{because:e.because}:{},...e.mode?{mode:e.mode}:{},...e.yes?{yes:!0}:{}},{io:n,asks:{blast:d??{ask:async(c,l)=>await n.confirm(`proceed with the re-design of ${l}?`)?"proceed":"decline"}},runDesign:t.runDesignForUc??I,...t.onChild?{onChild:t.onChild}:!m&&n.isTTY?{onChild:$(n)}:{},...m?{emit:m}:{},by:{kind:"human",id:process.env.USER??"operator"}})}function $(o){let e="",n="evolve";return t=>{t.kind==="start"?(e=t.subject,n=t.verb,o.out(`\u25CF ${y(t.verb).ing} ${t.subject}`)):t.kind==="end"&&o.out(t.ok?`\u25CF ${y(n).ed} ${e} \u2014 ${t.durS}s`:`\u25CF ${n} failed \u2014 ${t.exitCode!=null?`exited ${t.exitCode}`:"error"}${t.fixCmd?` \xB7 ${t.fixCmd}`:""}`)}}var I=async(o,e)=>{let{designTestsCommand:n}=await import("./bind-H3ALI2NG.js"),t=a=>n({useCase:o,force:!0,...e.mode?{mode:e.mode}:e.yes?{mode:"override"}:{},...e.because?{because:e.because}:{},...e.changeDelta!==void 0?{changeDelta:e.changeDelta}:{},...e.priorDesign!==void 0?{priorDesign:e.priorDesign}:{},...e.repinsKept?{repinsKept:!0}:{},...e.statement?{statement:e.statement}:{},...a?{onEvent:a}:{}});if(e.mode!=="agent")return t(e.onChildEvent);let i=e.onChildEvent,u=process.stdout.write,s="";process.stdout.write=((a,d,m)=>{if(i){s+=typeof a=="string"?a:Buffer.isBuffer(a)?a.toString("utf8"):String(a);let l=s.indexOf(`
3
3
  `);for(;l>=0;)S(s.slice(0,l),i),s=s.slice(l+1),l=s.indexOf(`
4
- `)}let c=typeof d=="function"?d:m;return typeof c=="function"&&queueMicrotask(()=>c(null)),!0});try{return await t()}finally{process.stdout.write=u,i&&s.length>0&&S(s,i)}};function S(o,e){let n=o.trim();if(!n.startsWith("{"))return;let t;try{t=JSON.parse(n)}catch{return}if(!t||typeof t!="object"||typeof t.type!="string")return;let i=t;i.type!=="done"&&e(i)}async function B(o,e,n={},t,i=process.cwd()){if(!t&&i===process.cwd()){let{remoteEntry:d}=await import("./remote-entry-X6JMPC2K.js"),m=await d("maintain evolve",e.mode==="agent");if(m!==null){if("exit"in m)return m.exit;let{remoteEvolve:c}=await import("./evolve-remote-WLVY3QID.js");return c({choice:m.choice,...o!==void 0?{ref:o}:{},opts:e})}}let{makeHeadlessIO:u,agentRefusal:s}=await import("./headless-io-FFM5T6KL.js");if(e.mode!==void 0&&e.mode!=="interactive"&&e.mode!=="agent")return s(u("ndjson","evolve",t),`--mode must be interactive | agent, got '${e.mode}'`,"MODE_USAGE");if(e.mode==="agent"){let d=process.stdout.write.bind(process.stdout),m=process.stderr.write.bind(process.stderr),c=u("ndjson","evolve",t??{stdout:r=>{d(r)},stderr:r=>{m(r)}}),l=[],D=r=>{(r.type==="evolve_paused"||r.type==="session_paused")&&Array.isArray(r.next)&&l.push(...r.next),c.event(r)},k={out:c.out,err:(r,w)=>c.event({type:"error",message:r,...w?{code:w}:{}}),isTTY:!1,confirm:async()=>!1,ask:async()=>""},{runWithChannel:T}=await import("./run-channel-63SVP5OI.js"),f=2;try{f=await T({event:r=>c.event(r)},()=>O(o,e,k,{...n,emitEvent:D},i))}catch(r){f=1,c.event({type:"error",message:r instanceof Error?r.message:String(r)})}return c.done(f,void 0,l.length>0?l:void 0)}let a=t?{...g(),out:d=>t.stdout(`${d}
4
+ `)}let c=typeof d=="function"?d:m;return typeof c=="function"&&queueMicrotask(()=>c(null)),!0});try{return await t()}finally{process.stdout.write=u,i&&s.length>0&&S(s,i)}};function S(o,e){let n=o.trim();if(!n.startsWith("{"))return;let t;try{t=JSON.parse(n)}catch{return}if(!t||typeof t!="object"||typeof t.type!="string")return;let i=t;i.type!=="done"&&e(i)}async function B(o,e,n={},t,i=process.cwd()){if(!t&&i===process.cwd()){let{remoteEntry:d}=await import("./remote-entry-BCTFT643.js"),m=await d("maintain evolve",e.mode==="agent");if(m!==null){if("exit"in m)return m.exit;let{remoteEvolve:c}=await import("./evolve-remote-K2MCCVMM.js");return c({choice:m.choice,...o!==void 0?{ref:o}:{},opts:e})}}let{makeHeadlessIO:u,agentRefusal:s}=await import("./headless-io-FFM5T6KL.js");if(e.mode!==void 0&&e.mode!=="interactive"&&e.mode!=="agent")return s(u("ndjson","evolve",t),`--mode must be interactive | agent, got '${e.mode}'`,"MODE_USAGE");if(e.mode==="agent"){let d=process.stdout.write.bind(process.stdout),m=process.stderr.write.bind(process.stderr),c=u("ndjson","evolve",t??{stdout:r=>{d(r)},stderr:r=>{m(r)}}),l=[],D=r=>{(r.type==="evolve_paused"||r.type==="session_paused")&&Array.isArray(r.next)&&l.push(...r.next),c.event(r)},k={out:c.out,err:(r,w)=>c.event({type:"error",message:r,...w?{code:w}:{}}),isTTY:!1,confirm:async()=>!1,ask:async()=>""},{runWithChannel:T}=await import("./run-channel-IIIYXOIW.js"),f=2;try{f=await T({event:r=>c.event(r)},()=>O(o,e,k,{...n,emitEvent:D},i))}catch(r){f=1,c.event({type:"error",message:r instanceof Error?r.message:String(r)})}return c.done(f,void 0,l.length>0?l:void 0)}let a=t?{...g(),out:d=>t.stdout(`${d}
5
5
  `),err:d=>t.stderr(`${d}
6
6
  `),isTTY:!1}:g();return O(o,e,a,n,i)}export{O as a,I as b,S as c,B as d};
@@ -1,3 +1,3 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as h}from"./chunk-72KYMWQ5.js";import{a as d}from"./chunk-JQ64X2TO.js";import{a as m}from"./chunk-34R7BNZ2.js";import{a as p}from"./chunk-3G2LSTK5.js";import{a as V}from"./chunk-4IEQNX7F.js";import{a as y}from"./chunk-C2RUDJ46.js";import{a as g}from"./chunk-4QTH7VYE.js";import{a as c}from"./chunk-RZ4F3BHX.js";var u=class{constructor(e){this.baseUrl=e}async pushSecret(e){let s=g(e.username,e.accessKey),n=await c(`${this.baseUrl}/logistics/v1.0/secrets/create`,{method:"PUT",headers:{Authorization:s,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({secretKey:e.secretKey,secretValue:e.secretValue,orgId:e.orgId,username:e.username,scope:"user",type:"user",accessKey:e.accessKey})});if(!n.ok)throw new Error(`Push secret failed: ${n.status} ${await n.text()}`)}static extractVariableKeys(e){let s=e.matchAll(/\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}/g),n=new Set;for(let t of s)n.add(t[1]);return[...n]}};var f=class extends p{constructor(e,s,n){super(e,{username:s,accessKey:n})}async upsertVariable(e){let s=e.environmentId??0,n=await c(`${this.baseUrl}/v1/variables`,{method:"POST",headers:this.headers(),body:JSON.stringify({name:e.name,value:String(e.value),type:"variable",value_type:"string",is_persist:e.isPersist??!1,environment_id:s})});if(n.ok){let o=await n.json().catch(()=>({}));if(o.type==="Success"&&o.id!=null)return{id:Number(o.id)||0}}let t=await c(`${this.baseUrl}/v1/variables/${encodeURIComponent(e.name)}?environment_id=${s}`,{method:"GET",headers:this.headers()});if(!t.ok)return{id:0};let i=(await t.json().catch(()=>({}))).data?.id;return i==null?{id:0}:(await c(`${this.baseUrl}/v1/variables/${i}`,{method:"PUT",headers:this.headers(),body:JSON.stringify({value:String(e.value),value_type:"string"})})).ok?{id:Number(i)||0}:{id:0}}};import{readdirSync as P,readFileSync as E,existsSync as S}from"fs";import{join as A}from"path";function b(r,e){let s=e.type==="parameter";return{value:typeof e.value=="number"?String(e.value):e.value,secret:e.secret??!1,syntax:e.syntax??(s?"${"+r+"}":`{{${r}}}`),...typeof e.type=="string"?{type:e.type}:{},...typeof e.description=="string"?{description:e.description}:{}}}function v(r,e){if(!S(r))return{};let s={},n;try{n=P(r).filter(t=>t.endsWith(".json")).sort()}catch{return{}}for(let t of n)try{let a=E(A(r,t),"utf-8"),i=JSON.parse(a);if(i&&typeof i=="object")for(let[l,o]of Object.entries(i))o&&typeof o=="object"&&"value"in o&&(s[l]=b(l,o))}catch{e?e("warn","VARIABLE_PARSE_FAILED","Skipping invalid variables file",{file:t}):process.stderr.write(`[variables] Warning: skipping invalid variables file: ${t}
2
+ import{a as h}from"./chunk-72KYMWQ5.js";import{a as m}from"./chunk-CCOD4GQJ.js";import{a as d}from"./chunk-JQ64X2TO.js";import{a as p}from"./chunk-3G2LSTK5.js";import{a as V}from"./chunk-4IEQNX7F.js";import{a as y}from"./chunk-FI2DVNRT.js";import{a as g}from"./chunk-4QTH7VYE.js";import{a as c}from"./chunk-RZ4F3BHX.js";var u=class{constructor(e){this.baseUrl=e}async pushSecret(e){let s=g(e.username,e.accessKey),n=await c(`${this.baseUrl}/logistics/v1.0/secrets/create`,{method:"PUT",headers:{Authorization:s,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({secretKey:e.secretKey,secretValue:e.secretValue,orgId:e.orgId,username:e.username,scope:"user",type:"user",accessKey:e.accessKey})});if(!n.ok)throw new Error(`Push secret failed: ${n.status} ${await n.text()}`)}static extractVariableKeys(e){let s=e.matchAll(/\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}/g),n=new Set;for(let t of s)n.add(t[1]);return[...n]}};var f=class extends p{constructor(e,s,n){super(e,{username:s,accessKey:n})}async upsertVariable(e){let s=e.environmentId??0,n=await c(`${this.baseUrl}/v1/variables`,{method:"POST",headers:this.headers(),body:JSON.stringify({name:e.name,value:String(e.value),type:"variable",value_type:"string",is_persist:e.isPersist??!1,environment_id:s})});if(n.ok){let o=await n.json().catch(()=>({}));if(o.type==="Success"&&o.id!=null)return{id:Number(o.id)||0}}let t=await c(`${this.baseUrl}/v1/variables/${encodeURIComponent(e.name)}?environment_id=${s}`,{method:"GET",headers:this.headers()});if(!t.ok)return{id:0};let i=(await t.json().catch(()=>({}))).data?.id;return i==null?{id:0}:(await c(`${this.baseUrl}/v1/variables/${i}`,{method:"PUT",headers:this.headers(),body:JSON.stringify({value:String(e.value),value_type:"string"})})).ok?{id:Number(i)||0}:{id:0}}};import{readdirSync as P,readFileSync as E,existsSync as S}from"fs";import{join as A}from"path";function b(r,e){let s=e.type==="parameter";return{value:typeof e.value=="number"?String(e.value):e.value,secret:e.secret??!1,syntax:e.syntax??(s?"${"+r+"}":`{{${r}}}`),...typeof e.type=="string"?{type:e.type}:{},...typeof e.description=="string"?{description:e.description}:{}}}function v(r,e){if(!S(r))return{};let s={},n;try{n=P(r).filter(t=>t.endsWith(".json")).sort()}catch{return{}}for(let t of n)try{let a=E(A(r,t),"utf-8"),i=JSON.parse(a);if(i&&typeof i=="object")for(let[l,o]of Object.entries(i))o&&typeof o=="object"&&"value"in o&&(s[l]=b(l,o))}catch{e?e("warn","VARIABLE_PARSE_FAILED","Skipping invalid variables file",{file:t}):process.stderr.write(`[variables] Warning: skipping invalid variables file: ${t}
3
3
  `)}return s}function R(r){if(!S(r))throw new Error(`Variables file not found: ${r}`);let e=E(r,"utf-8"),s=V(e,r),n={};if(s&&typeof s=="object")for(let[t,a]of Object.entries(s))a&&typeof a=="object"&&"value"in a&&(n[t]=b(t,a));return n}function w(r){let e;try{e=JSON.parse(r)}catch{throw new Error("Invalid --variables JSON")}let s={};if(e&&typeof e=="object")for(let[n,t]of Object.entries(e))t&&typeof t=="object"&&"value"in t&&(s[n]=b(n,t));return s}function j(r,e,s){let n=v(r,s),t=v(e,s);return{...n,...t}}function G(r,e){if(Object.keys(r).length===0)return{};let s={};for(let[n,t]of Object.entries(r)){let a=t.syntax??`{{${n}}}`;k(e,a)&&(s[n]=t)}return s}function I(r){let e=r.trim();return e.startsWith("{{")&&e.endsWith("}}")?e.slice(2,-2).trim():e.startsWith("${")&&e.endsWith("}")?e.slice(2,-1).trim():e}function k(r,e){if(!e||!r)return!1;if(r.includes(e))return!0;let s=I(e);if(!s)return!1;let n=s.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`(?:\\{\\{|\\$\\{)\\s*${n}(?=\\s*\\}|[.\\[])`).test(r)}function M(r){let e=j(r.globalDir,r.localDir,r.onLoadError),s=r.file?R(r.file):{},n=r.inline?w(r.inline):{},t={...e,...s,...n,...r.parameters??{}},a=Object.keys(t).length>0,{variables:i,objective:l}=a?h(t,r.objective):{variables:{},objective:r.objective},o=_(t);return m(o.secretEntries.map(([,x])=>x.value)),{raw:t,auteur:i,auteurObjective:l,...o}}function _(r){let e=Object.entries(r),s=e.filter(([,t])=>d(t)),n=e.filter(([,t])=>!d(t));return{secretEntries:n.filter(([,t])=>t.secret),nonSecretEntries:n.filter(([,t])=>!t.secret),parameterEntries:s}}async function Q(r){if(r.localMode)return{};let e=y(r.env);if(r.variables.secretEntries.length>0){let n=new u(e.secretsBaseUrl);for(let[t,a]of r.variables.secretEntries)n.pushSecret({secretKey:t,secretValue:a.value,username:r.auth.username,accessKey:r.auth.access_key,orgId:r.orgId}).then(()=>r.log("info","SECRET_PUSH_OK","Secret pushed",{key:t})).catch(i=>r.log("error","SECRET_PUSH_FAILED","Secret push failed",{key:t,error:String(i)}))}let s={};if(r.variables.nonSecretEntries.length>0){let n=new f(e.tmsBaseUrl,r.auth.username,r.auth.access_key);for(let[t,a]of r.variables.nonSecretEntries)try{let i=await n.upsertVariable({name:t,value:a.value});s[t]=i.id,r.log("info","VAR_PUSH_OK","Variable pushed",{name:t,id:i.id})}catch(i){r.log("error","VAR_PUSH_FAILED","Variable push failed",{name:t,error:String(i)})}}return s}export{u as a,f as b,G as c,M as d,_ as e,Q as f};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as V,e as W,f as Q}from"./chunk-3JLEDSG5.js";import{d as I,j as T}from"./chunk-7XBNMOH4.js";import{Ea as $,M as y}from"./chunk-UEE3RZN4.js";import{d as N}from"./chunk-KU3YHPWZ.js";import{d as h,m as S}from"./chunk-4I7YN6YY.js";function B(e,n,t){let i=S();return e===void 0||e===n?null:e==="extract"||e==="design"?{code:"WRONG_VERB",message:i.text("WRONG_VERB",{sid:t,verb:e}),next:[h(i,"next.resume_session",{verb:e,sid:t},{why:`this session belongs to a ${e} run`})]}:{code:"WRONG_VERB",message:`error: session ${t} belongs to a ${e} run \u2014 this command cannot resume it`,next:[]}}function X(e){return P(e)!==null}function P(e){let n=e,t=K(n);if(t<0)return null;let i=n[t].data?.tool_calls??[],r=i.map(o=>o.id),a=n.slice(t+1);if(r.length===0||a.some(o=>o?.kind!=="tool_result"))return null;let s=new Set(a.map(o=>o.data?.tool_call_id));if(!r.every(o=>s.has(o)))return null;let c=a.find(o=>o.data?.status==="ok"&&o.data?.payload?.accepted===!0);if(!c)return null;let _=i.find(o=>o.id===c.data?.tool_call_id),w=_?.arguments;return{name:typeof _?.name=="string"?_.name:"",arguments:w!==null&&typeof w=="object"?w:{}}}function Y(e){let n=e,t=K(n);if(t<0)return!1;let i=n.slice(t+1);if(i.some(s=>s?.kind!=="tool_result"))return!1;let r=new Set(i.map(s=>s.data?.tool_call_id)),a=(n[t].data?.tool_calls??[]).filter(s=>!r.has(s.id));return a.length===1&&a[0].name==="ask_user"}function K(e){for(let n=e.length-1;n>=0;n--)if(e[n]?.kind==="assistant_turn")return n;return-1}function ce(e){return{id:e.id,text:e.question,risk:["high","med","low"].includes(e.risk)?e.risk:"med",rationale:e.rationale,options:e.options.map(n=>({label:n.label,detail:n.description??""})),recommended_index:e.recommendedOptionIndex,allow_free_text:e.allowFreeText,kind:e.kind,consequence:e.consequence,evidence_count:e.evidence_count,multi_select:e.multiSelect}}function G(e){return{id:e.id,header:e.kind??"question",question:e.text,kind:e.kind??"clarify",multiSelect:e.multi_select??!1,options:e.options.map((n,t)=>({id:`o${t}`,label:n.label,description:n.detail||void 0})),recommendedOptionIndex:e.recommended_index,risk:e.risk,rationale:e.rationale,consequence:e.consequence??"",evidence_count:e.evidence_count,allowFreeText:e.allow_free_text}}function de(e,n,t){let i=n.pending.questions.map(G),r=W(e.state.pending.answers).filter(a=>n.pending.questions.some(s=>s.id===a.id&&Q(a,s)));e.save({agent_state:n.agent_state,pending:{questions:i,proposals:n.pending.proposals??[],...r.length>0?{answers:r}:{}},assumed:n.assumed.map(a=>({questionId:a.question_id,optionId:a.option_id,flagged:!0,eventId:`assumed:${n.sid}:${a.question_id}`}))}),t?.(),e.release(),I(e.state.sid)}function pe(e,n,t,i){if(t.name.startsWith("finalize"))return{call:t.name,event_id:`${e}:ckpt:${i}`};let r=t.arguments.ops;return Array.isArray(r)&&r.length>0&&n?{call:t.name,event_prefix:`chatop:${n}:s${i}:`}:null}function ge(e,n,t){if(!t)return!0;let i=y(e).appliedEvents;if(t.event_id!==void 0)return i.has(t.event_id)||n.includes(t.event_id);let r=t.event_prefix??"";for(let a of i)if(a.startsWith(r))return!0;return n.some(a=>a.startsWith(r))}function fe(e){return`the agent's last ${e==="finalize_design"?"design phase was":e.startsWith("finalize")?"proposal was":"changes were"} not saved before the session stopped \u2014 it is sent again`}function me(e){return e===1?"your last message was sent again":`your last ${e} messages were sent again`}function U(e,n,t){return t?.call!=="finalize_design"||t.event_id===void 0?!1:y(e).appliedEvents.has(t.event_id)&&!n.includes(t.event_id)}function _e(){return"the agent's last design phase was saved before the session stopped, but not all of its files \u2014 it is sent again to write them"}function he(e){return{persist(n,t){let i=e.seqBase(),r={seq:n.seq+i,turn_id:n.turn_id,at:n.at,agent_state_schema:n.agent_state_schema,delta_items:n.delta_items,binding:n.binding,usage_total:n.usage_total,...n.base_fingerprint!==void 0?{base_fingerprint:n.base_fingerprint}:{}},a={applied_events:[...new Set([...e.handle.state.applied_events,...e.store.sessions().appliedEvents(e.handle.state.sid)])].sort(),held_receipts:e.peekHeldReceipts?.()??[],pending:{questions:n.at!=="turn"?(n.pending_questions??[]).map(G):[],proposals:e.stagedProposals?.()??[]},parent_asks:[],read_basis:e.readBasis(),corpus_cursor:e.corpusCursor(),store_watermark:e.store.serialize(e.store.head()),...(()=>{let s=n.at==="turn"&&e.awaits?P(n.delta_items):null,c=s?e.awaits(s,r.seq):null;return c?{awaits:c}:{}})(),...t?.sentUnread?.length?{sent_unread:[...t.sentUnread]}:{},...(()=>{let s=e.ingestRegistry?e.ingestRegistry():e.handle.state.ingest_registry??[],c=e.ingestSchedule?e.ingestSchedule():e.handle.state.ingest_schedule??[];return{...s.length?{ingest_registry:s}:{},...c.length?{ingest_schedule:c}:{}}})()};return e.store.sessions().persistCheckpoint(e.handle,r,a,{...e.onSoftCap?{onSoftCap:e.onSoftCap}:{},...e.onStat?{onStat:e.onStat}:{},...e.now?{now:e.now}:{}})}}}function D(e,n){return!e.checkpoint&&!n&&e.agent_state.items.length===0}var m=class extends Error{constructor(t,i,r=[]){super(`${t}: ${i}`);this.code=t;this.next=r}};function we(e){return[...new Set(["extract-agent","design-agent","owner",...e?[e.id]:[]])]}async function ke(e,n,t,i={}){let r=i.deps??{},a=S(),s=e.sessions().resume(n);try{let c=s.state.checkpoint??null,_=e.sessions().hasBase(n),w=!c&&s.state.agent_state.items.length>0;if(D(s.state,_))throw new m("SESSION_KEPT_NOTHING",`session ${n} kept nothing to resume \u2014 no checkpoint, no base and no agent snapshot; start the run again`);if(!c&&!_||w)throw new m("SESSION_V1",a.text("SESSION_V1",{sid:n}),[h(a,"next.abandon_session",{sid:n},{why:"abandon the pre-checkpoint session, then start a fresh run"})]);!c&&_&&r.onWarn?.(a.text("note.chain_recovered",{sid:n}));let o=e.sessions().loadCheckpoint(n);o.orphans.length>0&&e.sessions().gcOrphans(n,o.orphans),o.fallback&&r.onWarn?.(a.text("note.chain_truncated",{sid:n,at:o.fallback.resumableAt,lost:o.fallback.turnsLost}));let u=o.base;if(i.verb){let l=B(u.verb,i.verb,n);if(l)throw new m("WRONG_VERB",l.message,l.next)}if(i.useCase!==void 0&&i.useCase!==u.use_case&&!await(r.confirmRetarget?.(u.use_case,i.useCase)??!1))throw new m("RESUME_RETARGET_DECLINED",u.use_case?`session ${n} was designing ${u.use_case}; resuming onto ${i.useCase} needs an explicit retarget`:`session ${n} has no recorded use-case; adopting ${i.useCase} needs an explicit retarget`,u.use_case?[h(a,"next.resume_session",{verb:"design",sid:n},{why:`continue on ${u.use_case} (the session's own subject)`})]:[]);let g=o.kane,R=[],j=g?.read_basis??Object.fromEntries(Object.entries(s.state.read_basis));for(let[l,d]of Object.entries(j)){let p=t.heads.get(l)??null;p!==d&&R.push({subject:l,pinned:d,live:p})}u.uc_tip!==void 0&&r.liveUcTip!==void 0&&r.liveUcTip!==u.uc_tip&&R.push({subject:u.use_case??"use-case",pinned:u.uc_tip,live:r.liveUcTip}),r.locks?.reacquire?.(n);let v={...u.run_config,checkpoints:!0};delete v.resume;let x;if(o.pointer===null||o.agent===null)x=v;else{if(!o.agent.base_fingerprint)throw new m("CHECKPOINT_PROTOCOL",`session ${n}: chain carries no base fingerprint \u2014 cannot attest the seed rebuild`);x={...v,resend_open_ask:!0,resume:{schema:2,binding:o.agent.binding,base_fingerprint:o.agent.base_fingerprint,delta_items:o.agent.delta_items,last_seq:o.pointer.seq}}}let C=g?.pending.questions??[],E=l=>{let d=`resolveq:${n}:${l}`,p=`assumed:${n}:${l}`;return t.appliedEvents.has(d)||t.appliedEvents.has(p)||s.isApplied(d)||s.isApplied(p)},H=g&&C.length>0?C.filter(l=>!E(l.id)):s.state.pending.questions.filter(l=>!E(l.id)),A={redeliverReceipts:[],recommit:[]},k,b;if(g){let l={...g,applied_events:[...new Set([...g.applied_events,...s.state.applied_events])].sort()},d=u.verb==="design"&&U(e,l.applied_events,g.awaits)?g.awaits?.event_id:void 0,p;try{p=T(e,n,l,t,{...d?{resent:d}:{},verb:u.verb==="design"?"design":"extract",...u.use_case?{ucRef:u.use_case}:{},...N(String(o.agent?.binding?.template_version??""))>=8?{typedBlockers:!0}:{},...s.state.force_scope?.length?{ignoreGaps:new Set(s.state.force_scope)}:{},composeReceipt:(f,q,L)=>V(f,q,L),onNote:r.onWarn,...r.ownActors?{ownActors:r.ownActors}:{}})}catch(f){throw f instanceof $?new m("CHECKPOINT_PROTOCOL",`store reconciliation refused: ${f.message}`,[h(a,"next.abandon_session",{sid:n},{why:"abandon the session if the store was rebuilt"})]):f}A={redeliverReceipts:p.redeliverReceipts,recommit:p.recommit},b=p.prunedPending;let O=g.pending.proposals??[];k=(O.length>0?O:s.state.pending.proposals).filter(f=>!(typeof f.event_id=="string"&&t.appliedEvents.has(f.event_id))),(p.newlyApplied.length>0||p.prunedPending.length>0)&&s.reconcileSave({appliedEvents:p.newlyApplied,heldReceipts:[...s.state.held_receipts??[],...p.redeliverReceipts],pending:{questions:s.state.pending.questions,proposals:k,...s.state.pending.answers?.length?{answers:s.state.pending.answers}:{}}})}else{let l=s.state.pending.proposals;b=l.filter(d=>typeof d.event_id=="string"&&t.appliedEvents.has(d.event_id)),k=l.filter(d=>!(typeof d.event_id=="string"&&t.appliedEvents.has(d.event_id)))}return{kind:"v2",handle:s,base:u,view:o,kane:g,spawnConfig:x,drift:R,reconcile:A,questions:H,represent:k,prunedPending:b}}catch(c){throw s.release(),c}}export{B as a,X as b,P as c,Y as d,ce as e,de as f,pe as g,ge as h,fe as i,me as j,U as k,_e as l,he as m,D as n,m as o,we as p,ke as q};
2
+ import{b as V,e as W,f as Q}from"./chunk-3JLEDSG5.js";import{d as I,j as T}from"./chunk-LLQWEGXD.js";import{Ea as $,M as y}from"./chunk-PI7OXS62.js";import{d as N}from"./chunk-KU3YHPWZ.js";import{d as h,o as S}from"./chunk-HYJVYYAZ.js";function B(e,n,t){let i=S();return e===void 0||e===n?null:e==="extract"||e==="design"?{code:"WRONG_VERB",message:i.text("WRONG_VERB",{sid:t,verb:e}),next:[h(i,"next.resume_session",{verb:e,sid:t},{why:`this session belongs to a ${e} run`})]}:{code:"WRONG_VERB",message:`error: session ${t} belongs to a ${e} run \u2014 this command cannot resume it`,next:[]}}function X(e){return P(e)!==null}function P(e){let n=e,t=K(n);if(t<0)return null;let i=n[t].data?.tool_calls??[],r=i.map(o=>o.id),a=n.slice(t+1);if(r.length===0||a.some(o=>o?.kind!=="tool_result"))return null;let s=new Set(a.map(o=>o.data?.tool_call_id));if(!r.every(o=>s.has(o)))return null;let c=a.find(o=>o.data?.status==="ok"&&o.data?.payload?.accepted===!0);if(!c)return null;let _=i.find(o=>o.id===c.data?.tool_call_id),w=_?.arguments;return{name:typeof _?.name=="string"?_.name:"",arguments:w!==null&&typeof w=="object"?w:{}}}function Y(e){let n=e,t=K(n);if(t<0)return!1;let i=n.slice(t+1);if(i.some(s=>s?.kind!=="tool_result"))return!1;let r=new Set(i.map(s=>s.data?.tool_call_id)),a=(n[t].data?.tool_calls??[]).filter(s=>!r.has(s.id));return a.length===1&&a[0].name==="ask_user"}function K(e){for(let n=e.length-1;n>=0;n--)if(e[n]?.kind==="assistant_turn")return n;return-1}function ce(e){return{id:e.id,text:e.question,risk:["high","med","low"].includes(e.risk)?e.risk:"med",rationale:e.rationale,options:e.options.map(n=>({label:n.label,detail:n.description??""})),recommended_index:e.recommendedOptionIndex,allow_free_text:e.allowFreeText,kind:e.kind,consequence:e.consequence,evidence_count:e.evidence_count,multi_select:e.multiSelect}}function G(e){return{id:e.id,header:e.kind??"question",question:e.text,kind:e.kind??"clarify",multiSelect:e.multi_select??!1,options:e.options.map((n,t)=>({id:`o${t}`,label:n.label,description:n.detail||void 0})),recommendedOptionIndex:e.recommended_index,risk:e.risk,rationale:e.rationale,consequence:e.consequence??"",evidence_count:e.evidence_count,allowFreeText:e.allow_free_text}}function de(e,n,t){let i=n.pending.questions.map(G),r=W(e.state.pending.answers).filter(a=>n.pending.questions.some(s=>s.id===a.id&&Q(a,s)));e.save({agent_state:n.agent_state,pending:{questions:i,proposals:n.pending.proposals??[],...r.length>0?{answers:r}:{}},assumed:n.assumed.map(a=>({questionId:a.question_id,optionId:a.option_id,flagged:!0,eventId:`assumed:${n.sid}:${a.question_id}`}))}),t?.(),e.release(),I(e.state.sid)}function pe(e,n,t,i){if(t.name.startsWith("finalize"))return{call:t.name,event_id:`${e}:ckpt:${i}`};let r=t.arguments.ops;return Array.isArray(r)&&r.length>0&&n?{call:t.name,event_prefix:`chatop:${n}:s${i}:`}:null}function ge(e,n,t){if(!t)return!0;let i=y(e).appliedEvents;if(t.event_id!==void 0)return i.has(t.event_id)||n.includes(t.event_id);let r=t.event_prefix??"";for(let a of i)if(a.startsWith(r))return!0;return n.some(a=>a.startsWith(r))}function fe(e){return`the agent's last ${e==="finalize_design"?"design phase was":e.startsWith("finalize")?"proposal was":"changes were"} not saved before the session stopped \u2014 it is sent again`}function me(e){return e===1?"your last message was sent again":`your last ${e} messages were sent again`}function U(e,n,t){return t?.call!=="finalize_design"||t.event_id===void 0?!1:y(e).appliedEvents.has(t.event_id)&&!n.includes(t.event_id)}function _e(){return"the agent's last design phase was saved before the session stopped, but not all of its files \u2014 it is sent again to write them"}function he(e){return{persist(n,t){let i=e.seqBase(),r={seq:n.seq+i,turn_id:n.turn_id,at:n.at,agent_state_schema:n.agent_state_schema,delta_items:n.delta_items,binding:n.binding,usage_total:n.usage_total,...n.base_fingerprint!==void 0?{base_fingerprint:n.base_fingerprint}:{}},a={applied_events:[...new Set([...e.handle.state.applied_events,...e.store.sessions().appliedEvents(e.handle.state.sid)])].sort(),held_receipts:e.peekHeldReceipts?.()??[],pending:{questions:n.at!=="turn"?(n.pending_questions??[]).map(G):[],proposals:e.stagedProposals?.()??[]},parent_asks:[],read_basis:e.readBasis(),corpus_cursor:e.corpusCursor(),store_watermark:e.store.serialize(e.store.head()),...(()=>{let s=n.at==="turn"&&e.awaits?P(n.delta_items):null,c=s?e.awaits(s,r.seq):null;return c?{awaits:c}:{}})(),...t?.sentUnread?.length?{sent_unread:[...t.sentUnread]}:{},...(()=>{let s=e.ingestRegistry?e.ingestRegistry():e.handle.state.ingest_registry??[],c=e.ingestSchedule?e.ingestSchedule():e.handle.state.ingest_schedule??[];return{...s.length?{ingest_registry:s}:{},...c.length?{ingest_schedule:c}:{}}})()};return e.store.sessions().persistCheckpoint(e.handle,r,a,{...e.onSoftCap?{onSoftCap:e.onSoftCap}:{},...e.onStat?{onStat:e.onStat}:{},...e.now?{now:e.now}:{}})}}}function D(e,n){return!e.checkpoint&&!n&&e.agent_state.items.length===0}var m=class extends Error{constructor(t,i,r=[]){super(`${t}: ${i}`);this.code=t;this.next=r}};function we(e){return[...new Set(["extract-agent","design-agent","owner",...e?[e.id]:[]])]}async function ke(e,n,t,i={}){let r=i.deps??{},a=S(),s=e.sessions().resume(n);try{let c=s.state.checkpoint??null,_=e.sessions().hasBase(n),w=!c&&s.state.agent_state.items.length>0;if(D(s.state,_))throw new m("SESSION_KEPT_NOTHING",`session ${n} kept nothing to resume \u2014 no checkpoint, no base and no agent snapshot; start the run again`);if(!c&&!_||w)throw new m("SESSION_V1",a.text("SESSION_V1",{sid:n}),[h(a,"next.abandon_session",{sid:n},{why:"abandon the pre-checkpoint session, then start a fresh run"})]);!c&&_&&r.onWarn?.(a.text("note.chain_recovered",{sid:n}));let o=e.sessions().loadCheckpoint(n);o.orphans.length>0&&e.sessions().gcOrphans(n,o.orphans),o.fallback&&r.onWarn?.(a.text("note.chain_truncated",{sid:n,at:o.fallback.resumableAt,lost:o.fallback.turnsLost}));let u=o.base;if(i.verb){let l=B(u.verb,i.verb,n);if(l)throw new m("WRONG_VERB",l.message,l.next)}if(i.useCase!==void 0&&i.useCase!==u.use_case&&!await(r.confirmRetarget?.(u.use_case,i.useCase)??!1))throw new m("RESUME_RETARGET_DECLINED",u.use_case?`session ${n} was designing ${u.use_case}; resuming onto ${i.useCase} needs an explicit retarget`:`session ${n} has no recorded use-case; adopting ${i.useCase} needs an explicit retarget`,u.use_case?[h(a,"next.resume_session",{verb:"design",sid:n},{why:`continue on ${u.use_case} (the session's own subject)`})]:[]);let g=o.kane,R=[],j=g?.read_basis??Object.fromEntries(Object.entries(s.state.read_basis));for(let[l,d]of Object.entries(j)){let p=t.heads.get(l)??null;p!==d&&R.push({subject:l,pinned:d,live:p})}u.uc_tip!==void 0&&r.liveUcTip!==void 0&&r.liveUcTip!==u.uc_tip&&R.push({subject:u.use_case??"use-case",pinned:u.uc_tip,live:r.liveUcTip}),r.locks?.reacquire?.(n);let v={...u.run_config,checkpoints:!0};delete v.resume;let x;if(o.pointer===null||o.agent===null)x=v;else{if(!o.agent.base_fingerprint)throw new m("CHECKPOINT_PROTOCOL",`session ${n}: chain carries no base fingerprint \u2014 cannot attest the seed rebuild`);x={...v,resend_open_ask:!0,resume:{schema:2,binding:o.agent.binding,base_fingerprint:o.agent.base_fingerprint,delta_items:o.agent.delta_items,last_seq:o.pointer.seq}}}let C=g?.pending.questions??[],E=l=>{let d=`resolveq:${n}:${l}`,p=`assumed:${n}:${l}`;return t.appliedEvents.has(d)||t.appliedEvents.has(p)||s.isApplied(d)||s.isApplied(p)},H=g&&C.length>0?C.filter(l=>!E(l.id)):s.state.pending.questions.filter(l=>!E(l.id)),A={redeliverReceipts:[],recommit:[]},k,b;if(g){let l={...g,applied_events:[...new Set([...g.applied_events,...s.state.applied_events])].sort()},d=u.verb==="design"&&U(e,l.applied_events,g.awaits)?g.awaits?.event_id:void 0,p;try{p=T(e,n,l,t,{...d?{resent:d}:{},verb:u.verb==="design"?"design":"extract",...u.use_case?{ucRef:u.use_case}:{},...N(String(o.agent?.binding?.template_version??""))>=8?{typedBlockers:!0}:{},...s.state.force_scope?.length?{ignoreGaps:new Set(s.state.force_scope)}:{},composeReceipt:(f,q,L)=>V(f,q,L),onNote:r.onWarn,...r.ownActors?{ownActors:r.ownActors}:{}})}catch(f){throw f instanceof $?new m("CHECKPOINT_PROTOCOL",`store reconciliation refused: ${f.message}`,[h(a,"next.abandon_session",{sid:n},{why:"abandon the session if the store was rebuilt"})]):f}A={redeliverReceipts:p.redeliverReceipts,recommit:p.recommit},b=p.prunedPending;let O=g.pending.proposals??[];k=(O.length>0?O:s.state.pending.proposals).filter(f=>!(typeof f.event_id=="string"&&t.appliedEvents.has(f.event_id))),(p.newlyApplied.length>0||p.prunedPending.length>0)&&s.reconcileSave({appliedEvents:p.newlyApplied,heldReceipts:[...s.state.held_receipts??[],...p.redeliverReceipts],pending:{questions:s.state.pending.questions,proposals:k,...s.state.pending.answers?.length?{answers:s.state.pending.answers}:{}}})}else{let l=s.state.pending.proposals;b=l.filter(d=>typeof d.event_id=="string"&&t.appliedEvents.has(d.event_id)),k=l.filter(d=>!(typeof d.event_id=="string"&&t.appliedEvents.has(d.event_id)))}return{kind:"v2",handle:s,base:u,view:o,kane:g,spawnConfig:x,drift:R,reconcile:A,questions:H,represent:k,prunedPending:b}}catch(c){throw s.release(),c}}export{B as a,X as b,P as c,Y as d,ce as e,de as f,pe as g,ge as h,fe as i,me as j,U as k,_e as l,he as m,D as n,m as o,we as p,ke as q};
@@ -0,0 +1,7 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as A}from"./chunk-TDPWFYTJ.js";import{b as T}from"./chunk-BHQIH2FE.js";import{d as x}from"./chunk-I52NWH4U.js";import{a as S}from"./chunk-MMBBQ4OZ.js";import{a as y}from"./chunk-TD6GCEIK.js";import{a as m}from"./chunk-FI2DVNRT.js";import{f as R}from"./chunk-A7RJQJNT.js";import{d as g,i as E}from"./chunk-FAMQ4DHU.js";import{spawn as U,execSync as L}from"child_process";import{appendFileSync as P,existsSync as f,mkdirSync as h}from"fs";import{homedir as V}from"os";import{join as D,resolve as s,dirname as v,delimiter as M}from"path";import{fileURLToPath as k}from"url";import{createInterface as I}from"readline";async function*N(e){let n=I({input:e,crlfDelay:1/0});for await(let r of n){let o=r.trim();if(o)try{let i=JSON.parse(o);i&&typeof i.type=="string"&&(yield i)}catch{}}}function O(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 w(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(k(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"]},o=`${process.platform}-${process.arch}`,i=r[o];if(i)for(let t of i){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 C(e){return e?D(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=C(e.sessionId);if(r)try{h(v(r),{recursive:!0})}catch{}let o=1e5,i="";n.stderr.on("data",u=>{if(i+=u.toString(),i.length>o&&(i=i.slice(-o)),r)try{P(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,_)=>{d=p,l=_?String(_):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:()=>i,getExitCode:()=>d,getExitSignal:()=>l,exited:t}}async function G(e,n){if(!n?.platform||!n.target)return;if(R(n.target)){e.TESTMU_RUN_TARGET??="cloud",e.LT_HUB_URL??=m(e.TESTMUAI_ENV==="stage"?"stage":"prod").mobileHubUrl;return}let r=await x(n.platform)?.toolEnv(n.target)??{dirs:[]};if(r.dirs.length>0&&(e.PATH=[...r.dirs,e.PATH??""].filter(Boolean).join(M)),r.appiumHome&&(e.APPIUM_HOME=r.appiumHome),r.wdaRoot&&(e.TESTMU_IOS_WDA_DERIVED_DATA=r.wdaRoot),n.platform==="android"){let o=S();o&&(e.PATH=[o.platformToolsDir,e.PATH??""].filter(Boolean).join(M),e.ANDROID_HOME=o.root,e.ANDROID_SDK_ROOT=o.root)}}function j(e){let n={...process.env,...y(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 o=O(e.mode??"testing");Object.assign(n,o.set);for(let a of o.unset)delete n[a];let i=new T().load(),d=b(e.assertionMode??(i.assertion_mode==="visual"?"visual":"dom"));Object.assign(n,d.set);for(let a of d.unset)delete n[a];let l=e.finalValidation??i.final_validation,t=w(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),o=A();o!==void 0&&e.ap_mode===void 0&&(e.ap_mode=o),e.telemetry_proxy_url===void 0&&process.env.KANE_TELEMETRY!=="0"&&(e.telemetry_proxy_url=E),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:g,files_url:e.tmsBaseUrl.replace(/\/api\/?$/,"")}}async function ue(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 o=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(o,e.device),W(e,{environment:n?.environment});let i=K({env:o,runner:r,log:n?.log,sessionId:e.session_id}),d=i.child;d.stdin.write(JSON.stringify(e)+`
4
+ `);let l=C(e.session_id);if(l)try{h(v(l),{recursive:!0}),P(l,`--- runner spawn ${new Date().toISOString()} run_index=${e.run_index} ---
5
+ `)}catch{}return{child:d,events:i.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 i.getStderr()},get exitCode(){return i.getExitCode()},get exitSignal(){return i.getExitSignal()},exited:i.exited}}export{H as a,K as b,G as c,j as d,W as e,$ as f,ue as g};