@testmuai/kane-cli 0.4.6 → 0.4.8
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-HBFXP75A.js → ChromeProfilePicker-B2PUH2LL.js} +1 -1
- package/dist/{CliFeedbackPrompt-WICQY46X.js → CliFeedbackPrompt-647ESLIL.js} +1 -1
- package/dist/{CliUploadProgress-XJ6CCNCR.js → CliUploadProgress-U325KQO6.js} +1 -1
- package/dist/{ConfigView-GPMON37C.js → ConfigView-NKD7QMUV.js} +1 -1
- package/dist/FolderPicker-2LEIB5F5.js +2 -0
- package/dist/HelpView-35KKWQVE.js +2 -0
- package/dist/{InfoBox-PNFLVOCW.js → InfoBox-OIZ3APE3.js} +1 -1
- package/dist/{LinksBox-R23D7MOQ.js → LinksBox-DLIYPE3S.js} +1 -1
- package/dist/{ProfilesView-7BXBJQWU.js → ProfilesView-CFYBJIL4.js} +1 -1
- package/dist/{ProjectPicker-ZZQKNTV5.js → ProjectPicker-ASHXV4HU.js} +1 -1
- package/dist/{SaveSessionPrompt-HJYSPZH5.js → SaveSessionPrompt-ATKVPQEJ.js} +1 -1
- package/dist/SingleShotApp-JYKEW3WS.js +2 -0
- package/dist/{SummaryBox-WWMBNF6O.js → SummaryBox-AAXB55TE.js} +1 -1
- package/dist/TestMdRunView-U35UBFHZ.js +2 -0
- package/dist/{WhoamiView-JEXEKDXI.js → WhoamiView-TRGZE2NZ.js} +1 -1
- package/dist/{changelog-74AVV4RG.js → changelog-JBGYPN7J.js} +1 -1
- package/dist/{chunk-WILJRFXU.js → chunk-25YRWDQ7.js} +1 -1
- package/dist/{chunk-TQZPYXN7.js → chunk-3PISMPFM.js} +1 -1
- package/dist/{chunk-SC4KKGUA.js → chunk-5VZSCQXN.js} +1 -1
- package/dist/{chunk-BFYV4TJW.js → chunk-AD6DPSIZ.js} +1 -1
- package/dist/{chunk-3TNWLCIU.js → chunk-ALF5ETLD.js} +1 -1
- package/dist/{chunk-J54IX7BP.js → chunk-BGXAW2B5.js} +1 -1
- package/dist/{chunk-Y6MB5JP7.js → chunk-BH6EP2LD.js} +1 -1
- package/dist/{chunk-6E4FS7EC.js → chunk-C2E2DKY3.js} +1 -1
- package/dist/{chunk-TOR7WEDD.js → chunk-CL5SB2I7.js} +1 -1
- package/dist/{chunk-264ZEJT7.js → chunk-CVC6MQN6.js} +1 -1
- package/dist/{chunk-H7TODYZ2.js → chunk-DMLJUTQO.js} +1 -1
- package/dist/{chunk-HWCBOJOP.js → chunk-EAUU5F4P.js} +1 -1
- package/dist/{chunk-554BXLWE.js → chunk-F5ZL4XYL.js} +1 -1
- package/dist/{chunk-NURJMABT.js → chunk-F6VA5YBJ.js} +34 -34
- package/dist/{chunk-HHDG2TGX.js → chunk-GRIQ4OQL.js} +1 -1
- package/dist/{chunk-AR6VSIYN.js → chunk-HZUTFC3G.js} +1 -1
- package/dist/chunk-IT2GFEFH.js +5 -0
- package/dist/{chunk-6IE22TW6.js → chunk-IXYUSFH2.js} +2 -2
- package/dist/{chunk-Q3RXDN74.js → chunk-K266M5ZM.js} +1 -1
- package/dist/{chunk-WVAX7IIU.js → chunk-LY3DAHNE.js} +2 -2
- package/dist/{chunk-LFQ2MZYC.js → chunk-LZEYE2WE.js} +1 -1
- package/dist/{chunk-33273OM4.js → chunk-RBG4VTHQ.js} +1 -1
- package/dist/{chunk-7YZO2QQ6.js → chunk-SH5FUG47.js} +1 -1
- package/dist/{chunk-YC7GOEEW.js → chunk-SRQ7P3WI.js} +1 -1
- package/dist/{chunk-LAPX4BA7.js → chunk-SSPIKPHV.js} +1 -1
- package/dist/{chunk-AFUGVKF7.js → chunk-SVZUJ2QE.js} +1 -1
- package/dist/{chunk-KKXWOTVX.js → chunk-UR4NSWY7.js} +1 -1
- package/dist/chunk-UVOM74DG.js +27 -0
- package/dist/{chunk-T7ECNTOU.js → chunk-W67JBBQF.js} +2 -2
- package/dist/{chunk-7NELLGD4.js → chunk-WKS4ST3B.js} +1 -1
- package/dist/chunk-WZ6GNXM3.js +2 -0
- package/dist/chunk-XCMNFMSO.js +8 -0
- package/dist/chunk-YJVA6LBY.js +6 -0
- package/dist/{chunk-2RXJ7SIN.js → chunk-YYSABHRE.js} +1 -1
- package/dist/{chunk-BY7T5OJN.js → chunk-ZQ5IPBXJ.js} +1 -1
- package/dist/{chunk-WXV73W6R.js → chunk-ZQPTSSU6.js} +1 -1
- package/dist/{chunk-JTXYQ2KH.js → chunk-ZRGEUDG5.js} +1 -1
- package/dist/{generate-headless-FX7EAINU.js → generate-headless-VB52MM2A.js} +2 -2
- package/dist/index.js +39 -39
- package/dist/{list-commands-M35SC7YD.js → list-commands-X6EXASQG.js} +1 -1
- package/dist/login-flow-R5IGUIPA.js +2 -0
- package/dist/{persist-recorded-session-V4OYUDBM.js → persist-recorded-session-EI4ISSRI.js} +1 -1
- package/dist/{pipeline-26FR6BXR.js → pipeline-34CX3UBO.js} +1 -1
- package/dist/{recording-banner-5V66U2RF.js → recording-banner-BQQSRJIF.js} +1 -1
- package/dist/{require-project-folder-J5IFDFQZ.js → require-project-folder-LSM4YSKJ.js} +1 -1
- package/dist/{run-test-md-XSR7NXBR.js → run-test-md-VR2Q46Q3.js} +5 -5
- package/dist/{skill-installer-WZCILRBJ.js → skill-installer-JS7LUETO.js} +1 -1
- package/dist/tcg-generate-YQJZTSSI.js +2 -0
- package/dist/testmd-actions-FAQYABQT.js +2 -0
- package/dist/token-refresh-XM3DXY2A.js +2 -0
- package/dist/{validate-basic-3W5ODPRI.js → validate-basic-W7UJ5D25.js} +1 -1
- package/dist/{version-check-43WUFMCW.js → version-check-ACQ5Z7JV.js} +1 -1
- package/package.json +6 -6
- package/dist/FolderPicker-IZXWPOTS.js +0 -2
- package/dist/HelpView-7SDQKJFW.js +0 -2
- package/dist/SingleShotApp-SLABQ7BW.js +0 -2
- package/dist/TestMdRunView-33RBMIZB.js +0 -2
- package/dist/chunk-2TT2RIVP.js +0 -2
- package/dist/chunk-BACEOONG.js +0 -5
- package/dist/chunk-BSTC6BLT.js +0 -5
- package/dist/chunk-J7QJ5Q3J.js +0 -8
- package/dist/chunk-OUO4AO3Z.js +0 -22
- package/dist/login-flow-OBWXOIJ2.js +0 -2
- package/dist/tcg-generate-2H5AUMWY.js +0 -2
- package/dist/testmd-actions-QKMEYBUJ.js +0 -2
- package/dist/token-refresh-VUGZH2DA.js +0 -2
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
+
import{b as We}from"./chunk-IT2GFEFH.js";import{a as ue,b as Te}from"./chunk-UR4NSWY7.js";import{d as Ke,f as xe}from"./chunk-LOIRZFV3.js";import{a as Ue}from"./chunk-LZEYE2WE.js";import{a as qe}from"./chunk-WZ6GNXM3.js";import{b as Ge}from"./chunk-C6S4IEBC.js";import{x as l}from"./chunk-BGXAW2B5.js";import{a as D}from"./chunk-HCBYKLMW.js";import{a as u,b as s,i as Me,j as Ne,k as ye}from"./chunk-C44QQJR4.js";import{a as ce}from"./chunk-6YGTRKDT.js";import{e as k}from"./chunk-UR6MHSHU.js";var ee=k(ce(),1);var U=k(ce(),1);var A=k(ce(),1);function be(e,t){let r=null,a=(d,p)=>{for(let i=0;i<d.length;i++){let T=d[i],f=[...p,i];t(T)&&(r===null||f.length>r.length)&&(r=f),T.children&&T.children.length>0&&a(T.children,f)}};return a(e,[]),r}function Se(e,t,r){if(t.length===0)return[...e];let a=t[0],d=[...e],p=d[a];if(t.length===1)d[a]=r(p);else{let i=t.slice(1),T=Se(p.children??[],i,r);d[a]={...p,children:T}}return d}function _e(e){let t=e.indexOf(": ");return t>0&&t<15?e.slice(t+2):e}function Le(e){return e.map(t=>{let r=t.children?Le(t.children):t.children;return t.status==="running"?{...t,status:"stopped",phase:void 0,children:r}:r!==t.children?{...t,children:r}:t})}function He(e,t,r,a,d){let[p,i]=(0,A.useState)(!1),[T,f]=(0,A.useState)([]),[$,h]=(0,A.useState)(null),[M,N]=(0,A.useState)(null),[C,v]=(0,A.useState)(null),[I,E]=(0,A.useState)(null),[V,Q]=(0,A.useState)([]),[se,ie]=(0,A.useState)(null),[ne,ae]=(0,A.useState)(void 0),G=(0,A.useRef)(null),W=(0,A.useRef)(null),Y=(0,A.useRef)(0),me=(0,A.useRef)(!1),Re=(0,A.useCallback)(async(Z,b)=>{let y=G.current;if(y){try{await y.exited}catch{}G.current=null}f([]),h(null),N(null),v(null),E(null),Q([]),ie(null),ae(Z.max_steps),i(!0),W.current=null,Y.current=0;let x;try{x=We(Z,b)}catch(g){v(g instanceof Error?g.message:String(g)),i(!1);return}G.current=x,Ke("runner",()=>x.cancel()),(async()=>{me.current=!1;let g=!1;for await(let n of x.events){if(me.current)break;switch(n.type){case"run_start":if(n.child_id)break;if(W.current&&!W.current.isSingleFlow){let B=Y.current;Y.current++,f(O=>O.map((R,w)=>w===B?{...R,status:"running"}:R.status==="running"&&!R.children?.some(c=>c.status==="running")?{...R,status:R.children?.some(c=>c.status==="failed")?"failed":"passed"}:R))}break;case"bifurcation":{let B=n.flows??[],O=n.count??B.length,R={flows:B,isSingleFlow:n.is_single_flow??O<=1};E(R),W.current=R,Y.current=0,f(B.map((w,c)=>({index:c+1,objective:w??`Flow ${c+1}`,status:"pending"})));break}case"step_start":{t?.("STEP_START",`Step ${n.index} started`,{index:n.index,objective:n.objective,child_id:n.child_id});let B=n.index,O=n.objective??`Step ${B}`,R=n.child_id,w=W.current&&!W.current.isSingleFlow;if(R)f(c=>{let m=be(c,L=>L.branchChildId===R)??be(c,L=>L.status==="running");return m?Se(c,m,L=>{let F=(L.children??[]).map(H=>H.status==="running"&&H.childId===R?{...H,status:"stopped",phase:void 0}:H);return F.push({index:B,objective:O,status:"running",childId:R}),{...L,children:F}}):c});else if(w){let c=Math.max(0,Y.current-1);f(m=>{let L=[...m];if(c>=L.length)return m;let F={...L[c]},ge=[...F.children??[]].map(ve=>ve.status==="running"&&ve.childId===void 0?{...ve,status:"stopped",phase:void 0}:ve);return ge.push({index:B,objective:O,status:"running"}),F.children=ge,F.status="running",L[c]=F,L})}else f(c=>{let m=Le(c);return m.some(F=>F.index===B)?m.map(F=>F.index===B?{...F,status:"running",objective:O}:F):[...m,{index:B,objective:O,status:"running"}]});break}case"step_event":{t?.("STEP_EVENT",`Step ${n.index} ${n.event}`,{index:n.index,phase:n.event,action_type:n.action_type,detail:n.detail,child_id:n.child_id});let B=n.child_id,O=W.current&&!W.current.isSingleFlow;if(n.event==="cm_init"&&n.checkpoint_count!=null){Q(R=>[...R,n.checkpoint_count]);break}if(n.event==="replay_started"){ie({recordingLength:n.recording_length??0});break}if(n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&r?.(n.detail),B){let R=c=>{if(c.index!==n.index||c.childId!==B)return c;let m={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(m.objective=n.detail),n.action_type&&(m.actionType=n.action_type),{...c,...m}},w=c=>c.map(m=>{let L=R(m);return L!==m?L:m.children&&m.children.length>0?{...m,children:w(m.children)}:m});f(c=>c.map(m=>m.children?{...m,children:w(m.children)}:m))}else if(O){let R=Math.max(0,Y.current-1);f(w=>{let c=[...w];if(R>=c.length)return w;let m={...c[R]},L=[...m.children??[]];if(!L.some(H=>H.index===n.index&&H.childId===void 0))L.push({index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type});else for(let H=0;H<L.length;H++){if(L[H].index!==n.index||L[H].childId!==void 0)continue;let ge={phase:n.event};n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(ge.objective=n.detail),n.action_type&&(ge.actionType=n.action_type),L[H]={...L[H],...ge}}return m.children=L,c[R]=m,c})}else f(R=>R.some(c=>c.index===n.index)?R.map(c=>{if(c.index!==n.index)return c;let m={phase:n.event};return n.event==="reasoning"&&n.detail&&n.detail!=="reasoning"&&(m.objective=n.detail),n.action_type&&(m.actionType=n.action_type),{...c,...m}}):[...Le(R),{index:n.index,objective:`Step ${n.index}`,status:"running",phase:n.event,actionType:n.action_type}]);break}case"step_end":{t?.("STEP_END",`Step ${n.index} ${n.status}`,{index:n.index,status:n.status,duration:n.duration,summary:n.summary,child_id:n.child_id}),a?.();let B=n.child_id,O=W.current&&!W.current.isSingleFlow;if(B){let R=c=>c.index===n.index&&c.childId===B?{...c,status:n.status,duration:n.duration,phase:void 0,objective:c.objective.startsWith("Step ")?_e(n.summary||c.objective):c.objective}:c,w=c=>c.map(m=>{let L=R(m);return L!==m?L:m.children&&m.children.length>0?{...m,children:w(m.children)}:m});f(c=>c.map(m=>m.children?{...m,children:w(m.children)}:m))}else if(O){let R=Math.max(0,Y.current-1);f(w=>{let c=[...w];if(R>=c.length)return w;let m={...c[R]},L=(m.children??[]).map(F=>F.index===n.index&&F.childId===void 0?{...F,status:n.status,duration:n.duration,phase:void 0,objective:F.objective.startsWith("Step ")?_e(n.summary||F.objective):F.objective}:F);return m.children=L,c[R]=m,c})}else f(R=>R.map(w=>w.index===n.index?{...w,status:n.status,duration:n.duration,phase:void 0,objective:w.objective.startsWith("Step ")?_e(n.summary||w.objective):w.objective}:w));{let w=W.current&&!W.current.isSingleFlow?Math.max(0,Y.current-1):0;e?.(n.index,w,n.child_id)}break}case"child_agent_start":{let B=n.objective??"",O=n.child_id;f(R=>{let w=be(R,c=>c.status==="running");return w?Se(R,w,c=>({...c,objective:`${B} (branch)`,phase:`child: ${B.slice(0,50)}`,branchObjective:B,branchChildId:O})):R});break}case"child_agent_end":{let B=n.child_id,O=`child ${n.success?"done":"failed"}`;f(R=>{let w=be(R,c=>c.branchChildId===B);return w?Se(R,w,c=>({...c,phase:O})):R.map(c=>c.phase?.startsWith("child:")?{...c,phase:O}:c)});break}case"describe_trigger":d?.(n);break;case"ask_user":h(n.question??"");break;case"run_end":f(B=>B.map(O=>O.status==="running"?{...O,status:n.status,phase:void 0}:O)),i(!1),N(n),g=!0;break;case"error":i(!1),v(n.message??"Runner error"),f(B=>B.map(O=>O.status==="running"?{...O,status:"failed",phase:void 0}:O));break}}let{code:S,signal:P}=await x.exited,_=x.stderr,le=S===0&&!P,oe=[];S!==null&&S!==0&&oe.push(`Runner exited with code ${S}`),P&&oe.push(`Runner killed by signal ${P}`),_&&(!le||!g?oe.push(_):b?.log?.("debug","RUNNER_STDERR_BENIGN","Runner stderr on clean exit",{stderr:_})),G.current===x&&(oe.length>0&&v(oe.join(`
|
|
3
|
+
`)),i(!1),xe("runner","Event stream ended"),G.current=null)})().catch(g=>{let S=[`Runner event loop error: ${g}`];x.exitCode!==null&&x.exitCode!==0&&S.push(`Exit code: ${x.exitCode}`),x.exitSignal&&S.push(`Signal: ${x.exitSignal}`),x.stderr&&S.push(x.stderr),G.current===x&&(v(S.join(`
|
|
4
|
+
`)),i(!1),xe("runner","Event loop error"),G.current=null)})},[e,t,r,a,d]),re=(0,A.useCallback)(Z=>{G.current?.sendUserResponse(Z),h(null)},[]),Ce=(0,A.useCallback)(()=>{let Z=G.current;Z&&(Z.sendCancel("user"),i(!1),h(null),setTimeout(()=>{G.current===Z&&(xe("runner","User cancelled run"),G.current=null)},5e3))},[]),Pe=(0,A.useCallback)(()=>{f([]),N(null),v(null)},[]);return(0,A.useEffect)(()=>()=>{me.current=!0,xe("runner","Component unmounted"),G.current=null},[]),{isRunning:p,steps:T,askingUser:$,lastRunEnd:M,runError:C,bifurcationInfo:I,cmInitCounts:V,replayInfo:se,maxSteps:ne,startRun:Re,sendAnswer:re,cancelRun:Ce,clearLastRun:Pe}}function Oe(e){let t=e.flatMap(p=>[p,...p.children??[]]),r=t.filter(p=>p.status==="passed").length,a=t.filter(p=>p.status==="failed").length,d=t.filter(p=>p.status==="passed"||p.status==="failed").length;return{passed:r,failed:a,total:d}}function Ve(e){let t=He(e.screenshotDispatcher,e.stepLogger,e.onReasoning,e.onStepComplete),[r,a]=(0,U.useState)(0),[d,p]=(0,U.useState)("idle"),i=(0,U.useRef)("idle"),T=(0,U.useRef)(0),f=(0,U.useRef)(!1),$=(0,U.useRef)(null),h=(0,U.useRef)(null),M=(0,U.useCallback)(v=>{i.current=v,p(v)},[]),N=(0,U.useCallback)(async v=>{let I=await e.getNextConfig(v);if(!I){M("done"),e.onAllComplete?.();return}let E=v?T.current+1:0;T.current=E,a(E),e.onStepStart?.(I,E),$.current=null,h.current=null,M("running"),await t.startRun(I,e.spawnOpts)},[t,e,M]);(0,U.useEffect)(()=>{f.current||(f.current=!0,N(null))},[]),(0,U.useEffect)(()=>{if(!t.lastRunEnd||t.lastRunEnd===$.current||i.current!=="running")return;$.current=t.lastRunEnd,i.current="transitioning",p("transitioning");let v=t.lastRunEnd,I=Oe(t.steps),E=t.bifurcationInfo,V={status:v.status==="passed"?"passed":"failed",duration_s:v.duration??0,reason:v.reason,runEnd:v,hadError:!1,stepsPassed:I.passed,stepsFailed:I.failed,stepsTotal:I.total,bifurcationFlows:E&&!E.isSingleFlow?E.flows:null};if(!(e.onStepEnd?.(V,T.current)??!0)){M("done"),e.onAllComplete?.();return}N(V)},[t.lastRunEnd]),(0,U.useEffect)(()=>{if(!t.runError||t.runError===h.current||t.lastRunEnd||i.current!=="running")return;h.current=t.runError,i.current="transitioning",p("transitioning");let v=Oe(t.steps),I={status:"failed",duration_s:0,reason:t.runError,runEnd:null,hadError:!0,stepsPassed:v.passed,stepsFailed:v.failed,stepsTotal:v.total,bifurcationFlows:null};if(!(e.onStepEnd?.(I,T.current)??!0)){M("done"),e.onAllComplete?.();return}N(I)},[t.runError,t.lastRunEnd]);let C=(0,U.useCallback)(()=>{t.cancelRun()},[t]);return{runner:t,currentStepIndex:r,phase:d,cancel:C}}var je=k(ce(),1);var Be=k(D(),1),ze=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"];function Xe({label:e,hasBifurcation:t=!1}){let[r,a]=(0,je.useState)(0),[d,p]=(0,je.useState)(0);ue(()=>{a(T=>(T+1)%ze.length)},80),ue(()=>{p(T=>(T+1)%4)},400);let i=e??(t?"Planning approach":"Analyzing objective");return(0,Be.jsxs)(u,{marginLeft:1,children:[(0,Be.jsxs)(s,{color:l.orange,children:[ze[r]," "]}),(0,Be.jsxs)(s,{color:l.dim,children:[i,".".repeat(d+1)]})]})}function Ye(e){if(!e.isRunning||e.replayInfo)return null;let t=e.bifurcationInfo;if(t&&!t.isSingleFlow){let r=e.steps.findIndex(d=>d.status==="running");return(r===-1?e.cmInitCounts.length===0:r>=e.cmInitCounts.length)?{label:r>0?`Planning flow ${r+1}`:void 0,hasBifurcation:!0}:null}return e.cmInitCounts.length>0||e.steps.some(r=>r.children?.length)?null:{hasBifurcation:!!t}}var q=k(ce(),1);var Qe=k(ce(),1);var we=k(D(),1),lt="#ffc580",ct="#ffd9a8",Je="#ffffff";function Ie({text:e,active:t=!0}){let[r,a]=(0,Qe.useState)(0),d=4;if(ue(()=>{a(i=>(i+1)%(e.length+d*2))},t?80:null),!t)return(0,we.jsx)(s,{color:Je,children:e});let p=e.split("").map((i,T)=>{let f=r-d,$=Math.abs(T-f-d/2),h;return $<=d/2?h=lt:$<=d?h=ct:h=Je,(0,we.jsx)(s,{color:h,children:i},T)});return(0,we.jsx)(s,{children:p})}var J=k(D(),1),ut={starting:l.orange,running:l.orange,passed:l.green,failed:l.red,cancelled:l.dim,timed_out:l.orange};function $e({currentStep:e,maxSteps:t,elapsed:r,status:a}){let d=ut[a]??l.orange,p=r<60?`${r.toFixed(1)}s`:`${Math.floor(r/60)}m ${Math.round(r%60)}s`;return(0,J.jsxs)(u,{marginLeft:3,children:[(0,J.jsx)(s,{color:l.dim,children:"Steps "}),(0,J.jsx)(s,{bold:!0,children:e}),(0,J.jsxs)(s,{color:l.dim,children:["/",t]}),(0,J.jsx)(s,{children:" "}),(0,J.jsx)(s,{color:l.dim,children:"Elapsed "}),(0,J.jsx)(s,{bold:!0,children:p}),(0,J.jsx)(s,{children:" "}),(0,J.jsx)(s,{color:l.dim,children:"Status "}),(0,J.jsx)(s,{bold:!0,color:d,children:a})]})}var dt={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 Ze(e){return dt[e]??"\u25CF"}var te=k(D(),1);function De({steps:e,flows:t,cmInitCounts:r,renderStep:a}){return(0,te.jsxs)(u,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[(0,te.jsxs)(s,{color:l.dim,children:["\u2501\u2501 Bifurcated into ",t?.length??e.length," flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"]}),e.map((d,p)=>(0,te.jsxs)(u,{flexDirection:"column",marginTop:p>0?1:0,children:[(0,te.jsxs)(s,{color:l.orange,children:["Flow ",p+1,": ",t?.[p]??d.objective]}),r&&r[p]!=null&&(0,te.jsxs)(s,{color:l.dim,children:[" \u25AA Generated task with ",r[p]," checkpoints"]}),d.children&&d.children.length>0?d.children.map(i=>{let T=!!i.branchObjective,f=`f${p}-${i.childId??"p"}-${i.index}`;return T?(0,te.jsxs)(u,{flexDirection:"column",children:[a({...i,children:void 0},f),(i.children??[]).map($=>(0,te.jsx)(u,{marginLeft:2,children:a($,`${f}-${$.childId??"p"}-${$.index}`)},`${f}-${$.childId??"p"}-${$.index}`))]},`${f}-host`):a(i,f)}):d.status==="pending"&&(0,te.jsx)(s,{color:l.dim,children:" \u25CB Waiting..."})]},p))]})}var de=k(D(),1);function et({label:e,shimmer:t=!1}){return(0,de.jsxs)(u,{marginLeft:6,children:[(0,de.jsx)(Te,{}),(0,de.jsx)(s,{children:" "}),t?(0,de.jsx)(Ie,{text:e,active:!0}):(0,de.jsx)(s,{color:l.dim,children:e})]})}var tt=k(ce(),1);var Fe=k(D(),1);function pt(e,t){let r=[];for(let a of e.split(`
|
|
5
|
+
`)){if(a===""){r.push("");continue}let d="";for(let p of a.split(" ")){let i=p;for(;i.length>t;)d&&(r.push(d),d=""),r.push(i.slice(0,t)),i=i.slice(t);d===""?d=i:d.length+1+i.length<=t?d+=" "+i:(r.push(d),d=i)}r.push(d)}return r}function nt({text:e,maxLines:t=3}){let{stdout:r}=ye(),a=Math.max(20,(r?.columns??80)-7),d=!e.trim(),[p,i]=(0,tt.useState)(!0);ue(()=>i($=>!$),500);let T=(d?"Thinking\u2026":e)+(p?"\u258C":" "),f=pt(T,a).slice(-t);for(;f.length<t;)f.push("");return(0,Fe.jsx)(u,{borderStyle:"round",borderColor:l.muted,paddingX:1,marginLeft:3,flexDirection:"column",children:f.map(($,h)=>(0,Fe.jsx)(s,{color:d?l.dim:l.secondary,wrap:"truncate-end",children:$.length?$:" "},h))})}var pe=k(D(),1);function Ee({activity:e,describe:t,describeVisible:r}){return(0,pe.jsxs)(pe.Fragment,{children:[e?(0,pe.jsx)(et,{label:e.label,shimmer:e.shimmer}):null,r?(0,pe.jsx)(nt,{text:t??""}):null]})}var o=k(D(),1);function ke(e){for(let t of e){if(t.children&&t.children.length>0){let r=ke(t.children);if(r)return r}if(t.status==="running")return t}}function he(e){return e.status==="running"&&!e.branchObjective&&(!e.children||e.children.length===0)}function rt(e){let t=[];for(let r of e)he(r)||(r.children&&r.children.length>0?t.push({...r,children:rt(r.children)}):t.push(r));return t}function Ae(e,t){if(!e)return null;let r=e.objective??"";return r.length>0&&!/^Step \d+$/.test(r)?{label:r+"\u2026",shimmer:!1}:{label:t?"Looking at the screen\u2026":"Deciding next action\u2026",shimmer:!0}}function K({step:e,indent:t=2}){let r=e.actionType?Ze(e.actionType):null,a=e.status==="running",d=e.status==="passed",p=e.status==="failed",i=e.status==="pending"||e.status==="stopped",{stdout:T}=ye(),f=T?.columns??80,$=Math.max(20,f-t-21),h=e.objective??"",M=h.length>$?h.slice(0,$-1)+"\u2026":h,N=(e.duration??0)*1e3,C=e.duration!=null?N<1e3?`${Math.round(N)}ms`:`${(N/1e3).toFixed(1)}s`:"";return(0,o.jsxs)(u,{flexDirection:"column",children:[(0,o.jsxs)(u,{marginLeft:t,children:[(0,o.jsx)(u,{width:4,children:(0,o.jsxs)(s,{color:l.muted,children:[String(e.index).padStart(2," ")," "]})}),(0,o.jsx)(u,{width:3,children:a?(0,o.jsx)(Te,{}):d?(0,o.jsx)(s,{color:l.green,bold:!0,children:"\u2713"}):p?(0,o.jsx)(s,{color:l.red,bold:!0,children:"\u2717"}):(0,o.jsx)(s,{color:l.muted,children:"\u25CB"})}),(0,o.jsx)(u,{flexGrow:1,children:a?(0,o.jsx)(Ie,{text:M,active:!0}):p?(0,o.jsx)(s,{color:l.red,children:M}):i?(0,o.jsx)(s,{color:l.dim,children:M}):(0,o.jsx)(s,{color:l.dim,children:M})}),(d||p)&&r?(0,o.jsx)(u,{width:3,marginLeft:1,children:(0,o.jsx)(s,{color:l.muted,children:r})}):(0,o.jsx)(u,{width:3,marginLeft:1}),(0,o.jsx)(u,{width:7,justifyContent:"flex-end",children:(0,o.jsx)(s,{color:l.dim,children:C})})]}),e.children&&e.children.length>0&&(0,o.jsx)(u,{flexDirection:"column",children:e.children.map((v,I)=>(0,o.jsx)(K,{step:v,indent:t+2},`child-${I}`))})]})}function ft(e){return e.type==="cm_init"?(0,o.jsx)(u,{marginLeft:2,paddingLeft:1,children:(0,o.jsxs)(s,{color:l.dim,children:["\u25AA Generated task with ",e.count," checkpoints"]})}):(0,o.jsx)(u,{marginLeft:2,paddingLeft:1,children:(0,o.jsx)(K,{step:e.step})})}function ot({steps:e,bifurcated:t,flows:r,cmInitCounts:a,maxSteps:d=50,staticSteps:p=!1,onStepCommit:i,describe:T,describeVisible:f,describeRevealing:$}){let h=(0,q.useRef)(new Set),M=(0,q.useRef)(!1),N=(0,q.useRef)(new Set),C=(0,q.useRef)(!1),v=(0,q.useRef)(new Set),I=(0,q.useRef)(0);(0,q.useEffect)(()=>{e.length===0&&I.current>0&&(h.current.clear(),M.current=!1,N.current.clear(),C.current=!1,v.current.clear()),I.current=e.length},[e.length]);let E=e.flatMap(b=>[b,...b.children??[]]),V=E.some(b=>b.status==="running"),Q=E.some(b=>b.status==="failed"),se=E.length===0||E.every(b=>b.status==="pending"),ie=E.filter(b=>b.status==="passed"||b.status==="failed").length,ne;se?ne="starting":V?ne="running":Q?ne="failed":ne="passed";let ae=(0,q.useRef)(null),[G,W]=(0,q.useState)(0);(0,q.useEffect)(()=>{E.length===0||se?(ae.current=null,W(0)):V&&ae.current==null&&(ae.current=Date.now())},[V,se,E.length]),(0,q.useEffect)(()=>{if(!V)return;let b=setInterval(()=>{ae.current!=null&&W((Date.now()-ae.current)/1e3)},500);return()=>clearInterval(b)},[V]);let Y=(0,q.useRef)(new Set),[,me]=(0,q.useState)(0),Re=(0,q.useRef)(!1);(0,q.useEffect)(()=>{if(!i||!p||t)return;let b=[];!Re.current&&a&&a[0]!=null&&(Re.current=!0,a[0]>0&&b.push({key:"cm_init_0",type:"cm_init",count:a[0]}));for(let y of e)(y.status==="passed"||y.status==="failed")&&!Y.current.has(y.index)&&(Y.current.add(y.index),b.push({key:`step_${y.index}`,type:"step",step:{...y,children:y.children?[...y.children]:void 0}}));if(b.length>0){for(let y of b)i(ft(y));me(y=>y+1)}},[e,t,a,p,i]),(0,q.useEffect)(()=>{if(!i||p)return;let b=h.current.size;if(!t&&!C.current&&a&&a[0]!=null&&(C.current=!0,a[0]>0&&i((0,o.jsx)(u,{marginLeft:2,children:(0,o.jsxs)(s,{color:l.dim,children:["\u25A0 Generated task with ",a[0]," checkpoints"]})}))),t&&r&&!M.current&&(M.current=!0,i((0,o.jsx)(s,{color:l.purple,children:"\u2501\u2501 Bifurcated into "+r.length+" flows \u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"}))),t){let y=e.flatMap((x,g)=>{let S=x.children??[];return!N.current.has(g)&&S.length>0&&(N.current.add(g),i((0,o.jsx)(s,{color:l.purple,children:" Flow "+(g+1)+": "+(r?.[g]??"")})),a?.[g]!=null&&a[g]>0&&!v.current.has(g)&&(v.current.add(g),i((0,o.jsx)(u,{marginLeft:2,children:(0,o.jsxs)(s,{color:l.dim,children:[" \u25AA Generated task with ",a[g]," checkpoints"]})})))),a?.[g]!=null&&a[g]>0&&N.current.has(g)&&!v.current.has(g)&&(v.current.add(g),i((0,o.jsx)(u,{marginLeft:2,children:(0,o.jsxs)(s,{color:l.dim,children:[" \u25AA Generated task with ",a[g]," checkpoints"]})}))),S});for(let x of y){let g=`${x.childId??"p"}-${x.index}-${x.objective}`;if(!!x.branchObjective){h.current.has(g)||(h.current.add(g),i((0,o.jsx)(u,{marginLeft:2,children:(0,o.jsx)(K,{step:{...x,children:void 0}})})));for(let P of x.children??[]){let _=`child-${x.childId??"p"}-${x.index}-${P.childId??"p"}-${P.index}-${P.objective}`;h.current.has(_)||(P.status==="passed"||P.status==="failed"||P.status==="stopped")&&(h.current.add(_),i((0,o.jsx)(u,{marginLeft:4,children:(0,o.jsx)(K,{step:P})})))}continue}h.current.has(g)||(x.status==="passed"||x.status==="failed"||x.status==="stopped")&&(h.current.add(g),i((0,o.jsx)(u,{marginLeft:2,children:(0,o.jsx)(K,{step:x})})))}}else for(let y of e){let x=`${y.index}-${y.objective}`,g=!!y.branchObjective;g&&!h.current.has(x)&&(h.current.add(x),i((0,o.jsx)(u,{marginLeft:2,children:(0,o.jsx)(K,{step:{...y,children:void 0}})})));for(let S of y.children??[]){let P=`child-${y.index}-${S.childId??"p"}-${S.index}-${S.objective}`;h.current.has(P)||(S.status==="passed"||S.status==="failed"||S.status==="stopped")&&(h.current.add(P),i((0,o.jsx)(u,{marginLeft:4,children:(0,o.jsx)(K,{step:S})})))}!g&&!h.current.has(x)&&(y.status==="passed"||y.status==="failed"||y.status==="stopped")&&(h.current.add(x),i((0,o.jsx)(u,{marginLeft:2,children:(0,o.jsx)(K,{step:{...y,children:void 0}})})))}h.current.size>b&&me(y=>y+1)},[e,i,t,r,a]);let re=[];if(p&&!t)for(let b of e)Y.current.has(b.index)||re.push(b);else if(i&&!p)if(t)for(let b of e){let y=b.children??[],x=[];for(let g of y){let S=`${g.childId??"p"}-${g.index}-${g.objective}`,P=h.current.has(S);if(g.branchObjective){let _=(g.children??[]).filter(le=>{let oe=`child-${g.childId??"p"}-${g.index}-${le.childId??"p"}-${le.index}-${le.objective}`;return!h.current.has(oe)});(!P||_.length>0)&&x.push({...g,children:_})}else P||x.push(g)}x.length>0&&re.push({...b,children:x})}else for(let b of e){let y=`${b.index}-${b.objective}`,x=h.current.has(y),g=(b.children??[]).filter(S=>{let P=`child-${b.index}-${S.childId??"p"}-${S.index}-${S.objective}`;return!h.current.has(P)});x?g.length>0&&re.push({...b,children:g}):re.push({...b,children:g})}if(!p){let b=i?re:e,y=ke(b),x=Ae(y,$);return(0,o.jsxs)(u,{flexDirection:"column",children:[t?i?b.length>0?(0,o.jsx)(u,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:b.map((S,P)=>(0,o.jsx)(u,{flexDirection:"column",marginTop:P>0?1:0,children:S.children&&S.children.length>0?S.children.map(_=>{if(he(_))return null;let le=!!_.branchObjective,oe=`${_.childId??"p"}-${_.index}-${_.objective}`,n=h.current.has(oe);return le?(0,o.jsxs)(u,{flexDirection:"column",children:[!n&&(0,o.jsx)(K,{step:{..._,children:void 0}}),(_.children??[]).filter(B=>!he(B)).map(B=>(0,o.jsx)(u,{marginLeft:2,children:(0,o.jsx)(K,{step:B})},`f${P}-${_.index}-${B.childId??"p"}-${B.index}`))]},`f${P}-host-${_.childId??"p"}-${_.index}`):(0,o.jsx)(K,{step:_},`f${P}-${_.childId??"p"}-${_.index}`)}):S.status==="pending"&&(0,o.jsx)(s,{color:l.dim,children:" \u25CB Waiting..."})},P))}):null:(0,o.jsx)(De,{steps:e,flows:r,cmInitCounts:a,renderStep:(S,P)=>he(S)?null:(0,o.jsx)(K,{step:S},P)}):(0,o.jsxs)(u,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:[!i&&a&&a[0]!=null&&(0,o.jsxs)(s,{color:l.dim,children:["\u25AA Generated task with ",a[0]," checkpoints"]}),b.filter(S=>!(S.status==="running"&&(!S.children||S.children.length===0))).map(S=>{let P=`${S.index}-${S.objective}`;return i&&h.current.has(P)?(0,o.jsx)(u,{flexDirection:"column",children:(S.children??[]).filter(_=>!he(_)).map(_=>(0,o.jsx)(u,{marginLeft:2,children:(0,o.jsx)(K,{step:_})},`${_.childId??"p"}-${_.index}`))},`branch-children-${S.index}`):(0,o.jsx)(K,{step:S},S.index)})]}),(0,o.jsx)(Ee,{activity:x,describe:T,describeVisible:f}),E.length>0&&(0,o.jsx)($e,{currentStep:ie,maxSteps:d,elapsed:G,status:ne})]})}if(t){let b=ke(e),y=Ae(b,$);return(0,o.jsxs)(u,{flexDirection:"column",children:[(0,o.jsx)(De,{steps:e,flows:r,cmInitCounts:a,renderStep:(x,g)=>he(x)?null:(0,o.jsx)(K,{step:x},g)}),(0,o.jsx)(Ee,{activity:y,describe:T,describeVisible:f}),E.length>0&&(0,o.jsx)($e,{currentStep:ie,maxSteps:d,elapsed:G,status:ne})]})}let Ce=ke(re),Pe=Ae(Ce,$),Z=rt(re);return(0,o.jsxs)(u,{flexDirection:"column",children:[Z.length>0&&(0,o.jsx)(u,{flexDirection:"column",marginLeft:2,paddingLeft:1,children:Z.map(b=>(0,o.jsx)(K,{step:b},b.index))}),(0,o.jsx)(Ee,{activity:Pe,describe:T,describeVisible:f}),E.length>0&&(0,o.jsx)($e,{currentStep:ie,maxSteps:d,elapsed:G,status:ne})]})}var fe=k(D(),1);function it({runner:e,runKey:t,onStepCommit:r}){let a=Ye({isRunning:e.isRunning,bifurcationInfo:e.bifurcationInfo,steps:e.steps,cmInitCounts:e.cmInitCounts,replayInfo:e.replayInfo});return(0,fe.jsxs)(fe.Fragment,{children:[a&&(0,fe.jsx)(Xe,{label:a.label,hasBifurcation:a.hasBifurcation}),e.isRunning&&e.steps.length>0&&(0,fe.jsx)(ot,{steps:e.steps,bifurcated:!!e.bifurcationInfo&&!e.bifurcationInfo.isSingleFlow,flows:e.bifurcationInfo?.flows,cmInitCounts:e.cmInitCounts,maxSteps:e.maxSteps,onStepCommit:r},`run-${t}`)]})}var z=k(D(),1),mt=64;function gt(e){return e.split(`
|
|
6
|
+
`).map(t=>t.replace(/^[-–•]\s*/,"").trim()).filter(t=>t.length>0)}function st({status:e,summary:t,duration:r,steps:a,stepsPassed:d,stepsFailed:p,reason:i,creditsConsumed:T}){let f=e==="passed",$=f?l.green:l.red,h=f?"\u2713":"\u2717",M=e.toUpperCase(),N=d??(f?a:Math.max(0,a-1)),C=p??(f?0:1),v=C>0?`${a} steps (${N} passed, ${C} failed)`:`${a} steps`,I=r<60?`${r.toFixed(1)}s`:`${Math.floor(r/60)}m ${Math.round(r%60)}s`,E=gt(t);return(0,z.jsx)(u,{flexDirection:"column",marginTop:1,children:(0,z.jsxs)(u,{borderStyle:"round",borderColor:$,flexDirection:"column",paddingX:2,paddingY:1,width:mt+6,children:[(0,z.jsxs)(u,{flexDirection:"column",children:[(0,z.jsxs)(s,{bold:!0,color:$,children:[h," ",M]}),(0,z.jsxs)(s,{color:l.dim,wrap:"wrap",children:[v," \xB7 ",I,typeof T=="number"&&T>0?` \xB7 ${parseFloat(T.toFixed(4))} credits`:""]})]}),E.length>0&&(0,z.jsx)(u,{flexDirection:"column",marginTop:1,marginLeft:1,children:E.map((V,Q)=>(0,z.jsxs)(u,{marginBottom:Q<E.length-1?1:0,children:[(0,z.jsx)(s,{color:l.orange,children:"\u25CF "}),(0,z.jsx)(u,{flexShrink:1,children:(0,z.jsx)(s,{wrap:"wrap",children:V})})]},Q))}),i&&!f&&(0,z.jsx)(u,{marginTop:1,children:(0,z.jsxs)(s,{color:l.red,wrap:"wrap",children:["Reason: ",i]})})]})})}var X=k(D(),1);function at({message:e,code:t,remediation:r,docsUrl:a}){return(0,X.jsx)(qe,{title:"Error",variant:"error",children:(0,X.jsxs)(u,{flexDirection:"column",paddingY:1,children:[(0,X.jsxs)(s,{color:l.red,bold:!0,children:[" \u2717 ",e]}),t&&(0,X.jsxs)(u,{marginTop:0,marginLeft:5,children:[(0,X.jsx)(s,{color:l.muted,children:"Code: "}),(0,X.jsx)(s,{color:l.dim,children:t})]}),r&&(0,X.jsxs)(u,{flexDirection:"column",marginTop:1,marginLeft:5,children:[(0,X.jsx)(s,{color:l.green,bold:!0,children:"Fix:"}),(0,X.jsxs)(s,{color:l.orange,children:["$ ",r]})]}),a&&(0,X.jsxs)(u,{marginTop:1,marginLeft:5,children:[(0,X.jsx)(s,{color:l.muted,children:"Docs: "}),(0,X.jsx)(s,{color:l.orange,underline:!0,children:a})]})]})})}var j=k(D(),1);function Ln(e){let{exit:t}=Ne(),{append:r}=Ge(),a=(0,ee.useRef)(!1);(0,ee.useEffect)(()=>{a.current||(a.current=!0,r((0,j.jsx)(u,{flexDirection:"column",marginBottom:1,children:(0,j.jsxs)(u,{borderStyle:"round",borderColor:"#dc4e08",paddingX:2,children:[(0,j.jsx)(s,{color:"#ff9500",bold:!0,children:"KaneAI CLI"}),(0,j.jsx)(s,{color:l.dim,children:" \u2502 "}),(0,j.jsx)(s,{color:l.orange,children:e.topBanner.model}),(0,j.jsx)(s,{color:l.dim,children:" \u2502 "}),(0,j.jsx)(s,{color:l.dim,children:e.topBanner.auth})]})})),r((0,j.jsx)(ht,{data:e.globalConfig})),e.priorAttemptRollup&&r((0,j.jsx)(s,{color:l.dim,children:` \u21B3 replayed ${e.priorAttemptRollup.startIdx}..${e.priorAttemptRollup.endIdx-1} (${e.priorAttemptRollup.count} steps, from prior attempt)`})))},[]);let d=(0,ee.useRef)(null),p=(0,ee.useCallback)(async C=>{let v=await e.getNextStep(C);return v?(d.current=v,v.config):(d.current=null,null)},[e]),i=(0,ee.useCallback)((C,v)=>{let I=d.current;if(!I)return;let E=I.mode==="replay"?"cyan":"#dc4e08",V=I.modeReason?` (${I.modeReason})`:"",Q=I.perStepOverrides?Object.entries(I.perStepOverrides):[];r((0,j.jsxs)(u,{flexDirection:"column",marginBottom:0,children:[(0,j.jsxs)(s,{children:[(0,j.jsxs)(s,{color:l.dim,children:[I.banner.stepLabel," "]}),(0,j.jsxs)(s,{color:E,children:["[",I.mode,"]"]}),(0,j.jsx)(s,{color:l.dim,children:V})]}),(0,j.jsx)(s,{color:l.dim,children:I.banner.objective}),Q.length>0&&(0,j.jsxs)(s,{color:l.dim,children:["overrides: ",Q.map(([se,ie])=>`${se}=${ie}`).join(", ")]})]}))},[r]),T=(0,ee.useRef)(0),f=(0,ee.useRef)(!1),$=(0,ee.useCallback)((C,v)=>(C.hadError?r((0,j.jsx)(at,{message:C.reason??"Runner error",code:"RUNNER_ERROR"})):r((0,j.jsx)(u,{flexDirection:"column",marginBottom:1,children:(0,j.jsx)(st,{status:C.status,summary:C.runEnd?.summary??"",duration:C.runEnd?.duration??0,steps:C.stepsTotal,stepsPassed:C.stepsPassed,stepsFailed:C.stepsFailed,reason:C.runEnd?.reason,creditsConsumed:C.runEnd?.credits_consumed})})),e.onStepEnd?.(C,v)??!0),[r,e]),h=Ve({getNextConfig:p,onStepStart:i,onStepEnd:$,onAllComplete:()=>{e.onAllComplete(),e.exitOnComplete!==!1&&setImmediate(()=>t())},screenshotDispatcher:e.screenshotDispatcher,stepLogger:e.stepLogger,onReasoning:e.onReasoning,onStepComplete:e.onStepComplete,spawnOpts:e.spawnOpts}),M=250,N=5e3;return Me((C,v)=>{if(v.ctrl&&C==="c"){let I=Date.now(),E=I-T.current;if(E<M)return;f.current&&E<N?(h.cancel(),e.onCancel?.(),e.exitOnComplete!==!1&&setImmediate(()=>t())):(f.current=!0,r((0,j.jsx)(s,{color:"yellow",children:"press Ctrl+C again to cancel run"}))),T.current=I}}),(0,j.jsx)(u,{flexDirection:"column",children:h.phase!=="done"&&(0,j.jsx)(it,{runner:h.runner,runKey:h.currentStepIndex,onStepCommit:r})})}function ht({data:e}){return(0,j.jsx)(Ue,{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{ot as a,Xe as b,Ye as c,He as d,Oe as e,st as f,at as g,Ln as h};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as l}from"./chunk-RZ4F3BHX.js";import{a,c,e as o}from"./chunk-
|
|
2
|
+
import{a as l}from"./chunk-RZ4F3BHX.js";import{a,c,e as o}from"./chunk-BGXAW2B5.js";import{readFileSync as f,writeFileSync as d,mkdirSync as h,realpathSync as g}from"fs";import{join as y}from"path";var C="npm install -g @testmuai/kane-cli@latest",b="brew upgrade lambdatest/kane/kane-cli";function w(){try{let t=process.argv[1];if(t&&g(t).includes("/Cellar/"))return b}catch{}return C}var m=y(c,"version-check.json"),S=1440*60*1e3;function k(){try{let t=JSON.parse(f(m,"utf-8"));if(Date.now()-t.checkedAt<S)return t}catch{}return null}function A(t){try{h(c,{recursive:!0}),d(m,JSON.stringify({latest:t,checkedAt:Date.now()}))}catch{}}function u(t,r){let i=t.split(".").map(Number),n=r.split(".").map(Number);for(let s=0;s<3;s++){let e=(n[s]??0)-(i[s]??0);if(e!==0)return e}return 0}function p(t,r){let i=t.split(".").map(Number),n=r.split(".").map(Number);return(n[0]??0)!==(i[0]??0)?"major":(n[1]??0)!==(i[1]??0)?"minor":"patch"}async function j(){try{let t=k();if(t)return u(a,t.latest)>0?{current:a,latest:t.latest,severity:p(a,t.latest)}:null;let r=new AbortController,i=setTimeout(()=>r.abort(),5e3),n=await l(o,{headers:{Accept:"application/json"},signal:r.signal});if(clearTimeout(i),!n.ok)return null;let e=(await n.json())["dist-tags"]?.latest;return e?(A(e),u(a,e)>0?{current:a,latest:e,severity:p(a,e)}:null):null}catch{return null}}export{w as a,u as b,p as c,j as d};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as f}from"./chunk-
|
|
2
|
+
import{b as f}from"./chunk-UR4NSWY7.js";import{x as t}from"./chunk-BGXAW2B5.js";import{a as x}from"./chunk-HCBYKLMW.js";import{a as r,b as n}from"./chunk-C44QQJR4.js";import{a as B}from"./chunk-6YGTRKDT.js";import{e as p}from"./chunk-UR6MHSHU.js";var c=p(B(),1);var e=p(x(),1);function v(){return[{name:"convert",label:"Converting session data",status:"pending"},{name:"zip",label:"Compressing artifacts",status:"pending"},{name:"presign",label:"Requesting upload URLs",status:"pending"},{name:"upload",label:"Uploading to KaneAI",status:"pending"},{name:"atomic_replace",label:"Replacing local output",status:"pending"},{name:"commit_lock",label:"Committing to TMS",status:"pending"},{name:"finalize",label:"Finalizing test case",status:"pending"},{name:"code_export",label:"Downloading test code",status:"pending"}]}function U(s,o,d,a){return s.map(l=>l.name===o?{...l,status:d,detail:a}:l)}function R(s){let o=s/1e3;if(o<60)return`${o.toFixed(1)}s`;let d=Math.floor(o/60),a=Math.round(o%60);return`${d}m ${a}s`}function D(s){let[o,d]=(0,c.useState)(0),a=c.default.useRef(Date.now());return(0,c.useEffect)(()=>{if(!s)return;a.current=Date.now();let l=setInterval(()=>{d(Date.now()-a.current)},100);return()=>clearInterval(l)},[s]),o}function h({steps:s,status:o,testUrl:d,error:a}){let l=D(o==="uploading");return o==="uploading"?(0,e.jsxs)(r,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,e.jsxs)(r,{children:[(0,e.jsx)(n,{color:t.orange,children:"\u2601 "}),(0,e.jsx)(n,{color:t.orange,bold:!0,children:"Saving to KaneAI"}),(0,e.jsxs)(n,{color:t.dim,children:[" ",R(l)]})]}),(0,e.jsx)(r,{flexDirection:"column",marginTop:1,children:s.filter(i=>i.status!=="skipped").map((i,S,T)=>{let b=S===T.length-1?"\u2514\u2500":"\u251C\u2500",u=i.status==="done",m=i.status==="running",g=i.status==="failed";return(0,e.jsxs)(r,{children:[(0,e.jsxs)(n,{color:t.dim,children:[" ",b," "]}),(0,e.jsx)(r,{width:3,children:m?(0,e.jsx)(f,{}):u?(0,e.jsx)(n,{color:t.green,children:"\u2713"}):g?(0,e.jsx)(n,{color:t.red,children:"\u2717"}):(0,e.jsx)(n,{color:t.muted,children:"\u25CB"})}),(0,e.jsx)(n,{color:u?t.dim:m?void 0:g?t.red:t.muted,children:i.label}),i.detail&&(0,e.jsxs)(n,{color:t.dim,children:[" ",i.detail]})]},i.name)})}),(0,e.jsx)(r,{marginTop:1,children:(0,e.jsx)(n,{color:t.muted,children:" press Ctrl+C twice to force exit"})})]}):o==="success"?(0,e.jsx)(e.Fragment,{}):(0,e.jsxs)(r,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,e.jsxs)(r,{children:[(0,e.jsx)(n,{color:t.red,children:"\u2601 "}),(0,e.jsx)(n,{color:t.red,bold:!0,children:"Save failed"})]}),a&&(0,e.jsxs)(r,{marginTop:0,children:[(0,e.jsx)(n,{color:t.dim,children:" "}),(0,e.jsx)(n,{color:t.dim,children:a})]})]})}export{v as a,U as b,h as c};
|
|
@@ -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-LZEYE2WE.js";import{x as s}from"./chunk-BGXAW2B5.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{a as m}from"./chunk-LPUQ4HWQ.js";import{b as f,c as j}from"./chunk-VE3SUJMA.js";import{a as g}from"./chunk-
|
|
2
|
+
import{a as m}from"./chunk-LPUQ4HWQ.js";import{b as f,c as j}from"./chunk-VE3SUJMA.js";import{a as g}from"./chunk-3PISMPFM.js";var _="KaneAI Generated",E="Untitled";async function p(e){let r=e.config.load(),d=new m(g(e.env).tmsBaseUrl,e.tmsCreds.username,e.tmsCreds.access_key),l=e.projectName??_,o=e.folderName??E,t=r.project_id??null,s=r.project_name??null;if(!t){let a=(await d.listProjects()).find(n=>n.name===l);if(a)t=a.project_id,s=a.name,e.log("info","ENSURE_PROJECT_FOUND","Found default project",{project_id:t,name:s});else{let n=await d.createProject(l);t=n.id,s=n.name,e.log("info","ENSURE_PROJECT_CREATED","Created default project",{project_id:t,name:s})}f(e.creds,e.config,e.profile,e.env,{projectId:t,projectName:s})}let c=r.folder_id??null,i=r.folder_name??null,u=!r.project_id;if(!c||u){let a=(await d.listFolders(t)).find(n=>n.name===o);if(a)c=a.id,i=a.name,e.log("info","ENSURE_FOLDER_FOUND","Found default folder",{folder_id:c,name:i});else{let n=await d.createFolder(t,o);c=n.id,i=n.name,e.log("info","ENSURE_FOLDER_CREATED","Created default folder",{folder_id:c,name:i})}f(e.creds,e.config,e.profile,e.env,{folderId:c,folderName:i})}return{projectId:t,projectName:s??l,folderId:c,folderName:i??o}}function N(e,r,d){let l=e.loadProfileConfig(r,d)??{};return{projectId:l.project_id??null,folderId:l.folder_id??null}}function A(e,r){return e.projectId===null||e.folderId===null||r===null?"needs-picker":r.project==="ok"&&r.folder==="ok"?"ok":r.project==="error"&&r.folder==="error"?"ok-tms-degraded":"needs-picker"}var k=(e,r)=>`error: profile "${e}" (${r}) has no project/folder configured AND no TMS credentials were available to auto-configure one.
|
|
3
3
|
|
|
4
4
|
discover IDs:
|
|
5
5
|
kane-cli projects list --search "<keyword>" --limit 10
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as T,f as P,g as $,h as G,j as N,k as M,l as B,m as I,n as L,o as U,p as F,r as z,s as C,t as _,u as O,v as K}from"./chunk-
|
|
2
|
+
import{a as T,f as P,g as $,h as G,j as N,k as M,l as B,m as I,n as L,o as U,p as F,r as z,s as C,t as _,u as O,v as K}from"./chunk-WKS4ST3B.js";import{d as J}from"./chunk-YYSABHRE.js";import{b as k}from"./chunk-DMLJUTQO.js";import{c as E}from"./chunk-K266M5ZM.js";import"./chunk-L5LI2JF4.js";import{a as q}from"./chunk-XCMNFMSO.js";import"./chunk-FPFOW6BS.js";import"./chunk-WAOCHXJ5.js";import"./chunk-IT2GFEFH.js";import{d as x,e as A}from"./chunk-LOIRZFV3.js";import{g as H}from"./chunk-ZRGEUDG5.js";import"./chunk-LPUQ4HWQ.js";import"./chunk-NLCCBXXV.js";import"./chunk-VE3SUJMA.js";import"./chunk-SH5FUG47.js";import{a as j}from"./chunk-HZUTFC3G.js";import"./chunk-ALF5ETLD.js";import{a as R}from"./chunk-3PISMPFM.js";import"./chunk-RZ4F3BHX.js";import"./chunk-BGXAW2B5.js";import"./chunk-UR6MHSHU.js";import{join as se}from"path";async function V(t){let e=t.projectId,n=t.folderId,r=null;if(!e&&t.autoResolve){let l=await t.resolver.resolve();if(!l)throw new $("unauthorized; run `kane-cli login`");let u=await H({creds:t.autoResolve.creds,config:t.autoResolve.config,profile:t.autoResolve.profile,env:t.autoResolve.envName,tmsCreds:{username:l.username,access_key:l.access_key},isLocal:!1,log:t.log});u.status==="ok"&&(e=u.projectId,n=n??u.folderId,u.autoDefaulted&&(r={projectId:u.autoDefaulted.projectId,projectName:u.autoDefaulted.projectName,folderId:u.autoDefaulted.folderId,folderName:u.autoDefaulted.folderName}))}return{baseUrl:`${t.env.testGeneratorBaseUrl}/test-generator/api/v2`,tmsBaseUrl:t.env.tmsBaseUrl,authResolver:t.resolver,projectId:e,folderId:n,suiteName:t.suiteName,autoDefaulted:r,log:t.log}}function Z(t){return t.reduce((e,n)=>e+(n.test_cases?.length??0),0)}var y=class{constructor(e=n=>process.stdout.write(n)){this.write=e}emit(e){this.write(JSON.stringify(e)+`
|
|
3
3
|
`)}onStart(e){this.emit({type:"generate_start",request_id:e.requestId,objective_chars:e.objectiveChars,scenario_limit:e.scenarioLimit,per_scenario_limit:e.perScenarioLimit,is_refine:e.isRefine})}onUpload(e){this.emit({type:"generate_upload",file:e.file,index:e.index,total:e.total,status:e.status})}onThinking(e){this.emit({type:"generate_thinking",took_ms:e.tookMs})}onProgress(e){this.emit({type:"generate_progress",pct:e})}onSnapshot(e){this.emit({type:"generate_snapshot",scenario_count:e.scenarios.length,case_count:Z(e.scenarios),scenarios:e.scenarios})}onClarification(e){this.emit({type:"generate_clarification",text:e})}onChat(e){this.emit({type:"generate_chat",text:e})}onError(e){this.emit({type:"error",message:e})}onSaveResult(e){this.emit({type:"generate_save_result",suite_dir:e.suiteDir,saved:e.saved,fell_back:e.fellBack,...e.warning?{warning:e.warning}:{}})}onDone(e){this.emit({type:"generate_done",request_id:e.requestId,status:e.status,scenario_count:e.scenarioCount,case_count:e.caseCount,refine_hint:e.refineHint,save_hint:e.saveHint,...e.suiteDir?{suite_dir:e.suiteDir}:{}})}onUpdateAvailable(e){this.emit({type:"update_available",current:e.current,latest:e.latest,severity:e.severity})}},S=class{constructor(e=n=>process.stdout.write(n)){this.write=e}onStart(e){let n=e.isRefine?"Refining":"Generating";this.write(`${n} (request ${e.requestId})\u2026
|
|
4
4
|
`)}onUpload(e){e.status==="uploading"&&this.write(` uploading ${e.file} (${e.index}/${e.total})
|
|
5
5
|
`)}onThinking(e){let n=e.tookMs?` (${Math.round(e.tookMs/1e3)}s)`:"";this.write(` thinking${n}
|
|
@@ -16,6 +16,6 @@ import{a as T,f as P,g as $,h as G,j as N,k as M,l as B,m as I,n as L,o as U,p a
|
|
|
16
16
|
`),this.write(` Save: ${e.saveHint}
|
|
17
17
|
`),e.suiteDir&&this.write(` Saved: ${e.suiteDir}
|
|
18
18
|
`)}onUpdateAvailable(e){this.write(`(update available: ${e.current} \u2192 ${e.latest})
|
|
19
|
-
`)}};import{createHash as ee}from"crypto";function te(t){return ee("sha1").update(JSON.stringify({t:t.title,p:t.preconditions,m:t.manual_steps})).digest("hex")}function re(t){let e=[];for(let n of t.scenarios)for(let r of n.test_cases??[])I(r)&&r.manual_steps!=null&&e.push(r);return e}async function ne(t,e,n){let r=new Array(t.length),l=0,u=Array.from({length:Math.min(e,t.length)},async()=>{for(;;){let d=l++;if(d>=t.length)return;try{r[d]={ok:!0,value:await n(t[d])}}catch{r[d]={ok:!1}}}});return await Promise.all(u),r}async function Y(t,e,n){let r=re(t),l=n.run??(async(c,s)=>{let m=await n.resolveAuth(),o=U({objective:c,model:n.model,sessionId:n.sessionId,auth:m});return F(o,n.spawnOpts,s)}),u=r.map(te),d=[...new Set(u)],g=new Map;d.forEach(c=>{g.set(c,r[u.indexOf(c)])});let p=d.map(c=>g.get(c)),v=await ne(p,n.concurrency??3,c=>l(L(c))),i=new Map;d.forEach((c,s)=>{let m=v[s];m.ok&&i.set(c,m.value)});let f=new Map;r.forEach((c,s)=>{f.set(c.id,i.get(u[s]))});let a=0;for(let c of t.scenarios)for(let s of c.test_cases??[])I(s)&&!f.get(s.id)&&a++;let w=c=>{let s=f.get(c.id);return s?N(s,c):M(c)};return{...await B(t,e,{suiteName:n.suiteName,redirectBareCwd:!1},w),fellBack:a}}function Pe(t,e){let n=!!t.agent||!!t.refine||!!t.save||!e,r=t.agent?"agent":"plain";return{headless:n,mode:r}}function $e(t){return t.refine&&t.save?{error:"use --refine or --save, not both"}:t.save?t.objective?{error:"--save takes no objective; use --refine to add to a request"}:t.req?{op:"save"}:{error:"--save requires --req <id>"}:t.refine?t.req?t.objective?t.out?{error:"--out is only valid with --save"}:{op:"refine"}:{error:"--refine needs a refinement objective"}:{error:"--refine requires --req <id>"}:t.req?{error:"--req requires --refine or --save"}:t.out?{error:"--out is only valid with --save"}:t.objective?{op:"new"}:{error:"provide an objective, or use --refine/--save with --req"}}function ie(){return se(process.cwd(),".testmuai","tests")}function Ge(t){if(typeof t!="string")return;let e=t.split(",").map(n=>n.trim()).filter(Boolean);return e.length?e:void 0}var X="tcg-generate-headless";function Q(t){return{refineHint:`kane-cli generate "<refinement>" --refine --req ${t}`,saveHint:`kane-cli generate --save --req ${t}`}}function W(t){return t.scenarios.reduce((e,n)=>e+(n.test_cases?.length??0),0)}function oe(t){return t==="completed"?0:t==="stopped"?3:1}async function Ne(t,e){let n=e.write??(i=>process.stdout.write(i)),r=e.sink??(e.mode==="agent"?new y(n):new S(n)),l,u,d=null;try{let i=await e.makeClient();l=i.client,u=i.conn,d=i.autoDefaulted}catch(i){return r.onError(i.message),2}if(e.mode==="agent"&&d){let{buildAutoDefaultedNdjson:i}=await import("./require-project-folder-
|
|
19
|
+
`)}};import{createHash as ee}from"crypto";function te(t){return ee("sha1").update(JSON.stringify({t:t.title,p:t.preconditions,m:t.manual_steps})).digest("hex")}function re(t){let e=[];for(let n of t.scenarios)for(let r of n.test_cases??[])I(r)&&r.manual_steps!=null&&e.push(r);return e}async function ne(t,e,n){let r=new Array(t.length),l=0,u=Array.from({length:Math.min(e,t.length)},async()=>{for(;;){let d=l++;if(d>=t.length)return;try{r[d]={ok:!0,value:await n(t[d])}}catch{r[d]={ok:!1}}}});return await Promise.all(u),r}async function Y(t,e,n){let r=re(t),l=n.run??(async(c,s)=>{let m=await n.resolveAuth(),o=U({objective:c,model:n.model,sessionId:n.sessionId,auth:m});return F(o,n.spawnOpts,s)}),u=r.map(te),d=[...new Set(u)],g=new Map;d.forEach(c=>{g.set(c,r[u.indexOf(c)])});let p=d.map(c=>g.get(c)),v=await ne(p,n.concurrency??3,c=>l(L(c))),i=new Map;d.forEach((c,s)=>{let m=v[s];m.ok&&i.set(c,m.value)});let f=new Map;r.forEach((c,s)=>{f.set(c.id,i.get(u[s]))});let a=0;for(let c of t.scenarios)for(let s of c.test_cases??[])I(s)&&!f.get(s.id)&&a++;let w=c=>{let s=f.get(c.id);return s?N(s,c):M(c)};return{...await B(t,e,{suiteName:n.suiteName,redirectBareCwd:!1},w),fellBack:a}}function Pe(t,e){let n=!!t.agent||!!t.refine||!!t.save||!e,r=t.agent?"agent":"plain";return{headless:n,mode:r}}function $e(t){return t.refine&&t.save?{error:"use --refine or --save, not both"}:t.save?t.objective?{error:"--save takes no objective; use --refine to add to a request"}:t.req?{op:"save"}:{error:"--save requires --req <id>"}:t.refine?t.req?t.objective?t.out?{error:"--out is only valid with --save"}:{op:"refine"}:{error:"--refine needs a refinement objective"}:{error:"--refine requires --req <id>"}:t.req?{error:"--req requires --refine or --save"}:t.out?{error:"--out is only valid with --save"}:t.objective?{op:"new"}:{error:"provide an objective, or use --refine/--save with --req"}}function ie(){return se(process.cwd(),".testmuai","tests")}function Ge(t){if(typeof t!="string")return;let e=t.split(",").map(n=>n.trim()).filter(Boolean);return e.length?e:void 0}var X="tcg-generate-headless";function Q(t){return{refineHint:`kane-cli generate "<refinement>" --refine --req ${t}`,saveHint:`kane-cli generate --save --req ${t}`}}function W(t){return t.scenarios.reduce((e,n)=>e+(n.test_cases?.length??0),0)}function oe(t){return t==="completed"?0:t==="stopped"?3:1}async function Ne(t,e){let n=e.write??(i=>process.stdout.write(i)),r=e.sink??(e.mode==="agent"?new y(n):new S(n)),l,u,d=null;try{let i=await e.makeClient();l=i.client,u=i.conn,d=i.autoDefaulted}catch(i){return r.onError(i.message),2}if(e.mode==="agent"&&d){let{buildAutoDefaultedNdjson:i}=await import("./require-project-folder-LSM4YSKJ.js");n(i(d))}try{let i=await(e.checkUpdate??J)();i&&r.onUpdateAvailable(i)}catch{}let g=t.reqId??null;x(X,()=>{g&&l.cancel(g).catch(()=>{})});let p=process.cwd(),v={validate:e.validate??z,upload:e.upload??O,buildMappings:K,onUpload:i=>r.onUpload(i)};try{if(t.op==="save"){let s;try{s=(await l.attach(t.reqId)).state}catch(D){return r.onError(D.message),2}g=s.requestId,r.onSnapshot(s);let m=t.outDir??ie(),o=await e.materialize(s,m,t.suiteName);r.onSaveResult({suiteDir:o.suiteDir,saved:o.paths.length,fellBack:o.fellBack,warning:o.warning});let h=Q(s.requestId);return r.onDone({requestId:s.requestId,status:"completed",scenarioCount:s.scenarios.length,caseCount:W(s),refineHint:h.refineHint,saveHint:h.saveHint,suiteDir:o.suiteDir}),0}let i=t.op==="refine",f,a;if(i){let s;try{s=await l.attach(t.reqId)}catch(o){return r.onError(o.message),2}if(a=s.state,g=a.requestId,a.error)return r.onError(a.error),2;let m;try{m=await _({promptText:t.objective,filePaths:t.files??[],cwd:p,scenarios:a.scenarios,isRefine:!0,conn:u,deps:v})}catch(o){if(o instanceof C){for(let h of o.errors)r.onError(h);return 2}return r.onError(o.message),2}for(let o of m.warnings)process.stderr.write(`warning: ${o}
|
|
20
20
|
`);r.onStart({requestId:a.requestId,objectiveChars:m.promptText.length,scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit,isRefine:!0});try{await l.chat(t.reqId,m.promptText,{mappings:m.mappings,attachments:m.attachments})}catch(o){return r.onError(o.message),2}f=s.events}else{let s;try{s=await _({promptText:t.objective,filePaths:t.files??[],cwd:p,scenarios:[],isRefine:!1,conn:u,deps:v})}catch(o){if(o instanceof C){for(let h of o.errors)r.onError(h);return 2}return r.onError(o.message),2}for(let o of s.warnings)process.stderr.write(`warning: ${o}
|
|
21
21
|
`);let m;try{m=await l.start({prompt:s.promptText,attachments:s.attachments,scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit,memoryEnhancement:t.memory})}catch(o){return r.onError(o.message),2}a=m.state,g=a.requestId,r.onStart({requestId:a.requestId,objectiveChars:s.promptText.length,scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit,isRefine:!1}),f=m.events}let w="";for await(let s of f){switch(a=P(a,s),s.type){case"thinking_done":r.onThinking({tookMs:s.tookMs});break;case"progress":r.onProgress(s.pct);break;case"clarification":r.onClarification(s.text);break;case"chat":r.onChat(s.text);break;case"error":r.onError(s.message);break;case"done":w=s.status;break;default:break}if(s.type==="done"||s.type!=="thinking"&&a.status&&T(a.status))break}r.onSnapshot(a);let b=w||a.status||"completed",c=Q(a.requestId);return r.onDone({requestId:a.requestId,status:b,scenarioCount:a.scenarios.length,caseCount:W(a),refineHint:c.refineHint,saveHint:c.saveHint,suiteDir:void 0}),oe(b)}finally{A(X)}}var ae=()=>{};async function Me(t){let e=new j,n=new q,r=e.getActiveProfile()??"default",l=t.env??e.getDefaultEnv()??"prod",u=R(l),d=new E;t.name&&d.setSessionName(t.name);let g=n.load().model,p=async()=>{let i=await k({creds:e,env:l,usernameFlag:t.username,accessKeyFlag:t.accessKey,log:()=>{}}),f=await V({resolver:i.resolver,env:u,log:ae,projectId:t.projectId,folderId:t.folderId,autoResolve:t.projectId?void 0:{creds:e,config:n,profile:r,envName:l}});return{client:G(f),conn:f,autoDefaulted:f.autoDefaulted??null}},v=async()=>{let i=await k({creds:e,env:l,usernameFlag:t.username,accessKeyFlag:t.accessKey,log:()=>{}});return i.basicAuth?{username:i.basicAuth.username,access_key:i.basicAuth.access_key}:i.token?{auth:{type:"bearer",token:i.token}}:{}};return{mode:t.mode,makeClient:p,materialize:(i,f,a)=>Y(i,f,{model:g,sessionId:d.sessionId,resolveAuth:v,spawnOpts:{environment:l},suiteName:a})}}export{Me as buildHeadlessDeps,Pe as decideGenerateMode,ie as defaultOutDir,Ge as parseFilesFlag,$e as resolveGenerateOp,Ne as runGenerateHeadless};
|