@testmuai/kane-cli 0.8.22 → 0.8.23
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-PA73V3NT.js → ChatSurface-GBZX4LWL.js} +1 -1
- package/dist/{ChromeProfilePicker-XX223SYB.js → ChromeProfilePicker-UONX2UVC.js} +1 -1
- package/dist/{CliFeedbackPrompt-J6DW6TZL.js → CliFeedbackPrompt-6BJCNRNG.js} +1 -1
- package/dist/{CliUploadProgress-TWEL7NWG.js → CliUploadProgress-K4Z22DSY.js} +1 -1
- package/dist/{ConfigView-ROFNVFDQ.js → ConfigView-BB22G7JO.js} +1 -1
- package/dist/{EvidenceViewOffer-XUP44BGJ.js → EvidenceViewOffer-25IQF3TX.js} +1 -1
- package/dist/FolderPicker-65JFR2NW.js +2 -0
- package/dist/{InfoBox-ELZ5Q65V.js → InfoBox-OU5PLRIL.js} +1 -1
- package/dist/{LinksBox-2V26KLTJ.js → LinksBox-DH7TSUXW.js} +1 -1
- package/dist/{ProfilesView-P4Z42LSX.js → ProfilesView-MGJKBOF5.js} +1 -1
- package/dist/{ProjectPicker-2QNFNN7T.js → ProjectPicker-YFV6K77F.js} +1 -1
- package/dist/{SaveSessionPrompt-XMWL3P6G.js → SaveSessionPrompt-64QKQB6B.js} +1 -1
- package/dist/SingleShotApp-VYKUCRVW.js +2 -0
- package/dist/{SummaryBox-RWO4BYYD.js → SummaryBox-DGS3LVRF.js} +1 -1
- package/dist/TestMdRunView-LKAITAA4.js +2 -0
- package/dist/{TestrunEvidenceTable-MUOGF6CZ.js → TestrunEvidenceTable-PHBAB4XQ.js} +1 -1
- package/dist/{WhoamiView-4EYWZR4N.js → WhoamiView-6HWPYN6Y.js} +1 -1
- package/dist/{app-download-KUJVMZ7L.js → app-download-SQ2LYYL7.js} +1 -1
- package/dist/{auth-5HAY24TN.js → auth-NWBIFCB7.js} +1 -1
- package/dist/{binary-6UEOI7PT.js → binary-MOJTQGUV.js} +1 -1
- package/dist/{bind-3C2IIPML.js → bind-S3IQTPNN.js} +2 -2
- package/dist/{bootstrap-DBAQWVNA.js → bootstrap-RCV7PNMQ.js} +1 -1
- package/dist/bridge-O7ENTV4K.js +2 -0
- package/dist/{changelog-QAGRYBEZ.js → changelog-2N6HKKKQ.js} +1 -1
- package/dist/{chunk-T6MGCP57.js → chunk-2A7OQRAD.js} +4 -4
- package/dist/{chunk-GVE5GEW2.js → chunk-2FH4HJYB.js} +1 -1
- package/dist/{chunk-5ILTSBWT.js → chunk-2MEQTHNI.js} +1 -1
- package/dist/{chunk-YFBJWIBU.js → chunk-3C32LVLX.js} +1 -1
- package/dist/{chunk-XQNJSM5C.js → chunk-3OKX64UR.js} +1 -1
- package/dist/{chunk-R43ELADV.js → chunk-3UMVRJX3.js} +2 -2
- package/dist/{chunk-OT3VKXJX.js → chunk-5ESGUPSR.js} +1 -1
- package/dist/{chunk-Z2XKFYMH.js → chunk-5HOHXV2K.js} +1 -1
- package/dist/{chunk-NUYGWRB2.js → chunk-5RHR4DMF.js} +1 -1
- package/dist/{chunk-VW3PFRCO.js → chunk-5UHY3PTQ.js} +1 -1
- package/dist/{chunk-PUFZTE6L.js → chunk-6YZ3VP3E.js} +1 -1
- package/dist/{chunk-OBB57E2L.js → chunk-7KRY26OF.js} +1 -1
- package/dist/{chunk-6MCQ2UKE.js → chunk-AGDPEZXT.js} +1 -1
- package/dist/{chunk-LKPOOZYN.js → chunk-AIK7BAME.js} +2 -2
- package/dist/{chunk-BPYRVV7O.js → chunk-AT3RME5W.js} +1 -1
- package/dist/{chunk-SB5XM4YV.js → chunk-ATYXPCM6.js} +1 -1
- package/dist/{chunk-P37ALET7.js → chunk-BASTDR3M.js} +1 -1
- package/dist/{chunk-SW54RAAT.js → chunk-C7NWWGLT.js} +1 -1
- package/dist/{chunk-E2KV4BQB.js → chunk-CAJZQQ3G.js} +1 -1
- package/dist/{chunk-QV445GUU.js → chunk-CLQP3DHT.js} +1 -1
- package/dist/{chunk-2OIIXLXW.js → chunk-CSVPZ33X.js} +1 -1
- package/dist/{chunk-SJZJ7ASF.js → chunk-CXF6AZWY.js} +1 -1
- package/dist/{chunk-R7ZDLGMU.js → chunk-D4XR7EEQ.js} +1 -1
- package/dist/{chunk-FDXDFZ7J.js → chunk-D6BULK7E.js} +1 -1
- package/dist/{chunk-5E4JLXR5.js → chunk-DDHGEJJP.js} +1 -1
- package/dist/{chunk-3MWLFHPO.js → chunk-DSKJ6J7Y.js} +1 -1
- package/dist/{chunk-MHMEEA4S.js → chunk-DUYRCVI5.js} +1 -1
- package/dist/{chunk-CBUSNWHA.js → chunk-DWHF5HUD.js} +1 -1
- package/dist/{chunk-ADBOWRMW.js → chunk-EM3PU2YW.js} +1 -1
- package/dist/{chunk-DF4EBXGN.js → chunk-FMBPUXWL.js} +1 -1
- package/dist/{chunk-XFQLR6MF.js → chunk-FORNRNHU.js} +1 -1
- package/dist/{chunk-HKIBJDKE.js → chunk-FPFS6OSR.js} +1 -1
- package/dist/{chunk-2HFNP2LM.js → chunk-FQJOWUEN.js} +1 -1
- package/dist/{chunk-JHYWNWS5.js → chunk-GFNCGN5V.js} +2 -2
- package/dist/{chunk-RUSRN7YE.js → chunk-HBSYBL6J.js} +1 -1
- package/dist/{chunk-5XAX4C5N.js → chunk-HJGVM6TS.js} +1 -1
- package/dist/{chunk-JPOFRYTX.js → chunk-HJX5PQRD.js} +1 -1
- package/dist/{chunk-WBH5GYFM.js → chunk-HPHETGRE.js} +1 -1
- package/dist/{chunk-VCY7UNEL.js → chunk-IEW7AW64.js} +1 -1
- package/dist/{chunk-DZCJE77P.js → chunk-IGHK2ENL.js} +1 -1
- package/dist/{chunk-FR3LVUAB.js → chunk-IIDBLJ5A.js} +1 -1
- package/dist/{chunk-6C35NKQ7.js → chunk-J2FJ62K4.js} +1 -1
- package/dist/{chunk-NMAPNJRY.js → chunk-J6TBTWW7.js} +1 -1
- package/dist/{chunk-WGIZQGR5.js → chunk-JFZA4UON.js} +1 -1
- package/dist/{chunk-3M6OM3T4.js → chunk-K6VDRR3H.js} +1 -1
- package/dist/{chunk-SREUA7YQ.js → chunk-KJIDMW6N.js} +1 -1
- package/dist/{chunk-BNC4DJCC.js → chunk-LF42V6P6.js} +1 -1
- package/dist/{chunk-5BHB5D2C.js → chunk-LHUW5QDT.js} +1 -1
- package/dist/{chunk-I4SO2FQV.js → chunk-LNFU4JZ7.js} +1 -1
- package/dist/{chunk-MXI5P373.js → chunk-LNSBC32V.js} +1 -1
- package/dist/{chunk-5TQIKRKP.js → chunk-MBJHS653.js} +1 -1
- package/dist/{chunk-3H3KTCL7.js → chunk-MKMJOMLX.js} +2 -2
- package/dist/{chunk-4VW3B7SE.js → chunk-MKQ7ZRDW.js} +1 -1
- package/dist/{chunk-44NNFVCJ.js → chunk-MV3Q335C.js} +1 -1
- package/dist/{chunk-GYLMH2EX.js → chunk-MWIE6LOZ.js} +1 -1
- package/dist/{chunk-2G5CJQOR.js → chunk-MZ7W4WLF.js} +1 -1
- package/dist/{chunk-L35DJDX7.js → chunk-NIFJJX6N.js} +1 -1
- package/dist/{chunk-SIXPXYCH.js → chunk-OFRYEWZE.js} +1 -1
- package/dist/{chunk-NAWGHDA3.js → chunk-OYKRCDT4.js} +1 -1
- package/dist/{chunk-RFDL7MHI.js → chunk-PXHN7SFG.js} +1 -1
- package/dist/{chunk-LSRNUBIV.js → chunk-QAG67DUT.js} +1 -1
- package/dist/{chunk-BPDFI2DC.js → chunk-QGXVQIN5.js} +2 -2
- package/dist/{chunk-REPKBN7I.js → chunk-QQCEP3QP.js} +1 -1
- package/dist/{chunk-WPBETG6U.js → chunk-QU7P7B3W.js} +3 -3
- package/dist/{chunk-5FQYB5SM.js → chunk-RAARDC2O.js} +1 -1
- package/dist/{chunk-46U7TRPE.js → chunk-RAPV3BTA.js} +2 -2
- package/dist/{chunk-ZUJGYHZ2.js → chunk-RD72POF2.js} +1 -1
- package/dist/{chunk-5D6YMG63.js → chunk-RMVASIVL.js} +2 -2
- package/dist/{chunk-SVJBOVI4.js → chunk-SB2SKN34.js} +1 -1
- package/dist/{chunk-4ZBI54KE.js → chunk-SFFDVF3J.js} +2 -2
- package/dist/{chunk-PLIQ72LH.js → chunk-SY4T44VC.js} +1 -1
- package/dist/{chunk-EVBCKI7D.js → chunk-SYJXTB4J.js} +1 -1
- package/dist/{chunk-CE23VDW5.js → chunk-TONFENRW.js} +1 -1
- package/dist/{chunk-3BUYTNAV.js → chunk-UF4MU2AZ.js} +2 -2
- package/dist/{chunk-GF32QBCM.js → chunk-UQSVO7TY.js} +1 -1
- package/dist/{chunk-WHNF5SWS.js → chunk-URWWROLS.js} +2 -2
- package/dist/{chunk-O4LJWUSJ.js → chunk-UYI4WPNQ.js} +1 -1
- package/dist/{chunk-WRGPMDDE.js → chunk-VACHFCNC.js} +1 -1
- package/dist/{chunk-3NMXXTHE.js → chunk-VAN7ECN6.js} +1 -1
- package/dist/{chunk-26HZJJN6.js → chunk-VOYMN2WQ.js} +1 -1
- package/dist/{chunk-UXR57BCE.js → chunk-WICJY6KL.js} +1 -1
- package/dist/{chunk-FBRTUEAL.js → chunk-X4NUVVCJ.js} +3 -3
- package/dist/{chunk-JQ3JB5CO.js → chunk-XQQHSC7G.js} +1 -1
- package/dist/{chunk-XKYL4K4A.js → chunk-YI3H2UIB.js} +1 -1
- package/dist/{chunk-JHBNXTG6.js → chunk-ZIHG6EKH.js} +1 -1
- package/dist/{config-HVSKN6L4.js → config-7E4NS553.js} +1 -1
- package/dist/{cover-cmd-ZZJA5C6H.js → cover-cmd-6KZX46S2.js} +1 -1
- package/dist/{credentials-FH6VZPJS.js → credentials-PSQWWFGD.js} +1 -1
- package/dist/{deps-bundle-QUROUKJI.js → deps-bundle-PPOQHJTB.js} +1 -1
- package/dist/{deps-resolve-N2KKJ37Q.js → deps-resolve-AX6ZAKLH.js} +1 -1
- package/dist/{device-env-ID7EDDOD.js → device-env-TZQDB5T3.js} +1 -1
- package/dist/{dispatch-BYA5Q2SD.js → dispatch-KMWEDMKE.js} +1 -1
- package/dist/{doctor-MGHY2M36.js → doctor-XDF3MA4W.js} +1 -1
- package/dist/{evidence-XYKLWPPY.js → evidence-EUIDOVOR.js} +1 -1
- package/dist/{evolve-cmd-BURJDLVF.js → evolve-cmd-QVTGTCJ5.js} +1 -1
- package/dist/{explain-cmd-53EO2IMN.js → explain-cmd-36SVSHU7.js} +1 -1
- package/dist/{extract-bind-T7GKUEJ6.js → extract-bind-PLMSZKLZ.js} +2 -2
- package/dist/{extract-cmd-WXG34RMY.js → extract-cmd-RJBHPPF3.js} +1 -1
- package/dist/{gaps-cmd-T55FFFVB.js → gaps-cmd-3WZPDDYS.js} +1 -1
- package/dist/{generate-headless-BSBY47K2.js → generate-headless-TEDHS3F2.js} +2 -2
- package/dist/index.js +16 -16
- package/dist/{ingest-cmd-BYOZCTVG.js → ingest-cmd-JDIOPJBN.js} +1 -1
- package/dist/install-Y3VKFBK3.js +2 -0
- package/dist/{interactive-bind-JAB6XUPX.js → interactive-bind-XUMKEGAN.js} +3 -3
- package/dist/{lifecycle-cmd-QVGYYJSG.js → lifecycle-cmd-FBDRFIOE.js} +1 -1
- package/dist/{list-cmd-RQYRC345.js → list-cmd-TFUACRAM.js} +1 -1
- package/dist/{list-commands-VTWPMFG3.js → list-commands-OHIQFJGQ.js} +1 -1
- package/dist/login-flow-OHNKSVYZ.js +2 -0
- package/dist/{maintenance-cmd-NC2VI5G7.js → maintenance-cmd-7OSUIDL4.js} +1 -1
- package/dist/{mobile-prompts-VCA73IYP.js → mobile-prompts-DEVUZRG3.js} +1 -1
- package/dist/{objective-variable-gate-WZFN5I7Y.js → objective-variable-gate-JALOH6SL.js} +1 -1
- package/dist/{open-provider-YXHFPVDE.js → open-provider-746LLSEO.js} +1 -1
- package/dist/{persist-recorded-session-SZDBBSNH.js → persist-recorded-session-GPP6UKN6.js} +1 -1
- package/dist/{pipeline-FAU3PBDH.js → pipeline-QPTPZVUJ.js} +1 -1
- package/dist/prepare-target-N7QRNYOS.js +2 -0
- package/dist/{reconcile-cmd-2BFK7RFL.js → reconcile-cmd-SMGLHMLF.js} +1 -1
- package/dist/{reconcile-deps-CYWH6GM4.js → reconcile-deps-DVIJK5UZ.js} +2 -2
- package/dist/{reconcile-engine-ZWIJFYBP.js → reconcile-engine-KL2J5SNQ.js} +1 -1
- package/dist/{recording-banner-FRH2EJBM.js → recording-banner-TCFFB6KE.js} +1 -1
- package/dist/registry-BFFA4YJK.js +2 -0
- package/dist/{require-project-folder-A6YTVLAK.js → require-project-folder-2224ZMJ5.js} +1 -1
- package/dist/{resolve-run-intent-PHAXPW6C.js → resolve-run-intent-HFXGEOYK.js} +1 -1
- package/dist/{resolver-U55SNASN.js → resolver-GJR2Z7JY.js} +1 -1
- package/dist/{review-cmd-ZKCXBMFP.js → review-cmd-CQE6SBZA.js} +1 -1
- package/dist/{run-76I4OYXD.js → run-BXKWDJFJ.js} +1 -1
- package/dist/{run-XJK3YOW2.js → run-HSP2MZPU.js} +1 -1
- package/dist/{run-test-md-A3QRWLCW.js → run-test-md-2ELPAASM.js} +2 -2
- package/dist/{skill-installer-LSDCMJ6P.js → skill-installer-T2IOCPET.js} +1 -1
- package/dist/{spawner-HZXP66DS.js → spawner-HQM2757J.js} +1 -1
- package/dist/{store-guard-27XJZ7WF.js → store-guard-NAW26EEQ.js} +1 -1
- package/dist/{sync-cmd-JZ3MXGEU.js → sync-cmd-Q6ZYEVWI.js} +1 -1
- package/dist/{sync-setup-HGG7ALGA.js → sync-setup-CA362C5S.js} +1 -1
- package/dist/tcg-generate-CDB2N5LD.js +2 -0
- package/dist/testmd-actions-BDWDE2TG.js +2 -0
- package/dist/{testmd-sync-RKSGTCZA.js → testmd-sync-EPTUVJYJ.js} +1 -1
- package/dist/token-refresh-TKBOHXSD.js +2 -0
- package/dist/{validate-basic-5NYH5WYI.js → validate-basic-V7R4RH5M.js} +1 -1
- package/dist/{variable-receipt-C3US6X4M.js → variable-receipt-F55CSW5Z.js} +1 -1
- package/dist/{verdicts-VPTU4YAS.js → verdicts-7IUZFXB4.js} +1 -1
- package/dist/{version-check-YY57B2A4.js → version-check-PUUSB7AY.js} +1 -1
- package/dist/{view-cmd-KWIBYZ5S.js → view-cmd-ELDKYRMZ.js} +1 -1
- package/dist/{walk-session-YSKEJM2F.js → walk-session-EGIMA4VG.js} +1 -1
- package/dist/{with-telemetry-2NY4CPL5.js → with-telemetry-LRWWBISP.js} +1 -1
- package/package.json +11 -11
- package/dist/FolderPicker-XLAK7324.js +0 -2
- package/dist/SingleShotApp-3YZSE3AA.js +0 -2
- package/dist/TestMdRunView-QHPMG46M.js +0 -2
- package/dist/bridge-NHXCRSIU.js +0 -2
- package/dist/install-OABVIXAE.js +0 -2
- package/dist/login-flow-HUORIV6P.js +0 -2
- package/dist/prepare-target-XYOTVK2I.js +0 -2
- package/dist/registry-QR3BDI5F.js +0 -2
- package/dist/tcg-generate-S77VVSVU.js +0 -2
- package/dist/testmd-actions-VQJ22WZZ.js +0 -2
- package/dist/token-refresh-AOCGYGEC.js +0 -2
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{d as Me,h as $e}from"./chunk-AACQE24F.js";import{b as H,c as C,d as K,e as Y}from"./chunk-
|
|
2
|
+
import{d as Me,h as $e}from"./chunk-AACQE24F.js";import{b as H,c as C,d as K,e as Y}from"./chunk-MBJHS653.js";import{b as _,c as B,d as Ae,f as z,g as U}from"./chunk-5GUD3CIH.js";import{c as Ve,d as Be}from"./chunk-WJR2FU7S.js";import{a as A,b as D,d as Pe}from"./chunk-EHN5HTUD.js";import{h as j,k as je,m as Oe,o as Fe}from"./chunk-RGRFL7XG.js";import{d as Te}from"./chunk-VVOKM2VO.js";import{a as N,c as Se,d as Ee,e as Re,f as V}from"./chunk-YFQGOOF7.js";import{z as O}from"./chunk-IICT4VOU.js";import{a as Ne}from"./chunk-CH273NAE.js";import{b as x,c as h}from"./chunk-VZ7KXRXB.js";import{a as De,b as Ce,c as Le}from"./chunk-6YZ3VP3E.js";import{a as xe,b as Ie}from"./chunk-HBSYBL6J.js";import{a as ke}from"./chunk-CXF6AZWY.js";function S(e){if(e===null)return"broken";let t=Math.floor(e/100);return t===1?"passed":t===7?"failed":t===2?"skipped":"broken"}var I={failed:3,broken:2,passed:1,skipped:0};function q(e){let t="skipped";for(let r of e)I[r]>I[t]&&(t=r);return t}import{createHash as ft}from"crypto";import{basename as gt}from"path";function W(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40);return t.length>0?t:"session"}function G(e){return ft("sha256").update(e).digest("hex").slice(0,8)}function J(e){let t=gt(e).replace(/_test\.md$/i,"").replace(/\.md$/i,"");return`${W(t)}-${G(e)}`}function X(e,t){return`${W(e)}-${G(t)}`}function Z(e){let t=e?.trim();return t||void 0}function ze(e=process.env){let t=Z(e.TEST_INSTANCE_ID),r=Z(e.JOB_ID),n=Z(e.TASK_ID);return{...t?{testInstanceId:t}:{},...r?{jobId:r}:{},...n?{taskId:n}:{}}}function Q(e,t=process.env){let r=ze(t),n={...r.testInstanceId?{hyper_test_instance_id:r.testInstanceId}:{},...r.jobId?{hyper_job_id:r.jobId}:{},...r.taskId?{hyper_task_id:r.taskId}:{},...e},i={};for(let[o,s]of Object.entries(n))typeof s=="string"&&s.length>0&&(i[o]=s);return i}function _t(e,t){return{pack_test_dir:e,ordinal_offset:t}}import{promises as w}from"fs";import{join as y}from"path";function ee(e){let t={evidence:"0.1",run_id:e.execution_id,status:"running",title:e.title,started:e.started,environment:{producer:{name:"kane-cli",version:e.producerVersion},...e.surfaces?{surfaces:e.surfaces}:{},run_kind:e.run_kind,origin:e.origin,pid:e.pid},...e.credits!==void 0?{metrics:{credits:{value:e.credits,type:"count"}}}:{}};return h(t,{lineWidth:-1})}async function te(e,t,r,n=process.cwd(),i){let o=i??_(e.execution_id,n),s=y(o,"tests",t);return await w.mkdir(y(o,"coverage"),{recursive:!0}),await w.writeFile(y(o,"coverage",".keep"),""),await w.mkdir(s,{recursive:!0}),await w.writeFile(y(o,"run.yaml"),ee(e)),r&&await w.writeFile(y(s,r.path),r.content),o}async function vt(e,t=process.cwd()){let r=_(e.execution_id,t);await w.mkdir(y(r,"coverage"),{recursive:!0}),await w.writeFile(y(r,"coverage",".keep"),"");let n=x(ee(e));return n.environment&&delete n.environment.run_kind,await w.writeFile(y(r,"run.yaml"),h(n,{lineWidth:-1})),r}async function ht(e,t=process.cwd()){return D(_(e,t),new Date().toISOString())}async function re(e,t=process.cwd()){await w.rm(_(e,t),{recursive:!0,force:!0})}import{promises as ne}from"fs";import{join as ie}from"path";function F(e){let t={evidence:"0.1",test:e.testId,status:e.status,...e.durationMs!==void 0?{duration_ms:e.durationMs}:{},...e.attempts&&e.attempts.length?{attempts:e.attempts}:{},...e.flaky!==void 0?{flaky:e.flaky}:{},...e.adaptiveHeal?{adaptive_heal:e.adaptiveHeal}:{},...e.definitionPath?{definition:{path:e.definitionPath}}:{},...e.definitionId?{definition_id:e.definitionId}:{},...e.assuranceId?{assurance_id:e.assuranceId}:{},...Object.keys(e.externalId).length?{external_id:e.externalId}:{},...e.tags&&e.tags.length?{tags:e.tags}:{},...Object.keys(e.environment).length?{environment:e.environment}:{},steps:e.steps};return h(t,{lineWidth:-1})}function oe(e){return h({logs:e},{lineWidth:-1})}async function se(e,t,r){await ne.writeFile(ie(e,"tests",t,"result.yaml"),r)}async function ae(e,t,r){let n=ie(e,"tests",t,"logs");await ne.mkdir(n,{recursive:!0}),await ne.writeFile(ie(n,"meta.yaml"),r)}import{promises as M}from"fs";import{join as Ue}from"path";function He(e){return Ue(e,".internal","meta.json")}async function Ke(e){let t;try{t=await M.readFile(He(e),"utf8")}catch(n){if(n?.code==="ENOENT")return null;throw n}let r=JSON.parse(t);if(!r||typeof r!="object"||Array.isArray(r))throw new Error("meta.json is not a JSON object");return r}async function ce(e,t){let r;try{r=await Ke(e)??{}}catch(s){console.warn(`evidence: meta.json at ${e} unreadable \u2014 skipping execution-pointer append to preserve identity`,s);return}let n=Array.isArray(r.executions)?r.executions:[];n.push(t),r.executions=n,await M.mkdir(Ue(e,".internal"),{recursive:!0});let i=He(e),o=`${i}.tmp-${process.pid}-${Date.now()}`;await M.writeFile(o,JSON.stringify(r,null,2)+`
|
|
3
3
|
`),await M.rename(o,i)}async function wt(e){try{let t=await Ke(e);return t&&Array.isArray(t.executions)?t.executions:[]}catch{return[]}}async function yt(e,t,r=process.cwd()){let n=await z(e,r);if(!n){let o=`evidence: no pack found for "${e}"`;return t.json?console.log(JSON.stringify({valid:!1,error:"not_found",target:e})):console.error(o),2}let i=await A(n,t.profile??"L1");return t.json?console.log(JSON.stringify({valid:i.valid,status:i.status,diagnostics:i.diagnostics})):console.log(`evidence: ${i.valid?"valid":"INVALID"} (${t.profile??"L1"}, status ${i.status})`),i.valid?0:1}function ue(e){let t=[];for(let r of e){let n=r.perFlow&&r.perFlow.length?r.perFlow.map(i=>i.resultCode):[r.resultCode];for(let i of n)t.push(S(i))}return q(t)}function bt(e){let t=null;for(let r of e){let n=r.perFlow&&r.perFlow.length?r.perFlow.map(i=>i.resultCode):[r.resultCode];for(let i of n)i!=null&&(t==null||I[S(i)]>I[S(t)]||I[S(i)]===I[S(t)]&&i>t)&&(t=i)}return t}import{promises as kt}from"fs";import{extname as Ye,basename as xt}from"path";var It={".ndjson":"ndjson",".log":"log",".json":"json",".har":"har"};async function de(e){let t;try{t=await kt.readdir(e)}catch{return[]}return t.filter(r=>r!=="meta.yaml"&&!r.startsWith(".")).sort().map(r=>({name:xt(r,Ye(r)),file:r,format:It[Ye(r)]??"txt"}))}import{mkdirSync as St,appendFileSync as Et}from"fs";import{join as qe}from"path";function le(e,t){return qe(e,"tests",t,"logs")}function pe(e,t,r,n={},i){try{i?.(t,r,r,n)}catch{}if(e)try{St(e,{recursive:!0});let o=JSON.stringify({ts:new Date().toISOString(),level:t,event:r,...n})+`
|
|
4
4
|
`;Et(qe(e,"diagnostics.ndjson"),o)}catch{}}import{promises as b}from"fs";import{dirname as Ft,join as E}from"path";import{statSync as Rt}from"fs";import{promises as me}from"fs";import{basename as Pt,join as At}from"path";var Dt=1e6,Ct=2e6;function Lt(){return xe.map(e=>Ie(e))}function We(e=Lt()){return e.map(t=>{let r=0;try{r=Rt(t).size}catch{}return{path:t,offset:r}})}var jt=/\x1b\[[0-9;]*[A-Za-z]/g;async function Ot(e,t,r){let n;try{n=await me.open(e,"r");let i=(await n.stat()).size,o=t<=i?t:0,s=i-o;if(s<=0)return null;let a=s>r?i-r:o,u=Buffer.alloc(Math.min(s,r));return await n.read(u,0,u.length,a),u.toString("utf8")}catch{return null}finally{await n?.close().catch(()=>{})}}async function Ge(e,t){let r=t.caps?.stderr??Dt,n=t.caps?.appium??Ct,i=[];t.runnerStderrPath&&i.push({src:t.runnerStderrPath,from:0,cap:r});for(let o of t.appiumMarks??[])i.push({src:o.path,from:o.offset,cap:n});for(let o of i){let s=await Ot(o.src,o.from,o.cap);if(s===null)continue;let a=s.replace(jt,"");if(a!=="")try{await me.mkdir(e,{recursive:!0}),await me.writeFile(At(e,Pt(o.src)),a)}catch{}}}async function Mt(e){try{let t=E(e,"tests"),r=await b.readdir(t).catch(()=>[]);for(let n of r){let i=E(t,n,"steps"),o=await b.readdir(i).catch(()=>[]);for(let s of o){let a=await b.readFile(E(i,s,"failure.yaml"),"utf8").catch(()=>null);if(a!=null)try{let u=x(a);if(u&&typeof u=="object"&&u.triage)return!0}catch{}}}}catch{}return!1}async function Je(e,t,r,n={}){let i=E(e,"tests",t,"logs");if(r)try{await b.mkdir(i,{recursive:!0}),await b.copyFile(r,E(i,"tui.log"))}catch{}await Ge(i,{runnerStderrPath:r?E(Ft(r),"runner-stderr.log"):void 0,appiumMarks:n.appiumMarks});let o=await de(i);if(!o.length&&n.requireRealLog)throw new Error(`evidence test ${t} has no real log to declare`);o.length&&await ae(e,t,oe(o))}async function fe(e){let t=e.cwd??process.cwd(),r=e.packDir??_(e.executionId,t);if(!e.saved&&!e.packDir)return await re(e.executionId,t),{sealed:!1};await Je(r,e.testId,e.tuiLogPath,{requireRealLog:e.requireRealLog,appiumMarks:e.appiumMarks});let n=E(r,"run.yaml"),i=x(await b.readFile(n,"utf8"));i.environment={...i.environment??{},saved:e.saved,run_kind:e.runKind},await b.writeFile(n,h(i,{lineWidth:-1}));let o=await b.open(n,"r+");try{await o.sync()}finally{await o.close()}let s=await Mt(r);await D(r,new Date().toISOString());let a;try{let c=await A(r,"L1");a=c.valid;let p=(c.diagnostics??[]).filter(l=>String(l?.code??"").includes("failure.status_disagrees"));if(p.length>0)if(e.expectStatusDisagrees||s){let l=e.expectStatusDisagrees?"expected under --bug-detection continue":"self-explained by triaged failure record(s)";console.warn(`evidence: ${p.length} status_disagrees advisory(ies) \u2014 ${l}`)}else console.warn(`evidence: ${p.length} status_disagrees advisory(ies) \u2014 step verdicts disagree with their failure records`,p);if(!c.valid){console.warn(`evidence: sealed pack ${e.executionId} failed L1 validation`,c.diagnostics);let l=String(c.diagnostics?.[0]?.code??"");pe(le(r,e.testId),"warn","EVIDENCE_INVALID",{execution_id:e.executionId,first_code:l,surface:e.surface??"testmd"},e.log)}}catch(c){console.warn(`evidence: validation error for ${e.executionId}`,c)}let u;if(e.saved&&e.packDir)try{u=await Ae(r,e.executionId,t)}catch(c){console.warn(`evidence: store install failed for ${e.executionId}`,c)}if(e.outputStemDir)try{await ce(e.outputStemDir,{execution_id:e.executionId,run_kind:e.runKind,status:e.verdict,valid:a,at:new Date().toISOString()})}catch(c){console.warn(`evidence: execution-pointer append failed for ${e.executionId} (pack is sealed)`,c)}return{sealed:!0,valid:a,storePath:u}}import{release as Xe}from"os";import{execFileSync as $t}from"child_process";var Ze=!1,$;function Tt(){if(!Ze)if(Ze=!0,process.platform==="darwin")try{$=$t("sw_vers",["-productVersion"],{timeout:2e3}).toString().trim()||void 0}catch{$=Xe()||void 0}else $=Xe()||void 0;return $}function ge(e){let t={os:N(process.platform)},r=Tt();if(r&&(t.os_version=r),e.cdpBrowser){let o=/^([A-Za-z]+)\/(\d+)/.exec(e.cdpBrowser);o&&(t.browser=o[1].replace(/^Headless/,""),t.browser_version=o[2])}e.resolution&&(t.resolution=e.resolution);let n=Ee(t,e.runnerEnvironment);if(!n.native_platform)return n;e.deviceName&&(n.device=e.deviceName),!n.os_version&&e.deviceOsVersion&&(n.os_version=e.deviceOsVersion);let i=De(e.deviceApp);if(i&&(n.app=i),e.deviceModel){let o=Ce(e.deviceModel);o&&(n.device_slug=o)}return e.pixelResolution&&(n.viewport=n.resolution??Nt(e.pixelResolution,n.pixel_ratio)??e.pixelResolution,n.resolution=e.pixelResolution),n}function Nt(e,t){if(!t||!Number.isFinite(t)||t<=0)return;let r=/^(\d+)x(\d+)$/.exec(e);if(r)return`${Math.round(Number(r[1])/t)}x${Math.round(Number(r[2])/t)}`}async function Qe(e){if(e)try{let t=await fetch(`${e}/json/version`,{signal:AbortSignal.timeout(2e3)});if(!t.ok)return;let r=await t.json();return typeof r.Browser=="string"?r.Browser:void 0}catch{return}}function Vt(e){let t;return()=>(t||(t=Qe(e)),t)}import{promises as v,existsSync as k,readFileSync as Ht}from"fs";import{basename as Kt,join as m}from"path";import{readFileSync as Bt}from"fs";import{dirname as zt,resolve as Ut}from"path";function et(e,t){let r=Ut(e),n=Bt(r,"utf8");return j(t?je(n,Oe(zt(r),t)):n)}async function tt(e){for(let t of await v.readdir(e,{withFileTypes:!0})){let r=m(e,t.name);if(t.isDirectory()){await tt(r);continue}try{await v.unlink(r)}catch{await v.truncate(r,0)}}await v.rmdir(e).catch(()=>{})}function Yt(e){let t=e.authorBoundary<0||e.authorBoundary>e.totalSteps?e.totalSteps:e.authorBoundary;return{shrink_count:e.shrinkCount,complete_reauthor:t===0&&e.totalSteps>0,author_boundary:t,total_steps:e.totalSteps,reauthored_steps:e.totalSteps-t,credits_consumed:Math.round(e.creditsConsumed*100)/100}}var L=class e{constructor(t){this.opts=t}executionId;testId;definitionPath=null;definitionContent=null;accumulatedSteps=[];maxOrdinal=0;_attempts=[];_packDirOverride;_attached=!1;appiumMarks=We();get attached(){return this._attached}static async attach(t){let r=Kt(t.packDir).replace(/\.evidence$/,""),n=new e({origin:"testrun",runKind:"author",pid:process.pid,title:t.testId,started:new Date().toISOString(),producerVersion:ke,cwd:t.cwd});n.executionId=r,n.testId=t.testId,n._packDirOverride=t.packDir,n._attached=!0;let i=m(t.packDir,"tests",t.testId);return await v.mkdir(i,{recursive:!0}),t.definition&&(await v.writeFile(m(i,t.definition.path),t.definition.content),n.definitionPath=t.definition.path,n.definitionContent=t.definition.content),n}async start(){if(this._attached)throw new Error("attach-mode session is already started");this.executionId=B(),this.testId=this.opts.testmdRelPath?J(this.opts.testmdRelPath):X(this.opts.objectiveOrName??"session",this.opts.sessionId??this.executionId);let t=this.opts.definition??null;return await te({execution_id:this.executionId,title:this.opts.title,started:this.opts.started,producerVersion:this.opts.producerVersion,surfaces:this.opts.surfaces,run_kind:this.opts.runKind,origin:this.opts.origin,pid:this.opts.pid,...this.opts.credits!==void 0?{credits:this.opts.credits}:{}},this.testId,t,this.opts.cwd,this.opts.packRootDir?this.pack:void 0),t&&(this.definitionPath=t.path,this.definitionContent=t.content),{executionId:this.executionId,testId:this.testId,packTestDir:this.packTestDir}}get pack(){return this._packDirOverride?this._packDirOverride:this.opts.packRootDir?m(this.opts.packRootDir,`${this.executionId}.evidence`):_(this.executionId,this.opts.cwd)}get packTestDir(){return m(this.pack,"tests",this.testId)}async writeDefinition(t,r="test.md"){await v.writeFile(m(this.packTestDir,r),t),this.definitionPath=r,this.definitionContent=t}computeAssuranceId(){try{if(this.opts.testmdRelPath&&this.opts.cwd){let t=m(this.opts.cwd,this.opts.testmdRelPath);if(k(t))return Fe(Ht(t,"utf8"))?.id}}catch{}}computeDefinitionId(){try{if(this.opts.testmdRelPath&&this.opts.cwd){let t=m(this.opts.cwd,this.opts.testmdRelPath),r=m(this.opts.cwd,".context"),n=k(r)?O(r):void 0;if(k(t))return et(t,n)}if(this.definitionContent!=null)return j(this.definitionContent)}catch{}}noteSpawn(t){this.accumulatedSteps.push(...t.steps),this.maxOrdinal=Math.max(this.maxOrdinal,t.maxOrdinal)}nextOrdinalOffset(){return this.maxOrdinal}get steps(){return this.accumulatedSteps}get attempts(){return this._attempts}async archiveAttempt(t,r,n={}){let i=this._attempts.length+1,o=m(this.packTestDir,String(i)),s=n.log,a=(c,d)=>s?.("warn","ARCHIVE_ATTEMPT_FAILED",`Attempt ${i}: ${c} could not be archived into ${i}/; the next attempt will mingle with it`,{attempt:i,dir:c,error:String(d)}),u;try{await v.mkdir(o,{recursive:!0})}catch(c){a(`${i}/`,c)}for(let c of["steps","logs","v16-trajectory"]){let d=m(this.packTestDir,c);if(!k(d))continue;let p=m(o,c);try{await v.rename(d,p);continue}catch(l){s?.("warn","ARCHIVE_ATTEMPT_RENAME_FAILED",`Attempt ${i}: rename of ${c}/ refused; copying it into ${i}/ and emptying the originals in place`,{attempt:i,dir:c,error:String(l),fallback:"copy+truncate"})}try{await v.cp(d,p,{recursive:!0}),await tt(d)}catch(l){a(c,l)}}try{this.definitionPath&&k(m(this.packTestDir,this.definitionPath))&&await v.copyFile(m(this.packTestDir,this.definitionPath),m(o,this.definitionPath));let c=m(o,"steps");if(k(c)){for(let d of await v.readdir(c))if(k(m(c,d,"failure.yaml"))){u=`${i}/steps/${d}/failure.yaml`;break}}}catch(c){a("definition + failure pointer",c)}return this._attempts.push({n:i,status:t,steps:this.accumulatedSteps,...r!==void 0?{failedAt:r}:{},...u?{failure:u}:{}}),this.accumulatedSteps=[],this.maxOrdinal=0,i}async writeResult(t){let r=ue(t.spawns),n=this._attempts.length?[...this._attempts.map(g=>({status:g.status})),{status:r,...t.durationMs!==void 0?{duration_ms:t.durationMs}:{}}]:void 0,i=n?new Set(n.map(g=>g.status)).size>1:void 0,o=this._attempts.length>0,s=t.heal,a=o||s?.forced?{triggered:o,...o?{outcome:r==="passed"?"healed":"exhausted"}:{},...s?Yt(s):{},...o?{attempts:this._attempts.map(g=>({n:g.n,status:g.status,failed_at:g.failedAt??-1,...g.failure?{failure:g.failure}:{}}))}:{}}:void 0,u=this.pack,c=Q(t.externalIdInput),d=V(t.runnerEnv,t.intentEnv),p=this.computeDefinitionId(),l=this.computeAssuranceId();await se(u,this.testId,F({testId:this.testId,status:r,durationMs:t.durationMs,definitionPath:this.definitionPath,definitionId:p,assuranceId:l,externalId:c,environment:d,steps:t.steps,tags:t.tags,attempts:n,flaky:i,adaptiveHeal:a}));for(let g of this._attempts){let R=m(this.packTestDir,String(g.n));k(R)&&await v.writeFile(m(R,"result.yaml"),F({testId:this.testId,status:g.status,definitionPath:this.definitionPath,definitionId:p,assuranceId:l,externalId:c,environment:d,steps:g.steps,tags:t.tags}))}let f=t.externalIdInput;return t.log&&(f.commit_id||f.test_id||f.testcase_id)&&t.log("info","EVIDENCE_EXTERNAL_ID","Evidence external-id mapping",{execution_id:this.executionId,commit_id:f.commit_id??null,test_id:f.test_id??null,testcase_id:f.testcase_id??null,tc_id:c.tc_id??null,project_id:f.project_id??null,session_id:f.session_id??null,session_name:f.session_name??null,hyper_test_instance_id:c.hyper_test_instance_id??null,hyper_job_id:c.hyper_job_id??null,hyper_task_id:c.hyper_task_id??null,dataset_id:c.dataset_id??null,dataset_row_id:c.dataset_row_id??null,dataset_version_id:c.dataset_version_id??null}),r}get id(){return this.executionId}get test(){return this.testId}};async function qt(e,t,r=U){try{let n=await r(e);if(n.aborted.length>0||n.removed.length>0)try{t?.("info","EVIDENCE_RECOVERY","Startup evidence recovery swept incomplete packs",{aborted:n.aborted,removed:n.removed,origin:"startup"})}catch{}return n}catch(n){return console.warn("evidence: startup recovery failed",n),{aborted:[],removed:[]}}}import{promises as sr}from"fs";import{existsSync as _e,mkdirSync as Qt,readdirSync as er,readFileSync as tr,rmSync as rr,statSync as nr,writeFileSync as ir}from"fs";import{join as P}from"path";import{mkdirSync as Wt,renameSync as Gt,rmSync as Jt,writeFileSync as Xt}from"fs";import{join as rt}from"path";var Zt=5e6;function nt(e,t,r){let n=rt(e,"coverage","sources"),i=new Map,o=!1;try{for(let s of r.usecases)for(let a of s.sources){if(i.has(a.id)){a.file=i.get(a.id);continue}if(!a.cid)continue;let u=Te(t,a.cid);if(u===null||u.byteLength>Zt)continue;o||(Wt(n,{recursive:!0}),o=!0);let c=rt(n,a.id),d=`${c}.tmp-${process.pid}`;Xt(d,u),Gt(d,c);let p=`coverage/sources/${a.id}`;i.set(a.id,p),a.file=p}}catch{for(let s of r.usecases)for(let a of s.sources)delete a.file;if(o)try{Jt(n,{recursive:!0,force:!0})}catch{}}}var or={passed:"passed",failed:"failed",broken:"blocked",skipped:"not-run"},it=(e,t)=>{try{if(!_e(t))return{status:"skipped",reason:"no context store at the project root"};let r=P(e,"tests");if(!_e(r))return{status:"skipped",reason:"pack has no tests/"};let n=new Map;for(let a of er(r)){let u=P(r,a,"result.yaml");if(!_e(u)||!nr(P(r,a)).isDirectory())continue;let c=x(tr(u,"utf8"));if(!c?.definition_id&&!c?.assurance_id)continue;let d=Ve(c.steps??[]),p={testShortId:String(c.test??a),execution:or[String(c.status)]??"not-run",...d.length?{acs:d}:{}};c.assurance_id&&n.set(`id:${c.assurance_id}`,p),c.definition_id&&n.set(`def:${c.definition_id}`,p)}let i=$e(O(t),n,{scope:"run"}),o=Me(i);nt(e,t,i);let s=h({...i,rollup:o},{lineWidth:-1});return Qt(P(e,"coverage"),{recursive:!0}),ir(P(e,"coverage","usecases.yaml"),s),{status:"written"}}catch(r){try{rr(P(e,"coverage","sources"),{recursive:!0,force:!0})}catch{}return{status:"skipped",reason:r instanceof Error?r.message:String(r)}}};async function ar(e){try{let t=new L({origin:"inline",runKind:"author",pid:e.pid,title:e.title,started:new Date().toISOString(),producerVersion:e.producerVersion,surfaces:e.surfaces,objectiveOrName:e.objectiveOrName,sessionId:e.sessionId,cwd:e.cwd,packRootDir:e.packRootDir}),r=await t.start();return{session:t,...r,packDir:t.pack,spawns:[],startedAtMs:Date.now(),cwd:e.cwd}}catch(t){return console.warn("evidence: inline pack creation failed",t),null}}function cr(e,t,r){if(!e)return;e.session.noteSpawn(t),t.resolution&&(e.resolution=t.resolution),e.runnerEnvironment=Se(e.runnerEnvironment,t.runnerEnvironment);let n=(r?.per_flow_metadata??[]).map(i=>({resultCode:i?.result_code!=null?Number(i.result_code):null}));e.spawns.push({resultCode:r?.result_code!=null?Number(r.result_code):null,...n.length?{perFlow:n}:{}})}function ur(e){if(e)return{packTestDir:e.packTestDir,ordinalOffset:e.session.nextOrdinalOffset()}}async function dr(e,t){if(!e)return null;if(e.finalized)return e.finalized;let r=(n,i,o)=>t.log?t.log("warn",n,i,o):console.warn(`evidence: ${i}`,o??"");try{if(t.recordedTestPath)try{await e.session.writeDefinition(await sr.readFile(t.recordedTestPath,"utf8"))}catch(s){r("EVIDENCE_DEFINITION_FAILED","could not attach synthesized test.md",{error:String(s)})}let n=t.cdpBrowserCapture?await t.cdpBrowserCapture():void 0,i=await e.session.writeResult({steps:e.session.steps,spawns:e.spawns.length?e.spawns:[{resultCode:null}],externalIdInput:{...t.externalIdInput,execution_id:e.executionId},runnerEnv:ge({cdpBrowser:n,resolution:e.resolution,runnerEnvironment:e.runnerEnvironment,deviceName:t.deviceName,deviceModel:t.deviceModel,deviceApp:t.deviceApp,pixelResolution:await Le(e.packTestDir)}),intentEnv:Re(t.model,e.runnerEnvironment),durationMs:t.durationMs??Date.now()-e.startedAtMs,log:t.log});try{if(t.recordedTestPath){let s=Be({cwd:t.cwd??e.cwd??process.cwd(),members:[{path:t.recordedTestPath,verdict:i,executionId:e.executionId,startedAt:new Date(e.startedAtMs).toISOString(),mode:"inline",local:t.local??!1}]});for(let a of s.warnings)r("EXEC_SYNC",a)}}catch(s){r("EXEC_SYNC","exec-sync failed",{error:String(s)})}try{let s=(t.coverageWriter??it)(e.packDir,Ne(t.cwd??e.cwd??process.cwd()));s.status==="skipped"&&r("EVIDENCE_COVERAGE_SKIPPED",`coverage/usecases.yaml not written: ${s.reason}`)}catch(s){r("EVIDENCE_COVERAGE_SKIPPED","coverage writer threw",{error:String(s)})}let o=await fe({executionId:e.executionId,testId:e.testId,saved:t.saved,runKind:"author",verdict:i,cwd:t.cwd??e.cwd,packDir:e.packDir,tuiLogPath:t.tuiLogPath,log:t.log,surface:"inline",requireRealLog:!!e.runnerEnvironment?.native_platform,appiumMarks:e.session.appiumMarks});return e.finalized=o,t.log?.("info","EVIDENCE_SEALED","Inline pack sealed",{execution_id:e.executionId,verdict:i,valid:o.valid,pack:e.packDir,store_copy:o.storePath??null}),o}catch(n){return r("EVIDENCE_SEAL_FAILED","inline pack finalize failed",{error:String(n)}),null}}import{statSync as lr,openSync as pr,readSync as mr,closeSync as fr}from"fs";import{basename as gr,resolve as _r}from"path";async function vr(e,t,r={}){let n=r.out??(d=>process.stdout.write(d+`
|
|
5
5
|
`)),i=d=>(n(`error: ${d}`),2);if(t.env!=="prod"&&t.env!=="stage")return i(`invalid --env: ${String(t.env)}`);if(t.port!==void 0&&(!Number.isInteger(t.port)||t.port<1||t.port>65535))return i("invalid --port: expected an integer 1-65535");let o;try{o=C(t.env,t.viewerUrl),new URL(o)}catch{return i(`invalid --viewer-url: ${t.viewerUrl}`)}if(e.length===0)return i("no pack paths given");let s=new Map;for(let d of e){let p=_r(d),l;try{l=lr(p)}catch{return i(`${d}: not found`)}if(l.isDirectory())return i(`${d}: is a directory \u2014 packs must be sealed .evidence files (run the execution to completion, or seal it, first)`);if(!l.isFile())return i(`${d}: not a regular file`);let f=Buffer.alloc(2),g=pr(p,"r");try{mr(g,f,0,2,0)}finally{fr(g)}if(f.toString("latin1")!=="PK")return i(`${d}: not a sealed evidence pack (zip magic missing)`);let R=gr(p);if(s.has(R))return i(`duplicate pack basename: ${R} (URL names collide \u2014 rename one)`);s.set(R,p)}let a=r.log??((d,p,l)=>process.stderr.write(`warn: ${p} reason=${l.reason} path=${l.path}
|
|
6
|
-
`)),u;try{u=await H({packs:s,allowedOrigins:[new URL(o).origin],port:t.port,log:a})}catch(d){return i(`could not bind 127.0.0.1${t.port?`:${t.port}`:""} \u2014 ${d.message}`)}n(`serving ${s.size} pack${s.size===1?"":"s"} on http://127.0.0.1:${u.port}`);for(let d of s.keys()){let p=u.urlFor(d);n(d),n(` pack ${p}`),n(` viewer ${K(p,o)}`)}return n("press Ctrl-C to stop"),await(r.hold??hr)(),await u.close(),0}function hr(){return new Promise(e=>{let t=process.listeners("SIGINT");process.removeAllListeners("SIGINT"),process.once("SIGINT",()=>{for(let r of t)process.on("SIGINT",r);e()})})}import{promises as T}from"fs";import{tmpdir as kr}from"os";import{join as at,resolve as he}from"path";var wr=["error","prefer_first","prefer_latest","discard"],yr=["external_id.commit_id","external_id.test_id","external_id.dataset_row_id","environment.os","environment.os_version","environment.browser","environment.browser_version","environment.device","environment.app"];function ot(e){let t=e.replace(/-/g,"_");return wr.includes(t)?t:null}function st(e){let t=e==="discard"?{on_collision:"discard"}:{on_collision:"error",identity:{keys:[...yr],on_same:e??"nest",on_different:e?"error":"split"}};return h({packs:{require_status:"finalized",require_valid:"L1",on_ineligible:"abort"},tests:t,rules:[{file:"run.yaml",key:"run_id",must:"different",on_violation:"skip"},{file:"result.yaml",key:"external_id.project_id",must:"same",on_violation:"error"},{file:"result.yaml",key:"external_id.org_id",must:"same",on_violation:"error"}]},{lineWidth:-1})}async function ve(e){try{if(!e.isTTY){e.log(Y(e.packPath));return}let t=C(e.env);await(e.renderPrompt??br)(e.packPath,t)}catch(t){try{e.log(`evidence view failed \u2014 ${t.message}`)}catch{}}}async function br(e,t){let r=await import("./react-QWOAB3TB.js"),{render:n}=await import("./build-JIKYOZUH.js"),{EvidenceViewOffer:i}=await import("./EvidenceViewOffer-
|
|
6
|
+
`)),u;try{u=await H({packs:s,allowedOrigins:[new URL(o).origin],port:t.port,log:a})}catch(d){return i(`could not bind 127.0.0.1${t.port?`:${t.port}`:""} \u2014 ${d.message}`)}n(`serving ${s.size} pack${s.size===1?"":"s"} on http://127.0.0.1:${u.port}`);for(let d of s.keys()){let p=u.urlFor(d);n(d),n(` pack ${p}`),n(` viewer ${K(p,o)}`)}return n("press Ctrl-C to stop"),await(r.hold??hr)(),await u.close(),0}function hr(){return new Promise(e=>{let t=process.listeners("SIGINT");process.removeAllListeners("SIGINT"),process.once("SIGINT",()=>{for(let r of t)process.on("SIGINT",r);e()})})}import{promises as T}from"fs";import{tmpdir as kr}from"os";import{join as at,resolve as he}from"path";var wr=["error","prefer_first","prefer_latest","discard"],yr=["external_id.commit_id","external_id.test_id","external_id.dataset_row_id","environment.os","environment.os_version","environment.browser","environment.browser_version","environment.device","environment.app"];function ot(e){let t=e.replace(/-/g,"_");return wr.includes(t)?t:null}function st(e){let t=e==="discard"?{on_collision:"discard"}:{on_collision:"error",identity:{keys:[...yr],on_same:e??"nest",on_different:e?"error":"split"}};return h({packs:{require_status:"finalized",require_valid:"L1",on_ineligible:"abort"},tests:t,rules:[{file:"run.yaml",key:"run_id",must:"different",on_violation:"skip"},{file:"result.yaml",key:"external_id.project_id",must:"same",on_violation:"error"},{file:"result.yaml",key:"external_id.org_id",must:"same",on_violation:"error"}]},{lineWidth:-1})}async function ve(e){try{if(!e.isTTY){e.log(Y(e.packPath));return}let t=C(e.env);await(e.renderPrompt??br)(e.packPath,t)}catch(t){try{e.log(`evidence view failed \u2014 ${t.message}`)}catch{}}}async function br(e,t){let r=await import("./react-QWOAB3TB.js"),{render:n}=await import("./build-JIKYOZUH.js"),{EvidenceViewOffer:i}=await import("./EvidenceViewOffer-25IQF3TX.js");await new Promise(o=>{let s=n(r.default.createElement(i,{packPath:e,viewerBase:t,onDone:()=>{s.unmount(),o()}}),{stdout:process.stderr,exitOnCtrlC:!1})})}async function xr(e,t,r=process.cwd(),n={}){let i=n.out??(l=>process.stdout.write(l+`
|
|
7
7
|
`)),o=n.err??(l=>process.stderr.write(l+`
|
|
8
8
|
`)),s=l=>(o(`evidence merge: ${l}`),2);if(!t.runId)return s("--run-id is required (merged identity is the caller's fact)");if(t.rules&&t.onCollision)return s("--rules and --on-collision are mutually exclusive");let a;if(t.onCollision!==void 0){let l=ot(t.onCollision);if(!l)return s(`invalid --on-collision: ${t.onCollision} (expected error | prefer-first | prefer-latest | discard)`);a=l}let u=[];for(let l of e){let f=await Ir(l,r);if(!f)return s(`no pack found for "${l}"`);u.push(f)}let c=t.out?he(r,t.out):_(t.runId,r),d=null,p;t.rules?p=he(r,t.rules):(d=await T.mkdtemp(at(kr(),"kane-merge-rules-")),p=at(d,"merge-rules.yaml"),await T.writeFile(p,st(a)));try{let l=await(n.mergeFn??Pe)(u,{runId:t.runId,out:c,rulesPath:p,title:t.title,finalize:t.finalize});return t.json?i(JSON.stringify(l)):Sr(i,l),l.output.finalized&&!t.json&&await(n.offer??ve)({packPath:c,env:t.env,isTTY:n.isTTY??(!!process.stdin.isTTY&&!!process.stderr.isTTY),log:o}),0}catch(l){let f=l instanceof Error?l.message:String(l);return l?.code==="ABORT"?(o(`evidence merge: aborted \u2014 ${f}`),1):s(f)}finally{d&&await T.rm(d,{recursive:!0,force:!0}).catch(()=>{})}}async function Ir(e,t){let r=he(t,e);if(await ct(r))return r;let n=_(e,t);return await ct(n)?n:null}async function ct(e){try{return await T.stat(e),!0}catch{return!1}}function Sr(e,t){let{packs:r,tests:n,output:i}=t;e(`evidence: merged ${n.merged} tests from ${r.eligible.length} packs -> ${i.path} (${i.finalized?"sealed":"live"})`);for(let o of r.skipped)e(` skipped ${o.runId}: ${o.rule} \u2014 ${o.reason}`);for(let o of n.collisions){let s;o.action==="nest"?s=`nested into ${o.folder}, latest ${o.winner}`:o.action==="split"?s=`split into ${o.folder}`:s=`winner ${o.winner}`,e(` collision ${o.test}: ${s} (${o.rule})`)}for(let o of n.discarded)e(` discarded ${o}`)}import{copyFileSync as Er,existsSync as we,mkdirSync as Rr}from"fs";import{join as ut}from"path";function Pr(e,t,r){try{let n=ut(e,"auteur","execution.json");if(we(n))return!0;for(let i of t)if(!(!i||!we(i)))return Rr(ut(e,"auteur"),{recursive:!0}),Er(i,n),!0}catch(n){try{r?.("debug","EVIDENCE_BLOB_COPY_FAILED","auteur execution blob copy failed",{operation:"ensureAuteurExecution",source:t.find(i=>i&&we(i))??null,error:n instanceof Error?n.message:String(n)})}catch{}}return!1}import{mkdirSync as Ar,writeFileSync as Dr}from"fs";import{join as dt}from"path";function Cr(e,t,r){try{return Ar(dt(e,"auteur"),{recursive:!0}),Dr(dt(e,"auteur","dataset.json"),JSON.stringify(t,null,2)+`
|
|
9
9
|
`,"utf8"),!0}catch(n){try{r?.("debug","EVIDENCE_DATASET_WRITE_FAILED","auteur dataset record write failed",{dataset_id:t.dataset_id,error:n instanceof Error?n.message:String(n)})}catch{}}return!1}import{readFileSync as Lr}from"fs";import{join as jr}from"path";var lt="module_block";var Or=new Set(["generative_block",lt]);function be(e){let t=[],r=!0,n=o=>{if(o===null||typeof o!="object")return;let s=o;if(Array.isArray(s.operations))for(let a of s.operations){let u=a?.operation_id;typeof u=="string"&&u&&t.push(u)}if(Array.isArray(s.children)){Or.has(s.content_type)||(r=!1);for(let a of s.children)n(a)}if(Array.isArray(s.branches)){r=!1;for(let a of s.branches){let u=a?.children;if(Array.isArray(u))for(let c of u)n(c)}}},i=e?.instructions;if(Array.isArray(i))for(let o of i)n(o);return{ids:t,linear:r}}function Fr(e){return be(e).ids}function ye(e,t){let r=new Set(t.map(a=>a.action_id).filter(Boolean)),n=-1;for(let a of r){let u=e.indexOf(a);u>n&&(n=u)}let i=t.reduce((a,u)=>Math.max(a,u.ordinal),0),o=new Set,s=[];for(let a of e.slice(n+1))r.has(a)||o.has(a)||(o.add(a),s.push({id:a,ordinal:++i,status:"skipped",action_id:a}));return s}function pt(e,t){let r=new Set(t),n=e.filter(o=>o.action_id);if(n.some(o=>r.has(o.action_id))||n.length>t.length)return null;let i=0;return e.map(o=>o.action_id?{...o,action_id:t[i++]}:o)}function Mr(e,t){if(e.length>t.length)return!1;for(let r=0;r<e.length;r++)if(t[r]!==e[r].action_id)return!1;return!0}function $r(e,t,r,n=!0){if(t.length===0)return{steps:e,tail:[]};let i=(r&&n?pt(e,t):null)??e,o=i.filter(a=>a.action_id),s=new Set(t);return o.length>0&&o.every(a=>s.has(a.action_id))?{steps:i,tail:ye(t,i)}:o.length>0&&!Mr(o,t)?{steps:i,tail:[],unjoined:!0}:{steps:i,tail:ye(t,i)}}function mt(e){try{let t=Lr(jr(e,"auteur","execution.json"),"utf8");return be(JSON.parse(t))}catch{return{ids:[],linear:!0}}}function Tr(e){return mt(e).ids}export{S as a,q as b,W as c,G as d,J as e,X as f,ze as g,Q as h,_t as i,ee as j,te as k,vt as l,ht as m,re as n,F as o,oe as p,se as q,ae as r,ce as s,wt as t,yt as u,ue as v,bt as w,de as x,le as y,pe as z,Je as A,fe as B,ge as C,Qe as D,Vt as E,L as F,qt as G,it as H,ar as I,cr as J,ur as K,dr as L,vr as M,st as N,ve as O,xr as P,Pr as Q,Cr as R,lt as S,be as T,Fr as U,ye as V,pt as W,$r as X,mt as Y,Tr as Z};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as g}from"./chunk-2KVECC36.js";import{b as f,c as j}from"./chunk-VE3SUJMA.js";import{a as m}from"./chunk-
|
|
2
|
+
import{a as g}from"./chunk-2KVECC36.js";import{b as f,c as j}from"./chunk-VE3SUJMA.js";import{a as m}from"./chunk-DUYRCVI5.js";var _="KaneAI Generated",E="Untitled";async function p(e){let r=e.config.load(),d=new g(m(e.env).tmsBaseUrl,e.tmsCreds.username,e.tmsCreds.access_key),n=e.projectName??_,o=e.folderName??E,t=r.project_id??null,s=r.project_name??null;if(!t){let a=(await d.listProjects()).find(l=>l.name===n);if(a)t=a.project_id,s=a.name,e.log("info","ENSURE_PROJECT_FOUND","Found default project",{project_id:t,name:s});else{let l=await d.createProject(n);t=l.id,s=l.name,e.log("info","ENSURE_PROJECT_CREATED","Created default project",{project_id:t,name:s})}f(e.creds,e.config,e.profile,e.env,{projectId:t,projectName:s})}let c=r.folder_id??null,i=r.folder_name??null,u=!r.project_id;if(!c||u){let a=(await d.listFolders(t)).find(l=>l.name===o);if(a)c=a.id,i=a.name,e.log("info","ENSURE_FOLDER_FOUND","Found default folder",{folder_id:c,name:i});else{let l=await d.createFolder(t,o);c=l.id,i=l.name,e.log("info","ENSURE_FOLDER_CREATED","Created default folder",{folder_id:c,name:i})}f(e.creds,e.config,e.profile,e.env,{folderId:c,folderName:i})}return{projectId:t,projectName:s??n,folderId:c,folderName:i??o}}function A(e,r,d){let n=e.loadProfileConfig(r,d)??{};return{projectId:n.project_id??null,folderId:n.folder_id??null}}function N(e,r){return e.projectId===null||e.folderId===null||r===null?"needs-picker":r.project==="ok"&&r.folder==="ok"?"ok":r.project==="error"&&r.folder==="error"?"ok-tms-degraded":"needs-picker"}var k=(e,r)=>`error: profile "${e}" (${r}) has no project/folder configured AND no TMS credentials were available to auto-configure one.
|
|
3
3
|
|
|
4
4
|
discover IDs:
|
|
5
5
|
kane-cli projects list --search "<keyword>" --limit 10
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as d,g as B,k as ee}from"./chunk-YLQHY4A7.js";import{P as Z}from"./chunk-RDHWNSDP.js";import{b as A}from"./chunk-
|
|
2
|
+
import{a as d,g as B,k as ee}from"./chunk-YLQHY4A7.js";import{P as Z}from"./chunk-RDHWNSDP.js";import{b as A}from"./chunk-CXF6AZWY.js";import{createHash as Ie,randomBytes as F}from"crypto";import{mkdirSync as xe,mkdtempSync as P,rmSync as $,existsSync as ve,renameSync as ke}from"fs";import{tmpdir as j}from"os";import{join as _,dirname as ce}from"path";import{spawn as te}from"child_process";function N(n,e=process.env){let t=n.replace(/https?:\/\/[^\s/@]+:[^\s/@]+@/gi,"https://[redacted]@").replace(/(authorization\s*[:=])[^\r\n]+/gi,"$1 [redacted]"),r=e.KANE_SYNC_GIT_TOKEN;if(r)for(let i of[r,Buffer.from(`x-access-token:${r}`).toString("base64")])t=t.split(i).join("[redacted]");return t}function be(n,e){if(n.GIT_SSH_COMMAND)return re(n.GIT_SSH_COMMAND);if(!n.GIT_SSH)return e?re(e):"ssh -o BatchMode=yes"}function re(n){return/(^|\s)-o\s*BatchMode=yes(\s|$)/.test(n)?n:`${n} -o BatchMode=yes`}var _e=/^(?:ssh:\/\/|[^/\s@:]+@[^/\s:]+:)/i,ie=new Map;function Ae(n,e){let t=[e??"",n.GIT_CONFIG_GLOBAL??"",n.HOME??""].join("\0"),r=ie.get(t);return r===void 0&&(r=se(["config","--get","core.sshCommand"],n,e,12e4).then(i=>i.code===0&&i.stdout.toString().trim()||void 0,()=>{}),ie.set(t,r)),r}var ne=new Set(["fetch","push","clone","ls-remote"]);function Ce(n,e,t){if(t!==void 0)return t;if(!n.some(i=>ne.has(i)))return 12e4;let r=e.KANE_SYNC_GIT_TRANSFER_TIMEOUT_SECONDS;if(r!==void 0){if(!/^\d+$/.test(r)||Number(r)<60||Number(r)>3600)throw new Error("KANE_SYNC_GIT_TRANSFER_TIMEOUT_SECONDS must be 60 to 3600");return Number(r)*1e3}return 9e5}function Ne(n){if(n.some(t=>/^(--force(?:-with-lease|-if-includes)?(?:=|$)|--mirror(?:=|$)|--delete(?:=|$)|-f$)/.test(t)))throw new Error("Git location cannot force, mirror or delete");let e=n.indexOf("push");if(e>=0){let t=n.slice(e+1);if(t.length!==3||t[0]!=="--porcelain"||!/^[0-9a-f]{40,64}:refs\/(heads|kane\/probe)\/[A-Za-z0-9._/-]+$/.test(t[2]))throw new Error("Git location requires an exact commit SHA and explicit ref")}}var H=async(n,e={})=>{Ne(n);let t={...process.env,...e.env};for(let h of["GIT_DIR","GIT_WORK_TREE","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_CONFIG_PARAMETERS"])delete t[h];e.env?.GIT_INDEX_FILE&&(t.GIT_INDEX_FILE=e.env.GIT_INDEX_FILE);let r=[["core.autocrlf","false"],["core.eol","lf"],["core.symlinks","false"],["core.hooksPath","/dev/null"],["gc.autoDetach","false"],["gc.pruneExpire","3.days.ago"],["maintenance.auto","false"],["push.followTags","false"],["push.gpgSign","false"],["commit.gpgSign","false"]],i=t.KANE_SYNC_GIT_HTTP_POST_BUFFER;if(i!==void 0){if(!/^\d+$/.test(i)||Number(i)<1048576||Number(i)>536870912)throw new Error("KANE_SYNC_GIT_HTTP_POST_BUFFER must be 1048576 to 536870912 bytes; use it only for a proxy that rejects chunked uploads");r.push(["http.postBuffer",i])}for(let h of Object.keys(t))h.startsWith("GIT_TRACE")&&delete t[h];let s=n.find(h=>h.startsWith("https://"));if(t.KANE_SYNC_GIT_TOKEN&&s){let h=new URL(s);r.push([`http.${h.origin}${h.pathname}.extraheader`,""],[`http.${h.origin}${h.pathname}.extraheader`,`AUTHORIZATION: basic ${Buffer.from(`x-access-token:${t.KANE_SYNC_GIT_TOKEN}`).toString("base64")}`],["credential.helper",""])}for(let h of Object.keys(t))/^GIT_CONFIG_(COUNT|KEY_\d+|VALUE_\d+)$/.test(h)&&delete t[h];let a=!t.GIT_SSH_COMMAND&&!t.GIT_SSH&&n.some(h=>ne.has(h))&&n.some(h=>_e.test(h))?await Ae({...t},e.cwd):void 0;r.forEach(([h,u],g)=>{t[`GIT_CONFIG_KEY_${g}`]=h,t[`GIT_CONFIG_VALUE_${g}`]=u}),t.GIT_CONFIG_COUNT=String(r.length),t.GIT_TERMINAL_PROMPT="0",t.GCM_INTERACTIVE="never",t.GIT_ASKPASS="",t.SSH_ASKPASS="";let c=be(t,a);return c!==void 0&&(t.GIT_SSH_COMMAND=c),t.GIT_NO_REPLACE_OBJECTS="1",se(n,t,e.cwd,Ce(n,t,e.timeout),e.input)};function se(n,e,t,r,i){return new Promise((s,o)=>{let a=te("git",n,{cwd:t,env:e,windowsHide:!0,detached:process.platform!=="win32",stdio:["pipe","pipe","pipe"]}),c=[],h=0,u="",g=!1,w=()=>{if(process.platform==="win32"&&a.pid)te("taskkill",["/pid",String(a.pid),"/t","/f"],{windowsHide:!0,stdio:"ignore"}).on("error",()=>a.kill("SIGKILL"));else try{a.pid&&process.kill(-a.pid,"SIGKILL")}catch{a.kill("SIGKILL")}},S=setTimeout(()=>{g=!0,w()},r);a.stdout.on("data",l=>{h+=l.length,h>128*1024*1024?w():c.push(l)}),a.stderr.on("data",l=>{u.length<64e3&&(u+=l.toString())}),a.stdin.on("error",()=>{}),a.on("error",l=>{clearTimeout(S),o(new d("SYNC_GIT_REQUIRED",`Git could not start: ${N(l.message,e)}`,"Install Git 2.31 or newer, then run the command again: https://git-scm.com/downloads"))}),a.on("close",l=>{clearTimeout(S),s({code:g||h>128*1024*1024?124:l??1,stdout:Buffer.concat(c),stderr:N(g?"Git operation timed out":u,e)})}),a.stdin.end(i)})}async function oe(n=H){let e=await n(["--version"],{timeout:1e4}),t=/git version (\d+)\.(\d+)/.exec(e.stdout.toString());if(e.code||!t||+t[1]<2||+t[1]==2&&+t[2]<31)throw new d("SYNC_GIT_REQUIRED","This location needs Git 2.31 or newer.","Install or update Git, then run setup again: https://git-scm.com/downloads")}function ae(n){let e=/^([^/@:]+)@([^/:]+):/.exec(n);if(e)return{user:e[1],host:e[2]};try{let t=new URL(n);return{host:t.hostname||"the server",user:t.username||"git",port:t.port||void 0}}catch{return{host:"the server",user:"git"}}}function gt(n){let e=/^[^/@:]+@([^/:]+):/.exec(n);if(e)return e[1].toLowerCase();try{return new URL(n).hostname.toLowerCase()}catch{return""}}function Y(n,e){let{host:t,user:r,port:i}=ae(e),s=N(n).trim().split(`
|
|
3
3
|
`).slice(-2).join(" ").trim();return/Host key verification failed|REMOTE HOST IDENTIFICATION HAS CHANGED/i.test(n)?{code:"SYNC_LOCATION_DENIED",message:`this computer has not accepted ${t}'s SSH host key yet`,remedy:`in a terminal run: ssh -T ${i?`-p ${i} `:""}${r}@${t} and answer yes, then run the command again`,diagnostic:s}:/Permission denied \(publickey/i.test(n)?{code:"SYNC_LOCATION_DENIED",message:`${t} did not accept your SSH key`,remedy:"load it with ssh-add, or ask the repository owner to grant your account access",diagnostic:s}:/could not read Username|Authentication failed|Access denied|Invalid username or (password|token)|returned error: 401|returned error: 403/i.test(n)?{code:"SYNC_LOCATION_DENIED",message:`sign in is needed, or your account has no access to this repository on ${t}`,remedy:"sign in through Git, or ask the owner to grant your account access",diagnostic:s}:/Could not resolve host|Connection refused|Connection timed out|timed out|Network is unreachable|Failed to connect/i.test(n)?{code:"SYNC_LOCATION_UNREACHABLE",message:`${t} could not be reached`,remedy:"check the address and your network, then run the command again",diagnostic:s}:/not found|does not appear to be a git repository|Repository not found/i.test(n)?{code:"SYNC_LOCATION_UNREACHABLE",message:"no repository answered at that address, or your account cannot see it; a private repository looks missing until access is granted",remedy:"check the address, then run the command again",diagnostic:s}:{code:"SYNC_LOCATION_UNREACHABLE",message:`git could not read the repository on ${t}`,remedy:"check the address and your access, then run the command again",...s?{diagnostic:s}:{}}}function M(n,e){return(n.startsWith(e)?n:n.charAt(0).toUpperCase()+n.slice(1))+"."}function yt(n,e){let t=Y(n,e),{host:r}=ae(e),i=t.remedy.replace(/,? ?(and )?then run the command again$/,"");return i?`${M(t.message,r)} ${M(i,r)}`:M(t.message,r)}var Oe=Buffer.from(`* -text -filter -ident -working-tree-encoding
|
|
4
4
|
`),Re="refs/kane/tip",Pe=/unexpected disconnect|hung up unexpectedly|Connection reset|Connection timed out|timed out|Could not resolve host|Failed to connect|RPC failed|Broken pipe|early EOF/i,$e={GIT_AUTHOR_NAME:"kane-cli context",GIT_AUTHOR_EMAIL:"context@kane-cli.invalid",GIT_COMMITTER_NAME:"kane-cli context",GIT_COMMITTER_EMAIL:"context@kane-cli.invalid"},G=class n{constructor(e){this.options=e;this.exec=e.exec??H,this.prefix=e.prefix?`${e.prefix}/`:"";let t=Ie("sha256").update(JSON.stringify([e.url,e.branch,this.prefix])).digest("hex");if(this.repo=_(e.cacheDir??_(A,"context-sync","mirrors"),`${t}.git`),this.ref=e.ref??`refs/heads/${e.branch}`,!/^refs\/(heads|kane\/probe)\/[A-Za-z0-9][A-Za-z0-9._/-]*$/.test(this.ref)||this.ref.includes(".."))throw new Error("Invalid Git location ref")}kind="git";contractVersion=1;ceilingTier=1;exec;repo;ref;prefix;ready;tip=null;tree=new Map;async run(e,t={}){let r=await this.exec(["--git-dir",this.repo,...e],t);if(r.code)throw new Error(`Git ${e[0]} failed: ${r.stderr||"unable to read the location"}`);return r.stdout}async transfer(e){let t=await this.exec(["--git-dir",this.repo,...e]);if(t.code){let r=Y(t.stderr||"",this.options.url);throw new d(r.code,r.message,r.remedy,r.diagnostic)}return t.stdout}get name(){return this.options.name??"<name>"}takenRemedy(e){return e===1?`${this.name} holds a different history: to work on it, clone it with kane-cli context clone <descriptor of ${this.name}> <dir>; to share this store, add an empty location`:`kane-cli context pull ${this.name} --rebase`}init(){return this.ready??=(async()=>{if(await oe(this.exec),xe(ce(this.repo),{recursive:!0}),!ve(this.repo)){let e=P(_(ce(this.repo),".init-"));try{let t=await this.exec(["init","--bare",e]);if(t.code)throw new Error(`Cannot open Git cache: ${t.stderr}`);try{ke(e,this.repo)}catch(r){if(!["EEXIST","ENOTEMPTY"].includes(r.code??""))throw r}}finally{$(e,{recursive:!0,force:!0})}}if((await this.run(["rev-parse","--is-bare-repository"])).toString().trim()!=="true")throw new Error("The Git cache must be a bare repository");await this.refresh()})()}async refresh(){let t=(await this.transfer(["ls-remote",this.options.url,this.ref])).toString().trim();if(!t){this.tip=null,this.tree=new Map;return}let r=t.split(/\s+/)[0];if(!/^[0-9a-f]{40,64}$/.test(r))throw new Error("Git returned an invalid ref");if(r===this.tip)return;let i=`refs/kane/snapshots/${F(16).toString("hex")}`;await this.transfer(["fetch","--no-tags","--no-write-fetch-head",this.options.url,`${this.ref}:${i}`]);let s=(await this.run(["rev-parse",i])).toString().trim();await this.run(["update-ref",Re,s]),await this.run(["update-ref","-d",i]);let o=await this.readTree(s);this.tip=s,this.tree=o}contextKeys(e){let t=new Map;for(let[r,i]of e)r.startsWith(`${this.prefix}kane-context/`)&&t.set(r,i);return t}async readTree(e){let t=await this.run(["ls-tree","-rz","--full-tree",e]),r=new Map;for(let i of t.toString().split("\0").filter(Boolean)){let s=/^(\d+) (\w+) ([0-9a-f]+)\t([\s\S]+)$/.exec(i);if(!s)throw new Error("Git returned an invalid tree entry");if(s[4].startsWith(`${this.prefix}kane-context/`)&&(s[1]!=="100644"||s[2]!=="blob"))throw new d("SYNC_OBJECT_CORRUPT","Context storage contains a link or non-file object.","Ask the repository owner to restore the original context files.");r.set(s[4],s[3])}return r}key(e){if(!/^[a-zA-Z0-9_~./-]+$/.test(e)||e.split("/").some(t=>!t||t==="."||t===".."||t.toLowerCase()===".git"))throw new Error("Invalid context storage key");return this.prefix+e}async head(e){return await this.init(),this.tree.has(this.key(e))}async get(e){await this.init();let t=this.tree.get(this.key(e));return t?this.run(["cat-file","blob",t]):null}async list(e){return await this.init(),e&&e.replace(/\/$/,"")&&this.key(e.replace(/\/$/,"")),[...this.tree.keys()].filter(t=>t.startsWith(this.prefix+e)).map(t=>t.slice(this.prefix.length)).sort()}async beginTransaction(){await this.init();let e=new Map(this.tree),t=this.tip,r=new Map,i=!1,s=()=>{if(i)throw new Error("Git transaction is closed")},o=async a=>{s();let c=this.key(a),h=r.get(c),u=e.get(c);return h?Buffer.from(h):u?this.run(["cat-file","blob",u]):null};return{get:o,head:async a=>await o(a)!==null,stageIfAbsent:async(a,c)=>{s();let h=this.key(a);if(e.has(h)||r.has(h))return"exists";if(c.length>1e8)throw new d("SYNC_LOCATION_REFUSED_WRITE","A context object is too large for this Git location.","Use an S3 location for this context.");return r.set(h,Buffer.from(c)),"staged"},abort:async()=>{i=!0,r.clear()},commit:async()=>{s();try{if(!r.size)return{created:[]};let a=this.prefix+"kane-context/.gitattributes";e.has(a)||r.set(a,Oe);let c=new Map;for(let[l,m]of r)c.set(l,(await this.run(["hash-object","-w","--no-filters","--stdin"],{input:m})).toString().trim());let h=this.contextKeys(e),u=()=>{this.assertUnchanged(h);for(let[l,m]of this.contextKeys(this.tree))h.set(l,m)},g=!1,w="",S=0;for(let l=0;l<4;l++){u();for(let f of this.tree.keys())if(!(!f.startsWith(this.prefix)||e.has(f)||c.has(f))&&B(f.slice(this.prefix.length))!==null)throw new d("SYNC_BEHIND","the location gained records after this batch was prepared; nothing was published","run kane-cli context pull, then push again");let m=new Map;for(let[f,T]of c){let C=this.tree.get(f);if(C&&C!==T){let R=B(f.slice(this.prefix.length));throw R?new d("SYNC_POSITION_TAKEN",g?`position ${R} on ${this.name} now holds different work; an earlier publication could not be confirmed`:`position ${R} on ${this.name} was published by another writer; this batch was not published`,this.takenRemedy(R)):new d("SYNC_OBJECT_CORRUPT",`existing context object ${f} differs from the intended bytes`,"the object needs a person to look; nothing was published")}C||m.set(f,T)}if(!m.size)return await this.verifyPublication(c),{created:[]};t=this.tip;let I=await this.build(t,m);await this.checkAttributes(I,[...r.keys()]),S++;let E=await this.exec(["--git-dir",this.repo,"push","--porcelain",this.options.url,`${I}:${this.ref}`]),y=N(E.stdout.toString()+`
|
|
5
5
|
`+E.stderr);w=y.trim();let O=E.code!==0&&/\[rejected\]|\[remote rejected\]/.test(y),p=E.code!==0&&(E.code===124||Pe.test(y));g||=p;try{await this.refresh()}catch{throw new d("SYNC_PUBLICATION_UNKNOWN","we could not confirm whether your context was uploaded; your local work is safe","check the connection and retry; kane-cli compares the published data before writing again")}if(u(),[...c].every(([f,T])=>this.tree.get(f)===T)){await this.verifyPublication(c);let f=E.code===0&&!E.stdout.toString().split(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as f}from"./chunk-
|
|
2
|
+
import{a as f}from"./chunk-CSVPZ33X.js";import{y as r}from"./chunk-CXF6AZWY.js";import{a as g}from"./chunk-HCBYKLMW.js";import{a as i,b as n,i as p}from"./chunk-C44QQJR4.js";import{a as x}from"./chunk-6YGTRKDT.js";import{e as d}from"./chunk-UR6MHSHU.js";var b=d(x(),1);var e=d(g(),1),v=[{value:"desktop",label:"Desktop",hint:"Chrome on this machine"},{value:"emulator",label:"Emulator",hint:"a virtual Android device"},{value:"simulator",label:"Simulator",hint:"a virtual iOS device"}];function T(a){return a==="all"?v:v.filter(l=>l.value!=="desktop")}function B({mode:a="all",onSelect:l,onCancel:c}){let u=T(a),[h,m]=(0,b.useState)(0);return p((s,o)=>{if(o.escape&&c){c();return}o.upArrow&&m(t=>Math.max(0,t-1)),o.downArrow&&m(t=>Math.min(u.length-1,t+1)),o.return&&l(u[h].value)}),(0,e.jsxs)(i,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(n,{color:r.orange,bold:!0,children:a==="all"?"Where should tests run?":"Which kind of device?"}),(0,e.jsx)(i,{marginTop:1,flexDirection:"column",children:u.map((s,o)=>{let t=o===h;return(0,e.jsxs)(i,{children:[(0,e.jsxs)(n,{color:t?r.orange:void 0,children:[t?"\u276F ":" ",s.label]}),(0,e.jsxs)(n,{color:r.dim,children:[" ",s.hint]})]},s.value)})}),(0,e.jsx)(i,{marginTop:1,children:(0,e.jsx)(n,{color:r.dim,children:"You can change this any time with /desktop or /mobile."})}),(0,e.jsx)(f,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],suppressEscBack:!c,escBackLabel:"skip"})]})}export{B as a};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as W,c as Z}from"./chunk-W3USRQX6.js";import{S as Y}from"./chunk-
|
|
2
|
+
import{b as W,c as Z}from"./chunk-W3USRQX6.js";import{S as Y}from"./chunk-URWWROLS.js";import{b as X}from"./chunk-5GUD3CIH.js";import{a as J}from"./chunk-JQ64X2TO.js";import{a as Pt,b as k}from"./chunk-NBXYL2JT.js";import{a as H}from"./chunk-2KVECC36.js";import{a as K}from"./chunk-DHJSM5DT.js";import{a as G}from"./chunk-NLCCBXXV.js";import{a as R}from"./chunk-RZ4F3BHX.js";import{e as Rt}from"./chunk-UR6MHSHU.js";import{readFileSync as T,existsSync as V,readdirSync as le,mkdirSync as q,writeFileSync as w}from"fs";import{readFile as kt,unlink as de}from"fs/promises";import{join as y}from"path";import{existsSync as ee,mkdirSync as ne,readdirSync as bt,writeFileSync as re}from"fs";import{join as S}from"path";import{randomUUID as A}from"crypto";var tt=["children","instructions","branches","module_content","true_branch","false_branch"];function D(e){let t=new Map,n=i=>{if(!i||typeof i!="object")return;let o=i;if(Array.isArray(o.operations))for(let r of o.operations){let s=r.operation_id;if(typeof s!="string"||!s)continue;let a=t.get(s)??[];a.includes(o)||a.push(o),t.set(s,a)}for(let r of tt){let s=o[r];Array.isArray(s)?s.forEach(n):s&&typeof s=="object"&&n(s)}};return e.forEach(n),t}function St(e,t){if(!t||t.length===0)return;if(t.length===1)return t[0];let n=e.action_params?.script;if(typeof n=="string"&&n.trim()){let i=n.trim(),o=t.find(r=>wt(r)?.trim()===i);if(o)return o}return t[0]}function wt(e){let t=e,n=t.script_content??t.js_snippet;return typeof n=="string"?n:void 0}function U(e,t){let n=new Map;for(let i of e){let o=St(i,i.action_id?t.get(i.action_id):void 0);if(!o)continue;let r=n.get(o)??[];r.push(i),n.set(o,r)}return n.size===0?null:[...n].map(([i,o])=>Tt(i,o))}function et(e,t){let n=D(t.authoredInstructions),i=[];for(let o of e){if(o.flatIndex===void 0||!t.replayOnlyFlatIndices.has(o.flatIndex))continue;let r=U(o.records,n);r&&i.push(...r)}return i}function nt(e,t){let n=new Map(t.map(a=>[a.instruction_id,a])),i=[],o=a=>{if(!a||typeof a!="object")return;let c=a.instruction_id,u=typeof c=="string"?n.get(c):void 0;return u&&i.push(c),u},r=a=>{if(!a||typeof a!="object")return;let c=a;for(let u of tt){let l=c[u];if(Array.isArray(l))s(l);else if(l&&typeof l=="object"){let _=o(l);_&&(c[u]=_),r(_??l)}}},s=a=>{for(let c=0;c<a.length;c++){let u=o(a[c]);u&&(a[c]=u),r(u??a[c])}};return s(e),i}function xt(e){if(!e.timestamp||e.duration_ms==null)return"";let t=new Date(e.timestamp);return isNaN(t.getTime())?"":new Date(t.getTime()+e.duration_ms).toISOString()}function j(e){if(e!=null)try{return JSON.parse(e)}catch{return e}}function Ot(e){return typeof e=="string"?"string":typeof e=="boolean"?"bool":typeof e=="number"?Number.isInteger(e)?"int":"float":Array.isArray(e)?"list":e==null?"NoneType":"JSON"}function C(e,t,n){let i=e.user_variables,o=typeof i=="string",r;try{r=o?JSON.parse(i):i??[]}catch{return}if(!Array.isArray(r)||r.length===0)return;let s=r.find(a=>t&&a.name===t)??(r.length===1?r[0]:void 0);s&&(s.value=n,s.value_type=Ot(n),e.user_variables=o?JSON.stringify(r):r)}function Q(e){e.user_variables!==void 0&&(e.user_variables=typeof e.user_variables=="string"?"[]":[])}function Nt(e,t){let n=e.operations??[],i=new Set(t.map(r=>r.action_id).filter(Boolean)),o=n.filter(r=>i.has(r.operation_id));return o.length>0?o:n.length===1?n:[]}function Lt(e){let t=e.error??"Script execution failed";return{error:t,error_code:"SCRIPT_EXECUTION_ERROR",error_message:t,reason:t}}function Tt(e,t){let n=structuredClone(e),i=t[0],o=t[t.length-1];n.status=t.find(s=>s.status!=="success")?.status??i.status,n.start_timestamp=i.timestamp??n.start_timestamp,n.end_timestamp=xt(o)||n.end_timestamp;let r=Nt(n,t);for(let s of r)s.status=n.status,s.operation_start=n.start_timestamp,s.operation_end=n.end_timestamp;switch(n.content_type){case"api":{let s=o.action_params?.api_data?.response;if(s&&typeof s=="object")for(let a of[n,...r])a.api_data={...a.api_data??{},response:s},C(a,o.output_variable,s);break}case"script":{let s=o.output_variable??n.output_variable_name;if(n.status!=="success"){let a=Lt(o);n.code_error=a,Q(n);for(let c of r)c.execution_result=a,c.code_error=a,Q(c)}else if(o.output_value!=null){let a=j(o.output_value);C(n,s,a);for(let c of r)c.execution_result={value:a},C(c,s,a)}break}case"db_query":{o.output_value!=null&&(n.db_details={...n.db_details??{},carried_out_query:j(o.output_value)});break}case"screenshot_command":{let s=j(o.output_value);s&&typeof s=="object"&&(n.smartui_results=s);break}case"network_assertion":case"network_query":break;default:break}return n}var jt="/home/kaneai/Downloads";function O(e){return`${jt}/${e}`}function ot(e){return"FILE__"+e.replace(/[^A-Za-z0-9]/g,"_")}function N(e){let t=e?.media;return!t||!t.name||!t.media_url?null:{media_id:t.media_id??"",name:t.name,media_url:t.media_url,type:t.type??"doc"}}function st(e){return e?e.includes(`
|
|
3
3
|
`)?e.split(`
|
|
4
4
|
`).map(t=>t.trim()).filter(Boolean):e.split(". ").map(t=>t.trim()).filter(Boolean).map(t=>t.endsWith(".")?t:t+"."):[]}function F(e){return typeof e=="string"&&e.includes("{{secrets.")}var Ct={click:"CLICK",double_click:"CLICK",type:"TYPE",fill:"TYPE",clear:"CLEAR",select:"SELECT",hover:"HOVER",drag:"DRAG_DROP",upload_files:"UPLOAD_FILE",navigate:"OPEN",go_back:"NAVIGATE",go_forward:"NAVIGATE",refresh:"REFRESH",press_key:"SENDKEYS",scroll:"SCROLL_PIXELS",scroll_into_view:"SCROLL_UNTIL_ELEMENT",wait:"WAIT",wait_until:"WAIT_UNTIL",wait_for_load:"WAIT_FOR_LOAD",switch_tab:"SWITCH_TAB",new_tab:"NEW_TAB",close_tab:"CLOSE_TAB",api:"API",evaluate_js:"EVALUATE_JS",vision_query:"VISION_QUERY",textual_query:"TEXTUAL_QUERY",get_url:"GET_URL",get_title:"GET_TITLE",assert:"ASSERTION",math:"MATHEMATICAL_OPERATION",set_cookies:"SET_COOKIES",delete_cookies:"DELETE_COOKIES",clear_cookies:"CLEAR_COOKIES",set_local_storage:"SET_LOCAL_STORAGE",delete_local_storage:"DELETE_LOCAL_STORAGE",clear_local_storage:"CLEAR_LOCAL_STORAGE",set_clipboard:"SET_CLIPBOARD",paste_clipboard:"PASTE_CLIPBOARD",clear_clipboard:"CLEAR_CLIPBOARD",device_control:"DEVICE_CONTROL",device_control_query:"DEVICE_CONTROL_QUERY"},at={literal:"SET_VARIABLE",condition:"SET_VARIABLE",visual:"VISION_QUERY",dom:"TEXTUAL_QUERY",url:"GET_URL",title:"GET_TITLE",devtool_network:"DEVTOOLS_NETWORK_QUERY",devtool_console:"DEVTOOLS_CONSOLE_QUERY",devtool_cookies:"DEVTOOLS_COOKIES_QUERY",devtool_storage:"DEVTOOLS_STORAGE_QUERY",devtool_performance:"DEVTOOLS_PERFORMANCE",api_response:"API_CALLS_QUERY",textual_visual:"TEXTUAL_ANALYZER"},Dt=new Set(["CLICK","TYPE","FILL","HOVER","SCROLL_UNTIL_ELEMENT","UPLOAD_FILE","VISION_QUERY","DRAG_DROP","SELECT"]);function ct(e,t){if(e==="analyze"){let i=t?.action_params?.analyzer_type??"";return at[i]}if(e==="scroll"&&t?.action_params?.into_view===!0)return"SCROLL_UNTIL_ELEMENT";let n=Ct[e];return n||console.warn(`[migrator] UNKNOWN action_type "${e}" \u2014 falling back to "${e.toUpperCase()}"; explicit mapping required`),n??e.toUpperCase()}function ut(e,t){if(!e||!t)return"";try{let n=new Date(e);return isNaN(n.getTime())?"":new Date(n.getTime()+t).toISOString()}catch{return""}}function lt(e){try{return JSON.parse(e.output_value??"{}")}catch{return{}}}function Ut(e){let t=e.output_variable??"";if(!t)return"[]";let i={...lt(e)};return delete i.body,JSON.stringify([{name:t,unique_key:(e.action_id??"").replace(/-/g,"").slice(0,8)||A().replace(/-/g,"").slice(0,8),value:i,variable_description:"API Response"}])}function Ft(e,t,n){let i=e.action_params??{},o=Dt.has(t)?"Vision Agent":"Operation Agent",r={operation_type:t};if(t==="OPEN"&&(r.url=i.url??""),t==="SET_VARIABLE"&&(r.variable_name=e.output_variable??i.key??"",r.variable_value=e.output_value??""),t==="UPLOAD_FILE"){let m=N(i);m&&(r.value=O(m.name))}let s={},a={},c=e.action_instruction??"",u=i.text??"",l=i.url??"",_=[["intent",c],["value",u],["url",l]];for(let[m,h]of Object.entries(n)){let I=String(h);if(m.startsWith("secrets."))for(let[E,b]of _)b.includes(I)&&(a[E]=m);for(let[E,b]of _)b.includes(I)&&!(E in s)&&(s[E]=b)}let p=e.action_type,d={operation:e.action_instruction??"",agent:o,operation_dict:r,reasoning:p==="analyze"?i.query??"":e.intent??e.action_instruction??"",variable:s,secrets:a,params:{}};p==="analyze"&&typeof i.code=="string"&&i.code&&(d.code=i.code),p==="analyze"&&typeof i.code_js=="string"&&i.code_js&&(d.code_js=i.code_js),p==="analyze"&&typeof i.condition_expression=="string"&&i.condition_expression&&(d.condition_expression=i.condition_expression),i.uses_websocket===!0&&(d.uses_websocket=!0),i.uses_sse===!0&&(d.uses_sse=!0),p==="analyze"&&i.analyzer_type==="textual_visual"&&(typeof i.wrapped_js=="string"&&(d.wrapped_js=i.wrapped_js),Array.isArray(i.locators)&&(d.locators=i.locators),typeof i.operator=="string"&&(d.operator=i.operator),Array.isArray(i.transforms)&&(d.transforms=i.transforms),typeof i.query=="string"&&(d.query=i.query),typeof i.expected_value=="string"&&(d.expected_value=i.expected_value),typeof i.needs_unit_conversion=="boolean"&&(d.needs_unit_conversion=i.needs_unit_conversion),typeof i.condition=="string"&&(d.condition=i.condition));let g={set_cookies:"cookies",set_clipboard:"text",delete_cookies:"names",set_local_storage:"items",delete_local_storage:"keys"}[p];return g&&i[g]!==void 0&&(d[g]=i[g]),p==="set_clipboard"&&typeof i.html=="string"&&i.html&&(d.html=i.html),d}function L(e){let t=e.assertion_tree;return t&&typeof t=="object"&&Object.keys(t).length>0?t:Array.isArray(e.sub_results)?e:{}}function Bt(e){let t=L(e);if(typeof t.passed=="boolean")return t.passed;let n=t.sub_results??[];return n.length===0?t.status==="passed":(t.composite_operator??"and")==="or"?n.some(o=>o.passed===!0):n.every(o=>o.passed===!0)}function dt(e){return e.map(t=>({description:t.description??"",store_key:t.store_key??"",expected_value:t.expected??"",extracted_value:t.extracted_value??"",operator:t.operator??"equals",transforms:t.transforms??[]}))}function Mt(e){let t=L(e),n=t.sub_results??[],i=dt(n);return{operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[],sub_results:n,sub_checks:i,composite_operator:t.composite_operator??"and",verification:t.verification??"",claim:t.description??""}}function zt(e){let t=e.action_params??{},n=L(t),i=n.sub_results??[],o=dt(i);return[{operation:e.action_instruction??"",agent:"Operation Agent",operation_dict:{operation_type:"ASSERTION",assertion_tree:{sub_results:i,sub_checks:o,composite_operator:n.composite_operator??"and",verification:"",claim:n.description??e.action_instruction??"",operator:[],assertion_operands:[],left_operand:null,right_operand:null,operands:[]}},variable:{},secrets:{},params:{}}]}function Vt(e,t,n,i){let o=e.visual_data;if(!o||o.x==null||o.y==null)return null;let r=t?`${t}/test_screenshots`:"";return{x:o.x,y:o.y,confidence:0,bbox:o.bbox??null,bbox_source:o.bbox?"accessibility_tree":"fallback",viewport_width:o.viewport_width??1280,viewport_height:o.viewport_height??800,scale_factor:null,raw_image_url:r?`${r}/untagged_screenshot/${n}.${i?.get(n)??"png"}`:"",raw_image_sas_url:"",annotated_image_url:"",annotated_image_sas_url:""}}function qt(e){if(!e)return"";let t=e;return typeof e=="object"&&!Array.isArray(e)&&Array.isArray(e.frameInfo)&&(t=e.frameInfo),!Array.isArray(t)||t.length===0?"":JSON.stringify(t)}function $t(e){return/^(android|ios)_native$/i.test(e.platform??"")}function _t(e,t){return e.map(n=>({...n,type:t?n.strategy??n.type??"native":n.isXPath?"xpath":"css"}))}function Gt(e,t,n){let i={selector_target:"",drag_displacement:{},hold_duration_ms:null,move_duration_ms:null,hold_at_destination_ms:null};if(e!=="drag")return i;let o=t.target_selectors,r={};typeof t.direction=="string"&&t.direction&&(r.direction=t.direction,typeof t.fraction=="number"&&(r.fraction=t.fraction));let s=a=>typeof t[a]=="number"?Math.trunc(t[a]):null;return{selector_target:Array.isArray(o)&&o.length>0?_t(o,n):"",drag_displacement:r,hold_duration_ms:s("hold_duration_ms"),move_duration_ms:s("move_duration_ms"),hold_at_destination_ms:s("hold_at_destination_ms")}}function rt(e,t="",n){let i=e.action_type,o=ct(i,e),r=e.action_params??{},s=e.coordinates??null,a=e.selectors??null,c=!!(a&&a.length>0),u=$t(e),l=Gt(i,r,u),_=e.timestamp??"",p=e.duration_ms??0,d=e.variables_used??{},f=e.action_id??A(),g=A(),m=ut(_,p),h="",I="";if(i==="navigate")I=r.url??"",h=I;else if(i==="type"||i==="fill")h=r.text??"";else if(i==="press_key")h=r.key??"";else if(i==="wait")h=String(r.ms??r.timeout_ms??"");else if(i==="evaluate_js")h=r.script??"";else if(i==="upload_files"){let $=N(r);$&&(h=O($.name))}else i==="analyze"&&o==="SET_VARIABLE"&&(h=e.output_value??"");let E="";i==="go_back"?E="back":i==="go_forward"&&(E="forward");let b=e.action_instruction??"",v=F(h)||F(I)||F(b),x=Ft(e,o,d);return{operation_id:f,instruction_id:g,instruction:b,intent:b,operation_start:_,operation_end:m,status:e.status??"",command:o,name:"",target:"",value:h,message:"",operation_dict:"",frame:qt(e.frame_info),surface:typeof r.surface=="string"?r.surface:"",frame_path:typeof r.frame_path=="string"?r.frame_path:"",grounded_by:typeof r.grounded_by=="string"?r.grounded_by:"",error_message:e.error??"",code_snippet:"",sub_instruction_obj:JSON.stringify(x),test_id:"",test_version:"",action:"",string_to_float:!1,feedback_msg:"",time_taken:"",create_time_stamp:"",update_time_stamp:"",locator_variable:"",locator_variable_name:"",image_url:t?`${t}/test_screenshots/untagged_screenshot/${f}.${n?.get(f)??"png"}`:"",alternative_xpaths:[],attribute:"",value_description:"",url:I,navigation_direction:E,tagified_image_url:"",query_variable_name:e.output_variable??"",query_variable_value:e.output_value??"",query_variable_type:"",expected_value:"",queried_value:"",operator:"",assertion_status:o==="ASSERTION"?Bt(r):"",query_info_dict:{},query_content_confidence:"none",debugging_logs:[],locator_index:0,query_html:"",user_variables:"[]",optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,tab_index:String(r.tab_index??""),tab_identifier:String(r.tab_identifier??""),scroll_value:r.amount??1,scroll_direction:r.direction??"",mi_scroll_payload:{},sleep_duration:0,app_id:"",manual_interaction_tag:"",string_to_float_list:[],js_snippet:i==="evaluate_js"?r.script??"":"",code_error:"",hide:v,dismiss_dialog:!1,use_v2_mobile_tagging:u,multiple_inputs:!1,dialog_action:"",dialog_type:"",is_coordinates_used_for_interaction:s!==null&&!c,element_coordinates_ratio:[],element_bounds_ratio:[],x_coord:c?null:s?.x??null,y_coord:c?null:s?.y??null,target_x_coord:r.target_x??null,target_y_coord:r.target_y??null,source_description:r.source_description??null,target_description:r.target_description??null,use_coordinates:s!==null&&!c,kaneaiMobileTaggingImageLimit:1,clicks_order_code:"se_js_ac",selector:c?_t(a,u):"",selector_target:l.selector_target,math_result_variable_name:"",math_result_variable_value:"",expression_tree:o==="ASSERTION"?Mt(r):r.expression_tree??{},assertion_tree:o==="ASSERTION"?L(r):r.assertion_tree??{},assertion_tree_simplified:{},network_throttle:{},is_mobile_offline:!1,autoheal:!1,reprobe:e.reprobe??!1,click_modifier:(r.click_count??1)>=2?{kind:"multi_click",frequency:r.click_count}:null,db_query:"",db_details:{},db_query_decoded:"",is_global_variable:!1,is_global_variable_persist:!1,global_variable_id:"",wait_for_element_timeout:0,failure_condition:o==="ASSERTION"?"Fail test immediately":"",screenshot_command:"",smartui_contents:{},smartui_results:{},result_type:"",result_hint:"",drag_offset:{},drag_displacement:l.drag_displacement,hold_duration_ms:l.hold_duration_ms,move_duration_ms:l.move_duration_ms,hold_at_destination_ms:l.hold_at_destination_ms,start_coordinates:r.source_coordinates?{x:r.source_coordinates[0],y:r.source_coordinates[1]}:{},end_coordinates:r.target_coordinates?{x:r.target_coordinates[0],y:r.target_coordinates[1]}:{},element_rect:null,is_canvas:!1,until_condition:"",until_max_retries:0,until_settle_ms:0,api_data:i==="api"?{request:e.action_params?.api_data?.request??{}}:{},output_variables:i==="api"?e.output_variable?{[e.output_variable]:null}:{}:e.output_variable?{[e.output_variable]:e.output_value??""}:{},visual_context:Vt(e,t,f,n),reasoning:i==="analyze"?r.query??"":e.intent??e.action_instruction??""}}function it(e,t){let n=e.action_type,i=ct(n,e),o=e.timestamp??"",r=e.duration_ms??0,s=ut(o,r),a=i==="ASSERTION"||i==="MATHEMATICAL_OPERATION";return{instruction_id:t.instruction_id,instruction_class:a?"non_driver_action":"driver_action",module_id:"",instruction:e.action_instruction??"",command:i,error:null,parent_instruction_id:"",classification_layer_resp:i==="ASSERTION"?zt(e):[],classification_error:{},operations:[t],status:e.status??"",start_timestamp:o,end_timestamp:s,type:"agent_generated",tags:[],html_paths:[],optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,content_type:n==="api"?"api":n==="analyze"&&e.action_params?.analyzer_type==="api_response"?"api_calls_query":n==="analyze"&&e.action_params?.analyzer_type?.startsWith("devtool_")?e.action_params.analyzer_type.replace("devtool_","devtools_"):"instruction",js_snippet:n==="evaluate_js"?e.action_params?.script??"":"",user_variables:n==="api"?Ut(e):"[]",api_data:n==="api"?{request:e.action_params?.api_data?.request??{},response:lt(e)}:{},params_used:!1,hard_assertion:i==="ASSERTION"?e.action_params?.failure_condition==="hard":!1,expected_outcome:"",module_execution_index:0,module_version:null,network_throttle:{},isEdited:!1,use_query_assertion_v2:!1,db_query:"",db_details:{},network_assertion_content:{},screenshot_command:"",smartui_contents:{},generative_id:"",plan_id:"",generative_objective:"",error_message:"",error_code:"",reason:"",title:"",used_variables:[],reasoning:n==="analyze"?e.action_params?.query??"":e.intent??e.action_instruction??""}}function Kt(e,t=[]){let n=e.action_params??{},i=n.branches??[],o=n.winning_index??-1,r=n.sub_results??[],s={};for(let c of r){let u=c.sub_results;if(u)for(let l of u){let _=l.store_key;_&&(s[_]=l)}}let a=i.map((c,u)=>{let l=u===o,_=(c.sub_checks??[]).map(p=>{let d=s[p.store_key];return{description:p.description,store_key:p.store_key,expected_value:p.expected_value,stored_value:d?.extracted_value??p.stored_value,operator:p.operator??d?.operator??"equals",transforms:p.transforms??d?.transforms??[]}});if(_.length===0&&c.condition&&r.length>0){let d=r.find(f=>f.branch_index===u)?.sub_results??[];d.length>0&&(_=d.map(f=>({description:f.description??c.condition,store_key:f.store_key??"",expected_value:f.expected??"true",stored_value:f.extracted_value??void 0,operator:f.operator??"equals",transforms:f.transforms??[]})))}return{branch_index:u,condition:c.condition??null,branch_type:c.branch_type??"sub_objective",passed:l,sub_objective:null,custom_event:c.custom_event??null,children:l?t:[],sub_checks:c.condition?_:[],composite_operator:c.composite_operator??"and"}});return{content_type:"conditional_block",instruction_id:`if_else_${A().slice(0,8)}`,instruction:e.action_instruction??"",instruction_class:"driver_action",command:"",status:e.status??"success",resolved_branch_index:o,branches:a,generative_id:"",generative_objective:"",variables_used:{},classification_layer_resp:[],classification_error:{},used_variables:[],user_variables:"[]",module_id:"",module_execution_index:0,module_version:"",plan_id:"",optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,error:null,error_message:"",error_code:"",reason:"",start_timestamp:e.timestamp??"",end_timestamp:"",type:"agent_generated",hook:null,hook_type:null,evaluation_context:{},query_variables:{}}}function pt(e,t,n){for(let i of e)i.content_type==="instruction"&&"generative_id"in i&&(i.generative_id=t,i.generative_objective=n)}function B(e,t="",n,i){let o=[],r=0;for(;r<e.length;){let s=e[r],a=s.action_type;if(!i?.keepFailedActions&&s.status==="error"&&a!=="assert"&&a!=="if_else"&&a!=="child_agent_start"&&a!=="child_agent_end"&&!(s.until_condition&&!s.error)){r+=1;continue}if(a==="analyze"&&(!at[s.action_params?.analyzer_type??""]||s.action_params?.analyzer_type==="textual_visual"&&s.action_params?.code)){r+=1;continue}if(a==="child_agent_start"){let c=s.action_params?.child_id??"",u=s.action_params?.objective??"",l=[];r+=1;let _=1,p="error",d;for(;r<e.length&&_>0;){let v=e[r],x=v.action_type;if(x==="child_agent_start")_+=1;else if(x==="child_agent_end"&&(_-=1,_===0)){p=v.status??"success",d=v,r+=1;break}_>0&&l.push(v),r+=1}let f=B(l,t,n);pt(f,c,u);let g=d?.action_params?.result_code??null,m=d?.action_params?.reason_code??null,h=d?.action_params?.error_message??null,I=d?.action_params?.summary??null,E=d?.action_params?.one_liner??null,b=p==="error";o.push({content_type:"generative_block",instruction_id:`generative_block_${c}`,generative_id:c,objective:u,status:p,children:f,error_message:b?h??null:null,error_code:b?m??null:null,result_code:g??null,bifurcation_context:[],approach_reason:st(I),one_liner:E??null});continue}else if(a==="child_agent_end"){r+=1;continue}else if(a==="if_else"){r+=1;let c=[];for(;r<e.length&&e[r].action_type==="child_agent_start";){let u=e[r],l=u.action_params?.child_id??"",_=u.action_params?.objective??"",p=[];r+=1;let d=1,f="error";for(;r<e.length&&d>0;){let m=e[r];if(m.action_type==="child_agent_start")d+=1;else if(m.action_type==="child_agent_end"&&(d-=1,d===0)){f=m.status??"success",r+=1;break}d>0&&p.push(m),r+=1}let g=B(p,t,n);c.push(...g)}o.push(Kt(s,c));continue}else if(a==="query_tool"){r+=1;continue}else if(s.until_condition){let c=rt(s,t,n),u=it(s,c),l=typeof s.until_condition_met=="boolean"?s.until_condition_met:s.status==="success";o.push({content_type:"until_block",instruction_id:`until_${A().slice(0,8)}`,condition:s.until_condition,max_retries:s.until_max_retries??10,settle_ms:s.until_settle_ms??500,current_count:0,condition_met:l,children:[u],generative_id:"",generative_objective:"",variables_used:{},status:s.status??"success"})}else{let c=rt(s,t,n),u=it(s,c);o.push(u)}r+=1}return o}function P(e,t="",n,i){let o=[],r=[],s=i?.passthrough,a=s?D(s.authoredInstructions):null;for(let d of e){if(s&&a&&d.flatIndex!==void 0&&s.replayOnlyFlatIndices.has(d.flatIndex)){let b=U(d.records,a);if(b){for(let v of b)o.push(v),r.push(d.flatIndex);continue}console.warn(`[migrator] replay-only passthrough: no authored operation matched step ${d.flatIndex} (action_id \u2260 any operation_id in the authored blob) \u2014 falling back to this run's records`)}let f=B(d.records,t,n,i);if(f.length===0)continue;let g=A().replace(/-/g,"");pt(f,g,d.objective);let m=f.some(b=>"status"in b&&typeof b.status=="string"?b.status==="error"||b.status==="failed":!1),h=d.resultCode?parseInt(d.resultCode,10):null,I=h!==null&&!isNaN(h)&&h>=200,E=m||I?"error":"success";o.push({content_type:"generative_block",instruction_id:`generative_block_${g}`,generative_id:g,objective:d.objective,status:E,children:f,error_message:E==="error"?d.errorMessage??null:null,error_code:E==="error"?d.reasonCode??null:null,result_code:d.resultCode??null,bifurcation_context:[],approach_reason:st(d.summary),one_liner:d.oneLiner??null}),r.push(d.flatIndex)}let c=o.map((d,f)=>({block:d,flat:r[f]})),u=i?.moduleSpans??[],l=i?.blockSpans??[],_=i?.authoredBlocks??[];u.length>0&&(c=gt(c,u,l,_));let p=ht(l,u);return p.length>0&&(c=M(c,p,_)),{instructions:c.map(d=>d.block)}}function gt(e,t,n,i){let o=[],r=a=>a===void 0?void 0:t.find(c=>a>=c.flatFrom&&a<=c.flatTo),s=0;for(;s<e.length;){let a=r(e[s].flat);if(!a){o.push(e[s]),s++;continue}let c=[];for(;s<e.length&&r(e[s].flat)===a;)c.push(e[s++]);let u=gt(c,a.children,n,i),l=ht(mt(n,a),a.children);l.length>0&&(u=M(u,l,i)),o.push({block:te(a,u.map(_=>_.block)),flat:c[0].flat})}return o}function ft(e,t){return e.flatFrom>=t.flatFrom&&e.flatTo<=t.flatTo}function mt(e,t){let n=[];for(let i of e)ft(i,t)?n.push(i):n.push(...mt(i.children,t));return n}function ht(e,t){let n=[],i=r=>{for(let s of r)n.push(s),i(s.children)};i(t);let o=r=>r.filter(s=>!n.some(a=>ft(s,a))).map(s=>({...s,children:o(s.children)}));return n.length>0?o(e):e}function M(e,t,n){let i=[...t].sort((u,l)=>u.flatFrom-l.flatFrom),o=[],r=(u,l)=>{o.push({block:Wt(u,l,n),flat:u.flatFrom})},s=(u,l)=>u!==void 0&&u>=l.flatFrom&&u<=l.flatTo,a=0,c=0;for(;c<e.length;){let u=e[c].flat;for(;a<i.length&&u!==void 0&&i[a].flatTo<u;)r(i[a++],[]);let l=a<i.length&&s(u,i[a])?i[a]:void 0;if(!l){o.push(e[c]),c++;continue}let _=[];for(;c<e.length&&s(e[c].flat,l);)_.push(e[c++]);r(l,_),a++}for(;a<i.length;)r(i[a++],[]);return o}function Ht(e){let t=new Map;for(let n of e)t.set(n.flat,n);return e.filter(n=>t.get(n.flat)===n)}var Jt=["children","instructions","branches","module_content","true_branch","false_branch"];function Xt(e,t){if(!t)return;let n=[...e];for(;n.length>0;){let i=n.pop();if(!i||typeof i!="object")continue;let o=i;if(o.instruction_id===t&&(o.content_type==="conditional_block"||o.content_type==="until_block"))return o;for(let r of Jt){let s=o[r];Array.isArray(s)?n.push(...s):s&&typeof s=="object"&&n.push(s)}}}function Yt(e,t,n){if(!e)return[];if(t==="while")return Array.isArray(e.children)?e.children:[];let o=(Array.isArray(e.branches)?e.branches:[])[n];return o&&Array.isArray(o.children)?o.children:[]}function Wt(e,t,n){let i=Xt(n,e.blockId),o=e.branches.map((r,s)=>{let a=t.filter(l=>l.flat!==void 0&&l.flat>=r.flatFrom&&l.flat<=r.flatTo);e.kind==="while"&&(a=Ht(a));let c=M(a,e.children,n).map(l=>l.block);if(c.length>0)return c;let u=Yt(i,e.kind,s);return u.length===0&&!r.taken&&console.warn(`[migrator] control-flow: branch ${s} of block ${e.blockId||e.instruction} did not run and no authored block matched \u2014 emitted empty`),u});return e.kind==="if"?Zt(e,o,i):Qt(e,o[0]??[],i)}function Zt(e,t,n){let i=Array.isArray(n?.branches)?n.branches:[],o=z(t.flat()),r=e.branches.map((s,a)=>{let c=i[a];return{branch_index:a,condition:s.branch_type==="else"?null:s.condition,branch_type:s.branch_type,passed:s.taken,sub_objective:null,custom_event:c?.custom_event??null,children:t[a],sub_checks:Array.isArray(c?.sub_checks)?c.sub_checks:[],composite_operator:c?.composite_operator??"and"}});return{content_type:"conditional_block",instruction_id:e.blockId||`if_else_${A().slice(0,8)}`,instruction:e.instruction,instruction_class:"driver_action",command:"",status:o?"error":"success",resolved_branch_index:e.branches.findIndex(s=>s.taken),branches:r,generative_id:"",generative_objective:"",variables_used:{},classification_layer_resp:[],classification_error:{},used_variables:[],user_variables:"[]",module_id:"",module_execution_index:0,module_version:"",plan_id:"",optional_flag:!1,max_retries:0,retries_delay:0,explicit_wait:0,implicit_wait:0,error:null,error_message:o?.message??"",error_code:o?.code??"",reason:"",start_timestamp:"",end_timestamp:"",type:"agent_generated",hook:null,hook_type:null,evaluation_context:{},query_variables:{}}}function Qt(e,t,n){let i=e.whileCfg??{max_retries:5,settle_ms:500,on_exhaust:"fail",iterations:0,condition_met:!1},o=z(t),r=(s,a)=>n&&n[s]!==void 0?n[s]:a;return{content_type:"until_block",instruction_id:e.blockId||`until_${A().slice(0,8)}`,condition:e.instruction,max_retries:i.max_retries,settle_ms:i.settle_ms,current_count:i.iterations,condition_met:i.condition_met,children:t,generative_id:"",generative_objective:"",variables_used:{},status:o?"error":"success",on_exhaust:r("on_exhaust",i.on_exhaust),mode:r("mode",""),check:r("check",""),conditions:r("conditions",[]),connectors:r("connectors",[]),sub_checks:r("sub_checks",[]),composite_operator:r("composite_operator","and")}}function z(e){for(let t of e){let n="status"in t&&typeof t.status=="string"?t.status:"";if(n==="error"||n==="failed"){let i="error_message"in t?t.error_message:void 0,o="error_code"in t?t.error_code:void 0;return{message:i??null,code:o??null}}}return null}function te(e,t){let n=e.meta,i=(u,l="")=>typeof n[u]=="string"?n[u]:l,o=(u,l=!1)=>typeof n[u]=="boolean"?n[u]:l,r=u=>Array.isArray(n[u])?n[u]:[],s=typeof n.module_version=="number"||typeof n.module_version=="string"?n.module_version:null,a=i("module_id"),c=z(t);return{content_type:Y,instruction_id:`module_block_${a}`,module_id:a,module_version:s,module_instance_id:A(),module_name:i("module_name"),module_description:i("module_description"),module_platform:i("module_platform"),creation_mode:i("creation_mode","Agent"),tms_status:i("tms_status","active"),is_validated:o("is_validated"),is_dirty:e.dirty,enrichment_id:i("enrichment_id"),tags:r("tags"),project_ids:r("project_ids"),link_to_all:o("link_to_all"),status:c?"error":"success",children:t,error_message:c?.message??null,error_code:c?.code??null,update_available:!1,update_info:{}}}function yt(e,t){let n;try{n=bt(e)}catch{return 0}let i=0,o=n.filter(r=>/^\d+$/.test(r)).sort((r,s)=>Number(r)-Number(s));for(let r of o){let s=S(e,r),a=S(s,"logs");if(!ee(a))continue;let c;try{c=bt(a)}catch{continue}let u=c.filter(p=>p.endsWith("-actions.ndjson")).sort((p,d)=>(parseInt(p,10)||0)-(parseInt(d,10)||0)),l=[];for(let p of u){let d=t.readActions(S(a,p));d.length&&l.push({objective:t.objective??"",records:d})}if(l.length===0)continue;let{instructions:_}=P(l,t.screenshotBaseUrl??"",t.extMap,{keepFailedActions:!0});if(_.length!==0)try{let p=S(s,"auteur");ne(p,{recursive:!0}),re(S(p,"execution.json"),JSON.stringify(t.buildBlob(_),null,2)),i++,t.log?.("info","EVIDENCE_ARCHIVED_ATTEMPT_BLOB","Derived nested attempt blob",{attempt:r,instructions:_.length})}catch(p){t.log?.("debug","EVIDENCE_ARCHIVED_ATTEMPT_BLOB_FAILED","Nested attempt blob derivation failed",{attempt:r,error:p instanceof Error?p.message:String(p)})}}return i}var Et=Rt(Pt(),1);import{createWriteStream as ie}from"fs";import{readFile as oe}from"fs/promises";import{join as se,basename as ae}from"path";import{tmpdir as ce}from"os";var ue=["**/screenshots/**","**/annotated/**","**/tcg/**","**/bifurcation/**"];async function It(e){let t=se(ce(),`${ae(e)}_artifacts.zip`);return new Promise((n,i)=>{let o=ie(t),r=(0,Et.default)("zip",{zlib:{level:6}});o.on("close",()=>n(t)),r.on("error",i),r.pipe(o),r.glob("**/*",{cwd:e,ignore:ue}),r.finalize()})}async function At(e){return oe(e)}async function _e(e,t){return kt(X(e,t))}function pe(e){return{key:"artifacts",content_type:"application/zip",filename:`${e}.evidence`}}var vt=class{config;controller;testId;constructor(t){this.config=t,this.controller=new K(t.controllerBaseUrl,t.auth),this.testId=t.testId}log(t,n,i,o){this.config.log?.(t,n,i,o)}async execute(){let{onProgress:t}=this.config;try{if(!this.testId)return this.log("error","PIPELINE_ABORT","No test_id available"),{success:!1,testId:null,error:"No test_id available"};let n=this.config.evidence,i=null;if(this.config.shouldUploadArtifacts!==!1){t("convert","running");let a=this.collectNdjsonPerRun(),c=a.reduce((g,m)=>g+m.records.length,0);this.log("info","PIPELINE_CONVERT","Collected NDJSON records",{total_records:c,run_groups:a.length});let u=this.loadReplayOnlyPassthrough(),{instructions:l}=a.length>0?P(a,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap,{moduleSpans:this.config.moduleSpans,...u?{passthrough:u}:{},...this.config.blockSpans?.length?{blockSpans:this.config.blockSpans,authoredBlocks:this.loadAuthoredBlocks()}:{}}):{instructions:[]};this.log("info","PIPELINE_CONVERT_INSTRUCTIONS","Auteur instructions produced",{count:l.length});let _=this.buildExecutionEnvelope(l),p=Buffer.from(JSON.stringify(_));this.log("info","PIPELINE_CONVERT_BLOB","Blob created",{size_kb:+(p.length/1024).toFixed(1)});let d=y(this.config.sessionDir,"execution.json");w(d,JSON.stringify(_,null,2)),this.log("info","PIPELINE_CONVERT_LOCAL_SAVE","Execution blob saved locally",{path:d});let f=n?.packTestDir??this.config.evidenceRead?.packTestDir;if(f){let g=y(f,"auteur");q(g,{recursive:!0}),w(y(g,"execution.json"),JSON.stringify(_,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack",{path:y(g,"execution.json")}),this.deriveArchivedAttemptBlobs(f)}if(t("convert","done"),n)i=p;else{t("zip","running"),this.log("info","PIPELINE_ZIP_START","Zipping session",{session_dir:this.config.sessionDir});let g=null,m;try{g=await It(this.config.sessionDir),m=await At(g),this.log("info","PIPELINE_ZIP_DONE","Zip complete",{size_mb:+(m.length/1024/1024).toFixed(1),path:g}),t("zip","done",`${(m.length/1024/1024).toFixed(1)}MB`)}finally{g&&await de(g).catch(()=>{})}t("presign","running"),this.log("info","PIPELINE_PRESIGN_START","Requesting presigned URLs",{url:`${this.config.controllerBaseUrl}/upload/presign`,test_id:this.testId,session_id:this.config.sessionId});let h=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[{key:"artifacts",content_type:"application/zip",filename:`${this.config.sessionId}_artifacts.zip`},{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);this.log("info","PIPELINE_PRESIGN_OK","Presigned URLs received",{artifacts_url:h.urls.artifacts?.blob_url,blob_url:h.urls.blob?.blob_url}),t("presign","done"),t("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading artifacts and blob",{artifact_size_mb:+(m.length/1024/1024).toFixed(1),blob_size_kb:+(p.length/1024).toFixed(1)}),await Promise.all([k(h.urls.artifacts.upload_url,m,"application/zip"),k(h.urls.blob.upload_url,p,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),t("upload","done")}}else{let a=this.collectNdjsonPerRun(),c=this.loadReplayOnlyPassthrough(),{instructions:u}=a.length>0?P(a,this.config.screenshotBaseUrl??"",this.config.screenshotExtMap,{keepFailedActions:!0,moduleSpans:this.config.moduleSpans,...c?{passthrough:c}:{},...this.config.blockSpans?.length?{blockSpans:this.config.blockSpans,authoredBlocks:this.loadAuthoredBlocks()}:{}}):{instructions:[]},l=this.buildExecutionEnvelope(u),_=y(this.config.sessionDir,"execution.json");w(_,JSON.stringify(l,null,2)),this.log("info","PIPELINE_LOCAL_SAVE","Execution blob saved locally (no upload)",{path:_});let p=this.config.evidence?.packTestDir??this.config.evidenceRead?.packTestDir;if(p){let d=y(p,"auteur");q(d,{recursive:!0});let f=this.readAuthoredExecution(),g=f?this.refreshReplayOnlyInPack(f,a,c):null;w(y(d,"execution.json"),g?.raw??JSON.stringify(l,null,2)),this.log("info","PIPELINE_CONVERT_PACK_COPY","Execution blob copied into pack (gated)",{path:y(d,"execution.json"),source:g?g.refreshed.length>0?"authored+replay_results":"authored":"run_envelope",...g&&g.refreshed.length>0?{refreshed_instruction_ids:g.refreshed}:{}}),this.deriveArchivedAttemptBlobs(p)}t("convert","skipped"),t("zip","skipped"),t("presign","skipped"),t("upload","skipped"),this.log("info","PIPELINE_UPLOAD_SKIPPED","Upload steps skipped (gate disabled)")}if(this.config.shouldReplaceLocalOutput&&this.config.onAtomicReplace){t("atomic_replace","running");try{await this.config.onAtomicReplace(),this.log("info","PIPELINE_ATOMIC_REPLACE_OK","Local output replaced"),t("atomic_replace","done")}catch(a){let c=a instanceof Error?a.message:String(a);throw this.log("error","PIPELINE_ATOMIC_REPLACE_FAILED","Atomic-replace failed",{error:c}),t("atomic_replace","failed",c),a}}else t("atomic_replace","skipped");let o,r;if(this.config.shouldCommit&&!this.config.isFirstRun&&this.config.onCommitLock){t("commit_lock","running");let a=await this.config.onCommitLock();if(a.ok)o=a.testcaseId||void 0,this.log("info","PIPELINE_COMMIT_LOCK_OK","Commit lock acquired",{testcase_id:o??"none",trigger:a.trigger??null,test_instance_id:a.testInstanceId??null}),t("commit_lock","done");else return this.log("error","PIPELINE_COMMIT_LOCK_FAILED","Commit lock failed",{reason:a.reason,message:a.message}),t("commit_lock","failed",`${a.reason??"unknown"}: ${a.message??""}`),{success:!1,testId:this.testId,error:`commit-lock failed: ${a.reason??"unknown"}`}}else t("commit_lock","skipped");if(this.config.isFirstRun&&!this.config.skipTmsFinalize){t("finalize","running"),this.log("info","PIPELINE_FINALIZE_START","Finalizing test (first-run)",{test_id:this.testId,commit_id:this.config.commitId});let a=new H(this.config.tmsBaseUrl,this.config.tmsUsername,this.config.tmsAccessKey),c=this.config.runObjectives&&this.config.runObjectives.length>0?this.config.runObjectives:[this.config.firstObjective];if(o=(await a.endTest(this.testId,{commit_id:this.config.commitId,time_taken:Math.round(this.config.totalDuration),steps_count:this.config.totalSteps,commit_message:this.config.firstObjective.slice(0,255),objectives:c})).testcase_id||void 0,this.log("info","PIPELINE_FINALIZE_OK","Test finalized",{testcase_id:o??"none"}),this.config.onFinalizeSuccess)try{await this.config.onFinalizeSuccess(o)}catch(l){this.log("warn","PIPELINE_FINALIZE_META_FAILED","Meta-rewrite after endTest failed",{error:String(l)})}t("finalize","done")}else t("finalize","skipped"),this.log("info","PIPELINE_FINALIZE_SKIPPED","Finalize skipped (evolve flow or first-run disabled)");if(o&&this.config.shareApiBaseUrl)try{r=await this.generateShareLink(o),this.log("info","PIPELINE_SHARE_OK","Share link generated",{share_id:r})}catch(a){this.log("warn","PIPELINE_SHARE_FAILED","Share link failed",{error:String(a)})}if(n&&i){let a=null;t("zip","running");try{await n.sealFn({testcaseId:o,shareId:r}),a=n.sealedPackPath?await kt(n.sealedPackPath):await _e(n.executionId,n.cwd),this.log("info","PIPELINE_EVIDENCE_SEALED","Evidence pack sealed",{execution_id:n.executionId}),this.log("info","PIPELINE_PACK_READ","Sealed pack read",{size_mb:+(a.length/1024/1024).toFixed(1)})}catch(c){let u=c instanceof Error?c.message:String(c);this.log("warn","PIPELINE_EVIDENCE_UPLOAD_SKIPPED","Evidence seal/read failed \u2014 uploading blob only",{execution_id:n.executionId,error:u})}if(a){t("zip","done",`${(a.length/1024/1024).toFixed(1)}MB`),t("presign","running");let c=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[pe(n.executionId),{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);this.log("info","PIPELINE_PRESIGN_OK","Presigned URLs received",{artifacts_url:c.urls.artifacts?.blob_url,blob_url:c.urls.blob?.blob_url}),t("presign","done"),t("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading pack and blob",{artifact_size_mb:+(a.length/1024/1024).toFixed(1),blob_size_kb:+(i.length/1024).toFixed(1)}),await Promise.all([k(c.urls.artifacts.upload_url,a,"application/zip"),k(c.urls.blob.upload_url,i,"application/json")]),this.log("info","PIPELINE_UPLOAD_OK","Upload complete"),t("upload","done")}else{t("zip","skipped"),t("presign","running");let c=await this.controller.getPresignedUrls(this.testId,this.config.sessionId,[{key:"blob",content_type:"application/json",filename:`${this.config.commitId}.json`}]);t("presign","done"),t("upload","running"),this.log("info","PIPELINE_UPLOAD_START","Uploading blob only (evidence skipped)",{blob_size_kb:+(i.length/1024).toFixed(1)}),await k(c.urls.blob.upload_url,i,"application/json"),this.log("info","PIPELINE_UPLOAD_OK","Blob upload complete (pack skipped)"),t("upload","done")}}let s;if(this.config.codeExport?.enabled&&o){let a=!1;try{await this.triggerCodeExport(o),this.log("info","PIPELINE_CODE_EXPORT_START","Code export triggered"),a=!0}catch(c){let u=c instanceof Error?c.message:String(c);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export trigger failed; skipping poll",{error:u}),t("code_export","failed",`trigger failed: ${u}`)}if(a){t("code_export","running","Waiting for code generation\u2026");try{s=await this.pollAndDownloadCode(o,t),this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:s}),t("code_export","done",s)}catch(c){let u=c instanceof Error?c.message:String(c);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:u}),t("code_export","failed",u)}}}else t("code_export","skipped");return this.log("info","PIPELINE_COMPLETE","Pipeline complete"),{success:!0,testId:this.testId,testcaseId:o,shareId:r,codeExportDir:s}}catch(n){return{success:!1,testId:this.testId,error:n instanceof Error?n.message:String(n)}}}async runCodeExport(t,n){let i=n??this.config.onProgress,o=!1;try{await this.triggerCodeExport(t),this.log("info","PIPELINE_CODE_EXPORT_TRIGGER","Code export triggered",{testcase_id:t}),o=!0}catch(r){let s=r instanceof Error?r.message:String(r);this.log("error","PIPELINE_CODE_EXPORT_TRIGGER_FAILED","Code export trigger failed; skipping poll",{error:s}),i("code_export","failed",`trigger failed: ${s}`)}if(o){i("code_export","running","Waiting for code generation\u2026");try{let r=await this.pollAndDownloadCode(t,i);return this.log("info","PIPELINE_CODE_EXPORT_OK","Code export complete",{dir:r}),i("code_export","done",r),r}catch(r){let s=r instanceof Error?r.message:String(r);this.log("error","PIPELINE_CODE_EXPORT_FAILED","Code export failed",{error:s}),i("code_export","failed",s);return}}}deriveArchivedAttemptBlobs(t){try{let n=yt(t,{readActions:i=>this.readNdjsonFromFile(i),buildBlob:i=>this.buildExecutionEnvelope(i),objective:this.config.firstObjective,screenshotBaseUrl:this.config.screenshotBaseUrl??"",extMap:this.config.screenshotExtMap,log:(i,o,r,s)=>this.log(i,o,r,s)});n>0&&this.log("info","PIPELINE_ARCHIVED_ATTEMPTS","Nested retry-attempt blobs derived",{count:n})}catch(n){this.log("debug","PIPELINE_ARCHIVED_ATTEMPTS_FAILED","Nested attempt blob pass failed",{error:n instanceof Error?n.message:String(n)})}}collectNdjsonPerRun(){let t=[],n=this.config.runObjectives??[],i=this.config.runMetadata??[],o=this.config.evidence??this.config.evidenceRead;for(let r=0;r<this.config.runDirs.length;r++){let s=this.config.runDirs[r],a=n[r]||this.config.firstObjective,c=i[r],u=o?this.readNdjsonFromFile(y(o.packTestDir,"logs",`${o.runIndices?.[r]??r}-actions.ndjson`)):this.readNdjsonFromDir(s);if(u.length>0){let l=o?.runIndices?.[r]??r,_=this.config.runFlatIndex?.[l];t.push({objective:a,records:u,..._!==void 0?{flatIndex:_}:{},resultCode:c?.resultCode,reasonCode:c?.reasonCode,errorMessage:c?.errorMessage,summary:c?.summary,oneLiner:c?.oneLiner})}}if(t.length===0){let r=y(this.config.sessionDir,"runs");if(V(r))try{let a=le(r,{withFileTypes:!0}).filter(c=>c.isDirectory()).map(c=>c.name).sort();for(let c of a){let u=y(r,c),l=this.readNdjsonFromDir(u);l.length>0&&t.push({objective:this.config.firstObjective,records:l})}}catch{}}return t}readNdjsonFromDir(t){let n=[y(t,"run-test","actions.ndjson"),y(t,"actions.ndjson")];for(let i of n)if(V(i))return this.readNdjsonFromFile(i);return[]}readNdjsonFromFile(t){let n=[];if(!V(t))return n;this.log("debug","PIPELINE_COLLECT_READ","Reading NDJSON file",{path:t});let i=T(t,"utf-8");for(let o of i.split(`
|
|
5
5
|
`)){let r=o.trim();if(r)try{n.push(JSON.parse(r))}catch{}}return n}async generateShareLink(t){let n=`${this.config.shareApiBaseUrl}/lshs/api/v1.0/share-item/generate-sharable-link`;this.log("info","PIPELINE_SHARE_START","Requesting share link",{url:n,testcase_id:t});let i={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({entityIds:[t],entityType:"Test Case Details",expiresAt:7})},o=!!this.config.authResolver;this.log("debug","PIPELINE_SHARE_AUTH","Share link auth config",{resolver:o,fallback_auth_type:typeof this.config.auth=="string"?"bearer":"basic",tms_user:this.config.tmsUsername});let r=o?await this.config.authResolver.fetch(n,i):await R(n,{...i,headers:{...i.headers,Authorization:this.buildAuthHeader()}});if(!r.ok)throw new Error(`Share link API failed: ${r.status} ${await r.text()}`);let s=await r.json();if(!s.shareId)throw new Error("Share link API returned no shareId");return s.shareId}async triggerCodeExport(t){if(!this.config.codeExport)throw new Error("triggerCodeExport called without resolved codeExport config");let{url:n,body:i}=W({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:t,codeExport:this.config.codeExport,mobile:this.config.mobile});this.log("info","PIPELINE_CODE_EXPORT_POST","Triggering code export",{url:n});let o={method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(i)},r=this.config.authResolver?await this.config.authResolver.fetch(n,o):await R(n,{...o,headers:{...o.headers,Authorization:this.buildAuthHeader()}});if(!r.ok)throw new Error(`Code export failed: ${r.status} ${await r.text()}`)}async pollAndDownloadCode(t,n){let i=Z({tmsBaseUrl:this.config.tmsBaseUrl,testcaseId:t}),o=this.config.exitTimeoutMs??3e5,r=5e3,s=Date.now()+o;this.log("info","PIPELINE_CODE_EXPORT_POLL","Polling for code export",{url:i,timeout_ms:o});let a=(c,u)=>this.config.authResolver?this.config.authResolver.fetch(c,u):R(c,{...u,headers:{...u?.headers,Authorization:this.buildAuthHeader()}});for(;Date.now()<s;){let c=await a(i,{method:"GET",headers:{Accept:"application/json"}});if(!c.ok){let d=await c.text().catch(()=>"");throw this.log("warn","PIPELINE_CODE_EXPORT_POLL_FAILED","Code export poll non-200; skipping",{status:c.status,body:d.slice(0,200)}),new Error(`code export poll skipped: HTTP ${c.status}`)}let l=(await c.json()).data?.find(d=>d.code_name==="kane-cli-trigger");if(!l){this.log("debug","PIPELINE_CODE_EXPORT_WAITING","No kane-cli-trigger entry yet"),n("code_export","running","Waiting for code generation\u2026"),await this.sleep(r);continue}let _=l.status.toLowerCase();if(_==="in progress"||_==="in_progress"||_==="pending"){this.log("debug","PIPELINE_CODE_EXPORT_IN_PROGRESS","Code export in progress",{status:l.status}),n("code_export","running","Generating code\u2026"),await this.sleep(r);continue}if(!l.url||l.url.length===0)throw new Error(`Code export status=${l.status} but no files returned`);let p=this.config.codeExportDir??y(this.config.sessionDir,"code-export");q(p,{recursive:!0}),this.log("info","PIPELINE_CODE_EXPORT_DOWNLOAD","Downloading code files",{file_count:l.url.length,dir:p}),n("code_export","running",`Downloading ${l.url.length} files\u2026`);for(let d of l.url){let f=y(p,d.file_name),g=await R(d.file_url);if(!g.ok){this.log("warn","PIPELINE_CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:d.file_name,status:g.status});continue}let m=await g.text();w(f,m,"utf-8"),this.log("info","PIPELINE_CODE_EXPORT_FILE_SAVED","File saved",{file_name:d.file_name,size_bytes:m.length})}return p}throw new Error("Code export timed out")}sleep(t){return new Promise(n=>setTimeout(n,t))}buildAuthHeader(){return typeof this.config.auth=="string"?`Bearer ${this.config.auth}`:G(this.config.auth.username,this.config.auth.accessKey)}readAuthoredExecution(){let t=this.config.authoredExecutionPath;if(!t)return null;try{let n=T(t,"utf8");return JSON.parse(n),n}catch{return this.log("warn","PIPELINE_AUTHORED_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 pack gets this run's envelope",{path:t}),null}}refreshReplayOnlyInPack(t,n,i){if(!i)return{raw:t,refreshed:[]};let o=et(n,i);if(o.length===0)return{raw:t,refreshed:[]};let r=JSON.parse(t);if(!Array.isArray(r.instructions))return{raw:t,refreshed:[]};let s=nt(r.instructions,o);return s.length===0?{raw:t,refreshed:s}:{raw:JSON.stringify(r,null,2),refreshed:s}}loadAuthoredBlocks(){let t=this.config.blockAuthoredExecutionPath;if(!t)return[];try{let n=JSON.parse(T(t,"utf8"));return Array.isArray(n.instructions)?n.instructions:[]}catch(n){return this.log("warn","PIPELINE_AUTHORED_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 branches that did not run this time upload empty",{path:t,error:n instanceof Error?n.message:String(n)}),[]}}loadReplayOnlyPassthrough(){let t=this.config.replayOnlyPassthrough;if(!(!t||t.flatIndices.length===0))try{let n=JSON.parse(T(t.authoredExecutionPath,"utf8"));if(!Array.isArray(n.instructions))throw new Error("no instructions array");return{authoredInstructions:n.instructions,replayOnlyFlatIndices:new Set(t.flatIndices)}}catch(n){this.log("warn","PIPELINE_PASSTHROUGH_BLOB_UNREADABLE","Authored execution.json missing/unreadable \u2014 replay-only steps convert from this run's records",{path:t.authoredExecutionPath,flat_indices:t.flatIndices,error:n instanceof Error?n.message:String(n)});return}}buildExecutionEnvelope(t){let n=this.config.runStatuses.every(u=>u==="passed")?"success":"error",i=this.config.variableIds??{},o=[];if(this.config.variables)for(let[u,l]of Object.entries(this.config.variables)){if(l.secret||J(l))continue;let _=u.startsWith("global.")?u.slice(7):u;o.push({id:i[_]??0,name:_,value:l.value,session_value:l.value,is_persist:!1,environment_id:0,environment_name:"No Env"})}let r=[],s=u=>{let l=r.find(_=>_.name===u.name);l?l.value=u.value:r.push(u)},a=[],c=new Set;for(let u of this.collectNdjsonPerRun())for(let l of u.records)if(l.output_variable&&l.output_value!=null&&s({name:l.output_variable,value:String(l.output_value),value_type:"test_level",variable_description:"ANALYZE result"}),l.action_type==="upload_files"){let _=N(l.action_params);if(_){let p=_.media_id||_.media_url;if(!c.has(p)){c.add(p),a.push({media_url:_.media_url,media_id:_.media_id,name:_.name,type:_.type});let d=O(_.name);s({name:ot(_.name),value:d,value_type:"string",variable_description:`variable for ${d}`})}}}return{test_id:this.testId,version:"v4",auto_heal_version:this.config.apMode==="v2"?"AH2":"",session_id:this.config.sessionId,org_id:String(this.config.orgId),user_id:String(this.config.userId),url:this.config.firstUrl??"",start_timestamp:this.config.startedAt,end_timestamp:this.config.endedAt,status:n,commit_id:this.config.commitId,instructions:t,modules:[],uploaded_files:a,test_params:this.config.testParams??[],test_level_variables:JSON.stringify(r),test_global_variables:o,max_network_wait:0,wait_buffer:0,network_throttle:{},secrets:this.config.secrets??[],totp:[],environment_id:this.config.environmentId??0,environment:"",mobile_browser:!1,native_popups:[],smartui:{},module_index:0}}};export{_e as a,pe as b,vt as c};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as v}from"./chunk-QSCXXNC2.js";import{n as g}from"./chunk-RSSOJ3L2.js";import{a as u,b as d}from"./chunk-
|
|
2
|
+
import{a as v}from"./chunk-QSCXXNC2.js";import{n as g}from"./chunk-RSSOJ3L2.js";import{a as u,b as d}from"./chunk-CXF6AZWY.js";import{existsSync as F}from"fs";import{join as P}from"path";import{mkdirSync as w,rmSync as b,writeFileSync as h}from"fs";import{join as S,resolve as k}from"path";import{join as W}from"path";function f(){return process.env.KANE_CLI_WIRE_BASE_DIR||d}function B(e){return W(f(),"sessions",`testrun-${e}`)}function E(e=f()){return S(e,"sessions","active")}function y(e,r){return S(E(r),`${e}.json`)}function _(e){let r=e.pid??process.pid,n=y(r,e.baseDir);try{w(E(e.baseDir),{recursive:!0}),h(n,JSON.stringify({pid:r,cwd:process.cwd(),surface:e.surface,session_dir:k(e.sessionDir),started:new Date().toISOString(),cli_version:u,host_agent:v()},null,2)+`
|
|
3
3
|
`)}catch{}return n}function m(e=process.pid,r){try{b(y(e,r),{force:!0})}catch{}}var R={run:"run_end",testmd:"test_md_done",testrun:"testrun_done"};import{appendFileSync as A,mkdirSync as I}from"fs";import{dirname as N}from"path";function x(e){let r=!1;return{path:e,append(n){try{r||(I(N(e),{recursive:!0}),r=!0),A(e,n+`
|
|
4
4
|
`)}catch{}}}}function D(e,r=()=>new Date){let{v:n,ts:c,...i}=e;return{...i,v:1,ts:typeof c=="string"?c:r().toISOString()}}function T(e){let r=e.stdout??(t=>{process.stdout.write(t)}),n=R[e.surface],c=!1,i=null,o=null,p=[],l=()=>{if(!(o||!i||!F(i))){o=x(P(i,"events.ndjson"));for(let t of p)o.append(t);p=[];try{e.onAttach?.(i)}catch{}}};return{emit(t){if(c)return;let a=JSON.stringify(D(t,e.now));r(a+`
|
|
5
5
|
`),l(),o?o.append(a):p.push(a),t.type===n&&(c=!0,p=[])},attachSessionDir(t){i=t,l()},setTerminal(t){n=t},get logPath(){return o?o.path:null}}}var s=null;function V(e){return r=>{_({surface:e,sessionDir:r}),g("wire-active-run",()=>m()),process.once("exit",()=>m())}}function ie(e,r){return s=T({surface:e,cliVersion:u,onAttach:r??V(e)}),s.emit({type:"stream_start",cli_version:u,surface:e,pid:process.pid}),s}function oe(){return s}function se(e){if(s){s.emit(e);return}process.stdout.write(JSON.stringify(D(e))+`
|