@testmuai/kane-cli 0.8.12 → 0.8.14

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 (308) hide show
  1. package/dist/{ChatSurface-DALSIICW.js → ChatSurface-AVL3TJA2.js} +3 -3
  2. package/dist/{ChromeProfilePicker-ZMVZH3AK.js → ChromeProfilePicker-WJZJOZ6Z.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-K66H7YE6.js → CliFeedbackPrompt-65BQF5G5.js} +1 -1
  4. package/dist/{CliUploadProgress-5DZHZY4M.js → CliUploadProgress-HEBZYKGN.js} +1 -1
  5. package/dist/{ConfigView-S5KBV62S.js → ConfigView-JEVQ2SO4.js} +1 -1
  6. package/dist/EvidenceViewOffer-5MB4ZXKM.js +2 -0
  7. package/dist/FolderPicker-SYFXH6D5.js +2 -0
  8. package/dist/{InfoBox-7PAM2FQH.js → InfoBox-KM5DLBCV.js} +1 -1
  9. package/dist/{LinksBox-2NVZ3FHJ.js → LinksBox-FQA36GTV.js} +1 -1
  10. package/dist/{ProfilesView-SIUBF7IU.js → ProfilesView-76KGHTMK.js} +1 -1
  11. package/dist/{ProjectPicker-5NI554X3.js → ProjectPicker-65YOU46H.js} +1 -1
  12. package/dist/{SaveSessionPrompt-5OULBV5N.js → SaveSessionPrompt-QD6BNTWO.js} +1 -1
  13. package/dist/ScrollbackTap-QHJOFYMC.js +2 -0
  14. package/dist/SingleShotApp-U54ETXS3.js +2 -0
  15. package/dist/{SummaryBox-GTGF3CBO.js → SummaryBox-N2B6DUDD.js} +1 -1
  16. package/dist/TestMdRunView-WA4TC5PT.js +2 -0
  17. package/dist/{TestrunEvidenceTable-7WBCOGYW.js → TestrunEvidenceTable-3WLQVTF4.js} +1 -1
  18. package/dist/{WhoamiView-E2SVBHLC.js → WhoamiView-T26HA4ZZ.js} +1 -1
  19. package/dist/agent-parse-XMWVKCRD.js +2 -0
  20. package/dist/{app-download-SAXSYXIV.js → app-download-XKZWFMEK.js} +1 -1
  21. package/dist/attach-target-V6LECVES.js +2 -0
  22. package/dist/{auth-3LLVDHOJ.js → auth-PPJANIMZ.js} +1 -1
  23. package/dist/{binary-WSMIRJNC.js → binary-DKWWODT2.js} +1 -1
  24. package/dist/bind-62AZYFAY.js +15 -0
  25. package/dist/{bootstrap-QTVHGL45.js → bootstrap-6IJNZIPT.js} +1 -1
  26. package/dist/bridge-X5DEJL6F.js +2 -0
  27. package/dist/{changelog-CNYWOB2V.js → changelog-UTGJ7FSP.js} +1 -1
  28. package/dist/chat-committer-HDE3TP5I.js +2 -0
  29. package/dist/chat-controller-3EPK7UZG.js +2 -0
  30. package/dist/chunk-22QIVSQR.js +29 -0
  31. package/dist/{chunk-CQ3ZQ5UK.js → chunk-2BFXT7VQ.js} +3 -3
  32. package/dist/{chunk-AHRL4E3M.js → chunk-2RMHDOP4.js} +1 -1
  33. package/dist/{chunk-HPUQJRDX.js → chunk-3BHRGHIZ.js} +1 -1
  34. package/dist/{chunk-EEFZXZTZ.js → chunk-3IXEARDX.js} +1 -1
  35. package/dist/chunk-3N6IAVD5.js +7 -0
  36. package/dist/{chunk-3OU2F34I.js → chunk-3SPOJWRA.js} +1 -1
  37. package/dist/chunk-3YX3RQXO.js +2 -0
  38. package/dist/chunk-42FHKRPA.js +4 -0
  39. package/dist/{chunk-FBYB3SRE.js → chunk-4BBDKWM3.js} +1 -1
  40. package/dist/{chunk-UDFDTFBL.js → chunk-4K5XTIJ6.js} +1 -1
  41. package/dist/chunk-52WM3XYO.js +4 -0
  42. package/dist/{chunk-H6VS5RYO.js → chunk-53MPG2J3.js} +1 -1
  43. package/dist/{chunk-R7QAS6LZ.js → chunk-55YDTPB7.js} +1 -1
  44. package/dist/{chunk-IDX3TOPY.js → chunk-5LJRZI7S.js} +1 -1
  45. package/dist/chunk-66MOZKD2.js +2 -0
  46. package/dist/chunk-6F6YI3ZG.js +2 -0
  47. package/dist/chunk-6LGED4FC.js +35 -0
  48. package/dist/chunk-73ULUGBM.js +5 -0
  49. package/dist/{chunk-X6APRDUM.js → chunk-75I46VTM.js} +2 -2
  50. package/dist/{chunk-5FYO3PFG.js → chunk-7L25ZNNP.js} +1 -1
  51. package/dist/chunk-7O54QURK.js +2 -0
  52. package/dist/{chunk-4T35SA2O.js → chunk-7RAI77XD.js} +1 -1
  53. package/dist/{chunk-7NXHVC7G.js → chunk-AC7BPO4X.js} +1 -1
  54. package/dist/chunk-AHXOKBVE.js +7 -0
  55. package/dist/{chunk-DNNZ353O.js → chunk-ALCE5RLK.js} +1 -1
  56. package/dist/{chunk-5AHOVOWV.js → chunk-ARG56PJG.js} +1 -1
  57. package/dist/chunk-B2ZGG7WM.js +2 -0
  58. package/dist/{chunk-GNAPBOAJ.js → chunk-BAKJPQGU.js} +1 -1
  59. package/dist/chunk-BJYGWXVP.js +52 -0
  60. package/dist/chunk-C74ABM24.js +2 -0
  61. package/dist/chunk-CGT4NFQN.js +8 -0
  62. package/dist/{chunk-EV64VI66.js → chunk-CRZUBDJ3.js} +1 -1
  63. package/dist/{chunk-M4WSRYRA.js → chunk-DA57DXCF.js} +1 -1
  64. package/dist/chunk-DHJSM5DT.js +2 -0
  65. package/dist/{chunk-UZXCCO7V.js → chunk-EMSLJTYN.js} +1 -1
  66. package/dist/{chunk-2LXJ2ZM3.js → chunk-FFFB5BXL.js} +1 -1
  67. package/dist/{chunk-WIAZN7G4.js → chunk-FFVNISYH.js} +1 -1
  68. package/dist/chunk-FQNQVC5O.js +5 -0
  69. package/dist/{chunk-NSD2H67E.js → chunk-GESG672R.js} +1 -1
  70. package/dist/{chunk-FHYG3QLL.js → chunk-GKZ2KVE6.js} +1 -1
  71. package/dist/chunk-GP7WD4UY.js +4 -0
  72. package/dist/{chunk-7R5K4IGS.js → chunk-GPIXV7AV.js} +2 -2
  73. package/dist/chunk-H6TNBKGR.js +5 -0
  74. package/dist/chunk-HOA4VWSD.js +5 -0
  75. package/dist/chunk-IE3OO5GI.js +2 -0
  76. package/dist/chunk-IICQ5KRD.js +5 -0
  77. package/dist/{chunk-VG7BTA5G.js → chunk-IQ7GPETF.js} +1 -1
  78. package/dist/{chunk-AFNDJK2A.js → chunk-IQ7NGOAT.js} +1 -1
  79. package/dist/{chunk-F2CET54H.js → chunk-J7NRD4Q7.js} +1 -1
  80. package/dist/{chunk-FAREJ4P2.js → chunk-JH6E632O.js} +1 -1
  81. package/dist/{chunk-L7GAZQYL.js → chunk-JJJSDDQ2.js} +1 -1
  82. package/dist/{chunk-XWO5MDEU.js → chunk-JKX57HA7.js} +1 -1
  83. package/dist/{chunk-LLY7TQSI.js → chunk-K7K23DIQ.js} +1 -1
  84. package/dist/chunk-KN65CUNT.js +15 -0
  85. package/dist/{chunk-YF26DH4Z.js → chunk-KOL6ZWOQ.js} +1 -1
  86. package/dist/{chunk-COVIEKZN.js → chunk-KOPP4CJW.js} +1 -1
  87. package/dist/chunk-KZG4E5RM.js +2 -0
  88. package/dist/{chunk-GRDYYYIQ.js → chunk-L4M7753M.js} +1 -1
  89. package/dist/{chunk-ZVJGHQNG.js → chunk-L6MOO4WT.js} +1 -1
  90. package/dist/chunk-LBNADEQN.js +8 -0
  91. package/dist/{chunk-HWHLKBUT.js → chunk-LL5DQO6V.js} +1 -1
  92. package/dist/chunk-LNV7C2YO.js +6 -0
  93. package/dist/{chunk-3N2YOHD6.js → chunk-LR5DJ6EN.js} +1 -1
  94. package/dist/{chunk-ZXN67F4U.js → chunk-M7DN6FO3.js} +1 -1
  95. package/dist/chunk-MLRO7OH3.js +9 -0
  96. package/dist/{chunk-ZZI4Y3CX.js → chunk-MNE5VMHT.js} +1 -1
  97. package/dist/{chunk-3G3LY6BM.js → chunk-N7ZRF5K3.js} +1 -1
  98. package/dist/{chunk-MMQLVGUJ.js → chunk-NBMLBCJ3.js} +1 -1
  99. package/dist/{chunk-WHYEXCTG.js → chunk-NDCRJXYF.js} +1 -1
  100. package/dist/{chunk-4E4GJPEM.js → chunk-NOLYYHVG.js} +1 -1
  101. package/dist/{chunk-IWVA37B6.js → chunk-O25AL4B7.js} +1 -1
  102. package/dist/{chunk-2MTAXT2U.js → chunk-O2APH6TZ.js} +1 -1
  103. package/dist/{chunk-KAZGHWGK.js → chunk-O3XBIURC.js} +1 -1
  104. package/dist/{chunk-APZCLVZD.js → chunk-O5AS2ZIX.js} +1 -1
  105. package/dist/{chunk-43DM2I6Q.js → chunk-O6U2HU5M.js} +1 -1
  106. package/dist/{chunk-7KAPHA56.js → chunk-OH2NSBO6.js} +1 -1
  107. package/dist/{chunk-3CCD434H.js → chunk-OO5GMBVI.js} +1 -1
  108. package/dist/chunk-OPL2MIQG.js +2 -0
  109. package/dist/chunk-P3JUE2RM.js +17 -0
  110. package/dist/{chunk-QZRHXGNI.js → chunk-PGU64EWQ.js} +1 -1
  111. package/dist/{chunk-24QPDHRD.js → chunk-Q7XBMBMR.js} +1 -1
  112. package/dist/{chunk-4TZSEC2C.js → chunk-QJ5O27SJ.js} +1 -1
  113. package/dist/{chunk-YTAAF62A.js → chunk-QPUVOVD7.js} +1 -1
  114. package/dist/{chunk-5A4QG7ZM.js → chunk-RBHQXWR7.js} +1 -1
  115. package/dist/{chunk-G52YPXKT.js → chunk-RH6KFHJB.js} +1 -1
  116. package/dist/{chunk-ASYWKYTQ.js → chunk-RQLU4NDG.js} +12 -12
  117. package/dist/{chunk-U27OWZPW.js → chunk-SFTFHFG3.js} +7 -7
  118. package/dist/{chunk-H6NHARB4.js → chunk-SGHP44WS.js} +1 -1
  119. package/dist/{chunk-U2CIXGZR.js → chunk-SQDQADWD.js} +1 -1
  120. package/dist/{chunk-IE4BCGUE.js → chunk-SX56MVUO.js} +1 -1
  121. package/dist/{chunk-O5U6EAL3.js → chunk-TCAHDVII.js} +1 -1
  122. package/dist/chunk-TNBF5OMZ.js +2 -0
  123. package/dist/chunk-TU6IMGWO.js +2 -0
  124. package/dist/{chunk-5G22NOZK.js → chunk-UHT5SVP5.js} +1 -1
  125. package/dist/{chunk-L2BCQQLJ.js → chunk-UXH3RMQ7.js} +1 -1
  126. package/dist/{chunk-DYXYNH6X.js → chunk-VNFCX2SH.js} +1 -1
  127. package/dist/{chunk-O7U5BVX5.js → chunk-WBHSPN55.js} +2 -2
  128. package/dist/chunk-WILT62DP.js +16 -0
  129. package/dist/{chunk-I57TM22L.js → chunk-WOA7VCGA.js} +1 -1
  130. package/dist/{chunk-SA6EDKUF.js → chunk-WR42Q3HU.js} +1 -1
  131. package/dist/chunk-X5276I5H.js +9 -0
  132. package/dist/{chunk-75HF3GPO.js → chunk-X74PP5NJ.js} +1 -1
  133. package/dist/{chunk-3XWKKSIM.js → chunk-XGHMZJGI.js} +2 -2
  134. package/dist/{chunk-XS2LZFCH.js → chunk-YCH7H7JX.js} +1 -1
  135. package/dist/{chunk-IGW77FMB.js → chunk-YHR2YAN5.js} +1 -1
  136. package/dist/chunk-YHVG7V3E.js +21 -0
  137. package/dist/chunk-YLQHY4A7.js +2 -0
  138. package/dist/{chunk-KGKJU27A.js → chunk-YYYQ5MVD.js} +1 -1
  139. package/dist/chunk-ZA4M4O7E.js +27 -0
  140. package/dist/chunk-ZKEOPIQ3.js +9 -0
  141. package/dist/chunk-ZUZ6QJRA.js +23 -0
  142. package/dist/{chunk-4ASRA7CD.js → chunk-ZWHPIR2Z.js} +2 -2
  143. package/dist/chunk-ZZTZJPT2.js +88 -0
  144. package/dist/committer-IYQPXG6C.js +2 -0
  145. package/dist/{config-HUK7V364.js → config-3AKWRTFS.js} +1 -1
  146. package/dist/{controller-client-OB4WD2C4.js → controller-client-ZF5IXRUV.js} +1 -1
  147. package/dist/cover-cmd-ZLAWMEC2.js +3 -0
  148. package/dist/{credentials-6DP4KAMJ.js → credentials-Q4WH5CBN.js} +1 -1
  149. package/dist/{deps-bundle-PZNXSKLC.js → deps-bundle-RVZK6LZJ.js} +1 -1
  150. package/dist/{deps-resolve-62XK3LKV.js → deps-resolve-6F2U4TJP.js} +1 -1
  151. package/dist/design-committer-J57IAAA5.js +2 -0
  152. package/dist/dispatch-46BETGXY.js +2 -0
  153. package/dist/{doctor-ZQQ4VMPY.js → doctor-WRPG56HH.js} +1 -1
  154. package/dist/docx-convert-WPZS6OIC.js +2 -0
  155. package/dist/{dossier-Y6TJWFZU.js → dossier-UGJMYYAB.js} +1 -1
  156. package/dist/evidence-XWR32HWP.js +2 -0
  157. package/dist/evolve-cmd-27ZQN6YB.js +2 -0
  158. package/dist/explain-H5HJEDEF.js +2 -0
  159. package/dist/explain-cmd-JCJTXVZY.js +9 -0
  160. package/dist/{explain-cmd-XCRO4AS6.js → explain-cmd-R45I5MT7.js} +1 -1
  161. package/dist/extract-bind-D5BYYGYA.js +14 -0
  162. package/dist/{extract-cmd-IPBCCR3T.js → extract-cmd-CCYW7FIY.js} +3 -3
  163. package/dist/feeder-RSHMGW6B.js +2 -0
  164. package/dist/gaps-cmd-3VJKQ25D.js +3 -0
  165. package/dist/{generate-headless-CLMSXEAS.js → generate-headless-2M6UT3IK.js} +2 -2
  166. package/dist/headless-io-3A3BZVQ5.js +2 -0
  167. package/dist/index.js +206 -164
  168. package/dist/ingest-QGLVY7ND.js +2 -0
  169. package/dist/ingest-cmd-HVTUK264.js +2 -0
  170. package/dist/install-5WJLE7XT.js +2 -0
  171. package/dist/interactive-bind-OJCYNQPI.js +26 -0
  172. package/dist/lifecycle-cmd-GWFGUGTC.js +2 -0
  173. package/dist/{list-cmd-V3HJ5K4O.js → list-cmd-AXDW64OY.js} +1 -1
  174. package/dist/list-commands-YNZ6EFIF.js +2 -0
  175. package/dist/{locks-cmd-CSVSWY2Y.js → locks-cmd-67OHQZNV.js} +1 -1
  176. package/dist/logical-ids-DN6IZSUM.js +2 -0
  177. package/dist/login-flow-PRXFPRYZ.js +2 -0
  178. package/dist/maintenance-cmd-QEMK6YNV.js +2 -0
  179. package/dist/{mobile-prompts-WJVFBWW5.js → mobile-prompts-OXHA5GHJ.js} +1 -1
  180. package/dist/{objective-variable-gate-GCQYYM77.js → objective-variable-gate-76GYUHEP.js} +1 -1
  181. package/dist/open-provider-E5VUGFNE.js +2 -0
  182. package/dist/pdf-convert-5H4HQNN3.js +2 -0
  183. package/dist/{persist-recorded-session-MHLD4A32.js → persist-recorded-session-KWPH37HI.js} +1 -1
  184. package/dist/phase-seed-HKJ2EF7R.js +2 -0
  185. package/dist/pipeline-A2OGF4XW.js +2 -0
  186. package/dist/prepare-target-P6BWJZBZ.js +2 -0
  187. package/dist/readmodel-IBFRM6EO.js +2 -0
  188. package/dist/reconcile-cmd-V7TDYETT.js +2 -0
  189. package/dist/reconcile-deps-X6IGH4CA.js +4 -0
  190. package/dist/reconcile-engine-OGXSIE7O.js +2 -0
  191. package/dist/{recording-banner-4H4AL6YN.js → recording-banner-IZWN2XFY.js} +1 -1
  192. package/dist/records-TJJJWBUD.js +2 -0
  193. package/dist/registry-GOLIFVK5.js +2 -0
  194. package/dist/{require-project-folder-G2G4WKWW.js → require-project-folder-PEEUITK6.js} +1 -1
  195. package/dist/{resolve-run-intent-MZRPYN4V.js → resolve-run-intent-JGXXE45Y.js} +1 -1
  196. package/dist/{resolver-X5NHNX5O.js → resolver-TY7XLJBN.js} +1 -1
  197. package/dist/revert-6BBBK3I4.js +2 -0
  198. package/dist/review-cmd-74YTPT7E.js +5 -0
  199. package/dist/run-DN4XARP2.js +2 -0
  200. package/dist/run-GRYWYKIH.js +2 -0
  201. package/dist/{run-test-md-4VRH7FU5.js → run-test-md-DFCKCQ4T.js} +2 -2
  202. package/dist/sessions-NH7WQWMX.js +2 -0
  203. package/dist/{sessions-cmd-VDQGRBEM.js → sessions-cmd-DV442ZCY.js} +1 -1
  204. package/dist/{skill-installer-WPW6NDCR.js → skill-installer-GRU3HOYF.js} +1 -1
  205. package/dist/{spawner-R3XOP3GP.js → spawner-LNMD4NJF.js} +1 -1
  206. package/dist/store-guard-Q4MYZQHF.js +2 -0
  207. package/dist/structured-answers-NADW6D44.js +5 -0
  208. package/dist/sync-cmd-H6Y5EB3L.js +2 -0
  209. package/dist/sync-setup-THGRBKTA.js +2 -0
  210. package/dist/sync-setup-ui-RC727VK6.js +3 -0
  211. package/dist/tcg-generate-SZZ7MJXY.js +2 -0
  212. package/dist/testmd-actions-MRIUOOXO.js +2 -0
  213. package/dist/testmd-sync-UYVJ47BN.js +2 -0
  214. package/dist/token-refresh-KN5JK2U4.js +2 -0
  215. package/dist/{validate-basic-YNGP5JFB.js → validate-basic-RCBEELSB.js} +1 -1
  216. package/dist/{variable-receipt-2VCUG7NN.js → variable-receipt-JHRW73Z6.js} +1 -1
  217. package/dist/verdicts-XFXDRND4.js +2 -0
  218. package/dist/{version-check-GUGRBTIH.js → version-check-Z774UWW3.js} +1 -1
  219. package/dist/{view-cmd-SXXNDZIC.js → view-cmd-I4LQGJ2X.js} +1 -1
  220. package/dist/walk-session-FP52IGLB.js +2 -0
  221. package/dist/with-telemetry-P6RUPWBH.js +2 -0
  222. package/package.json +12 -11
  223. package/dist/EvidenceViewOffer-UACWB3YJ.js +0 -2
  224. package/dist/FolderPicker-YH5TKMX3.js +0 -2
  225. package/dist/ScrollbackTap-Q3IOKNMS.js +0 -2
  226. package/dist/SingleShotApp-LA3EMPUK.js +0 -2
  227. package/dist/TestMdRunView-5MNKJJMS.js +0 -2
  228. package/dist/bind-A3M4PV4V.js +0 -12
  229. package/dist/bridge-E2C5VV3H.js +0 -2
  230. package/dist/chat-committer-RAOIL2T6.js +0 -2
  231. package/dist/chat-controller-YJCNU76T.js +0 -2
  232. package/dist/chunk-4O6XBS5G.js +0 -5
  233. package/dist/chunk-54JZ6VEW.js +0 -4
  234. package/dist/chunk-5DT7PIGB.js +0 -5
  235. package/dist/chunk-5KLDW3ZW.js +0 -85
  236. package/dist/chunk-6A47PRDS.js +0 -4
  237. package/dist/chunk-6FCPS2VT.js +0 -4
  238. package/dist/chunk-7RFGO3TH.js +0 -2
  239. package/dist/chunk-DBIBROYW.js +0 -5
  240. package/dist/chunk-DPUV6OSP.js +0 -2
  241. package/dist/chunk-G2Q2TP3O.js +0 -9
  242. package/dist/chunk-IAHKTEET.js +0 -2
  243. package/dist/chunk-IVQX3AKL.js +0 -4
  244. package/dist/chunk-JDGBRACP.js +0 -16
  245. package/dist/chunk-JOATASPP.js +0 -4
  246. package/dist/chunk-KRL2BDI5.js +0 -8
  247. package/dist/chunk-N7Z7BQYO.js +0 -3
  248. package/dist/chunk-NJJQL54J.js +0 -2
  249. package/dist/chunk-NP3VGFZM.js +0 -26
  250. package/dist/chunk-NVGBE2DR.js +0 -2
  251. package/dist/chunk-OS4VSIHT.js +0 -4
  252. package/dist/chunk-OZMYKG6E.js +0 -6
  253. package/dist/chunk-QQ5MHSSY.js +0 -2
  254. package/dist/chunk-RV7Q4RUV.js +0 -7
  255. package/dist/chunk-SACCB44S.js +0 -21
  256. package/dist/chunk-T4OJX2GZ.js +0 -15
  257. package/dist/chunk-TLFNUXKS.js +0 -2
  258. package/dist/chunk-UH2ZTX4E.js +0 -2
  259. package/dist/chunk-VDM3TWF6.js +0 -17
  260. package/dist/chunk-W3Z7AZNT.js +0 -4
  261. package/dist/chunk-WMVPJWWA.js +0 -37
  262. package/dist/chunk-XMTSHHYQ.js +0 -4
  263. package/dist/chunk-ZVZHE7KH.js +0 -27
  264. package/dist/committer-C6UCDYMC.js +0 -2
  265. package/dist/cover-cmd-5LPHIOSI.js +0 -3
  266. package/dist/design-committer-UPC6NZUF.js +0 -2
  267. package/dist/dispatch-7JCKGQVC.js +0 -2
  268. package/dist/docx-convert-BIV5T7F5.js +0 -2
  269. package/dist/evidence-YAXIWZ6A.js +0 -2
  270. package/dist/evolve-cmd-5ACHYQPE.js +0 -2
  271. package/dist/explain-3HAZY7Q6.js +0 -2
  272. package/dist/explain-cmd-RMJPXD4U.js +0 -9
  273. package/dist/extract-bind-BF2G6AS6.js +0 -10
  274. package/dist/feeder-IOR3XRNF.js +0 -2
  275. package/dist/gaps-cmd-3WXL6PAW.js +0 -3
  276. package/dist/headless-io-66RG5NN5.js +0 -2
  277. package/dist/ingest-TTUQ7UDK.js +0 -2
  278. package/dist/ingest-cmd-KP5M6XTA.js +0 -2
  279. package/dist/install-5VWCH5GW.js +0 -2
  280. package/dist/interactive-bind-MOV2VWHJ.js +0 -25
  281. package/dist/lifecycle-cmd-KSMETBPP.js +0 -2
  282. package/dist/list-commands-KUDSKVP5.js +0 -2
  283. package/dist/logical-ids-MLXAH45L.js +0 -2
  284. package/dist/login-flow-GZ3XHVCS.js +0 -2
  285. package/dist/maintenance-cmd-VFYGKY3X.js +0 -2
  286. package/dist/pdf-convert-OZIRUADA.js +0 -2
  287. package/dist/phase-seed-BMOSAA74.js +0 -2
  288. package/dist/pipeline-G7KWRK2G.js +0 -2
  289. package/dist/prepare-target-SQ5IGKXD.js +0 -2
  290. package/dist/readmodel-TDRFVDVI.js +0 -2
  291. package/dist/reconcile-cmd-NI3AYU3Y.js +0 -2
  292. package/dist/reconcile-deps-DCHUFIEC.js +0 -4
  293. package/dist/reconcile-engine-QXUKUKSL.js +0 -2
  294. package/dist/records-JLS63SDI.js +0 -2
  295. package/dist/registry-R6QNPI5E.js +0 -2
  296. package/dist/revert-PRR3D4XM.js +0 -2
  297. package/dist/review-cmd-SAGIKWEW.js +0 -4
  298. package/dist/run-PBS2J4N4.js +0 -2
  299. package/dist/run-VTUYLPSG.js +0 -2
  300. package/dist/sessions-GIEXOCE4.js +0 -2
  301. package/dist/structured-answers-YAVW65G4.js +0 -5
  302. package/dist/tcg-generate-HIC5AA3L.js +0 -2
  303. package/dist/testmd-actions-VOSP7L74.js +0 -2
  304. package/dist/testmd-sync-GNCDKPQN.js +0 -2
  305. package/dist/token-refresh-GSFVJ6GU.js +0 -2
  306. package/dist/verdicts-PRXUKSDV.js +0 -2
  307. package/dist/walk-session-G3DLBR24.js +0 -2
  308. package/dist/with-telemetry-5Y2CVPXK.js +0 -2
@@ -0,0 +1,5 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as G,c as K}from"./chunk-PDXZROJM.js";import{S as $}from"./chunk-CGT4NFQN.js";import{b as q}from"./chunk-5GUD3CIH.js";import{a as yt,b as k}from"./chunk-NBXYL2JT.js";import{a as V}from"./chunk-BPMSNGXQ.js";import{a as z}from"./chunk-DHJSM5DT.js";import{a as M}from"./chunk-NLCCBXXV.js";import{a as R}from"./chunk-RZ4F3BHX.js";import{e as Et}from"./chunk-UR6MHSHU.js";import{readFileSync as L,existsSync as U,readdirSync as te,mkdirSync as F,writeFileSync as w}from"fs";import{readFile as bt,unlink as ee}from"fs/promises";import{join as E}from"path";import{existsSync as Gt,mkdirSync as Kt,readdirSync as _t,writeFileSync as Ht}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 Y(e){let t=new Map,n=i=>{if(!i||typeof i!="object")return;let r=i;if(Array.isArray(r.operations))for(let o of r.operations){let s=o.operation_id;typeof s=="string"&&s&&!t.has(s)&&t.set(s,r)}for(let o of It){let s=r[o];Array.isArray(s)?s.forEach(n):s&&typeof s=="object"&&n(s)}};return e.forEach(n),t}function W(e,t){let n=new Map;for(let i of e){let r=i.action_id?t.get(i.action_id):void 0;if(!r)continue;let o=n.get(r)??[];o.push(i),n.set(r,o)}return n.size===0?null:[...n].map(([i,r])=>At(i,r))}function vt(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 H(e){if(e!=null)try{return JSON.parse(e)}catch{return e}}function J(e,t,n){let i=e.user_variables,r=typeof i=="string",o;try{o=r?JSON.parse(i):i??[]}catch{return}if(!Array.isArray(o)||o.length===0)return;let s=o.find(c=>t&&c.name===t)??(o.length===1?o[0]:void 0);s&&(s.value=n,e.user_variables=r?JSON.stringify(o):o)}function At(e,t){let n=structuredClone(e),i=t[0],r=t[t.length-1];switch(n.status=t.find(o=>o.status!=="success")?.status??i.status,n.start_timestamp=i.timestamp??n.start_timestamp,n.end_timestamp=vt(r)||n.end_timestamp,n.content_type){case"api":{let o=r.action_params?.api_data?.response;o&&typeof o=="object"&&(n.api_data={...n.api_data??{},response:o},J(n,r.output_variable,o));break}case"script":{r.output_value!=null&&J(n,r.output_variable??n.output_variable_name,r.output_value);break}case"db_query":{r.output_value!=null&&(n.db_details={...n.db_details??{},carried_out_query:H(r.output_value)});break}case"screenshot_command":{let o=H(r.output_value);o&&typeof o=="object"&&(n.smartui_results=o);break}case"network_assertion":case"network_query":break;default:break}return n}var kt="/home/kaneai/Downloads";function O(e){return`${kt}/${e}`}function Q(e){return"FILE__"+e.replace(/[^A-Za-z0-9]/g,"_")}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"}}function tt(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 T(e){return typeof e=="string"&&e.includes("{{secrets.")}var Rt={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",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"},et={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"},Pt=new Set(["CLICK","TYPE","FILL","HOVER","SCROLL_UNTIL_ELEMENT","UPLOAD_FILE","VISION_QUERY","DRAG_DROP","SELECT"]);function nt(e,t){if(e==="analyze"){let i=t?.action_params?.analyzer_type??"";return et[i]}if(e==="scroll"&&t?.action_params?.into_view===!0)return"SCROLL_UNTIL_ELEMENT";let n=Rt[e];return n||console.warn(`[migrator] UNKNOWN action_type "${e}" \u2014 falling back to "${e.toUpperCase()}"; explicit mapping required`),n??e.toUpperCase()}function it(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 ot(e){try{return JSON.parse(e.output_value??"{}")}catch{return{}}}function St(e){let t=e.output_variable??"";if(!t)return"[]";let i={...ot(e)};return delete i.body,JSON.stringify([{name:t,unique_key:(e.action_id??"").replace(/-/g,"").slice(0,8)||v().replace(/-/g,"").slice(0,8),value:i,variable_description:"API Response"}])}function wt(e,t,n){let i=e.action_params??{},r=Pt.has(t)?"Vision Agent":"Operation Agent",o={operation_type:t};if(t==="OPEN"&&(o.url=i.url??""),t==="SET_VARIABLE"&&(o.variable_name=e.output_variable??i.key??"",o.variable_value=e.output_value??""),t==="UPLOAD_FILE"){let m=N(i);m&&(o.value=O(m.name))}let s={},c={},a=e.action_instruction??"",l=i.text??"",u=i.url??"",_=[["intent",a],["value",l],["url",u]];for(let[m,h]of Object.entries(n)){let I=String(h);if(m.startsWith("secrets."))for(let[y,b]of _)b.includes(I)&&(c[y]=m);for(let[y,b]of _)b.includes(I)&&!(y in s)&&(s[y]=b)}let p=e.action_type,d={operation:e.action_instruction??"",agent:r,operation_dict:o,reasoning:p==="analyze"?i.query??"":e.intent??e.action_instruction??"",variable:s,secrets:c,params:{}};p==="analyze"&&typeof i.code=="string"&&i.code&&(d.code=i.code),p==="analyze"&&typeof i.code_js=="string"&&i.code_js&&(d.code_js=i.code_js),p==="analyze"&&typeof i.condition_expression=="string"&&i.condition_expression&&(d.condition_expression=i.condition_expression),i.uses_websocket===!0&&(d.uses_websocket=!0),i.uses_sse===!0&&(d.uses_sse=!0),p==="analyze"&&i.analyzer_type==="textual_visual"&&(typeof i.wrapped_js=="string"&&(d.wrapped_js=i.wrapped_js),Array.isArray(i.locators)&&(d.locators=i.locators),typeof i.operator=="string"&&(d.operator=i.operator),Array.isArray(i.transforms)&&(d.transforms=i.transforms),typeof i.query=="string"&&(d.query=i.query),typeof i.expected_value=="string"&&(d.expected_value=i.expected_value),typeof i.needs_unit_conversion=="boolean"&&(d.needs_unit_conversion=i.needs_unit_conversion),typeof i.condition=="string"&&(d.condition=i.condition));let f={set_cookies:"cookies",set_clipboard:"text",delete_cookies:"names",set_local_storage:"items",delete_local_storage:"keys"}[p];return f&&i[f]!==void 0&&(d[f]=i[f]),p==="set_clipboard"&&typeof i.html=="string"&&i.html&&(d.html=i.html),d}function xt(e){let t=e.assertion_tree??{};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(r=>r.passed===!0):n.every(r=>r.passed===!0)}function rt(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 Ot(e){let t=e.assertion_tree??{},n=t.sub_results??[],i=rt(n);return{operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[],sub_results:n,sub_checks:i,composite_operator:t.composite_operator??"and",verification:t.verification??"",claim:t.description??""}}function Nt(e){let n=(e.action_params??{}).assertion_tree??{},i=n.sub_results??[],r=rt(i);return[{operation:e.action_instruction??"",agent:"Operation Agent",operation_dict:{operation_type:"ASSERTION",assertion_tree:{sub_results:i,sub_checks:r,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 Lt(e,t,n,i){let r=e.visual_data;if(!r||r.x==null||r.y==null)return null;let o=t?`${t}/test_screenshots`:"";return{x:r.x,y:r.y,confidence:0,bbox:r.bbox??null,bbox_source:r.bbox?"accessibility_tree":"fallback",viewport_width:r.viewport_width??1280,viewport_height:r.viewport_height??800,scale_factor:null,raw_image_url:o?`${o}/untagged_screenshot/${n}.${i?.get(n)??"png"}`:"",raw_image_sas_url:"",annotated_image_url:"",annotated_image_sas_url:""}}function Tt(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 Ct(e){return/^(android|ios)_native$/i.test(e.platform??"")}function st(e,t){return e.map(n=>({...n,type:t?n.strategy??n.type??"native":n.isXPath?"xpath":"css"}))}function jt(e,t,n){let i={selector_target:"",drag_displacement:{},hold_duration_ms:null,move_duration_ms:null,hold_at_destination_ms:null};if(e!=="drag")return i;let r=t.target_selectors,o={};typeof t.direction=="string"&&t.direction&&(o.direction=t.direction,typeof t.fraction=="number"&&(o.fraction=t.fraction));let s=c=>typeof t[c]=="number"?Math.trunc(t[c]):null;return{selector_target:Array.isArray(r)&&r.length>0?st(r,n):"",drag_displacement:o,hold_duration_ms:s("hold_duration_ms"),move_duration_ms:s("move_duration_ms"),hold_at_destination_ms:s("hold_at_destination_ms")}}function X(e,t="",n){let i=e.action_type,r=nt(i,e),o=e.action_params??{},s=e.coordinates??null,c=e.selectors??null,a=!!(c&&c.length>0),l=Ct(e),u=jt(i,o,l),_=e.timestamp??"",p=e.duration_ms??0,d=e.variables_used??{},g=e.action_id??v(),f=v(),m=it(_,p),h="",I="";if(i==="navigate")I=o.url??"",h=I;else if(i==="type"||i==="fill")h=o.text??"";else if(i==="press_key")h=o.key??"";else if(i==="wait")h=String(o.ms??o.timeout_ms??"");else if(i==="evaluate_js")h=o.script??"";else if(i==="upload_files"){let B=N(o);B&&(h=O(B.name))}else i==="analyze"&&r==="SET_VARIABLE"&&(h=e.output_value??"");let y="";i==="go_back"?y="back":i==="go_forward"&&(y="forward");let b=e.action_instruction??"",A=T(h)||T(I)||T(b),x=wt(e,r,d);return{operation_id:g,instruction_id:f,instruction:b,intent:b,operation_start:_,operation_end:m,status:e.status??"",command:r,name:"",target:"",value:h,message:"",operation_dict:"",frame:Tt(e.frame_info),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?`${t}/test_screenshots/untagged_screenshot/${g}.${n?.get(g)??"png"}`:"",alternative_xpaths:[],attribute:"",value_description:"",url:I,navigation_direction:y,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:r==="ASSERTION"?xt(o):"",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(o.tab_index??""),tab_identifier:String(o.tab_identifier??""),scroll_value:o.amount??1,scroll_direction:o.direction??"",mi_scroll_payload:{},sleep_duration:0,app_id:"",manual_interaction_tag:"",string_to_float_list:[],js_snippet:i==="evaluate_js"?o.script??"":"",code_error:"",hide:A,dismiss_dialog:!1,use_v2_mobile_tagging:l,multiple_inputs:!1,dialog_action:"",dialog_type:"",is_coordinates_used_for_interaction:s!==null&&!a,element_coordinates_ratio:[],element_bounds_ratio:[],x_coord:a?null:s?.x??null,y_coord:a?null:s?.y??null,target_x_coord:o.target_x??null,target_y_coord:o.target_y??null,source_description:o.source_description??null,target_description:o.target_description??null,use_coordinates:s!==null&&!a,kaneaiMobileTaggingImageLimit:1,clicks_order_code:"se_js_ac",selector:a?st(c,l):"",selector_target:u.selector_target,math_result_variable_name:"",math_result_variable_value:"",expression_tree:r==="ASSERTION"?Ot(o):o.expression_tree??{},assertion_tree:o.assertion_tree??{},assertion_tree_simplified:{},network_throttle:{},is_mobile_offline:!1,autoheal:!1,reprobe:e.reprobe??!1,click_modifier:(o.click_count??1)>=2?{kind:"multi_click",frequency:o.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:r==="ASSERTION"?"Fail test immediately":"",screenshot_command:"",smartui_contents:{},smartui_results:{},result_type:"",result_hint:"",drag_offset:{},drag_displacement:u.drag_displacement,hold_duration_ms:u.hold_duration_ms,move_duration_ms:u.move_duration_ms,hold_at_destination_ms:u.hold_at_destination_ms,start_coordinates:o.source_coordinates?{x:o.source_coordinates[0],y:o.source_coordinates[1]}:{},end_coordinates:o.target_coordinates?{x:o.target_coordinates[0],y:o.target_coordinates[1]}:{},element_rect:null,is_canvas:!1,until_condition:"",until_max_retries:0,until_settle_ms:0,api_data:i==="api"?{request:e.action_params?.api_data?.request??{}}:{},output_variables:i==="api"?e.output_variable?{[e.output_variable]:null}:{}:e.output_variable?{[e.output_variable]:e.output_value??""}:{},visual_context:Lt(e,t,g,n),reasoning:i==="analyze"?o.query??"":e.intent??e.action_instruction??""}}function Z(e,t){let n=e.action_type,i=nt(n,e),r=e.timestamp??"",o=e.duration_ms??0,s=it(r,o),c=i==="ASSERTION"||i==="MATHEMATICAL_OPERATION";return{instruction_id:t.instruction_id,instruction_class:c?"non_driver_action":"driver_action",module_id:"",instruction:e.action_instruction??"",command:i,error:null,parent_instruction_id:"",classification_layer_resp:i==="ASSERTION"?Nt(e):[],classification_error:{},operations:[t],status:e.status??"",start_timestamp:r,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"?St(e):"[]",api_data:n==="api"?{request:e.action_params?.api_data?.request??{},response:ot(e)}:{},params_used:!1,hard_assertion:i==="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 Dt(e,t=[]){let n=e.action_params??{},i=n.branches??[],r=n.winning_index??-1,o=n.sub_results??[],s={};for(let a of o){let l=a.sub_results;if(l)for(let u of l){let _=u.store_key;_&&(s[_]=u)}}let c=i.map((a,l)=>{let u=l===r,_=(a.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&&a.condition&&o.length>0){let d=o.find(g=>g.branch_index===l)?.sub_results??[];d.length>0&&(_=d.map(g=>({description:g.description??a.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:l,condition:a.condition??null,branch_type:a.branch_type??"sub_objective",passed:u,sub_objective:null,custom_event:a.custom_event??null,children:u?t:[],sub_checks:a.condition?_:[],composite_operator:a.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:r,branches:c,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 at(e,t,n){for(let i of e)i.content_type==="instruction"&&"generative_id"in i&&(i.generative_id=t,i.generative_objective=n)}function C(e,t="",n,i){let r=[],o=0;for(;o<e.length;){let s=e[o],c=s.action_type;if(!i?.keepFailedActions&&s.status==="error"&&c!=="assert"&&c!=="if_else"&&c!=="child_agent_start"&&c!=="child_agent_end"&&!(s.until_condition&&!s.error)){o+=1;continue}if(c==="analyze"&&(!et[s.action_params?.analyzer_type??""]||s.action_params?.analyzer_type==="textual_visual"&&s.action_params?.code)){o+=1;continue}if(c==="child_agent_start"){let a=s.action_params?.child_id??"",l=s.action_params?.objective??"",u=[];o+=1;let _=1,p="error",d;for(;o<e.length&&_>0;){let A=e[o],x=A.action_type;if(x==="child_agent_start")_+=1;else if(x==="child_agent_end"&&(_-=1,_===0)){p=A.status??"success",d=A,o+=1;break}_>0&&u.push(A),o+=1}let g=C(u,t,n);at(g,a,l);let f=d?.action_params?.result_code??null,m=d?.action_params?.reason_code??null,h=d?.action_params?.error_message??null,I=d?.action_params?.summary??null,y=d?.action_params?.one_liner??null,b=p==="error";r.push({content_type:"generative_block",instruction_id:`generative_block_${a}`,generative_id:a,objective:l,status:p,children:g,error_message:b?h??null:null,error_code:b?m??null:null,result_code:f??null,bifurcation_context:[],approach_reason:tt(I),one_liner:y??null});continue}else if(c==="child_agent_end"){o+=1;continue}else if(c==="if_else"){o+=1;let a=[];for(;o<e.length&&e[o].action_type==="child_agent_start";){let l=e[o],u=l.action_params?.child_id??"",_=l.action_params?.objective??"",p=[];o+=1;let d=1,g="error";for(;o<e.length&&d>0;){let m=e[o];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",o+=1;break}d>0&&p.push(m),o+=1}let f=C(p,t,n);a.push(...f)}r.push(Dt(s,a));continue}else if(c==="query_tool"){o+=1;continue}else if(s.until_condition){let a=X(s,t,n),l=Z(s,a),u=typeof s.until_condition_met=="boolean"?s.until_condition_met:s.status==="success";r.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:u,children:[l],generative_id:"",generative_objective:"",variables_used:{},status:s.status??"success"})}else{let a=X(s,t,n),l=Z(s,a);r.push(l)}o+=1}return r}function P(e,t="",n,i){let r=[],o=[],s=i?.passthrough,c=s?Y(s.authoredInstructions):null;for(let d of e){if(s&&c&&d.flatIndex!==void 0&&s.replayOnlyFlatIndices.has(d.flatIndex)){let b=W(d.records,c);if(b){for(let A of b)r.push(A),o.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=C(d.records,t,n,i);if(g.length===0)continue;let f=v().replace(/-/g,"");at(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,I=h!==null&&!isNaN(h)&&h>=200,y=m||I?"error":"success";r.push({content_type:"generative_block",instruction_id:`generative_block_${f}`,generative_id:f,objective:d.objective,status:y,children:g,error_message:y==="error"?d.errorMessage??null:null,error_code:y==="error"?d.reasonCode??null:null,result_code:d.resultCode??null,bifurcation_context:[],approach_reason:tt(d.summary),one_liner:d.oneLiner??null}),o.push(d.flatIndex)}let a=r.map((d,g)=>({block:d,flat:o[g]})),l=i?.moduleSpans??[],u=i?.blockSpans??[],_=i?.authoredBlocks??[];l.length>0&&(a=ct(a,l,u,_));let p=dt(u,l);return p.length>0&&(a=j(a,p,_)),{instructions:a.map(d=>d.block)}}function ct(e,t,n,i){let r=[],o=c=>c===void 0?void 0:t.find(a=>c>=a.flatFrom&&c<=a.flatTo),s=0;for(;s<e.length;){let c=o(e[s].flat);if(!c){r.push(e[s]),s++;continue}let a=[];for(;s<e.length&&o(e[s].flat)===c;)a.push(e[s++]);let l=ct(a,c.children,n,i),u=dt(ut(n,c),c.children);u.length>0&&(l=j(l,u,i)),r.push({block:$t(c,l.map(_=>_.block)),flat:a[0].flat})}return r}function lt(e,t){return e.flatFrom>=t.flatFrom&&e.flatTo<=t.flatTo}function ut(e,t){let n=[];for(let i of e)lt(i,t)?n.push(i):n.push(...ut(i.children,t));return n}function dt(e,t){let n=[],i=o=>{for(let s of o)n.push(s),i(s.children)};i(t);let r=o=>o.filter(s=>!n.some(c=>lt(s,c))).map(s=>({...s,children:r(s.children)}));return n.length>0?r(e):e}function j(e,t,n){let i=[...t].sort((l,u)=>l.flatFrom-u.flatFrom),r=[],o=(l,u)=>{r.push({block:zt(l,u,n),flat:l.flatFrom})},s=(l,u)=>l!==void 0&&l>=u.flatFrom&&l<=u.flatTo,c=0,a=0;for(;a<e.length;){let l=e[a].flat;for(;c<i.length&&l!==void 0&&i[c].flatTo<l;)o(i[c++],[]);let u=c<i.length&&s(l,i[c])?i[c]:void 0;if(!u){r.push(e[a]),a++;continue}let _=[];for(;a<e.length&&s(e[a].flat,u);)_.push(e[a++]);o(u,_),c++}for(;c<i.length;)o(i[c++],[]);return r}function Ut(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 Ft=["children","instructions","branches","module_content","true_branch","false_branch"];function Bt(e,t){if(!t)return;let n=[...e];for(;n.length>0;){let i=n.pop();if(!i||typeof i!="object")continue;let r=i;if(r.instruction_id===t&&(r.content_type==="conditional_block"||r.content_type==="until_block"))return r;for(let o of Ft){let s=r[o];Array.isArray(s)?n.push(...s):s&&typeof s=="object"&&n.push(s)}}}function Mt(e,t,n){if(!e)return[];if(t==="while")return Array.isArray(e.children)?e.children:[];let r=(Array.isArray(e.branches)?e.branches:[])[n];return r&&Array.isArray(r.children)?r.children:[]}function zt(e,t,n){let i=Bt(n,e.blockId),r=e.branches.map((o,s)=>{let c=t.filter(u=>u.flat!==void 0&&u.flat>=o.flatFrom&&u.flat<=o.flatTo);e.kind==="while"&&(c=Ut(c));let a=j(c,e.children,n).map(u=>u.block);if(a.length>0)return a;let l=Mt(i,e.kind,s);return l.length===0&&!o.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`),l});return e.kind==="if"?Vt(e,r,i):qt(e,r[0]??[],i)}function Vt(e,t,n){let i=Array.isArray(n?.branches)?n.branches:[],r=D(t.flat()),o=e.branches.map((s,c)=>{let a=i[c];return{branch_index:c,condition:s.branch_type==="else"?null:s.condition,branch_type:s.branch_type,passed:s.taken,sub_objective:null,custom_event:a?.custom_event??null,children:t[c],sub_checks:Array.isArray(a?.sub_checks)?a.sub_checks:[],composite_operator:a?.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:r?"error":"success",resolved_branch_index:e.branches.findIndex(s=>s.taken),branches:o,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:r?.message??"",error_code:r?.code??"",reason:"",start_timestamp:"",end_timestamp:"",type:"agent_generated",hook:null,hook_type:null,evaluation_context:{},query_variables:{}}}function qt(e,t,n){let i=e.whileCfg??{max_retries:5,settle_ms:500,on_exhaust:"fail",iterations:0,condition_met:!1},r=D(t),o=(s,c)=>n&&n[s]!==void 0?n[s]:c;return{content_type:"until_block",instruction_id:e.blockId||`until_${v().slice(0,8)}`,condition:e.instruction,max_retries:i.max_retries,settle_ms:i.settle_ms,current_count:i.iterations,condition_met:i.condition_met,children:t,generative_id:"",generative_objective:"",variables_used:{},status:r?"error":"success",on_exhaust:o("on_exhaust",i.on_exhaust),mode:o("mode",""),check:o("check",""),conditions:o("conditions",[]),connectors:o("connectors",[]),sub_checks:o("sub_checks",[]),composite_operator:o("composite_operator","and")}}function D(e){for(let t of e){let n="status"in t&&typeof t.status=="string"?t.status:"";if(n==="error"||n==="failed"){let i="error_message"in t?t.error_message:void 0,r="error_code"in t?t.error_code:void 0;return{message:i??null,code:r??null}}}return null}function $t(e,t){let n=e.meta,i=(l,u="")=>typeof n[l]=="string"?n[l]:u,r=(l,u=!1)=>typeof n[l]=="boolean"?n[l]:u,o=l=>Array.isArray(n[l])?n[l]:[],s=typeof n.module_version=="number"||typeof n.module_version=="string"?n.module_version:null,c=i("module_id"),a=D(t);return{content_type:$,instruction_id:`module_block_${c}`,module_id:c,module_version:s,module_instance_id:v(),module_name:i("module_name"),module_description:i("module_description"),module_platform:i("module_platform"),creation_mode:i("creation_mode","Agent"),tms_status:i("tms_status","active"),is_validated:r("is_validated"),is_dirty:e.dirty,enrichment_id:i("enrichment_id"),tags:o("tags"),project_ids:o("project_ids"),link_to_all:r("link_to_all"),status:a?"error":"success",children:t,error_message:a?.message??null,error_code:a?.code??null,update_available:!1,update_info:{}}}function pt(e,t){let n;try{n=_t(e)}catch{return 0}let i=0,r=n.filter(o=>/^\d+$/.test(o)).sort((o,s)=>Number(o)-Number(s));for(let o of r){let s=S(e,o),c=S(s,"logs");if(!Gt(c))continue;let a;try{a=_t(c)}catch{continue}let l=a.filter(p=>p.endsWith("-actions.ndjson")).sort((p,d)=>(parseInt(p,10)||0)-(parseInt(d,10)||0)),u=[];for(let p of l){let d=t.readActions(S(c,p));d.length&&u.push({objective:t.objective??"",records:d})}if(u.length===0)continue;let{instructions:_}=P(u,t.screenshotBaseUrl??"",t.extMap,{keepFailedActions:!0});if(_.length!==0)try{let p=S(s,"auteur");Kt(p,{recursive:!0}),Ht(S(p,"execution.json"),JSON.stringify(t.buildBlob(_),null,2)),i++,t.log?.("info","EVIDENCE_ARCHIVED_ATTEMPT_BLOB","Derived nested attempt blob",{attempt:o,instructions:_.length})}catch(p){t.log?.("debug","EVIDENCE_ARCHIVED_ATTEMPT_BLOB_FAILED","Nested attempt blob derivation failed",{attempt:o,error:p instanceof Error?p.message:String(p)})}}return i}var gt=Et(yt(),1);import{createWriteStream as Jt}from"fs";import{readFile as Yt}from"fs/promises";import{join as Wt,basename as Xt}from"path";import{tmpdir as Zt}from"os";var Qt=["**/screenshots/**","**/annotated/**","**/tcg/**","**/bifurcation/**"];async function ft(e){let t=Wt(Zt(),`${Xt(e)}_artifacts.zip`);return new Promise((n,i)=>{let r=Jt(t),o=(0,gt.default)("zip",{zlib:{level:6}});r.on("close",()=>n(t)),o.on("error",i),o.pipe(r),o.glob("**/*",{cwd:e,ignore:Qt}),o.finalize()})}async function mt(e){return Yt(e)}async function ne(e,t){return bt(q(e,t))}function ie(e){return{key:"artifacts",content_type:"application/zip",filename:`${e}.evidence`}}var ht=class{config;controller;testId;constructor(t){this.config=t,this.controller=new z(t.controllerBaseUrl,t.auth),this.testId=t.testId}log(t,n,i,r){this.config.log?.(t,n,i,r)}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,i=null;if(this.config.shouldUploadArtifacts!==!1){t("convert","running");let c=this.collectNdjsonPerRun(),a=c.reduce((f,m)=>f+m.records.length,0);this.log("info","PIPELINE_CONVERT","Collected NDJSON records",{total_records:a,run_groups:c.length});let l=this.loadReplayOnlyPassthrough(),{instructions:u}=c.length>0?P(c,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap,{moduleSpans:this.config.moduleSpans,...l?{passthrough:l}:{},...this.config.blockSpans?.length?{blockSpans:this.config.blockSpans,authoredBlocks:this.loadAuthoredBlocks()}:{}}):{instructions:[]};this.log("info","PIPELINE_CONVERT_INSTRUCTIONS","Auteur instructions produced",{count:u.length});let _=this.buildExecutionEnvelope(u),p=Buffer.from(JSON.stringify(_));this.log("info","PIPELINE_CONVERT_BLOB","Blob created",{size_kb:+(p.length/1024).toFixed(1)});let d=E(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=E(g,"auteur");F(f,{recursive:!0}),w(E(f,"execution.json"),JSON.stringify(_,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack",{path:E(f,"execution.json")}),this.deriveArchivedAttemptBlobs(g)}if(t("convert","done"),n)i=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 ft(this.config.sessionDir),m=await mt(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 ee(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 c=this.collectNdjsonPerRun(),a=this.loadReplayOnlyPassthrough(),{instructions:l}=c.length>0?P(c,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap,{keepFailedActions:!0,moduleSpans:this.config.moduleSpans,...a?{passthrough:a}:{},...this.config.blockSpans?.length?{blockSpans:this.config.blockSpans,authoredBlocks:this.loadAuthoredBlocks()}:{}}):{instructions:[]},u=this.buildExecutionEnvelope(l),_=E(this.config.sessionDir,"execution.json");w(_,JSON.stringify(u,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=E(p,"auteur");F(d,{recursive:!0});let g=this.readAuthoredExecution();w(E(d,"execution.json"),g??JSON.stringify(u,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack (gated)",{path:E(d,"execution.json"),source:g?"authored":"run_envelope"}),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(c){let a=c instanceof Error?c.message:String(c);throw this.log("error","PIPELINE_ATOMIC_REPLACE_FAILED","Atomic-replace failed",{error:a}),t("atomic_replace","failed",a),c}}else t("atomic_replace","skipped");let r,o;if(this.config.shouldCommit&&!this.config.isFirstRun&&this.config.onCommitLock){t("commit_lock","running");let c=await this.config.onCommitLock();if(c.ok)r=c.testcaseId||void 0,this.log("info","PIPELINE_COMMIT_LOCK_OK","Commit lock acquired",{testcase_id:r??"none",trigger:c.trigger??null,test_instance_id:c.testInstanceId??null}),t("commit_lock","done");else return this.log("error","PIPELINE_COMMIT_LOCK_FAILED","Commit lock failed",{reason:c.reason,message:c.message}),t("commit_lock","failed",`${c.reason??"unknown"}: ${c.message??""}`),{success:!1,testId:this.testId,error:`commit-lock failed: ${c.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 c=new V(this.config.tmsBaseUrl,this.config.tmsUsername,this.config.tmsAccessKey),a=this.config.runObjectives&&this.config.runObjectives.length>0?this.config.runObjectives:[this.config.firstObjective];if(r=(await c.endTest(this.testId,{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:a})).testcase_id||void 0,this.log("info","PIPELINE_FINALIZE_OK","Test finalized",{testcase_id:r??"none"}),this.config.onFinalizeSuccess)try{await this.config.onFinalizeSuccess(r)}catch(u){this.log("warn","PIPELINE_FINALIZE_META_FAILED","Meta-rewrite after endTest failed",{error:String(u)})}t("finalize","done")}else t("finalize","skipped"),this.log("info","PIPELINE_FINALIZE_SKIPPED","Finalize skipped (evolve flow or first-run disabled)");if(r&&this.config.shareApiBaseUrl)try{o=await this.generateShareLink(r),this.log("info","PIPELINE_SHARE_OK","Share link generated",{share_id:o})}catch(c){this.log("warn","PIPELINE_SHARE_FAILED","Share link failed",{error:String(c)})}if(n&&i){let c=null;t("zip","running");try{await n.sealFn({testcaseId:r,shareId:o}),c=n.sealedPackPath?await bt(n.sealedPackPath):await ne(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:+(c.length/1024/1024).toFixed(1)})}catch(a){let l=a instanceof Error?a.message:String(a);this.log("warn","PIPELINE_EVIDENCE_UPLOAD_SKIPPED","Evidence seal/read failed \u2014 uploading blob only",{execution_id:n.executionId,error:l})}if(c){t("zip","done",`${(c.length/1024/1024).toFixed(1)}MB`),t("presign","running");let a=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:a.urls.artifacts?.blob_url,blob_url:a.urls.blob?.blob_url}),t("presign","done"),t("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading pack and blob",{artifact_size_mb:+(c.length/1024/1024).toFixed(1),blob_size_kb:+(i.length/1024).toFixed(1)}),await Promise.all([k(a.urls.artifacts.upload_url,c,"application/zip"),k(a.urls.blob.upload_url,i,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),t("upload","done")}else{t("zip","skipped"),t("presign","running");let a=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:+(i.length/1024).toFixed(1)}),await k(a.urls.blob.upload_url,i,"application/json"),this.log("info","PIPELINE_UPLOAD_OK","Blob upload complete (pack skipped)"),t("upload","done")}}let s;if(this.config.codeExport?.enabled&&r){let c=!1;try{await this.triggerCodeExport(r),this.log("info","PIPELINE_CODE_EXPORT_START","Code export triggered"),c=!0}catch(a){let l=a instanceof Error?a.message:String(a);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export trigger failed; skipping poll",{error:l}),t("code_export","failed",`trigger failed: ${l}`)}if(c){t("code_export","running","Waiting for code generation\u2026");try{s=await this.pollAndDownloadCode(r,t),this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:s}),t("code_export","done",s)}catch(a){let l=a instanceof Error?a.message:String(a);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:l}),t("code_export","failed",l)}}}else t("code_export","skipped");return this.log("info","PIPELINE_COMPLETE","Pipeline complete"),{success:!0,testId:this.testId,testcaseId:r,shareId:o,codeExportDir:s}}catch(n){return{success:!1,testId:this.testId,error:n instanceof Error?n.message:String(n)}}}async runCodeExport(t,n){let i=n??this.config.onProgress,r=!1;try{await this.triggerCodeExport(t),this.log("info","PIPELINE_CODE_EXPORT_TRIGGER","Code export triggered",{testcase_id:t}),r=!0}catch(o){let s=o instanceof Error?o.message:String(o);this.log("error","PIPELINE_CODE_EXPORT_TRIGGER_FAILED","Code export trigger failed; skipping poll",{error:s}),i("code_export","failed",`trigger failed: ${s}`)}if(r){i("code_export","running","Waiting for code generation\u2026");try{let o=await this.pollAndDownloadCode(t,i);return this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:o}),i("code_export","done",o),o}catch(o){let s=o instanceof Error?o.message:String(o);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:s}),i("code_export","failed",s);return}}}deriveArchivedAttemptBlobs(t){try{let n=pt(t,{readActions:i=>this.readNdjsonFromFile(i),buildBlob:i=>this.buildExecutionEnvelope(i),objective:this.config.firstObjective,screenshotBaseUrl:this.config.screenshotBaseUrl??"",extMap:this.config.screenshotExtMap,log:(i,r,o,s)=>this.log(i,r,o,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??[],i=this.config.runMetadata??[],r=this.config.evidence??this.config.evidenceRead;for(let o=0;o<this.config.runDirs.length;o++){let s=this.config.runDirs[o],c=n[o]||this.config.firstObjective,a=i[o],l=r?this.readNdjsonFromFile(E(r.packTestDir,"logs",`${r.runIndices?.[o]??o}-actions.ndjson`)):this.readNdjsonFromDir(s);if(l.length>0){let u=r?.runIndices?.[o]??o,_=this.config.runFlatIndex?.[u];t.push({objective:c,records:l,..._!==void 0?{flatIndex:_}:{},resultCode:a?.resultCode,reasonCode:a?.reasonCode,errorMessage:a?.errorMessage,summary:a?.summary,oneLiner:a?.oneLiner})}}if(t.length===0){let o=E(this.config.sessionDir,"runs");if(U(o))try{let c=te(o,{withFileTypes:!0}).filter(a=>a.isDirectory()).map(a=>a.name).sort();for(let a of c){let l=E(o,a),u=this.readNdjsonFromDir(l);u.length>0&&t.push({objective:this.config.firstObjective,records:u})}}catch{}}return t}readNdjsonFromDir(t){let n=[E(t,"run-test","actions.ndjson"),E(t,"actions.ndjson")];for(let i of n)if(U(i))return this.readNdjsonFromFile(i);return[]}readNdjsonFromFile(t){let n=[];if(!U(t))return n;this.log("debug","PIPELINE_COLLECT_READ","Reading NDJSON file",{path:t});let i=L(t,"utf-8");for(let r of i.split(`
5
+ `)){let o=r.trim();if(o)try{n.push(JSON.parse(o))}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 i={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({entityIds:[t],entityType:"Test Case Details",expiresAt:7})},r=!!this.config.authResolver;this.log("debug","PIPELINE_SHARE_AUTH","Share link auth config",{resolver:r,fallback_auth_type:typeof this.config.auth=="string"?"bearer":"basic",tms_user:this.config.tmsUsername});let o=r?await this.config.authResolver.fetch(n,i):await R(n,{...i,headers:{...i.headers,Authorization:this.buildAuthHeader()}});if(!o.ok)throw new Error(`Share link API failed: ${o.status} ${await o.text()}`);let s=await o.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:i}=G({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 r={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(i)},o=this.config.authResolver?await this.config.authResolver.fetch(n,r):await R(n,{...r,headers:{...r.headers,Authorization:this.buildAuthHeader()}});if(!o.ok)throw new Error(`Code export failed: ${o.status} ${await o.text()}`)}async pollAndDownloadCode(t,n){let i=K({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:t}),r=this.config.exitTimeoutMs??3e5,o=5e3,s=Date.now()+r;this.log("info","PIPELINE_CODE_EXPORT_POLL","Polling for code export",{url:i,timeout_ms:r});let c=(a,l)=>this.config.authResolver?this.config.authResolver.fetch(a,l):R(a,{...l,headers:{...l?.headers,Authorization:this.buildAuthHeader()}});for(;Date.now()<s;){let a=await c(i,{method:"GET",headers:{Accept:"application/json"}});if(!a.ok){let d=await a.text().catch(()=>"");throw this.log("warn","PIPELINE_CODE_EXPORT_POLL_FAILED","Code export poll non-200; skipping",{status:a.status,body:d.slice(0,200)}),new Error(`code export poll skipped: HTTP ${a.status}`)}let u=(await a.json()).data?.find(d=>d.code_name==="kane-cli-trigger");if(!u){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(o);continue}let _=u.status.toLowerCase();if(_==="in progress"||_==="in_progress"||_==="pending"){this.log("debug","PIPELINE_CODE_EXPORT_IN_PROGRESS","Code export in progress",{status:u.status}),n("code_export","running","Generating code\u2026"),await this.sleep(o);continue}if(!u.url||u.url.length===0)throw new Error(`Code export status=${u.status} but no files returned`);let p=this.config.codeExportDir??E(this.config.sessionDir,"code-export");F(p,{recursive:!0}),this.log("info","PIPELINE_CODE_EXPORT_DOWNLOAD","Downloading code files",{file_count:u.url.length,dir:p}),n("code_export","running",`Downloading ${u.url.length} files\u2026`);for(let d of u.url){let g=E(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}`:M(this.config.auth.username,this.config.auth.accessKey)}readAuthoredExecution(){let t=this.config.authoredExecutionPath;if(!t)return null;try{let n=L(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}}loadAuthoredBlocks(){let t=this.config.blockAuthoredExecutionPath;if(!t)return[];try{let n=JSON.parse(L(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(L(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}}buildExecutionEnvelope(t){let n=this.config.runStatuses.every(l=>l==="passed")?"success":"error",i=this.config.variableIds??{},r=[];if(this.config.variables)for(let[l,u]of Object.entries(this.config.variables)){if(u.secret)continue;let _=l.startsWith("global.")?l.slice(7):l;r.push({id:i[_]??0,name:_,value:u.value,session_value:u.value,is_persist:!1,environment_id:0,environment_name:"No Env"})}let o=[],s=l=>{let u=o.find(_=>_.name===l.name);u?u.value=l.value:o.push(l)},c=[],a=new Set;for(let l of this.collectNdjsonPerRun())for(let u of l.records)if(u.output_variable&&u.output_value!=null&&s({name:u.output_variable,value:String(u.output_value),value_type:"test_level",variable_description:"ANALYZE result"}),u.action_type==="upload_files"){let _=N(u.action_params);if(_){let p=_.media_id||_.media_url;if(!a.has(p)){a.add(p),c.push({media_url:_.media_url,media_id:_.media_id,name:_.name,type:_.type});let d=O(_.name);s({name:Q(_.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:c,test_params:[],test_level_variables:JSON.stringify(o),test_global_variables:r,max_network_wait:0,wait_buffer:0,network_throttle:{},secrets:this.config.secrets??[],totp:[],environment_id:0,environment:"",mobile_browser:!1,native_popups:[],smartui:{},module_index:0}}};export{ne as a,ie as b,ht as c};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as O,d as S}from"./chunk-DYXYNH6X.js";import{c as L}from"./chunk-RFHMDQXZ.js";import{n as P,o as R}from"./chunk-RSSOJ3L2.js";import{x as s}from"./chunk-NJJQL54J.js";import{a as y}from"./chunk-HCBYKLMW.js";import{a as E,b as o,i as h}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as d}from"./chunk-UR6MHSHU.js";var n=d(B(),1);import{basename as D}from"path";var r=d(y(),1),U="evidence-view-server";function Q({packPath:m,viewerBase:w,onDone:V,openUrl:k}){let[t,a]=(0,n.useState)("ask"),[g,b]=(0,n.useState)(null),[l,p]=(0,n.useState)(null),f=(0,n.useRef)(null),u=(0,n.useRef)(!1),x=async()=>{let e=f.current;f.current=null,e&&(R(U),await e.close())},v=()=>{u.current||(u.current=!0,V())};return h((e,i)=>{u.current||(t==="ask"?e==="y"||e==="Y"?a("starting"):(e==="n"||e==="N"||i.return||i.escape)&&v():t==="serving"&&(e==="q"||e==="Q"||i.escape)&&x().then(v))}),(0,n.useEffect)(()=>{if(t!=="starting")return;let e=!1;return(async()=>{try{let i=D(m),c=await O({packs:new Map([[i,m]]),allowedOrigins:[new URL(w).origin]});if(e){await c.close();return}f.current=c,P(U,()=>{c.close()});let T=S(c.urlFor(i),w);b(T);try{await(k??(q=>L(q)))(T)}catch{p("could not open browser \u2014 open the URL manually")}a("serving")}catch(i){p(`evidence view failed \u2014 ${i.message}`),a("failed")}})(),()=>{e=!0}},[t]),(0,n.useEffect)(()=>{if(t!=="failed")return;let e=setTimeout(v,0);return()=>clearTimeout(e)},[t]),(0,n.useEffect)(()=>()=>{x()},[]),t==="ask"?(0,r.jsxs)(o,{children:["View evidence in browser? ",(0,r.jsx)(o,{color:s.dim,children:"(y/N)"})]}):t==="serving"||t==="starting"?(0,r.jsxs)(E,{flexDirection:"column",children:[g?(0,r.jsxs)(o,{children:["viewer ",(0,r.jsx)(o,{color:s.orange,children:g})]}):(0,r.jsx)(o,{color:s.dim,children:"starting\u2026"}),l?(0,r.jsx)(o,{color:"yellow",children:l}):null,t==="serving"?(0,r.jsx)(o,{color:s.dim,children:"Press q when done"}):null]}):l?(0,r.jsx)(o,{color:"yellow",children:l}):null}export{Q as a};
2
+ import{b as O,d as S}from"./chunk-VNFCX2SH.js";import{c as L}from"./chunk-RFHMDQXZ.js";import{n as P,o as R}from"./chunk-RSSOJ3L2.js";import{y as s}from"./chunk-B2ZGG7WM.js";import{a as y}from"./chunk-HCBYKLMW.js";import{a as E,b as o,i as h}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as d}from"./chunk-UR6MHSHU.js";var n=d(B(),1);import{basename as D}from"path";var r=d(y(),1),U="evidence-view-server";function Q({packPath:m,viewerBase:w,onDone:V,openUrl:k}){let[t,a]=(0,n.useState)("ask"),[g,b]=(0,n.useState)(null),[l,p]=(0,n.useState)(null),f=(0,n.useRef)(null),u=(0,n.useRef)(!1),x=async()=>{let e=f.current;f.current=null,e&&(R(U),await e.close())},v=()=>{u.current||(u.current=!0,V())};return h((e,i)=>{u.current||(t==="ask"?e==="y"||e==="Y"?a("starting"):(e==="n"||e==="N"||i.return||i.escape)&&v():t==="serving"&&(e==="q"||e==="Q"||i.escape)&&x().then(v))}),(0,n.useEffect)(()=>{if(t!=="starting")return;let e=!1;return(async()=>{try{let i=D(m),c=await O({packs:new Map([[i,m]]),allowedOrigins:[new URL(w).origin]});if(e){await c.close();return}f.current=c,P(U,()=>{c.close()});let T=S(c.urlFor(i),w);b(T);try{await(k??(q=>L(q)))(T)}catch{p("could not open browser \u2014 open the URL manually")}a("serving")}catch(i){p(`evidence view failed \u2014 ${i.message}`),a("failed")}})(),()=>{e=!0}},[t]),(0,n.useEffect)(()=>{if(t!=="failed")return;let e=setTimeout(v,0);return()=>clearTimeout(e)},[t]),(0,n.useEffect)(()=>()=>{x()},[]),t==="ask"?(0,r.jsxs)(o,{children:["View evidence in browser? ",(0,r.jsx)(o,{color:s.dim,children:"(y/N)"})]}):t==="serving"||t==="starting"?(0,r.jsxs)(E,{flexDirection:"column",children:[g?(0,r.jsxs)(o,{children:["viewer ",(0,r.jsx)(o,{color:s.orange,children:g})]}):(0,r.jsx)(o,{color:s.dim,children:"starting\u2026"}),l?(0,r.jsx)(o,{color:"yellow",children:l}):null,t==="serving"?(0,r.jsx)(o,{color:s.dim,children:"Press q when done"}):null]}):l?(0,r.jsx)(o,{color:"yellow",children:l}):null}export{Q as a};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as g}from"./chunk-NJJQL54J.js";import{readFileSync as o,writeFileSync as h,mkdirSync as u,readdirSync as a,unlinkSync as s,existsSync as l,chmodSync as f}from"fs";import{join as n,dirname as P}from"path";var d=class{baseDir;profilesDir;configFile;constructor(t=g){this.baseDir=t,this.profilesDir=n(t,"profiles"),this.configFile=n(t,"config.json")}readConfig(){try{return JSON.parse(o(this.configFile,"utf-8"))}catch{return{}}}writeConfig(t){u(this.baseDir,{recursive:!0,mode:448}),h(this.configFile,JSON.stringify(t,null,2)+`
2
+ import{b as g}from"./chunk-B2ZGG7WM.js";import{readFileSync as o,writeFileSync as h,mkdirSync as u,readdirSync as a,unlinkSync as s,existsSync as l,chmodSync as f}from"fs";import{join as n,dirname as P}from"path";var d=class{baseDir;profilesDir;configFile;constructor(t=g){this.baseDir=t,this.profilesDir=n(t,"profiles"),this.configFile=n(t,"config.json")}readConfig(){try{return JSON.parse(o(this.configFile,"utf-8"))}catch{return{}}}writeConfig(t){u(this.baseDir,{recursive:!0,mode:448}),h(this.configFile,JSON.stringify(t,null,2)+`
3
3
  `),f(this.configFile,384)}getActiveProfile(){return this.readConfig().active_profile??null}setActiveProfile(t){let i=this.readConfig();i.active_profile=t,this.writeConfig(i)}getDefaultEnv(){return this.readConfig().default_env??"prod"}setDefaultEnv(t){let i=this.readConfig();i.default_env=t,this.writeConfig(i)}credentialsPath(t,i){return n(this.profilesDir,t,i,"credentials")}clientPath(t,i){return n(this.profilesDir,t,i,"client.json")}basicAuthPath(t,i){return n(this.profilesDir,t,i,"basic-auth")}profileConfigPath(t,i){return n(this.profilesDir,t,i,"profile-config.json")}saveProfileConfig(t,i,r){let e=this.loadProfileConfig(t,i)??{};this.writeSecure(this.profileConfigPath(t,i),{...e,...r})}loadProfileConfig(t,i){try{return JSON.parse(o(this.profileConfigPath(t,i),"utf-8"))}catch{return null}}writeSecure(t,i){try{u(P(t),{recursive:!0,mode:448}),h(t,JSON.stringify(i,null,2)+`
4
4
  `),f(t,384)}catch(r){let e=r instanceof Error?r.message:String(r);process.stderr.write(`[auth] Failed to save credentials: ${e}
5
5
  `)}}saveCredentials(t,i,r){this.writeSecure(this.credentialsPath(t,i),r)}loadCredentials(t,i){try{return JSON.parse(o(this.credentialsPath(t,i),"utf-8"))}catch{return null}}saveClient(t,i,r){this.writeSecure(this.clientPath(t,i),r)}loadClient(t,i){try{return JSON.parse(o(this.clientPath(t,i),"utf-8"))}catch{return null}}getActiveCredentials(){let t=this.getActiveProfile();if(!t)return{credentials:null,profile:null,env:null};let i=this.getDefaultEnv();return{credentials:this.loadCredentials(t,i),profile:t,env:i}}saveBasicAuth(t,i,r){this.writeSecure(this.basicAuthPath(t,i),r)}loadBasicAuth(t,i){try{return JSON.parse(o(this.basicAuthPath(t,i),"utf-8"))}catch{return null}}deleteBasicAuth(t,i){try{s(this.basicAuthPath(t,i))}catch{}}resolveAuth(){let t=this.getActiveProfile();if(!t)return null;let i=this.getDefaultEnv(),r=this.loadBasicAuth(t,i);return r?{method:"basic",...r,profile:t,env:i}:this.loadCredentials(t,i)?{method:"oauth",profile:t,env:i}:null}listProfiles(){let t=[];try{for(let i of a(this.profilesDir)){let r=n(this.profilesDir,i);try{for(let e of a(r)){let c=n(r,e),v=l(n(c,"credentials")),p=l(n(c,"client.json")),y=l(n(c,"basic-auth"));(v||p||y)&&t.push({profile:i,env:e})}}catch{}}}catch{}return t}deleteProfile(t,i){try{s(this.credentialsPath(t,i))}catch{}if(this.getActiveProfile()===t){let r=this.readConfig();delete r.active_profile,this.writeConfig(r)}}deleteProfileFull(t,i){if(i){try{s(this.credentialsPath(t,i))}catch{}try{s(this.clientPath(t,i))}catch{}try{s(this.basicAuthPath(t,i))}catch{}try{s(this.profileConfigPath(t,i))}catch{}}else try{let r=n(this.profilesDir,t);for(let e of a(r)){try{s(n(r,e,"credentials"))}catch{}try{s(n(r,e,"client.json"))}catch{}try{s(n(r,e,"basic-auth"))}catch{}try{s(n(r,e,"profile-config.json"))}catch{}}}catch{}}};export{d as a};
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as n}from"./chunk-NJJQL54J.js";import{createHash as _}from"crypto";import{existsSync as m,readFileSync as u}from"fs";import{dirname as T,join as f,resolve as o}from"path";import{fileURLToPath as E}from"url";var s=T(E(import.meta.url)),l=2;function p(e,r){let t=_("sha256");return t.update(`kane-assurance-contract
2
+ import{a as n}from"./chunk-B2ZGG7WM.js";import{createHash as _}from"crypto";import{existsSync as m,readFileSync as u}from"fs";import{dirname as T,join as f,resolve as o}from"path";import{fileURLToPath as E}from"url";var s=T(E(import.meta.url)),l=2;function p(e,r){let t=_("sha256");return t.update(`kane-assurance-contract
3
3
  `),t.update(e),t.update(`
4
4
  agent_state_schema=${r}`),"sha256:"+t.digest("hex")}function d(){return[o(s,".."),o(s,"../../..")]}function i(){return"sha256:4f00de27d151118e79aafd46ebe51bb69ce7dd9fabe647124c62f2d187e11aa7"}var a=class extends Error{constructor(t,c){super(`agent/cli contract mismatch (cli ${t||"<unset>"}, agent ${c||"<unset>"}) \u2014 rebuild or reinstall the stale half`);this.expected=t;this.actual=c;this.name="PairMismatchError"}};function I(){return{TESTMUAI_CONTRACT_DIGEST:i(),TESTMUAI_CLIENT_VERSION:process.env.KANE_DEV_FORCE_CLIENT_RELEASE??`kane-cli/${n}`}}export{a,I as b};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as V,c as H,d as W,e as ie,f as se}from"./chunk-3OU2F34I.js";import{a as le}from"./chunk-M4WSRYRA.js";import{c as te}from"./chunk-ZXN67F4U.js";import{a as oe}from"./chunk-APZCLVZD.js";import{a as re}from"./chunk-FBYB3SRE.js";import{b as Z}from"./chunk-I57TM22L.js";import{b as ee}from"./chunk-IGW77FMB.js";import{a as I}from"./chunk-BPMSNGXQ.js";import{a as T,b as j,d as ne}from"./chunk-VE3SUJMA.js";import{b as Q}from"./chunk-TZXXJWHA.js";import{r as C}from"./chunk-RSSOJ3L2.js";import{b as Y}from"./chunk-7NXHVC7G.js";import{i as J}from"./chunk-Z7S3IWUX.js";import{a as D}from"./chunk-7KAPHA56.js";import{a as B,e as K}from"./chunk-EYOCNMUM.js";import{a as z}from"./chunk-AFNDJK2A.js";import{a as q}from"./chunk-HCBYKLMW.js";import{a as c,b as u,i as L,j as G}from"./chunk-C44QQJR4.js";import{a as ve}from"./chunk-6YGTRKDT.js";import{e as F}from"./chunk-UR6MHSHU.js";var s=F(ve(),1);import{basename as he}from"path";var n=F(q(),1);function Ge({resultRef:x,mode:g="singleshot",loginCompleteRef:d}){let{exit:m}=G(),A=(0,s.useRef)(new z),E=(0,s.useRef)(new oe),v=(0,s.useRef)(new te),o=A.current,l=E.current,O=v.current,ae=V(),[h,f]=(0,s.useState)(g==="login"?"login":"gate"),[M,ce]=(0,s.useState)(null),[Pe,R]=(0,s.useState)(null),[we,$]=(0,s.useState)(null),[X,ue]=(0,s.useState)(null),[N,_]=(0,s.useState)([]),P=(0,s.useCallback)((e,t,i,r)=>O.log(e,t,i,r),[O]),be=(0,s.useCallback)((e,t)=>{e?T(o,l,e,t):l.save({project_id:null,project_name:null,folder_id:null,folder_name:null})},[o,l]),y=(0,s.useCallback)(()=>{if(g==="login")d&&(d.current=!0),m();else{let e=l.load().mobile,t=B(e?.tui_target,e?.default_target?.kind),i=(t.kind==="unset"||t.kind==="choose-mobile")&&Q();f(i?"target":"input")}},[g,m,d,l]),S=(0,s.useCallback)((e,t)=>{let i=T(o,l,e,t);if(g==="login"){f("ensure-project");return}ne(i)?y():i.projectId?f("ensure-folder"):f("ensure-project")},[o,l,y,g]);L((e,t)=>{t.ctrl&&e==="c"&&C(0,"Ctrl+C exit")});let U=(0,s.useRef)(!1);s.default.useEffect(()=>{U.current||(U.current=!0,g!=="login"&&se(o,P).then(e=>{ce(e),e.status==="authenticated"?S(e.result.profile,e.result.env):e.status==="needs_pick"?f("pick"):(R(e.profile??null),$(e.env??null),f("login"))}).catch(e=>{ue(`Auth check failed: ${e instanceof Error?e.message:String(e)}`)}))},[o,P]);let fe=(0,s.useCallback)(e=>{x.current={objective:e},m()},[x,m]),de=(0,s.useCallback)(async(e,t)=>{o.setActiveProfile(e),o.setDefaultEnv(t),(await ie(o,e,t,P)).status==="authenticated"?S(e,t):(R(e),$(t),f("login"))},[o,P,S]),w=(0,s.useCallback)(()=>{let e=o.getActiveProfile(),t=o.getDefaultEnv();if(!e)return null;let i=D(t),r=o.loadBasicAuth(e,t);return new re(i.controllerBaseUrl,async()=>o.loadCredentials(e,t)?.access_token??null,r,P)},[o,P]),ge=(0,s.useCallback)(async()=>{let e=w();if(!e)return null;let t=e.cached??await e.resolve();if(!t)return null;let i=D(o.getDefaultEnv()),r=new I(i.tmsBaseUrl,t.username,t.access_key);try{let p=(await r.listProjects()).find(k=>k.name==="KaneAI Generated");if(p)return{id:p.project_id,name:p.name};let b=await r.createProject("KaneAI Generated");return{id:b.id,name:b.name}}catch{return null}},[w,o]),pe=(0,s.useCallback)(async e=>{let t=w();if(!t)return null;let i=t.cached??await t.resolve();if(!i)return null;let r=D(o.getDefaultEnv()),a=new I(r.tmsBaseUrl,i.username,i.access_key);try{let b=(await a.listFolders(e)).find(me=>me.name==="Untitled");if(b)return{id:b.id,name:b.name};let k=await a.createFolder(e,"Untitled");return{id:k.id,name:k.name}}catch{return null}},[w,o]);if(h==="gate")return(0,n.jsx)(c,{paddingX:1,children:(0,n.jsx)(u,{color:"yellow",children:"Checking authentication..."})});if(X)return(0,n.jsxs)(c,{flexDirection:"column",paddingX:1,children:[(0,n.jsx)(u,{color:"red",children:X}),(0,n.jsx)(u,{color:"gray",children:"Press Ctrl+C to exit."})]});if(h==="pick"&&M?.status==="needs_pick")return(0,n.jsx)(xe,{profiles:M.profiles,onSelect:de});if(h==="login")return(0,n.jsx)(W,{devMode:process.env.KANE_DEV_MODE==="1",profiles:o.listProfiles(),onBasicLogin:async(e,t,i,r)=>{let{validateBasicAuth:a}=await import("./validate-basic-YNGP5JFB.js");await a(t,i,r),o.saveBasicAuth(e,t,{username:i,access_key:r}),o.setActiveProfile(e),o.setDefaultEnv(t)},onOAuthLogin:async(e,t)=>{let{LoginFlow:i}=await import("./login-flow-GZ3XHVCS.js");o.setDefaultEnv(t),o.setActiveProfile(e),await new i(e,t,o).login()},onComplete:(e,t)=>{R(e),$(t),o.setActiveProfile(e),o.setDefaultEnv(t),S(e,t)},onCancel:()=>{C(0,"Login cancelled")}});if(h==="ensure-project"){let e=o.getActiveProfile()??"default",t=o.getDefaultEnv(),i=()=>{if(g==="login"){f("ensure-folder");return}T(o,l,e,t).folderId?y():f("ensure-folder")};return(0,n.jsxs)(c,{flexDirection:"column",children:[(0,n.jsx)(c,{paddingX:1,marginBottom:1,children:(0,n.jsx)(u,{color:"yellow",children:"Project & folder are required to save tests \xB7 Esc to use defaults \xB7 Ctrl+C to exit"})}),(0,n.jsx)(Z,{resolver:w(),currentProjectId:l.load().project_id,env:t,onSelect:(r,a)=>{j(o,l,e,t,{projectId:r,projectName:a}),_(p=>[...p,`\u2713 Project: ${a} (${r})`]),i()},onCancel:async()=>{let r=await ge();r&&(j(o,l,e,t,{projectId:r.id,projectName:r.name}),_(a=>[...a,`\u2713 Default project: ${r.name} (${r.id})`]),i())}})]})}if(h==="ensure-folder"){let e=o.getActiveProfile()??"default",t=o.getDefaultEnv(),i=o.loadProfileConfig(e,t);return(0,n.jsxs)(c,{flexDirection:"column",children:[(0,n.jsx)(c,{paddingX:1,marginBottom:1,children:(0,n.jsx)(u,{color:"yellow",children:"Project & folder are required to save tests \xB7 Esc to use defaults \xB7 Ctrl+C to exit"})}),(0,n.jsx)(ee,{resolver:w(),projectId:i?.project_id??"",currentFolderId:l.load().folder_id,env:t,onSelect:(r,a)=>{j(o,l,e,t,{folderId:r,folderName:a}),_(p=>[...p,`\u2713 Folder: ${a} (${r})`]),y()},onCancel:async()=>{if(!i?.project_id)return;let r=await pe(i.project_id);r&&(j(o,l,e,t,{folderId:r.id,folderName:r.name}),_(a=>[...a,`\u2713 Default folder: ${r.name} (${r.id})`]),y())}})]})}if(h==="target"){let e=B(l.load().mobile?.tui_target,l.load().mobile?.default_target?.kind).kind==="choose-mobile";return(0,n.jsx)(c,{paddingX:1,children:(0,n.jsx)(le,{mode:e?"mobile-only":"all",onSelect:t=>{l.setMobile({tui_target:t}),f("input")},onCancel:()=>f("input")})})}if(h==="input"){let e=l.load().mobile,t=B(e?.tui_target,e?.default_target?.kind),i=(()=>{if(t.kind==="emulator"||t.kind==="simulator"){let r=J(e?.default_target)??"(no device)",a=e?.default_app?Y(e.default_app)?e.default_app:he(e.default_app):"(no app)";return`Config: ${K(t.kind)} \xB7 ${r} \xB7 ${a}`}return"Config: Desktop \xB7 Chrome"})();return(0,n.jsxs)(c,{flexDirection:"column",children:[N.length>0&&(0,n.jsx)(c,{flexDirection:"column",paddingX:1,marginBottom:1,children:N.map((r,a)=>(0,n.jsx)(u,{color:"green",children:r},a))}),(0,n.jsx)(c,{paddingX:1,children:(0,n.jsx)(u,{color:"gray",children:i})}),(0,n.jsx)(H,{onSubmit:fe,onEscape:()=>C(0,"User pressed Escape"),history:ae,placeholder:"Type an objective..."})]})}return(0,n.jsx)(n.Fragment,{})}function xe({profiles:x,onSelect:g}){let[d,m]=(0,s.useState)(0),[A,E]=(0,s.useState)(!1);return L((v,o)=>{if(!A){if(o.escape){C(0,"Profile picker cancelled");return}if(o.upArrow&&d>0&&m(l=>l-1),o.downArrow&&d<x.length-1&&m(l=>l+1),o.return){E(!0);let l=x[d];g(l.profile,l.env).catch(()=>E(!1))}}}),(0,n.jsxs)(c,{flexDirection:"column",paddingX:1,children:[(0,n.jsx)(u,{color:"#ff9500",bold:!0,children:"Select a profile:"}),(0,n.jsx)(c,{marginTop:1,flexDirection:"column",children:x.map((v,o)=>(0,n.jsxs)(u,{children:[o===d?"\u276F ":" ",(0,n.jsx)(u,{color:o===d?"#ff9500":"white",bold:o===d,children:v.profile}),(0,n.jsxs)(u,{color:"gray",children:[" [",v.env,"]"]})]},`${v.profile}-${v.env}`))}),A&&(0,n.jsx)(c,{marginTop:1,children:(0,n.jsx)(u,{color:"yellow",children:"Validating credentials..."})})]})}export{Ge as a};
2
+ import{b as V,c as H,d as W,e as ie,f as se}from"./chunk-3SPOJWRA.js";import{a as le}from"./chunk-DA57DXCF.js";import{c as te}from"./chunk-M7DN6FO3.js";import{a as oe}from"./chunk-O5AS2ZIX.js";import{a as re}from"./chunk-4BBDKWM3.js";import{b as Z}from"./chunk-WOA7VCGA.js";import{b as ee}from"./chunk-YHR2YAN5.js";import{a as I}from"./chunk-BPMSNGXQ.js";import{a as T,b as j,d as ne}from"./chunk-VE3SUJMA.js";import{b as Q}from"./chunk-TZXXJWHA.js";import{r as C}from"./chunk-RSSOJ3L2.js";import{b as Y}from"./chunk-AC7BPO4X.js";import{i as J}from"./chunk-Z7S3IWUX.js";import{a as D}from"./chunk-OH2NSBO6.js";import{a as B,e as K}from"./chunk-EYOCNMUM.js";import{a as z}from"./chunk-IQ7NGOAT.js";import{a as q}from"./chunk-HCBYKLMW.js";import{a as c,b as u,i as L,j as G}from"./chunk-C44QQJR4.js";import{a as ve}from"./chunk-6YGTRKDT.js";import{e as F}from"./chunk-UR6MHSHU.js";var s=F(ve(),1);import{basename as he}from"path";var n=F(q(),1);function Ge({resultRef:x,mode:g="singleshot",loginCompleteRef:d}){let{exit:m}=G(),A=(0,s.useRef)(new z),E=(0,s.useRef)(new oe),v=(0,s.useRef)(new te),o=A.current,l=E.current,O=v.current,ae=V(),[h,f]=(0,s.useState)(g==="login"?"login":"gate"),[M,ce]=(0,s.useState)(null),[Pe,R]=(0,s.useState)(null),[we,$]=(0,s.useState)(null),[X,ue]=(0,s.useState)(null),[N,_]=(0,s.useState)([]),P=(0,s.useCallback)((e,t,i,r)=>O.log(e,t,i,r),[O]),be=(0,s.useCallback)((e,t)=>{e?T(o,l,e,t):l.save({project_id:null,project_name:null,folder_id:null,folder_name:null})},[o,l]),y=(0,s.useCallback)(()=>{if(g==="login")d&&(d.current=!0),m();else{let e=l.load().mobile,t=B(e?.tui_target,e?.default_target?.kind),i=(t.kind==="unset"||t.kind==="choose-mobile")&&Q();f(i?"target":"input")}},[g,m,d,l]),S=(0,s.useCallback)((e,t)=>{let i=T(o,l,e,t);if(g==="login"){f("ensure-project");return}ne(i)?y():i.projectId?f("ensure-folder"):f("ensure-project")},[o,l,y,g]);L((e,t)=>{t.ctrl&&e==="c"&&C(0,"Ctrl+C exit")});let U=(0,s.useRef)(!1);s.default.useEffect(()=>{U.current||(U.current=!0,g!=="login"&&se(o,P).then(e=>{ce(e),e.status==="authenticated"?S(e.result.profile,e.result.env):e.status==="needs_pick"?f("pick"):(R(e.profile??null),$(e.env??null),f("login"))}).catch(e=>{ue(`Auth check failed: ${e instanceof Error?e.message:String(e)}`)}))},[o,P]);let fe=(0,s.useCallback)(e=>{x.current={objective:e},m()},[x,m]),de=(0,s.useCallback)(async(e,t)=>{o.setActiveProfile(e),o.setDefaultEnv(t),(await ie(o,e,t,P)).status==="authenticated"?S(e,t):(R(e),$(t),f("login"))},[o,P,S]),w=(0,s.useCallback)(()=>{let e=o.getActiveProfile(),t=o.getDefaultEnv();if(!e)return null;let i=D(t),r=o.loadBasicAuth(e,t);return new re(i.controllerBaseUrl,async()=>o.loadCredentials(e,t)?.access_token??null,r,P)},[o,P]),ge=(0,s.useCallback)(async()=>{let e=w();if(!e)return null;let t=e.cached??await e.resolve();if(!t)return null;let i=D(o.getDefaultEnv()),r=new I(i.tmsBaseUrl,t.username,t.access_key);try{let p=(await r.listProjects()).find(k=>k.name==="KaneAI Generated");if(p)return{id:p.project_id,name:p.name};let b=await r.createProject("KaneAI Generated");return{id:b.id,name:b.name}}catch{return null}},[w,o]),pe=(0,s.useCallback)(async e=>{let t=w();if(!t)return null;let i=t.cached??await t.resolve();if(!i)return null;let r=D(o.getDefaultEnv()),a=new I(r.tmsBaseUrl,i.username,i.access_key);try{let b=(await a.listFolders(e)).find(me=>me.name==="Untitled");if(b)return{id:b.id,name:b.name};let k=await a.createFolder(e,"Untitled");return{id:k.id,name:k.name}}catch{return null}},[w,o]);if(h==="gate")return(0,n.jsx)(c,{paddingX:1,children:(0,n.jsx)(u,{color:"yellow",children:"Checking authentication..."})});if(X)return(0,n.jsxs)(c,{flexDirection:"column",paddingX:1,children:[(0,n.jsx)(u,{color:"red",children:X}),(0,n.jsx)(u,{color:"gray",children:"Press Ctrl+C to exit."})]});if(h==="pick"&&M?.status==="needs_pick")return(0,n.jsx)(xe,{profiles:M.profiles,onSelect:de});if(h==="login")return(0,n.jsx)(W,{devMode:process.env.KANE_DEV_MODE==="1",profiles:o.listProfiles(),onBasicLogin:async(e,t,i,r)=>{let{validateBasicAuth:a}=await import("./validate-basic-RCBEELSB.js");await a(t,i,r),o.saveBasicAuth(e,t,{username:i,access_key:r}),o.setActiveProfile(e),o.setDefaultEnv(t)},onOAuthLogin:async(e,t)=>{let{LoginFlow:i}=await import("./login-flow-PRXFPRYZ.js");o.setDefaultEnv(t),o.setActiveProfile(e),await new i(e,t,o).login()},onComplete:(e,t)=>{R(e),$(t),o.setActiveProfile(e),o.setDefaultEnv(t),S(e,t)},onCancel:()=>{C(0,"Login cancelled")}});if(h==="ensure-project"){let e=o.getActiveProfile()??"default",t=o.getDefaultEnv(),i=()=>{if(g==="login"){f("ensure-folder");return}T(o,l,e,t).folderId?y():f("ensure-folder")};return(0,n.jsxs)(c,{flexDirection:"column",children:[(0,n.jsx)(c,{paddingX:1,marginBottom:1,children:(0,n.jsx)(u,{color:"yellow",children:"Project & folder are required to save tests \xB7 Esc to use defaults \xB7 Ctrl+C to exit"})}),(0,n.jsx)(Z,{resolver:w(),currentProjectId:l.load().project_id,env:t,onSelect:(r,a)=>{j(o,l,e,t,{projectId:r,projectName:a}),_(p=>[...p,`\u2713 Project: ${a} (${r})`]),i()},onCancel:async()=>{let r=await ge();r&&(j(o,l,e,t,{projectId:r.id,projectName:r.name}),_(a=>[...a,`\u2713 Default project: ${r.name} (${r.id})`]),i())}})]})}if(h==="ensure-folder"){let e=o.getActiveProfile()??"default",t=o.getDefaultEnv(),i=o.loadProfileConfig(e,t);return(0,n.jsxs)(c,{flexDirection:"column",children:[(0,n.jsx)(c,{paddingX:1,marginBottom:1,children:(0,n.jsx)(u,{color:"yellow",children:"Project & folder are required to save tests \xB7 Esc to use defaults \xB7 Ctrl+C to exit"})}),(0,n.jsx)(ee,{resolver:w(),projectId:i?.project_id??"",currentFolderId:l.load().folder_id,env:t,onSelect:(r,a)=>{j(o,l,e,t,{folderId:r,folderName:a}),_(p=>[...p,`\u2713 Folder: ${a} (${r})`]),y()},onCancel:async()=>{if(!i?.project_id)return;let r=await pe(i.project_id);r&&(j(o,l,e,t,{folderId:r.id,folderName:r.name}),_(a=>[...a,`\u2713 Default folder: ${r.name} (${r.id})`]),y())}})]})}if(h==="target"){let e=B(l.load().mobile?.tui_target,l.load().mobile?.default_target?.kind).kind==="choose-mobile";return(0,n.jsx)(c,{paddingX:1,children:(0,n.jsx)(le,{mode:e?"mobile-only":"all",onSelect:t=>{l.setMobile({tui_target:t}),f("input")},onCancel:()=>f("input")})})}if(h==="input"){let e=l.load().mobile,t=B(e?.tui_target,e?.default_target?.kind),i=(()=>{if(t.kind==="emulator"||t.kind==="simulator"){let r=J(e?.default_target)??"(no device)",a=e?.default_app?Y(e.default_app)?e.default_app:he(e.default_app):"(no app)";return`Config: ${K(t.kind)} \xB7 ${r} \xB7 ${a}`}return"Config: Desktop \xB7 Chrome"})();return(0,n.jsxs)(c,{flexDirection:"column",children:[N.length>0&&(0,n.jsx)(c,{flexDirection:"column",paddingX:1,marginBottom:1,children:N.map((r,a)=>(0,n.jsx)(u,{color:"green",children:r},a))}),(0,n.jsx)(c,{paddingX:1,children:(0,n.jsx)(u,{color:"gray",children:i})}),(0,n.jsx)(H,{onSubmit:fe,onEscape:()=>C(0,"User pressed Escape"),history:ae,placeholder:"Type an objective..."})]})}return(0,n.jsx)(n.Fragment,{})}function xe({profiles:x,onSelect:g}){let[d,m]=(0,s.useState)(0),[A,E]=(0,s.useState)(!1);return L((v,o)=>{if(!A){if(o.escape){C(0,"Profile picker cancelled");return}if(o.upArrow&&d>0&&m(l=>l-1),o.downArrow&&d<x.length-1&&m(l=>l+1),o.return){E(!0);let l=x[d];g(l.profile,l.env).catch(()=>E(!1))}}}),(0,n.jsxs)(c,{flexDirection:"column",paddingX:1,children:[(0,n.jsx)(u,{color:"#ff9500",bold:!0,children:"Select a profile:"}),(0,n.jsx)(c,{marginTop:1,flexDirection:"column",children:x.map((v,o)=>(0,n.jsxs)(u,{children:[o===d?"\u276F ":" ",(0,n.jsx)(u,{color:o===d?"#ff9500":"white",bold:o===d,children:v.profile}),(0,n.jsxs)(u,{color:"gray",children:[" [",v.env,"]"]})]},`${v.profile}-${v.env}`))}),A&&(0,n.jsx)(c,{marginTop:1,children:(0,n.jsx)(u,{color:"yellow",children:"Validating credentials..."})})]})}export{Ge as a};
@@ -1,4 +1,4 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as f,d as l}from"./chunk-ASYWKYTQ.js";import{a as p}from"./chunk-TZXXJWHA.js";function d(t,e,o){return{id:`${t}.internal`,label:e,required:!0,status:"fail",detail:o instanceof Error?o.message:String(o)}}async function k(t,e={}){let o=p();if(!o.supported)return{sections:[{platform:"host",checks:[{id:"host.platform",label:"host",required:!0,status:"fail",detail:o.reason}]}]};let n=t?f().filter(r=>r.toLowerCase()===t.toLowerCase()):f(),{managedDeps:i}=await import("./deps-bundle-PZNXSKLC.js"),s=n.flatMap(r=>r==="android"?["emulator"]:r==="ios"?["simulator"]:[]);await Promise.allSettled(s.map(r=>i().warmResolveCache(r)));let c=[];for(let r of n){let u=l(r);if(!u)continue;let a;try{a=await u.checks(e)}catch(h){a=[d(r,"toolchain check",h)]}c.push({platform:r,checks:a})}return{sections:c}}function m(t){return t==="pass"?"\u2713":t==="fail"?"\u2717":"\u2139"}function x(t){return t.charAt(0).toUpperCase()+t.slice(1)}function C(t){let e=[];if(t.sections.length===0)return"No mobile platforms are supported on this host.";for(let o of t.sections){e.length>0&&e.push(""),e.push(`${x(o.platform)} toolchain`);let n=o.checks.filter(s=>s.status!=="info"),i=new Set;for(let s of n){let c=s.detail?` \u2014 ${s.detail}`:"";if(e.push(` ${m(s.status)} ${s.label}${c}`),s.status==="fail"&&s.fixText&&!i.has(s.fixText)){i.add(s.fixText);for(let r of s.fixText.split(`
2
+ import{b as f,d as l}from"./chunk-RQLU4NDG.js";import{a as p}from"./chunk-TZXXJWHA.js";function d(t,e,o){return{id:`${t}.internal`,label:e,required:!0,status:"fail",detail:o instanceof Error?o.message:String(o)}}async function k(t,e={}){let o=p();if(!o.supported)return{sections:[{platform:"host",checks:[{id:"host.platform",label:"host",required:!0,status:"fail",detail:o.reason}]}]};let n=t?f().filter(r=>r.toLowerCase()===t.toLowerCase()):f(),{managedDeps:i}=await import("./deps-bundle-RVZK6LZJ.js"),s=n.flatMap(r=>r==="android"?["emulator"]:r==="ios"?["simulator"]:[]);await Promise.allSettled(s.map(r=>i().warmResolveCache(r)));let c=[];for(let r of n){let u=l(r);if(!u)continue;let a;try{a=await u.checks(e)}catch(h){a=[d(r,"toolchain check",h)]}c.push({platform:r,checks:a})}return{sections:c}}function m(t){return t==="pass"?"\u2713":t==="fail"?"\u2717":"\u2139"}function x(t){return t.charAt(0).toUpperCase()+t.slice(1)}function C(t){let e=[];if(t.sections.length===0)return"No mobile platforms are supported on this host.";for(let o of t.sections){e.length>0&&e.push(""),e.push(`${x(o.platform)} toolchain`);let n=o.checks.filter(s=>s.status!=="info"),i=new Set;for(let s of n){let c=s.detail?` \u2014 ${s.detail}`:"";if(e.push(` ${m(s.status)} ${s.label}${c}`),s.status==="fail"&&s.fixText&&!i.has(s.fixText)){i.add(s.fixText);for(let r of s.fixText.split(`
3
3
  `))e.push(` fix: ${r}`)}}}return e.join(`
4
4
  `)}function w(t){return t.sections.length===0?!0:t.sections.every(e=>e.checks.some(o=>o.required&&o.status==="fail"&&!o.fixedByBundle))}function b(t){for(let e of t.sections)for(let o of e.checks)if(o.required&&o.status!=="pass")return 2;return 0}export{k as a,C as b,w as c,b as d};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as h}from"./chunk-FBYB3SRE.js";import{a as f}from"./chunk-3G3LY6BM.js";import{a as m}from"./chunk-7KAPHA56.js";var o=class extends Error{constructor(a,l){super(a);this.code=l;this.name="AuthError"}};async function k(c){let{creds:i,env:a,usernameFlag:l,accessKeyFlag:g,log:t}=c,e=null,u=null;if(l&&g)e={username:l,access_key:g},t("info","AUTH_RESOLVE_FLAGS","Auth resolved via CLI flags",{username:l});else{let r=i.resolveAuth();r?.method==="basic"&&(e={username:r.username,access_key:r.access_key},t("info","AUTH_RESOLVE_CONFIG","Auth resolved via config",{username:r.username}))}if(!e){let{credentials:r,profile:E}=i.getActiveCredentials();if(!r)throw new o("Not authenticated \u2014 no credentials found","not_authenticated");if(u=r.access_token,r.expires_at-Date.now()/1e3<300)try{let n=await f({creds:i,profile:E,env:a,credentials:r});n&&(u=n.accessToken,t("info","AUTH_TOKEN_REFRESHED","OAuth token refreshed"))}catch(n){let d=n instanceof Error?n.message:String(n);throw t("error","TOKEN_REFRESH_FAILED","Token refresh failed",{error:d}),new o(`Token refresh failed: ${d}`,"refresh_failed")}}let v=m(a),b=async()=>u,y=e?{username:e.username,access_key:e.access_key}:null,p=new h(v.controllerBaseUrl,b,y,t),s=await p.resolve();return s&&!e&&(e={username:s.username,access_key:s.access_key},t("info","AUTH_RESOLVE_CONTROLLER","Auth resolved via controller",{username:s.username})),{basicAuth:e,token:u,resolver:p,resolvedCreds:s}}export{o as a,k as b};
2
+ import{a as h}from"./chunk-4BBDKWM3.js";import{a as f}from"./chunk-N7ZRF5K3.js";import{a as m}from"./chunk-OH2NSBO6.js";var o=class extends Error{constructor(a,l){super(a);this.code=l;this.name="AuthError"}};async function k(c){let{creds:i,env:a,usernameFlag:l,accessKeyFlag:g,log:t}=c,e=null,u=null;if(l&&g)e={username:l,access_key:g},t("info","AUTH_RESOLVE_FLAGS","Auth resolved via CLI flags",{username:l});else{let r=i.resolveAuth();r?.method==="basic"&&(e={username:r.username,access_key:r.access_key},t("info","AUTH_RESOLVE_CONFIG","Auth resolved via config",{username:r.username}))}if(!e){let{credentials:r,profile:E}=i.getActiveCredentials();if(!r)throw new o("Not authenticated \u2014 no credentials found","not_authenticated");if(u=r.access_token,r.expires_at-Date.now()/1e3<300)try{let n=await f({creds:i,profile:E,env:a,credentials:r});n&&(u=n.accessToken,t("info","AUTH_TOKEN_REFRESHED","OAuth token refreshed"))}catch(n){let d=n instanceof Error?n.message:String(n);throw t("error","TOKEN_REFRESH_FAILED","Token refresh failed",{error:d}),new o(`Token refresh failed: ${d}`,"refresh_failed")}}let v=m(a),b=async()=>u,y=e?{username:e.username,access_key:e.access_key}:null,p=new h(v.controllerBaseUrl,b,y,t),s=await p.resolve();return s&&!e&&(e={username:s.username,access_key:s.access_key},t("info","AUTH_RESOLVE_CONTROLLER","Auth resolved via controller",{username:s.username})),{basicAuth:e,token:u,resolver:p,resolvedCreds:s}}export{o as a,k as b};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as m}from"./chunk-3CCD434H.js";import{x as t}from"./chunk-NJJQL54J.js";import{a as p}from"./chunk-HCBYKLMW.js";import{a,b as r,i as u}from"./chunk-C44QQJR4.js";import{a as b}from"./chunk-6YGTRKDT.js";import{e as n}from"./chunk-UR6MHSHU.js";var c=n(b(),1);var e=n(p(),1);function R({onSubmit:l}){let[o,f]=(0,c.useState)(0),s=(0,c.useRef)(!1);return u((x,i)=>{s.current||(i.leftArrow||i.rightArrow?f(d=>d===0?1:0):i.return?(s.current=!0,l(o===0?"positive":"negative")):i.escape&&(s.current=!0,l(null)))}),(0,e.jsxs)(a,{flexDirection:"column",marginTop:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(r,{color:t.secondary,children:"Rate this session: "}),(0,e.jsx)(r,{color:o===0?t.orange:t.dim,children:o===0?"[ \u{1F44D} ]":" \u{1F44D} "}),(0,e.jsx)(r,{children:" "}),(0,e.jsx)(r,{color:o===1?t.orange:t.dim,children:o===1?"[ \u{1F44E} ]":" \u{1F44E} "})]}),(0,e.jsx)(m,{bindings:[{keys:"\u2190/\u2192",label:"select"},{keys:"\u21B5",label:"submit"}],escBackLabel:"skip"})]})}export{R as a};
2
+ import{a as m}from"./chunk-OO5GMBVI.js";import{y as t}from"./chunk-B2ZGG7WM.js";import{a as p}from"./chunk-HCBYKLMW.js";import{a,b as r,i as u}from"./chunk-C44QQJR4.js";import{a as b}from"./chunk-6YGTRKDT.js";import{e as n}from"./chunk-UR6MHSHU.js";var c=n(b(),1);var e=n(p(),1);function R({onSubmit:l}){let[o,f]=(0,c.useState)(0),s=(0,c.useRef)(!1);return u((x,i)=>{s.current||(i.leftArrow||i.rightArrow?f(d=>d===0?1:0):i.return?(s.current=!0,l(o===0?"positive":"negative")):i.escape&&(s.current=!0,l(null)))}),(0,e.jsxs)(a,{flexDirection:"column",marginTop:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(r,{color:t.secondary,children:"Rate this session: "}),(0,e.jsx)(r,{color:o===0?t.orange:t.dim,children:o===0?"[ \u{1F44D} ]":" \u{1F44D} "}),(0,e.jsx)(r,{children:" "}),(0,e.jsx)(r,{color:o===1?t.orange:t.dim,children:o===1?"[ \u{1F44E} ]":" \u{1F44E} "})]}),(0,e.jsx)(m,{bindings:[{keys:"\u2190/\u2192",label:"select"},{keys:"\u21B5",label:"submit"}],escBackLabel:"skip"})]})}export{R as a};
@@ -0,0 +1,15 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{a as S,c as M}from"./chunk-LBNADEQN.js";import{dirname as W,basename as N,join as d}from"path";function G(t){let e=N(t);return e.endsWith("_test.md")?e.slice(0,-8):e.endsWith("_module.md")?e.slice(0,-10):e.endsWith(".md")?e.slice(0,-3):e}function f(t){return d(W(t),`output-${G(t)}`)}function rt(t){return d(f(t),"Result.md")}function _(t){return d(f(t),".internal")}function w(t){return d(_(t),"meta.json")}function ot(t){return d(_(t),"execution.json")}function st(t,e,n){return d(f(t),`${e}-${n}-code`)}function dt(t){return d(f(t),"generated-code")}function at(t){return f(t)+".staging"}function J(t){return d(_(t),"steps")}function ct(t,e,n){return d(J(t),`${e}-${n}`)}import{writeFileSync as L,mkdirSync as H,readFileSync as U}from"fs";import{dirname as k}from"path";function j(t){try{return JSON.parse(U(w(t),"utf8"))}catch{return null}}function ft(t){let e=w(t.sourcePath);try{H(k(e),{recursive:!0})}catch(r){return process.stderr.write(`
3
+ \u26A0 Failed to create output directory.
4
+ ${r.message}
5
+ Path: ${k(e)}
6
+
7
+ `),e}let n={commit_id:t.commitId};t.testId!==void 0&&(n.test_id=t.testId),t.testcaseId!==void 0&&(n.testcase_id=t.testcaseId),t.projectId!==void 0&&(n.project_id=t.projectId),t.folderId!==void 0&&(n.folder_id=t.folderId),t.orgId!==void 0&&(n.org_id=t.orgId),t.sessionName!==void 0&&(n.session_name=t.sessionName),t.plan!==void 0&&(n.plan=t.plan);try{L(e,JSON.stringify(n,null,2)+`
8
+ `,"utf8")}catch(r){process.stderr.write(`
9
+ \u26A0 Failed to write meta.json.
10
+ ${r.message}
11
+ Path: ${e}
12
+
13
+ `)}return e}import{readFileSync as z,existsSync as q}from"fs";import{basename as C,dirname as B,isAbsolute as Q,resolve as F}from"path";import{createHash as O}from"crypto";function h(t){if(t==null)return null;if(Array.isArray(t))return t.map(h);if(typeof t=="object"){let e={};for(let n of Object.keys(t).sort()){let r=t[n];r!==void 0&&(e[n]=h(r))}return e}return t}function Y(t){if(t.body.kind!=="objective")throw new Error("stepMd5: only objective steps have an md5; @import rows do not");let e={...t.config??{},optional:t.optional??!1},n=JSON.stringify(h(e));return O("md5").update(t.body.text).update(`
14
+ `).update(n).digest("hex")}function I(t){let e={};for(let[r,o]of Object.entries(t.bindings??{}))e[r]={value:o.value,...o.secret===!0?{secret:!0}:{},...o.syntax?{syntax:o.syntax}:{}};let n=JSON.stringify(h({bindings:e,optional:t.optional}));return O("md5").update(t.path).update(`
15
+ `).update(n).digest("hex")}function bt(t){return Y({index:t.trace[t.trace.length-1].stepIndex,heading:t.trace[t.trace.length-1].heading,verifies:[],body:{kind:"objective",text:t.objective},config:t.parsedConfig,headingLine:1,optional:t.optional})}var T=["target","chrome_profile","cdp_endpoint","ws_endpoint","headless"],X=["app","no_reset","os_version","device_name"],Z=["mode","on_lock_conflict","tags","target","chrome_profile","cdp_endpoint","ws_endpoint","headless","app","no_reset","os_version","device_name"],g=class extends Error{constructor(e){super(e),this.name="TestMdResolveError"}};function v(t){let e=C(t);return e.endsWith("_test.md")?"test":e.endsWith("_module.md")?"module":"helper"}function St(t){let e=F(t),n=E(e),r=tt(n.global),o=[],a=[],s=[{file:e,kind:v(e)}],c=[];return $(n,a,o,[],e,{},s,c,{}),o.forEach((u,b)=>u.flatIndex=b+1),{rootPath:e,rootTitle:n.title,rootGlobal:n.global,rootSteps:n.steps,chrome:r,steps:o,unitFiles:s,warnings:c}}function Mt(t){let e=[];for(let n of t.unitFiles){if(n.kind!=="test")continue;let r=j(n.file);r&&e.push({file:n.file,...r.project_id?{project_id:String(r.project_id)}:{},...r.org_id?{org_id:String(r.org_id)}:{}})}return e}function E(t){if(!q(t))throw new g(`@import path not found: ${t}`);let e=z(t,"utf8");return S(t,e)}function $(t,e,n,r,o,a,s,c,p){if(e.includes(t.path)){let i=[...e,t.path].map(l=>C(l)).join(" \u2192 ");throw new g(`cyclic reference: ${i}`)}e.push(t.path);let u=r.length===0,b=t.global.variables??{};for(let i of Object.keys(a))if(Object.hasOwn(b,i))throw new g(`callsite binding '${i}' collides with a declared variable in ${t.path} (frontmatter variables are pinned; parameters are its undeclared names)`);let x=t.global;if(!u){let i={...t.global};for(let l of Z)i[l]!==void 0&&(c.push(`${t.path}: '${l}' is root-governed on imported units \u2014 ignored`),delete i[l]);i.url!==void 0&&(p.pending=String(i.url),delete i.url),x=i}let P=new Map;for(let i of t.steps){let l=i.body.kind!=="objective";if(i.optional&&l&&!u)throw new g(`intermediate-ref 'optional' is not supported in v1: ${t.path}:${i.headingLine}`);if(i.body.kind==="objective"){let y={file:t.path,stepIndex:i.index,heading:i.heading,optional:i.optional??!1},K=et(x,i.config,a),R={flatIndex:0,objective:i.body.text,sourceFile:t.path,trace:[...r,y],config:K,parsedConfig:i.config,optional:i.optional??!1,verifies:i.verifies,owningFile:t.path,unitKind:v(t.path),...i.replayOnly?{replayOnly:i.replayOnly}:{},...i.controlFlow?{controlFlow:i.controlFlow}:{},...i.block?{block:{...i.block,id:nt(i,n.length+1,P)}}:{}};p.pending&&(R.unitEntryUrl=p.pending,p.pending=void 0),n.push(R);continue}let V={file:t.path,stepIndex:i.index,heading:i.heading,optional:i.optional??!1,rowMd5:I({path:i.body.path,bindings:i.body.bindings,optional:i.optional??!1})},A=B(t.path),m=Q(i.body.path)?i.body.path:F(A,i.body.path),D=E(m);s.some(y=>y.file===m)||s.push({file:m,kind:v(m)}),$(D,e,n,[...r,V],o,i.body.bindings??{},s,c,p)}u||(p.pending=void 0),e.pop()}function tt(t){let e={};for(let n of T){if(n==="target"){let r=M(t);r!==void 0&&(e.target=r);continue}t[n]!==void 0&&(e[n]=t[n])}return e}function et(t,e,n){let r={};for(let[s,c]of Object.entries(t))T.includes(s)||X.includes(s)||(r[s]=c);let o={...r,...e??{}},a={...n,...t.variables??{},...e?.variables??{}};return Object.keys(a).length>0?o.variables=a:delete o.variables,o}function nt(t,e,n){let r=t.block.id;if(t.controlFlow==="if"||t.controlFlow==="while")return n.set(r,e),e;let o=n.get(r);if(o===void 0)throw new g(`block member before its opener in ${t.heading}`);return o}export{G as a,f as b,rt as c,_ as d,w as e,ot as f,st as g,dt as h,at as i,J as j,ct as k,I as l,bt as m,j as n,ft as o,g as p,v as q,St as r,Mt as s};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as R}from"./chunk-TDPWFYTJ.js";import{a as x}from"./chunk-APZCLVZD.js";import{d as S}from"./chunk-ASYWKYTQ.js";import{a as y}from"./chunk-MMBBQ4OZ.js";import{a as p}from"./chunk-7KAPHA56.js";import{d as g,i as E}from"./chunk-NJJQL54J.js";import{spawn as M,execSync as h}from"child_process";import{appendFileSync as b,existsSync as m,mkdirSync as C}from"fs";import{homedir as L}from"os";import{join as V,resolve as s,dirname as v,delimiter as T}from"path";import{fileURLToPath as U}from"url";import{createInterface as I}from"readline";async function*A(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 N(e){return e==="dom"?{set:{V16_AGENT_ENABLE_TEXTUAL_VISUAL:"true"},unset:[]}:{set:{},unset:["V16_AGENT_ENABLE_TEXTUAL_VISUAL"]}}var c=v(U(import.meta.url));function k(){for(let e of["python3","python"])try{return h(`${e} --version`,{stdio:"ignore"}),e}catch{}return null}function D(){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(m(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(m(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(m(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(m(u))return{cmd:u,args:["main.py"],cwd:t};let a=k();if(a)return{cmd:a,args:["main.py"],cwd:t}}return null}function P(e){return e?V(L(),".testmuai","kaneai","sessions",e,"runner-stderr.log"):null}function K(e){let n=M(e.runner.cmd,e.runner.args,{stdio:["pipe","pipe","pipe"],env:e.env,cwd:e.runner.cwd});n.stdin.on("error",()=>{});let r=P(e.sessionId);if(r)try{C(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{b(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",(f,_)=>{d=f,l=_?String(_):null,e.log?.("info","RUNNER_EXIT","Runner exited",{code:f,signal:l??"none"}),u({code:f,signal:l})})}),a=A(n.stdout);return{child:n,events:a,getStderr:()=>i,getExitCode:()=>d,getExitSignal:()=>l,exited:t}}async function B(e,n){if(!n?.platform||!n.target_kind)return;let r=await S(n.platform)?.toolEnv(n.target_kind)??{dirs:[]};if(r.dirs.length>0&&(e.PATH=[...r.dirs,e.PATH??""].filter(Boolean).join(T)),r.appiumHome&&(e.APPIUM_HOME=r.appiumHome),r.wdaRoot&&(e.TESTMU_IOS_WDA_DERIVED_DATA=r.wdaRoot),n.platform==="android"){let o=y();o&&(e.PATH=[o.platformToolsDir,e.PATH??""].filter(Boolean).join(T),e.ANDROID_HOME=o.root,e.ANDROID_SDK_ROOT=o.root)}}function H(e){let n={...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=p(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 x().load(),d=N(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 G(e,n){let r=p(n?.environment),o=R();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={url:r.shareApiBaseUrl.replace(/\/$/,"")+"/mfs/v1.0/media/upload",artefacts_host:r.mediaArtefactsHost,org_id:e.org_id,media_dir:g})}async function oe(e,n){let r=D();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)}
2
+ import{a as R}from"./chunk-TDPWFYTJ.js";import{a as x}from"./chunk-O5AS2ZIX.js";import{d as S}from"./chunk-RQLU4NDG.js";import{a as y}from"./chunk-MMBBQ4OZ.js";import{a as p}from"./chunk-OH2NSBO6.js";import{d as g,i as E}from"./chunk-B2ZGG7WM.js";import{spawn as M,execSync as h}from"child_process";import{appendFileSync as b,existsSync as m,mkdirSync as C}from"fs";import{homedir as L}from"os";import{join as V,resolve as s,dirname as v,delimiter as T}from"path";import{fileURLToPath as U}from"url";import{createInterface as I}from"readline";async function*A(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 N(e){return e==="dom"?{set:{V16_AGENT_ENABLE_TEXTUAL_VISUAL:"true"},unset:[]}:{set:{},unset:["V16_AGENT_ENABLE_TEXTUAL_VISUAL"]}}var c=v(U(import.meta.url));function k(){for(let e of["python3","python"])try{return h(`${e} --version`,{stdio:"ignore"}),e}catch{}return null}function D(){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(m(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(m(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(m(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(m(u))return{cmd:u,args:["main.py"],cwd:t};let a=k();if(a)return{cmd:a,args:["main.py"],cwd:t}}return null}function P(e){return e?V(L(),".testmuai","kaneai","sessions",e,"runner-stderr.log"):null}function K(e){let n=M(e.runner.cmd,e.runner.args,{stdio:["pipe","pipe","pipe"],env:e.env,cwd:e.runner.cwd});n.stdin.on("error",()=>{});let r=P(e.sessionId);if(r)try{C(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{b(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",(f,_)=>{d=f,l=_?String(_):null,e.log?.("info","RUNNER_EXIT","Runner exited",{code:f,signal:l??"none"}),u({code:f,signal:l})})}),a=A(n.stdout);return{child:n,events:a,getStderr:()=>i,getExitCode:()=>d,getExitSignal:()=>l,exited:t}}async function B(e,n){if(!n?.platform||!n.target_kind)return;let r=await S(n.platform)?.toolEnv(n.target_kind)??{dirs:[]};if(r.dirs.length>0&&(e.PATH=[...r.dirs,e.PATH??""].filter(Boolean).join(T)),r.appiumHome&&(e.APPIUM_HOME=r.appiumHome),r.wdaRoot&&(e.TESTMU_IOS_WDA_DERIVED_DATA=r.wdaRoot),n.platform==="android"){let o=y();o&&(e.PATH=[o.platformToolsDir,e.PATH??""].filter(Boolean).join(T),e.ANDROID_HOME=o.root,e.ANDROID_SDK_ROOT=o.root)}}function H(e){let n={...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=p(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 x().load(),d=N(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 G(e,n){let r=p(n?.environment),o=R();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={url:r.shareApiBaseUrl.replace(/\/$/,"")+"/mfs/v1.0/media/upload",artefacts_host:r.mediaArtefactsHost,org_id:e.org_id,media_dir:g})}async function oe(e,n){let r=D();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
3
  `);let o=H({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 B(o,e.device),G(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
4
  `);let l=P(e.session_id);if(l)try{C(v(l),{recursive:!0}),b(l,`--- runner spawn ${new Date().toISOString()} run_index=${e.run_index} ---
5
5
  `)}catch{}return{child:d,events:i.events,sendUserResponse(t){let a=JSON.stringify({type:"user_response",answer:t});try{d.stdin.write(a+`
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as C}from"./chunk-75HF3GPO.js";import{h as Z}from"./chunk-7RFGO3TH.js";import{a as D}from"./chunk-YCCUBQY4.js";import{a as M}from"./chunk-5A4QG7ZM.js";import{a as z}from"./chunk-ASYWKYTQ.js";import{b as W}from"./chunk-7NXHVC7G.js";import{a as B}from"./chunk-3CCD434H.js";import{e as V}from"./chunk-Z7S3IWUX.js";import{x as o}from"./chunk-NJJQL54J.js";import{a as A}from"./chunk-HCBYKLMW.js";import{a as n,b as t,i as L}from"./chunk-C44QQJR4.js";import{a as N}from"./chunk-6YGTRKDT.js";import{e as g}from"./chunk-UR6MHSHU.js";var T=g(A(),1);function te(e){let i=e.kind==="simulator";switch(e.state){case"ready":return i?"Booted":"Running";case"stopped":return i?"Shutdown":"Stopped";case"unauthorized":return"UNAUTHORIZED";case"offline":return"Offline"}}function re(e){switch(e.state){case"unauthorized":return"accept the authorisation prompt on the device, then reopen this list";case"offline":return e.kind==="simulator"?"not responding \u2014 open Simulator.app to inspect it":"not responding \u2014 reconnect it, or restart the emulator";default:return}}function ne(e,i){let m=i.id!==void 0?{...i,id:z(i.id)}:i,c=e.virtualName!==void 0?{...e,virtualName:z(e.virtualName)}:e;return V(c,m)}function ie(e){return e.virtualName??e.displayName}function ae(e,i){let m=e.state==="ready"||e.state==="stopped",c=re(e),b=e.osVersion?` (${e.osVersion})`:"";return{id:e.id,label:`${ie(e)}${b} \xB7 ${te(e)}`,...i&&ne(e,i)?{isActive:!0}:{},...m?{}:{disabled:!0},...!m&&c?{disabledHint:c}:{}}}function le(e){return e==="emulator"?"No Android emulator found. Make sure an emulator exists on this machine (Android Studio \u2192 Device Manager), then reopen this list.":e==="simulator"?"No iOS simulator found. Make sure a simulator exists on this machine (Xcode \u2192 Windows \u2192 Devices and Simulators), then reopen this list.":"No emulator or simulator found. Make sure one exists on this machine, then reopen this list."}function he({targets:e,preselectedTarget:i,preselectedId:m,busyMessage:c,onSelect:b,onCancel:f,kind:l}){if(c)return(0,T.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,T.jsx)(t,{color:o.orange,bold:!0,children:"Device"}),(0,T.jsxs)(n,{marginTop:1,children:[(0,T.jsx)(C,{}),(0,T.jsxs)(t,{color:o.secondary,children:[" ",c]})]})]});if(e.length===0)return(0,T.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,T.jsx)(t,{color:o.orange,bold:!0,children:"Device"}),(0,T.jsx)(n,{marginTop:1,children:(0,T.jsx)(t,{color:o.dim,children:le(l)})})]});let d=e.map(r=>ae(r,i)),p=i?d.find(r=>r.isActive)?.id??null:m?e.find(r=>r.id===m||r.virtualName===m)?.id??null:null,a=new Map(e.map(r=>[r.id,r]));return(0,T.jsx)(M,{title:"Device",items:d,itemNoun:"devices",defaultActiveId:p,preserveSelectionById:!0,onSelect:r=>{let y=a.get(r.id);y&&b(y)},onCancel:f})}var x=g(N(),1);var u=g(A(),1),q=50,G=500;function pe(e){return`${e.name} (${e.appId})`}function Pe({kind:e,listApps:i,onSelect:m,onManualEntry:c,onCancel:b,busyMessage:f}){let[l,d]=(0,x.useState)([]),[p,a]=(0,x.useState)(!0),[r,y]=(0,x.useState)(!1),[Q,O]=(0,x.useState)(!1),[E,H]=(0,x.useState)(null),[w,J]=(0,x.useState)(""),[j,U]=(0,x.useState)(!1),$=(0,x.useRef)(!0),R=(0,x.useRef)(0);if((0,x.useEffect)(()=>{let h=++R.current,k=w.trim();$.current?a(!0):k&&O(!0),y(!0),H(null),U(!1),(async()=>{let I=[];try{for(let P=0;;P+=q){let X=await i({limit:q,offset:P,search:k});if(h!==R.current)return;if(I.push(...X.apps),d([...I]),$.current&&(a(!1),$.current=!1),O(!1),X.apps.length===0||I.length>=X.total)break;if(I.length>=G){U(!0);break}}}catch(P){if(h!==R.current)return;H(P instanceof Error?P.message:String(P)),a(!1),O(!1)}finally{h===R.current&&y(!1)}})()},[w,i]),L((h,k)=>{if(k.tab){c();return}k.escape&&b()},{isActive:!!E&&!f}),f)return(0,u.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,u.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,u.jsxs)(n,{marginTop:1,children:[(0,u.jsx)(C,{}),(0,u.jsxs)(t,{color:o.secondary,children:[" ",f]})]})]});if(E)return(0,u.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.red,paddingX:2,paddingY:1,children:[(0,u.jsx)(t,{color:o.red,bold:!0,children:"App under test"}),(0,u.jsx)(n,{marginTop:1,children:(0,u.jsx)(t,{color:o.red,children:"Could not load your uploads."})}),(0,u.jsx)(n,{marginTop:1,children:(0,u.jsx)(t,{color:o.dim,children:E})}),(0,u.jsx)(B,{bindings:[{keys:"tab",label:"tab to enter an app id"}],escBackLabel:"back to chat"})]});let ee=new Map(l.map(h=>[h.appId,h])),oe=l.map(h=>({id:h.appId,label:pe(h)})),_=!p&&!r&&l.length===0&&!w.trim()?e==="simulator"?"No simulator builds uploaded to this account yet \u2014 press Tab to enter an app id.":"No emulator builds uploaded to this account yet \u2014 press Tab to enter an app id.":null;return(0,u.jsx)(M,{title:"App under test",items:oe,loading:p,loadingText:"Loading your uploads\u2026",loadingMore:r,searching:Q,itemNoun:"uploads",preserveSelectionById:!0,onSearch:J,onTab:c,extraHint:"tab to enter an id",footer:_?(0,u.jsx)(t,{color:o.dim,children:_}):j?(0,u.jsx)(t,{color:o.dim,children:`Showing the first ${G} \u2014 type to search the rest.`}):void 0,onSelect:h=>{let k=ee.get(h.id);k&&m({appId:k.appId,name:k.name})},onCancel:b})}var Y=g(N(),1);var S=g(A(),1),se={emulator:["apk"],simulator:["zip"]};function ce(e){return Z(e.trim())}function Oe({kind:e,onBack:i,onSelect:m,onCancel:c}){let[b,f]=(0,Y.useState)(""),[l,d]=(0,Y.useState)(null),p=e==="emulator"?".apk":".zip";return(0,S.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,S.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,S.jsx)(n,{marginTop:1,children:(0,S.jsx)(t,{color:o.dim,children:`Path to a build (${p}): `})}),(0,S.jsxs)(n,{marginTop:1,children:[(0,S.jsx)(t,{color:o.dim,children:" "}),(0,S.jsx)(D,{value:b,onChange:a=>{f(a),l&&d(null)},onSubmit:a=>{let r=ce(a);if(!r){d(a.trim()?`Not a build \u2014 expected ${p}.`:"Enter the path to a build.");return}if(!se[e].includes(r.kind)){d(`${r.kind} builds don't run on a ${e} \u2014 expected ${p}.`);return}d(null),m(r).then(y=>{!y.ok&&y.error&&d(y.error)})},onCancel:i,placeholder:e==="emulator"?"/path/to/app-debug.apk":"/path/to/MyApp.zip"})]}),l&&(0,S.jsx)(n,{marginTop:1,children:(0,S.jsx)(t,{color:o.red,children:l})}),(0,S.jsx)(B,{bindings:[{keys:"\u21B5",label:"use this build"}],escBackLabel:"back"})]})}var F=g(N(),1);var v=g(A(),1);function de(e){return[{value:"local",label:"Local build",hint:e==="emulator"?".apk":".zip",available:!0},{value:"uploaded",label:"Uploaded app",hint:"an app id from your cloud uploads",available:!0}]}function Ye({kind:e,onSelect:i,onCancel:m}){let c=de(e),[b,f]=(0,F.useState)(0),[l,d]=(0,F.useState)(null);return L((p,a)=>{if(a.escape){m();return}if(a.upArrow&&f(r=>Math.max(0,r-1)),a.downArrow&&f(r=>Math.min(c.length-1,r+1)),a.return){let r=c[b];if(!r.available){d("That source isn't available \u2014 choose a local build for now.");return}d(null),i(r.value)}}),(0,v.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,v.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,v.jsx)(n,{marginTop:1,flexDirection:"column",children:c.map((p,a)=>{let r=a===b,y=p.available?r?o.orange:void 0:o.muted;return(0,v.jsxs)(n,{children:[(0,v.jsxs)(t,{color:y,children:[r?"\u276F ":" ",p.label]}),(0,v.jsxs)(t,{color:o.dim,children:[" ",p.hint]})]},p.value)})}),l&&(0,v.jsx)(n,{marginTop:1,children:(0,v.jsx)(t,{color:o.red,children:l})}),(0,v.jsx)(B,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}var K=g(N(),1);var s=g(A(),1);function qe({busyMessage:e,onSubmit:i,onBack:m}){let[c,b]=(0,K.useState)(""),[f,l]=(0,K.useState)(null);return e?(0,s.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,s.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,s.jsxs)(n,{marginTop:1,children:[(0,s.jsx)(C,{}),(0,s.jsxs)(t,{color:o.secondary,children:[" ",e]})]})]}):(0,s.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,s.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,s.jsx)(n,{marginTop:1,children:(0,s.jsx)(t,{color:o.dim,children:"App id from your cloud uploads:"})}),(0,s.jsxs)(n,{marginTop:1,children:[(0,s.jsx)(t,{color:o.dim,children:" "}),(0,s.jsx)(D,{value:c,onChange:d=>{b(d),f&&l(null)},onSubmit:d=>{let p=d.trim();if(!p){l("Enter an app id.");return}if(!W(p)){l("That doesn't look like an app id \u2014 they start with APP.");return}l(null),i(p).then(a=>{!a.ok&&a.error&&l(a.error)})},onCancel:m,placeholder:"APP1016032231178585590501450"})]}),f&&(0,s.jsxs)(n,{marginTop:1,flexDirection:"column",children:[(0,s.jsx)(t,{color:o.red,children:f}),(0,s.jsx)(t,{color:o.dim,children:"Enter a valid app id \u2014 copy it from your cloud uploads."})]}),(0,s.jsx)(B,{bindings:[{keys:"\u21B5",label:"use this app"}],escBackLabel:"back"})]})}export{he as a,Pe as b,Oe as c,Ye as d,qe as e};
2
+ import{a as C}from"./chunk-X74PP5NJ.js";import{k as Z}from"./chunk-6F6YI3ZG.js";import{a as D}from"./chunk-YCCUBQY4.js";import{a as M}from"./chunk-RBHQXWR7.js";import{a as z}from"./chunk-RQLU4NDG.js";import{b as W}from"./chunk-AC7BPO4X.js";import{a as B}from"./chunk-OO5GMBVI.js";import{e as V}from"./chunk-Z7S3IWUX.js";import{y as o}from"./chunk-B2ZGG7WM.js";import{a as A}from"./chunk-HCBYKLMW.js";import{a as n,b as t,i as L}from"./chunk-C44QQJR4.js";import{a as N}from"./chunk-6YGTRKDT.js";import{e as g}from"./chunk-UR6MHSHU.js";var T=g(A(),1);function te(e){let i=e.kind==="simulator";switch(e.state){case"ready":return i?"Booted":"Running";case"stopped":return i?"Shutdown":"Stopped";case"unauthorized":return"UNAUTHORIZED";case"offline":return"Offline"}}function re(e){switch(e.state){case"unauthorized":return"accept the authorisation prompt on the device, then reopen this list";case"offline":return e.kind==="simulator"?"not responding \u2014 open Simulator.app to inspect it":"not responding \u2014 reconnect it, or restart the emulator";default:return}}function ne(e,i){let m=i.id!==void 0?{...i,id:z(i.id)}:i,c=e.virtualName!==void 0?{...e,virtualName:z(e.virtualName)}:e;return V(c,m)}function ie(e){return e.virtualName??e.displayName}function ae(e,i){let m=e.state==="ready"||e.state==="stopped",c=re(e),b=e.osVersion?` (${e.osVersion})`:"";return{id:e.id,label:`${ie(e)}${b} \xB7 ${te(e)}`,...i&&ne(e,i)?{isActive:!0}:{},...m?{}:{disabled:!0},...!m&&c?{disabledHint:c}:{}}}function le(e){return e==="emulator"?"No Android emulator found. Make sure an emulator exists on this machine (Android Studio \u2192 Device Manager), then reopen this list.":e==="simulator"?"No iOS simulator found. Make sure a simulator exists on this machine (Xcode \u2192 Windows \u2192 Devices and Simulators), then reopen this list.":"No emulator or simulator found. Make sure one exists on this machine, then reopen this list."}function he({targets:e,preselectedTarget:i,preselectedId:m,busyMessage:c,onSelect:b,onCancel:f,kind:l}){if(c)return(0,T.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,T.jsx)(t,{color:o.orange,bold:!0,children:"Device"}),(0,T.jsxs)(n,{marginTop:1,children:[(0,T.jsx)(C,{}),(0,T.jsxs)(t,{color:o.secondary,children:[" ",c]})]})]});if(e.length===0)return(0,T.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,T.jsx)(t,{color:o.orange,bold:!0,children:"Device"}),(0,T.jsx)(n,{marginTop:1,children:(0,T.jsx)(t,{color:o.dim,children:le(l)})})]});let d=e.map(r=>ae(r,i)),p=i?d.find(r=>r.isActive)?.id??null:m?e.find(r=>r.id===m||r.virtualName===m)?.id??null:null,a=new Map(e.map(r=>[r.id,r]));return(0,T.jsx)(M,{title:"Device",items:d,itemNoun:"devices",defaultActiveId:p,preserveSelectionById:!0,onSelect:r=>{let y=a.get(r.id);y&&b(y)},onCancel:f})}var x=g(N(),1);var u=g(A(),1),q=50,G=500;function pe(e){return`${e.name} (${e.appId})`}function Pe({kind:e,listApps:i,onSelect:m,onManualEntry:c,onCancel:b,busyMessage:f}){let[l,d]=(0,x.useState)([]),[p,a]=(0,x.useState)(!0),[r,y]=(0,x.useState)(!1),[Q,O]=(0,x.useState)(!1),[E,H]=(0,x.useState)(null),[w,J]=(0,x.useState)(""),[j,U]=(0,x.useState)(!1),$=(0,x.useRef)(!0),R=(0,x.useRef)(0);if((0,x.useEffect)(()=>{let h=++R.current,k=w.trim();$.current?a(!0):k&&O(!0),y(!0),H(null),U(!1),(async()=>{let I=[];try{for(let P=0;;P+=q){let X=await i({limit:q,offset:P,search:k});if(h!==R.current)return;if(I.push(...X.apps),d([...I]),$.current&&(a(!1),$.current=!1),O(!1),X.apps.length===0||I.length>=X.total)break;if(I.length>=G){U(!0);break}}}catch(P){if(h!==R.current)return;H(P instanceof Error?P.message:String(P)),a(!1),O(!1)}finally{h===R.current&&y(!1)}})()},[w,i]),L((h,k)=>{if(k.tab){c();return}k.escape&&b()},{isActive:!!E&&!f}),f)return(0,u.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,u.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,u.jsxs)(n,{marginTop:1,children:[(0,u.jsx)(C,{}),(0,u.jsxs)(t,{color:o.secondary,children:[" ",f]})]})]});if(E)return(0,u.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.red,paddingX:2,paddingY:1,children:[(0,u.jsx)(t,{color:o.red,bold:!0,children:"App under test"}),(0,u.jsx)(n,{marginTop:1,children:(0,u.jsx)(t,{color:o.red,children:"Could not load your uploads."})}),(0,u.jsx)(n,{marginTop:1,children:(0,u.jsx)(t,{color:o.dim,children:E})}),(0,u.jsx)(B,{bindings:[{keys:"tab",label:"tab to enter an app id"}],escBackLabel:"back to chat"})]});let ee=new Map(l.map(h=>[h.appId,h])),oe=l.map(h=>({id:h.appId,label:pe(h)})),_=!p&&!r&&l.length===0&&!w.trim()?e==="simulator"?"No simulator builds uploaded to this account yet \u2014 press Tab to enter an app id.":"No emulator builds uploaded to this account yet \u2014 press Tab to enter an app id.":null;return(0,u.jsx)(M,{title:"App under test",items:oe,loading:p,loadingText:"Loading your uploads\u2026",loadingMore:r,searching:Q,itemNoun:"uploads",preserveSelectionById:!0,onSearch:J,onTab:c,extraHint:"tab to enter an id",footer:_?(0,u.jsx)(t,{color:o.dim,children:_}):j?(0,u.jsx)(t,{color:o.dim,children:`Showing the first ${G} \u2014 type to search the rest.`}):void 0,onSelect:h=>{let k=ee.get(h.id);k&&m({appId:k.appId,name:k.name})},onCancel:b})}var Y=g(N(),1);var S=g(A(),1),se={emulator:["apk"],simulator:["zip"]};function ce(e){return Z(e.trim())}function Oe({kind:e,onBack:i,onSelect:m,onCancel:c}){let[b,f]=(0,Y.useState)(""),[l,d]=(0,Y.useState)(null),p=e==="emulator"?".apk":".zip";return(0,S.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,S.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,S.jsx)(n,{marginTop:1,children:(0,S.jsx)(t,{color:o.dim,children:`Path to a build (${p}): `})}),(0,S.jsxs)(n,{marginTop:1,children:[(0,S.jsx)(t,{color:o.dim,children:" "}),(0,S.jsx)(D,{value:b,onChange:a=>{f(a),l&&d(null)},onSubmit:a=>{let r=ce(a);if(!r){d(a.trim()?`Not a build \u2014 expected ${p}.`:"Enter the path to a build.");return}if(!se[e].includes(r.kind)){d(`${r.kind} builds don't run on a ${e} \u2014 expected ${p}.`);return}d(null),m(r).then(y=>{!y.ok&&y.error&&d(y.error)})},onCancel:i,placeholder:e==="emulator"?"/path/to/app-debug.apk":"/path/to/MyApp.zip"})]}),l&&(0,S.jsx)(n,{marginTop:1,children:(0,S.jsx)(t,{color:o.red,children:l})}),(0,S.jsx)(B,{bindings:[{keys:"\u21B5",label:"use this build"}],escBackLabel:"back"})]})}var F=g(N(),1);var v=g(A(),1);function de(e){return[{value:"local",label:"Local build",hint:e==="emulator"?".apk":".zip",available:!0},{value:"uploaded",label:"Uploaded app",hint:"an app id from your cloud uploads",available:!0}]}function Ye({kind:e,onSelect:i,onCancel:m}){let c=de(e),[b,f]=(0,F.useState)(0),[l,d]=(0,F.useState)(null);return L((p,a)=>{if(a.escape){m();return}if(a.upArrow&&f(r=>Math.max(0,r-1)),a.downArrow&&f(r=>Math.min(c.length-1,r+1)),a.return){let r=c[b];if(!r.available){d("That source isn't available \u2014 choose a local build for now.");return}d(null),i(r.value)}}),(0,v.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,v.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,v.jsx)(n,{marginTop:1,flexDirection:"column",children:c.map((p,a)=>{let r=a===b,y=p.available?r?o.orange:void 0:o.muted;return(0,v.jsxs)(n,{children:[(0,v.jsxs)(t,{color:y,children:[r?"\u276F ":" ",p.label]}),(0,v.jsxs)(t,{color:o.dim,children:[" ",p.hint]})]},p.value)})}),l&&(0,v.jsx)(n,{marginTop:1,children:(0,v.jsx)(t,{color:o.red,children:l})}),(0,v.jsx)(B,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}var K=g(N(),1);var s=g(A(),1);function qe({busyMessage:e,onSubmit:i,onBack:m}){let[c,b]=(0,K.useState)(""),[f,l]=(0,K.useState)(null);return e?(0,s.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,s.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,s.jsxs)(n,{marginTop:1,children:[(0,s.jsx)(C,{}),(0,s.jsxs)(t,{color:o.secondary,children:[" ",e]})]})]}):(0,s.jsxs)(n,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,s.jsx)(t,{color:o.orange,bold:!0,children:"App under test"}),(0,s.jsx)(n,{marginTop:1,children:(0,s.jsx)(t,{color:o.dim,children:"App id from your cloud uploads:"})}),(0,s.jsxs)(n,{marginTop:1,children:[(0,s.jsx)(t,{color:o.dim,children:" "}),(0,s.jsx)(D,{value:c,onChange:d=>{b(d),f&&l(null)},onSubmit:d=>{let p=d.trim();if(!p){l("Enter an app id.");return}if(!W(p)){l("That doesn't look like an app id \u2014 they start with APP.");return}l(null),i(p).then(a=>{!a.ok&&a.error&&l(a.error)})},onCancel:m,placeholder:"APP1016032231178585590501450"})]}),f&&(0,s.jsxs)(n,{marginTop:1,flexDirection:"column",children:[(0,s.jsx)(t,{color:o.red,children:f}),(0,s.jsx)(t,{color:o.dim,children:"Enter a valid app id \u2014 copy it from your cloud uploads."})]}),(0,s.jsx)(B,{bindings:[{keys:"\u21B5",label:"use this app"}],escBackLabel:"back"})]})}export{he as a,Pe as b,Oe as c,Ye as d,qe as e};
@@ -0,0 +1,2 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{d as b}from"./chunk-BZAGVBCX.js";import{B as S}from"./chunk-GP7WD4UY.js";import{M as N,c as k,m as w}from"./chunk-3N6IAVD5.js";import{d as _,f as $}from"./chunk-AKX4VRRR.js";var j=3,F={edit:"edit",reject:"mistake",dedup_dropped:"mistake",approve:"usage",enhance:"directed-edit",add:"directed-edit",default_accepted:"usage",default_overridden:"edit",gap_resolution:"usage",dedup_kept:"usage"};function z(m){let{contextDir:u,graph:o,watermark:v,by:f}=m,{signals:E}=b(u,v),D=E.filter(e=>e.event_id===void 0||o.appliedEvents.has(e.event_id)),s=new Map;for(let e of D){let t=e.event_id??`${e.ts}|${e.id}|${e.verdict}|${e.polarity}`;s.has(`${t}|${e.polarity}|${e.verdict}`)||s.set(`${t}|${e.polarity}|${e.verdict}`,e)}let R=[...s.values()].sort((e,t)=>(e.event_id??e.ts)<(t.event_id??t.ts)?-1:1),i=new Map;for(let e of R){let t=`${e.verdict}|${e.tag??""}`,r=i.get(t)??{verdict:e.verdict,tag:e.tag,events:new Set};r.events.add(e.event_id??e.ts),i.set(t,r)}let d=[],a=[],g=new Set,c=[],y=0;for(let[,e]of[...i.entries()].sort(([t],[r])=>t<r?-1:1)){if(e.events.size<j)continue;let r={derived:!0,statement:`${e.verdict}${e.tag?`/${e.tag}`:""} recurs (${e.events.size} distinct events) \u2014 bias future proposals ${e.verdict==="approve"?"toward":"away from"} this pattern`,learned_from_kind:F[e.verdict]??"usage",learned_from:[...e.events].sort()},h=$("stylenote",r);if(h.length>0)return{record:null,errors:h.map(n=>({code:n.code,detail:n.detail})),minted:0};let p=k("stylenote",r);if(o.hasNode(p))continue;d.push({cid:p,label:_.STYLENOTE,content:r});for(let n of r.learned_from)c.includes(n)||c.push(n);let l=S("stylenote",n=>g.has(n),o.names.keys());l!==null&&(g.add(l),a.push({cid:p,slug:l,by:f})),y+=1}return d.length===0?{record:null,errors:null,minted:0}:{record:N(u,{ts:new Date().toISOString(),proposal_id:null,nodes:d,edges:[],review:[],supersessions:[],source_head_moves:{},...a.length>0?{names:a}:{}},{expectPrev:o.latestHash,intent:{v:1,verb:"distill",args:w({watermark:v,by:f}),pins:{events:c}},provenance:m.provenance}).record,errors:null,minted:y}}export{z as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as y}from"./chunk-NJJQL54J.js";import{existsSync as V,readdirSync as N,readFileSync as w}from"fs";import{join as g}from"path";var U="--variables",R=["smart","environment","secrets","totp"],O=/^[a-z][a-z0-9_]*$/;function D(e){return typeof e=="string"?e.trim().length>0:typeof e=="number"&&Number.isFinite(e)}function p(e,r,n){let t=JSON.parse(e);if(!(!t||typeof t!="object")){for(let[o,l]of Object.entries(t))if(l&&typeof l=="object"&&"value"in l){let c={has_value:D(l.value),source:r},i=/^(?:global|secrets\.user|environment)\.(.+)$/.exec(o);n.set(i?i[1]:o,c)}}}function h(e,r){if(!V(e))return;let n;try{n=N(e).filter(t=>t.endsWith(".json")).sort()}catch{return}for(let t of n){let o=g(e,t);try{p(w(o,"utf-8"),o,r)}catch{}}}function G(e){return{globalDir:g(y,"variables"),localDir:g(e,".testmuai","variables")}}function L(e){let r=new Map;if(h(e.globalDir,r),h(e.localDir,r),e.file&&V(e.file))try{p(w(e.file,"utf-8"),e.file,r)}catch{}if(e.inline)try{p(e.inline,U,r)}catch{}return r}function u(e){let r=e.trim();if(!r)return null;let n=r.split(/[.[]/).map(t=>t.trim()).filter(Boolean);return n.length===0||R.includes(n[0])?null:n[0]==="global"?n[1]??null:n[0]}function P(e){if(!e||!e.trim())return"variable name is empty";let r=e.split(".")[0];return r==="global"||R.includes(r)?`'${e}' starts with a runtime namespace (global/secrets/smart/environment/totp) \u2014 declare the bare name`:O.test(e)?null:`'${e}' is not lower_snake_case (letters, digits, underscores; starts with a letter)`}import{basename as T}from"path";var K="objective",F=/(\\?)\{\{\s*([^{}]+?)\s*\}\}/g;function m(e){let r=[];if(!e)return r;for(let n of e.matchAll(F)){if(n[1])continue;let t=u(n[2]??"");t&&!r.includes(t)&&r.push(t)}return r}var M=/\b(?:store|save|extract|remember|capture)\b/i,z=/\bas\s+(?:['"`]([A-Za-z_][A-Za-z0-9_]*)['"`]|([A-Za-z_][A-Za-z0-9_]*)(?=\s*(?:,|$)))/gi,C=new Set(["a","an","the"]);function S(e){let r=[];if(!e)return r;for(let n of e.split(/[.;\n]/))if(M.test(n))for(let t of n.matchAll(z)){let o=t[1]??t[2];!o||C.has(o.toLowerCase())||r.includes(o)||r.push(o)}return r}function E(e,r,n){let t=r.get(e);return t?t.has_value?null:{name:e,reason:"value_missing",file:t.source,used_by:[n]}:{name:e,reason:"not_declared",used_by:[n]}}function Q(e,r,n,t=[]){let o=new Set([...t,...S(e)]),l=[];for(let c of m(e)){if(o.has(c))continue;let i=E(c,r,n);i&&l.push(i)}return l}function X(e,r,n={}){let t=e.rootGlobal.variables??{},o=new Set(n.produced??[]),l=n.authorFrom??0,c=[];for(let i of e.steps){let I=i.flatIndex-1>=l,f=S(i.objective);if(!I){for(let s of f)o.add(s);continue}let k={file:T(i.sourceFile),step:i.flatIndex},j=i.config.variables??{},d=new Map;for(let[s,a]of Object.entries(t))d.set(u(s)??s,a.value);for(let[s,a]of Object.entries(j))d.set(u(s)??s,a.value);let b=new Set,v=(s,a)=>{if(o.has(s)||f.includes(s))return;let x=d.get(s);if(x===void 0){b.add(s);return}if(a.has(s)){b.add(s);return}a.add(s);for(let A of m(x))v(A,a);a.delete(s)};for(let s of m(i.objective))v(s,new Set);let _=[];for(let s of b){let a=E(s,r,k);a&&_.push(a)}c.push(_);for(let s of f)o.add(s)}return $(c)}function Y(e){let r=new Set,n=e&&typeof e=="object"?e:null;for(let t of n?.prior_runs??[])for(let o of Object.keys(t.variables??{}))r.add(o);return[...r]}function $(e){let r=new Map;for(let n of e)for(let t of n){let o=r.get(t.name);o?o.used_by.push(...t.used_by):r.set(t.name,{...t,used_by:[...t.used_by]})}return[...r.values()].sort((n,t)=>n.name<t.name?-1:1)}export{U as a,G as b,L as c,P as d,K as e,m as f,Q as g,X as h,Y as i,$ as j};
2
+ import{b as y}from"./chunk-B2ZGG7WM.js";import{existsSync as V,readdirSync as N,readFileSync as w}from"fs";import{join as g}from"path";var U="--variables",R=["smart","environment","secrets","totp"],O=/^[a-z][a-z0-9_]*$/;function D(e){return typeof e=="string"?e.trim().length>0:typeof e=="number"&&Number.isFinite(e)}function p(e,r,n){let t=JSON.parse(e);if(!(!t||typeof t!="object")){for(let[o,l]of Object.entries(t))if(l&&typeof l=="object"&&"value"in l){let c={has_value:D(l.value),source:r},i=/^(?:global|secrets\.user|environment)\.(.+)$/.exec(o);n.set(i?i[1]:o,c)}}}function h(e,r){if(!V(e))return;let n;try{n=N(e).filter(t=>t.endsWith(".json")).sort()}catch{return}for(let t of n){let o=g(e,t);try{p(w(o,"utf-8"),o,r)}catch{}}}function G(e){return{globalDir:g(y,"variables"),localDir:g(e,".testmuai","variables")}}function L(e){let r=new Map;if(h(e.globalDir,r),h(e.localDir,r),e.file&&V(e.file))try{p(w(e.file,"utf-8"),e.file,r)}catch{}if(e.inline)try{p(e.inline,U,r)}catch{}return r}function u(e){let r=e.trim();if(!r)return null;let n=r.split(/[.[]/).map(t=>t.trim()).filter(Boolean);return n.length===0||R.includes(n[0])?null:n[0]==="global"?n[1]??null:n[0]}function P(e){if(!e||!e.trim())return"variable name is empty";let r=e.split(".")[0];return r==="global"||R.includes(r)?`'${e}' starts with a runtime namespace (global/secrets/smart/environment/totp) \u2014 declare the bare name`:O.test(e)?null:`'${e}' is not lower_snake_case (letters, digits, underscores; starts with a letter)`}import{basename as T}from"path";var K="objective",F=/(\\?)\{\{\s*([^{}]+?)\s*\}\}/g;function m(e){let r=[];if(!e)return r;for(let n of e.matchAll(F)){if(n[1])continue;let t=u(n[2]??"");t&&!r.includes(t)&&r.push(t)}return r}var M=/\b(?:store|save|extract|remember|capture)\b/i,z=/\bas\s+(?:['"`]([A-Za-z_][A-Za-z0-9_]*)['"`]|([A-Za-z_][A-Za-z0-9_]*)(?=\s*(?:,|$)))/gi,C=new Set(["a","an","the"]);function S(e){let r=[];if(!e)return r;for(let n of e.split(/[.;\n]/))if(M.test(n))for(let t of n.matchAll(z)){let o=t[1]??t[2];!o||C.has(o.toLowerCase())||r.includes(o)||r.push(o)}return r}function E(e,r,n){let t=r.get(e);return t?t.has_value?null:{name:e,reason:"value_missing",file:t.source,used_by:[n]}:{name:e,reason:"not_declared",used_by:[n]}}function Q(e,r,n,t=[]){let o=new Set([...t,...S(e)]),l=[];for(let c of m(e)){if(o.has(c))continue;let i=E(c,r,n);i&&l.push(i)}return l}function X(e,r,n={}){let t=e.rootGlobal.variables??{},o=new Set(n.produced??[]),l=n.authorFrom??0,c=[];for(let i of e.steps){let I=i.flatIndex-1>=l,f=S(i.objective);if(!I){for(let s of f)o.add(s);continue}let k={file:T(i.sourceFile),step:i.flatIndex},j=i.config.variables??{},d=new Map;for(let[s,a]of Object.entries(t))d.set(u(s)??s,a.value);for(let[s,a]of Object.entries(j))d.set(u(s)??s,a.value);let b=new Set,v=(s,a)=>{if(o.has(s)||f.includes(s))return;let x=d.get(s);if(x===void 0){b.add(s);return}if(a.has(s)){b.add(s);return}a.add(s);for(let A of m(x))v(A,a);a.delete(s)};for(let s of m(i.objective))v(s,new Set);let _=[];for(let s of b){let a=E(s,r,k);a&&_.push(a)}c.push(_);for(let s of f)o.add(s)}return $(c)}function Y(e){let r=new Set,n=e&&typeof e=="object"?e:null;for(let t of n?.prior_runs??[])for(let o of Object.keys(t.variables??{}))r.add(o);return[...r]}function $(e){let r=new Map;for(let n of e)for(let t of n){let o=r.get(t.name);o?o.used_by.push(...t.used_by):r.set(t.name,{...t,used_by:[...t.used_by]})}return[...r.values()].sort((n,t)=>n.name<t.name?-1:1)}export{U as a,G as b,L as c,P as d,K as e,m as f,Q as g,X as h,Y as i,$ as j};
@@ -1,5 +1,5 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as Bt}from"./chunk-ZMNJBUAO.js";import{f as tr}from"./chunk-W5TTF7GB.js";import{a as Ft}from"./chunk-I7TIGB7K.js";import{a as te,c as Yt,e as Zt,f as qe,g as Qt,h as nr}from"./chunk-G2Q2TP3O.js";import{a as Xt,b as rr,c as sr,d as ir,e as dt,f as or}from"./chunk-5G22NOZK.js";import{a as ke,b as qt,c as Gt,d as Lt,e as Vt}from"./chunk-2LXJ2ZM3.js";import{a as Kt,b as Jt}from"./chunk-BZAGVBCX.js";import{a as er}from"./chunk-GX3FPJUG.js";import{a as zt}from"./chunk-L2TV4G56.js";import{c as Wt}from"./chunk-IVQX3AKL.js";import{e as Ut}from"./chunk-UDFDTFBL.js";import{a as Fe}from"./chunk-F2CET54H.js";import{g as Mt}from"./chunk-54JZ6VEW.js";import{a as $e,b as ct}from"./chunk-DNNZ353O.js";import{b as Nt}from"./chunk-YKTYVJBN.js";import{a as Ht,e as jt}from"./chunk-EV64VI66.js";import{a as Se}from"./chunk-NVGBE2DR.js";import{b as nt}from"./chunk-IDX3TOPY.js";import{C as ee,m as be,q as Be}from"./chunk-W3Z7AZNT.js";import{g as It}from"./chunk-XMTSHHYQ.js";import{e as at}from"./chunk-DBIBROYW.js";import{d as me}from"./chunk-AKX4VRRR.js";import{b as Ot}from"./chunk-IAHKTEET.js";import{a as At}from"./chunk-5EOX4MEY.js";import{appendFileSync as wr,mkdirSync as ut,rmdirSync as br,writeFileSync as lt}from"fs";import{dirname as mr,extname as Sr,join as ce}from"path";var X=class extends Error{code;constructor(e,a){super(`${e}: ${a}`),this.name="ProposalAdapterError",this.code=e}};function cr(r){return r.version===2}var ar=8;function vr(r){let e=/^extract@(\d+)$/.exec(r??"");return e?Number.parseInt(e[1],10):null}var yr=r=>typeof r=="object"&&r!==null&&"op"in r;function Ge(r,e,a){return{anchor:r.anchor,quote:r.quote,...a||r.source_id!==e?{source_id:r.source_id}:{}}}function dr(r,e,a={}){let m=vr(a.templateVersion),x=m!==null&&m>=5,_=m!==null&&m<5,y=r.archived!=null&&r.archived.length>0&&m!==null&&m<5;if(y&&a.warn?.(`dropped ${r.archived.length} archive op(s): the bound extract template @${m} never described archiving \u2014 nothing was archived; the use-cases still land`),!x&&r.read_basis.length!==1)throw new X("READ_BASIS_COUNT",`read_basis must have exactly 1 element, got ${r.read_basis.length}`);if(r.read_basis.length===0)throw new X("READ_BASIS_COUNT","read_basis must not be empty");let v=r.read_basis[0],h=r.read_basis.length>1,$=r.use_cases.map(i=>{if(_&&i.cite.length!==1)throw new X("CITE_COUNT",`${i.temp_ref}: cite must have exactly 1 element, got ${i.cite.length}`);if(i.cite.length<1||i.cite.length>ar)throw new X("CITE_COUNT",`${i.temp_ref}: 1..${ar} cites allowed, got ${i.cite.length}`);let M=(f,re)=>{if(!x&&f!==v.source_id)throw new X("SOURCE_MISMATCH",`${re}: cite source ${f} != read_basis source ${v.source_id} (single-source)`)};M(i.cite[0].source_id,i.temp_ref);let P=i.cite.map(f=>(M(f.source_id,i.temp_ref),Ge(f,v.source_id,x&&(h||f.source_id!==v.source_id)))),l=(i.updated?.criteria??[]).some(yr);if(!x&&l)throw new X("CRITERIA_OPS_UNSUPPORTED",`${i.temp_ref}: op-union updated.criteria (keep/set/remove) needs an extract@5+ binding \u2014 this session is bound to ${a.templateVersion??"an unversioned template"}`);return{temp_ref:i.temp_ref,title:i.title,...i.description!==void 0?{description:i.description}:{},...i.summary!==void 0?{summary:i.summary}:{},...i.actors!==void 0?{actors:i.actors}:{},...i.value!==void 0?{value:i.value}:{},risk:i.risk,cite:P[0],...P.length>1?{cites:P}:{},...i.criteria!=null&&i.criteria.length>0?{criteria:i.criteria.map((f,re)=>(M(f.cite.source_id,`${i.temp_ref}.criteria[${re}]`),{text:f.text,cite:Ge(f.cite,v.source_id,x&&f.cite.source_id!==v.source_id)}))}:{},depends_on_hint:i.depends_on_hint,matches_existing:i.matches_existing,...i.conflicts_with!=null?{conflicts_with:i.conflicts_with}:{},...i.changed?{changed:!0}:{},...i.updated!=null?{updated:{...i.updated.title!=null?{title:i.updated.title}:{},...i.updated.description!=null?{description:i.updated.description}:{},...i.updated.summary!=null?{summary:i.updated.summary}:{},...i.updated.actors!=null?{actors:i.updated.actors}:{},...i.updated.value!=null?{value:i.updated.value}:{},...i.updated.risk!=null?{risk:i.updated.risk}:{},...i.updated.criteria!=null?{criteria:l?i.updated.criteria.map(f=>f.op==="set"?{op:"set",text:f.text,cite:Ge(f.cite,v.source_id,x&&f.cite.source_id!==v.source_id)}:f.op==="keep"?{op:"keep",ref:f.ref,text:f.text}:{op:"remove",ref:f.ref,text:f.text,reason:f.reason}):i.updated.criteria.map((f,re)=>(M(f.cite.source_id,`${i.temp_ref}.updated.criteria[${re}]`),{text:f.text,cite:Ge(f.cite,v.source_id,x&&f.cite.source_id!==v.source_id)}))}:{}}}:{},...i.change_note!=null?{change_note:i.change_note}:{}}});return{version:1,read_basis:e,source:{source_id:v.source_id,source_cid:v.source_cid},use_cases:$,...h?{sources:r.read_basis.map(i=>({source_id:i.source_id,source_cid:i.source_cid}))}:{},...r.extraction_of!=null&&r.extraction_of.length>0?{extraction_claims:r.extraction_of.map(i=>({source_id:i.source_id,completeness:i.completeness}))}:{},...r.archived!=null&&r.archived.length>0&&!y?{archived:r.archived.map(i=>({target:i.target,reason:i.reason,basis:i.basis}))}:{}}}function ur(r){let{contextDir:e,graph:a}=r,m=r.maxDigestBytes??4096,x={},_=[];for(let[h,$]of a.heads){if(x[h]=$,typeof $!="string")continue;let i=a.mediaOf($),M=a.getNode($)?.content?.blob;if(typeof M=="string")if(i.format==="image")_.push({source_id:h,cid:$,format:"image",blobRef:{path:Se(e,M),cid:M}});else{let P=$e(e,a,$)?.toString("utf8")??"";_.push({source_id:h,cid:$,format:i.format,text:P})}}_.sort((h,$)=>h.source_id<$.source_id?-1:1);let y=[];for(let h of a.byLabel(me.STYLENOTE).sort(($,i)=>$.cid<i.cid?-1:1))a.superseded.has(h.cid)||y.push(`\u2022 ${String(h.content.statement)} [${String(h.content.learned_from_kind)}]`);let v="";for(let h of y){if(Buffer.byteLength(v+h+`
2
+ import{b as Bt}from"./chunk-ZMNJBUAO.js";import{f as tr}from"./chunk-W5TTF7GB.js";import{a as Ft}from"./chunk-I7TIGB7K.js";import{a as te,c as Yt,e as Zt,f as qe,g as Qt,h as nr}from"./chunk-MLRO7OH3.js";import{a as Xt,b as rr,c as sr,d as ir,e as dt,f as or}from"./chunk-UHT5SVP5.js";import{a as ke,b as qt,c as Gt,d as Lt,e as Vt}from"./chunk-FFFB5BXL.js";import{a as zt}from"./chunk-L2TV4G56.js";import{a as Kt,b as Jt}from"./chunk-BZAGVBCX.js";import{c as Wt}from"./chunk-52WM3XYO.js";import{b as Nt}from"./chunk-YKTYVJBN.js";import{a as Ht,e as jt}from"./chunk-CRZUBDJ3.js";import{a as er}from"./chunk-GX3FPJUG.js";import{i as Mt}from"./chunk-AHXOKBVE.js";import{a as $e,b as ct}from"./chunk-ALCE5RLK.js";import{e as Ut}from"./chunk-4K5XTIJ6.js";import{a as Fe}from"./chunk-J7NRD4Q7.js";import{a as Se}from"./chunk-IE3OO5GI.js";import{c as nt}from"./chunk-5LJRZI7S.js";import{C as ee,m as be,q as Be}from"./chunk-GP7WD4UY.js";import{H as It,b as Ot}from"./chunk-3N6IAVD5.js";import{f as at}from"./chunk-FQNQVC5O.js";import{d as me}from"./chunk-AKX4VRRR.js";import{a as At}from"./chunk-5EOX4MEY.js";import{appendFileSync as wr,mkdirSync as ut,rmdirSync as br,writeFileSync as lt}from"fs";import{dirname as mr,extname as Sr,join as ce}from"path";var X=class extends Error{code;constructor(e,a){super(`${e}: ${a}`),this.name="ProposalAdapterError",this.code=e}};function cr(r){return r.version===2}var ar=8;function vr(r){let e=/^extract@(\d+)$/.exec(r??"");return e?Number.parseInt(e[1],10):null}var yr=r=>typeof r=="object"&&r!==null&&"op"in r;function Ge(r,e,a){return{anchor:r.anchor,quote:r.quote,...a||r.source_id!==e?{source_id:r.source_id}:{}}}function dr(r,e,a={}){let m=vr(a.templateVersion),x=m!==null&&m>=5,_=m!==null&&m<5,y=r.archived!=null&&r.archived.length>0&&m!==null&&m<5;if(y&&a.warn?.(`dropped ${r.archived.length} archive op(s): the bound extract template @${m} never described archiving \u2014 nothing was archived; the use-cases still land`),!x&&r.read_basis.length!==1)throw new X("READ_BASIS_COUNT",`read_basis must have exactly 1 element, got ${r.read_basis.length}`);if(r.read_basis.length===0)throw new X("READ_BASIS_COUNT","read_basis must not be empty");let v=r.read_basis[0],h=r.read_basis.length>1,$=r.use_cases.map(i=>{if(_&&i.cite.length!==1)throw new X("CITE_COUNT",`${i.temp_ref}: cite must have exactly 1 element, got ${i.cite.length}`);if(i.cite.length<1||i.cite.length>ar)throw new X("CITE_COUNT",`${i.temp_ref}: 1..${ar} cites allowed, got ${i.cite.length}`);let M=(f,re)=>{if(!x&&f!==v.source_id)throw new X("SOURCE_MISMATCH",`${re}: cite source ${f} != read_basis source ${v.source_id} (single-source)`)};M(i.cite[0].source_id,i.temp_ref);let P=i.cite.map(f=>(M(f.source_id,i.temp_ref),Ge(f,v.source_id,x&&(h||f.source_id!==v.source_id)))),l=(i.updated?.criteria??[]).some(yr);if(!x&&l)throw new X("CRITERIA_OPS_UNSUPPORTED",`${i.temp_ref}: op-union updated.criteria (keep/set/remove) needs an extract@5+ binding \u2014 this session is bound to ${a.templateVersion??"an unversioned template"}`);return{temp_ref:i.temp_ref,title:i.title,...i.description!==void 0?{description:i.description}:{},...i.summary!==void 0?{summary:i.summary}:{},...i.actors!==void 0?{actors:i.actors}:{},...i.value!==void 0?{value:i.value}:{},risk:i.risk,cite:P[0],...P.length>1?{cites:P}:{},...i.criteria!=null&&i.criteria.length>0?{criteria:i.criteria.map((f,re)=>(M(f.cite.source_id,`${i.temp_ref}.criteria[${re}]`),{text:f.text,cite:Ge(f.cite,v.source_id,x&&f.cite.source_id!==v.source_id)}))}:{},depends_on_hint:i.depends_on_hint,matches_existing:i.matches_existing,...i.conflicts_with!=null?{conflicts_with:i.conflicts_with}:{},...i.changed?{changed:!0}:{},...i.updated!=null?{updated:{...i.updated.title!=null?{title:i.updated.title}:{},...i.updated.description!=null?{description:i.updated.description}:{},...i.updated.summary!=null?{summary:i.updated.summary}:{},...i.updated.actors!=null?{actors:i.updated.actors}:{},...i.updated.value!=null?{value:i.updated.value}:{},...i.updated.risk!=null?{risk:i.updated.risk}:{},...i.updated.criteria!=null?{criteria:l?i.updated.criteria.map(f=>f.op==="set"?{op:"set",text:f.text,cite:Ge(f.cite,v.source_id,x&&f.cite.source_id!==v.source_id)}:f.op==="keep"?{op:"keep",ref:f.ref,text:f.text}:{op:"remove",ref:f.ref,text:f.text,reason:f.reason}):i.updated.criteria.map((f,re)=>(M(f.cite.source_id,`${i.temp_ref}.updated.criteria[${re}]`),{text:f.text,cite:Ge(f.cite,v.source_id,x&&f.cite.source_id!==v.source_id)}))}:{}}}:{},...i.change_note!=null?{change_note:i.change_note}:{}}});return{version:1,read_basis:e,source:{source_id:v.source_id,source_cid:v.source_cid},use_cases:$,...h?{sources:r.read_basis.map(i=>({source_id:i.source_id,source_cid:i.source_cid}))}:{},...r.extraction_of!=null&&r.extraction_of.length>0?{extraction_claims:r.extraction_of.map(i=>({source_id:i.source_id,completeness:i.completeness}))}:{},...r.archived!=null&&r.archived.length>0&&!y?{archived:r.archived.map(i=>({target:i.target,reason:i.reason,basis:i.basis}))}:{}}}function ur(r){let{contextDir:e,graph:a}=r,m=r.maxDigestBytes??4096,x={},_=[];for(let[h,$]of a.heads){if(x[h]=$,typeof $!="string")continue;let i=a.mediaOf($),M=a.getNode($)?.content?.blob;if(typeof M=="string")if(i.format==="image")_.push({source_id:h,cid:$,format:"image",blobRef:{path:Se(e,M),cid:M}});else{let P=$e(e,a,$)?.toString("utf8")??"";_.push({source_id:h,cid:$,format:i.format,text:P})}}_.sort((h,$)=>h.source_id<$.source_id?-1:1);let y=[];for(let h of a.byLabel(me.STYLENOTE).sort(($,i)=>$.cid<i.cid?-1:1))a.superseded.has(h.cid)||y.push(`\u2022 ${String(h.content.statement)} [${String(h.content.learned_from_kind)}]`);let v="";for(let h of y){if(Buffer.byteLength(v+h+`
3
3
  `,"utf8")>m)break;v+=h+`
4
4
  `}return{read_basis:x,sources:_,styleNoteDigest:v}}function lr(r,e){let a=ur({contextDir:r,graph:e}).styleNoteDigest;return a.length>0?a:void 0}function mt(r,e,a,m,x){let _=null,y=()=>_??=x&&Object.keys(x).length>0?Promise.resolve(x):Ut().catch(()=>({}));return{contextDir:r,rootSid:e,locks:at(r,e),probe:m??Ft(r,{resolveAlias:async v=>qt(v,{env:process.env,auth:await y()}),embed:async(v,h)=>Gt(v,h,{env:process.env,auth:await y()}),readVector:(v,h)=>Lt(r,v,h),writeVector:(v,h,$)=>Vt(r,v,h,$)}),...a?.length?{reservedEventIds:a}:{}}}function ht(r,e){let a=[],m=[];for(let x of r.use_cases){let _=x.matches_existing;_?.cid&&e.hasNode(_.cid)?a.push({ref:_.cid,expectedTip:e.tipOf(_.cid)}):m.push({tempRef:x.temp_ref,title:String(x.title??""),probeText:String(x.title??"")})}return{verb:"extract",ucTargets:a,newBuCandidates:m,sourcePins:[{source_id:r.source.source_id,source_cid:r.source.source_cid}],readBasis:r.read_basis??null}}function $r(r,e){let a=(r.images??[]).filter(m=>m.delivery==="selected");if(a.length!==0)return a.map(m=>({ref:m.ref,...m.page!==void 0?{page:m.page}:{},...m.loc!==void 0?{loc:m.loc}:{},media_type:m.media_type,blob_ref:{path:Se(e,m.blob),cid:m.blob}}))}function kr(r){return r.length>8&&r[0]===137&&r[1]===80&&r[2]===78&&r[3]===71?"image/png":r.length>3&&r[0]===255&&r[1]===216&&r[2]===255?"image/jpeg":r.length>12&&r.toString("ascii",0,4)==="RIFF"&&r.toString("ascii",8,12)==="WEBP"?"image/webp":null}function Le(r){return r.toISOString().replace(/[-:]/g,"").slice(0,15)}function hr(r){return r.startsWith("su-conv-")?`conv-${Ot(Buffer.from(r,"utf8")).slice(0,8)}`:r}function pr(r){return r.source_id.startsWith("su-conv-")?"the conversation":r.source_id}function Rr(r,e,a){return`reading ${pr(r)}${a>1?` (source ${e} of ${a})`:""}`}function Re(r){return r.toLowerCase().trim().replace(/\s+/g," ")}function gr(r,e){let a=new Map,m=new Map,x=new Map;for(let{cid:y,content:v}of e.byLabel(me.USECASE)){if(e.superseded.has(y))continue;(e.trust.get(y)==="archived"?x:m).set(Re(String(v.title??"")),y)}let _=y=>e.trust.get(y)==="archived"?{cid:y,archived:!0,reason:e.archivedReason.get(y)}:{cid:y};for(let y of r.use_cases){if(y.matches_existing){let $=y.matches_existing.cid;if(e.superseded.has($)){let i=e.tipOf($);$=e.superseded.has(i)?null:i}if($!==null){a.set(y.temp_ref,_($));continue}}let v=m.get(Re(y.title));if(v){a.set(y.temp_ref,{cid:v});continue}let h=x.get(Re(y.title));h&&a.set(y.temp_ref,_(h))}return a}var fr=/^(\S+)\.criteria\[(\d+)\]/;function Cr(r,e,a){if(e.length===0||!e.every(x=>fr.test(x.detail)))return!1;let m=new Map;for(let x of e){let _=fr.exec(x.detail),y=m.get(_[1])??new Set;y.add(Number(_[2])),m.set(_[1],y)}for(let x of r.use_cases){let _=m.get(x.temp_ref);_?.size&&(x.criteria=(x.criteria??[]).filter((y,v)=>!_.has(v)),a(`${x.temp_ref}: dropped ${_.size} criteria with unverifiable cites \u2014 committed without them (criteria are hints, not oracles)`))}return!0}async function gt(r,e,a,m,x=()=>{},_,y){let v=(h,$)=>x(h,$,r.session_id);return Zt(r,e,a,m,x,{async onProposalEvent(h){let $=h,i=null,M=null;if(cr($))try{i=dr($,r.read_basis,{templateVersion:y?.()??null,warn:P=>{e.out(`warning: ${P}`),v("adapter",{warn:P})}}),v("adapter",{ok:!0,use_cases:i.use_cases.length})}catch(P){M=P instanceof X?P.message:String(P),v("adapter",{ok:!1,error:M})}else i=$;return i&&i.use_cases.length===0&&(e.out("warning: the agent proposed ZERO use-cases for this source"),e.emit?.({type:"warning",code:"ZERO_USE_CASES",message:"the agent proposed ZERO use-cases for this source"})),i&&_&&await _(i),{proposal:i,error:M}}})}var Dr=new Set(["agent","ci","override"]);async function Ss(r,e){let a=`ext-${Le(e.now?.()??new Date)}-lk${Math.random().toString(36).slice(2,8)}`,x=at(e.contextDir,a,e.now?{now:e.now}:void 0).tryAcquire([{kind:"extract"}],{hold:"session",verb:"extract"});if("contended"in x){let _=x.contended.holder,y=`another extraction is running on this context${_?` (pid ${_.pid})`:""} \u2014 retry when it finishes`;return e.out(y),e.emit?.({type:"error",message:y,code:"EXTRACT_LOCKED"}),2}try{return await Er(r,e)}finally{x.release()}}async function Er(r,e){let a=r.mode??"interactive";if(r.posture==="reconcile"){if(r.trust==="hold"){let o="error: --trust hold has no meaning here \u2014 a reconcile IS the review; drop the flag";return e.out(`${o} [TRUST_USAGE]`),e.emit?.({type:"error",message:o,code:"TRUST_USAGE"}),2}if(!r.source||!r.changeContext){let o="reconcile posture needs a pinned source and its change context \u2014 internal wiring fault";return e.out(`error: ${o}`),e.emit?.({type:"error",message:o,code:"POSTURE_USAGE"}),2}if(a==="ci"){let o="reconcile posture is not available under --mode ci \u2014 a held changeset needs a durable session; use --mode agent";return e.out(`error: ${o}`),e.emit?.({type:"error",message:o,code:"POSTURE_USAGE"}),2}}if(r.trust==="hold"&&a==="interactive")return e.out("error: --trust hold only applies to headless runs \u2014 in interactive chat you review items in-session anyway; use --mode agent to hold everything for review"),e.emit?.({type:"error",message:"error: --trust hold only applies to headless runs \u2014 use --mode agent",code:"TRUST_USAGE"}),2;if(a==="interactive"){if(!e.isTTY)return e.out("extract: --mode interactive needs a TTY (use --mode agent|ci|override headless)"),2}else if(!Dr.has(a))return e.out(`extract: unknown mode "${a}" \u2014 interactive | agent | ci | override`),2;if(r.trust!==void 0){if(a==="ci")return e.out("error: --trust is not available under --mode ci (ci is fail-closed \u2014 no trust dials)"),e.emit?.({type:"error",message:"error: --trust is not available under --mode ci",code:"TRUST_UNDER_CI"}),2;if(r.trust!=="auto"&&r.trust!=="hold")return e.out(`error: --trust must be auto | hold, got '${r.trust}'`),e.emit?.({type:"error",message:`error: --trust must be auto | hold, got '${r.trust}'`,code:"TRUST_USAGE"}),2}let m=e.telemetry?.enabled?e.telemetry:void 0,x=Le(e.now?.()??new Date),_=m?At(m.ids.context_instance_id??null,"extract",m.ids.session_id):ce(e.contextDir,"logs",`extract-${x}.log`);ut(mr(_),{recursive:!0});let y=`run-${x}-${Math.random().toString(36).slice(2,8)}`,v=o=>o==="error"||o==="failed_proposal"?"error":o==="repair_respawn"?"warn":"info",h=(o,u,s)=>{try{wr(_,JSON.stringify({ts:new Date().toISOString(),level:v(o),run_id:y,...m?{user_session_id:m.ids.session_id}:{},...s?{session_id:s}:{},kind:o,data:u})+`
5
5
  `)}catch{}m?.wireTrace(o,u,s)};{let o=e.out;e.out=u=>{h("transcript",{line:u}),o(u)}}e.chat||e.out(`trace: ${te(_)}`),e.emit?.({type:"run_start",mode:a,trace:_,...m?{session:m.ids.session_id}:{}});let $=Nt();if($&&e.out($),e.preflightTurn){let o=await e.preflightTurn();if(h("preflight",o),!o.ok)return e.out(o.message??"error: turn-endpoint preflight failed"),e.emit?.({type:"error",message:o.message??"error: turn-endpoint preflight failed",code:"PREFLIGHT"}),2}let i=ee(e.contextDir),M=lr(e.contextDir,i),P=r.sources?.length?r.sources:r.source?[r.source]:[];if(P.length>0){if(r.resume){let o="error: --source cannot be combined with --resume (the resumed session already has its scope)";return e.out(o),e.emit?.({type:"error",message:o,code:"SOURCE_WITH_RESUME"}),2}for(let o of P){let u=i.heads.get(o);if(typeof u!="string"){let s=u===null?`error: --source ${o} was ingested but is retired \u2014 re-ingest it to extract again`:`error: --source ${o} is not an ingested source (kane-cli context list shows them)`;return e.out(s),e.emit?.({type:"error",message:s,code:"SOURCE_UNKNOWN"}),2}}}let l=null,f=null;if(r.resume){try{{let c=await or(e.contextDir,r.resume,i,{verb:"extract",deps:{onWarn:C=>e.out(`note: ${C}`)}});{let C=Object.keys(c.handle.state.read_basis??{});if(C.length>1){let B=`error: session ${r.resume} spans ${C.length} sources \u2014 multi-source resume isn't supported yet; committed work is preserved (re-run kane-cli context extract for anything remaining)`;return e.out(B),e.emit?.({type:"error",message:B,code:"MULTI_SOURCE_RESUME"}),c.handle.release(),2}f=c,h("resume_kind",{kind:c.view.pointer===null?"bare-base":c.view.pointer.at==="final"?"pause":"crash"}),l={handle:c.handle,represent:c.represent,questions:c.questions,staleBasis:c.drift.map(B=>B.subject)}}}}catch(c){let C=c instanceof Error?c.message:String(c);return e.out(`error: ${C}`),e.emit?.({type:"error",message:`error: ${C}`,...c instanceof dt?{code:c.code}:{}}),c instanceof dt?2:1}let o=f?null:Xt(l.handle.state.verb,"extract",r.resume);if(o)return e.out(o.message),e.emit?.({type:"error",message:o.message,code:o.code}),l.handle.release(),2;let u=l.handle.state.change_basis;if(u&&(i.heads.get(u.source_id)??null)!==u.new_head){let c=`error: ${u.source_id} moved while this reconcile extraction was paused \u2014 its recorded change context no longer matches; re-run kane-cli maintain reconcile against the current file (session ${r.resume} is defunct and can be ignored)`;return e.out(c),e.emit?.({type:"error",message:c,code:"CHANGE_BASIS_MOVED"}),l.handle.release(),2}if(f&&f.view.pointer!==null&&f.drift.length>0){if(!await e.confirmStale(`changed since the pause: ${f.drift.map(C=>C.subject).join(", ")} \u2014 re-ground and continue against the current versions?`)){let C=`resume aborted: the context moved since the pause (${f.drift.map(B=>B.subject).join(", ")}) \u2014 session ${r.resume} is preserved`;return e.out(C),e.emit?.({type:"error",message:C,code:"RESUME_DRIFT"}),l.handle.release(),2}}else l.staleBasis.length>0&&e.out(`note: changed since the pause: ${l.staleBasis.join(", ")} \u2014 re-presented items may be stale`);let s=[...new Set([...l.handle.state.held_receipts??[],...f?.view.kane?.held_receipts??[]])];if(s.length>0)if(e.chat?.holdReceipt)for(let c of s)e.chat.holdReceipt(c);else e={...e,initialMessage:[s.join(`
@@ -0,0 +1,8 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{b as h}from"./chunk-VZ7KXRXB.js";import{c as _}from"./chunk-EYOCNMUM.js";import{dirname as F,isAbsolute as T,resolve as j}from"path";var k=["db","api","js","smartui","network_query","network_assertion"];var a=class extends Error{constructor(r,o,e){super(`[${o}${e!=null?`:${e}`:""}] ${r}`);this.file=o;this.line=e;this.name="TestMdParseError"}};var R=["if","elif","else","end-if","while","end-while"];var C={"end-if":"if","end-while":"while"};function v(n,t){let r=[],o=()=>r[r.length-1];for(let i of t){let s=i.controlFlow;if(s==="if"||s==="while"){r.push({kind:s,id:i.index,branch:0,elseSeen:!1}),i.block={id:i.index,branch:0,depth:r.length};continue}if(s==="elif"||s==="else"){let l=o();if(!l||l.kind!=="if")throw new a(`@${s} outside an open @if`,n,i.headingLine);if(l.elseSeen)throw new a(`@${s} after @else`,n,i.headingLine);l.branch+=1,l.elseSeen=s==="else",i.block={id:l.id,branch:l.branch,depth:r.length};continue}if(s==="end-if"||s==="end-while"){let l=o(),f=C[s];if(!l||l.kind!==f)throw new a(`@${s} without an open @${f}`,n,i.headingLine);i.block={id:l.id,branch:-1,depth:r.length},r.pop();continue}let c=o();c&&(i.block={id:c.id,branch:c.branch,depth:r.length})}let e=o();if(e){let i=t.find(s=>s.index===e.id);throw new a(`unclosed @${e.kind} block`,n,i?.headingLine)}}var P=new Set(["username","access_key","oauth","profile","project_id","folder_id"]),$=new Set(["mode","max_steps","timeout","global_context","local_context","variables","session_context","code_export","code_language","url","target","chrome_profile","cdp_endpoint","ws_endpoint","headless","app","no_reset","os_version","device_name","on_lock_conflict","tags","assurance"]),O=new Set(["optional"]),Y=new Set(["optional","variables"]),M=new Set(["target","chrome_profile","cdp_endpoint","ws_endpoint","headless"]),N=new Set(["app","no_reset","os_version","device_name"]),B=new Set(["mode","on_lock_conflict","tags","assurance"]);function we(n,t){let r=t.split(`
3
+ `),{global:o,bodyStartLine:e}=I(n,r),{title:i,steps:s}=oe(n,r,e);return{path:n,title:i,global:o,steps:s}}function I(n,t){if(t[0]?.trim()!=="---")return{global:{},bodyStartLine:0};let r=-1;for(let c=1;c<t.length;c++)if(t[c].trim()==="---"){r=c;break}if(r===-1)throw new a("frontmatter is missing closing '---'",n,1);let o=t.slice(1,r).join(`
4
+ `),e;try{e=h(o)??{}}catch(c){throw new a(`invalid YAML in frontmatter: ${c.message}`,n,1)}if(E(n,e,"frontmatter",1),e.on_lock_conflict!==void 0){let c=e.on_lock_conflict;if(c!=="readonly"&&c!=="fail"&&c!=="wait")throw new a(`on_lock_conflict must be 'readonly' | 'fail' | 'wait', got: ${JSON.stringify(c)}`,n,1)}if(L(n,e,1),e.assurance!==void 0){let c=e.assurance;if(c===null||typeof c!="object"||Array.isArray(c))throw new a("assurance must be a mapping with sub-keys {id, base}",n,1);let l=c;for(let f of Object.keys(l))if(f!=="id"&&f!=="base")throw new a(`unknown assurance sub-key '${f}' \u2014 the engine block allows only {id, base}`,n,1);if(typeof l.id!="string"||l.id.length===0)throw new a("assurance.id must be a non-empty string (logical id)",n,1);if(l.base!==void 0&&!(typeof l.base=="string"&&/^sha256:[0-9a-f]+$/.test(l.base)))throw new a("assurance.base must be a 'sha256:<hex>' string",n,1)}if(e.tags!==void 0){let c=e.tags,l=Array.isArray(c)?c.map(f=>String(f)).join(","):String(c);e.tags=G(l,n,1)}if(e.target!==void 0&&(e.target=q(e.target,n,1)),e.app!==void 0&&(e.app=H(e.app,n,1)),e.no_reset!==void 0&&typeof e.no_reset!="boolean")throw new a(`no_reset must be boolean: got ${typeof e.no_reset}`,n,1);if(e.os_version!==void 0&&typeof e.os_version!="string")if(typeof e.os_version=="number")e.os_version=String(e.os_version);else throw new a(`os_version must be a string: got ${typeof e.os_version}`,n,1);let i=e.target,s=i==="emulator"||i==="simulator";if(s&&e.app===void 0)throw new a(`target: ${String(i)} needs an app \u2014 add \`app: <path-to-build | AppId>\``,n,1);if(!s&&e.app!==void 0)throw new a("app requires a mobile target \u2014 add `target: emulator` or `target: simulator`",n,1);if(!s&&e.no_reset!==void 0)throw new a("no_reset requires a mobile target \u2014 add `target: emulator` or `target: simulator`",n,1);if(!s&&e.os_version!==void 0)throw new a("os_version requires a mobile target \u2014 add `target: emulator` or `target: simulator`",n,1);if(e.device_name!==void 0&&typeof e.device_name!="string")throw new a(`device_name must be a string: got ${typeof e.device_name}`,n,1);if(!s&&e.device_name!==void 0)throw new a("device_name requires a mobile target \u2014 add `target: emulator` or `target: simulator`",n,1);return{global:e,bodyStartLine:r+1}}function G(n,t,r){let e=n.trim().replace(/^\[/,"").replace(/\]$/,"").split(",").map(i=>i.trim().toLowerCase());if(e.length===0||e.some(i=>i.length===0))throw new a("tags must be a non-empty list of non-empty strings",t,r);return[...new Set(e)]}var V=new Set(["chrome","cdp","ws","emulator","simulator"]),W="target must be one of 'chrome' | 'cdp' | 'ws' (web) or 'emulator' | 'simulator' (mobile, with a root `app:` key)";function q(n,t,r){if(typeof n=="string"&&V.has(n))return n;throw n!==null&&typeof n=="object"&&!Array.isArray(n)?new a(`the mapping form of target is no longer accepted \u2014 write flat keys:
5
+ target: emulator | simulator
6
+ app: <path-to-build | AppId>`,t,r):new a(`${W} \u2014 got: ${JSON.stringify(n)}`,t,r)}function H(n,t,r){if(typeof n!="string"||n.trim().length===0)throw new a("app must be a build (e.g. ./builds/app-debug.apk) or an app id from your cloud uploads",t,r);let o=n.trim();if(!/\.(apk|zip)$/i.test(o)&&!/^APP\d{6,}$/.test(o))throw new a(`app '${o}' is not a build \u2014 expected a path ending in .apk or .zip, or an app id from your cloud uploads.`,t,r);return z(o,t)}function z(n,t){return/^APP[0-9A-Za-z_-]+$/.test(n)||T(n)?n:j(F(t),n)}function be(n){let t=n.target;if(!(t!=="emulator"&&t!=="simulator"))return{platform:_(t)??"",app:n.app??"",...n.no_reset!==void 0?{no_reset:n.no_reset}:{},...n.os_version!==void 0?{os_version:n.os_version}:{},...n.device_name!==void 0?{device_name:n.device_name}:{}}}function ye(n){let t=n.target;return t==="chrome"||t==="cdp"||t==="ws"?t:void 0}var D=/\s@verifies\s+(ac-[\w.:\/-]+(?:\s*,\s*ac-[\w.:\/-]+)*)\s*$/;function J(n,t,r){let o=D.exec(t);if(o)return{label:t.slice(0,o.index).trim(),verifies:o[1].split(",").map(i=>i.trim())};let e=t.lastIndexOf("@verifies");if(e>0&&/\s/.test(t[e-1])){let i=t.slice(e+9).split(/[\s,]+/).filter(s=>s.length>0);if(i.length===0||i.every(s=>s.startsWith("ac-")))throw new a("malformed @verifies directive \u2014 expected '@verifies ac-<id>[, ac-<id>\u2026]' at the end of the heading",n,r)}return{label:t,verifies:[]}}var S=k.join("|"),U=new RegExp(`^(.*\\S)\\s+@(${S})\\s*$`),Z=new RegExp(`^@(${S})\\s*$`);function Q(n,t,r,o){let e=Z.exec(t);if(e)throw new a(`replay-only marker @${e[1]} needs a step label before it (e.g. '## Step 3 @${e[1]}')`,n,r);let i=U.exec(t);if(!i)return null;let s=i[2];if(o)throw new a(`only one replay-only marker per step \u2014 found @${o} and @${s}`,n,r);return{label:i[1].trim(),replayOnly:s}}var x=R.join("|"),X=new RegExp(`^(.*\\S)\\s+@(${x})\\s*$`),ee=new RegExp(`^@(${x})\\s*$`);function ne(n,t,r,o){let e=ee.exec(t);if(e)throw new a(`control-flow marker @${e[1]} needs a step label before it (e.g. '## banner is visible @${e[1]}')`,n,r);let i=X.exec(t);if(!i)return null;let s=i[2];if(o)throw new a(`only one control-flow marker per step \u2014 found @${o} and @${s}`,n,r);return{label:i[1].trim(),controlFlow:s}}function te(n,t,r){let o=t,e,i,s=()=>{let l=Q(n,o,r,e);l&&({label:o,replayOnly:e}=l);let f=ne(n,o,r,i);f&&({label:o,controlFlow:i}=f)};s();let c=J(n,o,r);if(o=c.label,s(),e&&i)throw new a(`@${i} is a control-flow marker and @${e} a replay-only marker \u2014 a step carries one or the other`,n,r);return{label:o,verifies:c.verifies,...e?{replayOnly:e}:{},...i?{controlFlow:i}:{}}}function oe(n,t,r){let o,e=r;for(;e<t.length&&t[e].trim()==="";)e++;let i=e<t.length?/^#\s+(.+?)\s*$/.exec(t[e]):null;i&&(o=i[1],e++);let s=[];for(let l=e;l<t.length;l++)/^##\s/.test(t[l])&&s.push(l);let c=[];for(let l=0;l<s.length;l++){let f=s[l],g=s[l+1]??t.length,m=t[f].replace(/^##\s+/,"").trim(),{label:w,verifies:d,replayOnly:p,controlFlow:u}=te(n,m,f+1),b=t.slice(f+1,g),{config:A,body:y,optional:K}=re(n,f+1,b);if(p&&y.kind==="import_ref")throw new a(`@${p} is a replay-only marker for objective steps \u2014 it cannot mark an @import row`,n,f+1);if(u&&y.kind==="import_ref")throw new a(`@${u} is a control-flow marker for objective steps \u2014 it cannot mark an @import row`,n,f+1);c.push({index:l+1,heading:w,verifies:d,config:A,body:y,headingLine:f+1,optional:K,...p?{replayOnly:p}:{},...u?{controlFlow:u}:{}})}return v(n,c),{title:o,steps:c}}function re(n,t,r){let o=0;for(;o<r.length&&r[o].trim()==="";)o++;let e,i=t;if(o<r.length&&/^```yaml\s*$/.test(r[o])){let d=o;i=t+d,o++;let p=-1;for(;o<r.length;){if(/^```\s*$/.test(r[o])){p=o;break}o++}if(p===-1)throw new a("step-config fenced ```yaml block is not closed",n,i);let u=r.slice(d+1,p).join(`
7
+ `);try{e=h(u)??{}}catch(b){throw new a(`invalid YAML in step config: ${b.message}`,n,i)}o=p+1}let s=ie(r.slice(o)),c=s.filter(d=>d.trim()!=="");if(c.length>0&&/^@session\s+/.test(c[0].trim()))throw new a("@session is no longer supported (iteration 3); use @import instead",n,t);let l=/^@import\s+(\S.*)$/,g=s.filter(d=>l.test(d.trim())).length>0;if(g&&c.length!==1)throw new a("step body must be exactly one of prose / @import",n,t);let m=!1,w;if(e){if(E(n,e,g?"step config (ref)":"step config (objective)",i),L(n,e,i),typeof e.optional=="boolean")m=e.optional;else if(e.optional!==void 0)throw new a(`step config 'optional' must be boolean: got ${typeof e.optional}`,n,i);let d={...e};delete d.optional,g&&delete d.variables,!g&&Object.keys(d).length>0&&(w=d)}if(g){let p=l.exec(c[0].trim())[1].trim(),u=e?.variables;return{body:{kind:"import_ref",path:p,...u&&Object.keys(u).length>0?{bindings:u}:{}},optional:m}}return{body:{kind:"objective",text:s.join(`
8
+ `).trim()},config:w,optional:m}}function ie(n){let t=0,r=n.length;for(;t<r&&n[t].trim()==="";)t++;for(;r>t&&n[r-1].trim()==="";)r--;return n.slice(t,r)}function L(n,t,r){let o=t.variables;if(o==null)return;if(typeof o!="object"||Array.isArray(o))throw new a("variables must be an object map",n,r);let e={};for(let[i,s]of Object.entries(o))if(typeof s=="string")e[i]={value:s};else if(s&&typeof s=="object"&&!Array.isArray(s)&&typeof s.value=="string")e[i]=s;else throw new a(`variable '${i}' must be a string or { value: ... } object`,n,r);t.variables=e}function E(n,t,r,o){for(let e of Object.keys(t)){if(P.has(e))throw new a(`auth/identity keys are CLI-only: ${e}`,n,o);if(r==="frontmatter"){if(O.has(e))throw new a(`step-only key in frontmatter: ${e}`,n,o);if(!$.has(e))throw new a(`unknown config key: ${e}`,n,o)}else if(r==="step config (objective)"){if(!$.has(e)&&!O.has(e))throw new a(`unknown config key: ${e}`,n,o);if(M.has(e))throw new a(`chrome config is global-only: ${e}`,n,o);if(N.has(e))throw new a(`'${e}' is global-only: the whole run drives one app`,n,o);if(B.has(e))throw new a(`'${e}' is run-level and cannot be set per-step`,n,o)}else if(!Y.has(e))throw new a(`step config on @import may only contain 'optional' / 'variables': got ${e}`,n,o)}}export{we as a,be as b,ye as c,D as d};
@@ -1,2 +1,2 @@
1
1
  import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{a as b}from"./chunk-3CCD434H.js";import{m as d,x as o}from"./chunk-NJJQL54J.js";import{a as L}from"./chunk-HCBYKLMW.js";import{a as u,b as c,i as A}from"./chunk-C44QQJR4.js";import{a as D}from"./chunk-6YGTRKDT.js";import{e as h}from"./chunk-UR6MHSHU.js";var x=h(D(),1);import{readdirSync as N,mkdirSync as B,statSync as k}from"fs";import{join as P}from"path";var r=h(L(),1);function O(n){try{return N(n).filter(l=>{try{return k(P(n,l)).isDirectory()}catch{return!1}})}catch{return[]}}function E(n,l,f,v){return{name:n,path:l,label:n,isActive:v}}function H({currentPath:n,onSelect:l,onCancel:f}){let s=O(d).map(i=>{let e=P(d,i);return E(i,e,n,e===n)}),p=!n,R=s.length+2,[a,C]=(0,x.useState)(()=>{if(p)return 0;let i=s.findIndex(e=>e.isActive);return i>=0?i+1:0}),[T,I]=(0,x.useState)(!1),[S,g]=(0,x.useState)("");return A((i,e)=>{if(T){if(e.escape){I(!1),g("");return}if(e.return){let t=S.trim();if(t){let m=P(d,t);B(m,{recursive:!0}),l(m),f()}return}if(e.backspace||e.delete){g(t=>t.slice(0,-1));return}i&&!e.ctrl&&!e.meta&&g(t=>t+i);return}if(e.escape){f();return}if(e.upArrow){C(t=>Math.max(0,t-1));return}if(e.downArrow){C(t=>Math.min(R-1,t+1));return}if(e.return){if(a===0){p||l(""),f();return}if(a===s.length+1){B(d,{recursive:!0}),I(!0),g("");return}let t=s[a-1];t&&!t.isActive&&l(t.path),f();return}}),T?(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile \u203A New"}),(0,r.jsxs)(u,{marginTop:1,children:[(0,r.jsx)(c,{color:o.secondary,children:"Name: "}),(0,r.jsx)(c,{children:S}),(0,r.jsx)(c,{color:o.dim,children:"\u2588"})]}),(0,r.jsx)(b,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:"back"})]}):(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile"}),(0,r.jsxs)(u,{flexDirection:"column",marginTop:1,children:[(0,r.jsxs)(c,{color:p?o.green:a===0?o.orange:o.dim,children:[a===0?"\u276F ":" ","Use temporary (no profile)",p?" \u25CF active":""]}),s.map((i,e)=>{let m=e+1===a,w=m?"\u276F ":" ",y=i.isActive?o.green:m?o.orange:void 0;return(0,r.jsxs)(c,{color:y,children:[w,i.label,i.isActive?" \u25CF active":""]},i.name)}),(0,r.jsxs)(c,{color:a===s.length+1?o.orange:o.dim,children:[a===s.length+1?"\u276F ":" ","+ Create new"]})]}),(0,r.jsx)(b,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}export{O as a,E as b,H as c};
2
+ import{a as b}from"./chunk-OO5GMBVI.js";import{m as d,y as o}from"./chunk-B2ZGG7WM.js";import{a as L}from"./chunk-HCBYKLMW.js";import{a as u,b as c,i as A}from"./chunk-C44QQJR4.js";import{a as D}from"./chunk-6YGTRKDT.js";import{e as h}from"./chunk-UR6MHSHU.js";var x=h(D(),1);import{readdirSync as N,mkdirSync as B,statSync as k}from"fs";import{join as P}from"path";var r=h(L(),1);function O(n){try{return N(n).filter(l=>{try{return k(P(n,l)).isDirectory()}catch{return!1}})}catch{return[]}}function E(n,l,f,v){return{name:n,path:l,label:n,isActive:v}}function H({currentPath:n,onSelect:l,onCancel:f}){let s=O(d).map(i=>{let e=P(d,i);return E(i,e,n,e===n)}),p=!n,R=s.length+2,[a,C]=(0,x.useState)(()=>{if(p)return 0;let i=s.findIndex(e=>e.isActive);return i>=0?i+1:0}),[T,I]=(0,x.useState)(!1),[S,g]=(0,x.useState)("");return A((i,e)=>{if(T){if(e.escape){I(!1),g("");return}if(e.return){let t=S.trim();if(t){let m=P(d,t);B(m,{recursive:!0}),l(m),f()}return}if(e.backspace||e.delete){g(t=>t.slice(0,-1));return}i&&!e.ctrl&&!e.meta&&g(t=>t+i);return}if(e.escape){f();return}if(e.upArrow){C(t=>Math.max(0,t-1));return}if(e.downArrow){C(t=>Math.min(R-1,t+1));return}if(e.return){if(a===0){p||l(""),f();return}if(a===s.length+1){B(d,{recursive:!0}),I(!0),g("");return}let t=s[a-1];t&&!t.isActive&&l(t.path),f();return}}),T?(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile \u203A New"}),(0,r.jsxs)(u,{marginTop:1,children:[(0,r.jsx)(c,{color:o.secondary,children:"Name: "}),(0,r.jsx)(c,{children:S}),(0,r.jsx)(c,{color:o.dim,children:"\u2588"})]}),(0,r.jsx)(b,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:"back"})]}):(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile"}),(0,r.jsxs)(u,{flexDirection:"column",marginTop:1,children:[(0,r.jsxs)(c,{color:p?o.green:a===0?o.orange:o.dim,children:[a===0?"\u276F ":" ","Use temporary (no profile)",p?" \u25CF active":""]}),s.map((i,e)=>{let m=e+1===a,w=m?"\u276F ":" ",y=i.isActive?o.green:m?o.orange:void 0;return(0,r.jsxs)(c,{color:y,children:[w,i.label,i.isActive?" \u25CF active":""]},i.name)}),(0,r.jsxs)(c,{color:a===s.length+1?o.orange:o.dim,children:[a===s.length+1?"\u276F ":" ","+ Create new"]})]}),(0,r.jsx)(b,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}export{O as a,E as b,H as c};
@@ -0,0 +1,6 @@
1
+ import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
+ import{e as U}from"./chunk-EHN5HTUD.js";import{b as J,c as P,e as q,i as z,j as Q,k as X,l as Y,m as A}from"./chunk-KN65CUNT.js";import{a as G}from"./chunk-LBNADEQN.js";import{copyFileSync as le,cpSync as ue,existsSync as $,mkdirSync as pe,readFileSync as Oe,readdirSync as ce,rmSync as Te,writeFileSync as Ae}from"fs";import{dirname as _e,isAbsolute as Ee,join as y,relative as Le,resolve as Ke}from"path";import{writeFileSync as ge,mkdirSync as Se,readFileSync as ye}from"fs";import{dirname as Re,basename as Z}from"path";function te(e){let t=e.outPath??P(e.sourcePath);Se(Re(t),{recursive:!0});let s=[];s.push("---"),s.push(`test: ../${Z(e.sourcePath)}`),s.push(`status: ${e.overallStatus}`),s.push(`started: ${e.startedISO}`),s.push(`duration_s: ${e.durationS}`),s.push(`session_id: ${e.sessionId}`),s.push("---",""),s.push(`# ${e.title??Z(e.sourcePath)} \u2014 Result`,"");for(let l=0;l<e.rootSteps.length;l++){let d=e.rootSteps[l],r=e.outcomes.find(p=>p.rootStepIndex===l+1);if(s.push(xe(d,r)),r?.stepMd5&&s.push(`md5: ${r.stepMd5}`),r?.status==="failed"&&r.reason&&s.push(`Reason: ${r.reason}`),r?.softFailures?.length)for(let p of r.softFailures){let o=p.reason?`: ${p.reason}`:"";s.push(`\u26A0 optional sub-step ${p.subStepIndex} failed${o}`)}d.body.kind==="objective"&&r?.status!=="skipped"&&s.push(d.body.text),s.push("")}return ge(t,s.join(`
3
+ `),"utf8"),t}function xe(e,t){if(!t)return`## ${e.heading} (no outcome)`;let s=t.duration_s!=null?`${t.duration_s}s`:"\u2014";if(t.status==="skipped")return`## ${e.heading} \u23ED skipped`;let l=t.softFailed?" (optional)":"";if(t.refKind&&t.status==="passed"){let d=t.helperResultRelPath?` \u2192 ${t.helperResultRelPath}`:"";return`## ${e.heading} \u2713 passed (via @${t.refKind} ${t.refLabel} \u2014 ${t.inlinedCount} inlined steps, ${s}${d})`}if(t.refKind&&t.status==="failed"){let d=t.failedSubStepIndex&&t.failedSubStepIndex.length>0?` \u2014 at sub-step ${t.failedSubStepIndex.join(" \u2192 sub-step ")}`:"",r=t.helperResultRelPath?` \u2192 ${t.helperResultRelPath}`:"";return`## ${e.heading} \u2717 failed${l} (via @${t.refKind} ${t.refLabel}${d}, ${s}${r})`}return t.status==="passed"?`## ${e.heading} \u2713 passed (${s})`:`## ${e.heading} \u2717 failed${l} (${s})`}var Ie=/^##\s+(.+?)\s+(✓ passed|✗ failed(?:\s+\(optional\))?|⏭ skipped)(?:\s+\((.*)\))?\s*$/,ke=/via\s+@\w+\s+(\S+).*?(?:→\s+(\S+))?\s*$/,be=/^md5:\s+([a-f0-9]{32})\s*$/;function ee(e,t){for(let s=t;s<e.length&&!/^##\s/.test(e[s]);s++){if(e[s].trim()==="")continue;let l=be.exec(e[s]);return l?l[1]:null}return null}function M(e){let s=ye(e,"utf8").split(`
4
+ `),l="passed";if(s[0]?.trim()==="---")for(let r=1;r<s.length&&s[r].trim()!=="---";r++){let p=/^status:\s+(passed|failed|interrupted)\s*$/.exec(s[r]);p&&(l=p[1])}let d=[];for(let r=0;r<s.length;r++){let p=Ie.exec(s[r]);if(!p)continue;let o=p[1],n=p[2],c=p[3]??"",m=n.startsWith("\u2713")?"passed":n.startsWith("\u23ED")?"skipped":"failed";if(/via\s+@/.test(c)){let f=ke.exec(c),v=f?.[1]??"",x=f?.[2]??null;d.push({kind:"import",heading:o,status:m,md5:ee(s,r+1),importPath:v,helperResultRelPath:x})}else d.push({kind:"objective",heading:o,status:m,md5:ee(s,r+1)})}return{overallStatus:l,steps:d}}import{copyFileSync as se,existsSync as H,mkdirSync as ve,writeFileSync as ne,promises as Ue}from"fs";import{join as F,dirname as re,basename as we}from"path";async function ie(e){for(let t=0;t<e.totalRunDirs;t++){let s=e.runIndex+t,l=F(e.sessionDir,"runs",String(s)),d=F(e.stagingStepDir,"flows",String(t));ve(d,{recursive:!0});let r=F(d,"actions.ndjson");if(e.packTestDir){let n=F(e.packTestDir,"logs",`${s}-actions.ndjson`);if(H(n)){se(n,r);continue}let c=re(re(e.packTestDir)),m=we(e.packTestDir),R=H(c)?await U(c,`tests/${m}/logs/${s}-actions.ndjson`).catch(()=>null):null;ne(r,R??"");continue}let p=[F(l,"run-test","actions.ndjson"),F(l,"actions.ndjson")],o=!1;for(let n of p)if(H(n)){se(n,r),o=!0;break}o||ne(r,"")}}import{existsSync as _,readdirSync as Pe}from"fs";import{dirname as $e,join as j,basename as W}from"path";function et(e,t){let s=[];return e.steps.forEach((l,d)=>{let r=t[d];l.block||!l.replayOnly||!r||r.kind!=="author"||s.push({flatIndex:l.flatIndex,file:l.owningFile,heading:l.trace[l.trace.length-1].heading,kind:l.replayOnly,reason:r.reason})}),s}function tt(e){let t=[],s=new Set,l=new Map;function d(n){if(l.has(n))return l.get(n);let c=P(n),m=_(c)?M(c):null;return l.set(n,m),m}let r=new Map;function p(n){if(r.has(n))return r.get(n);let c=j(n,"Result.md"),m=_(c)?M(c):null;return r.set(n,m),m}function o(n){for(let c=1;c<n.trace.length;c++){let m=n.trace[c-1],R=d(m.file);if(!R)continue;let f=R.steps[m.stepIndex-1];if(f){if(f.kind!=="import")return{kind:"author",reason:"structure-mismatch"};if(W(f.importPath)!==W(n.trace[c].file))return{kind:"author",reason:"structure-mismatch"};if(f.md5!=null&&f.md5!==m.rowMd5)return{kind:"author",reason:"structure-mismatch"}}}return null}for(let n of e.steps){let c=n.trace[n.trace.length-1].stepIndex,m=n.replayOnly;if(n.block){let h=d(n.owningFile)?.steps[c-1],D=n.controlFlow!==void 0,O=h?.kind==="objective"&&h.status==="skipped";if(D||O){t.push({kind:"replay",recordingDir:"",flowCount:0,unrecorded:!0,...m?{replayOnly:m}:{}});continue}}let R=s.has(n.owningFile);for(let h=0;h<n.trace.length-1&&!R;h++)s.has(n.trace[h].file)&&(R=!0);if(R&&!m){t.push({kind:"author",reason:d(n.owningFile)===null?"no-result-md":"downstream-of-divergence"});continue}let f=o(n);if(f){for(let h=0;h<n.trace.length;h++)s.add(n.trace[h].file);if(!m){t.push(f);continue}}let v=d(n.owningFile),x;if(v===null&&n.trace.length>1){let h=V(n.trace);x=oe(n,p(h),c,h)}else x=oe(n,v,c);if(m&&x.kind==="replay"&&(x={...x,replayOnly:m}),t.push(x),x.kind==="author"){s.add(n.owningFile);for(let h=0;h<n.trace.length-1;h++)s.add(n.trace[h].file)}}return t}function oe(e,t,s,l=null){if(!t)return{kind:"author",reason:"no-result-md"};let d=t.steps[s-1];if(!d)return{kind:"author",reason:"no-result-md"};if(d.kind!=="objective")return{kind:"author",reason:"structure-mismatch"};if(d.status!=="passed")return{kind:"author",reason:"recorded-failed"};let r=A(e);if(r!==d.md5)return{kind:"author",reason:"md5-mismatch"};let p=l===null?X(e.owningFile,s,r.slice(0,8)):j(l,".internal","steps",`${s}-${r.slice(0,8)}`),o=De(p);return o===0?{kind:"author",reason:"missing-recording"}:{kind:"replay",recordingDir:p,flowCount:o}}function De(e){let t=j(e,"flows");if(!_(t))return 0;let s;try{s=Pe(t,{withFileTypes:!0}).filter(d=>d.isDirectory()&&/^\d+$/.test(d.name)).map(d=>parseInt(d.name,10))}catch{return 0}if(s.length===0)return 0;let l=Math.max(...s);for(let d=0;d<=l;d++)if(!_(j(t,String(d),"actions.ndjson")))return 0;return l+1}function st(e){return e.some(t=>t.kind==="author")}function nt(e){for(let t=0;t<e.length;t++)if(e[t].kind==="author")return t;return e.length}function V(e){let t=r=>{let p=W(r);return p.endsWith("_test.md")?p.slice(0,-8):p.endsWith(".md")?p.slice(0,-3):p},s=t(e[0].file),l=t(e[e.length-1].file),d=e.slice(0,-1).map(r=>String(r.stepIndex));return j($e(e[e.length-1].file),`helper-output-${l}-${s}-${d.join("-")}`)}function rt(e){return Array.from({length:e.flowCount},(t,s)=>j(e.recordingDir,"flows",String(s),"actions.ndjson"))}import{existsSync as de,mkdirSync as Me,rmSync as Fe,cpSync as je}from"fs";function ae(e,t){de(e)&&(de(t)&&Fe(t,{recursive:!0,force:!0}),Me(t,{recursive:!0}),je(e,t,{recursive:!0}))}async function St(e){let t=new Map;for(let o of e.stepRunRecords)t.set(o.testmdStepIndex,o);let s=e.authoredFlatIdx??new Set,l=[],d=[],r=new Map,p=o=>{if(r.has(o))return r.get(o);let n=y(o,"Result.md"),c=$(n)?M(n):null;return r.set(o,c),c};for(let o of e.resolvedTest.unitFiles){let n=o.file===e.resolvedTest.rootPath,c=G(o.file,Oe(o.file,"utf8")),m=P(o.file),R=$(m)?M(m):null,f=[],v=[],x=[],h=[];if(!n)for(let a of e.resolvedTest.steps){if(a.owningFile!==o.file||a.trace.length<2)continue;let i=V(a.trace);h.includes(i)||h.push(i)}let D=a=>{if(R!==null)return null;for(let i of h){let w=p(i)?.steps[a-1];if(w)return{row:w,dir:i}}return null},O=[],E=!1,B=!1,L=!1,K=!1;for(let a of c.steps){let i=a.index,u=R?.steps[i-1];if(a.body.kind==="objective"){let g=e.resolvedTest.steps.filter(S=>S.owningFile===o.file&&S.trace[S.trace.length-1].stepIndex===i&&t.has(S.flatIndex)),I=g.length>0?g[g.length-1]:null;if(I){E=!0,s.has(I.flatIndex)&&(B=!0);let S=A(I),k;n?k=e.outcomes.find(he=>he.rootStepIndex===i)??{rootStepIndex:i,status:"skipped"}:k={rootStepIndex:i,status:fe(I,e.outcomes)},k.status==="failed"&&(L=!0),k.stepMd5==null&&(k.stepMd5=S),f.push(k),v.push({stepIndex:i,md5:S,rec:t.get(I.flatIndex)}),(!u||u.kind!=="objective"||u.status!==k.status||k.status==="passed"&&u.md5!==S)&&(K=!0)}else if(u&&u.kind==="objective")f.push({rootStepIndex:i,status:u.status,...u.md5?{stepMd5:u.md5}:{}}),x.push(i);else if(!n&&D(i)?.row.kind==="objective"){let S=D(i),k=S.row;f.push({rootStepIndex:i,status:k.status,...k.md5?{stepMd5:k.md5}:{}}),O.push({psIdx:i,dir:S.dir})}else n?f.push(e.outcomes.find(S=>S.rootStepIndex===i)??{rootStepIndex:i,status:"skipped"}):f.push({rootStepIndex:i,status:"skipped"});continue}let w=Ee(a.body.path)?a.body.path:Ke(_e(o.file),a.body.path),T=Y({path:a.body.path,bindings:a.body.bindings,optional:a.optional??!1}),N=Le(J(o.file),P(w)),C=e.resolvedTest.steps.filter(g=>g.trace.some((I,S)=>S<g.trace.length-1&&I.file===o.file&&I.stepIndex===i)&&t.has(g.flatIndex));if(C.length>0){E=!0;let g;if(n)g=e.outcomes.find(I=>I.rootStepIndex===i)??{rootStepIndex:i,status:"passed",refKind:"import",refLabel:a.body.path};else{let I=C.some(S=>fe(S,e.outcomes)==="failed");g={rootStepIndex:i,status:I?"failed":"passed",refKind:"import",refLabel:a.body.path,inlinedCount:C.length}}g.status==="failed"&&(L=!0),g.stepMd5==null&&(g.stepMd5=T),g.helperResultRelPath==null&&(g.helperResultRelPath=N),f.push(g),(!u||u.kind!=="import"||u.status!==g.status||u.md5!==T)&&(K=!0)}else if(u&&u.kind==="import")f.push({rootStepIndex:i,status:u.status,refKind:"import",refLabel:u.importPath,...u.md5?{stepMd5:u.md5}:{},...u.helperResultRelPath?{helperResultRelPath:u.helperResultRelPath}:{}});else if(!n&&D(i)?.row.kind==="import"){let g=D(i).row;f.push({rootStepIndex:i,status:g.status,refKind:"import",refLabel:a.body.path})}else n?f.push(e.outcomes.find(g=>g.rootStepIndex===i)??{rootStepIndex:i,status:"skipped",refKind:"import",refLabel:a.body.path}):f.push({rootStepIndex:i,status:"skipped",refKind:"import",refLabel:a.body.path})}if(!(n||E&&(B||L||R===null||K)))continue;l.push(o.file);let b=z(o.file);pe(y(b,".internal"),{recursive:!0});for(let a of v){let i=y(b,".internal","steps",`${a.stepIndex}-${a.md5.slice(0,8)}`);pe(i,{recursive:!0}),await ie({sessionDir:e.sessionDir,runIndex:a.rec.runIndex,totalRunDirs:a.rec.totalRunDirs,stagingStepDir:i,packTestDir:e.packTestDir})}if(x.length>0){let a=Q(o.file);if($(a))for(let i of ce(a)){let u=parseInt(i.split("-")[0]??"",10);!Number.isNaN(u)&&x.includes(u)&&ue(y(a,i),y(b,".internal","steps",i),{recursive:!0})}}for(let a of O){let i=y(a.dir,".internal","steps");if($(i))for(let u of ce(i))parseInt(u.split("-")[0]??"",10)===a.psIdx&&ue(y(i,u),y(b,".internal","steps",u),{recursive:!0})}let me=f.some(a=>a.status==="failed");if(te({sourcePath:o.file,title:c.title,rootSteps:c.steps,outcomes:f,overallStatus:n?e.overallStatus:me?"failed":"passed",startedISO:e.startedISO,durationS:n?e.durationS:0,sessionId:e.sessionId,outPath:y(b,"Result.md")}),n){let a={};e.commitId&&(a.commit_id=e.commitId),e.tmsIds.testId&&(a.test_id=e.tmsIds.testId),e.tmsIds.testcaseId&&(a.testcase_id=e.tmsIds.testcaseId),e.tmsIds.projectId&&(a.project_id=e.tmsIds.projectId),e.tmsIds.folderId&&(a.folder_id=e.tmsIds.folderId),e.tmsIds.orgId&&(a.org_id=e.tmsIds.orgId),e.tmsIds.sessionName&&(a.session_name=e.tmsIds.sessionName),Ae(y(b,".internal","meta.json"),JSON.stringify(a,null,2)+`
5
+ `,"utf8");let i=y(e.sessionDir,"execution.json");if($(i))try{le(i,y(b,".internal","execution.json"))}catch{}if(e.codeExportDir){let u=e.codeExportLanguage??"python",w=e.codeExportFramework??"playwright",T=y(b,`${w}-${u}-code`);try{ae(e.codeExportDir,T)}catch(N){process.stderr.write(`warn: codegen copy failed: ${N.message}
6
+ `)}}}else if(o.kind==="test"||o.kind==="module"){let a=q(o.file);if($(a))try{le(a,y(b,".internal","meta.json"))}catch{}}!n&&h.length>0&&f.every(i=>i.status!=="skipped")&&d.push({unitFile:o.file,dirs:h.filter(i=>$(i))})}return{changedUnitFiles:l,legacySweep:d}}function yt(e){for(let t of e)try{Te(t,{recursive:!0,force:!0})}catch{}}function fe(e,t){let s=e.trace[0].stepIndex,l=t.find(o=>o.rootStepIndex===s);if(!l)return"skipped";if(l.status==="passed")return"passed";if(l.status==="skipped")return"skipped";let d=e.trace.slice(1).map(o=>o.stepIndex),r=l.failedSubStepIndex??[],p=Math.min(d.length,r.length);for(let o=0;o<p;o++)if(d[o]!==r[o])return d[o]<r[o]?"passed":"skipped";return d.length===r.length?"failed":d.length<r.length?"passed":"skipped"}export{te as a,et as b,tt as c,st as d,nt as e,rt as f,ae as g,St as h,yt as i};