@testmuai/kane-cli 0.9.0 → 0.10.0-rc.3
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.
- package/dist/ChatSurface-6NZGMNHL.js +2 -0
- package/dist/ChromeProfilePicker-M4WXOB5O.js +2 -0
- package/dist/CliFeedbackPrompt-6MJA7DF6.js +2 -0
- package/dist/CliUploadProgress-6NLS7XHH.js +2 -0
- package/dist/ConfigView-O4WKZ5PU.js +2 -0
- package/dist/EvidenceViewOffer-WIEWCZUP.js +2 -0
- package/dist/FolderPicker-AF7ZMV3M.js +2 -0
- package/dist/InfoBox-D7GGZJU4.js +2 -0
- package/dist/LinksBox-DXP66H3H.js +2 -0
- package/dist/ProfilesView-TWOY5PVC.js +2 -0
- package/dist/ProjectPicker-OBYHJJLU.js +2 -0
- package/dist/SaveSessionPrompt-7XSHS4NL.js +2 -0
- package/dist/ScrollbackTap-4SPXGFMU.js +2 -0
- package/dist/SingleShotApp-XQUDR36R.js +2 -0
- package/dist/SummaryBox-IA2KS6GT.js +2 -0
- package/dist/TestMdRunView-LS2QUFWR.js +2 -0
- package/dist/TestrunEvidenceTable-HNDVJDIF.js +2 -0
- package/dist/WhoamiView-SNL75TEF.js +2 -0
- package/dist/{agent-parse-2MLJOJTH.js → agent-parse-CAS45UKA.js} +1 -1
- package/dist/app-client-U2YYF65L.js +2 -0
- package/dist/app-download-UI4ABEIX.js +2 -0
- package/dist/assurance-job-FFSSS4XV.js +7 -0
- package/dist/auth-7Z54TMQQ.js +2 -0
- package/dist/{binary-LVHXED3O.js → binary-THPLXCOD.js} +1 -1
- package/dist/bind-4XWK3DG2.js +2 -0
- package/dist/bootstrap-6ACT4ALI.js +2 -0
- package/dist/bridge-T6QMYKED.js +2 -0
- package/dist/build-5ZN47FAT.js +2 -0
- package/dist/catalog-MYPS2BXY.js +2 -0
- package/dist/{changelog-N5AZHXOS.js → changelog-SU674BVE.js} +1 -1
- package/dist/chat-committer-ZCSRJEUB.js +2 -0
- package/dist/chat-controller-XINCDH6Z.js +2 -0
- package/dist/child-G2GCW73X.js +2 -0
- package/dist/chunk-22PIMG52.js +2 -0
- package/dist/chunk-2DYHAP4E.js +2 -0
- package/dist/chunk-2TVPA3LL.js +2 -0
- package/dist/{chunk-FMUV6UCX.js → chunk-2XW33VOK.js} +1 -1
- package/dist/chunk-33DWJV67.js +235 -0
- package/dist/chunk-34R7BNZ2.js +2 -0
- package/dist/chunk-35ECWCCK.js +2 -0
- package/dist/{chunk-OHOJSADN.js → chunk-36N3EHW5.js} +1 -1
- package/dist/chunk-3BSYOCSW.js +3 -0
- package/dist/chunk-3E4ZO73O.js +6 -0
- package/dist/chunk-3F5FMH76.js +2 -0
- package/dist/chunk-3G2LSTK5.js +2 -0
- package/dist/chunk-3GXN6VF6.js +2 -0
- package/dist/chunk-3JLEDSG5.js +4 -0
- package/dist/chunk-3OQW2GTA.js +2 -0
- package/dist/chunk-3QICDXY5.js +5 -0
- package/dist/chunk-3RJHXOZH.js +3 -0
- package/dist/{chunk-Q5RDCSYM.js → chunk-3YTCKCBG.js} +1 -1
- package/dist/chunk-42PALMW2.js +4 -0
- package/dist/chunk-44B6THYK.js +2 -0
- package/dist/chunk-457Y5TEC.js +19 -0
- package/dist/chunk-47WQBG5I.js +6 -0
- package/dist/chunk-4I7YN6YY.js +3 -0
- package/dist/chunk-4IEQNX7F.js +2 -0
- package/dist/chunk-4LTHDJ3D.js +2 -0
- package/dist/chunk-4QFTHUJA.js +34 -0
- package/dist/chunk-4QTH7VYE.js +2 -0
- package/dist/chunk-4YW767UV.js +47 -0
- package/dist/chunk-54XA5MZH.js +2 -0
- package/dist/chunk-5AKJPYUW.js +11 -0
- package/dist/{chunk-AKE2CTV6.js → chunk-5D7ENQTQ.js} +1 -1
- package/dist/chunk-63EKRZKI.js +2 -0
- package/dist/{chunk-EHN5HTUD.js → chunk-65VANXOF.js} +51 -51
- package/dist/{chunk-J3BGYSMD.js → chunk-6DZX5HLZ.js} +8 -8
- package/dist/{chunk-YBAVDT3G.js → chunk-6EB5VRAN.js} +1 -1
- package/dist/chunk-6NFOH4AC.js +4 -0
- package/dist/chunk-6PIIUAZF.js +3 -0
- package/dist/chunk-6UVIY56J.js +2 -0
- package/dist/chunk-72KYMWQ5.js +2 -0
- package/dist/chunk-72RC7JSA.js +21 -0
- package/dist/chunk-734ORT6O.js +4 -0
- package/dist/chunk-77ZZQJLX.js +2 -0
- package/dist/chunk-7AET4JKQ.js +2 -0
- package/dist/chunk-7DFBOVUB.js +2 -0
- package/dist/chunk-7HMSMAUG.js +29 -0
- package/dist/chunk-7HO4NX5W.js +1 -0
- package/dist/chunk-7KX2BHKG.js +2 -0
- package/dist/{chunk-ULGZPRKU.js → chunk-7NCJMWFX.js} +1 -1
- package/dist/chunk-7NPTL66J.js +2 -0
- package/dist/chunk-7RWP4Y3H.js +2 -0
- package/dist/{chunk-PCKIANML.js → chunk-7SY34IIL.js} +1 -1
- package/dist/chunk-7V4BQSSV.js +2 -0
- package/dist/chunk-7XBNMOH4.js +6 -0
- package/dist/{chunk-SOCHN2PY.js → chunk-7YT4TTKL.js} +1 -1
- package/dist/{chunk-C25M2J5Q.js → chunk-ACMBMZDQ.js} +1 -1
- package/dist/chunk-AEWNWAXW.js +18 -0
- package/dist/chunk-AQ2OG2EF.js +2 -0
- package/dist/chunk-AUJSC7PU.js +4 -0
- package/dist/chunk-AVI5H4UM.js +13 -0
- package/dist/chunk-AVSMXDTX.js +2 -0
- package/dist/chunk-AZLNLHUA.js +4 -0
- package/dist/{chunk-HGFWIBVF.js → chunk-B7ZX5HEN.js} +5 -5
- package/dist/{chunk-66MOZKD2.js → chunk-BSRSXYDZ.js} +1 -1
- package/dist/chunk-BWXLZS5O.js +2 -0
- package/dist/chunk-BY65QAAN.js +4 -0
- package/dist/chunk-C2RUDJ46.js +2 -0
- package/dist/chunk-C5Z7MQE6.js +2 -0
- package/dist/{chunk-WDMUPK6I.js → chunk-C62QWG4B.js} +1 -1
- package/dist/chunk-C6HI6Y3S.js +2 -0
- package/dist/chunk-CB4ARIHR.js +2 -0
- package/dist/{chunk-7WXMV3O3.js → chunk-CCP4X75B.js} +1 -1
- package/dist/chunk-CGITGJ3I.js +4 -0
- package/dist/chunk-CM4CHYSN.js +2 -0
- package/dist/{chunk-ZXY4P76I.js → chunk-CUXY6KQ2.js} +1 -1
- package/dist/chunk-D36V5OX6.js +2 -0
- package/dist/chunk-D756UWY2.js +6 -0
- package/dist/chunk-D7TKE7LK.js +2 -0
- package/dist/{chunk-UWXDURAB.js → chunk-D7U2M26S.js} +1 -1
- package/dist/chunk-DBMW3VUN.js +4 -0
- package/dist/chunk-DDZLCAEO.js +5 -0
- package/dist/chunk-DJC7NTLA.js +3 -0
- package/dist/chunk-DPGOAFKF.js +2 -0
- package/dist/chunk-DREQ3RAA.js +2 -0
- package/dist/chunk-DTUPEKEO.js +2 -0
- package/dist/chunk-DZOYYWOW.js +2 -0
- package/dist/chunk-E6KSRQXL.js +8 -0
- package/dist/chunk-EBPRPNSA.js +2 -0
- package/dist/chunk-ECPFI75W.js +5 -0
- package/dist/chunk-EECDDDSB.js +3 -0
- package/dist/chunk-EF47KRUK.js +2 -0
- package/dist/chunk-ETZMFRD6.js +2 -0
- package/dist/chunk-EZN7CF45.js +4 -0
- package/dist/{chunk-CNUCP6DK.js → chunk-F22K3RRX.js} +1 -1
- package/dist/{chunk-WRSIKZ2V.js → chunk-F5NHG7VB.js} +1 -1
- package/dist/{chunk-DHJSM5DT.js → chunk-FCD3NYOM.js} +1 -1
- package/dist/chunk-FIP5L6LV.js +9 -0
- package/dist/chunk-FOJHSG5M.js +6 -0
- package/dist/chunk-FSYOTRMC.js +2 -0
- package/dist/chunk-FWDUVFS6.js +26 -0
- package/dist/chunk-FWUPJORV.js +6 -0
- package/dist/chunk-GFLB2SHW.js +2 -0
- package/dist/chunk-GMTHZUZ3.js +2 -0
- package/dist/chunk-GQRU3B54.js +1397 -0
- package/dist/chunk-GRURFGBP.js +2 -0
- package/dist/chunk-GXKY5A46.js +9 -0
- package/dist/chunk-HAW5WEKT.js +13 -0
- package/dist/chunk-HCJ2N3XB.js +12 -0
- package/dist/chunk-HHW6MRU3.js +6 -0
- package/dist/chunk-HIUAUZNL.js +2 -0
- package/dist/chunk-HJLMH7ZM.js +2 -0
- package/dist/{chunk-YWYORBY3.js → chunk-HJMCXSUJ.js} +1 -1
- package/dist/chunk-HK62JVQM.js +3 -0
- package/dist/{chunk-5GUD3CIH.js → chunk-HQ2E2XCU.js} +1 -1
- package/dist/chunk-I2MC6VVX.js +2 -0
- package/dist/chunk-I4RVVBG3.js +10 -0
- package/dist/chunk-I4WXALQR.js +2 -0
- package/dist/chunk-ICLUC44J.js +2 -0
- package/dist/{chunk-6HU5M2DS.js → chunk-IGEAET7M.js} +1 -1
- package/dist/{chunk-GCISXCDU.js → chunk-IINZZ4BZ.js} +1 -1
- package/dist/chunk-IJ2AHSWW.js +2 -0
- package/dist/{chunk-CSNJPD2J.js → chunk-IUQOG7Z5.js} +3 -3
- package/dist/chunk-IZ65ZPWY.js +3 -0
- package/dist/chunk-JGRXMTME.js +15 -0
- package/dist/{chunk-NBXYL2JT.js → chunk-JIRNI5TB.js} +7 -7
- package/dist/chunk-JNSWKGTB.js +2 -0
- package/dist/chunk-JZP3Y4ZM.js +2 -0
- package/dist/chunk-KF4DKXSS.js +2 -0
- package/dist/chunk-KGNE5CIM.js +2 -0
- package/dist/chunk-KM3YCIDV.js +3 -0
- package/dist/{chunk-HAYV4D2I.js → chunk-KODJVOCN.js} +1 -1
- package/dist/chunk-KU3YHPWZ.js +2 -0
- package/dist/{chunk-M3UAZTDK.js → chunk-KXHJMAZU.js} +2 -2
- package/dist/chunk-L5DALV5N.js +2 -0
- package/dist/chunk-LAOTVZHV.js +6 -0
- package/dist/chunk-LCSJ7GOG.js +2 -0
- package/dist/{chunk-DWMESHFI.js → chunk-LIGTP3A3.js} +1 -1
- package/dist/chunk-LKQFG4RW.js +5 -0
- package/dist/{chunk-EBLXHOE3.js → chunk-LQQNPMOD.js} +1 -1
- package/dist/chunk-LSDJOVWW.js +6 -0
- package/dist/{chunk-C6S2RPZA.js → chunk-LUR7JFPP.js} +1 -1
- package/dist/chunk-LUZBGTYB.js +2 -0
- package/dist/chunk-LX2I4JEH.js +2 -0
- package/dist/{chunk-7GAHJZLH.js → chunk-M43WH5DQ.js} +1 -1
- package/dist/chunk-MEKPGQAM.js +21 -0
- package/dist/chunk-MNBGG4H3.js +16 -0
- package/dist/chunk-MYVKUJGS.js +2 -0
- package/dist/chunk-MYZHOBS4.js +2 -0
- package/dist/chunk-NC7D7GOM.js +21 -0
- package/dist/chunk-NIVFEACM.js +2 -0
- package/dist/chunk-NLZZLANH.js +4 -0
- package/dist/{chunk-XT7XA4DN.js → chunk-NXAJBSIF.js} +1 -1
- package/dist/chunk-NXRF7FFS.js +2 -0
- package/dist/chunk-NZ6AV2TA.js +4 -0
- package/dist/chunk-O3HHTKZ5.js +6 -0
- package/dist/chunk-OCDBTAYS.js +12 -0
- package/dist/chunk-OFSDB7B4.js +3 -0
- package/dist/{chunk-Q5CINJYL.js → chunk-OGFU4YY4.js} +1 -1
- package/dist/chunk-OJ33Q6DU.js +2 -0
- package/dist/chunk-P2ZQDQDB.js +2 -0
- package/dist/{chunk-KXEE6VCA.js → chunk-P3JXJ4BW.js} +1 -1
- package/dist/chunk-PAWQ4AKN.js +2 -0
- package/dist/chunk-PUVMC4PX.js +26 -0
- package/dist/{chunk-SEEEGDVK.js → chunk-PZA3BSOE.js} +1 -1
- package/dist/chunk-Q3C6NDGI.js +2 -0
- package/dist/chunk-QBYENBMB.js +2 -0
- package/dist/chunk-QDFY5GGO.js +5 -0
- package/dist/chunk-QDXKEOKI.js +16 -0
- package/dist/{chunk-6VY62QC2.js → chunk-QENCC2ZS.js} +1 -1
- package/dist/chunk-QI5RZ7LL.js +2 -0
- package/dist/chunk-QXQ7KVEN.js +2 -0
- package/dist/chunk-R4JUKTDO.js +2 -0
- package/dist/chunk-R7KXAISS.js +12 -0
- package/dist/chunk-RDP7GWSY.js +2 -0
- package/dist/chunk-REKHAN53.js +5 -0
- package/dist/chunk-RF37IJNN.js +2 -0
- package/dist/{chunk-KWEOLPBJ.js → chunk-RFEON5GN.js} +1 -1
- package/dist/chunk-RHGW7B5Q.js +2 -0
- package/dist/chunk-RPRXRKKR.js +2 -0
- package/dist/{chunk-EOA6YPES.js → chunk-RTVHJ23A.js} +4 -4
- package/dist/chunk-RTVWQK7I.js +2 -0
- package/dist/chunk-RX6776AI.js +5 -0
- package/dist/{chunk-F7NSSQYZ.js → chunk-SGPAM5DZ.js} +1 -1
- package/dist/chunk-SMTBOSEJ.js +2 -0
- package/dist/chunk-SMXABALN.js +2 -0
- package/dist/{chunk-TM7VRLWS.js → chunk-SXRHKXSE.js} +1 -1
- package/dist/chunk-TNORODUF.js +2 -0
- package/dist/chunk-TU42YZOJ.js +6 -0
- package/dist/chunk-TU7TVFBK.js +2 -0
- package/dist/chunk-TW5AA5A7.js +8 -0
- package/dist/chunk-UEE3RZN4.js +14 -0
- package/dist/chunk-URH4FX3H.js +2 -0
- package/dist/chunk-UTM7D4PI.js +2 -0
- package/dist/chunk-UUJIGOEO.js +2 -0
- package/dist/chunk-UYDHOHSZ.js +2 -0
- package/dist/{chunk-4BZOG6PE.js → chunk-V7USCQWO.js} +1 -1
- package/dist/chunk-VJGWVBZR.js +1 -0
- package/dist/chunk-VLDCHFXF.js +2 -0
- package/dist/chunk-VO66KP2W.js +2 -0
- package/dist/chunk-VRIZDOO5.js +2 -0
- package/dist/{chunk-DOOI2JBD.js → chunk-VSVWNRI2.js} +1 -1
- package/dist/chunk-VUFIL5VR.js +6 -0
- package/dist/chunk-VX657KIK.js +2 -0
- package/dist/chunk-VXGN3IV7.js +2 -0
- package/dist/chunk-VZ4A6WMK.js +97 -0
- package/dist/chunk-VZJ6LUXX.js +2 -0
- package/dist/{chunk-RWSOZPJQ.js → chunk-W4QSZNMB.js} +1 -1
- package/dist/chunk-W54OT2FU.js +9 -0
- package/dist/{chunk-BL3SJDCG.js → chunk-W6HZF56M.js} +1 -1
- package/dist/chunk-W72ACCFL.js +27 -0
- package/dist/chunk-W7FLXW6Q.js +5 -0
- package/dist/chunk-WAOUE7MP.js +9 -0
- package/dist/chunk-WEIPY3CI.js +16 -0
- package/dist/chunk-WMGKUERB.js +6 -0
- package/dist/{chunk-DFS4RMVP.js → chunk-WN5VKKJ3.js} +1 -1
- package/dist/chunk-WOSANGV6.js +5 -0
- package/dist/{chunk-K3IQEL7R.js → chunk-WXJCJL5L.js} +1 -1
- package/dist/chunk-WZXPF3BI.js +2 -0
- package/dist/chunk-XB6BJPDL.js +2 -0
- package/dist/{chunk-4FHK4LKQ.js → chunk-XLEGGC4Y.js} +1 -1
- package/dist/chunk-XMPTFXPW.js +5 -0
- package/dist/chunk-XQMWHPZI.js +3 -0
- package/dist/{chunk-75MMTNPB.js → chunk-XRNQSXOM.js} +2 -2
- package/dist/{chunk-2PKME4VT.js → chunk-XZGEN4NU.js} +4 -4
- package/dist/chunk-XZYA7DNH.js +2 -0
- package/dist/{chunk-OIUV3ISA.js → chunk-Y6Y6RAY4.js} +1 -1
- package/dist/chunk-Y7E5L42F.js +3 -0
- package/dist/{chunk-GFBAK7WQ.js → chunk-YAW6JW6D.js} +7 -7
- package/dist/chunk-YDPTSDIJ.js +2 -0
- package/dist/chunk-YDSGXB25.js +2 -0
- package/dist/chunk-YGRULEZY.js +2 -0
- package/dist/chunk-YHFZFV3A.js +22 -0
- package/dist/chunk-YIKF4ERQ.js +375 -0
- package/dist/chunk-YLXWAY7D.js +2 -0
- package/dist/{chunk-UA2QDAWT.js → chunk-YPFQ4UGF.js} +1 -1
- package/dist/{chunk-4CYBXJIA.js → chunk-YQ5C6UDG.js} +1 -1
- package/dist/chunk-Z55KBMYV.js +2 -0
- package/dist/chunk-ZAFJQ3SM.js +2 -0
- package/dist/chunk-ZCRZFAOT.js +2 -0
- package/dist/chunk-ZFM77AQU.js +2 -0
- package/dist/{chunk-Q6F23V7L.js → chunk-ZFMRQ57Y.js} +1 -1
- package/dist/chunk-ZHWU6L2G.js +5 -0
- package/dist/chunk-ZTHYAHDN.js +17 -0
- package/dist/{chunk-X2A6CC6B.js → chunk-ZTRRFG52.js} +1 -1
- package/dist/chunk-ZU4W2QGM.js +3 -0
- package/dist/committer-JGY66PFM.js +2 -0
- package/dist/config-754B73XK.js +2 -0
- package/dist/controller-client-PB3AZAGG.js +2 -0
- package/dist/cover-cmd-NBNZCR6C.js +2 -0
- package/dist/{credentials-QD32Y7K7.js → credentials-F7DYLVWY.js} +1 -1
- package/dist/{deps-bundle-OI7JJ22L.js → deps-bundle-PW3WEQJ7.js} +1 -1
- package/dist/{deps-resolve-ZOALDS6H.js → deps-resolve-SQYVN76L.js} +1 -1
- package/dist/descriptor-7T32VRMB.js +2 -0
- package/dist/design-chat-F3OEZPNJ.js +2 -0
- package/dist/design-committer-TRYP3LOZ.js +2 -0
- package/dist/design-headless-OTHYOX3E.js +2 -0
- package/dist/design-remote-2BEGCVCX.js +3 -0
- package/dist/device-env-CHFRRV6W.js +2 -0
- package/dist/dispatch-DVQ3H7EJ.js +2 -0
- package/dist/doctor-XY26Z35T.js +2 -0
- package/dist/docx-convert-6IZO5P5K.js +2 -0
- package/dist/{dossier-7HVC6BNK.js → dossier-NROC2MCY.js} +1 -1
- package/dist/evidence-P6FFKC7B.js +2 -0
- package/dist/evidence-presentation-YYTIDCBS.js +2 -0
- package/dist/evolve-cmd-WWOB3QJR.js +2 -0
- package/dist/evolve-remote-WLVY3QID.js +2 -0
- package/dist/{exit-manager-ZLDO54S4.js → exit-manager-EDHCETUN.js} +1 -1
- package/dist/explain-DGJ5T6V5.js +2 -0
- package/dist/explain-cmd-OP5I5W3O.js +12 -0
- package/dist/explain-cmd-VYAANFFZ.js +4 -0
- package/dist/explore-K5YBGHK6.js +2 -0
- package/dist/explore-context-tty-RZ7D2TBV.js +2 -0
- package/dist/explore-entry-EKXJ67BD.js +6 -0
- package/dist/explore-live-2YVRAQZO.js +5 -0
- package/dist/explore-run-tty-D47FGPX7.js +5 -0
- package/dist/extract-bind-W2NET364.js +14 -0
- package/dist/extract-chat-M65NWGUK.js +2 -0
- package/dist/extract-cmd-FTFLETOP.js +6 -0
- package/dist/extract-headless-G6W6JQ27.js +2 -0
- package/dist/feeder-NY45UFJK.js +2 -0
- package/dist/folder-flags-KKIH654K.js +2 -0
- package/dist/gaps-cmd-OIDDLRYL.js +3 -0
- package/dist/gate-7AKRPRMK.js +2 -0
- package/dist/gate-WISOUTHQ.js +2 -0
- package/dist/{generate-headless-6WMJYNI6.js → generate-headless-RURIEKVS.js} +3 -3
- package/dist/headless-io-FFM5T6KL.js +2 -0
- package/dist/hold-passthrough-IOWPVB4W.js +2 -0
- package/dist/identity-HL5CJJXR.js +2 -0
- package/dist/index.js +178 -160
- package/dist/ingest-PDGS5ZTL.js +2 -0
- package/dist/ingest-cmd-4G2AK4Y2.js +8 -0
- package/dist/ingest-remote-SSLUHQVG.js +2 -0
- package/dist/ink-screen-RZ7QDIUI.js +2 -0
- package/dist/install-ZVBHPXGP.js +2 -0
- package/dist/interactive-bind-SI2ZS55Q.js +26 -0
- package/dist/interactive-remote-J56EWJGA.js +65 -0
- package/dist/interrupt-guard-QETBPINI.js +2 -0
- package/dist/lane-AQYRIW24.js +2 -0
- package/dist/lattice-auth-6FEVSR7E.js +2 -0
- package/dist/lifecycle-cmd-HJ37LTXE.js +2 -0
- package/dist/list-cmd-6XL2FYLQ.js +3 -0
- package/dist/list-commands-5DCCKU3L.js +2 -0
- package/dist/list-remote-LXPQNXYN.js +15 -0
- package/dist/locks-cmd-JJ2QNTNY.js +2 -0
- package/dist/logical-ids-RXAQJZ3T.js +2 -0
- package/dist/login-flow-WEK3E476.js +2 -0
- package/dist/maintenance-cmd-BXXHP36K.js +2 -0
- package/dist/mobile-prompts-CECJ5UY2.js +2 -0
- package/dist/{next-KZXH4UA4.js → next-O6SUSX3R.js} +1 -1
- package/dist/{objective-variable-gate-CG2KK5UX.js → objective-variable-gate-3Z7DNVVC.js} +1 -1
- package/dist/onboarding-PDVYMTY5.js +5 -0
- package/dist/open-provider-OZAG6WZS.js +2 -0
- package/dist/{paths-JCYX6UWL.js → paths-UMIX3RJF.js} +1 -1
- package/dist/pdf-convert-447ACUB3.js +2 -0
- package/dist/persist-recorded-session-A3ID7JFA.js +3 -0
- package/dist/phase-seed-LCJ4WSYV.js +2 -0
- package/dist/pipeline-GX3LKPI5.js +2 -0
- package/dist/prepare-target-FMT6QFHZ.js +2 -0
- package/dist/pull-cmd-UPFQYUND.js +2 -0
- package/dist/pull-route-FWBXJMR7.js +2 -0
- package/dist/readmodel-INMP6MNW.js +2 -0
- package/dist/real-device-run-X7JJWOIK.js +2 -0
- package/dist/reconcile-cmd-JBH365JL.js +5 -0
- package/dist/reconcile-deps-TWJ3FTSU.js +2 -0
- package/dist/reconcile-remote-BCX6SWFC.js +13 -0
- package/dist/recording-banner-YKBAL6UB.js +2 -0
- package/dist/registry-VQC757MJ.js +2 -0
- package/dist/remote-entry-X6JMPC2K.js +2 -0
- package/dist/remote-mode-FDPA7EWG.js +4 -0
- package/dist/remote-words-YVB66R3F.js +2 -0
- package/dist/require-project-folder-MLMEQJYP.js +2 -0
- package/dist/resolve-run-intent-PC7TQZUL.js +2 -0
- package/dist/resolver-EID34LQE.js +2 -0
- package/dist/revert-FHOBLZWF.js +2 -0
- package/dist/review-cmd-EUHFLFMY.js +5 -0
- package/dist/run-5RQUCNYP.js +2 -0
- package/dist/run-PC5YO4AS.js +2 -0
- package/dist/run-channel-63SVP5OI.js +2 -0
- package/dist/run-remote-SJCRTL7O.js +2 -0
- package/dist/run-startup-gate-YO66G6LS.js +2 -0
- package/dist/run-test-md-BLNBK4MH.js +17 -0
- package/dist/scrollback-GGNBDFQV.js +2 -0
- package/dist/session-target-DD53UXO7.js +2 -0
- package/dist/session-worker.js +12 -0
- package/dist/sessions-CFV7FOIT.js +2 -0
- package/dist/sessions-cmd-S7WZBUCN.js +26 -0
- package/dist/sessions-remote-IWHWIQ2T.js +3 -0
- package/dist/shell-arg-FN3MT5U7.js +2 -0
- package/dist/{skill-installer-32YYMM4N.js → skill-installer-MAVQY6GW.js} +1 -1
- package/dist/spawner-C7NLLM4F.js +2 -0
- package/dist/store-MSA7KASS.js +2 -0
- package/dist/store-choice-3OJCV26J.js +2 -0
- package/dist/store-guard-OOSDLMEC.js +2 -0
- package/dist/store-id-YZ5WKJ25.js +2 -0
- package/dist/store-site-KA2DNBGY.js +2 -0
- package/dist/stream-warnings-GEQKKJU7.js +2 -0
- package/dist/structured-answers-EQ2AP3F7.js +2 -0
- package/dist/sync-cmd-RDFDMVKQ.js +2 -0
- package/dist/sync-setup-RBRDUV7Q.js +2 -0
- package/dist/{sync-setup-ui-RC727VK6.js → sync-setup-ui-XITPGSO4.js} +2 -2
- package/dist/tcg-generate-KIECTZ2C.js +2 -0
- package/dist/test-definition-VRI4YIYL.js +2 -0
- package/dist/testmd-actions-CMAG6HWI.js +2 -0
- package/dist/testmd-sync-UPAA5UMD.js +2 -0
- package/dist/tms-client-NXAB6VJD.js +2 -0
- package/dist/token-refresh-KP3AYMYK.js +2 -0
- package/dist/trust-gate-AT2XBWN4.js +2 -0
- package/dist/turn-preflight-LHYLRL7G.js +2 -0
- package/dist/ui-SNV3FD2G.js +4 -0
- package/dist/use-case-ref-NE4X4MZN.js +2 -0
- package/dist/validate-basic-M5JHHNZA.js +2 -0
- package/dist/{variable-receipt-YWNS24TH.js → variable-receipt-BXSZO36E.js} +1 -1
- package/dist/verdicts-XK3GAUX3.js +2 -0
- package/dist/version-check-Q737BE65.js +2 -0
- package/dist/{view-cmd-3WHG6MVB.js → view-cmd-XSNL5DGI.js} +4 -3
- package/dist/walk-session-SHGYLFRB.js +2 -0
- package/dist/with-telemetry-PM2HVN2B.js +2 -0
- package/package.json +11 -11
- package/dist/ChatSurface-FJPK3XEJ.js +0 -8
- package/dist/ChromeProfilePicker-7DUDJTE2.js +0 -2
- package/dist/CliFeedbackPrompt-ZZPYC6OS.js +0 -2
- package/dist/CliUploadProgress-WQYKIBAR.js +0 -2
- package/dist/ConfigView-KXNOODDW.js +0 -2
- package/dist/EvidenceViewOffer-BTBVPBZX.js +0 -2
- package/dist/FolderPicker-H4YEX5LV.js +0 -2
- package/dist/InfoBox-DTM7X24Z.js +0 -2
- package/dist/LinksBox-KFG3FVOT.js +0 -2
- package/dist/ProfilesView-KBZHT4KL.js +0 -2
- package/dist/ProjectPicker-OARWULNN.js +0 -2
- package/dist/SaveSessionPrompt-37SMU5MC.js +0 -2
- package/dist/ScrollbackTap-QHJOFYMC.js +0 -2
- package/dist/SingleShotApp-UYCAW65Y.js +0 -2
- package/dist/SummaryBox-6RB5DSAH.js +0 -2
- package/dist/TestMdRunView-ZMOII3PL.js +0 -2
- package/dist/TestrunEvidenceTable-3UP2EYIV.js +0 -2
- package/dist/WhoamiView-MC62GERR.js +0 -2
- package/dist/app-client-PQFJAB63.js +0 -2
- package/dist/app-download-P6YXWSVQ.js +0 -2
- package/dist/auth-LXW4OFKF.js +0 -2
- package/dist/bind-ZYESQSCJ.js +0 -15
- package/dist/bootstrap-DI4UGMH3.js +0 -2
- package/dist/bridge-7J3JE3JS.js +0 -2
- package/dist/build-JIKYOZUH.js +0 -2
- package/dist/catalog-LLME3744.js +0 -2
- package/dist/chat-committer-6D7AQI6Z.js +0 -2
- package/dist/chat-controller-UJQ6Z4RE.js +0 -2
- package/dist/chunk-243ZJHT6.js +0 -4
- package/dist/chunk-2KVECC36.js +0 -2
- package/dist/chunk-2YEHV2CX.js +0 -2
- package/dist/chunk-3MCPTVJX.js +0 -2
- package/dist/chunk-3UI5VTQS.js +0 -4
- package/dist/chunk-3VAU3PNU.js +0 -2
- package/dist/chunk-3YIZG7WZ.js +0 -3
- package/dist/chunk-4Y2WH77W.js +0 -2
- package/dist/chunk-5EOX4MEY.js +0 -2
- package/dist/chunk-5HMN74RZ.js +0 -9
- package/dist/chunk-5LJRZI7S.js +0 -6
- package/dist/chunk-5RCS2LIQ.js +0 -26
- package/dist/chunk-5TQFOPJV.js +0 -2
- package/dist/chunk-5ZFOKYFB.js +0 -5
- package/dist/chunk-63DYVWNX.js +0 -2
- package/dist/chunk-6MD7SR7D.js +0 -9
- package/dist/chunk-7N6OCHPC.js +0 -7
- package/dist/chunk-A2SQD2AY.js +0 -4
- package/dist/chunk-AACQE24F.js +0 -2
- package/dist/chunk-AHFIRHSP.js +0 -18
- package/dist/chunk-AJT34ESA.js +0 -38
- package/dist/chunk-AUMJ4RVA.js +0 -21
- package/dist/chunk-AXTPNZPX.js +0 -2
- package/dist/chunk-BB2W35TW.js +0 -2
- package/dist/chunk-BKM2LWU2.js +0 -3
- package/dist/chunk-BUPRL2TE.js +0 -2
- package/dist/chunk-C44QQJR4.js +0 -239
- package/dist/chunk-CW3RHKLA.js +0 -5
- package/dist/chunk-D6E6KRVX.js +0 -2
- package/dist/chunk-DTRKTBCE.js +0 -17
- package/dist/chunk-DTRSYWZE.js +0 -2
- package/dist/chunk-EVFFDODK.js +0 -5
- package/dist/chunk-F2OBORCG.js +0 -2
- package/dist/chunk-FQNQVC5O.js +0 -5
- package/dist/chunk-FY7TCYPK.js +0 -6
- package/dist/chunk-GTVQYT3D.js +0 -35
- package/dist/chunk-HG5LLZBU.js +0 -2
- package/dist/chunk-I7TIGB7K.js +0 -2
- package/dist/chunk-IICT4VOU.js +0 -2
- package/dist/chunk-ILDHE4P4.js +0 -6
- package/dist/chunk-IPXKUYUK.js +0 -2
- package/dist/chunk-JQY5HRZ4.js +0 -15
- package/dist/chunk-JX6BFEDO.js +0 -4
- package/dist/chunk-K2UJYY2U.js +0 -2
- package/dist/chunk-KBM3XHAM.js +0 -2
- package/dist/chunk-KDNNMU7Q.js +0 -4
- package/dist/chunk-KJQNAOOE.js +0 -6
- package/dist/chunk-LH4IPANP.js +0 -2
- package/dist/chunk-LLG7NEGX.js +0 -6
- package/dist/chunk-LSDWPG6C.js +0 -2
- package/dist/chunk-MSGW4JDG.js +0 -2
- package/dist/chunk-NJ4BXZBX.js +0 -2
- package/dist/chunk-NLCCBXXV.js +0 -2
- package/dist/chunk-NMSZ7G6P.js +0 -2
- package/dist/chunk-OC6H6BYI.js +0 -6
- package/dist/chunk-OJAXOOZ5.js +0 -8
- package/dist/chunk-OMNLAGQC.js +0 -29
- package/dist/chunk-OOCCUUR2.js +0 -2
- package/dist/chunk-OXC6O5O7.js +0 -2
- package/dist/chunk-OZQDD2EX.js +0 -94
- package/dist/chunk-PEDINHVU.js +0 -2
- package/dist/chunk-PNUAP3RY.js +0 -8
- package/dist/chunk-Q2F5QB2W.js +0 -2
- package/dist/chunk-Q4YYAN6E.js +0 -2
- package/dist/chunk-Q6AHSGOE.js +0 -5
- package/dist/chunk-QAB3Y5FQ.js +0 -4
- package/dist/chunk-RDHWNSDP.js +0 -7
- package/dist/chunk-RKXHVP2Z.js +0 -2
- package/dist/chunk-RRY5IXOB.js +0 -2
- package/dist/chunk-RSSOJ3L2.js +0 -21
- package/dist/chunk-RTSBKCZY.js +0 -16
- package/dist/chunk-SID4X77D.js +0 -370
- package/dist/chunk-SRTKRHYI.js +0 -12
- package/dist/chunk-T2ONUKTL.js +0 -5
- package/dist/chunk-U6OTFMIT.js +0 -4
- package/dist/chunk-UD7KKHPW.js +0 -5
- package/dist/chunk-USOYXCZ4.js +0 -2
- package/dist/chunk-USY7VAO6.js +0 -2
- package/dist/chunk-V4B5QA3U.js +0 -4
- package/dist/chunk-VBS33P2C.js +0 -2
- package/dist/chunk-VHW7BMZQ.js +0 -2
- package/dist/chunk-VIO7CCFW.js +0 -5
- package/dist/chunk-VORWZLS3.js +0 -9
- package/dist/chunk-VVOKM2VO.js +0 -2
- package/dist/chunk-W5TTF7GB.js +0 -6
- package/dist/chunk-WESMQEPO.js +0 -2
- package/dist/chunk-WMI4P76K.js +0 -27
- package/dist/chunk-WNOC6MQC.js +0 -2
- package/dist/chunk-WVHMPIDQ.js +0 -2
- package/dist/chunk-XBX643ZD.js +0 -2
- package/dist/chunk-XKHWWKJZ.js +0 -3
- package/dist/chunk-XLSOQLVT.js +0 -2
- package/dist/chunk-Y3ZYN6AK.js +0 -4
- package/dist/chunk-YCCUBQY4.js +0 -2
- package/dist/chunk-YKTYVJBN.js +0 -3
- package/dist/chunk-YLQHY4A7.js +0 -2
- package/dist/chunk-Z7IGTVJW.js +0 -2
- package/dist/chunk-ZC2CKWLB.js +0 -2
- package/dist/chunk-ZER3FZSZ.js +0 -22
- package/dist/chunk-ZJYT72BA.js +0 -9
- package/dist/chunk-ZKSN2SJ7.js +0 -2
- package/dist/chunk-ZLWURCJ7.js +0 -2
- package/dist/committer-2QPBANRD.js +0 -2
- package/dist/config-YGTHSGQN.js +0 -2
- package/dist/controller-client-ZF5IXRUV.js +0 -2
- package/dist/cover-cmd-6RO366CC.js +0 -3
- package/dist/descriptor-3JJUOHBM.js +0 -2
- package/dist/design-committer-D44GSUXY.js +0 -2
- package/dist/device-env-DXDJJMTL.js +0 -2
- package/dist/dispatch-7EWWQRQ5.js +0 -2
- package/dist/doctor-TPYPEEUL.js +0 -2
- package/dist/docx-convert-SQRTF7XS.js +0 -2
- package/dist/evidence-NPFTBGDF.js +0 -2
- package/dist/evidence-presentation-XF23B7F2.js +0 -2
- package/dist/evolve-cmd-VGVXV6XW.js +0 -2
- package/dist/explain-NEFBUX5G.js +0 -2
- package/dist/explain-cmd-GOP5TE63.js +0 -9
- package/dist/explain-cmd-M7IX2YNB.js +0 -3
- package/dist/extract-bind-CKIRLXAJ.js +0 -14
- package/dist/extract-cmd-3EWLSPGS.js +0 -5
- package/dist/feeder-66TUPB2R.js +0 -2
- package/dist/gaps-cmd-WVC5GXQC.js +0 -3
- package/dist/gate-OYRDJMF6.js +0 -2
- package/dist/headless-io-75HUMWZB.js +0 -2
- package/dist/identity-ADZ4PAJF.js +0 -2
- package/dist/ingest-OSNNM3DH.js +0 -2
- package/dist/ingest-cmd-AECK5T4H.js +0 -2
- package/dist/install-ZV3KJZV4.js +0 -2
- package/dist/interactive-bind-IYS6KDOH.js +0 -26
- package/dist/interrupt-guard-UREUWNRL.js +0 -2
- package/dist/lifecycle-cmd-XCSBELFQ.js +0 -2
- package/dist/list-cmd-S4DSN2ET.js +0 -3
- package/dist/list-commands-GLNGHPDU.js +0 -2
- package/dist/locks-cmd-67OHQZNV.js +0 -2
- package/dist/logical-ids-GLVM2SVR.js +0 -2
- package/dist/login-flow-ASUUU7SO.js +0 -2
- package/dist/maintenance-cmd-K5KXRIFL.js +0 -2
- package/dist/mobile-prompts-ZUZTA3RV.js +0 -2
- package/dist/open-provider-YIBB77FE.js +0 -2
- package/dist/pdf-convert-RLXSXFWN.js +0 -2
- package/dist/persist-recorded-session-EWV56TSZ.js +0 -3
- package/dist/phase-seed-MKHEWUN6.js +0 -2
- package/dist/pipeline-LAWACB2O.js +0 -2
- package/dist/prepare-target-WGPCZKLE.js +0 -2
- package/dist/readmodel-FVLRQWZ7.js +0 -2
- package/dist/real-device-run-MDLFKFVQ.js +0 -2
- package/dist/reconcile-cmd-XFM2ZXUJ.js +0 -2
- package/dist/reconcile-deps-V5VLDPYT.js +0 -4
- package/dist/reconcile-engine-VZBTMPUK.js +0 -2
- package/dist/recording-banner-CJHRPHHF.js +0 -2
- package/dist/records-LMCVKPE5.js +0 -2
- package/dist/registry-3JXQFZEG.js +0 -2
- package/dist/require-project-folder-SE5GVCYJ.js +0 -2
- package/dist/resolve-run-intent-DD4MB6UD.js +0 -2
- package/dist/resolver-TLO4SRWV.js +0 -2
- package/dist/revert-NOUECRW4.js +0 -2
- package/dist/review-cmd-7EOYQMPE.js +0 -5
- package/dist/run-EHUNJPW6.js +0 -2
- package/dist/run-OTMPUQSH.js +0 -2
- package/dist/run-channel-RGH4WIQX.js +0 -2
- package/dist/run-test-md-KBDEHGXJ.js +0 -17
- package/dist/scrollback-JLPJR25X.js +0 -2
- package/dist/session-items-2ATN7VXG.js +0 -2
- package/dist/session-target-UMNASXI7.js +0 -2
- package/dist/sessions-NH7WQWMX.js +0 -2
- package/dist/sessions-cmd-M3SECFKQ.js +0 -25
- package/dist/spawner-DPT2RLAO.js +0 -2
- package/dist/store-guard-U32JE6JJ.js +0 -2
- package/dist/store-id-EOSGEKVK.js +0 -2
- package/dist/structured-answers-ZI2B6JJE.js +0 -2
- package/dist/sync-cmd-3EP7LZGL.js +0 -2
- package/dist/sync-setup-SWTBVQEV.js +0 -2
- package/dist/tcg-generate-KXU7E2GF.js +0 -2
- package/dist/testmd-actions-PEWCPQ5R.js +0 -2
- package/dist/testmd-sync-ZWFQWZ2X.js +0 -2
- package/dist/tms-client-KU6HCA23.js +0 -2
- package/dist/token-refresh-QD3OCGJJ.js +0 -2
- package/dist/trust-gate-EX7R2P4Y.js +0 -2
- package/dist/turn-preflight-JGYT7LXP.js +0 -2
- package/dist/ui-JEJGTURD.js +0 -4
- package/dist/validate-basic-AAIXSAWH.js +0 -2
- package/dist/verdicts-LAB5BGCC.js +0 -2
- package/dist/version-check-EHOLX3YH.js +0 -2
- package/dist/walk-session-XP4KYFKO.js +0 -2
- package/dist/with-telemetry-FJMJQDCM.js +0 -2
- /package/dist/{chunk-BKHXPBWN.js → chunk-2RUSXQ3O.js} +0 -0
- /package/dist/{chunk-6J5T5FEY.js → chunk-3AGP2BVN.js} +0 -0
- /package/dist/{chunk-CH273NAE.js → chunk-73Y6T2UK.js} +0 -0
- /package/dist/{chunk-ZMNJBUAO.js → chunk-73ZFOJOK.js} +0 -0
- /package/dist/{chunk-NOL7MNZH.js → chunk-A7RJQJNT.js} +0 -0
- /package/dist/{chunk-N2P4MI32.js → chunk-FWGUISUG.js} +0 -0
- /package/dist/{chunk-UJZZDPDY.js → chunk-HD6NR44L.js} +0 -0
- /package/dist/{chunk-LDPLJFCV.js → chunk-I6S6DZ2E.js} +0 -0
- /package/dist/{chunk-427OQS2N.js → chunk-LD5B3QFW.js} +0 -0
- /package/dist/{chunk-2UIHS2FH.js → chunk-PGESS7BW.js} +0 -0
- /package/dist/{chunk-BZAGVBCX.js → chunk-ZCIWQHCO.js} +0 -0
package/dist/chunk-OZQDD2EX.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as Cr,b as Ho,c as Go,d as Mt,e as ut,f as qo,g as Qo,h as xr,i as Pr,j as Tr,k as Zo,l as Xo}from"./chunk-2PKME4VT.js";import{a as Uo}from"./chunk-WD52ZNQY.js";import{f as Yo,h as Jo}from"./chunk-GFBAK7WQ.js";import{c as es}from"./chunk-CSNJPD2J.js";import{a as Sr}from"./chunk-W3USRQX6.js";import{b as Dr,c as Lr}from"./chunk-KWEOLPBJ.js";import{c as ts,e as rs,f as ns}from"./chunk-USY7VAO6.js";import{T as os}from"./chunk-GTVQYT3D.js";import{c as Or}from"./chunk-T2ONUKTL.js";import{b as Ge}from"./chunk-AHFIRHSP.js";import{a as dt,b as io,c as ao,d as lo,e as co,f as uo,g as gr,i as mo}from"./chunk-JQ64X2TO.js";import{d as Bt,e as Ko}from"./chunk-JX6BFEDO.js";import{a as ct,b as ee,c as jo,e as Se,f as qe,g as Ir,k as Fo,m as $o,n as Bo,o as kr,p as _r,q as he,r as Rr,t as Er,v as Vo}from"./chunk-JQY5HRZ4.js";import{b as No}from"./chunk-NBXYL2JT.js";import{c as Mo}from"./chunk-VHW7BMZQ.js";import{a as no,b as oo,c as Ut,e as Nt,f as br}from"./chunk-7WXMV3O3.js";import{a as jt,c as ho,d as yo,e as Ft,f as bo}from"./chunk-K3IQEL7R.js";import{a as mt,b as zo,c as Ar}from"./chunk-BHSHGWBL.js";import{c as Wo}from"./chunk-S3DAAAE5.js";import{A as _o,B as Ro,C as Eo,E as vr,F as Co,H as Po,Q as To,R as Do,X as Lo,Y as Oo,g as Io,i as $t,v as So,w as ko}from"./chunk-ZJYT72BA.js";import{c as Ao,d as xo}from"./chunk-RTSBKCZY.js";import{c as vo,e as wo}from"./chunk-GCISXCDU.js";import{a as wr}from"./chunk-CH273NAE.js";import{g as fo,h as po}from"./chunk-M3UAZTDK.js";import{a as hr}from"./chunk-ZLWURCJ7.js";import{a as yr}from"./chunk-QSCXXNC2.js";import{a as go}from"./chunk-2YEHV2CX.js";import{f as Yn,j as Jn}from"./chunk-EBLXHOE3.js";import{a as Zn,d as eo,e as to,g as ro}from"./chunk-AJT34ESA.js";import{h as Qn}from"./chunk-AKE2CTV6.js";import{a as Xn}from"./chunk-OIUV3ISA.js";import{c as so}from"./chunk-HG5LLZBU.js";import{a as Ot}from"./chunk-2KVECC36.js";import{j as Gn,m as qn,n as Lt,o as zn,p as Wn}from"./chunk-RSSOJ3L2.js";import{a as Kn}from"./chunk-Z7S3IWUX.js";import{d as Hn}from"./chunk-4JOD47QI.js";import{a as oe}from"./chunk-NMSZ7G6P.js";import{a as De}from"./chunk-DHJSM5DT.js";import{a as Tt,b as Dt}from"./chunk-NLCCBXXV.js";import{a as X}from"./chunk-RZ4F3BHX.js";import{a as Bn}from"./chunk-E47GFYXA.js";import{e as pr,f as lt,p as Mn}from"./chunk-NOL7MNZH.js";import{a as xt,b as Pt,i as Vn,j as He}from"./chunk-5TQFOPJV.js";import{join as be,basename as Ue}from"path";import{existsSync as _a,readFileSync as ci}from"fs";function ss(e,t){if(process.env.KANE_REPLAY_TRACE==="1")for(let r=0;r<e.steps.length;r++){let n=e.steps[r],o=t[r],s=" ".repeat(n.trace.length-1),l=`step ${n.flatIndex}`;if(o.kind==="replay"){let p=o.replayOnly?` [replay-only @${o.replayOnly}]`:"";process.stderr.write(`[replay-trace] ${s}${l}: REPLAY${p} (would skip; v1 always authors)
|
|
3
|
-
`)}else process.stderr.write(`[replay-trace] ${s}${l}: AUTHOR (${o.reason})
|
|
4
|
-
`)}}function Le(e){process.env.KANE_REPLAY_TRACE==="1"&&process.stderr.write(e)}function is(e,t){let r=e===0?"(none)":`0..${e-1}`,n=e>=t?"(none)":`${e}..${t-1}`;Le(`[replay-trace] phase: replay ${r}, author ${n}
|
|
5
|
-
`)}function as(e,t){Le(`[replay-trace] step ${e}: REPLAY ${t==="ok"?"OK":"FAILED"}
|
|
6
|
-
`)}function ls(e,t,r){Le(`[replay-trace] shrink ${e}/${t} \u2192 new boundary ${r}
|
|
7
|
-
`)}function ds(e,t){Le(`[replay-trace] complete-reauthor (${e} shrinks exhausted of ${t})
|
|
8
|
-
`)}function jr(){Le(`[replay-trace] force-author (--author) \u2014 walker bypassed; identity kept
|
|
9
|
-
`)}function cs(e){Le(`[replay-trace] cancelled at step ${e}
|
|
10
|
-
`)}function Oe(e,t){Le(`[replay-trace] step ${e}: replay-only @${t} failed \u2014 adaptive heal cannot re-author it; the run fails here
|
|
11
|
-
`)}import{join as us}from"path";function Fr(e){let t=qo(e.decision),r={objective:e.step.objective,model:"v16-alpha",width:e.windowSize.width,height:e.windowSize.height,session_id:e.sessionId,run_index:e.runIndex,mode:"replay",replay:{recording_path:t[0],...t.length>1?{recording_paths:t}:{},step_label:e.step.objective,...e.investigationAsync?{investigation:"async"}:{}},screenshot_dir:e.evidence?us(e.sessionDir,"scratch",String(e.runIndex)):us(e.sessionDir,"runs",String(e.runIndex)),run_id:"run",test_id:"test",disable_ask_user:!0};return e.forceNavigateUrl&&(r.url=e.forceNavigateUrl),e.chrome.wsEndpoint?r.ws_endpoint=e.chrome.wsEndpoint:e.chrome.cdpEndpoint&&(r.cdp_endpoint=e.chrome.cdpEndpoint),e.auth.basicAuth?(r.username=e.auth.basicAuth.username,r.access_key=e.auth.basicAuth.access_key):e.auth.token&&(r.auth={type:"bearer",token:e.auth.token}),e.auth.resolvedCreds?.org_id&&(r.org_id=String(e.auth.resolvedCreds.org_id)),e.environmentId&&(r.environment_id=e.environmentId),e.variables&&Object.keys(e.variables).length>0&&(r.variables=e.variables),e.sessionContext&&(r.session_context=e.sessionContext),e.device&&(r.device=e.device),e.evidence&&(r.evidence=$t(e.evidence.packTestDir,e.evidence.ordinalOffset)),r}async function ms(e){let t=e.forceAuthor?0:ut(e.decisions),r=0,n=!1;for(;;){let o=e.session.snapshot(),s=e.accumulator.snapshot(),l=await e.runReplayPhase(t);if(l.cancelled)return n=!0,cs(l.failedAt??0),{authorBoundary:t,cancelledInPhase:n,shrinkCount:r};if(l.failedAt===null)return{authorBoundary:t,cancelledInPhase:n,shrinkCount:r};let p=e.decisions[l.failedAt],i=p?.kind==="replay"?p.replayOnly:void 0,c=zo({failedAt:l.failedAt,shrinkCount:r,hasRetry:e.hasRetry,maxShrinks:e.maxShrinks,failedAtReplayOnly:i});if(c.kind==="fail")return c.replayOnly&&(Oe(l.failedAt,c.replayOnly),e.onReplayOnlyFail?.(l.failedAt,c.replayOnly)),{authorBoundary:-1,cancelledInPhase:n,shrinkCount:r};if(e.acquireLockIfNeeded&&!await e.acquireLockIfNeeded())return{authorBoundary:-1,cancelledInPhase:n,shrinkCount:r};if(e.recycleBrowser&&!await e.recycleBrowser())return{authorBoundary:-1,cancelledInPhase:n,shrinkCount:r};if(e.archiveAttempt&&await e.archiveAttempt(l.failedAt),e.session.rollback(o),e.accumulator.rollback(s),c.kind==="complete-reauthor")return ds(r+1,e.maxShrinks),{authorBoundary:0,cancelledInPhase:n,shrinkCount:r};r++,ls(r,mt.maxShrinks,c.newAuthorBoundary),t=c.newAuthorBoundary}}var Ei=15e3,Ur=3,fs=[500,1e3];async function Nr(e){if(process.env.KANE_LOCK_CONFLICT_SIMULATE==="1")return{ok:!1,reason:"concurrent",httpStatus:409,message:"simulated contention (KANE_LOCK_CONFLICT_SIMULATE=1)"};let t=`${e.baseUrl}/test/${encodeURIComponent(e.testId)}/playground`,r=await Vt(t,{from_commit_id:e.fromCommitId,new_commit_id:e.newCommitId},e.auth);return r.ok?{ok:!0,sessionExpiresAt:Y(r.body,"session_expires_at")??""}:{ok:!1,...Ci(r)}}function Ci(e){let t=Y(e.body,"error")??Y(e.body,"code")??"",r=Y(e.body,"message")??Y(e.body,"detail")??e.text??`HTTP ${e.status}`,n;return e.status===0?n="network":e.status===401||e.status===403?n="auth":e.status===409&&t==="PlaygroundBaseCommitMismatch"?n="base_mismatch":e.status===409?n="concurrent":e.status===422?n="disabled":e.status===400&&/no committed/i.test(r)?n="no_commits":e.status===400?n="missing_field":e.status>=500||e.status===408||e.status===429?n="network":n="other",{reason:n,httpStatus:e.status,message:r}}async function gs(e){let t=`${e.baseUrl}/test/${encodeURIComponent(e.testId)}/playground/reserve`,r=await Vt(t,void 0,e.auth);return r.ok?{ok:!0,sessionExpiresAt:Y(r.body,"session_expires_at")??""}:{ok:!1,expired:r.status===404,httpStatus:r.status,message:Y(r.body,"message")??Y(r.body,"detail")??r.text??`HTTP ${r.status}`}}async function $r(e){let t=`${e.baseUrl}/test/${encodeURIComponent(e.testId)}/commit`,r={commit_id:e.body.commitId,from_commit_id:e.body.fromCommitId,commit_message:e.body.commitMessage,total_steps:e.body.totalSteps};e.body.timeTaken!==void 0&&(r.time_taken=e.body.timeTaken),e.body.objectives!==void 0&&(r.objectives=e.body.objectives),e.body.testInstanceId!==void 0&&(r.test_instance_id=e.body.testInstanceId),e.body.trigger!==void 0&&(r.trigger=e.body.trigger);let n=await Vt(t,r,e.auth);return n.ok?{ok:!0,testId:Y(n.body,"test_id")??e.testId,testcaseId:Y(n.body,"testcase_id")??"",projectId:Y(n.body,"project_id"),isTestCaseDeleted:typeof n.body?.is_test_case_deleted=="boolean"?n.body.is_test_case_deleted:void 0}:{ok:!1,...Ai(n)}}function Ai(e){let t=Y(e.body,"error")??Y(e.body,"code")??"",r=Y(e.body,"message")??Y(e.body,"detail")??e.text??`HTTP ${e.status}`,n;return e.status===0?n="network":e.status===401||e.status===403?n="auth":e.status===409&&t==="PlaygroundBaseCommitMismatch"?n="base_mismatch":e.status===409&&t==="PlaygroundCommitLockMismatch"?n="lock_mismatch":e.status===409?n="expired":e.status===422?n="not_found":e.status>=500||e.status===408||e.status===429?n="network":n="other",{reason:n,httpStatus:e.status,message:r}}async function je(e){let t=`${e.baseUrl}/test/${encodeURIComponent(e.testId)}/commit`,r={discard:!0,commit_id:e.body.commitId,from_commit_id:e.body.fromCommitId,commit_message:"(discarded)",total_steps:1},n=await Vt(t,r,e.auth);return n.ok?{ok:!0}:{ok:!1,reason:Y(n.body,"error")??"other",httpStatus:n.status,message:Y(n.body,"message")??Y(n.body,"detail")??n.text??`HTTP ${n.status}`}}async function Vt(e,t,r){let n=null;for(let o=1;o<=Ur;o++){let s=new AbortController,l=setTimeout(()=>s.abort(),Ei);try{let p=await X(e,{method:"POST",headers:{Authorization:Tt(r.username,r.accessKey),"Content-Type":"application/json",Accept:"application/json"},...t!==void 0?{body:JSON.stringify(t)}:{},signal:s.signal});clearTimeout(l);let i=await p.text(),c=null;if(i)try{c=JSON.parse(i)}catch{}let v=p.status>=500||p.status===408||p.status===429;if(p.ok||!v)return{ok:p.ok,status:p.status,body:c,text:i};if(o<Ur){await ps(fs[o-1]??1e3);continue}return{ok:!1,status:p.status,body:c,text:i}}catch(p){if(clearTimeout(l),n=p,o<Ur){await ps(fs[o-1]??1e3);continue}}}return{ok:!1,status:0,body:null,text:n?.message??"exhausted retries"}}function ps(e){return new Promise(t=>setTimeout(t,e))}function Y(e,t){if(typeof e!="object"||e===null)return;let r=e[t];return typeof r=="string"?r:void 0}var xi=60*1e3,hs="lock-heartbeat",Ae=new Map,ft=null,Pi={register:(e,t)=>Lt(e,t),deregister:e=>zn(e),cleanup:(e,t)=>Wn(e,t),remoteLogger:null};function ys(e){if(e!==void 0){let t=Ae.get(e);t!==void 0&&(clearInterval(t),Ae.delete(e));return}for(let t of Ae.values())clearInterval(t);Ae.clear()}function Kt(e){if(Ae.has(e.testId))return;let t=e.lifecycle??Pi,r=setInterval(async()=>{let n=await gs({baseUrl:e.baseUrl,testId:e.testId,auth:e.auth});if(!n.ok){let o=n.expired?"session expired":n.message;process.stderr.write(`[lock] heartbeat failed (${e.testId}): ${o}; continuing run
|
|
12
|
-
`)}},xi);Ae.set(e.testId,r),ft===null&&(ft=t,t.register(hs,()=>ys()))}function ye(e){Ae.size!==0&&(ys(e),Ae.size===0&&ft!==null&&(ft.deregister(hs),ft=null))}import{readFileSync as bs,readdirSync as vs,existsSync as Fe,promises as Br}from"fs";import{join as ue}from"path";async function Ti(e,t){let r=ue(e,"steps",`${t.ordinal}-${t.id}`),n,o=null,s=[];try{n=JSON.parse(await Br.readFile(ue(r,"step.json"),"utf8")),o=n.action_id??null,Array.isArray(n.analyze_action_ids)&&(s=n.analyze_action_ids.filter(l=>typeof l=="string"))}catch{}if(typeof n?.screenshot=="string"&&/^screenshot\.(?:png|jpg)$/i.test(n.screenshot)){let l=n.screenshot;try{return{png:await Br.readFile(ue(r,l)),filename:l,actionId:o,analyzeActionIds:s}}catch{}}for(let l of["screenshot.png","screenshot.jpg"])try{return{png:await Br.readFile(ue(r,l)),filename:l,actionId:o,analyzeActionIds:s}}catch{}return null}function tl(){let e=[];return{track:t=>{e.push(t.catch(()=>{}))},settle:async()=>{await Promise.all(e)}}}async function ws(e,t,r,n){try{let o=await Ti(e,t);if(!o){n("warn","SCREENSHOT_SKIP","Pack step folder or screenshot not found",{ordinal:t.ordinal,id:t.id,reason:"pack_step_not_found"});return}let s=new Set;o.actionId&&s.add(o.actionId);for(let l of o.analyzeActionIds)s.add(l);if(s.size===0){n("warn","SCREENSHOT_SKIP","No action_id in step.json",{ordinal:t.ordinal,id:t.id,reason:"no_action_id"});return}for(let l of s)r.enqueue(l,o.png);n("info","SCREENSHOT_ENQUEUED","Screenshot enqueued",{ordinal:t.ordinal,id:t.id,action_id:o.actionId,action_ids:[...s],screenshot:o.filename,size:o.png.length})}catch(o){n("error","SCREENSHOT_DISPATCH_ERROR","Screenshot dispatch error",{ordinal:t.ordinal,id:t.id,error:o instanceof Error?o.message:String(o)})}}function Is(e,t,r,n,o,s){try{let l=ue(e,"runs",String(t),"run-test");if(!Fe(l)){o("warn","SCREENSHOT_SKIP","Runs dir not found",{step_index:r,reason:"runsDir_not_found",path:l});return}let p=l;if(s){let E=ue(l,`child-${s}`);if(!Fe(E)){o("warn","SCREENSHOT_SKIP","Child dir not found",{step_index:r,child_id:s,reason:"child_dir_not_found",path:E});return}let C=vs(E).filter(d=>Fe(ue(E,d,"screenshots")));if(C.length===0){o("warn","SCREENSHOT_SKIP","No screenshots dir under child",{step_index:r,child_id:s,reason:"no_child_screenshots_dir"});return}p=ue(E,C[0])}else if(!Fe(ue(l,"screenshots"))){let E=vs(l).filter(C=>Fe(ue(l,C,"screenshots")));if(E.length===0){o("warn","SCREENSHOT_SKIP","No screenshots dir found",{step_index:r,reason:"no_screenshots_dir"});return}p=ue(l,E[0])}let i=ue(p,"screenshots",`step_${String(r).padStart(3,"0")}.png`);if(!Fe(i)){o("warn","SCREENSHOT_SKIP","Screenshot not found",{step_index:r,child_id:s,reason:"screenshot_not_found",path:i});return}let c=ue(l,"actions.ndjson");if(!Fe(c)){o("warn","SCREENSHOT_SKIP","NDJSON not found",{step_index:r,reason:"ndjson_not_found"});return}let v=bs(c,"utf-8").trim().split(`
|
|
13
|
-
`),f=v[v.length-1];if(!f){o("warn","SCREENSHOT_SKIP","NDJSON empty",{step_index:r,reason:"ndjson_empty"});return}let k=JSON.parse(f).action_id;if(!k){o("warn","SCREENSHOT_SKIP","No action_id in NDJSON",{step_index:r,reason:"no_action_id"});return}let T=bs(i);n.enqueue(k,T),o("info","SCREENSHOT_ENQUEUED","Screenshot enqueued",{step_index:r,child_id:s,action_id:k,size:T.length})}catch(l){o("error","SCREENSHOT_DISPATCH_ERROR","Screenshot dispatch error",{step_index:r,error:l instanceof Error?l.message:String(l)})}}import{dirname as Di,join as Li}from"path";function Ss(e,t,r){let n=e.total_runs??1,o=e.run_dir,s,l;if(n>1&&o){let p=Di(o);s=Array.from({length:n},(i,c)=>Li(p,String(t+c))),r&&r.length===n&&(l=r)}return{allRunDirs:s,flowObjectives:l}}function ks(e,t,r,n){return{index:r,objective:t,summary:e.summary,oneLiner:e.one_liner,status:e.status,resultCode:e.result_code,reasonCode:e.reason_code,perFlowMetadata:e.per_flow_metadata,context:e.context??{memory:{},variables:{},pointer:""},run_dir:e.run_dir,run_dirs:n.allRunDirs,flow_objectives:n.flowObjectives}}var Ht=class{constructor(t){this.resolved=t;this.outcomes=t.rootSteps.map(r=>({rootStepIndex:r.index,status:"skipped"}))}outcomes;skipRoot=null;overallHalted=!1;shouldRunFlatStep(t){if(this.overallHalted)return!1;let r=t.trace[0].stepIndex;return!(this.skipRoot!==null&&r===this.skipRoot)}recordStep(t,r){let n=t.trace[0].stepIndex,o=this.outcomes.find(i=>i.rootStepIndex===n),s=this.resolved.rootSteps.find(i=>i.index===n),l=s.body.kind!=="objective";return l&&(o.refKind="import",o.refLabel=s.body.path,o.inlinedCount=(o.inlinedCount??0)+1,o.duration_s=(o.duration_s??0)+r.duration_s),r.status==="passed"?(l?o.status!=="failed"&&(o.status="passed"):(o.status="passed",o.duration_s=r.duration_s),{continueOverall:!0}):t.optional?(o.softFailures=o.softFailures??[],o.softFailures.push({subStepIndex:t.trace[t.trace.length-1].stepIndex,reason:r.reason}),{continueOverall:!0}):(o.status="failed",o.duration_s=l?o.duration_s:r.duration_s,o.failedSubStepIndex=l?t.trace.slice(1).map(i=>i.stepIndex):void 0,o.reason=r.reason,this.skipRoot=n,s.optional??!1?(o.softFailed=!0,{continueOverall:!0}):(this.overallHalted=!0,{continueOverall:!1}))}snapshotOutcomes(){return[...this.outcomes]}snapshot(){return{outcomes:this.outcomes.map(t=>({...t,softFailures:t.softFailures?[...t.softFailures]:void 0})),skipRoot:this.skipRoot,overallHalted:this.overallHalted}}rollback(t){this.outcomes=t.outcomes.map(r=>({...r,softFailures:r.softFailures?[...r.softFailures]:void 0})),this.skipRoot=t.skipRoot,this.overallHalted=t.overallHalted}finalize(t={}){let r=t.cancelled||this.outcomes.some(o=>o.status==="failed"&&!o.softFailed)?"failed":"passed",n=this.outcomes.reduce((o,s)=>o+(s.duration_s??0),0);return{overallStatus:r,outcomes:this.outcomes,totalDurationS:n}}};var al=He;function Mr(e){if(!e)return null;let t=e.trim();return t?/^https?:\/\//i.test(t)?t:`https://${t}`:null}function _s(e){return Mr(e.flag)??Mr(e.frontmatter)??(e.configDefault&&e.configDefault!==He?Mr(e.configDefault):null)}function Rs(e){return e.resolvedUrl!==null?!1:!((!!e.local||!!e.allowMissingUrl)&&!e.isTTY)}import{spawn as Oi}from"child_process";async function Es(e,t,r=100){let n=`${e.replace(/\/+$/,"")}/json/version`,o=await X(n);if(!o.ok)throw new Error(`CDP /json/version returned ${o.status}`);let s=await o.json();if(!s.webSocketDebuggerUrl)throw new Error("CDP /json/version missing webSocketDebuggerUrl");let l=new Bn(s.webSocketDebuggerUrl);await new Promise((h,R)=>{l.once("open",h),l.once("error",R)});let p=1,i=new Map;l.on("message",h=>{let R;try{R=JSON.parse(h.toString())}catch{return}if(R.id==null)return;let K=i.get(R.id);K&&(i.delete(R.id),R.error?K.reject(new Error(R.error.message)):K.resolve(R.result))});function c(h,R){let K=p++;return new Promise((Pe,se)=>{i.set(K,{resolve:te=>Pe(te),reject:se});let ie={id:K,method:h};R&&(ie.params=R),l.send(JSON.stringify(ie))})}let f=(await c("Target.getTargets")).targetInfos.find(h=>h.type==="page");if(!f)throw l.close(),new Error("CDP: no page target found");let k=(await c("Browser.getWindowForTarget",{targetId:f.targetId})).windowId,T="",E=!1,C=null,d=!1;l.on("close",()=>{d=!0}),l.on("error",()=>{d=!0});async function F(){if(!E){if(d){E=!0;return}try{let R=(await c("Browser.getWindowBounds",{windowId:k})).bounds,K=`${R.left}:${R.top}:${R.width}:${R.height}`;K!==T&&(T=K,t({left:R.left,top:R.top,width:R.width,height:R.height}))}catch{}E||(C=setTimeout(F,r))}}return F(),{stop(){if(!E){E=!0,C&&clearTimeout(C);try{l.close()}catch{}}}}}var ji=new Set(["1","true","yes"]);function Vr(e){if(e?.headless)return null;let t=process.env.KANE_CLI_DISABLE_MARKER;if(t!=null&&ji.has(t.toLowerCase()))return null;let r=jt();if(!r)return null;let n=[...r.args,"overlay"];e?.text&&n.push(e.text);let o;try{o=Oi(r.cmd,n,{cwd:r.cwd,stdio:["pipe","ignore","ignore"],detached:!1,windowsHide:!0})}catch{return null}o.stdin?.on("error",()=>{});let s=!1;o.on("exit",()=>{s=!0}),o.on("error",()=>{s=!0});function l(c){if(!(s||!o.stdin||o.stdin.destroyed))try{o.stdin.write(JSON.stringify(c)+`
|
|
14
|
-
`)}catch{}}e?.chromePid&&e.chromePid>0&&l({type:"chrome_pid",pid:e.chromePid});let p=null;e?.cdpEndpoint&&Es(e.cdpEndpoint,c=>l({type:"bounds",...c})).then(c=>{p=c.stop}).catch(()=>{});let i=!1;return{setRunActive(c){i||l({type:"run_active",active:c})},setStepText(c){if(i)return;let v=c.trim();v&&l({type:"step_text",text:v})},setStepComplete(){i||l({type:"step_complete"})},kill(){if(!i){i=!0,p?.();try{o.stdin?.end()}catch{}try{o.kill("SIGTERM")}catch{}}}}}function Cs(e,t,r){return`${e}/projects/${t}/test-cases/${r}`}function Gt(e,t,r,n){return`${Cs(e,t,r)}/dashboard/share/${n}?type=summary&agentView=true&fqdn=summary-page`}function As(e,t,r,n){if(!(!t||!r||!n))return Gt(e,t,r,n)}function xs(e,t,r){return`${Cs(e,t,r)}/dashboard?type=summary&agentView=true&fqdn=summary-page`}import{mkdtempSync as Gi,rmSync as qi}from"fs";import{join as zi}from"path";import{tmpdir as Wi}from"os";import{readFileSync as Fi}from"fs";var Ui="wss://cdp.lambdatest.com/playwright",Ni="1.57.0",$i=new Set(["chrome","microsoftedge","pw-chromium"]),Bi=e=>e==="true"||e==="1",Mi="KANE_CLI_GRID",Kr="KANE_CLI_GRID_CAPS";function xe(e=process.env){return Bi((e[Mi]??"").trim().toLowerCase())}function Vi(){return{browserName:"Chrome",browserVersion:"latest","LT:Options":{platform:"linux",resolution:"1920x1080",video:!0,console:!0,network:!1,"network.full.har":!1,"network.http2":!0,w3c:!0,plugin:"kane-cli",project:"KaneAI-CLI",idleTimeout:1800,hideInternalCommandLogs:!0,"goog:chromeOptions":["--enable-logging","--disable-notifications","--no-sandbox","--log-level=0","--ignore-certificate-errors","--disable-blink-features=AutomationControlled","--password-store=basic","--safebrowsing-disable-auto-update","--disable-sync"]}}}function Ki(e=process.env){let t=(e[Kr]??"").trim();if(!t)return Vi();let r;try{r=JSON.parse(Fi(t,"utf8"))}catch(s){throw new Error(`${Kr}: cannot read grid capabilities at ${t}: ${s.message}`)}let n=r,o=n?.["LT:Options"];if(!n||typeof n!="object"||!o||typeof o!="object"||Array.isArray(o))throw new Error(`${Kr}: ${t} is not a grid capability object (needs "LT:Options")`);return{browserName:String(n.browserName||"Chrome"),browserVersion:String(n.browserVersion||"latest"),"LT:Options":{...o}}}function Ps(e,t=process.env){let r=Ki(t);if(!$i.has(r.browserName.toLowerCase()))throw new Error(`LT grid browser "${r.browserName}" is not supported by kane-cli (it drives Chromium: Chrome or Edge)`);let n=r["LT:Options"];n.user=e.username,n.accessKey=e.accessKey,n.build=t.BUILD||n.build||"kane-cli",n.playwrightClientVersion=Ni,n.name||(n.name=e.name),!n["tms.tc_id"]&&e.tcId&&(n["tms.tc_id"]=e.tcId);let o=Hi(n.customHeaders,t);return o?n.customHeaders=o:delete n.customHeaders,{browserName:r.browserName,browserVersion:r.browserVersion,"LT:Options":n}}function Hi(e,t){if(!e||typeof e!="object"||Array.isArray(e))return;let r={};for(let[n,o]of Object.entries(e))typeof o=="string"&&(r[n]=o.replace(/\{\{\s*([^}]+?)\s*\}\}/g,(s,l)=>{let p=l.split(".").pop()??l,i=t[p];return i===void 0?(process.stderr.write(`warn: LT grid custom header ${n}: ${s} has no value
|
|
15
|
-
`),s):i}));return Object.keys(r).length?r:void 0}function Ts(e,t=process.env){let r=(t.HYE_HUB??"").trim().replace(/^[a-z]+:\/\//i,"").replace(/^[^@/]*@/,"").split("/")[0];return`${r?`wss://${r}/playwright`:Ui}?capabilities=${encodeURIComponent(JSON.stringify(e))}`}async function Ds(e){if(!e)return null;if(e.basicAuth)return{username:e.basicAuth.username,accessKey:e.basicAuth.access_key};let t=e.resolvedCreds??await e.resolver.resolve().catch(()=>null);return t?.username&&t?.access_key?{username:t.username,accessKey:t.access_key}:null}async function Hr(e){if(e.cft)return{instance:null,tempDir:null};if(e.wsEndpoint)return{wsEndpoint:e.wsEndpoint,instance:null,tempDir:null};if(e.cdpEndpoint){let o=await X(`${e.cdpEndpoint}/json/version`);if(!o.ok)throw new Error(`CDP endpoint not reachable: ${e.cdpEndpoint} (${o.status})`);return{cdpEndpoint:e.cdpEndpoint,instance:null,tempDir:null}}if(xe()){if(!e.ltGrid)throw new Error("KANE_CLI_GRID is set but no LambdaTest credentials were resolved for the LT browser");let o=Ts(Ps(e.ltGrid));return process.stderr.write(`chrome: KANE_CLI_GRID \u2014 LT grid session "${e.ltGrid.name}"
|
|
16
|
-
`),{wsEndpoint:o,instance:null,tempDir:null,...e.startUrl?{startUrl:e.startUrl}:{}}}let t,r=null;if(e.config.chrome_profile_path)t=e.config.chrome_profile_path.replace("~",process.env.HOME??"~");else{r=Gi(zi(Wi(),"kane-clean-")),t=r;let o=r;Lt("tempDir",()=>{try{qi(o,{recursive:!0,force:!0})}catch{}})}let n=await eo({userDataDir:t,width:e.config.window_size.width,height:e.config.window_size.height,startUrl:e.startUrl,headless:e.headless});return{cdpEndpoint:n.cdpEndpoint,instance:n,tempDir:r}}async function Ls(e,t){if(e==="device"){let{device:r,appRef:n,appId:o}=await t.prepareDevice();return{kind:"device",device:r,...n?{appRef:n}:{},...o?{appId:o}:{}}}return{kind:"web",chrome:await t.prepareWeb()}}function xl(e,t={}){if(e.kind==="device")return pr(e.device.target);if(e.chrome.instance)return"chrome";if(t.cdpEndpoint)return"cdp";if(t.wsEndpoint)return"ws"}function Pl(e,t){if(!(e.kind!=="device"||e.device.target!=="simulator"))return t?Kn(t):void 0}function Tl(e){if(!(e.kind!=="device"||!pr(e.device.target)))return e.appRef??""}function Gr(e){let t={objective:e.objective,model:e.model,width:e.windowSize.width,height:e.windowSize.height,session_id:e.sessionId,run_index:e.runIndex,max_steps:e.maxSteps??30,headless:e.headless??!1};return e.conditions&&e.conditions.length>0&&(t.conditions=[...e.conditions]),e.url&&(t.url=e.url),e.requireStartUrl&&(t.require_start_url=!0),e.chrome.wsEndpoint?t.ws_endpoint=e.chrome.wsEndpoint:e.chrome.cdpEndpoint&&(t.cdp_endpoint=e.chrome.cdpEndpoint),e.auth.basicAuth?(t.username=e.auth.basicAuth.username,t.access_key=e.auth.basicAuth.access_key):e.auth.token&&(t.auth={type:"bearer",token:e.auth.token}),e.auth.resolvedCreds?.org_id&&(t.org_id=String(e.auth.resolvedCreds.org_id)),e.projectId&&(t.project_id=e.projectId),e.disableAskUser&&(t.disable_ask_user=!0),e.enableTaskSkills&&(t.enable_task_skills=!0),e.networkWs&&(t.network_ws=!0),e.networkSse&&(t.network_sse=!0),(e.bugDetection==="stop"||e.bugDetection==="continue")&&(t.bug_detection=e.bugDetection),e.variables&&Object.keys(e.variables).length>0&&(t.variables=e.variables),e.globalContext&&(t.global_context=e.globalContext),e.localContext&&(t.local_context=e.localContext),e.sessionContext&&(t.session_context=e.sessionContext),e.device&&(t.device=e.device),e.environmentId&&(t.environment_id=e.environmentId),e.evidence&&(t.evidence=$t(e.evidence.packTestDir,e.evidence.ordinalOffset)),t}import{existsSync as Yi,readFileSync as Ji}from"fs";import{join as Qi}from"path";var qt={max_retries:5,settle_ms:500,on_exhaust:"fail"},ze=class{constructor(t,r,n){this.steps=t;this.decisions=r;this.deps=n;for(let o=0;o<t.length;o++){let s=t[o];if(s.controlFlow!=="if"&&s.controlFlow!=="while")continue;let l=s.block,p=t.map((b,k)=>[b,k]).filter(([b])=>b.block?.id===l.id&&b.block.depth===l.depth),i=p.find(([b])=>b.block.branch===-1)[1],c=p.filter(([b])=>b.controlFlow!==void 0&&b.block.branch!==-1).map(([,b])=>b),v=c.filter(b=>t[b].controlFlow!=="else").map(b=>t[b].objective),f={kind:s.controlFlow,opener:o,closer:i,markers:c,conditions:v,hasElse:t[c[c.length-1]].controlFlow==="else"};this.blocks.set(o,f),this.closers.set(i,f)}}blocks=new Map;closers=new Map;skip=new Set;attempts=new Map;taken=new Map;whileRuns=new Map;static hasBlocks(t){return t.some(r=>r.block!==void 0)}reset(){this.skip.clear(),this.attempts.clear(),this.taken.clear(),this.whileRuns.clear()}outcomes(){let t={};for(let[n,o]of this.taken)t[this.steps[n].flatIndex]=o;let r={};for(let[n,o]of this.whileRuns)r[this.steps[n].flatIndex]={...o};return{taken:t,whileRuns:r}}range(t,r){let n=t.markers[r]+1,o=r+1<t.markers.length?t.markers[r+1]:t.closer,s=[];for(let l=n;l<o;l++)s.push(l);return s}skipBranch(t,r){for(let n of this.range(t,r))this.skip.add(n)}unskipBody(t){for(let r=t.opener+1;r<t.closer;r++)this.skip.delete(r)}async judge(t){let r=await this.deps.evaluate(t),n=r.findIndex(o=>o==null);return n!==-1||r.length<t.length?{fail:`condition could not be judged: ${t[n===-1?r.length:n]}`}:r}async before(t){if(this.skip.has(t))return{action:"skip"};let n=this.steps[t].controlFlow;if(n==="if"){let s=this.blocks.get(t),l=await this.judge(s.conditions);if("fail"in l)return{action:"fail",reason:l.fail};let p=l.findIndex(i=>i===!0);p===-1&&s.hasElse&&(p=s.markers.length-1),this.taken.set(t,p);for(let i=0;i<s.markers.length;i++)i!==p&&this.skipBranch(s,i);return{action:"structural"}}if(n==="while"){let s=this.blocks.get(t);this.attempts.set(t,0);let l=await this.judge(s.conditions);return"fail"in l?{action:"fail",reason:l.fail}:(this.whileRuns.set(t,{iterations:l[0]?1:0,condition_met:!l[0]}),l[0]||this.skipBranch(s,0),{action:"structural"})}if(n==="end-while"){let s=this.closers.get(t);if(!(s.opener+1===s.closer)&&this.skip.has(s.opener+1))return{action:"structural"};let p=this.deps.whileConfig(s.opener),i=(this.attempts.get(s.opener)??0)+1;this.attempts.set(s.opener,i);let c=this.whileRuns.get(s.opener)??{iterations:i,condition_met:!1};if(c.iterations=i,this.whileRuns.set(s.opener,c),i>=p.max_retries)return p.on_exhaust==="fail"?{action:"fail",reason:`while exhausted after ${i} iteration(s): ${s.conditions[0]}`}:{action:"structural"};await this.deps.sleep(p.settle_ms);let v=await this.judge(s.conditions);return"fail"in v?{action:"fail",reason:v.fail}:v[0]?(this.unskipBody(s),c.iterations=i+1,{action:"jump",to:s.opener+1}):(c.condition_met=!0,{action:"structural"})}if(n!==void 0)return{action:"structural"};let o=this.decisions[t];return o?.kind==="replay"&&o.unrecorded?{action:"author"}:{action:"run"}}};function qr(e){try{let t=$o(e),r=Fo(e.owningFile,e.trace[e.trace.length-1].stepIndex,t.slice(0,8)),n=Qi(r,"flows","0","actions.ndjson");if(!Yi(n))return null;let o=Ji(n,"utf8").split(`
|
|
17
|
-
`).find(s=>s.trim().length>0);return o?JSON.parse(o):null}catch{return null}}function zt(e){let t=qr(e);if(!t||t.action_type!=="while")return{...qt};let r=t.action_params??{};return{max_retries:typeof r.max_retries=="number"&&r.max_retries>0?r.max_retries:qt.max_retries,settle_ms:typeof r.settle_ms=="number"&&r.settle_ms>=0?r.settle_ms:qt.settle_ms,on_exhaust:typeof r.on_exhaust=="string"&&r.on_exhaust?r.on_exhaust:qt.on_exhaust}}import{readdirSync as Zi,readFileSync as js,existsSync as Fs}from"fs";import{join as Xi}from"path";function zr(e,t){let r=t.type==="parameter";return{value:typeof t.value=="number"?String(t.value):t.value,secret:t.secret??!1,syntax:t.syntax??(r?"${"+e+"}":`{{${e}}}`),...typeof t.type=="string"?{type:t.type}:{},...typeof t.description=="string"?{description:t.description}:{}}}function Os(e,t){if(!Fs(e))return{};let r={},n;try{n=Zi(e).filter(o=>o.endsWith(".json")).sort()}catch{return{}}for(let o of n)try{let s=js(Xi(e,o),"utf-8"),l=JSON.parse(s);if(l&&typeof l=="object")for(let[p,i]of Object.entries(l))i&&typeof i=="object"&&"value"in i&&(r[p]=zr(p,i))}catch{t?t("warn","VARIABLE_PARSE_FAILED","Skipping invalid variables file",{file:o}):process.stderr.write(`[variables] Warning: skipping invalid variables file: ${o}
|
|
18
|
-
`)}return r}function Us(e){if(!Fs(e))throw new Error(`Variables file not found: ${e}`);let t=js(e,"utf-8"),r=JSON.parse(t),n={};if(r&&typeof r=="object")for(let[o,s]of Object.entries(r))s&&typeof s=="object"&&"value"in s&&(n[o]=zr(o,s));return n}function Ns(e){let t;try{t=JSON.parse(e)}catch{throw new Error("Invalid --variables JSON")}let r={};if(t&&typeof t=="object")for(let[n,o]of Object.entries(t))o&&typeof o=="object"&&"value"in o&&(r[n]=zr(n,o));return r}function $s(e,t,r){let n=Os(e,r),o=Os(t,r);return{...n,...o}}var We=class{constructor(t){this.baseUrl=t}async pushSecret(t){let r=Tt(t.username,t.accessKey),n=await X(`${this.baseUrl}/logistics/v1.0/secrets/create`,{method:"PUT",headers:{Authorization:r,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({secretKey:t.secretKey,secretValue:t.secretValue,orgId:t.orgId,username:t.username,scope:"user",type:"user",accessKey:t.accessKey})});if(!n.ok)throw new Error(`Push secret failed: ${n.status} ${await n.text()}`)}static extractVariableKeys(t){let r=t.matchAll(/\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}/g),n=new Set;for(let o of r)n.add(o[1]);return[...n]}};var Ye=class extends Dt{constructor(t,r,n){super(t,{username:r,accessKey:n})}async upsertVariable(t){let r=t.environmentId??0,n=await X(`${this.baseUrl}/v1/variables`,{method:"POST",headers:this.headers(),body:JSON.stringify({name:t.name,value:String(t.value),type:"variable",value_type:"string",is_persist:t.isPersist??!1,environment_id:r})});if(n.ok){let i=await n.json().catch(()=>({}));if(i.type==="Success"&&i.id!=null)return{id:Number(i.id)||0}}let o=await X(`${this.baseUrl}/v1/variables/${encodeURIComponent(t.name)}?environment_id=${r}`,{method:"GET",headers:this.headers()});if(!o.ok)return{id:0};let l=(await o.json().catch(()=>({}))).data?.id;return l==null?{id:0}:(await X(`${this.baseUrl}/v1/variables/${l}`,{method:"PUT",headers:this.headers(),body:JSON.stringify({value:String(t.value),value_type:"string"})})).ok?{id:Number(l)||0}:{id:0}}};function Bs(e,t){if(Object.keys(e).length===0)return{};let r={};for(let[n,o]of Object.entries(e)){let s=o.syntax??`{{${n}}}`;ta(t,s)&&(r[n]=o)}return r}function ea(e){let t=e.trim();return t.startsWith("{{")&&t.endsWith("}}")?t.slice(2,-2).trim():t.startsWith("${")&&t.endsWith("}")?t.slice(2,-1).trim():t}function ta(e,t){if(!t||!e)return!1;if(e.includes(t))return!0;let r=ea(t);if(!r)return!1;let n=r.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`(?:\\{\\{|\\$\\{)\\s*${n}(?=\\s*\\}|[.\\[])`).test(e)}function Ms(e){let t=$s(e.globalDir,e.localDir,e.onLoadError),r=e.file?Us(e.file):{},n=e.inline?Ns(e.inline):{},o={...t,...r,...n,...e.parameters??{}},s=Object.keys(o).length>0,{variables:l,objective:p}=s?Ge(o,e.objective):{variables:{},objective:e.objective};return{raw:o,auteur:l,auteurObjective:p,...Wr(o)}}function Wr(e){let t=Object.entries(e),r=t.filter(([,o])=>dt(o)),n=t.filter(([,o])=>!dt(o));return{secretEntries:n.filter(([,o])=>o.secret),nonSecretEntries:n.filter(([,o])=>!o.secret),parameterEntries:r}}async function Vs(e){if(e.localMode)return{};let t=oe(e.env);if(e.variables.secretEntries.length>0){let n=new We(t.secretsBaseUrl);for(let[o,s]of e.variables.secretEntries)n.pushSecret({secretKey:o,secretValue:s.value,username:e.auth.username,accessKey:e.auth.access_key,orgId:e.orgId}).then(()=>e.log("info","SECRET_PUSH_OK","Secret pushed",{key:o})).catch(l=>e.log("error","SECRET_PUSH_FAILED","Secret push failed",{key:o,error:String(l)}))}let r={};if(e.variables.nonSecretEntries.length>0){let n=new Ye(t.tmsBaseUrl,e.auth.username,e.auth.access_key);for(let[o,s]of e.variables.nonSecretEntries)try{let l=await n.upsertVariable({name:o,value:s.value});r[o]=l.id,e.log("info","VAR_PUSH_OK","Variable pushed",{name:o,id:l.id})}catch(l){e.log("error","VAR_PUSH_FAILED","Variable push failed",{name:o,error:String(l)})}}return r}import{mkdirSync as ra,writeFileSync as na}from"fs";import{join as Ks}from"path";var Wt=class extends Dt{constructor(t,r,n){super(t,{username:r,accessKey:n})}async getDataset(t,r){let n=`/v1/dataset/${encodeURIComponent(t)}`,o=r?.versionId?`?version_id=${encodeURIComponent(r.versionId)}`:"",s=await X(`${this.baseUrl}${n}${o}`,{method:"GET",headers:this.headers()}),l=await s.text();if(!s.ok){let c=l.trim();try{let v=JSON.parse(l);typeof v.message=="string"&&v.message&&(c=v.message)}catch{}throw new Error(`GET ${n} failed: ${s.status} ${c}`)}let p;try{p=JSON.parse(l)}catch{throw new Error(`dataset ${t}: response is not JSON`)}let i=p;if(!i||!Array.isArray(i.headers)||!Array.isArray(i.rows))throw new Error(`dataset ${t}: response carries no headers / rows`);return i}};async function Hs(e){let{id:t,version:r,row:n}=e.selection,o=new Wt(e.tmsBaseUrl,e.auth.username,e.auth.access_key),s;try{s=await o.getDataset(t,r?{versionId:r}:void 0)}catch(f){throw new Error(`dataset ${t}: ${f.message}`)}let l=Ks(e.saveDir,"dataset"),p=Ks(l,`${t}.json`);try{ra(l,{recursive:!0}),na(p,JSON.stringify(s,null,2)+`
|
|
19
|
-
`,"utf8")}catch(f){e.log?.("warn","DATASET_SAVE_FAILED","Could not save the fetched dataset",{path:p,error:String(f)})}let i;try{i=io(s,n)}catch(f){throw new Error(`dataset ${t}: ${f.message}`)}let c=ao(s,i.row),v=typeof s.latest_version_id=="string"&&s.latest_version_id?s.latest_version_id:void 0;return e.log?.("info","DATASET_ROW_LOADED","Dataset row loaded as parameters",{dataset_id:t,row_id:i.id,row_index:i.index,columns:Object.keys(c)}),{selection:e.selection,dataset:s,rowIndex:i.index,rowId:i.id,versionId:v,externalId:mo(t,i.id,v),evidenceRecord:{dataset_id:t,dataset_name:typeof s.name=="string"&&s.name?s.name:null,dataset_version_id:v??null,row_id:i.id,row_index:i.index,columns:Object.keys(c),values:Object.fromEntries(Object.entries(c).map(([f,b])=>[f,b.value]))},parameters:c,testParams:lo(s,i.row),columns:new Set(Object.keys(c)),savedPath:p}}import{readFileSync as oa,existsSync as sa}from"fs";function Yr(e){if(!sa(e))return null;try{return oa(e,"utf-8").trim()||null}catch{return null}}var ia=()=>{};async function Gs(e,t,r){let n=t.log??ia,o=e.session.testId??null,s=null,l=null,p=null;if(!r.localMode&&t.performUpload)try{s=await t.performUpload(),s?.success&&(s.testId&&(o=s.testId),s.testcaseId&&e.session.setTestcaseId(s.testcaseId))}catch(i){n("error","FINALIZE_UPLOAD_ERROR","Upload pipeline threw",{error:String(i)})}if(t.renderFeedbackPrompt)try{l=await t.renderFeedbackPrompt(),l&&o&&t.submitFeedback&&t.submitFeedback(o,l).catch(i=>{n("error","FINALIZE_FEEDBACK_SUBMIT_ERROR","Feedback submit failed",{error:String(i)})})}catch(i){n("error","FINALIZE_FEEDBACK_RENDER_ERROR","Feedback prompt threw",{error:String(i)})}if(e.session.flushRecorder(),r.skipLocalWrites)n("info","FINALIZE_SKIP_LOCAL_WRITES","Skipping local writes (testmd flow handles via staging)");else if(r.sourcePath&&r.rootSteps&&r.outcomes){try{p=Cr({sourcePath:r.sourcePath,title:r.title,rootSteps:r.rootSteps,outcomes:r.outcomes,overallStatus:r.overallStatus,startedISO:r.startedISO,durationS:r.durationS,sessionId:e.session.sessionId})}catch(i){n("error","FINALIZE_RESULT_MD_ERROR","_Result.md write failed",{error:String(i)})}try{Rr({sourcePath:r.sourcePath,commitId:e.session.sessionId,testId:o??void 0,testcaseId:e.session.testcaseId??void 0,projectId:e.tuiConfig.project_id??void 0,folderId:e.tuiConfig.folder_id??void 0,orgId:e.session.orgId??void 0,sessionName:e.session.sessionName??ct(r.sourcePath),plan:e.session.plan??void 0,media:Pr({priorMetaPath:Se(r.sourcePath),recordFiles:xr(e.session.sessionDir)}),tcId:kr(r.sourcePath),environmentId:_r(r.sourcePath)})}catch(i){n("error","FINALIZE_META_WRITE_ERROR","meta.json write failed",{error:String(i)})}if(s?.codeExportDir)try{let i=Sr(e.tuiConfig.code_export?.language??"python",r.mobile);Tr(s.codeExportDir,Ir(r.sourcePath,i.framework,i.language))}catch(i){n("error","FINALIZE_CODE_COPY_ERROR","code-export copy failed",{error:String(i)})}}else if(e.session.recorder?.lastWrittenPath){let i=e.session.recorder.lastWrittenPath,c=e.session.getFlows(),v=c.map((k,T)=>({index:T+1,heading:`Step ${T+1}`,verifies:[],headingLine:0,body:{kind:"objective",text:k.objective}})),f=c.map((k,T)=>({rootStepIndex:T+1,status:k.status==="passed"?"passed":k.status==="failed"?"failed":"skipped",duration_s:k.duration,reason:k.reason})),b=f.some(k=>k.status==="failed")?"failed":"passed";try{p=Cr({sourcePath:i,title:e.session.sessionName??"Session",rootSteps:v,outcomes:f,overallStatus:b,startedISO:e.session.startedAt,durationS:f.reduce((k,T)=>k+(T.duration_s??0),0),sessionId:e.session.sessionId})}catch(k){n("error","FINALIZE_TUI_RESULT_MD_ERROR","TUI _Result.md write failed",{error:String(k)})}try{Rr({sourcePath:i,commitId:e.session.sessionId,testId:o??void 0,testcaseId:e.session.testcaseId??void 0,sessionName:e.session.sessionName??void 0,projectId:e.tuiConfig.project_id??void 0,folderId:e.tuiConfig.folder_id??void 0,plan:e.session.plan??void 0,media:Pr({priorMetaPath:Se(i),recordFiles:xr(e.session.sessionDir)}),tcId:kr(i),environmentId:_r(i)})}catch(k){n("error","FINALIZE_TUI_META_WRITE_ERROR","TUI meta.json write failed",{error:String(k)})}if(s?.codeExportDir)try{let k=Sr(e.tuiConfig.code_export?.language??"python",r.mobile);Tr(s.codeExportDir,Ir(i,k.framework,k.language))}catch(k){n("error","FINALIZE_TUI_CODE_COPY_ERROR","TUI code-export copy failed",{error:String(k)})}e.session.recorder.lastCollisionSuffixed&&process.stderr.write(`Saved to ${i} (renamed: ${e.session.sessionName}_test.md already existed)
|
|
20
|
-
`)}try{t.runCleanup?.()}catch(i){n("error","FINALIZE_CLEANUP_ERROR","Cleanup hook threw",{error:String(i)})}try{await e.session.finish("complete")}catch(i){n("error","FINALIZE_SESSION_FINISH_ERROR","session.finish threw",{error:String(i)})}return{uploadResult:s,feedbackChoice:l,resultMdPath:p}}import{readFileSync as Qr,writeFileSync as Zr,existsSync as Qs}from"fs";function qs(e,t,r){if(r.forceAuthor)return"re-recorded from scratch";if(r.retryTriggered)return"re-recorded after retry";if(t.length>0&&t.every(l=>l.kind==="author"&&l.reason==="no-result-md"))return"initial recording";if(t.length>0&&t.every(l=>l.kind==="replay"))return r.wantsPush?"re-recorded (no source changes)":"no changes";let n=[];for(let l=0;l<t.length;l++){let p=t[l];if(!p||p.kind!=="author"||p.reason==="downstream-of-divergence"||p.reason==="no-result-md")continue;let i=aa(e,e.steps[l]);switch(p.reason){case"structure-mismatch":n.push(`added/removed: ${i}`);break;case"md5-mismatch":n.push(`modified: ${i}`);break;case"missing-recording":n.push(`re-recorded: ${i}`);break;case"recorded-failed":n.push(`re-authored after failure: ${i}`);break}}if(n.length===0)return"automated commit";let o=n.filter((l,p)=>p===0||n[p-1]!==l),s=o.slice(0,3).join("; ");return o.length>3?`${s}; +${o.length-3} more`:s}function aa(e,t){if(!t)return"unknown step";let r=t.trace[0]?.stepIndex;if(r==null)return"unknown step";let o=e.rootSteps[r-1]?.heading?.trim()??"";return t.trace.length>1?o?`imported step in "${o}"`:`imported step ${r}`:o||`step ${r}`}import{existsSync as la}from"fs";function da(e){return!!e&&typeof e.module_id=="string"&&e.module_id.trim()!==""}function Jr(e){return`warn: ${e}: *_module.md without a cloud meta.json module_id \u2014 it ran as a module, but its steps upload as plain blocks (no module_block)`}function zs(e,t,r={}){let n=r.tapePresent??(b=>la(jo(b))),o=r.readMeta??(b=>he(b)),s=r.onMissingIdentity??(b=>{process.stderr.write(`${Jr(b)}
|
|
21
|
-
`)}),l=new Set,p=new Set(e.unitFiles.filter(b=>b.kind==="module").map(b=>b.file)),i=new Map,c=[];for(let b of e.steps){let k=b.flatIndex,T,E="";for(let C=0;C+1<b.trace.length;C++){let d=b.trace[C],F=b.trace[C+1].file;if(E=E?`${E}>${d.file}#${d.stepIndex}`:`${d.file}#${d.stepIndex}`,!p.has(F))continue;let h=i.get(E);if(!h){let R=o(F);if(!da(R)){l.has(F)||(l.add(F),s(F));continue}h={key:E,file:F,meta:R,flatFrom:k,flatTo:k,dirty:!1,children:[]},i.set(E,h),(T?T.children:c).push(h)}h.flatFrom=Math.min(h.flatFrom,k),h.flatTo=Math.max(h.flatTo,k),T=h}}let v=b=>{for(let k=b.flatFrom;k<=b.flatTo;k++)if(t.has(k))return!0;return!1},f=b=>{for(let k of b)k.dirty=n(k.file)&&v(k),f(k.children)};return f(c),c}function Ws(e){let t={};for(let r of e)for(let n=0;n<Math.max(1,r.totalRunDirs);n++)t[r.runIndex+n]=r.testmdStepIndex;return t}function Js(e,t){let r=e.steps,n=[],o=[];for(let s=0;s<r.length;s++){let l=r[s],p=l.controlFlow;if(p==="if"||p==="while"){let i=ca(l,p,t);(o.length?o[o.length-1].children:n).push(i),o.push(i);continue}if(p==="elif"||p==="else"){let i=o[o.length-1];Ys(i,l.flatIndex-1),i.branches.push({branch_type:p,condition:p==="else"?"":l.objective,flatFrom:l.flatIndex+1,flatTo:l.flatIndex,taken:!1});continue}if(p==="end-if"||p==="end-while"){let i=o.pop();Ys(i,l.flatIndex-1),i.flatTo=l.flatIndex,ua(i,t);continue}}return n}function ca(e,t,r){let n=qr(e),o=n?.action_params??{},s=typeof o.block_id=="string"?o.block_id:"",l=n?.action_instruction&&n.action_instruction.trim()||e.objective,p={kind:t,blockId:s,instruction:l,flatFrom:e.flatIndex,flatTo:e.flatIndex,branches:[{branch_type:"if",condition:e.objective,flatFrom:e.flatIndex+1,flatTo:e.flatIndex,taken:!1}],children:[]};if(t==="while"){let i=zt(e),c=r?.whileRuns[e.flatIndex];p.whileCfg={...i,iterations:c?.iterations??0,condition_met:c?.condition_met??!1}}return p}function Ys(e,t){let r=e.branches[e.branches.length-1];r.flatTo=t}function ua(e,t){if(e.kind==="while"){e.branches[0].taken=(e.whileCfg?.iterations??0)>0;return}let r=t?.taken[e.flatFrom];typeof r=="number"&&r>=0&&r<e.branches.length&&(e.branches[r].taken=!0)}function ma(e,t){if(!(!e.shouldReplaceLocalOutput||!e.resolvedTest||!e.sourcePath||!e.stepRunRecords||!e.outcomes||!e.overallStatus))return async()=>{let{changedUnitFiles:r,legacySweep:n}=await Zo({resolvedTest:e.resolvedTest,sessionDir:e.session.sessionDir,stepRunRecords:e.stepRunRecords,outcomes:e.outcomes,overallStatus:e.overallStatus,startedISO:e.startedISO??new Date().toISOString(),durationS:e.durationS??0,sessionId:e.session.sessionId,commitId:e.fromCommitId??"",tmsIds:e.tmsIds??{},codeExportDir:e.codeExportDir,packTestDir:e.evidence?.packTestDir??e.evidenceRead?.packTestDir,authoredFlatIdx:new Set(e.authoredFlatIdx??[])});t.files=r;for(let o of r){let s=ee(o);if(Qs(`${s}.staging`)){Uo(s);let l=n.find(p=>p.unitFile===o);l&&Xo(l.dirs)}}}}function fa(e,t){if(!e.shouldCommit||e.isFirstRun||!e.tmsBaseUrl||!e.testId||!e.fromCommitId||!e.newCommitId||!e.basicAuth||!e.resolvedTest||!e.decisions)return;let r=(o,s)=>Bt({sourcePath:o,testId:s,sessionId:e.session.sessionId,commitId:e.newCommitId,identityOverride:{commit_id:e.newCommitId},controller:new De(oe(e.env).controllerBaseUrl,{username:e.basicAuth.username,accessKey:e.basicAuth.access_key})}),n=(o,s)=>e.onAgentEvent?.({type:"test_md_bundle_sync",status:s.ok?"ok":"failed",commit_id:e.newCommitId,path:o,...s.ok?{bytes:s.bytes}:{stage:s.stage}});return async()=>{let o;if(e.testmdSync===!1)e.log?.("info","BUNDLE_SYNC_SKIPPED","testmd bundle sync skipped",{reason:"flag",commit_id:e.newCommitId});else{if(!e.sourcePath){let f="bundle sync requires a source path";return e.log?.("warn","BUNDLE_SYNC_FAILED","testmd bundle sync failed",{commit_id:e.newCommitId,stage:"collect",error:f}),{ok:!1,reason:"bundle_sync_failed",message:f}}if(o=await r(e.sourcePath,e.testId),!o.ok)return e.log?.("warn","BUNDLE_SYNC_FAILED","testmd bundle sync failed",{commit_id:e.newCommitId,stage:o.stage,error:o.error}),n(e.sourcePath,o),process.stderr.write(` \u26A0 bundle sync failed (${o.stage}): ${o.error} \u2014 commit not attempted; the local tape is kept, run again with --push once fixed
|
|
22
|
-
`),{ok:!1,reason:"bundle_sync_failed",message:o.error}}let s=qs(e.resolvedTest,e.decisions,{wantsPush:e.wantsPush??!1,retryTriggered:e.retryTriggered??!1,forceAuthor:e.forceAuthor??!1}),l=e.resolvedTest.steps.map(f=>f.objective).filter(f=>typeof f=="string"&&f.length>0).slice(0,50),p=e.forceAuthor?"always_reauthor":e.retryTriggered?"adaptive_heal":void 0,i=Io().testInstanceId,c={...i?{testInstanceId:i}:{},...p?{trigger:p}:{}},v=await $r({baseUrl:`${e.tmsBaseUrl}/kane-cli/v1`,testId:e.testId,body:{commitId:e.newCommitId,fromCommitId:e.fromCommitId,commitMessage:s,totalSteps:e.resolvedTest.steps.length,timeTaken:Math.round(e.durationS??0),objectives:l,...c},auth:{username:e.basicAuth.username,accessKey:e.basicAuth.access_key}});if(v.ok&&e.commitBox&&(e.commitBox.committed=!0,e.commitBox.testcaseId=v.testcaseId||void 0),v.ok&&o?.ok&&e.sourcePath&&(e.log?.("info","BUNDLE_SYNC_OK","testmd bundle pushed",{commit_id:e.newCommitId,bytes:o.bytes}),n(e.sourcePath,o)),v.ok&&e.sourcePath){let f=Se(e.sourcePath);try{let b=JSON.parse(Qr(f,"utf8"));b.commit_id=e.newCommitId,Zr(f,JSON.stringify(b,null,2)+`
|
|
23
|
-
`,"utf8")}catch(b){process.stderr.write(`warn: failed to update meta.json commit_id: ${b.message}
|
|
24
|
-
`)}}if(v.ok)for(let f of e.unitLocks??[]){if(!t.files.includes(f.file)){await je({baseUrl:`${e.tmsBaseUrl}/kane-cli/v1`,testId:f.testId,body:{commitId:e.newCommitId,fromCommitId:f.fromCommitId},auth:{username:e.basicAuth.username,accessKey:e.basicAuth.access_key}}),ye(f.testId);continue}let b;if(e.testmdSync!==!1&&(b=await r(f.file,f.testId),!b.ok)){e.log?.("warn","BUNDLE_SYNC_FAILED","unit bundle sync failed",{commit_id:e.newCommitId,path:f.file,stage:b.stage,error:b.error}),n(f.file,b),process.stderr.write(`warn: unit bundle sync failed (${f.file}): ${b.stage}: ${b.error} \u2014 unit not committed
|
|
25
|
-
`),await je({baseUrl:`${e.tmsBaseUrl}/kane-cli/v1`,testId:f.testId,body:{commitId:e.newCommitId,fromCommitId:f.fromCommitId},auth:{username:e.basicAuth.username,accessKey:e.basicAuth.access_key}}),ye(f.testId);continue}let k=e.resolvedTest.steps.filter(C=>C.owningFile===f.file),T=k.map(C=>C.objective).filter(C=>typeof C=="string"&&C.length>0).slice(0,50),E=await $r({baseUrl:`${e.tmsBaseUrl}/kane-cli/v1`,testId:f.testId,body:{commitId:e.newCommitId,fromCommitId:f.fromCommitId,commitMessage:`healed via importer ${e.sourcePath??""}`,totalSteps:k.length,timeTaken:0,objectives:T,...c},auth:{username:e.basicAuth.username,accessKey:e.basicAuth.access_key}});if(E.ok){let C=Se(f.file);try{let d=JSON.parse(Qr(C,"utf8"));d.commit_id=e.newCommitId,Zr(C,JSON.stringify(d,null,2)+`
|
|
26
|
-
`,"utf8")}catch(d){process.stderr.write(`warn: failed to update unit meta commit_id (${f.file}): ${d.message}
|
|
27
|
-
`)}b?.ok&&(e.log?.("info","BUNDLE_SYNC_OK","unit bundle pushed",{commit_id:e.newCommitId,path:f.file,bytes:b.bytes}),n(f.file,b))}else process.stderr.write(`warn: unit self-commit failed (${f.file}): ${E.reason??""} ${E.message??""} \u2014 unit lock released
|
|
28
|
-
`),e.log?.("warn","UNIT_COMMIT_FAILED","Imported unit commit failed; lock discarded",{path:f.file,test_id:f.testId,reason:E.reason,message:E.message}),await je({baseUrl:`${e.tmsBaseUrl}/kane-cli/v1`,testId:f.testId,body:{commitId:e.newCommitId,fromCommitId:f.fromCommitId},auth:{username:e.basicAuth.username,accessKey:e.basicAuth.access_key}}),ye(f.testId)}return v.ok?{...v,...c}:v}}function pa(e){if(!(!e.isFirstRun||!e.sourcePath))return async t=>{if(!e.sourcePath)return;let r=Se(e.sourcePath);try{let n=Qs(r)?JSON.parse(Qr(r,"utf8")):{};e.session.sessionId&&(n.commit_id=e.session.sessionId),t&&(n.testcase_id=t),e.tmsIds?.testId&&(n.test_id=e.tmsIds.testId),e.tmsIds?.projectId&&(n.project_id=e.tmsIds.projectId),e.tmsIds?.folderId&&(n.folder_id=e.tmsIds.folderId),e.tmsIds?.orgId&&(n.org_id=e.tmsIds.orgId),e.tmsIds?.sessionName&&(n.session_name=e.tmsIds.sessionName),Zr(r,JSON.stringify(n,null,2)+`
|
|
29
|
-
`,"utf8")}catch(n){process.stderr.write(`warn: failed to update meta.json after endTest: ${n.message}
|
|
30
|
-
`)}}}function ga(e){let t=e.decisions,r=e.resolvedTest?.steps,n=e.sourcePath;if(!t||!r||!n)return;let o=[];if(t.forEach((s,l)=>{s.kind==="replay"&&s.replayOnly&&o.push(r[l]?.flatIndex??l+1)}),o.length!==0)return{authoredExecutionPath:qe(n),flatIndices:o}}function Zs(e){let t=ga(e),r=oe(e.env),n=e.resolvedTest,o=!!n&&Array.isArray(n.unitFiles)&&(e.stepRunRecords?.length??0)>0,s=o?zs(n,new Set(e.authoredFlatIdx??[]),{onMissingIdentity:se=>{e.log?.("warn","MODULE_IDENTITY_MISSING","*_module.md without a cloud module_id; its blocks upload unfolded",{path:se}),process.stderr.write(`${Jr(se)}
|
|
31
|
-
`)}}):void 0,l=o?Ws(e.stepRunRecords):void 0,p=!!n&&n.steps.some(se=>se.block!==void 0),i=o&&p?Js(n,e.blockOutcomes):void 0,c=i?.length&&e.sourcePath?qe(e.sourcePath):void 0,v={files:[]},{session:f,auth:b}=e,k=b.basicAuth?{username:b.basicAuth.username,accessKey:b.basicAuth.access_key}:b.token,T=b.resolvedCreds?.username??b.basicAuth?.username??"",E=b.resolvedCreds?.access_key??b.basicAuth?.access_key??"",C=b.resolvedCreds?.org_id??0,d=b.resolvedCreds?.user_id??0,F=[];for(let se of Object.keys(f.auteurVariables))se.startsWith("secrets.user.")&&F.push({key_name:se.replace("secrets.user.",""),scope:"user"});let R=f.getContext().prior_runs.map(se=>se.status),K=f.auteurVariables,Pe=Object.keys(K).length>0;return{controllerBaseUrl:r.controllerBaseUrl,tmsBaseUrl:r.tmsBaseUrl,auth:k,authResolver:b.resolver,sessionId:f.sessionId,sessionDir:f.sessionDir,testId:f.testId,commitId:f.sessionId,apMode:f.apMode,projectId:e.projectId,folderId:e.folderId,firstObjective:f.firstObjective??"KaneAI Test",firstUrl:f.firstUrl??"",runDirs:f.getRunDirs(),runObjectives:f.getRunObjectives(),runMetadata:f.getRunMetadata(),startedAt:f.startedAt,endedAt:new Date().toISOString(),totalSteps:e.totalSteps,totalDuration:e.totalDuration,runStatuses:R,orgId:C,userId:d,tmsUsername:T,tmsAccessKey:E,screenshotBaseUrl:f.screenshotBaseUrl,screenshotExtMap:e.screenshotExtMap,shareApiBaseUrl:r.shareApiBaseUrl,variables:Pe?K:void 0,variableIds:e.variableIds,...e.testParams?{testParams:e.testParams}:{},secrets:F,codeExport:e.codeExport,...e.mobile?{mobile:!0}:{},...e.environmentId?{environmentId:e.environmentId}:{},onProgress:e.onProgress,log:e.log,shouldUploadArtifacts:e.shouldUploadArtifacts,shouldReplaceLocalOutput:e.shouldReplaceLocalOutput,shouldCommit:e.shouldCommit,isFirstRun:e.isFirstRun,onAtomicReplace:ma(e,v),onCommitLock:fa(e,v),onFinalizeSuccess:pa(e),evidence:e.evidence,evidenceRead:e.evidenceRead,...s?{moduleSpans:s}:{},...i?.length?{blockSpans:i,blockAuthoredExecutionPath:c}:{},...l?{runFlatIndex:l}:{},authoredExecutionPath:e.authoredExecutionPath,...t?{replayOnlyPassthrough:t}:{}}}var Xs=["python","javascript"];function Bd(e,t){return e?e.kind==="mobile":t}function ha(e){if(e!==void 0){if(!Xs.includes(e))throw new Error(`--code-language must be one of: ${Xs.join(", ")} (got "${e}")`);return e}}function ei(e,t,r=!1){if(r&&e.skipCodeValidation===!1)throw new Error("Code export validation is web only: --skip-code-validation=false and --no-skip-code-validation are not supported for mobile. Remove the flag or use --skip-code-validation=true.");let n=ha(e.codeLanguage);return{enabled:e.codeExport??t.enabled,language:n??t.language,skipValidation:r?!0:e.skipCodeValidation??t.skip_validation}}function ti(e){let t=e.platform?.toLowerCase(),r=lt(e.target)?e.target:t==="android"||t==="ios"?Mn(t):void 0;return{platform:e.platform??"",...e.appId?{appId:e.appId}:{},...e.deviceName?{deviceName:e.deviceName}:{},...e.osVersion?{osVersion:e.osVersion}:{},...e.udid?{udid:e.udid}:{},...r?{settings:Qn(e.mobile,r)}:{}}}async function ri(e){try{let t=new Ot(e.tmsBaseUrl,e.auth.username,e.auth.access_key);if(e.mobile){if(!e.mobile.appId)return e.log("warn","ATM_CREATE_SKIPPED","Mobile test not registered in TMS",{reason:"no cloud app id for the build under test"}),null;let n=await t.createMobileAtmTest({objective:e.objective.slice(0,100),creation_mode:"KANECLI",playground_disabled:e.hasCustomProfile,mobile_browser:!1,os:e.mobile.platform.toLowerCase(),app_id:e.mobile.appId,project_id:e.projectId,folder_id:e.folderId,authoring_version:4,...e.mobile.deviceName?{deviceName:e.mobile.deviceName}:{},...e.mobile.osVersion?{osVersion:e.mobile.osVersion}:{},...e.mobile.udid?{udid:e.mobile.udid}:{},...e.mobile.settings});return e.log("info","ATM_CREATE_OK","Mobile test created",{test_id:n}),n}let r=await t.createAtmTest({objective:e.objective.slice(0,100),creation_mode:"KANECLI",playground_disabled:e.hasCustomProfile,testURL:e.url,project_id:e.projectId,folder_id:e.folderId,authoring_version:4});return e.log("info","ATM_CREATE_OK","Test created",{test_id:r}),r}catch(t){return e.log("error","ATM_CREATE_FAILED","Test creation failed",{error:t instanceof Error?t.message:String(t)}),null}}var ya=null,ba=()=>ya??=import("sharp").then(e=>e.default??e).catch(()=>null),Yt=class{maxWorkers;maxRetries=2;queue=[];activeCount=0;drainResolvers=[];sas;log;uploadedExt=new Map;refreshSas;refreshInFlight=null;constructor(t,r=3,n,o){this.sas=t,this.maxWorkers=r,this.log=n,this.refreshSas=o}updateSas(t){this.sas=t}refresh(t){return this.refreshSas?(this.refreshInFlight??=this.refreshSas().then(r=>{this.updateSas(r),this.log?.("info","SCREENSHOT_SAS_REFRESHED","Screenshot SAS refreshed",{reason:t,expiry:r.expiry})}).catch(r=>{this.log?.("warn","SCREENSHOT_SAS_REFRESH_FAILED","Screenshot SAS refresh failed",{reason:t,error:r instanceof Error?r.message:String(r)})}).finally(()=>{this.refreshInFlight=null}),this.refreshInFlight):Promise.resolve()}enqueue(t,r){this.queue.push({operationId:t,buffer:r}),this.pump()}async drain(t=3e4){if(!(this.queue.length===0&&this.activeCount===0))return new Promise(r=>{this.drainResolvers.push(r),setTimeout(()=>{r()},t)})}pump(){for(;this.activeCount<this.maxWorkers&&this.queue.length>0;){let t=this.queue.shift();this.activeCount++,this.processJob(t).finally(()=>{if(this.activeCount--,this.pump(),this.queue.length===0&&this.activeCount===0){for(let r of this.drainResolvers)r();this.drainResolvers=[]}})}}async processJob(t){let r,n="image/webp",o=await ba();if(o)try{let i=await o(t.buffer).webp({quality:80}).toBuffer();r=new Uint8Array(i)}catch(i){r=new Uint8Array(t.buffer),n="image/png",this.log?.("warn","SCREENSHOT_CONVERT_FAILED","WebP conversion failed, using PNG",{operation_id:t.operationId,error:i instanceof Error?i.message:String(i)})}else r=new Uint8Array(t.buffer),n="image/png";let s=n==="image/webp"?"webp":"png",l=`test_screenshots/untagged_screenshot/${t.operationId}.${s}`;this.isNearExpiry()&&await this.refresh("near_expiry");let p=!1;for(let i=0;i<=this.maxRetries;i++){let c=`${this.sas.base_url}/${this.sas.container}/${l}?${this.sas.sas_token}`;try{let v=await X(c,{method:"PUT",headers:{"Content-Type":n,"x-ms-blob-type":"BlockBlob"},body:r});if(v.ok){this.uploadedExt.set(t.operationId,s);return}if(v.status===403&&!p&&this.refreshSas){p=!0,await this.refresh("forbidden"),i--;continue}if(i<this.maxRetries){await this.backoff(i);continue}this.log?.("warn","SCREENSHOT_UPLOAD_FAILED","Screenshot upload failed after retries",{operation_id:t.operationId,status:v.status,attempts:this.maxRetries+1})}catch{if(i<this.maxRetries){await this.backoff(i);continue}this.log?.("warn","SCREENSHOT_UPLOAD_FAILED","Screenshot upload failed (network error)",{operation_id:t.operationId,error:"network",attempts:this.maxRetries+1})}}}backoff(t){let r=t===0?1e3:3e3;return new Promise(n=>setTimeout(n,r))}getExt(t){return this.uploadedExt.get(t)??"png"}getExtMap(){return this.uploadedExt}isNearExpiry(){if(!this.sas.expiry)return!1;let t=new Date(this.sas.expiry).getTime();return Date.now()>t-5*6e4}};import{platform as va,arch as wa}from"os";function ni(e){let t={proxyUrl:Vn,sessionId:e.sessionId,identity:e.identity,device:{cli_version:xt,platform:va(),arch:wa(),host_agent:yr(),invocation_mode:e.invocationMode},getToken:e.getToken};return new hr(t)}async function Ia(e){try{let t=oe(e.env),r=new De(t.controllerBaseUrl,e.auth),n=await r.getScreenshotSas();return e.session.setScreenshotSas(n),e.log("info","SCREENSHOT_SAS_OK","Screenshot SAS fetched",{base_url:n.base_url,container:n.container,expiry:n.expiry}),new Yt(n,3,e.log,async()=>{let o=await r.getScreenshotSas();return e.session.setScreenshotSas(o),o})}catch(t){return e.log("warn","SCREENSHOT_SAS_FAIL","Screenshot SAS fetch failed",{error:t instanceof Error?t.message:String(t)}),null}}async function Sa(e){if(e.session.hasRemoteLogger||!e.tmsCreds)return null;let t=e.tmsCreds,r=ni({sessionId:e.session.sessionId,identity:{org_id:String(t.org_id??""),user_id:String(t.user_id??""),machine_id:go(),email:t.email??null,email_domain:t.email_domain??"unknown",user_type:t.user_type??"unknown",env:e.env,plan:t.plan??"unknown"},invocationMode:e.invocationMode,getToken:e.getToken});return e.session.setRemoteLogger(r),r.start(),r}async function rn(e){let[t,r]=await Promise.allSettled([e.skipScreenshotQueue?Promise.resolve(null):Ia({env:e.env,auth:e.auth,session:e.session,log:e.log}),Sa({env:e.env,tmsCreds:e.tmsCreds,getToken:e.getToken,session:e.session,invocationMode:e.invocationMode})]);return{resolver:e.resolver,screenshotQueue:t.status==="fulfilled"?t.value:null,remoteLogger:r.status==="fulfilled"?r.value:null}}async function Xr(e){await Promise.allSettled([e.screenshotQueue?.drain(),e.remoteLogger?.shutdown()])}async function ic(e,t){switch(e.kind){case"boot":{if(t.state.identityServicesRef.current)return t.state.identityServicesRef.current;let r=t.auth.initResolver(e.env);r.prime(e.tmsCreds),t.state.setTmsCredsCache(e.tmsCreds);let n=await en(e.env,e.tmsCreds,r,t);return tn(n,t),n}case"login":case"switch":{let r=t.state.identityServicesRef.current;r&&(await Xr(r),r.resolver.revoke()),t.state.identityServicesRef.current=null,t.state.screenshotQueueRef.current=null,t.state.setTmsCredsCache(null);let n=t.auth.initResolver(e.env),o=await n.resolve(!0).catch(()=>null);if(!o)return t.log("warn","IDENTITY_VALIDATE_FAILED","Identity validation failed",{kind:e.kind,env:e.env}),null;t.state.setTmsCredsCache(o);let s=await en(e.env,o,n,t);return tn(s,t),s}case"logout":{let r=t.state.identityServicesRef.current;return r&&(await Xr(r),r.resolver.revoke()),t.state.identityServicesRef.current=null,t.state.screenshotQueueRef.current=null,t.state.setTmsCredsCache(null),null}case"resessionize":{let r=t.state.identityServicesRef.current;r&&await Xr(r),t.state.identityServicesRef.current=null,t.state.screenshotQueueRef.current=null;let n=t.state.getTmsCredsCache(),o=t.auth.getResolver(),s=o??t.auth.initResolver(e.env);!o&&n&&s.prime(n);let l=await en(e.env,n,s,t);return tn(l,t),l}}}async function en(e,t,r,n){!n.options?.localMode&&t?.user_id!==void 0&&n.getSession().setCompletionIdentity(Number(t.user_id));let o=n.auth.getBasicAuth(),s=o?null:await n.auth.getToken(),l=o?{username:o.username,accessKey:o.access_key}:s??null;return l===null?{resolver:r,screenshotQueue:null,remoteLogger:null}:rn({env:e,tmsCreds:t,resolver:r,auth:l,getToken:()=>n.auth.getToken(),session:n.getSession(),log:n.log,skipScreenshotQueue:n.options?.localMode,invocationMode:"tui"})}function tn(e,t){t.state.identityServicesRef.current=e,t.state.screenshotQueueRef.current=e.screenshotQueue,e.remoteLogger&&(t.exit.registerCleanup("remote-logger",()=>e.remoteLogger.shutdownSync()),t.exit.setExitRemoteLogger(e.remoteLogger))}function oi(e){if(!e.executionId)return;let t={executionId:e.executionId,published:e.published};return e.testId&&(t.testId=e.testId),e.testcaseId&&(t.testcaseId=e.testcaseId),e.commitId&&(t.commitId=e.commitId),t}import{relative as Ra}from"path";import{readFile as ka}from"fs/promises";function si(e){return e.shouldUploadArtifacts&&!e.lockHeld&&!e.isFirstRun&&e.sealed&&!!e.testId}var nn=e=>e instanceof Error?e.message:String(e);async function ii(e){let{controller:t,tms:r,testId:n,sessionId:o,executionId:s,sealedPackPath:l,projectId:p}=e,i;try{let c={key:"evidence",content_type:"application/zip",filename:`${s}.evidence`},f=(await t.getPresignedUrls(n,o,[c])).urls?.evidence?.upload_url;if(!f)return{ok:!1,stage:"presign",error:"presign response missing evidence upload_url"};i=f}catch(c){return{ok:!1,stage:"presign",error:nn(c)}}try{let c=await ka(l);await No(i,c,"application/zip")}catch(c){return{ok:!1,stage:"upload",error:nn(c)}}try{await r.ingestEvidence(s,p)}catch(c){return{ok:!1,stage:"ingest",error:nn(c)}}return{ok:!0}}function ai(e){return e.isFirstRun||Mt(e.decisions)||e.push===!0||e.author===!0}function li(e,t){return{projectId:e?.project_id??t.project_id??null,folderId:e?.folder_id??t.folder_id??null}}function on(e){return e?"author":"replay"}function Ea(e,t){return e?{session:e,ownsLifecycle:!1}:{session:t,ownsLifecycle:!0}}function Jt(e,t){return e?.total_runs??t?.length??1}function Ca(e){let t=(e?.per_flow_metadata??[]).map(r=>({resultCode:r?.result_code!=null?Number(r.result_code):null}));return{resultCode:e?.result_code!=null?Number(e.result_code):null,...t.length?{perFlow:t}:{}}}var Qt=["target","chrome_profile","cdp_endpoint","ws_endpoint","headless"];async function Ou(e,t,r){let{path:n,cwd:o,opts:s,isAgent:l,disableAskUser:p,resolved:i,resolvedAuth:c,cliOverrides:v,environment:f,envConfig:b,profile:k,model:T,creds:E,configStore:C,session:d}=e,F=!1,h=await La(n,i,s,{resolvedAuth:c,tmsBaseUrl:b.tmsBaseUrl},d.sessionId,r);if(h.abort)return{overallStatus:"failed",exitCode:h.abort.exitCode,outputDir:ee(n),durationS:0,uploadResult:null};let R=h.lockAcquired,K=!1;try{let cr=function(a,u){let m=i.steps[a],y=di(m.config,v),w=Je(Te.raw,y.variables,m.objective);return Gr({objective:w.objective,url:x.kind==="device"?void 0:Xt(a)?Re??void 0:m.unitEntryUrl,requireStartUrl:x.kind==="web"&&Xt(a)&&hi,model:T,chrome:q,device:x.kind==="device"?x.device:void 0,auth:c,sessionId:d.sessionId,runIndex:u,projectId:s.local?null:M,windowSize:{width:1920,height:1080},maxSteps:Ta(y,yi),headless:H.headless??!1,disableAskUser:!0,variables:Object.keys(w.variables).length>0?w.variables:void 0,globalContext:y.global_context??vn,localContext:y.local_context??wn,sessionContext:d.getContext(),environmentId:bt,bugDetection:s.bugDetection??N.bug_detection,evidence:dr()})},it=function(a){let m=i.steps[a].trace[0].stepIndex,y=i.rootSteps.find(g=>g.index===m);i.steps.slice(0,a).some(g=>g.trace[0].stepIndex===m)||t.onAgentEvent({type:"test_md_step_start",step_index:m,heading:y.heading,ref:y.body.kind==="import_ref"?{kind:"import",label:y.body.path,unit_kind:Er(y.body.path)}:null,...y.replayOnly?{replay_only:y.replayOnly}:{}})},kt=function(a,u,m,y,w,g){let I=i.steps[a],D=I.trace[0].stepIndex,$=!i.steps.slice(a+1).some(V=>V.trace[0].stepIndex===D),_=m?.status==="passed"?"passed":"failed",P=m?.reason??w??void 0,O=m?.duration??g,S=m?.verdict;if(S&&typeof S=="object"){let V=typeof S.one_liner=="string"?S.one_liner:"",U=typeof S.bug_title=="string"&&S.bug_title?S.bug_title:V;if(U&&_==="failed"){let ge=[S.family,S.category].filter(Boolean).join("/"),At=typeof S.confidence=="number"?`, confidence ${S.confidence.toFixed(2)}`:"";P=`${P??"failed"} \u2014 bug verdict: ${U}${ge?` [${ge}${At}]`:""}`}let at=typeof S.category_proposal=="string"?S.category_proposal:"";at&&_==="failed"&&(P=`${P??"failed"}; category proposal: ${at} \u2014 consider adding to taxonomy`),t.onAgentEvent({type:"test_md_bug_verdict",step_index:I.trace[0].stepIndex,confirmed:S.confirmed===!0,bug_title:U||null,family:S.family??null,category:S.category??null,category_proposal:at||null,severity:S.severity??null,confidence:typeof S.confidence=="number"?S.confidence:null,one_liner:V||null})}let{continueOverall:B}=de.recordStep(I,{status:_,duration_s:O,reason:P}),W=di(I.config,v),A=Je(Te.raw,W.variables,I.objective).objective;if(m){let V=Ss(m,u,y);d.addRunResult(ks(m,A,u,V),m.total_runs)}else d.addRunResult({index:u,objective:A,status:_,summary:"",context:{memory:{},variables:{},pointer:""}},1);if($||!B){let V=de.snapshotOutcomes().find(U=>U.rootStepIndex===D);t.onAgentEvent({type:"test_md_step_end",step_index:D,status:V.status,duration_s:V.duration_s??0,ref_kind:V.refKind??null,unit_kind:V.refKind==="import"?Er(V.refLabel??""):null,inlined_count:V.inlinedCount??null,failed_sub_step_index:V.failedSubStepIndex??null})}return B},Ve=function(a,u){let m=i.steps[a],y=m.trace[m.trace.length-1].heading;process.stderr.write(`\u{1FA79} step ${m.flatIndex} "${y}" @${u} broke on replay \u2014 adaptive heal cannot re-author a replay-only step; the run fails here
|
|
32
|
-
`),d.log("warn","REPLAY_ONLY_STEP_FAILED","Replay-only step failed on replay; heal not attempted",{flat_index:m.flatIndex,marker:u})};var Pe=cr,se=it,ie=kt,te=Ve;let Zt={committed:!1},pe=!1,gt=new Set,Xe=0,mi=i.steps.some(a=>a.block!==void 0),Xt=a=>mi?Xe===0:a===0,me=!1,ht=!1,et=s.author===!0?0:ut(h.decisions),er=0,tr=0,Ne=0,tt=a=>typeof a?.credits_consumed=="number"&&Number.isFinite(a.credits_consumed)?a.credits_consumed:0;{let a;try{a=typeof s.sessionContext=="string"?JSON.parse(s.sessionContext):void 0}catch{a=void 0}let u=Aa({resolved:i,cwd:o,globalDir:be(Pt,"variables"),opts:s,authorFrom:et,produced:ns(a)});u&&(l?t.onAgentEvent(u.event):process.stderr.write(u.text))}R&&t.onLockState({phase:"acquired",scope:"preemptive"}),d.start({model:T,environment:f,profile:k}),d.setRecordingEnabled(!1);let yt=0,an=c.basicAuth?{username:c.basicAuth.username,accessKey:c.basicAuth.access_key}:c.token??null,rt=null;if(an!==null){let a=await rn({env:f,tmsCreds:c.resolvedCreds??null,resolver:c.resolver,auth:an,getToken:async()=>c.token??null,session:d,log:(u,m,y,w)=>d.log(u,m,y,w),skipScreenshotQueue:!!s.local||!c.basicAuth,invocationMode:l?"agent":"cli"});rt=a.screenshotQueue,a.remoteLogger&&(r.register("remote-logger",()=>a.remoteLogger.shutdownSync()),r.remoteLogger=a.remoteLogger,e.skipGlobalRemoteLogger||Gn(a.remoteLogger))}if(s.name){try{Wo(s.name)}catch(a){return process.stderr.write(`error: ${a.message}
|
|
33
|
-
`),{overallStatus:"failed",exitCode:2,outputDir:ee(n),durationS:0,uploadResult:null}}d.setSessionName(s.name)}let rr={};for(let[a,u]of Object.entries(i.rootGlobal))Qt.includes(a)||(rr[a]=u);for(let[a,u]of Object.entries(v))Qt.includes(a)||u!==void 0&&(rr[a]=u);let H={...i.chrome};for(let a of Qt){let u=v[a];u!==void 0&&(H[a]=u)}let $e={...rr,...H},ke=Yo({flags:{target:s.target,deviceName:s.deviceName,osVersion:s.osVersion,app:s.app},file:{target:i.rootGlobal.target,device_name:i.rootGlobal.device_name,os_version:i.rootGlobal.os_version,app:i.rootGlobal.app,no_reset:i.rootGlobal.no_reset},grid:xe(),deviceConfig:Xn()});if(ke.kind==="invalid")return process.stderr.write(`error: ${ke.message}
|
|
34
|
-
`),await d.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:ee(n),durationS:0,uploadResult:null};for(let a of ke.warnings)process.stderr.write(`warning: ${a}
|
|
35
|
-
`);let ve=ke.kind==="mobile"?ke:null,re=ke.kind==="real-device"?ke:null,ln=Ar(s)&&!re;if(re&&Ar(s)&&(process.stderr.write(`note: adaptive heal is off on real devices \u2014 a failed replay step is not repaired, and the test fails.
|
|
36
|
-
`),d.log("info","ADAPTIVE_HEAL_OFF_REAL_DEVICE","Adaptive heal is off for a real-device run")),d.setCompletionMetadata({runType:i.rootGlobal.assurance?.id?"assurance":"testmd",target:re?re.platform==="ios"?"simulator":"emulator":ve?.target??"desktop"}),ke.kind==="web"&&i.rootGlobal.target===void 0){let u=i.rootSteps.map(y=>y.body).find(y=>y.kind==="objective")?.text??"",m=/^\s*\[mobile:\s*(emulator|simulator)\]/.exec(u);if(m)return process.stderr.write(`error: this test was designed for a mobile ${m[1]} but its frontmatter has no target: \u2014 add \`target: ${m[1]}\` and \`app: <path-to-build | AppId>\` to the file (or re-design it with the app named in the design chat: kane-cli design tests --use-case <uc> --force), then run again
|
|
37
|
-
`),await d.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:ee(n),durationS:0,uploadResult:null}}ve?($e.target=ve.target,ve.app&&($e.app=ve.app)):re?$e.target=re.platform:(i.rootGlobal.target==="emulator"||i.rootGlobal.target==="simulator")&&(delete $e.app,delete $e.no_reset),d.setResolvedGlobal($e);let we=null;{let a=m=>(process.stderr.write(`error: ${m}
|
|
38
|
-
`),{overallStatus:"failed",exitCode:2,outputDir:ee(n),durationS:0,uploadResult:null}),u;try{u=co({datasetId:s.datasetId,datasetVersion:s.datasetVersion,datasetRow:s.datasetRow},i.rootGlobal.dataset)}catch(m){return a(m.message)}if(u){if(!c.basicAuth)return a("--dataset-id needs Test Manager credentials \u2014 run 'kane-cli login' or pass --username/--access-key");try{we=await Hs({selection:u,tmsBaseUrl:oe(f).tmsBaseUrl,auth:c.basicAuth,saveDir:d.sessionDir,log:(y,w,g,I)=>d.log(y,w,g,I)})}catch(y){return a(y.message)}d.setResolvedGlobal({dataset:uo(u.id,we.rowId)});let m=ts(i.steps.filter(y=>y.flatIndex-1>=et).map(y=>({text:y.objective,usedBy:{file:Ue(y.sourceFile),step:y.flatIndex}})),we.columns,u.id);m.length>0&&(l?t.onAgentEvent(Lr(m,{cwd:o})):process.stderr.write(Dr(m,{cwd:o,entryFile:Ue(i.rootPath)})))}}let dn=E.getActiveProfile()??"default",cn=E.getDefaultEnv(),{rehydrateIfStale:fi}=await import("./profile-sync-DTTRRIVP.js");fi(E,C,dn,cn);let N=C.load(),un=(v.assertion_mode??N.assertion_mode)==="dom"?"dom":"visual",mn=v.final_validation,fn=mn===void 0?void 0:mn==="on",M=N.project_id??null,_e=N.folder_id??null,pn=he(n),bt=pn?.environment_id,nt=Bo(pn?.tc_id),gn=async()=>{if(!xe())return;let a=await Ds(c);if(a)return{name:i.rootTitle||Ue(n).replace(/_test\.md$/,""),...nt?{tcId:nt}:{},...a}},hn=ai({isFirstRun:h.isFirstRun,decisions:h.decisions,push:s.push===!0,author:s.author===!0});if(hn){if(c.basicAuth){let a=await po({creds:E,config:C,profile:dn,env:cn,tmsCreds:c.basicAuth,isLocal:!!s.local,log:(u,m,y,w)=>d.log(u,m,y,w),onAnnounce:e.onAnnounce,onFatalExit:e.onFatalExit});if(a.status==="ok"){M=a.projectId,_e=a.folderId,N=C.load();let u=he(n);u?.project_id&&(M=u.project_id,_e=u.folder_id??_e),l&&a.autoDefaulted&&t.onAgentEvent(fo(a.autoDefaulted))}else if(a.status==="cancelled"){process.stderr.write(`error: project/folder configuration failed. See remediation above, or use --local.
|
|
39
|
-
`);let{shutdown:u}=await import("./exit-manager-ZLDO54S4.js");return u(2,"project/folder gate failed"),{}}}}else{let a=he(n);({projectId:M,folderId:_e}=li(a,{project_id:N.project_id??null,folder_id:N.folder_id??null})),d.log("info","GATE_SKIP_REPLAY","Project/folder gate skipped (planned pure replay)",{meta_project:!!a?.project_id,config_project:!!N.project_id})}{let a=Vo(i),u=c.resolvedCreds?.org_id!=null?String(c.resolvedCreds.org_id):void 0,m=a.find(g=>g.project_id&&M&&g.project_id!==String(M)||g.org_id&&u&&g.org_id!==u),y=new Set(a.map(g=>g.project_id).filter(Boolean)),w=new Set(a.map(g=>g.org_id).filter(Boolean));if(m||y.size>1||w.size>1){let g=m??a[0];return process.stderr.write(`error: tenant mismatch \u2014 imported test '${g.file}' was authored under project ${g.project_id??"?"} / org ${g.org_id??"?"}, which differs from the run's project/org (or another imported test). Cross-tenant imports are not allowed.
|
|
40
|
-
`),await d.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:ee(n),durationS:0,uploadResult:null}}}let ae={},ot,x;try{x=await Ls(ve||re?"device":"web",{prepareDevice:async()=>{if(re){let m=await ro({target:re.platform,...re.selection?{selection:re.selection}:{},env:f,sessionDir:d.sessionDir,auth:c,mobile:N.mobile,testName:i.rootTitle||Ue(n).replace(/_test\.md$/,""),...nt?{tcId:nt}:{},write:y=>process.stderr.write(`${y}
|
|
41
|
-
`),stream:to({interactive:Or()&&!l,flag:s.stream,mobile:N.mobile})});return m.deviceName&&(ae.deviceName=m.deviceName),m.osVersion&&(ae.osVersion=m.osVersion),m.app&&(ae.app=m.app),ot=m.announce,m.appId&&d.setResolvedGlobal({app:m.appId}),{device:m.device,...m.appId?{appId:m.appId}:{}}}let a=ve,u=await Jn({platform:a.platform,...a.deviceSelector?{device:a.deviceSelector}:{},...a.app?{app:a.app}:{},...a.noReset!==void 0?{noReset:a.noReset}:{},defaults:N.mobile,interactive:Or()&&!l,agent:l,...!s.local&&c.basicAuth&&c.resolvedCreds?.org_id?{cloudUpload:{env:f,orgId:String(c.resolvedCreds.org_id),userId:String(c.resolvedCreds.user_id??""),baseUrl:Zn(f),auth:{username:c.basicAuth.username,accessKey:c.basicAuth.access_key}}}:{},onProgress:m=>process.stderr.write(`${m}
|
|
42
|
-
`)});return ae.deviceName=u.target.displayName,u.target.osVersion&&(ae.osVersion=u.target.osVersion),u.target.modelIdentifier&&(ae.modelIdentifier=u.target.modelIdentifier),u.appRef&&(ae.app=u.appRef),{device:u.device,...u.appRef?{appRef:u.appRef}:{},...u.appId?{appId:u.appId}:{}}},prepareWeb:async()=>Hr({config:{chrome_profile_path:H.chrome_profile??null,window_size:{width:1920,height:1080}},startUrl:He,headless:H.headless??!1,wsEndpoint:H.ws_endpoint,cdpEndpoint:H.cdp_endpoint,ltGrid:await gn()})})}catch(a){if(re)process.stderr.write(`error: real-device target preparation failed: ${a.message}
|
|
43
|
-
`);else if(ve){let u=a instanceof Yn?`${a.doctorText}
|
|
44
|
-
${a.message}`:a.message;process.stderr.write(`error: mobile target preparation failed: ${u}
|
|
45
|
-
`)}else process.stderr.write(`error: Chrome launch failed: ${a.message}
|
|
46
|
-
`);return await d.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:ee(n),durationS:0,uploadResult:null}}if(x.kind==="device"&&!lt(x.device.target)&&!x.device.app_package)return process.stderr.write(`error: ${Jo(ve.target,"app")}
|
|
47
|
-
`),await d.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:ee(n),durationS:0,uploadResult:null};let q=x.kind==="web"?x.chrome:{instance:null,tempDir:null},Ie=q.instance;Ie&&r.register("chrome",()=>{try{Ie?.kill()}catch{}});let nr=vr(q.cdpEndpoint),G=null,yn=!1,vt=()=>{if(!G?.diedUnexpectedly)return!1;if(!yn){yn=!0;let a=G.stderr.slice(-500);d.log("error","RUNNER_FATAL_DEATH","v16-runner exited unexpectedly mid-session",{stderr_tail:a}),process.stderr.write(`error: v16-runner exited unexpectedly mid-session \u2014 remaining steps skipped.
|
|
48
|
-
`)}return!0},z=null,bn=q.cdpEndpoint??H.cdp_endpoint;if(bn&&!H.ws_endpoint&&!H.headless&&!e.isAgent)try{z=Vr({headless:H.headless??!1,cdpEndpoint:bn,chromePid:Ie?.process.pid}),z&&r.register("marker-overlay",()=>z?.kill())}catch(a){d.log("warn","OVERLAY_SPAWN_FAILED","Marker overlay spawn failed",{error:String(a)})}c.resolvedCreds?.org_id!==void 0&&d.setOrgId(String(c.resolvedCreds.org_id)),!s.local&&c.resolvedCreds?.user_id!==void 0&&d.setCompletionIdentity(Number(c.resolvedCreds.user_id)),d.setUserIdentity(c.resolvedCreds?.username??null,c.resolvedCreds?.email??null);let Te=Ms({objective:"",globalDir:be(Pt,"variables"),localDir:be(o,".testmuai","variables"),file:s.variablesFile,inline:s.variables,parameters:we?.parameters}),pi=i.rootGlobal.variables??{},le=xa(Te.raw,pi);d.setAuteurVariables(le.auteur);let vn=Yr(be(Pt,"global-memory.md"))??void 0,wn=Yr(be(o,".testmuai","context.md"))??void 0;s.local?process.stderr.write(`info: --local \u2014 cloud upload skipped
|
|
49
|
-
`):c.basicAuth?M||(hn?process.stderr.write(`warn: cloud upload skipped \u2014 no project configured.
|
|
50
|
-
`):process.stderr.write(`warn: evidence publish will be skipped \u2014 no project_id in meta.json or config.
|
|
51
|
-
`)):process.stderr.write(`warn: cloud upload skipped \u2014 TMS credentials could not be resolved.
|
|
52
|
-
Run 'kane-cli login' (OAuth) or 'kane-cli config set-username/set-access-key' (basic auth).
|
|
53
|
-
`);let Be=!s.local&&!!c.basicAuth&&M!=null;if(d.log("info","PIPELINE_GATE_STATE","Initial gate state (run-start)",{phase:"run-start",shouldUploadArtifacts:Be,lockHeld:R,isFirstRun:h.isFirstRun,hasAuth:h.hasAuth}),Be&&h.testId==null&&!h.degradedReadonly){let a=oe(f);try{let u=await ri({tmsBaseUrl:a.tmsBaseUrl,auth:c.basicAuth,objective:i.steps[0].objective,url:"",projectId:M,folderId:_e??"",hasCustomProfile:!!H.chrome_profile,...x.kind==="device"?{mobile:ti({platform:x.device.platform,target:x.device.target,mobile:N.mobile,appId:x.appId,deviceName:ae.deviceName,osVersion:ae.osVersion,udid:x.device.udid})}:{},log:(m,y,w,g)=>d.log(m,y,w,g)});u&&d.setTestId(u)}catch(u){process.stderr.write(`warn: ATM test creation failed: ${u.message}
|
|
54
|
-
`)}}else h.testId&&d.setTestId(h.testId);let wt={};if(c.basicAuth&&!s.local&&(le.secretEntries.length>0||le.nonSecretEntries.length>0))try{wt=await Vs({variables:le,auth:c.basicAuth,orgId:String(c.resolvedCreds?.org_id??""),env:f,localMode:!!s.local,log:(a,u,m,y)=>d.log(a,u,m,y)})}catch(a){process.stderr.write(`warn: variable/secret push failed: ${a.message}
|
|
55
|
-
`)}let or=new Map;for(let[a,u]of le.nonSecretEntries)or.set(a,u.value);let sr=new Map;for(let[a,u]of le.secretEntries)sr.set(a,u.value);async function ir(a){if(!c.basicAuth||s.local)return;let u=[],m=[];for(let[w,g]of Object.entries(a))if(!dt(g))if(g.secret){if(sr.get(w)===g.value)continue;m.push([w,g])}else{if(or.get(w)===g.value)continue;u.push([w,g])}if(u.length===0&&m.length===0)return;let y=oe(f);if(u.length>0){let w=new Ye(y.tmsBaseUrl,c.basicAuth.username,c.basicAuth.access_key);for(let[g,I]of u)try{let D=await w.upsertVariable({name:g,value:I.value});wt[g]=D.id,or.set(g,I.value),d.log("info","VAR_PUSH_STEP","Variable updated mid-run",{name:g})}catch(D){d.log("warn","VAR_PUSH_STEP_FAILED","Mid-run variable push failed",{name:g,error:String(D)})}}if(m.length>0){let w=new We(y.secretsBaseUrl);for(let[g,I]of m)try{await w.pushSecret({secretKey:g,secretValue:I.value,username:c.basicAuth.username,accessKey:c.basicAuth.access_key,orgId:String(c.resolvedCreds?.org_id??"")}),sr.set(g,I.value),d.log("info","SECRET_PUSH_STEP","Secret updated mid-run",{name:g})}catch(D){d.log("warn","SECRET_PUSH_STEP_FAILED","Mid-run secret push failed",{name:g,error:String(D)})}}}let st=rt?(a,u,m,y)=>{if(!(R||h.isFirstRun))return;if(L&&y){ws(L.packTestDir,y,rt,(g,I,D,$)=>d.log(g,I,D,$));return}let w=yt+u;Is(d.sessionDir,w,a,rt,(g,I,D,$)=>d.log(g,I,D,$),m)}:void 0,In=i.rootTitle??i.rootSteps[0]?.heading??Ue(n),gi=Object.keys(le.raw).length>0?Ge(le.raw,In).objective:In,Re=_s({flag:s.url,frontmatter:i.rootGlobal?.url,configDefault:C.load().default_url}),hi=Rs({resolvedUrl:Re,local:!!s.local,allowMissingUrl:!!s.allowMissingUrl,isTTY:!l});d.setFirstRun(gi,Re??"");let de=new Ht(i),It=new Date().toISOString(),Sn=Date.now(),ar=e.evidenceAttach?null:new Co({origin:"testmd",runKind:"author",pid:process.pid,title:i.rootTitle??Ue(n),started:It,producerVersion:xt,surfaces:Re?[Re]:void 0,testmdRelPath:Ra(o,n),definition:{path:"test.md",content:ci(n,"utf8")},cwd:o,packRootDir:be(d.sessionDir,"evidence")}),Q=Ea(e.evidenceAttach,ar),J=Q.session,L=null;if(e.evidenceAttach)L={executionId:e.evidenceAttach.id,testId:e.evidenceAttach.test,packTestDir:e.evidenceAttach.packTestDir};else if(ar)try{L=await ar.start()}catch(a){d.log("warn","EVIDENCE_START_FAILED","Evidence pack creation failed",{error:String(a)})}let Ee=[],St=[],kn,Me,lr=(a,u,m,y,w)=>{if(!L)return;J.noteSpawn(w?.length?{...a,steps:a.steps.map(I=>({...I,verifies:w}))}:a),a.resolution&&(kn=a.resolution),Me=vo(Me,a.runnerEnvironment),Ee.push(Ca(u));let g=Jt(u,y);for(let I=0;I<g;I++)St.push(m+I)},dr=()=>L?{packTestDir:L.packTestDir,ordinalOffset:J.nextOrdinalOffset()}:void 0,_n=async a=>{if(!L||!J)return;let u=So(Ee.length?Ee:[{resultCode:null}]);await J.archiveAttempt(u,a,{log:(m,y,w,g)=>d.log(m,y,w,g)}),Ee.length=0,St.length=0},yi=typeof s.maxSteps=="string"&&s.maxSteps!==""?parseInt(s.maxSteps,10):void 0,ur=[],_t=ze.hasBlocks(i.steps)?new ze(i.steps,h.decisions,{evaluate:async a=>{let u=d.nextRunIndex(),m=Xe===0,w={...Gr({objective:a.join(`
|
|
56
|
-
`),conditions:a,url:m&&x.kind!=="device"?Re??void 0:void 0,model:T,chrome:q,auth:c,sessionId:d.sessionId,runIndex:u,projectId:s.local?null:M,windowSize:{width:1920,height:1080},maxSteps:1,headless:H.headless??!1,disableAskUser:!0})};delete w.run_id,Ft(w,{environment:f});let g=null;try{for await(let I of G.run(`run-${u}`,"evaluate",w)){if(t.onAgentEvent(I),I.type==="run_end"){g=I;break}if(I.type==="error")break}}catch(I){d.log("error","BLOCK_CONDITION_JUDGE_FAILED","evaluate run failed",{error:I.message})}return m&&g&&Xe++,d.log("info","BLOCK_CONDITION_JUDGED","Control-flow conditions judged",{conditions:a,results:g?.condition_results??null,reasons:g?.condition_reasons??null}),g?.condition_results??a.map(()=>null)},whileConfig:a=>zt(i.steps[a]),sleep:a=>new Promise(u=>setTimeout(u,a))}):null;async function Rn(a){if(!_t)return null;let u=await _t.before(a),m=i.steps[a];switch(u.action){case"run":return null;case"author":return{kind:"author"};case"skip":return{kind:"done",stop:null};case"structural":return it(a),de.recordStep(m,{status:"passed",duration_s:0}),d.log("info","BLOCK_STRUCTURAL_STEP","Control-flow marker step",{step:m.flatIndex,marker:m.controlFlow}),{kind:"done",stop:null};case"jump":return d.log("info","BLOCK_WHILE_REENTER","While condition holds \u2014 re-entering the body",{from:m.flatIndex,to:u.to+1}),{kind:"jump",to:u.to};case"fail":return it(a),de.recordStep(m,{status:"failed",duration_s:0,reason:u.reason}),d.log("error","BLOCK_STEP_FAILED",u.reason,{step:m.flatIndex}),{kind:"done",stop:{failedAt:a,cancelled:!1}}}}async function En(a){let u=i.steps[a];it(a),Xe++,pe=!0,gt.add(i.steps[a].flatIndex);let m=d.nextRunIndex();yt=m,await ir(Je(Te.raw,u.config.variables,u.objective).raw);let y=cr(a,m),w=Date.now(),g=null,I=null,D=null,$=!1,_=0,P=Nt(),O={...y};delete O.run_id,Ft(O,{environment:f});let S=`run-${m}`;try{z?.setRunActive(!0);try{for await(let A of G.run(S,"author",O)){if(t.onAgentEvent(A),P=br(P,A),A.type==="bifurcation"){let V=A.count??A.flows?.length??0;(A.is_single_flow??V<=1)||(D=A.flows??null,$=!0,_=0)}else if(A.type==="run_start"&&$)_++;else if(A.type==="step_event"&&A.event==="reasoning")z?.setStepText(A.detail);else if(A.type==="step_end"&&(A.status==="passed"&&z?.setStepComplete(),st)){let V=$?Math.max(0,_-1):0;st(A.index,V,A.child_id,typeof A.ordinal=="number"&&A.id?{ordinal:A.ordinal,id:A.id}:void 0)}if(A.type==="run_end"){g=A;break}if(A.type==="error"){I=A.message??"runner error";break}}}finally{z?.setRunActive(!1)}}catch(A){I=A.message}G.diedUnexpectedly&&vt();let B=Math.round((Date.now()-w)/1e3),W=kt(a,m,g,D,I,B);return d.recordStepRun({testmdStepIndex:i.steps[a].flatIndex,runIndex:m,totalRunDirs:Jt(g,D)}),tr+=tt(g),Ne+=tt(g),lr(P,g,m,D,i.steps[a].verifies),{continueOverall:W}}async function Cn(a){if(F||e.signal?.aborted)return{failedAt:a,cancelled:!0};if(vt())return{failedAt:a,cancelled:!1};let u=i.steps[a],m=h.decisions[a];if(m.kind!=="replay")return process.stderr.write(`error: runReplayPhase invoked on a non-replay decision at step ${a}
|
|
57
|
-
`),{failedAt:a,cancelled:!1};let y=d.nextRunIndex();yt=y;let w=Xt(a)?Re??void 0:i.steps[a].unitEntryUrl,g={width:N.window_size.width,height:N.window_size.height},I=Je(Te.raw,u.config.variables,u.objective),D=Fr({step:u,decision:m,chrome:q,device:x.kind==="device"?x.device:void 0,auth:c,sessionId:d.sessionId,runIndex:y,sessionDir:d.sessionDir,windowSize:g,environmentId:bt,forceNavigateUrl:x.kind==="device"?void 0:w,sessionContext:d.getContext(),variables:Object.keys(I.variables).length>0?I.variables:void 0,evidence:dr(),investigationAsync:!Q.ownsLifecycle});await ir(I.raw),it(a),Xe++;let $=Date.now(),_=null,P=null,O=Nt(),S={...D};delete S.run_id,Ft(S,{environment:f});let B=`run-${y}`;try{z?.setRunActive(!0);try{for await(let U of G.run(B,"replay",S)){if(t.onAgentEvent(U),O=br(O,U),U.type==="step_event"&&U.event==="reasoning"?z?.setStepText(U.detail):U.type==="step_end"&&(U.status==="passed"&&z?.setStepComplete(),st&&st(U.index,0,U.child_id,typeof U.ordinal=="number"&&U.id?{ordinal:U.ordinal,id:U.id}:void 0)),U.type==="run_end"){_=U;break}if(U.type==="error"){P=U.message??"runner error";break}}!Q.ownsLifecycle&&_?.status==="failed"&&ur.push({exited:G.exited.then(()=>{}).catch(()=>{}),cancel:()=>{try{G?.cancel()}catch{}}})}finally{z?.setRunActive(!1)}}catch(U){P=U.message}if(G.diedUnexpectedly&&vt(),F)return{failedAt:a,cancelled:!0};let W=Math.round((Date.now()-$)/1e3),A=kt(a,y,_,null,P,W);d.recordStepRun({testmdStepIndex:i.steps[a].flatIndex,runIndex:y,totalRunDirs:Jt(_,null)}),lr(O,_,y,null,i.steps[a].verifies),Ne+=tt(_);let V=!!P||_?.status==="failed";return as(a,V?"failed":"ok"),V||!A?{failedAt:a,cancelled:!1}:null}async function bi(a){is(a,i.steps.length),_t?.reset();for(let u=0;u<a;u++){let m=await Rn(u);if(m?.kind==="done"){if(m.stop)return m.stop;continue}if(m?.kind==="jump"){u=m.to-1;continue}if(m?.kind==="author"){let w=i.steps[u];if(w.replayOnly)return Oe(u,w.replayOnly),Ve(u,w.replayOnly),de.recordStep(w,{status:"failed",duration_s:0,reason:`replay-only step @${w.replayOnly} has no recording`}),{failedAt:u,cancelled:!1};if(!(await En(u)).continueOverall)return{failedAt:u,cancelled:!1};continue}let y=await Cn(u);if(y)return y}return{failedAt:null,cancelled:!1}}let An=async()=>{if(R||h.degradedReadonly)return!0;let a=c.basicAuth;if(!a){let g=await c.resolver.resolve(!0);g?.username&&g?.access_key&&(a={username:g.username,access_key:g.access_key},c.basicAuth=a)}if(!h.testId||!h.fromCommitId||!a)return process.stderr.write(`error: cannot acquire lock \u2014 missing required state
|
|
58
|
-
`),!1;let u=d.sessionId,m=s.onLockConflict??i.rootGlobal.on_lock_conflict??"readonly",y=await sn({tmsBaseUrl:b.tmsBaseUrl,testId:h.testId,fromCommitId:h.fromCommitId,newCommitId:u,basicAuth:a,onLockConflict:m}),w=y.outcome;if(w==="ok"){R=!0,h.newCommitId=u,d.log("info","MID_RUN_LOCK_ACQUIRED","Mid-run lock acquired",{test_id:h.testId}),l&&t.onLockState({phase:"acquired",scope:"mid_run"}),Kt({baseUrl:Qe(b.tmsBaseUrl),testId:h.testId,auth:Ze(a),lifecycle:r});let g=await ui({resolved:i,decisions:h.decisions,tmsBaseUrl:b.tmsBaseUrl,newCommitId:u,basicAuth:a,mode:m,lifecycle:r,alreadyLocked:h.unitLocks,allUnits:!0});return g.outcome==="ok"?h.unitLocks.push(...g.locks):process.stderr.write(`warn: mid-run unit lock acquisition degraded (${g.outcome}) \u2014 affected units will not self-commit
|
|
59
|
-
`),!0}if(y.outcome==="readonly"){h.degradedReadonly=!0;let g=y.reason==="disabled"?"playground disabled for this test":y.reason==="base_mismatch"?"base commit mismatch":"concurrent session";return d.log("warn","MID_RUN_LOCK_READONLY","Mid-run lock unavailable; healing continues in readonly (no commit)",{test_id:h.testId,reason:y.reason}),l&&t.onLockState({phase:"conflict",scope:"mid_run",reason:"readonly"}),process.stderr.write(`[lock] mid-run ${g} \u2014 healing continues in readonly mode (no commit)
|
|
60
|
-
`),!0}return d.log("error","MID_RUN_LOCK_CONFLICT","Mid-run lock acquisition failed",{reason:w}),l&&t.onLockState({phase:"conflict",scope:"mid_run",reason:w}),process.stderr.write(`error: mid-run lock acquisition failed (${w})
|
|
61
|
-
`),!1},xn=async()=>{try{z?.kill(),z=null,Ie?.kill(),q=await Hr({config:{chrome_profile_path:H.chrome_profile??null,window_size:{width:1920,height:1080}},startUrl:He,headless:H.headless??!1,wsEndpoint:H.ws_endpoint,cdpEndpoint:H.cdp_endpoint,ltGrid:await gn()}),Ie=q.instance,nr=vr(q.cdpEndpoint);let a=q.cdpEndpoint??H.cdp_endpoint;if(a&&!H.ws_endpoint&&!H.headless&&!e.isAgent)try{z=Vr({headless:H.headless??!1,cdpEndpoint:a,chromePid:Ie?.process.pid})}catch(u){d.log("warn","OVERLAY_SPAWN_FAILED","Marker overlay respawn failed",{error:String(u)})}return d.log("info","BROWSER_RECYCLED","Fresh browser brought up for the replay re-attempt",{cdp_endpoint:q.cdpEndpoint}),!0}catch(a){return d.log("error","RECYCLE_FAILED","Could not bring up a fresh browser for the replay re-attempt",{error:a.message}),process.stderr.write(`error: could not recycle the browser for the replay re-attempt: ${a.message}
|
|
62
|
-
`),!1}},Pn=async()=>{if(x.kind!=="device"||x.device.target!=="simulator"||x.device.no_reset===!0||!x.device.udid)return;let a=await Hn("xcrun",["simctl","keychain",x.device.udid,"reset"],{timeoutMs:3e4});a.code===0?d.log("info","SIM_KEYCHAIN_RESET","Simulator keychain reset for the replay re-attempt"):d.log("warn","SIM_KEYCHAIN_RESET_FAILED","Could not reset the simulator keychain; keychain-backed login state may survive the recycle",{error:a.stderr.trim()||a.stdout.trim()})};if(l){let a=jt();if(!a)return process.stderr.write("error: v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available.\n"),r.cleanup("marker-overlay","v16-runner not found"),r.cleanup("chrome","v16-runner not found"),await d.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:ee(n),durationS:0,uploadResult:null};let u=yo({environment:f,mode:v.mode??"testing",assertionMode:un,finalValidation:fn,username:c.basicAuth?.username,accessKey:c.basicAuth?.access_key,sessionId:d.sessionId});x.kind==="device"&&await ho(u,x.device),G=new Ut({env:u,runner:a,log:(_,P,O,S)=>d.log(_,P,O,S),sessionId:d.sessionId,...ot?{onEvent:ot}:{}}),r.register("runner",()=>{(qn()||e.signal?.aborted)&&(F=!0);try{G?.kill()}catch{}});let m=_=>{let P={...x.kind==="device"?{device:x.device}:{},cdp_endpoint:_.cdpEndpoint,ws_endpoint:_.wsEndpoint,..._.startUrl?{start_url:_.startUrl}:{},width:N.window_size.width,height:N.window_size.height,headless:H.headless??!1,model:T,session_id:d.sessionId,disable_ask_user:!0},O=Qo(he(i.rootPath));return O.length>0&&(P.media_info=O),!s.local&&M&&(P.project_id=M),c.basicAuth?(P.username=c.basicAuth.username,P.access_key=c.basicAuth.access_key,c.resolvedCreds?.org_id&&(P.media_upload=bo(oe(f),String(c.resolvedCreds.org_id)))):c.token&&(P.auth={type:"bearer",token:c.token}),P};await G.start(m(q));let y=async()=>{try{await G?.shutdown()}catch{}if(!await xn())return!1;try{return G=new Ut({env:u,runner:a,log:(_,P,O,S)=>d.log(_,P,O,S),sessionId:d.sessionId}),await G.start(m(q)),!0}catch(_){return d.log("error","RECYCLE_FAILED","Could not restart the persistent runner after recycle",{error:_.message}),process.stderr.write(`error: could not restart the runner for the replay re-attempt: ${_.message}
|
|
63
|
-
`),!1}},w=async()=>{try{await G?.shutdown()}catch{}await Pn();try{return G=new Ut({env:u,runner:a,log:(_,P,O,S)=>d.log(_,P,O,S),sessionId:d.sessionId}),await G.start(m(q)),x.kind==="device"&&x.device.no_reset===!0&&d.log("warn","DEVICE_RECYCLED_DIRTY","no_reset: true \u2014 the re-attempt keeps the app state the broken replay left behind"),d.log("info","DEVICE_RECYCLED","Fresh device session brought up for the replay re-attempt"),!0}catch(_){return d.log("error","RECYCLE_FAILED","Could not bring up a fresh device session for the replay re-attempt",{error:_.message}),process.stderr.write(`error: could not recycle the device session for the replay re-attempt: ${_.message}
|
|
64
|
-
`),!1}},g=s.author===!0;g&&(jr(),d.log("info","FORCE_AUTHOR_RUN","--author flag set; walker bypassed; identity kept"));let{authorBoundary:I,cancelledInPhase:D,shrinkCount:$}=await ms({decisions:h.decisions,forceAuthor:g,hasRetry:ln,onReplayOnlyFail:Ve,maxShrinks:mt.maxShrinks,runReplayPhase:bi,session:d,accumulator:de,acquireLockIfNeeded:An,archiveAttempt:_n,recycleBrowser:x.kind==="web"&&Ie&&Q.ownsLifecycle?y:x.kind==="device"&&!lt(x.device.target)&&Q.ownsLifecycle?w:void 0});if(ht=$>0,et=I,er=$,$>0&&(d.log("info","ADAPTIVE_HEAL_TRIGGERED","Adaptive heal engaged",{shrink_count:$,final_author_boundary:I}),t.onAdaptiveHeal({shrink_count:$,final_author_boundary:I,complete_reauthor:I===0})),I===0&&$>0&&d.log("info","COMPLETE_REAUTHOR_TRIGGERED","Complete reauthor fallback",{shrink_count:$}),!D&&I>=0)for(let _=I;_<i.steps.length&&!e.signal?.aborted;_++){let P=i.steps[_],O=await Rn(_);if(O?.kind==="done"){if(O.stop)break;continue}if(O?.kind==="jump"){_=O.to-1;continue}if(O?.kind==="author"&&P.replayOnly){Oe(_,P.replayOnly),Ve(_,P.replayOnly),de.recordStep(P,{status:"failed",duration_s:0,reason:`replay-only step @${P.replayOnly} has no recording`});break}if(vt()){de.recordStep(P,{status:"failed",duration_s:0,reason:"v16-runner exited unexpectedly mid-session"});break}if(!de.shouldRunFlatStep(P))continue;let S=h.decisions[_];if(S?.kind==="replay"&&S.replayOnly){let W=await Cn(_);if(W){W.cancelled||(Oe(_,S.replayOnly),Ve(_,S.replayOnly));break}continue}let{continueOverall:B}=await En(_);if(!B||F||e.signal?.aborted)break}}else{if(ze.hasBlocks(i.steps))return process.stderr.write(`error: this test has if/else or while blocks (@if \u2026 @end-if, @while \u2026 @end-while), which run in agent mode only \u2014 re-run with --agent
|
|
65
|
-
`),r.cleanup("marker-overlay","control-flow blocks need agent mode"),r.cleanup("chrome","control-flow blocks need agent mode"),await d.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:ee(n),durationS:0,uploadResult:null};let{effectiveDecisions:a}=await import("./effective-decisions-UNE2TFVA.js"),{decideRetry:u}=await import("./replay-policy-A62KXE6Y.js"),m=ln,y=mt.maxShrinks,w=s.author===!0;w&&(jr(),d.log("info","FORCE_AUTHOR_RUN","--author flag set; walker bypassed; identity kept"));let g=w?0:ut(h.decisions),I=0,D=null,$=x.kind==="device"?x.device.no_reset:void 0,_=0,P=()=>_++===0?$??!1:!0,O=h.decisions.filter(A=>A.kind==="replay").length,S=h.decisions.length-O,B=[];s.push&&B.push("--push"),m||B.push("--no-adaptive-heal"),w&&B.push("--author");let W={source:n,steps:{total:h.decisions.length,replay:O,author:S},model:T,viewport:{width:N.window_size.width,height:N.window_size.height},chrome:q.cdpEndpoint??(xe()?q.wsEndpoint?.split("?")[0]:q.wsEndpoint)??"managed",session:d.sessionName??"ephemeral",variables:{count:Object.keys(le.raw).length,secrets:Object.values(le.raw).filter(A=>A.secret).length,names:Object.keys(le.raw)},flags:B,mode:v.mode??"testing"};for(;;){let A=d.snapshot(),V=de.snapshot();_=0;let U=a(h.decisions,g,w);if(I>=1){let j=g===0?`\u{1FA79} Healing \u2014 full re-author, heal budget exhausted (${I}/${y})`:`\u{1FA79} Healing ${I}/${y} \u2014 replay 0..${g-1}, re-author ${g}..${h.decisions.length-1}
|
|
66
|
-
reason: replay miss at step ${(D??0)+1}`;process.stderr.write(j+`
|
|
67
|
-
`)}let at=I>=1&&g>0&&D!==null?{startIdx:0,endIdx:D,count:D}:void 0;z?.setRunActive(!0);let ge=await Fa({decisions:U,resolved:i,session:d,accumulator:de,tuiConfig:N,globalConfig:W,buildStepConfigAt:(j,ce)=>{let ne=cr(j,ce);return x.kind==="device"&&ne.device&&(ne.device={...ne.device,no_reset:P()}),ne},buildReplayConfig:j=>{let ce=h.decisions[j];if(ce.kind!=="replay")throw new Error("expected replay decision at index "+j);let ne=i.steps[j];return Fr({step:ne,decision:ce,chrome:q,device:x.kind==="device"?{...x.device,no_reset:P()}:void 0,auth:c,sessionId:d.sessionId,runIndex:d.nextRunIndex(),sessionDir:d.sessionDir,windowSize:{width:N.window_size.width,height:N.window_size.height},environmentId:bt,forceNavigateUrl:x.kind==="device"?void 0:j===0?Re??void 0:ne.unitEntryUrl,sessionContext:d.getContext(),variables:Pa(Te.raw,ne.config.variables,ne.objective),evidence:dr()})},onAnyAuthorStep:j=>{pe=!0,gt.add(i.steps[j].flatIndex)},onCancel:()=>{me=!0},topBannerModel:T,topBannerAuth:`${E.getActiveProfile()??"no profile"}/${f}`,spawnOpts:{environment:f,mode:v.mode??"testing",assertionMode:un,finalValidation:fn,log:(j,ce,ne,fr)=>d.log(j,ce,ne,fr),...ot?{onRunnerEvent:ot}:{}},priorAttemptRollup:at,reportVerdictOnComplete:xe()||!!re,pushStepLevelDelta:(j,ce)=>ir(Je(Te.raw,j,ce).raw),onSequencerStepEnd:(j,ce,ne,fr)=>{let ki=Math.round((Date.now()-fr)/1e3),_i=j.hadError?j.reason??"runner error":null,Ri=kt(ce,ne,j.runEnd,j.bifurcationFlows??null,_i,ki);return d.recordStepRun({testmdStepIndex:i.steps[ce].flatIndex,runIndex:ne,totalRunDirs:Jt(j.runEnd,j.bifurcationFlows)}),lr(j.evidence??Nt(),j.runEnd,ne,j.bifurcationFlows,i.steps[ce].verifies),Ne+=tt(j.runEnd),U[ce]?.kind==="author"&&(tr+=tt(j.runEnd)),Ri},screenshotDispatcher:st,onReasoning:j=>z?.setStepText(j),onStepComplete:()=>z?.setStepComplete(),onSpawnStart:j=>{yt=j},host:t});if(z?.setRunActive(!1),ge.cancelled){r.cleanup("marker-overlay","user cancelled run"),r.cleanup("chrome","user cancelled run");break}if(ge.failedAt===null)break;let At=h.decisions[ge.failedAt],Ke=u({failedAt:ge.failedAt,shrinkCount:I,hasRetry:m,maxShrinks:y,failedAtReplayOnly:At?.kind==="replay"?At.replayOnly:void 0});if(Ke.kind==="fail"){Ke.replayOnly&&(Oe(ge.failedAt,Ke.replayOnly),Ve(ge.failedAt,Ke.replayOnly));break}if(!R&&!await An()||x.kind==="web"&&Ie&&Q.ownsLifecycle&&!await xn())break;x.kind==="device"&&Q.ownsLifecycle&&await Pn(),await _n(ge.failedAt),d.rollback(A),de.rollback(V),Ke.kind==="complete-reauthor"?g=0:(g=Ke.newAuthorBoundary,I++),ht=!0,d.log("info","RETRY_TRIGGERED","Retry loop triggered (TTY)",{shrink_count:I,failed_at:D}),g===0&&d.log("info","COMPLETE_REAUTHOR_TRIGGERED","Complete reauthor fallback (TTY)",{shrink_count:I}),D=ge.failedAt}et=g,er=I}let Z=de.finalize({cancelled:me}),Ce=Math.round((Date.now()-Sn)/1e3),vi={session:d,resolvedAuth:c,chromeResult:q,chromeInstance:Ie??null,testId:d.testId??null,preparedVariables:le,variableIds:wt,globalContext:vn,localContext:wn,tuiConfig:N,env:f,localMode:!!s.local},Tn=!1,Dn=!1,Ln=!1,mr=!1,On=async(a={})=>{if(!L)return!1;if(Q.ownsLifecycle?Tn:Ln)return!0;try{let u=await nr(),m=on(pe)==="replay",y=qe(n),w=be(d.sessionDir,"execution.json"),g=To(L.packTestDir,m?[y,w]:[w,y],(S,B,W,A)=>d.log(S,B,W,A));we&&Do(L.packTestDir,we.evidenceRecord,(S,B,W,A)=>d.log(S,B,W,A));let{ids:I,linear:D}=g?Oo(L.packTestDir):{ids:[],linear:!0},{steps:$,tail:_,unjoined:P}=Lo(J.steps,I,m,D);g?P?d.log("warn","SKIPPED_TAIL_UNJOINED","Executed records don't align with the authored blob \u2014 skipped tail withheld",{executed:J.steps.length,leaves:I.length}):_.length>0&&d.log("info","SKIPPED_TAIL_APPENDED","Unexecuted authored actions recorded as skipped",{count:_.length}):d.log("warn","SKIPPED_TAIL_NO_BLOB","No auteur blob in pack \u2014 unexecuted actions cannot be recorded as skipped",{});let O=await J.writeResult({steps:[...$,..._],heal:{shrinkCount:er,authorBoundary:et,totalSteps:h.decisions.length,forced:s.author===!0,creditsConsumed:tr},spawns:me?[...Ee,{resultCode:null}]:Ee.length?Ee:[{resultCode:null}],tags:i.rootGlobal.tags,externalIdInput:{...we?we.externalId:{},execution_id:L.executionId,session_id:d.sessionId,commit_id:m?h.fromCommitId??d.sessionId:d.sessionId,test_id:h.testId??d.testId??void 0,testcase_id:a.testcaseId||h.testcaseId||d.testcaseId||void 0,tc_id:nt,project_id:M??void 0,folder_id:_e??void 0,org_id:d.orgId!=null?String(d.orgId):void 0,session_name:d.sessionName??ct(n),user_name:d.userName??void 0,user_email:d.userEmail??void 0,sharable_link:As(oe(f).testManagerUiUrl,M,a.testcaseId??h.testcaseId??d.testcaseId,a.shareId)},runnerEnv:Eo({cdpBrowser:u,resolution:kn,runnerEnvironment:Me,deviceName:ae.deviceName,deviceModel:ae.modelIdentifier,deviceApp:ae.app,...re&&ae.osVersion?{deviceOsVersion:ae.osVersion}:{},pixelResolution:L?await so(L.packTestDir):void 0}),intentEnv:wo(T,Me,Q.ownsLifecycle?void 0:on(pe)),durationMs:Date.now()-Sn,log:(S,B,W,A)=>d.log(S,B,W,A)});if(!Q.ownsLifecycle)return await _o(J.pack,L.testId,be(d.sessionDir,"tui.log"),{requireRealLog:!!Me?.native_platform,appiumMarks:J.appiumMarks}),Ln=!0,d.log("info","EVIDENCE_RESULT_WRITTEN","Member result.yaml written",{execution_id:L.executionId,verdict:O}),!0;if(!Dn)try{await os(wr(process.cwd()),B=>d.log("warn","SYNC_BEHIND",B,{}));let S=xo({cwd:process.cwd(),members:[{path:n,verdict:O,executionId:L.executionId,startedAt:new Date().toISOString(),acs:Ao(J.steps),mode:"testmd",local:!!s.local}]});Dn=!0;for(let B of S.warnings)d.log("warn","EXEC_SYNC",B,{});S.synced>0&&d.log("info","EXEC_SYNC",`context sync: ${S.synced} fact(s), ${S.superseded} supersession(s)`,{})}catch(S){d.log("warn","EXEC_SYNC",`exec-sync failed: ${S instanceof Error?S.message:String(S)}`,{})}try{let S=Po(J.pack,wr(process.cwd()));S.status==="skipped"&&d.log("warn","EVIDENCE_COVERAGE_SKIPPED",`coverage/usecases.yaml not written: ${S.reason}`,{})}catch(S){d.log("warn","EVIDENCE_COVERAGE_SKIPPED","coverage writer threw",{error:String(S)})}return await Ro({executionId:L.executionId,testId:L.testId,saved:!0,runKind:on(pe),verdict:O,outputStemDir:ee(n),cwd:o,packDir:J.pack,tuiLogPath:be(d.sessionDir,"tui.log"),expectStatusDisagrees:(s.bugDetection??N.bug_detection)==="continue",log:(S,B,W,A)=>d.log(S,B,W,A),surface:"testmd",requireRealLog:!!Me?.native_platform,appiumMarks:J.appiumMarks}),Tn=!0,d.log("info","EVIDENCE_SEALED","Evidence pack sealed",{execution_id:L.executionId,verdict:O}),!0}catch(u){return d.log("warn","EVIDENCE_SEAL_FAILED","Evidence pack seal failed",{error:String(u)}),!1}},Rt=Be&&(R||h.isFirstRun)&&!h.degradedReadonly,wi=async()=>{if(!c.basicAuth)return null;let a=oe(f),u=(pe||s.push===!0)&&!me,m=(R||h.isFirstRun)&&!me&&Z.overallStatus==="passed"&&!h.degradedReadonly;d.log("info","PIPELINE_GATE_STATE","Derived gate state (finalize)",{phase:"finalize",shouldUploadArtifacts:Be,shouldUploadPipeline:Rt,shouldReplaceLocalOutput:u,shouldCommit:m,lockHeld:R,anyAuthorStepRan:pe,cancelled:me,overallStatus:Z.overallStatus});let y=Zs({mobile:x.kind==="device",environmentId:bt,session:d,env:f,auth:c,variables:le,variableIds:wt,testParams:we?.testParams,projectId:M,folderId:_e,totalSteps:Z.outcomes.length,totalDuration:Ce,screenshotExtMap:rt?.getExtMap(),codeExport:ei({codeExport:s.codeExport,codeLanguage:s.codeLanguage,skipCodeValidation:s.skipCodeValidation},N.code_export),onProgress:()=>{},log:(g,I,D,$)=>d.log(g,I,D,$),shouldUploadArtifacts:Rt,shouldReplaceLocalOutput:u,shouldCommit:m,isFirstRun:h.isFirstRun,resolvedTest:i,sourcePath:n,stepRunRecords:d.getStepRunRecords(),authoredFlatIdx:[...gt],blockOutcomes:_t?.outcomes(),unitLocks:h.unitLocks,outcomes:Z.outcomes,overallStatus:Z.overallStatus,fromCommitId:h.fromCommitId,startedISO:It,durationS:Ce,tmsIds:{testId:h.testId??d.testId??void 0,testcaseId:h.testcaseId??d.testcaseId??void 0,projectId:M??void 0,folderId:_e??void 0,orgId:d.orgId??void 0,sessionName:d.sessionName??ct(n)},tmsBaseUrl:b.tmsBaseUrl,testId:h.testId??void 0,newCommitId:h.newCommitId??void 0,basicAuth:c.basicAuth??void 0,decisions:h.decisions,wantsPush:s.push===!0,retryTriggered:ht,forceAuthor:s.author===!0,commitBox:Zt,testmdSync:s.testmdSync!==!1,onAgentEvent:g=>t.onAgentEvent(g),evidence:L&&Q.ownsLifecycle?{executionId:L.executionId,packTestDir:L.packTestDir,sealedPackPath:J.pack,cwd:o,runIndices:St,sealFn:On}:void 0,evidenceRead:L&&!Q.ownsLifecycle?{packTestDir:L.packTestDir,runIndices:St}:void 0,authoredExecutionPath:pe?void 0:qe(n)});h.newCommitId!=null&&(y.skipTmsFinalize=!0);let w=new es(y);return l?await w.execute():await t.runUpload(w,g=>{if(g.testcaseId&&g.shareId&&M)return Gt(a.testManagerUiUrl,M,g.testcaseId,g.shareId)})};L&&await nr(),G&&(await G.shutdown(xe()||re?me?oo:no(Z.overallStatus):{}),r.cleanup("runner","test.md run complete"));let fe=await Gs(vi,{performUpload:wi,runCleanup:()=>{r.cleanup("chrome","test.md run complete")},log:(a,u,m,y)=>d.log(a,u,m,y)},{overallStatus:Z.overallStatus,outcomes:Z.outcomes,sourcePath:n,title:i.rootTitle,rootSteps:i.rootSteps,startedISO:It,durationS:Ce,localMode:!!s.local,skipLocalWrites:!0,mobile:x.kind==="device"});Q.ownsLifecycle&&Rt&&fe.uploadResult?.success&&(mr=!0);let jn=await On({testcaseId:fe.uploadResult?.testcaseId,shareId:fe.uploadResult?.shareId}),Fn=s.evidencePublish===!1,Un=Q.ownsLifecycle&&!!L&&!!c.basicAuth&&si({shouldUploadArtifacts:Be,lockHeld:R,isFirstRun:h.isFirstRun,sealed:jn,testId:h.testId});if(Un&&Fn)d.log("info","EVIDENCE_PUBLISH_SKIPPED","Replay evidence publish skipped (--no-evidence-publish)",{execution_id:L.executionId}),process.stderr.write(`info: evidence publish skipped (--no-evidence-publish)
|
|
68
|
-
`);else if(Fn&&(R||h.isFirstRun))process.stderr.write(`note: --no-evidence-publish has no effect on author/commit runs
|
|
69
|
-
`);else if(Un){let a=c.basicAuth,u=L,m=M,y=await ii({controller:new De(b.controllerBaseUrl,{username:a.username,accessKey:a.access_key}),tms:new Ot(b.tmsBaseUrl,c.resolvedCreds?.username??a.username,c.resolvedCreds?.access_key??a.access_key),testId:h.testId,sessionId:d.sessionId,executionId:u.executionId,sealedPackPath:J.pack,projectId:m});mr=y.ok,y.ok?d.log("info","EVIDENCE_INGESTED","Replay evidence uploaded and ingested",{execution_id:u.executionId,project_id:m}):(d.log("warn","EVIDENCE_PUBLISH_FAILED","Replay evidence publish failed",{execution_id:u.executionId,stage:y.stage,error:y.error}),process.stderr.write(` \u26A0 evidence publish failed (${y.stage}): ${y.error}
|
|
70
|
-
`)),t.onAgentEvent({type:"test_md_evidence_ingest",status:y.ok?"ok":"failed",evidence_id:u.executionId,...y.ok?{}:{stage:y.stage}})}if(K=!0,await Oa(n,h,d,Z.outcomes,Z.overallStatus,It,Ce,fe.uploadResult,N,s,{resolvedAuth:c,tmsBaseUrl:b.tmsBaseUrl},R,me,Zt.committed),h.isFirstRun&&s.testmdSync!==!1)try{let a=he(n);if(Ko({shouldUploadPipeline:Rt,uploadSucceeded:!!fe.uploadResult?.success,metaCommitId:a?.commit_id,metaTestId:a?.test_id})){let u=await Bt({sourcePath:n,testId:a.test_id,sessionId:d.sessionId,commitId:a.commit_id,controller:new De(b.controllerBaseUrl,{username:c.basicAuth.username,accessKey:c.basicAuth.access_key})});u.ok?d.log("info","BUNDLE_SYNC_OK","testmd bundle pushed",{commit_id:a.commit_id,bytes:u.bytes}):(d.log("warn","BUNDLE_SYNC_FAILED","testmd bundle sync failed",{commit_id:a.commit_id,stage:u.stage,error:u.error}),process.stderr.write(` \u26A0 bundle sync failed (${u.stage}): ${u.error}
|
|
71
|
-
`)),t.onAgentEvent({type:"test_md_bundle_sync",status:u.ok?"ok":"failed",commit_id:a.commit_id,path:n,...u.ok?{bytes:u.bytes}:{stage:u.stage}})}}catch(a){d.log("warn","BUNDLE_SYNC_FAILED","testmd bundle sync threw",{error:a instanceof Error?a.message:String(a)})}else h.isFirstRun&&d.log("info","BUNDLE_SYNC_SKIPPED","testmd bundle sync skipped",{reason:"flag"});let Nn=oe(f),Et=fe.uploadResult?.testcaseId,Ct=Et&&fe.uploadResult?.shareId&&M?Gt(Nn.testManagerUiUrl,M,Et,fe.uploadResult.shareId):void 0,Ii=i.unitFiles.filter(a=>a.file!==i.rootPath).map(a=>{let u=i.steps.filter(g=>g.owningFile===a.file),m=u.filter(g=>gt.has(g.flatIndex)).length,w=(a.kind==="test"?he(a.file):null)?.commit_id===d.sessionId;return{path:a.file,kind:a.kind,replayed:u.length-m,authored:m,committed:w,...w?{commit_id:d.sessionId}:{}}}),$n={overallStatus:Z.overallStatus,durationS:Ce,creditsConsumed:Ne,decisions:h.decisions,outcomes:Z.outcomes,cancelled:me,retryTriggered:ht,lockHeld:R,anyAuthorStepRan:pe,isFirstRun:h.isFirstRun,wantsPush:s.push===!0,uploadResult:fe.uploadResult,shouldUploadArtifacts:Be,shouldReplaceLocalOutput:pe&&!me,shouldCommit:(R||h.isFirstRun)&&!me&&Z.overallStatus==="passed"&&!h.degradedReadonly,committed:Zt.committed,shareUrl:Ct,imports:Ii},{buildSummaryEvent:Si}=await import("./SummaryBox-6RB5DSAH.js");if(l?t.onAgentEvent(Si($n)):await t.onSummary($n),!l){let a=Et&&M?xs(Nn.testManagerUiUrl,M,Et):void 0;await t.onLinks({recordedTestPath:n,outputDir:ee(n),shareableLink:Ct,testCaseLink:a,codeExportDir:fe.uploadResult?.codeExportDir})}if(Q.ownsLifecycle&&J&&jn&&!e.suppressEvidenceOffer){let{offerEvidenceView:a}=await import("./evidence-NPFTBGDF.js");await a({packPath:J.pack,env:f,isTTY:!l&&!me&&!!process.stdin.isTTY&&!!process.stderr.isTTY,log:u=>process.stderr.write(u+`
|
|
72
|
-
`)})}return t.onAgentEvent({type:"test_md_done",overall_status:Z.overallStatus,duration_s:Ce,session_id:d.sessionId,...Ct?{share_url:Ct}:{}}),await d.reportCompletedSession({runsCompleted:d.getStepRunRecords().length,creditsConsumed:Ne,durationSeconds:Ce}),{overallStatus:Z.overallStatus,exitCode:Z.overallStatus==="passed"?0:1,outputDir:ee(n),durationS:Ce,creditsConsumed:Ne,uploadResult:fe.uploadResult,anyAuthorStepRan:pe,resultCode:ko(Ee),...ur.length?{pendingInvestigations:ur}:{},ownPack:Q.ownsLifecycle?oi({executionId:L?.executionId,testId:h.testId??L?.testId,testcaseId:fe?.uploadResult?.testcaseId,commitId:d.sessionId,published:mr}):void 0}}finally{!K&&(R||h.unitLocks.length>0)&&await ja(h,d,R,{resolvedAuth:c,tmsBaseUrl:b.tmsBaseUrl})}}function Aa(e){if((e.env??process.env).KANE_CLI_MODE==="hyperexecute")return null;let t=Mo({globalDir:e.globalDir,localDir:be(e.cwd,".testmuai","variables"),file:e.opts.variablesFile,inline:e.opts.variables}),r=rs(e.resolved,t,{authorFrom:e.authorFrom,produced:e.produced});return r.length===0?null:{text:Dr(r,{cwd:e.cwd,entryFile:Ue(e.resolved.rootPath)}),event:Lr(r,{cwd:e.cwd})}}function xa(e,t){let r={...e,...t,...gr(e)},n=Object.keys(r).length>0?Ge(r,""):{variables:{},objective:"",keyMap:{}};return{raw:r,auteur:n.variables,auteurObjective:"",...Wr(r)}}function Je(e,t,r){let n={...e,...t??{},...gr(e)};if(Object.keys(n).length===0)return{raw:n,variables:{},objective:r};let o=Ge(n,r);return{raw:n,variables:Bs(o.variables,o.objective),objective:o.objective}}function Pa(e,t,r){let n=Je(e,t,r).variables;return Object.keys(n).length>0?n:void 0}function Ta(e,t){return e.max_steps??t??50}function di(e,t){let r=new Set(Qt),n={...e};for(let[o,s]of Object.entries(t))r.has(o)||o!=="variables"&&s!==void 0&&e[o]===void 0&&(n[o]=s);return n}function Da(e,t){return e.length<=t?e:e.slice(0,t-1)+"\u2026"}async function La(e,t,r,n,o,s){let l=Go(t);ss(t,l);let p=Se(e),i=_a(p)?JSON.parse(ci(p,"utf8")):null,c=i?.testcase_id,v=i?.test_id,f=i?.commit_id,b=r.push===!0,k=r.author===!0;b&&!c&&process.stderr.write(`[--push] no meta.json yet \u2014 flag is a no-op on first run
|
|
73
|
-
`);let T=n.resolvedAuth.basicAuth;if(!T){let te=await n.resolvedAuth.resolver.resolve(!0);te?.username&&te?.access_key&&(T={username:te.username,access_key:te.access_key},n.resolvedAuth.basicAuth=T)}let E=!!T,C=!r.local&&E&&v!=null&&f!=null&&c!=null,d=C&&(Mt(l)||b||k),F=Ho(t,l);if(F.length>0)return process.stderr.write(`error: replay-only step(s) cannot be replayed \u2014 the agent cannot author them, so the run will not start:
|
|
74
|
-
`+F.map(ie=>` step ${ie.flatIndex} "${ie.heading}" @${ie.kind} \u2014 ${ie.reason} (${ie.file})`).join(`
|
|
75
|
-
`)+`
|
|
76
|
-
Regenerate the test from KaneAI, or drop the marker to let the agent author the step.
|
|
77
|
-
`),{resolved:t,decisions:l,testId:v,testcaseId:c,fromCommitId:f,newCommitId:null,isFirstRun:!1,hasAuth:E,canLock:C,lockAcquired:!1,unitLocks:[],degradedReadonly:!1,abort:{exitCode:2}};if(b&&!C)return process.stderr.write(`error: --push requires authenticated credentials for the lock API. Run 'kane-cli login' (OAuth) or pass --username/--access-key inline.
|
|
78
|
-
`),{resolved:t,decisions:l,testId:v,testcaseId:c,fromCommitId:f,newCommitId:null,isFirstRun:!1,hasAuth:E,canLock:C,lockAcquired:!1,unitLocks:[],degradedReadonly:!1,abort:{exitCode:2}};if(k&&!E)return process.stderr.write(`error: --author requires authenticated credentials for the TMS API. Run 'kane-cli login' (OAuth) or pass --username/--access-key inline.
|
|
79
|
-
`),{resolved:t,decisions:l,testId:v,testcaseId:c,fromCommitId:f,newCommitId:null,isFirstRun:!1,hasAuth:E,canLock:C,lockAcquired:!1,unitLocks:[],degradedReadonly:!1,abort:{exitCode:2}};let h=null,R=!1,K=!1;if(d){h=o;let ie=r.onLockConflict??t.rootGlobal.on_lock_conflict??"readonly",te=await sn({tmsBaseUrl:n.tmsBaseUrl,testId:v,fromCommitId:f,newCommitId:h,basicAuth:T,onLockConflict:ie});if(te.outcome==="ok")R=!0,Kt({baseUrl:Qe(n.tmsBaseUrl),testId:v,auth:Ze(T),lifecycle:s});else{if(te.outcome==="abort")return{resolved:t,decisions:l,testId:v,testcaseId:c,fromCommitId:f,newCommitId:null,isFirstRun:!1,hasAuth:E,canLock:C,lockAcquired:!1,unitLocks:[],degradedReadonly:!1,abort:{exitCode:2}};h=null,K=!0,k&&process.stderr.write(te.reason==="disabled"?`[lock] --author: re-authoring locally in readonly mode (not committed); this test cannot be evolved, so the changes stay local
|
|
80
|
-
`:`[lock] --author: re-authoring locally in readonly mode (not committed); run again with --push once the playground is free
|
|
81
|
-
`)}}let Pe=[],se=d&&!R;if(!r.local&&E&&!se){let ie=r.onLockConflict??t.rootGlobal.on_lock_conflict??"readonly",te=await ui({resolved:t,decisions:l,allUnits:k,tmsBaseUrl:n.tmsBaseUrl,newCommitId:h??o,basicAuth:T,mode:ie,lifecycle:s});if(te.outcome==="ok")Pe=te.locks;else{if(R&&v&&f&&h&&await pt(n,v,f,h),ye(),te.outcome==="abort")return{resolved:t,decisions:l,testId:v,testcaseId:c,fromCommitId:f,newCommitId:null,isFirstRun:c==null,hasAuth:E,canLock:C,lockAcquired:!1,unitLocks:[],degradedReadonly:!1,abort:{exitCode:2}};process.stderr.write(`[lock] imported-unit conflict \u2014 whole run degrades to readonly (no commits, no uploads)
|
|
82
|
-
`),h=null,R=!1,K=!0}}return{resolved:t,decisions:l,testId:v,testcaseId:c,fromCommitId:f,newCommitId:h,isFirstRun:c==null,hasAuth:E,canLock:C,lockAcquired:R,unitLocks:Pe,degradedReadonly:K}}async function ui(e){let t=new Set(e.resolved.steps.filter((n,o)=>e.decisions[o]?.kind==="author").map(n=>n.owningFile)),r=[];for(let n of e.resolved.unitFiles){if(n.kind!=="test"||n.file===e.resolved.rootPath||!e.allUnits&&!t.has(n.file)||e.alreadyLocked?.some(l=>l.file===n.file))continue;let o=he(n.file);if(!o?.test_id||!o?.commit_id)continue;let s=await sn({tmsBaseUrl:e.tmsBaseUrl,testId:String(o.test_id),fromCommitId:String(o.commit_id),newCommitId:e.newCommitId,basicAuth:e.basicAuth,onLockConflict:e.mode});if(s.outcome==="ok"){r.push({file:n.file,testId:String(o.test_id),fromCommitId:String(o.commit_id)}),Kt({baseUrl:Qe(e.tmsBaseUrl),testId:String(o.test_id),auth:Ze(e.basicAuth),lifecycle:e.lifecycle});continue}if(s.outcome==="readonly"&&s.reason==="disabled"){process.stderr.write(`[lock] ${n.file}: playground disabled \u2014 this unit will not be committed
|
|
83
|
-
`);continue}for(let l of r)await je({baseUrl:Qe(e.tmsBaseUrl),testId:l.testId,body:{commitId:e.newCommitId,fromCommitId:l.fromCommitId},auth:Ze(e.basicAuth)}),ye(l.testId);return{outcome:s.outcome,locks:[]}}return{outcome:"ok",locks:r}}function Qe(e){return`${e}/kane-cli/v1`}function Ze(e){return{username:e.username,accessKey:e.access_key}}async function sn(e){let t=Qe(e.tmsBaseUrl),r=Ze(e.basicAuth),n={baseUrl:t,testId:e.testId,fromCommitId:e.fromCommitId,newCommitId:e.newCommitId,auth:r},o=await Nr(n);if(o.ok)return{outcome:"ok"};if(o.reason==="disabled")return process.stderr.write(`[lock] ${o.message}
|
|
84
|
-
[lock] running in readonly mode (no commit)
|
|
85
|
-
`),{outcome:"readonly",reason:"disabled"};if(!(o.reason==="concurrent"||o.reason==="base_mismatch"))return process.stderr.write(`[lock] acquire failed: ${o.reason} (HTTP ${o.httpStatus}): ${o.message}
|
|
86
|
-
`),{outcome:"abort"};let l=o.reason,p=o.reason==="concurrent"?"concurrent session":"base commit mismatch (pull latest)";if(e.onLockConflict==="fail")return process.stderr.write(`[lock] ${p}; aborting (--on-lock-conflict fail)
|
|
87
|
-
`),{outcome:"abort"};if(e.onLockConflict==="wait"){if(o.reason==="base_mismatch")return process.stderr.write(`[lock] base commit mismatch \u2014 pull latest; aborting
|
|
88
|
-
`),{outcome:"abort"};for(;;){process.stderr.write(`[lock] waiting (concurrent session)...
|
|
89
|
-
`),await new Promise(c=>setTimeout(c,3e4));let i=await Nr(n);if(i.ok)return{outcome:"ok"};if(i.reason!=="concurrent")return process.stderr.write(`[lock] wait drifted to ${i.reason} (HTTP ${i.httpStatus}): ${i.message}; aborting
|
|
90
|
-
`),{outcome:"abort"}}}return process.stderr.write(`[lock] ${p} \u2014 running in readonly mode (no commit)
|
|
91
|
-
`),{outcome:"readonly",reason:l}}async function Oa(e,t,r,n,o,s,l,p,i,c,v,f,b,k){let{decisions:T,testId:E,testcaseId:C,fromCommitId:d,newCommitId:F}=t,h=o==="passed";if(!k){let R=b?"cancelled":h?"commit did not land":o;f&&E&&d&&F&&(process.stderr.write(`[lock] run not committed (${R}); discarding playground lock
|
|
92
|
-
`),await pt(v,E,d,F));for(let K of t.unitLocks)await pt(v,K.testId,K.fromCommitId,F??r.sessionId);ye();return}ye()}async function ja(e,t,r,n){let o=e.newCommitId??t.sessionId,s=e.unitLocks.length;process.stderr.write(`[lock] run exited before finalize; discarding playground lock${s?` + ${s} unit lock${s===1?"":"s"}`:""}
|
|
93
|
-
`);try{t.log("warn","LOCKS_RELEASED_EARLY_EXIT","Run exited before finalize; discarding held playground locks",{test_id:e.testId??null,unit_locks:s})}catch{}try{r&&e.testId&&e.fromCommitId&&await pt(n,e.testId,e.fromCommitId,o);for(let l of e.unitLocks)await pt(n,l.testId,l.fromCommitId,o)}finally{ye()}}async function pt(e,t,r,n){let o=e.resolvedAuth.basicAuth;if(!o){let l=await e.resolvedAuth.resolver.resolve(!0);l?.username&&l?.access_key&&(o={username:l.username,access_key:l.access_key},e.resolvedAuth.basicAuth=o)}if(!o)return;let s=await je({baseUrl:Qe(e.tmsBaseUrl),testId:t,body:{commitId:n,fromCommitId:r},auth:Ze(o)});s.ok||process.stderr.write(`warn: discardLock failed: ${s.reason} (HTTP ${s.httpStatus}): ${s.message}
|
|
94
|
-
`)}async function Fa(e){let t=null,r=!1,n=0,o=-1,s=-1,l=0,p=async i=>{if(i&&i.status==="failed")return n>0&&e.decisions[n-1].kind==="replay"&&(t=n-1),null;for(;n<e.decisions.length&&!e.accumulator.shouldRunFlatStep(e.resolved.steps[n]);)n++;if(n>=e.decisions.length)return null;let c=e.decisions[n],v=e.resolved.steps[n],f=n;n++;let b=e.session.nextRunIndex();o=f,s=b,l=Date.now(),e.onSpawnStart?.(b),c.kind==="author"&&e.onAnyAuthorStep(f),await e.pushStepLevelDelta(v.config.variables,v.objective);let k=c.kind==="replay"?e.buildReplayConfig(f):e.buildStepConfigAt(f,b),T=c.kind==="replay"?"md5-match":c.reason,E=v.config??{},C={};for(let[d,F]of Object.entries(E))F!=null&&d!=="variables"&&d!=="assurance"&&(C[d]=F);return{config:k,banner:{stepLabel:`Step ${f+1}/${e.decisions.length}`,objective:Da(v.objective,100)},mode:c.kind,modeReason:T,perStepOverrides:Object.keys(C).length>0?C:void 0}};return await e.host.runSteps({topBanner:{model:e.topBannerModel,auth:e.topBannerAuth},globalConfig:e.globalConfig,getNextStep:p,onStepEnd:i=>(i.status==="failed"&&o>=0&&e.decisions[o]?.kind==="replay"&&(t=o),e.onSequencerStepEnd(i,o,s,l)),onAllComplete:()=>{},onCancel:()=>{r=!0,e.onCancel()},spawnOpts:e.spawnOpts,priorAttemptRollup:e.priorAttemptRollup,...e.reportVerdictOnComplete?{reportVerdictOnComplete:!0,runVerdict:()=>e.accumulator.finalize().overallStatus}:{},screenshotDispatcher:e.screenshotDispatcher,onReasoning:e.onReasoning,onStepComplete:e.onStepComplete}),{failedAt:t,cancelled:r}}export{Ss as a,ks as b,Vr as c,tl as d,ws as e,Is as f,al as g,Mr as h,_s as i,Rs as j,Gt as k,As as l,xs as m,xe as n,Ds as o,Hr as p,Ls as q,xl as r,Pl as s,Tl as t,Gr as u,We as v,Bs as w,Ms as x,Vs as y,Hs as z,Yr as A,Zs as B,Bd as C,ei as D,ti as E,ri as F,ni as G,rn as H,ic as I,ii as J,on as K,Ou as L,xa as M,Je as N,Pa as O,Ta as P,di as Q};
|
package/dist/chunk-PEDINHVU.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as _}from"./chunk-WNOC6MQC.js";import{a as A}from"./chunk-YCCUBQY4.js";import{a as B}from"./chunk-2KVECC36.js";import{a as R}from"./chunk-ZC2CKWLB.js";import{a as k}from"./chunk-NMSZ7G6P.js";import{y as c}from"./chunk-5TQFOPJV.js";import{a as P}from"./chunk-HCBYKLMW.js";import{a as u,b as l}from"./chunk-C44QQJR4.js";import{a as J}from"./chunk-6YGTRKDT.js";import{e as L}from"./chunk-UR6MHSHU.js";var t=L(J(),1);var e=L(P(),1);function X(n,i,y,m){return{id:n,label:`${i} (${n}) \xB7 ${y} tests`,isActive:n===m}}function W({resolver:n,projectId:i,currentFolderId:y,env:m,onSelect:x,onCancel:w}){let[I,M]=(0,t.useState)([]),[$,d]=(0,t.useState)(!0),[O,g]=(0,t.useState)(!1),[U,N]=(0,t.useState)(null),[p,b]=(0,t.useState)("list"),[S,v]=(0,t.useState)(""),[E,f]=(0,t.useState)(null),h=(0,t.useRef)(!1);(0,t.useEffect)(()=>{if(!n){N("Login first to browse folders"),d(!1);return}let o=new AbortController;return d(!0),g(!0),(async()=>{try{let r=n.cached??await n.resolve();if(!r){N("Login first to browse folders"),d(!1),g(!1);return}let a=k(m),T=new B(a.tmsBaseUrl,r.username,r.access_key),F=(async function*(){if(o.signal.aborted)return;let s=await T.listFolders(i);yield{page:1,folders:s,totalLoaded:s.length,done:!0}})();for await(let s of F){if(d(!1),s.totalLoaded===0){h.current=!0,b("naming"),g(!1);return}M(s.folders.map(C=>X(C.id,C.name,C.test_cases_count,y))),s.done&&g(!1)}}catch(r){if(r?.name==="AbortError")return;N(r instanceof Error?r.message:String(r)),d(!1),g(!1)}})(),()=>o.abort()},[n,i,y,m]);let D=(0,t.useCallback)(o=>{let r=o.trim();if(!r){f("Name cannot be empty");return}if(!i){f("No project selected \u2014 pick a project first");return}f(null),b("creating"),(async()=>{try{if(!n)throw new Error("Not authenticated");let a=n.cached??await n.resolve();if(!a)throw new Error("Not authenticated");let T=k(m),s=await new B(T.tmsBaseUrl,a.username,a.access_key).createFolder(i,r);x(s.id,s.name)}catch(a){f(a instanceof Error?a.message:String(a)),b("naming")}})()},[n,i,m,x]),H=(0,t.useCallback)(()=>{v(""),f(null),h.current?w():b("list")},[w]);return p==="naming"||p==="creating"?(0,e.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:c.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:c.orange,bold:!0,children:"Create new folder"}),h.current&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.dim,children:"No folders yet \u2014 let's create one."})}),(0,e.jsxs)(u,{marginTop:1,children:[(0,e.jsx)(l,{color:c.dim,children:"Name: "}),p==="naming"?(0,e.jsx)(A,{value:S,onChange:o=>{v(o),E&&f(null)},onSubmit:D,onCancel:H}):(0,e.jsx)(l,{children:S})]}),E&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.red,children:E})}),p==="creating"&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.dim,children:"Creating..."})}),p==="naming"&&(0,e.jsx)(R,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:h.current?"cancel":"back"})]}):(0,e.jsx)(_,{title:"Folders",items:I,loading:$,loadingMore:O,preserveSelectionById:!0,error:U,itemNoun:"folders",onTab:()=>{h.current=!1,b("naming")},extraHint:"tab to create new",onSelect:o=>{let r=o.label.split(" (")[0];x(o.id,r)},onCancel:w})}export{X as a,W as b};
|
package/dist/chunk-PNUAP3RY.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as K}from"./chunk-OJAXOOZ5.js";import{a as U,b as Y,c as q}from"./chunk-KJQNAOOE.js";import{a as B}from"./chunk-KDNNMU7Q.js";import{d as j}from"./chunk-WESMQEPO.js";import{j as N,n as F,z as k}from"./chunk-IICT4VOU.js";import{a as L,b as V,c as G}from"./chunk-3UI5VTQS.js";import{F as I}from"./chunk-RDHWNSDP.js";import{f as v,g as x,i as H}from"./chunk-XLSOQLVT.js";function te(t,e,n,i,s){let f=n.rows.filter(u=>{let d=i.get(u.temp_ref);return d!==void 0&&d!=="reject"});if(f.length===0)return{record:null,errors:null};let o={version:1,read_basis:e.latestHash,source:{source_id:n.source_id,source_cid:e.heads.get(n.source_id)??""},use_cases:f.map(u=>u.uc)},p=new Map;for(let u of f){let d=i.get(u.temp_ref);typeof d=="object"?p.set(u.temp_ref,{resolution:"edited",edit:d.edited}):p.set(u.temp_ref,{resolution:u.uc.matches_existing&&u.uc.changed?"edited":"approved"})}let g=q(o,e,n.staged_source_cid);if(g.errors!==null)return{record:null,errors:g.errors};let r=g.proposal,l=o.source.source_cid?D(t,e,o.source.source_cid):null;if(l!==null){r=Y(r,l);let u=N(r,U(l),e);if(u.length>0)return{record:null,errors:[{code:"HELD_CITES_STALE",detail:"the source moved after this plan staged \u2014 its quotes no longer verify against the current head; re-run kane-cli maintain reconcile to re-stage"},...u]}}let m=`held-${(e.latestHash??"root").slice(-12)}-${f.length}`;return F({contextDir:t,graph:e,proposal:r,proposalId:m,verdicts:p,by:s,autoName:!0})}function Z(t,e,n=[]){let i=K(t,e),s=new Set,f=[],o=l=>{!l||s.has(l)||(s.add(l),f.push(y(t,l)))};for(let l of i.pairs)o(l.scenario),o(l.test);for(let[l,m]of i.verifies){o(l);for(let u of m)o(u)}if(n.length===0)return{stale_refs:f};let p=l=>`${String(l.props.source_id)}\0${String(l.props.anchor)}`,g=new Set;for(let{cid:l}of t.byLabel(v.USECASE))if(t.tipOf(l)===e)for(let m of t.edgesInto(l)){if(m.type!==x.DERIVES)continue;let u=m.props.claim;typeof u=="string"&&n.includes(u)&&g.add(p(m))}if(g.size===0)return{stale_refs:f};let r=new Set;for(let[l,m]of i.verifies)if(t.edgesInto(l).some(d=>d.type===x.DERIVES&&g.has(p(d)))){r.add(y(t,l));for(let d of m)r.add(y(t,d))}return{stale_refs:f,...r.size>0?{direct_refs:[...r]}:{}}}var X="this release plans changes only \u2014 blast-radius impact and drift meaning-checks are not measured, and REMOVE rows are never executed automatically",ne="suite untouched; graph updated";function M(t,e){return!t.superseded.has(e)&&t.trust.get(e)!=="archived"}function y(t,e,n=new Set){let i=t.nameOf.get(e);if(i!==void 0)return i;if(n.has(e))return e;n.add(e);for(let[s,f]of t.superseded){if(f!==e)continue;let o=y(t,s,n);if(o!==s)return o}return e}function C(t){return String(t).slice(0,19)}function A(t,e,n){let i=t.edgesFrom(e).find(s=>s.type===n);return i?t.tipOf(i.dst):null}function z(t,e){let n=t.nodeLabel.get(e);if(n===v.USECASE)return e;if(n===v.SCENARIO)return A(t,e,x.BELONGS_TO);if(n===v.AC){let i=A(t,e,x.SCOPED_TO);return i?t.nodeLabel.get(i)===v.USECASE?i:A(t,i,x.BELONGS_TO):null}if(n===v.TEST){let i=A(t,e,x.AUTOMATES);return i?A(t,i,x.BELONGS_TO):null}return null}function J(t,e){let n=[],i=new Map;for(let s of t.derivesInto(e))i.set(String(s.props.source_id),s);for(let[s,f]of i){let o=t.heads.get(s);if(o==null){n.push(`DERIVES pin ${s} @ ${C(f.props.source_cid)} \u2014 source retired`);continue}if(o!==f.props.source_cid){let p=t.convChains.get(s)?.chain;if(p&&p.includes(String(f.props.source_cid)))continue;n.push(`DERIVES pin ${s} @ ${C(f.props.source_cid)} \u2014 source head moved to ${C(o)}`)}}for(let s of t.edgesFrom(e))H(s.type)?.pin?.comparesTo==="dst_tip"&&t.superseded.has(s.dst)&&n.push(`${s.type} pin \u2192 ${y(t,s.dst)} \u2014 target superseded`);return n.join("; ")||"structural pin broken"}var se=new Set([v.USECASE,v.SCENARIO,v.AC,v.TEST]);function $(t,e){return t.ref<e.ref?-1:t.ref>e.ref?1:0}function D(t,e,n){let i=B(t,e,n);return i===null?null:i.toString("utf8")}function oe(t,e,n,i,s){let f=n.props.quote;if(typeof f=="string"&&f.length>0)return G(f,i);let o=String(n.props.source_cid);s.has(o)||s.set(o,D(t,e,o));let p=s.get(o);if(p===null)return!1;let g=V(p,String(n.props.anchor));return g===null?!1:g.split(`
|
|
3
|
-
`).some(r=>r.trim().length>0&&i.includes(r.trim()))}function re(t,e,n){let i=L(String(e.props.anchor));if(i?.kind!=="img-part")return!1;let f=(t.mediaOf(String(e.props.source_cid)).images??[]).find(r=>r.ref===i.ref),o=f?.blob;if(o===void 0)return!1;let p=t.mediaOf(n).images??[];if(p.some(r=>r.blob===o))return!0;let g=f?.appearance;return g!==void 0&&p.filter(r=>r.appearance===g).length===1}var W=128*1024,Q=64*1024;function ie(t,e){let n=t.split(`
|
|
4
|
-
`),i=e.split(`
|
|
5
|
-
`),s=0;for(;s<n.length&&s<i.length&&n[s]===i[s];)s++;let f=n.length,o=i.length;for(;f>s&&o>s&&n[f-1]===i[o-1];)f--,o--;if(f===s&&o===s)return"";let p=n.slice(s,f),g=i.slice(s,o),l=ce(p,g,2e3),m=[];if(l===null)m.push(`@@ old L${s+1}-L${f} \u2192 new L${s+1}-L${o} @@`,...p.map(u=>`- ${u}`),...g.map(u=>`+ ${u}`));else{let u=l.map((a,h)=>a.op==="="?-1:h).filter(a=>a>=0),d=0;for(;d<u.length;){let a=d;for(;a+1<u.length&&u[a+1]-u[a]<=3;)a++;let h=Math.max(u[d]-1,0),R=Math.min(u[a]+1,l.length-1),b=l.slice(h,R+1),S=s+(b[0].ai??0)+1,_=s+(b[0].bi??0)+1,c=b.filter(E=>E.op!=="+").length,w=b.filter(E=>E.op!=="-").length;m.push(`@@ old L${S}-L${S+Math.max(c-1,0)} \u2192 new L${_}-L${_+Math.max(w-1,0)} @@`);for(let E of b)m.push(E.op==="="?` ${E.line}`:`${E.op} ${E.line}`);d=a+1}}return m.join(`
|
|
6
|
-
`)}function ce(t,e,n){let i=t.length,s=e.length,f=Math.min(i+s,n),o=new Map([[1,0]]),p=[],g=!1;for(let u=0;u<=f&&!g;u++){p.push(new Map(o));for(let d=-u;d<=u;d+=2){let a=d===-u||d!==u&&(o.get(d-1)??0)<(o.get(d+1)??0)?o.get(d+1)??0:(o.get(d-1)??0)+1,h=a-d;for(;a<i&&h<s&&t[a]===e[h];)a++,h++;if(o.set(d,a),a>=i&&h>=s){g=!0;break}}}if(!g)return null;let r=i,l=s,m=[];for(let u=p.length-1;u>0;u--){let d=p[u],a=r-l,h=a===-u||a!==u&&(d.get(a-1)??0)<(d.get(a+1)??0)?a+1:a-1,R=d.get(h)??0,b=R-h;for(;r>R&&l>b;)m.push({op:"=",line:t[r-1],ai:r-1,bi:l-1}),r--,l--;u>0&&(r===R?(m.push({op:"+",line:e[l-1],ai:r,bi:l-1}),l--):(m.push({op:"-",line:t[r-1],ai:r-1,bi:l}),r--))}for(;r>0&&l>0;)m.push({op:"=",line:t[r-1],ai:r-1,bi:l-1}),r--,l--;for(;r>0;)m.push({op:"-",line:t[r-1],ai:r-1,bi:0}),r--;for(;l>0;)m.push({op:"+",line:e[l-1],ai:0,bi:l-1}),l--;return m.reverse()}function ae(t){let e=Buffer.byteLength(t,"utf8");if(e<=W+Q)return{diff:t,truncated:!1};let n=Buffer.from(t,"utf8"),i=W;for(;i>0&&(n[i]&192)===128;)i--;let s=e-Q;for(;s<e&&(n[s]&192)===128;)s++;let f=n.subarray(0,i).toString("utf8"),o=n.subarray(s).toString("utf8");return{diff:`${f}
|
|
7
|
-
\u2026 [diff truncated: ${e-i-(e-s)} bytes omitted] \u2026
|
|
8
|
-
${o}`,truncated:!0}}function de(t,e){let n=k(t),i=n.heads.get(e);if(typeof i!="string")return null;let s=[];for(let d of I(t).records){let a=d.source_head_moves?.[e];a!==void 0&&a!==s[s.length-1]&&s.push(a)}let f=s.lastIndexOf(i),o=f>0?s[f-1]:null;if(typeof o!="string"||o===i)return null;let p=D(t,n,o),g=D(t,n,i);if(p===null||g===null)return null;let{diff:r,truncated:l}=ae(ie(p,g)),m=new Set,u=[];for(let d of n.edgesFrom(o))d.type!==x.DERIVES||n.nodeLabel.get(d.dst)!==v.USECASE||m.has(d.dst)||(m.add(d.dst),u.push({id:d.dst,title:String(n.getNode(d.dst)?.content.title??"")}));return{source_id:e,old_head:o,new_head:i,diff:r,...l?{truncated:!0}:{},prior_ucs:u}}function le(t,e,n){let i=t.getNode(e)?.content??{},s=t.getNode(n)?.content??{},o=[...new Set([...Object.keys(i),...Object.keys(s)])].sort().filter(p=>JSON.stringify(i[p])!==JSON.stringify(s[p]));return o.length>0?`updated: ${o.join(", ")}`:"updated"}function ue(t,e,n,i,s,f,o){let p=new Set((o?.rows??[]).map(a=>a.matched_cid).filter(a=>!!a)),g=[];for(let[a,h]of n.superseded)h===null||a===h||e.superseded.has(a)||n.nodeLabel.get(a)===v.USECASE&&g.push({kind:"MODIFY",ref:y(n,a),old_cid:a,new_cid:h,summary:le(n,a,h)});let r=f.map(a=>({kind:"ADD",ref:y(n,a),cid:a}));for(let a of o?.rows??[])a.kind==="MODIFY"&&a.matched_cid?g.push({kind:"MODIFY",ref:y(n,a.matched_cid),old_cid:a.matched_cid,new_cid:null,summary:`${a.why} (staged)`}):a.kind==="ADD"&&r.push({kind:"ADD",ref:a.title,cid:null});let l=[],m=D(t,n,s),u=new Map;for(let{cid:a}of n.byLabel(v.USECASE)){if(!M(n,a)||p.has(a))continue;let h=n.derivesInto(a),R=h.filter(_=>String(_.props.source_id)===i);R.length===0||R.some(_=>_.props.source_cid===s)||R.some(_=>{let c=String(_.props.anchor),w=L(c);return w?.kind==="img-whole"?!1:w?.kind==="img-part"?re(n,_,s):m!==null&&oe(t,n,_,m,u)})||h.some(_=>{let c=String(_.props.source_id);if(c===i)return!1;let w=n.heads.get(c);return w!=null})||l.push({kind:"ARCHIVE",ref:y(n,a),cid:a,why:`evidence decayed: no quote from ${i} relocates into @${C(s)}, no other live source, no fresh evidence this run`,impact:Z(n,n.tipOf(a))})}let d=(a,h)=>a.ref<h.ref?-1:a.ref>h.ref?1:0;return[...g.sort(d),...r.sort(d),...l.sort(d)]}function Re(t,e,n,i,s){let f=e.rows.find(d=>d.temp_ref===n);if(!f)return{ok:!1,message:`held item ${n} missing from the plan artifact`};let o=f,p=k(t);if(o.matched_cid){let d=p.tipOf(o.matched_cid);if(p.superseded.get(d)===null)return{ok:!1,message:`use-case for "${o.title}" was retired meanwhile \u2014 nothing to update`};d!==o.matched_cid&&(o={...o,matched_cid:d,uc:{...o.uc,matches_existing:{cid:d}}})}let g=s?{edited:s}:"approve",r=te(t,p,{source_id:e.source_id,...e.staged_source_cid!==void 0?{staged_source_cid:e.staged_source_cid}:{},rows:[o]},new Map([[o.temp_ref,g]]),i);if(r.errors)return{ok:!1,message:r.errors.map(d=>`${d.code}: ${d.detail}`).join("; ")};let l=k(t),m=o.matched_cid?l.tipOf(o.matched_cid):r.record?.nodes.find(d=>d.label==="usecase")?.cid??r.record?.review[0]?.id;return{ok:!0,ref:m?y(l,m):o.title,kind:o.kind}}async function ye(t,e,n,i={}){let s=k(t),f=s.heads.get(e)??null,o=new Set(s.staleList().filter(c=>c.state==="stale").map(c=>c.cid)),p=await n.reingest(e);if(p.status==="unchanged"&&!i.resumeHeld)return{source_id:e,changed:!1,head:{status:p.status,before:f,after:p.cid},note:`nothing to reconcile \u2014 ${e} is unchanged`,skipped_arms:X,changeset:[],rows:[]};let g=i.resumeHeld?{minted:[],matched:[],held:i.resumeHeld}:await n.reextract(e),r=k(t),l=g.minted.map(c=>{let w=y(r,c);return{kind:"ADD",origin:"content-change",ref:w,reason:`new use-case extracted from ${e}`,provenance:`extraction commit \u2014 DERIVES ${e} @ ${C(p.cid)}`,action:`kane-cli design tests --use-case ${w}`}}),m=r.staleList().filter(c=>c.state==="stale"&&!o.has(c.cid)&&M(r,c.cid)).map(c=>c.cid),u=m.map(c=>{let w=y(r,c),E=se.has(r.nodeLabel.get(c)??"");return{kind:"MODIFY",origin:"structural-stale",ref:w,reason:"stale (structural)",provenance:J(r,c),action:E?`kane-cli maintain evolve ${w}`:`kane-cli design explain ${w}`}}),d=[],a=[];for(let c of g.held?.rows??[])if(c.kind==="ADD")d.push({kind:"ADD",origin:"content-change",ref:c.title,held_ref:c.temp_ref,reason:`${c.why} (staged \u2014 commits on approval)`,provenance:`staged extraction of ${e} @ ${C(p.cid)}`,action:"approve to commit + design"});else{let w=c.matched_cid?r.tipOf(c.matched_cid):null,E=w?r.getNode(w)?.content.criteria??[]:[],T=(c.uc.updated?.criteria??[]).map(O=>typeof O=="string"?O:O.text),ee=[...T.filter(O=>!E.includes(O)),...c.uc.updated?.criteria!==void 0?E.filter(O=>!T.includes(O)):[]],P=w?Z(r,w,ee):void 0;a.push({kind:"MODIFY",origin:"content-change",ref:c.matched_cid?y(r,c.matched_cid):c.title,held_ref:c.temp_ref,reason:`${c.why} (staged \u2014 commits on approval)`,provenance:`staged extraction of ${e} @ ${C(p.cid)}`,action:"approve to commit the updated version (old\u2192new redirect)",...P?{impact:P}:{}})}let h=new Set;for(let c of[...g.minted,...g.matched])h.add(r.tipOf(c));for(let c of g.held?.rows??[])c.matched_cid&&h.add(r.tipOf(c.matched_cid));for(let c of m){let w=z(r,r.tipOf(c));w&&r.nodeLabel.get(w)===v.USECASE&&h.add(r.tipOf(w))}let R=[];for(let c of await j(r,"design")){if(c.kind!=="no-verifies")continue;let w=r.resolve(c.ref);if(!w)continue;let E=z(r,w.tip);!E||!h.has(r.tipOf(E))||R.push({kind:"ADD",origin:"content-change",ref:c.ref,reason:c.why,provenance:`gaps engine (design) \u2014 uncovered AC of touched use-case ${y(r,E)}`,action:c.ready_command})}let b=[];for(let{cid:c}of r.byLabel(v.USECASE))M(r,c)&&r.stale(c)==="orphaned"&&b.push({kind:"REMOVE",ref:y(r,c),reason:"orphaned \u2014 no live source evidences this use-case",provenance:J(r,c),action:"plan-only \u2014 REMOVE is not executed in this release"});let S=new Set,_=[...l.sort($),...d.sort($),...R.sort($),...a.sort($),...u.sort($),...b.sort($)].filter(c=>{let w=`${c.kind}\0${c.ref}`;return S.has(w)?!1:(S.add(w),!0)});return{source_id:e,changed:!0,head:{status:p.status,before:f,after:p.cid},note:ne,skipped_arms:X,changeset:ue(t,s,r,e,p.cid,g.minted,g.held),rows:_,...g.held?{held:g.held}:{}}}function be(t,e){return async n=>{let{ingestFile:i}=await import("./ingest-OSNNM3DH.js"),{convertPdf:s}=await import("./pdf-convert-RLXSXFWN.js"),{convertDocx:f}=await import("./docx-convert-SQRTF7XS.js"),o=await i({contextDir:t,filePath:e,asId:n,converters:{pdf:s,docx:f}});return{status:o.status,cid:o.cid}}}function xe(t,e,n,i){return async()=>{let f=(i??(await import("./dispatch-7EWWQRQ5.js")).findProvider)(e);if(!f)throw new Error(`the remote re-ingest failed \u2014 no provider matches '${e}'`);let o=await f.ingest(e,void 0,{out:n.out,err:n.err,confirm:async()=>!0,isTTY:!1},t,void 0);if(o.code!==0||!o.result)throw new Error("the remote re-ingest failed \u2014 fix the reported problem and re-run");return{status:o.result.status,cid:o.result.source_cid}}}function ke(t,e={}){return async n=>{let i=[],[{runExtract:s},{resolveAgentAuthEnv:f},{runAgent:o},{preflightTurn:p}]=await Promise.all([import("./run-EHUNJPW6.js"),import("./spawner-DPT2RLAO.js"),import("./bridge-7J3JE3JS.js"),import("./turn-preflight-JGYT7LXP.js")]),g=await f(),r=new Set(k(t).byLabel(v.USECASE).map(S=>S.cid)),l=de(t,n)??void 0,m=0,u=await s({mode:"override",source:n,...l?{changeContext:l}:{}},{contextDir:t,agent:o,preflightTurn:()=>p(g),ask:async()=>[],review:async S=>{if(!e.stage)return new Map(S.map(c=>[c.temp_ref,{resolution:c.matches_existing&&c.changed?"edited":"skipped"}]));let _=new Map;for(let c of S){if(c.matches_existing&&!c.changed){_.set(c.temp_ref,{resolution:"skipped"});continue}i.push({kind:c.matches_existing?"MODIFY":"ADD",temp_ref:c.temp_ref,title:c.title,why:c.matches_existing?`updated: ${Object.keys(c.updated??{}).join(", ")||"content"}`:`newly extracted from ${n}`,...c.matches_existing?{matched_cid:c.matches_existing.cid,updated:c.updated}:{},uc:c}),_.set(c.temp_ref,{resolution:"rejected"})}return _},confirmStale:async()=>!1,out:S=>e.hostOut?.(S),progress:S=>e.hostProgress?.(S),emit:S=>{S.type==="commit"&&typeof S.assumed=="number"&&(m+=S.assumed),e.hostEmit?.(S)},isTTY:!1,auth:g});if(u!==0)throw new Error(`reconcile: re-extract of ${n} failed (exit ${u})`);let d=k(t),a=d.heads.get(n),h=[],R=[];if(typeof a=="string"){let S=new Set;for(let _ of d.edgesFrom(a))_.type!==x.DERIVES||d.nodeLabel.get(_.dst)!==v.USECASE||S.has(_.dst)||(S.add(_.dst),!(e.stage&&d.trust.get(_.dst)==="archived")&&(r.has(_.dst)?R:h).push(_.dst))}let b=k(t).heads.get(n);return{minted:h,matched:R,defaultsTaken:m,...e.stage?{held:{source_id:n,...b!=null?{staged_source_cid:b}:{},rows:i}}:{}}}}export{te as a,Z as b,X as c,ne as d,M as e,z as f,se as g,ie as h,ae as i,de as j,Re as k,ye as l,be as m,xe as n,ke as o};
|
package/dist/chunk-Q2F5QB2W.js
DELETED
package/dist/chunk-Q4YYAN6E.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{M as a,X as p,m as c}from"./chunk-RDHWNSDP.js";function v(t,e,s){let{ref:r,reason:o,by:i}=s;if(!o||o.trim().length===0)return{record:null,errors:[{code:"REASON_REQUIRED",detail:"archiving a node needs a reason \u2014 it becomes the tombstone's provenance"}]};let d=e.resolve(r);if(!d)return{record:null,errors:[{code:"UNKNOWN_REF",detail:`no node '${r}' in the graph`}]};let n=e.tipOf(d.cid);if(e.superseded.has(n))return{record:null,errors:[{code:"ALREADY_ARCHIVED",detail:`${r} is already superseded at its tip (${n.slice(0,19)}\u2026)`}]};let l=a(t,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[{kind:"node",old:n,new:null,reason:o,by:i}],source_head_moves:{}},{expectPrev:e.latestHash,intent:{v:1,verb:"archive",args:c({ref:r,reason:o,by:i}),pins:{ref:n}},provenance:s.provenance});return p(t),{record:l.record,errors:null}}export{v as a};
|
package/dist/chunk-Q6AHSGOE.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as D}from"./chunk-KDNNMU7Q.js";import{b as k}from"./chunk-3UI5VTQS.js";import{f as x,g as _}from"./chunk-XLSOQLVT.js";var a=(e,t,r=new Set)=>{let s=e.nameOf.get(t);if(s!==void 0)return s;if(r.has(t))return t;r.add(t);for(let[c,n]of e.superseded){if(n!==t)continue;let o=a(e,c,r);if(o!==c)return o}return t};function P(e,t){let r=e.stale(t);if(r==="fresh")return;if(r==="orphaned")return"orphaned \u2014 no live source evidences this item";let s=[],c=new Map;for(let n of e.derivesInto(t))c.set(String(n.props.source_id),n);for(let[n,o]of c){let i=e.heads.get(n);if(i==null||i===o.props.source_cid)continue;let l=e.convChains.get(n)?.chain;l&&l.includes(String(o.props.source_cid))||s.push(`DERIVES pin ${n}@${String(o.props.source_cid).slice(0,19)} broke \u2014 the source head moved`)}for(let n of e.edgesFrom(t)){if(n.type===_.DERIVES||!e.superseded.has(n.dst))continue;let o=e.tipOf(n.dst);if(e.superseded.has(o)){s.push(`${n.type} pin \u2192 ${a(e,n.dst)} \u2014 target retired`);continue}let i=C(e,n.dst,o);s.push(i.length>0?`${a(e,n.dst)} updated: ${i.map(l=>l.field).join(", ")}`:`${n.type} pin \u2192 ${a(e,n.dst)} \u2014 target superseded`)}return s.length>0?s.join("; "):"stale \u2014 a pinned dependency moved"}function C(e,t,r){let s=e.getNode(t)?.content??{},c=e.getNode(r)?.content??{},n=i=>i===void 0?"":Array.isArray(i)?i.map(String).join(" \xB7 "):typeof i=="object"?JSON.stringify(i):String(i),o=[];for(let i of[...new Set([...Object.keys(s),...Object.keys(c)])].sort())JSON.stringify(s[i])!==JSON.stringify(c[i])&&o.push({field:i,old:n(s[i]),new:n(c[i])});return o}function R(e,t){let r=[];for(let{cid:s}of e.byLabel(x.SCENARIO))e.superseded.has(s)||e.edgesFrom(s).some(c=>c.type===_.BELONGS_TO&&e.tipOf(c.dst)===t)&&r.push(s);return r}function O(e,t){let r=[],s=[],c=[],n=[],o=[],i=[],l=R(e,t),E=new Set(l),p=(u,f)=>{let d=P(e,f);return d===void 0?u:{...u,stale:!0,stale_reason:d}};for(let u of l){let f=e.getNode(u)?.content??{};r.push(p({ref:a(e,u),title:String(f.title??""),case_type:String(f.case_type??""),intent:String(f.intent??"")},u));for(let d of e.edgesInto(u)){if(d.type!==_.AUTOMATES||e.superseded.has(d.src))continue;let m=e.getNode(d.src)?.content??{},h=e.edgesFrom(d.src).filter(S=>S.type===_.VERIFIES&&!e.superseded.has(S.dst)).map(S=>a(e,S.dst));s.push(p({ref:a(e,d.src),title:String(m.title??""),automates:a(e,u),check:m.check,verifies:h,...typeof m.target=="string"?{target:m.target}:{},...typeof m.app=="string"?{app:m.app}:{}},d.src)),o.push(d.src)}for(let d of e.edgesFrom(u))d.type!==_.EXERCISES||e.superseded.has(d.dst)||n.push({scenario:a(e,u),ac:a(e,d.dst)})}for(let{cid:u}of e.byLabel(x.AC)){if(e.superseded.has(u))continue;let f=e.edgesFrom(u).find(S=>S.type===_.SCOPED_TO);if(!f)continue;let d=e.tipOf(f.dst);if(!(d===t||E.has(d)))continue;let h=e.getNode(u)?.content??{};c.push(p({ref:a(e,u),text:String(h.text??""),kind:String(h.kind??""),scope:d===t?"use-case":a(e,d)},u)),i.push(u)}let y=[],g=new Set;for(let u of[t,...l,...o,...i])for(let f of e.retractedEdgesTouching(u))g.has(f.ecid)||(g.add(f.ecid),y.push({type:f.type,src:a(e,f.src),dst:a(e,f.dst),at:f.retraction.at,...f.retraction.reason?{reason:f.retraction.reason}:{}}));return{scenarios:r,tests:s,acs:c,exercises:n,retracted_edges:y}}function b(e,t,r){let s=D(e,t,r);return s===null?null:s.toString("utf8")}function v(e,t){let r=t.split(`
|
|
3
|
-
`).map(c=>c.replace(/^\d+\| /,"")),s=[];for(let c of e.split(`
|
|
4
|
-
`)){let n=c.trim();if(n.length===0)continue;let o=r.find(i=>i.includes(n));o!==void 0&&!s.includes(o.trim())&&s.push(o.trim())}return s.length>0?s.join(`
|
|
5
|
-
`):{removed:!0}}function G(e,t,r,s,c){let n=c?{requested:c}:{};if(s!==void 0&&s.trim().length>0)return{kind:"user-directive",text:s.trim(),...n};let o=[r,...O(t,r).acs.map(p=>t.resolve(p.ref)?.cid??"")].filter(Boolean),i=[],l=new Set;for(let p of o){let y=new Map;for(let g of t.derivesInto(p))y.set(String(g.props.source_id),g);for(let[g,u]of y){let f=t.heads.get(g);if(f==null||f===u.props.source_cid)continue;let d=String(u.props.anchor),m=`${g}\0${d}`;if(l.has(m)||d==="img#whole")continue;l.add(m);let h=b(e,t,String(u.props.source_cid)),S=h===null?null:k(h,d);if(S===null)continue;let w=b(e,t,f);i.push({source_id:g,anchor:d,old_anchor_text:S,new_anchor_text:w===null?{removed:!0}:v(S,w)})}}let E;for(let[p,y]of t.superseded){if(y!==r||t.nodeLabel.get(p)!==x.USECASE)continue;let g=C(t,p,r);g.length>0&&(E=g);break}return{kind:"source-change",changes:i,...E?{uc_updated:E}:{},...n}}function $(e,t,r,s,c){let n=O(t,r);if(n.scenarios.length===0&&n.tests.length===0&&n.acs.length===0)return;let o=G(e,t,r,s,c);if(!(!c&&o.kind==="source-change"&&o.changes.length===0&&!o.uc_updated))return{prior_design:n,change_delta:o}}export{P as a,O as b,$ as c};
|
package/dist/chunk-QAB3Y5FQ.js
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as c}from"./chunk-AKE2CTV6.js";import{a as v}from"./chunk-FMUV6UCX.js";import{d as b,h as _}from"./chunk-NOL7MNZH.js";import{c as h,j as w}from"./chunk-5TQFOPJV.js";import{readFileSync as C,writeFileSync as k,mkdirSync as x,existsSync as T}from"fs";import{dirname as S}from"path";var u={window_size:{width:1920,height:1080},chrome_profile_path:"",default_url:w,model:"v16-alpha",project_id:null,project_name:null,folder_id:null,folder_name:null,mode:"testing",assertion_mode:"dom",network_ws:!1,network_sse:!1,bug_detection:"off",final_validation:!1,code_export:{enabled:!0,language:"python",skip_validation:!0},generate:{scenario_limit:2,per_scenario_limit:3,memory_enabled:!1},last_seen_version:"",hints_enabled:!0};function E(r){let{mobile:e,...i}=r,t={...i};delete t.target,delete t.device,delete t.device_name,delete t.os_version,delete t.app;let n=e??{};n.tui_target&&(t.target=n.tui_target);let s=n.default_target?.name?.trim(),l=n.default_target?.os_version?.trim();if(s||l)s&&(t.device_name=s),l&&(t.os_version=l);else{let o=n.default_target?.id?.trim();o&&(t.device=o)}n.default_app&&(t.app=n.default_app);let a={};n.no_reset!==void 0&&(a.no_reset=n.no_reset),n.appium_url!==void 0&&(a.appium_url=n.appium_url);for(let o of c)n[o]!==void 0&&(a[o]=n[o]);return Object.keys(a).length>0&&(t.mobile=a),t}function M(r){let e=r.mobile??{},i=typeof r.target=="string"?r.target:void 0,t=typeof r.device=="string"&&r.device.trim()!==""?r.device.trim():void 0,n=d=>typeof d=="string"&&d.trim()!==""?d.trim():void 0,s=n(r.device_name),l=n(r.os_version),a=typeof r.app=="string"&&r.app!==""?r.app:void 0,o={},g=i??e.tui_target;g&&(o.tui_target=g);let p=v(g,void 0).kind,f=b(p)?p:null;f&&(s||l)?o.default_target={platform:_(f),kind:f,...s?{name:s}:{},...l?{os_version:l}:{}}:f&&t?o.default_target={platform:_(f),kind:f,id:t}:(e.default_target?.id?.trim()||e.default_target?.name?.trim())&&(o.default_target=e.default_target);let m=a??e.default_app;m&&(o.default_app=m),e.no_reset!==void 0&&(o.no_reset=e.no_reset),e.appium_url!==void 0&&(o.appium_url=e.appium_url);for(let d of c)e[d]!==void 0&&(o[d]=e[d]);return Object.keys(o).length>0?o:void 0}var y=class{constructor(e=h){this.path=e}exists(){return T(this.path)}load(){try{let e=C(this.path,"utf-8"),i=JSON.parse(e),t=M(i),{target:n,device:s,app:l,...a}=i;return{...u,...a,...t?{mobile:t}:{},code_export:{...u.code_export,...i.code_export??{}},generate:{...u.generate,...i.generate??{}}}}catch{return{...u,code_export:{...u.code_export},generate:{...u.generate}}}}write(e){try{x(S(this.path),{recursive:!0}),k(this.path,JSON.stringify(E(e),null,2)+`
|
|
3
|
-
`)}catch(i){let t=i instanceof Error?i.message:String(i);process.stderr.write(`[config] Failed to save config: ${t}
|
|
4
|
-
`)}}set(e,i){let t=this.load();t[e]=i,this.write(t)}save(e){this.write({...this.load(),...e})}getMobile(){return this.load().mobile??{}}setMobile(e){let i={...this.getMobile()};for(let t of Object.keys(e)){let n=e[t];n===void 0?delete i[t]:i[t]=n}this.set("mobile",Object.keys(i).length>0?i:void 0)}writeRaw(e){this.write(e)}};export{y as a};
|
package/dist/chunk-RDHWNSDP.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as le}from"./chunk-FQNQVC5O.js";import{a as S,g as K,h as C,i as ae,j,k as ce,l as de}from"./chunk-XLSOQLVT.js";import{closeSync as Oe,existsSync as Ae,fsyncSync as qe,mkdirSync as xe,openSync as Ce,readFileSync as R,readdirSync as je,renameSync as re,rmSync as te,writeFileSync as Fe}from"fs";import{dirname as un,join as b}from"path";import{createHash as He}from"crypto";function E(e){if(e===null)return"null";let n=typeof e;if(n==="string")return JSON.stringify(e.normalize("NFC"));if(n==="boolean")return e?"true":"false";if(n==="number"){if(!Number.isFinite(e))throw new Error("non-finite number is not canonicalizable");return JSON.stringify(e)}if(Array.isArray(e))return"["+e.map(t=>t===void 0?"null":E(t)).join(",")+"]";if(n==="object"){let t=e,a=new Map;for(let o of Object.keys(t)){if(t[o]===void 0)continue;let c=o.normalize("NFC");if(a.has(c))throw new Error(`canonicalization collision: NFC-equivalent duplicate key ${JSON.stringify(c)}`);a.set(c,t[o])}return"{"+[...a.keys()].sort((o,c)=>Buffer.compare(Buffer.from(o,"utf8"),Buffer.from(c,"utf8"))).map(o=>JSON.stringify(o)+":"+E(a.get(o))).join(",")+"}"}throw new Error("unsupported type for canonicalization: "+n)}function I(e){return He("sha256").update(e).digest("hex")}function F(e,n){return"sha256:"+I(Buffer.from("assurance."+e+"\0"+E(ce(e,n)),"utf8"))}function Sn(e,n,t,a){return"sha256:"+I(Buffer.from("assurance.edge\0"+E({type:e,src:n,dst:t,props:de(e,a)}),"utf8"))}function kn(e,n){return{source_id:e,blob:n}}function Nn(e){return{...e,derived:!0}}import{existsSync as D,mkdirSync as Ge,readFileSync as X,renameSync as We,rmSync as pe,writeFileSync as ze}from"fs";import{dirname as Ke,join as J}from"path";var B=e=>J(e,"derived"),ge=e=>J(B(e),"index.json");function he(e,n){let t=n.startsWith("sha256:")?n.slice(7):n;if(!/^[A-Za-z0-9_-]{2,}$/.test(t))throw new Error(`${n} is not a fingerprint: it cannot name a node file`);return J(B(e),"nodes",t.slice(0,2),t.slice(2)+".json")}function O(){return{applied:{seq:0,hash:null},heads:{},trust:{},nodeLabel:{},forward:{},extracted:[],design_of:{},design_generation:{},exec:{},superseded:{},names:{},archivedReason:{},appliedEvents:[],eventDigests:{},completeness:{},srcOwner:{},conv:{},media:{},design_phases:{},edgeRetractions:{}}}function M(e){let n=ge(e);if(!D(n))return null;try{let t=JSON.parse(X(n,"utf8"));return t.superseded===void 0||t.names===void 0||t.archivedReason===void 0||t.appliedEvents===void 0||t.conv===void 0||t.media===void 0||t.exec===void 0||t.completeness===void 0||t.srcOwner===void 0||t.design_phases===void 0||t.edgeRetractions===void 0||t.eventDigests===void 0||t.reverse!==void 0?null:t}catch{return null}}function me(e,n){Ge(Ke(e),{recursive:!0});let t=`${e}.tmp-${process.pid}`;ze(t,n),We(t,e)}function k(e,n,t,a,i={}){let o=i.writeNodeFiles!==!1,c=new Set(n.extracted),p=new Set(n.appliedEvents);t.forEach((s,h)=>{for(let r of s.nodes){let d=he(e,r.cid);o&&!D(d)&&me(d,JSON.stringify({label:r.label,content:r.content})+`
|
|
3
|
-
`),!(r.cid in n.trust)&&r.content.derived===!0&&(n.trust[r.cid]="derived"),n.nodeLabel[r.cid]=r.label}for(let[r,d]of Object.entries(s.source_head_moves))typeof d=="string"&&(n.srcOwner[d]=r);if(s.proposal_id!=null&&typeof s.extraction_of=="string"){c.add(s.extraction_of);let r=null;for(let d of s.edges)if(d.type===K.DERIVES&&d.props.source_cid===s.extraction_of&&typeof d.props.source_id=="string"){r=d.props.source_id;break}if(r??=n.srcOwner[s.extraction_of]??null,r!==null){let d=n.completeness[r];(!d||s.seq>=d.seq)&&(n.completeness[r]={source_cid:s.extraction_of,completeness:"complete",...s.extractor_version?{extractor_version:s.extractor_version}:{},at:s.ts,seq:s.seq})}else n.completenessSkipped=(n.completenessSkipped??0)+1}else if(s.proposal_id!=null&&Array.isArray(s.extraction_of))for(let r of s.extraction_of){c.add(r.source_cid);let d=n.completeness[r.source_id];(!d||s.seq>=d.seq)&&(n.completeness[r.source_id]={source_cid:r.source_cid,completeness:r.completeness,...r.extractor_version?{extractor_version:r.extractor_version}:{},at:r.at,seq:s.seq})}s.design_of&&((n.design_of??={})[s.design_of.uc_cid]={engine:s.design_of.engine,seq:s.seq}),s.design_generation&&((n.design_generation??={})[s.design_generation.uc_root]={gen:s.design_generation.generation,seq:s.seq});{let r=s.design_phase;r&&typeof r.uc_root=="string"&&typeof r.phase=="string"&&typeof r.generation=="number"&&((n.design_phases??={})[r.uc_root]??=[]).push({phase:r.phase,generation:r.generation,seq:s.seq,completeness:r.completeness==="partial"?"partial":"complete"})}for(let r of s.executions??[])((n.exec??={})[r.about]??=[]).push(r);for(let r of s.edges){let{quote:d,...g}=r.props,u=n.forward[r.src]??=[];u.some(l=>l.ecid===r.ecid)||u.push({...r,props:g}),s.proposal_id!=null&&r.type===K.DERIVES&&typeof r.props.source_cid=="string"&&c.add(r.props.source_cid)}for(let r of s.review)r.resolution==="approved"||r.resolution==="edited"?(n.trust[r.id]="trusted",delete n.archivedReason[r.id]):r.resolution==="rejected"?(n.trust[r.id]="archived",r.reason?n.archivedReason[r.id]=r.reason:delete n.archivedReason[r.id]):r.resolution==="reset"&&(n.trust[r.id]="derived",delete n.archivedReason[r.id]);for(let r of s.supersessions)r.kind==="node"?r.new===r.old?delete n.superseded[r.old]:n.superseded[r.old]=r.new:r.revoke?(delete n.superseded[r.ecid],delete n.edgeRetractions[r.ecid]):(n.superseded[r.ecid]=null,n.edgeRetractions[r.ecid]={at:s.ts,...r.by?{by:r.by}:{},...r.reason?{reason:r.reason}:{}});for(let r of s.names??[])n.names[r.slug]=r.cid;for(let[r,d]of Object.entries(s.source_head_moves))n.heads[r]=d;if((s.event_ids??[]).forEach((r,d)=>{p.add(r),n.eventDigests[r]=s.event_digests?.[d]??""}),s.media)for(let[r,d]of Object.entries(s.media)){let g=s.source_head_moves[r];typeof g=="string"&&(n.media[g]=d)}if(s.conv){let r=s.source_head_moves[s.conv.source_id];if(typeof r=="string"){let d=n.conv[s.conv.source_id],g=d&&d.chain.length>0?d.chain[d.chain.length-1]:null;s.conv.append_of===g?n.conv[s.conv.source_id]={turns:s.conv.turn,chain:[...d?.chain??[],r]}:n.conv[s.conv.source_id]={turns:s.conv.turn,chain:[r]}}}for(let[r,d]of Object.entries(s.source_head_moves))s.conv?.source_id!==r&&n.conv[r]!==void 0&&(n.conv[r]=typeof d=="string"?{turns:n.conv[r].turns,chain:[d]}:{turns:n.conv[r].turns,chain:[]});n.applied={seq:s.seq,hash:a[h]}}),n.extracted=[...c].sort(),n.appliedEvents=[...p].sort()}function fe(e,n){me(ge(e),JSON.stringify(n)+`
|
|
4
|
-
`)}function Ye(e){let n=J(e,"meta.json");if(D(n))try{let t=JSON.parse(X(n,"utf8"));if(t.schema!==S||t.canonicalizer!=="v1")throw new f(`schema fence: store is ${t.schema}/${t.canonicalizer}, this build is ${S}/${"v1"} \u2014 migrate explicitly (kane-cli context rebuild after upgrading)`)}catch(t){throw t instanceof f?t:new f(`corrupt meta.json in ${e} \u2014 fix or remove it`)}}function Xe(e){Ye(e);let n=M(e),t=n!==null&&n.applied.seq>0?T(e,n.applied.seq):null;if(n!==null&&t!==null&&t!==n.applied.hash&&(pe(B(e),{recursive:!0,force:!0}),n=null),n===null){n=O();let{records:o,hashes:c}=L(e);return k(e,n,o,c),fe(e,n),n}let{records:a,hashes:i}=A(e,n.applied.seq,n.applied.hash);return a.length>0&&(k(e,n,a,i),fe(e,n)),n}function jn(e){return pe(B(e),{recursive:!0,force:!0}),Xe(e)}var Ze=new Set(["CHAIN_ERROR","DERIVED_MISSING","DERIVED_DRIFT","NODE_FILE_MISSING","NODE_FILE_MISMATCH","NODE_FILE_CORRUPT"]);function Fn(e){return Ze.has(e.code)?e.detail:`${e.code}: ${e.detail}`}function Ln(e){let n=[],t=(u,l)=>{n.push({code:u,detail:l})},a=[],i=[];try{({records:a,hashes:i}=L(e))}catch(u){return{ok:!1,issues:[{code:"CHAIN_ERROR",detail:u instanceof f?u.message:String(u)}],records:0}}let o=O();k(e,o,a,i,{writeNodeFiles:!1});let c=M(e),p=0,s=o;if(c!==null&&c.applied.seq<a.length){let u=c.applied.seq;c.applied.hash===(u===0?null:i[u-1])&&(p=a.length-u,s=O(),k(e,s,a.slice(0,u),i.slice(0,u),{writeNodeFiles:!1}))}if(c===null)t("DERIVED_MISSING","derived/index.json missing or corrupt (run kane-cli context rebuild)");else{let u=l=>JSON.stringify(Y(l));for(let l of["applied","heads","trust","nodeLabel","forward","extracted","superseded","names","archivedReason","appliedEvents","eventDigests","conv","media","design_of","design_generation","design_phases","exec","completeness","srcOwner","edgeRetractions"])u(s[l])!==u(c[l])&&t("DERIVED_DRIFT",`derived drift in index.${l} (run kane-cli context rebuild)`)}let h=new Set;for(let u of Object.values(o.forward))for(let l of u)h.add(l.ecid);let r=new Set,d=new Set;for(let u of a)for(let l of u.supersessions)l.kind==="node"?(l.old in o.nodeLabel||t("SUPERSEDE_UNKNOWN_OLD",`${l.old} (record ${u.seq})`),l.new!==null&&l.new!==l.old&&!(l.new in o.nodeLabel)&&t("SUPERSEDE_UNKNOWN_NEW",`${String(l.new)} (record ${u.seq})`),l.new===l.old?r.delete(l.old):(r.has(l.old)&&t("DOUBLE_SUPERSEDE",`${l.old} re-superseded while live (record ${u.seq})`),r.add(l.old))):(h.has(l.ecid)||t("SUPERSEDE_UNKNOWN_ECID",`${l.ecid} (record ${u.seq})`),l.revoke?(d.has(l.ecid)||t("EDGE_ORPHAN_REVOKE",`${l.ecid} revoked without a standing retraction (record ${u.seq})`),d.delete(l.ecid)):(d.has(l.ecid)&&t("EDGE_DOUBLE_RETRACT",`${l.ecid} re-retracted while already retracted (record ${u.seq})`),d.add(l.ecid)));for(let u of Object.keys(o.superseded)){let l=new Set,y=u;for(;y!==null&&y in o.superseded;){if(l.has(y)){t("SUPERSEDE_CYCLE",`chain from ${u} revisits ${y}`);break}l.add(y),y=o.superseded[y]}}for(let[u,l]of Object.entries(o.names))l in o.nodeLabel||t("NAME_UNKNOWN_TARGET",`slug ${u} \u2192 ${l} not in the graph`);for(let u of a)for(let l of u.edges){let y=o.nodeLabel[l.src]??"(unknown)",w=o.nodeLabel[l.dst]??"(unknown)";for(let m of j(l.type,y,w,l.props))t(m.code,`${l.ecid} ${m.detail}`)}let g=new Map;for(let u of Object.values(o.forward))for(let l of u){if(l.ecid in o.superseded)continue;let y=g.get(l.type)??[];y.push(l),g.set(l.type,y)}for(let[u,l]of g){let y=ae(u);if(y?.acyclic){let w=new Map;for(let v of l)w.set(v.src,[...w.get(v.src)??[],v.dst]);let m=new Map,_=v=>{m.set(v,1);for(let z of w.get(v)??[])if(m.get(z)===1||m.get(z)===void 0&&_(z))return!0;return m.set(v,2),!1};for(let v of w.keys())if(m.get(v)===void 0&&_(v)){t("EDGE_CYCLE",`live ${u} edges form a cycle reachable from ${v}`);break}}if(y?.cardinality==="one-live-per-src"||y?.cardinality==="one-live-per-src-and-dst"){let w=new Map;for(let m of l)m.dst in o.superseded||w.set(m.src,[...w.get(m.src)??[],m]);for(let[m,_]of w)_.length>1&&t("CARDINALITY_VIOLATION",`${_.length} live ${u} edges from ${m} (one-live-per-src): ecids ${_.map(v=>v.ecid).join(",")}`)}if(y?.cardinality==="one-live-per-src-and-dst"){let w=new Map;for(let m of l)m.src in o.superseded||m.dst in o.superseded||w.set(m.dst,[...w.get(m.dst)??[],m]);for(let[m,_]of w)_.length>1&&t("CARDINALITY_VIOLATION",`${_.length} live ${u} edges onto ${m} (one-live-per-dst): ecids ${_.map(v=>v.ecid).join(",")}`)}}for(let[u,l]of Object.entries(s.nodeLabel)){let y=he(e,u);if(!D(y)){t("NODE_FILE_MISSING",`missing node file for ${u} (run kane-cli context rebuild)`);continue}try{let w=JSON.parse(X(y,"utf8"));(w.label!==l||F(w.label,w.content)!==u)&&t("NODE_FILE_MISMATCH",`node file content mismatch for ${u} (run kane-cli context rebuild)`);for(let m of C(w.label,w.content))t(m.code,`${u} ${m.detail}`)}catch{t("NODE_FILE_CORRUPT",`corrupt node file for ${u} (run kane-cli context rebuild)`)}}return{ok:n.length===0,issues:n,records:a.length,...p>0?{pending:p}:{}}}function Y(e){return Array.isArray(e)?e.map(Y):e&&typeof e=="object"?Object.fromEntries(Object.entries(e).sort(([n],[t])=>n<t?-1:1).map(([n,t])=>[n,Y(t)])):e}import{join as Qe}from"path";var ye=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;function Z(e){return typeof e=="string"&&e!=="."&&e!==".."&&ye.test(e)}function Dn(e){if(!Z(e))throw new Error(`unsafe logical_id: ${JSON.stringify(e)} \u2014 must match ${String(ye)} (no path separators)`)}function we(e,n){if(!Z(n))throw new Error(`proposal id ${JSON.stringify(n)} is not a plain name (letters, digits, . _ - after a letter or digit)`);return Qe(e,"proposals",n,"proposal.json")}var q=class extends Error{},en=new Set(["UNKNOWN_LABEL","MISSING_FIELD","BAD_ENUM"]),nn=new Set(["UNKNOWN_EDGE_TYPE","ILLEGAL_EDGE","MISSING_SALIENT"]),tn=["nodes","edges","review","supersessions"],rn=/^sha256:[0-9a-f]{64}$/;function sn(e){let n=[];for(let t of e.nodes)n.push(["node cid",t?.cid]);for(let t of e.edges)n.push(["edge ecid",t?.ecid],["edge src",t?.src],["edge dst",t?.dst]);for(let t of e.supersessions)t?.kind==="node"?(n.push(["superseded cid",t.old]),t.new!==null&&n.push(["superseding cid",t.new])):n.push(["retracted ecid",t?.ecid]);for(let t of e.names??[])n.push(["named cid",t?.cid]);return n}function ve(e){let n=M(e),a=n!==null&&(n.applied.seq===0||T(e,n.applied.seq)===n.applied.hash)?n:O(),{records:i,hashes:o}=A(e,a.applied.seq,a.applied.hash);return i.length>0&&k(e,a,i,o,{writeNodeFiles:!1}),a}function be(e,n,t,a){let i=r=>new q(r);for(let r of tn)if(!Array.isArray(t[r]))throw i(`${r} is not a list`);if(typeof t.source_head_moves!="object"||t.source_head_moves===null||Array.isArray(t.source_head_moves))throw i("source_head_moves is not an object");if(t.media!==void 0&&(typeof t.media!="object"||t.media===null||Array.isArray(t.media)))throw i("media is not an object");if(t.names!==void 0&&!Array.isArray(t.names))throw i("names is not a list");for(let[r,d]of sn(t))if(typeof d!="string"||!rn.test(d))throw i(`${r} ${String(d)} is not a sha256 fingerprint`);if(t.proposal_id!=null)try{we(e,t.proposal_id)}catch(r){throw i(r instanceof Error?r.message:String(r))}let o=new Map;for(let r of t.nodes){let d=C(r.label,r.content);for(let g of d)if(en.has(g.code))throw i(`${r.cid} ${g.detail}`);if(!d.some(g=>g.code==="UNKNOWN_FIELD")&&F(r.label,r.content)!==r.cid)throw i(`${r.cid} is not the hash of its content`);o.set(r.cid,r.label)}let c=r=>n.nodeLabel[r]??o.get(r)??"(unknown)",p=r=>r in n.nodeLabel||o.has(r),s=new Set(t.edges.map(r=>r.ecid)),h=r=>s.has(r)||Object.values(n.forward).some(d=>d.some(g=>g.ecid===r));for(let r of t.edges)for(let d of j(r.type,c(r.src),c(r.dst),r.props))if(nn.has(d.code))throw i(`${r.ecid} ${d.detail}`);for(let r of t.supersessions)if(r.kind==="node"){if(!p(r.old))throw i(`supersedes ${r.old}, which the graph does not hold`);if(r.new!==null&&!p(r.new))throw i(`supersedes with ${r.new}, which the graph does not hold`);if(r.new!==r.old&&r.old in n.superseded)throw i(`${r.old} is re-superseded while already superseded`)}else{if(!h(r.ecid))throw i(`retracts edge ${r.ecid}, which the graph does not hold`);if(r.revoke&&!(r.ecid in n.superseded))throw i(`${r.ecid} is revoked without a standing retraction`);if(!r.revoke&&r.ecid in n.superseded)throw i(`${r.ecid} is re-retracted while already retracted`)}for(let r of t.names??[])if(!p(r.cid))throw i(`names ${r.slug} \u2192 ${r.cid}, which the graph does not hold`);k(e,n,[t],[a],{writeNodeFiles:!1});for(let r of t.supersessions){if(r.kind!=="node"||r.new===r.old)continue;let d=new Set,g=r.old;for(;g!==null&&g in n.superseded;){if(d.has(g))throw i(`supersession chain from ${r.old} revisits ${g}`);d.add(g),g=n.superseded[g]}}}import{existsSync as Q,mkdirSync as on,readFileSync as an}from"fs";import{dirname as _e,join as cn}from"path";var ee="unknown",Ee=()=>ee;function Zn(e){ee=e}var dn=["extract","review","pair-merge","names","retire","gap","gap-close","chat","design","execution","parked","exec-supersede","ingest","distill","conv-mint","conv-turn","archive","revert"],Re={extract:{v:1,args:["proposal","proposalId","verdicts","by","flags","judgements","probeHits","eventIds"],pins:["supersedeTarget","matches_existing","conflicts_with","depends_on_hint","read_basis_heads"]},review:{v:1,args:["verdicts","by","holdArchives"],pins:["verdicts","supersedeTarget"]},"pair-merge":{v:1,args:["survivor","merged","reason","by"],pins:["survivor","merged"]},names:{v:1,args:["assignments","by"],pins:["refs"]},retire:{v:1,args:["sourceId","reason","by"],pins:["head"]},gap:{v:1,args:["content","annotates"],pins:["annotates"]},"gap-close":{v:1,args:["targetTip","resolvedBy","sourceId","by"],pins:["gaps"]},chat:{v:1,args:["ops","judgements","by","mintable","sid"],pins:["targets","enhance","redirectTo","retract","conv"]},design:{v:1,args:["ucRef","sections","by","engine","force","forceScope","reason","generationTicket","templateVersion","phase","phaseCompleteness","eventIds","sid"],pins:["ucRef","automates","verifies","reuses","scope","depends_on","exercises","scoped_to_repoints","judgements","body_tags","forceScope"]},execution:{v:1,args:["facts","by","eventIds"],pins:["facts"]},parked:{v:1,args:["line"],pins:["facts"]},"exec-supersede":{v:1,args:["tip","raw","fileId","by"],pins:["tip","imports"]},ingest:{v:1,args:["source_id","blob","label","media","derived_blobs","eventIds"],pins:["prior_head"]},distill:{v:1,args:["watermark","by"],pins:["events"]},"conv-mint":{v:1,args:["sessionStamp","by"],pins:[]},"conv-turn":{v:1,args:["sourceId","text","force","by"],pins:["append_of"]},archive:{v:1,args:["ref","reason","by"],pins:["ref"]},revert:{v:1,args:["seq","reason","by"],pins:["target"]}};function P(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let n=Object.getPrototypeOf(e);return n===Object.prototype||n===null}function V(e){return e===null||typeof e=="string"||typeof e=="boolean"?!0:typeof e=="number"?Number.isFinite(e):Array.isArray(e)?e.every(V):P(e)&&Object.values(e).every(V)}var ln=e=>typeof e=="string"&&dn.includes(e);function $e(e){if(!P(e))return"intent is missing: every append names the intent it fulfils";if(!ln(e.verb))return`intent verb ${String(e.verb)} is not a writer this build knows`;let n=Re[e.verb].v;if(e.v!==n)return`intent ${e.verb} v ${String(e.v)} is not the version this build writes (v ${n})`;if(!P(e.pins)||!V(e.pins))return"intent pins is not a plain JSON object";if(!V(e.args))return"intent args is not JSON";let t=Re[e.verb];for(let a of t.args??[])if(!P(e.args)||!(a in e.args))return`intent ${e.verb} arg ${a} is missing`;for(let a of t.pins??[])if(!(a in e.pins))return`intent ${e.verb} pin ${a} is missing`;return null}function Qn(e){return JSON.parse(JSON.stringify(e))}function Se(e,n){let t=n.slice(7);return cn(e,"intents",t.slice(0,2),`${t}.json`)}function et(e,n){let t=Se(e,n);return Q(t)?JSON.parse(an(t,"utf8")):null}function ke(e,n,t){let a=Se(e,t.hash),i=_e(a),o=_e(i),c=!Q(o),p=c||!Q(i);on(i,{recursive:!0});let s={v:n.v,verb:n.verb,args:n.args,pins:n.pins,born:{...t,build:ee}};return ne(a,JSON.stringify(s)+`
|
|
5
|
-
`),p&&U(o),c&&U(e),a}var f=class extends Error{},Le="run kane-cli context sync or kane-cli context pull to continue, or kane-cli context sync doctor --abort to close it",Ne="run kane-cli context sync doctor to see it, and kane-cli context sync doctor --abort to set the unreadable ledger aside; the backup stays";function fn(e){if(!e||typeof e!="object"||Array.isArray(e))return null;let n=e;if(n.state!=="open"&&n.state!=="closed"||!Array.isArray(n.items))return null;let t=["applied","held","skipped","deduped"];for(let a of n.items){if(!a||typeof a!="object"||Array.isArray(a))return null;let i=a.outcome;if(i===void 0)continue;if(!i||typeof i!="object"||Array.isArray(i))return null;let o=Object.keys(i);if(o.length!==1||!t.includes(o[0]))return null;let c=i[o[0]];if(!c||typeof c!="object")return null}return n}var H=class extends f{constructor(t,a=Le){super(t);this.remedy=a}code="SYNC_REBASE_PENDING"};function pn(e){let n=b(e,"sync","replay");if(!Ae(n))return null;let t=je(n).filter(a=>a.endsWith(".json")&&!a.endsWith(".receipt.json")).sort().reverse();for(let a of t){let i=a.slice(0,-5),o;try{o=fn(JSON.parse(R(b(n,a),"utf8")))}catch{o=null}if(o===null)return{id:i,decisions:0,unreadable:!0};if(o.state==="open")return{id:i,decisions:o.items.filter(c=>c.outcome!==void 0&&c.outcome!==null&&"held"in c.outcome).length}}return null}function gn(e){let n=pn(e);if(!n)return;if(n.unreadable)throw new H(`rebase ${n.id} has a ledger this store cannot read (sync/replay/${n.id}.json); this store takes no other change until it is set aside \u2014 ${Ne}`,Ne);let t=n.decisions>0?`a rebase (${n.id}) is open with ${n.decisions} decision${n.decisions===1?"":"s"} unresolved`:`a rebase (${n.id}) is open and not finished`;throw new H(`${t}; this store takes no other change until it is finished \u2014 ${Le}`)}function hn(e){let n=e.args?.by,t=typeof n=="object"&&n!==null&&typeof n.kind=="string"&&typeof n.id=="string";return{build:Ee(),...t?{by:n}:{}}}function mn(e){return"sha256:"+I(Buffer.from(E({verb:e.verb,args:e.args,pins:e.pins})))}function W(e,n){if(e.schema_version!==void 0&&e.schema_version!==S)throw new f(`record ${n} is stamped ${e.schema_version}, this build reads ${S} \u2014 migrate explicitly`);if(e.parents!==void 0&&!(e.prev_hash===null?e.parents.length===0:e.parents.length===1&&e.parents[0]===e.prev_hash))throw new f(`record ${n}: parents does not mirror prev_hash \u2014 multi-parent records need a DAG-aware reader`)}var G=class extends f{},se=class extends f{code="CONTEXT_APPEND_BUSY"};function ie(e,n){xe(e,{recursive:!0});let t=b(e,".lock"),a=Date.now()+(n?n.deadlineMs:2e3);for(;;)try{return Fe(t,`${process.pid}
|
|
6
|
-
`,{flag:"wx"}),()=>{try{te(t)}catch{}}}catch(i){if(i.code!=="EEXIST")throw i;if(n){let o=null,c=null;try{c=R(t,"utf8");let p=Number.parseInt(c.trim(),10);o=Number.isInteger(p)?p:null}catch{c=null}if(c!==null&&o!==null&&!le(o)){let p=`${t}.break-${process.pid}-${Date.now()}`;try{re(t,p);let s=null;try{s=R(p,"utf8")}catch{s=null}if(s===null||s===c)te(p,{force:!0});else try{re(p,t)}catch{te(p,{force:!0})}}catch(s){if(s.code!=="ENOENT")throw s}continue}if(Date.now()>a)throw new se(`.context append is busy: ${t} held ${o===null?"by a holder that has not written its pid":`by live pid ${o}`} past the deadline`);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,25+Math.floor(Math.random()*50));continue}if(Date.now()>a)throw new f(`.context is locked by another process \u2014 remove ${t} if that process is gone`);Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,25)}}var yn=/^\d{6}-[0-9a-f]{12}\.json$/,wn=999999;function Te(e,n){if(e>wn)throw new f(`${n}: position ${e} is above 999,999, the highest a six-digit record file can name \u2014 the sharded commits layout is a follow-up; nothing was written`)}var $=e=>b(e,"commits");function N(e){return"sha256:"+I(Buffer.from(E(e),"utf8"))}var oe=class extends f{constructor(t){let a=[...new Set(t.map(i=>Number(i.slice(0,6))))];super(`FORKED: more than one record at position${a.length>1?"s":""} ${a.join(", ")} \u2014 another copy of this store was merged into commits/. kane-cli context sync doctor lists the files; move the foreign ones out and rebuild.`);this.duplicates=t}code="CONTEXT_FORKED"},De="000001-000000000000.json",Je="store is mid-reset: run kane-cli context sync doctor";function dt(e){return JSON.stringify({seq:1,prev_hash:null,schema_version:"assurance/context@1 :: mid-reset :: run kane-cli context sync doctor",kane:{fence:"reset",nonce:e,journal:"sync/journal.json"}})}function x(e){let{files:n,midReset:t}=Be(e);if(t)throw new f(Je);return n}function Be(e){let n=$(e);if(!Ae(n))return{files:[],midReset:!1};let t=je(n).filter(o=>yn.test(o)).sort(),a=t.indexOf(De);a>=0&&t.splice(a,1);let i=[];for(let o=0;o<t.length;o++){let c=t[o].slice(0,6);(o>0&&t[o-1].slice(0,6)===c||o+1<t.length&&t[o+1].slice(0,6)===c)&&i.push(t[o])}if(i.length>0)throw new oe(i);return{files:t,midReset:a>=0}}function L(e){let n=x(e),t=[],a=[],i=null;return n.forEach((o,c)=>{let p=R(b($(e),o),"utf8"),s;try{s=JSON.parse(p)}catch(d){throw new f(`corrupt commit record ${o}: ${String(d)}`)}if(s.seq!==c+1)throw new f(`sequence gap: expected seq ${c+1}, ${o} has ${s.seq}`);if(s.prev_hash!==i)throw new f(`broken chain at ${o}: prev_hash ${String(s.prev_hash)} != ${String(i)}`);W(s,o);let h=N(s),r=o.slice(7,19);if(!h.slice(7).startsWith(r))throw new f(`tampered record ${o}: content hash ${h} does not match filename`);t.push(s),a.push(h),i=h}),{records:t,hashes:a}}function Me(e){return Pe(e,x(e))}function Pe(e,n){if(n.length===0)return null;let t=n[n.length-1],a=R(b($(e),t),"utf8"),i;try{i=JSON.parse(a)}catch(c){throw new f(`corrupt tail record ${t}: ${String(c)}`)}W(i,t);let o=N(i);if(!o.slice(7).startsWith(t.slice(7,19)))throw new f(`tampered tail record ${t}: content hash ${o} does not match filename`);if(i.seq!==n.length)throw new f(`sequence gap at tail: ${n.length} record files but tail seq is ${i.seq}`);return{seq:i.seq,hash:o}}function lt(e){return Me(e)?.hash??null}var vn="corrupt";function T(e,n){let t=x(e)[n-1];if(!t)return null;try{return N(JSON.parse(R(b($(e),t),"utf8")))}catch{return vn}}function A(e,n,t){let a=x(e);if(a.length<n)throw new f(`derived state is ahead of the record log (applied seq ${n}, ${a.length} records) \u2014 run kane-cli context rebuild`);let i=[],o=[],c=t;for(let p=n;p<a.length;p++){let s=a[p],h=R(b($(e),s),"utf8"),r;try{r=JSON.parse(h)}catch(g){throw new f(`corrupt commit record ${s}: ${String(g)}`)}if(r.seq!==p+1)throw new f(`sequence gap: expected seq ${p+1}, ${s} has ${r.seq}`);if(r.prev_hash!==c)throw new f(`broken chain at ${s}: prev_hash ${String(r.prev_hash)} != ${String(c)}`);W(r,s);let d=N(r);if(!d.slice(7).startsWith(s.slice(7,19)))throw new f(`tampered record ${s}: content hash ${d} does not match filename`);i.push(r),o.push(d),c=d}return{records:i,hashes:o}}function ut(e,n){if(n.seq===0){if(n.hash!==null)throw new f("watermark not in chain: seq 0 cannot carry a hash");return L(e)}let t=x(e);if(t.length<n.seq)throw new f(`watermark not in chain: seq ${n.seq} is beyond the ${t.length}-record chain`);let a=t[n.seq-1],i;try{i=JSON.parse(R(b($(e),a),"utf8"))}catch(c){throw new f(`watermark record ${a} unreadable: ${String(c)}`)}let o=N(i);if(o!==n.hash)throw new f(`watermark not in chain: seq ${n.seq} hashes ${o}, watermark claims ${String(n.hash)}`);return A(e,n.seq,n.hash)}function ft(e,n,t){let a=$e(t.intent);if(a!==null)throw new f(`append refused: ${a}; nothing was written`);if("replayed_from"in n)throw new f("append refused: replayed_from is stamped by the append layer from opts.provenance; nothing was written");if("event_digests"in n||"intent_verb"in n||"created_by"in n)throw new f("append refused: event_digests, intent_verb and created_by are stamped by the append layer from the intent; nothing was written");let i=ie(e,t.busyRetry);try{return Ve(e,n,t)}finally{i()}}function pt(e,n){let t=ie(e);try{return Ve(e,n,{})}finally{t()}}function Ve(e,n,t){t.provenance||gn(e);let a=Me(e),i=(a?.seq??0)+1;Te(i,"append");let o=a?.hash??null;if(t.expectPrev!==void 0&&t.expectPrev!==o)throw new G(`concurrent append detected: validated against ${String(t.expectPrev)} but the chain head is ${String(o)} \u2014 re-open and retry`);let c={seq:i,prev_hash:o,...n,schema_version:S,parents:o===null?[]:[o],...t.intent?{intent_verb:t.intent.verb,created_by:hn(t.intent)}:{},...t.intent&&n.event_ids&&n.event_ids.length>0?{event_digests:n.event_ids.map(()=>mn(t.intent))}:{},...t.provenance?{replayed_from:t.provenance.replayed_from}:{}},p=N(c);if(t.provenance)try{be(e,ve(e),c,p)}catch(h){throw h instanceof q?new f(`replayed record would not pass this store's checks: ${h.message}; nothing was written`):h}t.intent&&ke(e,t.intent,{seq:i,hash:p,ts:c.ts});let s=Ue(e,i,p,JSON.stringify(c)+`
|
|
7
|
-
`);return{seq:i,hash:p,file:s,record:c}}function ne(e,n){let t=`${e}.tmp-${process.pid}`,a=Ce(t,"w");try{Fe(a,n),qe(a)}finally{Oe(a)}re(t,e),U(un(e))}function U(e){try{let n=Ce(e,"r");try{qe(n)}finally{Oe(n)}}catch{}}function Ue(e,n,t,a){let i=$(e);xe(i,{recursive:!0});let o=`${String(n).padStart(6,"0")}-${t.slice(7,19)}.json`,c=b(i,o);return ne(c,a),c}var Ie=100;function gt(e,n,t,a={}){if(n.length===0)return[];if(n.length>Ie)throw new f(`import: batch of ${n.length} exceeds ${Ie} records per lock \u2014 chunk it`);let i=n[0].seq;if(!Number.isInteger(i)||i<1)throw new f(`import: batch starts at seq ${String(i)}, positions start at 1`);Te(i+n.length-1,"import");let o=[],c=t;n.forEach(({seq:s,raw:h},r)=>{let d=i+r;if(s!==d)throw new f(`import: expected seq ${d}, batch carries ${String(s)}`);let g;try{g=JSON.parse(h)}catch(y){throw new f(`import: record ${s} is not JSON: ${String(y)}`)}if(g===null||typeof g!="object"||Array.isArray(g))throw new f(`import: record ${s} is not a JSON object`);let u=g;if(u.seq!==s)throw new f(`import: expected seq ${s}, record carries ${String(u.seq)}`);if(u.prev_hash!==c)throw new f(`import: record ${s} is sealed onto ${String(u.prev_hash)}, local tail is ${String(c)}`);W(u,`import@${s}`);let l=N(u);o.push({seq:s,hash:l,raw:h}),c=l});let p=a.lockHeld?()=>{}:ie(e);try{let s=Be(e);if(s.midReset&&!bn(e,a.underReset))throw new f(Je);let h=Pe(e,s.files);if((h?.hash??null)!==t)throw new G(`import: local tail moved to ${String(h?.seq??0)} ${String(h?.hash??null)} \u2014 re-plan the pull`);if((h?.seq??0)!==i-1)throw new f(`import: batch starts at seq ${i}, local tail is at ${String(h?.seq??0)}`);return o.map(({seq:r,hash:d,raw:g})=>({seq:r,hash:d,file:Ue(e,r,d,g)}))}finally{p()}}function bn(e,n){if(!n)return!1;try{return JSON.parse(R(b($(e),De),"utf8")).kane?.nonce===n.nonce}catch{return!1}}export{E as a,I as b,F as c,Sn as d,kn as e,Nn as f,Dn as g,we as h,q as i,be as j,Zn as k,$e as l,Qn as m,Se as n,et as o,f as p,Le as q,Ne as r,fn as s,H as t,pn as u,gn as v,mn as w,G as x,se as y,ie as z,wn as A,N as B,oe as C,De as D,dt as E,L as F,Me as G,lt as H,vn as I,T as J,A as K,ut as L,ft as M,pt as N,ne as O,U as P,Ie as Q,gt as R,B as S,he as T,O as U,M as V,k as W,Xe as X,jn as Y,Fn as Z,Ln as _};
|
package/dist/chunk-RKXHVP2Z.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
var R={"use-case":"use-cases",ac:"ACs",scenario:"scenarios",test:"tests",gap:"gaps"},l=n=>R[n]??`${n}s`,k=n=>n==="ac"?"AC":n==="use-case"?"use-case":n,p=n=>n.kind??"use-case",C=n=>`${p(n)}:${n.temp_ref}`;function T(n){let t=n,a=t.badge??n.risk??null,u=t.why??n.summary??n.description??null;return JSON.stringify([n.title,a,u,t.extra??null,n.depends_on_hint??null])}function w(n){return n.filter(t=>t.role==="agent"&&typeof t.turnIndex=="number"&&Array.isArray(t.items)&&t.items.length>0)}function S(n){let t=new Map,a=1;for(let s of w(n)){let r=new Set;for(let o of s.items){let d=C(o);if(r.has(d))continue;r.add(d);let f=t.get(d);t.set(d,{num:f?.num??a++,ref:o.temp_ref,kind:p(o),item:o,turnIndex:s.turnIndex,fingerprint:T(o)})}}let u=[...t.values()].sort((s,r)=>s.num-r.num),c=[];for(let s of u){let r=c.find(o=>o.kind===s.kind);r?r.count++:c.push({kind:s.kind,label:l(s.kind),count:1})}return{entries:u,byRef:t,counts:c}}function $(n,t){let u=w(n).find(e=>e.turnIndex===t);if(!u)return null;let c=n.filter(e=>e.role!=="agent"||typeof e.turnIndex!="number"||e.turnIndex<=t),s=S(c),r=S(n.filter(e=>e.role!=="agent"||typeof e.turnIndex!="number"||e.turnIndex<t)),o=[],d=new Map,f=new Map,y=new Map,b=new Set;for(let e of u.items){let i=C(e);if(b.has(i))continue;b.add(i);let m=r.byRef.get(i),h=e.changed===!0,U=s.byRef.get(i).num,g=p(e);if(m&&!h&&m.fingerprint===T(e)){d.set(g,(d.get(g)??0)+1);continue}let x=!!m||h,I=x?y:f;I.set(g,(I.get(g)??0)+1),o.push({item:e,num:U,updated:x})}let A=[...d.entries()].map(([e,i])=>({label:l(e),count:i})),D=[...[...f.entries()].map(([e,i])=>`${i} new ${i===1?k(e):l(e)}`),...[...y.entries()].map(([e,i])=>`${i} updated ${i===1?k(e):l(e)}`)].join(" \xB7 ");return{fresh:o,unchanged:A,headerStats:D}}function M(n,t){let a=n.entries.filter(s=>s.turnIndex===t);if(a.length===0)return n;let u=new Map(a.map(s=>[s.ref,s])),c=[];for(let s of a){let r=c.find(o=>o.kind===s.kind);r?r.count+=1:c.push({kind:s.kind,label:l(s.kind),count:1})}return{entries:a,byRef:u,counts:c}}export{l as a,C as b,T as c,S as d,$ as e,M as f};
|
package/dist/chunk-RRY5IXOB.js
DELETED