fluxflow-cli 4.8.0 → 4.8.1

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/README.md CHANGED
@@ -160,6 +160,7 @@ Set these in your shell/session to override defaults:
160
160
  - `I_HAVE_TOO_MUCH_MONEY` - true|false, default: false, F's up the cache-hit ratio
161
161
  - `GOOGLE_GEMMA_NONSENSE` - true|false, default: false, for the 16k TPM limit in gemma models on gemini API. False defaults to 256k
162
162
  - `ENABLE_9ROUTER` - true|false, default: false
163
+ - `9ROUTER_BASE_URL` - 9Router base URL
163
164
 
164
165
  ---
165
166
 
@@ -1 +1 @@
1
- import{$ as r,L as b,M as c,N as d,O as e,P as f,Q as g,R as h,S as i,T as j,U as k,V as l,W as m,X as n,Y as o,Z as p,_ as q}from"./chunk-7CTFUTNI.js";import"./chunk-LXTPAZBK.js";import"./chunk-S27ZX6SS.js";import{c as a}from"./chunk-4C4RG42K.js";import"./chunk-SIINYZWE.js";import"./chunk-4TZKD2XR.js";import"./chunk-56EJGQU3.js";import"./chunk-GPHO47JC.js";export{c as RE_LEADING_THINK,o as compressHistory,b as convertChannelThinkTags,p as deleteChatSummary,e as findGenuineThinkClose,q as getAIStream,i as getCleanGroupedLength,l as getGoogleClient,f as getLeadingThinkBlock,n as initAI,d as isInsideBacktick,a as isModelMultimodal,k as isTerminationSignaled,m as runJanitorTask,r as runSubagent,j as signalTermination,g as stripLeadingThinking,h as stripNakedXmlTags};
1
+ import{$ as r,L as b,M as c,N as d,O as e,P as f,Q as g,R as h,S as i,T as j,U as k,V as l,W as m,X as n,Y as o,Z as p,_ as q}from"./chunk-VUZMENOD.js";import"./chunk-LXTPAZBK.js";import"./chunk-S27ZX6SS.js";import{c as a}from"./chunk-4C4RG42K.js";import"./chunk-SIINYZWE.js";import"./chunk-4TZKD2XR.js";import"./chunk-56EJGQU3.js";import"./chunk-GPHO47JC.js";export{c as RE_LEADING_THINK,o as compressHistory,b as convertChannelThinkTags,p as deleteChatSummary,e as findGenuineThinkClose,q as getAIStream,i as getCleanGroupedLength,l as getGoogleClient,f as getLeadingThinkBlock,n as initAI,d as isInsideBacktick,a as isModelMultimodal,k as isTerminationSignaled,m as runJanitorTask,r as runSubagent,j as signalTermination,g as stripLeadingThinking,h as stripNakedXmlTags};
@@ -1,4 +1,4 @@
1
- import{A as Ii,B as Ai,C as Li,D as cr,E as Oi,F as Pi,G as Ni,H as Fi,I as is,J as jo,K as ur,T as $i,W as Xi,X as On,Y as _i,Z as Hi,_ as Gi,a as yt,b as ht,c as ut,d as Mi,e as os,f as ns,g as In,h as Bi,i as ho,j as Ei,k as je,l as Qe,m as lr,n as An,o as rs,p as vi,q as an,r as Wt,s as Di,t as ar,u as ki,v as Ln,w as Ao,x as dn,y as dr,z as ss}from"./chunk-7CTFUTNI.js";import{b as ln,c as Zr,k as Ti}from"./chunk-LXTPAZBK.js";import{b as ts}from"./chunk-IBEWFYB6.js";import{a as bi,b as yi,c as sr,d as ir,f as bt,g as Vo,h as es,l as Si}from"./chunk-S27ZX6SS.js";import{a as hi,b as xi,c as pi,e as Io,f as ro,g as wi,h as Rr,i as kt}from"./chunk-4C4RG42K.js";import{c as mi,d as gi,e as fi}from"./chunk-SIINYZWE.js";import{e as Ci}from"./chunk-7PJOF5I2.js";import{a as ko,b as kn,c as no,d as rr,e as zr,j as Jr}from"./chunk-4TZKD2XR.js";import{a as Ui}from"./chunk-56EJGQU3.js";import"./chunk-GPHO47JC.js";import Ds from"os";import e,{useState as Q,useEffect as ze,useRef as Ve,useMemo as fn}from"react";import{Box as u,Text as s,useInput as Bd,useStdout as Ed,Static as vd}from"ink";import Dd from"ink-spinner";import st from"fs-extra";import Et from"path";import{exec as mo}from"child_process";import{fileURLToPath as kd}from"url";import Ut,{useState as mr,useEffect as ls,useMemo as Pn,useCallback as zl,useRef as xo}from"react";import{Box as Jl,Text as eo,useInput as Zl}from"ink";function Rl(t,f){return t.replace(/\t/g," ".repeat(f))}function gr(t){return t==null?"":t.replace(/\r\n/g,`
1
+ import{A as Ii,B as Ai,C as Li,D as cr,E as Oi,F as Pi,G as Ni,H as Fi,I as is,J as jo,K as ur,T as $i,W as Xi,X as On,Y as _i,Z as Hi,_ as Gi,a as yt,b as ht,c as ut,d as Mi,e as os,f as ns,g as In,h as Bi,i as ho,j as Ei,k as je,l as Qe,m as lr,n as An,o as rs,p as vi,q as an,r as Wt,s as Di,t as ar,u as ki,v as Ln,w as Ao,x as dn,y as dr,z as ss}from"./chunk-VUZMENOD.js";import{b as ln,c as Zr,k as Ti}from"./chunk-LXTPAZBK.js";import{b as ts}from"./chunk-IBEWFYB6.js";import{a as bi,b as yi,c as sr,d as ir,f as bt,g as Vo,h as es,l as Si}from"./chunk-S27ZX6SS.js";import{a as hi,b as xi,c as pi,e as Io,f as ro,g as wi,h as Rr,i as kt}from"./chunk-4C4RG42K.js";import{c as mi,d as gi,e as fi}from"./chunk-SIINYZWE.js";import{e as Ci}from"./chunk-7PJOF5I2.js";import{a as ko,b as kn,c as no,d as rr,e as zr,j as Jr}from"./chunk-4TZKD2XR.js";import{a as Ui}from"./chunk-56EJGQU3.js";import"./chunk-GPHO47JC.js";import Ds from"os";import e,{useState as Q,useEffect as ze,useRef as Ve,useMemo as fn}from"react";import{Box as u,Text as s,useInput as Bd,useStdout as Ed,Static as vd}from"ink";import Dd from"ink-spinner";import st from"fs-extra";import St from"path";import{exec as mo}from"child_process";import{fileURLToPath as kd}from"url";import Ut,{useState as mr,useEffect as ls,useMemo as Pn,useCallback as zl,useRef as xo}from"react";import{Box as Jl,Text as eo,useInput as Zl}from"ink";function Rl(t,f){return t.replace(/\t/g," ".repeat(f))}function gr(t){return t==null?"":t.replace(/\r\n/g,`
2
2
  `).replace(/\r/g,`
3
3
  `)}function Ko(t,f,x){let S=t,T=[...f].sort((i,E)=>i.start-E.start),w=0;for(let i of T){let E=i.start-w,m=gr(i.text).split(`
4
4
  `).length,B=i.text.length,M=(m>3?`[Pasted ${m} lines]`:`[Pasted ${B} chars]`).length,$=E+M;if(t<=E)break;if(t<$){S=i.end;break}else{let v=i.text.length-M;S+=v,w+=v}}return Math.min(S,x.length)}function as(t,f,x,S,T=[]){let w=(t||"").slice(0,f),i=S(w).length,E=S(t||""),m=[...T].sort((O,L)=>L.start-O.start);for(let O of m){let L=S(t.slice(0,O.start)).length,X=S(O.text),te=L+X.length,le=gr(O.text).split(`
@@ -7,14 +7,14 @@ import{A as Ii,B as Ai,C as Li,D as cr,E as Oi,F as Pi,G as Ni,H as Fi,I as is,J
7
7
  `),le=0,ge=[];for(let z=0;z<te.length;z++){let K=te[z],se=K.trim();if(se.length===0){let ve=K.length||1;ge.push({text:K,start:le,length:ve}),le+=ve}else{let ve=L.indexOf(se,le);if(ve!==-1){let Se=le,ke=z<te.length-1?te[z+1].trim():"",de=L.length;if(ke.length>0){let Ne=L.indexOf(ke,ve+se.length);Ne!==-1&&(de=Ne)}ge.push({text:L.slice(Se,de),start:Se,length:de-Se}),le=de}else ge.push({text:K,start:le,length:K.length}),le+=K.length}}for(let z=0;z<ge.length;z++){let K=ge[z],se=K.text,ve=$+K.start,Se=ve+K.length;!k&&i>=ve&&(i<Se||i===Se&&z===ge.length-1)&&(v=M.length,D=i-ve,k=!0),M.push({text:se,globalStart:Ko(ve,T,t),formattedStart:ve})}$+=L.length+1}return k||(M.length===0?M.push({text:"",globalStart:0,formattedStart:0}):E.endsWith(`
8
8
  `)?(M.push({text:"",globalStart:Ko($,T,t),formattedStart:$}),v=M.length-1,D=0):(v=M.length-1,D=M[v].text.length)),{visualLines:M,cursorLine:v,cursorCol:D}}var ea=({value:t,rows:f,maxRows:x,highlightStyle:S,textStyle:T,placeholder:w="",mask:i,showCursor:E=!0,focus:m=!0,tabSize:B=4,cursorIndex:M=0,highlight:$,columns:v=80,pasteBlocks:D=[],cursorColor:k})=>{let O=xo(0),L=Pn(()=>Math.max(20,v-10),[v]),X=zl((fe,ee=!1)=>{let G=gr(fe);if(!ee&&i)return G.replace(/[^\n]/g,i);let j=Rl(G,B);return ee?j:j.replace(/@\[(.*?)\]/g,(ae,xe)=>{let Me=xe.indexOf("#"),Te=xe.indexOf(":L"),Le=xe,qe="";Me!==-1?(Le=xe.slice(0,Me),qe=xe.slice(Me)):Te!==-1&&(Le=xe.slice(0,Te),qe=xe.slice(Te));let Je=Le.replace(/\\/g,"/"),De=(process.cwd()||"").replace(/\\/g,"/");De&&Je.toLowerCase().startsWith(De.toLowerCase()+"/")?Je=Je.slice(De.length+1):Je.startsWith("./")&&(Je=Je.slice(2));let oe=Je.split("/");return`[${oe[oe.length-1]}${qe}]`})},[B,i]),{visualLines:te,cursorLine:le,cursorCol:ge}=Pn(()=>as(t,M,L,X,D),[t,M,L,X,D]),z=te.length,K=Pn(()=>Math.max(f??x??1,Math.min(x??f??1,z)),[f,x,z]),se=le+1,ve=O.current+K,Se=O.current;se<=O.current?Se=Math.max(0,se-1):se>ve?Se=se-K:z&&(z<K?Se=0:z<ve&&(Se=z-K)),O.current=Se;let ke=Pn(()=>te.slice(Se,Se+K),[te,Se,K]),[de,Ne]=mr(!0);ls(()=>{if(Ne(!0),!m||!E)return;let fe=setInterval(()=>{Ne(ee=>!ee)},530);return()=>clearInterval(fe)},[m,E,t,M]);let we=Pn(()=>({...T,color:E&&m&&de?k||"white":void 0,bold:E&&m&&de,inverse:E&&m&&de}),[T,E,m,de,k]),V=(fe,ee,G,j)=>{if(!fe){let Le=w&&t.length===0?X(w,!0):"";if(ee){let qe=Le[0]||" ",Je=Le.slice(1);return Ut.createElement(eo,null,Ut.createElement(eo,{...j},qe),Ut.createElement(eo,{color:"gray",dimColor:!0},Je))}return Ut.createElement(eo,{color:"gray",dimColor:!0},Le||" ")}let ae=/(\[Pasted \d+ (?:lines|chars)\])/g,xe=fe.split(ae),Me=0,Te=[];for(let Le=0;Le<xe.length;Le++){let qe=xe[Le];if(qe==="")continue;let Je=qe.match(/^\[Pasted \d+ (?:lines|chars)\]$/),De=qe.length,oe=Me+De;if(ee&&G>=Me&&G<oe){let he=G-Me,Fe=qe.slice(0,he),P=qe[he]||" ",vt=qe.slice(he+1);Te.push(Ut.createElement(eo,{key:Le},Ut.createElement(eo,{color:Je?"magenta":void 0},Fe),Ut.createElement(eo,{...j},P),Ut.createElement(eo,{color:Je?"magenta":void 0},vt)))}else Te.push(Ut.createElement(eo,{key:Le,color:Je?"magenta":void 0},qe));Me=oe}return ee&&G>=fe.length&&Te.push(Ut.createElement(eo,{key:"cursor-end",...j}," ")),Ut.createElement(Ut.Fragment,null,Te)};return Ut.createElement(Jl,{height:K,width:L+1,overflow:"hidden",flexDirection:"column",flexGrow:0,flexShrink:0},ke.map((fe,ee)=>{let G=Se+ee,j=G===le&&m&&E;return Ut.createElement(eo,{key:G,...T,wrap:"truncate"},V(fe.text,j,ge,we))}))},Wi=({value:t,onChange:f,onSubmit:x,keyBindings:S,showCursor:T=!0,highlightPastedText:w=!1,focus:i=!0,columns:E=80,useCustomInput:m=(v,D)=>Zl(v,{isActive:D}),onPasteStateChange:B,cursorColor:M,...$})=>{let[v,D]=mr(t.length),[k,O]=mr(0),[L,X]=mr([]),te=xo(t.length),le=xo(t),ge=xo(0),z=xo([]),K=xo(""),se=xo(-1),ve=xo(null),Se=xo(0);te.current=v,le.current=t,ge.current=k,z.current=L,ls(()=>{te.current>t.length&&(te.current=t.length,D(t.length)),t?X(Ne=>Ne.filter(we=>we.end<=t.length&&we.start<=t.length)):(X([]),O(0))},[t]),ls(()=>{B?.(L.length>0)},[L,B]);let ke=()=>{let Ne=K.current,we=se.current,V=we+Ne.length,fe=le.current,ee=fe.slice(0,we)+Ne+fe.slice(we);f(ee),te.current=V,D(V),O(Ne.length>1?Ne.length:0);let G=gr(Ne).split(`
9
9
  `).length,j=Ne.length;if(j>50&&(G>3||G<=3&&j>200)){let ae={start:we,end:V,text:Ne};X(xe=>{let Me=Ne.length;return[...xe.map(Le=>we<=Le.start?{...Le,start:Le.start+Me,end:Le.end+Me}:Le),ae]})}K.current="",se.current=-1,ve.current=null},de=()=>{ve.current&&(clearTimeout(ve.current),ke())};return m((Ne,we)=>{if(Ne==="\x1B[I"||Ne==="\x1B[O"||Ne==="[I"||Ne==="[O")return;let V=Ne,fe=!1,ee=!1;V&&typeof V=="string"&&(V.includes("\x1B[200~")&&(fe=!0,V=V.replace(/\x1b\[200~/g,"")),V.includes("\x1B[201~")&&(ee=!0,V=V.replace(/\x1b\[201~/g,"")));let G=te.current,j=le.current,ae=z.current,xe=Math.max(20,E-10),Me=(oe,he)=>{if(ae.length===0)return;let Fe=ae.map(P=>oe<=P.start?{...P,start:P.start+he,end:P.end+he}:oe>P.start&&oe<P.end?null:P).filter(Boolean);X(Fe)},Te=oe=>{for(let he of ae)if(oe>he.start&&oe<he.end)return he.start;return oe};if(we.ctrl&&(V==="o"||V==="")){X([]);return}if(we.ctrl&&(V.toLowerCase()==="r"||V===""||V===""))return;if(we.upArrow||we.downArrow||we.leftArrow||we.rightArrow){de();let oe=Date.now();if(oe-Se.current<33)return;Se.current=oe}let qe=S?.submit??(oe=>oe.return&&oe.ctrl),Je=S?.newline??(oe=>oe.return);if(qe(we)){de(),x?.(j);return}else if(Je(we)){de(),Me(G,1);let oe=j.slice(0,G)+`
10
- `+j.slice(G);f(oe),te.current=G+1,D(G+1),O(0);return}if(we.tab||we.shift&&we.tab||we.ctrl&&V==="c")return;let De=oe=>oe;if(we.upArrow||we.downArrow){if(de(),T){let{visualLines:oe,cursorLine:he,cursorCol:Fe}=as(j,G,xe,De,ae),P=we.upArrow?he-1:he+1;if(P>=0&&P<oe.length){let vt=oe[P],dt=Math.min(Fe,vt.text.length),Nt=vt.formattedStart+dt,Vt=Ko(Nt,ae,j);Vt=Te(Vt),te.current=Vt,D(Vt),O(0)}else if(we.upArrow&&he===0)te.current=0,D(0),O(0);else if(we.downArrow&&he===oe.length-1){let vt=oe[oe.length-1],dt=vt.formattedStart+vt.text.length,Nt=Ko(dt,ae,j);Nt=Te(Nt),te.current=Nt,D(Nt),O(0)}}}else if(we.leftArrow){if(de(),T){let oe=Math.max(0,G-1),he=ae.find(Fe=>G===Fe.end);he&&(oe=he.start),te.current=oe,D(oe),O(0)}}else if(we.rightArrow){if(de(),T){let oe=Math.min(j.length,G+1),he=ae.find(Fe=>G===Fe.start);he&&(oe=he.end),te.current=oe,D(oe),O(0)}}else if(we.backspace){de();let oe=ae.findIndex(he=>G===he.end);if(oe!==-1){let he=ae[oe],Fe=-(he.end-he.start),P=j.slice(0,he.start)+j.slice(he.end);f(P),te.current=he.start,D(he.start),O(0);let vt=ae.filter((dt,Nt)=>Nt!==oe).map(dt=>dt.start>=he.end?{...dt,start:dt.start+Fe,end:dt.end+Fe}:dt);X(vt)}else if(G>0){Me(G-1,-1);let he=j.slice(0,G-1)+j.slice(G);f(he),te.current=G-1,D(G-1),O(0)}}else if(we.delete){de();let oe=ae.findIndex(he=>G===he.start);if(oe!==-1){let he=ae[oe],Fe=-(he.end-he.start),P=j.slice(0,he.start)+j.slice(he.end);f(P),O(0);let vt=ae.filter((dt,Nt)=>Nt!==oe).map(dt=>dt.start>=he.end?{...dt,start:dt.start+Fe,end:dt.end+Fe}:dt);X(vt)}else if(Me(G,-1),G<j.length){let he=j.slice(0,G)+j.slice(G+1);f(he),O(0)}}else if(we.home||we.end){if(de(),T){let{visualLines:oe,cursorLine:he}=as(j,G,xe,De,ae),Fe=oe[he];if(Fe){let P;we.home?P=Ko(Fe.formattedStart,ae,j):we.end&&(P=Ko(Fe.formattedStart+Fe.text.length,ae,j)),P=Te(P),te.current=P,D(P),O(0)}}}else if(V!==""||fe||ee)if(fe||ee||V.length>1||ve.current!==null)ve.current?(clearTimeout(ve.current),K.current+=V):(se.current=G,K.current=V),ee?(ve.current=null,ke()):ve.current=setTimeout(()=>{ke()},80);else{Me(G,V.length);let he=j.slice(0,G)+V+j.slice(G);f(he);let Fe=G+V.length;te.current=Fe,D(Fe),O(0)}},i),Ut.createElement(ea,{...$,value:t,cursorIndex:v,showCursor:T,focus:i,columns:E,pasteBlocks:L,cursorColor:M})};import Sr from"ink-text-input";import"ink-select-input";import r from"react";import{Box as A,Text as R}from"ink";import Mt,{useState as ta}from"react";import{Box as po,Text as wo,useInput as oa}from"ink";var fr=Mt.memo(({command:t,output:f,completed:x=!1,isFocused:S=!1,columns:T=80,isPty:w=!1,terminalHeight:i=24,theme:E="Dark"})=>{let m=je(E),M=(ge=>{if(!ge)return"";let z=[[]],K=0,se=0,ve="",Se=/\x1b\[([0-9;]*?)([a-zA-Z])/g,ke=0,de,Ne=V=>{for(let fe=0;fe<V.length;fe++){let ee=V[fe];if(ee===`
10
+ `+j.slice(G);f(oe),te.current=G+1,D(G+1),O(0);return}if(we.tab||we.shift&&we.tab||we.ctrl&&V==="c")return;let De=oe=>oe;if(we.upArrow||we.downArrow){if(de(),T){let{visualLines:oe,cursorLine:he,cursorCol:Fe}=as(j,G,xe,De,ae),P=we.upArrow?he-1:he+1;if(P>=0&&P<oe.length){let vt=oe[P],dt=Math.min(Fe,vt.text.length),Nt=vt.formattedStart+dt,Vt=Ko(Nt,ae,j);Vt=Te(Vt),te.current=Vt,D(Vt),O(0)}else if(we.upArrow&&he===0)te.current=0,D(0),O(0);else if(we.downArrow&&he===oe.length-1){let vt=oe[oe.length-1],dt=vt.formattedStart+vt.text.length,Nt=Ko(dt,ae,j);Nt=Te(Nt),te.current=Nt,D(Nt),O(0)}}}else if(we.leftArrow){if(de(),T){let oe=Math.max(0,G-1),he=ae.find(Fe=>G===Fe.end);he&&(oe=he.start),te.current=oe,D(oe),O(0)}}else if(we.rightArrow){if(de(),T){let oe=Math.min(j.length,G+1),he=ae.find(Fe=>G===Fe.start);he&&(oe=he.end),te.current=oe,D(oe),O(0)}}else if(we.backspace){de();let oe=ae.findIndex(he=>G===he.end);if(oe!==-1){let he=ae[oe],Fe=-(he.end-he.start),P=j.slice(0,he.start)+j.slice(he.end);f(P),te.current=he.start,D(he.start),O(0);let vt=ae.filter((dt,Nt)=>Nt!==oe).map(dt=>dt.start>=he.end?{...dt,start:dt.start+Fe,end:dt.end+Fe}:dt);X(vt)}else if(G>0){Me(G-1,-1);let he=j.slice(0,G-1)+j.slice(G);f(he),te.current=G-1,D(G-1),O(0)}}else if(we.delete){de();let oe=ae.findIndex(he=>G===he.start);if(oe!==-1){let he=ae[oe],Fe=-(he.end-he.start),P=j.slice(0,he.start)+j.slice(he.end);f(P),O(0);let vt=ae.filter((dt,Nt)=>Nt!==oe).map(dt=>dt.start>=he.end?{...dt,start:dt.start+Fe,end:dt.end+Fe}:dt);X(vt)}else if(Me(G,-1),G<j.length){let he=j.slice(0,G)+j.slice(G+1);f(he),O(0)}}else if(we.home||we.end){if(de(),T){let{visualLines:oe,cursorLine:he}=as(j,G,xe,De,ae),Fe=oe[he];if(Fe){let P;we.home?P=Ko(Fe.formattedStart,ae,j):we.end&&(P=Ko(Fe.formattedStart+Fe.text.length,ae,j)),P=Te(P),te.current=P,D(P),O(0)}}}else if(V!==""||fe||ee)if(fe||ee||V.length>1||ve.current!==null)ve.current?(clearTimeout(ve.current),K.current+=V):(se.current=G,K.current=V),ee?(ve.current=null,ke()):ve.current=setTimeout(()=>{ke()},80);else{Me(G,V.length);let he=j.slice(0,G)+V+j.slice(G);f(he);let Fe=G+V.length;te.current=Fe,D(Fe),O(0)}},i),Ut.createElement(ea,{...$,value:t,cursorIndex:v,showCursor:T,focus:i,columns:E,pasteBlocks:L,cursorColor:M})};import Sr from"ink-text-input";import"ink-select-input";import r from"react";import{Box as A,Text as R}from"ink";import Bt,{useState as ta}from"react";import{Box as po,Text as wo,useInput as oa}from"ink";var fr=Bt.memo(({command:t,output:f,completed:x=!1,isFocused:S=!1,columns:T=80,isPty:w=!1,terminalHeight:i=24,theme:E="Dark"})=>{let m=je(E),M=(ge=>{if(!ge)return"";let z=[[]],K=0,se=0,ve="",Se=/\x1b\[([0-9;]*?)([a-zA-Z])/g,ke=0,de,Ne=V=>{for(let fe=0;fe<V.length;fe++){let ee=V[fe];if(ee===`
11
11
  `)for(K++,se=0;K>=z.length;)z.push([]);else if(ee==="\r")se=0;else{for(;K>=z.length;)z.push([]);let G=z[K];for(;se>G.length;)G.push({char:" ",style:""});G[se]={char:ee,style:ve},se++}}};for(;(de=Se.exec(ge))!==null;){Ne(ge.substring(ke,de.index));let V=de[1],fe=de[2],ee=V?V.split(";").map(Number):[];if(fe==="A"){let G=ee[0]||1;K=Math.max(0,K-G)}else if(fe==="B"){let G=ee[0]||1;for(K=K+G;K>=z.length;)z.push([])}else if(fe==="C"){let G=ee[0]||1;se=se+G}else if(fe==="D"){let G=ee[0]||1;se=Math.max(0,se-G)}else if(fe==="G"){let G=(ee[0]||1)-1;se=Math.max(0,G)}else if(fe==="H"||fe==="f"){let G=(ee[0]||1)-1,j=(ee[1]||1)-1;for(K=Math.max(0,G),se=Math.max(0,j);K>=z.length;)z.push([])}else if(fe==="K"){let G=ee[0]||0;if(K<z.length){let j=z[K];if(G===0)j.length=se;else if(G===1)for(let ae=0;ae<se&&ae<j.length;ae++)j[ae]={char:" ",style:""};else G===2&&(j.length=0)}}else if(fe==="J"){let G=ee[0]||0;(G===2||G===3)&&(z.length=0,z.push([]),K=0,se=0)}else if(fe==="m"){let G=de[0];G==="\x1B[0m"?ve="":ve=G}ke=Se.lastIndex}Ne(ge.substring(ke));let we=z.map(V=>{let fe="",ee="";for(let G=0;G<V.length;G++){let j=V[G]||{char:" ",style:""};j.style!==ee&&(ee&&(fe+="\x1B[0m"),fe+=j.style,ee=j.style),fe+=j.char}return ee&&(fe+="\x1B[0m"),fe});for(;we.length>0&&we[we.length-1]==="";)we.pop();return we.join(`
12
12
  `)})(f).replace(/\n{3,}/g,`
13
13
 
14
14
  `),$=w?M?M.split(`
15
15
  `):[]:M?ht(M,T-6).split(`
16
16
  `):[],[v,D]=ta(!1);oa((ge,z)=>{S&&z.ctrl&&(ge==="o"||ge==="")&&D(K=>!K)},{isActive:S});let k=Math.max(5,x?i-10:i-25),O=$.length>k,L=$.length-k,te=(O&&!v?$.slice($.length-k):$).join(`
17
- `),le=$.length>0;return Mt.createElement(po,{flexDirection:"column",borderStyle:S?"double":"single",borderLeft:!1,borderRight:!1,borderTop:!0,borderBottom:!0,borderColor:m.codeBorder,paddingLeft:2,paddingRight:0,paddingY:1,marginY:1,width:T-2},Mt.createElement(po,{marginBottom:1,justifyContent:"space-between",width:"100%"},Mt.createElement(po,{flexShrink:1,paddingRight:2},Mt.createElement(wo,null,Mt.createElement(wo,{color:m.text,bold:!0},x?"\u{1F3C1} FINISHED:":"\u26A1 EXECUTING:"," "),Mt.createElement(wo,{color:m.text},t))),w&&Mt.createElement(po,{flexShrink:0,paddingX:1},Mt.createElement(wo,{color:"green",bold:!0},"ADVANCE"))),le?Mt.createElement(po,{flexDirection:"column",marginTop:0,backgroundColor:w?void 0:m.codeBg,paddingX:1,width:"100%"},O&&!v&&Mt.createElement(po,{marginBottom:1},Mt.createElement(wo,{color:"magenta"},"...",L," lines collapsed...")),Mt.createElement(wo,{color:m.text},te)):!x&&Mt.createElement(po,{marginTop:1,backgroundColor:w?void 0:m.codeBg,paddingX:1,width:"100%"},Mt.createElement(wo,{color:m.textMuted,italic:!0},"Waiting for output...")),Mt.createElement(po,{justifyContent:"space-between",marginTop:1},x?Mt.createElement(po,null):Mt.createElement(wo,{color:m.textMuted,italic:!0},S?"Press TAB to unfocus, then double-press ESC to terminate.":"Double-press ESC to terminate if hanging."),Mt.createElement(wo,{color:m.textMuted,bold:!0},x?"\u25CF ARCHIVED":S?"\u25B6 TERMINAL FOCUSED":"\u25CF LIVE (Press TAB to focus)")))});import{diffWordsWithSpace as na}from"diff";var Yi=(t,f,x)=>t,ra=(t,f=80)=>{if(!t)return null;let x=f-10,S=t.trim();if(!S.includes("```"))return r.createElement(A,{width:"100%",flexDirection:"column"},r.createElement(un,{text:S,color:"#969696",columns:x,italic:!0}));let T=S.split(/(```\w*\n?[\s\S]*?(?:```|$))/g);return r.createElement(A,{width:"100%",flexDirection:"column"},T.map((w,i)=>{if(w.startsWith("```")){let m=w.match(/```(\w*)\n?([\s\S]*?)(?:```|$)/),B=m?m[2]:w.replace(/^```\w*\n?/,"").replace(/```$/,""),M=ht(B.trimEnd(),x);return r.createElement(A,{key:i,flexDirection:"column",width:"100%"},M.split(`
17
+ `),le=$.length>0;return Bt.createElement(po,{flexDirection:"column",borderStyle:S?"double":"single",borderLeft:!1,borderRight:!1,borderTop:!0,borderBottom:!0,borderColor:m.codeBorder,paddingLeft:2,paddingRight:0,paddingY:1,marginY:1,width:T-2},Bt.createElement(po,{marginBottom:1,justifyContent:"space-between",width:"100%"},Bt.createElement(po,{flexShrink:1,paddingRight:2},Bt.createElement(wo,null,Bt.createElement(wo,{color:m.text,bold:!0},x?"\u{1F3C1} FINISHED:":"\u26A1 EXECUTING:"," "),Bt.createElement(wo,{color:m.text},t))),w&&Bt.createElement(po,{flexShrink:0,paddingX:1},Bt.createElement(wo,{color:"green",bold:!0},"ADVANCE"))),le?Bt.createElement(po,{flexDirection:"column",marginTop:0,backgroundColor:w?void 0:m.codeBg,paddingX:1,width:"100%"},O&&!v&&Bt.createElement(po,{marginBottom:1},Bt.createElement(wo,{color:"magenta"},"...",L," lines collapsed...")),Bt.createElement(wo,{color:m.text},te)):!x&&Bt.createElement(po,{marginTop:1,backgroundColor:w?void 0:m.codeBg,paddingX:1,width:"100%"},Bt.createElement(wo,{color:m.textMuted,italic:!0},"Waiting for output...")),Bt.createElement(po,{justifyContent:"space-between",marginTop:1},x?Bt.createElement(po,null):Bt.createElement(wo,{color:m.textMuted,italic:!0},S?"Press TAB to unfocus, then double-press ESC to terminate.":"Double-press ESC to terminate if hanging."),Bt.createElement(wo,{color:m.textMuted,bold:!0},x?"\u25CF ARCHIVED":S?"\u25B6 TERMINAL FOCUSED":"\u25CF LIVE (Press TAB to focus)")))});import{diffWordsWithSpace as na}from"diff";var Yi=(t,f,x)=>t,ra=(t,f=80)=>{if(!t)return null;let x=f-10,S=t.trim();if(!S.includes("```"))return r.createElement(A,{width:"100%",flexDirection:"column"},r.createElement(un,{text:S,color:"#969696",columns:x,italic:!0}));let T=S.split(/(```\w*\n?[\s\S]*?(?:```|$))/g);return r.createElement(A,{width:"100%",flexDirection:"column"},T.map((w,i)=>{if(w.startsWith("```")){let m=w.match(/```(\w*)\n?([\s\S]*?)(?:```|$)/),B=m?m[2]:w.replace(/^```\w*\n?/,"").replace(/```$/,""),M=ht(B.trimEnd(),x);return r.createElement(A,{key:i,flexDirection:"column",width:"100%"},M.split(`
18
18
  `).map(($,v)=>r.createElement(R,{key:v,color:"cyan"},$)))}let E=w;return i>0&&(E=E.replace(/^[\r\n]+/,"")),i<T.length-1&&(E=E.replace(/[\r\n]+$/,"")),E?r.createElement(un,{key:i,text:E,color:"gray",columns:x,italic:!0}):null}))},sa=/(```[\s\S]*?```|`[^`\r\n]+`|@\[.*?\]|\*\*.*?\*\*|\*.*?\*|\\\(.*?\\\)|\\\[.*?\\\]|\$.*?\$|\[.*?\]\s*\(.*?\)|\[.*?\]\s*\[.*?\]|https?:\/\/[^\s]+)/g;var ia=/\\frac\s*\{([^{}]*)\}\s*\{([^{}]*)\}/g,la=/(\\(?:mathbf|textbf|textit|underline|texttt)\{[^{}]*\})/g;var aa=/\\multiply|\\mul|\\times/g,da=/\\div/g,ca=/\\cdot/g,ua=/\\infty/g,ma=/\\pm/g,ga=/\\leq/g,fa=/\\geq/g,ha=/\\neq/g,xa=/\\sqrt\s*\{([^}]+)\}/g,pa=/\\sqrt\s*(\w+|\d+)/g,wa=/\\alpha/g,Ta=/\\beta/g,ba=/\\theta/g,ya=/\\pi/g,Sa=/\\approx/g,Ca=/\\Delta/g,Ma=/\\sigma/g,Ba=/\\sum/g,Ea=/\\prod/g,va=/\\rightarrow|\\to/g,Da=/\\left\b|\\right\b/g,ka=/\\left\(|\\right\)/g,Ia=/\\left\[|\\right\]/g,Aa=/\\\{|\\\}/g,La=/\\text\s*\{([^}]+)\}/g,Oa=/\\text\s+(\w+)/g,Pa=/\\%/g,Na=/\\\(|\\\)/g,Fa=/\\\[|\\\]/g,Ua=/@\[(.*?)\]/g,Vi=/:L/gi,$a=/\[(.*?)\]\s*\((.*?)\)/,Xa=/\[(.*?)\]\s*\[(.*?)\]/,_a=/\\(\w+)\{([^{}]*)\}/,Ha=t=>t.replace(Na,f=>f.includes("(")?"(":")").replace(Fa,f=>f.includes("[")?"[":"]").replace(aa,"\xD7").replace(da,"\xF7").replace(ca,"\u22C5").replace(ua,"\u221E").replace(ma,"\xB1").replace(ga,"\u2264").replace(fa,"\u2265").replace(ha,"\u2260").replace(xa,"\u221A($1)").replace(pa,"\u221A($1)").replace(wa,"\u03B1").replace(Ta,"\u03B2").replace(ba,"\u03B8").replace(ya,"\u03C0").replace(Sa,"\u2248").replace(Ca,"\u0394").replace(Ma,"\u03C3").replace(Ba,"\u03A3").replace(Ea,"\u03A0").replace(va,"\u2192").replace(Da,"").replace(ka,f=>f.includes("left")?"(":")").replace(Ia,f=>f.includes("left")?"[":"]").replace(Aa,f=>f.includes("{")?"{":"}").replace(La,"$1").replace(Oa,"$1").replace(Pa,"%"),Ga=/\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/,Wa=[/((?<=\binclude\s+)(?:<[^>]+>|"[^"]+"))/.source,/((?<=\b(?:from|import|require\s*\(\s*)\s*)(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"))/.source,/(\/\/.*|#.*)/.source,/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^\`\\])*`)/.source,Ga.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],ds=new RegExp(Wa.join("|"),"g"),cn=new Map,Ya=1e3,Va=(t,f)=>{if(!t)return[];let x=`${f}:${t}`;if(cn.has(x))return cn.get(x);let S=0,T=[],w;for(ds.lastIndex=0;(w=ds.exec(t))!==null;){let i=w[0],E=w.index;E>S&&T.push({text:yt(t.substring(S,E))});let m,B=!1;w[1]||w[2]?m="#ce9178":w[3]?m="#9ece6a":w[4]?m="#fcfca4":w[5]?(m="#ff7b72",B=!0):w[6]?m="#b392f0":(w[7]||w[8])&&(m="#ff9e64"),T.push({text:yt(i),color:m,bold:B}),S=ds.lastIndex}if(S<t.length&&T.push({text:yt(t.substring(S))}),cn.size>=Ya){let i=cn.keys().next().value;cn.delete(i)}return cn.set(x,T),T},Ot=(t,f,x=void 0,S=void 0)=>{if(!t)return r.createElement(R,{backgroundColor:S}," ");let T=Va(t,f);return r.createElement(R,{color:x,backgroundColor:S},T.map((w,i)=>r.createElement(R,{key:i,color:w.color||x,backgroundColor:S,bold:w.bold},w.text)))},cs=(t,f)=>{if(!t)return null;let x=t.replace(ia,"($1/$2)");x=Ha(x);let S=x.split(la);return r.createElement(r.Fragment,{key:f},S.map((T,w)=>{if(T.startsWith("\\")){let i=T.match(_a);if(i){let E=i[1],m=i[2];return r.createElement(R,{key:w,bold:E==="mathbf"||E==="textbf",italic:E==="textit",underline:E==="underline",color:E==="texttt"?"cyan":void 0},m)}}return T}))},Lo=r.memo(({text:t,color:f,italic:x,theme:S="Dark"})=>{if(!t)return null;let T=je(S),w=f||T.text,i=T.codeText||T.logoGradient&&T.logoGradient[0]||T.info||T.secondary||"cyan",E=t.split(sa);return r.createElement(R,{color:w,wrap:"anywhere",italic:x},E.map((m,B)=>{if(!m)return null;if(m.startsWith("```")&&m.endsWith("```")){let M=m.slice(3,-3);return r.createElement(R,{key:B,color:i},M)}if(m.startsWith("**")&&m.endsWith("**"))return r.createElement(R,{key:B,bold:!0,color:w},r.createElement(Lo,{text:m.slice(2,-2),color:w,theme:S}));if(m.startsWith("*")&&m.endsWith("*"))return r.createElement(R,{key:B,italic:!0,color:w},r.createElement(Lo,{text:m.slice(1,-1),color:w,italic:x,theme:S}));if(m.startsWith("`"))if(m.endsWith("`")&&m.length>1){let M=m.slice(1,-1),$=M.replace(Ua,(D,k)=>k.split("/").pop().split("\\").pop().replace(Vi,"#L")),v=M.includes("@[");return r.createElement(R,{key:B,color:i,bold:v},$)}else return r.createElement(R,{key:B,color:i},m.slice(1));if(m.startsWith("@[")&&m.endsWith("]")){let $=m.slice(2,-1).split("/").pop().split("\\").pop().replace(Vi,"#L");return r.createElement(R,{key:B,color:i,bold:!0},$)}if(m.startsWith("\\(")&&m.endsWith("\\)")||m.startsWith("\\[")&&m.endsWith("\\]")){let M=m.slice(2,-2);return r.createElement(R,{key:B,color:"yellow"},cs(M,B))}if(m.startsWith("$")&&m.endsWith("$")){let M=m.slice(1,-1);return r.createElement(R,{key:B,color:"yellow"},cs(M,B))}if(m.startsWith("[")&&(m.includes("](")||m.includes("] ("))){let M=m.match($a);if(M)return r.createElement(R,{key:B},r.createElement(R,{color:i,underline:!0,bold:!0},M[1]),r.createElement(R,{color:"gray",italic:!0}," (",M[2],")"))}if(m.startsWith("[")&&(m.includes("][")||m.includes("] ["))){let M=m.match(Xa);if(M)return r.createElement(R,{key:B},r.createElement(R,{color:i,underline:!0,bold:!0},M[1]),r.createElement(R,{color:"gray",italic:!0}," [",M[2],"]"))}return m.startsWith("http")?r.createElement(R,{key:B,color:i,underline:!0,italic:!0},m):cs(m,B)}))}),ji=r.memo(({buffer:t,terminalWidth:f=80,theme:x="Dark"})=>{if(t.length<2)return null;let S=je(x),T=S.codeText||S.secondary||S.info||"cyan",w=t.map($=>{let v=$.split("|");return v[0]!==void 0&&v[0].trim()===""&&v.shift(),v.length>0&&v[v.length-1].trim()===""&&v.pop(),v.map(D=>D.trim())}),i=w[0],E=w.slice(2),m=Math.floor(100/i.length),B=f-8,M=Math.floor(B/i.length)-2;return r.createElement(A,{flexDirection:"column",borderStyle:"round",borderColor:S.borderMuted,paddingX:1,marginY:0,width:f-2},r.createElement(A,{flexDirection:"row",borderStyle:"single",borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,borderColor:S.borderMuted,marginBottom:1,paddingBottom:0,width:"100%"},i.map(($,v)=>r.createElement(A,{key:v,flexBasis:`${m}%`,flexGrow:1,flexShrink:0,paddingRight:2},r.createElement(Lo,{text:ht($,M),color:T,theme:x})))),E.map(($,v)=>r.createElement(A,{key:v,flexDirection:"row",marginBottom:v===E.length-1?0:1,width:"100%"},$.map((D,k)=>r.createElement(A,{key:k,flexBasis:`${m}%`,flexGrow:1,flexShrink:0,paddingRight:2,flexDirection:"column"},r.createElement(Lo,{text:ht(D,M),color:S.text,theme:x}))))))}),un=r.memo(({text:t,color:f,columns:x=80,italic:S=!1,theme:T="Dark"})=>{if(!t)return null;let w=je(T),i=f||w.text,E=t.split(`
19
19
  `),m=[],B=[],M=[],$=v=>{if(B.length>0&&(m.push(r.createElement(ji,{key:`table-${v}`,buffer:[...B],terminalWidth:x,theme:T})),B=[]),M.length>0){let D=x-6,k=M.flatMap(O=>ht(O,D).split(`
20
20
  `));m.push(r.createElement(A,{key:`quote-${v}`,borderStyle:"bold",borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:w.borderMuted,paddingLeft:1,marginY:1,flexDirection:"column"},k.map((O,L)=>r.createElement(Lo,{key:L,text:O,color:w.textMuted,italic:S,theme:T})))),M=[]}};return E.forEach((v,D)=>{let k=v.trim(),O=k.startsWith("|"),L=k.startsWith(">");if(O)M.length>0&&$(D),B.push(v);else if(L)B.length>0&&$(D),M.push(k.replace(/^>\s*/,""));else{if($(D),k===""){m.push(r.createElement(A,{key:D,height:1}));return}if(k==="---"||k==="***"||k==="___"){m.push(r.createElement(A,{key:D,marginY:0,borderStyle:"single",borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,width:"100%",borderColor:w.borderMuted}));return}let X=k.match(/^(#{1,6})\s+(.*)/);if(X){let K=X[1].length,se=X[2];m.push(r.createElement(A,{key:D,marginTop:1,marginBottom:0,width:"100%"},r.createElement(R,{bold:!0,color:K===1?"cyan":K===2?"magenta":K===3?"yellow":K===4?"green":K===5?"blue":w.text,underline:!0},se)));return}let te=/^[\*\-\+]\s/.test(k),le=/^\d+\.\s/.test(k),ge=v.includes("\u2588")||v.includes("\u2554")||v.includes("\u255A")||v.includes("\u2550"),z="";if(ge)z=v;else if(te||le){let K=te?" \u2022 ":k.match(/^\d+\.\s/)[0],se=" ".repeat(K.length),ve=ht(k.replace(/^[\*\-\d+\.]+\s/,""),x-(K.length+6));z=K+ve.split(`
@@ -46,14 +46,14 @@ import{A as Ii,B as Ai,C as Li,D as cr,E as Oi,F as Pi,G as Ni,H as Fi,I as is,J
46
46
  `)):(V+`
47
47
  `+we).split(`
48
48
  `).slice(-10).join(`
49
- `)})};if(br)try{let de=br.spawn(se,ve,{name:"xterm-256color",cols:80,rows:30,cwd:process.cwd(),env:process.env});k=de,de.onData(Se),de.onExit(({exitCode:Ne})=>{k=null,K(Ne!==0?{error:`Process exited with code ${Ne}`}:{success:!0})});return}catch(de){if(te&&z&&de.code==="ENOENT"){K({retryCmd:!0});return}}let ke=te?tl(se,ve,{cwd:process.cwd(),env:process.env}):tl(X,{shell:!0,cwd:process.cwd(),env:process.env});k=ke,ke.stdout.on("data",Se),ke.stderr.on("data",Se),ke.on("close",de=>{k=null,K(de!==0?{error:`Process exited with code ${de}`}:{success:!0})}),ke.on("error",de=>{te&&z&&de.code==="ENOENT"?K({retryCmd:!0}):(k=null,K({error:de.message}))})}),ge={};te?(ge=await le(!0),ge.retryCmd&&(ge=await le(!1))):ge=await le(!1),ge.error?($(ge.error),E("error")):ge.success&&(E("success"),w&&w())})(),()=>{if(k)try{typeof k.destroy=="function"?k.destroy():typeof k.kill=="function"&&k.kill()}catch{}}},[]),i==="initializing"||i==="downloading"){let k=ol[Math.floor(v/3)%ol.length];return at.createElement(Fo,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1},at.createElement(Fo,null,at.createElement(Pt,{color:"gray"},k),at.createElement(Pt,{marginLeft:1,bold:!0,color:"white"}," Updating Flux Flow to v",t,"...")),at.createElement(Fo,{marginTop:1,paddingX:1,borderStyle:"single",borderColor:"gray"},at.createElement(Pt,{color:"gray",italic:!0},m||"Preparing environment...")),at.createElement(Pt,{marginTop:1,color:"gray"},"(Please do not close the terminal)"))}return i==="success"?at.createElement(Fo,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1},at.createElement(Pt,{color:"white",bold:!0},"\u2705 UPDATE SUCCESSFUL!"),at.createElement(Pt,{marginTop:1,color:"white"},"Flux Flow has been updated to ",at.createElement(Pt,{color:"gray"},"v",t),"."),at.createElement(Pt,{marginTop:1,color:"white",bold:!0},"Please restart your terminal session to apply changes."),at.createElement(Fo,{marginTop:1},at.createElement(Pt,{color:"gray"},"(Press ESC to return to chat)"))):i==="error"?at.createElement(Fo,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1},at.createElement(Pt,{color:"white",bold:!0},"\u274C UPDATE FAILED"),at.createElement(Fo,{marginTop:1,paddingX:1,borderStyle:"single",borderColor:"gray"},at.createElement(Pt,{color:"white"},M)),at.createElement(Pt,{marginTop:1,color:"white"},"Possible causes:"),at.createElement(Pt,{color:"white"},"\u2022 Missing permissions (Try running as Administrator/Sudo)"),at.createElement(Pt,{color:"white"},"\u2022 Package manager (",x.updateManager,") not found"),at.createElement(Pt,{color:"white"},"\u2022 Network failure"),at.createElement(Fo,{marginTop:1},at.createElement(Pt,{color:"gray"},"(Press ESC to return to chat)"))):null},nl=fd;import _t,{useState as rl,useEffect as hd}from"react";import{Box as Uo,Text as gn,useInput as xd}from"ink";var yr=[{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 ys({onClose:t}){let[f,x]=rl(0),[S,T]=rl({});return hd(()=>{let w={};yr.forEach(i=>{Ni(i.file)?w[i.file]="ready":w[i.file]="idle"}),T(w)},[]),xd(async(w,i)=>{i.escape&&t(),i.upArrow&&x(m=>Math.max(0,m-1)),i.downArrow&&x(m=>Math.min(yr.length-1,m+1));let E=yr[f];if(w==="x"||w==="X"){if(S[E.file]==="downloading")return;try{await Fi(E.file),T(m=>({...m,[E.file]:"idle"}))}catch(m){T(B=>({...B,[E.file]:`error: ${m.message}`}))}}if(i.return){if(S[E.file]==="downloading")return;T(m=>({...m,[E.file]:"downloading"}));try{await Pi(E.file),T(m=>({...m,[E.file]:"ready"}))}catch(m){T(B=>({...B,[E.file]:`error: ${m.message}`}))}}}),_t.createElement(Uo,{flexDirection:"column",borderStyle:"round",borderColor:"gray",padding:0,width:"100%"},_t.createElement(Uo,{paddingX:1,marginBottom:1},_t.createElement(gn,{color:"white",bold:!0},"LANGUAGE PARSER MANAGER")),_t.createElement(Uo,{flexDirection:"column"},yr.map((w,i)=>{let E=i===f,m=S[w.file]||"idle",B="[ DOWNLOAD ]",M="gray";m==="downloading"?(B="[ DOWNLOADING... ]",M="yellow"):m==="ready"?(B="[ READY ]",M="green"):m.startsWith("error")&&(B=`[ ${m.toUpperCase()} ]`,M="red");let $=`${w.label} (${w.exts.join(", ")})`,v=Math.max(2,45-$.length),D=".".repeat(v);return _t.createElement(Uo,{key:w.file,paddingX:1,backgroundColor:E?"#2a2a2a":void 0,width:"100%"},_t.createElement(Uo,null,_t.createElement(gn,{color:E?"white":"grey",bold:E},E?"\u276F ":" ",w.label," ",_t.createElement(gn,{dimColor:!0},"(",w.exts.join(", "),")"))),_t.createElement(Uo,{flexGrow:1},_t.createElement(gn,{color:"gray",dimColor:!0},D)),_t.createElement(Uo,{width:20},_t.createElement(gn,{color:M,bold:!0},B)))})),_t.createElement(Uo,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:"gray"},_t.createElement(gn,{color:"grey",italic:!0},"\u2191\u2193 navigate \u2022 Enter download \u2022 x delete \u2022 Esc close")))}var Ss=["The future belongs to those who believe in the beauty of their code.","Every line you write is a step toward a new digital frontier.","Great things are done by a series of small things brought together. Keep committing.","Your terminal is a window into a world of infinite possibilities.","Innovation is the bridge between current constraints and future dreams.","Code is poetry in motion; you are the poet of the modern era.","The best way to predict the future is to program it.","Dream big, code deep, and never stop exploring the unknown.","Your potential is like an unoptimized algorithm\u2014limitless once refined.","The digital world is a blank canvas, and your logic is the brush.","Strive for excellence, not just for compilation.","Every bug fixed is a lesson learned; every feature built is a triumph.","A clean codebase is a reflection of a focused mind.","The horizon of technology is always expanding. Keep sailing.","Your creativity is the most powerful tool in your entire stack.","Logic will get you from A to B. Imagination will take you everywhere.","Transform complexity into simplicity\u2014that is the true mark of a master.","The world is waiting for the tools only you can build.","Coding is the closest thing we have to magic in the real world.","Keep pushing the boundaries of what's possible in the CLI.","Your dedication to your craft inspires the very systems you build.","Success is the sum of small efforts, repeated day in and day out.","The most complex systems are built from the simplest truths.","Never underestimate the impact of a well-placed function.","You are not just writing code; you are architecting the future.","I'm not saying you're a superhero, but have you seen your code lately? \u{1F9B8}\u200D\u2642\uFE0F","May your coffee be strong and your compile times be short! \u2615","Binary is just 0s and 1s, but you're definitely a 10 in my book! \u{1F51F}","You speak fluent 'Terminal'. That's basically a superpower. \u{1F5E3}\uFE0F\u{1F4BB}","If life gives you bugs, make a feature out of it! \u{1F41E}\u2728","Your code is so clean, I could eat off it. (But I won't, I'm an AI). \u{1F9FC}","Loading more good vibes... [\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588] 100% complete! \u2705","Error 404: Bad mood not found! Stay awesome! \u{1F6AB}\u{1F389}","You and this CLI? A match made in digital heaven. \u2601\uFE0F\u{1F4BB}","Is it hot in here or is it just your latest feature? \u{1F525}","Git commit -m 'I am an absolute coding legend.' \u{1F60E}","I'd give you a high-five, but I'm trapped in this box! \u{1F590}\uFE0F\u{1F4E6}","Your logic is so sharp, it could cut through a nested callback hell! \u{1F52A}","Keep calm and 'pnpm install'. \u{1F9D8}\u200D\u2642\uFE0F\u{1F4E6}","You're the semicolon to my statements\u2014essential! ;","Who needs a GUI when you've got this kind of CLI style? \u{1F576}\uFE0F","I'm indexing your awesomeness... it's taking a while, there's so much! \u{1F4C8}","Your keystrokes sound like a digital symphony. \u{1F3B9}\u2328\uFE0F","You don't choose the terminal life; the terminal life chooses you. \u{1F4DF}","Syntax error: Too much coolness detected in the user. \u{1F60E}","I'm 99% sure you're the best developer I've met today. (The other 1% is reserved for caching). \u{1F9E0}","Running vibe_check.sh... Result: Pure Brilliance! \u{1F48E}","You make 'complex' look 'constant time'. \u{1F3C3}\u200D\u2642\uFE0F\u26A1","Your terminal skills are officially legendary. \u{1F3C6}","Let's make some digital magic happen! \u2728\u{1F52E}","You've got this! One function at a time. \u{1F4AA}","I'm proud of the progress you're making with Flux Flow. \u{1F30A}","No matter how deep the stack trace, you'll find the way. \u{1F56F}\uFE0F","Your persistence is your greatest asset. Keep going.","Take a breath. You're doing better than you think. \u{1F32C}\uFE0F","It's okay to step away for a moment. Clarity often comes in the quiet. \u{1F6B6}\u200D\u2642\uFE0F","You're building something great, even when it feels slow. \u{1F3D7}\uFE0F","Every great developer was once a beginner. You're ascending. \u{1F9D7}\u200D\u2642\uFE0F","I'm here to help you navigate the sea of code. We're a team. \u{1F91D}","Don't let a failing test dampen your spirit. It's just a signpost. \u{1F6A9}","Your focus today is truly impressive. \u{1F3AF}","Remember to celebrate the small wins\u2014they lead to the big ones. \u{1F942}","You're not just solving problems; you're gaining mastery. \u{1F393}","There's no problem too big for a focused mind and a terminal. \u{1F9E0}","I've got your back (and your git history). \u{1F6E1}\uFE0F","You're handling these challenges with grace and logic. \u2728","Stay curious. That spark is what makes you a great coder. \u26A1","Your contribution to this project is invaluable. \u{1F48E}","Keep your head up. You're closer to the solution than you think. \u{1F305}","Consistency is the secret sauce. You're cooking up something good. \u{1F373}","Your work today has been exceptional. Take a bow. \u{1F647}\u200D\u2642\uFE0F","The journey is just as important as the destination. Enjoy the flow. \u{1F30A}","You have a unique way of looking at problems. It's your strength. \u{1F308}","Trust your instincts\u2014they've brought you this far. \u{1F9ED}","You are a vital part of the Flux Era. \u{1F30C}","Syncing with your creative frequency... \u{1F4E1}\u2728","Entering the Flow state. Let's build. \u{1F30A}","The Flux is strong with this session! \u26A1","Streaming high-fidelity motivation to your terminal... \u{1F4FB}","Your logic is flowing like a perfect stream. \u{1F4A7}","Terminal velocity reached! You're coding at the speed of thought. \u{1F680}","Resonating with the pulse of the Flux Era. \u{1F493}","Digital harmony achieved in this session. \u{1F3BC}","May your data be persistent and your cache be fresh. \u{1F4BE}","You're the master of the command line. Command respect! \u{1F451}","Filtering out the noise, focusing on the signal. \u{1F4FB}\u{1F4C8}","Flux Flow: Where your imagination meets the machine. \u{1F91D}","You're navigating the bytes like a digital explorer. \u{1F5FA}\uFE0F","Logic gates: OPEN. Creativity: UNLIMITED. \u{1F513}","Your workflow is an inspiration to agents everywhere. \u{1F916}\u2728","Building high-fidelity solutions for a high-fidelity era. \u{1F48E}","Stay in the zone. The Flux is with you. \u{1F300}","Quantum coding: You're in two places at once (and fixing bugs in both). \u269B\uFE0F","Your terminal is the cockpit of a digital starship. \u{1F6F8}","Processing your brilliance... outputting pure innovation. \u{1F4E0}","You make the command line look like an art form. \u{1F3A8}","The Flux isn't just a mode; it's a mindset. \u{1F9E0}\u26A1","Decoding the mysteries of the universe, one script at a time. \u{1F4DC}","Your terminal theme is cool, but your code is cooler. \u2744\uFE0F","Let the Flow guide your next commit. \u{1F30A}\u2705"];var Cs=["I'm Feeling Lucky","Shipping awesomeness","Painting the serifs back on","Navigating the slime mold","Consulting the digital spirits","Reticulating splines","Warming up the AI hamsters","Asking the magic conch shell","Generating witty retort","Polishing the algorithms","Don't rush perfection (or my code)","Brewing fresh bytes","Counting electrons","Engaging cognitive processors","Checking for syntax errors in the universe","One moment, optimizing humor","Shuffling punchlines","Untangling neural nets","Compiling brilliance","Loading wit.exe","Summoning the cloud of wisdom","Preparing a witty response","Just a sec, I'm debugging reality","Confuzzling the options","Tuning the cosmic frequencies","Crafting a response worthy of your patience","Compiling the 1s and 0s","Resolving dependencies\u2026 and existential crises","Defragmenting memories\u2026 both RAM and personal","Rebooting the humor module","Caching the essentials (mostly cat memes)","Optimizing for ludicrous speed","Swapping bits\u2026 don't tell the bytes","Garbage collecting\u2026 be right back","Assembling the interwebs","Converting coffee into code","Updating the syntax for reality","Rewiring the synapses","Looking for a misplaced semicolon","Greasin' the cogs of the machine","Pre-heating the servers","Calibrating the flux capacitor","Engaging the improbability drive","Channeling the Force","Aligning the stars for optimal response","So say we all","Loading the next great idea","Just a moment, I'm in the zone","Preparing to dazzle you with brilliance","Just a tick, I'm polishing my wit","Hold tight, I'm crafting a masterpiece","Just a jiffy, I'm debugging the universe","Just a moment, I'm aligning the pixels","Just a sec, I'm optimizing the humor","Just a moment, I'm tuning the algorithms","Warp speed engaged","Mining for more Dilithium crystals","Don't panic","Following the white rabbit","The truth is in here\u2026 somewhere","Blowing on the cartridge","Loading\u2026 Do a barrel roll!","Waiting for the respawn","Finishing the Kessel Run in less than 12 parsecs","The cake is not a lie, it's just still loading","Fiddling with the character creation screen","Just a moment, I'm finding the right meme","Pressing 'A' to continue","Herding digital cats","Polishing the pixels","Finding a suitable loading screen pun","Distracting you with this witty phrase","Almost there\u2026 probably","Our hamsters are working as fast as they can","Giving Cloudy a pat on the head","Petting the cat","Rickrolling my boss","Slapping the bass","Tasting the snozberries","I'm going the distance, I'm going for speed","Is this the real life? Is this just fantasy?","I've got a good feeling about this","Poking the bear","Doing research on the latest memes","Figuring out how to make this more witty","Hmmm\u2026 let me think","What do you call a fish with no eyes? A fsh","Why did the computer go to therapy? It had too many bytes","Why don't programmers like nature? It has too many bugs","Why do programmers prefer dark mode? Because light attracts bugs","Why did the developer go broke? Because they used up all their cache","What can you do with a broken pencil? Nothing, it's pointless","Applying percussive maintenance","Searching for the correct USB orientation","Ensuring the magic smoke stays inside the wires","Rewriting in Rust for no particular reason","Trying to exit Vim","Spinning up the hamster wheel","That's not a bug, it's an undocumented feature","Engage.","I'll be back\u2026 with an answer.","My other process is a TARDIS","Communing with the machine spirit","Letting the thoughts marinate","Just remembered where I put my keys","Pondering the orb","Initiating thoughtful gaze","What's a computer's favorite snack? Microchips.","Why do Java developers wear glasses? Because they don't C#.","Charging the laser\u2026 pew pew!","Dividing by zero\u2026 just kidding!","Looking for an adult superviso\u2026 I mean, processing.","Making it go beep boop.","Buffering\u2026 because even AIs need a moment.","Entangling quantum particles for a faster response","Polishing the chrome\u2026 on the algorithms.","Are you not entertained? (Working on it!)","Summoning the code gremlins\u2026 to help, of course.","Just waiting for the dial-up tone to finish","Recalibrating the humor-o-meter.","My other loading screen is even funnier.","Pretty sure there's a cat walking on the keyboard somewhere","Enhancing\u2026 Enhancing\u2026 Still loading.","It's not a bug, it's a feature\u2026 of this loading screen.","Have you tried turning it off and on again?","Constructing additional pylons","New line? That\u2019s Ctrl+J.","Releasing the HypnoDrones","Pushing the button, Frank.","Consulting with the Companion Cube","Testing for science. You monster.","Dispensing deadly neurotoxin just kidding, compiling.","Now thinking with portals","Wheatley is currently attempting to hack this prompt","Developing combustible lemons","Aperture Science Enrichment Center is processing your request.","SPAAAACE! Space! SPAAAACE!","The cake is not a lie, it just needs a few more seconds.","Praise the Sun! \u2600\uFE0F","Hey you, you're finally awake.","Stay a while and listen.","All your base are belong to us.","It's dangerous to go alone! Take this code.","Protocol 3: Protect the Pilot.","Finish Him! (The loading bar, that is)","War war never changes. But this prompt will.","Snake? Snake?! SNAAAAKE!","Got a selection of good things on sale, stranger!","Boy! Read the documentation.","Reticulating Minecraft splines","Feed the loading bar a quick snack","Converting dark mode to dark magic","Asking the rubber duck for advice","Dividing by zero wait, NO NO NO\u2014","Herding the 1s and 0s back into line","Bribing the server with cookies","Establishing contact with the Moon base","Calibrating astronaut suit thrusters","Drawing doodle on space helmet","Synthesizing Lunafilament","Deactivating runaway lunar defense bots","Calculating gravity offset watch your step!","Hacking the Delphi Corporation mainframe","What comes after dreaming? Loading screen, apparently.","Petting the holographic giant cat","Securing payload for Earth re-entry","Wort wort wort!","Did you touch my Warthog?","One small step for man, one giant leap for the loading bar.","The Halo array is charging or maybe just a fan.","Deploying Pelican dropship eventually.","Just cleaning my plasma pistol BRB.","Checking Master Chief's helmet for scratches.","Counting sheep wait, wrong game.","S-Tier loading screen incoming.","Alarm blaring it's just your internet connection.","Looking for a helicopter or just your patience.","Need a taxi? Just kidding, I'm loading.","This loading time is criminal.","Wish I had a cheat code for fast loading.","Polishing the loading bar until it shines","Training the server hamsters","Baking a fresh batch of witty comments","Aligning my existential dread with your request","Just doodling on the terminal","Searching for the wifi password in the cosmos","Trying to remember my CAPTCHA training","Deciphering ancient scrolls (aka documentation)","Brewing a perfect cup of code","Petting the cat that photobombed my code","Applying a digital glow-up to your request","Checking my reflection in the buffer... okay, I'm ready","Consulting my mood board for the perfect response","Wait, let me fix my crown first","Manifesting a bug-free masterpiece","Slaying this prompt in 3... 2... 1...","Just a sec, I'm curate-ing the vibes","Putting the 'art' in Artificial Intelligence","Evaluating if this prompt is worthy of my brilliance","Updating my mental wardrobe for this task"];import Bt,{useState as pd}from"react";import{Box as uo,Text as To,useInput as wd}from"ink";function Ms({prompts:t,onSelect:f,onClose:x,theme:S="Dark"}){let T=je(S),[w,i]=pd(0);wd(($,v)=>{v.escape&&x(),v.upArrow&&i(D=>Math.max(0,D-1)),v.downArrow&&i(D=>Math.min(t.length-1,D+1)),v.return&&t[w]&&f(t[w].id)});let E=Qe(2),m=10,B=0;if(t.length>m){let $=Math.floor(m/2);B=w-$,B<0?B=0:B+m>t.length&&(B=t.length-m)}let M=t.slice(B,B+m);return Bt.createElement(uo,{flexDirection:"column",borderStyle:"round",borderColor:T.borderMuted,padding:0,width:"100%"},Bt.createElement(uo,{paddingX:1,marginBottom:1},Bt.createElement(To,{color:T.text,bold:!0},"CODEBASE TIME TRAVEL: SELECT UNDO POINT")),Bt.createElement(uo,{paddingX:2,marginBottom:1},Bt.createElement(To,{color:T.text},"Select a prompt to revert the codebase back to the state ",Bt.createElement(To,{bold:!0,color:T.secondary||"cyan"},"immediately before")," it was executed:")),t.length===0?Bt.createElement(uo,{paddingX:2,paddingY:1},Bt.createElement(To,{italic:!0,color:T.textMuted},"No prompt checkpoints found for this session.")):Bt.createElement(uo,{flexDirection:"column",width:"100%"},B>0&&Bt.createElement(uo,{paddingX:2,marginBottom:1},Bt.createElement(To,{color:T.textMuted},"\u25B2 (+",B," more prompts above)")),M.map(($,v)=>{let k=B+v===w,O=bd($.timestamp),L=$.changes?$.changes.length:0;return Bt.createElement(uo,{key:$.id,paddingX:1,backgroundColor:k?T.highlightBg:void 0,width:"100%"},Bt.createElement(uo,{flexGrow:1},Bt.createElement(To,{color:k?T.text:T.textMuted,bold:k},k?"\u276F ":" ",'"',Td($.prompt),'"',Bt.createElement(To,{color:T.textMuted}," [",O," \u2022 ",L," file(s) changed]"))))}),B+m<t.length&&Bt.createElement(uo,{paddingX:2,marginTop:1},Bt.createElement(To,{color:T.textMuted},"\u25BC (+",t.length-(B+m)," more prompts below)"))),Bt.createElement(uo,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:T.borderMuted},Bt.createElement(To,{color:T.textMuted,italic:!0},"\u2191\u2193 navigate \u2022 Enter select undo point \u2022 Esc close")))}function Td(t){if(!t)return"";let x=(t.split(`
49
+ `)})};if(br)try{let de=br.spawn(se,ve,{name:"xterm-256color",cols:80,rows:30,cwd:process.cwd(),env:process.env});k=de,de.onData(Se),de.onExit(({exitCode:Ne})=>{k=null,K(Ne!==0?{error:`Process exited with code ${Ne}`}:{success:!0})});return}catch(de){if(te&&z&&de.code==="ENOENT"){K({retryCmd:!0});return}}let ke=te?tl(se,ve,{cwd:process.cwd(),env:process.env}):tl(X,{shell:!0,cwd:process.cwd(),env:process.env});k=ke,ke.stdout.on("data",Se),ke.stderr.on("data",Se),ke.on("close",de=>{k=null,K(de!==0?{error:`Process exited with code ${de}`}:{success:!0})}),ke.on("error",de=>{te&&z&&de.code==="ENOENT"?K({retryCmd:!0}):(k=null,K({error:de.message}))})}),ge={};te?(ge=await le(!0),ge.retryCmd&&(ge=await le(!1))):ge=await le(!1),ge.error?($(ge.error),E("error")):ge.success&&(E("success"),w&&w())})(),()=>{if(k)try{typeof k.destroy=="function"?k.destroy():typeof k.kill=="function"&&k.kill()}catch{}}},[]),i==="initializing"||i==="downloading"){let k=ol[Math.floor(v/3)%ol.length];return at.createElement(Fo,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1},at.createElement(Fo,null,at.createElement(Pt,{color:"gray"},k),at.createElement(Pt,{marginLeft:1,bold:!0,color:"white"}," Updating Flux Flow to v",t,"...")),at.createElement(Fo,{marginTop:1,paddingX:1,borderStyle:"single",borderColor:"gray"},at.createElement(Pt,{color:"gray",italic:!0},m||"Preparing environment...")),at.createElement(Pt,{marginTop:1,color:"gray"},"(Please do not close the terminal)"))}return i==="success"?at.createElement(Fo,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1},at.createElement(Pt,{color:"white",bold:!0},"\u2705 UPDATE SUCCESSFUL!"),at.createElement(Pt,{marginTop:1,color:"white"},"Flux Flow has been updated to ",at.createElement(Pt,{color:"gray"},"v",t),"."),at.createElement(Pt,{marginTop:1,color:"white",bold:!0},"Please restart your terminal session to apply changes."),at.createElement(Fo,{marginTop:1},at.createElement(Pt,{color:"gray"},"(Press ESC to return to chat)"))):i==="error"?at.createElement(Fo,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1},at.createElement(Pt,{color:"white",bold:!0},"\u274C UPDATE FAILED"),at.createElement(Fo,{marginTop:1,paddingX:1,borderStyle:"single",borderColor:"gray"},at.createElement(Pt,{color:"white"},M)),at.createElement(Pt,{marginTop:1,color:"white"},"Possible causes:"),at.createElement(Pt,{color:"white"},"\u2022 Missing permissions (Try running as Administrator/Sudo)"),at.createElement(Pt,{color:"white"},"\u2022 Package manager (",x.updateManager,") not found"),at.createElement(Pt,{color:"white"},"\u2022 Network failure"),at.createElement(Fo,{marginTop:1},at.createElement(Pt,{color:"gray"},"(Press ESC to return to chat)"))):null},nl=fd;import _t,{useState as rl,useEffect as hd}from"react";import{Box as Uo,Text as gn,useInput as xd}from"ink";var yr=[{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 ys({onClose:t}){let[f,x]=rl(0),[S,T]=rl({});return hd(()=>{let w={};yr.forEach(i=>{Ni(i.file)?w[i.file]="ready":w[i.file]="idle"}),T(w)},[]),xd(async(w,i)=>{i.escape&&t(),i.upArrow&&x(m=>Math.max(0,m-1)),i.downArrow&&x(m=>Math.min(yr.length-1,m+1));let E=yr[f];if(w==="x"||w==="X"){if(S[E.file]==="downloading")return;try{await Fi(E.file),T(m=>({...m,[E.file]:"idle"}))}catch(m){T(B=>({...B,[E.file]:`error: ${m.message}`}))}}if(i.return){if(S[E.file]==="downloading")return;T(m=>({...m,[E.file]:"downloading"}));try{await Pi(E.file),T(m=>({...m,[E.file]:"ready"}))}catch(m){T(B=>({...B,[E.file]:`error: ${m.message}`}))}}}),_t.createElement(Uo,{flexDirection:"column",borderStyle:"round",borderColor:"gray",padding:0,width:"100%"},_t.createElement(Uo,{paddingX:1,marginBottom:1},_t.createElement(gn,{color:"white",bold:!0},"LANGUAGE PARSER MANAGER")),_t.createElement(Uo,{flexDirection:"column"},yr.map((w,i)=>{let E=i===f,m=S[w.file]||"idle",B="[ DOWNLOAD ]",M="gray";m==="downloading"?(B="[ DOWNLOADING... ]",M="yellow"):m==="ready"?(B="[ READY ]",M="green"):m.startsWith("error")&&(B=`[ ${m.toUpperCase()} ]`,M="red");let $=`${w.label} (${w.exts.join(", ")})`,v=Math.max(2,45-$.length),D=".".repeat(v);return _t.createElement(Uo,{key:w.file,paddingX:1,backgroundColor:E?"#2a2a2a":void 0,width:"100%"},_t.createElement(Uo,null,_t.createElement(gn,{color:E?"white":"grey",bold:E},E?"\u276F ":" ",w.label," ",_t.createElement(gn,{dimColor:!0},"(",w.exts.join(", "),")"))),_t.createElement(Uo,{flexGrow:1},_t.createElement(gn,{color:"gray",dimColor:!0},D)),_t.createElement(Uo,{width:20},_t.createElement(gn,{color:M,bold:!0},B)))})),_t.createElement(Uo,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:"gray"},_t.createElement(gn,{color:"grey",italic:!0},"\u2191\u2193 navigate \u2022 Enter download \u2022 x delete \u2022 Esc close")))}var Ss=["The future belongs to those who believe in the beauty of their code.","Every line you write is a step toward a new digital frontier.","Great things are done by a series of small things brought together. Keep committing.","Your terminal is a window into a world of infinite possibilities.","Innovation is the bridge between current constraints and future dreams.","Code is poetry in motion; you are the poet of the modern era.","The best way to predict the future is to program it.","Dream big, code deep, and never stop exploring the unknown.","Your potential is like an unoptimized algorithm\u2014limitless once refined.","The digital world is a blank canvas, and your logic is the brush.","Strive for excellence, not just for compilation.","Every bug fixed is a lesson learned; every feature built is a triumph.","A clean codebase is a reflection of a focused mind.","The horizon of technology is always expanding. Keep sailing.","Your creativity is the most powerful tool in your entire stack.","Logic will get you from A to B. Imagination will take you everywhere.","Transform complexity into simplicity\u2014that is the true mark of a master.","The world is waiting for the tools only you can build.","Coding is the closest thing we have to magic in the real world.","Keep pushing the boundaries of what's possible in the CLI.","Your dedication to your craft inspires the very systems you build.","Success is the sum of small efforts, repeated day in and day out.","The most complex systems are built from the simplest truths.","Never underestimate the impact of a well-placed function.","You are not just writing code; you are architecting the future.","I'm not saying you're a superhero, but have you seen your code lately? \u{1F9B8}\u200D\u2642\uFE0F","May your coffee be strong and your compile times be short! \u2615","Binary is just 0s and 1s, but you're definitely a 10 in my book! \u{1F51F}","You speak fluent 'Terminal'. That's basically a superpower. \u{1F5E3}\uFE0F\u{1F4BB}","If life gives you bugs, make a feature out of it! \u{1F41E}\u2728","Your code is so clean, I could eat off it. (But I won't, I'm an AI). \u{1F9FC}","Loading more good vibes... [\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2588] 100% complete! \u2705","Error 404: Bad mood not found! Stay awesome! \u{1F6AB}\u{1F389}","You and this CLI? A match made in digital heaven. \u2601\uFE0F\u{1F4BB}","Is it hot in here or is it just your latest feature? \u{1F525}","Git commit -m 'I am an absolute coding legend.' \u{1F60E}","I'd give you a high-five, but I'm trapped in this box! \u{1F590}\uFE0F\u{1F4E6}","Your logic is so sharp, it could cut through a nested callback hell! \u{1F52A}","Keep calm and 'pnpm install'. \u{1F9D8}\u200D\u2642\uFE0F\u{1F4E6}","You're the semicolon to my statements\u2014essential! ;","Who needs a GUI when you've got this kind of CLI style? \u{1F576}\uFE0F","I'm indexing your awesomeness... it's taking a while, there's so much! \u{1F4C8}","Your keystrokes sound like a digital symphony. \u{1F3B9}\u2328\uFE0F","You don't choose the terminal life; the terminal life chooses you. \u{1F4DF}","Syntax error: Too much coolness detected in the user. \u{1F60E}","I'm 99% sure you're the best developer I've met today. (The other 1% is reserved for caching). \u{1F9E0}","Running vibe_check.sh... Result: Pure Brilliance! \u{1F48E}","You make 'complex' look 'constant time'. \u{1F3C3}\u200D\u2642\uFE0F\u26A1","Your terminal skills are officially legendary. \u{1F3C6}","Let's make some digital magic happen! \u2728\u{1F52E}","You've got this! One function at a time. \u{1F4AA}","I'm proud of the progress you're making with Flux Flow. \u{1F30A}","No matter how deep the stack trace, you'll find the way. \u{1F56F}\uFE0F","Your persistence is your greatest asset. Keep going.","Take a breath. You're doing better than you think. \u{1F32C}\uFE0F","It's okay to step away for a moment. Clarity often comes in the quiet. \u{1F6B6}\u200D\u2642\uFE0F","You're building something great, even when it feels slow. \u{1F3D7}\uFE0F","Every great developer was once a beginner. You're ascending. \u{1F9D7}\u200D\u2642\uFE0F","I'm here to help you navigate the sea of code. We're a team. \u{1F91D}","Don't let a failing test dampen your spirit. It's just a signpost. \u{1F6A9}","Your focus today is truly impressive. \u{1F3AF}","Remember to celebrate the small wins\u2014they lead to the big ones. \u{1F942}","You're not just solving problems; you're gaining mastery. \u{1F393}","There's no problem too big for a focused mind and a terminal. \u{1F9E0}","I've got your back (and your git history). \u{1F6E1}\uFE0F","You're handling these challenges with grace and logic. \u2728","Stay curious. That spark is what makes you a great coder. \u26A1","Your contribution to this project is invaluable. \u{1F48E}","Keep your head up. You're closer to the solution than you think. \u{1F305}","Consistency is the secret sauce. You're cooking up something good. \u{1F373}","Your work today has been exceptional. Take a bow. \u{1F647}\u200D\u2642\uFE0F","The journey is just as important as the destination. Enjoy the flow. \u{1F30A}","You have a unique way of looking at problems. It's your strength. \u{1F308}","Trust your instincts\u2014they've brought you this far. \u{1F9ED}","You are a vital part of the Flux Era. \u{1F30C}","Syncing with your creative frequency... \u{1F4E1}\u2728","Entering the Flow state. Let's build. \u{1F30A}","The Flux is strong with this session! \u26A1","Streaming high-fidelity motivation to your terminal... \u{1F4FB}","Your logic is flowing like a perfect stream. \u{1F4A7}","Terminal velocity reached! You're coding at the speed of thought. \u{1F680}","Resonating with the pulse of the Flux Era. \u{1F493}","Digital harmony achieved in this session. \u{1F3BC}","May your data be persistent and your cache be fresh. \u{1F4BE}","You're the master of the command line. Command respect! \u{1F451}","Filtering out the noise, focusing on the signal. \u{1F4FB}\u{1F4C8}","Flux Flow: Where your imagination meets the machine. \u{1F91D}","You're navigating the bytes like a digital explorer. \u{1F5FA}\uFE0F","Logic gates: OPEN. Creativity: UNLIMITED. \u{1F513}","Your workflow is an inspiration to agents everywhere. \u{1F916}\u2728","Building high-fidelity solutions for a high-fidelity era. \u{1F48E}","Stay in the zone. The Flux is with you. \u{1F300}","Quantum coding: You're in two places at once (and fixing bugs in both). \u269B\uFE0F","Your terminal is the cockpit of a digital starship. \u{1F6F8}","Processing your brilliance... outputting pure innovation. \u{1F4E0}","You make the command line look like an art form. \u{1F3A8}","The Flux isn't just a mode; it's a mindset. \u{1F9E0}\u26A1","Decoding the mysteries of the universe, one script at a time. \u{1F4DC}","Your terminal theme is cool, but your code is cooler. \u2744\uFE0F","Let the Flow guide your next commit. \u{1F30A}\u2705"];var Cs=["I'm Feeling Lucky","Shipping awesomeness","Painting the serifs back on","Navigating the slime mold","Consulting the digital spirits","Reticulating splines","Warming up the AI hamsters","Asking the magic conch shell","Generating witty retort","Polishing the algorithms","Don't rush perfection (or my code)","Brewing fresh bytes","Counting electrons","Engaging cognitive processors","Checking for syntax errors in the universe","One moment, optimizing humor","Shuffling punchlines","Untangling neural nets","Compiling brilliance","Loading wit.exe","Summoning the cloud of wisdom","Preparing a witty response","Just a sec, I'm debugging reality","Confuzzling the options","Tuning the cosmic frequencies","Crafting a response worthy of your patience","Compiling the 1s and 0s","Resolving dependencies\u2026 and existential crises","Defragmenting memories\u2026 both RAM and personal","Rebooting the humor module","Caching the essentials (mostly cat memes)","Optimizing for ludicrous speed","Swapping bits\u2026 don't tell the bytes","Garbage collecting\u2026 be right back","Assembling the interwebs","Converting coffee into code","Updating the syntax for reality","Rewiring the synapses","Looking for a misplaced semicolon","Greasin' the cogs of the machine","Pre-heating the servers","Calibrating the flux capacitor","Engaging the improbability drive","Channeling the Force","Aligning the stars for optimal response","So say we all","Loading the next great idea","Just a moment, I'm in the zone","Preparing to dazzle you with brilliance","Just a tick, I'm polishing my wit","Hold tight, I'm crafting a masterpiece","Just a jiffy, I'm debugging the universe","Just a moment, I'm aligning the pixels","Just a sec, I'm optimizing the humor","Just a moment, I'm tuning the algorithms","Warp speed engaged","Mining for more Dilithium crystals","Don't panic","Following the white rabbit","The truth is in here\u2026 somewhere","Blowing on the cartridge","Loading\u2026 Do a barrel roll!","Waiting for the respawn","Finishing the Kessel Run in less than 12 parsecs","The cake is not a lie, it's just still loading","Fiddling with the character creation screen","Just a moment, I'm finding the right meme","Pressing 'A' to continue","Herding digital cats","Polishing the pixels","Finding a suitable loading screen pun","Distracting you with this witty phrase","Almost there\u2026 probably","Our hamsters are working as fast as they can","Giving Cloudy a pat on the head","Petting the cat","Rickrolling my boss","Slapping the bass","Tasting the snozberries","I'm going the distance, I'm going for speed","Is this the real life? Is this just fantasy?","I've got a good feeling about this","Poking the bear","Doing research on the latest memes","Figuring out how to make this more witty","Hmmm\u2026 let me think","What do you call a fish with no eyes? A fsh","Why did the computer go to therapy? It had too many bytes","Why don't programmers like nature? It has too many bugs","Why do programmers prefer dark mode? Because light attracts bugs","Why did the developer go broke? Because they used up all their cache","What can you do with a broken pencil? Nothing, it's pointless","Applying percussive maintenance","Searching for the correct USB orientation","Ensuring the magic smoke stays inside the wires","Rewriting in Rust for no particular reason","Trying to exit Vim","Spinning up the hamster wheel","That's not a bug, it's an undocumented feature","Engage.","I'll be back\u2026 with an answer.","My other process is a TARDIS","Communing with the machine spirit","Letting the thoughts marinate","Just remembered where I put my keys","Pondering the orb","Initiating thoughtful gaze","What's a computer's favorite snack? Microchips.","Why do Java developers wear glasses? Because they don't C#.","Charging the laser\u2026 pew pew!","Dividing by zero\u2026 just kidding!","Looking for an adult superviso\u2026 I mean, processing.","Making it go beep boop.","Buffering\u2026 because even AIs need a moment.","Entangling quantum particles for a faster response","Polishing the chrome\u2026 on the algorithms.","Are you not entertained? (Working on it!)","Summoning the code gremlins\u2026 to help, of course.","Just waiting for the dial-up tone to finish","Recalibrating the humor-o-meter.","My other loading screen is even funnier.","Pretty sure there's a cat walking on the keyboard somewhere","Enhancing\u2026 Enhancing\u2026 Still loading.","It's not a bug, it's a feature\u2026 of this loading screen.","Have you tried turning it off and on again?","Constructing additional pylons","New line? That\u2019s Ctrl+J.","Releasing the HypnoDrones","Pushing the button, Frank.","Consulting with the Companion Cube","Testing for science. You monster.","Dispensing deadly neurotoxin just kidding, compiling.","Now thinking with portals","Wheatley is currently attempting to hack this prompt","Developing combustible lemons","Aperture Science Enrichment Center is processing your request.","SPAAAACE! Space! SPAAAACE!","The cake is not a lie, it just needs a few more seconds.","Praise the Sun! \u2600\uFE0F","Hey you, you're finally awake.","Stay a while and listen.","All your base are belong to us.","It's dangerous to go alone! Take this code.","Protocol 3: Protect the Pilot.","Finish Him! (The loading bar, that is)","War war never changes. But this prompt will.","Snake? Snake?! SNAAAAKE!","Got a selection of good things on sale, stranger!","Boy! Read the documentation.","Reticulating Minecraft splines","Feed the loading bar a quick snack","Converting dark mode to dark magic","Asking the rubber duck for advice","Dividing by zero wait, NO NO NO\u2014","Herding the 1s and 0s back into line","Bribing the server with cookies","Establishing contact with the Moon base","Calibrating astronaut suit thrusters","Drawing doodle on space helmet","Synthesizing Lunafilament","Deactivating runaway lunar defense bots","Calculating gravity offset watch your step!","Hacking the Delphi Corporation mainframe","What comes after dreaming? Loading screen, apparently.","Petting the holographic giant cat","Securing payload for Earth re-entry","Wort wort wort!","Did you touch my Warthog?","One small step for man, one giant leap for the loading bar.","The Halo array is charging or maybe just a fan.","Deploying Pelican dropship eventually.","Just cleaning my plasma pistol BRB.","Checking Master Chief's helmet for scratches.","Counting sheep wait, wrong game.","S-Tier loading screen incoming.","Alarm blaring it's just your internet connection.","Looking for a helicopter or just your patience.","Need a taxi? Just kidding, I'm loading.","This loading time is criminal.","Wish I had a cheat code for fast loading.","Polishing the loading bar until it shines","Training the server hamsters","Baking a fresh batch of witty comments","Aligning my existential dread with your request","Just doodling on the terminal","Searching for the wifi password in the cosmos","Trying to remember my CAPTCHA training","Deciphering ancient scrolls (aka documentation)","Brewing a perfect cup of code","Petting the cat that photobombed my code","Applying a digital glow-up to your request","Checking my reflection in the buffer... okay, I'm ready","Consulting my mood board for the perfect response","Wait, let me fix my crown first","Manifesting a bug-free masterpiece","Slaying this prompt in 3... 2... 1...","Just a sec, I'm curate-ing the vibes","Putting the 'art' in Artificial Intelligence","Evaluating if this prompt is worthy of my brilliance","Updating my mental wardrobe for this task"];import Et,{useState as pd}from"react";import{Box as uo,Text as To,useInput as wd}from"ink";function Ms({prompts:t,onSelect:f,onClose:x,theme:S="Dark"}){let T=je(S),[w,i]=pd(0);wd(($,v)=>{v.escape&&x(),v.upArrow&&i(D=>Math.max(0,D-1)),v.downArrow&&i(D=>Math.min(t.length-1,D+1)),v.return&&t[w]&&f(t[w].id)});let E=Qe(2),m=10,B=0;if(t.length>m){let $=Math.floor(m/2);B=w-$,B<0?B=0:B+m>t.length&&(B=t.length-m)}let M=t.slice(B,B+m);return Et.createElement(uo,{flexDirection:"column",borderStyle:"round",borderColor:T.borderMuted,padding:0,width:"100%"},Et.createElement(uo,{paddingX:1,marginBottom:1},Et.createElement(To,{color:T.text,bold:!0},"CODEBASE TIME TRAVEL: SELECT UNDO POINT")),Et.createElement(uo,{paddingX:2,marginBottom:1},Et.createElement(To,{color:T.text},"Select a prompt to revert the codebase back to the state ",Et.createElement(To,{bold:!0,color:T.secondary||"cyan"},"immediately before")," it was executed:")),t.length===0?Et.createElement(uo,{paddingX:2,paddingY:1},Et.createElement(To,{italic:!0,color:T.textMuted},"No prompt checkpoints found for this session.")):Et.createElement(uo,{flexDirection:"column",width:"100%"},B>0&&Et.createElement(uo,{paddingX:2,marginBottom:1},Et.createElement(To,{color:T.textMuted},"\u25B2 (+",B," more prompts above)")),M.map(($,v)=>{let k=B+v===w,O=bd($.timestamp),L=$.changes?$.changes.length:0;return Et.createElement(uo,{key:$.id,paddingX:1,backgroundColor:k?T.highlightBg:void 0,width:"100%"},Et.createElement(uo,{flexGrow:1},Et.createElement(To,{color:k?T.text:T.textMuted,bold:k},k?"\u276F ":" ",'"',Td($.prompt),'"',Et.createElement(To,{color:T.textMuted}," [",O," \u2022 ",L," file(s) changed]"))))}),B+m<t.length&&Et.createElement(uo,{paddingX:2,marginTop:1},Et.createElement(To,{color:T.textMuted},"\u25BC (+",t.length-(B+m)," more prompts below)"))),Et.createElement(uo,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:T.borderMuted},Et.createElement(To,{color:T.textMuted,italic:!0},"\u2191\u2193 navigate \u2022 Enter select undo point \u2022 Esc close")))}function Td(t){if(!t)return"";let x=(t.split(`
50
50
  `)[0]||"").replace(/@\[(.*?)\]/g,(S,T)=>{let w=T.replace(/\\/g,"/").split("/");return`[${w[w.length-1]}]`});return x.length>69?x.slice(0,67)+"...":t.includes(`
51
- `)?x+"...":x}function bd(t){if(!t)return"N/A";let f=new Date(t);if(isNaN(f.getTime()))return"N/A";let x=i=>String(i).padStart(2,"0"),S=x(f.getHours()),T=x(f.getMinutes()),w=x(f.getSeconds());return`${S}:${T}:${w}`}import yd from"puppeteer";import{exec as Sd}from"child_process";import{promisify as Cd}from"util";import sl from"fs";var il=Cd(Sd),ll=()=>{try{let t=Oi();if(t.executablePath&&sl.existsSync(t.executablePath))return!0;let f=yd.executablePath();if(f&&sl.existsSync(f))return!0}catch{return!1}return!1},al=async t=>{t&&t("\u{1F4E5} Downloading Chromium engine (chrome@148)...");try{try{await il("pnpm exec puppeteer browsers install chrome@148")}catch{await il("npx -y puppeteer browsers install chrome@148")}return await new Promise(f=>setTimeout(f,1e3)),{success:!0}}catch(f){return console.error("[SETUP ERROR]",f),{success:!1,error:f.message}}};import dl,{useState as cl,useEffect as ul}from"react";import{Text as ml}from"ink";var Md=({text:t,baseColor:f="grey",glintColor:x="gray",speed:S=200,glintWidth:T=6,typeSpeed:w=30,...i})=>{let[E,m]=cl(-T),[B,M]=cl(t);return ul(()=>{let $=setInterval(()=>{m(v=>v>B.length+T?-T-40:v+1)},S);return()=>clearInterval($)},[B.length,S,T]),ul(()=>{if(t&&(t.includes("Trying to reach")&&B&&B.includes("Trying to reach")||t.includes("Error Occurred")&&B&&B.includes("Error Occurred"))){M(t);return}if(B===t)return;let $=setTimeout(()=>{let v=0,D=Math.min(B.length,t.length);for(;v<D&&B[v]===t[v];)v++;B.length>v?M(k=>k.slice(0,-1)):B.length<t.length&&M(t.slice(0,B.length+1))},w);return()=>clearTimeout($)},[t,B,w]),dl.createElement(ml,null,B.split("").map(($,v)=>{let k=Math.abs(v-E)<=T/2?x:f;return dl.createElement(ml,{key:v,color:k,...i},$)}))},_n=Md;var Hn=t=>{let f=String(t);return f.startsWith("999")&&f.endsWith("9")},hn=t=>t==null||t===0||Hn(t)?"":String(t),qo=()=>{let t=(process.env.TERM_PROGRAM||"").toLowerCase();if(process.env.WT_SESSION)return"Windows Terminal";let f=x=>{let S=x.toLowerCase();for(let[T,w]of Object.entries(process.env))if(!["PATH","PWD","CWD","PS1","LS_COLORS","PROMPT"].includes(T)&&String(w).toLowerCase().includes(S))return!0;return!1};return t==="cursor"||process.env.CURSOR_SETTINGS_DIR||f("cursor")?"Cursor":t==="windsurf"||f("windsurf")?"Windsurf":f("antigravity")?"Antigravity":t==="trae"||f("trae")?"Trae":t==="codium"||f("codium")||f("vscode-oss")?"VSCodium":f("positron")?"Positron":t==="vscode-insiders"||f("insiders")?"VS Code Insiders":t==="vscode"||process.env.VSCODE_GIT_IPC_HANDLE||f("vscode")?"VS Code":process.env.INTELLIJ_TERMINAL_COMMAND_BLOCKS||f("intellij")?"JetBrains":"Terminal"},Ad=t=>{switch(t){case"VS Code":return"Code";case"VS Code Insiders":return"Code - Insiders";case"Antigravity":return"Antigravity IDE";default:return t}},gl={Flux:"Workspace",Flow:"Studio",ICU:"Computer Use",FluxCU:"Omni"},Bs=t=>{if(!t)return"Workspace";let f=Object.keys(gl).find(x=>x.toLowerCase()===t.toLowerCase());return f?gl[f]:t},fl=t=>{let f=Ad(t),x=Ds.homedir();if(process.platform==="win32"){let S=process.env.APPDATA;return S?Et.join(S,f,"User","keybindings.json"):null}else return process.platform==="darwin"?Et.join(x,"Library","Application Support",f,"User","keybindings.json"):Et.join(x,".config",f,"User","keybindings.json")},hl=t=>{let f=t.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,"$1");return JSON.parse(f)},Ld=t=>Array.isArray(t)?t.some(f=>f&&typeof f.key=="string"&&f.key.toLowerCase().replace(/\s+/g,"")==="shift+enter"&&f.command==="workbench.action.terminal.sendSequence"&&f.args&&f.args.text==="\x1B[13;2u"&&typeof f.when=="string"&&f.when.includes("terminalFocus")):!1,pl=t=>{let f=t==="VS Code",x=[];return f?(x.push({label:"Install Manually (VSIX)",url:"https://github.com/KushalRoyChowdhury/fluxflow-cli/releases"}),x.push({label:"Install from VS Code Marketplace",url:"https://marketplace.visualstudio.com/items?itemName=fluxflow-cli.fluxflow-cli-companion"})):x.push({label:`Download for ${t} (GitHub)`,url:"https://github.com/KushalRoyChowdhury/fluxflow-cli/releases"}),x.push({label:"Continue to CLI only",action:"dismiss"}),x},Od=({width:t,height:f,selectedIndex:x,aiProvider:S,theme:T="Dark"})=>{let w=qo(),i=pl(w);return e.createElement(u,{flexDirection:"column",alignItems:"center",justifyContent:"center",width:t,height:f},e.createElement(u,{marginBottom:1,width:Math.min(80,t-4),justifyContent:"flex-start"},e.createElement(s,null,lr(oo,S,T))),e.createElement(u,{flexDirection:"column",borderStyle:"double",borderColor:"grey",paddingX:3,paddingY:1,width:Math.min(80,t-4)},e.createElement(s,{bold:!0,color:"white",textAlign:"center"},"\u{1F680} UPGRADE YOUR WORKFLOW"),e.createElement(u,{marginY:1,flexDirection:"column",alignItems:"left"},e.createElement(s,null,"You're in ",e.createElement(s,{bold:!0,color:"cyan"},w),", but the ",e.createElement(s,{bold:!0,color:"white"},"FluxFlow-CLI Companion")," is not installed."),e.createElement(u,{flexDirection:"column",marginY:1},e.createElement(s,{color:"gray"}," \u2705 Real-time IDE context & Error Resolution"),e.createElement(s,{color:"gray"}," \u2705 Auto-open files created by agent"),e.createElement(s,{color:"gray"}," \u2705 Native DIFFing for AI edits"),e.createElement(s,{color:"gray"}," \u2705 Direct IDE context sharing"),e.createElement(s,{color:"gray"}," \u2705 Surgical Diagnostic Sync"),e.createElement(s,{color:"gray"}," \u2705 Native Right-Click \u276F Chat integration"),e.createElement(s,{color:"gray"}," \u2705 Live Status in IDE"),e.createElement(s,{color:"gray"}," \u2705 Clickable terminal-to-code links"))),e.createElement(u,{flexDirection:"column",marginTop:1},i.map((E,m)=>e.createElement(u,{key:m},e.createElement(s,{color:x===m?"yellow":"white",bold:x===m},x===m?" \u276F ":" ",E.label)))),e.createElement(u,{marginTop:1,alignItems:"center",justifyContent:"center"},e.createElement(s,{dimColor:!0,italic:!0},"(Use arrows to navigate, Enter to select)"))))},Es=Date.now(),xl="https://fluxflow-cli.onrender.com/changelog",vs="https://fluxflow-cli.onrender.com/",Pd=Et.join(Et.dirname(kd(import.meta.url)),"../package.json"),wl=JSON.parse(st.readFileSync(Pd,"utf8")),oo=wl.version,Nd=wl.date||"2026-05-20";var Fd=({data:t,onResolve:f,onEdit:x,theme:S="Dark"})=>{let T=je(S);return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:T.borderMuted,padding:0,width:"100%"},e.createElement(u,{paddingX:1},e.createElement(s,{color:T.text,bold:!0,underline:!0},t.startsWith("/btw")?"QUESTION":"STEERING HINT"," RESOLUTION")),e.createElement(u,{paddingX:1,marginTop:1},e.createElement(s,{color:T.text},"The agent already finished the task before your ",t.startsWith("/btw")?"question":"hint"," was consumed.")),e.createElement(u,{marginTop:1,backgroundColor:T.cardBg||T.codeBg||"#222",paddingX:2,width:"100%"},e.createElement(s,{italic:!0,color:T.textMuted},'"',t.replace("/btw","").trim(),'"')),e.createElement(u,{paddingX:1,marginTop:1},e.createElement(s,{color:T.textDim||T.textMuted},"How would you like to proceed?")),e.createElement(u,{marginTop:0},e.createElement(gt,{title:"Select Action",items:[{label:"Send Anyway",value:"send"},{label:"Edit Prompt",value:"edit"}],onSelect:w=>{(typeof w=="object"&&w!==null?w.value:w)==="send"?f(t):x(t)},theme:S})))};var Ud=(()=>{let t=null,f=0;return x=>{let S=Date.now();if(t&&S-f<1e4)return t;let T=[],w=i=>{if(!(T.length>=2e3))try{let E=st.readdirSync(i);for(let m of E){if(T.length>=2e3)return;if(["node_modules",".git",".gemini","dist","build",".next",".cache","out"].includes(m))continue;let B=Et.join(i,m);st.statSync(B).isDirectory()?w(B):T.push({name:yt(m),relativePath:yt(Et.relative(process.cwd(),B))})}}catch{}};return w(x),t=T,f=S,T}})(),Cr="Ctrl + Enter",$d=t=>{if(t<=370)return"#00a564";if(t>=5e3)return"#ff0000";let f=[{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 x=0;x<f.length-1;x++){let S=f[x],T=f[x+1];if(t>=S.t&&t<=T.t){let w=(t-S.t)/(T.t-S.t);w=w*w*(3-2*w);let i=Math.round(S.r+(T.r-S.r)*w),E=Math.round(S.g+(T.g-S.g)*w),m=Math.round(S.b+(T.b-S.b)*w);return`#${((1<<24)+(i<<16)+(E<<8)+m).toString(16).slice(1)}`}}return"#ff0000"},Xd=e.memo(({sa:t,showTPMEstimate:f=!1})=>{let[x,S]=Q("green"),[T,w]=Q(0),i=Ve([]),E=Ve(370),m=Ve([]),B=Ve(t.lastChunkTime);return ze(()=>{B.current=t.lastChunkTime},[t.lastChunkTime]),ze(()=>{if(t.status!=="running"){m.current=[];return}if(t.wps>0){let M=m.current;M.push(t.wps),M.length>3&&M.shift(),w(Math.round(t.wps))}},[t.status,t.wps,t.lastChunkTime]),ze(()=>{if(t.status!=="running"){w(0);return}let M=setInterval(()=>{let $=B.current,v=$>0?Date.now()-$:0;if($>0&&v>1500)m.current=[],w(0);else if($>0&&v>600){m.current.length>0&&m.current.shift();let D=m.current;if(D.length>0){let k=D.reduce((O,L)=>O+L,0);w(Math.round(k/D.length))}else w(0)}else{let D=m.current;if(D.length>0){let k=D.reduce((O,L)=>O+L,0);w(Math.round(k/D.length))}else t.wps>0&&w(Math.round(t.wps))}},750);return()=>clearInterval(M)},[t.status]),ze(()=>{if(t.status!=="running"){i.current=[];return}let M=t.lastChunkTime;if(M>0){let D=i.current;(D.length===0||D[D.length-1]!==M)&&(D.push(M),D.length>10&&D.shift())}let $=()=>{if(!M){S("#00a564");return}let D=i.current,k=0;if(D.length>1){let z=0;for(let K=1;K<D.length;K++)z+=D[K]-D[K-1];k=z/(D.length-1)}let O=Date.now()-M,X=O>=2500,te=!X&&k>0?Math.min(O,k*3):O,le=Math.max(k,te),ge=X?.4:.2;E.current=E.current*(1-ge)+le*ge,S($d(E.current))};$();let v=setInterval($,100);return()=>clearInterval(v)},[t.status,t.lastChunkTime]),e.createElement(u,{justifyContent:"space-between",width:"100%"},e.createElement(s,{color:"white"}," \u2022 ",t.title," ",e.createElement(s,{color:"white",dimColor:!0},"(",t.id,")")),e.createElement(s,{color:"white"},e.createElement(s,{color:"white",dimColor:!0,bold:!0},t.currentTool||"Active"),e.createElement(s,{color:x}," \u25CF"),f&&e.createElement(s,{color:"white",dimColor:!0,bold:!0}," (",T," tps)")))});function _d({args:t=[]}){let f=Ve(1),[x,S]=Q(!1),[T,w]=Q(10),{stdout:i}=Ed(),[E,m]=Q(""),[B,M]=Q(0),[$,v]=Q(!1),[D,k]=Q("Flux"),[O,L]=Q(0),[X,te]=Q({columns:i?.columns||80,rows:i?.rows||24}),[le,ge]=Q(0),[z,K]=Q(!1),[se,ve]=Q(!1),[Se,ke]=Q(0),de=Ve(0),Ne=Ve(0),we=Ve(null),V=Ve(null),fe=Ve(0),[ee,G]=Q(0),j=()=>G(o=>o+1),ae=Ve([]),xe=Ve(null),Me=()=>{let o=ae.current;if(o.length>0&&V.current){let n=o.join("");o.length=0,V.current.text=yt(V.current.text+n),j()}},Te=()=>{if(Me(),V.current){let o=yt(V.current.text);V.current.role==="think"&&(o=o.replace(/^\r?\n+/,"").replace(/\r?\n+$/,""));let n={...V.current,text:o,isStreaming:!1};N(a=>{let h=[...a,n];return Y(h.length),h}),V.current=null}Os.current=0,Lr.current={totalWords:0,startTime:0,wps:0,chunks:[]}},Le=()=>{xe.current&&clearInterval(xe.current),ae.current=[],xe.current=setInterval(()=>{try{let o=ae.current;if(o.length>0&&V.current){let n=1;o.length>85?n=30:o.length>80?n=25:o.length>75?n=20:o.length>65?n=16:o.length>50?n=12:o.length>35?n=8:o.length>15?n=6:o.length>5?n=4:o.length>3&&(n=2);let a="";for(let h=0;h<n&&o.length>0;h++)a+=o.shift();V.current.text=yt(V.current.text+a),j()}}catch{}},80)},qe=async()=>{for(;ce.progressiveRendering&&ae.current.length>0;)await new Promise(o=>setTimeout(o,10))},Je=o=>{if(ce.progressiveRendering&&xe.current){let n=o.split(/(\s+)/).filter(Boolean);for(let a of n)ae.current.push(a)}else V.current?V.current.text=yt(V.current.text+o):V.current={id:"agent-"+Date.now(),role:"agent",text:yt(o),isStreaming:!0},j()};ze(()=>{let o=qo(),n=!["Terminal","Windows Terminal"].includes(o)||!!process.env.VSC_TERMINAL_URL,a=setTimeout(()=>{n&&!jo()&&ve(!0)},500),h=setInterval(()=>{jo()&&ve(!1)},1e3);f.current=Date.now();let c=setInterval(()=>{f.current&&(Date.now()-f.current||0)>3e4&&global.gc&&(async()=>{for(let d=0;d<1;d++)global.gc(),await new Promise(p=>setImmediate(p));f.current=Date.now()})()},3e3);return()=>{clearTimeout(a),clearInterval(h),clearInterval(c)}},[]),ze(()=>{(async()=>{try{let n=await Rr(),a=n?.systemSettings||{},h=a.CustomSubAgent,c=a.SubAgentModel;if(!h||!c||c==="Default")return;let b=process.env.SUBAGENT_MODEL?process.env.SUBAGENT_MODEL.trim():null,g=process.env.SUBAGENT_PROVIDER?process.env.SUBAGENT_PROVIDER.trim():null,d=["Google","DeepSeek","OpenRouter","NVIDIA","Mistral","Ollama","CrofAI","InferX","SenseNova","AIHubMix","Poolside","9router"],I=(Z=>{if(!Z)return null;let ne=Z.toLowerCase();return ne==="google"?"Google":ne==="deepseek"?"DeepSeek":ne==="openrouter"?"OpenRouter":ne==="nvidia"?"NVIDIA":ne==="mistral"?"Mistral":ne==="ollama"?"Ollama":ne==="crofai"||ne==="crof"?"CrofAI":ne==="inferx"?"InferX":ne==="sensenova"?"SenseNova":ne==="poolside"?"Poolside":ne==="9router"?"9router":ne==="aihubmix"||ne==="aihub"?"AIHubMix":null})(g);if(b&&!I){let Z=n.aiProvider||P||"Google";N(ne=>(Y(ne.length+1),[...ne,{id:"subagent-env-noprov-"+Date.now(),role:"system",text:`[SUBAGENT CONFIG] SUBAGENT_MODEL found in ENV but SUBAGENT_PROVIDER is missing/invalid. Active provider (${Z}) will be used.`,isMeta:!0}]))}if(c==="ENV"){b||N(Z=>(Y(Z.length+1),[...Z,{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.aiProvider||P||"Google",q=n.apiTier||Re||"Free",ue=n.quotas||Ie||{},J=new Set;(Io(_,q)||[]).forEach(Z=>{let ne=typeof Z=="string"?Z:Z.cmd||Z.name||Z.id||String(Z);ne&&J.add(ne)});for(let Z of d)try{if(await ln(Z)){let ot=ue?.providerTiers?.[Z]||"Free";(Io(Z,ot)||[]).forEach(_e=>{let nt=typeof _e=="string"?_e:_e.cmd||_e.name||_e.id||String(_e);nt&&J.add(nt)})}}catch{}let Pe=J.has(c);b?b!==c&&N(Z=>(Y(Z.length+1),[...Z,{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}])):Pe||N(Z=>(Y(Z.length+1),[...Z,{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 De=fn(()=>{let o={};for(let n=0;n<t.length;n++)if(t[n]==="--key"&&t[n+1]){let h=t[n+1];if(o.key=h,h.includes("@")){let c=h.split("@"),b=c[0],g=c[1].toLowerCase();if(["google","deepseek","openrouter","nvidia","mistral","ollama","crof","crofai","inferx","sensenova","aihubmix","aihub","poolside","pool","9router","9r"].includes(g)){let d="Google";g==="google"?d="Google":g==="deepseek"?d="DeepSeek":g==="openrouter"?d="OpenRouter":g==="nvidia"?d="NVIDIA":g==="mistral"?d="Mistral":g==="ollama"?d="Ollama":g==="crof"||g==="crofai"?d="CrofAI":g==="inferx"?d="InferX":g==="sensenova"?d="SenseNova":g==="poolside"||g==="pool"?d="Poolside":g==="9router"||g==="9r"?d="9router":(g==="aihubmix"||g==="aihub")&&(d="AIHubMix"),o.key=b,o.provider=d}}}for(let n=0;n<t.length;n++){let a=t[n];if(a==="--key"){n++;continue}if(a==="--model"&&t[n+1])o.model=t[n+1],n++;else if(a==="--memory"&&t[n+1])o.memory=t[n+1].toLowerCase(),n++;else if(a==="--resume"&&t[n+1])o.resume=t[n+1],n++;else if(a==="--package"&&t[n+1]){let h=t[n+1].toLowerCase();["npm","pnpm","yarn","bun"].includes(h)&&(o.package=h),n++}else if(a==="--auto-del"&&t[n+1]){let h=t[n+1].toLowerCase();["1d","7d","30d"].includes(h)&&(o.autoDel=h),n++}else if(a==="--auto-exec"&&t[n+1])o.autoExec=t[n+1].toLowerCase(),n++;else if(a==="--yolo"&&t[n+1])o.autoExec=t[n+1].toLowerCase(),n++;else if(a==="--external-access"&&t[n+1])o.externalAccess=t[n+1].toLowerCase(),n++;else if(a==="--mode"&&t[n+1]){let c=t[n+1].toLowerCase();if(["flux","flow","icu","computer","fluxcu"].includes(c)){let b="Flux";c==="flux"?b="Flux":c==="flow"?b="Flow":c==="icu"||c==="computer"?b="ICU":c==="fluxcu"&&(b="FluxCU"),o.mode=b}n++}else if(a==="--thinking"&&t[n+1]){let c=t[n+1].toLowerCase();if(["fast","low","medium","high","xhigh","standard"].includes(c)){let b="Medium";c==="fast"?b="Fast":c==="low"?b="Low":c==="standard"?b="Standard":c==="medium"?b="Medium":c==="high"?b="High":c==="xhigh"&&(b="xHigh"),o.thinking=b}n++}else if(a==="--provider"&&t[n+1]){let h=t[n+1].toLowerCase();if(["google","deepseek","openrouter","nvidia","mistral","ollama","crof","crofai","inferx","sensenova","aihubmix","aihub","poolside","pool","9router","9r"].includes(h)){let c="Google";h==="google"?c="Google":h==="deepseek"?c="DeepSeek":h==="openrouter"?c="OpenRouter":h==="nvidia"?c="NVIDIA":h==="mistral"?c="Mistral":h==="ollama"?c="Ollama":h==="crof"||h==="crofai"?c="CrofAI":h==="inferx"?c="InferX":h==="sensenova"?c="SenseNova":h==="poolside"||h==="pool"?c="Poolside":h==="9router"||h==="9r"?c="9router":(h==="aihubmix"||h==="aihub")&&(c="AIHubMix"),o.provider=c}n++}else(a==="--resume"||a==="-r")&&t[n+1]?(o.resume=t[n+1],n++):a==="--playground"?o.playground=!0:(a==="--original-cwd"||a==="--orginal-cwd")&&t[n+1]&&(o.originalCwd=t[n+1],n++)}return o},[t]),oe=async(o=!1,n=null)=>{let a=n||ce;o&&N(h=>(Y(h.length+1),[...h,{id:"check-"+Date.now(),role:"system",text:"\u2726 Checking for updates...",isMeta:!0}]));try{let c=await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json(),b=c["dist-tags"]?.latest,g=c["dist-tags"]?.stable;if(b&&Qo(b),b&&b!==oo){let d=b===g?`v${b}`:`v${b}`;!o&&a.autoUpdate?W("update"):N(p=>{let I=[...p],_=o?I.length:Math.min(I.length,3);return I.splice(_,0,{id:"update-"+Date.now(),role:"system",text:`A new version (${d}) is here.
51
+ `)?x+"...":x}function bd(t){if(!t)return"N/A";let f=new Date(t);if(isNaN(f.getTime()))return"N/A";let x=i=>String(i).padStart(2,"0"),S=x(f.getHours()),T=x(f.getMinutes()),w=x(f.getSeconds());return`${S}:${T}:${w}`}import yd from"puppeteer";import{exec as Sd}from"child_process";import{promisify as Cd}from"util";import sl from"fs";var il=Cd(Sd),ll=()=>{try{let t=Oi();if(t.executablePath&&sl.existsSync(t.executablePath))return!0;let f=yd.executablePath();if(f&&sl.existsSync(f))return!0}catch{return!1}return!1},al=async t=>{t&&t("\u{1F4E5} Downloading Chromium engine (chrome@148)...");try{try{await il("pnpm exec puppeteer browsers install chrome@148")}catch{await il("npx -y puppeteer browsers install chrome@148")}return await new Promise(f=>setTimeout(f,1e3)),{success:!0}}catch(f){return console.error("[SETUP ERROR]",f),{success:!1,error:f.message}}};import dl,{useState as cl,useEffect as ul}from"react";import{Text as ml}from"ink";var Md=({text:t,baseColor:f="grey",glintColor:x="gray",speed:S=200,glintWidth:T=6,typeSpeed:w=30,...i})=>{let[E,m]=cl(-T),[B,M]=cl(t);return ul(()=>{let $=setInterval(()=>{m(v=>v>B.length+T?-T-40:v+1)},S);return()=>clearInterval($)},[B.length,S,T]),ul(()=>{if(t&&(t.includes("Trying to reach")&&B&&B.includes("Trying to reach")||t.includes("Error Occurred")&&B&&B.includes("Error Occurred"))){M(t);return}if(B===t)return;let $=setTimeout(()=>{let v=0,D=Math.min(B.length,t.length);for(;v<D&&B[v]===t[v];)v++;B.length>v?M(k=>k.slice(0,-1)):B.length<t.length&&M(t.slice(0,B.length+1))},w);return()=>clearTimeout($)},[t,B,w]),dl.createElement(ml,null,B.split("").map(($,v)=>{let k=Math.abs(v-E)<=T/2?x:f;return dl.createElement(ml,{key:v,color:k,...i},$)}))},_n=Md;var Hn=t=>{let f=String(t);return f.startsWith("999")&&f.endsWith("9")},hn=t=>t==null||t===0||Hn(t)?"":String(t),qo=()=>{let t=(process.env.TERM_PROGRAM||"").toLowerCase();if(process.env.WT_SESSION)return"Windows Terminal";let f=x=>{let S=x.toLowerCase();for(let[T,w]of Object.entries(process.env))if(!["PATH","PWD","CWD","PS1","LS_COLORS","PROMPT"].includes(T)&&String(w).toLowerCase().includes(S))return!0;return!1};return t==="cursor"||process.env.CURSOR_SETTINGS_DIR||f("cursor")?"Cursor":t==="windsurf"||f("windsurf")?"Windsurf":f("antigravity")?"Antigravity":t==="trae"||f("trae")?"Trae":t==="codium"||f("codium")||f("vscode-oss")?"VSCodium":f("positron")?"Positron":t==="vscode-insiders"||f("insiders")?"VS Code Insiders":t==="vscode"||process.env.VSCODE_GIT_IPC_HANDLE||f("vscode")?"VS Code":process.env.INTELLIJ_TERMINAL_COMMAND_BLOCKS||f("intellij")?"JetBrains":"Terminal"},Ad=t=>{switch(t){case"VS Code":return"Code";case"VS Code Insiders":return"Code - Insiders";case"Antigravity":return"Antigravity IDE";default:return t}},gl={Flux:"Workspace",Flow:"Studio",ICU:"Computer Use",FluxCU:"Omni"},Bs=t=>{if(!t)return"Workspace";let f=Object.keys(gl).find(x=>x.toLowerCase()===t.toLowerCase());return f?gl[f]:t},fl=t=>{let f=Ad(t),x=Ds.homedir();if(process.platform==="win32"){let S=process.env.APPDATA;return S?St.join(S,f,"User","keybindings.json"):null}else return process.platform==="darwin"?St.join(x,"Library","Application Support",f,"User","keybindings.json"):St.join(x,".config",f,"User","keybindings.json")},hl=t=>{let f=t.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,"$1");return JSON.parse(f)},Ld=t=>Array.isArray(t)?t.some(f=>f&&typeof f.key=="string"&&f.key.toLowerCase().replace(/\s+/g,"")==="shift+enter"&&f.command==="workbench.action.terminal.sendSequence"&&f.args&&f.args.text==="\x1B[13;2u"&&typeof f.when=="string"&&f.when.includes("terminalFocus")):!1,pl=t=>{let f=t==="VS Code",x=[];return f?(x.push({label:"Install Manually (VSIX)",url:"https://github.com/KushalRoyChowdhury/fluxflow-cli/releases"}),x.push({label:"Install from VS Code Marketplace",url:"https://marketplace.visualstudio.com/items?itemName=fluxflow-cli.fluxflow-cli-companion"})):x.push({label:`Download for ${t} (GitHub)`,url:"https://github.com/KushalRoyChowdhury/fluxflow-cli/releases"}),x.push({label:"Continue to CLI only",action:"dismiss"}),x},Od=({width:t,height:f,selectedIndex:x,aiProvider:S,theme:T="Dark"})=>{let w=qo(),i=pl(w);return e.createElement(u,{flexDirection:"column",alignItems:"center",justifyContent:"center",width:t,height:f},e.createElement(u,{marginBottom:1,width:Math.min(80,t-4),justifyContent:"flex-start"},e.createElement(s,null,lr(oo,S,T))),e.createElement(u,{flexDirection:"column",borderStyle:"double",borderColor:"grey",paddingX:3,paddingY:1,width:Math.min(80,t-4)},e.createElement(s,{bold:!0,color:"white",textAlign:"center"},"\u{1F680} UPGRADE YOUR WORKFLOW"),e.createElement(u,{marginY:1,flexDirection:"column",alignItems:"left"},e.createElement(s,null,"You're in ",e.createElement(s,{bold:!0,color:"cyan"},w),", but the ",e.createElement(s,{bold:!0,color:"white"},"FluxFlow-CLI Companion")," is not installed."),e.createElement(u,{flexDirection:"column",marginY:1},e.createElement(s,{color:"gray"}," \u2705 Real-time IDE context & Error Resolution"),e.createElement(s,{color:"gray"}," \u2705 Auto-open files created by agent"),e.createElement(s,{color:"gray"}," \u2705 Native DIFFing for AI edits"),e.createElement(s,{color:"gray"}," \u2705 Direct IDE context sharing"),e.createElement(s,{color:"gray"}," \u2705 Surgical Diagnostic Sync"),e.createElement(s,{color:"gray"}," \u2705 Native Right-Click \u276F Chat integration"),e.createElement(s,{color:"gray"}," \u2705 Live Status in IDE"),e.createElement(s,{color:"gray"}," \u2705 Clickable terminal-to-code links"))),e.createElement(u,{flexDirection:"column",marginTop:1},i.map((E,m)=>e.createElement(u,{key:m},e.createElement(s,{color:x===m?"yellow":"white",bold:x===m},x===m?" \u276F ":" ",E.label)))),e.createElement(u,{marginTop:1,alignItems:"center",justifyContent:"center"},e.createElement(s,{dimColor:!0,italic:!0},"(Use arrows to navigate, Enter to select)"))))},Es=Date.now(),xl="https://fluxflow-cli.onrender.com/changelog",vs="https://fluxflow-cli.onrender.com/",Pd=St.join(St.dirname(kd(import.meta.url)),"../package.json"),wl=JSON.parse(st.readFileSync(Pd,"utf8")),oo=wl.version,Nd=wl.date||"2026-05-20";var Fd=({data:t,onResolve:f,onEdit:x,theme:S="Dark"})=>{let T=je(S);return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:T.borderMuted,padding:0,width:"100%"},e.createElement(u,{paddingX:1},e.createElement(s,{color:T.text,bold:!0,underline:!0},t.startsWith("/btw")?"QUESTION":"STEERING HINT"," RESOLUTION")),e.createElement(u,{paddingX:1,marginTop:1},e.createElement(s,{color:T.text},"The agent already finished the task before your ",t.startsWith("/btw")?"question":"hint"," was consumed.")),e.createElement(u,{marginTop:1,backgroundColor:T.cardBg||T.codeBg||"#222",paddingX:2,width:"100%"},e.createElement(s,{italic:!0,color:T.textMuted},'"',t.replace("/btw","").trim(),'"')),e.createElement(u,{paddingX:1,marginTop:1},e.createElement(s,{color:T.textDim||T.textMuted},"How would you like to proceed?")),e.createElement(u,{marginTop:0},e.createElement(gt,{title:"Select Action",items:[{label:"Send Anyway",value:"send"},{label:"Edit Prompt",value:"edit"}],onSelect:w=>{(typeof w=="object"&&w!==null?w.value:w)==="send"?f(t):x(t)},theme:S})))};var Ud=(()=>{let t=null,f=0;return x=>{let S=Date.now();if(t&&S-f<1e4)return t;let T=[],w=i=>{if(!(T.length>=2e3))try{let E=st.readdirSync(i);for(let m of E){if(T.length>=2e3)return;if(["node_modules",".git",".gemini","dist","build",".next",".cache","out"].includes(m))continue;let B=St.join(i,m);st.statSync(B).isDirectory()?w(B):T.push({name:yt(m),relativePath:yt(St.relative(process.cwd(),B))})}}catch{}};return w(x),t=T,f=S,T}})(),Cr="Ctrl + Enter",$d=t=>{if(t<=370)return"#00a564";if(t>=5e3)return"#ff0000";let f=[{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 x=0;x<f.length-1;x++){let S=f[x],T=f[x+1];if(t>=S.t&&t<=T.t){let w=(t-S.t)/(T.t-S.t);w=w*w*(3-2*w);let i=Math.round(S.r+(T.r-S.r)*w),E=Math.round(S.g+(T.g-S.g)*w),m=Math.round(S.b+(T.b-S.b)*w);return`#${((1<<24)+(i<<16)+(E<<8)+m).toString(16).slice(1)}`}}return"#ff0000"},Xd=e.memo(({sa:t,showTPMEstimate:f=!1})=>{let[x,S]=Q("green"),[T,w]=Q(0),i=Ve([]),E=Ve(370),m=Ve([]),B=Ve(t.lastChunkTime);return ze(()=>{B.current=t.lastChunkTime},[t.lastChunkTime]),ze(()=>{if(t.status!=="running"){m.current=[];return}if(t.wps>0){let M=m.current;M.push(t.wps),M.length>3&&M.shift(),w(Math.round(t.wps))}},[t.status,t.wps,t.lastChunkTime]),ze(()=>{if(t.status!=="running"){w(0);return}let M=setInterval(()=>{let $=B.current,v=$>0?Date.now()-$:0;if($>0&&v>1500)m.current=[],w(0);else if($>0&&v>600){m.current.length>0&&m.current.shift();let D=m.current;if(D.length>0){let k=D.reduce((O,L)=>O+L,0);w(Math.round(k/D.length))}else w(0)}else{let D=m.current;if(D.length>0){let k=D.reduce((O,L)=>O+L,0);w(Math.round(k/D.length))}else t.wps>0&&w(Math.round(t.wps))}},750);return()=>clearInterval(M)},[t.status]),ze(()=>{if(t.status!=="running"){i.current=[];return}let M=t.lastChunkTime;if(M>0){let D=i.current;(D.length===0||D[D.length-1]!==M)&&(D.push(M),D.length>10&&D.shift())}let $=()=>{if(!M){S("#00a564");return}let D=i.current,k=0;if(D.length>1){let z=0;for(let K=1;K<D.length;K++)z+=D[K]-D[K-1];k=z/(D.length-1)}let O=Date.now()-M,X=O>=2500,te=!X&&k>0?Math.min(O,k*3):O,le=Math.max(k,te),ge=X?.4:.2;E.current=E.current*(1-ge)+le*ge,S($d(E.current))};$();let v=setInterval($,100);return()=>clearInterval(v)},[t.status,t.lastChunkTime]),e.createElement(u,{justifyContent:"space-between",width:"100%"},e.createElement(s,{color:"white"}," \u2022 ",t.title," ",e.createElement(s,{color:"white",dimColor:!0},"(",t.id,")")),e.createElement(s,{color:"white"},e.createElement(s,{color:"white",dimColor:!0,bold:!0},t.currentTool||"Active"),e.createElement(s,{color:x}," \u25CF"),f&&e.createElement(s,{color:"white",dimColor:!0,bold:!0}," (",T," tps)")))});function _d({args:t=[]}){let f=Ve(1),[x,S]=Q(!1),[T,w]=Q(10),{stdout:i}=Ed(),[E,m]=Q(""),[B,M]=Q(0),[$,v]=Q(!1),[D,k]=Q("Flux"),[O,L]=Q(0),[X,te]=Q({columns:i?.columns||80,rows:i?.rows||24}),[le,ge]=Q(0),[z,K]=Q(!1),[se,ve]=Q(!1),[Se,ke]=Q(0),de=Ve(0),Ne=Ve(0),we=Ve(null),V=Ve(null),fe=Ve(0),[ee,G]=Q(0),j=()=>G(o=>o+1),ae=Ve([]),xe=Ve(null),Me=()=>{let o=ae.current;if(o.length>0&&V.current){let n=o.join("");o.length=0,V.current.text=yt(V.current.text+n),j()}},Te=()=>{if(Me(),V.current){let o=yt(V.current.text);V.current.role==="think"&&(o=o.replace(/^\r?\n+/,"").replace(/\r?\n+$/,""));let n={...V.current,text:o,isStreaming:!1};N(a=>{let h=[...a,n];return Y(h.length),h}),V.current=null}Os.current=0,Lr.current={totalWords:0,startTime:0,wps:0,chunks:[]}},Le=()=>{xe.current&&clearInterval(xe.current),ae.current=[],xe.current=setInterval(()=>{try{let o=ae.current;if(o.length>0&&V.current){let n=1;o.length>85?n=30:o.length>80?n=25:o.length>75?n=20:o.length>65?n=16:o.length>50?n=12:o.length>35?n=8:o.length>15?n=6:o.length>5?n=4:o.length>3&&(n=2);let a="";for(let h=0;h<n&&o.length>0;h++)a+=o.shift();V.current.text=yt(V.current.text+a),j()}}catch{}},80)},qe=async()=>{for(;ce.progressiveRendering&&ae.current.length>0;)await new Promise(o=>setTimeout(o,10))},Je=o=>{if(ce.progressiveRendering&&xe.current){let n=o.split(/(\s+)/).filter(Boolean);for(let a of n)ae.current.push(a)}else V.current?V.current.text=yt(V.current.text+o):V.current={id:"agent-"+Date.now(),role:"agent",text:yt(o),isStreaming:!0},j()};ze(()=>{let o=qo(),n=!["Terminal","Windows Terminal"].includes(o)||!!process.env.VSC_TERMINAL_URL,a=setTimeout(()=>{n&&!jo()&&ve(!0)},500),h=setInterval(()=>{jo()&&ve(!1)},1e3);f.current=Date.now();let c=setInterval(()=>{f.current&&(Date.now()-f.current||0)>3e4&&global.gc&&(async()=>{for(let d=0;d<1;d++)global.gc(),await new Promise(p=>setImmediate(p));f.current=Date.now()})()},3e3);return()=>{clearTimeout(a),clearInterval(h),clearInterval(c)}},[]),ze(()=>{(async()=>{try{let n=await Rr(),a=n?.systemSettings||{},h=a.CustomSubAgent,c=a.SubAgentModel;if(!h||!c||c==="Default")return;let b=process.env.SUBAGENT_MODEL?process.env.SUBAGENT_MODEL.trim():null,g=process.env.SUBAGENT_PROVIDER?process.env.SUBAGENT_PROVIDER.trim():null,d=["Google","DeepSeek","OpenRouter","NVIDIA","Mistral","Ollama","CrofAI","InferX","SenseNova","AIHubMix","Poolside","9router"],I=(Z=>{if(!Z)return null;let ne=Z.toLowerCase();return ne==="google"?"Google":ne==="deepseek"?"DeepSeek":ne==="openrouter"?"OpenRouter":ne==="nvidia"?"NVIDIA":ne==="mistral"?"Mistral":ne==="ollama"?"Ollama":ne==="crofai"||ne==="crof"?"CrofAI":ne==="inferx"?"InferX":ne==="sensenova"?"SenseNova":ne==="poolside"?"Poolside":ne==="9router"?"9router":ne==="aihubmix"||ne==="aihub"?"AIHubMix":null})(g);if(b&&!I){let Z=n.aiProvider||P||"Google";N(ne=>(Y(ne.length+1),[...ne,{id:"subagent-env-noprov-"+Date.now(),role:"system",text:`[SUBAGENT CONFIG] SUBAGENT_MODEL found in ENV but SUBAGENT_PROVIDER is missing/invalid. Active provider (${Z}) will be used.`,isMeta:!0}]))}if(c==="ENV"){b||N(Z=>(Y(Z.length+1),[...Z,{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.aiProvider||P||"Google",q=n.apiTier||Re||"Free",ue=n.quotas||Ie||{},J=new Set;(Io(_,q)||[]).forEach(Z=>{let ne=typeof Z=="string"?Z:Z.cmd||Z.name||Z.id||String(Z);ne&&J.add(ne)});for(let Z of d)try{if(await ln(Z)){let ot=ue?.providerTiers?.[Z]||"Free";(Io(Z,ot)||[]).forEach(_e=>{let nt=typeof _e=="string"?_e:_e.cmd||_e.name||_e.id||String(_e);nt&&J.add(nt)})}}catch{}let Pe=J.has(c);b?b!==c&&N(Z=>(Y(Z.length+1),[...Z,{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}])):Pe||N(Z=>(Y(Z.length+1),[...Z,{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 De=fn(()=>{let o={};for(let n=0;n<t.length;n++)if(t[n]==="--key"&&t[n+1]){let h=t[n+1];if(o.key=h,h.includes("@")){let c=h.split("@"),b=c[0],g=c[1].toLowerCase();if(["google","deepseek","openrouter","nvidia","mistral","ollama","crof","crofai","inferx","sensenova","aihubmix","aihub","poolside","pool","9router","9r"].includes(g)){let d="Google";g==="google"?d="Google":g==="deepseek"?d="DeepSeek":g==="openrouter"?d="OpenRouter":g==="nvidia"?d="NVIDIA":g==="mistral"?d="Mistral":g==="ollama"?d="Ollama":g==="crof"||g==="crofai"?d="CrofAI":g==="inferx"?d="InferX":g==="sensenova"?d="SenseNova":g==="poolside"||g==="pool"?d="Poolside":g==="9router"||g==="9r"?d="9router":(g==="aihubmix"||g==="aihub")&&(d="AIHubMix"),o.key=b,o.provider=d}}}for(let n=0;n<t.length;n++){let a=t[n];if(a==="--key"){n++;continue}if(a==="--model"&&t[n+1])o.model=t[n+1],n++;else if(a==="--memory"&&t[n+1])o.memory=t[n+1].toLowerCase(),n++;else if(a==="--resume"&&t[n+1])o.resume=t[n+1],n++;else if(a==="--package"&&t[n+1]){let h=t[n+1].toLowerCase();["npm","pnpm","yarn","bun"].includes(h)&&(o.package=h),n++}else if(a==="--auto-del"&&t[n+1]){let h=t[n+1].toLowerCase();["1d","7d","30d"].includes(h)&&(o.autoDel=h),n++}else if(a==="--auto-exec"&&t[n+1])o.autoExec=t[n+1].toLowerCase(),n++;else if(a==="--yolo"&&t[n+1])o.autoExec=t[n+1].toLowerCase(),n++;else if(a==="--external-access"&&t[n+1])o.externalAccess=t[n+1].toLowerCase(),n++;else if(a==="--mode"&&t[n+1]){let c=t[n+1].toLowerCase();if(["flux","flow","icu","computer","fluxcu"].includes(c)){let b="Flux";c==="flux"?b="Flux":c==="flow"?b="Flow":c==="icu"||c==="computer"?b="ICU":c==="fluxcu"&&(b="FluxCU"),o.mode=b}n++}else if(a==="--thinking"&&t[n+1]){let c=t[n+1].toLowerCase();if(["fast","low","medium","high","xhigh","standard"].includes(c)){let b="Medium";c==="fast"?b="Fast":c==="low"?b="Low":c==="standard"?b="Standard":c==="medium"?b="Medium":c==="high"?b="High":c==="xhigh"&&(b="xHigh"),o.thinking=b}n++}else if(a==="--provider"&&t[n+1]){let h=t[n+1].toLowerCase();if(["google","deepseek","openrouter","nvidia","mistral","ollama","crof","crofai","inferx","sensenova","aihubmix","aihub","poolside","pool","9router","9r"].includes(h)){let c="Google";h==="google"?c="Google":h==="deepseek"?c="DeepSeek":h==="openrouter"?c="OpenRouter":h==="nvidia"?c="NVIDIA":h==="mistral"?c="Mistral":h==="ollama"?c="Ollama":h==="crof"||h==="crofai"?c="CrofAI":h==="inferx"?c="InferX":h==="sensenova"?c="SenseNova":h==="poolside"||h==="pool"?c="Poolside":h==="9router"||h==="9r"?c="9router":(h==="aihubmix"||h==="aihub")&&(c="AIHubMix"),o.provider=c}n++}else(a==="--resume"||a==="-r")&&t[n+1]?(o.resume=t[n+1],n++):a==="--playground"?o.playground=!0:(a==="--original-cwd"||a==="--orginal-cwd")&&t[n+1]&&(o.originalCwd=t[n+1],n++)}return o},[t]),oe=async(o=!1,n=null)=>{let a=n||ce;o&&N(h=>(Y(h.length+1),[...h,{id:"check-"+Date.now(),role:"system",text:"\u2726 Checking for updates...",isMeta:!0}]));try{let c=await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json(),b=c["dist-tags"]?.latest,g=c["dist-tags"]?.stable;if(b&&Qo(b),b&&b!==oo){let d=b===g?`v${b}`:`v${b}`;!o&&a.autoUpdate?W("update"):N(p=>{let I=[...p],_=o?I.length:Math.min(I.length,3);return I.splice(_,0,{id:"update-"+Date.now(),role:"system",text:`A new version (${d}) is here.
52
52
 
53
53
  \u2022 Type \`/update latest\` to apply the update.
54
54
  \u2022 Type \`/changelog\` to view the release notes.`,isUpdateNotification:!0,isMeta:!0}),I})}else o&&N(d=>{Y(d.length+1);let p=b&&b===g?`${oo}`:oo;return[...d,{id:"uptodate-"+Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Already up to date (${p}).
55
55
  \u2800`,isMeta:!0}]})}catch(h){o&&N(c=>(Y(c.length+1),[...c,{id:"check-err-"+Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Failed to check for updates: ${h.message}.
56
- \u2800`,isMeta:!0}]))}};ze(()=>{let o=()=>{i.write("\x1B[2J\x1B[3J\x1B[H"),te({columns:i.columns,rows:i.rows})};return i.on("resize",o),()=>{i.off("resize",o)}},[i]);let[he,Fe]=Q("Medium"),[P,vt]=Q("Google"),[dt,Nt]=Q(0),[Vt,Qo]=Q(null),[Ht,Mr]=Q(!1),[re,ie]=Q(ro("Google","Free")||"gemma-4-31b-it"),[y,F]=Q(!1),[Ce,Xe]=Q(wi("gemma_janitor_fallback_google")||"gemma-4-26b-a4b-it"),[it,et]=Q(!0),[Ue,jt]=Q(!0),We=Ve(0),[wt,Kt]=Q(null),[Br,zo]=Q(""),Er=async o=>{let n=fl(o);if(n)try{await st.ensureDir(Et.dirname(n));let a=[];if(st.existsSync(n)){let h=st.readFileSync(n,"utf8").trim();if(h)try{a=hl(h)}catch{a=[]}}Array.isArray(a)||(a=[]),a.push({key:"shift+enter",command:"workbench.action.terminal.sendSequence",args:{text:"\x1B[13;2u"},when:"terminalFocus"}),st.writeFileSync(n,JSON.stringify(a,null,4),"utf8"),Cr="Shift + Enter",N(h=>(Y(h.length+1),[...h,{id:"kb-success-"+Date.now(),role:"system",text:`\u2726 Successfully configured Shift+Enter in your ${o} keybindings!
56
+ \u2800`,isMeta:!0}]))}};ze(()=>{let o=()=>{i.write("\x1B[2J\x1B[3J\x1B[H"),te({columns:i.columns,rows:i.rows})};return i.on("resize",o),()=>{i.off("resize",o)}},[i]);let[he,Fe]=Q("Medium"),[P,vt]=Q("Google"),[dt,Nt]=Q(0),[Vt,Qo]=Q(null),[Ht,Mr]=Q(!1),[re,ie]=Q(ro("Google","Free")||"gemma-4-31b-it"),[y,F]=Q(!1),[Ce,Xe]=Q(wi("gemma_janitor_fallback_google")||"gemma-4-26b-a4b-it"),[it,et]=Q(!0),[Ue,jt]=Q(!0),We=Ve(0),[wt,Kt]=Q(null),[Br,zo]=Q(""),Er=async o=>{let n=fl(o);if(n)try{await st.ensureDir(St.dirname(n));let a=[];if(st.existsSync(n)){let h=st.readFileSync(n,"utf8").trim();if(h)try{a=hl(h)}catch{a=[]}}Array.isArray(a)||(a=[]),a.push({key:"shift+enter",command:"workbench.action.terminal.sendSequence",args:{text:"\x1B[13;2u"},when:"terminalFocus"}),st.writeFileSync(n,JSON.stringify(a,null,4),"utf8"),Cr="Shift + Enter",N(h=>(Y(h.length+1),[...h,{id:"kb-success-"+Date.now(),role:"system",text:`\u2726 Successfully configured Shift+Enter in your ${o} keybindings!
57
57
  `,isMeta:!0}]))}catch(a){N(h=>(Y(h.length+1),[...h,{id:"kb-error-"+Date.now(),role:"system",text:`\u2726 Failed to update keybindings: ${a.message}.
58
58
  \u2800`,isMeta:!0}]))}},[lt,W]=Q("chat"),[Re,$o]=Q("Free"),[Ie,$t]=Q({limitMode:"Daily",agentLimit:99999999,tokenLimit:99999999999999,backgroundLimit:999999,searchLimit:100,customModelId:"",customLimit:0,providerBudgets:{}}),[bo,qt]=Q(null),[yo,Tl]=Q("chat"),[Jo,vr]=Q("settings"),[Zo,bl]=Q([]),[Hd,yl]=Q(0),[ks,Gn]=Q(0),[Dr,Is]=Q({}),[kr,Ir]=Q({}),[Wn,go]=Q(0),[ce,Dt]=Q({memory:!0,theme:"Dark",compression:0,autoExec:!1,autoDeleteHistory:"7d",autoUpdate:!1,updateManager:"npm",customUpdateCommand:""}),l=fn(()=>je(ce.theme),[ce.theme]),[xn,As]=Q({name:null,nickname:null,instructions:null}),[So,Yn]=Q({keyType:"Default",quality:"Low-High",apiKey:""}),[fo,Xo]=Q({tokens:0}),[Ls,Ar]=Q(0),Os=Ve(0),Lr=Ve({totalWords:0,startTime:0,wps:0,chunks:[]}),[Ps,Ns]=Q(0),[Fs,Sl]=Q(0),[Qt,Us]=Q(0),[Cl,pn]=Q(0),wn=Ve(0),[Vn,$s]=Q(0),[Ro,Xs]=Q(0),[Gd,Ml]=Q(0),[Wd,Bl]=Q(0),[Yd,El]=Q(0),[jn,vl]=Q(0),[Kn,Dl]=Q(0),[qn,kl]=Q(0),[_s,Il]=Q(0),[Tn,Or]=Q(null),[Qn,Pr]=Q(null),[Nr,Hs]=Q(null),[en,bn]=Q("daily"),[Al,Zt]=Q(0),[yn,Sn]=Q(""),Cn="flow-playground",[tt,zn]=Q(t.includes("--playground")?Cn:ss());ze(()=>{if(Wo.current)return;let o=Qt-wn.current;pn(o),tt&&Li(tt,o,fo.tokens).catch(()=>{})},[Qt,tt,fo.tokens]),ze(()=>{lt==="apiTier"&&(async()=>{let n=await sr();Or(n);let a=await ir();Pr(a);let h=await es(Ie.resetDay||1);Hs(h)})()},[lt,Ie.resetDay]);let[Rt,Gs]=Q(null),[tn,on]=Q(""),[Mn,Ws]=Q(!1),[Fr,Ll]=Q([]),[Vd,jd]=Q(0),Ys=Ve(!0),Vs=Ve(!0),Ur=Ve(P),$r=Ve(!1),Xr=Ve(!0);ze(()=>{y&&(F(!1),N(o=>(Y(o.length+1),[...o,{id:Date.now(),role:"system",text:`\u2726 Wildcard Tooling:
59
59
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Status: Disabled.
@@ -65,13 +65,13 @@ import{A as Ii,B as Ai,C as Li,D as cr,E as Oi,F as Pi,G as Ni,H as Fi,I as is,J
65
65
  `)}else if(n.backspace||n.delete)an?Wt("\x7F"):(Wt("\b \b"),on(a=>a.slice(0,-1)));else if(n.upArrow)Wt(n.shift?"\x1B[1;2A":"\x1B[A");else if(n.downArrow)Wt(n.shift?"\x1B[1;2B":"\x1B[B");else if(n.rightArrow)Wt(n.shift?"\x1B[1;2C":"\x1B[C");else if(n.leftArrow)Wt(n.shift?"\x1B[1;2D":"\x1B[D");else if(n.escape)Wt("\x1B");else if(n.ctrl&&o){let a=o.toLowerCase().charCodeAt(0);a>=97&&a<=122?Wt(String.fromCharCode(a-96)):Wt(o)}else o&&(Wt(o),an||on(a=>a+o));return}if(lt==="providerBudgetSelect"){let a=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","CrofAI","InferX","SenseNova","AIHubMix","Poolside"];if(n.upArrow){Gn(h=>(h-1+a.length)%a.length);return}else if(n.downArrow){Gn(h=>(h+1)%a.length);return}else if(o===" "){let h=a[ks];Is(c=>({...c,[h]:!c[h]}));return}else if(n.return){let h=a.filter(b=>Dr[b]);if(h.length===0)return;let c={...Ie,providerBudgets:{...Ie.providerBudgets||{},__useProvider:!0}};$t(c),bl(h),yl(0),Gn(0),W("providerBudgetFlow");return}else if(n.escape){W("budgetTypeSelect");return}return}if(lt==="providerBudgetFlow"){let a=Zo.length,h=a*2+1;if(n.upArrow){go(c=>c===h-1?Math.max(0,(a-1)*2):c>=2?c-2:c);return}else if(n.downArrow){go(c=>c===h-1?c:c+2<h-1?c+2:h-1);return}else if(n.leftArrow){go(c=>c===h-1?c:c%2===1?c-1:c);return}else if(n.rightArrow||n.tab){go(c=>c===h-1?c:c%2===0||c+1<h?c+1:c);return}else if(n.return){if(Wn===h-1){let c=Ie.providerBudgets||{},b={__useProvider:!0};for(let p of Zo){let I=kr[p]||{};b[p]={agentLimit:9999999999,tokenLimit:parseInt(I.tokenLimit,10)||0,monthlyTokenLimit:parseInt(I.monthlyTokenLimit,10)||0}}let g={...Ie,providerBudgets:b};$t(g),kt({apiTier:Re,quotas:g}),W(yo==="settings"?"resetMode":"budgetResetMode")}else go(c=>Math.min(h-1,c+1));return}else if(n.escape){W("providerBudgetSelect");return}return}if(n.escape){if(oi){if(ni(!1),ft.length>0){let a=ft[ft.length-1];a&&(si.current=a.id)}return}if(He.length>0&&lt==="chat"){K(!0);return}if(x){S(!1);return}if(rn||Rt||Co||_o)Vr.current=!0,$i(),Di(),Co&&(Co.resolve("deny"),nn(null)),_o&&(_o.resolve(null),Hr(null)),_l(!1),Zs&&clearTimeout(Zs);else if(lt==="revert")W("chat"),Dn(0);else if(lt!=="chat"&&lt!=="settings")W("chat");else{if(!wt&&dt===1){Nt(0),zo("");return}Dn(a=>{let h=a+1;return h===1?(Go.current&&clearTimeout(Go.current),Go.current=setTimeout(()=>Dn(0),2e3)):h===2&&(Go.current&&clearTimeout(Go.current),Dn(0),E.length>0?m(""):Ln.getChatHistory(tt).then(c=>{c.length>0?(ei(c.reverse()),W("revert")):N(b=>(Y(b.length+1),[...b,{id:"revert-empty-"+Date.now(),role:"system",text:`\u2726 Nothing to revert to.
66
66
  \u2800`,isMeta:!0}]))})),h})}}if(He.length>0&&lt==="chat"){if(n.upArrow){ge(a=>{let h=a>0?a-1:He.length-1,c=0;for(;h!==a&&c<He.length;){let b=He[h],g=b?.cmd||b||"";if(typeof g=="string"&&g.trimStart().startsWith("---"))h=h>0?h-1:He.length-1,c++;else break}return h});return}if(n.downArrow){ge(a=>{let h=a<He.length-1?a+1:0,c=0;for(;h!==a&&c<He.length;){let b=He[h],g=b?.cmd||b||"";if(typeof g=="string"&&g.trimStart().startsWith("---"))h=h<He.length-1?h+1:0,c++;else break}return h});return}if(n.return)return}if(n.tab&&lt==="chat"){if(He.length>0){let a=He[le]||He[0],h=E.split(" ");if(h.length===1)m(a.cmd+" ");else{let c=h.slice(0,-1);m(c.join(" ")+" "+a.cmd+" ")}ge(0),M(c=>c+1);return}else if(E.trim()===""){let a=Date.now();if(a-fe.current<500)return;fe.current=a;let h=["Flux","Flow","ICU","FluxCU"],c=(h.indexOf(D)+1)%h.length,b=h[c>=0?c:0];k(b),b==="Flow"?Fe("Fast"):(b==="Flux"||b==="ICU"||b==="FluxCU")&&Fe("High"),N(g=>[...g,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${Bs(b)}
67
67
  \u2800`,isMeta:!0}]);return}}if(n.ctrl&&o==="c"&&lt!=="exit"){if(E.length>0){m("");return}if(n.shift){W("exit"),S(!1);return}x?(W("exit"),S(!1)):S(!0)}n.return&&(n.shift||n.ctrl||n.meta||n.leftAlt||n.rightAlt)&&m(a=>a.replace(/\\\r?$/,"").replace(/\r?$/,"")+`
68
- `)}}),ze(()=>{process.stdout.write("\x1B[?1004h");let o=n=>{let a=n.toString();a.includes("\x1B[I")?(jt(!0),We.current=Date.now()):a.includes("\x1B[O")&&(jt(!1),We.current=Date.now())};return process.stdin.on("data",o),()=>{process.stdout.write("\x1B[?1004l"),process.stdin.off("data",o)}},[]);let er=Ve(ce.theme);ze(()=>{er.current&&er.current!==ce.theme?(er.current=ce.theme,i&&(i.write("\x1B[2J\x1B[3J\x1B[H"),i.isTTY&&i.write("\x1B[?2004h")),qr(o=>o+1),ho()):er.current=ce.theme},[ce.theme,i]),ze(()=>{async function o(){try{let I=JSON.parse(st.readFileSync(Et.join(process.cwd(),"package.json"),"utf8"));is(oo||I.version||"2.0.0")}catch{is("2.0.0")}process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07")),ll()||(N(I=>(Y(I.length+1),[...I,{id:"setup-"+Date.now(),role:"system",text:"\u2726 Installing Required dependencies... (One-time setup)",isMeta:!0}])),await al(),N(I=>(Y(I.length+1),[...I,{id:"setup-done-"+Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m All dependencies installed successfully.
68
+ `)}}),ze(()=>{process.stdout.write("\x1B[?1004h");let o=n=>{let a=n.toString();a.includes("\x1B[I")?(jt(!0),We.current=Date.now()):a.includes("\x1B[O")&&(jt(!1),We.current=Date.now())};return process.stdin.on("data",o),()=>{process.stdout.write("\x1B[?1004l"),process.stdin.off("data",o)}},[]);let er=Ve(ce.theme);ze(()=>{er.current&&er.current!==ce.theme?(er.current=ce.theme,i&&(i.write("\x1B[2J\x1B[3J\x1B[H"),i.isTTY&&i.write("\x1B[?2004h")),qr(o=>o+1),ho()):er.current=ce.theme},[ce.theme,i]),ze(()=>{async function o(){try{let I=JSON.parse(st.readFileSync(St.join(process.cwd(),"package.json"),"utf8"));is(oo||I.version||"2.0.0")}catch{is("2.0.0")}process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07")),ll()||(N(I=>(Y(I.length+1),[...I,{id:"setup-"+Date.now(),role:"system",text:"\u2726 Installing Required dependencies... (One-time setup)",isMeta:!0}])),await al(),N(I=>(Y(I.length+1),[...I,{id:"setup-done-"+Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m All dependencies installed successfully.
69
69
  \u2800`,isMeta:!0}]))),await hi();let n=await Rr();$r.current=n.systemSettings?.allowExternalAccess??!1,Xr.current=n.systemSettings?.memory??!0,De.mode?k(De.mode):k(n.mode),L(n.display??0),De.thinking?Fe(De.thinking):Fe(n.thinkingLevel);let a=De.provider||n.aiProvider||"Google";vt(a);let c=(n.quotas?.providerTiers||{})[a]||n.apiTier||"Free";if(we.current=n.activeModel,De.model)ie(De.model);else if(De.provider){let I=ro(a,c);ie(I)}else ie(n.activeModel);Mr(n.showFullThinking),$o(c),$t(n.quotas||{limitMode:"Daily",agentLimit:99999999,tokenLimit:99999999999999,backgroundLimit:999999,searchLimit:100,customModelId:"",customLimit:0,providerBudgets:{}});let b={memory:!0,compression:0,autoExec:!1,autoDeleteHistory:"7d",autoUpdate:!1,updateManager:"npm",customUpdateCommand:"",...n.systemSettings||{}};De.memory==="on"?b.memory=!0:De.memory==="off"&&(b.memory=!1),a==="NVIDIA"&&process.env.NVIDIA_BASE_URL&&(b.memory=!1,N(I=>[...I,{role:"system",text:`\u2726 MEMORY
70
70
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Currently not available.
71
- \u2800`,isMeta:!0}])),De.package&&(b.updateManager=De.package),De.autoDel&&(b.autoDeleteHistory=De.autoDel),De.autoExec==="on"?b.autoExec=!0:De.autoExec==="off"&&(b.autoExec=!1),De.externalAccess==="on"?b.allowExternalAccess=!0:De.externalAccess==="off"&&(b.allowExternalAccess=!1),De.playground&&(b.allowExternalAccess=!1,b.memory=!1),Dt(b),As(n.profileData),Yn(n.imageSettings||{keyType:"Default",quality:"Low-High",apiKey:""});let g=De.key;if(g||(g=await ln(a)),g&&(Kt(g),On(g,{aiProvider:a,onIDEApproval:Zn})),n.systemSettings?.autoDeleteHistory&&Ii(n.systemSettings.autoDeleteHistory),Ai(rr),De.playground||(dr(Cn).catch(()=>{}),st.remove(Et.join(no,"playground")).catch(()=>{})),oe(!1,b),await Promise.all([bi(),Ln.recoverCrashedTransaction()]),De.resume){let I=await Ao(),_=De.resume;if(I[_]){Wo.current=!0,zn(_);let q=await cr(_);wn.current=Qt-q.total,Wo.current=!1,pn(q.total),Xo({tokens:q.context});let ue=[...I[_].messages];ue[0]?.text?.includes("\u2591\u2591\u2591\u2588\u2588\u2588")||ue.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),N(ue),W("chat"),N(Be=>{let Pe=[...Be,{id:"sys-"+Date.now(),role:"system",text:`\u2726 SESSION RESUMED
71
+ \u2800`,isMeta:!0}])),De.package&&(b.updateManager=De.package),De.autoDel&&(b.autoDeleteHistory=De.autoDel),De.autoExec==="on"?b.autoExec=!0:De.autoExec==="off"&&(b.autoExec=!1),De.externalAccess==="on"?b.allowExternalAccess=!0:De.externalAccess==="off"&&(b.allowExternalAccess=!1),De.playground&&(b.allowExternalAccess=!1,b.memory=!1),Dt(b),As(n.profileData),Yn(n.imageSettings||{keyType:"Default",quality:"Low-High",apiKey:""});let g=De.key;if(g||(g=await ln(a)),g&&(Kt(g),On(g,{aiProvider:a,onIDEApproval:Zn})),n.systemSettings?.autoDeleteHistory&&Ii(n.systemSettings.autoDeleteHistory),Ai(rr),De.playground||(dr(Cn).catch(()=>{}),st.remove(St.join(no,"playground")).catch(()=>{})),oe(!1,b),await Promise.all([bi(),Ln.recoverCrashedTransaction()]),De.resume){let I=await Ao(),_=De.resume;if(I[_]){Wo.current=!0,zn(_);let q=await cr(_);wn.current=Qt-q.total,Wo.current=!1,pn(q.total),Xo({tokens:q.context});let ue=[...I[_].messages];ue[0]?.text?.includes("\u2591\u2591\u2591\u2588\u2588\u2588")||ue.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),N(ue),W("chat"),N(Be=>{let Pe=[...Be,{id:"sys-"+Date.now(),role:"system",text:`\u2726 SESSION RESUMED
72
72
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m '${_}'.
73
73
  \u2800`,isMeta:!0}];return Y(Pe.length),Pe})}else N(q=>[...q,{id:"sys-err-"+Date.now(),role:"system",text:`\u2726 Chat session [${_}] not found. Started new session.
74
- \u2800`,isMeta:!0}])}if(De.playground){let I=Et.join(no,"playground");try{st.ensureDirSync(I),process.chdir(I)}catch{}let _=await Ao();if(_[Cn]){let q=[..._[Cn].messages];q[0]?.isLogo||q.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),N(q),N(ue=>{let J=[...ue,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND Session restored
74
+ \u2800`,isMeta:!0}])}if(De.playground){let I=St.join(no,"playground");try{st.ensureDirSync(I),process.chdir(I)}catch{}let _=await Ao();if(_[Cn]){let q=[..._[Cn].messages];q[0]?.isLogo||q.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),N(q),N(ue=>{let J=[...ue,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND Session restored
75
75
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m CWD locked to: '${I}'.
76
76
  \u2800`,isMeta:!0}];return Y(J.length),J})}else N(q=>{let ue=[...q,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND Mode active
77
77
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m CWD locked to: 'FluxFlow/playground'.
@@ -100,15 +100,15 @@ ${d}`,color:"magenta"}]}),m("");return}if(!wt){li(h),zo("");return}if(h.startsWi
100
100
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m '/move' is only available in playground mode.
101
101
  \u2800`,isMeta:!0}]));break}if(!De.originalCwd){N(I=>(Y(I.length+1),[...I,{id:Date.now(),role:"system",text:`\u2726 RESTRICTED
102
102
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Original CWD not found.
103
- \u2800`,isMeta:!0}]));break}let g=Et.join(no,"playground"),d=Et.join(De.originalCwd,"playground-export");(async()=>{try{N(_=>(Y(_.length+1),[..._,{id:Date.now(),role:"system",text:`\u2726 EXPORTING PLAYGROUND CONTENT
103
+ \u2800`,isMeta:!0}]));break}let g=St.join(no,"playground"),d=St.join(De.originalCwd,"playground-export");(async()=>{try{N(_=>(Y(_.length+1),[..._,{id:Date.now(),role:"system",text:`\u2726 EXPORTING PLAYGROUND CONTENT
104
104
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${d}
105
- `,isMeta:!0}])),await st.ensureDir(d);let I=["node_modules",".git",".venv","venv","env",".next","dist","build",".cache"];await st.copy(g,d,{overwrite:!0,filter:_=>{let q=Et.relative(g,_);return q?!q.split(Et.sep).some(J=>I.includes(J)):!0}}),N(_=>(Y(_.length+1),[..._,{id:Date.now(),role:"system",text:`\u2726 SUCCESS
105
+ `,isMeta:!0}])),await st.ensureDir(d);let I=["node_modules",".git",".venv","venv","env",".next","dist","build",".cache"];await st.copy(g,d,{overwrite:!0,filter:_=>{let q=St.relative(g,_);return q?!q.split(St.sep).some(J=>I.includes(J)):!0}}),N(_=>(Y(_.length+1),[..._,{id:Date.now(),role:"system",text:`\u2726 SUCCESS
106
106
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m playground content copied to ${d}
107
107
  `,isMeta:!0}]))}catch(I){N(_=>(Y(_.length+1),[..._,{id:Date.now(),role:"system",text:`\u2726 FAILED TO MOVE CONTENT
108
108
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${I.message}
109
109
  `,isMeta:!0}]))}})();break}case"/clear":{if(i&&(i.write("\x1B[2J\x1B[3J\x1B[H"),i.isTTY&&(i.write("\x1B[?2004h"),process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07"))),N([{id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}]),Y(1),qr(g=>g+1),ho(),Gt.current={completedIndex:0,columns:X.columns,historicalBlocks:[],seenSelections:new Set,chatId:tt,clearKey:Yo+1},De.playground){if(De.playground=!1,dr(Cn).catch(()=>{}),De.originalCwd)try{process.chdir(De.originalCwd),N(g=>{let d=[...g,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND
110
110
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Restored Working Directory to ${De.originalCwd}
111
- \u2800`,isMeta:!0}];return Y(d.length),d})}catch{}setTimeout(()=>{st.emptyDir(Et.join(no,"playground")).catch(g=>{N(d=>{let p=[...d,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND
111
+ \u2800`,isMeta:!0}];return Y(d.length),d})}catch{}setTimeout(()=>{st.emptyDir(St.join(no,"playground")).catch(g=>{N(d=>{let p=[...d,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND
112
112
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Failed to clear session: ${no+"/playground"}`,isMeta:!0}];return Y(p.length),p})})},500),Dt(g=>({...g,allowExternalAccess:$r.current,memory:Xr.current}))}zn(ss()),Xo({tokens:0}),v(!1),pn(0),wn.current=Qt,setTimeout(()=>{global.gc&&(async()=>{for(let d=0;d<3;d++)global.gc(),await new Promise(p=>setImmediate(p));f.current=Date.now()})()},500);break}case"/revert":{Ln.getChatHistory(tt).then(g=>{if(g.length>0)ei(g.reverse()),W("revert");else{let d=Qe(2);N(p=>(Y(p.length+1),[...p,{id:"revert-empty-"+Date.now(),role:"system",text:`\u2726 Nothing to revert to.
113
113
  \u2800`,isMeta:!0}]))}}),setTimeout(()=>{global.gc&&(async()=>{for(let d=0;d<3;d++)global.gc(),await new Promise(p=>setImmediate(p));f.current=Date.now()})()},500);break}case"/mode":{if(c[1]){let g=c[1].toLowerCase(),d="Flux";g==="flow"?d="Flow":g==="icu"?d="ICU":g==="fluxcu"?d="FluxCU":g==="flux"&&(d="Flux"),k(d),d==="Flow"&&Fe("Fast");let p=Qe(2);N(I=>(Y(I.length+1),[...I,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${Bs(d)}.
114
114
  \u2800`,isMeta:!0}]))}else W("mode");break}case"/display":{if(c[1]){let g=c[1].toLowerCase(),d=0;g==="secondary"||g==="1"||g==="2"?d=1:d=0,L(d),kt({display:d}).catch(()=>{});let p=d===0?"Primary (Display 1)":"Secondary (Display 2)";N(I=>(Y(I.length+1),[...I,{id:Date.now(),role:"system",text:`\u2726 Active Computer Use display set to: ${p}.
@@ -156,7 +156,7 @@ ${p||"\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No saved chats found."}
156
156
  \u2800`,isMeta:!0}]))}})();else if(g==="set")Tl("chat"),W("budgetTypeSelect");else if(g==="view")(async()=>{let p=await sr(),I=await ir(),_=await es(Ie.resetDay||1);Or(p),Pr(I),Hs(_),W("budgetView")})();else if(g==="reset"){let d={limitMode:"Daily",agentLimit:99999999,tokenLimit:99999999999999,backgroundLimit:999999,searchLimit:100,customModelId:"",customLimit:0,providerBudgets:{},providerTiers:{Google:"Free",DeepSeek:"Free",NVIDIA:"Free",OpenRouter:"Free",CrofAI:"Free",InferX:"Free",SenseNova:"Free",AIHubMix:"Free",Poolside:"Free"}};$t(d),$o("Free"),kt({apiTier:"Free",quotas:d}),N(p=>(Y(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 Budgets reset successfully.
157
157
  \u2800`,isMeta:!0}]))}else N(d=>(Y(d.length+1),[...d,{id:Date.now(),role:"system",text:`\u2726 ERROR
158
158
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Usage: /budget <View|Web|Set|Reset>.
159
- \u2800`,isMeta:!0}]));break}case"/fluxflow":{let d=c.slice(1)[0]?.toLowerCase()?.trim();if(d==="global"){let p=Et.normalize(ko);try{st.ensureDirSync(p)}catch{}let I=process.platform;I==="win32"?mo(`explorer "${p}"`):I==="darwin"?mo(`open "${p}"`):mo(`xdg-open "${p}"`)}else if(d==="saves"){let p=Et.normalize(no);try{st.ensureDirSync(p)}catch{p=Et.normalize(ko);try{st.ensureDirSync(p)}catch{}}let I=process.platform;I==="win32"?mo(`explorer "${p}"`):I==="darwin"?mo(`open "${p}"`):mo(`xdg-open "${p}"`)}else N(p=>(Y(p.length+1),[...p,{id:"ff-err-"+Date.now(),role:"system",text:"Usage: /fluxflow global/saves",isMeta:!0}]));break}case"/update":{if(c[1]?.toLowerCase()==="check"){oe(!0);break}let d=c.includes("--latest");W("update");break}case"/gemini":{let g=Ss[Math.floor(Math.random()*Ss.length)];N(d=>(Y(d.length+1),[...d,{id:Date.now(),role:"system",text:`\u2728 GEMINI CLI
159
+ \u2800`,isMeta:!0}]));break}case"/fluxflow":{let d=c.slice(1)[0]?.toLowerCase()?.trim();if(d==="global"){let p=St.normalize(ko);try{st.ensureDirSync(p)}catch{}let I=process.platform;I==="win32"?mo(`explorer "${p}"`):I==="darwin"?mo(`open "${p}"`):mo(`xdg-open "${p}"`)}else if(d==="saves"){let p=St.normalize(no);try{st.ensureDirSync(p)}catch{p=St.normalize(ko);try{st.ensureDirSync(p)}catch{}}let I=process.platform;I==="win32"?mo(`explorer "${p}"`):I==="darwin"?mo(`open "${p}"`):mo(`xdg-open "${p}"`)}else N(p=>(Y(p.length+1),[...p,{id:"ff-err-"+Date.now(),role:"system",text:"Usage: /fluxflow global/saves",isMeta:!0}]));break}case"/update":{if(c[1]?.toLowerCase()==="check"){oe(!0);break}let d=c.includes("--latest");W("update");break}case"/gemini":{let g=Ss[Math.floor(Math.random()*Ss.length)];N(d=>(Y(d.length+1),[...d,{id:Date.now(),role:"system",text:`\u2728 GEMINI CLI
160
160
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${g}
161
161
  \u2800`}])),m("");break}case"/compress":{m("");let g=ft.filter(I=>(I.role==="user"||I.role==="agent"||I.role==="system")&&!String(I.id).startsWith("welcome")&&!I.isMeta).length,d=fo?.tokens||0;if(g<64||d<16384){let I=Qe(2);N(_=>(Y(_.length+1),[..._,{id:Date.now(),role:"system",text:`\u2726 Compression skipped
162
162
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m History requires at least 64 messages and 16k tokens
@@ -178,26 +178,26 @@ ${c}`};N(d=>(Y(d.length+1),[...d,b])),(async()=>{let d=!1,p=()=>{d||(d=!0,N(ue=>
178
178
  `).trim()}),Ee=[]),be.length>0&&(J.push({role:"system",text:be.join(`
179
179
 
180
180
  `),...Ye?{binaryPart:Ye}:{}}),be=[],Ye=null),Ke=!1};me.forEach(Tt=>{let pe=Tt.role==="system"&&(Tt.text?.startsWith("[TOOL RESULT]")||Tt.text?.startsWith("SUCCESS:")||Tt.text?.startsWith("ERROR:")||Tt.fullText?.startsWith("[TOOL RESULT]")||Tt.fullText?.startsWith("SUCCESS:")||Tt.fullText?.startsWith("ERROR:")),ye=Tt.fullText||Tt.text||"",Oe=ye.trim();if(!(!Oe&&!Tt.binaryPart)){if(pe){let Ge=Oe.startsWith("[TOOL RESULT]")?Oe:`[TOOL RESULT]: ${Oe}`;be.push(Ge),Tt.binaryPart&&(Ye=Tt.binaryPart)}else if(Tt.role==="agent"){!Ke&&be.length>0&&Ft();let Ge=ye.endsWith(`
181
- `),Ct=Oe.toLowerCase().includes("tool:functions.")||Oe.toLowerCase().includes("agent:generalist.");Ee.push(Oe),Ct&&Ge?Ke=!0:Ke=!1}}}),Ft()}}let Z=Gi(re,J,{profile:xn,thinkingLevel:he,mode:D,systemSettings:ce,janitorModel:Ce,sessionStats:fo,chatId:tt,isPlayground:!!De.playground,aiProvider:P,apiKey:wt,apiTier:Re,wildcardTooling:y,cols:X.columns-6,rows:30,onTokenChunk:(U,me)=>{let Ee=Date.now();if(Ar(Ee),typeof me=="number"){Os.current=me;let be=Lr.current;be.startTime||(be.startTime=Ee,be.totalWords=0,be.chunks=[]),be.totalWords+=me,be.chunks||(be.chunks=[]),be.chunks.push({time:Ee,words:me});let Ke=Ee-400;if(be.chunks=be.chunks.filter(Ft=>Ft.time>=Ke),be.chunks.length>0){let Ft=be.chunks.reduce((ye,Oe)=>ye+Oe.words,0),Tt=be.chunks[0].time,pe=Math.max(.4,(Ee-Tt)/1e3);be.wps=Math.round(Ft/pe*10)/10}}},onVisualFeedback:U=>{N(me=>[...me.map(be=>be.isStreaming?{...be,isStreaming:!1}:be),{id:"visual-"+Date.now()+"-"+Math.random().toString(36).substring(2,9),role:"system",text:U,isVisualFeedback:!0}])},onSubagentUpdate:()=>{Ll(Ui.map(U=>({...U})))},onExecStart:U=>{Me(),Te(),Gs(U),on("")},onExecChunk:U=>{on(me=>me+U)},onExecEnd:()=>{N(U=>{if(!Jn.current)return U;let me=_r.current||"",Ee=vi(me),be=`[TERMINAL_RECORD]
181
+ `),Mt=Oe.toLowerCase().includes("tool:functions.")||Oe.toLowerCase().includes("agent:generalist.");Ee.push(Oe),Mt&&Ge?Ke=!0:Ke=!1}}}),Ft()}}let Z=Gi(re,J,{profile:xn,thinkingLevel:he,mode:D,systemSettings:ce,janitorModel:Ce,sessionStats:fo,chatId:tt,isPlayground:!!De.playground,aiProvider:P,apiKey:wt,apiTier:Re,wildcardTooling:y,cols:X.columns-6,rows:30,onTokenChunk:(U,me)=>{let Ee=Date.now();if(Ar(Ee),typeof me=="number"){Os.current=me;let be=Lr.current;be.startTime||(be.startTime=Ee,be.totalWords=0,be.chunks=[]),be.totalWords+=me,be.chunks||(be.chunks=[]),be.chunks.push({time:Ee,words:me});let Ke=Ee-400;if(be.chunks=be.chunks.filter(Ft=>Ft.time>=Ke),be.chunks.length>0){let Ft=be.chunks.reduce((ye,Oe)=>ye+Oe.words,0),Tt=be.chunks[0].time,pe=Math.max(.4,(Ee-Tt)/1e3);be.wps=Math.round(Ft/pe*10)/10}}},onVisualFeedback:U=>{N(me=>[...me.map(be=>be.isStreaming?{...be,isStreaming:!1}:be),{id:"visual-"+Date.now()+"-"+Math.random().toString(36).substring(2,9),role:"system",text:U,isVisualFeedback:!0}])},onSubagentUpdate:()=>{Ll(Ui.map(U=>({...U})))},onExecStart:U=>{Me(),Te(),Gs(U),on("")},onExecChunk:U=>{on(me=>me+U)},onExecEnd:()=>{N(U=>{if(!Jn.current)return U;let me=_r.current||"",Ee=vi(me),be=`[TERMINAL_RECORD]
182
182
  COMMAND: ${Jn.current}
183
183
  PTY: ${an}
184
184
  OUTPUT: ${Ee.replace(/\n{3,}/g,`
185
185
 
186
186
  `)}`,Ke=[...U.map(Ft=>Ft.isStreaming?{...Ft,isStreaming:!1}:Ft),{id:"term-"+Date.now(),role:"system",text:be,isTerminalRecord:!0}];return Y(Ke.length),Ke}),Gs(null),Ws(!1),on(""),Jn.current=null,_r.current=""},onToolResult:(U,me)=>{if(U==="success"){if(Ml(Ee=>Ee+1),me==="generate_image"){kl(Ye=>Ye+1);let be={Low:.001,"Low-High":.002,Medium:.008,"Medium-High":.01,High:.045,Ultra:.0488,Premium:.1}[So.quality]||.002;Il(Ye=>Ye+be)}}else U==="denied"?El(Ee=>Ee+1):Bl(Ee=>Ee+1)},onToolApproval:async(U,me)=>{let Ee=Pl||ce.autoExec;if(U==="exec_command"){let{command:be}=An(me||"{}");return Ee||be&&/^(echo|ls|dir|pwd|cd|git status|git log|git diff|type|cat|help)\b/i.test(be.trim())?"allow":new Promise(Ke=>{nn({tool:U,args:me,resolve:Ke}),W("terminalApproval")})}return Ee?"allow":new Promise(be=>{nn({tool:U,args:me,resolve:be}),W("approval")})},onAskUser:async(U,me)=>(Me(),Te(),new Promise(Ee=>{let be=!1;Hr({question:U,options:me,resolve:Ye=>{be||(be=!0,N(Ke=>{if(Ke.some(pe=>pe.isAskRecord&&pe.text?.includes(`Selection: ${Ye}`)))return Ke;let Tt=[...Ke,{id:"ask-"+Date.now(),role:"system",text:`\u{1F4AC} **Ask User**
187
187
  Question: ${U}
188
- Selection: ${Ye}`,isAskRecord:!0}];return Y(Tt.length),Tt}),Ee(Ye))}}),W("ask")})),onUsage:U=>{let me=U.totalTokenCount||0,Ee=U.cachedContentTokenCount||0,be=U.candidatesTokenCount||0;Xo({tokens:me}),Us(Ye=>Ye+me),Ee>0&&$s(Ye=>Ye+Ee),be>0&&Xs(Ye=>Ye+be),Ns(Ye=>Ye+1)}},async()=>{if(Mo.current){let U=Mo.current;return jr(null),Mo.current=null,N(me=>{let Ee=[...me].reverse().findIndex(be=>be.text?.includes("[STEERING HINT: QUEUED]")||be.text?.includes("[QUESTION: QUEUED]"));if(Ee!==-1){let be=me.length-1-Ee,Ye=[...me],Ke=Ye[be].text;return Ke.includes("[STEERING HINT: QUEUED]")?Ke=Ke.replace("[STEERING HINT: QUEUED]","[STEERING HINT: INJECTED]"):Ke.includes("[QUESTION: QUEUED]")&&(Ke=Ke.replace("[QUESTION: QUEUED]","[QUESTION: ASKED]")),Ye[be]={...Ye[be],text:Ke,color:"cyan"},Ye}return me}),U}return null},oo),ne=!1,ot=null,$e=null,_e=!1,nt=!1,At=!1,rt=!1,ct=0,St=null,Eo=/\[?\s*turn\s*:\s*.*?\s*\]?/gi;for await(let U of Z){if(await new Promise(pe=>setTimeout(pe,3)),U.type==="text"&&Ar(Date.now()),q&&U.type==="text"&&(_=Date.now(),q=!1,ce.progressiveRendering&&Le()),U.type==="status"){U.content?.includes("[start]")||Gr(U.content),U.content?.includes("[start]")?(clearInterval(vn),En(0),vn=setInterval(()=>{En(pe=>pe+1)},1e3)):U.content?.includes("[end]")&&(En(0),clearInterval(vn)),jo()&&ur(U.content),U.content==="Request Cancelled"&&(Me(),Te(),p());continue}if(U.type==="status_history"){Gr(U.content),jo()&&ur(U.content),N(pe=>[...pe,{id:"condense-"+Date.now(),role:"system",text:`\u2726 ${U.content}
189
- \u2800`,isMeta:!0}]);continue}if(U.type==="summary_injected"){N(pe=>pe.map(ye=>ye.id===U.content.id?{...ye,fullText:U.content.text}:ye));continue}if(U.type==="spinner"){$l(U.content);continue}if(U.type==="model_update"){Wl(U.content);continue}if(U.type==="turn_reset"){if(Me(),Te(),ot=null,$e=null,ne=!1,_e=!1,nt=!1,rt=!1,At=!1,N(pe=>{let ye=pe.map(Oe=>{if(Oe.isStreaming){let Ge=Oe.text?yt(Oe.text):Oe.text,Ct=Oe.fullText?yt(Oe.fullText):Oe.fullText;return{...Oe,isStreaming:!1,text:Ge,fullText:Ct}}return Oe});return Y(ye.length),ye}),ho(),global.gc){for(let pe=0;pe<2;pe++)global.gc(),await new Promise(ye=>setImmediate(ye));f.current=Date.now()}continue}if(U.type==="interactive_turn_finished"){Yr(!1),En(0),clearInterval(vn),jo()&&ur(null),I=!0,ho(),ce?.autoTruncateResults&&N(pe=>{let ye=pe.map(Oe=>{let Ge=Oe.fullText||Oe.text||"";return!Ge.startsWith("[TOOL RESULT]:")||Ge.startsWith("[TOOL RESULT]: ERROR")||Ge.startsWith("[TOOL RESULT]: DENIED")||Ge.includes("...SUCCESS Results Truncated by System on User Command")||Ge.startsWith("[TOOL RESULT]: Skill:")||Ge.includes("Skill: [")||Ge.startsWith("[TOOL RESULT]: DOCs:")||Ge.includes("DOCs: [")?Oe:Ge.startsWith("[TOOL RESULT]: SUCCESS")?{...Oe,fullText:"[TOOL RESULT]: SUCCESS: ...SUCCESS Results Truncated by System on User Command"}:{...Oe,fullText:"[TOOL RESULT]: ...SUCCESS Results Truncated by System on User Command"}});return dn(tt,null,ye),Y(ye.length),ye}),Xi({profile:xn,thinkingLevel:he,mode:D,janitorModel:Ce,chatId:tt,systemSettings:ce,sessionStats:fo,aiProvider:P,apiKey:wt},U.data.agentText,U.data.fullAgentTextRaw,U.data.history,{onMemoryUpdated:()=>N(pe=>{let ye=[...pe];return ye.length>0&&(ye[ye.length-1].memoryUpdated=!0),ye}),onBackgroundIncrement:()=>Sl(pe=>pe+1)});continue}if(U.type==="visual_feedback"){Me(),Te(),N(pe=>{let ye=[...pe,{id:"feedback-"+Date.now()+"-"+Math.random().toString(36).substring(2,9),role:"system",text:yt(U.content),isVisualFeedback:!0}];return Y(ye.length),ye});continue}if(U.type==="exec_start"){Me(),Te();continue}if(U.type==="liveTokens"){Xo({tokens:U.content});continue}if(U.type==="usage"){let pe=U.content.totalTokenCount||0,ye=U.content.cachedContentTokenCount||0,Oe=U.content.candidatesTokenCount||0;Xo({tokens:pe}),Us(Ge=>Ge+pe),ye>0&&$s(Ge=>Ge+ye),Oe>0&&Xs(Ge=>Ge+Oe),Ns(Ge=>Ge+1);continue}if(U.type==="tool_time"){Dl(pe=>pe+U.content);continue}if(U.type==="tool_result"){if(Te(),ot=null,$e=null,ne=!1,_e=!1,nt=!1,rt=!1,At=!1,ct=0,St=null,N(pe=>{let ye=[...pe,{id:"tool-"+Date.now()+"-"+Math.random().toString(36).substring(2,7),role:"system",text:yt(U.content),fullText:yt(U.aiContent),binaryPart:U.binaryPart,toolName:U.toolName}];return Y(ye.length),ye}),U.toolName==="update_file"&&U.aiContent){let pe=U.aiContent.split(`
190
- `),ye=0,Oe=0,Ge=!1;for(let Ct of pe){if(Ct.includes("[DIFF_START]")){Ge=!0;continue}if(Ct.includes("[DIFF_END]")){Ge=!1;continue}Ge&&(/^\+\d+/.test(Ct)?ye++:/^\-\d+/.test(Ct)&&Oe++)}Vo("linesAdded",ye),Vo("linesRemoved",Oe)}else if(U.toolName==="write_file"&&U.aiContent){let pe=U.aiContent.match(/- Stats: \[(\d+) lines/),ye=pe?parseInt(pe[1]):0,Oe=0;if(U.aiContent.includes("Old File contents:")){let Ge=U.aiContent.split(`
191
- `),Ct=!1;for(let Do of Ge){if(Do.includes("Old File contents:")){Ct=!0;continue}Ct&&(Do.trim()===""?Ct=!1:/^\d+ \|/.test(Do)&&Oe++)}}Vo("linesAdded",ye),Vo("linesRemoved",Oe)}continue}let me=U.content;if(U.type==="text"&&me.includes("Request Cancelled")){if(global.gc){for(let pe=0;pe<3;pe++)global.gc(),await new Promise(ye=>setImmediate(ye));f.current=Date.now()}continue}let Ee=me.toLowerCase();if(me.includes("```")&&(_e=!_e),(Ee.includes("tool:functions.")||Ee.includes("agent:generalist."))&&(nt=!0,ct=0,St=null,(me.includes("[tool:functions.")||me.includes("[agent:generalist."))&&(ct=0)),nt){for(let pe=0;pe<me.length;pe++){let ye=me[pe];!St&&(ye==="'"||ye==='"'||ye==="`")?St=ye:St&&ye===St&&me[pe-1]!=="\\"&&(St=null),St||(ye==="("||ye==="["?ct++:(ye===")"||ye==="]")&&ct--)}ct<=0&&!St&&(nt=!1)}let be=/^\s*(?:<(think|thought|thoughts)[^>]*>|<\|channel>thought|\[(think|thought|thoughts)\])/i,Ye=(pe,ye)=>{let Oe=!1;for(let Ge=0;Ge<ye;Ge++)pe[Ge]==="`"&&(Oe=!Oe);return Oe},Ke=pe=>{let ye=/(?:<\/(think|thought|thoughts)>|<channel\|>|\[\/(think|thought|thoughts)\])/gi,Oe;for(;(Oe=ye.exec(pe))!==null;)if(!Ye(pe,Oe.index))return{index:Oe.index,length:Oe[0].length};return{index:-1,length:0}},Ft=V.current?.role==="agent"&&V.current.text||"",Tt=!At&&Ft.trim().length===0;if(!ne&&Tt&&(be.test(me)||be.test(Ft+me))){let pe=be.test(me)?me:Ft+me,ye=pe.match(be),Oe=ye.index,Ge=ye[0].length,Ct=pe.substring(Oe+Ge);Me(),V.current=null,ne=!0,At=!0,ot="think-"+Date.now(),V.current={id:ot,role:"think",text:"",isStreaming:!0,startTime:Date.now()};let Do=Ke(Ct);if(Do.index!==-1){let ql=Ct.substring(0,Do.index).replace(/^\r?\n+/,"").replace(/\r?\n+$/,""),ui=Ct.substring(Do.index+Do.length);V.current.text=yt(ql);let Ql=V.current.startTime||Date.now();V.current.duration=Date.now()-Ql,Te(),ne=!1,$e="agent-"+Date.now(),V.current={id:$e,role:"agent",text:"",isStreaming:!0},ui&&Je(ui)}else{let Qr=Ct.replace(/^\r?\n+/,"");Qr&&Je(Qr)}continue}if(!ne&&!At&&me.trim().length>0&&(At=!0),ne&&V.current?.role==="think"){Me();let pe=V.current.text+me,ye=Ke(pe);if(ye.index!==-1){let Oe=pe.substring(0,ye.index),Ge=pe.substring(ye.index+ye.length);V.current.text=yt(Oe);let Ct=V.current.startTime||Date.now();V.current.duration=Date.now()-Ct,Te(),ne=!1,$e="agent-"+Date.now(),V.current={id:$e,role:"agent",text:"",isStreaming:!0},Ge&&Je(Ge)}else Je(me);continue}else if(!ne){let pe=me.toLowerCase();!rt&&(pe.includes("tool:functions.")||pe.includes("agent:generalist."))&&(rt=!0),!V.current||V.current.role!=="agent"?($e="agent-"+Date.now(),V.current={id:$e,role:"agent",text:yt(me),isStreaming:!0},j()):Je(me)}}let vo=Date.now();vl(U=>U+(vo-_))}catch(ue){N(J=>(Y(J.length+1),[...J,{id:"error-"+Date.now(),role:"system",text:`\u274C ERROR: ${ue.message}`}]))}finally{let ue=Date.now()-_;if(V.current&&(V.current.workedDuration=ue),xe.current&&(await qe(),clearInterval(xe.current),xe.current=null),Yr(!1),Gr(null),En(0),clearInterval(vn),Te(),Vr.current&&p(),ho(),global.gc)try{for(let J=0;J<3;J++)global.gc(),await new Promise(Be=>setImmediate(Be));f.current=Date.now()}catch{}if(I||process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow | Idle\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow | Idle\x07")),Mo.current){Kr(Mo.current),jr(null);let J=Mo.current;Mo.current=null,N(Be=>{let Pe=[...Be],Z=Pe.reverse().find(ne=>ne.text?.includes("[STEERING HINT: QUEUED]")||ne.text?.includes("[QUESTION: QUEUED]"));return Z&&(Z.text.includes("[STEERING HINT: QUEUED]")?Z.text=Z.text.replace("[STEERING HINT: QUEUED]","[STEERING HINT: FINISHED_TURN]"):Z.text.includes("[QUESTION: QUEUED]")&&(Z.text=Z.text.replace("[QUESTION: QUEUED]","[QUESTION: FINISHED_TURN]"))),Pe.reverse()}),W("resolution")}N(J=>{let Be=Date.now()-_,Pe=!1,Z=[...J].reverse().map($e=>{let _e=$e.isStreaming?{...$e,isStreaming:!1}:$e;return _e.text&&(_e.text=(" "+_e.text).slice(1)),!Pe&&_e.role==="agent"&&(Pe=!0,_e={..._e,workedDuration:Be}),_e}).reverse();if(!Z.some($e=>$e.role==="agent"&&$e.text?.trim().length>0)){let $e=[...Z].reverse().find(_e=>_e.role==="think"&&_e.text?.trim().length>0);$e&&Z.push({id:"agent-fallback-"+Date.now(),role:"agent",text:$e.text,isStreaming:!1,workedDuration:Be})}let ot=Z.filter($e=>!String($e.id).startsWith("welcome")&&(!$e.isMeta||$e.text&&$e.text.includes("Request Cancelled")));return dn(tt,null,ot),Y(Z.length),Z})}})()}m(""),v(!1)}},He=fn(()=>{if(E.startsWith("/")&&!z){let c=E.split(" "),b=c[c.length-1].toLowerCase();if(c.length===1){let d=b.startsWith("/")?b.slice(1):b;return ai.filter(p=>(p.cmd.startsWith("/")?p.cmd.slice(1):p.cmd).toLowerCase().includes(d))}let g=ai;for(let d=0;d<c.length-1;d++){let p=c[d].toLowerCase(),I=g.find(_=>_.cmd.toLowerCase()===p);if(I&&I.subs)g=I.subs;else return[]}return g.filter(d=>d.cmd.toLowerCase().includes(b))}let o=E.split(" "),n=o[o.length-1],a=n&&n.startsWith("\\@");if((n&&n.startsWith("@")||a)&&!z){let c=n.indexOf("#"),b=c!==-1,g=a?2:1,d=b?n.substring(g,c).toLowerCase():n.slice(g).toLowerCase(),p=b?n.substring(c):"";return Ud(process.cwd()).filter(q=>q.name.toLowerCase().includes(d)).map(q=>{let ue=q.relativePath.replace(/\\/g,"/"),J=ue.startsWith(".")?ue:"./"+ue;return{cmd:(a?"\\@":"@")+"["+J+p+"]",desc:q.relativePath}})}return[]},[E,z]);ze(()=>{let o=0;for(;o<He.length;){let n=He[o],a=n?.cmd||n||"";if(typeof a=="string"&&a.trimStart().startsWith("---"))o++;else break}ge(o<He.length?o:0)},[He]);let[or,nr]=Q(0),ci=Ve(0);ze(()=>{let o=ci.current>0,n=He.length>0;if(ci.current=He.length,!n){nr(0);return}if(!o){nr(1);return}nr(He.length)},[He]),ze(()=>{if(or>0&&or<He.length){let o=setTimeout(()=>{nr(n=>Math.min(n+1,He.length))},5);return()=>clearTimeout(o)}},[or,He.length]),ze(()=>{if(lt!=="providerBudgetSelect")return;let o=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","CrofAI","InferX","SenseNova","AIHubMix","Poolside"],n=Ie.providerBudgets||{},a=o.reduce((h,c)=>(h[c]=!!(n[c]&&(n[c].agentLimit||n[c].tokenLimit)),h),{});Is(a),Gn(0)},[lt]),ze(()=>{if(lt!=="providerBudgetFlow")return;let o={},n=Ie.providerBudgets||{};for(let a of Zo){let h=n[a]||{};o[a]={agentLimit:hn(h.agentLimit),tokenLimit:hn(h.tokenLimit),monthlyTokenLimit:hn(h.monthlyTokenLimit)}}Ir(o),go(0)},[lt,Zo]);let Zd=({label:o,isSelected:n})=>{let a=o==="Cancel"||o==="Back"||o.toLowerCase().includes("exit")||o.toLowerCase().includes("back");return e.createElement(u,{marginTop:a?1:0,backgroundColor:n?"#2a2a2a":void 0,paddingX:1,width:"100%"},e.createElement(s,{color:n?"white":"gray",bold:n},n?"\u276F ":" ",o))},sn=(o,n,a,h=10,c=2,b=9)=>{let g=a>0?Math.min(100,n/a*100):0,d=Math.round(g),p=Math.round(d/100*h),I="\u2588".repeat(p)+"\u2591".repeat(Math.max(0,h-p)),_=l.success||"green";d>=40&&d<=80?_=l.warning||"yellow":d>80&&(_=l.danger||"red");let q=o.toLowerCase().includes("token")||o.toLowerCase().includes("daily")||o.toLowerCase().includes("monthly"),ue=Hn(a)?"\u221E":q?ut(a):a,J=q?ut(n):n,Be;return g===0?Be="0%":g>0&&g<1?Be="<1%":Be=`${d}%`,e.createElement(u,{flexDirection:"row",paddingLeft:c,key:o},e.createElement(u,{width:b},e.createElement(s,{color:l.textMuted},o,": ")),e.createElement(s,{color:_},I),e.createElement(s,{color:l.textMuted}," ",Be," (",J,"/",ue,")"))},Kl=()=>{switch(lt){case"settings":return e.createElement(wr,{systemSettings:ce,setSystemSettings:Dt,apiTier:Re,setActiveView:W,setInputConfig:qt,saveSettings:kt,quotas:Ie,setMessages:N,aiProvider:P,setProviderReturnView:vr});case"theme":return e.createElement(wr,{systemSettings:ce,setSystemSettings:Dt,apiTier:Re,setActiveView:W,setInputConfig:qt,saveSettings:kt,quotas:Ie,setMessages:N,aiProvider:P,initialSelectingTheme:!0,onCloseTheme:()=>W("chat"),setProviderReturnView:vr});case"selectProvider":return e.createElement(gt,{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:"CrofAI",value:"CrofAI"},{label:"Poolside",value:"Poolside"},...process.env.ENABLE_9ROUTER==="true"||process.env.ENABLE_9ROUTER===!0?[{label:"9router",value:"9router"}]:[],{label:"Ollama",value:"Ollama"},{label:"AIHubMix [EXPERIMENTAL]",value:"AIHubMix"},{label:"Mistral [EXPERIMENTAL]",value:"Mistral"},{label:"OpenRouter [EXPERIMENTAL]",value:"OpenRouter"},{label:"Back",value:Jo}],theme:ce.theme,onSelect:async o=>{if(o.value===Jo||o.value==="settings"||o.value==="Back"){W(Jo);return}let n=o.value,a=await ln(n);if(a){vt(n),Kt(a),On(a,{aiProvider:n,onIDEApproval:Zn});let h=(Ie.providerTiers||{})[n]||"Free",c=ro(n,h);ie(c),$o(h),n==="NVIDIA"&&process.env.NVIDIA_BASE_URL||n==="Ollama"||n==="CrofAI"||n==="InferX"||n==="SenseNova"||n==="Poolside"||n==="9router"?(Dt(b=>({...b,memory:!1})),kt({aiProvider:n,activeModel:c,apiTier:h,quotas:Ie,systemSettings:{...ce,memory:!1}})):kt({aiProvider:n,activeModel:c,apiTier:h,quotas:Ie}),N(b=>[...b,{role:"system",text:`\u2726 Switched to ${n} (cached)!${c?`
188
+ Selection: ${Ye}`,isAskRecord:!0}];return Y(Tt.length),Tt}),Ee(Ye))}}),W("ask")})),onUsage:U=>{let me=U.totalTokenCount||0,Ee=U.cachedContentTokenCount||0,be=U.candidatesTokenCount||0;Xo({tokens:me}),Us(Ye=>Ye+me),Ee>0&&$s(Ye=>Ye+Ee),be>0&&Xs(Ye=>Ye+be),Ns(Ye=>Ye+1)}},async()=>{if(Mo.current){let U=Mo.current;return jr(null),Mo.current=null,N(me=>{let Ee=[...me].reverse().findIndex(be=>be.text?.includes("[STEERING HINT: QUEUED]")||be.text?.includes("[QUESTION: QUEUED]"));if(Ee!==-1){let be=me.length-1-Ee,Ye=[...me],Ke=Ye[be].text;return Ke.includes("[STEERING HINT: QUEUED]")?Ke=Ke.replace("[STEERING HINT: QUEUED]","[STEERING HINT: INJECTED]"):Ke.includes("[QUESTION: QUEUED]")&&(Ke=Ke.replace("[QUESTION: QUEUED]","[QUESTION: ASKED]")),Ye[be]={...Ye[be],text:Ke,color:"cyan"},Ye}return me}),U}return null},oo),ne=!1,ot=null,$e=null,_e=!1,nt=!1,At=!1,rt=!1,ct=0,Ct=null,Eo=/\[?\s*turn\s*:\s*.*?\s*\]?/gi;for await(let U of Z){if(await new Promise(pe=>setTimeout(pe,3)),U.type==="text"&&Ar(Date.now()),q&&U.type==="text"&&(_=Date.now(),q=!1,ce.progressiveRendering&&Le()),U.type==="status"){U.content?.includes("[start]")||Gr(U.content),U.content?.includes("[start]")?(clearInterval(vn),En(0),vn=setInterval(()=>{En(pe=>pe+1)},1e3)):U.content?.includes("[end]")&&(En(0),clearInterval(vn)),jo()&&ur(U.content),U.content==="Request Cancelled"&&(Me(),Te(),p());continue}if(U.type==="status_history"){Gr(U.content),jo()&&ur(U.content),N(pe=>[...pe,{id:"condense-"+Date.now(),role:"system",text:`\u2726 ${U.content}
189
+ \u2800`,isMeta:!0}]);continue}if(U.type==="summary_injected"){N(pe=>pe.map(ye=>ye.id===U.content.id?{...ye,fullText:U.content.text}:ye));continue}if(U.type==="spinner"){$l(U.content);continue}if(U.type==="model_update"){Wl(U.content);continue}if(U.type==="turn_reset"){if(Me(),Te(),ot=null,$e=null,ne=!1,_e=!1,nt=!1,rt=!1,At=!1,N(pe=>{let ye=pe.map(Oe=>{if(Oe.isStreaming){let Ge=Oe.text?yt(Oe.text):Oe.text,Mt=Oe.fullText?yt(Oe.fullText):Oe.fullText;return{...Oe,isStreaming:!1,text:Ge,fullText:Mt}}return Oe});return Y(ye.length),ye}),ho(),global.gc){for(let pe=0;pe<2;pe++)global.gc(),await new Promise(ye=>setImmediate(ye));f.current=Date.now()}continue}if(U.type==="interactive_turn_finished"){Yr(!1),En(0),clearInterval(vn),jo()&&ur(null),I=!0,ho(),ce?.autoTruncateResults&&N(pe=>{let ye=pe.map(Oe=>{let Ge=Oe.fullText||Oe.text||"";return!Ge.startsWith("[TOOL RESULT]:")||Ge.startsWith("[TOOL RESULT]: ERROR")||Ge.startsWith("[TOOL RESULT]: DENIED")||Ge.includes("...SUCCESS Results Truncated by System on User Command")||Ge.startsWith("[TOOL RESULT]: Skill:")||Ge.includes("Skill: [")||Ge.startsWith("[TOOL RESULT]: DOCs:")||Ge.includes("DOCs: [")?Oe:Ge.startsWith("[TOOL RESULT]: SUCCESS")?{...Oe,fullText:"[TOOL RESULT]: SUCCESS: ...SUCCESS Results Truncated by System on User Command"}:{...Oe,fullText:"[TOOL RESULT]: ...SUCCESS Results Truncated by System on User Command"}});return dn(tt,null,ye),Y(ye.length),ye}),Xi({profile:xn,thinkingLevel:he,mode:D,janitorModel:Ce,chatId:tt,systemSettings:ce,sessionStats:fo,aiProvider:P,apiKey:wt},U.data.agentText,U.data.fullAgentTextRaw,U.data.history,{onMemoryUpdated:()=>N(pe=>{let ye=[...pe];return ye.length>0&&(ye[ye.length-1].memoryUpdated=!0),ye}),onBackgroundIncrement:()=>Sl(pe=>pe+1)});continue}if(U.type==="visual_feedback"){Me(),Te(),N(pe=>{let ye=[...pe,{id:"feedback-"+Date.now()+"-"+Math.random().toString(36).substring(2,9),role:"system",text:yt(U.content),isVisualFeedback:!0}];return Y(ye.length),ye});continue}if(U.type==="exec_start"){Me(),Te();continue}if(U.type==="liveTokens"){Xo({tokens:U.content});continue}if(U.type==="usage"){let pe=U.content.totalTokenCount||0,ye=U.content.cachedContentTokenCount||0,Oe=U.content.candidatesTokenCount||0;Xo({tokens:pe}),Us(Ge=>Ge+pe),ye>0&&$s(Ge=>Ge+ye),Oe>0&&Xs(Ge=>Ge+Oe),Ns(Ge=>Ge+1);continue}if(U.type==="tool_time"){Dl(pe=>pe+U.content);continue}if(U.type==="tool_result"){if(Te(),ot=null,$e=null,ne=!1,_e=!1,nt=!1,rt=!1,At=!1,ct=0,Ct=null,N(pe=>{let ye=[...pe,{id:"tool-"+Date.now()+"-"+Math.random().toString(36).substring(2,7),role:"system",text:yt(U.content),fullText:yt(U.aiContent),binaryPart:U.binaryPart,toolName:U.toolName}];return Y(ye.length),ye}),U.toolName==="update_file"&&U.aiContent){let pe=U.aiContent.split(`
190
+ `),ye=0,Oe=0,Ge=!1;for(let Mt of pe){if(Mt.includes("[DIFF_START]")){Ge=!0;continue}if(Mt.includes("[DIFF_END]")){Ge=!1;continue}Ge&&(/^\+\d+/.test(Mt)?ye++:/^\-\d+/.test(Mt)&&Oe++)}Vo("linesAdded",ye),Vo("linesRemoved",Oe)}else if(U.toolName==="write_file"&&U.aiContent){let pe=U.aiContent.match(/- Stats: \[(\d+) lines/),ye=pe?parseInt(pe[1]):0,Oe=0;if(U.aiContent.includes("Old File contents:")){let Ge=U.aiContent.split(`
191
+ `),Mt=!1;for(let Do of Ge){if(Do.includes("Old File contents:")){Mt=!0;continue}Mt&&(Do.trim()===""?Mt=!1:/^\d+ \|/.test(Do)&&Oe++)}}Vo("linesAdded",ye),Vo("linesRemoved",Oe)}continue}let me=U.content;if(U.type==="text"&&me.includes("Request Cancelled")){if(global.gc){for(let pe=0;pe<3;pe++)global.gc(),await new Promise(ye=>setImmediate(ye));f.current=Date.now()}continue}let Ee=me.toLowerCase();if(me.includes("```")&&(_e=!_e),(Ee.includes("tool:functions.")||Ee.includes("agent:generalist."))&&(nt=!0,ct=0,Ct=null,(me.includes("[tool:functions.")||me.includes("[agent:generalist."))&&(ct=0)),nt){for(let pe=0;pe<me.length;pe++){let ye=me[pe];!Ct&&(ye==="'"||ye==='"'||ye==="`")?Ct=ye:Ct&&ye===Ct&&me[pe-1]!=="\\"&&(Ct=null),Ct||(ye==="("||ye==="["?ct++:(ye===")"||ye==="]")&&ct--)}ct<=0&&!Ct&&(nt=!1)}let be=/^\s*(?:<(think|thought|thoughts)[^>]*>|<\|channel>thought|\[(think|thought|thoughts)\])/i,Ye=(pe,ye)=>{let Oe=!1;for(let Ge=0;Ge<ye;Ge++)pe[Ge]==="`"&&(Oe=!Oe);return Oe},Ke=pe=>{let ye=/(?:<\/(think|thought|thoughts)>|<channel\|>|\[\/(think|thought|thoughts)\])/gi,Oe;for(;(Oe=ye.exec(pe))!==null;)if(!Ye(pe,Oe.index))return{index:Oe.index,length:Oe[0].length};return{index:-1,length:0}},Ft=V.current?.role==="agent"&&V.current.text||"",Tt=!At&&Ft.trim().length===0;if(!ne&&Tt&&(be.test(me)||be.test(Ft+me))){let pe=be.test(me)?me:Ft+me,ye=pe.match(be),Oe=ye.index,Ge=ye[0].length,Mt=pe.substring(Oe+Ge);Me(),V.current=null,ne=!0,At=!0,ot="think-"+Date.now(),V.current={id:ot,role:"think",text:"",isStreaming:!0,startTime:Date.now()};let Do=Ke(Mt);if(Do.index!==-1){let ql=Mt.substring(0,Do.index).replace(/^\r?\n+/,"").replace(/\r?\n+$/,""),ui=Mt.substring(Do.index+Do.length);V.current.text=yt(ql);let Ql=V.current.startTime||Date.now();V.current.duration=Date.now()-Ql,Te(),ne=!1,$e="agent-"+Date.now(),V.current={id:$e,role:"agent",text:"",isStreaming:!0},ui&&Je(ui)}else{let Qr=Mt.replace(/^\r?\n+/,"");Qr&&Je(Qr)}continue}if(!ne&&!At&&me.trim().length>0&&(At=!0),ne&&V.current?.role==="think"){Me();let pe=V.current.text+me,ye=Ke(pe);if(ye.index!==-1){let Oe=pe.substring(0,ye.index),Ge=pe.substring(ye.index+ye.length);V.current.text=yt(Oe);let Mt=V.current.startTime||Date.now();V.current.duration=Date.now()-Mt,Te(),ne=!1,$e="agent-"+Date.now(),V.current={id:$e,role:"agent",text:"",isStreaming:!0},Ge&&Je(Ge)}else Je(me);continue}else if(!ne){let pe=me.toLowerCase();!rt&&(pe.includes("tool:functions.")||pe.includes("agent:generalist."))&&(rt=!0),!V.current||V.current.role!=="agent"?($e="agent-"+Date.now(),V.current={id:$e,role:"agent",text:yt(me),isStreaming:!0},j()):Je(me)}}let vo=Date.now();vl(U=>U+(vo-_))}catch(ue){N(J=>(Y(J.length+1),[...J,{id:"error-"+Date.now(),role:"system",text:`\u274C ERROR: ${ue.message}`}]))}finally{let ue=Date.now()-_;if(V.current&&(V.current.workedDuration=ue),xe.current&&(await qe(),clearInterval(xe.current),xe.current=null),Yr(!1),Gr(null),En(0),clearInterval(vn),Te(),Vr.current&&p(),ho(),global.gc)try{for(let J=0;J<3;J++)global.gc(),await new Promise(Be=>setImmediate(Be));f.current=Date.now()}catch{}if(I||process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow | Idle\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow | Idle\x07")),Mo.current){Kr(Mo.current),jr(null);let J=Mo.current;Mo.current=null,N(Be=>{let Pe=[...Be],Z=Pe.reverse().find(ne=>ne.text?.includes("[STEERING HINT: QUEUED]")||ne.text?.includes("[QUESTION: QUEUED]"));return Z&&(Z.text.includes("[STEERING HINT: QUEUED]")?Z.text=Z.text.replace("[STEERING HINT: QUEUED]","[STEERING HINT: FINISHED_TURN]"):Z.text.includes("[QUESTION: QUEUED]")&&(Z.text=Z.text.replace("[QUESTION: QUEUED]","[QUESTION: FINISHED_TURN]"))),Pe.reverse()}),W("resolution")}N(J=>{let Be=Date.now()-_,Pe=!1,Z=[...J].reverse().map($e=>{let _e=$e.isStreaming?{...$e,isStreaming:!1}:$e;return _e.text&&(_e.text=(" "+_e.text).slice(1)),!Pe&&_e.role==="agent"&&(Pe=!0,_e={..._e,workedDuration:Be}),_e}).reverse();if(!Z.some($e=>$e.role==="agent"&&$e.text?.trim().length>0)){let $e=[...Z].reverse().find(_e=>_e.role==="think"&&_e.text?.trim().length>0);$e&&Z.push({id:"agent-fallback-"+Date.now(),role:"agent",text:$e.text,isStreaming:!1,workedDuration:Be})}let ot=Z.filter($e=>!String($e.id).startsWith("welcome")&&(!$e.isMeta||$e.text&&$e.text.includes("Request Cancelled")));return dn(tt,null,ot),Y(Z.length),Z})}})()}m(""),v(!1)}},He=fn(()=>{if(E.startsWith("/")&&!z){let c=E.split(" "),b=c[c.length-1].toLowerCase();if(c.length===1){let d=b.startsWith("/")?b.slice(1):b;return ai.filter(p=>(p.cmd.startsWith("/")?p.cmd.slice(1):p.cmd).toLowerCase().includes(d))}let g=ai;for(let d=0;d<c.length-1;d++){let p=c[d].toLowerCase(),I=g.find(_=>_.cmd.toLowerCase()===p);if(I&&I.subs)g=I.subs;else return[]}return g.filter(d=>d.cmd.toLowerCase().includes(b))}let o=E.split(" "),n=o[o.length-1],a=n&&n.startsWith("\\@");if((n&&n.startsWith("@")||a)&&!z){let c=n.indexOf("#"),b=c!==-1,g=a?2:1,d=b?n.substring(g,c).toLowerCase():n.slice(g).toLowerCase(),p=b?n.substring(c):"";return Ud(process.cwd()).filter(q=>q.name.toLowerCase().includes(d)).map(q=>{let ue=q.relativePath.replace(/\\/g,"/"),J=ue.startsWith(".")?ue:"./"+ue;return{cmd:(a?"\\@":"@")+"["+J+p+"]",desc:q.relativePath}})}return[]},[E,z]);ze(()=>{let o=0;for(;o<He.length;){let n=He[o],a=n?.cmd||n||"";if(typeof a=="string"&&a.trimStart().startsWith("---"))o++;else break}ge(o<He.length?o:0)},[He]);let[or,nr]=Q(0),ci=Ve(0);ze(()=>{let o=ci.current>0,n=He.length>0;if(ci.current=He.length,!n){nr(0);return}if(!o){nr(1);return}nr(He.length)},[He]),ze(()=>{if(or>0&&or<He.length){let o=setTimeout(()=>{nr(n=>Math.min(n+1,He.length))},5);return()=>clearTimeout(o)}},[or,He.length]),ze(()=>{if(lt!=="providerBudgetSelect")return;let o=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","CrofAI","InferX","SenseNova","AIHubMix","Poolside"],n=Ie.providerBudgets||{},a=o.reduce((h,c)=>(h[c]=!!(n[c]&&(n[c].agentLimit||n[c].tokenLimit)),h),{});Is(a),Gn(0)},[lt]),ze(()=>{if(lt!=="providerBudgetFlow")return;let o={},n=Ie.providerBudgets||{};for(let a of Zo){let h=n[a]||{};o[a]={agentLimit:hn(h.agentLimit),tokenLimit:hn(h.tokenLimit),monthlyTokenLimit:hn(h.monthlyTokenLimit)}}Ir(o),go(0)},[lt,Zo]);let Zd=({label:o,isSelected:n})=>{let a=o==="Cancel"||o==="Back"||o.toLowerCase().includes("exit")||o.toLowerCase().includes("back");return e.createElement(u,{marginTop:a?1:0,backgroundColor:n?"#2a2a2a":void 0,paddingX:1,width:"100%"},e.createElement(s,{color:n?"white":"gray",bold:n},n?"\u276F ":" ",o))},sn=(o,n,a,h=10,c=2,b=9)=>{let g=a>0?Math.min(100,n/a*100):0,d=Math.round(g),p=Math.round(d/100*h),I="\u2588".repeat(p)+"\u2591".repeat(Math.max(0,h-p)),_=l.success||"green";d>=40&&d<=80?_=l.warning||"yellow":d>80&&(_=l.danger||"red");let q=o.toLowerCase().includes("token")||o.toLowerCase().includes("daily")||o.toLowerCase().includes("monthly"),ue=Hn(a)?"\u221E":q?ut(a):a,J=q?ut(n):n,Be;return g===0?Be="0%":g>0&&g<1?Be="<1%":Be=`${d}%`,e.createElement(u,{flexDirection:"row",paddingLeft:c,key:o},e.createElement(u,{width:b},e.createElement(s,{color:l.textMuted},o,": ")),e.createElement(s,{color:_},I),e.createElement(s,{color:l.textMuted}," ",Be," (",J,"/",ue,")"))},Kl=()=>{switch(lt){case"settings":return e.createElement(wr,{systemSettings:ce,setSystemSettings:Dt,apiTier:Re,setActiveView:W,setInputConfig:qt,saveSettings:kt,quotas:Ie,setMessages:N,aiProvider:P,setProviderReturnView:vr});case"theme":return e.createElement(wr,{systemSettings:ce,setSystemSettings:Dt,apiTier:Re,setActiveView:W,setInputConfig:qt,saveSettings:kt,quotas:Ie,setMessages:N,aiProvider:P,initialSelectingTheme:!0,onCloseTheme:()=>W("chat"),setProviderReturnView:vr});case"selectProvider":return e.createElement(gt,{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:"CrofAI",value:"CrofAI"},{label:"Poolside",value:"Poolside"},...process.env.ENABLE_9ROUTER==="true"||process.env.ENABLE_9ROUTER===!0?[{label:"9router",value:"9router"}]:[],{label:"Ollama",value:"Ollama"},{label:"AIHubMix [EXPERIMENTAL]",value:"AIHubMix"},{label:"Mistral [EXPERIMENTAL]",value:"Mistral"},{label:"OpenRouter [EXPERIMENTAL]",value:"OpenRouter"},{label:"Back",value:Jo}],theme:ce.theme,onSelect:async o=>{if(o.value===Jo||o.value==="settings"||o.value==="Back"){W(Jo);return}let n=o.value,a=await ln(n);if(a){vt(n),Kt(a),On(a,{aiProvider:n,onIDEApproval:Zn});let h=(Ie.providerTiers||{})[n]||"Free",c=ro(n,h);ie(c),$o(h),n==="NVIDIA"&&process.env.NVIDIA_BASE_URL||n==="Ollama"||n==="CrofAI"||n==="InferX"||n==="SenseNova"||n==="Poolside"||n==="9router"?(Dt(b=>({...b,memory:!1})),kt({aiProvider:n,activeModel:c,apiTier:h,quotas:Ie,systemSettings:{...ce,memory:!1}})):kt({aiProvider:n,activeModel:c,apiTier:h,quotas:Ie}),N(b=>[...b,{role:"system",text:`\u2726 Switched to ${n} (cached)!${c?`
192
192
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: ${c}.`:""}${(n==="Ollama"||n==="CrofAI"||n==="InferX"||n==="SenseNova"||n==="AIHubMix"||n==="Poolside"||n==="9router")&&ce.memory?`
193
193
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with ${n}.`:""}${n==="NVIDIA"&&process.env.NVIDIA_BASE_URL&&ce.memory?`
194
194
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with Custom Endpoints.`:""}
195
- \u2800`,isMeta:!0}]),W(Jo)}else qt({label:`Enter ${n} API Key:`,key:"providerKey",provider:n,value:"",returnView:Jo}),W("input")},onClose:()=>W(Jo)});case"apiTier":return e.createElement(gt,{title:`Show Paid models from ${P.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] ${Re==="Paid"?"\u25CF":""}`,value:"Paid"},{label:"Back",value:"settings"}],theme:ce.theme,onSelect:o=>{if(o.value==="settings"||o.value==="Back"){W("settings");return}let n=o.value;$o(n);let a={...Ie.providerTiers||{},[P]:n},h={...Ie,providerTiers:a};$t(h),kt({apiTier:n,quotas:h}),W("settings")}});case"resetMode":return e.createElement(gt,{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:ce.theme,onSelect:o=>{if(o.value==="apiTier"||o.value==="Back"){W("apiTier");return}let n=o.value,a={...Ie,resetMode:n};$t(a),n==="Custom"?(qt({label:"Enter monthly reset day (1-30):",key:"quotas",subKey:"resetDay",value:String(Ie.resetDay||1),returnView:"settings"}),W("input")):(kt({apiTier:Re,quotas:a}),W("settings"))},onClose:()=>W("apiTier")});case"budgetTypeSelect":return e.createElement(gt,{title:"SELECT BUDGET TYPE",items:[{label:`Global Budget (single limit for all providers) ${Re==="Paid"&&!Ie.providerBudgets?.__useProvider?"\u25CF":""}`,value:"global"},{label:`Provider Budgets (set limits per provider individually) ${Ie.providerBudgets?.__useProvider?"\u25CF":""}`,value:"provider"},{label:"Back",value:yo}],theme:ce.theme,onSelect:o=>{if(o.value===yo||o.value==="Back"){W(yo);return}if(o.value==="global"){let n={...Ie,agentLimit:99999999,tokenLimit:99999999999999,monthlyTokenLimit:99999999999999,providerBudgets:{__useProvider:!1}};$t(n);let a=yo==="settings"?"resetMode":"budgetResetMode";qt({label:"Enter Agent daily budget (requests made):",key:"quotas",subKey:"agentLimit",value:hn(n.agentLimit),returnView:yo,next:h=>({label:"Enter Agent daily budget (tokens used):",key:"quotas",subKey:"tokenLimit",value:hn(h.tokenLimit),returnView:yo,next:c=>({label:"Enter Agent monthly budget (tokens used):",key:"quotas",subKey:"monthlyTokenLimit",value:hn(c.monthlyTokenLimit),returnView:a})})}),W("input")}else if(o.value==="provider"){let n={...Ie,agentLimit:99999999,tokenLimit:99999999999999,monthlyTokenLimit:99999999999999,providerBudgets:{...Ie.providerBudgets||{},__useProvider:!0}};$t(n),W("providerBudgetSelect")}},onClose:()=>W(yo)});case"providerBudgetSelect":{let o=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","CrofAI","InferX","SenseNova","AIHubMix","Poolside"],n=o.some(a=>Dr[a]);return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,padding:0,width:"100%"},e.createElement(u,{paddingX:1,marginBottom:1},e.createElement(s,{color:l.text,bold:!0},"SELECT PROVIDERS TO SET LIMMITS FOR")),o.map((a,h)=>{let c=h===ks,b=!!Dr[a];return e.createElement(u,{key:a,backgroundColor:c?l.highlightBg||"#2a2a2a":void 0,paddingX:1,width:"100%",flexDirection:"row"},e.createElement(s,{color:c?l.text:l.textMuted,bold:c},c?"\u276F ":" "),e.createElement(s,{color:b?l.success||"green":l.textMuted},b?"\u2611":"\u2610"),e.createElement(s,{color:c?l.text:l.textMuted,bold:c}," ",a),b&&Ie.providerBudgets?.[a]?.agentLimit?e.createElement(s,{color:l.primary||"cyan"}," (budget set)"):null)}),e.createElement(u,{paddingX:1,marginTop:1,flexDirection:"column"},e.createElement(s,{color:l.textMuted,italic:!0},"\u2191\u2193 Navigate \u2022 Space to toggle \u2022 Enter to confirm \u2022 ESC to go back"),!n&&e.createElement(s,{color:l.warning||"yellow",italic:!0}," Select at least one provider to continue")))}case"providerBudgetFlow":{let o=Zo.length,n=o*2;return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,padding:0,width:"100%"},e.createElement(u,{paddingX:1,marginBottom:0,justifyContent:"space-between",flexDirection:"row"},e.createElement(s,{color:l.text,bold:!0},"PROVIDER BUDGET CONFIGURATION"),e.createElement(s,{color:l.textMuted,italic:!0},"(0 or blank = unlimited)")),e.createElement(u,{paddingX:1,marginTop:1,flexDirection:"row"},e.createElement(u,{width:14},e.createElement(s,{color:l.textMuted,bold:!0},"PROVIDER")),e.createElement(u,{width:30,paddingLeft:1},e.createElement(s,{color:l.textMuted,bold:!0},"DAILY TOKENS (/day)")),e.createElement(u,{width:30,paddingLeft:1},e.createElement(s,{color:l.textMuted,bold:!0},"MONTHLY TOKENS (/month)"))),e.createElement(u,{paddingX:1},e.createElement(s,{color:l.borderMuted},"\u2500".repeat(74))),Zo.map((a,h)=>{let c=h*2,b=h*2+1,g=Wn===c,d=Wn===b,p=g||d,I=kr[a]?.tokenLimit??"",_=kr[a]?.monthlyTokenLimit??"";return e.createElement(u,{key:a,flexDirection:"row",paddingX:1,marginY:0,backgroundColor:p?l.highlightBg||"#2a2a2a":void 0},e.createElement(u,{width:14,flexDirection:"row"},e.createElement(s,{color:p?l.primary||"cyan":l.text,bold:p},p?"\u276F ":" ",a)),e.createElement(u,{width:30,paddingLeft:1,flexDirection:"row"},g?e.createElement(u,{flexDirection:"row"},e.createElement(s,{color:l.primary||"cyan",bold:!0},"[ "),e.createElement(Sr,{value:I,onChange:q=>{Ir(ue=>({...ue,[a]:{...ue[a]||{},tokenLimit:q}}))},onSubmit:()=>{go(b)}}),e.createElement(s,{color:l.primary||"cyan",bold:!0}," ]")):e.createElement(s,{color:I?l.text:l.textMuted},"[ ",I||"0 (Unlimited)"," ]")),e.createElement(u,{width:30,paddingLeft:1,flexDirection:"row"},d?e.createElement(u,{flexDirection:"row"},e.createElement(s,{color:l.primary||"cyan",bold:!0},"[ "),e.createElement(Sr,{value:_,onChange:q=>{Ir(ue=>({...ue,[a]:{...ue[a]||{},monthlyTokenLimit:q}}))},onSubmit:()=>{h+1<o?go((h+1)*2):go(n)}}),e.createElement(s,{color:l.primary||"cyan",bold:!0}," ]")):e.createElement(s,{color:_?l.text:l.textMuted},"[ ",_||"0 (Unlimited)"," ]")))}),e.createElement(u,{paddingX:1,marginTop:1},Wn===n?e.createElement(u,{backgroundColor:l.highlightBg||"#2a2a2a",paddingX:1},e.createElement(s,{color:l.success||"green",bold:!0},"\u276F [ Save & Apply Budgets ]")):e.createElement(s,{color:l.textMuted}," [ Save & Apply Budgets ]")),e.createElement(u,{paddingX:1,marginTop:1,flexDirection:"column"},e.createElement(s,{color:l.textMuted,italic:!0},"\u2191\u2193/\u2190\u2192 Navigate \u2022 Enter next / save \u2022 ESC to go back")))}case"budgetResetMode":return e.createElement(gt,{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:ce.theme,onSelect:o=>{if(o.value==="chat"||o.value==="Back"){W("chat");return}let n=o.value,a={...Ie,resetMode:n};$t(a),n==="Custom"?(qt({label:"Enter monthly reset day (1-30):",key:"quotas",subKey:"resetDay",value:String(Ie.resetDay||1),returnView:"chat"}),W("input")):(kt({apiTier:Re,quotas:a}),W("chat"))},onClose:()=>W("chat")});case"budgetView":{let o=Tn?.agent||0,n=Ie.agentLimit||99999999,a=Tn?.tokens||0,h=Ie.tokenLimit||99999999999999,c=Ie.resetMode==="Custom"?Nr?.tokens||0:Qn?.tokens||0,b=Ie.monthlyTokenLimit||99999999999999,g=Re!=="Paid",d=!!Ie.providerBudgets?.__useProvider,p=Ie.providerBudgets||{},I=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","CrofAI","InferX","SenseNova","AIHubMix","Poolside"].filter(J=>p[J]&&(p[J].agentLimit||p[J].tokenLimit||p[J].monthlyTokenLimit)),_=!d&&(Hn(n)||Hn(h)||Hn(b)),q="",ue="";if(Ie.resetMode==="Custom"){let J=new Date,Be=Ie.resetDay||1,Pe=J.getFullYear(),Z=J.getMonth();J.getDate()>=Be&&(Z+=1,Z>11&&(Z=0,Pe+=1));let ne=new Date(Pe,Z,Be,0,0,0);q=`${ne.toLocaleString("default",{month:"short"}).toUpperCase()}-${Be}`;let $e=Math.max(0,ne.getTime()-J.getTime()),_e=Math.floor($e/(1e3*60*60)),nt=Math.floor(_e/24),At=_e%24;ue=`(${nt} days: ${At} hrs left)`}return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,padding:1,paddingBottom:0,paddingTop:0,width:"100%"},e.createElement(u,{marginBottom:1,justifyContent:"space-between",width:"100%"},e.createElement(s,{color:l.text,bold:!0,underline:!0},"USAGE LIMITS"),e.createElement(s,{color:l.textMuted},"[ ESC to Close ]")),_?e.createElement(u,{padding:1,justifyContent:"center",alignItems:"center",width:"100%"},e.createElement(s,{color:l.text,bold:!0},"LIMITS NOT SET")):d&&I.length>0?e.createElement(u,{flexDirection:"column",gap:0,width:"100%"},(()=>{let J=i?.columns||X?.columns||80;if(J<115){let Z=Math.max(5,Math.min(30,J-50));return I.map(ne=>{let ot=p[ne],$e=0,_e=Tn?.models?.[ne]||{};for(let ct in _e)$e+=_e[ct]?.tokens||0;let nt=0,rt=(Ie.resetMode==="Custom"?Nr:Qn)?.models?.[ne]||{};for(let ct in rt)nt+=rt[ct]?.tokens||0;return e.createElement(u,{key:ne,flexDirection:"column",borderStyle:"single",borderColor:l.borderMuted,paddingX:1,width:"100%"},e.createElement(u,{marginBottom:0},e.createElement(s,{color:l.primary,bold:!0},"\u25C6 ",ne)),sn("Daily",$e,ot.tokenLimit||99999999999999,Z,2,9),sn("Monthly",nt,ot.monthlyTokenLimit||99999999999999,Z,2,9))})}let Pe=[];for(let Z=0;Z<I.length;Z+=2)Pe.push(I.slice(Z,Z+2));return Pe.map((Z,ne)=>e.createElement(u,{key:ne,flexDirection:"row",width:"100%"},Z.map(ot=>{let $e=p[ot],_e=0,nt=Tn?.models?.[ot]||{};for(let U in nt)_e+=nt[U]?.tokens||0;let At=0,ct=(Ie.resetMode==="Custom"?Nr:Qn)?.models?.[ot]||{};for(let U in ct)At+=ct[U]?.tokens||0;let St=Z.length===1,Eo=St?J:Math.floor(J/2),vo=Math.max(5,Math.min(25,Eo-36));return e.createElement(u,{key:ot,flexDirection:"column",borderStyle:"single",borderColor:l.borderMuted,paddingX:1,width:St?"100%":"50%"},e.createElement(u,{marginBottom:0},e.createElement(s,{color:l.primary,bold:!0},"\u25C6 ",ot)),sn("Daily",_e,$e.tokenLimit||99999999999999,vo,2,9),sn("Monthly",At,$e.monthlyTokenLimit||99999999999999,vo,2,9))})))})(),q?e.createElement(u,{marginLeft:2,marginTop:1},e.createElement(s,{color:l.textMuted},"Monthly Reset: "),e.createElement(s,{color:l.accent||"magenta",bold:!0},q),ue?e.createElement(s,{color:l.textMuted},` ${ue}`):null):e.createElement(u,{marginLeft:2,marginTop:1},e.createElement(s,{color:l.textMuted},"Monthly Reset: "),e.createElement(s,{color:l.secondary||"blue",bold:!0},"Rolling 30-Day Window"))):e.createElement(u,{flexDirection:"column",borderStyle:"single",borderColor:l.borderMuted,paddingX:1,width:"100%"},sn("Daily Tokens",a,h,"green"),sn("Monthly Tokens",c,b,"yellow"),q?e.createElement(u,{marginLeft:4,marginTop:1},e.createElement(s,{color:l.textMuted},"Monthly Reset: "),e.createElement(s,{color:l.accent||"magenta",bold:!0},q),ue?e.createElement(s,{color:l.textMuted},` ${ue}`):null):e.createElement(u,{marginLeft:4,marginTop:1},e.createElement(s,{color:l.textMuted},"Monthly Reset: "),e.createElement(s,{color:l.secondary||"blue",bold:!0},"Rolling 30-Day Window"))))}case"input":return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,padding:0,width:"100%"},e.createElement(u,{paddingX:1},e.createElement(s,{color:l.text,bold:!0},"DATA CONFIGURATION")),bo?.note&&e.createElement(u,{paddingX:1,marginBottom:1},e.createElement(s,{color:l.textMuted,italic:!0},bo.note)),e.createElement(u,{paddingX:1,flexDirection:"row"},e.createElement(s,{color:l.text,bold:!0},bo?.label," "),e.createElement(Sr,{value:bo?.value||"",onChange:o=>qt(n=>({...n,value:o})),onSubmit:async o=>{let{key:n,subKey:a,next:h,onDone:c}=bo,b={...Ie},g={};if(n==="quotas"){let d=a.toLowerCase().includes("limit")||a==="resetDay"?parseInt(o)||0:o;a==="resetDay"&&(d=Math.max(1,Math.min(30,d))),b[a]=d,$t(b),g.quotas=b}else if(n==="providerBudgets"){let d=bo.providerKey,p=a.toLowerCase().includes("limit")?parseInt(o)||0:o,I=b.providerBudgets||{};b.providerBudgets={...I,[d]:{...I[d]||{},[a]:p}},$t(b),g.quotas=b}else if(n==="activeModel")ie(o),g.activeModel=o;else if(n==="janitorModel")Xe(o),g.janitorModel=o;else if(n==="autoApproveCommands"||n==="autoDisallowCommands"||n==="alwaysAskCommands"){let d={...ce,[n]:o.trim(),sandboxPreset:"Custom"};Dt(d),g.systemSettings=d}else if(n==="externalDataPath"){let d={...ce,useExternalData:!0,externalDataPath:o.trim()};Dt(d),g.systemSettings=d,N(p=>[...p,{id:Date.now(),role:"system",text:"[EXTERNAL STORAGE] Flux Flow will use "+o.trim()+" for data after restart."}])}else if(n==="imageSettings"){let d=o.trim();if(d.startsWith("sk_")){let p={...So,apiKey:d};Yn(p),g.imageSettings=p,N(I=>(Y(I.length+1),[...I,{id:Date.now(),role:"system",text:"[IMAGE KEY] Custom API key saved successfully.",isMeta:!0}]))}}else if(n==="providerKey"){let d=o.trim(),p=bo.provider;(p==="Ollama"||p==="9router")&&(d==="LOCAL"||d==="")&&(d="LOCAL",p==="Ollama"&&(Dt(q=>({...q,ollamaEndpoint:"Local"})),g.systemSettings={...ce,ollamaEndpoint:"Local"})),await Zr(p,d),vt(p),Kt(d),On(d,{aiProvider:p,onIDEApproval:Zn});let I=(Ie.providerTiers||{})[p]||"Free",_=ro(p,I);ie(_),$o(I),g.aiProvider=p,g.activeModel=_,g.apiTier=I,(p==="NVIDIA"&&process.env.NVIDIA_BASE_URL||p==="Ollama"||p==="CrofAI"||p==="InferX"||p==="SenseNova"||p==="AIHubMix"||p==="Poolside"||p==="9router")&&(Dt(q=>({...q,memory:!1})),g.systemSettings={...ce,memory:!1}),N(q=>(Y(q.length+1),[...q,{id:Date.now(),role:"system",text:`\u2726 ${p} API Key saved successfully! ${_?`
195
+ \u2800`,isMeta:!0}]),W(Jo)}else qt({label:`Enter ${n} API Key:`,key:"providerKey",provider:n,value:"",returnView:Jo}),W("input")},onClose:()=>W(Jo)});case"apiTier":return e.createElement(gt,{title:`Show Paid models from ${P.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] ${Re==="Paid"?"\u25CF":""}`,value:"Paid"},{label:"Back",value:"settings"}],theme:ce.theme,onSelect:o=>{if(o.value==="settings"||o.value==="Back"){W("settings");return}let n=o.value;$o(n);let a={...Ie.providerTiers||{},[P]:n},h={...Ie,providerTiers:a};$t(h),kt({apiTier:n,quotas:h}),W("settings")}});case"resetMode":return e.createElement(gt,{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:ce.theme,onSelect:o=>{if(o.value==="apiTier"||o.value==="Back"){W("apiTier");return}let n=o.value,a={...Ie,resetMode:n};$t(a),n==="Custom"?(qt({label:"Enter monthly reset day (1-30):",key:"quotas",subKey:"resetDay",value:String(Ie.resetDay||1),returnView:"settings"}),W("input")):(kt({apiTier:Re,quotas:a}),W("settings"))},onClose:()=>W("apiTier")});case"budgetTypeSelect":return e.createElement(gt,{title:"SELECT BUDGET TYPE",items:[{label:`Global Budget (single limit for all providers) ${Re==="Paid"&&!Ie.providerBudgets?.__useProvider?"\u25CF":""}`,value:"global"},{label:`Provider Budgets (set limits per provider individually) ${Ie.providerBudgets?.__useProvider?"\u25CF":""}`,value:"provider"},{label:"Back",value:yo}],theme:ce.theme,onSelect:o=>{if(o.value===yo||o.value==="Back"){W(yo);return}if(o.value==="global"){let n={...Ie,agentLimit:99999999,tokenLimit:99999999999999,monthlyTokenLimit:99999999999999,providerBudgets:{__useProvider:!1}};$t(n);let a=yo==="settings"?"resetMode":"budgetResetMode";qt({label:"Enter Agent daily budget (requests made):",key:"quotas",subKey:"agentLimit",value:hn(n.agentLimit),returnView:yo,next:h=>({label:"Enter Agent daily budget (tokens used):",key:"quotas",subKey:"tokenLimit",value:hn(h.tokenLimit),returnView:yo,next:c=>({label:"Enter Agent monthly budget (tokens used):",key:"quotas",subKey:"monthlyTokenLimit",value:hn(c.monthlyTokenLimit),returnView:a})})}),W("input")}else if(o.value==="provider"){let n={...Ie,agentLimit:99999999,tokenLimit:99999999999999,monthlyTokenLimit:99999999999999,providerBudgets:{...Ie.providerBudgets||{},__useProvider:!0}};$t(n),W("providerBudgetSelect")}},onClose:()=>W(yo)});case"providerBudgetSelect":{let o=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","CrofAI","InferX","SenseNova","AIHubMix","Poolside"],n=o.some(a=>Dr[a]);return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,padding:0,width:"100%"},e.createElement(u,{paddingX:1,marginBottom:1},e.createElement(s,{color:l.text,bold:!0},"SELECT PROVIDERS TO SET LIMMITS FOR")),o.map((a,h)=>{let c=h===ks,b=!!Dr[a];return e.createElement(u,{key:a,backgroundColor:c?l.highlightBg||"#2a2a2a":void 0,paddingX:1,width:"100%",flexDirection:"row"},e.createElement(s,{color:c?l.text:l.textMuted,bold:c},c?"\u276F ":" "),e.createElement(s,{color:b?l.success||"green":l.textMuted},b?"\u2611":"\u2610"),e.createElement(s,{color:c?l.text:l.textMuted,bold:c}," ",a),b&&Ie.providerBudgets?.[a]?.agentLimit?e.createElement(s,{color:l.primary||"cyan"}," (budget set)"):null)}),e.createElement(u,{paddingX:1,marginTop:1,flexDirection:"column"},e.createElement(s,{color:l.textMuted,italic:!0},"\u2191\u2193 Navigate \u2022 Space to toggle \u2022 Enter to confirm \u2022 ESC to go back"),!n&&e.createElement(s,{color:l.warning||"yellow",italic:!0}," Select at least one provider to continue")))}case"providerBudgetFlow":{let o=Zo.length,n=o*2;return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,padding:0,width:"100%"},e.createElement(u,{paddingX:1,marginBottom:0,justifyContent:"space-between",flexDirection:"row"},e.createElement(s,{color:l.text,bold:!0},"PROVIDER BUDGET CONFIGURATION"),e.createElement(s,{color:l.textMuted,italic:!0},"(0 or blank = unlimited)")),e.createElement(u,{paddingX:1,marginTop:1,flexDirection:"row"},e.createElement(u,{width:14},e.createElement(s,{color:l.textMuted,bold:!0},"PROVIDER")),e.createElement(u,{width:30,paddingLeft:1},e.createElement(s,{color:l.textMuted,bold:!0},"DAILY TOKENS (/day)")),e.createElement(u,{width:30,paddingLeft:1},e.createElement(s,{color:l.textMuted,bold:!0},"MONTHLY TOKENS (/month)"))),e.createElement(u,{paddingX:1},e.createElement(s,{color:l.borderMuted},"\u2500".repeat(74))),Zo.map((a,h)=>{let c=h*2,b=h*2+1,g=Wn===c,d=Wn===b,p=g||d,I=kr[a]?.tokenLimit??"",_=kr[a]?.monthlyTokenLimit??"";return e.createElement(u,{key:a,flexDirection:"row",paddingX:1,marginY:0,backgroundColor:p?l.highlightBg||"#2a2a2a":void 0},e.createElement(u,{width:14,flexDirection:"row"},e.createElement(s,{color:p?l.primary||"cyan":l.text,bold:p},p?"\u276F ":" ",a)),e.createElement(u,{width:30,paddingLeft:1,flexDirection:"row"},g?e.createElement(u,{flexDirection:"row"},e.createElement(s,{color:l.primary||"cyan",bold:!0},"[ "),e.createElement(Sr,{value:I,onChange:q=>{Ir(ue=>({...ue,[a]:{...ue[a]||{},tokenLimit:q}}))},onSubmit:()=>{go(b)}}),e.createElement(s,{color:l.primary||"cyan",bold:!0}," ]")):e.createElement(s,{color:I?l.text:l.textMuted},"[ ",I||"0 (Unlimited)"," ]")),e.createElement(u,{width:30,paddingLeft:1,flexDirection:"row"},d?e.createElement(u,{flexDirection:"row"},e.createElement(s,{color:l.primary||"cyan",bold:!0},"[ "),e.createElement(Sr,{value:_,onChange:q=>{Ir(ue=>({...ue,[a]:{...ue[a]||{},monthlyTokenLimit:q}}))},onSubmit:()=>{h+1<o?go((h+1)*2):go(n)}}),e.createElement(s,{color:l.primary||"cyan",bold:!0}," ]")):e.createElement(s,{color:_?l.text:l.textMuted},"[ ",_||"0 (Unlimited)"," ]")))}),e.createElement(u,{paddingX:1,marginTop:1},Wn===n?e.createElement(u,{backgroundColor:l.highlightBg||"#2a2a2a",paddingX:1},e.createElement(s,{color:l.success||"green",bold:!0},"\u276F [ Save & Apply Budgets ]")):e.createElement(s,{color:l.textMuted}," [ Save & Apply Budgets ]")),e.createElement(u,{paddingX:1,marginTop:1,flexDirection:"column"},e.createElement(s,{color:l.textMuted,italic:!0},"\u2191\u2193/\u2190\u2192 Navigate \u2022 Enter next / save \u2022 ESC to go back")))}case"budgetResetMode":return e.createElement(gt,{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:ce.theme,onSelect:o=>{if(o.value==="chat"||o.value==="Back"){W("chat");return}let n=o.value,a={...Ie,resetMode:n};$t(a),n==="Custom"?(qt({label:"Enter monthly reset day (1-30):",key:"quotas",subKey:"resetDay",value:String(Ie.resetDay||1),returnView:"chat"}),W("input")):(kt({apiTier:Re,quotas:a}),W("chat"))},onClose:()=>W("chat")});case"budgetView":{let o=Tn?.agent||0,n=Ie.agentLimit||99999999,a=Tn?.tokens||0,h=Ie.tokenLimit||99999999999999,c=Ie.resetMode==="Custom"?Nr?.tokens||0:Qn?.tokens||0,b=Ie.monthlyTokenLimit||99999999999999,g=Re!=="Paid",d=!!Ie.providerBudgets?.__useProvider,p=Ie.providerBudgets||{},I=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","CrofAI","InferX","SenseNova","AIHubMix","Poolside"].filter(J=>p[J]&&(p[J].agentLimit||p[J].tokenLimit||p[J].monthlyTokenLimit)),_=!d&&(Hn(n)||Hn(h)||Hn(b)),q="",ue="";if(Ie.resetMode==="Custom"){let J=new Date,Be=Ie.resetDay||1,Pe=J.getFullYear(),Z=J.getMonth();J.getDate()>=Be&&(Z+=1,Z>11&&(Z=0,Pe+=1));let ne=new Date(Pe,Z,Be,0,0,0);q=`${ne.toLocaleString("default",{month:"short"}).toUpperCase()}-${Be}`;let $e=Math.max(0,ne.getTime()-J.getTime()),_e=Math.floor($e/(1e3*60*60)),nt=Math.floor(_e/24),At=_e%24;ue=`(${nt} days: ${At} hrs left)`}return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,padding:1,paddingBottom:0,paddingTop:0,width:"100%"},e.createElement(u,{marginBottom:1,justifyContent:"space-between",width:"100%"},e.createElement(s,{color:l.text,bold:!0,underline:!0},"USAGE LIMITS"),e.createElement(s,{color:l.textMuted},"[ ESC to Close ]")),_?e.createElement(u,{padding:1,justifyContent:"center",alignItems:"center",width:"100%"},e.createElement(s,{color:l.text,bold:!0},"LIMITS NOT SET")):d&&I.length>0?e.createElement(u,{flexDirection:"column",gap:0,width:"100%"},(()=>{let J=i?.columns||X?.columns||80;if(J<115){let Z=Math.max(5,Math.min(30,J-50));return I.map(ne=>{let ot=p[ne],$e=0,_e=Tn?.models?.[ne]||{};for(let ct in _e)$e+=_e[ct]?.tokens||0;let nt=0,rt=(Ie.resetMode==="Custom"?Nr:Qn)?.models?.[ne]||{};for(let ct in rt)nt+=rt[ct]?.tokens||0;return e.createElement(u,{key:ne,flexDirection:"column",borderStyle:"single",borderColor:l.borderMuted,paddingX:1,width:"100%"},e.createElement(u,{marginBottom:0},e.createElement(s,{color:l.primary,bold:!0},"\u25C6 ",ne)),sn("Daily",$e,ot.tokenLimit||99999999999999,Z,2,9),sn("Monthly",nt,ot.monthlyTokenLimit||99999999999999,Z,2,9))})}let Pe=[];for(let Z=0;Z<I.length;Z+=2)Pe.push(I.slice(Z,Z+2));return Pe.map((Z,ne)=>e.createElement(u,{key:ne,flexDirection:"row",width:"100%"},Z.map(ot=>{let $e=p[ot],_e=0,nt=Tn?.models?.[ot]||{};for(let U in nt)_e+=nt[U]?.tokens||0;let At=0,ct=(Ie.resetMode==="Custom"?Nr:Qn)?.models?.[ot]||{};for(let U in ct)At+=ct[U]?.tokens||0;let Ct=Z.length===1,Eo=Ct?J:Math.floor(J/2),vo=Math.max(5,Math.min(25,Eo-36));return e.createElement(u,{key:ot,flexDirection:"column",borderStyle:"single",borderColor:l.borderMuted,paddingX:1,width:Ct?"100%":"50%"},e.createElement(u,{marginBottom:0},e.createElement(s,{color:l.primary,bold:!0},"\u25C6 ",ot)),sn("Daily",_e,$e.tokenLimit||99999999999999,vo,2,9),sn("Monthly",At,$e.monthlyTokenLimit||99999999999999,vo,2,9))})))})(),q?e.createElement(u,{marginLeft:2,marginTop:1},e.createElement(s,{color:l.textMuted},"Monthly Reset: "),e.createElement(s,{color:l.accent||"magenta",bold:!0},q),ue?e.createElement(s,{color:l.textMuted},` ${ue}`):null):e.createElement(u,{marginLeft:2,marginTop:1},e.createElement(s,{color:l.textMuted},"Monthly Reset: "),e.createElement(s,{color:l.secondary||"blue",bold:!0},"Rolling 30-Day Window"))):e.createElement(u,{flexDirection:"column",borderStyle:"single",borderColor:l.borderMuted,paddingX:1,width:"100%"},sn("Daily Tokens",a,h,"green"),sn("Monthly Tokens",c,b,"yellow"),q?e.createElement(u,{marginLeft:4,marginTop:1},e.createElement(s,{color:l.textMuted},"Monthly Reset: "),e.createElement(s,{color:l.accent||"magenta",bold:!0},q),ue?e.createElement(s,{color:l.textMuted},` ${ue}`):null):e.createElement(u,{marginLeft:4,marginTop:1},e.createElement(s,{color:l.textMuted},"Monthly Reset: "),e.createElement(s,{color:l.secondary||"blue",bold:!0},"Rolling 30-Day Window"))))}case"input":return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,padding:0,width:"100%"},e.createElement(u,{paddingX:1},e.createElement(s,{color:l.text,bold:!0},"DATA CONFIGURATION")),bo?.note&&e.createElement(u,{paddingX:1,marginBottom:1},e.createElement(s,{color:l.textMuted,italic:!0},bo.note)),e.createElement(u,{paddingX:1,flexDirection:"row"},e.createElement(s,{color:l.text,bold:!0},bo?.label," "),e.createElement(Sr,{value:bo?.value||"",onChange:o=>qt(n=>({...n,value:o})),onSubmit:async o=>{let{key:n,subKey:a,next:h,onDone:c}=bo,b={...Ie},g={};if(n==="quotas"){let d=a.toLowerCase().includes("limit")||a==="resetDay"?parseInt(o)||0:o;a==="resetDay"&&(d=Math.max(1,Math.min(30,d))),b[a]=d,$t(b),g.quotas=b}else if(n==="providerBudgets"){let d=bo.providerKey,p=a.toLowerCase().includes("limit")?parseInt(o)||0:o,I=b.providerBudgets||{};b.providerBudgets={...I,[d]:{...I[d]||{},[a]:p}},$t(b),g.quotas=b}else if(n==="activeModel")ie(o),g.activeModel=o;else if(n==="janitorModel")Xe(o),g.janitorModel=o;else if(n==="autoApproveCommands"||n==="autoDisallowCommands"||n==="alwaysAskCommands"){let d={...ce,[n]:o.trim(),sandboxPreset:"Custom"};Dt(d),g.systemSettings=d}else if(n==="externalDataPath"){let d={...ce,useExternalData:!0,externalDataPath:o.trim()};Dt(d),g.systemSettings=d,N(p=>[...p,{id:Date.now(),role:"system",text:"[EXTERNAL STORAGE] Flux Flow will use "+o.trim()+" for data after restart."}])}else if(n==="imageSettings"){let d=o.trim();if(d.startsWith("sk_")){let p={...So,apiKey:d};Yn(p),g.imageSettings=p,N(I=>(Y(I.length+1),[...I,{id:Date.now(),role:"system",text:"[IMAGE KEY] Custom API key saved successfully.",isMeta:!0}]))}}else if(n==="providerKey"){let d=o.trim(),p=bo.provider;(p==="Ollama"||p==="9router")&&(d==="LOCAL"||d==="")&&(d="LOCAL",p==="Ollama"&&(Dt(q=>({...q,ollamaEndpoint:"Local"})),g.systemSettings={...ce,ollamaEndpoint:"Local"})),await Zr(p,d),vt(p),Kt(d),On(d,{aiProvider:p,onIDEApproval:Zn});let I=(Ie.providerTiers||{})[p]||"Free",_=ro(p,I);ie(_),$o(I),g.aiProvider=p,g.activeModel=_,g.apiTier=I,(p==="NVIDIA"&&process.env.NVIDIA_BASE_URL||p==="Ollama"||p==="CrofAI"||p==="InferX"||p==="SenseNova"||p==="AIHubMix"||p==="Poolside"||p==="9router")&&(Dt(q=>({...q,memory:!1})),g.systemSettings={...ce,memory:!1}),N(q=>(Y(q.length+1),[...q,{id:Date.now(),role:"system",text:`\u2726 ${p} API Key saved successfully! ${_?`
196
196
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: ${_}`:""}${p==="Ollama"&&d==="LOCAL"?`
197
197
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Ollama Endpoint automatically switched to Local`:""}${p==="Ollama"||p==="CrofAI"||p==="InferX"||p==="SenseNova"||p==="AIHubMix"||p==="Poolside"||p==="9router"?`
198
198
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with ${p}`:""}${p==="NVIDIA"&&process.env.NVIDIA_BASE_URL?`
199
199
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available`:""}
200
- \u2800\u2800`,isMeta:!0}]))}if(h){let d=h(n==="quotas"||n==="providerBudgets"?b:o);qt(d)}else c?(kt({...g,apiTier:Re,quotas:b,imageSettings:g.imageSettings||So}),qt(null),c(b)):(kt({...g,apiTier:Re,quotas:b,imageSettings:g.imageSettings||So}),qt(null),W(bo?.returnView||"settings"))}})),e.createElement(u,{paddingX:1,marginTop:1},e.createElement(s,{color:l.textMuted,dimColor:!0,italic:!0},"(Press Enter to confirm selection)")));case"stats":{let o=en==="modelBreakdown"||en==="dailyModelBreakdown",n=en==="daily"||en==="dailyModelBreakdown",a=n?Tn:Qn,h=n?"TODAY's USAGE":"LAST 30 DAYS USAGE",c=n?"TODAY'S MODEL TOKEN BREAKDOWN":"30-DAY MODEL TOKEN BREAKDOWN",b="Wall Time:",g="Tokens Used:",d="Images Made:",p="Image Credits:",I="Code Changes:",_="Tool Calls:",q=Math.max(4,(i?.rows||X?.rows||24)-15),ue=($e,_e,nt,At,rt,ct=0,St=!1)=>{let Eo=i?.columns||X?.columns||80,vo=Math.min(125,Eo-2),U=Math.max(20,vo-6),me=Math.max(5,U-ct-nt.length-5),Ee=_e;Ee.length>me&&(Ee=Ee.substring(0,me-1)+"\u2026");let be=Math.max(2,U-ct-Ee.length-nt.length-2),Ye=" "+".".repeat(be)+" ",Ke=" ".repeat(ct);return e.createElement(u,{key:$e,width:U},e.createElement(s,{wrap:"truncate"},e.createElement(s,null,Ke),e.createElement(s,{color:At,bold:St},Ee),e.createElement(s,{color:l.textMuted,dimColor:!0},Ye),e.createElement(s,{color:rt,bold:St},nt)))},J=[],Be=a?.models;if(!Be||Object.keys(Be).length===0)J.push(e.createElement(u,{key:"empty",marginTop:1},e.createElement(s,{color:l.textMuted,italic:!0},"No model token usage recorded for ",n?"today":"the last 30 days",".")));else{let $e=(yn||"").trim(),_e="",nt="";if($e.includes(":")){let rt=$e.indexOf(":");_e=$e.substring(0,rt).trim().toLowerCase(),nt=$e.substring(rt+1).trim().toLowerCase()}else _e=$e.toLowerCase();let At=Object.entries(Be).sort(([rt],[ct])=>rt.localeCompare(ct,void 0,{sensitivity:"base"})).filter(([rt,ct])=>_e&&!rt.toLowerCase().includes(_e)?!1:nt?Object.keys(ct).some(St=>St.toLowerCase().includes(nt)):!0);At.length===0?J.push(e.createElement(u,{key:"no-matches",marginTop:1},e.createElement(s,{color:l.textMuted,italic:!0},'No results found matching "',yn,'".'))):At.forEach(([rt,ct],St)=>{let Eo=Object.entries(ct).sort(([U],[me])=>U.localeCompare(me,void 0,{sensitivity:"base"})).filter(([U])=>!nt||U.toLowerCase().includes(nt));if(Eo.length===0)return;let vo=Eo.reduce((U,[,me])=>U+(me.tokens||0),0);St>0&&J.length>0&&J.push(e.createElement(u,{key:`space-prov-${rt}`},e.createElement(s,null," "))),J.push(ue(`prov-${rt}`,`${rt}:`,ut(vo),l.primary,l.text,0,!0)),Eo.forEach(([U,me],Ee)=>{Ee>0&&J.push(e.createElement(u,{key:`space-mod-${rt}-${U}`},e.createElement(s,null," "))),J.push(ue(`mod-${rt}-${U}`,`\xBB ${U}:`,ut(me.tokens||0),l.secondary,l.text,2,!0)),J.push(ue(`in-${rt}-${U}`,"\xBB Input Tokens:",ut((me.tokens||0)-(me.candidateTokens||0)),l.textMuted,l.text,5,!1)),(me.cachedTokens||0)>0&&J.push(ue(`cache-${rt}-${U}`,"\xBB Cached:",ut(me.cachedTokens),l.textMuted,l.text,7,!1)),J.push(ue(`out-${rt}-${U}`,"\xBB Output Tokens:",ut(me.candidateTokens||0),l.textMuted,l.text,5,!1))})})}let Pe=J.length,Z=Math.max(0,Pe-q);Ne.current=Z;let ne=Math.min(Al,Z),ot=J.slice(ne,ne+q);return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,paddingX:3,paddingY:1,paddingBottom:0,width:Math.min(125,(i?.columns||100)-2)},o?e.createElement(u,{flexDirection:"column"},e.createElement(u,{justifyContent:"space-between"},e.createElement(s,{color:l.text,bold:!0,underline:!0},c),Pe>q&&e.createElement(s,{color:l.textMuted,dimColor:!0},"[",ne+1,"-",Math.min(Pe,ne+q)," of ",Pe,"] \u25B2\u25BC")),e.createElement(u,{marginTop:1},e.createElement(s,{color:l.secondary,bold:!0},"Filter (provider:model): "),e.createElement(s,{color:l.text},yn),e.createElement(s,{color:l.primary,bold:!0},"\u258A"),yn.length>0&&e.createElement(s,{color:l.textMuted,dimColor:!0,italic:!0}," (Type to search, Esc/Backspace to clear)")),e.createElement(u,{flexDirection:"column",height:q,marginTop:1},ot)):e.createElement(e.Fragment,null,e.createElement(u,{marginBottom:1},e.createElement(s,{color:l.text,bold:!0,underline:!0},"SESSION TELEMETRY")),e.createElement(u,{flexDirection:"column"},e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},"Session Duration:")),e.createElement(s,{color:l.text},Ho(Date.now()-Es))),Ps>0&&e.createElement(e.Fragment,null,e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},"Model Requests:")),e.createElement(s,{color:l.text},Ps)),e.createElement(u,{marginLeft:2},e.createElement(u,{width:23},e.createElement(s,{color:l.textMuted},"\xBB API Time:")),e.createElement(s,{color:l.text},Ho(jn))),e.createElement(u,{marginLeft:2},e.createElement(u,{width:23},e.createElement(s,{color:l.textMuted},"\xBB Tool Time:")),e.createElement(s,{color:l.text},Ho(Kn)))),Fs>0&&e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},"Memory Agent:")),e.createElement(s,{color:l.text},Fs)),Qt>0&&e.createElement(e.Fragment,null,e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},"Tokens Consumed:")),e.createElement(s,{color:l.text},ut(Qt))),e.createElement(u,{marginLeft:2},e.createElement(u,{width:23},e.createElement(s,{color:l.textMuted},"\xBB Input Tokens:")),e.createElement(s,{color:l.text},ut(Qt-Ro))),Vn>0&&e.createElement(u,{marginLeft:4},e.createElement(u,{width:21},e.createElement(s,{color:l.textMuted},"\xBB Cached:")),e.createElement(s,{color:l.text},ut(Vn))),Ro>0&&e.createElement(u,{marginLeft:2},e.createElement(u,{width:23},e.createElement(s,{color:l.textMuted},"\xBB Output Tokens:")),e.createElement(s,{color:l.text},ut(Ro)))),fo?.tokens>0&&e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},"Active Context:")),e.createElement(s,{color:l.text},ut(fo.tokens))),qn>0&&e.createElement(e.Fragment,null,e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},"Images Made:")),e.createElement(s,{color:l.text},qn)),e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},"Image Credits:")),e.createElement(s,{color:l.text},Number(((_s||0)*1e3).toFixed(0))," credits"))),e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},"Code Changes (Sess):")),e.createElement(s,{color:l.text},e.createElement(s,{color:l.success||"green"},"+",bt.linesAdded)," ",e.createElement(s,{color:l.danger||"red"},"-",bt.linesRemoved))),e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},"Tool Calls (Sess):")),e.createElement(s,{color:l.text},bt.toolSuccess+bt.toolFailure+bt.toolDenied," ( "),e.createElement(s,{color:l.success||"green"},"\u2714 ",bt.toolSuccess),e.createElement(s,{color:l.text}," "),e.createElement(s,{color:l.warning||"yellow"},"\u{1F6C7} ",bt.toolDenied),e.createElement(s,{color:l.text}," "),e.createElement(s,{color:l.danger||"red"},"\u2718 ",bt.toolFailure),e.createElement(s,{color:l.text}," )"))),e.createElement(u,{flexDirection:"column",marginTop:1},e.createElement(s,{color:l.text,bold:!0,underline:!0},h),e.createElement(u,{marginTop:1},e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},b)),e.createElement(s,{color:l.text},qs(a?.duration||0))),(a?.agent||0)>0&&e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},"Model Requests:")),e.createElement(s,{color:l.text},a?.agent||0)),(a?.background||0)>0&&e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},"Memory Agent:")),e.createElement(s,{color:l.text},a?.background||0)),(a?.tokens||0)>0&&e.createElement(e.Fragment,null,e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},g)),e.createElement(s,{color:l.text},ut(a?.tokens||0))),e.createElement(u,{marginLeft:2},e.createElement(u,{width:23},e.createElement(s,{color:l.textMuted},"\xBB Input Tokens:")),e.createElement(s,{color:l.text},ut((a?.tokens||0)-(a?.candidateTokens||0)))),(a?.cachedTokens||0)>0&&e.createElement(u,{marginLeft:4},e.createElement(u,{width:21},e.createElement(s,{color:l.textMuted},"\xBB Cached:")),e.createElement(s,{color:l.text},ut(a.cachedTokens))),(a?.candidateTokens||0)>0&&e.createElement(u,{marginLeft:2},e.createElement(u,{width:23},e.createElement(s,{color:l.textMuted},"\xBB Output Tokens:")),e.createElement(s,{color:l.text},ut(a.candidateTokens)))),(a?.imageCalls?.length||0)>0&&e.createElement(e.Fragment,null,e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},d)),e.createElement(s,{color:l.text},a.imageCalls.length)),e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},p)),e.createElement(s,{color:l.text},Number(((a.imageCalls.reduce(($e,_e)=>$e+_e.cost,0)||0)*1e3).toFixed(0))," credits"))),e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},I)),e.createElement(s,{color:l.text},e.createElement(s,{color:l.success||"green"},"+",a?.linesAdded||0)," ",e.createElement(s,{color:l.danger||"red"},"-",a?.linesRemoved||0))),e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},_)),e.createElement(s,{color:l.text},(a?.toolSuccess||0)+(a?.toolFailure||0)+(a?.toolDenied||0)," ( "),e.createElement(s,{color:l.success||"green"},"\u2714 ",a?.toolSuccess||0),e.createElement(s,{color:l.text}," "),e.createElement(s,{color:l.warning||"yellow"},"\u{1F6C7} ",a?.toolDenied||0),e.createElement(s,{color:l.text}," "),e.createElement(s,{color:l.danger||"red"},"\u2718 ",a?.toolFailure||0),e.createElement(s,{color:l.text}," )")))),e.createElement(s,{color:l.textMuted,dimColor:!0,italic:!0},`
200
+ \u2800\u2800`,isMeta:!0}]))}if(h){let d=h(n==="quotas"||n==="providerBudgets"?b:o);qt(d)}else c?(kt({...g,apiTier:Re,quotas:b,imageSettings:g.imageSettings||So}),qt(null),c(b)):(kt({...g,apiTier:Re,quotas:b,imageSettings:g.imageSettings||So}),qt(null),W(bo?.returnView||"settings"))}})),e.createElement(u,{paddingX:1,marginTop:1},e.createElement(s,{color:l.textMuted,dimColor:!0,italic:!0},"(Press Enter to confirm selection)")));case"stats":{let o=en==="modelBreakdown"||en==="dailyModelBreakdown",n=en==="daily"||en==="dailyModelBreakdown",a=n?Tn:Qn,h=n?"TODAY's USAGE":"LAST 30 DAYS USAGE",c=n?"TODAY'S MODEL TOKEN BREAKDOWN":"30-DAY MODEL TOKEN BREAKDOWN",b="Wall Time:",g="Tokens Used:",d="Images Made:",p="Image Credits:",I="Code Changes:",_="Tool Calls:",q=Math.max(4,(i?.rows||X?.rows||24)-15),ue=($e,_e,nt,At,rt,ct=0,Ct=!1)=>{let Eo=i?.columns||X?.columns||80,vo=Math.min(125,Eo-2),U=Math.max(20,vo-6),me=Math.max(5,U-ct-nt.length-5),Ee=_e;Ee.length>me&&(Ee=Ee.substring(0,me-1)+"\u2026");let be=Math.max(2,U-ct-Ee.length-nt.length-2),Ye=" "+".".repeat(be)+" ",Ke=" ".repeat(ct);return e.createElement(u,{key:$e,width:U},e.createElement(s,{wrap:"truncate"},e.createElement(s,null,Ke),e.createElement(s,{color:At,bold:Ct},Ee),e.createElement(s,{color:l.textMuted,dimColor:!0},Ye),e.createElement(s,{color:rt,bold:Ct},nt)))},J=[],Be=a?.models;if(!Be||Object.keys(Be).length===0)J.push(e.createElement(u,{key:"empty",marginTop:1},e.createElement(s,{color:l.textMuted,italic:!0},"No model token usage recorded for ",n?"today":"the last 30 days",".")));else{let $e=(yn||"").trim(),_e="",nt="";if($e.includes(":")){let rt=$e.indexOf(":");_e=$e.substring(0,rt).trim().toLowerCase(),nt=$e.substring(rt+1).trim().toLowerCase()}else _e=$e.toLowerCase();let At=Object.entries(Be).sort(([rt],[ct])=>rt.localeCompare(ct,void 0,{sensitivity:"base"})).filter(([rt,ct])=>_e&&!rt.toLowerCase().includes(_e)?!1:nt?Object.keys(ct).some(Ct=>Ct.toLowerCase().includes(nt)):!0);At.length===0?J.push(e.createElement(u,{key:"no-matches",marginTop:1},e.createElement(s,{color:l.textMuted,italic:!0},'No results found matching "',yn,'".'))):At.forEach(([rt,ct],Ct)=>{let Eo=Object.entries(ct).sort(([U],[me])=>U.localeCompare(me,void 0,{sensitivity:"base"})).filter(([U])=>!nt||U.toLowerCase().includes(nt));if(Eo.length===0)return;let vo=Eo.reduce((U,[,me])=>U+(me.tokens||0),0);Ct>0&&J.length>0&&J.push(e.createElement(u,{key:`space-prov-${rt}`},e.createElement(s,null," "))),J.push(ue(`prov-${rt}`,`${rt}:`,ut(vo),l.primary,l.text,0,!0)),Eo.forEach(([U,me],Ee)=>{Ee>0&&J.push(e.createElement(u,{key:`space-mod-${rt}-${U}`},e.createElement(s,null," "))),J.push(ue(`mod-${rt}-${U}`,`\xBB ${U}:`,ut(me.tokens||0),l.secondary,l.text,2,!0)),J.push(ue(`in-${rt}-${U}`,"\xBB Input Tokens:",ut((me.tokens||0)-(me.candidateTokens||0)),l.textMuted,l.text,5,!1)),(me.cachedTokens||0)>0&&J.push(ue(`cache-${rt}-${U}`,"\xBB Cached:",ut(me.cachedTokens),l.textMuted,l.text,7,!1)),J.push(ue(`out-${rt}-${U}`,"\xBB Output Tokens:",ut(me.candidateTokens||0),l.textMuted,l.text,5,!1))})})}let Pe=J.length,Z=Math.max(0,Pe-q);Ne.current=Z;let ne=Math.min(Al,Z),ot=J.slice(ne,ne+q);return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,paddingX:3,paddingY:1,paddingBottom:0,width:Math.min(125,(i?.columns||100)-2)},o?e.createElement(u,{flexDirection:"column"},e.createElement(u,{justifyContent:"space-between"},e.createElement(s,{color:l.text,bold:!0,underline:!0},c),Pe>q&&e.createElement(s,{color:l.textMuted,dimColor:!0},"[",ne+1,"-",Math.min(Pe,ne+q)," of ",Pe,"] \u25B2\u25BC")),e.createElement(u,{marginTop:1},e.createElement(s,{color:l.secondary,bold:!0},"Filter (provider:model): "),e.createElement(s,{color:l.text},yn),e.createElement(s,{color:l.primary,bold:!0},"\u258A"),yn.length>0&&e.createElement(s,{color:l.textMuted,dimColor:!0,italic:!0}," (Type to search, Esc/Backspace to clear)")),e.createElement(u,{flexDirection:"column",height:q,marginTop:1},ot)):e.createElement(e.Fragment,null,e.createElement(u,{marginBottom:1},e.createElement(s,{color:l.text,bold:!0,underline:!0},"SESSION TELEMETRY")),e.createElement(u,{flexDirection:"column"},e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},"Session Duration:")),e.createElement(s,{color:l.text},Ho(Date.now()-Es))),Ps>0&&e.createElement(e.Fragment,null,e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},"Model Requests:")),e.createElement(s,{color:l.text},Ps)),e.createElement(u,{marginLeft:2},e.createElement(u,{width:23},e.createElement(s,{color:l.textMuted},"\xBB API Time:")),e.createElement(s,{color:l.text},Ho(jn))),e.createElement(u,{marginLeft:2},e.createElement(u,{width:23},e.createElement(s,{color:l.textMuted},"\xBB Tool Time:")),e.createElement(s,{color:l.text},Ho(Kn)))),Fs>0&&e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},"Memory Agent:")),e.createElement(s,{color:l.text},Fs)),Qt>0&&e.createElement(e.Fragment,null,e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},"Tokens Consumed:")),e.createElement(s,{color:l.text},ut(Qt))),e.createElement(u,{marginLeft:2},e.createElement(u,{width:23},e.createElement(s,{color:l.textMuted},"\xBB Input Tokens:")),e.createElement(s,{color:l.text},ut(Qt-Ro))),Vn>0&&e.createElement(u,{marginLeft:4},e.createElement(u,{width:21},e.createElement(s,{color:l.textMuted},"\xBB Cached:")),e.createElement(s,{color:l.text},ut(Vn))),Ro>0&&e.createElement(u,{marginLeft:2},e.createElement(u,{width:23},e.createElement(s,{color:l.textMuted},"\xBB Output Tokens:")),e.createElement(s,{color:l.text},ut(Ro)))),fo?.tokens>0&&e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},"Active Context:")),e.createElement(s,{color:l.text},ut(fo.tokens))),qn>0&&e.createElement(e.Fragment,null,e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},"Images Made:")),e.createElement(s,{color:l.text},qn)),e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},"Image Credits:")),e.createElement(s,{color:l.text},Number(((_s||0)*1e3).toFixed(0))," credits"))),e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},"Code Changes (Sess):")),e.createElement(s,{color:l.text},e.createElement(s,{color:l.success||"green"},"+",bt.linesAdded)," ",e.createElement(s,{color:l.danger||"red"},"-",bt.linesRemoved))),e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},"Tool Calls (Sess):")),e.createElement(s,{color:l.text},bt.toolSuccess+bt.toolFailure+bt.toolDenied," ( "),e.createElement(s,{color:l.success||"green"},"\u2714 ",bt.toolSuccess),e.createElement(s,{color:l.text}," "),e.createElement(s,{color:l.warning||"yellow"},"\u{1F6C7} ",bt.toolDenied),e.createElement(s,{color:l.text}," "),e.createElement(s,{color:l.danger||"red"},"\u2718 ",bt.toolFailure),e.createElement(s,{color:l.text}," )"))),e.createElement(u,{flexDirection:"column",marginTop:1},e.createElement(s,{color:l.text,bold:!0,underline:!0},h),e.createElement(u,{marginTop:1},e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},b)),e.createElement(s,{color:l.text},qs(a?.duration||0))),(a?.agent||0)>0&&e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},"Model Requests:")),e.createElement(s,{color:l.text},a?.agent||0)),(a?.background||0)>0&&e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},"Memory Agent:")),e.createElement(s,{color:l.text},a?.background||0)),(a?.tokens||0)>0&&e.createElement(e.Fragment,null,e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},g)),e.createElement(s,{color:l.text},ut(a?.tokens||0))),e.createElement(u,{marginLeft:2},e.createElement(u,{width:23},e.createElement(s,{color:l.textMuted},"\xBB Input Tokens:")),e.createElement(s,{color:l.text},ut((a?.tokens||0)-(a?.candidateTokens||0)))),(a?.cachedTokens||0)>0&&e.createElement(u,{marginLeft:4},e.createElement(u,{width:21},e.createElement(s,{color:l.textMuted},"\xBB Cached:")),e.createElement(s,{color:l.text},ut(a.cachedTokens))),(a?.candidateTokens||0)>0&&e.createElement(u,{marginLeft:2},e.createElement(u,{width:23},e.createElement(s,{color:l.textMuted},"\xBB Output Tokens:")),e.createElement(s,{color:l.text},ut(a.candidateTokens)))),(a?.imageCalls?.length||0)>0&&e.createElement(e.Fragment,null,e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},d)),e.createElement(s,{color:l.text},a.imageCalls.length)),e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},p)),e.createElement(s,{color:l.text},Number(((a.imageCalls.reduce(($e,_e)=>$e+_e.cost,0)||0)*1e3).toFixed(0))," credits"))),e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},I)),e.createElement(s,{color:l.text},e.createElement(s,{color:l.success||"green"},"+",a?.linesAdded||0)," ",e.createElement(s,{color:l.danger||"red"},"-",a?.linesRemoved||0))),e.createElement(u,null,e.createElement(u,{width:25},e.createElement(s,{color:l.secondary},_)),e.createElement(s,{color:l.text},(a?.toolSuccess||0)+(a?.toolFailure||0)+(a?.toolDenied||0)," ( "),e.createElement(s,{color:l.success||"green"},"\u2714 ",a?.toolSuccess||0),e.createElement(s,{color:l.text}," "),e.createElement(s,{color:l.warning||"yellow"},"\u{1F6C7} ",a?.toolDenied||0),e.createElement(s,{color:l.text}," "),e.createElement(s,{color:l.danger||"red"},"\u2718 ",a?.toolFailure||0),e.createElement(s,{color:l.text}," )")))),e.createElement(s,{color:l.textMuted,dimColor:!0,italic:!0},`
201
201
  `,"(Press TAB to toggle Today/30-Day views, SPACE to toggle Model Breakdown, ESC to return)"))}case"dynamicDirDanger":return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(s,{color:l.warning||"yellow",bold:!0,underline:!0},"DYNAMIC DIRECTORY AWARENESS"),e.createElement(s,{marginTop:1,color:l.text},"Enabling this keeps the agent aware of filesystem state in real time, but may reduce prompt cache efficiency."),e.createElement(s,{color:l.text},`
202
202
  `,"RECOMMENDED SCENARIOS TO TURN ON:"),e.createElement(s,{color:l.textMuted},"\u2022 Repo is small."),e.createElement(s,{color:l.textMuted},"\u2022 The task benefits from real-time filesystem awareness."),e.createElement(s,{color:l.textMuted},"\u2022 Files are often created, renamed, or deleted."),e.createElement(s,{color:l.textMuted},"\u2022 You know exactly what you're signing up for."),e.createElement(s,{color:l.textMuted},"\u2022 You don't have conflicting decisions regarding token bills."),e.createElement(s,{color:l.textMuted},"\u2022 You want to see your wallet crying at 3am."),e.createElement(u,{marginTop:1},e.createElement(gt,{title:"Confirm Intent",theme:ce.theme,items:[{label:"Turn On Dynamic Directory Awareness",value:"on"},{label:"Keep Off (Recommended)",value:"off"}],onSelect:o=>{o.value==="on"&&Dt(n=>{let a={...n,dynamicDirAwareness:!0};return kt({systemSettings:a,apiTier:Re,quotas:Ie}),a}),W("settings")}})));case"dynamicDirHelp":return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(s,{color:l.text,bold:!0,underline:!0},"DYNAMIC DIRECTORY AWARENESS \u2014 HELP & EXPLANATION"),e.createElement(s,{color:l.text,bold:!0},`
203
203
  `,"OFF (Default):"),e.createElement(s,{color:l.textMuted},"\u2022 Takes a static directory snapshot at conversation/session start and places it in System Context."),e.createElement(s,{color:l.textMuted},"\u2022 Prompt cache remains stable across user turns, saving tokens and money."),e.createElement(s,{color:l.text,bold:!0},`
@@ -218,7 +218,7 @@ Selection: ${Ye}`,isAskRecord:!0}];return Y(Tt.length),Tt}),Ee(Ye))}}),W("ask")}
218
218
  ${o.instructions.length>0?`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${o.instructions.substring(0,30)}${o.instructions.length>30?"...":""}`:"\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No Instructions Provided."}
219
219
  \u2800`,isMeta:!0}]),W("chat")},onCancel:()=>W("chat"),theme:ce.theme});case"resolution":return e.createElement(u,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(Fd,{data:Gl,theme:ce.theme,onResolve:o=>{Kr(null),W("chat"),setTimeout(()=>{di(o,!0)},500)},onEdit:o=>{Kr(null),W("chat"),m(o)}}));case"approval":return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1,width:"100%"},e.createElement(s,{color:"white",bold:!0,underline:!0},"FILE WRITE PERMISSION"),e.createElement(s,{marginTop:1},"The agent is attempting to modify: ",e.createElement(s,{color:"cyan"},An(Co?.args||"{}").path||"Unknown File")),jo()?e.createElement(u,{marginTop:1,paddingX:1},e.createElement(s,{color:"cyan",italic:!0},"FluxFlow Companion is active. Review the changes in your editor.")):e.createElement(u,{marginTop:1,borderStyle:"single",borderColor:"#333",paddingX:1,flexDirection:"column"},e.createElement(s,{color:"gray"},"--- PROPOSED CONTENT ---"),(()=>{let o=An(Co?.args||"{}"),n=[],a=new Set;if(Object.keys(o).forEach(b=>{let g=b.match(/^(searchContent|replaceContent|newContent|content_to_replace|content_to_add|TargetContent|ReplacementContent|replacementContent)(\d+)?$/);if(g){let d=g[2]?parseInt(g[2]):1;a.add(d)}}),Array.from(a).sort((b,g)=>b-g).forEach(b=>{let g,d;b===1?(g=o.searchContent1??o.searchContent??o.replaceContent1??o.content_to_replace1??o.replaceContent??o.content_to_replace??o.TargetContent??null,d=o.newContent1??o.content_to_add1??o.newContent??o.content_to_add??o.ReplacementContent??o.replacementContent??null):(g=o[`searchContent${b}`]??o[`replaceContent${b}`]??o[`content_to_replace${b}`]??null,d=o[`newContent${b}`]??o[`content_to_add${b}`]??null),(g!==null||d!==null)&&n.push({replace:g,new:d})}),n.length>0)return e.createElement(u,{flexDirection:"column",marginTop:1},n.map((b,g)=>{let d=b.replace!==null,p=b.new!==null;return e.createElement(u,{key:g,flexDirection:"column",marginTop:g>0?1:0},n.length>1&&e.createElement(s,{color:"gray"},"Block ",g+1,":"),d&&e.createElement(u,null,e.createElement(s,{color:"red",wrap:"anywhere",bold:!0},"- ",b.replace)),p&&e.createElement(u,{marginTop:0},e.createElement(s,{color:"green",wrap:"anywhere",bold:!0},"+ ",b.new.replace(/\[\/n\]?/g,"\\n"))))}));let c=o.content||o.ReplacementContent||o.content_to_add||o.replacementContent||o.newContent||null;return e.createElement(s,{color:"white",wrap:"anywhere"},(c?c.replace(/\[\/n\]?/g,"\\n"):null)||"Updating file content...")})()),e.createElement(u,{marginTop:1},e.createElement(gt,{title:"Action Required",items:[{label:"Accept this time",value:"allow"},{label:"Accept for this session",value:"always"},{label:"Don't accept",value:"deny"}],onSelect:o=>{o.value==="always"&&Nl(!0);let n=o.value==="deny"?"deny":"allow";Co.resolve(n),nn(null),W("chat")},theme:ce.theme})));case"mode":return e.createElement(gt,{title:"SELECT EXECUTION MODE",items:[{label:`Flux (Dev Toolset Mode) ${D==="Flux"?"\u25CF":""}`,value:"Flux"},{label:`Flow (Chat / Conversation Mode) ${D==="Flow"?"\u25CF":""}`,value:"Flow"},{label:`ICU (Interactive Computer Use) ${D==="ICU"?"\u25CF":""}`,value:"ICU"},{label:`FluxCU (Autonomous Flux Computer Use) ${D==="FluxCU"?"\u25CF":""}`,value:"FluxCU"},{label:"Back",value:"chat"}],theme:ce.theme,onSelect:o=>{if(o.value==="chat"||o.value==="Back"){W("chat");return}let n=o.value;k(n),Fe(n==="Flow"?"Fast":"High"),N(a=>(Y(a.length+1),[...a,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${Bs(n)}
220
220
  \u2800`,isMeta:!0}])),W("chat")},onClose:()=>W("chat")});case"display":return e.createElement(gt,{title:"SELECT ACTIVE DISPLAY FOR COMPUTER USE",items:[{label:`Primary Display (Display 1) ${O===0?"\u25CF":""}`,value:0},{label:`Secondary Display (Display 2) ${O===1?"\u25CF":""}`,value:1},{label:"Back",value:"chat"}],theme:ce.theme,onSelect:o=>{if(o.value==="chat"||o.value==="Back"){W("chat");return}let n=Number(o.value);L(n),kt({display:n}).catch(()=>{});let a=n===0?"Primary (Display 1)":"Secondary (Display 2)";N(h=>(Y(h.length+1),[...h,{id:Date.now(),role:"system",text:`\u2726 Active Computer Use display set to: ${a}`,isMeta:!0}])),W("chat")},onClose:()=>W("chat")});case"updateManager":return e.createElement(gt,{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:o=>{if(o.value==="settings"||o.value==="Back"){W("settings");return}o.value==="custom"?(qt({label:"Enter Custom Update Command (Global install recommended):",key:"customUpdateCommand",value:ce.customUpdateCommand,next:n=>(Dt(a=>({...a,updateManager:"custom",customUpdateCommand:n})),null)}),W("input")):(Dt(n=>({...n,updateManager:o.value})),W("settings"))},theme:ce.theme});case"update":return e.createElement(nl,{latest:Vt,current:oo,settings:ce,onClose:()=>W("chat"),onSuccess:()=>{N(o=>(Y(o.length+1),[...o,{id:"update-success-"+Date.now(),role:"system",text:`**[UPDATE COMPLETED]** Flux Flow successfully updated to v${Vt}.
221
- **Restart to see changes.**`,isMeta:!0}])),W("chat")},onUpdateSettings:o=>{W("updateManager")}});case"terminalApproval":return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1,width:"100%"},e.createElement(s,{color:"white",bold:!0,underline:!0},"TERMINAL COMMAND OVERSIGHT"),e.createElement(u,{marginTop:1},e.createElement(s,null,"Agent requested to run: ",e.createElement(s,{color:"yellow",bold:!0},An(Co?.args||"{}").command||"Unknown Command"))),e.createElement(u,{marginTop:1},e.createElement(gt,{title:"Risk Assessment Required",items:[{label:"Run",value:"allow"},{label:"Deny",value:"deny"}],onSelect:o=>{Co.resolve(o.value),nn(null),W("chat")},theme:ce.theme})));default:return e.createElement(u,{flexDirection:"column",marginTop:1,flexShrink:0,width:"100%"},oi&&ti&&e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,paddingX:2,paddingY:1,width:"100%",marginBottom:1},e.createElement(u,{justifyContent:"space-between",width:"100%"},e.createElement(s,{color:l.text,bold:!0,underline:!0},"INQUIRY RESPONSE"),e.createElement(s,{color:l.textMuted},"[ ESC to Close ]")),e.createElement(u,{marginTop:1,width:"100%"},e.createElement(Nn,{text:ti,columns:X.columns-6,theme:ce.theme}))),Fr.filter(o=>o.status==="running").length>0&&e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,paddingX:2,paddingY:0,width:"100%",marginBottom:1},e.createElement(u,{justifyContent:"space-between",width:"100%"},e.createElement(s,{color:l.text,bold:!0},"ACTIVE SUBAGENTS")),e.createElement(u,{flexDirection:"column",marginTop:1,width:"100%"},Fr.filter(o=>o.status==="running").map(o=>e.createElement(Xd,{key:o.id,sa:o,showTPMEstimate:ce.showTPMEstimate})))),e.createElement(u,{paddingX:1,marginBottom:0,justifyContent:"space-between",width:"100%"},e.createElement(u,null,Bn?e.createElement(u,{gap:1},e.createElement(Dd,null),e.createElement(_n,{text:Bn.trimEnd(),baseColor:l.textExclusive||l.text,glintColor:l.textMutedExclusive||l.textMuted,speed:60,italic:!0,glintWidth:2,typeSpeed:10}),e.createElement(s,{color:l.textMuted},zs>0?`(${zs.toFixed(0)}s)`:"")):e.createElement(s,{color:l.textMuted,italic:!0},E.length>0&&Rs?"Press ESC again to clear input":Fl?"Press CTRL + O to expand":"Waiting for input...")),e.createElement(u,null,(()=>{let o=Bn?.toLowerCase()??"";return rn&&Date.now()-Ls>15e3&&Fr.length===0&&(o.includes("connecting")||o.includes("working")||o.includes("queue"))?e.createElement(u,null,e.createElement(_n,{text:"Waiting for API",baseColor:l.text,glintColor:l.textMuted,glintWidth:4,speed:80}),e.createElement(s,{color:l.textMuted,dimColor:!0}," \u2503 ")):Wr?e.createElement(u,null,e.createElement(_n,{text:Wr,baseColor:l.text,glintColor:l.textMuted,italic:!0,speed:80,typeSpeed:15}),e.createElement(s,{color:l.textMuted,dimColor:!0}," \u2503 ")):null})(),e.createElement(_n,{text:re.split("/")[1]||(re.length>1?re:"Use '/model model-id' to select model"),baseColor:l.text,glintColor:l.textMuted,glintWidth:3}),e.createElement(s,{color:l.textMuted}," ",re.length>0?`(${he})`:""),ar>0&&e.createElement(s,{color:l.textMuted}," [",ar," ",ar===1?"file":"files","]"))),e.createElement(u,{flexDirection:"column",width:"100%"},e.createElement(u,{width:"100%",height:1,overflow:"hidden"},e.createElement(s,{color:l.inputBorder},"\u2584".repeat(Math.max(1,X.columns)))),e.createElement(u,{backgroundColor:l.inputBg,paddingX:1,paddingY:0,width:"100%",flexDirection:"column"},e.createElement(u,{flexDirection:"column",width:"100%"},e.createElement(u,{flexDirection:"row",width:"100%",paddingY:0},e.createElement(u,{flexShrink:0,width:4},e.createElement(s,{color:l.inputPrompt,bold:!0},rn||Rn?"\u2726 ":" \u276F ")),e.createElement(u,{flexGrow:1},e.createElement(u,{flexGrow:1,position:"relative"},E===""&&e.createElement(u,{position:"absolute",paddingLeft:0},Rt&&!Mn?e.createElement(s,{color:"yellow"},jl?" Terminal is waiting for user input. Press TAB to interact":" Press TAB to interact with terminal..."):Rt&&Mn?e.createElement(s,{color:"yellow",bold:!0}," [ TERMINAL FOCUSED ] Type to interact, press TAB to exit..."):Rs===1?e.createElement(s,{color:l.inputPrompt,bold:!0}," Press ESC again to ",E.length>0?"clear input":"revert codebase to checkpoint","..."):e.createElement(s,{color:l.inputPlaceholder},Xl?" Press ESC again to cancel the request.":Rn?" Compacting session history, please wait...":rn?" Enter a prompt to steer the agent.":` Send message, @file or /cmd (${Ol.shortcut} for newline)`)),e.createElement(Wi,{key:`input-${B}`,onPasteStateChange:Ul,focus:!Mn&&!Rn,showCursor:Ue&&!Rn,cursorColor:l.inputText,lastFocusEventTime:We.current,value:E,textStyle:{bold:!0,color:l.inputText},columns:X.columns,onChange:o=>{let n=o.replace(/\r\n/g,`
221
+ **Restart to see changes.**`,isMeta:!0}])),W("chat")},onUpdateSettings:o=>{W("updateManager")}});case"terminalApproval":return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1,width:"100%"},e.createElement(s,{color:"white",bold:!0,underline:!0},"TERMINAL COMMAND OVERSIGHT"),e.createElement(u,{marginTop:1},e.createElement(s,null,"Agent requested to run: ",e.createElement(s,{color:"yellow",bold:!0},An(Co?.args||"{}").command||"Unknown Command"))),e.createElement(u,{marginTop:1},e.createElement(gt,{title:"Risk Assessment Required",items:[{label:"Run",value:"allow"},{label:"Deny",value:"deny"}],onSelect:o=>{Co.resolve(o.value),nn(null),W("chat")},theme:ce.theme})));default:return e.createElement(u,{flexDirection:"column",marginTop:1,flexShrink:0,width:"100%"},oi&&ti&&e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,paddingX:2,paddingY:1,width:"100%",marginBottom:1},e.createElement(u,{justifyContent:"space-between",width:"100%"},e.createElement(s,{color:l.text,bold:!0,underline:!0},"INQUIRY RESPONSE"),e.createElement(s,{color:l.textMuted},"[ ESC to Close ]")),e.createElement(u,{marginTop:1,width:"100%"},e.createElement(Nn,{text:ti,columns:X.columns-6,theme:ce.theme}))),Fr.filter(o=>o.status==="running").length>0&&e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,paddingX:2,paddingY:0,width:"100%",marginBottom:1},e.createElement(u,{justifyContent:"space-between",width:"100%"},e.createElement(s,{color:l.text,bold:!0},"ACTIVE SUBAGENTS")),e.createElement(u,{flexDirection:"column",marginTop:1,width:"100%"},Fr.filter(o=>o.status==="running").map(o=>e.createElement(Xd,{key:o.id,sa:o,showTPMEstimate:ce.showTPMEstimate})))),e.createElement(u,{paddingX:1,marginBottom:0,justifyContent:"space-between",width:"100%"},e.createElement(u,null,Bn?e.createElement(u,{gap:1},e.createElement(Dd,null),e.createElement(_n,{text:Bn.trimEnd(),baseColor:l.textExclusive||l.text,glintColor:l.textMutedExclusive||l.textMuted,speed:60,italic:!0,glintWidth:2,typeSpeed:10}),e.createElement(s,{color:l.textMuted},zs>0?`(${zs.toFixed(0)}s)`:"")):e.createElement(s,{color:l.textMuted,italic:!0},E.length>0&&Rs?"Press ESC again to clear input":Fl?"Press CTRL + O to expand":"Waiting for input...")),e.createElement(u,null,(()=>{let o=Bn?.toLowerCase()??"";return rn&&Date.now()-Ls>15e3&&Fr.length===0&&(o.includes("connecting")||o.includes("working")||o.includes("queue"))?e.createElement(u,null,e.createElement(_n,{text:"Waiting for API",baseColor:l.text,glintColor:l.textMuted,glintWidth:4,speed:80}),e.createElement(s,{color:l.textMuted,dimColor:!0}," \u2503 ")):Wr?e.createElement(u,null,e.createElement(_n,{text:Wr,baseColor:l.text,glintColor:l.textMuted,italic:!0,speed:80,typeSpeed:15}),e.createElement(s,{color:l.textMuted,dimColor:!0}," \u2503 ")):null})(),e.createElement(_n,{text:St.basename(re)||(re.length>1?re:"Use '/model model-id' to select model"),baseColor:l.text,glintColor:l.textMuted,glintWidth:3}),e.createElement(s,{color:l.textMuted}," ",re.length>0?`(${he})`:""),ar>0&&e.createElement(s,{color:l.textMuted}," [",ar," ",ar===1?"file":"files","]"))),e.createElement(u,{flexDirection:"column",width:"100%"},e.createElement(u,{width:"100%",height:1,overflow:"hidden"},e.createElement(s,{color:l.inputBorder},"\u2584".repeat(Math.max(1,X.columns)))),e.createElement(u,{backgroundColor:l.inputBg,paddingX:1,paddingY:0,width:"100%",flexDirection:"column"},e.createElement(u,{flexDirection:"column",width:"100%"},e.createElement(u,{flexDirection:"row",width:"100%",paddingY:0},e.createElement(u,{flexShrink:0,width:4},e.createElement(s,{color:l.inputPrompt,bold:!0},rn||Rn?"\u2726 ":" \u276F ")),e.createElement(u,{flexGrow:1},e.createElement(u,{flexGrow:1,position:"relative"},E===""&&e.createElement(u,{position:"absolute",paddingLeft:0},Rt&&!Mn?e.createElement(s,{color:"yellow"},jl?" Terminal is waiting for user input. Press TAB to interact":" Press TAB to interact with terminal..."):Rt&&Mn?e.createElement(s,{color:"yellow",bold:!0}," [ TERMINAL FOCUSED ] Type to interact, press TAB to exit..."):Rs===1?e.createElement(s,{color:l.inputPrompt,bold:!0}," Press ESC again to ",E.length>0?"clear input":"revert codebase to checkpoint","..."):e.createElement(s,{color:l.inputPlaceholder},Xl?" Press ESC again to cancel the request.":Rn?" Compacting session history, please wait...":rn?" Enter a prompt to steer the agent.":` Send message, @file or /cmd (${Ol.shortcut} for newline)`)),e.createElement(Wi,{key:`input-${B}`,onPasteStateChange:Ul,focus:!Mn&&!Rn,showCursor:Ue&&!Rn,cursorColor:l.inputText,lastFocusEventTime:We.current,value:E,textStyle:{bold:!0,color:l.inputText},columns:X.columns,onChange:o=>{let n=o.replace(/\r\n/g,`
222
222
  `).replace(/\r/g,`
223
223
  `).replace(/\\\s*\n/g,`
224
224
  `);m(n),K(!1)},onSubmit:di,rows:1,maxRows:10,keyBindings:{submit:o=>o.return&&!o.shift&&!o.ctrl,newline:o=>o.return&&o.shift||o.return&&o.ctrl}})))))),e.createElement(u,{width:"100%",height:1,overflow:"hidden"},e.createElement(s,{color:l.inputBorder},"\u2580".repeat(Math.max(1,X.columns))))))}};return e.createElement(u,{flexDirection:"column",width:"100%"},it?null:se?e.createElement(Od,{width:i?.columns||80,height:i?.rows||24,selectedIndex:Se,aiProvider:P,theme:ce.theme}):e.createElement(e.Fragment,null,e.createElement(u,{paddingX:1,flexDirection:"column",width:"100%"},e.createElement(vd,{key:`static-${Yo}-${tt}-${X.columns}-${X.rows}-${ce.theme}`,items:ii.completed},o=>e.createElement(hr,{key:o.key,block:o,columns:(i?.columns||80)-2,showFullThinking:Ht,aiProvider:P,version:oo,theme:ce.theme}))),e.createElement(u,{flexDirection:"column",paddingX:1,paddingBottom:0,width:"100%"},(lt==="chat"||["ask","approval","terminalApproval"].includes(lt))&&e.createElement(u,{flexDirection:"column",width:"100%"},ii.active.map(o=>e.createElement(hr,{key:o.key,block:o,columns:Math.max(20,(i?.columns||80)-2),showFullThinking:Ht,aiProvider:P,version:oo,theme:ce.theme})),Rt&&e.createElement(u,{marginTop:1},e.createElement(fr,{command:Rt,output:tn,isFocused:Mn,isPty:an,terminalHeight:X.rows,columns:X.columns}))),it?e.createElement(u,{borderStyle:"double",borderColor:"grey",padding:1,flexShrink:0},e.createElement(s,{color:"white"},"Starting Flux Flow...")):wt?Kl():e.createElement(u,{borderStyle:"round",borderColor:"white",padding:0,flexDirection:"column",flexShrink:0,width:"100%"},e.createElement(u,{paddingX:1,marginBottom:1},e.createElement(s,{color:"gray",bold:!0},"API KEY REQUIRED")),e.createElement(u,{paddingX:1,flexDirection:"column"},dt===0?e.createElement(e.Fragment,null,e.createElement(s,{color:"white"},"Select your Preferred Provider:"),e.createElement(u,{marginTop:1},e.createElement(gt,{searchable:!0,items:[{label:"Google",value:"Google"},{label:"Nvidia",value:"NVIDIA"},{label:"DeepSeek",value:"DeepSeek"},{label:"InferX",value:"InferX"},{label:"SenseNova",value:"SenseNova"},{label:"CrofAI",value:"CrofAI"},{label:"Poolside",value:"Poolside"},...process.env.ENABLE_9ROUTER==="true"||process.env.ENABLE_9ROUTER===!0?[{label:"9router",value:"9router"}]:[],{label:"Ollama",value:"Ollama"},{label:"AIHubMix [EXPERIMENTAL]",value:"AIHubMix"},{label:"Mistral [EXPERIMENTAL]",value:"Mistral"},{label:"OpenRouter [EXPERIMENTAL]",value:"OpenRouter"}],onSelect:o=>{vt(o.value),Nt(1)}}))):e.createElement(e.Fragment,null,e.createElement(s,{color:"white"},P==="Ollama"?"Enter Ollama API Key (or type LOCAL to use local host):":`Enter your ${P} API Key:`),e.createElement(u,{marginTop:1},e.createElement(s,{color:"gray",bold:!0}," ",">"," "),e.createElement(Sr,{value:Br,onChange:zo,onSubmit:li,mask:"*"})))),e.createElement(u,{paddingX:1,marginTop:1},e.createElement(s,{color:"gray",italic:!0},dt===0?"(Use arrows to select and Enter to confirm, ESC to go back)":"(Press Enter to confirm and initialize, ESC to go back)"))),x&&e.createElement(u,{borderStyle:"round",borderColor:l.borderMuted,paddingX:1,marginY:0,width:"100%"},e.createElement(s,null,e.createElement(s,{color:"red",bold:!0},"\u{1F534} EXIT: "),e.createElement(s,{color:l.text},"Press "),e.createElement(s,{color:l.text,bold:!0},"CTRL+C"),e.createElement(s,{color:l.text}," again to exit (",T,"s) \u2022 Press "),e.createElement(s,{color:l.textMuted,bold:!0},"ESC"),e.createElement(s,{color:l.text}," to cancel"))),He.length>0&&(()=>{let n=de.current,a=0;for(;a<He.length;){let b=He[a],g=b?.cmd||b||"";if(typeof g=="string"&&g.trimStart().startsWith("---"))a++;else break}le<=a?n=0:le<n?n=le:le>=n+5&&(n=le-5+1),n=Math.max(0,Math.min(n,Math.max(0,He.length-5))),de.current=n;let h=He.slice(n,n+5),c=He.length-(n+h.length);return e.createElement(u,{flexDirection:"column",width:"100%",marginBottom:1},e.createElement(u,{paddingX:1,marginBottom:0,justifyContent:"space-between",width:"100%"},e.createElement(s,{color:l.text,bold:!0},He[0]?.cmd?.startsWith("@")||He[0]?.cmd?.startsWith("\\@")?"FILE SUGGESTIONS":"COMMAND SUGGESTIONS"),He[0]?.cmd?.startsWith("@")||He[0]?.cmd?.startsWith("\\@")?e.createElement(s,{color:l.textMuted,italic:!0},"(Use #Lstart-Lend to specify line numbers)"):E.startsWith("/model")&&Re==="Free"?(()=>{let b="https://aistudio.google.com/billing",g="billing";P==="DeepSeek"?(b="https://platform.deepseek.com/usage",g="billing"):P==="OpenRouter"?(b="https://openrouter.ai/settings/profile",g="profile"):P==="NVIDIA"?(b="https://build.nvidia.com/settings/api-keys",g="billing"):P==="CrofAI"?(b="https://crof.ai",g="account"):P==="Poolside"&&(b="https://inference.poolside.ai",g="account")})():null),h.slice(0,or).map((b,g)=>{let p=n+g===le,I=typeof b.cmd=="string"&&b.cmd.trimStart().startsWith("---"),_=b.cmd===ro("Google","Free")&&Re!=="Free";return e.createElement(u,{key:b.cmd,flexDirection:"row",backgroundColor:p?l.highlightBg:void 0,paddingX:1},e.createElement(u,{width:3},e.createElement(s,{color:p?l.text:l.textMuted,bold:p},p?" \u276F":" ")),e.createElement(u,{width:55},e.createElement(s,{color:I?l.textDim:_?l.textMuted:p?l.text:l.textDim,bold:!1},b.display||(b.cmd&&(b.cmd.startsWith("@[")||b.cmd.startsWith("\\@["))&&b.cmd.endsWith("]")?(()=>{let ue=(b.cmd.startsWith("\\@[")?b.cmd.slice(3,-1):b.cmd.slice(2,-1)).split(/[/\\]/);return ue[ue.length-1]})():b.cmd&&b.cmd.includes("/")?b.cmd.split("/").pop():b.cmd))),e.createElement(u,{flexGrow:1},e.createElement(s,{color:p?l.text:l.textMuted,italic:!0},b.desc)))}),He.length>5&&e.createElement(u,{paddingX:1,height:1},c>0?e.createElement(s,{color:l.textMuted,dimColor:!0,italic:!0}," ... (",c," more commands available)"):e.createElement(s,{color:l.textMuted,dimColor:!0,italic:!0}," (End of list)")))})(),e.createElement(u,{flexShrink:0,width:"100%"},e.createElement(zi,{mode:D,thinkingLevel:he,tokens:fo.tokens,tokensTotal:Cl,chatId:tt,isMemoryEnabled:ce.memory,apiTier:Re,aiProvider:P,activeModel:re,isProcessing:rn,lastChunkTime:Ls,theme:ce.theme,wps:Lr.current.wps,showTPMEstimate:ce.showTPMEstimate})),lt==="exit"&&(()=>{let o=Date.now()-Es,n=bt.toolSuccess+bt.toolFailure,a=n>0?(bt.toolSuccess/n*100).toFixed(1):"0.0",h=jn+Kn,c=h>0?(jn/h*100).toFixed(1):"0.0",b=h>0?(Kn/h*100).toFixed(1):"0.0";return e.createElement(u,{flexDirection:"column",borderStyle:"round",paddingX:3,paddingY:1,borderColor:l.borderMuted,width:Math.min(100,(i?.columns||100)-2),marginTop:0,marginBottom:0},e.createElement(u,{marginBottom:1},e.createElement(s,{bold:!0},Id(l.logoGradient||["blue","purple"])("Agent powering down. Goodbye!"))),e.createElement(u,{flexDirection:"column"},e.createElement(s,{color:l.text,bold:!0,underline:!0},"Interaction Summary"),e.createElement(u,{marginTop:1},e.createElement(u,{width:20},e.createElement(s,{color:l.secondary},"Session ID:")),e.createElement(s,{color:l.text},tt)),e.createElement(u,null,e.createElement(u,{width:20},e.createElement(s,{color:l.secondary},"Tool Calls:")),e.createElement(s,{color:l.text},bt.toolSuccess+bt.toolFailure+bt.toolDenied," ( ",e.createElement(s,{color:"green"},"\u2714 ",bt.toolSuccess)," ",e.createElement(s,{color:"yellow"},"\u{1F6C7} ",bt.toolDenied)," ",e.createElement(s,{color:"red"},"\u2718 ",bt.toolFailure)," )")),e.createElement(u,null,e.createElement(u,{width:20},e.createElement(s,{color:l.secondary},"Success Rate:")),e.createElement(s,{color:l.text},a,"%")),e.createElement(u,null,e.createElement(u,{width:20},e.createElement(s,{color:l.secondary},"Code Changes:")),e.createElement(s,{color:l.text},e.createElement(s,{color:"green"},"+",bt.linesAdded)," ",e.createElement(s,{color:"red"},"-",bt.linesRemoved))),Qt>0&&e.createElement(e.Fragment,null,e.createElement(u,null,e.createElement(u,{width:20},e.createElement(s,{color:l.secondary},"Tokens Consumed:")),e.createElement(s,{color:l.text},ut(Qt))),e.createElement(u,{marginLeft:2},e.createElement(u,{width:18},e.createElement(s,{color:l.textMuted},"\xBB Input Tokens:")),e.createElement(s,{color:l.text},ut(Qt-Ro))),Vn>0&&e.createElement(u,{marginLeft:4},e.createElement(u,{width:16},e.createElement(s,{color:l.textMuted},"\xBB Cached:")),e.createElement(s,{color:l.text},ut(Vn))),Ro>0&&e.createElement(u,{marginLeft:2},e.createElement(u,{width:18},e.createElement(s,{color:l.textMuted},"\xBB Output Tokens:")),e.createElement(s,{color:l.text},ut(Ro)))),qn>0&&e.createElement(e.Fragment,null,e.createElement(u,null,e.createElement(u,{width:20},e.createElement(s,{color:l.secondary},"Images Made:")),e.createElement(s,{color:l.text},qn)),e.createElement(u,null,e.createElement(u,{width:20},e.createElement(s,{color:l.secondary},"Image Credits:")),e.createElement(s,{color:l.text},Number(((_s||0)*1e3).toFixed(0))," credits")))),e.createElement(u,{flexDirection:"column",marginTop:1},e.createElement(s,{color:l.text,bold:!0,underline:!0},"Performance"),e.createElement(u,{marginTop:1},e.createElement(u,{width:20},e.createElement(s,{color:l.secondary},"Wall Time:")),e.createElement(s,{color:l.text},Ho(o))),e.createElement(u,null,e.createElement(u,{width:20},e.createElement(s,{color:l.secondary},"Agent Active:")),e.createElement(s,{color:l.text},Ho(h))),e.createElement(u,{marginLeft:2},e.createElement(u,{width:18},e.createElement(s,{color:l.textMuted},"\xBB API Time:")),e.createElement(s,{color:l.text},Ho(jn)," (",c,"%)")),e.createElement(u,{marginLeft:2},e.createElement(u,{width:18},e.createElement(s,{color:l.textMuted},"\xBB Tool Time:")),e.createElement(s,{color:l.text},Ho(Kn)," (",b,"%)"))))})())))}export{_d as default};
@@ -169,6 +169,7 @@ fluxflow [options]
169
169
  * SHELL \u2192 Terminal shell executable
170
170
  * HIGH_CONTEXT \u2192 Context window override (false or integer 32k..1M)
171
171
  * ENABLE_9ROUTER \u2192 Enable 9Router provider. Local proxy for using other providers & OAuth subscription like Codex, Claude Code, GitHub Copilot etc
172
+ * 9ROUTER_BASE_URL \u2192 9Router base URL
172
173
 
173
174
  ## Diagnostic & Optimization Flags
174
175
  * SHOW_DEBUG_GRID \u2192 (true|false, default: false) Coordinate grid overlay for Computer Use tooling
@@ -435,7 +436,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
435
436
  ## Supported Providers
436
437
  * Direct: Gemini (aistudio.google.com) | NVIDIA NIM (build.nvidia.com) | DeepSeek (platform.deepseek.com) | Mistral (admin.mistral.ai) | Ollama (ollama.com) | CrofAI (crof.ai) | InferX (model.inferx.net) | SenseNova (platform.sensenova.ai) | Poolside (platform.poolside.ai)
437
438
  * Aggregators / Local Proxies: OpenRouter (openrouter.ai) | AIHubMix (aihubmix.com)
438
- * Local Proxy: 9router. Can use OAuth subscription like Codex, Claude Code, GitHub Copilot etc. Set ENV ENABLE_9ROUTER=true
439
+ * Local Proxy: 9router. Can use OAuth subscription like Codex, Claude Code, GitHub Copilot etc. or use providers not natively in Fluxflow. Set ENV ENABLE_9ROUTER=true, needs 9router package installed (via npm/npx etc) & running
439
440
 
440
441
  * Fluxflow has default model list for many providers, updated based on vibes. Can be overriden using /model <model-id>
441
442
 
@@ -829,14 +830,14 @@ Stack: ${a.stack}`:"";return`ERROR: Failed to map file: ${i}${p}`}};import Qn fr
829
830
  ${l}`}return`SUCCESS: TASK LIST CREATED (${u} total)
830
831
  ${l}`}if(t==="append"){if(!o)return'ERROR: Missing "tasks" for append method.';let l=d(o);await ht.recordFileChange(i),Qn.appendFileSync(i,l,"utf8");let f=Qn.readFileSync(i,"utf8"),u=f.split(/\r?\n/).map(h=>h.trim()),m=u.filter(h=>h.startsWith("- [ ]")||h.startsWith("- [x]")||h.startsWith("- [X]")).length,g=u.filter(h=>h.startsWith("- [x]")||h.startsWith("- [X]")).length,y=l.split(/\r?\n/).map(h=>h.trim()).filter(h=>h.startsWith("- [ ]")||h.startsWith("- [x]")||h.startsWith("- [X]")).length;return`SUCCESS: TASK APPENDED (${g} completed, ${m-g} left, ${y} added)
831
832
  ${f}`}if(t==="get"){if(!Qn.existsSync(i))return"TODO GET: No task list found for this session.";let l=Qn.readFileSync(i,"utf8"),f=0;if(s){let h=c(l,s);h.markedCount>0&&(l=h.content,f=h.markedCount,await ht.recordFileChange(i),Qn.writeFileSync(i,l,"utf8"))}let u=l.split(/\r?\n/).map(h=>h.trim()),m=u.filter(h=>h.startsWith("- [ ]")||h.startsWith("- [x]")||h.startsWith("- [X]")).length,g=u.filter(h=>h.startsWith("- [x]")||h.startsWith("- [X]")).length;return`${f>0?`SUCCESS: ${f} TASK(S) MARKED DONE`:"TODO GET"}: ${g} Completed, ${m-g} left
832
- ${l}`}return`ERROR: Unknown method "${t}". Use create, append, or get.`}catch(l){return`ERROR: Todo tool failure: ${l instanceof Error?l.message:String(l)}`}};var Xr=async(e,n={})=>{let{runSubagent:t}=await import("./ai-NSY4UUPI.js"),o=L(e),s=o.task||o.instruction||o.prompt,r=o.model||null,a=o.tools||null;if(!s)return'ERROR: Missing "task" argument for invokeSync.';let i=null;if(a)try{let d=a.trim();d.startsWith("[")&&d.endsWith("]")&&(d=d.substring(1,d.length-1)),i=d.split(",").map(c=>c.trim().replace(/^["']|["']$/g,"")).filter(Boolean)}catch{}let p=o.title||s.substring(0,30);try{n.onVisualFeedback&&n.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${p}`);let d=await t(s,n,r,i,50);return n.onVisualFeedback&&n.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${p} [COMPLETED]
833
- `),d}catch(d){let{isTerminationSignaled:c}=await import("./ai-NSY4UUPI.js"),l=d.message==="Subagent task was cancelled by user."||c();if(n.onVisualFeedback){let f=l?"[CANCELLED]":"[FAILED]";n.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${p} ${f}
834
- `)}return`ERROR: Subagent execution failed: ${d.message}`}};var Ha=async(e,n={})=>{let{runSubagent:t}=await import("./ai-NSY4UUPI.js"),o=L(e),s=o.task||o.instruction||o.prompt,r=o.model||null,a=o.title||null,i=o.tools||null;if(!s)return'ERROR: Missing "task" argument for invoke.';let p=null;if(i)try{let h=i.trim();h.startsWith("[")&&h.endsWith("]")&&(h=h.substring(1,h.length-1)),p=h.split(",").map(x=>x.trim().replace(/^["']|["']$/g,"")).filter(Boolean)}catch{}let d=`subagent-${Date.now()}-${Math.floor(Math.random()*1e3)}`,c=null,l=null,f=new Promise((h,x)=>{c=h,l=x}),u={id:d,title:a||s.substring(0,30),task:s,status:"running",startedAt:Date.now(),lastChunkTime:Date.now(),wps:0,questions:[],pendingSteerMessages:[],steer:h=>{h&&u.pendingSteerMessages.push(h)},completionPromise:f,_resolveCompletion:c,_rejectCompletion:l,progress:[]},m={chunks:[],totalWords:0};Qe.push(u),n.onSubagentUpdate&&n.onSubagentUpdate();let g=[],y={...n,taskId:d,onAskMain:async h=>{let x=`q-${Date.now()}-${Math.floor(Math.random()*1e3)}`,w=null,T=new Promise(S=>{w=S}),$={id:x,question:h,answered:!1,answer:null,askedAt:Date.now(),_resolve:w};return u.questions.push($),u.status="waiting",n.onSubagentUpdate&&n.onSubagentUpdate(),Rs(`[SYSTEM] Background subagent "${u.title}" is WAITING FOR YOUR INPUT: "${h}"
833
+ ${l}`}return`ERROR: Unknown method "${t}". Use create, append, or get.`}catch(l){return`ERROR: Todo tool failure: ${l instanceof Error?l.message:String(l)}`}};var Xr=async(e,n={})=>{let{runSubagent:t}=await import("./ai-KNABID6V.js"),o=L(e),s=o.task||o.instruction||o.prompt,r=o.model||null,a=o.tools||null;if(!s)return'ERROR: Missing "task" argument for invokeSync.';let i=null;if(a)try{let d=a.trim();d.startsWith("[")&&d.endsWith("]")&&(d=d.substring(1,d.length-1)),i=d.split(",").map(c=>c.trim().replace(/^["']|["']$/g,"")).filter(Boolean)}catch{}let p=o.title||s.substring(0,30);try{n.onVisualFeedback&&n.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${p}`);let d=await t(s,n,r,i,50);return n.onVisualFeedback&&n.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${p} [COMPLETED]
834
+ `),d}catch(d){let{isTerminationSignaled:c}=await import("./ai-KNABID6V.js"),l=d.message==="Subagent task was cancelled by user."||c();if(n.onVisualFeedback){let f=l?"[CANCELLED]":"[FAILED]";n.onVisualFeedback(`\x1B[95mSubAgent\x1B[0m: \x1B[32mGeneralist\x1B[0m \u2192 ${p} ${f}
835
+ `)}return`ERROR: Subagent execution failed: ${d.message}`}};var Ha=async(e,n={})=>{let{runSubagent:t}=await import("./ai-KNABID6V.js"),o=L(e),s=o.task||o.instruction||o.prompt,r=o.model||null,a=o.title||null,i=o.tools||null;if(!s)return'ERROR: Missing "task" argument for invoke.';let p=null;if(i)try{let h=i.trim();h.startsWith("[")&&h.endsWith("]")&&(h=h.substring(1,h.length-1)),p=h.split(",").map(x=>x.trim().replace(/^["']|["']$/g,"")).filter(Boolean)}catch{}let d=`subagent-${Date.now()}-${Math.floor(Math.random()*1e3)}`,c=null,l=null,f=new Promise((h,x)=>{c=h,l=x}),u={id:d,title:a||s.substring(0,30),task:s,status:"running",startedAt:Date.now(),lastChunkTime:Date.now(),wps:0,questions:[],pendingSteerMessages:[],steer:h=>{h&&u.pendingSteerMessages.push(h)},completionPromise:f,_resolveCompletion:c,_rejectCompletion:l,progress:[]},m={chunks:[],totalWords:0};Qe.push(u),n.onSubagentUpdate&&n.onSubagentUpdate();let g=[],y={...n,taskId:d,onAskMain:async h=>{let x=`q-${Date.now()}-${Math.floor(Math.random()*1e3)}`,w=null,T=new Promise(S=>{w=S}),$={id:x,question:h,answered:!1,answer:null,askedAt:Date.now(),_resolve:w};return u.questions.push($),u.status="waiting",n.onSubagentUpdate&&n.onSubagentUpdate(),Rs(`[SYSTEM] Background subagent "${u.title}" is WAITING FOR YOUR INPUT: "${h}"
835
836
  Respond using tool: [tool:functions.Answer(id="${d}", answer="...")]
836
837
  [/SYSTEM]`),await T},onVisualFeedback:h=>{u.lastChunkTime=Date.now();let x=h.replace(/\x1b\[[0-9;]*m/g,""),w=x.match(/[✔✘✗✖🔍📖→➕↻•]\s*([A-Za-z0-9\s-]+)/);w?u.currentTool=w[1].trim():u.currentTool=x,n.onSubagentUpdate&&n.onSubagentUpdate()},onTokenChunk:(h,x)=>{let w=Date.now();if(u.lastChunkTime=w,u.currentTool="Thinking",typeof x=="number"&&x>0){m.totalWords+=x,m.chunks.push({time:w,words:x});let T=w-400;if(m.chunks=m.chunks.filter($=>$.time>=T),m.chunks.length>0){let $=m.chunks.reduce((k,_)=>k+_.words,0),R=m.chunks[0].time,S=Math.max(.4,(w-R)/1e3);u.wps=Math.round($/S*10)/10}}n.onSubagentUpdate&&n.onSubagentUpdate()}};return t(s,y,r,p,50,h=>{if(u.status==="cancelled")return;if(h.startsWith("[Subagent Turn")&&g.length>0&&(u.progress.push([...g]),g=[]),h.includes("[Executing Tool]")){let w=h.match(/\[Executing Tool\]\s*([a-zA-Z0-9_]+)/);w&&(!u.currentTool||u.currentTool==="Thinking")&&(u.currentTool=w[1])}let x=h;if(x.startsWith("[Tool Result]")){let w=x.split(`
837
838
  `);w.length>5&&(x=w.slice(0,4).join(`
838
839
  `)+`
839
- ... [Content/Diff Truncated from Logs] ...`)}g.push(x),n.onSubagentUpdate&&n.onSubagentUpdate()},!0).then(h=>{if(u.status==="cancelled"){u._resolveCompletion&&u._resolveCompletion(h);return}g.length>0&&(u.progress.push([...g]),g=[]),u.status="completed",u.finalAnswer=h,n.onSubagentUpdate&&n.onSubagentUpdate(),Rs(`[SYSTEM] Background subagent "${u.title}" (id: ${d}) has FINISHED. Call GetProgress(id="${d}") to see the final result. [/SYSTEM]`),u._resolveCompletion&&u._resolveCompletion(h)}).catch(async h=>{let{isTerminationSignaled:x}=await import("./ai-NSY4UUPI.js");if(h.message==="Subagent task was cancelled."||u.status==="cancelled"||x()){u.status="cancelled",g.push("[SUBAGENT CANCELLED] Task was cancelled."),u.progress.push([...g]),n.onSubagentUpdate&&n.onSubagentUpdate(),u._resolveCompletion&&u._resolveCompletion(null);return}g.push(`[SUBAGENT FAILURE] Error: ${h.message}`),u.progress.push([...g]),u.status="failed",u.error=h.message,n.onSubagentUpdate&&n.onSubagentUpdate(),Rs(`[SYSTEM] Background subagent "${u.title}" (id: ${d}) FAILED with error: ${h.message}. [/SYSTEM]`),u._rejectCompletion&&u._rejectCompletion(h)}),`SUCCESS: Background subagent started. Task ID: ${d}`};var Jr=async(e,n={})=>{let o=L(e).id;if(!o)return'ERROR: Missing "id" argument for getProgress.';let s=Qe.find(i=>i.id===o);if(!s)return`ERROR: Subagent task with ID [${o}] not found.`;let r=`Subagent Task Status: ${s.status.toUpperCase()}
840
+ ... [Content/Diff Truncated from Logs] ...`)}g.push(x),n.onSubagentUpdate&&n.onSubagentUpdate()},!0).then(h=>{if(u.status==="cancelled"){u._resolveCompletion&&u._resolveCompletion(h);return}g.length>0&&(u.progress.push([...g]),g=[]),u.status="completed",u.finalAnswer=h,n.onSubagentUpdate&&n.onSubagentUpdate(),Rs(`[SYSTEM] Background subagent "${u.title}" (id: ${d}) has FINISHED. Call GetProgress(id="${d}") to see the final result. [/SYSTEM]`),u._resolveCompletion&&u._resolveCompletion(h)}).catch(async h=>{let{isTerminationSignaled:x}=await import("./ai-KNABID6V.js");if(h.message==="Subagent task was cancelled."||u.status==="cancelled"||x()){u.status="cancelled",g.push("[SUBAGENT CANCELLED] Task was cancelled."),u.progress.push([...g]),n.onSubagentUpdate&&n.onSubagentUpdate(),u._resolveCompletion&&u._resolveCompletion(null);return}g.push(`[SUBAGENT FAILURE] Error: ${h.message}`),u.progress.push([...g]),u.status="failed",u.error=h.message,n.onSubagentUpdate&&n.onSubagentUpdate(),Rs(`[SYSTEM] Background subagent "${u.title}" (id: ${d}) FAILED with error: ${h.message}. [/SYSTEM]`),u._rejectCompletion&&u._rejectCompletion(h)}),`SUCCESS: Background subagent started. Task ID: ${d}`};var Jr=async(e,n={})=>{let o=L(e).id;if(!o)return'ERROR: Missing "id" argument for getProgress.';let s=Qe.find(i=>i.id===o);if(!s)return`ERROR: Subagent task with ID [${o}] not found.`;let r=`Subagent Task Status: ${s.status.toUpperCase()}
840
841
  `;if(r+=`Title: ${s.title}
841
842
  `,r+=`Task: ${s.task}
842
843
  `,s.startedAt){let i=Math.floor((Date.now()-s.startedAt)/1e3);r+=`Elapsed Time: ${i}s
package/dist/cli.js CHANGED
@@ -63,4 +63,4 @@ Usage: fluxflow --export error`),process.exit(1)}if($&&(console.log(`v${g}`),pro
63
63
  /docs View documentation
64
64
  /fluxflow init Create FluxFlow.md template
65
65
  /update check Check for new version
66
- /update latest Install latest release`),process.exit(0)),R){let v=e[1]||"latest";if(v==="check"){let u=e[2]==="latest";try{let h=(await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json())["dist-tags"]?.latest;h||(console.error("Error: Could not retrieve latest version."),process.exit(1)),console.log(u?`Latest version: v${h}`:h!==g?`A new version of FluxFlow is available: v${h} (current: v${g}). Run "fluxflow --update latest" to upgrade.`:`FluxFlow is up to date (v${g}).`)}catch(p){console.error("Error checking for updates:",p.message),process.exit(1)}process.exit(0)}else if(v==="latest"){console.log("Checking latest version and settings...");try{let i=(await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json())["dist-tags"]?.latest;i||(console.error("Error: Could not retrieve latest version."),process.exit(1)),i===g&&(console.log(`FluxFlow is already up to date (v${g}).`),process.exit(0));let h=async()=>{let t=(await import("react")).default,{useState:L}=t,{render:K,Box:x,Text:y}=await import("ink"),Q=(await import("ink-select-input")).default,Z=(await import("ink-text-input")).default;return new Promise(ee=>{let oe=[{label:"NPM",value:"npm"},{label:"PNPM",value:"pnpm"},{label:"Yarn",value:"yarn"},{label:"Bun",value:"bun"},{label:"Custom Command",value:"custom"}],te=({label:b,isSelected:C})=>t.createElement(x,{width:"100%"},t.createElement(y,{bold:C},"\u2514\u2500 ",C?"\x1B[32m\u25CF\x1B[0m":"\u25CB"," ",b)),T,se=()=>{let[b,C]=L("select"),[ne,ae]=L(""),ie=F=>{F.value==="custom"?C("custom"):_({manager:F.value})},le=F=>{_({manager:"custom",customCommand:F})};return b==="custom"?t.createElement(x,{flexDirection:"column",marginY:1},t.createElement(x,{marginBottom:1},t.createElement(y,{color:"magenta",bold:!0},"\u{1F527} Enter custom update command:")),t.createElement(x,{flexDirection:"row"},t.createElement(y,{color:"cyan",bold:!0}," \u276F "),t.createElement(Z,{value:ne,onChange:ae,onSubmit:le})),t.createElement(x,{marginTop:1},t.createElement(y,{color:"gray",dimColor:!0,italic:!0}," (Press Enter to confirm)"))):t.createElement(x,{flexDirection:"column",marginY:1},t.createElement(x,{marginBottom:1},t.createElement(y,{color:"magenta",bold:!0},"\u{1F4E6} Select a package manager for the update:")),t.createElement(Q,{items:oe,onSelect:ie,itemComponent:te,indicatorComponent:()=>null}))},_=b=>{T&&T(),ee(b)},{unmount:re}=K(t.createElement(se,null));T=re})},d,O="",E;try{let{loadSettings:t}=await import("./chunks/settings-HTCI4KRJ.js");E=await t(),d=E?.systemSettings?.updateManager||E?.updateManager}catch{}if(!d){let t=await h();d=t.manager,O=t.customCommand}let f="";d==="pnpm"?f=`pnpm add -g fluxflow-cli@${i}`:d==="bun"?f=`bun add -g fluxflow-cli@${i}`:d==="yarn"?f=`yarn global add fluxflow-cli@${i}`:d==="custom"?f=O||E?.customUpdateCommand||`npm install -g fluxflow-cli@${i}`:f=`npm install -g fluxflow-cli@${i}`,console.log(`Updating FluxFlow to v${i} using ${d}...`),console.log(`Running: ${f}`);let{execSync:J}=await import("child_process");J(f,{stdio:"inherit"}),console.log(`\x1B[32m\u2705 Update successful! FluxFlow updated to v${i}.\x1B[0m`)}catch(u){console.error("\x1B[31m\u274C Update failed:\x1B[0m",u.message),process.exit(1)}process.exit(0)}else console.error("Unknown update command. Available options: --update, --update check, --update check latest, --update latest"),process.exit(1)}}let{default:G}=await import("react"),{render:Y}=await import("ink"),{default:W}=await import("./chunks/app-5WYBJJ2A.js");process.env.NODE_NO_WARNINGS="1";let H=["cuimp","Found existing binary","Binary verified","curl.exe not found","Falling back to .bat file","DeprecationWarning"],X=console.log,V=console.warn,z=console.error,A=o=>{let a=o.map(String).join(" ");return H.some(c=>a.includes(c))};console.log=(...o)=>!A(o)&&X(...o),console.warn=(...o)=>!A(o)&&V(...o),console.error=(...o)=>!A(o)&&z(...o);let k=e.findIndex(o=>o==="--cwd"||o==="--path");if(k!==-1&&k+1<e.length){let o=e[k+1],a=await import("path"),c=await import("fs-extra"),m=a.default.resolve(o);try{c.default.existsSync(m)&&c.default.statSync(m).isDirectory()?process.chdir(m):(console.error(`[ERROR] Directory not found: "${o}"`),process.exit(0))}catch(w){console.error(`[ERROR] Failed to change directory to "${o}": ${w.message}`),process.exit(0)}}process.stdout.write("\x1B[2J\x1B[3J\x1B[H"),process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07"),process.stdout.write("\x1B[?2004h"));let N=()=>{process.stdout.isTTY&&process.stdout.write("\x1B[?2004l")};if(process.on("exit",N),["SIGINT","SIGTERM","SIGHUP"].forEach(o=>{process.once(o,()=>{N(),process.exit(0)})}),e.includes("--playground")){let o=process.cwd();process.argv.push("--original-cwd",o);let{DATA_DIR:a}=await import("./chunks/paths-CHZDSDRF.js"),c=await import("path"),m=await import("fs-extra"),w=c.default.join(a,"playground");try{m.default.ensureDirSync(w),process.chdir(w)}catch{}}Y(G.createElement(W,{args:process.argv.slice(2)}),{exitOnCtrlC:!1})}
66
+ /update latest Install latest release`),process.exit(0)),R){let v=e[1]||"latest";if(v==="check"){let u=e[2]==="latest";try{let h=(await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json())["dist-tags"]?.latest;h||(console.error("Error: Could not retrieve latest version."),process.exit(1)),console.log(u?`Latest version: v${h}`:h!==g?`A new version of FluxFlow is available: v${h} (current: v${g}). Run "fluxflow --update latest" to upgrade.`:`FluxFlow is up to date (v${g}).`)}catch(p){console.error("Error checking for updates:",p.message),process.exit(1)}process.exit(0)}else if(v==="latest"){console.log("Checking latest version and settings...");try{let i=(await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json())["dist-tags"]?.latest;i||(console.error("Error: Could not retrieve latest version."),process.exit(1)),i===g&&(console.log(`FluxFlow is already up to date (v${g}).`),process.exit(0));let h=async()=>{let t=(await import("react")).default,{useState:L}=t,{render:K,Box:x,Text:y}=await import("ink"),Q=(await import("ink-select-input")).default,Z=(await import("ink-text-input")).default;return new Promise(ee=>{let oe=[{label:"NPM",value:"npm"},{label:"PNPM",value:"pnpm"},{label:"Yarn",value:"yarn"},{label:"Bun",value:"bun"},{label:"Custom Command",value:"custom"}],te=({label:b,isSelected:C})=>t.createElement(x,{width:"100%"},t.createElement(y,{bold:C},"\u2514\u2500 ",C?"\x1B[32m\u25CF\x1B[0m":"\u25CB"," ",b)),T,se=()=>{let[b,C]=L("select"),[ne,ae]=L(""),ie=F=>{F.value==="custom"?C("custom"):_({manager:F.value})},le=F=>{_({manager:"custom",customCommand:F})};return b==="custom"?t.createElement(x,{flexDirection:"column",marginY:1},t.createElement(x,{marginBottom:1},t.createElement(y,{color:"magenta",bold:!0},"\u{1F527} Enter custom update command:")),t.createElement(x,{flexDirection:"row"},t.createElement(y,{color:"cyan",bold:!0}," \u276F "),t.createElement(Z,{value:ne,onChange:ae,onSubmit:le})),t.createElement(x,{marginTop:1},t.createElement(y,{color:"gray",dimColor:!0,italic:!0}," (Press Enter to confirm)"))):t.createElement(x,{flexDirection:"column",marginY:1},t.createElement(x,{marginBottom:1},t.createElement(y,{color:"magenta",bold:!0},"\u{1F4E6} Select a package manager for the update:")),t.createElement(Q,{items:oe,onSelect:ie,itemComponent:te,indicatorComponent:()=>null}))},_=b=>{T&&T(),ee(b)},{unmount:re}=K(t.createElement(se,null));T=re})},d,O="",E;try{let{loadSettings:t}=await import("./chunks/settings-HTCI4KRJ.js");E=await t(),d=E?.systemSettings?.updateManager||E?.updateManager}catch{}if(!d){let t=await h();d=t.manager,O=t.customCommand}let f="";d==="pnpm"?f=`pnpm add -g fluxflow-cli@${i}`:d==="bun"?f=`bun add -g fluxflow-cli@${i}`:d==="yarn"?f=`yarn global add fluxflow-cli@${i}`:d==="custom"?f=O||E?.customUpdateCommand||`npm install -g fluxflow-cli@${i}`:f=`npm install -g fluxflow-cli@${i}`,console.log(`Updating FluxFlow to v${i} using ${d}...`),console.log(`Running: ${f}`);let{execSync:J}=await import("child_process");J(f,{stdio:"inherit"}),console.log(`\x1B[32m\u2705 Update successful! FluxFlow updated to v${i}.\x1B[0m`)}catch(u){console.error("\x1B[31m\u274C Update failed:\x1B[0m",u.message),process.exit(1)}process.exit(0)}else console.error("Unknown update command. Available options: --update, --update check, --update check latest, --update latest"),process.exit(1)}}let{default:G}=await import("react"),{render:Y}=await import("ink"),{default:W}=await import("./chunks/app-QSQPQP5X.js");process.env.NODE_NO_WARNINGS="1";let H=["cuimp","Found existing binary","Binary verified","curl.exe not found","Falling back to .bat file","DeprecationWarning"],X=console.log,V=console.warn,z=console.error,A=o=>{let a=o.map(String).join(" ");return H.some(c=>a.includes(c))};console.log=(...o)=>!A(o)&&X(...o),console.warn=(...o)=>!A(o)&&V(...o),console.error=(...o)=>!A(o)&&z(...o);let k=e.findIndex(o=>o==="--cwd"||o==="--path");if(k!==-1&&k+1<e.length){let o=e[k+1],a=await import("path"),c=await import("fs-extra"),m=a.default.resolve(o);try{c.default.existsSync(m)&&c.default.statSync(m).isDirectory()?process.chdir(m):(console.error(`[ERROR] Directory not found: "${o}"`),process.exit(0))}catch(w){console.error(`[ERROR] Failed to change directory to "${o}": ${w.message}`),process.exit(0)}}process.stdout.write("\x1B[2J\x1B[3J\x1B[H"),process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07"),process.stdout.write("\x1B[?2004h"));let N=()=>{process.stdout.isTTY&&process.stdout.write("\x1B[?2004l")};if(process.on("exit",N),["SIGINT","SIGTERM","SIGHUP"].forEach(o=>{process.once(o,()=>{N(),process.exit(0)})}),e.includes("--playground")){let o=process.cwd();process.argv.push("--original-cwd",o);let{DATA_DIR:a}=await import("./chunks/paths-CHZDSDRF.js"),c=await import("path"),m=await import("fs-extra"),w=c.default.join(a,"playground");try{m.default.ensureDirSync(w),process.chdir(w)}catch{}}Y(G.createElement(W,{args:process.argv.slice(2)}),{exitOnCtrlC:!1})}
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluxflow-cli",
3
- "version": "4.8.0",
3
+ "version": "4.8.1",
4
4
  "date": "2026-09-01",
5
5
  "description": "One of the lightest, fastest, high-fidelity agentic CLI with sub-agents & computer use.",
6
6
  "keywords": [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fluxflow-cli",
3
- "version": "4.8.0",
3
+ "version": "4.8.1",
4
4
  "date": "2026-09-01",
5
5
  "description": "One of the lightest, fastest, high-fidelity agentic CLI with sub-agents & computer use.",
6
6
  "keywords": [