@testmuai/kane-cli 0.4.5 → 0.4.7
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-DHEEFWVV.js → ChromeProfilePicker-HZP2G3K4.js} +1 -1
- package/dist/{CliFeedbackPrompt-XVBAXCYR.js → CliFeedbackPrompt-FTEA5JNK.js} +1 -1
- package/dist/{CliUploadProgress-4S3BH3LI.js → CliUploadProgress-3OPVLWXH.js} +1 -1
- package/dist/{ConfigView-Q5NNM5T5.js → ConfigView-NMRRHEMR.js} +1 -1
- package/dist/FolderPicker-3YHJUXE3.js +2 -0
- package/dist/HelpView-RIRNOKNM.js +2 -0
- package/dist/{InfoBox-TBM3RTBH.js → InfoBox-AXNZSJME.js} +1 -1
- package/dist/{LinksBox-WRMIRJLF.js → LinksBox-PYJZFOAG.js} +1 -1
- package/dist/{ProfilesView-GGYBHIOM.js → ProfilesView-BVR2IFBT.js} +1 -1
- package/dist/{ProjectPicker-UEVYQGLY.js → ProjectPicker-3FZJ4RK3.js} +1 -1
- package/dist/{SaveSessionPrompt-KYL6AOGP.js → SaveSessionPrompt-INCEUNPR.js} +1 -1
- package/dist/SingleShotApp-QDTII55J.js +2 -0
- package/dist/{SummaryBox-B4QJDLQD.js → SummaryBox-FMDQB4GN.js} +1 -1
- package/dist/TestMdRunView-FTWVR2DR.js +2 -0
- package/dist/{WhoamiView-BY57RUTR.js → WhoamiView-JLEFXOHP.js} +1 -1
- package/dist/{changelog-OM726WGL.js → changelog-O5IX7XHA.js} +1 -1
- package/dist/{chunk-SNV7DD5M.js → chunk-2H3DN3F5.js} +1 -1
- package/dist/{chunk-5WMT2WVI.js → chunk-2TAGK72D.js} +1 -1
- package/dist/{chunk-EQLDX5LN.js → chunk-467Q6LTP.js} +1 -1
- package/dist/{chunk-LY2SBSUM.js → chunk-4DRZNE2I.js} +1 -1
- package/dist/{chunk-GVXJKQF7.js → chunk-5QBGINQ5.js} +1 -1
- package/dist/{chunk-VF6NQFGC.js → chunk-5W225L2A.js} +1 -1
- package/dist/{chunk-K77SVBYU.js → chunk-6F5KNQEY.js} +1 -1
- package/dist/{chunk-XT45Z36Q.js → chunk-7DJANARQ.js} +1 -1
- package/dist/{chunk-SDY6K7ZR.js → chunk-ACIVGK3W.js} +1 -1
- package/dist/{chunk-FTWHK7PH.js → chunk-AVEPDV55.js} +1 -1
- package/dist/{chunk-D3NAXZ2R.js → chunk-BH6EP2LD.js} +9 -9
- package/dist/{chunk-X6FNT3EY.js → chunk-DPWUXRRO.js} +1 -1
- package/dist/chunk-DTFX3TMY.js +27 -0
- package/dist/{chunk-MBK47QLD.js → chunk-GRFHOT5X.js} +1 -1
- package/dist/{chunk-62ZUB3DG.js → chunk-HFRJE27Y.js} +1 -1
- package/dist/{chunk-6XWZHEQR.js → chunk-JFSBM4Z2.js} +1 -1
- package/dist/{chunk-WGYUOXJX.js → chunk-JPJFIOL7.js} +1 -1
- package/dist/{chunk-DVRZITSK.js → chunk-JSHGADRY.js} +1 -1
- package/dist/{chunk-E5WH7UGU.js → chunk-KHDW3N76.js} +1 -1
- package/dist/{chunk-4D5Z4OAS.js → chunk-KWGOSWHO.js} +1 -1
- package/dist/{chunk-GG73PQBI.js → chunk-NXAP7EWY.js} +2 -2
- package/dist/{chunk-S6DJADYF.js → chunk-OXHG2VIS.js} +1 -1
- package/dist/chunk-PGBUS6CL.js +8 -0
- package/dist/{chunk-T4WDQ7I4.js → chunk-PGKK7FRX.js} +1 -1
- package/dist/{chunk-HIFHTE2F.js → chunk-PI6BJEFB.js} +2 -2
- package/dist/{chunk-6GWQ2RA4.js → chunk-QLSRT65Q.js} +1 -1
- package/dist/chunk-RJW244F2.js +5 -0
- package/dist/{chunk-EWID6VQA.js → chunk-SX3MRVIA.js} +1 -1
- package/dist/{chunk-N7OAA2OD.js → chunk-V7ONIYZZ.js} +1 -1
- package/dist/chunk-VVPV3NA5.js +2 -0
- package/dist/{chunk-4EDPYAMW.js → chunk-WJRZKLUW.js} +34 -34
- package/dist/{chunk-BDMQY6N6.js → chunk-XBL2ZPYQ.js} +1 -1
- package/dist/{chunk-7XX4XFCV.js → chunk-Y7Q7OG2K.js} +1 -1
- package/dist/{chunk-Q5XYITHT.js → chunk-YIZ6D6YX.js} +1 -1
- package/dist/chunk-YTWM34XC.js +6 -0
- package/dist/{chunk-F22NYY2I.js → chunk-YVYIWAPJ.js} +1 -1
- package/dist/{chunk-UJJX2Y5K.js → chunk-ZHQVKKQZ.js} +2 -2
- package/dist/{generate-headless-6SH67NQN.js → generate-headless-J2Z5B3A5.js} +2 -2
- package/dist/index.js +39 -39
- package/dist/{list-commands-4OC75YL3.js → list-commands-UD7CKE46.js} +1 -1
- package/dist/login-flow-MCDTID4T.js +2 -0
- package/dist/{persist-recorded-session-HXVQRBJV.js → persist-recorded-session-W44GRYTY.js} +1 -1
- package/dist/{pipeline-IXEPO6AR.js → pipeline-34CX3UBO.js} +1 -1
- package/dist/{recording-banner-G3BDHTZU.js → recording-banner-I7W76JOM.js} +1 -1
- package/dist/{require-project-folder-VSJ3UJL6.js → require-project-folder-R746X2BU.js} +1 -1
- package/dist/{run-test-md-JVYGWYZJ.js → run-test-md-NZ32YJC7.js} +5 -5
- package/dist/{skill-installer-2CMWR2TX.js → skill-installer-GXQ6LRHC.js} +1 -1
- package/dist/tcg-generate-74IGNDXD.js +2 -0
- package/dist/testmd-actions-52KGXWZI.js +2 -0
- package/dist/token-refresh-4XAFVTGR.js +2 -0
- package/dist/{validate-basic-F6DP3VUX.js → validate-basic-SYV4FFMJ.js} +1 -1
- package/dist/{version-check-JHH3FYZ4.js → version-check-6EDCR423.js} +1 -1
- package/package.json +6 -6
- package/dist/FolderPicker-T575L6QE.js +0 -2
- package/dist/HelpView-2T36LFLG.js +0 -2
- package/dist/SingleShotApp-DOEY5FTW.js +0 -2
- package/dist/TestMdRunView-J3M33BMA.js +0 -2
- package/dist/chunk-73TFORTS.js +0 -8
- package/dist/chunk-AYWWHMM7.js +0 -2
- package/dist/chunk-D2J4EILJ.js +0 -22
- package/dist/chunk-I5KH34BI.js +0 -5
- package/dist/chunk-K74XYWPF.js +0 -5
- package/dist/login-flow-GLIUZ3XD.js +0 -2
- package/dist/tcg-generate-JNA7RLSH.js +0 -2
- package/dist/testmd-actions-3YF6E3W6.js +0 -2
- package/dist/token-refresh-TPRQLK6B.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-RJW244F2.js";import{a as ue,b as Te}from"./chunk-JFSBM4Z2.js";import{d as Ke,f as xe}from"./chunk-LOIRZFV3.js";import{a as Ue}from"./chunk-Y7Q7OG2K.js";import{a as qe}from"./chunk-VVPV3NA5.js";import{b as Ge}from"./chunk-C6S4IEBC.js";import{x as l}from"./chunk-DPWUXRRO.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 R}from"./chunk-
|
|
2
|
+
import{a as R}from"./chunk-7DJANARQ.js";import{x as r}from"./chunk-DPWUXRRO.js";import{a as Y}from"./chunk-HCBYKLMW.js";import{a,b as i,i as X}from"./chunk-C44QQJR4.js";import{a as G}from"./chunk-6YGTRKDT.js";import{e as P}from"./chunk-UR6MHSHU.js";var u=P(G(),1);var e=P(Y(),1),f=5;function K(t,I){if(!I)return t;let c=I.toLowerCase();return t.filter(B=>B.label.toLowerCase().includes(c))}function J(t){let{title:I,items:c,loading:B=!1,loadingText:F,error:L=null,itemNoun:T="items",onSelect:H,onCancel:E,defaultActiveId:w,onTab:y,extraHint:N}=t,[x,d]=(0,u.useState)(0),[S,g]=(0,u.useState)(0),[s,A]=(0,u.useState)(""),[C,h]=(0,u.useState)(null);(0,u.useEffect)(()=>{if(c.length===0)return;if(t.preserveSelectionById&&C!==null){let n=c.findIndex(o=>o.id===C);if(n>=0){g(Math.floor(n/f)),d(n%f);return}}let l=w?c.findIndex(n=>n.id===w):c.findIndex(n=>n.isActive);l>=0?(g(Math.floor(l/f)),d(l%f),t.preserveSelectionById&&h(c[l].id)):t.preserveSelectionById&&(g(0),d(0),h(c[0]?.id??null))},[c,w,t.preserveSelectionById,C]),(0,u.useEffect)(()=>{if(!t.onSearch)return;let l=setTimeout(()=>t.onSearch(s),t.searchDebounceMs??250);return()=>clearTimeout(l)},[s,t.onSearch,t.searchDebounceMs]);let m=t.onSearch?c:K(c,s),M=S*f,p=Math.min(M+f,m.length),D=Math.ceil(m.length/f),O=p-M,v=m.slice(M,p);return X((l,n)=>{if(L){n.escape&&E();return}if(n.escape){s?(A(""),d(0),g(0)):E();return}if(n.tab&&y){y();return}if(n.upArrow){if(x>0){let o=x-1;d(o),t.preserveSelectionById&&h(v[o]?.id??null)}else if(S>0){let o=S-1,b=f-1;g(o),d(b),t.preserveSelectionById&&h(m[o*f+b]?.id??null)}return}if(n.downArrow){if(x<O-1){let o=x+1;d(o),t.preserveSelectionById&&h(v[o]?.id??null)}else if(S<D-1){let o=S+1,b=0;g(o),d(b),t.preserveSelectionById&&h(m[o*f+b]?.id??null)}return}if(n.return&&v[x]){H(v[x]);return}if(n.backspace||n.delete){A(o=>o.slice(0,-1)),d(0),g(0);return}l&&!n.ctrl&&!n.meta&&(A(o=>o+l),d(0),g(0))},{isActive:!B}),B?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,e.jsx)(i,{color:r.orange,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(i,{color:r.secondary,children:F??`Loading ${T}\u2026`})})]}):L?(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.red,paddingX:2,paddingY:1,children:[(0,e.jsx)(i,{color:r.red,bold:!0,children:I}),(0,e.jsx)(a,{marginTop:1,children:(0,e.jsx)(i,{color:r.red,children:L})}),(0,e.jsx)(R,{bindings:[]})]}):(0,e.jsxs)(a,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,e.jsxs)(a,{children:[(0,e.jsx)(i,{color:r.orange,bold:!0,children:I}),(0,e.jsxs)(i,{color:r.dim,children:[" (",m.length,!t.onSearch&&s?`/${c.length}`:""," ",T,t.loadingMore?" \xB7 loading more":"",")"]})]}),(0,e.jsxs)(a,{marginTop:1,children:[(0,e.jsx)(i,{color:r.secondary,children:s?"filter: ":""}),s?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsx)(i,{children:s}),(0,e.jsx)(i,{inverse:!0,children:" "})]}):(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)(i,{color:r.dim,children:["Search ",T,"\u2026"]}),(0,e.jsx)(i,{inverse:!0,children:" "})]})]}),(0,e.jsx)(a,{flexDirection:"column",marginTop:1,children:t.searching?(0,e.jsxs)(i,{color:r.secondary,children:["Searching ",T,"\u2026"]}):m.length===0?(0,e.jsxs)(i,{color:r.dim,children:["No ",T,' match "',s,'"']}):v.map((l,n)=>{let o=n===x,b=o?"\u276F ":" ",$=l.isActive?r.green:o?r.orange:void 0;return(0,e.jsxs)(i,{color:$,children:[b,l.label,l.isActive?" \u25CF selected":""]},l.id)})}),!t.searching&&D>1&&(0,e.jsx)(a,{marginTop:1,children:(0,e.jsxs)(i,{color:r.dim,children:["Page ",S+1,"/",D]})}),t.footer&&(0,e.jsx)(a,{marginTop:1,flexDirection:"column",children:t.footer}),(0,e.jsx)(R,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"type",label:"to search"},{keys:"\u21B5",label:"select"},...y&&N?[{keys:"tab",label:N}]:[]],escBackLabel:s?"clear":"back to chat"})]})}export{J as a};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as k}from"./chunk-FPFOW6BS.js";import{g as a}from"./chunk-LOIRZFV3.js";import{a as m}from"./chunk-LPUQ4HWQ.js";import{a as h}from"./chunk-
|
|
2
|
+
import{a as k}from"./chunk-FPFOW6BS.js";import{g as a}from"./chunk-LOIRZFV3.js";import{a as m}from"./chunk-LPUQ4HWQ.js";import{a as h}from"./chunk-JPJFIOL7.js";import{a as y}from"./chunk-2TAGK72D.js";var $=10,u=200,N=1e4,S=1e6;function T(t,e,r="streaming"){let n=r==="full-fetch"?S:N,o=$,i=0;if(t!==void 0){let s=Number(t);if(!Number.isInteger(s)||s<1||s>u)return{error:`--limit must be an integer in [1, ${u}] (got "${t}")`};o=s}if(e!==void 0){let s=Number(e);if(!Number.isInteger(s)||s<0||s>n)return{error:`--offset must be an integer in [0, ${n}] (got "${e}")`};i=s}return{limit:o,offset:i}}function C(t,e){if(!e)return t;let r=e.toLowerCase();return t.filter(n=>n.name.toLowerCase().includes(r))}function j(t,{limit:e,offset:r}){let n=t.slice(r,r+e),o=t.length>r+e;return{slice:n,hasMore:o}}function v(t,e,r=n=>process.stdout.write(`${n}
|
|
3
3
|
`)){for(let n of t)r(JSON.stringify(n));r(JSON.stringify({_meta:"page",limit:e.limit,offset:e.offset,returned:t.length,has_more:e.has_more}))}function b(t,e,r=n=>process.stdout.write(`${n}
|
|
4
|
-
`)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:d}=await import("./token-refresh-
|
|
4
|
+
`)){if(t.length===0){r("(no results)");return}let n=Math.max(2,...t.map(s=>s.id.length)),o=`${"ID".padEnd(n)} NAME`;r(o),r(`${"-".repeat(n)} ----`);for(let s of t)r(`${s.id.padEnd(n)} ${s.name}`);r("");let i=e.offset+t.length;if(e.hasMore){let s=e.totalIsLowerBound?`${e.total}+`:`${e.total}`;r(`${i} of ${s} \u2014 next: --offset ${e.offset+e.limit}`)}else r(`${t.length} shown (${e.total} total)`)}async function B(t,e,r){if(r.username&&r.accessKey)return{ok:!0,creds:{username:r.username,access_key:r.accessKey}};let n=new h,o=n.loadBasicAuth(t,e);if(o)return{ok:!0,creds:{username:o.username,access_key:o.access_key}};let i=n.loadCredentials(t,e);if(!i)return{ok:!1,reason:"no_credentials"};let s=i.access_token;try{let{refreshOAuthToken:d}=await import("./token-refresh-4XAFVTGR.js"),w=await d({creds:n,profile:t,env:e,credentials:i});w&&(s=w.accessToken)}catch(d){return{ok:!1,reason:"refresh_failed",detail:d instanceof Error?d.message:String(d)}}let c=y(e),f=await new k(c.controllerBaseUrl,async()=>s,null).resolve();return f?{ok:!0,creds:{username:f.username,access_key:f.access_key}}:{ok:!1,reason:"exchange_failed"}}function E(t,e,r){switch(r.reason){case"no_credentials":return{message:`error: no credentials for profile "${t}" [${e}]. Run \`kane-cli login\` or pass --username/--access-key.
|
|
5
5
|
`,exitCode:2};case"refresh_failed":return{message:`error: OAuth token refresh failed for profile "${t}" [${e}]${r.detail?`: ${r.detail}`:""}. Run \`kane-cli login\` to re-auth.
|
|
6
6
|
`,exitCode:2};case"exchange_failed":return{message:`error: TMS credential exchange failed for profile "${t}" [${e}]. Token may be revoked \u2014 try \`kane-cli login\`; if the problem persists, TMS may be down.
|
|
7
7
|
`,exitCode:2}}}function O(t){return{id:t.project_id,name:t.name}}function M(t){return{id:t.id,name:t.name}}async function P(t,e,r,n){let o=r+n+1,i=[],s=!0;for await(let c of t.listProjectsStream({name:e})){if(i.push(...c.projects),c.done){s=!0;break}if(i.length>=o){s=!1;break}}return{items:i,doneStreaming:s}}function g(t){return!!t.agent||!process.stdin.isTTY||!process.stdout.isTTY}function _(t,e=r=>process.stdout.write(`${r}
|
|
@@ -1,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-4DRZNE2I.js";import{d as J}from"./chunk-KHDW3N76.js";import{b as k}from"./chunk-HFRJE27Y.js";import{c as E}from"./chunk-SX3MRVIA.js";import"./chunk-L5LI2JF4.js";import{a as q}from"./chunk-PGBUS6CL.js";import"./chunk-FPFOW6BS.js";import"./chunk-WAOCHXJ5.js";import"./chunk-RJW244F2.js";import{d as x,e as A}from"./chunk-LOIRZFV3.js";import{g as H}from"./chunk-JSHGADRY.js";import"./chunk-LPUQ4HWQ.js";import"./chunk-NLCCBXXV.js";import"./chunk-VE3SUJMA.js";import"./chunk-AVEPDV55.js";import{a as j}from"./chunk-JPJFIOL7.js";import"./chunk-XBL2ZPYQ.js";import{a as R}from"./chunk-2TAGK72D.js";import"./chunk-RZ4F3BHX.js";import"./chunk-DPWUXRRO.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-R746X2BU.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};
|