@testmuai/kane-cli 0.4.3 → 0.4.4
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-5ORNSIGU.js → ChromeProfilePicker-H427EL5U.js} +1 -1
- package/dist/{CliFeedbackPrompt-FLU2ARNK.js → CliFeedbackPrompt-D7DXZR4B.js} +1 -1
- package/dist/{CliUploadProgress-3XSSNZZC.js → CliUploadProgress-TZOIZVBK.js} +1 -1
- package/dist/{ConfigView-J3U7W5IC.js → ConfigView-ZU5ZNKUD.js} +1 -1
- package/dist/FolderPicker-3NJWN2F2.js +2 -0
- package/dist/{HelpView-QPZCA6E3.js → HelpView-DWUH3LLF.js} +1 -1
- package/dist/{InfoBox-2PQE7LQY.js → InfoBox-5GHCKHZE.js} +1 -1
- package/dist/{LinksBox-72DOWBUL.js → LinksBox-7RJTKT4B.js} +1 -1
- package/dist/{ProfilesView-VGHTTDXT.js → ProfilesView-YSIGYTJM.js} +1 -1
- package/dist/{ProjectPicker-WICA5KRO.js → ProjectPicker-XC6TSIR2.js} +1 -1
- package/dist/{SaveSessionPrompt-TH24UGJF.js → SaveSessionPrompt-MRUJIK7M.js} +1 -1
- package/dist/SingleShotApp-M6GGEFNF.js +2 -0
- package/dist/{SummaryBox-P42SBLBH.js → SummaryBox-ANGQ3UJN.js} +1 -1
- package/dist/TestMdRunView-PMTEPMCQ.js +2 -0
- package/dist/{WhoamiView-FVGT4VHK.js → WhoamiView-D5XIL6WM.js} +1 -1
- package/dist/{changelog-55BBQLCV.js → changelog-LAWVQATM.js} +1 -1
- package/dist/{chunk-M4JD6FAC.js → chunk-2COEECXK.js} +1 -1
- package/dist/{chunk-SP6DPSKB.js → chunk-2PAQTECV.js} +2 -2
- package/dist/{chunk-N2DL2XLX.js → chunk-34JPQPWA.js} +1 -1
- package/dist/{chunk-6YGJHOJJ.js → chunk-5JCW7SWD.js} +1 -1
- package/dist/{chunk-MDUS66QI.js → chunk-6TJO4BQP.js} +1 -1
- package/dist/{chunk-IR5EJOWF.js → chunk-ALVFWRMC.js} +1 -1
- package/dist/{chunk-6YH4L5PD.js → chunk-CIJJJRAO.js} +1 -1
- package/dist/{chunk-ARXOHFRQ.js → chunk-F5QI2E6V.js} +2 -2
- package/dist/{chunk-DOLZ3HLX.js → chunk-FNRTXVR2.js} +1 -1
- package/dist/{chunk-LTEYP6N4.js → chunk-FS2B5IHO.js} +1 -1
- package/dist/{chunk-2EDV5GRD.js → chunk-GAZK7QSI.js} +1 -1
- package/dist/{chunk-3CKFCRIC.js → chunk-H6SXCNLJ.js} +1 -1
- package/dist/{chunk-Z36MHRFD.js → chunk-IUECYFR6.js} +1 -1
- package/dist/{chunk-YO6OTYDJ.js → chunk-JRBDKEHJ.js} +1 -1
- package/dist/{chunk-RVK7MDEV.js → chunk-JSCT5YQ6.js} +1 -1
- package/dist/chunk-JULO4KDA.js +22 -0
- package/dist/{chunk-JWZDGFTV.js → chunk-JWJAOZT6.js} +1 -1
- package/dist/{chunk-QKZTUJUZ.js → chunk-KXRQELOX.js} +1 -1
- package/dist/{chunk-W7K5XSAM.js → chunk-LCLMSRS3.js} +1 -1
- package/dist/{chunk-WBYOM6I2.js → chunk-LUYOWEJW.js} +1 -1
- package/dist/{chunk-P6ZOLQ6M.js → chunk-M23DF6UM.js} +1 -1
- package/dist/{chunk-UN7QP7YJ.js → chunk-MCYS4R5P.js} +1 -1
- package/dist/{chunk-UMFJNYMK.js → chunk-MRKDRLID.js} +1 -1
- package/dist/{chunk-MSIFN664.js → chunk-POFY6TC3.js} +1 -1
- package/dist/{chunk-HN7DVSVI.js → chunk-PUU7A26K.js} +1 -1
- package/dist/chunk-QAS2SVT3.js +5 -0
- package/dist/{chunk-ZS22QC5H.js → chunk-QIMR6EU3.js} +1 -1
- package/dist/{chunk-DJZVPHCW.js → chunk-QSOQ2JMW.js} +1 -1
- package/dist/{chunk-HM2I36RC.js → chunk-RKAQBRNT.js} +1 -1
- package/dist/{chunk-UQLF4H5Z.js → chunk-RSRBUJRW.js} +1 -1
- package/dist/{chunk-JOPYH47V.js → chunk-TTRJNNAV.js} +1 -1
- package/dist/{chunk-D5P5DM3Y.js → chunk-W4OWTRMO.js} +1 -1
- package/dist/{chunk-OERW4FRV.js → chunk-WUY26ICP.js} +1 -1
- package/dist/{chunk-7HRF45Q4.js → chunk-YJY3HPGV.js} +1 -1
- package/dist/{chunk-USO6VWOP.js → chunk-YPOA4277.js} +1 -1
- package/dist/{chunk-7DLL4WUG.js → chunk-Z5YG763L.js} +2 -2
- package/dist/chunk-ZTYRCGGQ.js +60 -0
- package/dist/{generate-headless-2AVIJFUR.js → generate-headless-FYQ4IAPL.js} +2 -2
- package/dist/index.js +36 -36
- package/dist/{list-commands-GI6JUPK2.js → list-commands-JMSIAYLR.js} +1 -1
- package/dist/login-flow-WMUIDH7C.js +2 -0
- package/dist/{persist-recorded-session-L2UJYUMB.js → persist-recorded-session-QUEFYH4U.js} +1 -1
- package/dist/{recording-banner-RVW5S7ET.js → recording-banner-TI2Q7HV5.js} +1 -1
- package/dist/{require-project-folder-EGKVA3T3.js → require-project-folder-HOSORDUO.js} +1 -1
- package/dist/{run-test-md-B4XEFS35.js → run-test-md-XFQCBCIC.js} +6 -6
- package/dist/{skill-installer-NDDLIUWA.js → skill-installer-WYDRFJRS.js} +1 -1
- package/dist/tcg-generate-7IZZWQSU.js +2 -0
- package/dist/testmd-actions-QH7EQAOK.js +2 -0
- package/dist/token-refresh-YTRMAHED.js +2 -0
- package/dist/{validate-basic-36EIJ3ZB.js → validate-basic-CAF6WSCM.js} +1 -1
- package/dist/{version-check-575H4PFY.js → version-check-2RMMQEZJ.js} +1 -1
- package/package.json +6 -5
- package/dist/FolderPicker-63C6BXGW.js +0 -2
- package/dist/SingleShotApp-TFDCDSJ6.js +0 -2
- package/dist/TestMdRunView-HQE6IN2X.js +0 -2
- package/dist/chunk-3OATWGPB.js +0 -22
- package/dist/chunk-EBTYHLMG.js +0 -5
- package/dist/chunk-V45IPWG3.js +0 -60
- package/dist/login-flow-FM7VP76A.js +0 -2
- package/dist/tcg-generate-JQNBXV5P.js +0 -2
- package/dist/testmd-actions-QSLRU3KN.js +0 -2
- package/dist/token-refresh-DKWS73ET.js +0 -2
|
@@ -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-FS2B5IHO.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};
|
|
@@ -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-M23DF6UM.js";import{x as s}from"./chunk-FS2B5IHO.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{b as Le}from"./chunk-
|
|
2
|
+
import{b as Le}from"./chunk-QAS2SVT3.js";import{a as de,b as je}from"./chunk-H6SXCNLJ.js";import{d as Oe,f as pe}from"./chunk-LOIRZFV3.js";import{a as Pe}from"./chunk-M23DF6UM.js";import{a as Ce}from"./chunk-IUECYFR6.js";import{b as _e}from"./chunk-C6S4IEBC.js";import{x as l}from"./chunk-FS2B5IHO.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
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
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
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,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{c as O,h as F}from"./chunk-AH4AXJML.js";import{a as k}from"./chunk-L5LI2JF4.js";import{readFileSync as se,existsSync as ne}from"fs";import{basename as C,dirname as oe,isAbsolute as re,resolve as L}from"path";var u=class extends Error{constructor(s,o,n){super(`[${o}${n!=null?`:${n}`:""}] ${s}`);this.file=o;this.line=n;this.name="TestMdParseError"}},U=new Set(["username","access_key","oauth","profile","project_id","folder_id"]),D=new Set(["mode","max_steps","timeout","global_context","local_context","variables","session_context","code_export","code_language","target","chrome_profile","cdp_endpoint","ws_endpoint","headless","on_lock_conflict"]),$=new Set(["optional"]),V=new Set(["target","chrome_profile","cdp_endpoint","ws_endpoint","headless"]),Q=new Set(["mode","on_lock_conflict"]);function R(e,t){let s=t.split(`
|
|
2
|
+
import{c as O,h as F}from"./chunk-AH4AXJML.js";import{a as k}from"./chunk-L5LI2JF4.js";import{readFileSync as se,existsSync as ne}from"fs";import{basename as C,dirname as oe,isAbsolute as re,resolve as L}from"path";var u=class extends Error{constructor(s,o,n){super(`[${o}${n!=null?`:${n}`:""}] ${s}`);this.file=o;this.line=n;this.name="TestMdParseError"}},U=new Set(["username","access_key","oauth","profile","project_id","folder_id"]),D=new Set(["mode","max_steps","timeout","global_context","local_context","variables","session_context","code_export","code_language","url","target","chrome_profile","cdp_endpoint","ws_endpoint","headless","on_lock_conflict"]),$=new Set(["optional"]),V=new Set(["target","chrome_profile","cdp_endpoint","ws_endpoint","headless"]),Q=new Set(["mode","on_lock_conflict"]);function R(e,t){let s=t.split(`
|
|
3
3
|
`),{global:o,bodyStartLine:n}=X(e,s),{title:r,steps:i}=Z(e,s,n);return{path:e,title:r,global:o,steps:i}}function X(e,t){if(t[0]?.trim()!=="---")return{global:{},bodyStartLine:0};let s=-1;for(let r=1;r<t.length;r++)if(t[r].trim()==="---"){s=r;break}if(s===-1)throw new u("frontmatter is missing closing '---'",e,1);let o=t.slice(1,s).join(`
|
|
4
4
|
`),n;try{n=k(o)??{}}catch(r){throw new u(`invalid YAML in frontmatter: ${r.message}`,e,1)}if(M(e,n,"frontmatter",1),n.on_lock_conflict!==void 0){let r=n.on_lock_conflict;if(r!=="readonly"&&r!=="fail"&&r!=="wait")throw new u(`on_lock_conflict must be 'readonly' | 'fail' | 'wait', got: ${JSON.stringify(r)}`,e,1)}return E(e,n,1),{global:n,bodyStartLine:s+1}}function Z(e,t,s){let o,n=s;for(;n<t.length&&t[n].trim()==="";)n++;let r=n<t.length?/^#\s+(.+?)\s*$/.exec(t[n]):null;r&&(o=r[1],n++);let i=[];for(let d=n;d<t.length;d++)/^##\s/.test(t[d])&&i.push(d);let a=[];for(let d=0;d<i.length;d++){let c=i[d],p=i[d+1]??t.length,m=t[c].replace(/^##\s+/,"").trim(),g=t.slice(c+1,p),{config:l,body:f,optional:h}=ee(e,c+1,g);a.push({index:d+1,heading:m,config:l,body:f,headingLine:c+1,optional:h})}return{title:o,steps:a}}function ee(e,t,s){let o=0;for(;o<s.length&&s[o].trim()==="";)o++;let n,r=t;if(o<s.length&&/^```yaml\s*$/.test(s[o])){let l=o;r=t+l,o++;let f=-1;for(;o<s.length;){if(/^```\s*$/.test(s[o])){f=o;break}o++}if(f===-1)throw new u("step-config fenced ```yaml block is not closed",e,r);let h=s.slice(l+1,f).join(`
|
|
5
5
|
`);try{n=k(h)??{}}catch(I){throw new u(`invalid YAML in step config: ${I.message}`,e,r)}o=f+1}let i=te(s.slice(o)),a=i.filter(l=>l.trim()!=="");if(a.length>0&&/^@session\s+/.test(a[0].trim()))throw new u("@session is no longer supported (iteration 3); use @import instead",e,t);let d=/^@import\s+(\S.*)$/,p=i.filter(l=>d.test(l.trim())).length>0;if(p&&a.length!==1)throw new u("step body must be exactly one of prose / @import",e,t);let m=!1,g;if(n){if(M(e,n,p?"step config (ref)":"step config (objective)",r),p||E(e,n,r),typeof n.optional=="boolean")m=n.optional;else if(n.optional!==void 0)throw new u(`step config 'optional' must be boolean: got ${typeof n.optional}`,e,r);let l={...n};delete l.optional,Object.keys(l).length>0&&(g=l)}return p?{body:{kind:"import_ref",path:d.exec(a[0].trim())[1].trim()},optional:m}:{body:{kind:"objective",text:i.join(`
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{a as v}from"./chunk-6TJO4BQP.js";import{spawn as x,execSync as b}from"child_process";import{existsSync as g}from"fs";import{resolve as e,dirname as N}from"path";import{fileURLToPath as 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=N(A(import.meta.url));function C(){for(let i of["python3","python"])try{return b(`${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"],"linux-arm64":["@testmuai/kane-cli-linux-arm64","@lambdatestincprivate/kane-cli-linux-arm64"],"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,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{d as s,j as l}from"./chunk-
|
|
2
|
+
import{d as s,j as l}from"./chunk-FS2B5IHO.js";import{readFileSync as d,writeFileSync as i,mkdirSync as o,existsSync as p}from"fs";import{dirname as a}from"path";var n={window_size:{width:1920,height:1080},chrome_profile_path:"",default_url:l,model:"v16-alpha",project_id:null,project_name:null,folder_id:null,folder_name:null,mode:"testing",code_export:{enabled:!0,language:"python",skip_validation:!0},generate:{scenario_limit:2,per_scenario_limit:3,memory_enabled:!1},last_seen_version:"",hints_enabled:!0},c=class{constructor(r=s){this.path=r}exists(){return p(this.path)}load(){try{let r=d(this.path,"utf-8"),e=JSON.parse(r);return{...n,...e,code_export:{...n.code_export,...e.code_export??{}},generate:{...n.generate,...e.generate??{}}}}catch{return{...n,code_export:{...n.code_export},generate:{...n.generate}}}}set(r,e){try{let t=this.load();t[r]=e,o(a(this.path),{recursive:!0}),i(this.path,JSON.stringify(t,null,2)+`
|
|
3
3
|
`)}catch(t){let g=t instanceof Error?t.message:String(t);process.stderr.write(`[config] Failed to save config: ${g}
|
|
4
4
|
`)}}save(r){try{let t={...this.load(),...r};o(a(this.path),{recursive:!0}),i(this.path,JSON.stringify(t,null,2)+`
|
|
5
5
|
`)}catch(e){let t=e instanceof Error?e.message:String(e);process.stderr.write(`[config] Failed to save config: ${t}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as K,c as V,d as z,e as ee,f as te}from"./chunk-
|
|
2
|
+
import{b as K,c as V,d as z,e as ee,f as te}from"./chunk-RSRBUJRW.js";import{c as J}from"./chunk-W4OWTRMO.js";import{a as Q}from"./chunk-QIMR6EU3.js";import{a as Z}from"./chunk-FPFOW6BS.js";import{b as H}from"./chunk-CIJJJRAO.js";import{b as W}from"./chunk-RKAQBRNT.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-MCYS4R5P.js";import{a as _}from"./chunk-6TJO4BQP.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-CAF6WSCM.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-WMUIDH7C.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 A}from"./chunk-YCCUBQY4.js";import{a as _}from"./chunk-
|
|
2
|
+
import{a as A}from"./chunk-YCCUBQY4.js";import{a as _}from"./chunk-2COEECXK.js";import{a as k}from"./chunk-LPUQ4HWQ.js";import{a as B}from"./chunk-6TJO4BQP.js";import{a as R}from"./chunk-GAZK7QSI.js";import{x as c}from"./chunk-FS2B5IHO.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,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as $e}from"./chunk-
|
|
2
|
+
import{a as $e}from"./chunk-QIMR6EU3.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-JSCT5YQ6.js";import{a as Oe}from"./chunk-6TJO4BQP.js";import{a as de}from"./chunk-GAZK7QSI.js";import{c as Re,x as u}from"./chunk-FS2B5IHO.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
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
4
|
`;)e--;return e<0||r[e]!=="@"||e>0&&r[e-1]!==" "&&r[e-1]!==`
|
|
5
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,`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as l}from"./chunk-
|
|
2
|
+
import{b as l}from"./chunk-FNRTXVR2.js";import{a as f}from"./chunk-MCYS4R5P.js";import{a as m}from"./chunk-6TJO4BQP.js";import{a as p}from"./chunk-RZ4F3BHX.js";import{a as c,c as s,h as a,w as u}from"./chunk-FS2B5IHO.js";var v="/public/skills/kane-cli";function C(){try{let n=new f().getDefaultEnv();if(n in u)return n}catch{}return"prod"}function k(){return`${m(C()).controllerBaseUrl}${v}`}import{readFileSync as S,writeFileSync as E,mkdirSync as g}from"fs";import{join as d}from"path";var h=d(s,"skill-check.json"),y=3600*1e3;function V(){try{let n=JSON.parse(S(h,"utf-8"));if(Date.now()-n.checkedAt<y)return n}catch{}return null}function A(n){try{g(s,{recursive:!0}),E(h,JSON.stringify({map:n,checkedAt:Date.now()}))}catch{}}function I(){for(let{dir:n}of a)try{let t=S(d(n,"VERSION"),"utf-8").trim();if(t)return t}catch{}return null}function M(n,t){let i=Object.keys(n.versions??{});if(i.length===0)return null;let o=i.slice().sort((r,e)=>l(r,e));for(let r of o){let e=n.versions[r]?.kaneCliMinVersion;if(!e||l(t,e)<=0)return r}return null}async function U(){try{let n=V()?.map;if(!n){let o=new AbortController,r=setTimeout(()=>o.abort(),5e3),e=await p(k(),{headers:{Accept:"application/json"},signal:o.signal});if(clearTimeout(r),!e.ok)return null;n=await e.json(),A(n)}let t=M(n,c);if(!t)return null;let i=I();return i===null?{current:null,latestCompatible:t}:l(i,t)>0?{current:i,latestCompatible:t}:null}catch{return null}}export{k as a,M as b,U as c};
|
|
@@ -1,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-FS2B5IHO.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{a as t}from"./chunk-
|
|
2
|
+
import{a as t}from"./chunk-JSCT5YQ6.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 S}from"./chunk-
|
|
2
|
+
import{a as S}from"./chunk-M23DF6UM.js";import{x as o}from"./chunk-FS2B5IHO.js";import{a as R}from"./chunk-HCBYKLMW.js";import{a as x,b as c,j as y}from"./chunk-C44QQJR4.js";import{a as w}from"./chunk-6YGTRKDT.js";import{e as b}from"./chunk-UR6MHSHU.js";var T=b(w(),1);var i=b(R(),1);function L(e){let t=e.decisions.filter(l=>l.kind==="replay").length,r=e.decisions.filter(l=>l.kind==="author").length,d=e.outcomes.filter(l=>l.status==="passed").length,p=e.outcomes.filter(l=>l.status==="failed").length,f=e.outcomes.filter(l=>l.status==="skipped").length,a=o.green,n;e.cancelled||e.overallStatus==="interrupted"?(a=o.orange,n="CANCELLED"):e.overallStatus==="failed"?(a=o.red,n="FAILED"):n="PASSED";let s=`${n} \xB7 ${e.durationS}s \xB7 ${e.outcomes.length} steps (${d} passed, ${p} failed, ${f} skipped)`,k=`${t} replay \xB7 ${r} author`,C=e.retryTriggered,_="yes \u2014 run recovered after a replay miss",u,g=o.dim;if(e.cancelled)u="\u2013 not committed (cancellation)";else if(e.overallStatus==="failed")u="\u2013 not committed (run failed)",g=o.red;else if(!e.shouldCommit)e.isFirstRun?u="\u2013 not committed (first run skipped commit)":e.lockHeld?u="\u2013 not committed":u="\u2013 not committed (readonly fallback / no lock)";else{let l=e.uploadResult?.testcaseId;u=l?`\u2713 pushed (testcase=${l})`:"\u2713 pushed",g=o.green}let v=e.shouldReplaceLocalOutput?"output dir replaced":e.anyAuthorStepRan?"untouched (cancellation or no replace)":"untouched (replay-only)",m,h=o.dim;return e.shouldUploadArtifacts?e.uploadResult?.success?(m="\u2713 TMS",h=o.green):e.uploadResult?(m=`\u2717 failed${e.uploadResult.error?`: ${e.uploadResult.error}`:""}`,h=o.red):m="\u2013 not run":m="\u2013 skipped (--local or no auth)",{resultLine:{color:a,text:s},breakdown:k,showRetries:C,retriesText:_,commitText:u,commitColor:g,artifactsText:v,uploadText:m,uploadColor:h}}function O(e){let t=e.decisions.filter(s=>s.kind==="replay").length,r=e.decisions.filter(s=>s.kind==="author").length,d=e.outcomes.filter(s=>s.status==="passed").length,p=e.outcomes.filter(s=>s.status==="failed").length,f=e.outcomes.filter(s=>s.status==="skipped").length,a,n=!1;return e.cancelled?a="cancellation":e.overallStatus==="failed"?a="run_failed":e.shouldCommit&&e.uploadResult?.testcaseId?(a="ok",n=!0):!e.shouldCommit&&!e.lockHeld&&!e.isFirstRun?a="readonly_fallback":a="not_committed",{type:"test_md_summary",overall_status:e.overallStatus,duration_s:e.durationS,steps:{total:e.outcomes.length,passed:d,failed:p,skipped:f,replay_decisions:t,author_decisions:r},retries:{triggered:e.retryTriggered},commit:{committed:n,reason:a,...e.uploadResult?.testcaseId?{testcase_id:e.uploadResult.testcaseId}:{}},artifacts:{replaced:e.shouldReplaceLocalOutput},upload:{performed:e.shouldUploadArtifacts,...e.uploadResult?{succeeded:!!e.uploadResult.success}:{}},...e.shareUrl?{share_url:e.shareUrl}:{},cancelled:e.cancelled}}function A({data:e}){let t=L(e),r=[{label:"result",value:(0,i.jsx)(c,{color:t.resultLine.color,bold:!0,children:t.resultLine.text})},{label:"breakdown",value:(0,i.jsx)(c,{color:o.dim,children:t.breakdown})}];return t.showRetries&&r.push({label:"retries",value:(0,i.jsx)(c,{color:o.orange,children:t.retriesText})}),r.push({label:"commit",value:(0,i.jsx)(c,{color:t.commitColor,children:t.commitText})}),r.push({label:"artifacts",value:(0,i.jsx)(c,{color:o.dim,children:t.artifactsText})}),r.push({label:"upload",value:(0,i.jsx)(c,{color:t.uploadColor,children:t.uploadText})}),(0,i.jsx)(S,{title:"Run summary",titleColor:"#ff9500",rows:r})}function I({data:e}){let{exit:t}=y();return(0,T.useEffect)(()=>{let r=setTimeout(()=>t(),50);return()=>clearTimeout(r)},[t]),(0,i.jsx)(x,{flexDirection:"column",children:(0,i.jsx)(A,{data:e})})}export{L as a,O as b,A as c,I as d};
|
|
@@ -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-MCYS4R5P.js";import{a as A}from"./chunk-JSCT5YQ6.js";import{p as S,q as C,r as P,s as U,t as N}from"./chunk-FS2B5IHO.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>
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as L,b as et}from"./chunk-
|
|
2
|
+
import{a as L,b as et}from"./chunk-F5QI2E6V.js";import{a as U,b as X}from"./chunk-34JPQPWA.js";import{a as Z,b as tt}from"./chunk-MDBXYXSC.js";import{a as C,b as J,e as P,f as Q}from"./chunk-AH4AXJML.js";import{a as W}from"./chunk-QIMR6EU3.js";import{a as z}from"./chunk-2COEECXK.js";import{a as N}from"./chunk-MCYS4R5P.js";import{a as G}from"./chunk-6TJO4BQP.js";import{a as I}from"./chunk-RZ4F3BHX.js";import{x as h}from"./chunk-FS2B5IHO.js";import{a as $}from"./chunk-HCBYKLMW.js";import{a as k,b as g,i as K}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as R}from"./chunk-UR6MHSHU.js";var M=R(B(),1);import{existsSync as D,readFileSync as jt,rmSync as dt,unlinkSync as Bt}from"fs";import{resolve as Y}from"path";import{promises as rt,realpathSync as _t}from"fs";import{homedir as xt}from"os";import{join as H,parse as wt,relative as nt,resolve as ot}from"path";var it=new Set(["node_modules",".git","dist","build",".next",".venv","venv","target","__pycache__"]),v=class extends Error{constructor(i){super(`refusing to scan '${i}'. Run from your project root, or pass --root <dir>.`);this.cwd=i;this.name="HomeRefusedError"}};function st(t){try{return _t(ot(t))}catch{return ot(t)}}function yt(t){let r=st(t),i=st(xt()),n=wt(r).root;if(process.platform==="win32"){let o=e=>e.toLowerCase();return o(r)===o(i)||o(r)===o(n)}return r===i||r===n}async function A(t){if(yt(t.root))throw new v(t.root);let r=t.maxEntries??5e4,i=t.maxResults??5e3,n=new Set(t.ignore??[]),o=[],e=0,s=0,c=!1,d,l=[t.root];for(;l.length>0&&!c;){let a=l.shift(),m;try{m=await rt.readdir(a,{withFileTypes:!0})}catch{continue}s++;for(let E of m){if(e++,e>r){c=!0,d="max_entries";break}let x=E.name,T=H(a,x);if(E.isDirectory()){if(it.has(x)||x.startsWith(".")||x.startsWith("output-")||n.has(x))continue;l.push(T)}else if(E.isFile()&&x.endsWith("_test.md")&&(o.push({path:T,relPath:nt(t.root,T),source:"cwd"}),o.length>=i)){c=!0,d="max_results";break}}t.onProgress?.(s,o.length)}if(!c){let m=[{dir:H(t.root,".testmuai","tests"),depth:0}];for(;m.length>0&&!c;){let{dir:E,depth:x}=m.shift(),T;try{T=await rt.readdir(E,{withFileTypes:!0})}catch{continue}s++;for(let f of T){if(e++,e>r){c=!0,d="max_entries";break}let w=f.name,y=H(E,w);if(f.isDirectory()){if(x>=20||w.startsWith(".")||w.startsWith("output-")||it.has(w))continue;m.push({dir:y,depth:x+1})}else if(f.isFile()&&w.endsWith("_test.md")&&(o.push({path:y,relPath:nt(t.root,y),source:"tests-dir"}),o.length>=i)){c=!0,d="max_results";break}}}}return{results:o,aborted:c,abortReason:d,dirsScanned:s}}import{mkdirSync as kt,writeFileSync as Et}from"fs";import{join as bt}from"path";function at(t,r){return`Basic ${Buffer.from(`${t}:${r}`).toString("base64")}`}async function Tt(t){let r=Z({tmsBaseUrl:t.tmsBaseUrl,testcaseId:t.testcaseId,codeExport:{enabled:!0,language:t.language,skipValidation:t.skipValidation}}),i=await I(r.url,{method:"POST",headers:{"content-type":"application/json",authorization:at(t.auth.username,t.auth.access_key)},body:JSON.stringify(r.body)});if(!i.ok)throw new Error(`code-export trigger failed: ${i.status} ${await i.text()}`);t.log("info","CODE_EXPORT_TRIGGERED","Code export triggered",{testcase_id:t.testcaseId})}async function St(t){let r=tt({tmsBaseUrl:t.tmsBaseUrl,testcaseId:t.testcaseId}),i=t.pollIntervalMs??5e3,n=t.timeoutMs??3e5,o=Date.now()+n;for(;Date.now()<o;){let e=await I(r,{headers:{authorization:at(t.auth.username,t.auth.access_key),accept:"application/json"}});if(!e.ok){await new Promise(l=>setTimeout(l,i));continue}let c=(await e.json()).data?.find(l=>l.code_name==="kane-cli-trigger");if(!c){await new Promise(l=>setTimeout(l,i));continue}let d=(c.status??"").toLowerCase();if(d==="in progress"||d==="in_progress"||d==="pending"){await new Promise(l=>setTimeout(l,i));continue}if(!c.url||c.url.length===0)throw new Error(`code-export status=${c.status} but no files returned`);kt(t.outDir,{recursive:!0});for(let l of c.url){let a=bt(t.outDir,l.file_name),m=await I(l.file_url);if(!m.ok){t.log("warn","CODE_EXPORT_FILE_FAILED","Failed to download file",{file_name:l.file_name,status:m.status});continue}let E=await m.text();Et(a,E,"utf-8")}return t.log("info","CODE_EXPORT_DOWNLOADED","Code export saved",{out_dir:t.outDir,file_count:c.url.length}),t.outDir}throw new Error("code-export polling timed out")}async function ct(t){return await Tt(t),await St(t)}var b=R(B(),1);import{existsSync as Rt,readFileSync as vt}from"fs";var p=R($(),1);function Pt(t){L(t);let r=P(t);if(!Rt(r))return null;try{return JSON.parse(vt(r,"utf8"))}catch{return{}}}function Mt(t){return t===null?"never_run":t.testcase_id?"synced":"local_only"}function Dt(t){return t==="synced"?"\u2601":t==="local_only"?"\u25A3":"\u25CB"}function Ct(t){return t==="tests-dir"?"\u2726":" "}function Ot(t,r){return r==="all"?!0:r==="synced"?t.status==="synced":r==="local"?t.status==="local_only":r==="never_run"?t.status==="never_run":r==="cli"?t.source==="tests-dir":r==="hand"?t.source==="cwd":!0}var V=["all","synced","local","never_run","cli","hand"];function Ft(t){let r=V.indexOf(t);return V[(r+1)%V.length]}function lt({root:t,currentOrgId:r,onSelect:i,onCancel:n}){let[o,e]=(0,b.useState)([]),[s,c]=(0,b.useState)(null),[d,l]=(0,b.useState)(!0),[a,m]=(0,b.useState)("all");(0,b.useEffect)(()=>{(async()=>{try{let f=await A({root:t}),w=[];for(let y of f.results){let j=Pt(y.path);j?.org_id!==void 0&&j.org_id!==r||w.push({path:y.path,relPath:y.relPath,name:C(y.path),status:Mt(j),source:y.source})}e(w),l(!1)}catch(f){f instanceof v,c(f.message),l(!1)}})()},[t,r]);let E=(0,b.useMemo)(()=>o.filter(f=>Ot(f,a)).map(f=>({id:f.path,label:`${Dt(f.status)} ${Ct(f.source)} ${f.relPath}`})),[o,a]),x=(0,b.useMemo)(()=>It(a,o),[a,o]);if(s)return(0,p.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:h.red,paddingX:2,paddingY:1,children:[(0,p.jsx)(g,{color:h.red,bold:!0,children:"testmd"}),(0,p.jsx)(k,{marginTop:1,children:(0,p.jsx)(g,{color:h.red,children:s})})]});let T=a==="all"?"all":$t(a);return(0,p.jsx)(z,{title:`testmd \xB7 filter: ${T}`,items:E,loading:d,itemNoun:"tests",onSelect:f=>{let w=o.find(y=>y.path===f.id);w&&i(w)},onCancel:n,onTab:()=>m(f=>Ft(f)),extraHint:"cycle filter",footer:x})}function $t(t){return t==="synced"?"synced (\u2601)":t==="local"?"local (\u25A3)":t==="never_run"?"never run (\u25CB)":t==="cli"?"cli-generated (\u2726)":t==="hand"?"hand-written":"all"}function It(t,r){let i={synced:r.filter(o=>o.status==="synced").length,local:r.filter(o=>o.status==="local_only").length,never:r.filter(o=>o.status==="never_run").length,cli:r.filter(o=>o.source==="tests-dir").length,hand:r.filter(o=>o.source==="cwd").length},n=o=>o?h.orange:h.dim;return(0,p.jsxs)(k,{flexDirection:"column",children:[(0,p.jsx)(g,{color:h.dim,children:"legend:"}),(0,p.jsxs)(k,{children:[(0,p.jsx)(g,{color:n(t==="synced"),children:` \u2601 synced (${i.synced}) `}),(0,p.jsx)(g,{color:n(t==="local"),children:`\u25A3 local (${i.local}) `}),(0,p.jsx)(g,{color:n(t==="never_run"),children:`\u25CB never run (${i.never})`})]}),(0,p.jsxs)(k,{children:[(0,p.jsx)(g,{color:n(t==="cli"),children:` \u2726 cli-generated (${i.cli}) `}),(0,p.jsx)(g,{color:n(t==="hand"),children:` hand-written (${i.hand})`})]})]})}var O=R(B(),1);import{existsSync as Lt,readFileSync as At}from"fs";var u=R($(),1);function ut({path:t,relPath:r,onAction:i,onBack:n,onView:o}){let[e,s]=(0,O.useState)(null),[c,d]=(0,O.useState)(!1);(0,O.useEffect)(()=>{let a=P(t);if(Lt(a))try{s(JSON.parse(At(a,"utf8")))}catch{s(null)}},[t]),K((a,m)=>{if(m.escape){if(c){d(!1);return}n();return}if(c){a==="y"||a==="Y"?(d(!1),i("delete")):(a==="n"||a==="N")&&d(!1);return}a==="r"&&i("run"),a==="e"&&e?.testcase_id&&i("export"),a==="d"&&d(!0),a==="v"&&o&&o()});let l=({k:a,v:m})=>m?(0,u.jsxs)(g,{children:[(0,u.jsx)(g,{color:h.dim,children:a.padEnd(14)}),m]}):null;return(0,u.jsxs)(k,{flexDirection:"column",borderStyle:"round",borderColor:h.orange,paddingX:2,paddingY:1,children:[(0,u.jsx)(g,{color:h.orange,bold:!0,children:r}),(0,u.jsx)(k,{marginTop:1,flexDirection:"column",children:e?(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(l,{k:"test_id",v:e.test_id}),(0,u.jsx)(l,{k:"testcase_id",v:e.testcase_id}),(0,u.jsx)(l,{k:"project_id",v:e.project_id}),(0,u.jsx)(l,{k:"folder_id",v:e.folder_id}),(0,u.jsx)(l,{k:"org_id",v:e.org_id}),(0,u.jsx)(l,{k:"session_name",v:e.session_name}),(0,u.jsx)(l,{k:"commit_id",v:e.commit_id})]}):(0,u.jsx)(g,{color:h.dim,children:"(never run \u2014 no meta.json)"})}),c?(0,u.jsx)(k,{marginTop:1,children:(0,u.jsxs)(g,{color:h.red,bold:!0,children:["Delete ",r," and its output dir? [y/n]"]})}):(0,u.jsx)(k,{marginTop:1,children:(0,u.jsxs)(g,{color:h.dim,children:["[r] run [e] export",e?.testcase_id?"":" (need testcase_id)"," [d] delete",o?" [v] view":""," [Esc] back"]})})]})}function F(t){L(t);let r=P(t);if(!D(r))return null;try{return JSON.parse(jt(r,"utf8"))}catch{return null}}function ft(t,r){return!t||t.org_id===void 0?!0:t.org_id===r}function q(t,r){return ft(t,r)?null:(process.stderr.write(`error: this test belongs to org ${t.org_id}; you are logged in as org ${r}.
|
|
3
3
|
Switch profiles with \`kane-cli profiles switch\` to act on it.
|
|
4
4
|
`),2)}async function Me(t={}){let r=!!process.stdin.isTTY&&!t.json,i=new N,n=new W;await et({isInteractive:r,creds:i,config:n});let o=i.getDefaultEnv()??"prod";try{let e=await X({creds:i,env:o,log:()=>{}});return e.resolvedCreds?.org_id===void 0?(process.stderr.write("error: TMS did not return an org_id. Run `kane-cli login` again.\n"),{ok:!1,code:2}):{ok:!0,orgId:String(e.resolvedCreds.org_id)}}catch(e){if(e instanceof U)return process.stderr.write("error: not authenticated. Run `kane-cli login` first.\n"),{ok:!1,code:2};throw e}}async function De(t,r){if(process.stdin.isTTY&&!t.json)return await Jt(r,t.root);let i=t.root??process.cwd(),n;try{n=await A({root:i,ignore:t.ignore})}catch(o){if(o instanceof v)return process.stderr.write(`error: ${o.message}
|
|
5
5
|
`),2;throw o}for(let o of n.results){let e=F(o.path);if(!ft(e,r))continue;let s={path:o.relPath.startsWith(".")?o.relPath:`./${o.relPath}`,name:C(o.path),has_meta:e!==null,source:o.source,synced:!!e?.testcase_id};e&&(e.test_id&&(s.test_id=e.test_id),e.testcase_id&&(s.testcase_id=e.testcase_id),e.org_id&&(s.org_id=e.org_id),e.project_id&&(s.project_id=e.project_id),e.folder_id&&(s.folder_id=e.folder_id)),process.stdout.write(JSON.stringify(s)+`
|
|
6
6
|
`)}return n.aborted&&process.stderr.write(`warn: walk aborted (${n.abortReason}). Pass --root or --ignore to narrow.
|
|
7
|
-
`),0}var mt=-1001,gt=-1002,pt=-1003,_={action:null,path:null};function Nt(t,r){return _.action=t,_.path=r,t==="run"?mt:t==="export"?gt:pt}function Wt({root:t,currentOrgId:r,onComplete:i}){let[n,o]=M.default.useState({kind:"list"});return M.default.useEffect(()=>{n.kind==="exiting"&&i(n.code)},[n,i]),n.kind==="list"?M.default.createElement(lt,{root:t,currentOrgId:r,onSelect:e=>o({kind:"inspect",path:e.path,relPath:e.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?M.default.createElement(ut,{path:n.path,relPath:n.relPath,onAction:async e=>{o({kind:"exiting",code:Nt(e,n.path)})},onBack:()=>o({kind:"list"})}):null}async function Jt(t,r){let i=r??process.cwd(),{render:n}=await import("./build-JIKYOZUH.js"),o=await new Promise(e=>{let{unmount:s,waitUntilExit:c}=n(M.default.createElement(Wt,{root:i,currentOrgId:t,onComplete:d=>{s(),e(d)}}),{stdout:process.stderr,exitOnCtrlC:!0});c().then(()=>e(0)).catch(()=>e(0))});if(o===mt&&_.path){let{runTestMdFile:e}=await import("./run-test-md-
|
|
7
|
+
`),0}var mt=-1001,gt=-1002,pt=-1003,_={action:null,path:null};function Nt(t,r){return _.action=t,_.path=r,t==="run"?mt:t==="export"?gt:pt}function Wt({root:t,currentOrgId:r,onComplete:i}){let[n,o]=M.default.useState({kind:"list"});return M.default.useEffect(()=>{n.kind==="exiting"&&i(n.code)},[n,i]),n.kind==="list"?M.default.createElement(lt,{root:t,currentOrgId:r,onSelect:e=>o({kind:"inspect",path:e.path,relPath:e.relPath}),onCancel:()=>o({kind:"exiting",code:0})}):n.kind==="inspect"?M.default.createElement(ut,{path:n.path,relPath:n.relPath,onAction:async e=>{o({kind:"exiting",code:Nt(e,n.path)})},onBack:()=>o({kind:"list"})}):null}async function Jt(t,r){let i=r??process.cwd(),{render:n}=await import("./build-JIKYOZUH.js"),o=await new Promise(e=>{let{unmount:s,waitUntilExit:c}=n(M.default.createElement(Wt,{root:i,currentOrgId:t,onComplete:d=>{s(),e(d)}}),{stdout:process.stderr,exitOnCtrlC:!0});c().then(()=>e(0)).catch(()=>e(0))});if(o===mt&&_.path){let{runTestMdFile:e}=await import("./run-test-md-XFQCBCIC.js"),s=await e(_.path,{});return _.action=null,_.path=null,s}if(o===gt&&_.path){let e=await Xt(_.path,{},t);return _.action=null,_.path=null,e}if(o===pt&&_.path){let e=await Ut(_.path,!0,t);return _.action=null,_.path=null,e}return o}async function Ce(t,r){let i=Y(t);if(!D(i))return process.stderr.write(`error: file not found: ${i}
|
|
8
8
|
`),2;let n=F(i),o=q(n,r);if(o!==null)return o;let e={path:i,name:C(i),has_meta:n!==null};return n&&(n.commit_id&&(e.commit_id=n.commit_id),n.test_id&&(e.test_id=n.test_id),n.testcase_id&&(e.testcase_id=n.testcase_id),n.project_id&&(e.project_id=n.project_id),n.folder_id&&(e.folder_id=n.folder_id),n.org_id&&(e.org_id=n.org_id),n.session_name&&(e.session_name=n.session_name)),process.stdout.write(JSON.stringify(e)+`
|
|
9
9
|
`),0}async function Ut(t,r,i){let n=Y(t);if(!D(n))return process.stderr.write(`error: file not found: ${n}
|
|
10
10
|
`),2;let o=F(n),e=q(o,i);if(e!==null)return e;if(!r)return process.stderr.write(`error: refusing to delete without --yes.
|