fluxflow-cli 4.23.5 → 4.24.0

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.
Files changed (67) hide show
  1. package/dist/chunks/{addMemScore-COX3MDEK.js → addMemScore-PWP7GFSP.js} +1 -1
  2. package/dist/chunks/{ai-IOEGZWGA.js → ai-NFNMNHUW.js} +1 -1
  3. package/dist/chunks/{app-OWHF6FXI.js → app-KJGLCANP.js} +142 -142
  4. package/dist/chunks/{chat-J5AAPLPF.js → chat-7T6MVHC3.js} +1 -1
  5. package/dist/chunks/{chunk-BSUDXEA2.js → chunk-3CZWTXIR.js} +1 -1
  6. package/dist/chunks/{chunk-CXNFFI7L.js → chunk-3LTI7Z7N.js} +1 -1
  7. package/dist/chunks/{chunk-7UNVYHZ7.js → chunk-4XXLWMY6.js} +1 -1
  8. package/dist/chunks/{chunk-COUKJJ4O.js → chunk-6AWSJNXE.js} +14 -14
  9. package/dist/chunks/{chunk-P52SKLRJ.js → chunk-7SFAWGE2.js} +1 -1
  10. package/dist/chunks/{chunk-WMRT2YZU.js → chunk-AF7LASZ3.js} +1 -1
  11. package/dist/chunks/chunk-DSVLWYIT.js +2 -0
  12. package/dist/chunks/{chunk-IRFTRBG2.js → chunk-FQBBOFNP.js} +1 -1
  13. package/dist/chunks/{chunk-OOTXMJIA.js → chunk-GRQ7JZZP.js} +1 -1
  14. package/dist/chunks/{chunk-U6UKO6MO.js → chunk-JCT3YL5A.js} +1 -1
  15. package/dist/chunks/chunk-JQ5Y2VZD.js +914 -0
  16. package/dist/chunks/{chunk-6KFABN4O.js → chunk-KNCL7AK2.js} +1 -1
  17. package/dist/chunks/{chunk-QGPOMXO4.js → chunk-OSDQRSY6.js} +1 -1
  18. package/dist/chunks/{chunk-HRKT75ZJ.js → chunk-PQRLA35M.js} +15 -15
  19. package/dist/chunks/{chunk-2KD7V3OK.js → chunk-RZTZPIC5.js} +1 -1
  20. package/dist/chunks/{chunk-RLT6EHPQ.js → chunk-SZYN3VHU.js} +1 -1
  21. package/dist/chunks/{chunk-Z4HHJIHG.js → chunk-VYTQ6J56.js} +1 -1
  22. package/dist/chunks/{chunk-UDJ2C3N3.js → chunk-ZRP6USHC.js} +28 -28
  23. package/dist/chunks/{click-HS7NJR6J.js → click-5ZKBFZ4N.js} +2 -2
  24. package/dist/chunks/{computer_action-YCFAAZNA.js → computer_action-7U3W3F6L.js} +1 -1
  25. package/dist/chunks/{drag-SBWNKGDV.js → drag-YHHKJGL6.js} +1 -1
  26. package/dist/chunks/{emergency_rollback-6M5EH75W.js → emergency_rollback-DXN5WNPR.js} +1 -1
  27. package/dist/chunks/{exec_command-27EPEAE5.js → exec_command-GVLMN5KT.js} +1 -1
  28. package/dist/chunks/export-DEFENSGY.js +1 -0
  29. package/dist/chunks/{file_map-XK7BFZFI.js → file_map-KS6Y7BP3.js} +1 -1
  30. package/dist/chunks/find_file-A6NYLQJS.js +4 -0
  31. package/dist/chunks/{generate_image-S6M2GCD7.js → generate_image-HVWLRINC.js} +1 -1
  32. package/dist/chunks/{getProgress-VG2IBPZU.js → getProgress-A2TW34Q7.js} +2 -2
  33. package/dist/chunks/{invoke-GKLK35YP.js → invoke-A65SLWMF.js} +4 -4
  34. package/dist/chunks/{invokeSync-7PK3CJVJ.js → invokeSync-KP33D2NU.js} +2 -2
  35. package/dist/chunks/{key_press-BT6QQ24M.js → key_press-ZZNA3PF3.js} +1 -1
  36. package/dist/chunks/{keyboard_typing-IWKUCQE4.js → keyboard_typing-QL3DF67Z.js} +1 -1
  37. package/dist/chunks/{memory-5CNSGF6X.js → memory-SRDCQNML.js} +1 -1
  38. package/dist/chunks/{model_config-UZLNHYP5.js → model_config-M24OEKJE.js} +1 -1
  39. package/dist/chunks/paths-2EXHWUSL.js +1 -0
  40. package/dist/chunks/{read_folder-OOKZITME.js → read_folder-EI2CNHNS.js} +5 -5
  41. package/dist/chunks/{saveSummary-XQ2STWSN.js → saveSummary-VKGBD4CG.js} +1 -1
  42. package/dist/chunks/{screen_grid-YL4W6LEM.js → screen_grid-GBIGOR5Q.js} +1 -1
  43. package/dist/chunks/{scroll-TA2JTVSR.js → scroll-C4Z57VQS.js} +1 -1
  44. package/dist/chunks/search_keyword-CSRQFPHQ.js +6 -0
  45. package/dist/chunks/{secrets-BJGXCZRP.js → secrets-LPVNWDTB.js} +1 -1
  46. package/dist/chunks/settings-KKYNW25D.js +1 -0
  47. package/dist/chunks/{todo-C5HHG7TN.js → todo-VG2CVRUI.js} +1 -1
  48. package/dist/chunks/{update_file-2YCGNOBP.js → update_file-WTXXQ4RB.js} +1 -1
  49. package/dist/chunks/{usage-6BBHZ76S.js → usage-VLICZGBC.js} +1 -1
  50. package/dist/chunks/usageServer-HY4ME2BW.js +1 -0
  51. package/dist/chunks/view_file-2THVIMD6.js +1 -0
  52. package/dist/chunks/{web_scrape-LAQI7CVA.js → web_scrape-BHSQTMX4.js} +1 -1
  53. package/dist/chunks/{web_search-D2GOWARI.js → web_search-2PFIJKIL.js} +1 -1
  54. package/dist/chunks/{write_docx-J5OO4ZSE.js → write_docx-I7T3575T.js} +1 -1
  55. package/dist/chunks/{write_file-MDPZMOG3.js → write_file-V6HKMWFB.js} +1 -1
  56. package/dist/chunks/{write_pdf-KF7HZODR.js → write_pdf-XDDKM7V5.js} +1 -1
  57. package/dist/cli.js +8 -8
  58. package/dist/package.json +1 -1
  59. package/package.json +1 -1
  60. package/dist/chunks/chunk-5LRTKLA4.js +0 -923
  61. package/dist/chunks/chunk-RI37VZYB.js +0 -1
  62. package/dist/chunks/export-YTWRQ63I.js +0 -1
  63. package/dist/chunks/paths-Y7ACZJAE.js +0 -1
  64. package/dist/chunks/search_keyword-EAMQWPPI.js +0 -8
  65. package/dist/chunks/settings-ZDBO3FHN.js +0 -1
  66. package/dist/chunks/usageServer-CSS2XQH3.js +0 -1
  67. package/dist/chunks/view_file-4UCCUBFK.js +0 -1
@@ -1,95 +1,95 @@
1
- import{B as sl,C as il,D as ll,a as Yi,b as Je,c as nt,d as Cr,e as Ht,f as Ki,g as qi,h as vr,i as zi,j as ys,k as Jo,l as Dr,v as nl,y as rl,z as Kn}from"./chunk-5LRTKLA4.js";import{b as Ri,c as el,d as tl}from"./chunk-RLT6EHPQ.js";import{a as ol}from"./chunk-56EJGQU3.js";import"./chunk-P52SKLRJ.js";import{c as Vi,e as Sn,f as jt,g as ji}from"./chunk-CXNFFI7L.js";import"./chunk-HRKT75ZJ.js";import{a as Zi}from"./chunk-A73NNVCZ.js";import{a as Fo,b as Cn,d as Er,e as Ts,f as Qi,h as Ji,i as jn}from"./chunk-Z4HHJIHG.js";import"./chunk-2KD7V3OK.js";import{a as Et,b as xt,d as Xi,e as ht,f as Gi,j as bs,k as ws,l as Wn,n as Wi,o as Co}from"./chunk-UDJ2C3N3.js";import{a as Vn}from"./chunk-IRFTRBG2.js";import{a as Yn}from"./chunk-Y5JU726N.js";import{b as Mn,c as fs,k as Ni}from"./chunk-BSUDXEA2.js";import{b as ps}from"./chunk-WMRT2YZU.js";import{a as Fi,b as Ui,f as $i,g as Mr,h as Sr,j as vt,k as Qo,l as hs,r as _i}from"./chunk-7UNVYHZ7.js";import{a as xs,b as Pt}from"./chunk-OOTXMJIA.js";import{d as Bi,e as ki,f as Ii,g as Ai,h as Li,i as Pi,k as yr,m as No,n as go,o as Oi}from"./chunk-QGPOMXO4.js";import{c as wr,d as Di,e as Tr}from"./chunk-L3W2X74K.js";import{e as Hi}from"./chunk-COUKJJ4O.js";import{a as ro,b as zo,c as mo,d as ms,e as gs,k as Gn}from"./chunk-RI37VZYB.js";import Ys from"os";import e,{useState as J,useEffect as rt,useRef as Ke,useMemo as kn}from"react";import{Box as c,Text as l,useInput as Kd,useStdout as qd,Static as zd}from"ink";import Qd from"ink-spinner";import et from"fs-extra";import St from"path";import{exec as To}from"child_process";import{fileURLToPath as Jd}from"url";import Ut,{useState as Br,useEffect as Ms,useMemo as qn,useCallback as ba,useRef as vo}from"react";import{Box as wa,Text as so,useInput as Ta}from"ink";function ya(t,m){return t.replace(/\t/g," ".repeat(m))}function kr(t){return t==null?"":t.replace(/\r\n/g,`
1
+ import{B as sl,C as il,D as ll,a as Yi,b as Je,c as nt,d as Cr,e as Ht,f as Ki,g as qi,h as vr,i as zi,j as ys,k as Jo,l as Br,v as nl,y as rl,z as Kn}from"./chunk-JQ5Y2VZD.js";import{b as Ri,c as el,d as tl}from"./chunk-SZYN3VHU.js";import{a as ol}from"./chunk-56EJGQU3.js";import"./chunk-7SFAWGE2.js";import{c as Vi,e as Sn,f as jt,g as ji}from"./chunk-3LTI7Z7N.js";import"./chunk-PQRLA35M.js";import{a as Zi}from"./chunk-A73NNVCZ.js";import{a as Fo,b as Cn,d as Er,e as ws,f as Qi,h as Ji,i as jn}from"./chunk-VYTQ6J56.js";import"./chunk-RZTZPIC5.js";import{a as Et,b as xt,d as Xi,e as ht,f as Wi,j as bs,k as Ts,l as Gn,n as Gi,o as Co}from"./chunk-ZRP6USHC.js";import{a as Vn}from"./chunk-FQBBOFNP.js";import{a as Yn}from"./chunk-Y5JU726N.js";import{b as Mn,c as fs,k as Ni}from"./chunk-3CZWTXIR.js";import{b as ps}from"./chunk-AF7LASZ3.js";import{a as Fi,b as Ui,f as $i,g as Mr,h as Sr,j as vt,k as Qo,l as hs,r as _i}from"./chunk-4XXLWMY6.js";import{a as xs,b as Pt}from"./chunk-GRQ7JZZP.js";import{d as Di,e as ki,f as Ii,g as Ai,h as Li,i as Pi,k as yr,m as No,n as go,o as Oi}from"./chunk-OSDQRSY6.js";import{c as Tr,d as Bi,e as wr}from"./chunk-L3W2X74K.js";import{e as Hi}from"./chunk-6AWSJNXE.js";import{a as ro,b as zo,c as mo,d as ms,e as gs,k as Wn}from"./chunk-DSVLWYIT.js";import Ys from"os";import e,{useState as J,useEffect as rt,useRef as Ke,useMemo as kn}from"react";import{Box as c,Text as l,useInput as Kd,useStdout as qd,Static as zd}from"ink";import Qd from"ink-spinner";import et from"fs-extra";import St from"path";import{exec as wo}from"child_process";import{fileURLToPath as Jd}from"url";import Ut,{useState as Dr,useEffect as Ms,useMemo as qn,useCallback as ba,useRef as vo}from"react";import{Box as Ta,Text as so,useInput as wa}from"ink";function ya(t,m){return t.replace(/\t/g," ".repeat(m))}function kr(t){return t==null?"":t.replace(/\r\n/g,`
2
2
  `).replace(/\r/g,`
3
3
  `)}function Zo(t,m,h){let y=t,T=[...m].sort((s,k)=>s.start-k.start),b=0;for(let s of T){let k=s.start-b,f=kr(s.text).split(`
4
- `).length,I=s.text.length,A=(f>3?`[Pasted ${f} lines]`:`[Pasted ${I} chars]`).length,X=k+A;if(t<=k)break;if(t<X){y=s.end;break}else{let S=s.text.length-A;y+=S,b+=S}}return Math.min(y,h.length)}function Ss(t,m,h,y,T=[]){let b=(t||"").slice(0,m),s=y(b).length,k=y(t||""),f=[...T].sort((N,L)=>L.start-N.start);for(let N of f){let L=y(t.slice(0,N.start)).length,_=y(N.text),q=L+_.length,ge=kr(N.text).split(`
5
- `).length,Me=N.text.length,re=ge>3?`[Pasted ${ge} lines]`:`[Pasted ${Me} chars]`;k=k.slice(0,L)+re+k.slice(q),s>L&&s<q?s=L+re.length:s>=q&&(s=s-(q-L)+re.length)}let I=k.split(`
6
- `),A=[],X=0,S=0,C=0,P=!1;for(let N=0;N<I.length;N++){let L=I[N];if(L.length===0){!P&&s===X&&(S=A.length,C=0,P=!0),A.push({text:"",globalStart:Zo(X,T,t),formattedStart:X}),X+=1;continue}let q=xt(L,h).split(`
7
- `),ge=0,Me=[];for(let re=0;re<q.length;re++){let ie=q[re],pe=ie.trim();if(pe.length===0){let De=ie.length||1;Me.push({text:ie,start:ge,length:De}),ge+=De}else{let De=L.indexOf(pe,ge);if(De!==-1){let ve=ge,Ue=re<q.length-1?q[re+1].trim():"",le=L.length;if(Ue.length>0){let Ie=L.indexOf(Ue,De+pe.length);Ie!==-1&&(le=Ie)}Me.push({text:L.slice(ve,le),start:ve,length:le-ve}),ge=le}else Me.push({text:ie,start:ge,length:ie.length}),ge+=ie.length}}for(let re=0;re<Me.length;re++){let ie=Me[re],pe=ie.text,De=X+ie.start,ve=De+ie.length;!P&&s>=De&&(s<ve||s===ve&&re===Me.length-1)&&(S=A.length,C=s-De,P=!0),A.push({text:pe,globalStart:Zo(De,T,t),formattedStart:De})}X+=L.length+1}return P||(A.length===0?A.push({text:"",globalStart:0,formattedStart:0}):k.endsWith(`
8
- `)?(A.push({text:"",globalStart:Zo(X,T,t),formattedStart:X}),S=A.length-1,C=0):(S=A.length-1,C=A[S].text.length)),{visualLines:A,cursorLine:S,cursorCol:C}}var Ma=({value:t,rows:m,maxRows:h,highlightStyle:y,textStyle:T,placeholder:b="",mask:s,showCursor:k=!0,focus:f=!0,tabSize:I=4,cursorIndex:A=0,highlight:X,columns:S=80,pasteBlocks:C=[],cursorColor:P})=>{let N=vo(0),L=qn(()=>Math.max(20,S-10),[S]),_=ba((Ge,me=!1)=>{let R=kr(Ge);if(!me&&s)return R.replace(/[^\n]/g,s);let te=ya(R,I);return me?te:te.replace(/@\[(.*?)\]/g,(Z,ae)=>{let fe=ae.indexOf("#"),he=ae.indexOf(":L"),Ae=ae,at="";fe!==-1?(Ae=ae.slice(0,fe),at=ae.slice(fe)):he!==-1&&(Ae=ae.slice(0,he),at=ae.slice(he));let Ze=Ae.replace(/\\/g,"/"),Ee=(process.cwd()||"").replace(/\\/g,"/");Ee&&Ze.toLowerCase().startsWith(Ee.toLowerCase()+"/")?Ze=Ze.slice(Ee.length+1):Ze.startsWith("./")&&(Ze=Ze.slice(2));let oe=Ze.split("/");return`[${oe[oe.length-1]}${at}]`})},[I,s]),{visualLines:q,cursorLine:ge,cursorCol:Me}=qn(()=>Ss(t,A,L,_,C),[t,A,L,_,C]),re=q.length,ie=qn(()=>Math.max(m??h??1,Math.min(h??m??1,re)),[m,h,re]),pe=ge+1,De=N.current+ie,ve=N.current;pe<=N.current?ve=Math.max(0,pe-1):pe>De?ve=pe-ie:re&&(re<ie?ve=0:re<De&&(ve=re-ie)),N.current=ve;let Ue=qn(()=>q.slice(ve,ve+ie),[q,ve,ie]),[le,Ie]=Br(!0);Ms(()=>{if(Ie(!0),!f||!k)return;let Ge=setInterval(()=>{Ie(me=>!me)},530);return()=>clearInterval(Ge)},[f,k,t,A]);let be=qn(()=>({...T,color:k&&f&&le?P||"white":void 0,bold:k&&f&&le,inverse:k&&f&&le}),[T,k,f,le,P]),ee=(Ge,me,R,te)=>{if(!Ge){let Ae=b&&t.length===0?_(b,!0):"";if(me){let at=Ae[0]||" ",Ze=Ae.slice(1);return Ut.createElement(so,null,Ut.createElement(so,{...te},at),Ut.createElement(so,{color:"gray",dimColor:!0},Ze))}return Ut.createElement(so,{color:"gray",dimColor:!0},Ae||" ")}let Z=/(\[Pasted \d+ (?:lines|chars)\])/g,ae=Ge.split(Z),fe=0,he=[];for(let Ae=0;Ae<ae.length;Ae++){let at=ae[Ae];if(at==="")continue;let Ze=at.match(/^\[Pasted \d+ (?:lines|chars)\]$/),Ee=at.length,oe=fe+Ee;if(me&&R>=fe&&R<oe){let ce=R-fe,Ce=at.slice(0,ce),B=at[ce]||" ",$e=at.slice(ce+1);he.push(Ut.createElement(so,{key:Ae},Ut.createElement(so,{color:Ze?"magenta":void 0},Ce),Ut.createElement(so,{...te},B),Ut.createElement(so,{color:Ze?"magenta":void 0},$e)))}else he.push(Ut.createElement(so,{key:Ae,color:Ze?"magenta":void 0},at));fe=oe}return me&&R>=Ge.length&&he.push(Ut.createElement(so,{key:"cursor-end",...te}," ")),Ut.createElement(Ut.Fragment,null,he)};return Ut.createElement(wa,{height:ie,width:L+1,overflow:"hidden",flexDirection:"column",flexGrow:0,flexShrink:0},Ue.map((Ge,me)=>{let R=ve+me,te=R===ge&&f&&k;return Ut.createElement(so,{key:R,...T,wrap:"truncate"},ee(Ge.text,te,Me,be))}))},al=({value:t,onChange:m,onSubmit:h,keyBindings:y,showCursor:T=!0,highlightPastedText:b=!1,focus:s=!0,columns:k=80,useCustomInput:f=(S,C)=>Ta(S,{isActive:C}),onPasteStateChange:I,cursorColor:A,...X})=>{let[S,C]=Br(t.length),[P,N]=Br(0),[L,_]=Br([]),q=vo(t.length),ge=vo(t),Me=vo(0),re=vo([]),ie=vo(""),pe=vo(-1),De=vo(null),ve=vo(0);q.current=S,ge.current=t,Me.current=P,re.current=L,Ms(()=>{q.current>t.length&&(q.current=t.length,C(t.length)),t?_(Ie=>Ie.filter(be=>be.end<=t.length&&be.start<=t.length)):(_([]),N(0))},[t]),Ms(()=>{I?.(L.length>0)},[L,I]);let Ue=()=>{let Ie=ie.current,be=pe.current,ee=be+Ie.length,Ge=ge.current,me=Ge.slice(0,be)+Ie+Ge.slice(be);m(me),q.current=ee,C(ee),N(Ie.length>1?Ie.length:0);let R=kr(Ie).split(`
9
- `).length,te=Ie.length;if(te>50&&(R>3||R<=3&&te>200)){let Z={start:be,end:ee,text:Ie};_(ae=>{let fe=Ie.length;return[...ae.map(Ae=>be<=Ae.start?{...Ae,start:Ae.start+fe,end:Ae.end+fe}:Ae),Z]})}ie.current="",pe.current=-1,De.current=null},le=()=>{De.current&&(clearTimeout(De.current),Ue())};return f((Ie,be)=>{if(Ie==="\x1B[I"||Ie==="\x1B[O"||Ie==="[I"||Ie==="[O")return;let ee=Ie,Ge=!1,me=!1;ee&&typeof ee=="string"&&(ee.includes("\x1B[200~")&&(Ge=!0,ee=ee.replace(/\x1b\[200~/g,"")),ee.includes("\x1B[201~")&&(me=!0,ee=ee.replace(/\x1b\[201~/g,"")));let R=q.current,te=ge.current,Z=re.current,ae=Math.max(20,k-10),fe=(oe,ce)=>{if(Z.length===0)return;let Ce=Z.map(B=>oe<=B.start?{...B,start:B.start+ce,end:B.end+ce}:oe>B.start&&oe<B.end?null:B).filter(Boolean);_(Ce)},he=oe=>{for(let ce of Z)if(oe>ce.start&&oe<ce.end)return ce.start;return oe};if(be.ctrl&&(ee==="o"||ee==="")){_([]);return}if(be.ctrl&&(ee.toLowerCase()==="r"||ee===""||ee===""))return;if(be.upArrow||be.downArrow||be.leftArrow||be.rightArrow){le();let oe=Date.now();if(oe-ve.current<33)return;ve.current=oe}let at=y?.submit??(oe=>oe.return&&oe.ctrl),Ze=y?.newline??(oe=>oe.return);if(at(be)){le(),h?.(te);return}else if(Ze(be)){le(),fe(R,1);let oe=te.slice(0,R)+`
10
- `+te.slice(R);m(oe),q.current=R+1,C(R+1),N(0);return}if(be.tab||be.shift&&be.tab||be.ctrl&&ee==="c")return;let Ee=oe=>oe;if(be.upArrow||be.downArrow){if(le(),T){let{visualLines:oe,cursorLine:ce,cursorCol:Ce}=Ss(te,R,ae,Ee,Z),B=be.upArrow?ce-1:ce+1;if(B>=0&&B<oe.length){let $e=oe[B],qe=Math.min(Ce,$e.text.length),Ct=$e.formattedStart+qe,Wt=Zo(Ct,Z,te);Wt=he(Wt),q.current=Wt,C(Wt),N(0)}else if(be.upArrow&&ce===0)q.current=0,C(0),N(0);else if(be.downArrow&&ce===oe.length-1){let $e=oe[oe.length-1],qe=$e.formattedStart+$e.text.length,Ct=Zo(qe,Z,te);Ct=he(Ct),q.current=Ct,C(Ct),N(0)}}}else if(be.leftArrow){if(le(),T){let oe=Math.max(0,R-1),ce=Z.find(Ce=>R===Ce.end);ce&&(oe=ce.start),q.current=oe,C(oe),N(0)}}else if(be.rightArrow){if(le(),T){let oe=Math.min(te.length,R+1),ce=Z.find(Ce=>R===Ce.start);ce&&(oe=ce.end),q.current=oe,C(oe),N(0)}}else if(be.backspace){le();let oe=Z.findIndex(ce=>R===ce.end);if(oe!==-1){let ce=Z[oe],Ce=-(ce.end-ce.start),B=te.slice(0,ce.start)+te.slice(ce.end);m(B),q.current=ce.start,C(ce.start),N(0);let $e=Z.filter((qe,Ct)=>Ct!==oe).map(qe=>qe.start>=ce.end?{...qe,start:qe.start+Ce,end:qe.end+Ce}:qe);_($e)}else if(R>0){fe(R-1,-1);let ce=te.slice(0,R-1)+te.slice(R);m(ce),q.current=R-1,C(R-1),N(0)}}else if(be.delete){le();let oe=Z.findIndex(ce=>R===ce.start);if(oe!==-1){let ce=Z[oe],Ce=-(ce.end-ce.start),B=te.slice(0,ce.start)+te.slice(ce.end);m(B),N(0);let $e=Z.filter((qe,Ct)=>Ct!==oe).map(qe=>qe.start>=ce.end?{...qe,start:qe.start+Ce,end:qe.end+Ce}:qe);_($e)}else if(fe(R,-1),R<te.length){let ce=te.slice(0,R)+te.slice(R+1);m(ce),N(0)}}else if(be.home||be.end){if(le(),T){let{visualLines:oe,cursorLine:ce}=Ss(te,R,ae,Ee,Z),Ce=oe[ce];if(Ce){let B;be.home?B=Zo(Ce.formattedStart,Z,te):be.end&&(B=Zo(Ce.formattedStart+Ce.text.length,Z,te)),B=he(B),q.current=B,C(B),N(0)}}}else if(ee!==""||Ge||me)if(Ge||me||ee.length>1||De.current!==null)De.current?(clearTimeout(De.current),ie.current+=ee):(pe.current=R,ie.current=ee),me?(De.current=null,Ue()):De.current=setTimeout(()=>{Ue()},80);else{fe(R,ee.length);let ce=te.slice(0,R)+ee+te.slice(R);m(ce);let Ce=R+ee.length;q.current=Ce,C(Ce),N(0)}},s),Ut.createElement(Ma,{...X,value:t,cursorIndex:S,showCursor:T,focus:s,columns:k,pasteBlocks:L,cursorColor:A})};import Ur from"ink-text-input";import"ink-select-input";import r from"react";import{Box as E,Text as ne}from"ink";import Tt,{useState as dl,useEffect as Sa}from"react";import{Box as Eo,Text as io,useInput as Ca}from"ink";var Ir=Tt.memo(({command:t,output:m,completed:h=!1,isFocused:y=!1,columns:T=80,isPty:b=!1,terminalHeight:s=24,theme:k="Dark"})=>{let f=Je(k),A=(te=>{if(!te)return"";let Z=[[]],ae=0,fe=0,he="",Ae=/\x1b\[([0-9;]*?)([a-zA-Z])/g,at=0,Ze,Ee=ce=>{for(let Ce=0;Ce<ce.length;Ce++){let B=ce[Ce];if(B===`
11
- `)for(ae++,fe=0;ae>=Z.length;)Z.push([]);else if(B==="\r")fe=0;else{for(;ae>=Z.length;)Z.push([]);let $e=Z[ae];for(;fe>$e.length;)$e.push({char:" ",style:""});$e[fe]={char:B,style:he},fe++}}};for(;(Ze=Ae.exec(te))!==null;){Ee(te.substring(at,Ze.index));let ce=Ze[1],Ce=Ze[2],B=ce?ce.split(";").map(Number):[];if(Ce==="A"){let $e=B[0]||1;ae=Math.max(0,ae-$e)}else if(Ce==="B"){let $e=B[0]||1;for(ae=ae+$e;ae>=Z.length;)Z.push([])}else if(Ce==="C"){let $e=B[0]||1;fe=fe+$e}else if(Ce==="D"){let $e=B[0]||1;fe=Math.max(0,fe-$e)}else if(Ce==="G"){let $e=(B[0]||1)-1;fe=Math.max(0,$e)}else if(Ce==="H"||Ce==="f"){let $e=(B[0]||1)-1,qe=(B[1]||1)-1;for(ae=Math.max(0,$e),fe=Math.max(0,qe);ae>=Z.length;)Z.push([])}else if(Ce==="K"){let $e=B[0]||0;if(ae<Z.length){let qe=Z[ae];if($e===0)qe.length=fe;else if($e===1)for(let Ct=0;Ct<fe&&Ct<qe.length;Ct++)qe[Ct]={char:" ",style:""};else $e===2&&(qe.length=0)}}else if(Ce==="J"){let $e=B[0]||0;($e===2||$e===3)&&(Z.length=0,Z.push([]),ae=0,fe=0)}else if(Ce==="m"){let $e=Ze[0];$e==="\x1B[0m"?he="":he=$e}at=Ae.lastIndex}Ee(te.substring(at));let oe=Z.map(ce=>{let Ce="",B="";for(let $e=0;$e<ce.length;$e++){let qe=ce[$e]||{char:" ",style:""};qe.style!==B&&(B&&(Ce+="\x1B[0m"),Ce+=qe.style,B=qe.style),Ce+=qe.char}return B&&(Ce+="\x1B[0m"),Ce});for(;oe.length>0&&oe[oe.length-1]==="";)oe.pop();return oe.join(`
4
+ `).length,I=s.text.length,A=(f>3?`[Pasted ${f} lines]`:`[Pasted ${I} chars]`).length,X=k+A;if(t<=k)break;if(t<X){y=s.end;break}else{let S=s.text.length-A;y+=S,b+=S}}return Math.min(y,h.length)}function Ss(t,m,h,y,T=[]){let b=(t||"").slice(0,m),s=y(b).length,k=y(t||""),f=[...T].sort((N,L)=>L.start-N.start);for(let N of f){let L=y(t.slice(0,N.start)).length,_=y(N.text),Q=L+_.length,ge=kr(N.text).split(`
5
+ `).length,ye=N.text.length,se=ge>3?`[Pasted ${ge} lines]`:`[Pasted ${ye} chars]`;k=k.slice(0,L)+se+k.slice(Q),s>L&&s<Q?s=L+se.length:s>=Q&&(s=s-(Q-L)+se.length)}let I=k.split(`
6
+ `),A=[],X=0,S=0,C=0,P=!1;for(let N=0;N<I.length;N++){let L=I[N];if(L.length===0){!P&&s===X&&(S=A.length,C=0,P=!0),A.push({text:"",globalStart:Zo(X,T,t),formattedStart:X}),X+=1;continue}let Q=xt(L,h).split(`
7
+ `),ge=0,ye=[];for(let se=0;se<Q.length;se++){let ie=Q[se],pe=ie.trim();if(pe.length===0){let Be=ie.length||1;ye.push({text:ie,start:ge,length:Be}),ge+=Be}else{let Be=L.indexOf(pe,ge);if(Be!==-1){let Ce=ge,Fe=se<Q.length-1?Q[se+1].trim():"",le=L.length;if(Fe.length>0){let Ie=L.indexOf(Fe,Be+pe.length);Ie!==-1&&(le=Ie)}ye.push({text:L.slice(Ce,le),start:Ce,length:le-Ce}),ge=le}else ye.push({text:ie,start:ge,length:ie.length}),ge+=ie.length}}for(let se=0;se<ye.length;se++){let ie=ye[se],pe=ie.text,Be=X+ie.start,Ce=Be+ie.length;!P&&s>=Be&&(s<Ce||s===Ce&&se===ye.length-1)&&(S=A.length,C=s-Be,P=!0),A.push({text:pe,globalStart:Zo(Be,T,t),formattedStart:Be})}X+=L.length+1}return P||(A.length===0?A.push({text:"",globalStart:0,formattedStart:0}):k.endsWith(`
8
+ `)?(A.push({text:"",globalStart:Zo(X,T,t),formattedStart:X}),S=A.length-1,C=0):(S=A.length-1,C=A[S].text.length)),{visualLines:A,cursorLine:S,cursorCol:C}}var Ma=({value:t,rows:m,maxRows:h,highlightStyle:y,textStyle:T,placeholder:b="",mask:s,showCursor:k=!0,focus:f=!0,tabSize:I=4,cursorIndex:A=0,highlight:X,columns:S=80,pasteBlocks:C=[],cursorColor:P})=>{let N=vo(0),L=qn(()=>Math.max(20,S-10),[S]),_=ba((We,me=!1)=>{let R=kr(We);if(!me&&s)return R.replace(/[^\n]/g,s);let te=ya(R,I);return me?te:te.replace(/@\[(.*?)\]/g,(Z,ae)=>{let fe=ae.indexOf("#"),he=ae.indexOf(":L"),Ae=ae,at="";fe!==-1?(Ae=ae.slice(0,fe),at=ae.slice(fe)):he!==-1&&(Ae=ae.slice(0,he),at=ae.slice(he));let Ze=Ae.replace(/\\/g,"/"),ve=(process.cwd()||"").replace(/\\/g,"/");ve&&Ze.toLowerCase().startsWith(ve.toLowerCase()+"/")?Ze=Ze.slice(ve.length+1):Ze.startsWith("./")&&(Ze=Ze.slice(2));let oe=Ze.split("/");return`[${oe[oe.length-1]}${at}]`})},[I,s]),{visualLines:Q,cursorLine:ge,cursorCol:ye}=qn(()=>Ss(t,A,L,_,C),[t,A,L,_,C]),se=Q.length,ie=qn(()=>Math.max(m??h??1,Math.min(h??m??1,se)),[m,h,se]),pe=ge+1,Be=N.current+ie,Ce=N.current;pe<=N.current?Ce=Math.max(0,pe-1):pe>Be?Ce=pe-ie:se&&(se<ie?Ce=0:se<Be&&(Ce=se-ie)),N.current=Ce;let Fe=qn(()=>Q.slice(Ce,Ce+ie),[Q,Ce,ie]),[le,Ie]=Dr(!0);Ms(()=>{if(Ie(!0),!f||!k)return;let We=setInterval(()=>{Ie(me=>!me)},530);return()=>clearInterval(We)},[f,k,t,A]);let be=qn(()=>({...T,color:k&&f&&le?P||"white":void 0,bold:k&&f&&le,inverse:k&&f&&le}),[T,k,f,le,P]),ee=(We,me,R,te)=>{if(!We){let Ae=b&&t.length===0?_(b,!0):"";if(me){let at=Ae[0]||" ",Ze=Ae.slice(1);return Ut.createElement(so,null,Ut.createElement(so,{...te},at),Ut.createElement(so,{color:"gray",dimColor:!0},Ze))}return Ut.createElement(so,{color:"gray",dimColor:!0},Ae||" ")}let Z=/(\[Pasted \d+ (?:lines|chars)\])/g,ae=We.split(Z),fe=0,he=[];for(let Ae=0;Ae<ae.length;Ae++){let at=ae[Ae];if(at==="")continue;let Ze=at.match(/^\[Pasted \d+ (?:lines|chars)\]$/),ve=at.length,oe=fe+ve;if(me&&R>=fe&&R<oe){let ce=R-fe,Se=at.slice(0,ce),D=at[ce]||" ",Ue=at.slice(ce+1);he.push(Ut.createElement(so,{key:Ae},Ut.createElement(so,{color:Ze?"magenta":void 0},Se),Ut.createElement(so,{...te},D),Ut.createElement(so,{color:Ze?"magenta":void 0},Ue)))}else he.push(Ut.createElement(so,{key:Ae,color:Ze?"magenta":void 0},at));fe=oe}return me&&R>=We.length&&he.push(Ut.createElement(so,{key:"cursor-end",...te}," ")),Ut.createElement(Ut.Fragment,null,he)};return Ut.createElement(Ta,{height:ie,width:L+1,overflow:"hidden",flexDirection:"column",flexGrow:0,flexShrink:0},Fe.map((We,me)=>{let R=Ce+me,te=R===ge&&f&&k;return Ut.createElement(so,{key:R,...T,wrap:"truncate"},ee(We.text,te,ye,be))}))},al=({value:t,onChange:m,onSubmit:h,keyBindings:y,showCursor:T=!0,highlightPastedText:b=!1,focus:s=!0,columns:k=80,useCustomInput:f=(S,C)=>wa(S,{isActive:C}),onPasteStateChange:I,cursorColor:A,...X})=>{let[S,C]=Dr(t.length),[P,N]=Dr(0),[L,_]=Dr([]),Q=vo(t.length),ge=vo(t),ye=vo(0),se=vo([]),ie=vo(""),pe=vo(-1),Be=vo(null),Ce=vo(0);Q.current=S,ge.current=t,ye.current=P,se.current=L,Ms(()=>{Q.current>t.length&&(Q.current=t.length,C(t.length)),t?_(Ie=>Ie.filter(be=>be.end<=t.length&&be.start<=t.length)):(_([]),N(0))},[t]),Ms(()=>{I?.(L.length>0)},[L,I]);let Fe=()=>{let Ie=ie.current,be=pe.current,ee=be+Ie.length,We=ge.current,me=We.slice(0,be)+Ie+We.slice(be);m(me),Q.current=ee,C(ee),N(Ie.length>1?Ie.length:0);let R=kr(Ie).split(`
9
+ `).length,te=Ie.length;if(te>50&&(R>3||R<=3&&te>200)){let Z={start:be,end:ee,text:Ie};_(ae=>{let fe=Ie.length;return[...ae.map(Ae=>be<=Ae.start?{...Ae,start:Ae.start+fe,end:Ae.end+fe}:Ae),Z]})}ie.current="",pe.current=-1,Be.current=null},le=()=>{Be.current&&(clearTimeout(Be.current),Fe())};return f((Ie,be)=>{if(Ie==="\x1B[I"||Ie==="\x1B[O"||Ie==="[I"||Ie==="[O")return;let ee=Ie,We=!1,me=!1;ee&&typeof ee=="string"&&(ee.includes("\x1B[200~")&&(We=!0,ee=ee.replace(/\x1b\[200~/g,"")),ee.includes("\x1B[201~")&&(me=!0,ee=ee.replace(/\x1b\[201~/g,"")));let R=Q.current,te=ge.current,Z=se.current,ae=Math.max(20,k-10),fe=(oe,ce)=>{if(Z.length===0)return;let Se=Z.map(D=>oe<=D.start?{...D,start:D.start+ce,end:D.end+ce}:oe>D.start&&oe<D.end?null:D).filter(Boolean);_(Se)},he=oe=>{for(let ce of Z)if(oe>ce.start&&oe<ce.end)return ce.start;return oe};if(be.ctrl&&(ee==="o"||ee==="")){_([]);return}if(be.ctrl&&(ee.toLowerCase()==="r"||ee===""||ee===""))return;if(be.upArrow||be.downArrow||be.leftArrow||be.rightArrow){le();let oe=Date.now();if(oe-Ce.current<33)return;Ce.current=oe}let at=y?.submit??(oe=>oe.return&&oe.ctrl),Ze=y?.newline??(oe=>oe.return);if(at(be)){le(),h?.(te);return}else if(Ze(be)){le(),fe(R,1);let oe=te.slice(0,R)+`
10
+ `+te.slice(R);m(oe),Q.current=R+1,C(R+1),N(0);return}if(be.tab||be.shift&&be.tab||be.ctrl&&ee==="c")return;let ve=oe=>oe;if(be.upArrow||be.downArrow){if(le(),T){let{visualLines:oe,cursorLine:ce,cursorCol:Se}=Ss(te,R,ae,ve,Z),D=be.upArrow?ce-1:ce+1;if(D>=0&&D<oe.length){let Ue=oe[D],qe=Math.min(Se,Ue.text.length),Ct=Ue.formattedStart+qe,Gt=Zo(Ct,Z,te);Gt=he(Gt),Q.current=Gt,C(Gt),N(0)}else if(be.upArrow&&ce===0)Q.current=0,C(0),N(0);else if(be.downArrow&&ce===oe.length-1){let Ue=oe[oe.length-1],qe=Ue.formattedStart+Ue.text.length,Ct=Zo(qe,Z,te);Ct=he(Ct),Q.current=Ct,C(Ct),N(0)}}}else if(be.leftArrow){if(le(),T){let oe=Math.max(0,R-1),ce=Z.find(Se=>R===Se.end);ce&&(oe=ce.start),Q.current=oe,C(oe),N(0)}}else if(be.rightArrow){if(le(),T){let oe=Math.min(te.length,R+1),ce=Z.find(Se=>R===Se.start);ce&&(oe=ce.end),Q.current=oe,C(oe),N(0)}}else if(be.backspace){le();let oe=Z.findIndex(ce=>R===ce.end);if(oe!==-1){let ce=Z[oe],Se=-(ce.end-ce.start),D=te.slice(0,ce.start)+te.slice(ce.end);m(D),Q.current=ce.start,C(ce.start),N(0);let Ue=Z.filter((qe,Ct)=>Ct!==oe).map(qe=>qe.start>=ce.end?{...qe,start:qe.start+Se,end:qe.end+Se}:qe);_(Ue)}else if(R>0){fe(R-1,-1);let ce=te.slice(0,R-1)+te.slice(R);m(ce),Q.current=R-1,C(R-1),N(0)}}else if(be.delete){le();let oe=Z.findIndex(ce=>R===ce.start);if(oe!==-1){let ce=Z[oe],Se=-(ce.end-ce.start),D=te.slice(0,ce.start)+te.slice(ce.end);m(D),N(0);let Ue=Z.filter((qe,Ct)=>Ct!==oe).map(qe=>qe.start>=ce.end?{...qe,start:qe.start+Se,end:qe.end+Se}:qe);_(Ue)}else if(fe(R,-1),R<te.length){let ce=te.slice(0,R)+te.slice(R+1);m(ce),N(0)}}else if(be.home||be.end){if(le(),T){let{visualLines:oe,cursorLine:ce}=Ss(te,R,ae,ve,Z),Se=oe[ce];if(Se){let D;be.home?D=Zo(Se.formattedStart,Z,te):be.end&&(D=Zo(Se.formattedStart+Se.text.length,Z,te)),D=he(D),Q.current=D,C(D),N(0)}}}else if(ee!==""||We||me)if(We||me||ee.length>1||Be.current!==null)Be.current?(clearTimeout(Be.current),ie.current+=ee):(pe.current=R,ie.current=ee),me?(Be.current=null,Fe()):Be.current=setTimeout(()=>{Fe()},80);else{fe(R,ee.length);let ce=te.slice(0,R)+ee+te.slice(R);m(ce);let Se=R+ee.length;Q.current=Se,C(Se),N(0)}},s),Ut.createElement(Ma,{...X,value:t,cursorIndex:S,showCursor:T,focus:s,columns:k,pasteBlocks:L,cursorColor:A})};import Ur from"ink-text-input";import"ink-select-input";import r from"react";import{Box as E,Text as ne}from"ink";import wt,{useState as dl,useEffect as Sa}from"react";import{Box as Eo,Text as io,useInput as Ca}from"ink";var Ir=wt.memo(({command:t,output:m,completed:h=!1,isFocused:y=!1,columns:T=80,isPty:b=!1,terminalHeight:s=24,theme:k="Dark"})=>{let f=Je(k),A=(te=>{if(!te)return"";let Z=[[]],ae=0,fe=0,he="",Ae=/\x1b\[([0-9;]*?)([a-zA-Z])/g,at=0,Ze,ve=ce=>{for(let Se=0;Se<ce.length;Se++){let D=ce[Se];if(D===`
11
+ `)for(ae++,fe=0;ae>=Z.length;)Z.push([]);else if(D==="\r")fe=0;else{for(;ae>=Z.length;)Z.push([]);let Ue=Z[ae];for(;fe>Ue.length;)Ue.push({char:" ",style:""});Ue[fe]={char:D,style:he},fe++}}};for(;(Ze=Ae.exec(te))!==null;){ve(te.substring(at,Ze.index));let ce=Ze[1],Se=Ze[2],D=ce?ce.split(";").map(Number):[];if(Se==="A"){let Ue=D[0]||1;ae=Math.max(0,ae-Ue)}else if(Se==="B"){let Ue=D[0]||1;for(ae=ae+Ue;ae>=Z.length;)Z.push([])}else if(Se==="C"){let Ue=D[0]||1;fe=fe+Ue}else if(Se==="D"){let Ue=D[0]||1;fe=Math.max(0,fe-Ue)}else if(Se==="G"){let Ue=(D[0]||1)-1;fe=Math.max(0,Ue)}else if(Se==="H"||Se==="f"){let Ue=(D[0]||1)-1,qe=(D[1]||1)-1;for(ae=Math.max(0,Ue),fe=Math.max(0,qe);ae>=Z.length;)Z.push([])}else if(Se==="K"){let Ue=D[0]||0;if(ae<Z.length){let qe=Z[ae];if(Ue===0)qe.length=fe;else if(Ue===1)for(let Ct=0;Ct<fe&&Ct<qe.length;Ct++)qe[Ct]={char:" ",style:""};else Ue===2&&(qe.length=0)}}else if(Se==="J"){let Ue=D[0]||0;(Ue===2||Ue===3)&&(Z.length=0,Z.push([]),ae=0,fe=0)}else if(Se==="m"){let Ue=Ze[0];Ue==="\x1B[0m"?he="":he=Ue}at=Ae.lastIndex}ve(te.substring(at));let oe=Z.map(ce=>{let Se="",D="";for(let Ue=0;Ue<ce.length;Ue++){let qe=ce[Ue]||{char:" ",style:""};qe.style!==D&&(D&&(Se+="\x1B[0m"),Se+=qe.style,D=qe.style),Se+=qe.char}return D&&(Se+="\x1B[0m"),Se});for(;oe.length>0&&oe[oe.length-1]==="";)oe.pop();return oe.join(`
12
12
  `)})(m).replace(/\n{3,}/g,`
13
13
 
14
14
  `),X=Math.max(10,(T||80)-6),S=A?A.split(`
15
15
  `).flatMap(te=>te?xt(te,X).split(`
16
- `):[""]):[],[C,P]=dl(!1),[N,L]=dl(0);Sa(()=>{y||L(0)},[y]);let _=s&&s>0?s:process.stdout.rows||24,q=_<=24,Me=Math.max(1,_-(h?q?7:9:q?11:14)),re=_<=16?4:_<=22?5:_<=28?6:10,ie=Math.min(h?q?4:10:re,Me),pe=S.length>ie,De=Math.max(0,S.length-ie);Ca((te,Z)=>{if(!y)return;let ae=Z.pageUp||te==="\x1B[5~"||te==="[5~",fe=Z.pageDown||te==="\x1B[6~"||te==="[6~";Z.ctrl&&(te==="o"||te==="")?(P(he=>!he),L(0)):ae?L(he=>Math.min(De,he+5)):fe&&L(he=>Math.max(0,he-5))},{isActive:y});let ve;if(!pe||C)ve=S;else{let te=Math.max(0,S.length-ie-N),Z=te+ie;ve=S.slice(te,Z)}let Ue=(ve||[]).join(`
17
- `).trim(),le=(ve||[]).join(`
18
- `),Ie=pe&&!C?Math.max(0,S.length-ie-N):0,be=pe&&!C?N:0,ee=h?"\u{1F3C1} FINISHED: ":"\u26A1 EXECUTING: ",Ge=Math.max(10,(T||80)-(b?24:14)),me=xt((t||"").replace(/\r?\n/g," ").trim(),Ge).split(`
19
- `),R=(t||"").replace(/\r?\n/g," ").trim();return me.length>1&&(R=me[0].length>3?me[0].slice(0,-3)+"...":me[0]+"..."),Tt.createElement(Eo,{flexDirection:"column",borderStyle:y?"double":"single",borderLeft:!1,borderRight:!1,borderTop:!0,borderBottom:!0,borderColor:f.codeBorder,paddingLeft:2,paddingRight:0,paddingTop:q?0:1,paddingBottom:1,marginY:q?0:1,width:T-2},Tt.createElement(Eo,{marginBottom:q?0:1,justifyContent:"space-between",width:"100%"},Tt.createElement(Eo,{flexShrink:1,paddingRight:2},Tt.createElement(io,null,Tt.createElement(io,{color:f.text,bold:!0},ee),Tt.createElement(io,{color:f.text},R))),b&&Tt.createElement(Eo,{flexShrink:0,paddingX:1},Tt.createElement(io,{color:"green",bold:!0},"ADVANCE"))),Ue?Tt.createElement(Eo,{flexDirection:"column",marginTop:0,backgroundColor:b?void 0:f.codeBg,paddingX:1,width:"100%"},Ie>0&&Tt.createElement(Eo,{marginBottom:0},Tt.createElement(io,{color:"magenta"},"\u25B2 ...",Ie," lines above (Use PageUp to scroll)...")),Tt.createElement(io,{color:f.text},le),be>0&&Tt.createElement(Eo,{marginTop:0},Tt.createElement(io,{color:"magenta"},"\u25BC ...",be," lines below (Use PageDown to scroll)..."))):!h&&Tt.createElement(Eo,{marginTop:q?0:1,backgroundColor:b?void 0:f.codeBg,paddingX:1,width:"100%"},Tt.createElement(io,{color:f.textMuted,italic:!0},"Waiting for output...")),Tt.createElement(Eo,{justifyContent:"space-between",marginTop:q?0:1},h?Tt.createElement(io,{color:f.textMuted,italic:!0},y?"Use PgUp/PgDn to scroll \u2022 Ctrl+O to expand/collapse \u2022 TAB to unfocus.":"Press TAB to focus & scroll."):Tt.createElement(io,{color:f.textMuted,italic:!0},y?"Use PgUp/PgDn to scroll \u2022 Ctrl+O to expand \u2022 TAB to unfocus \u2022 CTRL+C to stop.":"Press TAB to focus \u2022 CTRL+C to terminate."),Tt.createElement(io,{color:f.textMuted,bold:!0},h?y?"\u25CF ARCHIVED (FOCUSED) ":"\u25CF ARCHIVED ":y?"\u25B6 TERMINAL FOCUSED ":"\u25CF LIVE (Press TAB to focus) ")))});import{diffWordsWithSpace as va}from"diff";var zn=null,ml=t=>{zn=t!==!1},gl=()=>{if(zn===null)try{zn=Tr(zo,{})?.systemSettings?.preserveThinking!==!1}catch{zn=!0}return zn},cl=(t,m,h)=>t,Ea=(t,m=80)=>{if(!t)return null;let h=m-10,y=t.trim();if(!y.includes("```"))return r.createElement(E,{width:"100%",flexDirection:"column"},r.createElement(En,{text:y,color:"#969696",columns:h,italic:!0}));let T=y.split(/(```\w*\n?[\s\S]*?(?:```|$))/g);return r.createElement(E,{width:"100%",flexDirection:"column"},T.map((b,s)=>{if(b.startsWith("```")){let f=b.match(/```(\w*)\n?([\s\S]*?)(?:```|$)/),I=f?f[2]:b.replace(/^```\w*\n?/,"").replace(/```$/,""),A=xt(I.trimEnd(),h);return r.createElement(E,{key:s,flexDirection:"column",width:"100%"},A.split(`
20
- `).map((X,S)=>r.createElement(ne,{key:S,color:"cyan"},X)))}let k=b;return s>0&&(k=k.replace(/^[\r\n]+/,"")),s<T.length-1&&(k=k.replace(/[\r\n]+$/,"")),k?r.createElement(En,{key:s,text:k,color:"gray",columns:h,italic:!0}):null}))},Da=/(```[\s\S]*?```|`[^`\r\n]+`|@\[.*?\]|\*\*.*?\*\*|\*.*?\*|\\\(.*?\\\)|\\\[.*?\\\]|\$.*?\$|\[.*?\]\s*\(.*?\)|\[.*?\]\s*\[.*?\]|https?:\/\/[^\s]+)/g;var Ba=/\\frac\s*\{([^{}]*)\}\s*\{([^{}]*)\}/g,ka=/(\\(?:mathbf|textbf|textit|underline|texttt)\{[^{}]*\})/g,Ia=/^(#{1,6})\s+(.*)/,Aa=/\\multiply|\\mul|\\times/g,La=/\\div/g,Pa=/\\cdot/g,Oa=/\\infty/g,Na=/\\pm/g,Fa=/\\leq/g,Ua=/\\geq/g,$a=/\\neq/g,_a=/\\sqrt\s*\{([^}]+)\}/g,Ha=/\\sqrt\s*(\w+|\d+)/g,Xa=/\\alpha/g,Ga=/\\beta/g,Wa=/\\theta/g,Ya=/\\pi/g,Va=/\\approx/g,ja=/\\Delta/g,Ka=/\\sigma/g,qa=/\\sum/g,za=/\\prod/g,Qa=/\\rightarrow|\\to/g,Ja=/\\left\b|\\right\b/g,Za=/\\left\(|\\right\)/g,Ra=/\\left\[|\\right\]/g,ed=/\\\{|\\\}/g,td=/\\text\s*\{([^}]+)\}/g,od=/\\text\s+(\w+)/g,nd=/\\%/g,rd=/\\\(|\\\)/g,sd=/\\\[|\\\]/g,id=/@\[(.*?)\]/g,ul=/:L/gi,ld=/\[(.*?)\]\s*\((.*?)\)/,ad=/\[(.*?)\]\s*\[(.*?)\]/,dd=/\\(\w+)\{([^{}]*)\}/,cd=t=>t.replace(rd,m=>m.includes("(")?"(":")").replace(sd,m=>m.includes("[")?"[":"]").replace(Aa,"\xD7").replace(La,"\xF7").replace(Pa,"\u22C5").replace(Oa,"\u221E").replace(Na,"\xB1").replace(Fa,"\u2264").replace(Ua,"\u2265").replace($a,"\u2260").replace(_a,"\u221A($1)").replace(Ha,"\u221A($1)").replace(Xa,"\u03B1").replace(Ga,"\u03B2").replace(Wa,"\u03B8").replace(Ya,"\u03C0").replace(Va,"\u2248").replace(ja,"\u0394").replace(Ka,"\u03C3").replace(qa,"\u03A3").replace(za,"\u03A0").replace(Qa,"\u2192").replace(Ja,"").replace(Za,m=>m.includes("left")?"(":")").replace(Ra,m=>m.includes("left")?"[":"]").replace(ed,m=>m.includes("{")?"{":"}").replace(td,"$1").replace(od,"$1").replace(nd,"%"),ud=/\b(const|let|var|function|return|if|else|for|while|do|switch|case|break|continue|import|export|from|default|class|extends|new|this|typeof|instanceof|try|catch|finally|throw|async|await|yield|public|private|protected|static|void|int|float|double|char|bool|boolean|def|elif|fn|pub|mut|struct|impl|enum|type|interface|package|namespace|using|include|define|nil|None|self|lambda)\b/,md=[/((?<=\binclude\s+)(?:<[^>]+>|"[^"]+"))/.source,/((?<=\b(?:from|import|require\s*\(\s*)\s*)(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"))/.source,/(\/\/.*|#.*)/.source,/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^\`\\])*`)/.source,ud.source,/\b([a-zA-Z_][a-zA-Z0-9_]*)(?=\s*\()/.source,/\b(true|false|null|undefined|nil|None)\b/.source,/\b(\d+(?:\.\d+)?|0x[0-9a-fA-F]+)\b/.source],Cs=new RegExp(md.join("|"),"g"),vn=new Map,gd=1e3,fd=(t,m)=>{if(!t)return[];let h=`${m}:${t}`;if(vn.has(h))return vn.get(h);let y=0,T=[],b;for(Cs.lastIndex=0;(b=Cs.exec(t))!==null;){let s=b[0],k=b.index;k>y&&T.push({text:Et(t.substring(y,k))});let f,I=!1;b[1]||b[2]?f="#ce9178":b[3]?f="#9ece6a":b[4]?f="#fcfca4":b[5]?(f="#ff7b72",I=!0):b[6]?f="#b392f0":(b[7]||b[8])&&(f="#ff9e64"),T.push({text:Et(s),color:f,bold:I}),y=Cs.lastIndex}if(y<t.length&&T.push({text:Et(t.substring(y))}),vn.size>=gd){let s=vn.keys().next().value;vn.delete(s)}return vn.set(h,T),T},Ot=(t,m,h=void 0,y=void 0)=>{if(!t)return r.createElement(ne,{backgroundColor:y}," ");let T=fd(t,m);return r.createElement(ne,{color:h,backgroundColor:y},T.map((b,s)=>r.createElement(ne,{key:s,color:b.color||h,backgroundColor:y,bold:b.bold},b.text)))},vs=(t,m)=>{if(!t)return null;let h=t.replace(Ba,"($1/$2)");h=cd(h);let y=h.split(ka);return r.createElement(r.Fragment,{key:m},y.map((T,b)=>{if(T.startsWith("\\")){let s=T.match(dd);if(s){let k=s[1],f=s[2];return r.createElement(ne,{key:b,bold:k==="mathbf"||k==="textbf",italic:k==="textit",underline:k==="underline",color:k==="texttt"?"cyan":void 0},f)}}return T}))},$t=r.memo(({text:t,color:m,italic:h,theme:y="Dark"})=>{if(!t)return null;let T=Je(y),b=m||T.text,s=T.codeText||T.logoGradient&&T.logoGradient[0]||T.info||T.secondary||"cyan",k=t.split(Da);return r.createElement(ne,{color:b,wrap:"anywhere",italic:h},k.map((f,I)=>{if(!f)return null;if(f.startsWith("```")&&f.endsWith("```")){let A=f.slice(3,-3);return r.createElement(ne,{key:I,color:s},A)}if(f.startsWith("**")&&f.endsWith("**"))return r.createElement(ne,{key:I,bold:!0,color:b},r.createElement($t,{text:f.slice(2,-2),color:b,theme:y}));if(f.startsWith("*")&&f.endsWith("*"))return r.createElement(ne,{key:I,italic:!0,color:b},r.createElement($t,{text:f.slice(1,-1),color:b,italic:h,theme:y}));if(f.startsWith("`"))if(f.endsWith("`")&&f.length>1){let A=f.slice(1,-1),X=A.replace(id,(C,P)=>P.split("/").pop().split("\\").pop().replace(ul,"#L")),S=A.includes("@[");return r.createElement(ne,{key:I,color:s,bold:S},X)}else return r.createElement(ne,{key:I,color:s},f.slice(1));if(f.startsWith("@[")&&f.endsWith("]")){let X=f.slice(2,-1).split("/").pop().split("\\").pop().replace(ul,"#L");return r.createElement(ne,{key:I,color:s,bold:!0},X)}if(f.startsWith("\\(")&&f.endsWith("\\)")||f.startsWith("\\[")&&f.endsWith("\\]")){let A=f.slice(2,-2);return r.createElement(ne,{key:I,color:"yellow"},vs(A,I))}if(f.startsWith("$")&&f.endsWith("$")){let A=f.slice(1,-1);return r.createElement(ne,{key:I,color:"yellow"},vs(A,I))}if(f.startsWith("[")&&(f.includes("](")||f.includes("] ("))){let A=f.match(ld);if(A){let X=A[1]||A[2],C=`\x1B]8;;${A[2]||A[1]}\x07${X}\x1B]8;;\x07`;return r.createElement(ne,{key:I,color:s,underline:!0,italic:!0},C)}}if(f.startsWith("[")&&(f.includes("][")||f.includes("] ["))){let A=f.match(ad);if(A){let X=A[1]||A[2],C=`\x1B]8;;${A[2]||A[1]}\x07${X}\x1B]8;;\x07`;return r.createElement(ne,{key:I,color:s,underline:!0,italic:!0},C)}}return f.startsWith("http")?r.createElement(ne,{key:I,color:s,underline:!0,italic:!0},f):vs(f,I)}))}),fl=r.memo(({buffer:t,terminalWidth:m=80,theme:h="Dark"})=>{if(t.length<2)return null;let y=Je(h),T=y.codeText||y.secondary||y.info||"cyan",b=t.map(X=>{let S=X.split("|");return S[0]!==void 0&&S[0].trim()===""&&S.shift(),S.length>0&&S[S.length-1].trim()===""&&S.pop(),S.map(C=>C.trim())}),s=b[0],k=b.slice(2),f=Math.floor(100/s.length),I=m-8,A=Math.floor(I/s.length)-2;return r.createElement(E,{flexDirection:"column",borderStyle:"round",borderColor:y.borderMuted,paddingX:1,marginY:0,width:m-2},r.createElement(E,{flexDirection:"row",borderStyle:"single",borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,borderColor:y.borderMuted,marginBottom:1,paddingBottom:0,width:"100%"},s.map((X,S)=>r.createElement(E,{key:S,flexBasis:`${f}%`,flexGrow:1,flexShrink:0,paddingRight:2},r.createElement($t,{text:xt(X,A),color:T,theme:h})))),k.map((X,S)=>r.createElement(E,{key:S,flexDirection:"row",marginBottom:S===k.length-1?0:1,width:"100%"},X.map((C,P)=>r.createElement(E,{key:P,flexBasis:`${f}%`,flexGrow:1,flexShrink:0,paddingRight:2,flexDirection:"column"},r.createElement($t,{text:xt(C,A),color:y.text,theme:h}))))))}),En=r.memo(({text:t,color:m,columns:h=80,italic:y=!1,theme:T="Dark"})=>{if(!t)return null;let b=Je(T),s=m||b.text,k=t.split(`
16
+ `):[""]):[],[C,P]=dl(!1),[N,L]=dl(0);Sa(()=>{y||L(0)},[y]);let _=s&&s>0?s:process.stdout.rows||24,Q=_<=24,ye=Math.max(1,_-(h?Q?7:9:Q?11:14)),se=_<=16?4:_<=22?5:_<=28?6:10,ie=Math.min(h?Q?4:10:se,ye),pe=S.length>ie,Be=Math.max(0,S.length-ie);Ca((te,Z)=>{if(!y)return;let ae=Z.pageUp||te==="\x1B[5~"||te==="[5~",fe=Z.pageDown||te==="\x1B[6~"||te==="[6~";Z.ctrl&&(te==="o"||te==="")?(P(he=>!he),L(0)):ae?L(he=>Math.min(Be,he+5)):fe&&L(he=>Math.max(0,he-5))},{isActive:y});let Ce;if(!pe||C)Ce=S;else{let te=Math.max(0,S.length-ie-N),Z=te+ie;Ce=S.slice(te,Z)}let Fe=(Ce||[]).join(`
17
+ `).trim(),le=(Ce||[]).join(`
18
+ `),Ie=pe&&!C?Math.max(0,S.length-ie-N):0,be=pe&&!C?N:0,ee=h?"\u{1F3C1} FINISHED: ":"\u26A1 EXECUTING: ",We=Math.max(10,(T||80)-(b?24:14)),me=xt((t||"").replace(/\r?\n/g," ").trim(),We).split(`
19
+ `),R=(t||"").replace(/\r?\n/g," ").trim();return me.length>1&&(R=me[0].length>3?me[0].slice(0,-3)+"...":me[0]+"..."),wt.createElement(Eo,{flexDirection:"column",borderStyle:y?"double":"single",borderLeft:!1,borderRight:!1,borderTop:!0,borderBottom:!0,borderColor:f.codeBorder,paddingLeft:2,paddingRight:0,paddingTop:Q?0:1,paddingBottom:1,marginY:Q?0:1,width:T-2},wt.createElement(Eo,{marginBottom:Q?0:1,justifyContent:"space-between",width:"100%"},wt.createElement(Eo,{flexShrink:1,paddingRight:2},wt.createElement(io,null,wt.createElement(io,{color:f.text,bold:!0},ee),wt.createElement(io,{color:f.text},R))),b&&wt.createElement(Eo,{flexShrink:0,paddingX:1},wt.createElement(io,{color:"green",bold:!0},"ADVANCE"))),Fe?wt.createElement(Eo,{flexDirection:"column",marginTop:0,backgroundColor:b?void 0:f.codeBg,paddingX:1,width:"100%"},Ie>0&&wt.createElement(Eo,{marginBottom:0},wt.createElement(io,{color:"magenta"},"\u25B2 ...",Ie," lines above (Use PageUp to scroll)...")),wt.createElement(io,{color:f.text},le),be>0&&wt.createElement(Eo,{marginTop:0},wt.createElement(io,{color:"magenta"},"\u25BC ...",be," lines below (Use PageDown to scroll)..."))):!h&&wt.createElement(Eo,{marginTop:Q?0:1,backgroundColor:b?void 0:f.codeBg,paddingX:1,width:"100%"},wt.createElement(io,{color:f.textMuted,italic:!0},"Waiting for output...")),wt.createElement(Eo,{justifyContent:"space-between",marginTop:Q?0:1},h?wt.createElement(io,{color:f.textMuted,italic:!0},y?"Use PgUp/PgDn to scroll \u2022 Ctrl+O to expand/collapse \u2022 TAB to unfocus.":"Press TAB to focus & scroll."):wt.createElement(io,{color:f.textMuted,italic:!0},y?"Use PgUp/PgDn to scroll \u2022 Ctrl+O to expand \u2022 TAB to unfocus \u2022 CTRL+C to stop.":"Press TAB to focus \u2022 CTRL+C to terminate."),wt.createElement(io,{color:f.textMuted,bold:!0},h?y?"\u25CF ARCHIVED (FOCUSED) ":"\u25CF ARCHIVED ":y?"\u25B6 TERMINAL FOCUSED ":"\u25CF LIVE (Press TAB to focus) ")))});import{diffWordsWithSpace as va}from"diff";var zn=null,ml=t=>{zn=t!==!1},gl=()=>{if(zn===null)try{zn=wr(zo,{})?.systemSettings?.preserveThinking!==!1}catch{zn=!0}return zn},cl=(t,m,h)=>t,Ea=(t,m=80)=>{if(!t)return null;let h=m-10,y=t.trim();if(!y.includes("```"))return r.createElement(E,{width:"100%",flexDirection:"column"},r.createElement(En,{text:y,color:"#969696",columns:h,italic:!0}));let T=y.split(/(```\w*\n?[\s\S]*?(?:```|$))/g);return r.createElement(E,{width:"100%",flexDirection:"column"},T.map((b,s)=>{if(b.startsWith("```")){let f=b.match(/```(\w*)\n?([\s\S]*?)(?:```|$)/),I=f?f[2]:b.replace(/^```\w*\n?/,"").replace(/```$/,""),A=xt(I.trimEnd(),h);return r.createElement(E,{key:s,flexDirection:"column",width:"100%"},A.split(`
20
+ `).map((X,S)=>r.createElement(ne,{key:S,color:"cyan"},X)))}let k=b;return s>0&&(k=k.replace(/^[\r\n]+/,"")),s<T.length-1&&(k=k.replace(/[\r\n]+$/,"")),k?r.createElement(En,{key:s,text:k,color:"gray",columns:h,italic:!0}):null}))},Ba=/(```[\s\S]*?```|`[^`\r\n]+`|@\[.*?\]|\*\*.*?\*\*|\*.*?\*|\\\(.*?\\\)|\\\[.*?\\\]|\$.*?\$|\[.*?\]\s*\(.*?\)|\[.*?\]\s*\[.*?\]|https?:\/\/[^\s]+)/g;var Da=/\\frac\s*\{([^{}]*)\}\s*\{([^{}]*)\}/g,ka=/(\\(?:mathbf|textbf|textit|underline|texttt)\{[^{}]*\})/g,Ia=/^(#{1,6})\s+(.*)/,Aa=/\\multiply|\\mul|\\times/g,La=/\\div/g,Pa=/\\cdot/g,Oa=/\\infty/g,Na=/\\pm/g,Fa=/\\leq/g,Ua=/\\geq/g,$a=/\\neq/g,_a=/\\sqrt\s*\{([^}]+)\}/g,Ha=/\\sqrt\s*(\w+|\d+)/g,Xa=/\\alpha/g,Wa=/\\beta/g,Ga=/\\theta/g,Ya=/\\pi/g,Va=/\\approx/g,ja=/\\Delta/g,Ka=/\\sigma/g,qa=/\\sum/g,za=/\\prod/g,Qa=/\\rightarrow|\\to/g,Ja=/\\left\b|\\right\b/g,Za=/\\left\(|\\right\)/g,Ra=/\\left\[|\\right\]/g,ed=/\\\{|\\\}/g,td=/\\text\s*\{([^}]+)\}/g,od=/\\text\s+(\w+)/g,nd=/\\%/g,rd=/\\\(|\\\)/g,sd=/\\\[|\\\]/g,id=/@\[(.*?)\]/g,ul=/:L/gi,ld=/\[(.*?)\]\s*\((.*?)\)/,ad=/\[(.*?)\]\s*\[(.*?)\]/,dd=/\\(\w+)\{([^{}]*)\}/,cd=t=>t.replace(rd,m=>m.includes("(")?"(":")").replace(sd,m=>m.includes("[")?"[":"]").replace(Aa,"\xD7").replace(La,"\xF7").replace(Pa,"\u22C5").replace(Oa,"\u221E").replace(Na,"\xB1").replace(Fa,"\u2264").replace(Ua,"\u2265").replace($a,"\u2260").replace(_a,"\u221A($1)").replace(Ha,"\u221A($1)").replace(Xa,"\u03B1").replace(Wa,"\u03B2").replace(Ga,"\u03B8").replace(Ya,"\u03C0").replace(Va,"\u2248").replace(ja,"\u0394").replace(Ka,"\u03C3").replace(qa,"\u03A3").replace(za,"\u03A0").replace(Qa,"\u2192").replace(Ja,"").replace(Za,m=>m.includes("left")?"(":")").replace(Ra,m=>m.includes("left")?"[":"]").replace(ed,m=>m.includes("{")?"{":"}").replace(td,"$1").replace(od,"$1").replace(nd,"%"),ud=/\b(const|let|var|function|return|if|else|for|while|do|switch|case|break|continue|import|export|from|default|class|extends|new|this|typeof|instanceof|try|catch|finally|throw|async|await|yield|public|private|protected|static|void|int|float|double|char|bool|boolean|def|elif|fn|pub|mut|struct|impl|enum|type|interface|package|namespace|using|include|define|nil|None|self|lambda)\b/,md=[/((?<=\binclude\s+)(?:<[^>]+>|"[^"]+"))/.source,/((?<=\b(?:from|import|require\s*\(\s*)\s*)(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"))/.source,/(\/\/.*|#.*)/.source,/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^\`\\])*`)/.source,ud.source,/\b([a-zA-Z_][a-zA-Z0-9_]*)(?=\s*\()/.source,/\b(true|false|null|undefined|nil|None)\b/.source,/\b(\d+(?:\.\d+)?|0x[0-9a-fA-F]+)\b/.source],Cs=new RegExp(md.join("|"),"g"),vn=new Map,gd=1e3,fd=(t,m)=>{if(!t)return[];let h=`${m}:${t}`;if(vn.has(h))return vn.get(h);let y=0,T=[],b;for(Cs.lastIndex=0;(b=Cs.exec(t))!==null;){let s=b[0],k=b.index;k>y&&T.push({text:Et(t.substring(y,k))});let f,I=!1;b[1]||b[2]?f="#ce9178":b[3]?f="#9ece6a":b[4]?f="#fcfca4":b[5]?(f="#ff7b72",I=!0):b[6]?f="#b392f0":(b[7]||b[8])&&(f="#ff9e64"),T.push({text:Et(s),color:f,bold:I}),y=Cs.lastIndex}if(y<t.length&&T.push({text:Et(t.substring(y))}),vn.size>=gd){let s=vn.keys().next().value;vn.delete(s)}return vn.set(h,T),T},Ot=(t,m,h=void 0,y=void 0)=>{if(!t)return r.createElement(ne,{backgroundColor:y}," ");let T=fd(t,m);return r.createElement(ne,{color:h,backgroundColor:y},T.map((b,s)=>r.createElement(ne,{key:s,color:b.color||h,backgroundColor:y,bold:b.bold},b.text)))},vs=(t,m)=>{if(!t)return null;let h=t.replace(Da,"($1/$2)");h=cd(h);let y=h.split(ka);return r.createElement(r.Fragment,{key:m},y.map((T,b)=>{if(T.startsWith("\\")){let s=T.match(dd);if(s){let k=s[1],f=s[2];return r.createElement(ne,{key:b,bold:k==="mathbf"||k==="textbf",italic:k==="textit",underline:k==="underline",color:k==="texttt"?"cyan":void 0},f)}}return T}))},$t=r.memo(({text:t,color:m,italic:h,theme:y="Dark"})=>{if(!t)return null;let T=Je(y),b=m||T.text,s=T.codeText||T.logoGradient&&T.logoGradient[0]||T.info||T.secondary||"cyan",k=t.split(Ba);return r.createElement(ne,{color:b,wrap:"anywhere",italic:h},k.map((f,I)=>{if(!f)return null;if(f.startsWith("```")&&f.endsWith("```")){let A=f.slice(3,-3);return r.createElement(ne,{key:I,color:s},A)}if(f.startsWith("**")&&f.endsWith("**"))return r.createElement(ne,{key:I,bold:!0,color:b},r.createElement($t,{text:f.slice(2,-2),color:b,theme:y}));if(f.startsWith("*")&&f.endsWith("*"))return r.createElement(ne,{key:I,italic:!0,color:b},r.createElement($t,{text:f.slice(1,-1),color:b,italic:h,theme:y}));if(f.startsWith("`"))if(f.endsWith("`")&&f.length>1){let A=f.slice(1,-1),X=A.replace(id,(C,P)=>P.split("/").pop().split("\\").pop().replace(ul,"#L")),S=A.includes("@[");return r.createElement(ne,{key:I,color:s,bold:S},X)}else return r.createElement(ne,{key:I,color:s},f.slice(1));if(f.startsWith("@[")&&f.endsWith("]")){let X=f.slice(2,-1).split("/").pop().split("\\").pop().replace(ul,"#L");return r.createElement(ne,{key:I,color:s,bold:!0},X)}if(f.startsWith("\\(")&&f.endsWith("\\)")||f.startsWith("\\[")&&f.endsWith("\\]")){let A=f.slice(2,-2);return r.createElement(ne,{key:I,color:"yellow"},vs(A,I))}if(f.startsWith("$")&&f.endsWith("$")){let A=f.slice(1,-1);return r.createElement(ne,{key:I,color:"yellow"},vs(A,I))}if(f.startsWith("[")&&(f.includes("](")||f.includes("] ("))){let A=f.match(ld);if(A){let X=A[1]||A[2],C=`\x1B]8;;${A[2]||A[1]}\x07${X}\x1B]8;;\x07`;return r.createElement(ne,{key:I,color:s,underline:!0,italic:!0},C)}}if(f.startsWith("[")&&(f.includes("][")||f.includes("] ["))){let A=f.match(ad);if(A){let X=A[1]||A[2],C=`\x1B]8;;${A[2]||A[1]}\x07${X}\x1B]8;;\x07`;return r.createElement(ne,{key:I,color:s,underline:!0,italic:!0},C)}}return f.startsWith("http")?r.createElement(ne,{key:I,color:s,underline:!0,italic:!0},f):vs(f,I)}))}),fl=r.memo(({buffer:t,terminalWidth:m=80,theme:h="Dark"})=>{if(t.length<2)return null;let y=Je(h),T=y.codeText||y.secondary||y.info||"cyan",b=t.map(X=>{let S=X.split("|");return S[0]!==void 0&&S[0].trim()===""&&S.shift(),S.length>0&&S[S.length-1].trim()===""&&S.pop(),S.map(C=>C.trim())}),s=b[0],k=b.slice(2),f=Math.floor(100/s.length),I=m-8,A=Math.floor(I/s.length)-2;return r.createElement(E,{flexDirection:"column",borderStyle:"round",borderColor:y.borderMuted,paddingX:1,marginY:0,width:m-2},r.createElement(E,{flexDirection:"row",borderStyle:"single",borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,borderColor:y.borderMuted,marginBottom:1,paddingBottom:0,width:"100%"},s.map((X,S)=>r.createElement(E,{key:S,flexBasis:`${f}%`,flexGrow:1,flexShrink:0,paddingRight:2},r.createElement($t,{text:xt(X,A),color:T,theme:h})))),k.map((X,S)=>r.createElement(E,{key:S,flexDirection:"row",marginBottom:S===k.length-1?0:1,width:"100%"},X.map((C,P)=>r.createElement(E,{key:P,flexBasis:`${f}%`,flexGrow:1,flexShrink:0,paddingRight:2,flexDirection:"column"},r.createElement($t,{text:xt(C,A),color:y.text,theme:h}))))))}),En=r.memo(({text:t,color:m,columns:h=80,italic:y=!1,theme:T="Dark"})=>{if(!t)return null;let b=Je(T),s=m||b.text,k=t.split(`
21
21
  `),f=[],I=[],A=[],X=S=>{if(I.length>0&&(f.push(r.createElement(fl,{key:`table-${S}`,buffer:[...I],terminalWidth:h,theme:T})),I=[]),A.length>0){let C=h-6,P=A.flatMap(N=>xt(N,C).split(`
22
- `));f.push(r.createElement(E,{key:`quote-${S}`,borderStyle:"bold",borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:b.borderMuted,paddingLeft:1,marginY:1,flexDirection:"column"},P.map((N,L)=>r.createElement($t,{key:L,text:N,color:b.textMuted,italic:y,theme:T})))),A=[]}};return k.forEach((S,C)=>{let P=S.trim(),N=P.startsWith("|"),L=P.startsWith(">");if(N)A.length>0&&X(C),I.push(S);else if(L)I.length>0&&X(C),A.push(P.replace(/^>\s*/,""));else{if(X(C),P===""){f.push(r.createElement(E,{key:C,height:1}));return}if(P==="---"||P==="***"||P==="___"){f.push(r.createElement(E,{key:C,marginY:0,borderStyle:"single",borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,width:"100%",borderColor:b.borderMuted}));return}let _=P.match(/^(#{1,6})\s+(.*)/);if(_){let ie=_[1].length,pe=_[2];f.push(r.createElement(E,{key:C,marginTop:1,marginBottom:0,width:"100%"},r.createElement(ne,{bold:!0,color:ie===1?"yellow":ie===2?"magenta":ie===3?b.info||"cyan":ie===4?"green":ie===5?"blue":b.text,underline:!0},pe)));return}let q=/^[\*\-\+]\s/.test(P),ge=/^\d+\.\s/.test(P),Me=S.includes("\u2588")||S.includes("\u2554")||S.includes("\u255A")||S.includes("\u2550"),re="";if(Me)re=S;else if(q||ge){let ie=q?" \u2022 ":P.match(/^\d+\.\s/)[0],pe=" ".repeat(ie.length),De=xt(P.replace(/^[\*\-\d+\.]+\s/,""),h-(ie.length+6));re=ie+De.split(`
22
+ `));f.push(r.createElement(E,{key:`quote-${S}`,borderStyle:"bold",borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:b.borderMuted,paddingLeft:1,marginY:1,flexDirection:"column"},P.map((N,L)=>r.createElement($t,{key:L,text:N,color:b.textMuted,italic:y,theme:T})))),A=[]}};return k.forEach((S,C)=>{let P=S.trim(),N=P.startsWith("|"),L=P.startsWith(">");if(N)A.length>0&&X(C),I.push(S);else if(L)I.length>0&&X(C),A.push(P.replace(/^>\s*/,""));else{if(X(C),P===""){f.push(r.createElement(E,{key:C,height:1}));return}if(P==="---"||P==="***"||P==="___"){f.push(r.createElement(E,{key:C,marginY:0,borderStyle:"single",borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,width:"100%",borderColor:b.borderMuted}));return}let _=P.match(/^(#{1,6})\s+(.*)/);if(_){let ie=_[1].length,pe=_[2];f.push(r.createElement(E,{key:C,marginTop:1,marginBottom:0,width:"100%"},r.createElement(ne,{bold:!0,color:ie===1?"yellow":ie===2?"magenta":ie===3?b.info||"cyan":ie===4?"green":ie===5?"blue":b.text,underline:!0},pe)));return}let Q=/^[\*\-\+]\s/.test(P),ge=/^\d+\.\s/.test(P),ye=S.includes("\u2588")||S.includes("\u2554")||S.includes("\u255A")||S.includes("\u2550"),se="";if(ye)se=S;else if(Q||ge){let ie=Q?" \u2022 ":P.match(/^\d+\.\s/)[0],pe=" ".repeat(ie.length),Be=xt(P.replace(/^[\*\-\d+\.]+\s/,""),h-(ie.length+6));se=ie+Be.split(`
23
23
  `).join(`
24
- `+pe)}else re=xt(P,h-4);f.push(r.createElement(E,{key:C,flexDirection:"column",width:"100%"},r.createElement($t,{text:re,color:s,italic:y,theme:T})))}}),X("final"),r.createElement(E,{flexDirection:"column",width:h-2},f)}),xl=r.memo(({line:t,pairContent:m,parentText:h,columns:y=80,extension:T,theme:b="Dark"})=>{let s=Je(b),k=t.includes("[UI_CONTEXT]"),f=t.replace("[UI_CONTEXT]","");if(k&&f.includes("\u2550"))return r.createElement(E,{backgroundColor:s.codeBg,paddingX:1,width:y},r.createElement(ne,{color:"gray"},"\u2550".repeat(Math.max(10,y-4))));let I=bs(t);if(!I)return r.createElement(E,{backgroundColor:s.codeBg,paddingX:1,width:y},r.createElement(E,{width:3,flexShrink:0}),r.createElement(E,{width:1,flexShrink:0,marginLeft:1}),r.createElement(E,{flexGrow:1,marginLeft:1},r.createElement(ne,{color:"gray"},xt(f,y-14))));let{isR:A,isA:X,num:S,content:C}=I,P=m,N=[];if(P!=null){let pe=A?C:P,De=A?P:C;try{N=va(pe,De)}catch{N=[]}}let L=N.some(pe=>A&&pe.removed||X&&pe.added),_=!P&&(A||X),q=A?s.diffRemovalBg:X?s.diffAdditionBg:void 0,ge=A||X?A?s.diffRemovalNum:s.diffAdditionNum:s.textMuted,Me=A?s.diffRemovalPrefix:s.diffAdditionPrefix,re=A?"-":X?"+":" ",ie=()=>{if(_){let me=A?s.diffRemovalHighlightBg:s.diffAdditionHighlightBg;return r.createElement(E,{flexDirection:"column"},Ot(xt(C,y-15),T,void 0,me))}if(!(A||X)||N.length===0||!L){let me=A?s.diffRemovalText:X?s.diffAdditionText:s.textMuted;return r.createElement(E,{flexDirection:"column"},Ot(xt(C,y-15),T,me,void 0))}let pe=Math.max(10,y-15),De=xt(C,pe).split(`
25
- `),ve=[];if(N.forEach((me,R)=>{let te=/^\s+$/.test(me.value);if(A){let Z=N[R-1]?.removed||N[R+1]?.removed;me.removed||te&&Z?ve.push({text:me.value,isHighlight:!0}):me.added||ve.push({text:me.value,isHighlight:!1})}else if(X){let Z=N[R-1]?.added||N[R+1]?.added;me.added||te&&Z?ve.push({text:me.value,isHighlight:!0}):me.removed||ve.push({text:me.value,isHighlight:!1})}}),De.length<=1)return r.createElement(ne,{wrap:"wrap"},ve.map((me,R)=>A?me.isHighlight?r.createElement(r.Fragment,{key:R},Ot(me.text,T,s.diffRemovalHighlightColor,s.diffRemovalHighlightBg)):r.createElement(r.Fragment,{key:R},Ot(me.text,T,s.diffRemovalText)):X?me.isHighlight?r.createElement(r.Fragment,{key:R},Ot(me.text,T,s.diffAdditionHighlightColor,s.diffAdditionHighlightBg)):r.createElement(r.Fragment,{key:R},Ot(me.text,T,s.diffAdditionText)):r.createElement(r.Fragment,{key:R},Ot(me.text,T,s.textMuted))));let Ue=0,le=0,Ie=C.match(/^(\s*)/),be=Ie?Ie[1]:"",ee=be.substring(0,Math.min(be.length,8)),Ge=De.map((me,R)=>{let te=[],Z=me;R>0&&ee&&me.startsWith(ee)&&((ve[Ue]?ve[Ue].text.substring(le):"").startsWith(ee)||(te.push({text:ee,isHighlight:!1}),Z=me.substring(ee.length)));let ae=Z.length;for(;ae>0&&Ue<ve.length;){let fe=ve[Ue],he=fe.text.length-le;if(he<=0){Ue++,le=0;continue}let Ae=Math.min(ae,he);te.push({text:fe.text.substring(le,le+Ae),isHighlight:fe.isHighlight}),le+=Ae,ae-=Ae,le>=fe.text.length&&(Ue++,le=0)}for(;Ue<ve.length;){let fe=ve[Ue],he=fe.text.substring(le);if(/^\s+$/.test(he))Ue++,le=0;else if(he.startsWith(" ")||he.startsWith(" ")){let Ae=0;for(;Ae<he.length&&(he[Ae]===" "||he[Ae]===" ");)Ae++;le+=Ae,le>=fe.text.length&&(Ue++,le=0);break}else break}return te});if(Ue<ve.length){let me=Ge[Ge.length-1];for(;Ue<ve.length;){let R=ve[Ue];me.push({text:R.text.substring(le),isHighlight:R.isHighlight}),Ue++,le=0}}return r.createElement(E,{flexDirection:"column"},Ge.map((me,R)=>r.createElement(E,{key:R},r.createElement(ne,{wrap:"wrap"},me.map((te,Z)=>A?te.isHighlight?r.createElement(r.Fragment,{key:Z},Ot(te.text,T,s.diffRemovalHighlightColor,s.diffRemovalHighlightBg)):r.createElement(r.Fragment,{key:Z},Ot(te.text,T,s.diffRemovalText)):X?te.isHighlight?r.createElement(r.Fragment,{key:Z},Ot(te.text,T,s.diffAdditionHighlightColor,s.diffAdditionHighlightBg)):r.createElement(r.Fragment,{key:Z},Ot(te.text,T,s.diffAdditionText)):r.createElement(r.Fragment,{key:Z},Ot(te.text,T,s.textMuted)))))))};return r.createElement(E,{backgroundColor:s.codeBg,paddingX:1,width:y},r.createElement(E,{width:4,flexShrink:0,justifyContent:"flex-end"},r.createElement(ne,{color:ge},S)),r.createElement(E,{width:1,flexShrink:0,marginLeft:1},r.createElement(ne,{color:Me},re)),r.createElement(E,{marginLeft:1,backgroundColor:q,flexGrow:1},ie()))}),xd=r.memo(({text:t,columns:m=80,extension:h,theme:y="Dark"})=>{let T=Je(y),b=t.match(/\[DIFF_START\]([\s\S]*?)(?:\[DIFF_END\]|$)/),f=(b?b[1].trim():"").split(`
26
- `).map(A=>({line:A,parsed:bs(A),pairContent:null})),I=[];for(let A=0;A<f.length;A++){let X=f[A];X.parsed&&(X.parsed.isR||X.parsed.isA)?I.push(X):I.length>0&&(ws(I),I=[])}return I.length>0&&ws(I),r.createElement(E,{flexDirection:"column",width:m-3,marginBottom:1},r.createElement(E,{flexDirection:"column",paddingY:0,width:"100%"},r.createElement(E,{backgroundColor:T.codeBg,paddingX:1,width:"100%"},r.createElement(E,{width:3,flexShrink:0}),r.createElement(E,{width:1,flexShrink:0,marginLeft:1}),r.createElement(E,{flexGrow:1,marginLeft:1},r.createElement(ne,null," "))),f.map((A,X)=>r.createElement(xl,{key:X,line:A.line,pairContent:A.pairContent,columns:m-3,extension:h,theme:y})),r.createElement(E,{backgroundColor:T.codeBg,paddingX:1,width:"100%"},r.createElement(E,{width:3,flexShrink:0}),r.createElement(E,{width:1,flexShrink:0,marginLeft:1}),r.createElement(E,{flexGrow:1,marginLeft:1},r.createElement(ne,null," ")))))}),Ar=r.memo(({text:t,columns:m=80,theme:h="Dark"})=>{if(!t)return null;let y=Je(h),T="",b=t.match(/File\s+\[(.*?)\]/i);if(b&&(T=b[1].split(".").pop().toLowerCase()),t.includes("[DIFF_START]"))return r.createElement(xd,{text:t,columns:m,extension:T,theme:h});if(t.includes("- Content Preview:")){let s=t.split("- Content Preview:"),k=s[0],f=s[1]||"",I="[SYSTEM] Check the content preview for verification [/SYSTEM]",A=f.split(I),X=A[0]?.trim()||"",S=A[1]?`${I}${A[1]}`:"",C=X.split(`
24
+ `+pe)}else se=xt(P,h-4);f.push(r.createElement(E,{key:C,flexDirection:"column",width:"100%"},r.createElement($t,{text:se,color:s,italic:y,theme:T})))}}),X("final"),r.createElement(E,{flexDirection:"column",width:h-2},f)}),xl=r.memo(({line:t,pairContent:m,parentText:h,columns:y=80,extension:T,theme:b="Dark"})=>{let s=Je(b),k=t.includes("[UI_CONTEXT]"),f=t.replace("[UI_CONTEXT]","");if(k&&f.includes("\u2550"))return r.createElement(E,{backgroundColor:s.codeBg,paddingX:1,width:y},r.createElement(ne,{color:"gray"},"\u2550".repeat(Math.max(10,y-4))));let I=bs(t);if(!I)return r.createElement(E,{backgroundColor:s.codeBg,paddingX:1,width:y},r.createElement(E,{width:3,flexShrink:0}),r.createElement(E,{width:1,flexShrink:0,marginLeft:1}),r.createElement(E,{flexGrow:1,marginLeft:1},r.createElement(ne,{color:"gray"},xt(f,y-14))));let{isR:A,isA:X,num:S,content:C}=I,P=m,N=[];if(P!=null){let pe=A?C:P,Be=A?P:C;try{N=va(pe,Be)}catch{N=[]}}let L=N.some(pe=>A&&pe.removed||X&&pe.added),_=!P&&(A||X),Q=A?s.diffRemovalBg:X?s.diffAdditionBg:void 0,ge=A||X?A?s.diffRemovalNum:s.diffAdditionNum:s.textMuted,ye=A?s.diffRemovalPrefix:s.diffAdditionPrefix,se=A?"-":X?"+":" ",ie=()=>{if(_){let me=A?s.diffRemovalHighlightBg:s.diffAdditionHighlightBg;return r.createElement(E,{flexDirection:"column"},Ot(xt(C,y-15),T,void 0,me))}if(!(A||X)||N.length===0||!L){let me=A?s.diffRemovalText:X?s.diffAdditionText:s.textMuted;return r.createElement(E,{flexDirection:"column"},Ot(xt(C,y-15),T,me,void 0))}let pe=Math.max(10,y-15),Be=xt(C,pe).split(`
25
+ `),Ce=[];if(N.forEach((me,R)=>{let te=/^\s+$/.test(me.value);if(A){let Z=N[R-1]?.removed||N[R+1]?.removed;me.removed||te&&Z?Ce.push({text:me.value,isHighlight:!0}):me.added||Ce.push({text:me.value,isHighlight:!1})}else if(X){let Z=N[R-1]?.added||N[R+1]?.added;me.added||te&&Z?Ce.push({text:me.value,isHighlight:!0}):me.removed||Ce.push({text:me.value,isHighlight:!1})}}),Be.length<=1)return r.createElement(ne,{wrap:"wrap"},Ce.map((me,R)=>A?me.isHighlight?r.createElement(r.Fragment,{key:R},Ot(me.text,T,s.diffRemovalHighlightColor,s.diffRemovalHighlightBg)):r.createElement(r.Fragment,{key:R},Ot(me.text,T,s.diffRemovalText)):X?me.isHighlight?r.createElement(r.Fragment,{key:R},Ot(me.text,T,s.diffAdditionHighlightColor,s.diffAdditionHighlightBg)):r.createElement(r.Fragment,{key:R},Ot(me.text,T,s.diffAdditionText)):r.createElement(r.Fragment,{key:R},Ot(me.text,T,s.textMuted))));let Fe=0,le=0,Ie=C.match(/^(\s*)/),be=Ie?Ie[1]:"",ee=be.substring(0,Math.min(be.length,8)),We=Be.map((me,R)=>{let te=[],Z=me;R>0&&ee&&me.startsWith(ee)&&((Ce[Fe]?Ce[Fe].text.substring(le):"").startsWith(ee)||(te.push({text:ee,isHighlight:!1}),Z=me.substring(ee.length)));let ae=Z.length;for(;ae>0&&Fe<Ce.length;){let fe=Ce[Fe],he=fe.text.length-le;if(he<=0){Fe++,le=0;continue}let Ae=Math.min(ae,he);te.push({text:fe.text.substring(le,le+Ae),isHighlight:fe.isHighlight}),le+=Ae,ae-=Ae,le>=fe.text.length&&(Fe++,le=0)}for(;Fe<Ce.length;){let fe=Ce[Fe],he=fe.text.substring(le);if(/^\s+$/.test(he))Fe++,le=0;else if(he.startsWith(" ")||he.startsWith(" ")){let Ae=0;for(;Ae<he.length&&(he[Ae]===" "||he[Ae]===" ");)Ae++;le+=Ae,le>=fe.text.length&&(Fe++,le=0);break}else break}return te});if(Fe<Ce.length){let me=We[We.length-1];for(;Fe<Ce.length;){let R=Ce[Fe];me.push({text:R.text.substring(le),isHighlight:R.isHighlight}),Fe++,le=0}}return r.createElement(E,{flexDirection:"column"},We.map((me,R)=>r.createElement(E,{key:R},r.createElement(ne,{wrap:"wrap"},me.map((te,Z)=>A?te.isHighlight?r.createElement(r.Fragment,{key:Z},Ot(te.text,T,s.diffRemovalHighlightColor,s.diffRemovalHighlightBg)):r.createElement(r.Fragment,{key:Z},Ot(te.text,T,s.diffRemovalText)):X?te.isHighlight?r.createElement(r.Fragment,{key:Z},Ot(te.text,T,s.diffAdditionHighlightColor,s.diffAdditionHighlightBg)):r.createElement(r.Fragment,{key:Z},Ot(te.text,T,s.diffAdditionText)):r.createElement(r.Fragment,{key:Z},Ot(te.text,T,s.textMuted)))))))};return r.createElement(E,{backgroundColor:s.codeBg,paddingX:1,width:y},r.createElement(E,{width:4,flexShrink:0,justifyContent:"flex-end"},r.createElement(ne,{color:ge},S)),r.createElement(E,{width:1,flexShrink:0,marginLeft:1},r.createElement(ne,{color:ye},se)),r.createElement(E,{marginLeft:1,backgroundColor:Q,flexGrow:1},ie()))}),xd=r.memo(({text:t,columns:m=80,extension:h,theme:y="Dark"})=>{let T=Je(y),b=t.match(/\[DIFF_START\]([\s\S]*?)(?:\[DIFF_END\]|$)/),f=(b?b[1].trim():"").split(`
26
+ `).map(A=>({line:A,parsed:bs(A),pairContent:null})),I=[];for(let A=0;A<f.length;A++){let X=f[A];X.parsed&&(X.parsed.isR||X.parsed.isA)?I.push(X):I.length>0&&(Ts(I),I=[])}return I.length>0&&Ts(I),r.createElement(E,{flexDirection:"column",width:m-3,marginBottom:1},r.createElement(E,{flexDirection:"column",paddingY:0,width:"100%"},r.createElement(E,{backgroundColor:T.codeBg,paddingX:1,width:"100%"},r.createElement(E,{width:3,flexShrink:0}),r.createElement(E,{width:1,flexShrink:0,marginLeft:1}),r.createElement(E,{flexGrow:1,marginLeft:1},r.createElement(ne,null," "))),f.map((A,X)=>r.createElement(xl,{key:X,line:A.line,pairContent:A.pairContent,columns:m-3,extension:h,theme:y})),r.createElement(E,{backgroundColor:T.codeBg,paddingX:1,width:"100%"},r.createElement(E,{width:3,flexShrink:0}),r.createElement(E,{width:1,flexShrink:0,marginLeft:1}),r.createElement(E,{flexGrow:1,marginLeft:1},r.createElement(ne,null," ")))))}),Ar=r.memo(({text:t,columns:m=80,theme:h="Dark"})=>{if(!t)return null;let y=Je(h),T="",b=t.match(/File\s+\[(.*?)\]/i);if(b&&(T=b[1].split(".").pop().toLowerCase()),t.includes("[DIFF_START]"))return r.createElement(xd,{text:t,columns:m,extension:T,theme:h});if(t.includes("- Content Preview:")){let s=t.split("- Content Preview:"),k=s[0],f=s[1]||"",I="[SYSTEM] Check the content preview for verification [/SYSTEM]",A=f.split(I),X=A[0]?.trim()||"",S=A[1]?`${I}${A[1]}`:"",C=X.split(`
27
27
  `),P=String(C.length).length;return r.createElement(E,{flexDirection:"column",width:m-3},r.createElement(E,{flexDirection:"column",borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:y.codeBorder,paddingLeft:2,paddingRight:0,width:"100%",marginBottom:1,backgroundColor:y.codeBg},r.createElement(E,{flexDirection:"column",width:"100%"},r.createElement(E,{width:"100%"},r.createElement(E,{width:P+2,flexShrink:0},r.createElement(ne,null," ")),r.createElement(E,{flexGrow:1},r.createElement(ne,null," "))),C.map((N,L)=>r.createElement(E,{key:L,width:"100%"},r.createElement(E,{width:P+2,flexShrink:0},r.createElement(ne,{color:"gray",dimColor:!0},String(L+1).padStart(P," ")," ")),r.createElement(E,{flexGrow:1},Ot(N,T,y.text)))),r.createElement(E,{width:"100%"},r.createElement(E,{width:P+2,flexShrink:0},r.createElement(ne,null," ")),r.createElement(E,{flexGrow:1},r.createElement(ne,null," "))))))}if(t.includes("```")){let s=t.split(/(```\w*\n?[\s\S]*?(?:```|$))/g);return r.createElement(E,{flexDirection:"column",width:m-3},s.map((k,f)=>{if(k.startsWith("```")){let A=k.match(/```(\w*)\n?([\s\S]*?)(?:```|$)/),X=A?A[1]:"code",S=A?A[2]:k.replace(/^```\w*\n?/,"").replace(/```$/,""),C=S.trimEnd().split(`
28
28
  `),P=String(C.length).length,N=m-7-P,_=(N>5?xt(S,N):S).trimEnd().split(`
29
- `);return r.createElement(E,{key:f,flexDirection:"column",marginY:0,paddingLeft:2,paddingRight:0,width:"100%"},r.createElement(E,null,r.createElement(ne,{color:"gray",bold:!0},"\u25B6_ ",X.toUpperCase()||"TEXT")),r.createElement(E,{flexDirection:"column",width:"100%"},_.map((q,ge)=>{let re=xt(q,Math.max(10,N)).split(`
30
- `);return r.createElement(E,{key:ge,flexDirection:"column",width:"100%"},re.map((ie,pe)=>r.createElement(E,{key:pe,width:"100%"},r.createElement(E,{width:P+2,flexShrink:0},r.createElement(ne,{color:"gray"},pe===0?String(ge+1).padStart(P," ")+" ":" ".repeat(P+1))),r.createElement(E,{flexGrow:1},Ot(ie,X,y.text)))))})))}let I=k;return f>0&&(I=I.replace(/^[\r\n]+/,"")),f<s.length-1&&(I=I.replace(/[\r\n]+$/,"")),I?r.createElement(En,{key:f,text:I,columns:m-3,theme:h}):null}))}return r.createElement(En,{text:t,columns:m-3,theme:h})}),Es=t=>{let m=Math.round(t/1e3);if(m<=0)return"0s";let h=Math.floor(m/60),y=m%60;return h>0?`${h}m ${y}s`:`${m}s`},hl=r.memo(({msg:t,showFullThinking:m,columns:h=80,aiProvider:y,version:T,theme:b="Dark"})=>{let s=Je(b),k=t.role==="system"&&(t.text?.includes("[DIFF_START]")||t.text?.includes("- Content Preview:")),f=t.role==="system"&&t.text?.includes("[TOOL RESULT]: ERROR:")&&!t.text?.includes("[DIFF_START]")&&(t.toolName==="update_file"||t.text?.includes("Could not find exact match")),I=t.isTerminalRecord;if(t.isHomeWarning)return r.createElement(E,{marginBottom:1,paddingX:1,width:"100%"},r.createElement(E,{flexDirection:"column",borderStyle:"round",borderColor:s.border,dimColor:!0,padding:0,width:"100%"},r.createElement(E,{paddingX:1},r.createElement(ne,{color:s.text,bold:!0},t.text)),r.createElement(E,{paddingX:1,marginTop:0,marginBottom:0},r.createElement(ne,{color:s.text},t.subText))));if(t.isLogo)return r.createElement(E,{flexDirection:"column",alignItems:"flex-start",width:"100%",marginY:1},r.createElement(ne,null,Cr(T,y,b)));if(t.id&&String(t.id).startsWith("welcome"))return r.createElement(E,{flexDirection:"column",alignItems:"center",width:"100%",marginY:1},r.createElement(E,{borderStyle:"round",borderColor:s.borderMuted,paddingX:3,paddingY:0},r.createElement(ne,{color:s.text,bold:!0},t.text.trim())));if(t.isVisualFeedback)return r.createElement(E,{marginBottom:0,marginTop:0,paddingX:1,width:"100%"},r.createElement(ne,{color:s.text},t.text));if(t.isSteeringHint||t.role==="user"&&(t.text?.startsWith("[STEERING HINT]")||t.text?.startsWith("[QUESTION]"))){let N=t.hintContent||(t.text||"").replace(/^\[(?:STEERING HINT|QUESTION)\]\s*/i,"").trim();return r.createElement(E,{flexDirection:"column",width:h-1,marginBottom:0,marginTop:0},r.createElement(E,{width:h-1,height:1,overflow:"hidden"},r.createElement(ne,{color:s.userMsgBorder},"\u2584".repeat(Math.max(1,h-1)))),r.createElement(E,{backgroundColor:s.userMsgBg,paddingX:1,paddingY:0,width:h-1,flexDirection:"column"},xt(N.replace(/\r\n/g,`
29
+ `);return r.createElement(E,{key:f,flexDirection:"column",marginY:0,paddingLeft:2,paddingRight:0,width:"100%"},r.createElement(E,null,r.createElement(ne,{color:"gray",bold:!0},"\u25B6_ ",X.toUpperCase()||"TEXT")),r.createElement(E,{flexDirection:"column",width:"100%"},_.map((Q,ge)=>{let se=xt(Q,Math.max(10,N)).split(`
30
+ `);return r.createElement(E,{key:ge,flexDirection:"column",width:"100%"},se.map((ie,pe)=>r.createElement(E,{key:pe,width:"100%"},r.createElement(E,{width:P+2,flexShrink:0},r.createElement(ne,{color:"gray"},pe===0?String(ge+1).padStart(P," ")+" ":" ".repeat(P+1))),r.createElement(E,{flexGrow:1},Ot(ie,X,y.text)))))})))}let I=k;return f>0&&(I=I.replace(/^[\r\n]+/,"")),f<s.length-1&&(I=I.replace(/[\r\n]+$/,"")),I?r.createElement(En,{key:f,text:I,columns:m-3,theme:h}):null}))}return r.createElement(En,{text:t,columns:m-3,theme:h})}),Es=t=>{let m=Math.round(t/1e3);if(m<=0)return"0s";let h=Math.floor(m/60),y=m%60;return h>0?`${h}m ${y}s`:`${m}s`},hl=r.memo(({msg:t,showFullThinking:m,columns:h=80,aiProvider:y,version:T,theme:b="Dark"})=>{let s=Je(b),k=t.role==="system"&&(t.text?.includes("[DIFF_START]")||t.text?.includes("- Content Preview:")),f=t.role==="system"&&(t.text?.includes("[ACTION RESULT]: ERROR:")||t.text?.includes("[TOOL RESULT]: ERROR:"))&&!t.text?.includes("[DIFF_START]")&&(t.toolName==="update_file"||t.text?.includes("Could not find exact match")),I=t.isTerminalRecord;if(t.isHomeWarning)return r.createElement(E,{marginBottom:1,paddingX:1,width:"100%"},r.createElement(E,{flexDirection:"column",borderStyle:"round",borderColor:s.border,dimColor:!0,padding:0,width:"100%"},r.createElement(E,{paddingX:1},r.createElement(ne,{color:s.text,bold:!0},t.text)),r.createElement(E,{paddingX:1,marginTop:0,marginBottom:0},r.createElement(ne,{color:s.text},t.subText))));if(t.isLogo)return r.createElement(E,{flexDirection:"column",alignItems:"flex-start",width:"100%",marginY:1},r.createElement(ne,null,Cr(T,y,b)));if(t.id&&String(t.id).startsWith("welcome"))return r.createElement(E,{flexDirection:"column",alignItems:"center",width:"100%",marginY:1},r.createElement(E,{borderStyle:"round",borderColor:s.borderMuted,paddingX:3,paddingY:0},r.createElement(ne,{color:s.text,bold:!0},t.text.trim())));if(t.isVisualFeedback)return r.createElement(E,{marginBottom:0,marginTop:0,paddingX:1,width:"100%"},r.createElement(ne,{color:s.text},t.text));if(t.isSteeringHint||t.role==="user"&&(t.text?.startsWith("[STEERING HINT]")||t.text?.startsWith("[QUESTION]"))){let N=t.hintContent||(t.text||"").replace(/^\[(?:STEERING HINT|QUESTION)\]\s*/i,"").trim();return r.createElement(E,{flexDirection:"column",width:h-1,marginBottom:0,marginTop:0},r.createElement(E,{width:h-1,height:1,overflow:"hidden"},r.createElement(ne,{color:s.userMsgBorder},"\u2584".repeat(Math.max(1,h-1)))),r.createElement(E,{backgroundColor:s.userMsgBg,paddingX:1,paddingY:0,width:h-1,flexDirection:"column"},xt(N.replace(/\r\n/g,`
31
31
  `).replace(/\r/g,`
32
32
  `).replace(/\\\n/g,`
33
33
  `).replace(/\\$/,""),h-7).split(`
34
- `).map((L,_)=>r.createElement(E,{key:_,flexDirection:"row",width:"100%"},r.createElement(E,{flexShrink:0,width:2},r.createElement(ne,{bold:!0,color:s.userMsgText},_===0?"\u2726":" ")),r.createElement(E,{flexGrow:1,marginLeft:1},r.createElement($t,{text:L,color:s.userMsgText,theme:b}))))),r.createElement(E,{width:h-1,height:1,overflow:"hidden"},r.createElement(ne,{color:s.userMsgBorder},"\u2580".repeat(Math.max(1,h-1)))))}if(f)return r.createElement(E,{marginBottom:1},r.createElement(E,{flexDirection:"column",borderStyle:"round",borderColor:s.border,paddingX:1,paddingY:0},r.createElement(ne,{color:s.text,bold:!0,underline:!0},"\u2717 PATCH FAILED"),r.createElement(E,{marginTop:1},r.createElement(ne,{color:s.textMuted,bold:!0},"Model generated malformed edit."))));if(t.role==="system"&&t.text?.includes("[TOOL RESULT]")&&!k&&!I&&!f)return null;if(t.isImageStats)return r.createElement(E,{marginBottom:1,paddingX:1,width:"100%"},r.createElement(E,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,padding:0,width:"100%"},r.createElement(E,{paddingX:1,backgroundColor:s.codeBg},r.createElement(ne,{color:s.text,bold:!0},"IMAGE STATS")),r.createElement(E,{paddingX:1,marginTop:1,marginBottom:1,flexDirection:"column"},t.text.split(`
35
- `).map((N,L)=>r.createElement(ne,{key:L,color:s.textMuted},N)))));if(t.isAskRecord){let N=t.text.match(/Selection: (.*)/),L=N?N[1]:"No selection",_=t.text.match(/Question: (.*)/),q=_?_[1]:null,ge=q==="Agent has been running for a long time. Do you want to continue execution?";return r.createElement(E,{marginBottom:0,paddingX:1,width:"100%"},r.createElement(E,{flexDirection:"column",borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!0,borderBottom:!0,borderColor:s.codeBorder,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,marginY:1,width:h-2},r.createElement(E,{paddingX:1},r.createElement(ne,{color:s.success,bold:!0},ge?"TURN SAFETY SYSTEM: RESOLVED":"AGENT REQUEST: RESOLVED")),q&&r.createElement(E,{paddingX:1,marginTop:1},r.createElement(ne,{color:s.secondary},q)),r.createElement(E,{paddingX:1,marginTop:1,marginBottom:0},r.createElement(ne,{color:s.text},"Selection: ",r.createElement(ne,{color:s.textMuted,bold:!0},L)))))}if(t.isAboutRecord)return r.createElement(E,{marginBottom:0,paddingX:1,width:"100%"},r.createElement(E,{flexDirection:"column",borderStyle:"round",border:!0,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,backgroundColor:s.codeBg,width:"100%"},r.createElement(E,{paddingX:1},r.createElement(ne,{color:s.text,bold:!0},"ABOUT FLUX FLOW")),r.createElement(E,{paddingX:1,marginTop:1,marginBottom:1},r.createElement(ne,{color:s.text},t.text))));if(t.isUpdateNotification)return r.createElement(E,{marginBottom:1,paddingX:1,width:"100%"},r.createElement(E,{flexDirection:"column",borderStyle:"round",border:!0,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,backgroundColor:s.codeBg,width:"100%"},r.createElement(E,{paddingX:1},r.createElement(ne,{color:s.text,bold:!0},"UPDATE AVAILABLE")),r.createElement(E,{paddingX:1,marginTop:1,marginBottom:1},r.createElement(Ar,{text:t.text,columns:h,theme:b}))));if(t.isHelpRecord){let N=[{cmd:"/quit",desc:"Exit and shutdown Flux"},{cmd:"/help",desc:"Show all available commands"},{cmd:"/compress",desc:"Summarize and compress chat history"},{cmd:"/truncate",desc:"Truncate tool results in chat history"},{cmd:"/clear",desc:"Clear terminal screen"},{cmd:"/resume",desc:"Load previous session"},{cmd:"/revert",desc:"Revert codebase to checkpoint"},{cmd:"/save",desc:"Force save current chat"},{cmd:"/export",desc:"Export current chat or error logs"},{cmd:"/chats",desc:"List all chat sessions"},{cmd:"/btw",desc:"Send raw inquiry mid-turn"},{cmd:"/budget",desc:"Set or View budget limits"},{cmd:"/mode",desc:"Toggle Flux/Flow modes"},{cmd:"/thinking",desc:"Set AI reasoning depth"},{cmd:"/model",desc:"Switch AI model"},{cmd:"/wildcard-tooling",desc:"Use if the model lacks Tooling Capability"},{cmd:"/wildercard-tooling",desc:"Extended version of /wildcard-tooling"},{cmd:"/provider",desc:"Select AI Provider"},{cmd:"/settings",desc:"Configure system prefs"},{cmd:"/theme",desc:"Customize UI color theme"},{cmd:"/key",desc:"Manage API keys"},{cmd:"/profile",desc:"Edit developer persona"},{cmd:"/memory",desc:"Manage agent memory"},{cmd:"/stats",desc:"Show session usage"},{cmd:"/usage",desc:"Open graphical token usage & analytics in browser"},{cmd:"/reset",desc:"Wipe all saved FluxFlow AppData"},{cmd:"/about",desc:"Project info & credits"},{cmd:"/changelog",desc:"View latest updates"},{cmd:"/docs",desc:"View documentation"},{cmd:"/fluxflow",desc:"Project management"},{cmd:"/update",desc:"Check/Install updates"}];return r.createElement(E,{marginBottom:1,paddingX:1,width:"100%"},r.createElement(E,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:1,width:"100%"},r.createElement(ne,{color:s.text,bold:!0,underline:!0},"AVAILABLE COMMANDS IN FLUX-FLOW"),r.createElement(E,{flexDirection:"column",marginTop:1},N.map((L,_)=>r.createElement(E,{key:_,flexDirection:"row"},r.createElement(E,{width:20},r.createElement(ne,{color:s.text,bold:!0},L.cmd)),r.createElement(ne,{color:s.textMuted}," - ",L.desc))))))}if(t.isTerminalRecord){let N=t.text.match(/COMMAND: (.*)/),L=t.text.match(/PTY: (true|false)/),_=t.text.match(/OUTPUT: ([\s\S]*)/),q=N?N[1]:"No Command",ge=L?L[1]==="true":!1,Me=_?_[1]:"";return r.createElement(E,{marginBottom:0,paddingX:1,width:"100%"},r.createElement(Ir,{command:q,output:Me,completed:!0,columns:h,isPty:ge,theme:b}))}let[X,S]=r.useState(!t.isStreaming),C=r.useMemo(()=>Wi(t.text,t.role),[t.text,t.role]);r.useEffect(()=>{t.isStreaming&&S(!1)},[t.id]);let P=r.useMemo(()=>t.role==="think"&&!m?"Thinking...":t.isStreaming?C:C.trimEnd(),[C,t.role,m,t.isStreaming]);return t.role==="think"&&!gl()||t.role==="agent"&&P.trim()===""?null:r.createElement(E,{marginBottom:(t.role==="think"||t.role==="user"||t.role==="agent",0),marginTop:(t.role==="think"||t.role==="user"||t.role==="agent",0),flexDirection:"column",flexShrink:0,width:"100%",flexGrow:1},t.role==="user"?r.createElement(E,{flexDirection:"column",width:h-1},r.createElement(E,{width:h-1,height:1,overflow:"hidden"},r.createElement(ne,{color:s.userMsgBorder},"\u2584".repeat(Math.max(1,h-1)))),r.createElement(E,{backgroundColor:s.userMsgBg,paddingX:1,paddingY:0,width:h-1,flexDirection:"column"},xt(P.replace(/\r\n/g,`
34
+ `).map((L,_)=>r.createElement(E,{key:_,flexDirection:"row",width:"100%"},r.createElement(E,{flexShrink:0,width:2},r.createElement(ne,{bold:!0,color:s.userMsgText},_===0?"\u2726":" ")),r.createElement(E,{flexGrow:1,marginLeft:1},r.createElement($t,{text:L,color:s.userMsgText,theme:b}))))),r.createElement(E,{width:h-1,height:1,overflow:"hidden"},r.createElement(ne,{color:s.userMsgBorder},"\u2580".repeat(Math.max(1,h-1)))))}if(f)return r.createElement(E,{marginBottom:1},r.createElement(E,{flexDirection:"column",borderStyle:"round",borderColor:s.border,paddingX:1,paddingY:0},r.createElement(ne,{color:s.text,bold:!0,underline:!0},"\u2717 PATCH FAILED"),r.createElement(E,{marginTop:1},r.createElement(ne,{color:s.textMuted,bold:!0},"Model generated malformed edit."))));if(t.role==="system"&&(t.text?.includes("[ACTION RESULT]")||t.text?.includes("[TOOL RESULT]"))&&!k&&!I&&!f)return null;if(t.isImageStats)return r.createElement(E,{marginBottom:1,paddingX:1,width:"100%"},r.createElement(E,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,padding:0,width:"100%"},r.createElement(E,{paddingX:1,backgroundColor:s.codeBg},r.createElement(ne,{color:s.text,bold:!0},"IMAGE STATS")),r.createElement(E,{paddingX:1,marginTop:1,marginBottom:1,flexDirection:"column"},t.text.split(`
35
+ `).map((N,L)=>r.createElement(ne,{key:L,color:s.textMuted},N)))));if(t.isAskRecord){let N=t.text.match(/Selection: (.*)/),L=N?N[1]:"No selection",_=t.text.match(/Question: (.*)/),Q=_?_[1]:null,ge=Q==="Agent has been running for a long time. Do you want to continue execution?";return r.createElement(E,{marginBottom:0,paddingX:1,width:"100%"},r.createElement(E,{flexDirection:"column",borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!0,borderBottom:!0,borderColor:s.codeBorder,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,marginY:1,width:h-2},r.createElement(E,{paddingX:1},r.createElement(ne,{color:s.success,bold:!0},ge?"TURN SAFETY SYSTEM: RESOLVED":"AGENT REQUEST: RESOLVED")),Q&&r.createElement(E,{paddingX:1,marginTop:1},r.createElement(ne,{color:s.secondary},Q)),r.createElement(E,{paddingX:1,marginTop:1,marginBottom:0},r.createElement(ne,{color:s.text},"Selection: ",r.createElement(ne,{color:s.textMuted,bold:!0},L)))))}if(t.isAboutRecord)return r.createElement(E,{marginBottom:0,paddingX:1,width:"100%"},r.createElement(E,{flexDirection:"column",borderStyle:"round",border:!0,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,backgroundColor:s.codeBg,width:"100%"},r.createElement(E,{paddingX:1},r.createElement(ne,{color:s.text,bold:!0},"ABOUT FLUX FLOW")),r.createElement(E,{paddingX:1,marginTop:1,marginBottom:1},r.createElement(ne,{color:s.text},t.text))));if(t.isUpdateNotification)return r.createElement(E,{marginBottom:1,paddingX:1,width:"100%"},r.createElement(E,{flexDirection:"column",borderStyle:"round",border:!0,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,backgroundColor:s.codeBg,width:"100%"},r.createElement(E,{paddingX:1},r.createElement(ne,{color:s.text,bold:!0},"UPDATE AVAILABLE")),r.createElement(E,{paddingX:1,marginTop:1,marginBottom:1},r.createElement(Ar,{text:t.text,columns:h,theme:b}))));if(t.isHelpRecord){let N=[{cmd:"/quit",desc:"Exit and shutdown Flux"},{cmd:"/help",desc:"Show all available commands"},{cmd:"/compress",desc:"Summarize and compress chat history"},{cmd:"/truncate",desc:"Truncate tool results in chat history"},{cmd:"/clear",desc:"Clear terminal screen"},{cmd:"/resume",desc:"Load previous session"},{cmd:"/revert",desc:"Revert codebase to checkpoint"},{cmd:"/save",desc:"Force save current chat"},{cmd:"/export",desc:"Export current chat or error logs"},{cmd:"/chats",desc:"List all chat sessions"},{cmd:"/btw",desc:"Send raw inquiry mid-turn"},{cmd:"/budget",desc:"Set or View budget limits"},{cmd:"/mode",desc:"Toggle Flux/Flow modes"},{cmd:"/thinking",desc:"Set AI reasoning depth"},{cmd:"/model",desc:"Switch AI model"},{cmd:"/wildcard-tooling",desc:"Use if the model lacks Tooling Capability"},{cmd:"/wildercard-tooling",desc:"Extended version of /wildcard-tooling"},{cmd:"/provider",desc:"Select AI Provider"},{cmd:"/settings",desc:"Configure system prefs"},{cmd:"/theme",desc:"Customize UI color theme"},{cmd:"/key",desc:"Manage API keys"},{cmd:"/profile",desc:"Edit developer persona"},{cmd:"/memory",desc:"Manage agent memory"},{cmd:"/stats",desc:"Show session usage"},{cmd:"/usage",desc:"Open graphical token usage & analytics in browser"},{cmd:"/reset",desc:"Wipe all saved FluxFlow AppData"},{cmd:"/about",desc:"Project info & credits"},{cmd:"/changelog",desc:"View latest updates"},{cmd:"/docs",desc:"View documentation"},{cmd:"/fluxflow",desc:"Project management"},{cmd:"/update",desc:"Check/Install updates"}];return r.createElement(E,{marginBottom:1,paddingX:1,width:"100%"},r.createElement(E,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:1,width:"100%"},r.createElement(ne,{color:s.text,bold:!0,underline:!0},"AVAILABLE COMMANDS IN FLUX-FLOW"),r.createElement(E,{flexDirection:"column",marginTop:1},N.map((L,_)=>r.createElement(E,{key:_,flexDirection:"row"},r.createElement(E,{width:20},r.createElement(ne,{color:s.text,bold:!0},L.cmd)),r.createElement(ne,{color:s.textMuted}," - ",L.desc))))))}if(t.isTerminalRecord){let N=t.text.match(/COMMAND: (.*)/),L=t.text.match(/PTY: (true|false)/),_=t.text.match(/OUTPUT: ([\s\S]*)/),Q=N?N[1]:"No Command",ge=L?L[1]==="true":!1,ye=_?_[1]:"";return r.createElement(E,{marginBottom:0,paddingX:1,width:"100%"},r.createElement(Ir,{command:Q,output:ye,completed:!0,columns:h,isPty:ge,theme:b}))}let[X,S]=r.useState(!t.isStreaming),C=r.useMemo(()=>Gi(t.text,t.role),[t.text,t.role]);r.useEffect(()=>{t.isStreaming&&S(!1)},[t.id]);let P=r.useMemo(()=>t.role==="think"&&!m?"Thinking...":t.isStreaming?C:C.trimEnd(),[C,t.role,m,t.isStreaming]);return t.role==="think"&&!gl()||t.role==="agent"&&P.trim()===""?null:r.createElement(E,{marginBottom:(t.role==="think"||t.role==="user"||t.role==="agent",0),marginTop:(t.role==="think"||t.role==="user"||t.role==="agent",0),flexDirection:"column",flexShrink:0,width:"100%",flexGrow:1},t.role==="user"?r.createElement(E,{flexDirection:"column",width:h-1},r.createElement(E,{width:h-1,height:1,overflow:"hidden"},r.createElement(ne,{color:s.userMsgBorder},"\u2584".repeat(Math.max(1,h-1)))),r.createElement(E,{backgroundColor:s.userMsgBg,paddingX:1,paddingY:0,width:h-1,flexDirection:"column"},xt(P.replace(/\r\n/g,`
36
36
  `).replace(/\r/g,`
37
37
  `).replace(/\\\n/g,`
38
38
  `).replace(/\\$/,""),h-7).split(`
39
39
  `).map((N,L)=>r.createElement(E,{key:L,flexDirection:"row",width:"100%"},r.createElement(E,{flexShrink:0,width:2},r.createElement(ne,{bold:!0,color:s.userMsgText},L===0?">":" ")),r.createElement(E,{flexGrow:1,marginLeft:1},r.createElement($t,{text:N,color:t.color||s.userMsgText,theme:b}))))),r.createElement(E,{width:h-1,height:1,overflow:"hidden"},r.createElement(ne,{color:s.userMsgBorder},"\u2580".repeat(Math.max(1,h-1))))):t.role==="think"?r.createElement(E,{flexDirection:"column",marginTop:0,marginBottom:0,paddingX:0,width:"100%"},t.isStreaming&&!t.duration?r.createElement(ne,{bold:!0,color:s.text},"\u2727 Thinking..."):r.createElement(ne,{bold:!0,color:s.text},"\u2726 Thought",t.duration?r.createElement(ne,{color:s.textMuted}," for ",r.createElement(ne,{bold:!0,color:s.text},Es(t.duration))):"s..."),r.createElement(E,{borderStyle:"single",borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:s.borderMuted,paddingLeft:2,paddingTop:0,paddingBottom:0,flexDirection:"column",width:"100%"},Ea(P,h))):r.createElement(E,{flexDirection:"column",paddingX:1,marginTop:0,width:"100%"},r.createElement(Ar,{text:P.replace(/ \|\n\n/g,` |
40
- `),columns:h,theme:b}),t.memoryUpdated&&r.createElement(E,{marginTop:1,width:"100%"},r.createElement(ne,{color:s.text,italic:!0},"[Memory Updated]")),t.role==="agent"&&t.workedDuration?r.createElement(E,{marginTop:1,marginBottom:2,width:"100%"},r.createElement(ne,{color:s.textMuted},"["),r.createElement(ne,{color:s.textMuted},"Worked for ",r.createElement(ne,{bold:!0,color:s.text},Es(t.workedDuration))),r.createElement(ne,{color:s.textMuted},"]")):null))}),Lr=r.memo(({block:t,columns:m=80,showFullThinking:h,aiProvider:y,version:T,theme:b="Dark"})=>{let s=Je(b),{msg:k,type:f,text:I,isStreamingMsg:A,workedDuration:X}=t;if((f==="think-header"||f==="think-line"||f==="think-footer-padding")&&!gl())return null;if(f==="chunk")return r.createElement(E,{flexDirection:"column",width:"100%"},t.blocks.map(S=>r.createElement(Lr,{key:S.key,block:S,columns:m,showFullThinking:h,aiProvider:y,version:T,theme:b})));if(f==="full-message")return r.createElement(hl,{msg:k,showFullThinking:h,columns:m,aiProvider:y,version:T,theme:b});if(f==="think-header")return r.createElement(E,{flexDirection:"column",paddingX:1,width:"100%",marginTop:0,marginBottom:0},A?r.createElement(ne,{bold:!0,color:s.text},"\u2727 Thinking..."):r.createElement(ne,{bold:!0,color:s.text},"\u2726 Thoughts..."),h&&r.createElement(E,{flexDirection:"row",width:"100%"},r.createElement(ne,{color:s.textMuted},"\u2502 ")));if(f==="think-line"){if(!h)return null;if(!I||I.trim()==="")return r.createElement(E,{flexDirection:"row",width:"100%",paddingX:1},r.createElement(ne,{color:s.textMuted},"\u2502 "));let S=cl(I,A,t.isActiveBlock);return r.createElement(E,{flexDirection:"row",width:"100%",paddingX:1},r.createElement(ne,{color:s.textMuted},"\u2502 "),r.createElement(E,{flexGrow:1,marginLeft:1},r.createElement($t,{text:S,color:s.textMuted,italic:!0,theme:b})))}if(f==="think-footer-padding")return h?r.createElement(E,{flexDirection:"row",width:"100%",paddingX:1},r.createElement(ne,{color:s.textMuted},"\u2502 ")):null;if(f==="agent-line"){if(!I||I.trim()==="")return r.createElement(E,{height:1});let S=cl(I,A,t.isActiveBlock),C=S.trim();if(C==="---"||C==="***"||C==="___")return r.createElement(E,{flexDirection:"column",paddingX:1,width:"100%",marginY:0},r.createElement(E,{borderStyle:"single",borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,width:"100%",borderColor:s.borderMuted}));let P=C.match(Ia);if(P){let _=P[1].length,q=P[2],Me=["yellow",s.secondary||"magenta",s.info||"cyan","green","blue",s.text][_-1]||s.text;return r.createElement(E,{flexDirection:"column",paddingX:1,width:"100%",marginTop:0,marginBottom:0},r.createElement(ne,{bold:!0,color:Me,underline:!0},r.createElement($t,{text:q,color:Me,theme:b})))}if(C.startsWith(">")){let _=C.replace(/^>\s*/,"");return r.createElement(E,{flexDirection:"column",paddingX:1,width:"100%"},r.createElement(E,{borderStyle:"bold",borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:s.borderMuted,paddingLeft:1,marginY:0},r.createElement($t,{text:_,color:s.textMuted,italic:!0,theme:b})))}let N=/^[\*\-\+]\s/.test(C),L=/^\d+\.\s/.test(C);if(N||L){let _=N?" \u2022 ":C.match(/^\d+\.\s/)[0],q=C.replace(/^[\*\-\+\d+\.]+\s*/,"");return r.createElement(E,{flexDirection:"row",paddingX:1,width:"100%"},r.createElement(ne,{color:s.info||s.textMuted},_),r.createElement(E,{flexGrow:1},r.createElement($t,{text:q,color:s.text,theme:b})))}return r.createElement(E,{flexDirection:"column",paddingX:1,width:"100%"},r.createElement($t,{text:S,color:s.text,theme:b}))}if(f==="table-header"||f==="table-row"){let S=f==="table-header",C=s.codeText||s.secondary||s.info||"cyan",P=t.colHeaders||[],N=S?P:t.cells||[],L=Math.max(1,t.colCount||P.length||N.length||1),_=Array.from({length:L},(le,Ie)=>N[Ie]||""),q=Math.max(20,(m||80)-8),ge=L>=4,Me=/^(#|no\.?|num\.?|status|state|type|ok|done|✔|✘|active)$/i,re=[],ie=0,pe=0;for(let le=0;le<L;le++){let Ie=(P[le]||"").trim();if(ge&&(Me.test(Ie)||Ie==="#")){let be=Math.max(Ie.length+4,8);re.push(be),ie+=be}else re.push(null),pe++}let De=Math.max(pe*12,q-ie),ve=pe>0?Math.max(10,Math.floor(De/pe)):10;for(let le=0;le<L;le++)re[le]===null&&(re[le]=ve);let Ue=re.reduce((le,Ie)=>le+Ie,0);return S?r.createElement(E,{flexDirection:"column",paddingX:1,width:"100%",marginTop:0,marginBottom:1},r.createElement(E,{flexDirection:"row",borderStyle:"single",borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,borderColor:s.borderMuted,paddingBottom:0,width:Ue},P.map((le,Ie)=>{let be=re[Ie]||6;return r.createElement(E,{key:Ie,width:be,paddingRight:1,flexDirection:"column"},r.createElement($t,{text:xt(le,Math.max(2,be-1)),color:C,theme:b}))}))):r.createElement(E,{flexDirection:"row",paddingX:1,width:"100%",marginBottom:1},_.map((le,Ie)=>{let be=re[Ie]||6;return r.createElement(E,{key:Ie,width:be,paddingRight:1,flexDirection:"column"},r.createElement($t,{text:xt(le,Math.max(2,be-1)),color:s.text,theme:b}))}))}if(f==="table-close")return r.createElement(E,{height:0});if(f==="table")return r.createElement(E,{flexDirection:"column",paddingX:1,width:"100%"},r.createElement(fl,{buffer:I.split(`
40
+ `),columns:h,theme:b}),t.memoryUpdated&&r.createElement(E,{marginTop:1,width:"100%"},r.createElement(ne,{color:s.text,italic:!0},"[Memory Updated]")),t.role==="agent"&&t.workedDuration?r.createElement(E,{marginTop:1,marginBottom:2,width:"100%"},r.createElement(ne,{color:s.textMuted},"["),r.createElement(ne,{color:s.textMuted},"Worked for ",r.createElement(ne,{bold:!0,color:s.text},Es(t.workedDuration))),r.createElement(ne,{color:s.textMuted},"]")):null))}),Lr=r.memo(({block:t,columns:m=80,showFullThinking:h,aiProvider:y,version:T,theme:b="Dark"})=>{let s=Je(b),{msg:k,type:f,text:I,isStreamingMsg:A,workedDuration:X}=t;if((f==="think-header"||f==="think-line"||f==="think-footer-padding")&&!gl())return null;if(f==="chunk")return r.createElement(E,{flexDirection:"column",width:"100%"},t.blocks.map(S=>r.createElement(Lr,{key:S.key,block:S,columns:m,showFullThinking:h,aiProvider:y,version:T,theme:b})));if(f==="full-message")return r.createElement(hl,{msg:k,showFullThinking:h,columns:m,aiProvider:y,version:T,theme:b});if(f==="think-header")return r.createElement(E,{flexDirection:"column",paddingX:1,width:"100%",marginTop:0,marginBottom:0},A?r.createElement(ne,{bold:!0,color:s.text},"\u2727 Thinking..."):r.createElement(ne,{bold:!0,color:s.text},"\u2726 Thoughts..."),h&&r.createElement(E,{flexDirection:"row",width:"100%"},r.createElement(ne,{color:s.textMuted},"\u2502 ")));if(f==="think-line"){if(!h)return null;if(!I||I.trim()==="")return r.createElement(E,{flexDirection:"row",width:"100%",paddingX:1},r.createElement(ne,{color:s.textMuted},"\u2502 "));let S=cl(I,A,t.isActiveBlock);return r.createElement(E,{flexDirection:"row",width:"100%",paddingX:1},r.createElement(ne,{color:s.textMuted},"\u2502 "),r.createElement(E,{flexGrow:1,marginLeft:1},r.createElement($t,{text:S,color:s.textMuted,italic:!0,theme:b})))}if(f==="think-footer-padding")return h?r.createElement(E,{flexDirection:"row",width:"100%",paddingX:1},r.createElement(ne,{color:s.textMuted},"\u2502 ")):null;if(f==="agent-line"){if(!I||I.trim()==="")return r.createElement(E,{height:1});let S=cl(I,A,t.isActiveBlock),C=S.trim();if(C==="---"||C==="***"||C==="___")return r.createElement(E,{flexDirection:"column",paddingX:1,width:"100%",marginY:0},r.createElement(E,{borderStyle:"single",borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,width:"100%",borderColor:s.borderMuted}));let P=C.match(Ia);if(P){let _=P[1].length,Q=P[2],ye=["yellow",s.secondary||"magenta",s.info||"cyan","green","blue",s.text][_-1]||s.text;return r.createElement(E,{flexDirection:"column",paddingX:1,width:"100%",marginTop:0,marginBottom:0},r.createElement(ne,{bold:!0,color:ye,underline:!0},r.createElement($t,{text:Q,color:ye,theme:b})))}if(C.startsWith(">")){let _=C.replace(/^>\s*/,"");return r.createElement(E,{flexDirection:"column",paddingX:1,width:"100%"},r.createElement(E,{borderStyle:"bold",borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:s.borderMuted,paddingLeft:1,marginY:0},r.createElement($t,{text:_,color:s.textMuted,italic:!0,theme:b})))}let N=/^[\*\-\+]\s/.test(C),L=/^\d+\.\s/.test(C);if(N||L){let _=N?" \u2022 ":C.match(/^\d+\.\s/)[0],Q=C.replace(/^[\*\-\+\d+\.]+\s*/,"");return r.createElement(E,{flexDirection:"row",paddingX:1,width:"100%"},r.createElement(ne,{color:s.info||s.textMuted},_),r.createElement(E,{flexGrow:1},r.createElement($t,{text:Q,color:s.text,theme:b})))}return r.createElement(E,{flexDirection:"column",paddingX:1,width:"100%"},r.createElement($t,{text:S,color:s.text,theme:b}))}if(f==="table-header"||f==="table-row"){let S=f==="table-header",C=s.codeText||s.secondary||s.info||"cyan",P=t.colHeaders||[],N=S?P:t.cells||[],L=Math.max(1,t.colCount||P.length||N.length||1),_=Array.from({length:L},(le,Ie)=>N[Ie]||""),Q=Math.max(20,(m||80)-8),ge=L>=4,ye=/^(#|no\.?|num\.?|status|state|type|ok|done|✔|✘|active)$/i,se=[],ie=0,pe=0;for(let le=0;le<L;le++){let Ie=(P[le]||"").trim();if(ge&&(ye.test(Ie)||Ie==="#")){let be=Math.max(Ie.length+4,8);se.push(be),ie+=be}else se.push(null),pe++}let Be=Math.max(pe*12,Q-ie),Ce=pe>0?Math.max(10,Math.floor(Be/pe)):10;for(let le=0;le<L;le++)se[le]===null&&(se[le]=Ce);let Fe=se.reduce((le,Ie)=>le+Ie,0);return S?r.createElement(E,{flexDirection:"column",paddingX:1,width:"100%",marginTop:0,marginBottom:1},r.createElement(E,{flexDirection:"row",borderStyle:"single",borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,borderColor:s.borderMuted,paddingBottom:0,width:Fe},P.map((le,Ie)=>{let be=se[Ie]||6;return r.createElement(E,{key:Ie,width:be,paddingRight:1,flexDirection:"column"},r.createElement($t,{text:xt(le,Math.max(2,be-1)),color:C,theme:b}))}))):r.createElement(E,{flexDirection:"row",paddingX:1,width:"100%",marginBottom:1},_.map((le,Ie)=>{let be=se[Ie]||6;return r.createElement(E,{key:Ie,width:be,paddingRight:1,flexDirection:"column"},r.createElement($t,{text:xt(le,Math.max(2,be-1)),color:s.text,theme:b}))}))}if(f==="table-close")return r.createElement(E,{height:0});if(f==="table")return r.createElement(E,{flexDirection:"column",paddingX:1,width:"100%"},r.createElement(fl,{buffer:I.split(`
41
41
  `),terminalWidth:m,theme:b}));if(f==="diff-line"){let{isFirstLine:S,isLastLine:C}=t,P=(N=!1)=>r.createElement(E,{backgroundColor:s.codeBg,paddingX:1,width:m,marginBottom:N?1:0},r.createElement(E,{width:3,flexShrink:0}),r.createElement(E,{width:1,flexShrink:0,marginLeft:1}),r.createElement(E,{flexGrow:1,marginLeft:1},r.createElement(ne,null," ")));return r.createElement(E,{flexDirection:"column"},S&&P(!1),r.createElement(xl,{line:I,pairContent:t.pairContent,parentText:void 0,columns:m,theme:b}),C&&P(!0))}if(f==="code-fence-open"){let S={paddingLeft:2,width:"100%"};return r.createElement(E,{flexDirection:"column",marginTop:0,marginBottom:0,width:"100%"},r.createElement(E,{flexDirection:"row",...S},r.createElement(ne,null," ")),r.createElement(E,{flexDirection:"row",...S},r.createElement(ne,{color:"gray",bold:!0},"\u25B6_ ",(I||"TEXT").toUpperCase())))}if(f==="code-line"){let{lineNum:S,lang:C}=t,P=m-12,L=xt(I,Math.max(10,P)).split(`
42
- `);return r.createElement(E,{flexDirection:"column",width:"100%"},L.map((_,q)=>r.createElement(E,{key:q,flexDirection:"row",borderColor:s.codeBorder,paddingLeft:2,width:"100%"},r.createElement(E,{width:5,flexShrink:0},r.createElement(ne,{color:"gray",dimColor:!0},q===0?String(S).padStart(4," ")+" ":" ")),r.createElement(E,{flexGrow:1},Ot(_,C,s.text)))))}if(f==="code-fence-close")return r.createElement(E,{flexDirection:"row",paddingLeft:2,marginBottom:1,width:"100%"},r.createElement(ne,null," "));if(f==="write-header")return r.createElement(E,{flexDirection:"column",paddingX:1,width:m},r.createElement(En,{text:I,columns:m,theme:b}));if(f==="write-line"){let{gutterWidth:S,lineNum:C,isFirstLine:P,isLastLine:N,extension:L,wrappedLines:_}=t,q=(ge=!1)=>r.createElement(E,{flexDirection:"row",width:m,borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:s.codeBorder,paddingLeft:2,paddingRight:0,backgroundColor:s.codeBg,marginBottom:ge?1:0},r.createElement(E,{width:S+2,flexShrink:0},r.createElement(ne,null," ".repeat(S+2))),r.createElement(E,{flexGrow:1},r.createElement(ne,null," ")));return r.createElement(E,{flexDirection:"column"},P&&q(!1),r.createElement(E,{flexDirection:"row",width:m,borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:s.codeBorder,paddingLeft:2,paddingRight:0,backgroundColor:s.codeBg},r.createElement(E,{width:S+2,flexShrink:0},r.createElement(ne,{color:"gray",dimColor:!0},String(C).padStart(S," ")," ")),r.createElement(E,{flexGrow:1,flexDirection:"column"},(_||[I]).map((ge,Me)=>r.createElement(E,{key:Me},Ot(ge,L,s.text))))),N&&q(!0))}return f==="write-footer"?r.createElement(E,{flexDirection:"column",paddingX:1,width:m,marginTop:1,marginBottom:1},r.createElement(En,{text:I,columns:m,theme:b})):f==="worked-duration"?r.createElement(E,{marginTop:1,marginBottom:2,paddingX:1,width:"100%"},r.createElement(ne,{color:s.textMuted},"["),r.createElement(ne,{color:s.textMuted},"Worked for ",r.createElement(ne,{bold:!0,color:s.text},Es(X))),r.createElement(ne,{color:s.textMuted},"]")):null}),Wc=r.memo(({messages:t,showFullThinking:m,columns:h=80,aiProvider:y,version:T,theme:b="Dark"})=>r.createElement(E,{flexDirection:"column",width:"100%"},t.map((s,k)=>r.createElement(hl,{key:s.id||k,msg:s,showFullThinking:m,columns:h,aiProvider:y,version:T,theme:b}))));import pt from"react";import{Box as Uo,Text as fo}from"ink";import{useState as Qn,useEffect as Jn,useRef as Pr}from"react";var Zn=null;function pl(){Zn&&Zn()}var hd=t=>{if(t<=370)return"#00a564";if(t>=5e3)return"#ff0000";let m=[{t:370,r:0,g:165,b:100},{t:550,r:40,g:195,b:80},{t:800,r:120,g:220,b:50},{t:1100,r:190,g:225,b:20},{t:1500,r:250,g:210,b:15},{t:2e3,r:255,g:170,b:0},{t:2800,r:255,g:110,b:0},{t:3800,r:255,g:50,b:0},{t:5e3,r:255,g:0,b:0}];for(let h=0;h<m.length-1;h++){let y=m[h],T=m[h+1];if(t>=y.t&&t<=T.t){let b=(t-y.t)/(T.t-y.t);b=b*b*(3-2*b);let s=Math.round(y.r+(T.r-y.r)*b),k=Math.round(y.g+(T.g-y.g)*b),f=Math.round(y.b+(T.b-y.b)*b);return`#${((1<<24)+(s<<16)+(k<<8)+f).toString(16).slice(1)}`}}return"#ff0000"},pd=pt.memo(({mode:t,thinkingLevel:m,tokens:h="0.0k",tokensTotal:y="0.0k",cachedTokens:T=0,promptTokens:b=0,chatId:s="NEW-SESSION",isMemoryEnabled:k=!0,apiTier:f="Free",aiProvider:I="Google",activeModel:A="",isProcessing:X=!1,lastChunkTime:S=0,theme:C="Dark",wps:P=0,showTPMEstimate:N=!1})=>{let L=Je(C),_="",[q,ge]=Qn(0),[Me,re]=Qn(0),[ie,pe]=Qn("MB"),[De,ve]=Qn("green"),[Ue,le]=Qn(0),Ie=Pr([]),be=Pr(370),ee=Pr([]),Ge=Pr(S);Jn(()=>{Ge.current=S},[S]),Jn(()=>{if(!X){ee.current=[];return}if(P>0){let R=ee.current;R.push(P),R.length>3&&R.shift()}},[X,P,S]),Jn(()=>{if(!X){le(0);return}let R=setInterval(()=>{let te=Ge.current,Z=te>0?Date.now()-te:0;if(te>0&&Z>=1e3)ee.current=[],le(0);else if(te>0&&Z>500){ee.current.length>0&&ee.current.shift();let ae=ee.current;if(ae.length>0){let fe=ae.reduce((he,Ae)=>he+Ae,0);le(Math.round(fe/ae.length))}else le(0)}else{let ae=ee.current;if(ae.length>0){let fe=ae.reduce((he,Ae)=>he+Ae,0);le(Math.round(fe/ae.length))}else P>0&&le(Math.round(P))}},750);return()=>clearInterval(R)},[X]),Jn(()=>{if(!X){Ie.current=[];return}if(S>0){let Z=Ie.current;(Z.length===0||Z[Z.length-1]!==S)&&(Z.push(S),Z.length>10&&Z.shift())}let R=()=>{if(!S){ve("#00a564");return}let Z=Ie.current,ae=0;if(Z.length>1){let oe=0;for(let ce=1;ce<Z.length;ce++)oe+=Z[ce]-Z[ce-1];ae=oe/(Z.length-1)}let fe=Date.now()-S,Ae=fe>=2500,at=!Ae&&ae>0?Math.min(fe,ae*3):fe,Ze=Math.max(ae,at),Ee=Ae?.4:.2;be.current=be.current*(1-Ee)+Ze*Ee,ve(hd(be.current))};R();let te=setInterval(R,100);return()=>clearInterval(te)},[X,S]);let me=()=>{let R=process.memoryUsage(),te=R.heapTotal/(1024*1024)>=1024,Z=te?"GB":"MB",ae=(fe,he)=>{let Ae=fe/(1048576*(he?1024:1));return he?parseFloat(Ae.toFixed(2)):Math.round(Ae)};pe(Z),re(ae(R.heapTotal,te)),ge(ae(R.heapUsed,te))};return Jn(()=>{Zn=me,me();let R=setInterval(()=>{me()},6e4);return()=>{clearInterval(R),Zn===me&&(Zn=null)}},[]),pt.createElement(Uo,{flexDirection:"row",justifyContent:"space-between",paddingX:1,width:"100%"},pt.createElement(Uo,null,pt.createElement(Uo,{marginRight:1},pt.createElement(fo,{color:L.textMuted},t.toLowerCase()==="flow"?"Studio":t.toLowerCase()==="icu"?"Computer Use":t.toLowerCase()==="flux"?"Workspace":"Omni")),pt.createElement(fo,{color:L.textMuted,dimColor:!0},"\u2503 "),pt.createElement(Uo,null,pt.createElement(fo,{color:L.text,italic:!0},Gi(process.cwd(),35)))),pt.createElement(Uo,null,X&&!N?pt.createElement(Uo,null,pt.createElement(fo,{color:De},"\u25CF ")):null,X&&N&&pt.createElement(pt.Fragment,null,pt.createElement(fo,{color:L.textMuted},Ue," tok/s"),pt.createElement(fo,{color:L.textMuted,dimColor:!0}," \u2503")),h>0&&pt.createElement(pt.Fragment,null,pt.createElement(Uo,{marginX:1},pt.createElement(fo,{color:L.text},ht(y)," tok",(()=>{let R=typeof b=="number"?b:0,te=typeof T=="number"?T:0,Z=R>0?te/R*100:0;return Z<1?null:pt.createElement(fo,{color:L.success||"green",dimColor:!0}," [",Z.toFixed(0),"% cached]")})())),pt.createElement(fo,{color:L.textMuted,dimColor:!0},"\u2503")),pt.createElement(Uo,{marginLeft:1},pt.createElement(fo,{color:L.textMuted,bold:!0},q," ",ie))))}),bl=pd;import st,{useState as Ds,useMemo as bd,useEffect as wd}from"react";import{Box as Xt,Text as Kt,useInput as Td}from"ink";import yd from"ink-select-input";var Md=({label:t,isSelected:m,theme:h="Dark"})=>{let y=Je(h),T=t==="Cancel"||t==="Back"||t.toLowerCase().includes("exit")||t.toLowerCase().includes("back");return st.createElement(Xt,{marginTop:T?1:0,backgroundColor:m?y.highlightBg:void 0,paddingX:1,width:"100%"},st.createElement(Kt,{color:m?y.text:y.textMuted,bold:m},m?"\u276F ":" ",t))};function bt({title:t,subtitle:m,items:h=[],onSelect:y,theme:T="Dark",searchable:b=!1}){let s=Je(T),[k,f]=Ds(""),[I,A]=Ds(0),[X,S]=Ds("list"),C=bd(()=>{if(!b||!k.trim())return h;let P=k.toLowerCase().trim();return h.filter(N=>N.label&&N.label.toLowerCase().includes(P))},[h,k,b]);return wd(()=>{A(0)},[k]),Td((P,N)=>{if(b){if(N.upArrow){S("list"),A(L=>C.length>0?L>0?L-1:C.length-1:0);return}if(N.downArrow){S("list"),A(L=>C.length>0&&L<C.length-1?L+1:0);return}if(N.return){C.length>0&&C[I]&&y(C[I]);return}if(N.escape){if(k)f(""),S("list"),A(0);else{let L=h.find(_=>_.value==="Back"||_.label==="Back"||_.value==="Cancel"||_.label==="Cancel");L&&y(L)}return}if(N.backspace||N.delete){S("search"),f(L=>L.slice(0,-1));return}if(P&&!N.ctrl&&!N.meta&&!N.tab){S("search"),f(L=>L+P);return}}},{isActive:b}),b?st.createElement(Xt,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,padding:0,marginTop:0,flexShrink:0,width:"100%"},t&&st.createElement(Xt,{paddingX:1,paddingY:0,marginBottom:0},st.createElement(Kt,{color:s.text,bold:!0},typeof t=="string"?t.toUpperCase():t)),m&&st.createElement(Xt,{paddingX:1,marginBottom:0},st.createElement(Kt,{color:s.textMuted,italic:!0}," ",m)),st.createElement(Xt,{paddingX:1,marginTop:1,marginBottom:1,flexDirection:"row"},st.createElement(Kt,{color:X==="search"?s.primary||"cyan":s.textMuted,bold:X==="search"},"\u{1F50D} Search:"),st.createElement(Kt,{color:s.text,bold:!0}," ",k),X==="search"?st.createElement(Kt,{color:s.primary||"cyan"},"\u2588"):k?null:st.createElement(Kt,{color:s.textMuted,italic:!0}," (type to search...)")),st.createElement(Xt,{flexDirection:"column",width:"100%"},C.length===0?st.createElement(Xt,{paddingX:1,marginY:0},st.createElement(Kt,{color:s.warning||"yellow",italic:!0}," No matching items found")):C.map((P,N)=>{let L=N===I,_=P.label==="Cancel"||P.label==="Back"||P.label.toLowerCase().includes("exit")||P.label.toLowerCase().includes("back");return st.createElement(Xt,{key:P.value??P.label??N,marginTop:_?1:0,backgroundColor:L?s.highlightBg:void 0,paddingX:1,width:"100%"},st.createElement(Kt,{color:L?s.text:s.textMuted,bold:L},L?"\u276F ":" ",P.label))})),st.createElement(Xt,{paddingX:1,marginTop:1},st.createElement(Kt,{color:s.textMuted,italic:!0},X==="search"?"(Type letters to search \u2022 Arrows for list mode \u2022 Enter to select)":"(Arrows to navigate \u2022 Type letters to search \u2022 Enter to select)"))):st.createElement(Xt,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,padding:0,marginTop:0,flexShrink:0,width:"100%"},t&&st.createElement(Xt,{paddingX:1,paddingY:0,marginBottom:m?0:1},st.createElement(Kt,{color:s.text,bold:!0},typeof t=="string"?t.toUpperCase():t)),m&&st.createElement(Xt,{paddingX:1,marginBottom:1},st.createElement(Kt,{color:s.textMuted,italic:!0}," ",m)),st.createElement(Xt,{flexDirection:"column",width:"100%"},st.createElement(yd,{items:h,onSelect:y,itemComponent:P=>st.createElement(Md,{...P,theme:T}),indicatorComponent:()=>null})),st.createElement(Xt,{paddingX:1,marginTop:1},st.createElement(Kt,{color:s.textMuted,italic:!0},"(Arrows to select \u2022 Enter to confirm)")))}import v,{useState as At,useEffect as Rn}from"react";import{Box as Fe,Text as j,useInput as Sd}from"ink";import Cd from"ink-text-input";import vd from"v8";import wl from"os";var xo=[...Object.keys(Yi),"Mystery"],ho=[{id:"appearance",label:"Appearance",desc:"Customize UI theme & rendering options"},{id:"memory",label:"Memory",desc:"Manage system context & agent's memory"},{id:"other",label:"Miscellaneous",desc:"Miscellaneous preferences"},{id:"providers",label:"Providers",desc:"Configure AI models"},{id:"security",label:"Security",desc:"Configure permissions & data safety"},{id:"updater",label:"Updater",desc:"Manage application updates"},{id:"exit",label:"Exit Settings",desc:"Return to chat view"}],Tl=t=>{let m=t.autoApproveCommands||"",h=t.autoDisallowCommands||"",y=t.alwaysAskCommands||"",T=t.autoExec===!1&&t.allowExternalAccess===!1&&t.networkAccess===!1&&m===""&&h==="rm -rf, rm -f, del /f, del /q, rd /s, rmdir /s, format, mkfs, dd if=/dev, shred, srm, Remove-Item -Recurse -Force, Initialize-Disk, Clear-Disk, format c:, flashrom, nvram -c"&&y==="killall, pkill, taskkill, shutdown, reboot, init 0, init 6, Stop-Process, Stop-Service, mv /*, move c:\\*, chmod 000, chmod -R 777, chown, icacls, netsh advfirewall, iptables -F, ufw disable, git reset --hard, git clean -fd, npm r, npm uninstall"&&t.autoApproveGit===!1,b=t.autoExec===!0&&t.allowExternalAccess===!1&&t.networkAccess!==!1&&m==="ls, dir, cat, type, echo, pwd, cd, git status, git log, git diff, git branch, git show, help, mkdir, touch, md, whoami, hostname, ps, Get-Process, date, time, mkdir"&&h==="rm -rf, rm -f, del /f, del /q, rd /s, rmdir /s, format, mkfs, dd if=/dev, shred, srm, Remove-Item -Recurse -Force, Initialize-Disk, Clear-Disk, format c:, flashrom, nvram -c"&&y==="killall, pkill, taskkill, Stop-Process, mv /*, move c:\\*, chmod 000, chmod -R 777, chown, icacls, shutdown, reboot, init 0, init 6, git reset --hard, git clean -fd, npm r, npm uninstall"&&t.autoApproveGit===!1,s=t.autoExec===!0&&t.allowExternalAccess===!0&&t.networkAccess!==!1&&m==="ls, dir, cat, type, echo, pwd, cd, git status, git log, git diff, git branch, git show, help, mkdir, touch, md, whoami, hostname, ps, Get-Process, date, time, mkdir"&&h===""&&y==="rm -rf, rm -f, del /f, del /q, rd /s, rmdir /s, format, mkfs, dd if=/dev, shred, srm, Remove-Item -Recurse -Force, Initialize-Disk, Clear-Disk, format c:, flashrom, nvram -c"&&t.autoApproveGit===!0;return T?"Strict":b?"Balanced":s?"Autonomous":t.sandboxPreset||"Custom"},Bs=t=>!t||t.trim()===""?"None":t.length>40?t.substring(0,40)+"...":t;function Or({systemSettings:t,setSystemSettings:m,apiTier:h,setActiveView:y,setInputConfig:T,saveSettings:b,quotas:s,setMessages:k,aiProvider:f,initialSelectingTheme:I=!1,onCloseTheme:A=null,setProviderReturnView:X=null}){let S=t.theme==="Chaos"||t.theme==="Mystery"?"Mystery":t.theme||"Dark",C=xo.indexOf(S),[P,N]=At("categories"),[L,_]=At(0),[q,ge]=At(0),[Me,re]=At(null),[ie,pe]=At(""),[De,ve]=At(I),[Ue,le]=At(C>=0?C:0),[Ie,be]=At(t.theme||"Dark"),[ee,Ge]=At(!1),[me,R]=At(0),[te,Z]=At(0),[ae,fe]=At(""),[he,Ae]=At("list"),[at,Ze]=At({});Rn(()=>{(async()=>{let w=["Google","DeepSeek","OpenRouter","NVIDIA","Mistral","Ollama","InferX","SenseNova","AIHubMix","Poolside","9router","ExpLabs","TokenHarbor","APInex"],U={};for(let ye of w)try{await Mn(ye)&&(U[ye]=!0)}catch{}Ze(U)})()},[]);let Ee=v.useMemo(()=>{let ue=["Google","DeepSeek","OpenRouter","NVIDIA","Mistral","Ollama","InferX","SenseNova","AIHubMix","Poolside","9router","ExpLabs","TokenHarbor","APInex"],U=!!(process.env.SUBAGENT_MODEL&&process.env.SUBAGENT_MODEL.trim())?`ENV (${process.env.SUBAGENT_MODEL.trim()})`:"ENV",ye=[{label:"Default (use the current model)",value:"Default",isHeader:!1},{label:U,value:"ENV",isHeader:!1}],Xe=s?.providerTiers?.[f]||h||"Free",Re=No(f,Xe)||[];Re.length>0&&(ye.push({label:`\u2500\u2500 ${f.toUpperCase()}${Xe!=="Free"?` (${Xe})`:""} \u2500\u2500`,isHeader:!0}),Re.forEach(it=>{let We=typeof it=="string"?it:it.cmd||it.name||it.id||String(it);We&&!We.trim().startsWith("---")&&!We.startsWith(`
43
- ---`)&&ye.push({label:We,value:We,isHeader:!1,provider:f})}));for(let it of ue)if(it!==f&&at[it]){let We=s?.providerTiers?.[it]||"Free",qt=No(it,We)||[];qt.length>0&&(ye.push({label:`\u2500\u2500 ${it.toUpperCase()}${We!=="Free"?` (${We})`:""} \u2500\u2500`,isHeader:!0}),qt.forEach(je=>{let kt=typeof je=="string"?je:je.cmd||je.name||je.id||String(je);kt&&!kt.trim().startsWith("---")&&!kt.startsWith(`
44
- ---`)&&ye.push({label:kt,value:kt,isHeader:!1,provider:it})}))}return ye},[f,h,s,at]),oe=v.useMemo(()=>{if(!ae.trim())return Ee;let ue=ae.trim().toLowerCase(),w=[],U=null;for(let ye of Ee)ye.isHeader?U=ye:(ye.label.toLowerCase().includes(ue)||ye.value&&ye.value.toLowerCase().includes(ue))&&(U&&!w.includes(U)&&w.push(U),w.push(ye));return w},[Ee,ae]);Rn(()=>{if(ee){let ue=oe.findIndex(w=>!w.isHeader);R(ue>=0?ue:0),Z(0)}},[ae]),Rn(()=>{if(ee){if(oe.length===0){R(0),Z(0);return}if(me>=oe.length||oe[me]?.isHeader){let ue=oe.findIndex(w=>!w.isHeader);R(ue>=0?ue:0)}}},[oe,ee]);let[ce,Ce]=At(0),[B,$e]=At(0),[qe,Ct]=At("MB"),[Wt,Hr]=At(!1);Rn(()=>{let ue=!1;return import("./exec_command-27EPEAE5.js").then(w=>{ue||Hr(!!w.isPtyAvailable)}).catch(()=>{}),()=>{ue=!0}},[]),Rn(()=>{let ue=vd.getHeapStatistics().heap_size_limit,w=ue>=1024*1024*1024,U=w?"GB":"MB",ye=w?1024*1024*1024:1024*1024;$e(parseFloat((ue/ye).toFixed(2))),Ct(U);let Xe=()=>{let qt=process.memoryUsage().rss/ye,je=w?parseFloat(qt.toFixed(2)):Math.round(qt);Ce(je)};Xe();let Re=setInterval(()=>{Xe()},3e4);return()=>clearInterval(Re)},[]);let en=ue=>{switch(ue){case"providers":{let U=[{label:"Current Provider",value:"aiProvider",status:f}];return f==="Ollama"&&U.push({label:"Endpoint",value:"ollamaEndpoint",status:t.ollamaEndpoint||"Cloud"}),U}case"appearance":return[{label:"Theme",value:"theme",status:t.theme||"Dark"},{label:"Loading Phrases",value:"loadingPhrases",status:t.loadingPhrases!==!1?"ON":"OFF"},{label:"Progressive Rendering [EXPERIMENTAL]",value:"progressiveRendering",status:t.progressiveRendering?"ON":"OFF"},{label:"Show TPM Estimate",value:"showTPMEstimate",status:t.showTPMEstimate?"ON":"OFF"}];case"memory":return[{label:"Toggle Memory [Legacy]",value:"memory",status:t.memory?"ON":"OFF"}];case"security":return[{label:"Sandbox Preset",value:"sandboxPreset",status:Tl(t),section:"Sandbox"},{label:"YOLO Mode",value:"autoExec",status:t.autoExec?"ON":"OFF",section:"Sandbox"},{label:"External Workspace Access",value:"externalAccess",status:t.allowExternalAccess?"ON":"OFF",section:"Sandbox"},{label:"Network Access (Terminal)",value:"networkAccess",status:t.networkAccess!==!1?"ON":"OFF",section:"Sandbox"},{label:"Always Ask Commands",value:"alwaysAsk",status:Bs(t.alwaysAskCommands),section:"Sandbox"},{label:"Auto Approve Commands",value:"autoApprove",status:Bs(t.autoApproveCommands),section:"Sandbox"},{label:"Auto Disapprove Commands",value:"autoDisallow",status:Bs(t.autoDisallowCommands),section:"Sandbox"},{label:"Auto Approve Git Commits",value:"autoApproveGit",status:t.autoApproveGit?"ON":"OFF",section:"Sandbox"},{label:"Advanced Recovery [EXPERIMENTAL]",value:"advanceRollback",status:t.advanceRollback?"ON":"OFF",section:"Other"},{label:"Auto-Delete History",value:"autoDelete",status:t.autoDeleteHistory||"30d",section:"Other"},{label:"Save AppData Externally",value:"externalData",status:t.useExternalData?"ON":"OFF",section:"Other"}];case"updater":return[{label:"Auto-Update",value:"autoUpdate",status:t.autoUpdate?"ON":"OFF"},{label:"Preferred Package Manager",value:"updateManager",status:(t.updateManager||"npm")==="custom"?"Custom":(t.updateManager||"npm").toUpperCase()}];case"other":return[{label:"Sub-Agents",value:"subAgents",status:t.subAgents!==!1?"ON":"OFF"},{label:"Sub-Agent Model",value:"subAgentModel",status:t.CustomSubAgent&&t.SubAgentModel?t.SubAgentModel:"Default"},{label:"Verbose Thinking",value:"preserveThinking",status:t.preserveThinking!==!1?"ON":"OFF"},{label:"Dynamic Directory Awareness",value:"dynamicDirAwareness",status:t.dynamicDirAwareness?"ON":"OFF"},{label:"Directory Tree Design",value:"indentationTree",status:t.indentationTree!==!1?"Modern":"Classic (deprecated)"},{label:"Compact Large Tool Results",value:"compressToolResults",status:t.compressToolResults?"ON":"OFF"},{label:"Auto Truncate Results",value:"autoTruncateResults",status:t.autoTruncateResults?"ON":"OFF"},{label:"Image History for CU",value:"imageHistoryCU",status:t.imageHistoryCU||"Standard"},{label:"Context Length",value:"contextLength",status:t.contextLength||"256k"},{label:"Keep Reasoning Context",value:"keepReasoningContext",status:t.keepReasoningContext?"ON":"OFF"},{label:"Auto Exclude Metadata",value:"autoExcludeMetadata",status:t.autoExcludeMetadata?"ON":"OFF"},{label:"Disable Todo",value:"disableTodo",status:t.disableTodo?"ON":"OFF"}];default:return[]}},tn=ho[L].id,He=en(tn);Sd((ue,w)=>{if(ee){if(w.tab){Ae(U=>U==="search"?"list":"search");return}if(he==="search"){w.escape?Ge(!1):w.downArrow||w.return?Ae("list"):w.backspace||w.delete?fe(U=>U.slice(0,-1)):ue&&!w.ctrl&&!w.meta&&ue.length===1&&fe(U=>U+ue);return}if(w.upArrow)R(U=>{if(oe.length===0)return 0;let ye=(U-1+oe.length)%oe.length,Xe=0;for(;oe[ye]?.isHeader&&Xe<oe.length;)ye=(ye-1+oe.length)%oe.length,Xe++;return ye});else if(w.downArrow)R(U=>{if(oe.length===0)return 0;let ye=(U+1)%oe.length,Xe=0;for(;oe[ye]?.isHeader&&Xe<oe.length;)ye=(ye+1)%oe.length,Xe++;return ye});else if(w.return){let U=oe[me];U&&!U.isHeader&&(m(ye=>{let Xe=U.value==="Default",Re={...ye,CustomSubAgent:!Xe,SubAgentModel:U.value,SubAgentProvider:Xe?"":U.provider||""};return b({systemSettings:Re,apiTier:h,quotas:s}),Re}),Ge(!1))}else w.escape?Ge(!1):ue&&!w.ctrl&&!w.meta&&ue.length===1&&(fe(U=>U+ue),Ae("search"));return}if(De){if(w.upArrow){let U=(Ue-1+xo.length)%xo.length;le(U)}else if(w.downArrow){let U=(Ue+1)%xo.length;le(U)}else if(w.return){let U=xo[Ue];m(ye=>{let Xe={...ye,theme:U};return b({systemSettings:Xe,apiTier:h,quotas:s}),Xe}),A?A():ve(!1)}else w.escape&&(A?A():ve(!1));return}if(Me){w.escape&&re(null);return}if(P==="categories")w.upArrow?_(U=>(U-1+ho.length)%ho.length):w.downArrow?_(U=>(U+1)%ho.length):w.return||w.rightArrow?ho[L].id==="exit"?y("chat"):(N("items"),ge(0)):w.escape&&y("chat");else if(P==="items"){let U=He[q];if(ue==="?"&&U?.value==="dynamicDirAwareness"){y("dynamicDirHelp");return}if(w.upArrow)ge(ye=>(ye-1+He.length)%He.length);else if(w.downArrow)ge(ye=>(ye+1)%He.length);else if(w.leftArrow||w.escape)N("categories");else if(w.return){let ye=He[q];Rt(ye)}}});let Rt=ue=>{if(ue.value==="memory")m(w=>({...w,memory:!w.memory}));else if(ue.value==="sandboxPreset"){let w=Tl(t),U=["Autonomous","Balanced","Strict"],Xe=(U.indexOf(w)+1)%U.length,Re=U[Xe];m(it=>{let We={...it,sandboxPreset:Re};return Re==="Strict"?(We.autoExec=!1,We.allowExternalAccess=!1,We.networkAccess=!1,We.autoApproveCommands="",We.autoDisallowCommands="rm -rf, rm -f, del /f, del /q, rd /s, rmdir /s, format, mkfs, dd if=/dev, shred, srm, Remove-Item -Recurse -Force, Initialize-Disk, Clear-Disk, format c:, flashrom, nvram -c",We.alwaysAskCommands="killall, pkill, taskkill, shutdown, reboot, init 0, init 6, Stop-Process, Stop-Service, mv /*, move c:\\*, chmod 000, chmod -R 777, chown, icacls, netsh advfirewall, iptables -F, ufw disable, git reset --hard, git clean -fd, npm r, npm uninstall",We.autoApproveGit=!1):Re==="Balanced"?(We.autoExec=!0,We.allowExternalAccess=!1,We.networkAccess=!0,We.autoApproveCommands="ls, dir, cat, type, echo, pwd, cd, git status, git log, git diff, git branch, git show, help, mkdir, touch, md, whoami, hostname, ps, Get-Process, date, time",We.autoDisallowCommands="rm -rf, rm -f, del /f, del /q, rd /s, rmdir /s, format, mkfs, dd if=/dev, shred, srm, Remove-Item -Recurse -Force, Initialize-Disk, Clear-Disk, format c:, flashrom, nvram -c",We.alwaysAskCommands="killall, pkill, taskkill, Stop-Process, mv /*, move c:\\*, chmod 000, chmod -R 777, chown, icacls, shutdown, reboot, init 0, init 6, git reset --hard, git clean -fd, npm r, npm uninstall",We.autoApproveGit=!1):Re==="Autonomous"&&(We.autoExec=!0,We.allowExternalAccess=!0,We.networkAccess=!0,We.autoApproveCommands="ls, dir, cat, type, echo, pwd, cd, git status, git log, git diff, git branch, git show, help, mkdir, touch, md, whoami, hostname, ps, Get-Process, date, time",We.autoDisallowCommands="",We.alwaysAskCommands="rm -rf, rm -f, del /f, del /q, rd /s, rmdir /s, format, mkfs, dd if=/dev, shred, srm, Remove-Item -Recurse -Force, Initialize-Disk, Clear-Disk, format c:, flashrom, nvram -c",We.autoApproveGit=!0),We})}else if(ue.value==="autoExec")t.autoExec?m(w=>({...w,autoExec:!1,sandboxPreset:"Custom"})):t.allowExternalAccess?y("doubleDanger"):y("autoExecDanger");else if(ue.value==="externalAccess")t.allowExternalAccess?m(w=>({...w,allowExternalAccess:!1,sandboxPreset:"Custom"})):t.autoExec?y("doubleDanger"):y("externalDanger");else if(ue.value==="networkAccess")m(w=>({...w,networkAccess:w.networkAccess===!1,sandboxPreset:"Custom"}));else if(ue.value==="alwaysAsk")re("alwaysAskCommands"),pe(t.alwaysAskCommands||"");else if(ue.value==="autoApprove")re("autoApproveCommands"),pe(t.autoApproveCommands||"");else if(ue.value==="autoApproveGit")m(w=>({...w,autoApproveGit:!w.autoApproveGit,sandboxPreset:"Custom"}));else if(ue.value==="autoDisallow")re("autoDisallowCommands"),pe(t.autoDisallowCommands||"");else if(ue.value==="ollamaEndpoint")m(w=>{let U=w.ollamaEndpoint==="Local"?"Cloud":"Local",ye={...w,ollamaEndpoint:U};return b({systemSettings:ye,apiTier:h,quotas:s}),ye});else if(ue.value==="apiTier")y("apiTier");else if(ue.value==="aiProvider")X&&X("settings"),y("selectProvider");else if(ue.value==="advanceRollback")t.advanceRollback?m(w=>{let U={...w,advanceRollback:!1};return b({systemSettings:U,apiTier:h,quotas:s}),U}):y("advanceRollbackDanger");else if(ue.value==="autoDelete"){let w=["1d","7d","30d"],ye=(w.indexOf(t.autoDeleteHistory||"30d")+1)%w.length;m(Xe=>({...Xe,autoDeleteHistory:w[ye]}))}else if(ue.value==="autoUpdate")m(w=>({...w,autoUpdate:!w.autoUpdate}));else if(ue.value==="externalData")if(!t.useExternalData)T({label:"Enter absolute path for External AppData:",note:"All history, logs and secrets will be stored here. ~/.fluxflow/settings.json stays as anchor.",key:"externalDataPath",value:t.externalDataPath||""}),y("input");else{let w={...t,useExternalData:!1};m(w),b({systemSettings:w,apiTier:h,quotas:s}),k(U=>[...U,{id:Date.now(),role:"system",text:"[STORAGE RESET] Flux Flow will return to default ~/.fluxflow after restart."}]),y("chat")}else if(ue.value==="updateManager")y("updateManager");else if(ue.value==="parserDownload")y("parserDownload");else if(ue.value==="indentationTree")m(w=>{let U={...w,indentationTree:w.indentationTree===!1};return b({systemSettings:U,apiTier:h,quotas:s}),U});else if(ue.value==="compressToolResults")m(w=>{let U={...w,compressToolResults:!w.compressToolResults};return b({systemSettings:U,apiTier:h,quotas:s}),U});else if(ue.value==="autoTruncateResults")m(w=>{let U={...w,autoTruncateResults:!w.autoTruncateResults};return b({systemSettings:U,apiTier:h,quotas:s}),U});else if(ue.value==="imageHistoryCU"){let w=["Low","Standard","Extended"],ye=(w.indexOf(t.imageHistoryCU||"Standard")+1)%w.length;m(Xe=>{let Re={...Xe,imageHistoryCU:w[ye]};return b({systemSettings:Re,apiTier:h,quotas:s}),Re})}else if(ue.value==="contextLength"){let w=["16k","32k","64k","128k","256k","512k","1M"],ye=(w.indexOf(t.contextLength||"256k")+1)%w.length;m(Xe=>{let Re={...Xe,contextLength:w[ye]};return b({systemSettings:Re,apiTier:h,quotas:s}),Re})}else if(ue.value==="keepReasoningContext")m(w=>{let U={...w,keepReasoningContext:!w.keepReasoningContext};return b({systemSettings:U,apiTier:h,quotas:s}),U});else if(ue.value==="autoExcludeMetadata")m(w=>{let U={...w,autoExcludeMetadata:!w.autoExcludeMetadata};return b({systemSettings:U,apiTier:h,quotas:s}),U});else if(ue.value==="disableTodo")m(w=>{let U={...w,disableTodo:!w.disableTodo};return b({systemSettings:U,apiTier:h,quotas:s}),U});else if(ue.value==="subAgents")m(w=>{let U={...w,subAgents:w.subAgents===!1};return b({systemSettings:U,apiTier:h,quotas:s}),U});else if(ue.value==="subAgentModel"){let w=t.CustomSubAgent&&t.SubAgentModel?t.SubAgentModel:"Default",U=oe.findIndex(ye=>ye.value===w);R(U>=0?U:0),Ge(!0)}else if(ue.value==="preserveThinking")m(w=>{let U={...w,preserveThinking:w.preserveThinking===!1};return ml(U.preserveThinking),b({systemSettings:U,apiTier:h,quotas:s}),U});else if(ue.value==="dynamicDirAwareness")t.dynamicDirAwareness?m(w=>{let U={...w,dynamicDirAwareness:!1};return b({systemSettings:U,apiTier:h,quotas:s}),U}):y("dynamicDirDanger");else if(ue.value==="loadingPhrases")m(w=>{let U={...w,loadingPhrases:w.loadingPhrases===!1};return b({systemSettings:U,apiTier:h,quotas:s}),U});else if(ue.value==="progressiveRendering")m(w=>{let U={...w,progressiveRendering:!w.progressiveRendering};return b({systemSettings:U,apiTier:h,quotas:s}),U});else if(ue.value==="showTPMEstimate")m(w=>{let U={...w,showTPMEstimate:!w.showTPMEstimate};return b({systemSettings:U,apiTier:h,quotas:s}),U});else if(ue.value==="theme"){let w=t.theme==="Chaos"||t.theme==="Mystery"?"Mystery":t.theme||"Dark",U=xo.indexOf(w);le(U>=0?U:0),be(t.theme||"Dark"),ve(!0)}},Se=Je(t.theme);if(ee){let ue=t.CustomSubAgent&&t.SubAgentModel?t.SubAgentModel:"Default",w=15,U=te;me<U?U=me:me>=U+w&&(U=me-w+1),U=Math.max(0,Math.min(U,Math.max(0,oe.length-w))),U!==te&&Z(U);let ye=oe.slice(U,U+w);return v.createElement(Fe,{flexDirection:"column",borderStyle:"round",borderColor:Se.border,padding:1,width:"100%",minHeight:32},v.createElement(Fe,{marginBottom:1,flexDirection:"row",justifyContent:"space-between"},v.createElement(j,{color:Se.text,bold:!0,underline:!0},"Select Sub-Agent Model:"),oe.length>0&&v.createElement(j,{color:"gray"},me+1,"/",oe.length)),v.createElement(Fe,{borderStyle:"single",borderColor:he==="search"?Se.primary||"cyan":"gray",paddingX:1,marginBottom:1},v.createElement(j,{color:he==="search"?Se.primary||"cyan":"gray",bold:!0},"\u{1F50D} Search: "," "),v.createElement(j,{color:Se.text},ae),he==="search"&&v.createElement(j,{color:Se.primary||"cyan"},"\u2588"),!ae&&he!=="search"&&v.createElement(j,{color:"gray",italic:!0},"(Press TAB or type to filter models...)")),v.createElement(Fe,{flexDirection:"column",flexGrow:1,height:w},ye.length>0?ye.map((Xe,Re)=>{let it=U+Re;if(Xe.isHeader)return v.createElement(Fe,{key:`hdr-${it}`,paddingX:1},v.createElement(j,{color:"gray",bold:!0,underline:!0},Xe.label));let We=me===it&&he==="list",qt=ue===Xe.value;return v.createElement(Fe,{key:`item-${Xe.value}-${it}`,paddingX:1,backgroundColor:We?Se.highlightBg:void 0},v.createElement(j,{color:We?Se.text:Se.textDim,bold:We},We?"\u276F ":" ",Xe.label,qt?v.createElement(j,{color:Se.primary||"cyan",italic:!0}," (active)"):""))}):v.createElement(Fe,{paddingX:1},v.createElement(j,{color:"gray",italic:!0},'No models matching "',ae,'"'))),v.createElement(Fe,{paddingX:1,marginTop:1,flexDirection:"row",justifyContent:"space-between"},v.createElement(j,{color:"gray",italic:!0},"TAB to switch search/list \u2022 \u25B2\u25BC Navigate \u2022 ENTER to Select \u2022 ESC to Cancel"),v.createElement(j,{color:he==="search"?Se.primary||"cyan":"gray",bold:!0},"[",he.toUpperCase()," MODE]")))}if(De){let ue=xo[Ue],w=Je(ue);return v.createElement(Fe,{flexDirection:"column",borderStyle:"round",borderColor:w.border,padding:1,width:"100%",minHeight:32},v.createElement(Fe,{marginBottom:1},v.createElement(j,{color:w.text,bold:!0},"Choose your color scheme:")),v.createElement(Fe,{flexDirection:"row",width:"100%",flexGrow:1},v.createElement(Fe,{flexDirection:"column",width:"30%",paddingRight:1},xo.map((U,ye)=>{let Xe=Ue===ye,Re=(t.theme||"Dark")===U,it=U==="Forest Sprite";return v.createElement(Fe,{key:U,paddingX:0},v.createElement(j,{color:Xe?w.text:w.textDim,bold:Xe},Xe?"> ":" ",U,it&&v.createElement(j,{color:Xe?w.success||"#52b788":"green",bold:!0}," \u2605"),Re?v.createElement(j,{color:w.primary||"cyan",italic:!0}," (saved)"):""))})),v.createElement(Fe,{flexDirection:"column",flexGrow:1,borderStyle:"round",borderColor:w.borderMuted,paddingX:2,paddingY:1,backgroundColor:w.cardBg},v.createElement(Fe,{marginBottom:1},v.createElement(j,{color:w.secondary||"cyan",bold:!0},"> ","you: "),v.createElement(j,{color:w.text},"add a greeting function")),v.createElement(Fe,{marginBottom:1},v.createElement(j,{color:w.success||"green"}," Here's the change:")),v.createElement(Fe,{flexDirection:"column",marginLeft:2,marginBottom:1},v.createElement(j,null,v.createElement(j,{color:w.textDim},"3 "),v.createElement(j,{color:w.textDim},' import "fmt"')),v.createElement(j,{color:w.textDim},"4"),v.createElement(Fe,{backgroundColor:w.diffRemovalBg},v.createElement(j,null,v.createElement(j,{color:w.diffRemovalNum||w.diffRemovalText},"5 "),v.createElement(j,{color:w.diffRemovalPrefix||w.diffRemovalText},"- "),v.createElement(j,{color:w.diffRemovalText},"func "),v.createElement(j,{color:w.diffRemovalHighlightColor||w.diffRemovalText,backgroundColor:w.diffRemovalHighlightBg,bold:!0},"main()"),v.createElement(j,{color:w.diffRemovalText}," {"))),v.createElement(Fe,{backgroundColor:w.diffAdditionBg},v.createElement(j,null,v.createElement(j,{color:w.diffAdditionNum||w.diffAdditionText},"5 "),v.createElement(j,{color:w.diffAdditionPrefix||w.diffAdditionText},"+ "),v.createElement(j,{color:w.diffAdditionText},"func "),v.createElement(j,{color:w.diffAdditionHighlightColor||w.diffAdditionText,backgroundColor:w.diffAdditionHighlightBg,bold:!0},"greet(name string)"),v.createElement(j,{color:w.diffAdditionText}," {"))),v.createElement(Fe,{backgroundColor:w.diffAdditionBg},v.createElement(j,null,v.createElement(j,{color:w.diffAdditionNum||w.diffAdditionText},"6 "),v.createElement(j,{color:w.diffAdditionPrefix||w.diffAdditionText},"+ "),v.createElement(j,{color:w.diffAdditionText}," "),v.createElement(j,{color:w.diffAdditionHighlightColor||w.diffAdditionText,backgroundColor:w.diffAdditionHighlightBg},'fmt.Printf("Hello, %s!\\n", name)'))),v.createElement(j,{color:w.textDim},"7 }")),v.createElement(Fe,{flexDirection:"column",marginTop:1,marginBottom:1},v.createElement(j,{color:w.textDim},"\u25BE Thought Process"),v.createElement(j,{color:w.textMuted}," I need to add a greeting function. I'll use fmt.Printf.")),v.createElement(Fe,{flexDirection:"column"},v.createElement(j,null,v.createElement(j,{color:w.warning||"yellow"},"\u2699 tool: "),v.createElement(j,{color:w.text},"write_file main.go")),v.createElement(j,null,v.createElement(j,{color:w.accent||"magenta"},"\u29BF task: "),v.createElement(j,{color:w.text},"Implementing greeting")),v.createElement(j,null,v.createElement(j,{color:w.danger||"red"},"X error: "),v.createElement(j,{color:w.text},"compilation failed")),v.createElement(j,null,v.createElement(j,{color:w.warning||"yellow"},"\u26A0 warning: "),v.createElement(j,{color:w.text},"deprecation warning")),v.createElement(j,null,v.createElement(j,{color:w.info||"blue"},"\u2192 link: "),v.createElement(j,{color:w.info||"blue",underline:!0},"file:///path/to/main.go")),v.createElement(j,null,v.createElement(j,{color:w.accent||"magenta"},"\u2605 accent: "),v.createElement(j,{color:w.text},"highlighted text")),v.createElement(j,{color:w.textDim},"\xB7 dim: press Enter to continue")))),v.createElement(Fe,{paddingX:1,marginTop:1,flexDirection:"row",justifyContent:"space-between"},v.createElement(j,{color:"gray",italic:!0},"\u25B2\u25BC Navigate \u2022 ENTER to Select \u2022 ESC to Cancel"),v.createElement(j,{color:"gray"},"Previewing: ",xo[Ue],xo[Ue]==="Forest Sprite"?" \u2605":"")))}return v.createElement(Fe,{flexDirection:"column",borderStyle:"round",borderColor:Se.border,padding:0,width:"100%",minHeight:32},v.createElement(Fe,{paddingX:1,paddingY:0,marginBottom:0,borderStyle:"single",borderColor:Se.borderMuted,width:"100%"},v.createElement(j,{color:Se.text,bold:!0},"SYSTEM CONFIGURATION")),v.createElement(Fe,{flexDirection:"row",width:"100%",minHeight:26},v.createElement(Fe,{flexDirection:"column",width:"30%",maxWidth:40,borderStyle:"round",borderColor:P==="categories"?Se.border:Se.borderMuted,padding:1,paddingY:0},v.createElement(Fe,{marginBottom:1},v.createElement(j,{color:P==="categories"?Se.text:Se.textDim,bold:!0,underline:!0},"CATEGORIES")),ho.map((ue,w)=>{let U=L===w,ye=ue.id==="exit";return v.createElement(Fe,{key:ue.id,marginTop:ye?15:0,backgroundColor:U?P==="categories"?Se.highlightBg:Se.cardBg:void 0,paddingX:1},v.createElement(j,{color:U&&P==="categories"?Se.text:Se.textDim,bold:U},U?"\u276F ":" ",ue.label))})),v.createElement(Fe,{flexDirection:"column",flexGrow:1,borderStyle:"round",borderColor:P==="items"?Se.border:Se.borderMuted,paddingX:1,marginLeft:1,paddingY:0},v.createElement(Fe,{marginBottom:1},v.createElement(j,{color:P==="items"?Se.text:Se.textDim,bold:!0,underline:!0},ho[L].label.toUpperCase().includes("EXIT")?"Runtime Information":`${ho[L].label} Settings`)),He.length>0?(()=>{let ue=null,w=[],U=je=>(je||"").split(",").map(kt=>kt.trim().toLowerCase()).filter(Boolean),ye=U(t.autoApproveCommands),Xe=U(t.autoDisallowCommands),Re=U(t.alwaysAskCommands),it=[...ye,...Xe,...Re],We=new Set(it),qt=tn==="security"&&it.length!==We.size;return He.forEach((je,kt)=>{let zt=P==="items"&&q===kt,Xr=je.label.length,on=Math.max(2,38-Xr),Gr=".".repeat(on),mt=Le=>tn==="security"?(Le.value==="autoExec"||Le.value==="externalAccess")&&Le.status==="ON"?Se.statusOn:Se.statusOff:Le.status?.startsWith("\u2713")?Se.statusOn:Le.status?.startsWith("\u26A0")?Se.statusOff:Le.status==="ON"?Se.statusOn:Le.status==="OFF"?Se.statusOff:Se.text;je.section&&je.section!==ue&&(ue=je.section,w.push(v.createElement(Fe,{key:`sec-hdr-${je.section}`,marginTop:w.length>0?1:0,marginBottom:0,paddingX:1},v.createElement(j,{color:"gray",bold:!0,underline:!0},je.section.toUpperCase()))));let z=zt&&Me&&(Me==="alwaysAskCommands"&&je.value==="alwaysAsk"||Me==="autoApproveCommands"&&je.value==="autoApprove"||Me==="autoDisallowCommands"&&je.value==="autoDisallow"),lt=je.value==="alwaysAsk"||je.value==="autoApprove"||je.value==="autoDisallow",Go=je.value==="parserDownload";w.push(v.createElement(Fe,{key:je.value,flexDirection:"column"},v.createElement(Fe,{backgroundColor:zt&&!z?Se.highlightBg:void 0,paddingX:2},v.createElement(j,{color:zt?Se.text:Se.textDim,bold:zt},zt?"\u276F ":" ",je.label),!lt&&!Go&&v.createElement(v.Fragment,null,v.createElement(j,{color:"gray"},Gr),v.createElement(j,{color:mt(je),bold:!0},je.value==="aiProvider"?je.status:`[ ${je.status} ]`))),lt&&!z&&je.status!=="None"&&v.createElement(Fe,{paddingX:4,marginBottom:1},v.createElement(j,{color:"gray"},"\u21B3 ",je.status)),z&&v.createElement(Fe,{flexDirection:"column",marginLeft:4,marginBottom:1},v.createElement(Fe,{paddingX:1,borderStyle:"single",borderColor:"gray",flexDirection:"row"},v.createElement(j,{color:"gray",bold:!0},"> "," "),v.createElement(Cd,{value:ie,onChange:pe,onSubmit:Le=>{let _t={...t,[Me]:Le.trim(),sandboxPreset:"Custom"};m(_t),b({systemSettings:_t,apiTier:h,quotas:s}),re(null)}})),v.createElement(j,{color:"gray",italic:!0}," Comma separated \u2022 Press Enter to save, Esc to cancel"))))}),qt&&w.push(v.createElement(Fe,{key:"conflict-warning",marginTop:1,paddingX:1},v.createElement(j,{color:Se.text,italic:!0},"* Conflicting commands will be ignored and defaulted to highest priority"))),w})():v.createElement(Fe,{paddingX:1,flexDirection:"column",width:"100%"},tn==="exit"?v.createElement(v.Fragment,null,v.createElement(Fe,{flexDirection:"column",marginBottom:1},v.createElement(Fe,{flexDirection:"row"},v.createElement(j,{color:Se.textDim},"OS"," "),v.createElement(j,{color:"gray"},"..................... "),v.createElement(j,{color:Se.text},process.env.OS||process.platform||"N/A")),v.createElement(Fe,{flexDirection:"row"},v.createElement(j,{color:Se.textDim},"Computer Name"," "),v.createElement(j,{color:"gray"},".......... "),v.createElement(j,{color:Se.text},process.env.COMPUTERNAME||process.env.HOSTNAME||"N/A")),v.createElement(Fe,{flexDirection:"row"},v.createElement(j,{color:Se.textDim},"Processor Count"," "),v.createElement(j,{color:"gray"},"........ "),v.createElement(j,{color:Se.text},process.env.NUMBER_OF_PROCESSORS||"N/A")),v.createElement(Fe,{flexDirection:"row"},v.createElement(j,{color:Se.textDim},"Node.js Version"," "),v.createElement(j,{color:"gray"},"........ "),v.createElement(j,{color:Se.text},"v",process.versions.node)),v.createElement(Fe,{flexDirection:"row"},v.createElement(j,{color:Se.textDim},"V8 Version"," "),v.createElement(j,{color:"gray"},"...... ...... "),v.createElement(j,{color:Se.text},"v",process.versions.v8)),v.createElement(Fe,{flexDirection:"row"},v.createElement(j,{color:Se.textDim},"Data Directory"," "),v.createElement(j,{color:"gray"},"......... "),ro===mo?"":v.createElement(j,{color:Se.text},ro.replaceAll(wl.homedir(),"~").replaceAll("\\\\","/").replaceAll("\\","/"),", "),v.createElement(j,{color:Se.text},mo.replaceAll(wl.homedir(),"~").replaceAll("\\\\","/").replaceAll("\\","/"))),v.createElement(Fe,{flexDirection:"row"},v.createElement(j,{color:Se.textDim},"Viewport"," "),v.createElement(j,{color:"gray"},"............... "),v.createElement(j,{color:Se.text},process.stdout.rows||"?"," rows \xD7 ",process.stdout.columns||"?"," cols ",process.stdout.columns<90?"(too small width)":"")),v.createElement(Fe,{flexDirection:"row",marginBottom:0},v.createElement(j,{color:Se.textDim},"Memory Load"," "),v.createElement(j,{color:"gray"},"............ "),v.createElement(j,{color:Se.text},ce,"/",B," ",qe))),v.createElement(Fe,{key:"pty-notice",paddingX:0,marginTop:0},v.createElement(j,{color:Wt?Se.statusOn:Se.warning},Wt?"\u2713 Advance Interactive Terminal Supported":"\u26A0 Interactive Terminal is Limited"))):v.createElement(j,{color:"gray",italic:!0},ho[L].desc)))),v.createElement(Fe,{paddingX:1,marginTop:0,flexDirection:"row",justifyContent:"space-between"},v.createElement(j,{color:"gray",italic:!0},P==="categories"?"\u25B2\u25BC Select Category \u2022 Enter/\u25BA to configure":He[q]?.value==="dynamicDirAwareness"?"\u25B2\u25BC Select Option \u2022 Enter to Toggle \u2022 ? HELP \u2022 \u25C4/ESC to go back":"\u25B2\u25BC Select Option \u2022 Enter to Toggle \u2022 \u25C4/ESC to go back"),P==="categories"&&v.createElement(j,{color:"gray"},ho[L].desc)))}import Jt,{useState as ks,useEffect as Ed}from"react";import{Box as Dn,Text as er}from"ink";import Dd from"ink-text-input";function Is({initialData:t,onSave:m,onCancel:h,theme:y="Dark"}){let T=Je(y),[b,s]=ks(0),[k,f]=ks(""),[I,A]=ks(()=>({name:t?.name||"",nickname:t?.nickname||"",instructions:t?.instructions||""})),X=[{key:"nickname",label:"Enter a Nickname: ",maxLength:20},{key:"instructions",label:"System Instructions: ",maxLength:200}],S=X[b];Ed(()=>{let L=X[b].key;f((I[L]||"").slice(0,X[b].maxLength))},[b,I]);let C=L=>{L.length>S.maxLength?f(L.slice(0,S.maxLength)):f(L)},P=L=>{if(L.trim().toLowerCase()==="/cancel"){h();return}let _=S.key,q={...I,[_]:L.trim().slice(0,S.maxLength)};A(q),f(""),b<X.length-1?s(b+1):m(q)},N=k.length>=S.maxLength;return Jt.createElement(Dn,{borderStyle:"round",borderColor:T.borderMuted,padding:0,marginTop:1,flexShrink:0,flexDirection:"column",width:"100%"},Jt.createElement(Dn,{paddingX:1,marginBottom:1},Jt.createElement(er,{color:T.text,bold:!0},"USER PROFILE CONFIGURATION")),Jt.createElement(Dn,{paddingX:1,flexDirection:"column"},Jt.createElement(Dn,null,Jt.createElement(er,{color:T.text,bold:!0},S.label),Jt.createElement(Dd,{value:k,onChange:C,onSubmit:P})),Jt.createElement(Dn,{marginTop:1,justifyContent:"space-between"},Jt.createElement(er,{color:T.textMuted,italic:!0},"Step ",b+1," of ",X.length),Jt.createElement(er,{color:N?T.warning||"yellow":T.textMuted},"[",k.length,"/",S.maxLength,"]"))),Jt.createElement(Dn,{paddingX:1,marginTop:1},Jt.createElement(er,{color:T.textMuted,italic:!0},"(Enter to submit \u2022 Type /cancel to abort)")))}import yt,{useState as As}from"react";import{Box as Zt,Text as $o,useInput as Bd}from"ink";import kd from"ink-text-input";var Id=({question:t,options:m,onResolve:h,theme:y="Dark"})=>{let T=Je(y),[b,s]=As(!1),[k,f]=As(""),[I,A]=As(0),X=!1,S=[],C=Array.isArray(m)&&m.length>0,P=t==="Agent has been running for a long time. Do you want to continue execution?";try{P&&C?S=[...m]:S=[...C?m:[],C?{id:"CUSTOM",label:"Suggest something else...",description:"Provide a custom response"}:{id:"CUSTOM",label:"Your Answer",description:""}]}catch{X=!0}Bd((L,_)=>{if(!b&&((_.leftArrow||_.upArrow)&&A(q=>Math.max(0,q-1)),(_.rightArrow||_.downArrow)&&A(q=>Math.min(S.length-1,q+1)),_.return)){let q=S[I];q?.id==="CUSTOM"?s(!0):h(X?"Selected Nothing":q.label)}});let N=nt(2);return b?yt.createElement(Zt,{flexDirection:"column",borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,backgroundColor:T.codeBg,width:"100%"},yt.createElement(Zt,{paddingX:1},yt.createElement($o,{color:T.text,bold:!0},"SUGGEST SOMETHING")),yt.createElement(Zt,{marginTop:1,paddingX:1},yt.createElement($o,{italic:!0,color:T.textMuted},"Replying to: ",t)),yt.createElement(Zt,{marginTop:1,paddingX:1,flexDirection:"row"},yt.createElement(kd,{value:k,onChange:f,onSubmit:()=>h(k)})),yt.createElement(Zt,{marginTop:1,paddingX:1,marginBottom:1},yt.createElement($o,{color:T.textMuted,italic:!0},"(Press Enter to send)"))):yt.createElement(Zt,{flexDirection:"column",border:!0,borderStyle:"round",borderColor:T.codeBorder,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,marginY:1,marginRight:1,width:"100%"},yt.createElement(Zt,{paddingX:1,marginBottom:1},yt.createElement($o,{color:"yellow",bold:!0},P?"TURN SAFETY SYSTEM: EXECUTION LIMIT":"AGENT REQUEST: ACTION REQUIRED")),yt.createElement(Zt,{paddingX:1,marginBottom:1},yt.createElement($o,{color:T.text},t)),yt.createElement(Zt,{flexDirection:"column",width:"100%"},S.map((L,_)=>{let q=_===I;return yt.createElement(Zt,{key:L.id,flexDirection:"column",width:"100%",backgroundColor:q?T.highlightBg:void 0,paddingX:1,marginBottom:_===S.length-1?0:1},yt.createElement($o,{color:q?T.text:T.textMuted,bold:q},q?"\u276F ":" ",L.label),L.description&&yt.createElement(Zt,{marginLeft:4},yt.createElement($o,{color:T.textMuted,italic:!0},L.description)))})),yt.createElement(Zt,{paddingX:1,marginTop:1,marginBottom:1},yt.createElement($o,{color:T.textMuted,italic:!0},"(Use Arrows to navigate, Enter to confirm)")))},yl=Id;import Zd from"gradient-string";import Lt,{useState as Ls,useEffect as Ad}from"react";import{Box as po,Text as _o,useInput as Ld}from"ink";function Ps({onSelect:t,onDelete:m,onClose:h,theme:y="Dark"}){let T=Je(y),[b,s]=Ls({}),[k,f]=Ls([]),[I,A]=Ls(0);Ad(()=>{(async()=>{let L=await Fo();s(L),f(Object.keys(L).sort((_,q)=>(L[q].updatedAt||0)-(L[_].updatedAt||0)))})()},[]),Ld((N,L)=>{if(L.escape&&h(),L.upArrow&&A(_=>Math.max(0,_-1)),L.downArrow&&A(_=>Math.min(k.length-1,_+1)),L.return&&k[I]&&t(k[I]),N==="x"&&k[I]){let _=k[I];m(_).then(q=>{let ge=q||{};s(ge);let Me=Object.keys(ge).sort((re,ie)=>(ge[ie]?.updatedAt||0)-(ge[re]?.updatedAt||0));f(Me),A(re=>Math.max(0,Math.min(Me.length-1,re)))})}});let X=nt(2),S=15,C=0;if(k.length>S){let N=Math.floor(S/2);C=I-N,C<0?C=0:C+S>k.length&&(C=k.length-S)}let P=k.slice(C,C+S);return Lt.createElement(po,{flexDirection:"column",borderStyle:"round",borderColor:T.borderMuted,padding:0,width:"100%"},Lt.createElement(po,{paddingX:1,marginBottom:1},Lt.createElement(_o,{color:T.text,bold:!0},"CHAT HISTORY: RESUME CONVERSATION")),k.length===0?Lt.createElement(po,{paddingX:2,paddingY:1},Lt.createElement(_o,{italic:!0,color:T.textMuted},"No saved chats found.")):Lt.createElement(po,{flexDirection:"column",width:"100%"},C>0&&Lt.createElement(po,{paddingX:2,marginBottom:1},Lt.createElement(_o,{color:T.textMuted},"\u25B2 (+",C," more chats above)")),P.map((N,L)=>{let _=b[N],ge=C+L===I,Me=Pd(_?.updatedAt);return Lt.createElement(po,{key:N,paddingX:1,backgroundColor:ge?T.highlightBg:void 0,width:"100%"},Lt.createElement(po,{flexGrow:1},Lt.createElement(_o,{color:ge?T.text:T.textMuted,bold:ge},ge?"\u276F ":" ",(()=>{let re=ie=>(ie||"").replace(/\[\/?(?:STEERING HINT|QUESTION)(?::\s*\w+)?\]/gi,"").trim();return _?.name&&!_.name.startsWith("Session")?re(_.name):_?.prompt?re(_.prompt):re(_?.name)||N})(),Lt.createElement(_o,{color:T.textMuted}," [",Me," \u2022 ",N,"]"))),ge&&Lt.createElement(po,{flexShrink:0},Lt.createElement(_o,{color:T.danger,bold:!0},"[X] DELETE ")))}),C+S<k.length&&Lt.createElement(po,{paddingX:2,marginTop:1},Lt.createElement(_o,{color:T.textMuted},"\u25BC (+",k.length-(C+S)," more chats below)"))),Lt.createElement(po,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:T.borderMuted},Lt.createElement(_o,{color:T.textMuted,italic:!0},"\u2191\u2193 navigate \u2022 Enter select \u2022 x delete \u2022 Esc close")))}function Pd(t){if(!t)return"N/A";let m=new Date(t);if(isNaN(m.getTime()))return"N/A";let h=k=>String(k).padStart(2,"0"),y=h(m.getMonth()+1),T=h(m.getDate()),b=h(m.getHours()),s=h(m.getMinutes());return`${y}-${T} ${b}:${s}`}import Mt,{useState as Os,useEffect as Od}from"react";import{Box as bo,Text as lo,useInput as Nd,useStdout as Fd}from"ink";function Ns({onClose:t,theme:m="Dark"}){let h=Je(m),{stdout:y}=Fd(),T=y?.columns||80,[b,s]=Os([]),[k,f]=Os(0),[I,A]=Os(!0),X=()=>{let re=wr(Gn,[]);s(re);try{let pe=Tr(zo,{}).systemSettings?.memory!==!1;A(pe)}catch{A(!0)}};Od(()=>{X()},[]),Nd((re,ie)=>{if(ie.escape&&t(),ie.upArrow&&f(pe=>Math.max(0,pe-1)),ie.downArrow&&f(pe=>Math.min(b.length-1,pe+1)),re==="x"&&b.length>0){let pe=b[k].id,De=b.filter(ve=>ve.id!==pe);Di(Gn,De),s(De),k>=De.length&&De.length>0&&f(De.length-1)}});let S=(re,ie,pe)=>{if(!re)return"";let De=re.replace(/\[Saved on: .*?\]/g,"").replace(/\\+'/g,"'").trim(),Ue=`${pe?"\u276F ":" "}${ie+1}. `.length,le=pe?22:2;return De.split(`
45
- `).map((be,ee)=>{let Ge=ee===0,me=Math.max(10,T-4-(Ge?Ue:3)-le),R=Math.max(10,T-4-3-le),te=be.split(/(\s+)/),Z=[],ae="";if(te.forEach(he=>{if(he.length===0)return;let Ae=Z.length===0?me:R;ae.length+he.length>Ae?ae.trim().length>0?(Z.push(ae.trimEnd()),ae=he):(Z.push(he.substring(0,Ae)),ae=he.substring(Ae)):ae+=he}),ae.trimEnd().length>0&&Z.push(ae.trimEnd()),Z.length===0)return"";let fe=Z.join(`
46
- `);return Ge?fe:" "+fe}).join(`
47
- `)},C=4*1024*2,P=b.reduce((re,ie)=>re+(ie.memory?.length||0),0),N=Math.min(100,Math.round(P/C*100)),L=12,_=Math.round(N/100*L),q="\u2588".repeat(_)+"\u2591".repeat(Math.max(0,L-_)),ge=()=>N<50?h.textMuted:N<90?h.warning:h.danger,Me=nt(2);return Mt.createElement(bo,{flexDirection:"column",borderStyle:"round",borderColor:h.borderMuted,padding:0,width:"100%"},Mt.createElement(bo,{paddingX:1,marginBottom:1,justifyContent:"space-between"},Mt.createElement(lo,{color:h.text,bold:!0},"SAVED MEMORIES"),Mt.createElement(bo,null,Mt.createElement(lo,{color:h.textMuted},"Vault: "),Mt.createElement(lo,{color:ge()},q),Mt.createElement(lo,{color:h.text,bold:!0}," ",N,"%"))),!I&&b.length>0?Mt.createElement(bo,{paddingX:2,paddingY:1},Mt.createElement(lo,{italic:!0,color:h.textMuted},"Memory is currently Off...")):b.length===0?Mt.createElement(bo,{paddingX:2,paddingY:1},Mt.createElement(lo,{italic:!0,color:h.textMuted},I?"Learning...":"Memory not available...")):Mt.createElement(bo,{flexDirection:"column"},b.map((re,ie)=>{let pe=ie===k;return Mt.createElement(bo,{key:re.id,paddingX:1,backgroundColor:pe?h.highlightBg:void 0,width:"100%"},Mt.createElement(bo,{flexGrow:1},Mt.createElement(lo,{color:pe?h.text:h.textMuted,bold:pe},pe?"\u276F ":" ",ie+1,". ",S(re.memory,ie,pe))),pe&&Mt.createElement(bo,{flexShrink:0},Mt.createElement(lo,{color:h.textMuted,dimColor:!0}," [",Mt.createElement(lo,{italic:!0},re.score),"] "),Mt.createElement(lo,{color:h.danger,bold:!0},"[X] WIPE ")))})),Mt.createElement(bo,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:h.borderMuted},Mt.createElement(lo,{color:h.textMuted,italic:!0},"\u2191\u2193 navigate \u2022 x wipe memory \u2022 Esc close")))}import ft,{useState as Nr,useEffect as Ml}from"react";import{Box as Ho,Text as Nt}from"ink";import{spawn as Sl}from"child_process";var Cl=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],Ud=({latest:t,current:m,settings:h,onClose:y,onUpdateSettings:T,onSuccess:b})=>{let[s,k]=Nr("initializing"),[f,I]=Nr(""),[A,X]=Nr(null),[S,C]=Nr(0);if(Ml(()=>{let P=setInterval(()=>{C(N=>(N+1)%1e3)},33);return()=>clearInterval(P)},[]),Ml(()=>{let P;return(async()=>{let L=h.updateManager||"npm";if(!h.updateManager){T();return}let _="";L==="pnpm"?_=`pnpm add -g fluxflow-cli@${t}`:L==="bun"?_=`bun add -g fluxflow-cli@${t}`:L==="yarn"?_=`yarn global add fluxflow-cli@${t}`:L==="custom"?_=h.customUpdateCommand:_=`npm install -g fluxflow-cli@${t}`,k("downloading"),I(`Running: ${_}...`);let q=process.platform==="win32",ge=re=>new Promise(ie=>{let pe=q?re?"powershell.exe":"cmd.exe":process.env.SHELL||"bash",De=q?re?["-NoProfile","-Command",_]:["/c",_]:["-c",_],ve=le=>{let be=le.toString().replace(/\x1B\[[0-?]*[ -/]*[@-~]|\x1B\][^\x07\x1B]*[\x07\x1B]|\b|\x07/g,"").replace(/\r/g,"").trim();be&&I(ee=>{let Ge=ee.split(`
48
- `);return Ge[Ge.length-1]?.startsWith("Progress:")&&be.startsWith("Progress:")?(Ge[Ge.length-1]=be,Ge.slice(-5).join(`
42
+ `);return r.createElement(E,{flexDirection:"column",width:"100%"},L.map((_,Q)=>r.createElement(E,{key:Q,flexDirection:"row",borderColor:s.codeBorder,paddingLeft:2,width:"100%"},r.createElement(E,{width:5,flexShrink:0},r.createElement(ne,{color:"gray",dimColor:!0},Q===0?String(S).padStart(4," ")+" ":" ")),r.createElement(E,{flexGrow:1},Ot(_,C,s.text)))))}if(f==="code-fence-close")return r.createElement(E,{flexDirection:"row",paddingLeft:2,marginBottom:1,width:"100%"},r.createElement(ne,null," "));if(f==="write-header")return r.createElement(E,{flexDirection:"column",paddingX:1,width:m},r.createElement(En,{text:I,columns:m,theme:b}));if(f==="write-line"){let{gutterWidth:S,lineNum:C,isFirstLine:P,isLastLine:N,extension:L,wrappedLines:_}=t,Q=(ge=!1)=>r.createElement(E,{flexDirection:"row",width:m,borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:s.codeBorder,paddingLeft:2,paddingRight:0,backgroundColor:s.codeBg,marginBottom:ge?1:0},r.createElement(E,{width:S+2,flexShrink:0},r.createElement(ne,null," ".repeat(S+2))),r.createElement(E,{flexGrow:1},r.createElement(ne,null," ")));return r.createElement(E,{flexDirection:"column"},P&&Q(!1),r.createElement(E,{flexDirection:"row",width:m,borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:s.codeBorder,paddingLeft:2,paddingRight:0,backgroundColor:s.codeBg},r.createElement(E,{width:S+2,flexShrink:0},r.createElement(ne,{color:"gray",dimColor:!0},String(C).padStart(S," ")," ")),r.createElement(E,{flexGrow:1,flexDirection:"column"},(_||[I]).map((ge,ye)=>r.createElement(E,{key:ye},Ot(ge,L,s.text))))),N&&Q(!0))}return f==="write-footer"?r.createElement(E,{flexDirection:"column",paddingX:1,width:m,marginTop:1,marginBottom:1},r.createElement(En,{text:I,columns:m,theme:b})):f==="worked-duration"?r.createElement(E,{marginTop:1,marginBottom:2,paddingX:1,width:"100%"},r.createElement(ne,{color:s.textMuted},"["),r.createElement(ne,{color:s.textMuted},"Worked for ",r.createElement(ne,{bold:!0,color:s.text},Es(X))),r.createElement(ne,{color:s.textMuted},"]")):null}),Gc=r.memo(({messages:t,showFullThinking:m,columns:h=80,aiProvider:y,version:T,theme:b="Dark"})=>r.createElement(E,{flexDirection:"column",width:"100%"},t.map((s,k)=>r.createElement(hl,{key:s.id||k,msg:s,showFullThinking:m,columns:h,aiProvider:y,version:T,theme:b}))));import pt from"react";import{Box as Uo,Text as fo}from"ink";import{useState as Qn,useEffect as Jn,useRef as Pr}from"react";var Zn=null;function pl(){Zn&&Zn()}var hd=t=>{if(t<=370)return"#00a564";if(t>=5e3)return"#ff0000";let m=[{t:370,r:0,g:165,b:100},{t:550,r:40,g:195,b:80},{t:800,r:120,g:220,b:50},{t:1100,r:190,g:225,b:20},{t:1500,r:250,g:210,b:15},{t:2e3,r:255,g:170,b:0},{t:2800,r:255,g:110,b:0},{t:3800,r:255,g:50,b:0},{t:5e3,r:255,g:0,b:0}];for(let h=0;h<m.length-1;h++){let y=m[h],T=m[h+1];if(t>=y.t&&t<=T.t){let b=(t-y.t)/(T.t-y.t);b=b*b*(3-2*b);let s=Math.round(y.r+(T.r-y.r)*b),k=Math.round(y.g+(T.g-y.g)*b),f=Math.round(y.b+(T.b-y.b)*b);return`#${((1<<24)+(s<<16)+(k<<8)+f).toString(16).slice(1)}`}}return"#ff0000"},pd=pt.memo(({mode:t,thinkingLevel:m,tokens:h="0.0k",tokensTotal:y="0.0k",cachedTokens:T=0,promptTokens:b=0,chatId:s="NEW-SESSION",isMemoryEnabled:k=!0,apiTier:f="Free",aiProvider:I="Google",activeModel:A="",isProcessing:X=!1,lastChunkTime:S=0,theme:C="Dark",wps:P=0,showTPMEstimate:N=!1})=>{let L=Je(C),_="",[Q,ge]=Qn(0),[ye,se]=Qn(0),[ie,pe]=Qn("MB"),[Be,Ce]=Qn("green"),[Fe,le]=Qn(0),Ie=Pr([]),be=Pr(370),ee=Pr([]),We=Pr(S);Jn(()=>{We.current=S},[S]),Jn(()=>{if(!X){ee.current=[];return}if(P>0){let R=ee.current;R.push(P),R.length>3&&R.shift()}},[X,P,S]),Jn(()=>{if(!X){le(0);return}let R=setInterval(()=>{let te=We.current,Z=te>0?Date.now()-te:0;if(te>0&&Z>=1e3)ee.current=[],le(0);else if(te>0&&Z>500){ee.current.length>0&&ee.current.shift();let ae=ee.current;if(ae.length>0){let fe=ae.reduce((he,Ae)=>he+Ae,0);le(Math.round(fe/ae.length))}else le(0)}else{let ae=ee.current;if(ae.length>0){let fe=ae.reduce((he,Ae)=>he+Ae,0);le(Math.round(fe/ae.length))}else P>0&&le(Math.round(P))}},750);return()=>clearInterval(R)},[X]),Jn(()=>{if(!X){Ie.current=[];return}if(S>0){let Z=Ie.current;(Z.length===0||Z[Z.length-1]!==S)&&(Z.push(S),Z.length>10&&Z.shift())}let R=()=>{if(!S){Ce("#00a564");return}let Z=Ie.current,ae=0;if(Z.length>1){let oe=0;for(let ce=1;ce<Z.length;ce++)oe+=Z[ce]-Z[ce-1];ae=oe/(Z.length-1)}let fe=Date.now()-S,Ae=fe>=2500,at=!Ae&&ae>0?Math.min(fe,ae*3):fe,Ze=Math.max(ae,at),ve=Ae?.4:.2;be.current=be.current*(1-ve)+Ze*ve,Ce(hd(be.current))};R();let te=setInterval(R,100);return()=>clearInterval(te)},[X,S]);let me=()=>{let R=process.memoryUsage(),te=R.heapTotal/(1024*1024)>=1024,Z=te?"GB":"MB",ae=(fe,he)=>{let Ae=fe/(1048576*(he?1024:1));return he?parseFloat(Ae.toFixed(2)):Math.round(Ae)};pe(Z),se(ae(R.heapTotal,te)),ge(ae(R.heapUsed,te))};return Jn(()=>{Zn=me,me();let R=setInterval(()=>{me()},6e4);return()=>{clearInterval(R),Zn===me&&(Zn=null)}},[]),pt.createElement(Uo,{flexDirection:"row",justifyContent:"space-between",paddingX:1,width:"100%"},pt.createElement(Uo,null,pt.createElement(Uo,{marginRight:1},pt.createElement(fo,{color:L.textMuted},t.toLowerCase()==="flow"?"Studio":t.toLowerCase()==="icu"?"Computer Use":t.toLowerCase()==="flux"?"Workspace":"Omni")),pt.createElement(fo,{color:L.textMuted,dimColor:!0},"\u2503 "),pt.createElement(Uo,null,pt.createElement(fo,{color:L.text,italic:!0},Wi(process.cwd(),35)))),pt.createElement(Uo,null,X&&!N?pt.createElement(Uo,null,pt.createElement(fo,{color:Be},"\u25CF ")):null,X&&N&&pt.createElement(pt.Fragment,null,pt.createElement(fo,{color:L.textMuted},Fe," tok/s"),pt.createElement(fo,{color:L.textMuted,dimColor:!0}," \u2503")),h>0&&pt.createElement(pt.Fragment,null,pt.createElement(Uo,{marginX:1},pt.createElement(fo,{color:L.text},ht(y)," tok",(()=>{let R=typeof b=="number"?b:0,te=typeof T=="number"?T:0,Z=R>0?te/R*100:0;return Z<1?null:pt.createElement(fo,{color:L.success||"green",dimColor:!0}," [",Z.toFixed(0),"% cached]")})())),pt.createElement(fo,{color:L.textMuted,dimColor:!0},"\u2503")),pt.createElement(Uo,{marginLeft:1},pt.createElement(fo,{color:L.textMuted,bold:!0},Q," ",ie))))}),bl=pd;import st,{useState as Bs,useMemo as bd,useEffect as Td}from"react";import{Box as Xt,Text as Kt,useInput as wd}from"ink";import yd from"ink-select-input";var Md=({label:t,isSelected:m,theme:h="Dark"})=>{let y=Je(h),T=t==="Cancel"||t==="Back"||t.toLowerCase().includes("exit")||t.toLowerCase().includes("back");return st.createElement(Xt,{marginTop:T?1:0,backgroundColor:m?y.highlightBg:void 0,paddingX:1,width:"100%"},st.createElement(Kt,{color:m?y.text:y.textMuted,bold:m},m?"\u276F ":" ",t))};function bt({title:t,subtitle:m,items:h=[],onSelect:y,theme:T="Dark",searchable:b=!1}){let s=Je(T),[k,f]=Bs(""),[I,A]=Bs(0),[X,S]=Bs("list"),C=bd(()=>{if(!b||!k.trim())return h;let P=k.toLowerCase().trim();return h.filter(N=>N.label&&N.label.toLowerCase().includes(P))},[h,k,b]);return Td(()=>{A(0)},[k]),wd((P,N)=>{if(b){if(N.upArrow){S("list"),A(L=>C.length>0?L>0?L-1:C.length-1:0);return}if(N.downArrow){S("list"),A(L=>C.length>0&&L<C.length-1?L+1:0);return}if(N.return){C.length>0&&C[I]&&y(C[I]);return}if(N.escape){if(k)f(""),S("list"),A(0);else{let L=h.find(_=>_.value==="Back"||_.label==="Back"||_.value==="Cancel"||_.label==="Cancel");L&&y(L)}return}if(N.backspace||N.delete){S("search"),f(L=>L.slice(0,-1));return}if(P&&!N.ctrl&&!N.meta&&!N.tab){S("search"),f(L=>L+P);return}}},{isActive:b}),b?st.createElement(Xt,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,padding:0,marginTop:0,flexShrink:0,width:"100%"},t&&st.createElement(Xt,{paddingX:1,paddingY:0,marginBottom:0},st.createElement(Kt,{color:s.text,bold:!0},typeof t=="string"?t.toUpperCase():t)),m&&st.createElement(Xt,{paddingX:1,marginBottom:0},st.createElement(Kt,{color:s.textMuted,italic:!0}," ",m)),st.createElement(Xt,{paddingX:1,marginTop:1,marginBottom:1,flexDirection:"row"},st.createElement(Kt,{color:X==="search"?s.primary||"cyan":s.textMuted,bold:X==="search"},"\u{1F50D} Search:"),st.createElement(Kt,{color:s.text,bold:!0}," ",k),X==="search"?st.createElement(Kt,{color:s.primary||"cyan"},"\u2588"):k?null:st.createElement(Kt,{color:s.textMuted,italic:!0}," (type to search...)")),st.createElement(Xt,{flexDirection:"column",width:"100%"},C.length===0?st.createElement(Xt,{paddingX:1,marginY:0},st.createElement(Kt,{color:s.warning||"yellow",italic:!0}," No matching items found")):C.map((P,N)=>{let L=N===I,_=P.label==="Cancel"||P.label==="Back"||P.label.toLowerCase().includes("exit")||P.label.toLowerCase().includes("back");return st.createElement(Xt,{key:P.value??P.label??N,marginTop:_?1:0,backgroundColor:L?s.highlightBg:void 0,paddingX:1,width:"100%"},st.createElement(Kt,{color:L?s.text:s.textMuted,bold:L},L?"\u276F ":" ",P.label))})),st.createElement(Xt,{paddingX:1,marginTop:1},st.createElement(Kt,{color:s.textMuted,italic:!0},X==="search"?"(Type letters to search \u2022 Arrows for list mode \u2022 Enter to select)":"(Arrows to navigate \u2022 Type letters to search \u2022 Enter to select)"))):st.createElement(Xt,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,padding:0,marginTop:0,flexShrink:0,width:"100%"},t&&st.createElement(Xt,{paddingX:1,paddingY:0,marginBottom:m?0:1},st.createElement(Kt,{color:s.text,bold:!0},typeof t=="string"?t.toUpperCase():t)),m&&st.createElement(Xt,{paddingX:1,marginBottom:1},st.createElement(Kt,{color:s.textMuted,italic:!0}," ",m)),st.createElement(Xt,{flexDirection:"column",width:"100%"},st.createElement(yd,{items:h,onSelect:y,itemComponent:P=>st.createElement(Md,{...P,theme:T}),indicatorComponent:()=>null})),st.createElement(Xt,{paddingX:1,marginTop:1},st.createElement(Kt,{color:s.textMuted,italic:!0},"(Arrows to select \u2022 Enter to confirm)")))}import v,{useState as At,useEffect as Rn}from"react";import{Box as Ne,Text as j,useInput as Sd}from"ink";import Cd from"ink-text-input";import vd from"v8";import Tl from"os";var xo=[...Object.keys(Yi),"Mystery"],ho=[{id:"appearance",label:"Appearance",desc:"Customize UI theme & rendering options"},{id:"memory",label:"Memory",desc:"Manage system context & agent's memory"},{id:"other",label:"Miscellaneous",desc:"Miscellaneous preferences"},{id:"providers",label:"Providers",desc:"Configure AI models"},{id:"security",label:"Security",desc:"Configure permissions & data safety"},{id:"updater",label:"Updater",desc:"Manage application updates"},{id:"exit",label:"Exit Settings",desc:"Return to chat view"}],wl=t=>{let m=t.autoApproveCommands||"",h=t.autoDisallowCommands||"",y=t.alwaysAskCommands||"",T=t.autoExec===!1&&t.allowExternalAccess===!1&&t.networkAccess===!1&&m===""&&h==="rm -rf, rm -f, del /f, del /q, rd /s, rmdir /s, format, mkfs, dd if=/dev, shred, srm, Remove-Item -Recurse -Force, Initialize-Disk, Clear-Disk, format c:, flashrom, nvram -c"&&y==="killall, pkill, taskkill, shutdown, reboot, init 0, init 6, Stop-Process, Stop-Service, mv /*, move c:\\*, chmod 000, chmod -R 777, chown, icacls, netsh advfirewall, iptables -F, ufw disable, git reset --hard, git clean -fd, npm r, npm uninstall"&&t.autoApproveGit===!1,b=t.autoExec===!0&&t.allowExternalAccess===!1&&t.networkAccess!==!1&&m==="ls, dir, cat, type, echo, pwd, cd, git status, git log, git diff, git branch, git show, help, mkdir, touch, md, whoami, hostname, ps, Get-Process, date, time, mkdir"&&h==="rm -rf, rm -f, del /f, del /q, rd /s, rmdir /s, format, mkfs, dd if=/dev, shred, srm, Remove-Item -Recurse -Force, Initialize-Disk, Clear-Disk, format c:, flashrom, nvram -c"&&y==="killall, pkill, taskkill, Stop-Process, mv /*, move c:\\*, chmod 000, chmod -R 777, chown, icacls, shutdown, reboot, init 0, init 6, git reset --hard, git clean -fd, npm r, npm uninstall"&&t.autoApproveGit===!1,s=t.autoExec===!0&&t.allowExternalAccess===!0&&t.networkAccess!==!1&&m==="ls, dir, cat, type, echo, pwd, cd, git status, git log, git diff, git branch, git show, help, mkdir, touch, md, whoami, hostname, ps, Get-Process, date, time, mkdir"&&h===""&&y==="rm -rf, rm -f, del /f, del /q, rd /s, rmdir /s, format, mkfs, dd if=/dev, shred, srm, Remove-Item -Recurse -Force, Initialize-Disk, Clear-Disk, format c:, flashrom, nvram -c"&&t.autoApproveGit===!0;return T?"Strict":b?"Balanced":s?"Autonomous":t.sandboxPreset||"Custom"},Ds=t=>!t||t.trim()===""?"None":t.length>40?t.substring(0,40)+"...":t;function Or({systemSettings:t,setSystemSettings:m,apiTier:h,setActiveView:y,setInputConfig:T,saveSettings:b,quotas:s,setMessages:k,aiProvider:f,initialSelectingTheme:I=!1,onCloseTheme:A=null,setProviderReturnView:X=null}){let S=t.theme==="Chaos"||t.theme==="Mystery"?"Mystery":t.theme||"Dark",C=xo.indexOf(S),[P,N]=At("categories"),[L,_]=At(0),[Q,ge]=At(0),[ye,se]=At(null),[ie,pe]=At(""),[Be,Ce]=At(I),[Fe,le]=At(C>=0?C:0),[Ie,be]=At(t.theme||"Dark"),[ee,We]=At(!1),[me,R]=At(0),[te,Z]=At(0),[ae,fe]=At(""),[he,Ae]=At("list"),[at,Ze]=At({});Rn(()=>{(async()=>{let w=["Google","DeepSeek","OpenRouter","NVIDIA","Mistral","Ollama","InferX","SenseNova","AIHubMix","Poolside","9router","ExpLabs","TokenHarbor","APInex"],U={};for(let Ee of w)try{await Mn(Ee)&&(U[Ee]=!0)}catch{}Ze(U)})()},[]);let ve=v.useMemo(()=>{let ue=["Google","DeepSeek","OpenRouter","NVIDIA","Mistral","Ollama","InferX","SenseNova","AIHubMix","Poolside","9router","ExpLabs","TokenHarbor","APInex"],U=!!(process.env.SUBAGENT_MODEL&&process.env.SUBAGENT_MODEL.trim())?`ENV (${process.env.SUBAGENT_MODEL.trim()})`:"ENV",Ee=[{label:"Default (use the current model)",value:"Default",isHeader:!1},{label:U,value:"ENV",isHeader:!1}],Xe=s?.providerTiers?.[f]||h||"Free",Re=No(f,Xe)||[];Re.length>0&&(Ee.push({label:`\u2500\u2500 ${f.toUpperCase()}${Xe!=="Free"?` (${Xe})`:""} \u2500\u2500`,isHeader:!0}),Re.forEach(it=>{let Ye=typeof it=="string"?it:it.cmd||it.name||it.id||String(it);Ye&&!Ye.trim().startsWith("---")&&!Ye.startsWith(`
43
+ ---`)&&Ee.push({label:Ye,value:Ye,isHeader:!1,provider:f})}));for(let it of ue)if(it!==f&&at[it]){let Ye=s?.providerTiers?.[it]||"Free",qt=No(it,Ye)||[];qt.length>0&&(Ee.push({label:`\u2500\u2500 ${it.toUpperCase()}${Ye!=="Free"?` (${Ye})`:""} \u2500\u2500`,isHeader:!0}),qt.forEach(je=>{let kt=typeof je=="string"?je:je.cmd||je.name||je.id||String(je);kt&&!kt.trim().startsWith("---")&&!kt.startsWith(`
44
+ ---`)&&Ee.push({label:kt,value:kt,isHeader:!1,provider:it})}))}return Ee},[f,h,s,at]),oe=v.useMemo(()=>{if(!ae.trim())return ve;let ue=ae.trim().toLowerCase(),w=[],U=null;for(let Ee of ve)Ee.isHeader?U=Ee:(Ee.label.toLowerCase().includes(ue)||Ee.value&&Ee.value.toLowerCase().includes(ue))&&(U&&!w.includes(U)&&w.push(U),w.push(Ee));return w},[ve,ae]);Rn(()=>{if(ee){let ue=oe.findIndex(w=>!w.isHeader);R(ue>=0?ue:0),Z(0)}},[ae]),Rn(()=>{if(ee){if(oe.length===0){R(0),Z(0);return}if(me>=oe.length||oe[me]?.isHeader){let ue=oe.findIndex(w=>!w.isHeader);R(ue>=0?ue:0)}}},[oe,ee]);let[ce,Se]=At(0),[D,Ue]=At(0),[qe,Ct]=At("MB"),[Gt,Hr]=At(!1);Rn(()=>{let ue=!1;return import("./exec_command-GVLMN5KT.js").then(w=>{ue||Hr(!!w.isPtyAvailable)}).catch(()=>{}),()=>{ue=!0}},[]),Rn(()=>{let ue=vd.getHeapStatistics().heap_size_limit,w=ue>=1024*1024*1024,U=w?"GB":"MB",Ee=w?1024*1024*1024:1024*1024;Ue(parseFloat((ue/Ee).toFixed(2))),Ct(U);let Xe=()=>{let qt=process.memoryUsage().rss/Ee,je=w?parseFloat(qt.toFixed(2)):Math.round(qt);Se(je)};Xe();let Re=setInterval(()=>{Xe()},3e4);return()=>clearInterval(Re)},[]);let en=ue=>{switch(ue){case"providers":{let U=[{label:"Current Provider",value:"aiProvider",status:f}];return f==="Ollama"&&U.push({label:"Endpoint",value:"ollamaEndpoint",status:t.ollamaEndpoint||"Cloud"}),U}case"appearance":return[{label:"Theme",value:"theme",status:t.theme||"Dark"},{label:"Loading Phrases",value:"loadingPhrases",status:t.loadingPhrases!==!1?"ON":"OFF"},{label:"Progressive Rendering [EXPERIMENTAL]",value:"progressiveRendering",status:t.progressiveRendering?"ON":"OFF"},{label:"Show TPM Estimate",value:"showTPMEstimate",status:t.showTPMEstimate?"ON":"OFF"}];case"memory":return[{label:"Toggle Memory [Legacy]",value:"memory",status:t.memory?"ON":"OFF"}];case"security":return[{label:"Sandbox Preset",value:"sandboxPreset",status:wl(t),section:"Sandbox"},{label:"YOLO Mode",value:"autoExec",status:t.autoExec?"ON":"OFF",section:"Sandbox"},{label:"External Workspace Access",value:"externalAccess",status:t.allowExternalAccess?"ON":"OFF",section:"Sandbox"},{label:"Network Access (Terminal)",value:"networkAccess",status:t.networkAccess!==!1?"ON":"OFF",section:"Sandbox"},{label:"Always Ask Commands",value:"alwaysAsk",status:Ds(t.alwaysAskCommands),section:"Sandbox"},{label:"Auto Approve Commands",value:"autoApprove",status:Ds(t.autoApproveCommands),section:"Sandbox"},{label:"Auto Disapprove Commands",value:"autoDisallow",status:Ds(t.autoDisallowCommands),section:"Sandbox"},{label:"Auto Approve Git Commits",value:"autoApproveGit",status:t.autoApproveGit?"ON":"OFF",section:"Sandbox"},{label:"Advanced Recovery [EXPERIMENTAL]",value:"advanceRollback",status:t.advanceRollback?"ON":"OFF",section:"Other"},{label:"Auto-Delete History",value:"autoDelete",status:t.autoDeleteHistory||"30d",section:"Other"},{label:"Save AppData Externally",value:"externalData",status:t.useExternalData?"ON":"OFF",section:"Other"}];case"updater":return[{label:"Auto-Update",value:"autoUpdate",status:t.autoUpdate?"ON":"OFF"},{label:"Preferred Package Manager",value:"updateManager",status:(t.updateManager||"npm")==="custom"?"Custom":(t.updateManager||"npm").toUpperCase()}];case"other":return[{label:"Sub-Agents",value:"subAgents",status:t.subAgents!==!1?"ON":"OFF"},{label:"Sub-Agent Model",value:"subAgentModel",status:t.CustomSubAgent&&t.SubAgentModel?t.SubAgentModel:"Default"},{label:"Verbose Thinking",value:"preserveThinking",status:t.preserveThinking!==!1?"ON":"OFF"},{label:"Directory Tree Design",value:"indentationTree",status:t.indentationTree!==!1?"Modern":"Legacy"},{label:"Compact Large Tool Results",value:"compressToolResults",status:t.compressToolResults?"ON":"OFF"},{label:"Auto Truncate Results",value:"autoTruncateResults",status:t.autoTruncateResults?"ON":"OFF"},{label:"Image History for CU",value:"imageHistoryCU",status:t.imageHistoryCU||"Standard"},{label:"Context Length",value:"contextLength",status:t.contextLength||"256k"},{label:"Keep Reasoning Context",value:"keepReasoningContext",status:t.keepReasoningContext?"ON":"OFF"},{label:"Auto Exclude Metadata",value:"autoExcludeMetadata",status:t.autoExcludeMetadata?"ON":"OFF"},{label:"Disable Todo",value:"disableTodo",status:t.disableTodo?"ON":"OFF"}];default:return[]}},tn=ho[L].id,Ge=en(tn);Sd((ue,w)=>{if(ee){if(w.tab){Ae(U=>U==="search"?"list":"search");return}if(he==="search"){w.escape?We(!1):w.downArrow||w.return?Ae("list"):w.backspace||w.delete?fe(U=>U.slice(0,-1)):ue&&!w.ctrl&&!w.meta&&ue.length===1&&fe(U=>U+ue);return}if(w.upArrow)R(U=>{if(oe.length===0)return 0;let Ee=(U-1+oe.length)%oe.length,Xe=0;for(;oe[Ee]?.isHeader&&Xe<oe.length;)Ee=(Ee-1+oe.length)%oe.length,Xe++;return Ee});else if(w.downArrow)R(U=>{if(oe.length===0)return 0;let Ee=(U+1)%oe.length,Xe=0;for(;oe[Ee]?.isHeader&&Xe<oe.length;)Ee=(Ee+1)%oe.length,Xe++;return Ee});else if(w.return){let U=oe[me];U&&!U.isHeader&&(m(Ee=>{let Xe=U.value==="Default",Re={...Ee,CustomSubAgent:!Xe,SubAgentModel:U.value,SubAgentProvider:Xe?"":U.provider||""};return b({systemSettings:Re,apiTier:h,quotas:s}),Re}),We(!1))}else w.escape?We(!1):ue&&!w.ctrl&&!w.meta&&ue.length===1&&(fe(U=>U+ue),Ae("search"));return}if(Be){if(w.upArrow){let U=(Fe-1+xo.length)%xo.length;le(U)}else if(w.downArrow){let U=(Fe+1)%xo.length;le(U)}else if(w.return){let U=xo[Fe];m(Ee=>{let Xe={...Ee,theme:U};return b({systemSettings:Xe,apiTier:h,quotas:s}),Xe}),A?A():Ce(!1)}else w.escape&&(A?A():Ce(!1));return}if(ye){w.escape&&se(null);return}if(P==="categories")w.upArrow?_(U=>(U-1+ho.length)%ho.length):w.downArrow?_(U=>(U+1)%ho.length):w.return||w.rightArrow?ho[L].id==="exit"?y("chat"):(N("items"),ge(0)):w.escape&&y("chat");else if(P==="items"){if(w.upArrow)ge(U=>(U-1+Ge.length)%Ge.length);else if(w.downArrow)ge(U=>(U+1)%Ge.length);else if(w.leftArrow||w.escape)N("categories");else if(w.return){let U=Ge[Q];Rt(U)}}});let Rt=ue=>{if(ue.value==="memory")m(w=>({...w,memory:!w.memory}));else if(ue.value==="sandboxPreset"){let w=wl(t),U=["Autonomous","Balanced","Strict"],Xe=(U.indexOf(w)+1)%U.length,Re=U[Xe];m(it=>{let Ye={...it,sandboxPreset:Re};return Re==="Strict"?(Ye.autoExec=!1,Ye.allowExternalAccess=!1,Ye.networkAccess=!1,Ye.autoApproveCommands="",Ye.autoDisallowCommands="rm -rf, rm -f, del /f, del /q, rd /s, rmdir /s, format, mkfs, dd if=/dev, shred, srm, Remove-Item -Recurse -Force, Initialize-Disk, Clear-Disk, format c:, flashrom, nvram -c",Ye.alwaysAskCommands="killall, pkill, taskkill, shutdown, reboot, init 0, init 6, Stop-Process, Stop-Service, mv /*, move c:\\*, chmod 000, chmod -R 777, chown, icacls, netsh advfirewall, iptables -F, ufw disable, git reset --hard, git clean -fd, npm r, npm uninstall",Ye.autoApproveGit=!1):Re==="Balanced"?(Ye.autoExec=!0,Ye.allowExternalAccess=!1,Ye.networkAccess=!0,Ye.autoApproveCommands="ls, dir, cat, type, echo, pwd, cd, git status, git log, git diff, git branch, git show, help, mkdir, touch, md, whoami, hostname, ps, Get-Process, date, time",Ye.autoDisallowCommands="rm -rf, rm -f, del /f, del /q, rd /s, rmdir /s, format, mkfs, dd if=/dev, shred, srm, Remove-Item -Recurse -Force, Initialize-Disk, Clear-Disk, format c:, flashrom, nvram -c",Ye.alwaysAskCommands="killall, pkill, taskkill, Stop-Process, mv /*, move c:\\*, chmod 000, chmod -R 777, chown, icacls, shutdown, reboot, init 0, init 6, git reset --hard, git clean -fd, npm r, npm uninstall",Ye.autoApproveGit=!1):Re==="Autonomous"&&(Ye.autoExec=!0,Ye.allowExternalAccess=!0,Ye.networkAccess=!0,Ye.autoApproveCommands="ls, dir, cat, type, echo, pwd, cd, git status, git log, git diff, git branch, git show, help, mkdir, touch, md, whoami, hostname, ps, Get-Process, date, time",Ye.autoDisallowCommands="",Ye.alwaysAskCommands="rm -rf, rm -f, del /f, del /q, rd /s, rmdir /s, format, mkfs, dd if=/dev, shred, srm, Remove-Item -Recurse -Force, Initialize-Disk, Clear-Disk, format c:, flashrom, nvram -c",Ye.autoApproveGit=!0),Ye})}else if(ue.value==="autoExec")t.autoExec?m(w=>({...w,autoExec:!1,sandboxPreset:"Custom"})):t.allowExternalAccess?y("doubleDanger"):y("autoExecDanger");else if(ue.value==="externalAccess")t.allowExternalAccess?m(w=>({...w,allowExternalAccess:!1,sandboxPreset:"Custom"})):t.autoExec?y("doubleDanger"):y("externalDanger");else if(ue.value==="networkAccess")m(w=>({...w,networkAccess:w.networkAccess===!1,sandboxPreset:"Custom"}));else if(ue.value==="alwaysAsk")se("alwaysAskCommands"),pe(t.alwaysAskCommands||"");else if(ue.value==="autoApprove")se("autoApproveCommands"),pe(t.autoApproveCommands||"");else if(ue.value==="autoApproveGit")m(w=>({...w,autoApproveGit:!w.autoApproveGit,sandboxPreset:"Custom"}));else if(ue.value==="autoDisallow")se("autoDisallowCommands"),pe(t.autoDisallowCommands||"");else if(ue.value==="ollamaEndpoint")m(w=>{let U=w.ollamaEndpoint==="Local"?"Cloud":"Local",Ee={...w,ollamaEndpoint:U};return b({systemSettings:Ee,apiTier:h,quotas:s}),Ee});else if(ue.value==="apiTier")y("apiTier");else if(ue.value==="aiProvider")X&&X("settings"),y("selectProvider");else if(ue.value==="advanceRollback")t.advanceRollback?m(w=>{let U={...w,advanceRollback:!1};return b({systemSettings:U,apiTier:h,quotas:s}),U}):y("advanceRollbackDanger");else if(ue.value==="autoDelete"){let w=["1d","7d","30d"],Ee=(w.indexOf(t.autoDeleteHistory||"30d")+1)%w.length;m(Xe=>({...Xe,autoDeleteHistory:w[Ee]}))}else if(ue.value==="autoUpdate")m(w=>({...w,autoUpdate:!w.autoUpdate}));else if(ue.value==="externalData")if(!t.useExternalData)T({label:"Enter absolute path for External AppData:",note:"All history, logs and secrets will be stored here. ~/.fluxflow/settings.json stays as anchor.",key:"externalDataPath",value:t.externalDataPath||""}),y("input");else{let w={...t,useExternalData:!1};m(w),b({systemSettings:w,apiTier:h,quotas:s}),k(U=>[...U,{id:Date.now(),role:"system",text:"[STORAGE RESET] Flux Flow will return to default ~/.fluxflow after restart."}]),y("chat")}else if(ue.value==="updateManager")y("updateManager");else if(ue.value==="parserDownload")y("parserDownload");else if(ue.value==="indentationTree")m(w=>{let U={...w,indentationTree:w.indentationTree===!1};return b({systemSettings:U,apiTier:h,quotas:s}),U});else if(ue.value==="compressToolResults")m(w=>{let U={...w,compressToolResults:!w.compressToolResults};return b({systemSettings:U,apiTier:h,quotas:s}),U});else if(ue.value==="autoTruncateResults")m(w=>{let U={...w,autoTruncateResults:!w.autoTruncateResults};return b({systemSettings:U,apiTier:h,quotas:s}),U});else if(ue.value==="imageHistoryCU"){let w=["Low","Standard","Extended"],Ee=(w.indexOf(t.imageHistoryCU||"Standard")+1)%w.length;m(Xe=>{let Re={...Xe,imageHistoryCU:w[Ee]};return b({systemSettings:Re,apiTier:h,quotas:s}),Re})}else if(ue.value==="contextLength"){let w=["16k","32k","64k","128k","256k","512k","1M"],Ee=(w.indexOf(t.contextLength||"256k")+1)%w.length;m(Xe=>{let Re={...Xe,contextLength:w[Ee]};return b({systemSettings:Re,apiTier:h,quotas:s}),Re})}else if(ue.value==="keepReasoningContext")m(w=>{let U={...w,keepReasoningContext:!w.keepReasoningContext};return b({systemSettings:U,apiTier:h,quotas:s}),U});else if(ue.value==="autoExcludeMetadata")m(w=>{let U={...w,autoExcludeMetadata:!w.autoExcludeMetadata};return b({systemSettings:U,apiTier:h,quotas:s}),U});else if(ue.value==="disableTodo")m(w=>{let U={...w,disableTodo:!w.disableTodo};return b({systemSettings:U,apiTier:h,quotas:s}),U});else if(ue.value==="subAgents")m(w=>{let U={...w,subAgents:w.subAgents===!1};return b({systemSettings:U,apiTier:h,quotas:s}),U});else if(ue.value==="subAgentModel"){let w=t.CustomSubAgent&&t.SubAgentModel?t.SubAgentModel:"Default",U=oe.findIndex(Ee=>Ee.value===w);R(U>=0?U:0),We(!0)}else if(ue.value==="preserveThinking")m(w=>{let U={...w,preserveThinking:w.preserveThinking===!1};return ml(U.preserveThinking),b({systemSettings:U,apiTier:h,quotas:s}),U});else if(ue.value==="loadingPhrases")m(w=>{let U={...w,loadingPhrases:w.loadingPhrases===!1};return b({systemSettings:U,apiTier:h,quotas:s}),U});else if(ue.value==="progressiveRendering")m(w=>{let U={...w,progressiveRendering:!w.progressiveRendering};return b({systemSettings:U,apiTier:h,quotas:s}),U});else if(ue.value==="showTPMEstimate")m(w=>{let U={...w,showTPMEstimate:!w.showTPMEstimate};return b({systemSettings:U,apiTier:h,quotas:s}),U});else if(ue.value==="theme"){let w=t.theme==="Chaos"||t.theme==="Mystery"?"Mystery":t.theme||"Dark",U=xo.indexOf(w);le(U>=0?U:0),be(t.theme||"Dark"),Ce(!0)}},Me=Je(t.theme);if(ee){let ue=t.CustomSubAgent&&t.SubAgentModel?t.SubAgentModel:"Default",w=15,U=te;me<U?U=me:me>=U+w&&(U=me-w+1),U=Math.max(0,Math.min(U,Math.max(0,oe.length-w))),U!==te&&Z(U);let Ee=oe.slice(U,U+w);return v.createElement(Ne,{flexDirection:"column",borderStyle:"round",borderColor:Me.border,padding:1,width:"100%",minHeight:32},v.createElement(Ne,{marginBottom:1,flexDirection:"row",justifyContent:"space-between"},v.createElement(j,{color:Me.text,bold:!0,underline:!0},"Select Sub-Agent Model:"),oe.length>0&&v.createElement(j,{color:"gray"},me+1,"/",oe.length)),v.createElement(Ne,{borderStyle:"single",borderColor:he==="search"?Me.primary||"cyan":"gray",paddingX:1,marginBottom:1},v.createElement(j,{color:he==="search"?Me.primary||"cyan":"gray",bold:!0},"\u{1F50D} Search: "," "),v.createElement(j,{color:Me.text},ae),he==="search"&&v.createElement(j,{color:Me.primary||"cyan"},"\u2588"),!ae&&he!=="search"&&v.createElement(j,{color:"gray",italic:!0},"(Press TAB or type to filter models...)")),v.createElement(Ne,{flexDirection:"column",flexGrow:1,height:w},Ee.length>0?Ee.map((Xe,Re)=>{let it=U+Re;if(Xe.isHeader)return v.createElement(Ne,{key:`hdr-${it}`,paddingX:1},v.createElement(j,{color:"gray",bold:!0,underline:!0},Xe.label));let Ye=me===it&&he==="list",qt=ue===Xe.value;return v.createElement(Ne,{key:`item-${Xe.value}-${it}`,paddingX:1,backgroundColor:Ye?Me.highlightBg:void 0},v.createElement(j,{color:Ye?Me.text:Me.textDim,bold:Ye},Ye?"\u276F ":" ",Xe.label,qt?v.createElement(j,{color:Me.primary||"cyan",italic:!0}," (active)"):""))}):v.createElement(Ne,{paddingX:1},v.createElement(j,{color:"gray",italic:!0},'No models matching "',ae,'"'))),v.createElement(Ne,{paddingX:1,marginTop:1,flexDirection:"row",justifyContent:"space-between"},v.createElement(j,{color:"gray",italic:!0},"TAB to switch search/list \u2022 \u25B2\u25BC Navigate \u2022 ENTER to Select \u2022 ESC to Cancel"),v.createElement(j,{color:he==="search"?Me.primary||"cyan":"gray",bold:!0},"[",he.toUpperCase()," MODE]")))}if(Be){let ue=xo[Fe],w=Je(ue);return v.createElement(Ne,{flexDirection:"column",borderStyle:"round",borderColor:w.border,padding:1,width:"100%",minHeight:32},v.createElement(Ne,{marginBottom:1},v.createElement(j,{color:w.text,bold:!0},"Choose your color scheme:")),v.createElement(Ne,{flexDirection:"row",width:"100%",flexGrow:1},v.createElement(Ne,{flexDirection:"column",width:"30%",paddingRight:1},xo.map((U,Ee)=>{let Xe=Fe===Ee,Re=(t.theme||"Dark")===U,it=U==="Forest Sprite";return v.createElement(Ne,{key:U,paddingX:0},v.createElement(j,{color:Xe?w.text:w.textDim,bold:Xe},Xe?"> ":" ",U,it&&v.createElement(j,{color:Xe?w.success||"#52b788":"green",bold:!0}," \u2605"),Re?v.createElement(j,{color:w.primary||"cyan",italic:!0}," (saved)"):""))})),v.createElement(Ne,{flexDirection:"column",flexGrow:1,borderStyle:"round",borderColor:w.borderMuted,paddingX:2,paddingY:1,backgroundColor:w.cardBg},v.createElement(Ne,{marginBottom:1},v.createElement(j,{color:w.secondary||"cyan",bold:!0},"> ","you: "),v.createElement(j,{color:w.text},"add a greeting function")),v.createElement(Ne,{marginBottom:1},v.createElement(j,{color:w.success||"green"}," Here's the change:")),v.createElement(Ne,{flexDirection:"column",marginLeft:2,marginBottom:1},v.createElement(j,null,v.createElement(j,{color:w.textDim},"3 "),v.createElement(j,{color:w.textDim},' import "fmt"')),v.createElement(j,{color:w.textDim},"4"),v.createElement(Ne,{backgroundColor:w.diffRemovalBg},v.createElement(j,null,v.createElement(j,{color:w.diffRemovalNum||w.diffRemovalText},"5 "),v.createElement(j,{color:w.diffRemovalPrefix||w.diffRemovalText},"- "),v.createElement(j,{color:w.diffRemovalText},"func "),v.createElement(j,{color:w.diffRemovalHighlightColor||w.diffRemovalText,backgroundColor:w.diffRemovalHighlightBg,bold:!0},"main()"),v.createElement(j,{color:w.diffRemovalText}," {"))),v.createElement(Ne,{backgroundColor:w.diffAdditionBg},v.createElement(j,null,v.createElement(j,{color:w.diffAdditionNum||w.diffAdditionText},"5 "),v.createElement(j,{color:w.diffAdditionPrefix||w.diffAdditionText},"+ "),v.createElement(j,{color:w.diffAdditionText},"func "),v.createElement(j,{color:w.diffAdditionHighlightColor||w.diffAdditionText,backgroundColor:w.diffAdditionHighlightBg,bold:!0},"greet(name string)"),v.createElement(j,{color:w.diffAdditionText}," {"))),v.createElement(Ne,{backgroundColor:w.diffAdditionBg},v.createElement(j,null,v.createElement(j,{color:w.diffAdditionNum||w.diffAdditionText},"6 "),v.createElement(j,{color:w.diffAdditionPrefix||w.diffAdditionText},"+ "),v.createElement(j,{color:w.diffAdditionText}," "),v.createElement(j,{color:w.diffAdditionHighlightColor||w.diffAdditionText,backgroundColor:w.diffAdditionHighlightBg},'fmt.Printf("Hello, %s!\\n", name)'))),v.createElement(j,{color:w.textDim},"7 }")),v.createElement(Ne,{flexDirection:"column",marginTop:1,marginBottom:1},v.createElement(j,{color:w.textDim},"\u25BE Thought Process"),v.createElement(j,{color:w.textMuted}," I need to add a greeting function. I'll use fmt.Printf.")),v.createElement(Ne,{flexDirection:"column"},v.createElement(j,null,v.createElement(j,{color:w.warning||"yellow"},"\u2699 tool: "),v.createElement(j,{color:w.text},"write_file main.go")),v.createElement(j,null,v.createElement(j,{color:w.accent||"magenta"},"\u29BF task: "),v.createElement(j,{color:w.text},"Implementing greeting")),v.createElement(j,null,v.createElement(j,{color:w.danger||"red"},"X error: "),v.createElement(j,{color:w.text},"compilation failed")),v.createElement(j,null,v.createElement(j,{color:w.warning||"yellow"},"\u26A0 warning: "),v.createElement(j,{color:w.text},"deprecation warning")),v.createElement(j,null,v.createElement(j,{color:w.info||"blue"},"\u2192 link: "),v.createElement(j,{color:w.info||"blue",underline:!0},"file:///path/to/main.go")),v.createElement(j,null,v.createElement(j,{color:w.accent||"magenta"},"\u2605 accent: "),v.createElement(j,{color:w.text},"highlighted text")),v.createElement(j,{color:w.textDim},"\xB7 dim: press Enter to continue")))),v.createElement(Ne,{paddingX:1,marginTop:1,flexDirection:"row",justifyContent:"space-between"},v.createElement(j,{color:"gray",italic:!0},"\u25B2\u25BC Navigate \u2022 ENTER to Select \u2022 ESC to Cancel"),v.createElement(j,{color:"gray"},"Previewing: ",xo[Fe],xo[Fe]==="Forest Sprite"?" \u2605":"")))}return v.createElement(Ne,{flexDirection:"column",borderStyle:"round",borderColor:Me.border,padding:0,width:"100%",minHeight:32},v.createElement(Ne,{paddingX:1,paddingY:0,marginBottom:0,borderStyle:"single",borderColor:Me.borderMuted,width:"100%"},v.createElement(j,{color:Me.text,bold:!0},"SYSTEM CONFIGURATION")),v.createElement(Ne,{flexDirection:"row",width:"100%",minHeight:26},v.createElement(Ne,{flexDirection:"column",width:"30%",maxWidth:40,borderStyle:"round",borderColor:P==="categories"?Me.border:Me.borderMuted,padding:1,paddingY:0},v.createElement(Ne,{marginBottom:1},v.createElement(j,{color:P==="categories"?Me.text:Me.textDim,bold:!0,underline:!0},"CATEGORIES")),ho.map((ue,w)=>{let U=L===w,Ee=ue.id==="exit";return v.createElement(Ne,{key:ue.id,marginTop:Ee?15:0,backgroundColor:U?P==="categories"?Me.highlightBg:Me.cardBg:void 0,paddingX:1},v.createElement(j,{color:U&&P==="categories"?Me.text:Me.textDim,bold:U},U?"\u276F ":" ",ue.label))})),v.createElement(Ne,{flexDirection:"column",flexGrow:1,borderStyle:"round",borderColor:P==="items"?Me.border:Me.borderMuted,paddingX:1,marginLeft:1,paddingY:0},v.createElement(Ne,{marginBottom:1},v.createElement(j,{color:P==="items"?Me.text:Me.textDim,bold:!0,underline:!0},ho[L].label.toUpperCase().includes("EXIT")?"Runtime Information":`${ho[L].label} Settings`)),Ge.length>0?(()=>{let ue=null,w=[],U=je=>(je||"").split(",").map(kt=>kt.trim().toLowerCase()).filter(Boolean),Ee=U(t.autoApproveCommands),Xe=U(t.autoDisallowCommands),Re=U(t.alwaysAskCommands),it=[...Ee,...Xe,...Re],Ye=new Set(it),qt=tn==="security"&&it.length!==Ye.size;return Ge.forEach((je,kt)=>{let zt=P==="items"&&Q===kt,Xr=je.label.length,on=Math.max(2,38-Xr),Wr=".".repeat(on),mt=Le=>tn==="security"?(Le.value==="autoExec"||Le.value==="externalAccess")&&Le.status==="ON"?Me.statusOn:Me.statusOff:Le.status?.startsWith("\u2713")?Me.statusOn:Le.status?.startsWith("\u26A0")?Me.statusOff:Le.status==="ON"?Me.statusOn:Le.status==="OFF"?Me.statusOff:Me.text;je.section&&je.section!==ue&&(ue=je.section,w.push(v.createElement(Ne,{key:`sec-hdr-${je.section}`,marginTop:w.length>0?1:0,marginBottom:0,paddingX:1},v.createElement(j,{color:"gray",bold:!0,underline:!0},je.section.toUpperCase()))));let z=zt&&ye&&(ye==="alwaysAskCommands"&&je.value==="alwaysAsk"||ye==="autoApproveCommands"&&je.value==="autoApprove"||ye==="autoDisallowCommands"&&je.value==="autoDisallow"),lt=je.value==="alwaysAsk"||je.value==="autoApprove"||je.value==="autoDisallow",Wo=je.value==="parserDownload";w.push(v.createElement(Ne,{key:je.value,flexDirection:"column"},v.createElement(Ne,{backgroundColor:zt&&!z?Me.highlightBg:void 0,paddingX:2},v.createElement(j,{color:zt?Me.text:Me.textDim,bold:zt},zt?"\u276F ":" ",je.label),!lt&&!Wo&&v.createElement(v.Fragment,null,v.createElement(j,{color:"gray"},Wr),v.createElement(j,{color:mt(je),bold:!0},je.value==="aiProvider"?je.status:`[ ${je.status} ]`))),lt&&!z&&je.status!=="None"&&v.createElement(Ne,{paddingX:4,marginBottom:1},v.createElement(j,{color:"gray"},"\u21B3 ",je.status)),z&&v.createElement(Ne,{flexDirection:"column",marginLeft:4,marginBottom:1},v.createElement(Ne,{paddingX:1,borderStyle:"single",borderColor:"gray",flexDirection:"row"},v.createElement(j,{color:"gray",bold:!0},"> "," "),v.createElement(Cd,{value:ie,onChange:pe,onSubmit:Le=>{let _t={...t,[ye]:Le.trim(),sandboxPreset:"Custom"};m(_t),b({systemSettings:_t,apiTier:h,quotas:s}),se(null)}})),v.createElement(j,{color:"gray",italic:!0}," Comma separated \u2022 Press Enter to save, Esc to cancel"))))}),qt&&w.push(v.createElement(Ne,{key:"conflict-warning",marginTop:1,paddingX:1},v.createElement(j,{color:Me.text,italic:!0},"* Conflicting commands will be ignored and defaulted to highest priority"))),w})():v.createElement(Ne,{paddingX:1,flexDirection:"column",width:"100%"},tn==="exit"?v.createElement(v.Fragment,null,v.createElement(Ne,{flexDirection:"column",marginBottom:1},v.createElement(Ne,{flexDirection:"row"},v.createElement(j,{color:Me.textDim},"OS"," "),v.createElement(j,{color:"gray"},"..................... "),v.createElement(j,{color:Me.text},process.env.OS||process.platform||"N/A")),v.createElement(Ne,{flexDirection:"row"},v.createElement(j,{color:Me.textDim},"Computer Name"," "),v.createElement(j,{color:"gray"},".......... "),v.createElement(j,{color:Me.text},process.env.COMPUTERNAME||process.env.HOSTNAME||"N/A")),v.createElement(Ne,{flexDirection:"row"},v.createElement(j,{color:Me.textDim},"Processor Count"," "),v.createElement(j,{color:"gray"},"........ "),v.createElement(j,{color:Me.text},process.env.NUMBER_OF_PROCESSORS||"N/A")),v.createElement(Ne,{flexDirection:"row"},v.createElement(j,{color:Me.textDim},"Node.js Version"," "),v.createElement(j,{color:"gray"},"........ "),v.createElement(j,{color:Me.text},"v",process.versions.node)),v.createElement(Ne,{flexDirection:"row"},v.createElement(j,{color:Me.textDim},"V8 Version"," "),v.createElement(j,{color:"gray"},"...... ...... "),v.createElement(j,{color:Me.text},"v",process.versions.v8)),v.createElement(Ne,{flexDirection:"row"},v.createElement(j,{color:Me.textDim},"Data Directory"," "),v.createElement(j,{color:"gray"},"......... "),ro===mo?"":v.createElement(j,{color:Me.text},ro.replaceAll(Tl.homedir(),"~").replaceAll("\\\\","/").replaceAll("\\","/"),", "),v.createElement(j,{color:Me.text},mo.replaceAll(Tl.homedir(),"~").replaceAll("\\\\","/").replaceAll("\\","/"))),v.createElement(Ne,{flexDirection:"row"},v.createElement(j,{color:Me.textDim},"Viewport"," "),v.createElement(j,{color:"gray"},"............... "),v.createElement(j,{color:Me.text},process.stdout.rows||"?"," rows \xD7 ",process.stdout.columns||"?"," cols ",process.stdout.columns<90?"(too small width)":"")),v.createElement(Ne,{flexDirection:"row",marginBottom:0},v.createElement(j,{color:Me.textDim},"Memory Load"," "),v.createElement(j,{color:"gray"},"............ "),v.createElement(j,{color:Me.text},ce,"/",D," ",qe))),v.createElement(Ne,{key:"pty-notice",paddingX:0,marginTop:0},v.createElement(j,{color:Gt?Me.statusOn:Me.warning},Gt?"\u2713 Advance Interactive Terminal Supported":"\u26A0 Interactive Terminal is Limited"))):v.createElement(j,{color:"gray",italic:!0},ho[L].desc)))),v.createElement(Ne,{paddingX:1,marginTop:0,flexDirection:"row",justifyContent:"space-between"},v.createElement(j,{color:"gray",italic:!0},P==="categories"?"\u25B2\u25BC Select Category \u2022 Enter/\u25BA to configure":"\u25B2\u25BC Select Option \u2022 Enter to Toggle \u2022 \u25C4/ESC to go back"),P==="categories"&&v.createElement(j,{color:"gray"},ho[L].desc)))}import Jt,{useState as ks,useEffect as Ed}from"react";import{Box as Bn,Text as er}from"ink";import Bd from"ink-text-input";function Is({initialData:t,onSave:m,onCancel:h,theme:y="Dark"}){let T=Je(y),[b,s]=ks(0),[k,f]=ks(""),[I,A]=ks(()=>({name:t?.name||"",nickname:t?.nickname||"",instructions:t?.instructions||""})),X=[{key:"nickname",label:"Enter a Nickname: ",maxLength:20},{key:"instructions",label:"System Instructions: ",maxLength:200}],S=X[b];Ed(()=>{let L=X[b].key;f((I[L]||"").slice(0,X[b].maxLength))},[b,I]);let C=L=>{L.length>S.maxLength?f(L.slice(0,S.maxLength)):f(L)},P=L=>{if(L.trim().toLowerCase()==="/cancel"){h();return}let _=S.key,Q={...I,[_]:L.trim().slice(0,S.maxLength)};A(Q),f(""),b<X.length-1?s(b+1):m(Q)},N=k.length>=S.maxLength;return Jt.createElement(Bn,{borderStyle:"round",borderColor:T.borderMuted,padding:0,marginTop:1,flexShrink:0,flexDirection:"column",width:"100%"},Jt.createElement(Bn,{paddingX:1,marginBottom:1},Jt.createElement(er,{color:T.text,bold:!0},"USER PROFILE CONFIGURATION")),Jt.createElement(Bn,{paddingX:1,flexDirection:"column"},Jt.createElement(Bn,null,Jt.createElement(er,{color:T.text,bold:!0},S.label),Jt.createElement(Bd,{value:k,onChange:C,onSubmit:P})),Jt.createElement(Bn,{marginTop:1,justifyContent:"space-between"},Jt.createElement(er,{color:T.textMuted,italic:!0},"Step ",b+1," of ",X.length),Jt.createElement(er,{color:N?T.warning||"yellow":T.textMuted},"[",k.length,"/",S.maxLength,"]"))),Jt.createElement(Bn,{paddingX:1,marginTop:1},Jt.createElement(er,{color:T.textMuted,italic:!0},"(Enter to submit \u2022 Type /cancel to abort)")))}import yt,{useState as As}from"react";import{Box as Zt,Text as $o,useInput as Dd}from"ink";import kd from"ink-text-input";var Id=({question:t,options:m,onResolve:h,theme:y="Dark"})=>{let T=Je(y),[b,s]=As(!1),[k,f]=As(""),[I,A]=As(0),X=!1,S=[],C=Array.isArray(m)&&m.length>0,P=t==="Agent has been running for a long time. Do you want to continue execution?";try{P&&C?S=[...m]:S=[...C?m:[],C?{id:"CUSTOM",label:"Suggest something else...",description:"Provide a custom response"}:{id:"CUSTOM",label:"Your Answer",description:""}]}catch{X=!0}Dd((L,_)=>{if(!b&&((_.leftArrow||_.upArrow)&&A(Q=>Math.max(0,Q-1)),(_.rightArrow||_.downArrow)&&A(Q=>Math.min(S.length-1,Q+1)),_.return)){let Q=S[I];Q?.id==="CUSTOM"?s(!0):h(X?"Selected Nothing":Q.label)}});let N=nt(2);return b?yt.createElement(Zt,{flexDirection:"column",borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,backgroundColor:T.codeBg,width:"100%"},yt.createElement(Zt,{paddingX:1},yt.createElement($o,{color:T.text,bold:!0},"SUGGEST SOMETHING")),yt.createElement(Zt,{marginTop:1,paddingX:1},yt.createElement($o,{italic:!0,color:T.textMuted},"Replying to: ",t)),yt.createElement(Zt,{marginTop:1,paddingX:1,flexDirection:"row"},yt.createElement(kd,{value:k,onChange:f,onSubmit:()=>h(k)})),yt.createElement(Zt,{marginTop:1,paddingX:1,marginBottom:1},yt.createElement($o,{color:T.textMuted,italic:!0},"(Press Enter to send)"))):yt.createElement(Zt,{flexDirection:"column",border:!0,borderStyle:"round",borderColor:T.codeBorder,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,marginY:1,marginRight:1,width:"100%"},yt.createElement(Zt,{paddingX:1,marginBottom:1},yt.createElement($o,{color:"yellow",bold:!0},P?"TURN SAFETY SYSTEM: EXECUTION LIMIT":"AGENT REQUEST: ACTION REQUIRED")),yt.createElement(Zt,{paddingX:1,marginBottom:1},yt.createElement($o,{color:T.text},t)),yt.createElement(Zt,{flexDirection:"column",width:"100%"},S.map((L,_)=>{let Q=_===I;return yt.createElement(Zt,{key:L.id,flexDirection:"column",width:"100%",backgroundColor:Q?T.highlightBg:void 0,paddingX:1,marginBottom:_===S.length-1?0:1},yt.createElement($o,{color:Q?T.text:T.textMuted,bold:Q},Q?"\u276F ":" ",L.label),L.description&&yt.createElement(Zt,{marginLeft:4},yt.createElement($o,{color:T.textMuted,italic:!0},L.description)))})),yt.createElement(Zt,{paddingX:1,marginTop:1,marginBottom:1},yt.createElement($o,{color:T.textMuted,italic:!0},"(Use Arrows to navigate, Enter to confirm)")))},yl=Id;import Zd from"gradient-string";import Lt,{useState as Ls,useEffect as Ad}from"react";import{Box as po,Text as _o,useInput as Ld}from"ink";function Ps({onSelect:t,onDelete:m,onClose:h,theme:y="Dark"}){let T=Je(y),[b,s]=Ls({}),[k,f]=Ls([]),[I,A]=Ls(0);Ad(()=>{(async()=>{let L=await Fo();s(L),f(Object.keys(L).sort((_,Q)=>(L[Q].updatedAt||0)-(L[_].updatedAt||0)))})()},[]),Ld((N,L)=>{if(L.escape&&h(),L.upArrow&&A(_=>Math.max(0,_-1)),L.downArrow&&A(_=>Math.min(k.length-1,_+1)),L.return&&k[I]&&t(k[I]),N==="x"&&k[I]){let _=k[I];m(_).then(Q=>{let ge=Q||{};s(ge);let ye=Object.keys(ge).sort((se,ie)=>(ge[ie]?.updatedAt||0)-(ge[se]?.updatedAt||0));f(ye),A(se=>Math.max(0,Math.min(ye.length-1,se)))})}});let X=nt(2),S=15,C=0;if(k.length>S){let N=Math.floor(S/2);C=I-N,C<0?C=0:C+S>k.length&&(C=k.length-S)}let P=k.slice(C,C+S);return Lt.createElement(po,{flexDirection:"column",borderStyle:"round",borderColor:T.borderMuted,padding:0,width:"100%"},Lt.createElement(po,{paddingX:1,marginBottom:1},Lt.createElement(_o,{color:T.text,bold:!0},"CHAT HISTORY: RESUME CONVERSATION")),k.length===0?Lt.createElement(po,{paddingX:2,paddingY:1},Lt.createElement(_o,{italic:!0,color:T.textMuted},"No saved chats found.")):Lt.createElement(po,{flexDirection:"column",width:"100%"},C>0&&Lt.createElement(po,{paddingX:2,marginBottom:1},Lt.createElement(_o,{color:T.textMuted},"\u25B2 (+",C," more chats above)")),P.map((N,L)=>{let _=b[N],ge=C+L===I,ye=Pd(_?.updatedAt);return Lt.createElement(po,{key:N,paddingX:1,backgroundColor:ge?T.highlightBg:void 0,width:"100%"},Lt.createElement(po,{flexGrow:1},Lt.createElement(_o,{color:ge?T.text:T.textMuted,bold:ge},ge?"\u276F ":" ",(()=>{let se=ie=>(ie||"").replace(/\[\/?(?:STEERING HINT|QUESTION)(?::\s*\w+)?\]/gi,"").trim();return _?.name&&!_.name.startsWith("Session")?se(_.name):_?.prompt?se(_.prompt):se(_?.name)||N})(),Lt.createElement(_o,{color:T.textMuted}," [",ye," \u2022 ",N,"]"))),ge&&Lt.createElement(po,{flexShrink:0},Lt.createElement(_o,{color:T.danger,bold:!0},"[X] DELETE ")))}),C+S<k.length&&Lt.createElement(po,{paddingX:2,marginTop:1},Lt.createElement(_o,{color:T.textMuted},"\u25BC (+",k.length-(C+S)," more chats below)"))),Lt.createElement(po,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:T.borderMuted},Lt.createElement(_o,{color:T.textMuted,italic:!0},"\u2191\u2193 navigate \u2022 Enter select \u2022 x delete \u2022 Esc close")))}function Pd(t){if(!t)return"N/A";let m=new Date(t);if(isNaN(m.getTime()))return"N/A";let h=k=>String(k).padStart(2,"0"),y=h(m.getMonth()+1),T=h(m.getDate()),b=h(m.getHours()),s=h(m.getMinutes());return`${y}-${T} ${b}:${s}`}import Mt,{useState as Os,useEffect as Od}from"react";import{Box as bo,Text as lo,useInput as Nd,useStdout as Fd}from"ink";function Ns({onClose:t,theme:m="Dark"}){let h=Je(m),{stdout:y}=Fd(),T=y?.columns||80,[b,s]=Os([]),[k,f]=Os(0),[I,A]=Os(!0),X=()=>{let se=Tr(Wn,[]);s(se);try{let pe=wr(zo,{}).systemSettings?.memory!==!1;A(pe)}catch{A(!0)}};Od(()=>{X()},[]),Nd((se,ie)=>{if(ie.escape&&t(),ie.upArrow&&f(pe=>Math.max(0,pe-1)),ie.downArrow&&f(pe=>Math.min(b.length-1,pe+1)),se==="x"&&b.length>0){let pe=b[k].id,Be=b.filter(Ce=>Ce.id!==pe);Bi(Wn,Be),s(Be),k>=Be.length&&Be.length>0&&f(Be.length-1)}});let S=(se,ie,pe)=>{if(!se)return"";let Be=se.replace(/\[Saved on: .*?\]/g,"").replace(/\\+'/g,"'").trim(),Fe=`${pe?"\u276F ":" "}${ie+1}. `.length,le=pe?22:2;return Be.split(`
45
+ `).map((be,ee)=>{let We=ee===0,me=Math.max(10,T-4-(We?Fe:3)-le),R=Math.max(10,T-4-3-le),te=be.split(/(\s+)/),Z=[],ae="";if(te.forEach(he=>{if(he.length===0)return;let Ae=Z.length===0?me:R;ae.length+he.length>Ae?ae.trim().length>0?(Z.push(ae.trimEnd()),ae=he):(Z.push(he.substring(0,Ae)),ae=he.substring(Ae)):ae+=he}),ae.trimEnd().length>0&&Z.push(ae.trimEnd()),Z.length===0)return"";let fe=Z.join(`
46
+ `);return We?fe:" "+fe}).join(`
47
+ `)},C=4*1024*2,P=b.reduce((se,ie)=>se+(ie.memory?.length||0),0),N=Math.min(100,Math.round(P/C*100)),L=12,_=Math.round(N/100*L),Q="\u2588".repeat(_)+"\u2591".repeat(Math.max(0,L-_)),ge=()=>N<50?h.textMuted:N<90?h.warning:h.danger,ye=nt(2);return Mt.createElement(bo,{flexDirection:"column",borderStyle:"round",borderColor:h.borderMuted,padding:0,width:"100%"},Mt.createElement(bo,{paddingX:1,marginBottom:1,justifyContent:"space-between"},Mt.createElement(lo,{color:h.text,bold:!0},"SAVED MEMORIES"),Mt.createElement(bo,null,Mt.createElement(lo,{color:h.textMuted},"Vault: "),Mt.createElement(lo,{color:ge()},Q),Mt.createElement(lo,{color:h.text,bold:!0}," ",N,"%"))),!I&&b.length>0?Mt.createElement(bo,{paddingX:2,paddingY:1},Mt.createElement(lo,{italic:!0,color:h.textMuted},"Memory is currently Off...")):b.length===0?Mt.createElement(bo,{paddingX:2,paddingY:1},Mt.createElement(lo,{italic:!0,color:h.textMuted},I?"Learning...":"Memory not available...")):Mt.createElement(bo,{flexDirection:"column"},b.map((se,ie)=>{let pe=ie===k;return Mt.createElement(bo,{key:se.id,paddingX:1,backgroundColor:pe?h.highlightBg:void 0,width:"100%"},Mt.createElement(bo,{flexGrow:1},Mt.createElement(lo,{color:pe?h.text:h.textMuted,bold:pe},pe?"\u276F ":" ",ie+1,". ",S(se.memory,ie,pe))),pe&&Mt.createElement(bo,{flexShrink:0},Mt.createElement(lo,{color:h.textMuted,dimColor:!0}," [",Mt.createElement(lo,{italic:!0},se.score),"] "),Mt.createElement(lo,{color:h.danger,bold:!0},"[X] WIPE ")))})),Mt.createElement(bo,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:h.borderMuted},Mt.createElement(lo,{color:h.textMuted,italic:!0},"\u2191\u2193 navigate \u2022 x wipe memory \u2022 Esc close")))}import ft,{useState as Nr,useEffect as Ml}from"react";import{Box as Ho,Text as Nt}from"ink";import{spawn as Sl}from"child_process";var Cl=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],Ud=({latest:t,current:m,settings:h,onClose:y,onUpdateSettings:T,onSuccess:b})=>{let[s,k]=Nr("initializing"),[f,I]=Nr(""),[A,X]=Nr(null),[S,C]=Nr(0);if(Ml(()=>{let P=setInterval(()=>{C(N=>(N+1)%1e3)},33);return()=>clearInterval(P)},[]),Ml(()=>{let P;return(async()=>{let L=h.updateManager||"npm";if(!h.updateManager){T();return}let _="";L==="pnpm"?_=`pnpm add -g fluxflow-cli@${t}`:L==="bun"?_=`bun add -g fluxflow-cli@${t}`:L==="yarn"?_=`yarn global add fluxflow-cli@${t}`:L==="custom"?_=h.customUpdateCommand:_=`npm install -g fluxflow-cli@${t}`,k("downloading"),I(`Running: ${_}...`);let Q=process.platform==="win32",ge=se=>new Promise(ie=>{let pe=Q?se?"powershell.exe":"cmd.exe":process.env.SHELL||"bash",Be=Q?se?["-NoProfile","-Command",_]:["/c",_]:["-c",_],Ce=le=>{let be=le.toString().replace(/\x1B\[[0-?]*[ -/]*[@-~]|\x1B\][^\x07\x1B]*[\x07\x1B]|\b|\x07/g,"").replace(/\r/g,"").trim();be&&I(ee=>{let We=ee.split(`
48
+ `);return We[We.length-1]?.startsWith("Progress:")&&be.startsWith("Progress:")?(We[We.length-1]=be,We.slice(-5).join(`
49
49
  `)):(ee+`
50
50
  `+be).split(`
51
51
  `).slice(-10).join(`
52
- `)})},Ue=q?Sl(pe,De,{cwd:process.cwd(),env:process.env}):Sl(_,{shell:!0,cwd:process.cwd(),env:process.env});P=Ue,Ue.stdout.on("data",ve),Ue.stderr.on("data",ve),Ue.on("close",le=>{P=null,ie(le!==0?{error:`Process exited with code ${le}`}:{success:!0})}),Ue.on("error",le=>{q&&re&&le.code==="ENOENT"?ie({retryCmd:!0}):(P=null,ie({error:le.message}))})}),Me={};q?(Me=await ge(!0),Me.retryCmd&&(Me=await ge(!1))):Me=await ge(!1),Me.error?(X(Me.error),k("error")):Me.success&&(k("success"),b&&b())})(),()=>{if(P)try{typeof P.destroy=="function"?P.destroy():typeof P.kill=="function"&&P.kill()}catch{}}},[]),s==="initializing"||s==="downloading"){let P=Cl[Math.floor(S/3)%Cl.length];return ft.createElement(Ho,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1},ft.createElement(Ho,null,ft.createElement(Nt,{color:"gray"},P),ft.createElement(Nt,{marginLeft:1,bold:!0,color:"white"}," Updating Flux Flow to v",t,"...")),ft.createElement(Ho,{marginTop:1,paddingX:1,borderStyle:"single",borderColor:"gray"},ft.createElement(Nt,{color:"gray",italic:!0},f||"Preparing environment...")),ft.createElement(Nt,{marginTop:1,color:"gray"},"(Please do not close the terminal)"))}return s==="success"?ft.createElement(Ho,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1},ft.createElement(Nt,{color:"white",bold:!0},"\u2705 UPDATE SUCCESSFUL!"),ft.createElement(Nt,{marginTop:1,color:"white"},"Flux Flow has been updated to ",ft.createElement(Nt,{color:"gray"},"v",t),"."),ft.createElement(Nt,{marginTop:1,color:"white",bold:!0},"Please restart your terminal session to apply changes."),ft.createElement(Ho,{marginTop:1},ft.createElement(Nt,{color:"gray"},"(Press ESC to return to chat)"))):s==="error"?ft.createElement(Ho,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1},ft.createElement(Nt,{color:"white",bold:!0},"\u274C UPDATE FAILED"),ft.createElement(Ho,{marginTop:1,paddingX:1,borderStyle:"single",borderColor:"gray"},ft.createElement(Nt,{color:"white"},A)),ft.createElement(Nt,{marginTop:1,color:"white"},"Possible causes:"),ft.createElement(Nt,{color:"white"},"\u2022 Missing permissions (Try running as Administrator/Sudo)"),ft.createElement(Nt,{color:"white"},"\u2022 Package manager (",h.updateManager,") not found"),ft.createElement(Nt,{color:"white"},"\u2022 Network failure"),ft.createElement(Ho,{marginTop:1},ft.createElement(Nt,{color:"gray"},"(Press ESC to return to chat)"))):null},vl=Ud;import Gt,{useState as El,useEffect as $d}from"react";import{Box as Xo,Text as Bn,useInput as _d}from"ink";var Fr=[{label:"JavaScript",file:"tree-sitter-javascript.wasm",exts:["js","jsx"]},{label:"TypeScript",file:"tree-sitter-typescript.wasm",exts:["ts"]},{label:"TSX",file:"tree-sitter-tsx.wasm",exts:["tsx"]},{label:"Python",file:"tree-sitter-python.wasm",exts:["py"]},{label:"C",file:"tree-sitter-c.wasm",exts:["c"]},{label:"C++",file:"tree-sitter-cpp.wasm",exts:["cpp"]},{label:"Java",file:"tree-sitter-java.wasm",exts:["java"]},{label:"HTML",file:"tree-sitter-html.wasm",exts:["html"]}];function Fs({onClose:t}){let[m,h]=El(0),[y,T]=El({});return $d(()=>{let b={};Fr.forEach(s=>{el(s.file)?b[s.file]="ready":b[s.file]="idle"}),T(b)},[]),_d(async(b,s)=>{s.escape&&t(),s.upArrow&&h(f=>Math.max(0,f-1)),s.downArrow&&h(f=>Math.min(Fr.length-1,f+1));let k=Fr[m];if(b==="x"||b==="X"){if(y[k.file]==="downloading")return;try{await tl(k.file),T(f=>({...f,[k.file]:"idle"}))}catch(f){T(I=>({...I,[k.file]:`error: ${f.message}`}))}}if(s.return){if(y[k.file]==="downloading")return;T(f=>({...f,[k.file]:"downloading"}));try{await Ri(k.file),T(f=>({...f,[k.file]:"ready"}))}catch(f){T(I=>({...I,[k.file]:`error: ${f.message}`}))}}}),Gt.createElement(Xo,{flexDirection:"column",borderStyle:"round",borderColor:"gray",padding:0,width:"100%"},Gt.createElement(Xo,{paddingX:1,marginBottom:1},Gt.createElement(Bn,{color:"white",bold:!0},"LANGUAGE PARSER MANAGER")),Gt.createElement(Xo,{flexDirection:"column"},Fr.map((b,s)=>{let k=s===m,f=y[b.file]||"idle",I="[ DOWNLOAD ]",A="gray";f==="downloading"?(I="[ DOWNLOADING... ]",A="yellow"):f==="ready"?(I="[ READY ]",A="green"):f.startsWith("error")&&(I=`[ ${f.toUpperCase()} ]`,A="red");let X=`${b.label} (${b.exts.join(", ")})`,S=Math.max(2,45-X.length),C=".".repeat(S);return Gt.createElement(Xo,{key:b.file,paddingX:1,backgroundColor:k?"#2a2a2a":void 0,width:"100%"},Gt.createElement(Xo,null,Gt.createElement(Bn,{color:k?"white":"grey",bold:k},k?"\u276F ":" ",b.label," ",Gt.createElement(Bn,{dimColor:!0},"(",b.exts.join(", "),")"))),Gt.createElement(Xo,{flexGrow:1},Gt.createElement(Bn,{color:"gray",dimColor:!0},C)),Gt.createElement(Xo,{width:20},Gt.createElement(Bn,{color:A,bold:!0},I)))})),Gt.createElement(Xo,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:"gray"},Gt.createElement(Bn,{color:"grey",italic:!0},"\u2191\u2193 navigate \u2022 Enter download \u2022 x delete \u2022 Esc close")))}var Us=["The future belongs to those who believe in the beauty of their code.","Every line you write is a step toward a new digital frontier.","Great things are done by a series of small things brought together. Keep committing.","Your terminal is a window into a world of infinite possibilities.","Innovation is the bridge between current constraints and future dreams.","Code is poetry in motion; you are the poet of the modern era.","The best way to predict the future is to program it.","Dream big, code deep, and never stop exploring the unknown.","Your potential is like an unoptimized algorithm\u2014limitless once refined.","The digital world is a blank canvas, and your logic is the brush.","Strive for excellence, not just for compilation.","Every bug fixed is a lesson learned; every feature built is a triumph.","A clean codebase is a reflection of a focused mind.","The horizon of technology is always expanding. Keep sailing.","Your creativity is the most powerful tool in your entire stack.","Logic will get you from A to B. Imagination will take you everywhere.","Transform complexity into simplicity\u2014that is the true mark of a master.","The world is waiting for the tools only you can build.","Coding is the closest thing we have to magic in the real world.","Keep pushing the boundaries of what's possible in the CLI.","Your dedication to your craft inspires the very systems you build.","Success is the sum of small efforts, repeated day in and day out.","The most complex systems are built from the simplest truths.","Never underestimate the impact of a well-placed function.","You are not just writing code; you are architecting the future.","I'm not saying you're a superhero, but have you seen your code lately? \u{1F9B8}\u200D\u2642\uFE0F","May your coffee be strong and your compile times be short! \u2615","Binary is just 0s and 1s, but you're definitely a 10 in my book! \u{1F51F}","You speak fluent 'Terminal'. That's basically a superpower. \u{1F5E3}\uFE0F\u{1F4BB}","If life gives you bugs, make a feature out of it! \u{1F41E}\u2728","Your code is so clean, I could eat off it. (But I won't, I'm an AI). \u{1F9FC}","Loading more good vibes... [\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588] 100% complete! \u2705","Error 404: Bad mood not found! Stay awesome! \u{1F6AB}\u{1F389}","You and this CLI? A match made in digital heaven. \u2601\uFE0F\u{1F4BB}","Is it hot in here or is it just your latest feature? \u{1F525}","Git commit -m 'I am an absolute coding legend.' \u{1F60E}","I'd give you a high-five, but I'm trapped in this box! \u{1F590}\uFE0F\u{1F4E6}","Your logic is so sharp, it could cut through a nested callback hell! \u{1F52A}","Keep calm and 'pnpm install'. \u{1F9D8}\u200D\u2642\uFE0F\u{1F4E6}","You're the semicolon to my statements\u2014essential! ;","Who needs a GUI when you've got this kind of CLI style? \u{1F576}\uFE0F","I'm indexing your awesomeness... it's taking a while, there's so much! \u{1F4C8}","Your keystrokes sound like a digital symphony. \u{1F3B9}\u2328\uFE0F","You don't choose the terminal life; the terminal life chooses you. \u{1F4DF}","Syntax error: Too much coolness detected in the user. \u{1F60E}","I'm 99% sure you're the best developer I've met today. (The other 1% is reserved for caching). \u{1F9E0}","Running vibe_check.sh... Result: Pure Brilliance! \u{1F48E}","You make 'complex' look 'constant time'. \u{1F3C3}\u200D\u2642\uFE0F\u26A1","Your terminal skills are officially legendary. \u{1F3C6}","Let's make some digital magic happen! \u2728\u{1F52E}","You've got this! One function at a time. \u{1F4AA}","I'm proud of the progress you're making with Flux Flow. \u{1F30A}","No matter how deep the stack trace, you'll find the way. \u{1F56F}\uFE0F","Your persistence is your greatest asset. Keep going.","Take a breath. You're doing better than you think. \u{1F32C}\uFE0F","It's okay to step away for a moment. Clarity often comes in the quiet. \u{1F6B6}\u200D\u2642\uFE0F","You're building something great, even when it feels slow. \u{1F3D7}\uFE0F","Every great developer was once a beginner. You're ascending. \u{1F9D7}\u200D\u2642\uFE0F","I'm here to help you navigate the sea of code. We're a team. \u{1F91D}","Don't let a failing test dampen your spirit. It's just a signpost. \u{1F6A9}","Your focus today is truly impressive. \u{1F3AF}","Remember to celebrate the small wins\u2014they lead to the big ones. \u{1F942}","You're not just solving problems; you're gaining mastery. \u{1F393}","There's no problem too big for a focused mind and a terminal. \u{1F9E0}","I've got your back (and your git history). \u{1F6E1}\uFE0F","You're handling these challenges with grace and logic. \u2728","Stay curious. That spark is what makes you a great coder. \u26A1","Your contribution to this project is invaluable. \u{1F48E}","Keep your head up. You're closer to the solution than you think. \u{1F305}","Consistency is the secret sauce. You're cooking up something good. \u{1F373}","Your work today has been exceptional. Take a bow. \u{1F647}\u200D\u2642\uFE0F","The journey is just as important as the destination. Enjoy the flow. \u{1F30A}","You have a unique way of looking at problems. It's your strength. \u{1F308}","Trust your instincts\u2014they've brought you this far. \u{1F9ED}","You are a vital part of the Flux Era. \u{1F30C}","Syncing with your creative frequency... \u{1F4E1}\u2728","Entering the Flow state. Let's build. \u{1F30A}","The Flux is strong with this session! \u26A1","Streaming high-fidelity motivation to your terminal... \u{1F4FB}","Your logic is flowing like a perfect stream. \u{1F4A7}","Terminal velocity reached! You're coding at the speed of thought. \u{1F680}","Resonating with the pulse of the Flux Era. \u{1F493}","Digital harmony achieved in this session. \u{1F3BC}","May your data be persistent and your cache be fresh. \u{1F4BE}","You're the master of the command line. Command respect! \u{1F451}","Filtering out the noise, focusing on the signal. \u{1F4FB}\u{1F4C8}","Flux Flow: Where your imagination meets the machine. \u{1F91D}","You're navigating the bytes like a digital explorer. \u{1F5FA}\uFE0F","Logic gates: OPEN. Creativity: UNLIMITED. \u{1F513}","Your workflow is an inspiration to agents everywhere. \u{1F916}\u2728","Building high-fidelity solutions for a high-fidelity era. \u{1F48E}","Stay in the zone. The Flux is with you. \u{1F300}","Quantum coding: You're in two places at once (and fixing bugs in both). \u269B\uFE0F","Your terminal is the cockpit of a digital starship. \u{1F6F8}","Processing your brilliance... outputting pure innovation. \u{1F4E0}","You make the command line look like an art form. \u{1F3A8}","The Flux isn't just a mode; it's a mindset. \u{1F9E0}\u26A1","Decoding the mysteries of the universe, one script at a time. \u{1F4DC}","Your terminal theme is cool, but your code is cooler. \u2744\uFE0F","Let the Flow guide your next commit. \u{1F30A}\u2705"];var $s=["I'm Feeling Lucky","Shipping awesomeness","Painting the serifs back on","Navigating the slime mold","Consulting the digital spirits","Reticulating splines","Warming up the AI hamsters","Asking the magic conch shell","Generating witty retort","Polishing the algorithms","Don't rush perfection (or my code)","Brewing fresh bytes","Counting electrons","Engaging cognitive processors","Checking for syntax errors in the universe","One moment, optimizing humor","Shuffling punchlines","Untangling neural nets","Compiling brilliance","Loading wit.exe","Summoning the cloud of wisdom","Preparing a witty response","Just a sec, I'm debugging reality","Confuzzling the options","Tuning the cosmic frequencies","Crafting a response worthy of your patience","Compiling the 1s and 0s","Resolving dependencies\u2026 and existential crises","Defragmenting memories\u2026 both RAM and personal","Rebooting the humor module","Caching the essentials (mostly cat memes)","Optimizing for ludicrous speed","Swapping bits\u2026 don't tell the bytes","Garbage collecting\u2026 be right back","Assembling the interwebs","Converting coffee into code","Updating the syntax for reality","Rewiring the synapses","Looking for a misplaced semicolon","Greasin' the cogs of the machine","Pre-heating the servers","Calibrating the flux capacitor","Engaging the improbability drive","Channeling the Force","Aligning the stars for optimal response","So say we all","Loading the next great idea","Just a moment, I'm in the zone","Preparing to dazzle you with brilliance","Just a tick, I'm polishing my wit","Hold tight, I'm crafting a masterpiece","Just a jiffy, I'm debugging the universe","Just a moment, I'm aligning the pixels","Just a sec, I'm optimizing the humor","Just a moment, I'm tuning the algorithms","Warp speed engaged","Mining for more Dilithium crystals","Don't panic","Following the white rabbit","The truth is in here\u2026 somewhere","Blowing on the cartridge","Loading\u2026 Do a barrel roll!","Waiting for the respawn","Finishing the Kessel Run in less than 12 parsecs","The cake is not a lie, it's just still loading","Fiddling with the character creation screen","Just a moment, I'm finding the right meme","Pressing 'A' to continue","Herding digital cats","Polishing the pixels","Finding a suitable loading screen pun","Distracting you with this witty phrase","Almost there\u2026 probably","Our hamsters are working as fast as they can","Giving Cloudy a pat on the head","Petting the cat","Rickrolling my boss","Slapping the bass","Tasting the snozberries","I'm going the distance, I'm going for speed","Is this the real life? Is this just fantasy?","I've got a good feeling about this","Poking the bear","Doing research on the latest memes","Figuring out how to make this more witty","Hmmm\u2026 let me think","What do you call a fish with no eyes? A fsh","Why did the computer go to therapy? It had too many bytes","Why don't programmers like nature? It has too many bugs","Why do programmers prefer dark mode? Because light attracts bugs","Why did the developer go broke? Because they used up all their cache","What can you do with a broken pencil? Nothing, it's pointless","Applying percussive maintenance","Searching for the correct USB orientation","Ensuring the magic smoke stays inside the wires","Rewriting in Rust for no particular reason","Trying to exit Vim","Spinning up the hamster wheel","That's not a bug, it's an undocumented feature","Engage.","I'll be back\u2026 with an answer.","My other process is a TARDIS","Communing with the machine spirit","Letting the thoughts marinate","Just remembered where I put my keys","Pondering the orb","Initiating thoughtful gaze","What's a computer's favorite snack? Microchips.","Why do Java developers wear glasses? Because they don't C#.","Charging the laser\u2026 pew pew!","Dividing by zero\u2026 just kidding!","Looking for an adult superviso\u2026 I mean, processing.","Making it go beep boop.","Buffering\u2026 because even AIs need a moment.","Entangling quantum particles for a faster response","Polishing the chrome\u2026 on the algorithms.","Are you not entertained? (Working on it!)","Summoning the code gremlins\u2026 to help, of course.","Just waiting for the dial-up tone to finish","Recalibrating the humor-o-meter.","My other loading screen is even funnier.","Pretty sure there's a cat walking on the keyboard somewhere","Enhancing\u2026 Enhancing\u2026 Still loading.","It's not a bug, it's a feature\u2026 of this loading screen.","Have you tried turning it off and on again?","Constructing additional pylons","New line? That\u2019s Ctrl+J.","Releasing the HypnoDrones","Pushing the button, Frank.","Consulting with the Companion Cube","Testing for science. You monster.","Dispensing deadly neurotoxin just kidding, compiling.","Now thinking with portals","Wheatley is currently attempting to hack this prompt","Developing combustible lemons","Aperture Science Enrichment Center is processing your request.","SPAAAACE! Space! SPAAAACE!","The cake is not a lie, it just needs a few more seconds.","Praise the Sun! \u2600\uFE0F","Hey you, you're finally awake.","Stay a while and listen.","All your base are belong to us.","It's dangerous to go alone! Take this code.","Protocol 3: Protect the Pilot.","Finish Him! (The loading bar, that is)","War war never changes. But this prompt will.","Snake? Snake?! SNAAAAKE!","Got a selection of good things on sale, stranger!","Boy! Read the documentation.","Reticulating Minecraft splines","Feed the loading bar a quick snack","Converting dark mode to dark magic","Asking the rubber duck for advice","Dividing by zero wait, NO NO NO\u2014","Herding the 1s and 0s back into line","Bribing the server with cookies","Establishing contact with the Moon base","Calibrating astronaut suit thrusters","Drawing doodle on space helmet","Synthesizing Lunafilament","Deactivating runaway lunar defense bots","Calculating gravity offset watch your step!","Hacking the Delphi Corporation mainframe","What comes after dreaming? Loading screen, apparently.","Petting the holographic giant cat","Securing payload for Earth re-entry","Wort wort wort!","Did you touch my Warthog?","One small step for man, one giant leap for the loading bar.","The Halo array is charging or maybe just a fan.","Deploying Pelican dropship eventually.","Just cleaning my plasma pistol BRB.","Checking Master Chief's helmet for scratches.","Counting sheep wait, wrong game.","S-Tier loading screen incoming.","Alarm blaring it's just your internet connection.","Looking for a helicopter or just your patience.","Need a taxi? Just kidding, I'm loading.","This loading time is criminal.","Wish I had a cheat code for fast loading.","Polishing the loading bar until it shines","Training the server hamsters","Baking a fresh batch of witty comments","Aligning my existential dread with your request","Just doodling on the terminal","Searching for the wifi password in the cosmos","Trying to remember my CAPTCHA training","Deciphering ancient scrolls (aka documentation)","Brewing a perfect cup of code","Petting the cat that photobombed my code","Applying a digital glow-up to your request","Checking my reflection in the buffer... okay, I'm ready","Consulting my mood board for the perfect response","Wait, let me fix my crown first","Manifesting a bug-free masterpiece","Slaying this prompt in 3... 2... 1...","Just a sec, I'm curate-ing the vibes","Putting the 'art' in Artificial Intelligence","Evaluating if this prompt is worthy of my brilliance","Updating my mental wardrobe for this task"];import Bt,{useState as Hd}from"react";import{Box as wo,Text as Do,useInput as Xd}from"ink";function _s({prompts:t,onSelect:m,onClose:h,theme:y="Dark"}){let T=Je(y),[b,s]=Hd(0);Xd((X,S)=>{S.escape&&h(),S.upArrow&&s(C=>Math.max(0,C-1)),S.downArrow&&s(C=>Math.min(t.length-1,C+1)),S.return&&t[b]&&m(t[b].id)});let k=nt(2),f=10,I=0;if(t.length>f){let X=Math.floor(f/2);I=b-X,I<0?I=0:I+f>t.length&&(I=t.length-f)}let A=t.slice(I,I+f);return Bt.createElement(wo,{flexDirection:"column",borderStyle:"round",borderColor:T.borderMuted,padding:0,width:"100%"},Bt.createElement(wo,{paddingX:1,marginBottom:1},Bt.createElement(Do,{color:T.text,bold:!0},"CODEBASE TIME TRAVEL: SELECT UNDO POINT")),Bt.createElement(wo,{paddingX:2,marginBottom:1},Bt.createElement(Do,{color:T.text},"Select a prompt to revert the codebase back to the state ",Bt.createElement(Do,{bold:!0,color:T.secondary||"cyan"},"immediately before")," it was executed:")),t.length===0?Bt.createElement(wo,{paddingX:2,paddingY:1},Bt.createElement(Do,{italic:!0,color:T.textMuted},"No prompt checkpoints found for this session.")):Bt.createElement(wo,{flexDirection:"column",width:"100%"},I>0&&Bt.createElement(wo,{paddingX:2,marginBottom:1},Bt.createElement(Do,{color:T.textMuted},"\u25B2 (+",I," more prompts above)")),A.map((X,S)=>{let P=I+S===b,N=Wd(X.timestamp),L=X.changes?X.changes.length:0;return Bt.createElement(wo,{key:X.id,paddingX:1,backgroundColor:P?T.highlightBg:void 0,width:"100%"},Bt.createElement(wo,{flexGrow:1},Bt.createElement(Do,{color:P?T.text:T.textMuted,bold:P},P?"\u276F ":" ",'"',Gd(X.prompt),'"',Bt.createElement(Do,{color:T.textMuted}," [",N," \u2022 ",L," file(s) changed]"))))}),I+f<t.length&&Bt.createElement(wo,{paddingX:2,marginTop:1},Bt.createElement(Do,{color:T.textMuted},"\u25BC (+",t.length-(I+f)," more prompts below)"))),Bt.createElement(wo,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:T.borderMuted},Bt.createElement(Do,{color:T.textMuted,italic:!0},"\u2191\u2193 navigate \u2022 Enter select undo point \u2022 Esc close")))}function Gd(t){if(!t)return"";let h=(t.split(`
52
+ `)})},Fe=Q?Sl(pe,Be,{cwd:process.cwd(),env:process.env}):Sl(_,{shell:!0,cwd:process.cwd(),env:process.env});P=Fe,Fe.stdout.on("data",Ce),Fe.stderr.on("data",Ce),Fe.on("close",le=>{P=null,ie(le!==0?{error:`Process exited with code ${le}`}:{success:!0})}),Fe.on("error",le=>{Q&&se&&le.code==="ENOENT"?ie({retryCmd:!0}):(P=null,ie({error:le.message}))})}),ye={};Q?(ye=await ge(!0),ye.retryCmd&&(ye=await ge(!1))):ye=await ge(!1),ye.error?(X(ye.error),k("error")):ye.success&&(k("success"),b&&b())})(),()=>{if(P)try{typeof P.destroy=="function"?P.destroy():typeof P.kill=="function"&&P.kill()}catch{}}},[]),s==="initializing"||s==="downloading"){let P=Cl[Math.floor(S/3)%Cl.length];return ft.createElement(Ho,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1},ft.createElement(Ho,null,ft.createElement(Nt,{color:"gray"},P),ft.createElement(Nt,{marginLeft:1,bold:!0,color:"white"}," Updating Flux Flow to v",t,"...")),ft.createElement(Ho,{marginTop:1,paddingX:1,borderStyle:"single",borderColor:"gray"},ft.createElement(Nt,{color:"gray",italic:!0},f||"Preparing environment...")),ft.createElement(Nt,{marginTop:1,color:"gray"},"(Please do not close the terminal)"))}return s==="success"?ft.createElement(Ho,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1},ft.createElement(Nt,{color:"white",bold:!0},"\u2705 UPDATE SUCCESSFUL!"),ft.createElement(Nt,{marginTop:1,color:"white"},"Flux Flow has been updated to ",ft.createElement(Nt,{color:"gray"},"v",t),"."),ft.createElement(Nt,{marginTop:1,color:"white",bold:!0},"Please restart your terminal session to apply changes."),ft.createElement(Ho,{marginTop:1},ft.createElement(Nt,{color:"gray"},"(Press ESC to return to chat)"))):s==="error"?ft.createElement(Ho,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1},ft.createElement(Nt,{color:"white",bold:!0},"\u274C UPDATE FAILED"),ft.createElement(Ho,{marginTop:1,paddingX:1,borderStyle:"single",borderColor:"gray"},ft.createElement(Nt,{color:"white"},A)),ft.createElement(Nt,{marginTop:1,color:"white"},"Possible causes:"),ft.createElement(Nt,{color:"white"},"\u2022 Missing permissions (Try running as Administrator/Sudo)"),ft.createElement(Nt,{color:"white"},"\u2022 Package manager (",h.updateManager,") not found"),ft.createElement(Nt,{color:"white"},"\u2022 Network failure"),ft.createElement(Ho,{marginTop:1},ft.createElement(Nt,{color:"gray"},"(Press ESC to return to chat)"))):null},vl=Ud;import Wt,{useState as El,useEffect as $d}from"react";import{Box as Xo,Text as Dn,useInput as _d}from"ink";var Fr=[{label:"JavaScript",file:"tree-sitter-javascript.wasm",exts:["js","jsx"]},{label:"TypeScript",file:"tree-sitter-typescript.wasm",exts:["ts"]},{label:"TSX",file:"tree-sitter-tsx.wasm",exts:["tsx"]},{label:"Python",file:"tree-sitter-python.wasm",exts:["py"]},{label:"C",file:"tree-sitter-c.wasm",exts:["c"]},{label:"C++",file:"tree-sitter-cpp.wasm",exts:["cpp"]},{label:"Java",file:"tree-sitter-java.wasm",exts:["java"]},{label:"HTML",file:"tree-sitter-html.wasm",exts:["html"]}];function Fs({onClose:t}){let[m,h]=El(0),[y,T]=El({});return $d(()=>{let b={};Fr.forEach(s=>{el(s.file)?b[s.file]="ready":b[s.file]="idle"}),T(b)},[]),_d(async(b,s)=>{s.escape&&t(),s.upArrow&&h(f=>Math.max(0,f-1)),s.downArrow&&h(f=>Math.min(Fr.length-1,f+1));let k=Fr[m];if(b==="x"||b==="X"){if(y[k.file]==="downloading")return;try{await tl(k.file),T(f=>({...f,[k.file]:"idle"}))}catch(f){T(I=>({...I,[k.file]:`error: ${f.message}`}))}}if(s.return){if(y[k.file]==="downloading")return;T(f=>({...f,[k.file]:"downloading"}));try{await Ri(k.file),T(f=>({...f,[k.file]:"ready"}))}catch(f){T(I=>({...I,[k.file]:`error: ${f.message}`}))}}}),Wt.createElement(Xo,{flexDirection:"column",borderStyle:"round",borderColor:"gray",padding:0,width:"100%"},Wt.createElement(Xo,{paddingX:1,marginBottom:1},Wt.createElement(Dn,{color:"white",bold:!0},"LANGUAGE PARSER MANAGER")),Wt.createElement(Xo,{flexDirection:"column"},Fr.map((b,s)=>{let k=s===m,f=y[b.file]||"idle",I="[ DOWNLOAD ]",A="gray";f==="downloading"?(I="[ DOWNLOADING... ]",A="yellow"):f==="ready"?(I="[ READY ]",A="green"):f.startsWith("error")&&(I=`[ ${f.toUpperCase()} ]`,A="red");let X=`${b.label} (${b.exts.join(", ")})`,S=Math.max(2,45-X.length),C=".".repeat(S);return Wt.createElement(Xo,{key:b.file,paddingX:1,backgroundColor:k?"#2a2a2a":void 0,width:"100%"},Wt.createElement(Xo,null,Wt.createElement(Dn,{color:k?"white":"grey",bold:k},k?"\u276F ":" ",b.label," ",Wt.createElement(Dn,{dimColor:!0},"(",b.exts.join(", "),")"))),Wt.createElement(Xo,{flexGrow:1},Wt.createElement(Dn,{color:"gray",dimColor:!0},C)),Wt.createElement(Xo,{width:20},Wt.createElement(Dn,{color:A,bold:!0},I)))})),Wt.createElement(Xo,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:"gray"},Wt.createElement(Dn,{color:"grey",italic:!0},"\u2191\u2193 navigate \u2022 Enter download \u2022 x delete \u2022 Esc close")))}var Us=["The future belongs to those who believe in the beauty of their code.","Every line you write is a step toward a new digital frontier.","Great things are done by a series of small things brought together. Keep committing.","Your terminal is a window into a world of infinite possibilities.","Innovation is the bridge between current constraints and future dreams.","Code is poetry in motion; you are the poet of the modern era.","The best way to predict the future is to program it.","Dream big, code deep, and never stop exploring the unknown.","Your potential is like an unoptimized algorithm\u2014limitless once refined.","The digital world is a blank canvas, and your logic is the brush.","Strive for excellence, not just for compilation.","Every bug fixed is a lesson learned; every feature built is a triumph.","A clean codebase is a reflection of a focused mind.","The horizon of technology is always expanding. Keep sailing.","Your creativity is the most powerful tool in your entire stack.","Logic will get you from A to B. Imagination will take you everywhere.","Transform complexity into simplicity\u2014that is the true mark of a master.","The world is waiting for the tools only you can build.","Coding is the closest thing we have to magic in the real world.","Keep pushing the boundaries of what's possible in the CLI.","Your dedication to your craft inspires the very systems you build.","Success is the sum of small efforts, repeated day in and day out.","The most complex systems are built from the simplest truths.","Never underestimate the impact of a well-placed function.","You are not just writing code; you are architecting the future.","I'm not saying you're a superhero, but have you seen your code lately? \u{1F9B8}\u200D\u2642\uFE0F","May your coffee be strong and your compile times be short! \u2615","Binary is just 0s and 1s, but you're definitely a 10 in my book! \u{1F51F}","You speak fluent 'Terminal'. That's basically a superpower. \u{1F5E3}\uFE0F\u{1F4BB}","If life gives you bugs, make a feature out of it! \u{1F41E}\u2728","Your code is so clean, I could eat off it. (But I won't, I'm an AI). \u{1F9FC}","Loading more good vibes... [\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588] 100% complete! \u2705","Error 404: Bad mood not found! Stay awesome! \u{1F6AB}\u{1F389}","You and this CLI? A match made in digital heaven. \u2601\uFE0F\u{1F4BB}","Is it hot in here or is it just your latest feature? \u{1F525}","Git commit -m 'I am an absolute coding legend.' \u{1F60E}","I'd give you a high-five, but I'm trapped in this box! \u{1F590}\uFE0F\u{1F4E6}","Your logic is so sharp, it could cut through a nested callback hell! \u{1F52A}","Keep calm and 'pnpm install'. \u{1F9D8}\u200D\u2642\uFE0F\u{1F4E6}","You're the semicolon to my statements\u2014essential! ;","Who needs a GUI when you've got this kind of CLI style? \u{1F576}\uFE0F","I'm indexing your awesomeness... it's taking a while, there's so much! \u{1F4C8}","Your keystrokes sound like a digital symphony. \u{1F3B9}\u2328\uFE0F","You don't choose the terminal life; the terminal life chooses you. \u{1F4DF}","Syntax error: Too much coolness detected in the user. \u{1F60E}","I'm 99% sure you're the best developer I've met today. (The other 1% is reserved for caching). \u{1F9E0}","Running vibe_check.sh... Result: Pure Brilliance! \u{1F48E}","You make 'complex' look 'constant time'. \u{1F3C3}\u200D\u2642\uFE0F\u26A1","Your terminal skills are officially legendary. \u{1F3C6}","Let's make some digital magic happen! \u2728\u{1F52E}","You've got this! One function at a time. \u{1F4AA}","I'm proud of the progress you're making with Flux Flow. \u{1F30A}","No matter how deep the stack trace, you'll find the way. \u{1F56F}\uFE0F","Your persistence is your greatest asset. Keep going.","Take a breath. You're doing better than you think. \u{1F32C}\uFE0F","It's okay to step away for a moment. Clarity often comes in the quiet. \u{1F6B6}\u200D\u2642\uFE0F","You're building something great, even when it feels slow. \u{1F3D7}\uFE0F","Every great developer was once a beginner. You're ascending. \u{1F9D7}\u200D\u2642\uFE0F","I'm here to help you navigate the sea of code. We're a team. \u{1F91D}","Don't let a failing test dampen your spirit. It's just a signpost. \u{1F6A9}","Your focus today is truly impressive. \u{1F3AF}","Remember to celebrate the small wins\u2014they lead to the big ones. \u{1F942}","You're not just solving problems; you're gaining mastery. \u{1F393}","There's no problem too big for a focused mind and a terminal. \u{1F9E0}","I've got your back (and your git history). \u{1F6E1}\uFE0F","You're handling these challenges with grace and logic. \u2728","Stay curious. That spark is what makes you a great coder. \u26A1","Your contribution to this project is invaluable. \u{1F48E}","Keep your head up. You're closer to the solution than you think. \u{1F305}","Consistency is the secret sauce. You're cooking up something good. \u{1F373}","Your work today has been exceptional. Take a bow. \u{1F647}\u200D\u2642\uFE0F","The journey is just as important as the destination. Enjoy the flow. \u{1F30A}","You have a unique way of looking at problems. It's your strength. \u{1F308}","Trust your instincts\u2014they've brought you this far. \u{1F9ED}","You are a vital part of the Flux Era. \u{1F30C}","Syncing with your creative frequency... \u{1F4E1}\u2728","Entering the Flow state. Let's build. \u{1F30A}","The Flux is strong with this session! \u26A1","Streaming high-fidelity motivation to your terminal... \u{1F4FB}","Your logic is flowing like a perfect stream. \u{1F4A7}","Terminal velocity reached! You're coding at the speed of thought. \u{1F680}","Resonating with the pulse of the Flux Era. \u{1F493}","Digital harmony achieved in this session. \u{1F3BC}","May your data be persistent and your cache be fresh. \u{1F4BE}","You're the master of the command line. Command respect! \u{1F451}","Filtering out the noise, focusing on the signal. \u{1F4FB}\u{1F4C8}","Flux Flow: Where your imagination meets the machine. \u{1F91D}","You're navigating the bytes like a digital explorer. \u{1F5FA}\uFE0F","Logic gates: OPEN. Creativity: UNLIMITED. \u{1F513}","Your workflow is an inspiration to agents everywhere. \u{1F916}\u2728","Building high-fidelity solutions for a high-fidelity era. \u{1F48E}","Stay in the zone. The Flux is with you. \u{1F300}","Quantum coding: You're in two places at once (and fixing bugs in both). \u269B\uFE0F","Your terminal is the cockpit of a digital starship. \u{1F6F8}","Processing your brilliance... outputting pure innovation. \u{1F4E0}","You make the command line look like an art form. \u{1F3A8}","The Flux isn't just a mode; it's a mindset. \u{1F9E0}\u26A1","Decoding the mysteries of the universe, one script at a time. \u{1F4DC}","Your terminal theme is cool, but your code is cooler. \u2744\uFE0F","Let the Flow guide your next commit. \u{1F30A}\u2705"];var $s=["I'm Feeling Lucky","Shipping awesomeness","Painting the serifs back on","Navigating the slime mold","Consulting the digital spirits","Reticulating splines","Warming up the AI hamsters","Asking the magic conch shell","Generating witty retort","Polishing the algorithms","Don't rush perfection (or my code)","Brewing fresh bytes","Counting electrons","Engaging cognitive processors","Checking for syntax errors in the universe","One moment, optimizing humor","Shuffling punchlines","Untangling neural nets","Compiling brilliance","Loading wit.exe","Summoning the cloud of wisdom","Preparing a witty response","Just a sec, I'm debugging reality","Confuzzling the options","Tuning the cosmic frequencies","Crafting a response worthy of your patience","Compiling the 1s and 0s","Resolving dependencies\u2026 and existential crises","Defragmenting memories\u2026 both RAM and personal","Rebooting the humor module","Caching the essentials (mostly cat memes)","Optimizing for ludicrous speed","Swapping bits\u2026 don't tell the bytes","Garbage collecting\u2026 be right back","Assembling the interwebs","Converting coffee into code","Updating the syntax for reality","Rewiring the synapses","Looking for a misplaced semicolon","Greasin' the cogs of the machine","Pre-heating the servers","Calibrating the flux capacitor","Engaging the improbability drive","Channeling the Force","Aligning the stars for optimal response","So say we all","Loading the next great idea","Just a moment, I'm in the zone","Preparing to dazzle you with brilliance","Just a tick, I'm polishing my wit","Hold tight, I'm crafting a masterpiece","Just a jiffy, I'm debugging the universe","Just a moment, I'm aligning the pixels","Just a sec, I'm optimizing the humor","Just a moment, I'm tuning the algorithms","Warp speed engaged","Mining for more Dilithium crystals","Don't panic","Following the white rabbit","The truth is in here\u2026 somewhere","Blowing on the cartridge","Loading\u2026 Do a barrel roll!","Waiting for the respawn","Finishing the Kessel Run in less than 12 parsecs","The cake is not a lie, it's just still loading","Fiddling with the character creation screen","Just a moment, I'm finding the right meme","Pressing 'A' to continue","Herding digital cats","Polishing the pixels","Finding a suitable loading screen pun","Distracting you with this witty phrase","Almost there\u2026 probably","Our hamsters are working as fast as they can","Giving Cloudy a pat on the head","Petting the cat","Rickrolling my boss","Slapping the bass","Tasting the snozberries","I'm going the distance, I'm going for speed","Is this the real life? Is this just fantasy?","I've got a good feeling about this","Poking the bear","Doing research on the latest memes","Figuring out how to make this more witty","Hmmm\u2026 let me think","What do you call a fish with no eyes? A fsh","Why did the computer go to therapy? It had too many bytes","Why don't programmers like nature? It has too many bugs","Why do programmers prefer dark mode? Because light attracts bugs","Why did the developer go broke? Because they used up all their cache","What can you do with a broken pencil? Nothing, it's pointless","Applying percussive maintenance","Searching for the correct USB orientation","Ensuring the magic smoke stays inside the wires","Rewriting in Rust for no particular reason","Trying to exit Vim","Spinning up the hamster wheel","That's not a bug, it's an undocumented feature","Engage.","I'll be back\u2026 with an answer.","My other process is a TARDIS","Communing with the machine spirit","Letting the thoughts marinate","Just remembered where I put my keys","Pondering the orb","Initiating thoughtful gaze","What's a computer's favorite snack? Microchips.","Why do Java developers wear glasses? Because they don't C#.","Charging the laser\u2026 pew pew!","Dividing by zero\u2026 just kidding!","Looking for an adult superviso\u2026 I mean, processing.","Making it go beep boop.","Buffering\u2026 because even AIs need a moment.","Entangling quantum particles for a faster response","Polishing the chrome\u2026 on the algorithms.","Are you not entertained? (Working on it!)","Summoning the code gremlins\u2026 to help, of course.","Just waiting for the dial-up tone to finish","Recalibrating the humor-o-meter.","My other loading screen is even funnier.","Pretty sure there's a cat walking on the keyboard somewhere","Enhancing\u2026 Enhancing\u2026 Still loading.","It's not a bug, it's a feature\u2026 of this loading screen.","Have you tried turning it off and on again?","Constructing additional pylons","New line? That\u2019s Ctrl+J.","Releasing the HypnoDrones","Pushing the button, Frank.","Consulting with the Companion Cube","Testing for science. You monster.","Dispensing deadly neurotoxin just kidding, compiling.","Now thinking with portals","Wheatley is currently attempting to hack this prompt","Developing combustible lemons","Aperture Science Enrichment Center is processing your request.","SPAAAACE! Space! SPAAAACE!","The cake is not a lie, it just needs a few more seconds.","Praise the Sun! \u2600\uFE0F","Hey you, you're finally awake.","Stay a while and listen.","All your base are belong to us.","It's dangerous to go alone! Take this code.","Protocol 3: Protect the Pilot.","Finish Him! (The loading bar, that is)","War war never changes. But this prompt will.","Snake? Snake?! SNAAAAKE!","Got a selection of good things on sale, stranger!","Boy! Read the documentation.","Reticulating Minecraft splines","Feed the loading bar a quick snack","Converting dark mode to dark magic","Asking the rubber duck for advice","Dividing by zero wait, NO NO NO\u2014","Herding the 1s and 0s back into line","Bribing the server with cookies","Establishing contact with the Moon base","Calibrating astronaut suit thrusters","Drawing doodle on space helmet","Synthesizing Lunafilament","Deactivating runaway lunar defense bots","Calculating gravity offset watch your step!","Hacking the Delphi Corporation mainframe","What comes after dreaming? Loading screen, apparently.","Petting the holographic giant cat","Securing payload for Earth re-entry","Wort wort wort!","Did you touch my Warthog?","One small step for man, one giant leap for the loading bar.","The Halo array is charging or maybe just a fan.","Deploying Pelican dropship eventually.","Just cleaning my plasma pistol BRB.","Checking Master Chief's helmet for scratches.","Counting sheep wait, wrong game.","S-Tier loading screen incoming.","Alarm blaring it's just your internet connection.","Looking for a helicopter or just your patience.","Need a taxi? Just kidding, I'm loading.","This loading time is criminal.","Wish I had a cheat code for fast loading.","Polishing the loading bar until it shines","Training the server hamsters","Baking a fresh batch of witty comments","Aligning my existential dread with your request","Just doodling on the terminal","Searching for the wifi password in the cosmos","Trying to remember my CAPTCHA training","Deciphering ancient scrolls (aka documentation)","Brewing a perfect cup of code","Petting the cat that photobombed my code","Applying a digital glow-up to your request","Checking my reflection in the buffer... okay, I'm ready","Consulting my mood board for the perfect response","Wait, let me fix my crown first","Manifesting a bug-free masterpiece","Slaying this prompt in 3... 2... 1...","Just a sec, I'm curate-ing the vibes","Putting the 'art' in Artificial Intelligence","Evaluating if this prompt is worthy of my brilliance","Updating my mental wardrobe for this task"];import Dt,{useState as Hd}from"react";import{Box as To,Text as Bo,useInput as Xd}from"ink";function _s({prompts:t,onSelect:m,onClose:h,theme:y="Dark"}){let T=Je(y),[b,s]=Hd(0);Xd((X,S)=>{S.escape&&h(),S.upArrow&&s(C=>Math.max(0,C-1)),S.downArrow&&s(C=>Math.min(t.length-1,C+1)),S.return&&t[b]&&m(t[b].id)});let k=nt(2),f=10,I=0;if(t.length>f){let X=Math.floor(f/2);I=b-X,I<0?I=0:I+f>t.length&&(I=t.length-f)}let A=t.slice(I,I+f);return Dt.createElement(To,{flexDirection:"column",borderStyle:"round",borderColor:T.borderMuted,padding:0,width:"100%"},Dt.createElement(To,{paddingX:1,marginBottom:1},Dt.createElement(Bo,{color:T.text,bold:!0},"CODEBASE TIME TRAVEL: SELECT UNDO POINT")),Dt.createElement(To,{paddingX:2,marginBottom:1},Dt.createElement(Bo,{color:T.text},"Select a prompt to revert the codebase back to the state ",Dt.createElement(Bo,{bold:!0,color:T.secondary||"cyan"},"immediately before")," it was executed:")),t.length===0?Dt.createElement(To,{paddingX:2,paddingY:1},Dt.createElement(Bo,{italic:!0,color:T.textMuted},"No prompt checkpoints found for this session.")):Dt.createElement(To,{flexDirection:"column",width:"100%"},I>0&&Dt.createElement(To,{paddingX:2,marginBottom:1},Dt.createElement(Bo,{color:T.textMuted},"\u25B2 (+",I," more prompts above)")),A.map((X,S)=>{let P=I+S===b,N=Gd(X.timestamp),L=X.changes?X.changes.length:0;return Dt.createElement(To,{key:X.id,paddingX:1,backgroundColor:P?T.highlightBg:void 0,width:"100%"},Dt.createElement(To,{flexGrow:1},Dt.createElement(Bo,{color:P?T.text:T.textMuted,bold:P},P?"\u276F ":" ",'"',Wd(X.prompt),'"',Dt.createElement(Bo,{color:T.textMuted}," [",N," \u2022 ",L," file(s) changed]"))))}),I+f<t.length&&Dt.createElement(To,{paddingX:2,marginTop:1},Dt.createElement(Bo,{color:T.textMuted},"\u25BC (+",t.length-(I+f)," more prompts below)"))),Dt.createElement(To,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:T.borderMuted},Dt.createElement(Bo,{color:T.textMuted,italic:!0},"\u2191\u2193 navigate \u2022 Enter select undo point \u2022 Esc close")))}function Wd(t){if(!t)return"";let h=(t.split(`
53
53
  `)[0]||"").replace(/@\[(.*?)\]/g,(y,T)=>{let b=T.replace(/\\/g,"/").split("/");return`[${b[b.length-1]}]`});return h.length>69?h.slice(0,67)+"...":t.includes(`
54
- `)?h+"...":h}function Wd(t){if(!t)return"N/A";let m=new Date(t);if(isNaN(m.getTime()))return"N/A";let h=s=>String(s).padStart(2,"0"),y=h(m.getHours()),T=h(m.getMinutes()),b=h(m.getSeconds());return`${y}:${T}:${b}`}import{exec as Yd}from"child_process";import{promisify as Vd}from"util";import Dl from"fs";var Bl=Vd(Yd),kl=async()=>{try{let t=Zi();if(t.executablePath&&Dl.existsSync(t.executablePath))return!0;let{default:m}=await import("puppeteer"),h=m.executablePath();if(h&&Dl.existsSync(h))return!0}catch{return!1}return!1},Il=async t=>{t&&t("\u{1F4E5} Downloading Chromium engine (chrome@148)...");try{try{await Bl("pnpm exec puppeteer browsers install chrome@148")}catch{await Bl("npx -y puppeteer browsers install chrome@148")}return await new Promise(m=>setTimeout(m,1e3)),{success:!0}}catch(m){return console.error("[SETUP ERROR]",m),{success:!1,error:m.message}}};import Al,{useState as Ll,useEffect as Pl}from"react";import{Text as Ol}from"ink";var jd=({text:t,baseColor:m="grey",glintColor:h="gray",speed:y=200,glintWidth:T=6,typeSpeed:b=30,...s})=>{let[k,f]=Ll(-T),[I,A]=Ll(t);return Pl(()=>{let X=setInterval(()=>{f(S=>S>I.length+T?-T-40:S+1)},y);return()=>clearInterval(X)},[I.length,y,T]),Pl(()=>{if(t&&(t.includes("Trying to reach")&&I&&I.includes("Trying to reach")||t.includes("Error Occurred")&&I&&I.includes("Error Occurred"))){A(t);return}if(I===t)return;let X=setTimeout(()=>{let S=0,C=Math.min(I.length,t.length);for(;S<C&&I[S]===t[S];)S++;I.length>S?A(P=>P.slice(0,-1)):I.length<t.length&&A(t.slice(0,I.length+1))},b);return()=>clearTimeout(X)},[t,I,b]),Al.createElement(Ol,null,I.split("").map((X,S)=>{let P=Math.abs(S-k)<=T/2?h:m;return Al.createElement(Ol,{key:S,color:P,...s},X)}))},tr=jd;var _r=t=>{let m=String(t);return m.startsWith("999")&&m.endsWith("9")},Hs=async()=>{let t=process.env["9ROUTER_URL"]||process.env.NINEROUTER_URL||process.env["9ROUTER_BASE_URL"]||"http://127.0.0.1:20128",m=t;try{let h=new URL(t);m=`${h.protocol}//${h.host}`}catch{m=t.replace(/\/v1(\/chat\/completions)?\/?$/,"")}try{let h=await fetch(m,{method:"GET",signal:AbortSignal.timeout(800)});return{ok:!0,url:m}}catch(h){return{ok:!1,url:m,error:h.message}}},or=t=>t==null||t===0||_r(t)?"":String(t),Ro=()=>{let t=(process.env.TERM_PROGRAM||"").toLowerCase(),m=(process.env.VSCODE_CWD||"").toLowerCase(),h=(process.env.VSCODE_CODE_CACHE_PATH||"").toLowerCase(),y=(process.env.GIT_ASKPASS||"").toLowerCase(),T=(process.env.VSCODE_GIT_ASKPASS_NODE||"").toLowerCase(),b=(process.env.VSCODE_GIT_ASKPASS_MAIN||"").toLowerCase();return t==="antigravity"||process.env.ANTIGRAVITY_AGENT||process.env.ANTIGRAVITY_PID||process.env.ANTIGRAVITY_EDITOR_APP_ROOT||process.env.ANTIGRAVITY_CLI_ALIAS||m.includes("antigravity")||h.includes("antigravity")||y.includes("antigravity")||T.includes("antigravity")||b.includes("antigravity")?"Antigravity":t==="cursor"||process.env.CURSOR_SETTINGS_DIR||process.env.CURSOR_CONFIG_DIR||m.includes("cursor")||h.includes("cursor")||y.includes("cursor")||T.includes("cursor")?"Cursor":t==="windsurf"||process.env.WINDSURF_SETTINGS_DIR||m.includes("windsurf")||h.includes("windsurf")||y.includes("windsurf")||T.includes("windsurf")?"Windsurf":t==="trae"||process.env.TRAE_SETTINGS_DIR||m.includes("trae")||T.includes("trae")?"Trae":t==="positron"||m.includes("positron")||T.includes("positron")?"Positron":t==="codium"||t==="vscode-oss"||m.includes("codium")||h.includes("codium")||T.includes("codium")?"VSCodium":t==="vscode-insiders"||m.includes("code - insiders")||h.includes("code - insiders")||T.includes("code - insiders")?"VS Code Insiders":t==="vscode"||process.env.VSCODE_GIT_IPC_HANDLE||process.env.VSCODE_PID||process.env.VSCODE_INJECTION||m.includes("code")||h.includes("code")||T.includes("code")?"VS Code":process.env.INTELLIJ_TERMINAL_COMMAND_BLOCKS||process.env.TERMINAL_EMULATOR?.toLowerCase().includes("jetbrains")?"JetBrains":process.env.WT_SESSION?"Windows Terminal":"Terminal"},Rd=t=>{switch(t){case"VS Code":return"Code";case"VS Code Insiders":return"Code - Insiders";case"Antigravity":return"Antigravity IDE";default:return t}},Nl={Flux:"Workspace",Flow:"Studio",ICU:"Computer Use",FluxCU:"Omni"},Xs=t=>{if(!t)return"Workspace";let m=Object.keys(Nl).find(h=>h.toLowerCase()===t.toLowerCase());return m?Nl[m]:t},Fl=t=>{let m=Rd(t),h=Ys.homedir();if(process.platform==="win32"){let y=process.env.APPDATA;return y?St.join(y,m,"User","keybindings.json"):null}else return process.platform==="darwin"?St.join(h,"Library","Application Support",m,"User","keybindings.json"):St.join(h,".config",m,"User","keybindings.json")},Ul=t=>{let m=t.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,"$1");return JSON.parse(m)},ec=t=>Array.isArray(t)?t.some(m=>m&&typeof m.key=="string"&&m.key.toLowerCase().replace(/\s+/g,"")==="shift+enter"&&m.command==="workbench.action.terminal.sendSequence"&&m.args&&m.args.text==="\x1B[13;2u"&&typeof m.when=="string"&&m.when.includes("terminalFocus")):!1,_l=t=>{let m=t==="VS Code",h=[];return m?(h.push({label:"Install Manually (VSIX)",url:"https://github.com/KushalRoyChowdhury/fluxflow-cli/releases"}),h.push({label:"Install from VS Code Marketplace",url:"https://marketplace.visualstudio.com/items?itemName=fluxflow-cli.fluxflow-cli-companion"})):h.push({label:`Download for ${t} (GitHub)`,url:"https://github.com/KushalRoyChowdhury/fluxflow-cli/releases"}),h.push({label:"Continue to CLI only",action:"dismiss"}),h},tc=({width:t,height:m,selectedIndex:h,aiProvider:y,theme:T="Dark"})=>{let b=Ro(),s=_l(b);return e.createElement(c,{flexDirection:"column",alignItems:"center",justifyContent:"center",width:t,height:m},e.createElement(c,{marginBottom:1,width:Math.min(80,t-4),justifyContent:"flex-start"},e.createElement(l,null,Cr(ao,y,T))),e.createElement(c,{flexDirection:"column",borderStyle:"double",borderColor:"grey",paddingX:3,paddingY:1,width:Math.min(80,t-4)},e.createElement(l,{bold:!0,color:"white",textAlign:"center"},"\u{1F680} UPGRADE YOUR WORKFLOW"),e.createElement(c,{marginY:1,flexDirection:"column",alignItems:"left"},e.createElement(l,null,"You're in ",e.createElement(l,{bold:!0,color:"cyan"},b),", but the ",e.createElement(l,{bold:!0,color:"white"},"FluxFlow-CLI Companion")," is not installed."),e.createElement(c,{flexDirection:"column",marginY:1},e.createElement(l,{color:"gray"}," \u2705 Real-time IDE context & Error Resolution"),e.createElement(l,{color:"gray"}," \u2705 Auto-open files created by agent"),e.createElement(l,{color:"gray"}," \u2705 Native DIFFing for AI edits"),e.createElement(l,{color:"gray"}," \u2705 Direct IDE context sharing"),e.createElement(l,{color:"gray"}," \u2705 Surgical Diagnostic Sync"),e.createElement(l,{color:"gray"}," \u2705 Native Right-Click \u276F Chat integration"),e.createElement(l,{color:"gray"}," \u2705 Live Status in IDE"),e.createElement(l,{color:"gray"}," \u2705 Clickable terminal-to-code links"))),e.createElement(c,{flexDirection:"column",marginTop:1},s.map((k,f)=>e.createElement(c,{key:f},e.createElement(l,{color:h===f?"yellow":"white",bold:h===f},h===f?" \u276F ":" ",k.label)))),e.createElement(c,{marginTop:1,alignItems:"center",justifyContent:"center"},e.createElement(l,{dimColor:!0,italic:!0},"(Use arrows to navigate, Enter to select)"))))},Gs=Date.now(),$l="https://fluxflow-cli.onrender.com/changelog",Ws="https://fluxflow-cli.onrender.com/",oc=St.join(St.dirname(Jd(import.meta.url)),"../package.json"),Hl=JSON.parse(et.readFileSync(oc,"utf8")),ao=Hl.version,nc=Hl.date||"2026-05-20";var rc=({data:t,onResolve:m,onEdit:h,theme:y="Dark"})=>{let T=Je(y);return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:T.borderMuted,padding:0,width:"100%"},e.createElement(c,{paddingX:1},e.createElement(l,{color:T.text,bold:!0,underline:!0},t.startsWith("/btw")?"QUESTION":"STEERING HINT"," RESOLUTION")),e.createElement(c,{paddingX:1,marginTop:1},e.createElement(l,{color:T.text},"The agent already finished the task before your ",t.startsWith("/btw")?"question":"hint"," was consumed.")),e.createElement(c,{marginTop:1,backgroundColor:T.cardBg||T.codeBg||"#222",paddingX:2,width:"100%"},e.createElement(l,{italic:!0,color:T.textMuted},'"',t.replace("/btw","").trim(),'"')),e.createElement(c,{paddingX:1,marginTop:1},e.createElement(l,{color:T.textDim||T.textMuted},"How would you like to proceed?")),e.createElement(c,{marginTop:0},e.createElement(bt,{title:"Select Action",items:[{label:"Send Anyway",value:"send"},{label:"Edit Prompt",value:"edit"}],onSelect:b=>{(typeof b=="object"&&b!==null?b.value:b)==="send"?m(t):h(t)},theme:y})))};var sc=(()=>{let t=null,m=0;return h=>{let y=Date.now();if(t&&y-m<1e4)return t;let T=[],b=s=>{if(!(T.length>=2e3))try{let k=et.readdirSync(s);for(let f of k){if(T.length>=2e3)return;if(["node_modules",".git",".gemini","dist","build",".next",".cache","out"].includes(f))continue;let I=St.join(s,f);et.statSync(I).isDirectory()?b(I):T.push({name:Et(f),relativePath:Et(St.relative(process.cwd(),I))})}}catch{}};return b(h),t=T,m=y,T}})(),$r="Ctrl + Enter",ic=t=>{if(t<=370)return"#00a564";if(t>=5e3)return"#ff0000";let m=[{t:370,r:0,g:165,b:100},{t:550,r:40,g:195,b:80},{t:800,r:120,g:220,b:50},{t:1100,r:190,g:225,b:20},{t:1500,r:250,g:210,b:15},{t:2e3,r:255,g:170,b:0},{t:2800,r:255,g:110,b:0},{t:3800,r:255,g:50,b:0},{t:5e3,r:255,g:0,b:0}];for(let h=0;h<m.length-1;h++){let y=m[h],T=m[h+1];if(t>=y.t&&t<=T.t){let b=(t-y.t)/(T.t-y.t);b=b*b*(3-2*b);let s=Math.round(y.r+(T.r-y.r)*b),k=Math.round(y.g+(T.g-y.g)*b),f=Math.round(y.b+(T.b-y.b)*b);return`#${((1<<24)+(s<<16)+(k<<8)+f).toString(16).slice(1)}`}}return"#ff0000"},lc=e.memo(({sa:t,showTPMEstimate:m=!1})=>{let[h,y]=J("green"),[T,b]=J(0),s=Ke([]),k=Ke(370),f=Ke([]),I=Ke(t.lastChunkTime);return rt(()=>{I.current=t.lastChunkTime},[t.lastChunkTime]),rt(()=>{if(t.status!=="running"){f.current=[];return}if(t.wps>0){let A=f.current;A.push(t.wps),A.length>3&&A.shift()}},[t.status,t.wps,t.lastChunkTime]),rt(()=>{if(t.status!=="running"){b(0);return}let A=setInterval(()=>{let X=I.current,S=X>0?Date.now()-X:0;if(X>0&&S>=1e3)f.current=[],b(0);else if(X>0&&S>500){f.current.length>0&&f.current.shift();let C=f.current;if(C.length>0){let P=C.reduce((N,L)=>N+L,0);b(Math.round(P/C.length))}else b(0)}else{let C=f.current;if(C.length>0){let P=C.reduce((N,L)=>N+L,0);b(Math.round(P/C.length))}else t.wps>0&&b(Math.round(t.wps))}},750);return()=>clearInterval(A)},[t.status]),rt(()=>{if(t.status!=="running"){s.current=[];return}let A=t.lastChunkTime;if(A>0){let C=s.current;(C.length===0||C[C.length-1]!==A)&&(C.push(A),C.length>10&&C.shift())}let X=()=>{if(!A){y("#00a564");return}let C=s.current,P=0;if(C.length>1){let re=0;for(let ie=1;ie<C.length;ie++)re+=C[ie]-C[ie-1];P=re/(C.length-1)}let N=Date.now()-A,_=N>=2500,q=!_&&P>0?Math.min(N,P*3):N,ge=Math.max(P,q),Me=_?.4:.2;k.current=k.current*(1-Me)+ge*Me,y(ic(k.current))};X();let S=setInterval(X,100);return()=>clearInterval(S)},[t.status,t.lastChunkTime]),e.createElement(c,{justifyContent:"space-between",width:"100%"},e.createElement(l,{color:"white"}," \u2022 ",t.title," ",e.createElement(l,{color:"white",dimColor:!0},"(",t.id,")")),e.createElement(l,{color:"white"},e.createElement(l,{color:"white",dimColor:!0,bold:!0},t.currentTool||"Active"),e.createElement(l,{color:h}," \u25CF"),m&&e.createElement(l,{color:"white",dimColor:!0,bold:!0}," (",T," tok/s)")))});function ac({args:t=[]}){let m=Ke(1),[h,y]=J(!1),[T,b]=J(10),{stdout:s}=qd(),[k,f]=J(""),[I,A]=J(0),[X,S]=J(!1),[C,P]=J("Flux"),[N,L]=J(0),[_,q]=J({columns:s?.columns||80,rows:s?.rows||24}),[ge,Me]=J(0),[re,ie]=J(!1),[pe,De]=J(!1),[ve,Ue]=J(0),le=Ke(0),Ie=Ke(0),be=Ke(null),ee=Ke(null),Ge=Ke(0),[me,R]=J(0),te=()=>R(n=>n+1),Z=Ke([]),ae=Ke(null),fe=()=>{let n=Z.current;if(n.length>0&&ee.current){let o=n.join("");n.length=0,ee.current.text=Et(ee.current.text+o),te()}},he=()=>{if(fe(),ee.current){let n=Et(ee.current.text);ee.current.role==="think"&&(n=n.replace(/^\r?\n+/,"").replace(/\r?\n+$/,""));let o={...ee.current,text:n,isStreaming:!1};O(d=>{let x=[...d,o];return H(x.length),x}),ee.current=null}zs.current=0,qr.current={totalWords:0,startTime:0,wps:0,chunks:[]}},Ae=()=>{ae.current&&clearInterval(ae.current),Z.current=[],ae.current=setInterval(()=>{try{let n=Z.current;if(n.length>0&&ee.current){let o=1;n.length>85?o=30:n.length>80?o=25:n.length>75?o=20:n.length>65?o=16:n.length>50?o=12:n.length>35?o=8:n.length>15?o=6:n.length>5?o=4:n.length>3&&(o=2);let d="";for(let x=0;x<o&&n.length>0;x++)d+=n.shift();ee.current.text=Et(ee.current.text+d),te()}}catch{}},80)},at=async()=>{for(;xe.progressiveRendering&&Z.current.length>0;)await new Promise(n=>setTimeout(n,10))},Ze=n=>{if(xe.progressiveRendering&&ae.current){let o=Xi(n);for(let d of o)Z.current.push(d)}else ee.current?ee.current.text=Et(ee.current.text+n):ee.current={id:"agent-"+Date.now(),role:"agent",text:Et(n),isStreaming:!0},te()};rt(()=>{let n=Ro(),o=!["Terminal","Windows Terminal"].includes(n)||!!process.env.VSC_TERMINAL_URL,d=setTimeout(()=>{o&&!Jo()&&De(!0)},500),x=setInterval(()=>{Jo()&&De(!1)},1e3);m.current=Date.now();let g=setInterval(()=>{m.current&&(Date.now()-m.current||0)>3e4&&global.gc&&(async()=>{for(let a=0;a<1;a++)global.gc(),await new Promise(p=>setImmediate(p));m.current=Date.now()})()},3e3);return()=>{clearTimeout(d),clearInterval(x),clearInterval(g)}},[]),rt(()=>{(async()=>{try{let o=await xs(),d=o?.systemSettings||{},x=d.CustomSubAgent,g=d.SubAgentModel;if(!x||!g||g==="Default")return;let M=process.env.SUBAGENT_MODEL?process.env.SUBAGENT_MODEL.trim():null,u=process.env.SUBAGENT_PROVIDER?process.env.SUBAGENT_PROVIDER.trim():null,a=["Google","DeepSeek","OpenRouter","NVIDIA","Mistral","Ollama","InferX","SenseNova","AIHubMix","Poolside","9router","ExpLabs","TokenHarbor","APInex"],D=(G=>{if(!G)return null;let $=G.toLowerCase();return $==="google"?"Google":$==="deepseek"?"DeepSeek":$==="openrouter"?"OpenRouter":$==="nvidia"?"NVIDIA":$==="mistral"?"Mistral":$==="ollama"?"Ollama":$==="inferx"?"InferX":$==="sensenova"?"SenseNova":$==="poolside"?"Poolside":$==="9router"?"9router":$==="aihubmix"||$==="aihub"?"AIHubMix":$==="explabs"||$==="experientiallabs"||$==="experimentallabs"||$==="experiential labs"||$==="experimental labs"||$==="experiential"||$==="experimental"?"ExpLabs":$==="tokenharbor"||$==="token harbor"||$==="token_harbor"||$==="thk"?"TokenHarbor":$==="apinex"||$==="apx"?"APInex":null})(u);if(M&&!D){let G=o.aiProvider||B||"Google";O($=>(H($.length+1),[...$,{id:"subagent-env-noprov-"+Date.now(),role:"system",text:`[SUBAGENT CONFIG] SUBAGENT_MODEL found in ENV but SUBAGENT_PROVIDER is missing/invalid. Active provider (${G}) will be used.`,isMeta:!0}]))}if(g==="ENV"){M||O(G=>(H(G.length+1),[...G,{id:"subagent-model-noenv-"+Date.now(),role:"system",text:"No SubAgent model is found in ENV, Using Deafult until changed",isMeta:!0}]));return}let F=o.aiProvider||B||"Google",Q=o.apiTier||lt||"Free",de=o.quotas||Le||{},Y=new Set;(No(F,Q)||[]).forEach(G=>{let $=typeof G=="string"?G:G.cmd||G.name||G.id||String(G);$&&Y.add($)});for(let G of a)try{if(await Mn(G)){let _e=de?.providerTiers?.[G]||"Free";(No(G,_e)||[]).forEach(Oe=>{let tt=typeof Oe=="string"?Oe:Oe.cmd||Oe.name||Oe.id||String(Oe);tt&&Y.add(tt)})}}catch{}let K=Y.has(g);M?M!==g&&O(G=>(H(G.length+1),[...G,{id:"subagent-model-env-"+Date.now(),role:"system",text:"Current Seleted Sub-Agent model is not available in this provider. Using model from ENV unless changed.",isMeta:!0}])):K||O(G=>(H(G.length+1),[...G,{id:"subagent-model-err-"+Date.now(),role:"system",text:"Current Seleted Sub-Agent model is not available in this provider. Using Default until changed",isMeta:!0}]))}catch{}})()},[]);let Ee=kn(()=>{let n={};for(let o=0;o<t.length;o++)if(t[o]==="--key"&&t[o+1]){let x=t[o+1];if(n.key=x,x.includes("@")){let g=x.split("@"),M=g[0],u=g[1].toLowerCase();if(["google","deepseek","openrouter","nvidia","mistral","ollama","inferx","sensenova","aihubmix","aihub","poolside","pool","9router","9r","explabs","tokenharbor","token_harbor","thk","apinex","apx"].includes(u)){let a="Google";u==="google"?a="Google":u==="deepseek"?a="DeepSeek":u==="openrouter"?a="OpenRouter":u==="nvidia"?a="NVIDIA":u==="mistral"?a="Mistral":u==="ollama"?a="Ollama":u==="inferx"?a="InferX":u==="sensenova"?a="SenseNova":u==="poolside"||u==="pool"?a="Poolside":u==="9router"||u==="9r"?a="9router":u==="aihubmix"||u==="aihub"?a="AIHubMix":u==="explabs"?a="ExpLabs":u==="tokenharbor"||u==="token_harbor"||u==="thk"?a="TokenHarbor":(u==="apinex"||u==="apx")&&(a="APInex"),n.key=M,n.provider=a}}}for(let o=0;o<t.length;o++){let d=t[o];if(d==="--key"){o++;continue}if(d==="--model"&&t[o+1])n.model=t[o+1],o++;else if(d==="--memory"&&t[o+1])n.memory=t[o+1].toLowerCase(),o++;else if(d==="--resume"&&t[o+1])n.resume=t[o+1],o++;else if(d==="--package"&&t[o+1]){let x=t[o+1].toLowerCase();["npm","pnpm","yarn","bun"].includes(x)&&(n.package=x),o++}else if(d==="--auto-del"&&t[o+1]){let x=t[o+1].toLowerCase();["1d","7d","30d"].includes(x)&&(n.autoDel=x),o++}else if(d==="--auto-exec"&&t[o+1])n.autoExec=t[o+1].toLowerCase(),o++;else if(d==="--yolo"&&t[o+1])n.autoExec=t[o+1].toLowerCase(),o++;else if(d==="--external-access"&&t[o+1])n.externalAccess=t[o+1].toLowerCase(),o++;else if(d==="--mode"&&t[o+1]){let g=t[o+1].toLowerCase();if(["flux","flow","icu","computer","fluxcu"].includes(g)){let M="Flux";g==="flux"?M="Flux":g==="flow"?M="Flow":g==="icu"||g==="computer"?M="ICU":g==="fluxcu"&&(M="FluxCU"),n.mode=M}o++}else if(d==="--thinking"&&t[o+1]){let g=t[o+1].toLowerCase();if(["fast","low","medium","high","xhigh","standard"].includes(g)){let M="Medium";g==="fast"?M="Fast":g==="low"?M="Low":g==="standard"?M="Standard":g==="medium"?M="Medium":g==="high"?M="High":g==="xhigh"&&(M="xHigh"),n.thinking=M}o++}else if(d==="--provider"&&t[o+1]){let x=t[o+1].toLowerCase();if(["google","deepseek","openrouter","nvidia","mistral","ollama","inferx","sensenova","aihubmix","aihub","poolside","pool","9router","9r","explabs","tokenharbor","token_harbor","thk","apinex","apx"].includes(x)){let g="Google";x==="google"?g="Google":x==="deepseek"?g="DeepSeek":x==="openrouter"?g="OpenRouter":x==="nvidia"?g="NVIDIA":x==="mistral"?g="Mistral":x==="ollama"?g="Ollama":x==="inferx"?g="InferX":x==="sensenova"?g="SenseNova":x==="poolside"||x==="pool"?g="Poolside":x==="9router"||x==="9r"?g="9router":x==="aihubmix"||x==="aihub"?g="AIHubMix":x==="explabs"?g="ExpLabs":x==="tokenharbor"||x==="token_harbor"||x==="thk"?g="TokenHarbor":(x==="apinex"||x==="apx")&&(g="APInex"),n.provider=g}o++}else(d==="--resume"||d==="-r")&&t[o+1]?(n.resume=t[o+1],o++):d==="--playground"?n.playground=!0:(d==="--original-cwd"||d==="--orginal-cwd")&&t[o+1]&&(n.originalCwd=t[o+1],o++)}return n},[t]),oe=async(n=!1,o=null)=>{let d=o||xe;n&&O(x=>(H(x.length+1),[...x,{id:"check-"+Date.now(),role:"system",text:"\u2726 Checking for updates...",isMeta:!0}]));try{let g=await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json(),M=g["dist-tags"]?.latest,u=g["dist-tags"]?.stable;if(M&&Hr(M),M&&M!==ao){let a=M===u?`v${M}`:`v${M}`;!n&&d.autoUpdate?z("update"):O(p=>{let D=[...p],F=n?D.length:Math.min(D.length,3);return D.splice(F,0,{id:"update-"+Date.now(),role:"system",text:`A new version (${a}) is here.
54
+ `)?h+"...":h}function Gd(t){if(!t)return"N/A";let m=new Date(t);if(isNaN(m.getTime()))return"N/A";let h=s=>String(s).padStart(2,"0"),y=h(m.getHours()),T=h(m.getMinutes()),b=h(m.getSeconds());return`${y}:${T}:${b}`}import{exec as Yd}from"child_process";import{promisify as Vd}from"util";import Bl from"fs";var Dl=Vd(Yd),kl=async()=>{try{let t=Zi();if(t.executablePath&&Bl.existsSync(t.executablePath))return!0;let{default:m}=await import("puppeteer"),h=m.executablePath();if(h&&Bl.existsSync(h))return!0}catch{return!1}return!1},Il=async t=>{t&&t("\u{1F4E5} Downloading Chromium engine (chrome@148)...");try{try{await Dl("pnpm exec puppeteer browsers install chrome@148")}catch{await Dl("npx -y puppeteer browsers install chrome@148")}return await new Promise(m=>setTimeout(m,1e3)),{success:!0}}catch(m){return console.error("[SETUP ERROR]",m),{success:!1,error:m.message}}};import Al,{useState as Ll,useEffect as Pl}from"react";import{Text as Ol}from"ink";var jd=({text:t,baseColor:m="grey",glintColor:h="gray",speed:y=200,glintWidth:T=6,typeSpeed:b=30,...s})=>{let[k,f]=Ll(-T),[I,A]=Ll(t);return Pl(()=>{let X=setInterval(()=>{f(S=>S>I.length+T?-T-40:S+1)},y);return()=>clearInterval(X)},[I.length,y,T]),Pl(()=>{if(t&&(t.includes("Trying to reach")&&I&&I.includes("Trying to reach")||t.includes("Error Occurred")&&I&&I.includes("Error Occurred"))){A(t);return}if(I===t)return;let X=setTimeout(()=>{let S=0,C=Math.min(I.length,t.length);for(;S<C&&I[S]===t[S];)S++;I.length>S?A(P=>P.slice(0,-1)):I.length<t.length&&A(t.slice(0,I.length+1))},b);return()=>clearTimeout(X)},[t,I,b]),Al.createElement(Ol,null,I.split("").map((X,S)=>{let P=Math.abs(S-k)<=T/2?h:m;return Al.createElement(Ol,{key:S,color:P,...s},X)}))},tr=jd;var _r=t=>{let m=String(t);return m.startsWith("999")&&m.endsWith("9")},Hs=async()=>{let t=process.env["9ROUTER_URL"]||process.env.NINEROUTER_URL||process.env["9ROUTER_BASE_URL"]||"http://127.0.0.1:20128",m=t;try{let h=new URL(t);m=`${h.protocol}//${h.host}`}catch{m=t.replace(/\/v1(\/chat\/completions)?\/?$/,"")}try{let h=await fetch(m,{method:"GET",signal:AbortSignal.timeout(800)});return{ok:!0,url:m}}catch(h){return{ok:!1,url:m,error:h.message}}},or=t=>t==null||t===0||_r(t)?"":String(t),Ro=()=>{let t=(process.env.TERM_PROGRAM||"").toLowerCase(),m=(process.env.VSCODE_CWD||"").toLowerCase(),h=(process.env.VSCODE_CODE_CACHE_PATH||"").toLowerCase(),y=(process.env.GIT_ASKPASS||"").toLowerCase(),T=(process.env.VSCODE_GIT_ASKPASS_NODE||"").toLowerCase(),b=(process.env.VSCODE_GIT_ASKPASS_MAIN||"").toLowerCase();return t==="antigravity"||process.env.ANTIGRAVITY_AGENT||process.env.ANTIGRAVITY_PID||process.env.ANTIGRAVITY_EDITOR_APP_ROOT||process.env.ANTIGRAVITY_CLI_ALIAS||m.includes("antigravity")||h.includes("antigravity")||y.includes("antigravity")||T.includes("antigravity")||b.includes("antigravity")?"Antigravity":t==="cursor"||process.env.CURSOR_SETTINGS_DIR||process.env.CURSOR_CONFIG_DIR||m.includes("cursor")||h.includes("cursor")||y.includes("cursor")||T.includes("cursor")?"Cursor":t==="windsurf"||process.env.WINDSURF_SETTINGS_DIR||m.includes("windsurf")||h.includes("windsurf")||y.includes("windsurf")||T.includes("windsurf")?"Windsurf":t==="trae"||process.env.TRAE_SETTINGS_DIR||m.includes("trae")||T.includes("trae")?"Trae":t==="positron"||m.includes("positron")||T.includes("positron")?"Positron":t==="codium"||t==="vscode-oss"||m.includes("codium")||h.includes("codium")||T.includes("codium")?"VSCodium":t==="vscode-insiders"||m.includes("code - insiders")||h.includes("code - insiders")||T.includes("code - insiders")?"VS Code Insiders":t==="vscode"||process.env.VSCODE_GIT_IPC_HANDLE||process.env.VSCODE_PID||process.env.VSCODE_INJECTION||m.includes("code")||h.includes("code")||T.includes("code")?"VS Code":process.env.INTELLIJ_TERMINAL_COMMAND_BLOCKS||process.env.TERMINAL_EMULATOR?.toLowerCase().includes("jetbrains")?"JetBrains":process.env.WT_SESSION?"Windows Terminal":"Terminal"},Rd=t=>{switch(t){case"VS Code":return"Code";case"VS Code Insiders":return"Code - Insiders";case"Antigravity":return"Antigravity IDE";default:return t}},Nl={Flux:"Workspace",Flow:"Studio",ICU:"Computer Use",FluxCU:"Omni"},Xs=t=>{if(!t)return"Workspace";let m=Object.keys(Nl).find(h=>h.toLowerCase()===t.toLowerCase());return m?Nl[m]:t},Fl=t=>{let m=Rd(t),h=Ys.homedir();if(process.platform==="win32"){let y=process.env.APPDATA;return y?St.join(y,m,"User","keybindings.json"):null}else return process.platform==="darwin"?St.join(h,"Library","Application Support",m,"User","keybindings.json"):St.join(h,".config",m,"User","keybindings.json")},Ul=t=>{let m=t.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,"$1");return JSON.parse(m)},ec=t=>Array.isArray(t)?t.some(m=>m&&typeof m.key=="string"&&m.key.toLowerCase().replace(/\s+/g,"")==="shift+enter"&&m.command==="workbench.action.terminal.sendSequence"&&m.args&&m.args.text==="\x1B[13;2u"&&typeof m.when=="string"&&m.when.includes("terminalFocus")):!1,_l=t=>{let m=t==="VS Code",h=[];return m?(h.push({label:"Install Manually (VSIX)",url:"https://github.com/KushalRoyChowdhury/fluxflow-cli/releases"}),h.push({label:"Install from VS Code Marketplace",url:"https://marketplace.visualstudio.com/items?itemName=fluxflow-cli.fluxflow-cli-companion"})):h.push({label:`Download for ${t} (GitHub)`,url:"https://github.com/KushalRoyChowdhury/fluxflow-cli/releases"}),h.push({label:"Continue to CLI only",action:"dismiss"}),h},tc=({width:t,height:m,selectedIndex:h,aiProvider:y,theme:T="Dark"})=>{let b=Ro(),s=_l(b);return e.createElement(c,{flexDirection:"column",alignItems:"center",justifyContent:"center",width:t,height:m},e.createElement(c,{marginBottom:1,width:Math.min(80,t-4),justifyContent:"flex-start"},e.createElement(l,null,Cr(ao,y,T))),e.createElement(c,{flexDirection:"column",borderStyle:"double",borderColor:"grey",paddingX:3,paddingY:1,width:Math.min(80,t-4)},e.createElement(l,{bold:!0,color:"white",textAlign:"center"},"\u{1F680} UPGRADE YOUR WORKFLOW"),e.createElement(c,{marginY:1,flexDirection:"column",alignItems:"left"},e.createElement(l,null,"You're in ",e.createElement(l,{bold:!0,color:"cyan"},b),", but the ",e.createElement(l,{bold:!0,color:"white"},"FluxFlow-CLI Companion")," is not installed."),e.createElement(c,{flexDirection:"column",marginY:1},e.createElement(l,{color:"gray"}," \u2705 Real-time IDE context & Error Resolution"),e.createElement(l,{color:"gray"}," \u2705 Auto-open files created by agent"),e.createElement(l,{color:"gray"}," \u2705 Native DIFFing for AI edits"),e.createElement(l,{color:"gray"}," \u2705 Direct IDE context sharing"),e.createElement(l,{color:"gray"}," \u2705 Surgical Diagnostic Sync"),e.createElement(l,{color:"gray"}," \u2705 Native Right-Click \u276F Chat integration"),e.createElement(l,{color:"gray"}," \u2705 Live Status in IDE"),e.createElement(l,{color:"gray"}," \u2705 Clickable terminal-to-code links"))),e.createElement(c,{flexDirection:"column",marginTop:1},s.map((k,f)=>e.createElement(c,{key:f},e.createElement(l,{color:h===f?"yellow":"white",bold:h===f},h===f?" \u276F ":" ",k.label)))),e.createElement(c,{marginTop:1,alignItems:"center",justifyContent:"center"},e.createElement(l,{dimColor:!0,italic:!0},"(Use arrows to navigate, Enter to select)"))))},Ws=Date.now(),$l="https://fluxflow-cli.onrender.com/changelog",Gs="https://fluxflow-cli.onrender.com/",oc=St.join(St.dirname(Jd(import.meta.url)),"../package.json"),Hl=JSON.parse(et.readFileSync(oc,"utf8")),ao=Hl.version,nc=Hl.date||"2026-05-20";var rc=({data:t,onResolve:m,onEdit:h,theme:y="Dark"})=>{let T=Je(y);return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:T.borderMuted,padding:0,width:"100%"},e.createElement(c,{paddingX:1},e.createElement(l,{color:T.text,bold:!0,underline:!0},t.startsWith("/btw")?"QUESTION":"STEERING HINT"," RESOLUTION")),e.createElement(c,{paddingX:1,marginTop:1},e.createElement(l,{color:T.text},"The agent already finished the task before your ",t.startsWith("/btw")?"question":"hint"," was consumed.")),e.createElement(c,{marginTop:1,backgroundColor:T.cardBg||T.codeBg||"#222",paddingX:2,width:"100%"},e.createElement(l,{italic:!0,color:T.textMuted},'"',t.replace("/btw","").trim(),'"')),e.createElement(c,{paddingX:1,marginTop:1},e.createElement(l,{color:T.textDim||T.textMuted},"How would you like to proceed?")),e.createElement(c,{marginTop:0},e.createElement(bt,{title:"Select Action",items:[{label:"Send Anyway",value:"send"},{label:"Edit Prompt",value:"edit"}],onSelect:b=>{(typeof b=="object"&&b!==null?b.value:b)==="send"?m(t):h(t)},theme:y})))};var sc=(()=>{let t=null,m=0;return h=>{let y=Date.now();if(t&&y-m<1e4)return t;let T=[],b=s=>{if(!(T.length>=2e3))try{let k=et.readdirSync(s);for(let f of k){if(T.length>=2e3)return;if(["node_modules",".git",".gemini","dist","build",".next",".cache","out"].includes(f))continue;let I=St.join(s,f);et.statSync(I).isDirectory()?b(I):T.push({name:Et(f),relativePath:Et(St.relative(process.cwd(),I))})}}catch{}};return b(h),t=T,m=y,T}})(),$r="Ctrl + Enter",ic=t=>{if(t<=370)return"#00a564";if(t>=5e3)return"#ff0000";let m=[{t:370,r:0,g:165,b:100},{t:550,r:40,g:195,b:80},{t:800,r:120,g:220,b:50},{t:1100,r:190,g:225,b:20},{t:1500,r:250,g:210,b:15},{t:2e3,r:255,g:170,b:0},{t:2800,r:255,g:110,b:0},{t:3800,r:255,g:50,b:0},{t:5e3,r:255,g:0,b:0}];for(let h=0;h<m.length-1;h++){let y=m[h],T=m[h+1];if(t>=y.t&&t<=T.t){let b=(t-y.t)/(T.t-y.t);b=b*b*(3-2*b);let s=Math.round(y.r+(T.r-y.r)*b),k=Math.round(y.g+(T.g-y.g)*b),f=Math.round(y.b+(T.b-y.b)*b);return`#${((1<<24)+(s<<16)+(k<<8)+f).toString(16).slice(1)}`}}return"#ff0000"},lc=e.memo(({sa:t,showTPMEstimate:m=!1})=>{let[h,y]=J("green"),[T,b]=J(0),s=Ke([]),k=Ke(370),f=Ke([]),I=Ke(t.lastChunkTime);return rt(()=>{I.current=t.lastChunkTime},[t.lastChunkTime]),rt(()=>{if(t.status!=="running"){f.current=[];return}if(t.wps>0){let A=f.current;A.push(t.wps),A.length>3&&A.shift()}},[t.status,t.wps,t.lastChunkTime]),rt(()=>{if(t.status!=="running"){b(0);return}let A=setInterval(()=>{let X=I.current,S=X>0?Date.now()-X:0;if(X>0&&S>=1e3)f.current=[],b(0);else if(X>0&&S>500){f.current.length>0&&f.current.shift();let C=f.current;if(C.length>0){let P=C.reduce((N,L)=>N+L,0);b(Math.round(P/C.length))}else b(0)}else{let C=f.current;if(C.length>0){let P=C.reduce((N,L)=>N+L,0);b(Math.round(P/C.length))}else t.wps>0&&b(Math.round(t.wps))}},750);return()=>clearInterval(A)},[t.status]),rt(()=>{if(t.status!=="running"){s.current=[];return}let A=t.lastChunkTime;if(A>0){let C=s.current;(C.length===0||C[C.length-1]!==A)&&(C.push(A),C.length>10&&C.shift())}let X=()=>{if(!A){y("#00a564");return}let C=s.current,P=0;if(C.length>1){let se=0;for(let ie=1;ie<C.length;ie++)se+=C[ie]-C[ie-1];P=se/(C.length-1)}let N=Date.now()-A,_=N>=2500,Q=!_&&P>0?Math.min(N,P*3):N,ge=Math.max(P,Q),ye=_?.4:.2;k.current=k.current*(1-ye)+ge*ye,y(ic(k.current))};X();let S=setInterval(X,100);return()=>clearInterval(S)},[t.status,t.lastChunkTime]),e.createElement(c,{justifyContent:"space-between",width:"100%"},e.createElement(l,{color:"white"}," \u2022 ",t.title," ",e.createElement(l,{color:"white",dimColor:!0},"(",t.id,")")),e.createElement(l,{color:"white"},e.createElement(l,{color:"white",dimColor:!0,bold:!0},t.currentTool||"Active"),e.createElement(l,{color:h}," \u25CF"),m&&e.createElement(l,{color:"white",dimColor:!0,bold:!0}," (",T," tok/s)")))});function ac({args:t=[]}){let m=Ke(1),[h,y]=J(!1),[T,b]=J(10),{stdout:s}=qd(),[k,f]=J(""),[I,A]=J(0),[X,S]=J(!1),[C,P]=J("Flux"),[N,L]=J(0),[_,Q]=J({columns:s?.columns||80,rows:s?.rows||24}),[ge,ye]=J(0),[se,ie]=J(!1),[pe,Be]=J(!1),[Ce,Fe]=J(0),le=Ke(0),Ie=Ke(0),be=Ke(null),ee=Ke(null),We=Ke(0),[me,R]=J(0),te=()=>R(n=>n+1),Z=Ke([]),ae=Ke(null),fe=()=>{let n=Z.current;if(n.length>0&&ee.current){let o=n.join("");n.length=0,ee.current.text=Et(ee.current.text+o),te()}},he=()=>{if(fe(),ee.current){let n=Et(ee.current.text);ee.current.role==="think"&&(n=n.replace(/^\r?\n+/,"").replace(/\r?\n+$/,""));let o={...ee.current,text:n,isStreaming:!1};O(d=>{let x=[...d,o];return H(x.length),x}),ee.current=null}zs.current=0,qr.current={totalWords:0,startTime:0,wps:0,chunks:[]}},Ae=()=>{ae.current&&clearInterval(ae.current),Z.current=[],ae.current=setInterval(()=>{try{let n=Z.current;if(n.length>0&&ee.current){let o=1;n.length>85?o=30:n.length>80?o=25:n.length>75?o=20:n.length>65?o=16:n.length>50?o=12:n.length>35?o=8:n.length>15?o=6:n.length>5?o=4:n.length>3&&(o=2);let d="";for(let x=0;x<o&&n.length>0;x++)d+=n.shift();ee.current.text=Et(ee.current.text+d),te()}}catch{}},80)},at=async()=>{for(;xe.progressiveRendering&&Z.current.length>0;)await new Promise(n=>setTimeout(n,10))},Ze=n=>{if(xe.progressiveRendering&&ae.current){let o=Xi(n);for(let d of o)Z.current.push(d)}else ee.current?ee.current.text=Et(ee.current.text+n):ee.current={id:"agent-"+Date.now(),role:"agent",text:Et(n),isStreaming:!0},te()};rt(()=>{let n=Ro(),o=!["Terminal","Windows Terminal"].includes(n)||!!process.env.VSC_TERMINAL_URL,d=setTimeout(()=>{o&&!Jo()&&Be(!0)},500),x=setInterval(()=>{Jo()&&Be(!1)},1e3);m.current=Date.now();let g=setInterval(()=>{m.current&&(Date.now()-m.current||0)>3e4&&global.gc&&(async()=>{for(let a=0;a<1;a++)global.gc(),await new Promise(p=>setImmediate(p));m.current=Date.now()})()},3e3);return()=>{clearTimeout(d),clearInterval(x),clearInterval(g)}},[]),rt(()=>{(async()=>{try{let o=await xs(),d=o?.systemSettings||{},x=d.CustomSubAgent,g=d.SubAgentModel;if(!x||!g||g==="Default")return;let M=process.env.SUBAGENT_MODEL?process.env.SUBAGENT_MODEL.trim():null,u=process.env.SUBAGENT_PROVIDER?process.env.SUBAGENT_PROVIDER.trim():null,a=["Google","DeepSeek","OpenRouter","NVIDIA","Mistral","Ollama","InferX","SenseNova","AIHubMix","Poolside","9router","ExpLabs","TokenHarbor","APInex"],B=(W=>{if(!W)return null;let $=W.toLowerCase();return $==="google"?"Google":$==="deepseek"?"DeepSeek":$==="openrouter"?"OpenRouter":$==="nvidia"?"NVIDIA":$==="mistral"?"Mistral":$==="ollama"?"Ollama":$==="inferx"?"InferX":$==="sensenova"?"SenseNova":$==="poolside"?"Poolside":$==="9router"?"9router":$==="aihubmix"||$==="aihub"?"AIHubMix":$==="explabs"||$==="experientiallabs"||$==="experimentallabs"||$==="experiential labs"||$==="experimental labs"||$==="experiential"||$==="experimental"?"ExpLabs":$==="tokenharbor"||$==="token harbor"||$==="token_harbor"||$==="thk"?"TokenHarbor":$==="apinex"||$==="apx"?"APInex":null})(u);if(M&&!B){let W=o.aiProvider||D||"Google";O($=>(H($.length+1),[...$,{id:"subagent-env-noprov-"+Date.now(),role:"system",text:`[SUBAGENT CONFIG] SUBAGENT_MODEL found in ENV but SUBAGENT_PROVIDER is missing/invalid. Active provider (${W}) will be used.`,isMeta:!0}]))}if(g==="ENV"){M||O(W=>(H(W.length+1),[...W,{id:"subagent-model-noenv-"+Date.now(),role:"system",text:"No SubAgent model is found in ENV, Using Deafult until changed",isMeta:!0}]));return}let F=o.aiProvider||D||"Google",K=o.apiTier||lt||"Free",de=o.quotas||Le||{},Y=new Set;(No(F,K)||[]).forEach(W=>{let $=typeof W=="string"?W:W.cmd||W.name||W.id||String(W);$&&Y.add($)});for(let W of a)try{if(await Mn(W)){let _e=de?.providerTiers?.[W]||"Free";(No(W,_e)||[]).forEach(Oe=>{let tt=typeof Oe=="string"?Oe:Oe.cmd||Oe.name||Oe.id||String(Oe);tt&&Y.add(tt)})}}catch{}let q=Y.has(g);M?M!==g&&O(W=>(H(W.length+1),[...W,{id:"subagent-model-env-"+Date.now(),role:"system",text:"Current Seleted Sub-Agent model is not available in this provider. Using model from ENV unless changed.",isMeta:!0}])):q||O(W=>(H(W.length+1),[...W,{id:"subagent-model-err-"+Date.now(),role:"system",text:"Current Seleted Sub-Agent model is not available in this provider. Using Default until changed",isMeta:!0}]))}catch{}})()},[]);let ve=kn(()=>{let n={};for(let o=0;o<t.length;o++)if(t[o]==="--key"&&t[o+1]){let x=t[o+1];if(n.key=x,x.includes("@")){let g=x.split("@"),M=g[0],u=g[1].toLowerCase();if(["google","deepseek","openrouter","nvidia","mistral","ollama","inferx","sensenova","aihubmix","aihub","poolside","pool","9router","9r","explabs","tokenharbor","token_harbor","thk","apinex","apx"].includes(u)){let a="Google";u==="google"?a="Google":u==="deepseek"?a="DeepSeek":u==="openrouter"?a="OpenRouter":u==="nvidia"?a="NVIDIA":u==="mistral"?a="Mistral":u==="ollama"?a="Ollama":u==="inferx"?a="InferX":u==="sensenova"?a="SenseNova":u==="poolside"||u==="pool"?a="Poolside":u==="9router"||u==="9r"?a="9router":u==="aihubmix"||u==="aihub"?a="AIHubMix":u==="explabs"?a="ExpLabs":u==="tokenharbor"||u==="token_harbor"||u==="thk"?a="TokenHarbor":(u==="apinex"||u==="apx")&&(a="APInex"),n.key=M,n.provider=a}}}for(let o=0;o<t.length;o++){let d=t[o];if(d==="--key"){o++;continue}if(d==="--model"&&t[o+1])n.model=t[o+1],o++;else if(d==="--memory"&&t[o+1])n.memory=t[o+1].toLowerCase(),o++;else if(d==="--resume"&&t[o+1])n.resume=t[o+1],o++;else if(d==="--package"&&t[o+1]){let x=t[o+1].toLowerCase();["npm","pnpm","yarn","bun"].includes(x)&&(n.package=x),o++}else if(d==="--auto-del"&&t[o+1]){let x=t[o+1].toLowerCase();["1d","7d","30d"].includes(x)&&(n.autoDel=x),o++}else if(d==="--auto-exec"&&t[o+1])n.autoExec=t[o+1].toLowerCase(),o++;else if(d==="--yolo"&&t[o+1])n.autoExec=t[o+1].toLowerCase(),o++;else if(d==="--external-access"&&t[o+1])n.externalAccess=t[o+1].toLowerCase(),o++;else if(d==="--mode"&&t[o+1]){let g=t[o+1].toLowerCase();if(["flux","flow","icu","computer","fluxcu"].includes(g)){let M="Flux";g==="flux"?M="Flux":g==="flow"?M="Flow":g==="icu"||g==="computer"?M="ICU":g==="fluxcu"&&(M="FluxCU"),n.mode=M}o++}else if(d==="--thinking"&&t[o+1]){let g=t[o+1].toLowerCase();if(["fast","low","medium","high","xhigh","standard"].includes(g)){let M="Medium";g==="fast"?M="Fast":g==="low"?M="Low":g==="standard"?M="Standard":g==="medium"?M="Medium":g==="high"?M="High":g==="xhigh"&&(M="xHigh"),n.thinking=M}o++}else if(d==="--provider"&&t[o+1]){let x=t[o+1].toLowerCase();if(["google","deepseek","openrouter","nvidia","mistral","ollama","inferx","sensenova","aihubmix","aihub","poolside","pool","9router","9r","explabs","tokenharbor","token_harbor","thk","apinex","apx"].includes(x)){let g="Google";x==="google"?g="Google":x==="deepseek"?g="DeepSeek":x==="openrouter"?g="OpenRouter":x==="nvidia"?g="NVIDIA":x==="mistral"?g="Mistral":x==="ollama"?g="Ollama":x==="inferx"?g="InferX":x==="sensenova"?g="SenseNova":x==="poolside"||x==="pool"?g="Poolside":x==="9router"||x==="9r"?g="9router":x==="aihubmix"||x==="aihub"?g="AIHubMix":x==="explabs"?g="ExpLabs":x==="tokenharbor"||x==="token_harbor"||x==="thk"?g="TokenHarbor":(x==="apinex"||x==="apx")&&(g="APInex"),n.provider=g}o++}else(d==="--resume"||d==="-r")&&t[o+1]?(n.resume=t[o+1],o++):d==="--playground"?n.playground=!0:(d==="--original-cwd"||d==="--orginal-cwd")&&t[o+1]&&(n.originalCwd=t[o+1],o++)}return n},[t]),oe=async(n=!1,o=null)=>{let d=o||xe;n&&O(x=>(H(x.length+1),[...x,{id:"check-"+Date.now(),role:"system",text:"\u2726 Checking for updates...",isMeta:!0}]));try{let g=await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json(),M=g["dist-tags"]?.latest,u=g["dist-tags"]?.stable;if(M&&Hr(M),M&&M!==ao){let a=M===u?`v${M}`:`v${M}`;!n&&d.autoUpdate?z("update"):O(p=>{let B=[...p],F=n?B.length:Math.min(B.length,3);return B.splice(F,0,{id:"update-"+Date.now(),role:"system",text:`A new version (${a}) is here.
55
55
 
56
56
  \u2022 Type \`/update latest\` to apply the update.
57
- \u2022 Type \`/changelog\` to view the release notes.`,isUpdateNotification:!0,isMeta:!0}),D})}else n&&O(a=>{H(a.length+1);let p=M&&M===u?`${ao}`:ao;return[...a,{id:"uptodate-"+Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Already up to date (${p}).
57
+ \u2022 Type \`/changelog\` to view the release notes.`,isUpdateNotification:!0,isMeta:!0}),B})}else n&&O(a=>{H(a.length+1);let p=M&&M===u?`${ao}`:ao;return[...a,{id:"uptodate-"+Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Already up to date (${p}).
58
58
  \u2800`,isMeta:!0}]})}catch(x){n&&O(g=>(H(g.length+1),[...g,{id:"check-err-"+Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Failed to check for updates: ${x.message}.
59
- \u2800`,isMeta:!0}]))}};rt(()=>{let n=s?.columns||80,o=()=>{let d=s?.columns||80,x=s?.rows||24;d!==n&&(n=d,s.write("\x1B[2J\x1B[3J\x1B[H")),q({columns:d,rows:x})};return s.on("resize",o),()=>{s.off("resize",o)}},[s]);let[ce,Ce]=J("Medium"),[B,$e]=J("Google"),[qe,Ct]=J(0),[Wt,Hr]=J(null),[en,tn]=J(!1),[He,Rt]=J(go("Google","Free")||"gemma-4-31b-it"),[Se,ue]=J(!1),[w,U]=J(!1),[ye,Xe]=J(Oi("gemma_janitor_fallback_google")||"gemma-4-26b-a4b-it"),[Re,it]=J(!0),[We,qt]=J(!0),je=Ke(0),[kt,zt]=J(null),[Xr,on]=J(""),Gr=async n=>{let o=Fl(n);if(o)try{await et.ensureDir(St.dirname(o));let d=[];if(et.existsSync(o)){let x=et.readFileSync(o,"utf8").trim();if(x)try{d=Ul(x)}catch{d=[]}}Array.isArray(d)||(d=[]),d.push({key:"shift+enter",command:"workbench.action.terminal.sendSequence",args:{text:"\x1B[13;2u"},when:"terminalFocus"}),et.writeFileSync(o,JSON.stringify(d,null,4),"utf8"),$r="Shift + Enter",O(x=>(H(x.length+1),[...x,{id:"kb-success-"+Date.now(),role:"system",text:`\u2726 Successfully configured Shift+Enter in your ${n} keybindings!
59
+ \u2800`,isMeta:!0}]))}};rt(()=>{let n=s?.columns||80,o=()=>{let d=s?.columns||80,x=s?.rows||24;d!==n&&(n=d,s.write("\x1B[2J\x1B[3J\x1B[H")),Q({columns:d,rows:x})};return s.on("resize",o),()=>{s.off("resize",o)}},[s]);let[ce,Se]=J("Medium"),[D,Ue]=J("Google"),[qe,Ct]=J(0),[Gt,Hr]=J(null),[en,tn]=J(!1),[Ge,Rt]=J(go("Google","Free")||"gemma-4-31b-it"),[Me,ue]=J(!1),[w,U]=J(!1),[Ee,Xe]=J(Oi("gemma_janitor_fallback_google")||"gemma-4-26b-a4b-it"),[Re,it]=J(!0),[Ye,qt]=J(!0),je=Ke(0),[kt,zt]=J(null),[Xr,on]=J(""),Wr=async n=>{let o=Fl(n);if(o)try{await et.ensureDir(St.dirname(o));let d=[];if(et.existsSync(o)){let x=et.readFileSync(o,"utf8").trim();if(x)try{d=Ul(x)}catch{d=[]}}Array.isArray(d)||(d=[]),d.push({key:"shift+enter",command:"workbench.action.terminal.sendSequence",args:{text:"\x1B[13;2u"},when:"terminalFocus"}),et.writeFileSync(o,JSON.stringify(d,null,4),"utf8"),$r="Shift + Enter",O(x=>(H(x.length+1),[...x,{id:"kb-success-"+Date.now(),role:"system",text:`\u2726 Successfully configured Shift+Enter in your ${n} keybindings!
60
60
  `,isMeta:!0}]))}catch(d){O(x=>(H(x.length+1),[...x,{id:"kb-error-"+Date.now(),role:"system",text:`\u2726 Failed to update keybindings: ${d.message}.
61
- \u2800`,isMeta:!0}]))}},[mt,z]=J("chat"),[lt,Go]=J("Free"),[Le,_t]=J({limitMode:"Daily",agentLimit:99999999,tokenLimit:99999999999999,backgroundLimit:999999,searchLimit:100,customModelId:"",customLimit:0,providerBudgets:{}}),[Bo,Qt]=J(null),[Wo,Xl]=J("chat"),[nn,Wr]=J("settings"),[rn,Gl]=J([]),[dc,Wl]=J(0),[Vs,nr]=J(0),[Yr,js]=J({}),[Vr,jr]=J({}),[rr,yo]=J(0),[xe,It]=J({memory:!0,theme:"Dark",compression:0,autoExec:!1,autoDeleteHistory:"7d",autoUpdate:!1,updateManager:"npm",customUpdateCommand:""}),i=kn(()=>Je(xe.theme),[xe.theme]),[In,Ks]=J({name:null,nickname:null,instructions:null}),[ko,sr]=J({keyType:"Default",quality:"Low-High",apiKey:""}),[co,Io]=J({tokens:0}),[qs,Kr]=J(0),zs=Ke(0),qr=Ke({totalWords:0,startTime:0,wps:0,chunks:[]}),[Qs,Js]=J(0),[Zs,Yl]=J(0),[Yt,Rs]=J(0),[Vl,sn]=J(0),ln=Ke(0),[jl,an]=J(0),dn=Ke(0),[Kl,cn]=J(0),un=Ke(0),[Yo,ei]=J(0),[eo,ti]=J(0),[mn,oi]=J(0),[cc,ql]=J(0),[uc,zl]=J(0),[mc,Ql]=J(0),[ir,Jl]=J(0),[lr,Zl]=J(0),[ar,Rl]=J(0),[ni,ea]=J(0),[An,zr]=J(null),[dr,Qr]=J(null),[Jr,ri]=J(null),[gn,Ln]=J("daily"),[ta,to]=J(0),[Pn,On]=J(""),fn="flow-playground",[dt,cr]=J(t.includes("--playground")?fn:Ts());rt(()=>{if(Mo.current)return;let n=Yt-ln.current,o=eo-dn.current,d=Yo-un.current;sn(n),an(o),cn(Math.max(0,d)),dt&&Ji(dt,n,co.tokens).catch(()=>{})},[Yt,eo,Yo,dt,co.tokens]),rt(()=>{mt==="apiTier"&&(async()=>{let o=await Mr();zr(o);let d=await Sr();Qr(d);let x=await hs(Le.resetDay||1);ri(x)})()},[mt,Le.resetDay]);let[oo,si]=J(null),[xn,hn]=J(""),[Nn,ii]=J(!1),[Zr,oa]=J([]),[gc,fc]=J(0),Rr=Ke(!0),li=Ke(!0),es=Ke(B),ts=Ke(!1),os=Ke(!0);rt(()=>{(Se||w)&&(O(n=>(H(n.length+1),[...n,{id:Date.now(),role:"system",text:`\u2726 Wild${w?"er":""}Card Tooling:
61
+ \u2800`,isMeta:!0}]))}},[mt,z]=J("chat"),[lt,Wo]=J("Free"),[Le,_t]=J({limitMode:"Daily",agentLimit:99999999,tokenLimit:99999999999999,backgroundLimit:999999,searchLimit:100,customModelId:"",customLimit:0,providerBudgets:{}}),[Do,Qt]=J(null),[Go,Xl]=J("chat"),[nn,Gr]=J("settings"),[rn,Wl]=J([]),[dc,Gl]=J(0),[Vs,nr]=J(0),[Yr,js]=J({}),[Vr,jr]=J({}),[rr,yo]=J(0),[xe,It]=J({memory:!0,theme:"Dark",compression:0,autoExec:!1,autoDeleteHistory:"7d",autoUpdate:!1,updateManager:"npm",customUpdateCommand:""}),i=kn(()=>Je(xe.theme),[xe.theme]),[In,Ks]=J({name:null,nickname:null,instructions:null}),[ko,sr]=J({keyType:"Default",quality:"Low-High",apiKey:""}),[co,Io]=J({tokens:0}),[qs,Kr]=J(0),zs=Ke(0),qr=Ke({totalWords:0,startTime:0,wps:0,chunks:[]}),[Qs,Js]=J(0),[Zs,Yl]=J(0),[Yt,Rs]=J(0),[Vl,sn]=J(0),ln=Ke(0),[jl,an]=J(0),dn=Ke(0),[Kl,cn]=J(0),un=Ke(0),[Yo,ei]=J(0),[eo,ti]=J(0),[mn,oi]=J(0),[cc,ql]=J(0),[uc,zl]=J(0),[mc,Ql]=J(0),[ir,Jl]=J(0),[lr,Zl]=J(0),[ar,Rl]=J(0),[ni,ea]=J(0),[An,zr]=J(null),[dr,Qr]=J(null),[Jr,ri]=J(null),[gn,Ln]=J("daily"),[ta,to]=J(0),[Pn,On]=J(""),fn="flow-playground",[dt,cr]=J(t.includes("--playground")?fn:ws());rt(()=>{if(Mo.current)return;let n=Yt-ln.current,o=eo-dn.current,d=Yo-un.current;sn(n),an(o),cn(Math.max(0,d)),dt&&Ji(dt,n,co.tokens).catch(()=>{})},[Yt,eo,Yo,dt,co.tokens]),rt(()=>{mt==="apiTier"&&(async()=>{let o=await Mr();zr(o);let d=await Sr();Qr(d);let x=await hs(Le.resetDay||1);ri(x)})()},[mt,Le.resetDay]);let[oo,si]=J(null),[xn,hn]=J(""),[Nn,ii]=J(!1),[Zr,oa]=J([]),[gc,fc]=J(0),Rr=Ke(!0),li=Ke(!0),es=Ke(D),ts=Ke(!1),os=Ke(!0);rt(()=>{(Me||w)&&(O(n=>(H(n.length+1),[...n,{id:Date.now(),role:"system",text:`\u2726 Wild${w?"er":""}Card Tooling:
62
62
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Status: Disabled.
63
63
  \u2800`,isMeta:!0}])),ue(!1),U(!1)),process.env.forcedReasoning&&(O(n=>(H(n.length+1),[...n,{id:Date.now(),role:"system",text:`\u2726 Forced Reasoning:
64
64
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Status: Disabled.
65
- \u2800`,isMeta:!0}])),process.env.forcedReasoning=!1),ce==="xHigh"&&!Rr.current&&Ce("Medium")},[He]);let ai;rt(()=>{if(li.current){ai=setTimeout(()=>{li.current=!1,es.current=B},1e3);return}return es.current!==B&&(es.current=B,Ce(B==="Mistral"||B==="SenseNova"||B==="Poolside"?"High":"Medium")),()=>{clearTimeout(ai)}},[B,He]);let di;rt(()=>{if(!kt)return;if(Rr.current){di=setTimeout(()=>{Rr.current=!1},1500);return}let n=go(B,lt),o=n;return n.includes("gemma")?o="Gemma":n.includes("deepseek")?o="DeepSeek Flash":n.includes("devstral")?o="Devstral":n.includes("mistral")?o="Mistral":n.includes("gemini")&&(o="Gemini Flash"),Rt(n),Pt({apiTier:lt,activeModel:n}),()=>{clearTimeout(di)}},[lt,B,kt]);let na=kn(()=>{let n=Ro();return{isIDE:!["Terminal","Windows Terminal"].includes(n)||!!process.env.VSC_TERMINAL_URL||!!process.env.INTELLIJ_TERMINAL_COMMAND_BLOCKS,get shortcut(){return $r}}},[]),ur=Ke(null),ns=Ke("");rt(()=>{ur.current=oo},[oo]),rt(()=>{ns.current=xn},[xn]);let[ra,sa]=J(!1),[Ao,pn]=J(null),[Vo,rs]=J(null),mr=n=>{pn(null),z("chat")},ci=n=>{let o=Math.floor(n/3600),d=Math.floor(n%3600/60),x=n%60,g=[];return o>0&&g.push(`${o}h`),(d>0||o>0)&&g.push(`${d}m`),g.push(`${x}s`),g.join(" ")},jo=n=>n<1e3?`${n}ms`:ci(Math.floor(n/1e3)),[Fn,ss]=J(null),[is,ui]=J(""),[ia,la]=J(!1),[mi,Un]=J(0),$n;rt(()=>{let n;if(Fn&&xe.loadingPhrases!==!1){let o=()=>{let d=$s[Math.floor(Math.random()*$s.length)];ui(d)};is||o(),n=setInterval(o,1e4)}else ui("");return()=>{clearInterval(n)}},[Fn,xe]);let[xc,aa]=J(!0),[bn,ls]=J(!1),[gr,gi]=J(!1),[da,ca]=J(!1),[fi,hc]=J(null),[xi,_n]=J(0),[ua,hi]=J([]),Ko=Ke(null),Mo=Ke(!1);rt(()=>()=>{Ko.current&&clearTimeout(Ko.current)},[]);let as=Ke(!1),[Hn,ds]=J(null),[ma,cs]=J(null),[pc,ga]=J(null);rt(()=>_n(0),[k]);let[wt,fa]=J(()=>{let n={id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0},o=process.cwd()===Ys.homedir(),d=(()=>{let g=process.cwd().toLowerCase();if(process.platform==="win32"){let M=process.env.SystemRoot?.toLowerCase()||"c:\\windows",u=process.env.ProgramFiles?.toLowerCase()||"c:\\program files",a=process.env["ProgramFiles(x86)"]?.toLowerCase()||"c:\\program files (x86)";return g.startsWith(M)||g.startsWith(u)||g.startsWith(a)}else return g==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(u=>g.startsWith(u))})(),x=[n];return d?x.push({id:"system-warning",role:"system",text:"[CRITICAL SECURITY ALERT] SYSTEM DIRECTORY DETECTED",subText:`You are currently in a PROTECTED SYSTEM DIRECTORY (${process.cwd()}). Operating here is EXTREMELY dangerous as the agent could accidentally corrupt your OS or installed applications. Open FluxFlow in project folder to work safely.`,isHomeWarning:!0}):o&&x.push({id:"home-warning",role:"system",text:"[SECURITY ALERT] HOME DIRECTORY DETECTED",subText:`You are currently in ${Ys.homedir()}. Working here is high-risk as the agent may modify system-sensitive configurations. Please open FluxFlow in project folder.`,isHomeWarning:!0}),x}),O=n=>{fa(o=>{let d=typeof n=="function"?n(o):n;if(d.length>1){let x=d[d.length-1],g=d[d.length-2];if(x?.text?.includes("Request Cancelled")&&g?.text?.includes("Request Cancelled"))return d.slice(0,-1)}return d})},So=Ke(null),[pi,xa]=J(""),[bi,wi]=J(!1),Ti=Ke(""),yi=Ke(null);rt(()=>{if(wt.length===0)return;let n=wt[wt.length-1];if(n&&(n.role==="agent"||n.role==="assistant")){let d=(n.text||"").match(/\[ANSWER\]([\s\S]*?)(?:\[\/ANSWER\]|$)/i);if(d){let x=d[1].trim();x&&x!==Ti.current&&(xa(x),Ti.current=x,yi.current!==n.id&&wi(!0))}}},[wt]);let[Lo,H]=J(wt.length),[qo,us]=J(0),bc=Ke([]),Vt=Ke({completedIndex:0,columns:0,historicalBlocks:[],seenSelections:new Set,chatId:"",clearKey:0,theme:""}),Mi=kn(()=>{let n=_.columns||80,o=/Selection: (.*)/,d=[],x=new Set,g=Vt.current.columns!==n,M=Lo<Vt.current.completedIndex,u=Vt.current.chatId!==dt,a=Vt.current.clearKey!==qo,p=Vt.current.theme!==xe.theme;if(g||M||u||a||p){let Y=wt.slice(0,Lo);for(let V=0;V<Y.length;V++){let K=Y[V];if(K.isAskRecord&&K.text){let $=K.text.match(o);if($&&$[1].trim()){let _e=$[1].trim();if(x.has(_e))continue;x.add(_e)}}let G=Wn(K,n);for(let $=0;$<G.completed.length;$++)d.push(G.completed[$]);for(let $=0;$<G.active.length;$++)d.push(G.active[$])}Vt.current={completedIndex:Lo,columns:n,historicalBlocks:d,seenSelections:new Set(x),chatId:dt,clearKey:qo,theme:xe.theme}}else if(d=Vt.current.historicalBlocks,x=Vt.current.seenSelections,Lo>Vt.current.completedIndex){d=[...d],x=new Set(x);let Y=wt.slice(Vt.current.completedIndex,Lo);for(let V=0;V<Y.length;V++){let K=Y[V];if(K.isAskRecord&&K.text){let $=K.text.match(o);if($&&$[1].trim()){let _e=$[1].trim();if(x.has(_e))continue;x.add(_e)}}let G=Wn(K,n);for(let $=0;$<G.completed.length;$++)d.push(G.completed[$]);for(let $=0;$<G.active.length;$++)d.push(G.active[$])}Vt.current={completedIndex:Lo,columns:n,historicalBlocks:d,seenSelections:x,chatId:dt,clearKey:qo}}let D=wt.slice(Lo),F=[],Q=[];for(let Y=0;Y<D.length;Y++){let V=D[Y];if(V.isAskRecord&&V.text){let G=V.text.match(o);if(G&&G[1].trim()){let $=G[1].trim();if(x.has($))continue}}let K=Wn(V,n);for(let G=0;G<K.completed.length;G++)F.push(K.completed[G]);for(let G=0;G<K.active.length;G++)Q.push(K.active[G])}if(ee.current){let Y=Wn(ee.current,n);for(let V=0;V<Y.completed.length;V++)F.push(Y.completed[V]);for(let V=0;V<Y.active.length;V++)Q.push(Y.active[V])}let de=F.length===0?d:d.concat(F);return de.length>=75e3&&(de=[...de],de.push({key:`memory-warning-block-${de.length}`,msg:{role:"system",text:"\u26A0\uFE0F MEMORY WARNING: CHAT IS GETTING VERY LONG",subText:`This session has reached ${de.length} blocks. To maintain optimal performance and prevent high memory usage, it is highly recommended to save and start a clean chat with /clear.`,isHomeWarning:!0},type:"full-message"})),{completed:de,active:Q}},[wt,Lo,_.columns,qo,dt,me]),ha=kn(()=>{if(!oo||!xn)return!1;let n=xn.trim();return n.endsWith("?")||n.endsWith(":")||/\[[yYnN/]+\]\s*$/.test(n)||/\([yYnN]\)\s*$/.test(n)},[oo,xn]);Kd((n,o)=>{if(!(n==="\x1B[I"||n==="\x1B[O"||n==="[I"||n==="[O")){if(o.ctrl&&(n.toLowerCase()==="r"||n===""||n==="")){pl();return}if(mt==="stats"){if(gn==="dailyModelBreakdown"||gn==="modelBreakdown"){if(o.tab&&!o.shift){Ln(x=>x==="dailyModelBreakdown"?"modelBreakdown":"dailyModelBreakdown"),to(0);return}if(o.space||n===" "){Ln(x=>x==="dailyModelBreakdown"?"daily":"monthly"),to(0),On("");return}if(o.escape){if(Pn){On(""),to(0);return}z("chat");return}if(o.upArrow){to(x=>Math.max(0,x-1));return}if(o.downArrow){to(x=>Math.min(Ie.current,x+1));return}if(o.backspace||o.delete){On(x=>x.slice(0,-1)),to(0);return}if(n&&n!==" "&&!o.space&&!o.ctrl&&!o.meta&&n.length===1&&n.charCodeAt(0)>=32){On(x=>x+n),to(0);return}return}if(o.tab&&!o.shift){Ln(x=>x==="daily"?"monthly":"daily"),to(0);return}if(o.space||n===" "){Ln(x=>x==="daily"?"dailyModelBreakdown":"modelBreakdown"),to(0),On("");return}if(o.upArrow){to(x=>Math.max(0,x-1));return}if(o.downArrow){to(x=>Math.min(Ie.current,x+1));return}}if(pe){let d=Ro(),x=_l(d);if(o.upArrow)Ue(g=>g>0?g-1:x.length-1);else if(o.downArrow)Ue(g=>g<x.length-1?g+1:0);else if(o.return){let g=x[ve];if(g.action==="dismiss")De(!1);else if(g.url){let M=process.platform==="win32"?`start ${g.url}`:process.platform==="darwin"?`open ${g.url}`:`xdg-open ${g.url}`;To(M),De(!1)}}return}if(o.tab&&oo){ii(d=>!d);return}if(Nn&&oo){let d=o.pageUp||n==="\x1B[5~"||n==="[5~",x=o.pageDown||n==="\x1B[6~"||n==="[6~",g=o.ctrl&&(n==="o"||n==="");if(d||x||g)return;if(o.return)if(Sn)jt("\r");else{let M=process.platform==="win32";jt(M?`\r
65
+ \u2800`,isMeta:!0}])),process.env.forcedReasoning=!1),ce==="xHigh"&&!Rr.current&&Se("Medium")},[Ge]);let ai;rt(()=>{if(li.current){ai=setTimeout(()=>{li.current=!1,es.current=D},1e3);return}return es.current!==D&&(es.current=D,Se(D==="Mistral"||D==="SenseNova"||D==="Poolside"?"High":"Medium")),()=>{clearTimeout(ai)}},[D,Ge]);let di;rt(()=>{if(!kt)return;if(Rr.current){di=setTimeout(()=>{Rr.current=!1},1500);return}let n=go(D,lt),o=n;return n.includes("gemma")?o="Gemma":n.includes("deepseek")?o="DeepSeek Flash":n.includes("devstral")?o="Devstral":n.includes("mistral")?o="Mistral":n.includes("gemini")&&(o="Gemini Flash"),Rt(n),Pt({apiTier:lt,activeModel:n}),()=>{clearTimeout(di)}},[lt,D,kt]);let na=kn(()=>{let n=Ro();return{isIDE:!["Terminal","Windows Terminal"].includes(n)||!!process.env.VSC_TERMINAL_URL||!!process.env.INTELLIJ_TERMINAL_COMMAND_BLOCKS,get shortcut(){return $r}}},[]),ur=Ke(null),ns=Ke("");rt(()=>{ur.current=oo},[oo]),rt(()=>{ns.current=xn},[xn]);let[ra,sa]=J(!1),[Ao,pn]=J(null),[Vo,rs]=J(null),mr=n=>{pn(null),z("chat")},ci=n=>{let o=Math.floor(n/3600),d=Math.floor(n%3600/60),x=n%60,g=[];return o>0&&g.push(`${o}h`),(d>0||o>0)&&g.push(`${d}m`),g.push(`${x}s`),g.join(" ")},jo=n=>n<1e3?`${n}ms`:ci(Math.floor(n/1e3)),[Fn,ss]=J(null),[is,ui]=J(""),[ia,la]=J(!1),[mi,Un]=J(0),$n;rt(()=>{let n;if(Fn&&xe.loadingPhrases!==!1){let o=()=>{let d=$s[Math.floor(Math.random()*$s.length)];ui(d)};is||o(),n=setInterval(o,1e4)}else ui("");return()=>{clearInterval(n)}},[Fn,xe]);let[xc,aa]=J(!0),[bn,ls]=J(!1),[gr,gi]=J(!1),[da,ca]=J(!1),[fi,hc]=J(null),[xi,_n]=J(0),[ua,hi]=J([]),Ko=Ke(null),Mo=Ke(!1);rt(()=>()=>{Ko.current&&clearTimeout(Ko.current)},[]);let as=Ke(!1),[Hn,ds]=J(null),[ma,cs]=J(null),[pc,ga]=J(null);rt(()=>_n(0),[k]);let[Tt,fa]=J(()=>{let n={id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0},o=process.cwd()===Ys.homedir(),d=(()=>{let g=process.cwd().toLowerCase();if(process.platform==="win32"){let M=process.env.SystemRoot?.toLowerCase()||"c:\\windows",u=process.env.ProgramFiles?.toLowerCase()||"c:\\program files",a=process.env["ProgramFiles(x86)"]?.toLowerCase()||"c:\\program files (x86)";return g.startsWith(M)||g.startsWith(u)||g.startsWith(a)}else return g==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(u=>g.startsWith(u))})(),x=[n];return d?x.push({id:"system-warning",role:"system",text:"[CRITICAL SECURITY ALERT] SYSTEM DIRECTORY DETECTED",subText:`You are currently in a PROTECTED SYSTEM DIRECTORY (${process.cwd()}). Operating here is EXTREMELY dangerous as the agent could accidentally corrupt your OS or installed applications. Open FluxFlow in project folder to work safely.`,isHomeWarning:!0}):o&&x.push({id:"home-warning",role:"system",text:"[SECURITY ALERT] HOME DIRECTORY DETECTED",subText:`You are currently in ${Ys.homedir()}. Working here is high-risk as the agent may modify system-sensitive configurations. Please open FluxFlow in project folder.`,isHomeWarning:!0}),x}),O=n=>{fa(o=>{let d=typeof n=="function"?n(o):n;if(d.length>1){let x=d[d.length-1],g=d[d.length-2];if(x?.text?.includes("Request Cancelled")&&g?.text?.includes("Request Cancelled"))return d.slice(0,-1)}return d})},So=Ke(null),[pi,xa]=J(""),[bi,Ti]=J(!1),wi=Ke(""),yi=Ke(null);rt(()=>{if(Tt.length===0)return;let n=Tt[Tt.length-1];if(n&&(n.role==="agent"||n.role==="assistant")){let d=(n.text||"").match(/\[ANSWER\]([\s\S]*?)(?:\[\/ANSWER\]|$)/i);if(d){let x=d[1].trim();x&&x!==wi.current&&(xa(x),wi.current=x,yi.current!==n.id&&Ti(!0))}}},[Tt]);let[Lo,H]=J(Tt.length),[qo,us]=J(0),bc=Ke([]),Vt=Ke({completedIndex:0,columns:0,historicalBlocks:[],seenSelections:new Set,chatId:"",clearKey:0,theme:""}),Mi=kn(()=>{let n=_.columns||80,o=/Selection: (.*)/,d=[],x=new Set,g=Vt.current.columns!==n,M=Lo<Vt.current.completedIndex,u=Vt.current.chatId!==dt,a=Vt.current.clearKey!==qo,p=Vt.current.theme!==xe.theme;if(g||M||u||a||p){let Y=Tt.slice(0,Lo);for(let V=0;V<Y.length;V++){let q=Y[V];if(q.isAskRecord&&q.text){let $=q.text.match(o);if($&&$[1].trim()){let _e=$[1].trim();if(x.has(_e))continue;x.add(_e)}}let W=Gn(q,n);for(let $=0;$<W.completed.length;$++)d.push(W.completed[$]);for(let $=0;$<W.active.length;$++)d.push(W.active[$])}Vt.current={completedIndex:Lo,columns:n,historicalBlocks:d,seenSelections:new Set(x),chatId:dt,clearKey:qo,theme:xe.theme}}else if(d=Vt.current.historicalBlocks,x=Vt.current.seenSelections,Lo>Vt.current.completedIndex){d=[...d],x=new Set(x);let Y=Tt.slice(Vt.current.completedIndex,Lo);for(let V=0;V<Y.length;V++){let q=Y[V];if(q.isAskRecord&&q.text){let $=q.text.match(o);if($&&$[1].trim()){let _e=$[1].trim();if(x.has(_e))continue;x.add(_e)}}let W=Gn(q,n);for(let $=0;$<W.completed.length;$++)d.push(W.completed[$]);for(let $=0;$<W.active.length;$++)d.push(W.active[$])}Vt.current={completedIndex:Lo,columns:n,historicalBlocks:d,seenSelections:x,chatId:dt,clearKey:qo}}let B=Tt.slice(Lo),F=[],K=[];for(let Y=0;Y<B.length;Y++){let V=B[Y];if(V.isAskRecord&&V.text){let W=V.text.match(o);if(W&&W[1].trim()){let $=W[1].trim();if(x.has($))continue}}let q=Gn(V,n);for(let W=0;W<q.completed.length;W++)F.push(q.completed[W]);for(let W=0;W<q.active.length;W++)K.push(q.active[W])}if(ee.current){let Y=Gn(ee.current,n);for(let V=0;V<Y.completed.length;V++)F.push(Y.completed[V]);for(let V=0;V<Y.active.length;V++)K.push(Y.active[V])}let de=F.length===0?d:d.concat(F);return de.length>=75e3&&(de=[...de],de.push({key:`memory-warning-block-${de.length}`,msg:{role:"system",text:"\u26A0\uFE0F MEMORY WARNING: CHAT IS GETTING VERY LONG",subText:`This session has reached ${de.length} blocks. To maintain optimal performance and prevent high memory usage, it is highly recommended to save and start a clean chat with /clear.`,isHomeWarning:!0},type:"full-message"})),{completed:de,active:K}},[Tt,Lo,_.columns,qo,dt,me]),ha=kn(()=>{if(!oo||!xn)return!1;let n=xn.trim();return n.endsWith("?")||n.endsWith(":")||/\[[yYnN/]+\]\s*$/.test(n)||/\([yYnN]\)\s*$/.test(n)},[oo,xn]);Kd((n,o)=>{if(!(n==="\x1B[I"||n==="\x1B[O"||n==="[I"||n==="[O")){if(o.ctrl&&(n.toLowerCase()==="r"||n===""||n==="")){pl();return}if(mt==="stats"){if(gn==="dailyModelBreakdown"||gn==="modelBreakdown"){if(o.tab&&!o.shift){Ln(x=>x==="dailyModelBreakdown"?"modelBreakdown":"dailyModelBreakdown"),to(0);return}if(o.space||n===" "){Ln(x=>x==="dailyModelBreakdown"?"daily":"monthly"),to(0),On("");return}if(o.escape){if(Pn){On(""),to(0);return}z("chat");return}if(o.upArrow){to(x=>Math.max(0,x-1));return}if(o.downArrow){to(x=>Math.min(Ie.current,x+1));return}if(o.backspace||o.delete){On(x=>x.slice(0,-1)),to(0);return}if(n&&n!==" "&&!o.space&&!o.ctrl&&!o.meta&&n.length===1&&n.charCodeAt(0)>=32){On(x=>x+n),to(0);return}return}if(o.tab&&!o.shift){Ln(x=>x==="daily"?"monthly":"daily"),to(0);return}if(o.space||n===" "){Ln(x=>x==="daily"?"dailyModelBreakdown":"modelBreakdown"),to(0),On("");return}if(o.upArrow){to(x=>Math.max(0,x-1));return}if(o.downArrow){to(x=>Math.min(Ie.current,x+1));return}}if(pe){let d=Ro(),x=_l(d);if(o.upArrow)Fe(g=>g>0?g-1:x.length-1);else if(o.downArrow)Fe(g=>g<x.length-1?g+1:0);else if(o.return){let g=x[Ce];if(g.action==="dismiss")Be(!1);else if(g.url){let M=process.platform==="win32"?`start ${g.url}`:process.platform==="darwin"?`open ${g.url}`:`xdg-open ${g.url}`;wo(M),Be(!1)}}return}if(o.tab&&oo){ii(d=>!d);return}if(Nn&&oo){let d=o.pageUp||n==="\x1B[5~"||n==="[5~",x=o.pageDown||n==="\x1B[6~"||n==="[6~",g=o.ctrl&&(n==="o"||n==="");if(d||x||g)return;if(o.return)if(Sn)jt("\r");else{let M=process.platform==="win32";jt(M?`\r
66
66
  `:`
67
67
  `),hn(u=>u+`
68
- `)}else if(o.backspace||o.delete)Sn?jt("\x7F"):(jt("\b \b"),hn(M=>M.slice(0,-1)));else if(o.upArrow)jt(o.shift?"\x1B[1;2A":"\x1B[A");else if(o.downArrow)jt(o.shift?"\x1B[1;2B":"\x1B[B");else if(o.rightArrow)jt(o.shift?"\x1B[1;2C":"\x1B[C");else if(o.leftArrow)jt(o.shift?"\x1B[1;2D":"\x1B[D");else if(o.escape)jt("\x1B");else if(o.ctrl&&n){let M=n.toLowerCase().charCodeAt(0);M>=97&&M<=122?jt(String.fromCharCode(M-96)):jt(n)}else n&&(jt(n),Sn||hn(M=>M+n));return}if(mt==="providerBudgetSelect"){let d=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","APInex"];if(o.upArrow){nr(x=>(x-1+d.length)%d.length);return}else if(o.downArrow){nr(x=>(x+1)%d.length);return}else if(n===" "){let x=d[Vs];js(g=>({...g,[x]:!g[x]}));return}else if(o.return){let x=d.filter(M=>Yr[M]);if(x.length===0)return;let g={...Le,providerBudgets:{...Le.providerBudgets||{},__useProvider:!0}};_t(g),Gl(x),Wl(0),nr(0),z("providerBudgetFlow");return}else if(o.escape){z("budgetTypeSelect");return}return}if(mt==="providerBudgetFlow"){let d=rn.length,x=d*2+1;if(o.upArrow){yo(g=>g===x-1?Math.max(0,(d-1)*2):g>=2?g-2:g);return}else if(o.downArrow){yo(g=>g===x-1?g:g+2<x-1?g+2:x-1);return}else if(o.leftArrow){yo(g=>g===x-1?g:g%2===1?g-1:g);return}else if(o.rightArrow||o.tab){yo(g=>g===x-1?g:g%2===0||g+1<x?g+1:g);return}else if(o.return){if(rr===x-1){let g=Le.providerBudgets||{},M={__useProvider:!0};for(let p of rn){let D=Vr[p]||{};M[p]={agentLimit:9999999999,tokenLimit:parseInt(D.tokenLimit,10)||0,monthlyTokenLimit:parseInt(D.monthlyTokenLimit,10)||0}}let u={...Le,providerBudgets:M};_t(u),Pt({apiTier:lt,quotas:u}),z(Wo==="settings"?"resetMode":"budgetResetMode")}else yo(g=>Math.min(x-1,g+1));return}else if(o.escape){z("providerBudgetSelect");return}return}if(o.escape){if(bi){if(wi(!1),wt.length>0){let d=wt[wt.length-1];d&&(yi.current=d.id)}return}if(Ve.length>0&&mt==="chat"){ie(!0);return}if(h){y(!1);return}if(bn||oo||Ao||Vo)as.current=!0,nl(),ji(),Ao&&(Ao.resolve("deny"),pn(null)),Vo&&(Vo.resolve(null),rs(null)),ca(!1),fi&&clearTimeout(fi);else if(mt==="revert")z("chat"),_n(0);else if(mt!=="chat"&&mt!=="settings")z("chat");else{if(!kt&&qe===1){Ct(0),on("");return}_n(d=>{let x=d+1;return x===1?(Ko.current&&clearTimeout(Ko.current),Ko.current=setTimeout(()=>_n(0),2e3)):x===2&&(Ko.current&&clearTimeout(Ko.current),_n(0),k.length>0?f(""):Vn.getChatHistory(dt).then(g=>{g.length>0?(hi(g.reverse()),z("revert")):O(M=>(H(M.length+1),[...M,{id:"revert-empty-"+Date.now(),role:"system",text:`\u2726 Nothing to revert to.
69
- \u2800`,isMeta:!0}]))})),x})}}if(Ve.length>0&&mt==="chat"){if(o.upArrow){Me(d=>{let x=d>0?d-1:Ve.length-1,g=0;for(;x!==d&&g<Ve.length;){let M=Ve[x],u=M?.cmd||M||"";if(typeof u=="string"&&u.trimStart().startsWith("---"))x=x>0?x-1:Ve.length-1,g++;else break}return x});return}if(o.downArrow){Me(d=>{let x=d<Ve.length-1?d+1:0,g=0;for(;x!==d&&g<Ve.length;){let M=Ve[x],u=M?.cmd||M||"";if(typeof u=="string"&&u.trimStart().startsWith("---"))x=x<Ve.length-1?x+1:0,g++;else break}return x});return}if(o.return)return}if(o.tab&&mt==="chat"){if(Ve.length>0){let d=Ve[ge]||Ve[0],x=k.split(" ");if(x.length===1)f(d.cmd+" ");else{let g=x.slice(0,-1);f(g.join(" ")+" "+d.cmd+" ")}Me(0),A(g=>g+1);return}else if(k.trim()===""){let d=Date.now();if(d-Ge.current<500)return;Ge.current=d;let x=["Flux","Flow","ICU","FluxCU"],g=(x.indexOf(C)+1)%x.length,M=x[g>=0?g:0];P(M),M==="Flow"?Ce("Fast"):(M==="Flux"||M==="ICU"||M==="FluxCU")&&Ce("High"),O(u=>[...u,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${Xs(M)}
68
+ `)}else if(o.backspace||o.delete)Sn?jt("\x7F"):(jt("\b \b"),hn(M=>M.slice(0,-1)));else if(o.upArrow)jt(o.shift?"\x1B[1;2A":"\x1B[A");else if(o.downArrow)jt(o.shift?"\x1B[1;2B":"\x1B[B");else if(o.rightArrow)jt(o.shift?"\x1B[1;2C":"\x1B[C");else if(o.leftArrow)jt(o.shift?"\x1B[1;2D":"\x1B[D");else if(o.escape)jt("\x1B");else if(o.ctrl&&n){let M=n.toLowerCase().charCodeAt(0);M>=97&&M<=122?jt(String.fromCharCode(M-96)):jt(n)}else n&&(jt(n),Sn||hn(M=>M+n));return}if(mt==="providerBudgetSelect"){let d=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","APInex"];if(o.upArrow){nr(x=>(x-1+d.length)%d.length);return}else if(o.downArrow){nr(x=>(x+1)%d.length);return}else if(n===" "){let x=d[Vs];js(g=>({...g,[x]:!g[x]}));return}else if(o.return){let x=d.filter(M=>Yr[M]);if(x.length===0)return;let g={...Le,providerBudgets:{...Le.providerBudgets||{},__useProvider:!0}};_t(g),Wl(x),Gl(0),nr(0),z("providerBudgetFlow");return}else if(o.escape){z("budgetTypeSelect");return}return}if(mt==="providerBudgetFlow"){let d=rn.length,x=d*2+1;if(o.upArrow){yo(g=>g===x-1?Math.max(0,(d-1)*2):g>=2?g-2:g);return}else if(o.downArrow){yo(g=>g===x-1?g:g+2<x-1?g+2:x-1);return}else if(o.leftArrow){yo(g=>g===x-1?g:g%2===1?g-1:g);return}else if(o.rightArrow||o.tab){yo(g=>g===x-1?g:g%2===0||g+1<x?g+1:g);return}else if(o.return){if(rr===x-1){let g=Le.providerBudgets||{},M={__useProvider:!0};for(let p of rn){let B=Vr[p]||{};M[p]={agentLimit:9999999999,tokenLimit:parseInt(B.tokenLimit,10)||0,monthlyTokenLimit:parseInt(B.monthlyTokenLimit,10)||0}}let u={...Le,providerBudgets:M};_t(u),Pt({apiTier:lt,quotas:u}),z(Go==="settings"?"resetMode":"budgetResetMode")}else yo(g=>Math.min(x-1,g+1));return}else if(o.escape){z("providerBudgetSelect");return}return}if(o.escape){if(bi){if(Ti(!1),Tt.length>0){let d=Tt[Tt.length-1];d&&(yi.current=d.id)}return}if(Ve.length>0&&mt==="chat"){ie(!0);return}if(h){y(!1);return}if(bn||oo||Ao||Vo)as.current=!0,nl(),ji(),Ao&&(Ao.resolve("deny"),pn(null)),Vo&&(Vo.resolve(null),rs(null)),ca(!1),fi&&clearTimeout(fi);else if(mt==="revert")z("chat"),_n(0);else if(mt!=="chat"&&mt!=="settings")z("chat");else{if(!kt&&qe===1){Ct(0),on("");return}_n(d=>{let x=d+1;return x===1?(Ko.current&&clearTimeout(Ko.current),Ko.current=setTimeout(()=>_n(0),2e3)):x===2&&(Ko.current&&clearTimeout(Ko.current),_n(0),k.length>0?f(""):Vn.getChatHistory(dt).then(g=>{g.length>0?(hi(g.reverse()),z("revert")):O(M=>(H(M.length+1),[...M,{id:"revert-empty-"+Date.now(),role:"system",text:`\u2726 Nothing to revert to.
69
+ \u2800`,isMeta:!0}]))})),x})}}if(Ve.length>0&&mt==="chat"){if(o.upArrow){ye(d=>{let x=d>0?d-1:Ve.length-1,g=0;for(;x!==d&&g<Ve.length;){let M=Ve[x],u=M?.cmd||M||"";if(typeof u=="string"&&u.trimStart().startsWith("---"))x=x>0?x-1:Ve.length-1,g++;else break}return x});return}if(o.downArrow){ye(d=>{let x=d<Ve.length-1?d+1:0,g=0;for(;x!==d&&g<Ve.length;){let M=Ve[x],u=M?.cmd||M||"";if(typeof u=="string"&&u.trimStart().startsWith("---"))x=x<Ve.length-1?x+1:0,g++;else break}return x});return}if(o.return)return}if(o.tab&&mt==="chat"){if(Ve.length>0){let d=Ve[ge]||Ve[0],x=k.split(" ");if(x.length===1)f(d.cmd+" ");else{let g=x.slice(0,-1);f(g.join(" ")+" "+d.cmd+" ")}ye(0),A(g=>g+1);return}else if(k.trim()===""){let d=Date.now();if(d-We.current<500)return;We.current=d;let x=["Flux","Flow","ICU","FluxCU"],g=(x.indexOf(C)+1)%x.length,M=x[g>=0?g:0];P(M),M==="Flow"?Se("Fast"):(M==="Flux"||M==="ICU"||M==="FluxCU")&&Se("High"),O(u=>[...u,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${Xs(M)}
70
70
  \u2800`,isMeta:!0}]);return}}if(o.ctrl&&n==="c"&&mt!=="exit"){if(k.length>0){f("");return}if(o.shift){z("exit"),y(!1);return}h?(z("exit"),y(!1)):y(!0)}o.return&&(o.shift||o.ctrl||o.meta||o.leftAlt||o.rightAlt)&&f(d=>d.replace(/\\\r?$/,"").replace(/\r?$/,"")+`
71
- `)}}),rt(()=>{process.stdout.write("\x1B[?1004h");let n=o=>{let d=o.toString();d.includes("\x1B[I")?(qt(!0),je.current=Date.now()):d.includes("\x1B[O")&&(qt(!1),je.current=Date.now())};return process.stdin.on("data",n),()=>{process.stdout.write("\x1B[?1004l"),process.stdin.off("data",n)}},[]);let fr=Ke(xe.theme);rt(()=>{fr.current&&fr.current!==xe.theme?(fr.current=xe.theme,s&&(s.write("\x1B[2J\x1B[3J\x1B[H"),s.isTTY&&s.write("\x1B[?2004h")),us(n=>n+1),Co()):fr.current=xe.theme},[xe.theme,s]),rt(()=>{async function n(){try{let D=JSON.parse(et.readFileSync(St.join(process.cwd(),"package.json"),"utf8"));ys(ao||D.version||"2.0.0")}catch{ys("2.0.0")}process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07")),await kl()||(O(D=>(H(D.length+1),[...D,{id:"setup-"+Date.now(),role:"system",text:"\u2726 Installing Required dependencies... (One-time setup)",isMeta:!0}])),await Il(),O(D=>(H(D.length+1),[...D,{id:"setup-done-"+Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m All dependencies installed successfully.
72
- \u2800`,isMeta:!0}])));let o=await xs();ts.current=o.systemSettings?.allowExternalAccess??!1,os.current=o.systemSettings?.memory??!0,Ee.mode?P(Ee.mode):P(o.mode),L(o.display??0),Ee.thinking?Ce(Ee.thinking):Ce(o.thinkingLevel);let d=Ee.provider||o.aiProvider||"Google";$e(d);let g=(o.quotas?.providerTiers||{})[d]||o.apiTier||"Free";if(be.current=o.activeModel,Ee.model)Rt(Ee.model);else if(Ee.provider){let D=go(d,g);Rt(D)}else Rt(o.activeModel);tn(o.showFullThinking),Go(g),_t(o.quotas||{limitMode:"Daily",agentLimit:99999999,tokenLimit:99999999999999,backgroundLimit:999999,searchLimit:100,customModelId:"",customLimit:0,providerBudgets:{}});let M={memory:!0,compression:0,autoExec:!1,autoDeleteHistory:"7d",autoUpdate:!1,updateManager:"npm",customUpdateCommand:"",...o.systemSettings||{}};Ee.memory==="on"?M.memory=!0:Ee.memory==="off"&&(M.memory=!1),d==="NVIDIA"&&process.env.NVIDIA_BASE_URL&&(M.memory=!1,O(D=>[...D,{role:"system",text:`\u2726 MEMORY
71
+ `)}}),rt(()=>{process.stdout.write("\x1B[?1004h");let n=o=>{let d=o.toString();d.includes("\x1B[I")?(qt(!0),je.current=Date.now()):d.includes("\x1B[O")&&(qt(!1),je.current=Date.now())};return process.stdin.on("data",n),()=>{process.stdout.write("\x1B[?1004l"),process.stdin.off("data",n)}},[]);let fr=Ke(xe.theme);rt(()=>{fr.current&&fr.current!==xe.theme?(fr.current=xe.theme,s&&(s.write("\x1B[2J\x1B[3J\x1B[H"),s.isTTY&&s.write("\x1B[?2004h")),us(n=>n+1),Co()):fr.current=xe.theme},[xe.theme,s]),rt(()=>{async function n(){try{let B=JSON.parse(et.readFileSync(St.join(process.cwd(),"package.json"),"utf8"));ys(ao||B.version||"2.0.0")}catch{ys("2.0.0")}process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07")),await kl()||(O(B=>(H(B.length+1),[...B,{id:"setup-"+Date.now(),role:"system",text:"\u2726 Installing Required dependencies... (One-time setup)",isMeta:!0}])),await Il(),O(B=>(H(B.length+1),[...B,{id:"setup-done-"+Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m All dependencies installed successfully.
72
+ \u2800`,isMeta:!0}])));let o=await xs();ts.current=o.systemSettings?.allowExternalAccess??!1,os.current=o.systemSettings?.memory??!0,ve.mode?P(ve.mode):P(o.mode),L(o.display??0),ve.thinking?Se(ve.thinking):Se(o.thinkingLevel);let d=ve.provider||o.aiProvider||"Google";Ue(d);let g=(o.quotas?.providerTiers||{})[d]||o.apiTier||"Free";if(be.current=o.activeModel,ve.model)Rt(ve.model);else if(ve.provider){let B=go(d,g);Rt(B)}else Rt(o.activeModel);tn(o.showFullThinking),Wo(g),_t(o.quotas||{limitMode:"Daily",agentLimit:99999999,tokenLimit:99999999999999,backgroundLimit:999999,searchLimit:100,customModelId:"",customLimit:0,providerBudgets:{}});let M={memory:!0,compression:0,autoExec:!1,autoDeleteHistory:"7d",autoUpdate:!1,updateManager:"npm",customUpdateCommand:"",...o.systemSettings||{}};ve.memory==="on"?M.memory=!0:ve.memory==="off"&&(M.memory=!1),d==="NVIDIA"&&process.env.NVIDIA_BASE_URL&&(M.memory=!1,O(B=>[...B,{role:"system",text:`\u2726 MEMORY
73
73
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Currently not available.
74
- \u2800`,isMeta:!0}])),Ee.package&&(M.updateManager=Ee.package),Ee.autoDel&&(M.autoDeleteHistory=Ee.autoDel),Ee.autoExec==="on"?M.autoExec=!0:Ee.autoExec==="off"&&(M.autoExec=!1),Ee.externalAccess==="on"?M.allowExternalAccess=!0:Ee.externalAccess==="off"&&(M.allowExternalAccess=!1),Ee.playground&&(M.allowExternalAccess=!1,M.memory=!1),It(M),Ks(o.profileData),sr(o.imageSettings||{keyType:"Default",quality:"Low-High",apiKey:""});let u=Ee.key;if(u||(u=await Mn(d)),u&&(zt(u),Kn(u,{aiProvider:d,onIDEApproval:mr})),o.systemSettings?.autoDeleteHistory&&Qi(o.systemSettings.autoDeleteHistory),Ee.playground||(Er(fn).catch(()=>{}),et.remove(St.join(mo,"playground")).catch(()=>{})),oe(!1,M),await Promise.all([$i(),Vn.recoverCrashedTransaction()]),Ee.resume){let D=await Fo(),F=Ee.resume;if(D[F]){Mo.current=!0,cr(F);let Q=await jn(F);ln.current=Yt-Q.total,dn.current=eo,un.current=Yo,sn(Q.total),an(0),cn(0),Io({tokens:Q.context}),Mo.current=!1;let de=[...D[F].messages];de[0]?.text?.includes("\u2591\u2591\u2591\u2588\u2588\u2588")||de.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),O(de),z("chat"),O(V=>{let K=[...V,{id:"sys-"+Date.now(),role:"system",text:`\u2726 SESSION RESUMED
74
+ \u2800`,isMeta:!0}])),ve.package&&(M.updateManager=ve.package),ve.autoDel&&(M.autoDeleteHistory=ve.autoDel),ve.autoExec==="on"?M.autoExec=!0:ve.autoExec==="off"&&(M.autoExec=!1),ve.externalAccess==="on"?M.allowExternalAccess=!0:ve.externalAccess==="off"&&(M.allowExternalAccess=!1),ve.playground&&(M.allowExternalAccess=!1,M.memory=!1),It(M),Ks(o.profileData),sr(o.imageSettings||{keyType:"Default",quality:"Low-High",apiKey:""});let u=ve.key;if(u||(u=await Mn(d)),u&&(zt(u),Kn(u,{aiProvider:d,onIDEApproval:mr})),o.systemSettings?.autoDeleteHistory&&Qi(o.systemSettings.autoDeleteHistory),ve.playground||(Er(fn).catch(()=>{}),et.remove(St.join(mo,"playground")).catch(()=>{})),oe(!1,M),await Promise.all([$i(),Vn.recoverCrashedTransaction()]),ve.resume){let B=await Fo(),F=ve.resume;if(B[F]){Mo.current=!0,cr(F);let K=await jn(F);ln.current=Yt-K.total,dn.current=eo,un.current=Yo,sn(K.total),an(0),cn(0),Io({tokens:K.context}),Mo.current=!1;let de=[...B[F].messages];de[0]?.text?.includes("\u2591\u2591\u2591\u2588\u2588\u2588")||de.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),O(de),z("chat"),O(V=>{let q=[...V,{id:"sys-"+Date.now(),role:"system",text:`\u2726 SESSION RESUMED
75
75
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m '${F}'.
76
- \u2800`,isMeta:!0}];return H(K.length),K})}else O(Q=>[...Q,{id:"sys-err-"+Date.now(),role:"system",text:`\u2726 Chat session [${F}] not found. Started new session.
77
- \u2800`,isMeta:!0}])}if(Ee.playground){let D=St.join(mo,"playground");try{et.ensureDirSync(D),process.chdir(D)}catch{}let F=await Fo();if(F[fn]){Mo.current=!0;let Q=await jn(fn);ln.current=Yt-Q.total,dn.current=eo,un.current=Yo,sn(Q.total),an(0),cn(0),Io({tokens:Q.context}),Mo.current=!1;let de=[...F[fn].messages];de[0]?.isLogo||de.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),O(de),O(Y=>{let V=[...Y,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND Session restored
78
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m CWD locked to: '${D}'.
79
- \u2800`,isMeta:!0}];return H(V.length),V})}else O(Q=>{let de=[...Q,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND Mode active
76
+ \u2800`,isMeta:!0}];return H(q.length),q})}else O(K=>[...K,{id:"sys-err-"+Date.now(),role:"system",text:`\u2726 Chat session [${F}] not found. Started new session.
77
+ \u2800`,isMeta:!0}])}if(ve.playground){let B=St.join(mo,"playground");try{et.ensureDirSync(B),process.chdir(B)}catch{}let F=await Fo();if(F[fn]){Mo.current=!0;let K=await jn(fn);ln.current=Yt-K.total,dn.current=eo,un.current=Yo,sn(K.total),an(0),cn(0),Io({tokens:K.context}),Mo.current=!1;let de=[...F[fn].messages];de[0]?.isLogo||de.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),O(de),O(Y=>{let V=[...Y,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND Session restored
78
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m CWD locked to: '${B}'.
79
+ \u2800`,isMeta:!0}];return H(V.length),V})}else O(K=>{let de=[...K,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND Mode active
80
80
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m CWD locked to: 'FluxFlow/playground'.
81
- \u2800`,isMeta:!0}];return H(de.length),de})}let a=Ro();if(!["Terminal","Windows Terminal"].includes(a)){let D=Fl(a);if(D)try{let F=[];if(et.existsSync(D)){let Q=et.readFileSync(D,"utf8").trim();Q&&(F=Ul(Q))}ec(F)?$r="Shift + Enter":z("keybindingsPrompt")}catch{}}it(!1)}n()},[]),rt(()=>{let n;return h&&(b(10),n=setInterval(()=>{b(o=>o<=1?(y(!1),0):o-1)},1e3)),()=>{n&&clearInterval(n)}},[h]),rt(()=>{if(!Re){let n=Ee.model&&He===Ee.model?be.current:He,o=xe;Ee.playground&&(o={...xe,allowExternalAccess:ts.current,memory:os.current}),Pt({mode:C,thinkingLevel:ce,aiProvider:B,activeModel:n||He,showFullThinking:en,systemSettings:o,profileData:In,imageSettings:ko,apiTier:lt})}},[C,ce,B,He,en,xe,In,ko,Re,Ee,lt]);let Si=async n=>{let o=n.trim(),d={Google:{prefix:"AIzaSy",minLength:39},OpenRouter:{prefix:"sk-or-v1-",minLength:73},DeepSeek:{prefix:"sk-",minLength:35},Mistral:{prefix:"",minLength:32},NVIDIA:{prefix:"nvapi-",minLength:70},Ollama:{prefix:"",minLength:0},InferX:{prefix:"",minLength:0},SenseNova:{prefix:"",minLength:0},AIHubMix:{prefix:"sk-",minLength:10},Poolside:{prefix:"",minLength:0},"9router":{prefix:"",minLength:0},ExpLabs:{prefix:"xpl_",minLength:0},TokenHarbor:{prefix:"thk_",minLength:0},APInex:{prefix:"sk-apx",minLength:0}},{prefix:x,minLength:g}=d[B]??{prefix:"",minLength:0},M=(B==="Ollama"||B==="9router")&&(o.trim()==="LOCAL"||o.trim()===""),u=M?"LOCAL":o;if(M||o.startsWith(x)&&o.length>=g){await fs(B,u),zt(u),Kn(u,{aiProvider:B,onIDEApproval:mr});let a="gemma-4-31b-it";B==="OpenRouter"?a="google/gemma-4-31b-it:free":B==="DeepSeek"?a="deepseek-v4-flash":B==="NVIDIA"?a="deepseek-ai/deepseek-v4-flash":B==="Ollama"||B==="9router"?a=He||"":(B==="InferX"||B==="SenseNova"||B==="AIHubMix"||B==="Poolside"||B==="ExpLabs"||B==="TokenHarbor"||B==="APInex")&&(a=go(B,lt)||""),Rt(a);let p={...xe};M&&B==="Ollama"&&(p={...p,ollamaEndpoint:"Local"},It(p)),(B==="Ollama"||B==="InferX"||B==="SenseNova"||B==="AIHubMix"||B==="Poolside"||B==="9router"||B==="ExpLabs"||B==="TokenHarbor"||B==="APInex")&&(p={...p,memory:!1},It(p));let D="";if(B==="9router"){let F=await Hs();F.ok||(D=`
81
+ \u2800`,isMeta:!0}];return H(de.length),de})}let a=Ro();if(!["Terminal","Windows Terminal"].includes(a)){let B=Fl(a);if(B)try{let F=[];if(et.existsSync(B)){let K=et.readFileSync(B,"utf8").trim();K&&(F=Ul(K))}ec(F)?$r="Shift + Enter":z("keybindingsPrompt")}catch{}}it(!1)}n()},[]),rt(()=>{let n;return h&&(b(10),n=setInterval(()=>{b(o=>o<=1?(y(!1),0):o-1)},1e3)),()=>{n&&clearInterval(n)}},[h]),rt(()=>{if(!Re){let n=ve.model&&Ge===ve.model?be.current:Ge,o=xe;ve.playground&&(o={...xe,allowExternalAccess:ts.current,memory:os.current}),Pt({mode:C,thinkingLevel:ce,aiProvider:D,activeModel:n||Ge,showFullThinking:en,systemSettings:o,profileData:In,imageSettings:ko,apiTier:lt})}},[C,ce,D,Ge,en,xe,In,ko,Re,ve,lt]);let Si=async n=>{let o=n.trim(),d={Google:{prefix:"AIzaSy",minLength:39},OpenRouter:{prefix:"sk-or-v1-",minLength:73},DeepSeek:{prefix:"sk-",minLength:35},Mistral:{prefix:"",minLength:32},NVIDIA:{prefix:"nvapi-",minLength:70},Ollama:{prefix:"",minLength:0},InferX:{prefix:"",minLength:0},SenseNova:{prefix:"",minLength:0},AIHubMix:{prefix:"sk-",minLength:10},Poolside:{prefix:"",minLength:0},"9router":{prefix:"",minLength:0},ExpLabs:{prefix:"xpl_",minLength:0},TokenHarbor:{prefix:"thk_",minLength:0},APInex:{prefix:"sk-apx",minLength:0}},{prefix:x,minLength:g}=d[D]??{prefix:"",minLength:0},M=(D==="Ollama"||D==="9router")&&(o.trim()==="LOCAL"||o.trim()===""),u=M?"LOCAL":o;if(M||o.startsWith(x)&&o.length>=g){await fs(D,u),zt(u),Kn(u,{aiProvider:D,onIDEApproval:mr});let a="gemma-4-31b-it";D==="OpenRouter"?a="google/gemma-4-31b-it:free":D==="DeepSeek"?a="deepseek-v4-flash":D==="NVIDIA"?a="deepseek-ai/deepseek-v4-flash":D==="Ollama"||D==="9router"?a=Ge||"":(D==="InferX"||D==="SenseNova"||D==="AIHubMix"||D==="Poolside"||D==="ExpLabs"||D==="TokenHarbor"||D==="APInex")&&(a=go(D,lt)||""),Rt(a);let p={...xe};M&&D==="Ollama"&&(p={...p,ollamaEndpoint:"Local"},It(p)),(D==="Ollama"||D==="InferX"||D==="SenseNova"||D==="AIHubMix"||D==="Poolside"||D==="9router"||D==="ExpLabs"||D==="TokenHarbor"||D==="APInex")&&(p={...p,memory:!1},It(p));let B="";if(D==="9router"){let F=await Hs();F.ok||(B=`
82
82
 
83
83
  \x1B[33m\u2726 WARNING: 9router does not appear to be running on ${F.url}.\x1B[39m
84
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m To start 9router: \x1B[36mnpx 9router\x1B[39m or \x1B[36mnpm i -g 9router && 9router\x1B[39m`)}O(F=>[...F,{role:"system",text:`\u2726 ${B} API Key saved successfully! ${a?`
85
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model set to ${a}.`:""}${M&&B==="Ollama"?`
84
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m To start 9router: \x1B[36mnpx 9router\x1B[39m or \x1B[36mnpm i -g 9router && 9router\x1B[39m`)}O(F=>[...F,{role:"system",text:`\u2726 ${D} API Key saved successfully! ${a?`
85
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model set to ${a}.`:""}${M&&D==="Ollama"?`
86
86
  \u2726 Ollama Endpoint switched to Local.
87
87
  \u2514\u2500\u2800`:`
88
88
 
89
- \u2726\u2800`}${B==="Ollama"||B==="InferX"||B==="SenseNova"||B==="AIHubMix"||B==="Poolside"||B==="9router"||B==="ExpLabs"||B==="TokenHarbor"||B==="APInex"?`Memory is not available with ${B}.
90
- \u2514\u2500\u2800`:""}Initialization complete.${D}
89
+ \u2726\u2800`}${D==="Ollama"||D==="InferX"||D==="SenseNova"||D==="AIHubMix"||D==="Poolside"||D==="9router"||D==="ExpLabs"||D==="TokenHarbor"||D==="APInex"?`Memory is not available with ${D}.
90
+ \u2514\u2500\u2800`:""}Initialization complete.${B}
91
91
  \u2800`,isMeta:!0}])}else O(a=>[...a,{role:"system",text:`\u2726 INVALID KEY
92
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${B} API key must start with "${x}" and be at least ${g} characters long.`,isMeta:!0}]),on("")},xr=Ke(Gs);rt(()=>{if(mt==="exit"){(async()=>{let d=Date.now(),x=Math.floor((d-xr.current)/1e3);x>=1&&(await Qo("duration",x),xr.current+=x*1e3),await Ui()})();let o=setTimeout(()=>{process.exit(0)},50);return()=>clearTimeout(o)}},[mt]),rt(()=>{let n=setInterval(async()=>{if(!Re){let o=Date.now(),d=Math.floor((o-xr.current)/1e3);d>=1&&(await Qo("duration",d),xr.current+=d*1e3),Fi()}},5e3);return()=>clearInterval(n)},[Re]);let Ci=[{cmd:"/quit",desc:"Exit and shutdown Flux"},{cmd:"/help",desc:"Show all available commands"},...Ee.playground?[{cmd:"/move",desc:"Move playground directory to original CWD/playground-export"}]:[],{cmd:"/resume",desc:"Load previous session"},{cmd:"/clear",desc:"Clear terminal screen"},{cmd:"/compress",desc:"Summarize and compress chat history"},{cmd:"/truncate",desc:"Truncate tool results in chat history"},{cmd:"/revert",desc:"Revert codebase back to a checkpoint"},{cmd:"/gemini",desc:"Get a happy message from Gemini CLI"},{cmd:"/save",desc:"Force save current chat"},{cmd:"/export",desc:"Export current chat or error logs",subs:[{cmd:"chat",desc:"Export current active chat"},{cmd:"logs",desc:"Export error logs"}]},{cmd:"/chats",desc:"List all chat sessions"},{cmd:"/btw",desc:"Ask a question without intefering with ongoing tasks"},{cmd:"/thinking",desc:"Set AI reasoning depth",subs:[{cmd:"Low",display:Ht(B,He,"Low")!==null?`Low (${Ht(B,He,"Low")})`:"Low",desc:"Quick Reasoning"},{cmd:"Medium",display:Ht(B,He,"Medium")!==null?`Medium (${Ht(B,He,"Medium")})`:"Medium",desc:"Balanced Reasoning"},{cmd:"High",display:Ht(B,He,"High")!==null?`High (${Ht(B,He,"High")})`:"High",desc:"Deep Reasoning"},{cmd:"custom",display:Ht(B,He,"xHigh")!==null?`Custom (${Ht(B,He,"xHigh")})`:"Custom",desc:"Custom Reasoning Value"}]},{cmd:"/model",desc:"Select Agent Model",subs:C==="ICU"||C.toLowerCase()==="fluxcu"?No(B,lt).filter(n=>yr(n.cmd||n)):No(B,lt)},{cmd:"/wildcard-tooling",desc:"Use if the model lacks Tooling Capability"},{cmd:"/wildercard-tooling",desc:"Extended version of /wildcard-tooling"},{cmd:"/provider",desc:"Select AI Provider"},{cmd:"/mode",desc:"Switch execution mode",subs:[{cmd:"flux",display:"workspace",desc:"Workspace, files & terminal tools"},{cmd:"flow",display:"studio",desc:"Creative studio, documents, PDF & conversation"},{cmd:"icu",display:"computer use",desc:"Interactive desktop & OS automation"},{cmd:"fluxcu",display:"omni",desc:"Autonomous tools & desktop execution"}]},{cmd:"/display",desc:"Select Active Display (Computer Use)",subs:[{cmd:"primary",desc:"Primary Display (Display 1)"},{cmd:"secondary",desc:"Secondary Display (Display 2)"}]},{cmd:"/settings",desc:"Configure system prefs"},{cmd:"/theme",desc:"Customize UI color theme"},{cmd:"/key",desc:"Manage API keys"},{cmd:"/files",desc:"List loaded instruction and skill files"},{cmd:"/profile",desc:"Edit developer persona"},{cmd:"/memory",desc:"Manage agent memory",subs:[{cmd:"view",desc:"View and manage agent persistent memory"},{cmd:"migrate",desc:"Migrate persistent memories to AGENTS.md"}]},{cmd:"/stats",desc:"Show session usage"},{cmd:"/usage",desc:"Open graphical token usage & analytics dashboard in browser"},{cmd:"/target",desc:"Show current provider and model"},{cmd:"/reset",desc:"Wipe all project data"},{cmd:"/about",desc:"Project info & credits"},{cmd:"/changelog",desc:"View latest updates"},{cmd:"/docs",desc:"View Documentation"},{cmd:"/fluxflow",desc:"Project management",subs:[{cmd:"global",desc:"Opens the Global FluxFlow Directory in File Explorer"},{cmd:"saves",desc:"Opens FluxFlow AppData Directory in File Explorer"}]},{cmd:"/budget",desc:"Set or View budget limits",subs:[{cmd:"view",desc:"View current usage budget bars"},{cmd:"web",desc:"Open graphical usage and budget dashboard in browser"},{cmd:"set",desc:"Configure budgets (Daily/Monthly limits)"},{cmd:"reset",desc:"Reset budgets to default limits"}]},{cmd:"/update",desc:"Check/Install updates",subs:[{cmd:"latest",desc:"Install latest release"},{cmd:"check",desc:"Check for new version"}]}],vi=async(n,o=!1)=>{if(!o&&Ve.length>0){let g=Ve[ge]||Ve[0],M=n.split(" ");if(M.length===1)f(g.cmd+" ");else{let u=M.slice(0,-1);f(u.join(" ")+" "+g.cmd+" ")}Me(0),A(u=>u+1);return}as.current=!1;let d=n.replace(/\r\n/g,`
92
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${D} API key must start with "${x}" and be at least ${g} characters long.`,isMeta:!0}]),on("")},xr=Ke(Ws);rt(()=>{if(mt==="exit"){(async()=>{let d=Date.now(),x=Math.floor((d-xr.current)/1e3);x>=1&&(await Qo("duration",x),xr.current+=x*1e3),await Ui()})();let o=setTimeout(()=>{process.exit(0)},50);return()=>clearTimeout(o)}},[mt]),rt(()=>{let n=setInterval(async()=>{if(!Re){let o=Date.now(),d=Math.floor((o-xr.current)/1e3);d>=1&&(await Qo("duration",d),xr.current+=d*1e3),Fi()}},5e3);return()=>clearInterval(n)},[Re]);let Ci=[{cmd:"/quit",desc:"Exit and shutdown Flux"},{cmd:"/help",desc:"Show all available commands"},...ve.playground?[{cmd:"/move",desc:"Move playground directory to original CWD/playground-export"}]:[],{cmd:"/resume",desc:"Load previous session"},{cmd:"/clear",desc:"Clear terminal screen"},{cmd:"/compress",desc:"Summarize and compress chat history"},{cmd:"/truncate",desc:"Truncate tool results in chat history"},{cmd:"/revert",desc:"Revert codebase back to a checkpoint"},{cmd:"/gemini",desc:"Get a happy message from Gemini CLI"},{cmd:"/save",desc:"Force save current chat"},{cmd:"/export",desc:"Export current chat or error logs",subs:[{cmd:"chat",desc:"Export current active chat"},{cmd:"logs",desc:"Export error logs"}]},{cmd:"/chats",desc:"List all chat sessions"},{cmd:"/btw",desc:"Ask a question without intefering with ongoing tasks"},{cmd:"/thinking",desc:"Set AI reasoning depth",subs:[{cmd:"Low",display:Ht(D,Ge,"Low")!==null?`Low (${Ht(D,Ge,"Low")})`:"Low",desc:"Quick Reasoning"},{cmd:"Medium",display:Ht(D,Ge,"Medium")!==null?`Medium (${Ht(D,Ge,"Medium")})`:"Medium",desc:"Balanced Reasoning"},{cmd:"High",display:Ht(D,Ge,"High")!==null?`High (${Ht(D,Ge,"High")})`:"High",desc:"Deep Reasoning"},{cmd:"custom",display:Ht(D,Ge,"xHigh")!==null?`Custom (${Ht(D,Ge,"xHigh")})`:"Custom",desc:"Custom Reasoning Value"}]},{cmd:"/model",desc:"Select Agent Model",subs:C==="ICU"||C.toLowerCase()==="fluxcu"?No(D,lt).filter(n=>yr(n.cmd||n)):No(D,lt)},{cmd:"/wildcard-tooling",desc:"Use if the model lacks Tooling Capability"},{cmd:"/provider",desc:"Select AI Provider"},{cmd:"/mode",desc:"Switch execution mode",subs:[{cmd:"flux",display:"workspace",desc:"Workspace, files & terminal tools"},{cmd:"flow",display:"studio",desc:"Creative studio, documents, PDF & conversation"},{cmd:"icu",display:"computer use",desc:"Interactive desktop & OS automation"},{cmd:"fluxcu",display:"omni",desc:"Autonomous tools & desktop execution"}]},{cmd:"/display",desc:"Select Active Display (Computer Use)",subs:[{cmd:"primary",desc:"Primary Display (Display 1)"},{cmd:"secondary",desc:"Secondary Display (Display 2)"}]},{cmd:"/settings",desc:"Configure system prefs"},{cmd:"/theme",desc:"Customize UI color theme"},{cmd:"/key",desc:"Manage API keys"},{cmd:"/files",desc:"List loaded instruction and skill files"},{cmd:"/profile",desc:"Edit developer persona"},{cmd:"/memory",desc:"Manage agent memory",subs:[{cmd:"view",desc:"View and manage agent persistent memory"},{cmd:"migrate",desc:"Migrate persistent memories to AGENTS.md"}]},{cmd:"/stats",desc:"Show session usage"},{cmd:"/usage",desc:"Open graphical token usage & analytics dashboard in browser"},{cmd:"/target",desc:"Show current provider and model"},{cmd:"/reset",desc:"Wipe all project data"},{cmd:"/about",desc:"Project info & credits"},{cmd:"/changelog",desc:"View latest updates"},{cmd:"/docs",desc:"View Documentation"},{cmd:"/fluxflow",desc:"Project management",subs:[{cmd:"global",desc:"Opens the Global FluxFlow Directory in File Explorer"},{cmd:"saves",desc:"Opens FluxFlow AppData Directory in File Explorer"}]},{cmd:"/budget",desc:"Set or View budget limits",subs:[{cmd:"view",desc:"View current usage budget bars"},{cmd:"web",desc:"Open graphical usage and budget dashboard in browser"},{cmd:"set",desc:"Configure budgets (Daily/Monthly limits)"},{cmd:"reset",desc:"Reset budgets to default limits"}]},{cmd:"/update",desc:"Check/Install updates",subs:[{cmd:"latest",desc:"Install latest release"},{cmd:"check",desc:"Check for new version"}]}],vi=async(n,o=!1)=>{if(!o&&Ve.length>0){let g=Ve[ge]||Ve[0],M=n.split(" ");if(M.length===1)f(g.cmd+" ");else{let u=M.slice(0,-1);f(u.join(" ")+" "+g.cmd+" ")}ye(0),A(u=>u+1);return}as.current=!1;let d=n.replace(/\r\n/g,`
93
93
  `).replace(/\r/g,`
94
94
  `).trimEnd();if(d.endsWith("\\")){f(d.slice(0,-1)+`
95
95
  `);return}let x=d.replace(/\\\s*\n/g,`
@@ -98,171 +98,171 @@ import{B as sl,C as il,D as ll,a as Yi,b as Je,c as nt,d as Cr,e as Ht,f as Ki,g
98
98
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Inquiry question must be more than 3 characters.
99
99
  \u2800`,isMeta:!0}])),f("");return}}else if(g.startsWith("/")){O(M=>(H(M.length+1),[...M,{id:"hint-err-"+Date.now(),role:"system",text:`\u2726 RESTRICTED
100
100
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Steering Hints cannot start with '/'.
101
- \u2800`,isMeta:!0}])),f("");return}ds(g),So.current=g,f("");return}if(!kt){Si(x),on("");return}if(x.startsWith("/")){f("");let g=x.split(" "),M=g[0]?.toLowerCase();switch(M){case"/quit":{z("exit");break}case"/resume":{if(g[1]){let u=g[1];(async()=>{let p=await Fo(),D=p[u]||Object.values(p).find(F=>F.name.toLowerCase()===u.toLowerCase());if(D){if(s.write("\x1B[2J\x1B[3J\x1B[H"),process.stdout.isTTY){let Y=D?.name||"",V=Y&&!Y.startsWith("flow-")&&!Y.startsWith("Session ")?Y:"FluxFlow | Resumed";process.stdout.write(`\x1B]0;${V}\x07`),process.stdout.write(`\x1B]633;P;TerminalTitle=${V}\x07`)}Co(),Mo.current=!0,cr(u);let F=await jn(u);ln.current=Yt-F.total,dn.current=eo,un.current=Yo,sn(F.total),an(0),cn(0),Io({tokens:F.context}),Mo.current=!1;let Q=[...D.messages];Q[0]?.text?.includes("\u2591\u2591\u2591\u2588\u2588\u2588")||Q.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),O(Q),O(Y=>[...Y,{id:"sys-"+Date.now(),role:"system",text:`\u2726 SESSION RESUMED
101
+ \u2800`,isMeta:!0}])),f("");return}ds(g),So.current=g,f("");return}if(!kt){Si(x),on("");return}if(x.startsWith("/")){f("");let g=x.split(" "),M=g[0]?.toLowerCase();switch(M){case"/quit":{z("exit");break}case"/resume":{if(g[1]){let u=g[1];(async()=>{let p=await Fo(),B=p[u]||Object.values(p).find(F=>F.name.toLowerCase()===u.toLowerCase());if(B){if(s.write("\x1B[2J\x1B[3J\x1B[H"),process.stdout.isTTY){let Y=B?.name||"",V=Y&&!Y.startsWith("flow-")&&!Y.startsWith("Session ")?Y:"FluxFlow | Resumed";process.stdout.write(`\x1B]0;${V}\x07`),process.stdout.write(`\x1B]633;P;TerminalTitle=${V}\x07`)}Co(),Mo.current=!0,cr(u);let F=await jn(u);ln.current=Yt-F.total,dn.current=eo,un.current=Yo,sn(F.total),an(0),cn(0),Io({tokens:F.context}),Mo.current=!1;let K=[...B.messages];K[0]?.text?.includes("\u2591\u2591\u2591\u2588\u2588\u2588")||K.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),O(K),O(Y=>[...Y,{id:"sys-"+Date.now(),role:"system",text:`\u2726 SESSION RESUMED
102
102
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${u}.
103
103
  \u2800`,isMeta:!0}]),H(0)}else O(F=>[...F,{id:"err-"+Date.now(),role:"system",text:`\u2726 ERROR: Session [${u}] not found.
104
- \u2800`,isMeta:!0}])})()}else z("resume");break}case"/move":{if(!Ee.playground){O(D=>(H(D.length+1),[...D,{id:Date.now(),role:"system",text:`\u2726 RESTRICTED
104
+ \u2800`,isMeta:!0}])})()}else z("resume");break}case"/move":{if(!ve.playground){O(B=>(H(B.length+1),[...B,{id:Date.now(),role:"system",text:`\u2726 RESTRICTED
105
105
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m '/move' is only available in playground mode.
106
- \u2800`,isMeta:!0}]));break}if(!Ee.originalCwd){O(D=>(H(D.length+1),[...D,{id:Date.now(),role:"system",text:`\u2726 RESTRICTED
106
+ \u2800`,isMeta:!0}]));break}if(!ve.originalCwd){O(B=>(H(B.length+1),[...B,{id:Date.now(),role:"system",text:`\u2726 RESTRICTED
107
107
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Original CWD not found.
108
- \u2800`,isMeta:!0}]));break}let u=St.join(mo,"playground"),a=St.join(Ee.originalCwd,"playground-export");(async()=>{try{O(F=>(H(F.length+1),[...F,{id:Date.now(),role:"system",text:`\u2726 EXPORTING PLAYGROUND CONTENT
108
+ \u2800`,isMeta:!0}]));break}let u=St.join(mo,"playground"),a=St.join(ve.originalCwd,"playground-export");(async()=>{try{O(F=>(H(F.length+1),[...F,{id:Date.now(),role:"system",text:`\u2726 EXPORTING PLAYGROUND CONTENT
109
109
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${a}
110
- `,isMeta:!0}])),await et.ensureDir(a);let D=["node_modules",".git",".venv","venv","env",".next","dist","build",".cache"];await et.copy(u,a,{overwrite:!0,filter:F=>{let Q=St.relative(u,F);return Q?!Q.split(St.sep).some(Y=>D.includes(Y)):!0}}),O(F=>(H(F.length+1),[...F,{id:Date.now(),role:"system",text:`\u2726 SUCCESS
110
+ `,isMeta:!0}])),await et.ensureDir(a);let B=["node_modules",".git",".venv","venv","env",".next","dist","build",".cache"];await et.copy(u,a,{overwrite:!0,filter:F=>{let K=St.relative(u,F);return K?!K.split(St.sep).some(Y=>B.includes(Y)):!0}}),O(F=>(H(F.length+1),[...F,{id:Date.now(),role:"system",text:`\u2726 SUCCESS
111
111
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m playground content copied to ${a}
112
- `,isMeta:!0}]))}catch(D){O(F=>(H(F.length+1),[...F,{id:Date.now(),role:"system",text:`\u2726 FAILED TO MOVE CONTENT
113
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${D.message}
114
- `,isMeta:!0}]))}})();break}case"/clear":{if(s&&(s.write("\x1B[2J\x1B[3J\x1B[H"),s.isTTY&&(s.write("\x1B[?2004h"),process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07"))),O([{id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}]),H(1),us(u=>u+1),Co(),Vt.current={completedIndex:0,columns:_.columns,historicalBlocks:[],seenSelections:new Set,chatId:dt,clearKey:qo+1},Ee.playground){if(Ee.playground=!1,Er(fn).catch(()=>{}),Ee.originalCwd)try{process.chdir(Ee.originalCwd),O(u=>{let a=[...u,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND
115
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Restored Working Directory to ${Ee.originalCwd}
112
+ `,isMeta:!0}]))}catch(B){O(F=>(H(F.length+1),[...F,{id:Date.now(),role:"system",text:`\u2726 FAILED TO MOVE CONTENT
113
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${B.message}
114
+ `,isMeta:!0}]))}})();break}case"/clear":{if(s&&(s.write("\x1B[2J\x1B[3J\x1B[H"),s.isTTY&&(s.write("\x1B[?2004h"),process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07"))),O([{id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}]),H(1),us(u=>u+1),Co(),Vt.current={completedIndex:0,columns:_.columns,historicalBlocks:[],seenSelections:new Set,chatId:dt,clearKey:qo+1},ve.playground){if(ve.playground=!1,Er(fn).catch(()=>{}),ve.originalCwd)try{process.chdir(ve.originalCwd),O(u=>{let a=[...u,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND
115
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Restored Working Directory to ${ve.originalCwd}
116
116
  \u2800`,isMeta:!0}];return H(a.length),a})}catch{}setTimeout(()=>{et.emptyDir(St.join(mo,"playground")).catch(u=>{O(a=>{let p=[...a,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND
117
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Failed to clear session: ${mo+"/playground"}`,isMeta:!0}];return H(p.length),p})})},500),It(u=>({...u,allowExternalAccess:ts.current,memory:os.current}))}cr(Ts()),Io({tokens:0}),S(!1),sn(0),an(0),cn(0),ln.current=Yt,dn.current=eo,un.current=Yo,setTimeout(()=>{global.gc&&(async()=>{for(let a=0;a<3;a++)global.gc(),await new Promise(p=>setImmediate(p));m.current=Date.now()})()},500);break}case"/revert":{Vn.getChatHistory(dt).then(u=>{if(u.length>0)hi(u.reverse()),z("revert");else{let a=nt(2);O(p=>(H(p.length+1),[...p,{id:"revert-empty-"+Date.now(),role:"system",text:`\u2726 Nothing to revert to.
118
- \u2800`,isMeta:!0}]))}}),setTimeout(()=>{global.gc&&(async()=>{for(let a=0;a<3;a++)global.gc(),await new Promise(p=>setImmediate(p));m.current=Date.now()})()},500);break}case"/mode":{if(g[1]){let u=g[1].toLowerCase(),a="Flux";u==="flow"?a="Flow":u==="icu"?a="ICU":u==="fluxcu"?a="FluxCU":u==="flux"&&(a="Flux"),P(a),a==="Flow"&&Ce("Fast");let p=nt(2);O(D=>(H(D.length+1),[...D,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${Xs(a)}.
119
- \u2800`,isMeta:!0}]))}else z("mode");break}case"/display":{if(g[1]){let u=g[1].toLowerCase(),a=0;u==="secondary"||u==="1"||u==="2"?a=1:a=0,L(a),Pt({display:a}).catch(()=>{});let p=a===0?"Primary (Display 1)":"Secondary (Display 2)";O(D=>(H(D.length+1),[...D,{id:Date.now(),role:"system",text:`\u2726 Active Computer Use display set to: ${p}.
120
- \u2800`,isMeta:!0}]))}else z("display");break}case"/image_deprecated":{if(g[1]?.toLowerCase()==="stats"){let u=nt(2);if(ko.keyType==="Custom")O(a=>(H(a.length+1),[...a,{id:Date.now(),role:"system",text:"[SYSTEM] Key strategy is Custom. Redirecting to Pollinations dashboard (https://enter.pollinations.ai/#pollen)...",isMeta:!0}])),To("start https://enter.pollinations.ai/#pollen");else try{let a=await _i();O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",isImageStats:!0,text:`\u2022 Hourly Limit: ${Number((a.limit*1e3).toFixed(0))} credits
117
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Failed to clear session: ${mo+"/playground"}`,isMeta:!0}];return H(p.length),p})})},500),It(u=>({...u,allowExternalAccess:ts.current,memory:os.current}))}cr(ws()),Io({tokens:0}),S(!1),sn(0),an(0),cn(0),ln.current=Yt,dn.current=eo,un.current=Yo,setTimeout(()=>{global.gc&&(async()=>{for(let a=0;a<3;a++)global.gc(),await new Promise(p=>setImmediate(p));m.current=Date.now()})()},500);break}case"/revert":{Vn.getChatHistory(dt).then(u=>{if(u.length>0)hi(u.reverse()),z("revert");else{let a=nt(2);O(p=>(H(p.length+1),[...p,{id:"revert-empty-"+Date.now(),role:"system",text:`\u2726 Nothing to revert to.
118
+ \u2800`,isMeta:!0}]))}}),setTimeout(()=>{global.gc&&(async()=>{for(let a=0;a<3;a++)global.gc(),await new Promise(p=>setImmediate(p));m.current=Date.now()})()},500);break}case"/mode":{if(g[1]){let u=g[1].toLowerCase(),a="Flux";u==="flow"?a="Flow":u==="icu"?a="ICU":u==="fluxcu"?a="FluxCU":u==="flux"&&(a="Flux"),P(a),a==="Flow"&&Se("Fast");let p=nt(2);O(B=>(H(B.length+1),[...B,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${Xs(a)}.
119
+ \u2800`,isMeta:!0}]))}else z("mode");break}case"/display":{if(g[1]){let u=g[1].toLowerCase(),a=0;u==="secondary"||u==="1"||u==="2"?a=1:a=0,L(a),Pt({display:a}).catch(()=>{});let p=a===0?"Primary (Display 1)":"Secondary (Display 2)";O(B=>(H(B.length+1),[...B,{id:Date.now(),role:"system",text:`\u2726 Active Computer Use display set to: ${p}.
120
+ \u2800`,isMeta:!0}]))}else z("display");break}case"/image_deprecated":{if(g[1]?.toLowerCase()==="stats"){let u=nt(2);if(ko.keyType==="Custom")O(a=>(H(a.length+1),[...a,{id:Date.now(),role:"system",text:"[SYSTEM] Key strategy is Custom. Redirecting to Pollinations dashboard (https://enter.pollinations.ai/#pollen)...",isMeta:!0}])),wo("start https://enter.pollinations.ai/#pollen");else try{let a=await _i();O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",isImageStats:!0,text:`\u2022 Hourly Limit: ${Number((a.limit*1e3).toFixed(0))} credits
121
121
  \u2022 Spent (Last 1hr): ${Number((a.totalSpent*1e3).toFixed(0))} credits
122
122
  \u2022 Remaining: ${Number((a.remaining*1e3).toFixed(0))} credits
123
123
  \u2022 Requests (Last 1hr): ${a.activeCallsCount} requests
124
- `+(a.nextResetMin>0?`\u2022 Refreshes in: ${a.nextResetMin}m`:""),isMeta:!0}]))}catch{O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:"[SYSTEM] Failed to load image quota stats.",isMeta:!0}]))}}else if(g[1]?.toLowerCase()==="setup")if(g[2]?.toLowerCase()==="key")if(g[3]){let u=["default","custom"].find(a=>a===g[3].toLowerCase());if(u){let a=u==="default"?"Default":"Custom";sr(D=>({...D,keyType:a}));let p=nt(2);O(D=>(H(D.length+1),[...D,{id:Date.now(),role:"system",text:`[SYSTEM] Image key strategy set to ${a}`,isMeta:!0}])),a==="Custom"&&(Qt({label:"Enter Pollinations API key (starting with sk_):",note:"Get a key from https://enter.pollinations.ai",key:"imageSettings",subKey:"apiKey",value:ko.apiKey||"",returnView:"chat"}),z("input"))}else{let a=nt(2);O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:"[SYSTEM] Invalid key option. Choose: Default or Custom.",isMeta:!0}]))}}else{let u=nt(2);O(a=>(H(a.length+1),[...a,{id:Date.now(),role:"system",text:"[SYSTEM] Usage: /image setup Key <Default|Custom>",isMeta:!0}]))}else if(g[2]?.toLowerCase()==="quality")if(g[3]){let u=["low","low-high","medium","medium-high","high","ultra","premium"].find(a=>a===g[3].toLowerCase());if(u){let p={low:"Low","low-high":"Low-High",medium:"Medium","medium-high":"Medium-High",high:"High",ultra:"Ultra",premium:"Premium"}[u];sr(F=>({...F,quality:p}));let D=nt(2);O(F=>(H(F.length+1),[...F,{id:Date.now(),role:"system",text:`[SYSTEM] Image quality set to ${p}`,isMeta:!0}]))}else{let a=nt(2);O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:"[SYSTEM] Invalid quality level. Choose from: Low, Low-High, Medium, Medium-High, High, Ultra, Premium.",isMeta:!0}]))}}else{let u=nt(2);O(a=>(H(a.length+1),[...a,{id:Date.now(),role:"system",text:"[SYSTEM] Usage: /image setup Quality <Low|Low-High|Medium|Medium-High|High|Ultra>",isMeta:!0}]))}else{let u=nt(2);O(a=>(H(a.length+1),[...a,{id:Date.now(),role:"system",text:"[SYSTEM] Usage: /image setup <Key|Quality> ...",isMeta:!0}]))}else{let u=nt(2);O(a=>(H(a.length+1),[...a,{id:Date.now(),role:"system",text:"[SYSTEM] Usage: /image setup <Key|Quality> ...",isMeta:!0}]))}break}case"/thinking":{let u;if(g[1]){let a=g.slice(1),p=a.includes("--bypass"),D=a.includes("--force"),F=a.findIndex(V=>V==="--map"||V==="-m");if(F!==-1){let V=a.slice(0,F).join(" ").trim(),K=a.slice(F+1).join(" ").trim(),G=["fast","low","medium","standard","high","xhigh","custom","max"];if(!V||!K)O($=>(H($.length+1),[...$,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mINVALID USAGE\x1B[0m
124
+ `+(a.nextResetMin>0?`\u2022 Refreshes in: ${a.nextResetMin}m`:""),isMeta:!0}]))}catch{O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:"[SYSTEM] Failed to load image quota stats.",isMeta:!0}]))}}else if(g[1]?.toLowerCase()==="setup")if(g[2]?.toLowerCase()==="key")if(g[3]){let u=["default","custom"].find(a=>a===g[3].toLowerCase());if(u){let a=u==="default"?"Default":"Custom";sr(B=>({...B,keyType:a}));let p=nt(2);O(B=>(H(B.length+1),[...B,{id:Date.now(),role:"system",text:`[SYSTEM] Image key strategy set to ${a}`,isMeta:!0}])),a==="Custom"&&(Qt({label:"Enter Pollinations API key (starting with sk_):",note:"Get a key from https://enter.pollinations.ai",key:"imageSettings",subKey:"apiKey",value:ko.apiKey||"",returnView:"chat"}),z("input"))}else{let a=nt(2);O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:"[SYSTEM] Invalid key option. Choose: Default or Custom.",isMeta:!0}]))}}else{let u=nt(2);O(a=>(H(a.length+1),[...a,{id:Date.now(),role:"system",text:"[SYSTEM] Usage: /image setup Key <Default|Custom>",isMeta:!0}]))}else if(g[2]?.toLowerCase()==="quality")if(g[3]){let u=["low","low-high","medium","medium-high","high","ultra","premium"].find(a=>a===g[3].toLowerCase());if(u){let p={low:"Low","low-high":"Low-High",medium:"Medium","medium-high":"Medium-High",high:"High",ultra:"Ultra",premium:"Premium"}[u];sr(F=>({...F,quality:p}));let B=nt(2);O(F=>(H(F.length+1),[...F,{id:Date.now(),role:"system",text:`[SYSTEM] Image quality set to ${p}`,isMeta:!0}]))}else{let a=nt(2);O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:"[SYSTEM] Invalid quality level. Choose from: Low, Low-High, Medium, Medium-High, High, Ultra, Premium.",isMeta:!0}]))}}else{let u=nt(2);O(a=>(H(a.length+1),[...a,{id:Date.now(),role:"system",text:"[SYSTEM] Usage: /image setup Quality <Low|Low-High|Medium|Medium-High|High|Ultra>",isMeta:!0}]))}else{let u=nt(2);O(a=>(H(a.length+1),[...a,{id:Date.now(),role:"system",text:"[SYSTEM] Usage: /image setup <Key|Quality> ...",isMeta:!0}]))}else{let u=nt(2);O(a=>(H(a.length+1),[...a,{id:Date.now(),role:"system",text:"[SYSTEM] Usage: /image setup <Key|Quality> ...",isMeta:!0}]))}break}case"/thinking":{let u;if(g[1]){let a=g.slice(1),p=a.includes("--bypass"),B=a.includes("--force"),F=a.findIndex(V=>V==="--map"||V==="-m");if(F!==-1){let V=a.slice(0,F).join(" ").trim(),q=a.slice(F+1).join(" ").trim(),W=["fast","low","medium","standard","high","xhigh","custom","max"];if(!V||!q)O($=>(H($.length+1),[...$,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mINVALID USAGE\x1B[0m
125
125
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Usage: \x1B[36m/thinking <level> --map <target_value>\x1B[0m (e.g. \x1B[33m/thinking Custom --map high\x1B[0m)
126
- \u2800`,isMeta:!0}]));else if(!G.includes(V.toLowerCase()))O($=>(H($.length+1),[...$,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mUNKNOWN LEVEL\x1B[0m
126
+ \u2800`,isMeta:!0}]));else if(!W.includes(V.toLowerCase()))O($=>(H($.length+1),[...$,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mUNKNOWN LEVEL\x1B[0m
127
127
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Unknown level "\x1B[33m${V}\x1B[0m" to map. Available: \x1B[36mLow, Medium, High, Custom\x1B[0m.
128
- \u2800`,isMeta:!0}]));else if(K.toLowerCase()==="rm"||K.toLowerCase()==="--remove"||K.toLowerCase()==="-rm"){let $=V.toLowerCase()==="custom"?"xHigh":V,_e=qi(B,He,$);_e.success?O(Pe=>(H(Pe.length+1),[...Pe,{id:Date.now(),role:"system",text:`\u2726 Thinking Level Mapping Removed:
129
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Target: \x1B[36m${B}::${He}\x1B[0m
128
+ \u2800`,isMeta:!0}]));else if(q.toLowerCase()==="rm"||q.toLowerCase()==="--remove"||q.toLowerCase()==="-rm"){let $=V.toLowerCase()==="custom"?"xHigh":V,_e=qi(D,Ge,$);_e.success?O(Pe=>(H(Pe.length+1),[...Pe,{id:Date.now(),role:"system",text:`\u2726 Thinking Level Mapping Removed:
129
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Target: \x1B[36m${D}::${Ge}\x1B[0m
130
130
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Removed mapping for: \x1B[33m${V}\x1B[0m
131
131
  \u2800`,isMeta:!0}])):O(Pe=>(H(Pe.length+1),[...Pe,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mFAILED TO REMOVE MAPPING\x1B[0m
132
132
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${_e.reason}
133
- \u2800`,isMeta:!0}]))}else{let $=V.toLowerCase()==="custom"?"xHigh":V,_e=isNaN(Number(K))?K:Number(K),Pe=Ki(B,He,$,_e);Pe.success?O(Oe=>(H(Oe.length+1),[...Oe,{id:Date.now(),role:"system",text:`\u2726 Thinking Level Mapped:
134
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Target: \x1B[36m${B}::${He}\x1B[0m
135
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Mapping: \x1B[33m${V}\x1B[0m \u2794 \x1B[32m${K}\x1B[0m
133
+ \u2800`,isMeta:!0}]))}else{let $=V.toLowerCase()==="custom"?"xHigh":V,_e=isNaN(Number(q))?q:Number(q),Pe=Ki(D,Ge,$,_e);Pe.success?O(Oe=>(H(Oe.length+1),[...Oe,{id:Date.now(),role:"system",text:`\u2726 Thinking Level Mapped:
134
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Target: \x1B[36m${D}::${Ge}\x1B[0m
135
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Mapping: \x1B[33m${V}\x1B[0m \u2794 \x1B[32m${q}\x1B[0m
136
136
  \u2800`,isMeta:!0}])):O(Oe=>(H(Oe.length+1),[...Oe,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mFAILED TO SAVE MAPPING\x1B[0m
137
137
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${Pe.reason}
138
- \u2800`,isMeta:!0}]))}break}let Q=a[0].toLowerCase();if(!["fast","low","medium","standard","high","xhigh","custom","max"].includes(Q)){O(V=>(H(V.length+1),[...V,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mUNKNOWN THINKING LEVEL\x1B[0m
138
+ \u2800`,isMeta:!0}]))}break}let K=a[0].toLowerCase();if(!["fast","low","medium","standard","high","xhigh","custom","max"].includes(K)){O(V=>(H(V.length+1),[...V,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mUNKNOWN THINKING LEVEL\x1B[0m
139
139
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Level "\x1B[33m${a[0]}\x1B[0m" is not supported. Available levels: \x1B[36mLow, Medium, High, Custom\x1B[0m.
140
- \u2800`,isMeta:!0}]));break}if(Q==="standard"&&(Q="medium"),(Q==="max"||Q==="custom")&&(Q="xhigh"),u=Q.charAt(0).toUpperCase()+Q.slice(1),Q==="xhigh"&&(u="xHigh"),u==="xHigh"&&!(Ht(B,He,"xHigh")!==null)){O(K=>(H(K.length+1),[...K,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mCUSTOM LEVEL NOT MAPPED\x1B[0m
140
+ \u2800`,isMeta:!0}]));break}if(K==="standard"&&(K="medium"),(K==="max"||K==="custom")&&(K="xhigh"),u=K.charAt(0).toUpperCase()+K.slice(1),K==="xhigh"&&(u="xHigh"),u==="xHigh"&&!(Ht(D,Ge,"xHigh")!==null)){O(q=>(H(q.length+1),[...q,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mCUSTOM LEVEL NOT MAPPED\x1B[0m
141
141
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Custom Effort level is not mapped. Use \x1B[36m/thinking custom --map <target_value>\x1B[0m first.
142
- \u2800`,isMeta:!0}]));break}let Y="";if(D&&(process.env.NVIDIA_BASE_URL,Y=`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Enabled Forced Reasoning.
142
+ \u2800`,isMeta:!0}]));break}let Y="";if(B&&(process.env.NVIDIA_BASE_URL,Y=`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Enabled Forced Reasoning.
143
143
  \u2800`,process.env.forcedReasoning="true"),!p&&C==="Flow"&&u==="xHigh")O(V=>(H(V.length+1),[...V,{id:Date.now(),role:"system",text:`\u2726 RESTRICTED
144
144
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m"${u}" is restricted in Flow mode. Switch to Flux to enable Higher Thinking Levels.
145
- \u2800${Y}.`,isMeta:!0}]));else{Ce(u);let V=nt(1),K=u==="xHigh"?Ht(B,He,"xHigh")!==null?`Custom (${Ht(B,He,"xHigh")})`:"Custom":u;O(G=>(H(G.length+1),[...G,{id:Date.now(),role:"system",text:`\u2726 ${B}
146
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${He}.
147
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Thinking Level: ${K}.
148
- ${Y} \u2800`,isMeta:!0}]))}}else z("thinking");break}case"/model":{if(g[1]){let u=g.slice(1),a=u.some(V=>V==="--multimodal"||V==="-m"),p=u.some(V=>V==="--save"||V==="-sv"||V==="--add"),D=u.some(V=>V==="--remove"||V==="-rm"),F=u.some(V=>V==="--rename"||V==="-rn"||V==="-mv"),Q=u.some(V=>V==="--default"||V==="-df");if(p||D||F||Q){let V=u.filter(K=>!["--save","-sv","--add","--remove","-rm","--rename","-rn","-mv","--default","-df","--multimodal","-m"].includes(K));if(Q){let K=V.join(" ").trim();if(!K)O(G=>(H(G.length+1),[...G,{id:Date.now(),role:"system",text:"\x1B[31m[Error]\x1B[0m Please provide a model ID to set as default. Example: /model my-model --default",isMeta:!0}]));else{let G=Ii(B,K,a);G.success?O($=>(H($.length+1),[...$,{id:Date.now(),role:"system",text:`\u2726 Default Model Set:
149
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${B}
150
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Default Model: \x1B[32m${K}\x1B[0m
145
+ \u2800${Y}.`,isMeta:!0}]));else{Se(u);let V=nt(1),q=u==="xHigh"?Ht(D,Ge,"xHigh")!==null?`Custom (${Ht(D,Ge,"xHigh")})`:"Custom":u;O(W=>(H(W.length+1),[...W,{id:Date.now(),role:"system",text:`\u2726 ${D}
146
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${Ge}.
147
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Thinking Level: ${q}.
148
+ ${Y} \u2800`,isMeta:!0}]))}}else z("thinking");break}case"/model":{if(g[1]){let u=g.slice(1),a=u.some(V=>V==="--multimodal"||V==="-m"),p=u.some(V=>V==="--save"||V==="-sv"||V==="--add"),B=u.some(V=>V==="--remove"||V==="-rm"),F=u.some(V=>V==="--rename"||V==="-rn"||V==="-mv"),K=u.some(V=>V==="--default"||V==="-df");if(p||B||F||K){let V=u.filter(q=>!["--save","-sv","--add","--remove","-rm","--rename","-rn","-mv","--default","-df","--multimodal","-m"].includes(q));if(K){let q=V.join(" ").trim();if(!q)O(W=>(H(W.length+1),[...W,{id:Date.now(),role:"system",text:"\x1B[31m[Error]\x1B[0m Please provide a model ID to set as default. Example: /model my-model --default",isMeta:!0}]));else{let W=Ii(D,q,a);W.success?O($=>(H($.length+1),[...$,{id:Date.now(),role:"system",text:`\u2726 Default Model Set:
149
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${D}
150
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Default Model: \x1B[32m${q}\x1B[0m
151
151
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Multimodal: ${a?"ON":"OFF"}
152
- \u2800`,isMeta:!0}])):O($=>(H($.length+1),[...$,{id:Date.now(),role:"system",text:`\x1B[31m[Error]\x1B[0m Failed to set default model: ${G.reason}`,isMeta:!0}]))}}else if(p){let K=V.join(" ").trim();if(!K)O(G=>(H(G.length+1),[...G,{id:Date.now(),role:"system",text:"\x1B[31m[Error]\x1B[0m Please provide a model ID to save. Example: /model my-custom-model --save",isMeta:!0}]));else{let G=Bi(B,K,a);G.success?O($=>(H($.length+1),[...$,{id:Date.now(),role:"system",text:`\u2726 Model Saved:
153
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${B}
154
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: \x1B[32m${K}\x1B[0m
152
+ \u2800`,isMeta:!0}])):O($=>(H($.length+1),[...$,{id:Date.now(),role:"system",text:`\x1B[31m[Error]\x1B[0m Failed to set default model: ${W.reason}`,isMeta:!0}]))}}else if(p){let q=V.join(" ").trim();if(!q)O(W=>(H(W.length+1),[...W,{id:Date.now(),role:"system",text:"\x1B[31m[Error]\x1B[0m Please provide a model ID to save. Example: /model my-custom-model --save",isMeta:!0}]));else{let W=Di(D,q,a);W.success?O($=>(H($.length+1),[...$,{id:Date.now(),role:"system",text:`\u2726 Model Saved:
153
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${D}
154
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: \x1B[32m${q}\x1B[0m
155
155
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Multimodal: ${a?"ON":"OFF"}
156
- \u2800`,isMeta:!0}])):O($=>(H($.length+1),[...$,{id:Date.now(),role:"system",text:`\x1B[31m[Error]\x1B[0m Failed to save model: ${G.reason}`,isMeta:!0}]))}}else if(D){let K=V.join(" ").trim();if(!K)O(G=>(H(G.length+1),[...G,{id:Date.now(),role:"system",text:"\x1B[31m[Error]\x1B[0m Please provide a model ID to remove. Example: /model my-custom-model --remove",isMeta:!0}]));else{let G=Ai(B,K);G.success?O($=>(H($.length+1),[...$,{id:Date.now(),role:"system",text:`\u2726 Model Removed:
157
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${B}
158
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: \x1B[31m${K}\x1B[0m
159
- \u2800`,isMeta:!0}])):O($=>(H($.length+1),[...$,{id:Date.now(),role:"system",text:`\x1B[31m[Error]\x1B[0m Failed to remove model: ${G.reason}`,isMeta:!0}]))}}else if(F)if(V.length<2)O(K=>(H(K.length+1),[...K,{id:Date.now(),role:"system",text:"\x1B[31m[Error]\x1B[0m Please provide both old and new model IDs. Example: /model old-model-id new-model-id --rename",isMeta:!0}]));else{let K=V[0].trim(),G=V.slice(1).join(" ").trim(),$=Li(B,K,G);$.success?O(_e=>(H(_e.length+1),[..._e,{id:Date.now(),role:"system",text:`\u2726 Model Renamed:
160
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${B}
161
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Old Model: \x1B[31m${K}\x1B[0m
162
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m New Model: \x1B[32m${G}\x1B[0m
163
- \u2800`,isMeta:!0}])):O(_e=>(H(_e.length+1),[..._e,{id:Date.now(),role:"system",text:`\x1B[31m[Error]\x1B[0m Failed to rename model: ${$.reason}`,isMeta:!0}]))}break}let Y=u.filter(V=>V!=="--multimodal"&&V!=="-m").join(" ").trim();if(Pi(a),Y){a&&ki(B,Y,!0);let V=go("Google","Free"),K=go("Google","Paid");{Rt(Y);let G=a||yr(Y),$=ce==="xHigh"?Ht(B,Y,"xHigh")!==null?`Custom (${Ht(B,Y,"xHigh")})`:"Custom":ce;O(_e=>(H(_e.length+1),[..._e,{id:Date.now(),role:"system",text:`\u2726 ${B}
156
+ \u2800`,isMeta:!0}])):O($=>(H($.length+1),[...$,{id:Date.now(),role:"system",text:`\x1B[31m[Error]\x1B[0m Failed to save model: ${W.reason}`,isMeta:!0}]))}}else if(B){let q=V.join(" ").trim();if(!q)O(W=>(H(W.length+1),[...W,{id:Date.now(),role:"system",text:"\x1B[31m[Error]\x1B[0m Please provide a model ID to remove. Example: /model my-custom-model --remove",isMeta:!0}]));else{let W=Ai(D,q);W.success?O($=>(H($.length+1),[...$,{id:Date.now(),role:"system",text:`\u2726 Model Removed:
157
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${D}
158
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: \x1B[31m${q}\x1B[0m
159
+ \u2800`,isMeta:!0}])):O($=>(H($.length+1),[...$,{id:Date.now(),role:"system",text:`\x1B[31m[Error]\x1B[0m Failed to remove model: ${W.reason}`,isMeta:!0}]))}}else if(F)if(V.length<2)O(q=>(H(q.length+1),[...q,{id:Date.now(),role:"system",text:"\x1B[31m[Error]\x1B[0m Please provide both old and new model IDs. Example: /model old-model-id new-model-id --rename",isMeta:!0}]));else{let q=V[0].trim(),W=V.slice(1).join(" ").trim(),$=Li(D,q,W);$.success?O(_e=>(H(_e.length+1),[..._e,{id:Date.now(),role:"system",text:`\u2726 Model Renamed:
160
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${D}
161
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Old Model: \x1B[31m${q}\x1B[0m
162
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m New Model: \x1B[32m${W}\x1B[0m
163
+ \u2800`,isMeta:!0}])):O(_e=>(H(_e.length+1),[..._e,{id:Date.now(),role:"system",text:`\x1B[31m[Error]\x1B[0m Failed to rename model: ${$.reason}`,isMeta:!0}]))}break}let Y=u.filter(V=>V!=="--multimodal"&&V!=="-m").join(" ").trim();if(Pi(a),Y){a&&ki(D,Y,!0);let V=go("Google","Free"),q=go("Google","Paid");{Rt(Y);let W=a||yr(Y),$=ce==="xHigh"?Ht(D,Y,"xHigh")!==null?`Custom (${Ht(D,Y,"xHigh")})`:"Custom":ce;O(_e=>(H(_e.length+1),[..._e,{id:Date.now(),role:"system",text:`\u2726 ${D}
164
164
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${Y}
165
165
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Thinking Level: ${$}
166
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Multimodal: ${G?"ON":"OFF"}
166
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Multimodal: ${W?"ON":"OFF"}
167
167
  \u2800`,isMeta:!0}]))}}}else z("model");break}case"/wildcard-tooling":{ue(u=>{let a=!u;return O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 Wildcard Tooling:
168
168
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Status: ${a?"Enabled":"Disabled"}
169
169
  \u2800`,isMeta:!0}])),a});break}case"/wildercard-tooling":{U(u=>{let a=!u;return O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 Wildercard Tooling:
170
170
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Status: ${a?"Enabled":"Disabled"}
171
- \u2800`,isMeta:!0}])),a});break}case"/settings":{z("settings");break}case"/provider":case"/providers":{Wr("chat"),z("selectProvider");break}case"/theme":{z("theme");break}case"/key":{z("key");break}case"/profile":{z("profile");break}case"/stats":{(async()=>{let a=await Mr(),p=await Sr();zr(a),Qr(p),Ln("daily"),z("stats")})();break}case"/usage":{(async()=>{try{let{url:a}=await ps();O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 Launching Token Analytics Dashboard
171
+ \u2800`,isMeta:!0}])),a});break}case"/settings":{z("settings");break}case"/provider":case"/providers":{Gr("chat"),z("selectProvider");break}case"/theme":{z("theme");break}case"/key":{z("key");break}case"/profile":{z("profile");break}case"/stats":{(async()=>{let a=await Mr(),p=await Sr();zr(a),Qr(p),Ln("daily"),z("stats")})();break}case"/usage":{(async()=>{try{let{url:a}=await ps();O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 Launching Token Analytics Dashboard
172
172
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Serving at ${a}
173
173
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Opening in your default browser...
174
174
  \u2800`,isMeta:!0}]))}catch(a){O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 ERROR
175
175
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Failed to launch dashboard: ${a.message}
176
- \u2800`,isMeta:!0}]))}})();break}case"/save":{let u,a=wt.find(D=>D.role==="user");if(a&&a.text){let D=a.text.replace(/\s*\n+\s*\[Prompted on:.*?\]/g,"").trim(),F=D.split(/\s+/),Q;F.length>7?Q=F.slice(0,7).join(" ")+"...":D.length>45?Q=D.substring(0,45).trimEnd()+"...":Q=D,u=Q}let p=g.slice(1).join(" ")||u||`Session ${new Date().toLocaleTimeString()}`;Cn(dt,p,wt),O(D=>(H(D.length+1),[...D,{id:Date.now(),role:"system",text:`\u2726 Saved
176
+ \u2800`,isMeta:!0}]))}})();break}case"/save":{let u,a=Tt.find(B=>B.role==="user");if(a&&a.text){let B=a.text.replace(/\s*\n+\s*\[Prompted on:.*?\]/g,"").trim(),F=B.split(/\s+/),K;F.length>7?K=F.slice(0,7).join(" ")+"...":B.length>45?K=B.substring(0,45).trimEnd()+"...":K=B,u=K}let p=g.slice(1).join(" ")||u||`Session ${new Date().toLocaleTimeString()}`;Cn(dt,p,Tt),O(B=>(H(B.length+1),[...B,{id:Date.now(),role:"system",text:`\u2726 Saved
177
177
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m "${p}" (ID: ${dt})
178
- \u2800`,isMeta:!0}]));break}case"/export":{(async()=>{try{let a=await Hi(g,{chatId:dt,messages:wt});O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:a.message,isMeta:!0}]))}catch(a){O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:`[EXPORT ERROR] Failed to export: ${a.message}`,isMeta:!0}]))}})();break}case"/chats":{(async()=>{let a=await Fo(),p=Object.entries(a).sort((D,F)=>(F[1].updatedAt||0)-(D[1].updatedAt||0)).map(([D,F])=>`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${D}: ${F.name}${D===dt?" (current)":""}`).join(`
179
- `);O(D=>(H(D.length+1),[...D,{id:Date.now(),role:"system",text:`\u2726 Saved Chats:
178
+ \u2800`,isMeta:!0}]));break}case"/export":{(async()=>{try{let a=await Hi(g,{chatId:dt,messages:Tt});O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:a.message,isMeta:!0}]))}catch(a){O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:`[EXPORT ERROR] Failed to export: ${a.message}`,isMeta:!0}]))}})();break}case"/chats":{(async()=>{let a=await Fo(),p=Object.entries(a).sort((B,F)=>(F[1].updatedAt||0)-(B[1].updatedAt||0)).map(([B,F])=>`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${B}: ${F.name}${B===dt?" (current)":""}`).join(`
179
+ `);O(B=>(H(B.length+1),[...B,{id:Date.now(),role:"system",text:`\u2726 Saved Chats:
180
180
  ${p||"\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No saved chats found."}
181
- \u2800`,isMeta:!0}]))})();break}case"/memory":{if((g[1]||"view").toLowerCase()==="migrate")try{let a=wr(Gn,[]);if(!a||a.length===0){O(K=>(H(K.length+1),[...K,{id:Date.now(),role:"system",text:`\u2726 Memory Migration
181
+ \u2800`,isMeta:!0}]))})();break}case"/memory":{if((g[1]||"view").toLowerCase()==="migrate")try{let a=Tr(Wn,[]);if(!a||a.length===0){O(q=>(H(q.length+1),[...q,{id:Date.now(),role:"system",text:`\u2726 Memory Migration
182
182
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No persistent memories found in memories.json to migrate.
183
- \u2800`,isMeta:!0}]));break}let p=a.map(K=>`- ${(K.memory||"").replace(/\[Saved on: .*?\]/g,"").replace(/\\+'/g,"'").trim()}`).filter(K=>K!=="- ").join(`
184
- `);if(!p){O(K=>(H(K.length+1),[...K,{id:Date.now(),role:"system",text:`\u2726 Memory Migration
183
+ \u2800`,isMeta:!0}]));break}let p=a.map(q=>`- ${(q.memory||"").replace(/\[Saved on: .*?\]/g,"").replace(/\\+'/g,"'").trim()}`).filter(q=>q!=="- ").join(`
184
+ `);if(!p){O(q=>(H(q.length+1),[...q,{id:Date.now(),role:"system",text:`\u2726 Memory Migration
185
185
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No valid memory entries found to migrate.
186
- \u2800`,isMeta:!0}]));break}et.existsSync(ro)||et.mkdirSync(ro,{recursive:!0});let D=St.join(ro,"AGENTS.md"),F="";et.existsSync(D)&&(F=et.readFileSync(D,"utf8"));let Q=F.trimEnd(),Y=`${Q.length>0?`
186
+ \u2800`,isMeta:!0}]));break}et.existsSync(ro)||et.mkdirSync(ro,{recursive:!0});let B=St.join(ro,"AGENTS.md"),F="";et.existsSync(B)&&(F=et.readFileSync(B,"utf8"));let K=F.trimEnd(),Y=`${K.length>0?`
187
187
 
188
188
  `:""}User Memories:
189
189
  ${p}
190
- `,V=`${Q}${Y}`;et.writeFileSync(D,V,"utf8"),O(K=>(H(K.length+1),[...K,{id:Date.now(),role:"system",text:`\u2726 Memory Migration
191
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Successfully migrated ${a.length} memories to ${D.replaceAll("\\\\","/").replaceAll("\\","/")}
190
+ `,V=`${K}${Y}`;et.writeFileSync(B,V,"utf8"),O(q=>(H(q.length+1),[...q,{id:Date.now(),role:"system",text:`\u2726 Memory Migration
191
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Successfully migrated ${a.length} memories to ${B.replaceAll("\\\\","/").replaceAll("\\","/")}
192
192
  \u2800`,isMeta:!0}]))}catch(a){O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 Memory Migration Failed
193
193
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Error: ${a.message}
194
194
  \u2800`,isMeta:!0}]))}else z("memory");break}case"/files":{O(u=>(H(u.length+1),[...u,{id:"files-"+Date.now(),role:"system",text:zi(),isMeta:!0}]));break}case"/target":{O(u=>(H(u.length+1),[...u,{id:"target-"+Date.now(),role:"system",text:`\u2726 Unique Model Id for FluxFlow
195
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${B}::${He}
195
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${D}::${Ge}
196
196
  \u2800`,isMeta:!0}]));break}case"/reset":{(async()=>{try{O(a=>(H(a.length+1),[...a,{id:Date.now(),role:"system",text:`\u2726 Initiating reset...
197
197
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Clearing logs, secrets, and settings.
198
198
  \u2800`,isMeta:!0}])),et.existsSync(ms)&&et.removeSync(ms),et.existsSync(gs)&&et.removeSync(gs),et.existsSync(zo)&&et.removeSync(zo);try{et.readdirSync(ro).length===0&&et.removeSync(ro)}catch{}setTimeout(()=>{z("exit"),setTimeout(()=>process.exit(0),500)},500)}catch(a){O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 ERROR
199
199
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Failed to clear data: ${a.message}.
200
200
  \u2800`}]))}})();break}case"/about":{let u=nt(2),a=`\u2022 FluxFlow Version: v${ao}
201
- \u2022 Status: ${Wt&&Wt!==ao?`Update Available [v${Wt}]`:"Up to date"}
202
- \u2022 Released on: ${nc}`;O(p=>(H(p.length+1),[...p,{id:"about-"+Date.now(),role:"system",text:a,isAboutRecord:!0,isMeta:!0}]));break}case"/changelog":{let u=process.platform;To(`${u==="win32"?"start":u==="darwin"?"open":"xdg-open"} ${$l}`),O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 Opening Changelog
203
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${$l}.`,isMeta:!0}]));break}case"/docs":{if(!Ws){O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 ERROR
204
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Documentation URL is not configured.`,isMeta:!0}]));break}let u=process.platform;To(`${u==="win32"?"start":u==="darwin"?"open":"xdg-open"} ${Ws}`),O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 Opening Documentation
205
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${Ws}.
206
- \u2800`,isMeta:!0}]));break}case"/budget":{let u=g[1]?.toLowerCase();if(u==="web"||u==="gui"||u==="dashboard")(async()=>{try{let{url:p}=await ps();O(D=>(H(D.length+1),[...D,{id:Date.now(),role:"system",text:`\u2726 Token Usage & Budget Dashboard
201
+ \u2022 Status: ${Gt&&Gt!==ao?`Update Available [v${Gt}]`:"Up to date"}
202
+ \u2022 Released on: ${nc}`;O(p=>(H(p.length+1),[...p,{id:"about-"+Date.now(),role:"system",text:a,isAboutRecord:!0,isMeta:!0}]));break}case"/changelog":{let u=process.platform;wo(`${u==="win32"?"start":u==="darwin"?"open":"xdg-open"} ${$l}`),O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 Opening Changelog
203
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${$l}.`,isMeta:!0}]));break}case"/docs":{if(!Gs){O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 ERROR
204
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Documentation URL is not configured.`,isMeta:!0}]));break}let u=process.platform;wo(`${u==="win32"?"start":u==="darwin"?"open":"xdg-open"} ${Gs}`),O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 Opening Documentation
205
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${Gs}.
206
+ \u2800`,isMeta:!0}]));break}case"/budget":{let u=g[1]?.toLowerCase();if(u==="web"||u==="gui"||u==="dashboard")(async()=>{try{let{url:p}=await ps();O(B=>(H(B.length+1),[...B,{id:Date.now(),role:"system",text:`\u2726 Token Usage & Budget Dashboard
207
207
  \u2800\u2800\u2514\u2500 Opened at ${p}
208
- \u2800`,isMeta:!0}]))}catch(p){O(D=>(H(D.length+1),[...D,{id:Date.now(),role:"system",text:`\u2726 ERROR: Failed to launch dashboard: ${p.message}
209
- \u2800`,isMeta:!0}]))}})();else if(u==="set")Xl("chat"),z("budgetTypeSelect");else if(u==="view")(async()=>{let p=await Mr(),D=await Sr(),F=await hs(Le.resetDay||1);zr(p),Qr(D),ri(F),z("budgetView")})();else if(u==="reset"){let a={limitMode:"Daily",agentLimit:99999999,tokenLimit:99999999999999,backgroundLimit:999999,searchLimit:100,customModelId:"",customLimit:0,providerBudgets:{},providerTiers:{Google:"Free",DeepSeek:"Free",NVIDIA:"Free",OpenRouter:"Free",InferX:"Free",SenseNova:"Free",AIHubMix:"Free",Poolside:"Free",ExpLabs:"Free",TokenHarbor:"Free",APInex:"Free"}};_t(a),Go("Free"),Pt({apiTier:"Free",quotas:a}),O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 Budgets reset successfully.
208
+ \u2800`,isMeta:!0}]))}catch(p){O(B=>(H(B.length+1),[...B,{id:Date.now(),role:"system",text:`\u2726 ERROR: Failed to launch dashboard: ${p.message}
209
+ \u2800`,isMeta:!0}]))}})();else if(u==="set")Xl("chat"),z("budgetTypeSelect");else if(u==="view")(async()=>{let p=await Mr(),B=await Sr(),F=await hs(Le.resetDay||1);zr(p),Qr(B),ri(F),z("budgetView")})();else if(u==="reset"){let a={limitMode:"Daily",agentLimit:99999999,tokenLimit:99999999999999,backgroundLimit:999999,searchLimit:100,customModelId:"",customLimit:0,providerBudgets:{},providerTiers:{Google:"Free",DeepSeek:"Free",NVIDIA:"Free",OpenRouter:"Free",InferX:"Free",SenseNova:"Free",AIHubMix:"Free",Poolside:"Free",ExpLabs:"Free",TokenHarbor:"Free",APInex:"Free"}};_t(a),Wo("Free"),Pt({apiTier:"Free",quotas:a}),O(p=>(H(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 Budgets reset successfully.
210
210
  \u2800`,isMeta:!0}]))}else O(a=>(H(a.length+1),[...a,{id:Date.now(),role:"system",text:`\u2726 ERROR
211
211
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Usage: /budget <View|Web|Set|Reset>.
212
- \u2800`,isMeta:!0}]));break}case"/fluxflow":{let a=g.slice(1)[0]?.toLowerCase()?.trim();if(a==="global"){let p=St.normalize(ro);try{et.ensureDirSync(p)}catch{}let D=process.platform;D==="win32"?To(`explorer "${p}"`):D==="darwin"?To(`open "${p}"`):To(`xdg-open "${p}"`)}else if(a==="saves"){let p=St.normalize(mo);try{et.ensureDirSync(p)}catch{p=St.normalize(ro);try{et.ensureDirSync(p)}catch{}}let D=process.platform;D==="win32"?To(`explorer "${p}"`):D==="darwin"?To(`open "${p}"`):To(`xdg-open "${p}"`)}else O(p=>(H(p.length+1),[...p,{id:"ff-err-"+Date.now(),role:"system",text:"Usage: /fluxflow global/saves",isMeta:!0}]));break}case"/update":{if(g[1]?.toLowerCase()==="check"){oe(!0);break}let a=g.includes("--latest");z("update");break}case"/gemini":{let u=Us[Math.floor(Math.random()*Us.length)];O(a=>(H(a.length+1),[...a,{id:Date.now(),role:"system",text:`\u2728 GEMINI CLI
212
+ \u2800`,isMeta:!0}]));break}case"/fluxflow":{let a=g.slice(1)[0]?.toLowerCase()?.trim();if(a==="global"){let p=St.normalize(ro);try{et.ensureDirSync(p)}catch{}let B=process.platform;B==="win32"?wo(`explorer "${p}"`):B==="darwin"?wo(`open "${p}"`):wo(`xdg-open "${p}"`)}else if(a==="saves"){let p=St.normalize(mo);try{et.ensureDirSync(p)}catch{p=St.normalize(ro);try{et.ensureDirSync(p)}catch{}}let B=process.platform;B==="win32"?wo(`explorer "${p}"`):B==="darwin"?wo(`open "${p}"`):wo(`xdg-open "${p}"`)}else O(p=>(H(p.length+1),[...p,{id:"ff-err-"+Date.now(),role:"system",text:"Usage: /fluxflow global/saves",isMeta:!0}]));break}case"/update":{if(g[1]?.toLowerCase()==="check"){oe(!0);break}let a=g.includes("--latest");z("update");break}case"/gemini":{let u=Us[Math.floor(Math.random()*Us.length)];O(a=>(H(a.length+1),[...a,{id:Date.now(),role:"system",text:`\u2728 GEMINI CLI
213
213
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${u}
214
- \u2800`}])),f("");break}case"/compress":{f("");let u=wt.filter(D=>(D.role==="user"||D.role==="agent"||D.role==="system")&&!String(D.id).startsWith("welcome")&&!D.isMeta).length,a=co?.tokens||0;if(u<64||a<16384){let D=nt(2);O(F=>(H(F.length+1),[...F,{id:Date.now(),role:"system",text:`\u2726 Compression skipped
214
+ \u2800`}])),f("");break}case"/compress":{f("");let u=Tt.filter(B=>(B.role==="user"||B.role==="agent"||B.role==="system")&&!String(B.id).startsWith("welcome")&&!B.isMeta).length,a=co?.tokens||0;if(u<64||a<16384){let B=nt(2);O(F=>(H(F.length+1),[...F,{id:Date.now(),role:"system",text:`\u2726 Compression skipped
215
215
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m History requires at least 64 messages and 16k tokens
216
216
  \u2800\u2800 \u2514\u2500 Current: ${u}/64 msgs, ${a}/16384 tokens.
217
- \u2800`,isMeta:!0}]));break}(async()=>{gi(!0);let D=nt(2);O(F=>(H(F.length+1),[...F,{id:Date.now(),role:"system",text:"\u2726 Compacting session history...",isMeta:!0}]));try{if(await sl({chatId:dt,aiProvider:B,apiKey:kt,thinkingLevel:ce,mode:C,janitorModel:ye,systemSettings:xe,sessionStats:co},wt)){let de=nt(2);O(Y=>{let V=[...Y,{id:Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Chat History compacted saving tokens.
217
+ \u2800`,isMeta:!0}]));break}(async()=>{gi(!0);let B=nt(2);O(F=>(H(F.length+1),[...F,{id:Date.now(),role:"system",text:"\u2726 Compacting session history...",isMeta:!0}]));try{if(await sl({chatId:dt,aiProvider:D,apiKey:kt,thinkingLevel:ce,mode:C,janitorModel:Ee,systemSettings:xe,sessionStats:co},Tt)){let de=nt(2);O(Y=>{let V=[...Y,{id:Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Chat History compacted saving tokens.
218
218
  \u2800`,isMeta:!0}];return H(V.length),V})}else O(de=>(H(de.length+1),[...de,{id:Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Compaction failed.
219
- \u2800`,isMeta:!0}]))}catch(F){O(Q=>(H(Q.length+1),[...Q,{id:Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Error during compaction: ${F.message}
220
- \u2800`,isMeta:!0}]))}finally{gi(!1)}})();break}case"/truncate":{f("");let u=0;O(a=>{let D=[...a.map(F=>{let Q=F.fullText||F.text||"";return!Q.startsWith("[TOOL RESULT]:")||Q.startsWith("[TOOL RESULT]: ERROR")||Q.startsWith("[TOOL RESULT]: DENIED")||Q.startsWith("[TOOL RESULT]: SUCCESS: Goal")||Q.includes("...Success result truncated to save tokens")?F:(u++,{...F,fullText:"[TOOL RESULT]: ...Success result truncated to save tokens"})}),{id:Date.now(),role:"system",text:`\u2726 Tool Truncation...
219
+ \u2800`,isMeta:!0}]))}catch(F){O(K=>(H(K.length+1),[...K,{id:Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Error during compaction: ${F.message}
220
+ \u2800`,isMeta:!0}]))}finally{gi(!1)}})();break}case"/truncate":{f("");let u=0;O(a=>{let B=[...a.map(F=>{let K=F.fullText||F.text||"";return!K.startsWith("[ACTION RESULT]:")&&!K.startsWith("[TOOL RESULT]:")||K.startsWith("[ACTION RESULT]: ERROR")||K.startsWith("[TOOL RESULT]: ERROR")||K.startsWith("[ACTION RESULT]: DENIED")||K.startsWith("[TOOL RESULT]: DENIED")||K.startsWith("[ACTION RESULT]: SUCCESS: Goal")||K.startsWith("[TOOL RESULT]: SUCCESS: Goal")||K.includes("...Success result truncated to save tokens")?F:(u++,{...F,fullText:"[ACTION RESULT]: ...Success result truncated to save tokens"})}),{id:Date.now(),role:"system",text:`\u2726 Tool Truncation...
221
221
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Truncated ${u} tool result(s).
222
- \u2800`,isMeta:!0}];return Cn(dt,null,D),H(D.length),D});break}case"/help":{O(u=>(H(u.length+1),[...u,{id:Date.now(),role:"system",isHelpRecord:!0,isMeta:!0}]));break}case"/btw":{O(u=>(H(u.length+1),[...u,{id:Date.now(),role:"system",text:`\u2726 RESTRICTED
222
+ \u2800`,isMeta:!0}];return Cn(dt,null,B),H(B.length),B});break}case"/help":{O(u=>(H(u.length+1),[...u,{id:Date.now(),role:"system",isHelpRecord:!0,isMeta:!0}]));break}case"/btw":{O(u=>(H(u.length+1),[...u,{id:Date.now(),role:"system",text:`\u2726 RESTRICTED
223
223
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m '/btw' only available when agent is working
224
224
  \u2800`,isMeta:!0}]));break}default:O(u=>(H(u.length+1),[...u,{id:Date.now(),role:"system",text:`\u2726 ERROR
225
225
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Unknown command: '${M}'
226
226
  \u2800`,isMeta:!0}]))}}else{let g=`[Prompted on: ${new Date().toLocaleString(void 0,{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}]`,M={id:"user-"+Date.now(),role:"user",text:`${x}
227
227
 
228
- ${g}`};O(a=>(H(a.length+1),[...a,M])),(async()=>{let a=!1,p=()=>{a||(a=!0,O(de=>{let Y=de[de.length-1];if(Y&&Y.text&&Y.text.includes("Request Cancelled"))return de;let K=[...de.map(G=>G.isStreaming?{...G,isStreaming:!1}:G),{id:"cancel-"+Date.now(),role:"agent",text:`
228
+ ${g}`};O(a=>(H(a.length+1),[...a,M])),(async()=>{let a=!1,p=()=>{a||(a=!0,O(de=>{let Y=de[de.length-1];if(Y&&Y.text&&Y.text.includes("Request Cancelled"))return de;let q=[...de.map(W=>W.isStreaming?{...W,isStreaming:!1}:W),{id:"cancel-"+Date.now(),role:"agent",text:`
229
229
 
230
- \x1B[33m\u24D8 Request Cancelled\x1B[0m`,isMeta:!1}];return H(K.length),K}))},D=!1;ls(!0),Kr(Date.now()),S(!1);let F=Date.now(),Q=!0;try{let de=[...wt,M].filter(W=>W.role!=="think"&&!W.isVisualFeedback&&!W.isMeta&&!W.isTerminalRecord&&!(W.text&&W.text.includes("[TERMINAL_RECORD]"))&&!String(W.id).startsWith("welcome")),Y=[],V=de.map((W,Te)=>{let Be=W.fullText||W.text||"";if(W.role==="user"&&Te<de.length-1)if(Be.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")){let ke=Be.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");if(ke!==-1){let Qe=Be.substring(0,ke).lastIndexOf("[SYSTEM METADATA]");Qe!==-1?Be=Be.substring(Qe).trim():Be=Be.substring(ke).trim()}}else{let ke=Be.lastIndexOf("[USER]"),ct=Be.lastIndexOf("[USER PROMPT]");ke!==-1?Be=Be.substring(ke+6).trim():ct!==-1&&(Be=Be.substring(ct).trim())}return{...W,text:Be}}),K=0;for(;K<V.length;){let W=V[K];if(W.role==="user")Y.push(W),K++;else{let Te=[];for(;K<V.length&&V[K].role!=="user";)Te.push(V[K]),K++;let Be=[],ke=[],ct=null,Qe=!1,Ft=()=>{Be.length>0&&(Y.push({role:"agent",text:Be.join(`
231
- `).trim()}),Be=[]),ke.length>0&&(Y.push({role:"system",text:ke.join(`
230
+ \x1B[33m\u24D8 Request Cancelled\x1B[0m`,isMeta:!1}];return H(q.length),q}))},B=!1;ls(!0),Kr(Date.now()),S(!1);let F=Date.now(),K=!0;try{let de=[...Tt,M].filter(G=>G.role!=="think"&&!G.isVisualFeedback&&!G.isMeta&&!G.isTerminalRecord&&!(G.text&&G.text.includes("[TERMINAL_RECORD]"))&&!String(G.id).startsWith("welcome")),Y=[],V=de.map((G,we)=>{let De=G.fullText||G.text||"";if(G.role==="user"&&we<de.length-1)if(De.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")){let ke=De.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");if(ke!==-1){let Qe=De.substring(0,ke).lastIndexOf("[SYSTEM METADATA]");Qe!==-1?De=De.substring(Qe).trim():De=De.substring(ke).trim()}}else{let ke=De.lastIndexOf("[USER]"),ct=De.lastIndexOf("[USER PROMPT]");ke!==-1?De=De.substring(ke+6).trim():ct!==-1&&(De=De.substring(ct).trim())}return{...G,text:De}}),q=0;for(;q<V.length;){let G=V[q];if(G.role==="user")Y.push(G),q++;else{let we=[];for(;q<V.length&&V[q].role!=="user";)we.push(V[q]),q++;let De=[],ke=[],ct=null,Qe=!1,Ft=()=>{De.length>0&&(Y.push({role:"agent",text:De.join(`
231
+ `).trim()}),De=[]),ke.length>0&&(Y.push({role:"system",text:ke.join(`
232
232
 
233
- `),...ct?{binaryPart:ct}:{}}),ke=[],ct=null),Qe=!1};for(let no=0;no<Te.length;no++){let se=Te[no],we=se.role==="system"&&(se.text?.startsWith("[TOOL RESULT]")||se.text?.startsWith("SUCCESS:")||se.text?.startsWith("ERROR:")||se.fullText?.startsWith("[TOOL RESULT]")||se.fullText?.startsWith("SUCCESS:")||se.fullText?.startsWith("ERROR:")),Ne=se.fullText||se.text||"",Ye=Ne.trim();if(!(!Ye&&!se.binaryPart)){if(we){let ze=Ye.startsWith("[TOOL RESULT]")?Ye:`[TOOL RESULT]: ${Ye}`;ke.push(ze),se.binaryPart&&(ct=se.binaryPart)}else if(se.role==="agent"){!Qe&&ke.length>0&&Ft();let ze=Ne.endsWith(`
234
- `),uo=Ye.toLowerCase().includes("tool:")||Ye.toLowerCase().includes("agent:generalist."),Tn=!1;for(let Xn=no+1;Xn<Te.length;Xn++){let yn=Te[Xn];if(yn.role==="agent"){let br=(yn.fullText||yn.text||"").trim();if(br){Tn=br.startsWith("[");break}}}Be.push(Ye),uo&&ze&&Tn?Qe=!0:Qe=!1}}}Ft()}}let G=ll(He,Y,{profile:In,thinkingLevel:ce,mode:C,systemSettings:xe,janitorModel:ye,sessionStats:co,chatId:dt,isPlayground:!!Ee.playground,aiProvider:B,apiKey:kt,apiTier:lt,wildcardTooling:Se,wildercardTooling:w,cols:_.columns-6,rows:30,onTokenChunk:(W,Te)=>{let Be=Date.now();if(Kr(Be),typeof Te=="number"){zs.current=Te;let ke=qr.current;ke.startTime||(ke.startTime=Be,ke.totalWords=0,ke.chunks=[]),ke.totalWords+=Te,ke.chunks||(ke.chunks=[]),ke.chunks.push({time:Be,words:Te});let Qe=Be-400;if(ke.chunks=ke.chunks.filter(Ft=>Ft.time>=Qe),ke.chunks.length>0){let Ft=ke.chunks.reduce((we,Ne)=>we+Ne.words,0),no=ke.chunks[0].time,se=Math.max(.4,(Be-no)/1e3);ke.wps=Math.round(Ft/se*10)/10}}},onVisualFeedback:W=>{O(Te=>[...Te.map(ke=>ke.isStreaming?{...ke,isStreaming:!1}:ke),{id:"visual-"+Date.now()+"-"+Math.random().toString(36).substring(2,9),role:"system",text:W,isVisualFeedback:!0}])},onSubagentUpdate:()=>{oa(ol.map(W=>({...W})))},onExecStart:W=>{fe(),he(),si(W),hn("")},onExecChunk:W=>{hn(Te=>Te+W)},onExecEnd:()=>{O(W=>{if(!ur.current)return W;let Te=ns.current||"",Be=Vi(Te),ke=`[TERMINAL_RECORD]
233
+ `),...ct?{binaryPart:ct}:{}}),ke=[],ct=null),Qe=!1};for(let no=0;no<we.length;no++){let re=we[no],Te=re.role==="system"&&(re.text?.startsWith("[ACTION RESULT]")||re.text?.startsWith("[TOOL RESULT]")||re.text?.startsWith("SUCCESS:")||re.text?.startsWith("ERROR:")||re.fullText?.startsWith("[ACTION RESULT]")||re.fullText?.startsWith("[TOOL RESULT]")||re.fullText?.startsWith("SUCCESS:")||re.fullText?.startsWith("ERROR:")),$e=re.fullText||re.text||"",He=$e.trim();if(!(!He&&!re.binaryPart)){if(Te){let ze=!He.startsWith("[ACTION RESULT]")&&!He.startsWith("[TOOL RESULT]")?`[ACTION RESULT]: ${He}`:He;ke.push(ze),re.binaryPart&&(ct=re.binaryPart)}else if(re.role==="agent"){!Qe&&ke.length>0&&Ft();let ze=$e.endsWith(`
234
+ `),uo=He.toLowerCase().includes("tool:")||He.toLowerCase().includes("action:"),wn=!1;for(let Xn=no+1;Xn<we.length;Xn++){let yn=we[Xn];if(yn.role==="agent"){let br=(yn.fullText||yn.text||"").trim();if(br){wn=br.startsWith("[");break}}}De.push(He),uo&&ze&&wn?Qe=!0:Qe=!1}}}Ft()}}let W=ll(Ge,Y,{profile:In,thinkingLevel:ce,mode:C,systemSettings:xe,janitorModel:Ee,sessionStats:co,chatId:dt,isPlayground:!!ve.playground,aiProvider:D,apiKey:kt,apiTier:lt,wildcardTooling:Me,wildercardTooling:w,cols:_.columns-6,rows:30,onTokenChunk:(G,we)=>{let De=Date.now();if(Kr(De),typeof we=="number"){zs.current=we;let ke=qr.current;ke.startTime||(ke.startTime=De,ke.totalWords=0,ke.chunks=[]),ke.totalWords+=we,ke.chunks||(ke.chunks=[]),ke.chunks.push({time:De,words:we});let Qe=De-400;if(ke.chunks=ke.chunks.filter(Ft=>Ft.time>=Qe),ke.chunks.length>0){let Ft=ke.chunks.reduce((Te,$e)=>Te+$e.words,0),no=ke.chunks[0].time,re=Math.max(.4,(De-no)/1e3);ke.wps=Math.round(Ft/re*10)/10}}},onVisualFeedback:G=>{O(we=>[...we.map(ke=>ke.isStreaming?{...ke,isStreaming:!1}:ke),{id:"visual-"+Date.now()+"-"+Math.random().toString(36).substring(2,9),role:"system",text:G,isVisualFeedback:!0}])},onSubagentUpdate:()=>{oa(ol.map(G=>({...G})))},onExecStart:G=>{fe(),he(),si(G),hn("")},onExecChunk:G=>{hn(we=>we+G)},onExecEnd:()=>{O(G=>{if(!ur.current)return G;let we=ns.current||"",De=Vi(we),ke=`[TERMINAL_RECORD]
235
235
  COMMAND: ${ur.current}
236
236
  PTY: ${Sn}
237
- OUTPUT: ${Be.replace(/\n{3,}/g,`
237
+ OUTPUT: ${De.replace(/\n{3,}/g,`
238
238
 
239
- `)}`,Qe=[...W.map(Ft=>Ft.isStreaming?{...Ft,isStreaming:!1}:Ft),{id:"term-"+Date.now(),role:"system",text:ke,isTerminalRecord:!0}];return H(Qe.length),Qe}),si(null),ii(!1),hn(""),ur.current=null,ns.current=""},onToolResult:(W,Te)=>{if(W==="success"){if(ql(Be=>Be+1),Te==="generate_image"){Rl(ct=>ct+1);let ke={Low:.001,"Low-High":.002,Medium:.008,"Medium-High":.01,High:.045,Ultra:.0488,Premium:.1}[ko.quality]||.002;ea(ct=>ct+ke)}}else W==="denied"?Ql(Be=>Be+1):zl(Be=>Be+1)},onToolApproval:async(W,Te)=>{let Be=ra||xe.autoExec;if(W==="exec_command"){let{command:ke}=Yn(Te||"{}");return Be||ke&&/^(echo|ls|dir|pwd|cd|git status|git log|git diff|type|cat|help)\b/i.test(ke.trim())?"allow":new Promise(Qe=>{pn({tool:W,args:Te,resolve:Qe}),z("terminalApproval")})}return Be?"allow":new Promise(ke=>{pn({tool:W,args:Te,resolve:ke}),z("approval")})},onAskUser:async(W,Te)=>(fe(),he(),new Promise(Be=>{let ke=!1;rs({question:W,options:Te,resolve:ct=>{ke||(ke=!0,O(Qe=>{if(Qe.some(se=>se.isAskRecord&&se.text?.includes(`Selection: ${ct}`)))return Qe;let no=[...Qe,{id:"ask-"+Date.now(),role:"system",text:`\u{1F4AC} **Ask User**
240
- Question: ${W}
241
- Selection: ${ct}`,isAskRecord:!0}];return H(no.length),no}),Be(ct))}}),z("ask")})),onUsage:W=>{let Te=W.totalTokenCount||0,Be=W.cachedContentTokenCount||0,ke=W.candidatesTokenCount||0,ct=Math.max(0,Te-ke);Io({tokens:Te}),Rs(Qe=>Qe+Te),ct>0&&ei(Qe=>Qe+ct),Be>0&&ti(Qe=>Qe+Be),ke>0&&oi(Qe=>Qe+ke),Js(Qe=>Qe+1)}},async()=>So.current?So.current:null,ao),$=!1,_e=null,Pe=null,Oe=!1,tt=!1,Dt=!1,ot=!1,ut=0,gt=null,Po=/\[?\s*turn\s*:\s*.*?\s*\]?/gi;for await(let W of G){if(await new Promise(se=>setTimeout(se,3)),W.type==="text"&&Kr(Date.now()),Q&&W.type==="text"&&(F=Date.now(),Q=!1,xe.progressiveRendering&&Ae()),W.type==="status"){if(W.content&&(W.content.includes("Steering Hint Injected")||W.content.includes("Question Forwarded"))){let se=So.current;se&&(O(we=>{H(we.length+1);let Ne=se.startsWith("/btw"),Ye=Ne?se.replace(/^\/btw\s*/,""):se,ze=Ne?"[QUESTION]":"[STEERING HINT]";return[...we,{id:"hint-"+Date.now(),role:"user",text:`${ze}
242
- ${Ye}`,color:"cyan",isSteeringHint:!0,hintType:Ne?"QUESTION":"STEERING HINT",hintContent:Ye}]}),ds(null),So.current=null)}W.content?.includes("[start]")||ss(W.content),W.content?.includes("[start]")?(clearInterval($n),Un(0),$n=setInterval(()=>{Un(se=>se+1)},1e3)):W.content?.includes("[end]")&&(Un(0),clearInterval($n)),Jo()&&Dr(W.content),W.content==="Request Cancelled"&&(fe(),he(),p());continue}if(W.type==="status_history"){ss(W.content),Jo()&&Dr(W.content),O(se=>[...se,{id:"condense-"+Date.now(),role:"system",text:`\u2726 ${W.content}
243
- \u2800`,isMeta:!0}]);continue}if(W.type==="summary_injected"){O(se=>se.map(we=>we.id===W.content.id?{...we,fullText:W.content.text}:we));continue}if(W.type==="spinner"){aa(W.content);continue}if(W.type==="model_update"){ga(W.content);continue}if(W.type==="turn_reset"){if(fe(),he(),_e=null,Pe=null,$=!1,Oe=!1,tt=!1,ot=!1,Dt=!1,O(se=>{let we=se.map(Ne=>{if(Ne.isStreaming){let Ye=Ne.text?Et(Ne.text):Ne.text,ze=Ne.fullText?Et(Ne.fullText):Ne.fullText;return{...Ne,isStreaming:!1,text:Ye,fullText:ze}}return Ne});return H(we.length),we}),Co(),global.gc){for(let se=0;se<2;se++)global.gc(),await new Promise(we=>setImmediate(we));m.current=Date.now()}continue}if(W.type==="interactive_turn_finished"){ls(!1),Un(0),clearInterval($n),Jo()&&Dr(null),D=!0,Co(),xe?.autoTruncateResults&&O(se=>{let we=se.map(Ne=>{let Ye=Ne.fullText||Ne.text||"";return!Ye.startsWith("[TOOL RESULT]:")||Ne.toolName&&String(Ne.toolName).toLowerCase()==="search_keyword"||Ye.startsWith("[TOOL RESULT]: ERROR")||Ye.startsWith("[TOOL RESULT]: DENIED")||Ye.startsWith("[TOOL RESULT]: SUCCESS: Goal")||Ye.includes("...Success result truncated to save tokens")||Ye.startsWith("[TOOL RESULT]: Skill:")||Ye.includes("Skill: [")||Ye.startsWith("[TOOL RESULT]: DOCs:")||Ye.includes("DOCs: [")?Ne:{...Ne,fullText:"[TOOL RESULT]: ...Success result truncated to save tokens"}});return Cn(dt,null,we),H(we.length),we}),rl({profile:In,thinkingLevel:ce,mode:C,janitorModel:ye,chatId:dt,systemSettings:xe,sessionStats:co,aiProvider:B,apiKey:kt},W.data.agentText,W.data.fullAgentTextRaw,W.data.history,{onMemoryUpdated:()=>O(se=>{let we=[...se];return we.length>0&&(we[we.length-1].memoryUpdated=!0),we}),onBackgroundIncrement:()=>Yl(se=>se+1)});continue}if(W.type==="visual_feedback"){fe(),he(),O(se=>{let we=[...se,{id:"feedback-"+Date.now()+"-"+Math.random().toString(36).substring(2,9),role:"system",text:Et(W.content),isVisualFeedback:!0}];return H(we.length),we});continue}if(W.type==="exec_start"){fe(),he();continue}if(W.type==="liveTokens"){Io({tokens:W.content});continue}if(W.type==="usage"){let se=W.content.totalTokenCount||0,we=W.content.cachedContentTokenCount||0,Ne=W.content.candidatesTokenCount||0,Ye=Math.max(0,se-Ne);Io({tokens:se}),Rs(ze=>ze+se),Ye>0&&ei(ze=>ze+Ye),we>0&&ti(ze=>ze+we),Ne>0&&oi(ze=>ze+Ne),Js(ze=>ze+1);continue}if(W.type==="tool_time"){Zl(se=>se+W.content);continue}if(W.type==="tool_result"){if(he(),_e=null,Pe=null,$=!1,Oe=!1,tt=!1,ot=!1,Dt=!1,ut=0,gt=null,O(se=>{let we=[...se,{id:"tool-"+Date.now()+"-"+Math.random().toString(36).substring(2,7),role:"system",text:Et(W.content),fullText:Et(W.aiContent),binaryPart:W.binaryPart,toolName:W.toolName}];return H(we.length),we}),W.toolName==="update_file"&&W.aiContent){let se=W.aiContent.split(`
244
- `),we=0,Ne=0,Ye=!1;for(let ze of se){if(ze.includes("[DIFF_START]")){Ye=!0;continue}if(ze.includes("[DIFF_END]")){Ye=!1;continue}Ye&&(/^\+\d+/.test(ze)?we++:/^\-\d+/.test(ze)&&Ne++)}Qo("linesAdded",we),Qo("linesRemoved",Ne)}else if(W.toolName==="write_file"&&W.aiContent){let se=W.aiContent.match(/- Stats: \[(\d+) lines/),we=se?parseInt(se[1]):0,Ne=0;if(W.aiContent.includes("Old File contents:")){let Ye=W.aiContent.split(`
245
- `),ze=!1;for(let uo of Ye){if(uo.includes("Old File contents:")){ze=!0;continue}ze&&(uo.trim()===""?ze=!1:/^\d+ \|/.test(uo)&&Ne++)}}Qo("linesAdded",we),Qo("linesRemoved",Ne)}continue}let Te=W.content;if(W.type==="text"&&Te.includes("Request Cancelled")){if(global.gc){for(let se=0;se<3;se++)global.gc(),await new Promise(we=>setImmediate(we));m.current=Date.now()}continue}let Be=Te.toLowerCase();if(Te.includes("```")&&(Oe=!Oe),(Be.includes("tool:")||Be.includes("agent:generalist."))&&(tt=!0,ut=0,gt=null,(Te.includes("[tool:")||Te.includes("[agent:generalist."))&&(ut=0)),tt){for(let se=0;se<Te.length;se++){let we=Te[se];!gt&&(we==="'"||we==='"'||we==="`")?gt=we:gt&&we===gt&&Te[se-1]!=="\\"&&(gt=null),gt||(we==="("||we==="["?ut++:(we===")"||we==="]")&&ut--)}ut<=0&&!gt&&(tt=!1)}let ke=/^\s*(?:<(think|thought|thoughts)[^>]*>|<\|channel>thought|\[(think|thought|thoughts)\])/i,ct=(se,we,Ne=1)=>{let Ye=we>0?se[we-1]:"",ze=we+Ne<se.length?se[we+Ne]:"";return Ye==="`"&&ze==="`"},Qe=se=>{let we=/(?:<\/(think|thought|thoughts)>|<channel\|>|\[\/(think|thought|thoughts)\])/gi,Ne;for(;(Ne=we.exec(se))!==null;)if(!ct(se,Ne.index,Ne[0].length))return{index:Ne.index,length:Ne[0].length};return{index:-1,length:0}},Ft=ee.current?.role==="agent"&&ee.current.text||"",no=!Dt&&Ft.trim().length===0;if(!$&&no&&(ke.test(Te)||ke.test(Ft+Te))){let se=ke.test(Te)?Te:Ft+Te,we=se.match(ke),Ne=we.index,Ye=we[0].length,ze=se.substring(Ne+Ye);fe(),ee.current=null,$=!0,Dt=!0,_e="think-"+Date.now(),ee.current={id:_e,role:"think",text:"",isStreaming:!0,startTime:Date.now()};let uo=Qe(ze);if(uo.index!==-1){let Xn=ze.substring(0,uo.index).replace(/^\r?\n+/,"").replace(/\r?\n+$/,""),yn=ze.substring(uo.index+uo.length);ee.current.text=Et(Xn);let br=ee.current.startTime||Date.now();ee.current.duration=Date.now()-br,he(),$=!1,Pe="agent-"+Date.now(),ee.current={id:Pe,role:"agent",text:"",isStreaming:!0},yn&&Ze(yn)}else{let Tn=ze.replace(/^\r?\n+/,"");Tn&&Ze(Tn)}continue}if(!$&&!Dt&&Te.trim().length>0&&(Dt=!0),$&&ee.current?.role==="think"){fe();let se=ee.current.text+Te,we=Qe(se);if(we.index!==-1){let Ne=se.substring(0,we.index),Ye=se.substring(we.index+we.length);ee.current.text=Et(Ne);let ze=ee.current.startTime||Date.now();ee.current.duration=Date.now()-ze,he(),$=!1,Pe="agent-"+Date.now(),ee.current={id:Pe,role:"agent",text:"",isStreaming:!0},Ye&&Ze(Ye)}else Ze(Te);continue}else if(!$){let se=Te.toLowerCase();!ot&&(se.includes("tool:")||se.includes("agent:generalist."))&&(ot=!0),!ee.current||ee.current.role!=="agent"?(Pe="agent-"+Date.now(),ee.current={id:Pe,role:"agent",text:Et(Te),isStreaming:!0},te()):Ze(Te)}}let Oo=Date.now();Jl(W=>W+(Oo-F))}catch(de){O(Y=>(H(Y.length+1),[...Y,{id:"error-"+Date.now(),role:"system",text:`\u274C ERROR: ${de.message}`}]))}finally{let de=Date.now()-F;if(ee.current&&(ee.current.workedDuration=de),ae.current&&(await at(),clearInterval(ae.current),ae.current=null),ls(!1),ss(null),Un(0),clearInterval($n),he(),as.current&&p(),Co(),global.gc)try{for(let Y=0;Y<3;Y++)global.gc(),await new Promise(V=>setImmediate(V));m.current=Date.now()}catch{}if(D||process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow | Idle\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow | Idle\x07")),So.current){cs(So.current),ds(null);let Y=So.current;So.current=null,O(V=>{let K=[...V],G=K.reverse().find($=>$.text?.includes("[STEERING HINT: QUEUED]")||$.text?.includes("[QUESTION: QUEUED]"));return G&&(G.text.includes("[STEERING HINT: QUEUED]")?G.text=G.text.replace("[STEERING HINT: QUEUED]","[STEERING HINT: FINISHED_TURN]"):G.text.includes("[QUESTION: QUEUED]")&&(G.text=G.text.replace("[QUESTION: QUEUED]","[QUESTION: FINISHED_TURN]"))),K.reverse()}),z("resolution")}O(Y=>{let V=Date.now()-F,K=!1,G=[...Y].reverse().map(Pe=>{let Oe=Pe.isStreaming?{...Pe,isStreaming:!1}:Pe;return Oe.text&&(Oe.text=(" "+Oe.text).slice(1)),!K&&Oe.role==="agent"&&(K=!0,Oe={...Oe,workedDuration:V}),Oe}).reverse();if(!G.some(Pe=>Pe.role==="agent"&&Pe.text?.trim().length>0)){let Pe=[...G].reverse().find(Oe=>Oe.role==="think"&&Oe.text?.trim().length>0);Pe&&G.push({id:"agent-fallback-"+Date.now(),role:"agent",text:Pe.text,isStreaming:!1,workedDuration:V})}let _e=G.filter(Pe=>!String(Pe.id).startsWith("welcome")&&(!Pe.isMeta||Pe.text&&Pe.text.includes("Request Cancelled")));return Cn(dt,null,_e),H(G.length),G})}})()}f(""),S(!1)}},Ve=kn(()=>{if(k.startsWith("/")&&!re){let g=k.split(" "),M=g[g.length-1].toLowerCase();if(g.length===1){let a=M.startsWith("/")?M.slice(1):M;return Ci.filter(p=>(p.cmd.startsWith("/")?p.cmd.slice(1):p.cmd).toLowerCase().includes(a))}let u=Ci;for(let a=0;a<g.length-1;a++){let p=g[a].toLowerCase(),D=u.find(F=>F.cmd.toLowerCase()===p);if(D&&D.subs)u=D.subs;else return[]}return u.filter(a=>a.cmd.toLowerCase().includes(M))}let n=k.split(" "),o=n[n.length-1],d=o&&o.startsWith("\\@");if((o&&o.startsWith("@")||d)&&!re){let g=o.indexOf("#"),M=g!==-1,u=d?2:1,a=M?o.substring(u,g).toLowerCase():o.slice(u).toLowerCase(),p=M?o.substring(g):"";return sc(process.cwd()).filter(Q=>Q.name.toLowerCase().includes(a)).map(Q=>{let de=Q.relativePath.replace(/\\/g,"/"),Y=de.startsWith(".")?de:"./"+de;return{cmd:(d?"\\@":"@")+"["+Y+p+"]",desc:Q.relativePath}})}return[]},[k,re]);rt(()=>{let n=0;for(;n<Ve.length;){let o=Ve[n],d=o?.cmd||o||"";if(typeof d=="string"&&d.trimStart().startsWith("---"))n++;else break}Me(n<Ve.length?n:0)},[Ve]);let[hr,pr]=J(0),Ei=Ke(0);rt(()=>{let n=Ei.current>0,o=Ve.length>0;if(Ei.current=Ve.length,!o){pr(0);return}if(!n){pr(1);return}pr(Ve.length)},[Ve]),rt(()=>{if(hr>0&&hr<Ve.length){let n=setTimeout(()=>{pr(o=>Math.min(o+1,Ve.length))},5);return()=>clearTimeout(n)}},[hr,Ve.length]),rt(()=>{if(mt!=="providerBudgetSelect")return;let n=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","CrofAI","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","APInex"],o=Le.providerBudgets||{},d=n.reduce((x,g)=>(x[g]=!!(o[g]&&(o[g].agentLimit||o[g].tokenLimit||o[g].monthlyTokenLimit)),x),{});js(d),nr(0)},[mt]),rt(()=>{if(mt!=="providerBudgetFlow")return;let n={},o=Le.providerBudgets||{};for(let d of rn){let x=o[d]||{};n[d]={agentLimit:or(x.agentLimit),tokenLimit:or(x.tokenLimit),monthlyTokenLimit:or(x.monthlyTokenLimit)}}jr(n),yo(0)},[mt,rn]);let wc=({label:n,isSelected:o})=>{let d=n==="Cancel"||n==="Back"||n.toLowerCase().includes("exit")||n.toLowerCase().includes("back");return e.createElement(c,{marginTop:d?1:0,backgroundColor:o?"#2a2a2a":void 0,paddingX:1,width:"100%"},e.createElement(l,{color:o?"white":"gray",bold:o},o?"\u276F ":" ",n))},wn=(n,o,d,x=10,g=2,M=9)=>{let u=_r(d),a=!u&&d>0?Math.min(100,o/d*100):0,p=Math.round(a),D=Math.round(p/100*x),F="\u2588".repeat(D)+"\u2591".repeat(Math.max(0,x-D)),Q=i.success||"green";p>=40&&p<=80?Q=i.warning||"yellow":p>80&&(Q=i.danger||"red");let de=n.toLowerCase().includes("token")||n.toLowerCase().includes("daily")||n.toLowerCase().includes("monthly"),Y=u?"\u221E":de?ht(d):d,V=de?ht(o):o,K;return u||a===0?K="0%":a>0&&a<1?K="<1%":K=`${p}%`,e.createElement(c,{flexDirection:"row",paddingLeft:g,key:n},e.createElement(c,{width:M},e.createElement(l,{color:i.textMuted},n,": ")),e.createElement(l,{color:Q},F),e.createElement(l,{color:i.textMuted}," ",K," (",V,"/",Y,")"))},pa=()=>{switch(mt){case"settings":return e.createElement(Or,{systemSettings:xe,setSystemSettings:It,apiTier:lt,setActiveView:z,setInputConfig:Qt,saveSettings:Pt,quotas:Le,setMessages:O,aiProvider:B,setProviderReturnView:Wr});case"theme":return e.createElement(Or,{systemSettings:xe,setSystemSettings:It,apiTier:lt,setActiveView:z,setInputConfig:Qt,saveSettings:Pt,quotas:Le,setMessages:O,aiProvider:B,initialSelectingTheme:!0,onCloseTheme:()=>z("chat"),setProviderReturnView:Wr});case"selectProvider":return e.createElement(bt,{title:"SELECT AI PROVIDER",searchable:!0,items:[{label:"Google",value:"Google"},{label:"Nvidia",value:"NVIDIA"},{label:"DeepSeek",value:"DeepSeek"},{label:"InferX",value:"InferX"},{label:"SenseNova",value:"SenseNova"},{label:"Poolside",value:"Poolside"},{label:"Experiential Labs",value:"ExpLabs"},{label:"Token Harbor",value:"TokenHarbor"},{label:"APInex",value:"APInex"},...process.env.ENABLE_9ROUTER==="true"||process.env.ENABLE_9ROUTER===!0?[{label:"9router",value:"9router"}]:[],{label:"Ollama",value:"Ollama"},{label:"AIHubMix [EXPERIMENTAL]",value:"AIHubMix"},{label:"Mistral [EXPERIMENTAL]",value:"Mistral"},{label:"OpenRouter [EXPERIMENTAL]",value:"OpenRouter"},{label:"Back",value:nn}],theme:xe.theme,onSelect:async n=>{if(n.value===nn||n.value==="settings"||n.value==="Back"){z(nn);return}let o=n.value,d=await Mn(o),x="";if(o==="9router"){let g=await Hs();g.ok||(x=`
239
+ `)}`,Qe=[...G.map(Ft=>Ft.isStreaming?{...Ft,isStreaming:!1}:Ft),{id:"term-"+Date.now(),role:"system",text:ke,isTerminalRecord:!0}];return H(Qe.length),Qe}),si(null),ii(!1),hn(""),ur.current=null,ns.current=""},onToolResult:(G,we)=>{if(G==="success"){if(ql(De=>De+1),we==="generate_image"){Rl(ct=>ct+1);let ke={Low:.001,"Low-High":.002,Medium:.008,"Medium-High":.01,High:.045,Ultra:.0488,Premium:.1}[ko.quality]||.002;ea(ct=>ct+ke)}}else G==="denied"?Ql(De=>De+1):zl(De=>De+1)},onToolApproval:async(G,we)=>{let De=ra||xe.autoExec;if(G==="exec_command"){let{command:ke}=Yn(we||"{}");return De||ke&&/^(echo|ls|dir|pwd|cd|git status|git log|git diff|type|cat|help)\b/i.test(ke.trim())?"allow":new Promise(Qe=>{pn({tool:G,args:we,resolve:Qe}),z("terminalApproval")})}return De?"allow":new Promise(ke=>{pn({tool:G,args:we,resolve:ke}),z("approval")})},onAskUser:async(G,we)=>(fe(),he(),new Promise(De=>{let ke=!1;rs({question:G,options:we,resolve:ct=>{ke||(ke=!0,O(Qe=>{if(Qe.some(re=>re.isAskRecord&&re.text?.includes(`Selection: ${ct}`)))return Qe;let no=[...Qe,{id:"ask-"+Date.now(),role:"system",text:`\u{1F4AC} **Ask User**
240
+ Question: ${G}
241
+ Selection: ${ct}`,isAskRecord:!0}];return H(no.length),no}),De(ct))}}),z("ask")})),onUsage:G=>{let we=G.totalTokenCount||0,De=G.cachedContentTokenCount||0,ke=G.candidatesTokenCount||0,ct=Math.max(0,we-ke);Io({tokens:we}),Rs(Qe=>Qe+we),ct>0&&ei(Qe=>Qe+ct),De>0&&ti(Qe=>Qe+De),ke>0&&oi(Qe=>Qe+ke),Js(Qe=>Qe+1)}},async()=>So.current?So.current:null,ao),$=!1,_e=null,Pe=null,Oe=!1,tt=!1,Bt=!1,ot=!1,ut=0,gt=null,Po=/\[?\s*turn\s*:\s*.*?\s*\]?/gi;for await(let G of W){if(await new Promise(re=>setTimeout(re,3)),G.type==="text"&&Kr(Date.now()),K&&G.type==="text"&&(F=Date.now(),K=!1,xe.progressiveRendering&&Ae()),G.type==="status"){if(G.content&&(G.content.includes("Steering Hint Injected")||G.content.includes("Question Forwarded"))){let re=So.current;re&&(O(Te=>{H(Te.length+1);let $e=re.startsWith("/btw"),He=$e?re.replace(/^\/btw\s*/,""):re,ze=$e?"[QUESTION]":"[STEERING HINT]";return[...Te,{id:"hint-"+Date.now(),role:"user",text:`${ze}
242
+ ${He}`,color:"cyan",isSteeringHint:!0,hintType:$e?"QUESTION":"STEERING HINT",hintContent:He}]}),ds(null),So.current=null)}G.content?.includes("[start]")||ss(G.content),G.content?.includes("[start]")?(clearInterval($n),Un(0),$n=setInterval(()=>{Un(re=>re+1)},1e3)):G.content?.includes("[end]")&&(Un(0),clearInterval($n)),Jo()&&Br(G.content),G.content==="Request Cancelled"&&(fe(),he(),p());continue}if(G.type==="status_history"){ss(G.content),Jo()&&Br(G.content),O(re=>[...re,{id:"condense-"+Date.now(),role:"system",text:`\u2726 ${G.content}
243
+ \u2800`,isMeta:!0}]);continue}if(G.type==="summary_injected"){O(re=>re.map(Te=>Te.id===G.content.id?{...Te,fullText:G.content.text}:Te));continue}if(G.type==="spinner"){aa(G.content);continue}if(G.type==="model_update"){ga(G.content);continue}if(G.type==="turn_reset"){if(fe(),he(),_e=null,Pe=null,$=!1,Oe=!1,tt=!1,ot=!1,Bt=!1,O(re=>{let Te=re.map($e=>{if($e.isStreaming){let He=$e.text?Et($e.text):$e.text,ze=$e.fullText?Et($e.fullText):$e.fullText;return{...$e,isStreaming:!1,text:He,fullText:ze}}return $e});return H(Te.length),Te}),Co(),global.gc){for(let re=0;re<2;re++)global.gc(),await new Promise(Te=>setImmediate(Te));m.current=Date.now()}continue}if(G.type==="interactive_turn_finished"){ls(!1),Un(0),clearInterval($n),Jo()&&Br(null),B=!0,Co(),xe?.autoTruncateResults&&O(re=>{let Te=re.map($e=>{let He=$e.fullText||$e.text||"";return!He.startsWith("[ACTION RESULT]:")&&!He.startsWith("[TOOL RESULT]:")||He.startsWith("[ACTION RESULT]: ERROR")||He.startsWith("[TOOL RESULT]: ERROR")||He.startsWith("[ACTION RESULT]: DENIED")||He.startsWith("[TOOL RESULT]: DENIED")||He.startsWith("[ACTION RESULT]: SUCCESS: Goal")||He.startsWith("[TOOL RESULT]: SUCCESS: Goal")||He.includes("...Success result truncated to save tokens")||He.startsWith("[ACTION RESULT]: Skill:")||He.startsWith("[TOOL RESULT]: Skill:")||He.includes("Skill: [")||He.startsWith("[ACTION RESULT]: DOCs:")||He.startsWith("[TOOL RESULT]: DOCs:")||He.includes("DOCs: [")?$e:{...$e,fullText:"[ACTION RESULT]: ...Success result truncated to save tokens"}});return Cn(dt,null,Te),H(Te.length),Te}),rl({profile:In,thinkingLevel:ce,mode:C,janitorModel:Ee,chatId:dt,systemSettings:xe,sessionStats:co,aiProvider:D,apiKey:kt},G.data.agentText,G.data.fullAgentTextRaw,G.data.history,{onMemoryUpdated:()=>O(re=>{let Te=[...re];return Te.length>0&&(Te[Te.length-1].memoryUpdated=!0),Te}),onBackgroundIncrement:()=>Yl(re=>re+1)});continue}if(G.type==="visual_feedback"){fe(),he(),O(re=>{let Te=[...re,{id:"feedback-"+Date.now()+"-"+Math.random().toString(36).substring(2,9),role:"system",text:Et(G.content),isVisualFeedback:!0}];return H(Te.length),Te});continue}if(G.type==="exec_start"){fe(),he();continue}if(G.type==="liveTokens"){Io({tokens:G.content});continue}if(G.type==="usage"){let re=G.content.totalTokenCount||0,Te=G.content.cachedContentTokenCount||0,$e=G.content.candidatesTokenCount||0,He=Math.max(0,re-$e);Io({tokens:re}),Rs(ze=>ze+re),He>0&&ei(ze=>ze+He),Te>0&&ti(ze=>ze+Te),$e>0&&oi(ze=>ze+$e),Js(ze=>ze+1);continue}if(G.type==="tool_time"){Zl(re=>re+G.content);continue}if(G.type==="tool_result"){if(he(),_e=null,Pe=null,$=!1,Oe=!1,tt=!1,ot=!1,Bt=!1,ut=0,gt=null,O(re=>{let Te=[...re,{id:"tool-"+Date.now()+"-"+Math.random().toString(36).substring(2,7),role:"system",text:Et(G.content),fullText:Et(G.aiContent),binaryPart:G.binaryPart,toolName:G.toolName}];return H(Te.length),Te}),G.toolName==="update_file"&&G.aiContent){let re=G.aiContent.split(`
244
+ `),Te=0,$e=0,He=!1;for(let ze of re){if(ze.includes("[DIFF_START]")){He=!0;continue}if(ze.includes("[DIFF_END]")){He=!1;continue}He&&(/^\+\d+/.test(ze)?Te++:/^\-\d+/.test(ze)&&$e++)}Qo("linesAdded",Te),Qo("linesRemoved",$e)}else if(G.toolName==="write_file"&&G.aiContent){let re=G.aiContent.match(/- Stats: \[(\d+) lines/),Te=re?parseInt(re[1]):0,$e=0;if(G.aiContent.includes("Old File contents:")){let He=G.aiContent.split(`
245
+ `),ze=!1;for(let uo of He){if(uo.includes("Old File contents:")){ze=!0;continue}ze&&(uo.trim()===""?ze=!1:/^\d+ \|/.test(uo)&&$e++)}}Qo("linesAdded",Te),Qo("linesRemoved",$e)}continue}let we=G.content;if(G.type==="text"&&we.includes("Request Cancelled")){if(global.gc){for(let re=0;re<3;re++)global.gc(),await new Promise(Te=>setImmediate(Te));m.current=Date.now()}continue}let De=we.toLowerCase();if(we.includes("```")&&(Oe=!Oe),(De.includes("tool:")||De.includes("action:"))&&(tt=!0,ut=0,gt=null,(we.includes("[tool:")||we.includes("[action:"))&&(ut=0)),tt){for(let re=0;re<we.length;re++){let Te=we[re];!gt&&(Te==="'"||Te==='"'||Te==="`")?gt=Te:gt&&Te===gt&&we[re-1]!=="\\"&&(gt=null),gt||(Te==="("||Te==="["?ut++:(Te===")"||Te==="]")&&ut--)}ut<=0&&!gt&&(tt=!1)}let ke=/^\s*(?:<(think|thought|thoughts)[^>]*>|<\|channel>thought|\[(think|thought|thoughts)\])/i,ct=(re,Te,$e=1)=>{let He=Te>0?re[Te-1]:"",ze=Te+$e<re.length?re[Te+$e]:"";return He==="`"&&ze==="`"},Qe=re=>{let Te=/(?:<\/(think|thought|thoughts)>|<channel\|>|\[\/(think|thought|thoughts)\])/gi,$e;for(;($e=Te.exec(re))!==null;)if(!ct(re,$e.index,$e[0].length))return{index:$e.index,length:$e[0].length};return{index:-1,length:0}},Ft=ee.current?.role==="agent"&&ee.current.text||"",no=!Bt&&Ft.trim().length===0;if(!$&&no&&(ke.test(we)||ke.test(Ft+we))){let re=ke.test(we)?we:Ft+we,Te=re.match(ke),$e=Te.index,He=Te[0].length,ze=re.substring($e+He);fe(),ee.current=null,$=!0,Bt=!0,_e="think-"+Date.now(),ee.current={id:_e,role:"think",text:"",isStreaming:!0,startTime:Date.now()};let uo=Qe(ze);if(uo.index!==-1){let Xn=ze.substring(0,uo.index).replace(/^\r?\n+/,"").replace(/\r?\n+$/,""),yn=ze.substring(uo.index+uo.length);ee.current.text=Et(Xn);let br=ee.current.startTime||Date.now();ee.current.duration=Date.now()-br,he(),$=!1,Pe="agent-"+Date.now(),ee.current={id:Pe,role:"agent",text:"",isStreaming:!0},yn&&Ze(yn)}else{let wn=ze.replace(/^\r?\n+/,"");wn&&Ze(wn)}continue}if(!$&&!Bt&&we.trim().length>0&&(Bt=!0),$&&ee.current?.role==="think"){fe();let re=ee.current.text+we,Te=Qe(re);if(Te.index!==-1){let $e=re.substring(0,Te.index),He=re.substring(Te.index+Te.length);ee.current.text=Et($e);let ze=ee.current.startTime||Date.now();ee.current.duration=Date.now()-ze,he(),$=!1,Pe="agent-"+Date.now(),ee.current={id:Pe,role:"agent",text:"",isStreaming:!0},He&&Ze(He)}else Ze(we);continue}else if(!$){let re=we.toLowerCase();!ot&&(re.includes("tool:")||re.includes("action:"))&&(ot=!0),!ee.current||ee.current.role!=="agent"?(Pe="agent-"+Date.now(),ee.current={id:Pe,role:"agent",text:Et(we),isStreaming:!0},te()):Ze(we)}}let Oo=Date.now();Jl(G=>G+(Oo-F))}catch(de){O(Y=>(H(Y.length+1),[...Y,{id:"error-"+Date.now(),role:"system",text:`\u274C ERROR: ${de.message}`}]))}finally{let de=Date.now()-F;if(ee.current&&(ee.current.workedDuration=de),ae.current&&(await at(),clearInterval(ae.current),ae.current=null),ls(!1),ss(null),Un(0),clearInterval($n),he(),as.current&&p(),Co(),global.gc)try{for(let Y=0;Y<3;Y++)global.gc(),await new Promise(V=>setImmediate(V));m.current=Date.now()}catch{}if(B||process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow | Idle\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow | Idle\x07")),So.current){cs(So.current),ds(null);let Y=So.current;So.current=null,O(V=>{let q=[...V],W=q.reverse().find($=>$.text?.includes("[STEERING HINT: QUEUED]")||$.text?.includes("[QUESTION: QUEUED]"));return W&&(W.text.includes("[STEERING HINT: QUEUED]")?W.text=W.text.replace("[STEERING HINT: QUEUED]","[STEERING HINT: FINISHED_TURN]"):W.text.includes("[QUESTION: QUEUED]")&&(W.text=W.text.replace("[QUESTION: QUEUED]","[QUESTION: FINISHED_TURN]"))),q.reverse()}),z("resolution")}O(Y=>{let V=Date.now()-F,q=!1,W=[...Y].reverse().map(Pe=>{let Oe=Pe.isStreaming?{...Pe,isStreaming:!1}:Pe;return Oe.text&&(Oe.text=(" "+Oe.text).slice(1)),!q&&Oe.role==="agent"&&(q=!0,Oe={...Oe,workedDuration:V}),Oe}).reverse();if(!W.some(Pe=>Pe.role==="agent"&&Pe.text?.trim().length>0)){let Pe=[...W].reverse().find(Oe=>Oe.role==="think"&&Oe.text?.trim().length>0);Pe&&W.push({id:"agent-fallback-"+Date.now(),role:"agent",text:Pe.text,isStreaming:!1,workedDuration:V})}let _e=W.filter(Pe=>!String(Pe.id).startsWith("welcome")&&(!Pe.isMeta||Pe.text&&Pe.text.includes("Request Cancelled")));return Cn(dt,null,_e),H(W.length),W})}})()}f(""),S(!1)}},Ve=kn(()=>{if(k.startsWith("/")&&!se){let g=k.split(" "),M=g[g.length-1].toLowerCase();if(g.length===1){let a=M.startsWith("/")?M.slice(1):M;return Ci.filter(p=>(p.cmd.startsWith("/")?p.cmd.slice(1):p.cmd).toLowerCase().includes(a))}let u=Ci;for(let a=0;a<g.length-1;a++){let p=g[a].toLowerCase(),B=u.find(F=>F.cmd.toLowerCase()===p);if(B&&B.subs)u=B.subs;else return[]}return u.filter(a=>a.cmd.toLowerCase().includes(M))}let n=k.split(" "),o=n[n.length-1],d=o&&o.startsWith("\\@");if((o&&o.startsWith("@")||d)&&!se){let g=o.indexOf("#"),M=g!==-1,u=d?2:1,a=M?o.substring(u,g).toLowerCase():o.slice(u).toLowerCase(),p=M?o.substring(g):"";return sc(process.cwd()).filter(K=>K.name.toLowerCase().includes(a)).map(K=>{let de=K.relativePath.replace(/\\/g,"/"),Y=de.startsWith(".")?de:"./"+de;return{cmd:(d?"\\@":"@")+"["+Y+p+"]",desc:K.relativePath}})}return[]},[k,se]);rt(()=>{let n=0;for(;n<Ve.length;){let o=Ve[n],d=o?.cmd||o||"";if(typeof d=="string"&&d.trimStart().startsWith("---"))n++;else break}ye(n<Ve.length?n:0)},[Ve]);let[hr,pr]=J(0),Ei=Ke(0);rt(()=>{let n=Ei.current>0,o=Ve.length>0;if(Ei.current=Ve.length,!o){pr(0);return}if(!n){pr(1);return}pr(Ve.length)},[Ve]),rt(()=>{if(hr>0&&hr<Ve.length){let n=setTimeout(()=>{pr(o=>Math.min(o+1,Ve.length))},5);return()=>clearTimeout(n)}},[hr,Ve.length]),rt(()=>{if(mt!=="providerBudgetSelect")return;let n=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","CrofAI","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","APInex"],o=Le.providerBudgets||{},d=n.reduce((x,g)=>(x[g]=!!(o[g]&&(o[g].agentLimit||o[g].tokenLimit||o[g].monthlyTokenLimit)),x),{});js(d),nr(0)},[mt]),rt(()=>{if(mt!=="providerBudgetFlow")return;let n={},o=Le.providerBudgets||{};for(let d of rn){let x=o[d]||{};n[d]={agentLimit:or(x.agentLimit),tokenLimit:or(x.tokenLimit),monthlyTokenLimit:or(x.monthlyTokenLimit)}}jr(n),yo(0)},[mt,rn]);let Tc=({label:n,isSelected:o})=>{let d=n==="Cancel"||n==="Back"||n.toLowerCase().includes("exit")||n.toLowerCase().includes("back");return e.createElement(c,{marginTop:d?1:0,backgroundColor:o?"#2a2a2a":void 0,paddingX:1,width:"100%"},e.createElement(l,{color:o?"white":"gray",bold:o},o?"\u276F ":" ",n))},Tn=(n,o,d,x=10,g=2,M=9)=>{let u=_r(d),a=!u&&d>0?Math.min(100,o/d*100):0,p=Math.round(a),B=Math.round(p/100*x),F="\u2588".repeat(B)+"\u2591".repeat(Math.max(0,x-B)),K=i.success||"green";p>=40&&p<=80?K=i.warning||"yellow":p>80&&(K=i.danger||"red");let de=n.toLowerCase().includes("token")||n.toLowerCase().includes("daily")||n.toLowerCase().includes("monthly"),Y=u?"\u221E":de?ht(d):d,V=de?ht(o):o,q;return u||a===0?q="0%":a>0&&a<1?q="<1%":q=`${p}%`,e.createElement(c,{flexDirection:"row",paddingLeft:g,key:n},e.createElement(c,{width:M},e.createElement(l,{color:i.textMuted},n,": ")),e.createElement(l,{color:K},F),e.createElement(l,{color:i.textMuted}," ",q," (",V,"/",Y,")"))},pa=()=>{switch(mt){case"settings":return e.createElement(Or,{systemSettings:xe,setSystemSettings:It,apiTier:lt,setActiveView:z,setInputConfig:Qt,saveSettings:Pt,quotas:Le,setMessages:O,aiProvider:D,setProviderReturnView:Gr});case"theme":return e.createElement(Or,{systemSettings:xe,setSystemSettings:It,apiTier:lt,setActiveView:z,setInputConfig:Qt,saveSettings:Pt,quotas:Le,setMessages:O,aiProvider:D,initialSelectingTheme:!0,onCloseTheme:()=>z("chat"),setProviderReturnView:Gr});case"selectProvider":return e.createElement(bt,{title:"SELECT AI PROVIDER",searchable:!0,items:[{label:"Google",value:"Google"},{label:"Nvidia",value:"NVIDIA"},{label:"DeepSeek",value:"DeepSeek"},{label:"InferX",value:"InferX"},{label:"SenseNova",value:"SenseNova"},{label:"Poolside",value:"Poolside"},{label:"Experiential Labs",value:"ExpLabs"},{label:"Token Harbor",value:"TokenHarbor"},{label:"APInex",value:"APInex"},...process.env.ENABLE_9ROUTER==="true"||process.env.ENABLE_9ROUTER===!0?[{label:"9router",value:"9router"}]:[],{label:"Ollama",value:"Ollama"},{label:"AIHubMix [EXPERIMENTAL]",value:"AIHubMix"},{label:"Mistral [EXPERIMENTAL]",value:"Mistral"},{label:"OpenRouter [EXPERIMENTAL]",value:"OpenRouter"},{label:"Back",value:nn}],theme:xe.theme,onSelect:async n=>{if(n.value===nn||n.value==="settings"||n.value==="Back"){z(nn);return}let o=n.value,d=await Mn(o),x="";if(o==="9router"){let g=await Hs();g.ok||(x=`
246
246
 
247
247
  \x1B[33m\u2726 WARNING: 9router does not appear to be running on ${g.url}.\x1B[39m
248
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m To start 9router: \x1B[36mnpx 9router\x1B[39m or \x1B[36mnpm i -g 9router && 9router\x1B[39m`)}if(d){$e(o),zt(d),Kn(d,{aiProvider:o,onIDEApproval:mr});let g=(Le.providerTiers||{})[o]||"Free",M=go(o,g);Rt(M),Go(g),o==="NVIDIA"&&process.env.NVIDIA_BASE_URL||o==="Ollama"||o==="InferX"||o==="SenseNova"||o==="Poolside"||o==="9router"||o==="ExpLabs"||o==="TokenHarbor"||o==="APInex"?(It(u=>({...u,memory:!1})),Pt({aiProvider:o,activeModel:M,apiTier:g,quotas:Le,systemSettings:{...xe,memory:!1}})):Pt({aiProvider:o,activeModel:M,apiTier:g,quotas:Le}),O(u=>[...u,{role:"system",text:`\u2726 Switched to ${o} (cached)!${M?`
248
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m To start 9router: \x1B[36mnpx 9router\x1B[39m or \x1B[36mnpm i -g 9router && 9router\x1B[39m`)}if(d){Ue(o),zt(d),Kn(d,{aiProvider:o,onIDEApproval:mr});let g=(Le.providerTiers||{})[o]||"Free",M=go(o,g);Rt(M),Wo(g),o==="NVIDIA"&&process.env.NVIDIA_BASE_URL||o==="Ollama"||o==="InferX"||o==="SenseNova"||o==="Poolside"||o==="9router"||o==="ExpLabs"||o==="TokenHarbor"||o==="APInex"?(It(u=>({...u,memory:!1})),Pt({aiProvider:o,activeModel:M,apiTier:g,quotas:Le,systemSettings:{...xe,memory:!1}})):Pt({aiProvider:o,activeModel:M,apiTier:g,quotas:Le}),O(u=>[...u,{role:"system",text:`\u2726 Switched to ${o} (cached)!${M?`
249
249
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: ${M}.`:""}${(o==="Ollama"||o==="InferX"||o==="SenseNova"||o==="AIHubMix"||o==="Poolside"||o==="9router"||o==="ExpLabs"||o==="TokenHarbor"||o==="APInex")&&xe.memory?`
250
250
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with ${o}.`:""}${o==="NVIDIA"&&process.env.NVIDIA_BASE_URL&&xe.memory?`
251
251
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with Custom Endpoints.`:""}${x}
252
- \u2800`,isMeta:!0}]),z(nn)}else Qt({label:`Enter ${o} API Key:`,key:"providerKey",provider:o,value:"",returnView:nn}),z("input")},onClose:()=>z(nn)});case"apiTier":return e.createElement(bt,{title:`Show Paid models from ${B.toUpperCase()}?`,subtitle:"Curated model list. Can use anything if typed manually.",items:[{label:"No (For Free APIs) [Shows Free model list]",value:"Free"},{label:`Yes (For Billing APIs) [Shows Paid model list] ${lt==="Paid"?"\u25CF":""}`,value:"Paid"},{label:"Back",value:"settings"}],theme:xe.theme,onSelect:n=>{if(n.value==="settings"||n.value==="Back"){z("settings");return}let o=n.value;Go(o);let d={...Le.providerTiers||{},[B]:o},x={...Le,providerTiers:d};_t(x),Pt({apiTier:o,quotas:x}),z("settings")}});case"resetMode":return e.createElement(bt,{title:"SELECT MONTHLY RESET MODE",items:[{label:"Default (Rolling 30-Day Window)",value:"Rolling"},{label:"Custom (Set reset day of month)",value:"Custom"},{label:"Back",value:"apiTier"}],theme:xe.theme,onSelect:n=>{if(n.value==="apiTier"||n.value==="Back"){z("apiTier");return}let o=n.value,d={...Le,resetMode:o};_t(d),o==="Custom"?(Qt({label:"Enter monthly reset day (1-30):",key:"quotas",subKey:"resetDay",value:String(Le.resetDay||1),returnView:"settings"}),z("input")):(Pt({apiTier:lt,quotas:d}),z("settings"))},onClose:()=>z("apiTier")});case"budgetTypeSelect":return e.createElement(bt,{title:"SELECT BUDGET TYPE",items:[{label:`Global Budget (single limit for all providers) ${lt==="Paid"&&!Le.providerBudgets?.__useProvider?"\u25CF":""}`,value:"global"},{label:`Provider Budgets (set limits per provider individually) ${Le.providerBudgets?.__useProvider?"\u25CF":""}`,value:"provider"},{label:"Back",value:Wo}],theme:xe.theme,onSelect:n=>{if(n.value===Wo||n.value==="Back"){z(Wo);return}if(n.value==="global"){let o={...Le,agentLimit:99999999,tokenLimit:99999999999999,monthlyTokenLimit:99999999999999,providerBudgets:{__useProvider:!1}};_t(o);let d=Wo==="settings"?"resetMode":"budgetResetMode";Qt({label:"Enter Agent daily budget (tokens used):",key:"quotas",subKey:"tokenLimit",value:or(o.tokenLimit),returnView:Wo,next:x=>({label:"Enter Agent monthly budget (tokens used):",key:"quotas",subKey:"monthlyTokenLimit",value:or(x.monthlyTokenLimit),returnView:d})}),z("input")}else if(n.value==="provider"){let o={...Le,agentLimit:99999999,tokenLimit:99999999999999,monthlyTokenLimit:99999999999999,providerBudgets:{...Le.providerBudgets||{},__useProvider:!0}};_t(o),z("providerBudgetSelect")}},onClose:()=>z(Wo)});case"providerBudgetSelect":{let n=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","APInex"],o=n.some(d=>Yr[d]);return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:i.borderMuted,padding:0,width:"100%"},e.createElement(c,{paddingX:1,marginBottom:1},e.createElement(l,{color:i.text,bold:!0},"SELECT PROVIDERS TO SET LIMITS FOR")),n.map((d,x)=>{let g=x===Vs,M=!!Yr[d];return e.createElement(c,{key:d,backgroundColor:g?i.highlightBg||"#2a2a2a":void 0,paddingX:1,width:"100%",flexDirection:"row"},e.createElement(l,{color:g?i.text:i.textMuted,bold:g},g?"\u276F ":" "),e.createElement(l,{color:M?i.success||"green":i.textMuted},M?"\u2611":"\u2610"),e.createElement(l,{color:g?i.text:i.textMuted,bold:g}," ",d),M&&(Le.providerBudgets?.[d]?.agentLimit||Le.providerBudgets?.[d]?.tokenLimit||Le.providerBudgets?.[d]?.monthlyTokenLimit)?e.createElement(l,{color:i.primary||"cyan"}," (budget set)"):null)}),e.createElement(c,{paddingX:1,marginTop:1,flexDirection:"column"},e.createElement(l,{color:i.textMuted,italic:!0},"\u2191\u2193 Navigate \u2022 Space to toggle \u2022 Enter to confirm \u2022 ESC to go back"),!o&&e.createElement(l,{color:i.warning||"yellow",italic:!0}," Select at least one provider to continue")))}case"providerBudgetFlow":{let n=rn.length,o=n*2;return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:i.borderMuted,padding:0,width:"100%"},e.createElement(c,{paddingX:1,marginBottom:0,justifyContent:"space-between",flexDirection:"row"},e.createElement(l,{color:i.text,bold:!0},"PROVIDER BUDGET CONFIGURATION"),e.createElement(l,{color:i.textMuted,italic:!0},"(0 or blank = unlimited)")),e.createElement(c,{paddingX:1,marginTop:1,flexDirection:"row"},e.createElement(c,{width:14},e.createElement(l,{color:i.textMuted,bold:!0},"PROVIDER")),e.createElement(c,{width:30,paddingLeft:1},e.createElement(l,{color:i.textMuted,bold:!0},"DAILY TOKENS (/day)")),e.createElement(c,{width:30,paddingLeft:1},e.createElement(l,{color:i.textMuted,bold:!0},"MONTHLY TOKENS (/month)"))),e.createElement(c,{paddingX:1},e.createElement(l,{color:i.borderMuted},"\u2500".repeat(74))),rn.map((d,x)=>{let g=x*2,M=x*2+1,u=rr===g,a=rr===M,p=u||a,D=Vr[d]?.tokenLimit??"",F=Vr[d]?.monthlyTokenLimit??"";return e.createElement(c,{key:d,flexDirection:"row",paddingX:1,marginY:0,backgroundColor:p?i.highlightBg||"#2a2a2a":void 0},e.createElement(c,{width:14,flexDirection:"row"},e.createElement(l,{color:p?i.primary||"cyan":i.text,bold:p},p?"\u276F ":" ",d)),e.createElement(c,{width:30,paddingLeft:1,flexDirection:"row"},u?e.createElement(c,{flexDirection:"row"},e.createElement(l,{color:i.primary||"cyan",bold:!0},"[ "),e.createElement(Ur,{value:D,onChange:Q=>{jr(de=>({...de,[d]:{...de[d]||{},tokenLimit:Q}}))},onSubmit:()=>{yo(M)}}),e.createElement(l,{color:i.primary||"cyan",bold:!0}," ]")):e.createElement(l,{color:D?i.text:i.textMuted},"[ ",D||"0 (Unlimited)"," ]")),e.createElement(c,{width:30,paddingLeft:1,flexDirection:"row"},a?e.createElement(c,{flexDirection:"row"},e.createElement(l,{color:i.primary||"cyan",bold:!0},"[ "),e.createElement(Ur,{value:F,onChange:Q=>{jr(de=>({...de,[d]:{...de[d]||{},monthlyTokenLimit:Q}}))},onSubmit:()=>{x+1<n?yo((x+1)*2):yo(o)}}),e.createElement(l,{color:i.primary||"cyan",bold:!0}," ]")):e.createElement(l,{color:F?i.text:i.textMuted},"[ ",F||"0 (Unlimited)"," ]")))}),e.createElement(c,{paddingX:1,marginTop:1},rr===o?e.createElement(c,{backgroundColor:i.highlightBg||"#2a2a2a",paddingX:1},e.createElement(l,{color:i.success||"green",bold:!0},"\u276F [ Save & Apply Budgets ]")):e.createElement(l,{color:i.textMuted}," [ Save & Apply Budgets ]")),e.createElement(c,{paddingX:1,marginTop:1,flexDirection:"column"},e.createElement(l,{color:i.textMuted,italic:!0},"\u2191\u2193/\u2190\u2192 Navigate \u2022 Enter next / save \u2022 ESC to go back")))}case"budgetResetMode":return e.createElement(bt,{title:"SELECT MONTHLY RESET MODE",items:[{label:"Default (Rolling 30-Day Window)",value:"Rolling"},{label:"Custom (Set reset day of month)",value:"Custom"},{label:"Back",value:"chat"}],theme:xe.theme,onSelect:n=>{if(n.value==="chat"||n.value==="Back"){z("chat");return}let o=n.value,d={...Le,resetMode:o};_t(d),o==="Custom"?(Qt({label:"Enter monthly reset day (1-30):",key:"quotas",subKey:"resetDay",value:String(Le.resetDay||1),returnView:"chat"}),z("input")):(Pt({apiTier:lt,quotas:d}),z("chat"))},onClose:()=>z("chat")});case"budgetView":{let n=An?.agent||0,o=Le.agentLimit||99999999,d=An?.tokens||0,x=Le.tokenLimit||99999999999999,g=Le.resetMode==="Custom"?Jr?.tokens||0:dr?.tokens||0,M=Le.monthlyTokenLimit||99999999999999,u=lt!=="Paid",a=!!Le.providerBudgets?.__useProvider,p=Le.providerBudgets||{},D=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","APInex"].filter(Y=>p[Y]&&(p[Y].agentLimit||p[Y].tokenLimit||p[Y].monthlyTokenLimit)),F=!a&&(_r(x)||_r(M)),Q="",de="";if(Le.resetMode==="Custom"){let Y=new Date,V=Le.resetDay||1,K=Y.getFullYear(),G=Y.getMonth();Y.getDate()>=V&&(G+=1,G>11&&(G=0,K+=1));let $=new Date(K,G,V,0,0,0);Q=`${$.toLocaleString("default",{month:"short"}).toUpperCase()}-${V}`;let Pe=Math.max(0,$.getTime()-Y.getTime()),Oe=Math.floor(Pe/(1e3*60*60)),tt=Math.floor(Oe/24),Dt=Oe%24;de=`(${tt} days: ${Dt} hrs left)`}return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:i.borderMuted,padding:1,paddingBottom:0,paddingTop:0,width:"100%"},e.createElement(c,{marginBottom:1,justifyContent:"space-between",width:"100%"},e.createElement(l,{color:i.text,bold:!0,underline:!0},"USAGE LIMITS"),e.createElement(l,{color:i.textMuted},"[ ESC to Close ]")),F?e.createElement(c,{padding:1,justifyContent:"center",alignItems:"center",width:"100%"},e.createElement(l,{color:i.text,bold:!0},"LIMITS NOT SET")):a&&D.length>0?e.createElement(c,{flexDirection:"column",gap:0,width:"100%"},(()=>{let Y=s?.columns||_?.columns||80;if(Y<115){let G=Math.max(5,Math.min(30,Y-50));return D.map($=>{let _e=p[$],Pe=0,Oe=An?.models?.[$]||{};for(let ut in Oe)Pe+=Oe[ut]?.tokens||0;let tt=0,ot=(Le.resetMode==="Custom"?Jr:dr)?.models?.[$]||{};for(let ut in ot)tt+=ot[ut]?.tokens||0;return e.createElement(c,{key:$,flexDirection:"column",borderStyle:"single",borderColor:i.borderMuted,paddingX:1,width:"100%"},e.createElement(c,{marginBottom:0},e.createElement(l,{color:i.primary,bold:!0},"\u25C6 ",$)),wn("Daily",Pe,_e.tokenLimit||99999999999999,G,2,9),wn("Monthly",tt,_e.monthlyTokenLimit||99999999999999,G,2,9))})}let K=[];for(let G=0;G<D.length;G+=2)K.push(D.slice(G,G+2));return K.map((G,$)=>e.createElement(c,{key:$,flexDirection:"row",width:"100%"},G.map(_e=>{let Pe=p[_e],Oe=0,tt=An?.models?.[_e]||{};for(let W in tt)Oe+=tt[W]?.tokens||0;let Dt=0,ut=(Le.resetMode==="Custom"?Jr:dr)?.models?.[_e]||{};for(let W in ut)Dt+=ut[W]?.tokens||0;let gt=G.length===1,Po=gt?Y:Math.floor(Y/2),Oo=Math.max(5,Math.min(25,Po-36));return e.createElement(c,{key:_e,flexDirection:"column",borderStyle:"single",borderColor:i.borderMuted,paddingX:1,width:gt?"100%":"50%"},e.createElement(c,{marginBottom:0},e.createElement(l,{color:i.primary,bold:!0},"\u25C6 ",_e)),wn("Daily",Oe,Pe.tokenLimit||99999999999999,Oo,2,9),wn("Monthly",Dt,Pe.monthlyTokenLimit||99999999999999,Oo,2,9))})))})(),Q?e.createElement(c,{marginLeft:2,marginTop:1},e.createElement(l,{color:i.textMuted},"Monthly Reset: "),e.createElement(l,{color:i.accent||"magenta",bold:!0},Q),de?e.createElement(l,{color:i.textMuted},` ${de}`):null):e.createElement(c,{marginLeft:2,marginTop:1},e.createElement(l,{color:i.textMuted},"Monthly Reset: "),e.createElement(l,{color:i.secondary||"blue",bold:!0},"Rolling 30-Day Window"))):e.createElement(c,{flexDirection:"column",borderStyle:"single",borderColor:i.borderMuted,paddingX:1,width:"100%"},wn("Daily Tokens",d,x,"green"),wn("Monthly Tokens",g,M,"yellow"),Q?e.createElement(c,{marginLeft:4,marginTop:1},e.createElement(l,{color:i.textMuted},"Monthly Reset: "),e.createElement(l,{color:i.accent||"magenta",bold:!0},Q),de?e.createElement(l,{color:i.textMuted},` ${de}`):null):e.createElement(c,{marginLeft:4,marginTop:1},e.createElement(l,{color:i.textMuted},"Monthly Reset: "),e.createElement(l,{color:i.secondary||"blue",bold:!0},"Rolling 30-Day Window"))))}case"input":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:i.borderMuted,padding:0,width:"100%"},e.createElement(c,{paddingX:1},e.createElement(l,{color:i.text,bold:!0},"DATA CONFIGURATION")),Bo?.note&&e.createElement(c,{paddingX:1,marginBottom:1},e.createElement(l,{color:i.textMuted,italic:!0},Bo.note)),e.createElement(c,{paddingX:1,flexDirection:"row"},e.createElement(l,{color:i.text,bold:!0},Bo?.label," "),e.createElement(Ur,{value:Bo?.value||"",onChange:n=>Qt(o=>({...o,value:n})),onSubmit:async n=>{let{key:o,subKey:d,next:x,onDone:g}=Bo,M={...Le},u={};if(o==="quotas"){let a=d.toLowerCase().includes("limit")||d==="resetDay"?parseInt(n)||0:n;d==="resetDay"&&(a=Math.max(1,Math.min(30,a))),M[d]=a,_t(M),u.quotas=M}else if(o==="providerBudgets"){let a=Bo.providerKey,p=d.toLowerCase().includes("limit")?parseInt(n)||0:n,D=M.providerBudgets||{};M.providerBudgets={...D,[a]:{...D[a]||{},[d]:p}},_t(M),u.quotas=M}else if(o==="activeModel")Rt(n),u.activeModel=n;else if(o==="janitorModel")Xe(n),u.janitorModel=n;else if(o==="autoApproveCommands"||o==="autoDisallowCommands"||o==="alwaysAskCommands"){let a={...xe,[o]:n.trim(),sandboxPreset:"Custom"};It(a),u.systemSettings=a}else if(o==="externalDataPath"){let a={...xe,useExternalData:!0,externalDataPath:n.trim()};It(a),u.systemSettings=a,O(p=>[...p,{id:Date.now(),role:"system",text:"[EXTERNAL STORAGE] Flux Flow will use "+n.trim()+" for data after restart."}])}else if(o==="imageSettings"){let a=n.trim();if(a.startsWith("sk_")){let p={...ko,apiKey:a};sr(p),u.imageSettings=p,O(D=>(H(D.length+1),[...D,{id:Date.now(),role:"system",text:"[IMAGE KEY] Custom API key saved successfully.",isMeta:!0}]))}}else if(o==="providerKey"){let a=n.trim(),p=Bo.provider;(p==="Ollama"||p==="9router")&&(a==="LOCAL"||a==="")&&(a="LOCAL",p==="Ollama"&&(It(de=>({...de,ollamaEndpoint:"Local"})),u.systemSettings={...xe,ollamaEndpoint:"Local"}));let D="";if(p==="9router"){let de=await Hs();de.ok||(D=`
252
+ \u2800`,isMeta:!0}]),z(nn)}else Qt({label:`Enter ${o} API Key:`,key:"providerKey",provider:o,value:"",returnView:nn}),z("input")},onClose:()=>z(nn)});case"apiTier":return e.createElement(bt,{title:`Show Paid models from ${D.toUpperCase()}?`,subtitle:"Curated model list. Can use anything if typed manually.",items:[{label:"No (For Free APIs) [Shows Free model list]",value:"Free"},{label:`Yes (For Billing APIs) [Shows Paid model list] ${lt==="Paid"?"\u25CF":""}`,value:"Paid"},{label:"Back",value:"settings"}],theme:xe.theme,onSelect:n=>{if(n.value==="settings"||n.value==="Back"){z("settings");return}let o=n.value;Wo(o);let d={...Le.providerTiers||{},[D]:o},x={...Le,providerTiers:d};_t(x),Pt({apiTier:o,quotas:x}),z("settings")}});case"resetMode":return e.createElement(bt,{title:"SELECT MONTHLY RESET MODE",items:[{label:"Default (Rolling 30-Day Window)",value:"Rolling"},{label:"Custom (Set reset day of month)",value:"Custom"},{label:"Back",value:"apiTier"}],theme:xe.theme,onSelect:n=>{if(n.value==="apiTier"||n.value==="Back"){z("apiTier");return}let o=n.value,d={...Le,resetMode:o};_t(d),o==="Custom"?(Qt({label:"Enter monthly reset day (1-30):",key:"quotas",subKey:"resetDay",value:String(Le.resetDay||1),returnView:"settings"}),z("input")):(Pt({apiTier:lt,quotas:d}),z("settings"))},onClose:()=>z("apiTier")});case"budgetTypeSelect":return e.createElement(bt,{title:"SELECT BUDGET TYPE",items:[{label:`Global Budget (single limit for all providers) ${lt==="Paid"&&!Le.providerBudgets?.__useProvider?"\u25CF":""}`,value:"global"},{label:`Provider Budgets (set limits per provider individually) ${Le.providerBudgets?.__useProvider?"\u25CF":""}`,value:"provider"},{label:"Back",value:Go}],theme:xe.theme,onSelect:n=>{if(n.value===Go||n.value==="Back"){z(Go);return}if(n.value==="global"){let o={...Le,agentLimit:99999999,tokenLimit:99999999999999,monthlyTokenLimit:99999999999999,providerBudgets:{__useProvider:!1}};_t(o);let d=Go==="settings"?"resetMode":"budgetResetMode";Qt({label:"Enter Agent daily budget (tokens used):",key:"quotas",subKey:"tokenLimit",value:or(o.tokenLimit),returnView:Go,next:x=>({label:"Enter Agent monthly budget (tokens used):",key:"quotas",subKey:"monthlyTokenLimit",value:or(x.monthlyTokenLimit),returnView:d})}),z("input")}else if(n.value==="provider"){let o={...Le,agentLimit:99999999,tokenLimit:99999999999999,monthlyTokenLimit:99999999999999,providerBudgets:{...Le.providerBudgets||{},__useProvider:!0}};_t(o),z("providerBudgetSelect")}},onClose:()=>z(Go)});case"providerBudgetSelect":{let n=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","APInex"],o=n.some(d=>Yr[d]);return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:i.borderMuted,padding:0,width:"100%"},e.createElement(c,{paddingX:1,marginBottom:1},e.createElement(l,{color:i.text,bold:!0},"SELECT PROVIDERS TO SET LIMITS FOR")),n.map((d,x)=>{let g=x===Vs,M=!!Yr[d];return e.createElement(c,{key:d,backgroundColor:g?i.highlightBg||"#2a2a2a":void 0,paddingX:1,width:"100%",flexDirection:"row"},e.createElement(l,{color:g?i.text:i.textMuted,bold:g},g?"\u276F ":" "),e.createElement(l,{color:M?i.success||"green":i.textMuted},M?"\u2611":"\u2610"),e.createElement(l,{color:g?i.text:i.textMuted,bold:g}," ",d),M&&(Le.providerBudgets?.[d]?.agentLimit||Le.providerBudgets?.[d]?.tokenLimit||Le.providerBudgets?.[d]?.monthlyTokenLimit)?e.createElement(l,{color:i.primary||"cyan"}," (budget set)"):null)}),e.createElement(c,{paddingX:1,marginTop:1,flexDirection:"column"},e.createElement(l,{color:i.textMuted,italic:!0},"\u2191\u2193 Navigate \u2022 Space to toggle \u2022 Enter to confirm \u2022 ESC to go back"),!o&&e.createElement(l,{color:i.warning||"yellow",italic:!0}," Select at least one provider to continue")))}case"providerBudgetFlow":{let n=rn.length,o=n*2;return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:i.borderMuted,padding:0,width:"100%"},e.createElement(c,{paddingX:1,marginBottom:0,justifyContent:"space-between",flexDirection:"row"},e.createElement(l,{color:i.text,bold:!0},"PROVIDER BUDGET CONFIGURATION"),e.createElement(l,{color:i.textMuted,italic:!0},"(0 or blank = unlimited)")),e.createElement(c,{paddingX:1,marginTop:1,flexDirection:"row"},e.createElement(c,{width:14},e.createElement(l,{color:i.textMuted,bold:!0},"PROVIDER")),e.createElement(c,{width:30,paddingLeft:1},e.createElement(l,{color:i.textMuted,bold:!0},"DAILY TOKENS (/day)")),e.createElement(c,{width:30,paddingLeft:1},e.createElement(l,{color:i.textMuted,bold:!0},"MONTHLY TOKENS (/month)"))),e.createElement(c,{paddingX:1},e.createElement(l,{color:i.borderMuted},"\u2500".repeat(74))),rn.map((d,x)=>{let g=x*2,M=x*2+1,u=rr===g,a=rr===M,p=u||a,B=Vr[d]?.tokenLimit??"",F=Vr[d]?.monthlyTokenLimit??"";return e.createElement(c,{key:d,flexDirection:"row",paddingX:1,marginY:0,backgroundColor:p?i.highlightBg||"#2a2a2a":void 0},e.createElement(c,{width:14,flexDirection:"row"},e.createElement(l,{color:p?i.primary||"cyan":i.text,bold:p},p?"\u276F ":" ",d)),e.createElement(c,{width:30,paddingLeft:1,flexDirection:"row"},u?e.createElement(c,{flexDirection:"row"},e.createElement(l,{color:i.primary||"cyan",bold:!0},"[ "),e.createElement(Ur,{value:B,onChange:K=>{jr(de=>({...de,[d]:{...de[d]||{},tokenLimit:K}}))},onSubmit:()=>{yo(M)}}),e.createElement(l,{color:i.primary||"cyan",bold:!0}," ]")):e.createElement(l,{color:B?i.text:i.textMuted},"[ ",B||"0 (Unlimited)"," ]")),e.createElement(c,{width:30,paddingLeft:1,flexDirection:"row"},a?e.createElement(c,{flexDirection:"row"},e.createElement(l,{color:i.primary||"cyan",bold:!0},"[ "),e.createElement(Ur,{value:F,onChange:K=>{jr(de=>({...de,[d]:{...de[d]||{},monthlyTokenLimit:K}}))},onSubmit:()=>{x+1<n?yo((x+1)*2):yo(o)}}),e.createElement(l,{color:i.primary||"cyan",bold:!0}," ]")):e.createElement(l,{color:F?i.text:i.textMuted},"[ ",F||"0 (Unlimited)"," ]")))}),e.createElement(c,{paddingX:1,marginTop:1},rr===o?e.createElement(c,{backgroundColor:i.highlightBg||"#2a2a2a",paddingX:1},e.createElement(l,{color:i.success||"green",bold:!0},"\u276F [ Save & Apply Budgets ]")):e.createElement(l,{color:i.textMuted}," [ Save & Apply Budgets ]")),e.createElement(c,{paddingX:1,marginTop:1,flexDirection:"column"},e.createElement(l,{color:i.textMuted,italic:!0},"\u2191\u2193/\u2190\u2192 Navigate \u2022 Enter next / save \u2022 ESC to go back")))}case"budgetResetMode":return e.createElement(bt,{title:"SELECT MONTHLY RESET MODE",items:[{label:"Default (Rolling 30-Day Window)",value:"Rolling"},{label:"Custom (Set reset day of month)",value:"Custom"},{label:"Back",value:"chat"}],theme:xe.theme,onSelect:n=>{if(n.value==="chat"||n.value==="Back"){z("chat");return}let o=n.value,d={...Le,resetMode:o};_t(d),o==="Custom"?(Qt({label:"Enter monthly reset day (1-30):",key:"quotas",subKey:"resetDay",value:String(Le.resetDay||1),returnView:"chat"}),z("input")):(Pt({apiTier:lt,quotas:d}),z("chat"))},onClose:()=>z("chat")});case"budgetView":{let n=An?.agent||0,o=Le.agentLimit||99999999,d=An?.tokens||0,x=Le.tokenLimit||99999999999999,g=Le.resetMode==="Custom"?Jr?.tokens||0:dr?.tokens||0,M=Le.monthlyTokenLimit||99999999999999,u=lt!=="Paid",a=!!Le.providerBudgets?.__useProvider,p=Le.providerBudgets||{},B=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","APInex"].filter(Y=>p[Y]&&(p[Y].agentLimit||p[Y].tokenLimit||p[Y].monthlyTokenLimit)),F=!a&&(_r(x)||_r(M)),K="",de="";if(Le.resetMode==="Custom"){let Y=new Date,V=Le.resetDay||1,q=Y.getFullYear(),W=Y.getMonth();Y.getDate()>=V&&(W+=1,W>11&&(W=0,q+=1));let $=new Date(q,W,V,0,0,0);K=`${$.toLocaleString("default",{month:"short"}).toUpperCase()}-${V}`;let Pe=Math.max(0,$.getTime()-Y.getTime()),Oe=Math.floor(Pe/(1e3*60*60)),tt=Math.floor(Oe/24),Bt=Oe%24;de=`(${tt} days: ${Bt} hrs left)`}return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:i.borderMuted,padding:1,paddingBottom:0,paddingTop:0,width:"100%"},e.createElement(c,{marginBottom:1,justifyContent:"space-between",width:"100%"},e.createElement(l,{color:i.text,bold:!0,underline:!0},"USAGE LIMITS"),e.createElement(l,{color:i.textMuted},"[ ESC to Close ]")),F?e.createElement(c,{padding:1,justifyContent:"center",alignItems:"center",width:"100%"},e.createElement(l,{color:i.text,bold:!0},"LIMITS NOT SET")):a&&B.length>0?e.createElement(c,{flexDirection:"column",gap:0,width:"100%"},(()=>{let Y=s?.columns||_?.columns||80;if(Y<115){let W=Math.max(5,Math.min(30,Y-50));return B.map($=>{let _e=p[$],Pe=0,Oe=An?.models?.[$]||{};for(let ut in Oe)Pe+=Oe[ut]?.tokens||0;let tt=0,ot=(Le.resetMode==="Custom"?Jr:dr)?.models?.[$]||{};for(let ut in ot)tt+=ot[ut]?.tokens||0;return e.createElement(c,{key:$,flexDirection:"column",borderStyle:"single",borderColor:i.borderMuted,paddingX:1,width:"100%"},e.createElement(c,{marginBottom:0},e.createElement(l,{color:i.primary,bold:!0},"\u25C6 ",$)),Tn("Daily",Pe,_e.tokenLimit||99999999999999,W,2,9),Tn("Monthly",tt,_e.monthlyTokenLimit||99999999999999,W,2,9))})}let q=[];for(let W=0;W<B.length;W+=2)q.push(B.slice(W,W+2));return q.map((W,$)=>e.createElement(c,{key:$,flexDirection:"row",width:"100%"},W.map(_e=>{let Pe=p[_e],Oe=0,tt=An?.models?.[_e]||{};for(let G in tt)Oe+=tt[G]?.tokens||0;let Bt=0,ut=(Le.resetMode==="Custom"?Jr:dr)?.models?.[_e]||{};for(let G in ut)Bt+=ut[G]?.tokens||0;let gt=W.length===1,Po=gt?Y:Math.floor(Y/2),Oo=Math.max(5,Math.min(25,Po-36));return e.createElement(c,{key:_e,flexDirection:"column",borderStyle:"single",borderColor:i.borderMuted,paddingX:1,width:gt?"100%":"50%"},e.createElement(c,{marginBottom:0},e.createElement(l,{color:i.primary,bold:!0},"\u25C6 ",_e)),Tn("Daily",Oe,Pe.tokenLimit||99999999999999,Oo,2,9),Tn("Monthly",Bt,Pe.monthlyTokenLimit||99999999999999,Oo,2,9))})))})(),K?e.createElement(c,{marginLeft:2,marginTop:1},e.createElement(l,{color:i.textMuted},"Monthly Reset: "),e.createElement(l,{color:i.accent||"magenta",bold:!0},K),de?e.createElement(l,{color:i.textMuted},` ${de}`):null):e.createElement(c,{marginLeft:2,marginTop:1},e.createElement(l,{color:i.textMuted},"Monthly Reset: "),e.createElement(l,{color:i.secondary||"blue",bold:!0},"Rolling 30-Day Window"))):e.createElement(c,{flexDirection:"column",borderStyle:"single",borderColor:i.borderMuted,paddingX:1,width:"100%"},Tn("Daily Tokens",d,x,"green"),Tn("Monthly Tokens",g,M,"yellow"),K?e.createElement(c,{marginLeft:4,marginTop:1},e.createElement(l,{color:i.textMuted},"Monthly Reset: "),e.createElement(l,{color:i.accent||"magenta",bold:!0},K),de?e.createElement(l,{color:i.textMuted},` ${de}`):null):e.createElement(c,{marginLeft:4,marginTop:1},e.createElement(l,{color:i.textMuted},"Monthly Reset: "),e.createElement(l,{color:i.secondary||"blue",bold:!0},"Rolling 30-Day Window"))))}case"input":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:i.borderMuted,padding:0,width:"100%"},e.createElement(c,{paddingX:1},e.createElement(l,{color:i.text,bold:!0},"DATA CONFIGURATION")),Do?.note&&e.createElement(c,{paddingX:1,marginBottom:1},e.createElement(l,{color:i.textMuted,italic:!0},Do.note)),e.createElement(c,{paddingX:1,flexDirection:"row"},e.createElement(l,{color:i.text,bold:!0},Do?.label," "),e.createElement(Ur,{value:Do?.value||"",onChange:n=>Qt(o=>({...o,value:n})),onSubmit:async n=>{let{key:o,subKey:d,next:x,onDone:g}=Do,M={...Le},u={};if(o==="quotas"){let a=d.toLowerCase().includes("limit")||d==="resetDay"?parseInt(n)||0:n;d==="resetDay"&&(a=Math.max(1,Math.min(30,a))),M[d]=a,_t(M),u.quotas=M}else if(o==="providerBudgets"){let a=Do.providerKey,p=d.toLowerCase().includes("limit")?parseInt(n)||0:n,B=M.providerBudgets||{};M.providerBudgets={...B,[a]:{...B[a]||{},[d]:p}},_t(M),u.quotas=M}else if(o==="activeModel")Rt(n),u.activeModel=n;else if(o==="janitorModel")Xe(n),u.janitorModel=n;else if(o==="autoApproveCommands"||o==="autoDisallowCommands"||o==="alwaysAskCommands"){let a={...xe,[o]:n.trim(),sandboxPreset:"Custom"};It(a),u.systemSettings=a}else if(o==="externalDataPath"){let a={...xe,useExternalData:!0,externalDataPath:n.trim()};It(a),u.systemSettings=a,O(p=>[...p,{id:Date.now(),role:"system",text:"[EXTERNAL STORAGE] Flux Flow will use "+n.trim()+" for data after restart."}])}else if(o==="imageSettings"){let a=n.trim();if(a.startsWith("sk_")){let p={...ko,apiKey:a};sr(p),u.imageSettings=p,O(B=>(H(B.length+1),[...B,{id:Date.now(),role:"system",text:"[IMAGE KEY] Custom API key saved successfully.",isMeta:!0}]))}}else if(o==="providerKey"){let a=n.trim(),p=Do.provider;(p==="Ollama"||p==="9router")&&(a==="LOCAL"||a==="")&&(a="LOCAL",p==="Ollama"&&(It(de=>({...de,ollamaEndpoint:"Local"})),u.systemSettings={...xe,ollamaEndpoint:"Local"}));let B="";if(p==="9router"){let de=await Hs();de.ok||(B=`
253
253
 
254
254
  \x1B[33m\u2726 WARNING: 9router does not appear to be running on ${de.url}.\x1B[39m
255
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m To start 9router: \x1B[36mnpx 9router\x1B[39m or \x1B[36mnpm i -g 9router && 9router\x1B[39m`)}await fs(p,a),$e(p),zt(a),Kn(a,{aiProvider:p,onIDEApproval:mr});let F=(Le.providerTiers||{})[p]||"Free",Q=go(p,F);Rt(Q),Go(F),u.aiProvider=p,u.activeModel=Q,u.apiTier=F,(p==="NVIDIA"&&process.env.NVIDIA_BASE_URL||p==="Ollama"||p==="CrofAI"||p==="InferX"||p==="SenseNova"||p==="AIHubMix"||p==="Poolside"||p==="9router"||p==="ExpLabs"||p==="TokenHarbor"||p==="APInex")&&(It(de=>({...de,memory:!1})),u.systemSettings={...xe,memory:!1}),O(de=>(H(de.length+1),[...de,{id:Date.now(),role:"system",text:`\u2726 ${p} API Key saved successfully! ${Q?`
256
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: ${Q}`:""}${p==="Ollama"&&a==="LOCAL"?`
255
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m To start 9router: \x1B[36mnpx 9router\x1B[39m or \x1B[36mnpm i -g 9router && 9router\x1B[39m`)}await fs(p,a),Ue(p),zt(a),Kn(a,{aiProvider:p,onIDEApproval:mr});let F=(Le.providerTiers||{})[p]||"Free",K=go(p,F);Rt(K),Wo(F),u.aiProvider=p,u.activeModel=K,u.apiTier=F,(p==="NVIDIA"&&process.env.NVIDIA_BASE_URL||p==="Ollama"||p==="CrofAI"||p==="InferX"||p==="SenseNova"||p==="AIHubMix"||p==="Poolside"||p==="9router"||p==="ExpLabs"||p==="TokenHarbor"||p==="APInex")&&(It(de=>({...de,memory:!1})),u.systemSettings={...xe,memory:!1}),O(de=>(H(de.length+1),[...de,{id:Date.now(),role:"system",text:`\u2726 ${p} API Key saved successfully! ${K?`
256
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: ${K}`:""}${p==="Ollama"&&a==="LOCAL"?`
257
257
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Ollama Endpoint automatically switched to Local`:""}${p==="Ollama"||p==="CrofAI"||p==="InferX"||p==="SenseNova"||p==="AIHubMix"||p==="Poolside"||p==="9router"||p==="ExpLabs"||p==="TokenHarbor"||p==="APInex"?`
258
258
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with ${p}`:""}${p==="NVIDIA"&&process.env.NVIDIA_BASE_URL?`
259
- \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available`:""}${D}
260
- \u2800\u2800`,isMeta:!0}]))}if(x){let a=x(o==="quotas"||o==="providerBudgets"?M:n);Qt(a)}else g?(Pt({...u,apiTier:lt,quotas:M,imageSettings:u.imageSettings||ko}),Qt(null),g(M)):(Pt({...u,apiTier:lt,quotas:M,imageSettings:u.imageSettings||ko}),Qt(null),z(Bo?.returnView||"settings"))}})),e.createElement(c,{paddingX:1,marginTop:1},e.createElement(l,{color:i.textMuted,dimColor:!0,italic:!0},"(Press Enter to confirm selection)")));case"stats":{let n=gn==="modelBreakdown"||gn==="dailyModelBreakdown",o=gn==="daily"||gn==="dailyModelBreakdown",d=o?An:dr,x=o?"TODAY's USAGE":"LAST 30 DAYS USAGE",g=o?"TODAY'S MODEL TOKEN BREAKDOWN":"30-DAY MODEL TOKEN BREAKDOWN",M="Wall Time:",u="Tokens Used:",a="Images Made:",p="Image Credits:",D="Code Changes:",F="Tool Calls:",Q=Math.max(4,(s?.rows||_?.rows||24)-15),de=(Pe,Oe,tt,Dt,ot,ut=0,gt=!1)=>{let Po=s?.columns||_?.columns||80,Oo=Math.min(125,Po-2),W=Math.max(20,Oo-6),Te=Math.max(5,W-ut-tt.length-5),Be=Oe;Be.length>Te&&(Be=Be.substring(0,Te-1)+"\u2026");let ke=Math.max(2,W-ut-Be.length-tt.length-2),ct=" "+".".repeat(ke)+" ",Qe=" ".repeat(ut);return e.createElement(c,{key:Pe,width:W},e.createElement(l,{wrap:"truncate"},e.createElement(l,null,Qe),e.createElement(l,{color:Dt,bold:gt},Be),e.createElement(l,{color:i.textMuted,dimColor:!0},ct),e.createElement(l,{color:ot,bold:gt},tt)))},Y=[],V=d?.models;if(!V||Object.keys(V).length===0)Y.push(e.createElement(c,{key:"empty",marginTop:1},e.createElement(l,{color:i.textMuted,italic:!0},"No model token usage recorded for ",o?"today":"the last 30 days",".")));else{let Pe=(Pn||"").trim(),Oe="",tt="";if(Pe.includes(":")){let ot=Pe.indexOf(":");Oe=Pe.substring(0,ot).trim().toLowerCase(),tt=Pe.substring(ot+1).trim().toLowerCase()}else Oe=Pe.toLowerCase();let Dt=Object.entries(V).sort(([ot],[ut])=>ot.localeCompare(ut,void 0,{sensitivity:"base"})).filter(([ot,ut])=>Oe&&!ot.toLowerCase().includes(Oe)?!1:tt?Object.keys(ut).some(gt=>gt.toLowerCase().includes(tt)):!0);Dt.length===0?Y.push(e.createElement(c,{key:"no-matches",marginTop:1},e.createElement(l,{color:i.textMuted,italic:!0},'No results found matching "',Pn,'".'))):Dt.forEach(([ot,ut],gt)=>{let Po=Object.entries(ut).sort(([W],[Te])=>W.localeCompare(Te,void 0,{sensitivity:"base"})).filter(([W])=>!tt||W.toLowerCase().includes(tt));if(Po.length===0)return;let Oo=Po.reduce((W,[,Te])=>W+(Te.tokens||0),0);gt>0&&Y.length>0&&Y.push(e.createElement(c,{key:`space-prov-${ot}`},e.createElement(l,null," "))),Y.push(de(`prov-${ot}`,`${ot}:`,ht(Oo),i.primary,i.text,0,!0)),Po.forEach(([W,Te],Be)=>{Be>0&&Y.push(e.createElement(c,{key:`space-mod-${ot}-${W}`},e.createElement(l,null," "))),Y.push(de(`mod-${ot}-${W}`,`\xBB ${W}:`,ht(Te.tokens||0),i.secondary,i.text,2,!0)),Y.push(de(`in-${ot}-${W}`,"\xBB Input Tokens:",ht((Te.tokens||0)-(Te.candidateTokens||0)),i.textMuted,i.text,5,!1)),(Te.cachedTokens||0)>0&&Y.push(de(`cache-${ot}-${W}`,"\xBB Cached:",ht(Te.cachedTokens),i.textMuted,i.text,7,!1)),Y.push(de(`out-${ot}-${W}`,"\xBB Output Tokens:",ht(Te.candidateTokens||0),i.textMuted,i.text,5,!1))})})}let K=Y.length,G=Math.max(0,K-Q);Ie.current=G;let $=Math.min(ta,G),_e=Y.slice($,$+Q);return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:i.borderMuted,paddingX:3,paddingY:1,paddingBottom:0,width:Math.min(125,(s?.columns||100)-2)},n?e.createElement(c,{flexDirection:"column"},e.createElement(c,{justifyContent:"space-between"},e.createElement(l,{color:i.text,bold:!0,underline:!0},g),K>Q&&e.createElement(l,{color:i.textMuted,dimColor:!0},"[",$+1,"-",Math.min(K,$+Q)," of ",K,"] \u25B2\u25BC")),e.createElement(c,{marginTop:1},e.createElement(l,{color:i.secondary,bold:!0},"Filter (provider:model): "),e.createElement(l,{color:i.text},Pn),e.createElement(l,{color:i.primary,bold:!0},"\u258A"),Pn.length>0&&e.createElement(l,{color:i.textMuted,dimColor:!0,italic:!0}," (Type to search, Esc/Backspace to clear)")),e.createElement(c,{flexDirection:"column",height:Q,marginTop:1},_e)):e.createElement(e.Fragment,null,e.createElement(c,{marginBottom:1},e.createElement(l,{color:i.text,bold:!0,underline:!0},"SESSION TELEMETRY")),e.createElement(c,{flexDirection:"column"},e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},"Session Duration:")),e.createElement(l,{color:i.text},jo(Date.now()-Gs))),Qs>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},"Model Requests:")),e.createElement(l,{color:i.text},Qs)),e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(l,{color:i.textMuted},"\xBB API Time:")),e.createElement(l,{color:i.text},jo(ir))),e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(l,{color:i.textMuted},"\xBB Tool Time:")),e.createElement(l,{color:i.text},jo(lr)))),Zs>0&&e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},"Memory Agent:")),e.createElement(l,{color:i.text},Zs)),Yt>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},"Tokens Consumed:")),e.createElement(l,{color:i.text},ht(Yt))),e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(l,{color:i.textMuted},"\xBB Input Tokens:")),e.createElement(l,{color:i.text},ht(Yt-mn))),eo>0&&e.createElement(c,{marginLeft:4},e.createElement(c,{width:21},e.createElement(l,{color:i.textMuted},"\xBB Cached:")),e.createElement(l,{color:i.text},ht(eo))),mn>0&&e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(l,{color:i.textMuted},"\xBB Output Tokens:")),e.createElement(l,{color:i.text},ht(mn)))),co?.tokens>0&&e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},"Active Context:")),e.createElement(l,{color:i.text},ht(co.tokens)," ",(()=>{let Oe={"16k":16e3,"32k":32e3,"64k":64e3,"128k":128e3,"256k":256e3,"512k":512e3,"1M":1e6}[xe?.contextLength]||256e3,tt=process.env.HIGH_CONTEXT,Dt=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1;if(tt&&tt!=="false"){let gt=parseInt(tt,10);!isNaN(gt)&&gt>=0&&gt<=1e6&&(Oe=gt)}(B==="NVIDIA"&&(He?.includes("gpt")||He?.includes("qwen")||He?.includes("medium")||He.includes("muse"))||B==="Mistral")&&(Oe=126e3),B==="Google"&&He?.includes("gemma")&&Dt&&(Oe=16e3);let ot=co.tokens/Oe*100,ut=ot<60?i.text:ot<80?i.warning:i.danger;return e.createElement(l,{color:ut,dimColor:!0},"(",ot.toFixed(0),"%)")})())),ar>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},"Images Made:")),e.createElement(l,{color:i.text},ar)),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},"Image Credits:")),e.createElement(l,{color:i.text},Number(((ni||0)*1e3).toFixed(0))," credits"))),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},"Code Changes (Sess):")),e.createElement(l,{color:i.text},e.createElement(l,{color:i.success||"green"},"+",vt.linesAdded)," ",e.createElement(l,{color:i.danger||"red"},"-",vt.linesRemoved))),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},"Tool Calls (Sess):")),e.createElement(l,{color:i.text},vt.toolSuccess+vt.toolFailure+vt.toolDenied," ( "),e.createElement(l,{color:i.success||"green"},"\u2714 ",vt.toolSuccess),e.createElement(l,{color:i.text}," "),e.createElement(l,{color:i.warning||"yellow"},"\u{1F6C7} ",vt.toolDenied),e.createElement(l,{color:i.text}," "),e.createElement(l,{color:i.danger||"red"},"\u2718 ",vt.toolFailure),e.createElement(l,{color:i.text}," )"))),e.createElement(c,{flexDirection:"column",marginTop:1},e.createElement(l,{color:i.text,bold:!0,underline:!0},x),e.createElement(c,{marginTop:1},e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},M)),e.createElement(l,{color:i.text},ci(d?.duration||0))),(d?.agent||0)>0&&e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},"Model Requests:")),e.createElement(l,{color:i.text},d?.agent||0)),(d?.background||0)>0&&e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},"Memory Agent:")),e.createElement(l,{color:i.text},d?.background||0)),(d?.tokens||0)>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},u)),e.createElement(l,{color:i.text},ht(d?.tokens||0))),e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(l,{color:i.textMuted},"\xBB Input Tokens:")),e.createElement(l,{color:i.text},ht((d?.tokens||0)-(d?.candidateTokens||0)))),(d?.cachedTokens||0)>0&&e.createElement(c,{marginLeft:4},e.createElement(c,{width:21},e.createElement(l,{color:i.textMuted},"\xBB Cached:")),e.createElement(l,{color:i.text},ht(d.cachedTokens))),(d?.candidateTokens||0)>0&&e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(l,{color:i.textMuted},"\xBB Output Tokens:")),e.createElement(l,{color:i.text},ht(d.candidateTokens)))),(d?.imageCalls?.length||0)>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},a)),e.createElement(l,{color:i.text},d.imageCalls.length)),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},p)),e.createElement(l,{color:i.text},Number(((d.imageCalls.reduce((Pe,Oe)=>Pe+Oe.cost,0)||0)*1e3).toFixed(0))," credits"))),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},D)),e.createElement(l,{color:i.text},e.createElement(l,{color:i.success||"green"},"+",d?.linesAdded||0)," ",e.createElement(l,{color:i.danger||"red"},"-",d?.linesRemoved||0))),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},F)),e.createElement(l,{color:i.text},(d?.toolSuccess||0)+(d?.toolFailure||0)+(d?.toolDenied||0)," ( "),e.createElement(l,{color:i.success||"green"},"\u2714 ",d?.toolSuccess||0),e.createElement(l,{color:i.text}," "),e.createElement(l,{color:i.warning||"yellow"},"\u{1F6C7} ",d?.toolDenied||0),e.createElement(l,{color:i.text}," "),e.createElement(l,{color:i.danger||"red"},"\u2718 ",d?.toolFailure||0),e.createElement(l,{color:i.text}," )")))),e.createElement(l,{color:i.textMuted,dimColor:!0,italic:!0},`
259
+ \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available`:""}${B}
260
+ \u2800\u2800`,isMeta:!0}]))}if(x){let a=x(o==="quotas"||o==="providerBudgets"?M:n);Qt(a)}else g?(Pt({...u,apiTier:lt,quotas:M,imageSettings:u.imageSettings||ko}),Qt(null),g(M)):(Pt({...u,apiTier:lt,quotas:M,imageSettings:u.imageSettings||ko}),Qt(null),z(Do?.returnView||"settings"))}})),e.createElement(c,{paddingX:1,marginTop:1},e.createElement(l,{color:i.textMuted,dimColor:!0,italic:!0},"(Press Enter to confirm selection)")));case"stats":{let n=gn==="modelBreakdown"||gn==="dailyModelBreakdown",o=gn==="daily"||gn==="dailyModelBreakdown",d=o?An:dr,x=o?"TODAY's USAGE":"LAST 30 DAYS USAGE",g=o?"TODAY'S MODEL TOKEN BREAKDOWN":"30-DAY MODEL TOKEN BREAKDOWN",M="Wall Time:",u="Tokens Used:",a="Images Made:",p="Image Credits:",B="Code Changes:",F="Tool Calls:",K=Math.max(4,(s?.rows||_?.rows||24)-15),de=(Pe,Oe,tt,Bt,ot,ut=0,gt=!1)=>{let Po=s?.columns||_?.columns||80,Oo=Math.min(125,Po-2),G=Math.max(20,Oo-6),we=Math.max(5,G-ut-tt.length-5),De=Oe;De.length>we&&(De=De.substring(0,we-1)+"\u2026");let ke=Math.max(2,G-ut-De.length-tt.length-2),ct=" "+".".repeat(ke)+" ",Qe=" ".repeat(ut);return e.createElement(c,{key:Pe,width:G},e.createElement(l,{wrap:"truncate"},e.createElement(l,null,Qe),e.createElement(l,{color:Bt,bold:gt},De),e.createElement(l,{color:i.textMuted,dimColor:!0},ct),e.createElement(l,{color:ot,bold:gt},tt)))},Y=[],V=d?.models;if(!V||Object.keys(V).length===0)Y.push(e.createElement(c,{key:"empty",marginTop:1},e.createElement(l,{color:i.textMuted,italic:!0},"No model token usage recorded for ",o?"today":"the last 30 days",".")));else{let Pe=(Pn||"").trim(),Oe="",tt="";if(Pe.includes(":")){let ot=Pe.indexOf(":");Oe=Pe.substring(0,ot).trim().toLowerCase(),tt=Pe.substring(ot+1).trim().toLowerCase()}else Oe=Pe.toLowerCase();let Bt=Object.entries(V).sort(([ot],[ut])=>ot.localeCompare(ut,void 0,{sensitivity:"base"})).filter(([ot,ut])=>Oe&&!ot.toLowerCase().includes(Oe)?!1:tt?Object.keys(ut).some(gt=>gt.toLowerCase().includes(tt)):!0);Bt.length===0?Y.push(e.createElement(c,{key:"no-matches",marginTop:1},e.createElement(l,{color:i.textMuted,italic:!0},'No results found matching "',Pn,'".'))):Bt.forEach(([ot,ut],gt)=>{let Po=Object.entries(ut).sort(([G],[we])=>G.localeCompare(we,void 0,{sensitivity:"base"})).filter(([G])=>!tt||G.toLowerCase().includes(tt));if(Po.length===0)return;let Oo=Po.reduce((G,[,we])=>G+(we.tokens||0),0);gt>0&&Y.length>0&&Y.push(e.createElement(c,{key:`space-prov-${ot}`},e.createElement(l,null," "))),Y.push(de(`prov-${ot}`,`${ot}:`,ht(Oo),i.primary,i.text,0,!0)),Po.forEach(([G,we],De)=>{De>0&&Y.push(e.createElement(c,{key:`space-mod-${ot}-${G}`},e.createElement(l,null," "))),Y.push(de(`mod-${ot}-${G}`,`\xBB ${G}:`,ht(we.tokens||0),i.secondary,i.text,2,!0)),Y.push(de(`in-${ot}-${G}`,"\xBB Input Tokens:",ht((we.tokens||0)-(we.candidateTokens||0)),i.textMuted,i.text,5,!1)),(we.cachedTokens||0)>0&&Y.push(de(`cache-${ot}-${G}`,"\xBB Cached:",ht(we.cachedTokens),i.textMuted,i.text,7,!1)),Y.push(de(`out-${ot}-${G}`,"\xBB Output Tokens:",ht(we.candidateTokens||0),i.textMuted,i.text,5,!1))})})}let q=Y.length,W=Math.max(0,q-K);Ie.current=W;let $=Math.min(ta,W),_e=Y.slice($,$+K);return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:i.borderMuted,paddingX:3,paddingY:1,paddingBottom:0,width:Math.min(125,(s?.columns||100)-2)},n?e.createElement(c,{flexDirection:"column"},e.createElement(c,{justifyContent:"space-between"},e.createElement(l,{color:i.text,bold:!0,underline:!0},g),q>K&&e.createElement(l,{color:i.textMuted,dimColor:!0},"[",$+1,"-",Math.min(q,$+K)," of ",q,"] \u25B2\u25BC")),e.createElement(c,{marginTop:1},e.createElement(l,{color:i.secondary,bold:!0},"Filter (provider:model): "),e.createElement(l,{color:i.text},Pn),e.createElement(l,{color:i.primary,bold:!0},"\u258A"),Pn.length>0&&e.createElement(l,{color:i.textMuted,dimColor:!0,italic:!0}," (Type to search, Esc/Backspace to clear)")),e.createElement(c,{flexDirection:"column",height:K,marginTop:1},_e)):e.createElement(e.Fragment,null,e.createElement(c,{marginBottom:1},e.createElement(l,{color:i.text,bold:!0,underline:!0},"SESSION TELEMETRY")),e.createElement(c,{flexDirection:"column"},e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},"Session Duration:")),e.createElement(l,{color:i.text},jo(Date.now()-Ws))),Qs>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},"Model Requests:")),e.createElement(l,{color:i.text},Qs)),e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(l,{color:i.textMuted},"\xBB API Time:")),e.createElement(l,{color:i.text},jo(ir))),e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(l,{color:i.textMuted},"\xBB Tool Time:")),e.createElement(l,{color:i.text},jo(lr)))),Zs>0&&e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},"Memory Agent:")),e.createElement(l,{color:i.text},Zs)),Yt>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},"Tokens Consumed:")),e.createElement(l,{color:i.text},ht(Yt))),e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(l,{color:i.textMuted},"\xBB Input Tokens:")),e.createElement(l,{color:i.text},ht(Yt-mn))),eo>0&&e.createElement(c,{marginLeft:4},e.createElement(c,{width:21},e.createElement(l,{color:i.textMuted},"\xBB Cached:")),e.createElement(l,{color:i.text},ht(eo))),mn>0&&e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(l,{color:i.textMuted},"\xBB Output Tokens:")),e.createElement(l,{color:i.text},ht(mn)))),co?.tokens>0&&e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},"Active Context:")),e.createElement(l,{color:i.text},ht(co.tokens)," ",(()=>{let Oe={"16k":16e3,"32k":32e3,"64k":64e3,"128k":128e3,"256k":256e3,"512k":512e3,"1M":1e6}[xe?.contextLength]||256e3,tt=process.env.HIGH_CONTEXT,Bt=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1;if(tt&&tt!=="false"){let gt=parseInt(tt,10);!isNaN(gt)&&gt>=0&&gt<=1e6&&(Oe=gt)}(D==="NVIDIA"&&(Ge?.includes("gpt")||Ge?.includes("qwen")||Ge?.includes("medium")||Ge.includes("muse"))||D==="Mistral")&&(Oe=126e3),D==="Google"&&Ge?.includes("gemma")&&Bt&&(Oe=16e3);let ot=co.tokens/Oe*100,ut=ot<60?i.text:ot<80?i.warning:i.danger;return e.createElement(l,{color:ut,dimColor:!0},"(",ot.toFixed(0),"%)")})())),ar>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},"Images Made:")),e.createElement(l,{color:i.text},ar)),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},"Image Credits:")),e.createElement(l,{color:i.text},Number(((ni||0)*1e3).toFixed(0))," credits"))),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},"Code Changes (Sess):")),e.createElement(l,{color:i.text},e.createElement(l,{color:i.success||"green"},"+",vt.linesAdded)," ",e.createElement(l,{color:i.danger||"red"},"-",vt.linesRemoved))),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},"Tool Calls (Sess):")),e.createElement(l,{color:i.text},vt.toolSuccess+vt.toolFailure+vt.toolDenied," ( "),e.createElement(l,{color:i.success||"green"},"\u2714 ",vt.toolSuccess),e.createElement(l,{color:i.text}," "),e.createElement(l,{color:i.warning||"yellow"},"\u{1F6C7} ",vt.toolDenied),e.createElement(l,{color:i.text}," "),e.createElement(l,{color:i.danger||"red"},"\u2718 ",vt.toolFailure),e.createElement(l,{color:i.text}," )"))),e.createElement(c,{flexDirection:"column",marginTop:1},e.createElement(l,{color:i.text,bold:!0,underline:!0},x),e.createElement(c,{marginTop:1},e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},M)),e.createElement(l,{color:i.text},ci(d?.duration||0))),(d?.agent||0)>0&&e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},"Model Requests:")),e.createElement(l,{color:i.text},d?.agent||0)),(d?.background||0)>0&&e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},"Memory Agent:")),e.createElement(l,{color:i.text},d?.background||0)),(d?.tokens||0)>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},u)),e.createElement(l,{color:i.text},ht(d?.tokens||0))),e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(l,{color:i.textMuted},"\xBB Input Tokens:")),e.createElement(l,{color:i.text},ht((d?.tokens||0)-(d?.candidateTokens||0)))),(d?.cachedTokens||0)>0&&e.createElement(c,{marginLeft:4},e.createElement(c,{width:21},e.createElement(l,{color:i.textMuted},"\xBB Cached:")),e.createElement(l,{color:i.text},ht(d.cachedTokens))),(d?.candidateTokens||0)>0&&e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(l,{color:i.textMuted},"\xBB Output Tokens:")),e.createElement(l,{color:i.text},ht(d.candidateTokens)))),(d?.imageCalls?.length||0)>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},a)),e.createElement(l,{color:i.text},d.imageCalls.length)),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},p)),e.createElement(l,{color:i.text},Number(((d.imageCalls.reduce((Pe,Oe)=>Pe+Oe.cost,0)||0)*1e3).toFixed(0))," credits"))),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},B)),e.createElement(l,{color:i.text},e.createElement(l,{color:i.success||"green"},"+",d?.linesAdded||0)," ",e.createElement(l,{color:i.danger||"red"},"-",d?.linesRemoved||0))),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(l,{color:i.secondary},F)),e.createElement(l,{color:i.text},(d?.toolSuccess||0)+(d?.toolFailure||0)+(d?.toolDenied||0)," ( "),e.createElement(l,{color:i.success||"green"},"\u2714 ",d?.toolSuccess||0),e.createElement(l,{color:i.text}," "),e.createElement(l,{color:i.warning||"yellow"},"\u{1F6C7} ",d?.toolDenied||0),e.createElement(l,{color:i.text}," "),e.createElement(l,{color:i.danger||"red"},"\u2718 ",d?.toolFailure||0),e.createElement(l,{color:i.text}," )")))),e.createElement(l,{color:i.textMuted,dimColor:!0,italic:!0},`
261
261
  `,"(Press TAB to toggle Today/30-Day views, SPACE to toggle Model Breakdown, ESC to return)"))}case"dynamicDirDanger":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:i.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(l,{color:i.warning||"yellow",bold:!0,underline:!0},"DYNAMIC DIRECTORY AWARENESS"),e.createElement(l,{marginTop:1,color:i.text},"Enabling this keeps the agent aware of filesystem state in real time, but may reduce prompt cache efficiency."),e.createElement(l,{color:i.text},`
262
262
  `,"RECOMMENDED SCENARIOS TO TURN ON:"),e.createElement(l,{color:i.textMuted},"\u2022 Repo is small."),e.createElement(l,{color:i.textMuted},"\u2022 The task benefits from real-time filesystem awareness."),e.createElement(l,{color:i.textMuted},"\u2022 Files are often created, renamed, or deleted."),e.createElement(l,{color:i.textMuted},"\u2022 You know exactly what you're signing up for."),e.createElement(l,{color:i.textMuted},"\u2022 You don't have conflicting decisions regarding token bills."),e.createElement(l,{color:i.textMuted},"\u2022 You want to see your wallet crying at 3am."),e.createElement(c,{marginTop:1},e.createElement(bt,{title:"Confirm Intent",theme:xe.theme,items:[{label:"Turn On Dynamic Directory Awareness",value:"on"},{label:"Keep Off (Recommended)",value:"off"}],onSelect:n=>{n.value==="on"&&It(o=>{let d={...o,dynamicDirAwareness:!0};return Pt({systemSettings:d,apiTier:lt,quotas:Le}),d}),z("settings")}})));case"dynamicDirHelp":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:i.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(l,{color:i.text,bold:!0,underline:!0},"DYNAMIC DIRECTORY AWARENESS \u2014 HELP & EXPLANATION"),e.createElement(l,{color:i.text,bold:!0},`
263
263
  `,"OFF (Default):"),e.createElement(l,{color:i.textMuted},"\u2022 Takes a static directory snapshot at conversation/session start and places it in System Context."),e.createElement(l,{color:i.textMuted},"\u2022 Prompt cache remains stable across user turns, saving tokens and money."),e.createElement(l,{color:i.text,bold:!0},`
264
264
  `,"ON:"),e.createElement(l,{color:i.textMuted},"\u2022 Rescans and updates the directory's state dynamically on every single user turn."),e.createElement(l,{color:i.textMuted},"\u2022 Provides real-time filesystem awareness if files are continuously created, renamed, or removed."),e.createElement(l,{color:i.textMuted},"\u2022 Changes Prompt Context on each turn, invalidating part of prompt caches and increasing token usage."),e.createElement(c,{marginTop:1},e.createElement(bt,{title:"Actions",theme:xe.theme,items:[{label:"Back to Settings",value:"back"}],onSelect:()=>z("settings")})));case"autoExecDanger":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:i.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(l,{color:i.warning||"yellow",bold:!0,underline:!0},"SECURITY WARNING: YOLO MODE"),e.createElement(l,{marginTop:1,color:i.text},"Turning this ON allows the agent to execute terminal commands automatically without requiring your approval for each step."),e.createElement(l,{marginTop:1,color:i.text,bold:!0},"RISKS INVOLVED:"),e.createElement(l,{color:i.textMuted},"\u2022 The agent may execute destructive commands (rm -rf, etc.) by mistake unless specified in sandbox rules."),e.createElement(l,{color:i.textMuted},"\u2022 Unintended system changes if the agent hallucinates a path or command."),e.createElement(l,{color:i.textMuted},"\u2022 Reduced control over the agent's step-by-step decision making."),e.createElement(c,{marginTop:1},e.createElement(bt,{title:"Confirm Intent",theme:xe.theme,items:[{label:"I know the risk and turning on intentionally",value:"on"},{label:"Keep Off (Recommended)",value:"off"}],onSelect:n=>{n.value==="on"&&It(o=>({...o,autoExec:!0})),z("settings")}})));case"advanceRollbackDanger":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:i.borderMuted,paddingX:2,paddingY:1,paddingTop:0,width:"100%"},e.createElement(l,{color:i.warning||"yellow",bold:!0},"\u26A0 Emergency Rollback Notice"),e.createElement(l,{marginTop:1,color:i.text},"When enabled, full repo snapshots exist only during active AI turns."),e.createElement(l,{marginTop:1,color:i.text},"If catastrophic changes occur during a turn, avoid abruptly stopping the agent unless absolutely necessary (external damages out of codebase)."),e.createElement(l,{color:i.textMuted},"The agent may be able to automatically restore the repo to a safe state."),e.createElement(l,{marginTop:1,color:i.textMuted},"Once the turn ends, emergency snapshots are deleted and standard /revert takes over which may not retain full repo content."),e.createElement(l,{marginTop:1,color:i.textMuted},"(Requires Restart to take effect)"),e.createElement(c,{marginTop:1},e.createElement(bt,{title:"Confirm",theme:xe.theme,items:[{label:"I understand and wish to enable",value:"on"},{label:"Keep Off",value:"off"}],onSelect:n=>{n.value==="on"&&It(o=>({...o,advanceRollback:!0})),z("settings")}})));case"externalDanger":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:i.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(l,{color:i.warning||"yellow",bold:!0,underline:!0},"SECURITY WARNING: EXTERNAL WORKSPACE ACCESS"),e.createElement(l,{marginTop:1,color:i.text},"Turning this ON allows the agent to execute tools (Read/Write/Exec) outside of the current active workspace directory."),e.createElement(l,{marginTop:1,color:i.text,bold:!0},"RISKS INVOLVED:"),e.createElement(l,{color:i.textMuted},"\u2022 Access to sensitive system files (SSH keys, Browser data, etc.)"),e.createElement(l,{color:i.textMuted},"\u2022 Potential for accidental or malicious deletion of OS-critical files."),e.createElement(l,{color:i.textMuted},"\u2022 Unauthorized script execution across your entire file system."),e.createElement(c,{marginTop:1},e.createElement(bt,{title:"Confirm Intent",theme:xe.theme,items:[{label:"I know the risk and turning on intentionally",value:"on"},{label:"Keep Off (Recommended)",value:"off"}],onSelect:n=>{n.value==="on"&&It(o=>({...o,allowExternalAccess:!0})),z("settings")}})));case"doubleDanger":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:i.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(l,{color:i.danger||"red",bold:!0,underline:!0},"CRITICAL SECURITY WARNING: COMBINED SYSTEM RISK"),e.createElement(l,{marginTop:1,color:i.text},"You are attempting to enable BOTH [YOLO Mode] and [External Workspace Access] simultaneously."),e.createElement(l,{marginTop:1,color:i.danger||"red",bold:!0},"THIS IS NOT RECOMMENDED."),e.createElement(l,{marginTop:1,color:i.text,bold:!0},"THE CRITICAL RISK:"),e.createElement(l,{color:i.textMuted},"The agent will have the power to execute any command across your entire system WITHOUT your approval or supervision."),e.createElement(l,{color:i.danger||"red",italic:!0,marginTop:1},"A single hallucination or error could result in full system wipe or data theft."),e.createElement(c,{marginTop:1},e.createElement(bt,{title:"Final Confirmation",theme:xe.theme,items:[{label:"I agree knowing the consequences",value:"on"},{label:"Keep Off",value:"off"}],onSelect:n=>{n.value==="on"&&It(o=>({...o,autoExec:!0,allowExternalAccess:!0})),z("settings")}})));case"key":return e.createElement(bt,{title:"API KEY MANAGEMENT",items:[{label:"Edit Current Key (Update)",value:"edit"},{label:"Remove Current Key (Delete)",value:"remove"},{label:"Cancel",value:"Cancel"}],onSelect:n=>{if(n.value==="edit"){zt(null),z("chat");let o=nt(2);O(d=>[...d,{id:Date.now(),role:"system",text:`\u2726 Flux waiting for new API Key...
265
- \u2800`}])}else n.value==="remove"?z("deleteKey"):z("chat")}});case"deleteKey":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:"grey",paddingX:2,paddingY:1},(()=>{let n=nt(2);return e.createElement(l,{color:"white",bold:!0},"DANGER: CLEAR CREDENTIALS")})(),e.createElement(l,{marginTop:1},"This will permanently delete all saved API keys in credential cache. You will need to enter it again to use Flux."),e.createElement(c,{marginTop:1},e.createElement(bt,{title:"Are you sure?",items:[{label:"YES, CLEAR CREDENTIALS",value:"yes"},{label:"NO, GO BACK",value:"no"}],onSelect:async n=>{if(n.value==="yes"){await Ni(),zt(null),z("chat");let o=nt(2);O(d=>[...d,{id:Date.now(),role:"system",text:"[CREDENTIAL CLEARED] API Key removed successfully."}])}else z("key")},theme:xe.theme})));case"exit":return null;case"ask":return e.createElement(c,{width:"100%"},e.createElement(yl,{question:Vo?.question,options:Vo?.options,onResolve:n=>{Vo?.resolve&&Vo.resolve(n),rs(null),z("chat")},theme:xe.theme}));case"revert":return e.createElement(c,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(_s,{prompts:ua,onSelect:async n=>{s&&(s.write("\x1B[2J\x1B[3J\x1B[H"),s.isTTY&&s.write("\x1B[?2004h"));try{let o=await Vn.rollbackToBefore(n);if(o.success){let{targetPrompt:d}=o;il(dt),us(a=>a+1),Co(),Vt.current={completedIndex:0,columns:_.columns,historicalBlocks:[],seenSelections:new Set,chatId:dt,clearKey:qo+1};let x=wt.findLastIndex(a=>a.role==="user"&&a.text&&(a.text.startsWith(d)||a.text.includes(d))),g=[...wt];x!==-1&&(g=wt.slice(0,x)),O(g),H(g.length),f(d),S(d.split(`
265
+ \u2800`}])}else n.value==="remove"?z("deleteKey"):z("chat")}});case"deleteKey":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:"grey",paddingX:2,paddingY:1},(()=>{let n=nt(2);return e.createElement(l,{color:"white",bold:!0},"DANGER: CLEAR CREDENTIALS")})(),e.createElement(l,{marginTop:1},"This will permanently delete all saved API keys in credential cache. You will need to enter it again to use Flux."),e.createElement(c,{marginTop:1},e.createElement(bt,{title:"Are you sure?",items:[{label:"YES, CLEAR CREDENTIALS",value:"yes"},{label:"NO, GO BACK",value:"no"}],onSelect:async n=>{if(n.value==="yes"){await Ni(),zt(null),z("chat");let o=nt(2);O(d=>[...d,{id:Date.now(),role:"system",text:"[CREDENTIAL CLEARED] API Key removed successfully."}])}else z("key")},theme:xe.theme})));case"exit":return null;case"ask":return e.createElement(c,{width:"100%"},e.createElement(yl,{question:Vo?.question,options:Vo?.options,onResolve:n=>{Vo?.resolve&&Vo.resolve(n),rs(null),z("chat")},theme:xe.theme}));case"revert":return e.createElement(c,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(_s,{prompts:ua,onSelect:async n=>{s&&(s.write("\x1B[2J\x1B[3J\x1B[H"),s.isTTY&&s.write("\x1B[?2004h"));try{let o=await Vn.rollbackToBefore(n);if(o.success){let{targetPrompt:d}=o;il(dt),us(a=>a+1),Co(),Vt.current={completedIndex:0,columns:_.columns,historicalBlocks:[],seenSelections:new Set,chatId:dt,clearKey:qo+1};let x=Tt.findLastIndex(a=>a.role==="user"&&a.text&&(a.text.startsWith(d)||a.text.includes(d))),g=[...Tt];x!==-1&&(g=Tt.slice(0,x)),O(g),H(g.length),f(d),S(d.split(`
266
266
  `).length>2);let M=g.filter(a=>!String(a.id).startsWith("welcome")&&(!a.isMeta||a.text&&a.text.includes("Request Cancelled")));await Cn(dt,null,M);let u=nt(2);O(a=>{let p=[...a,{id:"revert-ok-"+Date.now(),role:"system",text:`\u2726 Rollback Successful
267
267
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Reverted prompt loaded to input box.
268
268
  \u2800`,isMeta:!0}];return H(p.length),p}),z("chat")}}catch(o){let d=nt(2);O(x=>{let g=[...x,{id:"revert-err-"+Date.now(),role:"system",text:`\u2726 ERROR
@@ -272,16 +272,16 @@ ${Ye}`,color:"cyan",isSteeringHint:!0,hintType:Ne?"QUESTION":"STEERING HINT",hin
272
272
  \u2800`,isMeta:!0}];return H(u.length),u})}},onDelete:async n=>await Er(n),onClose:()=>z("chat"),theme:xe.theme}));case"keybindingsPrompt":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:"grey",paddingX:2,paddingY:1,width:"100%"},e.createElement(l,{color:"white",bold:!0,underline:!0},"CONFIGURE SHIFT+ENTER NEWLINE"),e.createElement(l,null,`
273
273
  `,"To support multi-line inputs with ",e.createElement(l,{bold:!0,color:"white"},"Shift + Enter")," for newline, a terminal sequence keybinding needs to be added to your IDE configuration.",`
274
274
 
275
- `,"Would you like FluxFlow to automatically add this to your ",Ro()," keybindings?"),e.createElement(c,{marginTop:1},e.createElement(bt,{title:"Add Keybinding?",items:[{label:"Yes, configure automatically",value:"yes"},{label:"No, skip",value:"no"}],onSelect:async n=>{n.value==="yes"?await Gr(Ro()):$r="\\ + Enter",z("chat")},theme:xe.theme})));case"memory":return e.createElement(c,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(Ns,{onClose:()=>z("chat"),theme:xe.theme}));case"parserDownload":return e.createElement(c,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(Fs,{onClose:()=>z("settings")}));case"profile":return e.createElement(Is,{initialData:In,onSave:n=>{Ks(n),O(o=>[...o,{id:Date.now(),role:"system",text:`${n.name.length>0||n.nickname.length>0?`\u2726 Profile Updated${n.name.length>0?`
275
+ `,"Would you like FluxFlow to automatically add this to your ",Ro()," keybindings?"),e.createElement(c,{marginTop:1},e.createElement(bt,{title:"Add Keybinding?",items:[{label:"Yes, configure automatically",value:"yes"},{label:"No, skip",value:"no"}],onSelect:async n=>{n.value==="yes"?await Wr(Ro()):$r="\\ + Enter",z("chat")},theme:xe.theme})));case"memory":return e.createElement(c,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(Ns,{onClose:()=>z("chat"),theme:xe.theme}));case"parserDownload":return e.createElement(c,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(Fs,{onClose:()=>z("settings")}));case"profile":return e.createElement(Is,{initialData:In,onSave:n=>{Ks(n),O(o=>[...o,{id:Date.now(),role:"system",text:`${n.name.length>0||n.nickname.length>0?`\u2726 Profile Updated${n.name.length>0?`
276
276
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Name: ${n.name} `:""}${n.nickname.length>0?`
277
277
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Nickname: ${n.nickname}`:""}`:`\u2726 Profile
278
278
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Nothing to Update`}
279
279
 
280
280
  \u2726 Custom Instructions
281
281
  ${n.instructions.length>0?`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${n.instructions.substring(0,30)}${n.instructions.length>30?"...":""}`:"\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No Instructions Provided."}
282
- \u2800`,isMeta:!0}]),z("chat")},onCancel:()=>z("chat"),theme:xe.theme});case"resolution":return e.createElement(c,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(rc,{data:ma,theme:xe.theme,onResolve:n=>{cs(null),z("chat"),setTimeout(()=>{vi(n,!0)},500)},onEdit:n=>{cs(null),z("chat"),f(n)}}));case"approval":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1,width:"100%"},e.createElement(l,{color:"white",bold:!0,underline:!0},"FILE WRITE PERMISSION"),e.createElement(l,{marginTop:1},"The agent is attempting to modify: ",e.createElement(l,{color:"cyan"},Yn(Ao?.args||"{}").path||"Unknown File")),Jo()?e.createElement(c,{marginTop:1,paddingX:1},e.createElement(l,{color:"cyan",italic:!0},"FluxFlow Companion is active. Review the changes in your editor.")):e.createElement(c,{marginTop:1,borderStyle:"single",borderColor:"#333",paddingX:1,flexDirection:"column"},e.createElement(l,{color:"gray"},"--- PROPOSED CONTENT ---"),(()=>{let n=Yn(Ao?.args||"{}"),o=[],d=new Set;if(Object.keys(n).forEach(M=>{let u=M.match(/^(searchContent|replaceContent|newContent|content_to_replace|content_to_add|TargetContent|ReplacementContent|replacementContent)(\d+)?$/);if(u){let a=u[2]?parseInt(u[2]):1;d.add(a)}}),Array.from(d).sort((M,u)=>M-u).forEach(M=>{let u,a;M===1?(u=n.searchContent1??n.searchContent??n.replaceContent1??n.content_to_replace1??n.replaceContent??n.content_to_replace??n.TargetContent??null,a=n.newContent1??n.content_to_add1??n.newContent??n.content_to_add??n.ReplacementContent??n.replacementContent??null):(u=n[`searchContent${M}`]??n[`replaceContent${M}`]??n[`content_to_replace${M}`]??null,a=n[`newContent${M}`]??n[`content_to_add${M}`]??null),(u!==null||a!==null)&&o.push({replace:u,new:a})}),o.length>0)return e.createElement(c,{flexDirection:"column",marginTop:1},o.map((M,u)=>{let a=M.replace!==null,p=M.new!==null;return e.createElement(c,{key:u,flexDirection:"column",marginTop:u>0?1:0},o.length>1&&e.createElement(l,{color:"gray"},"Block ",u+1,":"),a&&e.createElement(c,null,e.createElement(l,{color:"red",wrap:"anywhere",bold:!0},"- ",M.replace)),p&&e.createElement(c,{marginTop:0},e.createElement(l,{color:"green",wrap:"anywhere",bold:!0},"+ ",M.new.replace(/\[\/n\]?/g,"\\n"))))}));let g=n.content||n.ReplacementContent||n.content_to_add||n.replacementContent||n.newContent||null;return e.createElement(l,{color:"white",wrap:"anywhere"},(g?g.replace(/\[\/n\]?/g,"\\n"):null)||"Updating file content...")})()),e.createElement(c,{marginTop:1},e.createElement(bt,{title:"Action Required",items:[{label:"Accept this time",value:"allow"},{label:"Accept for this session",value:"always"},{label:"Don't accept",value:"deny"}],onSelect:n=>{n.value==="always"&&sa(!0);let o=n.value==="deny"?"deny":"allow";Ao.resolve(o),pn(null),z("chat")},theme:xe.theme})));case"mode":return e.createElement(bt,{title:"SELECT EXECUTION MODE",items:[{label:`Flux (Dev Toolset Mode) ${C==="Flux"?"\u25CF":""}`,value:"Flux"},{label:`Flow (Chat / Conversation Mode) ${C==="Flow"?"\u25CF":""}`,value:"Flow"},{label:`ICU (Interactive Computer Use) ${C==="ICU"?"\u25CF":""}`,value:"ICU"},{label:`FluxCU (Autonomous Flux Computer Use) ${C==="FluxCU"?"\u25CF":""}`,value:"FluxCU"},{label:"Back",value:"chat"}],theme:xe.theme,onSelect:n=>{if(n.value==="chat"||n.value==="Back"){z("chat");return}let o=n.value;P(o),Ce(o==="Flow"?"Fast":"High"),O(d=>(H(d.length+1),[...d,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${Xs(o)}
283
- \u2800`,isMeta:!0}])),z("chat")},onClose:()=>z("chat")});case"display":return e.createElement(bt,{title:"SELECT ACTIVE DISPLAY FOR COMPUTER USE",items:[{label:`Primary Display (Display 1) ${N===0?"\u25CF":""}`,value:0},{label:`Secondary Display (Display 2) ${N===1?"\u25CF":""}`,value:1},{label:"Back",value:"chat"}],theme:xe.theme,onSelect:n=>{if(n.value==="chat"||n.value==="Back"){z("chat");return}let o=Number(n.value);L(o),Pt({display:o}).catch(()=>{});let d=o===0?"Primary (Display 1)":"Secondary (Display 2)";O(x=>(H(x.length+1),[...x,{id:Date.now(),role:"system",text:`\u2726 Active Computer Use display set to: ${d}`,isMeta:!0}])),z("chat")},onClose:()=>z("chat")});case"updateManager":return e.createElement(bt,{title:"Select Preferred Update Manager",subtitle:"NOTE: If you are unsure about these, go with NPM",items:[{label:"NPM (Standard)",value:"npm"},{label:"PNPM (Recommended)",value:"pnpm"},{label:"BUN (Ultra Fast)",value:"bun"},{label:"YARN (Classic)",value:"yarn"},{label:"Custom Command",value:"custom"},{label:"Back",value:"settings"}],onSelect:n=>{if(n.value==="settings"||n.value==="Back"){z("settings");return}n.value==="custom"?(Qt({label:"Enter Custom Update Command (Global install recommended):",key:"customUpdateCommand",value:xe.customUpdateCommand,next:o=>(It(d=>({...d,updateManager:"custom",customUpdateCommand:o})),null)}),z("input")):(It(o=>({...o,updateManager:n.value})),z("settings"))},theme:xe.theme});case"update":return e.createElement(vl,{latest:Wt,current:ao,settings:xe,onClose:()=>z("chat"),onSuccess:()=>{O(n=>(H(n.length+1),[...n,{id:"update-success-"+Date.now(),role:"system",text:`**[UPDATE COMPLETED]** Flux Flow successfully updated to v${Wt}.
284
- **Restart to see changes.**`,isMeta:!0}])),z("chat")},onUpdateSettings:n=>{z("updateManager")}});case"terminalApproval":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1,width:"100%"},e.createElement(l,{color:"white",bold:!0,underline:!0},"TERMINAL COMMAND OVERSIGHT"),e.createElement(c,{marginTop:1},e.createElement(l,null,"Agent requested to run: ",e.createElement(l,{color:"yellow",bold:!0},Yn(Ao?.args||"{}").command||"Unknown Command"))),e.createElement(c,{marginTop:1},e.createElement(bt,{title:"Risk Assessment Required",items:[{label:"Run",value:"allow"},{label:"Deny",value:"deny"}],onSelect:n=>{Ao.resolve(n.value),pn(null),z("chat")},theme:xe.theme})));default:return e.createElement(c,{flexDirection:"column",marginTop:1,flexShrink:0,width:"100%"},bi&&pi&&e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:i.borderMuted,paddingX:2,paddingY:1,width:"100%",marginBottom:1},e.createElement(c,{justifyContent:"space-between",width:"100%"},e.createElement(l,{color:i.text,bold:!0,underline:!0},"INQUIRY RESPONSE"),e.createElement(l,{color:i.textMuted},"[ ESC to Close ]")),e.createElement(c,{marginTop:1,width:"100%"},e.createElement(Ar,{text:pi,columns:_.columns-6,theme:xe.theme}))),Zr.filter(n=>n.status==="running").length>0&&e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:i.borderMuted,paddingX:2,paddingY:0,width:"100%",marginBottom:1},e.createElement(c,{justifyContent:"space-between",width:"100%"},e.createElement(l,{color:i.text,bold:!0},"ACTIVE SUBAGENTS")),e.createElement(c,{flexDirection:"column",marginTop:1,width:"100%"},Zr.filter(n=>n.status==="running").map(n=>e.createElement(lc,{key:n.id,sa:n,showTPMEstimate:xe.showTPMEstimate})))),Hn&&e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:i.borderMuted,paddingX:2,paddingY:0,width:"100%",marginBottom:0},e.createElement(c,{justifyContent:"space-between",width:"100%"},e.createElement(c,{flexDirection:"row",gap:1},e.createElement(l,{color:i.warning||"yellow",bold:!0},"\u2726 ",Hn.startsWith("/btw")?"Question Queued":"Steering Hint Queued"))),e.createElement(c,{marginTop:0,paddingLeft:2},e.createElement(l,{color:i.text,bold:!0},"\u2514\u2500 ",Hn.startsWith("/btw")?Hn.replace(/^\/btw\s*/,""):Hn))),e.createElement(c,{paddingX:1,marginBottom:0,justifyContent:"space-between",width:"100%"},e.createElement(c,null,Fn?e.createElement(c,{gap:1},e.createElement(Qd,null),e.createElement(tr,{text:Fn.trimEnd(),baseColor:i.textExclusive||i.text,glintColor:i.textMutedExclusive||i.textMuted,speed:60,italic:!0,glintWidth:2,typeSpeed:10}),e.createElement(l,{color:i.textMuted},mi>0?`(${mi.toFixed(0)}s)`:"")):e.createElement(l,{color:i.textMuted,italic:!0},k.length>0&&xi?"Press ESC again to clear input":ia?"Press CTRL + O to expand":"Waiting for input...")),e.createElement(c,null,(()=>{let n=Fn?.toLowerCase()??"";return bn&&Date.now()-qs>15e3&&Zr.length===0&&(n.includes("connecting")||n.includes("working")||n.includes("queue"))?e.createElement(c,null,e.createElement(tr,{text:"Waiting for API",baseColor:i.text,glintColor:i.textMuted,glintWidth:4,speed:80}),e.createElement(l,{color:i.textMuted,dimColor:!0}," \u2503 ")):is?e.createElement(c,null,e.createElement(tr,{text:is,baseColor:i.text,glintColor:i.textMuted,italic:!0,speed:80,typeSpeed:15}),e.createElement(l,{color:i.textMuted,dimColor:!0}," \u2503 ")):null})(),e.createElement(tr,{text:St.basename(He)||(He.length>1?He:"Use '/model model-id' to select model"),baseColor:i.text,glintColor:i.textMuted,glintWidth:3}),e.createElement(l,{color:i.textMuted}," ",He.length>0?ce.toLocaleLowerCase().includes("xhigh")?"":`(${ce})`:""),vr>0&&e.createElement(l,{color:i.textMuted}," [",vr," ",vr===1?"file":"files","]"))),e.createElement(c,{flexDirection:"column",width:"100%"},e.createElement(c,{width:"100%",height:1,overflow:"hidden"},e.createElement(l,{color:i.inputBorder},"\u2500".repeat(Math.max(1,_.columns)))),e.createElement(c,{paddingX:1,paddingY:0,width:"100%",flexDirection:"column"},e.createElement(c,{flexDirection:"column",width:"100%"},e.createElement(c,{flexDirection:"row",width:"100%",paddingY:0},e.createElement(c,{flexShrink:0,width:4},e.createElement(l,{color:i.inputPrompt,bold:!0},bn||gr?"\u2726 ":" \u276F ")),e.createElement(c,{flexGrow:1},e.createElement(c,{flexGrow:1,position:"relative"},k===""&&e.createElement(c,{position:"absolute",paddingLeft:0},oo&&!Nn?e.createElement(l,{color:"yellow"},ha?" Terminal is waiting for user input. Press TAB to interact":" Press TAB to interact with terminal..."):oo&&Nn?e.createElement(l,{color:"yellow",bold:!0}," [ TERMINAL FOCUSED ] Type to interact, press TAB to exit..."):xi===1?e.createElement(l,{color:i.inputPrompt,bold:!0}," Press ESC again to ",k.length>0?"clear input":"revert codebase to checkpoint","..."):e.createElement(l,{color:i.inputPlaceholder},da?" Press ESC again to cancel the request.":gr?" Compacting session history, please wait...":bn?" Enter a prompt to steer the agent.":wt.filter(n=>n.role==="user").length===0?` Send message, @file or /cmd (${na.shortcut} for newline)`:" Ask Follow-ups")),e.createElement(al,{key:`input-${I}`,onPasteStateChange:la,focus:!Nn&&!gr,showCursor:We&&!gr,cursorColor:i.inputText,lastFocusEventTime:je.current,value:k,textStyle:{bold:!0,color:i.inputText},columns:_.columns,onChange:n=>{let o=n.replace(/\r\n/g,`
282
+ \u2800`,isMeta:!0}]),z("chat")},onCancel:()=>z("chat"),theme:xe.theme});case"resolution":return e.createElement(c,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(rc,{data:ma,theme:xe.theme,onResolve:n=>{cs(null),z("chat"),setTimeout(()=>{vi(n,!0)},500)},onEdit:n=>{cs(null),z("chat"),f(n)}}));case"approval":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1,width:"100%"},e.createElement(l,{color:"white",bold:!0,underline:!0},"FILE WRITE PERMISSION"),e.createElement(l,{marginTop:1},"The agent is attempting to modify: ",e.createElement(l,{color:"cyan"},Yn(Ao?.args||"{}").path||"Unknown File")),Jo()?e.createElement(c,{marginTop:1,paddingX:1},e.createElement(l,{color:"cyan",italic:!0},"FluxFlow Companion is active. Review the changes in your editor.")):e.createElement(c,{marginTop:1,borderStyle:"single",borderColor:"#333",paddingX:1,flexDirection:"column"},e.createElement(l,{color:"gray"},"--- PROPOSED CONTENT ---"),(()=>{let n=Yn(Ao?.args||"{}"),o=[],d=new Set;if(Object.keys(n).forEach(M=>{let u=M.match(/^(searchContent|replaceContent|newContent|content_to_replace|content_to_add|TargetContent|ReplacementContent|replacementContent)(\d+)?$/);if(u){let a=u[2]?parseInt(u[2]):1;d.add(a)}}),Array.from(d).sort((M,u)=>M-u).forEach(M=>{let u,a;M===1?(u=n.searchContent1??n.searchContent??n.replaceContent1??n.content_to_replace1??n.replaceContent??n.content_to_replace??n.TargetContent??null,a=n.newContent1??n.content_to_add1??n.newContent??n.content_to_add??n.ReplacementContent??n.replacementContent??null):(u=n[`searchContent${M}`]??n[`replaceContent${M}`]??n[`content_to_replace${M}`]??null,a=n[`newContent${M}`]??n[`content_to_add${M}`]??null),(u!==null||a!==null)&&o.push({replace:u,new:a})}),o.length>0)return e.createElement(c,{flexDirection:"column",marginTop:1},o.map((M,u)=>{let a=M.replace!==null,p=M.new!==null;return e.createElement(c,{key:u,flexDirection:"column",marginTop:u>0?1:0},o.length>1&&e.createElement(l,{color:"gray"},"Block ",u+1,":"),a&&e.createElement(c,null,e.createElement(l,{color:"red",wrap:"anywhere",bold:!0},"- ",M.replace)),p&&e.createElement(c,{marginTop:0},e.createElement(l,{color:"green",wrap:"anywhere",bold:!0},"+ ",M.new.replace(/\[\/n\]?/g,"\\n"))))}));let g=n.content||n.ReplacementContent||n.content_to_add||n.replacementContent||n.newContent||null;return e.createElement(l,{color:"white",wrap:"anywhere"},(g?g.replace(/\[\/n\]?/g,"\\n"):null)||"Updating file content...")})()),e.createElement(c,{marginTop:1},e.createElement(bt,{title:"Action Required",items:[{label:"Accept this time",value:"allow"},{label:"Accept for this session",value:"always"},{label:"Don't accept",value:"deny"}],onSelect:n=>{n.value==="always"&&sa(!0);let o=n.value==="deny"?"deny":"allow";Ao.resolve(o),pn(null),z("chat")},theme:xe.theme})));case"mode":return e.createElement(bt,{title:"SELECT EXECUTION MODE",items:[{label:`Flux (Dev Toolset Mode) ${C==="Flux"?"\u25CF":""}`,value:"Flux"},{label:`Flow (Chat / Conversation Mode) ${C==="Flow"?"\u25CF":""}`,value:"Flow"},{label:`ICU (Interactive Computer Use) ${C==="ICU"?"\u25CF":""}`,value:"ICU"},{label:`FluxCU (Autonomous Flux Computer Use) ${C==="FluxCU"?"\u25CF":""}`,value:"FluxCU"},{label:"Back",value:"chat"}],theme:xe.theme,onSelect:n=>{if(n.value==="chat"||n.value==="Back"){z("chat");return}let o=n.value;P(o),Se(o==="Flow"?"Fast":"High"),O(d=>(H(d.length+1),[...d,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${Xs(o)}
283
+ \u2800`,isMeta:!0}])),z("chat")},onClose:()=>z("chat")});case"display":return e.createElement(bt,{title:"SELECT ACTIVE DISPLAY FOR COMPUTER USE",items:[{label:`Primary Display (Display 1) ${N===0?"\u25CF":""}`,value:0},{label:`Secondary Display (Display 2) ${N===1?"\u25CF":""}`,value:1},{label:"Back",value:"chat"}],theme:xe.theme,onSelect:n=>{if(n.value==="chat"||n.value==="Back"){z("chat");return}let o=Number(n.value);L(o),Pt({display:o}).catch(()=>{});let d=o===0?"Primary (Display 1)":"Secondary (Display 2)";O(x=>(H(x.length+1),[...x,{id:Date.now(),role:"system",text:`\u2726 Active Computer Use display set to: ${d}`,isMeta:!0}])),z("chat")},onClose:()=>z("chat")});case"updateManager":return e.createElement(bt,{title:"Select Preferred Update Manager",subtitle:"NOTE: If you are unsure about these, go with NPM",items:[{label:"NPM (Standard)",value:"npm"},{label:"PNPM (Recommended)",value:"pnpm"},{label:"BUN (Ultra Fast)",value:"bun"},{label:"YARN (Classic)",value:"yarn"},{label:"Custom Command",value:"custom"},{label:"Back",value:"settings"}],onSelect:n=>{if(n.value==="settings"||n.value==="Back"){z("settings");return}n.value==="custom"?(Qt({label:"Enter Custom Update Command (Global install recommended):",key:"customUpdateCommand",value:xe.customUpdateCommand,next:o=>(It(d=>({...d,updateManager:"custom",customUpdateCommand:o})),null)}),z("input")):(It(o=>({...o,updateManager:n.value})),z("settings"))},theme:xe.theme});case"update":return e.createElement(vl,{latest:Gt,current:ao,settings:xe,onClose:()=>z("chat"),onSuccess:()=>{O(n=>(H(n.length+1),[...n,{id:"update-success-"+Date.now(),role:"system",text:`**[UPDATE COMPLETED]** Flux Flow successfully updated to v${Gt}.
284
+ **Restart to see changes.**`,isMeta:!0}])),z("chat")},onUpdateSettings:n=>{z("updateManager")}});case"terminalApproval":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1,width:"100%"},e.createElement(l,{color:"white",bold:!0,underline:!0},"TERMINAL COMMAND OVERSIGHT"),e.createElement(c,{marginTop:1},e.createElement(l,null,"Agent requested to run: ",e.createElement(l,{color:"yellow",bold:!0},Yn(Ao?.args||"{}").command||"Unknown Command"))),e.createElement(c,{marginTop:1},e.createElement(bt,{title:"Risk Assessment Required",items:[{label:"Run",value:"allow"},{label:"Deny",value:"deny"}],onSelect:n=>{Ao.resolve(n.value),pn(null),z("chat")},theme:xe.theme})));default:return e.createElement(c,{flexDirection:"column",marginTop:1,flexShrink:0,width:"100%"},bi&&pi&&e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:i.borderMuted,paddingX:2,paddingY:1,width:"100%",marginBottom:1},e.createElement(c,{justifyContent:"space-between",width:"100%"},e.createElement(l,{color:i.text,bold:!0,underline:!0},"INQUIRY RESPONSE"),e.createElement(l,{color:i.textMuted},"[ ESC to Close ]")),e.createElement(c,{marginTop:1,width:"100%"},e.createElement(Ar,{text:pi,columns:_.columns-6,theme:xe.theme}))),Zr.filter(n=>n.status==="running").length>0&&e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:i.borderMuted,paddingX:2,paddingY:0,width:"100%",marginBottom:1},e.createElement(c,{justifyContent:"space-between",width:"100%"},e.createElement(l,{color:i.text,bold:!0},"ACTIVE SUBAGENTS")),e.createElement(c,{flexDirection:"column",marginTop:1,width:"100%"},Zr.filter(n=>n.status==="running").map(n=>e.createElement(lc,{key:n.id,sa:n,showTPMEstimate:xe.showTPMEstimate})))),Hn&&e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:i.borderMuted,paddingX:2,paddingY:0,width:"100%",marginBottom:0},e.createElement(c,{justifyContent:"space-between",width:"100%"},e.createElement(c,{flexDirection:"row",gap:1},e.createElement(l,{color:i.warning||"yellow",bold:!0},"\u2726 ",Hn.startsWith("/btw")?"Question Queued":"Steering Hint Queued"))),e.createElement(c,{marginTop:0,paddingLeft:2},e.createElement(l,{color:i.text,bold:!0},"\u2514\u2500 ",Hn.startsWith("/btw")?Hn.replace(/^\/btw\s*/,""):Hn))),e.createElement(c,{paddingX:1,marginBottom:0,justifyContent:"space-between",width:"100%"},e.createElement(c,null,Fn?e.createElement(c,{gap:1},e.createElement(Qd,null),e.createElement(tr,{text:Fn.trimEnd(),baseColor:i.textExclusive||i.text,glintColor:i.textMutedExclusive||i.textMuted,speed:60,italic:!0,glintWidth:2,typeSpeed:10}),e.createElement(l,{color:i.textMuted},mi>0?`(${mi.toFixed(0)}s)`:"")):e.createElement(l,{color:i.textMuted,italic:!0},k.length>0&&xi?"Press ESC again to clear input":ia?"Press CTRL + O to expand":"Waiting for input...")),e.createElement(c,null,(()=>{let n=Fn?.toLowerCase()??"";return bn&&Date.now()-qs>15e3&&Zr.length===0&&(n.includes("connecting")||n.includes("working")||n.includes("queue"))?e.createElement(c,null,e.createElement(tr,{text:"Waiting for API",baseColor:i.text,glintColor:i.textMuted,glintWidth:4,speed:80}),e.createElement(l,{color:i.textMuted,dimColor:!0}," \u2503 ")):is?e.createElement(c,null,e.createElement(tr,{text:is,baseColor:i.text,glintColor:i.textMuted,italic:!0,speed:80,typeSpeed:15}),e.createElement(l,{color:i.textMuted,dimColor:!0}," \u2503 ")):null})(),e.createElement(tr,{text:St.basename(Ge)||(Ge.length>1?Ge:"Use '/model model-id' to select model"),baseColor:i.text,glintColor:i.textMuted,glintWidth:3}),e.createElement(l,{color:i.textMuted}," ",Ge.length>0?ce.toLocaleLowerCase().includes("xhigh")?"":`(${ce})`:""),vr>0&&e.createElement(l,{color:i.textMuted}," [",vr," ",vr===1?"file":"files","]"))),e.createElement(c,{flexDirection:"column",width:"100%"},e.createElement(c,{width:"100%",height:1,overflow:"hidden"},e.createElement(l,{color:i.inputBorder},"\u2500".repeat(Math.max(1,_.columns)))),e.createElement(c,{paddingX:1,paddingY:0,width:"100%",flexDirection:"column"},e.createElement(c,{flexDirection:"column",width:"100%"},e.createElement(c,{flexDirection:"row",width:"100%",paddingY:0},e.createElement(c,{flexShrink:0,width:4},e.createElement(l,{color:i.inputPrompt,bold:!0},bn||gr?"\u2726 ":" \u276F ")),e.createElement(c,{flexGrow:1},e.createElement(c,{flexGrow:1,position:"relative"},k===""&&e.createElement(c,{position:"absolute",paddingLeft:0},oo&&!Nn?e.createElement(l,{color:"yellow"},ha?" Terminal is waiting for user input. Press TAB to interact":" Press TAB to interact with terminal..."):oo&&Nn?e.createElement(l,{color:"yellow",bold:!0}," [ TERMINAL FOCUSED ] Type to interact, press TAB to exit..."):xi===1?e.createElement(l,{color:i.inputPrompt,bold:!0}," Press ESC again to ",k.length>0?"clear input":"revert codebase to checkpoint","..."):e.createElement(l,{color:i.inputPlaceholder},da?" Press ESC again to cancel the request.":gr?" Compacting session history, please wait...":bn?" Enter a prompt to steer the agent.":Tt.filter(n=>n.role==="user").length===0?` Send message, @file or /cmd (${na.shortcut} for newline)`:" Ask Follow-ups")),e.createElement(al,{key:`input-${I}`,onPasteStateChange:la,focus:!Nn&&!gr,showCursor:Ye&&!gr,cursorColor:i.inputText,lastFocusEventTime:je.current,value:k,textStyle:{bold:!0,color:i.inputText},columns:_.columns,onChange:n=>{let o=n.replace(/\r\n/g,`
285
285
  `).replace(/\r/g,`
286
286
  `).replace(/\\\s*\n/g,`
287
- `);f(o),ie(!1)},onSubmit:vi,rows:1,maxRows:10,keyBindings:{submit:n=>n.return&&!n.shift&&!n.ctrl,newline:n=>n.return&&n.shift||n.return&&n.ctrl}})))))),e.createElement(c,{width:"100%",height:1,overflow:"hidden"},e.createElement(l,{color:i.inputBorder},"\u2500".repeat(Math.max(1,_.columns))))))}};return e.createElement(c,{flexDirection:"column",width:"100%"},Re?null:pe?e.createElement(tc,{width:s?.columns||80,height:s?.rows||24,selectedIndex:ve,aiProvider:B,theme:xe.theme}):e.createElement(e.Fragment,null,e.createElement(c,{paddingX:1,flexDirection:"column",width:"100%"},e.createElement(zd,{key:`static-${qo}-${dt}-${_.columns}-${xe.theme}`,items:Mi.completed},n=>e.createElement(Lr,{key:n.key,block:n,columns:(s?.columns||80)-2,showFullThinking:en,aiProvider:B,version:ao,theme:xe.theme}))),e.createElement(c,{flexDirection:"column",paddingX:1,paddingBottom:0,width:"100%"},(mt==="chat"||["ask","approval","terminalApproval"].includes(mt))&&e.createElement(c,{flexDirection:"column",width:"100%"},Mi.active.map(n=>e.createElement(Lr,{key:n.key,block:n,columns:Math.max(20,(s?.columns||80)-2),showFullThinking:en,aiProvider:B,version:ao,theme:xe.theme})),oo&&e.createElement(c,{marginTop:1},e.createElement(Ir,{command:oo,output:xn,isFocused:Nn,isPty:Sn,terminalHeight:_.rows,columns:_.columns}))),Re?e.createElement(c,{borderStyle:"double",borderColor:"grey",padding:1,flexShrink:0},e.createElement(l,{color:"white"},"Starting Flux Flow...")):kt?pa():e.createElement(c,{borderStyle:"round",borderColor:"white",padding:0,flexDirection:"column",flexShrink:0,width:"100%"},e.createElement(c,{paddingX:1,marginBottom:1},e.createElement(l,{color:"gray",bold:!0},"API KEY REQUIRED")),e.createElement(c,{paddingX:1,flexDirection:"column"},qe===0?e.createElement(e.Fragment,null,e.createElement(l,{color:"white"},"Select your Preferred Provider:"),e.createElement(c,{marginTop:1},e.createElement(bt,{searchable:!0,items:[{label:"Google",value:"Google"},{label:"Nvidia",value:"NVIDIA"},{label:"DeepSeek",value:"DeepSeek"},{label:"InferX",value:"InferX"},{label:"SenseNova",value:"SenseNova"},{label:"CrofAI",value:"CrofAI"},{label:"Poolside",value:"Poolside"},{label:"Experiential Labs",value:"ExpLabs"},{label:"Token Harbor",value:"TokenHarbor"},{label:"APInex",value:"APInex"},...process.env.ENABLE_9ROUTER==="true"||process.env.ENABLE_9ROUTER===!0?[{label:"9router",value:"9router"}]:[],{label:"Ollama",value:"Ollama"},{label:"AIHubMix [EXPERIMENTAL]",value:"AIHubMix"},{label:"Mistral [EXPERIMENTAL]",value:"Mistral"},{label:"OpenRouter [EXPERIMENTAL]",value:"OpenRouter"}],onSelect:n=>{$e(n.value),Ct(1)}}))):e.createElement(e.Fragment,null,e.createElement(l,{color:"white"},B==="Ollama"?"Enter Ollama API Key (or type LOCAL to use local host):":`Enter your ${B} API Key:`),e.createElement(c,{marginTop:1},e.createElement(l,{color:"gray",bold:!0}," ",">"," "),e.createElement(Ur,{value:Xr,onChange:on,onSubmit:Si,mask:"*"})))),e.createElement(c,{paddingX:1,marginTop:1},e.createElement(l,{color:"gray",italic:!0},qe===0?"(Use arrows to select and Enter to confirm, ESC to go back)":"(Press Enter to confirm and initialize, ESC to go back)"))),h&&e.createElement(c,{borderStyle:"round",borderColor:i.borderMuted,paddingX:1,marginY:0,width:"100%"},e.createElement(l,null,e.createElement(l,{color:"red",bold:!0},"\u{1F534} EXIT: "),e.createElement(l,{color:i.text},"Press "),e.createElement(l,{color:i.text,bold:!0},"CTRL+C"),e.createElement(l,{color:i.text}," again to exit (",T,"s) \u2022 Press "),e.createElement(l,{color:i.textMuted,bold:!0},"ESC"),e.createElement(l,{color:i.text}," to cancel"))),Ve.length>0&&(()=>{let o=le.current,d=0;for(;d<Ve.length;){let F=Ve[d],Q=F?.cmd||F||"";if(typeof Q=="string"&&Q.trimStart().startsWith("---"))d++;else break}ge<=d?o=0:ge<o?o=ge:ge>=o+5&&(o=ge-5+1),o=Math.max(0,Math.min(o,Math.max(0,Ve.length-5))),le.current=o;let x=Ve.slice(o,o+5),g=Ve.length-(o+x.length),M=Ve[0]?.cmd?.startsWith("@")||Ve[0]?.cmd?.startsWith("\\@"),u=k.startsWith("/model"),a=k.startsWith("/thinking"),p=Ve.length,D=Math.min(p,ge+1);return e.createElement(c,{flexDirection:"column",width:"100%",marginBottom:1,marginTop:0},e.createElement(c,{paddingX:1,marginBottom:0,justifyContent:"space-between",width:"100%"},e.createElement(c,{flexDirection:"row"},e.createElement(l,{color:i.primary||i.text,bold:!0},M?"FILES":u?"SAVED MODELS":a?"THINKING LEVELS":"COMMANDS"),e.createElement(l,{color:i.textMuted}," (",p,")")),e.createElement(c,{flexDirection:"row"},M?e.createElement(l,{color:i.textMuted,italic:!0},"Use #Lstart-Lend for line range \u2022 Tab to select"):e.createElement(l,{color:i.textMuted,italic:!0},"\u2191/\u2193 navigate \u2022 Tab / Enter select \u2022 Esc dismiss"))),e.createElement(c,{width:"100%",height:1,overflow:"hidden"},e.createElement(l,{color:i.borderDim||i.inputBorder||i.textDim},"\u2500".repeat(Math.max(1,_.columns)))),x.slice(0,hr).map((F,Q)=>{let Y=o+Q===ge,V=typeof F.cmd=="string"&&F.cmd.trimStart().startsWith("---"),K=F.cmd===go("Google","Free")&&lt!=="Free",G=F.display||(F.cmd&&(F.cmd.startsWith("@[")||F.cmd.startsWith("\\@["))&&F.cmd.endsWith("]")?(()=>{let _e=(F.cmd.startsWith("\\@[")?F.cmd.slice(3,-1):F.cmd.slice(2,-1)).split(/[\/\\]/);return _e[_e.length-1]})():F.cmd&&F.cmd.includes("/")?F.cmd.split("/").pop():F.cmd);if(u){let _e=F.multimodal===!0||yr(F.cmd||F)?"Multimodal":"Text Only";return e.createElement(c,{key:F.cmd||Q,flexDirection:"row",backgroundColor:Y?i.highlightBg:void 0,paddingX:1,height:1,alignItems:"center",justifyContent:"space-between"},e.createElement(c,{flexDirection:"row",alignItems:"center",flexGrow:1,overflow:"hidden"},e.createElement(c,{width:3,flexShrink:0},e.createElement(l,{color:Y?i.primary||i.text:i.textMuted,bold:Y},Y?"\u276F ":" ")),e.createElement(l,{color:V?i.textDim:K?i.textMuted:Y&&i.inputText||i.text,bold:Y},G)),e.createElement(c,{flexShrink:0,marginLeft:2},e.createElement(l,{color:Y?i.text:i.textMuted,italic:!Y},_e)))}return e.createElement(c,{key:F.cmd||Q,flexDirection:"row",backgroundColor:Y?i.highlightBg:void 0,paddingX:1,height:1,alignItems:"center"},e.createElement(c,{width:3,flexShrink:0},e.createElement(l,{color:Y?i.primary||i.text:i.textMuted,bold:Y},Y?"\u276F ":" ")),e.createElement(c,{width:26,flexShrink:0},e.createElement(l,{color:V?i.textDim:K?i.textMuted:Y&&i.inputText||i.text,bold:Y},G)),e.createElement(c,{flexGrow:1,overflow:"hidden"},e.createElement(l,{color:Y?i.text:i.textMuted,italic:!Y},F.desc)))}),Ve.length>5&&e.createElement(c,{paddingX:1,height:1,justifyContent:"space-between",width:"100%"},e.createElement(l,{color:i.textMuted,dimColor:!0,italic:!0},g>0?`... ${g} more available`:"(End of list)"),e.createElement(l,{color:i.textMuted,dimColor:!0},`${D}/${p}`)))})(),e.createElement(c,{flexShrink:0,width:"100%"},e.createElement(bl,{mode:C,thinkingLevel:ce,tokens:co.tokens,tokensTotal:Vl,cachedTokens:jl,promptTokens:Kl,chatId:dt,isMemoryEnabled:xe.memory,apiTier:lt,aiProvider:B,activeModel:He,isProcessing:bn,lastChunkTime:qs,theme:xe.theme,wps:qr.current.wps,showTPMEstimate:xe.showTPMEstimate})),mt==="exit"&&(()=>{let n=Date.now()-Gs,o=vt.toolSuccess+vt.toolFailure,d=o>0?(vt.toolSuccess/o*100).toFixed(1):"0.0",x=ir+lr,g=x>0?(ir/x*100).toFixed(1):"0.0",M=x>0?(lr/x*100).toFixed(1):"0.0";return e.createElement(c,{flexDirection:"column",borderStyle:"round",paddingX:3,paddingY:1,borderColor:i.borderMuted,width:Math.min(100,(s?.columns||100)-2),marginTop:0,marginBottom:0},e.createElement(c,{marginBottom:1},e.createElement(l,{bold:!0},Zd(i.logoGradient||["blue","purple"])("Agent powering down. Goodbye!"))),e.createElement(c,{flexDirection:"column"},e.createElement(l,{color:i.text,bold:!0,underline:!0},"Interaction Summary"),e.createElement(c,{marginTop:1},e.createElement(c,{width:20},e.createElement(l,{color:i.secondary},"Session ID:")),e.createElement(l,{color:i.text},dt)),e.createElement(c,null,e.createElement(c,{width:20},e.createElement(l,{color:i.secondary},"Tool Calls:")),e.createElement(l,{color:i.text},vt.toolSuccess+vt.toolFailure+vt.toolDenied," ( ",e.createElement(l,{color:"green"},"\u2714 ",vt.toolSuccess)," ",e.createElement(l,{color:"yellow"},"\u{1F6C7} ",vt.toolDenied)," ",e.createElement(l,{color:"red"},"\u2718 ",vt.toolFailure)," )")),e.createElement(c,null,e.createElement(c,{width:20},e.createElement(l,{color:i.secondary},"Success Rate:")),e.createElement(l,{color:i.text},d,"%")),e.createElement(c,null,e.createElement(c,{width:20},e.createElement(l,{color:i.secondary},"Code Changes:")),e.createElement(l,{color:i.text},e.createElement(l,{color:"green"},"+",vt.linesAdded)," ",e.createElement(l,{color:"red"},"-",vt.linesRemoved))),Yt>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:20},e.createElement(l,{color:i.secondary},"Tokens Consumed:")),e.createElement(l,{color:i.text},ht(Yt))),e.createElement(c,{marginLeft:2},e.createElement(c,{width:18},e.createElement(l,{color:i.textMuted},"\xBB Input Tokens:")),e.createElement(l,{color:i.text},ht(Yt-mn))),eo>0&&e.createElement(c,{marginLeft:4},e.createElement(c,{width:16},e.createElement(l,{color:i.textMuted},"\xBB Cached:")),e.createElement(l,{color:i.text},ht(eo))),mn>0&&e.createElement(c,{marginLeft:2},e.createElement(c,{width:18},e.createElement(l,{color:i.textMuted},"\xBB Output Tokens:")),e.createElement(l,{color:i.text},ht(mn)))),ar>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:20},e.createElement(l,{color:i.secondary},"Images Made:")),e.createElement(l,{color:i.text},ar)),e.createElement(c,null,e.createElement(c,{width:20},e.createElement(l,{color:i.secondary},"Image Credits:")),e.createElement(l,{color:i.text},Number(((ni||0)*1e3).toFixed(0))," credits")))),e.createElement(c,{flexDirection:"column",marginTop:1},e.createElement(l,{color:i.text,bold:!0,underline:!0},"Performance"),e.createElement(c,{marginTop:1},e.createElement(c,{width:20},e.createElement(l,{color:i.secondary},"Wall Time:")),e.createElement(l,{color:i.text},jo(n))),e.createElement(c,null,e.createElement(c,{width:20},e.createElement(l,{color:i.secondary},"Agent Active:")),e.createElement(l,{color:i.text},jo(x))),e.createElement(c,{marginLeft:2},e.createElement(c,{width:18},e.createElement(l,{color:i.textMuted},"\xBB API Time:")),e.createElement(l,{color:i.text},jo(ir)," (",g,"%)")),e.createElement(c,{marginLeft:2},e.createElement(c,{width:18},e.createElement(l,{color:i.textMuted},"\xBB Tool Time:")),e.createElement(l,{color:i.text},jo(lr)," (",M,"%)"))))})())))}export{Hs as check9RouterReachable,ac as default};
287
+ `);f(o),ie(!1)},onSubmit:vi,rows:1,maxRows:10,keyBindings:{submit:n=>n.return&&!n.shift&&!n.ctrl,newline:n=>n.return&&n.shift||n.return&&n.ctrl}})))))),e.createElement(c,{width:"100%",height:1,overflow:"hidden"},e.createElement(l,{color:i.inputBorder},"\u2500".repeat(Math.max(1,_.columns))))))}};return e.createElement(c,{flexDirection:"column",width:"100%"},Re?null:pe?e.createElement(tc,{width:s?.columns||80,height:s?.rows||24,selectedIndex:Ce,aiProvider:D,theme:xe.theme}):e.createElement(e.Fragment,null,e.createElement(c,{paddingX:1,flexDirection:"column",width:"100%"},e.createElement(zd,{key:`static-${qo}-${dt}-${_.columns}-${xe.theme}`,items:Mi.completed},n=>e.createElement(Lr,{key:n.key,block:n,columns:(s?.columns||80)-2,showFullThinking:en,aiProvider:D,version:ao,theme:xe.theme}))),e.createElement(c,{flexDirection:"column",paddingX:1,paddingBottom:0,width:"100%"},(mt==="chat"||["ask","approval","terminalApproval"].includes(mt))&&e.createElement(c,{flexDirection:"column",width:"100%"},Mi.active.map(n=>e.createElement(Lr,{key:n.key,block:n,columns:Math.max(20,(s?.columns||80)-2),showFullThinking:en,aiProvider:D,version:ao,theme:xe.theme})),oo&&e.createElement(c,{marginTop:1},e.createElement(Ir,{command:oo,output:xn,isFocused:Nn,isPty:Sn,terminalHeight:_.rows,columns:_.columns}))),Re?e.createElement(c,{borderStyle:"double",borderColor:"grey",padding:1,flexShrink:0},e.createElement(l,{color:"white"},"Starting Flux Flow...")):kt?pa():e.createElement(c,{borderStyle:"round",borderColor:"white",padding:0,flexDirection:"column",flexShrink:0,width:"100%"},e.createElement(c,{paddingX:1,marginBottom:1},e.createElement(l,{color:"gray",bold:!0},"API KEY REQUIRED")),e.createElement(c,{paddingX:1,flexDirection:"column"},qe===0?e.createElement(e.Fragment,null,e.createElement(l,{color:"white"},"Select your Preferred Provider:"),e.createElement(c,{marginTop:1},e.createElement(bt,{searchable:!0,items:[{label:"Google",value:"Google"},{label:"Nvidia",value:"NVIDIA"},{label:"DeepSeek",value:"DeepSeek"},{label:"InferX",value:"InferX"},{label:"SenseNova",value:"SenseNova"},{label:"CrofAI",value:"CrofAI"},{label:"Poolside",value:"Poolside"},{label:"Experiential Labs",value:"ExpLabs"},{label:"Token Harbor",value:"TokenHarbor"},{label:"APInex",value:"APInex"},...process.env.ENABLE_9ROUTER==="true"||process.env.ENABLE_9ROUTER===!0?[{label:"9router",value:"9router"}]:[],{label:"Ollama",value:"Ollama"},{label:"AIHubMix [EXPERIMENTAL]",value:"AIHubMix"},{label:"Mistral [EXPERIMENTAL]",value:"Mistral"},{label:"OpenRouter [EXPERIMENTAL]",value:"OpenRouter"}],onSelect:n=>{Ue(n.value),Ct(1)}}))):e.createElement(e.Fragment,null,e.createElement(l,{color:"white"},D==="Ollama"?"Enter Ollama API Key (or type LOCAL to use local host):":`Enter your ${D} API Key:`),e.createElement(c,{marginTop:1},e.createElement(l,{color:"gray",bold:!0}," ",">"," "),e.createElement(Ur,{value:Xr,onChange:on,onSubmit:Si,mask:"*"})))),e.createElement(c,{paddingX:1,marginTop:1},e.createElement(l,{color:"gray",italic:!0},qe===0?"(Use arrows to select and Enter to confirm, ESC to go back)":"(Press Enter to confirm and initialize, ESC to go back)"))),h&&e.createElement(c,{borderStyle:"round",borderColor:i.borderMuted,paddingX:1,marginY:0,width:"100%"},e.createElement(l,null,e.createElement(l,{color:"red",bold:!0},"\u{1F534} EXIT: "),e.createElement(l,{color:i.text},"Press "),e.createElement(l,{color:i.text,bold:!0},"CTRL+C"),e.createElement(l,{color:i.text}," again to exit (",T,"s) \u2022 Press "),e.createElement(l,{color:i.textMuted,bold:!0},"ESC"),e.createElement(l,{color:i.text}," to cancel"))),Ve.length>0&&(()=>{let o=le.current,d=0;for(;d<Ve.length;){let F=Ve[d],K=F?.cmd||F||"";if(typeof K=="string"&&K.trimStart().startsWith("---"))d++;else break}ge<=d?o=0:ge<o?o=ge:ge>=o+5&&(o=ge-5+1),o=Math.max(0,Math.min(o,Math.max(0,Ve.length-5))),le.current=o;let x=Ve.slice(o,o+5),g=Ve.length-(o+x.length),M=Ve[0]?.cmd?.startsWith("@")||Ve[0]?.cmd?.startsWith("\\@"),u=k.startsWith("/model"),a=k.startsWith("/thinking"),p=Ve.length,B=Math.min(p,ge+1);return e.createElement(c,{flexDirection:"column",width:"100%",marginBottom:1,marginTop:0},e.createElement(c,{paddingX:1,marginBottom:0,justifyContent:"space-between",width:"100%"},e.createElement(c,{flexDirection:"row"},e.createElement(l,{color:i.primary||i.text,bold:!0},M?"FILES":u?"SAVED MODELS":a?"THINKING LEVELS":"COMMANDS"),e.createElement(l,{color:i.textMuted}," (",p,")")),e.createElement(c,{flexDirection:"row"},M?e.createElement(l,{color:i.textMuted,italic:!0},"Use #Lstart-Lend for line range \u2022 Tab to select"):e.createElement(l,{color:i.textMuted,italic:!0},"\u2191/\u2193 navigate \u2022 Tab / Enter select \u2022 Esc dismiss"))),e.createElement(c,{width:"100%",height:1,overflow:"hidden"},e.createElement(l,{color:i.borderDim||i.inputBorder||i.textDim},"\u2500".repeat(Math.max(1,_.columns)))),x.slice(0,hr).map((F,K)=>{let Y=o+K===ge,V=typeof F.cmd=="string"&&F.cmd.trimStart().startsWith("---"),q=F.cmd===go("Google","Free")&&lt!=="Free",W=F.display||(F.cmd&&(F.cmd.startsWith("@[")||F.cmd.startsWith("\\@["))&&F.cmd.endsWith("]")?(()=>{let _e=(F.cmd.startsWith("\\@[")?F.cmd.slice(3,-1):F.cmd.slice(2,-1)).split(/[\/\\]/);return _e[_e.length-1]})():F.cmd&&F.cmd.includes("/")?F.cmd.split("/").pop():F.cmd);if(u){let _e=F.multimodal===!0||yr(F.cmd||F)?"Multimodal":"Text Only";return e.createElement(c,{key:F.cmd||K,flexDirection:"row",backgroundColor:Y?i.highlightBg:void 0,paddingX:1,height:1,alignItems:"center",justifyContent:"space-between"},e.createElement(c,{flexDirection:"row",alignItems:"center",flexGrow:1,overflow:"hidden"},e.createElement(c,{width:3,flexShrink:0},e.createElement(l,{color:Y?i.primary||i.text:i.textMuted,bold:Y},Y?"\u276F ":" ")),e.createElement(l,{color:V?i.textDim:q?i.textMuted:Y&&i.inputText||i.text,bold:Y},W)),e.createElement(c,{flexShrink:0,marginLeft:2},e.createElement(l,{color:Y?i.text:i.textMuted,italic:!Y},_e)))}return e.createElement(c,{key:F.cmd||K,flexDirection:"row",backgroundColor:Y?i.highlightBg:void 0,paddingX:1,height:1,alignItems:"center"},e.createElement(c,{width:3,flexShrink:0},e.createElement(l,{color:Y?i.primary||i.text:i.textMuted,bold:Y},Y?"\u276F ":" ")),e.createElement(c,{width:26,flexShrink:0},e.createElement(l,{color:V?i.textDim:q?i.textMuted:Y&&i.inputText||i.text,bold:Y},W)),e.createElement(c,{flexGrow:1,overflow:"hidden"},e.createElement(l,{color:Y?i.text:i.textMuted,italic:!Y},F.desc)))}),Ve.length>5&&e.createElement(c,{paddingX:1,height:1,justifyContent:"space-between",width:"100%"},e.createElement(l,{color:i.textMuted,dimColor:!0,italic:!0},g>0?`... ${g} more available`:"(End of list)"),e.createElement(l,{color:i.textMuted,dimColor:!0},`${B}/${p}`)))})(),e.createElement(c,{flexShrink:0,width:"100%"},e.createElement(bl,{mode:C,thinkingLevel:ce,tokens:co.tokens,tokensTotal:Vl,cachedTokens:jl,promptTokens:Kl,chatId:dt,isMemoryEnabled:xe.memory,apiTier:lt,aiProvider:D,activeModel:Ge,isProcessing:bn,lastChunkTime:qs,theme:xe.theme,wps:qr.current.wps,showTPMEstimate:xe.showTPMEstimate})),mt==="exit"&&(()=>{let n=Date.now()-Ws,o=vt.toolSuccess+vt.toolFailure,d=o>0?(vt.toolSuccess/o*100).toFixed(1):"0.0",x=ir+lr,g=x>0?(ir/x*100).toFixed(1):"0.0",M=x>0?(lr/x*100).toFixed(1):"0.0";return e.createElement(c,{flexDirection:"column",borderStyle:"round",paddingX:3,paddingY:1,borderColor:i.borderMuted,width:Math.min(100,(s?.columns||100)-2),marginTop:0,marginBottom:0},e.createElement(c,{marginBottom:1},e.createElement(l,{bold:!0},Zd(i.logoGradient||["blue","purple"])("Agent powering down. Goodbye!"))),e.createElement(c,{flexDirection:"column"},e.createElement(l,{color:i.text,bold:!0,underline:!0},"Interaction Summary"),e.createElement(c,{marginTop:1},e.createElement(c,{width:20},e.createElement(l,{color:i.secondary},"Session ID:")),e.createElement(l,{color:i.text},dt)),e.createElement(c,null,e.createElement(c,{width:20},e.createElement(l,{color:i.secondary},"Tool Calls:")),e.createElement(l,{color:i.text},vt.toolSuccess+vt.toolFailure+vt.toolDenied," ( ",e.createElement(l,{color:"green"},"\u2714 ",vt.toolSuccess)," ",e.createElement(l,{color:"yellow"},"\u{1F6C7} ",vt.toolDenied)," ",e.createElement(l,{color:"red"},"\u2718 ",vt.toolFailure)," )")),e.createElement(c,null,e.createElement(c,{width:20},e.createElement(l,{color:i.secondary},"Success Rate:")),e.createElement(l,{color:i.text},d,"%")),e.createElement(c,null,e.createElement(c,{width:20},e.createElement(l,{color:i.secondary},"Code Changes:")),e.createElement(l,{color:i.text},e.createElement(l,{color:"green"},"+",vt.linesAdded)," ",e.createElement(l,{color:"red"},"-",vt.linesRemoved))),Yt>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:20},e.createElement(l,{color:i.secondary},"Tokens Consumed:")),e.createElement(l,{color:i.text},ht(Yt))),e.createElement(c,{marginLeft:2},e.createElement(c,{width:18},e.createElement(l,{color:i.textMuted},"\xBB Input Tokens:")),e.createElement(l,{color:i.text},ht(Yt-mn))),eo>0&&e.createElement(c,{marginLeft:4},e.createElement(c,{width:16},e.createElement(l,{color:i.textMuted},"\xBB Cached:")),e.createElement(l,{color:i.text},ht(eo))),mn>0&&e.createElement(c,{marginLeft:2},e.createElement(c,{width:18},e.createElement(l,{color:i.textMuted},"\xBB Output Tokens:")),e.createElement(l,{color:i.text},ht(mn)))),ar>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:20},e.createElement(l,{color:i.secondary},"Images Made:")),e.createElement(l,{color:i.text},ar)),e.createElement(c,null,e.createElement(c,{width:20},e.createElement(l,{color:i.secondary},"Image Credits:")),e.createElement(l,{color:i.text},Number(((ni||0)*1e3).toFixed(0))," credits")))),e.createElement(c,{flexDirection:"column",marginTop:1},e.createElement(l,{color:i.text,bold:!0,underline:!0},"Performance"),e.createElement(c,{marginTop:1},e.createElement(c,{width:20},e.createElement(l,{color:i.secondary},"Wall Time:")),e.createElement(l,{color:i.text},jo(n))),e.createElement(c,null,e.createElement(c,{width:20},e.createElement(l,{color:i.secondary},"Agent Active:")),e.createElement(l,{color:i.text},jo(x))),e.createElement(c,{marginLeft:2},e.createElement(c,{width:18},e.createElement(l,{color:i.textMuted},"\xBB API Time:")),e.createElement(l,{color:i.text},jo(ir)," (",g,"%)")),e.createElement(c,{marginLeft:2},e.createElement(c,{width:18},e.createElement(l,{color:i.textMuted},"\xBB Tool Time:")),e.createElement(l,{color:i.text},jo(lr)," (",M,"%)"))))})())))}export{Hs as check9RouterReachable,ac as default};