@testmuai/kane-cli 0.8.23 → 0.9.0

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 (250) hide show
  1. package/dist/{ChatSurface-GBZX4LWL.js → ChatSurface-FJPK3XEJ.js} +1 -1
  2. package/dist/{ChromeProfilePicker-UONX2UVC.js → ChromeProfilePicker-7DUDJTE2.js} +1 -1
  3. package/dist/{CliFeedbackPrompt-6BJCNRNG.js → CliFeedbackPrompt-ZZPYC6OS.js} +1 -1
  4. package/dist/{CliUploadProgress-K4Z22DSY.js → CliUploadProgress-WQYKIBAR.js} +1 -1
  5. package/dist/ConfigView-KXNOODDW.js +2 -0
  6. package/dist/EvidenceViewOffer-BTBVPBZX.js +2 -0
  7. package/dist/FolderPicker-H4YEX5LV.js +2 -0
  8. package/dist/{InfoBox-OU5PLRIL.js → InfoBox-DTM7X24Z.js} +1 -1
  9. package/dist/{LinksBox-DH7TSUXW.js → LinksBox-KFG3FVOT.js} +1 -1
  10. package/dist/{ProfilesView-MGJKBOF5.js → ProfilesView-KBZHT4KL.js} +1 -1
  11. package/dist/{ProjectPicker-YFV6K77F.js → ProjectPicker-OARWULNN.js} +1 -1
  12. package/dist/{SaveSessionPrompt-64QKQB6B.js → SaveSessionPrompt-37SMU5MC.js} +1 -1
  13. package/dist/SingleShotApp-UYCAW65Y.js +2 -0
  14. package/dist/{SummaryBox-DGS3LVRF.js → SummaryBox-6RB5DSAH.js} +1 -1
  15. package/dist/TestMdRunView-ZMOII3PL.js +2 -0
  16. package/dist/{TestrunEvidenceTable-PHBAB4XQ.js → TestrunEvidenceTable-3UP2EYIV.js} +1 -1
  17. package/dist/{WhoamiView-6HWPYN6Y.js → WhoamiView-MC62GERR.js} +1 -1
  18. package/dist/app-client-PQFJAB63.js +2 -0
  19. package/dist/app-download-P6YXWSVQ.js +2 -0
  20. package/dist/{auth-NWBIFCB7.js → auth-LXW4OFKF.js} +1 -1
  21. package/dist/{binary-MOJTQGUV.js → binary-LVHXED3O.js} +1 -1
  22. package/dist/{bind-S3IQTPNN.js → bind-ZYESQSCJ.js} +2 -2
  23. package/dist/{bootstrap-RCV7PNMQ.js → bootstrap-DI4UGMH3.js} +1 -1
  24. package/dist/bridge-7J3JE3JS.js +2 -0
  25. package/dist/catalog-LLME3744.js +2 -0
  26. package/dist/{changelog-2N6HKKKQ.js → changelog-N5AZHXOS.js} +1 -1
  27. package/dist/{chunk-MZ7W4WLF.js → chunk-243ZJHT6.js} +1 -1
  28. package/dist/{chunk-LF42V6P6.js → chunk-2PKME4VT.js} +4 -4
  29. package/dist/{chunk-3OKX64UR.js → chunk-3MCPTVJX.js} +1 -1
  30. package/dist/{chunk-5UHY3PTQ.js → chunk-3YIZG7WZ.js} +1 -1
  31. package/dist/{chunk-TONFENRW.js → chunk-4BZOG6PE.js} +1 -1
  32. package/dist/{chunk-MBJHS653.js → chunk-4CYBXJIA.js} +1 -1
  33. package/dist/{chunk-BASTDR3M.js → chunk-4FHK4LKQ.js} +1 -1
  34. package/dist/{chunk-LNSBC32V.js → chunk-4Y2WH77W.js} +1 -1
  35. package/dist/{chunk-UQSVO7TY.js → chunk-5HMN74RZ.js} +1 -1
  36. package/dist/chunk-5RCS2LIQ.js +26 -0
  37. package/dist/chunk-5TQFOPJV.js +2 -0
  38. package/dist/{chunk-KJIDMW6N.js → chunk-6HU5M2DS.js} +1 -1
  39. package/dist/{chunk-JFZA4UON.js → chunk-6MD7SR7D.js} +1 -1
  40. package/dist/{chunk-J6TBTWW7.js → chunk-6VY62QC2.js} +1 -1
  41. package/dist/{chunk-GFNCGN5V.js → chunk-75MMTNPB.js} +2 -2
  42. package/dist/{chunk-OFRYEWZE.js → chunk-7GAHJZLH.js} +1 -1
  43. package/dist/chunk-7WXMV3O3.js +7 -0
  44. package/dist/{chunk-IIDBLJ5A.js → chunk-AHFIRHSP.js} +1 -1
  45. package/dist/chunk-AJT34ESA.js +38 -0
  46. package/dist/chunk-AKE2CTV6.js +2 -0
  47. package/dist/{chunk-VACHFCNC.js → chunk-AUMJ4RVA.js} +1 -1
  48. package/dist/chunk-BL3SJDCG.js +10 -0
  49. package/dist/chunk-BUPRL2TE.js +2 -0
  50. package/dist/chunk-C25M2J5Q.js +4 -0
  51. package/dist/{chunk-RAARDC2O.js → chunk-C6S2RPZA.js} +1 -1
  52. package/dist/{chunk-3C32LVLX.js → chunk-CNUCP6DK.js} +1 -1
  53. package/dist/chunk-CSNJPD2J.js +5 -0
  54. package/dist/{chunk-2FH4HJYB.js → chunk-CW3RHKLA.js} +1 -1
  55. package/dist/{chunk-J2FJ62K4.js → chunk-DOOI2JBD.js} +1 -1
  56. package/dist/{chunk-2A7OQRAD.js → chunk-DTRKTBCE.js} +4 -4
  57. package/dist/{chunk-QAG67DUT.js → chunk-DTRSYWZE.js} +1 -1
  58. package/dist/{chunk-5HOHXV2K.js → chunk-DWMESHFI.js} +1 -1
  59. package/dist/chunk-EBLXHOE3.js +2 -0
  60. package/dist/{chunk-PXHN7SFG.js → chunk-EOA6YPES.js} +1 -1
  61. package/dist/{chunk-FPFS6OSR.js → chunk-F7NSSQYZ.js} +1 -1
  62. package/dist/chunk-FMUV6UCX.js +2 -0
  63. package/dist/chunk-GCISXCDU.js +2 -0
  64. package/dist/chunk-GFBAK7WQ.js +8 -0
  65. package/dist/{chunk-RMVASIVL.js → chunk-GTVQYT3D.js} +2 -2
  66. package/dist/{chunk-CLQP3DHT.js → chunk-HAYV4D2I.js} +1 -1
  67. package/dist/{chunk-6YZ3VP3E.js → chunk-HG5LLZBU.js} +1 -1
  68. package/dist/chunk-HGFWIBVF.js +8 -0
  69. package/dist/{chunk-3UMVRJX3.js → chunk-ILDHE4P4.js} +2 -2
  70. package/dist/{chunk-QQCEP3QP.js → chunk-IPXKUYUK.js} +1 -1
  71. package/dist/{chunk-D4XR7EEQ.js → chunk-J3BGYSMD.js} +12 -10
  72. package/dist/{chunk-OYKRCDT4.js → chunk-JQY5HRZ4.js} +1 -1
  73. package/dist/{chunk-AGDPEZXT.js → chunk-JX6BFEDO.js} +1 -1
  74. package/dist/chunk-K3IQEL7R.js +7 -0
  75. package/dist/{chunk-5RHR4DMF.js → chunk-KWEOLPBJ.js} +1 -1
  76. package/dist/{chunk-SYJXTB4J.js → chunk-KXEE6VCA.js} +1 -1
  77. package/dist/{chunk-FORNRNHU.js → chunk-LH4IPANP.js} +1 -1
  78. package/dist/{chunk-WICJY6KL.js → chunk-LLG7NEGX.js} +1 -1
  79. package/dist/{chunk-UYI4WPNQ.js → chunk-M3UAZTDK.js} +1 -1
  80. package/dist/{chunk-DUYRCVI5.js → chunk-NMSZ7G6P.js} +1 -1
  81. package/dist/chunk-NOL7MNZH.js +2 -0
  82. package/dist/{chunk-C7NWWGLT.js → chunk-OC6H6BYI.js} +1 -1
  83. package/dist/{chunk-HBSYBL6J.js → chunk-OHOJSADN.js} +1 -1
  84. package/dist/chunk-OIUV3ISA.js +2 -0
  85. package/dist/{chunk-AIK7BAME.js → chunk-OJAXOOZ5.js} +2 -2
  86. package/dist/{chunk-RGRFL7XG.js → chunk-OMNLAGQC.js} +1 -1
  87. package/dist/{chunk-HPHETGRE.js → chunk-OOCCUUR2.js} +1 -1
  88. package/dist/{chunk-SB2SKN34.js → chunk-OXC6O5O7.js} +1 -1
  89. package/dist/chunk-OZQDD2EX.js +94 -0
  90. package/dist/{chunk-D6BULK7E.js → chunk-PCKIANML.js} +1 -1
  91. package/dist/{chunk-RD72POF2.js → chunk-PEDINHVU.js} +1 -1
  92. package/dist/{chunk-MKMJOMLX.js → chunk-PNUAP3RY.js} +2 -2
  93. package/dist/{chunk-2MEQTHNI.js → chunk-Q5CINJYL.js} +1 -1
  94. package/dist/{chunk-SY4T44VC.js → chunk-Q5RDCSYM.js} +1 -1
  95. package/dist/chunk-QAB3Y5FQ.js +4 -0
  96. package/dist/{chunk-WJR2FU7S.js → chunk-RTSBKCZY.js} +1 -1
  97. package/dist/{chunk-K6VDRR3H.js → chunk-RWSOZPJQ.js} +1 -1
  98. package/dist/{chunk-HJGVM6TS.js → chunk-SID4X77D.js} +1 -1
  99. package/dist/chunk-SOCHN2PY.js +2 -0
  100. package/dist/{chunk-NIFJJX6N.js → chunk-SRTKRHYI.js} +1 -1
  101. package/dist/chunk-TM7VRLWS.js +2 -0
  102. package/dist/{chunk-IEW7AW64.js → chunk-UA2QDAWT.js} +1 -1
  103. package/dist/{chunk-ZIHG6EKH.js → chunk-USOYXCZ4.js} +1 -1
  104. package/dist/{chunk-DWHF5HUD.js → chunk-USY7VAO6.js} +1 -1
  105. package/dist/{chunk-AT3RME5W.js → chunk-UWXDURAB.js} +1 -1
  106. package/dist/{chunk-D7WG7SRA.js → chunk-VBS33P2C.js} +1 -1
  107. package/dist/{chunk-YI3H2UIB.js → chunk-VHW7BMZQ.js} +1 -1
  108. package/dist/{chunk-SFFDVF3J.js → chunk-VORWZLS3.js} +2 -2
  109. package/dist/{chunk-DSKJ6J7Y.js → chunk-WDMUPK6I.js} +1 -1
  110. package/dist/{chunk-QGXVQIN5.js → chunk-WMI4P76K.js} +2 -2
  111. package/dist/{chunk-MKQ7ZRDW.js → chunk-WNOC6MQC.js} +1 -1
  112. package/dist/{chunk-XQQHSC7G.js → chunk-WRSIKZ2V.js} +1 -1
  113. package/dist/chunk-X2A6CC6B.js +2 -0
  114. package/dist/{chunk-LNFU4JZ7.js → chunk-XBX643ZD.js} +1 -1
  115. package/dist/{chunk-CAJZQQ3G.js → chunk-XKHWWKJZ.js} +1 -1
  116. package/dist/{chunk-HJX5PQRD.js → chunk-XT7XA4DN.js} +1 -1
  117. package/dist/{chunk-QU7P7B3W.js → chunk-Y3ZYN6AK.js} +3 -3
  118. package/dist/chunk-YBAVDT3G.js +2 -0
  119. package/dist/{chunk-5ESGUPSR.js → chunk-YWYORBY3.js} +1 -1
  120. package/dist/{chunk-IGHK2ENL.js → chunk-Z7IGTVJW.js} +1 -1
  121. package/dist/{chunk-CSVPZ33X.js → chunk-ZC2CKWLB.js} +1 -1
  122. package/dist/{chunk-UF4MU2AZ.js → chunk-ZER3FZSZ.js} +2 -2
  123. package/dist/chunk-ZJYT72BA.js +9 -0
  124. package/dist/{chunk-LHUW5QDT.js → chunk-ZXY4P76I.js} +1 -1
  125. package/dist/{config-7E4NS553.js → config-YGTHSGQN.js} +1 -1
  126. package/dist/cover-cmd-6RO366CC.js +3 -0
  127. package/dist/{credentials-PSQWWFGD.js → credentials-QD32Y7K7.js} +1 -1
  128. package/dist/{deps-bundle-PPOQHJTB.js → deps-bundle-OI7JJ22L.js} +1 -1
  129. package/dist/{deps-resolve-AX6ZAKLH.js → deps-resolve-ZOALDS6H.js} +1 -1
  130. package/dist/device-env-DXDJJMTL.js +2 -0
  131. package/dist/{dispatch-KMWEDMKE.js → dispatch-7EWWQRQ5.js} +1 -1
  132. package/dist/{doctor-XDF3MA4W.js → doctor-TPYPEEUL.js} +1 -1
  133. package/dist/evidence-NPFTBGDF.js +2 -0
  134. package/dist/evolve-cmd-VGVXV6XW.js +2 -0
  135. package/dist/explain-cmd-GOP5TE63.js +9 -0
  136. package/dist/{explain-cmd-JAOHSI4F.js → explain-cmd-M7IX2YNB.js} +1 -1
  137. package/dist/{extract-bind-PLMSZKLZ.js → extract-bind-CKIRLXAJ.js} +2 -2
  138. package/dist/{extract-cmd-RJBHPPF3.js → extract-cmd-3EWLSPGS.js} +1 -1
  139. package/dist/gaps-cmd-WVC5GXQC.js +3 -0
  140. package/dist/{generate-headless-TEDHS3F2.js → generate-headless-6WMJYNI6.js} +2 -2
  141. package/dist/index.js +175 -174
  142. package/dist/ingest-cmd-AECK5T4H.js +2 -0
  143. package/dist/install-ZV3KJZV4.js +2 -0
  144. package/dist/{interactive-bind-XUMKEGAN.js → interactive-bind-IYS6KDOH.js} +3 -3
  145. package/dist/lifecycle-cmd-XCSBELFQ.js +2 -0
  146. package/dist/list-cmd-S4DSN2ET.js +3 -0
  147. package/dist/{list-commands-OHIQFJGQ.js → list-commands-GLNGHPDU.js} +1 -1
  148. package/dist/login-flow-ASUUU7SO.js +2 -0
  149. package/dist/maintenance-cmd-K5KXRIFL.js +2 -0
  150. package/dist/mobile-prompts-ZUZTA3RV.js +2 -0
  151. package/dist/{objective-variable-gate-JALOH6SL.js → objective-variable-gate-CG2KK5UX.js} +1 -1
  152. package/dist/{open-provider-746LLSEO.js → open-provider-YIBB77FE.js} +1 -1
  153. package/dist/persist-recorded-session-EWV56TSZ.js +3 -0
  154. package/dist/pipeline-LAWACB2O.js +2 -0
  155. package/dist/prepare-target-WGPCZKLE.js +2 -0
  156. package/dist/real-device-run-MDLFKFVQ.js +2 -0
  157. package/dist/reconcile-cmd-XFM2ZXUJ.js +2 -0
  158. package/dist/reconcile-deps-V5VLDPYT.js +4 -0
  159. package/dist/reconcile-engine-VZBTMPUK.js +2 -0
  160. package/dist/{recording-banner-TCFFB6KE.js → recording-banner-CJHRPHHF.js} +1 -1
  161. package/dist/registry-3JXQFZEG.js +2 -0
  162. package/dist/{require-project-folder-2224ZMJ5.js → require-project-folder-SE5GVCYJ.js} +1 -1
  163. package/dist/resolve-run-intent-DD4MB6UD.js +2 -0
  164. package/dist/{resolver-GJR2Z7JY.js → resolver-TLO4SRWV.js} +1 -1
  165. package/dist/review-cmd-7EOYQMPE.js +5 -0
  166. package/dist/run-EHUNJPW6.js +2 -0
  167. package/dist/run-OTMPUQSH.js +2 -0
  168. package/dist/run-test-md-KBDEHGXJ.js +17 -0
  169. package/dist/session-target-UMNASXI7.js +2 -0
  170. package/dist/{sessions-cmd-IV25N2L7.js → sessions-cmd-M3SECFKQ.js} +1 -1
  171. package/dist/{skill-installer-T2IOCPET.js → skill-installer-32YYMM4N.js} +1 -1
  172. package/dist/{spawner-HQM2757J.js → spawner-DPT2RLAO.js} +1 -1
  173. package/dist/store-guard-U32JE6JJ.js +2 -0
  174. package/dist/structured-answers-ZI2B6JJE.js +1 -1
  175. package/dist/sync-cmd-3EP7LZGL.js +2 -0
  176. package/dist/sync-setup-SWTBVQEV.js +2 -0
  177. package/dist/tcg-generate-KXU7E2GF.js +2 -0
  178. package/dist/testmd-actions-PEWCPQ5R.js +2 -0
  179. package/dist/testmd-sync-ZWFQWZ2X.js +2 -0
  180. package/dist/token-refresh-QD3OCGJJ.js +2 -0
  181. package/dist/{validate-basic-V7R4RH5M.js → validate-basic-AAIXSAWH.js} +1 -1
  182. package/dist/{variable-receipt-F55CSW5Z.js → variable-receipt-YWNS24TH.js} +1 -1
  183. package/dist/{verdicts-7IUZFXB4.js → verdicts-LAB5BGCC.js} +1 -1
  184. package/dist/{version-check-PUUSB7AY.js → version-check-EHOLX3YH.js} +1 -1
  185. package/dist/{view-cmd-ELDKYRMZ.js → view-cmd-3WHG6MVB.js} +1 -1
  186. package/dist/walk-session-XP4KYFKO.js +2 -0
  187. package/dist/with-telemetry-FJMJQDCM.js +2 -0
  188. package/package.json +11 -11
  189. package/dist/ConfigView-BB22G7JO.js +0 -2
  190. package/dist/EvidenceViewOffer-25IQF3TX.js +0 -2
  191. package/dist/FolderPicker-65JFR2NW.js +0 -2
  192. package/dist/SingleShotApp-VYKUCRVW.js +0 -2
  193. package/dist/TestMdRunView-LKAITAA4.js +0 -2
  194. package/dist/app-client-ZCCNE3RV.js +0 -2
  195. package/dist/app-download-SQ2LYYL7.js +0 -2
  196. package/dist/bridge-O7ENTV4K.js +0 -2
  197. package/dist/chunk-7KRY26OF.js +0 -4
  198. package/dist/chunk-ATYXPCM6.js +0 -6
  199. package/dist/chunk-BL5QHONU.js +0 -2
  200. package/dist/chunk-CXF6AZWY.js +0 -2
  201. package/dist/chunk-DDHGEJJP.js +0 -2
  202. package/dist/chunk-EM3PU2YW.js +0 -2
  203. package/dist/chunk-EYOCNMUM.js +0 -2
  204. package/dist/chunk-FMBPUXWL.js +0 -8
  205. package/dist/chunk-FQJOWUEN.js +0 -2
  206. package/dist/chunk-MV3Q335C.js +0 -7
  207. package/dist/chunk-MWIE6LOZ.js +0 -4
  208. package/dist/chunk-ODU2JSMA.js +0 -8
  209. package/dist/chunk-RAPV3BTA.js +0 -98
  210. package/dist/chunk-TAOHYWEO.js +0 -2
  211. package/dist/chunk-URWWROLS.js +0 -9
  212. package/dist/chunk-VAN7ECN6.js +0 -2
  213. package/dist/chunk-VOYMN2WQ.js +0 -5
  214. package/dist/chunk-X4NUVVCJ.js +0 -26
  215. package/dist/chunk-YFQGOOF7.js +0 -2
  216. package/dist/cover-cmd-6KZX46S2.js +0 -3
  217. package/dist/device-env-TZQDB5T3.js +0 -2
  218. package/dist/evidence-EUIDOVOR.js +0 -2
  219. package/dist/evolve-cmd-QVTGTCJ5.js +0 -2
  220. package/dist/explain-cmd-36SVSHU7.js +0 -9
  221. package/dist/gaps-cmd-3WZPDDYS.js +0 -3
  222. package/dist/ingest-cmd-JDIOPJBN.js +0 -2
  223. package/dist/install-Y3VKFBK3.js +0 -2
  224. package/dist/lifecycle-cmd-FBDRFIOE.js +0 -2
  225. package/dist/list-cmd-TFUACRAM.js +0 -3
  226. package/dist/login-flow-OHNKSVYZ.js +0 -2
  227. package/dist/maintenance-cmd-7OSUIDL4.js +0 -2
  228. package/dist/mobile-prompts-DEVUZRG3.js +0 -2
  229. package/dist/persist-recorded-session-GPP6UKN6.js +0 -3
  230. package/dist/pipeline-QPTPZVUJ.js +0 -2
  231. package/dist/prepare-target-N7QRNYOS.js +0 -2
  232. package/dist/reconcile-cmd-SMGLHMLF.js +0 -2
  233. package/dist/reconcile-deps-DVIJK5UZ.js +0 -4
  234. package/dist/reconcile-engine-KL2J5SNQ.js +0 -2
  235. package/dist/registry-BFFA4YJK.js +0 -2
  236. package/dist/resolve-run-intent-HFXGEOYK.js +0 -2
  237. package/dist/review-cmd-CQE6SBZA.js +0 -5
  238. package/dist/run-BXKWDJFJ.js +0 -2
  239. package/dist/run-HSP2MZPU.js +0 -2
  240. package/dist/run-test-md-2ELPAASM.js +0 -17
  241. package/dist/session-target-UWROGOCY.js +0 -2
  242. package/dist/store-guard-NAW26EEQ.js +0 -2
  243. package/dist/sync-cmd-Q6ZYEVWI.js +0 -2
  244. package/dist/sync-setup-CA362C5S.js +0 -2
  245. package/dist/tcg-generate-CDB2N5LD.js +0 -2
  246. package/dist/testmd-actions-BDWDE2TG.js +0 -2
  247. package/dist/testmd-sync-EPTUVJYJ.js +0 -2
  248. package/dist/token-refresh-TKBOHXSD.js +0 -2
  249. package/dist/walk-session-EGIMA4VG.js +0 -2
  250. package/dist/with-telemetry-LRWWBISP.js +0 -2
@@ -1,5 +0,0 @@
1
- import { createRequire } from 'module'; const require = createRequire(import.meta.url);
2
- import{b as W,c as Z}from"./chunk-W3USRQX6.js";import{S as Y}from"./chunk-URWWROLS.js";import{b as X}from"./chunk-5GUD3CIH.js";import{a as J}from"./chunk-JQ64X2TO.js";import{a as Pt,b as k}from"./chunk-NBXYL2JT.js";import{a as H}from"./chunk-2KVECC36.js";import{a as K}from"./chunk-DHJSM5DT.js";import{a as G}from"./chunk-NLCCBXXV.js";import{a as R}from"./chunk-RZ4F3BHX.js";import{e as Rt}from"./chunk-UR6MHSHU.js";import{readFileSync as T,existsSync as V,readdirSync as le,mkdirSync as q,writeFileSync as w}from"fs";import{readFile as kt,unlink as de}from"fs/promises";import{join as y}from"path";import{existsSync as ee,mkdirSync as ne,readdirSync as bt,writeFileSync as re}from"fs";import{join as S}from"path";import{randomUUID as A}from"crypto";var tt=["children","instructions","branches","module_content","true_branch","false_branch"];function D(e){let t=new Map,n=i=>{if(!i||typeof i!="object")return;let o=i;if(Array.isArray(o.operations))for(let r of o.operations){let s=r.operation_id;if(typeof s!="string"||!s)continue;let a=t.get(s)??[];a.includes(o)||a.push(o),t.set(s,a)}for(let r of tt){let s=o[r];Array.isArray(s)?s.forEach(n):s&&typeof s=="object"&&n(s)}};return e.forEach(n),t}function St(e,t){if(!t||t.length===0)return;if(t.length===1)return t[0];let n=e.action_params?.script;if(typeof n=="string"&&n.trim()){let i=n.trim(),o=t.find(r=>wt(r)?.trim()===i);if(o)return o}return t[0]}function wt(e){let t=e,n=t.script_content??t.js_snippet;return typeof n=="string"?n:void 0}function U(e,t){let n=new Map;for(let i of e){let o=St(i,i.action_id?t.get(i.action_id):void 0);if(!o)continue;let r=n.get(o)??[];r.push(i),n.set(o,r)}return n.size===0?null:[...n].map(([i,o])=>Tt(i,o))}function et(e,t){let n=D(t.authoredInstructions),i=[];for(let o of e){if(o.flatIndex===void 0||!t.replayOnlyFlatIndices.has(o.flatIndex))continue;let r=U(o.records,n);r&&i.push(...r)}return i}function nt(e,t){let n=new Map(t.map(a=>[a.instruction_id,a])),i=[],o=a=>{if(!a||typeof a!="object")return;let c=a.instruction_id,u=typeof c=="string"?n.get(c):void 0;return u&&i.push(c),u},r=a=>{if(!a||typeof a!="object")return;let c=a;for(let u of tt){let l=c[u];if(Array.isArray(l))s(l);else if(l&&typeof l=="object"){let _=o(l);_&&(c[u]=_),r(_??l)}}},s=a=>{for(let c=0;c<a.length;c++){let u=o(a[c]);u&&(a[c]=u),r(u??a[c])}};return s(e),i}function xt(e){if(!e.timestamp||e.duration_ms==null)return"";let t=new Date(e.timestamp);return isNaN(t.getTime())?"":new Date(t.getTime()+e.duration_ms).toISOString()}function j(e){if(e!=null)try{return JSON.parse(e)}catch{return e}}function Ot(e){return typeof e=="string"?"string":typeof e=="boolean"?"bool":typeof e=="number"?Number.isInteger(e)?"int":"float":Array.isArray(e)?"list":e==null?"NoneType":"JSON"}function C(e,t,n){let i=e.user_variables,o=typeof i=="string",r;try{r=o?JSON.parse(i):i??[]}catch{return}if(!Array.isArray(r)||r.length===0)return;let s=r.find(a=>t&&a.name===t)??(r.length===1?r[0]:void 0);s&&(s.value=n,s.value_type=Ot(n),e.user_variables=o?JSON.stringify(r):r)}function Q(e){e.user_variables!==void 0&&(e.user_variables=typeof e.user_variables=="string"?"[]":[])}function Nt(e,t){let n=e.operations??[],i=new Set(t.map(r=>r.action_id).filter(Boolean)),o=n.filter(r=>i.has(r.operation_id));return o.length>0?o:n.length===1?n:[]}function Lt(e){let t=e.error??"Script execution failed";return{error:t,error_code:"SCRIPT_EXECUTION_ERROR",error_message:t,reason:t}}function Tt(e,t){let n=structuredClone(e),i=t[0],o=t[t.length-1];n.status=t.find(s=>s.status!=="success")?.status??i.status,n.start_timestamp=i.timestamp??n.start_timestamp,n.end_timestamp=xt(o)||n.end_timestamp;let r=Nt(n,t);for(let s of r)s.status=n.status,s.operation_start=n.start_timestamp,s.operation_end=n.end_timestamp;switch(n.content_type){case"api":{let s=o.action_params?.api_data?.response;if(s&&typeof s=="object")for(let a of[n,...r])a.api_data={...a.api_data??{},response:s},C(a,o.output_variable,s);break}case"script":{let s=o.output_variable??n.output_variable_name;if(n.status!=="success"){let a=Lt(o);n.code_error=a,Q(n);for(let c of r)c.execution_result=a,c.code_error=a,Q(c)}else if(o.output_value!=null){let a=j(o.output_value);C(n,s,a);for(let c of r)c.execution_result={value:a},C(c,s,a)}break}case"db_query":{o.output_value!=null&&(n.db_details={...n.db_details??{},carried_out_query:j(o.output_value)});break}case"screenshot_command":{let s=j(o.output_value);s&&typeof s=="object"&&(n.smartui_results=s);break}case"network_assertion":case"network_query":break;default:break}return n}var jt="/home/kaneai/Downloads";function O(e){return`${jt}/${e}`}function ot(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 st(e){return e?e.includes(`
3
- `)?e.split(`
4
- `).map(t=>t.trim()).filter(Boolean):e.split(". ").map(t=>t.trim()).filter(Boolean).map(t=>t.endsWith(".")?t:t+"."):[]}function F(e){return typeof e=="string"&&e.includes("{{secrets.")}var Ct={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"},at={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"},Dt=new Set(["CLICK","TYPE","FILL","HOVER","SCROLL_UNTIL_ELEMENT","UPLOAD_FILE","VISION_QUERY","DRAG_DROP","SELECT"]);function ct(e,t){if(e==="analyze"){let i=t?.action_params?.analyzer_type??"";return at[i]}if(e==="scroll"&&t?.action_params?.into_view===!0)return"SCROLL_UNTIL_ELEMENT";let n=Ct[e];return n||console.warn(`[migrator] UNKNOWN action_type "${e}" \u2014 falling back to "${e.toUpperCase()}"; explicit mapping required`),n??e.toUpperCase()}function ut(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 lt(e){try{return JSON.parse(e.output_value??"{}")}catch{return{}}}function Ut(e){let t=e.output_variable??"";if(!t)return"[]";let i={...lt(e)};return delete i.body,JSON.stringify([{name:t,unique_key:(e.action_id??"").replace(/-/g,"").slice(0,8)||A().replace(/-/g,"").slice(0,8),value:i,variable_description:"API Response"}])}function Ft(e,t,n){let i=e.action_params??{},o=Dt.has(t)?"Vision Agent":"Operation Agent",r={operation_type:t};if(t==="OPEN"&&(r.url=i.url??""),t==="SET_VARIABLE"&&(r.variable_name=e.output_variable??i.key??"",r.variable_value=e.output_value??""),t==="UPLOAD_FILE"){let m=N(i);m&&(r.value=O(m.name))}let s={},a={},c=e.action_instruction??"",u=i.text??"",l=i.url??"",_=[["intent",c],["value",u],["url",l]];for(let[m,h]of Object.entries(n)){let I=String(h);if(m.startsWith("secrets."))for(let[E,b]of _)b.includes(I)&&(a[E]=m);for(let[E,b]of _)b.includes(I)&&!(E in s)&&(s[E]=b)}let p=e.action_type,d={operation:e.action_instruction??"",agent:o,operation_dict:r,reasoning:p==="analyze"?i.query??"":e.intent??e.action_instruction??"",variable:s,secrets:a,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 g={set_cookies:"cookies",set_clipboard:"text",delete_cookies:"names",set_local_storage:"items",delete_local_storage:"keys"}[p];return g&&i[g]!==void 0&&(d[g]=i[g]),p==="set_clipboard"&&typeof i.html=="string"&&i.html&&(d.html=i.html),d}function L(e){let t=e.assertion_tree;return t&&typeof t=="object"&&Object.keys(t).length>0?t:Array.isArray(e.sub_results)?e:{}}function Bt(e){let t=L(e);if(typeof t.passed=="boolean")return t.passed;let n=t.sub_results??[];return n.length===0?t.status==="passed":(t.composite_operator??"and")==="or"?n.some(o=>o.passed===!0):n.every(o=>o.passed===!0)}function dt(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 Mt(e){let t=L(e),n=t.sub_results??[],i=dt(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 zt(e){let t=e.action_params??{},n=L(t),i=n.sub_results??[],o=dt(i);return[{operation:e.action_instruction??"",agent:"Operation Agent",operation_dict:{operation_type:"ASSERTION",assertion_tree:{sub_results:i,sub_checks:o,composite_operator:n.composite_operator??"and",verification:"",claim:n.description??e.action_instruction??"",operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[]}},variable:{},secrets:{},params:{}}]}function Vt(e,t,n,i){let o=e.visual_data;if(!o||o.x==null||o.y==null)return null;let r=t?`${t}/test_screenshots`:"";return{x:o.x,y:o.y,confidence:0,bbox:o.bbox??null,bbox_source:o.bbox?"accessibility_tree":"fallback",viewport_width:o.viewport_width??1280,viewport_height:o.viewport_height??800,scale_factor:null,raw_image_url:r?`${r}/untagged_screenshot/${n}.${i?.get(n)??"png"}`:"",raw_image_sas_url:"",annotated_image_url:"",annotated_image_sas_url:""}}function qt(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 $t(e){return/^(android|ios)_native$/i.test(e.platform??"")}function _t(e,t){return e.map(n=>({...n,type:t?n.strategy??n.type??"native":n.isXPath?"xpath":"css"}))}function Gt(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 o=t.target_selectors,r={};typeof t.direction=="string"&&t.direction&&(r.direction=t.direction,typeof t.fraction=="number"&&(r.fraction=t.fraction));let s=a=>typeof t[a]=="number"?Math.trunc(t[a]):null;return{selector_target:Array.isArray(o)&&o.length>0?_t(o,n):"",drag_displacement:r,hold_duration_ms:s("hold_duration_ms"),move_duration_ms:s("move_duration_ms"),hold_at_destination_ms:s("hold_at_destination_ms")}}function rt(e,t="",n){let i=e.action_type,o=ct(i,e),r=e.action_params??{},s=e.coordinates??null,a=e.selectors??null,c=!!(a&&a.length>0),u=$t(e),l=Gt(i,r,u),_=e.timestamp??"",p=e.duration_ms??0,d=e.variables_used??{},f=e.action_id??A(),g=A(),m=ut(_,p),h="",I="";if(i==="navigate")I=r.url??"",h=I;else if(i==="type"||i==="fill")h=r.text??"";else if(i==="press_key")h=r.key??"";else if(i==="wait")h=String(r.ms??r.timeout_ms??"");else if(i==="evaluate_js")h=r.script??"";else if(i==="upload_files"){let $=N(r);$&&(h=O($.name))}else i==="analyze"&&o==="SET_VARIABLE"&&(h=e.output_value??"");let E="";i==="go_back"?E="back":i==="go_forward"&&(E="forward");let b=e.action_instruction??"",v=F(h)||F(I)||F(b),x=Ft(e,o,d);return{operation_id:f,instruction_id:g,instruction:b,intent:b,operation_start:_,operation_end:m,status:e.status??"",command:o,name:"",target:"",value:h,message:"",operation_dict:"",frame:qt(e.frame_info),surface:typeof r.surface=="string"?r.surface:"",frame_path:typeof r.frame_path=="string"?r.frame_path:"",grounded_by:typeof r.grounded_by=="string"?r.grounded_by:"",error_message:e.error??"",code_snippet:"",sub_instruction_obj:JSON.stringify(x),test_id:"",test_version:"",action:"",string_to_float:!1,feedback_msg:"",time_taken:"",create_time_stamp:"",update_time_stamp:"",locator_variable:"",locator_variable_name:"",image_url:t?`${t}/test_screenshots/untagged_screenshot/${f}.${n?.get(f)??"png"}`:"",alternative_xpaths:[],attribute:"",value_description:"",url:I,navigation_direction:E,tagified_image_url:"",query_variable_name:e.output_variable??"",query_variable_value:e.output_value??"",query_variable_type:"",expected_value:"",queried_value:"",operator:"",assertion_status:o==="ASSERTION"?Bt(r):"",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(r.tab_index??""),tab_identifier:String(r.tab_identifier??""),scroll_value:r.amount??1,scroll_direction:r.direction??"",mi_scroll_payload:{},sleep_duration:0,app_id:"",manual_interaction_tag:"",string_to_float_list:[],js_snippet:i==="evaluate_js"?r.script??"":"",code_error:"",hide:v,dismiss_dialog:!1,use_v2_mobile_tagging:u,multiple_inputs:!1,dialog_action:"",dialog_type:"",is_coordinates_used_for_interaction:s!==null&&!c,element_coordinates_ratio:[],element_bounds_ratio:[],x_coord:c?null:s?.x??null,y_coord:c?null:s?.y??null,target_x_coord:r.target_x??null,target_y_coord:r.target_y??null,source_description:r.source_description??null,target_description:r.target_description??null,use_coordinates:s!==null&&!c,kaneaiMobileTaggingImageLimit:1,clicks_order_code:"se_js_ac",selector:c?_t(a,u):"",selector_target:l.selector_target,math_result_variable_name:"",math_result_variable_value:"",expression_tree:o==="ASSERTION"?Mt(r):r.expression_tree??{},assertion_tree:o==="ASSERTION"?L(r):r.assertion_tree??{},assertion_tree_simplified:{},network_throttle:{},is_mobile_offline:!1,autoheal:!1,reprobe:e.reprobe??!1,click_modifier:(r.click_count??1)>=2?{kind:"multi_click",frequency:r.click_count}:null,db_query:"",db_details:{},db_query_decoded:"",is_global_variable:!1,is_global_variable_persist:!1,global_variable_id:"",wait_for_element_timeout:0,failure_condition:o==="ASSERTION"?"Fail test immediately":"",screenshot_command:"",smartui_contents:{},smartui_results:{},result_type:"",result_hint:"",drag_offset:{},drag_displacement:l.drag_displacement,hold_duration_ms:l.hold_duration_ms,move_duration_ms:l.move_duration_ms,hold_at_destination_ms:l.hold_at_destination_ms,start_coordinates:r.source_coordinates?{x:r.source_coordinates[0],y:r.source_coordinates[1]}:{},end_coordinates:r.target_coordinates?{x:r.target_coordinates[0],y:r.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:Vt(e,t,f,n),reasoning:i==="analyze"?r.query??"":e.intent??e.action_instruction??""}}function it(e,t){let n=e.action_type,i=ct(n,e),o=e.timestamp??"",r=e.duration_ms??0,s=ut(o,r),a=i==="ASSERTION"||i==="MATHEMATICAL_OPERATION";return{instruction_id:t.instruction_id,instruction_class:a?"non_driver_action":"driver_action",module_id:"",instruction:e.action_instruction??"",command:i,error:null,parent_instruction_id:"",classification_layer_resp:i==="ASSERTION"?zt(e):[],classification_error:{},operations:[t],status:e.status??"",start_timestamp:o,end_timestamp:s,type:"agent_generated",tags:[],html_paths:[],optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,content_type:n==="api"?"api":n==="analyze"&&e.action_params?.analyzer_type==="api_response"?"api_calls_query":n==="analyze"&&e.action_params?.analyzer_type?.startsWith("devtool_")?e.action_params.analyzer_type.replace("devtool_","devtools_"):"instruction",js_snippet:n==="evaluate_js"?e.action_params?.script??"":"",user_variables:n==="api"?Ut(e):"[]",api_data:n==="api"?{request:e.action_params?.api_data?.request??{},response:lt(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 Kt(e,t=[]){let n=e.action_params??{},i=n.branches??[],o=n.winning_index??-1,r=n.sub_results??[],s={};for(let c of r){let u=c.sub_results;if(u)for(let l of u){let _=l.store_key;_&&(s[_]=l)}}let a=i.map((c,u)=>{let l=u===o,_=(c.sub_checks??[]).map(p=>{let d=s[p.store_key];return{description:p.description,store_key:p.store_key,expected_value:p.expected_value,stored_value:d?.extracted_value??p.stored_value,operator:p.operator??d?.operator??"equals",transforms:p.transforms??d?.transforms??[]}});if(_.length===0&&c.condition&&r.length>0){let d=r.find(f=>f.branch_index===u)?.sub_results??[];d.length>0&&(_=d.map(f=>({description:f.description??c.condition,store_key:f.store_key??"",expected_value:f.expected??"true",stored_value:f.extracted_value??void 0,operator:f.operator??"equals",transforms:f.transforms??[]})))}return{branch_index:u,condition:c.condition??null,branch_type:c.branch_type??"sub_objective",passed:l,sub_objective:null,custom_event:c.custom_event??null,children:l?t:[],sub_checks:c.condition?_:[],composite_operator:c.composite_operator??"and"}});return{content_type:"conditional_block",instruction_id:`if_else_${A().slice(0,8)}`,instruction:e.action_instruction??"",instruction_class:"driver_action",command:"",status:e.status??"success",resolved_branch_index:o,branches:a,generative_id:"",generative_objective:"",variables_used:{},classification_layer_resp:[],classification_error:{},used_variables:[],user_variables:"[]",module_id:"",module_execution_index:0,module_version:"",plan_id:"",optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,error:null,error_message:"",error_code:"",reason:"",start_timestamp:e.timestamp??"",end_timestamp:"",type:"agent_generated",hook:null,hook_type:null,evaluation_context:{},query_variables:{}}}function pt(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 B(e,t="",n,i){let o=[],r=0;for(;r<e.length;){let s=e[r],a=s.action_type;if(!i?.keepFailedActions&&s.status==="error"&&a!=="assert"&&a!=="if_else"&&a!=="child_agent_start"&&a!=="child_agent_end"&&!(s.until_condition&&!s.error)){r+=1;continue}if(a==="analyze"&&(!at[s.action_params?.analyzer_type??""]||s.action_params?.analyzer_type==="textual_visual"&&s.action_params?.code)){r+=1;continue}if(a==="child_agent_start"){let c=s.action_params?.child_id??"",u=s.action_params?.objective??"",l=[];r+=1;let _=1,p="error",d;for(;r<e.length&&_>0;){let v=e[r],x=v.action_type;if(x==="child_agent_start")_+=1;else if(x==="child_agent_end"&&(_-=1,_===0)){p=v.status??"success",d=v,r+=1;break}_>0&&l.push(v),r+=1}let f=B(l,t,n);pt(f,c,u);let g=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,E=d?.action_params?.one_liner??null,b=p==="error";o.push({content_type:"generative_block",instruction_id:`generative_block_${c}`,generative_id:c,objective:u,status:p,children:f,error_message:b?h??null:null,error_code:b?m??null:null,result_code:g??null,bifurcation_context:[],approach_reason:st(I),one_liner:E??null});continue}else if(a==="child_agent_end"){r+=1;continue}else if(a==="if_else"){r+=1;let c=[];for(;r<e.length&&e[r].action_type==="child_agent_start";){let u=e[r],l=u.action_params?.child_id??"",_=u.action_params?.objective??"",p=[];r+=1;let d=1,f="error";for(;r<e.length&&d>0;){let m=e[r];if(m.action_type==="child_agent_start")d+=1;else if(m.action_type==="child_agent_end"&&(d-=1,d===0)){f=m.status??"success",r+=1;break}d>0&&p.push(m),r+=1}let g=B(p,t,n);c.push(...g)}o.push(Kt(s,c));continue}else if(a==="query_tool"){r+=1;continue}else if(s.until_condition){let c=rt(s,t,n),u=it(s,c),l=typeof s.until_condition_met=="boolean"?s.until_condition_met:s.status==="success";o.push({content_type:"until_block",instruction_id:`until_${A().slice(0,8)}`,condition:s.until_condition,max_retries:s.until_max_retries??10,settle_ms:s.until_settle_ms??500,current_count:0,condition_met:l,children:[u],generative_id:"",generative_objective:"",variables_used:{},status:s.status??"success"})}else{let c=rt(s,t,n),u=it(s,c);o.push(u)}r+=1}return o}function P(e,t="",n,i){let o=[],r=[],s=i?.passthrough,a=s?D(s.authoredInstructions):null;for(let d of e){if(s&&a&&d.flatIndex!==void 0&&s.replayOnlyFlatIndices.has(d.flatIndex)){let b=U(d.records,a);if(b){for(let v of b)o.push(v),r.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 f=B(d.records,t,n,i);if(f.length===0)continue;let g=A().replace(/-/g,"");pt(f,g,d.objective);let m=f.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,E=m||I?"error":"success";o.push({content_type:"generative_block",instruction_id:`generative_block_${g}`,generative_id:g,objective:d.objective,status:E,children:f,error_message:E==="error"?d.errorMessage??null:null,error_code:E==="error"?d.reasonCode??null:null,result_code:d.resultCode??null,bifurcation_context:[],approach_reason:st(d.summary),one_liner:d.oneLiner??null}),r.push(d.flatIndex)}let c=o.map((d,f)=>({block:d,flat:r[f]})),u=i?.moduleSpans??[],l=i?.blockSpans??[],_=i?.authoredBlocks??[];u.length>0&&(c=gt(c,u,l,_));let p=ht(l,u);return p.length>0&&(c=M(c,p,_)),{instructions:c.map(d=>d.block)}}function gt(e,t,n,i){let o=[],r=a=>a===void 0?void 0:t.find(c=>a>=c.flatFrom&&a<=c.flatTo),s=0;for(;s<e.length;){let a=r(e[s].flat);if(!a){o.push(e[s]),s++;continue}let c=[];for(;s<e.length&&r(e[s].flat)===a;)c.push(e[s++]);let u=gt(c,a.children,n,i),l=ht(mt(n,a),a.children);l.length>0&&(u=M(u,l,i)),o.push({block:te(a,u.map(_=>_.block)),flat:c[0].flat})}return o}function ft(e,t){return e.flatFrom>=t.flatFrom&&e.flatTo<=t.flatTo}function mt(e,t){let n=[];for(let i of e)ft(i,t)?n.push(i):n.push(...mt(i.children,t));return n}function ht(e,t){let n=[],i=r=>{for(let s of r)n.push(s),i(s.children)};i(t);let o=r=>r.filter(s=>!n.some(a=>ft(s,a))).map(s=>({...s,children:o(s.children)}));return n.length>0?o(e):e}function M(e,t,n){let i=[...t].sort((u,l)=>u.flatFrom-l.flatFrom),o=[],r=(u,l)=>{o.push({block:Wt(u,l,n),flat:u.flatFrom})},s=(u,l)=>u!==void 0&&u>=l.flatFrom&&u<=l.flatTo,a=0,c=0;for(;c<e.length;){let u=e[c].flat;for(;a<i.length&&u!==void 0&&i[a].flatTo<u;)r(i[a++],[]);let l=a<i.length&&s(u,i[a])?i[a]:void 0;if(!l){o.push(e[c]),c++;continue}let _=[];for(;c<e.length&&s(e[c].flat,l);)_.push(e[c++]);r(l,_),a++}for(;a<i.length;)r(i[a++],[]);return o}function Ht(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 Jt=["children","instructions","branches","module_content","true_branch","false_branch"];function Xt(e,t){if(!t)return;let n=[...e];for(;n.length>0;){let i=n.pop();if(!i||typeof i!="object")continue;let o=i;if(o.instruction_id===t&&(o.content_type==="conditional_block"||o.content_type==="until_block"))return o;for(let r of Jt){let s=o[r];Array.isArray(s)?n.push(...s):s&&typeof s=="object"&&n.push(s)}}}function Yt(e,t,n){if(!e)return[];if(t==="while")return Array.isArray(e.children)?e.children:[];let o=(Array.isArray(e.branches)?e.branches:[])[n];return o&&Array.isArray(o.children)?o.children:[]}function Wt(e,t,n){let i=Xt(n,e.blockId),o=e.branches.map((r,s)=>{let a=t.filter(l=>l.flat!==void 0&&l.flat>=r.flatFrom&&l.flat<=r.flatTo);e.kind==="while"&&(a=Ht(a));let c=M(a,e.children,n).map(l=>l.block);if(c.length>0)return c;let u=Yt(i,e.kind,s);return u.length===0&&!r.taken&&console.warn(`[migrator] control-flow: branch ${s} of block ${e.blockId||e.instruction} did not run and no authored block matched \u2014 emitted empty`),u});return e.kind==="if"?Zt(e,o,i):Qt(e,o[0]??[],i)}function Zt(e,t,n){let i=Array.isArray(n?.branches)?n.branches:[],o=z(t.flat()),r=e.branches.map((s,a)=>{let c=i[a];return{branch_index:a,condition:s.branch_type==="else"?null:s.condition,branch_type:s.branch_type,passed:s.taken,sub_objective:null,custom_event:c?.custom_event??null,children:t[a],sub_checks:Array.isArray(c?.sub_checks)?c.sub_checks:[],composite_operator:c?.composite_operator??"and"}});return{content_type:"conditional_block",instruction_id:e.blockId||`if_else_${A().slice(0,8)}`,instruction:e.instruction,instruction_class:"driver_action",command:"",status:o?"error":"success",resolved_branch_index:e.branches.findIndex(s=>s.taken),branches:r,generative_id:"",generative_objective:"",variables_used:{},classification_layer_resp:[],classification_error:{},used_variables:[],user_variables:"[]",module_id:"",module_execution_index:0,module_version:"",plan_id:"",optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,error:null,error_message:o?.message??"",error_code:o?.code??"",reason:"",start_timestamp:"",end_timestamp:"",type:"agent_generated",hook:null,hook_type:null,evaluation_context:{},query_variables:{}}}function Qt(e,t,n){let i=e.whileCfg??{max_retries:5,settle_ms:500,on_exhaust:"fail",iterations:0,condition_met:!1},o=z(t),r=(s,a)=>n&&n[s]!==void 0?n[s]:a;return{content_type:"until_block",instruction_id:e.blockId||`until_${A().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:o?"error":"success",on_exhaust:r("on_exhaust",i.on_exhaust),mode:r("mode",""),check:r("check",""),conditions:r("conditions",[]),connectors:r("connectors",[]),sub_checks:r("sub_checks",[]),composite_operator:r("composite_operator","and")}}function z(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,o="error_code"in t?t.error_code:void 0;return{message:i??null,code:o??null}}}return null}function te(e,t){let n=e.meta,i=(u,l="")=>typeof n[u]=="string"?n[u]:l,o=(u,l=!1)=>typeof n[u]=="boolean"?n[u]:l,r=u=>Array.isArray(n[u])?n[u]:[],s=typeof n.module_version=="number"||typeof n.module_version=="string"?n.module_version:null,a=i("module_id"),c=z(t);return{content_type:Y,instruction_id:`module_block_${a}`,module_id:a,module_version:s,module_instance_id:A(),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:o("is_validated"),is_dirty:e.dirty,enrichment_id:i("enrichment_id"),tags:r("tags"),project_ids:r("project_ids"),link_to_all:o("link_to_all"),status:c?"error":"success",children:t,error_message:c?.message??null,error_code:c?.code??null,update_available:!1,update_info:{}}}function yt(e,t){let n;try{n=bt(e)}catch{return 0}let i=0,o=n.filter(r=>/^\d+$/.test(r)).sort((r,s)=>Number(r)-Number(s));for(let r of o){let s=S(e,r),a=S(s,"logs");if(!ee(a))continue;let c;try{c=bt(a)}catch{continue}let u=c.filter(p=>p.endsWith("-actions.ndjson")).sort((p,d)=>(parseInt(p,10)||0)-(parseInt(d,10)||0)),l=[];for(let p of u){let d=t.readActions(S(a,p));d.length&&l.push({objective:t.objective??"",records:d})}if(l.length===0)continue;let{instructions:_}=P(l,t.screenshotBaseUrl??"",t.extMap,{keepFailedActions:!0});if(_.length!==0)try{let p=S(s,"auteur");ne(p,{recursive:!0}),re(S(p,"execution.json"),JSON.stringify(t.buildBlob(_),null,2)),i++,t.log?.("info","EVIDENCE_ARCHIVED_ATTEMPT_BLOB","Derived nested attempt blob",{attempt:r,instructions:_.length})}catch(p){t.log?.("debug","EVIDENCE_ARCHIVED_ATTEMPT_BLOB_FAILED","Nested attempt blob derivation failed",{attempt:r,error:p instanceof Error?p.message:String(p)})}}return i}var Et=Rt(Pt(),1);import{createWriteStream as ie}from"fs";import{readFile as oe}from"fs/promises";import{join as se,basename as ae}from"path";import{tmpdir as ce}from"os";var ue=["**/screenshots/**","**/annotated/**","**/tcg/**","**/bifurcation/**"];async function It(e){let t=se(ce(),`${ae(e)}_artifacts.zip`);return new Promise((n,i)=>{let o=ie(t),r=(0,Et.default)("zip",{zlib:{level:6}});o.on("close",()=>n(t)),r.on("error",i),r.pipe(o),r.glob("**/*",{cwd:e,ignore:ue}),r.finalize()})}async function At(e){return oe(e)}async function _e(e,t){return kt(X(e,t))}function pe(e){return{key:"artifacts",content_type:"application/zip",filename:`${e}.evidence`}}var vt=class{config;controller;testId;constructor(t){this.config=t,this.controller=new K(t.controllerBaseUrl,t.auth),this.testId=t.testId}log(t,n,i,o){this.config.log?.(t,n,i,o)}async execute(){let{onProgress:t}=this.config;try{if(!this.testId)return this.log("error","PIPELINE_ABORT","No test_id available"),{success:!1,testId:null,error:"No test_id available"};let n=this.config.evidence,i=null;if(this.config.shouldUploadArtifacts!==!1){t("convert","running");let a=this.collectNdjsonPerRun(),c=a.reduce((g,m)=>g+m.records.length,0);this.log("info","PIPELINE_CONVERT","Collected NDJSON records",{total_records:c,run_groups:a.length});let u=this.loadReplayOnlyPassthrough(),{instructions:l}=a.length>0?P(a,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap,{moduleSpans:this.config.moduleSpans,...u?{passthrough:u}:{},...this.config.blockSpans?.length?{blockSpans:this.config.blockSpans,authoredBlocks:this.loadAuthoredBlocks()}:{}}):{instructions:[]};this.log("info","PIPELINE_CONVERT_INSTRUCTIONS","Auteur instructions produced",{count:l.length});let _=this.buildExecutionEnvelope(l),p=Buffer.from(JSON.stringify(_));this.log("info","PIPELINE_CONVERT_BLOB","Blob created",{size_kb:+(p.length/1024).toFixed(1)});let d=y(this.config.sessionDir,"execution.json");w(d,JSON.stringify(_,null,2)),this.log("info","PIPELINE_CONVERT_LOCAL_SAVE","Execution blob saved locally",{path:d});let f=n?.packTestDir??this.config.evidenceRead?.packTestDir;if(f){let g=y(f,"auteur");q(g,{recursive:!0}),w(y(g,"execution.json"),JSON.stringify(_,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack",{path:y(g,"execution.json")}),this.deriveArchivedAttemptBlobs(f)}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 g=null,m;try{g=await It(this.config.sessionDir),m=await At(g),this.log("info","PIPELINE_ZIP_DONE","Zip complete",{size_mb:+(m.length/1024/1024).toFixed(1),path:g}),t("zip","done",`${(m.length/1024/1024).toFixed(1)}MB`)}finally{g&&await de(g).catch(()=>{})}t("presign","running"),this.log("info","PIPELINE_PRESIGN_START","Requesting presigned URLs",{url:`${this.config.controllerBaseUrl}/upload/presign`,test_id:this.testId,session_id:this.config.sessionId});let h=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[{key:"artifacts",content_type:"application/zip",filename:`${this.config.sessionId}_artifacts.zip`},{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);this.log("info","PIPELINE_PRESIGN_OK","Presigned URLs received",{artifacts_url:h.urls.artifacts?.blob_url,blob_url:h.urls.blob?.blob_url}),t("presign","done"),t("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading artifacts and blob",{artifact_size_mb:+(m.length/1024/1024).toFixed(1),blob_size_kb:+(p.length/1024).toFixed(1)}),await Promise.all([k(h.urls.artifacts.upload_url,m,"application/zip"),k(h.urls.blob.upload_url,p,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),t("upload","done")}}else{let a=this.collectNdjsonPerRun(),c=this.loadReplayOnlyPassthrough(),{instructions:u}=a.length>0?P(a,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap,{keepFailedActions:!0,moduleSpans:this.config.moduleSpans,...c?{passthrough:c}:{},...this.config.blockSpans?.length?{blockSpans:this.config.blockSpans,authoredBlocks:this.loadAuthoredBlocks()}:{}}):{instructions:[]},l=this.buildExecutionEnvelope(u),_=y(this.config.sessionDir,"execution.json");w(_,JSON.stringify(l,null,2)),this.log("info","PIPELINE_LOCAL_SAVE","Execution blob saved locally (no upload)",{path:_});let p=this.config.evidence?.packTestDir??this.config.evidenceRead?.packTestDir;if(p){let d=y(p,"auteur");q(d,{recursive:!0});let f=this.readAuthoredExecution(),g=f?this.refreshReplayOnlyInPack(f,a,c):null;w(y(d,"execution.json"),g?.raw??JSON.stringify(l,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack (gated)",{path:y(d,"execution.json"),source:g?g.refreshed.length>0?"authored+replay_results":"authored":"run_envelope",...g&&g.refreshed.length>0?{refreshed_instruction_ids:g.refreshed}:{}}),this.deriveArchivedAttemptBlobs(p)}t("convert","skipped"),t("zip","skipped"),t("presign","skipped"),t("upload","skipped"),this.log("info","PIPELINE_UPLOAD_SKIPPED","Upload steps skipped (gate disabled)")}if(this.config.shouldReplaceLocalOutput&&this.config.onAtomicReplace){t("atomic_replace","running");try{await this.config.onAtomicReplace(),this.log("info","PIPELINE_ATOMIC_REPLACE_OK","Local output replaced"),t("atomic_replace","done")}catch(a){let c=a instanceof Error?a.message:String(a);throw this.log("error","PIPELINE_ATOMIC_REPLACE_FAILED","Atomic-replace failed",{error:c}),t("atomic_replace","failed",c),a}}else t("atomic_replace","skipped");let o,r;if(this.config.shouldCommit&&!this.config.isFirstRun&&this.config.onCommitLock){t("commit_lock","running");let a=await this.config.onCommitLock();if(a.ok)o=a.testcaseId||void 0,this.log("info","PIPELINE_COMMIT_LOCK_OK","Commit lock acquired",{testcase_id:o??"none",trigger:a.trigger??null,test_instance_id:a.testInstanceId??null}),t("commit_lock","done");else return this.log("error","PIPELINE_COMMIT_LOCK_FAILED","Commit lock failed",{reason:a.reason,message:a.message}),t("commit_lock","failed",`${a.reason??"unknown"}: ${a.message??""}`),{success:!1,testId:this.testId,error:`commit-lock failed: ${a.reason??"unknown"}`}}else t("commit_lock","skipped");if(this.config.isFirstRun&&!this.config.skipTmsFinalize){t("finalize","running"),this.log("info","PIPELINE_FINALIZE_START","Finalizing test (first-run)",{test_id:this.testId,commit_id:this.config.commitId});let a=new H(this.config.tmsBaseUrl,this.config.tmsUsername,this.config.tmsAccessKey),c=this.config.runObjectives&&this.config.runObjectives.length>0?this.config.runObjectives:[this.config.firstObjective];if(o=(await a.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:c})).testcase_id||void 0,this.log("info","PIPELINE_FINALIZE_OK","Test finalized",{testcase_id:o??"none"}),this.config.onFinalizeSuccess)try{await this.config.onFinalizeSuccess(o)}catch(l){this.log("warn","PIPELINE_FINALIZE_META_FAILED","Meta-rewrite after endTest failed",{error:String(l)})}t("finalize","done")}else t("finalize","skipped"),this.log("info","PIPELINE_FINALIZE_SKIPPED","Finalize skipped (evolve flow or first-run disabled)");if(o&&this.config.shareApiBaseUrl)try{r=await this.generateShareLink(o),this.log("info","PIPELINE_SHARE_OK","Share link generated",{share_id:r})}catch(a){this.log("warn","PIPELINE_SHARE_FAILED","Share link failed",{error:String(a)})}if(n&&i){let a=null;t("zip","running");try{await n.sealFn({testcaseId:o,shareId:r}),a=n.sealedPackPath?await kt(n.sealedPackPath):await _e(n.executionId,n.cwd),this.log("info","PIPELINE_EVIDENCE_SEALED","Evidence pack sealed",{execution_id:n.executionId}),this.log("info","PIPELINE_PACK_READ","Sealed pack read",{size_mb:+(a.length/1024/1024).toFixed(1)})}catch(c){let u=c instanceof Error?c.message:String(c);this.log("warn","PIPELINE_EVIDENCE_UPLOAD_SKIPPED","Evidence seal/read failed \u2014 uploading blob only",{execution_id:n.executionId,error:u})}if(a){t("zip","done",`${(a.length/1024/1024).toFixed(1)}MB`),t("presign","running");let c=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[pe(n.executionId),{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);this.log("info","PIPELINE_PRESIGN_OK","Presigned URLs received",{artifacts_url:c.urls.artifacts?.blob_url,blob_url:c.urls.blob?.blob_url}),t("presign","done"),t("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading pack and blob",{artifact_size_mb:+(a.length/1024/1024).toFixed(1),blob_size_kb:+(i.length/1024).toFixed(1)}),await Promise.all([k(c.urls.artifacts.upload_url,a,"application/zip"),k(c.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 c=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);t("presign","done"),t("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading blob only (evidence skipped)",{blob_size_kb:+(i.length/1024).toFixed(1)}),await k(c.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&&o){let a=!1;try{await this.triggerCodeExport(o),this.log("info","PIPELINE_CODE_EXPORT_START","Code export triggered"),a=!0}catch(c){let u=c instanceof Error?c.message:String(c);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export trigger failed; skipping poll",{error:u}),t("code_export","failed",`trigger failed: ${u}`)}if(a){t("code_export","running","Waiting for code generation\u2026");try{s=await this.pollAndDownloadCode(o,t),this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:s}),t("code_export","done",s)}catch(c){let u=c instanceof Error?c.message:String(c);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:u}),t("code_export","failed",u)}}}else t("code_export","skipped");return this.log("info","PIPELINE_COMPLETE","Pipeline complete"),{success:!0,testId:this.testId,testcaseId:o,shareId:r,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,o=!1;try{await this.triggerCodeExport(t),this.log("info","PIPELINE_CODE_EXPORT_TRIGGER","Code export triggered",{testcase_id:t}),o=!0}catch(r){let s=r instanceof Error?r.message:String(r);this.log("error","PIPELINE_CODE_EXPORT_TRIGGER_FAILED","Code export trigger failed; skipping poll",{error:s}),i("code_export","failed",`trigger failed: ${s}`)}if(o){i("code_export","running","Waiting for code generation\u2026");try{let r=await this.pollAndDownloadCode(t,i);return this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:r}),i("code_export","done",r),r}catch(r){let s=r instanceof Error?r.message:String(r);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:s}),i("code_export","failed",s);return}}}deriveArchivedAttemptBlobs(t){try{let n=yt(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,o,r,s)=>this.log(i,o,r,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??[],o=this.config.evidence??this.config.evidenceRead;for(let r=0;r<this.config.runDirs.length;r++){let s=this.config.runDirs[r],a=n[r]||this.config.firstObjective,c=i[r],u=o?this.readNdjsonFromFile(y(o.packTestDir,"logs",`${o.runIndices?.[r]??r}-actions.ndjson`)):this.readNdjsonFromDir(s);if(u.length>0){let l=o?.runIndices?.[r]??r,_=this.config.runFlatIndex?.[l];t.push({objective:a,records:u,..._!==void 0?{flatIndex:_}:{},resultCode:c?.resultCode,reasonCode:c?.reasonCode,errorMessage:c?.errorMessage,summary:c?.summary,oneLiner:c?.oneLiner})}}if(t.length===0){let r=y(this.config.sessionDir,"runs");if(V(r))try{let a=le(r,{withFileTypes:!0}).filter(c=>c.isDirectory()).map(c=>c.name).sort();for(let c of a){let u=y(r,c),l=this.readNdjsonFromDir(u);l.length>0&&t.push({objective:this.config.firstObjective,records:l})}}catch{}}return t}readNdjsonFromDir(t){let n=[y(t,"run-test","actions.ndjson"),y(t,"actions.ndjson")];for(let i of n)if(V(i))return this.readNdjsonFromFile(i);return[]}readNdjsonFromFile(t){let n=[];if(!V(t))return n;this.log("debug","PIPELINE_COLLECT_READ","Reading NDJSON file",{path:t});let i=T(t,"utf-8");for(let o of i.split(`
5
- `)){let r=o.trim();if(r)try{n.push(JSON.parse(r))}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})},o=!!this.config.authResolver;this.log("debug","PIPELINE_SHARE_AUTH","Share link auth config",{resolver:o,fallback_auth_type:typeof this.config.auth=="string"?"bearer":"basic",tms_user:this.config.tmsUsername});let r=o?await this.config.authResolver.fetch(n,i):await R(n,{...i,headers:{...i.headers,Authorization:this.buildAuthHeader()}});if(!r.ok)throw new Error(`Share link API failed: ${r.status} ${await r.text()}`);let s=await r.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}=W({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:t,codeExport:this.config.codeExport,mobile:this.config.mobile});this.log("info","PIPELINE_CODE_EXPORT_POST","Triggering code export",{url:n});let o={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(i)},r=this.config.authResolver?await this.config.authResolver.fetch(n,o):await R(n,{...o,headers:{...o.headers,Authorization:this.buildAuthHeader()}});if(!r.ok)throw new Error(`Code export failed: ${r.status} ${await r.text()}`)}async pollAndDownloadCode(t,n){let i=Z({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:t}),o=this.config.exitTimeoutMs??3e5,r=5e3,s=Date.now()+o;this.log("info","PIPELINE_CODE_EXPORT_POLL","Polling for code export",{url:i,timeout_ms:o});let a=(c,u)=>this.config.authResolver?this.config.authResolver.fetch(c,u):R(c,{...u,headers:{...u?.headers,Authorization:this.buildAuthHeader()}});for(;Date.now()<s;){let c=await a(i,{method:"GET",headers:{Accept:"application/json"}});if(!c.ok){let d=await c.text().catch(()=>"");throw this.log("warn","PIPELINE_CODE_EXPORT_POLL_FAILED","Code export poll non-200; skipping",{status:c.status,body:d.slice(0,200)}),new Error(`code export poll skipped: HTTP ${c.status}`)}let l=(await c.json()).data?.find(d=>d.code_name==="kane-cli-trigger");if(!l){this.log("debug","PIPELINE_CODE_EXPORT_WAITING","No kane-cli-trigger entry yet"),n("code_export","running","Waiting for code generation\u2026"),await this.sleep(r);continue}let _=l.status.toLowerCase();if(_==="in progress"||_==="in_progress"||_==="pending"){this.log("debug","PIPELINE_CODE_EXPORT_IN_PROGRESS","Code export in progress",{status:l.status}),n("code_export","running","Generating code\u2026"),await this.sleep(r);continue}if(!l.url||l.url.length===0)throw new Error(`Code export status=${l.status} but no files returned`);let p=this.config.codeExportDir??y(this.config.sessionDir,"code-export");q(p,{recursive:!0}),this.log("info","PIPELINE_CODE_EXPORT_DOWNLOAD","Downloading code files",{file_count:l.url.length,dir:p}),n("code_export","running",`Downloading ${l.url.length} files\u2026`);for(let d of l.url){let f=y(p,d.file_name),g=await R(d.file_url);if(!g.ok){this.log("warn","PIPELINE_CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:d.file_name,status:g.status});continue}let m=await g.text();w(f,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}`:G(this.config.auth.username,this.config.auth.accessKey)}readAuthoredExecution(){let t=this.config.authoredExecutionPath;if(!t)return null;try{let n=T(t,"utf8");return JSON.parse(n),n}catch{return this.log("warn","PIPELINE_AUTHORED_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 pack gets this run's envelope",{path:t}),null}}refreshReplayOnlyInPack(t,n,i){if(!i)return{raw:t,refreshed:[]};let o=et(n,i);if(o.length===0)return{raw:t,refreshed:[]};let r=JSON.parse(t);if(!Array.isArray(r.instructions))return{raw:t,refreshed:[]};let s=nt(r.instructions,o);return s.length===0?{raw:t,refreshed:s}:{raw:JSON.stringify(r,null,2),refreshed:s}}loadAuthoredBlocks(){let t=this.config.blockAuthoredExecutionPath;if(!t)return[];try{let n=JSON.parse(T(t,"utf8"));return Array.isArray(n.instructions)?n.instructions:[]}catch(n){return this.log("warn","PIPELINE_AUTHORED_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 branches that did not run this time upload empty",{path:t,error:n instanceof Error?n.message:String(n)}),[]}}loadReplayOnlyPassthrough(){let t=this.config.replayOnlyPassthrough;if(!(!t||t.flatIndices.length===0))try{let n=JSON.parse(T(t.authoredExecutionPath,"utf8"));if(!Array.isArray(n.instructions))throw new Error("no instructions array");return{authoredInstructions:n.instructions,replayOnlyFlatIndices:new Set(t.flatIndices)}}catch(n){this.log("warn","PIPELINE_PASSTHROUGH_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 replay-only steps convert from this run's records",{path:t.authoredExecutionPath,flat_indices:t.flatIndices,error:n instanceof Error?n.message:String(n)});return}}buildExecutionEnvelope(t){let n=this.config.runStatuses.every(u=>u==="passed")?"success":"error",i=this.config.variableIds??{},o=[];if(this.config.variables)for(let[u,l]of Object.entries(this.config.variables)){if(l.secret||J(l))continue;let _=u.startsWith("global.")?u.slice(7):u;o.push({id:i[_]??0,name:_,value:l.value,session_value:l.value,is_persist:!1,environment_id:0,environment_name:"No Env"})}let r=[],s=u=>{let l=r.find(_=>_.name===u.name);l?l.value=u.value:r.push(u)},a=[],c=new Set;for(let u of this.collectNdjsonPerRun())for(let l of u.records)if(l.output_variable&&l.output_value!=null&&s({name:l.output_variable,value:String(l.output_value),value_type:"test_level",variable_description:"ANALYZE result"}),l.action_type==="upload_files"){let _=N(l.action_params);if(_){let p=_.media_id||_.media_url;if(!c.has(p)){c.add(p),a.push({media_url:_.media_url,media_id:_.media_id,name:_.name,type:_.type});let d=O(_.name);s({name:ot(_.name),value:d,value_type:"string",variable_description:`variable for ${d}`})}}}return{test_id:this.testId,version:"v4",auto_heal_version:this.config.apMode==="v2"?"AH2":"",session_id:this.config.sessionId,org_id:String(this.config.orgId),user_id:String(this.config.userId),url:this.config.firstUrl??"",start_timestamp:this.config.startedAt,end_timestamp:this.config.endedAt,status:n,commit_id:this.config.commitId,instructions:t,modules:[],uploaded_files:a,test_params:this.config.testParams??[],test_level_variables:JSON.stringify(r),test_global_variables:o,max_network_wait:0,wait_buffer:0,network_throttle:{},secrets:this.config.secrets??[],totp:[],environment_id:this.config.environmentId??0,environment:"",mobile_browser:!1,native_popups:[],smartui:{},module_index:0}}};export{_e as a,pe as b,vt as c};