@testmuai/kane-cli 0.4.0 → 0.4.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{ChromeProfilePicker-27QCT4NT.js → ChromeProfilePicker-HNP7QQ4J.js} +1 -1
- package/dist/{CliFeedbackPrompt-LMXDRY5F.js → CliFeedbackPrompt-OSNATI4W.js} +1 -1
- package/dist/{CliUploadProgress-QP5SPC7G.js → CliUploadProgress-7HRWDZ4P.js} +1 -1
- package/dist/ConfigView-PQH67FUK.js +2 -0
- package/dist/FolderPicker-SET7IG6S.js +2 -0
- package/dist/HelpView-HFKFRKG3.js +2 -0
- package/dist/{InfoBox-JELKGWY5.js → InfoBox-3IN3IZ2I.js} +1 -1
- package/dist/{LinksBox-NUSUOUIW.js → LinksBox-DI5QKX6K.js} +1 -1
- package/dist/{ProfilesView-RXYI2IS3.js → ProfilesView-N6XNSUHQ.js} +1 -1
- package/dist/ProjectPicker-6QIVHOO7.js +2 -0
- package/dist/{SaveSessionPrompt-GUBVAQ3O.js → SaveSessionPrompt-7CZHPNYK.js} +1 -1
- package/dist/SingleShotApp-A4VXMXEZ.js +2 -0
- package/dist/{SummaryBox-5Y2YYOUM.js → SummaryBox-7ZK2A6MA.js} +1 -1
- package/dist/TestMdRunView-KGHEZZBK.js +2 -0
- package/dist/WhoamiView-3E447A3G.js +2 -0
- package/dist/{changelog-N4SSER5V.js → changelog-ZBTZCYKI.js} +1 -1
- package/dist/chunk-34YRU7WM.js +6 -0
- package/dist/chunk-3QWAABMG.js +2 -0
- package/dist/{chunk-CKY3UXTY.js → chunk-4UKCDU64.js} +1 -1
- package/dist/{chunk-PWHFNSDC.js → chunk-4ZHU4DLD.js} +1 -1
- package/dist/{chunk-5TOE4RHH.js → chunk-7CBWZLRS.js} +1 -1
- package/dist/{chunk-PKQJHIKJ.js → chunk-AAJSF67A.js} +1 -1
- package/dist/{chunk-JCR3T34A.js → chunk-AKKATURY.js} +2 -2
- package/dist/chunk-BM25JQ3Z.js +17 -0
- package/dist/chunk-C6S4IEBC.js +2 -0
- package/dist/{chunk-TAEW7PXN.js → chunk-CZBHDBID.js} +1 -1
- package/dist/chunk-DGUXTSHM.js +11 -0
- package/dist/chunk-DQASLGFG.js +60 -0
- package/dist/{chunk-6NEJEMA6.js → chunk-EEF6OT52.js} +1 -1
- package/dist/{chunk-LMV2F35W.js → chunk-ELZIC2EH.js} +1 -1
- package/dist/chunk-FFTIDI5K.js +5 -0
- package/dist/chunk-FPFOW6BS.js +2 -0
- package/dist/{chunk-AT2Y5UNP.js → chunk-GNJBT6SS.js} +1 -1
- package/dist/{chunk-UJZCMEEH.js → chunk-H2P7UJAU.js} +1 -1
- package/dist/chunk-K4PLPKPF.js +5 -0
- package/dist/{chunk-7RPMUEEN.js → chunk-KPF3BPJ5.js} +1 -1
- package/dist/chunk-LOIRZFV3.js +10 -0
- package/dist/{chunk-O2UU4TS5.js → chunk-LOSNFBZV.js} +1 -1
- package/dist/chunk-LPUQ4HWQ.js +2 -0
- package/dist/chunk-LY5LHKGG.js +18 -0
- package/dist/chunk-NKFXY5TF.js +22 -0
- package/dist/chunk-OISHNB7D.js +2 -0
- package/dist/chunk-PF7PBYCJ.js +5 -0
- package/dist/{chunk-VS2BXLH4.js → chunk-PQIPYWTP.js} +1 -1
- package/dist/chunk-QXVI3LI4.js +6 -0
- package/dist/{chunk-CGAX3AXA.js → chunk-R7T6Z6QW.js} +1 -1
- package/dist/chunk-RCL22HDJ.js +2 -0
- package/dist/{chunk-XQXSPUIX.js → chunk-RD6G3CMN.js} +1 -1
- package/dist/chunk-RLSBAT6P.js +2 -0
- package/dist/chunk-S7JV4A3U.js +2 -0
- package/dist/{chunk-IH45REQA.js → chunk-TQGNNJX5.js} +1 -1
- package/dist/{chunk-VTDVK3DK.js → chunk-UHGECBEN.js} +1 -1
- package/dist/chunk-VBZIIF5N.js +17 -0
- package/dist/chunk-VL57GII7.js +2 -0
- package/dist/chunk-WFSTRBQF.js +2 -0
- package/dist/chunk-Y6IUJZMV.js +2 -0
- package/dist/{chunk-HYVAYSRZ.js → chunk-YB67GRWE.js} +1 -1
- package/dist/exit-manager-V2NW7A7U.js +2 -0
- package/dist/generate-headless-WL6A6ACX.js +21 -0
- package/dist/index.js +41 -31
- package/dist/list-commands-MK4W3Q7O.js +2 -0
- package/dist/login-flow-CDR6ARK3.js +2 -0
- package/dist/{persist-recorded-session-VEFILVPX.js → persist-recorded-session-A5EJ25AE.js} +1 -1
- package/dist/{pipeline-3GVPCDRE.js → pipeline-L5TDZMLS.js} +1 -1
- package/dist/{recording-banner-WS4Y7LVH.js → recording-banner-6UI6NNRK.js} +1 -1
- package/dist/require-project-folder-J5WZR653.js +2 -0
- package/dist/resolver-IDCGRPFJ.js +2 -0
- package/dist/run-test-md-I76IV7QA.js +14 -0
- package/dist/scrollback-6GINSTL2.js +2 -0
- package/dist/skill-installer-ZLBRT4QP.js +3 -0
- package/dist/tcg-generate-R6P4QUGO.js +2 -0
- package/dist/testmd-actions-W2INQVTH.js +2 -0
- package/dist/{tms-client-R5ZIAOBH.js → tms-client-NNYXLXZK.js} +1 -1
- package/dist/token-refresh-4QLWR5ZI.js +2 -0
- package/dist/validate-basic-QUPVT2EV.js +2 -0
- package/dist/{version-check-LNKXGYZE.js → version-check-RVK5YKDZ.js} +1 -1
- package/package.json +8 -6
- package/dist/ConfigView-RQM2JY4K.js +0 -2
- package/dist/FolderPicker-YN2YQJXI.js +0 -2
- package/dist/HelpView-2IYG5AC3.js +0 -2
- package/dist/ProjectPicker-RUR7HH2P.js +0 -2
- package/dist/SingleShotApp-3XDTU2BU.js +0 -2
- package/dist/TestMdRunView-PPZPUVVZ.js +0 -2
- package/dist/WhoamiView-IJZUFJ7B.js +0 -2
- package/dist/chunk-3C7ATCDM.js +0 -2
- package/dist/chunk-3Z4EHIOW.js +0 -2
- package/dist/chunk-6IQWD272.js +0 -2
- package/dist/chunk-7CLUJYMW.js +0 -2
- package/dist/chunk-7G7ZLAJH.js +0 -5
- package/dist/chunk-BKXTOQWL.js +0 -5
- package/dist/chunk-BPF7TDRU.js +0 -2
- package/dist/chunk-DTFPHZE7.js +0 -62
- package/dist/chunk-H4XV224I.js +0 -6
- package/dist/chunk-H6OVTXJQ.js +0 -2
- package/dist/chunk-J37YPPCD.js +0 -2
- package/dist/chunk-JLOY7SNA.js +0 -14
- package/dist/chunk-L3RTVAPG.js +0 -6
- package/dist/chunk-LRF6UP42.js +0 -10
- package/dist/chunk-M5RHRHFC.js +0 -9
- package/dist/chunk-PN7LNQ7G.js +0 -5
- package/dist/chunk-SJ7VGRQU.js +0 -17
- package/dist/chunk-UVBDUDSL.js +0 -2
- package/dist/generate-headless-7UYAPXE5.js +0 -18
- package/dist/login-flow-LK7GAUCZ.js +0 -2
- package/dist/resolver-OA35IO7J.js +0 -2
- package/dist/run-test-md-SXZUOYSG.js +0 -14
- package/dist/tcg-generate-CEBFKKJE.js +0 -2
- package/dist/testmd-actions-IZPOBSTC.js +0 -2
- package/dist/validate-basic-Y73NBDAD.js +0 -2
package/dist/chunk-JLOY7SNA.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as br,b as ho}from"./chunk-3MSXQU2C.js";import{a as fi}from"./chunk-H6OVTXJQ.js";import{a as ni,b as Ir,c as Vn,d as ri,e as On,f as oi,h as ii,i as si,j as ai,k as ci,l as li,m as it,n as ui,o as di,p as mi}from"./chunk-H4XV224I.js";import{a as So,b as wo,d as Bo,e as Ao,f as Po,g as Ho,h as Rr,i as Cr,k as Wo,l as zo,m as Xo,n as Ko,o as kr,p as Jo,q as Yo,r as Qo,t as ot,u as ei}from"./chunk-DTFPHZE7.js";import{a as $o,b as Fo,l as ti}from"./chunk-JCR3T34A.js";import{a as ko}from"./chunk-3C7ATCDM.js";import{a as pi,b as Er}from"./chunk-CGAX3AXA.js";import{a as No}from"./chunk-HN7DVSVI.js";import{b as Oo}from"./chunk-AH4AXJML.js";import{a as bo,b as yo,c as To,d as Do,e as Lo,f as Vo,h as Uo}from"./chunk-BKXTOQWL.js";import{a as jn,b as Go,c as wr}from"./chunk-6IQWD272.js";import{a as yr}from"./chunk-VS2BXLH4.js";import{c as qo}from"./chunk-IH45REQA.js";import{a as Mn}from"./chunk-XQXSPUIX.js";import{a as Zo}from"./chunk-6NEJEMA6.js";import{a as Io}from"./chunk-O2UU4TS5.js";import{a as xo,b as Tt,c as Dn,d as jo,e as Mo}from"./chunk-M5RHRHFC.js";import{b as Ln}from"./chunk-SJ7VGRQU.js";import{a as Ut}from"./chunk-UJZCMEEH.js";import{a as _o,d as rt,e as an,f as St,g as Gt}from"./chunk-LRF6UP42.js";import{b as Ft}from"./chunk-PWHFNSDC.js";import{b as Nt}from"./chunk-CKY3UXTY.js";import{a as Ge,b as Oe,c as Ro}from"./chunk-VE3SUJMA.js";import{a as Pn,b as Co}from"./chunk-7G7ZLAJH.js";import{a as Eo}from"./chunk-BPF7TDRU.js";import{a as Le}from"./chunk-J37YPPCD.js";import{a as vo}from"./chunk-5TOE4RHH.js";import{a as mt}from"./chunk-VTDVK3DK.js";import{b as Tr}from"./chunk-LMV2F35W.js";import{c as Sr}from"./chunk-HYVAYSRZ.js";import{a as Ot}from"./chunk-AT2Y5UNP.js";import{a as j}from"./chunk-HCBYKLMW.js";import{a as on,c as Ve,h as sn,t as r}from"./chunk-3Z4EHIOW.js";import{a as f,b as t,d as fo,i as Ce,j as po,k as go}from"./chunk-C44QQJR4.js";import{a as he}from"./chunk-6YGTRKDT.js";import{a as $t}from"./chunk-7CLUJYMW.js";import{e as k}from"./chunk-UR6MHSHU.js";var T=k(he(),1);var gi=k(he(),1);var qt=k(j(),1);function hi({path:e}){return e.length===0?null:(0,qt.jsx)(f,{children:e.map((n,o)=>(0,qt.jsxs)(gi.default.Fragment,{children:[o>0&&(0,qt.jsx)(t,{color:r.muted,children:" \u203A "}),(0,qt.jsx)(t,{color:r.dim,children:n})]},o))})}var q=k(j(),1);function xi({profile:e,environment:n,tokenValid:o,runCount:i,sessionId:p,viewMode:m,breadcrumb:x,chatMode:h,tcgRequestId:v,tcgStreamStatus:w}){let{stdout:M}=go(),R=M?.columns??80,_=h??"run",a=n==="stage",u=n==="prod",D=_==="generate"?r.generateAccent:r.orange,N=w==="completed"?r.green:w==="failed"?r.red:r.generateAccent;return(0,q.jsxs)(f,{flexDirection:"column",children:[(0,q.jsx)(t,{color:r.muted,children:"\u2500".repeat(R)}),x&&x.length>0&&(0,q.jsx)(f,{paddingX:1,children:(0,q.jsx)(hi,{path:x})}),(0,q.jsxs)(f,{paddingX:1,gap:1,children:[(0,q.jsx)(t,{color:r.dim,children:"Mode:"}),(0,q.jsx)(t,{color:D,bold:!0,children:_==="generate"?"Generate":"Run"}),(0,q.jsx)(t,{color:r.muted,children:"|"}),_==="generate"?(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(t,{color:r.dim,children:"req"}),(0,q.jsx)(t,{color:r.dim,children:v??"\u2014"}),w&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(t,{color:r.muted,children:"\xB7"}),(0,q.jsx)(t,{color:N,children:w})]})]}):(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(t,{color:r.dim,children:"Session:"}),(0,q.jsx)(t,{color:r.dim,children:p})]}),(0,q.jsx)(t,{color:r.muted,children:"|"}),(0,q.jsx)(t,{color:o?r.green:r.red,children:"\u25CF"}),(0,q.jsx)(t,{color:r.dim,children:o?"authenticated":"not logged in"}),!u&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(t,{color:r.muted,children:"|"}),a?(0,q.jsx)(t,{color:r.orange,bold:!0,children:"\u26A0 stage"}):(0,q.jsx)(t,{color:r.green,children:n})]})]}),(0,q.jsxs)(f,{paddingX:1,gap:1,children:[(0,q.jsx)(t,{color:r.dim,children:e??"no profile"}),_==="run"&&(0,q.jsxs)(q.Fragment,{children:[(0,q.jsx)(t,{color:r.muted,children:"|"}),(0,q.jsxs)(t,{color:r.dim,children:["runs: ",i]})]}),(0,q.jsx)(t,{color:r.muted,children:"|"}),(0,q.jsx)(t,{dimColor:!0,children:ho()})]}),(0,q.jsx)(f,{paddingX:1,children:(0,q.jsx)(t,{dimColor:!0,children:m==="chat"?"ctrl+c cancel/exit":"\u2191\u2193 navigate \u21B5 select esc back"})})]})}var Pt=k(he(),1);var cn=[[[" "],[" "],[" "],[" "],["\u2584","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],[" "],[" "],[" "],[" "],[" "],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2584","#af87d7"],[" "],[" "],[" "],[" "]],[[" "],[" "],["\u2584","#875faf"],["\u2584","#af87d7","#875faf"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2584","#af87d7","#875faf"],["\u2584","#875faf"],[" "],[" "]],[[" "],[" "],["\u2588","#875faf"],["\u2588","#af87d7"],["\u2584","#000000","#af87d7"],["\u2584","#000000","#303030"],["\u2584","#000000","#303030"],["\u2584","#000000","#303030"],["\u2584","#000000","#303030"],["\u2584","#000000","#303030"],["\u2584","#000000","#303030"],["\u2584","#000000","#303030"],["\u2584","#000000","#303030"],["\u2584","#000000","#303030"],["\u2584","#000000","#303030"],["\u2584","#000000","#303030"],["\u2584","#000000","#af87d7"],["\u2588","#af87d7"],["\u2588","#875faf"],[" "],[" "]],[[" "],["\u2588","#875faf"],["\u2588","#875faf"],["\u2588","#af87d7"],["\u2588","#000000"],["\u2584","#585858","#000000"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#af87d7"],["\u2588","#875faf"],["\u2588","#875faf"],[" "]],[[" "],["\u2588","#875faf"],["\u2588","#875faf"],["\u2588","#af87d7"],["\u2588","#000000"],["\u2588","#585858"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#af87d7"],["\u2588","#875faf"],["\u2588","#875faf"],[" "]],[[" "],[" "],["\u2588","#875faf"],["\u2588","#af87d7"],["\u2588","#000000"],["\u2584","#000000","#585858"],["\u2588","#000000"],["\u2588","#000000"],["\u2584","#af87d7","#000000"],["\u2584","#af87d7","#000000"],["\u2584","#af87d7","#000000"],["\u2584","#af87d7","#000000"],["\u2584","#af87d7","#000000"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#000000"],["\u2588","#af87d7"],["\u2588","#875faf"],[" "],[" "]],[[" "],[" "],["\u2580","#875faf"],["\u2580","#af87d7"],["\u2580","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2580","#af87d7"],["\u2580","#af87d7"],["\u2580","#875faf"],[" "],[" "]],[[" "],[" "],[" "],[" "],[" "],["\u2580","#af87d7"],["\u2580","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2588","#af87d7"],["\u2580","#af87d7"],["\u2580","#af87d7"],[" "],[" "],[" "],[" "],[" "]]];var X=k(j(),1),$n="#af87d7",_r="#875faf",vi="#5b3a7a",zs="#ff9500",Xs="#ea580c";var Br="#666666",Ks="#555555",At=[[$n,"\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588"],[$n,"\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588"],[$n,"\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588"],[$n,"\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588"],[_r,"\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588"],[_r,"\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588"],[_r,"\u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588 \u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588 \u2588\u2588\u2588"]],Ar=At.map(([,e])=>[...e]);function bi({visibleRows:e=At.length}){let n=Math.min(e,At.length);return(0,X.jsxs)(f,{flexDirection:"column",children:[At.slice(0,n).map(([o,i],p)=>{let m=Ar[p];return(0,X.jsx)(t,{children:m.map((x,h)=>{if(x==="\u2588")return(0,X.jsx)(t,{color:o,children:"\u2588"},h);let v=h>0&&m[h-1]==="\u2588",w=p>0&&h>0&&Ar[p-1][h-1]==="\u2588";return v||w?(0,X.jsx)(t,{color:vi,children:"\u2592"},h):(0,X.jsx)(t,{children:" "},h)})},p)}),n>=At.length&&(0,X.jsxs)(t,{children:[" ",Ar[At.length-1].map((o,i)=>o==="\u2588"?(0,X.jsx)(t,{color:vi,children:"\u2580"},i):(0,X.jsx)(t,{children:" "},i))]})]})}function Js({visibleRows:e=cn.length}){let n=Math.min(e,cn.length);return(0,X.jsx)(f,{flexDirection:"column",children:cn.slice(0,n).map((o,i)=>(0,X.jsx)(t,{children:o.map((p,m)=>{let x=p[0],h=p[1],v=p[2];return h?(0,X.jsx)(t,{color:h,backgroundColor:v,children:x},m):(0,X.jsx)(t,{children:x},m)})},i))})}function Fn({size:e="compact",helmetVisibleRows:n=cn.length,textVisibleRows:o=At.length,showMeta:i=!1,user:p=null,authenticated:m=!1,version:x=""}){return e==="compact"?(0,X.jsx)(bi,{}):(0,X.jsxs)(f,{flexDirection:"column",paddingX:1,paddingY:1,children:[(0,X.jsx)(t,{color:zs,italic:!0,children:" Welcome to"}),(0,X.jsx)(t,{children:" "}),(0,X.jsxs)(f,{gap:2,children:[(0,X.jsx)(Js,{visibleRows:n}),(0,X.jsxs)(f,{flexDirection:"column",children:[(0,X.jsx)(bi,{visibleRows:o}),(0,X.jsx)(f,{justifyContent:"flex-end",width:73,children:(0,X.jsx)(t,{color:Xs,italic:!0,children:"Command-line interface"})})]})]}),i&&(0,X.jsxs)(X.Fragment,{children:[(0,X.jsx)(t,{children:" "}),(0,X.jsxs)(t,{children:[(0,X.jsx)(t,{color:Br,children:" Browser automation powered by AI. "}),(0,X.jsx)(t,{color:Ks,children:`v${x}`})]}),(0,X.jsx)(t,{children:" "}),(0,X.jsx)(t,{children:(0,X.jsx)(t,{color:Br,children:" KaneCLI can navigate websites, fill forms, test web UI, and extract"})}),(0,X.jsx)(t,{children:(0,X.jsx)(t,{color:Br,children:" data \u2014 right from your terminal."})}),(0,X.jsx)(t,{children:" "})]})]})}var Lr=k(j(),1),Pr=8,Dr=7;function yi({onComplete:e}){let[n,o]=(0,Pt.useState)(0),[i,p]=(0,Pt.useState)(0),[m,x]=(0,Pt.useState)(!1),[h]=(0,Pt.useState)(()=>{let v=new Pn,w=v.getActiveProfile(),M=v.getDefaultEnv(),R=w?v.loadCredentials(w,M):null,_=w?v.loadBasicAuth(w,M):null;return{authenticated:!!(R||_),user:_?.username??w??null}});return yr(()=>{o(v=>Math.min(Pr,v+1))},n<Pr?60:null),yr(()=>{p(v=>Math.min(Dr,v+1))},i<Dr?80:null),(0,Pt.useEffect)(()=>{n>=Pr&&i>=Dr&&!m&&(x(!0),e?.())},[n,i,m,e]),(0,Lr.jsx)(f,{flexDirection:"column",children:(0,Lr.jsx)(Fn,{size:"full",helmetVisibleRows:n,textVisibleRows:i,showMeta:m,user:h.user,authenticated:h.authenticated,version:on})})}var ft=k(j(),1);function Ti({entry:e}){return e.type==="input"?(0,ft.jsxs)(f,{children:[(0,ft.jsx)(t,{color:r.orange,children:"\u276F "}),(0,ft.jsx)(t,{children:e.text})]}):e.type==="error"?(0,ft.jsx)(f,{marginLeft:2,children:(0,ft.jsx)(t,{color:r.red,children:e.text})}):(0,ft.jsx)(f,{marginLeft:2,children:(0,ft.jsx)(t,{color:e.type==="info"?r.dim:void 0,children:e.text})})}var st=k(he(),1);var _e=k(j(),1);function Ys(e,n){let o=[],p=Math.max(n-4,30);o.push({type:"title",text:e.title});for(let m=0;m<e.sections.length;m++){let x=e.sections[m];m>0&&o.push({type:"divider",text:"\u2500".repeat(p)}),x.label&&o.push({type:"header",text:x.label});let h=x.entries.length>0?Math.max(...x.entries.map(v=>v.key.length)):0;for(let v of x.entries){let w="\xB7".repeat(Math.max(2,h-v.key.length+3)),M=`${v.key} ${w} ${v.value}`;o.push({type:"entry",text:M,color:v.color})}}return o.push({type:"footer",text:"esc back"}),o}function Si({data:e,width:n=60}){let o=Ys(e,n);return(0,_e.jsx)(f,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:o.map((i,p)=>{if(i.type==="title")return(0,_e.jsx)(t,{color:r.orange,bold:!0,children:i.text},p);if(i.type==="header")return(0,_e.jsx)(f,{marginTop:1,children:(0,_e.jsx)(t,{color:r.dim,children:i.text})},p);if(i.type==="divider")return(0,_e.jsx)(f,{marginTop:1,marginBottom:0,children:(0,_e.jsx)(t,{color:r.muted,children:i.text})},p);if(i.type==="footer")return(0,_e.jsx)(f,{marginTop:1,children:(0,_e.jsx)(t,{color:r.dim,children:i.text})},p);let m=i.text.match(/^(.+?) (·+) (.+)$/);return m?(0,_e.jsxs)(t,{children:[(0,_e.jsxs)(t,{color:r.secondary,children:[m[1]," "]}),(0,_e.jsxs)(t,{color:r.muted,children:[m[2]," "]}),(0,_e.jsx)(t,{color:i.color,children:m[3]})]},p):(0,_e.jsx)(t,{color:i.color,children:i.text},p)})})}var ye=k(j(),1);function jr(e,n){let o=[];function i(p,m){for(let x of p)o.push({item:x,depth:m}),x.type==="submenu"&&x.children&&n.length>m&&n[m]===x.id&&i(x.children,m+1)}return i(e,0),o}function Mr({items:e,onRunSelected:n,initialExpandedPath:o,onDismiss:i,renderLoginWizard:p,renderProfilesView:m,renderChromeProfilePicker:x,renderProjectPicker:h,renderFolderPicker:v,renderWindowSizePicker:w,onActiveViewChange:M}){let[R,_]=(0,st.useState)(()=>{let $=o??[],U=jr(e,$),E=0;if($.length>0){let V=U.findIndex(J=>J.item.id===$[0]);V>=0&&V+1<U.length&&(E=V+1)}return{expandedPath:$,selectedIndex:E,inputValue:"",isEditing:!1,isSelecting:!1,feedback:null,activeView:null,infoData:null}}),a=jr(e,R.expandedPath),u=a[R.selectedIndex]?.item,D=(0,st.useRef)(null),N=(0,st.useCallback)($=>{_(U=>({...U,feedback:$})),D.current&&clearTimeout(D.current),D.current=setTimeout(()=>{_(U=>({...U,feedback:null})),D.current=null},4e3)},[]);(0,st.useEffect)(()=>()=>{D.current&&clearTimeout(D.current)},[]),(0,st.useEffect)(()=>{M?.(R.activeView)},[R.activeView,M]);let O=(0,st.useCallback)(()=>{_($=>({...$,activeView:null,infoData:null}))},[]);return Ce(($,U)=>{if(R.activeView==="infoView"){U.escape&&O();return}if(!(R.activeView==="loginWizard"||R.activeView==="profilesView"||R.activeView==="chromeProfilePicker"||R.activeView==="projectPicker"||R.activeView==="folderPicker"||R.activeView==="windowSizePicker")){if(R.isEditing){if(U.escape){_(E=>({...E,isEditing:!1,inputValue:""}));return}if(U.return){let E=R.inputValue.trim();if(u?.onValue&&E){let V=u.currentValue;u.onValue(E),N(V?`${u.label}: ${V} \u2192 ${E}`:`${u.label}: ${E}`)}_(V=>({...V,isEditing:!1,inputValue:""}));return}if(U.backspace||U.delete){_(E=>({...E,inputValue:E.inputValue.slice(0,-1)}));return}$&&!U.ctrl&&!U.meta&&_(E=>({...E,inputValue:E.inputValue+$}));return}if(R.isSelecting&&u?.options){let E=u.options;if(U.escape){_(V=>({...V,isSelecting:!1}));return}if(U.upArrow){_(V=>({...V,inputValue:String(Math.max(0,Number(V.inputValue||"0")-1))}));return}if(U.downArrow){_(V=>({...V,inputValue:String(Math.min(E.length-1,Number(V.inputValue||"0")+1))}));return}if(U.return){let V=Number(R.inputValue||"0"),J=E[V];if(J&&u.onValue){let K=u.currentValue;u.onValue(J.value),N(K?`${u.label}: ${K} \u2192 ${J.label}`:`${u.label}: ${J.label}`)}_(K=>({...K,isSelecting:!1,inputValue:""}));return}return}if(U.upArrow){_(E=>({...E,selectedIndex:Math.max(0,E.selectedIndex-1)}));return}if(U.downArrow){_(E=>({...E,selectedIndex:Math.min(a.length-1,E.selectedIndex+1)}));return}if(U.escape){if(R.expandedPath.length===0){i?.();return}_(E=>{let V=E.expandedPath.slice(0,-1),J=jr(e,V),K=E.expandedPath[E.expandedPath.length-1],Re=J.findIndex(H=>H.item.id===K);return{...E,expandedPath:V,selectedIndex:Re>=0?Re:0}});return}if(U.return&&u){if(u.id==="run-start"){n();return}if(u.type==="submenu"){let E=a[R.selectedIndex]?.depth??0;_(V=>({...V,expandedPath:[...V.expandedPath.slice(0,E),u.id],selectedIndex:V.selectedIndex+1}));return}if(u.onInfo){let E=u.onInfo();_(V=>({...V,activeView:"infoView",infoData:E}));return}if(u.onLoginWizard){u.onLoginWizard(),_(E=>({...E,activeView:"loginWizard"}));return}if(u.onProfilesView){u.onProfilesView(),_(E=>({...E,activeView:"profilesView"}));return}if(u.onChromeProfilePicker){u.onChromeProfilePicker(),_(E=>({...E,activeView:"chromeProfilePicker"}));return}if(u.onProjectPicker){u.onProjectPicker(),_(E=>({...E,activeView:"projectPicker"}));return}if(u.onFolderPicker){u.onFolderPicker(),_(E=>({...E,activeView:"folderPicker"}));return}if(u.onWindowSizePicker){u.onWindowSizePicker(),_(E=>({...E,activeView:"windowSizePicker"}));return}if(u.type==="action"){u.onAction?.(),u.suppressFeedback||N(`${u.label} done`);return}if(u.type==="select"&&u.options){let E=u.options.findIndex(V=>V.value===u.currentValue);_(V=>({...V,isSelecting:!0,inputValue:String(Math.max(0,E))}));return}if(u.type==="text-input"){_(E=>({...E,isEditing:!0,inputValue:u.currentValue??""}));return}}}}),(0,ye.jsx)(f,{flexDirection:"column",paddingX:1,children:R.activeView==="infoView"&&R.infoData?(0,ye.jsx)(Si,{data:R.infoData}):R.activeView==="loginWizard"&&p?p(O):R.activeView==="profilesView"&&m?m(O):R.activeView==="chromeProfilePicker"&&x?x(O):R.activeView==="projectPicker"&&h?h(O):R.activeView==="folderPicker"&&v?v(O):R.activeView==="windowSizePicker"&&w?w(O):(0,ye.jsxs)(ye.Fragment,{children:[a.map(({item:$,depth:U},E)=>{let V=E===R.selectedIndex,J=" ".repeat(U),K=V?"\u276F ":" ",Re=$.type==="submenu"?R.expandedPath.includes($.id)?"\u25BC ":"\u25B6 ":" ",H=$.currentValue!=null?` [${$.currentValue}]`:"";if(V&&R.isSelecting&&$.options){let de=Number(R.inputValue||"0");return(0,ye.jsxs)(f,{flexDirection:"column",children:[(0,ye.jsxs)(t,{color:r.orange,children:[J,K,Re,$.label]}),$.options.map((se,Ye)=>(0,ye.jsxs)(t,{color:Ye===de?r.orange:void 0,children:[J," ",Ye===de?"\u276F ":" ",se.label]},se.value))]},$.id)}return V&&R.isEditing?(0,ye.jsxs)(t,{color:r.orange,children:[J,K,Re,$.label,": ",R.inputValue,(0,ye.jsx)(t,{color:r.dim,children:"\u2588"})]},$.id):(0,ye.jsxs)(t,{color:V?r.orange:void 0,dimColor:!V&&U>0,children:[J,K,Re,$.label,(0,ye.jsx)(t,{dimColor:!0,children:H})]},$.id)}),R.feedback&&(0,ye.jsx)(f,{marginTop:1,children:(0,ye.jsxs)(t,{color:r.green,children:["\u2713 ",R.feedback]})}),(0,ye.jsx)(Ot,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})})}var ln=k(he(),1);var ke=k(j(),1),Vr=800,Or=3840,$r=600,Fr=2160;function wi(e,n){if(!n)return"Enter a value";let o=Number(n);if(!Number.isInteger(o))return"Must be a whole number";if(e==="width"){if(o<Vr)return`Min ${Vr}`;if(o>Or)return`Max ${Or}`}else{if(o<$r)return`Min ${$r}`;if(o>Fr)return`Max ${Fr}`}return null}function Nr({currentWidth:e,currentHeight:n,onSelect:o,onCancel:i}){let[p,m]=(0,ln.useState)("width"),[x,h]=(0,ln.useState)(String(e)),[v,w]=(0,ln.useState)(String(n)),[M,R]=(0,ln.useState)(null);Ce((a,u)=>{if(u.escape){i();return}if(u.tab||u.rightArrow||u.leftArrow){m(D=>D==="width"?"height":"width"),R(null);return}if(u.return){let D=wi("width",x);if(D){m("width"),R(`Width: ${D}`);return}let N=wi("height",v);if(N){m("height"),R(`Height: ${N}`);return}o(Number(x),Number(v));return}if(u.backspace||u.delete){p==="width"?h(D=>D.slice(0,-1)):w(D=>D.slice(0,-1)),R(null);return}a&&/^\d$/.test(a)&&(p==="width"?h(D=>D+a):w(D=>D+a),R(null))});let _=(a,u,D)=>{let N=p===D,O=N?r.orange:r.secondary;return(0,ke.jsxs)(f,{flexDirection:"column",children:[(0,ke.jsxs)(t,{color:r.dim,children:[" ",a]}),(0,ke.jsx)(f,{borderStyle:"round",borderColor:O,paddingX:1,width:10,children:(0,ke.jsxs)(t,{color:N?void 0:r.dim,children:[u||" ",N?(0,ke.jsx)(t,{color:r.dim,children:"\u2588"}):""]})}),(0,ke.jsxs)(t,{color:r.dim,dimColor:!0,children:[" ",D==="width"?`${Vr}\u2013${Or}`:`${$r}\u2013${Fr}`]})]})};return(0,ke.jsxs)(f,{flexDirection:"column",paddingX:1,children:[(0,ke.jsx)(t,{color:r.orange,bold:!0,children:"Window Size"}),(0,ke.jsxs)(f,{marginTop:1,gap:1,children:[_("Width",x,"width"),(0,ke.jsx)(f,{alignItems:"center",marginTop:1,children:(0,ke.jsx)(t,{color:r.dim,children:"x"})}),_("Height",v,"height")]}),M&&(0,ke.jsx)(f,{marginTop:1,children:(0,ke.jsx)(t,{color:r.red,children:M})}),(0,ke.jsx)(Ot,{bindings:[{keys:"tab/\u2190\u2192",label:"switch field"},{keys:"\u21B5",label:"save"}],escBackLabel:"cancel"})]})}var Ie=k(he(),1);async function Ri(e,n,o){let i=e.loadCredentials(n,o),p=e.loadClient(n,o);if(i&&p){let x=new Co(o);await Promise.allSettled([x.revokeToken(i.access_token,p.client_id,"access_token"),x.revokeToken(i.refresh_token,p.client_id,"refresh_token")])}e.deleteProfileFull(n,o);let m=e.listProfiles();return m.length>0&&(e.setActiveProfile(m[0].profile),e.setDefaultEnv(m[0].env)),{profile:n,env:o,switchedTo:m.length>0?m[0]:void 0}}function Ci(){let[e]=(0,Ie.useState)(()=>new Pn),[n,o]=(0,Ie.useState)(()=>{let u=e.resolveAuth();if(!u)return!1;if(u.method==="basic")return!0;let{credentials:D}=e.getActiveCredentials();return D?D.expires_at>Date.now()/1e3:!1}),i=(0,Ie.useRef)(null),p=(0,Ie.useRef)(null),m=(0,Ie.useCallback)(()=>{let u=e.resolveAuth();return u?{method:u.method,profile:u.profile,env:u.env}:null},[e]),x=(0,Ie.useCallback)(async()=>{let{credentials:u,profile:D,env:N}=e.getActiveCredentials();if(!u||!D||!N)return null;let O=u.expires_at,$=Date.now()/1e3;if(O-$<300){if(p.current)return p.current;let U=(async()=>{try{let E=await ko({creds:e,profile:D,env:N,credentials:u});return E?(o(!0),E.accessToken):null}catch{return o(!1),null}finally{p.current=null}})();return p.current=U,U}return o(!0),u.access_token},[e]),h=(0,Ie.useCallback)(()=>{let u=e.resolveAuth();return!u||u.method!=="basic"?null:{username:u.username,access_key:u.access_key}},[e]),v=(0,Ie.useCallback)((u,D)=>{i.current?.revoke();let N=Le(u),O=h(),$=new Eo(N.controllerBaseUrl,x,O,D);return i.current=$,$},[h,x]),w=(0,Ie.useCallback)(()=>i.current,[]),M=(0,Ie.useCallback)(()=>{let u=h();if(u)return u;let D=i.current?.cached;return D?{username:D.username,access_key:D.access_key}:null},[h]),R=(0,Ie.useCallback)(async()=>{let u=i.current;return u?u.resolve():null},[]),_=(0,Ie.useCallback)(async(u="default")=>{let D=e.getDefaultEnv();await new Io(u,D,e).login(),e.setActiveProfile(u);try{let O=new Ut;Ge(e,O,u,D)}catch{}o(!0)},[e]),a=(0,Ie.useCallback)(async()=>{let u=e.getActiveProfile();if(!u)return null;let D=e.getDefaultEnv(),N=await Ri(e,u,D);return o(!1),{profile:N.profile,env:N.env}},[e]);return{creds:e,tokenValid:n,setTokenValid:o,getToken:x,getBasicAuth:h,getAuthInfo:m,login:_,logout:a,initResolver:v,getResolver:w,getResolvedBasicAuth:M,resolveBasicAuth:R}}var pt=k(he(),1);import{mkdtempSync as Qs,rmSync as Zs}from"fs";import{join as ea}from"path";import{tmpdir as ta}from"os";function ki(){let[e]=(0,pt.useState)(()=>new Ut),n=(0,pt.useRef)(null),o=(0,pt.useRef)(null),i=(0,pt.useRef)(null),p=(0,pt.useCallback)(async x=>{if(n.current)return n.current;if(i.current)return i.current;let h=(async()=>{let v=e.load(),w;if(v.chrome_profile_path)w=v.chrome_profile_path.replace("~",process.env.HOME??"~");else{o.current&&(St("tempDir","Previous temp dir removed before retry"),o.current=null);let R=Qs(ea(ta(),"kane-clean-"));o.current=R,w=R,rt("tempDir",()=>{try{Zs(R,{recursive:!0,force:!0})}catch{}})}let M=await Ao({userDataDir:w,width:v.window_size.width,height:v.window_size.height,startUrl:x??v.default_url??void 0});return n.current=M,rt("chrome",()=>{M.kill()}),M})();i.current=h;try{return await h}finally{i.current=null}},[e]),m=(0,pt.useCallback)(()=>{St("chrome","Chrome killed"),St("tempDir","Temp dir removed"),n.current=null,o.current=null},[]);return{ensureChrome:p,killChrome:m}}var Nn=[{name:"run",description:"Execute a test run",args:'"objective"'},{name:"login",description:"OAuth login",args:"[--profile name]"},{name:"logout",description:"Logout & revoke tokens",args:"[--profile name]"},{name:"whoami",description:"Show profile info",args:"[--profile name]"},{name:"balance",description:"Show credit balance"},{name:"profiles",description:"Manage profiles",args:"list|switch|delete"},{name:"config",description:"Manage configuration",args:"show|set-window|set-mode|chrome-profile|project|folder"},{name:"new",description:"Start a fresh session (uploads current first)"},{name:"name",description:"Set the current session's name (used at /exit save)",args:"<new-name>"},{name:"summary",description:"View detailed run summaries",args:"[index]"},{name:"cancel",description:"Abort current run"},{name:"help",description:"Show command reference"},{name:"clear",description:"Clear chat history"},{name:"exit",description:"Quit kane-cli"}];function Un(e){let n=e.trim();if(!n.startsWith("/"))return null;let i=n.slice(1).match(/(?:[^\s"]+|"[^"]*")+/g)??[];if(i.length===0)return null;let p=i[0],m={},x=1;for(;x<i.length;){let h=i[x];if(h.startsWith("--")){let v=h.slice(2),w=i[x+1];w&&!w.startsWith("--")?(m[v]=w.replace(/^"|"$/g,""),x+=2):(m[v]=void 0,x++)}else{let v=h.replace(/^"|"$/g,"");p==="run"?m.objective=v:p==="config"?m.action?m.value=v:m.action=v:p==="profiles"?m.action=v:p==="summary"&&(m.index=v),x++}}return{command:p,args:m,raw:n}}var $c=[{name:"Testing",commands:Nn.filter(e=>["run","cancel"].includes(e.name))},{name:"Auth",commands:Nn.filter(e=>["login","logout","whoami","balance","profiles"].includes(e.name))},{name:"Settings",commands:Nn.filter(e=>["config"].includes(e.name))},{name:"Session",commands:Nn.filter(e=>["new","name","summary","help","clear","exit"].includes(e.name))}];var Ii=[{name:"testmd",description:"Browse & run saved tests under cwd"},{name:"auth",description:"Login, logout, profiles"},{name:"config",description:"View/change settings"},{name:"help",description:"Command reference"},{name:"new",description:"Start a fresh session"},{name:"name",description:"Set the session name",args:"<new-name>"},{name:"exit",description:"Quit kane-cli"}],na={name:"cancel",description:"Abort current run"},ra={name:"cancel",description:"Cancel current generation"},Ht=[{name:"generate",description:"Switch to Generate mode (test case generator)"},{name:"summary",description:"View run summaries",args:"[index]"},na,...Ii],un=[{name:"run",description:"Switch back to Run mode"},{name:"save",description:"Save the current test cases"},{name:"view",description:"Open the scenario browser",args:"[S<n>]"},ra,...Ii],Ei=Ht;function Gn(e,n="run"){let o=n==="generate"?un:Ht,i=e.startsWith("/")?e.slice(1):e;return i?o.filter(p=>p.name.startsWith(i)):o}var oa=new Set([...Ht,...un].map(e=>e.name));function _i(e,n){let o=n==="generate"?un:Ht;return oa.has(e)?o.some(i=>i.name===e):!0}function Bi(e,n){let o=n?.trim();return o?e==="generate"?{kind:"reject"}:{kind:"run",objective:o}:e==="generate"?{kind:"toggle"}:{kind:"already"}}var wt=k(j(),1);function Ur({flows:e,filterIndex:n}){let o=n!==void 0?e.filter(i=>i.index===n):e;return o.length===0?null:(0,wt.jsx)(f,{flexDirection:"column",children:o.map(i=>(0,wt.jsxs)(f,{flexDirection:"column",marginTop:1,children:[(0,wt.jsxs)(f,{marginLeft:1,children:[(0,wt.jsx)(t,{color:r.purple,bold:!0,children:"Flow "+i.index+": "}),(0,wt.jsx)(t,{color:r.purple,children:i.objective})]}),(0,wt.jsx)(Vo,{status:i.status==="error"?"failed":i.status,summary:i.summary,duration:i.duration,steps:i.steps,stepsPassed:i.stepsPassed,stepsFailed:i.stepsFailed,reason:i.reason,creditsConsumed:i.creditsConsumed})]},i.index))})}var Rt=k(j(),1),ia={ok:"\u2713",error:"\u2717",cancelled:"\u2298"},sa={ok:r.green,error:r.red,cancelled:r.dim};function Ai({status:e,command:n,message:o,details:i,accentColor:p}){let m=n.startsWith("/")?n.slice(1):n,x=p??sa[e];return(0,Rt.jsxs)(f,{flexDirection:"column",marginLeft:2,marginTop:1,children:[(0,Rt.jsx)(f,{marginLeft:1,children:(0,Rt.jsxs)(t,{color:x,bold:!0,children:[ia[e]," ",m]})}),(0,Rt.jsxs)(f,{borderStyle:"round",borderColor:x,paddingX:2,flexDirection:"column",width:70,children:[(0,Rt.jsx)(t,{children:o}),i&&(0,Rt.jsx)(t,{color:r.dim,children:i})]})]})}var pn=k(he(),1);import{join as mn}from"path";var dn=k(j(),1);function Pi({tabs:e,activeIndex:n}){return(0,dn.jsx)(f,{children:e.map((o,i)=>(0,dn.jsx)(f,{marginRight:1,children:i===n?(0,dn.jsx)(t,{color:r.orange,bold:!0,children:`[ ${o} ]`}):(0,dn.jsx)(t,{color:r.dim,children:` ${o} `})},o))})}var S=k(j(),1),fn=["Commands","Shortcuts","Tests","Setup","About"],qn=18,aa="https://www.testmuai.com/support/docs/kane-cli-introduction",ca="https://github.com/LambdaTest/kane-cli/issues";function Di({onClose:e,version:n,environment:o,sessionId:i,runUrl:p,mode:m="run"}){let[x,h]=(0,pn.useState)(0),[v,w]=(0,pn.useState)(0);(0,pn.useEffect)(()=>{w(0)},[x]);let M=fn[x],R=M==="Commands"?la(m):M==="Shortcuts"?ua():M==="Tests"?da():M==="Setup"?ma():fa({version:n,environment:o,sessionId:i,runUrl:p}),_=R.length,a=v>0,u=v+qn<_,D=R.slice(v,v+qn);Ce((O,$)=>{if($.escape){e();return}if($.rightArrow||$.tab){h(U=>(U+1)%fn.length);return}if($.leftArrow){h(U=>(U-1+fn.length)%fn.length);return}if($.upArrow){w(U=>Math.max(0,U-1));return}if($.downArrow){w(U=>Math.min(Math.max(0,_-qn),U+1));return}});let N=[{keys:"\u2190\u2192/tab",label:"switch tabs"}];return _>qn&&N.push({keys:"\u2191\u2193",label:"scroll"}),(0,S.jsxs)(f,{flexDirection:"column",borderStyle:"round",borderColor:r.orange,paddingX:2,paddingY:1,children:[(0,S.jsx)(Pi,{tabs:[...fn],activeIndex:x,onChange:h}),a&&(0,S.jsx)(f,{marginTop:1,children:(0,S.jsx)(t,{color:r.dim,children:"\u25B2 more above"})}),(0,S.jsx)(f,{marginTop:a?0:1,flexDirection:"column",children:D}),u&&(0,S.jsx)(f,{children:(0,S.jsx)(t,{color:r.dim,children:"\u25BC more below"})}),(0,S.jsx)(Ot,{bindings:N,escBackLabel:"back to chat"})]})}function la(e){let n=e==="generate"?un:Ht;return[(0,S.jsx)(t,{color:r.dim,children:"Type a natural-language objective and press \u21B5 to run, e.g."},"intro"),(0,S.jsx)(f,{marginLeft:2,children:(0,S.jsx)(t,{color:r.orange,children:'"search amazon for laptop"'})},"ex"),(0,S.jsx)(f,{marginBottom:1},"sp"),(0,S.jsx)(t,{color:r.dim,bold:!0,children:"Slash commands"},"cmd-h"),...n.map(o=>(0,S.jsxs)(f,{marginLeft:2,children:[(0,S.jsx)(f,{width:14,children:(0,S.jsxs)(t,{color:r.orange,children:["/",o.name]})}),o.args&&(0,S.jsx)(f,{width:14,children:(0,S.jsx)(t,{color:r.dim,children:o.args})}),(0,S.jsx)(t,{color:r.dim,children:o.description})]},o.name)),(0,S.jsx)(f,{marginBottom:1},"sp2"),(0,S.jsx)(f,{marginLeft:2,children:(0,S.jsx)(t,{color:r.dim,children:"/auth submenu: login \xB7 logout \xB7 whoami \xB7 profiles \xB7 balance"})},"auth-sub"),(0,S.jsx)(f,{marginLeft:2,children:(0,S.jsx)(t,{color:r.dim,children:"/config submenu: show \xB7 set-mode \xB7 set-window \xB7 chrome-profile \xB7 project \xB7 folder"})},"config-sub")]}function Hn(e,n){return[(0,S.jsx)(t,{color:r.dim,bold:!0,children:e},`h-${e}`),...n.map(([o,i],p)=>(0,S.jsxs)(f,{marginLeft:2,children:[(0,S.jsx)(f,{width:26,children:(0,S.jsx)(t,{color:r.orange,children:o})}),(0,S.jsx)(t,{color:r.dim,children:i})]},`r-${e}-${p}`)),(0,S.jsx)(f,{marginBottom:1},`s-${e}`)]}function ua(){return[...Hn("Cursor & word edit",[["\u2190 \u2192","Cursor by char"],["Ctrl+A Ctrl+E","Start / end of line"],["Home End","Start / end (Linux/Win; rare on Mac laptops)"],["Backspace","Delete char before cursor"],["Ctrl+W","Delete word back"],["Ctrl+U","Clear input"],["Ctrl+K","Kill from cursor to end"],["Ctrl+\u2190 Ctrl+\u2192","Word jump (Linux/Win, iTerm2)"],["Option+\u2190 Option+\u2192","Word jump (Mac native)"],["Option+B Option+F","Word jump (Mac, Emacs-style)"],["Alt+Backspace","Delete word back (Option+Delete on Mac)"],["Ctrl+Delete Option+Fn+Del","Delete word forward"]]),...Hn("History & completion",[["\u2191 \u2193","Previous / next history"],["Tab","Accept ghost / fill highlighted command"],["Ctrl+R","Reverse-search history"],["\u21B5","Submit"],["Esc","Close overlay / clear / back"]]),...Hn("Lists & menus",[["\u2191 \u2193","Navigate"],["type any char","Filter"],["\u21B5","Select"],["Tab","Create-new (in pickers)"],["Esc","Clear filter, then back"]]),...Hn("Global",[["Ctrl+C","Cancel run \xB7 twice exits"]]),(0,S.jsx)(t,{color:r.dim,bold:!0,children:"Platform caveats"},"cv-h"),(0,S.jsx)(t,{color:r.dim,children:'\u2022 Mac Terminal.app: enable "Use Option as Meta key" (Profile \u2192 Keyboard)'},"cv-1"),(0,S.jsx)(t,{color:r.dim,children:"\u2022 Mac iTerm2: works by default (Esc+ mode)"},"cv-2"),(0,S.jsx)(t,{color:r.dim,children:"\u2022 Mac Mission Control may intercept Ctrl+arrow \u2014 use Option+arrow instead"},"cv-3"),(0,S.jsx)(t,{color:r.dim,children:"\u2022 Bare Forward Delete acts as Backspace (Ink can't disambiguate)"},"cv-4"),(0,S.jsx)(t,{color:r.dim,children:"\u2022 Shift+arrow is parsed but unbound (selection model is future)"},"cv-5"),(0,S.jsx)(t,{color:r.dim,children:"\u2022 Thousands of terminals exist \u2014 if a shortcut fails, run `cat` to see bytes"},"cv-6")]}function da(){return[(0,S.jsxs)(t,{color:r.dim,children:["Sessions you run here are saved as ",(0,S.jsx)(t,{color:r.orange,children:"*_test.md"})," files you can replay later."]},"t-intro"),(0,S.jsx)(f,{marginBottom:1},"t-sp1"),(0,S.jsx)(t,{color:r.dim,bold:!0,children:"Auto-save"},"t-save-h"),(0,S.jsxs)(t,{color:r.dim,children:[" In ",(0,S.jsx)(t,{color:r.orange,children:"testing"})," mode, /exit prompts to save the session under a name (default: timestamp)."]},"t-save-1"),(0,S.jsxs)(t,{color:r.dim,children:[" In ",(0,S.jsx)(t,{color:r.orange,children:"action"})," mode, sessions are ephemeral unless launched with --name or set via /name."]},"t-save-2"),(0,S.jsxs)(t,{color:r.dim,children:[" Output: ",(0,S.jsx)(t,{color:r.orange,children:"<cwd>/.testmuai/tests/<name>_test.md"})," + sibling ",(0,S.jsx)(t,{color:r.orange,children:"output-<name>/"})," (Result.md + .internal/meta.json)."]},"t-save-3"),(0,S.jsx)(f,{marginBottom:1},"t-sp2"),(0,S.jsx)(t,{color:r.dim,bold:!0,children:"Replay from a shell"},"t-run-h"),(0,S.jsxs)(t,{color:r.dim,children:[" ",(0,S.jsx)(t,{color:r.orange,children:"kane-cli testmd run path/to/foo_test.md"})," \xB7 ",(0,S.jsx)(t,{color:r.orange,children:"kane-cli testmd list"})," \xB7 bare ",(0,S.jsx)(t,{color:r.orange,children:"kane-cli testmd"})," opens a TTY picker."]},"t-run-1"),(0,S.jsx)(t,{color:r.dim,children:" The .md file carries its own config (mode, max_steps, variables, \u2026) so the replay is reproducible."},"t-run-2"),(0,S.jsx)(f,{marginBottom:1},"t-sp3"),(0,S.jsx)(t,{color:r.dim,bold:!0,children:"Naming a session mid-run"},"t-name-h"),(0,S.jsxs)(t,{color:r.dim,children:[" Type ",(0,S.jsxs)(t,{color:r.orange,children:["/name ","<new-name>"]})," any time before /exit. Name allowed chars: letters, digits, _, -."]},"t-name-1"),(0,S.jsxs)(t,{color:r.dim,children:[" Discarding at the save prompt: press ",(0,S.jsx)(t,{color:r.orange,children:"N"})," (only key that discards \u2014 every other key saves with default)."]},"t-name-2")]}function ma(){return[(0,S.jsx)(t,{color:r.dim,bold:!0,children:"1. Login"},"s1-h"),(0,S.jsx)(t,{color:r.dim,children:" /auth \u2192 login. OAuth opens browser; basic uses LambdaTest username + access key."},"s1-b"),(0,S.jsx)(t,{color:r.dim,bold:!0,children:"2. Project & folder"},"s2-h"),(0,S.jsx)(t,{color:r.dim,children:" /config project / /config folder. Esc auto-picks KaneAI Generated / Untitled."},"s2-b"),(0,S.jsx)(t,{color:r.dim,bold:!0,children:"3. Mode"},"s3-h"),(0,S.jsx)(t,{color:r.dim,children:" testing (saves to TMS) | action (local report). /config set-mode"},"s3-b"),(0,S.jsx)(f,{marginBottom:1},"spacer-1"),(0,S.jsx)(t,{color:r.dim,bold:!0,children:"Variables (later wins)"},"v-h"),(0,S.jsxs)(t,{color:r.dim,children:[" ",`${mn(Ve,"variables")}/*.json`," (global)"]},"v-1"),(0,S.jsxs)(t,{color:r.dim,children:[" ","{cwd}/.testmuai/variables/*.json"," (local) \xB7 --variables-file \xB7 --variables ","'{...}'"]},"v-2"),(0,S.jsx)(t,{color:r.dim,children:' Format: { "key": { "value": "...", "secret": false } } \xB7 ref via {{key}}'},"v-3"),(0,S.jsx)(f,{marginBottom:1},"spacer-2"),(0,S.jsx)(t,{color:r.dim,bold:!0,children:"Context files"},"c-h"),(0,S.jsxs)(t,{color:r.dim,children:[" Global: ",mn(Ve,"global-memory.md")]},"c-1"),(0,S.jsxs)(t,{color:r.dim,children:[" Local: ","{cwd}/.testmuai/context.md"," \xB7 CLI: --global-context, --local-context"]},"c-2"),(0,S.jsx)(f,{marginBottom:1},"spacer-3"),(0,S.jsx)(t,{color:r.dim,bold:!0,children:"Paths"},"p-h"),(0,S.jsxs)(t,{color:r.dim,children:[" Config: ",mn(Ve,"tui-config.json")," \xB7 Auth: ",mn(Ve,"config.json")]},"p-1"),(0,S.jsxs)(t,{color:r.dim,children:[" Sessions: ",mn(Ve,"sessions"),"/"]},"p-2")]}function fa({version:e,environment:n,sessionId:o,runUrl:i}){return[(0,S.jsxs)(f,{children:[(0,S.jsx)(t,{color:r.orange,bold:!0,children:"kane-cli "}),(0,S.jsxs)(t,{color:r.muted,children:["v",e]})]},"title"),(0,S.jsx)(f,{marginBottom:1},"sp"),(0,S.jsxs)(f,{children:[(0,S.jsx)(f,{width:14,children:(0,S.jsx)(t,{color:r.dim,children:"Environment"})}),(0,S.jsx)(t,{children:n})]},"env"),(0,S.jsxs)(f,{children:[(0,S.jsx)(f,{width:14,children:(0,S.jsx)(t,{color:r.dim,children:"Session"})}),(0,S.jsx)(t,{children:o})]},"sess"),(0,S.jsxs)(f,{children:[(0,S.jsx)(f,{width:14,children:(0,S.jsx)(t,{color:r.dim,children:"Default URL"})}),(0,S.jsx)(t,{color:r.orange,children:i})]},"url"),(0,S.jsx)(f,{marginBottom:1},"sp2"),(0,S.jsxs)(f,{children:[(0,S.jsx)(f,{width:14,children:(0,S.jsx)(t,{color:r.dim,children:"Docs"})}),(0,S.jsx)(t,{color:r.orange,underline:!0,children:aa})]},"docs"),(0,S.jsxs)(f,{children:[(0,S.jsx)(f,{width:14,children:(0,S.jsx)(t,{color:r.dim,children:"Bugs"})}),(0,S.jsx)(t,{color:r.orange,underline:!0,children:ca})]},"bugs")]}var Wn=k(he(),1);import{existsSync as Li,readFileSync as cl,rmSync as pa,unlinkSync as ga}from"fs";function ji(e){let n=Oo(e);Li(n)&&pa(n,{recursive:!0,force:!0}),Li(e)&&ga(e)}var Gr=k(j(),1);function Mi({cwd:e,currentOrgId:n,onClose:o,onRun:i,onExport:p}){let[m,x]=(0,Wn.useState)("list"),[h,v]=(0,Wn.useState)(null),[w,M]=(0,Wn.useState)(0);return m==="inspect"&&h?(0,Gr.jsx)(Fo,{path:h.path,relPath:h.relPath,onBack:()=>x("list"),onAction:R=>{if(R==="run")i(h);else if(R==="export")p(h);else{try{ji(h.path)}catch{}v(null),x("list"),M(_=>_+1)}}}):(0,Gr.jsx)($o,{root:e,currentOrgId:n,onSelect:R=>{v(R),x("inspect")},onCancel:o},w)}var Ee=k(he(),1);function Vi(e){let[n,o]=(0,Ee.useState)(null),[i,p]=(0,Ee.useState)(!1),[m,x]=(0,Ee.useState)(null),[h,v]=(0,Ee.useState)(null),[w,M]=(0,Ee.useState)(null),R=(0,Ee.useRef)(0),_=(0,Ee.useRef)([]),a=(0,Ee.useRef)(!1),u=(0,Ee.useRef)(null),D=(0,Ee.useRef)(e);D.current=e;let N=(0,Ee.useCallback)(async U=>{if(a.current)return null;a.current=!0;let E=++R.current,V=[];_.current=V;let J=H=>`testmd-run-${E}-${H}`,K={register:(H,de)=>{let se=J(H);V.push(se),rt(se,de)},deregister:H=>an(J(H)),cleanup:(H,de)=>St(J(H),de),remoteLogger:D.current.remoteLogger},Re={runSteps:H=>new Promise(de=>{let se=()=>{u.current=null,de()};u.current=se,o({...H,exitOnComplete:!1,onAllComplete:()=>{H.onAllComplete?.(),se()}})}),onLockState:H=>{},onRetryAttempt:H=>{},onSummary:async H=>{x(H)},onLinks:async H=>{v(H)},runUpload:H=>H.execute(),onAgentEvent:H=>{}};p(!0),x(null),v(null),M(null);try{let H=await D.current.buildInput(U),de=await ei(H,Re,K);return M(de),de}finally{a.current=!1,u.current=null,p(!1),o(null);for(let H of V)St(H,"run-finished");V.length=0}},[]),O=(0,Ee.useCallback)(()=>{for(let E of _.current)St(E,"cancelled");_.current=[];let U=u.current;u.current=null,U?.()},[]),$=(0,Ee.useCallback)(()=>{x(null),v(null),M(null)},[]);return{start:N,cancel:O,clearResult:$,running:i,runViewProps:n,summary:m,links:h,runSummary:w}}var Te=k(he(),1);function Oi(e={}){let[n,o]=(0,Te.useState)(()=>Vn({requestId:"",objective:""})),[i,p]=(0,Te.useState)(!1),[m,x]=(0,Te.useState)(null),h=(0,Te.useRef)(null),v=(0,Te.useRef)(!1),w=(0,Te.useRef)(null),M=(0,Te.useCallback)(async(N,O,$)=>{v.current=!1;let U=0,E=0,V=0;for await(let J of N){if(v.current)break;switch(o(K=>oi(K,J)),J.type){case"thinking_done":$?.("tcg_thinking",{tookMs:J.tookMs});break;case"progress":{let K=Math.min(100,Math.floor(J.pct/25)*25);K>V&&(V=K,$?.("tcg_progress",{pct:K}));break}case"snapshot":U=J.data.scenarios.length,E=J.data.scenarios.reduce((K,Re)=>K+(Re.test_cases?.length??0),0),$?.("tcg_snapshot",{scenarioCount:U,caseCount:E});break;case"clarification":$?.("tcg_clarification",{});break;case"done":$?.("tcg_request_done",{status:J.status,scenarioCount:U,caseCount:E,durationMs:Date.now()-O});break;case"error":$?.("tcg_request_error",{errorCode:"tcg_request_failed",durationMs:Date.now()-O});break}}},[]),R=(0,Te.useCallback)(async(N,O)=>{if(h.current)throw new Error("useTcgSession: a session is already active; call reset() or end() first");let $=e.makeClient??ii;h.current=$(N),w.current=new AbortController;let U=Vn({requestId:"",objective:O.prompt});o(On(U));let E;try{E=await h.current.start(O,w.current.signal)}catch(J){throw h.current=null,w.current=null,o(K=>({...K,turnActive:!1})),J}x(E.requestId),o(On({...E.state,requestId:E.requestId,objective:O.prompt}));let V=Date.now();e.log?.("tcg_request_start",{request_id:E.requestId,objectiveChars:O.prompt.length,scenarioLimit:O.scenarioLimit,perScenarioLimit:O.perScenarioLimit,memoryEnhancement:O.memoryEnhancement}),await M(E.events,V,e.log)},[M,e.makeClient,e.log]),_=(0,Te.useCallback)(async N=>{if(!h.current||!m)throw new Error("useTcgSession: chat() with no active request");o(O=>On(ri(O))),await h.current.chat(m,N)},[m]),a=(0,Te.useCallback)(async()=>{if(!(!m||!h.current)){v.current=!0,w.current&&w.current.abort();try{await h.current.cancel(m)}catch{}h.current=null,x(null),o(N=>({...N,turnActive:!1}))}},[m]),u=(0,Te.useCallback)(async()=>{if(!(!m||!h.current)){v.current=!0,w.current&&w.current.abort();try{await h.current.end(m)}catch{}h.current=null,x(null),o(N=>({...N,turnActive:!1}))}},[m]),D=(0,Te.useCallback)(()=>{v.current=!0,w.current&&w.current.abort(),w.current=null,o(Vn({requestId:"",objective:""})),x(null),p(!1),h.current=null},[]);return(0,Te.useEffect)(()=>()=>{v.current=!0,w.current&&w.current.abort()},[]),{state:n,isStreaming:n.turnActive,isTerminal:ni(n.status),isReconnecting:i,turnActive:n.turnActive,inReview:n.scenarios.length>0&&!n.turnActive&&!Ir(n.status),isSessionClosed:Ir(n.status),requestId:m,startWith:R,chat:_,cancel:a,end:u,reset:D}}var Z=k(he(),1);import{join as Wt,resolve as ya}from"path";import{mkdirSync as Hr,writeFileSync as Wi,appendFileSync as Ta}from"fs";function $i(e){let n=Le(e.env);return!n||!n.testGeneratorBaseUrl?{ok:!1,error:`Unknown environment "${e.env}" \u2014 fix default_env via /config`}:{ok:!0,conn:{baseUrl:`${n.testGeneratorBaseUrl}/test-generator/api/v2`,authResolver:e.resolver,projectId:e.projectId,folderId:e.folderId,log:e.log}}}function Fi(e){return e.turnActive?!0:e.requestId!=null&&!e.isSessionClosed&&!e.saved}function Ni(e){return e.isRunning||e.hasLiveResults}function Ui(e){let n=(e??"").trim().match(/^[sS](\d+)$/);if(!n)return{level:"scenarios"};let o=parseInt(n[1],10);return o<1?{level:"scenarios"}:{level:"cases",scenarioIdx:o-1}}function $e(e,n){return`S${e+1}.C${n+1}`}function Gi(e,n){return e.reduce((o,i,p)=>o+(i.test_cases??[]).filter((m,x)=>!n.has($e(p,x))).length,0)}function qi(e,n){return e.map((o,i)=>({...o,test_cases:(o.test_cases??[]).filter((p,m)=>!n.has($e(i,m)))})).filter(o=>(o.test_cases??[]).length>0)}var gn=k(he(),1);import{createHash as ha}from"crypto";function xa(e){return ha("sha1").update(JSON.stringify({t:e.title,p:e.preconditions,m:e.manual_steps})).digest("hex")}var zn=class{constructor(n){this.deps=n;this.max=n.maxConcurrent??3}cache=new Map;caseById=new Map;queue=[];active=0;max;onSnapshot(n){n.forEach((o,i)=>{(o.test_cases??[]).forEach((p,m)=>{if(!it(p)||p.manual_steps==null)return;let x=xa(p),h=this.cache.get(p.id);h&&h.hash===x||(h?.controller?.abort(),this.caseById.set(p.id,p),this.cache.set(p.id,{hash:x,ref:$e(i,m),status:"pending"}),this.queue.includes(p.id)||this.queue.push(p.id))})}),this.pump()}pump(){for(;this.active<this.max&&this.queue.length>0;){let n=this.queue.shift(),o=this.cache.get(n),i=this.caseById.get(n);!o||!i||o.status!=="pending"||(this.active++,this.runOne(n,i,o))}}async runOne(n,o,i){let p=`bifurcation-${n}`,m=new AbortController;i.controller=m;let x=this.deps.run??this.defaultRun.bind(this);rt(p,()=>m.abort());let h=Date.now();try{this.safeLog("tcg_bif_start",{caseId:n,ref:i.ref});let v=await x(ui(o),m.signal);if(!m.signal.aborted&&this.cache.get(n)===i){i.status="done",i.result=v;try{this.deps.persist?.(n,v,i.ref)}catch{}this.safeLog("tcg_bif_done",{caseId:n,ref:i.ref,total_flows:v.total_flows,is_single_flow:v.is_single_flow,estimated_steps_total:(v.sub_objectives??[]).reduce((w,M)=>w+(M.estimated_steps??0),0),credits_consumed:v.credits_consumed,durationMs:Date.now()-h})}}catch(v){!m.signal.aborted&&this.cache.get(n)===i&&(i.status="error",i.error=v.message,this.safeLog("tcg_bif_error",{caseId:n,ref:i.ref,errorCode:"bifurcation_failed",durationMs:Date.now()-h}))}finally{an(p),this.active--,this.pump()}}safeLog(n,o){try{this.deps.log?.(n,o)}catch{}}async defaultRun(n,o){let i=await this.deps.resolveAuth(),p=di({objective:n,model:this.deps.model,sessionId:this.deps.sessionId,auth:i});return mi(p,this.deps.spawnOpts,o)}getStatus(n){return this.cache.get(n)?.status}getResult(n){return this.cache.get(n)?.result}dispose(){for(let[n,o]of this.cache)o.controller?.abort(),an(`bifurcation-${n}`);this.cache.clear(),this.caseById.clear(),this.queue=[],this.active=0}};function Hi(e){let n=(0,gn.useRef)(null);return(0,gn.useEffect)(()=>{if(!e.enabled)return;let o=e.log,i=o?(p,m,x,h)=>o(m,h??{}):void 0;return n.current=new zn({model:e.model,sessionId:e.sessionId,resolveAuth:e.resolveAuth,spawnOpts:{environment:e.environment,log:i},log:o,persist:e.persist}),()=>{n.current?.dispose(),n.current=null}},[e.enabled,e.sessionId,e.model,e.environment]),(0,gn.useEffect)(()=>{n.current&&n.current.onSnapshot(e.scenarios)},[e.scenarios]),{getStatus:o=>n.current?.getStatus(o),getResult:o=>n.current?.getResult(o),manager:n}}var va=["request_id","session_id","caseId","ref","total_flows","is_single_flow","estimated_steps_total","credits_consumed","durationMs","pct","tookMs","scenarioCount","caseCount","savedCount","fellBack","turnIndex","status","errorCode","objectiveChars","scenarioLimit","perScenarioLimit","memoryEnhancement"],ba=new Set(va);function qr(e){let n={};for(let o of Object.keys(e))ba.has(o)&&e[o]!==void 0&&(n[o]=e[o]);return n}var qe=k(j(),1);async function Sa(e){let n=e?.getResolvedBasicAuth?.();if(n)return{username:n.username,access_key:n.access_key};let o=await e?.getToken?.();return typeof o=="string"&&o.length>0?{auth:{type:"bearer",token:o}}:{}}function zi(e){let{tcg:n,initialChatMode:o,tuiConfig:i,auth:p,session:m,appendStatic:x,handleInput:h,freezeTcgArtifact:v,rearmArtifactFreeze:w,initialGenerateLimits:M}=e,[R,_]=(0,Z.useState)(o??"run"),[a,u]=(0,Z.useState)(null),[D,N]=(0,Z.useState)(null),[O,$]=(0,Z.useState)(null),[U,E]=(0,Z.useState)(0),[V,J]=(0,Z.useState)(!1),K=(0,Z.useRef)(null),Re=(0,Z.useRef)(()=>{}),H=(0,Z.useCallback)(()=>Sa(p),[p]),de=(0,Z.useRef)(null);de.current=n.requestId;let se=(0,Z.useCallback)((W,ee)=>{let me=W.endsWith("_error")?"warn":"info",Q=qr({request_id:de.current??void 0,...ee});m.log(me,W,JSON.stringify(Q),Q);try{let Be=typeof Q.request_id=="string"&&Q.request_id||de.current||"unknown",ge=Wt(Ve,"tcg",Be);Hr(ge,{recursive:!0}),Ta(Wt(ge,"tcg_tui.log"),`[${new Date().toISOString()}] ${W} ${JSON.stringify(Q)}
|
|
3
|
-
`)}catch{}},[m]),Ye=(0,Z.useRef)(0),xt=(0,Z.useCallback)((W,ee,me)=>{try{let Q=Wt(Ve,"tcg",de.current??"unknown","bifurcation");Hr(Q,{recursive:!0}),Wi(Wt(Q,`${W}.json`),JSON.stringify({request_id:de.current,ref:me,...ee},null,2))}catch{}},[]),Qe=Hi({scenarios:n.state?.scenarios??[],model:i.model,sessionId:m.sessionId,resolveAuth:H,environment:p?.creds?.getDefaultEnv?.(),enabled:!!n.requestId&&!n.isSessionClosed,log:se,persist:xt}),Ct=(0,Z.useRef)(null);(0,Z.useEffect)(()=>{let W=n.requestId;if(!W||!n.isSessionClosed&&!n.isTerminal)return;let ee=n.state?.scenarios??[];if(ee.length!==0&&Ct.current!==W){Ct.current=W;try{let me=Wt(Ve,"tcg",W);Hr(me,{recursive:!0}),Wi(Wt(me,"request.json"),JSON.stringify({request_id:W,objective:n.state?.objective,headline:n.state?.headline,scenarios:ee,status:n.state?.status},null,2))}catch{}}},[n.requestId,n.isTerminal,n.isSessionClosed,n.state?.scenarios,n.state?.status,n.state?.objective,n.state?.headline]);let je=(0,Z.useCallback)((W,ee=1500)=>{$(W),K.current&&clearTimeout(K.current),K.current=setTimeout(()=>{$(null),K.current=null},ee)},[]);(0,Z.useEffect)(()=>()=>{K.current&&clearTimeout(K.current)},[]);let Dt=(0,Z.useCallback)(async W=>{u(null),N(null),J(!1);let ee=W.trim();if(!ee)return;if(ee.startsWith("/")){Re.current(ee),E(ge=>ge+1);return}if(!i.project_id||!i.folder_id){N("Set a project and folder first \u2014 use /config");return}let me=p.getResolver();if(!me){u("Not logged in \u2014 use /login");return}let Q=$i({env:p.creds.getDefaultEnv(),resolver:me,projectId:i.project_id,folderId:i.folder_id,log:(ge,Ze,Jt,vt)=>m.log(ge,Ze,"",qr(vt??{}))});if(!Q.ok){u(Q.error);return}let Be=Q.conn;v(),n.reset(),w();try{let ge=M??{};x((0,qe.jsx)(f,{marginTop:1,children:(0,qe.jsx)(t,{color:r.generateAccent,bold:!0,children:`\u276F ${ee}`})})),await n.startWith(Be,{prompt:ee,scenarioLimit:ge.scenarioLimit??i.generate.scenario_limit,perScenarioLimit:ge.perScenarioLimit??i.generate.per_scenario_limit,memoryEnhancement:i.generate.memory_enabled})}catch(ge){let Ze=ge instanceof Error?ge.message:String(ge);u(Ze||"Generation failed")}},[i,n,p,m,M,x,v,w]),hn=(0,Z.useCallback)(()=>u(null),[]),Kt=(0,Z.useCallback)(W=>{x((0,qe.jsx)(t,{color:r.generateAccent,bold:!0,children:`\u276F ${W}`})),Ye.current+=1,se("tcg_refine",{turnIndex:Ye.current}),n.chat(W).catch(ee=>u(ee?.message??"chat failed"))},[x,n,se]),Ne=(0,Z.useCallback)(W=>{x((0,qe.jsx)(t,{color:r.generateAccent,bold:!0,children:`\u276F ${W}`})),n.chat(W).catch(ee=>u(ee?.message??"chat failed"))},[x,n]),kt=(0,Z.useCallback)(W=>{let ee=Un(W);if(ee?.command==="view"){let me=W.trim().split(/\s+/).slice(1)[0];if(n.state.scenarios.length===0){e.emitFeedback("ok","/view","(no generation yet)");return}let Q=Ui(me);if(Q.level==="cases"&&Q.scenarioIdx>=n.state.scenarios.length){e.emitFeedback("error","/view",`No scenario S${Q.scenarioIdx+1}`);return}e.openBrowse(Q);return}if(ee?.command==="save"){let me=n.state.scenarios;if(me.length===0){e.emitFeedback("error","/save","Nothing to save yet.");return}let Q=qi(me,e.excluded),Be=Q.reduce((vt,lt)=>vt+(lt.test_cases??[]).filter(it).length,0);if(Be===0){e.emitFeedback("error","/save",Gi(me,e.excluded)===0?"All cases removed \u2014 nothing to save.":"No functional test cases to save.");return}let ge={...n.state,scenarios:Q},Ze=W.trim().split(/\s+/).slice(1)[0],Jt=Ze?ya(process.cwd(),Ze):process.cwd();J(!0),e.freezeTcgArtifact(),(async()=>{let vt=Q.flatMap(le=>(le.test_cases??[]).filter(it)),lt=Date.now()+3e4;for(;Date.now()<lt&&vt.some(le=>Qe.getStatus(le.id)==="pending");)await new Promise(le=>setTimeout(le,250));let vn=new Map;for(let le of vt)vn.set(le.id,Qe.getStatus(le.id)==="done"?Qe.getResult(le.id):void 0);n.end();let Ae=0,It=le=>{let Lt=vn.get(le.id);return Lt?ai(Lt,le):(Ae++,ci(le))};try{let le=await li(ge,Jt,{},It);se("tcg_save",{savedCount:le.paths.length,fellBack:Ae})}catch(le){e.emitFeedback("error","/save",`Save failed: ${le.message}`);return}let bn=`test case${Be===1?"":"s"}`;e.emitFeedback("ok","/save",Ae>0?`Saved ${Be} ${bn} \xB7 ${Ae} fell back to raw steps.`:`Saved ${Be} ${bn}.`)})();return}ee?.command==="new"&&J(!1),h(W)},[h,e,n,Qe,se]);Re.current=kt;let Me=(0,Z.useCallback)(W=>{_(W),E(ee=>ee+1)},[]),xn=(0,Z.useCallback)(W=>{let ee=R==="generate"&&W==="run",me=R==="run"&&W==="generate",Q=Fi({requestId:n.requestId,isSessionClosed:n.isSessionClosed,turnActive:n.turnActive,saved:V}),Be=Ni({isRunning:e.runner.isRunning,hasLiveResults:e.runner.lastRunEnd!=null});return ee&&Q?(e.openSwitchConfirm("run"),!1):me&&Be?(e.openSwitchConfirm("generate"),!1):(Me(W),!0)},[R,n.requestId,n.isSessionClosed,n.turnActive,V,e,Me]),rr=(0,Z.useCallback)(async W=>{R==="generate"?(e.freezeTcgArtifact(),await n.end().catch(()=>{}),n.reset(),J(!1),e.appendStatic((0,qe.jsxs)(f,{marginBottom:1,children:[(0,qe.jsx)(t,{color:r.red,children:"\u2717 "}),(0,qe.jsx)(t,{color:r.dim,children:"Discarded generation"})]}))):(e.runner.isRunning&&e.runner.cancelRun(),e.runner.clearLastRun(),e.appendStatic((0,qe.jsxs)(f,{marginBottom:1,children:[(0,qe.jsx)(t,{color:r.red,children:"\u2717 "}),(0,qe.jsx)(t,{color:r.dim,children:"Discarded run"})]}))),Me(W),W==="generate"?e.emitFeedback("ok","/generate","Switched to Generate mode.",void 0,r.generateAccent):e.emitFeedback("ok","/run","Switched to Run mode.",void 0,r.orange)},[R,n,e,Me]);return{chatMode:R,tcgError:a,tcgValidationError:D,composeIdleHint:O,inputClearSeq:U,handleGenerateSubmit:Dt,onRefine:Kt,onClarificationAnswer:Ne,onSlash:kt,onClearError:hn,flashComposeHint:je,setInputClearSeq:E,setChatMode:_,setTcgError:u,setTcgValidationError:N,generateSaved:V,requestSwitch:xn,confirmSwitch:rr,bifurcation:Qe,tcgLog:se}}var at=k(he(),1);function Xn(e){return e.level==="cases"?{level:"cases",scenarioIdx:e.scenarioIdx,caseIdx:0,cursor:0,scroll:0}:{level:"scenarios",scenarioIdx:0,caseIdx:0,cursor:0,scroll:0}}var Xi=(e,n)=>Math.max(0,Math.min(n,e));function Wr(e,n,o){switch(n.type){case"open":return Xn(n.target);case"move":{let i=e.level==="scenarios"?o.length-1:e.level==="cases"?(o[e.scenarioIdx]??1)-1:0;return{...e,cursor:Xi(e.cursor+n.delta,Math.max(0,i))}}case"enter":return e.level==="scenarios"?{...e,level:"cases",scenarioIdx:e.cursor,caseIdx:0,cursor:0,scroll:0}:e.level==="cases"?{...e,level:"detail",caseIdx:e.cursor,scroll:0}:e;case"back":return e.level==="detail"?{...e,level:"cases",cursor:e.caseIdx,scroll:0}:e.level==="cases"?{...e,level:"scenarios",cursor:e.scenarioIdx}:e;case"sibling":{if(e.level==="scenarios")return e;let i=Xi(e.scenarioIdx+n.delta,Math.max(0,o.length-1));return{...e,scenarioIdx:i,caseIdx:0,cursor:0,scroll:0}}case"scroll":return{...e,scroll:Math.max(0,e.scroll+n.delta)};default:return e}}function Ki(e){let[n,o]=(0,at.useState)(null),[i,p]=(0,at.useReducer)((R,_)=>Wr(R,_,e),Xn({level:"scenarios"})),[m,x]=(0,at.useState)(new Set),h=(0,at.useCallback)(R=>{o(R),p({type:"open",target:R})},[]),v=(0,at.useCallback)(()=>o(null),[]),w=(0,at.useCallback)((R,_)=>{let a=$e(R,_);x(u=>{let D=new Set(u);return D.has(a)?D.delete(a):D.add(a),D})},[]),M=(0,at.useCallback)((R,_)=>{x(a=>{let u=new Set(a),D=Array.from({length:_},(O,$)=>$e(R,$)),N=D.every(O=>u.has(O));return D.forEach(O=>N?u.delete(O):u.add(O)),u})},[]);return{target:n,open:h,close:v,isOpen:n!=null,state:i,excluded:m,toggleCase:w,toggleScenario:M}}var Yn=k(he(),1);function Ji(){return{committedChat:0,committedThinking:0,prevTurnActive:!1}}function Yi(e,n,o){let i=[],p={...e};if(e.prevTurnActive&&!o&&n.thinkingLog.length>e.committedThinking){let x=n.thinkingLog.slice(e.committedThinking).reduce((v,w)=>v+(w.tookMs??0),0),h=Math.round(x/1e3);i.push({kind:"thinking-summary",text:` thought for ${h}s`}),p.committedThinking=n.thinkingLog.length}p.prevTurnActive=o;for(let m=e.committedChat;m<n.chatLog.length;m++)i.push({kind:"chat",text:n.chatLog[m].text});return p.committedChat=n.chatLog.length,{items:i,next:p}}function Qi(e){let n=e;return n=n.replace(/@TS\{([^}]+)\}/g,"@S{$1}"),n=n.replace(/@TS-(\d+)/g,(o,i)=>`@S${parseInt(i,10)}.C1`),n=n.replace(/@TS(\d+)/g,(o,i)=>`@S${parseInt(i,10)}`),n=n.replace(/\\n/g,`
|
|
4
|
-
`),n}var Fe=k(j(),1),Zi=e=>e!==void 0&&/[A-Za-z0-9]/.test(e);function Kn(e){let n=[],o="",i=()=>{o&&(n.push({text:o}),o="")},p=(x,h,v)=>(x===0||!Zi(e[x-1]))&&(h+v>=e.length||!Zi(e[h+v])),m=0;for(;m<e.length;){let x=e.slice(m,m+2),h=e[m];if(x==="**"||x==="__"){let v=e.indexOf(x,m+2);if(v!==-1&&v>m+2&&(x==="**"||p(m,v,2))){i(),n.push({text:e.slice(m+2,v),bold:!0}),m=v+2;continue}}if(h==="`"){let v=e.indexOf("`",m+1);if(v!==-1&&v>m+1){i(),n.push({text:e.slice(m+1,v),code:!0}),m=v+1;continue}}if(h==="*"||h==="_"){let v=e.indexOf(h,m+1);if(v!==-1&&v>m+1&&(h==="*"||p(m,v,1))){i(),n.push({text:e.slice(m+1,v),italic:!0}),m=v+1;continue}}o+=h,m+=1}return i(),n.length===0&&n.push({text:""}),n}function Jn(e){return e.map((n,o)=>(0,Fe.jsx)(t,{bold:n.bold,italic:n.italic,color:n.code?r.dim:void 0,children:n.text},o))}function wa(e){return e.split(`
|
|
5
|
-
`).map(n=>{if(n.trim()==="")return{kind:"blank"};let o=n.match(/^\s*[-*+]\s+(.*)$/);if(o)return{kind:"bullet",segs:Kn(o[1])};let i=n.match(/^\s*(\d+)\.\s+(.*)$/);if(i)return{kind:"numbered",n:i[1],segs:Kn(i[2])};let p=n.match(/^#{1,6}\s+(.*)$/);return p?{kind:"heading",segs:Kn(p[1])}:{kind:"para",segs:Kn(n)}})}function Ra(e,n,o=""){switch(e.kind){case"blank":return(0,Fe.jsx)(t,{children:o||" "},n);case"heading":return(0,Fe.jsxs)(t,{bold:!0,children:[o,Jn(e.segs)]},n);case"bullet":return(0,Fe.jsx)(f,{marginLeft:1,children:(0,Fe.jsxs)(t,{children:[o,"\u2022 ",Jn(e.segs)]})},n);case"numbered":return(0,Fe.jsx)(f,{marginLeft:1,children:(0,Fe.jsxs)(t,{children:[o,`${e.n}. `,Jn(e.segs)]})},n);default:return(0,Fe.jsxs)(t,{children:[o,Jn(e.segs)]},n)}}function es({text:e}){let n=wa(Qi(e));return(0,Fe.jsxs)(f,{marginBottom:1,children:[(0,Fe.jsx)(t,{color:r.generateAccent,children:"\u2503 "}),(0,Fe.jsx)(f,{flexDirection:"column",children:n.map((o,i)=>Ra(o,i))})]})}var zr=k(j(),1);function Ca(e){return e.kind==="thinking-summary"?(0,zr.jsx)(t,{color:r.dim,children:e.text}):(0,zr.jsx)(es,{text:e.text})}function ts(e,n,o){let i=(0,Yn.useRef)(Ji());(0,Yn.useEffect)(()=>{let{items:p,next:m}=Yi(i.current,e,n);i.current=m;for(let x of p)o(Ca(x))})}var xe=k(j(),1);function ns({projectId:e,folderId:n,onSubmit:o,history:i,error:p,validationError:m,composeIdleHint:x,clearSeq:h,closedNotice:v}){return(0,xe.jsxs)(f,{flexDirection:"column",children:[(0,xe.jsx)(f,{marginLeft:2,marginTop:1,children:!(!!e&&!!n)&&(0,xe.jsxs)(t,{color:r.orange,children:["\u2691 ",(0,xe.jsx)(t,{color:r.muted,children:"project / folder not set \u2014 use "}),(0,xe.jsx)(t,{bold:!0,children:"/config"})]})}),m&&(0,xe.jsx)(f,{marginLeft:2,marginTop:1,children:(0,xe.jsx)(mt,{variant:"error",paddingY:0,children:(0,xe.jsx)(t,{color:r.red,children:m})})}),p&&(0,xe.jsx)(f,{marginLeft:2,marginTop:1,children:(0,xe.jsx)(mt,{variant:"error",paddingY:0,children:(0,xe.jsx)(t,{color:r.red,children:p})})}),v&&(0,xe.jsx)(f,{paddingX:1,children:(0,xe.jsx)(t,{color:r.dim,children:v})}),x&&(0,xe.jsx)(f,{marginLeft:2,marginTop:1,children:(0,xe.jsx)(t,{color:r.dim,children:x})}),(0,xe.jsx)(Tt,{onSubmit:o,history:i,noHistory:!0,accent:r.generateAccent,commands:Gn("","generate"),clearSeq:h,clearOnSubmit:!1,placeholder:"Describe what to generate... (/ = commands)",footerBindings:[{keys:"\u21B5",label:"generate"},{keys:"tab",label:"complete"},{keys:"/run",label:"Run mode"},{keys:"ctrl+t",label:"thinking"}]})]})}var cs=k(he(),1);var Se=k(j(),1);function ka(e){return e?`[${e[0].toUpperCase()}]`:""}var Ia=8;function Qn({scenarios:e,headline:n,activeSid:o}){let i=e.slice(0,Ia),p=e.length-i.length;return(0,Se.jsxs)(f,{flexDirection:"column",marginBottom:1,marginLeft:2,children:[n&&(0,Se.jsx)(f,{paddingX:1,children:(0,Se.jsx)(t,{color:r.generateAccent,bold:!0,children:n})}),(0,Se.jsxs)(mt,{title:`Scenarios (${e.length})`,titleColor:r.generateAccent,borderColor:r.generateAccent,paddingX:1,children:[i.map(m=>{let x=!!o&&m.sid===o,h=x?"\u2237":"\u2713",v=x?r.generateAccent:r.green,w=m.test_cases?.length??0;return(0,Se.jsxs)(f,{gap:1,children:[(0,Se.jsx)(t,{color:v,children:h}),(0,Se.jsx)(t,{color:r.dim,children:m.sid??`#${m.id}`}),(0,Se.jsx)(t,{children:m.title??"(untitled)"}),(0,Se.jsx)(t,{color:r.muted,children:ka(m.priority)}),(0,Se.jsxs)(t,{color:r.dim,children:[w," case",w===1?"":"s"]})]},m.id)}),p>0&&(0,Se.jsx)(t,{color:r.muted,children:`\u22EE +${p} more`}),(0,Se.jsx)(f,{marginTop:1,children:(0,Se.jsxs)(t,{color:r.dim,children:[(0,Se.jsx)(t,{color:r.generateAccent,children:"/view"})," inspect \xB7 ",(0,Se.jsx)(t,{color:r.generateAccent,children:"/save"})," save as runnable tests"]})})]})]})}var gt=k(j(),1),Ea=5;function rs({thinking:e,expanded:n,thinkingDone:o,maxLines:i=Ea}){if(!n)return(0,gt.jsxs)(f,{paddingX:1,children:[(0,gt.jsx)(t,{color:r.dim,children:o?"\u2237 thinking complete ":"\u2237 thinking\u2026 "}),(0,gt.jsx)(t,{color:r.muted,children:o?"(ctrl+t to view)":"(ctrl+t to show)"})]});let p=e.split(`
|
|
6
|
-
`),m=Math.max(0,p.length-i),x=m>0?p.slice(-i).join(`
|
|
7
|
-
`):e;return(0,gt.jsxs)(mt,{variant:"default",paddingX:1,children:[m>0&&(0,gt.jsxs)(t,{color:r.muted,children:["\u22EE (",m," earlier line",m===1?"":"s"," hidden)"]}),(0,gt.jsx)(t,{color:r.dim,children:x}),o&&(0,gt.jsx)(t,{color:r.muted,children:"\u2014 thinking complete"})]})}var zt=k(j(),1),os=24;function _a(e){let n=Math.max(0,Math.min(100,e)),o=Math.round(n/100*os);return{filled:"\u2588".repeat(o),empty:"\u2591".repeat(os-o)}}function is({pct:e}){let n=_a(e);return(0,zt.jsxs)(f,{paddingX:1,children:[(0,zt.jsx)(t,{color:r.generateAccent,children:n.filled}),(0,zt.jsx)(t,{color:r.muted,children:n.empty}),(0,zt.jsx)(t,{color:r.dim,children:` ${e}%`})]})}var ht=k(j(),1);function ss(e,n){let o=e.trim();return o.startsWith("/")?{kind:"slash",text:o}:o?n?{kind:"ignore",text:o}:{kind:"refine",text:o}:{kind:"ignore",text:""}}function as({state:e,history:n,turnActive:o,onClarificationAnswer:i,onClearError:p,onRefine:m,onSlash:x}){let h=i?v=>{p?.(),i(v)}:void 0;return(0,ht.jsxs)(ht.Fragment,{children:[e.pendingClarification&&h&&(0,ht.jsx)(f,{paddingX:1,marginTop:1,flexDirection:"column",children:(0,ht.jsx)(Tt,{onSubmit:h,history:n,noHistory:!0,accent:r.generateAccent,placeholder:"Type your answer\u2026",submitVerb:"answer",footerBindings:[{keys:"\u21B5",label:"answer"}]})}),!(e.pendingClarification&&h)&&(o?(0,ht.jsx)(Tt,{inert:!0,onSubmit:()=>{},history:n,placeholder:"(generating\u2026 input inert \u2014 Ctrl+C to cancel)"}):(0,ht.jsx)(Tt,{onSubmit:v=>{let w=ss(v,o);w.kind==="slash"?x?.(w.text):w.kind==="refine"&&m?.(w.text)},history:n,noHistory:!0,accent:r.generateAccent,commands:Gn("","generate"),placeholder:"Refine, or /save \xB7 /view \xB7 /run",submitVerb:"refine",footerBindings:[{keys:"\u21B5",label:"refine"},{keys:"tab",label:"complete"},{keys:"/run",label:"Run mode"},{keys:"ctrl+t",label:"thinking"}]}))]})}var He=k(j(),1);function ls({state:e,requestId:n,history:o,onClarificationAnswer:i,error:p,onClearError:m,turnActive:x,onRefine:h,onSlash:v}){let[w,M]=(0,cs.useState)(!1),R=e.thinking.length===0&&e.thinkingLog.length>0,_=[...e.thinkingLog.map(a=>a.text),e.thinking].filter(a=>a.length>0).join(`
|
|
8
|
-
|
|
9
|
-
`);return Ce((a,u)=>{u.ctrl&&a==="t"&&M(D=>!D)}),(0,He.jsxs)(f,{flexDirection:"column",children:[(0,He.jsx)(f,{marginBottom:1,marginLeft:2,children:(0,He.jsx)(rs,{thinking:_,expanded:w,thinkingDone:R})}),x&&(0,He.jsx)(f,{marginLeft:2,children:(0,He.jsx)(is,{pct:e.progress})}),p&&(0,He.jsx)(f,{marginLeft:2,marginTop:1,children:(0,He.jsx)(mt,{variant:"error",paddingY:0,children:(0,He.jsx)(t,{color:r.red,children:p})})}),e.scenarios.length>0&&(0,He.jsx)(Qn,{scenarios:e.scenarios,headline:e.headline,activeSid:null}),(0,He.jsx)(as,{state:e,history:o,turnActive:x,onClarificationAnswer:i,onClearError:m,onRefine:h,onSlash:v})]})}var ps=k(he(),1);var we=k(j(),1);function Ba(e,n,o){let i=(e.test_cases??[]).length;return Array.from({length:i},(p,m)=>$e(n,m)).some(p=>!o.has(p))}function us({scenarios:e,cursor:n,excluded:o}){let i=e.reduce((p,m)=>p+(m.test_cases??[]).length,0);return(0,we.jsxs)(f,{flexDirection:"column",paddingX:1,children:[(0,we.jsxs)(t,{children:[(0,we.jsx)(t,{color:r.dim,children:"Generate \u203A "}),(0,we.jsx)(t,{color:r.generateAccent,children:"Scenarios"}),(0,we.jsx)(t,{color:r.dim,children:` ${e.length} scenarios \xB7 ${i} cases`})]}),(0,we.jsx)(t,{color:r.muted,children:"\u2500".repeat(60)}),(0,we.jsx)(f,{flexDirection:"column",marginY:1,children:e.map((p,m)=>{let x=m===n,h=Ba(p,m,o);return(0,we.jsxs)(t,{children:[(0,we.jsx)(t,{color:r.generateAccent,children:x?"\u276F ":" "}),(0,we.jsx)(t,{color:r.generateAccent,children:`S${m+1}`}),(0,we.jsx)(t,{children:` ${p.title??"(untitled)"}`}),(0,we.jsx)(t,{color:r.dim,children:` [${p.priority??"-"}] ${(p.test_cases??[]).length} cases `}),(0,we.jsx)(t,{color:h?r.green:r.red,children:h?"\u2713":"\u2717"})]},p.id)})}),(0,we.jsx)(t,{color:r.muted,children:"\u2500".repeat(60)}),(0,we.jsx)(t,{color:r.dim,children:"\u2191\u2193 move \u21B5 open x remove esc back to chat"})]})}var ve=k(j(),1);function ds({scenario:e,scenarioIdx:n,cursor:o,excluded:i}){let p=e.test_cases??[],m=p.some(x=>!it(x));return(0,ve.jsxs)(f,{flexDirection:"column",paddingX:1,children:[(0,ve.jsxs)(t,{children:[(0,ve.jsx)(t,{color:r.dim,children:"Generate \u203A Scenarios \u203A "}),(0,ve.jsx)(t,{color:r.generateAccent,children:`S${n+1} ${e.title??"(untitled)"}`}),(0,ve.jsx)(t,{color:r.dim,children:` ${p.length} cases`})]}),(0,ve.jsx)(t,{color:r.muted,children:"\u2500".repeat(60)}),(0,ve.jsx)(f,{flexDirection:"column",marginY:1,children:p.map((x,h)=>{let v=h===o,w=i.has($e(n,h));return(0,ve.jsxs)(t,{children:[(0,ve.jsx)(t,{color:r.generateAccent,children:v?"\u276F ":" "}),(0,ve.jsx)(t,{color:r.generateAccent,children:`C${h+1}`}),(0,ve.jsx)(t,{children:` ${x.title??"(untitled)"} `}),it(x)?(0,ve.jsx)(t,{color:w?r.red:r.green,children:w?"\u2717 removed":"\u2713 included"}):(0,ve.jsx)(t,{color:r.dim,children:"\u2713"})]},x.id)})}),(0,ve.jsx)(t,{color:r.muted,children:"\u2500".repeat(60)}),m&&(0,ve.jsx)(t,{color:r.dim,children:"gray \u2713 = non-functional \xB7 won't be saved by /save"}),(0,ve.jsx)(t,{color:r.dim,children:"\u2191\u2193 move \u21B5 view detail x remove case \u25C2 \u25B8 sibling \u2190 scenarios esc chat"})]})}var Je=k(j(),1);function Xr({label:e,value:n}){return n?(0,Je.jsxs)(f,{flexDirection:"column",marginBottom:1,children:[(0,Je.jsx)(t,{color:r.dim,children:e}),(0,Je.jsx)(f,{marginLeft:1,children:(0,Je.jsx)(t,{children:n})})]}):null}function ms({n:e,step:n,expected:o}){return(0,Je.jsxs)(f,{flexDirection:"column",marginBottom:1,children:[(0,Je.jsxs)(t,{children:[(0,Je.jsx)(t,{color:r.generateAccent,children:`${e}. `}),n]}),o?(0,Je.jsx)(f,{marginLeft:3,children:(0,Je.jsx)(t,{color:r.dim,children:`\u2192 ${o}`})}):null]})}var ie=k(j(),1);function fs({scenario:e,scenarioIdx:n,caseIdx:o,scroll:i,excluded:p,getStatus:m,getResult:x}){let h=(e.test_cases??[])[o],v=$e(n,o),w=p.has(v),M=h?it(h):!0,R=h&&m?m(h.id):void 0,_=R==="done"?(0,ie.jsx)(t,{color:r.generateAccent,children:"ready"}):R==="error"?(0,ie.jsx)(t,{color:r.red,children:"failed \u2192 raw steps"}):R==="pending"?(0,ie.jsx)(t,{color:r.dim,children:"bifurcating\u2026"}):null,a=R==="done"&&h&&x?x(h.id):void 0,u=a?a.sub_objectives.map(N=>({step:N.objective,expected:""})):si(h?.manual_steps),D=[h?.priority&&`Priority ${h.priority}`,h?.polarity&&`Polarity ${h.polarity}`,h?.tags&&`Tags ${h.tags}`].filter(Boolean).join(" \xB7 ");return(0,ie.jsxs)(f,{flexDirection:"column",paddingX:1,children:[(0,ie.jsxs)(t,{children:[(0,ie.jsx)(t,{color:r.dim,children:`Generate \u203A S${n+1} \u203A `}),(0,ie.jsx)(t,{color:r.generateAccent,children:`C${o+1} ${h?.title??"(untitled)"}`}),_?(0,ie.jsx)(t,{children:" "}):null,_]}),M?(0,ie.jsx)(t,{color:w?r.red:r.green,children:w?"\u2717 removed":"\u2713 included"}):(0,ie.jsx)(t,{color:r.dim,children:"\u2713 non-functional \xB7 not saved by /save"}),(0,ie.jsx)(t,{color:r.muted,children:"\u2500".repeat(60)}),(0,ie.jsxs)(f,{flexDirection:"column",marginTop:1,children:[D?(0,ie.jsx)(f,{marginBottom:1,children:(0,ie.jsx)(t,{color:r.dim,children:D})}):null,(0,ie.jsx)(Xr,{label:"Description",value:h?.description}),(0,ie.jsx)(Xr,{label:"Preconditions",value:h?.preconditions}),u.length>0&&(0,ie.jsxs)(f,{flexDirection:"column",children:[(0,ie.jsx)(t,{color:r.dim,children:"Steps"}),(0,ie.jsx)(f,{flexDirection:"column",marginLeft:1,marginTop:0,children:u.slice(i).map((N,O)=>(0,ie.jsx)(ms,{n:i+O+1,step:N.step,expected:N.expected},O))})]})]}),(0,ie.jsx)(t,{color:r.muted,children:"\u2500".repeat(60)}),(0,ie.jsx)(t,{color:r.dim,children:"\u2191\u2193 scroll \u2190 back \u25C2 \u25B8 prev/next case x remove esc chat"})]})}var Zn=k(j(),1);function gs({scenarios:e,target:n,onClose:o,excluded:i,onToggleCase:p,onToggleScenario:m,getStatus:x,getResult:h}){let v=e.map(_=>(_.test_cases??[]).length),[w,M]=(0,ps.useReducer)((_,a)=>Wr(_,a,v),Xn(n));Ce((_,a)=>{if(a.escape){o();return}if(a.upArrow){M(w.level==="detail"?{type:"scroll",delta:-1}:{type:"move",delta:-1});return}if(a.downArrow){M(w.level==="detail"?{type:"scroll",delta:1}:{type:"move",delta:1});return}if(a.return){M({type:"enter"});return}if(a.leftArrow){if(w.level==="scenarios"){o();return}M({type:"back"});return}if(_==="["){M({type:"sibling",delta:-1});return}if(_==="]"){M({type:"sibling",delta:1});return}if(_==="x"){w.level==="scenarios"?m(w.cursor,v[w.cursor]??0):p(w.scenarioIdx,w.level==="cases"?w.cursor:w.caseIdx);return}});let R=e[w.scenarioIdx];if(w.level==="scenarios"||R===void 0){let _=w.level==="scenarios"?w.cursor:0;return(0,Zn.jsx)(us,{scenarios:e,cursor:_,excluded:i})}return w.level==="cases"?(0,Zn.jsx)(ds,{scenario:R,scenarioIdx:w.scenarioIdx,cursor:w.cursor,excluded:i}):(0,Zn.jsx)(fs,{scenario:R,scenarioIdx:w.scenarioIdx,caseIdx:w.caseIdx,scroll:w.scroll,excluded:i,getStatus:x,getResult:h})}var er=k(j(),1);function hs({tcg:e,gm:n,history:o,tuiConfig:i,browse:p}){return p?(0,er.jsx)(gs,{scenarios:e.state.scenarios,target:p.target,onClose:p.onClose,excluded:p.excluded,onToggleCase:p.onToggleCase,onToggleScenario:p.onToggleScenario,getStatus:p.getStatus,getResult:p.getResult}):!e.requestId||e.isSessionClosed?(0,er.jsx)(ns,{projectId:i.project_id,folderId:i.folder_id,onSubmit:n.handleGenerateSubmit,history:o,error:n.tcgError,validationError:n.tcgValidationError,composeIdleHint:n.composeIdleHint,clearSeq:n.inputClearSeq,closedNotice:e.isSessionClosed?`Generation ${e.state.status}. Type a new objective or /run.`:void 0}):(0,er.jsx)(ls,{state:e.state,requestId:e.requestId,history:o,turnActive:e.turnActive,error:n.tcgError??e.state.error,onClearError:()=>n.onClearError?.(),onClarificationAnswer:m=>n.onClarificationAnswer?.(m),onRefine:n.onRefine,onSlash:n.onSlash})}var xs=k(he(),1);var ct=k(j(),1);function Aa({message:e,confirmLabel:n,choice:o}){return(0,ct.jsxs)(f,{flexDirection:"column",borderStyle:"round",borderColor:r.dim,paddingX:1,children:[(0,ct.jsx)(t,{bold:!0,children:e}),(0,ct.jsxs)(f,{marginTop:1,children:[(0,ct.jsx)(t,{color:o==="yes"?r.red:r.dim,children:`\u276F ${n}`}),(0,ct.jsx)(t,{children:" "}),(0,ct.jsx)(t,{color:o==="no"?r.green:r.dim,children:"\u276F No"})]}),(0,ct.jsx)(t,{color:r.dim,children:"\u2190 \u2192 choose \xB7 \u21B5 confirm \xB7 esc cancel"})]})}function vs({message:e,onConfirm:n,onCancel:o,confirmLabel:i="Yes, end"}){let[p,m]=(0,xs.useState)("no");return Ce((x,h)=>{(h.leftArrow||h.rightArrow)&&m(v=>v==="yes"?"no":"yes"),h.return&&(p==="yes"?n:o)(),h.escape&&o()}),(0,ct.jsx)(Aa,{message:e,confirmLabel:i,choice:p})}var Pa=null;function bs(e){Pa=e}import{join as Xt,resolve as Da}from"path";var tr=k(j(),1);function ys({status:e,steps:n,duration:o,creditsConsumed:i,reason:p}){let m=e==="passed",x=m?r.green:r.red,h=m?"\u2713":"\u2717",v=m?"Passed":"Failed",w=o<60?`${o.toFixed(1)}s`:`${Math.floor(o/60)}m ${Math.round(o%60)}s`,M=typeof i=="number"&&i>0?` \xB7 ${i.toFixed(4)} credits`:"",R=!m&&p?` \xB7 ${p}`:"";return(0,tr.jsxs)(f,{children:[(0,tr.jsxs)(t,{bold:!0,color:x,children:[h," ",v]}),(0,tr.jsxs)(t,{color:r.dim,children:[" ","\xB7 ",n," steps \xB7 ",w,M,R]})]})}var Ss=k(j(),1);function Ts(){return(0,Ss.jsx)(t,{color:r.dim,children:"Continue below \xB7 /new fresh session \xB7 /summary view details \xB7 Ctrl+C exit"})}var nr=e=>({kind:"login",env:e}),Kr=e=>({kind:"switch",env:e}),ws=(e,n)=>e?{kind:"switch",env:n}:{kind:"logout"};async function Rs(e){await new $t(e.tmsBaseUrl,e.username,e.accessKey).submitFeedback({instruction_id:"",test_id:e.testId,feedback_type:e.feedbackType,mode:e.mode??"human",...e.details?{details:e.details}:{}}),e.log("info","FEEDBACK_SUBMITTED","Feedback submitted",{type:e.feedbackType})}var b=k(j(),1);function Ym({localMode:e=!1,codeExport:n,codeLanguage:o,skipCodeValidation:i,updatePromise:p,migrationResult:m,sessionName:x,initialChatMode:h,initialObjective:v,initialGenerateLimits:w}={}){po();let M=(0,T.useRef)(new Ln),[R,_]=(0,T.useState)(0),a=M.current,[u]=(0,T.useState)(()=>new Ut),D=(0,T.useRef)(0),N=(0,T.useCallback)(()=>`msg-${++D.current}`,[]),[O,$]=(0,T.useState)(!1),[U,E]=(0,T.useState)(null),[V,J]=(0,T.useState)(!1),[K,Re]=(0,T.useState)(0),[H,de]=(0,T.useState)(!1),[se,Ye]=(0,T.useState)(null),[xt,Qe]=(0,T.useState)(null),Ct=(0,T.useRef)(null),[je,Dt]=(0,T.useState)(null),[hn,Kt]=(0,T.useState)(jn()),[Ne,kt]=(0,T.useState)(null),[Me,xn]=(0,T.useState)([]),[rr,W]=(0,T.useState)(!1),[ee,me]=(0,T.useState)(!1),[Q,Be]=(0,T.useState)(null),[ge,Ze]=(0,T.useState)(null),[Jt,vt]=(0,T.useState)(null),lt=(0,T.useRef)(null),vn=(0,T.useRef)(null),Ae=(0,T.useRef)(0),It=(0,T.useRef)(""),bn=(0,T.useRef)(null),le=(0,T.useRef)(null),Lt=(0,T.useRef)({}),yn=(0,T.useRef)(null),Cs=(0,T.useRef)(0),[Jr,ks]=(0,T.useState)([]),oe=(0,T.useCallback)(c=>{let l=`s-${++Cs.current}`;ks(s=>[...s,{id:l,content:c}])},[]),[Yt,et]=(0,T.useState)("booting"),[Is,Es]=(0,T.useState)([]),[_s,or]=(0,T.useState)(!1),[Yr,Bs]=(0,T.useState)(!1),[Tn,As]=(0,T.useState)("chat"),[tt,Qt]=(0,T.useState)(null),[Sn,Qr]=(0,T.useState)(null),[Zt,Zr]=(0,T.useState)(!1),[en,wn]=(0,T.useState)(!1),eo=(0,T.useRef)(()=>{}),Ps=(0,T.useCallback)((c,l)=>eo.current(c,l),[]),z=Oi({log:Ps});ts(z.state,z.turnActive,oe);let ir=(0,T.useRef)(!1),ut=(0,T.useCallback)(()=>{ir.current||z.state.scenarios.length!==0&&(ir.current=!0,oe((0,b.jsx)(Qn,{scenarios:z.state.scenarios,activeSid:null})))},[z.state.scenarios,oe]);(0,T.useEffect)(()=>{z.isSessionClosed&&ut()},[z.isSessionClosed,ut]);let[Rn,tn]=(0,T.useState)(null),[te,nn]=(0,T.useState)({headless:!1,maxSteps:50,timeout:0,cdpEndpoint:"",wsEndpoint:"",useCft:!1}),to=xo(),g=Ci(),Cn=ki(),Ue=(0,T.useMemo)(()=>({auth:{initResolver:c=>g.initResolver(c,(l,s,d,y)=>M.current.log(l,s,d,y)),getResolver:()=>g.getResolver(),getBasicAuth:()=>g.getBasicAuth(),getToken:()=>g.getToken()},getSession:()=>M.current,log:(c,l,s,d)=>M.current.log(c,l,s,d),state:{getTmsCredsCache:()=>Ne,setTmsCredsCache:kt,identityServicesRef:vn,screenshotQueueRef:lt},exit:{registerCleanup:rt,setExitRemoteLogger:_o},options:{skipScreenshotQueue:e}}),[g.initResolver,g.getResolver,g.getBasicAuth,g.getToken,Ne,e]),Ds=(0,T.useCallback)((c,l,s)=>{let d=lt.current;if(!d)return;let y=Ae.current+l;Ho(a.sessionDir,y,c,d,(P,L,F,G)=>a.log(P,L,F,G),s)},[a]),Ls=(0,T.useCallback)((c,l,s)=>{a.logStep(c,l,s)},[a]),js=(0,T.useCallback)(c=>yn.current?.setStepText(c),[]),Ms=(0,T.useCallback)(()=>yn.current?.setStepComplete(),[]),B=Do(Ds,Ls,js,Ms),[C,be]=(0,T.useState)(()=>u.load()),[,Vs]=(0,T.useState)(0),Pe=(0,T.useCallback)(()=>Vs(c=>c+1),[]),[I,fe]=(0,T.useState)(null),jt=g.creds.getActiveProfile(),ne=g.creds.getDefaultEnv(),We=(0,T.useCallback)((c,l)=>{let s=c?g.creds.loadProfileConfig(c,l):null;u.save({project_id:s?.project_id??null,project_name:s?.project_name??null,folder_id:s?.folder_id??null,folder_name:s?.folder_name??null}),be(u.load())},[g.creds,u]),sr=(0,T.useCallback)(async(c,l)=>{let s=g.getResolver();if(!s)return null;let d=s.cached??await s.resolve();if(!d)return null;let y=Le(l),P=new $t(y.tmsBaseUrl,d.username,d.access_key);try{let F=(await P.listProjects()).find(Y=>Y.name==="KaneAI Generated");if(F)return{id:F.project_id,name:F.name};let G=await P.createProject("KaneAI Generated");return{id:G.id,name:G.name}}catch{return null}},[g]),ar=(0,T.useCallback)(async(c,l)=>{let s=g.getResolver();if(!s)return null;let d=s.cached??await s.resolve();if(!d)return null;let y=Le(c),P=new $t(y.tmsBaseUrl,d.username,d.access_key);try{let F=(await P.listFolders(l)).find(Y=>Y.name==="Untitled");if(F)return{id:F.id,name:F.name};let G=await P.createFolder(l,"Untitled");return{id:G.id,name:G.name}}catch{return null}},[g]);(0,T.useEffect)(()=>{V||(a.start({model:C.model,environment:ne,profile:jt}),x&&a.setSessionName(x),J(!0))},[a,V,C.model,ne,jt,x]);let no=(0,T.useRef)(!1);(0,T.useEffect)(()=>{if(!V||no.current)return;no.current=!0;let c=x?[{label:"session",value:x},{label:"test",value:br(Xt(process.cwd(),".testmuai","tests",`${x}_test.md`))},{label:"output",value:br(Xt(process.cwd(),".testmuai","tests",`output-${x}`))}]:[{label:"session",value:"ephemeral"},{label:"note",value:"use /name <name> to persist this session"}];oe((0,b.jsx)(vo,{title:"Recording",titleColor:"#ff9500",rows:c}))},[V,x,oe]);let ro=(0,T.useRef)(!1);(0,T.useEffect)(()=>{if(!O||ro.current||!V)return;ro.current=!0;let c=Ue.state.getTmsCredsCache();if(!c){a.log("warn","BOOT_RESOLVE_FAILED","Boot done but tmsCredsCache empty \u2014 non-controller APIs may fail");return}ot({kind:"boot",tmsCreds:c,env:ne},Ue).then(l=>{l&&(c.org_id!==void 0&&a.setOrgId(String(c.org_id)),a.log("info","BOOT_RESOLVE_OK","Boot identity attached",{username:c.username,org_id:c.org_id}))}).catch(l=>{a.log("error","BOOT_RESOLVE_ERROR","Boot identity attach error",{error:l instanceof Error?l.message:String(l)})})},[O,V,Ue,ne,a]);let Et=(0,T.useCallback)(async()=>{if(Ne)return a.log("info","TMS_CREDS_CACHED","Using cached TMS credentials",{username:Ne.username,org_id:Ne.org_id}),Ne;let c=await g.resolveBasicAuth();return c?(a.log("info","TMS_CREDS_OK","TMS credentials resolved",{username:c.username,org_id:c.org_id,user_id:c.user_id}),kt(c)):a.log("warn","TMS_CREDS_FAILED","No TMS credentials resolved"),c},[g,Ne,a]),oo=(0,T.useCallback)(async()=>{let c=await Et();if(!c)return a.log("warn","PROJECT_FAILED","No TMS credentials for project resolution"),null;let l=Le(ne),s=new $t(l.tmsBaseUrl,c.username,c.access_key),d=g.creds.getActiveProfile(),y=g.creds.getDefaultEnv(),P=d?g.creds.loadProfileConfig(d,y):null,L=P?.project_id??C.project_id;if(L)a.log("info","PROJECT_CACHED","Using cached project",{project_id:L});else{a.log("info","PROJECT_FETCH","No project_id in config, fetching from TMS");try{a.log("info","PROJECT_LIST","Listing projects from TMS",{url:`${l.tmsBaseUrl}/v1/projects`});let G=await s.listProjects((ce,De,yt,ze)=>a.log(ce,De,yt,ze));a.log("info","PROJECT_LIST_OK","Projects listed",{count:G.length});let Y=G.find(ce=>ce.name==="KaneAI Generated");if(Y)L=Y.project_id,a.log("info","PROJECT_SELECTED","Using KaneAI Generated project",{project_id:L});else if(G.length>0){let ce=G[0];L=ce.project_id,a.log("info","PROJECT_SELECTED","Using first project",{name:ce.name,project_id:L})}L&&Oe(g.creds,u,g.creds.getActiveProfile()??"default",g.creds.getDefaultEnv(),{projectId:L})}catch(G){return a.log("error","PROJECT_LIST_FAILED","Project listing failed",{error:String(G)}),null}}if(!L)return a.log("warn","PROJECT_NONE","No projects found"),null;let F=P?.folder_id??C.folder_id;if(F)a.log("info","FOLDER_CACHED","Using cached folder",{folder_id:F});else try{a.log("info","FOLDER_FETCH","Fetching default folder",{project_id:L}),F=await s.getDefaultFolder(L),a.log("info","FOLDER_OK","Default folder resolved",{folder_id:F}),F&&Oe(g.creds,u,g.creds.getActiveProfile()??"default",g.creds.getDefaultEnv(),{folderId:F})}catch(G){return a.log("error","FOLDER_FAILED","Default folder fetch failed",{error:String(G)}),null}return{projectId:L,folderId:F??""}},[C.project_id,C.folder_id,Et,ne,u,a,g.creds]),ae=(0,T.useCallback)(c=>{let l=N(),s={...c,id:l};oe((0,b.jsx)(Ti,{entry:s}))},[N,oe]),A=(0,T.useCallback)((c,l,s,d,y)=>{oe((0,b.jsx)(Ai,{status:c,command:l,message:s,details:d,accentColor:y})),l==="/save"&&c==="ok"&&oe((0,b.jsx)(f,{marginLeft:2,children:(0,b.jsxs)(t,{color:r.dim,children:["\u2192 Run ",(0,b.jsx)(t,{color:r.generateAccent,children:"/testmd"})," to list your saved tests."]})}))},[oe]),io=(0,T.useRef)(()=>{}),bt=Ki(z.state.scenarios.map(c=>(c.test_cases??[]).length)),dt=zi({tcg:z,initialChatMode:h,tuiConfig:C,auth:g,session:a,runner:B,appendStatic:oe,handleInput:c=>io.current(c),freezeTcgArtifact:ut,rearmArtifactFreeze:()=>{ir.current=!1},openSwitchConfirm:c=>tn({reason:"switch",to:c}),emitFeedback:A,excluded:bt.excluded,openBrowse:bt.open,initialGenerateLimits:w});eo.current=dt.tcgLog;let{chatMode:pe,tcgError:ja,tcgValidationError:Ma,composeIdleHint:Va,inputClearSeq:Os,handleGenerateSubmit:$s,flashComposeHint:kn,setTcgError:Oa}=dt,cr=(0,T.useCallback)(async(c,l)=>{let s=Xo({objective:c,globalDir:Xt(Ve,"variables"),localDir:Xt(process.cwd(),".testmuai","variables")}),d=a.nextRunIndex();Ae.current=d,It.current=s.auteurObjective,a.logRunStart(d,s.auteurObjective,l??""),a.setFirstRun(s.auteurObjective,l??"");let y=g.getResolvedBasicAuth(),P=y,L=null;if(!P&&(L=await g.getToken(),!L)){ae({type:"error",text:"Not authenticated. Run /login first."});return}let F={basicAuth:y??null,token:L,resolver:g.getResolver(),resolvedCreds:null};bn.current=F;let G=g.creds.getActiveProfile()??"default",Y=g.creds.getDefaultEnv();Ro(g.creds,u,G,Y,(ue,Xe,Ke,nt)=>a.log(ue,Xe,Ke,nt));let ce=u.load();if(be(ce),d===0&&!e){a.log("info","ATM_CREATE_START","Creating test via ATM endpoint",{run_index:0});let ue=await oo(),Xe=Le(ne),Ke=P?{username:P.username,access_key:P.access_key}:await Et();if(Ke){let nt=await Qo({tmsBaseUrl:Xe.tmsBaseUrl,auth:{username:Ke.username,access_key:Ke.access_key},objective:s.auteurObjective,url:l??C.default_url??"",projectId:ue?.projectId??ce.project_id??"",folderId:ue?.folderId??ce.folder_id??"",hasCustomProfile:!!C.chrome_profile_path,log:(Bt,vr,Hs,Ws)=>a.log(Bt,vr,Hs,Ws)});nt&&(a.setTestId(nt),ue?.projectId&&a.setProjectId(ue.projectId))}}let De=null;if(te.useCft)ae({type:"info",text:"CfT mode: Playwright will manage browser"});else if(te.wsEndpoint)ae({type:"info",text:`WS endpoint: ${te.wsEndpoint.slice(0,60)}...`});else if(te.cdpEndpoint)ae({type:"info",text:`CDP endpoint: ${te.cdpEndpoint}`});else{ae({type:"info",text:"Starting Chrome..."});try{De=await Cn.ensureChrome(l)}catch(Xe){ae({type:"error",text:Bo(Xe)});return}a.logChromeLaunch(De.port,De.cdpEndpoint),ae({type:"info",text:`Chrome ready (port ${De.port})`});let ue=Po({headless:te.headless,cdpEndpoint:De.cdpEndpoint,chromePid:De.process.pid});ue&&(yn.current=ue,rt("marker-overlay",()=>ue.kill()))}a.setAuteurVariables(s.auteur),le.current=s;let yt=P&&!e?await Ko({variables:s,auth:P,orgId:String((await Et())?.org_id??""),env:ne,localMode:e,log:(ue,Xe,Ke,nt)=>a.log(ue,Xe,Ke,nt)}):{};Lt.current=yt;let ze=kr(Xt(Ve,"global-memory.md")),Mt=kr(Xt(process.cwd(),".testmuai","context.md")),rn=De?{cdpEndpoint:De.cdpEndpoint,instance:De,tempDir:null}:te.wsEndpoint?{wsEndpoint:te.wsEndpoint,instance:null,tempDir:null}:te.cdpEndpoint?{cdpEndpoint:te.cdpEndpoint,instance:null,tempDir:null}:{instance:null,tempDir:null};if(d===0){let ue={mode:C.mode,max_steps:te.maxSteps,timeout:te.timeout>0?te.timeout:void 0,target:De?"chrome":te.cdpEndpoint?"cdp":te.wsEndpoint?"ws":void 0,chrome_profile:C.chrome_profile_path||void 0,cdp_endpoint:te.cdpEndpoint||void 0,ws_endpoint:te.wsEndpoint||void 0,headless:te.headless,global_context:ze??void 0,local_context:Mt??void 0,variables:Object.keys(s.auteur).length>0?s.auteur:void 0};a.setResolvedGlobal(ue)}let Vt=zo(s.auteur,s.auteurObjective),An=Wo({objective:s.auteurObjective,url:l,model:C.model,chrome:rn,auth:F,sessionId:a.sessionId,runIndex:d,windowSize:C.window_size,maxSteps:te.maxSteps,headless:te.headless,variables:Object.keys(Vt).length>0?Vt:void 0,globalContext:ze??void 0,localContext:Mt??void 0,sessionContext:a.getContext()});l&&E(l),Ye(null),B.startRun(An,{environment:ne,mode:C.mode,log:(ue,Xe,Ke,nt)=>a.log(ue,Xe,Ke,nt)}),Re(ue=>ue+1)},[g,Cn,u,C,a,ne,B,ae,te,oo,Et]),Fs=(0,T.useCallback)(async c=>{let l=Da(c),s=No(l),d=new Ln,y=g.getResolvedBasicAuth(),P=null;y||(P=await g.getToken());let L={basicAuth:y??null,token:P,resolver:g.getResolver(),resolvedCreds:null},F=ne,G=Le(F),Y=g.creds.getActiveProfile()??"default";return{path:l,cwd:process.cwd(),opts:{},isAgent:!1,resolved:s,resolvedAuth:L,cliOverrides:{},environment:F,envConfig:G,profile:Y,model:"v16-alpha",creds:g.creds,configStore:u,session:d,skipGlobalRemoteLogger:!0}},[g,u,ne]),re=Vi({buildInput:Fs,remoteLogger:null}),lr=(0,T.useRef)(null);(0,T.useEffect)(()=>{if(B.bifurcationInfo&&B.bifurcationInfo!==lr.current){lr.current=B.bifurcationInfo;let{flows:c,isSingleFlow:l}=B.bifurcationInfo;if(l&&c.length===1&&c[0])a.log("info","OBJECTIVE_REWRITTEN","Objective rewritten",{objective:c[0]}),ae({type:"info",text:`Objective: ${c[0]}`});else if(!l&&c.length>1){let s=[`Bifurcated into ${c.length} flows:`];c.forEach((d,y)=>s.push(` ${y+1}. ${d}`)),a.log("info","BIFURCATION","Objective bifurcated into flows",{flow_count:c.length}),ae({type:"info",text:s.join(`
|
|
10
|
-
`)})}}},[B.bifurcationInfo,a,ae]);let ur=T.default.useRef(null),dr=T.default.useRef(0),mr=T.default.useRef(0);(0,T.useEffect)(()=>{if(B.lastRunEnd&&B.lastRunEnd!==ur.current){ur.current=B.lastRunEnd;let{status:c,duration:l,summary:s,reason:d,context:y}=B.lastRunEnd,{passed:P,failed:L,total:F}=Lo(B.steps);dr.current+=F,mr.current+=l??0,Ye({status:c,duration:l??0,summary:s??"",stepsPassed:P,stepsFailed:L,stepsTotal:F,reason:d,finalState:B.lastRunEnd?.final_state,creditsConsumed:B.lastRunEnd?.credits_consumed}),a.logRunEnd(Ae.current,c,l,s);let G=B.bifurcationInfo,Y=G&&!G.isSingleFlow?G.flows:null,ce=So(B.lastRunEnd,Ae.current,Y),De=wo(B.lastRunEnd,It.current,Ae.current,ce);a.addRunResult(De,B.lastRunEnd?.total_runs);let yt=B.lastRunEnd?.per_flow_metadata;if(G&&!G.isSingleFlow&&yt&&yt.length>1)for(let ze=0;ze<yt.length;ze++){let Mt=yt[ze],rn=B.steps[ze],Vt=rn?.children??[],An=Vt.filter(Bt=>Bt.status==="passed").length,ue=Vt.filter(Bt=>Bt.status==="failed").length,Xe=Vt.reduce((Bt,vr)=>Bt+(vr.duration??0),0),Ke=rn?.status==="failed"?"failed":"passed",nt=G.flows[ze]??rn?.objective??It.current;a.addFlow({runIndex:Ae.current,flowId:G.flows[ze],objective:nt,status:Ke,summary:Mt.summary??"",duration:Xe,steps:An+ue,stepsPassed:An,stepsFailed:ue,reason:Mt.error_message??void 0,creditsConsumed:Mt.credits_consumed??void 0})}else a.addFlow({runIndex:Ae.current,objective:It.current,status:c,summary:s??"",duration:l??0,steps:F,stepsPassed:P,stepsFailed:L,reason:d,creditsConsumed:B.lastRunEnd?.credits_consumed})}},[B.lastRunEnd,a,ae]);let fr=(0,T.useRef)(null);(0,T.useEffect)(()=>{B.askingUser&&(fr.current=B.askingUser)},[B.askingUser]);let pr=(0,T.useRef)(null);(0,T.useEffect)(()=>{if(se&&!B.isRunning&&B.lastRunEnd){if(pr.current===B.lastRunEnd)return;pr.current=B.lastRunEnd,oe((0,b.jsxs)(f,{flexDirection:"column",children:[(0,b.jsx)(ys,{status:se.status,steps:se.stepsTotal,duration:se.duration,creditsConsumed:se.creditsConsumed,reason:se.reason}),(0,b.jsx)(Ts,{})]})),Ye(null)}},[se,B.isRunning,B.lastRunEnd,oe]);let so=(0,T.useRef)(null);(0,T.useEffect)(()=>{if(re.runSummary&&!re.running){if(so.current===re.runSummary)return;so.current=re.runSummary,(re.summary||re.links)&&oe((0,b.jsxs)(f,{flexDirection:"column",children:[re.summary&&(0,b.jsx)(qo,{data:re.summary}),re.links&&(0,b.jsx)(Mn,{...re.links,autoExit:!1})]}))}},[re.runSummary,re.running,re.summary,re.links,oe]),(0,T.useEffect)(()=>{yn.current?.setRunActive(B.isRunning)},[B.isRunning]),(0,T.useEffect)(()=>{if(B.runError&&!B.isRunning){let c=B.runError.trim();a.log("error","RUNNER_ERROR","Runner error occurred",{error:c}),a.escalateRun(a.nextRunIndex()-1);let s=c.split(`
|
|
11
|
-
`).slice(-8).join(`
|
|
12
|
-
`);ae({type:"error",text:`Runner error:
|
|
13
|
-
${s}`})}},[B.runError,B.isRunning,ae,a]);let In=(0,T.useCallback)(async()=>{a.log("info","EXIT_UPLOAD_START","Starting exit upload pipeline"),Kt(jn()),Dt({status:"uploading"});let c=g.getResolvedBasicAuth(),l=null;if(!c&&(l=await g.getToken(),!l))return a.log("warn","EXIT_UPLOAD_ABORTED","Exit upload aborted \u2014 no auth available"),null;let s=Ne??await Et();if(!s)return a.log("warn","EXIT_UPLOAD_ABORTED","Exit upload aborted \u2014 no TMS credentials"),a.setUploadStatus("failed","Could not get TMS credentials"),null;a.log("info","EXIT_UPLOAD_CONFIG","Exit upload configuration",{test_id:a.testId,commit_id:a.sessionId,project_id:C.project_id,session_dir:a.sessionDir,run_dirs:a.getRunDirs()});let d={basicAuth:c??null,token:l,resolver:g.getResolver(),resolvedCreds:s};lt.current&&(a.log("info","SCREENSHOT_UPLOAD_DRAIN","Draining screenshot queue before pipeline"),await lt.current.drain(),a.log("info","SCREENSHOT_UPLOAD_DRAINED","Screenshot queue drained"));let y=Jo({session:a,env:ne,auth:d,variables:le.current??{raw:{},auteur:{},auteurObjective:"",secretEntries:[],nonSecretEntries:[]},variableIds:Lt.current,projectId:C.project_id,folderId:C.folder_id,totalSteps:dr.current,totalDuration:mr.current,screenshotExtMap:lt.current?.getExtMap(),codeExport:Yo({codeExport:n,codeLanguage:o,skipCodeValidation:i},C.code_export),onProgress:(F,G,Y)=>{a.log("info","EXIT_PROGRESS","Upload progress",{step:F,status:G,detail:Y}),Kt(ce=>Go(ce,F,G,Y))},log:(F,G,Y,ce)=>a.log(F,G,Y,ce),shouldUploadArtifacts:!0,shouldReplaceLocalOutput:!1,shouldCommit:!1,isFirstRun:!0}),L=await new Zo(y).execute();if(L.success){a.log("info","EXIT_UPLOAD_OK","Exit upload succeeded",{test_id:L.testId,testcase_id:L.testcaseId??null,share_id:L.shareId??null}),a.setUploadStatus("uploaded"),L.testId&&a.setTestId(L.testId),L.testcaseId&&a.setTestcaseId(L.testcaseId);let F=Le(ne),G=C.project_id,Y=L.testcaseId&&L.shareId&&G?Rr(F.testManagerUiUrl,G,L.testcaseId,L.shareId):void 0,ce=L.testcaseId&&G?Cr(F.testManagerUiUrl,G,L.testcaseId):void 0;Dt({status:"success",testUrl:Y,testCaseLink:ce,codeExportDir:L.codeExportDir}),bs({shareableLink:Y,testCaseLink:ce,codeExportDir:L.codeExportDir})}else a.log("error","EXIT_UPLOAD_FAILED","Exit upload failed",{error:L.error}),a.setUploadStatus("failed",L.error),Dt({status:"failed",error:L.error});return L},[g,ne,a,C,Ne,Et]),En=(0,T.useCallback)(async()=>{a.log("info","SESSION_RESET_START","Starting session reset via /new"),W(!0);let c=a.getFlows();c.length>0&&oe((0,b.jsx)(Ur,{flows:c}));let l=null;if(!e)try{l=await In()??null}catch(y){a.log("error","SESSION_RESET_UPLOAD_FAILED","Upload failed during /new",{error:String(y)}),ae({type:"error",text:"Upload failed \u2014 session data saved locally."})}let s=null;try{let{persistRecordedSession:y}=await import("./persist-recorded-session-VEFILVPX.js");s=y(a,{testcaseId:a.testcaseId??void 0,projectId:C.project_id??void 0,folderId:C.folder_id??void 0,codeExportDir:l?.codeExportDir})}catch(y){a.log("error","SESSION_RESET_PERSIST_FAILED","Persist failed during /new",{error:String(y)})}if(l?.success&&l.testcaseId||s){let y=Le(ne),P=C.project_id,L=l?.testcaseId;oe((0,b.jsx)(Mn,{recordedTestPath:s?.recordedTestPath,outputDir:s?.outputDir,shareableLink:L&&l?.shareId&&P?Rr(y.testManagerUiUrl,P,L,l.shareId):void 0,testCaseLink:L&&P?Cr(y.testManagerUiUrl,P,L):void 0,codeExportDir:l?.codeExportDir,autoExit:!1}))}a.testId&&xn(y=>[...y,{testId:a.testId,runCount:K}]),Cn.killChrome(),await a.finish("complete");let d=new Ln;d.start({model:C.model,environment:ne,profile:jt??null}),M.current=d,_(y=>y+1),a.log("info","SESSION_RESET_COMPLETE","Session reset complete",{new_session_id:d.sessionId}),await ot({kind:"resessionize",env:ne},Ue),Re(0),dr.current=0,mr.current=0,Ae.current=0,It.current="",le.current=null,Lt.current={},Bn.current=0,hr.current=0,fr.current=null,pr.current=null,ur.current=null,lr.current=null,Ye(null),E(null),Dt(null),Kt(jn()),W(!1),oe((0,b.jsxs)(f,{flexDirection:"column",marginY:1,children:[(0,b.jsx)(t,{color:r.dim,children:"\u2500".repeat(44)}),(0,b.jsx)(t,{color:r.green,bold:!0,children:"New session started"})]}))},[a,ae,oe,e,In,Cn,K,C,ne,jt,Ue]),ao=(0,T.useCallback)(async()=>{if(!(a.nextRunIndex()>0)){ae({type:"info",text:"No runs in current session."});return}if(B.isRunning){ae({type:"error",text:"Cannot reset while a run is in progress. Cancel the run first."});return}if(C.mode==="testing"&&!a.sessionName){Ze("new"),Be(Er());return}await En()},[a,B,ae,C.mode,En]),co=(0,T.useCallback)(async()=>{await a.finish("complete"),Gt(0,"Session complete")},[a]),Ns=(0,T.useCallback)(async c=>{me(!1);let l=a.testId??(Me.length>0?Me[Me.length-1].testId:null);if(c&&l){a.log("info","EXIT_FEEDBACK_SUBMIT","Submitting session feedback",{choice:c});try{let s=Le(ne),d=g.getResolvedBasicAuth();d&&await Rs({tmsBaseUrl:s.tmsBaseUrl,username:d.username,accessKey:d.access_key,testId:l,feedbackType:c,log:(y,P,L,F)=>a.log(y,P,L,F)})}catch(s){a.log("error","EXIT_FEEDBACK_FAILED","Feedback submission failed",{error:String(s)})}}else a.log("info","EXIT_FEEDBACK_SKIPPED","Feedback skipped");co()},[ne,g,a,co,Me]),_n=(0,T.useCallback)(async()=>{let c=a.nextRunIndex()>0,l=null;if(c&&!e){a.log("info","EXIT_WITH_ACTIVE_SESSION","Exit with active session \u2014 uploading first"),de(!0);try{l=await In()??null}catch(d){a.log("error","EXIT_UPLOAD_FAILED","Exit upload failed",{error:String(d)})}a.testId&&xn(d=>[...d,{testId:a.testId,runCount:K}])}try{let{persistRecordedSession:d}=await import("./persist-recorded-session-VEFILVPX.js"),y=d(a,{testcaseId:a.testcaseId??void 0,projectId:C.project_id??void 0,folderId:C.folder_id??void 0,codeExportDir:l?.codeExportDir});y&&vt(y)}catch(d){a.log("error","EXIT_PERSIST_FAILED","Persist failed during /exit",{error:String(d)})}if(c&&!e&&await a.finish("complete"),!(a.testId??(Me.length>0?Me[Me.length-1].testId:null))||e){await a.finish("complete"),Gt(0,"No test ID \u2014 quick exit");return}de(!0),me(!0)},[a,e,In,K,Me,C]),_t=(0,T.useCallback)(async()=>{if(H)return;a.log("info","EXIT_START","TUI exit initiated");let c=C.mode==="testing",l=a.nextRunIndex()>0;if(c&&l&&!a.sessionName){Ze("exit"),Be(Er());return}await _n()},[H,a,C.mode,_n]),Us=(0,T.useCallback)(c=>{c&&a.setSessionName(c);let l=ge;Be(null),Ze(null),l==="new"?En():_n()},[a,ge,_n,En]);(0,T.useEffect)(()=>{if(!H)return;let c=300*1e3,l=setTimeout(async()=>{a.setUploadStatus("failed","Upload timed out after 5m"),await a.finish("complete"),Gt(0,"Upload timed out after 5m")},c);return()=>clearTimeout(l)},[H,a]);let Bn=T.default.useRef(0),gr=T.default.useRef(null),hr=T.default.useRef(0);Ce((c,l)=>{if(l.ctrl&&c==="c"){if(pe==="generate"&&z.isStreaming){ut(),z.cancel();return}if(!re.running){if(H){hr.current+=1,hr.current>=2&&(a.setUploadStatus("pending","Force exit by user"),a.finish("complete"),Gt(0,"Force exit by user"));return}if(B.isRunning){B.cancelRun(),ae({type:"info",text:"Run cancelled."}),Bn.current++,gr.current&&clearTimeout(gr.current),gr.current=setTimeout(()=>{Bn.current=0},2e3),Bn.current>=2&&_t();return}_t()}}}),Ce((c,l)=>{if(l.ctrl&&c==="t"&&pe==="generate"&&!z.isStreaming){kn("no thinking yet");return}});let lo=T.default.useMemo(()=>{let c=g.creds.getActiveProfile()??"none",l=g.creds.getDefaultEnv();return[{id:"run",label:"Run",type:"submenu",children:[{id:"run-start",label:"Start Run",type:"action"},{id:"run-config",label:"Run Config",type:"submenu",children:[{id:"run-headless",label:"Headless",type:"select",currentValue:te.headless?"on":"off",options:[{label:"off",value:"off"},{label:"on",value:"on"}],onValue:s=>{nn(d=>({...d,headless:s==="on"}))}},{id:"run-max-steps",label:"Max Steps",type:"text-input",currentValue:String(te.maxSteps),onValue:s=>{let d=parseInt(s,10);d>0&&nn(y=>({...y,maxSteps:d}))}},{id:"run-timeout",label:"Timeout (sec)",type:"text-input",currentValue:te.timeout?String(te.timeout):"",placeholder:"0 = no timeout",onValue:s=>{let d=parseInt(s,10);nn(y=>({...y,timeout:isNaN(d)?0:d}))}},{id:"run-cdp",label:"CDP Endpoint",type:"text-input",currentValue:te.cdpEndpoint,placeholder:"http://127.0.0.1:9222",onValue:s=>{nn(d=>({...d,cdpEndpoint:s}))}},{id:"run-ws",label:"WS Endpoint",type:"text-input",currentValue:te.wsEndpoint,placeholder:"wss://...",onValue:s=>{nn(d=>({...d,wsEndpoint:s}))}}]}]},{id:"auth",label:"Auth",type:"submenu",children:[{id:"login",label:"Login",type:"action",onLoginWizard:()=>{}},{id:"logout",label:"Logout",type:"action",onAction:()=>{g.logout().then(s=>{Pe();let d=g.creds.getActiveProfile(),y=g.creds.getDefaultEnv();We(d,y);let P=ws(d,y);ot(P,Ue).catch(()=>{}),s?A("ok","/logout",`Logged out: ${s.profile} [${s.env}]`):A("ok","/logout","No active profile")}).catch(()=>{A("error","/logout","Logout failed")})}},{id:"whoami",label:"Who Am I",type:"action",onInfo:()=>{let s=g.creds.getActiveProfile()??"none",d=g.creds.getDefaultEnv(),y=g.creds.loadBasicAuth(s,d),P=y?"basic":g.creds.loadCredentials(s,d)?"oauth":"not configured";return{title:"Who Am I",sections:[{label:"Identity",entries:[{key:"Profile",value:s},{key:"Environment",value:d}]},{label:"Authentication",entries:[{key:"Method",value:P},...y?[{key:"Username",value:y.username}]:[]]},{label:"Token",entries:[{key:"Status",value:g.tokenValid?"valid":"not logged in",color:g.tokenValid?r.green:r.red}]}]}}},{id:"balance",label:"Credit Balance",type:"action",suppressFeedback:!0,onAction:()=>{(async()=>{let s=g.creds.getActiveProfile()??"default",d=g.creds.getDefaultEnv(),y=Le(d);try{let P=g.getBasicAuth(),L=P?null:await g.getToken();if(!P&&!L){Qe({text:"Not authenticated. Run /login first.",color:r.red});return}let{ControllerClient:F}=await import("./controller-client-RD2YEMAH.js"),Y=await(P?new F(y.controllerBaseUrl,{username:P.username,accessKey:P.access_key}):new F(y.controllerBaseUrl,L)).getCreditBalance();Qe({text:`Credits \u2014 available: ${Y.available_credits}, total: ${Y.total_credits} (${s} / ${d})`,color:r.green})}catch(P){Qe({text:`Balance check failed: ${P instanceof Error?P.message:String(P)}`,color:r.red})}Ct.current&&clearTimeout(Ct.current),Ct.current=setTimeout(()=>{Qe(null),Ct.current=null},5e3)})()}},{id:"profiles",label:"Profiles",type:"action",onProfilesView:()=>{}}]},{id:"config",label:"Config",type:"submenu",children:[{id:"config-show",label:"Show",type:"action",onInfo:()=>({title:"Show Config",sections:[{label:"General",entries:[{key:"Model",value:"v16-alpha"},{key:"Mode",value:C.mode}]},{label:"Browser",entries:[{key:"Window",value:`${C.window_size.width}x${C.window_size.height}`},{key:"Chrome Profile",value:C.chrome_profile_path?C.chrome_profile_path.split("/").pop()??C.chrome_profile_path:"(temporary)"}]},{label:"Project",entries:[{key:"Project",value:C.project_name?`${C.project_name} (${C.project_id})`:C.project_id??"(none)"},{key:"Folder",value:C.folder_name?`${C.folder_name} (${C.folder_id})`:C.folder_id??"(none)"},{key:"Default URL",value:sn}]},{label:"Code Export",entries:[{key:"Enabled",value:C.code_export.enabled?"yes":"no"},{key:"Language",value:C.code_export.language},{key:"Skip Validation",value:C.code_export.skip_validation?"yes":"no"}]}]})},{id:"config-chrome",label:"Chrome Profile",type:"action",onChromeProfilePicker:()=>{}},{id:"config-project",label:"Project",type:"action",onProjectPicker:()=>{}},{id:"config-folder",label:"Folder",type:"action",...C.project_id?{onFolderPicker:()=>{}}:{onInfo:()=>({title:"Folder",sections:[{entries:[{key:"Status",value:"Select a project first",color:r.dim}]}]})}},{id:"config-window",label:"Window Size",type:"action",currentValue:`${C.window_size.width}x${C.window_size.height}`,onWindowSizePicker:()=>{}},{id:"config-mode",label:"Mode",type:"select",currentValue:C.mode,options:[{label:"testing",value:"testing"},{label:"action",value:"action"}],onValue:s=>{(s==="action"||s==="testing")&&(u.set("mode",s),be(u.load()),A("ok","/config set-mode",s))}},{id:"config-generate",label:"Generate",type:"submenu",currentValue:`${C.generate.scenario_limit}x${C.generate.per_scenario_limit}`,children:[{id:"config-generate-scenario-limit",label:"Scenario limit",type:"text-input",currentValue:String(C.generate.scenario_limit),placeholder:"5",onValue:s=>{let d=parseInt(s,10);if(!Number.isFinite(d)||d<1||d>20){A("error","/config",`Scenario limit must be 1-20 (got ${s})`);return}u.set("generate",{...C.generate,scenario_limit:d}),be(u.load()),A("ok","/config",`Scenario limit: ${d}`)}},{id:"config-generate-per-scenario-limit",label:"Per-scenario limit",type:"text-input",currentValue:String(C.generate.per_scenario_limit),placeholder:"4",onValue:s=>{let d=parseInt(s,10);if(!Number.isFinite(d)||d<1||d>20){A("error","/config",`Per-scenario limit must be 1-20 (got ${s})`);return}u.set("generate",{...C.generate,per_scenario_limit:d}),be(u.load()),A("ok","/config",`Per-scenario limit: ${d}`)}},{id:"config-generate-memory",label:"Memory",type:"select",currentValue:C.generate.memory_enabled?"on":"off",options:[{label:"on",value:"on"},{label:"off",value:"off"}],onValue:s=>{let d=s==="on";u.set("generate",{...C.generate,memory_enabled:d}),be(u.load()),A("ok","/config",`Memory: ${d?"on":"off"}`)}}]},{id:"config-code-export",label:"Code Export",type:"submenu",currentValue:C.code_export.enabled?"enabled":"disabled",children:[{id:"config-code-export-enabled",label:"Enabled",type:"select",currentValue:C.code_export.enabled?"on":"off",options:[{label:"off",value:"off"},{label:"on",value:"on"}],onValue:s=>{u.set("code_export",{...C.code_export,enabled:s==="on"}),be(u.load()),A("ok","/config code-export enabled",s)}},{id:"config-code-export-language",label:"Language",type:"select",currentValue:C.code_export.language,options:[{label:"python",value:"python"},{label:"javascript",value:"javascript"}],onValue:s=>{s!=="python"&&s!=="javascript"||(u.set("code_export",{...C.code_export,language:s}),be(u.load()),A("ok","/config code-export language",s))}},{id:"config-code-export-skip-validation",label:"Skip Validation",type:"select",currentValue:C.code_export.skip_validation?"on":"off",options:[{label:"off",value:"off"},{label:"on",value:"on"}],onValue:s=>{u.set("code_export",{...C.code_export,skip_validation:s==="on"}),be(u.load()),A("ok","/config code-export skip-validation",s)}}]}]},{id:"exit",label:"Exit",type:"action",onAction:()=>{_t()}}]},[g,u,C,ae,_t,te,Pe,A]),xr=(0,T.useCallback)(c=>{if(B.askingUser){let s=B.askingUser;oe((0,b.jsxs)(f,{flexDirection:"column",marginLeft:2,paddingLeft:1,marginTop:1,children:[(0,b.jsx)(f,{marginLeft:1,children:(0,b.jsx)(t,{color:r.orange,bold:!0,children:"Agent Question"})}),(0,b.jsxs)(f,{borderStyle:"round",borderColor:r.orange,flexDirection:"column",paddingX:2,paddingY:1,width:70,children:[(0,b.jsxs)(f,{children:[(0,b.jsx)(f,{width:3,children:(0,b.jsx)(t,{color:r.orange,bold:!0,children:"?"})}),(0,b.jsx)(f,{flexShrink:1,children:(0,b.jsx)(t,{wrap:"wrap",children:s})})]}),(0,b.jsxs)(f,{marginTop:1,children:[(0,b.jsx)(f,{width:3,children:(0,b.jsx)(t,{color:r.dim,bold:!0,children:"\u2192"})}),(0,b.jsx)(f,{flexShrink:1,children:(0,b.jsx)(t,{wrap:"wrap",children:c})})]})]})]})),fr.current=null,B.sendAnswer(c);return}if(a.logCommand(c),B.isRunning){ae({type:"error",text:"Run in progress. Ctrl+C to cancel."});return}let l=Un(c);if(l){if(!_i(l.command,pe)){A("error",`/${l.command}`,`/${l.command} isn't available in ${pe==="run"?"Run":"Generate"} mode.`);return}switch(l.command){case"profiles":if(pe==="generate"&&z.requestId&&l.args.action==="switch"){tn({reason:"profile",pendingArgs:l.args});return}Qt("auth");return;case"login":case"logout":case"whoami":case"balance":case"auth":Qt("auth");return;case"config":Qt("config");return;case"help":Zr(!0);return;case"testmd":if(B.isRunning||z.isStreaming||re.running){A("error","/testmd","Finish or cancel the current run/generation first.");return}re.clearResult(),wn(!0);return;case"generate":if(re.running){A("error","/generate","Finish or cancel the running test first.");return}pe==="run"?dt.requestSwitch("generate")&&A("ok","/generate","Switched to Generate mode.",void 0,r.generateAccent):A("ok","/generate","Already in Generate mode.",void 0,r.generateAccent);return;case"run":{let s=Bi(pe,l.args.objective);switch(s.kind){case"run":cr(s.objective,sn);return;case"reject":A("error","/run",'Switch to Run mode first (bare /run), then /run "objective".');return;case"already":A("ok","/run","Already in Run mode.",void 0,r.orange);return;case"toggle":dt.requestSwitch("run")&&A("ok","/run","Switched to Run mode.",void 0,r.orange);return}return}case"update":{(async()=>{let{getUpdateCommand:s}=await import("./version-check-LNKXGYZE.js");A("ok","/update",`To update kane-cli, run: ${s()}`)})();return}case"summary":{if(pe==="generate"&&!z.requestId){kn("no generation yet"),A("ok","/summary","(no generation yet)");return}let s=a.getFlows();if(s.length===0){A("ok","/summary","No runs yet in this session.");return}let d=l.args.index?parseInt(l.args.index,10):void 0;if(d!==void 0&&!a.getFlow(d)){A("error","/summary",`No flow at index ${d}`,`${s.length} flow${s.length===1?"":"s"} available. Use /summary to see all.`);return}oe((0,b.jsx)(Ur,{flows:s,filterIndex:d})),A("ok","/summary",d!==void 0?`Flow ${d}`:`${s.length} flow${s.length===1?"":"s"}`);return}case"new":pe==="generate"&&z.requestId&&(ut(),z.end().catch(s=>{A("error","/new",`Could not end generation cleanly: ${s.message}`)}),z.reset()),ao(),A("ok","/new","Session reset");return;case"name":{let s=l.raw.replace(/^\/name\s*/,"").trim();if(!s){A("error","/name","Usage: /name <new-name>");return}(async()=>{let{validateNameOrThrow:d}=await import("./name-validator-5YGJXLZ7.js");try{d(s),a.setSessionName(s),A("ok","/name",`Session name set: ${s}`)}catch(y){A("error","/name",y.message)}})();return}case"cancel":if(pe==="generate"&&z.isStreaming){ut(),z.cancel(),A("ok","/cancel","Cancelled");return}if(pe==="generate"&&!z.requestId){kn("no generation yet"),A("ok","/cancel","(no generation yet)");return}if(re.running){re.cancel(),A("ok","/cancel","Run cancelled");return}B.cancelRun(),A("ok","/cancel","Run cancelled");return;case"clear":A("ok","/clear","Chat cleared");return;case"exit":pe==="generate"&&z.requestId&&(ut(),z.end()),_t();return;default:A("error",`/${l.command}`,"Unknown command");return}}if(c.trim().toLowerCase()==="exit"){_t();return}oe((0,b.jsxs)(f,{children:[(0,b.jsx)(t,{color:r.orange,children:"\u276F "}),(0,b.jsx)(t,{children:c})]})),cr(c,sn)},[B,ae,A,oe,a,cr,_t,ao,pe,z.isStreaming,z.requestId,z,kn,ut,re]);io.current=xr;let uo=(0,T.useRef)(!1);(0,T.useEffect)(()=>{if(!uo.current&&O&&h==="generate"&&v){uo.current=!0;let c=setTimeout(()=>{$s(v)},50);return()=>clearTimeout(c)}},[O,h,v]);let mo=g.getAuthInfo(),Gs=mo?mo.method==="basic"?"basic auth":"oauth":"not logged in",qs=(()=>{if(Zt)return["help"];if(en)return["testmd"];if(I)return I.phase==="wizard"?["auth","login"]:I.phase==="project"?["auth","login","project"]:I.phase==="folder"?["auth","login","folder"]:["auth","login"];let c={infoView:"info",loginWizard:"login",profilesView:"profiles",chromeProfilePicker:"chrome-profile",projectPicker:"project",folderPicker:"folder",windowSizePicker:"set-window"};return tt==="auth"?Sn?["auth",c[Sn]]:["auth"]:tt==="config"?Sn?["config",c[Sn]]:["config"]:tt==="help"?["help"]:B.askingUser?["agent question"]:[]})();return(0,b.jsxs)(f,{flexDirection:"column",children:[Jr.length>0&&(0,b.jsx)(fo,{items:Jr,children:c=>(0,b.jsx)(f,{paddingX:1,children:c.content},c.id)}),!O&&!Yr&&(0,b.jsx)(yi,{onComplete:()=>{let c=g.creds.getActiveProfile(),l=g.creds.getDefaultEnv(),s=c?g.creds.loadCredentials(c,l):null,d=c?g.creds.loadBasicAuth(c,l):null,y=!!(s||d),P=d?.username??c??null;oe((0,b.jsx)(Fn,{size:"full",helmetVisibleRows:8,textVisibleRows:7,showMeta:!0,version:on,authenticated:y,user:P})),Bs(!0);let L=(F,G,Y,ce)=>{a.log(F,G,Y,ce)};if(Mo(g.creds,L).then(F=>{if(F.status==="authenticated"){let{profile:G,env:Y,tmsCreds:ce}=F.result;g.creds.setActiveProfile(G),g.creds.setDefaultEnv(Y),Pe(),kt(ce),et("ready"),$(!0)}else F.status==="needs_pick"?(Es(F.profiles),et("pick")):et("login")}).catch(F=>{a.log("error","STARTUP_GATE_ERROR","Auth gate failed",{error:String(F)}),et("login")}),p&&p.then(async F=>{if(F){let{getUpdateCommand:G}=await import("./version-check-LNKXGYZE.js");A("ok","update available",`${F.current} \u2192 ${F.latest}`,`Run: ${G()}`)}}).catch(()=>{}),m&&m.changes.length>0){let F=`kane-cli updated to ${m.toVersion}. Default settings changed:`,G=[...m.changes.map(Y=>`\u2022 ${Y.description} (${Y.field}: ${JSON.stringify(Y.from)} \u2192 ${JSON.stringify(Y.to)})`),"","Use /config to review or revert any of these."].join(`
|
|
14
|
-
`);A("ok","defaults updated",F,G)}}}),!O&&Yt==="booting"&&Yr&&(0,b.jsx)(f,{paddingX:1,children:(0,b.jsx)(t,{color:"yellow",children:"Checking authentication..."})}),!O&&Yt==="pick"&&(0,b.jsx)(La,{profiles:Is,onCancel:()=>et("login"),onSelect:async(c,l)=>{g.creds.setActiveProfile(c),g.creds.setDefaultEnv(l),Pe(),or(!0);let s=(d,y,P,L)=>{a.log(d,y,P,L)};try{let d=await jo(g.creds,c,l,s);or(!1),d.status==="authenticated"?(We(c,l),kt(d.result.tmsCreds),et("ready"),$(!0)):et("login")}catch{or(!1),et("login")}},validating:_s}),!O&&Yt==="login"&&!I&&(0,b.jsx)(Dn,{devMode:process.env.KANE_DEV_MODE==="1",profiles:g.creds.listProfiles(),onBasicLogin:async(c,l,s,d)=>{let{validateBasicAuth:y}=await import("./validate-basic-Y73NBDAD.js");await y(l,s,d),g.creds.saveBasicAuth(c,l,{username:s,access_key:d}),g.creds.setActiveProfile(c),g.creds.setDefaultEnv(l),Ge(g.creds,u,c,l),g.setTokenValid(!0),Pe()},onOAuthLogin:async(c,l)=>{g.creds.setDefaultEnv(l),await g.login(c),Ge(g.creds,u,c,l),Pe()},onComplete:(c,l)=>{ot(nr(l),Ue).then(()=>{Pe(),fe({phase:"project",profile:c,env:l})}).catch(()=>{fe({phase:"project",profile:c,env:l})})},onCancel:()=>{Gt(0,"Login cancelled at startup")}}),!O&&Yt==="login"&&I?.phase==="project"&&(0,b.jsx)(Ft,{resolver:g.getResolver(),currentProjectId:null,env:I.env,onSelect:(c,l)=>{g.creds.saveProfileConfig(I.profile,I.env,{project_id:c,project_name:l}),A("ok","/config project",l,`id: ${c}`),fe({...I,phase:"folder"})},onCancel:async()=>{let c=await sr(I.profile,I.env);c&&(Oe(g.creds,u,I.profile,I.env,{projectId:c.id,projectName:c.name}),A("ok","/config project",c.name,`id: ${c.id}`),fe({...I,phase:"folder"}))}}),!O&&Yt==="login"&&I?.phase==="folder"&&(0,b.jsx)(Nt,{resolver:g.getResolver(),projectId:g.creds.loadProfileConfig(I.profile,I.env)?.project_id??"",currentFolderId:null,env:I.env,onSelect:(c,l)=>{g.creds.saveProfileConfig(I.profile,I.env,{folder_id:c,folder_name:l}),A("ok","/config folder",l,`id: ${c}`),We(I.profile,I.env),fe(null),et("ready"),$(!0)},onCancel:async()=>{let c=g.creds.loadProfileConfig(I.profile,I.env);if(!c?.project_id)return;let l=await ar(I.env,c.project_id);l&&(Oe(g.creds,u,I.profile,I.env,{folderId:l.id,folderName:l.name}),A("ok","/config folder",l.name,`id: ${l.id}`),We(I.profile,I.env),fe(null),et("ready"),$(!0))}}),O&&Tn==="menu"&&!H&&(0,b.jsx)(f,{marginBottom:1,children:(0,b.jsxs)(f,{borderStyle:"round",borderColor:"#dc4e08",paddingX:2,children:[(0,b.jsx)(t,{color:"#ff9500",bold:!0,children:"KaneAI CLI"}),(0,b.jsx)(t,{color:r.dim,children:" \u2502 "}),(0,b.jsx)(t,{color:"#ff9500",children:C.model}),(0,b.jsx)(t,{color:r.dim,children:" \u2502 "}),(0,b.jsx)(t,{color:r.dim,children:Gs}),(0,b.jsx)(t,{color:r.dim,children:" \u2502 "}),(0,b.jsxs)(t,{color:r.dim,children:[jt??"no profile","/",ne]})]})}),O&&!H&&(0,b.jsxs)(f,{flexDirection:"column",flexGrow:1,children:[Tn==="menu"&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(Mr,{items:lo,onRunSelected:()=>As("chat"),onActiveViewChange:Qr,renderLoginWizard:c=>{let l=I?.phase??"wizard";if(l==="project")return(0,b.jsx)(Ft,{resolver:g.getResolver(),currentProjectId:null,env:I.env,onSelect:(s,d)=>{g.creds.saveProfileConfig(I.profile,I.env,{project_id:s,project_name:d}),A("ok","/config project",d,`id: ${s}`),fe(y=>y?{...y,phase:"folder"}:null)},onCancel:async()=>{if(!I)return;let s=await sr(I.profile,I.env);s&&(Oe(g.creds,u,I.profile,I.env,{projectId:s.id,projectName:s.name}),A("ok","/config project",s.name,`id: ${s.id}`),fe(d=>d?{...d,phase:"folder"}:null))}});if(l==="folder"){let s=g.creds.loadProfileConfig(I.profile,I.env);return(0,b.jsx)(Nt,{resolver:g.getResolver(),projectId:s?.project_id??"",currentFolderId:null,env:I.env,onSelect:(d,y)=>{g.creds.saveProfileConfig(I.profile,I.env,{folder_id:d,folder_name:y}),A("ok","/config folder",y,`id: ${d}`),We(I.profile,I.env),fe(null),c()},onCancel:async()=>{if(!I)return;let d=g.creds.loadProfileConfig(I.profile,I.env);if(!d?.project_id)return;let y=await ar(I.env,d.project_id);y&&(Oe(g.creds,u,I.profile,I.env,{folderId:y.id,folderName:y.name}),A("ok","/config folder",y.name,`id: ${y.id}`),We(I.profile,I.env),fe(null),c())}})}return(0,b.jsx)(Dn,{devMode:process.env.KANE_DEV_MODE==="1",profiles:g.creds.listProfiles(),onBasicLogin:async(s,d,y,P)=>{let{validateBasicAuth:L}=await import("./validate-basic-Y73NBDAD.js");await L(d,y,P),g.creds.saveBasicAuth(s,d,{username:y,access_key:P}),g.creds.setActiveProfile(s),g.creds.setDefaultEnv(d),Ge(g.creds,u,s,d),g.setTokenValid(!0),Pe()},onOAuthLogin:async(s,d)=>{g.creds.setDefaultEnv(d),await g.login(s),Ge(g.creds,u,s,d),Pe()},onComplete:(s,d)=>{ot(nr(d),Ue).then(()=>{fe({phase:"project",profile:s,env:d})}).catch(()=>{fe({phase:"project",profile:s,env:d})})},onCancel:()=>{fe(null),c()}})},renderProfilesView:c=>(0,b.jsx)(Tr,{creds:g.creds,onSwitch:(l,s)=>{let d=g.creds.getActiveProfile()??"(none)";g.creds.setActiveProfile(l),g.creds.setDefaultEnv(s),Ge(g.creds,u,l,s),We(l,s),Pe(),ot(Kr(s),Ue).catch(()=>{}),A("ok","/profiles switch",`${d} \u2192 ${l} [${s}]`)},onCancel:c}),renderChromeProfilePicker:c=>(0,b.jsx)(Sr,{currentPath:C.chrome_profile_path,onSelect:l=>{u.set("chrome_profile_path",l),be(u.load()),A("ok","/config chrome-profile",l),c()},onCancel:c}),renderProjectPicker:c=>(0,b.jsx)(Ft,{resolver:g.getResolver(),currentProjectId:C.project_id,env:ne,onSelect:(l,s)=>{Oe(g.creds,u,g.creds.getActiveProfile()??"default",g.creds.getDefaultEnv(),{projectId:l,projectName:s}),A("ok","/config project",s,`id: ${l}`),be(u.load()),c()},onCancel:c}),renderFolderPicker:c=>(0,b.jsx)(Nt,{resolver:g.getResolver(),projectId:C.project_id??"",currentFolderId:C.folder_id,env:ne,onSelect:(l,s)=>{Oe(g.creds,u,g.creds.getActiveProfile()??"default",g.creds.getDefaultEnv(),{folderId:l,folderName:s}),A("ok","/config folder",s,`id: ${l}`),be(u.load()),c()},onCancel:c}),renderWindowSizePicker:c=>(0,b.jsx)(Nr,{currentWidth:C.window_size.width,currentHeight:C.window_size.height,onSelect:(l,s)=>{u.set("window_size",{width:l,height:s}),be(u.load()),A("ok","/config set-window",`${l} \xD7 ${s}`),c()},onCancel:c})}),xt&&(0,b.jsx)(f,{paddingX:1,marginTop:1,children:(0,b.jsx)(t,{color:xt.color,children:xt.text})})]}),Tn==="chat"&&(0,b.jsxs)(b.Fragment,{children:[(()=>{let c=To({isRunning:B.isRunning,bifurcationInfo:B.bifurcationInfo,steps:B.steps,cmInitCounts:B.cmInitCounts,replayInfo:B.replayInfo});return c?(0,b.jsx)(yo,{label:c.label,hasBifurcation:c.hasBifurcation}):null})(),B.isRunning&&B.steps.length>0&&(0,b.jsx)(bo,{steps:B.steps,bifurcated:!!B.bifurcationInfo&&!B.bifurcationInfo.isSingleFlow,flows:B.bifurcationInfo?.flows,cmInitCounts:B.cmInitCounts,onStepCommit:oe},`run-${Ae.current}`),re.runViewProps&&(0,b.jsx)(Uo,{...re.runViewProps,onCancel:()=>{re.runViewProps?.onCancel?.(),re.cancel()}}),Zt&&(0,b.jsx)(Di,{onClose:()=>Zr(!1),version:on,environment:g.creds.getDefaultEnv(),sessionId:a.sessionId,runUrl:C.default_url??sn,mode:pe}),en&&(0,b.jsx)(Mi,{cwd:process.cwd(),currentOrgId:String(Ne?.org_id??""),onClose:()=>wn(!1),onRun:c=>{if(B.isRunning||z.isStreaming||re.running){setTimeout(()=>A("error","/testmd","Finish or cancel the current run first."),0);return}wn(!1),!(pe==="generate"&&!dt.requestSwitch("run"))&&(pe==="generate"&&setTimeout(()=>A("ok","/testmd",`Switched to Run mode to run ${c.relPath}`,void 0,r.orange),0),re.start(c.path).catch(l=>setTimeout(()=>A("error","/testmd",`Run failed: ${l.message}`),0)))},onExport:c=>{wn(!1),ti(c.path,{language:C.code_export.language??"python",env:ne}).then(l=>setTimeout(()=>A("ok","/testmd",`Exported code \u2192 ${l.codeDir}`),0)).catch(l=>setTimeout(()=>A("error","/testmd",`Export failed: ${l.message}`),0))}}),tt&&!B.isRunning&&(()=>{let c=lo.find(l=>l.id===tt);return c?.children?(0,b.jsx)(Mr,{items:c.children,onRunSelected:()=>Qt(null),onDismiss:()=>Qt(null),onActiveViewChange:Qr,renderLoginWizard:l=>{let s=I?.phase??"wizard";if(s==="project")return(0,b.jsx)(Ft,{resolver:g.getResolver(),currentProjectId:null,env:I.env,onSelect:(d,y)=>{g.creds.saveProfileConfig(I.profile,I.env,{project_id:d,project_name:y}),A("ok","/config project",y,`id: ${d}`),fe(P=>P?{...P,phase:"folder"}:null)},onCancel:async()=>{if(!I)return;let d=await sr(I.profile,I.env);d&&(Oe(g.creds,u,I.profile,I.env,{projectId:d.id,projectName:d.name}),A("ok","/config project",d.name,`id: ${d.id}`),fe(y=>y?{...y,phase:"folder"}:null))}});if(s==="folder"){let d=g.creds.loadProfileConfig(I.profile,I.env);return(0,b.jsx)(Nt,{resolver:g.getResolver(),projectId:d?.project_id??"",currentFolderId:null,env:I.env,onSelect:(y,P)=>{g.creds.saveProfileConfig(I.profile,I.env,{folder_id:y,folder_name:P}),A("ok","/config folder",P,`id: ${y}`),We(I.profile,I.env),fe(null),l()},onCancel:async()=>{if(!I)return;let y=g.creds.loadProfileConfig(I.profile,I.env);if(!y?.project_id)return;let P=await ar(I.env,y.project_id);P&&(Oe(g.creds,u,I.profile,I.env,{folderId:P.id,folderName:P.name}),A("ok","/config folder",P.name,`id: ${P.id}`),We(I.profile,I.env),fe(null),l())}})}return(0,b.jsx)(Dn,{devMode:process.env.KANE_DEV_MODE==="1",profiles:g.creds.listProfiles(),onBasicLogin:async(d,y,P,L)=>{let{validateBasicAuth:F}=await import("./validate-basic-Y73NBDAD.js");await F(y,P,L),g.creds.saveBasicAuth(d,y,{username:P,access_key:L}),g.creds.setActiveProfile(d),g.creds.setDefaultEnv(y),Ge(g.creds,u,d,y),g.setTokenValid(!0),Pe()},onOAuthLogin:async(d,y)=>{g.creds.setDefaultEnv(y),await g.login(d),Ge(g.creds,u,d,y),Pe()},onComplete:(d,y)=>{ot(nr(y),Ue).then(()=>{fe({phase:"project",profile:d,env:y})}).catch(()=>{fe({phase:"project",profile:d,env:y})})},onCancel:()=>{fe(null),l()}})},renderProfilesView:l=>(0,b.jsx)(Tr,{creds:g.creds,onSwitch:(s,d)=>{let y=g.creds.getActiveProfile()??"(none)";g.creds.setActiveProfile(s),g.creds.setDefaultEnv(d),Ge(g.creds,u,s,d),We(s,d),Pe(),ot(Kr(d),Ue).catch(()=>{}),A("ok","/profiles switch",`${y} \u2192 ${s} [${d}]`),l()},onCancel:l}),renderChromeProfilePicker:l=>(0,b.jsx)(Sr,{currentPath:C.chrome_profile_path,onSelect:s=>{u.save({chrome_profile_path:s}),be(u.load()),A("ok","/config chrome-profile",s),l()},onCancel:l}),renderProjectPicker:l=>(0,b.jsx)(Ft,{resolver:g.getResolver(),currentProjectId:C.project_id,env:ne,onSelect:(s,d)=>{Oe(g.creds,u,g.creds.getActiveProfile()??"default",g.creds.getDefaultEnv(),{projectId:s,projectName:d}),be(u.load()),A("ok","/config project",d,`id: ${s}`),l()},onCancel:l}),renderFolderPicker:l=>(0,b.jsx)(Nt,{resolver:g.getResolver(),projectId:C.project_id??"",currentFolderId:C.folder_id,env:ne,onSelect:(s,d)=>{Oe(g.creds,u,g.creds.getActiveProfile()??"default",g.creds.getDefaultEnv(),{folderId:s,folderName:d}),be(u.load()),A("ok","/config folder",d,`id: ${s}`),l()},onCancel:l}),renderWindowSizePicker:l=>(0,b.jsx)(Nr,{currentWidth:C.window_size.width,currentHeight:C.window_size.height,onSelect:(s,d)=>{u.set("window_size",{width:s,height:d}),be(u.load()),A("ok","/config set-window",`${s} \xD7 ${d}`),l()},onCancel:l})},tt):null})(),tt&&xt&&(0,b.jsx)(f,{paddingX:1,marginTop:1,children:(0,b.jsx)(t,{color:xt.color,children:xt.text})}),pe==="run"&&!tt&&!Zt&&!en&&!Q&&B.askingUser&&(0,b.jsxs)(f,{flexDirection:"column",marginLeft:2,paddingLeft:1,marginTop:1,children:[(0,b.jsx)(f,{marginLeft:1,children:(0,b.jsx)(t,{color:r.orange,bold:!0,children:"Agent Question"})}),(0,b.jsx)(f,{borderStyle:"round",borderColor:r.orange,flexDirection:"column",paddingX:2,paddingY:1,width:70,children:(0,b.jsxs)(f,{children:[(0,b.jsx)(f,{width:3,children:(0,b.jsx)(t,{color:r.orange,bold:!0,children:"?"})}),(0,b.jsx)(f,{flexShrink:1,children:(0,b.jsx)(t,{wrap:"wrap",children:B.askingUser})})]})})]}),Rn&&(()=>{let c=Rn,l=c.reason==="switch"?c.to==="run"?"Discard the current generation and switch to Run?":"Stop the current run / discard its results and switch to Generate?":"Switching profile will end this generation. Continue?",s=c.reason==="switch"?"Discard & switch":"Yes, end";return(0,b.jsx)(vs,{message:l,confirmLabel:s,onConfirm:async()=>{if(c.reason==="switch"){let y=c.to;tn(null),dt.confirmSwitch(y);return}ut();let d=c.pendingArgs;if(tn(null),await z.end(),z.reset(),d.profile){let y=g.creds.getDefaultEnv(),P=g.creds.getActiveProfile()??"(none)";g.creds.setActiveProfile(d.profile),g.creds.setDefaultEnv(y),Ge(g.creds,u,d.profile,y),We(d.profile,y),Pe(),ot({kind:"switch",env:y},Ue).catch(()=>{}),A("ok","/profiles switch",`${P} \u2192 ${d.profile} [${y}]`)}else xr("/profiles switch")},onCancel:()=>tn(null)})})(),pe==="run"&&!tt&&!Zt&&!en&&!Q&&!Rn&&!re.running&&(0,b.jsx)(Tt,{onSubmit:xr,onEscape:void 0,history:to,commands:Ei,clearSeq:Os,placeholder:B.askingUser?"Type your answer...":B.isRunning?"Run in progress... Ctrl+C to cancel":"Type an objective... (/ = commands)",footerBindings:[{keys:"\u2191\u2193",label:"history"},{keys:"\u21B5",label:"submit"},{keys:"tab",label:"complete"},{keys:"ctrl+r",label:"search"},{keys:"/generate",label:"test cases"}]}),pe==="generate"&&!tt&&!Zt&&!en&&!Q&&!Rn&&(0,b.jsx)(hs,{tcg:z,gm:dt,history:to,tuiConfig:C,browse:bt.isOpen?{target:bt.target,onClose:bt.close,excluded:bt.excluded,onToggleCase:bt.toggleCase,onToggleScenario:bt.toggleScenario,getStatus:dt.bifurcation.getStatus,getResult:dt.bifurcation.getResult}:null})]})]}),O&&H&&je&&(0,b.jsxs)(b.Fragment,{children:[(0,b.jsx)(wr,{steps:hn,status:je.status,testUrl:je.testUrl,error:je.error}),je.status==="success"&&(0,b.jsx)(Mn,{recordedTestPath:Jt?.recordedTestPath,outputDir:Jt?.outputDir,shareableLink:je.testUrl,testCaseLink:je.testCaseLink,codeExportDir:je.codeExportDir,autoExit:!1})]}),Q&&(0,b.jsx)(pi,{defaultName:Q,onSubmit:Us}),ee&&(0,b.jsx)(fi,{onSubmit:Ns}),rr&&je&&(0,b.jsx)(wr,{steps:hn,status:je.status,error:je.error}),O&&!H&&(0,b.jsx)(xi,{profile:jt,environment:ne,tokenValid:g.tokenValid,runCount:K,sessionId:a.sessionId,viewMode:Tn,breadcrumb:qs,chatMode:pe,tcgRequestId:z.requestId,tcgStreamStatus:z.isStreaming?"streaming":z.isReconnecting?"reconnecting":z.isTerminal&&z.state.status.toLowerCase()==="completed"?"completed":z.isTerminal&&z.state.status.toLowerCase()==="failed"?"failed":null})]})}function La({profiles:e,onSelect:n,onCancel:o,validating:i}){let[p,m]=(0,T.useState)(0);return Ce((x,h)=>{if(!i){if(h.escape){o();return}if(h.upArrow&&p>0&&m(v=>v-1),h.downArrow&&p<e.length-1&&m(v=>v+1),h.return){let v=e[p];n(v.profile,v.env)}}}),(0,b.jsxs)(f,{flexDirection:"column",paddingX:1,children:[(0,b.jsx)(t,{color:"#ff9500",bold:!0,children:"Select a profile:"}),(0,b.jsx)(f,{marginTop:1,flexDirection:"column",children:e.map((x,h)=>(0,b.jsxs)(t,{children:[h===p?"\u276F ":" ",(0,b.jsx)(t,{color:h===p?"#ff9500":"white",bold:h===p,children:x.profile}),(0,b.jsxs)(t,{color:"gray",children:[" [",x.env,"]"]})]},`${x.profile}-${x.env}`))}),i&&(0,b.jsx)(f,{marginTop:1,children:(0,b.jsx)(t,{color:"yellow",children:"Validating credentials..."})}),!i&&(0,b.jsx)(f,{marginTop:1,children:(0,b.jsx)(t,{color:"gray",children:"Esc = new login"})})]})}export{Ri as a,Rs as b,Ym as c};
|
package/dist/chunk-L3RTVAPG.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as u,d,e as m,f as g,g as S,k as y}from"./chunk-AH4AXJML.js";import{a as l}from"./chunk-UJZCMEEH.js";import{g as f,h as p}from"./chunk-LRF6UP42.js";import{existsSync as i,mkdirSync as h,readFileSync as v,renameSync as w,writeFileSync as C}from"fs";import{join as R}from"path";function A(t){y(u(t));let o=u(t);if(!i(o))return;let n=R(o,"meta.json"),r=m(t);if(i(n)&&!i(r))try{h(d(t),{recursive:!0}),w(n,r)}catch(e){process.stderr.write(`warn: meta.json migration failed: ${e.message}
|
|
3
|
-
`)}let s=S(t);if(i(s)){let e="python";try{let a=new l().load();a.code_export?.language&&(e=a.code_export.language)}catch{}let c=g(t,"playwright",e);if(!i(c))try{w(s,c)}catch(a){process.stderr.write(`warn: generated-code migration failed: ${a.message}
|
|
4
|
-
`)}}if(i(r))try{let e=JSON.parse(v(r,"utf8"));"md5sum"in e&&(delete e.md5sum,C(r,JSON.stringify(e,null,2)+`
|
|
5
|
-
`,"utf8"))}catch(e){process.stderr.write(`warn: meta.json md5sum strip failed: ${e.message}
|
|
6
|
-
`)}}async function b(t){if(!t.isInteractive)return{recovered:!1};if(x(t.creds,t.config))return{recovered:!1};let{SingleShotApp:o}=await import("./SingleShotApp-3XDTU2BU.js"),{render:n}=await import("./build-JIKYOZUH.js"),r=await import("./react-QWOAB3TB.js"),s={current:null},e={current:!1},{waitUntilExit:c,unmount:a}=n(r.default.createElement(o,{resultRef:s,mode:"login",loginCompleteRef:e}),{exitOnCtrlC:!1});p(()=>a()),await c();try{process.stdin.setRawMode?.(!1)}catch{}return process.stdout.write("\x1B[?25h"),e.current?{recovered:!0}:(f(0,"Startup gate cancelled"),{recovered:!1})}function x(t,o){let n=t.getActiveProfile(),r=t.getDefaultEnv();if(!n||!!!(t.loadBasicAuth(n,r)||t.loadCredentials(n,r)))return!1;let e=o.load();return!!e.project_id&&!!e.folder_id}export{A as a,b};
|
package/dist/chunk-LRF6UP42.js
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
var v=()=>!!process.env.KANE_DEV_MODE,r=[],a=!1,f=null,g=null,d=null,i=null;function x(e){i=e}function m(){return i}function h(){return a}function y(e,t){r=r.filter(o=>o.name!==e),r.push({name:e,fn:t})}function R(e){r=r.filter(t=>t.name!==e)}function w(e,t){let o=r.find(n=>n.name===e);if(!o)return;r=r.filter(n=>n.name!==e);let s=!0;try{o.fn()}catch(n){s=!1,process.stderr.write(`[exit-manager] cleanup(${e}) failed: ${n instanceof Error?n.message:String(n)}
|
|
3
|
-
`)}t&&s&&v()&&process.stderr.write(`[exit-manager] cleanup(${e}): ${t}
|
|
4
|
-
`)}function l(e,t,o=!1){if(a){process.exit(f??e);return}if(a=!0,f=e,o&&i)try{i.log("error","CRASH",t),i.shutdownSync()}catch{}let s=[...r].reverse(),n=[];for(let u of s)try{u.fn(),n.push(u.name)}catch(c){process.stderr.write(`[exit-manager] cleanup(${u.name}) failed: ${c instanceof Error?c.message:String(c)}
|
|
5
|
-
`)}if(r=[],v()&&(process.stderr.write(`[exit-manager] shutdown(${e}): ${t}
|
|
6
|
-
`),n.length>0&&process.stderr.write(`[exit-manager] cleaned up: ${n.join(", ")}
|
|
7
|
-
`)),o&&d){try{d()}catch{}process.stderr.write(`
|
|
8
|
-
Kane CLI crashed unexpectedly: ${t}
|
|
9
|
-
`+(n.length>0?`Resources cleaned up (${n.join(", ")}).
|
|
10
|
-
`:"")),process.exit(e);return}if(g&&!o){g();return}process.exit(e)}function E(e){g=e}function $(e){d=e}var p=!1;function S(){p||(p=!0,process.on("SIGINT",()=>{l(130,"Received SIGINT",!0)}),process.on("SIGTERM",()=>{l(143,"Received SIGTERM",!0)}),process.on("uncaughtException",e=>{l(1,`Uncaught exception: ${e.message}`,!0)}),process.on("unhandledRejection",e=>{l(1,`Unhandled rejection: ${String(e)}`,!0)}))}export{x as a,m as b,h as c,y as d,R as e,w as f,l as g,E as h,$ as i,S as j};
|
package/dist/chunk-M5RHRHFC.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as Ae}from"./chunk-UJZCMEEH.js";import{a as Se}from"./chunk-YCCUBQY4.js";import{a as ye}from"./chunk-VE3SUJMA.js";import{b as Ce}from"./chunk-7G7ZLAJH.js";import{a as _e}from"./chunk-BPF7TDRU.js";import{a as Ee}from"./chunk-J37YPPCD.js";import{a as oe}from"./chunk-AT2Y5UNP.js";import{a as Z}from"./chunk-HCBYKLMW.js";import{c as ve,t as f}from"./chunk-3Z4EHIOW.js";import{a as T,b as d,h as Te,i as ce,k as we}from"./chunk-C44QQJR4.js";import{a as ue}from"./chunk-6YGTRKDT.js";import{e as M}from"./chunk-UR6MHSHU.js";var Re=M(ue(),1);import{readFileSync as Me,writeFileSync as Oe,mkdirSync as ke}from"fs";import{dirname as Ke,join as Ue}from"path";var Ne=Ue(ve,"command-history.json"),Fe=200,ge=class{entries;filePath;max;constructor(t=Ne,n=Fe){this.filePath=t,this.max=n,this.entries=this._load()}push(t){this.entries.length>0&&this.entries[this.entries.length-1]===t||(this.entries.push(t),this.entries.length>this.max&&(this.entries=this.entries.slice(this.entries.length-this.max)),this._save())}getAll(){return[...this.entries]}search(t){let n=t.toLowerCase(),o=[];for(let s=this.entries.length-1;s>=0;s--)this.entries[s].toLowerCase().includes(n)&&o.push(this.entries[s]);return o}_load(){try{let t=Me(this.filePath,"utf-8"),n=JSON.parse(t);return Array.isArray(n)?n:[]}catch{return[]}}_save(){try{ke(Ke(this.filePath),{recursive:!0}),Oe(this.filePath,JSON.stringify(this.entries)+`
|
|
3
|
-
`)}catch{}}};function nt(i){let t=(0,Re.useRef)(null);return t.current||(t.current=new ge(i)),t.current}var K=M(ue(),1);var pe=M(ue(),1);var H=M(Z(),1);function Pe({history:i,onSelect:t,onClose:n}){let[o,s]=(0,pe.useState)(""),[l,x]=(0,pe.useState)(0),S=o?i.search(o).slice(0,8):[];return ce((w,g)=>{if(g.escape){n();return}if(g.return){S.length>0&&S[l]?t(S[l]):n();return}if(g.upArrow){x(A=>Math.max(0,A-1));return}if(g.downArrow){x(A=>Math.min(S.length-1,A+1));return}if(g.backspace||g.delete){s(A=>A.slice(0,-1)),x(0);return}w&&!g.ctrl&&!g.meta&&(s(A=>A+w),x(0))}),(0,H.jsxs)(T,{flexDirection:"column",marginLeft:2,borderStyle:"single",paddingX:1,children:[(0,H.jsx)(d,{color:f.muted,bold:!0,children:"reverse search"}),(0,H.jsxs)(T,{gap:1,children:[(0,H.jsx)(d,{color:f.dim,children:"search:"}),(0,H.jsx)(d,{children:o}),(0,H.jsx)(d,{color:f.orange,children:"\u2588"})]}),S.length>0&&(0,H.jsx)(d,{children:" "}),S.map((w,g)=>(0,H.jsx)(T,{marginLeft:2,children:(0,H.jsxs)(d,{color:g===l?f.orange:f.dim,bold:g===l,children:[g===l?"\u25B8 ":" ",w]})},`${g}-${w}`))]})}var ee=M(Z(),1);function Ie({commands:i,selectedIndex:t}){return i.length===0?null:(0,ee.jsx)(T,{flexDirection:"column",marginBottom:0,children:i.map((n,o)=>{let s=o===t;return(0,ee.jsxs)(T,{children:[(0,ee.jsx)(d,{color:s?f.orange:f.dim,children:s?"\u276F ":" "}),(0,ee.jsxs)(d,{color:s?f.orange:void 0,bold:s,children:["/",n.name]}),n.args&&(0,ee.jsxs)(d,{color:f.dim,children:[" ",n.args]}),(0,ee.jsxs)(d,{color:f.dim,children:[" ",n.description]})]},n.name)})})}var de=M(ue(),1);var We=27,He=127,Ge=11;function $e(i){return i>=64&&i<=126}function Ve(i,t){i===Ge&&t({killToEnd:!0,ctrl:!0,raw:String.fromCharCode(i)})}function Ye(i,t){i===He&&t({backspace:!0,meta:!0,raw:"\x1B\x7F"})}function ze(i,t){let n=i.map(s=>String.fromCharCode(s)).join(""),o=/^\[1;([0-9]+)([A-D])$/.exec(n);if(o){let s=parseInt(o[1],10),l=o[2],x={raw:"\x1B"+n};if(s===2)x.shift=!0;else if(s===3)x.meta=!0;else if(s===5)x.ctrl=!0;else return;l==="A"?x.arrowUp=!0:l==="B"?x.arrowDown=!0:l==="C"?x.arrowRight=!0:l==="D"&&(x.arrowLeft=!0),t(x);return}if(n==="[H"||n==="[1~"||n==="[7~"){t({home:!0,raw:"\x1B"+n});return}if(n==="[F"||n==="[4~"||n==="[8~"){t({end:!0,raw:"\x1B"+n});return}if(n==="[3;5~"){t({delete:!0,ctrl:!0,raw:"\x1B"+n});return}if(n==="[3;3~"){t({delete:!0,meta:!0,raw:"\x1B"+n});return}}function Xe(i,t){i===72?t({home:!0,raw:"\x1BO"+String.fromCharCode(i)}):i===70&&t({end:!0,raw:"\x1BO"+String.fromCharCode(i)})}function je(){let i="IDLE",t=[];function n(){i="IDLE",t=[]}return{feed(o,s){for(let l of o)i==="IDLE"?l===We?(i="ESC",t=[]):Ve(l,s):i==="ESC"?l===91?(i="CSI",t=[]):l===79?(i="SS3",t=[]):(Ye(l,s),n()):i==="CSI"?(t.push(l),$e(l)&&(ze([91,...t],s),n())):i==="SS3"&&(Xe(l,s),n())},flushIdle(o){i==="ESC"&&t.length===0&&o({raw:"\x1B"}),n()}}}function Be(i,t={}){let n=(0,de.useRef)(i);n.current=i;let{stdin:o}=Te();(0,de.useEffect)(()=>{if(t.isActive===!1||!o)return;let s=je(),l=null,x=S=>{l&&(clearTimeout(l),l=null);let w=Buffer.isBuffer(S)?S:Buffer.from(S,"binary");s.feed(w,g=>n.current(g)),l=setTimeout(()=>{s.flushIdle(g=>n.current(g)),l=null},50)};return o.on("data",x),()=>{o.removeListener("data",x),l&&clearTimeout(l)}},[t.isActive,o])}var E=M(Z(),1),xe=10;function qe(i){return i.replace(/\x1b?\[200~/g,"").replace(/\x1b?\[201~/g,"").replace(/\r\n/g,`
|
|
4
|
-
`).replace(/\r/g,`
|
|
5
|
-
`).replace(/[\x00-\x08\x0b-\x1f\x7f]/g,"")}function Je(i,t){let n=[],o=0;for(;o<=i.length;){let s=o;for(;s<i.length&&i[s]!==`
|
|
6
|
-
`;)s++;if(o===s)n.push({start:o,end:o});else{let l=o;for(;l<s;){let x=Math.min(l+t,s);n.push({start:l,end:x}),l=x}}if(s>=i.length)break;o=s+1}return n}function Qe(i,t,n){if(i.length===0)return 0;if(t>=n.length)return i.length-1;if(n[t]===`
|
|
7
|
-
`){for(let o=i.length-1;o>=0;o--)if(i[o].end===t)return o;return i.length-1}for(let o=0;o<i.length;o++){let s=i[o];if(s.start<=t&&t<s.end)return o}return i.length-1}function Le(i,t,n,o){let s=Je(i,n);if(s.length===0)return null;let l=Qe(s,t,i),x=l+o;if(x<0||x>=s.length)return null;let S=t-s[l].start,w=s[x],g=w.end-w.start;return w.start+Math.min(S,g)}function vt({onSubmit:i,onEscape:t,history:n,placeholder:o="Type an objective or /command...",commands:s,clearSeq:l,submitVerb:x,footerBindings:S,inert:w=!1,clearOnSubmit:g=!0,noHistory:A=!1,accent:G=f.orange}){let[c,p]=(0,K.useState)([]),[u,b]=(0,K.useState)(0),[R,C]=(0,K.useState)("none"),[U,B]=(0,K.useState)(-1),V=(0,K.useRef)(""),[X,Y]=(0,K.useState)(!0),{stdout:he}=we(),j=he?.columns??80,[D,N]=(0,K.useState)(0),O=(0,K.useRef)(!1);(0,K.useEffect)(()=>{if(l!==void 0){if(!O.current){O.current=!0;return}p([]),b(0),B(-1),V.current="",Y(!0),C("none"),N(0)}},[l]);let y=c.join(""),q=(()=>{if(R!=="none"||c.length===0)return"";if(y.startsWith("/")&&s&&y.length>=2){let e=y.slice(1).toLowerCase(),r=s.find(h=>h.name.startsWith(e)&&h.name!==e);return r?`/${r.name}`.slice(y.length):""}if(y.startsWith("/")||A)return"";let a=n.getAll();for(let e=a.length-1;e>=0;e--)if(a[e].startsWith(y)&&a[e]!==y)return a[e].slice(y.length);return""})(),F=(()=>{if(!s||!y.startsWith("/"))return[];let a=y.length>=2?y.slice(1).toLowerCase():"";return a&&s.some(e=>e.name===a)?[]:s.filter(e=>!a||e.name.startsWith(a))})(),te=F.length>0&&y.startsWith("/");if(ce((a,e)=>{if(X&&a&&Y(!1),e.return){if(te&&F[D]){let r=`/${F[D].name}`;A||n.push(r),i(r),p([]),b(0),C("none"),B(-1),V.current="",Y(!0),N(0);return}y.trim()&&(A||n.push(y.trim()),i(y.trim()),g&&(p([]),b(0),C("none"),B(-1),V.current="",Y(!0),N(0)));return}if(e.escape){R!=="none"?C("none"):c.length>0?(p([]),b(0),B(-1),V.current=""):t?.();return}if(e.tab&&!e.shift){if(te&&F[D]){let r=`/${F[D].name}`;p([...r]),b(r.length),N(0);return}if(q){let r=y+q;p([...r]),b(r.length);return}return}if(e.ctrl&&a==="r"){if(A)return;C("search");return}if(e.ctrl&&a==="a"){b(0);return}if(e.ctrl&&a==="e"){b(c.length);return}if(e.ctrl&&a==="w"){if(u===0)return;let r=u-1;for(;r>0&&c[r]===" ";)r--;for(;r>0&&c[r-1]!==" ";)r--;let h=[...c.slice(0,r),...c.slice(u)];p(h),b(r);return}if(e.ctrl&&a==="u"){p([]),b(0),B(-1),C("none");return}if(e.meta&&a==="b"){let r=u-1;for(;r>0&&c[r]===" ";)r--;for(;r>0&&c[r-1]!==" ";)r--;b(Math.max(0,r));return}if(e.meta&&a==="f"){let r=u;for(;r<c.length&&c[r]!==" ";)r++;for(;r<c.length&&c[r]===" ";)r++;b(r);return}if(e.leftArrow){if(e.ctrl||e.shift)return;b(r=>Math.max(0,r-1));return}if(e.rightArrow){if(e.ctrl||e.shift)return;if(u>=c.length&&q){let r=y+q;p([...r]),b(r.length)}else b(r=>Math.min(c.length,r+1));return}if(e.upArrow){if(e.shift)return;if(te){N(r=>Math.max(0,r-1));return}if(R==="none"){let r=Math.max(1,j-2),h=Le(c,u,r,-1);if(h!==null){b(h);return}if(A)return;let v=n.getAll();if(v.length===0)return;if(U===-1){V.current=y,B(v.length-1);let _=v[v.length-1];p([..._]),b(_.length)}else if(U>0){let _=U-1;B(_);let k=v[_];p([...k]),b(k.length)}}return}if(e.downArrow){if(e.shift)return;if(te){N(r=>Math.min(F.length-1,r+1));return}if(R==="none"){let r=Math.max(1,j-2),h=Le(c,u,r,1);if(h!==null){b(h);return}if(A)return;let v=n.getAll();if(U===-1)return;if(U<v.length-1){let _=U+1;B(_);let k=v[_];p([...k]),b(k.length)}else{B(-1);let _=V.current;p([..._]),b(_.length)}}return}if(e.backspace||e.delete){if(e.meta||e.ctrl)return;if(u>0){let r=[...c.slice(0,u-1),...c.slice(u)];p(r),b(u-1),B(-1),N(0)}return}if(a&&!e.ctrl&&!e.meta){let r=qe(a);if(!r)return;let h=[...c.slice(0,u),...r,...c.slice(u)];p(h),b(u+r.length),B(-1),N(0)}},{isActive:!w&&R!=="search"}),Be(a=>{if(a.home){b(0);return}if(a.end){b(c.length);return}if(a.killToEnd){p(c.slice(0,u));return}if(a.arrowLeft&&(a.ctrl||a.meta)){let e=u-1;for(;e>0&&c[e]===" ";)e--;for(;e>0&&c[e-1]!==" ";)e--;b(Math.max(0,e));return}if(a.arrowRight&&(a.ctrl||a.meta)){let e=u;for(;e<c.length&&c[e]!==" ";)e++;for(;e<c.length&&c[e]===" ";)e++;b(e);return}if(a.backspace&&a.meta){if(u===0)return;let e=u-1;for(;e>0&&c[e]===" ";)e--;for(;e>0&&c[e-1]!==" ";)e--;let r=[...c.slice(0,e),...c.slice(u)];p(r),b(e);return}if(a.delete&&(a.ctrl||a.meta)){let e=u;for(;e<c.length&&c[e]===" ";)e++;for(;e<c.length&&c[e]!==" ";)e++;p([...c.slice(0,u),...c.slice(e)]);return}},{isActive:!w&&R!=="search"}),w)return(0,E.jsxs)(T,{flexDirection:"column",children:[(0,E.jsx)(d,{color:f.muted,children:"\u2500".repeat(j)}),(0,E.jsxs)(T,{children:[(0,E.jsx)(d,{color:f.muted,children:"\u276F "}),(0,E.jsx)(d,{color:f.dim,children:o})]}),(0,E.jsx)(oe,{bindings:S??[{keys:"ctrl+c",label:"cancel"},{keys:"/cancel",label:"stop turn"},{keys:"ctrl+t",label:"thinking"}],suppressEscBack:!0})]});let me=a=>{p([...a]),b(a.length),C("none")},se=()=>{C("none")},ae=(()=>{if(X&&c.length===0)return null;let a=u>=c.length,e=c.slice(0,u).join(""),r,h;a?(r=" ",h=""):c[u]===`
|
|
8
|
-
`?(r=" ",h=c.slice(u).join("")):(r=c[u],h=c.slice(u+1).join(""));let v=e+r+h+q,_=e.length,k=_+1,re=k+h.length,fe=Math.max(1,j-2),P=[],z=0;for(;z<=v.length;){let L=v.indexOf(`
|
|
9
|
-
`,z);if(L===-1&&(L=v.length),z===L)P.push({type:"content",start:z,end:z});else{let W=z;for(;W<L;){let J=Math.min(W+fe,L);P.push({type:"content",start:W,end:J}),W=J}}if(L>=v.length)break;z=L+1}let $=Math.max(0,P.findIndex(L=>L.start<=_&&_<=L.end)),ie;if(P.length<=xe)ie=P;else{let W=xe-1-4;if($<4||$>=P.length-W)ie=[...P.slice(0,4),{type:"ellipsis",hidden:P.length-4-W},...P.slice(P.length-W)];else{let J=xe-2,be=Math.floor(J/2),Q=$-be,le=$+(J-be)-1;Q<1&&(le+=1-Q,Q=1),le>P.length-2&&(Q-=le-(P.length-2),le=P.length-2),Q=Math.max(1,Q),ie=[{type:"ellipsis",hidden:Q},...P.slice(Q,le+1),{type:"ellipsis",hidden:P.length-le-1}]}}return{full:v,b:_,c:k,a:re,rows:ie}})();return(0,E.jsxs)(T,{flexDirection:"column",children:[R==="search"&&(0,E.jsx)(Pe,{history:n,onSelect:me,onClose:se}),te&&(0,E.jsx)(Ie,{commands:F,selectedIndex:D}),(0,E.jsx)(d,{color:f.muted,children:"\u2500".repeat(j)}),ae===null?(0,E.jsxs)(T,{children:[(0,E.jsx)(d,{color:G,children:"\u276F "}),(0,E.jsx)(d,{inverse:!0,children:" "}),(0,E.jsx)(d,{color:f.dim,children:o})]}):(()=>{let a=ae.rows.findIndex(e=>e.type==="content");return(0,E.jsx)(T,{flexDirection:"column",children:ae.rows.map((e,r)=>{if(e.type==="ellipsis")return(0,E.jsx)(T,{children:(0,E.jsxs)(d,{color:f.dim,children:[" \u22EF ","(",e.hidden," more line",e.hidden===1?"":"s",")"]})},r);let{full:h,b:v,c:_,a:k}=ae,re=e.start,ne=e.end,fe=r===a,P=fe?"\u276F ":" ",z=fe?G:f.muted,$=[(0,E.jsx)(d,{color:z,children:P},"p")];re<Math.min(v,ne)&&$.push((0,E.jsx)(d,{children:h.slice(re,Math.min(v,ne))},"b"));let ie=Math.max(v,re),L=Math.min(_,ne);ie<L&&$.push((0,E.jsx)(d,{color:G,inverse:!0,children:h.slice(ie,L)},"c"));let W=Math.max(_,re),J=Math.min(k,ne);return W<J&&$.push((0,E.jsx)(d,{children:h.slice(W,J)},"a")),ne>k&&$.push((0,E.jsx)(d,{color:f.dim,children:h.slice(Math.max(k,re),ne)},"g")),(0,E.jsx)(T,{children:$},r)})})})(),(0,E.jsx)(oe,{bindings:S??[{keys:"\u2191\u2193",label:"history"},{keys:"\u21B5",label:x??"submit"},{keys:"tab",label:"complete"},{keys:"ctrl+r",label:"search"}],escBackLabel:"clear"})]})}var I=M(ue(),1);var m=M(Z(),1);function Ze(i){let t=[{id:"method",label:"Auth method",options:[{label:"Basic Auth",value:"basic"},{label:"OAuth (browser)",value:"oauth"}]}];return i&&t.push({id:"env",label:"Environment",options:[{label:"prod",value:"prod"},{label:"stage",value:"stage"}]}),t.push({id:"profile",label:"Profile"}),t.push({id:"credentials",label:"Credentials"}),t}function Rt({devMode:i,profiles:t,onBasicLogin:n,onOAuthLogin:o,onComplete:s,onCancel:l}){let x=Ze(i),[S,w]=(0,I.useState)(0),[g,A]=(0,I.useState)(0),[G,c]=(0,I.useState)({}),[p,u]=(0,I.useState)("select"),[b,R]=(0,I.useState)(""),[C,U]=(0,I.useState)("username"),[B,V]=(0,I.useState)(""),[X,Y]=(0,I.useState)(null),[he,j]=(0,I.useState)(null),D=x[S],N=G.method??"basic",O=G.env??"prod",y=(0,I.useCallback)(()=>{let e=t.filter(r=>r.env===O).map(r=>({label:`${r.profile} [${r.env}]`,value:r.profile}));return e.push({label:"+ Create new",value:"__new__"}),e},[t,O]),q=(0,I.useCallback)(()=>{S===0?l():(w(a=>a-1),A(0),u("select"),R(""),Y(null))},[S,l]),F=(0,I.useCallback)(a=>{N==="basic"?(u("text-input"),U("username"),R("")):(u("waiting"),o(a,O).then(()=>{j(`Logged in via OAuth as ${a} [${O}]`),u("done")}).catch(e=>{Y(e.message),u("error")}))},[N,O,o]),te=(0,I.useCallback)(a=>{let e=a.trim();if(e){if(C==="profileName"){let r=e;c(h=>({...h,profile:r})),F(r);return}if(C==="username"){V(e),R(""),U("accessKey"),u("text-input-masked");return}if(C==="accessKey"){let r=G.profile??"default";u("waiting"),(async()=>{try{await n(r,O,B,e),j(`Logged in as ${r} [${O}] via basic auth`),u("done")}catch{Y("Credentials not valid. Please use valid credentials."),V(""),R(""),U("username"),u("text-input")}})()}}},[C,G.profile,O,n,B,F]),me=(0,I.useCallback)(a=>{R(a),X&&Y(null)},[X]);ce((a,e)=>{if(p==="done"){let h=G.profile??"default";s(h,O);return}if(p==="error"){l();return}if(p==="waiting"){e.escape&&l();return}if(p==="text-input"||p==="text-input-masked")return;if(e.escape){q();return}let r=D?.id==="profile"?y():D?.options??[];if(e.upArrow){A(h=>Math.max(0,h-1));return}if(e.downArrow){A(h=>Math.min(r.length-1,h+1));return}if(e.return&&r[g]){let h=r[g];if(D.id==="profile"){if(h.value==="__new__"){u("text-input"),U("profileName"),R("");return}c(v=>({...v,profile:h.value})),w(v=>v+1),A(0),F(h.value);return}c(v=>({...v,[D.id]:h.value})),w(v=>v+1),A(0)}});let se="Login";if(p==="done")return(0,m.jsxs)(T,{flexDirection:"column",borderStyle:"round",borderColor:f.green,paddingX:2,paddingY:1,children:[(0,m.jsxs)(d,{color:f.green,bold:!0,children:["\u2713 ",he]}),(0,m.jsx)(T,{marginTop:1,children:(0,m.jsx)(d,{color:f.dim,children:"press any key"})})]});if(p==="error")return(0,m.jsxs)(T,{flexDirection:"column",borderStyle:"round",borderColor:f.red,paddingX:2,paddingY:1,children:[(0,m.jsx)(d,{color:f.red,bold:!0,children:"Login failed"}),(0,m.jsx)(T,{marginTop:1,children:(0,m.jsx)(d,{color:f.red,children:X})}),(0,m.jsx)(T,{marginTop:1,children:(0,m.jsx)(d,{color:f.dim,children:"press any key"})})]});if(p==="waiting")return(0,m.jsxs)(T,{flexDirection:"column",borderStyle:"round",borderColor:f.orange,paddingX:2,paddingY:1,children:[(0,m.jsxs)(d,{color:f.orange,bold:!0,children:[se," \u203A OAuth"]}),(0,m.jsx)(T,{marginTop:1,children:(0,m.jsx)(d,{color:f.secondary,children:"Opening browser for login..."})}),(0,m.jsx)(T,{marginTop:1,children:(0,m.jsx)(d,{color:f.orange,children:"Waiting for callback \u27F3"})}),(0,m.jsx)(oe,{bindings:[],escBackLabel:"cancel"})]});if(p==="text-input"||p==="text-input-masked"){let a=C==="username"?"Username":C==="accessKey"?"Access Key":"Profile name",e=C==="username"||C==="accessKey"?`${se} \u203A Basic Auth`:`${se} \u203A New Profile`;return(0,m.jsxs)(T,{flexDirection:"column",borderStyle:"round",borderColor:f.orange,paddingX:2,paddingY:1,children:[X&&(C==="username"||C==="accessKey")&&(0,m.jsx)(T,{marginBottom:1,children:(0,m.jsxs)(d,{color:f.red,children:["\u2717 ",X]})}),(0,m.jsx)(d,{color:f.orange,bold:!0,children:e}),C==="accessKey"&&(0,m.jsxs)(T,{marginTop:1,children:[(0,m.jsx)(d,{color:f.secondary,children:"Username: "}),(0,m.jsx)(d,{children:B})]}),(0,m.jsxs)(T,{marginTop:1,children:[(0,m.jsxs)(d,{color:f.secondary,children:[a,": "]}),(0,m.jsx)(Se,{value:b,onChange:me,onSubmit:te,onCancel:q,masked:p==="text-input-masked"})]}),(0,m.jsx)(oe,{bindings:[{keys:"\u21B5",label:"confirm"}],escBackLabel:"back"})]})}let ae=D?.id==="profile"?y():D?.options??[];return(0,m.jsxs)(T,{flexDirection:"column",borderStyle:"round",borderColor:f.orange,paddingX:2,paddingY:1,children:[(0,m.jsx)(d,{color:f.orange,bold:!0,children:se}),(0,m.jsx)(T,{marginTop:1,children:(0,m.jsxs)(d,{color:f.secondary,children:[D?.label,":"]})}),(0,m.jsx)(T,{flexDirection:"column",marginTop:1,children:ae.map((a,e)=>{let r=e===g,h=r?"\u276F ":" ",v=a.value==="__new__"?f.green:r?f.orange:void 0;return(0,m.jsxs)(d,{color:v,children:[h,a.label]},a.value)})}),(0,m.jsx)(oe,{bindings:[{keys:"\u2191\u2193",label:"navigate"},{keys:"\u21B5",label:"select"}],escBackLabel:"back"})]})}async function De(i,t,n,o){let s=i.loadBasicAuth(t,n),l=i.loadCredentials(t,n);if(!s&&!l)return o("info","STARTUP_GATE_NO_CREDS","Profile has no credentials",{profile:t,env:n}),{status:"needs_login",profile:t,env:n};let x=Ee(n),S=async()=>i.loadCredentials(t,n)?.access_token??null,w=new _e(x.controllerBaseUrl,S,s,o);o("info","STARTUP_GATE_VALIDATE","Validating credentials with controller",{profile:t,env:n,method:s?"basic":"oauth"});let g=await w.resolve(!0);if(g)return o("info","STARTUP_GATE_VALID","Credentials validated",{profile:t,env:n,username:g.username,org_id:g.org_id}),{status:"authenticated",result:{profile:t,env:n,credentials:l,basicAuth:s,tmsCreds:g,resolver:w}};if(!s&&l){let A=l.refresh_token,c=i.loadClient(t,n)?.client_id;if(A&&c){o("info","STARTUP_GATE_REFRESH","Attempting token refresh",{profile:t,env:n});try{let u=await new Ce(n).refreshToken(A,c);if(u.access_token){i.saveCredentials(t,n,{...l,...u,expires_at:Date.now()/1e3+(u.expires_in??3600)});let R=await w.resolve(!0);if(R)return o("info","STARTUP_GATE_REFRESH_OK","Token refreshed and validated",{profile:t,env:n,username:R.username}),{status:"authenticated",result:{profile:t,env:n,credentials:{...l,...u},basicAuth:null,tmsCreds:R,resolver:w}}}o("warn","STARTUP_GATE_REFRESH_INVALID","Refreshed token still invalid",{profile:t,env:n})}catch(p){o("warn","STARTUP_GATE_REFRESH_FAILED","Token refresh failed",{profile:t,env:n,error:p instanceof Error?p.message:String(p)})}}else o("info","STARTUP_GATE_NO_REFRESH","No refresh_token or client_id \u2014 login required",{profile:t,env:n})}return o("info","STARTUP_GATE_INVALID","Credentials invalid \u2014 login required",{profile:t,env:n}),{status:"needs_login",profile:t,env:n}}async function Ot(i,t,n=new Ae){let o=i.listProfiles();if(t("info","STARTUP_GATE_START","Auth startup gate",{profile_count:o.length}),o.length===0)return t("info","STARTUP_GATE_NONE","No profiles found \u2014 login required"),{status:"needs_login"};if(o.length>1){let x=i.getActiveProfile(),S=i.getDefaultEnv();if(x&&o.some(g=>g.profile===x&&g.env===S)){t("info","STARTUP_GATE_TRY_ACTIVE","Multiple profiles \u2014 trying active first",{activeProfile:x,activeEnv:S});let g=await De(i,x,S,t);if(g.status==="authenticated")return g;t("info","STARTUP_GATE_ACTIVE_FAILED","Active profile invalid \u2014 showing picker",{activeProfile:x,activeEnv:S})}return t("info","STARTUP_GATE_MULTI","Multiple profiles \u2014 picker required",{profiles:o.map(w=>`${w.profile}/${w.env}`)}),{status:"needs_pick",profiles:o}}let{profile:s,env:l}=o[0];return i.setActiveProfile(s),i.setDefaultEnv(l),ye(i,n,s,l),De(i,s,l,t)}export{nt as a,vt as b,Rt as c,De as d,Ot as e};
|
package/dist/chunk-PN7LNQ7G.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as v}from"./chunk-J37YPPCD.js";import{spawn as x,execSync as b}from"child_process";import{existsSync as g}from"fs";import{resolve as e,dirname as N}from"path";import{fileURLToPath as h}from"url";import{createInterface as R}from"readline";async function*_(i){let n=R({input:i,crlfDelay:1/0});for await(let l of n){let r=l.trim();if(r)try{let d=JSON.parse(r);d&&typeof d.type=="string"&&(yield d)}catch{}}}function E(i){return i==="action"?{set:{V16_AGENT_ENABLE_ALL_BLOCKERS:"true",V16_AGENT_SKIP_CP_FINAL:"true"},unset:[]}:{set:{},unset:["V16_AGENT_ENABLE_ALL_BLOCKERS","V16_AGENT_SKIP_CP_FINAL"]}}var c=N(h(import.meta.url));function A(){for(let i of["python3","python"])try{return b(`${i} --version`,{stdio:"ignore"}),i}catch{}return null}function C(){let n=process.platform==="win32"?"v16-runner.exe":"v16-runner",l={"darwin-arm64":["@testmuai/kane-cli-darwin-arm64","@lambdatestincprivate/kane-cli-darwin-arm64"],"darwin-x64":["@testmuai/kane-cli-darwin-x64","@lambdatestincprivate/kane-cli-darwin-x64"],"linux-x64":["@testmuai/kane-cli-linux-x64","@lambdatestincprivate/kane-cli-linux-x64"],"win32-x64":["@testmuai/kane-cli-win-x64","@lambdatestincprivate/kane-cli-win-x64"]},r=`${process.platform}-${process.arch}`,d=l[r];if(d)for(let t of d){let a=[e(c,"..","node_modules",t,"bin",n),e(c,"..","..","node_modules",t,"bin",n),e(c,"..","..","..","node_modules",t,"bin",n),e(c,"..","..","..","..","node_modules",t,"bin",n)];for(let u of a)if(g(u))return{cmd:u,args:[]}}let p=[e(c,"bin",n),e(c,"..","bin",n),e(c,"..","..","..","..","v16-runner","dist",n),e(c,"..","..","..","v16-runner","dist",n),e(process.cwd(),"v16-runner","dist",n),e(process.cwd(),"..","v16-runner","dist",n)];for(let t of p)if(g(t))return{cmd:t,args:[]};let s=[e(c,"..","..","..","..","v16-runner"),e(c,"..","..","..","v16-runner"),e(process.cwd(),"v16-runner"),e(process.cwd(),"..","v16-runner")];for(let t of s)if(g(e(t,"main.py"))){for(let u of[e(t,".venv","bin","python"),e(t,"..","browser-agent",".venv","bin","python")])if(g(u))return{cmd:u,args:["main.py"],cwd:t};let a=A();if(a)return{cmd:a,args:["main.py"],cwd:t}}return null}function V(i,n){let l=C();if(!l)throw new Error("v16-runner not found. Build the binary with `cd v16-runner && python build.py` or ensure Python is available.");let r={...process.env};n?.environment&&(r.TESTMUAI_ENV=n.environment),r.TESTMUAI_SOURCE="kane-cli",process.platform==="win32"&&(r.PYTHONIOENCODING="utf-8");let d=v(n?.environment);r.V16_SERVER_API_HOST=d.v16ServerHost,r.ATMS_URL=d.tmsBaseUrl.replace(/\/api\/?$/,""),i.username&&i.access_key&&(r.LT_USERNAME=i.username,r.LT_ACCESS_KEY=i.access_key),i.session_id&&(r.TESTMUAI_SESSION_ID=i.session_id);let p=E(n?.mode??"testing");Object.assign(r,p.set);for(let o of p.unset)delete r[o];let s=x(l.cmd,l.args,{stdio:["pipe","pipe","pipe"],env:r,cwd:l.cwd});s.stdin.on("error",()=>{}),s.stdin.write(JSON.stringify(i)+`
|
|
3
|
-
`);let t=1e5,a="";s.stderr.on("data",o=>{a+=o.toString(),a.length>t&&(a=a.slice(-t))}),s.on("error",o=>{n?.log?.("error","RUNNER_SPAWN_ERROR","Runner spawn error",{error:o.message})});let u=null,f=null,S=new Promise(o=>{s.on("close",(m,y)=>{u=m,f=y?String(y):null,n?.log?.("info","RUNNER_EXIT","Runner exited",{code:m,signal:f??"none"}),o({code:m,signal:f})})}),w=_(s.stdout);return{child:s,events:w,sendUserResponse(o){let m=JSON.stringify({type:"user_response",answer:o});try{s.stdin.write(m+`
|
|
4
|
-
`)}catch{}},sendCancel(o){let m=JSON.stringify({type:"cancel",reason:o});try{s.stdin.write(m+`
|
|
5
|
-
`)}catch{}},cancel(){s.kill("SIGTERM")},get stderr(){return a},get exitCode(){return u},get exitSignal(){return f},exited:S}}export{C as a,V as b};
|
package/dist/chunk-SJ7VGRQU.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as h}from"./chunk-L5LI2JF4.js";import{c}from"./chunk-3Z4EHIOW.js";import{randomUUID as j}from"crypto";import{mkdirSync as $,writeFileSync as p,appendFileSync as E,existsSync as _}from"fs";import{join as a}from"path";import{writeFileSync as S,mkdirSync as b,existsSync as w}from"fs";import{join as g,relative as I}from"path";function m(i){let t=Object.keys(i.frontmatter).length>0?h(i.frontmatter).trimEnd():"",s=["---"];return t&&s.push(t),s.push("---",""),s.push(`# ${i.heading}`,""),i.steps.forEach((r,n)=>{s.push(`## Step ${n+1}`,r,"")}),s.join(`
|
|
3
|
-
`)}var x=new Set(["username","access_key","oauth","profile","project_id","folder_id"]),y=new Set(["model","env"]),d=class{constructor(e){this.opts=e}objectives=[];flushed=!1;lastWrittenPath=null;lastCollisionSuffixed=!1;appendObjective(e){this.objectives.push(e)}flush(){if(this.flushed||(this.flushed=!0,this.objectives.length===0))return;let e=this.opts.getName();if(!e)return;let t=g(this.opts.cwd,".testmuai","tests");try{b(t,{recursive:!0})}catch(u){process.stderr.write(`
|
|
4
|
-
\u26A0 Failed to create ${I(this.opts.cwd,t)}/
|
|
5
|
-
${u.message}
|
|
6
|
-
Your test recording was NOT saved.
|
|
7
|
-
|
|
8
|
-
`);return}let s=g(t,`${e}_test.md`),r=2,n=!1;for(;w(s);)s=g(t,`${e}-${r}_test.md`),r++,n=!0;let o=L(this.opts.getResolvedGlobal()),l=m({frontmatter:o,heading:`Session: ${e}`,steps:this.objectives});try{S(s,l,"utf8")}catch(u){process.stderr.write(`
|
|
9
|
-
\u26A0 Failed to save your test recording.
|
|
10
|
-
${u.message}
|
|
11
|
-
Path: ${s}
|
|
12
|
-
|
|
13
|
-
`);return}this.lastWrittenPath=s,this.lastCollisionSuffixed=n}};function L(i){let e={};for(let[t,s]of Object.entries(i))x.has(t)||y.has(t)||(e[t]=s);return e}var F=a(c,"sessions"),f=class{sessionId;sessionDir;runs=[];_flows=[];_nextIndex=0;_started=!1;_testId=null;_testcaseId=null;_projectId=null;_orgId=null;_uploadStatus="pending";_uploadAttempts=0;_uploadError=null;_firstObjective=null;_firstUrl=null;_auteurVariables={};_screenshotSas=null;_model="";_environment="";_profile=null;_startedAt="";_remoteLogger=null;_earlyLogBuffer=[];_recorder=null;_resolvedGlobal={};_sessionName=null;_recordingEnabled=!0;_stepRunRecords=[];constructor(e){this.sessionId=j();let t=e?.baseDir?a(e.baseDir,"sessions"):F;this.sessionDir=a(t,this.sessionId)}setResolvedGlobal(e){this._resolvedGlobal={...this._resolvedGlobal,...e}}setSessionName(e){this._sessionName=e}get sessionName(){return this._sessionName}setRecordingEnabled(e){this._recordingEnabled=e}get recorder(){return this._recorder}flushRecorder(){try{this._recorder?.flush()}catch(e){process.stderr.write(`[recorder] flush failed: ${e.message}
|
|
14
|
-
`)}}start(e){if(!this._started){this._started=!0,this._model=e.model,this._environment=e.environment,this._profile=e.profile,this._startedAt=new Date().toISOString();try{$(this.sessionDir,{recursive:!0}),this._recorder=new d({cwd:process.cwd(),getResolvedGlobal:()=>this._resolvedGlobal,getName:()=>this._sessionName});let t={session_id:this.sessionId,started_at:this._startedAt,model:e.model,environment:e.environment,profile:e.profile,objectives:[],runs:[],status:"in_progress"};p(a(this.sessionDir,"session.json"),JSON.stringify(t,null,2)+`
|
|
15
|
-
`)}catch{}this._log(`SESSION START session_id=${this.sessionId}`),this._log(`CONFIG model=${e.model} env=${e.environment} profile=${e.profile}`),this._earlyLogBuffer.push({level:"info",event:"SESSION_START",message:"Session started",context:{session_id:this.sessionId}},{level:"info",event:"CONFIG",message:"Session config",context:{model:e.model,environment:e.environment,profile:e.profile}})}}setRemoteLogger(e){this._remoteLogger=e;for(let t of this._earlyLogBuffer)e.log(t.level,t.event,t.message,t.context);this._earlyLogBuffer=[]}get hasRemoteLogger(){return this._remoteLogger!==null}setAuteurVariables(e){Object.assign(this._auteurVariables,e)}get auteurVariables(){return this._auteurVariables}setScreenshotSas(e){this._screenshotSas=e}get screenshotSas(){return this._screenshotSas}get screenshotBaseUrl(){return this._screenshotSas?`${this._screenshotSas.base_url}/${this._screenshotSas.container}`:""}get startedAt(){return this._startedAt||new Date().toISOString()}log(e,t,s,r){if(t===void 0){this._log(e);let l=e.indexOf(" "),u=l>0?e.slice(0,l):e,v=l>0?e.slice(l+1):"",R=/fail|error/i.test(e)?"error":"info";this._remoteLogger?.log(R,u,v||e);return}let n=e,o=s;this._log(`${t} ${o}`),this._remoteLogger?.log(n,t,o,r)}logStep(e,t,s){this._log(`${e} ${t}`);let r=this._nextIndex>0?this._nextIndex-1:0;this._remoteLogger?.logStep(r,e,t,s)}logCommand(e){this._log(`COMMAND ${e}`)}logRunStart(e,t,s){this._log(`RUN ${e} START objective="${t.slice(0,100)}" url=${s}`),this._remoteLogger?.setRunIndex(e),this._remoteLogger?.log("info","RUN_START",`Run ${e} started`,{run_index:e,objective:t,url:s})}logRunEnd(e,t,s,r){let n=(s??0).toFixed(1),o=(r??"").slice(0,100);this._log(`RUN ${e} END status=${t} duration=${n}s summary="${o}"`),this._remoteLogger?.log("info","RUN_END",`Run ${e} ended`,{run_index:e,status:t,duration:s??0,summary:r??""}),t!=="failed"&&t!=="error"&&this._remoteLogger?.discardSteps(e)}escalateRun(e){this._remoteLogger?.escalate(e)}logChromeLaunch(e,t){this._log(`CHROME LAUNCH port=${e} endpoint=${t}`),this._remoteLogger?.log("info","CHROME_LAUNCH","Chrome launched",{port:e,cdp_endpoint:t})}async finish(e="complete"){this._log(`SESSION END status=${e} total_runs=${this.runs.length}`),this._remoteLogger?.log("info","SESSION_END","Session ended",{status:e,total_runs:this.runs.length}),await this._remoteLogger?.shutdown();let t={session_id:this.sessionId,started_at:this._startedAt,ended_at:new Date().toISOString(),model:this._model,environment:this._environment,profile:this._profile,status:e,total_runs:this.runs.length,test_id:this._testId,testcase_id:this._testcaseId,commit_id:this.sessionId,project_id:this._projectId,upload_status:this._uploadStatus,upload_attempts:this._uploadAttempts,last_upload_attempt:this._uploadAttempts>0?new Date().toISOString():null,upload_error:this._uploadError,runs:this.runs.map(s=>({index:s.index,objective:s.objective,status:s.status,summary:s.summary,run_dir:s.run_dir}))};_(this.sessionDir)&&p(a(this.sessionDir,"session.json"),JSON.stringify(t,null,2)+`
|
|
16
|
-
`),this.flushRecorder(),this._recorder=null}nextRunIndex(){return this._nextIndex}addRunResult(e,t){this.runs.push(e),this._nextIndex+=t??1,this._recordingEnabled&&this._recorder?.appendObjective(e.objective)}getContext(){return{prior_runs:this.runs.map(e=>({index:e.index,objective:e.objective,summary:e.summary,status:e.status,memory:e.context.memory,variables:e.context.variables,pointer:e.context.pointer}))}}addFlow(e){let t={...e,index:this._flows.length+1};return this._flows.push(t),t}getFlows(){return[...this._flows]}getFlow(e){return this._flows.find(t=>t.index===e)}clearFlows(){this._flows=[]}recordStepRun(e){this._stepRunRecords.push(e)}getStepRunRecords(){return[...this._stepRunRecords]}getRunsAsStepRecords(){return this.runs.map((e,t)=>({testmdStepIndex:t+1,runIndex:e.index,totalRunDirs:e.run_dirs?.length??1}))}snapshot(){return{runsLen:this.runs.length,nextRunIndex:this._nextIndex,stepRunRecordsLen:this._stepRunRecords.length}}rollback(e){this.runs.length=e.runsLen,this._nextIndex=e.nextRunIndex,this._stepRunRecords.length=e.stepRunRecordsLen}setTestId(e){this._testId=e}get testId(){return this._testId}setTestcaseId(e){this._testcaseId=e}get testcaseId(){return this._testcaseId}setProjectId(e){this._projectId=e}setOrgId(e){this._orgId=e}get orgId(){return this._orgId}setFirstRun(e,t){this._firstObjective||(this._firstObjective=e,this._firstUrl=t)}get firstObjective(){return this._firstObjective}get firstUrl(){return this._firstUrl}getRunDirs(){let e=[];for(let t of this.runs)t.run_dirs&&t.run_dirs.length>0?e.push(...t.run_dirs):t.run_dir&&e.push(t.run_dir);return e}getRunObjectives(){let e=[];for(let t of this.runs)t.flow_objectives&&t.flow_objectives.length>0?e.push(...t.flow_objectives):e.push(t.objective);return e}getRunMetadata(){let e=[];for(let t of this.runs)if(t.perFlowMetadata&&t.perFlowMetadata.length>0)e.push(...t.perFlowMetadata);else{let s={resultCode:t.resultCode,reasonCode:t.reasonCode,errorMessage:t.status==="failed"?t.summary??null:null,summary:t.summary,oneLiner:t.oneLiner},r=t.run_dirs?.length??1;for(let n=0;n<r;n++)e.push(s)}return e}setUploadStatus(e,t){this._uploadStatus=e,this._uploadAttempts+=1,this._uploadError=t??null}_log(e){if(!(!this._started||!_(this.sessionDir)))try{let t=new Date().toISOString().slice(0,19).replace("T"," "),s=a(this.sessionDir,"tui.log");E(s,`[${t}] ${e}
|
|
17
|
-
`)}catch{}}};export{m as a,f as b};
|
package/dist/chunk-UVBDUDSL.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{b as m}from"./chunk-VE3SUJMA.js";import{a as g}from"./chunk-J37YPPCD.js";import{a as f}from"./chunk-7CLUJYMW.js";var _="KaneAI Generated",N="Untitled";async function u(e){let d=e.config.load(),c=new f(g(e.env).tmsBaseUrl,e.tmsCreds.username,e.tmsCreds.access_key),l=e.projectName??_,i=e.folderName??N,r=d.project_id??null,s=d.project_name??null;if(!r){let n=(await c.listProjects()).find(o=>o.name===l);if(n)r=n.project_id,s=n.name,e.log("info","ENSURE_PROJECT_FOUND","Found default project",{project_id:r,name:s});else{let o=await c.createProject(l);r=o.id,s=o.name,e.log("info","ENSURE_PROJECT_CREATED","Created default project",{project_id:r,name:s})}m(e.creds,e.config,e.profile,e.env,{projectId:r,projectName:s})}let t=d.folder_id??null,a=d.folder_name??null,j=!d.project_id;if(!t||j){let n=(await c.listFolders(r)).find(o=>o.name===i);if(n)t=n.id,a=n.name,e.log("info","ENSURE_FOLDER_FOUND","Found default folder",{folder_id:t,name:a});else{let o=await c.createFolder(r,i);t=o.id,a=o.name,e.log("info","ENSURE_FOLDER_CREATED","Created default folder",{folder_id:t,name:a})}m(e.creds,e.config,e.profile,e.env,{folderId:t,folderName:a})}return{projectId:r,projectName:s??l,folderId:t,folderName:a??i}}export{u as a};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a as D,f as E,g as H,h as x,j as A,k as G,l as M,m as w,n as T,o as $,p as B}from"./chunk-H4XV224I.js";import{a as j}from"./chunk-UVBDUDSL.js";import{c as b}from"./chunk-3C7ATCDM.js";import{d as L}from"./chunk-7RPMUEEN.js";import"./chunk-PN7LNQ7G.js";import{b as C}from"./chunk-SJ7VGRQU.js";import"./chunk-L5LI2JF4.js";import{a as _}from"./chunk-UJZCMEEH.js";import{d as R,e as q}from"./chunk-LRF6UP42.js";import"./chunk-VE3SUJMA.js";import{a as k}from"./chunk-7G7ZLAJH.js";import"./chunk-BPF7TDRU.js";import"./chunk-WAOCHXJ5.js";import{a as I}from"./chunk-J37YPPCD.js";import"./chunk-3Z4EHIOW.js";import"./chunk-7CLUJYMW.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-UR6MHSHU.js";import{join as Q}from"path";async function P(t){let e=t.projectId,n=t.folderId;if(!e&&t.autoResolve){let r=await t.resolver.resolve();if(!r)throw new H("unauthorized; run `kane-cli login`");let c=await j({creds:t.autoResolve.creds,config:t.autoResolve.config,profile:t.autoResolve.profile,env:t.autoResolve.envName,tmsCreds:{username:r.username,access_key:r.access_key},log:t.log});e=c.projectId,n=n??c.folderId}return{baseUrl:`${t.env.testGeneratorBaseUrl}/test-generator/api/v2`,authResolver:t.resolver,projectId:e,folderId:n,suiteName:t.suiteName,log:t.log}}function K(t){return t.reduce((e,n)=>e+(n.test_cases?.length??0),0)}var h=class{constructor(e=n=>process.stdout.write(n)){this.write=e}emit(e){this.write(JSON.stringify(e)+`
|
|
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})}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:K(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})}},y=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
|
-
`)}onThinking(e){let n=e.tookMs?` (${Math.round(e.tookMs/1e3)}s)`:"";this.write(` thinking${n}
|
|
5
|
-
`)}onProgress(e){this.write(` progress ${e}%
|
|
6
|
-
`)}onSnapshot(e){for(let n of e.scenarios){this.write(` \u2022 ${n.title??n.sid??"scenario"}
|
|
7
|
-
`);for(let r of n.test_cases??[])this.write(` - ${r.title??`case ${r.id}`}
|
|
8
|
-
`)}}onClarification(e){this.write(`? ${e}
|
|
9
|
-
`)}onChat(e){this.write(`${e}
|
|
10
|
-
`)}onError(e){this.write(`error: ${e}
|
|
11
|
-
`)}onSaveResult(e){this.write(` saved ${e.saved} test(s) to ${e.suiteDir}${e.fellBack?` (${e.fellBack} prose fallback)`:""}
|
|
12
|
-
`),e.warning&&this.write(` warning: ${e.warning}
|
|
13
|
-
`)}onDone(e){this.write(`\u2713 Generated ${e.scenarioCount} scenarios \xB7 ${e.caseCount} cases (request ${e.requestId})
|
|
14
|
-
`),this.write(` Refine: ${e.refineHint}
|
|
15
|
-
`),this.write(` Save: ${e.saveHint}
|
|
16
|
-
`),e.suiteDir&&this.write(` Saved: ${e.suiteDir}
|
|
17
|
-
`)}onUpdateAvailable(e){this.write(`(update available: ${e.current} \u2192 ${e.latest})
|
|
18
|
-
`)}};import{createHash as J}from"crypto";function Y(t){return J("sha1").update(JSON.stringify({t:t.title,p:t.preconditions,m:t.manual_steps})).digest("hex")}function V(t){let e=[];for(let n of t.scenarios)for(let r of n.test_cases??[])w(r)&&r.manual_steps!=null&&e.push(r);return e}async function X(t,e,n){let r=new Array(t.length),c=0,m=Array.from({length:Math.min(e,t.length)},async()=>{for(;;){let a=c++;if(a>=t.length)return;try{r[a]={ok:!0,value:await n(t[a])}}catch{r[a]={ok:!1}}}});return await Promise.all(m),r}async function N(t,e,n){let r=V(t),c=n.run??(async(o,l)=>{let p=await n.resolveAuth(),U=$({objective:o,model:n.model,sessionId:n.sessionId,auth:p});return B(U,n.spawnOpts,l)}),m=r.map(Y),a=[...new Set(m)],g=new Map;a.forEach(o=>{g.set(o,r[m.indexOf(o)])});let i=a.map(o=>g.get(o)),d=await X(i,n.concurrency??3,o=>c(T(o))),u=new Map;a.forEach((o,l)=>{let p=d[l];p.ok&&u.set(o,p.value)});let f=new Map;r.forEach((o,l)=>{f.set(o.id,u.get(m[l]))});let s=0;for(let o of t.scenarios)for(let l of o.test_cases??[])w(l)&&!f.get(l.id)&&s++;let S=o=>{let l=f.get(o.id);return l?A(l,o):G(o)};return{...await M(t,e,{suiteName:n.suiteName,redirectBareCwd:!1},S),fellBack:s}}function Ce(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 W(){return Q(process.cwd(),".testmuai","tests")}var z="tcg-generate-headless";function F(t){return{refineHint:`kane-cli generate "<refinement>" --refine --req ${t}`,saveHint:`kane-cli generate --save --req ${t}`}}function O(t){return t.scenarios.reduce((e,n)=>e+(n.test_cases?.length??0),0)}function Z(t){return t==="completed"?0:t==="stopped"?3:1}async function Re(t,e){let n=e.write??(a=>process.stdout.write(a)),r=e.sink??(e.mode==="agent"?new h(n):new y(n)),c;try{c=await e.makeClient()}catch(a){return r.onError(a.message),2}try{let a=await(e.checkUpdate??L)();a&&r.onUpdateAvailable(a)}catch{}let m=t.reqId??null;R(z,()=>{m&&c.cancel(m).catch(()=>{})});try{if(t.op==="save"){let s;try{s=(await c.attach(t.reqId)).state}catch(l){return r.onError(l.message),2}m=s.requestId,r.onSnapshot(s);let S=t.outDir??W(),v=await e.materialize(s,S,t.suiteName);r.onSaveResult({suiteDir:v.suiteDir,saved:v.paths.length,fellBack:v.fellBack,warning:v.warning});let o=F(s.requestId);return r.onDone({requestId:s.requestId,status:"completed",scenarioCount:s.scenarios.length,caseCount:O(s),refineHint:o.refineHint,saveHint:o.saveHint,suiteDir:v.suiteDir}),0}let a=t.op==="refine",g,i;try{if(a){let s=await c.attach(t.reqId);if(i=s.state,m=i.requestId,i.error)return r.onError(i.error),2;r.onStart({requestId:i.requestId,objectiveChars:(t.objective??"").length,scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit,isRefine:!0}),await c.chat(t.reqId,t.objective,void 0),g=s.events}else{let s=await c.start({prompt:t.objective,scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit,memoryEnhancement:t.memory});i=s.state,m=i.requestId,r.onStart({requestId:i.requestId,objectiveChars:t.objective.length,scenarioLimit:t.scenarioLimit,perScenarioLimit:t.perScenarioLimit,isRefine:!1}),g=s.events}}catch(s){return r.onError(s.message),2}let d="";for await(let s of g){switch(i=E(i,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":d=s.status;break;default:break}if(s.type==="done"||s.type!=="thinking"&&i.status&&D(i.status))break}r.onSnapshot(i);let u=d||i.status||"completed",f=F(i.requestId);return r.onDone({requestId:i.requestId,status:u,scenarioCount:i.scenarios.length,caseCount:O(i),refineHint:f.refineHint,saveHint:f.saveHint,suiteDir:void 0}),Z(u)}finally{q(z)}}var ee=()=>{};async function qe(t){let e=new k,n=new _,r=e.getActiveProfile()??"default",c=t.env??e.getDefaultEnv()??"prod",m=I(c),a=new C;t.name&&a.setSessionName(t.name);let g=n.load().model,i=async()=>{let u=await b({creds:e,env:c,usernameFlag:t.username,accessKeyFlag:t.accessKey,log:()=>{}}),f=await P({resolver:u.resolver,env:m,log:ee,projectId:t.projectId,folderId:t.folderId,autoResolve:t.projectId?void 0:{creds:e,config:n,profile:r,envName:c}});return x(f)},d=async()=>{let u=await b({creds:e,env:c,usernameFlag:t.username,accessKeyFlag:t.accessKey,log:()=>{}});return u.basicAuth?{username:u.basicAuth.username,access_key:u.basicAuth.access_key}:u.token?{auth:{type:"bearer",token:u.token}}:{}};return{mode:t.mode,makeClient:i,materialize:(u,f,s)=>N(u,f,{model:g,sessionId:a.sessionId,resolveAuth:d,spawnOpts:{environment:c},suiteName:s})}}export{qe as buildHeadlessDeps,Ce as decideGenerateMode,W as defaultOutDir,_e as resolveGenerateOp,Re as runGenerateHeadless};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{a}from"./chunk-O2UU4TS5.js";import"./chunk-7G7ZLAJH.js";import"./chunk-J37YPPCD.js";import"./chunk-3Z4EHIOW.js";import"./chunk-RZ4F3BHX.js";import"./chunk-UR6MHSHU.js";export{a as LoginFlow};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{u as P,v as D,w as U,x as V,y as H}from"./chunk-DTFPHZE7.js";import"./chunk-UVBDUDSL.js";import{a as k,b as T}from"./chunk-L3RTVAPG.js";import{b as y,c as _}from"./chunk-3C7ATCDM.js";import{a as A}from"./chunk-HN7DVSVI.js";import"./chunk-AH4AXJML.js";import"./chunk-PN7LNQ7G.js";import"./chunk-C5UNZ6ZY.js";import"./chunk-S3DAAAE5.js";import"./chunk-6NEJEMA6.js";import"./chunk-MDBXYXSC.js";import{b as x}from"./chunk-SJ7VGRQU.js";import"./chunk-L5LI2JF4.js";import{a as S}from"./chunk-UJZCMEEH.js";import{d as C,e as E,f as L}from"./chunk-LRF6UP42.js";import"./chunk-VE3SUJMA.js";import{a as h}from"./chunk-7G7ZLAJH.js";import"./chunk-BPF7TDRU.js";import"./chunk-WAOCHXJ5.js";import{a as v}from"./chunk-J37YPPCD.js";import"./chunk-E47GFYXA.js";import"./chunk-3Z4EHIOW.js";import"./chunk-7CLUJYMW.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import"./chunk-UR6MHSHU.js";import{resolve as K}from"path";import{existsSync as $}from"fs";function b(a){let{isAgent:r,log:i}=a,c=e=>{r&&process.stdout.write(JSON.stringify(e)+`
|
|
3
|
-
`)};return{async runSteps(e){let{default:o}=await import("./react-QWOAB3TB.js"),{render:n}=await import("./build-JIKYOZUH.js"),{TestMdRunView:s}=await import("./TestMdRunView-PPZPUVVZ.js"),{waitUntilExit:m}=n(o.createElement(s,e),{stdout:process.stderr,exitOnCtrlC:!1});await m()},async runUpload(e,o){let{renderUploadProgress:n}=await import("./CliUploadProgress-QP5SPC7G.js");return await n(e,o)},async onSummary(e){try{let{default:o}=await import("./react-QWOAB3TB.js"),{render:n}=await import("./build-JIKYOZUH.js"),{AutoExitSummaryBox:s}=await import("./SummaryBox-5Y2YYOUM.js"),{waitUntilExit:m}=n(o.createElement(s,{data:e}),{stdout:process.stderr});await m()}catch(o){i("warn","TEST_MD_SUMMARY_RENDER_FAILED","Summary box render failed",{error:String(o)})}},async onLinks(e){try{let{default:o}=await import("./react-QWOAB3TB.js"),{render:n}=await import("./build-JIKYOZUH.js"),{LinksBox:s}=await import("./LinksBox-NUSUOUIW.js"),{waitUntilExit:m}=n(o.createElement(s,e),{stdout:process.stderr});await m()}catch(o){i("warn","TEST_MD_LINKS_RENDER_FAILED","LinksBox render failed",{error:String(o)})}},onLockState(e){c({type:"test_md_lock_state",...e})},onRetryAttempt(e){c({type:"test_md_retry_attempt",...e})},onAgentEvent(e){c(e)}}}function M(){return{register:(a,r)=>C(a,r),deregister:a=>E(a),cleanup:(a,r)=>L(a,r),remoteLogger:null}}async function le(a,r){let i=K(a);if(!$(i))return process.stderr.write(`error: file not found: ${i}
|
|
4
|
-
`),2;k(i);let c=!process.stdin.isTTY||!!r.agent,e=M(),o;try{o=A(i)}catch(t){return process.stderr.write(`error: ${t.message}
|
|
5
|
-
`),2}if(o.steps.length===0)return process.stderr.write(`info: no steps in ${i}; nothing to run.
|
|
6
|
-
`),0;let n;try{n=Y(r)}catch(t){if(t instanceof p)return process.stderr.write(t.message),t.exitCode;throw t}let s=new h,m=new S,d=!!(r.username&&r.accessKey);await T({isInteractive:!!process.stdin.isTTY&&!r.agent&&!d,creds:s,config:m});let j=s.getActiveProfile()??"default",u=r.env??void 0??s.getDefaultEnv()??"prod",N=v(u),F="v16-alpha",f;try{f=await _({creds:s,env:u,usernameFlag:r.username,accessKeyFlag:r.accessKey,log:()=>{}})}catch(t){return t instanceof y&&t.code==="not_authenticated"?process.stderr.write(`error: Not authenticated. Choose one:
|
|
7
|
-
\u2022 Pass credentials inline: --username <user> --access-key <key>
|
|
8
|
-
\u2022 Run 'kane-cli login --oauth' (browser-based)
|
|
9
|
-
\u2022 Run 'kane-cli login --username <user> --access-key <key>'
|
|
10
|
-
`):t instanceof y&&t.code==="refresh_failed"?process.stderr.write(`error: Token refresh failed. Run 'kane-cli login' to re-authenticate.
|
|
11
|
-
`):process.stderr.write(`error: auth resolution failed: ${t.message}
|
|
12
|
-
`),2}let w=String(f.resolvedCreds?.org_id??"");if(!w)return process.stderr.write("error: TMS did not return an org_id. Run `kane-cli login` again.\n"),2;{let{readMetaIfExists:t,assertOrgMatchOrExit:g}=await import("./testmd-actions-IZPOBSTC.js"),l=g(t(i),w);if(l!==null)return l}let R=new x,I=b({isAgent:c,log:(t,g,l,B)=>R.log(t,g,l,B)}),O={path:i,cwd:process.cwd(),opts:r,isAgent:c,resolved:o,resolvedAuth:f,cliOverrides:n,environment:u,envConfig:N,profile:j,model:F,creds:s,configStore:m,session:R};try{return(await P(O,I,e)).exitCode}catch(t){return process.stderr.write(`error: ${t.message}
|
|
13
|
-
`),2}}var p=class extends Error{constructor(i,c){super(i);this.exitCode=c;this.name="CliArgError"}};function Y(a){let r={mode:"mode",maxSteps:"max_steps",timeout:"timeout",globalContext:"global_context",localContext:"local_context",codeExport:"code_export",codeLanguage:"code_language",headless:"headless",cdpEndpoint:"cdp_endpoint",wsEndpoint:"ws_endpoint"},i=new Set(["max_steps","timeout"]),c={};for(let[e,o]of Object.entries(r)){let n=a[e];if(n===void 0||n==="")continue;let s=n;if(i.has(o)&&(s=Number(n),Number.isNaN(s))){let m="--"+e.replace(/[A-Z]/g,d=>"-"+d.toLowerCase());throw new p(`error: ${m} must be a number
|
|
14
|
-
`,2)}c[o]=s}return c}export{H as applyCliStepConfig,U as buildStepRunVariables,D as buildTestLevelVariables,V as replayVariablesForStep,le as runTestMdFile};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createRequire } from 'module'; const require = createRequire(import.meta.url);
|
|
2
|
-
import{c as r}from"./chunk-JLOY7SNA.js";import"./chunk-3MSXQU2C.js";import"./chunk-H6OVTXJQ.js";import"./chunk-H4XV224I.js";import"./chunk-DTFPHZE7.js";import"./chunk-UVBDUDSL.js";import"./chunk-JCR3T34A.js";import"./chunk-L3RTVAPG.js";import"./chunk-3C7ATCDM.js";import"./chunk-CGAX3AXA.js";import"./chunk-HN7DVSVI.js";import"./chunk-AH4AXJML.js";import"./chunk-BKXTOQWL.js";import"./chunk-PN7LNQ7G.js";import"./chunk-6IQWD272.js";import"./chunk-VS2BXLH4.js";import"./chunk-IH45REQA.js";import"./chunk-XQXSPUIX.js";import"./chunk-C5UNZ6ZY.js";import"./chunk-S3DAAAE5.js";import"./chunk-6NEJEMA6.js";import"./chunk-MDBXYXSC.js";import"./chunk-O2UU4TS5.js";import"./chunk-M5RHRHFC.js";import"./chunk-SJ7VGRQU.js";import"./chunk-L5LI2JF4.js";import"./chunk-UJZCMEEH.js";import"./chunk-LRF6UP42.js";import"./chunk-PWHFNSDC.js";import"./chunk-CKY3UXTY.js";import"./chunk-YCCUBQY4.js";import"./chunk-TAEW7PXN.js";import"./chunk-VE3SUJMA.js";import"./chunk-7G7ZLAJH.js";import"./chunk-BPF7TDRU.js";import"./chunk-WAOCHXJ5.js";import"./chunk-J37YPPCD.js";import"./chunk-E47GFYXA.js";import"./chunk-5TOE4RHH.js";import"./chunk-VTDVK3DK.js";import"./chunk-LMV2F35W.js";import"./chunk-HYVAYSRZ.js";import"./chunk-AT2Y5UNP.js";import{a as t}from"./chunk-HCBYKLMW.js";import"./chunk-3Z4EHIOW.js";import{c as n}from"./chunk-C44QQJR4.js";import"./chunk-6YGTRKDT.js";import"./chunk-7CLUJYMW.js";import"./chunk-NLCCBXXV.js";import"./chunk-RZ4F3BHX.js";import{e}from"./chunk-UR6MHSHU.js";var a=e(t(),1);async function f(i){let o=i.scenarioLimit!==void 0||i.perScenarioLimit!==void 0?{scenarioLimit:i.scenarioLimit,perScenarioLimit:i.perScenarioLimit}:void 0,{waitUntilExit:m}=n((0,a.jsx)(r,{initialChatMode:"generate",initialObjective:i.objective,initialGenerateLimits:o}),{exitOnCtrlC:!1});await m()}export{f as runGenerate};
|