@testmuai/kane-cli 0.4.1 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ChromeProfilePicker-63JS7QX6.js → ChromeProfilePicker-HNP7QQ4J.js} +1 -1
- package/dist/{CliFeedbackPrompt-3SDJ5GZP.js → CliFeedbackPrompt-OSNATI4W.js} +1 -1
- package/dist/{CliUploadProgress-ZSZ7TGCN.js → CliUploadProgress-7HRWDZ4P.js} +1 -1
- package/dist/{ConfigView-OOQYCHWM.js → ConfigView-PQH67FUK.js} +1 -1
- package/dist/FolderPicker-SET7IG6S.js +2 -0
- package/dist/HelpView-HFKFRKG3.js +2 -0
- package/dist/{InfoBox-QECFIGGW.js → InfoBox-3IN3IZ2I.js} +1 -1
- package/dist/{LinksBox-2L2UX4LB.js → LinksBox-DI5QKX6K.js} +1 -1
- package/dist/{ProfilesView-72UTQ5PX.js → ProfilesView-N6XNSUHQ.js} +1 -1
- package/dist/{ProjectPicker-NLEAW232.js → ProjectPicker-6QIVHOO7.js} +1 -1
- package/dist/{SaveSessionPrompt-VNJDLJTF.js → SaveSessionPrompt-7CZHPNYK.js} +1 -1
- package/dist/SingleShotApp-A4VXMXEZ.js +2 -0
- package/dist/{SummaryBox-O772FRGO.js → SummaryBox-7ZK2A6MA.js} +1 -1
- package/dist/TestMdRunView-KGHEZZBK.js +2 -0
- package/dist/{WhoamiView-LR2EFCTK.js → WhoamiView-3E447A3G.js} +1 -1
- package/dist/{changelog-VCAUV47V.js → changelog-ZBTZCYKI.js} +1 -1
- package/dist/{chunk-CMRNCZGV.js → chunk-34YRU7WM.js} +2 -2
- package/dist/chunk-3QWAABMG.js +2 -0
- package/dist/{chunk-P7ZUISQG.js → chunk-4UKCDU64.js} +1 -1
- package/dist/{chunk-KJEJ7VW5.js → chunk-4ZHU4DLD.js} +1 -1
- package/dist/{chunk-UYHNJUPY.js → chunk-7CBWZLRS.js} +1 -1
- package/dist/{chunk-7I2SQ2KP.js → chunk-AAJSF67A.js} +1 -1
- package/dist/{chunk-RHUD7MK4.js → chunk-AKKATURY.js} +2 -2
- package/dist/{chunk-AGS57DSG.js → chunk-BM25JQ3Z.js} +1 -1
- package/dist/{chunk-UHFCCGVX.js → chunk-CZBHDBID.js} +1 -1
- package/dist/chunk-DGUXTSHM.js +11 -0
- package/dist/{chunk-LEXQLAWB.js → chunk-DQASLGFG.js} +33 -33
- package/dist/{chunk-4QO6JYHX.js → chunk-ELZIC2EH.js} +1 -1
- package/dist/chunk-FFTIDI5K.js +5 -0
- package/dist/{chunk-JGXJDTMO.js → chunk-GNJBT6SS.js} +1 -1
- package/dist/{chunk-YSSBAIJI.js → chunk-H2P7UJAU.js} +1 -1
- package/dist/chunk-K4PLPKPF.js +5 -0
- package/dist/{chunk-OFEPMULV.js → chunk-KPF3BPJ5.js} +1 -1
- package/dist/{chunk-J2KTLZAW.js → chunk-LOSNFBZV.js} +1 -1
- package/dist/chunk-LY5LHKGG.js +18 -0
- package/dist/{chunk-7U4NY37W.js → chunk-NKFXY5TF.js} +2 -2
- package/dist/chunk-OISHNB7D.js +2 -0
- package/dist/{chunk-T46Z27UL.js → chunk-PF7PBYCJ.js} +1 -1
- package/dist/{chunk-7NDFOI6Z.js → chunk-PQIPYWTP.js} +1 -1
- package/dist/chunk-QXVI3LI4.js +6 -0
- package/dist/{chunk-RJNGCQCL.js → chunk-R7T6Z6QW.js} +1 -1
- package/dist/{chunk-77SZF4ZU.js → chunk-RCL22HDJ.js} +1 -1
- package/dist/{chunk-DAVPOA2L.js → chunk-RD6G3CMN.js} +1 -1
- package/dist/chunk-RLSBAT6P.js +2 -0
- package/dist/chunk-S7JV4A3U.js +2 -0
- package/dist/{chunk-V3FSESZ4.js → chunk-TQGNNJX5.js} +1 -1
- package/dist/{chunk-HUOC7DUT.js → chunk-UHGECBEN.js} +1 -1
- package/dist/{chunk-TCLKNUAL.js → chunk-VBZIIF5N.js} +1 -1
- package/dist/chunk-VL57GII7.js +2 -0
- package/dist/chunk-WFSTRBQF.js +2 -0
- package/dist/{chunk-YAVIOVVP.js → chunk-Y6IUJZMV.js} +1 -1
- package/dist/{chunk-VKG45YIL.js → chunk-YB67GRWE.js} +1 -1
- package/dist/generate-headless-WL6A6ACX.js +21 -0
- package/dist/index.js +38 -33
- package/dist/{list-commands-Y6A3XR4L.js → list-commands-MK4W3Q7O.js} +1 -1
- package/dist/login-flow-CDR6ARK3.js +2 -0
- package/dist/{persist-recorded-session-WBPLUA55.js → persist-recorded-session-A5EJ25AE.js} +1 -1
- package/dist/{recording-banner-Q36WARSF.js → recording-banner-6UI6NNRK.js} +1 -1
- package/dist/{require-project-folder-DBXAG7FB.js → require-project-folder-J5WZR653.js} +1 -1
- package/dist/{run-test-md-H2X6CUIX.js → run-test-md-I76IV7QA.js} +3 -3
- package/dist/skill-installer-ZLBRT4QP.js +3 -0
- package/dist/tcg-generate-R6P4QUGO.js +2 -0
- package/dist/testmd-actions-W2INQVTH.js +2 -0
- package/dist/token-refresh-4QLWR5ZI.js +2 -0
- package/dist/{validate-basic-VFJZKHOE.js → validate-basic-QUPVT2EV.js} +1 -1
- package/dist/{version-check-5NUDIYG4.js → version-check-RVK5YKDZ.js} +1 -1
- package/package.json +8 -6
- package/dist/FolderPicker-FILMS64I.js +0 -2
- package/dist/HelpView-KBFE4EMP.js +0 -2
- package/dist/SingleShotApp-V2UTGNZO.js +0 -2
- package/dist/TestMdRunView-OVHCLNI7.js +0 -2
- package/dist/chunk-45VTQLJS.js +0 -6
- package/dist/chunk-FGC74Z76.js +0 -2
- package/dist/chunk-G6AXOEED.js +0 -2
- package/dist/chunk-H4XK55B3.js +0 -5
- package/dist/chunk-IBDWHXNE.js +0 -2
- package/dist/chunk-JJERCR2W.js +0 -5
- package/dist/chunk-LAR7I5SR.js +0 -2
- package/dist/chunk-OIPVMEM7.js +0 -2
- package/dist/chunk-Z7AXAKPX.js +0 -9
- package/dist/chunk-ZUIWBVGF.js +0 -14
- package/dist/generate-headless-XWVVEFQR.js +0 -18
- package/dist/login-flow-MKAYO6IS.js +0 -2
- package/dist/tcg-generate-WURS7TXW.js +0 -2
- package/dist/testmd-actions-MQ3N7IS4.js +0 -2
- package/dist/token-refresh-HHNMHTYX.js +0 -2
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c,d,e,f,g,h,i}from"./chunk-
|
|
2
|
+
import{a,b,c,d,e,f,g,h,i}from"./chunk-NKFXY5TF.js";import"./chunk-FPFOW6BS.js";import"./chunk-WAOCHXJ5.js";import"./chunk-LOIRZFV3.js";import"./chunk-LPUQ4HWQ.js";import"./chunk-NLCCBXXV.js";import"./chunk-PF7PBYCJ.js";import"./chunk-S7JV4A3U.js";import"./chunk-RZ4F3BHX.js";import"./chunk-3QWAABMG.js";import"./chunk-UR6MHSHU.js";export{d as emitNdjson,b as filterByName,g as formatAuthResolutionError,c as paginate,a as parsePagination,i as registerListCommands,e as renderTable,f as resolveTmsBasicAuth,h as validateCreateName};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a}from"./chunk-LOSNFBZV.js";import"./chunk-PF7PBYCJ.js";import"./chunk-WFSTRBQF.js";import"./chunk-S7JV4A3U.js";import"./chunk-RZ4F3BHX.js";import"./chunk-3QWAABMG.js";import"./chunk-UR6MHSHU.js";export{a as LoginFlow};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
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-
|
|
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-H2P7UJAU.js";import"./chunk-3QWAABMG.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
3
|
`)}return{recordedTestPath:o,outputDir:s}}export{y as persistRecordedSession};
|
|
@@ -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-3IN3IZ2I.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};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as a,c as b,d as c,e as d,f as e,g as f}from"./chunk-
|
|
2
|
+
import{b as a,c as b,d as c,e as d,f as e,g as f}from"./chunk-VBZIIF5N.js";import"./chunk-LPUQ4HWQ.js";import"./chunk-NLCCBXXV.js";import"./chunk-VE3SUJMA.js";import"./chunk-S7JV4A3U.js";import"./chunk-RZ4F3BHX.js";import"./chunk-3QWAABMG.js";import"./chunk-UR6MHSHU.js";export{d as buildAutoDefaultAnnouncement,e as buildAutoDefaultedNdjson,c as buildRemediationMessage,b as decideGateAction,a as loadCachedIds,f as requireProjectFolder};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{u as b,v as D,w as U,x as V,y as H}from"./chunk-
|
|
3
|
-
`)};return{async runSteps(e){let{default:t}=await import("./react-QWOAB3TB.js"),{render:n}=await import("./build-JIKYOZUH.js"),{TestMdRunView:s}=await import("./TestMdRunView-
|
|
2
|
+
import{u as b,v as D,w as U,x as V,y as H}from"./chunk-DQASLGFG.js";import"./chunk-C5UNZ6ZY.js";import"./chunk-EEF6OT52.js";import{a as L,b as T}from"./chunk-34YRU7WM.js";import{a as y,b as _}from"./chunk-RCL22HDJ.js";import"./chunk-MDBXYXSC.js";import"./chunk-S3DAAAE5.js";import{a as P}from"./chunk-HN7DVSVI.js";import"./chunk-AH4AXJML.js";import{c as x}from"./chunk-BM25JQ3Z.js";import"./chunk-L5LI2JF4.js";import{a as S}from"./chunk-H2P7UJAU.js";import"./chunk-FPFOW6BS.js";import"./chunk-WAOCHXJ5.js";import"./chunk-K4PLPKPF.js";import{d as E,e as C,f as k}from"./chunk-LOIRZFV3.js";import"./chunk-VBZIIF5N.js";import"./chunk-LPUQ4HWQ.js";import"./chunk-NLCCBXXV.js";import"./chunk-VE3SUJMA.js";import"./chunk-Y6IUJZMV.js";import{a as h}from"./chunk-PF7PBYCJ.js";import"./chunk-WFSTRBQF.js";import{a as v}from"./chunk-S7JV4A3U.js";import"./chunk-RZ4F3BHX.js";import"./chunk-E47GFYXA.js";import"./chunk-3QWAABMG.js";import"./chunk-UR6MHSHU.js";import{resolve as K}from"path";import{existsSync as $}from"fs";function A(a){let{isAgent:o,log:i}=a,c=e=>{o&&process.stdout.write(JSON.stringify(e)+`
|
|
3
|
+
`)};return{async runSteps(e){let{default:t}=await import("./react-QWOAB3TB.js"),{render:n}=await import("./build-JIKYOZUH.js"),{TestMdRunView:s}=await import("./TestMdRunView-KGHEZZBK.js"),{ScrollbackProvider:m}=await import("./scrollback-6GINSTL2.js"),{waitUntilExit:l}=n(t.createElement(m,null,t.createElement(s,e)),{stdout:process.stderr,exitOnCtrlC:!1});await l()},async runUpload(e,t){let{renderUploadProgress:n}=await import("./CliUploadProgress-7HRWDZ4P.js");return await n(e,t)},async onSummary(e){try{let{default:t}=await import("./react-QWOAB3TB.js"),{render:n}=await import("./build-JIKYOZUH.js"),{AutoExitSummaryBox:s}=await import("./SummaryBox-7ZK2A6MA.js"),{waitUntilExit:m}=n(t.createElement(s,{data:e}),{stdout:process.stderr});await m()}catch(t){i("warn","TEST_MD_SUMMARY_RENDER_FAILED","Summary box render failed",{error:String(t)})}},async onLinks(e){try{let{default:t}=await import("./react-QWOAB3TB.js"),{render:n}=await import("./build-JIKYOZUH.js"),{LinksBox:s}=await import("./LinksBox-DI5QKX6K.js"),{waitUntilExit:m}=n(t.createElement(s,e),{stdout:process.stderr});await m()}catch(t){i("warn","TEST_MD_LINKS_RENDER_FAILED","LinksBox render failed",{error:String(t)})}},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,o)=>E(a,o),deregister:a=>C(a),cleanup:(a,o)=>k(a,o),remoteLogger:null}}async function le(a,o){let i=K(a);if(!$(i))return process.stderr.write(`error: file not found: ${i}
|
|
4
4
|
`),2;L(i);let c=!process.stdin.isTTY||!!o.agent,e=M(),t;try{t=P(i)}catch(r){return process.stderr.write(`error: ${r.message}
|
|
5
5
|
`),2}if(t.steps.length===0)return process.stderr.write(`info: no steps in ${i}; nothing to run.
|
|
6
6
|
`),0;let n;try{n=Y(o)}catch(r){if(r instanceof d)return process.stderr.write(r.message),r.exitCode;throw r}let s=new h,m=new S,l=!!(o.username&&o.accessKey);await T({isInteractive:!!process.stdin.isTTY&&!o.agent&&!l,creds:s,config:m});let j=s.getActiveProfile()??"default",u=o.env??void 0??s.getDefaultEnv()??"prod",N=v(u),F="v16-alpha",f;try{f=await _({creds:s,env:u,usernameFlag:o.username,accessKeyFlag:o.accessKey,log:()=>{}})}catch(r){return r instanceof y&&r.code==="not_authenticated"?process.stderr.write(`error: Not authenticated. Choose one:
|
|
@@ -9,6 +9,6 @@ import{u as b,v as D,w as U,x as V,y as H}from"./chunk-LEXQLAWB.js";import"./chu
|
|
|
9
9
|
\u2022 Run 'kane-cli login --username <user> --access-key <key>'
|
|
10
10
|
`):r instanceof y&&r.code==="refresh_failed"?process.stderr.write(`error: Token refresh failed. Run 'kane-cli login' to re-authenticate.
|
|
11
11
|
`):process.stderr.write(`error: auth resolution failed: ${r.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:r,assertOrgMatchOrExit:g}=await import("./testmd-actions-
|
|
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:r,assertOrgMatchOrExit:g}=await import("./testmd-actions-W2INQVTH.js"),p=g(r(i),w);if(p!==null)return p}let R=new x,I=A({isAgent:c,log:(r,g,p,B)=>R.log(r,g,p,B)}),O={path:i,cwd:process.cwd(),opts:o,isAgent:c,resolved:t,resolvedAuth:f,cliOverrides:n,environment:u,envConfig:N,profile:j,model:F,creds:s,configStore:m,session:R};try{return(await b(O,I,e)).exitCode}catch(r){return process.stderr.write(`error: ${r.message}
|
|
13
13
|
`),2}}var d=class extends Error{constructor(i,c){super(i);this.exitCode=c;this.name="CliArgError"}};function Y(a){let o={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,t]of Object.entries(o)){let n=a[e];if(n===void 0||n==="")continue;let s=n;if(i.has(t)&&(s=Number(n),Number.isNaN(s))){let m="--"+e.replace(/[A-Z]/g,l=>"-"+l.toLowerCase());throw new d(`error: ${m} must be a number
|
|
14
14
|
`,2)}c[t]=s}return c}export{H as applyCliStepConfig,U as buildStepRunVariables,D as buildTestLevelVariables,V as replayVariablesForStep,le as runTestMdFile};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as p,b as g}from"./chunk-RLSBAT6P.js";import{b as m}from"./chunk-KPF3BPJ5.js";import"./chunk-PF7PBYCJ.js";import"./chunk-S7JV4A3U.js";import{a as d}from"./chunk-RZ4F3BHX.js";import{a as f,g as a,h as u}from"./chunk-3QWAABMG.js";import"./chunk-UR6MHSHU.js";import{mkdirSync as y,writeFileSync as w,readFileSync as S,rmSync as c,cpSync as v,createWriteStream as T,existsSync as b}from"fs";import{join as s}from"path";import{tmpdir as k}from"os";import{spawn as h}from"child_process";import{Readable as I}from"stream";import{pipeline as $}from"stream/promises";function E(t){try{return S(s(t,"VERSION"),"utf-8").trim()||null}catch{return null}}function L(t,r,l){return l?t!==r:t===null||m(t,r)>0}function C(t){let r=a.split("/").pop()??a;return`https://registry.npmjs.org/${a}/-/${r}-${t}.tgz`}var R=5e3,A=6e4;async function x(){let t=new AbortController,r=setTimeout(()=>t.abort(),R);try{let l=await d(p(),{headers:{Accept:"application/json"},signal:t.signal});if(!l.ok)throw new Error(`Controller returned ${l.status} fetching skill version map`);let i=await l.json(),n=g(i,f);if(!n)throw new Error("No compatible skill version found for this kane-cli build");return n}finally{clearTimeout(r)}}async function _(t){let r=C(t),l=new AbortController,i=setTimeout(()=>l.abort(),A);try{let n=await d(r,{headers:{Accept:"application/octet-stream"},signal:l.signal});if(!n.ok||!n.body)throw new Error(`Failed to download skill tarball (${n.status})`);let e=s(k(),`kane-cli-skill-${t}-${process.pid}.tgz`);return await $(I.fromWeb(n.body),T(e)),e}finally{clearTimeout(i)}}function M(t,r){return new Promise((l,i)=>{y(r,{recursive:!0});let n=h("tar",["-xzf",t,"-C",r,"--strip-components=2","package/skills"],{stdio:["ignore","ignore","pipe"]}),e="";n.stderr?.on("data",o=>{e+=o.toString()}),n.on("error",o=>i(o)),n.on("close",o=>{o===0?l():i(new Error(`tar exited ${o}${e?`: ${e.trim()}`:""}`))})})}async function W(t){let r;try{r=t??await x()}catch(e){return{status:"failed",version:t??"unknown",installedTargets:0,error:e instanceof Error?e.message:String(e)}}let l=u.filter(({dir:e})=>L(E(e),r,!!t));if(l.length===0)return{status:"already-installed",version:r,installedTargets:0};let i=null,n=null;try{if(n=await _(r),i=s(k(),`kane-cli-skill-${r}-stage-${process.pid}`),c(i,{recursive:!0,force:!0}),await M(n,i),!b(s(i,"SKILL.md")))throw new Error(`Unexpected skill tarball layout for v${r}: SKILL.md not at package/skills/ root`);let e=0;for(let{dir:o}of l)try{c(o,{recursive:!0,force:!0}),y(o,{recursive:!0}),v(i,o,{recursive:!0,force:!0}),w(s(o,"VERSION"),r+`
|
|
3
|
+
`),e++}catch{}return e===0?{status:"failed",version:r,installedTargets:0,error:"Could not write to any agent skill directory"}:{status:"installed",version:r,installedTargets:e}}catch(e){return{status:"failed",version:r,installedTargets:0,error:e instanceof Error?e.message:String(e)}}finally{if(n)try{c(n,{force:!0})}catch{}if(i)try{c(i,{recursive:!0,force:!0})}catch{}}}function D(t){switch(t.status){case"installed":return`Installed kane-cli skill v${t.version} (${t.installedTargets}/${u.length} agent dirs). Restart your AI agent (Claude Code / Codex CLI / Gemini CLI) to load it.`;case"already-installed":return`kane-cli skill v${t.version} already installed.`;case"failed":return`Failed to install kane-cli skill: ${t.error??"unknown error"}`}}export{D as formatInstallResult,W as installSkill,L as targetNeedsInstall};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{c as a}from"./chunk-LY5LHKGG.js";import"./chunk-QXVI3LI4.js";import"./chunk-3MSXQU2C.js";import"./chunk-OISHNB7D.js";import"./chunk-DQASLGFG.js";import"./chunk-C5UNZ6ZY.js";import"./chunk-EEF6OT52.js";import"./chunk-AKKATURY.js";import"./chunk-34YRU7WM.js";import"./chunk-RCL22HDJ.js";import"./chunk-MDBXYXSC.js";import"./chunk-R7T6Z6QW.js";import"./chunk-S3DAAAE5.js";import"./chunk-HN7DVSVI.js";import"./chunk-AH4AXJML.js";import"./chunk-DGUXTSHM.js";import"./chunk-BM25JQ3Z.js";import"./chunk-L5LI2JF4.js";import"./chunk-H2P7UJAU.js";import"./chunk-FPFOW6BS.js";import"./chunk-WAOCHXJ5.js";import"./chunk-FFTIDI5K.js";import"./chunk-K4PLPKPF.js";import"./chunk-VL57GII7.js";import"./chunk-PQIPYWTP.js";import"./chunk-TQGNNJX5.js";import"./chunk-RD6G3CMN.js";import"./chunk-4ZHU4DLD.js";import"./chunk-4UKCDU64.js";import"./chunk-YCCUBQY4.js";import"./chunk-CZBHDBID.js";import"./chunk-LOIRZFV3.js";import"./chunk-VBZIIF5N.js";import"./chunk-LPUQ4HWQ.js";import"./chunk-NLCCBXXV.js";import"./chunk-VE3SUJMA.js";import"./chunk-Y6IUJZMV.js";import"./chunk-LOSNFBZV.js";import"./chunk-PF7PBYCJ.js";import"./chunk-WFSTRBQF.js";import"./chunk-S7JV4A3U.js";import"./chunk-RZ4F3BHX.js";import"./chunk-E47GFYXA.js";import"./chunk-7CBWZLRS.js";import"./chunk-UHGECBEN.js";import{a as o}from"./chunk-C6S4IEBC.js";import"./chunk-ELZIC2EH.js";import"./chunk-YB67GRWE.js";import"./chunk-GNJBT6SS.js";import"./chunk-3QWAABMG.js";import{a as t}from"./chunk-HCBYKLMW.js";import{c as n}from"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import{e as r}from"./chunk-UR6MHSHU.js";var e=r(t(),1);async function p(i){let c=i.scenarioLimit!==void 0||i.perScenarioLimit!==void 0?{scenarioLimit:i.scenarioLimit,perScenarioLimit:i.perScenarioLimit}:void 0,{waitUntilExit:m}=n((0,e.jsx)(o,{children:(0,e.jsx)(a,{initialChatMode:"generate",initialObjective:i.objective,initialGenerateLimits:c})}),{exitOnCtrlC:!1});await m()}export{p as runGenerate};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{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-AKKATURY.js";import"./chunk-34YRU7WM.js";import"./chunk-RCL22HDJ.js";import"./chunk-MDBXYXSC.js";import"./chunk-AH4AXJML.js";import"./chunk-H2P7UJAU.js";import"./chunk-FPFOW6BS.js";import"./chunk-WAOCHXJ5.js";import"./chunk-CZBHDBID.js";import"./chunk-LOIRZFV3.js";import"./chunk-NLCCBXXV.js";import"./chunk-Y6IUJZMV.js";import"./chunk-PF7PBYCJ.js";import"./chunk-WFSTRBQF.js";import"./chunk-S7JV4A3U.js";import"./chunk-RZ4F3BHX.js";import"./chunk-GNJBT6SS.js";import"./chunk-3QWAABMG.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{i as ExportError,c as assertOrgMatchOrExit,j as exportTestmd,b as metaMatchesOrg,a as readMetaIfExists,d as resolveCurrentOrgId,h as runDeleteAction,k as runExportAction,e as runListAction,f as runListTui,g as runStatusAction};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a}from"./chunk-Y6IUJZMV.js";import"./chunk-WFSTRBQF.js";import"./chunk-S7JV4A3U.js";import"./chunk-RZ4F3BHX.js";import"./chunk-3QWAABMG.js";import"./chunk-UR6MHSHU.js";export{a as refreshOAuthToken};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as t}from"./chunk-
|
|
2
|
+
import{a as t}from"./chunk-S7JV4A3U.js";import"./chunk-3QWAABMG.js";import"./chunk-UR6MHSHU.js";async function l(n,o,r){let{ControllerClient:e}=await import("./controller-client-RD2YEMAH.js");await new e(t(n).controllerBaseUrl,{username:o,accessKey:r}).getTmsCredentials()}export{l as validateBasicAuth};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b,c,d}from"./chunk-
|
|
2
|
+
import{a,b,c,d}from"./chunk-KPF3BPJ5.js";import"./chunk-RZ4F3BHX.js";import"./chunk-3QWAABMG.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.4.
|
|
3
|
+
"version": "0.4.2",
|
|
4
4
|
"description": "KaneAI Terminal UI — browser automation testing agent",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,15 +18,17 @@
|
|
|
18
18
|
"chalk": "^5.3.0",
|
|
19
19
|
"commander": "^12.0.0",
|
|
20
20
|
"ink": "^5.1.0",
|
|
21
|
+
"js-yaml": "^4.1.1",
|
|
21
22
|
"open": "^10.1.0",
|
|
22
23
|
"react": "^18.3.1",
|
|
23
|
-
"
|
|
24
|
+
"ws": "^8.20.0"
|
|
24
25
|
},
|
|
25
26
|
"optionalDependencies": {
|
|
26
|
-
"@testmuai/kane-cli-darwin-arm64": "0.4.
|
|
27
|
-
"@testmuai/kane-cli-darwin-x64": "0.4.
|
|
28
|
-
"@testmuai/kane-cli-linux-x64": "0.4.
|
|
29
|
-
"@testmuai/kane-cli-win-x64": "0.4.
|
|
27
|
+
"@testmuai/kane-cli-darwin-arm64": "0.4.2",
|
|
28
|
+
"@testmuai/kane-cli-darwin-x64": "0.4.2",
|
|
29
|
+
"@testmuai/kane-cli-linux-x64": "0.4.2",
|
|
30
|
+
"@testmuai/kane-cli-win-x64": "0.4.2",
|
|
31
|
+
"sharp": "^0.34.5"
|
|
30
32
|
},
|
|
31
33
|
"publishConfig": {
|
|
32
34
|
"registry": "https://registry.npmjs.org",
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a,b}from"./chunk-P7ZUISQG.js";import"./chunk-YCCUBQY4.js";import"./chunk-UHFCCGVX.js";import"./chunk-LPUQ4HWQ.js";import"./chunk-NLCCBXXV.js";import"./chunk-LAR7I5SR.js";import"./chunk-RZ4F3BHX.js";import"./chunk-JGXJDTMO.js";import"./chunk-IBDWHXNE.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{b as FolderPicker,a as formatFolderLine};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as f,b as i,t}from"./chunk-IBDWHXNE.js";import{a as T}from"./chunk-HCBYKLMW.js";import{a as n,b as o,j as p,k as x}from"./chunk-C44QQJR4.js";import{a as b}from"./chunk-6YGTRKDT.js";import{e as h}from"./chunk-UR6MHSHU.js";var w=h(b(),1);var e=h(T(),1),S="https://www.testmuai.com/support/docs/kane-cli-introduction",v="https://github.com/LambdaTest/kane-cli/issues";function k(){let{exit:l}=p(),{stdout:r}=x(),c=r?.columns??80;return(0,w.useEffect)(()=>{let m=setTimeout(()=>l(),50);return()=>clearTimeout(m)},[l]),(0,e.jsxs)(n,{flexDirection:"column",children:[(0,e.jsxs)(n,{paddingX:1,paddingTop:1,flexDirection:"column",children:[(0,e.jsx)(o,{color:t.orange,bold:!0,children:i}),(0,e.jsxs)(n,{children:[(0,e.jsx)(o,{color:t.dim,children:"Browser automation powered by AI "}),(0,e.jsxs)(o,{color:t.muted,children:[" v",f]})]})]}),(0,e.jsx)(o,{children:" "}),(0,e.jsxs)(d,{title:"USAGE",children:[(0,e.jsx)(g,{cmd:`${i}`,desc:"Single-shot prompt (no args, TTY)"}),(0,e.jsx)(g,{cmd:`${i} --tui`,desc:"Full interactive TUI",highlight:!0}),(0,e.jsx)(g,{cmd:`${i} run "<objective>"`,desc:"Inline objective"}),(0,e.jsx)(g,{cmd:`${i} testmd run <path>.md`,desc:"Replay a saved *_test.md file"})]}),(0,e.jsxs)(d,{title:"HELP",children:[(0,e.jsx)(g,{cmd:`${i} --help`,desc:"Show this help (long form)"}),(0,e.jsx)(g,{cmd:`${i} -h`,desc:"Show this help (short form)"}),(0,e.jsx)(g,{cmd:`${i} help`,desc:"Show this help (subcommand form)"}),(0,e.jsxs)(n,{marginLeft:2,marginTop:0,flexDirection:"column",children:[(0,e.jsxs)(o,{color:t.dim,children:["These are the only supported help invocations. Anything else (e.g. ",(0,e.jsx)(o,{color:t.orange,children:"-help"}),") is an unknown flag."]}),(0,e.jsxs)(o,{color:t.dim,children:["Terminal tab-completion is a shell feature; ",i," does not ship shell-completion scripts, so any flag your shell suggests is a generic guess \u2014 not from ",i,"."]})]})]}),(0,e.jsxs)(d,{title:"COMMANDS",children:[(0,e.jsx)(a,{cmd:"run",args:"<objective>",desc:"Run an objective (inline string)",highlight:!0}),(0,e.jsx)(a,{cmd:"testmd",args:"run|list|status|delete|export",desc:"Manage *_test.md files"}),(0,e.jsx)(a,{cmd:"login",desc:"Auth setup (interactive, --oauth, or --username)"}),(0,e.jsx)(a,{cmd:"logout",desc:"Revoke tokens + delete profile"}),(0,e.jsx)(a,{cmd:"whoami",desc:"Show authenticated identity"}),(0,e.jsx)(a,{cmd:"config",args:"show|set-\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.dim,children:[(0,e.jsx)(o,{color:t.orange,children:"*_test.md"})," \u2014 markdown test files with YAML frontmatter and ",(0,e.jsx)(o,{color:t.orange,children:"## "}),"step headings."]}),(0,e.jsxs)(o,{color:t.dim,children:["Run with ",(0,e.jsxs)(o,{color:t.orange,children:[i," testmd run path/to/foo_test.md"]}),". (`.md` paths are not accepted by `",i," run`.)"]}),(0,e.jsxs)(o,{color:t.dim,children:["Sessions you run in TUI auto-save to ",(0,e.jsx)(o,{color:t.orange,children:"<cwd>/.testmuai/tests/<name>_test.md"})," (testing mode prompts on exit)."]})]})}),(0,e.jsxs)(n,{flexDirection:"column",marginTop:0,paddingX:1,children:[(0,e.jsx)(o,{color:t.muted,children:"\u2500".repeat(Math.min(c-2,70))}),(0,e.jsxs)(n,{gap:3,children:[(0,e.jsxs)(n,{children:[(0,e.jsx)(o,{color:t.dim,children:"Docs "}),(0,e.jsx)(o,{color:t.orange,underline:!0,children:S})]}),(0,e.jsxs)(n,{children:[(0,e.jsx)(o,{color:t.dim,children:"Bugs "}),(0,e.jsx)(o,{color:t.orange,underline:!0,children:v})]})]})]}),(0,e.jsx)(o,{children:" "})]})}function d({title:l,children:r}){return(0,e.jsxs)(n,{flexDirection:"column",marginBottom:1,children:[(0,e.jsx)(n,{marginLeft:1,children:(0,e.jsx)(o,{bold:!0,color:t.dim,children:l})}),r]})}function g({cmd:l,desc:r,highlight:c}){return(0,e.jsxs)(n,{marginLeft:2,children:[(0,e.jsxs)(n,{width:40,children:[(0,e.jsx)(o,{color:t.dim,children:"$ "}),(0,e.jsx)(o,{color:c?t.orange:t.orange,children:l})]}),(0,e.jsx)(o,{color:t.dim,children:r})]})}function a({cmd:l,args:r,desc:c,highlight:m}){return(0,e.jsxs)(n,{marginLeft:2,children:[(0,e.jsx)(n,{width:16,children:(0,e.jsx)(o,{color:m?t.orange:t.green,bold:!0,children:l})}),(0,e.jsx)(n,{width:32,children:r?(0,e.jsx)(o,{color:t.dim,children:r}):null}),(0,e.jsx)(o,{color:t.dim,children:c})]})}function s({long:l,arg:r,desc:c,highlight:m}){return(0,e.jsxs)(n,{marginLeft:2,children:[(0,e.jsxs)(n,{width:30,children:[(0,e.jsx)(o,{color:m?t.orange:t.orange,children:l}),r&&(0,e.jsxs)(o,{color:t.dim,children:[" ",r]})]}),(0,e.jsx)(o,{color:t.dim,children:c})]})}function u({label:l,cmd:r}){return(0,e.jsxs)(n,{marginLeft:2,flexDirection:"column",children:[(0,e.jsxs)(o,{color:t.dim,children:["# ",l]}),(0,e.jsxs)(o,{color:t.orange,children:["$ ",r]})]})}export{k as HelpView};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a}from"./chunk-7I2SQ2KP.js";import"./chunk-Z7AXAKPX.js";import"./chunk-AGS57DSG.js";import"./chunk-L5LI2JF4.js";import"./chunk-YSSBAIJI.js";import"./chunk-FPFOW6BS.js";import"./chunk-WAOCHXJ5.js";import"./chunk-KJEJ7VW5.js";import"./chunk-P7ZUISQG.js";import"./chunk-YCCUBQY4.js";import"./chunk-UHFCCGVX.js";import"./chunk-LOIRZFV3.js";import"./chunk-LPUQ4HWQ.js";import"./chunk-NLCCBXXV.js";import"./chunk-VE3SUJMA.js";import"./chunk-T46Z27UL.js";import"./chunk-OIPVMEM7.js";import"./chunk-LAR7I5SR.js";import"./chunk-RZ4F3BHX.js";import"./chunk-JGXJDTMO.js";import"./chunk-IBDWHXNE.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{a as SingleShotApp};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{h as a}from"./chunk-JJERCR2W.js";import"./chunk-H4XK55B3.js";import"./chunk-7NDFOI6Z.js";import"./chunk-LOIRZFV3.js";import"./chunk-LAR7I5SR.js";import"./chunk-UYHNJUPY.js";import"./chunk-HUOC7DUT.js";import"./chunk-C6S4IEBC.js";import"./chunk-IBDWHXNE.js";import"./chunk-HCBYKLMW.js";import"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-UR6MHSHU.js";export{a as TestMdRunView};
|
package/dist/chunk-45VTQLJS.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as R}from"./chunk-AGS57DSG.js";import{b as z}from"./chunk-H4XK55B3.js";import{a as q}from"./chunk-NLCCBXXV.js";function O(e){return["completed","failed","ended","stopped"].includes(e.trim().toLowerCase())}function ue(e){return["ended","stopped"].includes(e.trim().toLowerCase())}function D(e){return{requestId:e.requestId,objective:e.objective,status:"",turnActive:!1,scenarios:[],thinking:"",thinkingLog:[],chatLog:[],progress:0}}function de(e){return e.pendingClarification===void 0?e:{...e,pendingClarification:void 0}}function le(e){return{...e,turnActive:!0,error:void 0,thinking:"",thinkingLog:[]}}function A(e,t){switch(t.type){case"thinking":return{...e,status:"thinking",thinking:e.thinking+t.delta};case"thinking_done":return{...e,thinkingLog:[...e.thinkingLog,{text:e.thinking,tookMs:t.tookMs}],thinking:""};case"progress":return{...e,progress:t.pct};case"snapshot":return{...e,scenarios:t.data.scenarios,status:t.data.status,headline:t.data.headline??e.headline};case"chat":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}]};case"clarification":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}],pendingClarification:t.text};case"limit":return{...e,limits:{scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit}};case"error":return{...e,error:t.message};case"done":return{...e,status:t.status,turnActive:!1,error:t.status==="failed"&&!e.error?"generation failed":e.error}}}function N(e,t){let n=[],i=e.type??"",p=e.status??"";if(i==="ping")return n;switch(i){case"thinking_token":typeof e.data=="string"&&n.push({type:"thinking",delta:e.data});break;case"thinking_stopped":{let s=e.data??{},u=Q(s.time_taken);n.push({type:"thinking_done",text:typeof e.data=="string"?e.data:s.message??"",tookMs:u});break}case"progress":{let s=e.data??{};typeof s.progress=="number"&&n.push({type:"progress",pct:s.progress});break}case"clarification":{let s=e.data??{};typeof s.message=="string"&&n.push({type:"clarification",text:s.message});break}case"chatting_stopped":{let s=e.data??{};typeof s.message=="string"&&s.message.length>0&&n.push({type:"chat",text:s.message});break}case"limit_update":{let s=e.data??{},u=s.test_cases_limit??e.test_cases_limit,f=s.per_scenario_test_cases_limit??e.per_scenario_test_cases_limit;n.push({type:"limit",scenarioLimit:u,perScenarioLimit:f});break}case"error":{let s=typeof e.data=="string"?e.data:e.data?.message??"generation error";n.push({type:"error",message:s});break}case"request_cancelled":return n.push({type:"done",status:"stopped"}),n;case"session_ended":return n.push({type:"done",status:"ended"}),n;default:break}if(Array.isArray(e.scenarios)&&n.push({type:"snapshot",data:{requestId:t,status:p,headline:e.headline,scenarios:e.scenarios}}),p&&O(p)){let s=p.trim().toLowerCase();n.push({type:"done",status:s})}return n}function Q(e){if(!e)return;let t=/^([\d.]+)(ms|s)?$/.exec(e.trim());if(!t)return;let n=Number(t[1]);if(Number.isFinite(n))return t[2]==="ms"?Math.round(n):Math.round(n*1e3)}var E=class extends Error{constructor(t){super(t),this.name="AuthError"}},M=class extends Error{constructor(t){super(t),this.name="ForbiddenError"}},F=class extends Error{constructor(t){super(t),this.name="InsufficientCreditsError"}},k=class extends Error{constructor(n,i){super(n);this.cause=i;this.name="TransportError"}};function v(e,t){let n=t?.message??t?.error??`HTTP ${e}`;return e===401?new E(n):e===403?t?.key==="insufficient_credits"?new F(n):new M(n):new k(n)}async function*H(e){let t=e.fetchImpl??fetch,n=e.maxRetries??5,i=e.maxBackoffMs??3e4,p=e.connectTimeoutMs??1e4,s=0,u=!1;for(;;){if(e.signal.aborted)return;let f=new AbortController,d=()=>f.abort();e.signal.addEventListener("abort",d,{once:!0});let g=setTimeout(()=>f.abort(),p),b;try{b=await t(e.url,{method:"GET",headers:{Authorization:await e.authHeader(),Accept:"text/event-stream"},signal:f.signal})}catch(m){if(clearTimeout(g),e.signal.removeEventListener("abort",d),e.signal.aborted)return;if(++s>n)throw new k("SSE connect failed",m);await B(I(s,i));continue}if(clearTimeout(g),!b.ok){e.signal.removeEventListener("abort",d);let m=await Y(b);if(b.status===401&&u){if(++s>n)throw v(401,m);await B(I(s,i));continue}throw v(b.status,m)}if(!b.body)throw e.signal.removeEventListener("abort",d),new k("SSE response had no body");u=!0,s=0;let w=b.body.getReader(),h=new TextDecoder("utf-8"),y="";try{for(;;){if(e.signal.aborted){await w.cancel().catch(()=>{});return}let{done:m,value:r}=await w.read();if(m)break;y+=h.decode(r,{stream:!0});let a;for(;(a=y.indexOf(`
|
|
3
|
-
|
|
4
|
-
`))>=0;){let o=y.slice(0,a);y=y.slice(a+2);let c=V(o);c&&(yield c)}}}catch(m){if(e.signal.aborted)return;if(++s>n)throw new k("SSE stream dropped",m);await B(I(s,i));continue}finally{e.signal.removeEventListener("abort",d)}return}}function V(e){let t="message",n="";for(let i of e.split(`
|
|
5
|
-
`))i.startsWith("event:")?t=i.slice(6).trim():i.startsWith("data:")&&(n+=i.slice(5).trim());if(t!=="message"||!n)return null;try{let i=Buffer.from(n,"base64").toString("utf-8");return JSON.parse(i)}catch{return null}}function I(e,t){return Math.min(t,1e3*2**(e-1))}function B(e){return new Promise(t=>setTimeout(t,e))}async function Y(e){try{return await e.clone().json()}catch{return}}function ke(e,t={}){let n=t.fetchImpl??fetch,i=new Map,p=!0;async function s(){let r=await e.authResolver.resolve();if(!r)throw new E("unauthorized; run `kane-cli login`");return q(r.username,r.access_key)}function u(r){return`${e.baseUrl}${r}`}async function f(r){if(!r.ok){let a;try{a=await r.clone().json()}catch{a=void 0}throw v(r.status,a)}return r.json()}function d(r){let a=r?.data??r;return{request_id:a.request_id??a.id,status:a.status??""}}function g(r,a,o,c){let l=D({requestId:r,objective:a});c&&(l=A(l,{type:"snapshot",data:c}),c.status==="cleaned_up"&&(l={...l,error:"session was reaped (cleaned_up) \u2014 continuing will destructively regenerate"}));let S=new AbortController;o&&(o.aborted?S.abort():o.addEventListener("abort",()=>S.abort(),{once:!0})),i.set(r,S);let x={requestId:r,state:l,events:void 0};return x.events=(async function*(){try{let C=H({url:u(`/requests/${r}/sse`),authHeader:s,signal:S.signal,log:e.log,fetchImpl:n});for await(let L of C)for(let $ of N(L,r))x.state=A(x.state,$),yield $}finally{i.delete(r)}})(),x}async function b(r,a){let o=new FormData;o.append("prompt",r.prompt),p=r.memoryEnhancement??!0,o.append("memory_enhancement",String(p)),r.scenarioLimit!==void 0&&o.append("test_scenario_limit",String(r.scenarioLimit)),r.perScenarioLimit!==void 0&&o.append("per_scenario_test_cases_limit",String(r.perScenarioLimit));let c=r.projectId??e.projectId,l=r.folderId??e.folderId;c&&o.append("project_id",c),l&&o.append("folder_id",l);let S=await n(u("/requests"),{method:"POST",headers:{Authorization:await s()},body:o}),x=await f(S),{request_id:C}=d(x),L=String(C);return g(L,r.prompt,a)}async function w(r,a){let o=await n(u(`/requests/${r}`),{method:"GET",headers:{Authorization:await s()}}),c=await f(o),l=c?.data??c,S={requestId:r,status:l.status??"",headline:l.headline,scenarios:Array.isArray(l.scenarios)?l.scenarios:[]};return g(r,"",a,S)}async function h(r,a,o){let c=new FormData;c.append("prompt",a),c.append("chat_enabled","true"),c.append("memory_enhancement",String(p)),o&&c.append("mappings",JSON.stringify(o));let l=await n(u(`/requests/${r}`),{method:"PUT",headers:{Authorization:await s()},body:c});if(!l.ok){let S;try{S=await l.clone().json()}catch{}throw v(l.status,S)}}async function y(r){i.get(r)?.abort();let o=await n(u(`/requests/${r}/stop`),{method:"DELETE",headers:{Authorization:await s()}});if(!o.ok&&o.status!==404){let c;try{c=await o.clone().json()}catch{}throw v(o.status,c)}}async function m(r){i.get(r)?.abort();let o=await n(u(`/requests/${r}/end`),{method:"DELETE",headers:{Authorization:await s()}});if(!o.ok&&o.status!==404){let c;try{c=await o.clone().json()}catch{}throw v(o.status,c)}}return{start:b,attach:w,chat:h,cancel:y,end:m}}function j(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(n==null||typeof n!="object")return[];let i=n;if(typeof i.step!="string")return[];let p=typeof i.expected_result=="string"?i.expected_result:typeof i.outcome=="string"?i.outcome:"";t.push({step:i.step,expected:p})}return t}var ee=30,te=300;function J(){return{mode:"testing",max_steps:ee,timeout:te,variables:{}}}function U(e){return e.title??`Test case ${e.id}`}function Ce(e,t){return R({frontmatter:J(),heading:U(t),steps:e.sub_objectives.map(n=>n.objective)})}function G(e){let t=j(e.manual_steps).map(n=>n.step);return R({frontmatter:J(),heading:U(e),steps:t})}import{mkdtempSync as ne,mkdirSync as P,writeFileSync as W,rmSync as X,renameSync as re,existsSync as Z,readFileSync as se}from"fs";import{join as _,resolve as ie}from"path";async function Fe(e,t,n,i=G){(n.redirectBareCwd??!0)&&ie(t)===process.cwd()&&(t=_(t,".testmuai","tests"));let p=T(e.objective)??e.headline,s=T(n.suiteName)??`${T(K(p,4))??"tcg"}-${e.requestId}`,u=s,f=_(t,s);Z(f)&&!ae(f,e.requestId)&&(u=`${s}-${e.requestId}`);let d=_(t,u),g=[],b=new Map;for(let h of e.scenarios){let y=(h.test_cases??[]).filter(oe);if(y.length===0)continue;let m=T(ce(h.scode))??T(h.sid)??`s${h.id}`,r=b.get(m)??new Set;b.set(m,r);for(let a of y){let o=T(K(a.title,5))??"case",c=`${o}_test.md`;for(let l=2;r.has(c);l++)c=`${o}-${l}_test.md`;r.add(c),g.push({dir:m,file:c,tc:a})}}if(g.length===0)return{suiteDir:d,paths:[],warning:"no functional test cases generated"};P(t,{recursive:!0});let w=ne(_(t,".tcg-tmp-"));try{P(_(w,"helpers"),{recursive:!0}),W(_(w,".tcg-suite.json"),JSON.stringify({requestId:e.requestId,suiteName:u}));let h=[],y=new Set;for(let r of g){let a=_(w,r.dir);y.has(a)||(P(a,{recursive:!0}),y.add(a));let o=_(a,r.file);W(o,i(r.tc)),h.push(o)}Z(d)&&X(d,{recursive:!0,force:!0}),re(w,d);let m=h.map(r=>r.replace(w,d));return{suiteDir:d,paths:m}}catch(h){try{X(w,{recursive:!0,force:!0})}catch{}throw h}}function oe(e){return(e.category??"").trim().toLowerCase()==="functional"}function ae(e,t){try{return JSON.parse(se(_(e,".tcg-suite.json"),"utf-8"))?.requestId===t}catch{return!1}}function T(e){return e&&e.length>0?e:void 0}function K(e,t){return e?e.toLowerCase().replace(/[^a-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean).slice(0,t).join("-"):""}function ce(e){return e?e.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,""):""}function Pe(e){let t=[];e.title&&t.push(e.title),e.description&&t.push("",e.description);let n=j(e.manual_steps);return n.length>0&&(t.push("","Steps:"),n.forEach((i,p)=>{t.push(`${p+1}. ${i.step}`)})),t.join(`
|
|
6
|
-
`).trim()}function ze(e){return{mode:"bifurcate",objective:e.objective,model:e.model,session_id:e.sessionId,run_index:0,width:0,height:0,stream:!0,variables:e.variables,...e.auth}}async function Oe(e,t,n){let i=z(e,t),p=()=>i.cancel();n?.addEventListener("abort",p);let s=null,u=null;try{for await(let f of i.events)if(f.type==="bifurcation_result"){let d=f,g=d.sub_objectives??[];s={sub_objectives:g,extracted_variables:d.extracted_variables??{},total_flows:d.total_flows??g.length,is_single_flow:d.is_single_flow??g.length<=1,credits_consumed:d.credits_consumed??0}}else f.type==="error"&&(u=f.message??"bifurcation error")}finally{n?.removeEventListener("abort",p),i.cancel()}if(s)return s;throw new Error(u??"bifurcation produced no result")}export{O as a,ue as b,D as c,de as d,le as e,A as f,E as g,ke as h,j as i,Ce as j,G as k,Fe as l,oe as m,Pe as n,ze as o,Oe as p};
|
package/dist/chunk-FGC74Z76.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as m}from"./chunk-JGXJDTMO.js";import{t}from"./chunk-IBDWHXNE.js";import{a as p}from"./chunk-HCBYKLMW.js";import{a,b as r,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 R({onSubmit:l}){let[o,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(o===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)(r,{color:t.secondary,children:"Rate this session: "}),(0,e.jsx)(r,{color:o===0?t.orange:t.dim,children:o===0?"[ \u{1F44D} ]":" \u{1F44D} "}),(0,e.jsx)(r,{children:" "}),(0,e.jsx)(r,{color:o===1?t.orange:t.dim,children:o===1?"[ \u{1F44E} ]":" \u{1F44E} "})]}),(0,e.jsx)(m,{bindings:[{keys:"\u2190/\u2192",label:"select"},{keys:"\u21B5",label:"submit"}],escBackLabel:"skip"})]})}export{R as a};
|
package/dist/chunk-G6AXOEED.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as f}from"./chunk-7NDFOI6Z.js";import{t}from"./chunk-IBDWHXNE.js";import{a as x}from"./chunk-HCBYKLMW.js";import{a as r,b as n}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as p}from"./chunk-UR6MHSHU.js";var c=p(B(),1);var e=p(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,c.useState)(0),a=c.default.useRef(Date.now());return(0,c.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.orange,children:"\u2601 "}),(0,e.jsx)(n,{color:t.orange,bold:!0,children:"Saving to KaneAI"}),(0,e.jsxs)(n,{color:t.dim,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",u=i.status==="done",m=i.status==="running",g=i.status==="failed";return(0,e.jsxs)(r,{children:[(0,e.jsxs)(n,{color:t.dim,children:[" ",b," "]}),(0,e.jsx)(r,{width:3,children:m?(0,e.jsx)(f,{}):u?(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:u?t.dim:m?void 0:g?t.red:t.muted,children:i.label}),i.detail&&(0,e.jsxs)(n,{color:t.dim,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.dim,children:" "}),(0,e.jsx)(n,{color:t.dim,children:a})]})]})}export{v as a,U as b,h as c};
|
package/dist/chunk-H4XK55B3.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as v}from"./chunk-LAR7I5SR.js";import{spawn as x,execSync as b}from"child_process";import{existsSync as g}from"fs";import{resolve as e,dirname as N}from"path";import{fileURLToPath as h}from"url";import{createInterface as R}from"readline";async function*_(i){let n=R({input:i,crlfDelay:1/0});for await(let l of n){let r=l.trim();if(r)try{let d=JSON.parse(r);d&&typeof d.type=="string"&&(yield d)}catch{}}}function E(i){return i==="action"?{set:{V16_AGENT_ENABLE_ALL_BLOCKERS:"true",V16_AGENT_SKIP_CP_FINAL:"true"},unset:[]}:{set:{},unset:["V16_AGENT_ENABLE_ALL_BLOCKERS","V16_AGENT_SKIP_CP_FINAL"]}}var c=N(h(import.meta.url));function A(){for(let i of["python3","python"])try{return b(`${i} --version`,{stdio:"ignore"}),i}catch{}return null}function C(){let n=process.platform==="win32"?"v16-runner.exe":"v16-runner",l={"darwin-arm64":["@testmuai/kane-cli-darwin-arm64","@lambdatestincprivate/kane-cli-darwin-arm64"],"darwin-x64":["@testmuai/kane-cli-darwin-x64","@lambdatestincprivate/kane-cli-darwin-x64"],"linux-x64":["@testmuai/kane-cli-linux-x64","@lambdatestincprivate/kane-cli-linux-x64"],"win32-x64":["@testmuai/kane-cli-win-x64","@lambdatestincprivate/kane-cli-win-x64"]},r=`${process.platform}-${process.arch}`,d=l[r];if(d)for(let t of d){let a=[e(c,"..","node_modules",t,"bin",n),e(c,"..","..","node_modules",t,"bin",n),e(c,"..","..","..","node_modules",t,"bin",n),e(c,"..","..","..","..","node_modules",t,"bin",n)];for(let u of a)if(g(u))return{cmd:u,args:[]}}let p=[e(c,"bin",n),e(c,"..","bin",n),e(c,"..","..","..","..","v16-runner","dist",n),e(c,"..","..","..","v16-runner","dist",n),e(process.cwd(),"v16-runner","dist",n),e(process.cwd(),"..","v16-runner","dist",n)];for(let t of p)if(g(t))return{cmd:t,args:[]};let s=[e(c,"..","..","..","..","v16-runner"),e(c,"..","..","..","v16-runner"),e(process.cwd(),"v16-runner"),e(process.cwd(),"..","v16-runner")];for(let t of s)if(g(e(t,"main.py"))){for(let u of[e(t,".venv","bin","python"),e(t,"..","browser-agent",".venv","bin","python")])if(g(u))return{cmd:u,args:["main.py"],cwd:t};let a=A();if(a)return{cmd:a,args:["main.py"],cwd:t}}return null}function V(i,n){let l=C();if(!l)throw new Error("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available.");let r={...process.env};n?.environment&&(r.TESTMUAI_ENV=n.environment),r.TESTMUAI_SOURCE="kane-cli",process.platform==="win32"&&(r.PYTHONIOENCODING="utf-8");let d=v(n?.environment);r.V16_SERVER_API_HOST=d.v16ServerHost,r.ATMS_URL=d.tmsBaseUrl.replace(/\/api\/?$/,""),i.username&&i.access_key&&(r.LT_USERNAME=i.username,r.LT_ACCESS_KEY=i.access_key),i.session_id&&(r.TESTMUAI_SESSION_ID=i.session_id);let p=E(n?.mode??"testing");Object.assign(r,p.set);for(let o of p.unset)delete r[o];let s=x(l.cmd,l.args,{stdio:["pipe","pipe","pipe"],env:r,cwd:l.cwd});s.stdin.on("error",()=>{}),s.stdin.write(JSON.stringify(i)+`
|
|
3
|
-
`);let t=1e5,a="";s.stderr.on("data",o=>{a+=o.toString(),a.length>t&&(a=a.slice(-t))}),s.on("error",o=>{n?.log?.("error","RUNNER_SPAWN_ERROR","Runner spawn error",{error:o.message})});let u=null,f=null,S=new Promise(o=>{s.on("close",(m,y)=>{u=m,f=y?String(y):null,n?.log?.("info","RUNNER_EXIT","Runner exited",{code:m,signal:f??"none"}),o({code:m,signal:f})})}),w=_(s.stdout);return{child:s,events:w,sendUserResponse(o){let m=JSON.stringify({type:"user_response",answer:o});try{s.stdin.write(m+`
|
|
4
|
-
`)}catch{}},sendCancel(o){let m=JSON.stringify({type:"cancel",reason:o});try{s.stdin.write(m+`
|
|
5
|
-
`)}catch{}},cancel(){s.kill("SIGTERM")},get stderr(){return a},get exitCode(){return u},get exitSignal(){return f},exited:S}}export{C as a,V as b};
|
package/dist/chunk-IBDWHXNE.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.4.1",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",g="https://dd-proxy.lambdatest.com/intake/kane-cli",U="https://kaneai-playground.lambdatest.io",b=9222,_=9230,u=t(e,"chrome-profiles"),r="127.0.0.1",x=18392,A=18400,o="/callback";function R(a){return`http://${r}:${a}${o}`}var L="KANE CLI",B="*",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",testGeneratorBaseUrl:"https://test-manager-api.lambdatest.com",secretsBaseUrl:"https://api-hyperexecute.lambdatest.com",testManagerUiUrl:"https://test-manager.lambdatest.com",shareApiBaseUrl:"https://api.lambdatest.com",v16ServerHost:"https://kaneai-api.lambdatest.com/v16-server"},stage:{authBaseUrl:"https://stage-auth.lambdatestinternal.com",consentUrl:"https://stage-accounts.lambdatestinternal.com",controllerBaseUrl:"https://auteur-stage-automind.lambdatestinternal.com/v16-controller/v1",tmsBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com/api",testGeneratorBaseUrl:"https://stage-test-manager-api.lambdatestinternal.com",secretsBaseUrl:"https://api-stage-hyperexecute.lambdatestinternal.com",testManagerUiUrl:"https://stage-test-manager.lambdatestinternal.com",shareApiBaseUrl:"https://stage-api.lambdatestinternal.com",v16ServerHost:"https://auteur-stage-automind.lambdatestinternal.com/v16-server"}},E={orange:"#ff9500",generateAccent:"#0d9488",purple:"#b388ff",secondary:"#888888",dim:"#666666",muted:"#444444",green:"#4ade80",red:"#ef4444"};export{c as a,l as b,e as c,i as d,d as e,h as f,g,U as h,b as i,_ as j,u as k,r as l,x as m,A as n,o,R as p,L as q,B as r,C as s,E as t};
|
package/dist/chunk-JJERCR2W.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as je}from"./chunk-H4XK55B3.js";import{a as de,b as $e}from"./chunk-7NDFOI6Z.js";import{d as Pe,f as pe}from"./chunk-LOIRZFV3.js";import{a as Ce}from"./chunk-UYHNJUPY.js";import{a as Ie}from"./chunk-HUOC7DUT.js";import{b as _e}from"./chunk-C6S4IEBC.js";import{t as i}from"./chunk-IBDWHXNE.js";import{a as M}from"./chunk-HCBYKLMW.js";import{a as l,b as r,i as Ee,j as ke,k as me}from"./chunk-C44QQJR4.js";import{a as le}from"./chunk-6YGTRKDT.js";import{e as $}from"./chunk-UR6MHSHU.js";var Q=$(le(),1);var A=$(le(),1);var L=$(le(),1);function Se(e){let t=e.indexOf(": ");return t>0&&t<15?e.slice(t+2):e}function ve(e){return e.map(t=>{let s=t.children?ve(t.children):t.children;return t.status==="running"?{...t,status:"stopped",phase:void 0,children:s}:s!==t.children?{...t,children:s}:t})}function Oe(e,t,s,a){let[h,u]=(0,L.useState)(!1),[d,c]=(0,L.useState)([]),[D,C]=(0,L.useState)(null),[k,_]=(0,L.useState)(null),[N,f]=(0,L.useState)(null),[m,y]=(0,L.useState)(null),[P,z]=(0,L.useState)([]),[q,Z]=(0,L.useState)(null),[se,fe]=(0,L.useState)(void 0),U=(0,L.useRef)(null),G=(0,L.useRef)(null),Y=(0,L.useRef)(0),J=(0,L.useRef)(!1),p=(0,L.useCallback)(async(B,ae)=>{let we=U.current;if(we){try{await we.exited}catch{}U.current=null}c([]),C(null),_(null),f(null),y(null),z([]),Z(null),fe(B.max_steps),u(!0),G.current=null,Y.current=0;let W;try{W=je(B,ae)}catch(oe){f(oe instanceof Error?oe.message:String(oe)),u(!1);return}U.current=W,Pe("runner",()=>W.cancel()),(async()=>{J.current=!1;let oe=!1;for await(let n of W.events){if(J.current)break;switch(n.type){case"run_start":if(G.current&&!G.current.isSingleFlow){let w=Y.current;Y.current++,c(E=>E.map((R,T)=>T===w?{...R,status:"running"}:R.status==="running"&&!R.children?.some(x=>x.status==="running")?{...R,status:R.children?.some(x=>x.status==="failed")?"failed":"passed"}:R))}break;case"bifurcation":{let w=n.flows??[],E=n.count??w.length,R={flows:w,isSingleFlow:n.is_single_flow??E<=1};y(R),G.current=R,Y.current=0,c(w.map((T,x)=>({index:x+1,objective:T??`Flow ${x+1}`,status:"pending"})));break}case"step_start":{t?.("STEP_START",`Step ${n.index} started`,{index:n.index,objective:n.objective,child_id:n.child_id});let w=n.index,E=n.objective??`Step ${w}`,R=n.child_id,T=G.current&&!G.current.isSingleFlow;if(R)c(x=>{let v=x.findIndex(ee=>ee.status==="running"||ee.children?.some(ze=>ze.status==="running"));if(v===-1)return x;let j=[...x],O={...j[v]},re=[...O.children??[]].map(ee=>ee.status==="running"?{...ee,status:"stopped",phase:void 0}:ee);return re.push({index:w,objective:E,status:"running"}),O.children=re,j[v]=O,j});else if(T){let x=Math.max(0,Y.current-1);c(v=>{let j=[...v];if(x>=j.length)return v;let O={...j[x]},re=[...O.children??[]].map(ee=>ee.status==="running"?{...ee,status:"stopped",phase:void 0}:ee);return re.push({index:w,objective:E,status:"running"}),O.children=re,O.status="running",j[x]=O,j})}else c(x=>{let v=ve(x);return v.some(O=>O.index===w)?v.map(O=>O.index===w?{...O,status:"running",objective:E}:O):[...v,{index:w,objective:E,status:"running"}]});break}case"step_event":{t?.("STEP_EVENT",`Step ${n.index} ${n.event}`,{index:n.index,phase:n.event,action_type:n.action_type,detail:n.detail,child_id:n.child_id});let w=n.child_id,E=G.current&&!G.current.isSingleFlow;if(n.event==="cm_init"&&n.checkpoint_count!=null){z(R=>[...R,n.checkpoint_count]);break}if(n.event==="replay_started"){Z({recordingLength:n.recording_length??0});break}if(n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&s?.(n.detail),w)c(R=>R.map(T=>{if(!T.children)return T;let x=T.children.map(v=>{if(v.index!==n.index)return v;let j={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(j.objective=n.detail),n.action_type&&(j.actionType=n.action_type),{...v,...j}});return{...T,children:x}}));else if(E){let R=Math.max(0,Y.current-1);c(T=>{let x=[...T];if(R>=x.length)return T;let v={...x[R]},j=[...v.children??[]];if(!j.some(te=>te.index===n.index))j.push({index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type});else for(let te=0;te<j.length;te++){if(j[te].index!==n.index)continue;let re={phase:n.event};n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(re.objective=n.detail),n.action_type&&(re.actionType=n.action_type),j[te]={...j[te],...re}}return v.children=j,x[R]=v,x})}else c(R=>R.some(x=>x.index===n.index)?R.map(x=>{if(x.index!==n.index)return x;let v={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(v.objective=n.detail),n.action_type&&(v.actionType=n.action_type),{...x,...v}}):[...ve(R),{index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type}]);break}case"step_end":{t?.("STEP_END",`Step ${n.index} ${n.status}`,{index:n.index,status:n.status,duration:n.duration,summary:n.summary,child_id:n.child_id}),a?.();let w=n.child_id,E=G.current&&!G.current.isSingleFlow;if(w)c(R=>R.map(T=>{if(!T.children)return T;let x=T.children.map(v=>v.index===n.index?{...v,status:n.status,duration:n.duration,phase:void 0,objective:v.objective.startsWith("Step ")?Se(n.summary||v.objective):v.objective}:v);return{...T,children:x}}));else if(E){let R=Math.max(0,Y.current-1);c(T=>{let x=[...T];if(R>=x.length)return T;let v={...x[R]},j=(v.children??[]).map(O=>O.index===n.index?{...O,status:n.status,duration:n.duration,phase:void 0,objective:O.objective.startsWith("Step ")?Se(n.summary||O.objective):O.objective}:O);return v.children=j,x[R]=v,x})}else c(R=>R.map(T=>T.index===n.index?{...T,status:n.status,duration:n.duration,phase:void 0,objective:T.objective.startsWith("Step ")?Se(n.summary||T.objective):T.objective}:T));{let T=G.current&&!G.current.isSingleFlow?Math.max(0,Y.current-1):0;e?.(n.index,T,n.child_id)}break}case"child_agent_start":{let w=n.objective??"";c(E=>E.map(R=>R.status==="running"?{...R,objective:`${w} (branch)`,phase:`child: ${w.slice(0,50)}`,branchObjective:w}:R));break}case"child_agent_end":c(w=>w.map(E=>E.phase?.startsWith("child:")?{...E,phase:`child ${n.success?"done":"failed"}`}:E));break;case"ask_user":C(n.question??"");break;case"run_end":c(w=>w.map(E=>E.status==="running"?{...E,status:n.status,phase:void 0}:E)),u(!1),_(n),oe=!0;break;case"error":u(!1),f(n.message??"Runner error"),c(w=>w.map(E=>E.status==="running"?{...E,status:"failed",phase:void 0}:E));break}}let{code:ne,signal:Re}=await W.exited,be=W.stderr,Ve=ne===0&&!Re,ue=[];ne!==null&&ne!==0&&ue.push(`Runner exited with code ${ne}`),Re&&ue.push(`Runner killed by signal ${Re}`),be&&(!Ve||!oe?ue.push(be):ae?.log?.("debug","RUNNER_STDERR_BENIGN","Runner stderr on clean exit",{stderr:be})),U.current===W&&(ue.length>0&&f(ue.join(`
|
|
3
|
-
`)),u(!1),pe("runner","Event stream ended"),U.current=null)})().catch(oe=>{let ne=[`Runner event loop error: ${oe}`];W.exitCode!==null&&W.exitCode!==0&&ne.push(`Exit code: ${W.exitCode}`),W.exitSignal&&ne.push(`Signal: ${W.exitSignal}`),W.stderr&&ne.push(W.stderr),U.current===W&&(f(ne.join(`
|
|
4
|
-
`)),u(!1),pe("runner","Event loop error"),U.current=null)})},[e,t,s,a]),b=(0,L.useCallback)(B=>{U.current?.sendUserResponse(B),C(null)},[]),S=(0,L.useCallback)(()=>{let B=U.current;B&&(B.sendCancel("user"),u(!1),C(null),setTimeout(()=>{U.current===B&&(pe("runner","User cancelled run"),U.current=null)},5e3))},[]),g=(0,L.useCallback)(()=>{c([]),_(null),f(null)},[]);return(0,L.useEffect)(()=>()=>{J.current=!0,pe("runner","Component unmounted"),U.current=null},[]),{isRunning:h,steps:d,askingUser:D,lastRunEnd:k,runError:N,bifurcationInfo:m,cmInitCounts:P,replayInfo:q,maxSteps:se,startRun:p,sendAnswer:b,cancelRun:S,clearLastRun:g}}function ye(e){let t=e.flatMap(u=>[u,...u.children??[]]),s=t.filter(u=>u.status==="passed").length,a=t.filter(u=>u.status==="failed").length,h=t.filter(u=>u.status==="passed"||u.status==="failed").length;return{passed:s,failed:a,total:h}}function Le(e){let t=Oe(e.screenshotDispatcher,e.stepLogger,e.onReasoning,e.onStepComplete),[s,a]=(0,A.useState)(0),[h,u]=(0,A.useState)("idle"),d=(0,A.useRef)("idle"),c=(0,A.useRef)(0),D=(0,A.useRef)(!1),C=(0,A.useRef)(null),k=(0,A.useRef)(null),_=(0,A.useCallback)(m=>{d.current=m,u(m)},[]),N=(0,A.useCallback)(async m=>{let y=await e.getNextConfig(m);if(!y){_("done"),e.onAllComplete?.();return}let P=m?c.current+1:0;c.current=P,a(P),e.onStepStart?.(y,P),C.current=null,k.current=null,_("running"),await t.startRun(y,e.spawnOpts)},[t,e,_]);(0,A.useEffect)(()=>{D.current||(D.current=!0,N(null))},[]),(0,A.useEffect)(()=>{if(!t.lastRunEnd||t.lastRunEnd===C.current||d.current!=="running")return;C.current=t.lastRunEnd,d.current="transitioning",u("transitioning");let m=t.lastRunEnd,y=ye(t.steps),P=t.bifurcationInfo,z={status:m.status==="passed"?"passed":"failed",duration_s:m.duration??0,reason:m.reason,runEnd:m,hadError:!1,stepsPassed:y.passed,stepsFailed:y.failed,stepsTotal:y.total,bifurcationFlows:P&&!P.isSingleFlow?P.flows:null};if(!(e.onStepEnd?.(z,c.current)??!0)){_("done"),e.onAllComplete?.();return}N(z)},[t.lastRunEnd]),(0,A.useEffect)(()=>{if(!t.runError||t.runError===k.current||t.lastRunEnd||d.current!=="running")return;k.current=t.runError,d.current="transitioning",u("transitioning");let m=ye(t.steps),y={status:"failed",duration_s:0,reason:t.runError,runEnd:null,hadError:!0,stepsPassed:m.passed,stepsFailed:m.failed,stepsTotal:m.total,bifurcationFlows:null};if(!(e.onStepEnd?.(y,c.current)??!0)){_("done"),e.onAllComplete?.();return}N(y)},[t.runError,t.lastRunEnd]);let f=(0,A.useCallback)(()=>{t.cancelRun()},[t]);return{runner:t,currentStepIndex:s,phase:h,cancel:f}}var Te=$(le(),1);var ge=$(M(),1),De=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function Fe({label:e,hasBifurcation:t=!1}){let[s,a]=(0,Te.useState)(0),[h,u]=(0,Te.useState)(0);de(()=>{a(c=>(c+1)%De.length)},80),de(()=>{u(c=>(c+1)%4)},400);let d=e??(t?"Planning approach":"Analyzing objective");return(0,ge.jsxs)(l,{marginLeft:1,children:[(0,ge.jsxs)(r,{color:i.orange,children:[De[s]," "]}),(0,ge.jsxs)(r,{color:i.dim,children:[d,".".repeat(h+1)]})]})}function Me(e){if(!e.isRunning||e.replayInfo)return null;let t=e.bifurcationInfo;if(t&&!t.isSingleFlow){let s=e.steps.findIndex(h=>h.status==="running");return(s===-1?e.cmInitCounts.length===0:s>=e.cmInitCounts.length)?{label:s>0?`Planning flow ${s+1}`:void 0,hasBifurcation:!0}:null}return e.cmInitCounts.length>0||e.steps.some(s=>s.children?.length)?null:{hasBifurcation:!!t}}var F=$(le(),1);var Ne=$(le(),1);var xe=$(M(),1),Xe="#ffc580",Ye="#ffd9a8",Ae="#ffffff";function qe({text:e,active:t=!0}){let[s,a]=(0,Ne.useState)(0),h=4;if(de(()=>{a(d=>(d+1)%(e.length+h*2))},t?80:null),!t)return(0,xe.jsx)(r,{color:Ae,children:e});let u=e.split("").map((d,c)=>{let D=s-h,C=Math.abs(c-D-h/2),k;return C<=h/2?k=Xe:C<=h?k=Ye:k=Ae,(0,xe.jsx)(r,{color:k,children:d},c)});return(0,xe.jsx)(r,{children:u})}var K=$(M(),1),Je={starting:i.orange,running:i.orange,passed:i.green,failed:i.red,cancelled:i.dim,timed_out:i.orange};function he({currentStep:e,maxSteps:t,elapsed:s,status:a}){let{stdout:h}=me(),u=h?.columns??80,d=Je[a]??i.orange,c=s<60?`${s.toFixed(1)}s`:`${Math.floor(s/60)}m ${Math.round(s%60)}s`;return(0,K.jsxs)(l,{flexDirection:"column",marginTop:1,children:[(0,K.jsx)(r,{color:i.muted,children:"\u2500".repeat(Math.min(u,60))}),(0,K.jsxs)(l,{children:[(0,K.jsx)(r,{children:" "}),(0,K.jsx)(r,{color:i.dim,children:"Steps "}),(0,K.jsx)(r,{bold:!0,children:e}),(0,K.jsxs)(r,{color:i.dim,children:["/",t]}),(0,K.jsx)(r,{children:" "}),(0,K.jsx)(r,{color:i.dim,children:"Elapsed "}),(0,K.jsx)(r,{bold:!0,children:c}),(0,K.jsx)(r,{children:" "}),(0,K.jsx)(r,{color:i.dim,children:"Status "}),(0,K.jsx)(r,{bold:!0,color:d,children:a})]})]})}var Qe={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 Ue(e){return Qe[e]??"\u25CF"}var ie=$(M(),1);function Be({steps:e,flows:t,cmInitCounts:s,renderStep:a}){return(0,ie.jsxs)(l,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[(0,ie.jsxs)(r,{color:i.dim,children:["\u2501\u2501 Bifurcated into ",t?.length??e.length," flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"]}),e.map((h,u)=>(0,ie.jsxs)(l,{flexDirection:"column",marginTop:u>0?1:0,children:[(0,ie.jsxs)(r,{color:i.orange,children:["Flow ",u+1,": ",t?.[u]??h.objective]}),s&&s[u]!=null&&(0,ie.jsxs)(r,{color:i.dim,children:[" \u25AA Generated task with ",s[u]," checkpoints"]}),h.children&&h.children.length>0?h.children.map(d=>a(d,`f${u}-${d.index}`)):h.status==="pending"&&(0,ie.jsx)(r,{color:i.dim,children:" \u25CB Waiting..."})]},u))]})}var o=$(M(),1);function X({step:e,indent:t=2}){let s=e.actionType?Ue(e.actionType):null,a=e.status==="running",h=e.status==="passed",u=e.status==="failed",d=e.status==="pending"||e.status==="stopped",{stdout:c}=me(),D=c?.columns??80,C=Math.max(20,D-t-21),k=e.objective??"",_=k.length>C?k.slice(0,C-1)+"\u2026":k,N=(e.duration??0)*1e3,f=e.duration!=null?N<1e3?`${Math.round(N)}ms`:`${(N/1e3).toFixed(1)}s`:"";return(0,o.jsxs)(l,{flexDirection:"column",children:[(0,o.jsxs)(l,{marginLeft:t,children:[(0,o.jsx)(l,{width:4,children:(0,o.jsxs)(r,{color:i.muted,children:[String(e.index).padStart(2," ")," "]})}),(0,o.jsx)(l,{width:3,children:a?(0,o.jsx)($e,{}):h?(0,o.jsx)(r,{color:i.green,bold:!0,children:"\u2713"}):u?(0,o.jsx)(r,{color:i.red,bold:!0,children:"\u2717"}):(0,o.jsx)(r,{color:i.muted,children:"\u25CB"})}),(0,o.jsx)(l,{flexGrow:1,children:a?(0,o.jsx)(qe,{text:_,active:!0}):u?(0,o.jsx)(r,{color:i.red,children:_}):d?(0,o.jsx)(r,{color:i.dim,children:_}):(0,o.jsx)(r,{color:i.dim,children:_})}),(h||u)&&s?(0,o.jsx)(l,{width:3,marginLeft:1,children:(0,o.jsx)(r,{color:i.muted,children:s})}):(0,o.jsx)(l,{width:3,marginLeft:1}),(0,o.jsx)(l,{width:7,justifyContent:"flex-end",children:(0,o.jsx)(r,{color:i.dim,children:f})})]}),e.children&&e.children.length>0&&(0,o.jsx)(l,{flexDirection:"column",children:e.children.map((m,y)=>(0,o.jsx)(X,{step:m,indent:t+2},`child-${y}`))})]})}function Ze(e){return e.type==="cm_init"?(0,o.jsx)(l,{marginLeft:2,paddingLeft:1,children:(0,o.jsxs)(r,{color:i.dim,children:["\u25AA Generated task with ",e.count," checkpoints"]})}):(0,o.jsx)(l,{marginLeft:2,paddingLeft:1,children:(0,o.jsx)(X,{step:e.step})})}function Ge({steps:e,bifurcated:t,flows:s,cmInitCounts:a,maxSteps:h=50,staticSteps:u=!1,onStepCommit:d}){let c=(0,F.useRef)(new Set),D=(0,F.useRef)(!1),C=(0,F.useRef)(new Set),k=(0,F.useRef)(!1),_=(0,F.useRef)(new Set),N=(0,F.useRef)(0);(0,F.useEffect)(()=>{e.length===0&&N.current>0&&(c.current.clear(),D.current=!1,C.current.clear(),k.current=!1,_.current.clear()),N.current=e.length},[e.length]);let f=e.flatMap(p=>[p,...p.children??[]]),m=f.some(p=>p.status==="running"),y=f.some(p=>p.status==="failed"),P=f.length===0||f.every(p=>p.status==="pending"),z=f.filter(p=>p.status==="passed"||p.status==="failed").length,q;P?q="starting":m?q="running":y?q="failed":q="passed";let Z=(0,F.useRef)(null),[se,fe]=(0,F.useState)(0);(0,F.useEffect)(()=>{f.length===0||P?(Z.current=null,fe(0)):m&&Z.current==null&&(Z.current=Date.now())},[m,P,f.length]),(0,F.useEffect)(()=>{if(!m)return;let p=setInterval(()=>{Z.current!=null&&fe((Date.now()-Z.current)/1e3)},500);return()=>clearInterval(p)},[m]);let U=(0,F.useRef)(new Set),[,G]=(0,F.useState)(0),Y=(0,F.useRef)(!1);(0,F.useEffect)(()=>{if(!d||!u||t)return;let p=[];!Y.current&&a&&a[0]!=null&&(Y.current=!0,a[0]>0&&p.push({key:"cm_init_0",type:"cm_init",count:a[0]}));for(let b of e)(b.status==="passed"||b.status==="failed")&&!U.current.has(b.index)&&(U.current.add(b.index),p.push({key:`step_${b.index}`,type:"step",step:{...b,children:b.children?[...b.children]:void 0}}));if(p.length>0){for(let b of p)d(Ze(b));G(b=>b+1)}},[e,t,a,u,d]),(0,F.useEffect)(()=>{if(!d||u)return;let p=c.current.size;if(!t&&!k.current&&a&&a[0]!=null&&(k.current=!0,a[0]>0&&d((0,o.jsx)(l,{marginLeft:2,children:(0,o.jsxs)(r,{color:i.dim,children:["\u25A0 Generated task with ",a[0]," checkpoints"]})}))),t&&s&&!D.current&&(D.current=!0,d((0,o.jsx)(r,{color:i.purple,children:"\u2501\u2501 Bifurcated into "+s.length+" flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"}))),t){let b=e.flatMap((S,g)=>{let B=S.children??[];return!C.current.has(g)&&B.length>0&&(C.current.add(g),d((0,o.jsx)(r,{color:i.purple,children:" Flow "+(g+1)+": "+(s?.[g]??"")})),a?.[g]!=null&&a[g]>0&&!_.current.has(g)&&(_.current.add(g),d((0,o.jsx)(l,{marginLeft:2,children:(0,o.jsxs)(r,{color:i.dim,children:[" \u25AA Generated task with ",a[g]," checkpoints"]})})))),a?.[g]!=null&&a[g]>0&&C.current.has(g)&&!_.current.has(g)&&(_.current.add(g),d((0,o.jsx)(l,{marginLeft:2,children:(0,o.jsxs)(r,{color:i.dim,children:[" \u25AA Generated task with ",a[g]," checkpoints"]})}))),B});for(let S of b){let g=`${S.index}-${S.objective}`;c.current.has(g)||(S.status==="passed"||S.status==="failed"||S.status==="stopped")&&(c.current.add(g),d((0,o.jsx)(l,{marginLeft:2,children:(0,o.jsx)(X,{step:S})})))}}else for(let b of e){let S=`${b.index}-${b.objective}`,g=!!b.branchObjective;g&&!c.current.has(S)&&(c.current.add(S),d((0,o.jsx)(l,{marginLeft:2,children:(0,o.jsx)(X,{step:{...b,children:void 0}})})));for(let B of b.children??[]){let ae=`child-${b.index}-${B.index}-${B.objective}`;c.current.has(ae)||(B.status==="passed"||B.status==="failed"||B.status==="stopped")&&(c.current.add(ae),d((0,o.jsx)(l,{marginLeft:4,children:(0,o.jsx)(X,{step:B})})))}!g&&!c.current.has(S)&&(b.status==="passed"||b.status==="failed"||b.status==="stopped")&&(c.current.add(S),d((0,o.jsx)(l,{marginLeft:2,children:(0,o.jsx)(X,{step:{...b,children:void 0}})})))}c.current.size>p&&G(b=>b+1)},[e,d,t,s,a]);let J=[];if(u&&!t)for(let p of e)U.current.has(p.index)||J.push(p);else if(d&&!u)if(t)for(let p of e){let S=(p.children??[]).filter(g=>{let B=`${g.index}-${g.objective}`;return!c.current.has(B)});S.length>0&&J.push({...p,children:S})}else for(let p of e){let b=`${p.index}-${p.objective}`,S=c.current.has(b),g=(p.children??[]).filter(B=>{let ae=`child-${p.index}-${B.index}-${B.objective}`;return!c.current.has(ae)});S?g.length>0&&J.push({...p,children:g}):J.push({...p,children:g})}if(!u){let p=d?J:e;return(0,o.jsxs)(l,{flexDirection:"column",children:[t?d?p.length>0?(0,o.jsx)(l,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:p.map((S,g)=>(0,o.jsx)(l,{flexDirection:"column",marginTop:g>0?1:0,children:S.children&&S.children.length>0?S.children.map(B=>(0,o.jsx)(X,{step:B},`f${g}-${B.index}`)):S.status==="pending"&&(0,o.jsx)(r,{color:i.dim,children:" \u25CB Waiting..."})},g))}):null:(0,o.jsx)(Be,{steps:e,flows:s,cmInitCounts:a,renderStep:(S,g)=>(0,o.jsx)(X,{step:S},g)}):(0,o.jsxs)(l,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[!d&&a&&a[0]!=null&&(0,o.jsxs)(r,{color:i.dim,children:["\u25AA Generated task with ",a[0]," checkpoints"]}),p.map(S=>{let g=`${S.index}-${S.objective}`;return d&&c.current.has(g)?(0,o.jsx)(l,{flexDirection:"column",children:(S.children??[]).map(B=>(0,o.jsx)(l,{marginLeft:2,children:(0,o.jsx)(X,{step:B})},B.index))},`branch-children-${S.index}`):(0,o.jsx)(X,{step:S},S.index)})]}),m&&(0,o.jsx)(he,{currentStep:z,maxSteps:h,elapsed:se,status:q})]})}return t?(0,o.jsxs)(l,{flexDirection:"column",children:[(0,o.jsx)(Be,{steps:e,flows:s,cmInitCounts:a,renderStep:(p,b)=>(0,o.jsx)(X,{step:p},b)}),m&&(0,o.jsx)(he,{currentStep:z,maxSteps:h,elapsed:se,status:q})]}):(0,o.jsxs)(l,{flexDirection:"column",children:[J.length>0&&(0,o.jsx)(l,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:J.map(p=>(0,o.jsx)(X,{step:p},p.index))}),m&&(0,o.jsx)(he,{currentStep:z,maxSteps:h,elapsed:se,status:q})]})}var ce=$(M(),1);function We({runner:e,runKey:t,onStepCommit:s}){let a=Me({isRunning:e.isRunning,bifurcationInfo:e.bifurcationInfo,steps:e.steps,cmInitCounts:e.cmInitCounts,replayInfo:e.replayInfo});return(0,ce.jsxs)(ce.Fragment,{children:[a&&(0,ce.jsx)(Fe,{label:a.label,hasBifurcation:a.hasBifurcation}),e.isRunning&&e.steps.length>0&&(0,ce.jsx)(Ge,{steps:e.steps,bifurcated:!!e.bifurcationInfo&&!e.bifurcationInfo.isSingleFlow,flows:e.bifurcationInfo?.flows,cmInitCounts:e.cmInitCounts,maxSteps:e.maxSteps,onStepCommit:s},`run-${t}`)]})}var H=$(M(),1),en=64;function nn(e){return e.split(`
|
|
5
|
-
`).map(t=>t.replace(/^[-–•]\s*/,"").trim()).filter(t=>t.length>0)}function Ke({status:e,summary:t,duration:s,steps:a,stepsPassed:h,stepsFailed:u,reason:d,creditsConsumed:c}){let D=e==="passed",C=D?i.green:i.red,k=D?"\u2713":"\u2717",_=e.toUpperCase(),N=h??(D?a:Math.max(0,a-1)),f=u??(D?0:1),m=f>0?`${a} steps (${N} passed, ${f} failed)`:`${a} steps`,y=s<60?`${s.toFixed(1)}s`:`${Math.floor(s/60)}m ${Math.round(s%60)}s`,P=nn(t);return(0,H.jsx)(l,{flexDirection:"column",marginTop:1,children:(0,H.jsxs)(l,{borderStyle:"round",borderColor:C,flexDirection:"column",paddingX:2,paddingY:1,width:en+6,children:[(0,H.jsxs)(l,{flexDirection:"column",children:[(0,H.jsxs)(r,{bold:!0,color:C,children:[k," ",_]}),(0,H.jsxs)(r,{color:i.dim,wrap:"wrap",children:[m," \xB7 ",y,typeof c=="number"&&c>0?` \xB7 ${parseFloat(c.toFixed(4))} credits`:""]})]}),P.length>0&&(0,H.jsx)(l,{flexDirection:"column",marginTop:1,marginLeft:1,children:P.map((z,q)=>(0,H.jsxs)(l,{marginBottom:q<P.length-1?1:0,children:[(0,H.jsx)(r,{color:i.orange,children:"\u25CF "}),(0,H.jsx)(l,{flexShrink:1,children:(0,H.jsx)(r,{wrap:"wrap",children:z})})]},q))}),d&&!D&&(0,H.jsx)(l,{marginTop:1,children:(0,H.jsxs)(r,{color:i.red,wrap:"wrap",children:["Reason: ",d]})})]})})}var V=$(M(),1);function He({message:e,code:t,remediation:s,docsUrl:a}){return(0,V.jsx)(Ie,{title:"Error",variant:"error",children:(0,V.jsxs)(l,{flexDirection:"column",paddingY:1,children:[(0,V.jsxs)(r,{color:i.red,bold:!0,children:[" \u2717 ",e]}),t&&(0,V.jsxs)(l,{marginTop:0,marginLeft:5,children:[(0,V.jsx)(r,{color:i.muted,children:"Code: "}),(0,V.jsx)(r,{color:i.dim,children:t})]}),s&&(0,V.jsxs)(l,{flexDirection:"column",marginTop:1,marginLeft:5,children:[(0,V.jsx)(r,{color:i.green,bold:!0,children:"Fix:"}),(0,V.jsxs)(r,{color:i.orange,children:["$ ",s]})]}),a&&(0,V.jsxs)(l,{marginTop:1,marginLeft:5,children:[(0,V.jsx)(r,{color:i.muted,children:"Docs: "}),(0,V.jsx)(r,{color:i.orange,underline:!0,children:a})]})]})})}var I=$(M(),1);function rt(e){let{exit:t}=ke(),{append:s}=_e(),a=(0,Q.useRef)(!1);(0,Q.useEffect)(()=>{a.current||(a.current=!0,s((0,I.jsx)(l,{flexDirection:"column",marginBottom:1,children:(0,I.jsxs)(l,{borderStyle:"round",borderColor:"#dc4e08",paddingX:2,children:[(0,I.jsx)(r,{color:"#ff9500",bold:!0,children:"KaneAI CLI"}),(0,I.jsx)(r,{color:i.dim,children:" \u2502 "}),(0,I.jsx)(r,{color:i.orange,children:e.topBanner.model}),(0,I.jsx)(r,{color:i.dim,children:" \u2502 "}),(0,I.jsx)(r,{color:i.dim,children:e.topBanner.auth})]})})),s((0,I.jsx)(tn,{data:e.globalConfig})),e.priorAttemptRollup&&s((0,I.jsx)(r,{color:i.dim,children:` \u21B3 replayed ${e.priorAttemptRollup.startIdx}..${e.priorAttemptRollup.endIdx-1} (${e.priorAttemptRollup.count} steps, from prior attempt)`})))},[]);let h=(0,Q.useRef)(null),u=(0,Q.useCallback)(async f=>{let m=await e.getNextStep(f);return m?(h.current=m,m.config):(h.current=null,null)},[e]),d=(0,Q.useCallback)((f,m)=>{let y=h.current;if(!y)return;let P=y.mode==="replay"?"cyan":"#dc4e08",z=y.modeReason?` (${y.modeReason})`:"",q=y.perStepOverrides?Object.entries(y.perStepOverrides):[];s((0,I.jsxs)(l,{flexDirection:"column",marginBottom:0,children:[(0,I.jsxs)(r,{children:[(0,I.jsxs)(r,{color:i.dim,children:[y.banner.stepLabel," "]}),(0,I.jsxs)(r,{color:P,children:["[",y.mode,"]"]}),(0,I.jsx)(r,{color:i.dim,children:z})]}),(0,I.jsx)(r,{color:i.dim,children:y.banner.objective}),q.length>0&&(0,I.jsxs)(r,{color:i.dim,children:["overrides: ",q.map(([Z,se])=>`${Z}=${se}`).join(", ")]})]}))},[s]),c=(0,Q.useRef)(0),D=(0,Q.useRef)(!1),C=(0,Q.useCallback)((f,m)=>(f.hadError?s((0,I.jsx)(He,{message:f.reason??"Runner error",code:"RUNNER_ERROR"})):s((0,I.jsx)(l,{flexDirection:"column",marginBottom:1,children:(0,I.jsx)(Ke,{status:f.status,summary:f.runEnd?.summary??"",duration:f.runEnd?.duration??0,steps:f.stepsTotal,stepsPassed:f.stepsPassed,stepsFailed:f.stepsFailed,reason:f.runEnd?.reason,creditsConsumed:f.runEnd?.credits_consumed})})),e.onStepEnd?.(f,m)??!0),[s,e]),k=Le({getNextConfig:u,onStepStart:d,onStepEnd:C,onAllComplete:()=>{e.onAllComplete(),e.exitOnComplete!==!1&&setImmediate(()=>t())},screenshotDispatcher:e.screenshotDispatcher,stepLogger:e.stepLogger,onReasoning:e.onReasoning,onStepComplete:e.onStepComplete,spawnOpts:e.spawnOpts}),_=250,N=5e3;return Ee((f,m)=>{if(m.ctrl&&f==="c"){let y=Date.now(),P=y-c.current;if(P<_)return;D.current&&P<N?(k.cancel(),e.onCancel?.(),e.exitOnComplete!==!1&&setImmediate(()=>t())):(D.current=!0,s((0,I.jsx)(r,{color:"yellow",children:"press Ctrl+C again to cancel run"}))),c.current=y}}),(0,I.jsx)(l,{flexDirection:"column",children:k.phase!=="done"&&(0,I.jsx)(We,{runner:k.runner,runKey:k.currentStepIndex,onStepCommit:s})})}function tn({data:e}){return(0,I.jsx)(Ce,{title:"test.md run",titleColor:"#ff9500",borderColor:i.dim,rows:[{label:"source",value:e.source},{label:"steps",value:`${e.steps.total} (${e.steps.replay} replay, ${e.steps.author} author per walker)`},{label:"model",value:e.model},{label:"viewport",value:`${e.viewport.width} x ${e.viewport.height}`},{label:"chrome",value:e.chrome},{label:"session",value:e.session},{label:"variables",value:`${e.variables.count} (${e.variables.secrets} secret)`},{label:"flags",value:e.flags.length>0?e.flags.join(" "):"(none)"}]})}export{Ge as a,Fe as b,Me as c,Oe as d,ye as e,Ke as f,He as g,rt as h};
|
package/dist/chunk-LAR7I5SR.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{s}from"./chunk-IBDWHXNE.js";function n(r="prod"){let e=s[r];return r!=="stage"?e:{authBaseUrl:process.env.KANE_STAGE_AUTH_URL??e.authBaseUrl,consentUrl:process.env.KANE_STAGE_CONSENT_URL??e.consentUrl,controllerBaseUrl:process.env.TESTMUAI_BASE_URL??e.controllerBaseUrl,tmsBaseUrl:process.env.KANE_STAGE_TMS_URL??e.tmsBaseUrl,testGeneratorBaseUrl:process.env.KANE_STAGE_TCG_URL??e.testGeneratorBaseUrl,secretsBaseUrl:process.env.KANE_STAGE_SECRETS_URL??e.secretsBaseUrl,testManagerUiUrl:process.env.KANE_STAGE_TEST_MANAGER_UI_URL??e.testManagerUiUrl,shareApiBaseUrl:process.env.KANE_STAGE_SHARE_API_URL??e.shareApiBaseUrl,v16ServerHost:process.env.KANE_STAGE_V16_SERVER_HOST??e.v16ServerHost}}export{n as a};
|
package/dist/chunk-OIPVMEM7.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as c}from"./chunk-LAR7I5SR.js";import{a as n}from"./chunk-RZ4F3BHX.js";import{q as s,r as a}from"./chunk-IBDWHXNE.js";import{createHash as h,randomBytes as g}from"crypto";var l=class{authBaseUrl;consentUrl;constructor(t="prod"){let e=c(t);this.authBaseUrl=e.authBaseUrl,this.consentUrl=e.consentUrl}static generatePkce(){let t=g(96).toString("base64url").slice(0,128),e=h("sha256").update(t).digest("base64url");return[t,e]}buildAuthorizationUrl(t,e,r,o){let i=new URLSearchParams({response_type:"code",client_id:t,redirect_uri:o,scope:a,code_challenge:e,code_challenge_method:"S256",state:r});return`${this.consentUrl}/oauth2?${i.toString()}`}async registerClient(t){let e=await n(`${this.authBaseUrl}/oauth2/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:s,redirect_uris:[t],grant_types:["authorization_code"],response_types:["code"],client_type:"public",application_type:"native"})});if(!e.ok)throw new Error(`DCR failed: ${e.status} ${await e.text()}`);return e.json()}async exchangeCode(t,e,r,o){let i=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:t,redirect_uri:o,client_id:e,code_verifier:r})});if(!i.ok)throw new Error(`Token exchange failed: ${i.status}`);return i.json()}async refreshToken(t,e){let r=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:t,client_id:e})});if(!r.ok)throw new Error(`Token refresh failed: ${r.status}`);return r.json()}async revokeToken(t,e,r="access_token"){await n(`${this.authBaseUrl}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,token_type_hint:r,client_id:e})})}async validateToken(t){let e=new AbortController,r=setTimeout(()=>e.abort(),1e4);try{let o=await n(`${this.authBaseUrl}/api/user`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},signal:e.signal});return clearTimeout(r),o.ok}catch{return clearTimeout(r),!1}}};export{l as a};
|
package/dist/chunk-Z7AXAKPX.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as Ae}from"./chunk-YSSBAIJI.js";import{a as _e}from"./chunk-FPFOW6BS.js";import{a as Se}from"./chunk-YCCUBQY4.js";import{a as ye}from"./chunk-VE3SUJMA.js";import{a as Ce}from"./chunk-OIPVMEM7.js";import{a as Ee}from"./chunk-LAR7I5SR.js";import{a as oe}from"./chunk-JGXJDTMO.js";import{c as ve,t as f}from"./chunk-IBDWHXNE.js";import{a as Z}from"./chunk-HCBYKLMW.js";import{a as T,b as d,h as Te,i as ce,k as we}from"./chunk-C44QQJR4.js";import{a as ue}from"./chunk-6YGTRKDT.js";import{e as M}from"./chunk-UR6MHSHU.js";var Re=M(ue(),1);import{readFileSync as Me,writeFileSync as Oe,mkdirSync as ke}from"fs";import{dirname as Ke,join as Ue}from"path";var Ne=Ue(ve,"command-history.json"),Fe=200,ge=class{entries;filePath;max;constructor(t=Ne,n=Fe){this.filePath=t,this.max=n,this.entries=this._load()}push(t){this.entries.length>0&&this.entries[this.entries.length-1]===t||(this.entries.push(t),this.entries.length>this.max&&(this.entries=this.entries.slice(this.entries.length-this.max)),this._save())}getAll(){return[...this.entries]}search(t){let n=t.toLowerCase(),o=[];for(let s=this.entries.length-1;s>=0;s--)this.entries[s].toLowerCase().includes(n)&&o.push(this.entries[s]);return o}_load(){try{let t=Me(this.filePath,"utf-8"),n=JSON.parse(t);return Array.isArray(n)?n:[]}catch{return[]}}_save(){try{ke(Ke(this.filePath),{recursive:!0}),Oe(this.filePath,JSON.stringify(this.entries)+`
|
|
3
|
-
`)}catch{}}};function nt(i){let t=(0,Re.useRef)(null);return t.current||(t.current=new ge(i)),t.current}var K=M(ue(),1);var pe=M(ue(),1);var H=M(Z(),1);function Pe({history:i,onSelect:t,onClose:n}){let[o,s]=(0,pe.useState)(""),[l,x]=(0,pe.useState)(0),S=o?i.search(o).slice(0,8):[];return ce((w,g)=>{if(g.escape){n();return}if(g.return){S.length>0&&S[l]?t(S[l]):n();return}if(g.upArrow){x(A=>Math.max(0,A-1));return}if(g.downArrow){x(A=>Math.min(S.length-1,A+1));return}if(g.backspace||g.delete){s(A=>A.slice(0,-1)),x(0);return}w&&!g.ctrl&&!g.meta&&(s(A=>A+w),x(0))}),(0,H.jsxs)(T,{flexDirection:"column",marginLeft:2,borderStyle:"single",paddingX:1,children:[(0,H.jsx)(d,{color:f.muted,bold:!0,children:"reverse search"}),(0,H.jsxs)(T,{gap:1,children:[(0,H.jsx)(d,{color:f.dim,children:"search:"}),(0,H.jsx)(d,{children:o}),(0,H.jsx)(d,{color:f.orange,children:"\u2588"})]}),S.length>0&&(0,H.jsx)(d,{children:" "}),S.map((w,g)=>(0,H.jsx)(T,{marginLeft:2,children:(0,H.jsxs)(d,{color:g===l?f.orange:f.dim,bold:g===l,children:[g===l?"\u25B8 ":" ",w]})},`${g}-${w}`))]})}var ee=M(Z(),1);function Ie({commands:i,selectedIndex:t}){return i.length===0?null:(0,ee.jsx)(T,{flexDirection:"column",marginBottom:0,children:i.map((n,o)=>{let s=o===t;return(0,ee.jsxs)(T,{children:[(0,ee.jsx)(d,{color:s?f.orange:f.dim,children:s?"\u276F ":" "}),(0,ee.jsxs)(d,{color:s?f.orange:void 0,bold:s,children:["/",n.name]}),n.args&&(0,ee.jsxs)(d,{color:f.dim,children:[" ",n.args]}),(0,ee.jsxs)(d,{color:f.dim,children:[" ",n.description]})]},n.name)})})}var de=M(ue(),1);var We=27,He=127,Ge=11;function $e(i){return i>=64&&i<=126}function Ve(i,t){i===Ge&&t({killToEnd:!0,ctrl:!0,raw:String.fromCharCode(i)})}function Ye(i,t){i===He&&t({backspace:!0,meta:!0,raw:"\x1B\x7F"})}function ze(i,t){let n=i.map(s=>String.fromCharCode(s)).join(""),o=/^\[1;([0-9]+)([A-D])$/.exec(n);if(o){let s=parseInt(o[1],10),l=o[2],x={raw:"\x1B"+n};if(s===2)x.shift=!0;else if(s===3)x.meta=!0;else if(s===5)x.ctrl=!0;else return;l==="A"?x.arrowUp=!0:l==="B"?x.arrowDown=!0:l==="C"?x.arrowRight=!0:l==="D"&&(x.arrowLeft=!0),t(x);return}if(n==="[H"||n==="[1~"||n==="[7~"){t({home:!0,raw:"\x1B"+n});return}if(n==="[F"||n==="[4~"||n==="[8~"){t({end:!0,raw:"\x1B"+n});return}if(n==="[3;5~"){t({delete:!0,ctrl:!0,raw:"\x1B"+n});return}if(n==="[3;3~"){t({delete:!0,meta:!0,raw:"\x1B"+n});return}}function Xe(i,t){i===72?t({home:!0,raw:"\x1BO"+String.fromCharCode(i)}):i===70&&t({end:!0,raw:"\x1BO"+String.fromCharCode(i)})}function je(){let i="IDLE",t=[];function n(){i="IDLE",t=[]}return{feed(o,s){for(let l of o)i==="IDLE"?l===We?(i="ESC",t=[]):Ve(l,s):i==="ESC"?l===91?(i="CSI",t=[]):l===79?(i="SS3",t=[]):(Ye(l,s),n()):i==="CSI"?(t.push(l),$e(l)&&(ze([91,...t],s),n())):i==="SS3"&&(Xe(l,s),n())},flushIdle(o){i==="ESC"&&t.length===0&&o({raw:"\x1B"}),n()}}}function Be(i,t={}){let n=(0,de.useRef)(i);n.current=i;let{stdin:o}=Te();(0,de.useEffect)(()=>{if(t.isActive===!1||!o)return;let s=je(),l=null,x=S=>{l&&(clearTimeout(l),l=null);let w=Buffer.isBuffer(S)?S:Buffer.from(S,"binary");s.feed(w,g=>n.current(g)),l=setTimeout(()=>{s.flushIdle(g=>n.current(g)),l=null},50)};return o.on("data",x),()=>{o.removeListener("data",x),l&&clearTimeout(l)}},[t.isActive,o])}var E=M(Z(),1),xe=10;function qe(i){return i.replace(/\x1b?\[200~/g,"").replace(/\x1b?\[201~/g,"").replace(/\r\n/g,`
|
|
4
|
-
`).replace(/\r/g,`
|
|
5
|
-
`).replace(/[\x00-\x08\x0b-\x1f\x7f]/g,"")}function Je(i,t){let n=[],o=0;for(;o<=i.length;){let s=o;for(;s<i.length&&i[s]!==`
|
|
6
|
-
`;)s++;if(o===s)n.push({start:o,end:o});else{let l=o;for(;l<s;){let x=Math.min(l+t,s);n.push({start:l,end:x}),l=x}}if(s>=i.length)break;o=s+1}return n}function Qe(i,t,n){if(i.length===0)return 0;if(t>=n.length)return i.length-1;if(n[t]===`
|
|
7
|
-
`){for(let o=i.length-1;o>=0;o--)if(i[o].end===t)return o;return i.length-1}for(let o=0;o<i.length;o++){let s=i[o];if(s.start<=t&&t<s.end)return o}return i.length-1}function Le(i,t,n,o){let s=Je(i,n);if(s.length===0)return null;let l=Qe(s,t,i),x=l+o;if(x<0||x>=s.length)return null;let S=t-s[l].start,w=s[x],g=w.end-w.start;return w.start+Math.min(S,g)}function vt({onSubmit:i,onEscape:t,history:n,placeholder:o="Type an objective or /command...",commands:s,clearSeq:l,submitVerb:x,footerBindings:S,inert:w=!1,clearOnSubmit:g=!0,noHistory:A=!1,accent:G=f.orange}){let[c,p]=(0,K.useState)([]),[u,b]=(0,K.useState)(0),[R,C]=(0,K.useState)("none"),[U,B]=(0,K.useState)(-1),V=(0,K.useRef)(""),[X,Y]=(0,K.useState)(!0),{stdout:he}=we(),j=he?.columns??80,[D,N]=(0,K.useState)(0),O=(0,K.useRef)(!1);(0,K.useEffect)(()=>{if(l!==void 0){if(!O.current){O.current=!0;return}p([]),b(0),B(-1),V.current="",Y(!0),C("none"),N(0)}},[l]);let y=c.join(""),q=(()=>{if(R!=="none"||c.length===0)return"";if(y.startsWith("/")&&s&&y.length>=2){let e=y.slice(1).toLowerCase(),r=s.find(h=>h.name.startsWith(e)&&h.name!==e);return r?`/${r.name}`.slice(y.length):""}if(y.startsWith("/")||A)return"";let a=n.getAll();for(let e=a.length-1;e>=0;e--)if(a[e].startsWith(y)&&a[e]!==y)return a[e].slice(y.length);return""})(),F=(()=>{if(!s||!y.startsWith("/"))return[];let a=y.length>=2?y.slice(1).toLowerCase():"";return a&&s.some(e=>e.name===a)?[]:s.filter(e=>!a||e.name.startsWith(a))})(),te=F.length>0&&y.startsWith("/");if(ce((a,e)=>{if(X&&a&&Y(!1),e.return){if(te&&F[D]){let r=`/${F[D].name}`;A||n.push(r),i(r),p([]),b(0),C("none"),B(-1),V.current="",Y(!0),N(0);return}y.trim()&&(A||n.push(y.trim()),i(y.trim()),g&&(p([]),b(0),C("none"),B(-1),V.current="",Y(!0),N(0)));return}if(e.escape){R!=="none"?C("none"):c.length>0?(p([]),b(0),B(-1),V.current=""):t?.();return}if(e.tab&&!e.shift){if(te&&F[D]){let r=`/${F[D].name}`;p([...r]),b(r.length),N(0);return}if(q){let r=y+q;p([...r]),b(r.length);return}return}if(e.ctrl&&a==="r"){if(A)return;C("search");return}if(e.ctrl&&a==="a"){b(0);return}if(e.ctrl&&a==="e"){b(c.length);return}if(e.ctrl&&a==="w"){if(u===0)return;let r=u-1;for(;r>0&&c[r]===" ";)r--;for(;r>0&&c[r-1]!==" ";)r--;let h=[...c.slice(0,r),...c.slice(u)];p(h),b(r);return}if(e.ctrl&&a==="u"){p([]),b(0),B(-1),C("none");return}if(e.meta&&a==="b"){let r=u-1;for(;r>0&&c[r]===" ";)r--;for(;r>0&&c[r-1]!==" ";)r--;b(Math.max(0,r));return}if(e.meta&&a==="f"){let r=u;for(;r<c.length&&c[r]!==" ";)r++;for(;r<c.length&&c[r]===" ";)r++;b(r);return}if(e.leftArrow){if(e.ctrl||e.shift)return;b(r=>Math.max(0,r-1));return}if(e.rightArrow){if(e.ctrl||e.shift)return;if(u>=c.length&&q){let r=y+q;p([...r]),b(r.length)}else b(r=>Math.min(c.length,r+1));return}if(e.upArrow){if(e.shift)return;if(te){N(r=>Math.max(0,r-1));return}if(R==="none"){let r=Math.max(1,j-2),h=Le(c,u,r,-1);if(h!==null){b(h);return}if(A)return;let v=n.getAll();if(v.length===0)return;if(U===-1){V.current=y,B(v.length-1);let _=v[v.length-1];p([..._]),b(_.length)}else if(U>0){let _=U-1;B(_);let k=v[_];p([...k]),b(k.length)}}return}if(e.downArrow){if(e.shift)return;if(te){N(r=>Math.min(F.length-1,r+1));return}if(R==="none"){let r=Math.max(1,j-2),h=Le(c,u,r,1);if(h!==null){b(h);return}if(A)return;let v=n.getAll();if(U===-1)return;if(U<v.length-1){let _=U+1;B(_);let k=v[_];p([...k]),b(k.length)}else{B(-1);let _=V.current;p([..._]),b(_.length)}}return}if(e.backspace||e.delete){if(e.meta||e.ctrl)return;if(u>0){let r=[...c.slice(0,u-1),...c.slice(u)];p(r),b(u-1),B(-1),N(0)}return}if(a&&!e.ctrl&&!e.meta){let r=qe(a);if(!r)return;let h=[...c.slice(0,u),...r,...c.slice(u)];p(h),b(u+r.length),B(-1),N(0)}},{isActive:!w&&R!=="search"}),Be(a=>{if(a.home){b(0);return}if(a.end){b(c.length);return}if(a.killToEnd){p(c.slice(0,u));return}if(a.arrowLeft&&(a.ctrl||a.meta)){let e=u-1;for(;e>0&&c[e]===" ";)e--;for(;e>0&&c[e-1]!==" ";)e--;b(Math.max(0,e));return}if(a.arrowRight&&(a.ctrl||a.meta)){let e=u;for(;e<c.length&&c[e]!==" ";)e++;for(;e<c.length&&c[e]===" ";)e++;b(e);return}if(a.backspace&&a.meta){if(u===0)return;let e=u-1;for(;e>0&&c[e]===" ";)e--;for(;e>0&&c[e-1]!==" ";)e--;let r=[...c.slice(0,e),...c.slice(u)];p(r),b(e);return}if(a.delete&&(a.ctrl||a.meta)){let e=u;for(;e<c.length&&c[e]===" ";)e++;for(;e<c.length&&c[e]!==" ";)e++;p([...c.slice(0,u),...c.slice(e)]);return}},{isActive:!w&&R!=="search"}),w)return(0,E.jsxs)(T,{flexDirection:"column",children:[(0,E.jsx)(d,{color:f.muted,children:"\u2500".repeat(j)}),(0,E.jsxs)(T,{children:[(0,E.jsx)(d,{color:f.muted,children:"\u276F "}),(0,E.jsx)(d,{color:f.dim,children:o})]}),(0,E.jsx)(oe,{bindings:S??[{keys:"ctrl+c",label:"cancel"},{keys:"/cancel",label:"stop turn"},{keys:"ctrl+t",label:"thinking"}],suppressEscBack:!0})]});let me=a=>{p([...a]),b(a.length),C("none")},se=()=>{C("none")},ae=(()=>{if(X&&c.length===0)return null;let a=u>=c.length,e=c.slice(0,u).join(""),r,h;a?(r=" ",h=""):c[u]===`
|
|
8
|
-
`?(r=" ",h=c.slice(u).join("")):(r=c[u],h=c.slice(u+1).join(""));let v=e+r+h+q,_=e.length,k=_+1,re=k+h.length,fe=Math.max(1,j-2),P=[],z=0;for(;z<=v.length;){let L=v.indexOf(`
|
|
9
|
-
`,z);if(L===-1&&(L=v.length),z===L)P.push({type:"content",start:z,end:z});else{let W=z;for(;W<L;){let J=Math.min(W+fe,L);P.push({type:"content",start:W,end:J}),W=J}}if(L>=v.length)break;z=L+1}let $=Math.max(0,P.findIndex(L=>L.start<=_&&_<=L.end)),ie;if(P.length<=xe)ie=P;else{let W=xe-1-4;if($<4||$>=P.length-W)ie=[...P.slice(0,4),{type:"ellipsis",hidden:P.length-4-W},...P.slice(P.length-W)];else{let J=xe-2,be=Math.floor(J/2),Q=$-be,le=$+(J-be)-1;Q<1&&(le+=1-Q,Q=1),le>P.length-2&&(Q-=le-(P.length-2),le=P.length-2),Q=Math.max(1,Q),ie=[{type:"ellipsis",hidden:Q},...P.slice(Q,le+1),{type:"ellipsis",hidden:P.length-le-1}]}}return{full:v,b:_,c:k,a:re,rows:ie}})();return(0,E.jsxs)(T,{flexDirection:"column",children:[R==="search"&&(0,E.jsx)(Pe,{history:n,onSelect:me,onClose:se}),te&&(0,E.jsx)(Ie,{commands:F,selectedIndex:D}),(0,E.jsx)(d,{color:f.muted,children:"\u2500".repeat(j)}),ae===null?(0,E.jsxs)(T,{children:[(0,E.jsx)(d,{color:G,children:"\u276F "}),(0,E.jsx)(d,{inverse:!0,children:" "}),(0,E.jsx)(d,{color:f.dim,children:o})]}):(()=>{let a=ae.rows.findIndex(e=>e.type==="content");return(0,E.jsx)(T,{flexDirection:"column",children:ae.rows.map((e,r)=>{if(e.type==="ellipsis")return(0,E.jsx)(T,{children:(0,E.jsxs)(d,{color:f.dim,children:[" \u22EF ","(",e.hidden," more line",e.hidden===1?"":"s",")"]})},r);let{full:h,b:v,c:_,a:k}=ae,re=e.start,ne=e.end,fe=r===a,P=fe?"\u276F ":" ",z=fe?G:f.muted,$=[(0,E.jsx)(d,{color:z,children:P},"p")];re<Math.min(v,ne)&&$.push((0,E.jsx)(d,{children:h.slice(re,Math.min(v,ne))},"b"));let ie=Math.max(v,re),L=Math.min(_,ne);ie<L&&$.push((0,E.jsx)(d,{color:G,inverse:!0,children:h.slice(ie,L)},"c"));let W=Math.max(_,re),J=Math.min(k,ne);return W<J&&$.push((0,E.jsx)(d,{children:h.slice(W,J)},"a")),ne>k&&$.push((0,E.jsx)(d,{color:f.dim,children:h.slice(Math.max(k,re),ne)},"g")),(0,E.jsx)(T,{children:$},r)})})})(),(0,E.jsx)(oe,{bindings:S??[{keys:"\u2191\u2193",label:"history"},{keys:"\u21B5",label:x??"submit"},{keys:"tab",label:"complete"},{keys:"ctrl+r",label:"search"}],escBackLabel:"clear"})]})}var I=M(ue(),1);var m=M(Z(),1);function Ze(i){let t=[{id:"method",label:"Auth method",options:[{label:"Basic Auth",value:"basic"},{label:"OAuth (browser)",value:"oauth"}]}];return i&&t.push({id:"env",label:"Environment",options:[{label:"prod",value:"prod"},{label:"stage",value:"stage"}]}),t.push({id:"profile",label:"Profile"}),t.push({id:"credentials",label:"Credentials"}),t}function Rt({devMode:i,profiles:t,onBasicLogin:n,onOAuthLogin:o,onComplete:s,onCancel:l}){let x=Ze(i),[S,w]=(0,I.useState)(0),[g,A]=(0,I.useState)(0),[G,c]=(0,I.useState)({}),[p,u]=(0,I.useState)("select"),[b,R]=(0,I.useState)(""),[C,U]=(0,I.useState)("username"),[B,V]=(0,I.useState)(""),[X,Y]=(0,I.useState)(null),[he,j]=(0,I.useState)(null),D=x[S],N=G.method??"basic",O=G.env??"prod",y=(0,I.useCallback)(()=>{let e=t.filter(r=>r.env===O).map(r=>({label:`${r.profile} [${r.env}]`,value:r.profile}));return e.push({label:"+ Create new",value:"__new__"}),e},[t,O]),q=(0,I.useCallback)(()=>{S===0?l():(w(a=>a-1),A(0),u("select"),R(""),Y(null))},[S,l]),F=(0,I.useCallback)(a=>{N==="basic"?(u("text-input"),U("username"),R("")):(u("waiting"),o(a,O).then(()=>{j(`Logged in via OAuth as ${a} [${O}]`),u("done")}).catch(e=>{Y(e.message),u("error")}))},[N,O,o]),te=(0,I.useCallback)(a=>{let e=a.trim();if(e){if(C==="profileName"){let r=e;c(h=>({...h,profile:r})),F(r);return}if(C==="username"){V(e),R(""),U("accessKey"),u("text-input-masked");return}if(C==="accessKey"){let r=G.profile??"default";u("waiting"),(async()=>{try{await n(r,O,B,e),j(`Logged in as ${r} [${O}] via basic auth`),u("done")}catch{Y("Credentials not valid. Please use valid credentials."),V(""),R(""),U("username"),u("text-input")}})()}}},[C,G.profile,O,n,B,F]),me=(0,I.useCallback)(a=>{R(a),X&&Y(null)},[X]);ce((a,e)=>{if(p==="done"){let h=G.profile??"default";s(h,O);return}if(p==="error"){l();return}if(p==="waiting"){e.escape&&l();return}if(p==="text-input"||p==="text-input-masked")return;if(e.escape){q();return}let r=D?.id==="profile"?y():D?.options??[];if(e.upArrow){A(h=>Math.max(0,h-1));return}if(e.downArrow){A(h=>Math.min(r.length-1,h+1));return}if(e.return&&r[g]){let h=r[g];if(D.id==="profile"){if(h.value==="__new__"){u("text-input"),U("profileName"),R("");return}c(v=>({...v,profile:h.value})),w(v=>v+1),A(0),F(h.value);return}c(v=>({...v,[D.id]:h.value})),w(v=>v+1),A(0)}});let se="Login";if(p==="done")return(0,m.jsxs)(T,{flexDirection:"column",borderStyle:"round",borderColor:f.green,paddingX:2,paddingY:1,children:[(0,m.jsxs)(d,{color:f.green,bold:!0,children:["\u2713 ",he]}),(0,m.jsx)(T,{marginTop:1,children:(0,m.jsx)(d,{color:f.dim,children:"press any key"})})]});if(p==="error")return(0,m.jsxs)(T,{flexDirection:"column",borderStyle:"round",borderColor:f.red,paddingX:2,paddingY:1,children:[(0,m.jsx)(d,{color:f.red,bold:!0,children:"Login failed"}),(0,m.jsx)(T,{marginTop:1,children:(0,m.jsx)(d,{color:f.red,children:X})}),(0,m.jsx)(T,{marginTop:1,children:(0,m.jsx)(d,{color:f.dim,children:"press any key"})})]});if(p==="waiting")return(0,m.jsxs)(T,{flexDirection:"column",borderStyle:"round",borderColor:f.orange,paddingX:2,paddingY:1,children:[(0,m.jsxs)(d,{color:f.orange,bold:!0,children:[se," \u203A OAuth"]}),(0,m.jsx)(T,{marginTop:1,children:(0,m.jsx)(d,{color:f.secondary,children:"Opening browser for login..."})}),(0,m.jsx)(T,{marginTop:1,children:(0,m.jsx)(d,{color:f.orange,children:"Waiting for callback \u27F3"})}),(0,m.jsx)(oe,{bindings:[],escBackLabel:"cancel"})]});if(p==="text-input"||p==="text-input-masked"){let a=C==="username"?"Username":C==="accessKey"?"Access Key":"Profile name",e=C==="username"||C==="accessKey"?`${se} \u203A Basic Auth`:`${se} \u203A New Profile`;return(0,m.jsxs)(T,{flexDirection:"column",borderStyle:"round",borderColor:f.orange,paddingX:2,paddingY:1,children:[X&&(C==="username"||C==="accessKey")&&(0,m.jsx)(T,{marginBottom:1,children:(0,m.jsxs)(d,{color:f.red,children:["\u2717 ",X]})}),(0,m.jsx)(d,{color:f.orange,bold:!0,children:e}),C==="accessKey"&&(0,m.jsxs)(T,{marginTop:1,children:[(0,m.jsx)(d,{color:f.secondary,children:"Username: "}),(0,m.jsx)(d,{children:B})]}),(0,m.jsxs)(T,{marginTop:1,children:[(0,m.jsxs)(d,{color:f.secondary,children:[a,": "]}),(0,m.jsx)(Se,{value:b,onChange:me,onSubmit:te,onCancel:q,masked:p==="text-input-masked"})]}),(0,m.jsx)(oe,{bindings:[{keys:"\u21B5",label:"confirm"}],escBackLabel:"back"})]})}let ae=D?.id==="profile"?y():D?.options??[];return(0,m.jsxs)(T,{flexDirection:"column",borderStyle:"round",borderColor:f.orange,paddingX:2,paddingY:1,children:[(0,m.jsx)(d,{color:f.orange,bold:!0,children:se}),(0,m.jsx)(T,{marginTop:1,children:(0,m.jsxs)(d,{color:f.secondary,children:[D?.label,":"]})}),(0,m.jsx)(T,{flexDirection:"column",marginTop:1,children:ae.map((a,e)=>{let r=e===g,h=r?"\u276F ":" ",v=a.value==="__new__"?f.green:r?f.orange:void 0;return(0,m.jsxs)(d,{color:v,children:[h,a.label]},a.value)})}),(0,m.jsx)(oe,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}async function De(i,t,n,o){let s=i.loadBasicAuth(t,n),l=i.loadCredentials(t,n);if(!s&&!l)return o("info","STARTUP_GATE_NO_CREDS","Profile has no credentials",{profile:t,env:n}),{status:"needs_login",profile:t,env:n};let x=Ee(n),S=async()=>i.loadCredentials(t,n)?.access_token??null,w=new _e(x.controllerBaseUrl,S,s,o);o("info","STARTUP_GATE_VALIDATE","Validating credentials with controller",{profile:t,env:n,method:s?"basic":"oauth"});let g=await w.resolve(!0);if(g)return o("info","STARTUP_GATE_VALID","Credentials validated",{profile:t,env:n,username:g.username,org_id:g.org_id}),{status:"authenticated",result:{profile:t,env:n,credentials:l,basicAuth:s,tmsCreds:g,resolver:w}};if(!s&&l){let A=l.refresh_token,c=i.loadClient(t,n)?.client_id;if(A&&c){o("info","STARTUP_GATE_REFRESH","Attempting token refresh",{profile:t,env:n});try{let u=await new Ce(n).refreshToken(A,c);if(u.access_token){i.saveCredentials(t,n,{...l,...u,expires_at:Date.now()/1e3+(u.expires_in??3600)});let R=await w.resolve(!0);if(R)return o("info","STARTUP_GATE_REFRESH_OK","Token refreshed and validated",{profile:t,env:n,username:R.username}),{status:"authenticated",result:{profile:t,env:n,credentials:{...l,...u},basicAuth:null,tmsCreds:R,resolver:w}}}o("warn","STARTUP_GATE_REFRESH_INVALID","Refreshed token still invalid",{profile:t,env:n})}catch(p){o("warn","STARTUP_GATE_REFRESH_FAILED","Token refresh failed",{profile:t,env:n,error:p instanceof Error?p.message:String(p)})}}else o("info","STARTUP_GATE_NO_REFRESH","No refresh_token or client_id \u2014 login required",{profile:t,env:n})}return o("info","STARTUP_GATE_INVALID","Credentials invalid \u2014 login required",{profile:t,env:n}),{status:"needs_login",profile:t,env:n}}async function Ot(i,t,n=new Ae){let o=i.listProfiles();if(t("info","STARTUP_GATE_START","Auth startup gate",{profile_count:o.length}),o.length===0)return t("info","STARTUP_GATE_NONE","No profiles found \u2014 login required"),{status:"needs_login"};if(o.length>1){let x=i.getActiveProfile(),S=i.getDefaultEnv();if(x&&o.some(g=>g.profile===x&&g.env===S)){t("info","STARTUP_GATE_TRY_ACTIVE","Multiple profiles \u2014 trying active first",{activeProfile:x,activeEnv:S});let g=await De(i,x,S,t);if(g.status==="authenticated")return g;t("info","STARTUP_GATE_ACTIVE_FAILED","Active profile invalid \u2014 showing picker",{activeProfile:x,activeEnv:S})}return t("info","STARTUP_GATE_MULTI","Multiple profiles \u2014 picker required",{profiles:o.map(w=>`${w.profile}/${w.env}`)}),{status:"needs_pick",profiles:o}}let{profile:s,env:l}=o[0];return i.setActiveProfile(s),i.setDefaultEnv(l),ye(i,n,s,l),De(i,s,l,t)}export{nt as a,vt as b,Rt as c,De as d,Ot as e};
|