@testmuai/kane-cli 0.8.10 → 0.8.12
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-OWGOCHG3.js → ChatSurface-DALSIICW.js} +1 -1
- package/dist/{ChromeProfilePicker-QIMCWPPI.js → ChromeProfilePicker-ZMVZH3AK.js} +1 -1
- package/dist/{CliFeedbackPrompt-34E2AXS4.js → CliFeedbackPrompt-K66H7YE6.js} +1 -1
- package/dist/{CliUploadProgress-TRKOSED7.js → CliUploadProgress-5DZHZY4M.js} +1 -1
- package/dist/{ConfigView-XVKR7ATN.js → ConfigView-S5KBV62S.js} +1 -1
- package/dist/EvidenceViewOffer-UACWB3YJ.js +2 -0
- package/dist/FolderPicker-YH5TKMX3.js +2 -0
- package/dist/{InfoBox-QM5YEBMH.js → InfoBox-7PAM2FQH.js} +1 -1
- package/dist/{LinksBox-CSEDEZGU.js → LinksBox-2NVZ3FHJ.js} +1 -1
- package/dist/{ProfilesView-CZVPREIS.js → ProfilesView-SIUBF7IU.js} +1 -1
- package/dist/{ProjectPicker-F6FEWNMY.js → ProjectPicker-5NI554X3.js} +1 -1
- package/dist/{SaveSessionPrompt-RUSFOLBZ.js → SaveSessionPrompt-5OULBV5N.js} +1 -1
- package/dist/SingleShotApp-LA3EMPUK.js +2 -0
- package/dist/{SummaryBox-KOJXTZVZ.js → SummaryBox-GTGF3CBO.js} +1 -1
- package/dist/TestMdRunView-5MNKJJMS.js +2 -0
- package/dist/{TestrunEvidenceTable-KGVBX76H.js → TestrunEvidenceTable-7WBCOGYW.js} +1 -1
- package/dist/{WhoamiView-IOTBOCGK.js → WhoamiView-E2SVBHLC.js} +1 -1
- package/dist/{app-download-7AF6QL2C.js → app-download-SAXSYXIV.js} +1 -1
- package/dist/{auth-2HTDCT7X.js → auth-3LLVDHOJ.js} +1 -1
- package/dist/{binary-NKX3NEK7.js → binary-WSMIRJNC.js} +1 -1
- package/dist/{bind-IMBQFRKT.js → bind-A3M4PV4V.js} +2 -2
- package/dist/{bootstrap-TNFANHSS.js → bootstrap-QTVHGL45.js} +1 -1
- package/dist/bridge-E2C5VV3H.js +2 -0
- package/dist/{changelog-SQVLSCYO.js → changelog-CNYWOB2V.js} +1 -1
- package/dist/{chat-committer-K3NOTLOU.js → chat-committer-RAOIL2T6.js} +1 -1
- package/dist/{chunk-SAFETUCL.js → chunk-24QPDHRD.js} +1 -1
- package/dist/{chunk-C33E5XQM.js → chunk-2LXJ2ZM3.js} +1 -1
- package/dist/{chunk-CSCJLGIY.js → chunk-2MTAXT2U.js} +1 -1
- package/dist/{chunk-KUAFVRSR.js → chunk-3CCD434H.js} +1 -1
- package/dist/{chunk-ESHDTCSZ.js → chunk-3G3LY6BM.js} +1 -1
- package/dist/{chunk-EH3YMGQ7.js → chunk-3N2YOHD6.js} +1 -1
- package/dist/{chunk-QJNQN6ND.js → chunk-3OU2F34I.js} +1 -1
- package/dist/{chunk-GHL2A273.js → chunk-3XWKKSIM.js} +2 -2
- package/dist/chunk-43DM2I6Q.js +2 -0
- package/dist/chunk-4ASRA7CD.js +6 -0
- package/dist/{chunk-ETIQJIDI.js → chunk-4E4GJPEM.js} +1 -1
- package/dist/chunk-4O6XBS5G.js +5 -0
- package/dist/{chunk-NYQOYOBA.js → chunk-4T35SA2O.js} +1 -1
- package/dist/{chunk-NYSFEZUR.js → chunk-4TZSEC2C.js} +1 -1
- package/dist/{chunk-EKOL4WCC.js → chunk-5A4QG7ZM.js} +1 -1
- package/dist/{chunk-LUTRUSIV.js → chunk-5AHOVOWV.js} +1 -1
- package/dist/{chunk-ZFZB4CGJ.js → chunk-5FYO3PFG.js} +1 -1
- package/dist/chunk-5KLDW3ZW.js +85 -0
- package/dist/{chunk-USUFF3S6.js → chunk-6A47PRDS.js} +1 -1
- package/dist/{chunk-WAI5UHW3.js → chunk-75HF3GPO.js} +1 -1
- package/dist/{chunk-FOP6CJAM.js → chunk-7KAPHA56.js} +1 -1
- package/dist/{chunk-LTNMOEHT.js → chunk-7NXHVC7G.js} +1 -1
- package/dist/{chunk-47OUD76M.js → chunk-7R5K4IGS.js} +1 -1
- package/dist/{chunk-LKUWEQ5M.js → chunk-7RFGO3TH.js} +1 -1
- package/dist/{chunk-BUM367KV.js → chunk-AFNDJK2A.js} +1 -1
- package/dist/{chunk-PMOUXVUC.js → chunk-AHRL4E3M.js} +1 -1
- package/dist/{chunk-2ULZVQZV.js → chunk-APZCLVZD.js} +1 -1
- package/dist/{chunk-XTUSDGAB.js → chunk-ASYWKYTQ.js} +1 -1
- package/dist/chunk-BHSHGWBL.js +2 -0
- package/dist/{chunk-BZCVLCMG.js → chunk-COVIEKZN.js} +1 -1
- package/dist/chunk-CQ3ZQ5UK.js +26 -0
- package/dist/{chunk-HNNVVK2O.js → chunk-DYXYNH6X.js} +1 -1
- package/dist/{chunk-NJQNHD5P.js → chunk-F2CET54H.js} +2 -2
- package/dist/{chunk-SAKUG4KE.js → chunk-FAREJ4P2.js} +1 -1
- package/dist/{chunk-2BIPFAGX.js → chunk-FBYB3SRE.js} +1 -1
- package/dist/{chunk-TI7MR3PB.js → chunk-FHYG3QLL.js} +1 -1
- package/dist/{chunk-WXJQDLXX.js → chunk-G2Q2TP3O.js} +1 -1
- package/dist/chunk-G52YPXKT.js +4 -0
- package/dist/{chunk-B4CYIZP5.js → chunk-GNAPBOAJ.js} +1 -1
- package/dist/chunk-GRDYYYIQ.js +2 -0
- package/dist/{chunk-BG2AZQLI.js → chunk-H6NHARB4.js} +1 -1
- package/dist/chunk-H6VS5RYO.js +11 -0
- package/dist/{chunk-HE3ZKFRC.js → chunk-HPUQJRDX.js} +1 -1
- package/dist/{chunk-HXSOZWFL.js → chunk-HWHLKBUT.js} +1 -1
- package/dist/{chunk-BQSLPF5M.js → chunk-I57TM22L.js} +1 -1
- package/dist/{chunk-GOF5PQ5T.js → chunk-IE4BCGUE.js} +1 -1
- package/dist/{chunk-ML2E3JGK.js → chunk-IGW77FMB.js} +1 -1
- package/dist/{chunk-ZDAO5D6D.js → chunk-JDGBRACP.js} +1 -1
- package/dist/{chunk-SXX7ZE6L.js → chunk-JOATASPP.js} +3 -3
- package/dist/chunk-KRL2BDI5.js +8 -0
- package/dist/{chunk-CKNVMB4E.js → chunk-L2BCQQLJ.js} +1 -1
- package/dist/{chunk-CXKWVHZK.js → chunk-L7GAZQYL.js} +1 -1
- package/dist/{chunk-RP7FW23G.js → chunk-LLY7TQSI.js} +1 -1
- package/dist/{chunk-W7PBJXLJ.js → chunk-M4WSRYRA.js} +1 -1
- package/dist/{chunk-SU3QKERU.js → chunk-MMQLVGUJ.js} +1 -1
- package/dist/{chunk-M6SFFAAQ.js → chunk-NBXYL2JT.js} +6 -6
- package/dist/{chunk-WEJA3EVI.js → chunk-NJJQL54J.js} +1 -1
- package/dist/{chunk-H4WIA4IP.js → chunk-NP3VGFZM.js} +1 -1
- package/dist/{chunk-AWEUKXZQ.js → chunk-NSD2H67E.js} +1 -1
- package/dist/{chunk-6S3Z3WPF.js → chunk-O7U5BVX5.js} +2 -2
- package/dist/chunk-OZMYKG6E.js +6 -0
- package/dist/{chunk-YUA2VDWH.js → chunk-QZRHXGNI.js} +1 -1
- package/dist/{chunk-JGZWR3CR.js → chunk-RV7Q4RUV.js} +2 -2
- package/dist/{chunk-NDKHC6KL.js → chunk-SA6EDKUF.js} +1 -1
- package/dist/chunk-SACCB44S.js +21 -0
- package/dist/chunk-T4OJX2GZ.js +15 -0
- package/dist/{chunk-5EKTQY2S.js → chunk-TLFNUXKS.js} +1 -1
- package/dist/chunk-U27OWZPW.js +368 -0
- package/dist/{chunk-5YBKKWJA.js → chunk-U2CIXGZR.js} +1 -1
- package/dist/{chunk-YHL5NA43.js → chunk-UDFDTFBL.js} +1 -1
- package/dist/{chunk-5Q3W3SX7.js → chunk-UZXCCO7V.js} +1 -1
- package/dist/{chunk-DF3DUGJS.js → chunk-VDM3TWF6.js} +4 -4
- package/dist/{chunk-YXPWGIQ2.js → chunk-VG7BTA5G.js} +1 -1
- package/dist/chunk-WD52ZNQY.js +2 -0
- package/dist/{chunk-D6566A2X.js → chunk-WHYEXCTG.js} +1 -1
- package/dist/{chunk-FH6EDP77.js → chunk-WMVPJWWA.js} +4 -4
- package/dist/{chunk-ZXTVP4WX.js → chunk-X6APRDUM.js} +2 -2
- package/dist/{chunk-KRKGZ2ZW.js → chunk-XS2LZFCH.js} +1 -1
- package/dist/{chunk-P3UGM74Z.js → chunk-XWO5MDEU.js} +1 -1
- package/dist/{chunk-RJ4YFH7K.js → chunk-YF26DH4Z.js} +1 -1
- package/dist/{chunk-OSRRMY6M.js → chunk-YTAAF62A.js} +1 -1
- package/dist/{chunk-UEANTGQS.js → chunk-ZVJGHQNG.js} +1 -1
- package/dist/chunk-ZVZHE7KH.js +27 -0
- package/dist/{chunk-WAWMIKSI.js → chunk-ZXN67F4U.js} +9 -9
- package/dist/{chunk-RSNG5PBN.js → chunk-ZZI4Y3CX.js} +1 -1
- package/dist/{config-UF635MC4.js → config-HUK7V364.js} +1 -1
- package/dist/{credentials-3KBLEVJH.js → credentials-6DP4KAMJ.js} +1 -1
- package/dist/{deps-bundle-WGF4YYGO.js → deps-bundle-PZNXSKLC.js} +1 -1
- package/dist/{deps-resolve-DVJPU4YX.js → deps-resolve-62XK3LKV.js} +1 -1
- package/dist/{dispatch-YTIJKX6C.js → dispatch-7JCKGQVC.js} +1 -1
- package/dist/{doctor-2KRK42L2.js → doctor-ZQQ4VMPY.js} +1 -1
- package/dist/{docx-convert-JMUMT5C4.js → docx-convert-BIV5T7F5.js} +1 -1
- package/dist/effective-decisions-UNE2TFVA.js +2 -0
- package/dist/{evidence-CDCFEYS7.js → evidence-YAXIWZ6A.js} +1 -1
- package/dist/{evolve-cmd-L3JIBYP5.js → evolve-cmd-5ACHYQPE.js} +1 -1
- package/dist/{extract-bind-VFQWACVO.js → extract-bind-BF2G6AS6.js} +2 -2
- package/dist/{extract-cmd-2OFQBBJ4.js → extract-cmd-IPBCCR3T.js} +1 -1
- package/dist/{gaps-cmd-JIUM5YDY.js → gaps-cmd-3WXL6PAW.js} +1 -1
- package/dist/{generate-headless-B35UUR5A.js → generate-headless-CLMSXEAS.js} +2 -2
- package/dist/index.js +130 -125
- package/dist/{ingest-cmd-LAUSXSI3.js → ingest-cmd-KP5M6XTA.js} +1 -1
- package/dist/install-5VWCH5GW.js +2 -0
- package/dist/{interactive-bind-OWASLPBQ.js → interactive-bind-MOV2VWHJ.js} +3 -3
- package/dist/{list-commands-SLQDF6AT.js → list-commands-KUDSKVP5.js} +1 -1
- package/dist/login-flow-GZ3XHVCS.js +2 -0
- package/dist/{mobile-prompts-6MGOXIKX.js → mobile-prompts-WJVFBWW5.js} +1 -1
- package/dist/objective-variable-gate-GCQYYM77.js +2 -0
- package/dist/persist-recorded-session-MHLD4A32.js +3 -0
- package/dist/pipeline-G7KWRK2G.js +2 -0
- package/dist/prepare-target-SQ5IGKXD.js +2 -0
- package/dist/{reconcile-cmd-MR2MSVZ5.js → reconcile-cmd-NI3AYU3Y.js} +1 -1
- package/dist/{reconcile-deps-RYO67ZXY.js → reconcile-deps-DCHUFIEC.js} +2 -2
- package/dist/{reconcile-engine-PRH6YIAZ.js → reconcile-engine-QXUKUKSL.js} +1 -1
- package/dist/{recording-banner-CH2SZ4IU.js → recording-banner-4H4AL6YN.js} +1 -1
- package/dist/registry-R6QNPI5E.js +2 -0
- package/dist/{replay-policy-CVQ6OJX5.js → replay-policy-A62KXE6Y.js} +1 -1
- package/dist/{require-project-folder-XY77JKAQ.js → require-project-folder-G2G4WKWW.js} +1 -1
- package/dist/{resolve-run-intent-JFIGIF72.js → resolve-run-intent-MZRPYN4V.js} +1 -1
- package/dist/{resolver-6VDNZ6KP.js → resolver-X5NHNX5O.js} +1 -1
- package/dist/run-PBS2J4N4.js +2 -0
- package/dist/run-VTUYLPSG.js +2 -0
- package/dist/{run-test-md-OLGWTC4I.js → run-test-md-4VRH7FU5.js} +2 -2
- package/dist/{skill-installer-NT7ZT6O4.js → skill-installer-WPW6NDCR.js} +1 -1
- package/dist/{spawner-YQSAPZR4.js → spawner-R3XOP3GP.js} +1 -1
- package/dist/tcg-generate-HIC5AA3L.js +2 -0
- package/dist/testmd-actions-VOSP7L74.js +2 -0
- package/dist/testmd-sync-GNCDKPQN.js +2 -0
- package/dist/token-refresh-GSFVJ6GU.js +2 -0
- package/dist/{validate-basic-OMAFYHME.js → validate-basic-YNGP5JFB.js} +1 -1
- package/dist/variable-receipt-2VCUG7NN.js +2 -0
- package/dist/{verdicts-KEBSV2NL.js → verdicts-PRXUKSDV.js} +1 -1
- package/dist/{version-check-FRVZSYNF.js → version-check-GUGRBTIH.js} +1 -1
- package/dist/{walk-session-LNFOCPJ6.js → walk-session-G3DLBR24.js} +1 -1
- package/dist/{with-telemetry-4ATZC6IR.js → with-telemetry-5Y2CVPXK.js} +1 -1
- package/package.json +11 -11
- package/dist/EvidenceViewOffer-M2TGMSNE.js +0 -2
- package/dist/FolderPicker-WZTNQ5IV.js +0 -2
- package/dist/SingleShotApp-WBFVUZFP.js +0 -2
- package/dist/TestMdRunView-BEXL7TIN.js +0 -2
- package/dist/bridge-SXYWYZDO.js +0 -2
- package/dist/chunk-724NYDMU.js +0 -27
- package/dist/chunk-CPGUTSUD.js +0 -6
- package/dist/chunk-EKCGZXZE.js +0 -2
- package/dist/chunk-I3OVXNBW.js +0 -7
- package/dist/chunk-I5KYZHJ5.js +0 -71
- package/dist/chunk-IPEA7ZOF.js +0 -8
- package/dist/chunk-PCVTSFIX.js +0 -363
- package/dist/chunk-SXUQBPQ6.js +0 -2
- package/dist/chunk-TGPI7VDR.js +0 -21
- package/dist/chunk-VIJUT5AR.js +0 -26
- package/dist/chunk-WHEWZR2C.js +0 -15
- package/dist/chunk-XIGTZTFP.js +0 -5
- package/dist/effective-decisions-DRM3JSR4.js +0 -2
- package/dist/install-ENSOEMSX.js +0 -2
- package/dist/login-flow-YKQUXP75.js +0 -2
- package/dist/persist-recorded-session-RKG7HOEW.js +0 -3
- package/dist/pipeline-M25AR7RM.js +0 -2
- package/dist/prepare-target-UGACDQEJ.js +0 -2
- package/dist/registry-ARR5ITIQ.js +0 -2
- package/dist/run-GTBYWSLW.js +0 -2
- package/dist/run-UETW72YU.js +0 -2
- package/dist/tcg-generate-D73BMKOE.js +0 -2
- package/dist/testmd-actions-XPYXS36F.js +0 -2
- package/dist/token-refresh-2XVSIFRM.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{homedir as a}from"os";import{join as t}from"path";var m="0.8.
|
|
2
|
+
import{homedir as a}from"os";import{join as t}from"path";var m="0.8.12";var e=t(a(),".testmuai","kaneai"),d=t(e,"profiles"),g=t(e,"tui-config.json"),h=t(e,"media"),b="https://registry.npmjs.org/@testmuai/kane-cli",A="https://api.github.com/repos/LambdaTest/kane-cli/releases",n="@testmuai/kane-cli-skill",_=`https://registry.npmjs.org/${n}`,r="kane-cli",L=[{dir:t(a(),".claude","skills",r),agent:"Claude Code"},{dir:t(a(),".agents","skills",r),agent:"Codex CLI"},{dir:t(a(),".gemini","skills",r),agent:"Gemini CLI"}],x="https://dd-proxy.lambdatest.com/intake/kane-cli",U="https://kaneai-playground.lambdatest.io",u=9222,R=9230,I=t(e,"chrome-profiles"),o=t(e,"hints"),E=t(o,"state.json");function C(s){return t(o,`catalog-${s}.json`)}var c="127.0.0.1",T=18392,S=18400,i="/callback";function f(s){return`http://${c}:${s}${i}`}var B="KANE CLI",N="*",P={prod:{authBaseUrl:"https://auth.lambdatest.com",consentUrl:"https://accounts.lambdatest.com",controllerBaseUrl:"https://kaneai-api.lambdatest.com/v16-controller/v1",tmsBaseUrl:"https://test-manager-api.lambdatest.com/api",testGeneratorBaseUrl:"https://test-manager-api.lambdatest.com",secretsBaseUrl:"https://api-hyperexecute.lambdatest.com",testManagerUiUrl:"https://test-manager.lambdatest.com",shareApiBaseUrl:"https://api.lambdatest.com",v16ServerHost:"https://kaneai-api.lambdatest.com/v16-server",evidenceViewerUrl:"https://evidence.lambdatest.com",mediaArtefactsHost:"prod-mobile-artefacts.lambdatest.com",mobileAppBaseUrl:"https://api.lambdatest.com"},stage:{authBaseUrl:"https://stage-auth.lambdatestinternal.com",consentUrl:"https://stage-accounts.lambdatestinternal.com",controllerBaseUrl:"https://auteur-stage-automind.lambdatestinternal.com/v16-controller/v1",tmsBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com/api",testGeneratorBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com",secretsBaseUrl:"https://api-stage-hyperexecute.lambdatestinternal.com",testManagerUiUrl:"https://stage-test-manager.lambdatestinternal.com",shareApiBaseUrl:"https://stage-api.lambdatestinternal.com",v16ServerHost:"https://auteur-stage-automind.lambdatestinternal.com/v16-server",evidenceViewerUrl:"https://stage-evidence.lambdatestinternal.com",mediaArtefactsHost:"stage-mobile-artefacts.lambdatestinternal.com",mobileAppBaseUrl:"https://stage-api.lambdatestinternal.com"}},O={orange:"#ff9500",generateAccent:"#0d9488",assuranceAccent:"#b388ff",purple:"#b388ff",secondary:"#888888",dim:"#666666",muted:"#444444",green:"#4ade80",red:"#ef4444",amber:"#fbbf24"};export{m as a,e as b,g as c,h as d,b as e,A as f,n as g,L as h,x as i,U as j,u as k,R as l,I as m,E as n,C as o,c as p,T as q,S as r,i as s,f as t,B as u,N as v,P as w,O as x};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{d as w}from"./chunk-
|
|
2
|
+
import{d as w}from"./chunk-KRL2BDI5.js";import{b as h,c as b}from"./chunk-VZ7KXRXB.js";import{b as $}from"./chunk-IAHKTEET.js";var j=new Set(["delta","state-transition"]),K=/^capture baseline:/i;function I(e){return typeof e=="string"?e:e.text}function S(e){return typeof e=="object"&&e.baseline===!0||K.test(I(e).trim())}function T(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)&&"derived"in e}function B(e,r){if(e.check_prose)return e.check_prose;let t=r.find(o=>o.ref===e.check.verified_against),n=t?.text?` \u2014 the stated promise: ${t.text}`:"",s=String(e.check.operand??e.check.within??e.check.metric??"");return e.check.kind==="forbidden-presence"?`Confirm '${s}' does NOT appear (forbidden-presence)${n}`:`Confirm ${e.check.kind} check: ${s} (${e.check.operator})${n}`}var N=/^## Step \d+ — assert\s*$/;function X(e,r){let t=e.split(`
|
|
3
3
|
`),n=!1;for(let s=0;s<t.length;s++){let o=/^(##\s.*?)\s@verifies\s+(.+?)\s*$/.exec(t[s]);if(!o)continue;n=!0;let c=o[2].split(",").map(a=>a.trim()).filter(Boolean).map(a=>{let i=r(a)??(a.startsWith("ac-")?a:null);if(!i)throw new Error(`@verifies ref '${a}' does not resolve to a committed AC`);return i});t[s]=`${o[1]} @verifies ${c.join(", ")}`}return{md:t.join(`
|
|
4
4
|
`),tagged:n}}function Y(e,r){if(r.length!==0&&!e.split(`
|
|
5
5
|
`).some(t=>/^##\s/.test(t)&&w.test(t)))throw new Error("generated body has no @verifies binding for its ACs \u2014 the emitter contract is broken")}function ee(e){let r=e.split(`
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{e as $e}from"./chunk-
|
|
2
|
+
import{e as $e}from"./chunk-7R5K4IGS.js";import{a as te}from"./chunk-75HF3GPO.js";import{a as K}from"./chunk-5Y2G4NC7.js";import{a as Be}from"./chunk-5FYO3PFG.js";import{a as ve}from"./chunk-5AHOVOWV.js";import{x as i}from"./chunk-NJJQL54J.js";import{b as ye}from"./chunk-DFS4RMVP.js";import{a as k}from"./chunk-HCBYKLMW.js";import{a as s,b as o,i as Se,j as Te,k as ee}from"./chunk-C44QQJR4.js";import{a as V}from"./chunk-6YGTRKDT.js";import{e as R}from"./chunk-UR6MHSHU.js";var A=R(V(),1);var C=R(V(),1);function de(e){let t=e.flatMap(u=>[u,...u.children??[]]),n=t.filter(u=>u.status==="passed").length,l=t.filter(u=>u.status==="failed").length,a=t.filter(u=>u.status==="passed"||u.status==="failed").length;return{passed:n,failed:l,total:a}}function we(e){let t=$e(e.screenshotDispatcher,e.stepLogger,e.onReasoning,e.onStepComplete),[n,l]=(0,C.useState)(0),[a,u]=(0,C.useState)("idle"),c=(0,C.useRef)("idle"),v=(0,C.useRef)(0),S=(0,C.useRef)(!1),T=(0,C.useRef)(null),d=(0,C.useRef)(null),L=(0,C.useCallback)(h=>{c.current=h,u(h)},[]),O=(0,C.useCallback)(async h=>{let b=await e.getNextConfig(h);if(!b){L("done"),e.onAllComplete?.();return}let B=h?v.current+1:0;v.current=B,l(B),e.onStepStart?.(b,B),T.current=null,d.current=null,L("running"),await t.startRun(b,e.spawnOpts)},[t,e,L]);(0,C.useEffect)(()=>{S.current||(S.current=!0,O(null))},[]),(0,C.useEffect)(()=>{if(!t.lastRunEnd||t.lastRunEnd===T.current||c.current!=="running")return;T.current=t.lastRunEnd,c.current="transitioning",u("transitioning");let h=t.lastRunEnd,b=de(t.steps),B=t.bifurcationInfo,F={status:h.status==="passed"?"passed":"failed",duration_s:h.duration??0,reason:h.reason,runEnd:h,hadError:!1,stepsPassed:b.passed,stepsFailed:b.failed,stepsTotal:b.total,bifurcationFlows:B&&!B.isSingleFlow?B.flows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(F,v.current)??!0)){L("done"),e.onAllComplete?.();return}O(F)},[t.lastRunEnd]),(0,C.useEffect)(()=>{if(!t.runError||t.runError===d.current||t.lastRunEnd||c.current!=="running")return;d.current=t.runError,c.current="transitioning",u("transitioning");let h=de(t.steps),b={status:"failed",duration_s:0,reason:t.runError,runEnd:null,hadError:!0,stepsPassed:h.passed,stepsFailed:h.failed,stepsTotal:h.total,bifurcationFlows:null,evidence:t.getEvidenceState()};if(!(e.onStepEnd?.(b,v.current)??!0)){L("done"),e.onAllComplete?.();return}O(b)},[t.runError,t.lastRunEnd]);let y=(0,C.useCallback)(()=>{t.cancelRun()},[t]);return{runner:t,currentStepIndex:n,phase:a,cancel:y}}var pe=R(V(),1);var ne=R(k(),1),Ee=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function ke({label:e,hasBifurcation:t=!1}){let[n,l]=(0,pe.useState)(0),[a,u]=(0,pe.useState)(0);K(()=>{l(v=>(v+1)%Ee.length)},80),K(()=>{u(v=>(v+1)%4)},400);let c=e??(t?"Planning approach":"Analyzing objective");return(0,ne.jsxs)(s,{marginLeft:1,children:[(0,ne.jsxs)(o,{color:i.orange,children:[Ee[n]," "]}),(0,ne.jsxs)(o,{color:i.dim,children:[c,".".repeat(a+1)]})]})}function Ie(e){if(!e.isRunning||e.replayInfo)return null;let t=e.bifurcationInfo;if(t&&!t.isSingleFlow){let n=e.steps.findIndex(a=>a.status==="running");return(n===-1?e.cmInitCounts.length===0:n>=e.cmInitCounts.length)?{label:n>0?`Planning flow ${n+1}`:void 0,hasBifurcation:!0}:null}return e.cmInitCounts.length>0||e.steps.some(n=>n.children?.length)?null:{hasBifurcation:!!t}}var I=R(V(),1);var Ce=R(V(),1);var re=R(k(),1),He="#ffc580",Ue="#ffd9a8",Le="#ffffff";function oe({text:e,active:t=!0}){let[n,l]=(0,Ce.useState)(0),a=4;if(K(()=>{l(c=>(c+1)%(e.length+a*2))},t?80:null),!t)return(0,re.jsx)(o,{color:Le,children:e});let u=e.split("").map((c,v)=>{let S=n-a,T=Math.abs(v-S-a/2),d;return T<=a/2?d=He:T<=a?d=Ue:d=Le,(0,re.jsx)(o,{color:d,children:c},v)});return(0,re.jsx)(o,{children:u})}var _=R(k(),1),We={starting:i.orange,running:i.orange,passed:i.green,failed:i.red,cancelled:i.dim,timed_out:i.orange};function ie({currentStep:e,maxSteps:t,elapsed:n,status:l}){let a=We[l]??i.orange,u=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`;return(0,_.jsxs)(s,{marginLeft:3,children:[(0,_.jsx)(o,{color:i.dim,children:"Steps "}),(0,_.jsx)(o,{bold:!0,children:e}),(0,_.jsxs)(o,{color:i.dim,children:["/",t]}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Elapsed "}),(0,_.jsx)(o,{bold:!0,children:u}),(0,_.jsx)(o,{children:" "}),(0,_.jsx)(o,{color:i.dim,children:"Status "}),(0,_.jsx)(o,{bold:!0,color:a,children:l})]})}var Ve={click:"\u25CF",type:"\u229E",scroll:"\u2195",navigate:"\u2192",analyze:"\u25CE",assert:"\u25C8","if-else":"\u2442",select:"\u25BC",press_key:"\u21B5",wait:"\u2026",tool_call:"\u2299"};function Oe(e){return Ve[e]??"\u25CF"}var q=R(k(),1);function fe({steps:e,flows:t,cmInitCounts:n,renderStep:l}){return(0,q.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[(0,q.jsxs)(o,{color:i.dim,children:["\u2501\u2501 Bifurcated into ",t?.length??e.length," flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"]}),e.map((a,u)=>(0,q.jsxs)(s,{flexDirection:"column",marginTop:u>0?1:0,children:[(0,q.jsxs)(o,{color:i.orange,children:["Flow ",u+1,": ",t?.[u]??a.objective]}),n&&n[u]!=null&&(0,q.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",n[u]," checkpoints"]}),a.children&&a.children.length>0?a.children.map(c=>{let v=!!c.branchObjective,S=`f${u}-${c.childId??"p"}-${c.index}`;return v?(0,q.jsxs)(s,{flexDirection:"column",children:[l({...c,children:void 0},S),(c.children??[]).map(T=>(0,q.jsx)(s,{marginLeft:2,children:l(T,`${S}-${T.childId??"p"}-${T.index}`)},`${S}-${T.childId??"p"}-${T.index}`))]},`${S}-host`):l(c,S)}):a.status==="pending"&&(0,q.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})]},u))]})}var H=R(k(),1);function Pe({label:e,shimmer:t=!1}){return(0,H.jsxs)(s,{marginLeft:6,children:[(0,H.jsx)(te,{}),(0,H.jsx)(o,{children:" "}),t?(0,H.jsx)(oe,{text:e,active:!0}):(0,H.jsx)(o,{color:i.dim,children:e})]})}var De=R(V(),1);var me=R(k(),1);function ze(e,t){let n=[];for(let l of e.split(`
|
|
3
3
|
`)){if(l===""){n.push("");continue}let a="";for(let u of l.split(" ")){let c=u;for(;c.length>t;)a&&(n.push(a),a=""),n.push(c.slice(0,t)),c=c.slice(t);a===""?a=c:a.length+1+c.length<=t?a+=" "+c:(n.push(a),a=c)}n.push(a)}return n}function je({text:e,maxLines:t=3}){let{stdout:n}=ee(),l=Math.max(20,(n?.columns??80)-7),a=!e.trim(),[u,c]=(0,De.useState)(!0);K(()=>c(T=>!T),500);let v=(a?"Thinking\u2026":e)+(u?"\u258C":" "),S=ze(v,l).slice(-t);for(;S.length<t;)S.push("");return(0,me.jsx)(s,{borderStyle:"round",borderColor:i.muted,paddingX:1,marginLeft:3,flexDirection:"column",children:S.map((T,d)=>(0,me.jsx)(o,{color:a?i.dim:i.secondary,wrap:"truncate-end",children:T.length?T:" "},d))})}var U=R(k(),1);function se({activity:e,describe:t,describeVisible:n}){return(0,U.jsxs)(U.Fragment,{children:[e?(0,U.jsx)(Pe,{label:e.label,shimmer:e.shimmer}):null,n?(0,U.jsx)(je,{text:t??""}):null]})}var r=R(k(),1);function le(e){for(let t of e){if(t.children&&t.children.length>0){let n=le(t.children);if(n)return n}if(t.status==="running")return t}}function z(e){return e.status==="running"&&!e.branchObjective&&(!e.children||e.children.length===0)}function Fe(e){let t=[];for(let n of e)z(n)||(n.children&&n.children.length>0?t.push({...n,children:Fe(n.children)}):t.push(n));return t}function ge(e,t){if(!e)return null;let n=e.objective??"";return n.length>0&&!/^Step \d+$/.test(n)?{label:n+"\u2026",shimmer:!1}:{label:t?"Looking at the screen\u2026":"Deciding next action\u2026",shimmer:!0}}function P({step:e,indent:t=2}){let n=e.actionType?Oe(e.actionType):null,l=e.status==="running",a=e.status==="passed",u=e.status==="failed",c=e.status==="pending"||e.status==="stopped",{stdout:v}=ee(),S=v?.columns??80,T=Math.max(20,S-t-21),d=e.objective??"",L=d.length>T?d.slice(0,T-1)+"\u2026":d,O=(e.duration??0)*1e3,y=e.duration!=null?O<1e3?`${Math.round(O)}ms`:`${(O/1e3).toFixed(1)}s`:"";return(0,r.jsxs)(s,{flexDirection:"column",children:[(0,r.jsxs)(s,{marginLeft:t,children:[(0,r.jsx)(s,{width:4,children:(0,r.jsxs)(o,{color:i.muted,children:[String(e.index).padStart(2," ")," "]})}),(0,r.jsx)(s,{width:3,children:l?(0,r.jsx)(te,{}):a?(0,r.jsx)(o,{color:i.green,bold:!0,children:"\u2713"}):u?(0,r.jsx)(o,{color:i.red,bold:!0,children:"\u2717"}):(0,r.jsx)(o,{color:i.muted,children:"\u25CB"})}),(0,r.jsx)(s,{flexGrow:1,children:l?(0,r.jsx)(oe,{text:L,active:!0}):u?(0,r.jsx)(o,{color:i.red,children:L}):c?(0,r.jsx)(o,{color:i.dim,children:L}):(0,r.jsx)(o,{color:i.dim,children:L})}),(a||u)&&n?(0,r.jsx)(s,{width:3,marginLeft:1,children:(0,r.jsx)(o,{color:i.muted,children:n})}):(0,r.jsx)(s,{width:3,marginLeft:1}),(0,r.jsx)(s,{width:7,justifyContent:"flex-end",children:(0,r.jsx)(o,{color:i.dim,children:y})})]}),e.children&&e.children.length>0&&(0,r.jsx)(s,{flexDirection:"column",children:e.children.map((h,b)=>(0,r.jsx)(P,{step:h,indent:t+2},`child-${b}`))})]})}function Xe(e){return e.type==="cm_init"?(0,r.jsx)(s,{marginLeft:2,paddingLeft:1,children:(0,r.jsxs)(o,{color:i.dim,children:["\u25AA Generated task with ",e.count," checkpoints"]})}):(0,r.jsx)(s,{marginLeft:2,paddingLeft:1,children:(0,r.jsx)(P,{step:e.step})})}function _e({steps:e,bifurcated:t,flows:n,cmInitCounts:l,maxSteps:a=50,staticSteps:u=!1,onStepCommit:c,describe:v,describeVisible:S,describeRevealing:T}){let d=(0,I.useRef)(new Set),L=(0,I.useRef)(!1),O=(0,I.useRef)(new Set),y=(0,I.useRef)(!1),h=(0,I.useRef)(new Set),b=(0,I.useRef)(0);(0,I.useEffect)(()=>{e.length===0&&b.current>0&&(d.current.clear(),L.current=!1,O.current.clear(),y.current=!1,h.current.clear()),b.current=e.length},[e.length]);let B=e.flatMap(p=>[p,...p.children??[]]),F=B.some(p=>p.status==="running"),M=B.some(p=>p.status==="failed"),X=B.length===0||B.every(p=>p.status==="pending"),Y=B.filter(p=>p.status==="passed"||p.status==="failed").length,N;X?N="starting":F?N="running":M?N="failed":N="passed";let J=(0,I.useRef)(null),[ce,he]=(0,I.useState)(0);(0,I.useEffect)(()=>{B.length===0||X?(J.current=null,he(0)):F&&J.current==null&&(J.current=Date.now())},[F,X,B.length]),(0,I.useEffect)(()=>{if(!F)return;let p=setInterval(()=>{J.current!=null&&he((Date.now()-J.current)/1e3)},500);return()=>clearInterval(p)},[F]);let ae=(0,I.useRef)(new Set),[,xe]=(0,I.useState)(0),be=(0,I.useRef)(!1);(0,I.useEffect)(()=>{if(!c||!u||t)return;let p=[];!be.current&&l&&l[0]!=null&&(be.current=!0,l[0]>0&&p.push({key:"cm_init_0",type:"cm_init",count:l[0]}));for(let g of e)(g.status==="passed"||g.status==="failed")&&!ae.current.has(g.index)&&(ae.current.add(g.index),p.push({key:`step_${g.index}`,type:"step",step:{...g,children:g.children?[...g.children]:void 0}}));if(p.length>0){for(let g of p)c(Xe(g));xe(g=>g+1)}},[e,t,l,u,c]),(0,I.useEffect)(()=>{if(!c||u)return;let p=d.current.size;if(!t&&!y.current&&l&&l[0]!=null&&(y.current=!0,l[0]>0&&c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:["\u25A0 Generated task with ",l[0]," checkpoints"]})}))),t&&n&&!L.current&&(L.current=!0,c((0,r.jsx)(o,{color:i.purple,children:"\u2501\u2501 Bifurcated into "+n.length+" flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"}))),t){let g=e.flatMap((x,f)=>{let m=x.children??[];return!O.current.has(f)&&m.length>0&&(O.current.add(f),c((0,r.jsx)(o,{color:i.purple,children:" Flow "+(f+1)+": "+(n?.[f]??"")})),l?.[f]!=null&&l[f]>0&&!h.current.has(f)&&(h.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",l[f]," checkpoints"]})})))),l?.[f]!=null&&l[f]>0&&O.current.has(f)&&!h.current.has(f)&&(h.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsxs)(o,{color:i.dim,children:[" \u25AA Generated task with ",l[f]," checkpoints"]})}))),m});for(let x of g){let f=`${x.childId??"p"}-${x.index}-${x.objective}`;if(!!x.branchObjective){d.current.has(f)||(d.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:{...x,children:void 0}})})));for(let $ of x.children??[]){let w=`child-${x.childId??"p"}-${x.index}-${$.childId??"p"}-${$.index}-${$.objective}`;d.current.has(w)||($.status==="passed"||$.status==="failed"||$.status==="stopped")&&(d.current.add(w),c((0,r.jsx)(s,{marginLeft:4,children:(0,r.jsx)(P,{step:$})})))}continue}d.current.has(f)||(x.status==="passed"||x.status==="failed"||x.status==="stopped")&&(d.current.add(f),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:x})})))}}else for(let g of e){let x=`${g.index}-${g.objective}`,f=!!g.branchObjective;f&&!d.current.has(x)&&(d.current.add(x),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:{...g,children:void 0}})})));for(let m of g.children??[]){let $=`child-${g.index}-${m.childId??"p"}-${m.index}-${m.objective}`;d.current.has($)||(m.status==="passed"||m.status==="failed"||m.status==="stopped")&&(d.current.add($),c((0,r.jsx)(s,{marginLeft:4,children:(0,r.jsx)(P,{step:m})})))}!f&&!d.current.has(x)&&(g.status==="passed"||g.status==="failed"||g.status==="stopped")&&(d.current.add(x),c((0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:{...g,children:void 0}})})))}d.current.size>p&&xe(g=>g+1)},[e,c,t,n,l]);let G=[];if(u&&!t)for(let p of e)ae.current.has(p.index)||G.push(p);else if(c&&!u)if(t)for(let p of e){let g=p.children??[],x=[];for(let f of g){let m=`${f.childId??"p"}-${f.index}-${f.objective}`,$=d.current.has(m);if(f.branchObjective){let w=(f.children??[]).filter(Q=>{let ue=`child-${f.childId??"p"}-${f.index}-${Q.childId??"p"}-${Q.index}-${Q.objective}`;return!d.current.has(ue)});(!$||w.length>0)&&x.push({...f,children:w})}else $||x.push(f)}x.length>0&&G.push({...p,children:x})}else for(let p of e){let g=`${p.index}-${p.objective}`,x=d.current.has(g),f=(p.children??[]).filter(m=>{let $=`child-${p.index}-${m.childId??"p"}-${m.index}-${m.objective}`;return!d.current.has($)});x?f.length>0&&G.push({...p,children:f}):G.push({...p,children:f})}if(!u){let p=c?G:e,g=le(p),x=ge(g,T);return(0,r.jsxs)(s,{flexDirection:"column",children:[t?c?p.length>0?(0,r.jsx)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:p.map((m,$)=>(0,r.jsx)(s,{flexDirection:"column",marginTop:$>0?1:0,children:m.children&&m.children.length>0?m.children.map(w=>{if(z(w))return null;let Q=!!w.branchObjective,ue=`${w.childId??"p"}-${w.index}-${w.objective}`,Ke=d.current.has(ue);return Q?(0,r.jsxs)(s,{flexDirection:"column",children:[!Ke&&(0,r.jsx)(P,{step:{...w,children:void 0}}),(w.children??[]).filter(Z=>!z(Z)).map(Z=>(0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:Z})},`f${$}-${w.index}-${Z.childId??"p"}-${Z.index}`))]},`f${$}-host-${w.childId??"p"}-${w.index}`):(0,r.jsx)(P,{step:w},`f${$}-${w.childId??"p"}-${w.index}`)}):m.status==="pending"&&(0,r.jsx)(o,{color:i.dim,children:" \u25CB Waiting..."})},$))}):null:(0,r.jsx)(fe,{steps:e,flows:n,cmInitCounts:l,renderStep:(m,$)=>z(m)?null:(0,r.jsx)(P,{step:m},$)}):(0,r.jsxs)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[!c&&l&&l[0]!=null&&(0,r.jsxs)(o,{color:i.dim,children:["\u25AA Generated task with ",l[0]," checkpoints"]}),p.filter(m=>!(m.status==="running"&&(!m.children||m.children.length===0))).map(m=>{let $=`${m.index}-${m.objective}`;return c&&d.current.has($)?(0,r.jsx)(s,{flexDirection:"column",children:(m.children??[]).filter(w=>!z(w)).map(w=>(0,r.jsx)(s,{marginLeft:2,children:(0,r.jsx)(P,{step:w})},`${w.childId??"p"}-${w.index}`))},`branch-children-${m.index}`):(0,r.jsx)(P,{step:m},m.index)})]}),(0,r.jsx)(se,{activity:x,describe:v,describeVisible:S}),B.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}if(t){let p=le(e),g=ge(p,T);return(0,r.jsxs)(s,{flexDirection:"column",children:[(0,r.jsx)(fe,{steps:e,flows:n,cmInitCounts:l,renderStep:(x,f)=>z(x)?null:(0,r.jsx)(P,{step:x},f)}),(0,r.jsx)(se,{activity:g,describe:v,describeVisible:S}),B.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}let Ne=le(G),Ge=ge(Ne,T),Re=Fe(G);return(0,r.jsxs)(s,{flexDirection:"column",children:[Re.length>0&&(0,r.jsx)(s,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:Re.map(p=>(0,r.jsx)(P,{step:p},p.index))}),(0,r.jsx)(se,{activity:Ge,describe:v,describeVisible:S}),B.length>0&&(0,r.jsx)(ie,{currentStep:Y,maxSteps:a,elapsed:ce,status:N})]})}var W=R(k(),1);function Ae({runner:e,runKey:t,onStepCommit:n}){let l=Ie({isRunning:e.isRunning,bifurcationInfo:e.bifurcationInfo,steps:e.steps,cmInitCounts:e.cmInitCounts,replayInfo:e.replayInfo});return(0,W.jsxs)(W.Fragment,{children:[l&&(0,W.jsx)(ke,{label:l.label,hasBifurcation:l.hasBifurcation}),e.isRunning&&e.steps.length>0&&(0,W.jsx)(_e,{steps:e.steps,bifurcated:!!e.bifurcationInfo&&!e.bifurcationInfo.isSingleFlow,flows:e.bifurcationInfo?.flows,cmInitCounts:e.cmInitCounts,maxSteps:e.maxSteps,onStepCommit:n},`run-${t}`)]})}var D=R(k(),1),Ye=64;function Je(e){return e.split(`
|
|
4
4
|
`).map(t=>t.replace(/^[-–•]\s*/,"").trim()).filter(t=>t.length>0)}function qe({status:e,summary:t,duration:n,steps:l,stepsPassed:a,stepsFailed:u,reason:c,creditsConsumed:v}){let S=e==="passed",T=S?i.green:i.red,d=S?"\u2713":"\u2717",L=e.toUpperCase(),O=a??(S?l:Math.max(0,l-1)),y=u??(S?0:1),h=y>0?`${l} steps (${O} passed, ${y} failed)`:`${l} steps`,b=n<60?`${n.toFixed(1)}s`:`${Math.floor(n/60)}m ${Math.round(n%60)}s`,B=Je(t);return(0,D.jsx)(s,{flexDirection:"column",marginTop:1,children:(0,D.jsxs)(s,{borderStyle:"round",borderColor:T,flexDirection:"column",paddingX:2,paddingY:1,width:Ye+6,children:[(0,D.jsxs)(s,{flexDirection:"column",children:[(0,D.jsxs)(o,{bold:!0,color:T,children:[d," ",L]}),(0,D.jsxs)(o,{color:i.dim,wrap:"wrap",children:[h," \xB7 ",b,typeof v=="number"&&v>0?` \xB7 ${parseFloat(v.toFixed(4))} credits`:""]})]}),B.length>0&&(0,D.jsx)(s,{flexDirection:"column",marginTop:1,marginLeft:1,children:B.map((F,M)=>(0,D.jsxs)(s,{marginBottom:M<B.length-1?1:0,children:[(0,D.jsx)(o,{color:i.orange,children:"\u25CF "}),(0,D.jsx)(s,{flexShrink:1,children:(0,D.jsx)(o,{wrap:"wrap",children:F})})]},M))}),c&&!S&&(0,D.jsx)(s,{marginTop:1,children:(0,D.jsxs)(o,{color:i.red,wrap:"wrap",children:["Reason: ",c]})})]})})}var j=R(k(),1);function Me({message:e,code:t,remediation:n,docsUrl:l}){return(0,j.jsx)(ve,{title:"Error",variant:"error",children:(0,j.jsxs)(s,{flexDirection:"column",paddingY:1,children:[(0,j.jsxs)(o,{color:i.red,bold:!0,children:[" \u2717 ",e]}),t&&(0,j.jsxs)(s,{marginTop:0,marginLeft:5,children:[(0,j.jsx)(o,{color:i.muted,children:"Code: "}),(0,j.jsx)(o,{color:i.dim,children:t})]}),n&&(0,j.jsxs)(s,{flexDirection:"column",marginTop:1,marginLeft:5,children:[(0,j.jsx)(o,{color:i.green,bold:!0,children:"Fix:"}),(0,j.jsxs)(o,{color:i.orange,children:["$ ",n]})]}),l&&(0,j.jsxs)(s,{marginTop:1,marginLeft:5,children:[(0,j.jsx)(o,{color:i.muted,children:"Docs: "}),(0,j.jsx)(o,{color:i.orange,underline:!0,children:l})]})]})})}var E=R(k(),1);function un(e){let{exit:t}=Te(),{append:n}=ye(),l=(0,A.useRef)(!1);(0,A.useEffect)(()=>{l.current||(l.current=!0,n((0,E.jsx)(s,{flexDirection:"column",marginBottom:1,children:(0,E.jsxs)(s,{borderStyle:"round",borderColor:"#dc4e08",paddingX:2,children:[(0,E.jsx)(o,{color:"#ff9500",bold:!0,children:"KaneAI CLI"}),(0,E.jsx)(o,{color:i.dim,children:" \u2502 "}),(0,E.jsx)(o,{color:i.orange,children:e.topBanner.model}),(0,E.jsx)(o,{color:i.dim,children:" \u2502 "}),(0,E.jsx)(o,{color:i.dim,children:e.topBanner.auth})]})})),n((0,E.jsx)(Qe,{data:e.globalConfig})),e.priorAttemptRollup&&n((0,E.jsx)(o,{color:i.dim,children:` \u21B3 replayed ${e.priorAttemptRollup.startIdx}..${e.priorAttemptRollup.endIdx-1} (${e.priorAttemptRollup.count} steps, from prior attempt)`})))},[]);let a=(0,A.useRef)(null),u=(0,A.useCallback)(async y=>{let h=await e.getNextStep(y);return h?(a.current=h,h.config):(a.current=null,null)},[e]),c=(0,A.useCallback)((y,h)=>{let b=a.current;if(!b)return;let B=b.mode==="replay"?"cyan":"#dc4e08",F=b.modeReason?` (${b.modeReason})`:"",M=b.perStepOverrides?Object.entries(b.perStepOverrides):[];n((0,E.jsxs)(s,{flexDirection:"column",marginBottom:0,children:[(0,E.jsxs)(o,{children:[(0,E.jsxs)(o,{color:i.dim,children:[b.banner.stepLabel," "]}),(0,E.jsxs)(o,{color:B,children:["[",b.mode,"]"]}),(0,E.jsx)(o,{color:i.dim,children:F})]}),(0,E.jsx)(o,{color:i.dim,children:b.banner.objective}),M.length>0&&(0,E.jsxs)(o,{color:i.dim,children:["overrides: ",M.map(([X,Y])=>`${X}=${Y}`).join(", ")]})]}))},[n]),v=(0,A.useRef)(0),S=(0,A.useRef)(!1),T=(0,A.useCallback)((y,h)=>(y.hadError?n((0,E.jsx)(Me,{message:y.reason??"Runner error",code:"RUNNER_ERROR"})):n((0,E.jsx)(s,{flexDirection:"column",marginBottom:1,children:(0,E.jsx)(qe,{status:y.status,summary:y.runEnd?.summary??"",duration:y.runEnd?.duration??0,steps:y.stepsTotal,stepsPassed:y.stepsPassed,stepsFailed:y.stepsFailed,reason:y.runEnd?.reason,creditsConsumed:y.runEnd?.credits_consumed})})),e.onStepEnd?.(y,h)??!0),[n,e]),d=we({getNextConfig:u,onStepStart:c,onStepEnd:T,onAllComplete:()=>{e.onAllComplete(),e.exitOnComplete!==!1&&setImmediate(()=>t())},screenshotDispatcher:e.screenshotDispatcher,stepLogger:e.stepLogger,onReasoning:e.onReasoning,onStepComplete:e.onStepComplete,spawnOpts:e.spawnOpts}),L=250,O=5e3;return Se((y,h)=>{if(h.ctrl&&y==="c"){let b=Date.now(),B=b-v.current;if(B<L)return;S.current&&B<O?(d.cancel(),e.onCancel?.(),e.exitOnComplete!==!1&&setImmediate(()=>t())):(S.current=!0,n((0,E.jsx)(o,{color:"yellow",children:"press Ctrl+C again to cancel run"}))),v.current=b}}),(0,E.jsx)(s,{flexDirection:"column",children:d.phase!=="done"&&(0,E.jsx)(Ae,{runner:d.runner,runKey:d.currentStepIndex,onStepCommit:n})})}function Qe({data:e}){return(0,E.jsx)(Be,{title:"test.md run",titleColor:"#ff9500",borderColor:i.dim,rows:[{label:"source",value:e.source},{label:"steps",value:`${e.steps.total} (${e.steps.replay} replay, ${e.steps.author} author per walker)`},{label:"model",value:e.model},{label:"viewport",value:`${e.viewport.width} x ${e.viewport.height}`},{label:"chrome",value:e.chrome},{label:"session",value:e.session},{label:"variables",value:`${e.variables.count} (${e.variables.secrets} secret)`},{label:"flags",value:e.flags.length>0?e.flags.join(" "):"(none)"}]})}export{_e as a,ke as b,Ie as c,de as d,qe as e,Me as f,un as g};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{d as W}from"./chunk-MSGW4JDG.js";import{d as U,e as F}from"./chunk-4JOD47QI.js";import{a as H}from"./chunk-
|
|
3
|
-
`));this.deviceClass=s;this.name="DepsInstallRequiredError"}};function _(i){return i>=1024*1024?`${Math.ceil(i/(1024*1024))} MB`:`${i} bytes`}function at(i){let t=i/1048576;return t>=10?`${Math.round(t)} MB/s`:t>=1?`${t.toFixed(1)} MB/s`:`${Math.max(1,Math.round(i/1024))} KB/s`}function lt(i){let t=Math.max(1,Math.round(i));return t<60?`~${t}s left`:`~${Math.floor(t/60)}m ${t%60}s left`}var K=8*1024*1024,ct=8;function ut(i){if(!Number.isFinite(i)||i<2*K)return null;let t=Math.min(ct,Math.floor(i/K)),s=Math.ceil(i/t),e=[];for(let n=0;n<i;n+=s)e.push({start:n,end:Math.min(n+s,i)-1});return e}async function L(i,t){let s=i.body;if(!s||typeof s.getReader!="function"){let c=new Uint8Array(await i.arrayBuffer());return t?.(c.length),c}let e=s.getReader(),n=[],r=0;for(;;){let{done:c,value:h}=await e.read();if(c)break;h&&(n.push(h),r+=h.length,t?.(h.length))}let o=new Uint8Array(r),a=0;for(let c of n)o.set(c,a),a+=c.length;return o}var z=3,dt=3e4,k=class extends Error{};async function pt(i,t,s,e,n,r=dt){let o=new Uint8Array(s),a=0,c=new AbortController,h=null,b=!1;try{await Promise.all(e.map(async(f,M)=>{let P=0,V=d=>{P+=d,a+=d,n?.(a)},T=()=>{a=Math.max(0,a-P),P=0},R=null;for(let d=0;d<z;d+=1){if(c.signal.aborted)return;let u=new AbortController,m=()=>u.abort();c.signal.addEventListener("abort",m,{once:!0});let w=!1,g=null,$=()=>{g&&clearTimeout(g),g=setTimeout(()=>{w=!0,u.abort()},r)};try{$();let p=await i(t,{headers:{Range:`bytes=${f.start}-${f.end}`},signal:u.signal});if(typeof p.body?.getReader!="function"&&g&&(clearTimeout(g),g=null),!p.ok)throw new k(`Could not download ${t}: HTTP ${p.status}`);if(p.status!==206){b=!0,M===0?h=await L(p,I=>{$(),V(I)}):await(p.body?.cancel().catch(()=>{})??Promise.resolve());return}let D=f.end-f.start+1,E=await L(p,I=>{$(),V(I)});if(E.length!==D)throw new Error(`range ${f.start}-${f.end} returned ${E.length} bytes (expected ${D})`);o.set(E,f.start);return}catch(p){if(p instanceof k)throw p;if(c.signal.aborted)return;T(),R=w?new Error(`no data for ${Math.round(r/1e3)}s`):p instanceof Error?p:new Error(String(p))}finally{g&&clearTimeout(g),c.signal.removeEventListener("abort",m)}}throw new Error(`Could not download ${t}: range ${f.start}-${f.end} failed after ${z} attempts (${R?.message??"unknown error"}) \u2014 check your network and rerun \`kane-cli doctor --target <emulator|simulator> --install\`.`)}))}catch(f){throw c.abort(),f}return h||(b?null:o)}async function ht(i,t,s,e,n){let r=ut(s);if(r){let c=await pt(i,t,s,r,e,n?.stallMs);if(c)return c}let o=await i(t);if(!o.ok)throw new Error(`Could not download ${t}: HTTP ${o.status}`);let a=0;return L(o,e&&(c=>{a+=c,e(a)}))}function ft(i){return Y("sha256").update(i).digest("hex")}function mt(i,t){let s=X(i,t);return s!==""&&!s.startsWith(`..${it}`)&&s!==".."&&!nt(s)}async function A(i){try{return await Q(i),!0}catch{return!1}}function wt(){return{home:tt(),os:st,arch:et,cliVersion:H,nodeModuleVersion:process.versions.modules,fetch,resolveBundle:async i=>(await import("./deps-resolve-
|
|
2
|
+
import{d as W}from"./chunk-MSGW4JDG.js";import{d as U,e as F}from"./chunk-4JOD47QI.js";import{a as H}from"./chunk-NJJQL54J.js";import{createHash as Y}from"crypto";import{access as Q,mkdir as S,mkdtemp as Z,readdir as O,readFile as y,rename as N,rm as v,writeFile as x}from"fs/promises";import{homedir as tt}from"os";import{arch as et,platform as st}from"process";import{dirname as C,isAbsolute as nt,join as l,relative as X,resolve as rt,sep as it}from"path";var q=1,ot={emulator:"emulator",simulator:"simulator"};function Pt(i){return ot[i.kind]??null}var j=class extends Error{constructor(s,e,n){super([`Managed mobile dependencies for ${s} are not installed.`,`- kaneai-mobile-deps ${s} ${e.bundleVersion}: ${e.url} (${_(e.bytes)})`,`Destination: ${n}`,`Run \`kane-cli doctor --target ${s} --install\` to download it.`].join(`
|
|
3
|
+
`));this.deviceClass=s;this.name="DepsInstallRequiredError"}};function _(i){return i>=1024*1024?`${Math.ceil(i/(1024*1024))} MB`:`${i} bytes`}function at(i){let t=i/1048576;return t>=10?`${Math.round(t)} MB/s`:t>=1?`${t.toFixed(1)} MB/s`:`${Math.max(1,Math.round(i/1024))} KB/s`}function lt(i){let t=Math.max(1,Math.round(i));return t<60?`~${t}s left`:`~${Math.floor(t/60)}m ${t%60}s left`}var K=8*1024*1024,ct=8;function ut(i){if(!Number.isFinite(i)||i<2*K)return null;let t=Math.min(ct,Math.floor(i/K)),s=Math.ceil(i/t),e=[];for(let n=0;n<i;n+=s)e.push({start:n,end:Math.min(n+s,i)-1});return e}async function L(i,t){let s=i.body;if(!s||typeof s.getReader!="function"){let c=new Uint8Array(await i.arrayBuffer());return t?.(c.length),c}let e=s.getReader(),n=[],r=0;for(;;){let{done:c,value:h}=await e.read();if(c)break;h&&(n.push(h),r+=h.length,t?.(h.length))}let o=new Uint8Array(r),a=0;for(let c of n)o.set(c,a),a+=c.length;return o}var z=3,dt=3e4,k=class extends Error{};async function pt(i,t,s,e,n,r=dt){let o=new Uint8Array(s),a=0,c=new AbortController,h=null,b=!1;try{await Promise.all(e.map(async(f,M)=>{let P=0,V=d=>{P+=d,a+=d,n?.(a)},T=()=>{a=Math.max(0,a-P),P=0},R=null;for(let d=0;d<z;d+=1){if(c.signal.aborted)return;let u=new AbortController,m=()=>u.abort();c.signal.addEventListener("abort",m,{once:!0});let w=!1,g=null,$=()=>{g&&clearTimeout(g),g=setTimeout(()=>{w=!0,u.abort()},r)};try{$();let p=await i(t,{headers:{Range:`bytes=${f.start}-${f.end}`},signal:u.signal});if(typeof p.body?.getReader!="function"&&g&&(clearTimeout(g),g=null),!p.ok)throw new k(`Could not download ${t}: HTTP ${p.status}`);if(p.status!==206){b=!0,M===0?h=await L(p,I=>{$(),V(I)}):await(p.body?.cancel().catch(()=>{})??Promise.resolve());return}let D=f.end-f.start+1,E=await L(p,I=>{$(),V(I)});if(E.length!==D)throw new Error(`range ${f.start}-${f.end} returned ${E.length} bytes (expected ${D})`);o.set(E,f.start);return}catch(p){if(p instanceof k)throw p;if(c.signal.aborted)return;T(),R=w?new Error(`no data for ${Math.round(r/1e3)}s`):p instanceof Error?p:new Error(String(p))}finally{g&&clearTimeout(g),c.signal.removeEventListener("abort",m)}}throw new Error(`Could not download ${t}: range ${f.start}-${f.end} failed after ${z} attempts (${R?.message??"unknown error"}) \u2014 check your network and rerun \`kane-cli doctor --target <emulator|simulator> --install\`.`)}))}catch(f){throw c.abort(),f}return h||(b?null:o)}async function ht(i,t,s,e,n){let r=ut(s);if(r){let c=await pt(i,t,s,r,e,n?.stallMs);if(c)return c}let o=await i(t);if(!o.ok)throw new Error(`Could not download ${t}: HTTP ${o.status}`);let a=0;return L(o,e&&(c=>{a+=c,e(a)}))}function ft(i){return Y("sha256").update(i).digest("hex")}function mt(i,t){let s=X(i,t);return s!==""&&!s.startsWith(`..${it}`)&&s!==".."&&!nt(s)}async function A(i){try{return await Q(i),!0}catch{return!1}}function wt(){return{home:tt(),os:st,arch:et,cliVersion:H,nodeModuleVersion:process.versions.modules,fetch,resolveBundle:async i=>(await import("./deps-resolve-62XK3LKV.js")).controllerResolveBundle()(i),exec:U,now:()=>new Date,wait:F,processAlive:i=>{try{return process.kill(i,0),!0}catch{return!1}}}}var B=class extends Error{constructor(s,e,n){super(`No managed mobile dependencies are published for ${s} (kane-cli ${e}).
|
|
4
4
|
This is a packaging gap, not something to install locally \u2014 report it, or pass --appium-url to use an Appium server you manage yourself.`);this.coordinate=s;this.cause=n;this.name="NoPublishedBundleError"}},J=class i{deps;constructor(t={}){this.deps={...wt(),...t}}mobileRoot(){return l(this.deps.home,".testmuai","kaneai","mobile")}depsRoot(){return l(this.mobileRoot(),"deps")}classRoot(t,s){return l(this.depsRoot(),s,t)}resolveCacheFile(){return l(this.depsRoot(),"resolve-cache.json")}resolveCacheKey(t){return`${this.deps.cliVersion}|${this.deps.os}-${this.deps.arch}-${t}`}static RESOLVE_CACHE_TTL_MS=1440*60*1e3;async readCachedWantedVersion(t){try{let e=JSON.parse(await y(this.resolveCacheFile(),"utf8"))[this.resolveCacheKey(t)];if(!e?.bundleVersion||!e.fetchedAt)return null;let n=this.deps.now().getTime()-new Date(e.fetchedAt).getTime();return n>=0&&n<i.RESOLVE_CACHE_TTL_MS?e.bundleVersion:null}catch{return null}}async writeResolveCache(t,s){try{let e={};try{e=JSON.parse(await y(this.resolveCacheFile(),"utf8"))}catch{}e[this.resolveCacheKey(t)]={bundleVersion:s,fetchedAt:this.deps.now().toISOString()},await S(this.depsRoot(),{recursive:!0}),await x(this.resolveCacheFile(),`${JSON.stringify(e,null,2)}
|
|
5
5
|
`)}catch{}}async warmResolveCache(t){if(await this.readCachedWantedVersion(t)===null)try{await this.resolveOrExplain(t)}catch{}}paths(t,s){let e=this.classRoot(t,s);return{root:e,appium:l(e,"appium"),appiumHome:l(e,"appium-home"),platformTools:l(e,"platform-tools"),wdaDir:l(e,"wda","Build","Products","Debug-iphonesimulator"),iwdpBinDir:l(e,"bin"),installManifest:l(e,"install-manifest.json")}}async status(t,s){s||(s=await this.readCachedWantedVersion(t)??void 0);let e=[];try{e=await O(this.depsRoot())}catch{}s&&(e=e.filter(c=>c===s));let n=null;for(let c of e){let h=this.classRoot(t,c),b=null;try{b=JSON.parse(await y(l(h,"install-manifest.json"),"utf8"))}catch{continue}b.schemaVersion===q&&(!s&&b.cliVersion!==this.deps.cliVersion||(!n||b.installedAt>n.manifest.installedAt)&&(n={manifest:b,root:h}))}if(!n)return{class:t,installed:!1};let r=this.paths(t,n.manifest.bundleVersion),o=[l(r.appium,"node_modules","appium","index.js")];t==="emulator"&&o.push(l(r.platformTools,this.deps.os==="win32"?"adb.exe":"adb")),t==="simulator"&&o.push(l(r.wdaDir,"WebDriverAgentRunner-Runner.app"));for(let c of o)if(!await A(c))return{class:t,installed:!1,version:n.manifest.bundleVersion,root:n.root,corrupt:`a bundle component is missing from disk (${X(n.root,c)})`};let a=await this.postInstallDrifted(r);return{class:t,installed:!0,version:n.manifest.bundleVersion,root:n.root,...a?{needsRepair:a}:{}}}async postInstallDrifted(t){let s=l(t.appiumHome,"node_modules",".cache","appium","extensions.yaml");if(!await A(s))return!1;let e=await y(s,"utf8");for(let n of e.split(`
|
|
6
6
|
`)){let r=/^\s*installPath:\s*(.+?)\s*$/.exec(n);if(r&&!r[1].startsWith(t.appiumHome))return!0}return!1}async environment(t){let s=await this.status(t);if(!s.installed||!s.version)return{dirs:[]};let e=this.paths(t,s.version),n=[],r={dirs:n,appiumHome:e.appiumHome};return t!=="simulator"&&(n.push(e.platformTools),r.platformToolsDir=e.platformTools),n.push(l(e.appium,"node_modules",".bin")),t==="simulator"&&(n.push(e.iwdpBinDir),r.wdaDir=e.wdaDir,r.wdaRoot=l(e.root,"wda"),r.iwdpBinDir=e.iwdpBinDir),r}async ensure(t,s){let e,n;try{e=await this.resolveOrExplain(t)}catch(a){n=a}let r=await this.status(t,e?.bundleVersion);if(r.installed&&!r.needsRepair)return e&&r.version&&await this.adoptInstall(t,r.version),r;if(!e)throw n;if(r.installed&&r.needsRepair&&r.version){let a=this.paths(t,r.version);return await this.withInstallLock(async()=>{await this.postInstall(a.root,a,s.onProgress)}),await this.adoptInstall(t,r.version),this.status(t,e.bundleVersion)}let o=e;if(!s.automatic&&!s.approved)throw new j(t,o,this.classRoot(t,o.bundleVersion));return await this.withInstallLock(async()=>{(await this.status(t,o.bundleVersion)).installed||await this.install(t,o,s.onProgress)}),this.status(t,o.bundleVersion)}async adoptInstall(t,s){try{let e=this.paths(t,s).installManifest,n=JSON.parse(await y(e,"utf8"));if(n.cliVersion===this.deps.cliVersion)return;n.cliVersion=this.deps.cliVersion;let r=l(C(e),`install-manifest-${process.pid}.json`);await x(r,`${JSON.stringify(n,null,2)}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{e as U}from"./chunk-EHN5HTUD.js";import{b as J,c as w,e as q,i as z,j as Q,k as X,l as Y,m as T}from"./chunk-T4OJX2GZ.js";import{a as G}from"./chunk-KRL2BDI5.js";import{copyFileSync as le,cpSync as pe,existsSync as $,mkdirSync as ue,readFileSync as Oe,readdirSync as ce,rmSync as Te,writeFileSync as Ae}from"fs";import{dirname as _e,isAbsolute as Ee,join as y,relative as Le,resolve as Ke}from"path";import{writeFileSync as ge,mkdirSync as Se,readFileSync as ye}from"fs";import{dirname as Re,basename as Z}from"path";function te(e){let t=e.outPath??w(e.sourcePath);Se(Re(t),{recursive:!0});let s=[];s.push("---"),s.push(`test: ../${Z(e.sourcePath)}`),s.push(`status: ${e.overallStatus}`),s.push(`started: ${e.startedISO}`),s.push(`duration_s: ${e.durationS}`),s.push(`session_id: ${e.sessionId}`),s.push("---",""),s.push(`# ${e.title??Z(e.sourcePath)} \u2014 Result`,"");for(let l=0;l<e.rootSteps.length;l++){let d=e.rootSteps[l],r=e.outcomes.find(u=>u.rootStepIndex===l+1);if(s.push(xe(d,r)),r?.stepMd5&&s.push(`md5: ${r.stepMd5}`),r?.status==="failed"&&r.reason&&s.push(`Reason: ${r.reason}`),r?.softFailures?.length)for(let u of r.softFailures){let o=u.reason?`: ${u.reason}`:"";s.push(`\u26A0 optional sub-step ${u.subStepIndex} failed${o}`)}d.body.kind==="objective"&&r?.status!=="skipped"&&s.push(d.body.text),s.push("")}return ge(t,s.join(`
|
|
3
|
+
`),"utf8"),t}function xe(e,t){if(!t)return`## ${e.heading} (no outcome)`;let s=t.duration_s!=null?`${t.duration_s}s`:"\u2014";if(t.status==="skipped")return`## ${e.heading} \u23ED skipped`;let l=t.softFailed?" (optional)":"";if(t.refKind&&t.status==="passed"){let d=t.helperResultRelPath?` \u2192 ${t.helperResultRelPath}`:"";return`## ${e.heading} \u2713 passed (via @${t.refKind} ${t.refLabel} \u2014 ${t.inlinedCount} inlined steps, ${s}${d})`}if(t.refKind&&t.status==="failed"){let d=t.failedSubStepIndex&&t.failedSubStepIndex.length>0?` \u2014 at sub-step ${t.failedSubStepIndex.join(" \u2192 sub-step ")}`:"",r=t.helperResultRelPath?` \u2192 ${t.helperResultRelPath}`:"";return`## ${e.heading} \u2717 failed${l} (via @${t.refKind} ${t.refLabel}${d}, ${s}${r})`}return t.status==="passed"?`## ${e.heading} \u2713 passed (${s})`:`## ${e.heading} \u2717 failed${l} (${s})`}var Ie=/^##\s+(.+?)\s+(✓ passed|✗ failed(?:\s+\(optional\))?|⏭ skipped)(?:\s+\((.*)\))?\s*$/,ke=/via\s+@\w+\s+(\S+).*?(?:→\s+(\S+))?\s*$/,be=/^md5:\s+([a-f0-9]{32})\s*$/;function ee(e,t){for(let s=t;s<e.length&&!/^##\s/.test(e[s]);s++){if(e[s].trim()==="")continue;let l=be.exec(e[s]);return l?l[1]:null}return null}function D(e){let s=ye(e,"utf8").split(`
|
|
4
|
+
`),l="passed";if(s[0]?.trim()==="---")for(let r=1;r<s.length&&s[r].trim()!=="---";r++){let u=/^status:\s+(passed|failed|interrupted)\s*$/.exec(s[r]);u&&(l=u[1])}let d=[];for(let r=0;r<s.length;r++){let u=Ie.exec(s[r]);if(!u)continue;let o=u[1],n=u[2],c=u[3]??"",m=n.startsWith("\u2713")?"passed":n.startsWith("\u23ED")?"skipped":"failed";if(/via\s+@/.test(c)){let f=ke.exec(c),v=f?.[1]??"",x=f?.[2]??null;d.push({kind:"import",heading:o,status:m,md5:ee(s,r+1),importPath:v,helperResultRelPath:x})}else d.push({kind:"objective",heading:o,status:m,md5:ee(s,r+1)})}return{overallStatus:l,steps:d}}import{copyFileSync as se,existsSync as C,mkdirSync as ve,writeFileSync as ne,promises as Ue}from"fs";import{join as M,dirname as re,basename as Pe}from"path";async function ie(e){for(let t=0;t<e.totalRunDirs;t++){let s=e.runIndex+t,l=M(e.sessionDir,"runs",String(s)),d=M(e.stagingStepDir,"flows",String(t));ve(d,{recursive:!0});let r=M(d,"actions.ndjson");if(e.packTestDir){let n=M(e.packTestDir,"logs",`${s}-actions.ndjson`);if(C(n)){se(n,r);continue}let c=re(re(e.packTestDir)),m=Pe(e.packTestDir),R=C(c)?await U(c,`tests/${m}/logs/${s}-actions.ndjson`).catch(()=>null):null;ne(r,R??"");continue}let u=[M(l,"run-test","actions.ndjson"),M(l,"actions.ndjson")],o=!1;for(let n of u)if(C(n)){se(n,r),o=!0;break}o||ne(r,"")}}import{existsSync as A,readdirSync as we}from"fs";import{dirname as $e,join as j,basename as H}from"path";function et(e,t){let s=[];return e.steps.forEach((l,d)=>{let r=t[d];!l.replayOnly||!r||r.kind!=="author"||s.push({flatIndex:l.flatIndex,file:l.owningFile,heading:l.trace[l.trace.length-1].heading,kind:l.replayOnly,reason:r.reason})}),s}function tt(e){let t=[],s=new Set,l=new Map;function d(n){if(l.has(n))return l.get(n);let c=w(n),m=A(c)?D(c):null;return l.set(n,m),m}let r=new Map;function u(n){if(r.has(n))return r.get(n);let c=j(n,"Result.md"),m=A(c)?D(c):null;return r.set(n,m),m}function o(n){for(let c=1;c<n.trace.length;c++){let m=n.trace[c-1],R=d(m.file);if(!R)continue;let f=R.steps[m.stepIndex-1];if(f){if(f.kind!=="import")return{kind:"author",reason:"structure-mismatch"};if(H(f.importPath)!==H(n.trace[c].file))return{kind:"author",reason:"structure-mismatch"};if(f.md5!=null&&f.md5!==m.rowMd5)return{kind:"author",reason:"structure-mismatch"}}}return null}for(let n of e.steps){let c=n.trace[n.trace.length-1].stepIndex,m=n.replayOnly,R=s.has(n.owningFile);for(let g=0;g<n.trace.length-1&&!R;g++)s.has(n.trace[g].file)&&(R=!0);if(R&&!m){t.push({kind:"author",reason:d(n.owningFile)===null?"no-result-md":"downstream-of-divergence"});continue}let f=o(n);if(f){for(let g=0;g<n.trace.length;g++)s.add(n.trace[g].file);if(!m){t.push(f);continue}}let v=d(n.owningFile),x;if(v===null&&n.trace.length>1){let g=W(n.trace);x=oe(n,u(g),c,g)}else x=oe(n,v,c);if(m&&x.kind==="replay"&&(x={...x,replayOnly:m}),t.push(x),x.kind==="author"){s.add(n.owningFile);for(let g=0;g<n.trace.length-1;g++)s.add(n.trace[g].file)}}return t}function oe(e,t,s,l=null){if(!t)return{kind:"author",reason:"no-result-md"};let d=t.steps[s-1];if(!d)return{kind:"author",reason:"no-result-md"};if(d.kind!=="objective")return{kind:"author",reason:"structure-mismatch"};if(d.status!=="passed")return{kind:"author",reason:"recorded-failed"};let r=T(e);if(r!==d.md5)return{kind:"author",reason:"md5-mismatch"};let u=l===null?X(e.owningFile,s,r.slice(0,8)):j(l,".internal","steps",`${s}-${r.slice(0,8)}`),o=De(u);return o===0?{kind:"author",reason:"missing-recording"}:{kind:"replay",recordingDir:u,flowCount:o}}function De(e){let t=j(e,"flows");if(!A(t))return 0;let s;try{s=we(t,{withFileTypes:!0}).filter(d=>d.isDirectory()&&/^\d+$/.test(d.name)).map(d=>parseInt(d.name,10))}catch{return 0}if(s.length===0)return 0;let l=Math.max(...s);for(let d=0;d<=l;d++)if(!A(j(t,String(d),"actions.ndjson")))return 0;return l+1}function st(e){return e.some(t=>t.kind==="author")}function nt(e){for(let t=0;t<e.length;t++)if(e[t].kind==="author")return t;return e.length}function W(e){let t=r=>{let u=H(r);return u.endsWith("_test.md")?u.slice(0,-8):u.endsWith(".md")?u.slice(0,-3):u},s=t(e[0].file),l=t(e[e.length-1].file),d=e.slice(0,-1).map(r=>String(r.stepIndex));return j($e(e[e.length-1].file),`helper-output-${l}-${s}-${d.join("-")}`)}function rt(e){return Array.from({length:e.flowCount},(t,s)=>j(e.recordingDir,"flows",String(s),"actions.ndjson"))}import{existsSync as ae,mkdirSync as Me,rmSync as je,cpSync as Fe}from"fs";function de(e,t){ae(e)&&(ae(t)&&je(t,{recursive:!0,force:!0}),Me(t,{recursive:!0}),Fe(e,t,{recursive:!0}))}async function St(e){let t=new Map;for(let o of e.stepRunRecords)t.set(o.testmdStepIndex,o);let s=e.authoredFlatIdx??new Set,l=[],d=[],r=new Map,u=o=>{if(r.has(o))return r.get(o);let n=y(o,"Result.md"),c=$(n)?D(n):null;return r.set(o,c),c};for(let o of e.resolvedTest.unitFiles){let n=o.file===e.resolvedTest.rootPath,c=G(o.file,Oe(o.file,"utf8")),m=w(o.file),R=$(m)?D(m):null,f=[],v=[],x=[],g=[];if(!n)for(let a of e.resolvedTest.steps){if(a.owningFile!==o.file||a.trace.length<2)continue;let i=W(a.trace);g.includes(i)||g.push(i)}let F=a=>{if(R!==null)return null;for(let i of g){let P=u(i)?.steps[a-1];if(P)return{row:P,dir:i}}return null},V=[],_=!1,B=!1,E=!1,L=!1;for(let a of c.steps){let i=a.index,p=R?.steps[i-1];if(a.body.kind==="objective"){let h=e.resolvedTest.steps.filter(S=>S.owningFile===o.file&&S.trace[S.trace.length-1].stepIndex===i&&t.has(S.flatIndex)),I=h.length>0?h[h.length-1]:null;if(I){_=!0,s.has(I.flatIndex)&&(B=!0);let S=T(I),k;n?k=e.outcomes.find(he=>he.rootStepIndex===i)??{rootStepIndex:i,status:"skipped"}:k={rootStepIndex:i,status:fe(I,e.outcomes)},k.status==="failed"&&(E=!0),k.stepMd5==null&&(k.stepMd5=S),f.push(k),v.push({stepIndex:i,md5:S,rec:t.get(I.flatIndex)}),(!p||p.kind!=="objective"||p.status!==k.status||k.status==="passed"&&p.md5!==S)&&(L=!0)}else if(p&&p.kind==="objective")f.push({rootStepIndex:i,status:p.status,...p.md5?{stepMd5:p.md5}:{}}),x.push(i);else if(!n&&F(i)?.row.kind==="objective"){let S=F(i),k=S.row;f.push({rootStepIndex:i,status:k.status,...k.md5?{stepMd5:k.md5}:{}}),V.push({psIdx:i,dir:S.dir})}else n?f.push(e.outcomes.find(S=>S.rootStepIndex===i)??{rootStepIndex:i,status:"skipped"}):f.push({rootStepIndex:i,status:"skipped"});continue}let P=Ee(a.body.path)?a.body.path:Ke(_e(o.file),a.body.path),O=Y({path:a.body.path,bindings:a.body.bindings,optional:a.optional??!1}),K=Le(J(o.file),w(P)),N=e.resolvedTest.steps.filter(h=>h.trace.some((I,S)=>S<h.trace.length-1&&I.file===o.file&&I.stepIndex===i)&&t.has(h.flatIndex));if(N.length>0){_=!0;let h;if(n)h=e.outcomes.find(I=>I.rootStepIndex===i)??{rootStepIndex:i,status:"passed",refKind:"import",refLabel:a.body.path};else{let I=N.some(S=>fe(S,e.outcomes)==="failed");h={rootStepIndex:i,status:I?"failed":"passed",refKind:"import",refLabel:a.body.path,inlinedCount:N.length}}h.status==="failed"&&(E=!0),h.stepMd5==null&&(h.stepMd5=O),h.helperResultRelPath==null&&(h.helperResultRelPath=K),f.push(h),(!p||p.kind!=="import"||p.status!==h.status||p.md5!==O)&&(L=!0)}else if(p&&p.kind==="import")f.push({rootStepIndex:i,status:p.status,refKind:"import",refLabel:p.importPath,...p.md5?{stepMd5:p.md5}:{},...p.helperResultRelPath?{helperResultRelPath:p.helperResultRelPath}:{}});else if(!n&&F(i)?.row.kind==="import"){let h=F(i).row;f.push({rootStepIndex:i,status:h.status,refKind:"import",refLabel:a.body.path})}else n?f.push(e.outcomes.find(h=>h.rootStepIndex===i)??{rootStepIndex:i,status:"skipped",refKind:"import",refLabel:a.body.path}):f.push({rootStepIndex:i,status:"skipped",refKind:"import",refLabel:a.body.path})}if(!(n||_&&(B||E||R===null||L)))continue;l.push(o.file);let b=z(o.file);ue(y(b,".internal"),{recursive:!0});for(let a of v){let i=y(b,".internal","steps",`${a.stepIndex}-${a.md5.slice(0,8)}`);ue(i,{recursive:!0}),await ie({sessionDir:e.sessionDir,runIndex:a.rec.runIndex,totalRunDirs:a.rec.totalRunDirs,stagingStepDir:i,packTestDir:e.packTestDir})}if(x.length>0){let a=Q(o.file);if($(a))for(let i of ce(a)){let p=parseInt(i.split("-")[0]??"",10);!Number.isNaN(p)&&x.includes(p)&&pe(y(a,i),y(b,".internal","steps",i),{recursive:!0})}}for(let a of V){let i=y(a.dir,".internal","steps");if($(i))for(let p of ce(i))parseInt(p.split("-")[0]??"",10)===a.psIdx&&pe(y(i,p),y(b,".internal","steps",p),{recursive:!0})}let me=f.some(a=>a.status==="failed");if(te({sourcePath:o.file,title:c.title,rootSteps:c.steps,outcomes:f,overallStatus:n?e.overallStatus:me?"failed":"passed",startedISO:e.startedISO,durationS:n?e.durationS:0,sessionId:e.sessionId,outPath:y(b,"Result.md")}),n){let a={};e.commitId&&(a.commit_id=e.commitId),e.tmsIds.testId&&(a.test_id=e.tmsIds.testId),e.tmsIds.testcaseId&&(a.testcase_id=e.tmsIds.testcaseId),e.tmsIds.projectId&&(a.project_id=e.tmsIds.projectId),e.tmsIds.folderId&&(a.folder_id=e.tmsIds.folderId),e.tmsIds.orgId&&(a.org_id=e.tmsIds.orgId),e.tmsIds.sessionName&&(a.session_name=e.tmsIds.sessionName),Ae(y(b,".internal","meta.json"),JSON.stringify(a,null,2)+`
|
|
5
|
+
`,"utf8");let i=y(e.sessionDir,"execution.json");if($(i))try{le(i,y(b,".internal","execution.json"))}catch{}if(e.codeExportDir){let p=e.codeExportLanguage??"python",P=e.codeExportFramework??"playwright",O=y(b,`${P}-${p}-code`);try{de(e.codeExportDir,O)}catch(K){process.stderr.write(`warn: codegen copy failed: ${K.message}
|
|
6
|
+
`)}}}else if(o.kind==="test"||o.kind==="module"){let a=q(o.file);if($(a))try{le(a,y(b,".internal","meta.json"))}catch{}}!n&&g.length>0&&f.every(i=>i.status!=="skipped")&&d.push({unitFile:o.file,dirs:g.filter(i=>$(i))})}return{changedUnitFiles:l,legacySweep:d}}function yt(e){for(let t of e)try{Te(t,{recursive:!0,force:!0})}catch{}}function fe(e,t){let s=e.trace[0].stepIndex,l=t.find(o=>o.rootStepIndex===s);if(!l)return"skipped";if(l.status==="passed")return"passed";if(l.status==="skipped")return"skipped";let d=e.trace.slice(1).map(o=>o.stepIndex),r=l.failedSubStepIndex??[],u=Math.min(d.length,r.length);for(let o=0;o<u;o++)if(d[o]!==r[o])return d[o]<r[o]?"passed":"skipped";return d.length===r.length?"failed":d.length<r.length?"passed":"skipped"}export{te as a,et as b,tt as c,st as d,nt as e,rt as f,de as g,St as h,yt as i};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{x as m}from"./chunk-
|
|
2
|
+
import{x as m}from"./chunk-NJJQL54J.js";import{a as x}from"./chunk-HCBYKLMW.js";import{a as u,b as a,j as g}from"./chunk-C44QQJR4.js";import{a as b}from"./chunk-6YGTRKDT.js";import{e as f}from"./chunk-UR6MHSHU.js";var T=f(b(),1);function k(i,n){if(!n)return i;let l=i.trim()||n;return`\x1B]8;;${n}\x07${l}\x1B]8;;\x07`}var r=f(x(),1);function $({shareableLink:i,testCaseLink:n,codeExportDir:l,recordedTestPath:s,outputDir:o,autoExit:p=!0}){let{exit:c}=g();(0,T.useEffect)(()=>{if(!p)return;let t=setTimeout(()=>c(),100);return()=>clearTimeout(t)},[c,p]);let e=[];return s&&e.push({label:"Test",url:s,linkUrl:`file://${s}`}),o&&e.push({label:"Output",url:o,linkUrl:`file://${o}`}),i&&e.push({label:"ShareLink",url:i}),n&&e.push({label:"TestCase",url:n}),l&&!o&&e.push({label:"CodeExport",url:l,linkUrl:`file://${l}`}),e.length===0?(0,r.jsx)(r.Fragment,{}):(0,r.jsx)(u,{flexDirection:"column",marginTop:1,marginLeft:1,children:e.map(t=>(0,r.jsxs)(u,{flexDirection:"column",marginBottom:1,children:[(0,r.jsxs)(a,{color:m.orange,children:[t.label,":"]}),(0,r.jsx)(a,{color:m.dim,children:k(t.url,t.linkUrl??t.url)})]},t.label))})}export{$ as a};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{i as S}from"./chunk-
|
|
2
|
+
import{g as E}from"./chunk-R7QAS6LZ.js";import{i as S}from"./chunk-XS2LZFCH.js";import{a as C,b as k,c as R,d as D}from"./chunk-VDM3TWF6.js";import{j as T,k as $,l as b}from"./chunk-54JZ6VEW.js";import{c as y}from"./chunk-5DT7PIGB.js";import{a as O}from"./chunk-CH273NAE.js";import{C as _}from"./chunk-W3Z7AZNT.js";import{existsSync as H}from"fs";import{basename as q}from"path";import{appendFileSync as L,mkdirSync as U}from"fs";import{homedir as F}from"os";import{dirname as G,join as j}from"path";function P(c,s){let n=/^(DOCX_[A-Z_]+):/.exec(s)?.[1];if(n)try{let u=process.env.KANE_CONTEXT_REFUSAL_LOG??j(F(),".testmuai","kaneai","context-refusals.log");U(G(u),{recursive:!0}),L(u,`${new Date().toISOString()} ${n} ${c}
|
|
3
3
|
`)}catch{}}async function w(c,s,n,u=process.cwd(),p){let l=O(u),g=[];if(s.as!==void 0&&c.length>1)return(n.err??n.out)(`error: --as names ONE source identity \u2014 pass a single file (got ${c.length})`,"AS_SINGLE_SOURCE"),{code:2,results:g};for(let o of c){if(R(o)){let a=D(o);if(a===null)return(n.err??n.out)(`error: ${o}: unsupported remote URL \u2014 supported: ${k.map(d=>d.hint).join("; ")}`,"UNSUPPORTED_URL"),{code:1,results:g};let r=await a.ingest(o,s.as,n,l,p);if(r.code!==0)return{code:r.code,results:g};r.result&&g.push({status:r.result.status==="versioned"?"versioned":r.result.status==="unchanged"?"unchanged":"created",source_id:r.result.source_id,source_cid:r.result.source_cid});continue}let f=s.as,v;if(f===void 0&&H(l)){let a=T(o),r=$(a);if(r){let d=_(l);d.heads.get(r)!=null&&d.heads.get(a)==null&&(v=r,n.isTTY&&await n.confirm(`${a} looks like a new version of existing source '${r}' \u2014 ingest as '${r}' (replaces the current version; items built on it go stale)?`)&&(f=r))}}let e;try{e=await b({contextDir:l,filePath:o,asId:f,confirmSameSource:n.isTTY?a=>n.confirm(`identical bytes already ingested as ${a} \u2014 treat as the same source?`):void 0,converters:{pdf:E,docx:S}})}catch(a){let r=a instanceof Error?a.message:String(a);return P(o,r),(n.err??n.out)(`error: ${o}: ${r}`,"INGEST_FAILED"),{code:1,results:g}}n.out(C(n.isTTY,e,q(o)));for(let a of e.warnings??[])n.out(`warning: ${a}`);if(e.composite&&(e.composite.delivered>0||e.composite.omitted>0)){let a=e.composite.pages!==void 0?` ${e.composite.pages} pages,`:"";n.out(`${e.source_id}: ${e.composite.kind},${a} ${e.composite.delivered} images delivered (${e.composite.omitted} omitted)`)}let m;if(!n.isTTY&&e.status==="created"){let a=_(l);for(let[r,d]of a.heads.entries())if(!(r===e.source_id||d==null)&&a.getNode(d)?.content.blob===e.blob){m=r,n.out(`hint: identical bytes already ingested as ${r} \u2014 merged later via review`);break}}g.push({status:e.status,source_id:e.source_id,source_cid:e.cid,...e.warnings?.length?{warnings:e.warnings}:{},...e.composite?{media:{kind:e.composite.kind,...e.composite.pages!==void 0?{pages:e.composite.pages}:{},delivered:e.composite.delivered,omitted:e.composite.omitted}}:{},...m?{duplicate_of:m}:{},...v&&f===void 0?{lineage_candidate:v}:{}})}return{code:0,results:g}}async function se(c,s,n,u=process.cwd(),p){return(await w(c,s,n,u,p)).code}async function ie(c,s){if(s.mode!=null&&!["interactive","agent","ci","override"].includes(s.mode)){let{makeHeadlessIO:t,agentRefusal:i}=await import("./headless-io-66RG5NN5.js");return i(t("ndjson","extract"),`ingest: --mode must be interactive | agent | ci | override, got '${s.mode}'`,"MODE_USAGE")}let n=y();if(s.mode==="interactive"&&!n)return process.stderr.write(`ingest: --mode interactive needs a TTY on stdin and stdout (use --mode agent|ci|override headless)
|
|
4
4
|
`),2;let u=s.mode??(n?"interactive":void 0),p=u==="interactive"||u==="agent"||u==="override";if(!p&&(s.plan||s.force||s.trust!==void 0))return process.stderr.write(`ingest: --plan/--force/--trust steer the extraction \u2014 not available when only landing (use --mode agent to extract headless)
|
|
5
5
|
`),2;let{createInterface:l}=await import("readline/promises"),g=u==="agent",o=g?(await import("./headless-io-66RG5NN5.js")).makeHeadlessIO("ndjson","extract"):null,f=[],v=()=>{for(let t of f.splice(0))o.event({type:"error",message:t.message,...t.code?{code:t.code}:{}})},e=t=>{for(let i of t)o.event({type:"ingested",source_id:i.source_id,status:i.status,cid:i.source_cid,...i.warnings?.length?{warnings:i.warnings}:{},...i.media?{media:i.media}:{},...i.duplicate_of?{duplicate_of:i.duplicate_of}:{},...i.lineage_candidate?{lineage_candidate:i.lineage_candidate}:{}})},m=o?{out:()=>{},err:(t,i)=>f.push({message:t.replace(/^error: /,""),...i?{code:i}:{}}),isTTY:!1,confirm:async()=>!1}:{out:t=>process.stdout.write(t+`
|
|
6
6
|
`),err:t=>process.stderr.write(t+`
|
|
7
|
-
`),isTTY:n,confirm:async t=>{let i=l({input:process.stdin,output:process.stdout});try{let h=await i.question(`${t} [Y/n] `);return!/^n(o)?$/i.test(h.trim())}finally{i.close()}}};if(!p){let{withTelemetry:t}=await import("./with-telemetry-
|
|
7
|
+
`),isTTY:n,confirm:async t=>{let i=l({input:process.stdin,output:process.stdout});try{let h=await i.question(`${t} [Y/n] `);return!/^n(o)?$/i.test(h.trim())}finally{i.close()}}};if(!p){let{withTelemetry:t}=await import("./with-telemetry-5Y2CVPXK.js");return t("ingest",async()=>{let{code:i,results:h}=await w(c,{as:s.as},m,void 0,void 0);if(i!==0)return i;let I=h.filter(Y=>Y.status!=="unchanged").length;return I>0&&(m.err??m.out)(`landed ${I} source(s) \u2014 run kane-cli context extract to extract them`),0},{write:!0})}let a;try{a=o?await(await import("./run-channel-RGH4WIQX.js")).runWithChannel({event:o.event},()=>w(c,{as:s.as},m,void 0,void 0)):await w(c,{as:s.as},m,void 0,void 0)}catch(t){if(o)return v(),o.event({type:"error",message:t instanceof Error?t.message:String(t),code:"INGEST_FAILED"}),o.done(1,"error");throw t}let{code:r,results:d}=a;if(r!==0)return o?(e(d),v(),o.done(r,r===2?"refused":"error")):r;if(d.length===0)return o?o.done(0):0;let{extractCommand:A}=await import("./extract-cmd-IPBCCR3T.js"),N=[...new Set(d.map(t=>t.source_id))],x=await A({...s.mode!==void 0?{mode:s.mode}:{},...s.plan?{plan:!0}:{},...s.force?{force:!0}:{},...s.trust!==void 0?{trust:s.trust}:{},sources:N,landed:d});if(x===2&&!g){let t=d.filter(i=>i.status!=="unchanged").length;t>0&&(m.err??m.out)(`note: the ${t} landed source(s) are safe \u2014 extract later with kane-cli context extract`)}return x}export{w as a,se as b,ie as c};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as $}from"./chunk-
|
|
2
|
+
import{a as $}from"./chunk-ZXN67F4U.js";import{f as D}from"./chunk-YF26DH4Z.js";import{a as E}from"./chunk-NLCCBXXV.js";function U(e){return["completed","failed","ended","stopped"].includes(e.trim().toLowerCase())}function je(e){return["ended","stopped"].includes(e.trim().toLowerCase())}function q(e){return{requestId:e.requestId,objective:e.objective,status:"",turnActive:!1,scenarios:[],thinking:"",thinkingLog:[],chatLog:[],progress:0}}function Re(e){return e.pendingClarification===void 0?e:{...e,pendingClarification:void 0}}function Ce(e){return{...e,turnActive:!0,error:void 0,thinking:"",thinkingLog:[]}}function P(e,t){switch(t.type){case"thinking":return{...e,status:"thinking",thinking:e.thinking+t.delta};case"thinking_done":return{...e,thinkingLog:[...e.thinkingLog,{text:e.thinking,tookMs:t.tookMs}],thinking:""};case"progress":return{...e,progress:t.pct};case"snapshot":return{...e,scenarios:t.data.scenarios,status:t.data.status,headline:t.data.headline??e.headline};case"chat":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}]};case"clarification":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}],pendingClarification:t.text};case"limit":return{...e,limits:{scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit}};case"error":return{...e,error:t.message};case"done":return{...e,status:t.status,turnActive:!1,error:t.status==="failed"&&!e.error?"generation failed":e.error}}}function H(e,t){let n=[],i=e.type??"",d=e.status??"";if(i==="ping")return n;switch(i){case"thinking_token":typeof e.data=="string"&&n.push({type:"thinking",delta:e.data});break;case"thinking_stopped":{let r=e.data??{},o=se(r.time_taken);n.push({type:"thinking_done",text:typeof e.data=="string"?e.data:r.message??"",tookMs:o});break}case"progress":{let r=e.data??{};typeof r.progress=="number"&&n.push({type:"progress",pct:r.progress});break}case"clarification":{let r=e.data??{};typeof r.message=="string"&&n.push({type:"clarification",text:r.message});break}case"chatting_stopped":{let r=e.data??{};typeof r.message=="string"&&r.message.length>0&&n.push({type:"chat",text:r.message});break}case"limit_update":{let r=e.data??{},o=r.test_cases_limit??e.test_cases_limit,p=r.per_scenario_test_cases_limit??e.per_scenario_test_cases_limit;n.push({type:"limit",scenarioLimit:o,perScenarioLimit:p});break}case"error":{let r=typeof e.data=="string"?e.data:e.data?.message??"generation error";n.push({type:"error",message:r});break}case"request_cancelled":return n.push({type:"done",status:"stopped"}),n;case"session_ended":return n.push({type:"done",status:"ended"}),n;default:break}if(Array.isArray(e.scenarios)&&n.push({type:"snapshot",data:{requestId:t,status:d,headline:e.headline,scenarios:e.scenarios}}),d&&U(d)){let r=d.trim().toLowerCase();n.push({type:"done",status:r})}return n}function se(e){if(!e)return;let t=/^([\d.]+)(ms|s)?$/.exec(e.trim());if(!t)return;let n=Number(t[1]);if(Number.isFinite(n))return t[2]==="ms"?Math.round(n):Math.round(n*1e3)}var v=class extends Error{constructor(t){super(t),this.name="AuthError"}},M=class extends Error{constructor(t){super(t),this.name="ForbiddenError"}},I=class extends Error{constructor(t){super(t),this.name="InsufficientCreditsError"}},k=class extends Error{constructor(n,i){super(n);this.cause=i;this.name="TransportError"}};function x(e,t){let n=t?.message??t?.error??`HTTP ${e}`;return e===401?new v(n):e===403?t?.key==="insufficient_credits"?new I(n):new M(n):new k(n)}async function*J(e){let t=e.fetchImpl??fetch,n=e.maxRetries??5,i=e.maxBackoffMs??3e4,d=e.connectTimeoutMs??1e4,r=0,o=!1;for(;;){if(e.signal.aborted)return;let p=new AbortController,a=()=>p.abort();e.signal.addEventListener("abort",a,{once:!0});let c=setTimeout(()=>p.abort(),d),g;try{g=await t(e.url,{method:"GET",headers:{Authorization:await e.authHeader(),Accept:"text/event-stream"},signal:p.signal})}catch(w){if(clearTimeout(c),e.signal.removeEventListener("abort",a),e.signal.aborted)return;if(++r>n)throw new k("SSE connect failed",w);await O(F(r,i));continue}if(clearTimeout(c),!g.ok){e.signal.removeEventListener("abort",a);let w=await oe(g);if(g.status===401&&o){if(++r>n)throw x(401,w);await O(F(r,i));continue}throw x(g.status,w)}if(!g.body)throw e.signal.removeEventListener("abort",a),new k("SSE response had no body");o=!0,r=0;let m=g.body.getReader(),h=new TextDecoder("utf-8"),b="";try{for(;;){if(e.signal.aborted){await m.cancel().catch(()=>{});return}let{done:w,value:s}=await m.read();if(w)break;b+=h.decode(s,{stream:!0});let f;for(;(f=b.indexOf(`
|
|
3
3
|
|
|
4
4
|
`))>=0;){let u=b.slice(0,f);b=b.slice(f+2);let l=ie(u);l&&(yield l)}}}catch(w){if(e.signal.aborted)return;if(++r>n)throw new k("SSE stream dropped",w);await O(F(r,i));continue}finally{e.signal.removeEventListener("abort",a)}return}}function ie(e){let t="message",n="";for(let i of e.split(`
|
|
5
5
|
`))i.startsWith("event:")?t=i.slice(6).trim():i.startsWith("data:")&&(n+=i.slice(5).trim());if(t!=="message"||!n)return null;try{let i=Buffer.from(n,"base64").toString("utf-8");return JSON.parse(i)}catch{return null}}function F(e,t){return Math.min(t,1e3*2**(e-1))}function O(e){return new Promise(t=>setTimeout(t,e))}async function oe(e){try{return await e.clone().json()}catch{return}}function W(e,t){t?.length&&(e.append("files",t.map(n=>n.fileKey).join(",")),e.append("gemini_metadata",JSON.stringify(t.map(n=>({fileData:{fileUri:n.geminiUri,mimeType:n.mimeType}})))))}function Ue(e,t={}){let n=t.fetchImpl??fetch,i=new Map,d=!0;async function r(){let s=await e.authResolver.resolve();if(!s)throw new v("unauthorized; run `kane-cli login`");return E(s.username,s.access_key)}function o(s){return`${e.baseUrl}${s}`}async function p(s){if(!s.ok){let f;try{f=await s.clone().json()}catch{f=void 0}throw x(s.status,f)}return s.json()}function a(s){let f=s?.data??s;return{request_id:f.request_id??f.id,status:f.status??""}}function c(s,f,u,l){let y=q({requestId:s,objective:f});l&&(y=P(y,{type:"snapshot",data:l}),l.status==="cleaned_up"&&(y={...y,error:"session was reaped (cleaned_up) \u2014 continuing will destructively regenerate"}));let S=new AbortController;u&&(u.aborted?S.abort():u.addEventListener("abort",()=>S.abort(),{once:!0})),i.set(s,S);let A={requestId:s,state:y,events:void 0};return A.events=(async function*(){try{let C=J({url:o(`/requests/${s}/sse`),authHeader:r,signal:S.signal,log:e.log,fetchImpl:n});for await(let L of C)for(let z of H(L,s))A.state=P(A.state,z),yield z}finally{i.delete(s)}})(),A}async function g(s,f){let u=new FormData;u.append("prompt",s.prompt),d=s.memoryEnhancement??!0,u.append("memory_enhancement",String(d)),s.scenarioLimit!==void 0&&u.append("test_scenario_limit",String(s.scenarioLimit)),s.perScenarioLimit!==void 0&&u.append("per_scenario_test_cases_limit",String(s.perScenarioLimit));let l=s.projectId??e.projectId,y=s.folderId??e.folderId;l&&u.append("project_id",l),y&&u.append("folder_id",y),W(u,s.attachments);let S=await n(o("/requests"),{method:"POST",headers:{Authorization:await r()},body:u}),A=await p(S),{request_id:C}=a(A),L=String(C);return c(L,s.prompt,f)}async function m(s,f){let u=await n(o(`/requests/${s}`),{method:"GET",headers:{Authorization:await r()}}),l=await p(u),y=l?.data??l,S={requestId:s,status:y.status??"",headline:y.headline,scenarios:Array.isArray(y.scenarios)?y.scenarios:[]};return c(s,"",f,S)}async function h(s,f,u){let l=new FormData;l.append("prompt",f),l.append("chat_enabled","true"),l.append("memory_enhancement",String(d)),u?.mappings&&l.append("mappings",JSON.stringify(u.mappings)),W(l,u?.attachments);let y=await n(o(`/requests/${s}`),{method:"PUT",headers:{Authorization:await r()},body:l});if(!y.ok){let S;try{S=await y.clone().json()}catch{}throw x(y.status,S)}}async function b(s){i.get(s)?.abort();let u=await n(o(`/requests/${s}/stop`),{method:"DELETE",headers:{Authorization:await r()}});if(!u.ok&&u.status!==404){let l;try{l=await u.clone().json()}catch{}throw x(u.status,l)}}async function w(s){i.get(s)?.abort();let u=await n(o(`/requests/${s}/end`),{method:"DELETE",headers:{Authorization:await r()}});if(!u.ok&&u.status!==404){let l;try{l=await u.clone().json()}catch{}throw x(u.status,l)}}return{start:g,attach:m,chat:h,cancel:b,end:w}}import{statSync as ae,realpathSync as G,existsSync as ce}from"fs";import{extname as ue,resolve as j,isAbsolute as pe}from"path";import{homedir as V}from"os";var de=new Set([".txt",".md",".json",".xml",".jpg",".jpeg",".png",".gif",".bmp",".webp",".pdf",".docx",".csv",".xlsx",".mp3",".wav",".m4a",".webm",".mpeg",".mpga",".mp4",".mov"]),le=50*1024*1024,X=10;function fe(e){return e==="~"?V():e.startsWith("~/")?j(V(),e.slice(2)):e}function Ge(e,t){let n=[],i=[],d=new Set,r=[],o=(()=>{try{return G(j(t))}catch{return j(t)}})(),p=o.endsWith("/")?o:o+"/";for(let a of e){let c=fe(a),g=pe(c)?c:j(t,c);if(!ce(g)){n.push(`Not found: ${a}`);continue}let m;try{m=G(g)}catch{n.push(`Cannot resolve: ${a}`);continue}if(d.has(m))continue;let h;try{h=ae(m)}catch{n.push(`Cannot read: ${a}`);continue}if(!h.isFile()){n.push(`Not a file: ${a}`);continue}if(h.size===0){n.push(`Empty file: ${a}`);continue}let b=ue(m).toLowerCase();if(!de.has(b)){n.push(`Unsupported type ${b||"(none)"}: ${a}`);continue}if(h.size>le){n.push(`Too large (>50MB): ${a}`);continue}m!==o&&!m.startsWith(p)&&i.push(`Outside working dir: ${a}`),d.add(m),r.push(m)}return r.length>X&&n.push(`Too many files: ${r.length} (max ${X})`),{ok:n.length?[]:r,errors:n,warnings:i}}var B=class extends Error{constructor(n){super(n.join("; "));this.errors=n;this.name="AttachmentValidationError"}};async function Xe(e){let{promptText:t,filePaths:n,cwd:i,scenarios:d,isRefine:r,conn:o,deps:p}=e,{ok:a,errors:c,warnings:g}=p.validate(n,i);if(c.length)throw new B(c);e.onValidated?.();let m=a.length?await p.upload(o,a,p.onUpload):[],h=r?p.buildMappings(t,d):void 0;return{promptText:t,mappings:h,attachments:m,warnings:g}}import{readFile as me}from"fs/promises";import{basename as K}from"path";async function ge(e){let t=await e.authResolver.resolve();if(!t)throw new v("unauthorized; run `kane-cli login`");return E(t.username,t.access_key)}async function he(e,t,n={}){let i=n.fetchImpl??fetch,d=await me(t),r=K(t),o=new FormData;o.append("file",new Blob([d]),r),o.append("source","omniBox"),o.append("geminiFileUpload","true");let p=await i(`${e.tmsBaseUrl}/v1/attachment`,{method:"POST",headers:{Authorization:await ge(e)},body:o,signal:n.signal});if(!p.ok){let h;try{h=await p.clone().json()}catch{}throw x(p.status,h)}let a=await p.json(),c=a?.data??a,g=c?.gemini_response?.uri,m=c?.gemini_response?.mimeType;if(!c?.file_key||!g){let h=c&&typeof c=="object"?Object.keys(c).join(","):typeof c,b=(()=>{try{return JSON.stringify(c).slice(0,500)}catch{return"<unserializable>"}})();throw new Error(`attachment upload for ${r} returned no file_key/gemini uri \u2014 status ${p.status}, body keys: [${h}], raw: ${b}`)}return{fileName:c.file_name??r,fileKey:c.file_key,geminiUri:g,mimeType:m??"application/octet-stream"}}async function tt(e,t,n,i={}){let d=[];for(let r=0;r<t.length;r++){if(i.signal?.aborted)throw Object.assign(new Error("upload aborted"),{name:"AbortError"});let o=K(t[r]);n?.({file:o,index:r+1,total:t.length,status:"uploading"});try{d.push(await he(e,t[r],i)),n?.({file:o,index:r+1,total:t.length,status:"done"})}catch(p){throw n?.({file:o,index:r+1,total:t.length,status:"failed"}),p}}return d}var ye=/@([sS])(\d+)\.([cC])(\d+)/g,be=/@([sS])(\d+)(?!\d)(?!\.[cC]\d)/g;function rt(e,t){let n={},i={};for(let d of e.matchAll(ye)){let r=Number(d[2]),o=Number(d[4]),p=t[r-1];if(!p)continue;n[`s${r}`]=String(p.id);let a=p.test_cases??[];if(a[o-1])for(let c=0;c<o;c++){let g=a[c];g&&(i[`s${r}.c${c+1}`]=String(g.id))}}for(let d of e.matchAll(be)){let r=Number(d[2]),o=t[r-1];o&&(n[`s${r}`]=String(o.id))}if(!(Object.keys(n).length===0&&Object.keys(i).length===0))return{scenario:n,testcase:i}}function R(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(n==null||typeof n!="object")return[];let i=n;if(typeof i.step!="string")return[];let d=typeof i.expected_result=="string"?i.expected_result:typeof i.outcome=="string"?i.outcome:"";t.push({step:i.step,expected:d})}return t}var we=30,Se=300;function Z(){return{mode:"testing",max_steps:we,timeout:Se,variables:{}}}function Q(e){return e.title??`Test case ${e.id}`}function ct(e,t){return $({frontmatter:Z(),heading:Q(t),steps:e.sub_objectives.map(n=>n.objective)})}function Y(e){let t=R(e.manual_steps).map(n=>n.step);return $({frontmatter:Z(),heading:Q(e),steps:t})}import{mkdtempSync as xe,mkdirSync as N,writeFileSync as ee,rmSync as te,renameSync as _e,existsSync as ne,readFileSync as ve}from"fs";import{join as _,resolve as ke}from"path";async function ft(e,t,n,i=Y){(n.redirectBareCwd??!0)&&ke(t)===process.cwd()&&(t=_(t,".testmuai","tests"));let d=T(e.objective)??e.headline,r=T(n.suiteName)??`${T(re(d,4))??"tcg"}-${e.requestId}`,o=r,p=_(t,r);ne(p)&&!Te(p,e.requestId)&&(o=`${r}-${e.requestId}`);let a=_(t,o),c=[],g=new Map;for(let h of e.scenarios){let b=(h.test_cases??[]).filter(Ae);if(b.length===0)continue;let w=T(Ee(h.scode))??T(h.sid)??`s${h.id}`,s=g.get(w)??new Set;g.set(w,s);for(let f of b){let u=T(re(f.title,5))??"case",l=`${u}_test.md`;for(let y=2;s.has(l);y++)l=`${u}-${y}_test.md`;s.add(l),c.push({dir:w,file:l,tc:f})}}if(c.length===0)return{suiteDir:a,paths:[],warning:"no functional test cases generated"};N(t,{recursive:!0});let m=xe(_(t,".tcg-tmp-"));try{N(_(m,"helpers"),{recursive:!0}),ee(_(m,".tcg-suite.json"),JSON.stringify({requestId:e.requestId,suiteName:o}));let h=[],b=new Set;for(let s of c){let f=_(m,s.dir);b.has(f)||(N(f,{recursive:!0}),b.add(f));let u=_(f,s.file);ee(u,i(s.tc)),h.push(u)}ne(a)&&te(a,{recursive:!0,force:!0}),_e(m,a);let w=h.map(s=>s.replace(m,a));return{suiteDir:a,paths:w}}catch(h){try{te(m,{recursive:!0,force:!0})}catch{}throw h}}function Ae(e){return(e.category??"").trim().toLowerCase()==="functional"}function Te(e,t){try{return JSON.parse(ve(_(e,".tcg-suite.json"),"utf-8"))?.requestId===t}catch{return!1}}function T(e){return e&&e.length>0?e:void 0}function re(e,t){return e?e.toLowerCase().replace(/[^a-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean).slice(0,t).join("-"):""}function Ee(e){return e?e.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,""):""}function ht(e){let t=[];e.title&&t.push(e.title),e.description&&t.push("",e.description);let n=R(e.manual_steps);return n.length>0&&(t.push("","Steps:"),n.forEach((i,d)=>{t.push(`${d+1}. ${i.step}`)})),t.join(`
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{d as kt,g as xt}from"./chunk-QQ5MHSSY.js";import{b as y,c as me,d as ut,f as fe,g as ge}from"./chunk-5GUD3CIH.js";import{b as ve,c as K,d as ye,e as be}from"./chunk-DYXYNH6X.js";import{a as lt,d as pt,h as L,i as mt,j as ft,k as U,l as gt,m as Z,n as _t,o as F,p as ht}from"./chunk-NP3VGFZM.js";import{d as Et}from"./chunk-NVGBE2DR.js";import{a as V,b as z,d as dt}from"./chunk-EHN5HTUD.js";import{a as re}from"./chunk-CH273NAE.js";import{d as _e}from"./chunk-KRL2BDI5.js";import{b as $,c as k}from"./chunk-VZ7KXRXB.js";import{a as le,c as st,d as at,e as ct,f as pe}from"./chunk-P7YZ3PU3.js";import{C as x,e as bt,f as wt}from"./chunk-W3Z7AZNT.js";import{b as G}from"./chunk-6FCPS2VT.js";import{a as yt}from"./chunk-UH2ZTX4E.js";import{b as he,d as ee,g as te,j as H}from"./chunk-XMTSHHYQ.js";import{d as q,f as vt}from"./chunk-AKX4VRRR.js";import{a as it,b as ot}from"./chunk-HPUQJRDX.js";import{a as nt}from"./chunk-NJJQL54J.js";function D(e){if(e===null)return"broken";let t=Math.floor(e/100);return t===1?"passed":t===7?"failed":t===2?"skipped":"broken"}var C={failed:3,broken:2,passed:1,skipped:0};function we(e){let t="skipped";for(let r of e)C[r]>C[t]&&(t=r);return t}import{createHash as fr}from"crypto";import{basename as gr}from"path";function ke(e){let t=e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"").slice(0,40);return t.length>0?t:"session"}function xe(e){return fr("sha256").update(e).digest("hex").slice(0,8)}function Ee(e){let t=gr(e).replace(/_test\.md$/i,"").replace(/\.md$/i,"");return`${ke(t)}-${xe(e)}`}function Ie(e,t){return`${ke(e)}-${xe(t)}`}function Se(e){let t=e?.trim();return t||void 0}function It(e=process.env){let t=Se(e.TEST_INSTANCE_ID),r=Se(e.JOB_ID),n=Se(e.TASK_ID);return{...t?{testInstanceId:t}:{},...r?{jobId:r}:{},...n?{taskId:n}:{}}}function Re(e,t=process.env){let r=It(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 _r(e,t){return{pack_test_dir:e,ordinal_offset:t}}import{promises as I}from"fs";import{join as S}from"path";function Ae(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 k(t,{lineWidth:-1})}async function Pe(e,t,r,n=process.cwd(),i){let o=i??y(e.execution_id,n),s=S(o,"tests",t);return await I.mkdir(S(o,"coverage"),{recursive:!0}),await I.writeFile(S(o,"coverage",".keep"),""),await I.mkdir(s,{recursive:!0}),await I.writeFile(S(o,"run.yaml"),Ae(e)),r&&await I.writeFile(S(s,r.path),r.content),o}async function hr(e,t=process.cwd()){let r=y(e.execution_id,t);await I.mkdir(S(r,"coverage"),{recursive:!0}),await I.writeFile(S(r,"coverage",".keep"),"");let n=$(Ae(e));return n.environment&&delete n.environment.run_kind,await I.writeFile(S(r,"run.yaml"),k(n,{lineWidth:-1})),r}async function vr(e,t=process.cwd()){return z(y(e,t),new Date().toISOString())}async function $e(e,t=process.cwd()){await I.rm(y(e,t),{recursive:!0,force:!0})}import{promises as Le}from"fs";import{join as Fe}from"path";function ne(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 k(t,{lineWidth:-1})}function Ce(e){return k({logs:e},{lineWidth:-1})}async function De(e,t,r){await Le.writeFile(Fe(e,"tests",t,"result.yaml"),r)}async function je(e,t,r){let n=Fe(e,"tests",t,"logs");await Le.mkdir(n,{recursive:!0}),await Le.writeFile(Fe(n,"meta.yaml"),r)}import{promises as ie}from"fs";import{join as St}from"path";function Rt(e){return St(e,".internal","meta.json")}async function At(e){let t;try{t=await ie.readFile(Rt(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 Oe(e,t){let r;try{r=await At(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 ie.mkdir(St(e,".internal"),{recursive:!0});let i=Rt(e),o=`${i}.tmp-${process.pid}-${Date.now()}`;await ie.writeFile(o,JSON.stringify(r,null,2)+`
|
|
3
|
+
`),await ie.rename(o,i)}async function yr(e){try{let t=await At(e);return t&&Array.isArray(t.executions)?t.executions:[]}catch{return[]}}async function br(e,t,r=process.cwd()){let n=await fe(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 V(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 Te(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(D(i))}return we(t)}function wr(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||C[D(i)]>C[D(t)]||C[D(i)]===C[D(t)]&&i>t)&&(t=i)}return t}import{promises as kr}from"fs";import{extname as Pt,basename as xr}from"path";var Er={".ndjson":"ndjson",".log":"log",".json":"json",".har":"har"};async function Me(e){let t;try{t=await kr.readdir(e)}catch{return[]}return t.filter(r=>r!=="meta.yaml"&&!r.startsWith(".")).sort().map(r=>({name:xr(r,Pt(r)),file:r,format:Er[Pt(r)]??"txt"}))}import{mkdirSync as Ir,appendFileSync as Sr}from"fs";import{join as $t}from"path";function Ne(e,t){return $t(e,"tests",t,"logs")}function Be(e,t,r,n={},i){try{i?.(t,r,r,n)}catch{}if(e)try{Ir(e,{recursive:!0});let o=JSON.stringify({ts:new Date().toISOString(),level:t,event:r,...n})+`
|
|
4
|
+
`;Sr($t(e,"diagnostics.ndjson"),o)}catch{}}import{promises as R}from"fs";import{dirname as jr,join as j}from"path";import{statSync as Rr}from"fs";import{promises as Ve}from"fs";import{basename as Ar,join as Pr}from"path";var $r=1e6,Lr=2e6;function Fr(){return it.map(e=>ot(e))}function Lt(e=Fr()){return e.map(t=>{let r=0;try{r=Rr(t).size}catch{}return{path:t,offset:r}})}var Cr=/\x1b\[[0-9;]*[A-Za-z]/g;async function Dr(e,t,r){let n;try{n=await Ve.open(e,"r");let i=(await n.stat()).size,o=t<=i?t:0,s=i-o;if(s<=0)return null;let c=s>r?i-r:o,u=Buffer.alloc(Math.min(s,r));return await n.read(u,0,u.length,c),u.toString("utf8")}catch{return null}finally{await n?.close().catch(()=>{})}}async function Ft(e,t){let r=t.caps?.stderr??$r,n=t.caps?.appium??Lr,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 Dr(o.src,o.from,o.cap);if(s===null)continue;let c=s.replace(Cr,"");if(c!=="")try{await Ve.mkdir(e,{recursive:!0}),await Ve.writeFile(Pr(e,Ar(o.src)),c)}catch{}}}async function Or(e){try{let t=j(e,"tests"),r=await R.readdir(t).catch(()=>[]);for(let n of r){let i=j(t,n,"steps"),o=await R.readdir(i).catch(()=>[]);for(let s of o){let c=await R.readFile(j(i,s,"failure.yaml"),"utf8").catch(()=>null);if(c!=null)try{let u=$(c);if(u&&typeof u=="object"&&u.triage)return!0}catch{}}}}catch{}return!1}async function Ct(e,t,r,n={}){let i=j(e,"tests",t,"logs");if(r)try{await R.mkdir(i,{recursive:!0}),await R.copyFile(r,j(i,"tui.log"))}catch{}await Ft(i,{runnerStderrPath:r?j(jr(r),"runner-stderr.log"):void 0,appiumMarks:n.appiumMarks});let o=await Me(i);if(!o.length&&n.requireRealLog)throw new Error(`evidence test ${t} has no real log to declare`);o.length&&await je(e,t,Ce(o))}async function ze(e){let t=e.cwd??process.cwd(),r=e.packDir??y(e.executionId,t);if(!e.saved&&!e.packDir)return await $e(e.executionId,t),{sealed:!1};await Ct(r,e.testId,e.tuiLogPath,{requireRealLog:e.requireRealLog,appiumMarks:e.appiumMarks});let n=j(r,"run.yaml"),i=$(await R.readFile(n,"utf8"));i.environment={...i.environment??{},saved:e.saved,run_kind:e.runKind},await R.writeFile(n,k(i,{lineWidth:-1}));let o=await R.open(n,"r+");try{await o.sync()}finally{await o.close()}let s=await Or(r);await z(r,new Date().toISOString());let c;try{let a=await V(r,"L1");c=a.valid;let l=(a.diagnostics??[]).filter(d=>String(d?.code??"").includes("failure.status_disagrees"));if(l.length>0)if(e.expectStatusDisagrees||s){let d=e.expectStatusDisagrees?"expected under --bug-detection continue":"self-explained by triaged failure record(s)";console.warn(`evidence: ${l.length} status_disagrees advisory(ies) \u2014 ${d}`)}else console.warn(`evidence: ${l.length} status_disagrees advisory(ies) \u2014 step verdicts disagree with their failure records`,l);if(!a.valid){console.warn(`evidence: sealed pack ${e.executionId} failed L1 validation`,a.diagnostics);let d=String(a.diagnostics?.[0]?.code??"");Be(Ne(r,e.testId),"warn","EVIDENCE_INVALID",{execution_id:e.executionId,first_code:d,surface:e.surface??"testmd"},e.log)}}catch(a){console.warn(`evidence: validation error for ${e.executionId}`,a)}let u;if(e.saved&&e.packDir)try{u=await ut(r,e.executionId,t)}catch(a){console.warn(`evidence: store install failed for ${e.executionId}`,a)}if(e.outputStemDir)try{await Oe(e.outputStemDir,{execution_id:e.executionId,run_kind:e.runKind,status:e.verdict,valid:c,at:new Date().toISOString()})}catch(a){console.warn(`evidence: execution-pointer append failed for ${e.executionId} (pack is sealed)`,a)}return{sealed:!0,valid:c,storePath:u}}import{release as Mt}from"os";import{execFileSync as Tr}from"child_process";import{promises as Dt}from"fs";import{join as jt}from"path";function Ot(e){return e.replace(/\([^)]*\)/g," ").toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")||void 0}async function Tt(e){try{let t=jt(e,"steps"),r=(await Dt.readdir(t,{withFileTypes:!0})).filter(n=>n.isDirectory()).map(n=>n.name).sort((n,i)=>(parseInt(n,10)||0)-(parseInt(i,10)||0));for(let n of r)try{let i=await Dt.readFile(jt(t,n,"step.json"),"utf8"),s=JSON.parse(i).basis?.window;if(Array.isArray(s)&&s.length===2&&Number.isFinite(Number(s[0]))&&Number.isFinite(Number(s[1]))&&Number(s[0])>0&&Number(s[1])>0)return`${Math.round(Number(s[0]))}x${Math.round(Number(s[1]))}`}catch{}return}catch{return}}var Nt=!1,oe;function Mr(){if(!Nt)if(Nt=!0,process.platform==="darwin")try{oe=Tr("sw_vers",["-productVersion"],{timeout:2e3}).toString().trim()||void 0}catch{oe=Mt()||void 0}else oe=Mt()||void 0;return oe}function Ue(e){let t={os:le(process.platform)},r=Mr();if(r&&(t.os_version=r),e.cdpBrowser){let i=/^([A-Za-z]+)\/(\d+)/.exec(e.cdpBrowser);i&&(t.browser=i[1].replace(/^Headless/,""),t.browser_version=i[2])}e.resolution&&(t.resolution=e.resolution);let n=at(t,e.runnerEnvironment);if(!n.native_platform)return n;if(e.deviceName&&(n.device=e.deviceName),e.deviceModel){let i=Ot(e.deviceModel);i&&(n.device_slug=i)}return e.pixelResolution&&(n.viewport=n.resolution??Nr(e.pixelResolution,n.pixel_ratio)??e.pixelResolution,n.resolution=e.pixelResolution),n}function Nr(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 Bt(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 Br(e){let t;return()=>(t||(t=Bt(e)),t)}import{promises as b,existsSync as A,readFileSync as qr}from"fs";import{basename as Hr,join as _}from"path";import{readFileSync as Vr}from"fs";import{dirname as zr,resolve as Ur}from"path";function Vt(e,t){let r=Ur(e),n=Vr(r,"utf8");return L(t?U(n,Z(zr(r),t)):n)}async function zt(e){for(let t of await b.readdir(e,{withFileTypes:!0})){let r=_(e,t.name);if(t.isDirectory()){await zt(r);continue}try{await b.unlink(r)}catch{await b.truncate(r,0)}}await b.rmdir(e).catch(()=>{})}function Gr(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 W=class e{constructor(t){this.opts=t}executionId;testId;definitionPath=null;definitionContent=null;accumulatedSteps=[];maxOrdinal=0;_attempts=[];_packDirOverride;_attached=!1;appiumMarks=Lt();get attached(){return this._attached}static async attach(t){let r=Hr(t.packDir).replace(/\.evidence$/,""),n=new e({origin:"testrun",runKind:"author",pid:process.pid,title:t.testId,started:new Date().toISOString(),producerVersion:nt,cwd:t.cwd});n.executionId=r,n.testId=t.testId,n._packDirOverride=t.packDir,n._attached=!0;let i=_(t.packDir,"tests",t.testId);return await b.mkdir(i,{recursive:!0}),t.definition&&(await b.writeFile(_(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=me(),this.testId=this.opts.testmdRelPath?Ee(this.opts.testmdRelPath):Ie(this.opts.objectiveOrName??"session",this.opts.sessionId??this.executionId);let t=this.opts.definition??null;return await Pe({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?_(this.opts.packRootDir,`${this.executionId}.evidence`):y(this.executionId,this.opts.cwd)}get packTestDir(){return _(this.pack,"tests",this.testId)}async writeDefinition(t,r="test.md"){await b.writeFile(_(this.packTestDir,r),t),this.definitionPath=r,this.definitionContent=t}computeAssuranceId(){try{if(this.opts.testmdRelPath&&this.opts.cwd){let t=_(this.opts.cwd,this.opts.testmdRelPath);if(A(t))return F(qr(t,"utf8"))?.id}}catch{}}computeDefinitionId(){try{if(this.opts.testmdRelPath&&this.opts.cwd){let t=_(this.opts.cwd,this.opts.testmdRelPath),r=_(this.opts.cwd,".context"),n=A(r)?x(r):void 0;if(A(t))return Vt(t,n)}if(this.definitionContent!=null)return L(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=_(this.packTestDir,String(i)),s=n.log,c=(a,p)=>s?.("warn","ARCHIVE_ATTEMPT_FAILED",`Attempt ${i}: ${a} could not be archived into ${i}/; the next attempt will mingle with it`,{attempt:i,dir:a,error:String(p)}),u;try{await b.mkdir(o,{recursive:!0})}catch(a){c(`${i}/`,a)}for(let a of["steps","logs","v16-trajectory"]){let p=_(this.packTestDir,a);if(!A(p))continue;let l=_(o,a);try{await b.rename(p,l);continue}catch(d){s?.("warn","ARCHIVE_ATTEMPT_RENAME_FAILED",`Attempt ${i}: rename of ${a}/ refused; copying it into ${i}/ and emptying the originals in place`,{attempt:i,dir:a,error:String(d),fallback:"copy+truncate"})}try{await b.cp(p,l,{recursive:!0}),await zt(p)}catch(d){c(a,d)}}try{this.definitionPath&&A(_(this.packTestDir,this.definitionPath))&&await b.copyFile(_(this.packTestDir,this.definitionPath),_(o,this.definitionPath));let a=_(o,"steps");if(A(a)){for(let p of await b.readdir(a))if(A(_(a,p,"failure.yaml"))){u=`${i}/steps/${p}/failure.yaml`;break}}}catch(a){c("definition + failure pointer",a)}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=Te(t.spawns),n=this._attempts.length?[...this._attempts.map(m=>({status:m.status})),{status:r,...t.durationMs!==void 0?{duration_ms:t.durationMs}:{}}]:void 0,i=n?new Set(n.map(m=>m.status)).size>1:void 0,o=this._attempts.length>0,s=t.heal,c=o||s?.forced?{triggered:o,...o?{outcome:r==="passed"?"healed":"exhausted"}:{},...s?Gr(s):{},...o?{attempts:this._attempts.map(m=>({n:m.n,status:m.status,failed_at:m.failedAt??-1,...m.failure?{failure:m.failure}:{}}))}:{}}:void 0,u=this.pack,a=Re(t.externalIdInput),p=pe(t.runnerEnv,t.intentEnv),l=this.computeDefinitionId(),d=this.computeAssuranceId();await De(u,this.testId,ne({testId:this.testId,status:r,durationMs:t.durationMs,definitionPath:this.definitionPath,definitionId:l,assuranceId:d,externalId:a,environment:p,steps:t.steps,tags:t.tags,attempts:n,flaky:i,adaptiveHeal:c}));for(let m of this._attempts){let g=_(this.packTestDir,String(m.n));A(g)&&await b.writeFile(_(g,"result.yaml"),ne({testId:this.testId,status:m.status,definitionPath:this.definitionPath,definitionId:l,assuranceId:d,externalId:a,environment:p,steps:m.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,project_id:f.project_id??null,session_id:f.session_id??null,session_name:f.session_name??null,hyper_test_instance_id:a.hyper_test_instance_id??null,hyper_job_id:a.hyper_job_id??null,hyper_task_id:a.hyper_task_id??null}),r}get id(){return this.executionId}get test(){return this.testId}};async function Kr(e,t,r=ge){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 _n}from"fs";import{existsSync as Ke,mkdirSync as dn,readdirSync as un,readFileSync as ln,rmSync as pn,statSync as mn,writeFileSync as fn}from"fs";import{join as M}from"path";import{mkdirSync as Wr,renameSync as Yr,rmSync as Jr,writeFileSync as Xr}from"fs";import{join as Ut}from"path";var Qr=5e6;function qt(e,t,r){let n=Ut(e,"coverage","sources"),i=new Map,o=!1;try{for(let s of r.usecases)for(let c of s.sources){if(i.has(c.id)){c.file=i.get(c.id);continue}if(!c.cid)continue;let u=Et(t,c.cid);if(u===null||u.byteLength>Qr)continue;o||(Wr(n,{recursive:!0}),o=!0);let a=Ut(n,c.id),p=`${a}.tmp-${process.pid}`;Xr(p,u),Yr(p,a);let l=`coverage/sources/${c.id}`;i.set(c.id,l),c.file=l}}catch{for(let s of r.usecases)for(let c of s.sources)delete c.file;if(o)try{Jr(n,{recursive:!0,force:!0})}catch{}}}import{appendFileSync as Zt,existsSync as O,readFileSync as P,renameSync as er,writeFileSync as tr}from"fs";import{dirname as He,isAbsolute as ae,join as T,resolve as ce}from"path";var Zr=new Set(["inline","testmd","testrun"]),en=new Set(["inferred","authored","runtime-derived"]),se=new Set(["passed","failed","broken","skipped"]);function Ht(e,t,r){if(r.facts.length===0)return{record:null,errors:[{code:"EMPTY_EXECUTIONS",detail:"a run with no designed units attaches no facts \u2014 skip the call"}]};let n=t;for(let i=0;;i++){let o=te(e);if(n.latestHash!==o){if(i>=3)return{record:null,errors:[{code:"STALE_BASIS",detail:`graph opened at ${String(n.latestHash)} but chain head is ${String(o)} \u2014 retry budget exhausted`}]};n=x(e);continue}let s=tn(e,n,r);if(s!=="cas")return s;if(i>=3)return{record:null,errors:[{code:"STALE_BASIS",detail:"concurrent appends kept moving the head \u2014 retry budget exhausted"}]};n=x(e)}}function Gt(e,t){return Zr.has(e.mode)?se.has(e.verdict)?en.has(e.oracle_mode)?typeof e.drift_flag!="boolean"||typeof e.stale_at_run!="boolean"?[{code:"MISSING_FIELD",detail:`${t}: drift_flag and stale_at_run are required booleans`}]:!e.execution_id||!e.started_at||!e.definition_id_at_run?[{code:"MISSING_FIELD",detail:`${t}: execution_id, started_at and definition_id_at_run are required`}]:[]:[{code:"BAD_ORACLE_MODE",detail:`${t}: oracle_mode '${e.oracle_mode}' not in inferred|authored|runtime-derived`}]:[{code:"BAD_VERDICT",detail:`${t}: verdict '${e.verdict}' not in ${[...se].join("|")}`}]:[{code:"BAD_MODE",detail:`${t}: mode '${e.mode}' not in inline|testmd|testrun`}]}function Kt(e,t,r,n){return{about:t,definition_id_at_run:e.definition_id_at_run,verdict:e.verdict,...r&&r.length?{per_ac:r}:{},drift_flag:e.drift_flag,oracle_mode:e.oracle_mode,stale_at_run:e.stale_at_run,...n.length?{unresolved_acs:n}:{},execution_id:e.execution_id,...e.evidence_id?{evidence_id:e.evidence_id}:{},...e.duration_ms!==void 0?{duration_ms:e.duration_ms}:{},started_at:e.started_at,mode:e.mode,local:e.local,...e.via_parent?{via_parent:e.via_parent}:{}}}function Wt(e,t){if(!Array.isArray(t.facts)||t.facts.length===0)return{record:null,errors:[{code:"EMPTY_EXECUTIONS",detail:"parked line carries no facts"}]};for(let r=0;;r++){let n=x(e),i=t.facts.filter(a=>n.appliedEvents.has(a.event_id)).map(a=>a.event_id),o=t.facts.filter(a=>!n.appliedEvents.has(a.event_id));if(o.length===0)return{record:null,errors:null,applied:[],skipped:i,rejected:[]};let s=[],c=[],u=[];for(let a of o){let p=`executions[${a.ref}]`,l=[];if(!a.about_cid||!n.hasNode(a.about_cid))l.push({code:"UNKNOWN_REF",detail:`${p}: about_cid '${String(a.about_cid)}' is not in the graph \u2014 the pinned run-time target is gone`});else if(n.nodeLabel.get(a.about_cid)!==q.TEST)l.push({code:"ILLEGAL_TARGET",detail:`${p}: execution facts attach to tests \u2014 '${a.about_cid}' is a ${n.nodeLabel.get(a.about_cid)}`});else if(!a.event_id)l.push({code:"MISSING_FIELD",detail:`${p}: parked facts require event_id`});else{l.push(...Gt(a,p));for(let m of a.per_ac??[])se.has(m.verdict)||l.push({code:"BAD_VERDICT",detail:`${p}.per_ac['${m.ac_ref}']: verdict '${m.verdict}'`})}if(l.length>0){s.push({event_id:a.event_id??"",errors:l});continue}let d=[],f=[...a.unresolved_acs??[]];for(let m of a.per_ac??[]){let g=n.resolve(m.ac_ref),w=g?n.tipOf(g.cid):null;if(!g||!w||n.superseded.has(w)||n.nodeLabel.get(w)!==q.AC){f.push(m.ac_ref);continue}d.push({ac_ref:n.nameOf.get(w)??w,verdict:m.verdict})}c.push(Kt(a,a.about_cid,d,f)),u.push(a.event_id)}if(c.length===0)return{record:null,errors:null,applied:[],skipped:i,rejected:s};try{let a=H(e,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[],executions:c,event_ids:[...u].sort(),source_head_moves:{}},{expectPrev:n.latestHash,busyRetry:{deadlineMs:5e3}}),p;try{G(e)}catch(l){p=`parked facts committed, but the projection refresh failed (${l instanceof Error?l.message:String(l)}) \u2014 read state rebuilds on the next open`}return{record:a.record,errors:null,applied:u,skipped:i,rejected:s,...p?{warnings:[p]}:{}}}catch(a){if(!(a instanceof he))throw a;if(r>=3)return{record:null,errors:[{code:"STALE_BASIS",detail:"concurrent appends kept moving the head \u2014 parked replay retry budget exhausted (line stays queued)"}]}}}}function tn(e,t,r){let n=[],i=[];for(let c of r.facts){let u=`executions[${c.ref}]`,a=t.resolve(c.ref),p=a?t.tipOf(a.cid):null;if(!a||!p||t.superseded.has(p)){n.push({code:"UNKNOWN_REF",detail:`${u}: '${c.ref}' is not a live committed node`});continue}if(t.nodeLabel.get(p)!==q.TEST){n.push({code:"ILLEGAL_TARGET",detail:`${u}: execution facts attach to tests \u2014 '${c.ref}' is a ${t.nodeLabel.get(p)}`});continue}let l=Gt(c,u);if(l.length>0){n.push(...l);continue}let d=[];for(let f of c.per_ac??[]){let m=t.resolve(f.ac_ref),g=m?t.tipOf(m.cid):null;if(!m||!g||t.superseded.has(g)||t.nodeLabel.get(g)!==q.AC){n.push({code:"UNKNOWN_REF",detail:`${u}.per_ac: '${f.ac_ref}' is not a live AC`});continue}if(!se.has(f.verdict)){n.push({code:"BAD_VERDICT",detail:`${u}.per_ac['${f.ac_ref}']: verdict '${f.verdict}'`});continue}d.push({ac_ref:t.nameOf.get(g)??g,verdict:f.verdict})}i.push(Kt(c,p,d,c.unresolved_acs??[]))}if(n.length>0)return{record:null,errors:n};let o;try{o=H(e,{ts:new Date().toISOString(),proposal_id:null,nodes:[],edges:[],review:[],supersessions:[],executions:i,...r.eventIds&&r.eventIds.length>0?{event_ids:r.eventIds}:{},source_head_moves:{}},{expectPrev:t.latestHash,busyRetry:{deadlineMs:r.lockDeadlineMs??5e3}})}catch(c){if(c instanceof he)return"cas";throw c}let s;try{G(e)}catch(c){s=`facts committed, but the projection refresh failed (${c instanceof Error?c.message:String(c)}) \u2014 read state rebuilds on the next open`}return{record:o.record,errors:null,...s?{warnings:[s]}:{}}}function rr(e){let t={failed:3,broken:2,skipped:1,passed:0},r=new Map;for(let n of e)for(let i of n.verifies??[]){let o=r.get(i);(o===void 0||(t[n.status]??0)>(t[o]??0))&&r.set(i,n.status)}return[...r.entries()].map(([n,i])=>({ref:n,verdict:i}))}function nr(e){let t=[],r=re(e.cwd);if(!O(r))return{synced:0,superseded:0,skipped:"no-context",warnings:t};let n=e.by??{kind:"ai",id:"exec-sync"},i=e.lockDeadlineMs;try{rn(r,t,i)}catch(d){t.push(`sync: parked-facts replay failed (${d instanceof Error?d.message:String(d)}) \u2014 queue intact, retrying next sync`)}let o=x(r),s=[],c=0,u=new Set,a=new Set(e.members.map(d=>ae(d.path)?d.path:ce(e.cwd,d.path))),p=new Map;for(let d of e.members){let f=ae(d.path)?d.path:ce(e.cwd,d.path);if(!O(f)){t.push(`sync: member file missing: ${f} \u2014 skipped, no fact attached`);continue}for(let m of nn(f,t))if(!u.has(m.path))try{let g=m.path===f,w=!g&&a.has(m.path),h=g?void 0:F(P(f,"utf8"))?.id,Y=P(m.path,"utf8"),E=F(Y);if(!E?.id){u.add(m.path);continue}let ue=o.resolve(E.id),N=ue?o.tipOf(ue.cid):null;if(!ue||!N||o.superseded.has(N)){u.add(m.path),t.push(`sync: ${E.id} does not resolve to a live test \u2014 skipped (foreign store?)`);continue}let J=L(U(Y,Z(He(m.path),o))),mr=String(o.getNode(N)?.content.test_md_blob??""),X=L(U(mr,gt(o))),B=!1,Q=N;if(J===X)E.base!==X&&Qt(m.path,Y,X,t);else if(E.base===X){let v=sn(r,o,N,Y,J,He(m.path),n);v.error?(t.push(`sync: could not supersede ${E.id}: ${v.error}`),B=!0):(c++,Q=v.newCid,B=v.oracleTier,Qt(m.path,P(m.path,"utf8"),J,t),o=x(r))}else B=!0,t.push(E.base?`sync: ${E.id} was edited from an older version \u2014 graph kept; reconcile via a redesign or maintain`:`sync: ${E.id} carries no base pin (hand-copied file?) \u2014 fact attached with drift flag`);if(w){B&&p.set(m.path,!0);continue}u.add(m.path);let Ze=o.getNode(Q)?.content.check,et=g?d.acs??[]:[],tt=et.filter(v=>Jt(o,v.ref)),rt=et.filter(v=>!Jt(o,v.ref)).map(v=>v.ref);s.push({ref:E.id,about_cid:Q,definition_id_at_run:J,verdict:d.verdict,...tt.length?{per_ac:tt.map(v=>({ac_ref:v.ref,verdict:v.verdict}))}:{},drift_flag:B||p.get(m.path)===!0||g&&d.driftFlag===!0,oracle_mode:Ze?.expected_mode??(lt(Ze?.operand)?"runtime-derived":"inferred"),stale_at_run:o.stale(Q)!=="fresh",...rt.length?{unresolved_acs:rt}:{},execution_id:d.executionId,...d.evidenceId?{evidence_id:d.evidenceId}:{},...d.durationMs!==void 0?{duration_ms:d.durationMs}:{},started_at:d.startedAt,mode:d.mode,local:d.local,...h?{via_parent:h}:{}})}catch(g){m.path!==f&&a.has(m.path)||u.add(m.path),t.push(`sync: ${m.path} failed to sync (${g instanceof Error?g.message:String(g)}) \u2014 skipped; other members unaffected`)}}if(s.length===0)return{synced:0,superseded:c,warnings:t};let l;try{l=Ht(r,x(r),{facts:s,by:n,lockDeadlineMs:i})}catch(d){return t.push(`sync facts: commit threw: ${d instanceof Error?d.message:String(d)}`),Yt(r,s,n,t,i),{synced:0,superseded:c,warnings:t}}return l.errors?(Yt(r,s,n,t,i),t.push(...l.errors.map(d=>`sync facts: ${d.code}: ${d.detail}`)),{synced:0,superseded:c,warnings:t}):(l.warnings&&t.push(...l.warnings.map(d=>`sync facts: ${d}`)),{synced:s.length,superseded:c,warnings:t})}var Ge="pending-facts.ndjson",qe=".pending-facts.bad";function Yt(e,t,r,n,i){try{let o={by:r,ts:new Date().toISOString(),facts:t.map(c=>({...c,about_cid:c.about_cid??"",event_id:`exec-fact:${c.execution_id}:${c.ref}`}))},s=null;try{s=ee(e,{deadlineMs:i??5e3})}catch{n.push("sync facts: store lock busy \u2014 parking without it (a concurrent queue rewrite may race this line)")}try{Zt(T(e,Ge),JSON.stringify(o)+`
|
|
5
|
+
`)}finally{s?.()}n.push(`sync facts: commit failed \u2014 ${t.length} fact(s) parked to ${T(e,Ge)}; they replay on the next sync`)}catch(o){n.push(`sync facts: could not park the failed batch (${o instanceof Error?o.message:String(o)}) \u2014 this run's facts are LOST`)}}function rn(e,t,r){let n=T(e,Ge);if(!O(n))return;let i;{let a=ee(e,{deadlineMs:r??5e3});try{i=P(n,"utf8")}finally{a()}}let o=i.split(`
|
|
6
|
+
`).filter(a=>a.trim()!=="");if(o.length===0)return;let s=new Set,c=[],u=[];for(let a of o){let p=null;try{let d=JSON.parse(a);d&&Array.isArray(d.facts)&&(p=d)}catch{}if(!p){c.push(a),s.add(a);continue}let l=Wt(e,p);if(l.errors){if(l.errors.some(d=>d.code==="STALE_BASIS")){t.push(`sync: parked facts replay deferred (${l.errors[0].detail}) \u2014 retrying next sync`);continue}c.push(a),s.add(a),t.push(`sync: parked facts line quarantined to ${T(e,qe)} (${l.errors.map(d=>`${d.code}: ${d.detail}`).join("; ")})`);continue}for(let d of l.rejected){let f=p.facts.find(m=>m.event_id===d.event_id);u.push({parent:a,line:JSON.stringify({...f??{event_id:d.event_id},_reason:d.errors})})}l.rejected.length>0&&t.push(`sync: ${l.rejected.length} parked fact(s) quarantined to ${T(e,qe)} (${l.rejected.map(d=>d.errors.map(f=>`${f.code}: ${f.detail}`).join("; ")).join(" | ")})`),s.add(a),l.warnings&&t.push(...l.warnings.map(d=>`sync: ${d}`)),l.applied.length>0&&t.push(`sync: replayed ${l.applied.length} parked fact(s) from a previous run`)}if(s.size!==0)try{let a=ee(e,{deadlineMs:r??5e3});try{let l=(O(n)?P(n,"utf8"):"").split(`
|
|
7
|
+
`).filter(g=>g.trim()!==""),d=[...c.filter(g=>l.includes(g)),...u.filter(g=>l.includes(g.parent)).map(g=>g.line)];d.length>0&&Zt(T(e,qe),d.map(g=>g+`
|
|
8
|
+
`).join(""));let f=l.filter(g=>!s.has(g)),m=`${n}.tmp.${process.pid}`;tr(m,f.length>0?f.join(`
|
|
9
|
+
`)+`
|
|
10
|
+
`:""),er(m,n)}finally{a()}}catch(a){t.push(`sync: queue rewrite failed (${a instanceof Error?a.message:String(a)}) \u2014 already-applied lines dedupe next sync; bad lines re-quarantine then`)}}function nn(e,t){let r=[],n=new Set,i=o=>{if(n.has(o)||!O(o))return;n.add(o);let s;try{s=P(o,"utf8")}catch(c){t.push(`sync: unreadable unit ${o} (${c instanceof Error?c.message:String(c)}) \u2014 skipped`);return}for(let c of s.split(`
|
|
11
|
+
`)){let u=/^@import\s+(\S+)\s*$/.exec(c.trim());if(!u)continue;let a=ae(u[1])?u[1]:ce(He(o),u[1]);if(!O(a))continue;let p;try{p=P(a,"utf8")}catch(l){t.push(`sync: unreadable import ${a} (${l instanceof Error?l.message:String(l)}) \u2014 skipped; importer continues`);continue}F(p)?.id&&i(a)}r.push({path:o})};return i(e),r}function Jt(e,t){let r=e.resolve(t),n=r?e.tipOf(r.cid):null;return!!(r&&n&&!e.superseded.has(n)&&e.nodeLabel.get(n)==="ac")}function on(e,t,r){let n=e.split(`
|
|
12
|
+
`),i=ft(n);return n.map((o,s)=>{let c=mt.exec(o.trim());if(!c||i.has(s))return o;let u=c[1];if(r.resolve(u))return o;let a=ae(u)?u:ce(t,u);if(!O(a))return o;let p=F(P(a,"utf8"))?.id;return!p||!r.resolve(p)?o:`@import ${p}`}).join(`
|
|
13
|
+
`)}function sn(e,t,r,n,i,o,s){let c=t.getNode(r);if(!c)return{oracleTier:!1,error:"tip unreadable"};let u=on(ht(n),o,t),a=String(c.content.test_md_blob??""),p=/^#\s+(.+?)\s*$/m.exec(u)?.[1]??String(c.content.title??""),l={...c.content,test_md_blob:u,definitionId:i,title:p};{let h=an(u);h.target!==void 0?l.target=h.target:delete l.target,h.app!==void 0?l.app=h.app:delete l.app}let d=vt("test",l);if(d.length>0)return{oracleTier:!1,error:d.map(h=>h.detail).join("; ")};let f=yt("test",l);if(f===r)return{newCid:r,oracleTier:!1};let m=Xt(a)!==Xt(u);if(bt(t,r,f))return{oracleTier:m,error:"file content reproduces an already-superseded version (supersession cycle guard) \u2014 graph kept; re-edit forward or redesign"};let g=wt({graph:t,oldTip:r,newCid:f,newLabel:"test",by:s,reason:`re-blessed onto ${f} (edited on disk, run sync)`});if(g.errors.length>0)return{oracleTier:m,error:`edge re-bless refused: ${g.errors.join("; ")}`};let w=te(e);if(t.latestHash!==w)return{oracleTier:m,error:`store advanced under the sync (basis ${String(t.latestHash)} vs head ${String(w)}) \u2014 re-run to retry`};try{H(e,{ts:new Date().toISOString(),proposal_id:null,nodes:[{cid:f,label:"test",content:l}],edges:g.edges,review:[{id:f,kind:"review-item",resolution:"edited",edit:null,reason:"edited on disk (run sync)",by:s}],supersessions:[{kind:"node",old:r,new:f,reason:"edited on disk (run sync)",by:s},...g.supersessions],source_head_moves:{}},{expectPrev:w})}catch(h){return{oracleTier:m,error:h instanceof Error?h.message:String(h)}}return G(e),{newCid:f,oracleTier:m}}function an(e){let t=pt(e);return{...typeof t.target=="string"?{target:t.target}:{},...typeof t.app=="string"?{app:t.app}:{}}}function Xt(e){let t=[],r=e.split(`
|
|
14
|
+
`),n=r.some(o=>/^##\s/.test(o)&&_e.test(o)),i=!1;for(let o of r){if(/^##\s/.test(o)){let s=_e.exec(o);i=n?s!==null:/\bassert\b/i.test(o),s&&t.push(`v:${s[1].trim()}`);continue}i&&o.trim()!==""&&t.push(o.trim())}return t.join(`
|
|
15
|
+
`)}var cn=0;function Qt(e,t,r,n){try{let i=t.split(`
|
|
16
|
+
`),o=-1;if(i[0]?.trim()==="---"){for(let u=1;u<i.length;u++)if(i[u].trim()==="---"){o=u;break}}if(o<0)return;let s=_t(i,o);if(!s)return;if(s.baseLine!==void 0){let u=i[s.baseLine].endsWith("\r")?"\r":"";i[s.baseLine]=`${s.childIndent}base: ${r}${s.baseComment?` ${s.baseComment}`:""}${u}`}else if(s.strayBase){n.push(`sync: ${e} has a base: line this scanner cannot confidently rewrite (unexpected indentation or key quoting) \u2014 pin refresh skipped (stale pin until the shape is fixed)`);return}else{let a=i[s.idLine??s.start].endsWith("\r")?"\r":"";i.splice((s.idLine??s.start)+1,0,`${s.childIndent??" "}base: ${r}${a}`)}let c=`${e}.tmp-sync.${process.pid}-${cn++}`;tr(c,i.join(`
|
|
17
|
+
`)),er(c,e)}catch(i){n.push(`sync: pin refresh failed for ${e} (${i instanceof Error?i.message:String(i)}) \u2014 next run self-heals`)}}var gn={passed:"passed",failed:"failed",broken:"blocked",skipped:"not-run"},ir=(e,t)=>{try{if(!Ke(t))return{status:"skipped",reason:"no context store at the project root"};let r=M(e,"tests");if(!Ke(r))return{status:"skipped",reason:"pack has no tests/"};let n=new Map;for(let c of un(r)){let u=M(r,c,"result.yaml");if(!Ke(u)||!mn(M(r,c)).isDirectory())continue;let a=$(ln(u,"utf8"));if(!a?.definition_id&&!a?.assurance_id)continue;let p=rr(a.steps??[]),l={testShortId:String(a.test??c),execution:gn[String(a.status)]??"not-run",...p.length?{acs:p}:{}};a.assurance_id&&n.set(`id:${a.assurance_id}`,l),a.definition_id&&n.set(`def:${a.definition_id}`,l)}let i=xt(x(t),n,{scope:"run"}),o=kt(i);qt(e,t,i);let s=k({...i,rollup:o},{lineWidth:-1});return dn(M(e,"coverage"),{recursive:!0}),fn(M(e,"coverage","usecases.yaml"),s),{status:"written"}}catch(r){try{pn(M(e,"coverage","sources"),{recursive:!0,force:!0})}catch{}return{status:"skipped",reason:r instanceof Error?r.message:String(r)}}};async function hn(e){try{let t=new W({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 vn(e,t,r){if(!e)return;e.session.noteSpawn(t),t.resolution&&(e.resolution=t.resolution),e.runnerEnvironment=st(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 yn(e){if(e)return{packTestDir:e.packTestDir,ordinalOffset:e.session.nextOrdinalOffset()}}async function bn(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 _n.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:Ue({cdpBrowser:n,resolution:e.resolution,runnerEnvironment:e.runnerEnvironment,deviceName:t.deviceName,deviceModel:t.deviceModel,pixelResolution:await Tt(e.packTestDir)}),intentEnv:ct(t.model,e.runnerEnvironment),durationMs:t.durationMs??Date.now()-e.startedAtMs,log:t.log});try{if(t.recordedTestPath){let s=nr({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 c of s.warnings)r("EXEC_SYNC",c)}}catch(s){r("EXEC_SYNC","exec-sync failed",{error:String(s)})}try{let s=(t.coverageWriter??ir)(e.packDir,re(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 ze({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 wn,openSync as kn,readSync as xn,closeSync as En}from"fs";import{basename as In,resolve as Sn}from"path";async function Rn(e,t,r={}){let n=r.out??(p=>process.stdout.write(p+`
|
|
18
|
+
`)),i=p=>(n(`error: ${p}`),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=K(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 p of e){let l=Sn(p),d;try{d=wn(l)}catch{return i(`${p}: not found`)}if(d.isDirectory())return i(`${p}: is a directory \u2014 packs must be sealed .evidence files (run the execution to completion, or seal it, first)`);if(!d.isFile())return i(`${p}: not a regular file`);let f=Buffer.alloc(2),m=kn(l,"r");try{xn(m,f,0,2,0)}finally{En(m)}if(f.toString("latin1")!=="PK")return i(`${p}: not a sealed evidence pack (zip magic missing)`);let g=In(l);if(s.has(g))return i(`duplicate pack basename: ${g} (URL names collide \u2014 rename one)`);s.set(g,l)}let c=r.log??((p,l,d)=>process.stderr.write(`warn: ${l} reason=${d.reason} path=${d.path}
|
|
19
|
+
`)),u;try{u=await ve({packs:s,allowedOrigins:[new URL(o).origin],port:t.port,log:c})}catch(p){return i(`could not bind 127.0.0.1${t.port?`:${t.port}`:""} \u2014 ${p.message}`)}n(`serving ${s.size} pack${s.size===1?"":"s"} on http://127.0.0.1:${u.port}`);for(let p of s.keys()){let l=u.urlFor(p);n(p),n(` pack ${l}`),n(` viewer ${ye(l,o)}`)}return n("press Ctrl-C to stop"),await(r.hold??An)(),await u.close(),0}function An(){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 de}from"fs";import{tmpdir as Fn}from"os";import{join as ar,resolve as Ye}from"path";var Pn=["error","prefer_first","prefer_latest","discard"],$n=["external_id.commit_id","external_id.test_id","environment.os","environment.os_version","environment.browser","environment.browser_version"];function or(e){let t=e.replace(/-/g,"_");return Pn.includes(t)?t:null}function sr(e){let t=e==="discard"?{on_collision:"discard"}:{on_collision:"error",identity:{keys:[...$n],on_same:e??"nest",on_different:e?"error":"split"}};return k({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 We(e){try{if(!e.isTTY){e.log(be(e.packPath));return}let t=K(e.env);await(e.renderPrompt??Ln)(e.packPath,t)}catch(t){try{e.log(`evidence view failed \u2014 ${t.message}`)}catch{}}}async function Ln(e,t){let r=await import("./react-QWOAB3TB.js"),{render:n}=await import("./build-JIKYOZUH.js"),{EvidenceViewOffer:i}=await import("./EvidenceViewOffer-UACWB3YJ.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 Cn(e,t,r=process.cwd(),n={}){let i=n.out??(d=>process.stdout.write(d+`
|
|
20
|
+
`)),o=n.err??(d=>process.stderr.write(d+`
|
|
21
|
+
`)),s=d=>(o(`evidence merge: ${d}`),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 c;if(t.onCollision!==void 0){let d=or(t.onCollision);if(!d)return s(`invalid --on-collision: ${t.onCollision} (expected error | prefer-first | prefer-latest | discard)`);c=d}let u=[];for(let d of e){let f=await Dn(d,r);if(!f)return s(`no pack found for "${d}"`);u.push(f)}let a=t.out?Ye(r,t.out):y(t.runId,r),p=null,l;t.rules?l=Ye(r,t.rules):(p=await de.mkdtemp(ar(Fn(),"kane-merge-rules-")),l=ar(p,"merge-rules.yaml"),await de.writeFile(l,sr(c)));try{let d=await(n.mergeFn??dt)(u,{runId:t.runId,out:a,rulesPath:l,title:t.title,finalize:t.finalize});return t.json?i(JSON.stringify(d)):jn(i,d),d.output.finalized&&!t.json&&await(n.offer??We)({packPath:a,env:t.env,isTTY:n.isTTY??(!!process.stdin.isTTY&&!!process.stderr.isTTY),log:o}),0}catch(d){let f=d instanceof Error?d.message:String(d);return d?.code==="ABORT"?(o(`evidence merge: aborted \u2014 ${f}`),1):s(f)}finally{p&&await de.rm(p,{recursive:!0,force:!0}).catch(()=>{})}}async function Dn(e,t){let r=Ye(t,e);if(await cr(r))return r;let n=y(e,t);return await cr(n)?n:null}async function cr(e){try{return await de.stat(e),!0}catch{return!1}}function jn(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 On,existsSync as Je,mkdirSync as Tn}from"fs";import{join as dr}from"path";function Mn(e,t,r){try{let n=dr(e,"auteur","execution.json");if(Je(n))return!0;for(let i of t)if(!(!i||!Je(i)))return Tn(dr(e,"auteur"),{recursive:!0}),On(i,n),!0}catch(n){try{r?.("debug","EVIDENCE_BLOB_COPY_FAILED","auteur execution blob copy failed",{operation:"ensureAuteurExecution",source:t.find(i=>i&&Je(i))??null,error:n instanceof Error?n.message:String(n)})}catch{}}return!1}import{readFileSync as Nn}from"fs";import{join as Bn}from"path";var ur="module_block";var Vn=new Set(["generative_block",ur]);function Qe(e){let t=[],r=!0,n=o=>{if(o===null||typeof o!="object")return;let s=o;if(Array.isArray(s.operations))for(let c of s.operations){let u=c?.operation_id;typeof u=="string"&&u&&t.push(u)}if(Array.isArray(s.children)){Vn.has(s.content_type)||(r=!1);for(let c of s.children)n(c)}if(Array.isArray(s.branches)){r=!1;for(let c of s.branches){let u=c?.children;if(Array.isArray(u))for(let a of u)n(a)}}},i=e?.instructions;if(Array.isArray(i))for(let o of i)n(o);return{ids:t,linear:r}}function zn(e){return Qe(e).ids}function Xe(e,t){let r=new Set(t.map(c=>c.action_id).filter(Boolean)),n=-1;for(let c of r){let u=e.indexOf(c);u>n&&(n=u)}let i=t.reduce((c,u)=>Math.max(c,u.ordinal),0),o=new Set,s=[];for(let c of e.slice(n+1))r.has(c)||o.has(c)||(o.add(c),s.push({id:c,ordinal:++i,status:"skipped",action_id:c}));return s}function lr(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 Un(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 qn(e,t,r,n=!0){if(t.length===0)return{steps:e,tail:[]};let i=(r&&n?lr(e,t):null)??e,o=i.filter(c=>c.action_id),s=new Set(t);return o.length>0&&o.every(c=>s.has(c.action_id))?{steps:i,tail:Xe(t,i)}:o.length>0&&!Un(o,t)?{steps:i,tail:[],unjoined:!0}:{steps:i,tail:Xe(t,i)}}function pr(e){try{let t=Nn(Bn(e,"auteur","execution.json"),"utf8");return Qe(JSON.parse(t))}catch{return{ids:[],linear:!0}}}function Hn(e){return pr(e).ids}export{D as a,we as b,ke as c,xe as d,Ee as e,Ie as f,It as g,Re as h,_r as i,Ae as j,Pe as k,hr as l,vr as m,$e as n,ne as o,Ce as p,De as q,je as r,Oe as s,yr as t,br as u,Te as v,wr as w,Me as x,Ne as y,Be as z,Ct as A,ze as B,Tt as C,Ue as D,Bt as E,Br as F,W as G,Kr as H,rr as I,nr as J,ir as K,hn as L,vn as M,yn as N,bn as O,Rn as P,sr as Q,We as R,Cn as S,Mn as T,ur as U,Qe as V,zn as W,Xe as X,lr as Y,qn as Z,pr as _,Hn as $};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as w,c as M}from"./chunk-KRL2BDI5.js";import{dirname as K,basename as N,join as d}from"path";function W(t){let e=N(t);return e.endsWith("_test.md")?e.slice(0,-8):e.endsWith("_module.md")?e.slice(0,-10):e.endsWith(".md")?e.slice(0,-3):e}function f(t){return d(K(t),`output-${W(t)}`)}function nt(t){return d(f(t),"Result.md")}function _(t){return d(f(t),".internal")}function x(t){return d(_(t),"meta.json")}function it(t){return d(_(t),"execution.json")}function rt(t,e,n){return d(f(t),`${e}-${n}-code`)}function ot(t){return d(f(t),"generated-code")}function st(t){return f(t)+".staging"}function G(t){return d(_(t),"steps")}function dt(t,e,n){return d(G(t),`${e}-${n}`)}import{writeFileSync as J,mkdirSync as L,readFileSync as H}from"fs";import{dirname as j}from"path";function k(t){try{return JSON.parse(H(x(t),"utf8"))}catch{return null}}function ut(t){let e=x(t.sourcePath);try{L(j(e),{recursive:!0})}catch(r){return process.stderr.write(`
|
|
3
|
+
\u26A0 Failed to create output directory.
|
|
4
|
+
${r.message}
|
|
5
|
+
Path: ${j(e)}
|
|
6
|
+
|
|
7
|
+
`),e}let n={commit_id:t.commitId};t.testId!==void 0&&(n.test_id=t.testId),t.testcaseId!==void 0&&(n.testcase_id=t.testcaseId),t.projectId!==void 0&&(n.project_id=t.projectId),t.folderId!==void 0&&(n.folder_id=t.folderId),t.orgId!==void 0&&(n.org_id=t.orgId),t.sessionName!==void 0&&(n.session_name=t.sessionName),t.plan!==void 0&&(n.plan=t.plan);try{J(e,JSON.stringify(n,null,2)+`
|
|
8
|
+
`,"utf8")}catch(r){process.stderr.write(`
|
|
9
|
+
\u26A0 Failed to write meta.json.
|
|
10
|
+
${r.message}
|
|
11
|
+
Path: ${e}
|
|
12
|
+
|
|
13
|
+
`)}return e}import{readFileSync as Y,existsSync as z}from"fs";import{basename as C,dirname as q,isAbsolute as Q,resolve as T}from"path";import{createHash as O}from"crypto";function h(t){if(t==null)return null;if(Array.isArray(t))return t.map(h);if(typeof t=="object"){let e={};for(let n of Object.keys(t).sort()){let r=t[n];r!==void 0&&(e[n]=h(r))}return e}return t}function U(t){if(t.body.kind!=="objective")throw new Error("stepMd5: only objective steps have an md5; @import rows do not");let e={...t.config??{},optional:t.optional??!1},n=JSON.stringify(h(e));return O("md5").update(t.body.text).update(`
|
|
14
|
+
`).update(n).digest("hex")}function I(t){let e={};for(let[r,o]of Object.entries(t.bindings??{}))e[r]={value:o.value,...o.secret===!0?{secret:!0}:{},...o.syntax?{syntax:o.syntax}:{}};let n=JSON.stringify(h({bindings:e,optional:t.optional}));return O("md5").update(t.path).update(`
|
|
15
|
+
`).update(n).digest("hex")}function mt(t){return U({index:t.trace[t.trace.length-1].stepIndex,heading:t.trace[t.trace.length-1].heading,verifies:[],body:{kind:"objective",text:t.objective},config:t.parsedConfig,headingLine:1,optional:t.optional})}var E=["target","chrome_profile","cdp_endpoint","ws_endpoint","headless"],X=["app","no_reset","os_version","device_name"],Z=["mode","on_lock_conflict","tags","target","chrome_profile","cdp_endpoint","ws_endpoint","headless","app","no_reset","os_version","device_name"],u=class extends Error{constructor(e){super(e),this.name="TestMdResolveError"}};function v(t){let e=C(t);return e.endsWith("_test.md")?"test":e.endsWith("_module.md")?"module":"helper"}function Rt(t){let e=T(t),n=$(e),r=B(n.global),o=[],a=[],s=[{file:e,kind:v(e)}],c=[];return F(n,a,o,[],e,{},s,c,{}),o.forEach((l,b)=>l.flatIndex=b+1),{rootPath:e,rootTitle:n.title,rootGlobal:n.global,rootSteps:n.steps,chrome:r,steps:o,unitFiles:s,warnings:c}}function St(t){let e=[];for(let n of t.unitFiles){if(n.kind!=="test")continue;let r=k(n.file);r&&e.push({file:n.file,...r.project_id?{project_id:String(r.project_id)}:{},...r.org_id?{org_id:String(r.org_id)}:{}})}return e}function $(t){if(!z(t))throw new u(`@import path not found: ${t}`);let e=Y(t,"utf8");return w(t,e)}function F(t,e,n,r,o,a,s,c,p){if(e.includes(t.path)){let i=[...e,t.path].map(g=>C(g)).join(" \u2192 ");throw new u(`cyclic reference: ${i}`)}e.push(t.path);let l=r.length===0,b=t.global.variables??{};for(let i of Object.keys(a))if(Object.hasOwn(b,i))throw new u(`callsite binding '${i}' collides with a declared variable in ${t.path} (frontmatter variables are pinned; parameters are its undeclared names)`);let R=t.global;if(!l){let i={...t.global};for(let g of Z)i[g]!==void 0&&(c.push(`${t.path}: '${g}' is root-governed on imported units \u2014 ignored`),delete i[g]);i.url!==void 0&&(p.pending=String(i.url),delete i.url),R=i}for(let i of t.steps){let g=i.body.kind!=="objective";if(i.optional&&g&&!l)throw new u(`intermediate-ref 'optional' is not supported in v1: ${t.path}:${i.headingLine}`);if(i.body.kind==="objective"){let y={file:t.path,stepIndex:i.index,heading:i.heading,optional:i.optional??!1},D=tt(R,i.config,a),S={flatIndex:0,objective:i.body.text,sourceFile:t.path,trace:[...r,y],config:D,parsedConfig:i.config,optional:i.optional??!1,verifies:i.verifies,owningFile:t.path,unitKind:v(t.path),...i.replayOnly?{replayOnly:i.replayOnly}:{}};p.pending&&(S.unitEntryUrl=p.pending,p.pending=void 0),n.push(S);continue}let P={file:t.path,stepIndex:i.index,heading:i.heading,optional:i.optional??!1,rowMd5:I({path:i.body.path,bindings:i.body.bindings,optional:i.optional??!1})},V=q(t.path),m=Q(i.body.path)?i.body.path:T(V,i.body.path),A=$(m);s.some(y=>y.file===m)||s.push({file:m,kind:v(m)}),F(A,e,n,[...r,P],o,i.body.bindings??{},s,c,p)}l||(p.pending=void 0),e.pop()}function B(t){let e={};for(let n of E){if(n==="target"){let r=M(t);r!==void 0&&(e.target=r);continue}t[n]!==void 0&&(e[n]=t[n])}return e}function tt(t,e,n){let r={};for(let[s,c]of Object.entries(t))E.includes(s)||X.includes(s)||(r[s]=c);let o={...r,...e??{}},a={...n,...t.variables??{},...e?.variables??{}};return Object.keys(a).length>0?o.variables=a:delete o.variables,o}export{W as a,f as b,nt as c,_ as d,x as e,it as f,rt as g,ot as h,st as i,G as j,dt as k,I as l,mt as m,k as n,ut as o,u as p,v as q,Rt as r,St as s};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as j}from"./chunk-O5U6EAL3.js";import{d as K}from"./chunk-RKXHVP2Z.js";import{a as L}from"./chunk-5Y2G4NC7.js";import{a as M}from"./chunk-YCCUBQY4.js";import{x as s}from"./chunk-WEJA3EVI.js";import{a as O}from"./chunk-HCBYKLMW.js";import{a as x,b as n,i as D,k as E}from"./chunk-C44QQJR4.js";import{a as I}from"./chunk-6YGTRKDT.js";import{e as y}from"./chunk-UR6MHSHU.js";var g=y(O(),1);function ee(e){let t=e.findIndex(r=>r.free);return t>=0?t:null}var q=60,Q=100;function te({headline:e,ask:t=!1,rows:r,sel:o,focused:d,freeText:c=null,freeTextNote:h,sublines:b=[]}){let{stdout:p}=E(),i=p?.columns??80,v=i<q,k=Math.min(i-1,Q),u=a=>d&&o===a?(0,g.jsx)(n,{color:s.assuranceAccent,children:"\u276F"}):" ",m=t?`? ${e}`:e,A=Math.max(4,k-3),S=b.map((a,w)=>(0,g.jsx)(n,{color:s.dim,children:` ${a.length>A?`${a.slice(0,A-1)}\u2026`:a}`},`sub-${w}`)),R=0,B=r.map((a,w)=>a.free?c?(0,g.jsxs)(x,{flexDirection:"column",children:[(0,g.jsxs)(x,{children:[(0,g.jsxs)(n,{children:[(0,g.jsx)(n,{color:s.assuranceAccent,children:"\u276F"})," ",(0,g.jsx)(n,{color:s.dim,children:"\u270E "})]}),(0,g.jsx)(M,{value:c.value,onChange:c.onChange,onSubmit:c.onSubmit,onCancel:c.onCancel,placeholder:a.label})]}),h?(0,g.jsx)(n,{color:s.muted,children:` ${h}`}):null]},a.key):(0,g.jsxs)(n,{children:[u(w)," ",(0,g.jsx)(n,{color:s.dim,children:`\u270E ${a.label}`})]},a.key):(R+=1,(0,g.jsxs)(n,{bold:d&&o===w,children:[u(w),` ${R}. ${a.label}`,a.detail?(0,g.jsx)(n,{color:s.dim,bold:!1,children:` \u2014 ${a.detail}`}):null]},a.key)));return v?(0,g.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,g.jsx)(n,{bold:!0,color:s.assuranceAccent,children:m}),S,B]}):(0,g.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,g.jsx)(n,{bold:!0,color:s.assuranceAccent,children:m}),S,(0,g.jsx)(n,{children:" "}),B]})}var H=y(I(),1);var $=y(O(),1),N=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function le(e){let t=e.replace(/…$/,"");return t&&t.charAt(0).toLowerCase()+t.slice(1)}function F(e,t){if(e.length<=t)return e;if(t<=1)return"\u2026";let r=Math.ceil((t-1)/2),o=Math.floor((t-1)/2);return`${e.slice(0,r)}\u2026${o>0?e.slice(-o):""}`}function ce({status:e,meta:t,tallies:r,keys:o,child:d,cols:c}){let{stdout:h}=E(),b=c??h?.columns??80,p=e.kind==="working"||e.kind==="child-working",[i,v]=(0,H.useState)(0);L(()=>v(f=>f+1),p?120:null);let k=N[i%N.length],u,m;switch(e.kind){case"working":u=`${k} ${e.step}${e.elapsedS!==void 0?` \xB7 ${e.elapsedS}s`:""}`,m=s.assuranceAccent;break;case"waiting":u=`\u25CF waiting on you${e.pending?` \u2014 ${e.pending} question${e.pending===1?"":"s"}`:""}`,m=s.amber;break;case"idle":u="\u25CF idle",m=s.assuranceAccent;break;case"card":u=`\u25CF card ${e.n} of ${e.m}`,m=s.amber;break;case"child-working":u=`${k} child: ${e.step}`,m=s.assuranceAccent;break;case"child-waiting":u="\u25CF child waiting on you",m=s.amber;break}let A=d?`${t.verb} \u25B8 ${d.verb}`:t.verb,S=d?.sid?t.sid?`${F(t.sid,14)} \u25B8 ${d.sid}`:d.sid:t.sid,R=t.env==="prod"?"":t.env,B=[A,S,R].filter(Boolean),a=" \xB7 ",w=u.length+a.length+B.join(a).length,C=t.subject;if(C){let f=b-w-a.length;C=f>=8?F(C,f):void 0}let _=[A,...C?[C]:[],S,R].filter(Boolean).join(a);return(0,$.jsxs)(x,{flexDirection:"column",children:[(0,$.jsx)(n,{color:s.muted,children:"\u2500".repeat(Math.max(1,b))}),(0,$.jsxs)(n,{children:[(0,$.jsx)(n,{color:m,children:u}),(0,$.jsx)(n,{color:s.dim,children:`${a}${_}`})]}),(0,$.jsx)(n,{color:s.dim,children:r.items.length>0?r.items.join(a):" "}),(0,$.jsx)(n,{color:s.muted,children:o.join(a)})]})}var P=y(I(),1);function ue({onToggleThinking:e,onCtrlC:t,explorer:r,panel:o}){let c=(0,P.useRef)(null),h=(0,P.useRef)(""),b=()=>{c.current&&clearTimeout(c.current),c.current=null,h.current=""};return(0,P.useEffect)(()=>b,[]),D((p,i)=>{if(i.ctrl&&p==="t"){e();return}if(i.ctrl&&p==="c"){t();return}if(!i.ctrl&&p.includes("")){t();return}if(!i.ctrl&&p.includes("")){e();return}if(r&&r.isOpen()){let v=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{b(),r.onBack()},150)};if(c.current){if(i.upArrow||i.downArrow||i.return){b(),i.return?r.onEnter():r.onMove(i.upArrow?-1:1);return}if(h.current+=p,h.current==="["){v();return}let k=h.current;b();let u=/^\[([ABCD])/.exec(k);if(u){(u[1]==="A"||u[1]==="B")&&r.onMove(u[1]==="A"?-1:1);return}r.onBack();return}if(i.upArrow){r.onMove(-1);return}if(i.downArrow){r.onMove(1);return}if(i.return){r.onEnter();return}if(i.escape){h.current="",v();return}return}if(o&&o.isFocused()){let v=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{b(),o.onBack()},150)};if(c.current){if(i.upArrow||i.downArrow||i.return||i.leftArrow||i.rightArrow){b(),i.return?o.onSelect():i.leftArrow?o.onLeft?.():i.rightArrow?o.onRight?.():o.onMove(i.upArrow?-1:1);return}if(h.current+=p,h.current==="["){v();return}let k=h.current;b();let u=/^\[([ABCD])/.exec(k);if(u){u[1]==="A"||u[1]==="B"?o.onMove(u[1]==="A"?-1:1):u[1]==="C"?o.onRight?.():o.onLeft?.();return}o.onBack();return}if(i.upArrow){o.onMove(-1);return}if(i.downArrow){o.onMove(1);return}if(i.leftArrow){o.onLeft?.();return}if(i.rightArrow){o.onRight?.();return}if(i.return){o.onSelect();return}if(i.escape){h.current="",v();return}if(/^[1-9]$/.test(p)){o.onDigit(Number(p));return}if(i.tab){o.onTab?.();return}if(p===" "&&o.isMulti()){o.onSpace();return}if(p&&!i.ctrl&&!i.meta){o.onType(p);return}return}}),null}var l=y(O(),1);function X(e){return e.kind==="REVIEW"?[{v:"approve",label:"approve",detail:"mark it reviewed and trusted"},{v:"archive",label:"archive",detail:"reject it \u2014 asks for a reason; impact shown above"},{v:"defer",label:"defer",detail:"not now \u2014 stays queued"}]:e.kind==="PAIR"?[{v:"merge",label:"merge",detail:"duplicate \u2014 fold into the older item (it stays unreviewed)"},{v:"keep_both",label:"keep both",detail:"genuinely distinct \u2014 promote both"},{v:"defer",label:"defer",detail:"not now \u2014 stays queued"}]:e.kind==="ARCHIVE"?[{v:"archive",label:"retire",detail:"hidden from now on; history is kept and it can be reverted"},{v:"skip",label:"skip",detail:"keep it \u2014 decided, never re-offered"},{v:"defer",label:"defer",detail:"not now \u2014 the plan re-offers it"}]:e.heldPayload?[{v:"approve",label:"approve update",detail:"commit the held payload \u2014 impact preview above"},{v:"skip",label:"keep current",detail:"drop the held payload (the owner's disk state stays untouched)"},{v:"defer",label:"defer",detail:"not now \u2014 stays held"}]:[{v:"approve",label:"approve",detail:e.kind==="ADD"?"commit + design it":"commit the updated version (old\u2192new redirect)"},{v:"skip",label:e.origin==="content-change"?"reject":"skip",detail:e.origin==="content-change"?"drop the staged proposal \u2014 nothing committed":"leave it as is"},{v:"defer",label:"defer",detail:"not now \u2014 the plan keeps it staged"}]}function V(e){let t=X(e);return e.viewDiff&&t.push({v:"view_diff",label:"view diff",detail:"full old \u2192 new"}),t}function W(e){return e.kind==="ARCHIVE"?null:V(e).length}var Y={ADD:{color:s.green??"green"},MODIFY:{color:"yellow"},ARCHIVE:{color:s.red},REVIEW:{color:"cyan"},PAIR:{color:"magenta"}},U=60;function be({card:e,position:t,sel:r=0,focused:o=!1,freeText:d=null,editorIntent:c="steer"}){let{stdout:h}=E(),b=h?.columns??80,p=b<U,i=V(e),v=W(e),k=Y[e.kind],u=f=>o&&r===f?(0,l.jsx)(n,{color:s.assuranceAccent,children:"\u276F"}):" ",m=e.impact,A=m&&"stale_refs"in m&&m.stale_refs.length>0?`${e.kind==="ARCHIVE"?"retiring leaves":"approving marks"} ${m.stale_refs.length} item(s) stale`+((m.direct_refs?.length??0)>0?` \u2014 ${m.direct_refs.length} directly touched: ${m.direct_refs.join(", ")}`:""):m&&"design_children"in m?`${e.kind==="REVIEW"?"archiving drops":"merging folds"} ${m.design_children} design child(ren)`:null,S=e.provenance&&e.provenance!==e.why?e.provenance:e.origin??null,R=[{label:"why",text:e.why},...S?[{label:"from",text:S,dimmer:!0}]:[],...e.tier?[{label:"match",text:e.tier,dimmer:!0}]:[],...A?[{label:"impact",text:A}]:[]],B=Math.max(...R.map(f=>f.label.length)),a="? reconcile",w=`item ${t.n} of ${t.of}`,C=(0,l.jsxs)(x,{flexDirection:"column",children:[(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsxs)(n,{bold:!0,children:[(0,l.jsx)(n,{color:k.color,children:`[${e.kind}]`}),` ${j(e.title)}`]})}),R.map((f,T)=>(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{color:s.dim,children:`${f.label.padEnd(B)} `}),(0,l.jsx)(n,{color:f.dimmer?s.dim:void 0,children:f.text})]})},`f-${T}`)),e.diffSummary?(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsx)(n,{color:s.dim,children:e.diffSummary})}):(e.diff??[]).map((f,T)=>(0,l.jsx)(x,{paddingLeft:4,children:(0,l.jsx)(n,{color:f.op==="-"?"red":"green",children:`${f.op==="-"?"\u2212":"+"} ${f.field==="criteria"?"criterion":f.field}: ${f.text}`})},`d-${T}`)),(e.citeLines??[]).map((f,T)=>(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsx)(n,{color:s.dim,children:f})},`c-${T}`)),(0,l.jsx)(n,{children:" "}),i.map((f,T)=>(0,l.jsxs)(n,{children:[u(T),` ${T+1}. ${f.label}`,(0,l.jsx)(n,{color:s.dim,children:` \u2014 ${f.detail}`})]},`o-${T}`)),v!==null||d&&c==="because"?d?(0,l.jsxs)(x,{flexDirection:"column",children:[(0,l.jsxs)(x,{children:[(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{color:s.assuranceAccent,children:"\u276F"})," ",(0,l.jsx)(n,{color:s.dim,children:"\u270E "})]}),(0,l.jsx)(M,{value:d.value,onChange:d.onChange,onSubmit:d.onSubmit,onCancel:d.onCancel,placeholder:c==="because"?"why archive it?":"say what to adjust"})]}),(0,l.jsx)(n,{color:s.muted,children:c==="because"?" submits as: archive \xB7 your reason goes on the record":e.kind==="PAIR"?" submits as: defer \xB7 your note parks with the card (it re-offers)":" submits as: approve \xB7 your words steer the re-design"})]}):v!==null?(0,l.jsxs)(n,{children:[u(v)," ",(0,l.jsx)(n,{color:s.dim,children:e.kind==="PAIR"?"\u270E defer with a note \u2014 say what you noticed":"\u270E approve with changes \u2014 say what to adjust"})]}):null:null]});if(p)return(0,l.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,l.jsx)(n,{bold:!0,color:s.assuranceAccent,children:a}),(0,l.jsx)(n,{color:s.dim,children:w}),C]});let _=Math.max(2,Math.min(b-1,100)-a.length-w.length);return(0,l.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{bold:!0,color:s.assuranceAccent,children:a})," ".repeat(_),(0,l.jsx)(n,{color:s.dim,children:w})]}),(0,l.jsx)(n,{children:" "}),C]})}var z={"acceptance criteria":1,scenarios:2,"acceptance criteria + exercises":3,"tests + gaps":4};function we(e,t){let r=[],o=K(e.turns).entries.length;if(t==="design"){let c;for(let b=e.ledger.length-1;b>=0;b--){let p=e.ledger[b];if(p.kind==="banner"&&p.text.startsWith("designing: ")){c=p.text.slice(11);break}}let h=c?z[c]:void 0;h&&r.push(`phase ${h}/4`),o>0&&r.push(`${o} item${o===1?"":"s"} this session`)}else o>0&&r.push(`${o} saved as draft${o===1?"":"s"}`);let d=e.pending?e.pending.resolution.filter(c=>!c).length:0;return d>0&&r.push(`${d} question${d===1?"":"s"} pending`),e.credits&&r.push(`${e.credits.total.toFixed(1)} credits`),{items:r}}function ke(e,t){let r=[],o=e.applied+e.committed+e.retired;r.push(`${o} applied`),r.push(`${t} to decide`);let d=[];return e.skipped>0&&d.push(`${e.skipped} skipped`),e.deferred>0&&d.push(`${e.deferred} deferred`),e.failed>0&&d.push(`${e.failed} failed`),{items:[...r,...d]}}function Ae(e,t){let r=["\u2191\u2193 select","\u23CE confirm"];return e.multi_select&&r.push("space toggle"),t.batchCount>1&&r.push("\u2190 \u2192 questions"),(e.allow_free_text||e.options.some(o=>o.input===!0))&&r.push("\u270E type your own"),t.canAttach&&r.push("@ attach a file or URL"),t.escBack&&r.push("esc back"),{keys:r}}function Se(e,t){let r=["\u2191\u2193 select","\u23CE confirm"];return e.some(o=>o.free)&&r.push("\u270E type your own"),t.escBack&&r.push("esc back"),{keys:r}}function Re(e){let t=["\u2191\u2193 select","\u23CE confirm","1-9 verdict"];return W(e)!==null&&t.push("type = adjust"),t.push("esc \xB7 nothing to undo"),{keys:t}}export{ee as a,te as b,le as c,ce as d,ue as e,X as f,V as g,W as h,be as i,we as j,ke as k,Ae as l,Se as m,Re as n};
|
|
2
|
+
import{a as j}from"./chunk-O5U6EAL3.js";import{d as K}from"./chunk-RKXHVP2Z.js";import{a as L}from"./chunk-5Y2G4NC7.js";import{a as M}from"./chunk-YCCUBQY4.js";import{x as s}from"./chunk-NJJQL54J.js";import{a as O}from"./chunk-HCBYKLMW.js";import{a as x,b as n,i as D,k as E}from"./chunk-C44QQJR4.js";import{a as I}from"./chunk-6YGTRKDT.js";import{e as y}from"./chunk-UR6MHSHU.js";var g=y(O(),1);function ee(e){let t=e.findIndex(r=>r.free);return t>=0?t:null}var q=60,Q=100;function te({headline:e,ask:t=!1,rows:r,sel:o,focused:d,freeText:c=null,freeTextNote:h,sublines:b=[]}){let{stdout:p}=E(),i=p?.columns??80,v=i<q,k=Math.min(i-1,Q),u=a=>d&&o===a?(0,g.jsx)(n,{color:s.assuranceAccent,children:"\u276F"}):" ",m=t?`? ${e}`:e,A=Math.max(4,k-3),S=b.map((a,w)=>(0,g.jsx)(n,{color:s.dim,children:` ${a.length>A?`${a.slice(0,A-1)}\u2026`:a}`},`sub-${w}`)),R=0,B=r.map((a,w)=>a.free?c?(0,g.jsxs)(x,{flexDirection:"column",children:[(0,g.jsxs)(x,{children:[(0,g.jsxs)(n,{children:[(0,g.jsx)(n,{color:s.assuranceAccent,children:"\u276F"})," ",(0,g.jsx)(n,{color:s.dim,children:"\u270E "})]}),(0,g.jsx)(M,{value:c.value,onChange:c.onChange,onSubmit:c.onSubmit,onCancel:c.onCancel,placeholder:a.label})]}),h?(0,g.jsx)(n,{color:s.muted,children:` ${h}`}):null]},a.key):(0,g.jsxs)(n,{children:[u(w)," ",(0,g.jsx)(n,{color:s.dim,children:`\u270E ${a.label}`})]},a.key):(R+=1,(0,g.jsxs)(n,{bold:d&&o===w,children:[u(w),` ${R}. ${a.label}`,a.detail?(0,g.jsx)(n,{color:s.dim,bold:!1,children:` \u2014 ${a.detail}`}):null]},a.key)));return v?(0,g.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,g.jsx)(n,{bold:!0,color:s.assuranceAccent,children:m}),S,B]}):(0,g.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,g.jsx)(n,{bold:!0,color:s.assuranceAccent,children:m}),S,(0,g.jsx)(n,{children:" "}),B]})}var H=y(I(),1);var $=y(O(),1),N=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function le(e){let t=e.replace(/…$/,"");return t&&t.charAt(0).toLowerCase()+t.slice(1)}function F(e,t){if(e.length<=t)return e;if(t<=1)return"\u2026";let r=Math.ceil((t-1)/2),o=Math.floor((t-1)/2);return`${e.slice(0,r)}\u2026${o>0?e.slice(-o):""}`}function ce({status:e,meta:t,tallies:r,keys:o,child:d,cols:c}){let{stdout:h}=E(),b=c??h?.columns??80,p=e.kind==="working"||e.kind==="child-working",[i,v]=(0,H.useState)(0);L(()=>v(f=>f+1),p?120:null);let k=N[i%N.length],u,m;switch(e.kind){case"working":u=`${k} ${e.step}${e.elapsedS!==void 0?` \xB7 ${e.elapsedS}s`:""}`,m=s.assuranceAccent;break;case"waiting":u=`\u25CF waiting on you${e.pending?` \u2014 ${e.pending} question${e.pending===1?"":"s"}`:""}`,m=s.amber;break;case"idle":u="\u25CF idle",m=s.assuranceAccent;break;case"card":u=`\u25CF card ${e.n} of ${e.m}`,m=s.amber;break;case"child-working":u=`${k} child: ${e.step}`,m=s.assuranceAccent;break;case"child-waiting":u="\u25CF child waiting on you",m=s.amber;break}let A=d?`${t.verb} \u25B8 ${d.verb}`:t.verb,S=d?.sid?t.sid?`${F(t.sid,14)} \u25B8 ${d.sid}`:d.sid:t.sid,R=t.env==="prod"?"":t.env,B=[A,S,R].filter(Boolean),a=" \xB7 ",w=u.length+a.length+B.join(a).length,C=t.subject;if(C){let f=b-w-a.length;C=f>=8?F(C,f):void 0}let _=[A,...C?[C]:[],S,R].filter(Boolean).join(a);return(0,$.jsxs)(x,{flexDirection:"column",children:[(0,$.jsx)(n,{color:s.muted,children:"\u2500".repeat(Math.max(1,b))}),(0,$.jsxs)(n,{children:[(0,$.jsx)(n,{color:m,children:u}),(0,$.jsx)(n,{color:s.dim,children:`${a}${_}`})]}),(0,$.jsx)(n,{color:s.dim,children:r.items.length>0?r.items.join(a):" "}),(0,$.jsx)(n,{color:s.muted,children:o.join(a)})]})}var P=y(I(),1);function ue({onToggleThinking:e,onCtrlC:t,explorer:r,panel:o}){let c=(0,P.useRef)(null),h=(0,P.useRef)(""),b=()=>{c.current&&clearTimeout(c.current),c.current=null,h.current=""};return(0,P.useEffect)(()=>b,[]),D((p,i)=>{if(i.ctrl&&p==="t"){e();return}if(i.ctrl&&p==="c"){t();return}if(!i.ctrl&&p.includes("")){t();return}if(!i.ctrl&&p.includes("")){e();return}if(r&&r.isOpen()){let v=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{b(),r.onBack()},150)};if(c.current){if(i.upArrow||i.downArrow||i.return){b(),i.return?r.onEnter():r.onMove(i.upArrow?-1:1);return}if(h.current+=p,h.current==="["){v();return}let k=h.current;b();let u=/^\[([ABCD])/.exec(k);if(u){(u[1]==="A"||u[1]==="B")&&r.onMove(u[1]==="A"?-1:1);return}r.onBack();return}if(i.upArrow){r.onMove(-1);return}if(i.downArrow){r.onMove(1);return}if(i.return){r.onEnter();return}if(i.escape){h.current="",v();return}return}if(o&&o.isFocused()){let v=()=>{c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{b(),o.onBack()},150)};if(c.current){if(i.upArrow||i.downArrow||i.return||i.leftArrow||i.rightArrow){b(),i.return?o.onSelect():i.leftArrow?o.onLeft?.():i.rightArrow?o.onRight?.():o.onMove(i.upArrow?-1:1);return}if(h.current+=p,h.current==="["){v();return}let k=h.current;b();let u=/^\[([ABCD])/.exec(k);if(u){u[1]==="A"||u[1]==="B"?o.onMove(u[1]==="A"?-1:1):u[1]==="C"?o.onRight?.():o.onLeft?.();return}o.onBack();return}if(i.upArrow){o.onMove(-1);return}if(i.downArrow){o.onMove(1);return}if(i.leftArrow){o.onLeft?.();return}if(i.rightArrow){o.onRight?.();return}if(i.return){o.onSelect();return}if(i.escape){h.current="",v();return}if(/^[1-9]$/.test(p)){o.onDigit(Number(p));return}if(i.tab){o.onTab?.();return}if(p===" "&&o.isMulti()){o.onSpace();return}if(p&&!i.ctrl&&!i.meta){o.onType(p);return}return}}),null}var l=y(O(),1);function X(e){return e.kind==="REVIEW"?[{v:"approve",label:"approve",detail:"mark it reviewed and trusted"},{v:"archive",label:"archive",detail:"reject it \u2014 asks for a reason; impact shown above"},{v:"defer",label:"defer",detail:"not now \u2014 stays queued"}]:e.kind==="PAIR"?[{v:"merge",label:"merge",detail:"duplicate \u2014 fold into the older item (it stays unreviewed)"},{v:"keep_both",label:"keep both",detail:"genuinely distinct \u2014 promote both"},{v:"defer",label:"defer",detail:"not now \u2014 stays queued"}]:e.kind==="ARCHIVE"?[{v:"archive",label:"retire",detail:"hidden from now on; history is kept and it can be reverted"},{v:"skip",label:"skip",detail:"keep it \u2014 decided, never re-offered"},{v:"defer",label:"defer",detail:"not now \u2014 the plan re-offers it"}]:e.heldPayload?[{v:"approve",label:"approve update",detail:"commit the held payload \u2014 impact preview above"},{v:"skip",label:"keep current",detail:"drop the held payload (the owner's disk state stays untouched)"},{v:"defer",label:"defer",detail:"not now \u2014 stays held"}]:[{v:"approve",label:"approve",detail:e.kind==="ADD"?"commit + design it":"commit the updated version (old\u2192new redirect)"},{v:"skip",label:e.origin==="content-change"?"reject":"skip",detail:e.origin==="content-change"?"drop the staged proposal \u2014 nothing committed":"leave it as is"},{v:"defer",label:"defer",detail:"not now \u2014 the plan keeps it staged"}]}function V(e){let t=X(e);return e.viewDiff&&t.push({v:"view_diff",label:"view diff",detail:"full old \u2192 new"}),t}function W(e){return e.kind==="ARCHIVE"?null:V(e).length}var Y={ADD:{color:s.green??"green"},MODIFY:{color:"yellow"},ARCHIVE:{color:s.red},REVIEW:{color:"cyan"},PAIR:{color:"magenta"}},U=60;function be({card:e,position:t,sel:r=0,focused:o=!1,freeText:d=null,editorIntent:c="steer"}){let{stdout:h}=E(),b=h?.columns??80,p=b<U,i=V(e),v=W(e),k=Y[e.kind],u=f=>o&&r===f?(0,l.jsx)(n,{color:s.assuranceAccent,children:"\u276F"}):" ",m=e.impact,A=m&&"stale_refs"in m&&m.stale_refs.length>0?`${e.kind==="ARCHIVE"?"retiring leaves":"approving marks"} ${m.stale_refs.length} item(s) stale`+((m.direct_refs?.length??0)>0?` \u2014 ${m.direct_refs.length} directly touched: ${m.direct_refs.join(", ")}`:""):m&&"design_children"in m?`${e.kind==="REVIEW"?"archiving drops":"merging folds"} ${m.design_children} design child(ren)`:null,S=e.provenance&&e.provenance!==e.why?e.provenance:e.origin??null,R=[{label:"why",text:e.why},...S?[{label:"from",text:S,dimmer:!0}]:[],...e.tier?[{label:"match",text:e.tier,dimmer:!0}]:[],...A?[{label:"impact",text:A}]:[]],B=Math.max(...R.map(f=>f.label.length)),a="? reconcile",w=`item ${t.n} of ${t.of}`,C=(0,l.jsxs)(x,{flexDirection:"column",children:[(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsxs)(n,{bold:!0,children:[(0,l.jsx)(n,{color:k.color,children:`[${e.kind}]`}),` ${j(e.title)}`]})}),R.map((f,T)=>(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{color:s.dim,children:`${f.label.padEnd(B)} `}),(0,l.jsx)(n,{color:f.dimmer?s.dim:void 0,children:f.text})]})},`f-${T}`)),e.diffSummary?(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsx)(n,{color:s.dim,children:e.diffSummary})}):(e.diff??[]).map((f,T)=>(0,l.jsx)(x,{paddingLeft:4,children:(0,l.jsx)(n,{color:f.op==="-"?"red":"green",children:`${f.op==="-"?"\u2212":"+"} ${f.field==="criteria"?"criterion":f.field}: ${f.text}`})},`d-${T}`)),(e.citeLines??[]).map((f,T)=>(0,l.jsx)(x,{paddingLeft:2,children:(0,l.jsx)(n,{color:s.dim,children:f})},`c-${T}`)),(0,l.jsx)(n,{children:" "}),i.map((f,T)=>(0,l.jsxs)(n,{children:[u(T),` ${T+1}. ${f.label}`,(0,l.jsx)(n,{color:s.dim,children:` \u2014 ${f.detail}`})]},`o-${T}`)),v!==null||d&&c==="because"?d?(0,l.jsxs)(x,{flexDirection:"column",children:[(0,l.jsxs)(x,{children:[(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{color:s.assuranceAccent,children:"\u276F"})," ",(0,l.jsx)(n,{color:s.dim,children:"\u270E "})]}),(0,l.jsx)(M,{value:d.value,onChange:d.onChange,onSubmit:d.onSubmit,onCancel:d.onCancel,placeholder:c==="because"?"why archive it?":"say what to adjust"})]}),(0,l.jsx)(n,{color:s.muted,children:c==="because"?" submits as: archive \xB7 your reason goes on the record":e.kind==="PAIR"?" submits as: defer \xB7 your note parks with the card (it re-offers)":" submits as: approve \xB7 your words steer the re-design"})]}):v!==null?(0,l.jsxs)(n,{children:[u(v)," ",(0,l.jsx)(n,{color:s.dim,children:e.kind==="PAIR"?"\u270E defer with a note \u2014 say what you noticed":"\u270E approve with changes \u2014 say what to adjust"})]}):null:null]});if(p)return(0,l.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,l.jsx)(n,{bold:!0,color:s.assuranceAccent,children:a}),(0,l.jsx)(n,{color:s.dim,children:w}),C]});let _=Math.max(2,Math.min(b-1,100)-a.length-w.length);return(0,l.jsxs)(x,{marginTop:1,marginBottom:1,flexDirection:"column",children:[(0,l.jsxs)(n,{children:[(0,l.jsx)(n,{bold:!0,color:s.assuranceAccent,children:a})," ".repeat(_),(0,l.jsx)(n,{color:s.dim,children:w})]}),(0,l.jsx)(n,{children:" "}),C]})}var z={"acceptance criteria":1,scenarios:2,"acceptance criteria + exercises":3,"tests + gaps":4};function we(e,t){let r=[],o=K(e.turns).entries.length;if(t==="design"){let c;for(let b=e.ledger.length-1;b>=0;b--){let p=e.ledger[b];if(p.kind==="banner"&&p.text.startsWith("designing: ")){c=p.text.slice(11);break}}let h=c?z[c]:void 0;h&&r.push(`phase ${h}/4`),o>0&&r.push(`${o} item${o===1?"":"s"} this session`)}else o>0&&r.push(`${o} saved as draft${o===1?"":"s"}`);let d=e.pending?e.pending.resolution.filter(c=>!c).length:0;return d>0&&r.push(`${d} question${d===1?"":"s"} pending`),e.credits&&r.push(`${e.credits.total.toFixed(1)} credits`),{items:r}}function ke(e,t){let r=[],o=e.applied+e.committed+e.retired;r.push(`${o} applied`),r.push(`${t} to decide`);let d=[];return e.skipped>0&&d.push(`${e.skipped} skipped`),e.deferred>0&&d.push(`${e.deferred} deferred`),e.failed>0&&d.push(`${e.failed} failed`),{items:[...r,...d]}}function Ae(e,t){let r=["\u2191\u2193 select","\u23CE confirm"];return e.multi_select&&r.push("space toggle"),t.batchCount>1&&r.push("\u2190 \u2192 questions"),(e.allow_free_text||e.options.some(o=>o.input===!0))&&r.push("\u270E type your own"),t.canAttach&&r.push("@ attach a file or URL"),t.escBack&&r.push("esc back"),{keys:r}}function Se(e,t){let r=["\u2191\u2193 select","\u23CE confirm"];return e.some(o=>o.free)&&r.push("\u270E type your own"),t.escBack&&r.push("esc back"),{keys:r}}function Re(e){let t=["\u2191\u2193 select","\u23CE confirm","1-9 verdict"];return W(e)!==null&&t.push("type = adjust"),t.push("esc \xB7 nothing to undo"),{keys:t}}export{ee as a,te as b,le as c,ce as d,ue as e,X as f,V as g,W as h,be as i,we as j,ke as k,Ae as l,Se as m,Re as n};
|