fluxflow-cli 4.45.0 → 4.46.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.
- package/dist/chunks/{ai-5NWQNNMC.js → ai-ES7GEGZ2.js} +1 -1
- package/dist/chunks/{app-KYCCN4ZF.js → app-FR7775JT.js} +62 -62
- package/dist/chunks/{auto_completion-MS7UGN4H.js → auto_completion-ZGT6WREW.js} +1 -1
- package/dist/chunks/{chunk-TPUNXYGC.js → chunk-2ZGSUC4G.js} +1 -1
- package/dist/chunks/{chunk-UXLD7KTZ.js → chunk-7D7IG3AG.js} +1 -1
- package/dist/chunks/{chunk-OECY2H5A.js → chunk-BKGKMEQ4.js} +10 -10
- package/dist/chunks/{chunk-EIJ6AAGK.js → chunk-FXGGSOXY.js} +1 -1
- package/dist/chunks/{chunk-5UIG3YUH.js → chunk-JPJB2SJL.js} +1 -1
- package/dist/chunks/{chunk-YSMPGXV3.js → chunk-MAXLHC7A.js} +1 -1
- package/dist/chunks/chunk-MXADZLMH.js +1 -0
- package/dist/chunks/{click-TFBIMVSS.js → click-ZZBBIP7F.js} +2 -2
- package/dist/chunks/{computer_action-DM2RWE3G.js → computer_action-5SW7LW5R.js} +1 -1
- package/dist/chunks/{drag-VXALN3P3.js → drag-OBMCSGER.js} +1 -1
- package/dist/chunks/{generate_image-ABIDYET4.js → generate_image-ALAAHL2E.js} +1 -1
- package/dist/chunks/{invoke-7HHBCMTV.js → invoke-DCX72AHI.js} +2 -2
- package/dist/chunks/{invokeSync-AULNCDC5.js → invokeSync-GQPUH52H.js} +2 -2
- package/dist/chunks/{key_press-YIUO27XG.js → key_press-65GEUW4K.js} +1 -1
- package/dist/chunks/{keyboard_typing-Q5CUT6YK.js → keyboard_typing-GCMJCV7O.js} +1 -1
- package/dist/chunks/{recapture_screen-ILVFVUJF.js → recapture_screen-QB65V5CM.js} +1 -1
- package/dist/chunks/{screen_grid-MSVBHIGV.js → screen_grid-M5K7ZHKD.js} +1 -1
- package/dist/chunks/{scroll-5XSQ6ZBZ.js → scroll-LTWDNSC6.js} +1 -1
- package/dist/chunks/{search_keyword-VY5KXDOB.js → search_keyword-GT5GEEJW.js} +1 -1
- package/dist/chunks/{secrets-HXB3H4UI.js → secrets-HSGGFVG5.js} +1 -1
- package/dist/chunks/secrets_v2-YV7YCUN7.js +1 -0
- package/dist/chunks/{settings-XLD5ZEHD.js → settings-4RNTQJ75.js} +1 -1
- package/dist/chunks/{update_file-VOCN7OPY.js → update_file-ALQM76Y4.js} +1 -1
- package/dist/chunks/{usage-TNW22X3Y.js → usage-67IZJXM2.js} +1 -1
- package/dist/chunks/{usageServer-TAVWXYT6.js → usageServer-HBVYDUQK.js} +1 -1
- package/dist/chunks/{write_file-R6BAMSDH.js → write_file-XHSRFBMF.js} +5 -5
- package/dist/cli.js +3 -3
- package/dist/package.json +2 -2
- package/package.json +2 -2
- package/dist/chunks/chunk-YEVCTH3B.js +0 -1
- package/dist/chunks/secrets_v2-AEJNZCOS.js +0 -1
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import{a as ca}from"./chunk-UEV335RW.js";import{b as Jl,c as Zl,d as Rl}from"./chunk-IHDJDAG3.js";import{c as Wl,e as jn,f as co,g as Gl}from"./chunk-TQOQHYJ6.js";import{A as xo,C as ia,D as la,E as aa,a as Xl,b as xt,c as yt,d as br,e as
|
|
1
|
+
import{a as ca}from"./chunk-UEV335RW.js";import{b as Jl,c as Zl,d as Rl}from"./chunk-IHDJDAG3.js";import{c as Wl,e as jn,f as co,g as Gl}from"./chunk-TQOQHYJ6.js";import{A as xo,C as ia,D as la,E as aa,a as Xl,b as xt,c as yt,d as br,e as si,f as Yl,g as Bn,h as es,i as ts,j as jl,t as ta,w as oa,x as na,y as ra,z as sa}from"./chunk-BKGKMEQ4.js";import{a as to,b as Kl,c as Vl}from"./chunk-HFTI3R3Q.js";import"./chunk-52STSLCN.js";import{a as ea}from"./chunk-56EJGQU3.js";import"./chunk-4BLSASW6.js";import{a as Xt,b as kt,d as Ul,e as At,f as _l,j as ni,k as ri,l as pr,m as Hl,n as Wo}from"./chunk-MKC4AVAL.js";import"./chunk-KYQFLMZE.js";import{a as Ql}from"./chunk-YX4X2ZTX.js";import{a as Tr,b as Go,c as En,e as os,f as ii,g as ql,i as zl,j as yr}from"./chunk-Z5D4VQSG.js";import{a as wr}from"./chunk-6EYQQ7GQ.js";import{a as vn}from"./chunk-Y5JU726N.js";import{b as on,c as ei}from"./chunk-7D7IG3AG.js";import{C as Ll,c as yl,e as Js,g as Cl,k as Ml,l as Sl,m as vl,n as Bl,q as Zs,r as El,s as Rs,w as Dl,x as Il,y as kl,z as Al}from"./chunk-MXADZLMH.js";import{a as Ol,b as Nl,i as Fl,j as Zr,k as Rr,m as Dt,n as Sn,o as oi,u as $l}from"./chunk-FXGGSOXY.js";import{a as Pl,b as ti,c as Kt}from"./chunk-MAXLHC7A.js";import{d as fl,e as Qs,f as gl,g as hl,h as pl,i as bl,j as wl,l as Jr,n as tn,o as ao,p as hr,q as Tl}from"./chunk-HTOLY3HR.js";import{c as zr,d as xl,e as Qr}from"./chunk-P5HBJA23.js";import{a as So,b as Mn,c as ko,d as qs,e as zs,k as gr,y as ml}from"./chunk-26BQ45XP.js";import vi from"os";import e,{useState as Q,useEffect as gt,useRef as Re,useMemo as Jn}from"react";import{Box as m,Text as i,useInput as tu,useStdout as ou,Static as nu}from"ink";import ru from"ink-spinner";import pt from"fs-extra";import Ct from"path";import{exec as $o}from"child_process";import{fileURLToPath as su}from"url";import Qt,{useState as ns,useEffect as li,useMemo as Cr,useCallback as vc,useRef as Ko}from"react";import{Box as Bc,Text as vo,useInput as Ec}from"ink";function Dc(t,g){return t.replace(/\t/g," ".repeat(g))}function rs(t){return t==null?"":t.replace(/\r\n/g,`
|
|
2
2
|
`).replace(/\r/g,`
|
|
3
3
|
`)}function Dn(t,g,d){let S=t,w=[...g].sort((r,y)=>r.start-y.start),p=0;for(let r of w){let y=r.start-p,b=rs(r.text).split(`
|
|
4
|
-
`).length,C=r.text.length,A=(b>3?`[Pasted ${b} lines]`:`[Pasted ${C} chars]`).length,P=y+A;if(t<=y)break;if(t<P){S=r.end;break}else{let B=r.text.length-A;S+=B,p+=B}}return Math.min(S,d.length)}function
|
|
4
|
+
`).length,C=r.text.length,A=(b>3?`[Pasted ${b} lines]`:`[Pasted ${C} chars]`).length,P=y+A;if(t<=y)break;if(t<P){S=r.end;break}else{let B=r.text.length-A;S+=B,p+=B}}return Math.min(S,d.length)}function ai(t,g,d,S,w=[]){let p=(t||"").slice(0,g),r=S(p).length,y=S(t||""),b=[...w].sort((G,$)=>$.start-G.start);for(let G of b){let $=S(t.slice(0,G.start)).length,z=S(G.text),Y=$+z.length,le=rs(G.text).split(`
|
|
5
5
|
`).length,xe=G.text.length,oe=le>3?`[Pasted ${le} lines]`:`[Pasted ${xe} chars]`;y=y.slice(0,$)+oe+y.slice(Y),r>$&&r<Y?r=$+oe.length:r>=Y&&(r=r-(Y-$)+oe.length)}let C=y.split(`
|
|
6
6
|
`),A=[],P=0,B=0,L=0,_=!1;for(let G=0;G<C.length;G++){let $=C[G];if($.length===0){!_&&r===P&&(B=A.length,L=0,_=!0),A.push({text:"",globalStart:Dn(P,w,t),formattedStart:P}),P+=1;continue}let Y=kt($,d).split(`
|
|
7
7
|
`),le=0,xe=[];for(let oe=0;oe<Y.length;oe++){let X=Y[oe],be=X.trim();if(be.length===0){let De=X.length||1;xe.push({text:X,start:le,length:De}),le+=De}else{let De=$.indexOf(be,le);if(De!==-1){let Oe=le,Xe=oe<Y.length-1?Y[oe+1].trim():"",Be=$.length;if(Xe.length>0){let fe=$.indexOf(Xe,De+be.length);fe!==-1&&(Be=fe)}xe.push({text:$.slice(Oe,Be),start:Oe,length:Be-Oe}),le=Be}else xe.push({text:X,start:le,length:X.length}),le+=X.length}}for(let oe=0;oe<xe.length;oe++){let X=xe[oe],be=X.text,De=P+X.start,Oe=De+X.length;!_&&r>=De&&(r<Oe||r===Oe&&oe===xe.length-1)&&(B=A.length,L=r-De,_=!0),A.push({text:be,globalStart:Dn(De,w,t),formattedStart:De})}P+=$.length+1}return _||(A.length===0?A.push({text:"",globalStart:0,formattedStart:0}):y.endsWith(`
|
|
8
|
-
`)?(A.push({text:"",globalStart:Dn(P,w,t),formattedStart:P}),B=A.length-1,L=0):(B=A.length-1,L=A[B].text.length)),{visualLines:A,cursorLine:B,cursorCol:L}}var Ic=({value:t,rows:g,maxRows:d,highlightStyle:S,textStyle:w,placeholder:p="",mask:r,showCursor:y=!0,focus:b=!0,tabSize:C=4,cursorIndex:A=0,highlight:P,columns:B=80,pasteBlocks:L=[],cursorColor:_})=>{let G=Ko(0),$=Cr(()=>Math.max(20,B-10),[B]),z=vc((Fe,Le=!1)=>{let R=rs(Fe);if(!Le&&r)return R.replace(/[^\n]/g,r);let re=Dc(R,C);return Le?re:re.replace(/@\[(.*?)\]/g,(ge,we)=>{let ie=we.indexOf("#"),me=we.indexOf(":L"),j=we,Ye="";ie!==-1?(j=we.slice(0,ie),Ye=we.slice(ie)):me!==-1&&(j=we.slice(0,me),Ye=we.slice(me));let ot=j.replace(/\\/g,"/"),Tt=(process.cwd()||"").replace(/\\/g,"/");Tt&&ot.toLowerCase().startsWith(Tt.toLowerCase()+"/")?ot=ot.slice(Tt.length+1):ot.startsWith("./")&&(ot=ot.slice(2));let ct=ot.split("/");return`[${ct[ct.length-1]}${Ye}]`})},[C,r]),{visualLines:Y,cursorLine:le,cursorCol:xe}=Cr(()=>
|
|
8
|
+
`)?(A.push({text:"",globalStart:Dn(P,w,t),formattedStart:P}),B=A.length-1,L=0):(B=A.length-1,L=A[B].text.length)),{visualLines:A,cursorLine:B,cursorCol:L}}var Ic=({value:t,rows:g,maxRows:d,highlightStyle:S,textStyle:w,placeholder:p="",mask:r,showCursor:y=!0,focus:b=!0,tabSize:C=4,cursorIndex:A=0,highlight:P,columns:B=80,pasteBlocks:L=[],cursorColor:_})=>{let G=Ko(0),$=Cr(()=>Math.max(20,B-10),[B]),z=vc((Fe,Le=!1)=>{let R=rs(Fe);if(!Le&&r)return R.replace(/[^\n]/g,r);let re=Dc(R,C);return Le?re:re.replace(/@\[(.*?)\]/g,(ge,we)=>{let ie=we.indexOf("#"),me=we.indexOf(":L"),j=we,Ye="";ie!==-1?(j=we.slice(0,ie),Ye=we.slice(ie)):me!==-1&&(j=we.slice(0,me),Ye=we.slice(me));let ot=j.replace(/\\/g,"/"),Tt=(process.cwd()||"").replace(/\\/g,"/");Tt&&ot.toLowerCase().startsWith(Tt.toLowerCase()+"/")?ot=ot.slice(Tt.length+1):ot.startsWith("./")&&(ot=ot.slice(2));let ct=ot.split("/");return`[${ct[ct.length-1]}${Ye}]`})},[C,r]),{visualLines:Y,cursorLine:le,cursorCol:xe}=Cr(()=>ai(t,A,$,z,L),[t,A,$,z,L]),oe=Y.length,X=Cr(()=>Math.max(g??d??1,Math.min(d??g??1,oe)),[g,d,oe]),be=le+1,De=G.current+X,Oe=G.current;be<=G.current?Oe=Math.max(0,be-1):be>De?Oe=be-X:oe&&(oe<X?Oe=0:oe<De&&(Oe=oe-X)),G.current=Oe;let Xe=Cr(()=>Y.slice(Oe,Oe+X),[Y,Oe,X]),[Be,fe]=ns(!0);li(()=>{if(fe(!0),!b||!y)return;let Fe=setInterval(()=>{fe(Le=>!Le)},530);return()=>clearInterval(Fe)},[b,y,t,A]);let Ne=Cr(()=>({...w,color:y&&b&&Be?_||"white":void 0,bold:y&&b&&Be,inverse:y&&b&&Be}),[w,y,b,Be,_]),Mt=(Fe,Le,R,re)=>{if(!Fe){let j=p&&t.length===0?z(p,!0):"";if(Le){let Ye=j[0]||" ",ot=j.slice(1);return Qt.createElement(vo,null,Qt.createElement(vo,{...re},Ye),Qt.createElement(vo,{color:"gray",dimColor:!0},ot))}return Qt.createElement(vo,{color:"gray",dimColor:!0},j||" ")}let ge=/(\[Pasted \d+ (?:lines|chars)\])/g,we=Fe.split(ge),ie=0,me=[];for(let j=0;j<we.length;j++){let Ye=we[j];if(Ye==="")continue;let ot=Ye.match(/^\[Pasted \d+ (?:lines|chars)\]$/),Tt=Ye.length,ct=ie+Tt;if(Le&&R>=ie&&R<ct){let wt=R-ie,st=Ye.slice(0,wt),qe=Ye[wt]||" ",se=Ye.slice(wt+1);me.push(Qt.createElement(vo,{key:j},Qt.createElement(vo,{color:ot?"magenta":void 0},st),Qt.createElement(vo,{...re},qe),Qt.createElement(vo,{color:ot?"magenta":void 0},se)))}else me.push(Qt.createElement(vo,{key:j,color:ot?"magenta":void 0},Ye));ie=ct}return Le&&R>=Fe.length&&me.push(Qt.createElement(vo,{key:"cursor-end",...re}," ")),Qt.createElement(Qt.Fragment,null,me)};return Qt.createElement(Bc,{height:X,width:$+1,overflow:"hidden",flexDirection:"column",flexGrow:0,flexShrink:0},Xe.map((Fe,Le)=>{let R=Oe+Le,re=R===le&&b&&y;return Qt.createElement(vo,{key:R,...w,wrap:"truncate"},Mt(Fe.text,re,xe,Ne))}))},da=({value:t,onChange:g,onSubmit:d,keyBindings:S,showCursor:w=!0,highlightPastedText:p=!1,focus:r=!0,columns:y=80,useCustomInput:b=($,z)=>Ec($,{isActive:z}),onPasteStateChange:C,cursorColor:A,historyEnabled:P=!1,isBrowsingHistory:B=!1,onHistoryPrev:L,onHistoryNext:_,...G})=>{let[$,z]=ns(t.length),[Y,le]=ns(0),[xe,oe]=ns([]),X=Ko(t.length),be=Ko(t),De=Ko(0),Oe=Ko([]),Xe=Ko(""),Be=Ko(-1),fe=Ko(null),Ne=Ko(0);X.current=$,be.current=t,De.current=Y,Oe.current=xe,li(()=>{X.current>t.length&&(X.current=t.length,z(t.length)),t?oe(Le=>Le.filter(R=>R.end<=t.length&&R.start<=t.length)):(oe([]),le(0))},[t]),li(()=>{C?.(xe.length>0)},[xe,C]);let Mt=()=>{let Le=Xe.current,R=Be.current,re=R+Le.length,ge=be.current,we=ge.slice(0,R)+Le+ge.slice(R);g(we),X.current=re,z(re),le(Le.length>1?Le.length:0);let ie=rs(Le).split(`
|
|
9
9
|
`).length,me=Le.length;if(me>50&&(ie>3||ie<=3&&me>200)){let j={start:R,end:re,text:Le};oe(Ye=>{let ot=Le.length;return[...Ye.map(ct=>R<=ct.start?{...ct,start:ct.start+ot,end:ct.end+ot}:ct),j]})}Xe.current="",Be.current=-1,fe.current=null},Fe=()=>{fe.current&&(clearTimeout(fe.current),Mt())};return b((Le,R)=>{if(Le==="\x1B[I"||Le==="\x1B[O"||Le==="[I"||Le==="[O")return;let re=Le,ge=!1,we=!1;re&&typeof re=="string"&&(re.includes("\x1B[200~")&&(ge=!0,re=re.replace(/\x1b\[200~/g,"")),re.includes("\x1B[201~")&&(we=!0,re=re.replace(/\x1b\[201~/g,"")));let ie=X.current,me=be.current,j=Oe.current,Ye=Math.max(20,y-10),ot=(se,Se)=>{if(j.length===0)return;let ut=j.map(mt=>se<=mt.start?{...mt,start:mt.start+Se,end:mt.end+Se}:se>mt.start&&se<mt.end?null:mt).filter(Boolean);oe(ut)},Tt=se=>{for(let Se of j)if(se>Se.start&&se<Se.end)return Se.start;return se};if(R.ctrl&&(re==="o"||re==="")){oe([]);return}if(R.ctrl&&(re.toLowerCase()==="r"||re===""||re===""))return;if(R.upArrow||R.downArrow||R.leftArrow||R.rightArrow){Fe();let se=Date.now();if(se-Ne.current<33)return;Ne.current=se}let wt=S?.submit??(se=>se.return&&se.ctrl),st=S?.newline??(se=>se.return);if(wt(R)){Fe(),d?.(me);return}else if(st(R)){Fe(),ot(ie,1);let se=me.slice(0,ie)+`
|
|
10
|
-
`+me.slice(ie);g(se),X.current=ie+1,z(ie+1),le(0);return}if(R.tab||R.shift&&R.tab||R.ctrl&&re==="c")return;let qe=se=>se;if(R.upArrow||R.downArrow){if(Fe(),P){if(R.upArrow&&(me===""||B)){L?.();return}if(R.downArrow&&B){_?.();return}}if(w){let{visualLines:se,cursorLine:Se,cursorCol:ut}=
|
|
10
|
+
`+me.slice(ie);g(se),X.current=ie+1,z(ie+1),le(0);return}if(R.tab||R.shift&&R.tab||R.ctrl&&re==="c")return;let qe=se=>se;if(R.upArrow||R.downArrow){if(Fe(),P){if(R.upArrow&&(me===""||B)){L?.();return}if(R.downArrow&&B){_?.();return}}if(w){let{visualLines:se,cursorLine:Se,cursorCol:ut}=ai(me,ie,Ye,qe,j),mt=R.upArrow?Se-1:Se+1;if(mt>=0&&mt<se.length){let _e=se[mt],Bt=Math.min(ut,_e.text.length),We=_e.formattedStart+Bt,no=Dn(We,j,me);no=Tt(no),X.current=no,z(no),le(0)}else if(R.upArrow&&Se===0)X.current=0,z(0),le(0);else if(R.downArrow&&Se===se.length-1){let _e=se[se.length-1],Bt=_e.formattedStart+_e.text.length,We=Dn(Bt,j,me);We=Tt(We),X.current=We,z(We),le(0)}}}else if(R.leftArrow){if(Fe(),w){let se=Math.max(0,ie-1),Se=j.find(ut=>ie===ut.end);Se&&(se=Se.start),X.current=se,z(se),le(0)}}else if(R.rightArrow){if(Fe(),w){let se=Math.min(me.length,ie+1),Se=j.find(ut=>ie===ut.start);Se&&(se=Se.end),X.current=se,z(se),le(0)}}else if(R.backspace){Fe();let se=j.findIndex(Se=>ie===Se.end);if(se!==-1){let Se=j[se],ut=-(Se.end-Se.start),mt=me.slice(0,Se.start)+me.slice(Se.end);g(mt),X.current=Se.start,z(Se.start),le(0);let _e=j.filter((Bt,We)=>We!==se).map(Bt=>Bt.start>=Se.end?{...Bt,start:Bt.start+ut,end:Bt.end+ut}:Bt);oe(_e)}else if(ie>0){ot(ie-1,-1);let Se=me.slice(0,ie-1)+me.slice(ie);g(Se),X.current=ie-1,z(ie-1),le(0)}}else if(R.delete){Fe();let se=j.findIndex(Se=>ie===Se.start);if(se!==-1){let Se=j[se],ut=-(Se.end-Se.start),mt=me.slice(0,Se.start)+me.slice(Se.end);g(mt),le(0);let _e=j.filter((Bt,We)=>We!==se).map(Bt=>Bt.start>=Se.end?{...Bt,start:Bt.start+ut,end:Bt.end+ut}:Bt);oe(_e)}else if(ot(ie,-1),ie<me.length){let Se=me.slice(0,ie)+me.slice(ie+1);g(Se),le(0)}}else if(R.home||R.end){if(Fe(),w){let{visualLines:se,cursorLine:Se}=ai(me,ie,Ye,qe,j),ut=se[Se];if(ut){let mt;R.home?mt=Dn(ut.formattedStart,j,me):R.end&&(mt=Dn(ut.formattedStart+ut.text.length,j,me)),mt=Tt(mt),X.current=mt,z(mt),le(0)}}}else if(re!==""||ge||we)if(ge||we||re.length>1||fe.current!==null)fe.current?(clearTimeout(fe.current),Xe.current+=re):(Be.current=ie,Xe.current=re),we?(fe.current=null,Mt()):fe.current=setTimeout(()=>{Mt()},80);else{ot(ie,re.length);let Se=me.slice(0,ie)+re+me.slice(ie);g(Se);let ut=ie+re.length;X.current=ut,z(ut),le(0)}},r),Qt.createElement(Ic,{...G,value:t,cursorIndex:$,showCursor:w,focus:r,columns:y,pasteBlocks:xe,cursorColor:A})};import Zn from"ink-text-input";import"ink-select-input";import l from"react";import{Box as E,Text as ae}from"ink";import Ft,{useState as ua,useEffect as kc}from"react";import{Box as Vo,Text as Bo,useInput as Ac}from"ink";var ss=Ft.memo(({command:t,output:g,completed:d=!1,isFocused:S=!1,columns:w=80,isPty:p=!1,terminalHeight:r=24,theme:y="Dark"})=>{let b=xt(y),A=(re=>{if(!re)return"";let ge=[[]],we=0,ie=0,me="",j=/\x1b\[([0-9;]*?)([a-zA-Z])/g,Ye=0,ot,Tt=wt=>{for(let st=0;st<wt.length;st++){let qe=wt[st];if(qe===`
|
|
11
11
|
`)for(we++,ie=0;we>=ge.length;)ge.push([]);else if(qe==="\r")ie=0;else{for(;we>=ge.length;)ge.push([]);let se=ge[we];for(;ie>se.length;)se.push({char:" ",style:""});se[ie]={char:qe,style:me},ie++}}};for(;(ot=j.exec(re))!==null;){Tt(re.substring(Ye,ot.index));let wt=ot[1],st=ot[2],qe=wt?wt.split(";").map(Number):[];if(st==="A"){let se=qe[0]||1;we=Math.max(0,we-se)}else if(st==="B"){let se=qe[0]||1;for(we=we+se;we>=ge.length;)ge.push([])}else if(st==="C"){let se=qe[0]||1;ie=ie+se}else if(st==="D"){let se=qe[0]||1;ie=Math.max(0,ie-se)}else if(st==="G"){let se=(qe[0]||1)-1;ie=Math.max(0,se)}else if(st==="H"||st==="f"){let se=(qe[0]||1)-1,Se=(qe[1]||1)-1;for(we=Math.max(0,se),ie=Math.max(0,Se);we>=ge.length;)ge.push([])}else if(st==="K"){let se=qe[0]||0;if(we<ge.length){let Se=ge[we];if(se===0)Se.length=ie;else if(se===1)for(let ut=0;ut<ie&&ut<Se.length;ut++)Se[ut]={char:" ",style:""};else se===2&&(Se.length=0)}}else if(st==="J"){let se=qe[0]||0;(se===2||se===3)&&(ge.length=0,ge.push([]),we=0,ie=0)}else if(st==="m"){let se=ot[0];se==="\x1B[0m"?me="":me=se}Ye=j.lastIndex}Tt(re.substring(Ye));let ct=ge.map(wt=>{let st="",qe="";for(let se=0;se<wt.length;se++){let Se=wt[se]||{char:" ",style:""};Se.style!==qe&&(qe&&(st+="\x1B[0m"),st+=Se.style,qe=Se.style),st+=Se.char}return qe&&(st+="\x1B[0m"),st});for(;ct.length>0&&ct[ct.length-1]==="";)ct.pop();return ct.join(`
|
|
12
12
|
`)})(g).replace(/\n{3,}/g,`
|
|
13
13
|
|
|
@@ -17,13 +17,13 @@ import{a as ca}from"./chunk-UEV335RW.js";import{b as Jl,c as Zl,d as Rl}from"./c
|
|
|
17
17
|
`).trim(),Be=(Oe||[]).join(`
|
|
18
18
|
`),fe=be&&!L?Math.max(0,B.length-X-G):0,Ne=be&&!L?G:0,Mt=d?"\u{1F3C1} FINISHED: ":"\u26A1 EXECUTING: ",Fe=Math.max(10,(w||80)-(p?24:14)),Le=kt((t||"").replace(/\r?\n/g," ").trim(),Fe).split(`
|
|
19
19
|
`),R=(t||"").replace(/\r?\n/g," ").trim();return Le.length>1&&(R=Le[0].length>3?Le[0].slice(0,-3)+"...":Le[0]+"..."),Ft.createElement(Vo,{flexDirection:"column",borderStyle:S?"double":"single",borderLeft:!1,borderRight:!1,borderTop:!0,borderBottom:!0,borderColor:b.codeBorder,paddingLeft:2,paddingRight:0,paddingTop:Y?0:1,paddingBottom:1,marginY:Y?0:1,width:w-2},Ft.createElement(Vo,{marginBottom:Y?0:1,justifyContent:"space-between",width:"100%"},Ft.createElement(Vo,{flexShrink:1,paddingRight:2},Ft.createElement(Bo,null,Ft.createElement(Bo,{color:b.text,bold:!0},Mt),Ft.createElement(Bo,{color:b.text},R))),p&&Ft.createElement(Vo,{flexShrink:0,paddingX:1},Ft.createElement(Bo,{color:"green",bold:!0},"ADVANCE"))),Xe?Ft.createElement(Vo,{flexDirection:"column",marginTop:0,backgroundColor:p?void 0:b.codeBg,paddingX:1,width:"100%"},fe>0&&Ft.createElement(Vo,{marginBottom:0},Ft.createElement(Bo,{color:"magenta"},"\u25B2 ...",fe," lines above (Use PageUp to scroll)...")),Ft.createElement(Bo,{color:b.text},Be),Ne>0&&Ft.createElement(Vo,{marginTop:0},Ft.createElement(Bo,{color:"magenta"},"\u25BC ...",Ne," lines below (Use PageDown to scroll)..."))):!d&&Ft.createElement(Vo,{marginTop:Y?0:1,backgroundColor:p?void 0:b.codeBg,paddingX:1,width:"100%"},Ft.createElement(Bo,{color:b.textMuted,italic:!0},"Waiting for output...")),Ft.createElement(Vo,{justifyContent:"space-between",marginTop:Y?0:1},d?Ft.createElement(Bo,{color:b.textMuted,italic:!0},S?"Use PgUp/PgDn to scroll \u2022 Ctrl+O to expand/collapse \u2022 TAB to unfocus.":"Press TAB to focus & scroll."):Ft.createElement(Bo,{color:b.textMuted,italic:!0},S?"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."),Ft.createElement(Bo,{color:b.textMuted,bold:!0},d?S?"\u25CF ARCHIVED (FOCUSED) ":"\u25CF ARCHIVED ":S?"\u25B6 TERMINAL FOCUSED ":"\u25CF LIVE (Press TAB to focus) ")))});import{diffWordsWithSpace as Lc}from"diff";var Mr=null,fa=t=>{Mr=t!==!1},ga=()=>{if(Mr===null)try{Mr=Qr(Mn,{})?.systemSettings?.preserveThinking!==!1}catch{Mr=!0}return Mr},ma=(t,g,d)=>t,Pc=(t,g=80)=>{if(!t)return null;let d=t.replaceAll(" "," "),S=g-10,w=d.trim();if(!w.includes("```"))return l.createElement(E,{width:"100%",flexDirection:"column"},l.createElement(zn,{text:w,color:"#969696",columns:S,italic:!0}));let p=w.split(/(```\w*\n?[\s\S]*?(?:```|$))/g);return l.createElement(E,{width:"100%",flexDirection:"column"},p.map((r,y)=>{if(r.startsWith("```")){let C=r.match(/```(\w*)\n?([\s\S]*?)(?:```|$)/),A=C?C[2]:r.replace(/^```\w*\n?/,"").replace(/```$/,""),P=kt(A.trimEnd(),S);return l.createElement(E,{key:y,flexDirection:"column",width:"100%"},P.split(`
|
|
20
|
-
`).map((B,L)=>l.createElement(ae,{key:L,color:"cyan"},B)))}let b=r;return y>0&&(b=b.replace(/^[\r\n]+/,"")),y<p.length-1&&(b=b.replace(/[\r\n]+$/,"")),b?l.createElement(zn,{key:y,text:b,color:"gray",columns:S,italic:!0}):null}))},Oc=/(```[\s\S]*?```|`[^`\r\n]+`|@\[.*?\]|\*\*.*?\*\*|\*.*?\*|\\\(.*?\\\)|\\\[.*?\\\]|\$.*?\$|\[.*?\]\s*\(.*?\)|\[[^\x1b\[\]\r\n]+\]\s*\[(?:https?:\/\/[^\s\]]+|#[^\s\]]+)\]|https?:\/\/[^\s)]+)/g;var Nc=/\\frac\s*\{([^{}]*)\}\s*\{([^{}]*)\}/g,Fc=/(\\(?:mathbf|textbf|textit|underline|texttt)\{[^{}]*\})/g,$c=/^(#{1,6})\s+(.*)/,Uc=/\\multiply|\\mul|\\times/g,_c=/\\div/g,Hc=/\\cdot/g,Xc=/\\infty/g,Wc=/\\pm/g,Gc=/\\leq/g,Kc=/\\geq/g,Vc=/\\neq/g,Yc=/\\sqrt\s*\{([^}]+)\}/g,jc=/\\sqrt\s*(\w+|\d+)/g,qc=/\\alpha/g,zc=/\\beta/g,Qc=/\\theta/g,Jc=/\\pi/g,Zc=/\\approx/g,Rc=/\\Delta/g,ed=/\\sigma/g,td=/\\sum/g,od=/\\prod/g,nd=/\\rightarrow|\\to/g,rd=/\\left\b|\\right\b/g,sd=/\\left\(|\\right\)/g,id=/\\left\[|\\right\]/g,ld=/\\\{|\\\}/g,ad=/\\text\s*\{([^}]+)\}/g,cd=/\\text\s+(\w+)/g,dd=/\\%/g,ud=/\\\(|\\\)/g,md=/\\\[|\\\]/g,xd=/@\[(.*?)\]/g,xa=/:L/gi,fd=/\[(.*?)\]\s*\((.*?)\)/,gd=/\[([^\x1b\[\]\r\n]+)\]\s*\[(https?:\/\/[^\s\]]+|#[^\s\]]+)\]/,hd=/\\(\w+)\{([^{}]*)\}/,pd=t=>t.replace(ud,g=>g.includes("(")?"(":")").replace(md,g=>g.includes("[")?"[":"]").replace(Uc,"\xD7").replace(_c,"\xF7").replace(Hc,"\u22C5").replace(Xc,"\u221E").replace(Wc,"\xB1").replace(Gc,"\u2264").replace(Kc,"\u2265").replace(Vc,"\u2260").replace(Yc,"\u221A($1)").replace(jc,"\u221A($1)").replace(qc,"\u03B1").replace(zc,"\u03B2").replace(Qc,"\u03B8").replace(Jc,"\u03C0").replace(Zc,"\u2248").replace(Rc,"\u0394").replace(ed,"\u03C3").replace(td,"\u03A3").replace(od,"\u03A0").replace(nd,"\u2192").replace(rd,"").replace(sd,g=>g.includes("left")?"(":")").replace(id,g=>g.includes("left")?"[":"]").replace(ld,g=>g.includes("{")?"{":"}").replace(ad,"$1").replace(cd,"$1").replace(dd,"%"),bd=/\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/,wd=[/((?<=\binclude\s+)(?:<[^>]+>|"[^"]+"))/.source,/((?<=\b(?:from|import|require\s*\(\s*)\s*)(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"))/.source,/(\/\/.*|#.*)/.source,/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^\`\\])*`)/.source,bd.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],
|
|
20
|
+
`).map((B,L)=>l.createElement(ae,{key:L,color:"cyan"},B)))}let b=r;return y>0&&(b=b.replace(/^[\r\n]+/,"")),y<p.length-1&&(b=b.replace(/[\r\n]+$/,"")),b?l.createElement(zn,{key:y,text:b,color:"gray",columns:S,italic:!0}):null}))},Oc=/(```[\s\S]*?```|`[^`\r\n]+`|@\[.*?\]|\*\*.*?\*\*|\*.*?\*|\\\(.*?\\\)|\\\[.*?\\\]|\$.*?\$|\[.*?\]\s*\(.*?\)|\[[^\x1b\[\]\r\n]+\]\s*\[(?:https?:\/\/[^\s\]]+|#[^\s\]]+)\]|https?:\/\/[^\s)]+)/g;var Nc=/\\frac\s*\{([^{}]*)\}\s*\{([^{}]*)\}/g,Fc=/(\\(?:mathbf|textbf|textit|underline|texttt)\{[^{}]*\})/g,$c=/^(#{1,6})\s+(.*)/,Uc=/\\multiply|\\mul|\\times/g,_c=/\\div/g,Hc=/\\cdot/g,Xc=/\\infty/g,Wc=/\\pm/g,Gc=/\\leq/g,Kc=/\\geq/g,Vc=/\\neq/g,Yc=/\\sqrt\s*\{([^}]+)\}/g,jc=/\\sqrt\s*(\w+|\d+)/g,qc=/\\alpha/g,zc=/\\beta/g,Qc=/\\theta/g,Jc=/\\pi/g,Zc=/\\approx/g,Rc=/\\Delta/g,ed=/\\sigma/g,td=/\\sum/g,od=/\\prod/g,nd=/\\rightarrow|\\to/g,rd=/\\left\b|\\right\b/g,sd=/\\left\(|\\right\)/g,id=/\\left\[|\\right\]/g,ld=/\\\{|\\\}/g,ad=/\\text\s*\{([^}]+)\}/g,cd=/\\text\s+(\w+)/g,dd=/\\%/g,ud=/\\\(|\\\)/g,md=/\\\[|\\\]/g,xd=/@\[(.*?)\]/g,xa=/:L/gi,fd=/\[(.*?)\]\s*\((.*?)\)/,gd=/\[([^\x1b\[\]\r\n]+)\]\s*\[(https?:\/\/[^\s\]]+|#[^\s\]]+)\]/,hd=/\\(\w+)\{([^{}]*)\}/,pd=t=>t.replace(ud,g=>g.includes("(")?"(":")").replace(md,g=>g.includes("[")?"[":"]").replace(Uc,"\xD7").replace(_c,"\xF7").replace(Hc,"\u22C5").replace(Xc,"\u221E").replace(Wc,"\xB1").replace(Gc,"\u2264").replace(Kc,"\u2265").replace(Vc,"\u2260").replace(Yc,"\u221A($1)").replace(jc,"\u221A($1)").replace(qc,"\u03B1").replace(zc,"\u03B2").replace(Qc,"\u03B8").replace(Jc,"\u03C0").replace(Zc,"\u2248").replace(Rc,"\u0394").replace(ed,"\u03C3").replace(td,"\u03A3").replace(od,"\u03A0").replace(nd,"\u2192").replace(rd,"").replace(sd,g=>g.includes("left")?"(":")").replace(id,g=>g.includes("left")?"[":"]").replace(ld,g=>g.includes("{")?"{":"}").replace(ad,"$1").replace(cd,"$1").replace(dd,"%"),bd=/\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/,wd=[/((?<=\binclude\s+)(?:<[^>]+>|"[^"]+"))/.source,/((?<=\b(?:from|import|require\s*\(\s*)\s*)(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"))/.source,/(\/\/.*|#.*)/.source,/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^\`\\])*`)/.source,bd.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],ci=new RegExp(wd.join("|"),"g"),qn=new Map,Td=1e3,yd=(t,g)=>{if(!t)return[];let d=`${g}:${t}`;if(qn.has(d))return qn.get(d);let S=0,w=[],p;for(ci.lastIndex=0;(p=ci.exec(t))!==null;){let r=p[0],y=p.index;y>S&&w.push({text:Xt(t.substring(S,y))});let b,C=!1;p[1]||p[2]?b="#ce9178":p[3]?b="#9ece6a":p[4]?b="#fcfca4":p[5]?(b="#ff7b72",C=!0):p[6]?b="#b392f0":(p[7]||p[8])&&(b="#ff9e64"),w.push({text:Xt(r),color:b,bold:C}),S=ci.lastIndex}if(S<t.length&&w.push({text:Xt(t.substring(S))}),qn.size>=Td){let r=qn.keys().next().value;qn.delete(r)}return qn.set(d,w),w},vt=(t,g,d=void 0,S=void 0)=>{if(!t)return l.createElement(ae,{backgroundColor:S}," ");let w=yd(t,g);return l.createElement(ae,{color:d,backgroundColor:S},w.map((p,r)=>l.createElement(ae,{key:r,color:p.color||d,backgroundColor:S,bold:p.bold},p.text)))},di=(t,g)=>{if(!t)return null;let d=t.replace(Nc,"($1/$2)");d=pd(d);let S=d.split(Fc);return l.createElement(l.Fragment,{key:g},S.map((w,p)=>{if(w.startsWith("\\")){let r=w.match(hd);if(r){let y=r[1],b=r[2];return l.createElement(ae,{key:p,bold:y==="mathbf"||y==="textbf",italic:y==="textit",underline:y==="underline",color:y==="texttt"?"cyan":void 0},b)}}return w}))},Jt=l.memo(({text:t,color:g,italic:d,theme:S="Dark"})=>{if(!t)return null;let w=t.replaceAll(" "," "),p=xt(S),r=g||p.text,y=p.codeText||p.logoGradient&&p.logoGradient[0]||p.info||p.secondary||"cyan",b=w.split(Oc);return l.createElement(ae,{color:r,wrap:"anywhere",italic:d},b.map((C,A)=>{if(!C)return null;if(C.startsWith("```")&&C.endsWith("```")){let P=C.slice(3,-3);return l.createElement(ae,{key:A,color:y},P)}if(C.startsWith("**")&&C.endsWith("**"))return l.createElement(ae,{key:A,bold:!0,color:r},l.createElement(Jt,{text:C.slice(2,-2),color:r,theme:S}));if(C.startsWith("*")&&C.endsWith("*"))return l.createElement(ae,{key:A,italic:!0,color:r},l.createElement(Jt,{text:C.slice(1,-1),color:r,italic:d,theme:S}));if(C.startsWith("`"))if(C.endsWith("`")&&C.length>1){let P=C.slice(1,-1),B=P.replace(xd,(_,G)=>G.split("/").pop().split("\\").pop().replace(xa,"#L")),L=P.includes("@[");return l.createElement(ae,{key:A,color:y,bold:L},B)}else return l.createElement(ae,{key:A,color:y},C.slice(1));if(C.startsWith("@[")&&C.endsWith("]")){let B=C.slice(2,-1).split("/").pop().split("\\").pop().replace(xa,"#L");return l.createElement(ae,{key:A,color:y,bold:!0},B)}if(C.startsWith("\\(")&&C.endsWith("\\)")||C.startsWith("\\[")&&C.endsWith("\\]")){let P=C.slice(2,-2);return l.createElement(ae,{key:A,color:"yellow"},di(P,A))}if(C.startsWith("$")&&C.endsWith("$")){let P=C.slice(1,-1);return l.createElement(ae,{key:A,color:"yellow"},di(P,A))}if(C.startsWith("[")&&(C.includes("](")||C.includes("] ("))){let P=C.match(fd);if(P){let B=P[1]||P[2],_=`\x1B]8;;${P[2]||P[1]}\x07${B}\x1B]8;;\x07`;return l.createElement(ae,{key:A,color:y,underline:!0,italic:!0},_)}}if(C.startsWith("[")&&(C.includes("][")||C.includes("] ["))){let P=C.match(gd);if(P){let B=P[1]||P[2],_=`\x1B]8;;${P[2]||P[1]}\x07${B}\x1B]8;;\x07`;return l.createElement(ae,{key:A,color:y,underline:!0,italic:!0},_)}}return C.startsWith("http")?l.createElement(ae,{key:A,color:y,underline:!0,italic:!0},C):di(C,A)}))}),ha=l.memo(({buffer:t,terminalWidth:g=80,theme:d="Dark"})=>{if(t.length<2)return null;let S=xt(d),w=S.codeText||S.secondary||S.info||"cyan",p=t.map(P=>{let B=P.split("|");return B[0]!==void 0&&B[0].trim()===""&&B.shift(),B.length>0&&B[B.length-1].trim()===""&&B.pop(),B.map(L=>L.trim())}),r=p[0],y=p.slice(2),b=Math.floor(100/r.length),C=g-8,A=Math.floor(C/r.length)-2;return l.createElement(E,{flexDirection:"column",borderStyle:"round",borderColor:S.borderMuted,paddingX:1,marginY:0,width:g-2},l.createElement(E,{flexDirection:"row",borderStyle:"single",borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,borderColor:S.borderMuted,marginBottom:1,paddingBottom:0,width:"100%"},r.map((P,B)=>l.createElement(E,{key:B,flexBasis:`${b}%`,flexGrow:1,flexShrink:0,paddingRight:2},l.createElement(Jt,{text:kt(P,A),color:w,theme:d})))),y.map((P,B)=>l.createElement(E,{key:B,flexDirection:"row",marginBottom:B===y.length-1?0:1,width:"100%"},P.map((L,_)=>l.createElement(E,{key:_,flexBasis:`${b}%`,flexGrow:1,flexShrink:0,paddingRight:2,flexDirection:"column"},l.createElement(Jt,{text:kt(L,A),color:S.text,theme:d}))))))}),zn=l.memo(({text:t,color:g,columns:d=80,italic:S=!1,theme:w="Dark"})=>{if(!t)return null;let p=t.replaceAll(" "," "),r=xt(w),y=g||r.text,b=p.split(`
|
|
21
21
|
`),C=[],A=[],P=[],B=L=>{if(A.length>0&&(C.push(l.createElement(ha,{key:`table-${L}`,buffer:[...A],terminalWidth:d,theme:w})),A=[]),P.length>0){let _=d-6,G=P.flatMap($=>kt($,_).split(`
|
|
22
22
|
`));C.push(l.createElement(E,{key:`quote-${L}`,borderStyle:"bold",borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:r.borderMuted,paddingLeft:1,marginY:1,flexDirection:"column"},G.map(($,z)=>l.createElement(Jt,{key:z,text:$,color:r.textMuted,italic:S,theme:w})))),P=[]}};return b.forEach((L,_)=>{let G=L.trim(),$=G.startsWith("|"),z=G.startsWith(">");if($)P.length>0&&B(_),A.push(L);else if(z)A.length>0&&B(_),P.push(G.replace(/^>\s*/,""));else{if(B(_),G===""){C.push(l.createElement(E,{key:_,height:1}));return}if(G==="---"||G==="***"||G==="___"){C.push(l.createElement(E,{key:_,marginY:0,borderStyle:"single",borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,width:"100%",borderColor:r.borderMuted}));return}let Y=G.match(/^(#{1,6})\s+(.*)/);if(Y){let be=Y[1].length,De=Y[2];C.push(l.createElement(E,{key:_,marginTop:1,marginBottom:0,width:"100%"},l.createElement(ae,{bold:!0,color:be===1?"yellow":be===2?"magenta":be===3?r.info||"cyan":be===4?"green":be===5?"blue":r.text,underline:!0},De)));return}let le=/^[\*\-\+]\s/.test(G),xe=/^\d+\.\s/.test(G),oe=L.includes("\u2588")||L.includes("\u2554")||L.includes("\u255A")||L.includes("\u2550"),X="";if(oe)X=L;else if(le||xe){let be=le?" \u2022 ":G.match(/^\d+\.\s/)[0],De=" ".repeat(be.length),Oe=kt(G.replace(/^[\*\-\d+\.]+\s/,""),d-(be.length+6));X=be+Oe.split(`
|
|
23
23
|
`).join(`
|
|
24
|
-
`+De)}else X=kt(G,d-4);C.push(l.createElement(E,{key:_,flexDirection:"column",width:"100%"},l.createElement(Jt,{text:X,color:y,italic:S,theme:w})))}}),B("final"),l.createElement(E,{flexDirection:"column",width:d-2},C)}),pa=l.memo(({line:t,pairContent:g,parentText:d,columns:S=80,extension:w,theme:p="Dark"})=>{let r=xt(p),y=(t||"").replaceAll(" "," "),b=y.includes("[UI_CONTEXT]"),C=y.replace("[UI_CONTEXT]","");if(b&&C.includes("\u2550"))return l.createElement(E,{backgroundColor:r.codeBg,paddingX:1,width:S},l.createElement(ae,{color:"gray"},"\u2550".repeat(Math.max(10,S-4))));let A=
|
|
24
|
+
`+De)}else X=kt(G,d-4);C.push(l.createElement(E,{key:_,flexDirection:"column",width:"100%"},l.createElement(Jt,{text:X,color:y,italic:S,theme:w})))}}),B("final"),l.createElement(E,{flexDirection:"column",width:d-2},C)}),pa=l.memo(({line:t,pairContent:g,parentText:d,columns:S=80,extension:w,theme:p="Dark"})=>{let r=xt(p),y=(t||"").replaceAll(" "," "),b=y.includes("[UI_CONTEXT]"),C=y.replace("[UI_CONTEXT]","");if(b&&C.includes("\u2550"))return l.createElement(E,{backgroundColor:r.codeBg,paddingX:1,width:S},l.createElement(ae,{color:"gray"},"\u2550".repeat(Math.max(10,S-4))));let A=ni(y);if(!A)return l.createElement(E,{backgroundColor:r.codeBg,paddingX:1,width:S},l.createElement(E,{width:3,flexShrink:0}),l.createElement(E,{width:1,flexShrink:0,marginLeft:1}),l.createElement(E,{flexGrow:1,marginLeft:1},l.createElement(ae,{color:"gray"},kt(C,S-14))));let{isR:P,isA:B,num:L,content:_}=A,G=g&&g.replaceAll(" "," "),$=[];if(G!=null){let De=P?_:G,Oe=P?G:_;try{$=Lc(De,Oe)}catch{$=[]}}let z=$.some(De=>P&&De.removed||B&&De.added),Y=!G&&(P||B),le=P?r.diffRemovalBg:B?r.diffAdditionBg:void 0,xe=P||B?P?r.diffRemovalNum:r.diffAdditionNum:r.textMuted,oe=P?r.diffRemovalPrefix:r.diffAdditionPrefix,X=P?"-":B?"+":" ",be=()=>{if(Y){let R=P?r.diffRemovalHighlightBg:r.diffAdditionHighlightBg;return l.createElement(E,{flexDirection:"column"},vt(kt(_,S-15),w,void 0,R))}if(!(P||B)||$.length===0||!z)return l.createElement(E,{flexDirection:"column"},vt(kt(_,S-15),w,void 0,void 0));let De=Math.max(10,S-15),Oe=kt(_,De).split(`
|
|
25
25
|
`),Xe=[];if($.forEach((R,re)=>{let ge=/^\s+$/.test(R.value);if(P){let we=$[re-1]?.removed||$[re+1]?.removed;R.removed||ge&&we?Xe.push({text:R.value,isHighlight:!0}):R.added||Xe.push({text:R.value,isHighlight:!1})}else if(B){let we=$[re-1]?.added||$[re+1]?.added;R.added||ge&&we?Xe.push({text:R.value,isHighlight:!0}):R.removed||Xe.push({text:R.value,isHighlight:!1})}}),Oe.length<=1)return l.createElement(ae,{wrap:"wrap"},Xe.map((R,re)=>P?R.isHighlight?l.createElement(l.Fragment,{key:re},vt(R.text,w,void 0,r.diffRemovalHighlightBg)):l.createElement(l.Fragment,{key:re},vt(R.text,w,void 0)):B?R.isHighlight?l.createElement(l.Fragment,{key:re},vt(R.text,w,void 0,r.diffAdditionHighlightBg)):l.createElement(l.Fragment,{key:re},vt(R.text,w,void 0)):l.createElement(l.Fragment,{key:re},vt(R.text,w,void 0))));let Be=0,fe=0,Ne=_.match(/^(\s*)/),Mt=Ne?Ne[1]:"",Fe=Mt.substring(0,Math.min(Mt.length,8)),Le=Oe.map((R,re)=>{let ge=[],we=R;re>0&&Fe&&R.startsWith(Fe)&&((Xe[Be]?Xe[Be].text.substring(fe):"").startsWith(Fe)||(ge.push({text:Fe,isHighlight:!1}),we=R.substring(Fe.length)));let ie=we.length;for(;ie>0&&Be<Xe.length;){let me=Xe[Be],j=me.text.length-fe;if(j<=0){Be++,fe=0;continue}let Ye=Math.min(ie,j);ge.push({text:me.text.substring(fe,fe+Ye),isHighlight:me.isHighlight}),fe+=Ye,ie-=Ye,fe>=me.text.length&&(Be++,fe=0)}for(;Be<Xe.length;){let me=Xe[Be],j=me.text.substring(fe);if(/^\s+$/.test(j))Be++,fe=0;else if(j.startsWith(" ")||j.startsWith(" ")){let Ye=0;for(;Ye<j.length&&(j[Ye]===" "||j[Ye]===" ");)Ye++;fe+=Ye,fe>=me.text.length&&(Be++,fe=0);break}else break}return ge});if(Be<Xe.length){let R=Le[Le.length-1];for(;Be<Xe.length;){let re=Xe[Be];R.push({text:re.text.substring(fe),isHighlight:re.isHighlight}),Be++,fe=0}}return l.createElement(E,{flexDirection:"column"},Le.map((R,re)=>l.createElement(E,{key:re},l.createElement(ae,{wrap:"wrap"},R.map((ge,we)=>P?ge.isHighlight?l.createElement(l.Fragment,{key:we},vt(ge.text,w,void 0,r.diffRemovalHighlightBg)):l.createElement(l.Fragment,{key:we},vt(ge.text,w,void 0)):B?ge.isHighlight?l.createElement(l.Fragment,{key:we},vt(ge.text,w,void 0,r.diffAdditionHighlightBg)):l.createElement(l.Fragment,{key:we},vt(ge.text,w,void 0)):l.createElement(l.Fragment,{key:we},vt(ge.text,w,void 0)))))))};return l.createElement(E,{backgroundColor:r.codeBg,paddingX:1,width:S},l.createElement(E,{width:4,flexShrink:0,justifyContent:"flex-end"},l.createElement(ae,{color:xe},L)),l.createElement(E,{width:1,flexShrink:0,marginLeft:1},l.createElement(ae,{color:oe},X)),l.createElement(E,{marginLeft:1,backgroundColor:le,flexGrow:1},be()))}),Cd=l.memo(({text:t,columns:g=80,extension:d,theme:S="Dark"})=>{let w=xt(S),p=t.match(/\[DIFF_START\]([\s\S]*?)(?:\[DIFF_END\]|$)/),b=(p?p[1].trim():"").split(`
|
|
26
|
-
`).map(A=>{let P=A.replaceAll(" "," ");return{line:P,parsed:
|
|
26
|
+
`).map(A=>{let P=A.replaceAll(" "," ");return{line:P,parsed:ni(P),pairContent:null}}),C=[];for(let A=0;A<b.length;A++){let P=b[A];P.parsed&&(P.parsed.isR||P.parsed.isA)?C.push(P):C.length>0&&(ri(C),C=[])}return C.length>0&&ri(C),l.createElement(E,{flexDirection:"column",width:g-3,marginBottom:1},l.createElement(E,{flexDirection:"column",paddingY:0,width:"100%"},l.createElement(E,{backgroundColor:w.codeBg,paddingX:1,width:"100%"},l.createElement(E,{width:3,flexShrink:0}),l.createElement(E,{width:1,flexShrink:0,marginLeft:1}),l.createElement(E,{flexGrow:1,marginLeft:1},l.createElement(ae,null," "))),b.map((A,P)=>l.createElement(pa,{key:P,line:A.line,pairContent:A.pairContent,columns:g-3,extension:d,theme:S})),l.createElement(E,{backgroundColor:w.codeBg,paddingX:1,width:"100%"},l.createElement(E,{width:3,flexShrink:0}),l.createElement(E,{width:1,flexShrink:0,marginLeft:1}),l.createElement(E,{flexGrow:1,marginLeft:1},l.createElement(ae,null," ")))))}),is=l.memo(({text:t,columns:g=80,theme:d="Dark"})=>{if(!t)return null;let S=xt(d),w="",p=t.match(/File\s+\[(.*?)\]/i);if(p&&(w=p[1].split(".").pop().toLowerCase()),t.includes("[DIFF_START]"))return l.createElement(Cd,{text:t,columns:g,extension:w,theme:d});if(t.includes("- Content Preview:")){let r=t.split("- Content Preview:"),y=r[0],b=r[1]||"",C="[SYSTEM] Check the content preview for verification [/SYSTEM]",A=b.split(C),P=(A[0]?.trim()||"").replaceAll(" "," "),B=A[1]?`${C}${A[1]}`:"",L=P.split(`
|
|
27
27
|
`),_=String(L.length).length;return l.createElement(E,{flexDirection:"column",width:g-3},l.createElement(E,{flexDirection:"column",borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:S.codeBorder,paddingLeft:2,paddingRight:0,width:"100%",marginBottom:1,backgroundColor:S.codeBg},l.createElement(E,{flexDirection:"column",width:"100%"},l.createElement(E,{width:"100%"},l.createElement(E,{width:_+2,flexShrink:0},l.createElement(ae,null," ")),l.createElement(E,{flexGrow:1},l.createElement(ae,null," "))),L.map((G,$)=>l.createElement(E,{key:$,width:"100%"},l.createElement(E,{width:_+2,flexShrink:0},l.createElement(ae,{color:"gray",dimColor:!0},String($+1).padStart(_," ")," ")),l.createElement(E,{flexGrow:1},vt(G,w,S.text)))),l.createElement(E,{width:"100%"},l.createElement(E,{width:_+2,flexShrink:0},l.createElement(ae,null," ")),l.createElement(E,{flexGrow:1},l.createElement(ae,null," "))))))}if(t.includes("```")){let r=t.split(/(```\w*\n?[\s\S]*?(?:```|$))/g);return l.createElement(E,{flexDirection:"column",width:g-3},r.map((y,b)=>{if(y.startsWith("```")){let A=y.match(/```(\w*)\n?([\s\S]*?)(?:```|$)/),P=A?A[1]:"code",B=(A?A[2]:y.replace(/^```\w*\n?/,"").replace(/```$/,"")).replaceAll(" "," "),L=B.trimEnd().split(`
|
|
28
28
|
`),_=String(L.length).length,G=g-7-_,z=(G>5?kt(B,G):B).trimEnd().split(`
|
|
29
29
|
`);return l.createElement(E,{key:b,flexDirection:"column",marginY:0,paddingLeft:2,paddingRight:0,width:"100%"},l.createElement(E,null,l.createElement(ae,{color:"gray",bold:!0},"\u25B6_ ",P.toUpperCase()||"TEXT")),l.createElement(E,{flexDirection:"column",width:"100%"},z.map((Y,le)=>{let oe=kt(Y,Math.max(10,G)).split(`
|
|
@@ -40,8 +40,8 @@ import{a as ca}from"./chunk-UEV335RW.js";import{b as Jl,c as Zl,d as Rl}from"./c
|
|
|
40
40
|
`),columns:d,theme:p}),t.memoryUpdated&&l.createElement(E,{marginTop:1,width:"100%"},l.createElement(ae,{color:r.text,italic:!0},"[Memory Updated]")),t.role==="agent"&&t.workedDuration?l.createElement(E,{marginTop:1,marginBottom:2,width:"100%"},l.createElement(ae,{color:r.textMuted},"["),l.createElement(ae,{color:r.textMuted},"Worked for ",l.createElement(ae,{bold:!0,color:r.text},ls(t.workedDuration))),l.createElement(ae,{color:r.textMuted},"]")):null))}),as=l.memo(({block:t,columns:g=80,showFullThinking:d,aiProvider:S,version:w,theme:p="Dark"})=>{let r=xt(p),{msg:y,type:b,text:C,isStreamingMsg:A,workedDuration:P}=t;if((b==="think-header"||b==="think-line"||b==="think-footer-padding")&&!ga())return null;if(b==="chunk")return l.createElement(E,{flexDirection:"column",width:"100%"},t.blocks.map(B=>l.createElement(as,{key:B.key,block:B,columns:g,showFullThinking:d,aiProvider:S,version:w,theme:p})));if(b==="full-message")return l.createElement(ba,{msg:y,showFullThinking:d,columns:g,aiProvider:S,version:w,theme:p});if(b==="think-header")return l.createElement(E,{flexDirection:"column",paddingX:1,width:"100%",marginTop:0,marginBottom:0},(()=>{let B=t.duration||y?.duration||P;return A&&!B?l.createElement(ae,{bold:!0,color:r.text},"\u2727 Thinking..."):l.createElement(ae,{bold:!0,color:r.text},"\u2726 Thought",B?l.createElement(ae,{color:r.textMuted}," for ",l.createElement(ae,{bold:!0,color:r.text},ls(B)),"..."):"s...")})(),d&&l.createElement(E,{flexDirection:"row",width:"100%"},l.createElement(ae,{color:r.textMuted},"\u2502 ")));if(b==="think-line"){if(!d)return null;if(!C||C.trim()==="")return l.createElement(E,{flexDirection:"row",width:"100%",paddingX:1},l.createElement(ae,{color:r.textMuted},"\u2502 "));let B=ma(C,A,t.isActiveBlock)?.replaceAll(" "," ")||"";return l.createElement(E,{flexDirection:"row",width:"100%",paddingX:1},l.createElement(ae,{color:r.textMuted},"\u2502 "),l.createElement(E,{flexGrow:1,marginLeft:1},l.createElement(Jt,{text:B,color:r.textMuted,italic:!0,theme:p})))}if(b==="think-footer-padding")return d?l.createElement(E,{flexDirection:"row",width:"100%",paddingX:1},l.createElement(ae,{color:r.textMuted},"\u2502 ")):null;if(b==="agent-line"){if(!C||C.trim()==="")return l.createElement(E,{height:1});let B=ma(C,A,t.isActiveBlock)?.replaceAll(" "," ")||"",L=B.trim();if(L==="---"||L==="***"||L==="___")return l.createElement(E,{flexDirection:"column",paddingX:1,width:"100%",marginY:0},l.createElement(E,{borderStyle:"single",borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,width:"100%",borderColor:r.borderMuted}));let _=L.match($c);if(_){let z=_[1].length,Y=_[2],xe=["yellow",r.secondary||"magenta",r.info||"cyan","green","blue",r.text][z-1]||r.text;return l.createElement(E,{flexDirection:"column",paddingX:1,width:"100%",marginTop:0,marginBottom:0},l.createElement(ae,{bold:!0,color:xe,underline:!0},l.createElement(Jt,{text:Y,color:xe,theme:p})))}if(L.startsWith(">")){let z=L.replace(/^>\s*/,"");return l.createElement(E,{flexDirection:"column",paddingX:1,width:"100%"},l.createElement(E,{borderStyle:"bold",borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:r.borderMuted,paddingLeft:1,marginY:0},l.createElement(Jt,{text:z,color:r.textMuted,italic:!0,theme:p})))}let G=/^[\*\-\+]\s/.test(L),$=/^\d+\.\s/.test(L);if(G||$){let z=G?" \u2022 ":L.match(/^\d+\.\s/)[0],Y=L.replace(/^[\*\-\+\d+\.]+\s*/,"");return l.createElement(E,{flexDirection:"row",paddingX:1,width:"100%"},l.createElement(ae,{color:r.info||r.textMuted},z),l.createElement(E,{flexGrow:1},l.createElement(Jt,{text:Y,color:r.text,theme:p})))}return l.createElement(E,{flexDirection:"column",paddingX:1,width:"100%"},l.createElement(Jt,{text:B,color:r.text,theme:p}))}if(b==="table-header"||b==="table-row"){let B=b==="table-header",L=r.codeText||r.secondary||r.info||"cyan",_=t.colHeaders||[],G=B?_:t.cells||[],$=Math.max(1,t.colCount||_.length||G.length||1),z=Array.from({length:$},(Be,fe)=>G[fe]||""),Y=Math.max(20,(g||80)-8),le=$>=4,xe=/^(#|no\.?|num\.?|status|state|type|ok|done|✔|✘|active)$/i,oe=[],X=0,be=0;for(let Be=0;Be<$;Be++){let fe=(_[Be]||"").trim();if(le&&(xe.test(fe)||fe==="#")){let Ne=Math.max(fe.length+4,8);oe.push(Ne),X+=Ne}else oe.push(null),be++}let De=Math.max(be*12,Y-X),Oe=be>0?Math.max(10,Math.floor(De/be)):10;for(let Be=0;Be<$;Be++)oe[Be]===null&&(oe[Be]=Oe);let Xe=oe.reduce((Be,fe)=>Be+fe,0);return B?l.createElement(E,{flexDirection:"column",paddingX:1,width:"100%",marginTop:0,marginBottom:1},l.createElement(E,{flexDirection:"row",borderStyle:"single",borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,borderColor:r.borderMuted,paddingBottom:0,width:Xe},_.map((Be,fe)=>{let Ne=oe[fe]||6;return l.createElement(E,{key:fe,width:Ne,paddingRight:1,flexDirection:"column"},l.createElement(Jt,{text:kt(Be,Math.max(2,Ne-1)),color:L,theme:p}))}))):l.createElement(E,{flexDirection:"row",paddingX:1,width:"100%",marginBottom:1},z.map((Be,fe)=>{let Ne=oe[fe]||6;return l.createElement(E,{key:fe,width:Ne,paddingRight:1,flexDirection:"column"},l.createElement(Jt,{text:kt(Be,Math.max(2,Ne-1)),color:r.text,theme:p}))}))}if(b==="table-close")return l.createElement(E,{height:0});if(b==="table")return l.createElement(E,{flexDirection:"column",paddingX:1,width:"100%"},l.createElement(ha,{buffer:C.split(`
|
|
41
41
|
`),terminalWidth:g,theme:p}));if(b==="diff-line"){let{isFirstLine:B,isLastLine:L}=t,_=(G=!1)=>l.createElement(E,{backgroundColor:r.codeBg,paddingX:1,width:g,marginBottom:G?1:0},l.createElement(E,{width:3,flexShrink:0}),l.createElement(E,{width:1,flexShrink:0,marginLeft:1}),l.createElement(E,{flexGrow:1,marginLeft:1},l.createElement(ae,null," ")));return l.createElement(E,{flexDirection:"column"},B&&_(!1),l.createElement(pa,{line:C,pairContent:t.pairContent,parentText:void 0,columns:g,theme:p}),L&&_(!0))}if(b==="code-fence-open"){let B={paddingLeft:2,width:"100%"};return l.createElement(E,{flexDirection:"column",marginTop:0,marginBottom:0,width:"100%"},l.createElement(E,{flexDirection:"row",...B},l.createElement(ae,null," ")),l.createElement(E,{flexDirection:"row",...B},l.createElement(ae,{color:"gray",bold:!0},"\u25B6_ ",(C||"TEXT").toUpperCase())))}if(b==="code-line"){let{lineNum:B,lang:L}=t,_=g-12,G=(C||"").replaceAll(" "," "),z=kt(G,Math.max(10,_)).split(`
|
|
42
42
|
`);return l.createElement(E,{flexDirection:"column",width:"100%"},z.map((Y,le)=>l.createElement(E,{key:le,flexDirection:"row",borderColor:r.codeBorder,paddingLeft:2,width:"100%"},l.createElement(E,{width:5,flexShrink:0},l.createElement(ae,{color:"gray",dimColor:!0},le===0?String(B).padStart(4," ")+" ":" ")),l.createElement(E,{flexGrow:1},vt(Y,L,r.text)))))}if(b==="code-fence-close")return l.createElement(E,{flexDirection:"row",paddingLeft:2,marginBottom:1,width:"100%"},l.createElement(ae,null," "));if(b==="write-header")return l.createElement(E,{flexDirection:"column",paddingX:1,width:g},l.createElement(zn,{text:C,columns:g,theme:p}));if(b==="write-line"){let{gutterWidth:B,lineNum:L,isFirstLine:_,isLastLine:G,extension:$,wrappedLines:z}=t,Y=(le=!1)=>l.createElement(E,{flexDirection:"row",width:g,borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:r.codeBorder,paddingLeft:2,paddingRight:0,backgroundColor:r.codeBg,marginBottom:le?1:0},l.createElement(E,{width:B+2,flexShrink:0},l.createElement(ae,null," ".repeat(B+2))),l.createElement(E,{flexGrow:1},l.createElement(ae,null," ")));return l.createElement(E,{flexDirection:"column"},_&&Y(!1),l.createElement(E,{flexDirection:"row",width:g,borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:r.codeBorder,paddingLeft:2,paddingRight:0,backgroundColor:r.codeBg},l.createElement(E,{width:B+2,flexShrink:0},l.createElement(ae,{color:"gray",dimColor:!0},String(L).padStart(B," ")," ")),l.createElement(E,{flexGrow:1,flexDirection:"column"},(z||[C]).map((le,xe)=>l.createElement(E,{key:xe},vt((le||"").replaceAll(" "," "),$,r.text))))),G&&Y(!0))}return b==="write-footer"?l.createElement(E,{flexDirection:"column",paddingX:1,width:g,marginTop:1,marginBottom:1},l.createElement(zn,{text:C,columns:g,theme:p})):b==="worked-duration"?l.createElement(E,{marginTop:1,marginBottom:2,paddingX:1,width:"100%"},l.createElement(ae,{color:r.textMuted},"["),l.createElement(ae,{color:r.textMuted},"Worked for ",l.createElement(ae,{bold:!0,color:r.text},ls(P))),l.createElement(ae,{color:r.textMuted},"]")):null}),Ru=l.memo(({messages:t,showFullThinking:g,columns:d=80,aiProvider:S,version:w,theme:p="Dark"})=>l.createElement(E,{flexDirection:"column",width:"100%"},t.map((r,y)=>l.createElement(ba,{key:r.id||y,msg:r,showFullThinking:g,columns:d,aiProvider:S,version:w,theme:p}))));import Lt from"react";import{Box as nn,Text as Ao}from"ink";import{useState as Sr,useEffect as vr,useRef as cs}from"react";var Br=null;function wa(){Br&&Br()}var Md=t=>{if(t<=370)return"#00a564";if(t>=5e3)return"#ff0000";let g=[{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 d=0;d<g.length-1;d++){let S=g[d],w=g[d+1];if(t>=S.t&&t<=w.t){let p=(t-S.t)/(w.t-S.t);p=p*p*(3-2*p);let r=Math.round(S.r+(w.r-S.r)*p),y=Math.round(S.g+(w.g-S.g)*p),b=Math.round(S.b+(w.b-S.b)*p);return`#${((1<<24)+(r<<16)+(y<<8)+b).toString(16).slice(1)}`}}return"#ff0000"},Sd=Lt.memo(({mode:t,thinkingLevel:g,tokens:d="0.0k",tokensTotal:S="0.0k",cachedTokens:w=0,promptTokens:p=0,chatCacheTokenLatest:r=0,cacheCalculateMode:y="Session",chatId:b="NEW-SESSION",isMemoryEnabled:C=!0,apiTier:A="Free",aiProvider:P="Google",activeModel:B="",isProcessing:L=!1,lastChunkTime:_=0,theme:G="Dark",wps:$=0,showTPMEstimate:z=!1})=>{let Y=xt(G),le="",[xe,oe]=Sr(0),[X,be]=Sr(0),[De,Oe]=Sr("MB"),[Xe,Be]=Sr("green"),[fe,Ne]=Sr(0),Mt=cs([]),Fe=cs(370),Le=cs([]),R=cs(_);vr(()=>{R.current=_},[_]),vr(()=>{if(!L){Le.current=[];return}if($>0){let ge=Le.current;ge.push($),ge.length>3&&ge.shift()}},[L,$,_]),vr(()=>{if(!L){Ne(0);return}let ge=setInterval(()=>{let we=R.current,ie=we>0?Date.now()-we:0;if(we>0&&ie>=1e3)Le.current=[],Ne(0);else if(we>0&&ie>500){Le.current.length>0&&Le.current.shift();let me=Le.current;if(me.length>0){let j=me.reduce((Ye,ot)=>Ye+ot,0);Ne(Math.round(j/me.length))}else Ne(0)}else{let me=Le.current;if(me.length>0){let j=me.reduce((Ye,ot)=>Ye+ot,0);Ne(Math.round(j/me.length))}else $>0&&Ne(Math.round($))}},750);return()=>clearInterval(ge)},[L]),vr(()=>{if(!L){Mt.current=[];return}if(_>0){let ie=Mt.current;(ie.length===0||ie[ie.length-1]!==_)&&(ie.push(_),ie.length>10&&ie.shift())}let ge=()=>{if(!_){Be("#00a564");return}let ie=Mt.current,me=0;if(ie.length>1){let st=0;for(let qe=1;qe<ie.length;qe++)st+=ie[qe]-ie[qe-1];me=st/(ie.length-1)}let j=Date.now()-_,ot=j>=2500,Tt=!ot&&me>0?Math.min(j,me*3):j,ct=Math.max(me,Tt),wt=ot?.4:.2;Fe.current=Fe.current*(1-wt)+ct*wt,Be(Md(Fe.current))};ge();let we=setInterval(ge,100);return()=>clearInterval(we)},[L,_]);let re=()=>{let ge=process.memoryUsage(),we=ge.heapTotal/(1024*1024)>=1024,ie=we?"GB":"MB",me=(j,Ye)=>{let ot=j/(1048576*(Ye?1024:1));return Ye?parseFloat(ot.toFixed(2)):Math.round(ot)};Oe(ie),be(me(ge.heapTotal,we)),oe(me(ge.heapUsed,we))};return vr(()=>{Br=re,re();let ge=setInterval(()=>{re()},6e4);return()=>{clearInterval(ge),Br===re&&(Br=null)}},[]),Lt.createElement(nn,{flexDirection:"row",justifyContent:"space-between",paddingX:1,width:"100%"},Lt.createElement(nn,null,Lt.createElement(nn,{marginRight:1},Lt.createElement(Ao,{color:Y.textMuted},t.toLowerCase()==="flow"?"Studio":t.toLowerCase()==="icu"?"Computer Use":t.toLowerCase()==="flux"?"Workspace":"Omni")),Lt.createElement(Ao,{color:Y.textMuted,dimColor:!0},"\u2503 "),Lt.createElement(nn,null,Lt.createElement(Ao,{color:Y.text,italic:!0},_l(process.cwd(),35)))),Lt.createElement(nn,null,L&&!z?Lt.createElement(nn,null,Lt.createElement(Ao,{color:Xe},"\u25CF ")):null,L&&z&&Lt.createElement(Lt.Fragment,null,Lt.createElement(Ao,{color:Y.textMuted},"~",fe," tok/s"),Lt.createElement(Ao,{color:Y.textMuted,dimColor:!0}," \u2503")),d>0&&Lt.createElement(Lt.Fragment,null,Lt.createElement(nn,{marginX:1},Lt.createElement(Ao,{color:Y.text},At(S)," tok",(()=>{let ge=0;if(y==="Current")ge=typeof r=="number"?r:0;else{let we=typeof p=="number"?p:0,ie=typeof w=="number"?w:0;ge=we>0?ie/we*100:0}return ge<1?null:Lt.createElement(Ao,{color:Y.success||"green",dimColor:!0}," [",ge.toFixed(0),"% cached]")})())),Lt.createElement(Ao,{color:Y.textMuted,dimColor:!0},"\u2503")),Lt.createElement(nn,{marginLeft:1},Lt.createElement(Ao,{color:Y.textMuted,bold:!0},xe," ",De))))}),Ta=Sd;import ft,{useState as ds,useMemo as vd,useEffect as ya}from"react";import{Box as Zt,Text as Rt,useInput as Bd}from"ink";import Ed from"ink-select-input";var Dd=({label:t,isSelected:g,theme:d="Dark"})=>{let S=xt(d),w=t==="Cancel"||t==="Back"||t.toLowerCase().includes("exit")||t.toLowerCase().includes("back");return ft.createElement(Zt,{marginTop:w?1:0,backgroundColor:g?S.highlightBg:void 0,paddingX:1,width:"100%"},ft.createElement(Rt,{color:g?S.text:S.textMuted,bold:g},g?"\u276F ":" ",t))},Id=8;function $t({title:t,subtitle:g,items:d=[],onSelect:S,theme:w="Dark",searchable:p=!1,maxVisible:r=Id}){let y=xt(w),[b,C]=ds(""),[A,P]=ds(0),[B,L]=ds("list"),_=vd(()=>{if(!p||!b.trim())return d;let xe=b.toLowerCase().trim();return d.filter(oe=>oe.label&&oe.label.toLowerCase().includes(xe))},[d,b,p]);ya(()=>{P(0)},[b]);let[G,$]=ds(0);ya(()=>{$(xe=>_.length<=r?0:A<xe?A:A>=xe+r?A-r+1:xe)},[A,_.length,r]),Bd((xe,oe)=>{if(p){if(oe.upArrow){L("list"),P(X=>_.length===0?0:X>0?X-1:_.length-1);return}if(oe.downArrow){L("list"),P(X=>_.length===0?0:X<_.length-1?X+1:0);return}if(oe.return){_.length>0&&_[A]&&S(_[A]);return}if(oe.escape){if(b)C(""),L("list"),P(0);else{let X=d.find(be=>be.value==="Back"||be.label==="Back"||be.value==="Cancel"||be.label==="Cancel");X&&S(X)}return}if(oe.backspace||oe.delete){L("search"),C(X=>X.slice(0,-1));return}if(xe&&!oe.ctrl&&!oe.meta&&!oe.tab){L("search"),C(X=>X+xe);return}}},{isActive:p});let z=_.length,Y=G;z<=r?Y=0:Y=Math.max(0,Math.min(G,z-r));let le=_.slice(Y,Y+r);return p?ft.createElement(Zt,{flexDirection:"column",borderStyle:"round",borderColor:y.borderMuted,padding:0,marginTop:0,flexShrink:0,width:"100%"},ft.createElement(Zt,{paddingX:1,paddingY:0,marginBottom:0,flexDirection:"row",justifyContent:"space-between"},t?ft.createElement(Rt,{color:y.text,bold:!0},typeof t=="string"?t.toUpperCase():t):ft.createElement(Zt,null),z>0&&ft.createElement(Rt,{color:y.textMuted},A+1,"/",z)),g&&ft.createElement(Zt,{paddingX:1,marginBottom:0},ft.createElement(Rt,{color:y.textMuted,italic:!0}," ",g)),ft.createElement(Zt,{paddingX:1,marginTop:1,marginBottom:1,flexDirection:"row"},ft.createElement(Rt,{color:B==="search"?y.primary||"cyan":y.textMuted,bold:B==="search"},"\u{1F50D} Search:"),ft.createElement(Rt,{color:y.text,bold:!0}," ",b),B==="search"?ft.createElement(Rt,{color:y.primary||"cyan"},"\u2588"):b?null:ft.createElement(Rt,{color:y.textMuted,italic:!0}," (type to search...)")),ft.createElement(Zt,{flexDirection:"column",width:"100%"},_.length===0?ft.createElement(Zt,{paddingX:1,marginY:0},ft.createElement(Rt,{color:y.warning||"yellow",italic:!0}," No matching items found")):le.map((xe,oe)=>{let X=Y+oe,be=X===A,De=xe.label==="Cancel"||xe.label==="Back"||xe.label.toLowerCase().includes("exit")||xe.label.toLowerCase().includes("back");return ft.createElement(Zt,{key:xe.value??xe.label??X,marginTop:De?1:0,backgroundColor:be?y.highlightBg:void 0,paddingX:1,width:"100%"},ft.createElement(Rt,{color:be?y.text:y.textMuted,bold:be},be?"\u276F ":" ",xe.label))})),ft.createElement(Zt,{paddingX:1,marginTop:1},ft.createElement(Rt,{color:y.textMuted,italic:!0},B==="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)"))):ft.createElement(Zt,{flexDirection:"column",borderStyle:"round",borderColor:y.borderMuted,padding:0,marginTop:0,flexShrink:0,width:"100%"},t&&ft.createElement(Zt,{paddingX:1,paddingY:0,marginBottom:g?0:1,flexDirection:"row",justifyContent:"space-between"},ft.createElement(Rt,{color:y.text,bold:!0},typeof t=="string"?t.toUpperCase():t),d.length>r&&ft.createElement(Rt,{color:y.textMuted,italic:!0},d.length," options")),g&&ft.createElement(Zt,{paddingX:1,marginBottom:1},ft.createElement(Rt,{color:y.textMuted,italic:!0}," ",g)),ft.createElement(Zt,{flexDirection:"column",width:"100%"},ft.createElement(Ed,{items:d,onSelect:S,limit:r,itemComponent:xe=>ft.createElement(Dd,{...xe,theme:w}),indicatorComponent:()=>null})),ft.createElement(Zt,{paddingX:1,marginTop:1},ft.createElement(Rt,{color:y.textMuted,italic:!0},"(Arrows to select \u2022 Enter to confirm)")))}import D,{useState as Wt,useEffect as Er}from"react";import{Box as $e,Text as Z,useInput as kd}from"ink";import Ad from"ink-text-input";import Ld from"v8";import Ca from"os";var Lo=[...Object.keys(Xl),"Mystery"],Po=[{id:"appearance",label:"Appearance",desc:"Customize UI theme & rendering options"},{id:"memory",label:"Personalization",desc:"Manage system context & agent's memory"},{id:"secondaryModels",label:"Secondary Models",desc:"Sub-agents & auto-completion models"},{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"}],Ma=t=>{let g=t.autoApproveCommands||"",d=t.autoDisallowCommands||"",S=t.alwaysAskCommands||"",w=t.autoExec===!1&&t.allowExternalAccess===!1&&t.networkAccess===!1&&g===""&&d==="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"&&S==="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,p=t.autoExec===!0&&t.allowExternalAccess===!1&&t.networkAccess!==!1&&g==="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"&&d==="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"&&S==="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,r=t.autoExec===!0&&t.allowExternalAccess===!0&&t.networkAccess!==!1&&g==="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"&&d===""&&S==="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 w?"Strict":p?"Balanced":r?"Autonomous":t.sandboxPreset||"Custom"},Dr=t=>!t||t.trim()===""?"None":t.length>40?t.substring(0,40)+"...":t;function us({systemSettings:t,setSystemSettings:g,apiTier:d,setActiveView:S,setInputConfig:w,saveSettings:p,quotas:r,setMessages:y,aiProvider:b,autoCompletion:C,setAutoCompletion:A,profileData:P,setProfileData:B,initialSelectingTheme:L=!1,onCloseTheme:_=null,setProviderReturnView:G=null,setApiKey:$=null,initAI:z=null}){let Y=t.theme==="Chaos"||t.theme==="Mystery"?"Mystery":t.theme||"Dark",le=Lo.indexOf(Y),[xe,oe]=Wt("categories"),[X,be]=Wt(0),[De,Oe]=Wt(0),[Xe,Be]=Wt("Sandbox"),[fe,Ne]=Wt(null),[Mt,Fe]=Wt(""),[Le,R]=Wt(L),[re,ge]=Wt(le>=0?le:0),[we,ie]=Wt(t.theme||"Dark"),[me,j]=Wt(!1),[Ye,ot]=Wt("subAgent"),[Tt,ct]=Wt(0),[wt,st]=Wt(0),[qe,se]=Wt(""),[Se,ut]=Wt("list"),[mt,_e]=Wt({});Er(()=>{(async()=>{let T=["Google","DeepSeek","OpenRouter","NVIDIA","Mistral","Ollama","InferX","SenseNova","AIHubMix","Poolside","9router","ExpLabs","TokenHarbor","Infron","APInex","xKiro","c_openai"],k={};for(let Me of T)try{await on(Me,{silent:!0})&&(k[Me]=!0)}catch{}_e(k)})()},[]);let Bt=D.useMemo(()=>{let ce=["Google","DeepSeek","OpenRouter","NVIDIA","Mistral","Ollama","InferX","SenseNova","AIHubMix","Poolside","9router","ExpLabs","TokenHarbor","Infron","APInex","xKiro","c_openai"],k=!!(process.env.SUBAGENT_MODEL&&process.env.SUBAGENT_MODEL.trim())?`ENV (${process.env.SUBAGENT_MODEL.trim()})`:"ENV",Me=[{label:"Default (use the current model)",value:"Default",isHeader:!1},{label:k,value:"ENV",isHeader:!1}],Pe=r?.providerTiers?.[b]||d||"Free",at=tn(b,Pe,t?.customOpenAIBaseUrl)||[];at.length>0&&(Me.push({label:`\u2500\u2500 ${b.toUpperCase()}${Pe!=="Free"?` (${Pe})`:""} \u2500\u2500`,isHeader:!0}),at.forEach(dt=>{let tt=typeof dt=="string"?dt:dt.cmd||dt.name||dt.id||String(dt);tt&&!tt.trim().startsWith("---")&&!tt.startsWith(`
|
|
43
|
-
---`)&&Me.push({label:tt,value:tt,isHeader:!1,provider:b})}));for(let dt of ce)if(dt!==b&&mt[dt]){let tt=r?.providerTiers?.[dt]||"Free",ro=tn(dt,tt)||[];ro.length>0&&(Me.push({label:`\u2500\u2500 ${dt.toUpperCase()}${tt!=="Free"?` (${tt})`:""} \u2500\u2500`,isHeader:!0}),ro.forEach(
|
|
44
|
-
---`)&&Me.push({label:Pt,value:Pt,isHeader:!1,provider:dt})}))}return Me},[b,d,r,mt]),We=D.useMemo(()=>{if(!qe.trim())return Bt;let ce=qe.trim().toLowerCase(),T=[],k=null;for(let Me of Bt)Me.isHeader?k=Me:(Me.label.toLowerCase().includes(ce)||Me.value&&Me.value.toLowerCase().includes(ce))&&(k&&!T.includes(k)&&T.push(k),T.push(Me));return T},[Bt,qe]);Er(()=>{if(me){let ce=We.findIndex(T=>!T.isHeader);ct(ce>=0?ce:0),st(0)}},[qe]),Er(()=>{if(me){if(We.length===0){ct(0),st(0);return}if(Tt>=We.length||We[Tt]?.isHeader){let ce=We.findIndex(T=>!T.isHeader);ct(ce>=0?ce:0)}}},[We,me]);let[no,F]=Wt(0),[zo,er]=Wt(0),[Ar,dn]=Wt("MB"),[Lr,un]=Wt(!1);Er(()=>{let ce=!1;return import("./exec_command-BDFXJQZJ.js").then(T=>{ce||un(!!T.isPtyAvailable)}).catch(()=>{}),()=>{ce=!0}},[]),Er(()=>{let ce=Ld.getHeapStatistics().heap_size_limit,T=ce>=1024*1024*1024,k=T?"GB":"MB",Me=T?1024*1024*1024:1024*1024;er(parseFloat((ce/Me).toFixed(2))),dn(k);let Pe=()=>{let ro=process.memoryUsage().rss/Me,Ge=T?parseFloat(ro.toFixed(2)):Math.round(ro);F(Ge)};Pe();let at=setInterval(()=>{Pe()},3e4);return()=>clearInterval(at)},[]);let ys=ce=>{switch(ce){case"providers":{let T=[{label:"Current Provider",value:"aiProvider",status:b==="c_openai"?"Custom (OpenAI)":b}];return b==="Ollama"&&T.push({label:"Endpoint",value:"ollamaEndpoint",status:t.ollamaEndpoint||"Cloud"}),(b==="c_openai"||b==="Custom (OpenAI)")&&(T.push({label:"Base URL",value:"customOpenAIBaseUrl",status:t.customOpenAIBaseUrl||"Not Configured"}),T.push({label:"API Key (if needed)",value:"customOpenAIKey",status:mt.c_openai?"Set":"None"})),T}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"},{label:"Verbose Thinking",value:"preserveThinking",status:t.preserveThinking!==!1?"ON":"OFF"}];case"memory":return[{label:"Base Personality",value:"profilePreset",status:P?.preset||"Default"},{label:"Nickname",value:"profileNickname",status:P?.nickname||"None"},{label:"Custom Instructions",value:"profileInstructions",status:Dr(P?.instructions)},{label:"Toggle Memory [Legacy]",value:"memory",status:t.memory?"ON":"OFF"}];case"security":return[{label:"Sandbox Preset",value:"sandboxPreset",status:Ma(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:Dr(t.alwaysAskCommands),section:"Sandbox"},{label:"Always Ask Files/Paths",value:"alwaysAskFiles",status:Dr(t.alwaysAskFiles||".env, .env.*, *.env"),section:"Sandbox"},{label:"Auto Approve Commands",value:"autoApprove",status:Dr(t.autoApproveCommands),section:"Sandbox"},{label:"Auto Disapprove Commands",value:"autoDisallow",status:Dr(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"},{label:"Agent Clipboard Context",value:"clipboardContext",status:t.clipboardContext?"ON":"OFF",section:"Other"}].filter(Me=>Me.section.toLowerCase()===Xe.toLowerCase());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"secondaryModels":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:"Enable Auto-Completion",value:"autoCompletionEnabled",status:C?.enabled?"ON":"OFF"},{label:"Auto-Completion Model",value:"autoCompletionModel",status:C?.model&&C.model!=="Default"?C.model:"Default"}];case"other":return[{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:"Agent Finish Notification",value:"agentFinishSound",status:t.agentFinishSound?"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"},...process.platform==="win32"?[{label:"Prefer Bash",value:"preferBash",status:t.preferBash!==!1?"ON":"OFF"}]:[],{label:"Cache Calculate Mode",value:"cacheCalculateMode",status:t.cacheCalculateMode||"Session"}];default:return[]}},je=Po[X].id,Gt=ys(je);kd((ce,T)=>{if(me){if(T.tab){ut(k=>k==="search"?"list":"search");return}if(Se==="search"){T.escape?j(!1):T.downArrow||T.return?ut("list"):T.backspace||T.delete?se(k=>k.slice(0,-1)):ce&&!T.ctrl&&!T.meta&&ce.length===1&&se(k=>k+ce);return}if(T.upArrow)ct(k=>{if(We.length===0)return 0;let Me=(k-1+We.length)%We.length,Pe=0;for(;We[Me]?.isHeader&&Pe<We.length;)Me=(Me-1+We.length)%We.length,Pe++;return Me});else if(T.downArrow)ct(k=>{if(We.length===0)return 0;let Me=(k+1)%We.length,Pe=0;for(;We[Me]?.isHeader&&Pe<We.length;)Me=(Me+1)%We.length,Pe++;return Me});else if(T.return){let k=We[Tt];if(k&&!k.isHeader){let Me=k.value==="Default";Ye==="autoCompletion"?A(Pe=>{let at=Me?"":k.provider||"",dt={...Pe,model:k.value,provider:at,baseUrl:Me?"":Pl[at]||""};return p({autoCompletion:dt,apiTier:d,quotas:r}),dt}):g(Pe=>{let at={...Pe,CustomSubAgent:!Me,SubAgentModel:k.value,SubAgentProvider:Me?"":k.provider||""};return p({systemSettings:at,apiTier:d,quotas:r}),at}),j(!1)}}else T.escape?j(!1):ce&&!T.ctrl&&!T.meta&&ce.length===1&&(se(k=>k+ce),ut("search"));return}if(Le){if(T.upArrow){let k=(re-1+Lo.length)%Lo.length;ge(k)}else if(T.downArrow){let k=(re+1)%Lo.length;ge(k)}else if(T.return){let k=Lo[re];g(Me=>{let Pe={...Me,theme:k};return p({systemSettings:Pe,apiTier:d,quotas:r}),Pe}),_?_():R(!1)}else T.escape&&(_?_():R(!1));return}if(fe){T.escape&&Ne(null);return}if(xe==="categories")T.upArrow?be(k=>(k-1+Po.length)%Po.length):T.downArrow?be(k=>(k+1)%Po.length):T.return||T.rightArrow?Po[X].id==="exit"?S("chat"):(oe("items"),Oe(0)):T.escape&&S("chat");else if(xe==="items"){if(je==="security"&&(T.tab||ce===" ")){Be(k=>k==="Sandbox"?"Other":"Sandbox"),Oe(0);return}if(T.upArrow)Oe(k=>(k-1+Gt.length)%Gt.length);else if(T.downArrow)Oe(k=>(k+1)%Gt.length);else if(T.leftArrow)je==="security"&&Xe==="Other"?(Be("Sandbox"),Oe(0)):oe("categories");else if(T.rightArrow&&je==="security"&&Xe==="Sandbox")Be("Other"),Oe(0);else if(T.escape)oe("categories");else if(T.return){let k=Gt[De];Pr(k)}}});let Pr=ce=>{if(ce.value==="profilePreset"){let T=["Default","Sassy","Friendly","Playful","Efficient","Professional"],k=P?.preset||"Default",Pe=(T.indexOf(k)+1)%T.length,at=T[Pe>=0?Pe:0],dt={...P||{},preset:at};B&&B(dt),p({profileData:dt,systemSettings:t,apiTier:d,quotas:r})}else if(ce.value==="profileNickname")Ne("profileNickname"),Fe(P?.nickname||"");else if(ce.value==="profileInstructions")Ne("profileInstructions"),Fe(P?.instructions||"");else if(ce.value==="memory")g(T=>({...T,memory:!T.memory}));else if(ce.value==="sandboxPreset"){let T=Ma(t),k=["Autonomous","Balanced","Strict"],Pe=(k.indexOf(T)+1)%k.length,at=k[Pe];g(dt=>{let tt={...dt,sandboxPreset:at};return at==="Strict"?(tt.autoExec=!1,tt.allowExternalAccess=!1,tt.networkAccess=!1,tt.autoApproveCommands="",tt.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",tt.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",tt.autoApproveGit=!1):at==="Balanced"?(tt.autoExec=!0,tt.allowExternalAccess=!1,tt.networkAccess=!0,tt.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",tt.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",tt.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",tt.autoApproveGit=!1):at==="Autonomous"&&(tt.autoExec=!0,tt.allowExternalAccess=!0,tt.networkAccess=!0,tt.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",tt.autoDisallowCommands="",tt.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",tt.autoApproveGit=!0),tt})}else if(ce.value==="autoExec")t.autoExec?g(T=>({...T,autoExec:!1,sandboxPreset:"Custom"})):t.allowExternalAccess?S("doubleDanger"):S("autoExecDanger");else if(ce.value==="externalAccess")t.allowExternalAccess?g(T=>({...T,allowExternalAccess:!1,sandboxPreset:"Custom"})):t.autoExec?S("doubleDanger"):S("externalDanger");else if(ce.value==="networkAccess")g(T=>({...T,networkAccess:T.networkAccess===!1,sandboxPreset:"Custom"}));else if(ce.value==="alwaysAsk")Ne("alwaysAskCommands"),Fe(t.alwaysAskCommands||"");else if(ce.value==="alwaysAskFiles")Ne("alwaysAskFiles"),Fe(t.alwaysAskFiles||".env, .env.*, *.env");else if(ce.value==="autoApprove")Ne("autoApproveCommands"),Fe(t.autoApproveCommands||"");else if(ce.value==="autoDisallow")Ne("autoDisallowCommands"),Fe(t.autoDisallowCommands||"");else if(ce.value==="autoApproveGit")g(T=>({...T,autoApproveGit:!T.autoApproveGit,sandboxPreset:"Custom"}));else if(ce.value==="customOpenAIBaseUrl")Ne("customOpenAIBaseUrl"),Fe(t.customOpenAIBaseUrl||"");else if(ce.value==="customOpenAIKey")Ne("customOpenAIKey"),Fe("");else if(ce.value==="ollamaEndpoint")g(T=>{let k=T.ollamaEndpoint==="Local"?"Cloud":"Local",Me={...T,ollamaEndpoint:k};return p({systemSettings:Me,apiTier:d,quotas:r}),Me});else if(ce.value==="apiTier")S("apiTier");else if(ce.value==="aiProvider")G&&G("settings"),S("selectProvider");else if(ce.value==="advanceRollback")t.advanceRollback?g(T=>{let k={...T,advanceRollback:!1};return p({systemSettings:k,apiTier:d,quotas:r}),k}):S("advanceRollbackDanger");else if(ce.value==="autoDelete"){let T=["1d","7d","30d"],Me=(T.indexOf(t.autoDeleteHistory||"30d")+1)%T.length;g(Pe=>({...Pe,autoDeleteHistory:T[Me]}))}else if(ce.value==="autoUpdate")g(T=>({...T,autoUpdate:!T.autoUpdate}));else if(ce.value==="externalData")if(!t.useExternalData)w({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||""}),S("input");else{let T={...t,useExternalData:!1};g(T),p({systemSettings:T,apiTier:d,quotas:r}),y(k=>[...k,{id:Date.now(),role:"system",text:"[STORAGE RESET] Flux Flow will return to default ~/.fluxflow after restart."}]),S("chat")}else if(ce.value==="updateManager")S("updateManager");else if(ce.value==="parserDownload")S("parserDownload");else if(ce.value==="indentationTree")g(T=>{let k={...T,indentationTree:T.indentationTree===!1};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="compressToolResults")g(T=>{let k={...T,compressToolResults:!T.compressToolResults};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="autoTruncateResults")g(T=>{let k={...T,autoTruncateResults:!T.autoTruncateResults};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="agentFinishSound")g(T=>{let k={...T,agentFinishSound:!T.agentFinishSound};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="imageHistoryCU"){let T=["Low","Standard","Extended","Max"],Me=(T.indexOf(t.imageHistoryCU||"Standard")+1)%T.length;g(Pe=>{let at={...Pe,imageHistoryCU:T[Me]};return p({systemSettings:at,apiTier:d,quotas:r}),at})}else if(ce.value==="contextLength"){let T=["16k","32k","64k","128k","256k","512k","1M"],Me=(T.indexOf(t.contextLength||"256k")+1)%T.length;g(Pe=>{let at={...Pe,contextLength:T[Me]};return p({systemSettings:at,apiTier:d,quotas:r}),at})}else if(ce.value==="keepReasoningContext")g(T=>{let k={...T,keepReasoningContext:!T.keepReasoningContext};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="autoExcludeMetadata")g(T=>{let k={...T,autoExcludeMetadata:!T.autoExcludeMetadata};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="disableTodo")g(T=>{let k={...T,disableTodo:!T.disableTodo};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="preferBash")g(T=>{let k=T.preferBash!==!1,Me={...T,preferBash:!k};return p({systemSettings:Me,apiTier:d,quotas:r}),Me});else if(ce.value==="cacheCalculateMode"){let T=["Session","Current"],Me=(T.indexOf(t.cacheCalculateMode||"Session")+1)%T.length;g(Pe=>{let at={...Pe,cacheCalculateMode:T[Me]};return p({systemSettings:at,apiTier:d,quotas:r}),at})}else if(ce.value==="subAgents")g(T=>{let k={...T,subAgents:T.subAgents===!1};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="subAgentModel"){let T=t.CustomSubAgent&&t.SubAgentModel?t.SubAgentModel:"Default",k=We.findIndex(Me=>Me.value===T);ct(k>=0?k:0),ot("subAgent"),j(!0)}else if(ce.value==="autoCompletionEnabled")A(T=>{let k={...T,enabled:!T.enabled};return p({autoCompletion:k,apiTier:d,quotas:r}),k});else if(ce.value==="clipboardContext")g(T=>{let k={...T,clipboardContext:!T.clipboardContext};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="autoCompletionModel"){let T=C?.model||"Default",k=We.findIndex(Me=>Me.value===T);ct(k>=0?k:0),ot("autoCompletion"),j(!0)}else if(ce.value==="preserveThinking")g(T=>{let k={...T,preserveThinking:T.preserveThinking===!1};return fa(k.preserveThinking),p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="loadingPhrases")g(T=>{let k={...T,loadingPhrases:T.loadingPhrases===!1};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="progressiveRendering")g(T=>{let k={...T,progressiveRendering:!T.progressiveRendering};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="showTPMEstimate")g(T=>{let k={...T,showTPMEstimate:!T.showTPMEstimate};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="theme"){let T=t.theme==="Chaos"||t.theme==="Mystery"?"Mystery":t.theme||"Dark",k=Lo.indexOf(T);ge(k>=0?k:0),ie(t.theme||"Dark"),R(!0)}},Ce=xt(t.theme);if(me){let ce=Ye==="autoCompletion"?C?.model||"Default":t.CustomSubAgent&&t.SubAgentModel?t.SubAgentModel:"Default",T=15,k=wt;Tt<k?k=Tt:Tt>=k+T&&(k=Tt-T+1),k=Math.max(0,Math.min(k,Math.max(0,We.length-T))),k!==wt&&st(k);let Me=We.slice(k,k+T);return D.createElement($e,{flexDirection:"column",borderStyle:"round",borderColor:Ce.border,padding:1,width:"100%",minHeight:32},D.createElement($e,{marginBottom:1,flexDirection:"row",justifyContent:"space-between"},D.createElement(Z,{color:Ce.text,bold:!0,underline:!0},Ye==="autoCompletion"?"Select Auto-Completion Model:":"Select Sub-Agent Model:"),We.length>0&&D.createElement(Z,{color:"gray"},Tt+1,"/",We.length)),D.createElement($e,{borderStyle:"single",borderColor:Se==="search"?Ce.primary||"cyan":"gray",paddingX:1,marginBottom:1},D.createElement(Z,{color:Se==="search"?Ce.primary||"cyan":"gray",bold:!0},"\u{1F50D} Search: "," "),D.createElement(Z,{color:Ce.text},qe),Se==="search"&&D.createElement(Z,{color:Ce.primary||"cyan"},"\u2588"),!qe&&Se!=="search"&&D.createElement(Z,{color:"gray",italic:!0},"(Press TAB or type to filter models...)")),D.createElement($e,{flexDirection:"column",flexGrow:1,height:T},Me.length>0?Me.map((Pe,at)=>{let dt=k+at;if(Pe.isHeader)return D.createElement($e,{key:`hdr-${dt}`,paddingX:1},D.createElement(Z,{color:"gray",bold:!0,underline:!0},Pe.label));let tt=Tt===dt&&Se==="list",ro=ce===Pe.value;return D.createElement($e,{key:`item-${Pe.value}-${dt}`,paddingX:1,backgroundColor:tt?Ce.highlightBg:void 0},D.createElement(Z,{color:tt?Ce.text:Ce.textDim,bold:tt},tt?"\u276F ":" ",Pe.label,ro?D.createElement(Z,{color:Ce.primary||"cyan",italic:!0}," (active)"):""))}):D.createElement($e,{paddingX:1},D.createElement(Z,{color:"gray",italic:!0},'No models matching "',qe,'"'))),D.createElement($e,{paddingX:1,marginTop:1,flexDirection:"row",justifyContent:"space-between"},D.createElement(Z,{color:"gray",italic:!0},"TAB to switch search/list \u2022 \u25B2\u25BC Navigate \u2022 ENTER to Select \u2022 ESC to Cancel"),D.createElement(Z,{color:Se==="search"?Ce.primary||"cyan":"gray",bold:!0},"[",Se.toUpperCase()," MODE]")))}if(Le){let ce=Lo[re],T=xt(ce);return D.createElement($e,{flexDirection:"column",borderStyle:"round",borderColor:T.border,padding:1,width:"100%",minHeight:32},D.createElement($e,{marginBottom:1},D.createElement(Z,{color:T.text,bold:!0},"Choose your color scheme:")),D.createElement($e,{flexDirection:"row",width:"100%",flexGrow:1},D.createElement($e,{flexDirection:"column",width:"30%",paddingRight:1},Lo.map((k,Me)=>{let Pe=re===Me,at=(t.theme||"Dark")===k,dt=k==="Forest Sprite"||k==="Spookfest";return D.createElement($e,{key:k,paddingX:0},D.createElement(Z,{color:Pe?T.text:T.textDim,bold:Pe},Pe?"> ":" ",k,dt&&D.createElement(Z,{color:Pe?T.success||"#52b788":"green",bold:!0}," \u2605"),at?D.createElement(Z,{color:T.primary||"cyan",italic:!0}," (saved)"):""))})),D.createElement($e,{flexDirection:"column",flexGrow:1,borderStyle:"round",borderColor:T.borderMuted,paddingX:2,paddingY:1,backgroundColor:T.cardBg},D.createElement($e,{marginBottom:1},D.createElement(Z,{color:T.secondary||"cyan",bold:!0},"> ","you: "),D.createElement(Z,{color:T.text},"add a greeting function")),D.createElement($e,{marginBottom:1},D.createElement(Z,{color:T.success||"green"}," Here's the change:")),D.createElement($e,{flexDirection:"column",marginLeft:2,marginBottom:1},D.createElement(Z,null,D.createElement(Z,{color:T.textDim},"3 "),vt(' import "fmt"',".go",void 0)),D.createElement(Z,{color:T.textDim},"4"),D.createElement($e,{backgroundColor:T.diffRemovalBg},D.createElement(Z,null,D.createElement(Z,{color:T.diffRemovalNum||T.diffRemovalText},"5 "),D.createElement(Z,{color:T.diffRemovalPrefix||T.diffRemovalText},"- "),vt("func ",".go",void 0),vt("main()",".go",void 0,T.diffRemovalHighlightBg),vt(" {",".go",void 0))),D.createElement($e,{backgroundColor:T.diffAdditionBg},D.createElement(Z,null,D.createElement(Z,{color:T.diffAdditionNum||T.diffAdditionText},"5 "),D.createElement(Z,{color:T.diffAdditionPrefix||T.diffAdditionText},"+ "),vt("func ",".go",void 0),vt("greet(name string)",".go",void 0,T.diffAdditionHighlightBg),vt(" {",".go",void 0))),D.createElement($e,{backgroundColor:T.diffAdditionBg},D.createElement(Z,null,D.createElement(Z,{color:T.diffAdditionNum||T.diffAdditionText},"6 "),D.createElement(Z,{color:T.diffAdditionPrefix||T.diffAdditionText},"+ "),D.createElement(Z,null," "),vt('fmt.Printf("Hello, %s!\\n", name)',".go",void 0,T.diffAdditionHighlightBg))),D.createElement(Z,null,"7 }")),D.createElement($e,{flexDirection:"column",marginTop:1,marginBottom:1},D.createElement(Z,{color:T.textDim},"\u25BE Thought Process"),D.createElement(Z,{color:T.textMuted}," I need to add a greeting function. I'll use fmt.Printf.")),D.createElement($e,{flexDirection:"column"},D.createElement(Z,null,D.createElement(Z,{color:T.warning||"yellow"},"\u2699 tool: "),D.createElement(Z,{color:T.text},"write_file main.go")),D.createElement(Z,null,D.createElement(Z,{color:T.accent||"magenta"},"\u29BF task: "),D.createElement(Z,{color:T.text},"Implementing greeting")),D.createElement(Z,null,D.createElement(Z,{color:T.danger||"red"},"X error: "),D.createElement(Z,{color:T.text},"compilation failed")),D.createElement(Z,null,D.createElement(Z,{color:T.warning||"yellow"},"\u26A0 warning: "),D.createElement(Z,{color:T.text},"deprecation warning")),D.createElement(Z,null,D.createElement(Z,{color:T.info||"blue"},"\u2192 link: "),D.createElement(Z,{color:T.info||"blue",underline:!0},"file:///path/to/main.go")),D.createElement(Z,null,D.createElement(Z,{color:T.accent||"magenta"},"\u2605 accent: "),D.createElement(Z,{color:T.text},"highlighted text")),D.createElement(Z,{color:T.textDim},"\xB7 dim: press Enter to continue")))),D.createElement($e,{paddingX:1,marginTop:1,flexDirection:"row",justifyContent:"space-between"},D.createElement(Z,{color:"gray",italic:!0},"\u25B2\u25BC Navigate \u2022 ENTER to Select \u2022 ESC to Cancel"),D.createElement(Z,{color:"gray"},"Previewing: ",Lo[re],Lo[re]==="Forest Sprite"?" \u2605":"")))}return D.createElement($e,{flexDirection:"column",borderStyle:"round",borderColor:Ce.border,padding:0,width:"100%",minHeight:26},D.createElement($e,{paddingX:1,paddingY:0,marginBottom:0,borderStyle:"single",borderColor:Ce.borderMuted,width:"100%"},D.createElement(Z,{color:Ce.text,bold:!0},"SYSTEM CONFIGURATION")),D.createElement($e,{flexDirection:"row",width:"100%",minHeight:20},D.createElement($e,{flexDirection:"column",width:"30%",maxWidth:40,borderStyle:"round",borderColor:xe==="categories"?Ce.border:Ce.borderMuted,padding:1,paddingY:0},D.createElement($e,{marginBottom:1},D.createElement(Z,{color:xe==="categories"?Ce.text:Ce.textDim,bold:!0,underline:!0},"CATEGORIES")),Po.map((ce,T)=>{let k=X===T,Me=ce.id==="exit";return D.createElement($e,{key:ce.id,marginTop:Me?9:0,backgroundColor:k?xe==="categories"?Ce.highlightBg:Ce.cardBg:void 0,paddingX:1},D.createElement(Z,{color:k&&xe==="categories"?Ce.text:Ce.textDim,bold:k},k?"\u276F ":" ",ce.label))})),D.createElement($e,{flexDirection:"column",flexGrow:1,borderStyle:"round",borderColor:xe==="items"?Ce.border:Ce.borderMuted,paddingX:1,marginLeft:1,paddingY:0},D.createElement($e,{marginBottom:1,flexDirection:"row",justifyContent:"space-between",alignItems:"center"},D.createElement(Z,{color:xe==="items"?Ce.text:Ce.textDim,bold:!0,underline:!0},Po[X].label.toUpperCase().includes("EXIT")?"Runtime Information":`${Po[X].label} Settings`),je==="security"&&D.createElement($e,{flexDirection:"row"},D.createElement($e,{paddingX:1,backgroundColor:Xe==="Sandbox"?xe==="items"?Ce.highlightBg:Ce.cardBg:void 0},D.createElement(Z,{bold:Xe==="Sandbox",color:Xe==="Sandbox"?Ce.primary||"cyan":Ce.textDim},"[ Sandbox ]")),D.createElement($e,{paddingX:1,backgroundColor:Xe==="Other"?xe==="items"?Ce.highlightBg:Ce.cardBg:void 0},D.createElement(Z,{bold:Xe==="Other",color:Xe==="Other"?Ce.primary||"cyan":Ce.textDim},"[ Others ]")))),Gt.length>0?(()=>{let ce=null,T=[],k=Ge=>(Ge||"").split(",").map(Pt=>Pt.trim().toLowerCase()).filter(Boolean),Me=k(t.autoApproveCommands),Pe=k(t.autoDisallowCommands),at=k(t.alwaysAskCommands),dt=[...Me,...Pe,...at],tt=new Set(dt),ro=je==="security"&&dt.length!==tt.size;return Gt.forEach((Ge,Pt)=>{let mn=xe==="items"&&De===Pt,xn=Ge.label.length,Cs=Math.max(2,38-xn),St=".".repeat(Cs),ne=ze=>je==="security"?(ze.value==="autoExec"||ze.value==="externalAccess")&&ze.status==="ON"?Ce.statusOn:Ce.statusOff:ze.status?.startsWith("\u2713")?Ce.statusOn:ze.status?.startsWith("\u26A0")?Ce.statusOff:ze.status==="ON"?Ce.statusOn:ze.status==="OFF"?Ce.statusOff:Ce.text;Ge.section&&Ge.section!==ce&&je!=="security"&&(ce=Ge.section,T.push(D.createElement($e,{key:`sec-hdr-${Ge.section}`,marginTop:T.length>0?1:0,marginBottom:0,paddingX:1},D.createElement(Z,{color:"gray",bold:!0,underline:!0},Ge.section.toUpperCase()))));let In=mn&&fe&&(fe==="alwaysAskCommands"&&Ge.value==="alwaysAsk"||fe==="alwaysAskFiles"&&Ge.value==="alwaysAskFiles"||fe==="autoApproveCommands"&&Ge.value==="autoApprove"||fe==="autoDisallowCommands"&&Ge.value==="autoDisallow"||fe==="customOpenAIBaseUrl"&&Ge.value==="customOpenAIBaseUrl"||fe==="customOpenAIKey"&&Ge.value==="customOpenAIKey"||fe==="profileNickname"&&Ge.value==="profileNickname"||fe==="profileInstructions"&&Ge.value==="profileInstructions"),Or=Ge.value==="alwaysAsk"||Ge.value==="alwaysAskFiles"||Ge.value==="autoApprove"||Ge.value==="autoDisallow"||Ge.value==="profileInstructions",Nr=Ge.value==="parserDownload";T.push(D.createElement($e,{key:Ge.value,flexDirection:"column"},D.createElement($e,{backgroundColor:mn&&!In?Ce.highlightBg:void 0,paddingX:2},D.createElement(Z,{color:mn?Ce.text:Ce.textDim,bold:mn},mn?"\u276F ":" ",Ge.label),!Or&&!Nr&&D.createElement(D.Fragment,null,D.createElement(Z,{color:"gray"},St),D.createElement(Z,{color:ne(Ge),bold:!0},Ge.value==="aiProvider"?Ge.status:`[ ${Ge.status} ]`))),Or&&!In&&Ge.status!=="None"&&D.createElement($e,{paddingX:4,marginBottom:1},D.createElement(Z,{color:"gray"},"\u21B3 ",Ge.status)),In&&D.createElement($e,{flexDirection:"column",marginLeft:4,marginBottom:1},D.createElement($e,{paddingX:1,borderStyle:"single",borderColor:"gray",flexDirection:"row"},D.createElement(Z,{color:"gray",bold:!0},"> "," "),D.createElement(Ad,{value:Mt,onChange:ze=>{let Ht=fe==="profileNickname"?20:fe==="profileInstructions"?250:1/0;Fe(ze.slice(0,Ht))},onSubmit:async ze=>{if(fe==="customOpenAIBaseUrl"){let Ht=ze.trim().replace(/\/+$/,""),Ie={...t,customOpenAIBaseUrl:Ht};g(Ie),p({systemSettings:Ie,apiTier:d,quotas:r})}else if(fe==="customOpenAIKey"){let{saveProviderAPIKey:Ht}=await import("./secrets-HXB3H4UI.js");await Ht("c_openai",ze.trim()),_e(Ie=>({...Ie,c_openai:!!ze.trim()})),b==="c_openai"&&($&&$(ze.trim()),z&&z(ze.trim(),{aiProvider:"c_openai"}))}else if(fe==="profileNickname"){let Ht=ze.trim().slice(0,20),Ie={...P||{},nickname:Ht};B&&B(Ie),p({profileData:Ie,systemSettings:t,apiTier:d,quotas:r})}else if(fe==="profileInstructions"){let Ht=ze.trim().slice(0,250),Ie={...P||{},instructions:Ht};B&&B(Ie),p({profileData:Ie,systemSettings:t,apiTier:d,quotas:r})}else{let Ht={...t,[fe]:ze.trim(),sandboxPreset:"Custom"};g(Ht),p({systemSettings:Ht,apiTier:d,quotas:r})}Ne(null)}})),D.createElement(Z,{color:"gray",italic:!0}," ",fe==="customOpenAIBaseUrl"?"Enter Base URL (.../v1) \u2022 Press Enter to save, Esc to cancel":fe==="customOpenAIKey"?"Enter API Key \u2022 Press Enter to save, Esc to cancel":fe==="profileNickname"?`Enter Nickname (${Mt.length}/20) \u2022 Press Enter to save, Esc to cancel`:fe==="profileInstructions"?`Enter Custom Instructions (${Mt.length}/250) \u2022 Press Enter to save, Esc to cancel`:"Comma separated \u2022 Press Enter to save, Esc to cancel"))))}),ro&&T.push(D.createElement($e,{key:"conflict-warning",marginTop:1,paddingX:1},D.createElement(Z,{color:Ce.text,italic:!0},"* Conflicting commands will be ignored and defaulted to highest priority"))),T})():D.createElement($e,{paddingX:1,flexDirection:"column",width:"100%"},je==="exit"?D.createElement(D.Fragment,null,D.createElement($e,{flexDirection:"column",marginBottom:1},D.createElement($e,{flexDirection:"row"},D.createElement(Z,{color:Ce.textDim},"OS"," "),D.createElement(Z,{color:"gray"},"..................... "),D.createElement(Z,{color:Ce.text},process.env.OS||process.platform||"N/A")),D.createElement($e,{flexDirection:"row"},D.createElement(Z,{color:Ce.textDim},"Computer Name"," "),D.createElement(Z,{color:"gray"},".......... "),D.createElement(Z,{color:Ce.text},process.env.COMPUTERNAME||process.env.HOSTNAME||"N/A")),D.createElement($e,{flexDirection:"row"},D.createElement(Z,{color:Ce.textDim},"Processor Count"," "),D.createElement(Z,{color:"gray"},"........ "),D.createElement(Z,{color:Ce.text},process.env.NUMBER_OF_PROCESSORS||"N/A")),D.createElement($e,{flexDirection:"row"},D.createElement(Z,{color:Ce.textDim},"Node.js Version"," "),D.createElement(Z,{color:"gray"},"........ "),D.createElement(Z,{color:Ce.text},"v",process.versions.node)),D.createElement($e,{flexDirection:"row"},D.createElement(Z,{color:Ce.textDim},"V8 Version"," "),D.createElement(Z,{color:"gray"},"...... ...... "),D.createElement(Z,{color:Ce.text},"v",process.versions.v8)),D.createElement($e,{flexDirection:"row"},D.createElement(Z,{color:Ce.textDim},"Data Directory"," "),D.createElement(Z,{color:"gray"},"......... "),So===ko?"":D.createElement(Z,{color:Ce.text},So.replaceAll(Ca.homedir(),"~").replaceAll("\\\\","/").replaceAll("\\","/"),", "),D.createElement(Z,{color:Ce.text},ko.replaceAll(Ca.homedir(),"~").replaceAll("\\\\","/").replaceAll("\\","/"))),D.createElement($e,{flexDirection:"row"},D.createElement(Z,{color:Ce.textDim},"Viewport"," "),D.createElement(Z,{color:"gray"},"............... "),D.createElement(Z,{color:Ce.text},process.stdout.rows||"?"," rows \xD7 ",process.stdout.columns||"?"," cols ",process.stdout.columns<90?"(too small width)":"")),D.createElement($e,{flexDirection:"row",marginBottom:0},D.createElement(Z,{color:Ce.textDim},"Memory Load"," "),D.createElement(Z,{color:"gray"},"............ "),D.createElement(Z,{color:Ce.text},no,"/",zo," ",Ar))),D.createElement($e,{key:"pty-notice",paddingX:0,marginTop:0},D.createElement(Z,{color:Lr?Ce.statusOn:Ce.warning},Lr?"\u2713 Advance Interactive Terminal Supported":"\u26A0 Interactive Terminal is Limited"))):D.createElement(Z,{color:"gray",italic:!0},Po[X].desc)))),D.createElement($e,{paddingX:1,marginTop:0,flexDirection:"row",justifyContent:"space-between"},D.createElement(Z,{color:"gray",italic:!0},xe==="categories"?"\u25B2\u25BC Select Category \u2022 Enter/\u25BA to configure":je==="security"?"\u25B2\u25BC Select Option \u2022 TAB/\u25C4\u25BA Switch Tab \u2022 Enter to Edit/Toggle \u2022 ESC to go back":"\u25B2\u25BC Select Option \u2022 Enter to Toggle \u2022 \u25C4/ESC to go back"),xe==="categories"&&D.createElement(Z,{color:"gray"},Po[X].desc)))}import Ut,{useState as di}from"react";import{Box as fo,Text as rn,useInput as Pd}from"ink";import Od from"ink-text-input";var Nd=({question:t,options:g,onResolve:d,theme:S="Dark"})=>{let w=xt(S),[p,r]=di(!1),[y,b]=di(""),[C,A]=di(0),P=!1,B=[],L=Array.isArray(g)&&g.length>0,_=t==="Agent has been running for a long time. Do you want to continue execution?";try{_&&L?B=[...g]:B=[...L?g:[],L?{id:"CUSTOM",label:"Suggest something else...",description:"Provide a custom response"}:{id:"CUSTOM",label:"Your Answer",description:""}]}catch{P=!0}Pd(($,z)=>{if(!p&&((z.leftArrow||z.upArrow)&&A(Y=>Math.max(0,Y-1)),(z.rightArrow||z.downArrow)&&A(Y=>Math.min(B.length-1,Y+1)),z.return)){let Y=B[C];Y?.id==="CUSTOM"?r(!0):d(P?"Selected Nothing":Y.label)}});let G=yt(2);return p?Ut.createElement(fo,{flexDirection:"column",borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,backgroundColor:w.codeBg,width:"100%"},Ut.createElement(fo,{paddingX:1},Ut.createElement(rn,{color:w.text,bold:!0},"SUGGEST SOMETHING")),Ut.createElement(fo,{marginTop:1,paddingX:1},Ut.createElement(rn,{italic:!0,color:w.textMuted},"Replying to: ",t)),Ut.createElement(fo,{marginTop:1,paddingX:1,flexDirection:"row"},Ut.createElement(Od,{value:y,onChange:b,onSubmit:()=>d(y)})),Ut.createElement(fo,{marginTop:1,paddingX:1,marginBottom:1},Ut.createElement(rn,{color:w.textMuted,italic:!0},"(Press Enter to send)"))):Ut.createElement(fo,{flexDirection:"column",border:!0,borderStyle:"round",borderColor:w.codeBorder,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,marginY:1,marginRight:1,width:"100%"},Ut.createElement(fo,{paddingX:1,marginBottom:1},Ut.createElement(rn,{color:"yellow",bold:!0},_?"TURN SAFETY SYSTEM: EXECUTION LIMIT":"AGENT REQUEST: ACTION REQUIRED")),Ut.createElement(fo,{paddingX:1,marginBottom:1},Ut.createElement(rn,{color:w.text},t)),Ut.createElement(fo,{flexDirection:"column",width:"100%"},B.map(($,z)=>{let Y=z===C;return Ut.createElement(fo,{key:$.id,flexDirection:"column",width:"100%",backgroundColor:Y?w.highlightBg:void 0,paddingX:1,marginBottom:z===B.length-1?0:1},Ut.createElement(rn,{color:Y?w.text:w.textMuted,bold:Y},Y?"\u276F ":" ",$.label),$.description&&Ut.createElement(fo,{marginLeft:4},Ut.createElement(rn,{color:w.textMuted,italic:!0},$.description)))})),Ut.createElement(fo,{paddingX:1,marginTop:1,marginBottom:1},Ut.createElement(rn,{color:w.textMuted,italic:!0},"(Use Arrows to navigate, Enter to confirm)")))},Sa=Nd;import iu from"gradient-string";var Fd=t=>{let g=String(t||"").trim().split(/\s+/).filter(Boolean),d={sub:null,args:[],provider:null,providerBare:!1,index:null,temp:!1,all:!1,unmask:!1},S=[];for(let w=0;w<g.length;w++){let p=g[w];if(p==="--provider"){let r=g[w+1];r&&!r.startsWith("--")?(d.provider=r,w++):d.providerBare=!0}else if(p==="--index"){let r=g[w+1];r&&/^\d+$/.test(r)&&(d.index=parseInt(r,10)-1,w++)}else p==="--temp"?d.temp=!0:p==="--all"?d.all=!0:p==="--unmask"||p==="--reveal"?d.unmask=!0:p==="--mask"?d.unmask=!1:S.push(p)}return d.sub=S.length?S[0].toLowerCase():null,d.args=S.slice(1),d},va=["\u2726 API KEY MANAGEMENT","\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m /key list [--provider <name>] [--unmask]","\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m /key add <key> [--index <n>] [--provider <name>]","\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m /key remove [<index>|<key>|--all] [--provider <name>]","\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m /key use <index>|<key> | /key use <key> --temp","\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m /key clean [--provider <name>]","\u2800"],Ba=async(t,g={})=>{let d=Fd(t),S=g.currentProvider||"Google",w=[],p=(b={})=>({lines:w,...b}),r=S;if(d.provider){let b=Tl(d.provider);if(!b)return{lines:[`\u2726 Unknown provider: ${d.provider}`]};r=b}let y=d.sub;if(!y)return{lines:va};if(y==="list"){if(d.providerBare){let C=Ml();w.push("\u2726 SAVED API KEYS");for(let A of C)w.push(`- ${A.provider} (${A.hasKeys?A.count:"No Saved Keys"})`);return w.push("\u2800"),p()}let b=await Ll(r,{unmask:d.unmask});return w.push(`\u2726 ${Cl(r)} API KEYS`),w.push(...b),w.push("\u2800"),p()}if(y==="add"||y==="new"){let b=d.args.join(" ").trim();if(!b)return p({promptNewKey:!0});let C=await Dl(r,b,{index:d.index!==null?d.index:void 0});return C.ok?(await Sl(r)===null&&await vl(r,C.index),w.push(`\u2726 Key added to ${r} slot ${C.index+1}.`),p()):C.full?{lines:[`\u2726 ${C.error}`,"\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Use /key add <key> --index <n> to overwrite a slot."]}:{lines:[`\u2726 Failed to add key: ${C.error}`]}}if(y==="remove"){let b;if(d.all)b=void 0;else if(d.args.length){let A=d.args.join(" ");b=/^\d+$/.test(A)?parseInt(A,10)-1:A}let C=await Il(r,b,{all:d.all});return C.ok?C.all?(w.push(`\u2726 Cleared all keys for ${r}.`),p({promptNewKey:!0})):(w.push(`\u2726 Removed key from ${r} slot ${C.removedIndex+1}.`),C.needsNewKey?(w.push(`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No keys remain for ${r}. Please enter a new key.`),p({promptNewKey:!0})):p()):{lines:[`\u2726 ${C.error}`]}}if(y==="use"){let b=d.args.join(" ").trim();if(!b)return{lines:["\u2726 Usage: /key use <index> | <key> [--temp]"]};if(d.temp)return Bl(r,b),w.push(`\u2726 Temporary key set for ${r} (session only).`),yl(r)&&w.push("\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Will use the current Custom base URL."),p();let C=/^\d+$/.test(b)?parseInt(b,10)-1:b,A=await kl(r,C);return A.ok?(El(r),w.push(`\u2726 ${r} now using slot ${A.index+1}.`),A.switchedBaseUrl&&w.push(`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Switched Base URL to: ${A.switchedBaseUrl}`),p({switchedBaseUrl:A.switchedBaseUrl,switchedKey:A.key})):{lines:[`\u2726 ${A.error}`]}}if(y==="clean"){let b=d.provider?r:null,C=await Al(b);return w.push(b?`\u2726 Compacted ${b} key slots.`:`\u2726 Compacted all key stores (${C.touched} provider(s) touched).`),p()}return{lines:[`\u2726 Unknown subcommand: ${y}`,...va]}};import Ia from"node-notifier";import Yo from"path";import Ea from"fs";import{execSync as $d}from"child_process";import{fileURLToPath as Ud}from"url";var ms=Yo.dirname(Ud(import.meta.url)),Ir=t=>{let g=[Yo.resolve(ms,"../assets",t),Yo.resolve(ms,"../../assets",t),Yo.resolve(ms,"../../src/assets",t),Yo.resolve(process.cwd(),"src/assets",t),Yo.resolve(process.cwd(),"dist/assets",t)];for(let d of g)if(Ea.existsSync(d))return d;return g[0]},Da=Yo.join(process.env.APPDATA,"Microsoft","Windows","Start Menu","Programs","FluxFlow"),_m=Yo.join(Da,"FluxFlow.lnk"),Hm=Yo.resolve(ms,"../../node_modules/node-notifier/vendor/snoreToast/snoretoast-x64.exe"),ui=()=>{if(process.platform==="win32")try{let t=Ir("logo.png"),g=Ir("logo.ico"),S=`
|
|
43
|
+
---`)&&Me.push({label:tt,value:tt,isHeader:!1,provider:b})}));for(let dt of ce)if(dt!==b&&mt[dt]){let tt=r?.providerTiers?.[dt]||"Free",ro=tn(dt,tt)||[];ro.length>0&&(Me.push({label:`\u2500\u2500 ${dt.toUpperCase()}${tt!=="Free"?` (${tt})`:""} \u2500\u2500`,isHeader:!0}),ro.forEach(Ke=>{let Pt=typeof Ke=="string"?Ke:Ke.cmd||Ke.name||Ke.id||String(Ke);Pt&&!Pt.trim().startsWith("---")&&!Pt.startsWith(`
|
|
44
|
+
---`)&&Me.push({label:Pt,value:Pt,isHeader:!1,provider:dt})}))}return Me},[b,d,r,mt]),We=D.useMemo(()=>{if(!qe.trim())return Bt;let ce=qe.trim().toLowerCase(),T=[],k=null;for(let Me of Bt)Me.isHeader?k=Me:(Me.label.toLowerCase().includes(ce)||Me.value&&Me.value.toLowerCase().includes(ce))&&(k&&!T.includes(k)&&T.push(k),T.push(Me));return T},[Bt,qe]);Er(()=>{if(me){let ce=We.findIndex(T=>!T.isHeader);ct(ce>=0?ce:0),st(0)}},[qe]),Er(()=>{if(me){if(We.length===0){ct(0),st(0);return}if(Tt>=We.length||We[Tt]?.isHeader){let ce=We.findIndex(T=>!T.isHeader);ct(ce>=0?ce:0)}}},[We,me]);let[no,F]=Wt(0),[zo,er]=Wt(0),[Ar,dn]=Wt("MB"),[Lr,un]=Wt(!1);Er(()=>{let ce=!1;return import("./exec_command-BDFXJQZJ.js").then(T=>{ce||un(!!T.isPtyAvailable)}).catch(()=>{}),()=>{ce=!0}},[]),Er(()=>{let ce=Ld.getHeapStatistics().heap_size_limit,T=ce>=1024*1024*1024,k=T?"GB":"MB",Me=T?1024*1024*1024:1024*1024;er(parseFloat((ce/Me).toFixed(2))),dn(k);let Pe=()=>{let ro=process.memoryUsage().rss/Me,Ke=T?parseFloat(ro.toFixed(2)):Math.round(ro);F(Ke)};Pe();let at=setInterval(()=>{Pe()},3e4);return()=>clearInterval(at)},[]);let ys=ce=>{switch(ce){case"providers":{let T=[{label:"Current Provider",value:"aiProvider",status:b==="c_openai"?"Custom (OpenAI)":b}];return b==="Ollama"&&T.push({label:"Endpoint",value:"ollamaEndpoint",status:t.ollamaEndpoint||"Cloud"}),(b==="c_openai"||b==="Custom (OpenAI)")&&(T.push({label:"Base URL",value:"customOpenAIBaseUrl",status:t.customOpenAIBaseUrl||"Not Configured"}),T.push({label:"API Key (if needed)",value:"customOpenAIKey",status:mt.c_openai?"Set":"None"})),T}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"},{label:"Verbose Thinking",value:"preserveThinking",status:t.preserveThinking!==!1?"ON":"OFF"}];case"memory":return[{label:"Base Personality",value:"profilePreset",status:P?.preset||"Default"},{label:"Nickname",value:"profileNickname",status:P?.nickname||"None"},{label:"Custom Instructions",value:"profileInstructions",status:Dr(P?.instructions)},{label:"Toggle Memory [Legacy]",value:"memory",status:t.memory?"ON":"OFF"}];case"security":return[{label:"Sandbox Preset",value:"sandboxPreset",status:Ma(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:Dr(t.alwaysAskCommands),section:"Sandbox"},{label:"Always Ask Files/Paths",value:"alwaysAskFiles",status:Dr(t.alwaysAskFiles||".env, .env.*, *.env"),section:"Sandbox"},{label:"Auto Approve Commands",value:"autoApprove",status:Dr(t.autoApproveCommands),section:"Sandbox"},{label:"Auto Disapprove Commands",value:"autoDisallow",status:Dr(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"},{label:"Agent Clipboard Context",value:"clipboardContext",status:t.clipboardContext?"ON":"OFF",section:"Other"}].filter(Me=>Me.section.toLowerCase()===Xe.toLowerCase());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"secondaryModels":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:"Enable Auto-Completion",value:"autoCompletionEnabled",status:C?.enabled?"ON":"OFF"},{label:"Auto-Completion Model",value:"autoCompletionModel",status:C?.model&&C.model!=="Default"?C.model:"Default"}];case"other":return[{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:"Agent Finish Notification",value:"agentFinishSound",status:t.agentFinishSound?"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"},...process.platform==="win32"?[{label:"Prefer Bash",value:"preferBash",status:t.preferBash!==!1?"ON":"OFF"}]:[],{label:"Cache Calculate Mode",value:"cacheCalculateMode",status:t.cacheCalculateMode||"Session"}];default:return[]}},je=Po[X].id,Gt=ys(je);kd((ce,T)=>{if(me){if(T.tab){ut(k=>k==="search"?"list":"search");return}if(Se==="search"){T.escape?j(!1):T.downArrow||T.return?ut("list"):T.backspace||T.delete?se(k=>k.slice(0,-1)):ce&&!T.ctrl&&!T.meta&&ce.length===1&&se(k=>k+ce);return}if(T.upArrow)ct(k=>{if(We.length===0)return 0;let Me=(k-1+We.length)%We.length,Pe=0;for(;We[Me]?.isHeader&&Pe<We.length;)Me=(Me-1+We.length)%We.length,Pe++;return Me});else if(T.downArrow)ct(k=>{if(We.length===0)return 0;let Me=(k+1)%We.length,Pe=0;for(;We[Me]?.isHeader&&Pe<We.length;)Me=(Me+1)%We.length,Pe++;return Me});else if(T.return){let k=We[Tt];if(k&&!k.isHeader){let Me=k.value==="Default";Ye==="autoCompletion"?A(Pe=>{let at=Me?"":k.provider||"",dt={...Pe,model:k.value,provider:at,baseUrl:Me?"":Pl[at]||""};return p({autoCompletion:dt,apiTier:d,quotas:r}),dt}):g(Pe=>{let at={...Pe,CustomSubAgent:!Me,SubAgentModel:k.value,SubAgentProvider:Me?"":k.provider||""};return p({systemSettings:at,apiTier:d,quotas:r}),at}),j(!1)}}else T.escape?j(!1):ce&&!T.ctrl&&!T.meta&&ce.length===1&&(se(k=>k+ce),ut("search"));return}if(Le){if(T.upArrow){let k=(re-1+Lo.length)%Lo.length;ge(k)}else if(T.downArrow){let k=(re+1)%Lo.length;ge(k)}else if(T.return){let k=Lo[re];g(Me=>{let Pe={...Me,theme:k};return p({systemSettings:Pe,apiTier:d,quotas:r}),Pe}),_?_():R(!1)}else T.escape&&(_?_():R(!1));return}if(fe){T.escape&&Ne(null);return}if(xe==="categories")T.upArrow?be(k=>(k-1+Po.length)%Po.length):T.downArrow?be(k=>(k+1)%Po.length):T.return||T.rightArrow?Po[X].id==="exit"?S("chat"):(oe("items"),Oe(0)):T.escape&&S("chat");else if(xe==="items"){if(je==="security"&&(T.tab||ce===" ")){Be(k=>k==="Sandbox"?"Other":"Sandbox"),Oe(0);return}if(T.upArrow)Oe(k=>(k-1+Gt.length)%Gt.length);else if(T.downArrow)Oe(k=>(k+1)%Gt.length);else if(T.leftArrow)je==="security"&&Xe==="Other"?(Be("Sandbox"),Oe(0)):oe("categories");else if(T.rightArrow&&je==="security"&&Xe==="Sandbox")Be("Other"),Oe(0);else if(T.escape)oe("categories");else if(T.return){let k=Gt[De];Pr(k)}}});let Pr=ce=>{if(ce.value==="profilePreset"){let T=["Default","Sassy","Friendly","Playful","Efficient","Professional"],k=P?.preset||"Default",Pe=(T.indexOf(k)+1)%T.length,at=T[Pe>=0?Pe:0],dt={...P||{},preset:at};B&&B(dt),p({profileData:dt,systemSettings:t,apiTier:d,quotas:r})}else if(ce.value==="profileNickname")Ne("profileNickname"),Fe(P?.nickname||"");else if(ce.value==="profileInstructions")Ne("profileInstructions"),Fe(P?.instructions||"");else if(ce.value==="memory")g(T=>({...T,memory:!T.memory}));else if(ce.value==="sandboxPreset"){let T=Ma(t),k=["Autonomous","Balanced","Strict"],Pe=(k.indexOf(T)+1)%k.length,at=k[Pe];g(dt=>{let tt={...dt,sandboxPreset:at};return at==="Strict"?(tt.autoExec=!1,tt.allowExternalAccess=!1,tt.networkAccess=!1,tt.autoApproveCommands="",tt.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",tt.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",tt.autoApproveGit=!1):at==="Balanced"?(tt.autoExec=!0,tt.allowExternalAccess=!1,tt.networkAccess=!0,tt.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",tt.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",tt.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",tt.autoApproveGit=!1):at==="Autonomous"&&(tt.autoExec=!0,tt.allowExternalAccess=!0,tt.networkAccess=!0,tt.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",tt.autoDisallowCommands="",tt.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",tt.autoApproveGit=!0),tt})}else if(ce.value==="autoExec")t.autoExec?g(T=>({...T,autoExec:!1,sandboxPreset:"Custom"})):t.allowExternalAccess?S("doubleDanger"):S("autoExecDanger");else if(ce.value==="externalAccess")t.allowExternalAccess?g(T=>({...T,allowExternalAccess:!1,sandboxPreset:"Custom"})):t.autoExec?S("doubleDanger"):S("externalDanger");else if(ce.value==="networkAccess")g(T=>({...T,networkAccess:T.networkAccess===!1,sandboxPreset:"Custom"}));else if(ce.value==="alwaysAsk")Ne("alwaysAskCommands"),Fe(t.alwaysAskCommands||"");else if(ce.value==="alwaysAskFiles")Ne("alwaysAskFiles"),Fe(t.alwaysAskFiles||".env, .env.*, *.env");else if(ce.value==="autoApprove")Ne("autoApproveCommands"),Fe(t.autoApproveCommands||"");else if(ce.value==="autoDisallow")Ne("autoDisallowCommands"),Fe(t.autoDisallowCommands||"");else if(ce.value==="autoApproveGit")g(T=>({...T,autoApproveGit:!T.autoApproveGit,sandboxPreset:"Custom"}));else if(ce.value==="customOpenAIBaseUrl")Ne("customOpenAIBaseUrl"),Fe(t.customOpenAIBaseUrl||"");else if(ce.value==="customOpenAIKey")Ne("customOpenAIKey"),Fe("");else if(ce.value==="ollamaEndpoint")g(T=>{let k=T.ollamaEndpoint==="Local"?"Cloud":"Local",Me={...T,ollamaEndpoint:k};return p({systemSettings:Me,apiTier:d,quotas:r}),Me});else if(ce.value==="apiTier")S("apiTier");else if(ce.value==="aiProvider")G&&G("settings"),S("selectProvider");else if(ce.value==="advanceRollback")t.advanceRollback?g(T=>{let k={...T,advanceRollback:!1};return p({systemSettings:k,apiTier:d,quotas:r}),k}):S("advanceRollbackDanger");else if(ce.value==="autoDelete"){let T=["1d","7d","30d"],Me=(T.indexOf(t.autoDeleteHistory||"30d")+1)%T.length;g(Pe=>({...Pe,autoDeleteHistory:T[Me]}))}else if(ce.value==="autoUpdate")g(T=>({...T,autoUpdate:!T.autoUpdate}));else if(ce.value==="externalData")if(!t.useExternalData)w({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||""}),S("input");else{let T={...t,useExternalData:!1};g(T),p({systemSettings:T,apiTier:d,quotas:r}),y(k=>[...k,{id:Date.now(),role:"system",text:"[STORAGE RESET] Flux Flow will return to default ~/.fluxflow after restart."}]),S("chat")}else if(ce.value==="updateManager")S("updateManager");else if(ce.value==="parserDownload")S("parserDownload");else if(ce.value==="indentationTree")g(T=>{let k={...T,indentationTree:T.indentationTree===!1};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="compressToolResults")g(T=>{let k={...T,compressToolResults:!T.compressToolResults};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="autoTruncateResults")g(T=>{let k={...T,autoTruncateResults:!T.autoTruncateResults};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="agentFinishSound")g(T=>{let k={...T,agentFinishSound:!T.agentFinishSound};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="imageHistoryCU"){let T=["Low","Standard","Extended","Max"],Me=(T.indexOf(t.imageHistoryCU||"Standard")+1)%T.length;g(Pe=>{let at={...Pe,imageHistoryCU:T[Me]};return p({systemSettings:at,apiTier:d,quotas:r}),at})}else if(ce.value==="contextLength"){let T=["16k","32k","64k","128k","256k","512k","1M"],Me=(T.indexOf(t.contextLength||"256k")+1)%T.length;g(Pe=>{let at={...Pe,contextLength:T[Me]};return p({systemSettings:at,apiTier:d,quotas:r}),at})}else if(ce.value==="keepReasoningContext")g(T=>{let k={...T,keepReasoningContext:!T.keepReasoningContext};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="autoExcludeMetadata")g(T=>{let k={...T,autoExcludeMetadata:!T.autoExcludeMetadata};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="disableTodo")g(T=>{let k={...T,disableTodo:!T.disableTodo};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="preferBash")g(T=>{let k=T.preferBash!==!1,Me={...T,preferBash:!k};return p({systemSettings:Me,apiTier:d,quotas:r}),Me});else if(ce.value==="cacheCalculateMode"){let T=["Session","Current"],Me=(T.indexOf(t.cacheCalculateMode||"Session")+1)%T.length;g(Pe=>{let at={...Pe,cacheCalculateMode:T[Me]};return p({systemSettings:at,apiTier:d,quotas:r}),at})}else if(ce.value==="subAgents")g(T=>{let k={...T,subAgents:T.subAgents===!1};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="subAgentModel"){let T=t.CustomSubAgent&&t.SubAgentModel?t.SubAgentModel:"Default",k=We.findIndex(Me=>Me.value===T);ct(k>=0?k:0),ot("subAgent"),j(!0)}else if(ce.value==="autoCompletionEnabled")A(T=>{let k={...T,enabled:!T.enabled};return p({autoCompletion:k,apiTier:d,quotas:r}),k});else if(ce.value==="clipboardContext")g(T=>{let k={...T,clipboardContext:!T.clipboardContext};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="autoCompletionModel"){let T=C?.model||"Default",k=We.findIndex(Me=>Me.value===T);ct(k>=0?k:0),ot("autoCompletion"),j(!0)}else if(ce.value==="preserveThinking")g(T=>{let k={...T,preserveThinking:T.preserveThinking===!1};return fa(k.preserveThinking),p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="loadingPhrases")g(T=>{let k={...T,loadingPhrases:T.loadingPhrases===!1};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="progressiveRendering")g(T=>{let k={...T,progressiveRendering:!T.progressiveRendering};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="showTPMEstimate")g(T=>{let k={...T,showTPMEstimate:!T.showTPMEstimate};return p({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="theme"){let T=t.theme==="Chaos"||t.theme==="Mystery"?"Mystery":t.theme||"Dark",k=Lo.indexOf(T);ge(k>=0?k:0),ie(t.theme||"Dark"),R(!0)}},Ce=xt(t.theme);if(me){let ce=Ye==="autoCompletion"?C?.model||"Default":t.CustomSubAgent&&t.SubAgentModel?t.SubAgentModel:"Default",T=15,k=wt;Tt<k?k=Tt:Tt>=k+T&&(k=Tt-T+1),k=Math.max(0,Math.min(k,Math.max(0,We.length-T))),k!==wt&&st(k);let Me=We.slice(k,k+T);return D.createElement($e,{flexDirection:"column",borderStyle:"round",borderColor:Ce.border,padding:1,width:"100%",minHeight:32},D.createElement($e,{marginBottom:1,flexDirection:"row",justifyContent:"space-between"},D.createElement(Z,{color:Ce.text,bold:!0,underline:!0},Ye==="autoCompletion"?"Select Auto-Completion Model:":"Select Sub-Agent Model:"),We.length>0&&D.createElement(Z,{color:"gray"},Tt+1,"/",We.length)),D.createElement($e,{borderStyle:"single",borderColor:Se==="search"?Ce.primary||"cyan":"gray",paddingX:1,marginBottom:1},D.createElement(Z,{color:Se==="search"?Ce.primary||"cyan":"gray",bold:!0},"\u{1F50D} Search: "," "),D.createElement(Z,{color:Ce.text},qe),Se==="search"&&D.createElement(Z,{color:Ce.primary||"cyan"},"\u2588"),!qe&&Se!=="search"&&D.createElement(Z,{color:"gray",italic:!0},"(Press TAB or type to filter models...)")),D.createElement($e,{flexDirection:"column",flexGrow:1,height:T},Me.length>0?Me.map((Pe,at)=>{let dt=k+at;if(Pe.isHeader)return D.createElement($e,{key:`hdr-${dt}`,paddingX:1},D.createElement(Z,{color:"gray",bold:!0,underline:!0},Pe.label));let tt=Tt===dt&&Se==="list",ro=ce===Pe.value;return D.createElement($e,{key:`item-${Pe.value}-${dt}`,paddingX:1,backgroundColor:tt?Ce.highlightBg:void 0},D.createElement(Z,{color:tt?Ce.text:Ce.textDim,bold:tt},tt?"\u276F ":" ",Pe.label,ro?D.createElement(Z,{color:Ce.primary||"cyan",italic:!0}," (active)"):""))}):D.createElement($e,{paddingX:1},D.createElement(Z,{color:"gray",italic:!0},'No models matching "',qe,'"'))),D.createElement($e,{paddingX:1,marginTop:1,flexDirection:"row",justifyContent:"space-between"},D.createElement(Z,{color:"gray",italic:!0},"TAB to switch search/list \u2022 \u25B2\u25BC Navigate \u2022 ENTER to Select \u2022 ESC to Cancel"),D.createElement(Z,{color:Se==="search"?Ce.primary||"cyan":"gray",bold:!0},"[",Se.toUpperCase()," MODE]")))}if(Le){let ce=Lo[re],T=xt(ce);return D.createElement($e,{flexDirection:"column",borderStyle:"round",borderColor:T.border,padding:1,width:"100%",minHeight:32},D.createElement($e,{marginBottom:1},D.createElement(Z,{color:T.text,bold:!0},"Choose your color scheme:")),D.createElement($e,{flexDirection:"row",width:"100%",flexGrow:1},D.createElement($e,{flexDirection:"column",width:"30%",paddingRight:1},Lo.map((k,Me)=>{let Pe=re===Me,at=(t.theme||"Dark")===k,dt=k==="Forest Sprite"||k==="Spookfest";return D.createElement($e,{key:k,paddingX:0},D.createElement(Z,{color:Pe?T.text:T.textDim,bold:Pe},Pe?"> ":" ",k,dt&&D.createElement(Z,{color:Pe?T.success||"#52b788":"green",bold:!0}," \u2605"),at?D.createElement(Z,{color:T.primary||"cyan",italic:!0}," (saved)"):""))})),D.createElement($e,{flexDirection:"column",flexGrow:1,borderStyle:"round",borderColor:T.borderMuted,paddingX:2,paddingY:1,backgroundColor:T.cardBg},D.createElement($e,{marginBottom:1},D.createElement(Z,{color:T.secondary||"cyan",bold:!0},"> ","you: "),D.createElement(Z,{color:T.text},"add a greeting function")),D.createElement($e,{marginBottom:1},D.createElement(Z,{color:T.success||"green"}," Here's the change:")),D.createElement($e,{flexDirection:"column",marginLeft:2,marginBottom:1},D.createElement(Z,null,D.createElement(Z,{color:T.textDim},"3 "),vt(' import "fmt"',".go",void 0)),D.createElement(Z,{color:T.textDim},"4"),D.createElement($e,{backgroundColor:T.diffRemovalBg},D.createElement(Z,null,D.createElement(Z,{color:T.diffRemovalNum||T.diffRemovalText},"5 "),D.createElement(Z,{color:T.diffRemovalPrefix||T.diffRemovalText},"- "),vt("func ",".go",void 0),vt("main()",".go",void 0,T.diffRemovalHighlightBg),vt(" {",".go",void 0))),D.createElement($e,{backgroundColor:T.diffAdditionBg},D.createElement(Z,null,D.createElement(Z,{color:T.diffAdditionNum||T.diffAdditionText},"5 "),D.createElement(Z,{color:T.diffAdditionPrefix||T.diffAdditionText},"+ "),vt("func ",".go",void 0),vt("greet(name string)",".go",void 0,T.diffAdditionHighlightBg),vt(" {",".go",void 0))),D.createElement($e,{backgroundColor:T.diffAdditionBg},D.createElement(Z,null,D.createElement(Z,{color:T.diffAdditionNum||T.diffAdditionText},"6 "),D.createElement(Z,{color:T.diffAdditionPrefix||T.diffAdditionText},"+ "),D.createElement(Z,null," "),vt('fmt.Printf("Hello, %s!\\n", name)',".go",void 0,T.diffAdditionHighlightBg))),D.createElement(Z,null,"7 }")),D.createElement($e,{flexDirection:"column",marginTop:1,marginBottom:1},D.createElement(Z,{color:T.textDim},"\u25BE Thought Process"),D.createElement(Z,{color:T.textMuted}," I need to add a greeting function. I'll use fmt.Printf.")),D.createElement($e,{flexDirection:"column"},D.createElement(Z,null,D.createElement(Z,{color:T.warning||"yellow"},"\u2699 tool: "),D.createElement(Z,{color:T.text},"write_file main.go")),D.createElement(Z,null,D.createElement(Z,{color:T.accent||"magenta"},"\u29BF task: "),D.createElement(Z,{color:T.text},"Implementing greeting")),D.createElement(Z,null,D.createElement(Z,{color:T.danger||"red"},"X error: "),D.createElement(Z,{color:T.text},"compilation failed")),D.createElement(Z,null,D.createElement(Z,{color:T.warning||"yellow"},"\u26A0 warning: "),D.createElement(Z,{color:T.text},"deprecation warning")),D.createElement(Z,null,D.createElement(Z,{color:T.info||"blue"},"\u2192 link: "),D.createElement(Z,{color:T.info||"blue",underline:!0},"file:///path/to/main.go")),D.createElement(Z,null,D.createElement(Z,{color:T.accent||"magenta"},"\u2605 accent: "),D.createElement(Z,{color:T.text},"highlighted text")),D.createElement(Z,{color:T.textDim},"\xB7 dim: press Enter to continue")))),D.createElement($e,{paddingX:1,marginTop:1,flexDirection:"row",justifyContent:"space-between"},D.createElement(Z,{color:"gray",italic:!0},"\u25B2\u25BC Navigate \u2022 ENTER to Select \u2022 ESC to Cancel"),D.createElement(Z,{color:"gray"},"Previewing: ",Lo[re],Lo[re]==="Forest Sprite"?" \u2605":"")))}return D.createElement($e,{flexDirection:"column",borderStyle:"round",borderColor:Ce.border,padding:0,width:"100%",minHeight:26},D.createElement($e,{paddingX:1,paddingY:0,marginBottom:0,borderStyle:"single",borderColor:Ce.borderMuted,width:"100%"},D.createElement(Z,{color:Ce.text,bold:!0},"SYSTEM CONFIGURATION")),D.createElement($e,{flexDirection:"row",width:"100%",minHeight:20},D.createElement($e,{flexDirection:"column",width:"30%",maxWidth:40,borderStyle:"round",borderColor:xe==="categories"?Ce.border:Ce.borderMuted,padding:1,paddingY:0},D.createElement($e,{marginBottom:1},D.createElement(Z,{color:xe==="categories"?Ce.text:Ce.textDim,bold:!0,underline:!0},"CATEGORIES")),Po.map((ce,T)=>{let k=X===T,Me=ce.id==="exit";return D.createElement($e,{key:ce.id,marginTop:Me?9:0,backgroundColor:k?xe==="categories"?Ce.highlightBg:Ce.cardBg:void 0,paddingX:1},D.createElement(Z,{color:k&&xe==="categories"?Ce.text:Ce.textDim,bold:k},k?"\u276F ":" ",ce.label))})),D.createElement($e,{flexDirection:"column",flexGrow:1,borderStyle:"round",borderColor:xe==="items"?Ce.border:Ce.borderMuted,paddingX:1,marginLeft:1,paddingY:0},D.createElement($e,{marginBottom:1,flexDirection:"row",justifyContent:"space-between",alignItems:"center"},D.createElement(Z,{color:xe==="items"?Ce.text:Ce.textDim,bold:!0,underline:!0},Po[X].label.toUpperCase().includes("EXIT")?"Runtime Information":`${Po[X].label} Settings`),je==="security"&&D.createElement($e,{flexDirection:"row"},D.createElement($e,{paddingX:1,backgroundColor:Xe==="Sandbox"?xe==="items"?Ce.highlightBg:Ce.cardBg:void 0},D.createElement(Z,{bold:Xe==="Sandbox",color:Xe==="Sandbox"?Ce.primary||"cyan":Ce.textDim},"[ Sandbox ]")),D.createElement($e,{paddingX:1,backgroundColor:Xe==="Other"?xe==="items"?Ce.highlightBg:Ce.cardBg:void 0},D.createElement(Z,{bold:Xe==="Other",color:Xe==="Other"?Ce.primary||"cyan":Ce.textDim},"[ Others ]")))),Gt.length>0?(()=>{let ce=null,T=[],k=Ke=>(Ke||"").split(",").map(Pt=>Pt.trim().toLowerCase()).filter(Boolean),Me=k(t.autoApproveCommands),Pe=k(t.autoDisallowCommands),at=k(t.alwaysAskCommands),dt=[...Me,...Pe,...at],tt=new Set(dt),ro=je==="security"&&dt.length!==tt.size;return Gt.forEach((Ke,Pt)=>{let mn=xe==="items"&&De===Pt,xn=Ke.label.length,Cs=Math.max(2,38-xn),St=".".repeat(Cs),ne=ze=>je==="security"?(ze.value==="autoExec"||ze.value==="externalAccess")&&ze.status==="ON"?Ce.statusOn:Ce.statusOff:ze.status?.startsWith("\u2713")?Ce.statusOn:ze.status?.startsWith("\u26A0")?Ce.statusOff:ze.status==="ON"?Ce.statusOn:ze.status==="OFF"?Ce.statusOff:Ce.text;Ke.section&&Ke.section!==ce&&je!=="security"&&(ce=Ke.section,T.push(D.createElement($e,{key:`sec-hdr-${Ke.section}`,marginTop:T.length>0?1:0,marginBottom:0,paddingX:1},D.createElement(Z,{color:"gray",bold:!0,underline:!0},Ke.section.toUpperCase()))));let In=mn&&fe&&(fe==="alwaysAskCommands"&&Ke.value==="alwaysAsk"||fe==="alwaysAskFiles"&&Ke.value==="alwaysAskFiles"||fe==="autoApproveCommands"&&Ke.value==="autoApprove"||fe==="autoDisallowCommands"&&Ke.value==="autoDisallow"||fe==="customOpenAIBaseUrl"&&Ke.value==="customOpenAIBaseUrl"||fe==="customOpenAIKey"&&Ke.value==="customOpenAIKey"||fe==="profileNickname"&&Ke.value==="profileNickname"||fe==="profileInstructions"&&Ke.value==="profileInstructions"),Or=Ke.value==="alwaysAsk"||Ke.value==="alwaysAskFiles"||Ke.value==="autoApprove"||Ke.value==="autoDisallow"||Ke.value==="profileInstructions",Nr=Ke.value==="parserDownload";T.push(D.createElement($e,{key:Ke.value,flexDirection:"column"},D.createElement($e,{backgroundColor:mn&&!In?Ce.highlightBg:void 0,paddingX:2},D.createElement(Z,{color:mn?Ce.text:Ce.textDim,bold:mn},mn?"\u276F ":" ",Ke.label),!Or&&!Nr&&D.createElement(D.Fragment,null,D.createElement(Z,{color:"gray"},St),D.createElement(Z,{color:ne(Ke),bold:!0},Ke.value==="aiProvider"?Ke.status:`[ ${Ke.status} ]`))),Or&&!In&&Ke.status!=="None"&&D.createElement($e,{paddingX:4,marginBottom:1},D.createElement(Z,{color:"gray"},"\u21B3 ",Ke.status)),In&&D.createElement($e,{flexDirection:"column",marginLeft:4,marginBottom:1},D.createElement($e,{paddingX:1,borderStyle:"single",borderColor:"gray",flexDirection:"row"},D.createElement(Z,{color:"gray",bold:!0},"> "," "),D.createElement(Ad,{value:Mt,onChange:ze=>{let Ht=fe==="profileNickname"?20:fe==="profileInstructions"?250:1/0;Fe(ze.slice(0,Ht))},onSubmit:async ze=>{if(fe==="customOpenAIBaseUrl"){let Ht=ze.trim().replace(/\/+$/,""),Ie={...t,customOpenAIBaseUrl:Ht};g(Ie),p({systemSettings:Ie,apiTier:d,quotas:r})}else if(fe==="customOpenAIKey"){let{saveProviderAPIKey:Ht}=await import("./secrets-HSGGFVG5.js");await Ht("c_openai",ze.trim()),_e(Ie=>({...Ie,c_openai:!!ze.trim()})),b==="c_openai"&&($&&$(ze.trim()),z&&z(ze.trim(),{aiProvider:"c_openai"}))}else if(fe==="profileNickname"){let Ht=ze.trim().slice(0,20),Ie={...P||{},nickname:Ht};B&&B(Ie),p({profileData:Ie,systemSettings:t,apiTier:d,quotas:r})}else if(fe==="profileInstructions"){let Ht=ze.trim().slice(0,250),Ie={...P||{},instructions:Ht};B&&B(Ie),p({profileData:Ie,systemSettings:t,apiTier:d,quotas:r})}else{let Ht={...t,[fe]:ze.trim(),sandboxPreset:"Custom"};g(Ht),p({systemSettings:Ht,apiTier:d,quotas:r})}Ne(null)}})),D.createElement(Z,{color:"gray",italic:!0}," ",fe==="customOpenAIBaseUrl"?"Enter Base URL (.../v1) \u2022 Press Enter to save, Esc to cancel":fe==="customOpenAIKey"?"Enter API Key \u2022 Press Enter to save, Esc to cancel":fe==="profileNickname"?`Enter Nickname (${Mt.length}/20) \u2022 Press Enter to save, Esc to cancel`:fe==="profileInstructions"?`Enter Custom Instructions (${Mt.length}/250) \u2022 Press Enter to save, Esc to cancel`:"Comma separated \u2022 Press Enter to save, Esc to cancel"))))}),ro&&T.push(D.createElement($e,{key:"conflict-warning",marginTop:1,paddingX:1},D.createElement(Z,{color:Ce.text,italic:!0},"* Conflicting commands will be ignored and defaulted to highest priority"))),T})():D.createElement($e,{paddingX:1,flexDirection:"column",width:"100%"},je==="exit"?D.createElement(D.Fragment,null,D.createElement($e,{flexDirection:"column",marginBottom:1},D.createElement($e,{flexDirection:"row"},D.createElement(Z,{color:Ce.textDim},"OS"," "),D.createElement(Z,{color:"gray"},"..................... "),D.createElement(Z,{color:Ce.text},process.env.OS||process.platform||"N/A")),D.createElement($e,{flexDirection:"row"},D.createElement(Z,{color:Ce.textDim},"Computer Name"," "),D.createElement(Z,{color:"gray"},".......... "),D.createElement(Z,{color:Ce.text},process.env.COMPUTERNAME||process.env.HOSTNAME||"N/A")),D.createElement($e,{flexDirection:"row"},D.createElement(Z,{color:Ce.textDim},"Processor Count"," "),D.createElement(Z,{color:"gray"},"........ "),D.createElement(Z,{color:Ce.text},process.env.NUMBER_OF_PROCESSORS||"N/A")),D.createElement($e,{flexDirection:"row"},D.createElement(Z,{color:Ce.textDim},"Node.js Version"," "),D.createElement(Z,{color:"gray"},"........ "),D.createElement(Z,{color:Ce.text},"v",process.versions.node)),D.createElement($e,{flexDirection:"row"},D.createElement(Z,{color:Ce.textDim},"V8 Version"," "),D.createElement(Z,{color:"gray"},"...... ...... "),D.createElement(Z,{color:Ce.text},"v",process.versions.v8)),D.createElement($e,{flexDirection:"row"},D.createElement(Z,{color:Ce.textDim},"Data Directory"," "),D.createElement(Z,{color:"gray"},"......... "),So===ko?"":D.createElement(Z,{color:Ce.text},So.replaceAll(Ca.homedir(),"~").replaceAll("\\\\","/").replaceAll("\\","/"),", "),D.createElement(Z,{color:Ce.text},ko.replaceAll(Ca.homedir(),"~").replaceAll("\\\\","/").replaceAll("\\","/"))),D.createElement($e,{flexDirection:"row"},D.createElement(Z,{color:Ce.textDim},"Viewport"," "),D.createElement(Z,{color:"gray"},"............... "),D.createElement(Z,{color:Ce.text},process.stdout.rows||"?"," rows \xD7 ",process.stdout.columns||"?"," cols ",process.stdout.columns<90?"(too small width)":"")),D.createElement($e,{flexDirection:"row",marginBottom:0},D.createElement(Z,{color:Ce.textDim},"Memory Load"," "),D.createElement(Z,{color:"gray"},"............ "),D.createElement(Z,{color:Ce.text},no,"/",zo," ",Ar))),D.createElement($e,{key:"pty-notice",paddingX:0,marginTop:0},D.createElement(Z,{color:Lr?Ce.statusOn:Ce.warning},Lr?"\u2713 Advance Interactive Terminal Supported":"\u26A0 Interactive Terminal is Limited"))):D.createElement(Z,{color:"gray",italic:!0},Po[X].desc)))),D.createElement($e,{paddingX:1,marginTop:0,flexDirection:"row",justifyContent:"space-between"},D.createElement(Z,{color:"gray",italic:!0},xe==="categories"?"\u25B2\u25BC Select Category \u2022 Enter/\u25BA to configure":je==="security"?"\u25B2\u25BC Select Option \u2022 TAB/\u25C4\u25BA Switch Tab \u2022 Enter to Edit/Toggle \u2022 ESC to go back":"\u25B2\u25BC Select Option \u2022 Enter to Toggle \u2022 \u25C4/ESC to go back"),xe==="categories"&&D.createElement(Z,{color:"gray"},Po[X].desc)))}import Ut,{useState as ui}from"react";import{Box as fo,Text as rn,useInput as Pd}from"ink";import Od from"ink-text-input";var Nd=({question:t,options:g,onResolve:d,theme:S="Dark"})=>{let w=xt(S),[p,r]=ui(!1),[y,b]=ui(""),[C,A]=ui(0),P=!1,B=[],L=Array.isArray(g)&&g.length>0,_=t==="Agent has been running for a long time. Do you want to continue execution?";try{_&&L?B=[...g]:B=[...L?g:[],L?{id:"CUSTOM",label:"Suggest something else...",description:"Provide a custom response"}:{id:"CUSTOM",label:"Your Answer",description:""}]}catch{P=!0}Pd(($,z)=>{if(!p&&((z.leftArrow||z.upArrow)&&A(Y=>Math.max(0,Y-1)),(z.rightArrow||z.downArrow)&&A(Y=>Math.min(B.length-1,Y+1)),z.return)){let Y=B[C];Y?.id==="CUSTOM"?r(!0):d(P?"Selected Nothing":Y.label)}});let G=yt(2);return p?Ut.createElement(fo,{flexDirection:"column",borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,backgroundColor:w.codeBg,width:"100%"},Ut.createElement(fo,{paddingX:1},Ut.createElement(rn,{color:w.text,bold:!0},"SUGGEST SOMETHING")),Ut.createElement(fo,{marginTop:1,paddingX:1},Ut.createElement(rn,{italic:!0,color:w.textMuted},"Replying to: ",t)),Ut.createElement(fo,{marginTop:1,paddingX:1,flexDirection:"row"},Ut.createElement(Od,{value:y,onChange:b,onSubmit:()=>d(y)})),Ut.createElement(fo,{marginTop:1,paddingX:1,marginBottom:1},Ut.createElement(rn,{color:w.textMuted,italic:!0},"(Press Enter to send)"))):Ut.createElement(fo,{flexDirection:"column",border:!0,borderStyle:"round",borderColor:w.codeBorder,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,marginY:1,marginRight:1,width:"100%"},Ut.createElement(fo,{paddingX:1,marginBottom:1},Ut.createElement(rn,{color:"yellow",bold:!0},_?"TURN SAFETY SYSTEM: EXECUTION LIMIT":"AGENT REQUEST: ACTION REQUIRED")),Ut.createElement(fo,{paddingX:1,marginBottom:1},Ut.createElement(rn,{color:w.text},t)),Ut.createElement(fo,{flexDirection:"column",width:"100%"},B.map(($,z)=>{let Y=z===C;return Ut.createElement(fo,{key:$.id,flexDirection:"column",width:"100%",backgroundColor:Y?w.highlightBg:void 0,paddingX:1,marginBottom:z===B.length-1?0:1},Ut.createElement(rn,{color:Y?w.text:w.textMuted,bold:Y},Y?"\u276F ":" ",$.label),$.description&&Ut.createElement(fo,{marginLeft:4},Ut.createElement(rn,{color:w.textMuted,italic:!0},$.description)))})),Ut.createElement(fo,{paddingX:1,marginTop:1,marginBottom:1},Ut.createElement(rn,{color:w.textMuted,italic:!0},"(Use Arrows to navigate, Enter to confirm)")))},Sa=Nd;import iu from"gradient-string";var Fd=t=>{let g=String(t||"").trim().split(/\s+/).filter(Boolean),d={sub:null,args:[],provider:null,providerBare:!1,index:null,url:null,temp:!1,all:!1,unmask:!1},S=[];for(let w=0;w<g.length;w++){let p=g[w];if(p==="--provider"){let r=g[w+1];r&&!r.startsWith("--")?(d.provider=r,w++):d.providerBare=!0}else if(p==="--index"){let r=g[w+1];r&&/^\d+$/.test(r)&&(d.index=parseInt(r,10)-1,w++)}else if(p==="--url"){let r=g[w+1];r&&!r.startsWith("--")&&(d.url=r,w++)}else p==="--temp"?d.temp=!0:p==="--all"?d.all=!0:p==="--unmask"||p==="--reveal"?d.unmask=!0:p==="--mask"?d.unmask=!1:S.push(p)}return d.sub=S.length?S[0].toLowerCase():null,d.args=S.slice(1),d},va=["\u2726 API KEY MANAGEMENT","\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m /key list [--provider <name>] [--unmask]","\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m /key add <key> [--index <n>] [--provider <name>] [--url <endpoint>]","\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m /key remove [<index>|<key>|--all] [--provider <name>]","\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m /key use <index>|<key> | /key use <key> --temp","\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m /key clean [--provider <name>]","\u2800"],Ba=async(t,g={})=>{let d=Fd(t),S=g.currentProvider||"Google",w=[],p=(b={})=>({lines:w,...b}),r=S;if(d.provider){let b=yl(d.provider);if(!b)return{lines:[`\u2726 Unknown provider: ${d.provider}`]};r=b}let y=d.sub;if(!y)return{lines:va};if(y==="list"){if(d.providerBare){let C=Ml();w.push("\u2726 SAVED API KEYS");for(let A of C)w.push(`- ${A.provider} (${A.hasKeys?A.count:"No Saved Keys"})`);return w.push("\u2800"),p()}let b=await Ll(r,{unmask:d.unmask});return w.push(`\u2726 ${Cl(r)} API KEYS`),w.push(...b),w.push("\u2800"),p()}if(y==="add"||y==="new"){let b=d.args.join(" ").trim();if(!b)return p({promptNewKey:!0});let C=await Dl(r,b,{index:d.index!==null?d.index:void 0,baseUrl:d.url!==null?d.url:void 0});return C.ok?(await Sl(r)===null&&await vl(r,C.index),w.push(`\u2726 Key added to ${r} slot ${C.index+1}.`),d.url!==null&&Js(r)&&w.push(`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Using URL: ${d.url}`),p()):C.full?{lines:[`\u2726 ${C.error}`,"\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Use /key add <key> --index <n> to overwrite a slot."]}:{lines:[`\u2726 Failed to add key: ${C.error}`]}}if(y==="remove"){let b;if(d.all)b=void 0;else if(d.args.length){let A=d.args.join(" ");b=/^\d+$/.test(A)?parseInt(A,10)-1:A}let C=await Il(r,b,{all:d.all});return C.ok?C.all?(w.push(`\u2726 Cleared all keys for ${r}.`),p({promptNewKey:!0})):(w.push(`\u2726 Removed key from ${r} slot ${C.removedIndex+1}.`),C.needsNewKey?(w.push(`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No keys remain for ${r}. Please enter a new key.`),p({promptNewKey:!0})):p()):{lines:[`\u2726 ${C.error}`]}}if(y==="use"){let b=d.args.join(" ").trim();if(!b)return{lines:["\u2726 Usage: /key use <index> | <key> [--temp]"]};if(d.temp)return Bl(r,b),w.push(`\u2726 Temporary key set for ${r} (session only).`),Js(r)&&w.push("\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Will use the current Custom base URL."),p();let C=/^\d+$/.test(b)?parseInt(b,10)-1:b,A=await kl(r,C);return A.ok?(El(r),w.push(`\u2726 ${r} now using slot ${A.index+1}.`),A.switchedBaseUrl&&w.push(`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Switched Base URL to: ${A.switchedBaseUrl}`),p({switchedBaseUrl:A.switchedBaseUrl,switchedKey:A.key})):{lines:[`\u2726 ${A.error}`]}}if(y==="clean"){let b=d.provider?r:null,C=await Al(b);return w.push(b?`\u2726 Compacted ${b} key slots.`:`\u2726 Compacted all key stores (${C.touched} provider(s) touched).`),p()}return{lines:[`\u2726 Unknown subcommand: ${y}`,...va]}};import Ia from"node-notifier";import Yo from"path";import Ea from"fs";import{execSync as $d}from"child_process";import{fileURLToPath as Ud}from"url";var ms=Yo.dirname(Ud(import.meta.url)),Ir=t=>{let g=[Yo.resolve(ms,"../assets",t),Yo.resolve(ms,"../../assets",t),Yo.resolve(ms,"../../src/assets",t),Yo.resolve(process.cwd(),"src/assets",t),Yo.resolve(process.cwd(),"dist/assets",t)];for(let d of g)if(Ea.existsSync(d))return d;return g[0]},Da=Yo.join(process.env.APPDATA,"Microsoft","Windows","Start Menu","Programs","FluxFlow"),_m=Yo.join(Da,"FluxFlow.lnk"),Hm=Yo.resolve(ms,"../../node_modules/node-notifier/vendor/snoreToast/snoretoast-x64.exe"),mi=()=>{if(process.platform==="win32")try{let t=Ir("logo.png"),g=Ir("logo.ico"),S=`
|
|
45
45
|
$key = 'HKCU:\\Software\\Classes\\AppUserModelId\\FluxFlow'
|
|
46
46
|
New-Item -Path $key -Force | Out-Null
|
|
47
47
|
Set-ItemProperty -Path $key -Name 'DisplayName' -Value 'FluxFlow'
|
|
@@ -49,7 +49,7 @@ Set-ItemProperty -Path $key -Name 'IconUri' -Value '${(Ea.existsSync(t)?t:g).rep
|
|
|
49
49
|
Set-ItemProperty -Path $key -Name 'IconBackgroundColor' -Value '00000000'
|
|
50
50
|
Set-ItemProperty -Path $key -Name 'ShowInSettings' -Value 0 -Type DWord -ErrorAction SilentlyContinue
|
|
51
51
|
Remove-Item -Path '${Da.replace(/'/g,"''")}' -Recurse -Force -ErrorAction SilentlyContinue
|
|
52
|
-
`.replace(/\r?\n\s*/g,"; ");$d(`powershell -NoProfile -Command "${S}"`,{stdio:"ignore"})}catch{}},
|
|
52
|
+
`.replace(/\r?\n\s*/g,"; ");$d(`powershell -NoProfile -Command "${S}"`,{stdio:"ignore"})}catch{}},xi=()=>"FluxFlow";var xs=!1,fi=(t="")=>{let g="FluxFlow",d=`Agent finished - ${t||"Session"}`;try{xs||(mi(),xs=!0);let S=process.platform==="win32"?xi():"FluxFlow",w=Ir("logo.png");Ia.notify({title:g,message:d,appID:S,icon:w,contentImage:w,wait:!1})}catch{}},fs=(t="User action required")=>{let g="FluxFlow";try{xs||(mi(),xs=!0);let d=process.platform==="win32"?xi():"FluxFlow",S=Ir("logo.png");Ia.notify({title:g,message:t,appID:d,icon:S,contentImage:S,wait:!1})}catch{}};import Yt,{useState as gi,useEffect as _d}from"react";import{Box as Oo,Text as sn,useInput as Hd}from"ink";function hi({onSelect:t,onDelete:g,onClose:d,theme:S="Dark"}){let w=xt(S),[p,r]=gi({}),[y,b]=gi([]),[C,A]=gi(0);_d(()=>{(async()=>{let $=await Go();r($),b(Object.keys($).sort((z,Y)=>($[Y].updatedAt||0)-($[z].updatedAt||0)))})()},[]),Hd((G,$)=>{if($.escape&&d(),$.upArrow&&A(z=>Math.max(0,z-1)),$.downArrow&&A(z=>Math.min(y.length-1,z+1)),$.return&&y[C]&&t(y[C]),G==="x"&&y[C]){let z=y[C];g(z).then(Y=>{let le=Y||{};r(le);let xe=Object.keys(le).sort((oe,X)=>(le[X]?.updatedAt||0)-(le[oe]?.updatedAt||0));b(xe),A(oe=>Math.max(0,Math.min(xe.length-1,oe)))})}});let P=yt(2),B=15,L=0;if(y.length>B){let G=Math.floor(B/2);L=C-G,L<0?L=0:L+B>y.length&&(L=y.length-B)}let _=y.slice(L,L+B);return Yt.createElement(Oo,{flexDirection:"column",borderStyle:"round",borderColor:w.borderMuted,padding:0,width:"100%"},Yt.createElement(Oo,{paddingX:1,marginBottom:1},Yt.createElement(sn,{color:w.text,bold:!0},"CHAT HISTORY: RESUME CONVERSATION")),y.length===0?Yt.createElement(Oo,{paddingX:2,paddingY:1},Yt.createElement(sn,{italic:!0,color:w.textMuted},"No saved chats found.")):Yt.createElement(Oo,{flexDirection:"column",width:"100%"},L>0&&Yt.createElement(Oo,{paddingX:2,marginBottom:1},Yt.createElement(sn,{color:w.textMuted},"\u25B2 (+",L," more chats above)")),_.map((G,$)=>{let z=p[G],le=L+$===C,xe=Xd(z?.updatedAt);return Yt.createElement(Oo,{key:G,paddingX:1,backgroundColor:le?w.highlightBg:void 0,width:"100%"},Yt.createElement(Oo,{flexGrow:1},Yt.createElement(sn,{color:le?w.text:w.textMuted,bold:le},le?"\u276F ":" ",Tr(z,G),Yt.createElement(sn,{color:w.textMuted}," [",xe," \u2022 ",G,"]"))),le&&Yt.createElement(Oo,{flexShrink:0},Yt.createElement(sn,{color:w.danger,bold:!0},"[X] DELETE ")))}),L+B<y.length&&Yt.createElement(Oo,{paddingX:2,marginTop:1},Yt.createElement(sn,{color:w.textMuted},"\u25BC (+",y.length-(L+B)," more chats below)"))),Yt.createElement(Oo,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:w.borderMuted},Yt.createElement(sn,{color:w.textMuted,italic:!0},"\u2191\u2193 navigate \u2022 Enter select \u2022 x delete \u2022 Esc close")))}function Xd(t){if(!t)return"N/A";let g=new Date(t);if(isNaN(g.getTime()))return"N/A";let d=y=>String(y).padStart(2,"0"),S=d(g.getMonth()+1),w=d(g.getDate()),p=d(g.getHours()),r=d(g.getMinutes());return`${S}-${w} ${p}:${r}`}import _t,{useState as pi,useEffect as Wd}from"react";import{Box as No,Text as Eo,useInput as Gd,useStdout as Kd}from"ink";function bi({onClose:t,theme:g="Dark"}){let d=xt(g),{stdout:S}=Kd(),w=S?.columns||80,[p,r]=pi([]),[y,b]=pi(0),[C,A]=pi(!0),P=()=>{let oe=zr(gr,[]);r(oe);try{let be=Qr(Mn,{}).systemSettings?.memory!==!1;A(be)}catch{A(!0)}};Wd(()=>{P()},[]),Gd((oe,X)=>{if(X.escape&&t(),X.upArrow&&b(be=>Math.max(0,be-1)),X.downArrow&&b(be=>Math.min(p.length-1,be+1)),oe==="x"&&p.length>0){let be=p[y].id,De=p.filter(Oe=>Oe.id!==be);xl(gr,De),r(De),y>=De.length&&De.length>0&&b(De.length-1)}});let B=(oe,X,be)=>{if(!oe)return"";let De=oe.replace(/\[Saved on: .*?\]/g,"").replace(/\\+'/g,"'").trim(),Xe=`${be?"\u276F ":" "}${X+1}. `.length,Be=be?22:2;return De.split(`
|
|
53
53
|
`).map((Ne,Mt)=>{let Fe=Mt===0,Le=Math.max(10,w-4-(Fe?Xe:3)-Be),R=Math.max(10,w-4-3-Be),re=Ne.split(/(\s+)/),ge=[],we="";if(re.forEach(me=>{if(me.length===0)return;let j=ge.length===0?Le:R;we.length+me.length>j?we.trim().length>0?(ge.push(we.trimEnd()),we=me):(ge.push(me.substring(0,j)),we=me.substring(j)):we+=me}),we.trimEnd().length>0&&ge.push(we.trimEnd()),ge.length===0)return"";let ie=ge.join(`
|
|
54
54
|
`);return Fe?ie:" "+ie}).join(`
|
|
55
55
|
`)},L=4*1024*2,_=p.reduce((oe,X)=>oe+(X.memory?.length||0),0),G=Math.min(100,Math.round(_/L*100)),$=12,z=Math.round(G/100*$),Y="\u2588".repeat(z)+"\u2591".repeat(Math.max(0,$-z)),le=()=>G<50?d.textMuted:G<90?d.warning:d.danger,xe=yt(2);return _t.createElement(No,{flexDirection:"column",borderStyle:"round",borderColor:d.borderMuted,padding:0,width:"100%"},_t.createElement(No,{paddingX:1,marginBottom:1,justifyContent:"space-between"},_t.createElement(Eo,{color:d.text,bold:!0},"SAVED MEMORIES"),_t.createElement(No,null,_t.createElement(Eo,{color:d.textMuted},"Vault: "),_t.createElement(Eo,{color:le()},Y),_t.createElement(Eo,{color:d.text,bold:!0}," ",G,"%"))),!C&&p.length>0?_t.createElement(No,{paddingX:2,paddingY:1},_t.createElement(Eo,{italic:!0,color:d.textMuted},"Memory is currently Off...")):p.length===0?_t.createElement(No,{paddingX:2,paddingY:1},_t.createElement(Eo,{italic:!0,color:d.textMuted},C?"Learning...":"Memory not available...")):_t.createElement(No,{flexDirection:"column"},p.map((oe,X)=>{let be=X===y;return _t.createElement(No,{key:oe.id,paddingX:1,backgroundColor:be?d.highlightBg:void 0,width:"100%"},_t.createElement(No,{flexGrow:1},_t.createElement(Eo,{color:be?d.text:d.textMuted,bold:be},be?"\u276F ":" ",X+1,". ",B(oe.memory,X,be))),be&&_t.createElement(No,{flexShrink:0},_t.createElement(Eo,{color:d.textMuted,dimColor:!0}," [",_t.createElement(Eo,{italic:!0},oe.score),"] "),_t.createElement(Eo,{color:d.danger,bold:!0},"[X] WIPE ")))})),_t.createElement(No,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:d.borderMuted},_t.createElement(Eo,{color:d.textMuted,italic:!0},"\u2191\u2193 navigate \u2022 x wipe memory \u2022 Esc close")))}import It,{useState as gs,useEffect as ka}from"react";import{Box as ln,Text as qt}from"ink";import{spawn as Aa}from"child_process";var La=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],Vd=({latest:t,current:g,settings:d,theme:S="Dark",onClose:w,onUpdateSettings:p,onSuccess:r})=>{let y=xt(S),[b,C]=gs("initializing"),[A,P]=gs(""),[B,L]=gs(null),[_,G]=gs(0);if(ka(()=>{let $=setInterval(()=>{G(z=>(z+1)%1e3)},33);return()=>clearInterval($)},[]),ka(()=>{let $;return(async()=>{let Y=d?.updateManager||"npm";if(!d?.updateManager){p();return}let le="";Y==="pnpm"?le=`pnpm add -g fluxflow-cli@${t}`:Y==="bun"?le=`bun add -g fluxflow-cli@${t}`:Y==="yarn"?le=`yarn global add fluxflow-cli@${t}`:Y==="custom"?le=d.customUpdateCommand:le=`npm install -g fluxflow-cli@${t}`,C("downloading"),P(`Running: ${le}...`);let xe=process.platform==="win32",oe=be=>new Promise(De=>{let Oe=xe?be?"powershell.exe":"cmd.exe":process.env.SHELL||"bash",Xe=xe?be?["-NoProfile","-Command",le]:["/c",le]:["-c",le],Be=Ne=>{let Fe=Ne.toString().replace(/\x1B\[[0-?]*[ -/]*[@-~]|\x1B\][^\x07\x1B]*[\x07\x1B]|\b|\x07/g,"").replace(/\r/g,"").trim();Fe&&P(Le=>{let R=Le.split(`
|
|
@@ -57,27 +57,27 @@ Remove-Item -Path '${Da.replace(/'/g,"''")}' -Recurse -Force -ErrorAction Silent
|
|
|
57
57
|
`)):(Le+`
|
|
58
58
|
`+Fe).split(`
|
|
59
59
|
`).slice(-10).join(`
|
|
60
|
-
`)})},fe=xe?Aa(Oe,Xe,{cwd:process.cwd(),env:process.env}):Aa(le,{shell:!0,cwd:process.cwd(),env:process.env});$=fe,fe.stdout.on("data",Be),fe.stderr.on("data",Be),fe.on("close",Ne=>{$=null,De(Ne!==0?{error:`Process exited with code ${Ne}`}:{success:!0})}),fe.on("error",Ne=>{xe&&be&&Ne.code==="ENOENT"?De({retryCmd:!0}):($=null,De({error:Ne.message}))})}),X={};xe?(X=await oe(!0),X.retryCmd&&(X=await oe(!1))):X=await oe(!1),X.error?(L(X.error),C("error")):X.success&&(C("success"),r&&r())})(),()=>{if($)try{typeof $.destroy=="function"?$.destroy():typeof $.kill=="function"&&$.kill()}catch{}}},[]),b==="initializing"||b==="downloading"){let $=La[Math.floor(_/3)%La.length];return It.createElement(ln,{flexDirection:"column",borderStyle:"round",borderColor:y.border,paddingX:2,paddingY:1},It.createElement(ln,null,It.createElement(qt,{color:y.accent||y.primary},$),It.createElement(qt,{marginLeft:1,bold:!0,color:y.text}," Updating Flux Flow to v",t,"...")),It.createElement(ln,{marginTop:1,paddingX:1,borderStyle:"single",borderColor:y.borderMuted},It.createElement(qt,{color:y.textMuted,italic:!0},A||"Preparing environment...")),It.createElement(qt,{marginTop:1,color:y.textDim||y.textMuted},"(Please do not close the terminal)"))}return b==="success"?It.createElement(ln,{flexDirection:"column",borderStyle:"round",borderColor:y.success||y.border,paddingX:2,paddingY:1},It.createElement(qt,{color:y.success||y.text,bold:!0},"\u2705 UPDATE SUCCESSFUL!"),It.createElement(qt,{marginTop:1,color:y.text},"Flux Flow has been updated to ",It.createElement(qt,{color:y.accent||y.primary},"v",t),"."),It.createElement(qt,{marginTop:1,color:y.text,bold:!0},"Please restart your terminal session to apply changes."),It.createElement(ln,{marginTop:1},It.createElement(qt,{color:y.textMuted},"(Press ESC to return to chat)"))):b==="error"?It.createElement(ln,{flexDirection:"column",borderStyle:"round",borderColor:y.danger||y.border,paddingX:2,paddingY:1},It.createElement(qt,{color:y.danger||y.text,bold:!0},"\u274C UPDATE FAILED"),It.createElement(ln,{marginTop:1,paddingX:1,borderStyle:"single",borderColor:y.borderMuted},It.createElement(qt,{color:y.danger||y.text},B)),It.createElement(qt,{marginTop:1,color:y.text,bold:!0},"Possible causes:"),It.createElement(qt,{color:y.textMuted},"\u2022 Missing permissions (Try running as Administrator/Sudo)"),It.createElement(qt,{color:y.textMuted},"\u2022 Package manager (",d?.updateManager,") not found"),It.createElement(qt,{color:y.textMuted},"\u2022 Network failure"),It.createElement(ln,{marginTop:1},It.createElement(qt,{color:y.textDim||y.textMuted},"(Press ESC to return to chat)"))):null},Pa=Vd;import oo,{useState as Oa,useEffect as Yd}from"react";import{Box as an,Text as Qn,useInput as jd}from"ink";var hs=[{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
|
|
60
|
+
`)})},fe=xe?Aa(Oe,Xe,{cwd:process.cwd(),env:process.env}):Aa(le,{shell:!0,cwd:process.cwd(),env:process.env});$=fe,fe.stdout.on("data",Be),fe.stderr.on("data",Be),fe.on("close",Ne=>{$=null,De(Ne!==0?{error:`Process exited with code ${Ne}`}:{success:!0})}),fe.on("error",Ne=>{xe&&be&&Ne.code==="ENOENT"?De({retryCmd:!0}):($=null,De({error:Ne.message}))})}),X={};xe?(X=await oe(!0),X.retryCmd&&(X=await oe(!1))):X=await oe(!1),X.error?(L(X.error),C("error")):X.success&&(C("success"),r&&r())})(),()=>{if($)try{typeof $.destroy=="function"?$.destroy():typeof $.kill=="function"&&$.kill()}catch{}}},[]),b==="initializing"||b==="downloading"){let $=La[Math.floor(_/3)%La.length];return It.createElement(ln,{flexDirection:"column",borderStyle:"round",borderColor:y.border,paddingX:2,paddingY:1},It.createElement(ln,null,It.createElement(qt,{color:y.accent||y.primary},$),It.createElement(qt,{marginLeft:1,bold:!0,color:y.text}," Updating Flux Flow to v",t,"...")),It.createElement(ln,{marginTop:1,paddingX:1,borderStyle:"single",borderColor:y.borderMuted},It.createElement(qt,{color:y.textMuted,italic:!0},A||"Preparing environment...")),It.createElement(qt,{marginTop:1,color:y.textDim||y.textMuted},"(Please do not close the terminal)"))}return b==="success"?It.createElement(ln,{flexDirection:"column",borderStyle:"round",borderColor:y.success||y.border,paddingX:2,paddingY:1},It.createElement(qt,{color:y.success||y.text,bold:!0},"\u2705 UPDATE SUCCESSFUL!"),It.createElement(qt,{marginTop:1,color:y.text},"Flux Flow has been updated to ",It.createElement(qt,{color:y.accent||y.primary},"v",t),"."),It.createElement(qt,{marginTop:1,color:y.text,bold:!0},"Please restart your terminal session to apply changes."),It.createElement(ln,{marginTop:1},It.createElement(qt,{color:y.textMuted},"(Press ESC to return to chat)"))):b==="error"?It.createElement(ln,{flexDirection:"column",borderStyle:"round",borderColor:y.danger||y.border,paddingX:2,paddingY:1},It.createElement(qt,{color:y.danger||y.text,bold:!0},"\u274C UPDATE FAILED"),It.createElement(ln,{marginTop:1,paddingX:1,borderStyle:"single",borderColor:y.borderMuted},It.createElement(qt,{color:y.danger||y.text},B)),It.createElement(qt,{marginTop:1,color:y.text,bold:!0},"Possible causes:"),It.createElement(qt,{color:y.textMuted},"\u2022 Missing permissions (Try running as Administrator/Sudo)"),It.createElement(qt,{color:y.textMuted},"\u2022 Package manager (",d?.updateManager,") not found"),It.createElement(qt,{color:y.textMuted},"\u2022 Network failure"),It.createElement(ln,{marginTop:1},It.createElement(qt,{color:y.textDim||y.textMuted},"(Press ESC to return to chat)"))):null},Pa=Vd;import oo,{useState as Oa,useEffect as Yd}from"react";import{Box as an,Text as Qn,useInput as jd}from"ink";var hs=[{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 wi({onClose:t}){let[g,d]=Oa(0),[S,w]=Oa({});return Yd(()=>{let p={};hs.forEach(r=>{Zl(r.file)?p[r.file]="ready":p[r.file]="idle"}),w(p)},[]),jd(async(p,r)=>{r.escape&&t(),r.upArrow&&d(b=>Math.max(0,b-1)),r.downArrow&&d(b=>Math.min(hs.length-1,b+1));let y=hs[g];if(p==="x"||p==="X"){if(S[y.file]==="downloading")return;try{await Rl(y.file),w(b=>({...b,[y.file]:"idle"}))}catch(b){w(C=>({...C,[y.file]:`error: ${b.message}`}))}}if(r.return){if(S[y.file]==="downloading")return;w(b=>({...b,[y.file]:"downloading"}));try{await Jl(y.file),w(b=>({...b,[y.file]:"ready"}))}catch(b){w(C=>({...C,[y.file]:`error: ${b.message}`}))}}}),oo.createElement(an,{flexDirection:"column",borderStyle:"round",borderColor:"gray",padding:0,width:"100%"},oo.createElement(an,{paddingX:1,marginBottom:1},oo.createElement(Qn,{color:"white",bold:!0},"LANGUAGE PARSER MANAGER")),oo.createElement(an,{flexDirection:"column"},hs.map((p,r)=>{let y=r===g,b=S[p.file]||"idle",C="[ DOWNLOAD ]",A="gray";b==="downloading"?(C="[ DOWNLOADING... ]",A="yellow"):b==="ready"?(C="[ READY ]",A="green"):b.startsWith("error")&&(C=`[ ${b.toUpperCase()} ]`,A="red");let P=`${p.label} (${p.exts.join(", ")})`,B=Math.max(2,45-P.length),L=".".repeat(B);return oo.createElement(an,{key:p.file,paddingX:1,backgroundColor:y?"#2a2a2a":void 0,width:"100%"},oo.createElement(an,null,oo.createElement(Qn,{color:y?"white":"grey",bold:y},y?"\u276F ":" ",p.label," ",oo.createElement(Qn,{dimColor:!0},"(",p.exts.join(", "),")"))),oo.createElement(an,{flexGrow:1},oo.createElement(Qn,{color:"gray",dimColor:!0},L)),oo.createElement(an,{width:20},oo.createElement(Qn,{color:A,bold:!0},C)))})),oo.createElement(an,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:"gray"},oo.createElement(Qn,{color:"grey",italic:!0},"\u2191\u2193 navigate \u2022 Enter download \u2022 x delete \u2022 Esc close")))}import Vt,{useState as qd}from"react";import{Box as Fo,Text as jo,useInput as zd}from"ink";function Ti({prompts:t,onSelect:g,onClose:d,theme:S="Dark"}){let w=xt(S),[p,r]=qd(0);zd((P,B)=>{B.escape&&d(),B.upArrow&&r(L=>Math.max(0,L-1)),B.downArrow&&r(L=>Math.min(t.length-1,L+1)),B.return&&t[p]&&g(t[p].id)});let y=yt(2),b=10,C=0;if(t.length>b){let P=Math.floor(b/2);C=p-P,C<0?C=0:C+b>t.length&&(C=t.length-b)}let A=t.slice(C,C+b);return Vt.createElement(Fo,{flexDirection:"column",borderStyle:"round",borderColor:w.borderMuted,padding:0,width:"100%"},Vt.createElement(Fo,{paddingX:1,marginBottom:1},Vt.createElement(jo,{color:w.text,bold:!0},"CODEBASE TIME TRAVEL: SELECT UNDO POINT")),Vt.createElement(Fo,{paddingX:2,marginBottom:1},Vt.createElement(jo,{color:w.text},"Select a prompt to revert the codebase back to the state ",Vt.createElement(jo,{bold:!0,color:w.secondary||"cyan"},"immediately before")," it was executed:")),t.length===0?Vt.createElement(Fo,{paddingX:2,paddingY:1},Vt.createElement(jo,{italic:!0,color:w.textMuted},"No prompt checkpoints found for this session.")):Vt.createElement(Fo,{flexDirection:"column",width:"100%"},C>0&&Vt.createElement(Fo,{paddingX:2,marginBottom:1},Vt.createElement(jo,{color:w.textMuted},"\u25B2 (+",C," more prompts above)")),A.map((P,B)=>{let _=C+B===p,G=Jd(P.timestamp),$=P.changes?P.changes.length:0;return Vt.createElement(Fo,{key:P.id,paddingX:1,backgroundColor:_?w.highlightBg:void 0,width:"100%"},Vt.createElement(Fo,{flexGrow:1},Vt.createElement(jo,{color:_?w.text:w.textMuted,bold:_},_?"\u276F ":" ",'"',Qd(P.prompt),'"',Vt.createElement(jo,{color:w.textMuted}," [",G," \u2022 ",$," file(s) changed]"))))}),C+b<t.length&&Vt.createElement(Fo,{paddingX:2,marginTop:1},Vt.createElement(jo,{color:w.textMuted},"\u25BC (+",t.length-(C+b)," more prompts below)"))),Vt.createElement(Fo,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:w.borderMuted},Vt.createElement(jo,{color:w.textMuted,italic:!0},"\u2191\u2193 navigate \u2022 Enter select undo point \u2022 Esc close")))}function Qd(t){if(!t)return"";let d=(t.split(`
|
|
61
61
|
`)[0]||"").replace(/@\[(.*?)\]/g,(S,w)=>{let p=w.replace(/\\/g,"/").split("/");return`[${p[p.length-1]}]`});return d.length>69?d.slice(0,67)+"...":t.includes(`
|
|
62
|
-
`)?d+"...":d}function Jd(t){if(!t)return"N/A";let g=new Date(t);if(isNaN(g.getTime()))return"N/A";let d=r=>String(r).padStart(2,"0"),S=d(g.getHours()),w=d(g.getMinutes()),p=d(g.getSeconds());return`${S}:${w}:${p}`}import{exec as Zd}from"child_process";import{promisify as Rd}from"util";import Na from"fs";var Fa=Rd(Zd),$a=async()=>{try{let t=Ql();if(t.executablePath&&Na.existsSync(t.executablePath))return!0;let{default:g}=await import("puppeteer"),d=g.executablePath();if(d&&Na.existsSync(d))return!0}catch{return!1}return!1},Ua=async t=>{t&&t("\u{1F4E5} Downloading Chromium engine (chrome@148)...");try{try{await Fa("pnpm exec puppeteer browsers install chrome@148")}catch{await Fa("npx -y puppeteer browsers install chrome@148")}return await new Promise(g=>setTimeout(g,1e3)),{success:!0}}catch(g){return console.error("[SETUP ERROR]",g),{success:!1,error:g.message}}};import _a,{useState as Ha,useEffect as Xa}from"react";import{Text as Wa}from"ink";var eu=({text:t,baseColor:g="grey",glintColor:d="gray",speed:S=200,glintWidth:w=6,typeSpeed:p=30,...r})=>{let[y,b]=Ha(-w),[C,A]=Ha(t);return Xa(()=>{let P=setInterval(()=>{b(B=>B>C.length+w?-w-40:B+1)},S);return()=>clearInterval(P)},[C.length,S,w]),Xa(()=>{if(t&&(t.includes("Trying to reach")&&C&&C.includes("Trying to reach")||t.includes("Error Occurred")&&C&&C.includes("Error Occurred"))){A(t);return}if(C===t)return;let P=setTimeout(()=>{let B=0,L=Math.min(C.length,t.length);for(;B<L&&C[B]===t[B];)B++;C.length>B?A(_=>_.slice(0,-1)):C.length<t.length&&A(t.slice(0,C.length+1))},p);return()=>clearTimeout(P)},[t,C,p]),_a.createElement(Wa,null,C.split("").map((P,B)=>{let _=Math.abs(B-y)<=w/2?d:g;return _a.createElement(Wa,{key:B,color:_,...r},P)}))},kr=eu;var ps=null,Rn=null,bs=null,ws=null,go=t=>{let g=String(t);return g.startsWith("999")&&g.endsWith("9")},Ti=async()=>{let t=process.env["9ROUTER_URL"]||process.env.NINEROUTER_URL||process.env["9ROUTER_BASE_URL"]||"http://127.0.0.1:20128",g=t;try{let d=new URL(t);g=`${d.protocol}//${d.host}`}catch{g=t.replace(/\/v1(\/chat\/completions)?\/?$/,"")}try{let d=await fetch(g,{method:"GET",signal:AbortSignal.timeout(800)});return{ok:!0,url:g}}catch(d){return{ok:!1,url:g,error:d.message}}},qo=t=>t==null||t===0||go(t)?"":String(t),cn=()=>{let t=(process.env.TERM_PROGRAM||"").toLowerCase(),g=(process.env.VSCODE_CWD||"").toLowerCase(),d=(process.env.VSCODE_CODE_CACHE_PATH||"").toLowerCase(),S=(process.env.GIT_ASKPASS||"").toLowerCase(),w=(process.env.VSCODE_GIT_ASKPASS_NODE||"").toLowerCase(),p=(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||g.includes("antigravity")||d.includes("antigravity")||S.includes("antigravity")||w.includes("antigravity")||p.includes("antigravity")?"Antigravity":t==="cursor"||process.env.CURSOR_SETTINGS_DIR||process.env.CURSOR_CONFIG_DIR||g.includes("cursor")||d.includes("cursor")||S.includes("cursor")||w.includes("cursor")?"Cursor":t==="windsurf"||process.env.WINDSURF_SETTINGS_DIR||g.includes("windsurf")||d.includes("windsurf")||S.includes("windsurf")||w.includes("windsurf")?"Windsurf":t==="trae"||process.env.TRAE_SETTINGS_DIR||g.includes("trae")||w.includes("trae")?"Trae":t==="positron"||g.includes("positron")||w.includes("positron")?"Positron":t==="codium"||t==="vscode-oss"||g.includes("codium")||d.includes("codium")||w.includes("codium")?"VSCodium":t==="vscode-insiders"||g.includes("code - insiders")||d.includes("code - insiders")||w.includes("code - insiders")?"VS Code Insiders":t==="vscode"||process.env.VSCODE_GIT_IPC_HANDLE||process.env.VSCODE_PID||process.env.VSCODE_INJECTION||g.includes("code")||d.includes("code")||w.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"},lu=t=>{switch(t){case"VS Code":return"Code";case"VS Code Insiders":return"Code - Insiders";case"Antigravity":return"Antigravity IDE";default:return t}},Ga={Flux:"Workspace",Flow:"Studio",ICU:"Computer Use",FluxCU:"Omni"},yi=t=>{if(!t)return"Workspace";let g=Object.keys(Ga).find(d=>d.toLowerCase()===t.toLowerCase());return g?Ga[g]:t},Ka=t=>{let g=lu(t),d=Si.homedir();if(process.platform==="win32"){let S=process.env.APPDATA;return S?Ct.join(S,g,"User","keybindings.json"):null}else return process.platform==="darwin"?Ct.join(d,"Library","Application Support",g,"User","keybindings.json"):Ct.join(d,".config",g,"User","keybindings.json")},Va=t=>{let g=t.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,"$1");return JSON.parse(g)},au=t=>Array.isArray(t)?t.some(g=>g&&typeof g.key=="string"&&g.key.toLowerCase().replace(/\s+/g,"")==="shift+enter"&&g.command==="workbench.action.terminal.sendSequence"&&g.args&&g.args.text==="\x1B[13;2u"&&typeof g.when=="string"&&g.when.includes("terminalFocus")):!1,ja=t=>{let g=t==="VS Code",d=[];return g?(d.push({label:"Install Manually (VSIX)",url:"https://github.com/KushalRoyChowdhury/fluxflow-cli/releases"}),d.push({label:"Install from VS Code Marketplace",url:"https://marketplace.visualstudio.com/items?itemName=fluxflow-cli.fluxflow-cli-companion"})):d.push({label:`Download for ${t} (GitHub)`,url:"https://github.com/KushalRoyChowdhury/fluxflow-cli/releases"}),d.push({label:"Continue to CLI only",action:"dismiss"}),d},cu=({width:t,height:g,selectedIndex:d,aiProvider:S,theme:w="Dark"})=>{let p=cn(),r=ja(p);return e.createElement(m,{flexDirection:"column",alignItems:"center",justifyContent:"center",width:t,height:g},e.createElement(m,{marginBottom:1,width:Math.min(80,t-4),justifyContent:"flex-start"},e.createElement(i,null,br(ho,S,w))),e.createElement(m,{flexDirection:"column",borderStyle:"double",borderColor:"grey",paddingX:3,paddingY:1,width:Math.min(80,t-4)},e.createElement(i,{bold:!0,color:"white",textAlign:"center"},"\u{1F680} UPGRADE YOUR WORKFLOW"),e.createElement(m,{marginY:1,flexDirection:"column",alignItems:"left"},e.createElement(i,null,"You're in ",e.createElement(i,{bold:!0,color:"cyan"},p),", but the ",e.createElement(i,{bold:!0,color:"white"},"FluxFlow-CLI Companion")," is not installed."),e.createElement(m,{flexDirection:"column",marginY:1},e.createElement(i,{color:"gray"}," \u2705 Real-time IDE context & Error Resolution"),e.createElement(i,{color:"gray"}," \u2705 Auto-open files created by agent"),e.createElement(i,{color:"gray"}," \u2705 Native DIFFing for AI edits"),e.createElement(i,{color:"gray"}," \u2705 Direct IDE context sharing"),e.createElement(i,{color:"gray"}," \u2705 Surgical Diagnostic Sync"),e.createElement(i,{color:"gray"}," \u2705 Native Right-Click \u276F Chat integration"),e.createElement(i,{color:"gray"}," \u2705 Live Status in IDE"),e.createElement(i,{color:"gray"}," \u2705 Clickable terminal-to-code links"))),e.createElement(m,{flexDirection:"column",marginTop:1},r.map((y,b)=>e.createElement(m,{key:b},e.createElement(i,{color:d===b?"yellow":"white",bold:d===b},d===b?" \u276F ":" ",y.label)))),e.createElement(m,{marginTop:1,alignItems:"center",justifyContent:"center"},e.createElement(i,{dimColor:!0,italic:!0},"(Use arrows to navigate, Enter to select)"))))},du=({width:t,height:g,aiProvider:d,theme:S="Dark",reason:w})=>{let p=cn(),r=w==="version_mismatch";return e.createElement(m,{flexDirection:"column",alignItems:"center",justifyContent:"center",width:t,height:g},e.createElement(m,{marginBottom:1,width:Math.min(80,t-4),justifyContent:"flex-start"},e.createElement(i,null,br(ho,d,S))),e.createElement(m,{flexDirection:"column",borderStyle:"double",paddingX:3,paddingY:1,width:Math.min(80,t-4)},e.createElement(i,{bold:!0,color:"yellow",textAlign:"center"},r?"\u26A0 VERSION MISMATCH":"\u26A0 CWD MISMATCH"),e.createElement(m,{marginY:1,flexDirection:"column",alignItems:"left"},e.createElement(i,null,r?"Your FluxFlow CLI version is not supported by the ":"CWD mismatch from ",!r&&e.createElement(i,{bold:!0,color:"white"},p),!r&&" workspace. ","IDE features aren't available right now."),!r&&e.createElement(m,{marginTop:1},e.createElement(i,{dimColor:!0},"Tip: Launch FluxFlow CLI from the same folder open in ",p,"."))),e.createElement(m,{marginTop:1},e.createElement(i,{color:"yellow",bold:!0}," \u276F Understood")),e.createElement(m,{marginTop:1,alignItems:"center",justifyContent:"center"},e.createElement(i,{dimColor:!0,italic:!0},"(Press Enter to dismiss)"))))},Ci=Date.now(),Ya="https://fluxflow-cli.onrender.com/changelog",Mi="https://fluxflow-cli.onrender.com/",uu=Ct.join(Ct.dirname(su(import.meta.url)),"../package.json"),qa=JSON.parse(pt.readFileSync(uu,"utf8")),ho=qa.version,mu=qa.date||"2026-05-20";var xu=({data:t,onResolve:g,onEdit:d,theme:S="Dark"})=>{let w=xt(S);return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:w.borderMuted,padding:0,width:"100%"},e.createElement(m,{paddingX:1},e.createElement(i,{color:w.text,bold:!0,underline:!0},t.startsWith("/btw")?"QUESTION":"STEERING HINT"," RESOLUTION")),e.createElement(m,{paddingX:1,marginTop:1},e.createElement(i,{color:w.text},"The agent already finished the task before your ",t.startsWith("/btw")?"question":"hint"," was consumed.")),e.createElement(m,{marginTop:1,backgroundColor:w.cardBg||w.codeBg||"#222",paddingX:2,width:"100%"},e.createElement(i,{italic:!0,color:w.textMuted},'"',t.replace("/btw","").trim(),'"')),e.createElement(m,{paddingX:1,marginTop:1},e.createElement(i,{color:w.textDim||w.textMuted},"How would you like to proceed?")),e.createElement(m,{marginTop:0},e.createElement($t,{title:"Select Action",items:[{label:"Send Anyway",value:"send"},{label:"Edit Prompt",value:"edit"}],onSelect:p=>{(typeof p=="object"&&p!==null?p.value:p)==="send"?g(t):d(t)},theme:S})))};var fu=(()=>{let t=null,g=0;return d=>{let S=Date.now();if(t&&S-g<1e4)return t;let w=[],p=r=>{if(!(w.length>=2e3))try{let y=pt.readdirSync(r);for(let b of y){if(w.length>=2e3)return;if(["node_modules",".git",".gemini","dist","build",".next",".cache","out"].includes(b))continue;let C=Ct.join(r,b);pt.statSync(C).isDirectory()?p(C):w.push({name:Xt(b),relativePath:Xt(Ct.relative(process.cwd(),C))})}}catch{}};return p(d),t=w,g=S,w}})(),Ts="Ctrl + Enter",gu=t=>{if(t<=370)return"#00a564";if(t>=5e3)return"#ff0000";let g=[{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 d=0;d<g.length-1;d++){let S=g[d],w=g[d+1];if(t>=S.t&&t<=w.t){let p=(t-S.t)/(w.t-S.t);p=p*p*(3-2*p);let r=Math.round(S.r+(w.r-S.r)*p),y=Math.round(S.g+(w.g-S.g)*p),b=Math.round(S.b+(w.b-S.b)*p);return`#${((1<<24)+(r<<16)+(y<<8)+b).toString(16).slice(1)}`}}return"#ff0000"},hu=e.memo(({sa:t,showTPMEstimate:g=!1})=>{let[d,S]=Q("green"),[w,p]=Q(0),r=Re([]),y=Re(370),b=Re([]),C=Re(t.lastChunkTime);return gt(()=>{C.current=t.lastChunkTime},[t.lastChunkTime]),gt(()=>{if(t.status!=="running"){b.current=[];return}if(t.wps>0){let A=b.current;A.push(t.wps),A.length>3&&A.shift()}},[t.status,t.wps,t.lastChunkTime]),gt(()=>{if(t.status!=="running"){p(0);return}let A=setInterval(()=>{let P=C.current,B=P>0?Date.now()-P:0;if(P>0&&B>=1e3)b.current=[],p(0);else if(P>0&&B>500){b.current.length>0&&b.current.shift();let L=b.current;if(L.length>0){let _=L.reduce((G,$)=>G+$,0);p(Math.round(_/L.length))}else p(0)}else{let L=b.current;if(L.length>0){let _=L.reduce((G,$)=>G+$,0);p(Math.round(_/L.length))}else t.wps>0&&p(Math.round(t.wps))}},750);return()=>clearInterval(A)},[t.status]),gt(()=>{if(t.status!=="running"){r.current=[];return}let A=t.lastChunkTime;if(A>0){let L=r.current;(L.length===0||L[L.length-1]!==A)&&(L.push(A),L.length>10&&L.shift())}let P=()=>{if(!A){S("#00a564");return}let L=r.current,_=0;if(L.length>1){let oe=0;for(let X=1;X<L.length;X++)oe+=L[X]-L[X-1];_=oe/(L.length-1)}let G=Date.now()-A,z=G>=2500,Y=!z&&_>0?Math.min(G,_*3):G,le=Math.max(_,Y),xe=z?.4:.2;y.current=y.current*(1-xe)+le*xe,S(gu(y.current))};P();let B=setInterval(P,100);return()=>clearInterval(B)},[t.status,t.lastChunkTime]),e.createElement(m,{justifyContent:"space-between",width:"100%"},e.createElement(i,{color:"white"}," \u2022 ",t.title," ",e.createElement(i,{color:"white",dimColor:!0},"(",t.id,")")),e.createElement(i,{color:"white"},e.createElement(i,{color:"white",dimColor:!0,bold:!0},t.currentTool||"Active"),!g&&e.createElement(i,{color:d}," \u25CF"),g&&e.createElement(i,{color:"white",dimColor:!0,bold:!0}," ~",w," tok/s")))});function pu({args:t=[]}){let g=Re(1),[d,S]=Q(!1),[w,p]=Q(10),{stdout:r}=ou(),[y,b]=Q(""),[C,A]=Q(0),P=Re([]),[B,L]=Q(-1),_=Re(""),G=Re(null),[$,z]=Q(!1),[Y,le]=Q("Flux"),[xe,oe]=Q(0),[X,be]=Q({columns:r?.columns||80,rows:r?.rows||24}),[De,Oe]=Q(0),[Xe,Be]=Q(!1),[fe,Ne]=Q(!1),[Mt,Fe]=Q(null),[Le,R]=Q(0),re=Re(null),ge=Re(!1),we=Re(0),ie=Re(0),me=Re(null),j=Re(null),Ye=Re(0),[ot,Tt]=Q(0),ct=()=>Tt(n=>n+1),wt=Re([]),st=Re(null),qe=()=>{let n=wt.current;if(n.length>0&&j.current){let o=n.join("");n.length=0,j.current.text=Xt(j.current.text+o),ct()}},se=()=>{if(qe(),j.current){let n=Xt(j.current.text||""),o="";if(j.current.role==="agent"&&n){let f=ra(n);f.inside&&typeof f.startIndex=="number"&&f.startIndex>=0&&(o=n.substring(f.startIndex),n=n.substring(0,f.startIndex))}let c=n;if(j.current.role==="think"&&(c=c.replace(/^\r?\n+/,"").replace(/\r?\n+$/,"")),c.trim().length>0||j.current.role!=="agent"){let f={...j.current,text:c,isStreaming:!1};I(x=>[...x,f]),O(x=>x+1)}o?j.current={id:"agent-"+Date.now(),role:"agent",text:o,isStreaming:!0}:j.current=null}Di.current=0,Ds.current={totalWords:0,startTime:0,wps:0,chunks:[]}},Se=()=>{st.current&&clearInterval(st.current),wt.current=[],st.current=setInterval(()=>{try{let n=wt.current;if(n.length>0&&j.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 c="";for(let f=0;f<o&&n.length>0;f++)c+=n.shift();j.current.text=Xt(j.current.text+c),ct()}}catch{}},80)},ut=async()=>{for(;de.progressiveRendering&&wt.current.length>0;)await new Promise(n=>setTimeout(n,10))},mt=n=>{if(de.progressiveRendering&&st.current){let o=n.trim();if((o.startsWith("[action:")||o.startsWith("[tool:"))&&o.endsWith("]")){wt.current.push(n);return}let f=Ul(n);for(let x of f)wt.current.push(x)}else j.current?j.current.text=Xt(j.current.text+n):j.current={id:"agent-"+Date.now(),role:"agent",text:Xt(n),isStreaming:!0},ct()};gt(()=>{let n=cn(),o=!["Terminal","Windows Terminal"].includes(n)||!!process.env.VSC_TERMINAL_URL,c=setTimeout(()=>{o&&!Bn()&&!re.current&&Ne(!0)},500),f=setInterval(()=>{Bn()&&(Ne(!1),Fe(null),re.current=null,ge.current=!1)},1e3);g.current=Date.now();let x=setInterval(()=>{g.current&&(Date.now()-g.current||0)>3e4&&global.gc&&(async()=>{for(let a=0;a<1;a++)global.gc(),await new Promise(h=>setImmediate(h));g.current=Date.now()})()},3e3);return()=>{clearTimeout(c),clearInterval(f),clearInterval(x)}},[]),gt(()=>{(async()=>{try{let o=await ei(),c=o?.systemSettings||{},f=c.CustomSubAgent,x=c.SubAgentModel;if(!f||!x||x==="Default")return;let v=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","Infron","APInex","xKiro"],M=(te=>{if(!te)return null;let U=te.toLowerCase();return U==="google"?"Google":U==="deepseek"?"DeepSeek":U==="openrouter"?"OpenRouter":U==="nvidia"?"NVIDIA":U==="mistral"?"Mistral":U==="ollama"?"Ollama":U==="inferx"?"InferX":U==="sensenova"?"SenseNova":U==="poolside"?"Poolside":U==="9router"?"9router":U==="aihubmix"||U==="aihub"?"AIHubMix":U==="explabs"||U==="experientiallabs"||U==="experimentallabs"||U==="experiential labs"||U==="experimental labs"||U==="experiential"||U==="experimental"?"ExpLabs":U==="tokenharbor"||U==="token harbor"||U==="token_harbor"||U==="thk"?"TokenHarbor":U==="apinex"||U==="apx"?"APInex":U==="xkiro"||U==="kiro"?"xKiro":U==="infron"?"Infron":null})(u);if(v&&!M){let te=o.aiProvider||F||"Google";I(U=>(O(U.length+1),[...U,{id:"subagent-env-noprov-"+Date.now(),role:"system",text:`[SUBAGENT CONFIG] SUBAGENT_MODEL found in ENV but SUBAGENT_PROVIDER is missing/invalid. Active provider (${te}) will be used.`,isMeta:!0}]))}if(x==="ENV"){v||I(te=>(O(te.length+1),[...te,{id:"subagent-model-noenv-"+Date.now(),role:"system",text:"No SubAgent model is found in ENV, Using Deafult until changed",isMeta:!0}]));return}let N=o.aiProvider||F||"Google",H=o.apiTier||ze||"Free",K=o.quotas||Ie||{},q=new Set;(tn(N,H)||[]).forEach(te=>{let U=typeof te=="string"?te:te.cmd||te.name||te.id||String(te);U&&q.add(U)});for(let te of a)try{if(await on(te,{silent:!0})){let et=K?.providerTiers?.[te]||"Free";(tn(te,et)||[]).forEach(He=>{let Qe=typeof He=="string"?He:He.cmd||He.name||He.id||String(He);Qe&&q.add(Qe)})}}catch{}let ee=q.has(x);v?v!==x&&I(te=>(O(te.length+1),[...te,{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}])):ee||I(te=>(O(te.length+1),[...te,{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 _e=Jn(()=>{let n={};for(let o=0;o<t.length;o++)if(t[o]==="--key"&&t[o+1]){let f=t[o+1];if(n.key=f,f.includes("@")){let x=f.split("@"),v=x[0],u=x[1].toLowerCase();if(["google","deepseek","openrouter","nvidia","mistral","ollama","inferx","sensenova","aihubmix","aihub","poolside","pool","9router","9r","explabs","tokenharbor","token_harbor","thk","infron","apinex","apx","xkiro","kiro"].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==="infron"?a="Infron":u==="apinex"||u==="apx"?a="APInex":(u==="xkiro"||u==="kiro")&&(a="xKiro"),n.key=v,n.provider=a}}}for(let o=0;o<t.length;o++){let c=t[o];if(c==="--key"){o++;continue}if(c==="--model"&&t[o+1])n.model=t[o+1],o++;else if(c==="--memory"&&t[o+1])n.memory=t[o+1].toLowerCase(),o++;else if(c==="--resume"&&t[o+1])n.resume=t[o+1],o++;else if(c==="--package"&&t[o+1]){let f=t[o+1].toLowerCase();["npm","pnpm","yarn","bun"].includes(f)&&(n.package=f),o++}else if(c==="--auto-del"&&t[o+1]){let f=t[o+1].toLowerCase();["1d","7d","30d"].includes(f)&&(n.autoDel=f),o++}else if(c==="--auto-exec"&&t[o+1])n.autoExec=t[o+1].toLowerCase(),o++;else if(c==="--yolo"&&t[o+1])n.autoExec=t[o+1].toLowerCase(),o++;else if(c==="--external-access"&&t[o+1])n.externalAccess=t[o+1].toLowerCase(),o++;else if(c==="--mode"&&t[o+1]){let x=t[o+1].toLowerCase();if(["flux","flow","icu","computer","fluxcu"].includes(x)){let v="Flux";x==="flux"?v="Flux":x==="flow"?v="Flow":x==="icu"||x==="computer"?v="ICU":x==="fluxcu"&&(v="FluxCU"),n.mode=v}o++}else if(c==="--thinking"&&t[o+1]){let x=t[o+1].toLowerCase();if(["fast","low","medium","high","xhigh","standard"].includes(x)){let v="Medium";x==="fast"?v="Fast":x==="low"?v="Low":x==="standard"?v="Standard":x==="medium"?v="Medium":x==="high"?v="High":x==="xhigh"&&(v="xHigh"),n.thinking=v}o++}else if(c==="--provider"&&t[o+1]){let f=t[o+1].toLowerCase();if(["google","deepseek","openrouter","nvidia","mistral","ollama","inferx","sensenova","aihubmix","aihub","poolside","pool","9router","9r","explabs","tokenharbor","token_harbor","thk","infron","apinex","apx","xkiro","kiro"].includes(f)){let x="Google";f==="google"?x="Google":f==="deepseek"?x="DeepSeek":f==="openrouter"?x="OpenRouter":f==="nvidia"?x="NVIDIA":f==="mistral"?x="Mistral":f==="ollama"?x="Ollama":f==="inferx"?x="InferX":f==="sensenova"?x="SenseNova":f==="poolside"||f==="pool"?x="Poolside":f==="9router"||f==="9r"?x="9router":f==="aihubmix"||f==="aihub"?x="AIHubMix":f==="explabs"?x="ExpLabs":f==="tokenharbor"||f==="token_harbor"||f==="thk"?x="TokenHarbor":f==="infron"?x="Infron":f==="apinex"||f==="apx"?x="APInex":(f==="xkiro"||f==="kiro")&&(x="xKiro"),n.provider=x}o++}else(c==="--resume"||c==="-r")&&t[o+1]?(n.resume=t[o+1],o++):c==="--playground"?n.playground=!0:(c==="--original-cwd"||c==="--orginal-cwd")&&t[o+1]&&(n.originalCwd=t[o+1],o++)}return n},[t]),Bt=async(n=!1,o=null)=>{let c=o||de;n&&I(f=>(O(f.length+1),[...f,{id:"check-"+Date.now(),role:"system",text:"\u2726 Checking for updates...",isMeta:!0}]));try{let x=await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json(),v=x["dist-tags"]?.latest,u=x["dist-tags"]?.stable;if(v&&Lr(v),v&&v!==ho){let a=v===u?`v${v}`:`v${v}`;!n&&c.autoUpdate?ne("update"):I(h=>{let M=[...h],N=n?M.length:Math.min(M.length,3);return M.splice(N,0,{id:"update-"+Date.now(),role:"system",text:`A new version (${a}) is here.
|
|
62
|
+
`)?d+"...":d}function Jd(t){if(!t)return"N/A";let g=new Date(t);if(isNaN(g.getTime()))return"N/A";let d=r=>String(r).padStart(2,"0"),S=d(g.getHours()),w=d(g.getMinutes()),p=d(g.getSeconds());return`${S}:${w}:${p}`}import{exec as Zd}from"child_process";import{promisify as Rd}from"util";import Na from"fs";var Fa=Rd(Zd),$a=async()=>{try{let t=Ql();if(t.executablePath&&Na.existsSync(t.executablePath))return!0;let{default:g}=await import("puppeteer"),d=g.executablePath();if(d&&Na.existsSync(d))return!0}catch{return!1}return!1},Ua=async t=>{t&&t("\u{1F4E5} Downloading Chromium engine (chrome@148)...");try{try{await Fa("pnpm exec puppeteer browsers install chrome@148")}catch{await Fa("npx -y puppeteer browsers install chrome@148")}return await new Promise(g=>setTimeout(g,1e3)),{success:!0}}catch(g){return console.error("[SETUP ERROR]",g),{success:!1,error:g.message}}};import _a,{useState as Ha,useEffect as Xa}from"react";import{Text as Wa}from"ink";var eu=({text:t,baseColor:g="grey",glintColor:d="gray",speed:S=200,glintWidth:w=6,typeSpeed:p=30,...r})=>{let[y,b]=Ha(-w),[C,A]=Ha(t);return Xa(()=>{let P=setInterval(()=>{b(B=>B>C.length+w?-w-40:B+1)},S);return()=>clearInterval(P)},[C.length,S,w]),Xa(()=>{if(t&&(t.includes("Trying to reach")&&C&&C.includes("Trying to reach")||t.includes("Error Occurred")&&C&&C.includes("Error Occurred"))){A(t);return}if(C===t)return;let P=setTimeout(()=>{let B=0,L=Math.min(C.length,t.length);for(;B<L&&C[B]===t[B];)B++;C.length>B?A(_=>_.slice(0,-1)):C.length<t.length&&A(t.slice(0,C.length+1))},p);return()=>clearTimeout(P)},[t,C,p]),_a.createElement(Wa,null,C.split("").map((P,B)=>{let _=Math.abs(B-y)<=w/2?d:g;return _a.createElement(Wa,{key:B,color:_,...r},P)}))},kr=eu;var ps=null,Rn=null,bs=null,ws=null,go=t=>{let g=String(t);return g.startsWith("999")&&g.endsWith("9")},yi=async()=>{let t=process.env["9ROUTER_URL"]||process.env.NINEROUTER_URL||process.env["9ROUTER_BASE_URL"]||"http://127.0.0.1:20128",g=t;try{let d=new URL(t);g=`${d.protocol}//${d.host}`}catch{g=t.replace(/\/v1(\/chat\/completions)?\/?$/,"")}try{let d=await fetch(g,{method:"GET",signal:AbortSignal.timeout(800)});return{ok:!0,url:g}}catch(d){return{ok:!1,url:g,error:d.message}}},qo=t=>t==null||t===0||go(t)?"":String(t),cn=()=>{let t=(process.env.TERM_PROGRAM||"").toLowerCase(),g=(process.env.VSCODE_CWD||"").toLowerCase(),d=(process.env.VSCODE_CODE_CACHE_PATH||"").toLowerCase(),S=(process.env.GIT_ASKPASS||"").toLowerCase(),w=(process.env.VSCODE_GIT_ASKPASS_NODE||"").toLowerCase(),p=(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||g.includes("antigravity")||d.includes("antigravity")||S.includes("antigravity")||w.includes("antigravity")||p.includes("antigravity")?"Antigravity":t==="cursor"||process.env.CURSOR_SETTINGS_DIR||process.env.CURSOR_CONFIG_DIR||g.includes("cursor")||d.includes("cursor")||S.includes("cursor")||w.includes("cursor")?"Cursor":t==="windsurf"||process.env.WINDSURF_SETTINGS_DIR||g.includes("windsurf")||d.includes("windsurf")||S.includes("windsurf")||w.includes("windsurf")?"Windsurf":t==="trae"||process.env.TRAE_SETTINGS_DIR||g.includes("trae")||w.includes("trae")?"Trae":t==="positron"||g.includes("positron")||w.includes("positron")?"Positron":t==="codium"||t==="vscode-oss"||g.includes("codium")||d.includes("codium")||w.includes("codium")?"VSCodium":t==="vscode-insiders"||g.includes("code - insiders")||d.includes("code - insiders")||w.includes("code - insiders")?"VS Code Insiders":t==="vscode"||process.env.VSCODE_GIT_IPC_HANDLE||process.env.VSCODE_PID||process.env.VSCODE_INJECTION||g.includes("code")||d.includes("code")||w.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"},lu=t=>{switch(t){case"VS Code":return"Code";case"VS Code Insiders":return"Code - Insiders";case"Antigravity":return"Antigravity IDE";default:return t}},Ga={Flux:"Workspace",Flow:"Studio",ICU:"Computer Use",FluxCU:"Omni"},Ci=t=>{if(!t)return"Workspace";let g=Object.keys(Ga).find(d=>d.toLowerCase()===t.toLowerCase());return g?Ga[g]:t},Ka=t=>{let g=lu(t),d=vi.homedir();if(process.platform==="win32"){let S=process.env.APPDATA;return S?Ct.join(S,g,"User","keybindings.json"):null}else return process.platform==="darwin"?Ct.join(d,"Library","Application Support",g,"User","keybindings.json"):Ct.join(d,".config",g,"User","keybindings.json")},Va=t=>{let g=t.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,"$1");return JSON.parse(g)},au=t=>Array.isArray(t)?t.some(g=>g&&typeof g.key=="string"&&g.key.toLowerCase().replace(/\s+/g,"")==="shift+enter"&&g.command==="workbench.action.terminal.sendSequence"&&g.args&&g.args.text==="\x1B[13;2u"&&typeof g.when=="string"&&g.when.includes("terminalFocus")):!1,ja=t=>{let g=t==="VS Code",d=[];return g?(d.push({label:"Install Manually (VSIX)",url:"https://github.com/KushalRoyChowdhury/fluxflow-cli/releases"}),d.push({label:"Install from VS Code Marketplace",url:"https://marketplace.visualstudio.com/items?itemName=fluxflow-cli.fluxflow-cli-companion"})):d.push({label:`Download for ${t} (GitHub)`,url:"https://github.com/KushalRoyChowdhury/fluxflow-cli/releases"}),d.push({label:"Continue to CLI only",action:"dismiss"}),d},cu=({width:t,height:g,selectedIndex:d,aiProvider:S,theme:w="Dark"})=>{let p=cn(),r=ja(p);return e.createElement(m,{flexDirection:"column",alignItems:"center",justifyContent:"center",width:t,height:g},e.createElement(m,{marginBottom:1,width:Math.min(80,t-4),justifyContent:"flex-start"},e.createElement(i,null,br(ho,S,w))),e.createElement(m,{flexDirection:"column",borderStyle:"double",borderColor:"grey",paddingX:3,paddingY:1,width:Math.min(80,t-4)},e.createElement(i,{bold:!0,color:"white",textAlign:"center"},"\u{1F680} UPGRADE YOUR WORKFLOW"),e.createElement(m,{marginY:1,flexDirection:"column",alignItems:"left"},e.createElement(i,null,"You're in ",e.createElement(i,{bold:!0,color:"cyan"},p),", but the ",e.createElement(i,{bold:!0,color:"white"},"FluxFlow-CLI Companion")," is not installed."),e.createElement(m,{flexDirection:"column",marginY:1},e.createElement(i,{color:"gray"}," \u2705 Real-time IDE context & Error Resolution"),e.createElement(i,{color:"gray"}," \u2705 Auto-open files created by agent"),e.createElement(i,{color:"gray"}," \u2705 Native DIFFing for AI edits"),e.createElement(i,{color:"gray"}," \u2705 Direct IDE context sharing"),e.createElement(i,{color:"gray"}," \u2705 Surgical Diagnostic Sync"),e.createElement(i,{color:"gray"}," \u2705 Native Right-Click \u276F Chat integration"),e.createElement(i,{color:"gray"}," \u2705 Live Status in IDE"),e.createElement(i,{color:"gray"}," \u2705 Clickable terminal-to-code links"))),e.createElement(m,{flexDirection:"column",marginTop:1},r.map((y,b)=>e.createElement(m,{key:b},e.createElement(i,{color:d===b?"yellow":"white",bold:d===b},d===b?" \u276F ":" ",y.label)))),e.createElement(m,{marginTop:1,alignItems:"center",justifyContent:"center"},e.createElement(i,{dimColor:!0,italic:!0},"(Use arrows to navigate, Enter to select)"))))},du=({width:t,height:g,aiProvider:d,theme:S="Dark",reason:w})=>{let p=cn(),r=w==="version_mismatch";return e.createElement(m,{flexDirection:"column",alignItems:"center",justifyContent:"center",width:t,height:g},e.createElement(m,{marginBottom:1,width:Math.min(80,t-4),justifyContent:"flex-start"},e.createElement(i,null,br(ho,d,S))),e.createElement(m,{flexDirection:"column",borderStyle:"double",paddingX:3,paddingY:1,width:Math.min(80,t-4)},e.createElement(i,{bold:!0,color:"yellow",textAlign:"center"},r?"\u26A0 VERSION MISMATCH":"\u26A0 CWD MISMATCH"),e.createElement(m,{marginY:1,flexDirection:"column",alignItems:"left"},e.createElement(i,null,r?"Your FluxFlow CLI version is not supported by the ":"CWD mismatch from ",!r&&e.createElement(i,{bold:!0,color:"white"},p),!r&&" workspace. ","IDE features aren't available right now."),!r&&e.createElement(m,{marginTop:1},e.createElement(i,{dimColor:!0},"Tip: Launch FluxFlow CLI from the same folder open in ",p,"."))),e.createElement(m,{marginTop:1},e.createElement(i,{color:"yellow",bold:!0}," \u276F Understood")),e.createElement(m,{marginTop:1,alignItems:"center",justifyContent:"center"},e.createElement(i,{dimColor:!0,italic:!0},"(Press Enter to dismiss)"))))},Mi=Date.now(),Ya="https://fluxflow-cli.onrender.com/changelog",Si="https://fluxflow-cli.onrender.com/",uu=Ct.join(Ct.dirname(su(import.meta.url)),"../package.json"),qa=JSON.parse(pt.readFileSync(uu,"utf8")),ho=qa.version,mu=qa.date||"2026-05-20";var xu=({data:t,onResolve:g,onEdit:d,theme:S="Dark"})=>{let w=xt(S);return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:w.borderMuted,padding:0,width:"100%"},e.createElement(m,{paddingX:1},e.createElement(i,{color:w.text,bold:!0,underline:!0},t.startsWith("/btw")?"QUESTION":"STEERING HINT"," RESOLUTION")),e.createElement(m,{paddingX:1,marginTop:1},e.createElement(i,{color:w.text},"The agent already finished the task before your ",t.startsWith("/btw")?"question":"hint"," was consumed.")),e.createElement(m,{marginTop:1,backgroundColor:w.cardBg||w.codeBg||"#222",paddingX:2,width:"100%"},e.createElement(i,{italic:!0,color:w.textMuted},'"',t.replace("/btw","").trim(),'"')),e.createElement(m,{paddingX:1,marginTop:1},e.createElement(i,{color:w.textDim||w.textMuted},"How would you like to proceed?")),e.createElement(m,{marginTop:0},e.createElement($t,{title:"Select Action",items:[{label:"Send Anyway",value:"send"},{label:"Edit Prompt",value:"edit"}],onSelect:p=>{(typeof p=="object"&&p!==null?p.value:p)==="send"?g(t):d(t)},theme:S})))};var fu=(()=>{let t=null,g=0;return d=>{let S=Date.now();if(t&&S-g<1e4)return t;let w=[],p=r=>{if(!(w.length>=2e3))try{let y=pt.readdirSync(r);for(let b of y){if(w.length>=2e3)return;if(["node_modules",".git",".gemini","dist","build",".next",".cache","out"].includes(b))continue;let C=Ct.join(r,b);pt.statSync(C).isDirectory()?p(C):w.push({name:Xt(b),relativePath:Xt(Ct.relative(process.cwd(),C))})}}catch{}};return p(d),t=w,g=S,w}})(),Ts="Ctrl + Enter",gu=t=>{if(t<=370)return"#00a564";if(t>=5e3)return"#ff0000";let g=[{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 d=0;d<g.length-1;d++){let S=g[d],w=g[d+1];if(t>=S.t&&t<=w.t){let p=(t-S.t)/(w.t-S.t);p=p*p*(3-2*p);let r=Math.round(S.r+(w.r-S.r)*p),y=Math.round(S.g+(w.g-S.g)*p),b=Math.round(S.b+(w.b-S.b)*p);return`#${((1<<24)+(r<<16)+(y<<8)+b).toString(16).slice(1)}`}}return"#ff0000"},hu=e.memo(({sa:t,showTPMEstimate:g=!1})=>{let[d,S]=Q("green"),[w,p]=Q(0),r=Re([]),y=Re(370),b=Re([]),C=Re(t.lastChunkTime);return gt(()=>{C.current=t.lastChunkTime},[t.lastChunkTime]),gt(()=>{if(t.status!=="running"){b.current=[];return}if(t.wps>0){let A=b.current;A.push(t.wps),A.length>3&&A.shift()}},[t.status,t.wps,t.lastChunkTime]),gt(()=>{if(t.status!=="running"){p(0);return}let A=setInterval(()=>{let P=C.current,B=P>0?Date.now()-P:0;if(P>0&&B>=1e3)b.current=[],p(0);else if(P>0&&B>500){b.current.length>0&&b.current.shift();let L=b.current;if(L.length>0){let _=L.reduce((G,$)=>G+$,0);p(Math.round(_/L.length))}else p(0)}else{let L=b.current;if(L.length>0){let _=L.reduce((G,$)=>G+$,0);p(Math.round(_/L.length))}else t.wps>0&&p(Math.round(t.wps))}},750);return()=>clearInterval(A)},[t.status]),gt(()=>{if(t.status!=="running"){r.current=[];return}let A=t.lastChunkTime;if(A>0){let L=r.current;(L.length===0||L[L.length-1]!==A)&&(L.push(A),L.length>10&&L.shift())}let P=()=>{if(!A){S("#00a564");return}let L=r.current,_=0;if(L.length>1){let oe=0;for(let X=1;X<L.length;X++)oe+=L[X]-L[X-1];_=oe/(L.length-1)}let G=Date.now()-A,z=G>=2500,Y=!z&&_>0?Math.min(G,_*3):G,le=Math.max(_,Y),xe=z?.4:.2;y.current=y.current*(1-xe)+le*xe,S(gu(y.current))};P();let B=setInterval(P,100);return()=>clearInterval(B)},[t.status,t.lastChunkTime]),e.createElement(m,{justifyContent:"space-between",width:"100%"},e.createElement(i,{color:"white"}," \u2022 ",t.title," ",e.createElement(i,{color:"white",dimColor:!0},"(",t.id,")")),e.createElement(i,{color:"white"},e.createElement(i,{color:"white",dimColor:!0,bold:!0},t.currentTool||"Active"),!g&&e.createElement(i,{color:d}," \u25CF"),g&&e.createElement(i,{color:"white",dimColor:!0,bold:!0}," ~",w," tok/s")))});function pu({args:t=[]}){let g=Re(1),[d,S]=Q(!1),[w,p]=Q(10),{stdout:r}=ou(),[y,b]=Q(""),[C,A]=Q(0),P=Re([]),[B,L]=Q(-1),_=Re(""),G=Re(null),[$,z]=Q(!1),[Y,le]=Q("Flux"),[xe,oe]=Q(0),[X,be]=Q({columns:r?.columns||80,rows:r?.rows||24}),[De,Oe]=Q(0),[Xe,Be]=Q(!1),[fe,Ne]=Q(!1),[Mt,Fe]=Q(null),[Le,R]=Q(0),re=Re(null),ge=Re(!1),we=Re(0),ie=Re(0),me=Re(null),j=Re(null),Ye=Re(0),[ot,Tt]=Q(0),ct=()=>Tt(n=>n+1),wt=Re([]),st=Re(null),qe=()=>{let n=wt.current;if(n.length>0&&j.current){let o=n.join("");n.length=0,j.current.text=Xt(j.current.text+o),ct()}},se=()=>{if(qe(),j.current){let n=Xt(j.current.text||""),o="";if(j.current.role==="agent"&&n){let f=ra(n);f.inside&&typeof f.startIndex=="number"&&f.startIndex>=0&&(o=n.substring(f.startIndex),n=n.substring(0,f.startIndex))}let c=n;if(j.current.role==="think"&&(c=c.replace(/^\r?\n+/,"").replace(/\r?\n+$/,"")),c.trim().length>0||j.current.role!=="agent"){let f={...j.current,text:c,isStreaming:!1};I(x=>[...x,f]),O(x=>x+1)}o?j.current={id:"agent-"+Date.now(),role:"agent",text:o,isStreaming:!0}:j.current=null}Ii.current=0,Ds.current={totalWords:0,startTime:0,wps:0,chunks:[]}},Se=()=>{st.current&&clearInterval(st.current),wt.current=[],st.current=setInterval(()=>{try{let n=wt.current;if(n.length>0&&j.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 c="";for(let f=0;f<o&&n.length>0;f++)c+=n.shift();j.current.text=Xt(j.current.text+c),ct()}}catch{}},80)},ut=async()=>{for(;de.progressiveRendering&&wt.current.length>0;)await new Promise(n=>setTimeout(n,10))},mt=n=>{if(de.progressiveRendering&&st.current){let o=n.trim();if((o.startsWith("[action:")||o.startsWith("[tool:"))&&o.endsWith("]")){wt.current.push(n);return}let f=Ul(n);for(let x of f)wt.current.push(x)}else j.current?j.current.text=Xt(j.current.text+n):j.current={id:"agent-"+Date.now(),role:"agent",text:Xt(n),isStreaming:!0},ct()};gt(()=>{let n=cn(),o=!["Terminal","Windows Terminal"].includes(n)||!!process.env.VSC_TERMINAL_URL,c=setTimeout(()=>{o&&!Bn()&&!re.current&&Ne(!0)},500),f=setInterval(()=>{Bn()&&(Ne(!1),Fe(null),re.current=null,ge.current=!1)},1e3);g.current=Date.now();let x=setInterval(()=>{g.current&&(Date.now()-g.current||0)>3e4&&global.gc&&(async()=>{for(let a=0;a<1;a++)global.gc(),await new Promise(h=>setImmediate(h));g.current=Date.now()})()},3e3);return()=>{clearTimeout(c),clearInterval(f),clearInterval(x)}},[]),gt(()=>{(async()=>{try{let o=await ti(),c=o?.systemSettings||{},f=c.CustomSubAgent,x=c.SubAgentModel;if(!f||!x||x==="Default")return;let v=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","Infron","APInex","xKiro"],M=(te=>{if(!te)return null;let U=te.toLowerCase();return U==="google"?"Google":U==="deepseek"?"DeepSeek":U==="openrouter"?"OpenRouter":U==="nvidia"?"NVIDIA":U==="mistral"?"Mistral":U==="ollama"?"Ollama":U==="inferx"?"InferX":U==="sensenova"?"SenseNova":U==="poolside"?"Poolside":U==="9router"?"9router":U==="aihubmix"||U==="aihub"?"AIHubMix":U==="explabs"||U==="experientiallabs"||U==="experimentallabs"||U==="experiential labs"||U==="experimental labs"||U==="experiential"||U==="experimental"?"ExpLabs":U==="tokenharbor"||U==="token harbor"||U==="token_harbor"||U==="thk"?"TokenHarbor":U==="apinex"||U==="apx"?"APInex":U==="xkiro"||U==="kiro"?"xKiro":U==="infron"?"Infron":null})(u);if(v&&!M){let te=o.aiProvider||F||"Google";I(U=>(O(U.length+1),[...U,{id:"subagent-env-noprov-"+Date.now(),role:"system",text:`[SUBAGENT CONFIG] SUBAGENT_MODEL found in ENV but SUBAGENT_PROVIDER is missing/invalid. Active provider (${te}) will be used.`,isMeta:!0}]))}if(x==="ENV"){v||I(te=>(O(te.length+1),[...te,{id:"subagent-model-noenv-"+Date.now(),role:"system",text:"No SubAgent model is found in ENV, Using Deafult until changed",isMeta:!0}]));return}let N=o.aiProvider||F||"Google",H=o.apiTier||ze||"Free",K=o.quotas||Ie||{},q=new Set;(tn(N,H)||[]).forEach(te=>{let U=typeof te=="string"?te:te.cmd||te.name||te.id||String(te);U&&q.add(U)});for(let te of a)try{if(await on(te,{silent:!0})){let et=K?.providerTiers?.[te]||"Free";(tn(te,et)||[]).forEach(He=>{let Qe=typeof He=="string"?He:He.cmd||He.name||He.id||String(He);Qe&&q.add(Qe)})}}catch{}let ee=q.has(x);v?v!==x&&I(te=>(O(te.length+1),[...te,{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}])):ee||I(te=>(O(te.length+1),[...te,{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 _e=Jn(()=>{let n={};for(let o=0;o<t.length;o++)if(t[o]==="--key"&&t[o+1]){let f=t[o+1];if(n.key=f,f.includes("@")){let x=f.split("@"),v=x[0],u=x[1].toLowerCase();if(["google","deepseek","openrouter","nvidia","mistral","ollama","inferx","sensenova","aihubmix","aihub","poolside","pool","9router","9r","explabs","tokenharbor","token_harbor","thk","infron","apinex","apx","xkiro","kiro"].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==="infron"?a="Infron":u==="apinex"||u==="apx"?a="APInex":(u==="xkiro"||u==="kiro")&&(a="xKiro"),n.key=v,n.provider=a}}}for(let o=0;o<t.length;o++){let c=t[o];if(c==="--key"){o++;continue}if(c==="--model"&&t[o+1])n.model=t[o+1],o++;else if(c==="--memory"&&t[o+1])n.memory=t[o+1].toLowerCase(),o++;else if(c==="--resume"&&t[o+1])n.resume=t[o+1],o++;else if(c==="--package"&&t[o+1]){let f=t[o+1].toLowerCase();["npm","pnpm","yarn","bun"].includes(f)&&(n.package=f),o++}else if(c==="--auto-del"&&t[o+1]){let f=t[o+1].toLowerCase();["1d","7d","30d"].includes(f)&&(n.autoDel=f),o++}else if(c==="--auto-exec"&&t[o+1])n.autoExec=t[o+1].toLowerCase(),o++;else if(c==="--yolo"&&t[o+1])n.autoExec=t[o+1].toLowerCase(),o++;else if(c==="--external-access"&&t[o+1])n.externalAccess=t[o+1].toLowerCase(),o++;else if(c==="--mode"&&t[o+1]){let x=t[o+1].toLowerCase();if(["flux","flow","icu","computer","fluxcu"].includes(x)){let v="Flux";x==="flux"?v="Flux":x==="flow"?v="Flow":x==="icu"||x==="computer"?v="ICU":x==="fluxcu"&&(v="FluxCU"),n.mode=v}o++}else if(c==="--thinking"&&t[o+1]){let x=t[o+1].toLowerCase();if(["fast","low","medium","high","xhigh","standard"].includes(x)){let v="Medium";x==="fast"?v="Fast":x==="low"?v="Low":x==="standard"?v="Standard":x==="medium"?v="Medium":x==="high"?v="High":x==="xhigh"&&(v="xHigh"),n.thinking=v}o++}else if(c==="--provider"&&t[o+1]){let f=t[o+1].toLowerCase();if(["google","deepseek","openrouter","nvidia","mistral","ollama","inferx","sensenova","aihubmix","aihub","poolside","pool","9router","9r","explabs","tokenharbor","token_harbor","thk","infron","apinex","apx","xkiro","kiro"].includes(f)){let x="Google";f==="google"?x="Google":f==="deepseek"?x="DeepSeek":f==="openrouter"?x="OpenRouter":f==="nvidia"?x="NVIDIA":f==="mistral"?x="Mistral":f==="ollama"?x="Ollama":f==="inferx"?x="InferX":f==="sensenova"?x="SenseNova":f==="poolside"||f==="pool"?x="Poolside":f==="9router"||f==="9r"?x="9router":f==="aihubmix"||f==="aihub"?x="AIHubMix":f==="explabs"?x="ExpLabs":f==="tokenharbor"||f==="token_harbor"||f==="thk"?x="TokenHarbor":f==="infron"?x="Infron":f==="apinex"||f==="apx"?x="APInex":(f==="xkiro"||f==="kiro")&&(x="xKiro"),n.provider=x}o++}else(c==="--resume"||c==="-r")&&t[o+1]?(n.resume=t[o+1],o++):c==="--playground"?n.playground=!0:(c==="--original-cwd"||c==="--orginal-cwd")&&t[o+1]&&(n.originalCwd=t[o+1],o++)}return n},[t]),Bt=async(n=!1,o=null)=>{let c=o||de;n&&I(f=>(O(f.length+1),[...f,{id:"check-"+Date.now(),role:"system",text:"\u2726 Checking for updates...",isMeta:!0}]));try{let x=await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json(),v=x["dist-tags"]?.latest,u=x["dist-tags"]?.stable;if(v&&Lr(v),v&&v!==ho){let a=v===u?`v${v}`:`v${v}`;!n&&c.autoUpdate?ne("update"):I(h=>{let M=[...h],N=n?M.length:Math.min(M.length,3);return M.splice(N,0,{id:"update-"+Date.now(),role:"system",text:`A new version (${a}) is here.
|
|
63
63
|
|
|
64
64
|
\u2022 Type \`/update latest\` to apply the update.
|
|
65
65
|
\u2022 Type \`/changelog\` to view the release notes.`,isUpdateNotification:!0,isMeta:!0}),M})}else n&&I(a=>{O(a.length+1);let h=v&&v===u?`${ho}`:ho;return[...a,{id:"uptodate-"+Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Already up to date (${h}).
|
|
66
66
|
\u2800`,isMeta:!0}]})}catch(f){n&&I(x=>(O(x.length+1),[...x,{id:"check-err-"+Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Failed to check for updates: ${f.message}.
|
|
67
|
-
\u2800`,isMeta:!0}]))}};gt(()=>{let n=r?.columns||80,o=()=>{let c=r?.columns||80,f=r?.rows||24;c!==n&&(n=c,r.write("\x1B[2J\x1B[3J\x1B[H")),be({columns:c,rows:f})};return r.on("resize",o),()=>{r.off("resize",o)}},[r]);let[We,no]=Q("Medium"),[F,zo]=Q("Google"),[er,Ar]=Q(0),[dn,Lr]=Q(null),[un,ys]=Q(!1),[je,Gt]=Q(ao("Google","Free")||"gemma-4-31b-it"),[Pr,Ce]=Q(!1),[ce,T]=Q(!1),[k,Me]=Q(
|
|
67
|
+
\u2800`,isMeta:!0}]))}};gt(()=>{let n=r?.columns||80,o=()=>{let c=r?.columns||80,f=r?.rows||24;c!==n&&(n=c,r.write("\x1B[2J\x1B[3J\x1B[H")),be({columns:c,rows:f})};return r.on("resize",o),()=>{r.off("resize",o)}},[r]);let[We,no]=Q("Medium"),[F,zo]=Q("Google"),[er,Ar]=Q(0),[dn,Lr]=Q(null),[un,ys]=Q(!1),[je,Gt]=Q(ao("Google","Free")||"gemma-4-31b-it"),[Pr,Ce]=Q(!1),[ce,T]=Q(!1),[k,Me]=Q(Tl("gemma_janitor_fallback_google")||"gemma-4-26b-a4b-it"),[Pe,at]=Q(!0),[dt,tt]=Q(!0),ro=Re(0),[Ke,Pt]=Q(null),[mn,xn]=Q(""),Cs=async n=>{let o=Ka(n);if(o)try{await pt.ensureDir(Ct.dirname(o));let c=[];if(pt.existsSync(o)){let f=pt.readFileSync(o,"utf8").trim();if(f)try{c=Va(f)}catch{c=[]}}Array.isArray(c)||(c=[]),c.push({key:"shift+enter",command:"workbench.action.terminal.sendSequence",args:{text:"\x1B[13;2u"},when:"terminalFocus"}),pt.writeFileSync(o,JSON.stringify(c,null,4),"utf8"),Ts="Shift + Enter",I(f=>(O(f.length+1),[...f,{id:"kb-success-"+Date.now(),role:"system",text:`\u2726 Successfully configured Shift+Enter in your ${n} keybindings!
|
|
68
68
|
`,isMeta:!0}]))}catch(c){I(f=>(O(f.length+1),[...f,{id:"kb-error-"+Date.now(),role:"system",text:`\u2726 Failed to update keybindings: ${c.message}.
|
|
69
|
-
\u2800`,isMeta:!0}]))}},[St,ne]=Q("chat"),[In,Or]=Q([]),Nr=y.startsWith("/k");gt(()=>{if(!Nr)return;let n=!0,o=async()=>{try{let f=await ca(process.pid);n&&Or(f||[])}catch{}};o();let c=setInterval(o,5e3);return()=>{n=!1,clearInterval(c)}},[Nr]);let[ze,Ht]=Q("Free"),[Ie,po]=Q({limitMode:"Daily",agentLimit:99999999,tokenLimit:99999999999999,backgroundLimit:999999,searchLimit:100,customModelId:"",customLimit:0,providerBudgets:{}}),[Qo,so]=Q(null),[Uo,za]=Q("chat"),[Jo,Ms]=Q("settings"),[kn,Qa]=Q([]),[bu,Ja]=Q(0),[
|
|
69
|
+
\u2800`,isMeta:!0}]))}},[St,ne]=Q("chat"),[In,Or]=Q([]),Nr=y.startsWith("/k");gt(()=>{if(!Nr)return;let n=!0,o=async()=>{try{let f=await ca(process.pid);n&&Or(f||[])}catch{}};o();let c=setInterval(o,5e3);return()=>{n=!1,clearInterval(c)}},[Nr]);let[ze,Ht]=Q("Free"),[Ie,po]=Q({limitMode:"Daily",agentLimit:99999999,tokenLimit:99999999999999,backgroundLimit:999999,searchLimit:100,customModelId:"",customLimit:0,providerBudgets:{}}),[Qo,so]=Q(null),[Uo,za]=Q("chat"),[Jo,Ms]=Q("settings"),[kn,Qa]=Q([]),[bu,Ja]=Q(0),[Bi,Fr]=Q(0),[Ss,Ei]=Q({}),[tr,or]=Q({}),[An,bo]=Q(0),[de,Ot]=Q({memory:!0,theme:"Dark",compression:0,autoExec:!1,autoDeleteHistory:"7d",autoUpdate:!1,updateManager:"npm",customUpdateCommand:"",clipboardContext:!1}),s=Jn(()=>xt(de.theme),[de.theme]),[fn,vs]=Q({preset:"Default",name:null,nickname:null,instructions:null}),[_o,$r]=Q({keyType:"Default",quality:"Low-High",apiKey:""}),[nr,Bs]=Q({enabled:!1,model:"Default",provider:"",baseUrl:""}),[Do,Zo]=Q({tokens:0}),[Di,Es]=Q(0),Ii=Re(0),Ds=Re({totalWords:0,startTime:0,wps:0,chunks:[]}),[ki,Ai]=Q(0),[Li,Za]=Q(0),[io,Pi]=Q(0),[Ra,Ln]=Q(0),Pn=Re(0),[ec,On]=Q(0),[tc,gn]=Q(0),zt=Re([]),Nn=Re(0),[oc,Fn]=Q(0),$n=Re(0),[hn,Oi]=Q(0),[wo,Ni]=Q(0),[Un,Fi]=Q(0),[wu,nc]=Q(0),[Tu,rc]=Q(0),[yu,sc]=Q(0),[Ur,ic]=Q(0),[_r,lc]=Q(0),[Hr,ac]=Q(0),[$i,cc]=Q(0),[_n,Is]=Q(null),[rr,ks]=Q(null),[Xr,Ui]=Q(null),[Hn,sr]=Q("daily"),[dc,To]=Q(0),[ir,lr]=Q(""),Xn="flow-playground",[bt,Wr]=Q(t.includes("--playground")?Xn:ii());gt(()=>{if(Ho.current)return;let n=io-Pn.current,o=wo-Nn.current,c=hn-$n.current;Ln(n),On(o),Fn(Math.max(0,c)),bt&&zl(bt,n,Do.tokens).catch(()=>{})},[io,wo,hn,bt,Do.tokens]),gt(()=>{St==="apiTier"&&(async()=>{let o=await Zr();Is(o);let c=await Rr();ks(c);let f=await oi(Ie.resetDay||1);Ui(f)})()},[St,Ie.resetDay]);let[yo,_i]=Q(null),[Wn,Gn]=Q(""),[ar,Hi]=Q(!1),[As,uc]=Q([]),[Cu,Mu]=Q(0),Ls=Re(!0),Xi=Re(!0),Ps=Re(F),Os=Re(!1),Ns=Re(!0);gt(()=>{(Pr||ce)&&(I(n=>(O(n.length+1),[...n,{id:Date.now(),role:"system",text:`\u2726 Wild${ce?"er":""}Card Tooling:
|
|
70
70
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Status: Disabled.
|
|
71
71
|
\u2800`,isMeta:!0}])),Ce(!1),T(!1)),process.env.forcedReasoning&&(I(n=>(O(n.length+1),[...n,{id:Date.now(),role:"system",text:`\u2726 Forced Reasoning:
|
|
72
72
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Status: Disabled.
|
|
73
|
-
\u2800`,isMeta:!0}])),process.env.forcedReasoning=!1),We==="xHigh"&&!Ls.current&&no("Medium")},[je]);let
|
|
73
|
+
\u2800`,isMeta:!0}])),process.env.forcedReasoning=!1),We==="xHigh"&&!Ls.current&&no("Medium")},[je]);let Wi;gt(()=>{if(Xi.current){Wi=setTimeout(()=>{Xi.current=!1,Ps.current=F},1e3);return}return Ps.current!==F&&(Ps.current=F,no(F==="SenseNova"||F==="Poolside"?"High":"Low")),()=>{clearTimeout(Wi)}},[F,je]);let Gi;gt(()=>{if(!Ke)return;if(Ls.current){Gi=setTimeout(()=>{Ls.current=!1},1500);return}let n=ao(F,ze),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"),Gt(n),Kt({apiTier:ze,activeModel:n}),()=>{clearTimeout(Gi)}},[ze,F,Ke]);let mc=Jn(()=>{let n=cn();return{isIDE:!["Terminal","Windows Terminal"].includes(n)||!!process.env.VSC_TERMINAL_URL||!!process.env.INTELLIJ_TERMINAL_COMMAND_BLOCKS,get shortcut(){return Ts}}},[]),Fs=Re(null),$s=Re("");gt(()=>{Fs.current=yo},[yo]),gt(()=>{$s.current=Wn},[Wn]);let[Ki,Us]=Q(!1),Vi=Re(new Set),Yi=Re(new Set),ji=Re(new Set),[eo,Kn]=Q(null),[pn,_s]=Q(null),Io=n=>{Kn(null),ne("chat")},qi=n=>{let o=Math.floor(n/3600),c=Math.floor(n%3600/60),f=n%60,x=[];return o>0&&x.push(`${o}h`),(c>0||o>0)&&x.push(`${c}m`),x.push(`${f}s`),x.join(" ")},bn=n=>n<1e3?`${n}ms`:qi(Math.floor(n/1e3)),[Ro,Hs]=Q(null),[Xs,zi]=Q(""),[xc,fc]=Q(!1),[Qi,cr]=Q(0),dr;gt(()=>{let n;if(Ro&&de.loadingPhrases!==!1){let o=f=>{zi(f[Math.floor(Math.random()*f.length)])},c=()=>{Rn?o(Rn):process.env.HALLOWEEN_EEGG==="true"||process.env.HALLOWEEN_EEGG===!0?import("./halloween_witty_phrases-IJGE3RWX.js").then(({HALLOWEEN_WITTY_PHRASES:x})=>{Rn=x,o(Rn)}):import("./witty_phrases-EEDEYYAH.js").then(({WITTY_LOADING_PHRASES:x})=>{Rn=x,o(Rn)})};Xs||c(),n=setInterval(c,1e4)}else zi("");return()=>{clearInterval(n)}},[Ro,de]);let[Su,gc]=Q(!0),[Vn,Ws]=Q(!1),[ur,Ji]=Q(!1),[hc,pc]=Q(!1),[Zi,vu]=Q(null),[Ri,mr]=Q(0),[bc,el]=Q([]),wn=Re(null),Ho=Re(!1);gt(()=>()=>{wn.current&&clearTimeout(wn.current)},[]);let Gs=Re(!1),[xr,Ks]=Q(null),[wc,Vs]=Q(null),[Bu,Tc]=Q(null);gt(()=>mr(0),[y]);let[Nt,yc]=Q(()=>{let n={id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0},o=process.cwd()===vi.homedir(),c=(()=>{let x=process.cwd().toLowerCase();if(process.platform==="win32"){let v=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 x.startsWith(v)||x.startsWith(u)||x.startsWith(a)}else return x==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(u=>x.startsWith(u))})(),f=[n];return c?f.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&&f.push({id:"home-warning",role:"system",text:"[SECURITY ALERT] HOME DIRECTORY DETECTED",subText:`You are currently in ${vi.homedir()}. Working here is high-risk as the agent may modify system-sensitive configurations. Please open FluxFlow in project folder.`,isHomeWarning:!0}),f}),I=n=>{yc(o=>{let c=typeof n=="function"?n(o):n;if(c.length>1){let f=c[c.length-1],x=c[c.length-2];if(f?.text?.includes("Request Cancelled")&&x?.text?.includes("Request Cancelled"))return c.slice(0,-1)}return c})},Xo=Re(null),[tl,Cc]=Q(""),[ol,nl]=Q(!1),rl=Re(""),sl=Re(null);gt(()=>{if(Nt.length===0)return;let n=Nt[Nt.length-1];if(n&&(n.role==="agent"||n.role==="assistant")){let c=(n.text||"").match(/\[ANSWER\]([\s\S]*?)(?:\[\/ANSWER\]|$)/i);if(c){let f=c[1].trim();f&&f!==rl.current&&(Cc(f),rl.current=f,sl.current!==n.id&&nl(!0))}}},[Nt]);let[en,O]=Q(Nt.length),[Tn,Ys]=Q(0),Eu=Re([]),lo=Re({completedIndex:0,columns:0,historicalBlocks:[],seenSelections:new Set,chatId:"",clearKey:0,theme:""}),il=Jn(()=>{let n=X.columns||80,o=/Selection: (.*)/,c=[],f=new Set,x=lo.current.columns!==n,v=en<lo.current.completedIndex,u=lo.current.chatId!==bt,a=lo.current.clearKey!==Tn,h=lo.current.theme!==de.theme;if(x||v||u||a||h){let q=Nt.slice(0,en);for(let V=0;V<q.length;V++){let ee=q[V];if(ee.isAskRecord&&ee.text){let U=ee.text.match(o);if(U&&U[1].trim()){let et=U[1].trim();if(f.has(et))continue;f.add(et)}}let te=pr(ee,n);for(let U=0;U<te.completed.length;U++)c.push(te.completed[U]);for(let U=0;U<te.active.length;U++)c.push(te.active[U])}lo.current={completedIndex:en,columns:n,historicalBlocks:c,seenSelections:new Set(f),chatId:bt,clearKey:Tn,theme:de.theme}}else if(c=lo.current.historicalBlocks,f=lo.current.seenSelections,en>lo.current.completedIndex){c=[...c],f=new Set(f);let q=Nt.slice(lo.current.completedIndex,en);for(let V=0;V<q.length;V++){let ee=q[V];if(ee.isAskRecord&&ee.text){let U=ee.text.match(o);if(U&&U[1].trim()){let et=U[1].trim();if(f.has(et))continue;f.add(et)}}let te=pr(ee,n);for(let U=0;U<te.completed.length;U++)c.push(te.completed[U]);for(let U=0;U<te.active.length;U++)c.push(te.active[U])}lo.current={completedIndex:en,columns:n,historicalBlocks:c,seenSelections:f,chatId:bt,clearKey:Tn}}let M=Nt.slice(en),N=[],H=[];for(let q=0;q<M.length;q++){let V=M[q];if(V.isAskRecord&&V.text){let te=V.text.match(o);if(te&&te[1].trim()){let U=te[1].trim();if(f.has(U))continue}}let ee=pr(V,n);for(let te=0;te<ee.completed.length;te++)N.push(ee.completed[te]);for(let te=0;te<ee.active.length;te++)H.push(ee.active[te])}if(j.current){let q=pr(j.current,n);for(let V=0;V<q.completed.length;V++)N.push(q.completed[V]);for(let V=0;V<q.active.length;V++)H.push(q.active[V])}let K=N.length===0?c:c.concat(N);return K.length>=75e3&&(K=[...K],K.push({key:`memory-warning-block-${K.length}`,msg:{role:"system",text:"\u26A0\uFE0F MEMORY WARNING: CHAT IS GETTING VERY LONG",subText:`This session has reached ${K.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:K,active:H}},[Nt,en,X.columns,Tn,bt,ot]),Mc=Jn(()=>{if(!yo||!Wn)return!1;let n=Wn.trim();return n.endsWith("?")||n.endsWith(":")||/\[[yYnN/]+\]\s*$/.test(n)||/\([yYnN]\)\s*$/.test(n)},[yo,Wn]);tu((n,o)=>{if(!(n==="\x1B[I"||n==="\x1B[O"||n==="[I"||n==="[O")){if(o.ctrl&&(n.toLowerCase()==="r"||n===""||n==="")){wa();return}if(St==="stats"){if(Hn==="dailyModelBreakdown"||Hn==="modelBreakdown"){if(o.tab&&!o.shift){sr(f=>f==="dailyModelBreakdown"?"modelBreakdown":"dailyModelBreakdown"),To(0);return}if(o.space||n===" "){sr(f=>f==="dailyModelBreakdown"?"daily":"monthly"),To(0),lr("");return}if(o.escape){if(ir){lr(""),To(0);return}ne("chat");return}if(o.upArrow){To(f=>Math.max(0,f-1));return}if(o.downArrow){To(f=>Math.min(ie.current,f+1));return}if(o.backspace||o.delete){lr(f=>f.slice(0,-1)),To(0);return}if(n&&n!==" "&&!o.space&&!o.ctrl&&!o.meta&&n.length===1&&n.charCodeAt(0)>=32){lr(f=>f+n),To(0);return}return}if(o.tab&&!o.shift){sr(f=>f==="daily"?"monthly":"daily"),To(0);return}if(o.space||n===" "){sr(f=>f==="daily"?"dailyModelBreakdown":"modelBreakdown"),To(0),lr("");return}if(o.upArrow){To(f=>Math.max(0,f-1));return}if(o.downArrow){To(f=>Math.min(ie.current,f+1));return}}if(Mt){(o.return||o.escape)&&(ge.current=!0,Fe(null));return}if(fe){let c=cn(),f=ja(c);if(o.upArrow)R(x=>x>0?x-1:f.length-1);else if(o.downArrow)R(x=>x<f.length-1?x+1:0);else if(o.return){let x=f[Le];if(x.action==="dismiss")Ne(!1);else if(x.url){let v=process.platform==="win32"?`start ${x.url}`:process.platform==="darwin"?`open ${x.url}`:`xdg-open ${x.url}`;$o(v),Ne(!1)}}return}if(o.tab&&yo){Hi(c=>!c);return}if(ar&&yo){let c=o.pageUp||n==="\x1B[5~"||n==="[5~",f=o.pageDown||n==="\x1B[6~"||n==="[6~",x=o.ctrl&&(n==="o"||n==="");if(c||f||x)return;if(o.return)if(jn)co("\r");else{let v=process.platform==="win32";co(v?`\r
|
|
74
74
|
`:`
|
|
75
75
|
`),Gn(u=>u+`
|
|
76
|
-
`)}else if(o.backspace||o.delete)jn?co("\x7F"):(co("\b \b"),Gn(v=>v.slice(0,-1)));else if(o.upArrow)co(o.shift?"\x1B[1;2A":"\x1B[A");else if(o.downArrow)co(o.shift?"\x1B[1;2B":"\x1B[B");else if(o.rightArrow)co(o.shift?"\x1B[1;2C":"\x1B[C");else if(o.leftArrow)co(o.shift?"\x1B[1;2D":"\x1B[D");else if(o.escape)co("\x1B");else if(o.ctrl&&n){let v=n.toLowerCase().charCodeAt(0);v>=97&&v<=122?co(String.fromCharCode(v-96)):co(n)}else n&&(co(n),jn||Gn(v=>v+n));return}if(St==="providerBudgetSelect"){let c=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","Infron","APInex","xKiro"];if(o.upArrow){Fr(f=>(f-1+c.length)%c.length);return}else if(o.downArrow){Fr(f=>(f+1)%c.length);return}else if(n===" "){let f=c[
|
|
77
|
-
\u2800`,isMeta:!0}]))})),f})}}if(lt.length>0&&St==="chat"&&B===-1){if(o.upArrow){Oe(c=>{let f=c>0?c-1:lt.length-1,x=0;for(;f!==c&&x<lt.length;){let v=lt[f],u=v?.cmd||v||"";if(typeof u=="string"&&u.trimStart().startsWith("---"))f=f>0?f-1:lt.length-1,x++;else break}return f});return}if(o.downArrow){Oe(c=>{let f=c<lt.length-1?c+1:0,x=0;for(;f!==c&&x<lt.length;){let v=lt[f],u=v?.cmd||v||"";if(typeof u=="string"&&u.trimStart().startsWith("---"))f=f<lt.length-1?f+1:0,x++;else break}return f});return}if(o.return)return}if(o.tab&&St==="chat"){if(lt.length>0){let c=lt[De]||lt[0],f=y.split(" ");if(f.length===1)b(c.cmd+" ");else{let x=f.slice(0,-1);b(x.join(" ")+" "+c.cmd+" ")}Oe(0),A(x=>x+1);return}else if(y.trim()===""){let c=Date.now();if(c-Ye.current<500)return;Ye.current=c;let f=["Flux","Flow","ICU","FluxCU"],x=(f.indexOf(Y)+1)%f.length,v=f[x>=0?x:0];le(v),I(u=>[...u,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${
|
|
76
|
+
`)}else if(o.backspace||o.delete)jn?co("\x7F"):(co("\b \b"),Gn(v=>v.slice(0,-1)));else if(o.upArrow)co(o.shift?"\x1B[1;2A":"\x1B[A");else if(o.downArrow)co(o.shift?"\x1B[1;2B":"\x1B[B");else if(o.rightArrow)co(o.shift?"\x1B[1;2C":"\x1B[C");else if(o.leftArrow)co(o.shift?"\x1B[1;2D":"\x1B[D");else if(o.escape)co("\x1B");else if(o.ctrl&&n){let v=n.toLowerCase().charCodeAt(0);v>=97&&v<=122?co(String.fromCharCode(v-96)):co(n)}else n&&(co(n),jn||Gn(v=>v+n));return}if(St==="providerBudgetSelect"){let c=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","Infron","APInex","xKiro"];if(o.upArrow){Fr(f=>(f-1+c.length)%c.length);return}else if(o.downArrow){Fr(f=>(f+1)%c.length);return}else if(n===" "){let f=c[Bi];Ei(x=>({...x,[f]:!x[f]}));return}else if(o.return){let f=c.filter(v=>Ss[v]);if(f.length===0)return;let x={...Ie,providerBudgets:{...Ie.providerBudgets||{},__useProvider:!0}};po(x),Qa(f),Ja(0),Fr(0),ne("providerBudgetFlow");return}else if(o.escape){ne("budgetTypeSelect");return}return}if(St==="providerBudgetFlow"){let c=kn.length,f=c*4+1;if(o.upArrow){bo(x=>x===f-1?Math.max(0,(c-1)*4):x>=4?x-4:x);return}else if(o.downArrow){bo(x=>x===f-1?x:x+4<f-1?x+4:f-1);return}else if(o.leftArrow){bo(x=>x===f-1?x:x%4>0?x-1:x);return}else if(o.rightArrow||o.tab){bo(x=>x===f-1?x:x+1<f?x+1:x);return}else if(o.return){if(An===f-1){let x=Ie.providerBudgets||{},v={__useProvider:!0};for(let h of kn){let M=tr[h]||{};v[h]={agentLimit:9999999999,tokenLimit:parseInt(M.tokenLimit,10)||0,monthlyTokenLimit:parseInt(M.monthlyTokenLimit,10)||0,dailyCostLimit:parseFloat(M.dailyCostLimit)||0,monthlyCostLimit:parseFloat(M.monthlyCostLimit)||0}}let u={...Ie,providerBudgets:v};po(u),Kt({apiTier:ze,quotas:u}),ne(Uo==="settings"?"resetMode":"budgetResetMode")}else bo(x=>Math.min(f-1,x+1));return}else if(o.escape){ne("providerBudgetSelect");return}return}if(o.escape){if(ol){if(nl(!1),Nt.length>0){let c=Nt[Nt.length-1];c&&(sl.current=c.id)}return}if(lt.length>0&&St==="chat"){Be(!0);return}if(d){S(!1);return}if(Vn||yo||eo||pn)Gs.current=!0,ta(),Gl(),eo&&(eo.resolve("deny"),Kn(null)),pn&&(pn.resolve(null),_s(null)),pc(!1),Zi&&clearTimeout(Zi);else if(St==="revert")ne("chat"),mr(0);else if(St!=="chat"&&St!=="settings")ne("chat");else{if(!Ke&&er===1){Ar(0),xn("");return}mr(c=>{let f=c+1;return f===1?(wn.current&&clearTimeout(wn.current),wn.current=setTimeout(()=>mr(0),2e3)):f===2&&(wn.current&&clearTimeout(wn.current),mr(0),y.length>0?b(""):wr.getChatHistory(bt).then(x=>{x.length>0?(el(x.reverse()),ne("revert")):I(v=>(O(v.length+1),[...v,{id:"revert-empty-"+Date.now(),role:"system",text:`\u2726 Nothing to revert to.
|
|
77
|
+
\u2800`,isMeta:!0}]))})),f})}}if(lt.length>0&&St==="chat"&&B===-1){if(o.upArrow){Oe(c=>{let f=c>0?c-1:lt.length-1,x=0;for(;f!==c&&x<lt.length;){let v=lt[f],u=v?.cmd||v||"";if(typeof u=="string"&&u.trimStart().startsWith("---"))f=f>0?f-1:lt.length-1,x++;else break}return f});return}if(o.downArrow){Oe(c=>{let f=c<lt.length-1?c+1:0,x=0;for(;f!==c&&x<lt.length;){let v=lt[f],u=v?.cmd||v||"";if(typeof u=="string"&&u.trimStart().startsWith("---"))f=f<lt.length-1?f+1:0,x++;else break}return f});return}if(o.return)return}if(o.tab&&St==="chat"){if(lt.length>0){let c=lt[De]||lt[0],f=y.split(" ");if(f.length===1)b(c.cmd+" ");else{let x=f.slice(0,-1);b(x.join(" ")+" "+c.cmd+" ")}Oe(0),A(x=>x+1);return}else if(y.trim()===""){let c=Date.now();if(c-Ye.current<500)return;Ye.current=c;let f=["Flux","Flow","ICU","FluxCU"],x=(f.indexOf(Y)+1)%f.length,v=f[x>=0?x:0];le(v),I(u=>[...u,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${Ci(v)}
|
|
78
78
|
\u2800`,isMeta:!0}]);return}}if(o.ctrl&&n==="c"&&St!=="exit"){if(y.length>0){b("");return}if(o.shift){ne("exit"),S(!1);return}d?(ne("exit"),S(!1)):S(!0)}o.return&&(o.shift||o.ctrl||o.meta||o.leftAlt||o.rightAlt)&&b(c=>c.replace(/\\\r?$/,"").replace(/\r?$/,"")+`
|
|
79
|
-
`)}}),gt(()=>{process.stdout.write("\x1B[?1004h");let n=o=>{let c=o.toString();c.includes("\x1B[I")?(tt(!0),ro.current=Date.now()):c.includes("\x1B[O")&&(tt(!1),ro.current=Date.now())};return process.stdin.on("data",n),()=>{process.stdout.write("\x1B[?1004l"),process.stdin.off("data",n)}},[]);let Gr=Re(de.theme);gt(()=>{Gr.current&&Gr.current!==de.theme?(Gr.current=de.theme,r&&(r.write("\x1B[2J\x1B[3J\x1B[H"),r.isTTY&&r.write("\x1B[?2004h")),Ys(n=>n+1),Wo()):Gr.current=de.theme},[de.theme,r]),gt(()=>{async function n(){Yl(M=>{let N=M?.reason||"cwd_mismatch";re.current=N,Ne(!1),ge.current||Fe(N)});try{let M=JSON.parse(pt.readFileSync(Ct.join(process.cwd(),"package.json"),"utf8"));
|
|
80
|
-
\u2800`,isMeta:!0}])));let o=await
|
|
79
|
+
`)}}),gt(()=>{process.stdout.write("\x1B[?1004h");let n=o=>{let c=o.toString();c.includes("\x1B[I")?(tt(!0),ro.current=Date.now()):c.includes("\x1B[O")&&(tt(!1),ro.current=Date.now())};return process.stdin.on("data",n),()=>{process.stdout.write("\x1B[?1004l"),process.stdin.off("data",n)}},[]);let Gr=Re(de.theme);gt(()=>{Gr.current&&Gr.current!==de.theme?(Gr.current=de.theme,r&&(r.write("\x1B[2J\x1B[3J\x1B[H"),r.isTTY&&r.write("\x1B[?2004h")),Ys(n=>n+1),Wo()):Gr.current=de.theme},[de.theme,r]),gt(()=>{async function n(){Yl(M=>{let N=M?.reason||"cwd_mismatch";re.current=N,Ne(!1),ge.current||Fe(N)});try{let M=JSON.parse(pt.readFileSync(Ct.join(process.cwd(),"package.json"),"utf8"));si(ho||M.version||"2.0.0")}catch{si("2.0.0")}process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07")),await $a()||(I(M=>(O(M.length+1),[...M,{id:"setup-"+Date.now(),role:"system",text:"\u2726 Installing Required dependencies... (One-time setup)",isMeta:!0}])),await Ua(),I(M=>(O(M.length+1),[...M,{id:"setup-done-"+Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m All dependencies installed successfully.
|
|
80
|
+
\u2800`,isMeta:!0}])));let o=await ti();Os.current=o.systemSettings?.allowExternalAccess??!1,Ns.current=o.systemSettings?.memory??!0,_e.mode?le(_e.mode):le(o.mode),oe(o.display??0),_e.thinking?no(_e.thinking):no(o.thinkingLevel);let c=_e.provider||o.aiProvider||"Google";zo(c);let x=(o.quotas?.providerTiers||{})[c]||o.apiTier||"Free";if(me.current=o.activeModel,_e.model)Gt(_e.model);else if(_e.provider){let M=ao(c,x);Gt(M)}else Gt(o.activeModel);ys(o.showFullThinking),Ht(x),po(o.quotas||{limitMode:"Daily",agentLimit:99999999,tokenLimit:99999999999999,backgroundLimit:999999,searchLimit:100,customModelId:"",customLimit:0,providerBudgets:{}});let v={memory:!0,compression:0,autoExec:!1,autoDeleteHistory:"7d",autoUpdate:!1,updateManager:"npm",customUpdateCommand:"",...o.systemSettings||{}};_e.memory==="on"?v.memory=!0:_e.memory==="off"&&(v.memory=!1),c==="NVIDIA"&&process.env.NVIDIA_BASE_URL&&(v.memory=!1,I(M=>[...M,{role:"system",text:`\u2726 MEMORY
|
|
81
81
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Currently not available.
|
|
82
82
|
\u2800`,isMeta:!0}])),_e.package&&(v.updateManager=_e.package),_e.autoDel&&(v.autoDeleteHistory=_e.autoDel),_e.autoExec==="on"?v.autoExec=!0:_e.autoExec==="off"&&(v.autoExec=!1),_e.externalAccess==="on"?v.allowExternalAccess=!0:_e.externalAccess==="off"&&(v.allowExternalAccess=!1),_e.playground&&(v.allowExternalAccess=!1,v.memory=!1),Ot(v),vs(o.profileData),$r(o.imageSettings||{keyType:"Default",quality:"Low-High",apiKey:""}),Bs({enabled:!1,model:"Default",provider:"",baseUrl:"",...o.autoCompletion||{}});let u=_e.key;if(u||(u=await on(c)),c==="c_openai"){let M=u||"";Pt(M),xo(M,{aiProvider:c,onIDEApproval:Io})}else u&&(Pt(u),xo(u,{aiProvider:c,onIDEApproval:Io}));if(o.systemSettings?.autoDeleteHistory&&ql(o.systemSettings.autoDeleteHistory),_e.playground||(os(Xn).catch(()=>{}),pt.remove(Ct.join(ko,"playground")).catch(()=>{})),Bt(!1,v),await Promise.all([Fl(),wr.recoverCrashedTransaction()]),_e.resume){let M=await Go(),N=_e.resume;if(M[N]){Ho.current=!0,Wr(N);let H=await yr(N);Pn.current=io-H.total,Nn.current=wo,$n.current=hn,zt.current=[],Ln(H.total),On(0),gn(0),Fn(0),Zo({tokens:H.context}),Ho.current=!1;let K=[...M[N].messages];K[0]?.text?.includes("\u2591\u2591\u2591\u2588\u2588\u2588")||K.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),I(K),ne("chat"),I(V=>{let ee=[...V,{id:"sys-"+Date.now(),role:"system",text:`\u2726 SESSION RESUMED
|
|
83
83
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m '${N}'.
|
|
@@ -86,11 +86,11 @@ Remove-Item -Path '${Da.replace(/'/g,"''")}' -Recurse -Force -ErrorAction Silent
|
|
|
86
86
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m CWD locked to: '${M}'.
|
|
87
87
|
\u2800`,isMeta:!0}];return O(V.length),V})}else I(H=>{let K=[...H,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND Mode active
|
|
88
88
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m CWD locked to: 'FluxFlow/playground'.
|
|
89
|
-
\u2800`,isMeta:!0}];return O(K.length),K})}let a=cn();if(!["Terminal","Windows Terminal"].includes(a)){let M=Ka(a);if(M)try{let N=[];if(pt.existsSync(M)){let H=pt.readFileSync(M,"utf8").trim();H&&(N=Va(H))}au(N)?Ts="Shift + Enter":ne("keybindingsPrompt")}catch{}}at(!1)}n()},[]),gt(()=>{let n;return d&&(p(10),n=setInterval(()=>{p(o=>o<=1?(S(!1),0):o-1)},1e3)),()=>{n&&clearInterval(n)}},[d]),gt(()=>{if(!Pe){let n=_e.model&&je===_e.model?me.current:je,o=de;_e.playground&&(o={...de,allowExternalAccess:Os.current,memory:Ns.current}),Kt({mode:Y,thinkingLevel:We,aiProvider:F,activeModel:n||je,showFullThinking:un,systemSettings:o,profileData:fn,imageSettings:_o,autoCompletion:nr,apiTier:ze})}},[Y,We,F,je,un,de,fn,_o,nr,Pe,_e,ze]);let
|
|
89
|
+
\u2800`,isMeta:!0}];return O(K.length),K})}let a=cn();if(!["Terminal","Windows Terminal"].includes(a)){let M=Ka(a);if(M)try{let N=[];if(pt.existsSync(M)){let H=pt.readFileSync(M,"utf8").trim();H&&(N=Va(H))}au(N)?Ts="Shift + Enter":ne("keybindingsPrompt")}catch{}}at(!1)}n()},[]),gt(()=>{let n;return d&&(p(10),n=setInterval(()=>{p(o=>o<=1?(S(!1),0):o-1)},1e3)),()=>{n&&clearInterval(n)}},[d]),gt(()=>{if(!Pe){let n=_e.model&&je===_e.model?me.current:je,o=de;_e.playground&&(o={...de,allowExternalAccess:Os.current,memory:Ns.current}),Kt({mode:Y,thinkingLevel:We,aiProvider:F,activeModel:n||je,showFullThinking:un,systemSettings:o,profileData:fn,imageSettings:_o,autoCompletion:nr,apiTier:ze})}},[Y,We,F,je,un,de,fn,_o,nr,Pe,_e,ze]);let ll=async n=>{let o=n.trim(),c={Google:{prefix:"",minLength:0},OpenRouter:{prefix:"",minLength:0},DeepSeek:{prefix:"",minLength:0},Mistral:{prefix:"",minLength:0},NVIDIA:{prefix:"",minLength:0},Ollama:{prefix:"",minLength:0},InferX:{prefix:"",minLength:0},SenseNova:{prefix:"",minLength:0},AIHubMix:{prefix:"",minLength:0},Poolside:{prefix:"",minLength:0},"9router":{prefix:"",minLength:0},ExpLabs:{prefix:"",minLength:0},TokenHarbor:{prefix:"",minLength:0},Infron:{prefix:"",minLength:0},APInex:{prefix:"",minLength:0},xKiro:{prefix:"",minLength:0}},{prefix:f,minLength:x}=c[F]??{prefix:"",minLength:0},v=(F==="Ollama"||F==="9router")&&(o.trim()==="LOCAL"||o.trim()===""),u=F==="c_openai",a=v?"LOCAL":o;if(u){let h=o.trim().replace(/\/+$/,""),M={...de,customOpenAIBaseUrl:h,memory:!1};Ot(M);let H=await on("c_openai")||"";Pt(H),xo(H,{aiProvider:"c_openai",onIDEApproval:Io});let K=ao("c_openai",ze)||"";Gt(K),await Kt({mode:Y,thinkingLevel:We,aiProvider:"c_openai",activeModel:K,showFullThinking:un,systemSettings:M,profileData:fn,imageSettings:_o,autoCompletion:nr,apiTier:ze}),I(q=>[...q,{role:"system",text:`\u2726 Custom (OpenAI) Base URL saved!
|
|
90
90
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Endpoint: ${h}${K?`
|
|
91
91
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: ${K}`:""}
|
|
92
92
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with Custom (OpenAI).
|
|
93
|
-
\u2800`,isMeta:!0}]),xn("");return}if(v||o.startsWith(f)&&o.length>=x){await
|
|
93
|
+
\u2800`,isMeta:!0}]),xn("");return}if(v||o.startsWith(f)&&o.length>=x){await ei(F,a),Pt(a),xo(a,{aiProvider:F,onIDEApproval:Io});let h="gemma-4-31b-it";F==="OpenRouter"?h="google/gemma-4-31b-it:free":F==="DeepSeek"?h="deepseek-v4-flash":F==="NVIDIA"?h="deepseek-ai/deepseek-v4-flash":F==="Ollama"||F==="9router"?h=je||"":(F==="InferX"||F==="SenseNova"||F==="AIHubMix"||F==="Poolside"||F==="ExpLabs"||F==="TokenHarbor"||F==="Infron"||F==="APInex"||F==="xKiro")&&(h=ao(F,ze)||""),Gt(h);let M={...de};v&&F==="Ollama"&&(M={...M,ollamaEndpoint:"Local"},Ot(M)),(F==="Ollama"||F==="InferX"||F==="SenseNova"||F==="AIHubMix"||F==="Poolside"||F==="9router"||F==="ExpLabs"||F==="TokenHarbor"||F==="Infron"||F==="APInex"||F==="xKiro")&&(M={...M,memory:!1},Ot(M));let N="";if(F==="9router"){let H=await yi();H.ok||(N=`
|
|
94
94
|
|
|
95
95
|
\x1B[33m\u2726 WARNING: 9router does not appear to be running on ${H.url}.\x1B[39m
|
|
96
96
|
\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`)}I(H=>[...H,{role:"system",text:`\u2726 ${F} API Key saved successfully! ${h?`
|
|
@@ -101,8 +101,8 @@ Remove-Item -Path '${Da.replace(/'/g,"''")}' -Recurse -Force -ErrorAction Silent
|
|
|
101
101
|
\u2726\u2800`}${F==="Ollama"||F==="InferX"||F==="SenseNova"||F==="AIHubMix"||F==="Poolside"||F==="9router"||F==="ExpLabs"||F==="TokenHarbor"||F==="Infron"||F==="APInex"||F==="xKiro"?`Memory is not available with ${F}.
|
|
102
102
|
\u2514\u2500\u2800`:""}Initialization complete.${N}
|
|
103
103
|
\u2800`,isMeta:!0}])}else I(h=>[...h,{role:"system",text:`\u2726 INVALID KEY
|
|
104
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${F} API key must start with "${f}" and be at least ${x} characters long.`,isMeta:!0}]),xn("")},Kr=Re(
|
|
105
|
-
\u2800`,isMeta:!0}]))})}catch{}return()=>{try{
|
|
104
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${F} API key must start with "${f}" and be at least ${x} characters long.`,isMeta:!0}]),xn("")},Kr=Re(Mi);gt(()=>{if(St==="exit"){(async()=>{let c=Date.now(),f=Math.floor((c-Kr.current)/1e3);f>=1&&(await Sn("duration",f),Kr.current+=f*1e3),await Nl()})();let o=setTimeout(()=>{process.exit(0)},50);return()=>clearTimeout(o)}},[St]),gt(()=>{try{Rs(n=>{I(o=>(O(o.length+1),[...o,{id:"keynotice-"+Date.now(),role:"system",text:`\u2726 ${n}
|
|
105
|
+
\u2800`,isMeta:!0}]))})}catch{}return()=>{try{Rs(null)}catch{}}},[]),gt(()=>{let n=setInterval(async()=>{if(!Pe){let o=Date.now(),c=Math.floor((o-Kr.current)/1e3);c>=1&&(await Sn("duration",c),Kr.current+=c*1e3),Ol()}},5e3);return()=>clearInterval(n)},[Pe]);let al=[{cmd:"/quit",desc:"Exit and shutdown Flux"},{cmd:"/kill",desc:"Kill a process by PID",subs:In.map(n=>{let o;return n.isRoot?o="FluxFlow":n.url&&(n.url.includes(":52991")||n.url.includes(":52145")||n.url.includes(":52140"))?o="Internal":o=n.url||n.name,{cmd:String(n.pid),display:`PID: ${n.pid}`,rightDesc:o,desc:o}})},{cmd:"/help",desc:"Show all available commands"},..._e.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:"/meow",desc:"Cat nonsense, delivered straight to the terminal"},...process.env.HALLOWEEN_EEGG==="true"||process.env.HALLOWEEN_EEGG===!0?[{cmd:"/trick-or-treat",desc:"Halloween surprise: Trick or Treat!"}]:[],{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:to(F,je,"Low")!==null?`Low (${to(F,je,"Low")})`:"Low",desc:"Quick Reasoning"},{cmd:"Medium",display:to(F,je,"Medium")!==null?`Medium (${to(F,je,"Medium")})`:"Medium",desc:"Balanced Reasoning"},{cmd:"High",display:to(F,je,"High")!==null?`High (${to(F,je,"High")})`:"High",desc:"Deep Reasoning"},{cmd:"custom",display:to(F,je,"xHigh")!==null?`Custom (${to(F,je,"xHigh")})`:"Custom",desc:"Custom Reasoning Value"}]},{cmd:"/model",desc:"Select Agent Model",subs:Y==="ICU"||Y.toLowerCase()==="fluxcu"?tn(F,ze,de?.customOpenAIBaseUrl).filter(n=>Jr(n.cmd||n)):tn(F,ze,de?.customOpenAIBaseUrl)},{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",subs:[{cmd:"list",desc:"List saved keys"},{cmd:"add",desc:"Add a key"},{cmd:"remove",desc:"Remove a key"},{cmd:"use",desc:"Select active key"},{cmd:"clean",desc:"Remove gaps between slots"}]},{cmd:"/files",desc:"List loaded instruction and skill files"},{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"}]}],cl=async(n,o=!1)=>{if(!o&<.length>0){let x=lt[De]||lt[0],v=n.split(" "),u=v.length===1?x.cmd:v.slice(0,-1).join(" ")+" "+x.cmd;if(u.trim()!==n.trim()){b(u+" "),Oe(0),A(a=>a+1);return}}Gs.current=!1;let c=n.replace(/\r\n/g,`
|
|
106
106
|
`).replace(/\r/g,`
|
|
107
107
|
`).trimEnd();if(c.endsWith("\\")){b(c.slice(0,-1)+`
|
|
108
108
|
`);return}let f=c.replace(/\\\s*\n/g,`
|
|
@@ -111,7 +111,7 @@ Remove-Item -Path '${Da.replace(/'/g,"''")}' -Recurse -Force -ErrorAction Silent
|
|
|
111
111
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Inquiry question must be more than 3 characters.
|
|
112
112
|
\u2800`,isMeta:!0}])),b("");return}}else if(x.startsWith("/")){I(v=>(O(v.length+1),[...v,{id:"hint-err-"+Date.now(),role:"system",text:`\u2726 RESTRICTED
|
|
113
113
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Steering Hints cannot start with '/'.
|
|
114
|
-
\u2800`,isMeta:!0}])),b("");return}Ks(x),Xo.current=x,b("");return}if(!
|
|
114
|
+
\u2800`,isMeta:!0}])),b("");return}Ks(x),Xo.current=x,b("");return}if(!Ke&&!(F==="c_openai"&&de.customOpenAIBaseUrl)){ll(f),xn("");return}if(f.startsWith("/")){b("");let x=f.split(" "),v=x[0]?.toLowerCase();switch(v){case"/quit":{ne("exit");break}case"/resume":{if(x[1]){let u=x[1];(async()=>{let h=await Go(),M=h[u]||Object.values(h).find(N=>N.name.toLowerCase()===u.toLowerCase());if(M){if(r.write("\x1B[2J\x1B[3J\x1B[H"),process.stdout.isTTY){let q=M?.name||"",V=q&&!q.startsWith("flow-")&&!q.startsWith("Session ")?q:"FluxFlow | Resumed";process.stdout.write(`\x1B]0;${V}\x07`),process.stdout.write(`\x1B]633;P;TerminalTitle=${V}\x07`)}Wo(),Ho.current=!0,Wr(u);let N=await yr(u);Pn.current=io-N.total,Nn.current=wo,$n.current=hn,zt.current=[],Ln(N.total),On(0),gn(0),Fn(0),Zo({tokens:N.context}),Ho.current=!1;let H=[...M.messages];H[0]?.text?.includes("\u2591\u2591\u2591\u2588\u2588\u2588")||H.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),I(H),I(q=>[...q,{id:"sys-"+Date.now(),role:"system",text:`\u2726 SESSION RESUMED
|
|
115
115
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${u}.
|
|
116
116
|
\u2800`,isMeta:!0}]),O(0)}else I(N=>[...N,{id:"err-"+Date.now(),role:"system",text:`\u2726 ERROR: Session [${u}] not found.
|
|
117
117
|
\u2800`,isMeta:!0}])})()}else ne("resume");break}case"/move":{if(!_e.playground){I(M=>(O(M.length+1),[...M,{id:Date.now(),role:"system",text:`\u2726 RESTRICTED
|
|
@@ -127,8 +127,8 @@ Remove-Item -Path '${Da.replace(/'/g,"''")}' -Recurse -Force -ErrorAction Silent
|
|
|
127
127
|
`,isMeta:!0}]))}})();break}case"/clear":{if(r&&(r.write("\x1B[2J\x1B[3J\x1B[H"),r.isTTY&&(r.write("\x1B[?2004h"),process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07"))),I([{id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}]),O(1),Ys(u=>u+1),Wo(),lo.current={completedIndex:0,columns:X.columns,historicalBlocks:[],seenSelections:new Set,chatId:bt,clearKey:Tn+1},_e.playground){if(_e.playground=!1,os(Xn).catch(()=>{}),_e.originalCwd)try{process.chdir(_e.originalCwd),I(u=>{let a=[...u,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND
|
|
128
128
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Restored Working Directory to ${_e.originalCwd}
|
|
129
129
|
\u2800`,isMeta:!0}];return O(a.length),a})}catch{}setTimeout(()=>{pt.emptyDir(Ct.join(ko,"playground")).catch(u=>{I(a=>{let h=[...a,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND
|
|
130
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Failed to clear session: ${ko+"/playground"}`,isMeta:!0}];return O(h.length),h})})},500),Ot(u=>({...u,allowExternalAccess:Os.current,memory:Ns.current}))}Wr(
|
|
131
|
-
\u2800`,isMeta:!0}]))}}),setTimeout(()=>{global.gc&&(async()=>{for(let a=0;a<3;a++)global.gc(),await new Promise(h=>setImmediate(h));g.current=Date.now()})()},500);break}case"/mode":{if(x[1]){let u=x[1].toLowerCase(),a="Flux";u==="flow"?a="Flow":u==="icu"?a="ICU":u==="fluxcu"?a="FluxCU":u==="flux"&&(a="Flux"),le(a);let h=yt(2);I(M=>(O(M.length+1),[...M,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${
|
|
130
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Failed to clear session: ${ko+"/playground"}`,isMeta:!0}];return O(h.length),h})})},500),Ot(u=>({...u,allowExternalAccess:Os.current,memory:Ns.current}))}Wr(ii()),Zo({tokens:0}),z(!1),Ln(0),On(0),gn(0),Fn(0),zt.current=[],Pn.current=io,Nn.current=wo,$n.current=hn,setTimeout(()=>{global.gc&&(async()=>{for(let a=0;a<3;a++)global.gc(),await new Promise(h=>setImmediate(h));g.current=Date.now()})()},500);break}case"/revert":{wr.getChatHistory(bt).then(u=>{if(u.length>0)el(u.reverse()),ne("revert");else{let a=yt(2);I(h=>(O(h.length+1),[...h,{id:"revert-empty-"+Date.now(),role:"system",text:`\u2726 Nothing to revert to.
|
|
131
|
+
\u2800`,isMeta:!0}]))}}),setTimeout(()=>{global.gc&&(async()=>{for(let a=0;a<3;a++)global.gc(),await new Promise(h=>setImmediate(h));g.current=Date.now()})()},500);break}case"/mode":{if(x[1]){let u=x[1].toLowerCase(),a="Flux";u==="flow"?a="Flow":u==="icu"?a="ICU":u==="fluxcu"?a="FluxCU":u==="flux"&&(a="Flux"),le(a);let h=yt(2);I(M=>(O(M.length+1),[...M,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${Ci(a)}.
|
|
132
132
|
\u2800`,isMeta:!0}]))}else ne("mode");break}case"/display":{if(x[1]){let u=x[1].toLowerCase(),a=0;u==="secondary"||u==="1"||u==="2"?a=1:a=0,oe(a),Kt({display:a}).catch(()=>{});let h=a===0?"Primary (Display 1)":"Secondary (Display 2)";I(M=>(O(M.length+1),[...M,{id:Date.now(),role:"system",text:`\u2726 Active Computer Use display set to: ${h}.
|
|
133
133
|
\u2800`,isMeta:!0}]))}else ne("display");break}case"/image_deprecated":{if(x[1]?.toLowerCase()==="stats"){let u=yt(2);if(_o.keyType==="Custom")I(a=>(O(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}])),$o("start https://enter.pollinations.ai/#pollen");else try{let a=await $l();I(h=>(O(h.length+1),[...h,{id:Date.now(),role:"system",isImageStats:!0,text:`\u2022 Hourly Limit: ${Number((a.limit*1e3).toFixed(0))} credits
|
|
134
134
|
\u2022 Spent (Last 1hr): ${Number((a.totalSpent*1e3).toFixed(0))} credits
|
|
@@ -158,23 +158,23 @@ Remove-Item -Path '${Da.replace(/'/g,"''")}' -Recurse -Force -ErrorAction Silent
|
|
|
158
158
|
\u2800${q}.`,isMeta:!0}]));else{no(u);let V=yt(1),ee=u==="xHigh"?to(F,je,"xHigh")!==null?`Custom (${to(F,je,"xHigh")})`:"Custom":u;I(te=>(O(te.length+1),[...te,{id:Date.now(),role:"system",text:`\u2726 ${F}
|
|
159
159
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${je}.
|
|
160
160
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Thinking Level: ${ee}.
|
|
161
|
-
${q} \u2800`,isMeta:!0}]))}}else ne("thinking");break}case"/model":{if(x[1]){let u=x.slice(1).join(" "),a=null,h=!1,M=null,N=u,H=/(?:^|\s)(?:--info|-i)(?:\s+(?:"([^"]*)"|'([^']*)'|\{([^}]*)\}|((?:(?!--[a-z]|-[a-z]\b).)+)))?(?=\s+--|\s+-[a-z]\b|$)/i,K=N.match(H);if(K){if(M=(K[1]??K[2]??K[3]??K[4]??"").trim(),N=(N.slice(0,K.index)+" "+N.slice(K.index+K[0].length)).trim(),M==="0")h=!0,a=null;else if(a={},M){let ue=M.split(",");for(let pe of ue){let Ze=pe.trim().match(/^(IN|OUT|CR|CW)\s+([0-9]*\.?[0-9]+)$/i);Ze&&(a[Ze[1].toUpperCase()]=parseFloat(Ze[2]))}}}let q=N.split(/\s+/).filter(Boolean),V=q.some(ue=>ue==="--multimodal"||ue==="-m"||ue==="--vision"||ue==="-v"),ee=q.some(ue=>ue==="--save"||ue==="-sv"||ue==="--add"),te=q.some(ue=>ue==="--remove"||ue==="-rm"),U=q.some(ue=>ue==="--rename"||ue==="-rn"||ue==="-mv"),et=q.some(ue=>ue==="--default"||ue==="-df"),Ue=q.some(ue=>ue==="--price"||ue==="-p"),He=q.some(ue=>ue==="--raw"||ue==="-r"),Qe=q.filter(ue=>!ue.startsWith("-")),
|
|
161
|
+
${q} \u2800`,isMeta:!0}]))}}else ne("thinking");break}case"/model":{if(x[1]){let u=x.slice(1).join(" "),a=null,h=!1,M=null,N=u,H=/(?:^|\s)(?:--info|-i)(?:\s+(?:"([^"]*)"|'([^']*)'|\{([^}]*)\}|((?:(?!--[a-z]|-[a-z]\b).)+)))?(?=\s+--|\s+-[a-z]\b|$)/i,K=N.match(H);if(K){if(M=(K[1]??K[2]??K[3]??K[4]??"").trim(),N=(N.slice(0,K.index)+" "+N.slice(K.index+K[0].length)).trim(),M==="0")h=!0,a=null;else if(a={},M){let ue=M.split(",");for(let pe of ue){let Ze=pe.trim().match(/^(IN|OUT|CR|CW)\s+([0-9]*\.?[0-9]+)$/i);Ze&&(a[Ze[1].toUpperCase()]=parseFloat(Ze[2]))}}}let q=N.split(/\s+/).filter(Boolean),V=q.some(ue=>ue==="--multimodal"||ue==="-m"||ue==="--vision"||ue==="-v"),ee=q.some(ue=>ue==="--save"||ue==="-sv"||ue==="--add"),te=q.some(ue=>ue==="--remove"||ue==="-rm"),U=q.some(ue=>ue==="--rename"||ue==="-rn"||ue==="-mv"),et=q.some(ue=>ue==="--default"||ue==="-df"),Ue=q.some(ue=>ue==="--price"||ue==="-p"),He=q.some(ue=>ue==="--raw"||ue==="-r"),Qe=q.filter(ue=>!ue.startsWith("-")),Ve=(ue=a)=>h?`
|
|
162
162
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Pricing: \x1B[33mReset (info removed)\x1B[0m`:ue?Object.keys(ue).length>0?`
|
|
163
163
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Pricing:
|
|
164
164
|
`+Object.entries(ue).map(([pe,Je])=>` \x1B[2m\u2022\x1B[22m \x1B[36m${pe}\x1B[0m: $${Je}`).join(`
|
|
165
165
|
`):M?`
|
|
166
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Pricing: \x1B[33mNo valid IN, OUT, CR, CW tokens parsed from: "${M}"\x1B[0m`:"":"";if(ee||te||U||et){if(et){let ue=Qe.join(" ").trim();if(!ue)I(pe=>(O(pe.length+1),[...pe,{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 pe=
|
|
166
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Pricing: \x1B[33mNo valid IN, OUT, CR, CW tokens parsed from: "${M}"\x1B[0m`:"":"";if(ee||te||U||et){if(et){let ue=Qe.join(" ").trim();if(!ue)I(pe=>(O(pe.length+1),[...pe,{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 pe=hl(F,ue,V,a);pe.success?I(Je=>{O(Je.length+1);let Ze=F==="c_openai"?de?.customOpenAIBaseUrl||"Custom Endpoint":F.replace("c_openai","Custom Endpoint");return[...Je,{id:Date.now(),role:"system",text:`\u2726 Default Model Set:
|
|
167
167
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${Ze}
|
|
168
168
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Default Model: \x1B[32m${ue}\x1B[0m
|
|
169
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Multimodal: ${V?"ON":"OFF"}${
|
|
170
|
-
\u2800`,isMeta:!0}]}):I(Je=>(O(Je.length+1),[...Je,{id:Date.now(),role:"system",text:`\x1B[31m[Error]\x1B[0m Failed to set default model: ${pe.reason}`,isMeta:!0}]))}}else if(ee){let ue=Qe.join(" ").trim();if(!ue)I(pe=>(O(pe.length+1),[...pe,{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 pe=F==="c_openai"?de.customOpenAIBaseUrl:null,Je=
|
|
169
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Multimodal: ${V?"ON":"OFF"}${Ve()}
|
|
170
|
+
\u2800`,isMeta:!0}]}):I(Je=>(O(Je.length+1),[...Je,{id:Date.now(),role:"system",text:`\x1B[31m[Error]\x1B[0m Failed to set default model: ${pe.reason}`,isMeta:!0}]))}}else if(ee){let ue=Qe.join(" ").trim();if(!ue)I(pe=>(O(pe.length+1),[...pe,{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 pe=F==="c_openai"?de.customOpenAIBaseUrl:null,Je=fl(F,ue,V,a,pe);Je.success?I(Ze=>(O(Ze.length+1),[...Ze,{id:Date.now(),role:"system",text:`\u2726 Model Saved:
|
|
171
171
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${F}
|
|
172
172
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: \x1B[32m${ue}\x1B[0m
|
|
173
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Multimodal: ${V?"ON":"OFF"}${
|
|
174
|
-
\u2800`,isMeta:!0}])):I(Ze=>(O(Ze.length+1),[...Ze,{id:Date.now(),role:"system",text:`\x1B[31m[Error]\x1B[0m Failed to save model: ${Je.reason}`,isMeta:!0}]))}}else if(te){let ue=Qe.join(" ").trim();if(!ue)I(pe=>(O(pe.length+1),[...pe,{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 pe=
|
|
173
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Multimodal: ${V?"ON":"OFF"}${Ve()}
|
|
174
|
+
\u2800`,isMeta:!0}])):I(Ze=>(O(Ze.length+1),[...Ze,{id:Date.now(),role:"system",text:`\x1B[31m[Error]\x1B[0m Failed to save model: ${Je.reason}`,isMeta:!0}]))}}else if(te){let ue=Qe.join(" ").trim();if(!ue)I(pe=>(O(pe.length+1),[...pe,{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 pe=pl(F,ue);pe.success?I(Je=>(O(Je.length+1),[...Je,{id:Date.now(),role:"system",text:`\u2726 Model Removed:
|
|
175
175
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${F}
|
|
176
176
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: \x1B[31m${ue}\x1B[0m
|
|
177
|
-
\u2800`,isMeta:!0}])):I(Je=>(O(Je.length+1),[...Je,{id:Date.now(),role:"system",text:`\x1B[31m[Error]\x1B[0m Failed to remove model: ${pe.reason}`,isMeta:!0}]))}}else if(U)if(Qe.length<2)I(ue=>(O(ue.length+1),[...ue,{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 ue=Qe[0].trim(),pe=Qe.slice(1).join(" ").trim(),Je=
|
|
177
|
+
\u2800`,isMeta:!0}])):I(Je=>(O(Je.length+1),[...Je,{id:Date.now(),role:"system",text:`\x1B[31m[Error]\x1B[0m Failed to remove model: ${pe.reason}`,isMeta:!0}]))}}else if(U)if(Qe.length<2)I(ue=>(O(ue.length+1),[...ue,{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 ue=Qe[0].trim(),pe=Qe.slice(1).join(" ").trim(),Je=bl(F,ue,pe);Je.success?I(Ze=>(O(Ze.length+1),[...Ze,{id:Date.now(),role:"system",text:`\u2726 Model Renamed:
|
|
178
178
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${F}
|
|
179
179
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Old Model: \x1B[31m${ue}\x1B[0m
|
|
180
180
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m New Model: \x1B[32m${pe}\x1B[0m
|
|
@@ -188,8 +188,8 @@ ${q} \u2800`,isMeta:!0}]))}}else ne("thinking");break}case"/model":{if(x[1]){let
|
|
|
188
188
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model ID: \x1B[32m${ue}\x1B[0m${W}
|
|
189
189
|
\u2800`,isMeta:!0}]));break}if(a!==null||h){let ue=Qe.join(" ").trim();if(!ue)I(pe=>(O(pe.length+1),[...pe,{id:Date.now(),role:"system",text:'\x1B[31m[Error]\x1B[0m Please provide a model ID. Example: /model <id> -i "IN 0.15, OUT 0.6, CR 0.05, CW 0.1"',isMeta:!0}]));else{h?Qs(F,ue,null):Object.keys(a).length>0&&Qs(F,ue,a);let pe=h?null:hr(F,ue),Je=F==="c_openai"?de?.customOpenAIBaseUrl||"Custom Endpoint":F.replace("c_openai","Custom Endpoint");I(Ze=>(O(Ze.length+1),[...Ze,{id:Date.now(),role:"system",text:`\u2726 Model Info ${h?"Reset":"Saved"}:
|
|
190
190
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${Je}
|
|
191
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model ID: \x1B[32m${ue}\x1B[0m${
|
|
192
|
-
\u2800`,isMeta:!0}]))}break}let it=Qe.join(" ").trim();if(
|
|
191
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model ID: \x1B[32m${ue}\x1B[0m${Ve(pe||a)}
|
|
192
|
+
\u2800`,isMeta:!0}]))}break}let it=Qe.join(" ").trim();if(wl(V),it){V&&gl(F,it,!0);let ue=ao("Google","Free"),pe=ao("Google","Paid");{Gt(it);let Je=V||Jr(it),Ze=We==="xHigh"?to(F,it,"xHigh")!==null?`Custom (${to(F,it,"xHigh")})`:"Custom":We,W=F==="c_openai"?de?.customOpenAIBaseUrl||"Custom Endpoint":F.replace("c_openai","Custom Endpoint");I(ye=>(O(ye.length+1),[...ye,{id:Date.now(),role:"system",text:`\u2726 ${W}
|
|
193
193
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${it}
|
|
194
194
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Thinking Level: ${Ze}
|
|
195
195
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Multimodal: ${Je?"ON":"OFF"}
|
|
@@ -198,7 +198,7 @@ ${q} \u2800`,isMeta:!0}]))}}else ne("thinking");break}case"/model":{if(x[1]){let
|
|
|
198
198
|
\u2800`,isMeta:!0}])),a});break}case"/wildercard-tooling":{T(u=>{let a=!u;return I(h=>(O(h.length+1),[...h,{id:Date.now(),role:"system",text:`\u2726 Wildercard Tooling:
|
|
199
199
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Status: ${a?"Enabled":"Disabled"}
|
|
200
200
|
\u2800`,isMeta:!0}])),a});break}case"/settings":{ne("settings");break}case"/provider":case"/providers":{Ms("chat"),ne("selectProvider");break}case"/theme":{ne("theme");break}case"/key":{(async()=>{try{let a=x.slice(1).join(" "),h=await Ba(a,{currentProvider:F}),M=(h.lines||[]).join(`
|
|
201
|
-
`);M&&I(N=>(O(N.length+1),[...N,{id:Date.now(),role:"system",text:M,isMeta:!0}])),h.switchedBaseUrl&&Ot(N=>({...N,customOpenAIBaseUrl:h.switchedBaseUrl,memory:!1})),h.switchedKey!==void 0&&(Pt(h.switchedKey),xo(h.switchedKey,{aiProvider:F,onIDEApproval:Io})),h.promptNewKey&&(Pt(null),ne("chat"))}catch(a){I(h=>(O(h.length+1),[...h,{id:Date.now(),role:"system",text:`\u2726 Key command error: ${a.message}`,isMeta:!0}]))}})();break}case"/stats":{(async()=>{let a=await Zr(),h=await Rr();Is(a),ks(h),sr("daily"),ne("stats")})();break}case"/usage":{(async()=>{try{let{openUsageDashboard:a}=await import("./usageServer-
|
|
201
|
+
`);M&&I(N=>(O(N.length+1),[...N,{id:Date.now(),role:"system",text:M,isMeta:!0}])),h.switchedBaseUrl&&Ot(N=>({...N,customOpenAIBaseUrl:h.switchedBaseUrl,memory:!1})),h.switchedKey!==void 0&&(Pt(h.switchedKey),xo(h.switchedKey,{aiProvider:F,onIDEApproval:Io})),h.promptNewKey&&(Pt(null),ne("chat"))}catch(a){I(h=>(O(h.length+1),[...h,{id:Date.now(),role:"system",text:`\u2726 Key command error: ${a.message}`,isMeta:!0}]))}})();break}case"/stats":{(async()=>{let a=await Zr(),h=await Rr();Is(a),ks(h),sr("daily"),ne("stats")})();break}case"/usage":{(async()=>{try{let{openUsageDashboard:a}=await import("./usageServer-HBVYDUQK.js"),{url:h}=await a();I(M=>(O(M.length+1),[...M,{id:Date.now(),role:"system",text:`\u2726 Launching Token Analytics Dashboard
|
|
202
202
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Serving at ${h}
|
|
203
203
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Opening in your default browser...
|
|
204
204
|
\u2800`,isMeta:!0}]))}catch(a){I(h=>(O(h.length+1),[...h,{id:Date.now(),role:"system",text:`\u2726 ERROR
|
|
@@ -230,13 +230,13 @@ ${h}
|
|
|
230
230
|
\u2800`}]))}})();break}case"/about":{let u=yt(2),a=`\u2022 FluxFlow Version: v${ho}
|
|
231
231
|
\u2022 Status: ${dn&&dn!==ho?`Update Available [v${dn}]`:"Up to date"}
|
|
232
232
|
\u2022 Released on: ${mu}`;I(h=>(O(h.length+1),[...h,{id:"about-"+Date.now(),role:"system",text:a,isAboutRecord:!0,isMeta:!0}]));break}case"/changelog":{let u=process.platform;$o(`${u==="win32"?"start":u==="darwin"?"open":"xdg-open"} ${Ya}`),I(h=>(O(h.length+1),[...h,{id:Date.now(),role:"system",text:`\u2726 Opening Changelog
|
|
233
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${Ya}.`,isMeta:!0}]));break}case"/docs":{if(!
|
|
234
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Documentation URL is not configured.`,isMeta:!0}]));break}let u=process.platform;$o(`${u==="win32"?"start":u==="darwin"?"open":"xdg-open"} ${
|
|
235
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${
|
|
236
|
-
\u2800`,isMeta:!0}]));break}case"/budget":{let u=x[1]?.toLowerCase();if(u==="web"||u==="gui"||u==="dashboard")(async()=>{try{let{openUsageDashboard:h}=await import("./usageServer-
|
|
233
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${Ya}.`,isMeta:!0}]));break}case"/docs":{if(!Si){I(h=>(O(h.length+1),[...h,{id:Date.now(),role:"system",text:`\u2726 ERROR
|
|
234
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Documentation URL is not configured.`,isMeta:!0}]));break}let u=process.platform;$o(`${u==="win32"?"start":u==="darwin"?"open":"xdg-open"} ${Si}`),I(h=>(O(h.length+1),[...h,{id:Date.now(),role:"system",text:`\u2726 Opening Documentation
|
|
235
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${Si}.
|
|
236
|
+
\u2800`,isMeta:!0}]));break}case"/budget":{let u=x[1]?.toLowerCase();if(u==="web"||u==="gui"||u==="dashboard")(async()=>{try{let{openUsageDashboard:h}=await import("./usageServer-HBVYDUQK.js"),{url:M}=await h();I(N=>(O(N.length+1),[...N,{id:Date.now(),role:"system",text:`\u2726 Token Usage & Budget Dashboard
|
|
237
237
|
\u2800\u2800\u2514\u2500 Opened at ${M}
|
|
238
238
|
\u2800`,isMeta:!0}]))}catch(h){I(M=>(O(M.length+1),[...M,{id:Date.now(),role:"system",text:`\u2726 ERROR: Failed to launch dashboard: ${h.message}
|
|
239
|
-
\u2800`,isMeta:!0}]))}})();else if(u==="set")za("chat"),ne("budgetTypeSelect");else if(u==="view")(async()=>{let h=await Zr(),M=await Rr(),N=await
|
|
239
|
+
\u2800`,isMeta:!0}]))}})();else if(u==="set")za("chat"),ne("budgetTypeSelect");else if(u==="view")(async()=>{let h=await Zr(),M=await Rr(),N=await oi(Ie.resetDay||1);Is(h),ks(M),Ui(N),ne("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",Infron:"Free",APInex:"Free",xKiro:"Free"}};po(a),Ht("Free"),Kt({apiTier:"Free",quotas:a}),I(h=>(O(h.length+1),[...h,{id:Date.now(),role:"system",text:`\u2726 Budgets reset successfully.
|
|
240
240
|
\u2800`,isMeta:!0}]))}else I(a=>(O(a.length+1),[...a,{id:Date.now(),role:"system",text:`\u2726 ERROR
|
|
241
241
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Usage: /budget <View|Web|Set|Reset>.
|
|
242
242
|
\u2800`,isMeta:!0}]));break}case"/fluxflow":{let a=x.slice(1)[0]?.toLowerCase()?.trim();if(a==="global"){let h=Ct.normalize(So);try{pt.ensureDirSync(h)}catch{}let M=process.platform;M==="win32"?$o(`explorer "${h}"`):M==="darwin"?$o(`open "${h}"`):$o(`xdg-open "${h}"`)}else if(a==="saves"){let h=Ct.normalize(ko);try{pt.ensureDirSync(h)}catch{h=Ct.normalize(So);try{pt.ensureDirSync(h)}catch{}}let M=process.platform;M==="win32"?$o(`explorer "${h}"`):M==="darwin"?$o(`open "${h}"`):$o(`xdg-open "${h}"`)}else I(h=>(O(h.length+1),[...h,{id:"ff-err-"+Date.now(),role:"system",text:"Usage: /fluxflow global/saves",isMeta:!0}]));break}case"/update":{if(x[1]?.toLowerCase()==="check"){Bt(!0);break}let a=x.includes("--latest");ne("update");break}case"/gemini":{let u=a=>{let h=a[Math.floor(Math.random()*a.length)];I(M=>(O(M.length+1),[...M,{id:Date.now(),role:"system",text:`\u2728 GEMINI CLI
|
|
@@ -248,10 +248,10 @@ ${h}
|
|
|
248
248
|
\u2800`}]))};ws?u(ws):import("./halloween-EZTJXDUW.js").then(({SPOOKY_LINES:a})=>{ws=a,u(ws)}),b("");break}case"/compress":{b("");let u=Nt.filter(M=>(M.role==="user"||M.role==="agent"||M.role==="system")&&!String(M.id).startsWith("welcome")&&!M.isMeta).length,a=Do?.tokens||0;if(u<64||a<16384){let M=yt(2);I(N=>(O(N.length+1),[...N,{id:Date.now(),role:"system",text:`\u2726 Compression skipped
|
|
249
249
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m History requires at least 64 messages and 16k tokens
|
|
250
250
|
\u2800\u2800 \u2514\u2500 Current: ${u}/64 msgs, ${a}/16384 tokens.
|
|
251
|
-
\u2800`,isMeta:!0}]));break}(async()=>{
|
|
251
|
+
\u2800`,isMeta:!0}]));break}(async()=>{Ji(!0);let M=yt(2);I(N=>(O(N.length+1),[...N,{id:Date.now(),role:"system",text:"\u2726 Compacting session history...",isMeta:!0}]));try{if(await ia({chatId:bt,aiProvider:F,apiKey:Ke,thinkingLevel:We,mode:Y,janitorModel:k,systemSettings:de,sessionStats:Do},Nt)){let K=yt(2);I(q=>{let V=[...q,{id:Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Chat History compacted saving tokens.
|
|
252
252
|
\u2800`,isMeta:!0}];return O(V.length),V})}else I(K=>(O(K.length+1),[...K,{id:Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Compaction failed.
|
|
253
253
|
\u2800`,isMeta:!0}]))}catch(N){I(H=>(O(H.length+1),[...H,{id:Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Error during compaction: ${N.message}
|
|
254
|
-
\u2800`,isMeta:!0}]))}finally{
|
|
254
|
+
\u2800`,isMeta:!0}]))}finally{Ji(!1)}})();break}case"/truncate":{b("");let u=0;I(a=>{let M=[...a.map(N=>{let H=N.fullText||N.text||"";return!H.startsWith("[ACTION RESULT]:")&&!H.startsWith("[TOOL RESULT]:")||H.startsWith("[ACTION RESULT]: Goal")||H.startsWith("[ACTION RESULT]: USER CHOOSE")||H.startsWith("[ACTION RESULT]: Background subagent started. Task ID:")||H.includes("...Success result truncated to save tokens")?N:(u++,{...N,fullText:"[ACTION RESULT]: ...Success result truncated to save tokens"})}),{id:Date.now(),role:"system",text:`\u2726 Tool Truncation...
|
|
255
255
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Truncated ${u} tool result(s).
|
|
256
256
|
\u2800`,isMeta:!0}];return En(bt,null,M),O(M.length),M});break}case"/kill":{(async()=>{let a=x[1]?parseInt(x[1],10):null,{getProcessTree:h,killProcess:M}=await import("./process-6Y7LS2MS.js");if(!a||isNaN(a))I(N=>(O(N.length+1),[...N,{id:Date.now(),role:"system",text:`\u2726 Usage: \x1B[36m/kill <pid>\x1B[0m
|
|
257
257
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Select an active process PID from the autocomplete list.
|
|
@@ -276,58 +276,58 @@ ${x}`};I(a=>{let h=[...a,v];return O(h.length),En(bt,null,h),h}),(async()=>{let
|
|
|
276
276
|
\x1B[33m\u24D8 Request Cancelled\x1B[0m`,isMeta:!1}];return O(ee.length),ee}))},M=!1;Ws(!0),Es(Date.now()),z(!1);let N=Date.now(),H=!0;try{let K=[...Nt,v].filter(W=>W.role!=="think"&&!W.isVisualFeedback&&!W.isMeta&&!W.isTerminalRecord&&!(W.text&&W.text.includes("[TERMINAL_RECORD]"))&&!String(W.id).startsWith("welcome")),q=[],V=K.map((W,ye)=>{let Te=W.fullText||W.text||"";if(W.role==="user"&&ye<K.length-1)if(Te.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")){let Ee=Te.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");if(Ee!==-1){let ke=Te.substring(0,Ee).lastIndexOf("[SYSTEM METADATA]");ke!==-1?Te=Te.substring(ke).trim():Te=Te.substring(Ee).trim()}}else{let Ee=Te.lastIndexOf("[USER]"),nt=Te.lastIndexOf("[USER PROMPT]");Ee!==-1?Te=Te.substring(Ee+6).trim():nt!==-1&&(Te=Te.substring(nt).trim())}return{...W,text:Te}}),ee=0;for(;ee<V.length;){let W=V[ee];if(W.role==="user")q.push(W),ee++;else{let ye=[];for(;ee<V.length&&V[ee].role!=="user";)ye.push(V[ee]),ee++;let Te=[],Ee=[],nt=null,ke=!1,rt=()=>{Te.length>0&&(q.push({role:"agent",text:Te.join(`
|
|
277
277
|
`).trim()}),Te=[]),Ee.length>0&&(q.push({role:"system",text:Ee.join(`
|
|
278
278
|
|
|
279
|
-
`),...nt?{binaryPart:nt}:{}}),Ee=[],nt=null),ke=!1};for(let ht=0;ht<ye.length;ht++){let J=ye[ht],he=J.role==="system"&&(J.text?.startsWith("[ACTION RESULT]")||J.text?.startsWith("[TOOL RESULT]")||J.text?.startsWith("SUCCESS:")||J.text?.startsWith("ERROR:")||J.fullText?.startsWith("[ACTION RESULT]")||J.fullText?.startsWith("[TOOL RESULT]")||J.fullText?.startsWith("SUCCESS:")||J.fullText?.startsWith("ERROR:")),ve=J.fullText||J.text||"",
|
|
280
|
-
`),js=Ae.toLowerCase().includes("tool:")||Ae.toLowerCase().includes("action:"),jr=!1;for(let yn=ht+1;yn<ye.length;yn++){let Cn=ye[yn];if(Cn.role==="agent"){let mo=(Cn.fullText||Cn.text||"").trim();if(mo){jr=mo.startsWith("[");break}}}Te.push(Ae),js&&fr&&jr?ke=!0:ke=!1}}}rt()}}let te=aa(je,q,{profile:fn,thinkingLevel:We,mode:Y,systemSettings:de,janitorModel:k,sessionStats:Do,chatId:bt,isPlayground:!!_e.playground,aiProvider:F,apiKey:
|
|
279
|
+
`),...nt?{binaryPart:nt}:{}}),Ee=[],nt=null),ke=!1};for(let ht=0;ht<ye.length;ht++){let J=ye[ht],he=J.role==="system"&&(J.text?.startsWith("[ACTION RESULT]")||J.text?.startsWith("[TOOL RESULT]")||J.text?.startsWith("SUCCESS:")||J.text?.startsWith("ERROR:")||J.fullText?.startsWith("[ACTION RESULT]")||J.fullText?.startsWith("[TOOL RESULT]")||J.fullText?.startsWith("SUCCESS:")||J.fullText?.startsWith("ERROR:")),ve=J.fullText||J.text||"",Ge=ve.trim();if(!(!Ge&&!J.binaryPart)){if(he){let Ae=!Ge.startsWith("[ACTION RESULT]")&&!Ge.startsWith("[TOOL RESULT]")?`[ACTION RESULT]: ${Ge}`:Ge;Ee.push(Ae),J.binaryPart&&(nt=J.binaryPart)}else if(J.role==="agent"){!ke&&Ee.length>0&&rt();let Ae=Ge,Et=na(Ae),Co=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,jt=[],Mo;for(;(Mo=Co.exec(Et))!==null;)jt.push(Mo.index);if(jt.length>0){let yn=sa(Ae),Cn=[];for(let mo=0;mo<jt.length;mo++){let Yn=jt[mo],qr=mo+1<jt.length?jt[mo+1]:Ae.length;yn.find(ul=>ul.fullMatch&&Ae.startsWith(ul.fullMatch,Yn))||Cn.push({start:Yn,end:qr})}if(Cn.length>0){let mo="",Yn=0;for(let qr of Cn)mo+=Ae.substring(Yn,qr.start),Yn=qr.end;mo+=Ae.substring(Yn),Ae=mo.trim()}}if(!Ae)continue;let fr=ve.endsWith(`
|
|
280
|
+
`),js=Ae.toLowerCase().includes("tool:")||Ae.toLowerCase().includes("action:"),jr=!1;for(let yn=ht+1;yn<ye.length;yn++){let Cn=ye[yn];if(Cn.role==="agent"){let mo=(Cn.fullText||Cn.text||"").trim();if(mo){jr=mo.startsWith("[");break}}}Te.push(Ae),js&&fr&&jr?ke=!0:ke=!1}}}rt()}}let te=aa(je,q,{profile:fn,thinkingLevel:We,mode:Y,systemSettings:de,janitorModel:k,sessionStats:Do,chatId:bt,isPlayground:!!_e.playground,aiProvider:F,apiKey:Ke,apiTier:ze,wildcardTooling:Pr,wildercardTooling:ce,cols:X.columns-6,rows:30,onTokenChunk:(W,ye)=>{let Te=Date.now();if(Es(Te),typeof ye=="number"){Ii.current=ye;let Ee=Ds.current;Ee.startTime||(Ee.startTime=Te,Ee.totalWords=0,Ee.chunks=[]),Ee.totalWords+=ye,Ee.chunks||(Ee.chunks=[]),Ee.chunks.push({time:Te,words:ye});let ke=Te-400;if(Ee.chunks=Ee.chunks.filter(rt=>rt.time>=ke),Ee.chunks.length>0){let rt=Ee.chunks.reduce((he,ve)=>he+ve.words,0),ht=Ee.chunks[0].time,J=Math.max(.4,(Te-ht)/1e3);Ee.wps=Math.round(rt/J*10)/10}}},onVisualFeedback:W=>{I(ye=>[...ye.map(Ee=>Ee.isStreaming?{...Ee,isStreaming:!1}:Ee),{id:"visual-"+Date.now()+"-"+Math.random().toString(36).substring(2,9),role:"system",text:W,isVisualFeedback:!0}])},onSubagentUpdate:()=>{uc(ea.map(W=>({...W})))},onExecStart:W=>{qe(),se(),_i(W),Gn("")},onExecChunk:W=>{Gn(ye=>ye+W)},onExecEnd:()=>{let W=Fs.current,ye=$s.current||"";Fs.current=null,$s.current="",I(Te=>{if(!W)return Te;let Ee=Wl(ye),nt=`[TERMINAL_RECORD]
|
|
281
281
|
COMMAND: ${W}
|
|
282
282
|
PTY: ${jn}
|
|
283
283
|
OUTPUT: ${Ee.replace(/\n{3,}/g,`
|
|
284
284
|
|
|
285
|
-
`)}`,rt=[...Te.map(ht=>ht.isStreaming?{...ht,isStreaming:!1}:ht),{id:"term-"+Date.now(),role:"system",text:nt,isTerminalRecord:!0}];return O(rt.length),rt}),
|
|
285
|
+
`)}`,rt=[...Te.map(ht=>ht.isStreaming?{...ht,isStreaming:!1}:ht),{id:"term-"+Date.now(),role:"system",text:nt,isTerminalRecord:!0}];return O(rt.length),rt}),_i(null),Hi(!1),Gn("")},onToolResult:(W,ye)=>{if(W==="success"){if(nc(Te=>Te+1),ye==="generate_image"){ac(nt=>nt+1);let Ee={Low:.001,"Low-High":.002,Medium:.008,"Medium-High":.01,High:.045,Ultra:.0488,Premium:.1}[_o.quality]||.002;cc(nt=>nt+Ee)}}else W==="denied"?sc(Te=>Te+1):rc(Te=>Te+1)},onIDEApproval:Io,onToolApproval:async(W,ye,Te={})=>{let Ee=vn(ye||"{}"),nt=Ee.path||Ee.targetPath||Ee.file||"",ke=de?.alwaysAskFiles||".env, .env.*, *.env",rt=(W==="view_file"||W==="write_file"||W==="update_file")&&ml(nt,ke),ht=nt?Ct.resolve(nt).toLowerCase():"",J=nt?Ct.extname(nt).toLowerCase():"",he=!rt&&(de.autoExec||Ki||W==="write_file"&&J&&Vi.current.has(J)||W==="update_file"&&ht&&Yi.current.has(ht));if(W==="exec_command"){let{command:ve}=Ee,Ge=(ve||"").trim(),Ae=/^(echo|ls|dir|pwd|cd|git status|git log|git diff|type|cat|help)\b/i;return de.autoExec||Ki||ji.current.has(Ge)||Ge&&Ae.test(Ge)?"allow":Te.checkOnly?null:new Promise(Et=>{fs(),Kn({tool:W,args:ye,resolve:Et}),ne("terminalApproval")})}return he?"allow":Te.checkOnly?null:new Promise(ve=>{fs(),Kn({tool:W,args:ye,resolve:ve}),ne("approval")})},onAskUser:async(W,ye)=>(qe(),se(),fs(),new Promise(Te=>{let Ee=!1;_s({question:W,options:ye,resolve:nt=>{Ee||(Ee=!0,I(ke=>{if(ke.some(J=>J.isAskRecord&&J.text?.includes(`Selection: ${nt}`)))return ke;let ht=[...ke,{id:"ask-"+Date.now(),role:"system",text:`\u{1F4AC} **Ask User**
|
|
286
286
|
Question: ${W}
|
|
287
|
-
Selection: ${nt}`,isAskRecord:!0}];return O(ht.length),ht}),Te(nt))}}),ne("ask")})),onUsage:W=>{let ye=W.totalTokenCount||0,Te=W.cachedContentTokenCount||0,Ee=W.candidatesTokenCount||0,nt=Math.max(0,ye-Ee);if(Zo({tokens:ye}),
|
|
288
|
-
${
|
|
289
|
-
\u2800`,isMeta:!0}]);continue}if(W.type==="summary_injected"){I(J=>J.map(he=>he.id===W.content.id?{...he,fullText:W.content.text}:he));continue}if(W.type==="spinner"){gc(W.content);continue}if(W.type==="model_update"){Tc(W.content);continue}if(W.type==="turn_reset"){if(qe(),se(),et=null,Ue=null,U=!1,He=!1,Qe=!1,it=!1,
|
|
290
|
-
`),he=0,ve=0,
|
|
291
|
-
`),Ae=!1;for(let Et of
|
|
287
|
+
Selection: ${nt}`,isAskRecord:!0}];return O(ht.length),ht}),Te(nt))}}),ne("ask")})),onUsage:W=>{let ye=W.totalTokenCount||0,Te=W.cachedContentTokenCount||0,Ee=W.candidatesTokenCount||0,nt=Math.max(0,ye-Ee);if(Zo({tokens:ye}),Pi(ke=>ke+ye),nt>0&&Oi(ke=>ke+nt),Te>0&&Ni(ke=>ke+Te),Ee>0&&Fi(ke=>ke+Ee),nt>0||Te>0){zt.current.push({input:nt,cached:Te}),zt.current.length>3&&zt.current.shift();let ke=zt.current.reduce((J,he)=>J+he.input,0),rt=zt.current.reduce((J,he)=>J+he.cached,0),ht=ke>0?rt/ke*100:0;gn(ht)}Ai(ke=>ke+1)}},async()=>Xo.current?Xo.current:null,ho),U=!1,et=null,Ue=null,He=!1,Qe=!1,Ve=!1,it=!1,ue=0,pe=null,Je=/\[?\s*turn\s*:\s*.*?\s*\]?/gi;for await(let W of te){if(await new Promise(J=>setTimeout(J,3)),W.type==="text"&&Es(Date.now()),H&&W.type==="text"&&(N=Date.now(),H=!1,de.progressiveRendering&&Se()),W.type==="status"){if(W.content&&(W.content.includes("Steering Hint Injected")||W.content.includes("Question Forwarded"))){let J=Xo.current;J&&(I(he=>{O(he.length+1);let ve=J.startsWith("/btw"),Ge=ve?J.replace(/^\/btw\s*/,""):J,Ae=ve?"[QUESTION]":"[STEERING HINT]";return[...he,{id:"hint-"+Date.now(),role:"user",text:`${Ae}
|
|
288
|
+
${Ge}`,color:"cyan",isSteeringHint:!0,hintType:ve?"QUESTION":"STEERING HINT",hintContent:Ge}]}),Ks(null),Xo.current=null)}W.content?.includes("[start]")||Hs(W.content),W.content?.includes("[start]")?(clearInterval(dr),cr(0),dr=setInterval(()=>{cr(J=>J+1)},1e3)):W.content?.includes("[end]")&&(cr(0),clearInterval(dr)),Bn()&&es(W.content),W.content==="Request Cancelled"&&(qe(),se(),h());continue}if(W.type==="status_history"){Hs(W.content),Bn()&&es(W.content),I(J=>[...J,{id:"condense-"+Date.now(),role:"system",text:`\u2726 ${W.content}
|
|
289
|
+
\u2800`,isMeta:!0}]);continue}if(W.type==="summary_injected"){I(J=>J.map(he=>he.id===W.content.id?{...he,fullText:W.content.text}:he));continue}if(W.type==="spinner"){gc(W.content);continue}if(W.type==="model_update"){Tc(W.content);continue}if(W.type==="turn_reset"){if(qe(),se(),et=null,Ue=null,U=!1,He=!1,Qe=!1,it=!1,Ve=!1,I(J=>{let he=J.map(ve=>{if(ve.isStreaming){let Ge=ve.text?Xt(ve.text):ve.text,Ae=ve.fullText?Xt(ve.fullText):ve.fullText;return{...ve,isStreaming:!1,text:Ge,fullText:Ae}}return ve});return O(he.length),he}),Wo(),global.gc){for(let J=0;J<2;J++)global.gc(),await new Promise(he=>setImmediate(he));g.current=Date.now()}continue}if(W.type==="interactive_turn_finished"){Ws(!1),cr(0),clearInterval(dr),Bn()&&es(null),M=!0,de?.agentFinishSound&&(async()=>{try{let he=(await Go())[bt],ve=Tr(he,String(bt));fi(ve)}catch{fi(String(bt))}})(),Wo(),de?.autoTruncateResults&&I(J=>{let he=J.map(ve=>{let Ge=ve.fullText||ve.text||"";return!Ge.startsWith("[ACTION RESULT]:")&&!Ge.startsWith("[TOOL RESULT]:")||Ge.startsWith("[ACTION RESULT]: Goal")||Ge.includes("...Success result truncated to save tokens")||Ge.startsWith("[ACTION RESULT]: USER CHOOSE")||Ge.startsWith("[ACTION RESULT]: Skill:")||Ge.startsWith("[ACTION RESULT]: DOCs:")||Ge.startsWith("[ACTION RESULT]: Markdown parsed")||Ge.startsWith("[ACTION RESULT]: Search results for [")||Ge.startsWith("[ACTION RESULT]: AI Mode temporarily failed")||Ge.startsWith("[ACTION RESULT]: Background subagent started. Task ID:")||/^\[ACTION RESULT\]: File \[.*?\] saved/s.test(Ge)?ve:{...ve,fullText:"[ACTION RESULT]: ...Success result truncated to save tokens"}});return En(bt,null,he),O(he.length),he}),oa({profile:fn,thinkingLevel:We,mode:Y,janitorModel:k,chatId:bt,systemSettings:de,sessionStats:Do,aiProvider:F,apiKey:Ke},W.data.agentText,W.data.fullAgentTextRaw,W.data.history,{onMemoryUpdated:()=>I(J=>{let he=[...J];return he.length>0&&(he[he.length-1].memoryUpdated=!0),he}),onBackgroundIncrement:()=>Za(J=>J+1)});continue}if(W.type==="visual_feedback"){qe(),se(),I(J=>{let he=[...J,{id:"feedback-"+Date.now()+"-"+Math.random().toString(36).substring(2,9),role:"system",text:Xt(W.content),isVisualFeedback:!0}];return O(he.length),he});continue}if(W.type==="exec_start"){qe(),se();continue}if(W.type==="liveTokens"){Zo({tokens:W.content});continue}if(W.type==="usage"){let J=W.content.totalTokenCount||0,he=W.content.cachedContentTokenCount||0,ve=W.content.candidatesTokenCount||0,Ge=Math.max(0,J-ve);if(Zo({tokens:J}),Pi(Ae=>Ae+J),Ge>0&&Oi(Ae=>Ae+Ge),he>0&&Ni(Ae=>Ae+he),ve>0&&Fi(Ae=>Ae+ve),Ge>0||he>0){zt.current.push({input:Ge,cached:he}),zt.current.length>3&&zt.current.shift();let Ae=zt.current.reduce((jt,Mo)=>jt+Mo.input,0),Et=zt.current.reduce((jt,Mo)=>jt+Mo.cached,0),Co=Ae>0?Et/Ae*100:0;gn(Co)}Ai(Ae=>Ae+1);continue}if(W.type==="tool_time"){lc(J=>J+W.content);continue}if(W.type==="tool_result"){if(se(),et=null,Ue=null,U=!1,He=!1,Qe=!1,it=!1,Ve=!1,ue=0,pe=null,I(J=>{let he=[...J,{id:"tool-"+Date.now()+"-"+Math.random().toString(36).substring(2,7),role:"system",text:Xt(W.content),fullText:Xt(W.aiContent),binaryPart:W.binaryPart,toolName:W.toolName}];return O(he.length),he}),j.current&&(Ue=j.current.id,Qe=!0),W.toolName==="update_file"&&W.aiContent){let J=W.aiContent.split(`
|
|
290
|
+
`),he=0,ve=0,Ge=!1;for(let Ae of J){if(Ae.includes("[DIFF_START]")){Ge=!0;continue}if(Ae.includes("[DIFF_END]")){Ge=!1;continue}Ge&&(/^\+\s*\d+/.test(Ae)?he++:/^\-\s*\d+/.test(Ae)&&ve++)}Sn("linesAdded",he),Sn("linesRemoved",ve)}else if(W.toolName==="write_file"&&W.aiContent){let J=W.aiContent.match(/- Stats: \[(\d+) lines/),he=J?parseInt(J[1]):0,ve=0;if(W.aiContent.includes("Old File contents:")){let Ge=W.aiContent.split(`
|
|
291
|
+
`),Ae=!1;for(let Et of Ge){if(Et.includes("Old File contents:")){Ae=!0;continue}Ae&&(Et.startsWith("- Content Preview:")||Et.trim()===""&&!/^\s*\d+\s*\|/.test(Et)?Ae=!1:/^\s*\d+\s*\|/.test(Et)&&ve++)}}(he>0||ve>0)&&(Sn("linesAdded",he),Sn("linesRemoved",ve))}continue}let ye=W.content;if(W.type==="text"&&ye.includes("Request Cancelled")){if(global.gc){for(let J=0;J<3;J++)global.gc(),await new Promise(he=>setImmediate(he));g.current=Date.now()}continue}let Te=ye.toLowerCase();if(ye.includes("```")&&(He=!He),(Te.includes("tool:")||Te.includes("action:"))&&(Qe=!0,ue=0,pe=null,(ye.includes("[tool:")||ye.includes("[action:"))&&(ue=0)),Qe){for(let J=0;J<ye.length;J++){let he=ye[J];!pe&&(he==="'"||he==='"'||he==="`")?pe=he:pe&&he===pe&&ye[J-1]!=="\\"&&(pe=null),pe||(he==="("||he==="["?ue++:(he===")"||he==="]")&&ue--)}ue<=0&&!pe&&(Qe=!1)}let Ee=/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])/i,nt=(J,he,ve=1)=>{let Ge=he>0?J[he-1]:"",Ae=he+ve<J.length?J[he+ve]:"";return Ge==="`"&&Ae==="`"},ke=J=>{let he=/(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\])/gi,ve;for(;(ve=he.exec(J))!==null;)if(!nt(J,ve.index,ve[0].length))return{index:ve.index,length:ve[0].length};return{index:-1,length:0}},rt=j.current?.role==="agent"&&j.current.text||"",ht=!Ve&&rt.trim().length===0;if(!U&&ht&&(Ee.test(ye)||Ee.test(rt+ye))){let J=Ee.test(ye)?ye:rt+ye,he=J.match(Ee),ve=he.index,Ge=he[0].length,Ae=J.substring(ve+Ge);qe(),j.current=null,U=!0,Ve=!0,et="think-"+Date.now(),j.current={id:et,role:"think",text:"",isStreaming:!0,startTime:Date.now()};let Et=ke(Ae);if(Et.index!==-1){let jt=Ae.substring(0,Et.index).replace(/^\r?\n+/,"").replace(/\r?\n+$/,""),Mo=Ae.substring(Et.index+Et.length);j.current.text=Xt(jt);let fr=j.current.startTime||Date.now();j.current.duration=Date.now()-fr,se(),U=!1,Ue="agent-"+Date.now(),j.current={id:Ue,role:"agent",text:"",isStreaming:!0},Mo&&mt(Mo)}else{let Co=Ae.replace(/^\r?\n+/,"");Co&&mt(Co)}continue}if(!U&&!Ve&&ye.trim().length>0&&(Ve=!0),U&&j.current?.role==="think"){qe();let he=(j.current.text||"")+ye,ve=ke(he);if(ve.index!==-1){let Ge=he.substring(0,ve.index),Ae=he.substring(ve.index+ve.length);j.current.text=Xt(Ge);let Et=j.current.startTime||Date.now();j.current.duration=Date.now()-Et,se(),U=!1,Ue="agent-"+Date.now(),j.current={id:Ue,role:"agent",text:"",isStreaming:!0},Ae&&mt(Ae)}else mt(ye);continue}else if(!U){let J=ye.toLowerCase();!it&&(J.includes("tool:")||J.includes("action:"))&&(it=!0),!j.current||j.current.role!=="agent"?(Ue="agent-"+Date.now(),j.current={id:Ue,role:"agent",text:Xt(ye),isStreaming:!0},ct()):mt(ye)}}let Ze=Date.now();ic(W=>W+(Ze-N))}catch(K){I(q=>(O(q.length+1),[...q,{id:"error-"+Date.now(),role:"system",text:`\u274C ERROR: ${K.message}`}]))}finally{let K=Date.now()-N;if(j.current&&(j.current.workedDuration=K),st.current&&(await ut(),clearInterval(st.current),st.current=null),Ws(!1),Hs(null),cr(0),clearInterval(dr),se(),Gs.current&&h(),Wo(),global.gc)try{for(let q=0;q<3;q++)global.gc(),await new Promise(V=>setImmediate(V));g.current=Date.now()}catch{}if(M||process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow | Idle\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow | Idle\x07")),Xo.current){Vs(Xo.current),Ks(null);let q=Xo.current;Xo.current=null,I(V=>{let ee=[...V],te=ee.reverse().find(U=>U.text?.includes("[STEERING HINT: QUEUED]")||U.text?.includes("[QUESTION: QUEUED]"));return te&&(te.text.includes("[STEERING HINT: QUEUED]")?te.text=te.text.replace("[STEERING HINT: QUEUED]","[STEERING HINT: FINISHED_TURN]"):te.text.includes("[QUESTION: QUEUED]")&&(te.text=te.text.replace("[QUESTION: QUEUED]","[QUESTION: FINISHED_TURN]"))),ee.reverse()}),ne("resolution")}I(q=>{let V=Date.now()-N,ee=!1,te=[...q].reverse().map(Ue=>{let He=Ue.isStreaming?{...Ue,isStreaming:!1}:Ue;return He.text&&(He.text=(" "+He.text).slice(1)),!ee&&He.role==="agent"&&(ee=!0,He={...He,workedDuration:V}),He}).reverse();if(!te.some(Ue=>Ue.role==="agent"&&Ue.text?.trim().length>0)){let Ue=[...te].reverse().find(He=>He.role==="think"&&He.text?.trim().length>0);Ue&&te.push({id:"agent-fallback-"+Date.now(),role:"agent",text:Ue.text,isStreaming:!1,workedDuration:V})}let et=te.filter(Ue=>!String(Ue.id).startsWith("welcome")&&(!Ue.isMeta||Ue.text&&Ue.text.includes("Request Cancelled")));return En(bt,null,et),O(te.length),te})}})()}b(""),z(!1)}},lt=Jn(()=>{if(y.startsWith("/")&&!Xe){let x=y.split(" "),v=x[x.length-1].toLowerCase();if(x.length===1){let a=v.startsWith("/")?v.slice(1):v;return al.filter(h=>(h.cmd.startsWith("/")?h.cmd.slice(1):h.cmd).toLowerCase().includes(a))}let u=al;for(let a=0;a<x.length-1;a++){let h=x[a].toLowerCase(),M=u.find(N=>N.cmd.toLowerCase()===h);if(M&&M.subs)u=M.subs;else return[]}return u.filter(a=>a.cmd.toLowerCase().includes(v))}let n=y.split(" "),o=n[n.length-1],c=o&&o.startsWith("\\@");if((o&&o.startsWith("@")||c)&&!Xe){let x=o.indexOf("#"),v=x!==-1,u=c?2:1,a=v?o.substring(u,x).toLowerCase():o.slice(u).toLowerCase(),h=v?o.substring(x):"";return fu(process.cwd()).filter(H=>H.name.toLowerCase().includes(a)).map(H=>{let K=H.relativePath.replace(/\\/g,"/"),q=K.startsWith(".")?K:"./"+K;return{cmd:(c?"\\@":"@")+"["+q+h+"]",desc:H.relativePath}})}return[]},[y,Xe]);gt(()=>{let n=0;for(;n<lt.length;){let o=lt[n],c=o?.cmd||o||"";if(typeof c=="string"&&c.trimStart().startsWith("---"))n++;else break}Oe(n<lt.length?n:0)},[lt]);let[Vr,Yr]=Q(0),dl=Re(0);gt(()=>{let n=dl.current>0,o=lt.length>0;if(dl.current=lt.length,!o){Yr(0);return}if(!n){Yr(1);return}Yr(lt.length)},[lt]),gt(()=>{if(Vr>0&&Vr<lt.length){let n=setTimeout(()=>{Yr(o=>Math.min(o+1,lt.length))},1);return()=>clearTimeout(n)}},[Vr,lt.length]),gt(()=>{if(St!=="providerBudgetSelect")return;let n=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","Infron","APInex","xKiro"],o=Ie.providerBudgets||{},c=n.reduce((f,x)=>(f[x]=!!(o[x]&&(o[x].agentLimit||o[x].tokenLimit||o[x].monthlyTokenLimit||o[x].dailyCostLimit||o[x].monthlyCostLimit)),f),{});Ei(c),Fr(0)},[St]),gt(()=>{if(St!=="providerBudgetFlow")return;let n={},o=Ie.providerBudgets||{};for(let c of kn){let f=o[c]||{};n[c]={agentLimit:qo(f.agentLimit),tokenLimit:qo(f.tokenLimit),monthlyTokenLimit:qo(f.monthlyTokenLimit),dailyCostLimit:qo(f.dailyCostLimit),monthlyCostLimit:qo(f.monthlyCostLimit)}}or(n),bo(0)},[St,kn]);let Du=({label:n,isSelected:o})=>{let c=n==="Cancel"||n==="Back"||n.toLowerCase().includes("exit")||n.toLowerCase().includes("back");return e.createElement(m,{marginTop:c?1:0,backgroundColor:o?"#2a2a2a":void 0,paddingX:1,width:"100%"},e.createElement(i,{color:o?"white":"gray",bold:o},o?"\u276F ":" ",n))},uo=(n,o,c,f=10,x=2,v=9)=>{let u=go(c),a=!u&&c>0?Math.min(100,o/c*100):0,h=Math.round(a),M=Math.round(h/100*f),N="\u2588".repeat(M)+"\u2591".repeat(Math.max(0,f-M)),H=s.success||"green";h>=40&&h<=80?H=s.warning||"yellow":h>80&&(H=s.danger||"red");let K=n.toLowerCase().includes("cost")||n.toLowerCase().includes("spend"),q=!K&&(n.toLowerCase().includes("token")||n.toLowerCase().includes("daily")||n.toLowerCase().includes("monthly")),V=u?"\u221E":K?`$${Number(c).toFixed(2)}`:q?At(c):c,ee=Number(o)||0,te=K?`$${ee.toFixed(ee<.01&&ee>0?4:2)}`:q?At(o):o,U;return u||a===0?U="0%":a>0&&a<1?U="<1%":U=`${h}%`,e.createElement(m,{flexDirection:"row",paddingLeft:x,key:n},e.createElement(m,{width:v},e.createElement(i,{color:s.textMuted},n,": ")),e.createElement(i,{color:H},N),e.createElement(i,{color:s.textMuted}," ",U," (",te,"/",V,")"))},Sc=()=>{switch(St){case"settings":return e.createElement(us,{systemSettings:de,setSystemSettings:Ot,apiTier:ze,setActiveView:ne,setInputConfig:so,saveSettings:Kt,quotas:Ie,setMessages:I,aiProvider:F,autoCompletion:nr,setAutoCompletion:Bs,profileData:fn,setProfileData:vs,setProviderReturnView:Ms,setApiKey:Pt,initAI:xo});case"theme":return e.createElement(us,{systemSettings:de,setSystemSettings:Ot,apiTier:ze,setActiveView:ne,setInputConfig:so,saveSettings:Kt,quotas:Ie,setMessages:I,aiProvider:F,autoCompletion:nr,setAutoCompletion:Bs,profileData:fn,setProfileData:vs,initialSelectingTheme:!0,onCloseTheme:()=>ne("chat"),setProviderReturnView:Ms,setApiKey:Pt,initAI:xo});case"selectProvider":return e.createElement($t,{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:"Infron",value:"Infron"},{label:"APInex",value:"APInex"},{label:"xKiro",value:"xKiro"},{label:"Ollama",value:"Ollama"},...process.env.ENABLE_9ROUTER==="true"||process.env.ENABLE_9ROUTER===!0?[{label:"9router [Local Proxy]",value:"9router"}]:[],{label:"AIHubMix [Experimental]",value:"AIHubMix"},{label:"Mistral [Experimental]",value:"Mistral"},{label:"OpenRouter [Experimental]",value:"OpenRouter"},{label:"Custom [OpenAI Chat Completion]",value:"c_openai"},{label:"Back",value:Jo}],theme:de.theme,onSelect:async n=>{if(n.value===Jo||n.value==="settings"||n.value==="Back"){ne(Jo);return}let o=n.value,c=await on(o),f="";if(o==="9router"){let x=await yi();x.ok||(f=`
|
|
292
292
|
|
|
293
293
|
\x1B[33m\u2726 WARNING: 9router does not appear to be running on ${x.url}.\x1B[39m
|
|
294
|
-
\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(o==="c_openai"){if(!de.customOpenAIBaseUrl){so({label:"Enter Custom OpenAI Base URL (.../v1):",key:"customOpenAIBaseUrl",value:"",returnView:Jo}),ne("input");return}let x=c||"";try{
|
|
294
|
+
\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(o==="c_openai"){if(!de.customOpenAIBaseUrl){so({label:"Enter Custom OpenAI Base URL (.../v1):",key:"customOpenAIBaseUrl",value:"",returnView:Jo}),ne("input");return}let x=c||"";try{Zs()}catch{}zo(o),Pt(x),xo(x,{aiProvider:o,onIDEApproval:Io});let v=(Ie.providerTiers||{})[o]||"Free",u=ao(o,v)||"";Gt(u),Ht(v),Ot(a=>({...a,memory:!1})),Kt({aiProvider:o,activeModel:u,apiTier:v,quotas:Ie,systemSettings:{...de,memory:!1}}),I(a=>[...a,{role:"system",text:`\u2726 Switched to Custom (OpenAI)!${u?`
|
|
295
295
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: ${u}.`:""}
|
|
296
296
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Endpoint: ${de.customOpenAIBaseUrl}${de.memory?`
|
|
297
297
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with Custom (OpenAI).`:""}
|
|
298
|
-
\u2800`,isMeta:!0}]),ne(Jo);return}if(c){try{
|
|
298
|
+
\u2800`,isMeta:!0}]),ne(Jo);return}if(c){try{Zs()}catch{}zo(o),Pt(c),xo(c,{aiProvider:o,onIDEApproval:Io});let x=(Ie.providerTiers||{})[o]||"Free",v=ao(o,x);Gt(v),Ht(x),o==="NVIDIA"&&process.env.NVIDIA_BASE_URL||o==="Ollama"||o==="InferX"||o==="SenseNova"||o==="Poolside"||o==="9router"||o==="ExpLabs"||o==="TokenHarbor"||o==="Infron"||o==="APInex"||o==="xKiro"||o==="c_openai"?(Ot(a=>({...a,memory:!1})),Kt({aiProvider:o,activeModel:v,apiTier:x,quotas:Ie,systemSettings:{...de,memory:!1}})):Kt({aiProvider:o,activeModel:v,apiTier:x,quotas:Ie});let u=o==="c_openai"?"Custom (OpenAI)":o;I(a=>[...a,{role:"system",text:`\u2726 Switched to ${u} (cached)!${v?`
|
|
299
299
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: ${v}.`:""}${(o==="Ollama"||o==="InferX"||o==="SenseNova"||o==="AIHubMix"||o==="Poolside"||o==="9router"||o==="ExpLabs"||o==="TokenHarbor"||o==="Infron"||o==="APInex"||o==="xKiro"||o==="c_openai")&&de.memory?`
|
|
300
300
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with ${u}.`:""}${o==="NVIDIA"&&process.env.NVIDIA_BASE_URL&&de.memory?`
|
|
301
301
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with Custom Endpoints.`:""}${f}
|
|
302
|
-
\u2800`,isMeta:!0}]),ne(Jo)}else so({label:`Enter ${o==="c_openai"?"Custom (OpenAI)":o} API Key:`,key:"providerKey",provider:o,value:"",returnView:Jo}),ne("input")},onClose:()=>ne(Jo)});case"apiTier":return e.createElement($t,{title:`Show Paid models from ${F.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] ${ze==="Paid"?"\u25CF":""}`,value:"Paid"},{label:"Back",value:"settings"}],theme:de.theme,onSelect:n=>{if(n.value==="settings"||n.value==="Back"){ne("settings");return}let o=n.value;Ht(o);let c={...Ie.providerTiers||{},[F]:o},f={...Ie,providerTiers:c};po(f),Kt({apiTier:o,quotas:f}),ne("settings")}});case"resetMode":return e.createElement($t,{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:de.theme,onSelect:n=>{if(n.value==="apiTier"||n.value==="Back"){ne("apiTier");return}let o=n.value,c={...Ie,resetMode:o};po(c),o==="Custom"?(so({label:"Enter monthly reset day (1-30):",key:"quotas",subKey:"resetDay",value:String(Ie.resetDay||1),returnView:"settings"}),ne("input")):(Kt({apiTier:ze,quotas:c}),ne("settings"))},onClose:()=>ne("apiTier")});case"budgetTypeSelect":return e.createElement($t,{title:"SELECT BUDGET TYPE",items:[{label:`Global Budget (single limit for all providers) ${ze==="Paid"&&!Ie.providerBudgets?.__useProvider?"\u25CF":""}`,value:"global"},{label:`Provider Budgets (set limits per provider individually) ${Ie.providerBudgets?.__useProvider?"\u25CF":""}`,value:"provider"},{label:"Back",value:Uo}],theme:de.theme,onSelect:n=>{if(n.value===Uo||n.value==="Back"){ne(Uo);return}if(n.value==="global"){let o={...Ie,agentLimit:99999999,tokenLimit:99999999999999,monthlyTokenLimit:99999999999999,providerBudgets:{__useProvider:!1}};po(o);let c=Uo==="settings"?"resetMode":"budgetResetMode";so({label:"Enter Agent daily budget (tokens used):",key:"quotas",subKey:"tokenLimit",value:qo(o.tokenLimit),returnView:Uo,next:f=>({label:"Enter Agent monthly budget (tokens used):",key:"quotas",subKey:"monthlyTokenLimit",value:qo(f.monthlyTokenLimit),returnView:Uo,next:x=>({label:"Enter Daily Cost Limit ($ or 0 for unlimited):",key:"quotas",subKey:"dailyCostLimit",value:qo(x.dailyCostLimit),returnView:Uo,next:v=>({label:"Enter Monthly Cost Limit ($ or 0 for unlimited):",key:"quotas",subKey:"monthlyCostLimit",value:qo(v.monthlyCostLimit),returnView:c})})})}),ne("input")}else if(n.value==="provider"){let o={...Ie,agentLimit:99999999,tokenLimit:99999999999999,monthlyTokenLimit:99999999999999,providerBudgets:{...Ie.providerBudgets||{},__useProvider:!0}};po(o),ne("providerBudgetSelect")}},onClose:()=>ne(Uo)});case"providerBudgetSelect":{let n=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","Infron","APInex","xKiro"],o=n.some(c=>Ss[c]);return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,padding:0,width:"100%"},e.createElement(m,{paddingX:1,marginBottom:1},e.createElement(i,{color:s.text,bold:!0},"SELECT PROVIDERS TO SET LIMITS FOR")),n.map((c,f)=>{let x=f===vi,v=!!Ss[c];return e.createElement(m,{key:c,backgroundColor:x?s.highlightBg||"#2a2a2a":void 0,paddingX:1,width:"100%",flexDirection:"row"},e.createElement(i,{color:x?s.text:s.textMuted,bold:x},x?"\u276F ":" "),e.createElement(i,{color:v?s.success||"green":s.textMuted},v?"\u2611":"\u2610"),e.createElement(i,{color:x?s.text:s.textMuted,bold:x}," ",c),v&&(Ie.providerBudgets?.[c]?.agentLimit||Ie.providerBudgets?.[c]?.tokenLimit||Ie.providerBudgets?.[c]?.monthlyTokenLimit||Ie.providerBudgets?.[c]?.dailyCostLimit||Ie.providerBudgets?.[c]?.monthlyCostLimit)?e.createElement(i,{color:s.primary||"cyan"}," (budget set)"):null)}),e.createElement(m,{paddingX:1,marginTop:1,flexDirection:"column"},e.createElement(i,{color:s.textMuted,italic:!0},"\u2191\u2193 Navigate \u2022 Space to toggle \u2022 Enter to confirm \u2022 ESC to go back"),!o&&e.createElement(i,{color:s.warning||"yellow",italic:!0}," Select at least one provider to continue")))}case"providerBudgetFlow":{let n=kn.length,o=n*4;return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,padding:0,width:"100%"},e.createElement(m,{paddingX:1,marginBottom:0,justifyContent:"space-between",flexDirection:"row"},e.createElement(i,{color:s.text,bold:!0},"PROVIDER BUDGET CONFIGURATION"),e.createElement(i,{color:s.textMuted,italic:!0},"(0 or blank = unlimited)")),e.createElement(m,{paddingX:1,marginTop:1,flexDirection:"row"},e.createElement(m,{width:13},e.createElement(i,{color:s.textMuted,bold:!0},"PROVIDER")),e.createElement(m,{width:20,paddingLeft:1},e.createElement(i,{color:s.textMuted,bold:!0},"DAILY TOKENS")),e.createElement(m,{width:22,paddingLeft:1},e.createElement(i,{color:s.textMuted,bold:!0},"MONTHLY TOKENS")),e.createElement(m,{width:18,paddingLeft:1},e.createElement(i,{color:s.textMuted,bold:!0},"DAILY COST ($)")),e.createElement(m,{width:20,paddingLeft:1},e.createElement(i,{color:s.textMuted,bold:!0},"MONTHLY COST ($)"))),e.createElement(m,{paddingX:1},e.createElement(i,{color:s.borderMuted},"\u2500".repeat(93))),kn.map((c,f)=>{let x=f*4,v=f*4+1,u=f*4+2,a=f*4+3,h=An===x,M=An===v,N=An===u,H=An===a,K=h||M||N||H,q=tr[c]?.tokenLimit??"",V=tr[c]?.monthlyTokenLimit??"",ee=tr[c]?.dailyCostLimit??"",te=tr[c]?.monthlyCostLimit??"";return e.createElement(m,{key:c,flexDirection:"row",paddingX:1,marginY:0,backgroundColor:K?s.highlightBg||"#2a2a2a":void 0},e.createElement(m,{width:13,flexDirection:"row"},e.createElement(i,{color:K?s.primary||"cyan":s.text,bold:K},K?"\u276F ":" ",c)),e.createElement(m,{width:20,paddingLeft:1,flexDirection:"row"},h?e.createElement(m,{flexDirection:"row"},e.createElement(i,{color:s.primary||"cyan",bold:!0},"[ "),e.createElement(Zn,{value:q,onChange:U=>{or(et=>({...et,[c]:{...et[c]||{},tokenLimit:U}}))},onSubmit:()=>bo(v)}),e.createElement(i,{color:s.primary||"cyan",bold:!0}," ]")):e.createElement(i,{color:q?s.text:s.textMuted},"[ ",q||"0 (\u221E)"," ]")),e.createElement(m,{width:22,paddingLeft:1,flexDirection:"row"},M?e.createElement(m,{flexDirection:"row"},e.createElement(i,{color:s.primary||"cyan",bold:!0},"[ "),e.createElement(Zn,{value:V,onChange:U=>{or(et=>({...et,[c]:{...et[c]||{},monthlyTokenLimit:U}}))},onSubmit:()=>bo(u)}),e.createElement(i,{color:s.primary||"cyan",bold:!0}," ]")):e.createElement(i,{color:V?s.text:s.textMuted},"[ ",V||"0 (\u221E)"," ]")),e.createElement(m,{width:18,paddingLeft:1,flexDirection:"row"},N?e.createElement(m,{flexDirection:"row"},e.createElement(i,{color:s.primary||"cyan",bold:!0},"[ $"),e.createElement(Zn,{value:ee,onChange:U=>{or(et=>({...et,[c]:{...et[c]||{},dailyCostLimit:U}}))},onSubmit:()=>bo(a)}),e.createElement(i,{color:s.primary||"cyan",bold:!0}," ]")):e.createElement(i,{color:ee?s.warning||"yellow":s.textMuted},"[ ",ee?`$${ee}`:"0 (\u221E)"," ]")),e.createElement(m,{width:20,paddingLeft:1,flexDirection:"row"},H?e.createElement(m,{flexDirection:"row"},e.createElement(i,{color:s.primary||"cyan",bold:!0},"[ $"),e.createElement(Zn,{value:te,onChange:U=>{or(et=>({...et,[c]:{...et[c]||{},monthlyCostLimit:U}}))},onSubmit:()=>{f+1<n?bo((f+1)*4):bo(o)}}),e.createElement(i,{color:s.primary||"cyan",bold:!0}," ]")):e.createElement(i,{color:te?s.warning||"yellow":s.textMuted},"[ ",te?`$${te}`:"0 (\u221E)"," ]")))}),e.createElement(m,{paddingX:1,marginTop:1},An===o?e.createElement(m,{backgroundColor:s.highlightBg||"#2a2a2a",paddingX:1},e.createElement(i,{color:s.success||"green",bold:!0},"\u276F [ Save & Apply Budgets ]")):e.createElement(i,{color:s.textMuted}," [ Save & Apply Budgets ]")),e.createElement(m,{paddingX:1,marginTop:1,flexDirection:"column"},e.createElement(i,{color:s.textMuted,italic:!0},"\u2191\u2193/\u2190\u2192 Navigate \u2022 Enter next / save \u2022 ESC to go back")))}case"budgetResetMode":return e.createElement($t,{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:de.theme,onSelect:n=>{if(n.value==="chat"||n.value==="Back"){ne("chat");return}let o=n.value,c={...Ie,resetMode:o};po(c),o==="Custom"?(so({label:"Enter monthly reset day (1-30):",key:"quotas",subKey:"resetDay",value:String(Ie.resetDay||1),returnView:"chat"}),ne("input")):(Kt({apiTier:ze,quotas:c}),ne("chat"))},onClose:()=>ne("chat")});case"budgetView":{let n=_n?.agent||0,o=Ie.agentLimit||99999999,c=_n?.tokens||0,f=Ie.tokenLimit||99999999999999,x=Ie.resetMode==="Custom"?Xr?.tokens||0:rr?.tokens||0,v=Ie.monthlyTokenLimit||99999999999999,u=_n?.cost||0,a=Ie.dailyCostLimit||99999999999999,h=Ie.resetMode==="Custom"?Xr?.cost||0:rr?.cost||0,M=Ie.monthlyCostLimit||99999999999999,N=ze!=="Paid",H=!!Ie.providerBudgets?.__useProvider,K=Ie.providerBudgets||{},q=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","Infron","APInex","xKiro"].filter(U=>K[U]&&(K[U].agentLimit||K[U].tokenLimit||K[U].monthlyTokenLimit||K[U].dailyCostLimit||K[U].monthlyCostLimit)),V=!H&&(go(f)||go(v))&&(go(a)||go(M)),ee="",te="";if(Ie.resetMode==="Custom"){let U=new Date,et=Ie.resetDay||1,Ue=U.getFullYear(),He=U.getMonth();U.getDate()>=et&&(He+=1,He>11&&(He=0,Ue+=1));let Qe=new Date(Ue,He,et,0,0,0);ee=`${Qe.toLocaleString("default",{month:"short"}).toUpperCase()}-${et}`;let it=Math.max(0,Qe.getTime()-U.getTime()),ue=Math.floor(it/(1e3*60*60)),pe=Math.floor(ue/24),Je=ue%24;te=`(${pe} days: ${Je} hrs left)`}return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,padding:1,paddingBottom:0,paddingTop:0,width:"100%"},e.createElement(m,{marginBottom:1,justifyContent:"space-between",width:"100%"},e.createElement(i,{color:s.text,bold:!0,underline:!0},"USAGE LIMITS"),e.createElement(i,{color:s.textMuted},"[ ESC to Close ]")),V?e.createElement(m,{padding:1,justifyContent:"center",alignItems:"center",width:"100%"},e.createElement(i,{color:s.text,bold:!0},"LIMITS NOT SET")):H&&q.length>0?e.createElement(m,{flexDirection:"column",gap:0,width:"100%"},(()=>{let U=r?.columns||X?.columns||80;if(U<115){let He=Math.max(5,Math.min(30,U-50));return q.map(Qe=>{let Ke=K[Qe],it=0,ue=_n?.models?.[Qe]||{};for(let Te in ue)it+=ue[Te]?.tokens||0;let pe=0,Ze=(Ie.resetMode==="Custom"?Xr:rr)?.models?.[Qe]||{};for(let Te in Ze)pe+=Ze[Te]?.tokens||0;let W=0;for(let Te in ue)W+=ue[Te]?.cost||0;let ye=0;for(let Te in Ze)ye+=Ze[Te]?.cost||0;return e.createElement(m,{key:Qe,flexDirection:"column",borderStyle:"single",borderColor:s.borderMuted,paddingX:1,width:"100%"},e.createElement(m,{marginBottom:0},e.createElement(i,{color:s.primary,bold:!0},"\u25C6 ",Qe)),uo("Daily",it,Ke.tokenLimit||99999999999999,He,2,9),uo("Monthly",pe,Ke.monthlyTokenLimit||99999999999999,He,2,9),(!go(Ke.dailyCostLimit)||!go(Ke.monthlyCostLimit))&&e.createElement(e.Fragment,null,uo("Daily Cost",W,Ke.dailyCostLimit||99999999999999,He,2,11),uo("Monthly Cost",ye,Ke.monthlyCostLimit||99999999999999,He,2,11)))})}let Ue=[];for(let He=0;He<q.length;He+=2)Ue.push(q.slice(He,He+2));return Ue.map((He,Qe)=>e.createElement(m,{key:Qe,flexDirection:"row",width:"100%"},He.map(Ke=>{let it=K[Ke],ue=0,pe=_n?.models?.[Ke]||{};for(let rt in pe)ue+=pe[rt]?.tokens||0;let Je=0,W=(Ie.resetMode==="Custom"?Xr:rr)?.models?.[Ke]||{};for(let rt in W)Je+=W[rt]?.tokens||0;let ye=0;for(let rt in pe)ye+=pe[rt]?.cost||0;let Te=0;for(let rt in W)Te+=W[rt]?.cost||0;let Ee=He.length===1,nt=Ee?U:Math.floor(U/2),ke=Math.max(5,Math.min(25,nt-36));return e.createElement(m,{key:Ke,flexDirection:"column",borderStyle:"single",borderColor:s.borderMuted,paddingX:1,width:Ee?"100%":"50%"},e.createElement(m,{marginBottom:0},e.createElement(i,{color:s.primary,bold:!0},"\u25C6 ",Ke)),uo("Daily",ue,it.tokenLimit||99999999999999,ke,2,9),uo("Monthly",Je,it.monthlyTokenLimit||99999999999999,ke,2,9),(!go(it.dailyCostLimit)||!go(it.monthlyCostLimit))&&e.createElement(e.Fragment,null,uo("Daily Cost",ye,it.dailyCostLimit||99999999999999,ke,2,11),uo("Monthly Cost",Te,it.monthlyCostLimit||99999999999999,ke,2,11)))})))})(),ee?e.createElement(m,{marginLeft:2,marginTop:1},e.createElement(i,{color:s.textMuted},"Monthly Reset: "),e.createElement(i,{color:s.accent||"magenta",bold:!0},ee),te?e.createElement(i,{color:s.textMuted},` ${te}`):null):e.createElement(m,{marginLeft:2,marginTop:1},e.createElement(i,{color:s.textMuted},"Monthly Reset: "),e.createElement(i,{color:s.secondary||"blue",bold:!0},"Rolling 30-Day Window"))):e.createElement(m,{flexDirection:"column",borderStyle:"single",borderColor:s.borderMuted,paddingX:1,width:"100%"},uo("Daily Tokens",c,f,"green"),uo("Monthly Tokens",x,v,"yellow"),(!go(a)||!go(M))&&e.createElement(e.Fragment,null,uo("Daily Cost",u,a,"cyan"),uo("Monthly Cost",h,M,"magenta")),ee?e.createElement(m,{marginLeft:4,marginTop:1},e.createElement(i,{color:s.textMuted},"Monthly Reset: "),e.createElement(i,{color:s.accent||"magenta",bold:!0},ee),te?e.createElement(i,{color:s.textMuted},` ${te}`):null):e.createElement(m,{marginLeft:4,marginTop:1},e.createElement(i,{color:s.textMuted},"Monthly Reset: "),e.createElement(i,{color:s.secondary||"blue",bold:!0},"Rolling 30-Day Window"))))}case"input":return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,padding:0,width:"100%"},e.createElement(m,{paddingX:1},e.createElement(i,{color:s.text,bold:!0},"DATA CONFIGURATION")),Qo?.note&&e.createElement(m,{paddingX:1,marginBottom:1},e.createElement(i,{color:s.textMuted,italic:!0},Qo.note)),e.createElement(m,{paddingX:1,flexDirection:"row"},e.createElement(i,{color:s.text,bold:!0},Qo?.label," "),e.createElement(Zn,{value:Qo?.value||"",onChange:n=>so(o=>({...o,value:n})),onSubmit:async n=>{let{key:o,subKey:c,next:f,onDone:x}=Qo,v={...Ie},u={};if(o==="quotas"){let a;c.toLowerCase().includes("costlimit")?a=parseFloat(n)||0:c.toLowerCase().includes("limit")||c==="resetDay"?a=parseInt(n)||0:a=n,c==="resetDay"&&(a=Math.max(1,Math.min(30,a))),v[c]=a,po(v),u.quotas=v}else if(o==="providerBudgets"){let a=Qo.providerKey,h=c.toLowerCase().includes("limit")?parseInt(n)||0:n,M=v.providerBudgets||{};v.providerBudgets={...M,[a]:{...M[a]||{},[c]:h}},po(v),u.quotas=v}else if(o==="activeModel")Gt(n),u.activeModel=n;else if(o==="janitorModel")Me(n),u.janitorModel=n;else if(o==="autoApproveCommands"||o==="autoDisallowCommands"||o==="alwaysAskCommands"){let a={...de,[o]:n.trim(),sandboxPreset:"Custom"};Ot(a),u.systemSettings=a}else if(o==="externalDataPath"){let a={...de,useExternalData:!0,externalDataPath:n.trim()};Ot(a),u.systemSettings=a,I(h=>[...h,{id:Date.now(),role:"system",text:"[EXTERNAL STORAGE] Flux Flow will use "+n.trim()+" for data after restart."}])}else if(o==="customOpenAIBaseUrl"){let a=n.trim().replace(/\/+$/,""),h={...de,customOpenAIBaseUrl:a,memory:!1};Ot(h),u.systemSettings=h;let M=(Ie.providerTiers||{}).c_openai||"Free",N=ao("c_openai",M)||"";zo("c_openai"),Gt(N),Ht(M),u.aiProvider="c_openai",u.activeModel=N,u.apiTier=M;let K=await on("c_openai")||"";Pt(K),xo(K,{aiProvider:"c_openai",onIDEApproval:Io}),I(q=>[...q,{id:Date.now(),role:"system",text:`\u2726 Custom OpenAI Base URL saved!
|
|
302
|
+
\u2800`,isMeta:!0}]),ne(Jo)}else so({label:`Enter ${o==="c_openai"?"Custom (OpenAI)":o} API Key:`,key:"providerKey",provider:o,value:"",returnView:Jo}),ne("input")},onClose:()=>ne(Jo)});case"apiTier":return e.createElement($t,{title:`Show Paid models from ${F.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] ${ze==="Paid"?"\u25CF":""}`,value:"Paid"},{label:"Back",value:"settings"}],theme:de.theme,onSelect:n=>{if(n.value==="settings"||n.value==="Back"){ne("settings");return}let o=n.value;Ht(o);let c={...Ie.providerTiers||{},[F]:o},f={...Ie,providerTiers:c};po(f),Kt({apiTier:o,quotas:f}),ne("settings")}});case"resetMode":return e.createElement($t,{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:de.theme,onSelect:n=>{if(n.value==="apiTier"||n.value==="Back"){ne("apiTier");return}let o=n.value,c={...Ie,resetMode:o};po(c),o==="Custom"?(so({label:"Enter monthly reset day (1-30):",key:"quotas",subKey:"resetDay",value:String(Ie.resetDay||1),returnView:"settings"}),ne("input")):(Kt({apiTier:ze,quotas:c}),ne("settings"))},onClose:()=>ne("apiTier")});case"budgetTypeSelect":return e.createElement($t,{title:"SELECT BUDGET TYPE",items:[{label:`Global Budget (single limit for all providers) ${ze==="Paid"&&!Ie.providerBudgets?.__useProvider?"\u25CF":""}`,value:"global"},{label:`Provider Budgets (set limits per provider individually) ${Ie.providerBudgets?.__useProvider?"\u25CF":""}`,value:"provider"},{label:"Back",value:Uo}],theme:de.theme,onSelect:n=>{if(n.value===Uo||n.value==="Back"){ne(Uo);return}if(n.value==="global"){let o={...Ie,agentLimit:99999999,tokenLimit:99999999999999,monthlyTokenLimit:99999999999999,providerBudgets:{__useProvider:!1}};po(o);let c=Uo==="settings"?"resetMode":"budgetResetMode";so({label:"Enter Agent daily budget (tokens used):",key:"quotas",subKey:"tokenLimit",value:qo(o.tokenLimit),returnView:Uo,next:f=>({label:"Enter Agent monthly budget (tokens used):",key:"quotas",subKey:"monthlyTokenLimit",value:qo(f.monthlyTokenLimit),returnView:Uo,next:x=>({label:"Enter Daily Cost Limit ($ or 0 for unlimited):",key:"quotas",subKey:"dailyCostLimit",value:qo(x.dailyCostLimit),returnView:Uo,next:v=>({label:"Enter Monthly Cost Limit ($ or 0 for unlimited):",key:"quotas",subKey:"monthlyCostLimit",value:qo(v.monthlyCostLimit),returnView:c})})})}),ne("input")}else if(n.value==="provider"){let o={...Ie,agentLimit:99999999,tokenLimit:99999999999999,monthlyTokenLimit:99999999999999,providerBudgets:{...Ie.providerBudgets||{},__useProvider:!0}};po(o),ne("providerBudgetSelect")}},onClose:()=>ne(Uo)});case"providerBudgetSelect":{let n=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","Infron","APInex","xKiro"],o=n.some(c=>Ss[c]);return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,padding:0,width:"100%"},e.createElement(m,{paddingX:1,marginBottom:1},e.createElement(i,{color:s.text,bold:!0},"SELECT PROVIDERS TO SET LIMITS FOR")),n.map((c,f)=>{let x=f===Bi,v=!!Ss[c];return e.createElement(m,{key:c,backgroundColor:x?s.highlightBg||"#2a2a2a":void 0,paddingX:1,width:"100%",flexDirection:"row"},e.createElement(i,{color:x?s.text:s.textMuted,bold:x},x?"\u276F ":" "),e.createElement(i,{color:v?s.success||"green":s.textMuted},v?"\u2611":"\u2610"),e.createElement(i,{color:x?s.text:s.textMuted,bold:x}," ",c),v&&(Ie.providerBudgets?.[c]?.agentLimit||Ie.providerBudgets?.[c]?.tokenLimit||Ie.providerBudgets?.[c]?.monthlyTokenLimit||Ie.providerBudgets?.[c]?.dailyCostLimit||Ie.providerBudgets?.[c]?.monthlyCostLimit)?e.createElement(i,{color:s.primary||"cyan"}," (budget set)"):null)}),e.createElement(m,{paddingX:1,marginTop:1,flexDirection:"column"},e.createElement(i,{color:s.textMuted,italic:!0},"\u2191\u2193 Navigate \u2022 Space to toggle \u2022 Enter to confirm \u2022 ESC to go back"),!o&&e.createElement(i,{color:s.warning||"yellow",italic:!0}," Select at least one provider to continue")))}case"providerBudgetFlow":{let n=kn.length,o=n*4;return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,padding:0,width:"100%"},e.createElement(m,{paddingX:1,marginBottom:0,justifyContent:"space-between",flexDirection:"row"},e.createElement(i,{color:s.text,bold:!0},"PROVIDER BUDGET CONFIGURATION"),e.createElement(i,{color:s.textMuted,italic:!0},"(0 or blank = unlimited)")),e.createElement(m,{paddingX:1,marginTop:1,flexDirection:"row"},e.createElement(m,{width:13},e.createElement(i,{color:s.textMuted,bold:!0},"PROVIDER")),e.createElement(m,{width:20,paddingLeft:1},e.createElement(i,{color:s.textMuted,bold:!0},"DAILY TOKENS")),e.createElement(m,{width:22,paddingLeft:1},e.createElement(i,{color:s.textMuted,bold:!0},"MONTHLY TOKENS")),e.createElement(m,{width:18,paddingLeft:1},e.createElement(i,{color:s.textMuted,bold:!0},"DAILY COST ($)")),e.createElement(m,{width:20,paddingLeft:1},e.createElement(i,{color:s.textMuted,bold:!0},"MONTHLY COST ($)"))),e.createElement(m,{paddingX:1},e.createElement(i,{color:s.borderMuted},"\u2500".repeat(93))),kn.map((c,f)=>{let x=f*4,v=f*4+1,u=f*4+2,a=f*4+3,h=An===x,M=An===v,N=An===u,H=An===a,K=h||M||N||H,q=tr[c]?.tokenLimit??"",V=tr[c]?.monthlyTokenLimit??"",ee=tr[c]?.dailyCostLimit??"",te=tr[c]?.monthlyCostLimit??"";return e.createElement(m,{key:c,flexDirection:"row",paddingX:1,marginY:0,backgroundColor:K?s.highlightBg||"#2a2a2a":void 0},e.createElement(m,{width:13,flexDirection:"row"},e.createElement(i,{color:K?s.primary||"cyan":s.text,bold:K},K?"\u276F ":" ",c)),e.createElement(m,{width:20,paddingLeft:1,flexDirection:"row"},h?e.createElement(m,{flexDirection:"row"},e.createElement(i,{color:s.primary||"cyan",bold:!0},"[ "),e.createElement(Zn,{value:q,onChange:U=>{or(et=>({...et,[c]:{...et[c]||{},tokenLimit:U}}))},onSubmit:()=>bo(v)}),e.createElement(i,{color:s.primary||"cyan",bold:!0}," ]")):e.createElement(i,{color:q?s.text:s.textMuted},"[ ",q||"0 (\u221E)"," ]")),e.createElement(m,{width:22,paddingLeft:1,flexDirection:"row"},M?e.createElement(m,{flexDirection:"row"},e.createElement(i,{color:s.primary||"cyan",bold:!0},"[ "),e.createElement(Zn,{value:V,onChange:U=>{or(et=>({...et,[c]:{...et[c]||{},monthlyTokenLimit:U}}))},onSubmit:()=>bo(u)}),e.createElement(i,{color:s.primary||"cyan",bold:!0}," ]")):e.createElement(i,{color:V?s.text:s.textMuted},"[ ",V||"0 (\u221E)"," ]")),e.createElement(m,{width:18,paddingLeft:1,flexDirection:"row"},N?e.createElement(m,{flexDirection:"row"},e.createElement(i,{color:s.primary||"cyan",bold:!0},"[ $"),e.createElement(Zn,{value:ee,onChange:U=>{or(et=>({...et,[c]:{...et[c]||{},dailyCostLimit:U}}))},onSubmit:()=>bo(a)}),e.createElement(i,{color:s.primary||"cyan",bold:!0}," ]")):e.createElement(i,{color:ee?s.warning||"yellow":s.textMuted},"[ ",ee?`$${ee}`:"0 (\u221E)"," ]")),e.createElement(m,{width:20,paddingLeft:1,flexDirection:"row"},H?e.createElement(m,{flexDirection:"row"},e.createElement(i,{color:s.primary||"cyan",bold:!0},"[ $"),e.createElement(Zn,{value:te,onChange:U=>{or(et=>({...et,[c]:{...et[c]||{},monthlyCostLimit:U}}))},onSubmit:()=>{f+1<n?bo((f+1)*4):bo(o)}}),e.createElement(i,{color:s.primary||"cyan",bold:!0}," ]")):e.createElement(i,{color:te?s.warning||"yellow":s.textMuted},"[ ",te?`$${te}`:"0 (\u221E)"," ]")))}),e.createElement(m,{paddingX:1,marginTop:1},An===o?e.createElement(m,{backgroundColor:s.highlightBg||"#2a2a2a",paddingX:1},e.createElement(i,{color:s.success||"green",bold:!0},"\u276F [ Save & Apply Budgets ]")):e.createElement(i,{color:s.textMuted}," [ Save & Apply Budgets ]")),e.createElement(m,{paddingX:1,marginTop:1,flexDirection:"column"},e.createElement(i,{color:s.textMuted,italic:!0},"\u2191\u2193/\u2190\u2192 Navigate \u2022 Enter next / save \u2022 ESC to go back")))}case"budgetResetMode":return e.createElement($t,{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:de.theme,onSelect:n=>{if(n.value==="chat"||n.value==="Back"){ne("chat");return}let o=n.value,c={...Ie,resetMode:o};po(c),o==="Custom"?(so({label:"Enter monthly reset day (1-30):",key:"quotas",subKey:"resetDay",value:String(Ie.resetDay||1),returnView:"chat"}),ne("input")):(Kt({apiTier:ze,quotas:c}),ne("chat"))},onClose:()=>ne("chat")});case"budgetView":{let n=_n?.agent||0,o=Ie.agentLimit||99999999,c=_n?.tokens||0,f=Ie.tokenLimit||99999999999999,x=Ie.resetMode==="Custom"?Xr?.tokens||0:rr?.tokens||0,v=Ie.monthlyTokenLimit||99999999999999,u=_n?.cost||0,a=Ie.dailyCostLimit||99999999999999,h=Ie.resetMode==="Custom"?Xr?.cost||0:rr?.cost||0,M=Ie.monthlyCostLimit||99999999999999,N=ze!=="Paid",H=!!Ie.providerBudgets?.__useProvider,K=Ie.providerBudgets||{},q=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","Infron","APInex","xKiro"].filter(U=>K[U]&&(K[U].agentLimit||K[U].tokenLimit||K[U].monthlyTokenLimit||K[U].dailyCostLimit||K[U].monthlyCostLimit)),V=!H&&(go(f)||go(v))&&(go(a)||go(M)),ee="",te="";if(Ie.resetMode==="Custom"){let U=new Date,et=Ie.resetDay||1,Ue=U.getFullYear(),He=U.getMonth();U.getDate()>=et&&(He+=1,He>11&&(He=0,Ue+=1));let Qe=new Date(Ue,He,et,0,0,0);ee=`${Qe.toLocaleString("default",{month:"short"}).toUpperCase()}-${et}`;let it=Math.max(0,Qe.getTime()-U.getTime()),ue=Math.floor(it/(1e3*60*60)),pe=Math.floor(ue/24),Je=ue%24;te=`(${pe} days: ${Je} hrs left)`}return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,padding:1,paddingBottom:0,paddingTop:0,width:"100%"},e.createElement(m,{marginBottom:1,justifyContent:"space-between",width:"100%"},e.createElement(i,{color:s.text,bold:!0,underline:!0},"USAGE LIMITS"),e.createElement(i,{color:s.textMuted},"[ ESC to Close ]")),V?e.createElement(m,{padding:1,justifyContent:"center",alignItems:"center",width:"100%"},e.createElement(i,{color:s.text,bold:!0},"LIMITS NOT SET")):H&&q.length>0?e.createElement(m,{flexDirection:"column",gap:0,width:"100%"},(()=>{let U=r?.columns||X?.columns||80;if(U<115){let He=Math.max(5,Math.min(30,U-50));return q.map(Qe=>{let Ve=K[Qe],it=0,ue=_n?.models?.[Qe]||{};for(let Te in ue)it+=ue[Te]?.tokens||0;let pe=0,Ze=(Ie.resetMode==="Custom"?Xr:rr)?.models?.[Qe]||{};for(let Te in Ze)pe+=Ze[Te]?.tokens||0;let W=0;for(let Te in ue)W+=ue[Te]?.cost||0;let ye=0;for(let Te in Ze)ye+=Ze[Te]?.cost||0;return e.createElement(m,{key:Qe,flexDirection:"column",borderStyle:"single",borderColor:s.borderMuted,paddingX:1,width:"100%"},e.createElement(m,{marginBottom:0},e.createElement(i,{color:s.primary,bold:!0},"\u25C6 ",Qe)),uo("Daily",it,Ve.tokenLimit||99999999999999,He,2,9),uo("Monthly",pe,Ve.monthlyTokenLimit||99999999999999,He,2,9),(!go(Ve.dailyCostLimit)||!go(Ve.monthlyCostLimit))&&e.createElement(e.Fragment,null,uo("Daily Cost",W,Ve.dailyCostLimit||99999999999999,He,2,11),uo("Monthly Cost",ye,Ve.monthlyCostLimit||99999999999999,He,2,11)))})}let Ue=[];for(let He=0;He<q.length;He+=2)Ue.push(q.slice(He,He+2));return Ue.map((He,Qe)=>e.createElement(m,{key:Qe,flexDirection:"row",width:"100%"},He.map(Ve=>{let it=K[Ve],ue=0,pe=_n?.models?.[Ve]||{};for(let rt in pe)ue+=pe[rt]?.tokens||0;let Je=0,W=(Ie.resetMode==="Custom"?Xr:rr)?.models?.[Ve]||{};for(let rt in W)Je+=W[rt]?.tokens||0;let ye=0;for(let rt in pe)ye+=pe[rt]?.cost||0;let Te=0;for(let rt in W)Te+=W[rt]?.cost||0;let Ee=He.length===1,nt=Ee?U:Math.floor(U/2),ke=Math.max(5,Math.min(25,nt-36));return e.createElement(m,{key:Ve,flexDirection:"column",borderStyle:"single",borderColor:s.borderMuted,paddingX:1,width:Ee?"100%":"50%"},e.createElement(m,{marginBottom:0},e.createElement(i,{color:s.primary,bold:!0},"\u25C6 ",Ve)),uo("Daily",ue,it.tokenLimit||99999999999999,ke,2,9),uo("Monthly",Je,it.monthlyTokenLimit||99999999999999,ke,2,9),(!go(it.dailyCostLimit)||!go(it.monthlyCostLimit))&&e.createElement(e.Fragment,null,uo("Daily Cost",ye,it.dailyCostLimit||99999999999999,ke,2,11),uo("Monthly Cost",Te,it.monthlyCostLimit||99999999999999,ke,2,11)))})))})(),ee?e.createElement(m,{marginLeft:2,marginTop:1},e.createElement(i,{color:s.textMuted},"Monthly Reset: "),e.createElement(i,{color:s.accent||"magenta",bold:!0},ee),te?e.createElement(i,{color:s.textMuted},` ${te}`):null):e.createElement(m,{marginLeft:2,marginTop:1},e.createElement(i,{color:s.textMuted},"Monthly Reset: "),e.createElement(i,{color:s.secondary||"blue",bold:!0},"Rolling 30-Day Window"))):e.createElement(m,{flexDirection:"column",borderStyle:"single",borderColor:s.borderMuted,paddingX:1,width:"100%"},uo("Daily Tokens",c,f,"green"),uo("Monthly Tokens",x,v,"yellow"),(!go(a)||!go(M))&&e.createElement(e.Fragment,null,uo("Daily Cost",u,a,"cyan"),uo("Monthly Cost",h,M,"magenta")),ee?e.createElement(m,{marginLeft:4,marginTop:1},e.createElement(i,{color:s.textMuted},"Monthly Reset: "),e.createElement(i,{color:s.accent||"magenta",bold:!0},ee),te?e.createElement(i,{color:s.textMuted},` ${te}`):null):e.createElement(m,{marginLeft:4,marginTop:1},e.createElement(i,{color:s.textMuted},"Monthly Reset: "),e.createElement(i,{color:s.secondary||"blue",bold:!0},"Rolling 30-Day Window"))))}case"input":return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,padding:0,width:"100%"},e.createElement(m,{paddingX:1},e.createElement(i,{color:s.text,bold:!0},"DATA CONFIGURATION")),Qo?.note&&e.createElement(m,{paddingX:1,marginBottom:1},e.createElement(i,{color:s.textMuted,italic:!0},Qo.note)),e.createElement(m,{paddingX:1,flexDirection:"row"},e.createElement(i,{color:s.text,bold:!0},Qo?.label," "),e.createElement(Zn,{value:Qo?.value||"",onChange:n=>so(o=>({...o,value:n})),onSubmit:async n=>{let{key:o,subKey:c,next:f,onDone:x}=Qo,v={...Ie},u={};if(o==="quotas"){let a;c.toLowerCase().includes("costlimit")?a=parseFloat(n)||0:c.toLowerCase().includes("limit")||c==="resetDay"?a=parseInt(n)||0:a=n,c==="resetDay"&&(a=Math.max(1,Math.min(30,a))),v[c]=a,po(v),u.quotas=v}else if(o==="providerBudgets"){let a=Qo.providerKey,h=c.toLowerCase().includes("limit")?parseInt(n)||0:n,M=v.providerBudgets||{};v.providerBudgets={...M,[a]:{...M[a]||{},[c]:h}},po(v),u.quotas=v}else if(o==="activeModel")Gt(n),u.activeModel=n;else if(o==="janitorModel")Me(n),u.janitorModel=n;else if(o==="autoApproveCommands"||o==="autoDisallowCommands"||o==="alwaysAskCommands"){let a={...de,[o]:n.trim(),sandboxPreset:"Custom"};Ot(a),u.systemSettings=a}else if(o==="externalDataPath"){let a={...de,useExternalData:!0,externalDataPath:n.trim()};Ot(a),u.systemSettings=a,I(h=>[...h,{id:Date.now(),role:"system",text:"[EXTERNAL STORAGE] Flux Flow will use "+n.trim()+" for data after restart."}])}else if(o==="customOpenAIBaseUrl"){let a=n.trim().replace(/\/+$/,""),h={...de,customOpenAIBaseUrl:a,memory:!1};Ot(h),u.systemSettings=h;let M=(Ie.providerTiers||{}).c_openai||"Free",N=ao("c_openai",M)||"";zo("c_openai"),Gt(N),Ht(M),u.aiProvider="c_openai",u.activeModel=N,u.apiTier=M;let K=await on("c_openai")||"";Pt(K),xo(K,{aiProvider:"c_openai",onIDEApproval:Io}),I(q=>[...q,{id:Date.now(),role:"system",text:`\u2726 Custom OpenAI Base URL saved!
|
|
303
303
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Switched to Custom (OpenAI)
|
|
304
304
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Endpoint: ${a}${N?`
|
|
305
305
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: ${N}`:""}
|
|
306
|
-
\u2800`,isMeta:!0}])}else if(o==="imageSettings"){let a=n.trim();if(a.startsWith("sk_")){let h={..._o,apiKey:a};$r(h),u.imageSettings=h,I(M=>(O(M.length+1),[...M,{id:Date.now(),role:"system",text:"[IMAGE KEY] Custom API key saved successfully.",isMeta:!0}]))}}else if(o==="providerKey"){let a=n.trim(),h=Qo.provider;(h==="Ollama"||h==="9router")&&(a==="LOCAL"||a==="")&&(a="LOCAL",h==="Ollama"&&(Ot(K=>({...K,ollamaEndpoint:"Local"})),u.systemSettings={...de,ollamaEndpoint:"Local"}));let M="";if(h==="9router"){let K=await
|
|
306
|
+
\u2800`,isMeta:!0}])}else if(o==="imageSettings"){let a=n.trim();if(a.startsWith("sk_")){let h={..._o,apiKey:a};$r(h),u.imageSettings=h,I(M=>(O(M.length+1),[...M,{id:Date.now(),role:"system",text:"[IMAGE KEY] Custom API key saved successfully.",isMeta:!0}]))}}else if(o==="providerKey"){let a=n.trim(),h=Qo.provider;(h==="Ollama"||h==="9router")&&(a==="LOCAL"||a==="")&&(a="LOCAL",h==="Ollama"&&(Ot(K=>({...K,ollamaEndpoint:"Local"})),u.systemSettings={...de,ollamaEndpoint:"Local"}));let M="";if(h==="9router"){let K=await yi();K.ok||(M=`
|
|
307
307
|
|
|
308
308
|
\x1B[33m\u2726 WARNING: 9router does not appear to be running on ${K.url}.\x1B[39m
|
|
309
|
-
\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
|
|
309
|
+
\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 ei(h,a),zo(h),Pt(a),xo(a,{aiProvider:h,onIDEApproval:Io});let N=(Ie.providerTiers||{})[h]||"Free",H=ao(h,N);Gt(H),Ht(N),u.aiProvider=h,u.activeModel=H,u.apiTier=N,(h==="NVIDIA"&&process.env.NVIDIA_BASE_URL||h==="Ollama"||h==="CrofAI"||h==="InferX"||h==="SenseNova"||h==="AIHubMix"||h==="Poolside"||h==="9router"||h==="ExpLabs"||h==="TokenHarbor"||h==="Infron"||h==="APInex"||h==="xKiro")&&(Ot(K=>({...K,memory:!1})),u.systemSettings={...de,memory:!1}),I(K=>(O(K.length+1),[...K,{id:Date.now(),role:"system",text:`\u2726 ${h} API Key saved successfully! ${H?`
|
|
310
310
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: ${H}`:""}${h==="Ollama"&&a==="LOCAL"?`
|
|
311
311
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Ollama Endpoint automatically switched to Local`:""}${h==="Ollama"||h==="CrofAI"||h==="InferX"||h==="SenseNova"||h==="AIHubMix"||h==="Poolside"||h==="9router"||h==="ExpLabs"||h==="TokenHarbor"||h==="Infron"||h==="APInex"||h==="xKiro"?`
|
|
312
312
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with ${h}`:""}${h==="NVIDIA"&&process.env.NVIDIA_BASE_URL?`
|
|
313
313
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available`:""}${M}
|
|
314
|
-
\u2800\u2800`,isMeta:!0}]))}if(f){let a=f(o==="quotas"||o==="providerBudgets"?v:n);so(a)}else x?(Kt({...u,apiTier:ze,quotas:v,imageSettings:u.imageSettings||_o}),so(null),x(v)):(Kt({...u,apiTier:ze,quotas:v,imageSettings:u.imageSettings||_o}),so(null),ne(Qo?.returnView||"settings"))}})),e.createElement(m,{paddingX:1,marginTop:1},e.createElement(i,{color:s.textMuted,dimColor:!0,italic:!0},"(Press Enter to confirm selection)")));case"stats":{let n=Hn==="modelBreakdown"||Hn==="dailyModelBreakdown",o=Hn==="daily"||Hn==="dailyModelBreakdown",c=o?_n:rr,f=o?"TODAY's USAGE":"LAST 30 DAYS USAGE",x=o?"TODAY'S MODEL TOKEN BREAKDOWN":"30-DAY MODEL TOKEN BREAKDOWN",v="Wall Time:",u="Tokens Used:",a="Images Made:",h="Image Credits:",M="Code Changes:",N="Tool Calls:",H=Math.max(4,(r?.rows||X?.rows||24)-15),K=(Qe,Ke,it,ue,pe,Je=0,Ze=!1)=>{let W=r?.columns||X?.columns||80,ye=Math.min(125,W-2),Te=Math.max(20,ye-6),Ee=Math.max(5,Te-Je-it.length-5),nt=Ke;nt.length>Ee&&(nt=nt.substring(0,Ee-1)+"\u2026");let ke=Math.max(2,Te-Je-nt.length-it.length-2),rt=" "+".".repeat(ke)+" ",ht=" ".repeat(Je);return e.createElement(m,{key:Qe,width:Te},e.createElement(i,{wrap:"truncate"},e.createElement(i,null,ht),e.createElement(i,{color:ue,bold:Ze},nt),e.createElement(i,{color:s.textMuted,dimColor:!0},rt),e.createElement(i,{color:pe,bold:Ze},it)))},q=Qe=>{let Ke=Number(Qe)||0;return Ke<=0?"":Ke<.001?" [<$0.001]":` [$${Ke.toFixed(Ke<.01?4:3)}]`},V=Qe=>{let Ke=Number(Qe)||0;return Ke<=0?"":Ke<.001?"<$0.001":`$${Ke.toFixed(Ke<.01?4:3)}`},ee=[],te=c?.models;if(!te||Object.keys(te).length===0)ee.push(e.createElement(m,{key:"empty",marginTop:1},e.createElement(i,{color:s.textMuted,italic:!0},"No model token usage recorded for ",o?"today":"the last 30 days",".")));else{let Qe=(ir||"").trim(),Ke="",it="";if(Qe.includes(":")){let pe=Qe.indexOf(":");Ke=Qe.substring(0,pe).trim().toLowerCase(),it=Qe.substring(pe+1).trim().toLowerCase()}else Ke=Qe.toLowerCase();let ue=Object.entries(te).sort(([pe],[Je])=>pe.localeCompare(Je,void 0,{sensitivity:"base"})).filter(([pe,Je])=>Ke&&!pe.toLowerCase().includes(Ke)?!1:it?Object.keys(Je).some(Ze=>Ze.toLowerCase().includes(it)):!0);ue.length===0?ee.push(e.createElement(m,{key:"no-matches",marginTop:1},e.createElement(i,{color:s.textMuted,italic:!0},'No results found matching "',ir,'".'))):ue.forEach(([pe,Je],Ze)=>{let W=Object.entries(Je).sort(([ke],[rt])=>ke.localeCompare(rt,void 0,{sensitivity:"base"})).filter(([ke])=>!it||ke.toLowerCase().includes(it));if(W.length===0)return;let ye=W.reduce((ke,[,rt])=>ke+(rt.tokens||0),0),Te=W.reduce((ke,[rt,ht])=>{if((ht.cost||0)>0)return ke+ht.cost;let J=hr(pe,rt);if(!J)return ke;let he=(ht.tokens||0)-(ht.candidateTokens||0),ve=ht.cachedTokens||0,Ve=Math.max(0,he-ve),Ae=ht.candidateTokens||0,Et=Ve/1e6*J.IN+ve/1e6*J.CR+Ae/1e6*J.OUT;return ke+Et},0),Ee=c?.providerRequests&&c.providerRequests[pe]||0;Ze>0&&ee.length>0&&ee.push(e.createElement(m,{key:`space-prov-${pe}`},e.createElement(i,null," ")));let nt=q(Te);ee.push(K(`prov-${pe}`,`${pe}:`,`${At(ye)} (${Ee})${nt}`,s.primary,s.text,0,!0)),W.forEach(([ke,rt],ht)=>{ht>0&&ee.push(e.createElement(m,{key:`space-mod-${pe}-${ke}`},e.createElement(i,null," ")));let J=hr(pe,ke),he=(rt.tokens||0)-(rt.candidateTokens||0),ve=rt.cachedTokens||0,Ve=Math.max(0,he-ve),Ae=rt.candidateTokens||0,Et=0,Co=0,jt=0;J&&(Et=Ve/1e6*J.IN,Co=ve/1e6*J.CR,jt=Ae/1e6*J.OUT);let Mo=(rt.cost||0)>0?rt.cost:Et+Co+jt,fr=q(Mo);ee.push(K(`mod-${pe}-${ke}`,`\xBB ${ke}:`,`${At(rt.tokens||0)}${fr}`,s.secondary,s.text,2,!0));let js=q(Et),jr=q(Co),yn=q(jt);ee.push(K(`in-${pe}-${ke}`,"\xBB Input Tokens:",`${At(he)}${js}`,s.textMuted,s.text,5,!1)),ve>0&&ee.push(K(`cache-${pe}-${ke}`,"\xBB Cached:",`${At(ve)}${jr}`,s.textMuted,s.text,7,!1)),ee.push(K(`out-${pe}-${ke}`,"\xBB Output Tokens:",`${At(Ae)}${yn}`,s.textMuted,s.text,5,!1))})})}let U=ee.length,et=Math.max(0,U-H);ie.current=et;let Ue=Math.min(dc,et),He=ee.slice(Ue,Ue+H);return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:3,paddingY:1,paddingBottom:0,width:Math.min(125,(r?.columns||100)-2)},n?e.createElement(m,{flexDirection:"column"},e.createElement(m,{justifyContent:"space-between"},e.createElement(i,{color:s.text,bold:!0,underline:!0},x),U>H&&e.createElement(i,{color:s.textMuted,dimColor:!0},"[",Ue+1,"-",Math.min(U,Ue+H)," of ",U,"] \u25B2\u25BC")),e.createElement(m,{marginTop:1},e.createElement(i,{color:s.secondary,bold:!0},"Filter (provider:model): "),e.createElement(i,{color:s.text},ir),e.createElement(i,{color:s.primary,bold:!0},"\u258A"),ir.length>0&&e.createElement(i,{color:s.textMuted,dimColor:!0,italic:!0}," (Type to search, Esc/Backspace to clear)")),e.createElement(m,{flexDirection:"column",height:H,marginTop:1},He)):e.createElement(e.Fragment,null,e.createElement(m,{marginBottom:1},e.createElement(i,{color:s.text,bold:!0,underline:!0},"SESSION TELEMETRY")),e.createElement(m,{flexDirection:"column"},e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},"Session Duration:")),e.createElement(i,{color:s.text},bn(Date.now()-Ci))),Ii>0&&e.createElement(e.Fragment,null,e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},"Model Requests:")),e.createElement(i,{color:s.text},Ii)),e.createElement(m,{marginLeft:2},e.createElement(m,{width:23},e.createElement(i,{color:s.textMuted},"\xBB API Time:")),e.createElement(i,{color:s.text},bn(Ur))),e.createElement(m,{marginLeft:2},e.createElement(m,{width:23},e.createElement(i,{color:s.textMuted},"\xBB Tool Time:")),e.createElement(i,{color:s.text},bn(_r)))),Ai>0&&e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},"Memory Agent:")),e.createElement(i,{color:s.text},Ai)),io>0&&e.createElement(e.Fragment,null,e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},"Tokens Consumed:")),e.createElement(i,{color:s.text},At(io))),(Dt?.cost||0)>0&&e.createElement(m,{marginLeft:2},e.createElement(m,{width:23},e.createElement(i,{color:s.textMuted},"\xBB Cost Estimate:")),e.createElement(i,{color:s.success||"green"},V(Dt.cost))),e.createElement(m,{marginLeft:2},e.createElement(m,{width:23},e.createElement(i,{color:s.textMuted},"\xBB Input Tokens:")),e.createElement(i,{color:s.text},At(io-Un))),wo>0&&e.createElement(m,{marginLeft:4},e.createElement(m,{width:21},e.createElement(i,{color:s.textMuted},"\xBB Cached:")),e.createElement(i,{color:s.text},At(wo))),Un>0&&e.createElement(m,{marginLeft:2},e.createElement(m,{width:23},e.createElement(i,{color:s.textMuted},"\xBB Output Tokens:")),e.createElement(i,{color:s.text},At(Un)))),Do?.tokens>0&&e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},"Active Context:")),e.createElement(i,{color:s.text},At(Do.tokens)," ",(()=>{let Ke={"16k":16e3,"32k":32e3,"64k":64e3,"128k":128e3,"256k":256e3,"512k":512e3,"1M":1e6}[de?.contextLength]||256e3,it=process.env.HIGH_CONTEXT,ue=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1;if(it&&it!=="false"){let Ze=parseInt(it,10);!isNaN(Ze)&&Ze>=0&&Ze<=1e6&&(Ke=Ze)}(F==="NVIDIA"&&(je?.includes("gpt")||je?.includes("qwen")||je?.includes("medium")||je.includes("muse"))||F==="Mistral")&&(Ke=126e3),F==="Google"&&je?.includes("gemma")&&ue&&(Ke=16e3);let pe=Do.tokens/Ke*100,Je=pe<60?s.text:pe<80?s.warning:s.danger;return e.createElement(i,{color:Je,dimColor:!0},"(",pe.toFixed(0),"%)")})())),Hr>0&&e.createElement(e.Fragment,null,e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},"Images Made:")),e.createElement(i,{color:s.text},Hr)),e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},"Image Credits:")),e.createElement(i,{color:s.text},Number(((Fi||0)*1e3).toFixed(0))," credits"))),e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},"Code Changes (Sess):")),e.createElement(i,{color:s.text},e.createElement(i,{color:s.success||"green"},"+",Dt.linesAdded)," ",e.createElement(i,{color:s.danger||"red"},"-",Dt.linesRemoved))),e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},"Tool Calls (Sess):")),e.createElement(i,{color:s.text},Dt.toolSuccess+Dt.toolFailure+Dt.toolDenied," ( "),e.createElement(i,{color:s.success||"green"},"\u2714 ",Dt.toolSuccess),e.createElement(i,{color:s.text}," "),e.createElement(i,{color:s.warning||"yellow"},"\u{1F6C7} ",Dt.toolDenied),e.createElement(i,{color:s.text}," "),e.createElement(i,{color:s.danger||"red"},"\u2718 ",Dt.toolFailure),e.createElement(i,{color:s.text}," )"))),e.createElement(m,{flexDirection:"column",marginTop:1},e.createElement(i,{color:s.text,bold:!0,underline:!0},f),e.createElement(m,{marginTop:1},e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},v)),e.createElement(i,{color:s.text},ji(c?.duration||0))),(c?.agent||0)>0&&e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},"Model Requests:")),e.createElement(i,{color:s.text},c?.agent||0)),(c?.background||0)>0&&e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},"Memory Agent:")),e.createElement(i,{color:s.text},c?.background||0)),(c?.tokens||0)>0&&e.createElement(e.Fragment,null,e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},u)),e.createElement(i,{color:s.text},At(c?.tokens||0))),(c?.cost||0)>0&&e.createElement(m,{marginLeft:2},e.createElement(m,{width:23},e.createElement(i,{color:s.textMuted},"\xBB Cost Estimate:")),e.createElement(i,{color:s.success||"green"},V(c.cost))),e.createElement(m,{marginLeft:2},e.createElement(m,{width:23},e.createElement(i,{color:s.textMuted},"\xBB Input Tokens:")),e.createElement(i,{color:s.text},At((c?.tokens||0)-(c?.candidateTokens||0)))),(c?.cachedTokens||0)>0&&e.createElement(m,{marginLeft:4},e.createElement(m,{width:21},e.createElement(i,{color:s.textMuted},"\xBB Cached:")),e.createElement(i,{color:s.text},At(c.cachedTokens))),(c?.candidateTokens||0)>0&&e.createElement(m,{marginLeft:2},e.createElement(m,{width:23},e.createElement(i,{color:s.textMuted},"\xBB Output Tokens:")),e.createElement(i,{color:s.text},At(c.candidateTokens)))),(c?.imageCalls?.length||0)>0&&e.createElement(e.Fragment,null,e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},a)),e.createElement(i,{color:s.text},c.imageCalls.length)),e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},h)),e.createElement(i,{color:s.text},Number(((c.imageCalls.reduce((Qe,Ke)=>Qe+Ke.cost,0)||0)*1e3).toFixed(0))," credits"))),e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},M)),e.createElement(i,{color:s.text},e.createElement(i,{color:s.success||"green"},"+",c?.linesAdded||0)," ",e.createElement(i,{color:s.danger||"red"},"-",c?.linesRemoved||0))),e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},N)),e.createElement(i,{color:s.text},(c?.toolSuccess||0)+(c?.toolFailure||0)+(c?.toolDenied||0)," ( "),e.createElement(i,{color:s.success||"green"},"\u2714 ",c?.toolSuccess||0),e.createElement(i,{color:s.text}," "),e.createElement(i,{color:s.warning||"yellow"},"\u{1F6C7} ",c?.toolDenied||0),e.createElement(i,{color:s.text}," "),e.createElement(i,{color:s.danger||"red"},"\u2718 ",c?.toolFailure||0),e.createElement(i,{color:s.text}," )")))),e.createElement(i,{color:s.textMuted,dimColor:!0,italic:!0},`
|
|
314
|
+
\u2800\u2800`,isMeta:!0}]))}if(f){let a=f(o==="quotas"||o==="providerBudgets"?v:n);so(a)}else x?(Kt({...u,apiTier:ze,quotas:v,imageSettings:u.imageSettings||_o}),so(null),x(v)):(Kt({...u,apiTier:ze,quotas:v,imageSettings:u.imageSettings||_o}),so(null),ne(Qo?.returnView||"settings"))}})),e.createElement(m,{paddingX:1,marginTop:1},e.createElement(i,{color:s.textMuted,dimColor:!0,italic:!0},"(Press Enter to confirm selection)")));case"stats":{let n=Hn==="modelBreakdown"||Hn==="dailyModelBreakdown",o=Hn==="daily"||Hn==="dailyModelBreakdown",c=o?_n:rr,f=o?"TODAY's USAGE":"LAST 30 DAYS USAGE",x=o?"TODAY'S MODEL TOKEN BREAKDOWN":"30-DAY MODEL TOKEN BREAKDOWN",v="Wall Time:",u="Tokens Used:",a="Images Made:",h="Image Credits:",M="Code Changes:",N="Tool Calls:",H=Math.max(4,(r?.rows||X?.rows||24)-15),K=(Qe,Ve,it,ue,pe,Je=0,Ze=!1)=>{let W=r?.columns||X?.columns||80,ye=Math.min(125,W-2),Te=Math.max(20,ye-6),Ee=Math.max(5,Te-Je-it.length-5),nt=Ve;nt.length>Ee&&(nt=nt.substring(0,Ee-1)+"\u2026");let ke=Math.max(2,Te-Je-nt.length-it.length-2),rt=" "+".".repeat(ke)+" ",ht=" ".repeat(Je);return e.createElement(m,{key:Qe,width:Te},e.createElement(i,{wrap:"truncate"},e.createElement(i,null,ht),e.createElement(i,{color:ue,bold:Ze},nt),e.createElement(i,{color:s.textMuted,dimColor:!0},rt),e.createElement(i,{color:pe,bold:Ze},it)))},q=Qe=>{let Ve=Number(Qe)||0;return Ve<=0?"":Ve<.001?" [<$0.001]":` [$${Ve.toFixed(Ve<.01?4:3)}]`},V=Qe=>{let Ve=Number(Qe)||0;return Ve<=0?"":Ve<.001?"<$0.001":`$${Ve.toFixed(Ve<.01?4:3)}`},ee=[],te=c?.models;if(!te||Object.keys(te).length===0)ee.push(e.createElement(m,{key:"empty",marginTop:1},e.createElement(i,{color:s.textMuted,italic:!0},"No model token usage recorded for ",o?"today":"the last 30 days",".")));else{let Qe=(ir||"").trim(),Ve="",it="";if(Qe.includes(":")){let pe=Qe.indexOf(":");Ve=Qe.substring(0,pe).trim().toLowerCase(),it=Qe.substring(pe+1).trim().toLowerCase()}else Ve=Qe.toLowerCase();let ue=Object.entries(te).sort(([pe],[Je])=>pe.localeCompare(Je,void 0,{sensitivity:"base"})).filter(([pe,Je])=>Ve&&!pe.toLowerCase().includes(Ve)?!1:it?Object.keys(Je).some(Ze=>Ze.toLowerCase().includes(it)):!0);ue.length===0?ee.push(e.createElement(m,{key:"no-matches",marginTop:1},e.createElement(i,{color:s.textMuted,italic:!0},'No results found matching "',ir,'".'))):ue.forEach(([pe,Je],Ze)=>{let W=Object.entries(Je).sort(([ke],[rt])=>ke.localeCompare(rt,void 0,{sensitivity:"base"})).filter(([ke])=>!it||ke.toLowerCase().includes(it));if(W.length===0)return;let ye=W.reduce((ke,[,rt])=>ke+(rt.tokens||0),0),Te=W.reduce((ke,[rt,ht])=>{if((ht.cost||0)>0)return ke+ht.cost;let J=hr(pe,rt);if(!J)return ke;let he=(ht.tokens||0)-(ht.candidateTokens||0),ve=ht.cachedTokens||0,Ge=Math.max(0,he-ve),Ae=ht.candidateTokens||0,Et=Ge/1e6*J.IN+ve/1e6*J.CR+Ae/1e6*J.OUT;return ke+Et},0),Ee=c?.providerRequests&&c.providerRequests[pe]||0;Ze>0&&ee.length>0&&ee.push(e.createElement(m,{key:`space-prov-${pe}`},e.createElement(i,null," ")));let nt=q(Te);ee.push(K(`prov-${pe}`,`${pe}:`,`${At(ye)} (${Ee})${nt}`,s.primary,s.text,0,!0)),W.forEach(([ke,rt],ht)=>{ht>0&&ee.push(e.createElement(m,{key:`space-mod-${pe}-${ke}`},e.createElement(i,null," ")));let J=hr(pe,ke),he=(rt.tokens||0)-(rt.candidateTokens||0),ve=rt.cachedTokens||0,Ge=Math.max(0,he-ve),Ae=rt.candidateTokens||0,Et=0,Co=0,jt=0;J&&(Et=Ge/1e6*J.IN,Co=ve/1e6*J.CR,jt=Ae/1e6*J.OUT);let Mo=(rt.cost||0)>0?rt.cost:Et+Co+jt,fr=q(Mo);ee.push(K(`mod-${pe}-${ke}`,`\xBB ${ke}:`,`${At(rt.tokens||0)}${fr}`,s.secondary,s.text,2,!0));let js=q(Et),jr=q(Co),yn=q(jt);ee.push(K(`in-${pe}-${ke}`,"\xBB Input Tokens:",`${At(he)}${js}`,s.textMuted,s.text,5,!1)),ve>0&&ee.push(K(`cache-${pe}-${ke}`,"\xBB Cached:",`${At(ve)}${jr}`,s.textMuted,s.text,7,!1)),ee.push(K(`out-${pe}-${ke}`,"\xBB Output Tokens:",`${At(Ae)}${yn}`,s.textMuted,s.text,5,!1))})})}let U=ee.length,et=Math.max(0,U-H);ie.current=et;let Ue=Math.min(dc,et),He=ee.slice(Ue,Ue+H);return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:3,paddingY:1,paddingBottom:0,width:Math.min(125,(r?.columns||100)-2)},n?e.createElement(m,{flexDirection:"column"},e.createElement(m,{justifyContent:"space-between"},e.createElement(i,{color:s.text,bold:!0,underline:!0},x),U>H&&e.createElement(i,{color:s.textMuted,dimColor:!0},"[",Ue+1,"-",Math.min(U,Ue+H)," of ",U,"] \u25B2\u25BC")),e.createElement(m,{marginTop:1},e.createElement(i,{color:s.secondary,bold:!0},"Filter (provider:model): "),e.createElement(i,{color:s.text},ir),e.createElement(i,{color:s.primary,bold:!0},"\u258A"),ir.length>0&&e.createElement(i,{color:s.textMuted,dimColor:!0,italic:!0}," (Type to search, Esc/Backspace to clear)")),e.createElement(m,{flexDirection:"column",height:H,marginTop:1},He)):e.createElement(e.Fragment,null,e.createElement(m,{marginBottom:1},e.createElement(i,{color:s.text,bold:!0,underline:!0},"SESSION TELEMETRY")),e.createElement(m,{flexDirection:"column"},e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},"Session Duration:")),e.createElement(i,{color:s.text},bn(Date.now()-Mi))),ki>0&&e.createElement(e.Fragment,null,e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},"Model Requests:")),e.createElement(i,{color:s.text},ki)),e.createElement(m,{marginLeft:2},e.createElement(m,{width:23},e.createElement(i,{color:s.textMuted},"\xBB API Time:")),e.createElement(i,{color:s.text},bn(Ur))),e.createElement(m,{marginLeft:2},e.createElement(m,{width:23},e.createElement(i,{color:s.textMuted},"\xBB Tool Time:")),e.createElement(i,{color:s.text},bn(_r)))),Li>0&&e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},"Memory Agent:")),e.createElement(i,{color:s.text},Li)),io>0&&e.createElement(e.Fragment,null,e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},"Tokens Consumed:")),e.createElement(i,{color:s.text},At(io))),(Dt?.cost||0)>0&&e.createElement(m,{marginLeft:2},e.createElement(m,{width:23},e.createElement(i,{color:s.textMuted},"\xBB Cost Estimate:")),e.createElement(i,{color:s.success||"green"},V(Dt.cost))),e.createElement(m,{marginLeft:2},e.createElement(m,{width:23},e.createElement(i,{color:s.textMuted},"\xBB Input Tokens:")),e.createElement(i,{color:s.text},At(io-Un))),wo>0&&e.createElement(m,{marginLeft:4},e.createElement(m,{width:21},e.createElement(i,{color:s.textMuted},"\xBB Cached:")),e.createElement(i,{color:s.text},At(wo))),Un>0&&e.createElement(m,{marginLeft:2},e.createElement(m,{width:23},e.createElement(i,{color:s.textMuted},"\xBB Output Tokens:")),e.createElement(i,{color:s.text},At(Un)))),Do?.tokens>0&&e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},"Active Context:")),e.createElement(i,{color:s.text},At(Do.tokens)," ",(()=>{let Ve={"16k":16e3,"32k":32e3,"64k":64e3,"128k":128e3,"256k":256e3,"512k":512e3,"1M":1e6}[de?.contextLength]||256e3,it=process.env.HIGH_CONTEXT,ue=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1;if(it&&it!=="false"){let Ze=parseInt(it,10);!isNaN(Ze)&&Ze>=0&&Ze<=1e6&&(Ve=Ze)}(F==="NVIDIA"&&(je?.includes("gpt")||je?.includes("qwen")||je?.includes("medium")||je.includes("muse"))||F==="Mistral")&&(Ve=126e3),F==="Google"&&je?.includes("gemma")&&ue&&(Ve=16e3);let pe=Do.tokens/Ve*100,Je=pe<60?s.text:pe<80?s.warning:s.danger;return e.createElement(i,{color:Je,dimColor:!0},"(",pe.toFixed(0),"%)")})())),Hr>0&&e.createElement(e.Fragment,null,e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},"Images Made:")),e.createElement(i,{color:s.text},Hr)),e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},"Image Credits:")),e.createElement(i,{color:s.text},Number((($i||0)*1e3).toFixed(0))," credits"))),e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},"Code Changes (Sess):")),e.createElement(i,{color:s.text},e.createElement(i,{color:s.success||"green"},"+",Dt.linesAdded)," ",e.createElement(i,{color:s.danger||"red"},"-",Dt.linesRemoved))),e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},"Tool Calls (Sess):")),e.createElement(i,{color:s.text},Dt.toolSuccess+Dt.toolFailure+Dt.toolDenied," ( "),e.createElement(i,{color:s.success||"green"},"\u2714 ",Dt.toolSuccess),e.createElement(i,{color:s.text}," "),e.createElement(i,{color:s.warning||"yellow"},"\u{1F6C7} ",Dt.toolDenied),e.createElement(i,{color:s.text}," "),e.createElement(i,{color:s.danger||"red"},"\u2718 ",Dt.toolFailure),e.createElement(i,{color:s.text}," )"))),e.createElement(m,{flexDirection:"column",marginTop:1},e.createElement(i,{color:s.text,bold:!0,underline:!0},f),e.createElement(m,{marginTop:1},e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},v)),e.createElement(i,{color:s.text},qi(c?.duration||0))),(c?.agent||0)>0&&e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},"Model Requests:")),e.createElement(i,{color:s.text},c?.agent||0)),(c?.background||0)>0&&e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},"Memory Agent:")),e.createElement(i,{color:s.text},c?.background||0)),(c?.tokens||0)>0&&e.createElement(e.Fragment,null,e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},u)),e.createElement(i,{color:s.text},At(c?.tokens||0))),(c?.cost||0)>0&&e.createElement(m,{marginLeft:2},e.createElement(m,{width:23},e.createElement(i,{color:s.textMuted},"\xBB Cost Estimate:")),e.createElement(i,{color:s.success||"green"},V(c.cost))),e.createElement(m,{marginLeft:2},e.createElement(m,{width:23},e.createElement(i,{color:s.textMuted},"\xBB Input Tokens:")),e.createElement(i,{color:s.text},At((c?.tokens||0)-(c?.candidateTokens||0)))),(c?.cachedTokens||0)>0&&e.createElement(m,{marginLeft:4},e.createElement(m,{width:21},e.createElement(i,{color:s.textMuted},"\xBB Cached:")),e.createElement(i,{color:s.text},At(c.cachedTokens))),(c?.candidateTokens||0)>0&&e.createElement(m,{marginLeft:2},e.createElement(m,{width:23},e.createElement(i,{color:s.textMuted},"\xBB Output Tokens:")),e.createElement(i,{color:s.text},At(c.candidateTokens)))),(c?.imageCalls?.length||0)>0&&e.createElement(e.Fragment,null,e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},a)),e.createElement(i,{color:s.text},c.imageCalls.length)),e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},h)),e.createElement(i,{color:s.text},Number(((c.imageCalls.reduce((Qe,Ve)=>Qe+Ve.cost,0)||0)*1e3).toFixed(0))," credits"))),e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},M)),e.createElement(i,{color:s.text},e.createElement(i,{color:s.success||"green"},"+",c?.linesAdded||0)," ",e.createElement(i,{color:s.danger||"red"},"-",c?.linesRemoved||0))),e.createElement(m,null,e.createElement(m,{width:25},e.createElement(i,{color:s.secondary},N)),e.createElement(i,{color:s.text},(c?.toolSuccess||0)+(c?.toolFailure||0)+(c?.toolDenied||0)," ( "),e.createElement(i,{color:s.success||"green"},"\u2714 ",c?.toolSuccess||0),e.createElement(i,{color:s.text}," "),e.createElement(i,{color:s.warning||"yellow"},"\u{1F6C7} ",c?.toolDenied||0),e.createElement(i,{color:s.text}," "),e.createElement(i,{color:s.danger||"red"},"\u2718 ",c?.toolFailure||0),e.createElement(i,{color:s.text}," )")))),e.createElement(i,{color:s.textMuted,dimColor:!0,italic:!0},`
|
|
315
315
|
`,"(Press TAB to toggle Today/30-Day views, SPACE to toggle Model Breakdown, ESC to return)"))}case"dynamicDirDanger":return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:s.warning||"yellow",bold:!0,underline:!0},"DYNAMIC DIRECTORY AWARENESS"),e.createElement(i,{marginTop:1,color:s.text},"Enabling this keeps the agent aware of filesystem state in real time, but may reduce prompt cache efficiency."),e.createElement(i,{color:s.text},`
|
|
316
316
|
`,"RECOMMENDED SCENARIOS TO TURN ON:"),e.createElement(i,{color:s.textMuted},"\u2022 Repo is small."),e.createElement(i,{color:s.textMuted},"\u2022 The task benefits from real-time filesystem awareness."),e.createElement(i,{color:s.textMuted},"\u2022 Files are often created, renamed, or deleted."),e.createElement(i,{color:s.textMuted},"\u2022 You know exactly what you're signing up for."),e.createElement(i,{color:s.textMuted},"\u2022 You don't have conflicting decisions regarding token bills."),e.createElement(i,{color:s.textMuted},"\u2022 You want to see your wallet crying at 3am."),e.createElement(m,{marginTop:1},e.createElement($t,{title:"Confirm Intent",theme:de.theme,items:[{label:"Turn On Dynamic Directory Awareness",value:"on"},{label:"Keep Off (Recommended)",value:"off"}],onSelect:n=>{n.value==="on"&&Ot(o=>{let c={...o,dynamicDirAwareness:!0};return Kt({systemSettings:c,apiTier:ze,quotas:Ie}),c}),ne("settings")}})));case"dynamicDirHelp":return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:s.text,bold:!0,underline:!0},"DYNAMIC DIRECTORY AWARENESS \u2014 HELP & EXPLANATION"),e.createElement(i,{color:s.text,bold:!0},`
|
|
317
317
|
`,"OFF (Default):"),e.createElement(i,{color:s.textMuted},"\u2022 Takes a static directory snapshot at conversation/session start and places it in System Context."),e.createElement(i,{color:s.textMuted},"\u2022 Prompt cache remains stable across user turns, saving tokens and money."),e.createElement(i,{color:s.text,bold:!0},`
|
|
318
|
-
`,"ON:"),e.createElement(i,{color:s.textMuted},"\u2022 Rescans and updates the directory's state dynamically on every single user turn."),e.createElement(i,{color:s.textMuted},"\u2022 Provides real-time filesystem awareness if files are continuously created, renamed, or removed."),e.createElement(i,{color:s.textMuted},"\u2022 Changes Prompt Context on each turn, invalidating part of prompt caches and increasing token usage."),e.createElement(m,{marginTop:1},e.createElement($t,{title:"Actions",theme:de.theme,items:[{label:"Back to Settings",value:"back"}],onSelect:()=>ne("settings")})));case"autoExecDanger":return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:s.warning||"yellow",bold:!0,underline:!0},"SECURITY WARNING: YOLO MODE"),e.createElement(i,{marginTop:1,color:s.text},"Turning this ON allows the agent to execute terminal commands automatically without requiring your approval for each step."),e.createElement(i,{marginTop:1,color:s.text,bold:!0},"RISKS INVOLVED:"),e.createElement(i,{color:s.textMuted},"\u2022 The agent may execute destructive commands (rm -rf, etc.) by mistake unless specified in sandbox rules."),e.createElement(i,{color:s.textMuted},"\u2022 Unintended system changes if the agent hallucinates a path or command."),e.createElement(i,{color:s.textMuted},"\u2022 Reduced control over the agent's step-by-step decision making."),e.createElement(m,{marginTop:1},e.createElement($t,{title:"Confirm Intent",theme:de.theme,items:[{label:"I know the risk and turning on intentionally",value:"on"},{label:"Keep Off (Recommended)",value:"off"}],onSelect:n=>{n.value==="on"&&Ot(o=>({...o,autoExec:!0})),ne("settings")}})));case"advanceRollbackDanger":return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:1,paddingTop:0,width:"100%"},e.createElement(i,{color:s.warning||"yellow",bold:!0},"\u26A0 Emergency Rollback Notice"),e.createElement(i,{marginTop:1,color:s.text},"When enabled, full repo snapshots exist only during active AI turns."),e.createElement(i,{marginTop:1,color:s.text},"If catastrophic changes occur during a turn, avoid abruptly stopping the agent unless absolutely necessary (external damages out of codebase)."),e.createElement(i,{color:s.textMuted},"The agent may be able to automatically restore the repo to a safe state."),e.createElement(i,{marginTop:1,color:s.textMuted},"Once the turn ends, emergency snapshots are deleted and standard /revert takes over which may not retain full repo content."),e.createElement(i,{marginTop:1,color:s.textMuted},"(Requires Restart to take effect)"),e.createElement(m,{marginTop:1},e.createElement($t,{title:"Confirm",theme:de.theme,items:[{label:"I understand and wish to enable",value:"on"},{label:"Keep Off",value:"off"}],onSelect:n=>{n.value==="on"&&Ot(o=>({...o,advanceRollback:!0})),ne("settings")}})));case"externalDanger":return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:s.warning||"yellow",bold:!0,underline:!0},"SECURITY WARNING: EXTERNAL WORKSPACE ACCESS"),e.createElement(i,{marginTop:1,color:s.text},"Turning this ON allows the agent to execute tools (Read/Write/Exec) outside of the current active workspace directory."),e.createElement(i,{marginTop:1,color:s.text,bold:!0},"RISKS INVOLVED:"),e.createElement(i,{color:s.textMuted},"\u2022 Access to sensitive system files (SSH keys, Browser data, etc.)"),e.createElement(i,{color:s.textMuted},"\u2022 Potential for accidental or malicious deletion of OS-critical files."),e.createElement(i,{color:s.textMuted},"\u2022 Unauthorized script execution across your entire file system."),e.createElement(m,{marginTop:1},e.createElement($t,{title:"Confirm Intent",theme:de.theme,items:[{label:"I know the risk and turning on intentionally",value:"on"},{label:"Keep Off (Recommended)",value:"off"}],onSelect:n=>{n.value==="on"&&Ot(o=>({...o,allowExternalAccess:!0})),ne("settings")}})));case"doubleDanger":return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:s.danger||"red",bold:!0,underline:!0},"CRITICAL SECURITY WARNING: COMBINED SYSTEM RISK"),e.createElement(i,{marginTop:1,color:s.text},"You are attempting to enable BOTH [YOLO Mode] and [External Workspace Access] simultaneously."),e.createElement(i,{marginTop:1,color:s.danger||"red",bold:!0},"THIS IS NOT RECOMMENDED."),e.createElement(i,{marginTop:1,color:s.text,bold:!0},"THE CRITICAL RISK:"),e.createElement(i,{color:s.textMuted},"The agent will have the power to execute any command across your entire system WITHOUT your approval or supervision."),e.createElement(i,{color:s.danger||"red",italic:!0,marginTop:1},"A single hallucination or error could result in full system wipe or data theft."),e.createElement(m,{marginTop:1},e.createElement($t,{title:"Final Confirmation",theme:de.theme,items:[{label:"I agree knowing the consequences",value:"on"},{label:"Keep Off",value:"off"}],onSelect:n=>{n.value==="on"&&Ot(o=>({...o,autoExec:!0,allowExternalAccess:!0})),ne("settings")}})));case"key":case"deleteKey":return null;case"exit":return null;case"ask":return e.createElement(m,{width:"100%"},e.createElement(Sa,{question:pn?.question,options:pn?.options,onResolve:n=>{pn?.resolve&&pn.resolve(n),_s(null),ne("chat")},theme:de.theme}));case"revert":return e.createElement(m,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(
|
|
318
|
+
`,"ON:"),e.createElement(i,{color:s.textMuted},"\u2022 Rescans and updates the directory's state dynamically on every single user turn."),e.createElement(i,{color:s.textMuted},"\u2022 Provides real-time filesystem awareness if files are continuously created, renamed, or removed."),e.createElement(i,{color:s.textMuted},"\u2022 Changes Prompt Context on each turn, invalidating part of prompt caches and increasing token usage."),e.createElement(m,{marginTop:1},e.createElement($t,{title:"Actions",theme:de.theme,items:[{label:"Back to Settings",value:"back"}],onSelect:()=>ne("settings")})));case"autoExecDanger":return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:s.warning||"yellow",bold:!0,underline:!0},"SECURITY WARNING: YOLO MODE"),e.createElement(i,{marginTop:1,color:s.text},"Turning this ON allows the agent to execute terminal commands automatically without requiring your approval for each step."),e.createElement(i,{marginTop:1,color:s.text,bold:!0},"RISKS INVOLVED:"),e.createElement(i,{color:s.textMuted},"\u2022 The agent may execute destructive commands (rm -rf, etc.) by mistake unless specified in sandbox rules."),e.createElement(i,{color:s.textMuted},"\u2022 Unintended system changes if the agent hallucinates a path or command."),e.createElement(i,{color:s.textMuted},"\u2022 Reduced control over the agent's step-by-step decision making."),e.createElement(m,{marginTop:1},e.createElement($t,{title:"Confirm Intent",theme:de.theme,items:[{label:"I know the risk and turning on intentionally",value:"on"},{label:"Keep Off (Recommended)",value:"off"}],onSelect:n=>{n.value==="on"&&Ot(o=>({...o,autoExec:!0})),ne("settings")}})));case"advanceRollbackDanger":return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:1,paddingTop:0,width:"100%"},e.createElement(i,{color:s.warning||"yellow",bold:!0},"\u26A0 Emergency Rollback Notice"),e.createElement(i,{marginTop:1,color:s.text},"When enabled, full repo snapshots exist only during active AI turns."),e.createElement(i,{marginTop:1,color:s.text},"If catastrophic changes occur during a turn, avoid abruptly stopping the agent unless absolutely necessary (external damages out of codebase)."),e.createElement(i,{color:s.textMuted},"The agent may be able to automatically restore the repo to a safe state."),e.createElement(i,{marginTop:1,color:s.textMuted},"Once the turn ends, emergency snapshots are deleted and standard /revert takes over which may not retain full repo content."),e.createElement(i,{marginTop:1,color:s.textMuted},"(Requires Restart to take effect)"),e.createElement(m,{marginTop:1},e.createElement($t,{title:"Confirm",theme:de.theme,items:[{label:"I understand and wish to enable",value:"on"},{label:"Keep Off",value:"off"}],onSelect:n=>{n.value==="on"&&Ot(o=>({...o,advanceRollback:!0})),ne("settings")}})));case"externalDanger":return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:s.warning||"yellow",bold:!0,underline:!0},"SECURITY WARNING: EXTERNAL WORKSPACE ACCESS"),e.createElement(i,{marginTop:1,color:s.text},"Turning this ON allows the agent to execute tools (Read/Write/Exec) outside of the current active workspace directory."),e.createElement(i,{marginTop:1,color:s.text,bold:!0},"RISKS INVOLVED:"),e.createElement(i,{color:s.textMuted},"\u2022 Access to sensitive system files (SSH keys, Browser data, etc.)"),e.createElement(i,{color:s.textMuted},"\u2022 Potential for accidental or malicious deletion of OS-critical files."),e.createElement(i,{color:s.textMuted},"\u2022 Unauthorized script execution across your entire file system."),e.createElement(m,{marginTop:1},e.createElement($t,{title:"Confirm Intent",theme:de.theme,items:[{label:"I know the risk and turning on intentionally",value:"on"},{label:"Keep Off (Recommended)",value:"off"}],onSelect:n=>{n.value==="on"&&Ot(o=>({...o,allowExternalAccess:!0})),ne("settings")}})));case"doubleDanger":return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:s.danger||"red",bold:!0,underline:!0},"CRITICAL SECURITY WARNING: COMBINED SYSTEM RISK"),e.createElement(i,{marginTop:1,color:s.text},"You are attempting to enable BOTH [YOLO Mode] and [External Workspace Access] simultaneously."),e.createElement(i,{marginTop:1,color:s.danger||"red",bold:!0},"THIS IS NOT RECOMMENDED."),e.createElement(i,{marginTop:1,color:s.text,bold:!0},"THE CRITICAL RISK:"),e.createElement(i,{color:s.textMuted},"The agent will have the power to execute any command across your entire system WITHOUT your approval or supervision."),e.createElement(i,{color:s.danger||"red",italic:!0,marginTop:1},"A single hallucination or error could result in full system wipe or data theft."),e.createElement(m,{marginTop:1},e.createElement($t,{title:"Final Confirmation",theme:de.theme,items:[{label:"I agree knowing the consequences",value:"on"},{label:"Keep Off",value:"off"}],onSelect:n=>{n.value==="on"&&Ot(o=>({...o,autoExec:!0,allowExternalAccess:!0})),ne("settings")}})));case"key":case"deleteKey":return null;case"exit":return null;case"ask":return e.createElement(m,{width:"100%"},e.createElement(Sa,{question:pn?.question,options:pn?.options,onResolve:n=>{pn?.resolve&&pn.resolve(n),_s(null),ne("chat")},theme:de.theme}));case"revert":return e.createElement(m,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(Ti,{prompts:bc,onSelect:async n=>{r&&(r.write("\x1B[2J\x1B[3J\x1B[H"),r.isTTY&&r.write("\x1B[?2004h"));try{let o=await wr.rollbackToBefore(n);if(o.success){let{targetPrompt:c}=o;la(bt),Ys(a=>a+1),Wo(),lo.current={completedIndex:0,columns:X.columns,historicalBlocks:[],seenSelections:new Set,chatId:bt,clearKey:Tn+1};let f=Nt.findLastIndex(a=>a.role==="user"&&a.text&&(a.text.startsWith(c)||a.text.includes(c))),x=[...Nt];f!==-1&&(x=Nt.slice(0,f)),I(x),O(x.length),b(c),z(c.split(`
|
|
319
319
|
`).length>2);let v=x.filter(a=>!String(a.id).startsWith("welcome")&&(!a.isMeta||a.text&&a.text.includes("Request Cancelled")));await En(bt,null,v);let u=yt(2);I(a=>{let h=[...a,{id:"revert-ok-"+Date.now(),role:"system",text:`\u2726 Rollback Successful
|
|
320
320
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Reverted prompt loaded to input box.
|
|
321
321
|
\u2800`,isMeta:!0}];return O(h.length),h}),ne("chat")}}catch(o){let c=yt(2);I(f=>{let x=[...f,{id:"revert-err-"+Date.now(),role:"system",text:`\u2726 ERROR
|
|
322
322
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${o.message}
|
|
323
|
-
\u2800`,isMeta:!0}];return O(x.length),x}),ne("chat")}},onClose:()=>ne("chat"),theme:de.theme}));case"resume":return e.createElement(m,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(
|
|
323
|
+
\u2800`,isMeta:!0}];return O(x.length),x}),ne("chat")}},onClose:()=>ne("chat"),theme:de.theme}));case"resume":return e.createElement(m,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(hi,{onSelect:async n=>{let o=await Go();if(o[n]){if(r.write("\x1B[2J\x1B[3J\x1B[H"),process.stdout.isTTY){let v=o[n]?.name||"",u=v&&!v.startsWith("flow-")&&!v.startsWith("Session ")?v:"FluxFlow | Resumed";process.stdout.write(`\x1B]0;${u}\x07`),process.stdout.write(`\x1B]633;P;TerminalTitle=${u}\x07`)}Wo(),Ho.current=!0,Wr(n);let c=await yr(n);Pn.current=io-c.total,Nn.current=wo,$n.current=hn,zt.current=[],Ln(c.total),On(0),gn(0),Fn(0),Zo({tokens:c.context}),Ho.current=!1;let f=[...o[n].messages];f[0]?.text?.includes("\u2591\u2591\u2591\u2588\u2588\u2588")||f.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),I(f),ne("chat"),I(v=>{let u=[...v,{id:"sys-"+Date.now(),role:"system",text:`\u2726 SESSION RESUMED
|
|
324
324
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${n}
|
|
325
325
|
\u2800`,isMeta:!0}];return O(u.length),u})}},onDelete:async n=>await os(n),onClose:()=>ne("chat"),theme:de.theme}));case"keybindingsPrompt":return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:"grey",paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:"white",bold:!0,underline:!0},"CONFIGURE SHIFT+ENTER NEWLINE"),e.createElement(i,null,`
|
|
326
326
|
`,"To support multi-line inputs with ",e.createElement(i,{bold:!0,color:"white"},"Shift + Enter")," for newline, a terminal sequence keybinding needs to be added to your IDE configuration.",`
|
|
327
327
|
|
|
328
|
-
`,"Would you like FluxFlow to automatically add this to your ",cn()," keybindings?"),e.createElement(m,{marginTop:1},e.createElement($t,{title:"Add Keybinding?",items:[{label:"Yes, configure automatically",value:"yes"},{label:"No, skip",value:"no"}],onSelect:async n=>{n.value==="yes"?await Cs(cn()):Ts="\\ + Enter",ne("chat")},theme:de.theme})));case"memory":return e.createElement(m,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(
|
|
328
|
+
`,"Would you like FluxFlow to automatically add this to your ",cn()," keybindings?"),e.createElement(m,{marginTop:1},e.createElement($t,{title:"Add Keybinding?",items:[{label:"Yes, configure automatically",value:"yes"},{label:"No, skip",value:"no"}],onSelect:async n=>{n.value==="yes"?await Cs(cn()):Ts="\\ + Enter",ne("chat")},theme:de.theme})));case"memory":return e.createElement(m,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(bi,{onClose:()=>ne("chat"),theme:de.theme}));case"parserDownload":return e.createElement(m,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(wi,{onClose:()=>ne("settings")}));case"resolution":return e.createElement(m,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(xu,{data:wc,theme:de.theme,onResolve:n=>{Vs(null),ne("chat"),setTimeout(()=>{cl(n,!0)},500)},onEdit:n=>{Vs(null),ne("chat"),b(n)}}));case"approval":return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:"white",bold:!0,underline:!0},eo?.tool==="view_file"?"FILE READ PERMISSION":"FILE WRITE PERMISSION"),e.createElement(i,{marginTop:1},"The agent is attempting to ",eo?.tool==="view_file"?"read":"modify",": ",e.createElement(i,{color:"cyan"},vn(eo?.args||"{}").path||"Unknown File")),eo?.tool==="view_file"?null:Bn()?e.createElement(m,{marginTop:1,paddingX:1},e.createElement(i,{color:"cyan",italic:!0},"FluxFlow Companion is active. Review the changes in your editor.")):e.createElement(m,{marginTop:1,borderStyle:"single",borderColor:"#333",paddingX:1,flexDirection:"column"},e.createElement(i,{color:"gray"},"--- PROPOSED CONTENT ---"),(()=>{let n=vn(eo?.args||"{}"),o=[],c=new Set;if(Object.keys(n).forEach(v=>{let u=v.match(/^(searchContent|replaceContent|newContent|content_to_replace|content_to_add|TargetContent|ReplacementContent|replacementContent)(\d+)?$/);if(u){let a=u[2]?parseInt(u[2]):1;c.add(a)}}),Array.from(c).sort((v,u)=>v-u).forEach(v=>{let u,a;v===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${v}`]??n[`replaceContent${v}`]??n[`content_to_replace${v}`]??null,a=n[`newContent${v}`]??n[`content_to_add${v}`]??null),(u!==null||a!==null)&&o.push({replace:u,new:a})}),o.length>0)return e.createElement(m,{flexDirection:"column",marginTop:1},o.map((v,u)=>{let a=v.replace!==null,h=v.new!==null;return e.createElement(m,{key:u,flexDirection:"column",marginTop:u>0?1:0},o.length>1&&e.createElement(i,{color:"gray"},"Block ",u+1,":"),a&&e.createElement(m,null,e.createElement(i,{color:"red",wrap:"anywhere",bold:!0},"- ",v.replace)),h&&e.createElement(m,{marginTop:0},e.createElement(i,{color:"green",wrap:"anywhere",bold:!0},"+ ",v.new.replace(/\[\/n\]?/g,"\\n"))))}));let x=n.content||n.ReplacementContent||n.content_to_add||n.replacementContent||n.newContent||null;return e.createElement(i,{color:"white",wrap:"anywhere"},(x?x.replace(/\[\/n\]?/g,"\\n"):null)||"Updating file content...")})()),e.createElement(m,{marginTop:1},(()=>{let n=eo?.tool,o=vn(eo?.args||"{}"),c=o.path||o.targetPath||o.file||"",f=c?Ct.extname(c).toLowerCase():"",x=c?Ct.basename(c):"this file",v="Accept for this session";return n==="write_file"&&f?v=`Accept for this session (*${f})`:n==="update_file"&&x&&(v=`Accept for this session (${x})`),e.createElement($t,{title:"Action Required",items:[{label:"Accept this time",value:"allow"},...n==="view_file"?[]:[{label:v,value:"always"}],{label:"Don't accept",value:"deny"}],onSelect:u=>{u.value==="always"&&(n==="write_file"?f?Vi.current.add(f):Us(!0):n==="update_file"&&c?Yi.current.add(Ct.resolve(c).toLowerCase()):Us(!0));let a=u.value==="deny"?"deny":"allow";eo.resolve(a),Kn(null),ne("chat")},theme:de.theme})})()));case"mode":return e.createElement($t,{title:"SELECT EXECUTION MODE",items:[{label:`Flux (Dev Toolset Mode) ${Y==="Flux"?"\u25CF":""}`,value:"Flux"},{label:`Flow (Chat / Conversation Mode) ${Y==="Flow"?"\u25CF":""}`,value:"Flow"},{label:`ICU (Interactive Computer Use) ${Y==="ICU"?"\u25CF":""}`,value:"ICU"},{label:`FluxCU (Autonomous Flux Computer Use) ${Y==="FluxCU"?"\u25CF":""}`,value:"FluxCU"},{label:"Back",value:"chat"}],theme:de.theme,onSelect:n=>{if(n.value==="chat"||n.value==="Back"){ne("chat");return}let o=n.value;le(o),I(c=>(O(c.length+1),[...c,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${Ci(o)}
|
|
329
329
|
\u2800`,isMeta:!0}])),ne("chat")},onClose:()=>ne("chat")});case"display":return e.createElement($t,{title:"SELECT ACTIVE DISPLAY FOR COMPUTER USE",items:[{label:`Primary Display (Display 1) ${xe===0?"\u25CF":""}`,value:0},{label:`Secondary Display (Display 2) ${xe===1?"\u25CF":""}`,value:1},{label:"Back",value:"chat"}],theme:de.theme,onSelect:n=>{if(n.value==="chat"||n.value==="Back"){ne("chat");return}let o=Number(n.value);oe(o),Kt({display:o}).catch(()=>{});let c=o===0?"Primary (Display 1)":"Secondary (Display 2)";I(f=>(O(f.length+1),[...f,{id:Date.now(),role:"system",text:`\u2726 Active Computer Use display set to: ${c}`,isMeta:!0}])),ne("chat")},onClose:()=>ne("chat")});case"updateManager":return e.createElement($t,{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"){ne("settings");return}n.value==="custom"?(so({label:"Enter Custom Update Command (Global install recommended):",key:"customUpdateCommand",value:de.customUpdateCommand,next:o=>(Ot(c=>({...c,updateManager:"custom",customUpdateCommand:o})),null)}),ne("input")):(Ot(o=>({...o,updateManager:n.value})),ne("settings"))},theme:de.theme});case"update":return e.createElement(Pa,{latest:dn,current:ho,settings:de,theme:de.theme,onClose:()=>ne("chat"),onSuccess:()=>{I(n=>(O(n.length+1),[...n,{id:"update-success-"+Date.now(),role:"system",text:`**[UPDATE COMPLETED]** Flux Flow successfully updated to v${dn}.
|
|
330
|
-
**Restart to see changes.**`,isMeta:!0}])),ne("chat")},onUpdateSettings:n=>{ne("updateManager")}});case"terminalApproval":return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:"white",bold:!0,underline:!0},"TERMINAL COMMAND OVERSIGHT"),e.createElement(m,{marginTop:1},e.createElement(i,null,"Agent requested to run: ",e.createElement(i,{color:"yellow",bold:!0},vn(eo?.args||"{}").command||"Unknown Command"))),e.createElement(m,{marginTop:1},(()=>{let o=(vn(eo?.args||"{}").command||"").trim();return e.createElement($t,{title:"Risk Assessment Required",items:[{label:"Run",value:"allow"},{label:"Accept for this session",value:"always"},{label:"Deny",value:"deny"}],onSelect:c=>{c.value==="always"&&o&&
|
|
330
|
+
**Restart to see changes.**`,isMeta:!0}])),ne("chat")},onUpdateSettings:n=>{ne("updateManager")}});case"terminalApproval":return e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:"white",bold:!0,underline:!0},"TERMINAL COMMAND OVERSIGHT"),e.createElement(m,{marginTop:1},e.createElement(i,null,"Agent requested to run: ",e.createElement(i,{color:"yellow",bold:!0},vn(eo?.args||"{}").command||"Unknown Command"))),e.createElement(m,{marginTop:1},(()=>{let o=(vn(eo?.args||"{}").command||"").trim();return e.createElement($t,{title:"Risk Assessment Required",items:[{label:"Run",value:"allow"},{label:"Accept for this session",value:"always"},{label:"Deny",value:"deny"}],onSelect:c=>{c.value==="always"&&o&&ji.current.add(o);let f=c.value==="deny"?"deny":"allow";eo.resolve(f),Kn(null),ne("chat")},theme:de.theme})})()));default:return e.createElement(m,{flexDirection:"column",marginTop:1,flexShrink:0,width:"100%"},ol&&tl&&e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:1,width:"100%",marginBottom:1},e.createElement(m,{justifyContent:"space-between",width:"100%"},e.createElement(i,{color:s.text,bold:!0,underline:!0},"INQUIRY RESPONSE"),e.createElement(i,{color:s.textMuted},"[ ESC to Close ]")),e.createElement(m,{marginTop:1,width:"100%"},e.createElement(is,{text:tl,columns:X.columns-6,theme:de.theme}))),As.filter(n=>n.status==="running").length>0&&e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:0,width:"100%",marginBottom:1},e.createElement(m,{justifyContent:"space-between",width:"100%"},e.createElement(i,{color:s.text,bold:!0},"ACTIVE SUBAGENTS")),e.createElement(m,{flexDirection:"column",marginTop:1,width:"100%"},As.filter(n=>n.status==="running").map(n=>e.createElement(hu,{key:n.id,sa:n,showTPMEstimate:de.showTPMEstimate})))),xr&&e.createElement(m,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:0,width:"100%",marginBottom:0},e.createElement(m,{justifyContent:"space-between",width:"100%"},e.createElement(m,{flexDirection:"row",gap:1},e.createElement(i,{color:s.warning||"yellow",bold:!0},"\u2726 ",xr.startsWith("/btw")?"Question Queued":"Steering Hint Queued"))),e.createElement(m,{marginTop:0,paddingLeft:2},e.createElement(i,{color:s.text,bold:!0},"\u2514\u2500 ",xr.startsWith("/btw")?xr.replace(/^\/btw\s*/,""):xr))),e.createElement(m,{paddingX:1,marginBottom:0,justifyContent:"space-between",width:"100%"},e.createElement(m,null,Ro?e.createElement(m,{gap:1},e.createElement(ru,null),e.createElement(kr,{text:Ro.trim().length>40&&!Ro.toLowerCase().includes("trying")?`${Ro.trim().slice(0,40)}...`:Ro.trim(),baseColor:s.textExclusive||s.text,glintColor:s.textMutedExclusive||s.textMuted,speed:60,italic:!0,glintWidth:2,typeSpeed:10}),e.createElement(i,{color:s.textMuted},Qi>0?`(${Qi.toFixed(0)}s)`:"")):e.createElement(i,{color:s.textMuted,italic:!0},y.length>0&&Ri?"Press ESC again to clear input":xc?"Press CTRL + O to expand":process.env.HALLOWEEN_EEGG==="true"?"Listening for shadows...":"Waiting for input...")),e.createElement(m,null,(()=>{let n=Ro?.toLowerCase()??"";return Vn&&Date.now()-Di>15e3&&As.length===0&&(n.includes("connecting")||n.includes("consulting")||n.includes("working")||n.includes("haunting")||n.includes("queue"))?e.createElement(m,null,e.createElement(kr,{text:"Waiting for API Response",baseColor:s.text,glintColor:s.textMuted,glintWidth:4,speed:100}),e.createElement(i,{color:s.textMuted,dimColor:!0}," \u2503 ")):Xs?e.createElement(m,null,e.createElement(kr,{text:Xs,baseColor:s.text,glintColor:s.textMuted,italic:!0,speed:85,typeSpeed:15}),e.createElement(i,{color:s.textMuted,dimColor:!0}," \u2503 ")):null})(),e.createElement(kr,{text:Ct.basename(je)||(je.length>1?je:"Use '/model model-id' to select model"),baseColor:s.text,glintColor:s.textMuted,glintWidth:3,speed:80}),e.createElement(i,{color:s.textMuted},je.length>0?We.toLocaleLowerCase().includes("xhigh")?"":` (${We})`:""),ts>0&&e.createElement(i,{color:s.textMuted}," [",ts," ",ts===1?"file":"files","]"))),e.createElement(m,{flexDirection:"column",width:"100%"},e.createElement(m,{width:"100%",height:1,overflow:"hidden"},e.createElement(i,{color:s.inputBorder},"\u2500".repeat(Math.max(1,X.columns)))),e.createElement(m,{paddingX:1,paddingY:0,width:"100%",flexDirection:"column"},e.createElement(m,{flexDirection:"column",width:"100%"},e.createElement(m,{flexDirection:"row",width:"100%",paddingY:0},e.createElement(m,{flexShrink:0,width:4},e.createElement(i,{color:s.inputPrompt,bold:!0},Vn||ur?"\u2726 ":" \u276F ")),e.createElement(m,{flexGrow:1},e.createElement(m,{flexGrow:1,position:"relative"},y===""&&e.createElement(m,{position:"absolute",paddingLeft:0},yo&&!ar?e.createElement(i,{color:"yellow"},Mc?" Terminal is waiting for user input. Press TAB to interact":" Press TAB to interact with terminal..."):yo&&ar?e.createElement(i,{color:"yellow",bold:!0}," [ TERMINAL FOCUSED ] Type to interact, press TAB to exit..."):Ri===1?e.createElement(i,{color:s.inputPrompt,bold:!0}," Press ESC again to ",y.length>0?"clear input":"revert codebase to checkpoint","..."):e.createElement(i,{color:s.inputPlaceholder},hc?" Press ESC again to cancel the request.":ur?" Compacting session history, please wait...":Vn?" Enter a prompt to steer the agent.":Nt.filter(n=>n.role==="user").length===0?` Send message, @file or /cmd (${mc.shortcut} for newline)`:" Ask Follow-ups")),e.createElement(da,{key:`input-${C}`,onPasteStateChange:fc,focus:!ar&&!ur,showCursor:dt&&!ur,cursorColor:s.inputText,lastFocusEventTime:ro.current,value:y,textStyle:{bold:!0,color:s.inputText},columns:X.columns,onChange:n=>{let o=n.replace(/\r\n/g,`
|
|
331
331
|
`).replace(/\r/g,`
|
|
332
332
|
`).replace(/\\\s*\n/g,`
|
|
333
|
-
`);b(o),Be(!1),G.current!==null&&o===G.current?G.current=null:B!==-1&&L(-1)},historyEnabled:St==="chat"&&!ur&&(lt.length===0||B!==-1),isBrowsingHistory:B!==-1,onHistoryPrev:()=>{let n=P.current;if(n.length!==0){if(B===-1){_.current=y;let o=n.length-1;G.current=n[o],L(o),b(n[o]),A(c=>c+1)}else if(B>0){let o=B-1;G.current=n[o],L(o),b(n[o]),A(c=>c+1)}}},onHistoryNext:()=>{let n=P.current;if(B!==-1)if(B<n.length-1){let o=B+1;G.current=n[o],L(o),b(n[o]),A(c=>c+1)}else{let o=_.current||"";G.current=o,L(-1),b(o),A(c=>c+1)}},onSubmit:al,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(m,{width:"100%",height:1,overflow:"hidden"},e.createElement(i,{color:s.inputBorder},"\u2500".repeat(Math.max(1,X.columns))))))}};return e.createElement(m,{flexDirection:"column",width:"100%"},Pe?null:Mt?e.createElement(du,{width:r?.columns||80,height:r?.rows||24,aiProvider:F,theme:de.theme,reason:Mt}):fe?e.createElement(cu,{width:r?.columns||80,height:r?.rows||24,selectedIndex:Le,aiProvider:F,theme:de.theme}):e.createElement(e.Fragment,null,e.createElement(m,{paddingX:1,flexDirection:"column",width:"100%"},e.createElement(nu,{key:`static-${Tn}-${bt}-${X.columns}-${de.theme}`,items:sl.completed},n=>e.createElement(as,{key:n.key,block:n,columns:(r?.columns||80)-2,showFullThinking:un,aiProvider:F,version:ho,theme:de.theme}))),e.createElement(m,{flexDirection:"column",paddingX:1,paddingBottom:0,width:"100%"},(St==="chat"||["ask","approval","terminalApproval"].includes(St))&&e.createElement(m,{flexDirection:"column",width:"100%"},sl.active.map(n=>e.createElement(as,{key:n.key,block:n,columns:Math.max(20,(r?.columns||80)-2),showFullThinking:un,aiProvider:F,version:ho,theme:de.theme})),yo&&e.createElement(m,{marginTop:1},e.createElement(ss,{command:yo,output:Wn,isFocused:ar,isPty:jn,terminalHeight:X.rows,columns:X.columns}))),Pe?e.createElement(m,{borderStyle:"double",borderColor:"grey",padding:1,flexShrink:0},e.createElement(i,{color:"white"},"Starting Flux Flow...")):!Ge&&!(F==="c_openai"&&de.customOpenAIBaseUrl)?e.createElement(m,{borderStyle:"round",borderColor:"white",padding:0,flexDirection:"column",flexShrink:0,width:"100%"},e.createElement(m,{paddingX:1,marginBottom:1},e.createElement(i,{color:"gray",bold:!0},F==="c_openai"?"CUSTOM BASE URL REQUIRED":"API KEY REQUIRED")),e.createElement(m,{paddingX:1,flexDirection:"column"},er===0?e.createElement(e.Fragment,null,e.createElement(i,{color:"white"},"Select your Preferred Provider:"),e.createElement(m,{marginTop:1},e.createElement($t,{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:"Infron",value:"Infron"},{label:"APInex",value:"APInex"},{label:"xKiro",value:"xKiro"},{label:"Ollama",value:"Ollama"},...process.env.ENABLE_9ROUTER==="true"||process.env.ENABLE_9ROUTER===!0?[{label:"9router [Local Proxy]",value:"9router"}]:[],{label:"AIHubMix [Experimental]",value:"AIHubMix"},{label:"Mistral [Experimental]",value:"Mistral"},{label:"OpenRouter [Experimental]",value:"OpenRouter"},{label:"Custom [OpenAI Chat Completion]",value:"c_openai"}],onSelect:n=>{zo(n.value),Ar(1)}}))):e.createElement(e.Fragment,null,e.createElement(i,{color:"white"},F==="Ollama"?"Enter Ollama API Key (or type LOCAL to use local host):":F==="c_openai"?"Enter Custom OpenAI Base URL (.../v1):":`Enter your ${F} API Key:`),e.createElement(m,{marginTop:1},e.createElement(i,{color:"gray",bold:!0}," ",">"," "),e.createElement(Zn,{value:mn,onChange:xn,onSubmit:il,mask:F==="c_openai"?void 0:"*"})))),e.createElement(m,{paddingX:1,marginTop:1},e.createElement(i,{color:"gray",italic:!0},er===0?"(Use arrows to select and Enter to confirm, ESC to go back)":"(Press Enter to confirm and initialize, ESC to go back)"))):Sc(),d&&e.createElement(m,{borderStyle:"round",borderColor:s.borderMuted,paddingX:1,marginY:0,width:"100%"},e.createElement(i,null,e.createElement(i,{color:"red",bold:!0},"\u{1F534} EXIT: "),e.createElement(i,{color:s.text},"Press "),e.createElement(i,{color:s.text,bold:!0},"CTRL+C"),e.createElement(i,{color:s.text}," again to exit (",w,"s) \u2022 Press "),e.createElement(i,{color:s.textMuted,bold:!0},"ESC"),e.createElement(i,{color:s.text}," to cancel"))),lt.length>0&&(()=>{let o=we.current,c=0;for(;c<lt.length;){let H=lt[c],K=H?.cmd||H||"";if(typeof K=="string"&&K.trimStart().startsWith("---"))c++;else break}De<=c?o=0:De<o?o=De:De>=o+5&&(o=De-5+1),o=Math.max(0,Math.min(o,Math.max(0,lt.length-5))),we.current=o;let f=lt.slice(o,o+5),x=lt.length-(o+f.length),v=lt[0]?.cmd?.startsWith("@")||lt[0]?.cmd?.startsWith("\\@"),u=y.startsWith("/model"),a=y.startsWith("/kill"),h=y.startsWith("/thinking"),M=lt.length,N=Math.min(M,De+1);return e.createElement(m,{flexDirection:"column",width:"100%",marginBottom:1,marginTop:0},e.createElement(m,{paddingX:1,marginBottom:0,justifyContent:"space-between",width:"100%"},e.createElement(m,{flexDirection:"row"},e.createElement(i,{color:s.primary||s.text,bold:!0},v?"WORKSPACE FILES":u?"SAVED MODELS":a?"ACTIVE PROCESSES":h?"THINKING LEVELS":"COMMANDS"),e.createElement(i,{color:s.textMuted}," (",M,")")),e.createElement(m,{flexDirection:"row"},v?e.createElement(i,{color:s.textMuted,italic:!0},"Use #Lstart-Lend for line range \u2022 Tab to select"):e.createElement(i,{color:s.textMuted,italic:!0},"\u2191/\u2193 navigate \u2022 Tab / Enter select \u2022 Esc dismiss"))),e.createElement(m,{width:"100%",height:1,overflow:"hidden"},e.createElement(i,{color:s.borderDim||s.inputBorder||s.textDim},"\u2500".repeat(Math.max(1,X.columns)))),f.slice(0,Vr).map((H,K)=>{let V=o+K===De,ee=typeof H.cmd=="string"&&H.cmd.trimStart().startsWith("---"),te=H.cmd===ao("Google","Free")&&ze!=="Free",U=H.display||(H.cmd&&(H.cmd.startsWith("@[")||H.cmd.startsWith("\\@["))&&H.cmd.endsWith("]")?(()=>{let Ue=(H.cmd.startsWith("\\@[")?H.cmd.slice(3,-1):H.cmd.slice(2,-1)).split(/[\/\\]/);return Ue[Ue.length-1]})():!u&&!a&&H.cmd&&H.cmd.includes("/")?H.cmd.split("/").pop():H.cmd);if(u){let Ue=H.multimodal===!0||Jr(H.cmd||H)?"Vision":"Text Only";return e.createElement(m,{key:H.cmd||K,flexDirection:"row",backgroundColor:V?s.highlightBg:void 0,paddingX:1,height:1,alignItems:"center",justifyContent:"space-between"},e.createElement(m,{flexDirection:"row",alignItems:"center",flexGrow:1,overflow:"hidden"},e.createElement(m,{width:3,flexShrink:0},e.createElement(i,{color:V?s.primary||s.text:s.textMuted,bold:V},V?"\u276F ":" ")),e.createElement(i,{color:ee?s.textDim:te?s.textMuted:V&&s.inputText||s.text,bold:V},U)),e.createElement(m,{flexShrink:0,marginLeft:2},e.createElement(i,{color:V?s.text:s.textMuted,italic:!V},Ue)))}return a&&H.rightDesc?e.createElement(m,{key:H.cmd||K,flexDirection:"row",backgroundColor:V?s.highlightBg:void 0,paddingX:1,height:1,alignItems:"center",justifyContent:"space-between"},e.createElement(m,{flexDirection:"row",alignItems:"center",flexGrow:1,overflow:"hidden"},e.createElement(m,{width:3,flexShrink:0},e.createElement(i,{color:V?s.primary||s.text:s.textMuted,bold:V},V?"\u276F ":" ")),e.createElement(i,{color:V&&s.inputText||s.text,bold:V},U)),e.createElement(m,{flexShrink:0,marginLeft:2},e.createElement(i,{color:V?s.text:s.textMuted,italic:!V},H.rightDesc))):e.createElement(m,{key:H.cmd||K,flexDirection:"row",backgroundColor:V?s.highlightBg:void 0,paddingX:1,height:1,alignItems:"center"},e.createElement(m,{width:3,flexShrink:0},e.createElement(i,{color:V?s.primary||s.text:s.textMuted,bold:V},V?"\u276F ":" ")),e.createElement(m,{width:26,flexShrink:0},e.createElement(i,{color:ee?s.textDim:te?s.textMuted:V&&s.inputText||s.text,bold:V},U)),e.createElement(m,{flexGrow:1,overflow:"hidden"},e.createElement(i,{color:V?s.text:s.textMuted,italic:!V},H.desc)))}),lt.length>5&&e.createElement(m,{paddingX:1,height:1,justifyContent:"space-between",width:"100%"},e.createElement(i,{color:s.textMuted,dimColor:!0,italic:!0},x>0?`... ${x} more available`:"(End of list)"),e.createElement(i,{color:s.textMuted,dimColor:!0},`${N}/${M}`)))})(),e.createElement(m,{flexShrink:0,width:"100%"},e.createElement(Ta,{mode:Y,thinkingLevel:We,tokens:Do.tokens,tokensTotal:Ra,cachedTokens:ec,promptTokens:oc,chatCacheTokenLatest:tc,cacheCalculateMode:de.cacheCalculateMode||"Session",chatId:bt,isMemoryEnabled:de.memory,apiTier:ze,aiProvider:F,activeModel:je,isProcessing:Vn,lastChunkTime:Ei,theme:de.theme,wps:Ds.current.wps,showTPMEstimate:de.showTPMEstimate})),St==="exit"&&(()=>{let n=Date.now()-Ci,o=Dt.toolSuccess+Dt.toolFailure,c=o>0?(Dt.toolSuccess/o*100).toFixed(1):"0.0",f=Ur+_r,x=f>0?(Ur/f*100).toFixed(1):"0.0",v=f>0?(_r/f*100).toFixed(1):"0.0";return e.createElement(m,{flexDirection:"column",borderStyle:"round",paddingX:3,paddingY:1,borderColor:s.borderMuted,width:Math.min(100,(r?.columns||100)-2),marginTop:0,marginBottom:0},e.createElement(m,{marginBottom:1},e.createElement(i,{bold:!0},iu(s.logoGradient||["blue","purple"])("Agent powering down. Goodbye!"))),e.createElement(m,{flexDirection:"column"},e.createElement(i,{color:s.text,bold:!0,underline:!0},"Interaction Summary"),e.createElement(m,{marginTop:1},e.createElement(m,{width:20},e.createElement(i,{color:s.secondary},"Session ID:")),e.createElement(i,{color:s.text},bt)),e.createElement(m,null,e.createElement(m,{width:20},e.createElement(i,{color:s.secondary},"Tool Calls:")),e.createElement(i,{color:s.text},Dt.toolSuccess+Dt.toolFailure+Dt.toolDenied," ( ",e.createElement(i,{color:"green"},"\u2714 ",Dt.toolSuccess)," ",e.createElement(i,{color:"yellow"},"\u{1F6C7} ",Dt.toolDenied)," ",e.createElement(i,{color:"red"},"\u2718 ",Dt.toolFailure)," )")),e.createElement(m,null,e.createElement(m,{width:20},e.createElement(i,{color:s.secondary},"Success Rate:")),e.createElement(i,{color:s.text},c,"%")),e.createElement(m,null,e.createElement(m,{width:20},e.createElement(i,{color:s.secondary},"Code Changes:")),e.createElement(i,{color:s.text},e.createElement(i,{color:"green"},"+",Dt.linesAdded)," ",e.createElement(i,{color:"red"},"-",Dt.linesRemoved))),io>0&&e.createElement(e.Fragment,null,e.createElement(m,null,e.createElement(m,{width:20},e.createElement(i,{color:s.secondary},"Tokens Consumed:")),e.createElement(i,{color:s.text},At(io))),(Dt?.cost||0)>0&&e.createElement(m,{marginLeft:2},e.createElement(m,{width:18},e.createElement(i,{color:s.textMuted},"\xBB Cost Estimate:")),e.createElement(i,{color:s.success||"green"},(()=>{let u=Number(Dt.cost)||0;return u<=0?"":u<.001?"<$0.001":`$${u.toFixed(u<.01?4:3)}`})())),e.createElement(m,{marginLeft:2},e.createElement(m,{width:18},e.createElement(i,{color:s.textMuted},"\xBB Input Tokens:")),e.createElement(i,{color:s.text},At(io-Un))),wo>0&&e.createElement(m,{marginLeft:4},e.createElement(m,{width:16},e.createElement(i,{color:s.textMuted},"\xBB Cached:")),e.createElement(i,{color:s.text},At(wo))),Un>0&&e.createElement(m,{marginLeft:2},e.createElement(m,{width:18},e.createElement(i,{color:s.textMuted},"\xBB Output Tokens:")),e.createElement(i,{color:s.text},At(Un)))),Hr>0&&e.createElement(e.Fragment,null,e.createElement(m,null,e.createElement(m,{width:20},e.createElement(i,{color:s.secondary},"Images Made:")),e.createElement(i,{color:s.text},Hr)),e.createElement(m,null,e.createElement(m,{width:20},e.createElement(i,{color:s.secondary},"Image Credits:")),e.createElement(i,{color:s.text},Number(((Fi||0)*1e3).toFixed(0))," credits")))),e.createElement(m,{flexDirection:"column",marginTop:1},e.createElement(i,{color:s.text,bold:!0,underline:!0},"Performance"),e.createElement(m,{marginTop:1},e.createElement(m,{width:20},e.createElement(i,{color:s.secondary},"Wall Time:")),e.createElement(i,{color:s.text},bn(n))),e.createElement(m,null,e.createElement(m,{width:20},e.createElement(i,{color:s.secondary},"Agent Active:")),e.createElement(i,{color:s.text},bn(f))),e.createElement(m,{marginLeft:2},e.createElement(m,{width:18},e.createElement(i,{color:s.textMuted},"\xBB API Time:")),e.createElement(i,{color:s.text},bn(Ur)," (",x,"%)")),e.createElement(m,{marginLeft:2},e.createElement(m,{width:18},e.createElement(i,{color:s.textMuted},"\xBB Tool Time:")),e.createElement(i,{color:s.text},bn(_r)," (",v,"%)"))))})())))}export{Ti as check9RouterReachable,pu as default};
|
|
333
|
+
`);b(o),Be(!1),G.current!==null&&o===G.current?G.current=null:B!==-1&&L(-1)},historyEnabled:St==="chat"&&!ur&&(lt.length===0||B!==-1),isBrowsingHistory:B!==-1,onHistoryPrev:()=>{let n=P.current;if(n.length!==0){if(B===-1){_.current=y;let o=n.length-1;G.current=n[o],L(o),b(n[o]),A(c=>c+1)}else if(B>0){let o=B-1;G.current=n[o],L(o),b(n[o]),A(c=>c+1)}}},onHistoryNext:()=>{let n=P.current;if(B!==-1)if(B<n.length-1){let o=B+1;G.current=n[o],L(o),b(n[o]),A(c=>c+1)}else{let o=_.current||"";G.current=o,L(-1),b(o),A(c=>c+1)}},onSubmit:cl,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(m,{width:"100%",height:1,overflow:"hidden"},e.createElement(i,{color:s.inputBorder},"\u2500".repeat(Math.max(1,X.columns))))))}};return e.createElement(m,{flexDirection:"column",width:"100%"},Pe?null:Mt?e.createElement(du,{width:r?.columns||80,height:r?.rows||24,aiProvider:F,theme:de.theme,reason:Mt}):fe?e.createElement(cu,{width:r?.columns||80,height:r?.rows||24,selectedIndex:Le,aiProvider:F,theme:de.theme}):e.createElement(e.Fragment,null,e.createElement(m,{paddingX:1,flexDirection:"column",width:"100%"},e.createElement(nu,{key:`static-${Tn}-${bt}-${X.columns}-${de.theme}`,items:il.completed},n=>e.createElement(as,{key:n.key,block:n,columns:(r?.columns||80)-2,showFullThinking:un,aiProvider:F,version:ho,theme:de.theme}))),e.createElement(m,{flexDirection:"column",paddingX:1,paddingBottom:0,width:"100%"},(St==="chat"||["ask","approval","terminalApproval"].includes(St))&&e.createElement(m,{flexDirection:"column",width:"100%"},il.active.map(n=>e.createElement(as,{key:n.key,block:n,columns:Math.max(20,(r?.columns||80)-2),showFullThinking:un,aiProvider:F,version:ho,theme:de.theme})),yo&&e.createElement(m,{marginTop:1},e.createElement(ss,{command:yo,output:Wn,isFocused:ar,isPty:jn,terminalHeight:X.rows,columns:X.columns}))),Pe?e.createElement(m,{borderStyle:"double",borderColor:"grey",padding:1,flexShrink:0},e.createElement(i,{color:"white"},"Starting Flux Flow...")):!Ke&&!(F==="c_openai"&&de.customOpenAIBaseUrl)?e.createElement(m,{borderStyle:"round",borderColor:"white",padding:0,flexDirection:"column",flexShrink:0,width:"100%"},e.createElement(m,{paddingX:1,marginBottom:1},e.createElement(i,{color:"gray",bold:!0},F==="c_openai"?"CUSTOM BASE URL REQUIRED":"API KEY REQUIRED")),e.createElement(m,{paddingX:1,flexDirection:"column"},er===0?e.createElement(e.Fragment,null,e.createElement(i,{color:"white"},"Select your Preferred Provider:"),e.createElement(m,{marginTop:1},e.createElement($t,{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:"Infron",value:"Infron"},{label:"APInex",value:"APInex"},{label:"xKiro",value:"xKiro"},{label:"Ollama",value:"Ollama"},...process.env.ENABLE_9ROUTER==="true"||process.env.ENABLE_9ROUTER===!0?[{label:"9router [Local Proxy]",value:"9router"}]:[],{label:"AIHubMix [Experimental]",value:"AIHubMix"},{label:"Mistral [Experimental]",value:"Mistral"},{label:"OpenRouter [Experimental]",value:"OpenRouter"},{label:"Custom [OpenAI Chat Completion]",value:"c_openai"}],onSelect:n=>{zo(n.value),Ar(1)}}))):e.createElement(e.Fragment,null,e.createElement(i,{color:"white"},F==="Ollama"?"Enter Ollama API Key (or type LOCAL to use local host):":F==="c_openai"?"Enter Custom OpenAI Base URL (.../v1):":`Enter your ${F} API Key:`),e.createElement(m,{marginTop:1},e.createElement(i,{color:"gray",bold:!0}," ",">"," "),e.createElement(Zn,{value:mn,onChange:xn,onSubmit:ll,mask:F==="c_openai"?void 0:"*"})))),e.createElement(m,{paddingX:1,marginTop:1},e.createElement(i,{color:"gray",italic:!0},er===0?"(Use arrows to select and Enter to confirm, ESC to go back)":"(Press Enter to confirm and initialize, ESC to go back)"))):Sc(),d&&e.createElement(m,{borderStyle:"round",borderColor:s.borderMuted,paddingX:1,marginY:0,width:"100%"},e.createElement(i,null,e.createElement(i,{color:"red",bold:!0},"\u{1F534} EXIT: "),e.createElement(i,{color:s.text},"Press "),e.createElement(i,{color:s.text,bold:!0},"CTRL+C"),e.createElement(i,{color:s.text}," again to exit (",w,"s) \u2022 Press "),e.createElement(i,{color:s.textMuted,bold:!0},"ESC"),e.createElement(i,{color:s.text}," to cancel"))),lt.length>0&&(()=>{let o=we.current,c=0;for(;c<lt.length;){let H=lt[c],K=H?.cmd||H||"";if(typeof K=="string"&&K.trimStart().startsWith("---"))c++;else break}De<=c?o=0:De<o?o=De:De>=o+5&&(o=De-5+1),o=Math.max(0,Math.min(o,Math.max(0,lt.length-5))),we.current=o;let f=lt.slice(o,o+5),x=lt.length-(o+f.length),v=lt[0]?.cmd?.startsWith("@")||lt[0]?.cmd?.startsWith("\\@"),u=y.startsWith("/model"),a=y.startsWith("/kill"),h=y.startsWith("/thinking"),M=lt.length,N=Math.min(M,De+1);return e.createElement(m,{flexDirection:"column",width:"100%",marginBottom:1,marginTop:0},e.createElement(m,{paddingX:1,marginBottom:0,justifyContent:"space-between",width:"100%"},e.createElement(m,{flexDirection:"row"},e.createElement(i,{color:s.primary||s.text,bold:!0},v?"WORKSPACE FILES":u?"SAVED MODELS":a?"ACTIVE PROCESSES":h?"THINKING LEVELS":"COMMANDS"),e.createElement(i,{color:s.textMuted}," (",M,")")),e.createElement(m,{flexDirection:"row"},v?e.createElement(i,{color:s.textMuted,italic:!0},"Use #Lstart-Lend for line range \u2022 Tab to select"):e.createElement(i,{color:s.textMuted,italic:!0},"\u2191/\u2193 navigate \u2022 Tab / Enter select \u2022 Esc dismiss"))),e.createElement(m,{width:"100%",height:1,overflow:"hidden"},e.createElement(i,{color:s.borderDim||s.inputBorder||s.textDim},"\u2500".repeat(Math.max(1,X.columns)))),f.slice(0,Vr).map((H,K)=>{let V=o+K===De,ee=typeof H.cmd=="string"&&H.cmd.trimStart().startsWith("---"),te=H.cmd===ao("Google","Free")&&ze!=="Free",U=H.display||(H.cmd&&(H.cmd.startsWith("@[")||H.cmd.startsWith("\\@["))&&H.cmd.endsWith("]")?(()=>{let Ue=(H.cmd.startsWith("\\@[")?H.cmd.slice(3,-1):H.cmd.slice(2,-1)).split(/[\/\\]/);return Ue[Ue.length-1]})():!u&&!a&&H.cmd&&H.cmd.includes("/")?H.cmd.split("/").pop():H.cmd);if(u){let Ue=H.multimodal===!0||Jr(H.cmd||H)?"Vision":"Text Only";return e.createElement(m,{key:H.cmd||K,flexDirection:"row",backgroundColor:V?s.highlightBg:void 0,paddingX:1,height:1,alignItems:"center",justifyContent:"space-between"},e.createElement(m,{flexDirection:"row",alignItems:"center",flexGrow:1,overflow:"hidden"},e.createElement(m,{width:3,flexShrink:0},e.createElement(i,{color:V?s.primary||s.text:s.textMuted,bold:V},V?"\u276F ":" ")),e.createElement(i,{color:ee?s.textDim:te?s.textMuted:V&&s.inputText||s.text,bold:V},U)),e.createElement(m,{flexShrink:0,marginLeft:2},e.createElement(i,{color:V?s.text:s.textMuted,italic:!V},Ue)))}return a&&H.rightDesc?e.createElement(m,{key:H.cmd||K,flexDirection:"row",backgroundColor:V?s.highlightBg:void 0,paddingX:1,height:1,alignItems:"center",justifyContent:"space-between"},e.createElement(m,{flexDirection:"row",alignItems:"center",flexGrow:1,overflow:"hidden"},e.createElement(m,{width:3,flexShrink:0},e.createElement(i,{color:V?s.primary||s.text:s.textMuted,bold:V},V?"\u276F ":" ")),e.createElement(i,{color:V&&s.inputText||s.text,bold:V},U)),e.createElement(m,{flexShrink:0,marginLeft:2},e.createElement(i,{color:V?s.text:s.textMuted,italic:!V},H.rightDesc))):e.createElement(m,{key:H.cmd||K,flexDirection:"row",backgroundColor:V?s.highlightBg:void 0,paddingX:1,height:1,alignItems:"center"},e.createElement(m,{width:3,flexShrink:0},e.createElement(i,{color:V?s.primary||s.text:s.textMuted,bold:V},V?"\u276F ":" ")),e.createElement(m,{width:26,flexShrink:0},e.createElement(i,{color:ee?s.textDim:te?s.textMuted:V&&s.inputText||s.text,bold:V},U)),e.createElement(m,{flexGrow:1,overflow:"hidden"},e.createElement(i,{color:V?s.text:s.textMuted,italic:!V},H.desc)))}),lt.length>5&&e.createElement(m,{paddingX:1,height:1,justifyContent:"space-between",width:"100%"},e.createElement(i,{color:s.textMuted,dimColor:!0,italic:!0},x>0?`... ${x} more available`:"(End of list)"),e.createElement(i,{color:s.textMuted,dimColor:!0},`${N}/${M}`)))})(),e.createElement(m,{flexShrink:0,width:"100%"},e.createElement(Ta,{mode:Y,thinkingLevel:We,tokens:Do.tokens,tokensTotal:Ra,cachedTokens:ec,promptTokens:oc,chatCacheTokenLatest:tc,cacheCalculateMode:de.cacheCalculateMode||"Session",chatId:bt,isMemoryEnabled:de.memory,apiTier:ze,aiProvider:F,activeModel:je,isProcessing:Vn,lastChunkTime:Di,theme:de.theme,wps:Ds.current.wps,showTPMEstimate:de.showTPMEstimate})),St==="exit"&&(()=>{let n=Date.now()-Mi,o=Dt.toolSuccess+Dt.toolFailure,c=o>0?(Dt.toolSuccess/o*100).toFixed(1):"0.0",f=Ur+_r,x=f>0?(Ur/f*100).toFixed(1):"0.0",v=f>0?(_r/f*100).toFixed(1):"0.0";return e.createElement(m,{flexDirection:"column",borderStyle:"round",paddingX:3,paddingY:1,borderColor:s.borderMuted,width:Math.min(100,(r?.columns||100)-2),marginTop:0,marginBottom:0},e.createElement(m,{marginBottom:1},e.createElement(i,{bold:!0},iu(s.logoGradient||["blue","purple"])("Agent powering down. Goodbye!"))),e.createElement(m,{flexDirection:"column"},e.createElement(i,{color:s.text,bold:!0,underline:!0},"Interaction Summary"),e.createElement(m,{marginTop:1},e.createElement(m,{width:20},e.createElement(i,{color:s.secondary},"Session ID:")),e.createElement(i,{color:s.text},bt)),e.createElement(m,null,e.createElement(m,{width:20},e.createElement(i,{color:s.secondary},"Tool Calls:")),e.createElement(i,{color:s.text},Dt.toolSuccess+Dt.toolFailure+Dt.toolDenied," ( ",e.createElement(i,{color:"green"},"\u2714 ",Dt.toolSuccess)," ",e.createElement(i,{color:"yellow"},"\u{1F6C7} ",Dt.toolDenied)," ",e.createElement(i,{color:"red"},"\u2718 ",Dt.toolFailure)," )")),e.createElement(m,null,e.createElement(m,{width:20},e.createElement(i,{color:s.secondary},"Success Rate:")),e.createElement(i,{color:s.text},c,"%")),e.createElement(m,null,e.createElement(m,{width:20},e.createElement(i,{color:s.secondary},"Code Changes:")),e.createElement(i,{color:s.text},e.createElement(i,{color:"green"},"+",Dt.linesAdded)," ",e.createElement(i,{color:"red"},"-",Dt.linesRemoved))),io>0&&e.createElement(e.Fragment,null,e.createElement(m,null,e.createElement(m,{width:20},e.createElement(i,{color:s.secondary},"Tokens Consumed:")),e.createElement(i,{color:s.text},At(io))),(Dt?.cost||0)>0&&e.createElement(m,{marginLeft:2},e.createElement(m,{width:18},e.createElement(i,{color:s.textMuted},"\xBB Cost Estimate:")),e.createElement(i,{color:s.success||"green"},(()=>{let u=Number(Dt.cost)||0;return u<=0?"":u<.001?"<$0.001":`$${u.toFixed(u<.01?4:3)}`})())),e.createElement(m,{marginLeft:2},e.createElement(m,{width:18},e.createElement(i,{color:s.textMuted},"\xBB Input Tokens:")),e.createElement(i,{color:s.text},At(io-Un))),wo>0&&e.createElement(m,{marginLeft:4},e.createElement(m,{width:16},e.createElement(i,{color:s.textMuted},"\xBB Cached:")),e.createElement(i,{color:s.text},At(wo))),Un>0&&e.createElement(m,{marginLeft:2},e.createElement(m,{width:18},e.createElement(i,{color:s.textMuted},"\xBB Output Tokens:")),e.createElement(i,{color:s.text},At(Un)))),Hr>0&&e.createElement(e.Fragment,null,e.createElement(m,null,e.createElement(m,{width:20},e.createElement(i,{color:s.secondary},"Images Made:")),e.createElement(i,{color:s.text},Hr)),e.createElement(m,null,e.createElement(m,{width:20},e.createElement(i,{color:s.secondary},"Image Credits:")),e.createElement(i,{color:s.text},Number((($i||0)*1e3).toFixed(0))," credits")))),e.createElement(m,{flexDirection:"column",marginTop:1},e.createElement(i,{color:s.text,bold:!0,underline:!0},"Performance"),e.createElement(m,{marginTop:1},e.createElement(m,{width:20},e.createElement(i,{color:s.secondary},"Wall Time:")),e.createElement(i,{color:s.text},bn(n))),e.createElement(m,null,e.createElement(m,{width:20},e.createElement(i,{color:s.secondary},"Agent Active:")),e.createElement(i,{color:s.text},bn(f))),e.createElement(m,{marginLeft:2},e.createElement(m,{width:18},e.createElement(i,{color:s.textMuted},"\xBB API Time:")),e.createElement(i,{color:s.text},bn(Ur)," (",x,"%)")),e.createElement(m,{marginLeft:2},e.createElement(m,{width:18},e.createElement(i,{color:s.textMuted},"\xBB Tool Time:")),e.createElement(i,{color:s.text},bn(_r)," (",v,"%)"))))})())))}export{yi as check9RouterReachable,pu as default};
|