@testmuai/kane-cli 0.4.1 → 0.4.3
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-5ORNSIGU.js} +1 -1
- package/dist/{CliFeedbackPrompt-3SDJ5GZP.js → CliFeedbackPrompt-FLU2ARNK.js} +1 -1
- package/dist/{CliUploadProgress-ZSZ7TGCN.js → CliUploadProgress-3XSSNZZC.js} +1 -1
- package/dist/{ConfigView-OOQYCHWM.js → ConfigView-J3U7W5IC.js} +1 -1
- package/dist/FolderPicker-63C6BXGW.js +2 -0
- package/dist/HelpView-QPZCA6E3.js +2 -0
- package/dist/{InfoBox-QECFIGGW.js → InfoBox-2PQE7LQY.js} +1 -1
- package/dist/{LinksBox-2L2UX4LB.js → LinksBox-72DOWBUL.js} +1 -1
- package/dist/{ProfilesView-72UTQ5PX.js → ProfilesView-VGHTTDXT.js} +1 -1
- package/dist/{ProjectPicker-NLEAW232.js → ProjectPicker-WICA5KRO.js} +1 -1
- package/dist/{SaveSessionPrompt-VNJDLJTF.js → SaveSessionPrompt-TH24UGJF.js} +1 -1
- package/dist/SingleShotApp-TFDCDSJ6.js +2 -0
- package/dist/{SummaryBox-O772FRGO.js → SummaryBox-P42SBLBH.js} +1 -1
- package/dist/TestMdRunView-HQE6IN2X.js +2 -0
- package/dist/{WhoamiView-LR2EFCTK.js → WhoamiView-FVGT4VHK.js} +1 -1
- package/dist/{changelog-VCAUV47V.js → changelog-55BBQLCV.js} +1 -1
- package/dist/{chunk-JGXJDTMO.js → chunk-2EDV5GRD.js} +1 -1
- package/dist/{chunk-7NDFOI6Z.js → chunk-3CKFCRIC.js} +1 -1
- package/dist/chunk-3OATWGPB.js +22 -0
- package/dist/{chunk-TCLKNUAL.js → chunk-6YGJHOJJ.js} +1 -1
- package/dist/{chunk-KJEJ7VW5.js → chunk-6YH4L5PD.js} +1 -1
- package/dist/{chunk-RHUD7MK4.js → chunk-7DLL4WUG.js} +2 -2
- package/dist/{chunk-V3FSESZ4.js → chunk-7HRF45Q4.js} +1 -1
- package/dist/{chunk-CMRNCZGV.js → chunk-ARXOHFRQ.js} +2 -2
- package/dist/{chunk-EEF6OT52.js → chunk-D3NAXZ2R.js} +8 -8
- package/dist/{chunk-AGS57DSG.js → chunk-D5P5DM3Y.js} +1 -1
- package/dist/{chunk-7I2SQ2KP.js → chunk-DJZVPHCW.js} +1 -1
- package/dist/{chunk-OFEPMULV.js → chunk-DOLZ3HLX.js} +1 -1
- package/dist/chunk-EBTYHLMG.js +5 -0
- package/dist/{chunk-P7ZUISQG.js → chunk-HM2I36RC.js} +1 -1
- package/dist/{chunk-VKG45YIL.js → chunk-IR5EJOWF.js} +1 -1
- package/dist/chunk-JOPYH47V.js +2 -0
- package/dist/chunk-JWZDGFTV.js +2 -0
- package/dist/chunk-LTEYP6N4.js +2 -0
- package/dist/{chunk-UHFCCGVX.js → chunk-M4JD6FAC.js} +1 -1
- package/dist/chunk-MDUS66QI.js +2 -0
- package/dist/chunk-MSIFN664.js +5 -0
- package/dist/{chunk-77SZF4ZU.js → chunk-N2DL2XLX.js} +1 -1
- package/dist/{chunk-YAVIOVVP.js → chunk-OERW4FRV.js} +1 -1
- package/dist/{chunk-UYHNJUPY.js → chunk-P6ZOLQ6M.js} +1 -1
- package/dist/chunk-QKZTUJUZ.js +6 -0
- package/dist/{chunk-OIPVMEM7.js → chunk-RVK7MDEV.js} +1 -1
- package/dist/{chunk-7U4NY37W.js → chunk-SP6DPSKB.js} +2 -2
- package/dist/{chunk-RJNGCQCL.js → chunk-UMFJNYMK.js} +1 -1
- package/dist/{chunk-T46Z27UL.js → chunk-UN7QP7YJ.js} +1 -1
- package/dist/chunk-UQLF4H5Z.js +11 -0
- package/dist/{chunk-J2KTLZAW.js → chunk-USO6VWOP.js} +1 -1
- package/dist/{chunk-LEXQLAWB.js → chunk-V45IPWG3.js} +33 -33
- package/dist/{chunk-4QO6JYHX.js → chunk-W7K5XSAM.js} +1 -1
- package/dist/chunk-WBYOM6I2.js +2 -0
- package/dist/{chunk-DAVPOA2L.js → chunk-YO6OTYDJ.js} +1 -1
- package/dist/{chunk-HUOC7DUT.js → chunk-Z36MHRFD.js} +1 -1
- package/dist/chunk-ZS22QC5H.js +8 -0
- package/dist/generate-headless-2AVIJFUR.js +21 -0
- package/dist/index.js +38 -33
- package/dist/{list-commands-Y6A3XR4L.js → list-commands-GI6JUPK2.js} +1 -1
- package/dist/login-flow-FM7VP76A.js +2 -0
- package/dist/{persist-recorded-session-WBPLUA55.js → persist-recorded-session-L2UJYUMB.js} +1 -1
- package/dist/{pipeline-L5TDZMLS.js → pipeline-IXEPO6AR.js} +1 -1
- package/dist/{recording-banner-Q36WARSF.js → recording-banner-RVW5S7ET.js} +1 -1
- package/dist/{require-project-folder-DBXAG7FB.js → require-project-folder-EGKVA3T3.js} +1 -1
- package/dist/{run-test-md-H2X6CUIX.js → run-test-md-B4XEFS35.js} +3 -3
- package/dist/skill-installer-NDDLIUWA.js +3 -0
- package/dist/tcg-generate-JQNBXV5P.js +2 -0
- package/dist/testmd-actions-QSLRU3KN.js +2 -0
- package/dist/token-refresh-DKWS73ET.js +2 -0
- package/dist/{validate-basic-VFJZKHOE.js → validate-basic-36EIJ3ZB.js} +1 -1
- package/dist/{version-check-5NUDIYG4.js → version-check-575H4PFY.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-YSSBAIJI.js +0 -8
- 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,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as m}from"./chunk-L5LI2JF4.js";import{c as h}from"./chunk-
|
|
2
|
+
import{b as m}from"./chunk-L5LI2JF4.js";import{c as h}from"./chunk-LTEYP6N4.js";import{randomUUID as N}from"crypto";import{mkdirSync as F,writeFileSync as f,appendFileSync as A,existsSync as v}from"fs";import{join as a}from"path";import{writeFileSync as w,mkdirSync as x,existsSync as I}from"fs";import{join as p,relative as j}from"path";function _(n){let t=Object.keys(n.frontmatter).length>0?m(n.frontmatter).trimEnd():"",s=["---"];return t&&s.push(t),s.push("---",""),s.push(`# ${n.heading}`,""),n.steps.forEach((i,r)=>{s.push(`## Step ${r+1}`,i,"")}),s.join(`
|
|
3
3
|
`)}function k(n,e){let t={},s={},i=e;for(let[r,l]of Object.entries(n)){if(r.startsWith("global.")||r.startsWith("secrets.user.")||r.startsWith("environment.")){let o=r.startsWith("secrets.user.");t[r]={value:l.value,secret:o,syntax:`{{${r}}}`,type:o?"secret":r.startsWith("environment.")?"environment":"global"},s[r]=r;continue}if(l.secret){let o=`secrets.user.${r}`;t[o]={value:l.value,secret:!0,syntax:`{{secrets.user.${r}}}`,type:"secret"},s[r]=o,i=i.replaceAll(`{{${r}}}`,`{{secrets.user.${r}}}`)}else{let o=`global.${r}`;t[o]={value:l.value,secret:!1,syntax:`{{global.${r}}}`,type:"global"},s[r]=o,i=i.replaceAll(`{{${r}}}`,`{{global.${r}}}`)}}return{variables:t,objective:i,keyMap:s}}var y=/\{\{\s*(?:global|secrets\.user|environment)\.([^{}]+?)\s*\}\}/g;function c(n){return typeof n!="string"||!n.includes("{{")?n:n.replace(y,"{{$1}}")}function d(n){if(typeof n=="string")return c(n);if(Array.isArray(n))return n.map(e=>d(e));if(n&&typeof n=="object"){let e={};for(let[t,s]of Object.entries(n))e[t]=d(s);return e}return n}var L=new Set(["username","access_key","oauth","profile","project_id","folder_id"]),$=new Set(["model","env"]),g=class{constructor(e){this.opts=e}objectives=[];flushed=!1;lastWrittenPath=null;lastCollisionSuffixed=!1;appendObjective(e){this.objectives.push(e)}flush(){if(this.flushed||(this.flushed=!0,this.objectives.length===0))return;let e=this.opts.getName();if(!e)return;let t=p(this.opts.cwd,".testmuai","tests");try{x(t,{recursive:!0})}catch(u){process.stderr.write(`
|
|
4
4
|
\u26A0 Failed to create ${j(this.opts.cwd,t)}/
|
|
5
5
|
${u.message}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{
|
|
2
|
+
import{b as K,c as V,d as z,e as ee,f as te}from"./chunk-UQLF4H5Z.js";import{c as J}from"./chunk-D5P5DM3Y.js";import{a as Q}from"./chunk-ZS22QC5H.js";import{a as Z}from"./chunk-FPFOW6BS.js";import{b as H}from"./chunk-6YH4L5PD.js";import{b as W}from"./chunk-HM2I36RC.js";import{g as E}from"./chunk-LOIRZFV3.js";import{a as O}from"./chunk-LPUQ4HWQ.js";import{a as k,b as A,d as Y}from"./chunk-VE3SUJMA.js";import{a as q}from"./chunk-UN7QP7YJ.js";import{a as _}from"./chunk-MDUS66QI.js";import{a as G}from"./chunk-HCBYKLMW.js";import{a as c,b as u,i as I,j as X}from"./chunk-C44QQJR4.js";import{a as ue}from"./chunk-6YGTRKDT.js";import{e as F}from"./chunk-UR6MHSHU.js";var i=F(ue(),1);var r=F(G(),1);function _e({resultRef:h,mode:d="singleshot",loginCompleteRef:f}){let{exit:m}=X(),C=(0,i.useRef)(new q),S=(0,i.useRef)(new Q),v=(0,i.useRef)(new J),t=C.current,l=S.current,$=v.current,ne=K(),[P,g]=(0,i.useState)(d==="login"?"login":"gate"),[L,re]=(0,i.useState)(null),[de,R]=(0,i.useState)(null),[ge,T]=(0,i.useState)(null),[N,oe]=(0,i.useState)(null),[U,B]=(0,i.useState)([]),x=(0,i.useCallback)((e,n,s,o)=>$.log(e,n,s,o),[$]),pe=(0,i.useCallback)((e,n)=>{e?k(t,l,e,n):l.save({project_id:null,project_name:null,folder_id:null,folder_name:null})},[t,l]),y=(0,i.useCallback)(()=>{d==="login"?(f&&(f.current=!0),m()):g("input")},[d,m,f]),D=(0,i.useCallback)((e,n)=>{let s=k(t,l,e,n);if(d==="login"){g("ensure-project");return}Y(s)?y():s.projectId?g("ensure-folder"):g("ensure-project")},[t,l,y,d]);I((e,n)=>{n.ctrl&&e==="c"&&E(0,"Ctrl+C exit")});let M=(0,i.useRef)(!1);i.default.useEffect(()=>{M.current||(M.current=!0,d!=="login"&&te(t,x).then(e=>{re(e),e.status==="authenticated"?D(e.result.profile,e.result.env):e.status==="needs_pick"?g("pick"):(R(e.profile??null),T(e.env??null),g("login"))}).catch(e=>{oe(`Auth check failed: ${e instanceof Error?e.message:String(e)}`)}))},[t,x]);let ie=(0,i.useCallback)(e=>{h.current={objective:e},m()},[h,m]),se=(0,i.useCallback)(async(e,n)=>{t.setActiveProfile(e),t.setDefaultEnv(n),(await ee(t,e,n,x)).status==="authenticated"?D(e,n):(R(e),T(n),g("login"))},[t,x,D]),w=(0,i.useCallback)(()=>{let e=t.getActiveProfile(),n=t.getDefaultEnv();if(!e)return null;let s=_(n),o=t.loadBasicAuth(e,n);return new Z(s.controllerBaseUrl,async()=>t.loadCredentials(e,n)?.access_token??null,o,x)},[t,x]),le=(0,i.useCallback)(async()=>{let e=w();if(!e)return null;let n=e.cached??await e.resolve();if(!n)return null;let s=_(t.getDefaultEnv()),o=new O(s.tmsBaseUrl,n.username,n.access_key);try{let p=(await o.listProjects()).find(b=>b.name==="KaneAI Generated");if(p)return{id:p.project_id,name:p.name};let j=await o.createProject("KaneAI Generated");return{id:j.id,name:j.name}}catch{return null}},[w,t]),ae=(0,i.useCallback)(async e=>{let n=w();if(!n)return null;let s=n.cached??await n.resolve();if(!s)return null;let o=_(t.getDefaultEnv()),a=new O(o.tmsBaseUrl,s.username,s.access_key);try{let j=(await a.listFolders(e)).find(ce=>ce.name==="Untitled");if(j)return{id:j.id,name:j.name};let b=await a.createFolder(e,"Untitled");return{id:b.id,name:b.name}}catch{return null}},[w,t]);if(P==="gate")return(0,r.jsx)(c,{paddingX:1,children:(0,r.jsx)(u,{color:"yellow",children:"Checking authentication..."})});if(N)return(0,r.jsxs)(c,{flexDirection:"column",paddingX:1,children:[(0,r.jsx)(u,{color:"red",children:N}),(0,r.jsx)(u,{color:"gray",children:"Press Ctrl+C to exit."})]});if(P==="pick"&&L?.status==="needs_pick")return(0,r.jsx)(fe,{profiles:L.profiles,onSelect:se});if(P==="login")return(0,r.jsx)(z,{devMode:process.env.KANE_DEV_MODE==="1",profiles:t.listProfiles(),onBasicLogin:async(e,n,s,o)=>{let{validateBasicAuth:a}=await import("./validate-basic-36EIJ3ZB.js");await a(n,s,o),t.saveBasicAuth(e,n,{username:s,access_key:o}),t.setActiveProfile(e),t.setDefaultEnv(n)},onOAuthLogin:async(e,n)=>{let{LoginFlow:s}=await import("./login-flow-FM7VP76A.js");t.setDefaultEnv(n),t.setActiveProfile(e),await new s(e,n,t).login()},onComplete:(e,n)=>{R(e),T(n),t.setActiveProfile(e),t.setDefaultEnv(n),D(e,n)},onCancel:()=>{E(0,"Login cancelled")}});if(P==="ensure-project"){let e=t.getActiveProfile()??"default",n=t.getDefaultEnv(),s=()=>{if(d==="login"){g("ensure-folder");return}k(t,l,e,n).folderId?y():g("ensure-folder")};return(0,r.jsxs)(c,{flexDirection:"column",children:[(0,r.jsx)(c,{paddingX:1,marginBottom:1,children:(0,r.jsx)(u,{color:"yellow",children:"Project & folder are required to save tests \xB7 Esc to use defaults \xB7 Ctrl+C to exit"})}),(0,r.jsx)(H,{resolver:w(),currentProjectId:l.load().project_id,env:n,onSelect:(o,a)=>{A(t,l,e,n,{projectId:o,projectName:a}),B(p=>[...p,`\u2713 Project: ${a} (${o})`]),s()},onCancel:async()=>{let o=await le();o&&(A(t,l,e,n,{projectId:o.id,projectName:o.name}),B(a=>[...a,`\u2713 Default project: ${o.name} (${o.id})`]),s())}})]})}if(P==="ensure-folder"){let e=t.getActiveProfile()??"default",n=t.getDefaultEnv(),s=t.loadProfileConfig(e,n);return(0,r.jsxs)(c,{flexDirection:"column",children:[(0,r.jsx)(c,{paddingX:1,marginBottom:1,children:(0,r.jsx)(u,{color:"yellow",children:"Project & folder are required to save tests \xB7 Esc to use defaults \xB7 Ctrl+C to exit"})}),(0,r.jsx)(W,{resolver:w(),projectId:s?.project_id??"",currentFolderId:l.load().folder_id,env:n,onSelect:(o,a)=>{A(t,l,e,n,{folderId:o,folderName:a}),B(p=>[...p,`\u2713 Folder: ${a} (${o})`]),y()},onCancel:async()=>{if(!s?.project_id)return;let o=await ae(s.project_id);o&&(A(t,l,e,n,{folderId:o.id,folderName:o.name}),B(a=>[...a,`\u2713 Default folder: ${o.name} (${o.id})`]),y())}})]})}return P==="input"?(0,r.jsxs)(c,{flexDirection:"column",children:[U.length>0&&(0,r.jsx)(c,{flexDirection:"column",paddingX:1,marginBottom:1,children:U.map((e,n)=>(0,r.jsx)(u,{color:"green",children:e},n))}),(0,r.jsx)(V,{onSubmit:ie,onEscape:()=>E(0,"User pressed Escape"),history:ne,placeholder:"Type an objective..."})]}):(0,r.jsx)(r.Fragment,{})}function fe({profiles:h,onSelect:d}){let[f,m]=(0,i.useState)(0),[C,S]=(0,i.useState)(!1);return I((v,t)=>{if(!C){if(t.escape){E(0,"Profile picker cancelled");return}if(t.upArrow&&f>0&&m(l=>l-1),t.downArrow&&f<h.length-1&&m(l=>l+1),t.return){S(!0);let l=h[f];d(l.profile,l.env).catch(()=>S(!1))}}}),(0,r.jsxs)(c,{flexDirection:"column",paddingX:1,children:[(0,r.jsx)(u,{color:"#ff9500",bold:!0,children:"Select a profile:"}),(0,r.jsx)(c,{marginTop:1,flexDirection:"column",children:h.map((v,t)=>(0,r.jsxs)(u,{children:[t===f?"\u276F ":" ",(0,r.jsx)(u,{color:t===f?"#ff9500":"white",bold:t===f,children:v.profile}),(0,r.jsxs)(u,{color:"gray",children:[" [",v.env,"]"]})]},`${v.profile}-${v.env}`))}),C&&(0,r.jsx)(c,{marginTop:1,children:(0,r.jsx)(u,{color:"yellow",children:"Validating credentials..."})})]})}export{_e as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as l}from"./chunk-RZ4F3BHX.js";import{a,c,e as o}from"./chunk-
|
|
2
|
+
import{a as l}from"./chunk-RZ4F3BHX.js";import{a,c,e as o}from"./chunk-LTEYP6N4.js";import{readFileSync as f,writeFileSync as d,mkdirSync as h,realpathSync as g}from"fs";import{join as y}from"path";var C="npm install -g @testmuai/kane-cli@latest",b="brew upgrade lambdatest/kane/kane-cli";function w(){try{let t=process.argv[1];if(t&&g(t).includes("/Cellar/"))return b}catch{}return C}var m=y(c,"version-check.json"),S=1440*60*1e3;function k(){try{let t=JSON.parse(f(m,"utf-8"));if(Date.now()-t.checkedAt<S)return t}catch{}return null}function A(t){try{h(c,{recursive:!0}),d(m,JSON.stringify({latest:t,checkedAt:Date.now()}))}catch{}}function u(t,r){let i=t.split(".").map(Number),n=r.split(".").map(Number);for(let s=0;s<3;s++){let e=(n[s]??0)-(i[s]??0);if(e!==0)return e}return 0}function p(t,r){let i=t.split(".").map(Number),n=r.split(".").map(Number);return(n[0]??0)!==(i[0]??0)?"major":(n[1]??0)!==(i[1]??0)?"minor":"patch"}async function j(){try{let t=k();if(t)return u(a,t.latest)>0?{current:a,latest:t.latest,severity:p(a,t.latest)}:null;let r=new AbortController,i=setTimeout(()=>r.abort(),5e3),n=await l(o,{headers:{Accept:"application/json"},signal:r.signal});if(clearTimeout(i),!n.ok)return null;let e=(await n.json())["dist-tags"]?.latest;return e?(A(e),u(a,e)>0?{current:a,latest:e,severity:p(a,e)}:null):null}catch{return null}}export{w as a,u as b,p as c,j as d};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as v}from"./chunk-MDUS66QI.js";import{spawn as x,execSync as N}from"child_process";import{existsSync as g}from"fs";import{resolve as e,dirname as b}from"path";import{fileURLToPath as A}from"url";import{createInterface as w}from"readline";async function*_(i){let n=w({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",V16_BIFURCATION_PHASES:"1"},unset:[]}:{set:{},unset:["V16_AGENT_ENABLE_ALL_BLOCKERS","V16_AGENT_SKIP_CP_FINAL","V16_BIFURCATION_PHASES"]}}var c=b(A(import.meta.url));function C(){for(let i of["python3","python"])try{return N(`${i} --version`,{stdio:"ignore"}),i}catch{}return null}function h(){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=C();if(a)return{cmd:a,args:["main.py"],cwd:t}}return null}function G(i,n){let l=h();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})})}),R=_(s.stdout);return{child:s,events:R,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{h as a,G as b};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as A}from"./chunk-YCCUBQY4.js";import{a as _}from"./chunk-
|
|
2
|
+
import{a as A}from"./chunk-YCCUBQY4.js";import{a as _}from"./chunk-M4JD6FAC.js";import{a as k}from"./chunk-LPUQ4HWQ.js";import{a as B}from"./chunk-MDUS66QI.js";import{a as R}from"./chunk-2EDV5GRD.js";import{x as c}from"./chunk-LTEYP6N4.js";import{a as P}from"./chunk-HCBYKLMW.js";import{a as u,b as l}from"./chunk-C44QQJR4.js";import{a as J}from"./chunk-6YGTRKDT.js";import{e as L}from"./chunk-UR6MHSHU.js";var t=L(J(),1);var e=L(P(),1);function X(n,i,y,m){return{id:n,label:`${i} (${n}) \xB7 ${y} tests`,isActive:n===m}}function W({resolver:n,projectId:i,currentFolderId:y,env:m,onSelect:x,onCancel:w}){let[I,M]=(0,t.useState)([]),[$,d]=(0,t.useState)(!0),[O,g]=(0,t.useState)(!1),[U,N]=(0,t.useState)(null),[p,b]=(0,t.useState)("list"),[S,v]=(0,t.useState)(""),[E,f]=(0,t.useState)(null),h=(0,t.useRef)(!1);(0,t.useEffect)(()=>{if(!n){N("Login first to browse folders"),d(!1);return}let o=new AbortController;return d(!0),g(!0),(async()=>{try{let r=n.cached??await n.resolve();if(!r){N("Login first to browse folders"),d(!1),g(!1);return}let a=B(m),T=new k(a.tmsBaseUrl,r.username,r.access_key),F=(async function*(){if(o.signal.aborted)return;let s=await T.listFolders(i);yield{page:1,folders:s,totalLoaded:s.length,done:!0}})();for await(let s of F){if(d(!1),s.totalLoaded===0){h.current=!0,b("naming"),g(!1);return}M(s.folders.map(C=>X(C.id,C.name,C.test_cases_count,y))),s.done&&g(!1)}}catch(r){if(r?.name==="AbortError")return;N(r instanceof Error?r.message:String(r)),d(!1),g(!1)}})(),()=>o.abort()},[n,i,y,m]);let D=(0,t.useCallback)(o=>{let r=o.trim();if(!r){f("Name cannot be empty");return}if(!i){f("No project selected \u2014 pick a project first");return}f(null),b("creating"),(async()=>{try{if(!n)throw new Error("Not authenticated");let a=n.cached??await n.resolve();if(!a)throw new Error("Not authenticated");let T=B(m),s=await new k(T.tmsBaseUrl,a.username,a.access_key).createFolder(i,r);x(s.id,s.name)}catch(a){f(a instanceof Error?a.message:String(a)),b("naming")}})()},[n,i,m,x]),H=(0,t.useCallback)(()=>{v(""),f(null),h.current?w():b("list")},[w]);return p==="naming"||p==="creating"?(0,e.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:c.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(l,{color:c.orange,bold:!0,children:"Create new folder"}),h.current&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.dim,children:"No folders yet \u2014 let's create one."})}),(0,e.jsxs)(u,{marginTop:1,children:[(0,e.jsx)(l,{color:c.dim,children:"Name: "}),p==="naming"?(0,e.jsx)(A,{value:S,onChange:o=>{v(o),E&&f(null)},onSubmit:D,onCancel:H}):(0,e.jsx)(l,{children:S})]}),E&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.red,children:E})}),p==="creating"&&(0,e.jsx)(u,{marginTop:1,children:(0,e.jsx)(l,{color:c.dim,children:"Creating..."})}),p==="naming"&&(0,e.jsx)(R,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:h.current?"cancel":"back"})]}):(0,e.jsx)(_,{title:"Folders",items:I,loading:$,loadingMore:O,preserveSelectionById:!0,error:U,itemNoun:"folders",onTab:()=>{h.current=!1,b("naming")},extraHint:"tab to create new",onSelect:o=>{let r=o.label.split(" (")[0];x(o.id,r)},onCancel:w})}export{X as a,W as b};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as b}from"./chunk-
|
|
2
|
+
import{a as b}from"./chunk-2EDV5GRD.js";import{m as d,x as o}from"./chunk-LTEYP6N4.js";import{a as L}from"./chunk-HCBYKLMW.js";import{a as u,b as c,i as A}from"./chunk-C44QQJR4.js";import{a as D}from"./chunk-6YGTRKDT.js";import{e as h}from"./chunk-UR6MHSHU.js";var x=h(D(),1);import{readdirSync as N,mkdirSync as B,statSync as k}from"fs";import{join as P}from"path";var r=h(L(),1);function O(n){try{return N(n).filter(l=>{try{return k(P(n,l)).isDirectory()}catch{return!1}})}catch{return[]}}function E(n,l,f,v){return{name:n,path:l,label:n,isActive:v}}function H({currentPath:n,onSelect:l,onCancel:f}){let s=O(d).map(i=>{let e=P(d,i);return E(i,e,n,e===n)}),p=!n,R=s.length+2,[a,C]=(0,x.useState)(()=>{if(p)return 0;let i=s.findIndex(e=>e.isActive);return i>=0?i+1:0}),[T,I]=(0,x.useState)(!1),[S,g]=(0,x.useState)("");return A((i,e)=>{if(T){if(e.escape){I(!1),g("");return}if(e.return){let t=S.trim();if(t){let m=P(d,t);B(m,{recursive:!0}),l(m),f()}return}if(e.backspace||e.delete){g(t=>t.slice(0,-1));return}i&&!e.ctrl&&!e.meta&&g(t=>t+i);return}if(e.escape){f();return}if(e.upArrow){C(t=>Math.max(0,t-1));return}if(e.downArrow){C(t=>Math.min(R-1,t+1));return}if(e.return){if(a===0){p||l(""),f();return}if(a===s.length+1){B(d,{recursive:!0}),I(!0),g("");return}let t=s[a-1];t&&!t.isActive&&l(t.path),f();return}}),T?(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile \u203A New"}),(0,r.jsxs)(u,{marginTop:1,children:[(0,r.jsx)(c,{color:o.secondary,children:"Name: "}),(0,r.jsx)(c,{children:S}),(0,r.jsx)(c,{color:o.dim,children:"\u2588"})]}),(0,r.jsx)(b,{bindings:[{keys:"\u21B5",label:"create"}],escBackLabel:"back"})]}):(0,r.jsxs)(u,{flexDirection:"column",borderStyle:"round",borderColor:o.orange,paddingX:2,paddingY:1,children:[(0,r.jsx)(c,{color:o.orange,bold:!0,children:"Chrome Profile"}),(0,r.jsxs)(u,{flexDirection:"column",marginTop:1,children:[(0,r.jsxs)(c,{color:p?o.green:a===0?o.orange:o.dim,children:[a===0?"\u276F ":" ","Use temporary (no profile)",p?" \u25CF active":""]}),s.map((i,e)=>{let m=e+1===a,w=m?"\u276F ":" ",y=i.isActive?o.green:m?o.orange:void 0;return(0,r.jsxs)(c,{color:y,children:[w,i.label,i.isActive?" \u25CF active":""]},i.name)}),(0,r.jsxs)(c,{color:a===s.length+1?o.orange:o.dim,children:[a===s.length+1?"\u276F ":" ","+ Create new"]})]}),(0,r.jsx)(b,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}export{O as a,E as b,H as c};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{b as l}from"./chunk-DOLZ3HLX.js";import{a as f}from"./chunk-UN7QP7YJ.js";import{a as m}from"./chunk-MDUS66QI.js";import{a as p}from"./chunk-RZ4F3BHX.js";import{a as c,c as s,h as a,w as u}from"./chunk-LTEYP6N4.js";var v="/public/skills/kane-cli";function C(){try{let n=new f().getDefaultEnv();if(n in u)return n}catch{}return"prod"}function k(){return`${m(C()).controllerBaseUrl}${v}`}import{readFileSync as S,writeFileSync as E,mkdirSync as g}from"fs";import{join as d}from"path";var h=d(s,"skill-check.json"),y=3600*1e3;function V(){try{let n=JSON.parse(S(h,"utf-8"));if(Date.now()-n.checkedAt<y)return n}catch{}return null}function A(n){try{g(s,{recursive:!0}),E(h,JSON.stringify({map:n,checkedAt:Date.now()}))}catch{}}function I(){for(let{dir:n}of a)try{let t=S(d(n,"VERSION"),"utf-8").trim();if(t)return t}catch{}return null}function M(n,t){let i=Object.keys(n.versions??{});if(i.length===0)return null;let o=i.slice().sort((r,e)=>l(r,e));for(let r of o){let e=n.versions[r]?.kaneCliMinVersion;if(!e||l(t,e)<=0)return r}return null}async function U(){try{let n=V()?.map;if(!n){let o=new AbortController,r=setTimeout(()=>o.abort(),5e3),e=await p(k(),{headers:{Accept:"application/json"},signal:o.signal});if(clearTimeout(r),!e.ok)return null;n=await e.json(),A(n)}let t=M(n,c);if(!t)return null;let i=I();return i===null?{current:null,latestCompatible:t}:l(i,t)>0?{current:i,latestCompatible:t}:null}catch{return null}}export{k as a,M as b,U as c};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{b as f}from"./chunk-3CKFCRIC.js";import{x as t}from"./chunk-LTEYP6N4.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};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{homedir as e}from"os";import{join as t}from"path";var m="0.4.3",d="kane-cli",a=t(e(),".testmuai","kaneai"),g=t(a,"profiles"),h=t(a,"tui-config.json"),_="https://registry.npmjs.org/@testmuai/kane-cli",L="https://api.github.com/repos/LambdaTest/kane-cli/releases",n="@testmuai/kane-cli-skill",x=`https://registry.npmjs.org/${n}`,r="kane-cli",A=[{dir:t(e(),".claude","skills",r),agent:"Claude Code"},{dir:t(e(),".agents","skills",r),agent:"Codex CLI"},{dir:t(e(),".gemini","skills",r),agent:"Gemini CLI"}],u="https://dd-proxy.lambdatest.com/intake/kane-cli",R="https://kaneai-playground.lambdatest.io",U=9222,b=9230,I=t(a,"chrome-profiles"),o=t(a,"hints"),C=t(o,"state.json");function E(s){return t(o,`catalog-${s}.json`)}var p="127.0.0.1",T=18392,S=18400,c="/callback";function N(s){return`http://${p}:${s}${c}`}var P="KANE CLI",B="*",O={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"}},k={orange:"#ff9500",generateAccent:"#0d9488",purple:"#b388ff",secondary:"#888888",dim:"#666666",muted:"#444444",green:"#4ade80",red:"#ef4444"};export{m as a,d as b,a as c,h as d,_ as e,L as f,n as g,A as h,u as i,R as j,U as k,b as l,I as m,C as n,E as o,p,T as q,S as r,c as s,N as t,P as u,B as v,O as w,k as x};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as R}from"./chunk-
|
|
2
|
+
import{a as R}from"./chunk-2EDV5GRD.js";import{x as r}from"./chunk-LTEYP6N4.js";import{a as Y}from"./chunk-HCBYKLMW.js";import{a,b as i,i as X}from"./chunk-C44QQJR4.js";import{a as G}from"./chunk-6YGTRKDT.js";import{e as P}from"./chunk-UR6MHSHU.js";var u=P(G(),1);var e=P(Y(),1),f=5;function K(t,I){if(!I)return t;let c=I.toLowerCase();return t.filter(B=>B.label.toLowerCase().includes(c))}function J(t){let{title:I,items:c,loading:B=!1,loadingText:F,error:L=null,itemNoun:T="items",onSelect:H,onCancel:E,defaultActiveId:w,onTab:y,extraHint:N}=t,[x,d]=(0,u.useState)(0),[S,g]=(0,u.useState)(0),[s,A]=(0,u.useState)(""),[C,h]=(0,u.useState)(null);(0,u.useEffect)(()=>{if(c.length===0)return;if(t.preserveSelectionById&&C!==null){let n=c.findIndex(o=>o.id===C);if(n>=0){g(Math.floor(n/f)),d(n%f);return}}let l=w?c.findIndex(n=>n.id===w):c.findIndex(n=>n.isActive);l>=0?(g(Math.floor(l/f)),d(l%f),t.preserveSelectionById&&h(c[l].id)):t.preserveSelectionById&&(g(0),d(0),h(c[0]?.id??null))},[c,w,t.preserveSelectionById,C]),(0,u.useEffect)(()=>{if(!t.onSearch)return;let l=setTimeout(()=>t.onSearch(s),t.searchDebounceMs??250);return()=>clearTimeout(l)},[s,t.onSearch,t.searchDebounceMs]);let m=t.onSearch?c:K(c,s),M=S*f,p=Math.min(M+f,m.length),D=Math.ceil(m.length/f),O=p-M,v=m.slice(M,p);return X((l,n)=>{if(L){n.escape&&E();return}if(n.escape){s?(A(""),d(0),g(0)):E();return}if(n.tab&&y){y();return}if(n.upArrow){if(x>0){let o=x-1;d(o),t.preserveSelectionById&&h(v[o]?.id??null)}else if(S>0){let o=S-1,b=f-1;g(o),d(b),t.preserveSelectionById&&h(m[o*f+b]?.id??null)}return}if(n.downArrow){if(x<O-1){let o=x+1;d(o),t.preserveSelectionById&&h(v[o]?.id??null)}else if(S<D-1){let o=S+1,b=0;g(o),d(b),t.preserveSelectionById&&h(m[o*f+b]?.id??null)}return}if(n.return&&v[x]){H(v[x]);return}if(n.backspace||n.delete){A(o=>o.slice(0,-1)),d(0),g(0);return}l&&!n.ctrl&&!n.meta&&(A(o=>o+l),d(0),g(0))},{isActive:!B}),B?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(i,{color:r.orange,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(i,{color:r.secondary,children:F??`Loading ${T}\u2026`})})]}):L?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.red,paddingX:2,paddingY:1,children:[(0,e.jsx)(i,{color:r.red,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(i,{color:r.red,children:L})}),(0,e.jsx)(R,{bindings:[]})]}):(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(i,{color:r.orange,bold:!0,children:I}),(0,e.jsxs)(i,{color:r.dim,children:[" (",m.length,!t.onSearch&&s?`/${c.length}`:""," ",T,t.loadingMore?" \xB7 loading more":"",")"]})]}),(0,e.jsxs)(a,{marginTop:1,children:[(0,e.jsx)(i,{color:r.secondary,children:s?"filter: ":""}),s?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(i,{children:s}),(0,e.jsx)(i,{inverse:!0,children:" "})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(i,{color:r.dim,children:["Search ",T,"\u2026"]}),(0,e.jsx)(i,{inverse:!0,children:" "})]})]}),(0,e.jsx)(a,{flexDirection:"column",marginTop:1,children:t.searching?(0,e.jsxs)(i,{color:r.secondary,children:["Searching ",T,"\u2026"]}):m.length===0?(0,e.jsxs)(i,{color:r.dim,children:["No ",T,' match "',s,'"']}):v.map((l,n)=>{let o=n===x,b=o?"\u276F ":" ",$=l.isActive?r.green:o?r.orange:void 0;return(0,e.jsxs)(i,{color:$,children:[b,l.label,l.isActive?" \u25CF selected":""]},l.id)})}),!t.searching&&D>1&&(0,e.jsx)(a,{marginTop:1,children:(0,e.jsxs)(i,{color:r.dim,children:["Page ",S+1,"/",D]})}),t.footer&&(0,e.jsx)(a,{marginTop:1,flexDirection:"column",children:t.footer}),(0,e.jsx)(R,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"type",label:"to search"},{keys:"\u21B5",label:"select"},...y&&N?[{keys:"tab",label:N}]:[]],escBackLabel:s?"clear":"back to chat"})]})}export{J as a};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{w as s}from"./chunk-LTEYP6N4.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};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{b as Le}from"./chunk-EBTYHLMG.js";import{a as de,b as je}from"./chunk-3CKFCRIC.js";import{d as Oe,f as pe}from"./chunk-LOIRZFV3.js";import{a as Pe}from"./chunk-P6ZOLQ6M.js";import{a as Ce}from"./chunk-Z36MHRFD.js";import{b as _e}from"./chunk-C6S4IEBC.js";import{x as l}from"./chunk-LTEYP6N4.js";import{a as N}from"./chunk-HCBYKLMW.js";import{a as u,b as i,i as Ee,j as ke,k as xe}from"./chunk-C44QQJR4.js";import{a as le}from"./chunk-6YGTRKDT.js";import{e as j}from"./chunk-UR6MHSHU.js";var te=j(le(),1);var q=j(le(),1);var D=j(le(),1);function fe(e,n){let s=null,c=(g,p)=>{for(let d=0;d<g.length;d++){let o=g[d],w=[...p,d];n(o)&&(s===null||w.length>s.length)&&(s=w),o.children&&o.children.length>0&&c(o.children,w)}};return c(e,[]),s}function me(e,n,s){if(n.length===0)return[...e];let c=n[0],g=[...e],p=g[c];if(n.length===1)g[c]=s(p);else{let d=n.slice(1),o=me(p.children??[],d,s);g[c]={...p,children:o}}return g}function Te(e){let n=e.indexOf(": ");return n>0&&n<15?e.slice(n+2):e}function Be(e){return e.map(n=>{let s=n.children?Be(n.children):n.children;return n.status==="running"?{...n,status:"stopped",phase:void 0,children:s}:s!==n.children?{...n,children:s}:n})}function De(e,n,s,c){let[g,p]=(0,D.useState)(!1),[d,o]=(0,D.useState)([]),[w,I]=(0,D.useState)(null),[k,_]=(0,D.useState)(null),[U,S]=(0,D.useState)(null),[v,B]=(0,D.useState)(null),[O,Q]=(0,D.useState)([]),[G,ne]=(0,D.useState)(null),[se,ge]=(0,D.useState)(void 0),K=(0,D.useRef)(null),H=(0,D.useRef)(null),Z=(0,D.useRef)(0),ee=(0,D.useRef)(!1),h=(0,D.useCallback)(async(x,A)=>{let re=K.current;if(re){try{await re.exited}catch{}K.current=null}o([]),I(null),_(null),S(null),B(null),Q([]),ne(null),ge(x.max_steps),p(!0),H.current=null,Z.current=0;let F;try{F=Le(x,A)}catch(X){S(X instanceof Error?X.message:String(X)),p(!1);return}K.current=F,Oe("runner",()=>F.cancel()),(async()=>{ee.current=!1;let X=!1;for await(let t of F.events){if(ee.current)break;switch(t.type){case"run_start":if(t.child_id)break;if(H.current&&!H.current.isSingleFlow){let E=Z.current;Z.current++,o(C=>C.map((b,T)=>T===E?{...b,status:"running"}:b.status==="running"&&!b.children?.some(a=>a.status==="running")?{...b,status:b.children?.some(a=>a.status==="failed")?"failed":"passed"}:b))}break;case"bifurcation":{let E=t.flows??[],C=t.count??E.length,b={flows:E,isSingleFlow:t.is_single_flow??C<=1};B(b),H.current=b,Z.current=0,o(E.map((T,a)=>({index:a+1,objective:T??`Flow ${a+1}`,status:"pending"})));break}case"step_start":{n?.("STEP_START",`Step ${t.index} started`,{index:t.index,objective:t.objective,child_id:t.child_id});let E=t.index,C=t.objective??`Step ${E}`,b=t.child_id,T=H.current&&!H.current.isSingleFlow;if(b)o(a=>{let f=fe(a,$=>$.branchChildId===b)??fe(a,$=>$.status==="running");return f?me(a,f,$=>{let L=($.children??[]).map(V=>V.status==="running"&&V.childId===b?{...V,status:"stopped",phase:void 0}:V);return L.push({index:E,objective:C,status:"running",childId:b}),{...$,children:L}}):a});else if(T){let a=Math.max(0,Z.current-1);o(f=>{let $=[...f];if(a>=$.length)return f;let L={...$[a]},ce=[...L.children??[]].map(he=>he.status==="running"&&he.childId===void 0?{...he,status:"stopped",phase:void 0}:he);return ce.push({index:E,objective:C,status:"running"}),L.children=ce,L.status="running",$[a]=L,$})}else o(a=>{let f=Be(a);return f.some(L=>L.index===E)?f.map(L=>L.index===E?{...L,status:"running",objective:C}:L):[...f,{index:E,objective:C,status:"running"}]});break}case"step_event":{n?.("STEP_EVENT",`Step ${t.index} ${t.event}`,{index:t.index,phase:t.event,action_type:t.action_type,detail:t.detail,child_id:t.child_id});let E=t.child_id,C=H.current&&!H.current.isSingleFlow;if(t.event==="cm_init"&&t.checkpoint_count!=null){Q(b=>[...b,t.checkpoint_count]);break}if(t.event==="replay_started"){ne({recordingLength:t.recording_length??0});break}if(t.event==="reasoning"&&t.detail&&t.detail!=="reasoning"&&s?.(t.detail),E){let b=a=>{if(a.index!==t.index||a.childId!==E)return a;let f={phase:t.event};return t.event==="reasoning"&&t.detail&&t.detail!=="reasoning"&&(f.objective=t.detail),t.action_type&&(f.actionType=t.action_type),{...a,...f}},T=a=>a.map(f=>{let $=b(f);return $!==f?$:f.children&&f.children.length>0?{...f,children:T(f.children)}:f});o(a=>a.map(f=>f.children?{...f,children:T(f.children)}:f))}else if(C){let b=Math.max(0,Z.current-1);o(T=>{let a=[...T];if(b>=a.length)return T;let f={...a[b]},$=[...f.children??[]];if(!$.some(V=>V.index===t.index&&V.childId===void 0))$.push({index:t.index,objective:`Step ${t.index}`,status:"running",phase:t.event,actionType:t.action_type});else for(let V=0;V<$.length;V++){if($[V].index!==t.index||$[V].childId!==void 0)continue;let ce={phase:t.event};t.event==="reasoning"&&t.detail&&t.detail!=="reasoning"&&(ce.objective=t.detail),t.action_type&&(ce.actionType=t.action_type),$[V]={...$[V],...ce}}return f.children=$,a[b]=f,a})}else o(b=>b.some(a=>a.index===t.index)?b.map(a=>{if(a.index!==t.index)return a;let f={phase:t.event};return t.event==="reasoning"&&t.detail&&t.detail!=="reasoning"&&(f.objective=t.detail),t.action_type&&(f.actionType=t.action_type),{...a,...f}}):[...Be(b),{index:t.index,objective:`Step ${t.index}`,status:"running",phase:t.event,actionType:t.action_type}]);break}case"step_end":{n?.("STEP_END",`Step ${t.index} ${t.status}`,{index:t.index,status:t.status,duration:t.duration,summary:t.summary,child_id:t.child_id}),c?.();let E=t.child_id,C=H.current&&!H.current.isSingleFlow;if(E){let b=a=>a.index===t.index&&a.childId===E?{...a,status:t.status,duration:t.duration,phase:void 0,objective:a.objective.startsWith("Step ")?Te(t.summary||a.objective):a.objective}:a,T=a=>a.map(f=>{let $=b(f);return $!==f?$:f.children&&f.children.length>0?{...f,children:T(f.children)}:f});o(a=>a.map(f=>f.children?{...f,children:T(f.children)}:f))}else if(C){let b=Math.max(0,Z.current-1);o(T=>{let a=[...T];if(b>=a.length)return T;let f={...a[b]},$=(f.children??[]).map(L=>L.index===t.index&&L.childId===void 0?{...L,status:t.status,duration:t.duration,phase:void 0,objective:L.objective.startsWith("Step ")?Te(t.summary||L.objective):L.objective}:L);return f.children=$,a[b]=f,a})}else o(b=>b.map(T=>T.index===t.index?{...T,status:t.status,duration:t.duration,phase:void 0,objective:T.objective.startsWith("Step ")?Te(t.summary||T.objective):T.objective}:T));{let T=H.current&&!H.current.isSingleFlow?Math.max(0,Z.current-1):0;e?.(t.index,T,t.child_id)}break}case"child_agent_start":{let E=t.objective??"",C=t.child_id;o(b=>{let T=fe(b,a=>a.status==="running");return T?me(b,T,a=>({...a,objective:`${E} (branch)`,phase:`child: ${E.slice(0,50)}`,branchObjective:E,branchChildId:C})):b});break}case"child_agent_end":{let E=t.child_id,C=`child ${t.success?"done":"failed"}`;o(b=>{let T=fe(b,a=>a.branchChildId===E);return T?me(b,T,a=>({...a,phase:C})):b.map(a=>a.phase?.startsWith("child:")?{...a,phase:C}:a)});break}case"ask_user":I(t.question??"");break;case"run_end":o(E=>E.map(C=>C.status==="running"?{...C,status:t.status,phase:void 0}:C)),p(!1),_(t),X=!0;break;case"error":p(!1),S(t.message??"Runner error"),o(E=>E.map(C=>C.status==="running"?{...C,status:"failed",phase:void 0}:C));break}}let{code:ie,signal:ve}=await F.exited,ye=F.stderr,Xe=ie===0&&!ve,ue=[];ie!==null&&ie!==0&&ue.push(`Runner exited with code ${ie}`),ve&&ue.push(`Runner killed by signal ${ve}`),ye&&(!Xe||!X?ue.push(ye):A?.log?.("debug","RUNNER_STDERR_BENIGN","Runner stderr on clean exit",{stderr:ye})),K.current===F&&(ue.length>0&&S(ue.join(`
|
|
3
|
+
`)),p(!1),pe("runner","Event stream ended"),K.current=null)})().catch(X=>{let ie=[`Runner event loop error: ${X}`];F.exitCode!==null&&F.exitCode!==0&&ie.push(`Exit code: ${F.exitCode}`),F.exitSignal&&ie.push(`Signal: ${F.exitSignal}`),F.stderr&&ie.push(F.stderr),K.current===F&&(S(ie.join(`
|
|
4
|
+
`)),p(!1),pe("runner","Event loop error"),K.current=null)})},[e,n,s,c]),y=(0,D.useCallback)(x=>{K.current?.sendUserResponse(x),I(null)},[]),R=(0,D.useCallback)(()=>{let x=K.current;x&&(x.sendCancel("user"),p(!1),I(null),setTimeout(()=>{K.current===x&&(pe("runner","User cancelled run"),K.current=null)},5e3))},[]),m=(0,D.useCallback)(()=>{o([]),_(null),S(null)},[]);return(0,D.useEffect)(()=>()=>{ee.current=!0,pe("runner","Component unmounted"),K.current=null},[]),{isRunning:g,steps:d,askingUser:w,lastRunEnd:k,runError:U,bifurcationInfo:v,cmInitCounts:O,replayInfo:G,maxSteps:se,startRun:h,sendAnswer:y,cancelRun:R,clearLastRun:m}}function we(e){let n=e.flatMap(p=>[p,...p.children??[]]),s=n.filter(p=>p.status==="passed").length,c=n.filter(p=>p.status==="failed").length,g=n.filter(p=>p.status==="passed"||p.status==="failed").length;return{passed:s,failed:c,total:g}}function Fe(e){let n=De(e.screenshotDispatcher,e.stepLogger,e.onReasoning,e.onStepComplete),[s,c]=(0,q.useState)(0),[g,p]=(0,q.useState)("idle"),d=(0,q.useRef)("idle"),o=(0,q.useRef)(0),w=(0,q.useRef)(!1),I=(0,q.useRef)(null),k=(0,q.useRef)(null),_=(0,q.useCallback)(v=>{d.current=v,p(v)},[]),U=(0,q.useCallback)(async v=>{let B=await e.getNextConfig(v);if(!B){_("done"),e.onAllComplete?.();return}let O=v?o.current+1:0;o.current=O,c(O),e.onStepStart?.(B,O),I.current=null,k.current=null,_("running"),await n.startRun(B,e.spawnOpts)},[n,e,_]);(0,q.useEffect)(()=>{w.current||(w.current=!0,U(null))},[]),(0,q.useEffect)(()=>{if(!n.lastRunEnd||n.lastRunEnd===I.current||d.current!=="running")return;I.current=n.lastRunEnd,d.current="transitioning",p("transitioning");let v=n.lastRunEnd,B=we(n.steps),O=n.bifurcationInfo,Q={status:v.status==="passed"?"passed":"failed",duration_s:v.duration??0,reason:v.reason,runEnd:v,hadError:!1,stepsPassed:B.passed,stepsFailed:B.failed,stepsTotal:B.total,bifurcationFlows:O&&!O.isSingleFlow?O.flows:null};if(!(e.onStepEnd?.(Q,o.current)??!0)){_("done"),e.onAllComplete?.();return}U(Q)},[n.lastRunEnd]),(0,q.useEffect)(()=>{if(!n.runError||n.runError===k.current||n.lastRunEnd||d.current!=="running")return;k.current=n.runError,d.current="transitioning",p("transitioning");let v=we(n.steps),B={status:"failed",duration_s:0,reason:n.runError,runEnd:null,hadError:!0,stepsPassed:v.passed,stepsFailed:v.failed,stepsTotal:v.total,bifurcationFlows:null};if(!(e.onStepEnd?.(B,o.current)??!0)){_("done"),e.onAllComplete?.();return}U(B)},[n.runError,n.lastRunEnd]);let S=(0,q.useCallback)(()=>{n.cancelRun()},[n]);return{runner:n,currentStepIndex:s,phase:g,cancel:S}}var Ie=j(le(),1);var be=j(N(),1),Ae=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function Me({label:e,hasBifurcation:n=!1}){let[s,c]=(0,Ie.useState)(0),[g,p]=(0,Ie.useState)(0);de(()=>{c(o=>(o+1)%Ae.length)},80),de(()=>{p(o=>(o+1)%4)},400);let d=e??(n?"Planning approach":"Analyzing objective");return(0,be.jsxs)(u,{marginLeft:1,children:[(0,be.jsxs)(i,{color:l.orange,children:[Ae[s]," "]}),(0,be.jsxs)(i,{color:l.dim,children:[d,".".repeat(g+1)]})]})}function Ne(e){if(!e.isRunning||e.replayInfo)return null;let n=e.bifurcationInfo;if(n&&!n.isSingleFlow){let s=e.steps.findIndex(g=>g.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:!!n}}var M=j(le(),1);var Ue=j(le(),1);var Re=j(N(),1),Ye="#ffc580",Je="#ffd9a8",qe="#ffffff";function Ge({text:e,active:n=!0}){let[s,c]=(0,Ue.useState)(0),g=4;if(de(()=>{c(d=>(d+1)%(e.length+g*2))},n?80:null),!n)return(0,Re.jsx)(i,{color:qe,children:e});let p=e.split("").map((d,o)=>{let w=s-g,I=Math.abs(o-w-g/2),k;return I<=g/2?k=Ye:I<=g?k=Je:k=qe,(0,Re.jsx)(i,{color:k,children:d},o)});return(0,Re.jsx)(i,{children:p})}var z=j(N(),1),Qe={starting:l.orange,running:l.orange,passed:l.green,failed:l.red,cancelled:l.dim,timed_out:l.orange};function Se({currentStep:e,maxSteps:n,elapsed:s,status:c}){let{stdout:g}=xe(),p=g?.columns??80,d=Qe[c]??l.orange,o=s<60?`${s.toFixed(1)}s`:`${Math.floor(s/60)}m ${Math.round(s%60)}s`;return(0,z.jsxs)(u,{flexDirection:"column",marginTop:1,children:[(0,z.jsx)(i,{color:l.muted,children:"\u2500".repeat(Math.min(p,60))}),(0,z.jsxs)(u,{children:[(0,z.jsx)(i,{children:" "}),(0,z.jsx)(i,{color:l.dim,children:"Steps "}),(0,z.jsx)(i,{bold:!0,children:e}),(0,z.jsxs)(i,{color:l.dim,children:["/",n]}),(0,z.jsx)(i,{children:" "}),(0,z.jsx)(i,{color:l.dim,children:"Elapsed "}),(0,z.jsx)(i,{bold:!0,children:o}),(0,z.jsx)(i,{children:" "}),(0,z.jsx)(i,{color:l.dim,children:"Status "}),(0,z.jsx)(i,{bold:!0,color:d,children:c})]})]})}var Ze={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 Ke(e){return Ze[e]??"\u25CF"}var oe=j(N(),1);function $e({steps:e,flows:n,cmInitCounts:s,renderStep:c}){return(0,oe.jsxs)(u,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[(0,oe.jsxs)(i,{color:l.dim,children:["\u2501\u2501 Bifurcated into ",n?.length??e.length," flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"]}),e.map((g,p)=>(0,oe.jsxs)(u,{flexDirection:"column",marginTop:p>0?1:0,children:[(0,oe.jsxs)(i,{color:l.orange,children:["Flow ",p+1,": ",n?.[p]??g.objective]}),s&&s[p]!=null&&(0,oe.jsxs)(i,{color:l.dim,children:[" \u25AA Generated task with ",s[p]," checkpoints"]}),g.children&&g.children.length>0?g.children.map(d=>{let o=!!d.branchObjective,w=`f${p}-${d.childId??"p"}-${d.index}`;return o?(0,oe.jsxs)(u,{flexDirection:"column",children:[c({...d,children:void 0},w),(d.children??[]).map(I=>(0,oe.jsx)(u,{marginLeft:2,children:c(I,`${w}-${I.childId??"p"}-${I.index}`)},`${w}-${I.childId??"p"}-${I.index}`))]},`${w}-host`):c(d,w)}):g.status==="pending"&&(0,oe.jsx)(i,{color:l.dim,children:" \u25CB Waiting..."})]},p))]})}var r=j(N(),1);function W({step:e,indent:n=2}){let s=e.actionType?Ke(e.actionType):null,c=e.status==="running",g=e.status==="passed",p=e.status==="failed",d=e.status==="pending"||e.status==="stopped",{stdout:o}=xe(),w=o?.columns??80,I=Math.max(20,w-n-21),k=e.objective??"",_=k.length>I?k.slice(0,I-1)+"\u2026":k,U=(e.duration??0)*1e3,S=e.duration!=null?U<1e3?`${Math.round(U)}ms`:`${(U/1e3).toFixed(1)}s`:"";return(0,r.jsxs)(u,{flexDirection:"column",children:[(0,r.jsxs)(u,{marginLeft:n,children:[(0,r.jsx)(u,{width:4,children:(0,r.jsxs)(i,{color:l.muted,children:[String(e.index).padStart(2," ")," "]})}),(0,r.jsx)(u,{width:3,children:c?(0,r.jsx)(je,{}):g?(0,r.jsx)(i,{color:l.green,bold:!0,children:"\u2713"}):p?(0,r.jsx)(i,{color:l.red,bold:!0,children:"\u2717"}):(0,r.jsx)(i,{color:l.muted,children:"\u25CB"})}),(0,r.jsx)(u,{flexGrow:1,children:c?(0,r.jsx)(Ge,{text:_,active:!0}):p?(0,r.jsx)(i,{color:l.red,children:_}):d?(0,r.jsx)(i,{color:l.dim,children:_}):(0,r.jsx)(i,{color:l.dim,children:_})}),(g||p)&&s?(0,r.jsx)(u,{width:3,marginLeft:1,children:(0,r.jsx)(i,{color:l.muted,children:s})}):(0,r.jsx)(u,{width:3,marginLeft:1}),(0,r.jsx)(u,{width:7,justifyContent:"flex-end",children:(0,r.jsx)(i,{color:l.dim,children:S})})]}),e.children&&e.children.length>0&&(0,r.jsx)(u,{flexDirection:"column",children:e.children.map((v,B)=>(0,r.jsx)(W,{step:v,indent:n+2},`child-${B}`))})]})}function et(e){return e.type==="cm_init"?(0,r.jsx)(u,{marginLeft:2,paddingLeft:1,children:(0,r.jsxs)(i,{color:l.dim,children:["\u25AA Generated task with ",e.count," checkpoints"]})}):(0,r.jsx)(u,{marginLeft:2,paddingLeft:1,children:(0,r.jsx)(W,{step:e.step})})}function We({steps:e,bifurcated:n,flows:s,cmInitCounts:c,maxSteps:g=50,staticSteps:p=!1,onStepCommit:d}){let o=(0,M.useRef)(new Set),w=(0,M.useRef)(!1),I=(0,M.useRef)(new Set),k=(0,M.useRef)(!1),_=(0,M.useRef)(new Set),U=(0,M.useRef)(0);(0,M.useEffect)(()=>{e.length===0&&U.current>0&&(o.current.clear(),w.current=!1,I.current.clear(),k.current=!1,_.current.clear()),U.current=e.length},[e.length]);let S=e.flatMap(h=>[h,...h.children??[]]),v=S.some(h=>h.status==="running"),B=S.some(h=>h.status==="failed"),O=S.length===0||S.every(h=>h.status==="pending"),Q=S.filter(h=>h.status==="passed"||h.status==="failed").length,G;O?G="starting":v?G="running":B?G="failed":G="passed";let ne=(0,M.useRef)(null),[se,ge]=(0,M.useState)(0);(0,M.useEffect)(()=>{S.length===0||O?(ne.current=null,ge(0)):v&&ne.current==null&&(ne.current=Date.now())},[v,O,S.length]),(0,M.useEffect)(()=>{if(!v)return;let h=setInterval(()=>{ne.current!=null&&ge((Date.now()-ne.current)/1e3)},500);return()=>clearInterval(h)},[v]);let K=(0,M.useRef)(new Set),[,H]=(0,M.useState)(0),Z=(0,M.useRef)(!1);(0,M.useEffect)(()=>{if(!d||!p||n)return;let h=[];!Z.current&&c&&c[0]!=null&&(Z.current=!0,c[0]>0&&h.push({key:"cm_init_0",type:"cm_init",count:c[0]}));for(let y of e)(y.status==="passed"||y.status==="failed")&&!K.current.has(y.index)&&(K.current.add(y.index),h.push({key:`step_${y.index}`,type:"step",step:{...y,children:y.children?[...y.children]:void 0}}));if(h.length>0){for(let y of h)d(et(y));H(y=>y+1)}},[e,n,c,p,d]),(0,M.useEffect)(()=>{if(!d||p)return;let h=o.current.size;if(!n&&!k.current&&c&&c[0]!=null&&(k.current=!0,c[0]>0&&d((0,r.jsx)(u,{marginLeft:2,children:(0,r.jsxs)(i,{color:l.dim,children:["\u25A0 Generated task with ",c[0]," checkpoints"]})}))),n&&s&&!w.current&&(w.current=!0,d((0,r.jsx)(i,{color:l.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"}))),n){let y=e.flatMap((R,m)=>{let x=R.children??[];return!I.current.has(m)&&x.length>0&&(I.current.add(m),d((0,r.jsx)(i,{color:l.purple,children:" Flow "+(m+1)+": "+(s?.[m]??"")})),c?.[m]!=null&&c[m]>0&&!_.current.has(m)&&(_.current.add(m),d((0,r.jsx)(u,{marginLeft:2,children:(0,r.jsxs)(i,{color:l.dim,children:[" \u25AA Generated task with ",c[m]," checkpoints"]})})))),c?.[m]!=null&&c[m]>0&&I.current.has(m)&&!_.current.has(m)&&(_.current.add(m),d((0,r.jsx)(u,{marginLeft:2,children:(0,r.jsxs)(i,{color:l.dim,children:[" \u25AA Generated task with ",c[m]," checkpoints"]})}))),x});for(let R of y){let m=`${R.childId??"p"}-${R.index}-${R.objective}`;if(!!R.branchObjective){o.current.has(m)||(o.current.add(m),d((0,r.jsx)(u,{marginLeft:2,children:(0,r.jsx)(W,{step:{...R,children:void 0}})})));for(let A of R.children??[]){let re=`child-${R.childId??"p"}-${R.index}-${A.childId??"p"}-${A.index}-${A.objective}`;o.current.has(re)||(A.status==="passed"||A.status==="failed"||A.status==="stopped")&&(o.current.add(re),d((0,r.jsx)(u,{marginLeft:4,children:(0,r.jsx)(W,{step:A})})))}continue}o.current.has(m)||(R.status==="passed"||R.status==="failed"||R.status==="stopped")&&(o.current.add(m),d((0,r.jsx)(u,{marginLeft:2,children:(0,r.jsx)(W,{step:R})})))}}else for(let y of e){let R=`${y.index}-${y.objective}`,m=!!y.branchObjective;m&&!o.current.has(R)&&(o.current.add(R),d((0,r.jsx)(u,{marginLeft:2,children:(0,r.jsx)(W,{step:{...y,children:void 0}})})));for(let x of y.children??[]){let A=`child-${y.index}-${x.childId??"p"}-${x.index}-${x.objective}`;o.current.has(A)||(x.status==="passed"||x.status==="failed"||x.status==="stopped")&&(o.current.add(A),d((0,r.jsx)(u,{marginLeft:4,children:(0,r.jsx)(W,{step:x})})))}!m&&!o.current.has(R)&&(y.status==="passed"||y.status==="failed"||y.status==="stopped")&&(o.current.add(R),d((0,r.jsx)(u,{marginLeft:2,children:(0,r.jsx)(W,{step:{...y,children:void 0}})})))}o.current.size>h&&H(y=>y+1)},[e,d,n,s,c]);let ee=[];if(p&&!n)for(let h of e)K.current.has(h.index)||ee.push(h);else if(d&&!p)if(n)for(let h of e){let y=h.children??[],R=[];for(let m of y){let x=`${m.childId??"p"}-${m.index}-${m.objective}`,A=o.current.has(x);if(m.branchObjective){let re=(m.children??[]).filter(F=>{let X=`child-${m.childId??"p"}-${m.index}-${F.childId??"p"}-${F.index}-${F.objective}`;return!o.current.has(X)});(!A||re.length>0)&&R.push({...m,children:re})}else A||R.push(m)}R.length>0&&ee.push({...h,children:R})}else for(let h of e){let y=`${h.index}-${h.objective}`,R=o.current.has(y),m=(h.children??[]).filter(x=>{let A=`child-${h.index}-${x.childId??"p"}-${x.index}-${x.objective}`;return!o.current.has(A)});R?m.length>0&&ee.push({...h,children:m}):ee.push({...h,children:m})}if(!p){let h=d?ee:e;return(0,r.jsxs)(u,{flexDirection:"column",children:[n?d?h.length>0?(0,r.jsx)(u,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:h.map((R,m)=>(0,r.jsx)(u,{flexDirection:"column",marginTop:m>0?1:0,children:R.children&&R.children.length>0?R.children.map(x=>{let A=!!x.branchObjective,re=`${x.childId??"p"}-${x.index}-${x.objective}`,F=o.current.has(re);return A?(0,r.jsxs)(u,{flexDirection:"column",children:[!F&&(0,r.jsx)(W,{step:{...x,children:void 0}}),(x.children??[]).map(X=>(0,r.jsx)(u,{marginLeft:2,children:(0,r.jsx)(W,{step:X})},`f${m}-${x.index}-${X.childId??"p"}-${X.index}`))]},`f${m}-host-${x.childId??"p"}-${x.index}`):(0,r.jsx)(W,{step:x},`f${m}-${x.childId??"p"}-${x.index}`)}):R.status==="pending"&&(0,r.jsx)(i,{color:l.dim,children:" \u25CB Waiting..."})},m))}):null:(0,r.jsx)($e,{steps:e,flows:s,cmInitCounts:c,renderStep:(R,m)=>(0,r.jsx)(W,{step:R},m)}):(0,r.jsxs)(u,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[!d&&c&&c[0]!=null&&(0,r.jsxs)(i,{color:l.dim,children:["\u25AA Generated task with ",c[0]," checkpoints"]}),h.map(R=>{let m=`${R.index}-${R.objective}`;return d&&o.current.has(m)?(0,r.jsx)(u,{flexDirection:"column",children:(R.children??[]).map(x=>(0,r.jsx)(u,{marginLeft:2,children:(0,r.jsx)(W,{step:x})},`${x.childId??"p"}-${x.index}`))},`branch-children-${R.index}`):(0,r.jsx)(W,{step:R},R.index)})]}),v&&(0,r.jsx)(Se,{currentStep:Q,maxSteps:g,elapsed:se,status:G})]})}return n?(0,r.jsxs)(u,{flexDirection:"column",children:[(0,r.jsx)($e,{steps:e,flows:s,cmInitCounts:c,renderStep:(h,y)=>(0,r.jsx)(W,{step:h},y)}),v&&(0,r.jsx)(Se,{currentStep:Q,maxSteps:g,elapsed:se,status:G})]}):(0,r.jsxs)(u,{flexDirection:"column",children:[ee.length>0&&(0,r.jsx)(u,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:ee.map(h=>(0,r.jsx)(W,{step:h},h.index))}),v&&(0,r.jsx)(Se,{currentStep:Q,maxSteps:g,elapsed:se,status:G})]})}var ae=j(N(),1);function He({runner:e,runKey:n,onStepCommit:s}){let c=Ne({isRunning:e.isRunning,bifurcationInfo:e.bifurcationInfo,steps:e.steps,cmInitCounts:e.cmInitCounts,replayInfo:e.replayInfo});return(0,ae.jsxs)(ae.Fragment,{children:[c&&(0,ae.jsx)(Me,{label:c.label,hasBifurcation:c.hasBifurcation}),e.isRunning&&e.steps.length>0&&(0,ae.jsx)(We,{steps:e.steps,bifurcated:!!e.bifurcationInfo&&!e.bifurcationInfo.isSingleFlow,flows:e.bifurcationInfo?.flows,cmInitCounts:e.cmInitCounts,maxSteps:e.maxSteps,onStepCommit:s},`run-${n}`)]})}var Y=j(N(),1),tt=64;function nt(e){return e.split(`
|
|
5
|
+
`).map(n=>n.replace(/^[-–•]\s*/,"").trim()).filter(n=>n.length>0)}function Ve({status:e,summary:n,duration:s,steps:c,stepsPassed:g,stepsFailed:p,reason:d,creditsConsumed:o}){let w=e==="passed",I=w?l.green:l.red,k=w?"\u2713":"\u2717",_=e.toUpperCase(),U=g??(w?c:Math.max(0,c-1)),S=p??(w?0:1),v=S>0?`${c} steps (${U} passed, ${S} failed)`:`${c} steps`,B=s<60?`${s.toFixed(1)}s`:`${Math.floor(s/60)}m ${Math.round(s%60)}s`,O=nt(n);return(0,Y.jsx)(u,{flexDirection:"column",marginTop:1,children:(0,Y.jsxs)(u,{borderStyle:"round",borderColor:I,flexDirection:"column",paddingX:2,paddingY:1,width:tt+6,children:[(0,Y.jsxs)(u,{flexDirection:"column",children:[(0,Y.jsxs)(i,{bold:!0,color:I,children:[k," ",_]}),(0,Y.jsxs)(i,{color:l.dim,wrap:"wrap",children:[v," \xB7 ",B,typeof o=="number"&&o>0?` \xB7 ${parseFloat(o.toFixed(4))} credits`:""]})]}),O.length>0&&(0,Y.jsx)(u,{flexDirection:"column",marginTop:1,marginLeft:1,children:O.map((Q,G)=>(0,Y.jsxs)(u,{marginBottom:G<O.length-1?1:0,children:[(0,Y.jsx)(i,{color:l.orange,children:"\u25CF "}),(0,Y.jsx)(u,{flexShrink:1,children:(0,Y.jsx)(i,{wrap:"wrap",children:Q})})]},G))}),d&&!w&&(0,Y.jsx)(u,{marginTop:1,children:(0,Y.jsxs)(i,{color:l.red,wrap:"wrap",children:["Reason: ",d]})})]})})}var J=j(N(),1);function ze({message:e,code:n,remediation:s,docsUrl:c}){return(0,J.jsx)(Ce,{title:"Error",variant:"error",children:(0,J.jsxs)(u,{flexDirection:"column",paddingY:1,children:[(0,J.jsxs)(i,{color:l.red,bold:!0,children:[" \u2717 ",e]}),n&&(0,J.jsxs)(u,{marginTop:0,marginLeft:5,children:[(0,J.jsx)(i,{color:l.muted,children:"Code: "}),(0,J.jsx)(i,{color:l.dim,children:n})]}),s&&(0,J.jsxs)(u,{flexDirection:"column",marginTop:1,marginLeft:5,children:[(0,J.jsx)(i,{color:l.green,bold:!0,children:"Fix:"}),(0,J.jsxs)(i,{color:l.orange,children:["$ ",s]})]}),c&&(0,J.jsxs)(u,{marginTop:1,marginLeft:5,children:[(0,J.jsx)(i,{color:l.muted,children:"Docs: "}),(0,J.jsx)(i,{color:l.orange,underline:!0,children:c})]})]})})}var P=j(N(),1);function sn(e){let{exit:n}=ke(),{append:s}=_e(),c=(0,te.useRef)(!1);(0,te.useEffect)(()=>{c.current||(c.current=!0,s((0,P.jsx)(u,{flexDirection:"column",marginBottom:1,children:(0,P.jsxs)(u,{borderStyle:"round",borderColor:"#dc4e08",paddingX:2,children:[(0,P.jsx)(i,{color:"#ff9500",bold:!0,children:"KaneAI CLI"}),(0,P.jsx)(i,{color:l.dim,children:" \u2502 "}),(0,P.jsx)(i,{color:l.orange,children:e.topBanner.model}),(0,P.jsx)(i,{color:l.dim,children:" \u2502 "}),(0,P.jsx)(i,{color:l.dim,children:e.topBanner.auth})]})})),s((0,P.jsx)(rt,{data:e.globalConfig})),e.priorAttemptRollup&&s((0,P.jsx)(i,{color:l.dim,children:` \u21B3 replayed ${e.priorAttemptRollup.startIdx}..${e.priorAttemptRollup.endIdx-1} (${e.priorAttemptRollup.count} steps, from prior attempt)`})))},[]);let g=(0,te.useRef)(null),p=(0,te.useCallback)(async S=>{let v=await e.getNextStep(S);return v?(g.current=v,v.config):(g.current=null,null)},[e]),d=(0,te.useCallback)((S,v)=>{let B=g.current;if(!B)return;let O=B.mode==="replay"?"cyan":"#dc4e08",Q=B.modeReason?` (${B.modeReason})`:"",G=B.perStepOverrides?Object.entries(B.perStepOverrides):[];s((0,P.jsxs)(u,{flexDirection:"column",marginBottom:0,children:[(0,P.jsxs)(i,{children:[(0,P.jsxs)(i,{color:l.dim,children:[B.banner.stepLabel," "]}),(0,P.jsxs)(i,{color:O,children:["[",B.mode,"]"]}),(0,P.jsx)(i,{color:l.dim,children:Q})]}),(0,P.jsx)(i,{color:l.dim,children:B.banner.objective}),G.length>0&&(0,P.jsxs)(i,{color:l.dim,children:["overrides: ",G.map(([ne,se])=>`${ne}=${se}`).join(", ")]})]}))},[s]),o=(0,te.useRef)(0),w=(0,te.useRef)(!1),I=(0,te.useCallback)((S,v)=>(S.hadError?s((0,P.jsx)(ze,{message:S.reason??"Runner error",code:"RUNNER_ERROR"})):s((0,P.jsx)(u,{flexDirection:"column",marginBottom:1,children:(0,P.jsx)(Ve,{status:S.status,summary:S.runEnd?.summary??"",duration:S.runEnd?.duration??0,steps:S.stepsTotal,stepsPassed:S.stepsPassed,stepsFailed:S.stepsFailed,reason:S.runEnd?.reason,creditsConsumed:S.runEnd?.credits_consumed})})),e.onStepEnd?.(S,v)??!0),[s,e]),k=Fe({getNextConfig:p,onStepStart:d,onStepEnd:I,onAllComplete:()=>{e.onAllComplete(),e.exitOnComplete!==!1&&setImmediate(()=>n())},screenshotDispatcher:e.screenshotDispatcher,stepLogger:e.stepLogger,onReasoning:e.onReasoning,onStepComplete:e.onStepComplete,spawnOpts:e.spawnOpts}),_=250,U=5e3;return Ee((S,v)=>{if(v.ctrl&&S==="c"){let B=Date.now(),O=B-o.current;if(O<_)return;w.current&&O<U?(k.cancel(),e.onCancel?.(),e.exitOnComplete!==!1&&setImmediate(()=>n())):(w.current=!0,s((0,P.jsx)(i,{color:"yellow",children:"press Ctrl+C again to cancel run"}))),o.current=B}}),(0,P.jsx)(u,{flexDirection:"column",children:k.phase!=="done"&&(0,P.jsx)(He,{runner:k.runner,runKey:k.currentStepIndex,onStepCommit:s})})}function rt({data:e}){return(0,P.jsx)(Pe,{title:"test.md run",titleColor:"#ff9500",borderColor:l.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{We as a,Me as b,Ne as c,De as d,we as e,Ve as f,ze as g,sn as h};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as f}from"./chunk-FPFOW6BS.js";import{a as h}from"./chunk-
|
|
2
|
+
import{a as f}from"./chunk-FPFOW6BS.js";import{a as h}from"./chunk-OERW4FRV.js";import{a as d}from"./chunk-MDUS66QI.js";var o=class extends Error{constructor(a,l){super(a);this.code=l;this.name="AuthError"}};async function k(c){let{creds:i,env:a,usernameFlag:l,accessKeyFlag:g,log:t}=c,e=null,u=null;if(l&&g)e={username:l,access_key:g},t("info","AUTH_RESOLVE_FLAGS","Auth resolved via CLI flags",{username:l});else{let r=i.resolveAuth();r?.method==="basic"&&(e={username:r.username,access_key:r.access_key},t("info","AUTH_RESOLVE_CONFIG","Auth resolved via config",{username:r.username}))}if(!e){let{credentials:r,profile:E}=i.getActiveCredentials();if(!r)throw new o("Not authenticated \u2014 no credentials found","not_authenticated");if(u=r.access_token,r.expires_at-Date.now()/1e3<300)try{let n=await h({creds:i,profile:E,env:a,credentials:r});n&&(u=n.accessToken,t("info","AUTH_TOKEN_REFRESHED","OAuth token refreshed"))}catch(n){let m=n instanceof Error?n.message:String(n);throw t("error","TOKEN_REFRESH_FAILED","Token refresh failed",{error:m}),new o(`Token refresh failed: ${m}`,"refresh_failed")}}let v=d(a),b=async()=>u,y=e?{username:e.username,access_key:e.access_key}:null,p=new f(v.controllerBaseUrl,b,y,t),s=await p.resolve();return s&&!e&&(e={username:s.username,access_key:s.access_key},t("info","AUTH_RESOLVE_CONTROLLER","Auth resolved via controller",{username:s.username})),{basicAuth:e,token:u,resolver:p,resolvedCreds:s}}export{o as a,k as b};
|
|
@@ -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-RVK7MDEV.js";async function l(e){let o=e.credentials.expires_at,i=e.thresholdSeconds??300;if(o-Date.now()/1e3>=i)return null;let r=e.creds.loadClient(e.profile,e.env);if(!r)return null;let n=await new t(e.env).refreshToken(e.credentials.refresh_token,r.client_id),s=Math.floor(Date.now()/1e3)+n.expires_in;return e.creds.saveCredentials(e.profile,e.env,{access_token:n.access_token,refresh_token:n.refresh_token,expires_at:s,scope:n.scope}),{accessToken:n.access_token,refreshToken:n.refresh_token,expiresAt:s,scope:n.scope}}export{l as a};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as u,b as x}from"./chunk-
|
|
2
|
+
import{a as u,b as x}from"./chunk-Z36MHRFD.js";import{x as m}from"./chunk-LTEYP6N4.js";import{a as f}from"./chunk-HCBYKLMW.js";import{a as r,b as i}from"./chunk-C44QQJR4.js";import{e as n}from"./chunk-UR6MHSHU.js";var e=n(f(),1);function C({title:B,titleColor:c,borderColor:d,variant:p,rows:s,footer:t,labelWidth:l=14,marginBottom:b=1}){return(0,e.jsxs)(u,{title:B,titleColor:c,borderColor:d,variant:p,marginBottom:b,children:[s.map((o,a)=>typeof o.value=="string"?(0,e.jsx)(x,{label:o.label,value:o.value,valueColor:o.valueColor,labelWidth:l},`${o.label}-${a}`):(0,e.jsxs)(r,{children:[(0,e.jsx)(r,{width:l,children:(0,e.jsx)(i,{color:m.dim,children:o.label})}),o.value]},`${o.label}-${a}`)),t&&(0,e.jsx)(r,{marginTop:1,children:t})]})}export{C as a};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as $}from"./chunk-D5P5DM3Y.js";import{b as D}from"./chunk-EBTYHLMG.js";import{a as E}from"./chunk-NLCCBXXV.js";function U(e){return["completed","failed","ended","stopped"].includes(e.trim().toLowerCase())}function je(e){return["ended","stopped"].includes(e.trim().toLowerCase())}function q(e){return{requestId:e.requestId,objective:e.objective,status:"",turnActive:!1,scenarios:[],thinking:"",thinkingLog:[],chatLog:[],progress:0}}function Re(e){return e.pendingClarification===void 0?e:{...e,pendingClarification:void 0}}function Ce(e){return{...e,turnActive:!0,error:void 0,thinking:"",thinkingLog:[]}}function P(e,t){switch(t.type){case"thinking":return{...e,status:"thinking",thinking:e.thinking+t.delta};case"thinking_done":return{...e,thinkingLog:[...e.thinkingLog,{text:e.thinking,tookMs:t.tookMs}],thinking:""};case"progress":return{...e,progress:t.pct};case"snapshot":return{...e,scenarios:t.data.scenarios,status:t.data.status,headline:t.data.headline??e.headline};case"chat":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}]};case"clarification":return{...e,turnActive:!1,chatLog:[...e.chatLog,{role:"model",text:t.text}],pendingClarification:t.text};case"limit":return{...e,limits:{scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit}};case"error":return{...e,error:t.message};case"done":return{...e,status:t.status,turnActive:!1,error:t.status==="failed"&&!e.error?"generation failed":e.error}}}function H(e,t){let n=[],i=e.type??"",l=e.status??"";if(i==="ping")return n;switch(i){case"thinking_token":typeof e.data=="string"&&n.push({type:"thinking",delta:e.data});break;case"thinking_stopped":{let r=e.data??{},o=se(r.time_taken);n.push({type:"thinking_done",text:typeof e.data=="string"?e.data:r.message??"",tookMs:o});break}case"progress":{let r=e.data??{};typeof r.progress=="number"&&n.push({type:"progress",pct:r.progress});break}case"clarification":{let r=e.data??{};typeof r.message=="string"&&n.push({type:"clarification",text:r.message});break}case"chatting_stopped":{let r=e.data??{};typeof r.message=="string"&&r.message.length>0&&n.push({type:"chat",text:r.message});break}case"limit_update":{let r=e.data??{},o=r.test_cases_limit??e.test_cases_limit,p=r.per_scenario_test_cases_limit??e.per_scenario_test_cases_limit;n.push({type:"limit",scenarioLimit:o,perScenarioLimit:p});break}case"error":{let r=typeof e.data=="string"?e.data:e.data?.message??"generation error";n.push({type:"error",message:r});break}case"request_cancelled":return n.push({type:"done",status:"stopped"}),n;case"session_ended":return n.push({type:"done",status:"ended"}),n;default:break}if(Array.isArray(e.scenarios)&&n.push({type:"snapshot",data:{requestId:t,status:l,headline:e.headline,scenarios:e.scenarios}}),l&&U(l)){let r=l.trim().toLowerCase();n.push({type:"done",status:r})}return n}function se(e){if(!e)return;let t=/^([\d.]+)(ms|s)?$/.exec(e.trim());if(!t)return;let n=Number(t[1]);if(Number.isFinite(n))return t[2]==="ms"?Math.round(n):Math.round(n*1e3)}var v=class extends Error{constructor(t){super(t),this.name="AuthError"}},M=class extends Error{constructor(t){super(t),this.name="ForbiddenError"}},I=class extends Error{constructor(t){super(t),this.name="InsufficientCreditsError"}},k=class extends Error{constructor(n,i){super(n);this.cause=i;this.name="TransportError"}};function x(e,t){let n=t?.message??t?.error??`HTTP ${e}`;return e===401?new v(n):e===403?t?.key==="insufficient_credits"?new I(n):new M(n):new k(n)}async function*J(e){let t=e.fetchImpl??fetch,n=e.maxRetries??5,i=e.maxBackoffMs??3e4,l=e.connectTimeoutMs??1e4,r=0,o=!1;for(;;){if(e.signal.aborted)return;let p=new AbortController,a=()=>p.abort();e.signal.addEventListener("abort",a,{once:!0});let c=setTimeout(()=>p.abort(),l),h;try{h=await t(e.url,{method:"GET",headers:{Authorization:await e.authHeader(),Accept:"text/event-stream"},signal:p.signal})}catch(w){if(clearTimeout(c),e.signal.removeEventListener("abort",a),e.signal.aborted)return;if(++r>n)throw new k("SSE connect failed",w);await O(F(r,i));continue}if(clearTimeout(c),!h.ok){e.signal.removeEventListener("abort",a);let w=await oe(h);if(h.status===401&&o){if(++r>n)throw x(401,w);await O(F(r,i));continue}throw x(h.status,w)}if(!h.body)throw e.signal.removeEventListener("abort",a),new k("SSE response had no body");o=!0,r=0;let g=h.body.getReader(),m=new TextDecoder("utf-8"),b="";try{for(;;){if(e.signal.aborted){await g.cancel().catch(()=>{});return}let{done:w,value:s}=await g.read();if(w)break;b+=m.decode(s,{stream:!0});let f;for(;(f=b.indexOf(`
|
|
3
|
+
|
|
4
|
+
`))>=0;){let u=b.slice(0,f);b=b.slice(f+2);let d=ie(u);d&&(yield d)}}}catch(w){if(e.signal.aborted)return;if(++r>n)throw new k("SSE stream dropped",w);await O(F(r,i));continue}finally{e.signal.removeEventListener("abort",a)}return}}function ie(e){let t="message",n="";for(let i of e.split(`
|
|
5
|
+
`))i.startsWith("event:")?t=i.slice(6).trim():i.startsWith("data:")&&(n+=i.slice(5).trim());if(t!=="message"||!n)return null;try{let i=Buffer.from(n,"base64").toString("utf-8");return JSON.parse(i)}catch{return null}}function F(e,t){return Math.min(t,1e3*2**(e-1))}function O(e){return new Promise(t=>setTimeout(t,e))}async function oe(e){try{return await e.clone().json()}catch{return}}function W(e,t){t?.length&&(e.append("files",t.map(n=>n.fileKey).join(",")),e.append("gemini_metadata",JSON.stringify(t.map(n=>({fileData:{fileUri:n.geminiUri,mimeType:n.mimeType}})))))}function Ue(e,t={}){let n=t.fetchImpl??fetch,i=new Map,l=!0;async function r(){let s=await e.authResolver.resolve();if(!s)throw new v("unauthorized; run `kane-cli login`");return E(s.username,s.access_key)}function o(s){return`${e.baseUrl}${s}`}async function p(s){if(!s.ok){let f;try{f=await s.clone().json()}catch{f=void 0}throw x(s.status,f)}return s.json()}function a(s){let f=s?.data??s;return{request_id:f.request_id??f.id,status:f.status??""}}function c(s,f,u,d){let y=q({requestId:s,objective:f});d&&(y=P(y,{type:"snapshot",data:d}),d.status==="cleaned_up"&&(y={...y,error:"session was reaped (cleaned_up) \u2014 continuing will destructively regenerate"}));let S=new AbortController;u&&(u.aborted?S.abort():u.addEventListener("abort",()=>S.abort(),{once:!0})),i.set(s,S);let A={requestId:s,state:y,events:void 0};return A.events=(async function*(){try{let C=J({url:o(`/requests/${s}/sse`),authHeader:r,signal:S.signal,log:e.log,fetchImpl:n});for await(let L of C)for(let z of H(L,s))A.state=P(A.state,z),yield z}finally{i.delete(s)}})(),A}async function h(s,f){let u=new FormData;u.append("prompt",s.prompt),l=s.memoryEnhancement??!0,u.append("memory_enhancement",String(l)),s.scenarioLimit!==void 0&&u.append("test_scenario_limit",String(s.scenarioLimit)),s.perScenarioLimit!==void 0&&u.append("per_scenario_test_cases_limit",String(s.perScenarioLimit));let d=s.projectId??e.projectId,y=s.folderId??e.folderId;d&&u.append("project_id",d),y&&u.append("folder_id",y),W(u,s.attachments);let S=await n(o("/requests"),{method:"POST",headers:{Authorization:await r()},body:u}),A=await p(S),{request_id:C}=a(A),L=String(C);return c(L,s.prompt,f)}async function g(s,f){let u=await n(o(`/requests/${s}`),{method:"GET",headers:{Authorization:await r()}}),d=await p(u),y=d?.data??d,S={requestId:s,status:y.status??"",headline:y.headline,scenarios:Array.isArray(y.scenarios)?y.scenarios:[]};return c(s,"",f,S)}async function m(s,f,u){let d=new FormData;d.append("prompt",f),d.append("chat_enabled","true"),d.append("memory_enhancement",String(l)),u?.mappings&&d.append("mappings",JSON.stringify(u.mappings)),W(d,u?.attachments);let y=await n(o(`/requests/${s}`),{method:"PUT",headers:{Authorization:await r()},body:d});if(!y.ok){let S;try{S=await y.clone().json()}catch{}throw x(y.status,S)}}async function b(s){i.get(s)?.abort();let u=await n(o(`/requests/${s}/stop`),{method:"DELETE",headers:{Authorization:await r()}});if(!u.ok&&u.status!==404){let d;try{d=await u.clone().json()}catch{}throw x(u.status,d)}}async function w(s){i.get(s)?.abort();let u=await n(o(`/requests/${s}/end`),{method:"DELETE",headers:{Authorization:await r()}});if(!u.ok&&u.status!==404){let d;try{d=await u.clone().json()}catch{}throw x(u.status,d)}}return{start:h,attach:g,chat:m,cancel:b,end:w}}import{statSync as ae,realpathSync as G,existsSync as ce}from"fs";import{extname as ue,resolve as j,isAbsolute as pe}from"path";import{homedir as V}from"os";var le=new Set([".txt",".json",".xml",".jpg",".jpeg",".png",".gif",".bmp",".webp",".pdf",".docx",".csv",".xlsx",".mp3",".wav",".m4a",".webm",".mpeg",".mpga",".mp4",".mov"]),de=50*1024*1024,X=10;function fe(e){return e==="~"?V():e.startsWith("~/")?j(V(),e.slice(2)):e}function Ge(e,t){let n=[],i=[],l=new Set,r=[],o=(()=>{try{return G(j(t))}catch{return j(t)}})(),p=o.endsWith("/")?o:o+"/";for(let a of e){let c=fe(a),h=pe(c)?c:j(t,c);if(!ce(h)){n.push(`Not found: ${a}`);continue}let g;try{g=G(h)}catch{n.push(`Cannot resolve: ${a}`);continue}if(l.has(g))continue;let m;try{m=ae(g)}catch{n.push(`Cannot read: ${a}`);continue}if(!m.isFile()){n.push(`Not a file: ${a}`);continue}if(m.size===0){n.push(`Empty file: ${a}`);continue}let b=ue(g).toLowerCase();if(!le.has(b)){n.push(`Unsupported type ${b||"(none)"}: ${a}`);continue}if(m.size>de){n.push(`Too large (>50MB): ${a}`);continue}g!==o&&!g.startsWith(p)&&i.push(`Outside working dir: ${a}`),l.add(g),r.push(g)}return r.length>X&&n.push(`Too many files: ${r.length} (max ${X})`),{ok:n.length?[]:r,errors:n,warnings:i}}var B=class extends Error{constructor(n){super(n.join("; "));this.errors=n;this.name="AttachmentValidationError"}};async function Xe(e){let{promptText:t,filePaths:n,cwd:i,scenarios:l,isRefine:r,conn:o,deps:p}=e,{ok:a,errors:c,warnings:h}=p.validate(n,i);if(c.length)throw new B(c);e.onValidated?.();let g=a.length?await p.upload(o,a,p.onUpload):[],m=r?p.buildMappings(t,l):void 0;return{promptText:t,mappings:m,attachments:g,warnings:h}}import{readFile as me}from"fs/promises";import{basename as K}from"path";async function ge(e){let t=await e.authResolver.resolve();if(!t)throw new v("unauthorized; run `kane-cli login`");return E(t.username,t.access_key)}async function he(e,t,n={}){let i=n.fetchImpl??fetch,l=await me(t),r=K(t),o=new FormData;o.append("file",new Blob([l]),r),o.append("source","omniBox"),o.append("geminiFileUpload","true");let p=await i(`${e.tmsBaseUrl}/v1/attachment`,{method:"POST",headers:{Authorization:await ge(e)},body:o,signal:n.signal});if(!p.ok){let m;try{m=await p.clone().json()}catch{}throw x(p.status,m)}let a=await p.json(),c=a?.data??a,h=c?.gemini_response?.uri,g=c?.gemini_response?.mimeType;if(!c?.file_key||!h){let m=c&&typeof c=="object"?Object.keys(c).join(","):typeof c,b=(()=>{try{return JSON.stringify(c).slice(0,500)}catch{return"<unserializable>"}})();throw new Error(`attachment upload for ${r} returned no file_key/gemini uri \u2014 status ${p.status}, body keys: [${m}], raw: ${b}`)}return{fileName:c.file_name??r,fileKey:c.file_key,geminiUri:h,mimeType:g??"application/octet-stream"}}async function tt(e,t,n,i={}){let l=[];for(let r=0;r<t.length;r++){if(i.signal?.aborted)throw Object.assign(new Error("upload aborted"),{name:"AbortError"});let o=K(t[r]);n?.({file:o,index:r+1,total:t.length,status:"uploading"});try{l.push(await he(e,t[r],i)),n?.({file:o,index:r+1,total:t.length,status:"done"})}catch(p){throw n?.({file:o,index:r+1,total:t.length,status:"failed"}),p}}return l}var ye=/@([sS])(\d+)\.([cC])(\d+)/g,be=/@([sS])(\d+)(?!\d)(?!\.[cC]\d)/g;function rt(e,t){let n={},i={};for(let l of e.matchAll(ye)){let r=Number(l[2]),o=Number(l[4]),p=t[r-1];if(!p)continue;n[`s${r}`]=String(p.id);let a=p.test_cases??[];if(a[o-1])for(let c=0;c<o;c++){let h=a[c];h&&(i[`s${r}.c${c+1}`]=String(h.id))}}for(let l of e.matchAll(be)){let r=Number(l[2]),o=t[r-1];o&&(n[`s${r}`]=String(o.id))}if(!(Object.keys(n).length===0&&Object.keys(i).length===0))return{scenario:n,testcase:i}}function R(e){if(!Array.isArray(e))return[];let t=[];for(let n of e){if(n==null||typeof n!="object")return[];let i=n;if(typeof i.step!="string")return[];let l=typeof i.expected_result=="string"?i.expected_result:typeof i.outcome=="string"?i.outcome:"";t.push({step:i.step,expected:l})}return t}var we=30,Se=300;function Z(){return{mode:"testing",max_steps:we,timeout:Se,variables:{}}}function Q(e){return e.title??`Test case ${e.id}`}function ct(e,t){return $({frontmatter:Z(),heading:Q(t),steps:e.sub_objectives.map(n=>n.objective)})}function Y(e){let t=R(e.manual_steps).map(n=>n.step);return $({frontmatter:Z(),heading:Q(e),steps:t})}import{mkdtempSync as xe,mkdirSync as N,writeFileSync as ee,rmSync as te,renameSync as _e,existsSync as ne,readFileSync as ve}from"fs";import{join as _,resolve as ke}from"path";async function ft(e,t,n,i=Y){(n.redirectBareCwd??!0)&&ke(t)===process.cwd()&&(t=_(t,".testmuai","tests"));let l=T(e.objective)??e.headline,r=T(n.suiteName)??`${T(re(l,4))??"tcg"}-${e.requestId}`,o=r,p=_(t,r);ne(p)&&!Te(p,e.requestId)&&(o=`${r}-${e.requestId}`);let a=_(t,o),c=[],h=new Map;for(let m of e.scenarios){let b=(m.test_cases??[]).filter(Ae);if(b.length===0)continue;let w=T(Ee(m.scode))??T(m.sid)??`s${m.id}`,s=h.get(w)??new Set;h.set(w,s);for(let f of b){let u=T(re(f.title,5))??"case",d=`${u}_test.md`;for(let y=2;s.has(d);y++)d=`${u}-${y}_test.md`;s.add(d),c.push({dir:w,file:d,tc:f})}}if(c.length===0)return{suiteDir:a,paths:[],warning:"no functional test cases generated"};N(t,{recursive:!0});let g=xe(_(t,".tcg-tmp-"));try{N(_(g,"helpers"),{recursive:!0}),ee(_(g,".tcg-suite.json"),JSON.stringify({requestId:e.requestId,suiteName:o}));let m=[],b=new Set;for(let s of c){let f=_(g,s.dir);b.has(f)||(N(f,{recursive:!0}),b.add(f));let u=_(f,s.file);ee(u,i(s.tc)),m.push(u)}ne(a)&&te(a,{recursive:!0,force:!0}),_e(g,a);let w=m.map(s=>s.replace(g,a));return{suiteDir:a,paths:w}}catch(m){try{te(g,{recursive:!0,force:!0})}catch{}throw m}}function Ae(e){return(e.category??"").trim().toLowerCase()==="functional"}function Te(e,t){try{return JSON.parse(ve(_(e,".tcg-suite.json"),"utf-8"))?.requestId===t}catch{return!1}}function T(e){return e&&e.length>0?e:void 0}function re(e,t){return e?e.toLowerCase().replace(/[^a-z0-9]+/g," ").trim().split(/\s+/).filter(Boolean).slice(0,t).join("-"):""}function Ee(e){return e?e.replace(/[^A-Za-z0-9._-]+/g,"-").replace(/^-+|-+$/g,""):""}function ht(e){let t=[];e.title&&t.push(e.title),e.description&&t.push("",e.description);let n=R(e.manual_steps);return n.length>0&&(t.push("","Steps:"),n.forEach((i,l)=>{t.push(`${l+1}. ${i.step}`)})),t.join(`
|
|
6
|
+
`).trim()}function wt(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 St(e,t,n){let i=D(e,t),l=()=>i.cancel();n?.addEventListener("abort",l);let r=null,o=null;try{for await(let p of i.events)if(p.type==="bifurcation_result"){let a=p,c=a.sub_objectives??[];r={sub_objectives:c,extracted_variables:a.extracted_variables??{},total_flows:a.total_flows??c.length,is_single_flow:a.is_single_flow??c.length<=1,credits_consumed:a.credits_consumed??0}}else p.type==="error"&&(o=p.message??"bifurcation error")}finally{n?.removeEventListener("abort",l),i.cancel()}if(r)return r;throw new Error(o??"bifurcation produced no result")}export{U as a,je as b,q as c,Re as d,Ce as e,P as f,v as g,Ue as h,R as i,ct as j,Y as k,ft as l,Ae as m,ht as n,wt as o,St as p,le as q,Ge as r,B as s,Xe as t,tt as u,rt as v};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as c}from"./chunk-
|
|
2
|
+
import{a as c}from"./chunk-MDUS66QI.js";import{a as n}from"./chunk-RZ4F3BHX.js";import{u as s,v as a}from"./chunk-LTEYP6N4.js";import{createHash as h,randomBytes as g}from"crypto";var l=class{authBaseUrl;consentUrl;constructor(t="prod"){let e=c(t);this.authBaseUrl=e.authBaseUrl,this.consentUrl=e.consentUrl}static generatePkce(){let t=g(96).toString("base64url").slice(0,128),e=h("sha256").update(t).digest("base64url");return[t,e]}buildAuthorizationUrl(t,e,r,o){let i=new URLSearchParams({response_type:"code",client_id:t,redirect_uri:o,scope:a,code_challenge:e,code_challenge_method:"S256",state:r});return`${this.consentUrl}/oauth2?${i.toString()}`}async registerClient(t){let e=await n(`${this.authBaseUrl}/oauth2/register`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({client_name:s,redirect_uris:[t],grant_types:["authorization_code"],response_types:["code"],client_type:"public",application_type:"native"})});if(!e.ok)throw new Error(`DCR failed: ${e.status} ${await e.text()}`);return e.json()}async exchangeCode(t,e,r,o){let i=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"authorization_code",code:t,redirect_uri:o,client_id:e,code_verifier:r})});if(!i.ok)throw new Error(`Token exchange failed: ${i.status}`);return i.json()}async refreshToken(t,e){let r=await n(`${this.authBaseUrl}/oauth2/token`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({grant_type:"refresh_token",refresh_token:t,client_id:e})});if(!r.ok)throw new Error(`Token refresh failed: ${r.status}`);return r.json()}async revokeToken(t,e,r="access_token"){await n(`${this.authBaseUrl}/oauth2/revoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({token:t,token_type_hint:r,client_id:e})})}async validateToken(t){let e=new AbortController,r=setTimeout(()=>e.abort(),1e4);try{let o=await n(`${this.authBaseUrl}/api/user`,{headers:{Authorization:`Bearer ${t}`,Accept:"application/json","Content-Type":"application/json"},signal:e.signal});return clearTimeout(r),o.ok}catch{return clearTimeout(r),!1}}};export{l as a};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as k}from"./chunk-FPFOW6BS.js";import{g as a}from"./chunk-LOIRZFV3.js";import{a as m}from"./chunk-LPUQ4HWQ.js";import{a as h}from"./chunk-
|
|
2
|
+
import{a as k}from"./chunk-FPFOW6BS.js";import{g as a}from"./chunk-LOIRZFV3.js";import{a as m}from"./chunk-LPUQ4HWQ.js";import{a as h}from"./chunk-UN7QP7YJ.js";import{a as y}from"./chunk-MDUS66QI.js";var $=10,u=200,N=1e4,S=1e6;function T(t,e,r="streaming"){let n=r==="full-fetch"?S:N,o=$,i=0;if(t!==void 0){let s=Number(t);if(!Number.isInteger(s)||s<1||s>u)return{error:`--limit must be an integer in [1, ${u}] (got "${t}")`};o=s}if(e!==void 0){let s=Number(e);if(!Number.isInteger(s)||s<0||s>n)return{error:`--offset must be an integer in [0, ${n}] (got "${e}")`};i=s}return{limit:o,offset:i}}function C(t,e){if(!e)return t;let r=e.toLowerCase();return t.filter(n=>n.name.toLowerCase().includes(r))}function j(t,{limit:e,offset:r}){let n=t.slice(r,r+e),o=t.length>r+e;return{slice:n,hasMore:o}}function v(t,e,r=n=>process.stdout.write(`${n}
|
|
3
3
|
`)){for(let n of t)r(JSON.stringify(n));r(JSON.stringify({_meta:"page",limit:e.limit,offset:e.offset,returned:t.length,has_more:e.has_more}))}function b(t,e,r=n=>process.stdout.write(`${n}
|
|
4
|
-
`)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:d}=await import("./token-refresh-
|
|
4
|
+
`)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:d}=await import("./token-refresh-DKWS73ET.js"),w=await d({creds:n,profile:t,env:e,credentials:i});w&&(s=w.accessToken)}catch(d){return{ok:!1,reason:"refresh_failed",detail:d instanceof Error?d.message:String(d)}}let c=y(e),f=await new k(c.controllerBaseUrl,async()=>s,null).resolve();return f?{ok:!0,creds:{username:f.username,access_key:f.access_key}}:{ok:!1,reason:"exchange_failed"}}function E(t,e,r){switch(r.reason){case"no_credentials":return{message:`error: no credentials for profile "${t}" [${e}]. Run \`kane-cli login\` or pass --username/--access-key.
|
|
5
5
|
`,exitCode:2};case"refresh_failed":return{message:`error: OAuth token refresh failed for profile "${t}" [${e}]${r.detail?`: ${r.detail}`:""}. Run \`kane-cli login\` to re-auth.
|
|
6
6
|
`,exitCode:2};case"exchange_failed":return{message:`error: TMS credential exchange failed for profile "${t}" [${e}]. Token may be revoked \u2014 try \`kane-cli login\`; if the problem persists, TMS may be down.
|
|
7
7
|
`,exitCode:2}}}function O(t){return{id:t.project_id,name:t.name}}function M(t){return{id:t.id,name:t.name}}async function P(t,e,r,n){let o=r+n+1,i=[],s=!0;for await(let c of t.listProjectsStream({name:e})){if(i.push(...c.projects),c.done){s=!0;break}if(i.length>=o){s=!1;break}}return{items:i,doneStreaming:s}}function g(t){return!!t.agent||!process.stdin.isTTY||!process.stdout.isTTY}function _(t,e=r=>process.stdout.write(`${r}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as B}from"./chunk-S3DAAAE5.js";import{a as g}from"./chunk-
|
|
2
|
+
import{b as B}from"./chunk-S3DAAAE5.js";import{a as g}from"./chunk-P6ZOLQ6M.js";import{x as s}from"./chunk-LTEYP6N4.js";import{a as w}from"./chunk-HCBYKLMW.js";import{a as x,b as t,c as h,i as P,j as S}from"./chunk-C44QQJR4.js";import{a as C}from"./chunk-6YGTRKDT.js";import{e as T}from"./chunk-UR6MHSHU.js";var o=T(C(),1);var e=T(w(),1);function D({defaultName:i,onSubmit:c}){let[d,p]=(0,o.useState)("confirm"),[f,a]=(0,o.useState)(""),[m,u]=(0,o.useState)(null),l=(0,o.useMemo)(()=>f.trim()||i,[f,i]);return P((n,r)=>{if(d==="confirm"){if(n==="y"||n==="Y"){a(i),p("name");return}if(n==="n"||n==="N"||r.escape||r.ctrl&&n==="c"){c(null);return}if(r.return){c(i);return}return}if(r.return){if(!B(l)){u(`name "${l}" is invalid; allowed: letters, digits, underscore, hyphen`);return}c(l);return}if(r.escape||r.ctrl&&n==="c"){c(null);return}if(r.backspace||r.delete){a(v=>v.slice(0,-1)),u(null);return}n&&!r.ctrl&&!r.meta&&(a(v=>v+n),u(null))}),d==="confirm"?(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsx)(t,{color:s.orange,children:i})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save with this name"}),(0,e.jsx)(t,{color:s.dim,children:"Y \u2014 edit name"}),(0,e.jsx)(t,{color:s.dim,children:"N/esc \u2014 discard session"})]})}):(0,e.jsx)(g,{title:"Save session?",titleColor:"#ff9500",rows:[{label:"name",value:(0,e.jsxs)(x,{children:[(0,e.jsx)(t,{color:s.orange,children:f}),(0,e.jsx)(t,{inverse:!0,children:" "})]})}],footer:(0,e.jsxs)(x,{flexDirection:"column",children:[m&&(0,e.jsx)(t,{color:s.red,children:m}),(0,e.jsx)(t,{color:s.dim,children:"enter \u2014 save \xB7 esc \u2014 discard"})]})})}function V(){return new Date().toISOString().slice(0,19).replace(/:/g,"-")}async function Y(i){return new Promise(c=>{function d(){let{exit:a}=S(),[m,u]=(0,o.useState)(!1);return(0,o.useEffect)(()=>{if(m){let l=setTimeout(()=>a(),50);return()=>clearTimeout(l)}},[m,a]),(0,e.jsx)(D,{defaultName:i,onSubmit:l=>{c(l),u(!0)}})}let{waitUntilExit:p,unmount:f}=h((0,e.jsx)(d,{}),{stdout:process.stderr,exitOnCtrlC:!1});p().then(()=>{try{f()}catch{}})})}export{D as a,V as b,Y as c};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{c as g}from"./chunk-
|
|
2
|
+
import{c as g}from"./chunk-LTEYP6N4.js";import{readFileSync as o,writeFileSync as h,mkdirSync as u,readdirSync as a,unlinkSync as s,existsSync as l,chmodSync as f}from"fs";import{join as n,dirname as P}from"path";var d=class{baseDir;profilesDir;configFile;constructor(t=g){this.baseDir=t,this.profilesDir=n(t,"profiles"),this.configFile=n(t,"config.json")}readConfig(){try{return JSON.parse(o(this.configFile,"utf-8"))}catch{return{}}}writeConfig(t){u(this.baseDir,{recursive:!0,mode:448}),h(this.configFile,JSON.stringify(t,null,2)+`
|
|
3
3
|
`),f(this.configFile,384)}getActiveProfile(){return this.readConfig().active_profile??null}setActiveProfile(t){let i=this.readConfig();i.active_profile=t,this.writeConfig(i)}getDefaultEnv(){return this.readConfig().default_env??"prod"}setDefaultEnv(t){let i=this.readConfig();i.default_env=t,this.writeConfig(i)}credentialsPath(t,i){return n(this.profilesDir,t,i,"credentials")}clientPath(t,i){return n(this.profilesDir,t,i,"client.json")}basicAuthPath(t,i){return n(this.profilesDir,t,i,"basic-auth")}profileConfigPath(t,i){return n(this.profilesDir,t,i,"profile-config.json")}saveProfileConfig(t,i,r){let e=this.loadProfileConfig(t,i)??{};this.writeSecure(this.profileConfigPath(t,i),{...e,...r})}loadProfileConfig(t,i){try{return JSON.parse(o(this.profileConfigPath(t,i),"utf-8"))}catch{return null}}writeSecure(t,i){try{u(P(t),{recursive:!0,mode:448}),h(t,JSON.stringify(i,null,2)+`
|
|
4
4
|
`),f(t,384)}catch(r){let e=r instanceof Error?r.message:String(r);process.stderr.write(`[auth] Failed to save credentials: ${e}
|
|
5
5
|
`)}}saveCredentials(t,i,r){this.writeSecure(this.credentialsPath(t,i),r)}loadCredentials(t,i){try{return JSON.parse(o(this.credentialsPath(t,i),"utf-8"))}catch{return null}}saveClient(t,i,r){this.writeSecure(this.clientPath(t,i),r)}loadClient(t,i){try{return JSON.parse(o(this.clientPath(t,i),"utf-8"))}catch{return null}}getActiveCredentials(){let t=this.getActiveProfile();if(!t)return{credentials:null,profile:null,env:null};let i=this.getDefaultEnv();return{credentials:this.loadCredentials(t,i),profile:t,env:i}}saveBasicAuth(t,i,r){this.writeSecure(this.basicAuthPath(t,i),r)}loadBasicAuth(t,i){try{return JSON.parse(o(this.basicAuthPath(t,i),"utf-8"))}catch{return null}}deleteBasicAuth(t,i){try{s(this.basicAuthPath(t,i))}catch{}}resolveAuth(){let t=this.getActiveProfile();if(!t)return null;let i=this.getDefaultEnv(),r=this.loadBasicAuth(t,i);return r?{method:"basic",...r,profile:t,env:i}:this.loadCredentials(t,i)?{method:"oauth",profile:t,env:i}:null}listProfiles(){let t=[];try{for(let i of a(this.profilesDir)){let r=n(this.profilesDir,i);try{for(let e of a(r)){let c=n(r,e),v=l(n(c,"credentials")),p=l(n(c,"client.json")),y=l(n(c,"basic-auth"));(v||p||y)&&t.push({profile:i,env:e})}}catch{}}}catch{}return t}deleteProfile(t,i){try{s(this.credentialsPath(t,i))}catch{}if(this.getActiveProfile()===t){let r=this.readConfig();delete r.active_profile,this.writeConfig(r)}}deleteProfileFull(t,i){if(i){try{s(this.credentialsPath(t,i))}catch{}try{s(this.clientPath(t,i))}catch{}try{s(this.basicAuthPath(t,i))}catch{}try{s(this.profileConfigPath(t,i))}catch{}}else try{let r=n(this.profilesDir,t);for(let e of a(r)){try{s(n(r,e,"credentials"))}catch{}try{s(n(r,e,"client.json"))}catch{}try{s(n(r,e,"basic-auth"))}catch{}try{s(n(r,e,"profile-config.json"))}catch{}}}catch{}}};export{d as a};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as $e}from"./chunk-ZS22QC5H.js";import{a as Fe}from"./chunk-FPFOW6BS.js";import{a as ke}from"./chunk-YCCUBQY4.js";import{a as Ke}from"./chunk-VE3SUJMA.js";import{a as Ue}from"./chunk-RVK7MDEV.js";import{a as Oe}from"./chunk-MDUS66QI.js";import{a as de}from"./chunk-2EDV5GRD.js";import{c as Re,x as u}from"./chunk-LTEYP6N4.js";import{a as Z}from"./chunk-HCBYKLMW.js";import{a as x,b as f,h as Le,i as be,k as De}from"./chunk-C44QQJR4.js";import{a as xe}from"./chunk-6YGTRKDT.js";import{e as O}from"./chunk-UR6MHSHU.js";var Ne=O(xe(),1);import{readFileSync as et,writeFileSync as tt,mkdirSync as nt}from"fs";import{dirname as rt,join as We}from"path";var ot=We(Re,"command-history.json"),yt=We(Re,"generate-history.json"),it=200,_e=class{entries;filePath;max;constructor(t=ot,e=it){this.filePath=t,this.max=e,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 e=t.toLowerCase(),i=[];for(let l=this.entries.length-1;l>=0;l--)this.entries[l].toLowerCase().includes(e)&&i.push(this.entries[l]);return i}_load(){try{let t=et(this.filePath,"utf-8"),e=JSON.parse(t);return Array.isArray(e)?e:[]}catch{return[]}}_save(){try{nt(rt(this.filePath),{recursive:!0}),tt(this.filePath,JSON.stringify(this.entries)+`
|
|
3
|
+
`)}catch{}}};function At(r){let t=(0,Ne.useRef)(null);return t.current||(t.current=new _e(r)),t.current}var L=O(xe(),1);var Ie=O(xe(),1);var X=O(Z(),1);function He({history:r,onSelect:t,onClose:e}){let[i,l]=(0,Ie.useState)(""),[a,g]=(0,Ie.useState)(0),v=i?r.search(i).slice(0,8):[];return be((T,d)=>{if(d.escape){e();return}if(d.return){v.length>0&&v[a]?t(v[a]):e();return}if(d.upArrow){g(w=>Math.max(0,w-1));return}if(d.downArrow){g(w=>Math.min(v.length-1,w+1));return}if(d.backspace||d.delete){l(w=>w.slice(0,-1)),g(0);return}T&&!d.ctrl&&!d.meta&&(l(w=>w+T),g(0))}),(0,X.jsxs)(x,{flexDirection:"column",marginLeft:2,borderStyle:"single",paddingX:1,children:[(0,X.jsx)(f,{color:u.muted,bold:!0,children:"reverse search"}),(0,X.jsxs)(x,{gap:1,children:[(0,X.jsx)(f,{color:u.dim,children:"search:"}),(0,X.jsx)(f,{children:i}),(0,X.jsx)(f,{color:u.orange,children:"\u2588"})]}),v.length>0&&(0,X.jsx)(f,{children:" "}),v.map((T,d)=>(0,X.jsx)(x,{marginLeft:2,children:(0,X.jsxs)(f,{color:d===a?u.orange:u.dim,bold:d===a,children:[d===a?"\u25B8 ":" ",T]})},`${d}-${T}`))]})}var ce=O(Z(),1);function Ge({commands:r,selectedIndex:t}){return r.length===0?null:(0,ce.jsx)(x,{flexDirection:"column",marginBottom:0,children:r.map((e,i)=>{let l=i===t;return(0,ce.jsxs)(x,{children:[(0,ce.jsx)(f,{color:l?u.orange:u.dim,children:l?"\u276F ":" "}),(0,ce.jsxs)(f,{color:l?u.orange:void 0,bold:l,children:["/",e.name]}),e.args&&(0,ce.jsxs)(f,{color:u.dim,children:[" ",e.args]}),(0,ce.jsxs)(f,{color:u.dim,children:[" ",e.description]})]},e.name)})})}var Ye=O(xe(),1);var H=O(Z(),1),qe={scenario:"Scenarios",case:"Test Cases",file:"Files"};function Ve(r){let t={scenario:0,case:0,file:0};for(let e of r)t[e.kind]++;return["scenario","case","file"].filter(e=>t[e]>0).map(e=>`${t[e]} ${qe[e]}`).join(" \xB7 ")}var Ee=7;function je({items:r,selectedIndex:t,accent:e=u.orange}){let i=r.length;if(i===0)return null;let l=Math.floor(Ee/2),a=i<=Ee?0:Math.max(0,Math.min(t-l,i-Ee)),g=Math.min(i,a+Ee),v=a,T=i-g;return(0,H.jsxs)(x,{flexDirection:"column",marginBottom:0,children:[v>0&&(0,H.jsx)(x,{children:(0,H.jsx)(f,{color:u.dim,children:` \u22EF ${v} above \u2014 ${Ve(r.slice(0,a))}`})}),r.slice(a,g).map((d,w)=>{let K=a+w,D=K===t,C=w===0||r[K-1].kind!==d.kind;return(0,H.jsxs)(Ye.default.Fragment,{children:[C&&(0,H.jsx)(x,{children:(0,H.jsx)(f,{color:u.dim,children:qe[d.kind]})}),(0,H.jsxs)(x,{children:[(0,H.jsx)(f,{color:D?e:u.dim,children:D?"\u276F ":" "}),(0,H.jsx)(f,{color:D?e:void 0,bold:D,children:d.label})]})]},`${d.kind}:${d.value}:${K}`)}),T>0&&(0,H.jsx)(x,{children:(0,H.jsx)(f,{color:u.dim,children:` \u22EF ${T} more \u2014 ${Ve(r.slice(g))}`})})]})}var ye=O(xe(),1);var st=27,lt=127,at=11;function ct(r){return r>=64&&r<=126}function ut(r,t){r===at&&t({killToEnd:!0,ctrl:!0,raw:String.fromCharCode(r)})}function ft(r,t){r===lt&&t({backspace:!0,meta:!0,raw:"\x1B\x7F"})}function dt(r,t){let e=r.map(l=>String.fromCharCode(l)).join(""),i=/^\[1;([0-9]+)([A-D])$/.exec(e);if(i){let l=parseInt(i[1],10),a=i[2],g={raw:"\x1B"+e};if(l===2)g.shift=!0;else if(l===3)g.meta=!0;else if(l===5)g.ctrl=!0;else return;a==="A"?g.arrowUp=!0:a==="B"?g.arrowDown=!0:a==="C"?g.arrowRight=!0:a==="D"&&(g.arrowLeft=!0),t(g);return}if(e==="[H"||e==="[1~"||e==="[7~"){t({home:!0,raw:"\x1B"+e});return}if(e==="[F"||e==="[4~"||e==="[8~"){t({end:!0,raw:"\x1B"+e});return}if(e==="[3;5~"){t({delete:!0,ctrl:!0,raw:"\x1B"+e});return}if(e==="[3;3~"){t({delete:!0,meta:!0,raw:"\x1B"+e});return}}function mt(r,t){r===72?t({home:!0,raw:"\x1BO"+String.fromCharCode(r)}):r===70&&t({end:!0,raw:"\x1BO"+String.fromCharCode(r)})}function ht(){let r="IDLE",t=[];function e(){r="IDLE",t=[]}return{feed(i,l){for(let a of i)r==="IDLE"?a===st?(r="ESC",t=[]):ut(a,l):r==="ESC"?a===91?(r="CSI",t=[]):a===79?(r="SS3",t=[]):(ft(a,l),e()):r==="CSI"?(t.push(a),ct(a)&&(dt([91,...t],l),e())):r==="SS3"&&(mt(a,l),e())},flushIdle(i){r==="ESC"&&t.length===0&&i({raw:"\x1B"}),e()}}}function ze(r,t={}){let e=(0,ye.useRef)(r);e.current=r;let{stdin:i}=Le();(0,ye.useEffect)(()=>{if(t.isActive===!1||!i)return;let l=ht(),a=null,g=v=>{a&&(clearTimeout(a),a=null);let T=Buffer.isBuffer(v)?v:Buffer.from(v,"binary");l.feed(T,d=>e.current(d)),a=setTimeout(()=>{l.flushIdle(d=>e.current(d)),a=null},50)};return i.on("data",g),()=>{i.removeListener("data",g),a&&clearTimeout(a)}},[t.isActive,i])}var E=O(Z(),1);function gt(r,t){let e=t-1;for(;e>=0&&r[e]!=="@"&&r[e]!==" "&&r[e]!==`
|
|
4
|
+
`;)e--;return e<0||r[e]!=="@"||e>0&&r[e-1]!==" "&&r[e-1]!==`
|
|
5
|
+
`?null:{at:e,query:r.slice(e+1,t).join("")}}var Pe=10;function pt(r){return r.replace(/\x1b?\[200~/g,"").replace(/\x1b?\[201~/g,"").replace(/\r\n/g,`
|
|
6
|
+
`).replace(/\r/g,`
|
|
7
|
+
`).replace(/[\x00-\x08\x0b-\x1f\x7f]/g,"")}function xt(r,t){let e=[],i=0;for(;i<=r.length;){let l=i;for(;l<r.length&&r[l]!==`
|
|
8
|
+
`;)l++;if(i===l)e.push({start:i,end:i});else{let a=i;for(;a<l;){let g=Math.min(a+t,l);e.push({start:a,end:g}),a=g}}if(l>=r.length)break;i=l+1}return e}function bt(r,t,e){if(r.length===0)return 0;if(t>=e.length)return r.length-1;if(e[t]===`
|
|
9
|
+
`){for(let i=r.length-1;i>=0;i--)if(r[i].end===t)return i;return r.length-1}for(let i=0;i<r.length;i++){let l=r[i];if(l.start<=t&&t<l.end)return i}return r.length-1}function Xe(r,t,e,i){let l=xt(r,e);if(l.length===0)return null;let a=bt(l,t,r),g=a+i;if(g<0||g>=l.length)return null;let v=t-l[a].start,T=l[g],d=T.end-T.start;return T.start+Math.min(v,d)}function qt({onSubmit:r,onEscape:t,history:e,placeholder:i="Type an objective or /command...",commands:l,clearSeq:a,submitVerb:g,footerBindings:v,inert:T=!1,clearOnSubmit:d=!0,noHistory:w=!1,accent:K=u.orange,scenarios:D,mentionFiles:C}){let[s,R]=(0,L.useState)([]),[m,h]=(0,L.useState)(0),[W,G]=(0,L.useState)("none"),[ee,M]=(0,L.useState)(-1),V=(0,L.useRef)(""),[ve,ie]=(0,L.useState)(!0),{stdout:te}=De(),se=te?.columns??80,[U,Y]=(0,L.useState)(0),[ne,J]=(0,L.useState)(0),[Ae,Te]=(0,L.useState)([]),[me,he]=(0,L.useState)(null),P=(0,L.useRef)(!1);(0,L.useEffect)(()=>{if(a!==void 0){if(!P.current){P.current=!0;return}R([]),h(0),M(-1),V.current="",ie(!0),G("none"),Y(0)}},[a]);let p=s.join(""),A=(()=>{if(W!=="none"||s.length===0)return"";if(p.startsWith("/")&&l&&p.length>=2){let n=p.slice(1).toLowerCase(),o=l.find(S=>S.name.startsWith(n)&&S.name!==n);return o?`/${o.name}`.slice(p.length):""}if(p.startsWith("/")||w)return"";let c=e.getAll();for(let n=c.length-1;n>=0;n--)if(c[n].startsWith(p)&&c[n]!==p)return c[n].slice(p.length);return""})(),_=(()=>{if(!l||!p.startsWith("/"))return[];let c=p.length>=2?p.slice(1).toLowerCase():"";return c&&l.some(n=>n.name===c)?[]:l.filter(n=>!c||n.name.startsWith(c))})(),k=_.length>0&&p.startsWith("/"),q=!!C||!!(D&&D.length)?gt(s,m):null,Ce=q?q.query:null,re=(()=>{if(!q)return[];let c=q.query.toLowerCase(),n=[];(D??[]).forEach((o,S)=>{let y=`s${S+1}`;(!c||y.includes(c)||(o.title??"").toLowerCase().includes(c))&&n.push({kind:"scenario",value:y,label:`@${y} ${o.title??o.sid??""}`.trim()})}),(D??[]).forEach((o,S)=>{let I=S+1;(o.test_cases??[]).forEach((y,F)=>{let j=`s${I}.c${F+1}`;(!c||j.includes(c)||(y.title??"").toLowerCase().includes(c))&&n.push({kind:"case",value:j,label:`@${j} ${y.title??""}`.trim()})})});for(let o of Ae)n.push({kind:"file",value:o,label:o});return n})(),ge=q!==null&&q.at!==me&&!k&&W==="none"&&re.length>0;(0,L.useEffect)(()=>{if(!C||Ce===null){Te([]);return}let c=!1;return C(Ce).then(n=>{c||Te(n)}).catch(()=>{c||Te([])}),()=>{c=!0}},[Ce,C]),(0,L.useEffect)(()=>{ne>=re.length&&J(0)},[re.length]);let Me=c=>{if(!q)return;let n=c.kind==="file"&&/\s/.test(c.value)?`@"${c.value}"`:`@${c.value}`,o=[...s.slice(0,q.at),...n,...s.slice(m)];R(o),h(q.at+n.length),J(0),he(q.at),ie(!1)};if(be((c,n)=>{if(ve&&c&&ie(!1),n.return){if(ge&&re[ne]){Me(re[ne]);return}if(k&&_[U]){let o=`/${_[U].name}`;w||e.push(o),r(o),R([]),h(0),G("none"),M(-1),V.current="",ie(!0),Y(0);return}p.trim()&&(w||e.push(p.trim()),r(p.trim()),d&&(R([]),h(0),G("none"),M(-1),V.current="",ie(!0),Y(0)));return}if(n.escape){if(ge){he(q.at);return}W!=="none"?G("none"):s.length>0?(R([]),h(0),M(-1),V.current=""):t?.();return}if(n.tab&&!n.shift){if(ge&&re[ne]){Me(re[ne]);return}if(k&&_[U]){let o=`/${_[U].name}`;R([...o]),h(o.length),Y(0);return}if(A){let o=p+A;R([...o]),h(o.length);return}return}if(n.ctrl&&c==="r"){if(w)return;G("search");return}if(n.ctrl&&c==="a"){h(0);return}if(n.ctrl&&c==="e"){h(s.length);return}if(n.ctrl&&c==="w"){if(m===0)return;let o=m-1;for(;o>0&&s[o]===" ";)o--;for(;o>0&&s[o-1]!==" ";)o--;let S=[...s.slice(0,o),...s.slice(m)];R(S),h(o);return}if(n.ctrl&&c==="u"){R([]),h(0),M(-1),G("none");return}if(n.meta&&c==="b"){let o=m-1;for(;o>0&&s[o]===" ";)o--;for(;o>0&&s[o-1]!==" ";)o--;h(Math.max(0,o));return}if(n.meta&&c==="f"){let o=m;for(;o<s.length&&s[o]!==" ";)o++;for(;o<s.length&&s[o]===" ";)o++;h(o);return}if(n.leftArrow){if(n.ctrl||n.shift)return;h(o=>Math.max(0,o-1));return}if(n.rightArrow){if(n.ctrl||n.shift)return;if(m>=s.length&&A){let o=p+A;R([...o]),h(o.length)}else h(o=>Math.min(s.length,o+1));return}if(n.upArrow){if(n.shift)return;if(ge){J(o=>Math.max(0,o-1));return}if(k){Y(o=>Math.max(0,o-1));return}if(W==="none"){let o=Math.max(1,se-2),S=Xe(s,m,o,-1);if(S!==null){h(S);return}if(w)return;let I=e.getAll();if(I.length===0)return;if(ee===-1){V.current=p,M(I.length-1);let y=I[I.length-1];R([...y]),h(y.length)}else if(ee>0){let y=ee-1;M(y);let F=I[y];R([...F]),h(F.length)}}return}if(n.downArrow){if(n.shift)return;if(ge){J(o=>Math.min(re.length-1,o+1));return}if(k){Y(o=>Math.min(_.length-1,o+1));return}if(W==="none"){let o=Math.max(1,se-2),S=Xe(s,m,o,1);if(S!==null){h(S);return}if(w)return;let I=e.getAll();if(ee===-1)return;if(ee<I.length-1){let y=ee+1;M(y);let F=I[y];R([...F]),h(F.length)}else{M(-1);let y=V.current;R([...y]),h(y.length)}}return}if(n.backspace||n.delete){if(n.meta||n.ctrl)return;if(m>0){let o=[...s.slice(0,m-1),...s.slice(m)];R(o),h(m-1),M(-1),Y(0),he(null),J(0)}return}if(c&&!n.ctrl&&!n.meta){let o=pt(c);if(!o)return;let S=[...s.slice(0,m),...o,...s.slice(m)];R(S),h(m+o.length),M(-1),Y(0),he(null),J(0)}},{isActive:!T&&W!=="search"}),ze(c=>{if(c.home){h(0);return}if(c.end){h(s.length);return}if(c.killToEnd){R(s.slice(0,m));return}if(c.arrowLeft&&(c.ctrl||c.meta)){let n=m-1;for(;n>0&&s[n]===" ";)n--;for(;n>0&&s[n-1]!==" ";)n--;h(Math.max(0,n));return}if(c.arrowRight&&(c.ctrl||c.meta)){let n=m;for(;n<s.length&&s[n]!==" ";)n++;for(;n<s.length&&s[n]===" ";)n++;h(n);return}if(c.backspace&&c.meta){if(m===0)return;let n=m-1;for(;n>0&&s[n]===" ";)n--;for(;n>0&&s[n-1]!==" ";)n--;let o=[...s.slice(0,n),...s.slice(m)];R(o),h(n);return}if(c.delete&&(c.ctrl||c.meta)){let n=m;for(;n<s.length&&s[n]===" ";)n++;for(;n<s.length&&s[n]!==" ";)n++;R([...s.slice(0,m),...s.slice(n)]);return}},{isActive:!T&&W!=="search"}),T)return(0,E.jsxs)(x,{flexDirection:"column",children:[(0,E.jsx)(f,{color:u.muted,children:"\u2500".repeat(se)}),(0,E.jsxs)(x,{children:[(0,E.jsx)(f,{color:u.muted,children:"\u276F "}),(0,E.jsx)(f,{color:u.dim,children:i})]}),(0,E.jsx)(de,{bindings:v??[{keys:"ctrl+c",label:"cancel"},{keys:"/cancel",label:"stop turn"},{keys:"ctrl+t",label:"thinking"}],suppressEscBack:!0})]});let Qe=c=>{R([...c]),h(c.length),G("none")},Ze=()=>{G("none")},we=(()=>{if(ve&&s.length===0)return null;let c=m>=s.length,n=s.slice(0,m).join(""),o,S;c?(o=" ",S=""):s[m]===`
|
|
10
|
+
`?(o=" ",S=s.slice(m).join("")):(o=s[m],S=s.slice(m+1).join(""));let I=n+o+S+A,y=n.length,F=y+1,j=F+S.length,Se=Math.max(1,se-2),B=[],oe=0;for(;oe<=I.length;){let N=I.indexOf(`
|
|
11
|
+
`,oe);if(N===-1&&(N=I.length),oe===N)B.push({type:"content",start:oe,end:oe});else{let z=oe;for(;z<N;){let le=Math.min(z+Se,N);B.push({type:"content",start:z,end:le}),z=le}}if(N>=I.length)break;oe=N+1}let Q=Math.max(0,B.findIndex(N=>N.start<=y&&y<=N.end)),fe;if(B.length<=Pe)fe=B;else{let z=Pe-1-4;if(Q<4||Q>=B.length-z)fe=[...B.slice(0,4),{type:"ellipsis",hidden:B.length-4-z},...B.slice(B.length-z)];else{let le=Pe-2,Be=Math.floor(le/2),ae=Q-Be,pe=Q+(le-Be)-1;ae<1&&(pe+=1-ae,ae=1),pe>B.length-2&&(ae-=pe-(B.length-2),pe=B.length-2),ae=Math.max(1,ae),fe=[{type:"ellipsis",hidden:ae},...B.slice(ae,pe+1),{type:"ellipsis",hidden:B.length-pe-1}]}}return{full:I,b:y,c:F,a:j,rows:fe}})();return(0,E.jsxs)(x,{flexDirection:"column",children:[W==="search"&&(0,E.jsx)(He,{history:e,onSelect:Qe,onClose:Ze}),k&&(0,E.jsx)(Ge,{commands:_,selectedIndex:U}),ge&&(0,E.jsx)(je,{items:re,selectedIndex:ne,accent:K}),(0,E.jsx)(f,{color:u.muted,children:"\u2500".repeat(se)}),we===null?(0,E.jsxs)(x,{children:[(0,E.jsx)(f,{color:K,children:"\u276F "}),(0,E.jsx)(f,{inverse:!0,children:" "}),(0,E.jsx)(f,{color:u.dim,children:i})]}):(()=>{let c=we.rows.findIndex(n=>n.type==="content");return(0,E.jsx)(x,{flexDirection:"column",children:we.rows.map((n,o)=>{if(n.type==="ellipsis")return(0,E.jsx)(x,{children:(0,E.jsxs)(f,{color:u.dim,children:[" \u22EF ","(",n.hidden," more line",n.hidden===1?"":"s",")"]})},o);let{full:S,b:I,c:y,a:F}=we,j=n.start,ue=n.end,Se=o===c,B=Se?"\u276F ":" ",oe=Se?K:u.muted,Q=[(0,E.jsx)(f,{color:oe,children:B},"p")];j<Math.min(I,ue)&&Q.push((0,E.jsx)(f,{children:S.slice(j,Math.min(I,ue))},"b"));let fe=Math.max(I,j),N=Math.min(y,ue);fe<N&&Q.push((0,E.jsx)(f,{color:K,inverse:!0,children:S.slice(fe,N)},"c"));let z=Math.max(y,j),le=Math.min(F,ue);return z<le&&Q.push((0,E.jsx)(f,{children:S.slice(z,le)},"a")),ue>F&&Q.push((0,E.jsx)(f,{color:u.dim,children:S.slice(Math.max(F,j),ue)},"g")),(0,E.jsx)(x,{children:Q},o)})})})(),(0,E.jsx)(de,{bindings:v??[{keys:"\u2191\u2193",label:"history"},{keys:"\u21B5",label:g??"submit"},{keys:"tab",label:"complete"},{keys:"ctrl+r",label:"search"}],escBackLabel:"clear"})]})}var $=O(xe(),1);var b=O(Z(),1);function Tt(r){let t=[{id:"method",label:"Auth method",options:[{label:"Basic Auth",value:"basic"},{label:"OAuth (browser)",value:"oauth"}]}];return r&&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 en({devMode:r,profiles:t,onBasicLogin:e,onOAuthLogin:i,onComplete:l,onCancel:a}){let g=Tt(r),[v,T]=(0,$.useState)(0),[d,w]=(0,$.useState)(0),[K,D]=(0,$.useState)({}),[C,s]=(0,$.useState)("select"),[R,m]=(0,$.useState)(""),[h,W]=(0,$.useState)("username"),[G,ee]=(0,$.useState)(""),[M,V]=(0,$.useState)(null),[ve,ie]=(0,$.useState)(null),te=g[v],se=K.method??"basic",U=K.env??"prod",Y=(0,$.useCallback)(()=>{let p=t.filter(A=>A.env===U).map(A=>({label:`${A.profile} [${A.env}]`,value:A.profile}));return p.push({label:"+ Create new",value:"__new__"}),p},[t,U]),ne=(0,$.useCallback)(()=>{v===0?a():(T(P=>P-1),w(0),s("select"),m(""),V(null))},[v,a]),J=(0,$.useCallback)(P=>{se==="basic"?(s("text-input"),W("username"),m("")):(s("waiting"),i(P,U).then(()=>{ie(`Logged in via OAuth as ${P} [${U}]`),s("done")}).catch(p=>{V(p.message),s("error")}))},[se,U,i]),Ae=(0,$.useCallback)(P=>{let p=P.trim();if(p){if(h==="profileName"){let A=p;D(_=>({..._,profile:A})),J(A);return}if(h==="username"){ee(p),m(""),W("accessKey"),s("text-input-masked");return}if(h==="accessKey"){let A=K.profile??"default";s("waiting"),(async()=>{try{await e(A,U,G,p),ie(`Logged in as ${A} [${U}] via basic auth`),s("done")}catch{V("Credentials not valid. Please use valid credentials."),ee(""),m(""),W("username"),s("text-input")}})()}}},[h,K.profile,U,e,G,J]),Te=(0,$.useCallback)(P=>{m(P),M&&V(null)},[M]);be((P,p)=>{if(C==="done"){let _=K.profile??"default";l(_,U);return}if(C==="error"){a();return}if(C==="waiting"){p.escape&&a();return}if(C==="text-input"||C==="text-input-masked")return;if(p.escape){ne();return}let A=te?.id==="profile"?Y():te?.options??[];if(p.upArrow){w(_=>Math.max(0,_-1));return}if(p.downArrow){w(_=>Math.min(A.length-1,_+1));return}if(p.return&&A[d]){let _=A[d];if(te.id==="profile"){if(_.value==="__new__"){s("text-input"),W("profileName"),m("");return}D(k=>({...k,profile:_.value})),T(k=>k+1),w(0),J(_.value);return}D(k=>({...k,[te.id]:_.value})),T(k=>k+1),w(0)}});let me="Login";if(C==="done")return(0,b.jsxs)(x,{flexDirection:"column",borderStyle:"round",borderColor:u.green,paddingX:2,paddingY:1,children:[(0,b.jsxs)(f,{color:u.green,bold:!0,children:["\u2713 ",ve]}),(0,b.jsx)(x,{marginTop:1,children:(0,b.jsx)(f,{color:u.dim,children:"press any key"})})]});if(C==="error")return(0,b.jsxs)(x,{flexDirection:"column",borderStyle:"round",borderColor:u.red,paddingX:2,paddingY:1,children:[(0,b.jsx)(f,{color:u.red,bold:!0,children:"Login failed"}),(0,b.jsx)(x,{marginTop:1,children:(0,b.jsx)(f,{color:u.red,children:M})}),(0,b.jsx)(x,{marginTop:1,children:(0,b.jsx)(f,{color:u.dim,children:"press any key"})})]});if(C==="waiting")return(0,b.jsxs)(x,{flexDirection:"column",borderStyle:"round",borderColor:u.orange,paddingX:2,paddingY:1,children:[(0,b.jsxs)(f,{color:u.orange,bold:!0,children:[me," \u203A OAuth"]}),(0,b.jsx)(x,{marginTop:1,children:(0,b.jsx)(f,{color:u.secondary,children:"Opening browser for login..."})}),(0,b.jsx)(x,{marginTop:1,children:(0,b.jsx)(f,{color:u.orange,children:"Waiting for callback \u27F3"})}),(0,b.jsx)(de,{bindings:[],escBackLabel:"cancel"})]});if(C==="text-input"||C==="text-input-masked"){let P=h==="username"?"Username":h==="accessKey"?"Access Key":"Profile name",p=h==="username"||h==="accessKey"?`${me} \u203A Basic Auth`:`${me} \u203A New Profile`;return(0,b.jsxs)(x,{flexDirection:"column",borderStyle:"round",borderColor:u.orange,paddingX:2,paddingY:1,children:[M&&(h==="username"||h==="accessKey")&&(0,b.jsx)(x,{marginBottom:1,children:(0,b.jsxs)(f,{color:u.red,children:["\u2717 ",M]})}),(0,b.jsx)(f,{color:u.orange,bold:!0,children:p}),h==="accessKey"&&(0,b.jsxs)(x,{marginTop:1,children:[(0,b.jsx)(f,{color:u.secondary,children:"Username: "}),(0,b.jsx)(f,{children:G})]}),(0,b.jsxs)(x,{marginTop:1,children:[(0,b.jsxs)(f,{color:u.secondary,children:[P,": "]}),(0,b.jsx)(ke,{value:R,onChange:Te,onSubmit:Ae,onCancel:ne,masked:C==="text-input-masked"})]}),(0,b.jsx)(de,{bindings:[{keys:"\u21B5",label:"confirm"}],escBackLabel:"back"})]})}let he=te?.id==="profile"?Y():te?.options??[];return(0,b.jsxs)(x,{flexDirection:"column",borderStyle:"round",borderColor:u.orange,paddingX:2,paddingY:1,children:[(0,b.jsx)(f,{color:u.orange,bold:!0,children:me}),(0,b.jsx)(x,{marginTop:1,children:(0,b.jsxs)(f,{color:u.secondary,children:[te?.label,":"]})}),(0,b.jsx)(x,{flexDirection:"column",marginTop:1,children:he.map((P,p)=>{let A=p===d,_=A?"\u276F ":" ",k=P.value==="__new__"?u.green:A?u.orange:void 0;return(0,b.jsxs)(f,{color:k,children:[_,P.label]},P.value)})}),(0,b.jsx)(de,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}async function Je(r,t,e,i){let l=r.loadBasicAuth(t,e),a=r.loadCredentials(t,e);if(!l&&!a)return i("info","STARTUP_GATE_NO_CREDS","Profile has no credentials",{profile:t,env:e}),{status:"needs_login",profile:t,env:e};let g=Oe(e),v=async()=>r.loadCredentials(t,e)?.access_token??null,T=new Fe(g.controllerBaseUrl,v,l,i);i("info","STARTUP_GATE_VALIDATE","Validating credentials with controller",{profile:t,env:e,method:l?"basic":"oauth"});let d=await T.resolve(!0);if(d)return i("info","STARTUP_GATE_VALID","Credentials validated",{profile:t,env:e,username:d.username,org_id:d.org_id}),{status:"authenticated",result:{profile:t,env:e,credentials:a,basicAuth:l,tmsCreds:d,resolver:T}};if(!l&&a){let w=a.refresh_token,D=r.loadClient(t,e)?.client_id;if(w&&D){i("info","STARTUP_GATE_REFRESH","Attempting token refresh",{profile:t,env:e});try{let s=await new Ue(e).refreshToken(w,D);if(s.access_token){r.saveCredentials(t,e,{...a,...s,expires_at:Date.now()/1e3+(s.expires_in??3600)});let m=await T.resolve(!0);if(m)return i("info","STARTUP_GATE_REFRESH_OK","Token refreshed and validated",{profile:t,env:e,username:m.username}),{status:"authenticated",result:{profile:t,env:e,credentials:{...a,...s},basicAuth:null,tmsCreds:m,resolver:T}}}i("warn","STARTUP_GATE_REFRESH_INVALID","Refreshed token still invalid",{profile:t,env:e})}catch(C){i("warn","STARTUP_GATE_REFRESH_FAILED","Token refresh failed",{profile:t,env:e,error:C instanceof Error?C.message:String(C)})}}else i("info","STARTUP_GATE_NO_REFRESH","No refresh_token or client_id \u2014 login required",{profile:t,env:e})}return i("info","STARTUP_GATE_INVALID","Credentials invalid \u2014 login required",{profile:t,env:e}),{status:"needs_login",profile:t,env:e}}async function an(r,t,e=new $e){let i=r.listProfiles();if(t("info","STARTUP_GATE_START","Auth startup gate",{profile_count:i.length}),i.length===0)return t("info","STARTUP_GATE_NONE","No profiles found \u2014 login required"),{status:"needs_login"};if(i.length>1){let g=r.getActiveProfile(),v=r.getDefaultEnv();if(g&&i.some(d=>d.profile===g&&d.env===v)){t("info","STARTUP_GATE_TRY_ACTIVE","Multiple profiles \u2014 trying active first",{activeProfile:g,activeEnv:v});let d=await Je(r,g,v,t);if(d.status==="authenticated")return d;t("info","STARTUP_GATE_ACTIVE_FAILED","Active profile invalid \u2014 showing picker",{activeProfile:g,activeEnv:v})}return t("info","STARTUP_GATE_MULTI","Multiple profiles \u2014 picker required",{profiles:i.map(T=>`${T.profile}/${T.env}`)}),{status:"needs_pick",profiles:i}}let{profile:l,env:a}=i[0];return r.setActiveProfile(l),r.setDefaultEnv(a),Ke(r,e,l,a),Je(r,l,a,t)}export{yt as a,At as b,qt as c,en as d,Je as e,an as f};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as D}from"./chunk-
|
|
2
|
+
import{a as D}from"./chunk-UN7QP7YJ.js";import{a as A}from"./chunk-RVK7MDEV.js";import{p as S,q as C,r as P,s as U,t as N}from"./chunk-LTEYP6N4.js";import{createServer as Oe}from"http";import{randomBytes as He}from"crypto";import{URL as $e}from"url";import Z from"process";import{Buffer as ee}from"buffer";import re from"path";import{fileURLToPath as ke}from"url";import{promisify as Le}from"util";import te from"child_process";import Me,{constants as Ie}from"fs/promises";import Y from"process";import G,{constants as me}from"fs/promises";import j from"process";import le from"os";import L from"fs";import se from"fs";import z from"fs";var E;function ie(){try{return z.statSync("/.dockerenv"),!0}catch{return!1}}function ae(){try{return z.readFileSync("/proc/self/cgroup","utf8").includes("docker")}catch{return!1}}function B(){return E===void 0&&(E=ie()||ae()),E}var k,ce=()=>{try{return se.statSync("/run/.containerenv"),!0}catch{return!1}};function u(){return k===void 0&&(k=ce()||B()),k}var K=()=>{if(j.platform!=="linux")return!1;if(le.release().toLowerCase().includes("microsoft"))return!u();try{if(L.readFileSync("/proc/version","utf8").toLowerCase().includes("microsoft"))return!u()}catch{}return L.existsSync("/proc/sys/fs/binfmt_misc/WSLInterop")||L.existsSync("/run/WSL")?!u():!1},d=j.env.__IS_WSL_TEST__?K:K();var de=(()=>{let e="/mnt/",r;return async function(){if(r)return r;let t="/etc/wsl.conf",n=!1;try{await G.access(t,me.F_OK),n=!0}catch{}if(!n)return e;let o=await G.readFile(t,{encoding:"utf8"}),i=/(?<!#.*)root\s*=\s*(?<mountPoint>.*)/g.exec(o);return i?(r=i.groups.mountPoint.trim(),r=r.endsWith("/")?r:`${r}/`,r):e}})(),fe=async()=>`${await de()}c/Windows/System32/WindowsPowerShell/v1.0/powershell.exe`,M=async()=>d?fe():`${Y.env.SYSTEMROOT||Y.env.windir||String.raw`C:\Windows`}\\System32\\WindowsPowerShell\\v1.0\\powershell.exe`;function f(e,r,t){let n=o=>Object.defineProperty(e,r,{value:o,enumerable:!0,writable:!0});return Object.defineProperty(e,r,{configurable:!0,enumerable:!0,get(){let o=t();return n(o),o},set(o){n(o)}}),e}import{promisify as Pe}from"util";import O from"process";import{execFile as Ae}from"child_process";import{promisify as pe}from"util";import ue from"process";import{execFile as ge}from"child_process";var he=pe(ge);async function I(){if(ue.platform!=="darwin")throw new Error("macOS only");let{stdout:e}=await he("defaults",["read","com.apple.LaunchServices/com.apple.launchservices.secure","LSHandlers"]),t=/LSHandlerRoleAll = "(?!-)(?<id>[^"]+?)";\s+?LSHandlerURLScheme = (?:http|https);/.exec(e)?.groups.id??"com.apple.Safari";return t==="com.apple.safari"?"com.apple.Safari":t}import we from"process";import{promisify as xe}from"util";import{execFile as ye,execFileSync as cr}from"child_process";var ve=xe(ye);async function X(e,{humanReadableOutput:r=!0,signal:t}={}){if(we.platform!=="darwin")throw new Error("macOS only");let n=r?[]:["-ss"],o={};t&&(o.signal=t);let{stdout:i}=await ve("osascript",["-e",e,n],o);return i.trim()}async function T(e){return X(`tell application "Finder" to set app_path to application file id "${e}" as string
|
|
3
3
|
tell application "System Events" to get value of property list item "CFBundleName" of property list file (app_path & ":Contents:Info.plist")`)}import{promisify as be}from"util";import{execFile as Se}from"child_process";var Ce=be(Se),y={MSEdgeHTM:{name:"Edge",id:"com.microsoft.edge"},MSEdgeBHTML:{name:"Edge Beta",id:"com.microsoft.edge.beta"},MSEdgeDHTML:{name:"Edge Dev",id:"com.microsoft.edge.dev"},AppXq0fevzme2pys62n3e0fbqa7peapykr8v:{name:"Edge",id:"com.microsoft.edge.old"},ChromeHTML:{name:"Chrome",id:"com.google.chrome"},ChromeBHTML:{name:"Chrome Beta",id:"com.google.chrome.beta"},ChromeDHTML:{name:"Chrome Dev",id:"com.google.chrome.dev"},ChromiumHTM:{name:"Chromium",id:"org.chromium.Chromium"},BraveHTML:{name:"Brave",id:"com.brave.Browser"},BraveBHTML:{name:"Brave Beta",id:"com.brave.Browser.beta"},BraveDHTML:{name:"Brave Dev",id:"com.brave.Browser.dev"},BraveSSHTM:{name:"Brave Nightly",id:"com.brave.Browser.nightly"},FirefoxURL:{name:"Firefox",id:"org.mozilla.firefox"},OperaStable:{name:"Opera",id:"com.operasoftware.Opera"},VivaldiHTM:{name:"Vivaldi",id:"com.vivaldi.Vivaldi"},"IE.HTTP":{name:"Internet Explorer",id:"com.microsoft.ie"}},ur=new Map(Object.entries(y)),F=class extends Error{};async function _(e=Ce){let{stdout:r}=await e("reg",["QUERY"," HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\Shell\\Associations\\UrlAssociations\\http\\UserChoice","/v","ProgId"]),t=/ProgId\s*REG_SZ\s*(?<id>\S+)/.exec(r);if(!t)throw new F(`Cannot find Windows browser in stdout: ${JSON.stringify(r)}`);let{id:n}=t.groups,o=n.lastIndexOf("."),i=n.lastIndexOf("-"),c=o===-1?void 0:n.slice(0,o),a=i===-1?void 0:n.slice(0,i);return y[n]??y[c]??y[a]??{name:n,id:n}}var Ee=Pe(Ae),Be=e=>e.toLowerCase().replaceAll(/(?:^|\s|-)\S/g,r=>r.toUpperCase());async function H(){if(O.platform==="darwin"){let e=await I();return{name:await T(e),id:e}}if(O.platform==="linux"){let{stdout:e}=await Ee("xdg-mime",["query","default","x-scheme-handler/http"]),r=e.trim();return{name:Be(r.replace(/.desktop$/,"").replace("-"," ")),id:r}}if(O.platform==="win32")return _();throw new Error("Only macOS, Linux, and Windows are supported")}var Te=Le(te.execFile),$=re.dirname(ke(import.meta.url)),q=re.join($,"xdg-open"),{platform:w,arch:V}=Z;async function Fe(){let e=await M(),r=String.raw`(Get-ItemProperty -Path "HKCU:\Software\Microsoft\Windows\Shell\Associations\UrlAssociations\http\UserChoice").ProgId`,t=ee.from(r,"utf16le").toString("base64"),{stdout:n}=await Te(e,["-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand",t],{encoding:"utf8"}),o=n.trim(),i={ChromeHTML:"com.google.chrome",BraveHTML:"com.brave.Browser",MSEdgeHTM:"com.microsoft.edge",FirefoxURL:"org.mozilla.firefox"};return i[o]?{id:i[o]}:{}}var J=async(e,r)=>{let t;for(let n of e)try{return await r(n)}catch(o){t=o}throw t},v=async e=>{if(e={wait:!1,background:!1,newInstance:!1,allowNonzeroExitCode:!1,...e},Array.isArray(e.app))return J(e.app,a=>v({...e,app:a}));let{name:r,arguments:t=[]}=e.app??{};if(t=[...t],Array.isArray(r))return J(r,a=>v({...e,app:{name:a,arguments:t}}));if(r==="browser"||r==="browserPrivate"){let a={"com.google.chrome":"chrome","google-chrome.desktop":"chrome","com.brave.Browser":"brave","org.mozilla.firefox":"firefox","firefox.desktop":"firefox","com.microsoft.msedge":"edge","com.microsoft.edge":"edge","com.microsoft.edgemac":"edge","microsoft-edge.desktop":"edge"},l={chrome:"--incognito",brave:"--incognito",firefox:"--private-window",edge:"--inPrivate"},s=d?await Fe():await H();if(s.id in a){let m=a[s.id];return r==="browserPrivate"&&t.push(l[m]),v({...e,app:{name:g[m],arguments:t}})}throw new Error(`${s.name} is not supported as a default browser`)}let n,o=[],i={};if(w==="darwin")n="open",e.wait&&o.push("--wait-apps"),e.background&&o.push("--background"),e.newInstance&&o.push("--new"),r&&o.push("-a",r);else if(w==="win32"||d&&!u()&&!r){n=await M(),o.push("-NoProfile","-NonInteractive","-ExecutionPolicy","Bypass","-EncodedCommand"),d||(i.windowsVerbatimArguments=!0);let a=["Start"];e.wait&&a.push("-Wait"),r?(a.push(`"\`"${r}\`""`),e.target&&t.push(e.target)):e.target&&a.push(`"${e.target}"`),t.length>0&&(t=t.map(l=>`"\`"${l}\`""`),a.push("-ArgumentList",t.join(","))),e.target=ee.from(a.join(" "),"utf16le").toString("base64")}else{if(r)n=r;else{let a=!$||$==="/",l=!1;try{await Me.access(q,Ie.X_OK),l=!0}catch{}n=Z.versions.electron??(w==="android"||a||!l)?"xdg-open":q}t.length>0&&o.push(...t),e.wait||(i.stdio="ignore",i.detached=!0)}w==="darwin"&&t.length>0&&o.push("--args",...t),e.target&&o.push(e.target);let c=te.spawn(n,o,i);return e.wait?new Promise((a,l)=>{c.once("error",l),c.once("close",s=>{if(!e.allowNonzeroExitCode&&s>0){l(new Error(`Exited with code ${s}`));return}a(c)})}):(c.unref(),c)},_e=(e,r)=>{if(typeof e!="string")throw new TypeError("Expected a `target`");return v({...r,target:e})};function Q(e){if(typeof e=="string"||Array.isArray(e))return e;let{[V]:r}=e;if(!r)throw new Error(`${V} is not supported`);return r}function b({[w]:e},{wsl:r}){if(r&&d)return Q(r);if(!e)throw new Error(`${w} is not supported`);return Q(e)}var g={};f(g,"chrome",()=>b({darwin:"google chrome",win32:"chrome",linux:["google-chrome","google-chrome-stable","chromium"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe",x64:["/mnt/c/Program Files/Google/Chrome/Application/chrome.exe","/mnt/c/Program Files (x86)/Google/Chrome/Application/chrome.exe"]}}));f(g,"brave",()=>b({darwin:"brave browser",win32:"brave",linux:["brave-browser","brave"]},{wsl:{ia32:"/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe",x64:["/mnt/c/Program Files/BraveSoftware/Brave-Browser/Application/brave.exe","/mnt/c/Program Files (x86)/BraveSoftware/Brave-Browser/Application/brave.exe"]}}));f(g,"firefox",()=>b({darwin:"firefox",win32:String.raw`C:\Program Files\Mozilla Firefox\firefox.exe`,linux:"firefox"},{wsl:"/mnt/c/Program Files/Mozilla Firefox/firefox.exe"}));f(g,"edge",()=>b({darwin:"microsoft edge",win32:"msedge",linux:["microsoft-edge","microsoft-edge-dev"]},{wsl:"/mnt/c/Program Files (x86)/Microsoft/Edge/Application/msedge.exe"}));f(g,"browser",()=>"browser");f(g,"browserPrivate",()=>"browserPrivate");var oe=_e;var ne=class{profile;environment;creds;oauth;constructor(r="default",t="prod",n){this.profile=r,this.environment=t,this.creds=n??new D,this.oauth=new A(t)}async login(){let{server:r,port:t}=await this.startCallbackServer(),n=N(t);try{let o=this.creds.loadClient(this.profile,this.environment),i=o?.redirect_uris;(!o||!i?.includes(n))&&(o=await this.oauth.registerClient(n),this.creds.saveClient(this.profile,this.environment,o));let c=o.client_id,[a,l]=A.generatePkce(),s=He(32).toString("hex"),m=this.oauth.buildAuthorizationUrl(c,l,s,n),p=await this.waitForCallback(r,t,m,s);if(!p)throw new Error("Login cancelled or timed out");let h=await this.oauth.exchangeCode(p,c,a,n),x={access_token:h.access_token,refresh_token:h.refresh_token,expires_at:Math.floor(Date.now()/1e3)+h.expires_in,scope:h.scope??"*"};return this.creds.saveCredentials(this.profile,this.environment,x),this.creds.setActiveProfile(this.profile),x}catch(o){throw r.close(),o}}startCallbackServer(){return new Promise((r,t)=>{let n=C,o=()=>{let i=Oe();i.on("error",c=>{c.code==="EADDRINUSE"&&n<P?(n++,o()):t(new Error(`Failed to start callback server: ${c.message}. Ports ${C}-${P} are all in use.`))}),i.listen(n,S,()=>{r({server:i,port:n})})};o()})}waitForCallback(r,t,n,o){return new Promise(i=>{let c=!1,a=setTimeout(()=>l(null),12e4),l=s=>{c||(c=!0,clearTimeout(a),r.close(),i(s))};r.on("request",(s,m)=>{let p=new $e(s.url??"/",`http://${S}:${t}`);if(p.pathname!==U){m.writeHead(404),m.end();return}let h=p.searchParams.get("state"),x=p.searchParams.get("code");if(p.searchParams.get("error")){m.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),m.end(R({state:"error",title:"Login failed",message:"We couldn't complete the sign-in. You can close this tab and try again from your terminal."})),l(null);return}if(h!==o){m.writeHead(400,{"Content-Type":"text/html; charset=utf-8"}),m.end(R({state:"error",title:"Invalid state",message:"The sign-in response didn't match this session. Please return to your terminal and try again."})),l(null);return}m.writeHead(200,{"Content-Type":"text/html; charset=utf-8"}),m.end(R({state:"success",title:"You're signed in",message:"Head back to your terminal \u2014 KaneAI is ready when you are.",autoClose:!0})),l(x)}),oe(n).catch(s=>{let m=s instanceof Error?s.message:String(s);process.stderr.write(`[auth] Could not open browser: ${m}
|
|
4
4
|
Please open this URL manually: ${n}
|
|
5
5
|
`)})})}};function R(e){let r=e.state==="success",t=r?"#22c55e":"#ef4444",n=r?"rgba(34, 197, 94, 0.12)":"rgba(239, 68, 68, 0.12)",o=r?'<svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M5 12.5l4.5 4.5L19 7"/></svg>':'<svg viewBox="0 0 24 24" width="36" height="36" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg>',i=e.autoClose?"<script>setTimeout(function(){try{window.close();}catch(e){}}, 1500);</script>":"";return`<!doctype html>
|