@testmuai/kane-cli 0.4.10 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ChromeProfilePicker-EFEVOCWS.js → ChromeProfilePicker-PIWZY4WH.js} +1 -1
- package/dist/{CliFeedbackPrompt-PPGJMKHQ.js → CliFeedbackPrompt-URXCHBZ5.js} +1 -1
- package/dist/{CliUploadProgress-3GGOTLPQ.js → CliUploadProgress-DMH3C3UZ.js} +1 -1
- package/dist/{ConfigView-Y7E4Q647.js → ConfigView-NWNDNTKW.js} +1 -1
- package/dist/EvidenceViewOffer-HEBQ7C4H.js +2 -0
- package/dist/FolderPicker-5S23OTSY.js +2 -0
- package/dist/HelpView-YYKTP4JH.js +2 -0
- package/dist/{InfoBox-BQ2QOIUP.js → InfoBox-FPAWQZGQ.js} +1 -1
- package/dist/{LinksBox-DX6BJAX5.js → LinksBox-O5ZFYSK2.js} +1 -1
- package/dist/{ProfilesView-X35WWM4L.js → ProfilesView-SPECXHZE.js} +1 -1
- package/dist/{ProjectPicker-Y4A4UVHA.js → ProjectPicker-ANJ6NGNY.js} +1 -1
- package/dist/{SaveSessionPrompt-IS6HZSF4.js → SaveSessionPrompt-W2GWELOP.js} +1 -1
- package/dist/SingleShotApp-5TYM356H.js +2 -0
- package/dist/{SummaryBox-47MHU37V.js → SummaryBox-DJUDYML7.js} +1 -1
- package/dist/TestMdRunView-BIVXQE54.js +2 -0
- package/dist/{WhoamiView-KVIQCGRC.js → WhoamiView-DH25ZD4C.js} +1 -1
- package/dist/{changelog-S4ZLEQLC.js → changelog-RCKUVBFL.js} +1 -1
- package/dist/{chunk-LPUQ4HWQ.js → chunk-2WVKOZ6W.js} +1 -1
- package/dist/chunk-2YQ6TW77.js +82 -0
- package/dist/chunk-3FN66LTP.js +3 -0
- package/dist/{chunk-JKLKZCJS.js → chunk-4IOOBSNB.js} +1 -1
- package/dist/chunk-54TKNWXF.js +5 -0
- package/dist/{chunk-HPZREZKG.js → chunk-5MTRNUAK.js} +1 -1
- package/dist/{chunk-OHT5RY5E.js → chunk-6E5UYAEB.js} +1 -1
- package/dist/{chunk-QC73LMAN.js → chunk-7AEC572G.js} +1 -1
- package/dist/{chunk-QSXYNJOW.js → chunk-7IBNOVML.js} +1 -1
- package/dist/chunk-7KDNH6JP.js +10 -0
- package/dist/{chunk-G2GQ67DP.js → chunk-7YRNLGUT.js} +1 -1
- package/dist/chunk-AFCEFOIK.js +4 -0
- package/dist/{chunk-YAOWO2GE.js → chunk-AM5WZPPY.js} +1 -1
- package/dist/{chunk-G3PWEKD7.js → chunk-C4LYBQT3.js} +2 -2
- package/dist/chunk-DJL47DYJ.js +8 -0
- package/dist/chunk-DTM4ZMMJ.js +102 -0
- package/dist/chunk-ELBPBHTE.js +26 -0
- package/dist/{chunk-IGZPQQFP.js → chunk-GEAWRRR7.js} +1 -1
- package/dist/{chunk-UBN6J3ZA.js → chunk-H6QJ4YU7.js} +1 -1
- package/dist/chunk-HFXQU7UZ.js +2 -0
- package/dist/{chunk-GF44B552.js → chunk-HZ46P2GR.js} +1 -1
- package/dist/chunk-I4B2KY4X.js +3 -0
- package/dist/{chunk-RB2YKN77.js → chunk-IECUFWIZ.js} +1 -1
- package/dist/{chunk-KJLOYIWT.js → chunk-IU53F4ZV.js} +1 -1
- package/dist/chunk-J75KVNX5.js +18 -0
- package/dist/{chunk-NUGGT2XH.js → chunk-LOQV5GME.js} +1 -1
- package/dist/chunk-MUPHP5W6.js +27 -0
- package/dist/chunk-NAYAVVTP.js +6 -0
- package/dist/chunk-NFOBDHZK.js +147 -0
- package/dist/{chunk-GSKA5DKJ.js → chunk-NLIOFVMP.js} +1 -1
- package/dist/chunk-P5XBCJYQ.js +7 -0
- package/dist/chunk-PISZLYS5.js +4 -0
- package/dist/{chunk-EQC7WE2O.js → chunk-PTP3WS3N.js} +1 -1
- package/dist/chunk-Q2I65L2W.js +6 -0
- package/dist/chunk-QCEWUUE6.js +55 -0
- package/dist/chunk-QO6PAA7Q.js +17 -0
- package/dist/{chunk-FKAXPYV7.js → chunk-R5RHRG65.js} +1 -1
- package/dist/chunk-T4PKTWZ6.js +17 -0
- package/dist/{chunk-RQZCGHG7.js → chunk-THEZSXZM.js} +1 -1
- package/dist/{chunk-HUAOH2JK.js → chunk-TJWU7DOO.js} +1 -1
- package/dist/{chunk-AKLIPQVR.js → chunk-TPG2T5GH.js} +1 -1
- package/dist/{chunk-KKIFXAJY.js → chunk-UOGJUJCF.js} +1 -1
- package/dist/{chunk-DMG5QABA.js → chunk-V2GYBVSM.js} +1 -1
- package/dist/{chunk-VLWWDXBN.js → chunk-XDERMCAU.js} +1 -1
- package/dist/chunk-Y44AETOW.js +2 -0
- package/dist/{chunk-53O3GMZR.js → chunk-YCNCW4O4.js} +1 -1
- package/dist/{chunk-IT66S24L.js → chunk-YSIYPC4R.js} +1 -1
- package/dist/{chunk-6ATKQYAL.js → chunk-ZWAZ4QU4.js} +1 -1
- package/dist/credentials-52QRPGET.js +2 -0
- package/dist/evidence-O4AON5FU.js +2 -0
- package/dist/exit-manager-IUHAXFJ6.js +2 -0
- package/dist/{generate-headless-ODYT3HT7.js → generate-headless-WG6ZPINI.js} +2 -2
- package/dist/index.js +75 -39
- package/dist/list-commands-VJAL4J3O.js +2 -0
- package/dist/login-flow-VZ2MITFA.js +2 -0
- package/dist/persist-recorded-session-XKPZX7HW.js +3 -0
- package/dist/pipeline-CADTHPDV.js +2 -0
- package/dist/{recording-banner-3XTXU2VL.js → recording-banner-2TNKQHP2.js} +1 -1
- package/dist/require-project-folder-SJG5FQY6.js +2 -0
- package/dist/run-test-md-INJKPE2I.js +13 -0
- package/dist/{skill-installer-GYYMVNE4.js → skill-installer-M6AREQQW.js} +1 -1
- package/dist/tcg-generate-VKFXR5JT.js +2 -0
- package/dist/testmd-actions-4QLHD74A.js +2 -0
- package/dist/{tms-client-NNYXLXZK.js → tms-client-VD3B3SMU.js} +1 -1
- package/dist/token-refresh-2HKIYD4Y.js +2 -0
- package/dist/{validate-basic-4YMRWYLS.js → validate-basic-FO7C2URG.js} +1 -1
- package/dist/{version-check-GU2LS6NM.js → version-check-PHZX5WS7.js} +1 -1
- package/package.json +8 -6
- package/dist/FolderPicker-LI5JKG2S.js +0 -2
- package/dist/HelpView-KHQYGSD2.js +0 -2
- package/dist/SingleShotApp-RO25ZX2E.js +0 -2
- package/dist/TestMdRunView-OXVWHOV3.js +0 -2
- package/dist/chunk-7GOX44H7.js +0 -103
- package/dist/chunk-AH4AXJML.js +0 -2
- package/dist/chunk-AT45XB6X.js +0 -60
- package/dist/chunk-BH6EP2LD.js +0 -85
- package/dist/chunk-BQACGLXW.js +0 -5
- package/dist/chunk-IS62CNJW.js +0 -20
- package/dist/chunk-LOIRZFV3.js +0 -10
- package/dist/chunk-LRKWPAGK.js +0 -2
- package/dist/chunk-MDBXYXSC.js +0 -2
- package/dist/chunk-NAAPNSZD.js +0 -17
- package/dist/chunk-PUU7A26K.js +0 -11
- package/dist/chunk-SQOIKS77.js +0 -6
- package/dist/chunk-UAYCLUUZ.js +0 -27
- package/dist/chunk-XCOU6AYD.js +0 -6
- package/dist/chunk-XCYCX4TU.js +0 -17
- package/dist/exit-manager-V2NW7A7U.js +0 -2
- package/dist/list-commands-PNYMVI6X.js +0 -2
- package/dist/login-flow-FIYH6K4A.js +0 -2
- package/dist/persist-recorded-session-OJPXI4HP.js +0 -3
- package/dist/pipeline-34CX3UBO.js +0 -2
- package/dist/require-project-folder-CFX6U6BZ.js +0 -2
- package/dist/run-test-md-YWKVMQDJ.js +0 -14
- package/dist/tcg-generate-KLY7QZY2.js +0 -2
- package/dist/testmd-actions-OUY5BOAV.js +0 -2
- package/dist/token-refresh-QCHKMPCM.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a,b,c,d,e,f,g,h,i}from"./chunk-C4LYBQT3.js";import"./chunk-FPFOW6BS.js";import"./chunk-WAOCHXJ5.js";import"./chunk-7KDNH6JP.js";import"./chunk-2WVKOZ6W.js";import"./chunk-NLCCBXXV.js";import"./chunk-UOGJUJCF.js";import"./chunk-RZ4F3BHX.js";import"./chunk-IECUFWIZ.js";import"./chunk-HFXQU7UZ.js";import"./chunk-UR6MHSHU.js";export{d as emitNdjson,b as filterByName,g as formatAuthResolutionError,c as paginate,a as parsePagination,i as registerListCommands,e as renderTable,f as resolveTmsBasicAuth,h as validateCreateName};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a}from"./chunk-DTM4ZMMJ.js";import"./chunk-3FN66LTP.js";import"./chunk-GEAWRRR7.js";import"./chunk-UOGJUJCF.js";import"./chunk-RZ4F3BHX.js";import"./chunk-IECUFWIZ.js";import"./chunk-HFXQU7UZ.js";import"./chunk-UR6MHSHU.js";export{a as LoginFlow};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{e as h}from"./chunk-P5XBCJYQ.js";import{a as m,b as I,k as S,o as _}from"./chunk-Q2I65L2W.js";import"./chunk-NFOBDHZK.js";import{a as f}from"./chunk-YCNCW4O4.js";import"./chunk-L5LI2JF4.js";import"./chunk-HFXQU7UZ.js";import"./chunk-UR6MHSHU.js";async function v(e,s={}){e.flushRecorder();let o=e.recorder?.lastWrittenPath??null;if(!o)return e.log("info","PERSIST_SKIPPED","No recorded path \u2014 recorder.flush no-op",{reason:e.sessionName?"recorder_flush_failed":"no_session_name",session_name:e.sessionName}),null;let p;try{p=_(o)}catch(t){throw e.log("error","PERSIST_RESOLVE_FAILED","resolveTestMd threw",{error:t.message,recorded_path:o}),t}let i=e.getRunsAsStepRecords(),u=e.getFlows(),a=[],c=0;for(let t=0;t<i.length;t++){let r=i[t],l=u.slice(c,c+r.totalRunDirs);c+=r.totalRunDirs;let g=l.find(n=>n.status==="failed"||n.status==="error"),T=g?"failed":l.length===0?"skipped":"passed";a.push({rootStepIndex:t+1,status:T,duration_s:l.reduce((n,E)=>n+(E.duration??0),0),reason:g?.reason})}let P=a.some(t=>t.status==="failed")?"failed":"passed",D=new f().load().code_export?.language==="javascript"?"javascript":"python",d=I(o);e.log("info","PERSIST_START","Building staging dir",{recorded_path:o,output_dir:d,session_dir:e.sessionDir,step_count:i.length,flow_count:u.length});try{await h({resolvedTest:p,sessionDir:e.sessionDir,stepRunRecords:i,outcomes:a,overallStatus:P,startedISO:e.startedAt,durationS:a.reduce((t,r)=>t+(r.duration_s??0),0),sessionId:e.sessionId,commitId:e.sessionId,tmsIds:{testId:e.testId??void 0,testcaseId:s.testcaseId,projectId:s.projectId,folderId:s.folderId,orgId:s.orgId??e.orgId??void 0,sessionName:e.sessionName??m(o)},codeExportDir:s.codeExportDir,codeExportLanguage:D,packTestDir:s.packTestDir}),e.log("info","PERSIST_STAGING_OK","Staging dir built",{output_dir:d}),S(d),e.log("info","PERSIST_OK","Persist complete",{output_dir:d})}catch(t){let r=t;e.log("error","PERSIST_FAILED","staging build / atomic replace failed",{error:r.message,stack:r.stack,output_dir:d}),process.stderr.write(`[persist] staging build / atomic replace failed: ${r.message}
|
|
3
|
+
`)}return{recordedTestPath:o,outputDir:d}}export{v as persistRecordedSession};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a,b,c}from"./chunk-54TKNWXF.js";import"./chunk-2YQ6TW77.js";import"./chunk-DJL47DYJ.js";import"./chunk-NFOBDHZK.js";import"./chunk-WAOCHXJ5.js";import"./chunk-L5LI2JF4.js";import"./chunk-2WVKOZ6W.js";import"./chunk-NLCCBXXV.js";import"./chunk-UOGJUJCF.js";import"./chunk-RZ4F3BHX.js";import"./chunk-HFXQU7UZ.js";import"./chunk-UR6MHSHU.js";export{c as UploadPipeline,b as packPresignEntry,a as readPackForUpload};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
2
|
import{a as n}from"./chunk-3MSXQU2C.js";import"./chunk-UR6MHSHU.js";function p(t){let s=t.sessionName!==null,e={type:"recording_state",enabled:!0,session_id:t.sessionId,persist:s};return t.sessionName&&(e.session_name=t.sessionName),t.testPath&&(e.test_path=t.testPath),t.outputPath&&(e.output_path=t.outputPath),e}async function g(t){if(t.isAgent){process.stdout.write(JSON.stringify(p(t))+`
|
|
3
|
-
`);return}let s=(await import("./react-QWOAB3TB.js")).default,{render:e,useApp:a}=await import("./build-JIKYOZUH.js"),{useEffect:o}=s,{InfoBox:r}=await import("./InfoBox-
|
|
3
|
+
`);return}let s=(await import("./react-QWOAB3TB.js")).default,{render:e,useApp:a}=await import("./build-JIKYOZUH.js"),{useEffect:o}=s,{InfoBox:r}=await import("./InfoBox-FPAWQZGQ.js"),u=t.sessionName?[{label:"session",value:t.sessionName},{label:"test",value:n(t.testPath??"")},{label:"output",value:n(t.outputPath??"")}]:[{label:"session",value:"ephemeral"},{label:"note",value:"use /name <name> to persist this session"}];function l(){let{exit:i}=a();return o(()=>{let c=setTimeout(()=>i(),50);return()=>clearTimeout(c)},[i]),s.createElement(r,{title:"Recording",titleColor:"#ff9500",rows:u})}await e(s.createElement(l),{stdout:process.stderr}).waitUntilExit()}export{p as buildRecordingStateEvent,g as printRecordingBanner};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{b as a,c as b,d as c,e as d,f as e,g as f,h as g}from"./chunk-QO6PAA7Q.js";import"./chunk-2WVKOZ6W.js";import"./chunk-NLCCBXXV.js";import"./chunk-VE3SUJMA.js";import"./chunk-UOGJUJCF.js";import"./chunk-RZ4F3BHX.js";import"./chunk-HFXQU7UZ.js";import"./chunk-UR6MHSHU.js";export{d as buildAutoDefaultAnnouncement,f as buildAutoDefaultedEvent,e as buildAutoDefaultedNdjson,c as buildRemediationMessage,b as decideGateAction,a as loadCachedIds,g as requireProjectFolder};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as A}from"./chunk-I4B2KY4X.js";import{E as M,F as K,G as H,H as V,I as Y}from"./chunk-QCEWUUE6.js";import{a as k,b as L}from"./chunk-J75KVNX5.js";import{a as h,b as E}from"./chunk-TPG2T5GH.js";import"./chunk-P5XBCJYQ.js";import{o as _}from"./chunk-Q2I65L2W.js";import"./chunk-C5UNZ6ZY.js";import"./chunk-S3DAAAE5.js";import"./chunk-54TKNWXF.js";import"./chunk-2YQ6TW77.js";import"./chunk-DJL47DYJ.js";import"./chunk-NFOBDHZK.js";import{c as R}from"./chunk-T4PKTWZ6.js";import{a as x}from"./chunk-YCNCW4O4.js";import"./chunk-FPFOW6BS.js";import"./chunk-WAOCHXJ5.js";import"./chunk-L5LI2JF4.js";import"./chunk-PISZLYS5.js";import"./chunk-NAYAVVTP.js";import{e as b,f as T,g as S}from"./chunk-7KDNH6JP.js";import"./chunk-QO6PAA7Q.js";import"./chunk-2WVKOZ6W.js";import"./chunk-NLCCBXXV.js";import"./chunk-VE3SUJMA.js";import"./chunk-4IOOBSNB.js";import"./chunk-GEAWRRR7.js";import{a as C}from"./chunk-UOGJUJCF.js";import"./chunk-RZ4F3BHX.js";import"./chunk-E47GFYXA.js";import{a as v}from"./chunk-IECUFWIZ.js";import"./chunk-HFXQU7UZ.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";import{resolve as U}from"path";import{existsSync as D}from"fs";function O(){return{register:(n,r)=>b(n,r),deregister:n=>T(n),cleanup:(n,r)=>S(n,r),remoteLogger:null}}async function le(n,r){let t=U(n);if(!D(t))return process.stderr.write(`error: file not found: ${t}
|
|
3
|
+
`),2;k(t);let i=!process.stdin.isTTY||!!r.agent,c=O(),a;try{a=_(t)}catch(e){return process.stderr.write(`error: ${e.message}
|
|
4
|
+
`),2}if(a.steps.length===0)return process.stderr.write(`info: no steps in ${t}; nothing to run.
|
|
5
|
+
`),0;let s;try{s=G(r)}catch(e){if(e instanceof m)return process.stderr.write(e.message),e.exitCode;throw e}let o=new v,l=new x,u=!!(r.username&&r.accessKey);await L({isInteractive:!!process.stdin.isTTY&&!r.agent&&!u,creds:o,config:l});let I=o.getActiveProfile()??"default",f=r.env??void 0??o.getDefaultEnv()??"prod",N=C(f),j="v16-alpha",p;try{p=await E({creds:o,env:f,usernameFlag:r.username,accessKeyFlag:r.accessKey,log:()=>{}})}catch(e){return e instanceof h&&e.code==="not_authenticated"?process.stderr.write(`error: Not authenticated. Choose one:
|
|
6
|
+
\u2022 Pass credentials inline: --username <user> --access-key <key>
|
|
7
|
+
\u2022 Run 'kane-cli login --oauth' (browser-based)
|
|
8
|
+
\u2022 Run 'kane-cli login --username <user> --access-key <key>'
|
|
9
|
+
`):e instanceof h&&e.code==="refresh_failed"?process.stderr.write(`error: Token refresh failed. Run 'kane-cli login' to re-authenticate.
|
|
10
|
+
`):process.stderr.write(`error: auth resolution failed: ${e.message}
|
|
11
|
+
`),2}let y=String(p.resolvedCreds?.org_id??"");if(!y)return process.stderr.write("error: TMS did not return an org_id. Run `kane-cli login` again.\n"),2;{let{readMetaIfExists:e,assertOrgMatchOrExit:g}=await import("./testmd-actions-4QLHD74A.js"),d=g(e(t),y);if(d!==null)return d}let w=new R,F=A({isAgent:i,log:(e,g,d,$)=>w.log(e,g,d,$)}),P={path:t,cwd:process.cwd(),opts:r,isAgent:i,disableAskUser:!process.stdin.isTTY,resolved:a,resolvedAuth:p,cliOverrides:s,environment:f,envConfig:N,profile:I,model:j,creds:o,configStore:l,session:w};try{return(await M(P,F,c)).exitCode}catch(e){return process.stderr.write(`error: ${e.message}
|
|
12
|
+
`),2}}var m=class extends Error{constructor(t,i){super(t);this.exitCode=i;this.name="CliArgError"}};function G(n){let r={mode:"mode",assertionMode:"assertion_mode",maxSteps:"max_steps",timeout:"timeout",globalContext:"global_context",localContext:"local_context",codeExport:"code_export",codeLanguage:"code_language",headless:"headless",cdpEndpoint:"cdp_endpoint",wsEndpoint:"ws_endpoint"},t=new Set(["max_steps","timeout"]),i={};for(let[c,a]of Object.entries(r)){let s=n[c];if(s===void 0||s==="")continue;let o=s;if(t.has(a)&&(o=Number(s),Number.isNaN(o))){let l="--"+c.replace(/[A-Z]/g,u=>"-"+u.toLowerCase());throw new m(`error: ${l} must be a number
|
|
13
|
+
`,2)}i[a]=o}return i}export{Y as applyCliStepConfig,H as buildStepRunVariables,K as buildTestLevelVariables,V as replayVariablesForStep,le as runTestMdFile};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as p,b as g}from"./chunk-
|
|
2
|
+
import{a as p,b as g}from"./chunk-R5RHRG65.js";import{b as m}from"./chunk-TJWU7DOO.js";import"./chunk-UOGJUJCF.js";import{a as d}from"./chunk-RZ4F3BHX.js";import"./chunk-IECUFWIZ.js";import{a as f,g as a,h as u}from"./chunk-HFXQU7UZ.js";import"./chunk-UR6MHSHU.js";import{mkdirSync as y,writeFileSync as w,readFileSync as S,rmSync as c,cpSync as v,createWriteStream as T,existsSync as b}from"fs";import{join as s}from"path";import{tmpdir as k}from"os";import{spawn as h}from"child_process";import{Readable as I}from"stream";import{pipeline as $}from"stream/promises";function E(t){try{return S(s(t,"VERSION"),"utf-8").trim()||null}catch{return null}}function L(t,r,l){return l?t!==r:t===null||m(t,r)>0}function C(t){let r=a.split("/").pop()??a;return`https://registry.npmjs.org/${a}/-/${r}-${t}.tgz`}var R=5e3,A=6e4;async function x(){let t=new AbortController,r=setTimeout(()=>t.abort(),R);try{let l=await d(p(),{headers:{Accept:"application/json"},signal:t.signal});if(!l.ok)throw new Error(`Controller returned ${l.status} fetching skill version map`);let i=await l.json(),n=g(i,f);if(!n)throw new Error("No compatible skill version found for this kane-cli build");return n}finally{clearTimeout(r)}}async function _(t){let r=C(t),l=new AbortController,i=setTimeout(()=>l.abort(),A);try{let n=await d(r,{headers:{Accept:"application/octet-stream"},signal:l.signal});if(!n.ok||!n.body)throw new Error(`Failed to download skill tarball (${n.status})`);let e=s(k(),`kane-cli-skill-${t}-${process.pid}.tgz`);return await $(I.fromWeb(n.body),T(e)),e}finally{clearTimeout(i)}}function M(t,r){return new Promise((l,i)=>{y(r,{recursive:!0});let n=h("tar",["-xzf",t,"-C",r,"--strip-components=2","package/skills"],{stdio:["ignore","ignore","pipe"]}),e="";n.stderr?.on("data",o=>{e+=o.toString()}),n.on("error",o=>i(o)),n.on("close",o=>{o===0?l():i(new Error(`tar exited ${o}${e?`: ${e.trim()}`:""}`))})})}async function W(t){let r;try{r=t??await x()}catch(e){return{status:"failed",version:t??"unknown",installedTargets:0,error:e instanceof Error?e.message:String(e)}}let l=u.filter(({dir:e})=>L(E(e),r,!!t));if(l.length===0)return{status:"already-installed",version:r,installedTargets:0};let i=null,n=null;try{if(n=await _(r),i=s(k(),`kane-cli-skill-${r}-stage-${process.pid}`),c(i,{recursive:!0,force:!0}),await M(n,i),!b(s(i,"SKILL.md")))throw new Error(`Unexpected skill tarball layout for v${r}: SKILL.md not at package/skills/ root`);let e=0;for(let{dir:o}of l)try{c(o,{recursive:!0,force:!0}),y(o,{recursive:!0}),v(i,o,{recursive:!0,force:!0}),w(s(o,"VERSION"),r+`
|
|
3
3
|
`),e++}catch{}return e===0?{status:"failed",version:r,installedTargets:0,error:"Could not write to any agent skill directory"}:{status:"installed",version:r,installedTargets:e}}catch(e){return{status:"failed",version:r,installedTargets:0,error:e instanceof Error?e.message:String(e)}}finally{if(n)try{c(n,{force:!0})}catch{}if(i)try{c(i,{recursive:!0,force:!0})}catch{}}}function D(t){switch(t.status){case"installed":return`Installed kane-cli skill v${t.version} (${t.installedTargets}/${u.length} agent dirs). Restart your AI agent (Claude Code / Codex CLI / Gemini CLI) to load it.`;case"already-installed":return`kane-cli skill v${t.version} already installed.`;case"failed":return`Failed to install kane-cli skill: ${t.error??"unknown error"}`}}export{D as formatInstallResult,W as installSkill,L as targetNeedsInstall};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{d as a}from"./chunk-MUPHP5W6.js";import"./chunk-3MSXQU2C.js";import"./chunk-PTP3WS3N.js";import"./chunk-7AEC572G.js";import"./chunk-ELBPBHTE.js";import"./chunk-LOQV5GME.js";import"./chunk-THEZSXZM.js";import"./chunk-H6QJ4YU7.js";import"./chunk-NLIOFVMP.js";import"./chunk-QCEWUUE6.js";import"./chunk-J75KVNX5.js";import"./chunk-TPG2T5GH.js";import"./chunk-P5XBCJYQ.js";import"./chunk-Q2I65L2W.js";import"./chunk-C5UNZ6ZY.js";import"./chunk-S3DAAAE5.js";import"./chunk-54TKNWXF.js";import"./chunk-2YQ6TW77.js";import"./chunk-DTM4ZMMJ.js";import"./chunk-Y44AETOW.js";import"./chunk-3FN66LTP.js";import"./chunk-DJL47DYJ.js";import"./chunk-NFOBDHZK.js";import"./chunk-7YRNLGUT.js";import"./chunk-T4PKTWZ6.js";import"./chunk-YCNCW4O4.js";import"./chunk-FPFOW6BS.js";import"./chunk-WAOCHXJ5.js";import"./chunk-L5LI2JF4.js";import"./chunk-AFCEFOIK.js";import"./chunk-V2GYBVSM.js";import"./chunk-PISZLYS5.js";import"./chunk-NAYAVVTP.js";import"./chunk-IU53F4ZV.js";import"./chunk-6E5UYAEB.js";import"./chunk-XDERMCAU.js";import"./chunk-YCCUBQY4.js";import"./chunk-AM5WZPPY.js";import"./chunk-7KDNH6JP.js";import"./chunk-QO6PAA7Q.js";import"./chunk-2WVKOZ6W.js";import"./chunk-NLCCBXXV.js";import"./chunk-VE3SUJMA.js";import"./chunk-4IOOBSNB.js";import"./chunk-GEAWRRR7.js";import"./chunk-UOGJUJCF.js";import"./chunk-RZ4F3BHX.js";import"./chunk-E47GFYXA.js";import"./chunk-IECUFWIZ.js";import"./chunk-ZWAZ4QU4.js";import"./chunk-7IBNOVML.js";import{a as o}from"./chunk-C6S4IEBC.js";import"./chunk-HZ46P2GR.js";import"./chunk-YSIYPC4R.js";import"./chunk-HFXQU7UZ.js";import{a as t}from"./chunk-HCBYKLMW.js";import{c as n}from"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import{e as r}from"./chunk-UR6MHSHU.js";var e=r(t(),1);async function p(i){let c=i.scenarioLimit!==void 0||i.perScenarioLimit!==void 0?{scenarioLimit:i.scenarioLimit,perScenarioLimit:i.perScenarioLimit}:void 0,{waitUntilExit:m}=n((0,e.jsx)(o,{children:(0,e.jsx)(a,{initialChatMode:"generate",initialObjective:i.objective,initialGenerateLimits:c})}),{exitOnCtrlC:!1});await m()}export{p as runGenerate};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{e as a,f as b,g as c,h as d,i as e,j as f,k as g,l as h,m as i,n as j,o as k,p as l,q as m}from"./chunk-ELBPBHTE.js";import"./chunk-J75KVNX5.js";import"./chunk-TPG2T5GH.js";import"./chunk-Q2I65L2W.js";import"./chunk-2YQ6TW77.js";import"./chunk-YCNCW4O4.js";import"./chunk-FPFOW6BS.js";import"./chunk-WAOCHXJ5.js";import"./chunk-L5LI2JF4.js";import"./chunk-AM5WZPPY.js";import"./chunk-7KDNH6JP.js";import"./chunk-NLCCBXXV.js";import"./chunk-4IOOBSNB.js";import"./chunk-GEAWRRR7.js";import"./chunk-UOGJUJCF.js";import"./chunk-RZ4F3BHX.js";import"./chunk-IECUFWIZ.js";import"./chunk-YSIYPC4R.js";import"./chunk-HFXQU7UZ.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{i as ExportError,c as assertOrgMatchOrExit,j as exportTestmd,b as metaMatchesOrg,a as readMetaIfExists,d as resolveCurrentOrgId,l as resolveSyncAuth,h as runDeleteAction,k as runExportAction,e as runListAction,f as runListTui,g as runStatusAction,m as runSyncAction};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a}from"./chunk-
|
|
2
|
+
import{a}from"./chunk-2WVKOZ6W.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-UR6MHSHU.js";export{a as TmsClient};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a}from"./chunk-4IOOBSNB.js";import"./chunk-GEAWRRR7.js";import"./chunk-UOGJUJCF.js";import"./chunk-RZ4F3BHX.js";import"./chunk-HFXQU7UZ.js";import"./chunk-UR6MHSHU.js";export{a as refreshOAuthToken};
|
|
@@ -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-UOGJUJCF.js";import"./chunk-HFXQU7UZ.js";import"./chunk-UR6MHSHU.js";async function l(n,o,r){let{ControllerClient:e}=await import("./controller-client-RD2YEMAH.js");await new e(t(n).controllerBaseUrl,{username:o,accessKey:r}).getTmsCredentials()}export{l as validateBasicAuth};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c,d}from"./chunk-
|
|
2
|
+
import{a,b,c,d}from"./chunk-TJWU7DOO.js";import"./chunk-RZ4F3BHX.js";import"./chunk-HFXQU7UZ.js";import"./chunk-UR6MHSHU.js";export{d as checkForUpdate,b as compareVersions,c as getSeverity,a as getUpdateCommand};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@testmuai/kane-cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "KaneAI Terminal UI — browser automation testing agent",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"README.md"
|
|
15
15
|
],
|
|
16
16
|
"dependencies": {
|
|
17
|
+
"@testmuai/evidence-cli": "^0.1.6",
|
|
17
18
|
"archiver": "^7.0.1",
|
|
18
19
|
"chalk": "^5.3.0",
|
|
19
20
|
"commander": "^12.0.0",
|
|
@@ -21,14 +22,15 @@
|
|
|
21
22
|
"js-yaml": "^4.1.1",
|
|
22
23
|
"open": "^10.1.0",
|
|
23
24
|
"react": "^18.3.1",
|
|
25
|
+
"semver": "^7.8.4",
|
|
24
26
|
"ws": "^8.20.0"
|
|
25
27
|
},
|
|
26
28
|
"optionalDependencies": {
|
|
27
|
-
"@testmuai/kane-cli-darwin-arm64": "0.
|
|
28
|
-
"@testmuai/kane-cli-darwin-x64": "0.
|
|
29
|
-
"@testmuai/kane-cli-linux-x64": "0.
|
|
30
|
-
"@testmuai/kane-cli-linux-arm64": "0.
|
|
31
|
-
"@testmuai/kane-cli-win-x64": "0.
|
|
29
|
+
"@testmuai/kane-cli-darwin-arm64": "0.5.0",
|
|
30
|
+
"@testmuai/kane-cli-darwin-x64": "0.5.0",
|
|
31
|
+
"@testmuai/kane-cli-linux-x64": "0.5.0",
|
|
32
|
+
"@testmuai/kane-cli-linux-arm64": "0.5.0",
|
|
33
|
+
"@testmuai/kane-cli-win-x64": "0.5.0",
|
|
32
34
|
"sharp": "^0.34.5"
|
|
33
35
|
},
|
|
34
36
|
"publishConfig": {
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b}from"./chunk-VLWWDXBN.js";import"./chunk-YCCUBQY4.js";import"./chunk-YAOWO2GE.js";import"./chunk-LPUQ4HWQ.js";import"./chunk-NLCCBXXV.js";import"./chunk-KKIFXAJY.js";import"./chunk-RZ4F3BHX.js";import"./chunk-IT66S24L.js";import"./chunk-LRKWPAGK.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{b as FolderPicker,a as formatFolderLine};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as f,b as i,x as t}from"./chunk-LRKWPAGK.js";import{a as T}from"./chunk-HCBYKLMW.js";import{a as n,b as o,j as p,k as x}from"./chunk-C44QQJR4.js";import{a as b}from"./chunk-6YGTRKDT.js";import{e as h}from"./chunk-UR6MHSHU.js";var w=h(b(),1);var e=h(T(),1),S="https://www.testmuai.com/support/docs/kane-cli-introduction",v="https://github.com/LambdaTest/kane-cli/issues";function k(){let{exit:l}=p(),{stdout:r}=x(),c=r?.columns??80;return(0,w.useEffect)(()=>{let m=setTimeout(()=>l(),50);return()=>clearTimeout(m)},[l]),(0,e.jsxs)(n,{flexDirection:"column",children:[(0,e.jsxs)(n,{paddingX:1,paddingTop:1,flexDirection:"column",children:[(0,e.jsx)(o,{color:t.orange,bold:!0,children:i}),(0,e.jsxs)(n,{children:[(0,e.jsx)(o,{color:t.dim,children:"Browser automation powered by AI "}),(0,e.jsxs)(o,{color:t.muted,children:[" v",f]})]})]}),(0,e.jsx)(o,{children:" "}),(0,e.jsxs)(d,{title:"USAGE",children:[(0,e.jsx)(g,{cmd:`${i}`,desc:"Single-shot prompt (no args, TTY)"}),(0,e.jsx)(g,{cmd:`${i} --tui`,desc:"Full interactive TUI",highlight:!0}),(0,e.jsx)(g,{cmd:`${i} run "<objective>"`,desc:"Inline objective"}),(0,e.jsx)(g,{cmd:`${i} testmd run <path>.md`,desc:"Replay a saved *_test.md file"})]}),(0,e.jsxs)(d,{title:"HELP",children:[(0,e.jsx)(g,{cmd:`${i} --help`,desc:"Show this help (long form)"}),(0,e.jsx)(g,{cmd:`${i} -h`,desc:"Show this help (short form)"}),(0,e.jsx)(g,{cmd:`${i} help`,desc:"Show this help (subcommand form)"}),(0,e.jsxs)(n,{marginLeft:2,marginTop:0,flexDirection:"column",children:[(0,e.jsxs)(o,{color:t.dim,children:["These are the only supported help invocations. Anything else (e.g. ",(0,e.jsx)(o,{color:t.orange,children:"-help"}),") is an unknown flag."]}),(0,e.jsxs)(o,{color:t.dim,children:["Terminal tab-completion is a shell feature; ",i," does not ship shell-completion scripts, so any flag your shell suggests is a generic guess \u2014 not from ",i,"."]})]})]}),(0,e.jsxs)(d,{title:"COMMANDS",children:[(0,e.jsx)(a,{cmd:"run",args:"<objective>",desc:"Run an objective (inline string)",highlight:!0}),(0,e.jsx)(a,{cmd:"testmd",args:"run|list|status|delete|export",desc:"Manage *_test.md files"}),(0,e.jsx)(a,{cmd:"login",desc:"Auth setup (interactive, --oauth, or --username)"}),(0,e.jsx)(a,{cmd:"logout",desc:"Revoke tokens + delete profile"}),(0,e.jsx)(a,{cmd:"whoami",desc:"Show authenticated identity"}),(0,e.jsx)(a,{cmd:"config",args:"show|set-mode|set-assertion-mode|\u2026",desc:"Chrome, run & generate settings"}),(0,e.jsx)(a,{cmd:"profiles",args:"list|switch|delete",desc:"Manage auth profiles"}),(0,e.jsx)(a,{cmd:"changelog",args:"[--all]",desc:"Show recent release notes"})]}),(0,e.jsxs)(d,{title:"TESTMD ACTIONS",children:[(0,e.jsx)(a,{cmd:"testmd run",args:"<path>",desc:"Replay a saved *_test.md file",highlight:!0}),(0,e.jsx)(a,{cmd:"testmd list",desc:"List *_test.md files in cwd (recursive)"}),(0,e.jsx)(a,{cmd:"testmd status",args:"<path>",desc:"Print local meta.json for a test"}),(0,e.jsx)(a,{cmd:"testmd delete",args:"<path>",desc:"Remove output-<stem>/ and the source file"}),(0,e.jsx)(a,{cmd:"testmd export",args:"<path> --language <py|js>",desc:"Generate standalone Playwright code"})]}),(0,e.jsxs)(d,{title:"RUN FLAGS",children:[(0,e.jsx)(s,{long:"--max-steps",arg:"<n>",desc:"Max agent steps (default: 30)"}),(0,e.jsx)(s,{long:"--timeout",arg:"<sec>",desc:"Kill run after N seconds"}),(0,e.jsx)(s,{long:"--headless",desc:"No visible browser window"}),(0,e.jsx)(s,{long:"--mode",arg:"<action|testing>",desc:"Run mode (default: testing)"}),(0,e.jsx)(s,{long:"--name",arg:"<name>",desc:"Persist session under this name"}),(0,e.jsx)(s,{long:"--variables",arg:"<json>",desc:"Inline variables as JSON"}),(0,e.jsx)(s,{long:"--variables-file",arg:"<path>",desc:"Load variables from file"}),(0,e.jsx)(s,{long:"--session-context",arg:"<json>",desc:"Prior runs context JSON"}),(0,e.jsx)(s,{long:"--global-context",arg:"<file>",desc:"Override global context markdown"}),(0,e.jsx)(s,{long:"--local-context",arg:"<file>",desc:"Override local context markdown"}),(0,e.jsx)(s,{long:"--ws-endpoint",arg:"<url>",desc:"Remote browser (LambdaTest)"}),(0,e.jsx)(s,{long:"--cdp-endpoint",arg:"<url>",desc:"Connect to existing Chrome CDP"}),(0,e.jsx)(s,{long:"--task-skills",desc:"Domain-specific task skills (experimental)"}),(0,e.jsx)(s,{long:"--code-export",desc:"Generate code export after upload"}),(0,e.jsx)(s,{long:"--code-language",arg:"<lang>",desc:"Code export language: python | javascript"}),(0,e.jsx)(s,{long:"--skip-code-validation",desc:"Skip post-codegen validation"}),(0,e.jsx)(s,{long:"--username",arg:"<user>",desc:"Basic auth (skip OAuth)"}),(0,e.jsx)(s,{long:"--access-key",arg:"<key>",desc:"Basic auth access key"}),(0,e.jsx)(s,{long:"--env",arg:"<name>",desc:"Environment (prod or stage)"}),(0,e.jsx)(s,{long:"--agent",desc:"NDJSON output (no UI)",highlight:!0})]}),(0,e.jsxs)(d,{title:"EXAMPLES",children:[(0,e.jsx)(u,{label:"Inline objective",cmd:`${i} run "Search for laptop"`}),(0,e.jsx)(u,{label:"Replay a saved test",cmd:`${i} testmd run smoke_test.md`}),(0,e.jsx)(u,{label:"Variables",cmd:`${i} run "Login as {{user}}" --variables '{"user":{"value":"alice"}}'`}),(0,e.jsx)(u,{label:"Agent mode (NDJSON)",cmd:`${i} run "Add to cart" --agent | jq .status`})]}),(0,e.jsx)(d,{title:"TEST FILES",children:(0,e.jsxs)(n,{marginLeft:2,flexDirection:"column",children:[(0,e.jsxs)(o,{color:t.dim,children:[(0,e.jsx)(o,{color:t.orange,children:"*_test.md"})," \u2014 markdown test files with YAML frontmatter and ",(0,e.jsx)(o,{color:t.orange,children:"## "}),"step headings."]}),(0,e.jsxs)(o,{color:t.dim,children:["Run with ",(0,e.jsxs)(o,{color:t.orange,children:[i," testmd run path/to/foo_test.md"]}),". (`.md` paths are not accepted by `",i," run`.)"]}),(0,e.jsxs)(o,{color:t.dim,children:["Sessions you run in TUI auto-save to ",(0,e.jsx)(o,{color:t.orange,children:"<cwd>/.testmuai/tests/<name>_test.md"})," (testing mode prompts on exit)."]})]})}),(0,e.jsxs)(n,{flexDirection:"column",marginTop:0,paddingX:1,children:[(0,e.jsx)(o,{color:t.muted,children:"\u2500".repeat(Math.min(c-2,70))}),(0,e.jsxs)(n,{gap:3,children:[(0,e.jsxs)(n,{children:[(0,e.jsx)(o,{color:t.dim,children:"Docs "}),(0,e.jsx)(o,{color:t.orange,underline:!0,children:S})]}),(0,e.jsxs)(n,{children:[(0,e.jsx)(o,{color:t.dim,children:"Bugs "}),(0,e.jsx)(o,{color:t.orange,underline:!0,children:v})]})]})]}),(0,e.jsx)(o,{children:" "})]})}function d({title:l,children:r}){return(0,e.jsxs)(n,{flexDirection:"column",marginBottom:1,children:[(0,e.jsx)(n,{marginLeft:1,children:(0,e.jsx)(o,{bold:!0,color:t.dim,children:l})}),r]})}function g({cmd:l,desc:r,highlight:c}){return(0,e.jsxs)(n,{marginLeft:2,children:[(0,e.jsxs)(n,{width:40,children:[(0,e.jsx)(o,{color:t.dim,children:"$ "}),(0,e.jsx)(o,{color:c?t.orange:t.orange,children:l})]}),(0,e.jsx)(o,{color:t.dim,children:r})]})}function a({cmd:l,args:r,desc:c,highlight:m}){return(0,e.jsxs)(n,{marginLeft:2,children:[(0,e.jsx)(n,{width:16,children:(0,e.jsx)(o,{color:m?t.orange:t.green,bold:!0,children:l})}),(0,e.jsx)(n,{width:32,children:r?(0,e.jsx)(o,{color:t.dim,children:r}):null}),(0,e.jsx)(o,{color:t.dim,children:c})]})}function s({long:l,arg:r,desc:c,highlight:m}){return(0,e.jsxs)(n,{marginLeft:2,children:[(0,e.jsxs)(n,{width:30,children:[(0,e.jsx)(o,{color:m?t.orange:t.orange,children:l}),r&&(0,e.jsxs)(o,{color:t.dim,children:[" ",r]})]}),(0,e.jsx)(o,{color:t.dim,children:c})]})}function u({label:l,cmd:r}){return(0,e.jsxs)(n,{marginLeft:2,flexDirection:"column",children:[(0,e.jsxs)(o,{color:t.dim,children:["# ",l]}),(0,e.jsxs)(o,{color:t.orange,children:["$ ",r]})]})}export{k as HelpView};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a}from"./chunk-HPZREZKG.js";import"./chunk-G2GQ67DP.js";import"./chunk-NAAPNSZD.js";import"./chunk-L5LI2JF4.js";import"./chunk-53O3GMZR.js";import"./chunk-FPFOW6BS.js";import"./chunk-WAOCHXJ5.js";import"./chunk-OHT5RY5E.js";import"./chunk-VLWWDXBN.js";import"./chunk-YCCUBQY4.js";import"./chunk-YAOWO2GE.js";import"./chunk-LOIRZFV3.js";import"./chunk-LPUQ4HWQ.js";import"./chunk-NLCCBXXV.js";import"./chunk-VE3SUJMA.js";import"./chunk-RB2YKN77.js";import"./chunk-IGZPQQFP.js";import"./chunk-KKIFXAJY.js";import"./chunk-RZ4F3BHX.js";import"./chunk-IT66S24L.js";import"./chunk-LRKWPAGK.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{a as SingleShotApp};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{h as a}from"./chunk-XCOU6AYD.js";import"./chunk-BQACGLXW.js";import"./chunk-DMG5QABA.js";import"./chunk-LOIRZFV3.js";import"./chunk-KKIFXAJY.js";import"./chunk-6ATKQYAL.js";import"./chunk-QSXYNJOW.js";import"./chunk-C6S4IEBC.js";import"./chunk-LRKWPAGK.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{a as TestMdRunView};
|
package/dist/chunk-7GOX44H7.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as D}from"./chunk-RB2YKN77.js";import{a as A}from"./chunk-IGZPQQFP.js";import{p as S,q as C,r as P,s as U,t as N}from"./chunk-LRKWPAGK.js";import{createServer as Oe}from"http";import{randomBytes as He}from"crypto";import{URL as $e}from"url";import Z from"process";import{Buffer as ee}from"buffer";import re from"path";import{fileURLToPath as ke}from"url";import{promisify as Le}from"util";import te from"child_process";import Me,{constants as Ie}from"fs/promises";import Y from"process";import G,{constants as me}from"fs/promises";import j from"process";import le from"os";import L from"fs";import se from"fs";import z from"fs";var E;function ie(){try{return z.statSync("/.dockerenv"),!0}catch{return!1}}function ae(){try{return z.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function B(){return E===void 0&&(E=ie()||ae()),E}var k,ce=()=>{try{return se.statSync("/run/.containerenv"),!0}catch{return!1}};function u(){return k===void 0&&(k=ce()||B()),k}var K=()=>{if(j.platform!=="linux")return!1;if(le.release().toLowerCase().includes("microsoft"))return!u();try{if(L.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft"))return!u()}catch{}return L.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop")||L.existsSync("/run/WSL")?!u():!1},d=j.env.__IS_WSL_TEST__?K:K();var de=(()=>{let e="/mnt/",r;return async function(){if(r)return r;let t="/etc/wsl.conf",n=!1;try{await G.access(t,me.F_OK),n=!0}catch{}if(!n)return e;let o=await G.readFile(t,{encoding:"utf8"}),i=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(o);return i?(r=i.groups.mountPoint.trim(),r=r.endsWith("/")?r:`${r}/`,r):e}})(),fe=async()=>`${await de()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,M=async()=>d?fe():`${Y.env.SYSTEMROOT||Y.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;function f(e,r,t){let n=o=>Object.defineProperty(e,r,{value:o,enumerable:!0,writable:!0});return Object.defineProperty(e,r,{configurable:!0,enumerable:!0,get(){let o=t();return n(o),o},set(o){n(o)}}),e}import{promisify as Pe}from"util";import O from"process";import{execFile as Ae}from"child_process";import{promisify as pe}from"util";import ue from"process";import{execFile as ge}from"child_process";var he=pe(ge);async function I(){if(ue.platform!=="darwin")throw new Error("macOS only");let{stdout:e}=await he("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),t=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??"com.apple.Safari";return t==="com.apple.safari"?"com.apple.Safari":t}import we from"process";import{promisify as xe}from"util";import{execFile as ye,execFileSync as cr}from"child_process";var ve=xe(ye);async function X(e,{humanReadableOutput:r=!0,signal:t}={}){if(we.platform!=="darwin")throw new Error("macOS only");let n=r?[]:["-ss"],o={};t&&(o.signal=t);let{stdout:i}=await ve("osascript",["-e",e,n],o);return i.trim()}async function T(e){return X(`tell application "Finder" to set app_path to application file id "${e}" as string
|
|
3
|
-
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}import{promisify as be}from"util";import{execFile as Se}from"child_process";var Ce=be(Se),y={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},ur=new Map(Object.entries(y)),F=class extends Error{};async function _(e=Ce){let{stdout:r}=await e("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),t=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(r);if(!t)throw new F(`Cannot find Windows browser in stdout: ${JSON.stringify(r)}`);let{id:n}=t.groups,o=n.lastIndexOf("."),i=n.lastIndexOf("-"),c=o===-1?void 0:n.slice(0,o),a=i===-1?void 0:n.slice(0,i);return y[n]??y[c]??y[a]??{name:n,id:n}}var Ee=Pe(Ae),Be=e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,r=>r.toUpperCase());async function H(){if(O.platform==="darwin"){let e=await I();return{name:await T(e),id:e}}if(O.platform==="linux"){let{stdout:e}=await Ee("xdg-mime",["query","default","x-scheme-handler/http"]),r=e.trim();return{name:Be(r.replace(/.desktop$/,"").replace("-"," ")),id:r}}if(O.platform==="win32")return _();throw new Error("Only macOS, Linux, and Windows are supported")}var Te=Le(te.execFile),$=re.dirname(ke(import.meta.url)),q=re.join($,"xdg-open"),{platform:w,arch:V}=Z;async function Fe(){let e=await M(),r=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,t=ee.from(r,"utf16le").toString("base64"),{stdout:n}=await Te(e,["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",t],{encoding:"utf8"}),o=n.trim(),i={ChromeHTML:"com.google.chrome",BraveHTML:"com.brave.Browser",MSEdgeHTM:"com.microsoft.edge",FirefoxURL:"org.mozilla.firefox"};return i[o]?{id:i[o]}:{}}var J=async(e,r)=>{let t;for(let n of e)try{return await r(n)}catch(o){t=o}throw t},v=async e=>{if(e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e},Array.isArray(e.app))return J(e.app,a=>v({...e,app:a}));let{name:r,arguments:t=[]}=e.app??{};if(t=[...t],Array.isArray(r))return J(r,a=>v({...e,app:{name:a,arguments:t}}));if(r==="browser"||r==="browserPrivate"){let a={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.Browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge"},l={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},s=d?await Fe():await H();if(s.id in a){let m=a[s.id];return r==="browserPrivate"&&t.push(l[m]),v({...e,app:{name:g[m],arguments:t}})}throw new Error(`${s.name} is not supported as a default browser`)}let n,o=[],i={};if(w==="darwin")n="open",e.wait&&o.push("--wait-apps"),e.background&&o.push("--background"),e.newInstance&&o.push("--new"),r&&o.push("-a",r);else if(w==="win32"||d&&!u()&&!r){n=await M(),o.push("-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"),d||(i.windowsVerbatimArguments=!0);let a=["Start"];e.wait&&a.push("-Wait"),r?(a.push(`"\`"${r}\`""`),e.target&&t.push(e.target)):e.target&&a.push(`"${e.target}"`),t.length>0&&(t=t.map(l=>`"\`"${l}\`""`),a.push("-ArgumentList",t.join(","))),e.target=ee.from(a.join(" "),"utf16le").toString("base64")}else{if(r)n=r;else{let a=!$||$==="/",l=!1;try{await Me.access(q,Ie.X_OK),l=!0}catch{}n=Z.versions.electron??(w==="android"||a||!l)?"xdg-open":q}t.length>0&&o.push(...t),e.wait||(i.stdio="ignore",i.detached=!0)}w==="darwin"&&t.length>0&&o.push("--args",...t),e.target&&o.push(e.target);let c=te.spawn(n,o,i);return e.wait?new Promise((a,l)=>{c.once("error",l),c.once("close",s=>{if(!e.allowNonzeroExitCode&&s>0){l(new Error(`Exited with code ${s}`));return}a(c)})}):(c.unref(),c)},_e=(e,r)=>{if(typeof e!="string")throw new TypeError("Expected a `target`");return v({...r,target:e})};function Q(e){if(typeof e=="string"||Array.isArray(e))return e;let{[V]:r}=e;if(!r)throw new Error(`${V} is not supported`);return r}function b({[w]:e},{wsl:r}){if(r&&d)return Q(r);if(!e)throw new Error(`${w} is not supported`);return Q(e)}var g={};f(g,"chrome",()=>b({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));f(g,"brave",()=>b({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));f(g,"firefox",()=>b({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));f(g,"edge",()=>b({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));f(g,"browser",()=>"browser");f(g,"browserPrivate",()=>"browserPrivate");var oe=_e;var ne=class{profile;environment;creds;oauth;constructor(r="default",t="prod",n){this.profile=r,this.environment=t,this.creds=n??new D,this.oauth=new A(t)}async login(){let{server:r,port:t}=await this.startCallbackServer(),n=N(t);try{let o=this.creds.loadClient(this.profile,this.environment),i=o?.redirect_uris;(!o||!i?.includes(n))&&(o=await this.oauth.registerClient(n),this.creds.saveClient(this.profile,this.environment,o));let c=o.client_id,[a,l]=A.generatePkce(),s=He(32).toString("hex"),m=this.oauth.buildAuthorizationUrl(c,l,s,n),p=await this.waitForCallback(r,t,m,s);if(!p)throw new Error("Login cancelled or timed out");let h=await this.oauth.exchangeCode(p,c,a,n),x={access_token:h.access_token,refresh_token:h.refresh_token,expires_at:Math.floor(Date.now()/1e3)+h.expires_in,scope:h.scope??"*"};return this.creds.saveCredentials(this.profile,this.environment,x),this.creds.setActiveProfile(this.profile),x}catch(o){throw r.close(),o}}startCallbackServer(){return new Promise((r,t)=>{let n=C,o=()=>{let i=Oe();i.on("error",c=>{c.code==="EADDRINUSE"&&n<P?(n++,o()):t(new Error(`Failed to start callback server: ${c.message}. Ports ${C}-${P} are all in use.`))}),i.listen(n,S,()=>{r({server:i,port:n})})};o()})}waitForCallback(r,t,n,o){return new Promise(i=>{let c=!1,a=setTimeout(()=>l(null),12e4),l=s=>{c||(c=!0,clearTimeout(a),r.close(),i(s))};r.on("request",(s,m)=>{let p=new $e(s.url??"/",`http://${S}:${t}`);if(p.pathname!==U){m.writeHead(404),m.end();return}let h=p.searchParams.get("state"),x=p.searchParams.get("code");if(p.searchParams.get("error")){m.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),m.end(R({state:"error",title:"Login failed",message:"We couldn't complete the sign-in. You can close this tab and try again from your terminal."})),l(null);return}if(h!==o){m.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),m.end(R({state:"error",title:"Invalid state",message:"The sign-in response didn't match this session. Please return to your terminal and try again."})),l(null);return}m.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),m.end(R({state:"success",title:"You're signed in",message:"Head back to your terminal \u2014 KaneAI is ready when you are.",autoClose:!0})),l(x)}),oe(n).catch(s=>{let m=s instanceof Error?s.message:String(s);process.stderr.write(`[auth] Could not open browser: ${m}
|
|
4
|
-
Please open this URL manually: ${n}
|
|
5
|
-
`)})})}};function R(e){let r=e.state==="success",t=r?"#22c55e":"#ef4444",n=r?"rgba(34, 197, 94, 0.12)":"rgba(239, 68, 68, 0.12)",o=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=e.autoClose?"<script>setTimeout(function(){try{window.close();}catch(e){}}, 1500);</script>":"";return`<!doctype html>
|
|
6
|
-
<html lang="en">
|
|
7
|
-
<head>
|
|
8
|
-
<meta charset="utf-8" />
|
|
9
|
-
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
10
|
-
<title>${W(e.title)} \xB7 KaneAI</title>
|
|
11
|
-
<style>
|
|
12
|
-
:root {
|
|
13
|
-
color-scheme: light dark;
|
|
14
|
-
--bg: #f7f7f8;
|
|
15
|
-
--card: #ffffff;
|
|
16
|
-
--fg: #0a0a0a;
|
|
17
|
-
--muted: #6b7280;
|
|
18
|
-
--border: rgba(0, 0, 0, 0.06);
|
|
19
|
-
--shadow: 0 10px 40px rgba(0, 0, 0, 0.08);
|
|
20
|
-
}
|
|
21
|
-
@media (prefers-color-scheme: dark) {
|
|
22
|
-
:root {
|
|
23
|
-
--bg: #0a0a0a;
|
|
24
|
-
--card: #141416;
|
|
25
|
-
--fg: #f5f5f7;
|
|
26
|
-
--muted: #9ca3af;
|
|
27
|
-
--border: rgba(255, 255, 255, 0.08);
|
|
28
|
-
--shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
* { box-sizing: border-box; }
|
|
32
|
-
html, body { height: 100%; }
|
|
33
|
-
body {
|
|
34
|
-
margin: 0;
|
|
35
|
-
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
|
|
36
|
-
background: var(--bg);
|
|
37
|
-
color: var(--fg);
|
|
38
|
-
display: flex;
|
|
39
|
-
align-items: center;
|
|
40
|
-
justify-content: center;
|
|
41
|
-
padding: 24px;
|
|
42
|
-
-webkit-font-smoothing: antialiased;
|
|
43
|
-
}
|
|
44
|
-
.card {
|
|
45
|
-
width: 100%;
|
|
46
|
-
max-width: 420px;
|
|
47
|
-
background: var(--card);
|
|
48
|
-
border: 1px solid var(--border);
|
|
49
|
-
border-radius: 16px;
|
|
50
|
-
box-shadow: var(--shadow);
|
|
51
|
-
padding: 40px 32px 32px;
|
|
52
|
-
text-align: center;
|
|
53
|
-
animation: rise 280ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
|
|
54
|
-
}
|
|
55
|
-
@keyframes rise {
|
|
56
|
-
from { opacity: 0; transform: translateY(8px); }
|
|
57
|
-
to { opacity: 1; transform: translateY(0); }
|
|
58
|
-
}
|
|
59
|
-
.icon {
|
|
60
|
-
width: 64px;
|
|
61
|
-
height: 64px;
|
|
62
|
-
margin: 0 auto 20px;
|
|
63
|
-
border-radius: 999px;
|
|
64
|
-
display: flex;
|
|
65
|
-
align-items: center;
|
|
66
|
-
justify-content: center;
|
|
67
|
-
background: ${n};
|
|
68
|
-
color: ${t};
|
|
69
|
-
}
|
|
70
|
-
h1 {
|
|
71
|
-
font-size: 22px;
|
|
72
|
-
font-weight: 600;
|
|
73
|
-
letter-spacing: -0.01em;
|
|
74
|
-
margin: 0 0 8px;
|
|
75
|
-
}
|
|
76
|
-
p {
|
|
77
|
-
margin: 0;
|
|
78
|
-
color: var(--muted);
|
|
79
|
-
font-size: 14.5px;
|
|
80
|
-
line-height: 1.5;
|
|
81
|
-
}
|
|
82
|
-
.brand {
|
|
83
|
-
margin-top: 28px;
|
|
84
|
-
padding-top: 20px;
|
|
85
|
-
border-top: 1px solid var(--border);
|
|
86
|
-
font-size: 12px;
|
|
87
|
-
letter-spacing: 0.08em;
|
|
88
|
-
text-transform: uppercase;
|
|
89
|
-
color: var(--muted);
|
|
90
|
-
}
|
|
91
|
-
.brand strong { color: var(--fg); font-weight: 600; letter-spacing: 0.08em; }
|
|
92
|
-
</style>
|
|
93
|
-
</head>
|
|
94
|
-
<body>
|
|
95
|
-
<main class="card" role="status" aria-live="polite">
|
|
96
|
-
<div class="icon">${o}</div>
|
|
97
|
-
<h1>${W(e.title)}</h1>
|
|
98
|
-
<p>${W(e.message)}</p>
|
|
99
|
-
<div class="brand"><strong>KaneAI</strong> \xB7 CLI</div>
|
|
100
|
-
</main>
|
|
101
|
-
${i}
|
|
102
|
-
</body>
|
|
103
|
-
</html>`}function W(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}export{ne as a};
|
package/dist/chunk-AH4AXJML.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{dirname as p,basename as f,join as i}from"path";function g(r){let t=f(r);return t.endsWith("_test.md")?t.slice(0,-8):t.endsWith(".md")?t.slice(0,-3):t}function o(r){return i(p(r),`output-${g(r)}`)}function x(r){return i(o(r),"Result.md")}function c(r){return i(o(r),".internal")}function d(r){return i(c(r),"meta.json")}function l(r,t,n){return i(o(r),`${t}-${n}-code`)}function D(r){return i(o(r),"generated-code")}function b(r){return o(r)+".staging"}function m(r){return i(c(r),"steps")}function v(r,t,n){return i(m(r),`${t}-${n}`)}import{existsSync as e,renameSync as s,rmSync as u}from"fs";function h(r){let t=`${r}.staging`,n=`${r}.bak`;if(!e(t))throw new Error(`atomicReplaceDir: staging missing: ${t}`);if(process.platform==="win32"){e(r)&&u(r,{recursive:!0,force:!0}),s(t,r);return}e(r)&&(e(n)&&u(n,{recursive:!0,force:!0}),s(r,n)),s(t,r),e(n)&&u(n,{recursive:!0,force:!0})}function w(r){let t=`${r}.staging`,n=`${r}.bak`;if(process.platform==="win32"){e(t)&&(e(r)?u(t,{recursive:!0,force:!0}):s(t,r));return}if(e(n)&&!e(r)){s(n,r),e(t)&&u(t,{recursive:!0,force:!0});return}e(n)&&e(r)&&u(n,{recursive:!0,force:!0}),e(t)&&e(r)&&u(t,{recursive:!0,force:!0})}export{g as a,o as b,x as c,c as d,d as e,l as f,D as g,b as h,v as i,h as j,w as k};
|
package/dist/chunk-AT45XB6X.js
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as Se,b as nr}from"./chunk-C5UNZ6ZY.js";import{a as ar}from"./chunk-BH6EP2LD.js";import{c as or}from"./chunk-S3DAAAE5.js";import{b as sr,c as ut,d as dt,e as ve,f as mt,g as ir}from"./chunk-PUU7A26K.js";import{a as Ue,b as se,c as tr,e as le,f as lt,i as rr,j as ct}from"./chunk-AH4AXJML.js";import{b as ue}from"./chunk-NAAPNSZD.js";import{a as Xt}from"./chunk-WAOCHXJ5.js";import{a as er,b as at}from"./chunk-BQACGLXW.js";import{a as Wt,b as ot,c as it,d as je,e as Jt,f as Qt}from"./chunk-LOIRZFV3.js";import{f as Yt,g as Zt}from"./chunk-XCYCX4TU.js";import{a as zt}from"./chunk-LPUQ4HWQ.js";import{a as De,b as Gt}from"./chunk-NLCCBXXV.js";import{a as W}from"./chunk-KKIFXAJY.js";import{a as D}from"./chunk-RZ4F3BHX.js";import{a as Ht}from"./chunk-E47GFYXA.js";import{a as Kt,c as rt,i as qt,j as Le,k as st,l as nt}from"./chunk-LRKWPAGK.js";import{join as qe,basename as En}from"path";import{existsSync as ds,readFileSync as An}from"fs";import{existsSync as ft}from"fs";import{join as Fe,basename as lr}from"path";function cr(e,t){if(!t||!ft(t))return e.steps.map(()=>({kind:"author",reason:"no-result-md"}));let r=dt(t),s=[],n=new Set,o=new Map;function a(i){let l=ve(i),h=Fe(l,"Result.md");if(o.has(h))return o.get(h);let f=ft(h)?dt(h):null;return o.set(h,f),f}function u(i){for(let l=1;l<i.trace.length;l++){let f=i.trace[l-1].file===e.rootPath?r:a(i.trace.slice(0,l));if(!f)return{kind:"author",reason:"no-result-md"};let w=i.trace[l-1].stepIndex,g=f.steps[w-1];if(!g)return{kind:"author",reason:"no-result-md"};if(g.kind!=="import")return{kind:"author",reason:"structure-mismatch"};let I=lr(g.importPath),S=lr(i.trace[l].file);if(I!==S)return{kind:"author",reason:"structure-mismatch"};if(g.status!=="passed")return{kind:"author",reason:"recorded-failed"}}return null}for(let i of e.steps){let l=i.trace[i.trace.length-1].file,h=i.trace[i.trace.length-1].stepIndex,f=n.has(l);for(let S=0;S<i.trace.length-1&&!f;S++)n.has(i.trace[S].file)&&(f=!0);if(f){s.push({kind:"author",reason:"downstream-of-divergence"});continue}let w=u(i);if(w){s.push(w);for(let S=0;S<i.trace.length;S++)n.add(i.trace[S].file);continue}let g=l===e.rootPath?r:a(i.trace),I=Es(i,g,h);if(s.push(I),I.kind==="author"){n.add(l);for(let S=0;S<i.trace.length-1;S++)n.add(i.trace[S].file)}}return s}function Es(e,t,r){if(!t)return{kind:"author",reason:"no-result-md"};let s=t.steps[r-1];if(!s)return{kind:"author",reason:"no-result-md"};if(s.kind!=="objective")return{kind:"author",reason:"structure-mismatch"};if(s.status!=="passed")return{kind:"author",reason:"recorded-failed"};let n=sr(e);if(n!==s.md5)return{kind:"author",reason:"md5-mismatch"};let o=e.trace.length===1?rr(e.trace[0].file,r,n.slice(0,8)):Fe(ve(e.trace),".internal","steps",`${r}-${n.slice(0,8)}`),a=Fe(o,"flows","0","actions.ndjson");return ft(a)?{kind:"replay",recordingDir:o}:{kind:"author",reason:"missing-recording"}}function ur(e){return e.some(t=>t.kind==="author")}function Me(e){for(let t=0;t<e.length;t++)if(e[t].kind==="author")return t;return e.length}function dr(e){return Fe(e.recordingDir,"flows","0","actions.ndjson")}function mr(e,t){if(process.env.KANE_REPLAY_TRACE==="1")for(let r=0;r<e.steps.length;r++){let s=e.steps[r],n=t[r],o=" ".repeat(s.trace.length-1),a=`step ${s.flatIndex}`;n.kind==="replay"?process.stderr.write(`[replay-trace] ${o}${a}: REPLAY (would skip; v1 always authors)
|
|
3
|
-
`):process.stderr.write(`[replay-trace] ${o}${a}: AUTHOR (${n.reason})
|
|
4
|
-
`)}}function de(e){process.env.KANE_REPLAY_TRACE==="1"&&process.stderr.write(e)}function fr(e,t){let r=e===0?"(none)":`0..${e-1}`,s=e>=t?"(none)":`${e}..${t-1}`;de(`[replay-trace] phase: replay ${r}, author ${s}
|
|
5
|
-
`)}function pr(e,t){de(`[replay-trace] step ${e}: REPLAY ${t==="ok"?"OK":"FAILED"}
|
|
6
|
-
`)}function hr(e,t,r){de(`[replay-trace] shrink ${e}/${t} \u2192 new boundary ${r}
|
|
7
|
-
`)}function gr(e,t){de(`[replay-trace] complete-reauthor (${e} shrinks exhausted of ${t})
|
|
8
|
-
`)}function pt(){de(`[replay-trace] force-author (--author) \u2014 walker bypassed
|
|
9
|
-
`)}function br(e){de(`[replay-trace] cancelled at step ${e}
|
|
10
|
-
`)}import{join as As}from"path";function ht(e){let t={objective:e.step.objective,model:"v16-alpha",width:e.windowSize.width,height:e.windowSize.height,session_id:e.sessionId,run_index:e.runIndex,stream:!0,mode:"replay",replay:{recording_path:dr(e.decision),step_label:e.step.objective},screenshot_dir:As(e.sessionDir,"runs",String(e.runIndex)),run_id:"run",test_id:"test"};return e.forceNavigateUrl&&(t.url=e.forceNavigateUrl),e.chrome.wsEndpoint?t.ws_endpoint=e.chrome.wsEndpoint:e.chrome.cdpEndpoint&&(t.cdp_endpoint=e.chrome.cdpEndpoint),e.auth.basicAuth?(t.username=e.auth.basicAuth.username,t.access_key=e.auth.basicAuth.access_key):e.auth.token&&(t.auth={type:"bearer",token:e.auth.token}),e.variables&&Object.keys(e.variables).length>0&&(t.variables=e.variables),e.sessionContext&&(t.session_context=e.sessionContext),t}async function yr(e){let t=e.forceAuthor?0:Me(e.decisions),r=0,s=!1;for(;;){let n=e.session.snapshot(),o=e.accumulator.snapshot(),a=await e.runReplayPhase(t);if(a.cancelled)return s=!0,br(a.failedAt??0),{authorBoundary:t,cancelledInPhase:s,shrinkCount:r};if(a.failedAt===null)return{authorBoundary:t,cancelledInPhase:s,shrinkCount:r};let u=nr({failedAt:a.failedAt,shrinkCount:r,hasRetry:e.hasRetry,maxShrinks:e.maxShrinks});if(u.kind==="fail")return{authorBoundary:-1,cancelledInPhase:s,shrinkCount:r};if(e.acquireLockIfNeeded&&!await e.acquireLockIfNeeded())return{authorBoundary:-1,cancelledInPhase:s,shrinkCount:r};if(e.session.rollback(n),e.accumulator.rollback(o),u.kind==="complete-reauthor")return gr(r+1,e.maxShrinks),{authorBoundary:0,cancelledInPhase:s,shrinkCount:r};r++,hr(r,Se.maxShrinks,u.newAuthorBoundary),t=u.newAuthorBoundary}}var xs=15e3,gt=3,vr=[500,1e3];async function bt(e){if(process.env.KANE_LOCK_CONFLICT_SIMULATE==="1")return{ok:!1,reason:"concurrent",httpStatus:409,message:"simulated contention (KANE_LOCK_CONFLICT_SIMULATE=1)"};let t=`${e.baseUrl}/test/${encodeURIComponent(e.testId)}/playground`,r=await Ne(t,{from_commit_id:e.fromCommitId,new_commit_id:e.newCommitId},e.auth);return r.ok?{ok:!0,sessionExpiresAt:j(r.body,"session_expires_at")??""}:{ok:!1,...Ps(r)}}function Ps(e){let t=j(e.body,"error")??j(e.body,"code")??"",r=j(e.body,"message")??j(e.body,"detail")??e.text??`HTTP ${e.status}`,s;return e.status===0?s="network":e.status===401||e.status===403?s="auth":e.status===409&&t==="PlaygroundBaseCommitMismatch"?s="base_mismatch":e.status===409?s="concurrent":e.status===422?s="disabled":e.status===400&&/no committed/i.test(r)?s="no_commits":e.status===400?s="missing_field":e.status>=500||e.status===408||e.status===429?s="network":s="other",{reason:s,httpStatus:e.status,message:r}}async function Rr(e){let t=`${e.baseUrl}/test/${encodeURIComponent(e.testId)}/playground/reserve`,r=await Ne(t,void 0,e.auth);return r.ok?{ok:!0,sessionExpiresAt:j(r.body,"session_expires_at")??""}:{ok:!1,expired:r.status===404,httpStatus:r.status,message:j(r.body,"message")??j(r.body,"detail")??r.text??`HTTP ${r.status}`}}async function wr(e){let t=`${e.baseUrl}/test/${encodeURIComponent(e.testId)}/commit`,r={commit_id:e.body.commitId,from_commit_id:e.body.fromCommitId,commit_message:e.body.commitMessage,total_steps:e.body.totalSteps};e.body.timeTaken!==void 0&&(r.time_taken=e.body.timeTaken),e.body.objectives!==void 0&&(r.objectives=e.body.objectives);let s=await Ne(t,r,e.auth);return s.ok?{ok:!0,testId:j(s.body,"test_id")??e.testId,testcaseId:j(s.body,"testcase_id")??"",projectId:j(s.body,"project_id"),isTestCaseDeleted:typeof s.body?.is_test_case_deleted=="boolean"?s.body.is_test_case_deleted:void 0}:{ok:!1,...Ts(s)}}function Ts(e){let t=j(e.body,"error")??j(e.body,"code")??"",r=j(e.body,"message")??j(e.body,"detail")??e.text??`HTTP ${e.status}`,s;return e.status===0?s="network":e.status===401||e.status===403?s="auth":e.status===409&&t==="PlaygroundBaseCommitMismatch"?s="base_mismatch":e.status===409&&t==="PlaygroundCommitLockMismatch"?s="lock_mismatch":e.status===409?s="expired":e.status===422?s="not_found":e.status>=500||e.status===408||e.status===429?s="network":s="other",{reason:s,httpStatus:e.status,message:r}}async function _r(e){let t=`${e.baseUrl}/test/${encodeURIComponent(e.testId)}/commit`,r={discard:!0,commit_id:e.body.commitId,from_commit_id:e.body.fromCommitId,commit_message:"(discarded)",total_steps:1},s=await Ne(t,r,e.auth);return s.ok?{ok:!0}:{ok:!1,reason:j(s.body,"error")??"other",httpStatus:s.status,message:j(s.body,"message")??j(s.body,"detail")??s.text??`HTTP ${s.status}`}}async function Ne(e,t,r){let s=null;for(let n=1;n<=gt;n++){let o=new AbortController,a=setTimeout(()=>o.abort(),xs);try{let u=await D(e,{method:"POST",headers:{Authorization:De(r.username,r.accessKey),"Content-Type":"application/json",Accept:"application/json"},...t!==void 0?{body:JSON.stringify(t)}:{},signal:o.signal});clearTimeout(a);let i=await u.text(),l=null;if(i)try{l=JSON.parse(i)}catch{}let h=u.status>=500||u.status===408||u.status===429;if(u.ok||!h)return{ok:u.ok,status:u.status,body:l,text:i};if(n<gt){await Sr(vr[n-1]??1e3);continue}return{ok:!1,status:u.status,body:l,text:i}}catch(u){if(clearTimeout(a),s=u,n<gt){await Sr(vr[n-1]??1e3);continue}}}return{ok:!1,status:0,body:null,text:s?.message??"exhausted retries"}}function Sr(e){return new Promise(t=>setTimeout(t,e))}function j(e,t){if(typeof e!="object"||e===null)return;let r=e[t];return typeof r=="string"?r:void 0}var Os=60*1e3,Ir="lock-heartbeat",me=null,yt=null,Cr={register:(e,t)=>je(e,t),deregister:e=>Jt(e),cleanup:(e,t)=>Qt(e,t),remoteLogger:null};function kr(){me!==null&&(clearInterval(me),me=null)}function vt(e){if(me!==null)return;let t=e.lifecycle??Cr;yt=t,me=setInterval(async()=>{let r=await Rr({baseUrl:e.baseUrl,testId:e.testId,auth:e.auth});if(!r.ok){let s=r.expired?"session expired":r.message;process.stderr.write(`[lock] heartbeat failed: ${s}; continuing run
|
|
11
|
-
`)}},Os),t.register(Ir,()=>kr())}function St(){me!==null&&(kr(),(yt??Cr).deregister(Ir),yt=null)}import{readFileSync as Er,readdirSync as Ar,existsSync as ce}from"fs";import{join as ee}from"path";function xr(e,t,r,s,n,o){try{let a=ee(e,"runs",String(t),"run-test");if(!ce(a)){n("warn","SCREENSHOT_SKIP","Runs dir not found",{step_index:r,reason:"runsDir_not_found",path:a});return}let u=a;if(o){let S=ee(a,`child-${o}`);if(!ce(S)){n("warn","SCREENSHOT_SKIP","Child dir not found",{step_index:r,child_id:o,reason:"child_dir_not_found",path:S});return}let k=Ar(S).filter(c=>ce(ee(S,c,"screenshots")));if(k.length===0){n("warn","SCREENSHOT_SKIP","No screenshots dir under child",{step_index:r,child_id:o,reason:"no_child_screenshots_dir"});return}u=ee(S,k[0])}else if(!ce(ee(a,"screenshots"))){let S=Ar(a).filter(k=>ce(ee(a,k,"screenshots")));if(S.length===0){n("warn","SCREENSHOT_SKIP","No screenshots dir found",{step_index:r,reason:"no_screenshots_dir"});return}u=ee(a,S[0])}let i=ee(u,"screenshots",`step_${String(r).padStart(3,"0")}.png`);if(!ce(i)){n("warn","SCREENSHOT_SKIP","Screenshot not found",{step_index:r,child_id:o,reason:"screenshot_not_found",path:i});return}let l=ee(a,"actions.ndjson");if(!ce(l)){n("warn","SCREENSHOT_SKIP","NDJSON not found",{step_index:r,reason:"ndjson_not_found"});return}let h=Er(l,"utf-8").trim().split(`
|
|
12
|
-
`),f=h[h.length-1];if(!f){n("warn","SCREENSHOT_SKIP","NDJSON empty",{step_index:r,reason:"ndjson_empty"});return}let g=JSON.parse(f).action_id;if(!g){n("warn","SCREENSHOT_SKIP","No action_id in NDJSON",{step_index:r,reason:"no_action_id"});return}let I=Er(i);s.enqueue(g,I),n("info","SCREENSHOT_ENQUEUED","Screenshot enqueued",{step_index:r,child_id:o,action_id:g,size:I.length})}catch(a){n("error","SCREENSHOT_DISPATCH_ERROR","Screenshot dispatch error",{step_index:r,error:a instanceof Error?a.message:String(a)})}}import{dirname as Ls,join as Ds}from"path";function Pr(e,t,r){let s=e.total_runs??1,n=e.run_dir,o,a;if(s>1&&n){let u=Ls(n);o=Array.from({length:s},(i,l)=>Ds(u,String(t+l))),r&&r.length===s&&(a=r)}return{allRunDirs:o,flowObjectives:a}}function Tr(e,t,r,s){return{index:r,objective:t,summary:e.summary,oneLiner:e.one_liner,status:e.status,resultCode:e.result_code,reasonCode:e.reason_code,perFlowMetadata:e.per_flow_metadata,context:e.context??{memory:{},variables:{},pointer:""},run_dir:e.run_dir,run_dirs:s.allRunDirs,flow_objectives:s.flowObjectives}}var $e=class{constructor(t){this.resolved=t;this.outcomes=t.rootSteps.map(r=>({rootStepIndex:r.index,status:"skipped"}))}outcomes;skipRoot=null;overallHalted=!1;shouldRunFlatStep(t){if(this.overallHalted)return!1;let r=t.trace[0].stepIndex;return!(this.skipRoot!==null&&r===this.skipRoot)}recordStep(t,r){let s=t.trace[0].stepIndex,n=this.outcomes.find(i=>i.rootStepIndex===s),o=this.resolved.rootSteps.find(i=>i.index===s),a=o.body.kind!=="objective";return a&&(n.refKind="import",n.refLabel=o.body.path,n.inlinedCount=(n.inlinedCount??0)+1,n.duration_s=(n.duration_s??0)+r.duration_s),r.status==="passed"?(a?n.status!=="failed"&&(n.status="passed"):(n.status="passed",n.duration_s=r.duration_s),{continueOverall:!0}):t.optional?(n.softFailures=n.softFailures??[],n.softFailures.push({subStepIndex:t.trace[t.trace.length-1].stepIndex,reason:r.reason}),{continueOverall:!0}):(n.status="failed",n.duration_s=a?n.duration_s:r.duration_s,n.failedSubStepIndex=a?t.trace.slice(1).map(i=>i.stepIndex):void 0,n.reason=r.reason,this.skipRoot=s,o.optional??!1?(n.softFailed=!0,{continueOverall:!0}):(this.overallHalted=!0,{continueOverall:!1}))}snapshotOutcomes(){return[...this.outcomes]}snapshot(){return{outcomes:this.outcomes.map(t=>({...t,softFailures:t.softFailures?[...t.softFailures]:void 0})),skipRoot:this.skipRoot,overallHalted:this.overallHalted}}rollback(t){this.outcomes=t.outcomes.map(r=>({...r,softFailures:r.softFailures?[...r.softFailures]:void 0})),this.skipRoot=t.skipRoot,this.overallHalted=t.overallHalted}finalize(){let t=this.outcomes.some(s=>s.status==="failed"&&!s.softFailed)?"failed":"passed",r=this.outcomes.reduce((s,n)=>s+(n.duration_s??0),0);return{overallStatus:t,outcomes:this.outcomes,totalDurationS:r}}};function Rt(e){if(!e)return null;let t=e.trim();return t?/^https?:\/\//i.test(t)?t:`https://${t}`:null}function Or(e){return Rt(e.flag)??Rt(e.frontmatter)??(e.configDefault&&e.configDefault!==Le?Rt(e.configDefault):null)}function Lr(e){return e.resolvedUrl!==null?!1:!((!!e.local||!!e.allowMissingUrl)&&!e.isTTY)}import{spawn as js}from"child_process";async function Dr(e,t,r=100){let s=`${e.replace(/\/+$/,"")}/json/version`,n=await D(s);if(!n.ok)throw new Error(`CDP /json/version returned ${n.status}`);let o=await n.json();if(!o.webSocketDebuggerUrl)throw new Error("CDP /json/version missing webSocketDebuggerUrl");let a=new Ht(o.webSocketDebuggerUrl);await new Promise((p,_)=>{a.once("open",p),a.once("error",_)});let u=1,i=new Map;a.on("message",p=>{let _;try{_=JSON.parse(p.toString())}catch{return}if(_.id==null)return;let L=i.get(_.id);L&&(i.delete(_.id),_.error?L.reject(new Error(_.error.message)):L.resolve(_.result))});function l(p,_){let L=u++;return new Promise((V,N)=>{i.set(L,{resolve:ke=>V(ke),reject:N});let ne={id:L,method:p};_&&(ne.params=_),a.send(JSON.stringify(ne))})}let f=(await l("Target.getTargets")).targetInfos.find(p=>p.type==="page");if(!f)throw a.close(),new Error("CDP: no page target found");let g=(await l("Browser.getWindowForTarget",{targetId:f.targetId})).windowId,I="",S=!1,k=null,c=!1;a.on("close",()=>{c=!0}),a.on("error",()=>{c=!0});async function P(){if(!S){if(c){S=!0;return}try{let _=(await l("Browser.getWindowBounds",{windowId:g})).bounds,L=`${_.left}:${_.top}:${_.width}:${_.height}`;L!==I&&(I=L,t({left:_.left,top:_.top,width:_.width,height:_.height}))}catch{}S||(k=setTimeout(P,r))}}return P(),{stop(){if(!S){S=!0,k&&clearTimeout(k);try{a.close()}catch{}}}}}var Us=new Set(["1","true","yes"]);function jr(e){if(e?.headless)return null;let t=process.env.KANE_CLI_DISABLE_MARKER;if(t!=null&&Us.has(t.toLowerCase()))return null;let r=er();if(!r)return null;let s=[...r.args,"overlay"];e?.text&&s.push(e.text);let n;try{n=js(r.cmd,s,{cwd:r.cwd,stdio:["pipe","ignore","ignore"],detached:!1,windowsHide:!0})}catch{return null}function o(i){if(!(!n.stdin||n.stdin.destroyed))try{n.stdin.write(JSON.stringify(i)+`
|
|
13
|
-
`)}catch{}}e?.chromePid&&e.chromePid>0&&o({type:"chrome_pid",pid:e.chromePid});let a=null;e?.cdpEndpoint&&Dr(e.cdpEndpoint,i=>o({type:"bounds",...i})).then(i=>{a=i.stop}).catch(()=>{});let u=!1;return{setRunActive(i){u||o({type:"run_active",active:i})},setStepText(i){if(u)return;let l=i.trim();l&&o({type:"step_text",text:l})},setStepComplete(){u||o({type:"step_complete"})},kill(){if(!u){u=!0,a?.();try{n.stdin?.end()}catch{}try{n.kill("SIGTERM")}catch{}}}}}function Ur(e,t,r){return`${e}/projects/${t}/test-cases/${r}`}function wt(e,t,r,s){return`${Ur(e,t,r)}/dashboard/share/${s}?type=summary&agentView=true&fqdn=summary-page`}function Fr(e,t,r){return`${Ur(e,t,r)}/dashboard?type=summary&agentView=true&fqdn=summary-page`}import{mkdtempSync as Qs,rmSync as Ys}from"fs";import{join as Zs}from"path";import{tmpdir as Xs}from"os";import{spawn as $r,spawnSync as Fs}from"child_process";import{existsSync as _t}from"fs";import{createConnection as Ms}from"net";import{homedir as Re,platform as Ie}from"os";import{join as we}from"path";var Ns=new Set(["1","true","yes"]),Be=class extends Error{constructor(t){super(t),this.name="ChromeNotFoundError"}};function Po(e){return e instanceof Be?e.message:`Chrome failed: ${e instanceof Error?e.message:String(e)}`}var Ve={darwin:["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",we(Re(),"Applications/Google Chrome.app/Contents/MacOS/Google Chrome"),"/Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing",we(Re(),"Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing"),"/Applications/Chromium.app/Contents/MacOS/Chromium"],linux:["/usr/bin/google-chrome","/usr/bin/google-chrome-stable","/usr/bin/google-chrome-for-testing","/usr/local/bin/google-chrome-for-testing",we(Re(),"chrome-for-testing/chrome-linux64/chrome"),"/usr/bin/chromium","/usr/bin/chromium-browser","/snap/bin/chromium"],win32:["C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe","C:\\Program Files (x86)\\Google\\Chrome\\Application\\chrome.exe",we(Re(),"AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"),"C:\\chrome-for-testing\\chrome-win64\\chrome.exe",we(Re(),"AppData\\Local\\chrome-for-testing\\chrome-win64\\chrome.exe")]};function $s(){if(process.env.KANE_CLI_CHROME_PATH)return process.env.KANE_CLI_CHROME_PATH;let e=Ie(),t=Ve[e]??Ve.linux;for(let r of t)if(_t(r))return r;return e==="win32"?"chrome.exe":"google-chrome"}function Bs(){if(process.env.KANE_CLI_CHROME_PATH)return _t(process.env.KANE_CLI_CHROME_PATH);let e=Ie();if((Ve[e]??Ve.linux).some(n=>_t(n)))return!0;let r=e==="win32"?"chrome.exe":"google-chrome",s=e==="win32"?"where":"which";try{return Fs(s,[r],{stdio:"ignore"}).status===0}catch{return!1}}function Vs(){let e=Ie();return e==="darwin"?["Google Chrome is required but was not found at any standard path.","","Install via Homebrew (recommended):"," brew install --cask google-chrome","","Or download:"," https://www.google.com/chrome/","","Then re-run your command. Set KANE_CLI_CHROME_PATH=/path/to/chrome","to point at a non-standard install."].join(`
|
|
14
|
-
`):e==="linux"?["Google Chrome is required but was not found at /usr/bin/google-chrome.","(amd64 / x86_64 only \u2014 Google does not ship Chrome for Linux ARM.)","","Debian / Ubuntu (any version):"," wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb"," sudo apt install -y ./google-chrome-stable_current_amd64.deb","","Fedora / RHEL / AlmaLinux / Rocky:"," sudo dnf install -y https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm","","Then re-run your command. Set KANE_CLI_CHROME_PATH=/path/to/chrome","to point at a non-standard install."].join(`
|
|
15
|
-
`):e==="win32"?["Google Chrome is required but was not found in Program Files or AppData.","","Install via winget (Windows 10 1809+):"," winget install --id Google.Chrome -e --silent","","Or download:"," https://www.google.com/chrome/","","Then re-run your command. Set KANE_CLI_CHROME_PATH=C:\\path\\to\\chrome.exe","to point at a non-standard install."].join(`
|
|
16
|
-
`):["Google Chrome is required.","Install from https://www.google.com/chrome/","(Note: no official Chrome builds for BSD or Alpine/musl Linux.)"].join(`
|
|
17
|
-
`)}function Hs(e){let t=Ie(),r=[`--remote-debugging-port=${e.port}`,`--user-data-dir=${e.userDataDir}`,`--window-size=${e.width},${e.height}`,"--no-first-run","--no-default-browser-check","--disable-blink-features=AutomationControlled","--disable-features=DownloadBubble,DownloadBubbleV2","--safebrowsing-disable-download-protection","--disable-popup-blocking","--disable-notifications","--disable-infobars","--disable-translate","--disable-prompt-on-repost","--disable-background-networking","--disable-client-side-phishing-detection","--disable-default-apps","--disable-hang-monitor","--disable-sync","--metrics-recording-only","--safebrowsing-disable-auto-update","--disable-backgrounding-occluded-windows","--disable-background-timer-throttling","--test-type=webdriver","--allow-pre-commit-input","--enable-logging","--v=1"];return t==="linux"&&(r.push("--no-sandbox"),r.push("--disable-dev-shm-usage"),r.push("--password-store=basic")),t==="darwin"&&r.push("--use-mock-keychain"),e.headless&&r.push("--headless=new"),r}function Ks(e){return new Promise(t=>{let r=Ms({port:e,host:"127.0.0.1"});r.setTimeout(1e3),r.on("connect",()=>{r.destroy(),t(!0)}),r.on("timeout",()=>{r.destroy(),t(!1)}),r.on("error",()=>{r.destroy(),t(!1)})})}async function qs(){for(let e=st;e<=nt;e++)if(!await Ks(e))return e;throw new Error(`All CDP ports ${st}-${nt} are in use. Close other Chrome instances.`)}var _e=class extends Error{constructor(t){super(t),this.name="CdpReadinessError"}};async function Gs(e,t){let r=Date.now(),s=`http://127.0.0.1:${e}/json/version`;for(;Date.now()-r<t;){try{if((await D(s)).ok)return`http://127.0.0.1:${e}`}catch{}await new Promise(n=>setTimeout(n,200))}throw new _e(`Chrome CDP not ready after ${t}ms on port ${e}`)}var zs=3e4,Ws=2;function Mr(e,t,r){let s=process.env[e];if(s==null||s.trim()==="")return t;let n=Number(s);return!Number.isInteger(n)||n<r?t:n}function Js(e){return Math.min(500*e,3e3)}function Nr(e,t){try{if(e.pid)if(t==="win32")$r("taskkill",["/pid",String(e.pid),"/T","/F"],{stdio:"ignore"});else try{process.kill(-e.pid,"SIGKILL")}catch{e.kill("SIGKILL")}else e.kill("SIGKILL")}catch{}}async function Br(e){let t=process.env.KANE_CLI_SKIP_BROWSER_DOWNLOAD;if(!(t!=null&&Ns.has(t.toLowerCase()))&&!Bs())throw ot()?.log("error","CHROME_NOT_FOUND","Startup gate: Chrome unavailable at standard system paths",{platform:process.platform,kane_cli_chrome_path:process.env.KANE_CLI_CHROME_PATH??null,skip_browser_download:process.env.KANE_CLI_SKIP_BROWSER_DOWNLOAD??null}),new Be(Vs());let s=Ie(),n=$s(),o=Mr("KANE_CLI_CDP_TIMEOUT_MS",zs,1),u=Mr("KANE_CLI_CDP_RETRIES",Ws,0)+1,i;for(let l=1;l<=u;l++){let h=await qs(),f=Hs({port:h,...e});e.startUrl&&f.push(e.startUrl);let w=$r(n,f,{stdio:"ignore",detached:!0});w.unref();try{let g=await new Promise((I,S)=>{w.on("error",k=>{S(new Error(`Failed to launch Chrome: ${k.message}. Is Chrome installed at ${n}?`))}),w.on("close",k=>{k!==null&&k!==0&&S(new _e(`Chrome exited during startup with code ${k}`))}),Gs(h,o).then(I,S)});return{process:w,port:h,cdpEndpoint:g,kill(){Nr(w,s)}}}catch(g){if(i=g,!(g instanceof _e))throw g;Nr(w,s),ot()?.log("warn","CHROME_CDP_LAUNCH_RETRY",`Chrome CDP launch attempt ${l}/${u} failed`,{attempt:l,max_attempts:u,port:h,timeout_ms:o,headless:e.headless??!1,error:g.message}),l<u&&await new Promise(I=>setTimeout(I,Js(l)))}}throw i??new Error("Chrome launch failed after retries")}async function Vr(e){if(e.cft)return{instance:null,tempDir:null};if(e.wsEndpoint)return{wsEndpoint:e.wsEndpoint,instance:null,tempDir:null};if(e.cdpEndpoint){let n=await D(`${e.cdpEndpoint}/json/version`);if(!n.ok)throw new Error(`CDP endpoint not reachable: ${e.cdpEndpoint} (${n.status})`);return{cdpEndpoint:e.cdpEndpoint,instance:null,tempDir:null}}let t,r=null;if(e.config.chrome_profile_path)t=e.config.chrome_profile_path.replace("~",process.env.HOME??"~");else{r=Qs(Zs(Xs(),"kane-clean-")),t=r;let n=r;je("tempDir",()=>{try{Ys(n,{recursive:!0,force:!0})}catch{}})}let s=await Br({userDataDir:t,width:e.config.window_size.width,height:e.config.window_size.height,startUrl:e.startUrl,headless:e.headless});return{cdpEndpoint:s.cdpEndpoint,instance:s,tempDir:r}}function Hr(e){let t={objective:e.objective,model:e.model,width:e.windowSize.width,height:e.windowSize.height,session_id:e.sessionId,run_index:e.runIndex,stream:!0,max_steps:e.maxSteps??30,headless:e.headless??!1};return e.url&&(t.url=e.url),e.requireStartUrl&&(t.require_start_url=!0),e.chrome.wsEndpoint?t.ws_endpoint=e.chrome.wsEndpoint:e.chrome.cdpEndpoint&&(t.cdp_endpoint=e.chrome.cdpEndpoint),e.auth.basicAuth?(t.username=e.auth.basicAuth.username,t.access_key=e.auth.basicAuth.access_key):e.auth.token&&(t.auth={type:"bearer",token:e.auth.token}),e.disableAskUser&&(t.disable_ask_user=!0),e.enableTaskSkills&&(t.enable_task_skills=!0),e.networkWs&&(t.network_ws=!0),e.networkSse&&(t.network_sse=!0),e.variables&&Object.keys(e.variables).length>0&&(t.variables=e.variables),e.globalContext&&(t.global_context=e.globalContext),e.localContext&&(t.local_context=e.localContext),e.sessionContext&&(t.session_context=e.sessionContext),t}import{readdirSync as en,readFileSync as qr,existsSync as Gr}from"fs";import{join as tn}from"path";function Kr(e,t){if(!Gr(e))return{};let r={},s;try{s=en(e).filter(n=>n.endsWith(".json")).sort()}catch{return{}}for(let n of s)try{let o=qr(tn(e,n),"utf-8"),a=JSON.parse(o);if(a&&typeof a=="object"){for(let[u,i]of Object.entries(a))if(i&&typeof i=="object"&&"value"in i){let l=i;r[u]={value:l.value,secret:l.secret??!1,syntax:l.syntax??`{{${u}}}`}}}}catch{t?t("warn","VARIABLE_PARSE_FAILED","Skipping invalid variables file",{file:n}):process.stderr.write(`[variables] Warning: skipping invalid variables file: ${n}
|
|
18
|
-
`)}return r}function zr(e){if(!Gr(e))throw new Error(`Variables file not found: ${e}`);let t=qr(e,"utf-8"),r=JSON.parse(t),s={};if(r&&typeof r=="object"){for(let[n,o]of Object.entries(r))if(o&&typeof o=="object"&&"value"in o){let a=o;s[n]={value:a.value,secret:a.secret??!1,syntax:a.syntax??`{{${n}}}`}}}return s}function Wr(e){let t;try{t=JSON.parse(e)}catch{throw new Error("Invalid --variables JSON")}let r={};if(t&&typeof t=="object"){for(let[s,n]of Object.entries(t))if(n&&typeof n=="object"&&"value"in n){let o=n;r[s]={value:o.value,secret:o.secret??!1,syntax:o.syntax??`{{${s}}}`}}}return r}function Jr(e,t,r){let s=Kr(e,r),n=Kr(t,r);return{...s,...n}}var fe=class{constructor(t){this.baseUrl=t}async pushSecret(t){let r=De(t.username,t.accessKey),s=await D(`${this.baseUrl}/logistics/v1.0/secrets/create`,{method:"PUT",headers:{Authorization:r,"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify({secretKey:t.secretKey,secretValue:t.secretValue,orgId:t.orgId,username:t.username,scope:"user",type:"user",accessKey:t.accessKey})});if(!s.ok)throw new Error(`Push secret failed: ${s.status} ${await s.text()}`)}static extractVariableKeys(t){let r=t.matchAll(/\{\{([a-zA-Z_][a-zA-Z0-9_]*)\}\}/g),s=new Set;for(let n of r)s.add(n[1]);return[...s]}};var pe=class extends Gt{constructor(t,r,s){super(t,{username:r,accessKey:s})}async upsertVariable(t){let r=t.environmentId??0,s=await D(`${this.baseUrl}/v1/variables`,{method:"POST",headers:this.headers(),body:JSON.stringify({name:t.name,value:String(t.value),type:"variable",value_type:"string",is_persist:t.isPersist??!1,environment_id:r})});if(s.ok)return{id:(await s.json()).id??0};if(s.status!==409&&s.status!==422)return{id:0};if(!(await D(`${this.baseUrl}/v1/variables/name/${encodeURIComponent(t.name)}`,{method:"PUT",headers:this.headers(),body:JSON.stringify({value:String(t.value),value_type:"string",type:"variable",environment_id:r})})).ok)return{id:0};let o=await D(`${this.baseUrl}/v1/variables/${encodeURIComponent(t.name)}?environment_id=${r}`,{method:"GET",headers:this.headers()});return o.ok?{id:(await o.json()).data?.id??0}:{id:0}}};function Qr(e,t){if(Object.keys(e).length===0)return{};let r={};for(let[s,n]of Object.entries(e)){let o=n.syntax??`{{${s}}}`;t.includes(o)&&(r[s]=n)}return r}function Yr(e){let t=Jr(e.globalDir,e.localDir,e.onLoadError),r=e.file?zr(e.file):{},s=e.inline?Wr(e.inline):{},n={...t,...r,...s},o=Object.keys(n).length>0,{variables:a,objective:u}=o?ue(n,e.objective):{variables:{},objective:e.objective},i=Object.entries(n).filter(([,h])=>h.secret),l=Object.entries(n).filter(([,h])=>!h.secret);return{raw:n,auteur:a,auteurObjective:u,secretEntries:i,nonSecretEntries:l}}async function Zr(e){if(e.localMode)return{};let t=W(e.env);if(e.variables.secretEntries.length>0){let s=new fe(t.secretsBaseUrl);for(let[n,o]of e.variables.secretEntries)s.pushSecret({secretKey:n,secretValue:o.value,username:e.auth.username,accessKey:e.auth.access_key,orgId:e.orgId}).then(()=>e.log("info","SECRET_PUSH_OK","Secret pushed",{key:n})).catch(a=>e.log("error","SECRET_PUSH_FAILED","Secret push failed",{key:n,error:String(a)}))}let r={};if(e.variables.nonSecretEntries.length>0){let s=new pe(t.tmsBaseUrl,e.auth.username,e.auth.access_key);for(let[n,o]of e.variables.nonSecretEntries)try{let a=await s.upsertVariable({name:n,value:o.value});r[n]=a.id,e.log("info","VAR_PUSH_OK","Variable pushed",{name:n,id:a.id})}catch(a){e.log("error","VAR_PUSH_FAILED","Variable push failed",{name:n,error:String(a)})}}return r}import{readFileSync as rn,existsSync as sn}from"fs";function It(e){if(!sn(e))return null;try{return rn(e,"utf-8").trim()||null}catch{return null}}import{writeFileSync as nn,mkdirSync as on}from"fs";import{dirname as Xr}from"path";function Ct(e){let t=le(e.sourcePath);try{on(Xr(t),{recursive:!0})}catch(s){return process.stderr.write(`
|
|
19
|
-
\u26A0 Failed to create output directory.
|
|
20
|
-
${s.message}
|
|
21
|
-
Path: ${Xr(t)}
|
|
22
|
-
|
|
23
|
-
`),t}let r={commit_id:e.commitId};e.testId!==void 0&&(r.test_id=e.testId),e.testcaseId!==void 0&&(r.testcase_id=e.testcaseId),e.projectId!==void 0&&(r.project_id=e.projectId),e.folderId!==void 0&&(r.folder_id=e.folderId),e.orgId!==void 0&&(r.org_id=e.orgId),e.sessionName!==void 0&&(r.session_name=e.sessionName),e.plan!==void 0&&(r.plan=e.plan);try{nn(t,JSON.stringify(r,null,2)+`
|
|
24
|
-
`,"utf8")}catch(s){process.stderr.write(`
|
|
25
|
-
\u26A0 Failed to write meta.json.
|
|
26
|
-
${s.message}
|
|
27
|
-
Path: ${t}
|
|
28
|
-
|
|
29
|
-
`)}return t}var an=()=>{};async function es(e,t,r){let s=t.log??an,n=e.session.testId??null,o=null,a=null,u=null;if(!r.localMode&&t.performUpload)try{o=await t.performUpload(),o?.success&&(o.testId&&(n=o.testId),o.testcaseId&&e.session.setTestcaseId(o.testcaseId))}catch(i){s("error","FINALIZE_UPLOAD_ERROR","Upload pipeline threw",{error:String(i)})}if(t.renderFeedbackPrompt)try{a=await t.renderFeedbackPrompt(),a&&n&&t.submitFeedback&&t.submitFeedback(n,a).catch(i=>{s("error","FINALIZE_FEEDBACK_SUBMIT_ERROR","Feedback submit failed",{error:String(i)})})}catch(i){s("error","FINALIZE_FEEDBACK_RENDER_ERROR","Feedback prompt threw",{error:String(i)})}if(e.session.flushRecorder(),r.skipLocalWrites)s("info","FINALIZE_SKIP_LOCAL_WRITES","Skipping local writes (testmd flow handles via staging)");else if(r.sourcePath&&r.rootSteps&&r.outcomes){try{u=ut({sourcePath:r.sourcePath,title:r.title,rootSteps:r.rootSteps,outcomes:r.outcomes,overallStatus:r.overallStatus,startedISO:r.startedISO,durationS:r.durationS,sessionId:e.session.sessionId})}catch(i){s("error","FINALIZE_RESULT_MD_ERROR","_Result.md write failed",{error:String(i)})}try{Ct({sourcePath:r.sourcePath,commitId:e.session.sessionId,testId:n??void 0,testcaseId:e.session.testcaseId??void 0,projectId:e.tuiConfig.project_id??void 0,folderId:e.tuiConfig.folder_id??void 0,orgId:e.session.orgId??void 0,sessionName:e.session.sessionName??Ue(r.sourcePath),plan:e.session.plan??void 0})}catch(i){s("error","FINALIZE_META_WRITE_ERROR","meta.json write failed",{error:String(i)})}if(o?.codeExportDir)try{let i=e.tuiConfig.code_export?.language??"python";mt(o.codeExportDir,lt(r.sourcePath,"playwright",i))}catch(i){s("error","FINALIZE_CODE_COPY_ERROR","code-export copy failed",{error:String(i)})}}else if(e.session.recorder?.lastWrittenPath){let i=e.session.recorder.lastWrittenPath,l=e.session.getFlows(),h=l.map((g,I)=>({index:I+1,heading:`Step ${I+1}`,headingLine:0,body:{kind:"objective",text:g.objective}})),f=l.map((g,I)=>({rootStepIndex:I+1,status:g.status==="passed"?"passed":g.status==="failed"?"failed":"skipped",duration_s:g.duration,reason:g.reason})),w=f.some(g=>g.status==="failed")?"failed":"passed";try{u=ut({sourcePath:i,title:e.session.sessionName??"Session",rootSteps:h,outcomes:f,overallStatus:w,startedISO:e.session.startedAt,durationS:f.reduce((g,I)=>g+(I.duration_s??0),0),sessionId:e.session.sessionId})}catch(g){s("error","FINALIZE_TUI_RESULT_MD_ERROR","TUI _Result.md write failed",{error:String(g)})}try{Ct({sourcePath:i,commitId:e.session.sessionId,testId:n??void 0,testcaseId:e.session.testcaseId??void 0,sessionName:e.session.sessionName??void 0,projectId:e.tuiConfig.project_id??void 0,folderId:e.tuiConfig.folder_id??void 0,plan:e.session.plan??void 0})}catch(g){s("error","FINALIZE_TUI_META_WRITE_ERROR","TUI meta.json write failed",{error:String(g)})}if(o?.codeExportDir)try{let g=e.tuiConfig.code_export?.language??"python";mt(o.codeExportDir,lt(i,"playwright",g))}catch(g){s("error","FINALIZE_TUI_CODE_COPY_ERROR","TUI code-export copy failed",{error:String(g)})}e.session.recorder.lastCollisionSuffixed&&process.stderr.write(`Saved to ${i} (renamed: ${e.session.sessionName}_test.md already existed)
|
|
30
|
-
`)}try{t.runCleanup?.()}catch(i){s("error","FINALIZE_CLEANUP_ERROR","Cleanup hook threw",{error:String(i)})}try{await e.session.finish("complete")}catch(i){s("error","FINALIZE_SESSION_FINISH_ERROR","session.finish threw",{error:String(i)})}return{uploadResult:o,feedbackChoice:a,resultMdPath:u}}import{readFileSync as rs,writeFileSync as ss,existsSync as ns}from"fs";function ts(e,t,r){if(r.forceAuthor)return"re-recorded from scratch";if(r.retryTriggered)return"re-recorded after retry";if(t.length>0&&t.every(a=>a.kind==="author"&&a.reason==="no-result-md"))return"initial recording";if(t.length>0&&t.every(a=>a.kind==="replay"))return r.wantsPush?"re-recorded (no source changes)":"no changes";let s=[];for(let a=0;a<t.length;a++){let u=t[a];if(!u||u.kind!=="author"||u.reason==="downstream-of-divergence"||u.reason==="no-result-md")continue;let i=ln(e,e.steps[a]);switch(u.reason){case"structure-mismatch":s.push(`added/removed: ${i}`);break;case"md5-mismatch":s.push(`modified: ${i}`);break;case"missing-recording":s.push(`re-recorded: ${i}`);break;case"recorded-failed":s.push(`re-authored after failure: ${i}`);break}}if(s.length===0)return"automated commit";let n=s.filter((a,u)=>u===0||s[u-1]!==a),o=n.slice(0,3).join("; ");return n.length>3?`${o}; +${n.length-3} more`:o}function ln(e,t){if(!t)return"unknown step";let r=t.trace[0]?.stepIndex;if(r==null)return"unknown step";let n=e.rootSteps[r-1]?.heading?.trim()??"";return t.trace.length>1?n?`imported step in "${n}"`:`imported step ${r}`:n||`step ${r}`}function cn(e){if(!(!e.shouldReplaceLocalOutput||!e.resolvedTest||!e.sourcePath||!e.stepRunRecords||!e.outcomes||!e.overallStatus))return async()=>{ir({resolvedTest:e.resolvedTest,sessionDir:e.session.sessionDir,stepRunRecords:e.stepRunRecords,outcomes:e.outcomes,overallStatus:e.overallStatus,startedISO:e.startedISO??new Date().toISOString(),durationS:e.durationS??0,sessionId:e.session.sessionId,commitId:e.fromCommitId??"",tmsIds:e.tmsIds??{},codeExportDir:e.codeExportDir}),ct(se(e.sourcePath));let t=new Set;for(let r of e.resolvedTest.steps)if(r.trace.length>1){let s=ve(r.trace);if(t.has(s))continue;t.add(s),ns(`${s}.staging`)&&ct(s)}}}function un(e){if(!(!e.shouldCommit||e.isFirstRun||!e.tmsBaseUrl||!e.testId||!e.fromCommitId||!e.newCommitId||!e.basicAuth||!e.resolvedTest||!e.decisions))return async()=>{let t=ts(e.resolvedTest,e.decisions,{wantsPush:e.wantsPush??!1,retryTriggered:e.retryTriggered??!1,forceAuthor:e.forceAuthor??!1}),r=e.resolvedTest.steps.map(n=>n.objective).filter(n=>typeof n=="string"&&n.length>0).slice(0,50),s=await wr({baseUrl:`${e.tmsBaseUrl}/kane-cli/v1`,testId:e.testId,body:{commitId:e.newCommitId,fromCommitId:e.fromCommitId,commitMessage:t,totalSteps:e.resolvedTest.steps.length,timeTaken:Math.round(e.durationS??0),objectives:r},auth:{username:e.basicAuth.username,accessKey:e.basicAuth.access_key}});if(s.ok&&e.sourcePath){let n=le(e.sourcePath);try{let o=JSON.parse(rs(n,"utf8"));o.commit_id=e.newCommitId,ss(n,JSON.stringify(o,null,2)+`
|
|
31
|
-
`,"utf8")}catch(o){process.stderr.write(`warn: failed to update meta.json commit_id: ${o.message}
|
|
32
|
-
`)}}return s}}function dn(e){if(!(!e.isFirstRun||!e.sourcePath))return async t=>{if(!e.sourcePath)return;let r=le(e.sourcePath);try{let s=ns(r)?JSON.parse(rs(r,"utf8")):{};e.session.sessionId&&(s.commit_id=e.session.sessionId),t&&(s.testcase_id=t),e.tmsIds?.testId&&(s.test_id=e.tmsIds.testId),e.tmsIds?.projectId&&(s.project_id=e.tmsIds.projectId),e.tmsIds?.folderId&&(s.folder_id=e.tmsIds.folderId),e.tmsIds?.orgId&&(s.org_id=e.tmsIds.orgId),e.tmsIds?.sessionName&&(s.session_name=e.tmsIds.sessionName),ss(r,JSON.stringify(s,null,2)+`
|
|
33
|
-
`,"utf8")}catch(s){process.stderr.write(`warn: failed to update meta.json after endTest: ${s.message}
|
|
34
|
-
`)}}}function os(e){let t=W(e.env),{session:r,auth:s}=e,n=s.basicAuth?{username:s.basicAuth.username,accessKey:s.basicAuth.access_key}:s.token,o=s.resolvedCreds?.username??s.basicAuth?.username??"",a=s.resolvedCreds?.access_key??s.basicAuth?.access_key??"",u=s.resolvedCreds?.org_id??0,i=s.resolvedCreds?.user_id??0,l=[];for(let I of Object.keys(r.auteurVariables))I.startsWith("secrets.user.")&&l.push({key_name:I.replace("secrets.user.",""),scope:"user"});let f=r.getContext().prior_runs.map(I=>I.status),w=r.auteurVariables,g=Object.keys(w).length>0;return{controllerBaseUrl:t.controllerBaseUrl,tmsBaseUrl:t.tmsBaseUrl,auth:n,authResolver:s.resolver,sessionId:r.sessionId,sessionDir:r.sessionDir,testId:r.testId,commitId:r.sessionId,projectId:e.projectId,folderId:e.folderId,firstObjective:r.firstObjective??"KaneAI Test",firstUrl:r.firstUrl??"",runDirs:r.getRunDirs(),runObjectives:r.getRunObjectives(),runMetadata:r.getRunMetadata(),startedAt:r.startedAt,endedAt:new Date().toISOString(),totalSteps:e.totalSteps,totalDuration:e.totalDuration,runStatuses:f,orgId:u,userId:i,tmsUsername:o,tmsAccessKey:a,screenshotBaseUrl:r.screenshotBaseUrl,screenshotExtMap:e.screenshotExtMap,shareApiBaseUrl:t.shareApiBaseUrl,variables:g?w:void 0,variableIds:e.variableIds,secrets:l,codeExport:e.codeExport,onProgress:e.onProgress,log:e.log,shouldUploadArtifacts:e.shouldUploadArtifacts,shouldReplaceLocalOutput:e.shouldReplaceLocalOutput,shouldCommit:e.shouldCommit,isFirstRun:e.isFirstRun,onAtomicReplace:cn(e),onCommitLock:un(e),onFinalizeSuccess:dn(e)}}var is=["python","javascript"];function mn(e){if(e!==void 0){if(!is.includes(e))throw new Error(`--code-language must be one of: ${is.join(", ")} (got "${e}")`);return e}}function as(e,t){let r=mn(e.codeLanguage);return{enabled:e.codeExport??t.enabled,language:r??t.language,skipValidation:e.skipCodeValidation??t.skip_validation}}async function ls(e){try{let r=await new zt(e.tmsBaseUrl,e.auth.username,e.auth.access_key).createAtmTest({objective:e.objective.slice(0,100),creation_mode:"KANECLI",playground_disabled:e.hasCustomProfile,testURL:e.url,project_id:e.projectId,folder_id:e.folderId,authoring_version:4});return e.log("info","ATM_CREATE_OK","Test created",{test_id:r}),r}catch(t){return e.log("error","ATM_CREATE_FAILED","Test creation failed",{error:t instanceof Error?t.message:String(t)}),null}}var fn=null,pn=()=>fn??=import("sharp").then(e=>e.default??e).catch(()=>null),He=class{maxWorkers;maxRetries=2;queue=[];activeCount=0;drainResolvers=[];sas;log;uploadedExt=new Map;constructor(t,r=3,s){this.sas=t,this.maxWorkers=r,this.log=s}updateSas(t){this.sas=t}enqueue(t,r){this.queue.push({operationId:t,buffer:r}),this.pump()}async drain(t=3e4){if(!(this.queue.length===0&&this.activeCount===0))return new Promise(r=>{this.drainResolvers.push(r),setTimeout(()=>{r()},t)})}pump(){for(;this.activeCount<this.maxWorkers&&this.queue.length>0;){let t=this.queue.shift();this.activeCount++,this.processJob(t).finally(()=>{if(this.activeCount--,this.pump(),this.queue.length===0&&this.activeCount===0){for(let r of this.drainResolvers)r();this.drainResolvers=[]}})}}async processJob(t){let r,s="image/webp",n=await pn();if(n)try{let i=await n(t.buffer).webp({quality:80}).toBuffer();r=new Uint8Array(i)}catch(i){r=new Uint8Array(t.buffer),s="image/png",this.log?.("warn","SCREENSHOT_CONVERT_FAILED","WebP conversion failed, using PNG",{operation_id:t.operationId,error:i instanceof Error?i.message:String(i)})}else r=new Uint8Array(t.buffer),s="image/png";let o=s==="image/webp"?"webp":"png",a=`test_screenshots/untagged_screenshot/${t.operationId}.${o}`,u=`${this.sas.base_url}/${this.sas.container}/${a}?${this.sas.sas_token}`;for(let i=0;i<=this.maxRetries;i++)try{let l=await D(u,{method:"PUT",headers:{"Content-Type":s,"x-ms-blob-type":"BlockBlob"},body:r});if(l.ok){this.uploadedExt.set(t.operationId,o);return}if(i<this.maxRetries){await this.backoff(i);continue}this.log?.("warn","SCREENSHOT_UPLOAD_FAILED","Screenshot upload failed after retries",{operation_id:t.operationId,status:l.status,attempts:this.maxRetries+1})}catch{if(i<this.maxRetries){await this.backoff(i);continue}this.log?.("warn","SCREENSHOT_UPLOAD_FAILED","Screenshot upload failed (network error)",{operation_id:t.operationId,error:"network",attempts:this.maxRetries+1})}}backoff(t){let r=t===0?1e3:3e3;return new Promise(s=>setTimeout(s,r))}getExt(t){return this.uploadedExt.get(t)??"png"}getExtMap(){return this.uploadedExt}isNearExpiry(){if(!this.sas.expiry)return!1;let t=new Date(this.sas.expiry).getTime();return Date.now()>t-5*6e4}};var Ce=class{config;buffer=[];stepBuffer=new Map;flushTimer=null;currentRunIndex=null;stopped=!1;_droppedBatches=0;_droppedEntries=0;constructor(t){this.config=t}start(){if(this.flushTimer)return;let t=this.config.flushIntervalMs??5e3;this.flushTimer=setInterval(()=>{this.flush().catch(()=>{})},t),this.flushTimer.unref&&this.flushTimer.unref()}setRunIndex(t){this.currentRunIndex=t}log(t,r,s,n={}){if(this.stopped)return;let o=this.buildEntry(t,r,s,n);this.buffer.push(o)}logStep(t,r,s,n={}){if(this.stopped)return;let o=this.buildEntry("debug",r,s,n);o.run_index=t,this.stepBuffer.has(t)||this.stepBuffer.set(t,[]),this.stepBuffer.get(t).push(o)}escalate(t){let r=this.stepBuffer.get(t);r&&r.length>0&&this.buffer.push(...r),this.stepBuffer.delete(t)}discardSteps(t){this.stepBuffer.delete(t)}async flush(){if(this.buffer.length===0)return;let t=this.buffer.splice(0),r=null;try{r=await this.config.getToken()}catch{this.buffer.unshift(...t);return}let s={"Content-Type":"application/json"};r&&(s.Authorization=`Bearer ${r}`);let n=JSON.stringify(t);for(let o=0;o<3;o++){try{let a=new AbortController,u=setTimeout(()=>a.abort(),1e4),i=await D(this.config.proxyUrl,{method:"POST",headers:s,body:n,signal:a.signal});if(clearTimeout(u),i.ok)return}catch{}o<2&&await new Promise(a=>setTimeout(a,1e3*Math.pow(2,o)))}this._droppedBatches++,this._droppedEntries+=t.length}get droppedBatches(){return this._droppedBatches}get droppedEntries(){return this._droppedEntries}async shutdown(){this._droppedBatches>0&&this.log("warn","LOG_DROPS",`Dropped ${this._droppedEntries} entries in ${this._droppedBatches} batches`,{dropped_batches:this._droppedBatches,dropped_entries:this._droppedEntries}),this.stopped=!0,this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null),await this.flush()}shutdownSync(){this.stopped=!0,this.flushTimer&&(clearInterval(this.flushTimer),this.flushTimer=null)}get bufferSize(){return this.buffer.length}stepBufferSize(t){return this.stepBuffer.get(t)?.length??0}buildEntry(t,r,s,n){return{hostname:"kane-cli",service:"kane-cli",ddsource:"kane-cli",ddtags:`version:${this.config.device.cli_version}`,level:t,event:r,message:s,session_id:this.config.sessionId,run_index:r.startsWith("tcg_")?null:this.currentRunIndex,identity:this.config.identity,device:this.config.device,context:n,timestamp:new Date().toISOString()}}};import{platform as gn,arch as bn}from"os";function kt(e=process.env){try{let t=e.KANE_CLI_USER_AGENT;return t&&t.trim()?hn(t):e.CLAUDECODE==="1"||e.CLAUDE_CODE_ENTRYPOINT?"claude-code":e.CURSOR_TRACE_ID||e.TERM_PROGRAM==="cursor"?"cursor":e.TERM_PROGRAM==="vscode"||e.VSCODE_PID?"vscode":e.CI==="true"||e.GITHUB_ACTIONS==="true"||e.GITLAB_CI==="true"||e.CIRCLECI==="true"||e.BUILDKITE==="true"?"ci":"unknown"}catch{return"unknown"}}function hn(e){return e.toLowerCase().replace(/[^a-z0-9_-]/g,"-").slice(0,40)}function cs(e){let t={proxyUrl:qt,sessionId:e.sessionId,identity:e.identity,device:{cli_version:Kt,platform:gn(),arch:bn(),host_agent:kt(),invocation_mode:e.invocationMode},getToken:e.getToken};return new Ce(t)}import{execSync as yn}from"child_process";import{readFileSync as vn}from"fs";import{createHash as Sn}from"crypto";import{hostname as Rn,platform as wn,arch as _n}from"os";var Ke=null;function us(){return Ke||(Ke=In(),Ke)}function In(){let e=wn();if(e==="darwin")try{let s=yn("ioreg -rd1 -c IOPlatformExpertDevice",{encoding:"utf-8",timeout:5e3}).match(/"IOPlatformUUID"\s*=\s*"([^"]+)"/);if(s?.[1])return s[1]}catch{}if(e==="linux")try{let r=vn("/etc/machine-id","utf-8").trim();if(r)return r}catch{}let t=`${Rn()}:${e}:${_n()}`;return Sn("sha256").update(t).digest("hex").slice(0,32)}async function Cn(e){try{let t=W(e.env),s=await new Xt(t.controllerBaseUrl,e.auth).getScreenshotSas();return e.session.setScreenshotSas(s),e.log("info","SCREENSHOT_SAS_OK","Screenshot SAS fetched",{base_url:s.base_url,container:s.container,expiry:s.expiry}),new He(s,3,e.log)}catch(t){return e.log("warn","SCREENSHOT_SAS_FAIL","Screenshot SAS fetch failed",{error:t instanceof Error?t.message:String(t)}),null}}async function kn(e){if(e.session.hasRemoteLogger||!e.tmsCreds)return null;let t=e.tmsCreds,r=cs({sessionId:e.session.sessionId,identity:{org_id:String(t.org_id??""),user_id:String(t.user_id??""),machine_id:us(),email:t.email??null,email_domain:t.email_domain??"unknown",user_type:t.user_type??"unknown",env:e.env,plan:t.plan??"unknown"},invocationMode:e.invocationMode,getToken:e.getToken});return e.session.setRemoteLogger(r),r.start(),r}async function Pt(e){let[t,r]=await Promise.allSettled([e.skipScreenshotQueue?Promise.resolve(null):Cn({env:e.env,auth:e.auth,session:e.session,log:e.log}),kn({env:e.env,tmsCreds:e.tmsCreds,getToken:e.getToken,session:e.session,invocationMode:e.invocationMode})]);return{resolver:e.resolver,screenshotQueue:t.status==="fulfilled"?t.value:null,remoteLogger:r.status==="fulfilled"?r.value:null}}async function Et(e){await Promise.allSettled([e.screenshotQueue?.drain(),e.remoteLogger?.shutdown()])}async function zi(e,t){switch(e.kind){case"boot":{if(t.state.identityServicesRef.current)return t.state.identityServicesRef.current;let r=t.auth.initResolver(e.env);r.prime(e.tmsCreds),t.state.setTmsCredsCache(e.tmsCreds);let s=await At(e.env,e.tmsCreds,r,t);return xt(s,t),s}case"login":case"switch":{let r=t.state.identityServicesRef.current;r&&(await Et(r),r.resolver.revoke()),t.state.identityServicesRef.current=null,t.state.screenshotQueueRef.current=null,t.state.setTmsCredsCache(null);let s=t.auth.initResolver(e.env),n=await s.resolve(!0).catch(()=>null);if(!n)return t.log("warn","IDENTITY_VALIDATE_FAILED","Identity validation failed",{kind:e.kind,env:e.env}),null;t.state.setTmsCredsCache(n);let o=await At(e.env,n,s,t);return xt(o,t),o}case"logout":{let r=t.state.identityServicesRef.current;return r&&(await Et(r),r.resolver.revoke()),t.state.identityServicesRef.current=null,t.state.screenshotQueueRef.current=null,t.state.setTmsCredsCache(null),null}case"resessionize":{let r=t.state.identityServicesRef.current;r&&await Et(r),t.state.identityServicesRef.current=null,t.state.screenshotQueueRef.current=null;let s=t.state.getTmsCredsCache(),n=t.auth.getResolver(),o=n??t.auth.initResolver(e.env);!n&&s&&o.prime(s);let a=await At(e.env,s,o,t);return xt(a,t),a}}}async function At(e,t,r,s){let n=s.auth.getBasicAuth(),o=n?null:await s.auth.getToken(),a=n?{username:n.username,accessKey:n.access_key}:o??null;return a===null?{resolver:r,screenshotQueue:null,remoteLogger:null}:Pt({env:e,tmsCreds:t,resolver:r,auth:a,getToken:()=>s.auth.getToken(),session:s.getSession(),log:s.log,skipScreenshotQueue:s.options?.skipScreenshotQueue,invocationMode:"tui"})}function xt(e,t){t.state.identityServicesRef.current=e,t.state.screenshotQueueRef.current=e.screenshotQueue,e.remoteLogger&&(t.exit.registerCleanup("remote-logger",()=>e.remoteLogger.shutdownSync()),t.exit.setExitRemoteLogger(e.remoteLogger))}var Ge=["target","chrome_profile","cdp_endpoint","ws_endpoint","headless"];async function Pa(e,t,r){let{path:s,cwd:n,opts:o,isAgent:a,disableAskUser:u,resolved:i,resolvedAuth:l,cliOverrides:h,environment:f,envConfig:w,profile:g,model:I,creds:S,configStore:k,session:c}=e,P=!1,p=await On(s,i,o,{resolvedAuth:l,tmsBaseUrl:w.tmsBaseUrl},c.sessionId,r);if(p.abort)return{overallStatus:"failed",exitCode:p.abort.exitCode,outputDir:se(s),durationS:0,uploadResult:null};let _=p.lockAcquired,L=!1,V=!1,N=!1;_&&t.onLockState({phase:"acquired",scope:"preemptive"}),c.start({model:I,environment:f,profile:g}),c.setRecordingEnabled(!1);let ne=0,ke=l.basicAuth?{username:l.basicAuth.username,accessKey:l.basicAuth.access_key}:l.token??null,Ee=null;if(ke!==null){let d=await Pt({env:f,tmsCreds:l.resolvedCreds??null,resolver:l.resolver,auth:ke,getToken:async()=>l.token??null,session:c,log:(m,v,y,b)=>c.log(m,v,y,b),skipScreenshotQueue:!!o.local||!l.basicAuth,invocationMode:a?"agent":"cli"});Ee=d.screenshotQueue,d.remoteLogger&&(r.register("remote-logger",()=>d.remoteLogger.shutdownSync()),r.remoteLogger=d.remoteLogger,e.skipGlobalRemoteLogger||Wt(d.remoteLogger))}if(o.name){try{or(o.name)}catch(d){return process.stderr.write(`error: ${d.message}
|
|
35
|
-
`),{overallStatus:"failed",exitCode:2,outputDir:se(s),durationS:0,uploadResult:null}}c.setSessionName(o.name)}let Je={};for(let[d,m]of Object.entries(i.rootGlobal))Ge.includes(d)||(Je[d]=m);for(let[d,m]of Object.entries(h))Ge.includes(d)||m!==void 0&&(Je[d]=m);let q={...i.chrome};for(let d of Ge){let m=h[d];m!==void 0&&(q[d]=m)}let ps={...Je,...q};c.setResolvedGlobal(ps);let Tt=S.getActiveProfile()??"default",Ot=S.getDefaultEnv(),{rehydrateIfStale:hs}=await import("./profile-sync-DTTRRIVP.js");hs(S,k,Tt,Ot);let $=k.load(),Lt=(h.assertion_mode??$.assertion_mode)==="dom"?"dom":"visual",G=$.project_id??null,Ae=$.folder_id??null;if(l.basicAuth){let d=await Zt({creds:S,config:k,profile:Tt,env:Ot,tmsCreds:l.basicAuth,isLocal:!!o.local,log:(m,v,y,b)=>c.log(m,v,y,b),onAnnounce:e.onAnnounce});if(d.status==="ok")G=d.projectId,Ae=d.folderId,$=k.load(),a&&d.autoDefaulted&&process.stdout.write(Yt(d.autoDefaulted));else if(d.status==="cancelled"){process.stderr.write(`error: project/folder configuration failed. See remediation above, or use --local.
|
|
36
|
-
`);let{shutdown:m}=await import("./exit-manager-V2NW7A7U.js");return m(2,"project/folder gate failed"),{}}}let Q;try{Q=await Vr({config:{chrome_profile_path:q.chrome_profile??null,window_size:{width:1920,height:1080}},startUrl:Le,headless:q.headless??!1,wsEndpoint:q.ws_endpoint,cdpEndpoint:q.cdp_endpoint})}catch(d){return process.stderr.write(`error: Chrome launch failed: ${d.message}
|
|
37
|
-
`),await c.finish("complete"),{overallStatus:"failed",exitCode:2,outputDir:se(s),durationS:0,uploadResult:null}}let xe=Q.instance;xe&&r.register("chrome",()=>{try{xe.kill()}catch{}});let F=null,Dt=Q.cdpEndpoint??q.cdp_endpoint;if(Dt&&!q.ws_endpoint&&!q.headless)try{F=jr({headless:q.headless??!1,cdpEndpoint:Dt,chromePid:xe?.process.pid}),F&&r.register("marker-overlay",()=>F.kill())}catch(d){c.log("warn","OVERLAY_SPAWN_FAILED","Marker overlay spawn failed",{error:String(d)})}l.resolvedCreds?.org_id!==void 0&&c.setOrgId(String(l.resolvedCreds.org_id));let oe=Yr({objective:"",globalDir:qe(rt,"variables"),localDir:qe(n,".testmuai","variables"),file:o.variablesFile,inline:o.variables}),gs=i.rootGlobal.variables??{},H=xn(oe.raw,gs);c.setAuteurVariables(H.auteur);let jt=It(qe(rt,"global-memory.md"))??void 0,Ut=It(qe(n,".testmuai","context.md"))??void 0;o.local?process.stderr.write(`info: --local \u2014 KaneAI upload skipped
|
|
38
|
-
`):l.basicAuth?G||process.stderr.write(`warn: KaneAI upload skipped \u2014 no project configured.
|
|
39
|
-
`):process.stderr.write(`warn: KaneAI upload skipped \u2014 TMS credentials could not be resolved.
|
|
40
|
-
Run 'kane-cli login' (OAuth) or 'kane-cli config set-username/set-access-key' (basic auth).
|
|
41
|
-
`);let ge=!o.local&&!!l.basicAuth&&G!=null;if(c.log("info","PIPELINE_GATE_STATE","Initial gate state (run-start)",{phase:"run-start",shouldUploadArtifacts:ge,lockHeld:_,isFirstRun:p.isFirstRun,hasAuth:p.hasAuth}),ge&&p.testId==null){let d=W(f);try{let m=await ls({tmsBaseUrl:d.tmsBaseUrl,auth:l.basicAuth,objective:i.steps[0].objective,url:"",projectId:G,folderId:Ae??"",hasCustomProfile:!!q.chrome_profile,log:(v,y,b,R)=>c.log(v,y,b,R)});m&&c.setTestId(m)}catch(m){process.stderr.write(`warn: ATM test creation failed: ${m.message}
|
|
42
|
-
`)}}else p.testId&&c.setTestId(p.testId);let Pe={};if(l.basicAuth&&!o.local&&(H.secretEntries.length>0||H.nonSecretEntries.length>0))try{Pe=await Zr({variables:H,auth:l.basicAuth,orgId:String(l.resolvedCreds?.org_id??""),env:f,localMode:!!o.local,log:(d,m,v,y)=>c.log(d,m,v,y)})}catch(d){process.stderr.write(`warn: variable/secret push failed: ${d.message}
|
|
43
|
-
`)}let Qe=new Map;for(let[d,m]of H.nonSecretEntries)Qe.set(d,m.value);let Ye=new Map;for(let[d,m]of H.secretEntries)Ye.set(d,m.value);async function Ze(d){if(!l.basicAuth||o.local)return;let m=[],v=[];for(let[b,R]of Object.entries(d))if(R.secret){if(Ye.get(b)===R.value)continue;v.push([b,R])}else{if(Qe.get(b)===R.value)continue;m.push([b,R])}if(m.length===0&&v.length===0)return;let y=W(f);if(m.length>0){let b=new pe(y.tmsBaseUrl,l.basicAuth.username,l.basicAuth.access_key);for(let[R,C]of m)try{let A=await b.upsertVariable({name:R,value:C.value});Pe[R]=A.id,Qe.set(R,C.value),c.log("info","VAR_PUSH_STEP","Variable updated mid-run",{name:R})}catch(A){c.log("warn","VAR_PUSH_STEP_FAILED","Mid-run variable push failed",{name:R,error:String(A)})}}if(v.length>0){let b=new fe(y.secretsBaseUrl);for(let[R,C]of v)try{await b.pushSecret({secretKey:R,secretValue:C.value,username:l.basicAuth.username,accessKey:l.basicAuth.access_key,orgId:String(l.resolvedCreds?.org_id??"")}),Ye.set(R,C.value),c.log("info","SECRET_PUSH_STEP","Secret updated mid-run",{name:R})}catch(A){c.log("warn","SECRET_PUSH_STEP_FAILED","Mid-run secret push failed",{name:R,error:String(A)})}}}let be=Ee?(d,m,v)=>{if(!(_||p.isFirstRun))return;let y=ne+m;xr(c.sessionDir,y,d,Ee,(b,R,C,A)=>c.log(b,R,C,A),v)}:void 0,Ft=i.rootTitle??i.rootSteps[0]?.heading??En(s),bs=Object.keys(H.raw).length>0?ue(H.raw,Ft).objective:Ft,ye=Or({flag:o.url,frontmatter:i.rootGlobal?.url,configDefault:k.load().default_url}),ys=Lr({resolvedUrl:ye,local:!!o.local,allowMissingUrl:!!o.allowMissingUrl,isTTY:!!process.stdin.isTTY});c.setFirstRun(bs,ye??"");let te=new $e(i),Xe=new Date().toISOString(),vs=Date.now(),Ss=typeof o.maxSteps=="string"&&o.maxSteps!==""?parseInt(o.maxSteps,10):void 0;function Mt(d,m){let v=i.steps[d],y=ms(v.config,h),b=he(oe.raw,y.variables,v.objective);return Hr({objective:b.objective,url:d===0?ye??void 0:void 0,requireStartUrl:d===0&&ys,model:I,chrome:Q,auth:l,sessionId:c.sessionId,runIndex:m,windowSize:{width:1920,height:1080},maxSteps:y.max_steps??Ss??30,headless:q.headless??!1,disableAskUser:u,variables:Object.keys(b.variables).length>0?b.variables:void 0,globalContext:y.global_context??jt,localContext:y.local_context??Ut,sessionContext:c.getContext()})}function Nt(d){let v=i.steps[d].trace[0].stepIndex,y=i.rootSteps.find(R=>R.index===v);i.steps.slice(0,d).some(R=>R.trace[0].stepIndex===v)||t.onAgentEvent({type:"test_md_step_start",step_index:v,heading:y.heading,ref:y.body.kind==="import_ref"?{kind:"import",label:y.body.path}:null})}function et(d,m,v,y,b,R){let C=i.steps[d],A=C.trace[0].stepIndex,J=!i.steps.slice(d+1).some(O=>O.trace[0].stepIndex===A),z=v?.status==="passed"?"passed":"failed",U=v?.reason??b??void 0,K=v?.duration??R,{continueOverall:B}=te.recordStep(C,{status:z,duration_s:K,reason:U}),Y=ms(C.config,h),Z=he(oe.raw,Y.variables,C.objective).objective;if(v){let O=Pr(v,m,y);c.addRunResult(Tr(v,Z,m,O),v.total_runs)}else c.addRunResult({index:m,objective:Z,status:z,summary:"",context:{memory:{},variables:{},pointer:""}},1);if(J||!B){let O=te.snapshotOutcomes().find(E=>E.rootStepIndex===A);t.onAgentEvent({type:"test_md_step_end",step_index:A,status:O.status,duration_s:O.duration_s??0,ref_kind:O.refKind??null,inlined_count:O.inlinedCount??null,failed_sub_step_index:O.failedSubStepIndex??null})}return B}async function Rs(d){fr(d,i.steps.length);for(let m=0;m<d;m++){if(P)return{failedAt:m,cancelled:!0};let v=i.steps[m],y=p.decisions[m];if(y.kind!=="replay")return process.stderr.write(`error: runReplayPhase invoked on a non-replay decision at step ${m}
|
|
44
|
-
`),{failedAt:m,cancelled:!1};let b=c.nextRunIndex();ne=b;let R=m===0?ye??void 0:void 0,C={width:$.window_size.width,height:$.window_size.height},A=he(oe.raw,v.config.variables,v.objective),J=ht({step:v,decision:y,chrome:Q,auth:l,sessionId:c.sessionId,runIndex:b,sessionDir:c.sessionDir,windowSize:C,forceNavigateUrl:R,sessionContext:c.getContext(),variables:Object.keys(A.variables).length>0?A.variables:void 0});await Ze(A.raw),Nt(m);let z=Date.now(),U=null,K=null;try{let O=at(J,{environment:f});r.register("runner",()=>{it()&&(P=!0);try{O.cancel()}catch{}}),F?.setRunActive(!0);try{for await(let E of O.events){if(t.onAgentEvent(E),E.type==="step_event"&&E.event==="reasoning"?F?.setStepText(E.detail):E.type==="step_end"&&(E.status==="passed"&&F?.setStepComplete(),be&&be(E.index,0,E.child_id)),E.type==="run_end"){U=E;break}if(E.type==="error"){K=E.message??"runner error";break}}try{O.cancel()}catch{}if(!U&&!K){let{code:E}=await O.exited;E!==0&&(K=`runner exited with code ${E}`)}}finally{F?.setRunActive(!1),r.cleanup("runner","Replay step complete")}}catch(O){K=O.message}if(P)return{failedAt:m,cancelled:!0};let B=Math.round((Date.now()-z)/1e3),Y=et(m,b,U,null,K,B);c.recordStepRun({testmdStepIndex:i.steps[m].flatIndex,runIndex:b,totalRunDirs:1});let Z=!!K||U?.status==="failed";if(pr(m,Z?"failed":"ok"),Z||!Y)return{failedAt:m,cancelled:!1}}return{failedAt:null,cancelled:!1}}let $t=async()=>{if(_)return!0;let d=l.basicAuth;if(!d){let b=await l.resolver.resolve(!0);b?.username&&b?.access_key&&(d={username:b.username,access_key:b.access_key},l.basicAuth=d)}if(!p.testId||!p.fromCommitId||!d)return process.stderr.write(`error: cannot acquire lock \u2014 missing required state
|
|
45
|
-
`),!1;let m=c.sessionId,v=o.onLockConflict??i.rootGlobal.on_lock_conflict??"readonly",y=await fs({tmsBaseUrl:w.tmsBaseUrl,testId:p.testId,fromCommitId:p.fromCommitId,newCommitId:m,basicAuth:d,onLockConflict:v});return y==="ok"?(_=!0,p.newCommitId=m,c.log("info","MID_RUN_LOCK_ACQUIRED","Mid-run lock acquired",{test_id:p.testId}),a&&t.onLockState({phase:"acquired",scope:"mid_run"}),vt({baseUrl:ze(w.tmsBaseUrl),testId:p.testId,auth:We(d),lifecycle:r}),!0):(c.log("error","MID_RUN_LOCK_CONFLICT","Mid-run lock acquisition failed",{reason:y}),a&&t.onLockState({phase:"conflict",scope:"mid_run",reason:y}),process.stderr.write(`error: mid-run lock acquisition failed (${y})
|
|
46
|
-
`),!1)};if(a){let d=o.author===!0;d&&(pt(),c.log("info","FORCE_AUTHOR_RUN","--author flag set; walker bypassed"));let{authorBoundary:m,cancelledInPhase:v,shrinkCount:y}=await yr({decisions:p.decisions,forceAuthor:d,hasRetry:o.retry===!0||o.retryCount!==void 0,maxShrinks:o.retryCount!==void 0?parseInt(o.retryCount,10):Se.maxShrinks,runReplayPhase:Rs,session:c,accumulator:te,acquireLockIfNeeded:$t});if(N=y>0,y>0&&(c.log("info","RETRY_TRIGGERED","Retry loop triggered",{shrink_count:y,final_author_boundary:m}),t.onRetryAttempt({shrink_count:y,final_author_boundary:m,complete_reauthor:m===0})),m===0&&y>0&&c.log("info","COMPLETE_REAUTHOR_TRIGGERED","Complete reauthor fallback",{shrink_count:y}),!v&&m>=0)for(let b=m;b<i.steps.length;b++){let R=i.steps[b];if(!te.shouldRunFlatStep(R))continue;Nt(b),L=!0;let C=c.nextRunIndex();ne=C,await Ze(he(oe.raw,R.config.variables,R.objective).raw);let A=Mt(b,C),J=Date.now(),z=null,U=null,K=null,B=!1,Y=0;try{let E=at(A,{environment:f,assertionMode:Lt});r.register("runner",()=>{it()&&(P=!0);try{E.cancel()}catch{}}),F?.setRunActive(!0);try{for await(let T of E.events){if(t.onAgentEvent(T),T.type==="bifurcation"){let x=T.count??T.flows?.length??0;(T.is_single_flow??x<=1)||(K=T.flows??null,B=!0,Y=0)}else if(T.type==="run_start"&&B)Y++;else if(T.type==="step_event"&&T.event==="reasoning")F?.setStepText(T.detail);else if(T.type==="step_end"&&(T.status==="passed"&&F?.setStepComplete(),be)){let x=B?Math.max(0,Y-1):0;be(T.index,x,T.child_id)}if(T.type==="run_end"){z=T;break}if(T.type==="error"){U=T.message??"runner error";break}}try{E.cancel()}catch{}}finally{F?.setRunActive(!1),r.cleanup("runner","Step complete")}}catch(E){U=E.message}let Z=Math.round((Date.now()-J)/1e3),O=et(b,C,z,K,U,Z);if(c.recordStepRun({testmdStepIndex:i.steps[b].flatIndex,runIndex:C,totalRunDirs:z?.total_runs??1}),!O||P)break}}else{let{effectiveDecisions:d}=await import("./effective-decisions-DRM3JSR4.js"),{decideRetry:m}=await import("./replay-policy-6USQBT3E.js"),v=o.retry===!0||o.retryCount!==void 0,y=o.retryCount!==void 0?parseInt(o.retryCount,10):Se.maxShrinks,b=o.author===!0;b&&(pt(),c.log("info","FORCE_AUTHOR_RUN","--author flag set; walker bypassed"));let R=b?0:Me(p.decisions),C=0,A=null,J=p.decisions.filter(B=>B.kind==="replay").length,z=p.decisions.length-J,U=[];o.push&&U.push("--push"),v&&U.push("--retry"),o.retryCount!==void 0&&U.push(`--retry-count=${o.retryCount}`),b&&U.push("--author");let K={source:s,steps:{total:p.decisions.length,replay:J,author:z},model:I,viewport:{width:$.window_size.width,height:$.window_size.height},chrome:Q.cdpEndpoint??Q.wsEndpoint??"managed",session:c.sessionName??"ephemeral",variables:{count:Object.keys(H.raw).length,secrets:Object.values(H.raw).filter(B=>B.secret).length,names:Object.keys(H.raw)},flags:U,mode:h.mode??"testing"};for(;;){let B=c.snapshot(),Y=te.snapshot(),Z=d(p.decisions,R,b);if(C>=1){let x=R===0?`\u21BB Complete re-author \u2014 retry budget exhausted (${C}/${y})`:`\u21BB Retry ${C}/${y} \u2014 replay 0..${R-1}, author ${R}..${p.decisions.length-1}
|
|
47
|
-
reason: replay miss at step ${(A??0)+1}`;process.stderr.write(x+`
|
|
48
|
-
`)}let O=C>=1&&R>0&&A!==null?{startIdx:0,endIdx:A,count:A}:void 0;F?.setRunActive(!0);let E=await jn({decisions:Z,resolved:i,session:c,accumulator:te,tuiConfig:$,globalConfig:K,buildStepConfigAt:Mt,buildReplayConfig:x=>{let X=p.decisions[x];if(X.kind!=="replay")throw new Error("expected replay decision at index "+x);let re=i.steps[x];return ht({step:re,decision:X,chrome:Q,auth:l,sessionId:c.sessionId,runIndex:c.nextRunIndex(),sessionDir:c.sessionDir,windowSize:{width:$.window_size.width,height:$.window_size.height},forceNavigateUrl:x===0?ye??void 0:void 0,sessionContext:c.getContext(),variables:Pn(oe.raw,re.config.variables,re.objective)})},onAnyAuthorStep:()=>{L=!0},onCancel:()=>{V=!0},topBannerModel:I,topBannerAuth:`${S.getActiveProfile()??"no profile"}/${f}`,spawnOpts:{environment:f,mode:h.mode??"testing",assertionMode:Lt,log:(x,X,re,tt)=>c.log(x,X,re,tt)},priorAttemptRollup:O,pushStepLevelDelta:(x,X)=>Ze(he(oe.raw,x,X).raw),onSequencerStepEnd:(x,X,re,tt)=>{let Is=Math.round((Date.now()-tt)/1e3),Cs=x.hadError?x.reason??"runner error":null,ks=et(X,re,x.runEnd,x.bifurcationFlows??null,Cs,Is);return c.recordStepRun({testmdStepIndex:i.steps[X].flatIndex,runIndex:re,totalRunDirs:x.runEnd?.total_runs??x.bifurcationFlows?.length??1}),ks},screenshotDispatcher:be,onReasoning:x=>F?.setStepText(x),onStepComplete:()=>F?.setStepComplete(),onSpawnStart:x=>{ne=x},host:t});if(F?.setRunActive(!1),E.cancelled){r.cleanup("marker-overlay","user cancelled run"),r.cleanup("chrome","user cancelled run");break}if(E.failedAt===null)break;let T=m({failedAt:E.failedAt,shrinkCount:C,hasRetry:v,maxShrinks:y});if(T.kind==="fail"||!_&&!await $t())break;c.rollback(B),te.rollback(Y),T.kind==="complete-reauthor"?R=0:R=T.newAuthorBoundary,C++,N=!0,c.log("info","RETRY_TRIGGERED","Retry loop triggered (TTY)",{shrink_count:C,failed_at:A}),R===0&&c.log("info","COMPLETE_REAUTHOR_TRIGGERED","Complete reauthor fallback (TTY)",{shrink_count:C}),A=E.failedAt}}let M=te.finalize(),ie=Math.round((Date.now()-vs)/1e3),ws={session:c,resolvedAuth:l,chromeResult:Q,chromeInstance:xe??null,testId:c.testId??null,preparedVariables:H,variableIds:Pe,globalContext:jt,localContext:Ut,tuiConfig:$,env:f,localMode:!!o.local},ae=await es(ws,{performUpload:async()=>{if(!l.basicAuth)return null;let d=W(f),m=(L||o.push===!0)&&!V,v=(_||p.isFirstRun)&&!V&&M.overallStatus==="passed",y=ge&&(_||p.isFirstRun);c.log("info","PIPELINE_GATE_STATE","Derived gate state (finalize)",{phase:"finalize",shouldUploadArtifacts:ge,shouldUploadPipeline:y,shouldReplaceLocalOutput:m,shouldCommit:v,lockHeld:_,anyAuthorStepRan:L,cancelled:V,overallStatus:M.overallStatus});let b=os({session:c,env:f,auth:l,variables:H,variableIds:Pe,projectId:G,folderId:Ae,totalSteps:M.outcomes.length,totalDuration:ie,screenshotExtMap:Ee?.getExtMap(),codeExport:as({codeExport:o.codeExport,codeLanguage:o.codeLanguage,skipCodeValidation:o.skipCodeValidation},$.code_export),onProgress:()=>{},log:(C,A,J,z)=>c.log(C,A,J,z),shouldUploadArtifacts:y,shouldReplaceLocalOutput:m,shouldCommit:v,isFirstRun:p.isFirstRun,resolvedTest:i,sourcePath:s,stepRunRecords:c.getStepRunRecords(),outcomes:M.outcomes,overallStatus:M.overallStatus,fromCommitId:p.fromCommitId,startedISO:Xe,durationS:ie,tmsIds:{testId:p.testId??c.testId??void 0,testcaseId:p.testcaseId??c.testcaseId??void 0,projectId:G??void 0,folderId:Ae??void 0,orgId:c.orgId??void 0,sessionName:c.sessionName??Ue(s)},tmsBaseUrl:w.tmsBaseUrl,testId:p.testId??void 0,newCommitId:p.newCommitId??void 0,basicAuth:l.basicAuth??void 0,decisions:p.decisions,wantsPush:o.push===!0,retryTriggered:N,forceAuthor:o.author===!0});p.newCommitId!=null&&(b.skipTmsFinalize=!0);let R=new ar(b);return a?await R.execute():await t.runUpload(R,C=>{if(C.testcaseId&&C.shareId&&G)return wt(d.testManagerUiUrl,G,C.testcaseId,C.shareId)})},runCleanup:()=>{r.cleanup("chrome","test.md run complete")},log:(d,m,v,y)=>c.log(d,m,v,y)},{overallStatus:M.overallStatus,outcomes:M.outcomes,sourcePath:s,title:i.rootTitle,rootSteps:i.rootSteps,startedISO:Xe,durationS:ie,localMode:!!o.local,skipLocalWrites:!0});await Ln(s,p,c,M.outcomes,M.overallStatus,Xe,ie,ae.uploadResult,$,o,{resolvedAuth:l,tmsBaseUrl:w.tmsBaseUrl},_,V);let Bt=W(f),Te=ae.uploadResult?.testcaseId,Oe=Te&&ae.uploadResult?.shareId&&G?wt(Bt.testManagerUiUrl,G,Te,ae.uploadResult.shareId):void 0,Vt={overallStatus:M.overallStatus,durationS:ie,decisions:p.decisions,outcomes:M.outcomes,cancelled:V,retryTriggered:N,lockHeld:_,anyAuthorStepRan:L,isFirstRun:p.isFirstRun,wantsPush:o.push===!0,uploadResult:ae.uploadResult,shouldUploadArtifacts:ge,shouldReplaceLocalOutput:L&&!V,shouldCommit:(_||p.isFirstRun)&&!V&&M.overallStatus==="passed",shareUrl:Oe},{buildSummaryEvent:_s}=await import("./SummaryBox-47MHU37V.js");if(a?t.onAgentEvent(_s(Vt)):await t.onSummary(Vt),!a){let d=Te&&G?Fr(Bt.testManagerUiUrl,G,Te):void 0;await t.onLinks({recordedTestPath:s,outputDir:se(s),shareableLink:Oe,testCaseLink:d,codeExportDir:ae.uploadResult?.codeExportDir})}return t.onAgentEvent({type:"test_md_done",overall_status:M.overallStatus,duration_s:ie,session_id:c.sessionId,...Oe?{share_url:Oe}:{}}),{overallStatus:M.overallStatus,exitCode:M.overallStatus==="passed"?0:1,outputDir:se(s),durationS:ie,uploadResult:ae.uploadResult}}function xn(e,t){let r={...e,...t},s=Object.keys(r).length>0?ue(r,""):{variables:{},objective:"",keyMap:{}};return{raw:r,auteur:s.variables,auteurObjective:"",secretEntries:Object.entries(r).filter(([,n])=>n.secret),nonSecretEntries:Object.entries(r).filter(([,n])=>!n.secret)}}function he(e,t,r){let s={...e,...t??{}};if(Object.keys(s).length===0)return{raw:s,variables:{},objective:r};let n=ue(s,r);return{raw:s,variables:Qr(n.variables,n.objective),objective:n.objective}}function Pn(e,t,r){let s=he(e,t,r).variables;return Object.keys(s).length>0?s:void 0}function ms(e,t){let r=new Set(Ge),s={...e};for(let[n,o]of Object.entries(t))r.has(n)||n!=="variables"&&o!==void 0&&e[n]===void 0&&(s[n]=o);return s}function Tn(e,t){return e.length<=t?e:e.slice(0,t-1)+"\u2026"}async function On(e,t,r,s,n,o){let a=tr(e),u=cr(t,ds(a)?a:null);mr(t,u);let i=le(e),l=ds(i)?JSON.parse(An(i,"utf8")):null,h=l?.testcase_id,f=l?.test_id,w=l?.commit_id,g=r.push===!0,I=r.retry===!0||r.retryCount!==void 0,S=r.author===!0;g&&!h&&process.stderr.write(`[--push] no meta.json yet \u2014 flag is a no-op on first run
|
|
49
|
-
`),S&&(h=void 0,f=void 0,w=void 0);let k=s.resolvedAuth.basicAuth;if(!k){let N=await s.resolvedAuth.resolver.resolve(!0);N?.username&&N?.access_key&&(k={username:N.username,access_key:N.access_key},s.resolvedAuth.basicAuth=k)}let c=!!k,P=!r.local&&c&&f!=null&&w!=null&&h!=null,p=P&&(ur(u)||g);if(g&&!P)return process.stderr.write(`error: --push requires authenticated credentials for the lock API. Run 'kane-cli login' (OAuth) or pass --username/--access-key inline.
|
|
50
|
-
`),{resolved:t,decisions:u,testId:f,testcaseId:h,fromCommitId:w,newCommitId:null,isFirstRun:!1,hasAuth:c,canLock:P,lockAcquired:!1,abort:{exitCode:2}};if(I&&!P)return process.stderr.write(`error: --retry requires authenticated credentials for the lock API. Run 'kane-cli login' (OAuth) or pass --username/--access-key inline.
|
|
51
|
-
`),{resolved:t,decisions:u,testId:f,testcaseId:h,fromCommitId:w,newCommitId:null,isFirstRun:!1,hasAuth:c,canLock:P,lockAcquired:!1,abort:{exitCode:2}};if(S&&!c)return process.stderr.write(`error: --author requires authenticated credentials for the TMS API. Run 'kane-cli login' (OAuth) or pass --username/--access-key inline.
|
|
52
|
-
`),{resolved:t,decisions:u,testId:f,testcaseId:h,fromCommitId:w,newCommitId:null,isFirstRun:!1,hasAuth:c,canLock:P,lockAcquired:!1,abort:{exitCode:2}};let _=null,L=!1;if(p){_=n;let V=r.onLockConflict??t.rootGlobal.on_lock_conflict??"readonly",N=await fs({tmsBaseUrl:s.tmsBaseUrl,testId:f,fromCommitId:w,newCommitId:_,basicAuth:k,onLockConflict:V});if(N==="ok")L=!0,vt({baseUrl:ze(s.tmsBaseUrl),testId:f,auth:We(k),lifecycle:o});else{if(N==="abort")return{resolved:t,decisions:u,testId:f,testcaseId:h,fromCommitId:w,newCommitId:null,isFirstRun:!1,hasAuth:c,canLock:P,lockAcquired:!1,abort:{exitCode:2}};_=null}}return{resolved:t,decisions:u,testId:f,testcaseId:h,fromCommitId:w,newCommitId:_,isFirstRun:h==null,hasAuth:c,canLock:P,lockAcquired:L}}function ze(e){return`${e}/kane-cli/v1`}function We(e){return{username:e.username,accessKey:e.access_key}}async function fs(e){let t=ze(e.tmsBaseUrl),r=We(e.basicAuth),s={baseUrl:t,testId:e.testId,fromCommitId:e.fromCommitId,newCommitId:e.newCommitId,auth:r},n=await bt(s);if(n.ok)return"ok";if(!(n.reason==="concurrent"||n.reason==="base_mismatch"))return process.stderr.write(`[lock] acquire failed: ${n.reason} (HTTP ${n.httpStatus}): ${n.message}
|
|
53
|
-
`),"abort";let a=n.reason==="concurrent"?"concurrent session":"base commit mismatch (pull latest)";if(e.onLockConflict==="fail")return process.stderr.write(`[lock] ${a}; aborting (--on-lock-conflict fail)
|
|
54
|
-
`),"abort";if(e.onLockConflict==="wait"){if(n.reason==="base_mismatch")return process.stderr.write(`[lock] base commit mismatch \u2014 pull latest; aborting
|
|
55
|
-
`),"abort";for(;;){process.stderr.write(`[lock] waiting (concurrent session)...
|
|
56
|
-
`),await new Promise(i=>setTimeout(i,3e4));let u=await bt(s);if(u.ok)return"ok";if(u.reason!=="concurrent")return process.stderr.write(`[lock] wait drifted to ${u.reason} (HTTP ${u.httpStatus}): ${u.message}; aborting
|
|
57
|
-
`),"abort"}}return process.stderr.write(`[lock] ${a} \u2014 running in readonly mode (no commit)
|
|
58
|
-
`),"readonly"}async function Ln(e,t,r,s,n,o,a,u,i,l,h,f,w){let{decisions:g,testId:I,testcaseId:S,fromCommitId:k,newCommitId:c}=t;if((!(n==="passed")||w)&&f&&I&&k&&c){let p=w?"cancelled":n;process.stderr.write(`[lock] run not committed (${p}); discarding playground lock
|
|
59
|
-
`),await Dn(h,I,k,c),St();return}St()}async function Dn(e,t,r,s){let n=e.resolvedAuth.basicAuth;if(!n){let a=await e.resolvedAuth.resolver.resolve(!0);a?.username&&a?.access_key&&(n={username:a.username,access_key:a.access_key},e.resolvedAuth.basicAuth=n)}if(!n)return;let o=await _r({baseUrl:ze(e.tmsBaseUrl),testId:t,body:{commitId:s,fromCommitId:r},auth:We(n)});o.ok||process.stderr.write(`warn: discardLock failed: ${o.reason} (HTTP ${o.httpStatus}): ${o.message}
|
|
60
|
-
`)}async function jn(e){let t=null,r=!1,s=0,n=-1,o=-1,a=0,u=async i=>{if(i&&i.status==="failed")return s>0&&e.decisions[s-1].kind==="replay"&&(t=s-1),null;for(;s<e.decisions.length&&!e.accumulator.shouldRunFlatStep(e.resolved.steps[s]);)s++;if(s>=e.decisions.length)return null;let l=e.decisions[s],h=e.resolved.steps[s],f=s;s++;let w=e.session.nextRunIndex();n=f,o=w,a=Date.now(),e.onSpawnStart?.(w),l.kind==="author"&&e.onAnyAuthorStep(),await e.pushStepLevelDelta(h.config.variables,h.objective);let g=l.kind==="replay"?e.buildReplayConfig(f):e.buildStepConfigAt(f,w),I=l.kind==="replay"?"md5-match":l.reason,S=h.config??{},k={};for(let[c,P]of Object.entries(S))P!=null&&c!=="variables"&&(k[c]=P);return{config:g,banner:{stepLabel:`Step ${f+1}/${e.decisions.length}`,objective:Tn(h.objective,100)},mode:l.kind,modeReason:I,perStepOverrides:Object.keys(k).length>0?k:void 0}};return await e.host.runSteps({topBanner:{model:e.topBannerModel,auth:e.topBannerAuth},globalConfig:e.globalConfig,getNextStep:u,onStepEnd:i=>(i.status==="failed"&&n>=0&&e.decisions[n]?.kind==="replay"&&(t=n),e.onSequencerStepEnd(i,n,o,a)),onAllComplete:()=>{},onCancel:()=>{r=!0,e.onCancel()},spawnOpts:e.spawnOpts,priorAttemptRollup:e.priorAttemptRollup,screenshotDispatcher:e.screenshotDispatcher,onReasoning:e.onReasoning,onStepComplete:e.onStepComplete}),{failedAt:t,cancelled:r}}export{Pr as a,Tr as b,Be as c,Po as d,Br as e,jr as f,Rt as g,Or as h,Lr as i,xr as j,wt as k,Fr as l,Vr as m,Hr as n,Qr as o,Yr as p,Zr as q,It as r,os as s,as as t,ls as u,Pt as v,zi as w,Pa as x,xn as y,he as z,Pn as A,ms as B};
|