@testmuai/kane-cli 0.3.7 → 0.4.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-CBF6SP67.js → ChromeProfilePicker-27QCT4NT.js} +1 -1
- package/dist/{CliFeedbackPrompt-P2FJBV3S.js → CliFeedbackPrompt-LMXDRY5F.js} +1 -1
- package/dist/{CliUploadProgress-B4CVWX62.js → CliUploadProgress-QP5SPC7G.js} +1 -1
- package/dist/ConfigView-RQM2JY4K.js +2 -0
- package/dist/FolderPicker-YN2YQJXI.js +2 -0
- package/dist/HelpView-2IYG5AC3.js +2 -0
- package/dist/{InfoBox-SYT7CVM4.js → InfoBox-JELKGWY5.js} +1 -1
- package/dist/{LinksBox-R3VLKMYS.js → LinksBox-NUSUOUIW.js} +1 -1
- package/dist/{ProfilesView-XKUXSFMQ.js → ProfilesView-RXYI2IS3.js} +1 -1
- package/dist/{ProjectPicker-TWTR6SWR.js → ProjectPicker-RUR7HH2P.js} +1 -1
- package/dist/{SaveSessionPrompt-WAVXAYCK.js → SaveSessionPrompt-GUBVAQ3O.js} +1 -1
- package/dist/SingleShotApp-3XDTU2BU.js +2 -0
- package/dist/SummaryBox-5Y2YYOUM.js +2 -0
- package/dist/TestMdRunView-PPZPUVVZ.js +2 -0
- package/dist/{WhoamiView-YG6SSQTV.js → WhoamiView-IJZUFJ7B.js} +1 -1
- package/dist/{changelog-M5VP33UN.js → changelog-N4SSER5V.js} +1 -1
- package/dist/chunk-3C7ATCDM.js +2 -0
- package/dist/chunk-3Z4EHIOW.js +2 -0
- package/dist/chunk-5TOE4RHH.js +2 -0
- package/dist/chunk-6IQWD272.js +2 -0
- package/dist/{chunk-VUIXILBR.js → chunk-6NEJEMA6.js} +8 -8
- package/dist/{chunk-KX7K3Y7R.js → chunk-7G7ZLAJH.js} +1 -1
- package/dist/{chunk-X5CCG35O.js → chunk-7RPMUEEN.js} +1 -1
- package/dist/{chunk-PQGNWC33.js → chunk-AT2Y5UNP.js} +1 -1
- package/dist/chunk-BKXTOQWL.js +5 -0
- package/dist/chunk-CGAX3AXA.js +2 -0
- package/dist/chunk-CKY3UXTY.js +2 -0
- package/dist/chunk-DTFPHZE7.js +62 -0
- package/dist/chunk-H4XV224I.js +6 -0
- package/dist/chunk-H6OVTXJQ.js +2 -0
- package/dist/chunk-HN7DVSVI.js +11 -0
- package/dist/chunk-HYVAYSRZ.js +2 -0
- package/dist/chunk-IH45REQA.js +2 -0
- package/dist/chunk-J37YPPCD.js +2 -0
- package/dist/chunk-JCR3T34A.js +20 -0
- package/dist/chunk-JLOY7SNA.js +14 -0
- package/dist/chunk-L3RTVAPG.js +6 -0
- package/dist/chunk-LMV2F35W.js +2 -0
- package/dist/chunk-LRF6UP42.js +10 -0
- package/dist/chunk-M5RHRHFC.js +9 -0
- package/dist/{chunk-QKM3RHSQ.js → chunk-O2UU4TS5.js} +1 -1
- package/dist/chunk-PKQJHIKJ.js +2 -0
- package/dist/{chunk-74MJWDIW.js → chunk-PN7LNQ7G.js} +1 -1
- package/dist/{chunk-L256AYYL.js → chunk-PWHFNSDC.js} +1 -1
- package/dist/{chunk-BDC7IOXP.js → chunk-SJ7VGRQU.js} +11 -11
- package/dist/chunk-TAEW7PXN.js +2 -0
- package/dist/chunk-UJZCMEEH.js +8 -0
- package/dist/chunk-UVBDUDSL.js +2 -0
- package/dist/chunk-VS2BXLH4.js +2 -0
- package/dist/chunk-VTDVK3DK.js +2 -0
- package/dist/chunk-XQXSPUIX.js +2 -0
- package/dist/generate-headless-7UYAPXE5.js +18 -0
- package/dist/index.js +34 -38
- package/dist/{login-flow-3YFO62HA.js → login-flow-LK7GAUCZ.js} +1 -1
- package/dist/persist-recorded-session-VEFILVPX.js +3 -0
- package/dist/{pipeline-L3VM7QEX.js → pipeline-3GVPCDRE.js} +1 -1
- package/dist/{recording-banner-Q66Y2UIC.js → recording-banner-WS4Y7LVH.js} +1 -1
- package/dist/run-test-md-SXZUOYSG.js +14 -0
- package/dist/tcg-generate-CEBFKKJE.js +2 -0
- package/dist/testmd-actions-IZPOBSTC.js +2 -0
- package/dist/{validate-basic-JJOEAFLT.js → validate-basic-Y73NBDAD.js} +1 -1
- package/dist/{version-check-WWOS4OEZ.js → version-check-LNKXGYZE.js} +1 -1
- package/package.json +5 -5
- package/dist/ConfigView-PCX3TZNC.js +0 -2
- package/dist/FolderPicker-UTY6XQHP.js +0 -2
- package/dist/HelpView-CDK7II5Q.js +0 -2
- package/dist/SingleShotApp-JH6A65TZ.js +0 -2
- package/dist/SummaryBox-FDNFQYSC.js +0 -2
- package/dist/TestMdRunView-E4UDWIGT.js +0 -2
- package/dist/chunk-2SXNPFGD.js +0 -2
- package/dist/chunk-5XTLIGWL.js +0 -2
- package/dist/chunk-EIZXV3UH.js +0 -2
- package/dist/chunk-G7VF5SDK.js +0 -10
- package/dist/chunk-HROFBRMS.js +0 -5
- package/dist/chunk-JHNEE2MB.js +0 -2
- package/dist/chunk-KMTNMUVS.js +0 -8
- package/dist/chunk-LYSEA5FB.js +0 -6
- package/dist/chunk-MJQ2EHSC.js +0 -2
- package/dist/chunk-OQZG3V6B.js +0 -2
- package/dist/chunk-PJMTAAZ7.js +0 -2
- package/dist/chunk-PYU2JPAY.js +0 -2
- package/dist/chunk-QCNKJUPT.js +0 -2
- package/dist/chunk-R7JZMKC7.js +0 -9
- package/dist/chunk-TP6KYKPD.js +0 -2
- package/dist/chunk-U4XV5KUD.js +0 -2
- package/dist/chunk-VS5FTXRZ.js +0 -13
- package/dist/chunk-WZCGEQ6M.js +0 -2
- package/dist/chunk-X7VI7KK3.js +0 -11
- package/dist/chunk-YX3YFXT5.js +0 -2
- package/dist/chunk-ZAUHYR76.js +0 -2
- package/dist/chunk-ZY4BZQHD.js +0 -2
- package/dist/persist-recorded-session-LVQLORT4.js +0 -3
- package/dist/run-test-md-5TNUTTEA.js +0 -64
- package/dist/testmd-actions-O4NTH2OR.js +0 -20
|
@@ -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-O2UU4TS5.js";import"./chunk-7G7ZLAJH.js";import"./chunk-J37YPPCD.js";import"./chunk-3Z4EHIOW.js";import"./chunk-RZ4F3BHX.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{a as _,g as h}from"./chunk-HN7DVSVI.js";import{a as m,b as I,j as S}from"./chunk-AH4AXJML.js";import"./chunk-L5LI2JF4.js";import{a as f}from"./chunk-UJZCMEEH.js";import"./chunk-3Z4EHIOW.js";import"./chunk-UR6MHSHU.js";function y(e,d={}){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"),R=g?"failed":l.length===0?"skipped":"passed";a.push({rootStepIndex:t+1,status:R,duration_s:l.reduce((n,D)=>n+(D.duration??0),0),reason:g?.reason})}let P=a.some(t=>t.status==="failed")?"failed":"passed",E=new f().load().code_export?.language==="javascript"?"javascript":"python",s=I(o);e.log("info","PERSIST_START","Building staging dir",{recorded_path:o,output_dir:s,session_dir:e.sessionDir,step_count:i.length,flow_count:u.length});try{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:d.testcaseId,projectId:d.projectId,folderId:d.folderId,orgId:d.orgId??e.orgId??void 0,sessionName:e.sessionName??m(o)},codeExportDir:d.codeExportDir,codeExportLanguage:E}),e.log("info","PERSIST_STAGING_OK","Staging dir built",{output_dir:s}),S(s),e.log("info","PERSIST_OK","Persist complete",{output_dir:s})}catch(t){let r=t;e.log("error","PERSIST_FAILED","staging build / atomic replace failed",{error:r.message,stack:r.stack,output_dir:s}),process.stderr.write(`[persist] staging build / atomic replace failed: ${r.message}
|
|
3
|
+
`)}return{recordedTestPath:o,outputDir:s}}export{y as persistRecordedSession};
|
|
@@ -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-6NEJEMA6.js";import"./chunk-MDBXYXSC.js";import"./chunk-WAOCHXJ5.js";import"./chunk-7CLUJYMW.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-UR6MHSHU.js";export{a as UploadPipeline};
|
|
@@ -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-JELKGWY5.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,14 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{u as P,v as D,w as U,x as V,y as H}from"./chunk-DTFPHZE7.js";import"./chunk-UVBDUDSL.js";import{a as k,b as T}from"./chunk-L3RTVAPG.js";import{b as y,c as _}from"./chunk-3C7ATCDM.js";import{a as A}from"./chunk-HN7DVSVI.js";import"./chunk-AH4AXJML.js";import"./chunk-PN7LNQ7G.js";import"./chunk-C5UNZ6ZY.js";import"./chunk-S3DAAAE5.js";import"./chunk-6NEJEMA6.js";import"./chunk-MDBXYXSC.js";import{b as x}from"./chunk-SJ7VGRQU.js";import"./chunk-L5LI2JF4.js";import{a as S}from"./chunk-UJZCMEEH.js";import{d as C,e as E,f as L}from"./chunk-LRF6UP42.js";import"./chunk-VE3SUJMA.js";import{a as h}from"./chunk-7G7ZLAJH.js";import"./chunk-BPF7TDRU.js";import"./chunk-WAOCHXJ5.js";import{a as v}from"./chunk-J37YPPCD.js";import"./chunk-E47GFYXA.js";import"./chunk-3Z4EHIOW.js";import"./chunk-7CLUJYMW.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-UR6MHSHU.js";import{resolve as K}from"path";import{existsSync as $}from"fs";function b(a){let{isAgent:r,log:i}=a,c=e=>{r&&process.stdout.write(JSON.stringify(e)+`
|
|
3
|
+
`)};return{async runSteps(e){let{default:o}=await import("./react-QWOAB3TB.js"),{render:n}=await import("./build-JIKYOZUH.js"),{TestMdRunView:s}=await import("./TestMdRunView-PPZPUVVZ.js"),{waitUntilExit:m}=n(o.createElement(s,e),{stdout:process.stderr,exitOnCtrlC:!1});await m()},async runUpload(e,o){let{renderUploadProgress:n}=await import("./CliUploadProgress-QP5SPC7G.js");return await n(e,o)},async onSummary(e){try{let{default:o}=await import("./react-QWOAB3TB.js"),{render:n}=await import("./build-JIKYOZUH.js"),{AutoExitSummaryBox:s}=await import("./SummaryBox-5Y2YYOUM.js"),{waitUntilExit:m}=n(o.createElement(s,{data:e}),{stdout:process.stderr});await m()}catch(o){i("warn","TEST_MD_SUMMARY_RENDER_FAILED","Summary box render failed",{error:String(o)})}},async onLinks(e){try{let{default:o}=await import("./react-QWOAB3TB.js"),{render:n}=await import("./build-JIKYOZUH.js"),{LinksBox:s}=await import("./LinksBox-NUSUOUIW.js"),{waitUntilExit:m}=n(o.createElement(s,e),{stdout:process.stderr});await m()}catch(o){i("warn","TEST_MD_LINKS_RENDER_FAILED","LinksBox render failed",{error:String(o)})}},onLockState(e){c({type:"test_md_lock_state",...e})},onRetryAttempt(e){c({type:"test_md_retry_attempt",...e})},onAgentEvent(e){c(e)}}}function M(){return{register:(a,r)=>C(a,r),deregister:a=>E(a),cleanup:(a,r)=>L(a,r),remoteLogger:null}}async function le(a,r){let i=K(a);if(!$(i))return process.stderr.write(`error: file not found: ${i}
|
|
4
|
+
`),2;k(i);let c=!process.stdin.isTTY||!!r.agent,e=M(),o;try{o=A(i)}catch(t){return process.stderr.write(`error: ${t.message}
|
|
5
|
+
`),2}if(o.steps.length===0)return process.stderr.write(`info: no steps in ${i}; nothing to run.
|
|
6
|
+
`),0;let n;try{n=Y(r)}catch(t){if(t instanceof p)return process.stderr.write(t.message),t.exitCode;throw t}let s=new h,m=new S,d=!!(r.username&&r.accessKey);await T({isInteractive:!!process.stdin.isTTY&&!r.agent&&!d,creds:s,config:m});let j=s.getActiveProfile()??"default",u=r.env??void 0??s.getDefaultEnv()??"prod",N=v(u),F="v16-alpha",f;try{f=await _({creds:s,env:u,usernameFlag:r.username,accessKeyFlag:r.accessKey,log:()=>{}})}catch(t){return t instanceof y&&t.code==="not_authenticated"?process.stderr.write(`error: Not authenticated. Choose one:
|
|
7
|
+
\u2022 Pass credentials inline: --username <user> --access-key <key>
|
|
8
|
+
\u2022 Run 'kane-cli login --oauth' (browser-based)
|
|
9
|
+
\u2022 Run 'kane-cli login --username <user> --access-key <key>'
|
|
10
|
+
`):t instanceof y&&t.code==="refresh_failed"?process.stderr.write(`error: Token refresh failed. Run 'kane-cli login' to re-authenticate.
|
|
11
|
+
`):process.stderr.write(`error: auth resolution failed: ${t.message}
|
|
12
|
+
`),2}let w=String(f.resolvedCreds?.org_id??"");if(!w)return process.stderr.write("error: TMS did not return an org_id. Run `kane-cli login` again.\n"),2;{let{readMetaIfExists:t,assertOrgMatchOrExit:g}=await import("./testmd-actions-IZPOBSTC.js"),l=g(t(i),w);if(l!==null)return l}let R=new x,I=b({isAgent:c,log:(t,g,l,B)=>R.log(t,g,l,B)}),O={path:i,cwd:process.cwd(),opts:r,isAgent:c,resolved:o,resolvedAuth:f,cliOverrides:n,environment:u,envConfig:N,profile:j,model:F,creds:s,configStore:m,session:R};try{return(await P(O,I,e)).exitCode}catch(t){return process.stderr.write(`error: ${t.message}
|
|
13
|
+
`),2}}var p=class extends Error{constructor(i,c){super(i);this.exitCode=c;this.name="CliArgError"}};function Y(a){let r={mode:"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"},i=new Set(["max_steps","timeout"]),c={};for(let[e,o]of Object.entries(r)){let n=a[e];if(n===void 0||n==="")continue;let s=n;if(i.has(o)&&(s=Number(n),Number.isNaN(s))){let m="--"+e.replace(/[A-Z]/g,d=>"-"+d.toLowerCase());throw new p(`error: ${m} must be a number
|
|
14
|
+
`,2)}c[o]=s}return c}export{H as applyCliStepConfig,U as buildStepRunVariables,D as buildTestLevelVariables,V as replayVariablesForStep,le as runTestMdFile};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{c as r}from"./chunk-JLOY7SNA.js";import"./chunk-3MSXQU2C.js";import"./chunk-H6OVTXJQ.js";import"./chunk-H4XV224I.js";import"./chunk-DTFPHZE7.js";import"./chunk-UVBDUDSL.js";import"./chunk-JCR3T34A.js";import"./chunk-L3RTVAPG.js";import"./chunk-3C7ATCDM.js";import"./chunk-CGAX3AXA.js";import"./chunk-HN7DVSVI.js";import"./chunk-AH4AXJML.js";import"./chunk-BKXTOQWL.js";import"./chunk-PN7LNQ7G.js";import"./chunk-6IQWD272.js";import"./chunk-VS2BXLH4.js";import"./chunk-IH45REQA.js";import"./chunk-XQXSPUIX.js";import"./chunk-C5UNZ6ZY.js";import"./chunk-S3DAAAE5.js";import"./chunk-6NEJEMA6.js";import"./chunk-MDBXYXSC.js";import"./chunk-O2UU4TS5.js";import"./chunk-M5RHRHFC.js";import"./chunk-SJ7VGRQU.js";import"./chunk-L5LI2JF4.js";import"./chunk-UJZCMEEH.js";import"./chunk-LRF6UP42.js";import"./chunk-PWHFNSDC.js";import"./chunk-CKY3UXTY.js";import"./chunk-YCCUBQY4.js";import"./chunk-TAEW7PXN.js";import"./chunk-VE3SUJMA.js";import"./chunk-7G7ZLAJH.js";import"./chunk-BPF7TDRU.js";import"./chunk-WAOCHXJ5.js";import"./chunk-J37YPPCD.js";import"./chunk-E47GFYXA.js";import"./chunk-5TOE4RHH.js";import"./chunk-VTDVK3DK.js";import"./chunk-LMV2F35W.js";import"./chunk-HYVAYSRZ.js";import"./chunk-AT2Y5UNP.js";import{a as t}from"./chunk-HCBYKLMW.js";import"./chunk-3Z4EHIOW.js";import{c as n}from"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-7CLUJYMW.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import{e}from"./chunk-UR6MHSHU.js";var a=e(t(),1);async function f(i){let o=i.scenarioLimit!==void 0||i.perScenarioLimit!==void 0?{scenarioLimit:i.scenarioLimit,perScenarioLimit:i.perScenarioLimit}:void 0,{waitUntilExit:m}=n((0,a.jsx)(r,{initialChatMode:"generate",initialObjective:i.objective,initialGenerateLimits:o}),{exitOnCtrlC:!1});await m()}export{f as runGenerate};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{c as a,d as b,e as c,f as d,g as e,h as f,i as g,j as h,k as i,l as j,m as k}from"./chunk-JCR3T34A.js";import"./chunk-L3RTVAPG.js";import"./chunk-3C7ATCDM.js";import"./chunk-AH4AXJML.js";import"./chunk-MDBXYXSC.js";import"./chunk-UJZCMEEH.js";import"./chunk-LRF6UP42.js";import"./chunk-TAEW7PXN.js";import"./chunk-7G7ZLAJH.js";import"./chunk-BPF7TDRU.js";import"./chunk-WAOCHXJ5.js";import"./chunk-J37YPPCD.js";import"./chunk-AT2Y5UNP.js";import"./chunk-HCBYKLMW.js";import"./chunk-3Z4EHIOW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-UR6MHSHU.js";export{i as ExportError,c as assertOrgMatchOrExit,j as exportTestmd,b as metaMatchesOrg,a as readMetaIfExists,d as resolveCurrentOrgId,h as runDeleteAction,k as runExportAction,e as runListAction,f as runListTui,g as runStatusAction};
|
|
@@ -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-J37YPPCD.js";import"./chunk-3Z4EHIOW.js";import"./chunk-UR6MHSHU.js";async function a(n,e,o){let{TmsClient:r}=await import("./tms-client-R5ZIAOBH.js"),i=new r(t(n).tmsBaseUrl,e,o);for await(let m of i.listProjectsStream({perPage:1,maxPages:1}))return}export{a 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-7RPMUEEN.js";import"./chunk-3Z4EHIOW.js";import"./chunk-RZ4F3BHX.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.4.0",
|
|
4
4
|
"description": "KaneAI Terminal UI — browser automation testing agent",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -23,10 +23,10 @@
|
|
|
23
23
|
"sharp": "^0.34.5"
|
|
24
24
|
},
|
|
25
25
|
"optionalDependencies": {
|
|
26
|
-
"@testmuai/kane-cli-darwin-arm64": "0.
|
|
27
|
-
"@testmuai/kane-cli-darwin-x64": "0.
|
|
28
|
-
"@testmuai/kane-cli-linux-x64": "0.
|
|
29
|
-
"@testmuai/kane-cli-win-x64": "0.
|
|
26
|
+
"@testmuai/kane-cli-darwin-arm64": "0.4.0",
|
|
27
|
+
"@testmuai/kane-cli-darwin-x64": "0.4.0",
|
|
28
|
+
"@testmuai/kane-cli-linux-x64": "0.4.0",
|
|
29
|
+
"@testmuai/kane-cli-win-x64": "0.4.0"
|
|
30
30
|
},
|
|
31
31
|
"publishConfig": {
|
|
32
32
|
"registry": "https://registry.npmjs.org",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as d,b as l,c as r}from"./chunk-U4XV5KUD.js";import{a as m}from"./chunk-HCBYKLMW.js";import{t as o}from"./chunk-5XTLIGWL.js";import{a as t,j as u}from"./chunk-C44QQJR4.js";import{a as C}from"./chunk-6YGTRKDT.js";import{e as n}from"./chunk-UR6MHSHU.js";var f=n(C(),1);var e=n(m(),1);function D({model:c,authLabel:s,profile:g,env:p,defaultUrl:i,projectId:b,folderId:v,windowSize:x,chromeProfile:w}){let{exit:a}=u();return(0,f.useEffect)(()=>{let B=setTimeout(()=>a(),50);return()=>clearTimeout(B)},[a]),(0,e.jsx)(t,{flexDirection:"column",children:(0,e.jsx)(d,{title:"Configuration",children:(0,e.jsxs)(t,{flexDirection:"column",paddingY:1,children:[(0,e.jsx)(r,{label:"Auth"}),(0,e.jsx)(l,{label:" method",value:s}),(0,e.jsx)(l,{label:" profile",value:g}),(0,e.jsx)(l,{label:" env",value:p}),(0,e.jsx)(r,{label:"Defaults"}),(0,e.jsx)(l,{label:" url",value:i??"(none)",valueColor:i?o.cyan:o.dimmed}),(0,e.jsx)(l,{label:" model",value:c}),(0,e.jsx)(l,{label:" window",value:x}),(0,e.jsx)(l,{label:" project",value:b??"(none)"}),(0,e.jsx)(l,{label:" folder",value:v??"(none)"}),(0,e.jsx)(r,{label:"Paths"}),(0,e.jsx)(l,{label:" chrome",value:w,valueColor:o.dimmed})]})})})}export{D as ConfigView};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b}from"./chunk-YX3YFXT5.js";import"./chunk-YCCUBQY4.js";import"./chunk-WZCGEQ6M.js";import"./chunk-JHNEE2MB.js";import"./chunk-PQGNWC33.js";import"./chunk-HCBYKLMW.js";import"./chunk-5XTLIGWL.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-7CLUJYMW.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.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 T}from"./chunk-HCBYKLMW.js";import{a as f,b as i,t}from"./chunk-5XTLIGWL.js";import{a as n,b as o,j as h,k as x}from"./chunk-C44QQJR4.js";import{a as b}from"./chunk-6YGTRKDT.js";import{e as p}from"./chunk-UR6MHSHU.js";var w=p(b(),1);var e=p(T(),1),S="https://www.testmuai.com/support/docs/kane-cli-introduction",v="https://github.com/LambdaTest/kane-cli/issues";function L(){let{exit:r}=h(),{stdout:c}=x(),l=c?.columns??80;return(0,w.useEffect)(()=>{let g=setTimeout(()=>r(),50);return()=>clearTimeout(g)},[r]),(0,e.jsxs)(n,{flexDirection:"column",children:[(0,e.jsxs)(n,{paddingX:1,paddingTop:1,flexDirection:"column",children:[(0,e.jsx)(o,{color:t.purple,bold:!0,children:i}),(0,e.jsxs)(n,{children:[(0,e.jsx)(o,{color:t.dimmed,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)(m,{cmd:`${i}`,desc:"Single-shot prompt (no args, TTY)"}),(0,e.jsx)(m,{cmd:`${i} --tui`,desc:"Full interactive TUI",highlight:!0}),(0,e.jsx)(m,{cmd:`${i} run "<objective>"`,desc:"Inline objective"}),(0,e.jsx)(m,{cmd:`${i} testmd run <path>.md`,desc:"Replay a saved *_test.md file"})]}),(0,e.jsxs)(d,{title:"HELP",children:[(0,e.jsx)(m,{cmd:`${i} --help`,desc:"Show this help (long form)"}),(0,e.jsx)(m,{cmd:`${i} -h`,desc:"Show this help (short form)"}),(0,e.jsx)(m,{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.dimmed,children:["These are the only supported help invocations. Anything else (e.g. ",(0,e.jsx)(o,{color:t.cyan,children:"-help"}),") is an unknown flag."]}),(0,e.jsxs)(o,{color:t.dimmed,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-\u2026|reset",desc:"Manage configuration"}),(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.dimmed,children:[(0,e.jsx)(o,{color:t.cyan,children:"*_test.md"})," \u2014 markdown test files with YAML frontmatter and ",(0,e.jsx)(o,{color:t.cyan,children:"## "}),"step headings."]}),(0,e.jsxs)(o,{color:t.dimmed,children:["Run with ",(0,e.jsxs)(o,{color:t.cyan,children:[i," testmd run path/to/foo_test.md"]}),". (`.md` paths are not accepted by `",i," run`.)"]}),(0,e.jsxs)(o,{color:t.dimmed,children:["Sessions you run in TUI auto-save to ",(0,e.jsx)(o,{color:t.cyan,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(l-2,70))}),(0,e.jsxs)(n,{gap:3,children:[(0,e.jsxs)(n,{children:[(0,e.jsx)(o,{color:t.dimmed,children:"Docs "}),(0,e.jsx)(o,{color:t.cyan,underline:!0,children:S})]}),(0,e.jsxs)(n,{children:[(0,e.jsx)(o,{color:t.dimmed,children:"Bugs "}),(0,e.jsx)(o,{color:t.cyan,underline:!0,children:v})]})]})]}),(0,e.jsx)(o,{children:" "})]})}function d({title:r,children:c}){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.dimmed,children:r})}),c]})}function m({cmd:r,desc:c,highlight:l}){return(0,e.jsxs)(n,{marginLeft:2,children:[(0,e.jsxs)(n,{width:40,children:[(0,e.jsx)(o,{color:t.dimmed,children:"$ "}),(0,e.jsx)(o,{color:l?t.purple:t.cyan,children:r})]}),(0,e.jsx)(o,{color:t.dimmed,children:c})]})}function a({cmd:r,args:c,desc:l,highlight:g}){return(0,e.jsxs)(n,{marginLeft:2,children:[(0,e.jsx)(n,{width:16,children:(0,e.jsx)(o,{color:g?t.purple:t.green,bold:!0,children:r})}),(0,e.jsx)(n,{width:32,children:c?(0,e.jsx)(o,{color:t.dimmed,children:c}):null}),(0,e.jsx)(o,{color:t.dimmed,children:l})]})}function s({long:r,arg:c,desc:l,highlight:g}){return(0,e.jsxs)(n,{marginLeft:2,children:[(0,e.jsxs)(n,{width:30,children:[(0,e.jsx)(o,{color:g?t.purple:t.cyan,children:r}),c&&(0,e.jsxs)(o,{color:t.dimmed,children:[" ",c]})]}),(0,e.jsx)(o,{color:t.dimmed,children:l})]})}function u({label:r,cmd:c}){return(0,e.jsxs)(n,{marginLeft:2,flexDirection:"column",children:[(0,e.jsxs)(o,{color:t.dimmed,children:["# ",r]}),(0,e.jsxs)(o,{color:t.cyan,children:["$ ",c]})]})}export{L as HelpView};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{f as a}from"./chunk-R7JZMKC7.js";import"./chunk-BDC7IOXP.js";import"./chunk-L5LI2JF4.js";import"./chunk-KMTNMUVS.js";import"./chunk-G7VF5SDK.js";import"./chunk-L256AYYL.js";import"./chunk-YX3YFXT5.js";import"./chunk-YCCUBQY4.js";import"./chunk-WZCGEQ6M.js";import"./chunk-VE3SUJMA.js";import"./chunk-KX7K3Y7R.js";import"./chunk-JHNEE2MB.js";import"./chunk-BPF7TDRU.js";import"./chunk-WAOCHXJ5.js";import"./chunk-PQGNWC33.js";import"./chunk-HCBYKLMW.js";import"./chunk-5XTLIGWL.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-7CLUJYMW.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.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{a as S}from"./chunk-MJQ2EHSC.js";import"./chunk-U4XV5KUD.js";import{a as R}from"./chunk-HCBYKLMW.js";import{t as o}from"./chunk-5XTLIGWL.js";import{a as b,b as c,j as x}from"./chunk-C44QQJR4.js";import{a as w}from"./chunk-6YGTRKDT.js";import{e as y}from"./chunk-UR6MHSHU.js";var T=y(w(),1);var i=y(R(),1);function L(e){let t=e.decisions.filter(l=>l.kind==="replay").length,s=e.decisions.filter(l=>l.kind==="author").length,d=e.outcomes.filter(l=>l.status==="passed").length,p=e.outcomes.filter(l=>l.status==="failed").length,f=e.outcomes.filter(l=>l.status==="skipped").length,a=o.green,n;e.cancelled||e.overallStatus==="interrupted"?(a=o.yellow,n="CANCELLED"):e.overallStatus==="failed"?(a=o.red,n="FAILED"):n="PASSED";let r=`${n} \xB7 ${e.durationS}s \xB7 ${e.outcomes.length} steps (${d} passed, ${p} failed, ${f} skipped)`,k=`${t} replay \xB7 ${s} author`,C=e.retryTriggered,v="yes \u2014 run recovered after a replay miss",u,g=o.dimmed;if(e.cancelled)u="\u2013 not committed (cancellation)";else if(e.overallStatus==="failed")u="\u2013 not committed (run failed)",g=o.red;else if(!e.shouldCommit)e.isFirstRun?u="\u2013 not committed (first run skipped commit)":e.lockHeld?u="\u2013 not committed":u="\u2013 not committed (readonly fallback / no lock)";else{let l=e.uploadResult?.testcaseId;u=l?`\u2713 pushed (testcase=${l})`:"\u2713 pushed",g=o.green}let _=e.shouldReplaceLocalOutput?"output dir replaced":e.anyAuthorStepRan?"untouched (cancellation or no replace)":"untouched (replay-only)",m,h=o.dimmed;return e.shouldUploadArtifacts?e.uploadResult?.success?(m="\u2713 TMS",h=o.green):e.uploadResult?(m=`\u2717 failed${e.uploadResult.error?`: ${e.uploadResult.error}`:""}`,h=o.red):m="\u2013 not run":m="\u2013 skipped (--local or no auth)",{resultLine:{color:a,text:r},breakdown:k,showRetries:C,retriesText:v,commitText:u,commitColor:g,artifactsText:_,uploadText:m,uploadColor:h}}function O(e){let t=e.decisions.filter(r=>r.kind==="replay").length,s=e.decisions.filter(r=>r.kind==="author").length,d=e.outcomes.filter(r=>r.status==="passed").length,p=e.outcomes.filter(r=>r.status==="failed").length,f=e.outcomes.filter(r=>r.status==="skipped").length,a,n=!1;return e.cancelled?a="cancellation":e.overallStatus==="failed"?a="run_failed":e.shouldCommit&&e.uploadResult?.testcaseId?(a="ok",n=!0):!e.shouldCommit&&!e.lockHeld&&!e.isFirstRun?a="readonly_fallback":a="not_committed",{type:"test_md_summary",overall_status:e.overallStatus,duration_s:e.durationS,steps:{total:e.outcomes.length,passed:d,failed:p,skipped:f,replay_decisions:t,author_decisions:s},retries:{triggered:e.retryTriggered},commit:{committed:n,reason:a,...e.uploadResult?.testcaseId?{testcase_id:e.uploadResult.testcaseId}:{}},artifacts:{replaced:e.shouldReplaceLocalOutput},upload:{performed:e.shouldUploadArtifacts,...e.uploadResult?{succeeded:!!e.uploadResult.success}:{}},cancelled:e.cancelled}}function A({data:e}){let t=L(e),s=[{label:"result",value:(0,i.jsx)(c,{color:t.resultLine.color,bold:!0,children:t.resultLine.text})},{label:"breakdown",value:(0,i.jsx)(c,{color:o.dimmed,children:t.breakdown})}];return t.showRetries&&s.push({label:"retries",value:(0,i.jsx)(c,{color:o.yellow,children:t.retriesText})}),s.push({label:"commit",value:(0,i.jsx)(c,{color:t.commitColor,children:t.commitText})}),s.push({label:"artifacts",value:(0,i.jsx)(c,{color:o.dimmed,children:t.artifactsText})}),s.push({label:"upload",value:(0,i.jsx)(c,{color:t.uploadColor,children:t.uploadText})}),(0,i.jsx)(S,{title:"Run summary",titleColor:"#ff9500",rows:s})}function I({data:e}){let{exit:t}=x();return(0,T.useEffect)(()=>{let s=setTimeout(()=>t(),50);return()=>clearTimeout(s)},[t]),(0,i.jsx)(b,{flexDirection:"column",children:(0,i.jsx)(A,{data:e})})}export{I as AutoExitSummaryBox,A as SummaryBox,O as buildSummaryEvent,L as buildSummaryRendered};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as $,b as j,c as L,d as N,e as T,f as _,g as F}from"./chunk-HROFBRMS.js";import"./chunk-TP6KYKPD.js";import"./chunk-74MJWDIW.js";import"./chunk-G7VF5SDK.js";import"./chunk-JHNEE2MB.js";import{a as A}from"./chunk-MJQ2EHSC.js";import"./chunk-U4XV5KUD.js";import{a as I}from"./chunk-HCBYKLMW.js";import{t as p}from"./chunk-5XTLIGWL.js";import{a as R,b as l,d as P,i as k,j as D}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as C}from"./chunk-UR6MHSHU.js";var a=C(B(),1);var i=C(B(),1);function U(e){let r=N(e.screenshotDispatcher,e.stepLogger,e.onReasoning,e.onStepComplete),[h,f]=(0,i.useState)(0),[y,c]=(0,i.useState)("idle"),d=(0,i.useRef)("idle"),S=(0,i.useRef)(0),w=(0,i.useRef)(!1),x=(0,i.useRef)(null),v=(0,i.useRef)(null),g=(0,i.useCallback)(u=>{d.current=u,c(u)},[]),m=(0,i.useCallback)(async u=>{let n=await e.getNextConfig(u);if(!n){g("done"),e.onAllComplete?.();return}let o=u?S.current+1:0;S.current=o,f(o),e.onStepStart?.(n,o),x.current=null,v.current=null,g("running"),await r.startRun(n,e.spawnOpts)},[r,e,g]);(0,i.useEffect)(()=>{w.current||(w.current=!0,m(null))},[]),(0,i.useEffect)(()=>{if(!r.lastRunEnd||r.lastRunEnd===x.current||d.current!=="running")return;x.current=r.lastRunEnd,d.current="transitioning",c("transitioning");let u=r.lastRunEnd,n=T(r.steps),o=r.bifurcationInfo,s={status:u.status==="passed"?"passed":"failed",duration_s:u.duration??0,reason:u.reason,runEnd:u,hadError:!1,stepsPassed:n.passed,stepsFailed:n.failed,stepsTotal:n.total,bifurcationFlows:o&&!o.isSingleFlow?o.flows:null};if(!(e.onStepEnd?.(s,S.current)??!0)){g("done"),e.onAllComplete?.();return}m(s)},[r.lastRunEnd]),(0,i.useEffect)(()=>{if(!r.runError||r.runError===v.current||r.lastRunEnd||d.current!=="running")return;v.current=r.runError,d.current="transitioning",c("transitioning");let u=T(r.steps),n={status:"failed",duration_s:0,reason:r.runError,runEnd:null,hadError:!0,stepsPassed:u.passed,stepsFailed:u.failed,stepsTotal:u.total,bifurcationFlows:null};if(!(e.onStepEnd?.(n,S.current)??!0)){g("done"),e.onAllComplete?.();return}m(n)},[r.runError,r.lastRunEnd]);let O=(0,i.useCallback)(()=>{r.cancelRun()},[r]);return{runner:r,currentStepIndex:h,phase:y,cancel:O}}var b=C(I(),1);function G({runner:e,runKey:r,onStepCommit:h}){let f=L({isRunning:e.isRunning,bifurcationInfo:e.bifurcationInfo,steps:e.steps,cmInitCounts:e.cmInitCounts,replayInfo:e.replayInfo});return(0,b.jsxs)(b.Fragment,{children:[f&&(0,b.jsx)(j,{label:f.label,hasBifurcation:f.hasBifurcation}),e.isRunning&&e.steps.length>0&&(0,b.jsx)($,{steps:e.steps,bifurcated:!!e.bifurcationInfo&&!e.bifurcationInfo.isSingleFlow,flows:e.bifurcationInfo?.flows,cmInitCounts:e.cmInitCounts,maxSteps:e.maxSteps,onStepCommit:h},`run-${r}`)]})}var t=C(I(),1);function le(e){let{exit:r}=D(),h=(0,a.useRef)(0),[f,y]=(0,a.useState)([{id:"top-banner",content:(0,t.jsx)(R,{flexDirection:"column",marginBottom:1,children:(0,t.jsxs)(R,{borderStyle:"round",borderColor:"#dc4e08",paddingX:2,children:[(0,t.jsx)(l,{color:"#ff9500",bold:!0,children:"KaneAI CLI"}),(0,t.jsx)(l,{color:p.dimmed,children:" \u2502 "}),(0,t.jsx)(l,{color:p.cyan,children:e.topBanner.model}),(0,t.jsx)(l,{color:p.dimmed,children:" \u2502 "}),(0,t.jsx)(l,{color:p.dimmed,children:e.topBanner.auth})]})})},{id:"global-config",content:(0,t.jsx)(W,{data:e.globalConfig})},...e.priorAttemptRollup?[{id:"prior-rollup",content:(0,t.jsx)(l,{color:p.dimmed,children:` \u21B3 replayed ${e.priorAttemptRollup.startIdx}..${e.priorAttemptRollup.endIdx-1} (${e.priorAttemptRollup.count} steps, from prior attempt)`})}]:[]]),c=(0,a.useCallback)(n=>{let o=`s-${++h.current}`;y(s=>[...s,{id:o,content:n}])},[]),d=(0,a.useRef)(null),S=(0,a.useCallback)(async n=>{let o=await e.getNextStep(n);return o?(d.current=o,o.config):(d.current=null,null)},[e]),w=(0,a.useCallback)((n,o)=>{let s=d.current;if(!s)return;let E=s.mode==="replay"?"cyan":"#dc4e08",M=s.modeReason?` (${s.modeReason})`:"",q=s.perStepOverrides?Object.entries(s.perStepOverrides):[];c((0,t.jsxs)(R,{flexDirection:"column",marginBottom:0,children:[(0,t.jsxs)(l,{children:[(0,t.jsxs)(l,{color:p.dimmed,children:[s.banner.stepLabel," "]}),(0,t.jsxs)(l,{color:E,children:["[",s.mode,"]"]}),(0,t.jsx)(l,{color:p.dimmed,children:M})]}),(0,t.jsx)(l,{color:p.dimmed,children:s.banner.objective}),q.length>0&&(0,t.jsxs)(l,{color:p.dimmed,children:["overrides: ",q.map(([V,K])=>`${V}=${K}`).join(", ")]})]}))},[c]),x=(0,a.useRef)(0),v=(0,a.useRef)(!1),g=(0,a.useCallback)((n,o)=>(n.hadError?c((0,t.jsx)(F,{message:n.reason??"Runner error",code:"RUNNER_ERROR"})):c((0,t.jsx)(R,{flexDirection:"column",marginBottom:1,children:(0,t.jsx)(_,{status:n.status,summary:n.runEnd?.summary??"",duration:n.runEnd?.duration??0,steps:n.stepsTotal,stepsPassed:n.stepsPassed,stepsFailed:n.stepsFailed,reason:n.runEnd?.reason,creditsConsumed:n.runEnd?.credits_consumed})})),e.onStepEnd?.(n,o)??!0),[c,e]),m=U({getNextConfig:S,onStepStart:w,onStepEnd:g,onAllComplete:()=>{e.onAllComplete(),setImmediate(()=>r())},screenshotDispatcher:e.screenshotDispatcher,stepLogger:e.stepLogger,onReasoning:e.onReasoning,onStepComplete:e.onStepComplete,spawnOpts:e.spawnOpts}),O=250,u=5e3;return k((n,o)=>{if(o.ctrl&&n==="c"){let s=Date.now(),E=s-x.current;if(E<O)return;v.current&&E<u?(m.cancel(),e.onCancel?.(),setImmediate(()=>r())):(v.current=!0,c((0,t.jsx)(l,{color:"yellow",children:"press Ctrl+C again to cancel run"}))),x.current=s}}),(0,t.jsxs)(R,{flexDirection:"column",children:[(0,t.jsx)(P,{items:f,children:n=>(0,t.jsx)(R,{children:n.content},n.id)}),m.phase!=="done"&&(0,t.jsx)(G,{runner:m.runner,runKey:m.currentStepIndex,onStepCommit:c})]})}function W({data:e}){return(0,t.jsx)(A,{title:"test.md run",titleColor:"#ff9500",borderColor:p.dimmed,rows:[{label:"source",value:e.source},{label:"steps",value:`${e.steps.total} (${e.steps.replay} replay, ${e.steps.author} author per walker)`},{label:"model",value:e.model},{label:"viewport",value:`${e.viewport.width} x ${e.viewport.height}`},{label:"chrome",value:e.chrome},{label:"session",value:e.session},{label:"variables",value:`${e.variables.count} (${e.variables.secrets} secret)`},{label:"flags",value:e.flags.length>0?e.flags.join(" "):"(none)"}]})}export{le as TestMdRunView};
|
package/dist/chunk-2SXNPFGD.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{f as v,g as b}from"./chunk-G7VF5SDK.js";import{b as f}from"./chunk-KX7K3Y7R.js";import{a as m}from"./chunk-JHNEE2MB.js";import{a as h}from"./chunk-BPF7TDRU.js";var p=class extends Error{constructor(n,s){super(n);this.code=s;this.name="AuthError"}};async function y(e){let o=e.credentials.expires_at,n=e.thresholdSeconds??300;if(o-Date.now()/1e3>=n)return null;let s=e.creds.loadClient(e.profile,e.env);if(!s)return null;let r=await new f(e.env).refreshToken(e.credentials.refresh_token,s.client_id),t=Math.floor(Date.now()/1e3)+r.expires_in;return e.creds.saveCredentials(e.profile,e.env,{access_token:r.access_token,refresh_token:r.refresh_token,expires_at:t,scope:r.scope}),{accessToken:r.access_token,refreshToken:r.refresh_token,expiresAt:t,scope:r.scope}}async function L(e){let{creds:o,env:n,usernameFlag:s,accessKeyFlag:a,log:r}=e,t=null,l=null;if(s&&a)t={username:s,access_key:a},r("info","AUTH_RESOLVE_FLAGS","Auth resolved via CLI flags",{username:s});else{let i=o.resolveAuth();i?.method==="basic"&&(t={username:i.username,access_key:i.access_key},r("info","AUTH_RESOLVE_CONFIG","Auth resolved via config",{username:i.username}))}if(!t){let{credentials:i,profile:A}=o.getActiveCredentials();if(!i)throw new p("Not authenticated \u2014 no credentials found","not_authenticated");if(l=i.access_token,i.expires_at-Date.now()/1e3<300)try{let c=await y({creds:o,profile:A,env:n,credentials:i});c&&(l=c.accessToken,r("info","AUTH_TOKEN_REFRESHED","OAuth token refreshed"))}catch(c){let g=c instanceof Error?c.message:String(c);throw r("error","TOKEN_REFRESH_FAILED","Token refresh failed",{error:g}),new p(`Token refresh failed: ${g}`,"refresh_failed")}}let R=m(n),x=async()=>l,E=t?{username:t.username,access_key:t.access_key}:null,d=new h(R.controllerBaseUrl,x,E,r),u=await d.resolve();return u&&!t&&(t={username:u.username,access_key:u.access_key},r("info","AUTH_RESOLVE_CONTROLLER","Auth resolved via controller",{username:u.username})),{basicAuth:t,token:l,resolver:d,resolvedCreds:u}}async function P(e){if(!e.isInteractive)return{recovered:!1};if(S(e.creds,e.config))return{recovered:!1};let{SingleShotApp:o}=await import("./SingleShotApp-JH6A65TZ.js"),{render:n}=await import("./build-JIKYOZUH.js"),s=await import("./react-QWOAB3TB.js"),a={current:null},r={current:!1},{waitUntilExit:t,unmount:l}=n(s.default.createElement(o,{resultRef:a,mode:"login",loginCompleteRef:r}),{exitOnCtrlC:!1});b(()=>l()),await t();try{process.stdin.setRawMode?.(!1)}catch{}return process.stdout.write("\x1B[?25h"),r.current?{recovered:!0}:(v(0,"Startup gate cancelled"),{recovered:!1})}function S(e,o){let n=e.getActiveProfile(),s=e.getDefaultEnv();if(!n||!!!(e.loadBasicAuth(n,s)||e.loadCredentials(n,s)))return!1;let r=o.load();return!!r.project_id&&!!r.folder_id}export{y as a,p as b,L as c,P as d};
|
package/dist/chunk-5XTLIGWL.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{homedir as s}from"os";import{join as t}from"path";var c="0.3.7",l="kane-cli",e=t(s(),".testmuai","kaneai"),m=t(e,"profiles"),i=t(e,"tui-config.json"),d="https://registry.npmjs.org/@testmuai/kane-cli",h="https://api.github.com/repos/LambdaTest/kane-cli/releases",f="https://dd-proxy.lambdatest.com/intake/kane-cli",u="https://kaneai-playground.lambdatest.io",_=9222,b=9230,U=t(e,"chrome-profiles"),r="127.0.0.1",x=18392,g=18400,o="/callback";function A(a){return`http://${r}:${a}${o}`}var R="KANE CLI",L="*",C={prod:{authBaseUrl:"https://auth.lambdatest.com",consentUrl:"https://accounts.lambdatest.com",controllerBaseUrl:"https://kaneai-api.lambdatest.com/v16-controller/v1",tmsBaseUrl:"https://test-manager-api.lambdatest.com/api",secretsBaseUrl:"https://api-hyperexecute.lambdatest.com",testManagerUiUrl:"https://test-manager.lambdatest.com",shareApiBaseUrl:"https://api.lambdatest.com",v16ServerHost:"https://kaneai-api.lambdatest.com/v16-server"},stage:{authBaseUrl:"https://stage-auth.lambdatestinternal.com",consentUrl:"https://stage-accounts.lambdatestinternal.com",controllerBaseUrl:"https://auteur-stage-automind.lambdatestinternal.com/v16-controller/v1",tmsBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com/api",secretsBaseUrl:"https://api-stage-hyperexecute.lambdatestinternal.com",testManagerUiUrl:"https://stage-test-manager.lambdatestinternal.com",shareApiBaseUrl:"https://stage-api.lambdatestinternal.com",v16ServerHost:"https://auteur-stage-automind.lambdatestinternal.com/v16-server"}},E={base:"#ffffff",primary:"#ff9500",secondary:"#888888",accent:"#ffffff",dim:"#666666",ambient:"#444444",statusPass:"#4ade80",statusFail:"#ef4444",purple:"#ff9500",cyan:"#ff9500",yellow:"#ff9500",green:"#4ade80",greenDim:"#666666",red:"#ef4444",redDim:"#666666",dimmed:"#666666",muted:"#444444"};export{c as a,l as b,e as c,i as d,d as e,h as f,f as g,u as h,_ as i,b as j,U as k,r as l,x as m,g as n,o,A as p,R as q,L as r,C as s,E as t};
|
package/dist/chunk-EIZXV3UH.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as f}from"./chunk-TP6KYKPD.js";import{a as x}from"./chunk-HCBYKLMW.js";import{t}from"./chunk-5XTLIGWL.js";import{a as r,b as n}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as c}from"./chunk-UR6MHSHU.js";var p=c(B(),1);var e=c(x(),1);function v(){return[{name:"convert",label:"Converting session data",status:"pending"},{name:"zip",label:"Compressing artifacts",status:"pending"},{name:"presign",label:"Requesting upload URLs",status:"pending"},{name:"upload",label:"Uploading to KaneAI",status:"pending"},{name:"atomic_replace",label:"Replacing local output",status:"pending"},{name:"commit_lock",label:"Committing to TMS",status:"pending"},{name:"finalize",label:"Finalizing test case",status:"pending"},{name:"code_export",label:"Downloading test code",status:"pending"}]}function U(s,o,d,a){return s.map(l=>l.name===o?{...l,status:d,detail:a}:l)}function R(s){let o=s/1e3;if(o<60)return`${o.toFixed(1)}s`;let d=Math.floor(o/60),a=Math.round(o%60);return`${d}m ${a}s`}function D(s){let[o,d]=(0,p.useState)(0),a=p.default.useRef(Date.now());return(0,p.useEffect)(()=>{if(!s)return;a.current=Date.now();let l=setInterval(()=>{d(Date.now()-a.current)},100);return()=>clearInterval(l)},[s]),o}function h({steps:s,status:o,testUrl:d,error:a}){let l=D(o==="uploading");return o==="uploading"?(0,e.jsxs)(r,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,e.jsxs)(r,{children:[(0,e.jsx)(n,{color:t.primary,children:"\u2601 "}),(0,e.jsx)(n,{color:t.primary,bold:!0,children:"Saving to KaneAI"}),(0,e.jsxs)(n,{color:t.dimmed,children:[" ",R(l)]})]}),(0,e.jsx)(r,{flexDirection:"column",marginTop:1,children:s.filter(i=>i.status!=="skipped").map((i,S,T)=>{let b=S===T.length-1?"\u2514\u2500":"\u251C\u2500",m=i.status==="done",u=i.status==="running",g=i.status==="failed";return(0,e.jsxs)(r,{children:[(0,e.jsxs)(n,{color:t.dimmed,children:[" ",b," "]}),(0,e.jsx)(r,{width:3,children:u?(0,e.jsx)(f,{}):m?(0,e.jsx)(n,{color:t.green,children:"\u2713"}):g?(0,e.jsx)(n,{color:t.red,children:"\u2717"}):(0,e.jsx)(n,{color:t.muted,children:"\u25CB"})}),(0,e.jsx)(n,{color:m?t.dim:u?t.base:g?t.red:t.muted,children:i.label}),i.detail&&(0,e.jsxs)(n,{color:t.dimmed,children:[" ",i.detail]})]},i.name)})}),(0,e.jsx)(r,{marginTop:1,children:(0,e.jsx)(n,{color:t.muted,children:" press Ctrl+C twice to force exit"})})]}):o==="success"?(0,e.jsx)(e.Fragment,{}):(0,e.jsxs)(r,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,e.jsxs)(r,{children:[(0,e.jsx)(n,{color:t.red,children:"\u2601 "}),(0,e.jsx)(n,{color:t.red,bold:!0,children:"Save failed"})]}),a&&(0,e.jsxs)(r,{marginTop:0,children:[(0,e.jsx)(n,{color:t.dimmed,children:" "}),(0,e.jsx)(n,{color:t.dim,children:a})]})]})}export{v as a,U as b,h as c};
|
package/dist/chunk-G7VF5SDK.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
var v=()=>!!process.env.KANE_DEV_MODE,o=[],a=!1,f=null,g=null,d=null,i=null;function x(e){i=e}function m(){return i}function h(){return a}function y(e,t){o=o.filter(r=>r.name!==e),o.push({name:e,fn:t})}function R(e,t){let r=o.find(n=>n.name===e);if(!r)return;o=o.filter(n=>n.name!==e);let s=!0;try{r.fn()}catch(n){s=!1,process.stderr.write(`[exit-manager] cleanup(${e}) failed: ${n instanceof Error?n.message:String(n)}
|
|
3
|
-
`)}t&&s&&v()&&process.stderr.write(`[exit-manager] cleanup(${e}): ${t}
|
|
4
|
-
`)}function l(e,t,r=!1){if(a){process.exit(f??e);return}if(a=!0,f=e,r&&i)try{i.log("error","CRASH",t),i.shutdownSync()}catch{}let s=[...o].reverse(),n=[];for(let u of s)try{u.fn(),n.push(u.name)}catch(c){process.stderr.write(`[exit-manager] cleanup(${u.name}) failed: ${c instanceof Error?c.message:String(c)}
|
|
5
|
-
`)}if(o=[],v()&&(process.stderr.write(`[exit-manager] shutdown(${e}): ${t}
|
|
6
|
-
`),n.length>0&&process.stderr.write(`[exit-manager] cleaned up: ${n.join(", ")}
|
|
7
|
-
`)),r&&d){try{d()}catch{}process.stderr.write(`
|
|
8
|
-
Kane CLI crashed unexpectedly: ${t}
|
|
9
|
-
`+(n.length>0?`Resources cleaned up (${n.join(", ")}).
|
|
10
|
-
`:"")),process.exit(e);return}if(g&&!r){g();return}process.exit(e)}function w(e){g=e}function E(e){d=e}var p=!1;function $(){p||(p=!0,process.on("SIGINT",()=>{l(130,"Received SIGINT",!0)}),process.on("SIGTERM",()=>{l(143,"Received SIGTERM",!0)}),process.on("uncaughtException",e=>{l(1,`Uncaught exception: ${e.message}`,!0)}),process.on("unhandledRejection",e=>{l(1,`Unhandled rejection: ${String(e)}`,!0)}))}export{x as a,m as b,h as c,y as d,R as e,l as f,w as g,E as h,$ as i};
|
package/dist/chunk-HROFBRMS.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as se,b as Te}from"./chunk-TP6KYKPD.js";import{b as ke}from"./chunk-74MJWDIW.js";import{d as Be,e as ae}from"./chunk-G7VF5SDK.js";import{a as Re}from"./chunk-U4XV5KUD.js";import{a as N}from"./chunk-HCBYKLMW.js";import{t as s}from"./chunk-5XTLIGWL.js";import{a as c,b as o,d as ye,k as ue}from"./chunk-C44QQJR4.js";import{a as le}from"./chunk-6YGTRKDT.js";import{e as j}from"./chunk-UR6MHSHU.js";var G=j(N(),1),Le=64;function Pe(t){return t.split(`
|
|
3
|
-
`).map(i=>i.replace(/^[-–•]\s*/,"").trim()).filter(i=>i.length>0)}function Ge({status:t,summary:i,duration:l,steps:u,stepsPassed:S,stepsFailed:f,reason:x,creditsConsumed:d}){let D=t==="passed",E=D?s.green:s.red,P=D?"\u2713":"\u2717",F=t.toUpperCase(),H=S??(D?u:Math.max(0,u-1)),I=f??(D?0:1),M=I>0?`${u} steps (${H} passed, ${I} failed)`:`${u} steps`,Q=l<60?`${l.toFixed(1)}s`:`${Math.floor(l/60)}m ${Math.round(l%60)}s`,V=Pe(i);return(0,G.jsx)(c,{flexDirection:"column",marginTop:1,children:(0,G.jsxs)(c,{borderStyle:"round",borderColor:E,flexDirection:"column",paddingX:2,paddingY:1,width:Le+6,children:[(0,G.jsxs)(c,{flexDirection:"column",children:[(0,G.jsxs)(o,{bold:!0,color:E,children:[P," ",F]}),(0,G.jsxs)(o,{color:s.dimmed,wrap:"wrap",children:[M," \xB7 ",Q,typeof d=="number"&&d>0?` \xB7 ${parseFloat(d.toFixed(4))} credits`:""]})]}),V.length>0&&(0,G.jsx)(c,{flexDirection:"column",marginTop:1,marginLeft:1,children:V.map((Z,W)=>(0,G.jsxs)(c,{marginBottom:W<V.length-1?1:0,children:[(0,G.jsx)(o,{color:s.primary,children:"\u25CF "}),(0,G.jsx)(c,{flexShrink:1,children:(0,G.jsx)(o,{wrap:"wrap",children:Z})})]},W))}),x&&!D&&(0,G.jsx)(c,{marginTop:1,children:(0,G.jsxs)(o,{color:s.red,wrap:"wrap",children:["Reason: ",x]})})]})})}var A=j(N(),1);function Ke({message:t,code:i,remediation:l,docsUrl:u}){return(0,A.jsx)(Re,{title:"Error",variant:"error",children:(0,A.jsxs)(c,{flexDirection:"column",paddingY:1,children:[(0,A.jsxs)(o,{color:s.red,bold:!0,children:[" \u2717 ",t]}),i&&(0,A.jsxs)(c,{marginTop:0,marginLeft:5,children:[(0,A.jsx)(o,{color:s.muted,children:"Code: "}),(0,A.jsx)(o,{color:s.dimmed,children:i})]}),l&&(0,A.jsxs)(c,{flexDirection:"column",marginTop:1,marginLeft:5,children:[(0,A.jsx)(o,{color:s.green,bold:!0,children:"Fix:"}),(0,A.jsxs)(o,{color:s.cyan,children:["$ ",l]})]}),u&&(0,A.jsxs)(c,{marginTop:1,marginLeft:5,children:[(0,A.jsx)(o,{color:s.muted,children:"Docs: "}),(0,A.jsx)(o,{color:s.cyan,underline:!0,children:u})]})]})})}var $=j(le(),1);var we=j(le(),1);var de=j(N(),1),De="#ffc580",Fe="#ffd9a8",ve="#ffffff";function _e({text:t,active:i=!0}){let[l,u]=(0,we.useState)(0),S=4;if(se(()=>{u(x=>(x+1)%(t.length+S*2))},i?80:null),!i)return(0,de.jsx)(o,{color:ve,children:t});let f=t.split("").map((x,d)=>{let D=l-S,E=Math.abs(d-D-S/2),P;return E<=S/2?P=De:E<=S?P=Fe:P=ve,(0,de.jsx)(o,{color:P,children:x},d)});return(0,de.jsx)(o,{children:f})}var O=j(N(),1),Oe={starting:s.cyan,running:s.purple,passed:s.green,failed:s.red,cancelled:s.dimmed,timed_out:s.yellow};function fe({currentStep:t,maxSteps:i,elapsed:l,status:u}){let{stdout:S}=ue(),f=S?.columns??80,x=Oe[u]??s.purple,d=l<60?`${l.toFixed(1)}s`:`${Math.floor(l/60)}m ${Math.round(l%60)}s`;return(0,O.jsxs)(c,{flexDirection:"column",marginTop:1,children:[(0,O.jsx)(o,{color:s.muted,children:"\u2500".repeat(Math.min(f,60))}),(0,O.jsxs)(c,{children:[(0,O.jsx)(o,{children:" "}),(0,O.jsx)(o,{color:s.dimmed,children:"Steps "}),(0,O.jsx)(o,{bold:!0,children:t}),(0,O.jsxs)(o,{color:s.dimmed,children:["/",i]}),(0,O.jsx)(o,{children:" "}),(0,O.jsx)(o,{color:s.dimmed,children:"Elapsed "}),(0,O.jsx)(o,{bold:!0,children:d}),(0,O.jsx)(o,{children:" "}),(0,O.jsx)(o,{color:s.dimmed,children:"Status "}),(0,O.jsx)(o,{bold:!0,color:x,children:u})]})]})}var Me={click:"\u25CF",type:"\u229E",scroll:"\u2195",navigate:"\u2192",analyze:"\u25CE",assert:"\u25C8","if-else":"\u2442",select:"\u25BC",press_key:"\u21B5",wait:"\u2026",tool_call:"\u2299"};function $e(t){return Me[t]??"\u25CF"}var ne=j(N(),1);function xe({steps:t,flows:i,cmInitCounts:l,renderStep:u}){return(0,ne.jsxs)(c,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[(0,ne.jsxs)(o,{color:s.dimmed,children:["\u2501\u2501 Bifurcated into ",i?.length??t.length," flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"]}),t.map((S,f)=>(0,ne.jsxs)(c,{flexDirection:"column",marginTop:f>0?1:0,children:[(0,ne.jsxs)(o,{color:s.purple,children:["Flow ",f+1,": ",i?.[f]??S.objective]}),l&&l[f]!=null&&(0,ne.jsxs)(o,{color:s.dimmed,children:[" \u25AA Generated task with ",l[f]," checkpoints"]}),S.children&&S.children.length>0?S.children.map(x=>u(x,`f${f}-${x.index}`)):S.status==="pending"&&(0,ne.jsx)(o,{color:s.dimmed,children:" \u25CB Waiting..."})]},f))]})}var r=j(N(),1);function U({step:t,indent:i=2}){let l=t.actionType?$e(t.actionType):null,u=t.status==="running",S=t.status==="passed",f=t.status==="failed",x=t.status==="pending"||t.status==="stopped",{stdout:d}=ue(),D=d?.columns??80,E=Math.max(20,D-i-21),P=t.objective??"",F=P.length>E?P.slice(0,E-1)+"\u2026":P,H=(t.duration??0)*1e3,I=t.duration!=null?H<1e3?`${Math.round(H)}ms`:`${(H/1e3).toFixed(1)}s`:"";return(0,r.jsxs)(c,{flexDirection:"column",children:[(0,r.jsxs)(c,{marginLeft:i,children:[(0,r.jsx)(c,{width:4,children:(0,r.jsxs)(o,{color:s.muted,children:[String(t.index).padStart(2," ")," "]})}),(0,r.jsx)(c,{width:3,children:u?(0,r.jsx)(Te,{}):S?(0,r.jsx)(o,{color:s.green,bold:!0,children:"\u2713"}):f?(0,r.jsx)(o,{color:s.red,bold:!0,children:"\u2717"}):(0,r.jsx)(o,{color:s.muted,children:"\u25CB"})}),(0,r.jsx)(c,{flexGrow:1,children:u?(0,r.jsx)(_e,{text:F,active:!0}):f?(0,r.jsx)(o,{color:s.red,children:F}):x?(0,r.jsx)(o,{color:s.dimmed,children:F}):(0,r.jsx)(o,{color:s.greenDim,children:F})}),(S||f)&&l?(0,r.jsx)(c,{width:3,marginLeft:1,children:(0,r.jsx)(o,{color:s.muted,children:l})}):(0,r.jsx)(c,{width:3,marginLeft:1}),(0,r.jsx)(c,{width:7,justifyContent:"flex-end",children:(0,r.jsx)(o,{color:s.dimmed,children:I})})]}),t.children&&t.children.length>0&&(0,r.jsx)(c,{flexDirection:"column",children:t.children.map((M,Q)=>(0,r.jsx)(U,{step:M,indent:i+2},`child-${Q}`))})]})}function ft({steps:t,bifurcated:i,flows:l,cmInitCounts:u,maxSteps:S=50,staticSteps:f=!1,onStepCommit:x}){let d=(0,$.useRef)(new Set),D=(0,$.useRef)(!1),E=(0,$.useRef)(new Set),P=(0,$.useRef)(!1),F=(0,$.useRef)(new Set),H=(0,$.useRef)(0);(0,$.useEffect)(()=>{t.length===0&&H.current>0&&(d.current.clear(),D.current=!1,E.current.clear(),P.current=!1,F.current.clear()),H.current=t.length},[t.length]);let I=t.flatMap(n=>[n,...n.children??[]]),M=I.some(n=>n.status==="running"),Q=I.some(n=>n.status==="failed"),V=I.length===0||I.every(n=>n.status==="pending"),Z=I.filter(n=>n.status==="passed"||n.status==="failed").length,W;V?W="starting":M?W="running":Q?W="failed":W="passed";let ee=(0,$.useRef)(null),[ie,ce]=(0,$.useState)(0);(0,$.useEffect)(()=>{I.length===0||V?(ee.current=null,ce(0)):M&&ee.current==null&&(ee.current=Date.now())},[M,V,I.length]),(0,$.useEffect)(()=>{if(!M)return;let n=setInterval(()=>{ee.current!=null&&ce((Date.now()-ee.current)/1e3)},500);return()=>clearInterval(n)},[M]);let v=(0,$.useRef)(new Set),[C,K]=(0,$.useState)([]),re=(0,$.useRef)(!1);(0,$.useEffect)(()=>{if(!f||i)return;let n=[];if(!i&&!re.current&&u&&u[0]!=null&&(re.current=!0,u[0]>0&&n.push({key:"cm_init_0",type:"cm_init",count:u[0]})),i){!v.current.has(-1)&&t.length>0&&(v.current.add(-1),n.push({key:"bif_header",type:"bifurcation_header",flowCount:l?.length??t.length}));for(let p=0;p<t.length;p++){let a=t[p],y=-(p+10);v.current.has(y)||(v.current.add(y),n.push({key:`flow_header_${p}`,type:"flow_header",flowIdx:p,label:l?.[p]??a.objective,cmCount:u?.[p]}));for(let B of a.children??[])(B.status==="passed"||B.status==="failed")&&!v.current.has(B.index)&&(v.current.add(B.index),n.push({key:`step_f${p}_${B.index}`,type:"step",step:{...B}}))}}else for(let p of t)(p.status==="passed"||p.status==="failed")&&!v.current.has(p.index)&&(v.current.add(p.index),n.push({key:`step_${p.index}`,type:"step",step:{...p,children:p.children?[...p.children]:void 0}}));n.length>0&&K(p=>[...p,...n])},[t,i,l,u,f]),(0,$.useEffect)(()=>{if(x)if(!i&&!P.current&&u&&u[0]!=null&&(P.current=!0,u[0]>0&&x((0,r.jsx)(c,{marginLeft:2,children:(0,r.jsxs)(o,{color:s.dimmed,children:["\u25A0 Generated task with ",u[0]," checkpoints"]})}))),i&&l&&!D.current&&(D.current=!0,x((0,r.jsx)(o,{color:"#b388ff",children:"\u2501\u2501 Bifurcated into "+l.length+" flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"}))),i){let n=t.flatMap((p,a)=>{let y=p.children??[];return!E.current.has(a)&&y.length>0&&(E.current.add(a),x((0,r.jsx)(o,{color:"#b388ff",children:" Flow "+(a+1)+": "+(l?.[a]??"")})),u?.[a]!=null&&u[a]>0&&!F.current.has(a)&&(F.current.add(a),x((0,r.jsx)(c,{marginLeft:2,children:(0,r.jsxs)(o,{color:s.dimmed,children:[" \u25AA Generated task with ",u[a]," checkpoints"]})})))),u?.[a]!=null&&u[a]>0&&E.current.has(a)&&!F.current.has(a)&&(F.current.add(a),x((0,r.jsx)(c,{marginLeft:2,children:(0,r.jsxs)(o,{color:s.dimmed,children:[" \u25AA Generated task with ",u[a]," checkpoints"]})}))),y});for(let p of n){let a=`${p.index}-${p.objective}`;d.current.has(a)||(p.status==="passed"||p.status==="failed"||p.status==="stopped")&&(d.current.add(a),x((0,r.jsx)(c,{marginLeft:2,children:(0,r.jsx)(U,{step:p})})))}}else for(let n of t){let p=`${n.index}-${n.objective}`,a=!!n.branchObjective;a&&!d.current.has(p)&&(d.current.add(p),x((0,r.jsx)(c,{marginLeft:2,children:(0,r.jsx)(U,{step:{...n,children:void 0}})})));for(let y of n.children??[]){let B=`child-${n.index}-${y.index}-${y.objective}`;d.current.has(B)||(y.status==="passed"||y.status==="failed"||y.status==="stopped")&&(d.current.add(B),x((0,r.jsx)(c,{marginLeft:4,children:(0,r.jsx)(U,{step:y})})))}!a&&!d.current.has(p)&&(n.status==="passed"||n.status==="failed"||n.status==="stopped")&&(d.current.add(p),x((0,r.jsx)(c,{marginLeft:2,children:(0,r.jsx)(U,{step:{...n,children:void 0}})})))}},[t,x,i,l,u]);let Y=[];if(x)if(i)for(let n of t){let a=(n.children??[]).filter(y=>{let B=`${y.index}-${y.objective}`;return!d.current.has(B)});a.length>0&&Y.push({...n,children:a})}else for(let n of t){let p=`${n.index}-${n.objective}`,a=d.current.has(p),y=(n.children??[]).filter(B=>{let L=`child-${n.index}-${B.index}-${B.objective}`;return!d.current.has(L)});a?y.length>0&&Y.push({...n,children:y}):Y.push({...n,children:y})}else if(f){if(!i)for(let n of t)v.current.has(n.index)||Y.push(n)}if(!f){let n=x?Y:t;return(0,r.jsxs)(c,{flexDirection:"column",children:[i?x?n.length>0?(0,r.jsx)(c,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:n.map((a,y)=>(0,r.jsx)(c,{flexDirection:"column",marginTop:y>0?1:0,children:a.children&&a.children.length>0?a.children.map(B=>(0,r.jsx)(U,{step:B},`f${y}-${B.index}`)):a.status==="pending"&&(0,r.jsx)(o,{color:s.dimmed,children:" \u25CB Waiting..."})},y))}):null:(0,r.jsx)(xe,{steps:t,flows:l,cmInitCounts:u,renderStep:(a,y)=>(0,r.jsx)(U,{step:a},y)}):(0,r.jsxs)(c,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[!x&&u&&u[0]!=null&&(0,r.jsxs)(o,{color:s.dimmed,children:["\u25AA Generated task with ",u[0]," checkpoints"]}),n.map(a=>{let y=`${a.index}-${a.objective}`;return x&&d.current.has(y)?(0,r.jsx)(c,{flexDirection:"column",children:(a.children??[]).map(B=>(0,r.jsx)(c,{marginLeft:2,children:(0,r.jsx)(U,{step:B})},B.index))},`branch-children-${a.index}`):(0,r.jsx)(U,{step:a},a.index)})]}),M&&(0,r.jsx)(fe,{currentStep:Z,maxSteps:S,elapsed:ie,status:W})]})}return i?(0,r.jsxs)(c,{flexDirection:"column",children:[(0,r.jsx)(xe,{steps:t,flows:l,cmInitCounts:u,renderStep:(n,p)=>(0,r.jsx)(U,{step:n},p)}),M&&(0,r.jsx)(fe,{currentStep:Z,maxSteps:S,elapsed:ie,status:W})]}):(0,r.jsxs)(c,{flexDirection:"column",children:[(0,r.jsx)(ye,{items:C,children:n=>n.type==="cm_init"?(0,r.jsx)(c,{marginLeft:2,paddingLeft:1,children:(0,r.jsxs)(o,{color:s.dimmed,children:["\u25AA Generated task with ",n.count," checkpoints"]})},n.key):n.type==="bifurcation_header"?(0,r.jsx)(c,{marginLeft:2,paddingLeft:1,children:(0,r.jsxs)(o,{color:s.dimmed,children:["\u2501\u2501 Bifurcated into ",n.flowCount," flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"]})},n.key):n.type==="flow_header"?(0,r.jsxs)(c,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[(0,r.jsxs)(o,{color:s.purple,children:["Flow ",n.flowIdx+1,": ",n.label]}),n.cmCount!=null&&(0,r.jsxs)(o,{color:s.dimmed,children:[" \u25AA Generated task with ",n.cmCount," checkpoints"]})]},n.key):(0,r.jsx)(c,{marginLeft:2,paddingLeft:1,children:(0,r.jsx)(U,{step:n.step})},n.key)}),Y.length>0&&(0,r.jsx)(c,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:Y.map(n=>(0,r.jsx)(U,{step:n},n.index))}),M&&(0,r.jsx)(fe,{currentStep:Z,maxSteps:S,elapsed:ie,status:W})]})}var ge=j(le(),1);var pe=j(N(),1),Ee=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function bt({label:t,hasBifurcation:i=!1}){let[l,u]=(0,ge.useState)(0),[S,f]=(0,ge.useState)(0);se(()=>{u(d=>(d+1)%Ee.length)},80),se(()=>{f(d=>(d+1)%4)},400);let x=t??(i?"Planning approach":"Analyzing objective");return(0,pe.jsxs)(c,{marginLeft:1,children:[(0,pe.jsxs)(o,{color:s.primary,children:[Ee[l]," "]}),(0,pe.jsxs)(o,{color:s.dim,children:[x,".".repeat(S+1)]})]})}function yt(t){if(!t.isRunning||t.replayInfo)return null;let i=t.bifurcationInfo;if(i&&!i.isSingleFlow){let l=t.steps.findIndex(S=>S.status==="running");return(l===-1?t.cmInitCounts.length===0:l>=t.cmInitCounts.length)?{label:l>0?`Planning flow ${l+1}`:void 0,hasBifurcation:!0}:null}return t.cmInitCounts.length>0||t.steps.some(l=>l.children?.length)?null:{hasBifurcation:!!i}}var _=j(le(),1);function be(t){let i=t.indexOf(": ");return i>0&&i<15?t.slice(i+2):t}function Se(t){return t.map(i=>{let l=i.children?Se(i.children):i.children;return i.status==="running"?{...i,status:"stopped",phase:void 0,children:l}:l!==i.children?{...i,children:l}:i})}function kt(t,i,l,u){let[S,f]=(0,_.useState)(!1),[x,d]=(0,_.useState)([]),[D,E]=(0,_.useState)(null),[P,F]=(0,_.useState)(null),[H,I]=(0,_.useState)(null),[M,Q]=(0,_.useState)(null),[V,Z]=(0,_.useState)([]),[W,ee]=(0,_.useState)(null),[ie,ce]=(0,_.useState)(void 0),v=(0,_.useRef)(null),C=(0,_.useRef)(null),K=(0,_.useRef)(0),re=(0,_.useRef)(!1),Y=(0,_.useCallback)(async(a,y)=>{let B=v.current;if(B){try{await B.exited}catch{}v.current=null}d([]),E(null),F(null),I(null),Q(null),Z([]),ee(null),ce(a.max_steps),f(!0),C.current=null,K.current=0;let L;try{L=ke(a,y)}catch(te){I(te instanceof Error?te.message:String(te)),f(!1);return}v.current=L,Be("runner",()=>L.cancel()),(async()=>{re.current=!1;let te=!1;for await(let e of L.events){if(re.current)break;switch(e.type){case"run_start":if(C.current&&!C.current.isSingleFlow){let R=K.current;K.current++,d(T=>T.map((h,b)=>b===R?{...h,status:"running"}:h.status==="running"&&!h.children?.some(m=>m.status==="running")?{...h,status:h.children?.some(m=>m.status==="failed")?"failed":"passed"}:h))}break;case"bifurcation":{let R=e.flows??[],T=e.count??R.length,h={flows:R,isSingleFlow:e.is_single_flow??T<=1};Q(h),C.current=h,K.current=0,d(R.map((b,m)=>({index:m+1,objective:b??`Flow ${m+1}`,status:"pending"})));break}case"step_start":{i?.("STEP_START",`Step ${e.index} started`,{index:e.index,objective:e.objective,child_id:e.child_id});let R=e.index,T=e.objective??`Step ${R}`,h=e.child_id,b=C.current&&!C.current.isSingleFlow;if(h)d(m=>{let g=m.findIndex(z=>z.status==="running"||z.children?.some(je=>je.status==="running"));if(g===-1)return m;let k=[...m],w={...k[g]},J=[...w.children??[]].map(z=>z.status==="running"?{...z,status:"stopped",phase:void 0}:z);return J.push({index:R,objective:T,status:"running"}),w.children=J,k[g]=w,k});else if(b){let m=Math.max(0,K.current-1);d(g=>{let k=[...g];if(m>=k.length)return g;let w={...k[m]},J=[...w.children??[]].map(z=>z.status==="running"?{...z,status:"stopped",phase:void 0}:z);return J.push({index:R,objective:T,status:"running"}),w.children=J,w.status="running",k[m]=w,k})}else d(m=>{let g=Se(m);return g.some(w=>w.index===R)?g.map(w=>w.index===R?{...w,status:"running",objective:T}:w):[...g,{index:R,objective:T,status:"running"}]});break}case"step_event":{i?.("STEP_EVENT",`Step ${e.index} ${e.event}`,{index:e.index,phase:e.event,action_type:e.action_type,detail:e.detail,child_id:e.child_id});let R=e.child_id,T=C.current&&!C.current.isSingleFlow;if(e.event==="cm_init"&&e.checkpoint_count!=null){Z(h=>[...h,e.checkpoint_count]);break}if(e.event==="replay_started"){ee({recordingLength:e.recording_length??0});break}if(e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&l?.(e.detail),R)d(h=>h.map(b=>{if(!b.children)return b;let m=b.children.map(g=>{if(g.index!==e.index)return g;let k={phase:e.event};return e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&(k.objective=e.detail),e.action_type&&(k.actionType=e.action_type),{...g,...k}});return{...b,children:m}}));else if(T){let h=Math.max(0,K.current-1);d(b=>{let m=[...b];if(h>=m.length)return b;let g={...m[h]},k=[...g.children??[]];if(!k.some(X=>X.index===e.index))k.push({index:e.index,objective:`Step ${e.index}`,status:"running",phase:e.event,actionType:e.action_type});else for(let X=0;X<k.length;X++){if(k[X].index!==e.index)continue;let J={phase:e.event};e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&(J.objective=e.detail),e.action_type&&(J.actionType=e.action_type),k[X]={...k[X],...J}}return g.children=k,m[h]=g,m})}else d(h=>h.some(m=>m.index===e.index)?h.map(m=>{if(m.index!==e.index)return m;let g={phase:e.event};return e.event==="reasoning"&&e.detail&&e.detail!=="reasoning"&&(g.objective=e.detail),e.action_type&&(g.actionType=e.action_type),{...m,...g}}):[...Se(h),{index:e.index,objective:`Step ${e.index}`,status:"running",phase:e.event,actionType:e.action_type}]);break}case"step_end":{i?.("STEP_END",`Step ${e.index} ${e.status}`,{index:e.index,status:e.status,duration:e.duration,summary:e.summary,child_id:e.child_id}),u?.();let R=e.child_id,T=C.current&&!C.current.isSingleFlow;if(R)d(h=>h.map(b=>{if(!b.children)return b;let m=b.children.map(g=>g.index===e.index?{...g,status:e.status,duration:e.duration,phase:void 0,objective:g.objective.startsWith("Step ")?be(e.summary||g.objective):g.objective}:g);return{...b,children:m}}));else if(T){let h=Math.max(0,K.current-1);d(b=>{let m=[...b];if(h>=m.length)return b;let g={...m[h]},k=(g.children??[]).map(w=>w.index===e.index?{...w,status:e.status,duration:e.duration,phase:void 0,objective:w.objective.startsWith("Step ")?be(e.summary||w.objective):w.objective}:w);return g.children=k,m[h]=g,m})}else d(h=>h.map(b=>b.index===e.index?{...b,status:e.status,duration:e.duration,phase:void 0,objective:b.objective.startsWith("Step ")?be(e.summary||b.objective):b.objective}:b));{let b=C.current&&!C.current.isSingleFlow?Math.max(0,K.current-1):0;t?.(e.index,b,e.child_id)}break}case"child_agent_start":{let R=e.objective??"";d(T=>T.map(h=>h.status==="running"?{...h,objective:`${R} (branch)`,phase:`child: ${R.slice(0,50)}`,branchObjective:R}:h));break}case"child_agent_end":d(R=>R.map(T=>T.phase?.startsWith("child:")?{...T,phase:`child ${e.success?"done":"failed"}`}:T));break;case"ask_user":E(e.question??"");break;case"run_end":d(R=>R.map(T=>T.status==="running"?{...T,status:e.status,phase:void 0}:T)),f(!1),F(e),te=!0;break;case"error":f(!1),I(e.message??"Runner error"),d(R=>R.map(T=>T.status==="running"?{...T,status:"failed",phase:void 0}:T));break}}let{code:q,signal:me}=await L.exited,he=L.stderr,Ie=q===0&&!me,oe=[];q!==null&&q!==0&&oe.push(`Runner exited with code ${q}`),me&&oe.push(`Runner killed by signal ${me}`),he&&(!Ie||!te?oe.push(he):y?.log?.("debug","RUNNER_STDERR_BENIGN","Runner stderr on clean exit",{stderr:he})),v.current===L&&(oe.length>0&&I(oe.join(`
|
|
4
|
-
`)),f(!1),ae("runner","Event stream ended"),v.current=null)})().catch(te=>{let q=[`Runner event loop error: ${te}`];L.exitCode!==null&&L.exitCode!==0&&q.push(`Exit code: ${L.exitCode}`),L.exitSignal&&q.push(`Signal: ${L.exitSignal}`),L.stderr&&q.push(L.stderr),v.current===L&&(I(q.join(`
|
|
5
|
-
`)),f(!1),ae("runner","Event loop error"),v.current=null)})},[t,i,l,u]),n=(0,_.useCallback)(a=>{v.current?.sendUserResponse(a),E(null)},[]),p=(0,_.useCallback)(()=>{let a=v.current;a&&(a.sendCancel("user"),f(!1),E(null),setTimeout(()=>{v.current===a&&(ae("runner","User cancelled run"),v.current=null)},5e3))},[]);return(0,_.useEffect)(()=>()=>{re.current=!0,ae("runner","Component unmounted"),v.current=null},[]),{isRunning:S,steps:x,askingUser:D,lastRunEnd:P,runError:H,bifurcationInfo:M,cmInitCounts:V,replayInfo:W,maxSteps:ie,startRun:Y,sendAnswer:n,cancelRun:p}}function wt(t){let i=t.flatMap(f=>[f,...f.children??[]]),l=i.filter(f=>f.status==="passed").length,u=i.filter(f=>f.status==="failed").length,S=i.filter(f=>f.status==="passed"||f.status==="failed").length;return{passed:l,failed:u,total:S}}export{ft as a,bt as b,yt as c,kt as d,wt as e,Ge as f,Ke as g};
|
package/dist/chunk-JHNEE2MB.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{s}from"./chunk-5XTLIGWL.js";function n(r="prod"){let e=s[r];return r!=="stage"?e:{authBaseUrl:process.env.KANE_STAGE_AUTH_URL??e.authBaseUrl,consentUrl:process.env.KANE_STAGE_CONSENT_URL??e.consentUrl,controllerBaseUrl:process.env.TESTMUAI_BASE_URL??e.controllerBaseUrl,tmsBaseUrl:process.env.KANE_STAGE_TMS_URL??e.tmsBaseUrl,secretsBaseUrl:process.env.KANE_STAGE_SECRETS_URL??e.secretsBaseUrl,testManagerUiUrl:process.env.KANE_STAGE_TEST_MANAGER_UI_URL??e.testManagerUiUrl,shareApiBaseUrl:process.env.KANE_STAGE_SHARE_API_URL??e.shareApiBaseUrl,v16ServerHost:process.env.KANE_STAGE_V16_SERVER_HOST??e.v16ServerHost}}export{n as a};
|
package/dist/chunk-KMTNMUVS.js
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{d as a,h as c}from"./chunk-5XTLIGWL.js";import{readFileSync as g,writeFileSync as n,mkdirSync as i,existsSync as p}from"fs";import{dirname as s}from"path";var o={window_size:{width:1920,height:1080},chrome_profile_path:"",default_url:c,model:"v16-alpha",project_id:null,project_name:null,folder_id:null,folder_name:null,mode:"testing",code_export:{enabled:!0,language:"python",skip_validation:!0},last_seen_version:""},l=class{constructor(r=a){this.path=r}exists(){return p(this.path)}load(){try{let r=g(this.path,"utf-8"),e=JSON.parse(r);return{...o,...e,code_export:{...o.code_export,...e.code_export??{}}}}catch{return{...o,code_export:{...o.code_export}}}}set(r,e){try{let t=this.load();t[r]=e,i(s(this.path),{recursive:!0}),n(this.path,JSON.stringify(t,null,2)+`
|
|
3
|
-
`)}catch(t){let d=t instanceof Error?t.message:String(t);process.stderr.write(`[config] Failed to save config: ${d}
|
|
4
|
-
`)}}save(r){try{let t={...this.load(),...r};i(s(this.path),{recursive:!0}),n(this.path,JSON.stringify(t,null,2)+`
|
|
5
|
-
`)}catch(e){let t=e instanceof Error?e.message:String(e);process.stderr.write(`[config] Failed to save config: ${t}
|
|
6
|
-
`)}}writeRaw(r){try{i(s(this.path),{recursive:!0}),n(this.path,JSON.stringify(r,null,2)+`
|
|
7
|
-
`)}catch(e){let t=e instanceof Error?e.message:String(e);process.stderr.write(`[config] Failed to save config: ${t}
|
|
8
|
-
`)}}};export{l as a};
|
package/dist/chunk-LYSEA5FB.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as i,d as p,e as f,f as g,g as u,k as l}from"./chunk-AH4AXJML.js";import{a as d}from"./chunk-KMTNMUVS.js";import{existsSync as t,mkdirSync as w,readFileSync as S,renameSync as y,writeFileSync as D}from"fs";import{join as j}from"path";function O(r){l(i(r));let a=i(r);if(!t(a))return;let s=j(a,"meta.json"),n=f(r);if(t(s)&&!t(n))try{w(p(r),{recursive:!0}),y(s,n)}catch(e){process.stderr.write(`warn: meta.json migration failed: ${e.message}
|
|
3
|
-
`)}let c=u(r);if(t(c)){let e="python";try{let o=new d().load();o.code_export?.language&&(e=o.code_export.language)}catch{}let m=g(r,"playwright",e);if(!t(m))try{y(c,m)}catch(o){process.stderr.write(`warn: generated-code migration failed: ${o.message}
|
|
4
|
-
`)}}if(t(n))try{let e=JSON.parse(S(n,"utf8"));"md5sum"in e&&(delete e.md5sum,D(n,JSON.stringify(e,null,2)+`
|
|
5
|
-
`,"utf8"))}catch(e){process.stderr.write(`warn: meta.json md5sum strip failed: ${e.message}
|
|
6
|
-
`)}}export{O as a};
|
package/dist/chunk-MJQ2EHSC.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as u,b as x}from"./chunk-U4XV5KUD.js";import{a as f}from"./chunk-HCBYKLMW.js";import{t as m}from"./chunk-5XTLIGWL.js";import{a as r,b as i}from"./chunk-C44QQJR4.js";import{e as n}from"./chunk-UR6MHSHU.js";var e=n(f(),1);function C({title:B,titleColor:d,borderColor:c,variant:p,rows:s,footer:t,labelWidth:l=14,marginBottom:b=1}){return(0,e.jsxs)(u,{title:B,titleColor:d,borderColor:c,variant:p,marginBottom:b,children:[s.map((o,a)=>typeof o.value=="string"?(0,e.jsx)(x,{label:o.label,value:o.value,valueColor:o.valueColor,labelWidth:l},`${o.label}-${a}`):(0,e.jsxs)(r,{children:[(0,e.jsx)(r,{width:l,children:(0,e.jsx)(i,{color:m.dimmed,children:o.label})}),o.value]},`${o.label}-${a}`)),t&&(0,e.jsx)(r,{marginTop:1,children:t})]})}export{C as a};
|
package/dist/chunk-OQZG3V6B.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{f as l}from"./chunk-X7VI7KK3.js";import{readFileSync as y,existsSync as S}from"fs";import{basename as f,dirname as R,isAbsolute as w,resolve as g}from"path";var h=["target","chrome_profile","cdp_endpoint","ws_endpoint","headless"],r=class extends Error{constructor(t){super(t),this.name="TestMdResolveError"}};function $(o){let t=g(o),n=m(t),s=x(n.global),i=[];return u(n,[],i,[],t),i.forEach((e,p)=>e.flatIndex=p+1),{rootPath:t,rootTitle:n.title,rootGlobal:n.global,rootSteps:n.steps,chrome:s,steps:i}}function m(o){if(!S(o))throw new r(`@import path not found: ${o}`);let t=y(o,"utf8");return l(o,t)}function u(o,t,n,s,i){if(t.includes(o.path)){let e=[...t,o.path].map(p=>f(p)).join(" \u2192 ");throw new r(`cyclic reference: ${e}`)}t.push(o.path);let a=s.length===0;for(let e of o.steps){let p=e.body.kind!=="objective";if(e.optional&&p&&!a)throw new r(`intermediate-ref 'optional' is not supported in v1: ${o.path}:${e.headingLine}`);let d={file:o.path,stepIndex:e.index,heading:e.heading,optional:e.optional??!1};if(e.body.kind==="objective"){let v=F(o.global,e.config);n.push({flatIndex:0,objective:e.body.text,sourceFile:o.path,trace:[...s,d],config:v,parsedConfig:e.config,optional:e.optional??!1});continue}let b=R(o.path),c=w(e.body.path)?e.body.path:g(b,e.body.path);if(f(c).endsWith("_test.md"))throw new r(`cannot @import a test file: only helpers may be imported (got ${c})`);let C=m(c);u(C,t,n,[...s,d],i)}t.pop()}function x(o){let t={};for(let n of h)o[n]!==void 0&&(t[n]=o[n]);return t}function F(o,t){let n={};for(let[s,i]of Object.entries(o))h.includes(s)||(n[s]=i);return{...n,...t??{}}}export{$ as a};
|
package/dist/chunk-PJMTAAZ7.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as h}from"./chunk-PQGNWC33.js";import{a as A}from"./chunk-HCBYKLMW.js";import{t as a}from"./chunk-5XTLIGWL.js";import{a as c,b as f,i as P}from"./chunk-C44QQJR4.js";import{a as y}from"./chunk-6YGTRKDT.js";import{e as x}from"./chunk-UR6MHSHU.js";var L=x(y(),1);var r=x(A(),1);function B(i,d,l,u,p){let g=l==="basic"&&u?`basic (${u})`:l,n=20,s=`${i} [${d}]`,m="\xB7".repeat(Math.max(2,n-s.length+3));return{label:`${s} ${m} ${g}`,profile:i,env:d,isActive:p}}function I({creds:i,onSwitch:d,onCancel:l}){let u=i.listProfiles(),p=i.getActiveProfile(),g=i.getDefaultEnv(),n=u.map(e=>{let t=i.loadBasicAuth(e.profile,e.env),o=i.loadCredentials(e.profile,e.env)!==null,v=t?"basic":o?"oauth":"none",b=t?t.username:null,w=e.profile===p&&e.env===g;return B(e.profile,e.env,v,b,w)}),[s,m]=(0,L.useState)(()=>{let e=n.findIndex(t=>t.isActive);return e>=0?e:0});return P((e,t)=>{if(t.escape){l();return}if(t.upArrow){m(o=>Math.max(0,o-1));return}if(t.downArrow){m(o=>Math.min(n.length-1,o+1));return}if(t.return&&n[s]){let o=n[s];o.isActive||d(o.profile,o.env),l();return}}),n.length===0?(0,r.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:a.primary,paddingX:2,paddingY:1,children:[(0,r.jsx)(f,{color:a.primary,bold:!0,children:"Profiles"}),(0,r.jsx)(c,{marginTop:1,children:(0,r.jsx)(f,{color:a.dim,children:"No profiles \u2014 use Login to create one"})}),(0,r.jsx)(h,{bindings:[],escBackLabel:"back"})]}):(0,r.jsxs)(c,{flexDirection:"column",borderStyle:"round",borderColor:a.primary,paddingX:2,paddingY:1,children:[(0,r.jsx)(f,{color:a.primary,bold:!0,children:"Profiles"}),(0,r.jsx)(c,{flexDirection:"column",marginTop:1,children:n.map((e,t)=>{let o=t===s,v=o?"\u276F ":" ",b=e.isActive?a.statusPass:o?a.primary:void 0;return(0,r.jsxs)(f,{color:b,children:[v,e.label,e.isActive?" \u25CF active":""]},`${e.profile}-${e.env}`)})}),(0,r.jsx)(h,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"switch"}],escBackLabel:"back"})]})}export{B as a,I as b};
|
package/dist/chunk-PYU2JPAY.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as m}from"./chunk-PQGNWC33.js";import{a as p}from"./chunk-HCBYKLMW.js";import{t}from"./chunk-5XTLIGWL.js";import{a,b as o,i as u}from"./chunk-C44QQJR4.js";import{a as b}from"./chunk-6YGTRKDT.js";import{e as n}from"./chunk-UR6MHSHU.js";var c=n(b(),1);var e=n(p(),1);function T({onSubmit:l}){let[r,f]=(0,c.useState)(0),s=(0,c.useRef)(!1);return u((x,i)=>{s.current||(i.leftArrow||i.rightArrow?f(d=>d===0?1:0):i.return?(s.current=!0,l(r===0?"positive":"negative")):i.escape&&(s.current=!0,l(null)))}),(0,e.jsxs)(a,{flexDirection:"column",marginTop:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(o,{color:t.secondary,children:"Rate this session: "}),(0,e.jsx)(o,{color:r===0?t.primary:t.dim,children:r===0?"[ \u{1F44D} ]":" \u{1F44D} "}),(0,e.jsx)(o,{children:" "}),(0,e.jsx)(o,{color:r===1?t.primary:t.dim,children:r===1?"[ \u{1F44E} ]":" \u{1F44E} "})]}),(0,e.jsx)(m,{bindings:[{keys:"\u2190/\u2192",label:"select"},{keys:"\u21B5",label:"submit"}],escBackLabel:"skip"})]})}export{T as a};
|
package/dist/chunk-QCNKJUPT.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as b}from"./chunk-PQGNWC33.js";import{a as A}from"./chunk-HCBYKLMW.js";import{k as p,t as i}from"./chunk-5XTLIGWL.js";import{a as u,b as a,i as S}from"./chunk-C44QQJR4.js";import{a as D}from"./chunk-6YGTRKDT.js";import{e as h}from"./chunk-UR6MHSHU.js";var g=h(D(),1);import{readdirSync as N,mkdirSync as L,statSync as k}from"fs";import{join as P}from"path";var r=h(A(),1);function O(n){try{return N(n).filter(s=>{try{return k(P(n,s)).isDirectory()}catch{return!1}})}catch{return[]}}function E(n,s,m,v){return{name:n,path:s,label:n,isActive:v}}function H({currentPath:n,onSelect:s,onCancel:m}){let l=O(p).map(o=>{let e=P(p,o);return E(o,e,n,e===n)}),d=!n,B=l.length+2,[c,C]=(0,g.useState)(()=>{if(d)return 0;let o=l.findIndex(e=>e.isActive);return o>=0?o+1:0}),[y,T]=(0,g.useState)(!1),[I,x]=(0,g.useState)("");return S((o,e)=>{if(y){if(e.escape){T(!1),x("");return}if(e.return){let t=I.trim();if(t){let f=P(p,t);L(f,{recursive:!0}),s(f),m()}return}if(e.backspace||e.delete){x(t=>t.slice(0,-1));return}o&&!e.ctrl&&!e.meta&&x(t=>t+o);return}if(e.escape){m();return}if(e.upArrow){C(t=>Math.max(0,t-1));return}if(e.downArrow){C(t=>Math.min(B-1,t+1));return}if(e.return){if(c===0){d||s(""),m();return}if(c===l.length+1){L(p,{recursive:!0}),T(!0),x("");return}let t=l[c-1];t&&!t.isActive&&s(t.path),m();return}}),y?(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:i.primary,paddingX:2,paddingY:1,children:[(0,r.jsx)(a,{color:i.primary,bold:!0,children:"Chrome Profile \u203A New"}),(0,r.jsxs)(u,{marginTop:1,children:[(0,r.jsx)(a,{color:i.secondary,children:"Name: "}),(0,r.jsx)(a,{children:I}),(0,r.jsx)(a,{color:i.dimmed,children:"\u2588"})]}),(0,r.jsx)(b,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:"back"})]}):(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:i.primary,paddingX:2,paddingY:1,children:[(0,r.jsx)(a,{color:i.primary,bold:!0,children:"Chrome Profile"}),(0,r.jsxs)(u,{flexDirection:"column",marginTop:1,children:[(0,r.jsxs)(a,{color:d?i.statusPass:c===0?i.primary:i.dim,children:[c===0?"\u276F ":" ","Use temporary (no profile)",d?" \u25CF active":""]}),l.map((o,e)=>{let f=e+1===c,R=f?"\u276F ":" ",w=o.isActive?i.statusPass:f?i.primary:void 0;return(0,r.jsxs)(a,{color:w,children:[R,o.label,o.isActive?" \u25CF active":""]},o.name)}),(0,r.jsxs)(a,{color:c===l.length+1?i.primary:i.dim,children:[c===l.length+1?"\u276F ":" ","+ Create new"]})]}),(0,r.jsx)(b,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}export{O as a,E as b,H as c};
|
package/dist/chunk-R7JZMKC7.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as Re}from"./chunk-BDC7IOXP.js";import{a as de}from"./chunk-KMTNMUVS.js";import{f as fe}from"./chunk-G7VF5SDK.js";import{b as Pe}from"./chunk-L256AYYL.js";import{b as _e}from"./chunk-YX3YFXT5.js";import{a as Ce}from"./chunk-YCCUBQY4.js";import{a as ae,b as ue,d as Ie}from"./chunk-VE3SUJMA.js";import{a as Ae,b as Be}from"./chunk-KX7K3Y7R.js";import{a as le}from"./chunk-JHNEE2MB.js";import{a as me}from"./chunk-BPF7TDRU.js";import{a as se}from"./chunk-PQGNWC33.js";import{a as J}from"./chunk-HCBYKLMW.js";import{c as Ee,t as w}from"./chunk-5XTLIGWL.js";import{a as b,b as h,h as Te,i as Q,j as ye,k as Se}from"./chunk-C44QQJR4.js";import{a as ie}from"./chunk-6YGTRKDT.js";import{a as he}from"./chunk-7CLUJYMW.js";import{e as U}from"./chunk-UR6MHSHU.js";var _=U(ie(),1);var Z=U(ie(),1);var xe=U(ie(),1);var q=U(J(),1);function De({history:i,onSelect:r,onClose:n}){let[l,u]=(0,xe.useState)(""),[e,f]=(0,xe.useState)(0),t=l?i.search(l).slice(0,8):[];return Q((a,v)=>{if(v.escape){n();return}if(v.return){t.length>0&&t[e]?r(t[e]):n();return}if(v.upArrow){f(A=>Math.max(0,A-1));return}if(v.downArrow){f(A=>Math.min(t.length-1,A+1));return}if(v.backspace||v.delete){u(A=>A.slice(0,-1)),f(0);return}a&&!v.ctrl&&!v.meta&&(u(A=>A+a),f(0))}),(0,q.jsxs)(b,{flexDirection:"column",marginLeft:2,borderStyle:"single",paddingX:1,children:[(0,q.jsx)(h,{color:w.muted,bold:!0,children:"reverse search"}),(0,q.jsxs)(b,{gap:1,children:[(0,q.jsx)(h,{color:w.dimmed,children:"search:"}),(0,q.jsx)(h,{children:l}),(0,q.jsx)(h,{color:w.purple,children:"\u2588"})]}),t.length>0&&(0,q.jsx)(h,{children:" "}),t.map((a,v)=>(0,q.jsx)(b,{marginLeft:2,children:(0,q.jsxs)(h,{color:v===e?w.purple:w.dimmed,bold:v===e,children:[v===e?"\u25B8 ":" ",a]})},`${v}-${a}`))]})}var re=U(J(),1);function Le({commands:i,selectedIndex:r}){return i.length===0?null:(0,re.jsx)(b,{flexDirection:"column",marginBottom:0,children:i.map((n,l)=>{let u=l===r;return(0,re.jsxs)(b,{children:[(0,re.jsx)(h,{color:u?w.primary:w.dimmed,children:u?"\u276F ":" "}),(0,re.jsxs)(h,{color:u?w.primary:void 0,bold:u,children:["/",n.name]}),n.args&&(0,re.jsxs)(h,{color:w.dimmed,children:[" ",n.args]}),(0,re.jsxs)(h,{color:w.dimmed,children:[" ",n.description]})]},n.name)})})}var pe=U(ie(),1);var Ne=27,$e=127,We=11;function He(i){return i>=64&&i<=126}function Ge(i,r){i===We&&r({killToEnd:!0,ctrl:!0,raw:String.fromCharCode(i)})}function Ve(i,r){i===$e&&r({backspace:!0,meta:!0,raw:"\x1B\x7F"})}function Xe(i,r){let n=i.map(u=>String.fromCharCode(u)).join(""),l=/^\[1;([0-9]+)([A-D])$/.exec(n);if(l){let u=parseInt(l[1],10),e=l[2],f={raw:"\x1B"+n};if(u===2)f.shift=!0;else if(u===3)f.meta=!0;else if(u===5)f.ctrl=!0;else return;e==="A"?f.arrowUp=!0:e==="B"?f.arrowDown=!0:e==="C"?f.arrowRight=!0:e==="D"&&(f.arrowLeft=!0),r(f);return}if(n==="[H"||n==="[1~"||n==="[7~"){r({home:!0,raw:"\x1B"+n});return}if(n==="[F"||n==="[4~"||n==="[8~"){r({end:!0,raw:"\x1B"+n});return}if(n==="[3;5~"){r({delete:!0,ctrl:!0,raw:"\x1B"+n});return}if(n==="[3;3~"){r({delete:!0,meta:!0,raw:"\x1B"+n});return}}function Ye(i,r){i===72?r({home:!0,raw:"\x1BO"+String.fromCharCode(i)}):i===70&&r({end:!0,raw:"\x1BO"+String.fromCharCode(i)})}function ze(){let i="IDLE",r=[];function n(){i="IDLE",r=[]}return{feed(l,u){for(let e of l)i==="IDLE"?e===Ne?(i="ESC",r=[]):Ge(e,u):i==="ESC"?e===91?(i="CSI",r=[]):e===79?(i="SS3",r=[]):(Ve(e,u),n()):i==="CSI"?(r.push(e),He(e)&&(Xe([91,...r],u),n())):i==="SS3"&&(Ye(e,u),n())},flushIdle(l){i==="ESC"&&r.length===0&&l({raw:"\x1B"}),n()}}}function Me(i,r={}){let n=(0,pe.useRef)(i);n.current=i;let{stdin:l}=Te();(0,pe.useEffect)(()=>{if(r.isActive===!1||!l)return;let u=ze(),e=null,f=t=>{e&&(clearTimeout(e),e=null);let a=Buffer.isBuffer(t)?t:Buffer.from(t,"binary");u.feed(a,v=>n.current(v)),e=setTimeout(()=>{u.flushIdle(v=>n.current(v)),e=null},50)};return l.on("data",f),()=>{l.removeListener("data",f),e&&clearTimeout(e)}},[r.isActive,l])}var k=U(J(),1),ve=10;function qe(i){return i.replace(/\x1b?\[200~/g,"").replace(/\x1b?\[201~/g,"").replace(/\r\n/g,`
|
|
3
|
-
`).replace(/\r/g,`
|
|
4
|
-
`).replace(/[\x00-\x08\x0b-\x1f\x7f]/g,"")}function Je(i,r){let n=[],l=0;for(;l<=i.length;){let u=l;for(;u<i.length&&i[u]!==`
|
|
5
|
-
`;)u++;if(l===u)n.push({start:l,end:l});else{let e=l;for(;e<u;){let f=Math.min(e+r,u);n.push({start:e,end:f}),e=f}}if(u>=i.length)break;l=u+1}return n}function Qe(i,r,n){if(i.length===0)return 0;if(r>=n.length)return i.length-1;if(n[r]===`
|
|
6
|
-
`){for(let l=i.length-1;l>=0;l--)if(i[l].end===r)return l;return i.length-1}for(let l=0;l<i.length;l++){let u=i[l];if(u.start<=r&&r<u.end)return l}return i.length-1}function ke(i,r,n,l){let u=Je(i,n);if(u.length===0)return null;let e=Qe(u,r,i),f=e+l;if(f<0||f>=u.length)return null;let t=r-u[e].start,a=u[f],v=a.end-a.start;return a.start+Math.min(t,v)}function Oe({onSubmit:i,onEscape:r,history:n,placeholder:l="Type an objective or /command...",commands:u}){let[e,f]=(0,Z.useState)([]),[t,a]=(0,Z.useState)(0),[v,A]=(0,Z.useState)("none"),[L,C]=(0,Z.useState)(-1),R=(0,Z.useRef)(""),[M,ne]=(0,Z.useState)(!0),{stdout:F}=Se(),O=F?.columns??80,[W,H]=(0,Z.useState)(0),I=e.join(""),G=(()=>{if(v!=="none"||e.length===0)return"";if(I.startsWith("/")&&u&&I.length>=2){let o=I.slice(1).toLowerCase(),c=u.find(y=>y.name.startsWith(o)&&y.name!==o);return c?`/${c.name}`.slice(I.length):""}if(I.startsWith("/"))return"";let p=n.getAll();for(let o=p.length-1;o>=0;o--)if(p[o].startsWith(I)&&p[o]!==I)return p[o].slice(I.length);return""})(),j=(()=>{if(!u||!I.startsWith("/"))return[];let p=I.length>=2?I.slice(1).toLowerCase():"";return p&&u.some(o=>o.name===p)?[]:u.filter(o=>!p||o.name.startsWith(p))})(),V=j.length>0&&I.startsWith("/");Q((p,o)=>{if(M&&p&&ne(!1),o.return){if(V&&j[W]){let c=`/${j[W].name}`;n.push(c),i(c),f([]),a(0),A("none"),C(-1),R.current="",ne(!0),H(0);return}I.trim()&&(n.push(I.trim()),i(I.trim()),f([]),a(0),A("none"),C(-1),R.current="",ne(!0),H(0));return}if(o.escape){v!=="none"?A("none"):e.length>0?(f([]),a(0),C(-1),R.current=""):r?.();return}if(o.tab){if(V&&j[W]){let c=`/${j[W].name}`;f([...c]),a(c.length),H(0);return}if(G){let c=I+G;f([...c]),a(c.length);return}return}if(o.ctrl&&p==="r"){A("search");return}if(o.ctrl&&p==="a"){a(0);return}if(o.ctrl&&p==="e"){a(e.length);return}if(o.ctrl&&p==="w"){if(t===0)return;let c=t-1;for(;c>0&&e[c]===" ";)c--;for(;c>0&&e[c-1]!==" ";)c--;let y=[...e.slice(0,c),...e.slice(t)];f(y),a(c);return}if(o.ctrl&&p==="u"){f([]),a(0),C(-1),A("none");return}if(o.meta&&p==="b"){let c=t-1;for(;c>0&&e[c]===" ";)c--;for(;c>0&&e[c-1]!==" ";)c--;a(Math.max(0,c));return}if(o.meta&&p==="f"){let c=t;for(;c<e.length&&e[c]!==" ";)c++;for(;c<e.length&&e[c]===" ";)c++;a(c);return}if(o.leftArrow){if(o.ctrl||o.shift)return;a(c=>Math.max(0,c-1));return}if(o.rightArrow){if(o.ctrl||o.shift)return;if(t>=e.length&&G){let c=I+G;f([...c]),a(c.length)}else a(c=>Math.min(e.length,c+1));return}if(o.upArrow){if(o.shift)return;if(V){H(c=>Math.max(0,c-1));return}if(v==="none"){let c=Math.max(1,O-2),y=ke(e,t,c,-1);if(y!==null){a(y);return}let D=n.getAll();if(D.length===0)return;if(L===-1){R.current=I,C(D.length-1);let B=D[D.length-1];f([...B]),a(B.length)}else if(L>0){let B=L-1;C(B);let s=D[B];f([...s]),a(s.length)}}return}if(o.downArrow){if(o.shift)return;if(V){H(c=>Math.min(j.length-1,c+1));return}if(v==="none"){let c=Math.max(1,O-2),y=ke(e,t,c,1);if(y!==null){a(y);return}let D=n.getAll();if(L===-1)return;if(L<D.length-1){let B=L+1;C(B);let s=D[B];f([...s]),a(s.length)}else{C(-1);let B=R.current;f([...B]),a(B.length)}}return}if(o.backspace||o.delete){if(o.meta||o.ctrl)return;if(t>0){let c=[...e.slice(0,t-1),...e.slice(t)];f(c),a(t-1),C(-1),H(0)}return}if(p&&!o.ctrl&&!o.meta){let c=qe(p);if(!c)return;let y=[...e.slice(0,t),...c,...e.slice(t)];f(y),a(t+c.length),C(-1),H(0)}},{isActive:v!=="search"}),Me(p=>{if(p.home){a(0);return}if(p.end){a(e.length);return}if(p.killToEnd){f(e.slice(0,t));return}if(p.arrowLeft&&(p.ctrl||p.meta)){let o=t-1;for(;o>0&&e[o]===" ";)o--;for(;o>0&&e[o-1]!==" ";)o--;a(Math.max(0,o));return}if(p.arrowRight&&(p.ctrl||p.meta)){let o=t;for(;o<e.length&&e[o]!==" ";)o++;for(;o<e.length&&e[o]===" ";)o++;a(o);return}if(p.backspace&&p.meta){if(t===0)return;let o=t-1;for(;o>0&&e[o]===" ";)o--;for(;o>0&&e[o-1]!==" ";)o--;let c=[...e.slice(0,o),...e.slice(t)];f(c),a(o);return}if(p.delete&&(p.ctrl||p.meta)){let o=t;for(;o<e.length&&e[o]===" ";)o++;for(;o<e.length&&e[o]!==" ";)o++;f([...e.slice(0,t),...e.slice(o)]);return}},{isActive:v!=="search"});let ce=p=>{f([...p]),a(p.length),A("none")},$=()=>{A("none")},X=(()=>{if(M&&e.length===0)return null;let p=t>=e.length,o=e.slice(0,t).join(""),c,y;p?(c=" ",y=""):e[t]===`
|
|
7
|
-
`?(c=" ",y=e.slice(t).join("")):(c=e[t],y=e.slice(t+1).join(""));let D=o+c+y+G,B=o.length,s=B+1,d=s+y.length,m=Math.max(1,O-2),g=[],S=0;for(;S<=D.length;){let K=D.indexOf(`
|
|
8
|
-
`,S);if(K===-1&&(K=D.length),S===K)g.push({type:"content",start:S,end:S});else{let z=S;for(;z<K;){let ee=Math.min(z+m,K);g.push({type:"content",start:z,end:ee}),z=ee}}if(K>=D.length)break;S=K+1}let P=Math.max(0,g.findIndex(K=>K.start<=B&&B<=K.end)),Y;if(g.length<=ve)Y=g;else{let z=ve-1-4;if(P<4||P>=g.length-z)Y=[...g.slice(0,4),{type:"ellipsis",hidden:g.length-4-z},...g.slice(g.length-z)];else{let ee=ve-2,be=Math.floor(ee/2),te=P-be,oe=P+(ee-be)-1;te<1&&(oe+=1-te,te=1),oe>g.length-2&&(te-=oe-(g.length-2),oe=g.length-2),te=Math.max(1,te),Y=[{type:"ellipsis",hidden:te},...g.slice(te,oe+1),{type:"ellipsis",hidden:g.length-oe-1}]}}return{full:D,b:B,c:s,a:d,rows:Y}})();return(0,k.jsxs)(b,{flexDirection:"column",children:[v==="search"&&(0,k.jsx)(De,{history:n,onSelect:ce,onClose:$}),V&&(0,k.jsx)(Le,{commands:j,selectedIndex:W}),(0,k.jsx)(h,{color:w.muted,children:"\u2500".repeat(O)}),X===null?(0,k.jsxs)(b,{children:[(0,k.jsx)(h,{color:w.purple,children:"\u276F "}),(0,k.jsx)(h,{inverse:!0,children:" "}),(0,k.jsx)(h,{color:w.dimmed,children:l})]}):(()=>{let p=X.rows.findIndex(o=>o.type==="content");return(0,k.jsx)(b,{flexDirection:"column",children:X.rows.map((o,c)=>{if(o.type==="ellipsis")return(0,k.jsx)(b,{children:(0,k.jsxs)(h,{color:w.dimmed,children:[" \u22EF ","(",o.hidden," more line",o.hidden===1?"":"s",")"]})},c);let{full:y,b:D,c:B,a:s}=X,d=o.start,x=o.end,m=c===p,g=m?"\u276F ":" ",S=m?w.purple:w.muted,P=[(0,k.jsx)(h,{color:S,children:g},"p")];d<Math.min(D,x)&&P.push((0,k.jsx)(h,{children:y.slice(d,Math.min(D,x))},"b"));let Y=Math.max(D,d),K=Math.min(B,x);Y<K&&P.push((0,k.jsx)(h,{color:w.purple,inverse:!0,children:y.slice(Y,K)},"c"));let z=Math.max(B,d),ee=Math.min(s,x);return z<ee&&P.push((0,k.jsx)(h,{children:y.slice(z,ee)},"a")),x>s&&P.push((0,k.jsx)(h,{color:w.dimmed,children:y.slice(Math.max(s,d),x)},"g")),(0,k.jsx)(b,{children:P},c)})})})(),(0,k.jsx)(se,{bindings:[{keys:"\u2191\u2193",label:"history"},{keys:"\u21B5",label:"submit"},{keys:"tab",label:"complete"},{keys:"ctrl+r",label:"search"}],escBackLabel:"clear"})]})}var N=U(ie(),1);var T=U(J(),1);function Ze(i){let r=[{id:"method",label:"Auth method",options:[{label:"Basic Auth",value:"basic"},{label:"OAuth (browser)",value:"oauth"}]}];return i&&r.push({id:"env",label:"Environment",options:[{label:"prod",value:"prod"},{label:"stage",value:"stage"}]}),r.push({id:"profile",label:"Profile"}),r.push({id:"credentials",label:"Credentials"}),r}function je({devMode:i,profiles:r,onBasicLogin:n,onOAuthLogin:l,onComplete:u,onCancel:e}){let f=Ze(i),[t,a]=(0,N.useState)(0),[v,A]=(0,N.useState)(0),[L,C]=(0,N.useState)({}),[R,M]=(0,N.useState)("select"),[ne,F]=(0,N.useState)(""),[O,W]=(0,N.useState)("username"),[H,I]=(0,N.useState)(""),[G,j]=(0,N.useState)(null),[V,ce]=(0,N.useState)(null),$=f[t],X=L.method??"basic",p=L.env??"prod",o=(0,N.useCallback)(()=>{let m=r.filter(g=>g.env===p).map(g=>({label:`${g.profile} [${g.env}]`,value:g.profile}));return m.push({label:"+ Create new",value:"__new__"}),m},[r,p]),c=(0,N.useCallback)(()=>{t===0?e():(a(x=>x-1),A(0),M("select"),F(""),j(null))},[t,e]),y=(0,N.useCallback)(x=>{X==="basic"?(M("text-input"),W("username"),F("")):(M("waiting"),l(x,p).then(()=>{ce(`Logged in via OAuth as ${x} [${p}]`),M("done")}).catch(m=>{j(m.message),M("error")}))},[X,p,l]),D=(0,N.useCallback)(x=>{let m=x.trim();if(m){if(O==="profileName"){let g=m;C(S=>({...S,profile:g})),y(g);return}if(O==="username"){I(m),F(""),W("accessKey"),M("text-input-masked");return}if(O==="accessKey"){let g=L.profile??"default";M("waiting"),(async()=>{try{await n(g,p,H,m),ce(`Logged in as ${g} [${p}] via basic auth`),M("done")}catch{j("Credentials not valid. Please use valid credentials."),I(""),F(""),W("username"),M("text-input")}})()}}},[O,L.profile,p,n,H,y]),B=(0,N.useCallback)(x=>{F(x),G&&j(null)},[G]);Q((x,m)=>{if(R==="done"){let S=L.profile??"default";u(S,p);return}if(R==="error"){e();return}if(R==="waiting"){m.escape&&e();return}if(R==="text-input"||R==="text-input-masked")return;if(m.escape){c();return}let g=$?.id==="profile"?o():$?.options??[];if(m.upArrow){A(S=>Math.max(0,S-1));return}if(m.downArrow){A(S=>Math.min(g.length-1,S+1));return}if(m.return&&g[v]){let S=g[v];if($.id==="profile"){if(S.value==="__new__"){M("text-input"),W("profileName"),F("");return}C(P=>({...P,profile:S.value})),a(P=>P+1),A(0),y(S.value);return}C(P=>({...P,[$.id]:S.value})),a(P=>P+1),A(0)}});let s="Login";if(R==="done")return(0,T.jsxs)(b,{flexDirection:"column",borderStyle:"round",borderColor:w.statusPass,paddingX:2,paddingY:1,children:[(0,T.jsxs)(h,{color:w.statusPass,bold:!0,children:["\u2713 ",V]}),(0,T.jsx)(b,{marginTop:1,children:(0,T.jsx)(h,{color:w.dim,children:"press any key"})})]});if(R==="error")return(0,T.jsxs)(b,{flexDirection:"column",borderStyle:"round",borderColor:w.statusFail,paddingX:2,paddingY:1,children:[(0,T.jsx)(h,{color:w.statusFail,bold:!0,children:"Login failed"}),(0,T.jsx)(b,{marginTop:1,children:(0,T.jsx)(h,{color:w.statusFail,children:G})}),(0,T.jsx)(b,{marginTop:1,children:(0,T.jsx)(h,{color:w.dim,children:"press any key"})})]});if(R==="waiting")return(0,T.jsxs)(b,{flexDirection:"column",borderStyle:"round",borderColor:w.primary,paddingX:2,paddingY:1,children:[(0,T.jsxs)(h,{color:w.primary,bold:!0,children:[s," \u203A OAuth"]}),(0,T.jsx)(b,{marginTop:1,children:(0,T.jsx)(h,{color:w.secondary,children:"Opening browser for login..."})}),(0,T.jsx)(b,{marginTop:1,children:(0,T.jsx)(h,{color:w.primary,children:"Waiting for callback \u27F3"})}),(0,T.jsx)(se,{bindings:[],escBackLabel:"cancel"})]});if(R==="text-input"||R==="text-input-masked"){let x=O==="username"?"Username":O==="accessKey"?"Access Key":"Profile name",m=O==="username"||O==="accessKey"?`${s} \u203A Basic Auth`:`${s} \u203A New Profile`;return(0,T.jsxs)(b,{flexDirection:"column",borderStyle:"round",borderColor:w.primary,paddingX:2,paddingY:1,children:[G&&(O==="username"||O==="accessKey")&&(0,T.jsx)(b,{marginBottom:1,children:(0,T.jsxs)(h,{color:w.statusFail,children:["\u2717 ",G]})}),(0,T.jsx)(h,{color:w.primary,bold:!0,children:m}),O==="accessKey"&&(0,T.jsxs)(b,{marginTop:1,children:[(0,T.jsx)(h,{color:w.secondary,children:"Username: "}),(0,T.jsx)(h,{children:H})]}),(0,T.jsxs)(b,{marginTop:1,children:[(0,T.jsxs)(h,{color:w.secondary,children:[x,": "]}),(0,T.jsx)(Ce,{value:ne,onChange:B,onSubmit:D,onCancel:c,masked:R==="text-input-masked"})]}),(0,T.jsx)(se,{bindings:[{keys:"\u21B5",label:"confirm"}],escBackLabel:"back"})]})}let d=$?.id==="profile"?o():$?.options??[];return(0,T.jsxs)(b,{flexDirection:"column",borderStyle:"round",borderColor:w.primary,paddingX:2,paddingY:1,children:[(0,T.jsx)(h,{color:w.primary,bold:!0,children:s}),(0,T.jsx)(b,{marginTop:1,children:(0,T.jsxs)(h,{color:w.secondary,children:[$?.label,":"]})}),(0,T.jsx)(b,{flexDirection:"column",marginTop:1,children:d.map((x,m)=>{let g=m===v,S=g?"\u276F ":" ",P=x.value==="__new__"?w.statusPass:g?w.primary:void 0;return(0,T.jsxs)(h,{color:P,children:[S,x.label]},x.value)})}),(0,T.jsx)(se,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}var Fe=U(ie(),1);import{readFileSync as et,writeFileSync as tt,mkdirSync as rt}from"fs";import{dirname as nt,join as ot}from"path";var it=ot(Ee,"command-history.json"),st=200,we=class{entries;filePath;max;constructor(r=it,n=st){this.filePath=r,this.max=n,this.entries=this._load()}push(r){this.entries.length>0&&this.entries[this.entries.length-1]===r||(this.entries.push(r),this.entries.length>this.max&&(this.entries=this.entries.slice(this.entries.length-this.max)),this._save())}getAll(){return[...this.entries]}search(r){let n=r.toLowerCase(),l=[];for(let u=this.entries.length-1;u>=0;u--)this.entries[u].toLowerCase().includes(n)&&l.push(this.entries[u]);return l}_load(){try{let r=et(this.filePath,"utf-8"),n=JSON.parse(r);return Array.isArray(n)?n:[]}catch{return[]}}_save(){try{rt(nt(this.filePath),{recursive:!0}),tt(this.filePath,JSON.stringify(this.entries)+`
|
|
9
|
-
`)}catch{}}};function Ke(i){let r=(0,Fe.useRef)(null);return r.current||(r.current=new we(i)),r.current}async function ge(i,r,n,l){let u=i.loadBasicAuth(r,n),e=i.loadCredentials(r,n);if(!u&&!e)return l("info","STARTUP_GATE_NO_CREDS","Profile has no credentials",{profile:r,env:n}),{status:"needs_login",profile:r,env:n};let f=le(n),t=async()=>i.loadCredentials(r,n)?.access_token??null,a=new me(f.controllerBaseUrl,t,u,l);l("info","STARTUP_GATE_VALIDATE","Validating credentials with controller",{profile:r,env:n,method:u?"basic":"oauth"});let v=await a.resolve(!0);if(v)return l("info","STARTUP_GATE_VALID","Credentials validated",{profile:r,env:n,username:v.username,org_id:v.org_id}),{status:"authenticated",result:{profile:r,env:n,credentials:e,basicAuth:u,tmsCreds:v,resolver:a}};if(!u&&e){let A=e.refresh_token,C=i.loadClient(r,n)?.client_id;if(A&&C){l("info","STARTUP_GATE_REFRESH","Attempting token refresh",{profile:r,env:n});try{let M=await new Be(n).refreshToken(A,C);if(M.access_token){i.saveCredentials(r,n,{...e,...M,expires_at:Date.now()/1e3+(M.expires_in??3600)});let F=await a.resolve(!0);if(F)return l("info","STARTUP_GATE_REFRESH_OK","Token refreshed and validated",{profile:r,env:n,username:F.username}),{status:"authenticated",result:{profile:r,env:n,credentials:{...e,...M},basicAuth:null,tmsCreds:F,resolver:a}}}l("warn","STARTUP_GATE_REFRESH_INVALID","Refreshed token still invalid",{profile:r,env:n})}catch(R){l("warn","STARTUP_GATE_REFRESH_FAILED","Token refresh failed",{profile:r,env:n,error:R instanceof Error?R.message:String(R)})}}else l("info","STARTUP_GATE_NO_REFRESH","No refresh_token or client_id \u2014 login required",{profile:r,env:n})}return l("info","STARTUP_GATE_INVALID","Credentials invalid \u2014 login required",{profile:r,env:n}),{status:"needs_login",profile:r,env:n}}async function Ue(i,r,n=new de){let l=i.listProfiles();if(r("info","STARTUP_GATE_START","Auth startup gate",{profile_count:l.length}),l.length===0)return r("info","STARTUP_GATE_NONE","No profiles found \u2014 login required"),{status:"needs_login"};if(l.length>1){let f=i.getActiveProfile(),t=i.getDefaultEnv();if(f&&l.some(v=>v.profile===f&&v.env===t)){r("info","STARTUP_GATE_TRY_ACTIVE","Multiple profiles \u2014 trying active first",{activeProfile:f,activeEnv:t});let v=await ge(i,f,t,r);if(v.status==="authenticated")return v;r("info","STARTUP_GATE_ACTIVE_FAILED","Active profile invalid \u2014 showing picker",{activeProfile:f,activeEnv:t})}return r("info","STARTUP_GATE_MULTI","Multiple profiles \u2014 picker required",{profiles:l.map(a=>`${a.profile}/${a.env}`)}),{status:"needs_pick",profiles:l}}let{profile:u,env:e}=l[0];return i.setActiveProfile(u),i.setDefaultEnv(e),ae(i,n,u,e),ge(i,u,e,r)}var E=U(J(),1);function rr({resultRef:i,mode:r="singleshot",loginCompleteRef:n}){let{exit:l}=ye(),u=(0,_.useRef)(new Ae),e=(0,_.useRef)(new de),f=(0,_.useRef)(new Re),t=u.current,a=e.current,v=f.current,A=Ke(),[L,C]=(0,_.useState)(r==="login"?"login":"gate"),[R,M]=(0,_.useState)(null),[ne,F]=(0,_.useState)(null),[O,W]=(0,_.useState)(null),[H,I]=(0,_.useState)(null),[G,j]=(0,_.useState)([]),V=(0,_.useCallback)((s,d,x,m)=>v.log(s,d,x,m),[v]),ce=(0,_.useCallback)((s,d)=>{s?ae(t,a,s,d):a.save({project_id:null,project_name:null,folder_id:null,folder_name:null})},[t,a]),$=(0,_.useCallback)(()=>{r==="login"?(n&&(n.current=!0),l()):C("input")},[r,l,n]),X=(0,_.useCallback)((s,d)=>{let x=ae(t,a,s,d);if(r==="login"){C("ensure-project");return}Ie(x)?$():x.projectId?C("ensure-folder"):C("ensure-project")},[t,a,$,r]);Q((s,d)=>{d.ctrl&&s==="c"&&fe(0,"Ctrl+C exit")});let p=(0,_.useRef)(!1);_.default.useEffect(()=>{p.current||(p.current=!0,r!=="login"&&Ue(t,V).then(s=>{M(s),s.status==="authenticated"?X(s.result.profile,s.result.env):s.status==="needs_pick"?C("pick"):(F(s.profile??null),W(s.env??null),C("login"))}).catch(s=>{I(`Auth check failed: ${s instanceof Error?s.message:String(s)}`)}))},[t,V]);let o=(0,_.useCallback)(s=>{i.current={objective:s},l()},[i,l]),c=(0,_.useCallback)(async(s,d)=>{t.setActiveProfile(s),t.setDefaultEnv(d),(await ge(t,s,d,V)).status==="authenticated"?X(s,d):(F(s),W(d),C("login"))},[t,V,X]),y=(0,_.useCallback)(()=>{let s=t.getActiveProfile(),d=t.getDefaultEnv();if(!s)return null;let x=le(d),m=t.loadBasicAuth(s,d);return new me(x.controllerBaseUrl,async()=>t.loadCredentials(s,d)?.access_token??null,m,V)},[t,V]),D=(0,_.useCallback)(async()=>{let s=y();if(!s)return null;let d=s.cached??await s.resolve();if(!d)return null;let x=le(t.getDefaultEnv()),m=new he(x.tmsBaseUrl,d.username,d.access_key);try{let S=(await m.listProjects()).find(Y=>Y.name==="KaneAI Generated");if(S)return{id:S.project_id,name:S.name};let P=await m.createProject("KaneAI Generated");return{id:P.id,name:P.name}}catch{return null}},[y,t]),B=(0,_.useCallback)(async s=>{let d=y();if(!d)return null;let x=d.cached??await d.resolve();if(!x)return null;let m=le(t.getDefaultEnv()),g=new he(m.tmsBaseUrl,x.username,x.access_key);try{let P=(await g.listFolders(s)).find(K=>K.name==="Untitled");if(P)return{id:P.id,name:P.name};let Y=await g.createFolder(s,"Untitled");return{id:Y.id,name:Y.name}}catch{return null}},[y,t]);if(L==="gate")return(0,E.jsx)(b,{paddingX:1,children:(0,E.jsx)(h,{color:"yellow",children:"Checking authentication..."})});if(H)return(0,E.jsxs)(b,{flexDirection:"column",paddingX:1,children:[(0,E.jsx)(h,{color:"red",children:H}),(0,E.jsx)(h,{color:"gray",children:"Press Ctrl+C to exit."})]});if(L==="pick"&&R?.status==="needs_pick")return(0,E.jsx)(lt,{profiles:R.profiles,onSelect:c});if(L==="login")return(0,E.jsx)(je,{devMode:process.env.KANE_DEV_MODE==="1",profiles:t.listProfiles(),onBasicLogin:async(s,d,x,m)=>{let{validateBasicAuth:g}=await import("./validate-basic-JJOEAFLT.js");await g(d,x,m),t.saveBasicAuth(s,d,{username:x,access_key:m}),t.setActiveProfile(s),t.setDefaultEnv(d)},onOAuthLogin:async(s,d)=>{let{LoginFlow:x}=await import("./login-flow-3YFO62HA.js");t.setDefaultEnv(d),t.setActiveProfile(s),await new x(s,d,t).login()},onComplete:(s,d)=>{F(s),W(d),t.setActiveProfile(s),t.setDefaultEnv(d),X(s,d)},onCancel:()=>{fe(0,"Login cancelled")}});if(L==="ensure-project"){let s=t.getActiveProfile()??"default",d=t.getDefaultEnv(),x=()=>{if(r==="login"){C("ensure-folder");return}ae(t,a,s,d).folderId?$():C("ensure-folder")};return(0,E.jsxs)(b,{flexDirection:"column",children:[(0,E.jsx)(b,{paddingX:1,marginBottom:1,children:(0,E.jsx)(h,{color:"yellow",children:"Project & folder are required to save tests \xB7 Esc to use defaults \xB7 Ctrl+C to exit"})}),(0,E.jsx)(Pe,{resolver:y(),currentProjectId:a.load().project_id,env:d,onSelect:(m,g)=>{ue(t,a,s,d,{projectId:m,projectName:g}),j(S=>[...S,`\u2713 Project: ${g} (${m})`]),x()},onCancel:async()=>{let m=await D();m&&(ue(t,a,s,d,{projectId:m.id,projectName:m.name}),j(g=>[...g,`\u2713 Default project: ${m.name} (${m.id})`]),x())}})]})}if(L==="ensure-folder"){let s=t.getActiveProfile()??"default",d=t.getDefaultEnv(),x=t.loadProfileConfig(s,d);return(0,E.jsxs)(b,{flexDirection:"column",children:[(0,E.jsx)(b,{paddingX:1,marginBottom:1,children:(0,E.jsx)(h,{color:"yellow",children:"Project & folder are required to save tests \xB7 Esc to use defaults \xB7 Ctrl+C to exit"})}),(0,E.jsx)(_e,{resolver:y(),projectId:x?.project_id??"",currentFolderId:a.load().folder_id,env:d,onSelect:(m,g)=>{ue(t,a,s,d,{folderId:m,folderName:g}),j(S=>[...S,`\u2713 Folder: ${g} (${m})`]),$()},onCancel:async()=>{if(!x?.project_id)return;let m=await B(x.project_id);m&&(ue(t,a,s,d,{folderId:m.id,folderName:m.name}),j(g=>[...g,`\u2713 Default folder: ${m.name} (${m.id})`]),$())}})]})}return L==="input"?(0,E.jsxs)(b,{flexDirection:"column",children:[G.length>0&&(0,E.jsx)(b,{flexDirection:"column",paddingX:1,marginBottom:1,children:G.map((s,d)=>(0,E.jsx)(h,{color:"green",children:s},d))}),(0,E.jsx)(Oe,{onSubmit:o,onEscape:()=>fe(0,"User pressed Escape"),history:A,placeholder:"Type an objective..."})]}):(0,E.jsx)(E.Fragment,{})}function lt({profiles:i,onSelect:r}){let[n,l]=(0,_.useState)(0),[u,e]=(0,_.useState)(!1);return Q((f,t)=>{if(!u){if(t.escape){fe(0,"Profile picker cancelled");return}if(t.upArrow&&n>0&&l(a=>a-1),t.downArrow&&n<i.length-1&&l(a=>a+1),t.return){e(!0);let a=i[n];r(a.profile,a.env).catch(()=>e(!1))}}}),(0,E.jsxs)(b,{flexDirection:"column",paddingX:1,children:[(0,E.jsx)(h,{color:"#ff9500",bold:!0,children:"Select a profile:"}),(0,E.jsx)(b,{marginTop:1,flexDirection:"column",children:i.map((f,t)=>(0,E.jsxs)(h,{children:[t===n?"\u276F ":" ",(0,E.jsx)(h,{color:t===n?"#ff9500":"white",bold:t===n,children:f.profile}),(0,E.jsxs)(h,{color:"gray",children:[" [",f.env,"]"]})]},`${f.profile}-${f.env}`))}),u&&(0,E.jsx)(b,{marginTop:1,children:(0,E.jsx)(h,{color:"yellow",children:"Validating credentials..."})})]})}export{Ke as a,Oe as b,je as c,ge as d,Ue as e,rr as f};
|
package/dist/chunk-TP6KYKPD.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as p}from"./chunk-HCBYKLMW.js";import{t as a}from"./chunk-5XTLIGWL.js";import{b as u}from"./chunk-C44QQJR4.js";import{a as l}from"./chunk-6YGTRKDT.js";import{e as n}from"./chunk-UR6MHSHU.js";var m=n(l(),1);var o=n(l(),1);function c(r,e){let t=(0,o.useRef)(r);t.current=r,(0,o.useEffect)(()=>{if(e===null)return;let i=setInterval(()=>t.current(),e);return()=>clearInterval(i)},[e])}var s=n(p(),1),f=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function I({active:r=!0}){let[e,t]=(0,m.useState)(0);return c(()=>{t(i=>(i+1)%f.length)},r?80:null),(0,s.jsx)(u,{color:a.purple,children:r?f[e]:"\u25CF"})}export{c as a,I as b};
|
package/dist/chunk-U4XV5KUD.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as m}from"./chunk-HCBYKLMW.js";import{t as o}from"./chunk-5XTLIGWL.js";import{a as r,b as i}from"./chunk-C44QQJR4.js";import{e as a}from"./chunk-UR6MHSHU.js";var e=a(m(),1),u={default:o.muted,error:o.red,success:o.green,info:o.purple,warning:o.yellow};function T({title:t,titleColor:l,borderColor:d,variant:n="default",children:c,width:s,paddingX:x=2,paddingY:g=0,marginBottom:p=0}){let f=d??u[n],B=l??(n==="default"?o.purple:u[n]);return(0,e.jsxs)(r,{flexDirection:"column",marginBottom:p,children:[t&&(0,e.jsx)(r,{marginBottom:0,children:(0,e.jsxs)(i,{color:B,bold:!0,children:[" ",t]})}),(0,e.jsx)(r,{borderStyle:"round",borderColor:f,flexDirection:"column",paddingX:x,paddingY:g,width:s,children:c})]})}function h({label:t,value:l,labelColor:d=o.dimmed,valueColor:n,labelWidth:c=14}){return(0,e.jsxs)(r,{children:[(0,e.jsx)(r,{width:c,children:(0,e.jsx)(i,{color:d,children:t})}),(0,e.jsx)(i,{color:n,children:l})]})}function C({label:t}){return(0,e.jsx)(r,{marginTop:1,marginBottom:0,children:(0,e.jsx)(i,{bold:!0,children:t})})}export{T as a,h as b,C as c};
|
package/dist/chunk-VS5FTXRZ.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{d as ie,g as ae}from"./chunk-X7VI7KK3.js";import{b as ne,e as V,j as K}from"./chunk-AH4AXJML.js";import{a as oe}from"./chunk-74MJWDIW.js";import{b as re,d as se}from"./chunk-G7VF5SDK.js";import{b as F}from"./chunk-VE3SUJMA.js";import{a as _}from"./chunk-JHNEE2MB.js";import{a as te}from"./chunk-WAOCHXJ5.js";import{a as Y}from"./chunk-E47GFYXA.js";import{a as X,g as Z,i as B,j as M}from"./chunk-5XTLIGWL.js";import{a as P}from"./chunk-7CLUJYMW.js";import{a as A,b as ee}from"./chunk-NLCCBXXV.js";import{a as m}from"./chunk-RZ4F3BHX.js";import{dirname as Oe,join as De}from"path";function kt(e,t,r){let s=e.total_runs??1,o=e.run_dir,n,i;if(s>1&&o){let a=Oe(o);n=Array.from({length:s},(c,l)=>De(a,String(t+l))),r&&r.length===s&&(i=r)}return{allRunDirs:n,flowObjectives:i}}function xt(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}}import{spawn as Ne}from"child_process";async function ce(e,t,r=100){let s=`${e.replace(/\/+$/,"")}/json/version`,o=await m(s);if(!o.ok)throw new Error(`CDP /json/version returned ${o.status}`);let n=await o.json();if(!n.webSocketDebuggerUrl)throw new Error("CDP /json/version missing webSocketDebuggerUrl");let i=new Y(n.webSocketDebuggerUrl);await new Promise((S,u)=>{i.once("open",S),i.once("error",u)});let a=1,c=new Map;i.on("message",S=>{let u;try{u=JSON.parse(S.toString())}catch{return}if(u.id==null)return;let b=c.get(u.id);b&&(c.delete(u.id),u.error?b.reject(new Error(u.error.message)):b.resolve(u.result))});function l(S,u){let b=a++;return new Promise((Pe,Le)=>{c.set(b,{resolve:je=>Pe(je),reject:Le});let z={id:b,method:S};u&&(z.params=u),i.send(JSON.stringify(z))})}let d=(await l("Target.getTargets")).targetInfos.find(S=>S.type==="page");if(!d)throw i.close(),new Error("CDP: no page target found");let C=(await l("Browser.getWindowForTarget",{targetId:d.targetId})).windowId,y="",h=!1,w=null,E=!1;i.on("close",()=>{E=!0}),i.on("error",()=>{E=!0});async function W(){if(!h){if(E){h=!0;return}try{let u=(await l("Browser.getWindowBounds",{windowId:C})).bounds,b=`${u.left}:${u.top}:${u.width}:${u.height}`;b!==y&&(y=b,t({left:u.left,top:u.top,width:u.width,height:u.height}))}catch{}h||(w=setTimeout(W,r))}}return W(),{stop(){if(!h){h=!0,w&&clearTimeout(w);try{i.close()}catch{}}}}}var Ue=new Set(["1","true","yes"]);function Nt(e){if(e?.headless)return null;let t=process.env.KANE_CLI_DISABLE_MARKER;if(t!=null&&Ue.has(t.toLowerCase()))return null;let r=oe();if(!r)return null;let s=[...r.args,"overlay"];e?.text&&s.push(e.text);let o;try{o=Ne(r.cmd,s,{cwd:r.cwd,stdio:["pipe","ignore","ignore"],detached:!1,windowsHide:!0})}catch{return null}function n(c){if(!(!o.stdin||o.stdin.destroyed))try{o.stdin.write(JSON.stringify(c)+`
|
|
3
|
-
`)}catch{}}e?.chromePid&&e.chromePid>0&&n({type:"chrome_pid",pid:e.chromePid});let i=null;e?.cdpEndpoint&&ce(e.cdpEndpoint,c=>n({type:"bounds",...c})).then(c=>{i=c.stop}).catch(()=>{});let a=!1;return{setRunActive(c){a||n({type:"run_active",active:c})},setStepText(c){if(a)return;let l=c.trim();l&&n({type:"step_text",text:l})},setStepComplete(){a||n({type:"step_complete"})},kill(){if(!a){a=!0,i?.();try{o.stdin?.end()}catch{}try{o.kill("SIGTERM")}catch{}}}}}import{readFileSync as $e,existsSync as Be}from"fs";function Bt(e){if(!Be(e))return null;try{return $e(e,"utf-8").trim()||null}catch{return null}}function le(e,t,r){return`${e}/projects/${t}/test-cases/${r}`}function Ft(e,t,r,s){return`${le(e,t,r)}/dashboard/share/${s}?type=summary&agentView=true&fqdn=summary-page`}function Vt(e,t,r){return`${le(e,t,r)}/dashboard?type=summary&agentView=true&fqdn=summary-page`}import{readFileSync as de,readdirSync as ue,existsSync as R}from"fs";import{join as v}from"path";function Gt(e,t,r,s,o,n){try{let i=v(e,"runs",String(t),"run-test");if(!R(i)){o("warn","SCREENSHOT_SKIP","Runs dir not found",{step_index:r,reason:"runsDir_not_found",path:i});return}let a=i;if(n){let h=v(i,`child-${n}`);if(!R(h)){o("warn","SCREENSHOT_SKIP","Child dir not found",{step_index:r,child_id:n,reason:"child_dir_not_found",path:h});return}let w=ue(h).filter(E=>R(v(h,E,"screenshots")));if(w.length===0){o("warn","SCREENSHOT_SKIP","No screenshots dir under child",{step_index:r,child_id:n,reason:"no_child_screenshots_dir"});return}a=v(h,w[0])}else if(!R(v(i,"screenshots"))){let h=ue(i).filter(w=>R(v(i,w,"screenshots")));if(h.length===0){o("warn","SCREENSHOT_SKIP","No screenshots dir found",{step_index:r,reason:"no_screenshots_dir"});return}a=v(i,h[0])}let c=v(a,"screenshots",`step_${String(r).padStart(3,"0")}.png`);if(!R(c)){o("warn","SCREENSHOT_SKIP","Screenshot not found",{step_index:r,child_id:n,reason:"screenshot_not_found",path:c});return}let l=v(i,"actions.ndjson");if(!R(l)){o("warn","SCREENSHOT_SKIP","NDJSON not found",{step_index:r,reason:"ndjson_not_found"});return}let g=de(l,"utf-8").trim().split(`
|
|
4
|
-
`),d=g[g.length-1];if(!d){o("warn","SCREENSHOT_SKIP","NDJSON empty",{step_index:r,reason:"ndjson_empty"});return}let C=JSON.parse(d).action_id;if(!C){o("warn","SCREENSHOT_SKIP","No action_id in NDJSON",{step_index:r,reason:"no_action_id"});return}let y=de(c);s.enqueue(C,y),o("info","SCREENSHOT_ENQUEUED","Screenshot enqueued",{step_index:r,child_id:n,action_id:C,size:y.length})}catch(i){o("error","SCREENSHOT_DISPATCH_ERROR","Screenshot dispatch error",{step_index:r,error:i instanceof Error?i.message:String(i)})}}var Me=null,Fe=()=>Me??=import("sharp").then(e=>e.default??e).catch(()=>null),L=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",o=await Fe();if(o)try{let c=await o(t.buffer).webp({quality:80}).toBuffer();r=new Uint8Array(c)}catch(c){r=new Uint8Array(t.buffer),s="image/png",this.log?.("warn","SCREENSHOT_CONVERT_FAILED","WebP conversion failed, using PNG",{operation_id:t.operationId,error:c instanceof Error?c.message:String(c)})}else r=new Uint8Array(t.buffer),s="image/png";let n=s==="image/webp"?"webp":"png",i=`test_screenshots/untagged_screenshot/${t.operationId}.${n}`,a=`${this.sas.base_url}/${this.sas.container}/${i}?${this.sas.sas_token}`;for(let c=0;c<=this.maxRetries;c++)try{let l=await m(a,{method:"PUT",headers:{"Content-Type":s,"x-ms-blob-type":"BlockBlob"},body:r});if(l.ok){this.uploadedExt.set(t.operationId,n);return}if(c<this.maxRetries){await this.backoff(c);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(c<this.maxRetries){await this.backoff(c);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 I=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,o={}){if(this.stopped)return;let n=this.buildEntry(t,r,s,o);this.buffer.push(n)}logStep(t,r,s,o={}){if(this.stopped)return;let n=this.buildEntry("debug",r,s,o);n.run_index=t,this.stepBuffer.has(t)||this.stepBuffer.set(t,[]),this.stepBuffer.get(t).push(n)}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 o=JSON.stringify(t);for(let n=0;n<3;n++){try{let i=new AbortController,a=setTimeout(()=>i.abort(),1e4),c=await m(this.config.proxyUrl,{method:"POST",headers:s,body:o,signal:i.signal});if(clearTimeout(a),c.ok)return}catch{}n<2&&await new Promise(i=>setTimeout(i,1e3*Math.pow(2,n)))}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,o){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:this.currentRunIndex,identity:this.config.identity,device:this.config.device,context:o,timestamp:new Date().toISOString()}}};import{platform as Ve,arch as Ke}from"os";function me(e){let t={proxyUrl:Z,sessionId:e.sessionId,identity:e.identity,device:{cli_version:X,platform:Ve(),arch:Ke()},getToken:e.getToken};return new I(t)}import{execSync as He}from"child_process";import{readFileSync as qe}from"fs";import{createHash as Ge}from"crypto";import{hostname as Je,platform as Qe,arch as We}from"os";var j=null;function fe(){return j||(j=ze(),j)}function ze(){let e=Qe();if(e==="darwin")try{let s=He("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=qe("/etc/machine-id","utf-8").trim();if(r)return r}catch{}let t=`${Je()}:${e}:${We()}`;return Ge("sha256").update(t).digest("hex").slice(0,32)}async function Ye(e){try{let t=_(e.env),s=await new te(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 L(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 Xe(e){if(e.session.hasRemoteLogger||!e.tmsCreds)return null;let t=e.tmsCreds,r=me({sessionId:e.session.sessionId,identity:{org_id:String(t.org_id??""),user_id:String(t.user_id??""),machine_id:fe(),email:t.email??null,email_domain:t.email_domain??"unknown",user_type:t.user_type??"unknown",env:e.env},getToken:e.getToken});return e.session.setRemoteLogger(r),r.start(),r}async function Ze(e){let[t,r]=await Promise.allSettled([e.skipScreenshotQueue?Promise.resolve(null):Ye({env:e.env,auth:e.auth,session:e.session,log:e.log}),Xe({env:e.env,tmsCreds:e.tmsCreds,getToken:e.getToken,session:e.session})]);return{resolver:e.resolver,screenshotQueue:t.status==="fulfilled"?t.value:null,remoteLogger:r.status==="fulfilled"?r.value:null}}async function H(e){await Promise.allSettled([e.screenshotQueue?.drain(),e.remoteLogger?.shutdown()])}async function fr(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 q(e.env,e.tmsCreds,r,t);return G(s,t),s}case"login":case"switch":{let r=t.state.identityServicesRef.current;r&&(await H(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),o=await s.resolve(!0).catch(()=>null);if(!o)return t.log("warn","IDENTITY_VALIDATE_FAILED","Identity validation failed",{kind:e.kind,env:e.env}),null;t.state.setTmsCredsCache(o);let n=await q(e.env,o,s,t);return G(n,t),n}case"logout":{let r=t.state.identityServicesRef.current;return r&&(await H(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 H(r),t.state.identityServicesRef.current=null,t.state.screenshotQueueRef.current=null;let s=t.state.getTmsCredsCache(),o=t.auth.getResolver(),n=o??t.auth.initResolver(e.env);!o&&s&&n.prime(s);let i=await q(e.env,s,n,t);return G(i,t),i}}}async function q(e,t,r,s){let o=s.auth.getBasicAuth(),n=o?null:await s.auth.getToken(),i=o?{username:o.username,accessKey:o.access_key}:n??null;return i===null?{resolver:r,screenshotQueue:null,remoteLogger:null}:Ze({env:e,tmsCreds:t,resolver:r,auth:i,getToken:()=>s.auth.getToken(),session:s.getSession(),log:s.log,skipScreenshotQueue:s.options?.skipScreenshotQueue})}function G(e,t){t.state.identityServicesRef.current=e,t.state.screenshotQueueRef.current=e.screenshotQueue,e.remoteLogger&&(t.exit.registerCleanup("remote-logger",()=>e.remoteLogger.shutdownSync()),t.exit.setExitRemoteLogger(e.remoteLogger))}function ge(e,t){let r={},s={},o=t;for(let[n,i]of Object.entries(e))if(i.secret){let a=`secrets.user.${n}`;r[a]={value:i.value,secret:!0,syntax:`{{secrets.user.${n}}}`,type:"secret"},s[n]=a,o=o.replaceAll(`{{${n}}}`,`{{secrets.user.${n}}}`)}else{let a=`global.${n}`;r[a]={value:i.value,secret:!1,syntax:`{{global.${n}}}`,type:"global"},s[n]=a,o=o.replaceAll(`{{${n}}}`,`{{global.${n}}}`)}return{variables:r,objective:o,keyMap:s}}var O=class{constructor(t){this.baseUrl=t}async pushSecret(t){let r=A(t.username,t.accessKey),s=await m(`${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 o of r)s.add(o[1]);return[...s]}};var D=class extends ee{constructor(t,r,s){super(t,{username:r,accessKey:s})}async upsertVariable(t){let r=t.environmentId??0,s=await m(`${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 m(`${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 n=await m(`${this.baseUrl}/v1/variables/${encodeURIComponent(t.name)}?environment_id=${r}`,{method:"GET",headers:this.headers()});return n.ok?{id:(await n.json()).data?.id??0}:{id:0}}};import{readdirSync as et,readFileSync as he,existsSync as ye}from"fs";import{join as tt}from"path";function pe(e,t){if(!ye(e))return{};let r={},s;try{s=et(e).filter(o=>o.endsWith(".json")).sort()}catch{return{}}for(let o of s)try{let n=he(tt(e,o),"utf-8"),i=JSON.parse(n);if(i&&typeof i=="object"){for(let[a,c]of Object.entries(i))if(c&&typeof c=="object"&&"value"in c){let l=c;r[a]={value:l.value,secret:l.secret??!1,syntax:l.syntax??`{{${a}}}`}}}}catch{t?t("warn","VARIABLE_PARSE_FAILED","Skipping invalid variables file",{file:o}):process.stderr.write(`[variables] Warning: skipping invalid variables file: ${o}
|
|
5
|
-
`)}return r}function be(e){if(!ye(e))throw new Error(`Variables file not found: ${e}`);let t=he(e,"utf-8"),r=JSON.parse(t),s={};if(r&&typeof r=="object"){for(let[o,n]of Object.entries(r))if(n&&typeof n=="object"&&"value"in n){let i=n;s[o]={value:i.value,secret:i.secret??!1,syntax:i.syntax??`{{${o}}}`}}}return s}function ve(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,o]of Object.entries(t))if(o&&typeof o=="object"&&"value"in o){let n=o;r[s]={value:n.value,secret:n.secret??!1,syntax:n.syntax??`{{${s}}}`}}}return r}function we(e,t,r){let s=pe(e,r),o=pe(t,r);return{...s,...o}}function Ar(e,t){if(Object.keys(e).length===0)return{};let r={};for(let[s,o]of Object.entries(e)){let n=o.syntax??`{{${s}}}`;t.includes(n)&&(r[s]=o)}return r}function Pr(e){let t=we(e.globalDir,e.localDir,e.onLoadError),r=e.file?be(e.file):{},s=e.inline?ve(e.inline):{},o={...t,...r,...s},n=Object.keys(o).length>0,{variables:i,objective:a}=n?ge(o,e.objective):{variables:{},objective:e.objective},c=Object.entries(o).filter(([,g])=>g.secret),l=Object.entries(o).filter(([,g])=>!g.secret);return{raw:o,auteur:i,auteurObjective:a,secretEntries:c,nonSecretEntries:l}}async function Lr(e){if(e.localMode)return{};let t=_(e.env);if(e.variables.secretEntries.length>0){let s=new O(t.secretsBaseUrl);for(let[o,n]of e.variables.secretEntries)s.pushSecret({secretKey:o,secretValue:n.value,username:e.auth.username,accessKey:e.auth.access_key,orgId:e.orgId}).then(()=>e.log("info","SECRET_PUSH_OK","Secret pushed",{key:o})).catch(i=>e.log("error","SECRET_PUSH_FAILED","Secret push failed",{key:o,error:String(i)}))}let r={};if(e.variables.nonSecretEntries.length>0){let s=new D(t.tmsBaseUrl,e.auth.username,e.auth.access_key);for(let[o,n]of e.variables.nonSecretEntries)try{let i=await s.upsertVariable({name:o,value:n.value});r[o]=i.id,e.log("info","VAR_PUSH_OK","Variable pushed",{name:o,id:i.id})}catch(i){e.log("error","VAR_PUSH_FAILED","Variable push failed",{name:o,error:String(i)})}}return r}function Or(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.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.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}var rt=15e3,J=3,Se=[500,1e3];async function $r(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 N(t,{from_commit_id:e.fromCommitId,new_commit_id:e.newCommitId},e.auth);return r.ok?{ok:!0,sessionExpiresAt:f(r.body,"session_expires_at")??""}:{ok:!1,...st(r)}}function st(e){let t=f(e.body,"error")??f(e.body,"code")??"",r=f(e.body,"message")??f(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 Br(e){let t=`${e.baseUrl}/test/${encodeURIComponent(e.testId)}/playground/reserve`,r=await N(t,void 0,e.auth);return r.ok?{ok:!0,sessionExpiresAt:f(r.body,"session_expires_at")??""}:{ok:!1,expired:r.status===404,httpStatus:r.status,message:f(r.body,"message")??f(r.body,"detail")??r.text??`HTTP ${r.status}`}}async function Ce(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 N(t,r,e.auth);return s.ok?{ok:!0,testId:f(s.body,"test_id")??e.testId,testcaseId:f(s.body,"testcase_id")??"",projectId:f(s.body,"project_id"),isTestCaseDeleted:typeof s.body?.is_test_case_deleted=="boolean"?s.body.is_test_case_deleted:void 0}:{ok:!1,...ot(s)}}function ot(e){let t=f(e.body,"error")??f(e.body,"code")??"",r=f(e.body,"message")??f(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 Mr(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 N(t,r,e.auth);return s.ok?{ok:!0}:{ok:!1,reason:f(s.body,"error")??"other",httpStatus:s.status,message:f(s.body,"message")??f(s.body,"detail")??s.text??`HTTP ${s.status}`}}async function N(e,t,r){let s=null;for(let o=1;o<=J;o++){let n=new AbortController,i=setTimeout(()=>n.abort(),rt);try{let a=await m(e,{method:"POST",headers:{Authorization:A(r.username,r.accessKey),"Content-Type":"application/json",Accept:"application/json"},...t!==void 0?{body:JSON.stringify(t)}:{},signal:n.signal});clearTimeout(i);let c=await a.text(),l=null;if(c)try{l=JSON.parse(c)}catch{}let g=a.status>=500||a.status===408||a.status===429;if(a.ok||!g)return{ok:a.ok,status:a.status,body:l,text:c};if(o<J){await _e(Se[o-1]??1e3);continue}return{ok:!1,status:a.status,body:l,text:c}}catch(a){if(clearTimeout(i),s=a,o<J){await _e(Se[o-1]??1e3);continue}}}return{ok:!1,status:0,body:null,text:s?.message??"exhausted retries"}}function _e(e){return new Promise(t=>setTimeout(t,e))}function f(e,t){if(typeof e!="object"||e===null)return;let r=e[t];return typeof r=="string"?r:void 0}import{readFileSync as Ee,writeFileSync as Ie,existsSync as ke}from"fs";function Re(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(i=>i.kind==="author"&&i.reason==="no-result-md"))return"initial recording";if(t.length>0&&t.every(i=>i.kind==="replay"))return r.wantsPush?"re-recorded (no source changes)":"no changes";let s=[];for(let i=0;i<t.length;i++){let a=t[i];if(!a||a.kind!=="author"||a.reason==="downstream-of-divergence"||a.reason==="no-result-md")continue;let c=nt(e,e.steps[i]);switch(a.reason){case"structure-mismatch":s.push(`added/removed: ${c}`);break;case"md5-mismatch":s.push(`modified: ${c}`);break;case"missing-recording":s.push(`re-recorded: ${c}`);break;case"recorded-failed":s.push(`re-authored after failure: ${c}`);break}}if(s.length===0)return"automated commit";let o=s.filter((i,a)=>a===0||s[a-1]!==i),n=o.slice(0,3).join("; ");return o.length>3?`${n}; +${o.length-3} more`:n}function nt(e,t){if(!t)return"unknown step";let r=t.trace[0]?.stepIndex;if(r==null)return"unknown step";let o=e.rootSteps[r-1]?.heading?.trim()??"";return t.trace.length>1?o?`imported step in "${o}"`:`imported step ${r}`:o||`step ${r}`}function it(e){if(!(!e.shouldReplaceLocalOutput||!e.resolvedTest||!e.sourcePath||!e.stepRunRecords||!e.outcomes||!e.overallStatus))return async()=>{ae({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}),K(ne(e.sourcePath));let t=new Set;for(let r of e.resolvedTest.steps)if(r.trace.length>1){let s=ie(r.trace);if(t.has(s))continue;t.add(s),ke(`${s}.staging`)&&K(s)}}}function at(e){if(!(!e.shouldCommit||e.isFirstRun||!e.tmsBaseUrl||!e.testId||!e.fromCommitId||!e.newCommitId||!e.basicAuth||!e.resolvedTest||!e.decisions))return async()=>{let t=Re(e.resolvedTest,e.decisions,{wantsPush:e.wantsPush??!1,retryTriggered:e.retryTriggered??!1,forceAuthor:e.forceAuthor??!1}),r=e.resolvedTest.steps.map(o=>o.objective).filter(o=>typeof o=="string"&&o.length>0).slice(0,50),s=await Ce({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 o=V(e.sourcePath);try{let n=JSON.parse(Ee(o,"utf8"));n.commit_id=e.newCommitId,Ie(o,JSON.stringify(n,null,2)+`
|
|
6
|
-
`,"utf8")}catch(n){process.stderr.write(`warn: failed to update meta.json commit_id: ${n.message}
|
|
7
|
-
`)}}return s}}function ct(e){if(!(!e.isFirstRun||!e.sourcePath))return async t=>{if(!e.sourcePath)return;let r=V(e.sourcePath);try{let s=ke(r)?JSON.parse(Ee(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),Ie(r,JSON.stringify(s,null,2)+`
|
|
8
|
-
`,"utf8")}catch(s){process.stderr.write(`warn: failed to update meta.json after endTest: ${s.message}
|
|
9
|
-
`)}}}function Yr(e){let t=_(e.env),{session:r,auth:s}=e,o=s.basicAuth?{username:s.basicAuth.username,accessKey:s.basicAuth.access_key}:s.token,n=s.resolvedCreds?.username??s.basicAuth?.username??"",i=s.resolvedCreds?.access_key??s.basicAuth?.access_key??"",a=s.resolvedCreds?.org_id??0,c=s.resolvedCreds?.user_id??0,l=[];for(let y of Object.keys(r.auteurVariables))y.startsWith("secrets.user.")&&l.push({key_name:y.replace("secrets.user.",""),scope:"user"});let d=r.getContext().prior_runs.map(y=>y.status),p=r.auteurVariables,C=Object.keys(p).length>0;return{controllerBaseUrl:t.controllerBaseUrl,tmsBaseUrl:t.tmsBaseUrl,auth:o,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:d,orgId:a,userId:c,tmsUsername:n,tmsAccessKey:i,screenshotBaseUrl:r.screenshotBaseUrl,screenshotExtMap:e.screenshotExtMap,shareApiBaseUrl:t.shareApiBaseUrl,variables:C?p: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:it(e),onCommitLock:at(e),onFinalizeSuccess:ct(e)}}var xe=["python","javascript"];function lt(e){if(e!==void 0){if(!xe.includes(e))throw new Error(`--code-language must be one of: ${xe.join(", ")} (got "${e}")`);return e}}function Zr(e,t){let r=lt(e.codeLanguage);return{enabled:e.codeExport??t.enabled,language:r??t.language,skipValidation:e.skipCodeValidation??t.skip_validation}}async function rs(e){try{let r=await new P(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}}import{mkdtempSync as wt,rmSync as St}from"fs";import{join as _t}from"path";import{tmpdir as Ct}from"os";import{spawn as Te,spawnSync as dt}from"child_process";import{existsSync as Q}from"fs";import{createConnection as ut}from"net";import{homedir as k,platform as T}from"os";import{join as x}from"path";var mt=new Set(["1","true","yes"]),U=class extends Error{constructor(t){super(t),this.name="ChromeNotFoundError"}};function ms(e){return e instanceof U?e.message:`Chrome failed: ${e instanceof Error?e.message:String(e)}`}var $={darwin:["/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",x(k(),"Applications/Google Chrome.app/Contents/MacOS/Google Chrome"),"/Applications/Google Chrome for Testing.app/Contents/MacOS/Google Chrome for Testing",x(k(),"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",x(k(),"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",x(k(),"AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"),"C:\\chrome-for-testing\\chrome-win64\\chrome.exe",x(k(),"AppData\\Local\\chrome-for-testing\\chrome-win64\\chrome.exe")]};function ft(){if(process.env.KANE_CLI_CHROME_PATH)return process.env.KANE_CLI_CHROME_PATH;let e=T(),t=$[e]??$.linux;for(let r of t)if(Q(r))return r;return e==="win32"?"chrome.exe":"google-chrome"}function gt(){if(process.env.KANE_CLI_CHROME_PATH)return Q(process.env.KANE_CLI_CHROME_PATH);let e=T();if(($[e]??$.linux).some(o=>Q(o)))return!0;let r=e==="win32"?"chrome.exe":"google-chrome",s=e==="win32"?"where":"which";try{return dt(s,[r],{stdio:"ignore"}).status===0}catch{return!1}}function pt(){let e=T();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(`
|
|
10
|
-
`):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(`
|
|
11
|
-
`):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(`
|
|
12
|
-
`):["Google Chrome is required.","Install from https://www.google.com/chrome/","(Note: no official Chrome builds for BSD or Alpine/musl Linux.)"].join(`
|
|
13
|
-
`)}function ht(e){let t=T(),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 yt(e){return new Promise(t=>{let r=ut({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 bt(){for(let e=B;e<=M;e++)if(!await yt(e))return e;throw new Error(`All CDP ports ${B}-${M} are in use. Close other Chrome instances.`)}async function vt(e,t=15e3){let r=Date.now(),s=`http://127.0.0.1:${e}/json/version`;for(;Date.now()-r<t;){try{if((await m(s)).ok)return`http://127.0.0.1:${e}`}catch{}await new Promise(o=>setTimeout(o,200))}throw new Error(`Chrome CDP not ready after ${t}ms on port ${e}`)}async function Ae(e){let t=process.env.KANE_CLI_SKIP_BROWSER_DOWNLOAD;if(!(t!=null&&mt.has(t.toLowerCase()))&&!gt())throw re()?.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 U(pt());let s=T(),o=await bt(),n=ft(),i=ht({port:o,...e});e.startUrl&&i.push(e.startUrl);let a=Te(n,i,{stdio:"ignore",detached:!0});a.unref();let c=await new Promise((l,g)=>{a.on("error",d=>{g(new Error(`Failed to launch Chrome: ${d.message}. Is Chrome installed at ${n}?`))}),a.on("close",d=>{d!==null&&d!==0&&g(new Error(`Chrome exited during startup with code ${d}`))}),vt(o).then(l,g)});return{process:a,port:o,cdpEndpoint:c,kill(){try{if(a.pid)if(s==="win32")Te("taskkill",["/pid",String(a.pid),"/T","/F"],{stdio:"ignore"});else try{process.kill(-a.pid,"SIGKILL")}catch{a.kill("SIGKILL")}else a.kill("SIGKILL")}catch{}}}}async function ws(e){if(e.cft)return{instance:null,tempDir:null};if(e.wsEndpoint)return{wsEndpoint:e.wsEndpoint,instance:null,tempDir:null};if(e.cdpEndpoint){let o=await m(`${e.cdpEndpoint}/json/version`);if(!o.ok)throw new Error(`CDP endpoint not reachable: ${e.cdpEndpoint} (${o.status})`);return{cdpEndpoint:e.cdpEndpoint,instance:null,tempDir:null}}let t,r=null;if(e.config.chrome_profile_path)t=e.config.chrome_profile_path.replace("~",process.env.HOME??"~");else{r=wt(_t(Ct(),"kane-clean-")),t=r;let o=r;se("tempDir",()=>{try{St(o,{recursive:!0,force:!0})}catch{}})}let s=await Ae({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}}var Rt="KaneAI Generated",Et="Untitled";async function Es(e){let t=e.config.load(),r=new P(_(e.env).tmsBaseUrl,e.tmsCreds.username,e.tmsCreds.access_key),s=e.projectName??Rt,o=e.folderName??Et,n=t.project_id??null,i=t.project_name??null;if(!n){let d=(await r.listProjects()).find(p=>p.name===s);if(d)n=d.project_id,i=d.name,e.log("info","ENSURE_PROJECT_FOUND","Found default project",{project_id:n,name:i});else{let p=await r.createProject(s);n=p.id,i=p.name,e.log("info","ENSURE_PROJECT_CREATED","Created default project",{project_id:n,name:i})}F(e.creds,e.config,e.profile,e.env,{projectId:n,projectName:i})}let a=t.folder_id??null,c=t.folder_name??null,l=!t.project_id;if(!a||l){let d=(await r.listFolders(n)).find(p=>p.name===o);if(d)a=d.id,c=d.name,e.log("info","ENSURE_FOLDER_FOUND","Found default folder",{folder_id:a,name:c});else{let p=await r.createFolder(n,o);a=p.id,c=p.name,e.log("info","ENSURE_FOLDER_CREATED","Created default folder",{folder_id:a,name:c})}F(e.creds,e.config,e.profile,e.env,{folderId:a,folderName:c})}return{projectId:n,projectName:i??s,folderId:a,folderName:c??o}}export{kt as a,xt as b,U as c,ms as d,Ae as e,Nt as f,Bt as g,Ft as h,Vt as i,Gt as j,Ze as k,fr as l,ge as m,O as n,D as o,Ar as p,Pr as q,Lr as r,Or as s,$r as t,Br as u,Mr as v,Yr as w,Zr as x,rs as y,ws as z,Es as A};
|