@testmuai/kane-cli 0.8.1 → 0.8.2
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-B3ULYDYC.js +8 -0
- package/dist/{ChromeProfilePicker-AUU7JF6F.js → ChromeProfilePicker-T77E7ZSC.js} +1 -1
- package/dist/{CliFeedbackPrompt-4W74Y3UF.js → CliFeedbackPrompt-FQ2XV5DZ.js} +1 -1
- package/dist/{CliUploadProgress-6HL7WTEX.js → CliUploadProgress-TZ55LONO.js} +1 -1
- package/dist/{ConfigView-6BSCZP5Y.js → ConfigView-WWQMH36G.js} +1 -1
- package/dist/EvidenceViewOffer-L5FVBQNK.js +2 -0
- package/dist/FolderPicker-6Z3CYSHF.js +2 -0
- package/dist/{HelpView-TU7ED43J.js → HelpView-XXPCPJNF.js} +1 -1
- package/dist/{InfoBox-JLTMKVDE.js → InfoBox-SHBRHQX5.js} +1 -1
- package/dist/{LinksBox-LREUUJDV.js → LinksBox-ENNF7TDJ.js} +1 -1
- package/dist/{ProfilesView-W3GX2N2E.js → ProfilesView-CNF2FXF3.js} +1 -1
- package/dist/{ProjectPicker-SYQUJK2J.js → ProjectPicker-PVPLS642.js} +1 -1
- package/dist/{SaveSessionPrompt-MR5NJMRP.js → SaveSessionPrompt-4QP4GNGO.js} +1 -1
- package/dist/SingleShotApp-M3HNSUMZ.js +2 -0
- package/dist/{SummaryBox-UAYSVFB7.js → SummaryBox-HYNINDNN.js} +1 -1
- package/dist/TestMdRunView-ISOVQ7YP.js +2 -0
- package/dist/{WhoamiView-2YU76ASQ.js → WhoamiView-NN2HOK6H.js} +1 -1
- package/dist/app-client-ZCCNE3RV.js +2 -0
- package/dist/{app-download-AEEFQ63M.js → app-download-5UJMXPF3.js} +1 -1
- package/dist/{auth-HET3TBRI.js → auth-QKBTOWQX.js} +1 -1
- package/dist/{bind-STKXOUYI.js → bind-LVGP5KHO.js} +2 -2
- package/dist/bootstrap-RUJBMB2P.js +2 -0
- package/dist/bridge-QDPBIIOW.js +2 -0
- package/dist/{changelog-7OWRHFHZ.js → changelog-HBPBPR2O.js} +1 -1
- package/dist/{chat-controller-T2FAI55V.js → chat-controller-R4THYYPU.js} +1 -1
- package/dist/chunk-2E3ZWGIK.js +12 -0
- package/dist/{chunk-ZVHCQMJ6.js → chunk-2KH2JUGL.js} +2 -2
- package/dist/{chunk-ZIUAOEUC.js → chunk-2TYCUPCN.js} +1 -1
- package/dist/{chunk-FEJXWJ3L.js → chunk-2ZZDNPFN.js} +1 -1
- package/dist/{chunk-KFSUPQAG.js → chunk-3654GK6O.js} +43 -43
- package/dist/{chunk-RFR4ZKIC.js → chunk-3NHO5R4P.js} +2 -2
- package/dist/{chunk-3LJWYRAA.js → chunk-4II6VDXG.js} +1 -1
- package/dist/chunk-4J6DQFPC.js +4 -0
- package/dist/{chunk-SDPRO2LE.js → chunk-4U4OSOA4.js} +1 -1
- package/dist/chunk-5NIYYD7O.js +2 -0
- package/dist/{chunk-L7MXYCD7.js → chunk-5SNT2MK5.js} +1 -1
- package/dist/chunk-6J5T5FEY.js +2 -0
- package/dist/chunk-6N726QLP.js +349 -0
- package/dist/chunk-7F2ZV46B.js +2 -0
- package/dist/{chunk-BRHNRCEZ.js → chunk-7S3JZ6FQ.js} +1 -1
- package/dist/chunk-A2SQD2AY.js +4 -0
- package/dist/{chunk-AW2XUHH4.js → chunk-AJQT4IWZ.js} +1 -1
- package/dist/{chunk-6XX4LEVJ.js → chunk-AN2ZPHCE.js} +1 -1
- package/dist/{chunk-3POR47RC.js → chunk-ATGRRKEV.js} +2 -2
- package/dist/chunk-AXTPNZPX.js +2 -0
- package/dist/{chunk-RC52N7PC.js → chunk-BKVDAZEJ.js} +1 -1
- package/dist/{chunk-2WVKOZ6W.js → chunk-BPMSNGXQ.js} +1 -1
- package/dist/{chunk-UV462FZR.js → chunk-BSYX225I.js} +1 -1
- package/dist/{chunk-DZGCXKKI.js → chunk-CAMO26QU.js} +1 -1
- package/dist/chunk-ECZMYPLJ.js +19 -0
- package/dist/{chunk-65ZTD5SJ.js → chunk-FNS2EAA5.js} +2 -2
- package/dist/{chunk-7BZSCUPP.js → chunk-GNIFMQNK.js} +3 -3
- package/dist/chunk-GUVM6SZF.js +2 -0
- package/dist/{chunk-2BGUUWNF.js → chunk-HFFPPCZO.js} +2 -2
- package/dist/{chunk-T5Y6MOLM.js → chunk-HRZOFTV7.js} +1 -1
- package/dist/chunk-HWH3UYD6.js +4 -0
- package/dist/{chunk-EDSZJZFG.js → chunk-I7RQS65W.js} +1 -1
- package/dist/chunk-IUEEFGEW.js +11 -0
- package/dist/{chunk-DO5HAO3H.js → chunk-IV76ZXCY.js} +1 -1
- package/dist/{chunk-UXDL4XDL.js → chunk-IZ2FJYHG.js} +1 -1
- package/dist/{chunk-766WGMBU.js → chunk-J7KT44IC.js} +1 -1
- package/dist/{chunk-QW6EZC53.js → chunk-JEDLXUO5.js} +1 -1
- package/dist/chunk-JGOZUAMC.js +2 -0
- package/dist/{chunk-XO5ZH3ZR.js → chunk-JHKM7W5X.js} +1 -1
- package/dist/{chunk-IOFZSQAA.js → chunk-JJN76EXE.js} +1 -1
- package/dist/{chunk-YFYCCTSL.js → chunk-JUVQQP42.js} +1 -1
- package/dist/chunk-KKRNTSLL.js +6 -0
- package/dist/{chunk-IP2O264K.js → chunk-LDCLZR2U.js} +1 -1
- package/dist/chunk-LQQXPY5B.js +4 -0
- package/dist/{chunk-FMRSMN34.js → chunk-LVCY5IYI.js} +1 -1
- package/dist/{chunk-G7VQCS4J.js → chunk-LVN6VHFN.js} +1 -1
- package/dist/chunk-MMBBQ4OZ.js +2 -0
- package/dist/{chunk-QSDH5P7C.js → chunk-MTIC65NK.js} +1 -1
- package/dist/chunk-NHBYZCSX.js +4 -0
- package/dist/{chunk-GZPK6FRP.js → chunk-NRUD56FY.js} +1 -1
- package/dist/{chunk-GKYPNSQP.js → chunk-NXFAEDHV.js} +2 -2
- package/dist/{chunk-ELM6MXGJ.js → chunk-NXXJ56QA.js} +1 -1
- package/dist/{chunk-JJHG3BWO.js → chunk-O3AHFP3K.js} +1 -1
- package/dist/{chunk-FQLIW3LM.js → chunk-OAVPM6YJ.js} +1 -1
- package/dist/{chunk-QRZRSAZH.js → chunk-OJTCIZDK.js} +1 -1
- package/dist/{chunk-YJELGSKJ.js → chunk-OOEPLMKA.js} +1 -1
- package/dist/{chunk-6O3DDOP2.js → chunk-PXCMEI73.js} +1 -1
- package/dist/{chunk-C7HSWZP6.js → chunk-R4UCBA5R.js} +1 -1
- package/dist/chunk-RKXHVP2Z.js +2 -0
- package/dist/{chunk-KU6IXFGZ.js → chunk-RN4PKQFR.js} +1 -1
- package/dist/chunk-RUCSRS4C.js +5 -0
- package/dist/chunk-TAOHYWEO.js +2 -0
- package/dist/{chunk-TFPPEOAK.js → chunk-U5GHOGLM.js} +1 -1
- package/dist/chunk-UJZZDPDY.js +2 -0
- package/dist/{chunk-EWCAFKLX.js → chunk-UODLRQQ4.js} +1 -1
- package/dist/chunk-VK3NU742.js +21 -0
- package/dist/{chunk-DCY6R5DP.js → chunk-VPRNGWIY.js} +1 -1
- package/dist/{chunk-NX7TM662.js → chunk-WOEQDUJ6.js} +1 -1
- package/dist/{chunk-OMQCD3KR.js → chunk-WQPQNL4S.js} +1 -1
- package/dist/{chunk-HMYMSRA4.js → chunk-WV27D55O.js} +1 -1
- package/dist/{chunk-GCBKDX2J.js → chunk-WVCH66YH.js} +1 -1
- package/dist/{chunk-7JWKHKFU.js → chunk-YCLG3T5E.js} +1 -1
- package/dist/chunk-YGMC3FGJ.js +26 -0
- package/dist/{chunk-TKGUT425.js → chunk-YHYTCENI.js} +1 -1
- package/dist/{chunk-UDIQOJEL.js → chunk-YSSYT5F5.js} +1 -1
- package/dist/{chunk-OTTGS2TE.js → chunk-YTDSQAYN.js} +1 -1
- package/dist/{chunk-HCKH44I2.js → chunk-ZEDAPY7M.js} +1 -1
- package/dist/chunk-ZI6UIJUN.js +11 -0
- package/dist/{config-RS47F5SC.js → config-RLDXM5ZH.js} +1 -1
- package/dist/{credentials-OH6AVI6N.js → credentials-CALNKQMN.js} +1 -1
- package/dist/deps-bundle-GVHIMZ5E.js +2 -0
- package/dist/{deps-resolve-XC5S53DG.js → deps-resolve-T6P4EACP.js} +1 -1
- package/dist/{dispatch-SE5GY3Z2.js → dispatch-ECUEAMXS.js} +1 -1
- package/dist/doctor-SIBHJVGC.js +2 -0
- package/dist/evidence-ZVQHPELX.js +2 -0
- package/dist/evolve-cmd-JGCFTXWA.js +2 -0
- package/dist/extract-bind-EXW32RUY.js +10 -0
- package/dist/{extract-cmd-UZMEZMGP.js → extract-cmd-7IOLJJCL.js} +1 -1
- package/dist/gaps-cmd-WPCJPLGB.js +3 -0
- package/dist/{generate-headless-D3SVQ2AI.js → generate-headless-U4GTG234.js} +2 -2
- package/dist/index.js +61 -60
- package/dist/{ingest-cmd-EAE7N5RC.js → ingest-cmd-YYNAKI2U.js} +1 -1
- package/dist/interactive-bind-Y65XV4Y5.js +25 -0
- package/dist/{list-commands-MRXL5HGS.js → list-commands-3EROWJWV.js} +1 -1
- package/dist/login-flow-TRINUSBB.js +2 -0
- package/dist/mobile-prompts-TP3ODM5M.js +2 -0
- package/dist/{persist-recorded-session-TLDQ5HKP.js → persist-recorded-session-EHYT3PVN.js} +1 -1
- package/dist/{phase-seed-VFHIH6FL.js → phase-seed-DIRETNU6.js} +1 -1
- package/dist/{pipeline-UOM4LNAI.js → pipeline-5GOS2KV2.js} +1 -1
- package/dist/prepare-target-BUEOZVJV.js +2 -0
- package/dist/reconcile-cmd-TY3MWZL3.js +2 -0
- package/dist/reconcile-deps-6KTJHBMJ.js +4 -0
- package/dist/reconcile-engine-O7QEZVX6.js +2 -0
- package/dist/{recording-banner-4M7XHVGI.js → recording-banner-BWWFOJCR.js} +1 -1
- package/dist/registry-KXEDLM6X.js +2 -0
- package/dist/{require-project-folder-4UPQNEBJ.js → require-project-folder-CXDRRWEQ.js} +1 -1
- package/dist/resolve-run-intent-PZXEQTHC.js +7 -0
- package/dist/{resolver-UBOZLFFE.js → resolver-FTU5KO7H.js} +1 -1
- package/dist/{run-URPGHOQM.js → run-CMFBSYWF.js} +1 -1
- package/dist/run-WKHPVWUN.js +2 -0
- package/dist/{run-test-md-76ZPKXO6.js → run-test-md-7HGOZJSU.js} +2 -2
- package/dist/session-items-2ATN7VXG.js +2 -0
- package/dist/{skill-installer-CIS6GAYF.js → skill-installer-QNUDLGPD.js} +1 -1
- package/dist/{spawner-J67QR4QP.js → spawner-DQZRJIE6.js} +1 -1
- package/dist/tcg-generate-XKSTMCOG.js +2 -0
- package/dist/{testmd-actions-77ELR5UU.js → testmd-actions-IFRW7NGG.js} +1 -1
- package/dist/{tms-client-VD3B3SMU.js → tms-client-V3TR4QW3.js} +1 -1
- package/dist/token-refresh-FP6JFLXB.js +2 -0
- package/dist/{validate-basic-2GVSQ2R5.js → validate-basic-3CNUDDH7.js} +1 -1
- package/dist/{verdicts-TRSTJLCL.js → verdicts-NYCSBWUC.js} +1 -1
- package/dist/{version-check-O6PYTI4T.js → version-check-7TSAVA6V.js} +1 -1
- package/dist/walk-session-AINBHZKB.js +2 -0
- package/dist/with-telemetry-3DL7ZEZL.js +2 -0
- package/package.json +11 -11
- package/dist/ChatSurface-U37VZDCW.js +0 -8
- package/dist/EvidenceViewOffer-62XHEEGW.js +0 -2
- package/dist/FolderPicker-S7U2EN2M.js +0 -2
- package/dist/SingleShotApp-XOKVOM7C.js +0 -2
- package/dist/TestMdRunView-7UVSDAF4.js +0 -2
- package/dist/app-client-OEXESV4U.js +0 -2
- package/dist/bootstrap-44YKVWWE.js +0 -2
- package/dist/bridge-5Z3BIB77.js +0 -2
- package/dist/chunk-27U4PLPX.js +0 -2
- package/dist/chunk-2KDGIZED.js +0 -4
- package/dist/chunk-3PECJD6S.js +0 -11
- package/dist/chunk-7Q6M6P4X.js +0 -26
- package/dist/chunk-CTW2VQKS.js +0 -6
- package/dist/chunk-FNH55WSR.js +0 -19
- package/dist/chunk-GPG3FIN3.js +0 -21
- package/dist/chunk-HEAIJCGZ.js +0 -2
- package/dist/chunk-KCCSWEGA.js +0 -4
- package/dist/chunk-MA34UWKX.js +0 -4
- package/dist/chunk-MBF3FP5P.js +0 -5
- package/dist/chunk-MXHHMIO2.js +0 -349
- package/dist/chunk-QGKPLOUI.js +0 -2
- package/dist/chunk-RLRNLIRS.js +0 -2
- package/dist/chunk-TYLYFERW.js +0 -10
- package/dist/chunk-V2R3LCA3.js +0 -12
- package/dist/chunk-VGFTNLQQ.js +0 -2
- package/dist/chunk-W2JFDDIB.js +0 -2
- package/dist/chunk-YRFMPIU2.js +0 -4
- package/dist/doctor-FSECFZUU.js +0 -2
- package/dist/evidence-OYPHZUKI.js +0 -2
- package/dist/evolve-cmd-BCPNXAMV.js +0 -2
- package/dist/extract-bind-LLEASZAK.js +0 -10
- package/dist/gaps-cmd-IVXFPFAQ.js +0 -3
- package/dist/interactive-bind-ORMN2REX.js +0 -25
- package/dist/login-flow-QJQM3RHT.js +0 -2
- package/dist/mobile-prompts-TOX35ER6.js +0 -2
- package/dist/prepare-target-QYWIJIVQ.js +0 -2
- package/dist/reconcile-cmd-3H34KVVD.js +0 -2
- package/dist/reconcile-deps-XIH75ZLY.js +0 -4
- package/dist/reconcile-engine-UKWPG2LV.js +0 -2
- package/dist/registry-PYOTKZYZ.js +0 -2
- package/dist/resolve-run-intent-X72V3KJA.js +0 -7
- package/dist/run-2COODVX2.js +0 -2
- package/dist/tcg-generate-BDTRKY2A.js +0 -2
- package/dist/token-refresh-4BPAPXKK.js +0 -2
- package/dist/walk-session-CHJXHZMO.js +0 -2
- package/dist/with-telemetry-CQCWLVOC.js +0 -2
- /package/dist/{lifecycle-cmd-O2324GN6.js → lifecycle-cmd-HO5VL7AM.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as f,c as u}from"./chunk-EYOCNMUM.js";import{d as g,k as p}from"./chunk-
|
|
2
|
+
import{a as f,c as u}from"./chunk-EYOCNMUM.js";import{d as g,k as p}from"./chunk-7F2ZV46B.js";import{readFileSync as _,writeFileSync as m,mkdirSync as b,existsSync as h}from"fs";import{dirname as v}from"path";var s={window_size:{width:1920,height:1080},chrome_profile_path:"",default_url:p,model:"v16-alpha",project_id:null,project_name:null,folder_id:null,folder_name:null,mode:"testing",assertion_mode:"dom",network_ws:!1,network_sse:!1,bug_detection:"off",final_validation:!1,code_export:{enabled:!0,language:"python",skip_validation:!0},generate:{scenario_limit:2,per_scenario_limit:3,memory_enabled:!1},last_seen_version:"",hints_enabled:!0};function w(o){let{mobile:e,...i}=o,t={...i};delete t.target,delete t.device,delete t.app;let n=e??{};n.tui_target&&(t.target=n.tui_target);let r=n.default_target?.id?.trim();r&&(t.device=r),n.default_app&&(t.app=n.default_app);let a={};return n.no_reset!==void 0&&(a.no_reset=n.no_reset),n.appium_url!==void 0&&(a.appium_url=n.appium_url),Object.keys(a).length>0&&(t.mobile=a),t}function C(o){let e=o.mobile??{},i=typeof o.target=="string"?o.target:void 0,t=typeof o.device=="string"&&o.device.trim()!==""?o.device.trim():void 0,n=typeof o.app=="string"&&o.app!==""?o.app:void 0,r={},a=i??e.tui_target;if(a&&(r.tui_target=a),t){let d=f(a,void 0);(d.kind==="emulator"||d.kind==="simulator")&&(r.default_target={platform:u(d.kind),kind:d.kind,id:t})}else e.default_target?.id?.trim()&&(r.default_target=e.default_target);let l=n??e.default_app;return l&&(r.default_app=l),e.no_reset!==void 0&&(r.no_reset=e.no_reset),e.appium_url!==void 0&&(r.appium_url=e.appium_url),Object.keys(r).length>0?r:void 0}var c=class{constructor(e=g){this.path=e}exists(){return h(this.path)}load(){try{let e=_(this.path,"utf-8"),i=JSON.parse(e),t=C(i),{target:n,device:r,app:a,...l}=i;return{...s,...l,...t?{mobile:t}:{},code_export:{...s.code_export,...i.code_export??{}},generate:{...s.generate,...i.generate??{}}}}catch{return{...s,code_export:{...s.code_export},generate:{...s.generate}}}}write(e){try{b(v(this.path),{recursive:!0}),m(this.path,JSON.stringify(w(e),null,2)+`
|
|
3
3
|
`)}catch(i){let t=i instanceof Error?i.message:String(i);process.stderr.write(`[config] Failed to save config: ${t}
|
|
4
4
|
`)}}set(e,i){let t=this.load();t[e]=i,this.write(t)}save(e){this.write({...this.load(),...e})}getMobile(){return this.load().mobile??{}}setMobile(e){let i={...this.getMobile()};for(let t of Object.keys(e)){let n=e[t];n===void 0?delete i[t]:i[t]=n}this.set("mobile",Object.keys(i).length>0?i:void 0)}writeRaw(e){this.write(e)}};export{c as a};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{b as f,d as l}from"./chunk-ECZMYPLJ.js";import{a as p}from"./chunk-TZXXJWHA.js";function d(t,e,o){return{id:`${t}.internal`,label:e,required:!0,status:"fail",detail:o instanceof Error?o.message:String(o)}}async function k(t,e={}){let o=p();if(!o.supported)return{sections:[{platform:"host",checks:[{id:"host.platform",label:"host",required:!0,status:"fail",detail:o.reason}]}]};let n=t?f().filter(r=>r.toLowerCase()===t.toLowerCase()):f(),{managedDeps:i}=await import("./deps-bundle-GVHIMZ5E.js"),s=n.flatMap(r=>r==="android"?["emulator"]:r==="ios"?["simulator"]:[]);await Promise.allSettled(s.map(r=>i().warmResolveCache(r)));let c=[];for(let r of n){let u=l(r);if(!u)continue;let a;try{a=await u.checks(e)}catch(h){a=[d(r,"toolchain check",h)]}c.push({platform:r,checks:a})}return{sections:c}}function m(t){return t==="pass"?"\u2713":t==="fail"?"\u2717":"\u2139"}function x(t){return t.charAt(0).toUpperCase()+t.slice(1)}function C(t){let e=[];if(t.sections.length===0)return"No mobile platforms are supported on this host.";for(let o of t.sections){e.length>0&&e.push(""),e.push(`${x(o.platform)} toolchain`);let n=o.checks.filter(s=>s.status!=="info"),i=new Set;for(let s of n){let c=s.detail?` \u2014 ${s.detail}`:"";if(e.push(` ${m(s.status)} ${s.label}${c}`),s.status==="fail"&&s.fixText&&!i.has(s.fixText)){i.add(s.fixText);for(let r of s.fixText.split(`
|
|
3
|
+
`))e.push(` fix: ${r}`)}}}return e.join(`
|
|
4
|
+
`)}function w(t){return t.sections.length===0?!0:t.sections.every(e=>e.checks.some(o=>o.required&&o.status==="fail"&&!o.fixedByBundle))}function b(t){for(let e of t.sections)for(let o of e.checks)if(o.required&&o.status!=="pass")return 2;return 0}export{k as a,C as b,w as c,b as d};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as o,b as i}from"./chunk-
|
|
2
|
+
import{a as o,b as i}from"./chunk-LDCLZR2U.js";import{resolve as n}from"path";async function w(c,s,r={}){let e=i({verb:c,mode:"cli",contextRoot:n(process.cwd(),".context"),env:o(),write:r.write});try{let t=await s(e);return r.write&&t===0&&await e.lateBindContext(n(process.cwd(),".context")),t===1&&process.stderr.write(e.supportFooter()+`
|
|
3
3
|
`),await e.end({exit_code:t}),t}catch(t){throw e.error("cli_crash"),process.stderr.write(e.supportFooter()+`
|
|
4
4
|
`),await e.end({exit_code:1}),t}}export{w as a};
|
|
@@ -0,0 +1,11 @@
|
|
|
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-7F2ZV46B.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-T6P4EACP.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
|
+
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
|
+
`)}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
|
+
`)){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)}
|
|
7
|
+
`),await N(r,e)}catch{}}async resolveOrExplain(t){let s=`${this.deps.os}-${this.deps.arch}-${t}`,e;try{e=await this.deps.resolveBundle({cliVersion:this.deps.cliVersion,os:this.deps.os,arch:this.deps.arch,deviceClass:t})}catch(n){throw new B(s,this.deps.cliVersion,n)}if(!e?.url||!e.sha256||!e.bundleVersion)throw new B(s,this.deps.cliVersion);return await this.writeResolveCache(t,e.bundleVersion),e}async install(t,s,e){let n=this.paths(t,s.bundleVersion),r=l(this.depsRoot(),s.bundleVersion);await S(r,{recursive:!0});let o=await Z(l(r,".staging-"));try{e?.(`Downloading the ${t} dependencies ${s.bundleVersion} (${_(s.bytes)}) \u2014 this happens once\u2026`);let a=[],c=-1,h=0,b=await this.download(s,(d,u)=>{if(!u)return;let m=Math.min(d,u),w=this.deps.now().getTime();for(a.push({t:w,received:m});a.length>1&&a[0].t<w-3e3;)a.shift();let g=Math.min(100,Math.floor(m/u*20)*5);if(g===c&&w-h<2e3&&m<u)return;c=g,h=w;let $=a[0],p=(w-$.t)/1e3,D=p>0?(m-$.received)/p:0,E=D>0&&m<u?` \xB7 ${at(D)} \xB7 ${lt((u-m)/D)}`:"";e?.(`Downloading the ${t} dependencies \u2014 ${_(m)} / ${_(u)} (${g}%)${E}`)}),f=W(b),M=gt(f);for(let[d,u]of Object.entries(f)){if(d.endsWith("/"))continue;let m=M&&d.startsWith(M)?d.slice(M.length):d;if(!m)continue;let w=rt(o,m);if(!mt(o,w))throw new Error(`Unsafe path in ${s.url}: ${d}`);await S(C(w),{recursive:!0}),await x(w,u,this.deps.os!=="win32"?{mode:493}:{})}let P=await this.readBundleManifest(o,s.url,t);await this.postInstall(o,n,e),await v(n.root,{recursive:!0,force:!0}),await N(o,n.root);let V={schemaVersion:q,class:t,bundleVersion:s.bundleVersion,cliVersion:this.deps.cliVersion,os:this.deps.os,arch:this.deps.arch,sha256:s.sha256,bytes:s.bytes,sourceUrl:s.url,installedAt:this.deps.now().toISOString(),nodeAbi:P.node_abi?.node_module_version??this.deps.nodeModuleVersion,postInstall:{quarantineStripped:this.deps.os==="darwin",extensionsRewritten:!0}},T=l(r,`install-manifest-${process.pid}.json`);await x(T,`${JSON.stringify(V,null,2)}
|
|
8
|
+
`),await N(T,n.installManifest),await this.gcOldVersions(t);let R=l(this.mobileRoot(),"trees");await A(R)&&(await this.reapLegacyServers(R,e),await v(R,{recursive:!0,force:!0}),e?.("Removed the legacy per-component toolchain trees"));for(let d of["emulator","simulator"]){let u=l(this.depsRoot(),d);await A(l(u,"install-manifest.json"))||await A(u)&&(await v(u,{recursive:!0,force:!0}),e?.(`Removed the previous ${d} deps layout`))}}finally{await v(o,{recursive:!0,force:!0})}}async reapLegacyServers(t,s){if(this.deps.os==="win32")return;let e=await this.deps.exec("pgrep",["-f",t],{timeoutMs:1e4});if(e.code!==0)return;let n=e.stdout.split(`
|
|
9
|
+
`).map(r=>r.trim()).filter(r=>/^\d+$/.test(r));for(let r of n)await this.deps.exec("kill",[r],{timeoutMs:5e3});n.length>0&&s?.(`Stopped ${n.length} legacy managed server process${n.length===1?"":"es"} before removing the old toolchain trees`)}async gcOldVersions(t){let s=[];try{s=await O(this.depsRoot())}catch{return}let e=[];for(let n of s){let r=this.classRoot(t,n);try{let o=JSON.parse(await y(l(r,"install-manifest.json"),"utf8"));e.push({root:r,installedAt:o.installedAt})}catch{}}e.sort((n,r)=>n.installedAt<r.installedAt?1:-1);for(let n of e.slice(2)){await v(n.root,{recursive:!0,force:!0});let r=C(n.root);try{(await O(r)).length===0&&await v(r,{recursive:!0,force:!0})}catch{}}}async download(t,s){let e=null;for(let n=0;n<2;n+=1){let r=await ht(this.deps.fetch,t.url,t.bytes,s&&(a=>s(a,t.bytes))),o=ft(r);if(o===t.sha256)return r;e=new Error(`Checksum mismatch for ${t.url}: expected ${t.sha256}, got ${o}.`)}throw e??new Error(`Could not download ${t.url}`)}async readBundleManifest(t,s,e){let n;try{n=JSON.parse(await y(l(t,"manifest.json"),"utf8"))}catch{throw new Error(`The bundle at ${s} carries no readable manifest.json; refusing to install it.`)}if(n.platform!==this.deps.os||n.arch!==this.deps.arch)throw new Error(`The bundle at ${s} is built for ${n.platform}-${n.arch}; this host is ${this.deps.os}-${this.deps.arch}. A wrong blob was published for this coordinate.`);if(!n.supported_targets?.includes(e))throw new Error(`The bundle at ${s} does not support the ${e} device class (it supports: ${n.supported_targets?.join(", ")||"nothing"}). A wrong blob was published.`);return n}async postInstall(t,s,e){this.deps.os==="darwin"&&await this.deps.exec("xattr",["-dr","com.apple.quarantine",t],{timeoutMs:6e4});let n=l(t,"appium-home","node_modules",".cache","appium","extensions.yaml");if(await A(n)){let r=await y(n,"utf8"),o=bt(r,s.appiumHome);await x(n,o),e?.("Rewrote Appium extension paths for this machine")}}async withInstallLock(t){let s=l(this.mobileRoot(),"install.lock"),e=Date.now();for(await S(this.mobileRoot(),{recursive:!0});;)try{await S(s),await x(l(s,"owner.json"),JSON.stringify({pid:process.pid,startedAt:new Date().toISOString()}));try{return await t()}finally{await v(s,{recursive:!0,force:!0})}}catch(n){if(n.code!=="EEXIST")throw n;let r={};try{r=JSON.parse(await y(l(s,"owner.json"),"utf8"))}catch{}if(r.pid&&!this.deps.processAlive(r.pid)){await v(s,{recursive:!0,force:!0});continue}if(Date.now()-e>12e4)throw new Error(`Timed out waiting for the mobile install lock (holder pid ${r.pid??"unknown"}).`);await this.deps.wait(500)}}};function gt(i){let t=Object.keys(i).filter(e=>!e.endsWith("/")),s=new Set(t.map(e=>e.split("/")[0]));return s.size===1&&t.every(e=>e.includes("/"))?`${[...s][0]}/`:""}function bt(i,t){return i.split(`
|
|
10
|
+
`).map(s=>{let e=/^(\s*installPath:\s*)(.+?)\s*$/.exec(s);if(!e)return s;let n=e[2],r=/[\\/]node_modules[\\/]/g,o=-1;for(let a=r.exec(n);a;a=r.exec(n))o=a.index+a[0].length;return o<0?s:`${e[1]}${l(t,"node_modules",n.slice(o))}`}).join(`
|
|
11
|
+
`)}var G;function Et(){return G??=new J,G}export{q as a,Pt as b,j as c,at as d,lt as e,ut as f,ht as g,B as h,J as i,Et as j};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as l}from"./chunk-
|
|
2
|
+
import{b as l}from"./chunk-JEDLXUO5.js";import{a as m}from"./chunk-LVN6VHFN.js";import{a as p}from"./chunk-RZ4F3BHX.js";import{a as f}from"./chunk-PXCMEI73.js";import{a as c,c as s,i as a,x as u}from"./chunk-7F2ZV46B.js";var v="/public/skills/kane-cli";function C(){try{let n=new f().getDefaultEnv();if(n in u)return n}catch{}return"prod"}function k(){return`${m(C()).controllerBaseUrl}${v}`}import{readFileSync as S,writeFileSync as E,mkdirSync as g}from"fs";import{join as d}from"path";var h=d(s,"skill-check.json"),y=3600*1e3;function V(){try{let n=JSON.parse(S(h,"utf-8"));if(Date.now()-n.checkedAt<y)return n}catch{}return null}function A(n){try{g(s,{recursive:!0}),E(h,JSON.stringify({map:n,checkedAt:Date.now()}))}catch{}}function I(){for(let{dir:n}of a)try{let t=S(d(n,"VERSION"),"utf-8").trim();if(t)return t}catch{}return null}function M(n,t){let i=Object.keys(n.versions??{});if(i.length===0)return null;let o=i.slice().sort((r,e)=>l(r,e));for(let r of o){let e=n.versions[r]?.kaneCliMinVersion;if(!e||l(t,e)<=0)return r}return null}async function U(){try{let n=V()?.map;if(!n){let o=new AbortController,r=setTimeout(()=>o.abort(),5e3),e=await p(k(),{headers:{Accept:"application/json"},signal:o.signal});if(clearTimeout(r),!e.ok)return null;n=await e.json(),A(n)}let t=M(n,c);if(!t)return null;let i=I();return i===null?{current:null,latestCompatible:t}:l(i,t)>0?{current:i,latestCompatible:t}:null}catch{return null}}export{k as a,M as b,U as c};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as A}from"./chunk-YCCUBQY4.js";import{a as _}from"./chunk-
|
|
2
|
+
import{a as A}from"./chunk-YCCUBQY4.js";import{a as _}from"./chunk-5SNT2MK5.js";import{a as B}from"./chunk-BPMSNGXQ.js";import{a as R}from"./chunk-U5GHOGLM.js";import{a as k}from"./chunk-LVN6VHFN.js";import{y as c}from"./chunk-7F2ZV46B.js";import{a as P}from"./chunk-HCBYKLMW.js";import{a as u,b as l}from"./chunk-C44QQJR4.js";import{a as J}from"./chunk-6YGTRKDT.js";import{e as L}from"./chunk-UR6MHSHU.js";var t=L(J(),1);var e=L(P(),1);function X(n,i,y,m){return{id:n,label:`${i} (${n}) \xB7 ${y} tests`,isActive:n===m}}function W({resolver:n,projectId:i,currentFolderId:y,env:m,onSelect:x,onCancel:w}){let[I,M]=(0,t.useState)([]),[$,d]=(0,t.useState)(!0),[O,g]=(0,t.useState)(!1),[U,N]=(0,t.useState)(null),[p,b]=(0,t.useState)("list"),[S,v]=(0,t.useState)(""),[E,f]=(0,t.useState)(null),h=(0,t.useRef)(!1);(0,t.useEffect)(()=>{if(!n){N("Login first to browse folders"),d(!1);return}let o=new AbortController;return d(!0),g(!0),(async()=>{try{let r=n.cached??await n.resolve();if(!r){N("Login first to browse folders"),d(!1),g(!1);return}let a=k(m),T=new B(a.tmsBaseUrl,r.username,r.access_key),F=(async function*(){if(o.signal.aborted)return;let s=await T.listFolders(i);yield{page:1,folders:s,totalLoaded:s.length,done:!0}})();for await(let s of F){if(d(!1),s.totalLoaded===0){h.current=!0,b("naming"),g(!1);return}M(s.folders.map(C=>X(C.id,C.name,C.test_cases_count,y))),s.done&&g(!1)}}catch(r){if(r?.name==="AbortError")return;N(r instanceof Error?r.message:String(r)),d(!1),g(!1)}})(),()=>o.abort()},[n,i,y,m]);let D=(0,t.useCallback)(o=>{let r=o.trim();if(!r){f("Name cannot be empty");return}if(!i){f("No project selected \u2014 pick a project first");return}f(null),b("creating"),(async()=>{try{if(!n)throw new Error("Not authenticated");let a=n.cached??await n.resolve();if(!a)throw new Error("Not authenticated");let T=k(m),s=await new B(T.tmsBaseUrl,a.username,a.access_key).createFolder(i,r);x(s.id,s.name)}catch(a){f(a instanceof Error?a.message:String(a)),b("naming")}})()},[n,i,m,x]),H=(0,t.useCallback)(()=>{v(""),f(null),h.current?w():b("list")},[w]);return p==="naming"||p==="creating"?(0,e.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:c.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:c.orange,bold:!0,children:"Create new folder"}),h.current&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.dim,children:"No folders yet \u2014 let's create one."})}),(0,e.jsxs)(u,{marginTop:1,children:[(0,e.jsx)(l,{color:c.dim,children:"Name: "}),p==="naming"?(0,e.jsx)(A,{value:S,onChange:o=>{v(o),E&&f(null)},onSubmit:D,onCancel:H}):(0,e.jsx)(l,{children:S})]}),E&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.red,children:E})}),p==="creating"&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.dim,children:"Creating..."})}),p==="naming"&&(0,e.jsx)(R,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:h.current?"cancel":"back"})]}):(0,e.jsx)(_,{title:"Folders",items:I,loading:$,loadingMore:O,preserveSelectionById:!0,error:U,itemNoun:"folders",onTab:()=>{h.current=!1,b("naming")},extraHint:"tab to create new",onSelect:o=>{let r=o.label.split(" (")[0];x(o.id,r)},onCancel:w})}export{X as a,W as b};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as c}from"./chunk-
|
|
2
|
+
import{a as c}from"./chunk-LVN6VHFN.js";import{a as n}from"./chunk-RZ4F3BHX.js";import{v as s,w as a}from"./chunk-7F2ZV46B.js";import{createHash as h,randomBytes as g}from"crypto";var l=class{authBaseUrl;consentUrl;constructor(t="prod"){let e=c(t);this.authBaseUrl=e.authBaseUrl,this.consentUrl=e.consentUrl}static generatePkce(){let t=g(96).toString("base64url").slice(0,128),e=h("sha256").update(t).digest("base64url");return[t,e]}buildAuthorizationUrl(t,e,r,o){let i=new URLSearchParams({response_type:"code",client_id:t,redirect_uri:o,scope:a,code_challenge:e,code_challenge_method:"S256",state:r});return`${this.consentUrl}/oauth2?${i.toString()}`}async registerClient(t){let e=await n(`${this.authBaseUrl}/oauth2/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:s,redirect_uris:[t],grant_types:["authorization_code"],response_types:["code"],client_type:"public",application_type:"native"})});if(!e.ok)throw new Error(`DCR failed: ${e.status} ${await e.text()}`);return e.json()}async exchangeCode(t,e,r,o){let i=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:t,redirect_uri:o,client_id:e,code_verifier:r})});if(!i.ok)throw new Error(`Token exchange failed: ${i.status}`);return i.json()}async refreshToken(t,e){let r=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:t,client_id:e})});if(!r.ok)throw new Error(`Token refresh failed: ${r.status}`);return r.json()}async revokeToken(t,e,r="access_token"){await n(`${this.authBaseUrl}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,token_type_hint:r,client_id:e})})}async validateToken(t){let e=new AbortController,r=setTimeout(()=>e.abort(),1e4);try{let o=await n(`${this.authBaseUrl}/api/user`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},signal:e.signal});return clearTimeout(r),o.ok}catch{return clearTimeout(r),!1}}};export{l as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as l}from"./chunk-RZ4F3BHX.js";import{a,c,f as o}from"./chunk-
|
|
2
|
+
import{a as l}from"./chunk-RZ4F3BHX.js";import{a,c,f as o}from"./chunk-7F2ZV46B.js";import{readFileSync as f,writeFileSync as d,mkdirSync as h,realpathSync as g}from"fs";import{join as y}from"path";var C="npm install -g @testmuai/kane-cli@latest",b="brew upgrade lambdatest/kane/kane-cli";function w(){try{let t=process.argv[1];if(t&&g(t).includes("/Cellar/"))return b}catch{}return C}var m=y(c,"version-check.json"),S=1440*60*1e3;function k(){try{let t=JSON.parse(f(m,"utf-8"));if(Date.now()-t.checkedAt<S)return t}catch{}return null}function A(t){try{h(c,{recursive:!0}),d(m,JSON.stringify({latest:t,checkedAt:Date.now()}))}catch{}}function u(t,r){let i=t.split(".").map(Number),n=r.split(".").map(Number);for(let s=0;s<3;s++){let e=(n[s]??0)-(i[s]??0);if(e!==0)return e}return 0}function p(t,r){let i=t.split(".").map(Number),n=r.split(".").map(Number);return(n[0]??0)!==(i[0]??0)?"major":(n[1]??0)!==(i[1]??0)?"minor":"patch"}async function j(){try{let t=k();if(t)return u(a,t.latest)>0?{current:a,latest:t.latest,severity:p(a,t.latest)}:null;let r=new AbortController,i=setTimeout(()=>r.abort(),5e3),n=await l(o,{headers:{Accept:"application/json"},signal:r.signal});if(clearTimeout(i),!n.ok)return null;let e=(await n.json())["dist-tags"]?.latest;return e?(A(e),u(a,e)>0?{current:a,latest:e,severity:p(a,e)}:null):null}catch{return null}}export{w as a,u as b,p as c,j as d};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as v,b as A,d as G}from"./chunk-OS4VSIHT.js";import{b as x}from"./chunk-TRJUD3XJ.js";import{a as S}from"./chunk-JZ26R6UL.js";import{a as U,b as C}from"./chunk-UJZZDPDY.js";import{a as w}from"./chunk-JFAFKHDX.js";import{A as E,B as $}from"./chunk-TH47OOBV.js";import{d,e as m}from"./chunk-WXHQYYD5.js";var k=new Set([d.USECASE,d.SCENARIO,d.AC,d.TEST]);function b(e,t){return!e.superseded.has(t)&&e.trust.get(t)!=="archived"}function h(e,t,n){let s=e.edgesFrom(t).find(o=>o.type===n);return s?e.tipOf(s.dst):null}function O(e,t,n){if(n===d.USECASE)return t;if(n===d.SCENARIO)return h(e,t,m.BELONGS_TO);if(n===d.AC){let s=h(e,t,m.SCOPED_TO);return s?e.nodeLabel.get(s)===d.USECASE?s:h(e,s,m.BELONGS_TO):null}if(n===d.TEST){let s=h(e,t,m.AUTOMATES);return s?h(e,s,m.BELONGS_TO):null}return null}function L(e,t){let n=e.nameOf.get(t);if(n)return n;for(let[s,o]of e.names)if(e.tipOf(o)===t)return s;return t}function F(e,t){return{ucTip:t,display:L(e,t),seamRef:e.nameOf.get(t)??t}}function N(e,t){let n=e.resolve(t);if(!n)return{ok:!1,message:`unknown ref '${t}' \u2014 no test/scenario/ac/use-case by that id or cid`};let s=n.tip,o=e.nodeLabel.get(s);if(!o||!k.has(o))return{ok:!1,message:`'${t}' is a ${o??"missing node"} \u2014 evolve takes a test, scenario, acceptance criterion, or use-case`};let a=O(e,s,o);return!a||e.nodeLabel.get(a)!==d.USECASE?{ok:!1,message:`cannot resolve '${t}' to a parent use-case \u2014 its ${o} chain is broken`}:e.superseded.has(a)?{ok:!1,message:`use-case ${L(e,a)} was removed \u2014 nothing to evolve`}:{ok:!0,target:F(e,a)}}function Z(e,t){return D(e,t)}function D(e,t){let n=[];for(let{cid:o}of e.byLabel(d.SCENARIO)){if(!b(e,o)||!e.edgesFrom(o).some(r=>r.type===m.BELONGS_TO&&e.tipOf(r.dst)===t))continue;let a=e.edgesInto(o).filter(r=>r.type===m.AUTOMATES&&b(e,r.src));if(a.length===0)n.push({scenario:o,test:null});else for(let r of a)n.push({scenario:o,test:r.src})}let s=new Map;for(let{cid:o}of e.byLabel(d.AC)){if(!b(e,o)||O(e,o,d.AC)!==t)continue;let a=e.edgesInto(o).filter(r=>r.type===m.VERIFIES&&b(e,r.src)).map(r=>r.src).sort();s.set(o,a)}return{pairs:n,verifies:s}}function B(e,t){let n=r=>`${r.scenario}\0${r.test??""}`,s=new Set(e.pairs.map(n)),o=new Set(t.pairs.map(n)),a=[];for(let[r,i]of e.verifies){let u=t.verifies.get(r);u&&(i.length===u.length&&i.every((l,g)=>l===u[g])||a.push({ac:r,before:i,after:u}))}return{superseded:e.pairs.filter(r=>!o.has(n(r))),minted:t.pairs.filter(r=>!s.has(n(r))),retained:t.pairs.filter(r=>s.has(n(r))),moves:a}}function _(e,t,n,s,o){let a=i=>t.nameOf.get(i)??i,r=i=>` - ${a(i.scenario)} \xB7 ${i.test?a(i.test):"(no test)"}`;e.out(`evolved: use-case ${n} \u2014 design record ${s.before} \u2192 ${s.after}`),e.out(` superseded ${o.superseded.length} pair(s)`);for(let i of o.superseded)e.out(r(i));e.out(` minted ${o.minted.length} pair(s)`);for(let i of o.minted)e.out(r(i));e.out(` retained ${o.retained.length} pair(s)`);for(let i of o.retained)e.out(r(i));if(o.moves.length===0)e.out(" verifies none moved");else{e.out(" verifies moved:");for(let i of o.moves){let u=l=>l.length>0?l.map(a).join(" + "):"(none)";e.out(` - ${a(i.ac)}: ${u(i.before)} \u2192 ${u(i.after)}`)}}}async function R(e,t,n,s,o,a,r){let i=E(e),u=S(i,t.ucTip);if(!u)return a==="batch"?(s.out(`note: ${t.display} has no design output \u2014 nothing to evolve; run kane-cli design tests --use-case ${t.display} first`),{code:0,outcome:"no-design"}):(v(s,`nothing to evolve \u2014 run kane-cli design tests --use-case ${t.display} first (no design output)`),{code:2,outcome:"no-design"});let l=D(i,t.ucTip),g=[`evolve ${t.display}`,` re-designs use-case ${t.display}`,` affects ${l.pairs.length} pair(s)`,...n.because?[` because ${n.because}`]:[]];if(n.yes)for(let y of g)s.out(y);else{for(let I of g)s.out(I);if(!await s.confirm(`proceed with the re-design of ${t.display}?`))return s.out(a==="batch"?`skipped ${t.display}`:"declined \u2014 nothing evolved"),{code:0,outcome:"declined"}}let p=x(e,i,t.ucTip,n.because),c=await U(r,{verb:"evolve",subject:t.display},()=>o(t.seamRef,{yes:!!n.yes,...n.mode?{mode:n.mode}:{},...n.because?{because:n.because}:{},...p!==void 0?{changeDelta:p.change_delta,priorDesign:p.prior_design}:{}}),y=>({ok:y===0,exitCode:y}));if(c===3)return s.out(`design session for ${t.display} paused \u2014 resume with \`kane-cli design tests --resume\`, then re-run evolve for the diff`),{code:c,outcome:"paused"};if(c!==0)return v(s,`design run for ${t.display} ended with exit code ${c} \u2014 no diff to report`),{code:c,outcome:"failed"};let f=E(e),T=f.tipOf(t.ucTip),P=S(f,T)?.seq;return _(s,f,t.display,{before:u.seq,after:P??"?"},B(l,D(f,T))),{code:0,outcome:"evolved"}}function j(e){let t=new Map,n=0;for(let{cid:o,state:a}of e.staleList()){if(a==="superseded")continue;let r=e.nodeLabel.get(o);if(!r||!k.has(r)||!b(e,o)||!$(e,o))continue;let i=O(e,o,r);!i||e.nodeLabel.get(i)!==d.USECASE||e.superseded.has(i)||(n++,t.has(i)||t.set(i,F(e,i)))}return{targets:[...t.values()].sort((o,a)=>o.display<a.display?-1:o.display>a.display?1:0),staleCount:n}}function M(e,t){for(let{cid:n,state:s}of e.staleList()){if(s==="superseded")continue;let o=e.nodeLabel.get(n);if(!(!o||!k.has(o)||!b(e,n))&&$(e,n)&&O(e,n,o)===t)return!0}return!1}async function q(e,t,n,s={},o=process.cwd()){if(e&&t.fromStale)return v(n,"pass a <ref> OR --from-stale, not both"),2;if(!e&&!t.fromStale)return v(n,"evolve needs a <ref> or --from-stale"),2;let a=A(o,n);if(!a)return 2;let r=s.runDesignForUc??Y,i=s.onChild??(n.isTTY?V(n):void 0);n.out(`evolving ${e??"stale use-cases"}: reading the graph\u2026`);let u=E(a),l,g=null;if(e){let c=N(u,e);if(!c.ok)return v(n,c.message),2;if(!t.because&&S(u,c.target.ucTip)&&!M(u,c.target.ucTip))return v(n,`nothing changed underneath ${e} \u2014 its sources and requirements are current; use --because "<reason>" to re-design anyway`),2;l=[c.target]}else{let{targets:c,staleCount:f}=j(u);if(c.length===0)return n.out("nothing stale \u2014 nothing to evolve"),0;g=`from-stale: ${f} stale node(s) \u2192 ${c.length} use-case(s)`,l=c}if(!t.yes&&!n.isTTY)return v(n,"evolve needs a TTY \u2014 the blast-radius confirm is the point; headless evolution rides `kane-cli maintain reconcile`"),2;if(g&&n.out(g),e){let c=await R(a,l[0],t,n,r,"single",i);return c.outcome==="evolved"&&t.because&&w(a,{ts:new Date().toISOString(),command:"evolve",id:e,verdict:"gap-resolved-evolve",polarity:"preference",by:{kind:"human",id:process.env.USER??"operator"},target:e,reason:t.because}),c.code}let p=0;for(let c of l){let{code:f}=await R(a,c,t,n,r,"batch",i);f!==0&&p===0&&(p=f)}return p}function V(e){let t="",n="evolve";return s=>{s.kind==="start"?(t=s.subject,n=s.verb,e.out(`\u25CF ${C(s.verb).ing} ${s.subject}`)):s.kind==="end"&&e.out(s.ok?`\u25CF ${C(n).ed} ${t} \u2014 ${s.durS}s`:`\u25CF ${n} failed \u2014 ${s.exitCode!=null?`exited ${s.exitCode}`:"error"}${s.fixCmd?` \xB7 ${s.fixCmd}`:""}`)}}var Y=async(e,t)=>{let{designTestsCommand:n}=await import("./bind-LVGP5KHO.js"),s=()=>n({useCase:e,force:!0,...t.mode?{mode:t.mode}:t.yes?{mode:"override"}:{},...t.because?{because:t.because}:{},...t.changeDelta!==void 0?{changeDelta:t.changeDelta}:{},...t.priorDesign!==void 0?{priorDesign:t.priorDesign}:{}});if(t.mode!=="agent")return s();let o=process.stdout.write;process.stdout.write=((...a)=>!0);try{return await s()}finally{process.stdout.write=o}};async function ee(e,t){return q(e,t,G(),{})}export{N as a,Z as b,R as c,j as d,q as e,Y as f,ee as g};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as t}from"./chunk-
|
|
2
|
+
import{a as t}from"./chunk-J7KT44IC.js";async function l(e){let o=e.credentials.expires_at,i=e.thresholdSeconds??300;if(o-Date.now()/1e3>=i)return null;let r=e.creds.loadClient(e.profile,e.env);if(!r)return null;let n=await new t(e.env).refreshToken(e.credentials.refresh_token,r.client_id),s=Math.floor(Date.now()/1e3)+n.expires_in;return e.creds.saveCredentials(e.profile,e.env,{access_token:n.access_token,refresh_token:n.refresh_token,expires_at:s,scope:n.scope}),{accessToken:n.access_token,refreshToken:n.refresh_token,expiresAt:s,scope:n.scope}}export{l as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as f}from"./chunk-
|
|
2
|
+
import{a as f}from"./chunk-U5GHOGLM.js";import{y as r}from"./chunk-7F2ZV46B.js";import{a as g}from"./chunk-HCBYKLMW.js";import{a as i,b as n,i as p}from"./chunk-C44QQJR4.js";import{a as x}from"./chunk-6YGTRKDT.js";import{e as d}from"./chunk-UR6MHSHU.js";var b=d(x(),1);var e=d(g(),1),v=[{value:"desktop",label:"Desktop",hint:"Chrome on this machine"},{value:"emulator",label:"Emulator",hint:"a virtual Android device"},{value:"simulator",label:"Simulator",hint:"a virtual iOS device"}];function T(a){return a==="all"?v:v.filter(l=>l.value!=="desktop")}function B({mode:a="all",onSelect:l,onCancel:c}){let u=T(a),[h,m]=(0,b.useState)(0);return p((s,o)=>{if(o.escape&&c){c();return}o.upArrow&&m(t=>Math.max(0,t-1)),o.downArrow&&m(t=>Math.min(u.length-1,t+1)),o.return&&l(u[h].value)}),(0,e.jsxs)(i,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(n,{color:r.orange,bold:!0,children:a==="all"?"Where should tests run?":"Which kind of device?"}),(0,e.jsx)(i,{marginTop:1,flexDirection:"column",children:u.map((s,o)=>{let t=o===h;return(0,e.jsxs)(i,{children:[(0,e.jsxs)(n,{color:t?r.orange:void 0,children:[t?"\u276F ":" ",s.label]}),(0,e.jsxs)(n,{color:r.dim,children:[" ",s.hint]})]},s.value)})}),(0,e.jsx)(i,{marginTop:1,children:(0,e.jsx)(n,{color:r.dim,children:"You can change this any time with /desktop or /mobile."})}),(0,e.jsx)(f,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],suppressEscBack:!c,escBackLabel:"skip"})]})}export{B as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{O,Q as S}from"./chunk-
|
|
2
|
+
import{O,Q as S}from"./chunk-2KH2JUGL.js";import{c as L}from"./chunk-RFHMDQXZ.js";import{m as P,n as R}from"./chunk-56PAQAX5.js";import{y as s}from"./chunk-7F2ZV46B.js";import{a as y}from"./chunk-HCBYKLMW.js";import{a as E,b as o,i as h}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as d}from"./chunk-UR6MHSHU.js";var n=d(B(),1);import{basename as D}from"path";var r=d(y(),1),U="evidence-view-server";function Q({packPath:m,viewerBase:w,onDone:V,openUrl:k}){let[t,a]=(0,n.useState)("ask"),[g,b]=(0,n.useState)(null),[l,p]=(0,n.useState)(null),f=(0,n.useRef)(null),u=(0,n.useRef)(!1),x=async()=>{let e=f.current;f.current=null,e&&(R(U),await e.close())},v=()=>{u.current||(u.current=!0,V())};return h((e,i)=>{u.current||(t==="ask"?e==="y"||e==="Y"?a("starting"):(e==="n"||e==="N"||i.return||i.escape)&&v():t==="serving"&&(e==="q"||e==="Q"||i.escape)&&x().then(v))}),(0,n.useEffect)(()=>{if(t!=="starting")return;let e=!1;return(async()=>{try{let i=D(m),c=await O({packs:new Map([[i,m]]),allowedOrigins:[new URL(w).origin]});if(e){await c.close();return}f.current=c,P(U,()=>{c.close()});let T=S(c.urlFor(i),w);b(T);try{await(k??(q=>L(q)))(T)}catch{p("could not open browser \u2014 open the URL manually")}a("serving")}catch(i){p(`evidence view failed \u2014 ${i.message}`),a("failed")}})(),()=>{e=!0}},[t]),(0,n.useEffect)(()=>{if(t!=="failed")return;let e=setTimeout(v,0);return()=>clearTimeout(e)},[t]),(0,n.useEffect)(()=>()=>{x()},[]),t==="ask"?(0,r.jsxs)(o,{children:["View evidence in browser? ",(0,r.jsx)(o,{color:s.dim,children:"(y/N)"})]}):t==="serving"||t==="starting"?(0,r.jsxs)(E,{flexDirection:"column",children:[g?(0,r.jsxs)(o,{children:["viewer ",(0,r.jsx)(o,{color:s.orange,children:g})]}):(0,r.jsx)(o,{color:s.dim,children:"starting\u2026"}),l?(0,r.jsx)(o,{color:"yellow",children:l}):null,t==="serving"?(0,r.jsx)(o,{color:s.dim,children:"Press q when done"}):null]}):l?(0,r.jsx)(o,{color:"yellow",children:l}):null}export{Q as a};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as Y,b as Z,c as nn,d as en,e as tn}from"./chunk-NRUD56FY.js";import{b as rn,c as sn}from"./chunk-6IA6QMPH.js";import{m as X,o as P}from"./chunk-56PAQAX5.js";import{a as jn}from"./chunk-6YGTRKDT.js";import{e as Pn}from"./chunk-UR6MHSHU.js";function on(i){return{command:"start",...i}}function an(i,e,o){return{command:"run",run_id:i,kind:e,...o}}function un(i){return{command:"cancel",...i?{run_id:i}:{}}}function dn(i){return{command:"ask_user_response",answer:i}}function ln(){return{command:"shutdown"}}var z=Symbol("run-queue-end"),G=class{items=[];waiting=null;ended=!1;error=null;push(e){if(this.waiting){let{resolve:o}=this.waiting;this.waiting=null,o(e)}else this.items.push(e)}end(){if(this.ended=!0,this.waiting){let{resolve:e}=this.waiting;this.waiting=null,e(z)}}fail(e){if(this.error=e,this.waiting){let{reject:o}=this.waiting;this.waiting=null,o(e)}}next(){return this.items.length>0?Promise.resolve(this.items.shift()):this.error?Promise.reject(this.error):this.ended?Promise.resolve(z):new Promise((e,o)=>{this.waiting={resolve:e,reject:o}})}},D=class{env;runner;log;sessionId;spawnFn;proc=null;activeRun=null;pendingReady=null;shuttingDown=!1;finalized=!1;exitInfo=null;exitedUnexpectedly=!1;exitResolve;exited;constructor(e){this.env=e.env,this.runner=e.runner,this.log=e.log,this.sessionId=e.sessionId,this.spawnFn=e.spawn??Z;let o;this.exited=new Promise(c=>{o=c}),this.exitResolve=o}async start(e){if(this.proc)throw new Error("PersistentRunner.start called twice");this.proc=this.spawnFn({env:this.env,runner:this.runner,log:this.log,sessionId:this.sessionId}),this.consume();let o=new Promise((c,g)=>{this.pendingReady={resolve:c,reject:g}});this.writeCommand(on(e)),await o}async*run(e,o,c){if(!this.proc)throw new Error("PersistentRunner.run called before start");if(this.finalized)throw new Error(`v16-runner is not running (exited code=${this.exitInfo?.code??"null"}, signal=${this.exitInfo?.signal??"none"}) \u2014 cannot start run '${e}'`);if(this.activeRun)throw new Error(`PersistentRunner.run overlap: '${this.activeRun.runId}' still in flight`);let g=new G,w={runId:e,queue:g};this.activeRun=w,this.writeCommand(an(e,o,c));try{for(;;){let v=await g.next();if(v===z||(yield v,v.type==="run_end"&&(v.run_id===void 0||v.run_id===e)))break}}finally{this.activeRun===w&&(this.activeRun=null)}}sendUserResponse(e){this.writeCommand(dn(e))}cancel(e){this.writeCommand(un(e))}kill(){this.proc?.child.kill("SIGTERM")}async shutdown(){this.shuttingDown=!0,this.proc&&(this.writeCommand(ln()),await this.exited)}get stderr(){return this.proc?.getStderr()??""}get diedUnexpectedly(){return this.exitedUnexpectedly}writeCommand(e){let o=JSON.stringify(e)+`
|
|
3
|
+
`;try{this.proc?.child.stdin?.write(o)}catch{}}async consume(){if(!this.proc)return;try{for await(let c of this.proc.events){if(c.type==="ready"){this.onReady();continue}this.routeEvent(c)}}catch(c){this.log?.("error","PERSISTENT_RUNNER_STREAM_ERROR","Runner stdout stream errored",{error:c instanceof Error?c.message:String(c)})}let{code:e,signal:o}=await this.proc.exited;this.onExit(e,o)}onReady(){if(this.pendingReady){let{resolve:e}=this.pendingReady;this.pendingReady=null,e()}}routeEvent(e){let o=this.activeRun;if(!o){this.log?.("warn","PERSISTENT_RUNNER_ORPHAN_EVENT","Runner event with no active run",{event_type:e.type});return}o.queue.push(e)}onExit(e,o){if(!this.finalized){if(this.finalized=!0,this.exitInfo={code:e,signal:o},this.shuttingDown||(this.exitedUnexpectedly=!0),this.exitResolve({code:e,signal:o}),this.pendingReady){let{reject:c}=this.pendingReady;this.pendingReady=null,c(new Error(`v16-runner exited before ready (code=${e}, signal=${o??"none"})`))}if(this.activeRun){let{queue:c}=this.activeRun;if(this.activeRun=null,this.shuttingDown)c.end();else{let g=this.proc?.getStderr()?.slice(-500)??"";c.fail(new Error(`v16-runner exited unexpectedly mid-run (code=${e}, signal=${o??"none"})${g?`
|
|
4
|
+
${g}`:""}`))}}}}};var p=Pn(jn(),1);function cn(i){let e={cdp_endpoint:i.cdp_endpoint,ws_endpoint:i.ws_endpoint,width:i.width,height:i.height,headless:i.headless,model:i.model,max_steps:i.max_steps,network_ws:i.network_ws,network_sse:i.network_sse,session_id:i.session_id};return i.device&&(e.device=i.device),i.auth&&(e.auth=i.auth),i.username&&(e.username=i.username),i.access_key&&(e.access_key=i.access_key),e}function j(i,e){let o=null,c=(g,w)=>{for(let v=0;v<g.length;v++){let b=g[v],h=[...w,v];e(b)&&(o===null||h.length>o.length)&&(o=h),b.children&&b.children.length>0&&c(b.children,h)}};return c(i,[]),o}function N(i,e,o){if(e.length===0)return[...i];let c=e[0],g=[...i],w=g[c];if(e.length===1)g[c]=o(w);else{let v=e.slice(1),b=N(w.children??[],v,o);g[c]={...w,children:b}}return g}function pn(){return{steps:[],maxOrdinal:0}}function Nn(i,e){if(e.type==="run_start"&&e.child_id)return e.environment?.resolution?{...i,resolution:e.environment.resolution}:i;if(e.type==="run_start"){let o=sn(i.runnerEnvironment,rn(e.environment));if(o)return{...i,runnerEnvironment:o,...o.resolution?{resolution:o.resolution}:{}}}if(e.type==="step_end"&&typeof e.ordinal=="number"&&e.id){let o={id:e.id,ordinal:e.ordinal,status:e.status,...e.kind?{kind:e.kind}:{},...typeof e.duration=="number"?{duration_ms:Math.round(e.duration*1e3)}:{},...typeof e.action_id=="string"&&e.action_id?{action_id:e.action_id}:{}};return{...i,steps:[...i.steps,o],maxOrdinal:Math.max(i.maxOrdinal,e.ordinal)}}return i}function V(i){let e=i.indexOf(": ");return e>0&&e<15?i.slice(e+2):i}function W(i){return i.map(e=>{let o=e.children?W(e.children):e.children;return e.status==="running"?{...e,status:"stopped",phase:void 0,children:o}:o!==e.children?{...e,children:o}:e})}function Gn(i,e,o,c,g){let[w,v]=(0,p.useState)(!1),[b,h]=(0,p.useState)([]),[hn,T]=(0,p.useState)(null),[fn,B]=(0,p.useState)(null),[mn,I]=(0,p.useState)(null),[vn,J]=(0,p.useState)(null),[gn,H]=(0,p.useState)([]),[Rn,K]=(0,p.useState)(null),[Sn,yn]=(0,p.useState)(void 0),[wn,$]=(0,p.useState)(0),y=(0,p.useRef)(null),E=(0,p.useRef)(null),S=(0,p.useRef)(null),_=(0,p.useRef)(0),F=(0,p.useRef)(!1),U=(0,p.useRef)(pn()),O=(0,p.useRef)(null),xn=(0,p.useCallback)(async(m,x)=>{let Q=O.current;if(Q)try{await Q}catch{}h([]),T(null),B(null),I(null),J(null),H([]),K(null),yn(m.max_steps),v(!0),S.current=null,_.current=0,U.current=pn();let k=y.current;if(k&&E.current!==m.session_id){try{k.kill()}catch{}y.current=null,E.current=null,$(n=>n+1),k=null}if(!k){let n=Y();if(!n){I("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available."),v(!1);return}let d=en({environment:x?.environment,mode:x?.mode,assertionMode:x?.assertionMode,finalValidation:x?.finalValidation,username:m.username,accessKey:m.access_key,sessionId:m.session_id});m.device?.platform&&await nn(d,m.device);let u=new D({env:d,runner:n,log:x?.log,sessionId:m.session_id});y.current=u,E.current=m.session_id,k=u,X("runner",()=>{try{u.kill()}catch{}});let s=cn(m);try{await u.start(s)}catch(a){I(a instanceof Error?a.message:String(a)),v(!1),P("runner","Runner start failed"),y.current=null,E.current=null,$(t=>t+1);return}}let M={...m};delete M.run_id,tn(M,{environment:x?.environment});let kn=`run-${m.run_index}`,Cn=m.mode==="replay"?"replay":"author",L=k,q=(async()=>{F.current=!1;for await(let n of L.run(kn,Cn,M)){if(F.current)break;switch(U.current=Nn(U.current,n),n.type){case"run_start":if(n.child_id)break;if(S.current&&!S.current.isSingleFlow){let d=_.current;_.current++,h(u=>u.map((s,a)=>a===d?{...s,status:"running"}:s.status==="running"&&!s.children?.some(t=>t.status==="running")?{...s,status:s.children?.some(t=>t.status==="failed")?"failed":"passed"}:s))}break;case"bifurcation":{let d=n.flows??[],u=n.count??d.length,s={flows:d,isSingleFlow:n.is_single_flow??u<=1};J(s),S.current=s,_.current=0,h(d.map((a,t)=>({index:t+1,objective:a??`Flow ${t+1}`,status:"pending"})));break}case"step_start":{e?.("STEP_START",`Step ${n.index} started`,{index:n.index,objective:n.objective,child_id:n.child_id});let d=n.index,u=n.objective??`Step ${d}`,s=n.child_id,a=S.current&&!S.current.isSingleFlow;if(s)h(t=>{let r=j(t,l=>l.branchChildId===s)??j(t,l=>l.status==="running");return r?N(t,r,l=>{let f=(l.children??[]).map(R=>R.status==="running"&&R.childId===s?{...R,status:"stopped",phase:void 0}:R);return f.push({index:d,objective:u,status:"running",childId:s}),{...l,children:f}}):t});else if(a){let t=Math.max(0,_.current-1);h(r=>{let l=[...r];if(t>=l.length)return r;let f={...l[t]},C=[...f.children??[]].map(A=>A.status==="running"&&A.childId===void 0?{...A,status:"stopped",phase:void 0}:A);return C.push({index:d,objective:u,status:"running"}),f.children=C,f.status="running",l[t]=f,l})}else h(t=>{let r=W(t);return r.some(f=>f.index===d)?r.map(f=>f.index===d?{...f,status:"running",objective:u}:f):[...r,{index:d,objective:u,status:"running"}]});break}case"step_event":{e?.("STEP_EVENT",`Step ${n.index} ${n.event}`,{index:n.index,phase:n.event,action_type:n.action_type,detail:n.detail,child_id:n.child_id});let d=n.child_id,u=S.current&&!S.current.isSingleFlow;if(n.event==="cm_init"&&n.checkpoint_count!=null){H(s=>[...s,n.checkpoint_count]);break}if(n.event==="replay_started"){K({recordingLength:n.recording_length??0});break}if(n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&o?.(n.detail),d){let s=t=>{if(t.index!==n.index||t.childId!==d)return t;let r={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(r.objective=n.detail),n.action_type&&(r.actionType=n.action_type),{...t,...r}},a=t=>t.map(r=>{let l=s(r);return l!==r?l:r.children&&r.children.length>0?{...r,children:a(r.children)}:r});h(t=>t.map(r=>r.children?{...r,children:a(r.children)}:r))}else if(u){let s=Math.max(0,_.current-1);h(a=>{let t=[...a];if(s>=t.length)return a;let r={...t[s]},l=[...r.children??[]];if(!l.some(R=>R.index===n.index&&R.childId===void 0))l.push({index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type});else for(let R=0;R<l.length;R++){if(l[R].index!==n.index||l[R].childId!==void 0)continue;let C={phase:n.event};n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(C.objective=n.detail),n.action_type&&(C.actionType=n.action_type),l[R]={...l[R],...C}}return r.children=l,t[s]=r,t})}else h(s=>s.some(t=>t.index===n.index)?s.map(t=>{if(t.index!==n.index)return t;let r={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(r.objective=n.detail),n.action_type&&(r.actionType=n.action_type),{...t,...r}}):[...W(s),{index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type}]);break}case"step_end":{e?.("STEP_END",`Step ${n.index} ${n.status}`,{index:n.index,status:n.status,duration:n.duration,summary:n.summary,child_id:n.child_id}),c?.();let d=n.child_id,u=S.current&&!S.current.isSingleFlow;if(d){let s=t=>t.index===n.index&&t.childId===d?{...t,status:n.status,duration:n.duration,phase:void 0,objective:t.objective.startsWith("Step ")?V(n.summary||t.objective):t.objective}:t,a=t=>t.map(r=>{let l=s(r);return l!==r?l:r.children&&r.children.length>0?{...r,children:a(r.children)}:r});h(t=>t.map(r=>r.children?{...r,children:a(r.children)}:r))}else if(u){let s=Math.max(0,_.current-1);h(a=>{let t=[...a];if(s>=t.length)return a;let r={...t[s]},l=(r.children??[]).map(f=>f.index===n.index&&f.childId===void 0?{...f,status:n.status,duration:n.duration,phase:void 0,objective:f.objective.startsWith("Step ")?V(n.summary||f.objective):f.objective}:f);return r.children=l,t[s]=r,t})}else h(s=>s.map(a=>a.index===n.index?{...a,status:n.status,duration:n.duration,phase:void 0,objective:a.objective.startsWith("Step ")?V(n.summary||a.objective):a.objective}:a));{let a=S.current&&!S.current.isSingleFlow?Math.max(0,_.current-1):0,t=typeof n.ordinal=="number"&&n.id?{ordinal:n.ordinal,id:n.id}:void 0;i?.(n.index,a,n.child_id,t)}break}case"child_agent_start":{let d=n.objective??"",u=n.child_id;h(s=>{let a=j(s,t=>t.status==="running");return a?N(s,a,t=>({...t,objective:`${d} (branch)`,phase:`child: ${d.slice(0,50)}`,branchObjective:d,branchChildId:u})):s});break}case"child_agent_end":{let d=n.child_id,u=`child ${n.success?"done":"failed"}`;h(s=>{let a=j(s,t=>t.branchChildId===d);return a?N(s,a,t=>({...t,phase:u})):s.map(t=>t.phase?.startsWith("child:")?{...t,phase:u}:t)});break}case"describe_trigger":g?.(n);break;case"ask_user":T(n.question??"");break;case"run_end":h(d=>d.map(u=>u.status==="running"?{...u,status:n.status,phase:void 0}:u)),v(!1),B(n);break;case"error":v(!1),I(n.message??"Runner error"),h(d=>d.map(u=>u.status==="running"?{...u,status:"failed",phase:void 0}:u));break}}})().catch(n=>{if(y.current!==L)return;let u=[n instanceof Error?n.message:String(n)],s=L.stderr;s&&!u.join(`
|
|
5
|
+
`).includes(s)&&u.push(s),I(u.join(`
|
|
6
|
+
`)),v(!1),h(a=>a.map(t=>t.status==="running"?{...t,status:"failed",phase:void 0}:t)),P("runner","Runner died mid-run"),y.current=null,E.current=null,$(a=>a+1)});O.current=q,q.finally(()=>{O.current===q&&(O.current=null)})},[i,e,o,c,g]),bn=(0,p.useCallback)(m=>{y.current?.sendUserResponse(m),T(null)},[]),_n=(0,p.useCallback)(()=>{let m=y.current;m&&(m.cancel(),v(!1),T(null))},[]),En=(0,p.useCallback)(async()=>{let m=y.current;if(m){try{await Promise.race([m.shutdown(),new Promise(x=>setTimeout(x,5e3))])}catch{}P("runner","Runner shut down"),y.current=null,E.current=null,$(x=>x+1)}},[]),In=(0,p.useCallback)(()=>{h([]),B(null),I(null)},[]);return(0,p.useEffect)(()=>()=>{F.current=!0,P("runner","Component unmounted"),y.current=null,E.current=null},[]),{isRunning:w,steps:b,askingUser:hn,lastRunEnd:fn,runError:mn,bifurcationInfo:vn,cmInitCounts:gn,replayInfo:Rn,maxSteps:Sn,sessionGen:wn,startRun:xn,sendAnswer:bn,cancelRun:_n,shutdownRunner:En,clearLastRun:In,getEvidenceState:()=>U.current}}export{D as a,cn as b,pn as c,Nn as d,Gn as e};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as w,b as O}from"./chunk-R5T4RLF5.js";import{
|
|
2
|
+
import{a as w,b as O}from"./chunk-R5T4RLF5.js";import{a as I}from"./chunk-KBM3XHAM.js";import{e as L}from"./chunk-IDX3TOPY.js";import{a as N,b as k}from"./chunk-BKM2LWU2.js";import{a as R,b as y,c as T,d as m,e as A,f as b,g as r}from"./chunk-56PAQAX5.js";import{b as x}from"./chunk-5EOX4MEY.js";import{a as E}from"./chunk-RZ4F3BHX.js";import{a as g,j as v}from"./chunk-7F2ZV46B.js";import{platform as X,arch as Y}from"os";import P from"fs";import M from"fs";import D from"path";var V=1e3,d=0,j=new Set([130,3]),a=class t{ids;logger;opts;ended=!1;createdAt=Date.now();errorState;constructor(e,n={emitted:!1}){this.ids=e.envelope,this.logger=e.logger,this.opts=e,this.errorState=n}get enabled(){return this.logger!==null}event(e,n={}){if(!this.logger)return;e==="ASR_ERROR"&&(this.errorState.emitted=!0);let i=m(this.ids,e,n);this.logger.log(R[e],e,e,C(i))}error(e,n={}){this.logger&&(this.logger.escalate(d),this.event("ASR_ERROR",{...n,error_code:e}))}child(e,n){return new t({...this.opts,envelope:{...this.ids,operation_id:n,parent_operation_id:this.ids.operation_id,verb:"design"}},this.errorState)}async lateBindContext(e){if(!(!this.logger||this.ids.context_instance_id))try{let{ensureStoreIds:n}=await import("./store-id-EOSGEKVK.js"),{ids:i,cloned:s}=n(e);this.ids.context_lineage_id=i.context_lineage_id,this.ids.context_instance_id=i.context_instance_id,s&&this.event("ASR_CONTEXT_CLONED")}catch{}}agentSession(e){this.ids.agent_session_id=e}spawnEnv(){if(!this.opts.telemetryEnabled)return{};let e={TESTMUAI_USER_SESSION_ID:this.ids.session_id,TESTMUAI_OPERATION_ID:this.ids.operation_id,TESTMUAI_CLIENT_VERSION:this.opts.clientVersion,TESTMUAI_TELEMETRY_PROXY_URL:this.opts.proxyUrl};return this.ids.context_instance_id&&(e.TESTMUAI_CONTEXT_INSTANCE_ID=this.ids.context_instance_id),e}traceTee(){return e=>{if(!this.logger)return;let n=typeof e.kind=="string"?e.kind.slice(0,64):"trace",i={...C(m(this.ids,"ASR_CMD_START",{})),trace_kind:n};typeof e.code=="string"&&(i.trace_code=e.code.slice(0,64)),delete i.event,this.logger.logStep(d,`trace_${n}`,n,i)}}wireTrace(e,n,i){if(!this.logger)return;i&&this.agentSession(i);let s=n&&typeof n=="object"?n:{};switch(e){case"spawn":this.event("ASR_AGENT_SPAWN",{tier:s.tier});break;case"session_paused":this.event("ASR_SESSION_PAUSED",s);break;case"commit":this.event("ASR_COMMIT",s);break;default:this.traceTee()({kind:e,code:typeof s.code=="string"?s.code:void 0})}}banner(){return`session: ${this.ids.session_id}`}supportFooter(){return`if this keeps failing, share this id with support: ${this.ids.session_id}`}async end(e){if(!this.ended){if(this.ended=!0,e.duration_ms===void 0&&(e={...e,duration_ms:Date.now()-this.createdAt}),this.logger)if(e.exit_code===0?this.logger.discardSteps(d):this.logger.escalate(d),e.exit_code>0&&!j.has(e.exit_code)&&!this.errorState.emitted&&this.event("ASR_ERROR",{error_code:e.exit_code===2?"usage_exit_unattributed":`exit_${e.exit_code}_unattributed`,exit_code:e.exit_code}),this.event("ASR_CMD_END",e),this.opts.longSession)await this.logger.shutdown();else{let n=await this.logger.flushOnce(V);(n==="failed"||n==="timeout")&&A(this.logger.drainBuffer())}this.logger&&this.writeManifestLine(e.exit_code),r(null)}}writeManifestLine(e){try{let n=x(this.ids.context_instance_id??null);M.mkdirSync(D.dirname(n),{recursive:!0});let i={ts:new Date().toISOString(),session_id:this.ids.session_id,operation_id:this.ids.operation_id,agent_session_id:this.ids.agent_session_id,verb:this.ids.verb,mode:this.ids.mode,exit_code:e};M.appendFileSync(n,JSON.stringify(i)+`
|
|
3
3
|
`,{flag:"a",mode:384})}catch{}}};function C(t){let e={event:t.event,session_id:t.session_id,operation_id:t.operation_id,verb:t.verb,mode:t.mode,component:t.component,seq:t.seq,context_lineage_id:t.context_lineage_id,context_instance_id:t.context_instance_id};t.parent_operation_id&&(e.parent_operation_id=t.parent_operation_id),t.agent_session_id&&(e.agent_session_id=t.agent_session_id);for(let[n,i]of Object.entries(t.context))e[n]=i;return e}var u=process.env.KANE_TELEMETRY_URL||v;function B(){return process.env.TESTMUAI_BASE_URL?"custom":process.env.TESTMUAI_ENV==="stage"?"stage":"prod"}function _e(t){let e=process.env.KANE_TELEMETRY!=="0"&&(!process.env.VITEST||process.env.KANE_TELEMETRY==="1"),n=t.env??B(),i=null;if(t.resumeSid&&t.contextRoot)try{let o=L(t.contextRoot,t.resumeSid);o?.user_session_id&&(i=o.user_session_id)}catch{}if(!i&&t.applyPlanPath)try{let o=JSON.parse(P.readFileSync(t.applyPlanPath,"utf8"));o.telemetry?.user_session_id&&(i=o.telemetry.user_session_id)}catch{}let s=i!==null;i||(i=y());let l=null,c=null,f=!1;if(t.contextRoot&&P.existsSync(t.contextRoot))if(t.write&&e){let o=k(t.contextRoot);l=o.ids.context_lineage_id,c=o.ids.context_instance_id,f=o.cloned}else{let o=N(t.contextRoot);l=o?.context_lineage_id??null,c=o?.context_instance_id??null}let h={session_id:i,operation_id:T(),context_lineage_id:l,context_instance_id:c,verb:t.verb,mode:t.mode,component:"kane-cli"},_=null;if(e){let o=I(n),S={org_id:o.org_id??"",user_id:o.user_id??"",machine_id:o.machine_id,email:null,email_domain:"",user_type:o.user_type??"unknown",env:o.env,plan:o.plan??"unknown"},U=t.mode==="interactive"||t.mode==="cli"?"cli":"agent";_=new w({proxyUrl:u,sessionId:i,identity:S,device:{cli_version:g,platform:X(),arch:Y(),host_agent:O(),invocation_mode:U},getToken:async()=>null}),t.longSession&&_.start()}let p=new a({envelope:h,logger:_,longSession:!!t.longSession,proxyUrl:u,clientVersion:`kane-cli/${g}`,telemetryEnabled:e});return e&&(r(h),p.event("ASR_CMD_START",{resumed:s,applied_plan:!!t.applyPlanPath}),f&&p.event("ASR_CONTEXT_CLONED"),b(async o=>{try{return(await E(u,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)})).ok}catch{return!1}}).catch(()=>{})),p}export{B as a,_e as b};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{d as ae,e as ue}from"./chunk-AXTPNZPX.js";import{a as oe}from"./chunk-L2TV4G56.js";import{b as K,d as se}from"./chunk-6KPPGMO2.js";import{d as ie}from"./chunk-NVGBE2DR.js";var ge=new Set(["approve","edit","reject"]);function pe(s,t){return`chatop:${t}:${s.target??"new"}:${s.op}:${s.seq}`}function me(s,t,y,k){let c=pe(s,t),h=s.payload;switch(s.op){case"approve":return{kind:"approve",target:s.target,expectedCid:s.expected_cid,eventId:c};case"edit":{let{reason:o,...v}=h;return{kind:"edit",target:s.target,expectedCid:s.expected_cid,edit:v,reason:o,eventId:c}}case"enhance":return{kind:"enhance",target:s.target,expectedCid:s.expected_cid,edges:h.edges??[],eventId:c};case"reject":return{kind:"reject",target:s.target,expectedCid:s.expected_cid,reason:h.reason??"",redirectTo:h.redirect_to,eventId:c};case"add":{let o=h.proposal_item??{},v=String(o.label??"");if(!y.mint_gate.includes(v))throw new Error(`GATED_LABEL: cannot mint "${v}" (gate: ${y.mint_gate.join(", ")})`);let l=o.cite??{},m=o.conv_source_id??k;if(!m||typeof l.turn!="number"||!l.quote)throw new Error("INVALID_ADD: a chat add requires a conversation cite {turn, quote} and conv_source_id");let _=o.content,C=_&&typeof _=="object"&&!Array.isArray(_)&&Object.keys(_).length>0?_:null,w=new Set(["label","cite","conv_source_id","content","rationale","edges"]),x=C??Object.fromEntries(Object.entries(o).filter(([D])=>!w.has(D)));return{kind:"add",label:v,content:x,cite:{turn:l.turn,quote:l.quote},convSourceId:m,rationale:o.rationale,eventId:c}}}}function ce(s,t,y={}){let k=y.turn??0,c=[],h=[];for(let l of s)(l.op==="add"||l.op==="enhance")&&h.push(l);let o=new Map;for(let l of s){if(!ge.has(l.op)||!l.target)continue;let m=o.get(l.target)??[];m.push(l),o.set(l.target,m)}for(let[l,m]of o){let _=Math.max(...m.map(w=>w.seq)),C=m.filter(w=>w.seq===_);if(C.length>1){c.push({target:l,seq:_,kinds:C.map(w=>w.op)});continue}h.push(C[0])}return{chatOps:h.sort((l,m)=>l.seq-m.seq).map(l=>me(l,k,t,y.convSourceId)),ambiguous:c}}function fe(s){let t=[];return s.questions.forEach((y,k)=>{if(s.resolution[k])return;let c=y.recommended_index!=null?y.options[y.recommended_index]?.label:void 0;c!=null&&t.push(y.risk==="high"?`${c} \u203C`:c)}),t.length>3?`${t.slice(0,3).join(" \xB7 ")} \xB7 +${t.length-3} more`:t.join(" \xB7 ")}function le(s){let t=s.text.replace(/\?+\s*$/,"");return t.length<=36?t:`${t.slice(0,33)}\u2026`}function he(s){return s.use_cases??[]}var ke={acs:"acceptance criteria",scenarios:"scenarios",exercises:"exercises",tests:"tests",gaps:"gaps"};function be(s){let t=[],y=[],k=(o,v)=>{v.length!==0&&(y.push(o),t.push(...v))},c=o=>typeof o=="string"&&/^[a-z]{1,4}\d{1,4}$/i.test(o)?o:null,h=o=>{let v=c(o.automates)??"1 scenario",l=o.verifies??[],m=l.map(c).filter(w=>w!==null).slice(0,2),_=l.length-m.length,C=m.length?`${m.join(" ")}${_>0?` +${_}`:""}`:`${l.length} ACs`;return`covers ${v} \xB7 verifies ${C}`};return k("acs",(s.acs??[]).map(o=>({temp_ref:o.temp_ref,title:o.text,kind:"ac",badge:String(o.kind),extra:{...o.expected_answer?{expects:`${String(o.expected_answer.operator??"")} \xB7 ${String(o.expected_answer.operand??"")}`}:{},"scoped to":o.scoped_to??"(use-case)"}}))),k("scenarios",(s.scenarios??[]).map(o=>({temp_ref:o.temp_ref,title:o.title,kind:"scenario",badge:o.case_type,why:o.intent,depends_on_hint:o.depends_on??[],extra:{technique:o.technique_notes}}))),k("exercises",(s.exercises??[]).map(o=>({temp_ref:c(o.scenario)??"wiring",title:`${c(o.scenario)??"scenario"} exercises ${c(o.ac)??"1 AC"}`,kind:"exercise",badge:"wires",why:o.rationale}))),k("tests",(s.tests??[]).map(o=>({temp_ref:o.temp_ref,title:o.title,kind:"test",why:h(o),depends_on_hint:o.reuses??[],extra:{automates:String(o.automates??"?"),verifies:(o.verifies??[]).join(", "),check:o.check?`${String(o.check.kind)} vs ${String(o.check.verified_against)}`:"?"}}))),k("gaps",(s.gaps??[]).map(o=>({temp_ref:o.temp_ref??o.ref??"?",title:String(o.question?.header??o.kind),kind:"gap",badge:o.kind,why:o.risk_rationale}))),{items:t,heading:y.join(" + ")||"design"}}function Se(s={}){let t={turns:[],thinking:ae(),pending:null,confirm:null,status:"idle",ledger:[],activeTurn:null,stream:null,checkpoint:!1},y=e=>{let n=[],r=e.minted.map(a=>a.slug).filter(Boolean);r.length&&n.push(`added ${r.join(", ")}`);let i=e.applied.length-e.minted.length;return i>0&&n.push(`${i} change${i===1?"":"s"} applied`),e.staleDelta.length&&n.push(`stales ${e.staleDelta.length}`),n.join(" \xB7 ")||"no changes"},k=[];s.onRender&&k.push(s.onRender);let c=0,h=0,o=null,v=null,l=null,m=[],_=0,C=e=>{if(!(!l||!s.contextDir||!e.trim()))try{let n=s.refreshGraph?.()??s.graph;if(!n)return;se({contextDir:s.contextDir,graph:n,sourceId:l,text:e,by:s.by??{kind:"human",id:"owner"}})}catch{}},w=e=>{if(!l||!s.contextDir)return;let n=s.refreshGraph?.()??s.graph,r=n?.heads.get(l),i=n?.convChains.get(l);if(!n||typeof r!="string"||!i)return;let a=n.getNode(r)?.content?.blob,u=typeof a=="string"?ie(s.contextDir,a)?.toString("utf8")??"":"";if(u)for(let f of e){if(f.kind!=="add"||f.convSourceId!==l)continue;let F=K(u,f.cite.turn);if(!(F!==null&&F.includes(f.cite.quote)))for(let $=i.turns;$>=1;$--){let z=K(u,$);if(z!==null&&z.includes(f.cite.quote)){f.cite={...f.cite,turn:$};break}}}},x={startedAt:null,thinkMs:0,toolCalls:0,tools:new Map},D=()=>{x.startedAt??=Date.now()},A=()=>{if(x.toolCalls>0){let e=x.startedAt!=null?Math.max(1,Math.round((Date.now()-x.startedAt)/1e3)):Math.max(1,Math.round(x.thinkMs/1e3));g({kind:"worked",durS:e,toolCalls:x.toolCalls,tools:[...x.tools.entries()].map(([n,r])=>({name:n,n:r}))})}x.startedAt=null,x.thinkMs=0,x.toolCalls=0,x.tools.clear()},I=null,G=new Map,V=e=>JSON.stringify([e.id,e.text,e.options.map(n=>n.label)]),q=null,J=new Map,U=new Map,Y=null,p=()=>{j&&(clearTimeout(j),j=null);for(let e of k)e()},j=null,X=()=>{j||(j=setTimeout(()=>{j=null;for(let e of k)e()},80))},B=0,g=e=>{e.kind==="childClose"&&B>0&&(B-=1),B>0&&e.kind!=="childOpen"&&e.kind!=="childBack"&&(e.era=B),e.kind==="childOpen"&&(B+=1),t.ledger.push(e)},E=null,W=!1,L=(e=!1)=>{E?g({kind:"agent",text:E}):e&&W&&g({kind:"note",text:'chat to refine ("looks good" approves; /done finishes)'}),E=null,W=!1},de=()=>{E=null,W=!1},P=null,H=e=>{if(P){if(e)for(let n of P.items){let r=e.get(n.temp_ref);r&&(n.logical_id=r)}g({kind:"turn",...P}),P=null}},M=()=>{H(),t.activeTurn&&(t.activeTurn=null)},Z=(e,n)=>n.choice||(n.selected_index!=null?e.options[n.selected_index]?.label??"?":"?"),N=()=>{let e=t.pending;if(!e)return;if(!e.resolution.every(Boolean)){e.cursor=e.resolution.findIndex(i=>i===null);return}let n=e.questions.map((i,a)=>{let u=e.resolution[a];return u.form==="deferred"?{id:i.id,selected_index:null,free_text:null}:{id:i.id,selected_index:u.selected_index,free_text:u.free_text}});t.pending=null,t.status=t.status==="pausing"?"pausing":"streaming",t.status==="streaming"&&(t.busySince=Date.now());let r=I;I=null,r?.(n)},R=(e,n)=>{let r=t.pending,i=r.questions[e],a=r.resolution[e];r.resolution[e]=n;let u=le(i);a?g({kind:"answer",receipt:{form:"changed",qNum:e+1,stub:u,choice:Z(i,n),prev:a.choice}}):n.form==="deferred"?g({kind:"answer",receipt:{form:"deferred",qNum:e+1,stub:u}}):g({kind:"answer",receipt:{form:n.form,qNum:e+1,stub:u,choice:Z(i,n)}})},ee=()=>{let e=t.pending;e&&(e.questions.forEach((n,r)=>{e.resolution[r]||R(r,{form:"deferred",selected_index:null,free_text:null,choice:""})}),N())},Q=new Map,te=e=>{Q.clear();let n={high:0,med:1,low:2};return e=e.map((r,i)=>({q:r,i})).sort((r,i)=>(n[r.q.risk]??3)-(n[i.q.risk]??3)||r.i-i.i).map(({q:r})=>r),{questions:e,cursor:0,resolution:e.map(()=>null)}};return{state:t,explainLines(e){if(!s.explain||!s.graph||s.contextDir===void 0)return null;let n=s.explain(s.contextDir,s.graph,e);return n.target?[`${n.target.label} ${n.target.slug??n.target.cid.slice(0,19)}:`,...n.entries.map(r=>` [${r.kind}] ${r.rationale??r.detail}`)]:null},explainRef(e){if(!s.explain||!s.graph||s.contextDir===void 0){g({kind:"note",text:"explain isn't available here"}),p();return}let n=s.explain(s.contextDir,s.graph,e),r=n.target?[`${n.target.label} ${n.target.slug??n.target.cid.slice(0,19)}:`,...n.entries.map(i=>` [${i.kind}] ${i.rationale??i.detail}`)].join(`
|
|
3
|
+
`):`unknown ref: ${e}`;g({kind:"note",text:r}),p()},subscribe(e){return k.push(e),()=>{let n=k.indexOf(e);n>=0&&k.splice(n,1)}},submit(e){if(t.confirm&&(t.confirm=null),!t.pending){if(!o){t.turns.push({role:"user",text:e}),g({kind:"user",text:e}),t.notice="the agent isn't running \u2014 nothing sent",p();return}for(t.notice=void 0,t.checkpoint=!1,L(),t.turns.push({role:"user",text:e}),g({kind:"user",text:e}),C(e),t.status="streaming",t.busySince=Date.now(),D(),t.error=void 0,h+=1;m.length>0;)h+=1,o({type:"user_message",message_id:`u${h}-receipt`,text:m.shift()});o({type:"user_message",message_id:`u${h}`,text:e}),p()}},attachSender(e){let n=o;return o=e,()=>{o=n}},attachOnCommitted(e){v=e},attachConversationSource(e){l=e},attachSession(e){s.session=e},holdReceipt(e){m.push(e),t.checkpoint=!0,p()},drainHeldReceipts(){return m.splice(0,m.length)},peekHeldReceipts(){return[...m]},submitAnswer(e,n){let r=t.pending,i=r?.questions[e],a=i?.options[n]?.label;!r||!i||a==null||(R(e,{form:"answered",selected_index:n,free_text:null,choice:a}),N(),p())},submitFreeText(e,n){let r=t.pending,i=r?.questions[e],a=n.trim();!r||!i||!a||(R(e,{form:"answered",selected_index:null,free_text:a,choice:a}),N(),p())},deferBatch(e){let n=t.pending;if(!n||!I)return;n.questions.forEach((i,a)=>{let u=n.resolution[a];u&&u.form==="answered"&&G.set(V(i),u)}),t.pending=null,t.status=t.status==="pausing"?"pausing":"streaming",t.status==="streaming"&&(t.busySince=Date.now()),g({kind:"note",text:`questions set aside \u2014 source ${e.source_id} landed; the agent reads it next`});let r=I;I=null,r({deferred:!0,ingested:e}),p()},submitAnswerWithText(e,n,r){let i=t.pending,a=i?.questions[e],u=a?.options[n]?.label;if(!i||!a||u==null)return;let f=r.trim();R(e,{form:"answered",selected_index:n,free_text:f||null,choice:f?`${u} \u2014 ${f}`:u}),N(),p()},toggleOption(e,n){let r=t.pending?.questions[e];if(!r||r.options[n]==null)return;let i=Q.get(e)??new Set;i.has(n)?i.delete(n):i.add(n),Q.set(e,i),p()},multiSelection(e){return[...Q.get(e)??[]].sort((n,r)=>n-r)},confirmMulti(e){let n=t.pending,r=n?.questions[e];if(!n||!r)return;let i=[...Q.get(e)??[]].sort((u,f)=>u-f).map(u=>r.options[u]?.label).filter(u=>u!=null);if(i.length===0)return;Q.delete(e);let a=i.join(", ");R(e,{form:"answered",selected_index:null,free_text:a,choice:a}),N(),p()},goWithRecommendations(){let e=t.pending;if(!e)return{picks:""};let n=fe(e),r=null;return e.questions.forEach((i,a)=>{if(e.resolution[a])return;let u=i.recommended_index,f=u!=null?i.options[u]?.label:void 0;if(f==null){r===null&&(r=a);return}R(a,{form:"assumed",selected_index:u,free_text:null,choice:f})}),r!==null?(e.cursor=r,p(),{blocked:r}):(N(),p(),{picks:n})},reopenQuestion(){let e=t.pending;if(!e)return;let n=e.cursor<0?e.questions.length:e.cursor;for(let r=n-1;r>=0;r--)if(e.resolution[r]){e.cursor=r,p();return}},continueParked(){if(o){for(t.checkpoint=!1,g({kind:"continued"});m.length>0;)h+=1,o({type:"user_message",message_id:`u${h}-receipt`,text:m.shift()});h+=1,o({type:"user_message",message_id:`u${h}`,text:"continue"}),t.status="streaming",t.busySince=Date.now(),D(),p()}},note(e){g({kind:"note",text:e}),p()},finalizeForExit(){M(),A(),L(),t.stream=null,p()},aliasOf(e){return U.get(e)},registerAliases(e){for(let n of e)U.set(n.ref,n.cid);H(new Map(e.filter(n=>n.id).map(n=>[n.ref,n.id]))),p()},setWorking(e){if(e!=null){if(t.status!=="idle"&&t.status!=="working")return;t.status==="idle"&&(t.busySince=Date.now()),D(),t.status="working",t.workingLabel=e}else{if(t.status!=="working")return;t.status="idle",t.workingLabel=void 0,t.busySince=void 0}p()},ledger(e){e.kind==="commit"&&H(),e.kind==="error"&&(M(),A(),L()),g(e),e.kind==="commit"&&(e.ok?L(!0):de()),p()},senderAlive(){return o!=null},completeSession(){ee(),o?.({type:"session_complete"}),t.status="idle",t.busySince=void 0,p()},requestPause(){ee(),t.status="pausing",t.busySince=void 0;let e=o;Promise.resolve().then(()=>e?.({type:"pause"})),p()},ask(e){t.pending=te(e),J=new Map(e.map((r,i)=>[r.id,i+1])),t.status="awaiting-input",t.busySince=void 0;let n=new Promise(r=>{I=r});if(G.size>0){let r=0;e.forEach((i,a)=>{let u=V(i),f=G.get(u);f&&(G.delete(u),R(a,{...f}),r+=1)}),r>0&&g({kind:"note",text:`your earlier answer${r>1?"s are":" is"} pre-filled \u2014 press enter to send, or pick a different answer`})}return p(),n},attachIngest(e){let n=q;return q=e,()=>{q===e&&(q=n)}},canIngest(){return q!==null},async ingestAttach(e){let n=q,r=e.trim();if(!n||!r)return;let i;try{i=await n(r)}catch(a){i={ok:!1,error:a instanceof Error?a.message:String(a)}}i.ok||(g({kind:"note",text:i.error??"the source could not be ingested"}),p())},noteCoercion(e,n){g({kind:"answer",receipt:{form:"assumed",qNum:J.get(e.id)??0,stub:le(e),choice:n,note:"your typed answer couldn't be used here"}}),p()},onAgentEvent(e){switch(e.type){case"reasoning_delta":case"reasoning_done":case"tool_activity":case"decision_activity":{let n=t.thinking;if(t.thinking=ue(n,e),t.thinking!==n&&(e.type==="reasoning_done"&&e.present?(D(),x.thinkMs+=e.took_ms):e.type==="tool_activity"&&e.status!=="started"&&(D(),x.toolCalls+=1,x.tools.set(e.name,(x.tools.get(e.name)??0)+1))),e.type==="reasoning_delta"){X();return}break}case"usage":t.credits={turn:e.credits,total:e.total_credits};break;case"text_delta":{let n=Y;if(n&&(e.turn_id<n.turn_id||e.turn_id===n.turn_id&&e.attempt<n.attempt))return;(!n||n.turn_id!==e.turn_id||n.attempt!==e.attempt)&&(Y={turn_id:e.turn_id,attempt:e.attempt},t.stream={text:""}),t.stream={text:(t.stream?.text??"")+e.text},X();return}case"progress":break;case"proposal":{c+=1,M(),t.stream=null,t.busySince=void 0,A();let n=he(e.proposal),r=s.dedupFlags?.(e.proposal);if(r)for(let i of n){let a=r.get(i.temp_ref);a&&(i.matches_existing=a)}t.turns.push({role:"agent",turnIndex:c,items:n,text:e.narrative}),E=e.narrative??null,W=!0,t.activeTurn={turnIndex:c,heading:"use-cases",items:n},P={turnIndex:c,heading:"use-cases",items:n},(t.status==="streaming"||t.status==="working")&&(t.status="idle"),t.workingLabel=void 0;break}case"design":{c+=1,M(),t.stream=null,t.busySince=void 0,A();let{items:n,heading:r}=be(e.design),i=e.design.phase==="wiring"?"acceptance criteria + exercises":r.split(" + ").map(a=>ke[a]??a).join(" + ");g({kind:"banner",text:`designing: ${i}`}),t.turns.push({role:"agent",turnIndex:c,items:n,itemsHeading:r,text:e.narrative}),E=e.narrative??null,W=!0,t.activeTurn={turnIndex:c,heading:r,items:n},P={turnIndex:c,heading:r,items:n},(t.status==="streaming"||t.status==="working")&&(t.status="idle"),t.workingLabel=void 0;break}case"ask_user":A(),t.pending=te(e.questions),t.status="awaiting-input",t.busySince=void 0;break;case"chat_ops":{c+=1,M(),A(),t.stream=null,(t.status==="streaming"||t.status==="working")&&(t.status="idle",t.busySince=void 0,t.workingLabel=void 0);let n=e.chat_ops??e,r=Array.isArray(n.ops)?n.ops:[],i=n.text??e.text??"",a=s.refreshGraph?.()??s.graph,u=d=>U.get(d)??d,f=r.map(d=>{if(!d.target)return d;let b=u(d.target),S=d.expected_cid;if(S==null&&a){let re=a.resolve(b);re&&(S=a.tipOf(re.cid))}let O=d.payload?.redirect_to,T=O&&u(O);return b===d.target&&S===d.expected_cid&&T===O?d:{...d,target:b,expected_cid:S,...T!==O?{payload:{...d.payload,redirect_to:T}}:{}}}),F;try{if(!Array.isArray(n.ops))throw new Error("the agent sent an unreadable change set (no ops array) \u2014 say it again in different words");F=ce(f,s.descriptor??{mint_gate:[]},{turn:c,...l?{convSourceId:l}:{}})}catch(d){t.error=d instanceof Error?d.message:String(d),t.turns.push({role:"agent",turnIndex:c,text:i,narration:t.error}),i&&g({kind:"agent",text:i}),g({kind:"error",title:t.error,detail:[]});break}let{chatOps:$,ambiguous:z}=F;if(z.length>0){let d=z[0];t.confirm={kind:"ambiguity-confirm",prompt:`did you mean edit or ${d.kinds.filter(b=>b!=="edit").join("/")} on ${d.target}?`},t.turns.push({role:"agent",turnIndex:c,text:i}),i&&g({kind:"agent",text:i});break}if(w($),s.commitChatTurn&&$.length>0){let d=s.commitChatTurn({contextDir:s.contextDir??"",graph:s.refreshGraph?.()??s.graph,ops:$,by:s.by??{kind:"human",id:"owner"},...s.descriptor?.mint_gate?{mintable:s.descriptor.mint_gate}:{},...s.session?.state?.sid?{sid:s.session.state.sid}:{}});if(d.errors)t.error=d.errors.map(b=>b.detail).join("; "),t.turns.push({role:"agent",turnIndex:c,text:i}),g({kind:"commit",ok:!1,line:"commit failed \u2014 nothing landed",warnings:d.errors.map(b=>`${b.code}: ${b.detail}`)}),m.push(["COMMIT FAILED (chat turn) \u2014 nothing landed; do not assume any of your last ops applied.",...d.errors.map(b=>`- ${b.code}: ${b.detail}`),...d.errors.some(b=>b.code==="UNKNOWN_FIELD")?["If you were changing citations or matched-existing content, that is proposal territory (approve/re-propose) \u2014 a chat edit can only replace a node's own schema fields."]:[]].join(`
|
|
4
|
+
`)),i&&g({kind:"agent",text:i});else{d.applied.length>0&&s.session?.markApplied(d.applied);let b=y(d);t.turns.push({role:"agent",turnIndex:c,text:i,narration:b}),g({kind:"commit",ok:!0,line:b});let S=s.refreshGraph?.();if(S&&v&&v(S),S)try{_+=1;let ne=s.descriptor?.mint_gate?.includes("usecase")?"extract":"design",O=oe({verb:ne,commitN:_,phase:"chat",committed:d.minted.map(T=>({cid:T.cid,...T.slug?{logical_id:T.slug}:{}}))},S);m.push(O.text)}catch{}i&&g({kind:"agent",text:i})}}else t.turns.push({role:"agent",turnIndex:c,text:i}),i&&g({kind:"agent",text:i});C(i);break}case"done":case"session_complete":M(),A(),L(),t.status="idle",t.busySince=void 0,o=null;break;case"error":M(),A(),L(),t.stream=null,t.status="idle",t.busySince=void 0,t.error=e.message,o=null,g({kind:"error",title:e.message,detail:[]});break;case"session_paused":break;default:break}p()}}}export{fe as a,le as b,Se as c};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{c as k}from"./chunk-RFHMDQXZ.js";import{a as b}from"./chunk-
|
|
2
|
+
import{c as k}from"./chunk-RFHMDQXZ.js";import{a as b}from"./chunk-J7KT44IC.js";import{a as C}from"./chunk-PXCMEI73.js";import{q as m,r as u,s as f,t as x,u as y}from"./chunk-7F2ZV46B.js";import{createServer as S}from"http";import{randomBytes as A}from"crypto";import{URL as L}from"url";var P=class{profile;environment;creds;oauth;constructor(r="default",o="prod",e){this.profile=r,this.environment=o,this.creds=e??new C,this.oauth=new b(o)}async login(){let{server:r,port:o}=await this.startCallbackServer(),e=y(o);try{let t=this.creds.loadClient(this.profile,this.environment),i=t?.redirect_uris;(!t||!i?.includes(e))&&(t=await this.oauth.registerClient(e),this.creds.saveClient(this.profile,this.environment,t));let c=t.client_id,[h,d]=b.generatePkce(),a=A(32).toString("hex"),n=this.oauth.buildAuthorizationUrl(c,d,a,e),l=await this.waitForCallback(r,o,n,a);if(!l)throw new Error("Login cancelled or timed out");let p=await this.oauth.exchangeCode(l,c,h,e),g={access_token:p.access_token,refresh_token:p.refresh_token,expires_at:Math.floor(Date.now()/1e3)+p.expires_in,scope:p.scope??"*"};return this.creds.saveCredentials(this.profile,this.environment,g),this.creds.setActiveProfile(this.profile),g}catch(t){throw r.close(),t}}startCallbackServer(){return new Promise((r,o)=>{let e=u,t=()=>{let i=S();i.on("error",c=>{c.code==="EADDRINUSE"&&e<f?(e++,t()):o(new Error(`Failed to start callback server: ${c.message}. Ports ${u}-${f} are all in use.`))}),i.listen(e,m,()=>{r({server:i,port:e})})};t()})}waitForCallback(r,o,e,t){return new Promise(i=>{let c=!1,h=setTimeout(()=>d(null),12e4),d=a=>{c||(c=!0,clearTimeout(h),r.close(),i(a))};r.on("request",(a,n)=>{let l=new L(a.url??"/",`http://${m}:${o}`);if(l.pathname!==x){n.writeHead(404),n.end();return}let p=l.searchParams.get("state"),g=l.searchParams.get("code");if(l.searchParams.get("error")){n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Login failed",message:"We couldn't complete the sign-in. You can close this tab and try again from your terminal."})),d(null);return}if(p!==t){n.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"error",title:"Invalid state",message:"The sign-in response didn't match this session. Please return to your terminal and try again."})),d(null);return}n.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),n.end(v({state:"success",title:"You're signed in",message:"Head back to your terminal \u2014 KaneAI is ready when you are.",autoClose:!0})),d(g)}),k(e).catch(a=>{let n=a instanceof Error?a.message:String(a);process.stderr.write(`[auth] Could not open browser: ${n}
|
|
3
3
|
Please open this URL manually: ${e}
|
|
4
4
|
`)})})}};function v(s){let r=s.state==="success",o=r?"#22c55e":"#ef4444",e=r?"rgba(34, 197, 94, 0.12)":"rgba(239, 68, 68, 0.12)",t=r?'<svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7"/></svg>':'<svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg>',i=s.autoClose?"<script>setTimeout(function(){try{window.close();}catch(e){}}, 1500);</script>":"";return`<!doctype html>
|
|
5
5
|
<html lang="en">
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{x as s}from"./chunk-
|
|
2
|
+
import{x as s}from"./chunk-7F2ZV46B.js";function n(r="prod"){let e=s[r];return r!=="stage"?e:{authBaseUrl:process.env.KANE_STAGE_AUTH_URL??e.authBaseUrl,consentUrl:process.env.KANE_STAGE_CONSENT_URL??e.consentUrl,controllerBaseUrl:process.env.TESTMUAI_BASE_URL??e.controllerBaseUrl,tmsBaseUrl:process.env.KANE_STAGE_TMS_URL??e.tmsBaseUrl,testGeneratorBaseUrl:process.env.KANE_STAGE_TCG_URL??e.testGeneratorBaseUrl,secretsBaseUrl:process.env.KANE_STAGE_SECRETS_URL??e.secretsBaseUrl,testManagerUiUrl:process.env.KANE_STAGE_TEST_MANAGER_UI_URL??e.testManagerUiUrl,shareApiBaseUrl:process.env.KANE_STAGE_SHARE_API_URL??e.shareApiBaseUrl,v16ServerHost:process.env.KANE_STAGE_V16_SERVER_HOST??e.v16ServerHost,evidenceViewerUrl:process.env.KANE_STAGE_EVIDENCE_VIEWER_URL??e.evidenceViewerUrl,mediaArtefactsHost:process.env.KANE_STAGE_MEDIA_ARTEFACTS_HOST??e.mediaArtefactsHost,mobileAppBaseUrl:process.env.KANE_STAGE_MOBILE_APP_URL??e.mobileAppBaseUrl}}export{n as a};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{c as u,d as p}from"./chunk-
|
|
2
|
+
import{c as u,d as p}from"./chunk-WQPQNL4S.js";import{spawn as h}from"child_process";var k=new Set(["progress","ask_user","graph_query","ingest_request","proposal","design","error","done","reasoning_delta","reasoning_done","tool_activity","decision_activity","text_delta","usage","receipt","chat_ops","session_paused","session_complete","state_checkpoint"]);function v(g,n={}){let a=n.spawnCmd!==void 0?n.spawnCmd:u();if(!a)throw new Error("assurance agent not found \u2014 your platform package may be missing; reinstall kane-cli (npm i -g @testmuai/kane-cli)");let f=g.source.images?.length??0;a.tier==="dev-python"&&f>0&&n.onWarn?.("warn: development agent in use \u2014 if image citations are missing, update the agent package");let t=h(a.cmd,a.args,{stdio:["pipe","pipe","pipe"],env:p(g.session_id,n.auth)});if(t.stdin.write(JSON.stringify(g)+`
|
|
3
3
|
`),n.onStderr){let e="";t.stderr.on("data",r=>{e+=r.toString("utf8");let i;for(;(i=e.indexOf(`
|
|
4
4
|
`))>=0;){let o=e.slice(0,i);e=e.slice(i+1),o.trim()&&n.onStderr(o)}})}let d=new Promise(e=>{t.on("exit",(r,i)=>e({code:r,signal:i}))});async function*m(){let e="",r=!1;for await(let i of t.stdout){e+=i.toString("utf8");let o;for(;(o=e.indexOf(`
|
|
5
5
|
`))>=0;){let l=e.slice(0,o).trim();if(e=e.slice(o+1),!l)continue;let c;try{c=JSON.parse(l)}catch{n.onWarn?.(`agent: skipping malformed line: ${l.slice(0,120)}`);continue}let s=c;if(!s||typeof s!="object"||!k.has(s.type)){n.onWarn?.(`agent: skipping unknown event type "${s&&typeof s=="object"?String(s.type??"?"):"?"}"`);continue}if(yield s,s.type==="done"){r=!0;break}}if(r)break}await d.catch(()=>{})}return{events:m(),send:e=>{t.stdin&&!t.stdin.destroyed&&t.stdin.write(JSON.stringify(e)+`
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as $}from"./chunk-MMBBQ4OZ.js";import{j as h}from"./chunk-IUEEFGEW.js";import{a as w}from"./chunk-RZ4F3BHX.js";import{c as v}from"./chunk-7F2ZV46B.js";import{spawn as V,spawnSync as _}from"child_process";import{createServer as K}from"net";import{mkdirSync as g,openSync as W,readFileSync as I,renameSync as j,rmSync as x,statSync as Y,writeFileSync as M}from"fs";import{readFile as q}from"fs/promises";import{dirname as l,join as y}from"path";var G=[4723,4724,4725,4726,4727,4728,4729,4730],X={emulator:4750,simulator:4790},z=40,E=2e3,D=3e4,T=500,Ce=["emulator","simulator"];function Q(e){return y(v,"mobile",`appium-server-${e}.log`)}function m(){return y(v,"mobile","appium-servers.json")}function Z(){return y(v,"mobile","appium-servers.lock")}var ee=1e4,re=50;function C(e){let r=Z();try{g(l(r),{recursive:!0})}catch{return e()}let n=!1;for(let o=0;o<re;o++)try{g(r),n=!0;break}catch{try{Date.now()-Y(r).mtimeMs>ee&&x(r,{recursive:!0,force:!0})}catch{}ne(10)}try{return e()}finally{if(n)try{x(r,{recursive:!0,force:!0})}catch{}}}function ne(e){try{Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,e)}catch{}}function te(){try{let e=JSON.parse(I(m(),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}function oe(e){let r=m();g(l(r),{recursive:!0});let n=`${r}.tmp`;M(n,JSON.stringify(e,null,2)),j(n,r)}function se(e,r,n){return`Another mobile session is already running${n?` on ${n}`:""}. Wait for it to finish, or close the terminal running it.`}var A=class extends Error{constructor(n,o){super(n);this.port=o;this.name="DeviceBusyError"}};function ie(e){return w(e,{signal:AbortSignal.timeout(E)}).then(r=>r.ok,()=>!1)}async function ae(e,r){try{return(await w(`http://127.0.0.1:${e}/session/${r}`,{method:"DELETE",signal:AbortSignal.timeout(E)})).ok}catch{return!1}}function R(e){let r=e?.value;return Array.isArray(r)?r.map(n=>{let o=n??{},t=o.capabilities??o;return{...typeof o.id=="string"?{id:o.id}:{},caps:t}}):[]}async function ue(e){try{let r=await w(`http://127.0.0.1:${e}/sessions`,{signal:AbortSignal.timeout(E)});return r.ok?R(await r.json()):[]}catch{return[]}}var ce=["udid","appium:udid","deviceUDID","appium:deviceUDID","deviceName","appium:deviceName"];function L(){let e=r=>{try{let n=_("curl",["-s","--noproxy","*","--max-time","2",...r],{encoding:"utf8",timeout:5e3});return{ok:n.status===0,stdout:n.stdout??""}}catch{return{ok:!1,stdout:""}}};return{readState:()=>{try{let r=JSON.parse(I(m(),"utf8"));return Array.isArray(r)?r:[]}catch{return[]}},alive:b,getJson:r=>{let n=e([r]);if(n.ok)try{return JSON.parse(n.stdout)}catch{return}},del:r=>{let n=e(["-o","/dev/null","-w","%{http_code}","-X","DELETE",r]);return n.ok&&/^2\d\d$/.test(n.stdout.trim())}}}function Le(e,r={}){let n={...L(),...r},o=0;try{for(let t of n.readState()){if(!n.alive(t.pid))continue;let i=R(n.getJson(`http://127.0.0.1:${t.port}/sessions`));for(let s of i)s.id&&de(s.caps,e.udid,e.displayName)&&n.del(`http://127.0.0.1:${t.port}/session/${s.id}`)&&(o+=1)}}catch{}return o}function de(e,r,n){let o=[r,n].filter(t=>!!t).map(t=>t.toLowerCase());for(let t of ce){let i=e[t];if(typeof i=="string"&&o.includes(i.toLowerCase()))return!0}return!1}function pe(e,r,n){let o=W(n.logPath,"a"),t=V(e,r,{stdio:["ignore",o,o],detached:!0,env:{...process.env,...n.env}});return t.unref(),t.pid}async function le(e,r){for(let n=e;n<e+r;n++)if(await new Promise(t=>{let i=K();i.once("error",()=>t(!1)),i.once("listening",()=>i.close(()=>t(!0))),i.listen(n)}))return n;throw new Error(`No free port for the managed Appium server in ${e}-${e+r-1}.`)}function b(e){try{return process.kill(e,0),!0}catch{return!1}}function P(e){try{let r=_("ps",["-o","comm=","-p",String(e)],{encoding:"utf8",timeout:2e3});if(r.status!==0)return!1;let n=r.stdout.trim().toLowerCase();return n===""?!0:n.includes("node")||n.includes("kane")}catch{return!0}}function k(e){try{process.kill(e)}catch{}}async function me(){try{let e=JSON.parse(await q(m(),"utf8"));return Array.isArray(e)?e:[]}catch{return[]}}async function fe(e){let r=process.pid,n=e.filter(o=>o.owner===r);C(()=>{let o=[];for(let t of te())t.owner!==r&&(Se(t)?o.push(t):b(t.pid)&&k(t.pid));oe([...o,...n])})}function Se(e){return e.owner===void 0?!1:b(e.owner)&&P(e.owner)}function ve(){return{probe:ie,sessions:ue,deleteSession:ae,spawn:pe,freePort:le,alive:b,kill:k,readState:me,writeState:fe,owner:process.pid,depsEnv:e=>h().environment(e),bundleVersion:async e=>(await h().status(e)).version,nodeBinary:process.execPath,env:process.env,os:process.platform,now:()=>Date.now(),sleep:e=>new Promise(r=>setTimeout(r,e))}}function we(e,r,n){if(!e.platformToolsDir)return{};let o=n==="win32"?";":":",t=$(r),i=t?.root??l(e.platformToolsDir),s=t?.platformToolsDir??e.platformToolsDir;return{ANDROID_HOME:i,ANDROID_SDK_ROOT:i,PATH:r.PATH?`${s}${o}${r.PATH}`:s}}async function ge(e){let r=await e.readState(),n=[],o=[];for(let t of r)t.owner!==void 0&&e.alive(t.owner)&&(e.ownerIsOurs??P)(t.owner)?n.push(t):o.push(t);for(let t of o){let i=e.ownerIsOurs??P;e.alive(t.pid)&&i(t.pid)&&e.kill(t.pid)}return o.length>0&&await e.writeState(n),n}async function Je(e,r={}){if(r.appiumUrl)return{result:"external",url:r.appiumUrl};let n={...ve(),...r.deps},o=await ge(n),t=o.filter(a=>a.owner===n.owner),i=new Set(t.map(a=>a.port)),s=new Set(o.map(a=>a.port));if(r.device){let a=await ye(n,s,i,e);if(a!==null)throw new A(se(r.device,a.port,a.device),a.port)}let c=await n.bundleVersion(e),u=t.find(a=>a.deviceClass===e&&(a.bundleVersion??c)===c);if(u&&await n.probe(`http://127.0.0.1:${u.port}/status`))return{result:"reused",url:`http://127.0.0.1:${u.port}`};for(let a of t.filter(S=>S.deviceClass===e&&S!==u))n.kill(a.pid);u&&n.kill(u.pid);let d=await n.depsEnv(e);if(!d.appiumHome)throw new Error(`The managed dependencies for the ${e} class are not installed.
|
|
3
|
+
Run \`kane-cli doctor --target ${e} --install\` to install them, or pass --appium-url for an external server.`);let p=await n.freePort(X[e],z),O=`http://127.0.0.1:${p}`,J=l(d.appiumHome),U=y(J,"appium","node_modules","appium","index.js"),N=Q(e);r.onProgress?.(`starting the managed Appium server (${e}, port ${p})\u2026`);let f=n.spawn(n.nodeBinary,[U,"--port",String(p)],{env:{APPIUM_HOME:d.appiumHome,...we(d,n.env,n.os)},logPath:N}),B=n.now()+D,F=Math.ceil(D/T)+1;for(let a=0;a<F&&n.now()<B;a++)if(await n.sleep(T),await n.probe(`${O}/status`)){if(f!==void 0){let S=t.filter(H=>H.deviceClass!==e);await n.writeState([...S,{port:p,pid:f,owner:n.owner,deviceClass:e,...c?{bundleVersion:c}:{},startedAt:new Date(n.now()).toISOString()}])}return r.onProgress?.("Appium server ready"),{result:"started",url:O}}throw f!==void 0&&n.kill(f),new Error(`The managed Appium server (${e}) did not answer on ${p} within ${D/1e3}s.
|
|
4
|
+
Check its log: ${N}`)}async function ye(e,r=[],n=[],o){let t=new Set(n),i=new Set([...G,...r]);for(let s of i)if(!t.has(s))for(let c of await e.sessions(s)){if(!c.id)continue;if(o){let d=be(c.caps);if(d&&d!==o)continue}let u=De(c.caps);return{port:s,...u?{device:u}:{}}}return null}function be(e){let r=t=>{let i=e[t];return typeof i=="string"?i.toLowerCase():""},n=r("platformName")||r("appium:platformName");if(n.includes("ios"))return"simulator";if(n.includes("android"))return"emulator";let o=r("appium:automationName")||r("automationName");if(o.includes("xcuitest"))return"simulator";if(o.includes("uiautomator"))return"emulator"}var he=["appium:deviceName","deviceName","appium:udid","udid","appium:deviceUDID","deviceUDID"];function De(e){for(let r of he){let n=e[r];if(typeof n=="string"&&n.trim())return n}}function Ue(e={}){let r={...L(),kill:k,writeState:Ae,...e.deps};try{let n=r.readState(),o=e.owner??process.pid,t=n.filter(s=>s.owner===o&&(!e.deviceClass||s.deviceClass===e.deviceClass));for(let s of t){if(!r.alive(s.pid))continue;let c=R(r.getJson(`http://127.0.0.1:${s.port}/sessions`));for(let u of c)u.id&&r.del(`http://127.0.0.1:${s.port}/session/${u.id}`);r.kill(s.pid)}let i=new Set(t.map(s=>`${s.port}:${s.pid}`));C(()=>{r.writeState(r.readState().filter(s=>!i.has(`${s.port}:${s.pid}`)))})}catch{}}function Ae(e){try{let r=m();g(l(r),{recursive:!0}),M(r,JSON.stringify(e,null,2))}catch{}}export{Ce as a,Q as b,se as c,Le as d,ve as e,Je as f,ye as g,Ue as h};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as R}from"./chunk-TDPWFYTJ.js";import{a as x}from"./chunk-
|
|
2
|
+
import{a as R}from"./chunk-TDPWFYTJ.js";import{a as x}from"./chunk-HRZOFTV7.js";import{d as S}from"./chunk-ECZMYPLJ.js";import{a as y}from"./chunk-MMBBQ4OZ.js";import{a as p}from"./chunk-LVN6VHFN.js";import{e as g,j as E}from"./chunk-7F2ZV46B.js";import{spawn as M,execSync as h}from"child_process";import{appendFileSync as b,existsSync as m,mkdirSync as C}from"fs";import{homedir as L}from"os";import{join as V,resolve as s,dirname as v,delimiter as T}from"path";import{fileURLToPath as U}from"url";import{createInterface as I}from"readline";async function*A(e){let n=I({input:e,crlfDelay:1/0});for await(let r of n){let o=r.trim();if(o)try{let i=JSON.parse(o);i&&typeof i.type=="string"&&(yield i)}catch{}}}function O(e){return e==="action"?{set:{V16_AGENT_ENABLE_ALL_BLOCKERS:"true",V16_BIFURCATION_PHASES:"1"},unset:["V16_NETWORK_WS","V16_NETWORK_SSE"]}:{set:{V16_BIFURCATION_PHASES:"1"},unset:["V16_AGENT_ENABLE_ALL_BLOCKERS","V16_NETWORK_WS","V16_NETWORK_SSE"]}}function w(e){return e?{set:{},unset:["V16_AGENT_SKIP_CP_FINAL"]}:{set:{V16_AGENT_SKIP_CP_FINAL:"true"},unset:[]}}function N(e){return e==="dom"?{set:{V16_AGENT_ENABLE_TEXTUAL_VISUAL:"true"},unset:[]}:{set:{},unset:["V16_AGENT_ENABLE_TEXTUAL_VISUAL"]}}var c=v(U(import.meta.url));function k(){for(let e of["python3","python"])try{return h(`${e} --version`,{stdio:"ignore"}),e}catch{}return null}function D(){let n=process.platform==="win32"?"v16-runner.exe":"v16-runner",r={"darwin-arm64":["@testmuai/kane-cli-darwin-arm64","@lambdatestincprivate/kane-cli-darwin-arm64"],"darwin-x64":["@testmuai/kane-cli-darwin-x64","@lambdatestincprivate/kane-cli-darwin-x64"],"linux-x64":["@testmuai/kane-cli-linux-x64","@lambdatestincprivate/kane-cli-linux-x64"],"linux-arm64":["@testmuai/kane-cli-linux-arm64","@lambdatestincprivate/kane-cli-linux-arm64"],"win32-x64":["@testmuai/kane-cli-win-x64","@lambdatestincprivate/kane-cli-win-x64"]},o=`${process.platform}-${process.arch}`,i=r[o];if(i)for(let t of i){let a=[s(c,"..","node_modules",t,"bin",n),s(c,"..","..","node_modules",t,"bin",n),s(c,"..","..","..","node_modules",t,"bin",n),s(c,"..","..","..","..","node_modules",t,"bin",n)];for(let u of a)if(m(u))return{cmd:u,args:[]}}let d=[s(c,"bin",n),s(c,"..","bin",n),s(c,"..","..","..","..","v16-runner","dist",n),s(c,"..","..","..","v16-runner","dist",n),s(c,"..","..","v16-runner","dist",n),s(process.cwd(),"v16-runner","dist",n),s(process.cwd(),"..","v16-runner","dist",n)];for(let t of d)if(m(t))return{cmd:t,args:[]};let l=[s(c,"..","..","v16-runner"),s(c,"..","..","..","..","v16-runner"),s(c,"..","..","..","v16-runner"),s(process.cwd(),"v16-runner"),s(process.cwd(),"..","v16-runner")];for(let t of l)if(m(s(t,"main.py"))){for(let u of[s(t,".venv","bin","python"),s(t,"..",".venv","bin","python"),s(t,"..","browser-agent",".venv","bin","python")])if(m(u))return{cmd:u,args:["main.py"],cwd:t};let a=k();if(a)return{cmd:a,args:["main.py"],cwd:t}}return null}function P(e){return e?V(L(),".testmuai","kaneai","sessions",e,"runner-stderr.log"):null}function K(e){let n=M(e.runner.cmd,e.runner.args,{stdio:["pipe","pipe","pipe"],env:e.env,cwd:e.runner.cwd});n.stdin.on("error",()=>{});let r=P(e.sessionId);if(r)try{C(v(r),{recursive:!0})}catch{}let o=1e5,i="";n.stderr.on("data",u=>{if(i+=u.toString(),i.length>o&&(i=i.slice(-o)),r)try{b(r,u)}catch{}}),n.on("error",u=>{e.log?.("error","RUNNER_SPAWN_ERROR","Runner spawn error",{error:u.message})});let d=null,l=null,t=new Promise(u=>{n.on("close",(f,_)=>{d=f,l=_?String(_):null,e.log?.("info","RUNNER_EXIT","Runner exited",{code:f,signal:l??"none"}),u({code:f,signal:l})})}),a=A(n.stdout);return{child:n,events:a,getStderr:()=>i,getExitCode:()=>d,getExitSignal:()=>l,exited:t}}async function B(e,n){if(!n?.platform||!n.target_kind)return;let r=await S(n.platform)?.toolEnv(n.target_kind)??{dirs:[]};if(r.dirs.length>0&&(e.PATH=[...r.dirs,e.PATH??""].filter(Boolean).join(T)),r.appiumHome&&(e.APPIUM_HOME=r.appiumHome),r.wdaRoot&&(e.TESTMU_IOS_WDA_DERIVED_DATA=r.wdaRoot),n.platform==="android"){let o=y();o&&(e.PATH=[o.platformToolsDir,e.PATH??""].filter(Boolean).join(T),e.ANDROID_HOME=o.root,e.ANDROID_SDK_ROOT=o.root)}}function H(e){let n={...process.env};e.environment&&(n.TESTMUAI_ENV=e.environment),n.TESTMUAI_SOURCE="kane-cli",process.platform==="win32"&&(n.PYTHONIOENCODING="utf-8",n.PYTHONUTF8="1");let r=p(e.environment);n.V16_SERVER_API_HOST=r.v16ServerHost,n.ATMS_URL=r.tmsBaseUrl.replace(/\/api\/?$/,""),e.username&&e.accessKey&&(n.LT_USERNAME=e.username,n.LT_ACCESS_KEY=e.accessKey),e.sessionId&&(n.TESTMUAI_SESSION_ID=e.sessionId);let o=O(e.mode??"testing");Object.assign(n,o.set);for(let a of o.unset)delete n[a];let i=new x().load(),d=N(e.assertionMode??(i.assertion_mode==="visual"?"visual":"dom"));Object.assign(n,d.set);for(let a of d.unset)delete n[a];let l=e.finalValidation??i.final_validation,t=w(l);Object.assign(n,t.set);for(let a of t.unset)delete n[a];return n}function G(e,n){let r=p(n?.environment),o=R();o!==void 0&&e.ap_mode===void 0&&(e.ap_mode=o),e.telemetry_proxy_url===void 0&&process.env.KANE_TELEMETRY!=="0"&&(e.telemetry_proxy_url=E),e.media_upload===void 0&&e.org_id&&e.username&&e.access_key&&(e.media_upload={url:r.shareApiBaseUrl.replace(/\/$/,"")+"/mfs/v1.0/media/upload",artefacts_host:r.mediaArtefactsHost,org_id:e.org_id,media_dir:g})}async function oe(e,n){let r=D();if(!r)throw new Error("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available.");process.env.KANE_SPAWN_DEBUG&&process.stderr.write(`[spawn-debug] ${JSON.stringify(r)}
|
|
3
3
|
`);let o=H({environment:n?.environment,mode:n?.mode,assertionMode:n?.assertionMode,finalValidation:n?.finalValidation,username:e.username,accessKey:e.access_key,sessionId:e.session_id});e.device?.platform&&await B(o,e.device),G(e,{environment:n?.environment});let i=K({env:o,runner:r,log:n?.log,sessionId:e.session_id}),d=i.child;d.stdin.write(JSON.stringify(e)+`
|
|
4
4
|
`);let l=P(e.session_id);if(l)try{C(v(l),{recursive:!0}),b(l,`--- runner spawn ${new Date().toISOString()} run_index=${e.run_index} ---
|
|
5
5
|
`)}catch{}return{child:d,events:i.events,sendUserResponse(t){let a=JSON.stringify({type:"user_response",answer:t});try{d.stdin.write(a+`
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as B,b as H,c as ie}from"./chunk-
|
|
2
|
+
import{a as B,b as H,c as ie}from"./chunk-3NHO5R4P.js";import{a as j,b as N}from"./chunk-OOEPLMKA.js";import{a as C,b as G,e as M,f as te,m as re,n as ne}from"./chunk-VK3NU742.js";import{a as oe,b as se}from"./chunk-2YQ6TW77.js";import{a as L}from"./chunk-HRZOFTV7.js";import{a as ee}from"./chunk-5SNT2MK5.js";import{a as q}from"./chunk-LVN6VHFN.js";import{a as Z}from"./chunk-DPUV6OSP.js";import{a as A}from"./chunk-RZ4F3BHX.js";import{a as O}from"./chunk-PXCMEI73.js";import{y as h}from"./chunk-7F2ZV46B.js";import{a as F}from"./chunk-HCBYKLMW.js";import{a as k,b as m,i as Q}from"./chunk-C44QQJR4.js";import{a as X}from"./chunk-6YGTRKDT.js";import{e as v}from"./chunk-UR6MHSHU.js";var D=v(X(),1);import{existsSync as P,readFileSync as Ge,rmSync as he,unlinkSync as He}from"fs";import{resolve as z}from"path";import{promises as ae,realpathSync as be}from"fs";import{homedir as Te}from"os";import{join as V,parse as Ee,relative as ce,resolve as le}from"path";var ue=new Set(["node_modules",".git","dist","build",".next",".venv","venv","target","__pycache__"]),R=class extends Error{constructor(s){super(`refusing to scan '${s}'. Run from your project root, or pass --root <dir>.`);this.cwd=s;this.name="HomeRefusedError"}};function de(e){try{return be(le(e))}catch{return le(e)}}function Se(e){let r=de(e),s=de(Te()),n=Ee(r).root;if(process.platform==="win32"){let o=t=>t.toLowerCase();return o(r)===o(s)||o(r)===o(n)}return r===s||r===n}async function U(e){if(Se(e.root))throw new R(e.root);let r=e.maxEntries??5e4,s=e.maxResults??5e3,n=new Set(e.ignore??[]),o=[],t=0,i=0,c=!1,f,l=[e.root];for(;l.length>0&&!c;){let a=l.shift(),g;try{g=await ae.readdir(a,{withFileTypes:!0})}catch{continue}i++;for(let b of g){if(t++,t>r){c=!0,f="max_entries";break}let x=b.name,E=V(a,x);if(b.isDirectory()){if(ue.has(x)||x.startsWith(".")||x.startsWith("output-")||n.has(x))continue;l.push(E)}else if(b.isFile()&&x.endsWith("_test.md")&&(o.push({path:E,relPath:ce(e.root,E),source:"cwd"}),o.length>=s)){c=!0,f="max_results";break}}e.onProgress?.(i,o.length)}if(!c){let g=[{dir:V(e.root,".testmuai","tests"),depth:0}];for(;g.length>0&&!c;){let{dir:b,depth:x}=g.shift(),E;try{E=await ae.readdir(b,{withFileTypes:!0})}catch{continue}i++;for(let u of E){if(t++,t>r){c=!0,f="max_entries";break}let w=u.name,y=V(b,w);if(u.isDirectory()){if(x>=20||w.startsWith(".")||w.startsWith("output-")||ue.has(w))continue;g.push({dir:y,depth:x+1})}else if(u.isFile()&&w.endsWith("_test.md")&&(o.push({path:y,relPath:ce(e.root,y),source:"tests-dir"}),o.length>=s)){c=!0,f="max_results";break}}}}return{results:o,aborted:c,abortReason:f,dirsScanned:i}}import{readFileSync as ve}from"fs";function Re(e){let r;try{r=ve(e,"utf8")}catch{return{tags:[]}}try{let{global:s}=re(e,r),n=ne(s);return{tags:s.tags??[],...n?{mobileTarget:n}:{}}}catch{return{tags:[],...Me(r)?{mobileTarget:Pe}:{}}}}var Pe={platform:"",app:""};function Me(e){let r=/^---\r?\n([\s\S]*?)\r?\n---/.exec(e);if(!r)return!1;let s=r[1].split(/\r?\n/);if(s.some(o=>/^target:\s*['"]?(emulator|simulator)['"]?\s*$/.test(o)))return!0;let n=s.findIndex(o=>/^target:\s*$/.test(o));return n<0?!1:s.slice(n+1).some(o=>/^\s+\S/.test(o))}function W(e){return Re(e).tags}import{mkdirSync as De,writeFileSync as $e}from"fs";import{join as Ce}from"path";function fe(e,r){return`Basic ${Buffer.from(`${e}:${r}`).toString("base64")}`}async function Ie(e){let r=oe({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId,codeExport:{enabled:!0,language:e.language,skipValidation:e.skipValidation}}),s=await A(r.url,{method:"POST",headers:{"content-type":"application/json",authorization:fe(e.auth.username,e.auth.access_key)},body:JSON.stringify(r.body)});if(!s.ok)throw new Error(`code-export trigger failed: ${s.status} ${await s.text()}`);e.log("info","CODE_EXPORT_TRIGGERED","Code export triggered",{testcase_id:e.testcaseId})}async function Fe(e){let r=se({tmsBaseUrl:e.tmsBaseUrl,testcaseId:e.testcaseId}),s=e.pollIntervalMs??5e3,n=e.timeoutMs??3e5,o=Date.now()+n;for(;Date.now()<o;){let t=await A(r,{headers:{authorization:fe(e.auth.username,e.auth.access_key),accept:"application/json"}});if(!t.ok){await new Promise(l=>setTimeout(l,s));continue}let c=(await t.json()).data?.find(l=>l.code_name==="kane-cli-trigger");if(!c){await new Promise(l=>setTimeout(l,s));continue}let f=(c.status??"").toLowerCase();if(f==="in progress"||f==="in_progress"||f==="pending"){await new Promise(l=>setTimeout(l,s));continue}if(!c.url||c.url.length===0)throw new Error(`code-export status=${c.status} but no files returned`);De(e.outDir,{recursive:!0});for(let l of c.url){let a=Ce(e.outDir,l.file_name),g=await A(l.file_url);if(!g.ok){e.log("warn","CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:l.file_name,status:g.status});continue}let b=await g.text();$e(a,b,"utf-8")}return e.log("info","CODE_EXPORT_DOWNLOADED","Code export saved",{out_dir:e.outDir,file_count:c.url.length}),e.outDir}throw new Error("code-export polling timed out")}async function ge(e){return await Ie(e),await Fe(e)}var T=v(X(),1);import{existsSync as Oe,readFileSync as Ae}from"fs";var p=v(F(),1);function Le(e){B(e);let r=M(e);if(!Oe(r))return null;try{return JSON.parse(Ae(r,"utf8"))}catch{return{}}}function Be(e){return e===null?"never_run":e.testcase_id?"synced":"local_only"}function je(e){return e==="synced"?"\u2601":e==="local_only"?"\u25A3":"\u25CB"}function Ne(e){return e==="tests-dir"?"\u2726":" "}function Ue(e,r){return r==="all"?!0:r==="synced"?e.status==="synced":r==="local"?e.status==="local_only":r==="never_run"?e.status==="never_run":r==="cli"?e.source==="tests-dir":r==="hand"?e.source==="cwd":!0}var Y=["all","synced","local","never_run","cli","hand"];function We(e){let r=Y.indexOf(e);return Y[(r+1)%Y.length]}function me({root:e,currentOrgId:r,onSelect:s,onCancel:n}){let[o,t]=(0,T.useState)([]),[i,c]=(0,T.useState)(null),[f,l]=(0,T.useState)(!0),[a,g]=(0,T.useState)("all");(0,T.useEffect)(()=>{(async()=>{try{let u=await U({root:e}),w=[];for(let y of u.results){let K=Le(y.path);K?.org_id!==void 0&&K.org_id!==r||w.push({path:y.path,relPath:y.relPath,name:C(y.path),status:Be(K),source:y.source,tags:W(y.path)})}t(w),l(!1)}catch(u){u instanceof R,c(u.message),l(!1)}})()},[e,r]);let b=(0,T.useMemo)(()=>o.filter(u=>Ue(u,a)).map(u=>({id:u.path,label:`${je(u.status)} ${Ne(u.source)} ${u.relPath}${u.tags.length>0?` [${u.tags.join(", ")}]`:""}`})),[o,a]),x=(0,T.useMemo)(()=>Ke(a,o),[a,o]);if(i)return(0,p.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:h.red,paddingX:2,paddingY:1,children:[(0,p.jsx)(m,{color:h.red,bold:!0,children:"testmd"}),(0,p.jsx)(k,{marginTop:1,children:(0,p.jsx)(m,{color:h.red,children:i})})]});let E=a==="all"?"all":Je(a);return(0,p.jsx)(ee,{title:`testmd \xB7 filter: ${E}`,items:b,loading:f,itemNoun:"tests",onSelect:u=>{let w=o.find(y=>y.path===u.id);w&&s(w)},onCancel:n,onTab:()=>g(u=>We(u)),extraHint:"cycle filter",footer:x})}function Je(e){return e==="synced"?"synced (\u2601)":e==="local"?"local (\u25A3)":e==="never_run"?"never run (\u25CB)":e==="cli"?"cli-generated (\u2726)":e==="hand"?"hand-written":"all"}function Ke(e,r){let s={synced:r.filter(o=>o.status==="synced").length,local:r.filter(o=>o.status==="local_only").length,never:r.filter(o=>o.status==="never_run").length,cli:r.filter(o=>o.source==="tests-dir").length,hand:r.filter(o=>o.source==="cwd").length},n=o=>o?h.orange:h.dim;return(0,p.jsxs)(k,{flexDirection:"column",children:[(0,p.jsx)(m,{color:h.dim,children:"legend:"}),(0,p.jsxs)(k,{children:[(0,p.jsx)(m,{color:n(e==="synced"),children:` \u2601 synced (${s.synced}) `}),(0,p.jsx)(m,{color:n(e==="local"),children:`\u25A3 local (${s.local}) `}),(0,p.jsx)(m,{color:n(e==="never_run"),children:`\u25CB never run (${s.never})`})]}),(0,p.jsxs)(k,{children:[(0,p.jsx)(m,{color:n(e==="cli"),children:` \u2726 cli-generated (${s.cli}) `}),(0,p.jsx)(m,{color:n(e==="hand"),children:` hand-written (${s.hand})`})]})]})}var I=v(X(),1);import{existsSync as Xe,readFileSync as qe}from"fs";var d=v(F(),1);function pe({path:e,relPath:r,onAction:s,onBack:n,onView:o}){let[t,i]=(0,I.useState)(null),[c,f]=(0,I.useState)(!1);(0,I.useEffect)(()=>{let a=M(e);if(Xe(a))try{i(JSON.parse(qe(a,"utf8")))}catch{i(null)}},[e]),Q((a,g)=>{if(g.escape){if(c){f(!1);return}n();return}if(c){a==="y"||a==="Y"?(f(!1),s("delete")):(a==="n"||a==="N")&&f(!1);return}a==="r"&&s("run"),a==="e"&&t?.testcase_id&&s("export"),a==="d"&&f(!0),a==="v"&&o&&o()});let l=({k:a,v:g})=>g?(0,d.jsxs)(m,{children:[(0,d.jsx)(m,{color:h.dim,children:a.padEnd(14)}),g]}):null;return(0,d.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:h.orange,paddingX:2,paddingY:1,children:[(0,d.jsx)(m,{color:h.orange,bold:!0,children:r}),(0,d.jsx)(k,{marginTop:1,flexDirection:"column",children:t?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(l,{k:"test_id",v:t.test_id}),(0,d.jsx)(l,{k:"testcase_id",v:t.testcase_id}),(0,d.jsx)(l,{k:"project_id",v:t.project_id}),(0,d.jsx)(l,{k:"folder_id",v:t.folder_id}),(0,d.jsx)(l,{k:"org_id",v:t.org_id}),(0,d.jsx)(l,{k:"session_name",v:t.session_name}),(0,d.jsx)(l,{k:"commit_id",v:t.commit_id})]}):(0,d.jsx)(m,{color:h.dim,children:"(never run \u2014 no meta.json)"})}),c?(0,d.jsx)(k,{marginTop:1,children:(0,d.jsxs)(m,{color:h.red,bold:!0,children:["Delete ",r," and its output dir? [y/n]"]})}):(0,d.jsx)(k,{marginTop:1,children:(0,d.jsxs)(m,{color:h.dim,children:["[r] run [e] export",t?.testcase_id?"":" (need testcase_id)"," [d] delete",o?" [v] view":""," [Esc] back"]})})]})}function $(e){B(e);let r=M(e);if(!P(r))return null;try{return JSON.parse(Ge(r,"utf8"))}catch{return null}}function _e(e,r){return!e||e.org_id===void 0?!0:e.org_id===r}function J(e,r){return _e(e,r)?null:(process.stderr.write(`error: this test belongs to org ${e.org_id}; you are logged in as org ${r}.
|
|
3
3
|
Switch profiles with \`kane-cli profiles switch\` to act on it.
|
|
4
4
|
`),2)}async function Xt(e={}){let r=!!process.stdin.isTTY&&!e.json,s=new O,n=new L;await H({isInteractive:r,creds:s,config:n});let o=s.getDefaultEnv()??"prod";try{let t=await N({creds:s,env:o,log:()=>{}});return t.resolvedCreds?.org_id===void 0?(process.stderr.write("error: TMS did not return an org_id. Run `kane-cli login` again.\n"),{ok:!1,code:2}):{ok:!0,orgId:String(t.resolvedCreds.org_id)}}catch(t){if(t instanceof j)return process.stderr.write("error: not authenticated. Run `kane-cli login` first.\n"),{ok:!1,code:2};throw t}}async function qt(e,r){if(process.stdin.isTTY&&!e.json)return await ze(r,e.root);let s=e.root??process.cwd(),n;try{n=await U({root:s,ignore:e.ignore})}catch(o){if(o instanceof R)return process.stderr.write(`error: ${o.message}
|
|
5
5
|
`),2;throw o}for(let o of n.results){let t=$(o.path);if(!_e(t,r))continue;let i={path:o.relPath.startsWith(".")?o.relPath:`./${o.relPath}`,name:C(o.path),has_meta:t!==null,source:o.source,synced:!!t?.testcase_id,tags:W(o.path)};t&&(t.test_id&&(i.test_id=t.test_id),t.testcase_id&&(i.testcase_id=t.testcase_id),t.org_id&&(i.org_id=t.org_id),t.project_id&&(i.project_id=t.project_id),t.folder_id&&(i.folder_id=t.folder_id)),process.stdout.write(JSON.stringify(i)+`
|
|
6
6
|
`)}return n.aborted&&process.stderr.write(`warn: walk aborted (${n.abortReason}). Pass --root or --ignore to narrow.
|
|
7
|
-
`),0}var ye=-1001,xe=-1002,we=-1003,_={action:null,path:null};function Ve(e,r){return _.action=e,_.path=r,e==="run"?ye:e==="export"?xe:we}function Ye({root:e,currentOrgId:r,onComplete:s}){let[n,o]=D.default.useState({kind:"list"});return D.default.useEffect(()=>{n.kind==="exiting"&&s(n.code)},[n,s]),n.kind==="list"?D.default.createElement(me,{root:e,currentOrgId:r,onSelect:t=>o({kind:"inspect",path:t.path,relPath:t.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?D.default.createElement(pe,{path:n.path,relPath:n.relPath,onAction:async t=>{o({kind:"exiting",code:Ve(t,n.path)})},onBack:()=>o({kind:"list"})}):null}async function ze(e,r){let s=r??process.cwd(),{render:n}=await import("./build-JIKYOZUH.js"),o=await new Promise(t=>{let{unmount:i,waitUntilExit:c}=n(D.default.createElement(Ye,{root:s,currentOrgId:e,onComplete:f=>{i(),t(f)}}),{stdout:process.stderr,exitOnCtrlC:!0});c().then(()=>t(0)).catch(()=>t(0))});if(o===ye&&_.path){let{runTestMdFile:t}=await import("./run-test-md-
|
|
7
|
+
`),0}var ye=-1001,xe=-1002,we=-1003,_={action:null,path:null};function Ve(e,r){return _.action=e,_.path=r,e==="run"?ye:e==="export"?xe:we}function Ye({root:e,currentOrgId:r,onComplete:s}){let[n,o]=D.default.useState({kind:"list"});return D.default.useEffect(()=>{n.kind==="exiting"&&s(n.code)},[n,s]),n.kind==="list"?D.default.createElement(me,{root:e,currentOrgId:r,onSelect:t=>o({kind:"inspect",path:t.path,relPath:t.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?D.default.createElement(pe,{path:n.path,relPath:n.relPath,onAction:async t=>{o({kind:"exiting",code:Ve(t,n.path)})},onBack:()=>o({kind:"list"})}):null}async function ze(e,r){let s=r??process.cwd(),{render:n}=await import("./build-JIKYOZUH.js"),o=await new Promise(t=>{let{unmount:i,waitUntilExit:c}=n(D.default.createElement(Ye,{root:s,currentOrgId:e,onComplete:f=>{i(),t(f)}}),{stdout:process.stderr,exitOnCtrlC:!0});c().then(()=>t(0)).catch(()=>t(0))});if(o===ye&&_.path){let{runTestMdFile:t}=await import("./run-test-md-7HGOZJSU.js"),i=await t(_.path,{});return _.action=null,_.path=null,i}if(o===xe&&_.path){let t=await Ze(_.path,{},e);return _.action=null,_.path=null,t}if(o===we&&_.path){let t=await Qe(_.path,!0,e);return _.action=null,_.path=null,t}return o}async function Gt(e,r){let s=z(e);if(!P(s))return process.stderr.write(`error: file not found: ${s}
|
|
8
8
|
`),2;let n=$(s),o=J(n,r);if(o!==null)return o;let t={path:s,name:C(s),has_meta:n!==null};return n&&(n.commit_id&&(t.commit_id=n.commit_id),n.test_id&&(t.test_id=n.test_id),n.testcase_id&&(t.testcase_id=n.testcase_id),n.project_id&&(t.project_id=n.project_id),n.folder_id&&(t.folder_id=n.folder_id),n.org_id&&(t.org_id=n.org_id),n.session_name&&(t.session_name=n.session_name)),process.stdout.write(JSON.stringify(t)+`
|
|
9
9
|
`),0}async function Qe(e,r,s){let n=z(e);if(!P(n))return process.stderr.write(`error: file not found: ${n}
|
|
10
10
|
`),2;let o=$(n),t=J(o,s);if(t!==null)return t;if(!r)return process.stderr.write(`error: refusing to delete without --yes.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as G,c as P,e as J,h as q,i as z,j as Q,m as V,o as X,p as T}from"./chunk-
|
|
2
|
+
import{b as G,c as P,e as J,h as q,i as z,j as Q,m as V,o as X,p as T}from"./chunk-VK3NU742.js";import{e as U}from"./chunk-EHN5HTUD.js";import{copyFileSync as ae,cpSync as le,existsSync as w,mkdirSync as ue,readFileSync as Oe,readdirSync as pe,rmSync as Te,writeFileSync as _e}from"fs";import{dirname as Ae,isAbsolute as Le,join as R,relative as Ee,resolve as Ne}from"path";import{writeFileSync as ge,mkdirSync as Se,readFileSync as Re}from"fs";import{dirname as Ie,basename as Y}from"path";function ee(e){let t=e.outPath??P(e.sourcePath);Se(Ie(t),{recursive:!0});let s=[];s.push("---"),s.push(`test: ../${Y(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??Y(e.sourcePath)} \u2014 Result`,"");for(let l=0;l<e.rootSteps.length;l++){let a=e.rootSteps[l],i=e.outcomes.find(p=>p.rootStepIndex===l+1);if(s.push(ye(a,i)),i?.stepMd5&&s.push(`md5: ${i.stepMd5}`),i?.status==="failed"&&i.reason&&s.push(`Reason: ${i.reason}`),i?.softFailures?.length)for(let p of i.softFailures){let o=p.reason?`: ${p.reason}`:"";s.push(`\u26A0 optional sub-step ${p.subStepIndex} failed${o}`)}a.body.kind==="objective"&&i?.status!=="skipped"&&s.push(a.body.text),s.push("")}return ge(t,s.join(`
|
|
3
3
|
`),"utf8"),t}function ye(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 a=t.helperResultRelPath?` \u2192 ${t.helperResultRelPath}`:"";return`## ${e.heading} \u2713 passed (via @${t.refKind} ${t.refLabel} \u2014 ${t.inlinedCount} inlined steps, ${s}${a})`}if(t.refKind&&t.status==="failed"){let a=t.failedSubStepIndex&&t.failedSubStepIndex.length>0?` \u2014 at sub-step ${t.failedSubStepIndex.join(" \u2192 sub-step ")}`:"",i=t.helperResultRelPath?` \u2192 ${t.helperResultRelPath}`:"";return`## ${e.heading} \u2717 failed${l} (via @${t.refKind} ${t.refLabel}${a}, ${s}${i})`}return t.status==="passed"?`## ${e.heading} \u2713 passed (${s})`:`## ${e.heading} \u2717 failed${l} (${s})`}var xe=/^##\s+(.+?)\s+(✓ passed|✗ failed(?:\s+\(optional\))?|⏭ skipped)(?:\s+\((.*)\))?\s*$/,be=/via\s+@\w+\s+(\S+).*?(?:→\s+(\S+))?\s*$/,ke=/^md5:\s+([a-f0-9]{32})\s*$/;function Z(e,t){for(let s=t;s<e.length&&!/^##\s/.test(e[s]);s++){if(e[s].trim()==="")continue;let l=ke.exec(e[s]);return l?l[1]:null}return null}function $(e){let s=Re(e,"utf8").split(`
|
|
4
4
|
`),l="passed";if(s[0]?.trim()==="---")for(let i=1;i<s.length&&s[i].trim()!=="---";i++){let p=/^status:\s+(passed|failed|interrupted)\s*$/.exec(s[i]);p&&(l=p[1])}let a=[];for(let i=0;i<s.length;i++){let p=xe.exec(s[i]);if(!p)continue;let o=p[1],r=p[2],c=p[3]??"",m=r.startsWith("\u2713")?"passed":r.startsWith("\u23ED")?"skipped":"failed";if(/via\s+@/.test(c)){let f=be.exec(c),b=f?.[1]??"",g=f?.[2]??null;a.push({kind:"import",heading:o,status:m,md5:Z(s,i+1),importPath:b,helperResultRelPath:g})}else a.push({kind:"objective",heading:o,status:m,md5:Z(s,i+1)})}return{overallStatus:l,steps:a}}import{copyFileSync as te,existsSync as K,mkdirSync as ve,writeFileSync as se,promises as Ge}from"fs";import{join as D,dirname as re,basename as Pe}from"path";async function ne(e){for(let t=0;t<e.totalRunDirs;t++){let s=e.runIndex+t,l=D(e.sessionDir,"runs",String(s)),a=D(e.stagingStepDir,"flows",String(t));ve(a,{recursive:!0});let i=D(a,"actions.ndjson");if(e.packTestDir){let r=D(e.packTestDir,"logs",`${s}-actions.ndjson`);if(K(r)){te(r,i);continue}let c=re(re(e.packTestDir)),m=Pe(e.packTestDir),I=K(c)?await U(c,`tests/${m}/logs/${s}-actions.ndjson`).catch(()=>null):null;se(i,I??"");continue}let p=[D(l,"run-test","actions.ndjson"),D(l,"actions.ndjson")],o=!1;for(let r of p)if(K(r)){te(r,i),o=!0;break}o||se(i,"")}}import{existsSync as _,readdirSync as we}from"fs";import{dirname as $e,join as M,basename as C}from"path";function et(e){let t=[],s=new Set,l=new Map;function a(r){if(l.has(r))return l.get(r);let c=P(r),m=_(c)?$(c):null;return l.set(r,m),m}let i=new Map;function p(r){if(i.has(r))return i.get(r);let c=M(r,"Result.md"),m=_(c)?$(c):null;return i.set(r,m),m}function o(r){for(let c=1;c<r.trace.length;c++){let m=r.trace[c-1],I=a(m.file);if(!I)continue;let f=I.steps[m.stepIndex-1];if(f){if(f.kind!=="import")return{kind:"author",reason:"structure-mismatch"};if(C(f.importPath)!==C(r.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 r of e.steps){let c=r.trace[r.trace.length-1].stepIndex,m=s.has(r.owningFile);for(let g=0;g<r.trace.length-1&&!m;g++)s.has(r.trace[g].file)&&(m=!0);if(m){t.push({kind:"author",reason:a(r.owningFile)===null?"no-result-md":"downstream-of-divergence"});continue}let I=o(r);if(I){t.push(I);for(let g=0;g<r.trace.length;g++)s.add(r.trace[g].file);continue}let f=a(r.owningFile),b;if(f===null&&r.trace.length>1){let g=H(r.trace);b=ie(r,p(g),c,g)}else b=ie(r,f,c);if(t.push(b),b.kind==="author"){s.add(r.owningFile);for(let g=0;g<r.trace.length-1;g++)s.add(r.trace[g].file)}}return t}function ie(e,t,s,l=null){if(!t)return{kind:"author",reason:"no-result-md"};let a=t.steps[s-1];if(!a)return{kind:"author",reason:"no-result-md"};if(a.kind!=="objective")return{kind:"author",reason:"structure-mismatch"};if(a.status!=="passed")return{kind:"author",reason:"recorded-failed"};let i=T(e);if(i!==a.md5)return{kind:"author",reason:"md5-mismatch"};let p=l===null?Q(e.owningFile,s,i.slice(0,8)):M(l,".internal","steps",`${s}-${i.slice(0,8)}`),o=De(p);return o===0?{kind:"author",reason:"missing-recording"}:{kind:"replay",recordingDir:p,flowCount:o}}function De(e){let t=M(e,"flows");if(!_(t))return 0;let s;try{s=we(t,{withFileTypes:!0}).filter(a=>a.isDirectory()&&/^\d+$/.test(a.name)).map(a=>parseInt(a.name,10))}catch{return 0}if(s.length===0)return 0;let l=Math.max(...s);for(let a=0;a<=l;a++)if(!_(M(t,String(a),"actions.ndjson")))return 0;return l+1}function tt(e){return e.some(t=>t.kind==="author")}function st(e){for(let t=0;t<e.length;t++)if(e[t].kind==="author")return t;return e.length}function H(e){let t=i=>{let p=C(i);return p.endsWith("_test.md")?p.slice(0,-8):p.endsWith(".md")?p.slice(0,-3):p},s=t(e[0].file),l=t(e[e.length-1].file),a=e.slice(0,-1).map(i=>String(i.stepIndex));return M($e(e[e.length-1].file),`helper-output-${l}-${s}-${a.join("-")}`)}function rt(e){return Array.from({length:e.flowCount},(t,s)=>M(e.recordingDir,"flows",String(s),"actions.ndjson"))}import{existsSync as oe,mkdirSync as Me,rmSync as je,cpSync as Fe}from"fs";function de(e,t){oe(e)&&(oe(t)&&je(t,{recursive:!0,force:!0}),Me(t,{recursive:!0}),Fe(e,t,{recursive:!0}))}async function gt(e){let t=new Map;for(let o of e.stepRunRecords)t.set(o.testmdStepIndex,o);let s=e.authoredFlatIdx??new Set,l=[],a=[],i=new Map,p=o=>{if(i.has(o))return i.get(o);let r=R(o,"Result.md"),c=w(r)?$(r):null;return i.set(o,c),c};for(let o of e.resolvedTest.unitFiles){let r=o.file===e.resolvedTest.rootPath,c=V(o.file,Oe(o.file,"utf8")),m=P(o.file),I=w(m)?$(m):null,f=[],b=[],g=[],j=[];if(!r)for(let d of e.resolvedTest.steps){if(d.owningFile!==o.file||d.trace.length<2)continue;let n=H(d.trace);j.includes(n)||j.push(n)}let F=d=>{if(I!==null)return null;for(let n of j){let v=p(n)?.steps[d-1];if(v)return{row:v,dir:n}}return null},W=[],A=!1,B=!1,L=!1,E=!1;for(let d of c.steps){let n=d.index,u=I?.steps[n-1];if(d.body.kind==="objective"){let h=e.resolvedTest.steps.filter(S=>S.owningFile===o.file&&S.trace[S.trace.length-1].stepIndex===n&&t.has(S.flatIndex)),y=h.length>0?h[h.length-1]:null;if(y){A=!0,s.has(y.flatIndex)&&(B=!0);let S=T(y),x;r?x=e.outcomes.find(he=>he.rootStepIndex===n)??{rootStepIndex:n,status:"skipped"}:x={rootStepIndex:n,status:ce(y,e.outcomes)},x.status==="failed"&&(L=!0),x.stepMd5==null&&(x.stepMd5=S),f.push(x),b.push({stepIndex:n,md5:S,rec:t.get(y.flatIndex)}),(!u||u.kind!=="objective"||u.status!==x.status||x.status==="passed"&&u.md5!==S)&&(E=!0)}else if(u&&u.kind==="objective")f.push({rootStepIndex:n,status:u.status,...u.md5?{stepMd5:u.md5}:{}}),g.push(n);else if(!r&&F(n)?.row.kind==="objective"){let S=F(n),x=S.row;f.push({rootStepIndex:n,status:x.status,...x.md5?{stepMd5:x.md5}:{}}),W.push({psIdx:n,dir:S.dir})}else r?f.push(e.outcomes.find(S=>S.rootStepIndex===n)??{rootStepIndex:n,status:"skipped"}):f.push({rootStepIndex:n,status:"skipped"});continue}let v=Le(d.body.path)?d.body.path:Ne(Ae(o.file),d.body.path),O=X({path:d.body.path,bindings:d.body.bindings,optional:d.optional??!1}),me=Ee(G(o.file),P(v)),N=e.resolvedTest.steps.filter(h=>h.trace.some((y,S)=>S<h.trace.length-1&&y.file===o.file&&y.stepIndex===n)&&t.has(h.flatIndex));if(N.length>0){A=!0;let h;if(r)h=e.outcomes.find(y=>y.rootStepIndex===n)??{rootStepIndex:n,status:"passed",refKind:"import",refLabel:d.body.path};else{let y=N.some(S=>ce(S,e.outcomes)==="failed");h={rootStepIndex:n,status:y?"failed":"passed",refKind:"import",refLabel:d.body.path,inlinedCount:N.length}}h.status==="failed"&&(L=!0),h.stepMd5==null&&(h.stepMd5=O),h.helperResultRelPath==null&&(h.helperResultRelPath=me),f.push(h),(!u||u.kind!=="import"||u.status!==h.status||u.md5!==O)&&(E=!0)}else if(u&&u.kind==="import")f.push({rootStepIndex:n,status:u.status,refKind:"import",refLabel:u.importPath,...u.md5?{stepMd5:u.md5}:{},...u.helperResultRelPath?{helperResultRelPath:u.helperResultRelPath}:{}});else if(!r&&F(n)?.row.kind==="import"){let h=F(n).row;f.push({rootStepIndex:n,status:h.status,refKind:"import",refLabel:d.body.path})}else r?f.push(e.outcomes.find(h=>h.rootStepIndex===n)??{rootStepIndex:n,status:"skipped",refKind:"import",refLabel:d.body.path}):f.push({rootStepIndex:n,status:"skipped",refKind:"import",refLabel:d.body.path})}if(!(r||A&&(B||L||I===null||E)))continue;l.push(o.file);let k=q(o.file);ue(R(k,".internal"),{recursive:!0});for(let d of b){let n=R(k,".internal","steps",`${d.stepIndex}-${d.md5.slice(0,8)}`);ue(n,{recursive:!0}),await ne({sessionDir:e.sessionDir,runIndex:d.rec.runIndex,totalRunDirs:d.rec.totalRunDirs,stagingStepDir:n,packTestDir:e.packTestDir})}if(g.length>0){let d=z(o.file);if(w(d))for(let n of pe(d)){let u=parseInt(n.split("-")[0]??"",10);!Number.isNaN(u)&&g.includes(u)&&le(R(d,n),R(k,".internal","steps",n),{recursive:!0})}}for(let d of W){let n=R(d.dir,".internal","steps");if(w(n))for(let u of pe(n))parseInt(u.split("-")[0]??"",10)===d.psIdx&&le(R(n,u),R(k,".internal","steps",u),{recursive:!0})}let fe=f.some(d=>d.status==="failed");if(ee({sourcePath:o.file,title:c.title,rootSteps:c.steps,outcomes:f,overallStatus:r?e.overallStatus:fe?"failed":"passed",startedISO:e.startedISO,durationS:r?e.durationS:0,sessionId:e.sessionId,outPath:R(k,"Result.md")}),r){let d={};e.commitId&&(d.commit_id=e.commitId),e.tmsIds.testId&&(d.test_id=e.tmsIds.testId),e.tmsIds.testcaseId&&(d.testcase_id=e.tmsIds.testcaseId),e.tmsIds.projectId&&(d.project_id=e.tmsIds.projectId),e.tmsIds.folderId&&(d.folder_id=e.tmsIds.folderId),e.tmsIds.orgId&&(d.org_id=e.tmsIds.orgId),e.tmsIds.sessionName&&(d.session_name=e.tmsIds.sessionName),_e(R(k,".internal","meta.json"),JSON.stringify(d,null,2)+`
|
|
5
5
|
`,"utf8");let n=R(e.sessionDir,"execution.json");if(w(n))try{ae(n,R(k,".internal","execution.json"))}catch{}if(e.codeExportDir){let u=e.codeExportLanguage??"python",v=R(k,`playwright-${u}-code`);try{de(e.codeExportDir,v)}catch(O){process.stderr.write(`warn: codegen copy failed: ${O.message}
|