fluxflow-cli 4.10.2 → 4.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/addMemScore-EIIMCED3.js +1 -0
- package/dist/chunks/ai-WB4PWDHV.js +1 -0
- package/dist/chunks/answerSubagent-JUVFNLE5.js +1 -0
- package/dist/chunks/app-DLM4TCBT.js +225 -0
- package/dist/chunks/ask_user-K2DLZF6H.js +1 -0
- package/dist/chunks/awaitSubagent-JTUSJDKD.js +7 -0
- package/dist/chunks/cancel-7IMADALP.js +1 -0
- package/dist/chunks/chat-5CITJOXW.js +1 -0
- package/dist/chunks/chunk-2CJOOYOT.js +1 -0
- package/dist/chunks/chunk-2TASXARO.js +1 -0
- package/dist/chunks/chunk-5GEXRVU6.js +15 -0
- package/dist/chunks/chunk-5K4X2VUW.js +33 -0
- package/dist/chunks/chunk-6GTIZENY.js +48 -0
- package/dist/chunks/chunk-A73NNVCZ.js +1 -0
- package/dist/chunks/chunk-DHQHSTTS.js +1 -0
- package/dist/chunks/chunk-FJGY5C4M.js +52 -0
- package/dist/chunks/chunk-GFDJETGV.js +868 -0
- package/dist/chunks/chunk-TGINXVDR.js +1 -0
- package/dist/chunks/chunk-TJII6UKN.js +6 -0
- package/dist/chunks/chunk-Y5JU726N.js +4 -0
- package/dist/chunks/click-WCT2TJ2G.js +2 -0
- package/dist/chunks/computer_action-EKG5CRRA.js +1 -0
- package/dist/chunks/drag-HYJQ5RE7.js +1 -0
- package/dist/chunks/emergency_rollback-A67M4DU6.js +18 -0
- package/dist/chunks/exec_command-43ZNHLVJ.js +1 -0
- package/dist/chunks/file_map-YYKJC7LP.js +9 -0
- package/dist/chunks/generate_image-Q6RIYYMI.js +1 -0
- package/dist/chunks/getProgress-KLWGCCPA.js +26 -0
- package/dist/chunks/invoke-RTBTXXOI.js +6 -0
- package/dist/chunks/invokeSync-RNOOUMPZ.js +3 -0
- package/dist/chunks/key_press-RKJOUTTG.js +1 -0
- package/dist/chunks/keyboard_typing-GJBWCAZ2.js +1 -0
- package/dist/chunks/memory-22U3WGHY.js +1 -0
- package/dist/chunks/read_folder-OOKZITME.js +15 -0
- package/dist/chunks/recapture_screen-5FKLOHJL.js +1 -0
- package/dist/chunks/saveSummary-2LC63SYI.js +1 -0
- package/dist/chunks/scroll-DVM5ACY2.js +1 -0
- package/dist/chunks/search_keyword-Y2B3YELW.js +8 -0
- package/dist/chunks/steerSubagent-L2JVT4QN.js +1 -0
- package/dist/chunks/todo-VFONYOUK.js +10 -0
- package/dist/chunks/update_file-CF2DSC6F.js +13 -0
- package/dist/chunks/view_file-SRYT37FH.js +1 -0
- package/dist/chunks/web_scrape-EWLJFTMV.js +16 -0
- package/dist/chunks/web_search-KNT73E64.js +36 -0
- package/dist/chunks/write_docx-T4UJCJ3L.js +13 -0
- package/dist/chunks/write_file-N2EG2T6U.js +29 -0
- package/dist/chunks/write_pdf-NGUPNIEZ.js +31 -0
- package/dist/cli.js +9 -9
- package/dist/package.json +1 -1
- package/flux-flow.cjs +17 -16
- package/package.json +1 -1
- package/dist/chunks/ai-LWFS4KRY.js +0 -1
- package/dist/chunks/app-IMH36EZP.js +0 -225
- package/dist/chunks/chunk-YPTXLUPC.js +0 -1246
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import{a as Li,b as Ke,c as Je,d as pr,e as Tr,f as Ni,g as gs,h as Qo,i as yr,r as Yi,u as Vi,v as Hn,w as ji,x as Ki,y as qi}from"./chunk-GFDJETGV.js";import"./chunk-2TASXARO.js";import{a as Wi}from"./chunk-56EJGQU3.js";import{b as $i,c as Hi,d as Gi}from"./chunk-DHQHSTTS.js";import{a as Po,b as gn,d as wr,e as ms,f as Fi,g as Ui,i as _i,j as br}from"./chunk-TJII6UKN.js";import"./chunk-5GEXRVU6.js";import{a as vt,b as wt,c as ft,d as ki,h as cs,i as us,j as _n,l as Ai,m as bo}from"./chunk-6GTIZENY.js";import{a as $n}from"./chunk-TGINXVDR.js";import{b as un,c as is,k as vi}from"./chunk-JSVFQZL2.js";import{b as ds}from"./chunk-TA42E3DA.js";import{a as Ei,b as Bi,c as hr,d as xr,f as Mt,g as qo,h as as,l as Di}from"./chunk-Q7SNDU5P.js";import{a as Si,b as Ci,c as ss,e as Oo,f as ao,g as Mi,h as ls,i as Lt}from"./chunk-K26OGD74.js";import{c as bi,d as yi,e as fr}from"./chunk-SIINYZWE.js";import{e as Ii}from"./chunk-7PJOF5I2.js";import{b as Oi,d as mn,e as jt,f as Pi}from"./chunk-5K4X2VUW.js";import"./chunk-FJGY5C4M.js";import{a as Xi}from"./chunk-A73NNVCZ.js";import{a as Lo,b as Ko,c as lo,d as gr,e as ns,j as rs}from"./chunk-4TZKD2XR.js";import{a as Xn}from"./chunk-Y5JU726N.js";import Ns from"os";import e,{useState as j,useEffect as Ze,useRef as Ye,useMemo as Tn}from"react";import{Box as c,Text as i,useInput as Pd,useStdout as Nd,Static as Fd}from"ink";import Ud from"ink-spinner";import at from"fs-extra";import Et from"path";import{exec as xo}from"child_process";import{fileURLToPath as _d}from"url";import $t,{useState as Sr,useEffect as fs,useMemo as Gn,useCallback as ia,useRef as yo}from"react";import{Box as la,Text as to,useInput as aa}from"ink";function da(t,h){return t.replace(/\t/g," ".repeat(h))}function Cr(t){return t==null?"":t.replace(/\r\n/g,`
|
|
2
|
+
`).replace(/\r/g,`
|
|
3
|
+
`)}function zo(t,h,x){let S=t,p=[...h].sort((s,I)=>s.start-I.start),T=0;for(let s of p){let I=s.start-T,m=Cr(s.text).split(`
|
|
4
|
+
`).length,v=s.text.length,E=(m>3?`[Pasted ${m} lines]`:`[Pasted ${v} chars]`).length,N=I+E;if(t<=I)break;if(t<N){S=s.end;break}else{let M=s.text.length-E;S+=M,T+=M}}return Math.min(S,x.length)}function hs(t,h,x,S,p=[]){let T=(t||"").slice(0,h),s=S(T).length,I=S(t||""),m=[...p].sort((O,k)=>k.start-O.start);for(let O of m){let k=S(t.slice(0,O.start)).length,X=S(O.text),ee=k+X.length,le=Cr(O.text).split(`
|
|
5
|
+
`).length,he=O.text.length,K=le>3?`[Pasted ${le} lines]`:`[Pasted ${he} chars]`;I=I.slice(0,k)+K+I.slice(ee),s>k&&s<ee?s=k+K.length:s>=ee&&(s=s-(ee-k)+K.length)}let v=I.split(`
|
|
6
|
+
`),E=[],N=0,M=0,D=0,L=!1;for(let O=0;O<v.length;O++){let k=v[O];if(k.length===0){!L&&s===N&&(M=E.length,D=0,L=!0),E.push({text:"",globalStart:zo(N,p,t),formattedStart:N}),N+=1;continue}let ee=wt(k,x).split(`
|
|
7
|
+
`),le=0,he=[];for(let K=0;K<ee.length;K++){let q=ee[K],re=q.trim();if(re.length===0){let Be=q.length||1;he.push({text:q,start:le,length:Be}),le+=Be}else{let Be=k.indexOf(re,le);if(Be!==-1){let De=le,Le=K<ee.length-1?ee[K+1].trim():"",me=k.length;if(Le.length>0){let $e=k.indexOf(Le,Be+re.length);$e!==-1&&(me=$e)}he.push({text:k.slice(De,me),start:De,length:me-De}),le=me}else he.push({text:q,start:le,length:q.length}),le+=q.length}}for(let K=0;K<he.length;K++){let q=he[K],re=q.text,Be=N+q.start,De=Be+q.length;!L&&s>=Be&&(s<De||s===De&&K===he.length-1)&&(M=E.length,D=s-Be,L=!0),E.push({text:re,globalStart:zo(Be,p,t),formattedStart:Be})}N+=k.length+1}return L||(E.length===0?E.push({text:"",globalStart:0,formattedStart:0}):I.endsWith(`
|
|
8
|
+
`)?(E.push({text:"",globalStart:zo(N,p,t),formattedStart:N}),M=E.length-1,D=0):(M=E.length-1,D=E[M].text.length)),{visualLines:E,cursorLine:M,cursorCol:D}}var ca=({value:t,rows:h,maxRows:x,highlightStyle:S,textStyle:p,placeholder:T="",mask:s,showCursor:I=!0,focus:m=!0,tabSize:v=4,cursorIndex:E=0,highlight:N,columns:M=80,pasteBlocks:D=[],cursorColor:L})=>{let O=yo(0),k=Gn(()=>Math.max(20,M-10),[M]),X=ia((Te,J=!1)=>{let H=Cr(Te);if(!J&&s)return H.replace(/[^\n]/g,s);let ne=da(H,v);return J?ne:ne.replace(/@\[(.*?)\]/g,(Se,ue)=>{let ve=ue.indexOf("#"),ie=ue.indexOf(":L"),Me=ue,ze="";ve!==-1?(Me=ue.slice(0,ve),ze=ue.slice(ve)):ie!==-1&&(Me=ue.slice(0,ie),ze=ue.slice(ie));let qe=Me.replace(/\\/g,"/"),we=(process.cwd()||"").replace(/\\/g,"/");we&&qe.toLowerCase().startsWith(we.toLowerCase()+"/")?qe=qe.slice(we.length+1):qe.startsWith("./")&&(qe=qe.slice(2));let te=qe.split("/");return`[${te[te.length-1]}${ze}]`})},[v,s]),{visualLines:ee,cursorLine:le,cursorCol:he}=Gn(()=>hs(t,E,k,X,D),[t,E,k,X,D]),K=ee.length,q=Gn(()=>Math.max(h??x??1,Math.min(x??h??1,K)),[h,x,K]),re=le+1,Be=O.current+q,De=O.current;re<=O.current?De=Math.max(0,re-1):re>Be?De=re-q:K&&(K<q?De=0:K<Be&&(De=K-q)),O.current=De;let Le=Gn(()=>ee.slice(De,De+q),[ee,De,q]),[me,$e]=Sr(!0);fs(()=>{if($e(!0),!m||!I)return;let Te=setInterval(()=>{$e(J=>!J)},530);return()=>clearInterval(Te)},[m,I,t,E]);let pe=Gn(()=>({...p,color:I&&m&&me?L||"white":void 0,bold:I&&m&&me,inverse:I&&m&&me}),[p,I,m,me,L]),Y=(Te,J,H,ne)=>{if(!Te){let Me=T&&t.length===0?X(T,!0):"";if(J){let ze=Me[0]||" ",qe=Me.slice(1);return $t.createElement(to,null,$t.createElement(to,{...ne},ze),$t.createElement(to,{color:"gray",dimColor:!0},qe))}return $t.createElement(to,{color:"gray",dimColor:!0},Me||" ")}let Se=/(\[Pasted \d+ (?:lines|chars)\])/g,ue=Te.split(Se),ve=0,ie=[];for(let Me=0;Me<ue.length;Me++){let ze=ue[Me];if(ze==="")continue;let qe=ze.match(/^\[Pasted \d+ (?:lines|chars)\]$/),we=ze.length,te=ve+we;if(J&&H>=ve&&H<te){let xe=H-ve,Xe=ze.slice(0,xe),P=ze[xe]||" ",ut=ze.slice(xe+1);ie.push($t.createElement(to,{key:Me},$t.createElement(to,{color:qe?"magenta":void 0},Xe),$t.createElement(to,{...ne},P),$t.createElement(to,{color:qe?"magenta":void 0},ut)))}else ie.push($t.createElement(to,{key:Me,color:qe?"magenta":void 0},ze));ve=te}return J&&H>=Te.length&&ie.push($t.createElement(to,{key:"cursor-end",...ne}," ")),$t.createElement($t.Fragment,null,ie)};return $t.createElement(la,{height:q,width:k+1,overflow:"hidden",flexDirection:"column",flexGrow:0,flexShrink:0},Le.map((Te,J)=>{let H=De+J,ne=H===le&&m&&I;return $t.createElement(to,{key:H,...p,wrap:"truncate"},Y(Te.text,ne,he,pe))}))},Qi=({value:t,onChange:h,onSubmit:x,keyBindings:S,showCursor:p=!0,highlightPastedText:T=!1,focus:s=!0,columns:I=80,useCustomInput:m=(M,D)=>aa(M,{isActive:D}),onPasteStateChange:v,cursorColor:E,...N})=>{let[M,D]=Sr(t.length),[L,O]=Sr(0),[k,X]=Sr([]),ee=yo(t.length),le=yo(t),he=yo(0),K=yo([]),q=yo(""),re=yo(-1),Be=yo(null),De=yo(0);ee.current=M,le.current=t,he.current=L,K.current=k,fs(()=>{ee.current>t.length&&(ee.current=t.length,D(t.length)),t?X($e=>$e.filter(pe=>pe.end<=t.length&&pe.start<=t.length)):(X([]),O(0))},[t]),fs(()=>{v?.(k.length>0)},[k,v]);let Le=()=>{let $e=q.current,pe=re.current,Y=pe+$e.length,Te=le.current,J=Te.slice(0,pe)+$e+Te.slice(pe);h(J),ee.current=Y,D(Y),O($e.length>1?$e.length:0);let H=Cr($e).split(`
|
|
9
|
+
`).length,ne=$e.length;if(ne>50&&(H>3||H<=3&&ne>200)){let Se={start:pe,end:Y,text:$e};X(ue=>{let ve=$e.length;return[...ue.map(Me=>pe<=Me.start?{...Me,start:Me.start+ve,end:Me.end+ve}:Me),Se]})}q.current="",re.current=-1,Be.current=null},me=()=>{Be.current&&(clearTimeout(Be.current),Le())};return m(($e,pe)=>{if($e==="\x1B[I"||$e==="\x1B[O"||$e==="[I"||$e==="[O")return;let Y=$e,Te=!1,J=!1;Y&&typeof Y=="string"&&(Y.includes("\x1B[200~")&&(Te=!0,Y=Y.replace(/\x1b\[200~/g,"")),Y.includes("\x1B[201~")&&(J=!0,Y=Y.replace(/\x1b\[201~/g,"")));let H=ee.current,ne=le.current,Se=K.current,ue=Math.max(20,I-10),ve=(te,xe)=>{if(Se.length===0)return;let Xe=Se.map(P=>te<=P.start?{...P,start:P.start+xe,end:P.end+xe}:te>P.start&&te<P.end?null:P).filter(Boolean);X(Xe)},ie=te=>{for(let xe of Se)if(te>xe.start&&te<xe.end)return xe.start;return te};if(pe.ctrl&&(Y==="o"||Y==="")){X([]);return}if(pe.ctrl&&(Y.toLowerCase()==="r"||Y===""||Y===""))return;if(pe.upArrow||pe.downArrow||pe.leftArrow||pe.rightArrow){me();let te=Date.now();if(te-De.current<33)return;De.current=te}let ze=S?.submit??(te=>te.return&&te.ctrl),qe=S?.newline??(te=>te.return);if(ze(pe)){me(),x?.(ne);return}else if(qe(pe)){me(),ve(H,1);let te=ne.slice(0,H)+`
|
|
10
|
+
`+ne.slice(H);h(te),ee.current=H+1,D(H+1),O(0);return}if(pe.tab||pe.shift&&pe.tab||pe.ctrl&&Y==="c")return;let we=te=>te;if(pe.upArrow||pe.downArrow){if(me(),p){let{visualLines:te,cursorLine:xe,cursorCol:Xe}=hs(ne,H,ue,we,Se),P=pe.upArrow?xe-1:xe+1;if(P>=0&&P<te.length){let ut=te[P],mt=Math.min(Xe,ut.text.length),Ut=ut.formattedStart+mt,Wt=zo(Ut,Se,ne);Wt=ie(Wt),ee.current=Wt,D(Wt),O(0)}else if(pe.upArrow&&xe===0)ee.current=0,D(0),O(0);else if(pe.downArrow&&xe===te.length-1){let ut=te[te.length-1],mt=ut.formattedStart+ut.text.length,Ut=zo(mt,Se,ne);Ut=ie(Ut),ee.current=Ut,D(Ut),O(0)}}}else if(pe.leftArrow){if(me(),p){let te=Math.max(0,H-1),xe=Se.find(Xe=>H===Xe.end);xe&&(te=xe.start),ee.current=te,D(te),O(0)}}else if(pe.rightArrow){if(me(),p){let te=Math.min(ne.length,H+1),xe=Se.find(Xe=>H===Xe.start);xe&&(te=xe.end),ee.current=te,D(te),O(0)}}else if(pe.backspace){me();let te=Se.findIndex(xe=>H===xe.end);if(te!==-1){let xe=Se[te],Xe=-(xe.end-xe.start),P=ne.slice(0,xe.start)+ne.slice(xe.end);h(P),ee.current=xe.start,D(xe.start),O(0);let ut=Se.filter((mt,Ut)=>Ut!==te).map(mt=>mt.start>=xe.end?{...mt,start:mt.start+Xe,end:mt.end+Xe}:mt);X(ut)}else if(H>0){ve(H-1,-1);let xe=ne.slice(0,H-1)+ne.slice(H);h(xe),ee.current=H-1,D(H-1),O(0)}}else if(pe.delete){me();let te=Se.findIndex(xe=>H===xe.start);if(te!==-1){let xe=Se[te],Xe=-(xe.end-xe.start),P=ne.slice(0,xe.start)+ne.slice(xe.end);h(P),O(0);let ut=Se.filter((mt,Ut)=>Ut!==te).map(mt=>mt.start>=xe.end?{...mt,start:mt.start+Xe,end:mt.end+Xe}:mt);X(ut)}else if(ve(H,-1),H<ne.length){let xe=ne.slice(0,H)+ne.slice(H+1);h(xe),O(0)}}else if(pe.home||pe.end){if(me(),p){let{visualLines:te,cursorLine:xe}=hs(ne,H,ue,we,Se),Xe=te[xe];if(Xe){let P;pe.home?P=zo(Xe.formattedStart,Se,ne):pe.end&&(P=zo(Xe.formattedStart+Xe.text.length,Se,ne)),P=ie(P),ee.current=P,D(P),O(0)}}}else if(Y!==""||Te||J)if(Te||J||Y.length>1||Be.current!==null)Be.current?(clearTimeout(Be.current),q.current+=Y):(re.current=H,q.current=Y),J?(Be.current=null,Le()):Be.current=setTimeout(()=>{Le()},80);else{ve(H,Y.length);let xe=ne.slice(0,H)+Y+ne.slice(H);h(xe);let Xe=H+Y.length;ee.current=Xe,D(Xe),O(0)}},s),$t.createElement(ca,{...N,value:t,cursorIndex:M,showCursor:p,focus:s,columns:I,pasteBlocks:k,cursorColor:E})};import kr from"ink-text-input";import"ink-select-input";import r from"react";import{Box as A,Text as Q}from"ink";import Dt,{useState as ua}from"react";import{Box as So,Text as Co,useInput as ma}from"ink";var Mr=Dt.memo(({command:t,output:h,completed:x=!1,isFocused:S=!1,columns:p=80,isPty:T=!1,terminalHeight:s=24,theme:I="Dark"})=>{let m=Ke(I),E=(he=>{if(!he)return"";let K=[[]],q=0,re=0,Be="",De=/\x1b\[([0-9;]*?)([a-zA-Z])/g,Le=0,me,$e=Y=>{for(let Te=0;Te<Y.length;Te++){let J=Y[Te];if(J===`
|
|
11
|
+
`)for(q++,re=0;q>=K.length;)K.push([]);else if(J==="\r")re=0;else{for(;q>=K.length;)K.push([]);let H=K[q];for(;re>H.length;)H.push({char:" ",style:""});H[re]={char:J,style:Be},re++}}};for(;(me=De.exec(he))!==null;){$e(he.substring(Le,me.index));let Y=me[1],Te=me[2],J=Y?Y.split(";").map(Number):[];if(Te==="A"){let H=J[0]||1;q=Math.max(0,q-H)}else if(Te==="B"){let H=J[0]||1;for(q=q+H;q>=K.length;)K.push([])}else if(Te==="C"){let H=J[0]||1;re=re+H}else if(Te==="D"){let H=J[0]||1;re=Math.max(0,re-H)}else if(Te==="G"){let H=(J[0]||1)-1;re=Math.max(0,H)}else if(Te==="H"||Te==="f"){let H=(J[0]||1)-1,ne=(J[1]||1)-1;for(q=Math.max(0,H),re=Math.max(0,ne);q>=K.length;)K.push([])}else if(Te==="K"){let H=J[0]||0;if(q<K.length){let ne=K[q];if(H===0)ne.length=re;else if(H===1)for(let Se=0;Se<re&&Se<ne.length;Se++)ne[Se]={char:" ",style:""};else H===2&&(ne.length=0)}}else if(Te==="J"){let H=J[0]||0;(H===2||H===3)&&(K.length=0,K.push([]),q=0,re=0)}else if(Te==="m"){let H=me[0];H==="\x1B[0m"?Be="":Be=H}Le=De.lastIndex}$e(he.substring(Le));let pe=K.map(Y=>{let Te="",J="";for(let H=0;H<Y.length;H++){let ne=Y[H]||{char:" ",style:""};ne.style!==J&&(J&&(Te+="\x1B[0m"),Te+=ne.style,J=ne.style),Te+=ne.char}return J&&(Te+="\x1B[0m"),Te});for(;pe.length>0&&pe[pe.length-1]==="";)pe.pop();return pe.join(`
|
|
12
|
+
`)})(h).replace(/\n{3,}/g,`
|
|
13
|
+
|
|
14
|
+
`),N=T?E?E.split(`
|
|
15
|
+
`):[]:E?wt(E,p-6).split(`
|
|
16
|
+
`):[],[M,D]=ua(!1);ma((he,K)=>{S&&K.ctrl&&(he==="o"||he==="")&&D(q=>!q)},{isActive:S});let L=Math.max(5,x?s-10:s-25),O=N.length>L,k=N.length-L,ee=(O&&!M?N.slice(N.length-L):N).join(`
|
|
17
|
+
`),le=N.length>0;return Dt.createElement(So,{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:p-2},Dt.createElement(So,{marginBottom:1,justifyContent:"space-between",width:"100%"},Dt.createElement(So,{flexShrink:1,paddingRight:2},Dt.createElement(Co,null,Dt.createElement(Co,{color:m.text,bold:!0},x?"\u{1F3C1} FINISHED:":"\u26A1 EXECUTING:"," "),Dt.createElement(Co,{color:m.text},t))),T&&Dt.createElement(So,{flexShrink:0,paddingX:1},Dt.createElement(Co,{color:"green",bold:!0},"ADVANCE"))),le?Dt.createElement(So,{flexDirection:"column",marginTop:0,backgroundColor:T?void 0:m.codeBg,paddingX:1,width:"100%"},O&&!M&&Dt.createElement(So,{marginBottom:1},Dt.createElement(Co,{color:"magenta"},"...",k," lines collapsed...")),Dt.createElement(Co,{color:m.text},ee)):!x&&Dt.createElement(So,{marginTop:1,backgroundColor:T?void 0:m.codeBg,paddingX:1,width:"100%"},Dt.createElement(Co,{color:m.textMuted,italic:!0},"Waiting for output...")),Dt.createElement(So,{justifyContent:"space-between",marginTop:1},x?Dt.createElement(So,null):Dt.createElement(Co,{color:m.textMuted,italic:!0},S?"Press TAB to unfocus, then double-press ESC to terminate.":"Double-press ESC to terminate if hanging."),Dt.createElement(Co,{color:m.textMuted,bold:!0},x?"\u25CF ARCHIVED":S?"\u25B6 TERMINAL FOCUSED":"\u25CF LIVE (Press TAB to focus)")))});import{diffWordsWithSpace as ga}from"diff";var Wn=null,Zi=t=>{Wn=t!==!1},Ri=()=>{if(Wn===null)try{Wn=fr(Ko,{})?.systemSettings?.preserveThinking!==!1}catch{Wn=!0}return Wn},zi=(t,h,x)=>t,fa=(t,h=80)=>{if(!t)return null;let x=h-10,S=t.trim();if(!S.includes("```"))return r.createElement(A,{width:"100%",flexDirection:"column"},r.createElement(hn,{text:S,color:"#969696",columns:x,italic:!0}));let p=S.split(/(```\w*\n?[\s\S]*?(?:```|$))/g);return r.createElement(A,{width:"100%",flexDirection:"column"},p.map((T,s)=>{if(T.startsWith("```")){let m=T.match(/```(\w*)\n?([\s\S]*?)(?:```|$)/),v=m?m[2]:T.replace(/^```\w*\n?/,"").replace(/```$/,""),E=wt(v.trimEnd(),x);return r.createElement(A,{key:s,flexDirection:"column",width:"100%"},E.split(`
|
|
18
|
+
`).map((N,M)=>r.createElement(Q,{key:M,color:"cyan"},N)))}let I=T;return s>0&&(I=I.replace(/^[\r\n]+/,"")),s<p.length-1&&(I=I.replace(/[\r\n]+$/,"")),I?r.createElement(hn,{key:s,text:I,color:"gray",columns:x,italic:!0}):null}))},ha=/(```[\s\S]*?```|`[^`\r\n]+`|@\[.*?\]|\*\*.*?\*\*|\*.*?\*|\\\(.*?\\\)|\\\[.*?\\\]|\$.*?\$|\[.*?\]\s*\(.*?\)|\[.*?\]\s*\[.*?\]|https?:\/\/[^\s]+)/g;var xa=/\\frac\s*\{([^{}]*)\}\s*\{([^{}]*)\}/g,pa=/(\\(?:mathbf|textbf|textit|underline|texttt)\{[^{}]*\})/g;var Ta=/\\multiply|\\mul|\\times/g,wa=/\\div/g,ba=/\\cdot/g,ya=/\\infty/g,Sa=/\\pm/g,Ca=/\\leq/g,Ma=/\\geq/g,va=/\\neq/g,Ea=/\\sqrt\s*\{([^}]+)\}/g,Ba=/\\sqrt\s*(\w+|\d+)/g,Da=/\\alpha/g,Ia=/\\beta/g,ka=/\\theta/g,Aa=/\\pi/g,La=/\\approx/g,Oa=/\\Delta/g,Pa=/\\sigma/g,Na=/\\sum/g,Fa=/\\prod/g,Ua=/\\rightarrow|\\to/g,_a=/\\left\b|\\right\b/g,Xa=/\\left\(|\\right\)/g,$a=/\\left\[|\\right\]/g,Ha=/\\\{|\\\}/g,Ga=/\\text\s*\{([^}]+)\}/g,Wa=/\\text\s+(\w+)/g,Ya=/\\%/g,Va=/\\\(|\\\)/g,ja=/\\\[|\\\]/g,Ka=/@\[(.*?)\]/g,Ji=/:L/gi,qa=/\[(.*?)\]\s*\((.*?)\)/,Qa=/\[(.*?)\]\s*\[(.*?)\]/,za=/\\(\w+)\{([^{}]*)\}/,Ja=t=>t.replace(Va,h=>h.includes("(")?"(":")").replace(ja,h=>h.includes("[")?"[":"]").replace(Ta,"\xD7").replace(wa,"\xF7").replace(ba,"\u22C5").replace(ya,"\u221E").replace(Sa,"\xB1").replace(Ca,"\u2264").replace(Ma,"\u2265").replace(va,"\u2260").replace(Ea,"\u221A($1)").replace(Ba,"\u221A($1)").replace(Da,"\u03B1").replace(Ia,"\u03B2").replace(ka,"\u03B8").replace(Aa,"\u03C0").replace(La,"\u2248").replace(Oa,"\u0394").replace(Pa,"\u03C3").replace(Na,"\u03A3").replace(Fa,"\u03A0").replace(Ua,"\u2192").replace(_a,"").replace(Xa,h=>h.includes("left")?"(":")").replace($a,h=>h.includes("left")?"[":"]").replace(Ha,h=>h.includes("{")?"{":"}").replace(Ga,"$1").replace(Wa,"$1").replace(Ya,"%"),Za=/\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/,Ra=[/((?<=\binclude\s+)(?:<[^>]+>|"[^"]+"))/.source,/((?<=\b(?:from|import|require\s*\(\s*)\s*)(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"))/.source,/(\/\/.*|#.*)/.source,/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^\`\\])*`)/.source,Za.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],xs=new RegExp(Ra.join("|"),"g"),fn=new Map,ed=1e3,td=(t,h)=>{if(!t)return[];let x=`${h}:${t}`;if(fn.has(x))return fn.get(x);let S=0,p=[],T;for(xs.lastIndex=0;(T=xs.exec(t))!==null;){let s=T[0],I=T.index;I>S&&p.push({text:vt(t.substring(S,I))});let m,v=!1;T[1]||T[2]?m="#ce9178":T[3]?m="#9ece6a":T[4]?m="#fcfca4":T[5]?(m="#ff7b72",v=!0):T[6]?m="#b392f0":(T[7]||T[8])&&(m="#ff9e64"),p.push({text:vt(s),color:m,bold:v}),S=xs.lastIndex}if(S<t.length&&p.push({text:vt(t.substring(S))}),fn.size>=ed){let s=fn.keys().next().value;fn.delete(s)}return fn.set(x,p),p},Nt=(t,h,x=void 0,S=void 0)=>{if(!t)return r.createElement(Q,{backgroundColor:S}," ");let p=td(t,h);return r.createElement(Q,{color:x,backgroundColor:S},p.map((T,s)=>r.createElement(Q,{key:s,color:T.color||x,backgroundColor:S,bold:T.bold},T.text)))},ps=(t,h)=>{if(!t)return null;let x=t.replace(xa,"($1/$2)");x=Ja(x);let S=x.split(pa);return r.createElement(r.Fragment,{key:h},S.map((p,T)=>{if(p.startsWith("\\")){let s=p.match(za);if(s){let I=s[1],m=s[2];return r.createElement(Q,{key:T,bold:I==="mathbf"||I==="textbf",italic:I==="textit",underline:I==="underline",color:I==="texttt"?"cyan":void 0},m)}}return p}))},No=r.memo(({text:t,color:h,italic:x,theme:S="Dark"})=>{if(!t)return null;let p=Ke(S),T=h||p.text,s=p.codeText||p.logoGradient&&p.logoGradient[0]||p.info||p.secondary||"cyan",I=t.split(ha);return r.createElement(Q,{color:T,wrap:"anywhere",italic:x},I.map((m,v)=>{if(!m)return null;if(m.startsWith("```")&&m.endsWith("```")){let E=m.slice(3,-3);return r.createElement(Q,{key:v,color:s},E)}if(m.startsWith("**")&&m.endsWith("**"))return r.createElement(Q,{key:v,bold:!0,color:T},r.createElement(No,{text:m.slice(2,-2),color:T,theme:S}));if(m.startsWith("*")&&m.endsWith("*"))return r.createElement(Q,{key:v,italic:!0,color:T},r.createElement(No,{text:m.slice(1,-1),color:T,italic:x,theme:S}));if(m.startsWith("`"))if(m.endsWith("`")&&m.length>1){let E=m.slice(1,-1),N=E.replace(Ka,(D,L)=>L.split("/").pop().split("\\").pop().replace(Ji,"#L")),M=E.includes("@[");return r.createElement(Q,{key:v,color:s,bold:M},N)}else return r.createElement(Q,{key:v,color:s},m.slice(1));if(m.startsWith("@[")&&m.endsWith("]")){let N=m.slice(2,-1).split("/").pop().split("\\").pop().replace(Ji,"#L");return r.createElement(Q,{key:v,color:s,bold:!0},N)}if(m.startsWith("\\(")&&m.endsWith("\\)")||m.startsWith("\\[")&&m.endsWith("\\]")){let E=m.slice(2,-2);return r.createElement(Q,{key:v,color:"yellow"},ps(E,v))}if(m.startsWith("$")&&m.endsWith("$")){let E=m.slice(1,-1);return r.createElement(Q,{key:v,color:"yellow"},ps(E,v))}if(m.startsWith("[")&&(m.includes("](")||m.includes("] ("))){let E=m.match(qa);if(E)return r.createElement(Q,{key:v},r.createElement(Q,{color:s,underline:!0,bold:!0},E[1]),r.createElement(Q,{color:"gray",italic:!0}," (",E[2],")"))}if(m.startsWith("[")&&(m.includes("][")||m.includes("] ["))){let E=m.match(Qa);if(E)return r.createElement(Q,{key:v},r.createElement(Q,{color:s,underline:!0,bold:!0},E[1]),r.createElement(Q,{color:"gray",italic:!0}," [",E[2],"]"))}return m.startsWith("http")?r.createElement(Q,{key:v,color:s,underline:!0,italic:!0},m):ps(m,v)}))}),el=r.memo(({buffer:t,terminalWidth:h=80,theme:x="Dark"})=>{if(t.length<2)return null;let S=Ke(x),p=S.codeText||S.secondary||S.info||"cyan",T=t.map(N=>{let M=N.split("|");return M[0]!==void 0&&M[0].trim()===""&&M.shift(),M.length>0&&M[M.length-1].trim()===""&&M.pop(),M.map(D=>D.trim())}),s=T[0],I=T.slice(2),m=Math.floor(100/s.length),v=h-8,E=Math.floor(v/s.length)-2;return r.createElement(A,{flexDirection:"column",borderStyle:"round",borderColor:S.borderMuted,paddingX:1,marginY:0,width:h-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%"},s.map((N,M)=>r.createElement(A,{key:M,flexBasis:`${m}%`,flexGrow:1,flexShrink:0,paddingRight:2},r.createElement(No,{text:wt(N,E),color:p,theme:x})))),I.map((N,M)=>r.createElement(A,{key:M,flexDirection:"row",marginBottom:M===I.length-1?0:1,width:"100%"},N.map((D,L)=>r.createElement(A,{key:L,flexBasis:`${m}%`,flexGrow:1,flexShrink:0,paddingRight:2,flexDirection:"column"},r.createElement(No,{text:wt(D,E),color:S.text,theme:x}))))))}),hn=r.memo(({text:t,color:h,columns:x=80,italic:S=!1,theme:p="Dark"})=>{if(!t)return null;let T=Ke(p),s=h||T.text,I=t.split(`
|
|
19
|
+
`),m=[],v=[],E=[],N=M=>{if(v.length>0&&(m.push(r.createElement(el,{key:`table-${M}`,buffer:[...v],terminalWidth:x,theme:p})),v=[]),E.length>0){let D=x-6,L=E.flatMap(O=>wt(O,D).split(`
|
|
20
|
+
`));m.push(r.createElement(A,{key:`quote-${M}`,borderStyle:"bold",borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:T.borderMuted,paddingLeft:1,marginY:1,flexDirection:"column"},L.map((O,k)=>r.createElement(No,{key:k,text:O,color:T.textMuted,italic:S,theme:p})))),E=[]}};return I.forEach((M,D)=>{let L=M.trim(),O=L.startsWith("|"),k=L.startsWith(">");if(O)E.length>0&&N(D),v.push(M);else if(k)v.length>0&&N(D),E.push(L.replace(/^>\s*/,""));else{if(N(D),L===""){m.push(r.createElement(A,{key:D,height:1}));return}if(L==="---"||L==="***"||L==="___"){m.push(r.createElement(A,{key:D,marginY:0,borderStyle:"single",borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,width:"100%",borderColor:T.borderMuted}));return}let X=L.match(/^(#{1,6})\s+(.*)/);if(X){let q=X[1].length,re=X[2];m.push(r.createElement(A,{key:D,marginTop:1,marginBottom:0,width:"100%"},r.createElement(Q,{bold:!0,color:q===1?"cyan":q===2?"magenta":q===3?"yellow":q===4?"green":q===5?"blue":T.text,underline:!0},re)));return}let ee=/^[\*\-\+]\s/.test(L),le=/^\d+\.\s/.test(L),he=M.includes("\u2588")||M.includes("\u2554")||M.includes("\u255A")||M.includes("\u2550"),K="";if(he)K=M;else if(ee||le){let q=ee?" \u2022 ":L.match(/^\d+\.\s/)[0],re=" ".repeat(q.length),Be=wt(L.replace(/^[\*\-\d+\.]+\s/,""),x-(q.length+6));K=q+Be.split(`
|
|
21
|
+
`).join(`
|
|
22
|
+
`+re)}else K=wt(L,x-4);m.push(r.createElement(A,{key:D,flexDirection:"column",width:"100%"},r.createElement(No,{text:K,color:s,italic:S,theme:p})))}}),N("final"),r.createElement(A,{flexDirection:"column",width:x-2},m)}),tl=r.memo(({line:t,pairContent:h,parentText:x,columns:S=80,extension:p,theme:T="Dark"})=>{let s=Ke(T),I=t.includes("[UI_CONTEXT]"),m=t.replace("[UI_CONTEXT]","");if(I&&m.includes("\u2550"))return r.createElement(A,{backgroundColor:s.codeBg,paddingX:1,width:S},r.createElement(Q,{color:"gray"},"\u2550".repeat(Math.max(10,S-4))));let v=cs(t);if(!v)return r.createElement(A,{backgroundColor:s.codeBg,paddingX:1,width:S},r.createElement(A,{width:3,flexShrink:0}),r.createElement(A,{width:1,flexShrink:0,marginLeft:1}),r.createElement(A,{flexGrow:1,marginLeft:1},r.createElement(Q,{color:"gray"},wt(m,S-14))));let{isR:E,isA:N,num:M,content:D}=v,L=h,O=[];if(L!=null){let re=E?D:L,Be=E?L:D;try{O=ga(re,Be)}catch{O=[]}}let k=O.some(re=>E&&re.removed||N&&re.added),X=!L&&(E||N),ee=E?s.diffRemovalBg:N?s.diffAdditionBg:void 0,le=E||N?E?s.diffRemovalNum:s.diffAdditionNum:s.textMuted,he=E?s.diffRemovalPrefix:s.diffAdditionPrefix,K=E?"-":N?"+":" ",q=()=>{if(X){let J=E?s.diffRemovalHighlightBg:s.diffAdditionHighlightBg;return r.createElement(A,{flexDirection:"column"},Nt(wt(D,S-15),p,void 0,J))}if(!(E||N)||O.length===0||!k){let J=E?s.diffRemovalText:N?s.diffAdditionText:s.textMuted;return r.createElement(A,{flexDirection:"column"},Nt(wt(D,S-15),p,J,void 0))}let re=Math.max(10,S-15),Be=wt(D,re).split(`
|
|
23
|
+
`),De=[];if(O.forEach((J,H)=>{let ne=/^\s+$/.test(J.value);if(E){let Se=O[H-1]?.removed||O[H+1]?.removed;J.removed||ne&&Se?De.push({text:J.value,isHighlight:!0}):J.added||De.push({text:J.value,isHighlight:!1})}else if(N){let Se=O[H-1]?.added||O[H+1]?.added;J.added||ne&&Se?De.push({text:J.value,isHighlight:!0}):J.removed||De.push({text:J.value,isHighlight:!1})}}),Be.length<=1)return r.createElement(Q,{wrap:"wrap"},De.map((J,H)=>E?J.isHighlight?r.createElement(r.Fragment,{key:H},Nt(J.text,p,s.diffRemovalHighlightColor,s.diffRemovalHighlightBg)):r.createElement(r.Fragment,{key:H},Nt(J.text,p,s.diffRemovalText)):N?J.isHighlight?r.createElement(r.Fragment,{key:H},Nt(J.text,p,s.diffAdditionHighlightColor,s.diffAdditionHighlightBg)):r.createElement(r.Fragment,{key:H},Nt(J.text,p,s.diffAdditionText)):r.createElement(r.Fragment,{key:H},Nt(J.text,p,s.textMuted))));let Le=0,me=0,$e=D.match(/^(\s*)/),pe=$e?$e[1]:"",Y=pe.substring(0,Math.min(pe.length,8)),Te=Be.map((J,H)=>{let ne=[],Se=J;H>0&&Y&&J.startsWith(Y)&&((De[Le]?De[Le].text.substring(me):"").startsWith(Y)||(ne.push({text:Y,isHighlight:!1}),Se=J.substring(Y.length)));let ue=Se.length;for(;ue>0&&Le<De.length;){let ve=De[Le],ie=ve.text.length-me;if(ie<=0){Le++,me=0;continue}let Me=Math.min(ue,ie);ne.push({text:ve.text.substring(me,me+Me),isHighlight:ve.isHighlight}),me+=Me,ue-=Me,me>=ve.text.length&&(Le++,me=0)}for(;Le<De.length;){let ve=De[Le],ie=ve.text.substring(me);if(/^\s+$/.test(ie))Le++,me=0;else if(ie.startsWith(" ")||ie.startsWith(" ")){let Me=0;for(;Me<ie.length&&(ie[Me]===" "||ie[Me]===" ");)Me++;me+=Me,me>=ve.text.length&&(Le++,me=0);break}else break}return ne});if(Le<De.length){let J=Te[Te.length-1];for(;Le<De.length;){let H=De[Le];J.push({text:H.text.substring(me),isHighlight:H.isHighlight}),Le++,me=0}}return r.createElement(A,{flexDirection:"column"},Te.map((J,H)=>r.createElement(A,{key:H},r.createElement(Q,{wrap:"wrap"},J.map((ne,Se)=>E?ne.isHighlight?r.createElement(r.Fragment,{key:Se},Nt(ne.text,p,s.diffRemovalHighlightColor,s.diffRemovalHighlightBg)):r.createElement(r.Fragment,{key:Se},Nt(ne.text,p,s.diffRemovalText)):N?ne.isHighlight?r.createElement(r.Fragment,{key:Se},Nt(ne.text,p,s.diffAdditionHighlightColor,s.diffAdditionHighlightBg)):r.createElement(r.Fragment,{key:Se},Nt(ne.text,p,s.diffAdditionText)):r.createElement(r.Fragment,{key:Se},Nt(ne.text,p,s.textMuted)))))))};return r.createElement(A,{backgroundColor:s.codeBg,paddingX:1,width:S},r.createElement(A,{width:4,flexShrink:0,justifyContent:"flex-end"},r.createElement(Q,{color:le},M)),r.createElement(A,{width:1,flexShrink:0,marginLeft:1},r.createElement(Q,{color:he},K)),r.createElement(A,{marginLeft:1,backgroundColor:ee,flexGrow:1},q()))}),od=r.memo(({text:t,columns:h=80,extension:x,theme:S="Dark"})=>{let p=Ke(S),T=t.match(/\[DIFF_START\]([\s\S]*?)(?:\[DIFF_END\]|$)/),m=(T?T[1].trim():"").split(`
|
|
24
|
+
`).map(E=>({line:E,parsed:cs(E),pairContent:null})),v=[];for(let E=0;E<m.length;E++){let N=m[E];N.parsed&&(N.parsed.isR||N.parsed.isA)?v.push(N):v.length>0&&(us(v),v=[])}return v.length>0&&us(v),r.createElement(A,{flexDirection:"column",width:h-3,marginBottom:1},r.createElement(A,{flexDirection:"column",paddingY:0,width:"100%"},r.createElement(A,{backgroundColor:p.codeBg,paddingX:1,width:"100%"},r.createElement(A,{width:3,flexShrink:0}),r.createElement(A,{width:1,flexShrink:0,marginLeft:1}),r.createElement(A,{flexGrow:1,marginLeft:1},r.createElement(Q,null," "))),m.map((E,N)=>r.createElement(tl,{key:N,line:E.line,pairContent:E.pairContent,columns:h-3,extension:x,theme:S})),r.createElement(A,{backgroundColor:p.codeBg,paddingX:1,width:"100%"},r.createElement(A,{width:3,flexShrink:0}),r.createElement(A,{width:1,flexShrink:0,marginLeft:1}),r.createElement(A,{flexGrow:1,marginLeft:1},r.createElement(Q,null," ")))))}),Yn=r.memo(({text:t,columns:h=80,theme:x="Dark"})=>{if(!t)return null;let S=Ke(x),p="",T=t.match(/File\s+\[(.*?)\]/i);if(T&&(p=T[1].split(".").pop().toLowerCase()),t.includes("[DIFF_START]"))return r.createElement(od,{text:t,columns:h,extension:p,theme:x});if(t.includes("- Content Preview:")){let s=t.split("- Content Preview:"),I=s[0],m=s[1]||"",v="[SYSTEM] Check the content preview for verification [/SYSTEM]",E=m.split(v),N=E[0]?.trim()||"",M=E[1]?`${v}${E[1]}`:"",D=N.split(`
|
|
25
|
+
`),L=String(D.length).length;return r.createElement(A,{flexDirection:"column",width:h-3},r.createElement(A,{flexDirection:"column",borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:S.codeBorder,paddingLeft:2,paddingRight:0,width:"100%",marginBottom:1,backgroundColor:S.codeBg},r.createElement(A,{flexDirection:"column",width:"100%"},r.createElement(A,{width:"100%"},r.createElement(A,{width:L+2,flexShrink:0},r.createElement(Q,null," ")),r.createElement(A,{flexGrow:1},r.createElement(Q,null," "))),D.map((O,k)=>r.createElement(A,{key:k,width:"100%"},r.createElement(A,{width:L+2,flexShrink:0},r.createElement(Q,{color:"gray",dimColor:!0},String(k+1).padStart(L," ")," ")),r.createElement(A,{flexGrow:1},Nt(O,p,S.text)))),r.createElement(A,{width:"100%"},r.createElement(A,{width:L+2,flexShrink:0},r.createElement(Q,null," ")),r.createElement(A,{flexGrow:1},r.createElement(Q,null," "))))))}if(t.includes("```")){let s=t.split(/(```\w*\n?[\s\S]*?(?:```|$))/g);return r.createElement(A,{flexDirection:"column",width:h-3},s.map((I,m)=>{if(I.startsWith("```")){let E=I.match(/```(\w*)\n?([\s\S]*?)(?:```|$)/),N=E?E[1]:"code",M=E?E[2]:I.replace(/^```\w*\n?/,"").replace(/```$/,""),D=M.trimEnd().split(`
|
|
26
|
+
`),L=String(D.length).length,O=h-7-L,X=(O>5?wt(M,O):M).trimEnd().split(`
|
|
27
|
+
`);return r.createElement(A,{key:m,flexDirection:"column",marginY:0,paddingLeft:2,paddingRight:0,width:"100%"},r.createElement(A,null,r.createElement(Q,{color:"gray",bold:!0},"\u25B6_ ",N.toUpperCase()||"TEXT")),r.createElement(A,{flexDirection:"column",width:"100%"},X.map((ee,le)=>{let K=wt(ee,Math.max(10,O)).split(`
|
|
28
|
+
`);return r.createElement(A,{key:le,flexDirection:"column",width:"100%"},K.map((q,re)=>r.createElement(A,{key:re,width:"100%"},r.createElement(A,{width:L+2,flexShrink:0},r.createElement(Q,{color:"gray"},re===0?String(le+1).padStart(L," ")+" ":" ".repeat(L+1))),r.createElement(A,{flexGrow:1},Nt(q,N,S.text)))))})))}let v=I;return m>0&&(v=v.replace(/^[\r\n]+/,"")),m<s.length-1&&(v=v.replace(/[\r\n]+$/,"")),v?r.createElement(hn,{key:m,text:v,columns:h-3,theme:x}):null}))}return r.createElement(hn,{text:t,columns:h-3,theme:x})}),Ts=t=>{let h=Math.round(t/1e3);if(h<=0)return"0s";let x=Math.floor(h/60),S=h%60;return x>0?`${x}m ${S}s`:`${h}s`},ol=r.memo(({msg:t,showFullThinking:h,columns:x=80,aiProvider:S,version:p,theme:T="Dark"})=>{let s=Ke(T),I=t.role==="system"&&(t.text?.includes("[DIFF_START]")||t.text?.includes("- Content Preview:")),m=t.role==="system"&&t.text?.includes("[TOOL RESULT]: ERROR:")&&!t.text?.includes("[DIFF_START]")&&(t.toolName==="update_file"||t.text?.includes("Could not find exact match")),v=t.isTerminalRecord;if(t.isHomeWarning)return r.createElement(A,{marginBottom:1,paddingX:1,width:"100%"},r.createElement(A,{flexDirection:"column",borderStyle:"round",borderColor:s.border,dimColor:!0,padding:0,width:"100%"},r.createElement(A,{paddingX:1},r.createElement(Q,{color:s.text,bold:!0},t.text)),r.createElement(A,{paddingX:1,marginTop:0,marginBottom:0},r.createElement(Q,{color:s.text},t.subText))));if(t.isLogo)return r.createElement(A,{flexDirection:"column",alignItems:"flex-start",width:"100%",marginY:1},r.createElement(Q,null,pr(p,S,T)));if(t.id&&String(t.id).startsWith("welcome"))return r.createElement(A,{flexDirection:"column",alignItems:"center",width:"100%",marginY:1},r.createElement(A,{borderStyle:"round",borderColor:s.borderMuted,paddingX:3,paddingY:0},r.createElement(Q,{color:s.text,bold:!0},t.text.trim())));if(t.isVisualFeedback)return r.createElement(A,{marginBottom:0,marginTop:0,paddingX:1,width:"100%"},r.createElement(Q,{color:s.text},t.text));if(t.isSteeringHint||t.role==="user"&&(t.text?.startsWith("[STEERING HINT]")||t.text?.startsWith("[QUESTION]"))){let O=t.hintType==="QUESTION"||t.text?.startsWith("[QUESTION]"),k=t.hintContent||(t.text||"").replace(/^\[(?:STEERING HINT|QUESTION)\]\s*/i,"").trim(),X=O?"QUESTION":"STEERING HINT",ee=O?s.accent||"#c451d6":s.primary||"cyan";return r.createElement(A,{marginBottom:0,marginTop:0,paddingX:1,width:"100%"},r.createElement(A,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:1,paddingY:0,width:Math.max(20,x-2)},r.createElement(A,{justifyContent:"space-between",width:"100%"},r.createElement(A,{flexDirection:"row",gap:1},r.createElement(Q,{color:ee,bold:!0},"\u2726 ",X))),r.createElement(A,{marginTop:0,paddingLeft:2},r.createElement(Q,{color:s.text,bold:!0},"\u2514\u2500 ",k))))}if(m)return r.createElement(A,{marginBottom:1},r.createElement(A,{flexDirection:"column",borderStyle:"round",borderColor:s.border,paddingX:1,paddingY:0},r.createElement(Q,{color:s.text,bold:!0,underline:!0},"\u2717 PATCH FAILED"),r.createElement(A,{marginTop:1},r.createElement(Q,{color:s.textMuted,bold:!0},"Model generated malformed edit."))));if(t.role==="system"&&t.text?.includes("[TOOL RESULT]")&&!I&&!v&&!m)return null;if(t.isImageStats)return r.createElement(A,{marginBottom:1,paddingX:1,width:"100%"},r.createElement(A,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,padding:0,width:"100%"},r.createElement(A,{paddingX:1,backgroundColor:s.codeBg},r.createElement(Q,{color:s.text,bold:!0},"IMAGE STATS")),r.createElement(A,{paddingX:1,marginTop:1,marginBottom:1,flexDirection:"column"},t.text.split(`
|
|
29
|
+
`).map((O,k)=>r.createElement(Q,{key:k,color:s.textMuted},O)))));if(t.isAskRecord){let O=t.text.match(/Selection: (.*)/),k=O?O[1]:"No selection",X=t.text.match(/Question: (.*)/),ee=X?X[1]:null;return r.createElement(A,{marginBottom:0,paddingX:1,width:"100%"},r.createElement(A,{flexDirection:"column",borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!0,borderBottom:!0,borderColor:s.codeBorder,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,marginY:1,width:x-2},r.createElement(A,{paddingX:1},r.createElement(Q,{color:s.success,bold:!0},"AGENT REQUEST: RESOLVED")),ee&&r.createElement(A,{paddingX:1,marginTop:1},r.createElement(Q,{color:s.secondary},ee)),r.createElement(A,{paddingX:1,marginTop:1,marginBottom:0},r.createElement(Q,{color:s.text},"Selection: ",r.createElement(Q,{color:s.textMuted,bold:!0},k)))))}if(t.isAboutRecord)return r.createElement(A,{marginBottom:0,paddingX:1,width:"100%"},r.createElement(A,{flexDirection:"column",borderStyle:"round",border:!0,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,backgroundColor:s.codeBg,width:"100%"},r.createElement(A,{paddingX:1},r.createElement(Q,{color:s.text,bold:!0},"ABOUT FLUX FLOW")),r.createElement(A,{paddingX:1,marginTop:1,marginBottom:1},r.createElement(Q,{color:s.text},t.text))));if(t.isUpdateNotification)return r.createElement(A,{marginBottom:1,paddingX:1,width:"100%"},r.createElement(A,{flexDirection:"column",borderStyle:"round",border:!0,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,backgroundColor:s.codeBg,width:"100%"},r.createElement(A,{paddingX:1},r.createElement(Q,{color:s.text,bold:!0},"UPDATE AVAILABLE")),r.createElement(A,{paddingX:1,marginTop:1,marginBottom:1},r.createElement(Yn,{text:t.text,columns:x,theme:T}))));if(t.isHelpRecord){let O=[{cmd:"/quit",desc:"Exit and shutdown Flux"},{cmd:"/help",desc:"Show all available commands"},{cmd:"/compress",desc:"Summarize and compress chat history"},{cmd:"/truncate",desc:"Truncate tool results in chat history"},{cmd:"/clear",desc:"Clear terminal screen"},{cmd:"/resume",desc:"Load previous session"},{cmd:"/revert",desc:"Revert codebase to checkpoint"},{cmd:"/save",desc:"Force save current chat"},{cmd:"/export",desc:"Export current chat or error logs"},{cmd:"/chats",desc:"List all chat sessions"},{cmd:"/btw",desc:"Send raw inquiry mid-turn"},{cmd:"/budget",desc:"Set or View budget limits"},{cmd:"/mode",desc:"Toggle Flux/Flow modes"},{cmd:"/thinking",desc:"Set AI reasoning depth"},{cmd:"/model",desc:"Switch AI model"},{cmd:"/wildcard-tooling",desc:"Use if the model lacks Tooling Capability"},{cmd:"/provider",desc:"Select AI Provider"},{cmd:"/settings",desc:"Configure system prefs"},{cmd:"/theme",desc:"Customize UI color theme"},{cmd:"/key",desc:"Manage API keys"},{cmd:"/profile",desc:"Edit developer persona"},{cmd:"/memory",desc:"Manage agent memory"},{cmd:"/stats",desc:"Show session usage"},{cmd:"/usage",desc:"Open graphical token usage & analytics in browser"},{cmd:"/reset",desc:"Wipe all saved FluxFlow AppData"},{cmd:"/about",desc:"Project info & credits"},{cmd:"/changelog",desc:"View latest updates"},{cmd:"/docs",desc:"View documentation"},{cmd:"/fluxflow",desc:"Project management"},{cmd:"/update",desc:"Check/Install updates"}];return r.createElement(A,{marginBottom:1,paddingX:1,width:"100%"},r.createElement(A,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:1,width:"100%"},r.createElement(Q,{color:s.text,bold:!0,underline:!0},"AVAILABLE COMMANDS IN FLUX-FLOW"),r.createElement(A,{flexDirection:"column",marginTop:1},O.map((k,X)=>r.createElement(A,{key:X,flexDirection:"row"},r.createElement(A,{width:20},r.createElement(Q,{color:s.text,bold:!0},k.cmd)),r.createElement(Q,{color:s.textMuted}," - ",k.desc))))))}if(t.isTerminalRecord){let O=t.text.match(/COMMAND: (.*)/),k=t.text.match(/PTY: (true|false)/),X=t.text.match(/OUTPUT: ([\s\S]*)/),ee=O?O[1]:"No Command",le=k?k[1]==="true":!1,he=X?X[1]:"";return r.createElement(A,{marginBottom:0,paddingX:1,width:"100%"},r.createElement(Mr,{command:ee,output:he,completed:!0,columns:x,isPty:le,theme:T}))}let[N,M]=r.useState(!t.isStreaming),D=r.useMemo(()=>Ai(t.text,t.role),[t.text,t.role]);r.useEffect(()=>{t.isStreaming&&M(!1)},[t.id]);let L=r.useMemo(()=>t.role==="think"&&!h?"Thinking...":t.isStreaming?D:D.trimEnd(),[D,t.role,h,t.isStreaming]);return t.role==="think"&&!Ri()||t.role==="agent"&&L.trim()===""?null:r.createElement(A,{marginBottom:(t.role==="think"||t.role==="user"||t.role==="agent",0),marginTop:(t.role==="think"||t.role==="user"||t.role==="agent",0),flexDirection:"column",flexShrink:0,width:"100%",flexGrow:1},t.role==="user"?r.createElement(A,{flexDirection:"column",width:x-1},r.createElement(A,{width:x-1,height:1,overflow:"hidden"},r.createElement(Q,{color:s.userMsgBorder},"\u2584".repeat(Math.max(1,x-1)))),r.createElement(A,{backgroundColor:s.userMsgBg,paddingX:1,paddingY:0,width:x-1,flexDirection:"column"},wt(L.replace(/\r\n/g,`
|
|
30
|
+
`).replace(/\r/g,`
|
|
31
|
+
`).replace(/\\\n/g,`
|
|
32
|
+
`).replace(/\\$/,""),x-7).split(`
|
|
33
|
+
`).map((O,k)=>r.createElement(A,{key:k,flexDirection:"row",width:"100%"},r.createElement(A,{flexShrink:0,width:2},r.createElement(Q,{bold:!0,color:s.userMsgText},k===0?">":" ")),r.createElement(A,{flexGrow:1,marginLeft:1},r.createElement(No,{text:O,color:t.color||s.userMsgText,theme:T}))))),r.createElement(A,{width:x-1,height:1,overflow:"hidden"},r.createElement(Q,{color:s.userMsgBorder},"\u2580".repeat(Math.max(1,x-1))))):t.role==="think"?r.createElement(A,{flexDirection:"column",marginTop:0,marginBottom:0,paddingX:0,width:"100%"},t.isStreaming&&!t.duration?r.createElement(Q,{bold:!0,color:s.text},"\u2727 Thinking..."):r.createElement(Q,{bold:!0,color:s.text},"\u2726 Thought",t.duration?r.createElement(Q,{color:s.textMuted}," for ",r.createElement(Q,{bold:!0,color:s.text},Ts(t.duration))):"s..."),r.createElement(A,{borderStyle:"single",borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:s.borderMuted,paddingLeft:2,paddingTop:0,paddingBottom:0,flexDirection:"column",width:"100%"},fa(L,x))):r.createElement(A,{flexDirection:"column",paddingX:1,marginTop:0,width:"100%"},r.createElement(Yn,{text:L.replace(/ \|\n\n/g,` |
|
|
34
|
+
`),columns:x,theme:T}),t.memoryUpdated&&r.createElement(A,{marginTop:1,width:"100%"},r.createElement(Q,{color:s.text,italic:!0},"[Memory Updated]")),t.role==="agent"&&t.workedDuration?r.createElement(A,{marginTop:1,marginBottom:2,width:"100%"},r.createElement(Q,{color:s.textMuted},"["),r.createElement(Q,{color:s.textMuted},"Worked for ",r.createElement(Q,{bold:!0,color:s.text},Ts(t.workedDuration))),r.createElement(Q,{color:s.textMuted},"]")):null))}),vr=r.memo(({block:t,columns:h=80,showFullThinking:x,aiProvider:S,version:p,theme:T="Dark"})=>{let s=Ke(T),{msg:I,type:m,text:v,isStreamingMsg:E,workedDuration:N}=t;if((m==="think-header"||m==="think-line"||m==="think-footer-padding")&&!Ri())return null;if(m==="chunk")return r.createElement(A,{flexDirection:"column",width:"100%"},t.blocks.map(M=>r.createElement(vr,{key:M.key,block:M,columns:h,showFullThinking:x,aiProvider:S,version:p,theme:T})));if(m==="full-message")return r.createElement(ol,{msg:I,showFullThinking:x,columns:h,aiProvider:S,version:p,theme:T});if(m==="think-header")return r.createElement(A,{flexDirection:"column",paddingX:1,width:"100%",marginTop:0,marginBottom:0},E?r.createElement(Q,{bold:!0,color:s.text},"\u2727 Thinking..."):r.createElement(Q,{bold:!0,color:s.text},"\u2726 Thoughts..."),x&&r.createElement(A,{flexDirection:"row",width:"100%"},r.createElement(Q,{color:s.textMuted},"\u2502 ")));if(m==="think-line"){if(!x)return null;if(!v||v.trim()==="")return r.createElement(A,{flexDirection:"row",width:"100%",paddingX:1},r.createElement(Q,{color:s.textMuted},"\u2502 "));let M=zi(v,E,t.isActiveBlock),D=M.trim(),L=/^[\*\-\+]\s/.test(D),O=/^\d+\.\s/.test(D),k=M;if(L||O){let ee=L?" \u2022 ":D.match(/^\d+\.\s/)[0],le=" ".repeat(ee.length),he=wt(D.replace(/^[\*\-\d+\.]+\s/,""),h-(ee.length+10));k=ee+he.split(`
|
|
35
|
+
`).join(`
|
|
36
|
+
`+le)}else k=wt(M,h-10);let X=k.split(`
|
|
37
|
+
`);return r.createElement(A,{flexDirection:"column",paddingX:1,width:"100%"},X.map((ee,le)=>r.createElement(A,{key:le,flexDirection:"row",width:"100%"},r.createElement(Q,{color:s.textMuted},"\u2502 "),r.createElement(A,{flexGrow:1,marginLeft:1},r.createElement(No,{text:ee,color:s.textMuted,italic:!0,theme:T})))))}if(m==="think-footer-padding")return x?r.createElement(A,{flexDirection:"row",width:"100%",paddingX:1},r.createElement(Q,{color:s.textMuted},"\u2502 ")):null;if(m==="agent-line"){if(!v||v.trim()==="")return r.createElement(A,{height:1});let M=zi(v,E,t.isActiveBlock);return r.createElement(A,{flexDirection:"column",paddingX:1,width:"100%"},r.createElement(Yn,{text:M,columns:h,theme:T}))}if(m==="table")return r.createElement(A,{flexDirection:"column",paddingX:1,width:"100%"},r.createElement(el,{buffer:v.split(`
|
|
38
|
+
`),terminalWidth:h,theme:T}));if(m==="diff-line"){let{isFirstLine:M,isLastLine:D}=t,L=(O=!1)=>r.createElement(A,{backgroundColor:s.codeBg,paddingX:1,width:h,marginBottom:O?1:0},r.createElement(A,{width:3,flexShrink:0}),r.createElement(A,{width:1,flexShrink:0,marginLeft:1}),r.createElement(A,{flexGrow:1,marginLeft:1},r.createElement(Q,null," ")));return r.createElement(A,{flexDirection:"column"},M&&L(!1),r.createElement(tl,{line:v,pairContent:t.pairContent,parentText:void 0,columns:h,theme:T}),D&&L(!0))}if(m==="code-fence-open"){let M={paddingLeft:2,width:"100%"};return r.createElement(A,{flexDirection:"column",marginTop:0,marginBottom:0,width:"100%"},r.createElement(A,{flexDirection:"row",...M},r.createElement(Q,null," ")),r.createElement(A,{flexDirection:"row",...M},r.createElement(Q,{color:"gray",bold:!0},"\u25B6_ ",(v||"TEXT").toUpperCase())))}if(m==="code-line"){let{lineNum:M,lang:D}=t,L=h-12,k=wt(v,Math.max(10,L)).split(`
|
|
39
|
+
`);return r.createElement(A,{flexDirection:"column",width:"100%"},k.map((X,ee)=>r.createElement(A,{key:ee,flexDirection:"row",borderColor:s.codeBorder,paddingLeft:2,width:"100%"},r.createElement(A,{width:5,flexShrink:0},r.createElement(Q,{color:"gray",dimColor:!0},ee===0?String(M).padStart(4," ")+" ":" ")),r.createElement(A,{flexGrow:1},Nt(X,D,s.text)))))}if(m==="code-fence-close")return r.createElement(A,{flexDirection:"row",paddingLeft:2,marginBottom:1,width:"100%"},r.createElement(Q,null," "));if(m==="write-header")return r.createElement(A,{flexDirection:"column",paddingX:1,width:h},r.createElement(hn,{text:v,columns:h,theme:T}));if(m==="write-line"){let{gutterWidth:M,lineNum:D,isFirstLine:L,isLastLine:O,extension:k,wrappedLines:X}=t,ee=(le=!1)=>r.createElement(A,{flexDirection:"row",width:h,borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:s.codeBorder,paddingLeft:2,paddingRight:0,backgroundColor:s.codeBg,marginBottom:le?1:0},r.createElement(A,{width:M+2,flexShrink:0},r.createElement(Q,null," ".repeat(M+2))),r.createElement(A,{flexGrow:1},r.createElement(Q,null," ")));return r.createElement(A,{flexDirection:"column"},L&&ee(!1),r.createElement(A,{flexDirection:"row",width:h,borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:s.codeBorder,paddingLeft:2,paddingRight:0,backgroundColor:s.codeBg},r.createElement(A,{width:M+2,flexShrink:0},r.createElement(Q,{color:"gray",dimColor:!0},String(D).padStart(M," ")," ")),r.createElement(A,{flexGrow:1,flexDirection:"column"},(X||[v]).map((le,he)=>r.createElement(A,{key:he},Nt(le,k,s.text))))),O&&ee(!0))}return m==="write-footer"?r.createElement(A,{flexDirection:"column",paddingX:1,width:h,marginTop:1,marginBottom:1},r.createElement(hn,{text:v,columns:h,theme:T})):m==="worked-duration"?r.createElement(A,{marginTop:1,marginBottom:2,paddingX:1,width:"100%"},r.createElement(Q,{color:s.textMuted},"["),r.createElement(Q,{color:s.textMuted},"Worked for ",r.createElement(Q,{bold:!0,color:s.text},Ts(N))),r.createElement(Q,{color:s.textMuted},"]")):null}),kc=r.memo(({messages:t,showFullThinking:h,columns:x=80,aiProvider:S,version:p,theme:T="Dark"})=>r.createElement(A,{flexDirection:"column",width:"100%"},t.map((s,I)=>r.createElement(ol,{key:s.id||I,msg:s,showFullThinking:h,columns:x,aiProvider:S,version:p,theme:T}))));import ht from"react";import{Box as Fo,Text as co}from"ink";import{useState as Vn,useEffect as jn,useRef as Er}from"react";var Kn=null;function nl(){Kn&&Kn()}var nd=t=>{if(t<=370)return"#00a564";if(t>=5e3)return"#ff0000";let h=[{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<h.length-1;x++){let S=h[x],p=h[x+1];if(t>=S.t&&t<=p.t){let T=(t-S.t)/(p.t-S.t);T=T*T*(3-2*T);let s=Math.round(S.r+(p.r-S.r)*T),I=Math.round(S.g+(p.g-S.g)*T),m=Math.round(S.b+(p.b-S.b)*T);return`#${((1<<24)+(s<<16)+(I<<8)+m).toString(16).slice(1)}`}}return"#ff0000"},rd=ht.memo(({mode:t,thinkingLevel:h,tokens:x="0.0k",tokensTotal:S="0.0k",cachedTokens:p=0,promptTokens:T=0,chatId:s="NEW-SESSION",isMemoryEnabled:I=!0,apiTier:m="Free",aiProvider:v="Google",activeModel:E="",isProcessing:N=!1,lastChunkTime:M=0,theme:D="Dark",wps:L=0,showTPMEstimate:O=!1})=>{let k=Ke(D),X="",[ee,le]=Vn(0),[he,K]=Vn(0),[q,re]=Vn("MB"),[Be,De]=Vn("green"),[Le,me]=Vn(0),$e=Er([]),pe=Er(370),Y=Er([]),Te=Er(M);jn(()=>{Te.current=M},[M]),jn(()=>{if(!N){Y.current=[];return}if(L>0){let ue=Y.current;ue.push(L),ue.length>3&&ue.shift()}},[N,L,M]),jn(()=>{if(!N){me(0);return}let ue=setInterval(()=>{let ve=Te.current,ie=ve>0?Date.now()-ve:0;if(ve>0&&ie>1500)Y.current=[],me(0);else if(ve>0&&ie>600){Y.current.length>0&&Y.current.shift();let Me=Y.current;if(Me.length>0){let ze=Me.reduce((we,te)=>we+te,0),qe=Math.round(ze/Me.length*10)/10;me(qe)}else me(0)}else{let Me=Y.current;if(Me.length>0){let ze=Me.reduce((we,te)=>we+te,0),qe=Math.round(ze/Me.length*10)/10;me(qe)}else L>0&&me(L)}},1350);return()=>clearInterval(ue)},[N]),jn(()=>{if(!N){$e.current=[];return}if(M>0){let ie=$e.current;(ie.length===0||ie[ie.length-1]!==M)&&(ie.push(M),ie.length>10&&ie.shift())}let ue=()=>{if(!M){De("#00a564");return}let ie=$e.current,Me=0;if(ie.length>1){let P=0;for(let ut=1;ut<ie.length;ut++)P+=ie[ut]-ie[ut-1];Me=P/(ie.length-1)}let ze=Date.now()-M,we=ze>=2500,te=!we&&Me>0?Math.min(ze,Me*3):ze,xe=Math.max(Me,te),Xe=we?.4:.2;pe.current=pe.current*(1-Xe)+xe*Xe,De(nd(pe.current))};ue();let ve=setInterval(ue,100);return()=>clearInterval(ve)},[N,M]);let J=()=>{let ue=process.memoryUsage(),ve=ue.heapTotal/(1024*1024)>=1024,ie=ve?"GB":"MB",Me=(ze,qe)=>{let we=ze/(1048576*(qe?1024:1));return qe?parseFloat(we.toFixed(2)):Math.round(we)};re(ie),K(Me(ue.heapTotal,ve)),le(Me(ue.heapUsed,ve))};jn(()=>{Kn=J,J();let ue=setInterval(()=>{J()},6e4);return()=>{clearInterval(ue),Kn===J&&(Kn=null)}},[]);let H=262144,ne=process.env.HIGH_CONTEXT,Se=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1;if(ne&&ne!=="false"){let ue=parseInt(ne,10);!isNaN(ue)&&ue>=32e3&&ue<=1e6&&(H=ue)}return(v==="NVIDIA"&&(E?.includes("gpt")||E?.includes("qwen")||E?.includes("medium")||E.includes("muse"))||v==="Mistral")&&(H=128e3),v==="Google"&&E?.includes("gemma")&&Se&&(H=16e3),ht.createElement(Fo,{flexDirection:"row",justifyContent:"space-between",paddingX:1,width:"100%"},ht.createElement(Fo,null,ht.createElement(Fo,{marginRight:1},ht.createElement(co,{color:k.textMuted},t.toLowerCase()==="flow"?"Studio":t.toLowerCase()==="icu"?"Computer Use":t.toLowerCase()==="flux"?"Workspace":"Omni")),ht.createElement(co,{color:k.textMuted,dimColor:!0},"\u2503 "),ht.createElement(Fo,null,ht.createElement(co,{color:k.text,italic:!0},ki(process.cwd(),35)))),ht.createElement(Fo,null,N?ht.createElement(Fo,null,ht.createElement(co,{color:Be},"\u25CF"),O&&ht.createElement(ht.Fragment,null,ht.createElement(co,{color:k.textMuted,bold:!0}," ",Le," tps"),ht.createElement(co,{color:k.textMuted,dimColor:!0}," \u2503"))):null,x>0&&ht.createElement(ht.Fragment,null,ht.createElement(Fo,{marginX:1},ht.createElement(co,{color:k.text},ft(S),(()=>{let ue=typeof T=="number"?T:0,ve=typeof p=="number"?p:0,ie=ue>0?ve/ue*100:0;return ie<1?null:ht.createElement(co,{color:k.success||"green",dimColor:!0}," ",ie.toFixed(0),"%")})())),ht.createElement(co,{color:k.textMuted,dimColor:!0},"\u2503")),ht.createElement(Fo,{marginLeft:1},ht.createElement(co,{color:k.textMuted,bold:!0},ee," ",q))))}),rl=rd;import Re,{useState as ws,useMemo as sd,useEffect as id}from"react";import{Box as Ht,Text as Kt,useInput as ld}from"ink";import ad from"ink-select-input";var dd=({label:t,isSelected:h,theme:x="Dark"})=>{let S=Ke(x),p=t==="Cancel"||t==="Back"||t.toLowerCase().includes("exit")||t.toLowerCase().includes("back");return Re.createElement(Ht,{marginTop:p?1:0,backgroundColor:h?S.highlightBg:void 0,paddingX:1,width:"100%"},Re.createElement(Kt,{color:h?S.text:S.textMuted,bold:h},h?"\u276F ":" ",t))};function xt({title:t,subtitle:h,items:x=[],onSelect:S,theme:p="Dark",searchable:T=!1}){let s=Ke(p),[I,m]=ws(""),[v,E]=ws(0),[N,M]=ws("list"),D=sd(()=>{if(!T||!I.trim())return x;let L=I.toLowerCase().trim();return x.filter(O=>O.label&&O.label.toLowerCase().includes(L))},[x,I,T]);return id(()=>{E(0)},[I]),ld((L,O)=>{if(T){if(O.upArrow){M("list"),E(k=>D.length>0?k>0?k-1:D.length-1:0);return}if(O.downArrow){M("list"),E(k=>D.length>0&&k<D.length-1?k+1:0);return}if(O.return){D.length>0&&D[v]&&S(D[v]);return}if(O.escape){if(I)m(""),M("list"),E(0);else{let k=x.find(X=>X.value==="Back"||X.label==="Back"||X.value==="Cancel"||X.label==="Cancel");k&&S(k)}return}if(O.backspace||O.delete){M("search"),m(k=>k.slice(0,-1));return}if(L&&!O.ctrl&&!O.meta&&!O.tab){M("search"),m(k=>k+L);return}}},{isActive:T}),T?Re.createElement(Ht,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,padding:0,marginTop:0,flexShrink:0,width:"100%"},t&&Re.createElement(Ht,{paddingX:1,paddingY:0,marginBottom:0},Re.createElement(Kt,{color:s.text,bold:!0},typeof t=="string"?t.toUpperCase():t)),h&&Re.createElement(Ht,{paddingX:1,marginBottom:0},Re.createElement(Kt,{color:s.textMuted,italic:!0}," ",h)),Re.createElement(Ht,{paddingX:1,marginTop:1,marginBottom:1,flexDirection:"row"},Re.createElement(Kt,{color:N==="search"?s.primary||"cyan":s.textMuted,bold:N==="search"},"\u{1F50D} Search:"),Re.createElement(Kt,{color:s.text,bold:!0}," ",I),N==="search"?Re.createElement(Kt,{color:s.primary||"cyan"},"\u2588"):I?null:Re.createElement(Kt,{color:s.textMuted,italic:!0}," (type to search...)")),Re.createElement(Ht,{flexDirection:"column",width:"100%"},D.length===0?Re.createElement(Ht,{paddingX:1,marginY:0},Re.createElement(Kt,{color:s.warning||"yellow",italic:!0}," No matching items found")):D.map((L,O)=>{let k=O===v,X=L.label==="Cancel"||L.label==="Back"||L.label.toLowerCase().includes("exit")||L.label.toLowerCase().includes("back");return Re.createElement(Ht,{key:L.value??L.label??O,marginTop:X?1:0,backgroundColor:k?s.highlightBg:void 0,paddingX:1,width:"100%"},Re.createElement(Kt,{color:k?s.text:s.textMuted,bold:k},k?"\u276F ":" ",L.label))})),Re.createElement(Ht,{paddingX:1,marginTop:1},Re.createElement(Kt,{color:s.textMuted,italic:!0},N==="search"?"(Type letters to search \u2022 Arrows for list mode \u2022 Enter to select)":"(Arrows to navigate \u2022 Type letters to search \u2022 Enter to select)"))):Re.createElement(Ht,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,padding:0,marginTop:0,flexShrink:0,width:"100%"},t&&Re.createElement(Ht,{paddingX:1,paddingY:0,marginBottom:h?0:1},Re.createElement(Kt,{color:s.text,bold:!0},typeof t=="string"?t.toUpperCase():t)),h&&Re.createElement(Ht,{paddingX:1,marginBottom:1},Re.createElement(Kt,{color:s.textMuted,italic:!0}," ",h)),Re.createElement(Ht,{flexDirection:"column",width:"100%"},Re.createElement(ad,{items:x,onSelect:S,itemComponent:L=>Re.createElement(dd,{...L,theme:p}),indicatorComponent:()=>null})),Re.createElement(Ht,{paddingX:1,marginTop:1},Re.createElement(Kt,{color:s.textMuted,italic:!0},"(Arrows to select \u2022 Enter to confirm)")))}import C,{useState as Ot,useEffect as qn}from"react";import{Box as Ae,Text as G,useInput as cd}from"ink";import ud from"ink-text-input";import md from"v8";import sl from"os";var uo=[...Object.keys(Li),"Mystery"],mo=[{id:"appearance",label:"Appearance",desc:"Customize UI theme & rendering options"},{id:"memory",label:"Memory",desc:"Manage system context & agent's memory"},{id:"other",label:"Miscellaneous",desc:"Miscellaneous preferences"},{id:"providers",label:"Providers",desc:"Configure AI models"},{id:"security",label:"Security",desc:"Configure permissions & data safety"},{id:"updater",label:"Updater",desc:"Manage application updates"},{id:"exit",label:"Exit Settings",desc:"Return to chat view"}],il=t=>{let h=t.autoApproveCommands||"",x=t.autoDisallowCommands||"",S=t.alwaysAskCommands||"",p=t.autoExec===!1&&t.allowExternalAccess===!1&&t.networkAccess===!1&&h===""&&x==="rm -rf, rm -f, del /f, del /q, rd /s, rmdir /s, format, mkfs, dd if=/dev, shred, srm, Remove-Item -Recurse -Force, Initialize-Disk, Clear-Disk, format c:, flashrom, nvram -c"&&S==="killall, pkill, taskkill, shutdown, reboot, init 0, init 6, Stop-Process, Stop-Service, mv /*, move c:\\*, chmod 000, chmod -R 777, chown, icacls, netsh advfirewall, iptables -F, ufw disable, git reset --hard, git clean -fd, npm r, npm uninstall"&&t.autoApproveGit===!1,T=t.autoExec===!0&&t.allowExternalAccess===!1&&t.networkAccess!==!1&&h==="ls, dir, cat, type, echo, pwd, cd, git status, git log, git diff, git branch, git show, help, mkdir, touch, md, whoami, hostname, ps, Get-Process, date, time, mkdir"&&x==="rm -rf, rm -f, del /f, del /q, rd /s, rmdir /s, format, mkfs, dd if=/dev, shred, srm, Remove-Item -Recurse -Force, Initialize-Disk, Clear-Disk, format c:, flashrom, nvram -c"&&S==="killall, pkill, taskkill, Stop-Process, mv /*, move c:\\*, chmod 000, chmod -R 777, chown, icacls, shutdown, reboot, init 0, init 6, git reset --hard, git clean -fd, npm r, npm uninstall"&&t.autoApproveGit===!1,s=t.autoExec===!0&&t.allowExternalAccess===!0&&t.networkAccess!==!1&&h==="ls, dir, cat, type, echo, pwd, cd, git status, git log, git diff, git branch, git show, help, mkdir, touch, md, whoami, hostname, ps, Get-Process, date, time, mkdir"&&x===""&&S==="rm -rf, rm -f, del /f, del /q, rd /s, rmdir /s, format, mkfs, dd if=/dev, shred, srm, Remove-Item -Recurse -Force, Initialize-Disk, Clear-Disk, format c:, flashrom, nvram -c"&&t.autoApproveGit===!0;return p?"Strict":T?"Balanced":s?"Autonomous":t.sandboxPreset||"Custom"},bs=t=>!t||t.trim()===""?"None":t.length>40?t.substring(0,40)+"...":t;function Br({systemSettings:t,setSystemSettings:h,apiTier:x,setActiveView:S,setInputConfig:p,saveSettings:T,quotas:s,setMessages:I,aiProvider:m,initialSelectingTheme:v=!1,onCloseTheme:E=null,setProviderReturnView:N=null}){let M=t.theme==="Chaos"||t.theme==="Mystery"?"Mystery":t.theme||"Dark",D=uo.indexOf(M),[L,O]=Ot("categories"),[k,X]=Ot(0),[ee,le]=Ot(0),[he,K]=Ot(null),[q,re]=Ot(""),[Be,De]=Ot(v),[Le,me]=Ot(D>=0?D:0),[$e,pe]=Ot(t.theme||"Dark"),[Y,Te]=Ot(!1),[J,H]=Ot(0),[ne,Se]=Ot(0),[ue,ve]=Ot(""),[ie,Me]=Ot("list"),[ze,qe]=Ot({});qn(()=>{(async()=>{let b=["Google","DeepSeek","OpenRouter","NVIDIA","Mistral","Ollama","CrofAI","InferX","SenseNova","AIHubMix","Poolside","9router","ExpLabs"],F={};for(let ge of b)try{await un(ge)&&(F[ge]=!0)}catch{}qe(F)})()},[]);let we=C.useMemo(()=>{let se=["Google","DeepSeek","OpenRouter","NVIDIA","Mistral","Ollama","CrofAI","InferX","SenseNova","AIHubMix","Poolside","9router","ExpLabs"],F=!!(process.env.SUBAGENT_MODEL&&process.env.SUBAGENT_MODEL.trim())?`ENV (${process.env.SUBAGENT_MODEL.trim()})`:"ENV",ge=[{label:"Default (use the current model)",value:"Default",isHeader:!1},{label:F,value:"ENV",isHeader:!1}],_e=s?.providerTiers?.[m]||x||"Free",gt=Oo(m,_e)||[];gt.length>0&&(ge.push({label:`\u2500\u2500 ${m.toUpperCase()}${_e!=="Free"?` (${_e})`:""} \u2500\u2500`,isHeader:!0}),gt.forEach(et=>{let Ne=typeof et=="string"?et:et.cmd||et.name||et.id||String(et);Ne&&!Ne.trim().startsWith("---")&&!Ne.startsWith(`
|
|
40
|
+
---`)&&ge.push({label:Ne,value:Ne,isHeader:!1,provider:m})}));for(let et of se)if(et!==m&&ze[et]){let Ne=s?.providerTiers?.[et]||"Free",St=Oo(et,Ne)||[];St.length>0&&(ge.push({label:`\u2500\u2500 ${et.toUpperCase()}${Ne!=="Free"?` (${Ne})`:""} \u2500\u2500`,isHeader:!0}),St.forEach(He=>{let Zt=typeof He=="string"?He:He.cmd||He.name||He.id||String(He);Zt&&!Zt.trim().startsWith("---")&&!Zt.startsWith(`
|
|
41
|
+
---`)&&ge.push({label:Zt,value:Zt,isHeader:!1,provider:et})}))}return ge},[m,x,s,ze]),te=C.useMemo(()=>{if(!ue.trim())return we;let se=ue.trim().toLowerCase(),b=[],F=null;for(let ge of we)ge.isHeader?F=ge:(ge.label.toLowerCase().includes(se)||ge.value&&ge.value.toLowerCase().includes(se))&&(F&&!b.includes(F)&&b.push(F),b.push(ge));return b},[we,ue]);qn(()=>{if(Y){let se=te.findIndex(b=>!b.isHeader);H(se>=0?se:0),Se(0)}},[ue]),qn(()=>{if(Y){if(te.length===0){H(0),Se(0);return}if(J>=te.length||te[J]?.isHeader){let se=te.findIndex(b=>!b.isHeader);H(se>=0?se:0)}}},[te,Y]);let[xe,Xe]=Ot(0),[P,ut]=Ot(0),[mt,Ut]=Ot("MB"),[Wt,Lr]=Ot(!1);qn(()=>{let se=!1;return import("./exec_command-43ZNHLVJ.js").then(b=>{se||Lr(!!b.isPtyAvailable)}).catch(()=>{}),()=>{se=!0}},[]),qn(()=>{let se=md.getHeapStatistics().heap_size_limit,b=se>=1024*1024*1024,F=b?"GB":"MB",ge=b?1024*1024*1024:1024*1024;ut(parseFloat((se/ge).toFixed(2))),Ut(F);let _e=()=>{let St=process.memoryUsage().rss/ge,He=b?parseFloat(St.toFixed(2)):Math.round(St);Xe(He)};_e();let gt=setInterval(()=>{_e()},3e4);return()=>clearInterval(gt)},[]);let Zo=se=>{switch(se){case"providers":{let F=[{label:"Current Provider",value:"aiProvider",status:m},...m.toLowerCase()==="google"||m.toLowerCase()==="openrouter"?[{label:"Show Paid Models?",value:"apiTier",status:x==="Free"?"No":"Yes"}]:[]];return m==="Ollama"&&F.push({label:"Endpoint",value:"ollamaEndpoint",status:t.ollamaEndpoint||"Cloud"}),F}case"appearance":return[{label:"Theme",value:"theme",status:t.theme||"Dark"},{label:"Loading Phrases",value:"loadingPhrases",status:t.loadingPhrases!==!1?"ON":"OFF"},{label:"Progressive Rendering [EXPERIMENTAL]",value:"progressiveRendering",status:t.progressiveRendering?"ON":"OFF"},{label:"Show TPM Estimate",value:"showTPMEstimate",status:t.showTPMEstimate?"ON":"OFF"}];case"memory":return[{label:"Toggle Memory",value:"memory",status:t.memory?"ON":"OFF"}];case"security":return[{label:"Sandbox Preset",value:"sandboxPreset",status:il(t),section:"Sandbox"},{label:"YOLO Mode",value:"autoExec",status:t.autoExec?"ON":"OFF",section:"Sandbox"},{label:"External Workspace Access",value:"externalAccess",status:t.allowExternalAccess?"ON":"OFF",section:"Sandbox"},{label:"Network Access (Terminal)",value:"networkAccess",status:t.networkAccess!==!1?"ON":"OFF",section:"Sandbox"},{label:"Always Ask Commands",value:"alwaysAsk",status:bs(t.alwaysAskCommands),section:"Sandbox"},{label:"Auto Approve Commands",value:"autoApprove",status:bs(t.autoApproveCommands),section:"Sandbox"},{label:"Auto Disapprove Commands",value:"autoDisallow",status:bs(t.autoDisallowCommands),section:"Sandbox"},{label:"Auto Approve Git Commits",value:"autoApproveGit",status:t.autoApproveGit?"ON":"OFF",section:"Sandbox"},{label:"Advanced Recovery [EXPERIMENTAL]",value:"advanceRollback",status:t.advanceRollback?"ON":"OFF",section:"Other"},{label:"Auto-Delete History",value:"autoDelete",status:t.autoDeleteHistory||"30d",section:"Other"},{label:"Save AppData Externally",value:"externalData",status:t.useExternalData?"ON":"OFF",section:"Other"}];case"updater":return[{label:"Auto-Update",value:"autoUpdate",status:t.autoUpdate?"ON":"OFF"},{label:"Preferred Package Manager",value:"updateManager",status:(t.updateManager||"npm")==="custom"?"Custom":(t.updateManager||"npm").toUpperCase()}];case"other":return[{label:"Sub-Agents",value:"subAgents",status:t.subAgents!==!1?"ON":"OFF"},{label:"Sub-Agent Model",value:"subAgentModel",status:t.CustomSubAgent&&t.SubAgentModel?t.SubAgentModel:"Default"},{label:"Verbose Thinking",value:"preserveThinking",status:t.preserveThinking!==!1?"ON":"OFF"},{label:"Dynamic Directory Awareness",value:"dynamicDirAwareness",status:t.dynamicDirAwareness?"ON":"OFF"},{label:"Directory Tree Design",value:"indentationTree",status:t.indentationTree!==!1?"Modern":"Classic (deprecated)"},{label:"Compact Large Tool Results",value:"compressToolResults",status:t.compressToolResults?"ON":"OFF"},{label:"Auto Truncate Results",value:"autoTruncateResults",status:t.autoTruncateResults?"ON":"OFF"},{label:"Image History for CU",value:"imageHistoryCU",status:t.imageHistoryCU||"Standard"}];default:return[]}},Ro=mo[k].id,je=Zo(Ro);cd((se,b)=>{if(Y){if(b.tab){Me(F=>F==="search"?"list":"search");return}if(ie==="search"){b.escape?Te(!1):b.downArrow||b.return?Me("list"):b.backspace||b.delete?ve(F=>F.slice(0,-1)):se&&!b.ctrl&&!b.meta&&se.length===1&&ve(F=>F+se);return}if(b.upArrow)H(F=>{if(te.length===0)return 0;let ge=(F-1+te.length)%te.length,_e=0;for(;te[ge]?.isHeader&&_e<te.length;)ge=(ge-1+te.length)%te.length,_e++;return ge});else if(b.downArrow)H(F=>{if(te.length===0)return 0;let ge=(F+1)%te.length,_e=0;for(;te[ge]?.isHeader&&_e<te.length;)ge=(ge+1)%te.length,_e++;return ge});else if(b.return){let F=te[J];F&&!F.isHeader&&(h(ge=>{let _e=F.value==="Default",gt={...ge,CustomSubAgent:!_e,SubAgentModel:F.value,SubAgentProvider:_e?"":F.provider||""};return T({systemSettings:gt,apiTier:x,quotas:s}),gt}),Te(!1))}else b.escape?Te(!1):se&&!b.ctrl&&!b.meta&&se.length===1&&(ve(F=>F+se),Me("search"));return}if(Be){if(b.upArrow){let F=(Le-1+uo.length)%uo.length;me(F)}else if(b.downArrow){let F=(Le+1)%uo.length;me(F)}else if(b.return){let F=uo[Le];h(ge=>{let _e={...ge,theme:F};return T({systemSettings:_e,apiTier:x,quotas:s}),_e}),E?E():De(!1)}else b.escape&&(E?E():De(!1));return}if(he){b.escape&&K(null);return}if(L==="categories")b.upArrow?X(F=>(F-1+mo.length)%mo.length):b.downArrow?X(F=>(F+1)%mo.length):b.return||b.rightArrow?mo[k].id==="exit"?S("chat"):(O("items"),le(0)):b.escape&&S("chat");else if(L==="items"){let F=je[ee];if(se==="?"&&F?.value==="dynamicDirAwareness"){S("dynamicDirHelp");return}if(b.upArrow)le(ge=>(ge-1+je.length)%je.length);else if(b.downArrow)le(ge=>(ge+1)%je.length);else if(b.leftArrow||b.escape)O("categories");else if(b.return){let ge=je[ee];Jt(ge)}}});let Jt=se=>{if(se.value==="memory")h(b=>({...b,memory:!b.memory}));else if(se.value==="sandboxPreset"){let b=il(t),F=["Autonomous","Balanced","Strict"],_e=(F.indexOf(b)+1)%F.length,gt=F[_e];h(et=>{let Ne={...et,sandboxPreset:gt};return gt==="Strict"?(Ne.autoExec=!1,Ne.allowExternalAccess=!1,Ne.networkAccess=!1,Ne.autoApproveCommands="",Ne.autoDisallowCommands="rm -rf, rm -f, del /f, del /q, rd /s, rmdir /s, format, mkfs, dd if=/dev, shred, srm, Remove-Item -Recurse -Force, Initialize-Disk, Clear-Disk, format c:, flashrom, nvram -c",Ne.alwaysAskCommands="killall, pkill, taskkill, shutdown, reboot, init 0, init 6, Stop-Process, Stop-Service, mv /*, move c:\\*, chmod 000, chmod -R 777, chown, icacls, netsh advfirewall, iptables -F, ufw disable, git reset --hard, git clean -fd, npm r, npm uninstall",Ne.autoApproveGit=!1):gt==="Balanced"?(Ne.autoExec=!0,Ne.allowExternalAccess=!1,Ne.networkAccess=!0,Ne.autoApproveCommands="ls, dir, cat, type, echo, pwd, cd, git status, git log, git diff, git branch, git show, help, mkdir, touch, md, whoami, hostname, ps, Get-Process, date, time",Ne.autoDisallowCommands="rm -rf, rm -f, del /f, del /q, rd /s, rmdir /s, format, mkfs, dd if=/dev, shred, srm, Remove-Item -Recurse -Force, Initialize-Disk, Clear-Disk, format c:, flashrom, nvram -c",Ne.alwaysAskCommands="killall, pkill, taskkill, Stop-Process, mv /*, move c:\\*, chmod 000, chmod -R 777, chown, icacls, shutdown, reboot, init 0, init 6, git reset --hard, git clean -fd, npm r, npm uninstall",Ne.autoApproveGit=!1):gt==="Autonomous"&&(Ne.autoExec=!0,Ne.allowExternalAccess=!0,Ne.networkAccess=!0,Ne.autoApproveCommands="ls, dir, cat, type, echo, pwd, cd, git status, git log, git diff, git branch, git show, help, mkdir, touch, md, whoami, hostname, ps, Get-Process, date, time",Ne.autoDisallowCommands="",Ne.alwaysAskCommands="rm -rf, rm -f, del /f, del /q, rd /s, rmdir /s, format, mkfs, dd if=/dev, shred, srm, Remove-Item -Recurse -Force, Initialize-Disk, Clear-Disk, format c:, flashrom, nvram -c",Ne.autoApproveGit=!0),Ne})}else if(se.value==="autoExec")t.autoExec?h(b=>({...b,autoExec:!1,sandboxPreset:"Custom"})):t.allowExternalAccess?S("doubleDanger"):S("autoExecDanger");else if(se.value==="externalAccess")t.allowExternalAccess?h(b=>({...b,allowExternalAccess:!1,sandboxPreset:"Custom"})):t.autoExec?S("doubleDanger"):S("externalDanger");else if(se.value==="networkAccess")h(b=>({...b,networkAccess:b.networkAccess===!1,sandboxPreset:"Custom"}));else if(se.value==="alwaysAsk")K("alwaysAskCommands"),re(t.alwaysAskCommands||"");else if(se.value==="autoApprove")K("autoApproveCommands"),re(t.autoApproveCommands||"");else if(se.value==="autoApproveGit")h(b=>({...b,autoApproveGit:!b.autoApproveGit,sandboxPreset:"Custom"}));else if(se.value==="autoDisallow")K("autoDisallowCommands"),re(t.autoDisallowCommands||"");else if(se.value==="ollamaEndpoint")h(b=>{let F=b.ollamaEndpoint==="Local"?"Cloud":"Local",ge={...b,ollamaEndpoint:F};return T({systemSettings:ge,apiTier:x,quotas:s}),ge});else if(se.value==="apiTier")S("apiTier");else if(se.value==="aiProvider")N&&N("settings"),S("selectProvider");else if(se.value==="advanceRollback")t.advanceRollback?h(b=>{let F={...b,advanceRollback:!1};return T({systemSettings:F,apiTier:x,quotas:s}),F}):S("advanceRollbackDanger");else if(se.value==="autoDelete"){let b=["1d","7d","30d"],ge=(b.indexOf(t.autoDeleteHistory||"30d")+1)%b.length;h(_e=>({..._e,autoDeleteHistory:b[ge]}))}else if(se.value==="autoUpdate")h(b=>({...b,autoUpdate:!b.autoUpdate}));else if(se.value==="externalData")if(!t.useExternalData)p({label:"Enter absolute path for External AppData:",note:"All history, logs and secrets will be stored here. ~/.fluxflow/settings.json stays as anchor.",key:"externalDataPath",value:t.externalDataPath||""}),S("input");else{let b={...t,useExternalData:!1};h(b),T({systemSettings:b,apiTier:x,quotas:s}),I(F=>[...F,{id:Date.now(),role:"system",text:"[STORAGE RESET] Flux Flow will return to default ~/.fluxflow after restart."}]),S("chat")}else if(se.value==="updateManager")S("updateManager");else if(se.value==="parserDownload")S("parserDownload");else if(se.value==="indentationTree")h(b=>{let F={...b,indentationTree:b.indentationTree===!1};return T({systemSettings:F,apiTier:x,quotas:s}),F});else if(se.value==="compressToolResults")h(b=>{let F={...b,compressToolResults:!b.compressToolResults};return T({systemSettings:F,apiTier:x,quotas:s}),F});else if(se.value==="autoTruncateResults")h(b=>{let F={...b,autoTruncateResults:!b.autoTruncateResults};return T({systemSettings:F,apiTier:x,quotas:s}),F});else if(se.value==="imageHistoryCU"){let b=["Low","Standard","Extended"],ge=(b.indexOf(t.imageHistoryCU||"Standard")+1)%b.length;h(_e=>{let gt={..._e,imageHistoryCU:b[ge]};return T({systemSettings:gt,apiTier:x,quotas:s}),gt})}else if(se.value==="subAgents")h(b=>{let F={...b,subAgents:b.subAgents===!1};return T({systemSettings:F,apiTier:x,quotas:s}),F});else if(se.value==="subAgentModel"){let b=t.CustomSubAgent&&t.SubAgentModel?t.SubAgentModel:"Default",F=te.findIndex(ge=>ge.value===b);H(F>=0?F:0),Te(!0)}else if(se.value==="preserveThinking")h(b=>{let F={...b,preserveThinking:b.preserveThinking===!1};return Zi(F.preserveThinking),T({systemSettings:F,apiTier:x,quotas:s}),F});else if(se.value==="dynamicDirAwareness")t.dynamicDirAwareness?h(b=>{let F={...b,dynamicDirAwareness:!1};return T({systemSettings:F,apiTier:x,quotas:s}),F}):S("dynamicDirDanger");else if(se.value==="loadingPhrases")h(b=>{let F={...b,loadingPhrases:b.loadingPhrases===!1};return T({systemSettings:F,apiTier:x,quotas:s}),F});else if(se.value==="progressiveRendering")h(b=>{let F={...b,progressiveRendering:!b.progressiveRendering};return T({systemSettings:F,apiTier:x,quotas:s}),F});else if(se.value==="showTPMEstimate")h(b=>{let F={...b,showTPMEstimate:!b.showTPMEstimate};return T({systemSettings:F,apiTier:x,quotas:s}),F});else if(se.value==="theme"){let b=t.theme==="Chaos"||t.theme==="Mystery"?"Mystery":t.theme||"Dark",F=uo.indexOf(b);me(F>=0?F:0),pe(t.theme||"Dark"),De(!0)}},ye=Ke(t.theme);if(Y){let se=t.CustomSubAgent&&t.SubAgentModel?t.SubAgentModel:"Default",b=15,F=ne;J<F?F=J:J>=F+b&&(F=J-b+1),F=Math.max(0,Math.min(F,Math.max(0,te.length-b))),F!==ne&&Se(F);let ge=te.slice(F,F+b);return C.createElement(Ae,{flexDirection:"column",borderStyle:"round",borderColor:ye.border,padding:1,width:"100%",minHeight:32},C.createElement(Ae,{marginBottom:1,flexDirection:"row",justifyContent:"space-between"},C.createElement(G,{color:ye.text,bold:!0,underline:!0},"Select Sub-Agent Model:"),te.length>0&&C.createElement(G,{color:"gray"},J+1,"/",te.length)),C.createElement(Ae,{borderStyle:"single",borderColor:ie==="search"?ye.primary||"cyan":"gray",paddingX:1,marginBottom:1},C.createElement(G,{color:ie==="search"?ye.primary||"cyan":"gray",bold:!0},"\u{1F50D} Search: "," "),C.createElement(G,{color:ye.text},ue),ie==="search"&&C.createElement(G,{color:ye.primary||"cyan"},"\u2588"),!ue&&ie!=="search"&&C.createElement(G,{color:"gray",italic:!0},"(Press TAB or type to filter models...)")),C.createElement(Ae,{flexDirection:"column",flexGrow:1,height:b},ge.length>0?ge.map((_e,gt)=>{let et=F+gt;if(_e.isHeader)return C.createElement(Ae,{key:`hdr-${et}`,paddingX:1},C.createElement(G,{color:"gray",bold:!0,underline:!0},_e.label));let Ne=J===et&&ie==="list",St=se===_e.value;return C.createElement(Ae,{key:`item-${_e.value}-${et}`,paddingX:1,backgroundColor:Ne?ye.highlightBg:void 0},C.createElement(G,{color:Ne?ye.text:ye.textDim,bold:Ne},Ne?"\u276F ":" ",_e.label,St?C.createElement(G,{color:ye.primary||"cyan",italic:!0}," (active)"):""))}):C.createElement(Ae,{paddingX:1},C.createElement(G,{color:"gray",italic:!0},'No models matching "',ue,'"'))),C.createElement(Ae,{paddingX:1,marginTop:1,flexDirection:"row",justifyContent:"space-between"},C.createElement(G,{color:"gray",italic:!0},"TAB to switch search/list \u2022 \u25B2\u25BC Navigate \u2022 ENTER to Select \u2022 ESC to Cancel"),C.createElement(G,{color:ie==="search"?ye.primary||"cyan":"gray",bold:!0},"[",ie.toUpperCase()," MODE]")))}if(Be){let se=uo[Le],b=Ke(se);return C.createElement(Ae,{flexDirection:"column",borderStyle:"round",borderColor:b.border,padding:1,width:"100%",minHeight:32},C.createElement(Ae,{marginBottom:1},C.createElement(G,{color:b.text,bold:!0},"Choose your color scheme:")),C.createElement(Ae,{flexDirection:"row",width:"100%",flexGrow:1},C.createElement(Ae,{flexDirection:"column",width:"30%",paddingRight:1},uo.map((F,ge)=>{let _e=Le===ge,gt=(t.theme||"Dark")===F,et=F==="Forest Sprite";return C.createElement(Ae,{key:F,paddingX:0},C.createElement(G,{color:_e?b.text:b.textDim,bold:_e},_e?"> ":" ",F,et&&C.createElement(G,{color:_e?b.success||"#52b788":"green",bold:!0}," \u2605"),gt?C.createElement(G,{color:b.primary||"cyan",italic:!0}," (saved)"):""))})),C.createElement(Ae,{flexDirection:"column",flexGrow:1,borderStyle:"round",borderColor:b.borderMuted,paddingX:2,paddingY:1,backgroundColor:b.cardBg},C.createElement(Ae,{marginBottom:1},C.createElement(G,{color:b.secondary||"cyan",bold:!0},"> ","you: "),C.createElement(G,{color:b.text},"add a greeting function")),C.createElement(Ae,{marginBottom:1},C.createElement(G,{color:b.success||"green"}," Here's the change:")),C.createElement(Ae,{flexDirection:"column",marginLeft:2,marginBottom:1},C.createElement(G,null,C.createElement(G,{color:b.textDim},"3 "),C.createElement(G,{color:b.textDim},' import "fmt"')),C.createElement(G,{color:b.textDim},"4"),C.createElement(Ae,{backgroundColor:b.diffRemovalBg},C.createElement(G,null,C.createElement(G,{color:b.diffRemovalNum||b.diffRemovalText},"5 "),C.createElement(G,{color:b.diffRemovalPrefix||b.diffRemovalText},"- "),C.createElement(G,{color:b.diffRemovalText},"func "),C.createElement(G,{color:b.diffRemovalHighlightColor||b.diffRemovalText,backgroundColor:b.diffRemovalHighlightBg,bold:!0},"main()"),C.createElement(G,{color:b.diffRemovalText}," {"))),C.createElement(Ae,{backgroundColor:b.diffAdditionBg},C.createElement(G,null,C.createElement(G,{color:b.diffAdditionNum||b.diffAdditionText},"5 "),C.createElement(G,{color:b.diffAdditionPrefix||b.diffAdditionText},"+ "),C.createElement(G,{color:b.diffAdditionText},"func "),C.createElement(G,{color:b.diffAdditionHighlightColor||b.diffAdditionText,backgroundColor:b.diffAdditionHighlightBg,bold:!0},"greet(name string)"),C.createElement(G,{color:b.diffAdditionText}," {"))),C.createElement(Ae,{backgroundColor:b.diffAdditionBg},C.createElement(G,null,C.createElement(G,{color:b.diffAdditionNum||b.diffAdditionText},"6 "),C.createElement(G,{color:b.diffAdditionPrefix||b.diffAdditionText},"+ "),C.createElement(G,{color:b.diffAdditionText}," "),C.createElement(G,{color:b.diffAdditionHighlightColor||b.diffAdditionText,backgroundColor:b.diffAdditionHighlightBg},'fmt.Printf("Hello, %s!\\n", name)'))),C.createElement(G,{color:b.textDim},"7 }")),C.createElement(Ae,{flexDirection:"column",marginTop:1,marginBottom:1},C.createElement(G,{color:b.textDim},"\u25BE Thought Process"),C.createElement(G,{color:b.textMuted}," I need to add a greeting function. I'll use fmt.Printf.")),C.createElement(Ae,{flexDirection:"column"},C.createElement(G,null,C.createElement(G,{color:b.warning||"yellow"},"\u2699 tool: "),C.createElement(G,{color:b.text},"write_file main.go")),C.createElement(G,null,C.createElement(G,{color:b.accent||"magenta"},"\u29BF task: "),C.createElement(G,{color:b.text},"Implementing greeting")),C.createElement(G,null,C.createElement(G,{color:b.danger||"red"},"X error: "),C.createElement(G,{color:b.text},"compilation failed")),C.createElement(G,null,C.createElement(G,{color:b.warning||"yellow"},"\u26A0 warning: "),C.createElement(G,{color:b.text},"deprecation warning")),C.createElement(G,null,C.createElement(G,{color:b.info||"blue"},"\u2192 link: "),C.createElement(G,{color:b.info||"blue",underline:!0},"file:///path/to/main.go")),C.createElement(G,null,C.createElement(G,{color:b.accent||"magenta"},"\u2605 accent: "),C.createElement(G,{color:b.text},"highlighted text")),C.createElement(G,{color:b.textDim},"\xB7 dim: press Enter to continue")))),C.createElement(Ae,{paddingX:1,marginTop:1,flexDirection:"row",justifyContent:"space-between"},C.createElement(G,{color:"gray",italic:!0},"\u25B2\u25BC Navigate \u2022 ENTER to Select \u2022 ESC to Cancel"),C.createElement(G,{color:"gray"},"Previewing: ",uo[Le],uo[Le]==="Forest Sprite"?" \u2605":"")))}return C.createElement(Ae,{flexDirection:"column",borderStyle:"round",borderColor:ye.border,padding:0,width:"100%",minHeight:32},C.createElement(Ae,{paddingX:1,paddingY:0,marginBottom:0,borderStyle:"single",borderColor:ye.borderMuted,width:"100%"},C.createElement(G,{color:ye.text,bold:!0},"SYSTEM CONFIGURATION")),C.createElement(Ae,{flexDirection:"row",width:"100%",minHeight:26},C.createElement(Ae,{flexDirection:"column",width:"30%",maxWidth:40,borderStyle:"round",borderColor:L==="categories"?ye.border:ye.borderMuted,padding:1,paddingY:0},C.createElement(Ae,{marginBottom:1},C.createElement(G,{color:L==="categories"?ye.text:ye.textDim,bold:!0,underline:!0},"CATEGORIES")),mo.map((se,b)=>{let F=k===b,ge=se.id==="exit";return C.createElement(Ae,{key:se.id,marginTop:ge?15:0,backgroundColor:F?L==="categories"?ye.highlightBg:ye.cardBg:void 0,paddingX:1},C.createElement(G,{color:F&&L==="categories"?ye.text:ye.textDim,bold:F},F?"\u276F ":" ",se.label))})),C.createElement(Ae,{flexDirection:"column",flexGrow:1,borderStyle:"round",borderColor:L==="items"?ye.border:ye.borderMuted,paddingX:1,marginLeft:1,paddingY:0},C.createElement(Ae,{marginBottom:1},C.createElement(G,{color:L==="items"?ye.text:ye.textDim,bold:!0,underline:!0},mo[k].label.toUpperCase().includes("EXIT")?"Runtime Information":`${mo[k].label} Settings`)),je.length>0?(()=>{let se=null,b=[],F=He=>(He||"").split(",").map(Zt=>Zt.trim().toLowerCase()).filter(Boolean),ge=F(t.autoApproveCommands),_e=F(t.autoDisallowCommands),gt=F(t.alwaysAskCommands),et=[...ge,..._e,...gt],Ne=new Set(et),St=Ro==="security"&&et.length!==Ne.size;return je.forEach((He,Zt)=>{let ro=L==="items"&&ee===Zt,Or=He.label.length,dt=Math.max(2,38-Or),W=".".repeat(dt),rt=kt=>Ro==="security"?(kt.value==="autoExec"||kt.value==="externalAccess")&&kt.status==="ON"?ye.statusOn:ye.statusOff:kt.status?.startsWith("\u2713")?ye.statusOn:kt.status?.startsWith("\u26A0")?ye.statusOff:kt.status==="ON"?ye.statusOn:kt.status==="OFF"?ye.statusOff:ye.text;He.section&&He.section!==se&&(se=He.section,b.push(C.createElement(Ae,{key:`sec-hdr-${He.section}`,marginTop:b.length>0?1:0,marginBottom:0,paddingX:1},C.createElement(G,{color:"gray",bold:!0,underline:!0},He.section.toUpperCase()))));let po=ro&&he&&(he==="alwaysAskCommands"&&He.value==="alwaysAsk"||he==="autoApproveCommands"&&He.value==="autoApprove"||he==="autoDisallowCommands"&&He.value==="autoDisallow"),Ue=He.value==="alwaysAsk"||He.value==="autoApprove"||He.value==="autoDisallow",Yt=He.value==="parserDownload";b.push(C.createElement(Ae,{key:He.value,flexDirection:"column"},C.createElement(Ae,{backgroundColor:ro&&!po?ye.highlightBg:void 0,paddingX:2},C.createElement(G,{color:ro?ye.text:ye.textDim,bold:ro},ro?"\u276F ":" ",He.label),!Ue&&!Yt&&C.createElement(C.Fragment,null,C.createElement(G,{color:"gray"},W),C.createElement(G,{color:rt(He),bold:!0},He.value==="aiProvider"?He.status:`[ ${He.status} ]`))),Ue&&!po&&He.status!=="None"&&C.createElement(Ae,{paddingX:4,marginBottom:1},C.createElement(G,{color:"gray"},"\u21B3 ",He.status)),po&&C.createElement(Ae,{flexDirection:"column",marginLeft:4,marginBottom:1},C.createElement(Ae,{paddingX:1,borderStyle:"single",borderColor:"gray",flexDirection:"row"},C.createElement(G,{color:"gray",bold:!0},"> "," "),C.createElement(ud,{value:q,onChange:re,onSubmit:kt=>{let _t={...t,[he]:kt.trim(),sandboxPreset:"Custom"};h(_t),T({systemSettings:_t,apiTier:x,quotas:s}),K(null)}})),C.createElement(G,{color:"gray",italic:!0}," Comma separated \u2022 Press Enter to save, Esc to cancel"))))}),St&&b.push(C.createElement(Ae,{key:"conflict-warning",marginTop:1,paddingX:1},C.createElement(G,{color:ye.text,italic:!0},"* Conflicting commands will be ignored and defaulted to highest priority"))),b})():C.createElement(Ae,{paddingX:1,flexDirection:"column",width:"100%"},Ro==="exit"?C.createElement(C.Fragment,null,C.createElement(Ae,{flexDirection:"column",marginBottom:1},C.createElement(Ae,{flexDirection:"row"},C.createElement(G,{color:ye.textDim},"OS"," "),C.createElement(G,{color:"gray"},"..................... "),C.createElement(G,{color:ye.text},process.env.OS||process.platform||"N/A")),C.createElement(Ae,{flexDirection:"row"},C.createElement(G,{color:ye.textDim},"Computer Name"," "),C.createElement(G,{color:"gray"},".......... "),C.createElement(G,{color:ye.text},process.env.COMPUTERNAME||process.env.HOSTNAME||"N/A")),C.createElement(Ae,{flexDirection:"row"},C.createElement(G,{color:ye.textDim},"Processor Count"," "),C.createElement(G,{color:"gray"},"........ "),C.createElement(G,{color:ye.text},process.env.NUMBER_OF_PROCESSORS||"N/A")),C.createElement(Ae,{flexDirection:"row"},C.createElement(G,{color:ye.textDim},"Node.js Version"," "),C.createElement(G,{color:"gray"},"........ "),C.createElement(G,{color:ye.text},"v",process.versions.node)),C.createElement(Ae,{flexDirection:"row"},C.createElement(G,{color:ye.textDim},"V8 Version"," "),C.createElement(G,{color:"gray"},"...... ...... "),C.createElement(G,{color:ye.text},"v",process.versions.v8)),C.createElement(Ae,{flexDirection:"row"},C.createElement(G,{color:ye.textDim},"Data Directory"," "),C.createElement(G,{color:"gray"},"......... "),Lo===lo?"":C.createElement(G,{color:ye.text},Lo.replaceAll(sl.homedir(),"~").replaceAll("\\\\","/").replaceAll("\\","/"),", "),C.createElement(G,{color:ye.text},lo.replaceAll(sl.homedir(),"~").replaceAll("\\\\","/").replaceAll("\\","/"))),C.createElement(Ae,{flexDirection:"row"},C.createElement(G,{color:ye.textDim},"Viewport"," "),C.createElement(G,{color:"gray"},"............... "),C.createElement(G,{color:ye.text},process.stdout.rows||"?"," rows \xD7 ",process.stdout.columns||"?"," cols ",process.stdout.columns<90?"(too small width)":"")),C.createElement(Ae,{flexDirection:"row",marginBottom:0},C.createElement(G,{color:ye.textDim},"Memory Load"," "),C.createElement(G,{color:"gray"},"............ "),C.createElement(G,{color:ye.text},xe,"/",P," ",mt))),C.createElement(Ae,{key:"pty-notice",paddingX:0,marginTop:0},C.createElement(G,{color:Wt?ye.statusOn:ye.warning},Wt?"\u2713 Advance Interactive Terminal Supported":"\u26A0 Interactive Terminal is Limited"))):C.createElement(G,{color:"gray",italic:!0},mo[k].desc)))),C.createElement(Ae,{paddingX:1,marginTop:0,flexDirection:"row",justifyContent:"space-between"},C.createElement(G,{color:"gray",italic:!0},L==="categories"?"\u25B2\u25BC Select Category \u2022 Enter/\u25BA to configure":je[ee]?.value==="dynamicDirAwareness"?"\u25B2\u25BC Select Option \u2022 Enter to Toggle \u2022 ? HELP \u2022 \u25C4/ESC to go back":"\u25B2\u25BC Select Option \u2022 Enter to Toggle \u2022 \u25C4/ESC to go back"),L==="categories"&&C.createElement(G,{color:"gray"},mo[k].desc)))}import Qt,{useState as ys,useEffect as gd}from"react";import{Box as xn,Text as Qn}from"ink";import fd from"ink-text-input";function Ss({initialData:t,onSave:h,onCancel:x,theme:S="Dark"}){let p=Ke(S),[T,s]=ys(0),[I,m]=ys(""),[v,E]=ys(()=>({name:t?.name||"",nickname:t?.nickname||"",instructions:t?.instructions||""})),N=[{key:"name",label:"Enter your Name: ",maxLength:20},{key:"nickname",label:"Enter a Nickname: ",maxLength:20},{key:"instructions",label:"System Instructions: ",maxLength:200}],M=N[T];gd(()=>{let k=N[T].key;m((v[k]||"").slice(0,N[T].maxLength))},[T,v]);let D=k=>{k.length>M.maxLength?m(k.slice(0,M.maxLength)):m(k)},L=k=>{if(k.trim().toLowerCase()==="/cancel"){x();return}let X=M.key,ee={...v,[X]:k.trim().slice(0,M.maxLength)};E(ee),m(""),T<N.length-1?s(T+1):h(ee)},O=I.length>=M.maxLength;return Qt.createElement(xn,{borderStyle:"round",borderColor:p.borderMuted,padding:0,marginTop:1,flexShrink:0,flexDirection:"column",width:"100%"},Qt.createElement(xn,{paddingX:1,marginBottom:1},Qt.createElement(Qn,{color:p.text,bold:!0},"USER PROFILE CONFIGURATION")),Qt.createElement(xn,{paddingX:1,flexDirection:"column"},Qt.createElement(xn,null,Qt.createElement(Qn,{color:p.text,bold:!0},M.label),Qt.createElement(fd,{value:I,onChange:D,onSubmit:L})),Qt.createElement(xn,{marginTop:1,justifyContent:"space-between"},Qt.createElement(Qn,{color:p.textMuted,italic:!0},"Step ",T+1," of ",N.length),Qt.createElement(Qn,{color:O?p.warning||"yellow":p.textMuted},"[",I.length,"/",M.maxLength,"]"))),Qt.createElement(xn,{paddingX:1,marginTop:1},Qt.createElement(Qn,{color:p.textMuted,italic:!0},"(Enter to submit \u2022 Type /cancel to abort)")))}import bt,{useState as Cs}from"react";import{Box as zt,Text as Uo,useInput as hd}from"ink";import xd from"ink-text-input";var pd=({question:t,options:h,onResolve:x,theme:S="Dark"})=>{let p=Ke(S),[T,s]=Cs(!1),[I,m]=Cs(""),[v,E]=Cs(0),N=!1,M=[],D=Array.isArray(h)&&h.length>0;try{M=[...D?h:[],D?{id:"CUSTOM",label:"Suggest something else...",description:"Provide a custom response"}:{id:"CUSTOM",label:"Your Answer",description:""}]}catch{N=!0}hd((O,k)=>{if(!T&&((k.leftArrow||k.upArrow)&&E(X=>Math.max(0,X-1)),(k.rightArrow||k.downArrow)&&E(X=>Math.min(M.length-1,X+1)),k.return)){let X=M[v];X?.id==="CUSTOM"?s(!0):x(N?"Selected Nothing":X.label)}});let L=Je(2);return T?bt.createElement(zt,{flexDirection:"column",borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,backgroundColor:p.codeBg,width:"100%"},bt.createElement(zt,{paddingX:1},bt.createElement(Uo,{color:p.text,bold:!0},"SUGGEST SOMETHING")),bt.createElement(zt,{marginTop:1,paddingX:1},bt.createElement(Uo,{italic:!0,color:p.textMuted},"Replying to: ",t)),bt.createElement(zt,{marginTop:1,paddingX:1,flexDirection:"row"},bt.createElement(xd,{value:I,onChange:m,onSubmit:()=>x(I)})),bt.createElement(zt,{marginTop:1,paddingX:1,marginBottom:1},bt.createElement(Uo,{color:p.textMuted,italic:!0},"(Press Enter to send)"))):bt.createElement(zt,{flexDirection:"column",border:!0,borderStyle:"round",borderColor:p.codeBorder,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,marginY:1,marginRight:1,width:"100%"},bt.createElement(zt,{paddingX:1,marginBottom:1},bt.createElement(Uo,{color:"yellow",bold:!0},"AGENT REQUEST: ACTION REQUIRED")),bt.createElement(zt,{paddingX:1,marginBottom:1},bt.createElement(Uo,{color:p.text},t)),bt.createElement(zt,{flexDirection:"column",width:"100%"},M.map((O,k)=>{let X=k===v;return bt.createElement(zt,{key:O.id,flexDirection:"column",width:"100%",backgroundColor:X?p.highlightBg:void 0,paddingX:1,marginBottom:k===M.length-1?0:1},bt.createElement(Uo,{color:X?p.text:p.textMuted,bold:X},X?"\u276F ":" ",O.label),O.description&&bt.createElement(zt,{marginLeft:4},bt.createElement(Uo,{color:p.textMuted,italic:!0},O.description)))})),bt.createElement(zt,{paddingX:1,marginTop:1,marginBottom:1},bt.createElement(Uo,{color:p.textMuted,italic:!0},"(Use Arrows to navigate, Enter to confirm)")))},ll=pd;import Xd from"gradient-string";import Pt,{useState as Ms,useEffect as Td}from"react";import{Box as go,Text as _o,useInput as wd}from"ink";function vs({onSelect:t,onDelete:h,onClose:x,theme:S="Dark"}){let p=Ke(S),[T,s]=Ms({}),[I,m]=Ms([]),[v,E]=Ms(0);Td(()=>{(async()=>{let k=await Po();s(k),m(Object.keys(k).sort((X,ee)=>(k[ee].updatedAt||0)-(k[X].updatedAt||0)))})()},[]),wd((O,k)=>{if(k.escape&&x(),k.upArrow&&E(X=>Math.max(0,X-1)),k.downArrow&&E(X=>Math.min(I.length-1,X+1)),k.return&&I[v]&&t(I[v]),O==="x"&&I[v]){let X=I[v];h(X).then(ee=>{let le=ee||{};s(le);let he=Object.keys(le).sort((K,q)=>(le[q]?.updatedAt||0)-(le[K]?.updatedAt||0));m(he),E(K=>Math.max(0,Math.min(he.length-1,K)))})}});let N=Je(2),M=15,D=0;if(I.length>M){let O=Math.floor(M/2);D=v-O,D<0?D=0:D+M>I.length&&(D=I.length-M)}let L=I.slice(D,D+M);return Pt.createElement(go,{flexDirection:"column",borderStyle:"round",borderColor:p.borderMuted,padding:0,width:"100%"},Pt.createElement(go,{paddingX:1,marginBottom:1},Pt.createElement(_o,{color:p.text,bold:!0},"CHAT HISTORY: RESUME CONVERSATION")),I.length===0?Pt.createElement(go,{paddingX:2,paddingY:1},Pt.createElement(_o,{italic:!0,color:p.textMuted},"No saved chats found.")):Pt.createElement(go,{flexDirection:"column",width:"100%"},D>0&&Pt.createElement(go,{paddingX:2,marginBottom:1},Pt.createElement(_o,{color:p.textMuted},"\u25B2 (+",D," more chats above)")),L.map((O,k)=>{let X=T[O],le=D+k===v,he=bd(X?.updatedAt);return Pt.createElement(go,{key:O,paddingX:1,backgroundColor:le?p.highlightBg:void 0,width:"100%"},Pt.createElement(go,{flexGrow:1},Pt.createElement(_o,{color:le?p.text:p.textMuted,bold:le},le?"\u276F ":" ",(()=>{let K=q=>(q||"").replace(/\[\/?(?:STEERING HINT|QUESTION)(?::\s*\w+)?\]/gi,"").trim();return X?.name&&!X.name.startsWith("Session")?K(X.name):X?.prompt?K(X.prompt):K(X?.name)||O})(),Pt.createElement(_o,{color:p.textMuted}," [",he," \u2022 ",O,"]"))),le&&Pt.createElement(go,{flexShrink:0},Pt.createElement(_o,{color:p.danger,bold:!0},"[X] DELETE ")))}),D+M<I.length&&Pt.createElement(go,{paddingX:2,marginTop:1},Pt.createElement(_o,{color:p.textMuted},"\u25BC (+",I.length-(D+M)," more chats below)"))),Pt.createElement(go,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:p.borderMuted},Pt.createElement(_o,{color:p.textMuted,italic:!0},"\u2191\u2193 navigate \u2022 Enter select \u2022 x delete \u2022 Esc close")))}function bd(t){if(!t)return"N/A";let h=new Date(t);if(isNaN(h.getTime()))return"N/A";let x=I=>String(I).padStart(2,"0"),S=x(h.getMonth()+1),p=x(h.getDate()),T=x(h.getHours()),s=x(h.getMinutes());return`${S}-${p} ${T}:${s}`}import yt,{useState as Es,useEffect as yd}from"react";import{Box as fo,Text as oo,useInput as Sd,useStdout as Cd}from"ink";function Bs({onClose:t,theme:h="Dark"}){let x=Ke(h),{stdout:S}=Cd(),p=S?.columns||80,[T,s]=Es([]),[I,m]=Es(0),[v,E]=Es(!0),N=()=>{let K=bi(rs,[]);s(K);try{let re=fr(Ko,{}).systemSettings?.memory!==!1;E(re)}catch{E(!0)}};yd(()=>{N()},[]),Sd((K,q)=>{if(q.escape&&t(),q.upArrow&&m(re=>Math.max(0,re-1)),q.downArrow&&m(re=>Math.min(T.length-1,re+1)),K==="x"&&T.length>0){let re=T[I].id,Be=T.filter(De=>De.id!==re);yi(rs,Be),s(Be),I>=Be.length&&Be.length>0&&m(Be.length-1)}});let M=(K,q,re)=>{if(!K)return"";let Be=K.replace(/\[Saved on: .*?\]/g,"").replace(/\\+'/g,"'").trim(),Le=`${re?"\u276F ":" "}${q+1}. `.length,me=re?22:2;return Be.split(`
|
|
42
|
+
`).map((pe,Y)=>{let Te=Y===0,J=Math.max(10,p-4-(Te?Le:3)-me),H=Math.max(10,p-4-3-me),ne=pe.split(/(\s+)/),Se=[],ue="";if(ne.forEach(ie=>{if(ie.length===0)return;let Me=Se.length===0?J:H;ue.length+ie.length>Me?ue.trim().length>0?(Se.push(ue.trimEnd()),ue=ie):(Se.push(ie.substring(0,Me)),ue=ie.substring(Me)):ue+=ie}),ue.trimEnd().length>0&&Se.push(ue.trimEnd()),Se.length===0)return"";let ve=Se.join(`
|
|
43
|
+
`);return Te?ve:" "+ve}).join(`
|
|
44
|
+
`)},D=4*1024*2,L=T.reduce((K,q)=>K+(q.memory?.length||0),0),O=Math.min(100,Math.round(L/D*100)),k=12,X=Math.round(O/100*k),ee="\u2588".repeat(X)+"\u2591".repeat(Math.max(0,k-X)),le=()=>O<50?x.textMuted:O<90?x.warning:x.danger,he=Je(2);return yt.createElement(fo,{flexDirection:"column",borderStyle:"round",borderColor:x.borderMuted,padding:0,width:"100%"},yt.createElement(fo,{paddingX:1,marginBottom:1,justifyContent:"space-between"},yt.createElement(oo,{color:x.text,bold:!0},"SAVED MEMORIES"),yt.createElement(fo,null,yt.createElement(oo,{color:x.textMuted},"Vault: "),yt.createElement(oo,{color:le()},ee),yt.createElement(oo,{color:x.text,bold:!0}," ",O,"%"))),!v&&T.length>0?yt.createElement(fo,{paddingX:2,paddingY:1},yt.createElement(oo,{italic:!0,color:x.textMuted},"Memory is currently Off...")):T.length===0?yt.createElement(fo,{paddingX:2,paddingY:1},yt.createElement(oo,{italic:!0,color:x.textMuted},v?"Learning...":"Memory not available...")):yt.createElement(fo,{flexDirection:"column"},T.map((K,q)=>{let re=q===I;return yt.createElement(fo,{key:K.id,paddingX:1,backgroundColor:re?x.highlightBg:void 0,width:"100%"},yt.createElement(fo,{flexGrow:1},yt.createElement(oo,{color:re?x.text:x.textMuted,bold:re},re?"\u276F ":" ",q+1,". ",M(K.memory,q,re))),re&&yt.createElement(fo,{flexShrink:0},yt.createElement(oo,{color:x.textMuted,dimColor:!0}," [",yt.createElement(oo,{italic:!0},K.score),"] "),yt.createElement(oo,{color:x.danger,bold:!0},"[X] WIPE ")))})),yt.createElement(fo,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:x.borderMuted},yt.createElement(oo,{color:x.textMuted,italic:!0},"\u2191\u2193 navigate \u2022 x wipe memory \u2022 Esc close")))}import ct,{useState as Dr,useEffect as al}from"react";import{Box as Xo,Text as Ft}from"ink";import{spawn as dl}from"child_process";var cl=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],Md=({latest:t,current:h,settings:x,onClose:S,onUpdateSettings:p,onSuccess:T})=>{let[s,I]=Dr("initializing"),[m,v]=Dr(""),[E,N]=Dr(null),[M,D]=Dr(0);if(al(()=>{let L=setInterval(()=>{D(O=>(O+1)%1e3)},33);return()=>clearInterval(L)},[]),al(()=>{let L;return(async()=>{let k=x.updateManager||"npm";if(!x.updateManager){p();return}let X="";k==="pnpm"?X=`pnpm add -g fluxflow-cli@${t}`:k==="bun"?X=`bun add -g fluxflow-cli@${t}`:k==="yarn"?X=`yarn global add fluxflow-cli@${t}`:k==="custom"?X=x.customUpdateCommand:X=`npm install -g fluxflow-cli@${t}`,I("downloading"),v(`Running: ${X}...`);let ee=process.platform==="win32",le=K=>new Promise(q=>{let re=ee?K?"powershell.exe":"cmd.exe":process.env.SHELL||"bash",Be=ee?K?["-NoProfile","-Command",X]:["/c",X]:["-c",X],De=me=>{let pe=me.toString().replace(/\x1B\[[0-?]*[ -/]*[@-~]|\x1B\][^\x07\x1B]*[\x07\x1B]|\b|\x07/g,"").replace(/\r/g,"").trim();pe&&v(Y=>{let Te=Y.split(`
|
|
45
|
+
`);return Te[Te.length-1]?.startsWith("Progress:")&&pe.startsWith("Progress:")?(Te[Te.length-1]=pe,Te.slice(-5).join(`
|
|
46
|
+
`)):(Y+`
|
|
47
|
+
`+pe).split(`
|
|
48
|
+
`).slice(-10).join(`
|
|
49
|
+
`)})},Le=ee?dl(re,Be,{cwd:process.cwd(),env:process.env}):dl(X,{shell:!0,cwd:process.cwd(),env:process.env});L=Le,Le.stdout.on("data",De),Le.stderr.on("data",De),Le.on("close",me=>{L=null,q(me!==0?{error:`Process exited with code ${me}`}:{success:!0})}),Le.on("error",me=>{ee&&K&&me.code==="ENOENT"?q({retryCmd:!0}):(L=null,q({error:me.message}))})}),he={};ee?(he=await le(!0),he.retryCmd&&(he=await le(!1))):he=await le(!1),he.error?(N(he.error),I("error")):he.success&&(I("success"),T&&T())})(),()=>{if(L)try{typeof L.destroy=="function"?L.destroy():typeof L.kill=="function"&&L.kill()}catch{}}},[]),s==="initializing"||s==="downloading"){let L=cl[Math.floor(M/3)%cl.length];return ct.createElement(Xo,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1},ct.createElement(Xo,null,ct.createElement(Ft,{color:"gray"},L),ct.createElement(Ft,{marginLeft:1,bold:!0,color:"white"}," Updating Flux Flow to v",t,"...")),ct.createElement(Xo,{marginTop:1,paddingX:1,borderStyle:"single",borderColor:"gray"},ct.createElement(Ft,{color:"gray",italic:!0},m||"Preparing environment...")),ct.createElement(Ft,{marginTop:1,color:"gray"},"(Please do not close the terminal)"))}return s==="success"?ct.createElement(Xo,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1},ct.createElement(Ft,{color:"white",bold:!0},"\u2705 UPDATE SUCCESSFUL!"),ct.createElement(Ft,{marginTop:1,color:"white"},"Flux Flow has been updated to ",ct.createElement(Ft,{color:"gray"},"v",t),"."),ct.createElement(Ft,{marginTop:1,color:"white",bold:!0},"Please restart your terminal session to apply changes."),ct.createElement(Xo,{marginTop:1},ct.createElement(Ft,{color:"gray"},"(Press ESC to return to chat)"))):s==="error"?ct.createElement(Xo,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1},ct.createElement(Ft,{color:"white",bold:!0},"\u274C UPDATE FAILED"),ct.createElement(Xo,{marginTop:1,paddingX:1,borderStyle:"single",borderColor:"gray"},ct.createElement(Ft,{color:"white"},E)),ct.createElement(Ft,{marginTop:1,color:"white"},"Possible causes:"),ct.createElement(Ft,{color:"white"},"\u2022 Missing permissions (Try running as Administrator/Sudo)"),ct.createElement(Ft,{color:"white"},"\u2022 Package manager (",x.updateManager,") not found"),ct.createElement(Ft,{color:"white"},"\u2022 Network failure"),ct.createElement(Xo,{marginTop:1},ct.createElement(Ft,{color:"gray"},"(Press ESC to return to chat)"))):null},ul=Md;import Gt,{useState as ml,useEffect as vd}from"react";import{Box as $o,Text as pn,useInput as Ed}from"ink";var Ir=[{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 Ds({onClose:t}){let[h,x]=ml(0),[S,p]=ml({});return vd(()=>{let T={};Ir.forEach(s=>{Hi(s.file)?T[s.file]="ready":T[s.file]="idle"}),p(T)},[]),Ed(async(T,s)=>{s.escape&&t(),s.upArrow&&x(m=>Math.max(0,m-1)),s.downArrow&&x(m=>Math.min(Ir.length-1,m+1));let I=Ir[h];if(T==="x"||T==="X"){if(S[I.file]==="downloading")return;try{await Gi(I.file),p(m=>({...m,[I.file]:"idle"}))}catch(m){p(v=>({...v,[I.file]:`error: ${m.message}`}))}}if(s.return){if(S[I.file]==="downloading")return;p(m=>({...m,[I.file]:"downloading"}));try{await $i(I.file),p(m=>({...m,[I.file]:"ready"}))}catch(m){p(v=>({...v,[I.file]:`error: ${m.message}`}))}}}),Gt.createElement($o,{flexDirection:"column",borderStyle:"round",borderColor:"gray",padding:0,width:"100%"},Gt.createElement($o,{paddingX:1,marginBottom:1},Gt.createElement(pn,{color:"white",bold:!0},"LANGUAGE PARSER MANAGER")),Gt.createElement($o,{flexDirection:"column"},Ir.map((T,s)=>{let I=s===h,m=S[T.file]||"idle",v="[ DOWNLOAD ]",E="gray";m==="downloading"?(v="[ DOWNLOADING... ]",E="yellow"):m==="ready"?(v="[ READY ]",E="green"):m.startsWith("error")&&(v=`[ ${m.toUpperCase()} ]`,E="red");let N=`${T.label} (${T.exts.join(", ")})`,M=Math.max(2,45-N.length),D=".".repeat(M);return Gt.createElement($o,{key:T.file,paddingX:1,backgroundColor:I?"#2a2a2a":void 0,width:"100%"},Gt.createElement($o,null,Gt.createElement(pn,{color:I?"white":"grey",bold:I},I?"\u276F ":" ",T.label," ",Gt.createElement(pn,{dimColor:!0},"(",T.exts.join(", "),")"))),Gt.createElement($o,{flexGrow:1},Gt.createElement(pn,{color:"gray",dimColor:!0},D)),Gt.createElement($o,{width:20},Gt.createElement(pn,{color:E,bold:!0},v)))})),Gt.createElement($o,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:"gray"},Gt.createElement(pn,{color:"grey",italic:!0},"\u2191\u2193 navigate \u2022 Enter download \u2022 x delete \u2022 Esc close")))}var Is=["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 ks=["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 It,{useState as Bd}from"react";import{Box as ho,Text as Mo,useInput as Dd}from"ink";function As({prompts:t,onSelect:h,onClose:x,theme:S="Dark"}){let p=Ke(S),[T,s]=Bd(0);Dd((N,M)=>{M.escape&&x(),M.upArrow&&s(D=>Math.max(0,D-1)),M.downArrow&&s(D=>Math.min(t.length-1,D+1)),M.return&&t[T]&&h(t[T].id)});let I=Je(2),m=10,v=0;if(t.length>m){let N=Math.floor(m/2);v=T-N,v<0?v=0:v+m>t.length&&(v=t.length-m)}let E=t.slice(v,v+m);return It.createElement(ho,{flexDirection:"column",borderStyle:"round",borderColor:p.borderMuted,padding:0,width:"100%"},It.createElement(ho,{paddingX:1,marginBottom:1},It.createElement(Mo,{color:p.text,bold:!0},"CODEBASE TIME TRAVEL: SELECT UNDO POINT")),It.createElement(ho,{paddingX:2,marginBottom:1},It.createElement(Mo,{color:p.text},"Select a prompt to revert the codebase back to the state ",It.createElement(Mo,{bold:!0,color:p.secondary||"cyan"},"immediately before")," it was executed:")),t.length===0?It.createElement(ho,{paddingX:2,paddingY:1},It.createElement(Mo,{italic:!0,color:p.textMuted},"No prompt checkpoints found for this session.")):It.createElement(ho,{flexDirection:"column",width:"100%"},v>0&&It.createElement(ho,{paddingX:2,marginBottom:1},It.createElement(Mo,{color:p.textMuted},"\u25B2 (+",v," more prompts above)")),E.map((N,M)=>{let L=v+M===T,O=kd(N.timestamp),k=N.changes?N.changes.length:0;return It.createElement(ho,{key:N.id,paddingX:1,backgroundColor:L?p.highlightBg:void 0,width:"100%"},It.createElement(ho,{flexGrow:1},It.createElement(Mo,{color:L?p.text:p.textMuted,bold:L},L?"\u276F ":" ",'"',Id(N.prompt),'"',It.createElement(Mo,{color:p.textMuted}," [",O," \u2022 ",k," file(s) changed]"))))}),v+m<t.length&&It.createElement(ho,{paddingX:2,marginTop:1},It.createElement(Mo,{color:p.textMuted},"\u25BC (+",t.length-(v+m)," more prompts below)"))),It.createElement(ho,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:p.borderMuted},It.createElement(Mo,{color:p.textMuted,italic:!0},"\u2191\u2193 navigate \u2022 Enter select undo point \u2022 Esc close")))}function Id(t){if(!t)return"";let x=(t.split(`
|
|
50
|
+
`)[0]||"").replace(/@\[(.*?)\]/g,(S,p)=>{let T=p.replace(/\\/g,"/").split("/");return`[${T[T.length-1]}]`});return x.length>69?x.slice(0,67)+"...":t.includes(`
|
|
51
|
+
`)?x+"...":x}function kd(t){if(!t)return"N/A";let h=new Date(t);if(isNaN(h.getTime()))return"N/A";let x=s=>String(s).padStart(2,"0"),S=x(h.getHours()),p=x(h.getMinutes()),T=x(h.getSeconds());return`${S}:${p}:${T}`}import{exec as Ad}from"child_process";import{promisify as Ld}from"util";import gl from"fs";var fl=Ld(Ad),hl=async()=>{try{let t=Xi();if(t.executablePath&&gl.existsSync(t.executablePath))return!0;let{default:h}=await import("puppeteer"),x=h.executablePath();if(x&&gl.existsSync(x))return!0}catch{return!1}return!1},xl=async t=>{t&&t("\u{1F4E5} Downloading Chromium engine (chrome@148)...");try{try{await fl("pnpm exec puppeteer browsers install chrome@148")}catch{await fl("npx -y puppeteer browsers install chrome@148")}return await new Promise(h=>setTimeout(h,1e3)),{success:!0}}catch(h){return console.error("[SETUP ERROR]",h),{success:!1,error:h.message}}};import pl,{useState as Tl,useEffect as wl}from"react";import{Text as bl}from"ink";var Od=({text:t,baseColor:h="grey",glintColor:x="gray",speed:S=200,glintWidth:p=6,typeSpeed:T=30,...s})=>{let[I,m]=Tl(-p),[v,E]=Tl(t);return wl(()=>{let N=setInterval(()=>{m(M=>M>v.length+p?-p-40:M+1)},S);return()=>clearInterval(N)},[v.length,S,p]),wl(()=>{if(t&&(t.includes("Trying to reach")&&v&&v.includes("Trying to reach")||t.includes("Error Occurred")&&v&&v.includes("Error Occurred"))){E(t);return}if(v===t)return;let N=setTimeout(()=>{let M=0,D=Math.min(v.length,t.length);for(;M<D&&v[M]===t[M];)M++;v.length>M?E(L=>L.slice(0,-1)):v.length<t.length&&E(t.slice(0,v.length+1))},T);return()=>clearTimeout(N)},[t,v,T]),pl.createElement(bl,null,v.split("").map((N,M)=>{let L=Math.abs(M-I)<=p/2?x:h;return pl.createElement(bl,{key:M,color:L,...s},N)}))},zn=Od;var Jn=t=>{let h=String(t);return h.startsWith("999")&&h.endsWith("9")},wn=t=>t==null||t===0||Jn(t)?"":String(t),Jo=()=>{let t=(process.env.TERM_PROGRAM||"").toLowerCase(),h=(process.env.VSCODE_CWD||"").toLowerCase(),x=(process.env.VSCODE_CODE_CACHE_PATH||"").toLowerCase(),S=(process.env.GIT_ASKPASS||"").toLowerCase(),p=(process.env.VSCODE_GIT_ASKPASS_NODE||"").toLowerCase(),T=(process.env.VSCODE_GIT_ASKPASS_MAIN||"").toLowerCase();return t==="antigravity"||process.env.ANTIGRAVITY_AGENT||process.env.ANTIGRAVITY_PID||process.env.ANTIGRAVITY_EDITOR_APP_ROOT||process.env.ANTIGRAVITY_CLI_ALIAS||h.includes("antigravity")||x.includes("antigravity")||S.includes("antigravity")||p.includes("antigravity")||T.includes("antigravity")?"Antigravity":t==="cursor"||process.env.CURSOR_SETTINGS_DIR||process.env.CURSOR_CONFIG_DIR||h.includes("cursor")||x.includes("cursor")||S.includes("cursor")||p.includes("cursor")?"Cursor":t==="windsurf"||process.env.WINDSURF_SETTINGS_DIR||h.includes("windsurf")||x.includes("windsurf")||S.includes("windsurf")||p.includes("windsurf")?"Windsurf":t==="trae"||process.env.TRAE_SETTINGS_DIR||h.includes("trae")||p.includes("trae")?"Trae":t==="positron"||h.includes("positron")||p.includes("positron")?"Positron":t==="codium"||t==="vscode-oss"||h.includes("codium")||x.includes("codium")||p.includes("codium")?"VSCodium":t==="vscode-insiders"||h.includes("code - insiders")||x.includes("code - insiders")||p.includes("code - insiders")?"VS Code Insiders":t==="vscode"||process.env.VSCODE_GIT_IPC_HANDLE||process.env.VSCODE_PID||process.env.VSCODE_INJECTION||h.includes("code")||x.includes("code")||p.includes("code")?"VS Code":process.env.INTELLIJ_TERMINAL_COMMAND_BLOCKS||process.env.TERMINAL_EMULATOR?.toLowerCase().includes("jetbrains")?"JetBrains":process.env.WT_SESSION?"Windows Terminal":"Terminal"},$d=t=>{switch(t){case"VS Code":return"Code";case"VS Code Insiders":return"Code - Insiders";case"Antigravity":return"Antigravity IDE";default:return t}},yl={Flux:"Workspace",Flow:"Studio",ICU:"Computer Use",FluxCU:"Omni"},Ls=t=>{if(!t)return"Workspace";let h=Object.keys(yl).find(x=>x.toLowerCase()===t.toLowerCase());return h?yl[h]:t},Sl=t=>{let h=$d(t),x=Ns.homedir();if(process.platform==="win32"){let S=process.env.APPDATA;return S?Et.join(S,h,"User","keybindings.json"):null}else return process.platform==="darwin"?Et.join(x,"Library","Application Support",h,"User","keybindings.json"):Et.join(x,".config",h,"User","keybindings.json")},Cl=t=>{let h=t.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,"$1");return JSON.parse(h)},Hd=t=>Array.isArray(t)?t.some(h=>h&&typeof h.key=="string"&&h.key.toLowerCase().replace(/\s+/g,"")==="shift+enter"&&h.command==="workbench.action.terminal.sendSequence"&&h.args&&h.args.text==="\x1B[13;2u"&&typeof h.when=="string"&&h.when.includes("terminalFocus")):!1,vl=t=>{let h=t==="VS Code",x=[];return h?(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},Gd=({width:t,height:h,selectedIndex:x,aiProvider:S,theme:p="Dark"})=>{let T=Jo(),s=vl(T);return e.createElement(c,{flexDirection:"column",alignItems:"center",justifyContent:"center",width:t,height:h},e.createElement(c,{marginBottom:1,width:Math.min(80,t-4),justifyContent:"flex-start"},e.createElement(i,null,pr(no,S,p))),e.createElement(c,{flexDirection:"column",borderStyle:"double",borderColor:"grey",paddingX:3,paddingY:1,width:Math.min(80,t-4)},e.createElement(i,{bold:!0,color:"white",textAlign:"center"},"\u{1F680} UPGRADE YOUR WORKFLOW"),e.createElement(c,{marginY:1,flexDirection:"column",alignItems:"left"},e.createElement(i,null,"You're in ",e.createElement(i,{bold:!0,color:"cyan"},T),", but the ",e.createElement(i,{bold:!0,color:"white"},"FluxFlow-CLI Companion")," is not installed."),e.createElement(c,{flexDirection:"column",marginY:1},e.createElement(i,{color:"gray"}," \u2705 Real-time IDE context & Error Resolution"),e.createElement(i,{color:"gray"}," \u2705 Auto-open files created by agent"),e.createElement(i,{color:"gray"}," \u2705 Native DIFFing for AI edits"),e.createElement(i,{color:"gray"}," \u2705 Direct IDE context sharing"),e.createElement(i,{color:"gray"}," \u2705 Surgical Diagnostic Sync"),e.createElement(i,{color:"gray"}," \u2705 Native Right-Click \u276F Chat integration"),e.createElement(i,{color:"gray"}," \u2705 Live Status in IDE"),e.createElement(i,{color:"gray"}," \u2705 Clickable terminal-to-code links"))),e.createElement(c,{flexDirection:"column",marginTop:1},s.map((I,m)=>e.createElement(c,{key:m},e.createElement(i,{color:x===m?"yellow":"white",bold:x===m},x===m?" \u276F ":" ",I.label)))),e.createElement(c,{marginTop:1,alignItems:"center",justifyContent:"center"},e.createElement(i,{dimColor:!0,italic:!0},"(Use arrows to navigate, Enter to select)"))))},Os=Date.now(),Ml="https://fluxflow-cli.onrender.com/changelog",Ps="https://fluxflow-cli.onrender.com/",Wd=Et.join(Et.dirname(_d(import.meta.url)),"../package.json"),El=JSON.parse(at.readFileSync(Wd,"utf8")),no=El.version,Yd=El.date||"2026-05-20";var Vd=({data:t,onResolve:h,onEdit:x,theme:S="Dark"})=>{let p=Ke(S);return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:p.borderMuted,padding:0,width:"100%"},e.createElement(c,{paddingX:1},e.createElement(i,{color:p.text,bold:!0,underline:!0},t.startsWith("/btw")?"QUESTION":"STEERING HINT"," RESOLUTION")),e.createElement(c,{paddingX:1,marginTop:1},e.createElement(i,{color:p.text},"The agent already finished the task before your ",t.startsWith("/btw")?"question":"hint"," was consumed.")),e.createElement(c,{marginTop:1,backgroundColor:p.cardBg||p.codeBg||"#222",paddingX:2,width:"100%"},e.createElement(i,{italic:!0,color:p.textMuted},'"',t.replace("/btw","").trim(),'"')),e.createElement(c,{paddingX:1,marginTop:1},e.createElement(i,{color:p.textDim||p.textMuted},"How would you like to proceed?")),e.createElement(c,{marginTop:0},e.createElement(xt,{title:"Select Action",items:[{label:"Send Anyway",value:"send"},{label:"Edit Prompt",value:"edit"}],onSelect:T=>{(typeof T=="object"&&T!==null?T.value:T)==="send"?h(t):x(t)},theme:S})))};var jd=(()=>{let t=null,h=0;return x=>{let S=Date.now();if(t&&S-h<1e4)return t;let p=[],T=s=>{if(!(p.length>=2e3))try{let I=at.readdirSync(s);for(let m of I){if(p.length>=2e3)return;if(["node_modules",".git",".gemini","dist","build",".next",".cache","out"].includes(m))continue;let v=Et.join(s,m);at.statSync(v).isDirectory()?T(v):p.push({name:vt(m),relativePath:vt(Et.relative(process.cwd(),v))})}}catch{}};return T(x),t=p,h=S,p}})(),Ar="Ctrl + Enter",Kd=t=>{if(t<=370)return"#00a564";if(t>=5e3)return"#ff0000";let h=[{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<h.length-1;x++){let S=h[x],p=h[x+1];if(t>=S.t&&t<=p.t){let T=(t-S.t)/(p.t-S.t);T=T*T*(3-2*T);let s=Math.round(S.r+(p.r-S.r)*T),I=Math.round(S.g+(p.g-S.g)*T),m=Math.round(S.b+(p.b-S.b)*T);return`#${((1<<24)+(s<<16)+(I<<8)+m).toString(16).slice(1)}`}}return"#ff0000"},qd=e.memo(({sa:t,showTPMEstimate:h=!1})=>{let[x,S]=j("green"),[p,T]=j(0),s=Ye([]),I=Ye(370),m=Ye([]),v=Ye(t.lastChunkTime);return Ze(()=>{v.current=t.lastChunkTime},[t.lastChunkTime]),Ze(()=>{if(t.status!=="running"){m.current=[];return}if(t.wps>0){let E=m.current;E.push(t.wps),E.length>3&&E.shift(),T(Math.round(t.wps))}},[t.status,t.wps,t.lastChunkTime]),Ze(()=>{if(t.status!=="running"){T(0);return}let E=setInterval(()=>{let N=v.current,M=N>0?Date.now()-N:0;if(N>0&&M>1500)m.current=[],T(0);else if(N>0&&M>600){m.current.length>0&&m.current.shift();let D=m.current;if(D.length>0){let L=D.reduce((O,k)=>O+k,0);T(Math.round(L/D.length))}else T(0)}else{let D=m.current;if(D.length>0){let L=D.reduce((O,k)=>O+k,0);T(Math.round(L/D.length))}else t.wps>0&&T(Math.round(t.wps))}},750);return()=>clearInterval(E)},[t.status]),Ze(()=>{if(t.status!=="running"){s.current=[];return}let E=t.lastChunkTime;if(E>0){let D=s.current;(D.length===0||D[D.length-1]!==E)&&(D.push(E),D.length>10&&D.shift())}let N=()=>{if(!E){S("#00a564");return}let D=s.current,L=0;if(D.length>1){let K=0;for(let q=1;q<D.length;q++)K+=D[q]-D[q-1];L=K/(D.length-1)}let O=Date.now()-E,X=O>=2500,ee=!X&&L>0?Math.min(O,L*3):O,le=Math.max(L,ee),he=X?.4:.2;I.current=I.current*(1-he)+le*he,S(Kd(I.current))};N();let M=setInterval(N,100);return()=>clearInterval(M)},[t.status,t.lastChunkTime]),e.createElement(c,{justifyContent:"space-between",width:"100%"},e.createElement(i,{color:"white"}," \u2022 ",t.title," ",e.createElement(i,{color:"white",dimColor:!0},"(",t.id,")")),e.createElement(i,{color:"white"},e.createElement(i,{color:"white",dimColor:!0,bold:!0},t.currentTool||"Active"),e.createElement(i,{color:x}," \u25CF"),h&&e.createElement(i,{color:"white",dimColor:!0,bold:!0}," (",p," tps)")))});function Qd({args:t=[]}){let h=Ye(1),[x,S]=j(!1),[p,T]=j(10),{stdout:s}=Nd(),[I,m]=j(""),[v,E]=j(0),[N,M]=j(!1),[D,L]=j("Flux"),[O,k]=j(0),[X,ee]=j({columns:s?.columns||80,rows:s?.rows||24}),[le,he]=j(0),[K,q]=j(!1),[re,Be]=j(!1),[De,Le]=j(0),me=Ye(0),$e=Ye(0),pe=Ye(null),Y=Ye(null),Te=Ye(0),[J,H]=j(0),ne=()=>H(o=>o+1),Se=Ye([]),ue=Ye(null),ve=()=>{let o=Se.current;if(o.length>0&&Y.current){let n=o.join("");o.length=0,Y.current.text=vt(Y.current.text+n),ne()}},ie=()=>{if(ve(),Y.current){let o=vt(Y.current.text);Y.current.role==="think"&&(o=o.replace(/^\r?\n+/,"").replace(/\r?\n+$/,""));let n={...Y.current,text:o,isStreaming:!1};_(a=>{let g=[...a,n];return V(g.length),g}),Y.current=null}$s.current=0,Xr.current={totalWords:0,startTime:0,wps:0,chunks:[]}},Me=()=>{ue.current&&clearInterval(ue.current),Se.current=[],ue.current=setInterval(()=>{try{let o=Se.current;if(o.length>0&&Y.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 g=0;g<n&&o.length>0;g++)a+=o.shift();Y.current.text=vt(Y.current.text+a),ne()}}catch{}},80)},ze=async()=>{for(;de.progressiveRendering&&Se.current.length>0;)await new Promise(o=>setTimeout(o,10))},qe=o=>{if(de.progressiveRendering&&ue.current){let n=o.split(/(\s+)/).filter(Boolean);for(let a of n)Se.current.push(a)}else Y.current?Y.current.text=vt(Y.current.text+o):Y.current={id:"agent-"+Date.now(),role:"agent",text:vt(o),isStreaming:!0},ne()};Ze(()=>{let o=Jo(),n=!["Terminal","Windows Terminal"].includes(o)||!!process.env.VSC_TERMINAL_URL,a=setTimeout(()=>{n&&!Qo()&&Be(!0)},500),g=setInterval(()=>{Qo()&&Be(!1)},1e3);h.current=Date.now();let u=setInterval(()=>{h.current&&(Date.now()-h.current||0)>3e4&&global.gc&&(async()=>{for(let d=0;d<1;d++)global.gc(),await new Promise(w=>setImmediate(w));h.current=Date.now()})()},3e3);return()=>{clearTimeout(a),clearInterval(g),clearInterval(u)}},[]),Ze(()=>{(async()=>{try{let n=await ls(),a=n?.systemSettings||{},g=a.CustomSubAgent,u=a.SubAgentModel;if(!g||!u||u==="Default")return;let y=process.env.SUBAGENT_MODEL?process.env.SUBAGENT_MODEL.trim():null,f=process.env.SUBAGENT_PROVIDER?process.env.SUBAGENT_PROVIDER.trim():null,d=["Google","DeepSeek","OpenRouter","NVIDIA","Mistral","Ollama","CrofAI","InferX","SenseNova","AIHubMix","Poolside","9router","ExpLabs"],B=(Z=>{if(!Z)return null;let R=Z.toLowerCase();return R==="google"?"Google":R==="deepseek"?"DeepSeek":R==="openrouter"?"OpenRouter":R==="nvidia"?"NVIDIA":R==="mistral"?"Mistral":R==="ollama"?"Ollama":R==="crofai"||R==="crof"?"CrofAI":R==="inferx"?"InferX":R==="sensenova"?"SenseNova":R==="poolside"?"Poolside":R==="9router"?"9router":R==="aihubmix"||R==="aihub"?"AIHubMix":R==="explabs"||R==="experientiallabs"||R==="experimentallabs"||R==="experiential labs"||R==="experimental labs"||R==="experiential"||R==="experimental"?"ExpLabs":null})(f);if(y&&!B){let Z=n.aiProvider||P||"Google";_(R=>(V(R.length+1),[...R,{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(u==="ENV"){y||_(Z=>(V(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",oe=n.apiTier||rt||"Free",ae=n.quotas||Ue||{},z=new Set;(Oo($,oe)||[]).forEach(Z=>{let R=typeof Z=="string"?Z:Z.cmd||Z.name||Z.id||String(Z);R&&z.add(R)});for(let Z of d)try{if(await un(Z)){let it=ae?.providerTiers?.[Z]||"Free";(Oo(Z,it)||[]).forEach(Fe=>{let tt=typeof Fe=="string"?Fe:Fe.cmd||Fe.name||Fe.id||String(Fe);tt&&z.add(tt)})}}catch{}let Oe=z.has(u);y?y!==u&&_(Z=>(V(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}])):Oe||_(Z=>(V(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 we=Tn(()=>{let o={};for(let n=0;n<t.length;n++)if(t[n]==="--key"&&t[n+1]){let g=t[n+1];if(o.key=g,g.includes("@")){let u=g.split("@"),y=u[0],f=u[1].toLowerCase();if(["google","deepseek","openrouter","nvidia","mistral","ollama","crof","crofai","inferx","sensenova","aihubmix","aihub","poolside","pool","9router","9r"].includes(f)){let d="Google";f==="google"?d="Google":f==="deepseek"?d="DeepSeek":f==="openrouter"?d="OpenRouter":f==="nvidia"?d="NVIDIA":f==="mistral"?d="Mistral":f==="ollama"?d="Ollama":f==="crof"||f==="crofai"?d="CrofAI":f==="inferx"?d="InferX":f==="sensenova"?d="SenseNova":f==="poolside"||f==="pool"?d="Poolside":f==="9router"||f==="9r"?d="9router":(f==="aihubmix"||f==="aihub")&&(d="AIHubMix"),o.key=y,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 g=t[n+1].toLowerCase();["npm","pnpm","yarn","bun"].includes(g)&&(o.package=g),n++}else if(a==="--auto-del"&&t[n+1]){let g=t[n+1].toLowerCase();["1d","7d","30d"].includes(g)&&(o.autoDel=g),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 u=t[n+1].toLowerCase();if(["flux","flow","icu","computer","fluxcu"].includes(u)){let y="Flux";u==="flux"?y="Flux":u==="flow"?y="Flow":u==="icu"||u==="computer"?y="ICU":u==="fluxcu"&&(y="FluxCU"),o.mode=y}n++}else if(a==="--thinking"&&t[n+1]){let u=t[n+1].toLowerCase();if(["fast","low","medium","high","xhigh","standard"].includes(u)){let y="Medium";u==="fast"?y="Fast":u==="low"?y="Low":u==="standard"?y="Standard":u==="medium"?y="Medium":u==="high"?y="High":u==="xhigh"&&(y="xHigh"),o.thinking=y}n++}else if(a==="--provider"&&t[n+1]){let g=t[n+1].toLowerCase();if(["google","deepseek","openrouter","nvidia","mistral","ollama","crof","crofai","inferx","sensenova","aihubmix","aihub","poolside","pool","9router","9r"].includes(g)){let u="Google";g==="google"?u="Google":g==="deepseek"?u="DeepSeek":g==="openrouter"?u="OpenRouter":g==="nvidia"?u="NVIDIA":g==="mistral"?u="Mistral":g==="ollama"?u="Ollama":g==="crof"||g==="crofai"?u="CrofAI":g==="inferx"?u="InferX":g==="sensenova"?u="SenseNova":g==="poolside"||g==="pool"?u="Poolside":g==="9router"||g==="9r"?u="9router":(g==="aihubmix"||g==="aihub")&&(u="AIHubMix"),o.provider=u}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]),te=async(o=!1,n=null)=>{let a=n||de;o&&_(g=>(V(g.length+1),[...g,{id:"check-"+Date.now(),role:"system",text:"\u2726 Checking for updates...",isMeta:!0}]));try{let u=await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json(),y=u["dist-tags"]?.latest,f=u["dist-tags"]?.stable;if(y&&Lr(y),y&&y!==no){let d=y===f?`v${y}`:`v${y}`;!o&&a.autoUpdate?W("update"):_(w=>{let B=[...w],$=o?B.length:Math.min(B.length,3);return B.splice($,0,{id:"update-"+Date.now(),role:"system",text:`A new version (${d}) is here.
|
|
52
|
+
|
|
53
|
+
\u2022 Type \`/update latest\` to apply the update.
|
|
54
|
+
\u2022 Type \`/changelog\` to view the release notes.`,isUpdateNotification:!0,isMeta:!0}),B})}else o&&_(d=>{V(d.length+1);let w=y&&y===f?`${no}`:no;return[...d,{id:"uptodate-"+Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Already up to date (${w}).
|
|
55
|
+
\u2800`,isMeta:!0}]})}catch(g){o&&_(u=>(V(u.length+1),[...u,{id:"check-err-"+Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Failed to check for updates: ${g.message}.
|
|
56
|
+
\u2800`,isMeta:!0}]))}};Ze(()=>{let o=()=>{s.write("\x1B[2J\x1B[3J\x1B[H"),ee({columns:s.columns,rows:s.rows})};return s.on("resize",o),()=>{s.off("resize",o)}},[s]);let[xe,Xe]=j("Medium"),[P,ut]=j("Google"),[mt,Ut]=j(0),[Wt,Lr]=j(null),[Zo,Ro]=j(!1),[je,Jt]=j(ao("Google","Free")||"gemma-4-31b-it"),[ye,se]=j(!1),[b,F]=j(Mi("gemma_janitor_fallback_google")||"gemma-4-26b-a4b-it"),[ge,_e]=j(!0),[gt,et]=j(!0),Ne=Ye(0),[St,He]=j(null),[Zt,ro]=j(""),Or=async o=>{let n=Sl(o);if(n)try{await at.ensureDir(Et.dirname(n));let a=[];if(at.existsSync(n)){let g=at.readFileSync(n,"utf8").trim();if(g)try{a=Cl(g)}catch{a=[]}}Array.isArray(a)||(a=[]),a.push({key:"shift+enter",command:"workbench.action.terminal.sendSequence",args:{text:"\x1B[13;2u"},when:"terminalFocus"}),at.writeFileSync(n,JSON.stringify(a,null,4),"utf8"),Ar="Shift + Enter",_(g=>(V(g.length+1),[...g,{id:"kb-success-"+Date.now(),role:"system",text:`\u2726 Successfully configured Shift+Enter in your ${o} keybindings!
|
|
57
|
+
`,isMeta:!0}]))}catch(a){_(g=>(V(g.length+1),[...g,{id:"kb-error-"+Date.now(),role:"system",text:`\u2726 Failed to update keybindings: ${a.message}.
|
|
58
|
+
\u2800`,isMeta:!0}]))}},[dt,W]=j("chat"),[rt,po]=j("Free"),[Ue,Yt]=j({limitMode:"Daily",agentLimit:99999999,tokenLimit:99999999999999,backgroundLimit:999999,searchLimit:100,customModelId:"",customLimit:0,providerBudgets:{}}),[kt,_t]=j(null),[vo,Bl]=j("chat"),[en,Pr]=j("settings"),[tn,Dl]=j([]),[zd,Il]=j(0),[Fs,Zn]=j(0),[Nr,Us]=j({}),[Fr,Ur]=j({}),[Rn,To]=j(0),[de,At]=j({memory:!0,theme:"Dark",compression:0,autoExec:!1,autoDeleteHistory:"7d",autoUpdate:!1,updateManager:"npm",customUpdateCommand:""}),l=Tn(()=>Ke(de.theme),[de.theme]),[bn,_s]=j({name:null,nickname:null,instructions:null}),[Eo,er]=j({keyType:"Default",quality:"Low-High",apiKey:""}),[so,Ho]=j({tokens:0}),[Xs,_r]=j(0),$s=Ye(0),Xr=Ye({totalWords:0,startTime:0,wps:0,chunks:[]}),[Hs,Gs]=j(0),[Ws,kl]=j(0),[qt,Ys]=j(0),[Al,yn]=j(0),Sn=Ye(0),[Ll,Cn]=j(0),Mn=Ye(0),[Ol,vn]=j(0),En=Ye(0),[on,Vs]=j(0),[io,js]=j(0),[nn,Ks]=j(0),[Jd,Pl]=j(0),[Zd,Nl]=j(0),[Rd,Fl]=j(0),[tr,Ul]=j(0),[or,_l]=j(0),[nr,Xl]=j(0),[qs,$l]=j(0),[Bn,$r]=j(null),[rr,Hr]=j(null),[Gr,Qs]=j(null),[rn,Dn]=j("daily"),[Hl,Rt]=j(0),[In,kn]=j(""),An="flow-playground",[st,sr]=j(t.includes("--playground")?An:ms());Ze(()=>{if(Vo.current)return;let o=qt-Sn.current,n=io-Mn.current,a=on-En.current;yn(o),Cn(n),vn(Math.max(0,a)),st&&_i(st,o,so.tokens).catch(()=>{})},[qt,io,on,st,so.tokens]),Ze(()=>{dt==="apiTier"&&(async()=>{let n=await hr();$r(n);let a=await xr();Hr(a);let g=await as(Ue.resetDay||1);Qs(g)})()},[dt,Ue.resetDay]);let[eo,zs]=j(null),[sn,ln]=j(""),[Ln,Js]=j(!1),[Wr,Gl]=j([]),[ec,tc]=j(0),Zs=Ye(!0),Rs=Ye(!0),Yr=Ye(P),Vr=Ye(!1),jr=Ye(!0);Ze(()=>{ye&&(se(!1),_(o=>(V(o.length+1),[...o,{id:Date.now(),role:"system",text:`\u2726 Wildcard Tooling:
|
|
59
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Status: Disabled.
|
|
60
|
+
\u2800`,isMeta:!0}]))),process.env.forcedReasoning&&(_(o=>(V(o.length+1),[...o,{id:Date.now(),role:"system",text:`\u2726 Forced Reasoning:
|
|
61
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Status: Disabled.
|
|
62
|
+
\u2800`,isMeta:!0}])),process.env.forcedReasoning=!1)},[je]);let ei;Ze(()=>{if(Rs.current){ei=setTimeout(()=>{Rs.current=!1,Yr.current=P},1e3);return}if(Yr.current!==P)if(Yr.current=P,P==="Mistral")Xe("Fast");else{if(P==="SenseNova"||P==="Poolside"){Xe("High");return}Xe(P==="DeepSeek"||P==="NVIDIA"||P==="CrofAI"||P==="InferX"||P==="Ollama"||P==="CroAI"||P==="OpenRouter"||P==="ExpLabs"?"Standard":"Medium")}else P==="Google"&&xe==="xHigh"&&je&&je.toLowerCase().startsWith("gemini-3")&&Xe("High");return()=>{clearTimeout(ei)}},[P,je]);let ti;Ze(()=>{if(!St)return;if(Zs.current){ti=setTimeout(()=>{Zs.current=!1},1500);return}let o=ao(P,rt),n=o;return o.includes("gemma")?n="Gemma":o.includes("deepseek")?n="DeepSeek Flash":o.includes("devstral")?n="Devstral":o.includes("mistral")?n="Mistral":o.includes("gemini")&&(n="Gemini Flash"),Jt(o),Lt({apiTier:rt,activeModel:o}),()=>{clearTimeout(ti)}},[rt,P,St]);let Wl=Tn(()=>{let o=Jo();return{isIDE:!["Terminal","Windows Terminal"].includes(o)||!!process.env.VSC_TERMINAL_URL||!!process.env.INTELLIJ_TERMINAL_COMMAND_BLOCKS,get shortcut(){return Ar}}},[]),ir=Ye(null),Kr=Ye("");Ze(()=>{ir.current=eo},[eo]),Ze(()=>{Kr.current=sn},[sn]);let[Yl,Vl]=j(!1),[Bo,an]=j(null),[Go,qr]=j(null),lr=o=>{an(null),W("chat")},oi=o=>{let n=Math.floor(o/3600),a=Math.floor(o%3600/60),g=o%60,u=[];return n>0&&u.push(`${n}h`),(a>0||n>0)&&u.push(`${a}m`),u.push(`${g}s`),u.join(" ")},Wo=o=>o<1e3?`${o}ms`:oi(Math.floor(o/1e3)),[On,Qr]=j(null),[zr,ni]=j(""),[jl,Kl]=j(!1),[ri,Pn]=j(0),Nn;Ze(()=>{let o;if(On&&de.loadingPhrases!==!1){let n=()=>{let a=ks[Math.floor(Math.random()*ks.length)];ni(a)};zr||n(),o=setInterval(n,1e4)}else ni("");return()=>{clearInterval(o)}},[On,de]);let[oc,ql]=j(!0),[dn,Jr]=j(!1),[ar,si]=j(!1),[Ql,zl]=j(!1),[ii,nc]=j(null),[li,Fn]=j(0),[Jl,ai]=j([]),Yo=Ye(null),Vo=Ye(!1);Ze(()=>()=>{Yo.current&&clearTimeout(Yo.current)},[]);let Zr=Ye(!1),[Un,Rr]=j(null),[Zl,es]=j(null),[rc,Rl]=j(null);Ze(()=>Fn(0),[I]);let[pt,ea]=j(()=>{let o={id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0},n=process.cwd()===Ns.homedir(),a=(()=>{let u=process.cwd().toLowerCase();if(process.platform==="win32"){let y=process.env.SystemRoot?.toLowerCase()||"c:\\windows",f=process.env.ProgramFiles?.toLowerCase()||"c:\\program files",d=process.env["ProgramFiles(x86)"]?.toLowerCase()||"c:\\program files (x86)";return u.startsWith(y)||u.startsWith(f)||u.startsWith(d)}else return u==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(f=>u.startsWith(f))})(),g=[o];return a?g.push({id:"system-warning",role:"system",text:"[CRITICAL SECURITY ALERT] SYSTEM DIRECTORY DETECTED",subText:`You are currently in a PROTECTED SYSTEM DIRECTORY (${process.cwd()}). Operating here is EXTREMELY dangerous as the agent could accidentally corrupt your OS or installed applications. Open FluxFlow in project folder to work safely.`,isHomeWarning:!0}):n&&g.push({id:"home-warning",role:"system",text:"[SECURITY ALERT] HOME DIRECTORY DETECTED",subText:`You are currently in ${Ns.homedir()}. Working here is high-risk as the agent may modify system-sensitive configurations. Please open FluxFlow in project folder.`,isHomeWarning:!0}),g}),_=o=>{ea(n=>{let a=typeof o=="function"?o(n):o;if(a.length>1){let g=a[a.length-1],u=a[a.length-2];if(g?.text?.includes("Request Cancelled")&&u?.text?.includes("Request Cancelled"))return a.slice(0,-1)}return a})},wo=Ye(null),[di,ta]=j(""),[ci,ui]=j(!1),mi=Ye(""),gi=Ye(null);Ze(()=>{if(pt.length===0)return;let o=pt[pt.length-1];if(o&&(o.role==="agent"||o.role==="assistant")){let a=(o.text||"").match(/\[ANSWER\]([\s\S]*?)(?:\[\/ANSWER\]|$)/i);if(a){let g=a[1].trim();g&&g!==mi.current&&(ta(g),mi.current=g,gi.current!==o.id&&ui(!0))}}},[pt]);let[Do,V]=j(pt.length),[jo,ts]=j(0),sc=Ye([]),Vt=Ye({completedIndex:0,columns:0,historicalBlocks:[],seenSelections:new Set,chatId:"",clearKey:0,theme:""}),fi=Tn(()=>{let o=X.columns||80,n=/Selection: (.*)/,a=[],g=new Set,u=Vt.current.columns!==o,y=Do<Vt.current.completedIndex,f=Vt.current.chatId!==st,d=Vt.current.clearKey!==jo,w=Vt.current.theme!==de.theme;if(u||y||f||d||w){let z=pt.slice(0,Do);for(let Ce=0;Ce<z.length;Ce++){let Oe=z[Ce];if(Oe.isAskRecord&&Oe.text){let R=Oe.text.match(n);if(R&&R[1].trim()){let it=R[1].trim();if(g.has(it))continue;g.add(it)}}let Z=_n(Oe,o);for(let R=0;R<Z.completed.length;R++)a.push(Z.completed[R]);for(let R=0;R<Z.active.length;R++)a.push(Z.active[R])}Vt.current={completedIndex:Do,columns:o,historicalBlocks:a,seenSelections:new Set(g),chatId:st,clearKey:jo,theme:de.theme}}else if(a=Vt.current.historicalBlocks,g=Vt.current.seenSelections,Do>Vt.current.completedIndex){a=[...a],g=new Set(g);let z=pt.slice(Vt.current.completedIndex,Do);for(let Ce=0;Ce<z.length;Ce++){let Oe=z[Ce];if(Oe.isAskRecord&&Oe.text){let R=Oe.text.match(n);if(R&&R[1].trim()){let it=R[1].trim();if(g.has(it))continue;g.add(it)}}let Z=_n(Oe,o);for(let R=0;R<Z.completed.length;R++)a.push(Z.completed[R]);for(let R=0;R<Z.active.length;R++)a.push(Z.active[R])}Vt.current={completedIndex:Do,columns:o,historicalBlocks:a,seenSelections:g,chatId:st,clearKey:jo}}let B=pt.slice(Do),$=[],oe=[];for(let z=0;z<B.length;z++){let Ce=B[z];if(Ce.isAskRecord&&Ce.text){let Z=Ce.text.match(n);if(Z&&Z[1].trim()){let R=Z[1].trim();if(g.has(R))continue}}let Oe=_n(Ce,o);for(let Z=0;Z<Oe.completed.length;Z++)$.push(Oe.completed[Z]);for(let Z=0;Z<Oe.active.length;Z++)oe.push(Oe.active[Z])}if(Y.current){let z=_n(Y.current,o);for(let Ce=0;Ce<z.completed.length;Ce++)$.push(z.completed[Ce]);for(let Ce=0;Ce<z.active.length;Ce++)oe.push(z.active[Ce])}let ae=$.length===0?a:a.concat($);return ae.length>=75e3&&(ae=[...ae],ae.push({key:`memory-warning-block-${ae.length}`,msg:{role:"system",text:"\u26A0\uFE0F MEMORY WARNING: CHAT IS GETTING VERY LONG",subText:`This session has reached ${ae.length} blocks. To maintain optimal performance and prevent high memory usage, it is highly recommended to save and start a clean chat with /clear.`,isHomeWarning:!0},type:"full-message"})),{completed:ae,active:oe}},[pt,Do,X.columns,jo,st,J]),oa=Tn(()=>{if(!eo||!sn)return!1;let o=sn.trim();return o.endsWith("?")||o.endsWith(":")||/\[[yYnN/]+\]\s*$/.test(o)||/\([yYnN]\)\s*$/.test(o)},[eo,sn]);Pd((o,n)=>{if(!(o==="\x1B[I"||o==="\x1B[O"||o==="[I"||o==="[O")){if(n.ctrl&&(o.toLowerCase()==="r"||o===""||o==="")){nl();return}if(dt==="stats"){if(rn==="dailyModelBreakdown"||rn==="modelBreakdown"){if(n.tab&&!n.shift){Dn(g=>g==="dailyModelBreakdown"?"modelBreakdown":"dailyModelBreakdown"),Rt(0);return}if(n.space||o===" "){Dn(g=>g==="dailyModelBreakdown"?"daily":"monthly"),Rt(0),kn("");return}if(n.escape){if(In){kn(""),Rt(0);return}W("chat");return}if(n.upArrow){Rt(g=>Math.max(0,g-1));return}if(n.downArrow){Rt(g=>Math.min($e.current,g+1));return}if(n.backspace||n.delete){kn(g=>g.slice(0,-1)),Rt(0);return}if(o&&o!==" "&&!n.space&&!n.ctrl&&!n.meta&&o.length===1&&o.charCodeAt(0)>=32){kn(g=>g+o),Rt(0);return}return}if(n.tab&&!n.shift){Dn(g=>g==="daily"?"monthly":"daily"),Rt(0);return}if(n.space||o===" "){Dn(g=>g==="daily"?"dailyModelBreakdown":"modelBreakdown"),Rt(0),kn("");return}if(n.upArrow){Rt(g=>Math.max(0,g-1));return}if(n.downArrow){Rt(g=>Math.min($e.current,g+1));return}}if(re){let a=Jo(),g=vl(a);if(n.upArrow)Le(u=>u>0?u-1:g.length-1);else if(n.downArrow)Le(u=>u<g.length-1?u+1:0);else if(n.return){let u=g[De];if(u.action==="dismiss")Be(!1);else if(u.url){let y=process.platform==="win32"?`start ${u.url}`:process.platform==="darwin"?`open ${u.url}`:`xdg-open ${u.url}`;xo(y),Be(!1)}}return}if(n.tab&&eo){Js(a=>!a);return}if(Ln&&eo){if(n.return)if(mn)jt("\r");else{let a=process.platform==="win32";jt(a?`\r
|
|
63
|
+
`:`
|
|
64
|
+
`),ln(g=>g+`
|
|
65
|
+
`)}else if(n.backspace||n.delete)mn?jt("\x7F"):(jt("\b \b"),ln(a=>a.slice(0,-1)));else if(n.upArrow)jt(n.shift?"\x1B[1;2A":"\x1B[A");else if(n.downArrow)jt(n.shift?"\x1B[1;2B":"\x1B[B");else if(n.rightArrow)jt(n.shift?"\x1B[1;2C":"\x1B[C");else if(n.leftArrow)jt(n.shift?"\x1B[1;2D":"\x1B[D");else if(n.escape)jt("\x1B");else if(n.ctrl&&o){let a=o.toLowerCase().charCodeAt(0);a>=97&&a<=122?jt(String.fromCharCode(a-96)):jt(o)}else o&&(jt(o),mn||ln(a=>a+o));return}if(dt==="providerBudgetSelect"){let a=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","CrofAI","InferX","SenseNova","AIHubMix","Poolside"];if(n.upArrow){Zn(g=>(g-1+a.length)%a.length);return}else if(n.downArrow){Zn(g=>(g+1)%a.length);return}else if(o===" "){let g=a[Fs];Us(u=>({...u,[g]:!u[g]}));return}else if(n.return){let g=a.filter(y=>Nr[y]);if(g.length===0)return;let u={...Ue,providerBudgets:{...Ue.providerBudgets||{},__useProvider:!0}};Yt(u),Dl(g),Il(0),Zn(0),W("providerBudgetFlow");return}else if(n.escape){W("budgetTypeSelect");return}return}if(dt==="providerBudgetFlow"){let a=tn.length,g=a*2+1;if(n.upArrow){To(u=>u===g-1?Math.max(0,(a-1)*2):u>=2?u-2:u);return}else if(n.downArrow){To(u=>u===g-1?u:u+2<g-1?u+2:g-1);return}else if(n.leftArrow){To(u=>u===g-1?u:u%2===1?u-1:u);return}else if(n.rightArrow||n.tab){To(u=>u===g-1?u:u%2===0||u+1<g?u+1:u);return}else if(n.return){if(Rn===g-1){let u=Ue.providerBudgets||{},y={__useProvider:!0};for(let w of tn){let B=Fr[w]||{};y[w]={agentLimit:9999999999,tokenLimit:parseInt(B.tokenLimit,10)||0,monthlyTokenLimit:parseInt(B.monthlyTokenLimit,10)||0}}let f={...Ue,providerBudgets:y};Yt(f),Lt({apiTier:rt,quotas:f}),W(vo==="settings"?"resetMode":"budgetResetMode")}else To(u=>Math.min(g-1,u+1));return}else if(n.escape){W("providerBudgetSelect");return}return}if(n.escape){if(ci){if(ui(!1),pt.length>0){let a=pt[pt.length-1];a&&(gi.current=a.id)}return}if(Ge.length>0&&dt==="chat"){q(!0);return}if(x){S(!1);return}if(dn||eo||Bo||Go)Zr.current=!0,Yi(),Pi(),Bo&&(Bo.resolve("deny"),an(null)),Go&&(Go.resolve(null),qr(null)),zl(!1),ii&&clearTimeout(ii);else if(dt==="revert")W("chat"),Fn(0);else if(dt!=="chat"&&dt!=="settings")W("chat");else{if(!St&&mt===1){Ut(0),ro("");return}Fn(a=>{let g=a+1;return g===1?(Yo.current&&clearTimeout(Yo.current),Yo.current=setTimeout(()=>Fn(0),2e3)):g===2&&(Yo.current&&clearTimeout(Yo.current),Fn(0),I.length>0?m(""):$n.getChatHistory(st).then(u=>{u.length>0?(ai(u.reverse()),W("revert")):_(y=>(V(y.length+1),[...y,{id:"revert-empty-"+Date.now(),role:"system",text:`\u2726 Nothing to revert to.
|
|
66
|
+
\u2800`,isMeta:!0}]))})),g})}}if(Ge.length>0&&dt==="chat"){if(n.upArrow){he(a=>{let g=a>0?a-1:Ge.length-1,u=0;for(;g!==a&&u<Ge.length;){let y=Ge[g],f=y?.cmd||y||"";if(typeof f=="string"&&f.trimStart().startsWith("---"))g=g>0?g-1:Ge.length-1,u++;else break}return g});return}if(n.downArrow){he(a=>{let g=a<Ge.length-1?a+1:0,u=0;for(;g!==a&&u<Ge.length;){let y=Ge[g],f=y?.cmd||y||"";if(typeof f=="string"&&f.trimStart().startsWith("---"))g=g<Ge.length-1?g+1:0,u++;else break}return g});return}if(n.return)return}if(n.tab&&dt==="chat"){if(Ge.length>0){let a=Ge[le]||Ge[0],g=I.split(" ");if(g.length===1)m(a.cmd+" ");else{let u=g.slice(0,-1);m(u.join(" ")+" "+a.cmd+" ")}he(0),E(u=>u+1);return}else if(I.trim()===""){let a=Date.now();if(a-Te.current<500)return;Te.current=a;let g=["Flux","Flow","ICU","FluxCU"],u=(g.indexOf(D)+1)%g.length,y=g[u>=0?u:0];L(y),y==="Flow"?Xe("Fast"):(y==="Flux"||y==="ICU"||y==="FluxCU")&&Xe("High"),_(f=>[...f,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${Ls(y)}
|
|
67
|
+
\u2800`,isMeta:!0}]);return}}if(n.ctrl&&o==="c"&&dt!=="exit"){if(I.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")?(et(!0),Ne.current=Date.now()):a.includes("\x1B[O")&&(et(!1),Ne.current=Date.now())};return process.stdin.on("data",o),()=>{process.stdout.write("\x1B[?1004l"),process.stdin.off("data",o)}},[]);let dr=Ye(de.theme);Ze(()=>{dr.current&&dr.current!==de.theme?(dr.current=de.theme,s&&(s.write("\x1B[2J\x1B[3J\x1B[H"),s.isTTY&&s.write("\x1B[?2004h")),ts(o=>o+1),bo()):dr.current=de.theme},[de.theme,s]),Ze(()=>{async function o(){try{let B=JSON.parse(at.readFileSync(Et.join(process.cwd(),"package.json"),"utf8"));gs(no||B.version||"2.0.0")}catch{gs("2.0.0")}process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07")),await hl()||(_(B=>(V(B.length+1),[...B,{id:"setup-"+Date.now(),role:"system",text:"\u2726 Installing Required dependencies... (One-time setup)",isMeta:!0}])),await xl(),_(B=>(V(B.length+1),[...B,{id:"setup-done-"+Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m All dependencies installed successfully.
|
|
69
|
+
\u2800`,isMeta:!0}]))),await Si();let n=await ls();Vr.current=n.systemSettings?.allowExternalAccess??!1,jr.current=n.systemSettings?.memory??!0,we.mode?L(we.mode):L(n.mode),k(n.display??0),we.thinking?Xe(we.thinking):Xe(n.thinkingLevel);let a=we.provider||n.aiProvider||"Google";ut(a);let u=(n.quotas?.providerTiers||{})[a]||n.apiTier||"Free";if(pe.current=n.activeModel,we.model)Jt(we.model);else if(we.provider){let B=ao(a,u);Jt(B)}else Jt(n.activeModel);Ro(n.showFullThinking),po(u),Yt(n.quotas||{limitMode:"Daily",agentLimit:99999999,tokenLimit:99999999999999,backgroundLimit:999999,searchLimit:100,customModelId:"",customLimit:0,providerBudgets:{}});let y={memory:!0,compression:0,autoExec:!1,autoDeleteHistory:"7d",autoUpdate:!1,updateManager:"npm",customUpdateCommand:"",...n.systemSettings||{}};we.memory==="on"?y.memory=!0:we.memory==="off"&&(y.memory=!1),a==="NVIDIA"&&process.env.NVIDIA_BASE_URL&&(y.memory=!1,_(B=>[...B,{role:"system",text:`\u2726 MEMORY
|
|
70
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Currently not available.
|
|
71
|
+
\u2800`,isMeta:!0}])),we.package&&(y.updateManager=we.package),we.autoDel&&(y.autoDeleteHistory=we.autoDel),we.autoExec==="on"?y.autoExec=!0:we.autoExec==="off"&&(y.autoExec=!1),we.externalAccess==="on"?y.allowExternalAccess=!0:we.externalAccess==="off"&&(y.allowExternalAccess=!1),we.playground&&(y.allowExternalAccess=!1,y.memory=!1),At(y),_s(n.profileData),er(n.imageSettings||{keyType:"Default",quality:"Low-High",apiKey:""});let f=we.key;if(f||(f=await un(a)),f&&(He(f),Hn(f,{aiProvider:a,onIDEApproval:lr})),n.systemSettings?.autoDeleteHistory&&Fi(n.systemSettings.autoDeleteHistory),Ui(gr),we.playground||(wr(An).catch(()=>{}),at.remove(Et.join(lo,"playground")).catch(()=>{})),te(!1,y),await Promise.all([Ei(),$n.recoverCrashedTransaction()]),we.resume){let B=await Po(),$=we.resume;if(B[$]){Vo.current=!0,sr($);let oe=await br($);Sn.current=qt-oe.total,Mn.current=io,En.current=on,Vo.current=!1,yn(oe.total),Cn(0),vn(0),Ho({tokens:oe.context});let ae=[...B[$].messages];ae[0]?.text?.includes("\u2591\u2591\u2591\u2588\u2588\u2588")||ae.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),_(ae),W("chat"),_(Ce=>{let Oe=[...Ce,{id:"sys-"+Date.now(),role:"system",text:`\u2726 SESSION RESUMED
|
|
72
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m '${$}'.
|
|
73
|
+
\u2800`,isMeta:!0}];return V(Oe.length),Oe})}else _(oe=>[...oe,{id:"sys-err-"+Date.now(),role:"system",text:`\u2726 Chat session [${$}] not found. Started new session.
|
|
74
|
+
\u2800`,isMeta:!0}])}if(we.playground){let B=Et.join(lo,"playground");try{at.ensureDirSync(B),process.chdir(B)}catch{}let $=await Po();if($[An]){let oe=[...$[An].messages];oe[0]?.isLogo||oe.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),_(oe),_(ae=>{let z=[...ae,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND Session restored
|
|
75
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m CWD locked to: '${B}'.
|
|
76
|
+
\u2800`,isMeta:!0}];return V(z.length),z})}else _(oe=>{let ae=[...oe,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND Mode active
|
|
77
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m CWD locked to: 'FluxFlow/playground'.
|
|
78
|
+
\u2800`,isMeta:!0}];return V(ae.length),ae})}let d=Jo();if(!["Terminal","Windows Terminal"].includes(d)){let B=Sl(d);if(B)try{let $=[];if(at.existsSync(B)){let oe=at.readFileSync(B,"utf8").trim();oe&&($=Cl(oe))}Hd($)?Ar="Shift + Enter":W("keybindingsPrompt")}catch{}}_e(!1)}o()},[]),Ze(()=>{let o;return x&&(T(10),o=setInterval(()=>{T(n=>n<=1?(S(!1),0):n-1)},1e3)),()=>{o&&clearInterval(o)}},[x]),Ze(()=>{if(!ge){let o=we.model&&je===we.model?pe.current:je,n=de;we.playground&&(n={...de,allowExternalAccess:Vr.current,memory:jr.current}),Lt({mode:D,thinkingLevel:xe,aiProvider:P,activeModel:o||je,showFullThinking:Zo,systemSettings:n,profileData:bn,imageSettings:Eo,apiTier:rt})}},[D,xe,P,je,Zo,de,bn,Eo,ge,we,rt]);let hi=async o=>{let n=o.trim(),a={Google:{prefix:"AIzaSy",minLength:39},OpenRouter:{prefix:"sk-or-v1-",minLength:73},DeepSeek:{prefix:"sk-",minLength:35},Mistral:{prefix:"",minLength:32},NVIDIA:{prefix:"nvapi-",minLength:70},Ollama:{prefix:"",minLength:0},CrofAI:{prefix:"",minLength:0},InferX:{prefix:"",minLength:0},SenseNova:{prefix:"",minLength:0},AIHubMix:{prefix:"sk-",minLength:10},Poolside:{prefix:"",minLength:0},"9router":{prefix:"",minLength:0},ExpLabs:{prefix:"xpl_",minLength:0}},{prefix:g,minLength:u}=a[P]??{prefix:"",minLength:0},y=(P==="Ollama"||P==="9router")&&(n.trim()==="LOCAL"||n.trim()===""),f=y?"LOCAL":n;if(y||n.startsWith(g)&&n.length>=u){await is(P,f),He(f),Hn(f,{aiProvider:P,onIDEApproval:lr});let d="gemma-4-31b-it";P==="OpenRouter"?d="google/gemma-4-31b-it:free":P==="DeepSeek"?d="deepseek-v4-flash":P==="NVIDIA"?d="deepseek-ai/deepseek-v4-flash":P==="Ollama"||P==="9router"?d=je||"":(P==="CrofAI"||P==="InferX"||P==="SenseNova"||P==="AIHubMix"||P==="Poolside"||P==="ExpLabs")&&(d=ao(P,rt)||""),Jt(d);let w={...de};y&&P==="Ollama"&&(w={...w,ollamaEndpoint:"Local"},At(w)),(P==="Ollama"||P==="CrofAI"||P==="InferX"||P==="SenseNova"||P==="AIHubMix"||P==="Poolside"||P==="9router"||P==="ExpLabs")&&(w={...w,memory:!1},At(w)),Lt({aiProvider:P,activeModel:d,systemSettings:w}),_(B=>[...B,{role:"system",text:`\u2726 ${P} API Key saved successfully! ${d?`
|
|
79
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model set to ${d}.`:""}${y&&P==="Ollama"?`
|
|
80
|
+
\u2726 Ollama Endpoint switched to Local.
|
|
81
|
+
\u2514\u2500\u2800`:`
|
|
82
|
+
|
|
83
|
+
\u2726\u2800`}${P==="Ollama"||P==="CrofAI"||P==="InferX"||P==="SenseNova"||P==="AIHubMix"||P==="Poolside"||P==="9router"||P==="ExpLabs"?`Memory is not available with ${P}.
|
|
84
|
+
\u2514\u2500\u2800`:""}Initialization complete.
|
|
85
|
+
\u2800`,isMeta:!0}])}else _(d=>[...d,{role:"system",text:`\u2726 INVALID KEY
|
|
86
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${P} API key must start with "${g}" and be at least ${u} characters long.`,isMeta:!0}]),ro("")},cr=Ye(Os);Ze(()=>{if(dt==="exit"){(async()=>{let a=Date.now(),g=Math.floor((a-cr.current)/1e3);g>=1&&(await qo("duration",g),cr.current+=g*1e3),await Bi()})();let n=setTimeout(()=>{process.exit(0)},200);return()=>clearTimeout(n)}},[dt]),Ze(()=>{let o=setInterval(async()=>{if(!ge){let n=Date.now(),a=Math.floor((n-cr.current)/1e3);a>=1&&(await qo("duration",a),cr.current+=a*1e3)}},5e3);return()=>clearInterval(o)},[ge]);let xi=[{cmd:"/quit",desc:"Exit and shutdown Flux"},{cmd:"/help",desc:"Show all available commands"},...we.playground?[{cmd:"/move",desc:"Move playground directory to original CWD/playground-export"}]:[],{cmd:"/resume",desc:"Load previous session"},{cmd:"/clear",desc:"Clear terminal screen"},{cmd:"/compress",desc:"Summarize and compress chat history"},{cmd:"/truncate",desc:"Truncate tool results in chat history"},{cmd:"/revert",desc:"Revert codebase back to a checkpoint"},{cmd:"/gemini",desc:"Get a happy message from Gemini CLI"},{cmd:"/save",desc:"Force save current chat"},{cmd:"/export",desc:"Export current chat or error logs",subs:[{cmd:"chat",desc:"Export current active chat"},{cmd:"logs",desc:"Export error logs"}]},{cmd:"/chats",desc:"List all chat sessions"},{cmd:"/btw",desc:"Ask a question without intefering with ongoing tasks"},{cmd:"/thinking",desc:"Set AI reasoning depth",subs:P==="Ollama"||P==="DeepSeek"||P==="ExpLabs"?[{cmd:"Fast",desc:"Reasoning Disabled"},{cmd:"Standard",desc:"Standard Reasoning"},{cmd:"High",desc:"Extended Reasoning"}]:P==="NVIDIA"?[{cmd:"Fast",desc:"Reasoning Disabled"},{cmd:"Standard",desc:"Balanced Reasoning"},{cmd:"High",desc:"Extended Reasoning"}]:P==="OpenRouter"?[{cmd:"Fast",desc:"Fastest"},{cmd:"Low",desc:"Quick Reasoning"},{cmd:"Standard",desc:"Balanced Reasoning"},{cmd:"High",desc:"Deep Reasoning"},{cmd:"xHigh",desc:"Extended Reasoning"}]:P==="Mistral"?[{cmd:"Fast",desc:"Reasoning Disabled"},{cmd:"xHigh",desc:"Deep Reasoning"}]:P==="Poolside"?[{cmd:"Fast",desc:"Reasoning Disabled"},{cmd:"High",desc:"Extended Reasoning"}]:P==="9router"||P==="9Router"?[{cmd:"Fast",desc:"None (Reasoning Disabled)"},{cmd:"Low",desc:"Low Reasoning"},{cmd:"Medium",desc:"Medium Reasoning"},{cmd:"High",desc:"High Reasoning"}]:je&&(je.toLowerCase().startsWith("gemini-3")||P==="CrofAI"||P==="InferX"||P==="SenseNova")?[{cmd:"Fast",desc:"Fastest"},{cmd:"Low",desc:"Quick Reasoning"},{cmd:"Standard",desc:"Balanced Reasoning"},{cmd:"High",desc:"Deep Reasoning"}]:[{cmd:"Fast",desc:"Fastest"},{cmd:"Low",desc:"Quick Reasoning"},{cmd:"Medium",desc:"Balanced Reasoning"},{cmd:"High",desc:"Deep Reasoning"},{cmd:"xHigh",desc:"Extended Reasoning"}]},{cmd:"/model",desc:"Select Agent Model",subs:(P==="Ollama"||P==="9router"||P==="9Router")&&(St==="LOCAL"||!St)?[]:D==="ICU"||D.toLowerCase()==="fluxcu"?Oo(P,rt).filter(o=>ss(o.cmd||o)):Oo(P,rt)},{cmd:"/wildcard-tooling",desc:"Use if the model lacks Tooling Capability"},{cmd:"/provider",desc:"Select AI Provider"},{cmd:"/mode",desc:"Switch execution mode",subs:[{cmd:"flux",display:"workspace",desc:"Workspace, files & terminal tools"},{cmd:"flow",display:"studio",desc:"Creative studio, documents, PDF & conversation"},{cmd:"icu",display:"computer use",desc:"Interactive desktop & OS automation"},{cmd:"fluxcu",display:"omni",desc:"Autonomous tools & desktop execution"}]},{cmd:"/display",desc:"Select Active Display (Computer Use)",subs:[{cmd:"primary",desc:"Primary Display (Display 1)"},{cmd:"secondary",desc:"Secondary Display (Display 2)"}]},{cmd:"/settings",desc:"Configure system prefs"},{cmd:"/theme",desc:"Customize UI color theme"},{cmd:"/key",desc:"Manage API keys"},{cmd:"/files",desc:"List loaded instruction and skill files"},{cmd:"/profile",desc:"Edit developer persona"},{cmd:"/memory",desc:"Manage agent memory"},{cmd:"/stats",desc:"Show session usage"},{cmd:"/usage",desc:"Open graphical token usage & analytics dashboard in browser"},{cmd:"/reset",desc:"Wipe all project data"},{cmd:"/about",desc:"Project info & credits"},{cmd:"/changelog",desc:"View latest updates"},{cmd:"/docs",desc:"View Documentation"},{cmd:"/fluxflow",desc:"Project management",subs:[{cmd:"global",desc:"Opens the Global FluxFlow Directory in File Explorer"},{cmd:"saves",desc:"Opens FluxFlow AppData Directory in File Explorer"}]},{cmd:"/budget",desc:"Set or View budget limits",subs:[{cmd:"view",desc:"View current usage budget bars"},{cmd:"web",desc:"Open graphical usage and budget dashboard in browser"},{cmd:"set",desc:"Configure budgets (Daily/Monthly limits)"},{cmd:"reset",desc:"Reset budgets to default limits"}]},{cmd:"/update",desc:"Check/Install updates",subs:[{cmd:"latest",desc:"Install latest release"},{cmd:"check",desc:"Check for new version"}]}],pi=async(o,n=!1)=>{if(!n&&Ge.length>0){let u=Ge[le]||Ge[0],y=o.split(" ");if(y.length===1)m(u.cmd+" ");else{let f=y.slice(0,-1);m(f.join(" ")+" "+u.cmd+" ")}he(0),E(f=>f+1);return}Zr.current=!1;let a=o.replace(/\r\n/g,`
|
|
87
|
+
`).replace(/\r/g,`
|
|
88
|
+
`).trimEnd();if(a.endsWith("\\")){m(a.slice(0,-1)+`
|
|
89
|
+
`);return}let g=a.replace(/\\\s*\n/g,`
|
|
90
|
+
`).split(/\r?\n/).map(u=>u.replace(/\\$/,"")).join(`
|
|
91
|
+
`);if(g.trim()){if(dn){let u=g.trim();if(u.startsWith("/btw")){if(u.replace(/^\/btw\s*/,"").trim().length<=3){_(f=>(V(f.length+1),[...f,{id:"hint-err-"+Date.now(),role:"system",text:`\u2726 RESTRICTED
|
|
92
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Inquiry question must be more than 3 characters.
|
|
93
|
+
\u2800`,isMeta:!0}])),m("");return}}else if(u.startsWith("/")){_(y=>(V(y.length+1),[...y,{id:"hint-err-"+Date.now(),role:"system",text:`\u2726 RESTRICTED
|
|
94
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Steering Hints cannot start with '/'.
|
|
95
|
+
\u2800`,isMeta:!0}])),m("");return}Rr(u),wo.current=u,m("");return}if(!St){hi(g),ro("");return}if(g.startsWith("/")){m("");let u=g.split(" "),y=u[0]?.toLowerCase();switch(y){case"/quit":{W("exit");break}case"/resume":{if(u[1]){let f=u[1];(async()=>{let w=await Po(),B=w[f]||Object.values(w).find($=>$.name.toLowerCase()===f.toLowerCase());if(B){if(s.write("\x1B[2J\x1B[3J\x1B[H"),process.stdout.isTTY){let z=B?.name||"",Ce=z&&!z.startsWith("flow-")&&!z.startsWith("Session ")?z:"FluxFlow | Resumed";process.stdout.write(`\x1B]0;${Ce}\x07`),process.stdout.write(`\x1B]633;P;TerminalTitle=${Ce}\x07`)}bo(),Vo.current=!0,sr(f);let $=await br(f);Sn.current=qt-$.total,Mn.current=io,En.current=on,Vo.current=!1,yn($.total),Cn(0),vn(0),Ho({tokens:$.context});let oe=[...B.messages];oe[0]?.text?.includes("\u2591\u2591\u2591\u2588\u2588\u2588")||oe.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),_(oe),_(z=>[...z,{id:"sys-"+Date.now(),role:"system",text:`\u2726 SESSION RESUMED
|
|
96
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${f}.
|
|
97
|
+
\u2800`,isMeta:!0}]),V(0)}else _($=>[...$,{id:"err-"+Date.now(),role:"system",text:`\u2726 ERROR: Session [${f}] not found.
|
|
98
|
+
\u2800`,isMeta:!0}])})()}else W("resume");break}case"/move":{if(!we.playground){_(B=>(V(B.length+1),[...B,{id:Date.now(),role:"system",text:`\u2726 RESTRICTED
|
|
99
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m '/move' is only available in playground mode.
|
|
100
|
+
\u2800`,isMeta:!0}]));break}if(!we.originalCwd){_(B=>(V(B.length+1),[...B,{id:Date.now(),role:"system",text:`\u2726 RESTRICTED
|
|
101
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Original CWD not found.
|
|
102
|
+
\u2800`,isMeta:!0}]));break}let f=Et.join(lo,"playground"),d=Et.join(we.originalCwd,"playground-export");(async()=>{try{_($=>(V($.length+1),[...$,{id:Date.now(),role:"system",text:`\u2726 EXPORTING PLAYGROUND CONTENT
|
|
103
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${d}
|
|
104
|
+
`,isMeta:!0}])),await at.ensureDir(d);let B=["node_modules",".git",".venv","venv","env",".next","dist","build",".cache"];await at.copy(f,d,{overwrite:!0,filter:$=>{let oe=Et.relative(f,$);return oe?!oe.split(Et.sep).some(z=>B.includes(z)):!0}}),_($=>(V($.length+1),[...$,{id:Date.now(),role:"system",text:`\u2726 SUCCESS
|
|
105
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m playground content copied to ${d}
|
|
106
|
+
`,isMeta:!0}]))}catch(B){_($=>(V($.length+1),[...$,{id:Date.now(),role:"system",text:`\u2726 FAILED TO MOVE CONTENT
|
|
107
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${B.message}
|
|
108
|
+
`,isMeta:!0}]))}})();break}case"/clear":{if(s&&(s.write("\x1B[2J\x1B[3J\x1B[H"),s.isTTY&&(s.write("\x1B[?2004h"),process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07"))),_([{id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}]),V(1),ts(f=>f+1),bo(),Vt.current={completedIndex:0,columns:X.columns,historicalBlocks:[],seenSelections:new Set,chatId:st,clearKey:jo+1},we.playground){if(we.playground=!1,wr(An).catch(()=>{}),we.originalCwd)try{process.chdir(we.originalCwd),_(f=>{let d=[...f,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND
|
|
109
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Restored Working Directory to ${we.originalCwd}
|
|
110
|
+
\u2800`,isMeta:!0}];return V(d.length),d})}catch{}setTimeout(()=>{at.emptyDir(Et.join(lo,"playground")).catch(f=>{_(d=>{let w=[...d,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND
|
|
111
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Failed to clear session: ${lo+"/playground"}`,isMeta:!0}];return V(w.length),w})})},500),At(f=>({...f,allowExternalAccess:Vr.current,memory:jr.current}))}sr(ms()),Ho({tokens:0}),M(!1),yn(0),Cn(0),vn(0),Sn.current=qt,Mn.current=io,En.current=on,setTimeout(()=>{global.gc&&(async()=>{for(let d=0;d<3;d++)global.gc(),await new Promise(w=>setImmediate(w));h.current=Date.now()})()},500);break}case"/revert":{$n.getChatHistory(st).then(f=>{if(f.length>0)ai(f.reverse()),W("revert");else{let d=Je(2);_(w=>(V(w.length+1),[...w,{id:"revert-empty-"+Date.now(),role:"system",text:`\u2726 Nothing to revert to.
|
|
112
|
+
\u2800`,isMeta:!0}]))}}),setTimeout(()=>{global.gc&&(async()=>{for(let d=0;d<3;d++)global.gc(),await new Promise(w=>setImmediate(w));h.current=Date.now()})()},500);break}case"/mode":{if(u[1]){let f=u[1].toLowerCase(),d="Flux";f==="flow"?d="Flow":f==="icu"?d="ICU":f==="fluxcu"?d="FluxCU":f==="flux"&&(d="Flux"),L(d),d==="Flow"&&Xe("Fast");let w=Je(2);_(B=>(V(B.length+1),[...B,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${Ls(d)}.
|
|
113
|
+
\u2800`,isMeta:!0}]))}else W("mode");break}case"/display":{if(u[1]){let f=u[1].toLowerCase(),d=0;f==="secondary"||f==="1"||f==="2"?d=1:d=0,k(d),Lt({display:d}).catch(()=>{});let w=d===0?"Primary (Display 1)":"Secondary (Display 2)";_(B=>(V(B.length+1),[...B,{id:Date.now(),role:"system",text:`\u2726 Active Computer Use display set to: ${w}.
|
|
114
|
+
\u2800`,isMeta:!0}]))}else W("display");break}case"/image_deprecated":{if(u[1]?.toLowerCase()==="stats"){let f=Je(2);if(Eo.keyType==="Custom")_(d=>(V(d.length+1),[...d,{id:Date.now(),role:"system",text:"[SYSTEM] Key strategy is Custom. Redirecting to Pollinations dashboard (https://enter.pollinations.ai/#pollen)...",isMeta:!0}])),xo("start https://enter.pollinations.ai/#pollen");else try{let d=await Di();_(w=>(V(w.length+1),[...w,{id:Date.now(),role:"system",isImageStats:!0,text:`\u2022 Hourly Limit: ${Number((d.limit*1e3).toFixed(0))} credits
|
|
115
|
+
\u2022 Spent (Last 1hr): ${Number((d.totalSpent*1e3).toFixed(0))} credits
|
|
116
|
+
\u2022 Remaining: ${Number((d.remaining*1e3).toFixed(0))} credits
|
|
117
|
+
\u2022 Requests (Last 1hr): ${d.activeCallsCount} requests
|
|
118
|
+
`+(d.nextResetMin>0?`\u2022 Refreshes in: ${d.nextResetMin}m`:""),isMeta:!0}]))}catch{_(w=>(V(w.length+1),[...w,{id:Date.now(),role:"system",text:"[SYSTEM] Failed to load image quota stats.",isMeta:!0}]))}}else if(u[1]?.toLowerCase()==="setup")if(u[2]?.toLowerCase()==="key")if(u[3]){let f=["default","custom"].find(d=>d===u[3].toLowerCase());if(f){let d=f==="default"?"Default":"Custom";er(B=>({...B,keyType:d}));let w=Je(2);_(B=>(V(B.length+1),[...B,{id:Date.now(),role:"system",text:`[SYSTEM] Image key strategy set to ${d}`,isMeta:!0}])),d==="Custom"&&(_t({label:"Enter Pollinations API key (starting with sk_):",note:"Get a key from https://enter.pollinations.ai",key:"imageSettings",subKey:"apiKey",value:Eo.apiKey||"",returnView:"chat"}),W("input"))}else{let d=Je(2);_(w=>(V(w.length+1),[...w,{id:Date.now(),role:"system",text:"[SYSTEM] Invalid key option. Choose: Default or Custom.",isMeta:!0}]))}}else{let f=Je(2);_(d=>(V(d.length+1),[...d,{id:Date.now(),role:"system",text:"[SYSTEM] Usage: /image setup Key <Default|Custom>",isMeta:!0}]))}else if(u[2]?.toLowerCase()==="quality")if(u[3]){let f=["low","low-high","medium","medium-high","high","ultra","premium"].find(d=>d===u[3].toLowerCase());if(f){let w={low:"Low","low-high":"Low-High",medium:"Medium","medium-high":"Medium-High",high:"High",ultra:"Ultra",premium:"Premium"}[f];er($=>({...$,quality:w}));let B=Je(2);_($=>(V($.length+1),[...$,{id:Date.now(),role:"system",text:`[SYSTEM] Image quality set to ${w}`,isMeta:!0}]))}else{let d=Je(2);_(w=>(V(w.length+1),[...w,{id:Date.now(),role:"system",text:"[SYSTEM] Invalid quality level. Choose from: Low, Low-High, Medium, Medium-High, High, Ultra, Premium.",isMeta:!0}]))}}else{let f=Je(2);_(d=>(V(d.length+1),[...d,{id:Date.now(),role:"system",text:"[SYSTEM] Usage: /image setup Quality <Low|Low-High|Medium|Medium-High|High|Ultra>",isMeta:!0}]))}else{let f=Je(2);_(d=>(V(d.length+1),[...d,{id:Date.now(),role:"system",text:"[SYSTEM] Usage: /image setup <Key|Quality> ...",isMeta:!0}]))}else{let f=Je(2);_(d=>(V(d.length+1),[...d,{id:Date.now(),role:"system",text:"[SYSTEM] Usage: /image setup <Key|Quality> ...",isMeta:!0}]))}break}case"/thinking":{let f;if(u[1]){let d=u[1].toLowerCase(),w=u.includes("--bypass"),B=u.includes("--force");f=d.charAt(0).toUpperCase()+d.slice(1),d==="xhigh"&&(f="xHigh");let $="";if(B&&(process.env.NVIDIA_BASE_URL,$=`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Enabled Forced Reasoning.
|
|
119
|
+
\u2800`,process.env.forcedReasoning="true"),!w&&D==="Flow"&&f==="xHigh")_(oe=>(V(oe.length+1),[...oe,{id:Date.now(),role:"system",text:`\u2726 RESTRICTED
|
|
120
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m"${f}" is restricted in Flow mode. Switch to Flux to enable Higher Thinking Levels.
|
|
121
|
+
\u2800${$}.`,isMeta:!0}]));else{Xe(f);let oe=Je(1);_(ae=>(V(ae.length+1),[...ae,{id:Date.now(),role:"system",text:`\u2726 ${P}
|
|
122
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${je}.
|
|
123
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Thinking Level: ${f}.
|
|
124
|
+
${$} \u2800`,isMeta:!0}]))}}else W("thinking");break}case"/model":{if(u[1]){let f=u.slice(1),d=!1,w=[];for(let $ of f)$==="--multimodal"||$==="-m"?d=!0:w.push($);let B=w.join(" ");if(Ci(d),B){let $=ao("Google","Free"),oe=ao("Google","Paid");{Jt(B);let ae=d||ss(B);_(z=>(V(z.length+1),[...z,{id:Date.now(),role:"system",text:`\u2726 ${P}
|
|
125
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${B}
|
|
126
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Thinking Level: ${xe}
|
|
127
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Multimodal: ${ae?"ON":"OFF"}
|
|
128
|
+
\u2800`,isMeta:!0}]))}}}else W("model");break}case"/wildcard-tooling":{se(f=>{let d=!f;return _(w=>(V(w.length+1),[...w,{id:Date.now(),role:"system",text:`\u2726 Wildcard Tooling:
|
|
129
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Status: ${d?"Enabled":"Disabled"}
|
|
130
|
+
\u2800`,isMeta:!0}])),d});break}case"/settings":{W("settings");break}case"/provider":case"/providers":{Pr("chat"),W("selectProvider");break}case"/theme":{W("theme");break}case"/key":{W("key");break}case"/profile":{W("profile");break}case"/stats":{(async()=>{let d=await hr(),w=await xr();$r(d),Hr(w),Dn("daily"),W("stats")})();break}case"/usage":{(async()=>{try{let{url:d}=await ds();_(w=>(V(w.length+1),[...w,{id:Date.now(),role:"system",text:`\u2726 Launching Token Analytics Dashboard
|
|
131
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Serving at ${d}
|
|
132
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Opening in your default browser...
|
|
133
|
+
\u2800`,isMeta:!0}]))}catch(d){_(w=>(V(w.length+1),[...w,{id:Date.now(),role:"system",text:`\u2726 ERROR
|
|
134
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Failed to launch dashboard: ${d.message}
|
|
135
|
+
\u2800`,isMeta:!0}]))}})();break}case"/save":{let f,d=pt.find(B=>B.role==="user");if(d&&d.text){let B=d.text.replace(/\s*\n+\s*\[Prompted on:.*?\]/g,"").trim(),$=B.split(/\s+/),oe;$.length>7?oe=$.slice(0,7).join(" ")+"...":B.length>45?oe=B.substring(0,45).trimEnd()+"...":oe=B,f=oe}let w=u.slice(1).join(" ")||f||`Session ${new Date().toLocaleTimeString()}`;gn(st,w,pt),_(B=>(V(B.length+1),[...B,{id:Date.now(),role:"system",text:`\u2726 Saved
|
|
136
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m "${w}" (ID: ${st})
|
|
137
|
+
\u2800`,isMeta:!0}]));break}case"/export":{(async()=>{try{let d=await Ii(u,{chatId:st,messages:pt});_(w=>(V(w.length+1),[...w,{id:Date.now(),role:"system",text:d.message,isMeta:!0}]))}catch(d){_(w=>(V(w.length+1),[...w,{id:Date.now(),role:"system",text:`[EXPORT ERROR] Failed to export: ${d.message}`,isMeta:!0}]))}})();break}case"/chats":{(async()=>{let d=await Po(),w=Object.entries(d).sort((B,$)=>($[1].updatedAt||0)-(B[1].updatedAt||0)).map(([B,$])=>`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${B}: ${$.name}${B===st?" (current)":""}`).join(`
|
|
138
|
+
`);_(B=>(V(B.length+1),[...B,{id:Date.now(),role:"system",text:`\u2726 Saved Chats:
|
|
139
|
+
${w||"\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No saved chats found."}
|
|
140
|
+
\u2800`,isMeta:!0}]))})();break}case"/memory":{W("memory");break}case"/files":{_(f=>(V(f.length+1),[...f,{id:"files-"+Date.now(),role:"system",text:Ni(),isMeta:!0}]));break}case"/reset":{(async()=>{try{_(d=>(V(d.length+1),[...d,{id:Date.now(),role:"system",text:`\u2726 Initiating reset...
|
|
141
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Clearing logs, secrets, and settings.
|
|
142
|
+
\u2800`,isMeta:!0}])),at.existsSync(gr)&&at.removeSync(gr),at.existsSync(ns)&&at.removeSync(ns),at.existsSync(Ko)&&at.removeSync(Ko);try{at.readdirSync(Lo).length===0&&at.removeSync(Lo)}catch{}setTimeout(()=>{W("exit"),setTimeout(()=>process.exit(0),500)},500)}catch(d){_(w=>(V(w.length+1),[...w,{id:Date.now(),role:"system",text:`\u2726 ERROR
|
|
143
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Failed to clear data: ${d.message}.
|
|
144
|
+
\u2800`}]))}})();break}case"/about":{let f=Je(2),d=`\u2022 FluxFlow Version: v${no}
|
|
145
|
+
\u2022 Status: ${Wt&&Wt!==no?`Update Available [v${Wt}]`:"Up to date"}
|
|
146
|
+
\u2022 Released on: ${Yd}`;_(w=>(V(w.length+1),[...w,{id:"about-"+Date.now(),role:"system",text:d,isAboutRecord:!0,isMeta:!0}]));break}case"/changelog":{let f=process.platform;xo(`${f==="win32"?"start":f==="darwin"?"open":"xdg-open"} ${Ml}`),_(w=>(V(w.length+1),[...w,{id:Date.now(),role:"system",text:`\u2726 Opening Changelog
|
|
147
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${Ml}.`,isMeta:!0}]));break}case"/docs":{if(!Ps){_(w=>(V(w.length+1),[...w,{id:Date.now(),role:"system",text:`\u2726 ERROR
|
|
148
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Documentation URL is not configured.`,isMeta:!0}]));break}let f=process.platform;xo(`${f==="win32"?"start":f==="darwin"?"open":"xdg-open"} ${Ps}`),_(w=>(V(w.length+1),[...w,{id:Date.now(),role:"system",text:`\u2726 Opening Documentation
|
|
149
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${Ps}.
|
|
150
|
+
\u2800`,isMeta:!0}]));break}case"/budget":{let f=u[1]?.toLowerCase();if(f==="web"||f==="gui"||f==="dashboard")(async()=>{try{let{url:w}=await ds();_(B=>(V(B.length+1),[...B,{id:Date.now(),role:"system",text:`\u2726 Token Usage & Budget Dashboard
|
|
151
|
+
\u2800\u2800\u2514\u2500 Opened at ${w}
|
|
152
|
+
\u2800`,isMeta:!0}]))}catch(w){_(B=>(V(B.length+1),[...B,{id:Date.now(),role:"system",text:`\u2726 ERROR: Failed to launch dashboard: ${w.message}
|
|
153
|
+
\u2800`,isMeta:!0}]))}})();else if(f==="set")Bl("chat"),W("budgetTypeSelect");else if(f==="view")(async()=>{let w=await hr(),B=await xr(),$=await as(Ue.resetDay||1);$r(w),Hr(B),Qs($),W("budgetView")})();else if(f==="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",ExpLabs:"Free"}};Yt(d),po("Free"),Lt({apiTier:"Free",quotas:d}),_(w=>(V(w.length+1),[...w,{id:Date.now(),role:"system",text:`\u2726 Budgets reset successfully.
|
|
154
|
+
\u2800`,isMeta:!0}]))}else _(d=>(V(d.length+1),[...d,{id:Date.now(),role:"system",text:`\u2726 ERROR
|
|
155
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Usage: /budget <View|Web|Set|Reset>.
|
|
156
|
+
\u2800`,isMeta:!0}]));break}case"/fluxflow":{let d=u.slice(1)[0]?.toLowerCase()?.trim();if(d==="global"){let w=Et.normalize(Lo);try{at.ensureDirSync(w)}catch{}let B=process.platform;B==="win32"?xo(`explorer "${w}"`):B==="darwin"?xo(`open "${w}"`):xo(`xdg-open "${w}"`)}else if(d==="saves"){let w=Et.normalize(lo);try{at.ensureDirSync(w)}catch{w=Et.normalize(Lo);try{at.ensureDirSync(w)}catch{}}let B=process.platform;B==="win32"?xo(`explorer "${w}"`):B==="darwin"?xo(`open "${w}"`):xo(`xdg-open "${w}"`)}else _(w=>(V(w.length+1),[...w,{id:"ff-err-"+Date.now(),role:"system",text:"Usage: /fluxflow global/saves",isMeta:!0}]));break}case"/update":{if(u[1]?.toLowerCase()==="check"){te(!0);break}let d=u.includes("--latest");W("update");break}case"/gemini":{let f=Is[Math.floor(Math.random()*Is.length)];_(d=>(V(d.length+1),[...d,{id:Date.now(),role:"system",text:`\u2728 GEMINI CLI
|
|
157
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${f}
|
|
158
|
+
\u2800`}])),m("");break}case"/compress":{m("");let f=pt.filter(B=>(B.role==="user"||B.role==="agent"||B.role==="system")&&!String(B.id).startsWith("welcome")&&!B.isMeta).length,d=so?.tokens||0;if(f<64||d<16384){let B=Je(2);_($=>(V($.length+1),[...$,{id:Date.now(),role:"system",text:`\u2726 Compression skipped
|
|
159
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m History requires at least 64 messages and 16k tokens
|
|
160
|
+
\u2800\u2800 \u2514\u2500 Current: ${f}/64 msgs, ${d}/16384 tokens.
|
|
161
|
+
\u2800`,isMeta:!0}]));break}(async()=>{si(!0);let B=Je(2);_($=>(V($.length+1),[...$,{id:Date.now(),role:"system",text:"\u2726 Compacting session history...",isMeta:!0}]));try{if(await ji({chatId:st,aiProvider:P,apiKey:St,thinkingLevel:xe,mode:D,janitorModel:b,systemSettings:de,sessionStats:so},pt)){let ae=Je(2);_(z=>{let Ce=[...z,{id:Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Chat History compacted saving tokens.
|
|
162
|
+
\u2800`,isMeta:!0}];return V(Ce.length),Ce})}else _(ae=>(V(ae.length+1),[...ae,{id:Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Compaction failed.
|
|
163
|
+
\u2800`,isMeta:!0}]))}catch($){_(oe=>(V(oe.length+1),[...oe,{id:Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Error during compaction: ${$.message}
|
|
164
|
+
\u2800`,isMeta:!0}]))}finally{si(!1)}})();break}case"/truncate":{m("");let f=0;_(d=>{let B=[...d.map($=>{let oe=$.fullText||$.text||"";return!oe.startsWith("[TOOL RESULT]:")||oe.startsWith("[TOOL RESULT]: ERROR")||oe.startsWith("[TOOL RESULT]: DENIED")||oe.startsWith("[TOOL RESULT]: SUCCESS: Goal")||oe.includes("...Results Truncated by System on User Command")?$:(f++,{...$,fullText:"[TOOL RESULT]: ...Results Truncated by System on User Command"})}),{id:Date.now(),role:"system",text:`\u2726 Tool Truncation...
|
|
165
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Truncated ${f} tool result(s).
|
|
166
|
+
\u2800`,isMeta:!0}];return gn(st,null,B),V(B.length),B});break}case"/help":{_(f=>(V(f.length+1),[...f,{id:Date.now(),role:"system",isHelpRecord:!0,isMeta:!0}]));break}case"/btw":{_(f=>(V(f.length+1),[...f,{id:Date.now(),role:"system",text:`\u2726 RESTRICTED
|
|
167
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m '/btw' only available when agent is working
|
|
168
|
+
\u2800`,isMeta:!0}]));break}default:_(f=>(V(f.length+1),[...f,{id:Date.now(),role:"system",text:`\u2726 ERROR
|
|
169
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Unknown command: '${y}'
|
|
170
|
+
\u2800`,isMeta:!0}]))}}else{let u=`[Prompted on: ${new Date().toLocaleString(void 0,{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}]`,y={id:"user-"+Date.now(),role:"user",text:`${g}
|
|
171
|
+
|
|
172
|
+
${u}`};_(d=>(V(d.length+1),[...d,y])),(async()=>{let d=!1,w=()=>{d||(d=!0,_(ae=>{let z=ae[ae.length-1];if(z&&z.text&&z.text.includes("Request Cancelled"))return ae;let Oe=[...ae.map(Z=>Z.isStreaming?{...Z,isStreaming:!1}:Z),{id:"cancel-"+Date.now(),role:"agent",text:`
|
|
173
|
+
|
|
174
|
+
\x1B[33m\u24D8 Request Cancelled\x1B[0m`,isMeta:!1}];return V(Oe.length),Oe}))},B=!1;Jr(!0),_r(Date.now()),M(!1);let $=Date.now(),oe=!0;try{let ae=[...pt,y].filter(U=>U.role!=="think"&&!U.isVisualFeedback&&!U.isMeta&&!U.isTerminalRecord&&!(U.text&&U.text.includes("[TERMINAL_RECORD]"))&&!String(U.id).startsWith("welcome")),z=[],Ce=ae.map((U,be)=>{let Ie=U.fullText||U.text||"";if(U.role==="user"&&be<ae.length-1)if(Ie.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")){let ke=Ie.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");if(ke!==-1){let Ve=Ie.substring(0,ke).lastIndexOf("[SYSTEM METADATA]");Ve!==-1?Ie=Ie.substring(Ve).trim():Ie=Ie.substring(ke).trim()}}else{let ke=Ie.lastIndexOf("[USER]"),lt=Ie.lastIndexOf("[USER PROMPT]");ke!==-1?Ie=Ie.substring(ke+6).trim():lt!==-1&&(Ie=Ie.substring(lt).trim())}return{...U,text:Ie}}),Oe=0;for(;Oe<Ce.length;){let U=Ce[Oe];if(U.role==="user")z.push(U),Oe++;else{let be=[];for(;Oe<Ce.length&&Ce[Oe].role!=="user";)be.push(Ce[Oe]),Oe++;let Ie=[],ke=[],lt=null,Ve=!1,Xt=()=>{Ie.length>0&&(z.push({role:"agent",text:Ie.join(`
|
|
175
|
+
`).trim()}),Ie=[]),ke.length>0&&(z.push({role:"system",text:ke.join(`
|
|
176
|
+
|
|
177
|
+
`),...lt?{binaryPart:lt}:{}}),ke=[],lt=null),Ve=!1};be.forEach(Ct=>{let ce=Ct.role==="system"&&(Ct.text?.startsWith("[TOOL RESULT]")||Ct.text?.startsWith("SUCCESS:")||Ct.text?.startsWith("ERROR:")||Ct.fullText?.startsWith("[TOOL RESULT]")||Ct.fullText?.startsWith("SUCCESS:")||Ct.fullText?.startsWith("ERROR:")),fe=Ct.fullText||Ct.text||"",Ee=fe.trim();if(!(!Ee&&!Ct.binaryPart)){if(ce){let We=Ee.startsWith("[TOOL RESULT]")?Ee:`[TOOL RESULT]: ${Ee}`;ke.push(We),Ct.binaryPart&&(lt=Ct.binaryPart)}else if(Ct.role==="agent"){!Ve&&ke.length>0&&Xt();let We=fe.endsWith(`
|
|
178
|
+
`),Qe=Ee.toLowerCase().includes("tool:functions.")||Ee.toLowerCase().includes("agent:generalist.");Ie.push(Ee),Qe&&We?Ve=!0:Ve=!1}}}),Xt()}}let Z=qi(je,z,{profile:bn,thinkingLevel:xe,mode:D,systemSettings:de,janitorModel:b,sessionStats:so,chatId:st,isPlayground:!!we.playground,aiProvider:P,apiKey:St,apiTier:rt,wildcardTooling:ye,cols:X.columns-6,rows:30,onTokenChunk:(U,be)=>{let Ie=Date.now();if(_r(Ie),typeof be=="number"){$s.current=be;let ke=Xr.current;ke.startTime||(ke.startTime=Ie,ke.totalWords=0,ke.chunks=[]),ke.totalWords+=be,ke.chunks||(ke.chunks=[]),ke.chunks.push({time:Ie,words:be});let Ve=Ie-400;if(ke.chunks=ke.chunks.filter(Xt=>Xt.time>=Ve),ke.chunks.length>0){let Xt=ke.chunks.reduce((fe,Ee)=>fe+Ee.words,0),Ct=ke.chunks[0].time,ce=Math.max(.4,(Ie-Ct)/1e3);ke.wps=Math.round(Xt/ce*10)/10}}},onVisualFeedback:U=>{_(be=>[...be.map(ke=>ke.isStreaming?{...ke,isStreaming:!1}:ke),{id:"visual-"+Date.now()+"-"+Math.random().toString(36).substring(2,9),role:"system",text:U,isVisualFeedback:!0}])},onSubagentUpdate:()=>{Gl(Wi.map(U=>({...U})))},onExecStart:U=>{ve(),ie(),zs(U),ln("")},onExecChunk:U=>{ln(be=>be+U)},onExecEnd:()=>{_(U=>{if(!ir.current)return U;let be=Kr.current||"",Ie=Oi(be),ke=`[TERMINAL_RECORD]
|
|
179
|
+
COMMAND: ${ir.current}
|
|
180
|
+
PTY: ${mn}
|
|
181
|
+
OUTPUT: ${Ie.replace(/\n{3,}/g,`
|
|
182
|
+
|
|
183
|
+
`)}`,Ve=[...U.map(Xt=>Xt.isStreaming?{...Xt,isStreaming:!1}:Xt),{id:"term-"+Date.now(),role:"system",text:ke,isTerminalRecord:!0}];return V(Ve.length),Ve}),zs(null),Js(!1),ln(""),ir.current=null,Kr.current=""},onToolResult:(U,be)=>{if(U==="success"){if(Pl(Ie=>Ie+1),be==="generate_image"){Xl(lt=>lt+1);let ke={Low:.001,"Low-High":.002,Medium:.008,"Medium-High":.01,High:.045,Ultra:.0488,Premium:.1}[Eo.quality]||.002;$l(lt=>lt+ke)}}else U==="denied"?Fl(Ie=>Ie+1):Nl(Ie=>Ie+1)},onToolApproval:async(U,be)=>{let Ie=Yl||de.autoExec;if(U==="exec_command"){let{command:ke}=Xn(be||"{}");return Ie||ke&&/^(echo|ls|dir|pwd|cd|git status|git log|git diff|type|cat|help)\b/i.test(ke.trim())?"allow":new Promise(Ve=>{an({tool:U,args:be,resolve:Ve}),W("terminalApproval")})}return Ie?"allow":new Promise(ke=>{an({tool:U,args:be,resolve:ke}),W("approval")})},onAskUser:async(U,be)=>(ve(),ie(),new Promise(Ie=>{let ke=!1;qr({question:U,options:be,resolve:lt=>{ke||(ke=!0,_(Ve=>{if(Ve.some(ce=>ce.isAskRecord&&ce.text?.includes(`Selection: ${lt}`)))return Ve;let Ct=[...Ve,{id:"ask-"+Date.now(),role:"system",text:`\u{1F4AC} **Ask User**
|
|
184
|
+
Question: ${U}
|
|
185
|
+
Selection: ${lt}`,isAskRecord:!0}];return V(Ct.length),Ct}),Ie(lt))}}),W("ask")})),onUsage:U=>{let be=U.totalTokenCount||0,Ie=U.cachedContentTokenCount||0,ke=U.candidatesTokenCount||0,lt=Math.max(0,be-ke);Ho({tokens:be}),Ys(Ve=>Ve+be),lt>0&&Vs(Ve=>Ve+lt),Ie>0&&js(Ve=>Ve+Ie),ke>0&&Ks(Ve=>Ve+ke),Gs(Ve=>Ve+1)}},async()=>wo.current?wo.current:null,no),R=!1,it=null,Pe=null,Fe=!1,tt=!1,Tt=!1,ot=!1,nt=0,Bt=null,Io=/\[?\s*turn\s*:\s*.*?\s*\]?/gi;for await(let U of Z){if(await new Promise(ce=>setTimeout(ce,3)),U.type==="text"&&_r(Date.now()),oe&&U.type==="text"&&($=Date.now(),oe=!1,de.progressiveRendering&&Me()),U.type==="status"){if(U.content&&(U.content.includes("Steering Hint Injected")||U.content.includes("Question Forwarded"))){let ce=wo.current;ce&&(_(fe=>{V(fe.length+1);let Ee=ce.startsWith("/btw"),We=Ee?ce.replace(/^\/btw\s*/,""):ce,Qe=Ee?"[QUESTION]":"[STEERING HINT]";return[...fe,{id:"hint-"+Date.now(),role:"user",text:`${Qe}
|
|
186
|
+
${We}`,color:"cyan",isSteeringHint:!0,hintType:Ee?"QUESTION":"STEERING HINT",hintContent:We}]}),Rr(null),wo.current=null)}U.content?.includes("[start]")||Qr(U.content),U.content?.includes("[start]")?(clearInterval(Nn),Pn(0),Nn=setInterval(()=>{Pn(ce=>ce+1)},1e3)):U.content?.includes("[end]")&&(Pn(0),clearInterval(Nn)),Qo()&&yr(U.content),U.content==="Request Cancelled"&&(ve(),ie(),w());continue}if(U.type==="status_history"){Qr(U.content),Qo()&&yr(U.content),_(ce=>[...ce,{id:"condense-"+Date.now(),role:"system",text:`\u2726 ${U.content}
|
|
187
|
+
\u2800`,isMeta:!0}]);continue}if(U.type==="summary_injected"){_(ce=>ce.map(fe=>fe.id===U.content.id?{...fe,fullText:U.content.text}:fe));continue}if(U.type==="spinner"){ql(U.content);continue}if(U.type==="model_update"){Rl(U.content);continue}if(U.type==="turn_reset"){if(ve(),ie(),it=null,Pe=null,R=!1,Fe=!1,tt=!1,ot=!1,Tt=!1,_(ce=>{let fe=ce.map(Ee=>{if(Ee.isStreaming){let We=Ee.text?vt(Ee.text):Ee.text,Qe=Ee.fullText?vt(Ee.fullText):Ee.fullText;return{...Ee,isStreaming:!1,text:We,fullText:Qe}}return Ee});return V(fe.length),fe}),bo(),global.gc){for(let ce=0;ce<2;ce++)global.gc(),await new Promise(fe=>setImmediate(fe));h.current=Date.now()}continue}if(U.type==="interactive_turn_finished"){Jr(!1),Pn(0),clearInterval(Nn),Qo()&&yr(null),B=!0,bo(),de?.autoTruncateResults&&_(ce=>{let fe=ce.map(Ee=>{let We=Ee.fullText||Ee.text||"";return!We.startsWith("[TOOL RESULT]:")||Ee.toolName&&String(Ee.toolName).toLowerCase()==="search_keyword"||We.startsWith("[TOOL RESULT]: ERROR")||We.startsWith("[TOOL RESULT]: DENIED")||We.startsWith("[TOOL RESULT]: SUCCESS: Goal")||We.includes("...Results Truncated by System on User Command")||We.startsWith("[TOOL RESULT]: Skill:")||We.includes("Skill: [")||We.startsWith("[TOOL RESULT]: DOCs:")||We.includes("DOCs: [")?Ee:{...Ee,fullText:"[TOOL RESULT]: ...Results Truncated by System on User Command"}});return gn(st,null,fe),V(fe.length),fe}),Vi({profile:bn,thinkingLevel:xe,mode:D,janitorModel:b,chatId:st,systemSettings:de,sessionStats:so,aiProvider:P,apiKey:St},U.data.agentText,U.data.fullAgentTextRaw,U.data.history,{onMemoryUpdated:()=>_(ce=>{let fe=[...ce];return fe.length>0&&(fe[fe.length-1].memoryUpdated=!0),fe}),onBackgroundIncrement:()=>kl(ce=>ce+1)});continue}if(U.type==="visual_feedback"){ve(),ie(),_(ce=>{let fe=[...ce,{id:"feedback-"+Date.now()+"-"+Math.random().toString(36).substring(2,9),role:"system",text:vt(U.content),isVisualFeedback:!0}];return V(fe.length),fe});continue}if(U.type==="exec_start"){ve(),ie();continue}if(U.type==="liveTokens"){Ho({tokens:U.content});continue}if(U.type==="usage"){let ce=U.content.totalTokenCount||0,fe=U.content.cachedContentTokenCount||0,Ee=U.content.candidatesTokenCount||0,We=Math.max(0,ce-Ee);Ho({tokens:ce}),Ys(Qe=>Qe+ce),We>0&&Vs(Qe=>Qe+We),fe>0&&js(Qe=>Qe+fe),Ee>0&&Ks(Qe=>Qe+Ee),Gs(Qe=>Qe+1);continue}if(U.type==="tool_time"){_l(ce=>ce+U.content);continue}if(U.type==="tool_result"){if(ie(),it=null,Pe=null,R=!1,Fe=!1,tt=!1,ot=!1,Tt=!1,nt=0,Bt=null,_(ce=>{let fe=[...ce,{id:"tool-"+Date.now()+"-"+Math.random().toString(36).substring(2,7),role:"system",text:vt(U.content),fullText:vt(U.aiContent),binaryPart:U.binaryPart,toolName:U.toolName}];return V(fe.length),fe}),U.toolName==="update_file"&&U.aiContent){let ce=U.aiContent.split(`
|
|
188
|
+
`),fe=0,Ee=0,We=!1;for(let Qe of ce){if(Qe.includes("[DIFF_START]")){We=!0;continue}if(Qe.includes("[DIFF_END]")){We=!1;continue}We&&(/^\+\d+/.test(Qe)?fe++:/^\-\d+/.test(Qe)&&Ee++)}qo("linesAdded",fe),qo("linesRemoved",Ee)}else if(U.toolName==="write_file"&&U.aiContent){let ce=U.aiContent.match(/- Stats: \[(\d+) lines/),fe=ce?parseInt(ce[1]):0,Ee=0;if(U.aiContent.includes("Old File contents:")){let We=U.aiContent.split(`
|
|
189
|
+
`),Qe=!1;for(let Ao of We){if(Ao.includes("Old File contents:")){Qe=!0;continue}Qe&&(Ao.trim()===""?Qe=!1:/^\d+ \|/.test(Ao)&&Ee++)}}qo("linesAdded",fe),qo("linesRemoved",Ee)}continue}let be=U.content;if(U.type==="text"&&be.includes("Request Cancelled")){if(global.gc){for(let ce=0;ce<3;ce++)global.gc(),await new Promise(fe=>setImmediate(fe));h.current=Date.now()}continue}let Ie=be.toLowerCase();if(be.includes("```")&&(Fe=!Fe),(Ie.includes("tool:functions.")||Ie.includes("agent:generalist."))&&(tt=!0,nt=0,Bt=null,(be.includes("[tool:functions.")||be.includes("[agent:generalist."))&&(nt=0)),tt){for(let ce=0;ce<be.length;ce++){let fe=be[ce];!Bt&&(fe==="'"||fe==='"'||fe==="`")?Bt=fe:Bt&&fe===Bt&&be[ce-1]!=="\\"&&(Bt=null),Bt||(fe==="("||fe==="["?nt++:(fe===")"||fe==="]")&&nt--)}nt<=0&&!Bt&&(tt=!1)}let ke=/^\s*(?:<(think|thought|thoughts)[^>]*>|<\|channel>thought|\[(think|thought|thoughts)\])/i,lt=(ce,fe)=>{let Ee=!1;for(let We=0;We<fe;We++)ce[We]==="`"&&(Ee=!Ee);return Ee},Ve=ce=>{let fe=/(?:<\/(think|thought|thoughts)>|<channel\|>|\[\/(think|thought|thoughts)\])/gi,Ee;for(;(Ee=fe.exec(ce))!==null;)if(!lt(ce,Ee.index))return{index:Ee.index,length:Ee[0].length};return{index:-1,length:0}},Xt=Y.current?.role==="agent"&&Y.current.text||"",Ct=!Tt&&Xt.trim().length===0;if(!R&&Ct&&(ke.test(be)||ke.test(Xt+be))){let ce=ke.test(be)?be:Xt+be,fe=ce.match(ke),Ee=fe.index,We=fe[0].length,Qe=ce.substring(Ee+We);ve(),Y.current=null,R=!0,Tt=!0,it="think-"+Date.now(),Y.current={id:it,role:"think",text:"",isStreaming:!0,startTime:Date.now()};let Ao=Ve(Qe);if(Ao.index!==-1){let ra=Qe.substring(0,Ao.index).replace(/^\r?\n+/,"").replace(/\r?\n+$/,""),wi=Qe.substring(Ao.index+Ao.length);Y.current.text=vt(ra);let sa=Y.current.startTime||Date.now();Y.current.duration=Date.now()-sa,ie(),R=!1,Pe="agent-"+Date.now(),Y.current={id:Pe,role:"agent",text:"",isStreaming:!0},wi&&qe(wi)}else{let os=Qe.replace(/^\r?\n+/,"");os&&qe(os)}continue}if(!R&&!Tt&&be.trim().length>0&&(Tt=!0),R&&Y.current?.role==="think"){ve();let ce=Y.current.text+be,fe=Ve(ce);if(fe.index!==-1){let Ee=ce.substring(0,fe.index),We=ce.substring(fe.index+fe.length);Y.current.text=vt(Ee);let Qe=Y.current.startTime||Date.now();Y.current.duration=Date.now()-Qe,ie(),R=!1,Pe="agent-"+Date.now(),Y.current={id:Pe,role:"agent",text:"",isStreaming:!0},We&&qe(We)}else qe(be);continue}else if(!R){let ce=be.toLowerCase();!ot&&(ce.includes("tool:functions.")||ce.includes("agent:generalist."))&&(ot=!0),!Y.current||Y.current.role!=="agent"?(Pe="agent-"+Date.now(),Y.current={id:Pe,role:"agent",text:vt(be),isStreaming:!0},ne()):qe(be)}}let ko=Date.now();Ul(U=>U+(ko-$))}catch(ae){_(z=>(V(z.length+1),[...z,{id:"error-"+Date.now(),role:"system",text:`\u274C ERROR: ${ae.message}`}]))}finally{let ae=Date.now()-$;if(Y.current&&(Y.current.workedDuration=ae),ue.current&&(await ze(),clearInterval(ue.current),ue.current=null),Jr(!1),Qr(null),Pn(0),clearInterval(Nn),ie(),Zr.current&&w(),bo(),global.gc)try{for(let z=0;z<3;z++)global.gc(),await new Promise(Ce=>setImmediate(Ce));h.current=Date.now()}catch{}if(B||process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow | Idle\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow | Idle\x07")),wo.current){es(wo.current),Rr(null);let z=wo.current;wo.current=null,_(Ce=>{let Oe=[...Ce],Z=Oe.reverse().find(R=>R.text?.includes("[STEERING HINT: QUEUED]")||R.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]"))),Oe.reverse()}),W("resolution")}_(z=>{let Ce=Date.now()-$,Oe=!1,Z=[...z].reverse().map(Pe=>{let Fe=Pe.isStreaming?{...Pe,isStreaming:!1}:Pe;return Fe.text&&(Fe.text=(" "+Fe.text).slice(1)),!Oe&&Fe.role==="agent"&&(Oe=!0,Fe={...Fe,workedDuration:Ce}),Fe}).reverse();if(!Z.some(Pe=>Pe.role==="agent"&&Pe.text?.trim().length>0)){let Pe=[...Z].reverse().find(Fe=>Fe.role==="think"&&Fe.text?.trim().length>0);Pe&&Z.push({id:"agent-fallback-"+Date.now(),role:"agent",text:Pe.text,isStreaming:!1,workedDuration:Ce})}let it=Z.filter(Pe=>!String(Pe.id).startsWith("welcome")&&(!Pe.isMeta||Pe.text&&Pe.text.includes("Request Cancelled")));return gn(st,null,it),V(Z.length),Z})}})()}m(""),M(!1)}},Ge=Tn(()=>{if(I.startsWith("/")&&!K){let u=I.split(" "),y=u[u.length-1].toLowerCase();if(u.length===1){let d=y.startsWith("/")?y.slice(1):y;return xi.filter(w=>(w.cmd.startsWith("/")?w.cmd.slice(1):w.cmd).toLowerCase().includes(d))}let f=xi;for(let d=0;d<u.length-1;d++){let w=u[d].toLowerCase(),B=f.find($=>$.cmd.toLowerCase()===w);if(B&&B.subs)f=B.subs;else return[]}return f.filter(d=>d.cmd.toLowerCase().includes(y))}let o=I.split(" "),n=o[o.length-1],a=n&&n.startsWith("\\@");if((n&&n.startsWith("@")||a)&&!K){let u=n.indexOf("#"),y=u!==-1,f=a?2:1,d=y?n.substring(f,u).toLowerCase():n.slice(f).toLowerCase(),w=y?n.substring(u):"";return jd(process.cwd()).filter(oe=>oe.name.toLowerCase().includes(d)).map(oe=>{let ae=oe.relativePath.replace(/\\/g,"/"),z=ae.startsWith(".")?ae:"./"+ae;return{cmd:(a?"\\@":"@")+"["+z+w+"]",desc:oe.relativePath}})}return[]},[I,K]);Ze(()=>{let o=0;for(;o<Ge.length;){let n=Ge[o],a=n?.cmd||n||"";if(typeof a=="string"&&a.trimStart().startsWith("---"))o++;else break}he(o<Ge.length?o:0)},[Ge]);let[ur,mr]=j(0),Ti=Ye(0);Ze(()=>{let o=Ti.current>0,n=Ge.length>0;if(Ti.current=Ge.length,!n){mr(0);return}if(!o){mr(1);return}mr(Ge.length)},[Ge]),Ze(()=>{if(ur>0&&ur<Ge.length){let o=setTimeout(()=>{mr(n=>Math.min(n+1,Ge.length))},5);return()=>clearTimeout(o)}},[ur,Ge.length]),Ze(()=>{if(dt!=="providerBudgetSelect")return;let o=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","CrofAI","InferX","SenseNova","AIHubMix","Poolside"],n=Ue.providerBudgets||{},a=o.reduce((g,u)=>(g[u]=!!(n[u]&&(n[u].agentLimit||n[u].tokenLimit)),g),{});Us(a),Zn(0)},[dt]),Ze(()=>{if(dt!=="providerBudgetFlow")return;let o={},n=Ue.providerBudgets||{};for(let a of tn){let g=n[a]||{};o[a]={agentLimit:wn(g.agentLimit),tokenLimit:wn(g.tokenLimit),monthlyTokenLimit:wn(g.monthlyTokenLimit)}}Ur(o),To(0)},[dt,tn]);let ic=({label:o,isSelected:n})=>{let a=o==="Cancel"||o==="Back"||o.toLowerCase().includes("exit")||o.toLowerCase().includes("back");return e.createElement(c,{marginTop:a?1:0,backgroundColor:n?"#2a2a2a":void 0,paddingX:1,width:"100%"},e.createElement(i,{color:n?"white":"gray",bold:n},n?"\u276F ":" ",o))},cn=(o,n,a,g=10,u=2,y=9)=>{let f=a>0?Math.min(100,n/a*100):0,d=Math.round(f),w=Math.round(d/100*g),B="\u2588".repeat(w)+"\u2591".repeat(Math.max(0,g-w)),$=l.success||"green";d>=40&&d<=80?$=l.warning||"yellow":d>80&&($=l.danger||"red");let oe=o.toLowerCase().includes("token")||o.toLowerCase().includes("daily")||o.toLowerCase().includes("monthly"),ae=Jn(a)?"\u221E":oe?ft(a):a,z=oe?ft(n):n,Ce;return f===0?Ce="0%":f>0&&f<1?Ce="<1%":Ce=`${d}%`,e.createElement(c,{flexDirection:"row",paddingLeft:u,key:o},e.createElement(c,{width:y},e.createElement(i,{color:l.textMuted},o,": ")),e.createElement(i,{color:$},B),e.createElement(i,{color:l.textMuted}," ",Ce," (",z,"/",ae,")"))},na=()=>{switch(dt){case"settings":return e.createElement(Br,{systemSettings:de,setSystemSettings:At,apiTier:rt,setActiveView:W,setInputConfig:_t,saveSettings:Lt,quotas:Ue,setMessages:_,aiProvider:P,setProviderReturnView:Pr});case"theme":return e.createElement(Br,{systemSettings:de,setSystemSettings:At,apiTier:rt,setActiveView:W,setInputConfig:_t,saveSettings:Lt,quotas:Ue,setMessages:_,aiProvider:P,initialSelectingTheme:!0,onCloseTheme:()=>W("chat"),setProviderReturnView:Pr});case"selectProvider":return e.createElement(xt,{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"},{label:"Experiential Labs",value:"ExpLabs"},...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:en}],theme:de.theme,onSelect:async o=>{if(o.value===en||o.value==="settings"||o.value==="Back"){W(en);return}let n=o.value,a=await un(n);if(a){ut(n),He(a),Hn(a,{aiProvider:n,onIDEApproval:lr});let g=(Ue.providerTiers||{})[n]||"Free",u=ao(n,g);Jt(u),po(g),n==="NVIDIA"&&process.env.NVIDIA_BASE_URL||n==="Ollama"||n==="CrofAI"||n==="InferX"||n==="SenseNova"||n==="Poolside"||n==="9router"||n==="ExpLabs"?(At(y=>({...y,memory:!1})),Lt({aiProvider:n,activeModel:u,apiTier:g,quotas:Ue,systemSettings:{...de,memory:!1}})):Lt({aiProvider:n,activeModel:u,apiTier:g,quotas:Ue}),_(y=>[...y,{role:"system",text:`\u2726 Switched to ${n} (cached)!${u?`
|
|
190
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: ${u}.`:""}${(n==="Ollama"||n==="CrofAI"||n==="InferX"||n==="SenseNova"||n==="AIHubMix"||n==="Poolside"||n==="9router"||n==="ExpLabs")&&de.memory?`
|
|
191
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with ${n}.`:""}${n==="NVIDIA"&&process.env.NVIDIA_BASE_URL&&de.memory?`
|
|
192
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with Custom Endpoints.`:""}
|
|
193
|
+
\u2800`,isMeta:!0}]),W(en)}else _t({label:`Enter ${n} API Key:`,key:"providerKey",provider:n,value:"",returnView:en}),W("input")},onClose:()=>W(en)});case"apiTier":return e.createElement(xt,{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] ${rt==="Paid"?"\u25CF":""}`,value:"Paid"},{label:"Back",value:"settings"}],theme:de.theme,onSelect:o=>{if(o.value==="settings"||o.value==="Back"){W("settings");return}let n=o.value;po(n);let a={...Ue.providerTiers||{},[P]:n},g={...Ue,providerTiers:a};Yt(g),Lt({apiTier:n,quotas:g}),W("settings")}});case"resetMode":return e.createElement(xt,{title:"SELECT MONTHLY RESET MODE",items:[{label:"Default (Rolling 30-Day Window)",value:"Rolling"},{label:"Custom (Set reset day of month)",value:"Custom"},{label:"Back",value:"apiTier"}],theme:de.theme,onSelect:o=>{if(o.value==="apiTier"||o.value==="Back"){W("apiTier");return}let n=o.value,a={...Ue,resetMode:n};Yt(a),n==="Custom"?(_t({label:"Enter monthly reset day (1-30):",key:"quotas",subKey:"resetDay",value:String(Ue.resetDay||1),returnView:"settings"}),W("input")):(Lt({apiTier:rt,quotas:a}),W("settings"))},onClose:()=>W("apiTier")});case"budgetTypeSelect":return e.createElement(xt,{title:"SELECT BUDGET TYPE",items:[{label:`Global Budget (single limit for all providers) ${rt==="Paid"&&!Ue.providerBudgets?.__useProvider?"\u25CF":""}`,value:"global"},{label:`Provider Budgets (set limits per provider individually) ${Ue.providerBudgets?.__useProvider?"\u25CF":""}`,value:"provider"},{label:"Back",value:vo}],theme:de.theme,onSelect:o=>{if(o.value===vo||o.value==="Back"){W(vo);return}if(o.value==="global"){let n={...Ue,agentLimit:99999999,tokenLimit:99999999999999,monthlyTokenLimit:99999999999999,providerBudgets:{__useProvider:!1}};Yt(n);let a=vo==="settings"?"resetMode":"budgetResetMode";_t({label:"Enter Agent daily budget (requests made):",key:"quotas",subKey:"agentLimit",value:wn(n.agentLimit),returnView:vo,next:g=>({label:"Enter Agent daily budget (tokens used):",key:"quotas",subKey:"tokenLimit",value:wn(g.tokenLimit),returnView:vo,next:u=>({label:"Enter Agent monthly budget (tokens used):",key:"quotas",subKey:"monthlyTokenLimit",value:wn(u.monthlyTokenLimit),returnView:a})})}),W("input")}else if(o.value==="provider"){let n={...Ue,agentLimit:99999999,tokenLimit:99999999999999,monthlyTokenLimit:99999999999999,providerBudgets:{...Ue.providerBudgets||{},__useProvider:!0}};Yt(n),W("providerBudgetSelect")}},onClose:()=>W(vo)});case"providerBudgetSelect":{let o=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","CrofAI","InferX","SenseNova","AIHubMix","Poolside","ExpLabs"],n=o.some(a=>Nr[a]);return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,padding:0,width:"100%"},e.createElement(c,{paddingX:1,marginBottom:1},e.createElement(i,{color:l.text,bold:!0},"SELECT PROVIDERS TO SET LIMMITS FOR")),o.map((a,g)=>{let u=g===Fs,y=!!Nr[a];return e.createElement(c,{key:a,backgroundColor:u?l.highlightBg||"#2a2a2a":void 0,paddingX:1,width:"100%",flexDirection:"row"},e.createElement(i,{color:u?l.text:l.textMuted,bold:u},u?"\u276F ":" "),e.createElement(i,{color:y?l.success||"green":l.textMuted},y?"\u2611":"\u2610"),e.createElement(i,{color:u?l.text:l.textMuted,bold:u}," ",a),y&&Ue.providerBudgets?.[a]?.agentLimit?e.createElement(i,{color:l.primary||"cyan"}," (budget set)"):null)}),e.createElement(c,{paddingX:1,marginTop:1,flexDirection:"column"},e.createElement(i,{color:l.textMuted,italic:!0},"\u2191\u2193 Navigate \u2022 Space to toggle \u2022 Enter to confirm \u2022 ESC to go back"),!n&&e.createElement(i,{color:l.warning||"yellow",italic:!0}," Select at least one provider to continue")))}case"providerBudgetFlow":{let o=tn.length,n=o*2;return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,padding:0,width:"100%"},e.createElement(c,{paddingX:1,marginBottom:0,justifyContent:"space-between",flexDirection:"row"},e.createElement(i,{color:l.text,bold:!0},"PROVIDER BUDGET CONFIGURATION"),e.createElement(i,{color:l.textMuted,italic:!0},"(0 or blank = unlimited)")),e.createElement(c,{paddingX:1,marginTop:1,flexDirection:"row"},e.createElement(c,{width:14},e.createElement(i,{color:l.textMuted,bold:!0},"PROVIDER")),e.createElement(c,{width:30,paddingLeft:1},e.createElement(i,{color:l.textMuted,bold:!0},"DAILY TOKENS (/day)")),e.createElement(c,{width:30,paddingLeft:1},e.createElement(i,{color:l.textMuted,bold:!0},"MONTHLY TOKENS (/month)"))),e.createElement(c,{paddingX:1},e.createElement(i,{color:l.borderMuted},"\u2500".repeat(74))),tn.map((a,g)=>{let u=g*2,y=g*2+1,f=Rn===u,d=Rn===y,w=f||d,B=Fr[a]?.tokenLimit??"",$=Fr[a]?.monthlyTokenLimit??"";return e.createElement(c,{key:a,flexDirection:"row",paddingX:1,marginY:0,backgroundColor:w?l.highlightBg||"#2a2a2a":void 0},e.createElement(c,{width:14,flexDirection:"row"},e.createElement(i,{color:w?l.primary||"cyan":l.text,bold:w},w?"\u276F ":" ",a)),e.createElement(c,{width:30,paddingLeft:1,flexDirection:"row"},f?e.createElement(c,{flexDirection:"row"},e.createElement(i,{color:l.primary||"cyan",bold:!0},"[ "),e.createElement(kr,{value:B,onChange:oe=>{Ur(ae=>({...ae,[a]:{...ae[a]||{},tokenLimit:oe}}))},onSubmit:()=>{To(y)}}),e.createElement(i,{color:l.primary||"cyan",bold:!0}," ]")):e.createElement(i,{color:B?l.text:l.textMuted},"[ ",B||"0 (Unlimited)"," ]")),e.createElement(c,{width:30,paddingLeft:1,flexDirection:"row"},d?e.createElement(c,{flexDirection:"row"},e.createElement(i,{color:l.primary||"cyan",bold:!0},"[ "),e.createElement(kr,{value:$,onChange:oe=>{Ur(ae=>({...ae,[a]:{...ae[a]||{},monthlyTokenLimit:oe}}))},onSubmit:()=>{g+1<o?To((g+1)*2):To(n)}}),e.createElement(i,{color:l.primary||"cyan",bold:!0}," ]")):e.createElement(i,{color:$?l.text:l.textMuted},"[ ",$||"0 (Unlimited)"," ]")))}),e.createElement(c,{paddingX:1,marginTop:1},Rn===n?e.createElement(c,{backgroundColor:l.highlightBg||"#2a2a2a",paddingX:1},e.createElement(i,{color:l.success||"green",bold:!0},"\u276F [ Save & Apply Budgets ]")):e.createElement(i,{color:l.textMuted}," [ Save & Apply Budgets ]")),e.createElement(c,{paddingX:1,marginTop:1,flexDirection:"column"},e.createElement(i,{color:l.textMuted,italic:!0},"\u2191\u2193/\u2190\u2192 Navigate \u2022 Enter next / save \u2022 ESC to go back")))}case"budgetResetMode":return e.createElement(xt,{title:"SELECT MONTHLY RESET MODE",items:[{label:"Default (Rolling 30-Day Window)",value:"Rolling"},{label:"Custom (Set reset day of month)",value:"Custom"},{label:"Back",value:"chat"}],theme:de.theme,onSelect:o=>{if(o.value==="chat"||o.value==="Back"){W("chat");return}let n=o.value,a={...Ue,resetMode:n};Yt(a),n==="Custom"?(_t({label:"Enter monthly reset day (1-30):",key:"quotas",subKey:"resetDay",value:String(Ue.resetDay||1),returnView:"chat"}),W("input")):(Lt({apiTier:rt,quotas:a}),W("chat"))},onClose:()=>W("chat")});case"budgetView":{let o=Bn?.agent||0,n=Ue.agentLimit||99999999,a=Bn?.tokens||0,g=Ue.tokenLimit||99999999999999,u=Ue.resetMode==="Custom"?Gr?.tokens||0:rr?.tokens||0,y=Ue.monthlyTokenLimit||99999999999999,f=rt!=="Paid",d=!!Ue.providerBudgets?.__useProvider,w=Ue.providerBudgets||{},B=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","CrofAI","InferX","SenseNova","AIHubMix","Poolside","ExpLabs"].filter(z=>w[z]&&(w[z].agentLimit||w[z].tokenLimit||w[z].monthlyTokenLimit)),$=!d&&(Jn(n)||Jn(g)||Jn(y)),oe="",ae="";if(Ue.resetMode==="Custom"){let z=new Date,Ce=Ue.resetDay||1,Oe=z.getFullYear(),Z=z.getMonth();z.getDate()>=Ce&&(Z+=1,Z>11&&(Z=0,Oe+=1));let R=new Date(Oe,Z,Ce,0,0,0);oe=`${R.toLocaleString("default",{month:"short"}).toUpperCase()}-${Ce}`;let Pe=Math.max(0,R.getTime()-z.getTime()),Fe=Math.floor(Pe/(1e3*60*60)),tt=Math.floor(Fe/24),Tt=Fe%24;ae=`(${tt} days: ${Tt} hrs left)`}return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,padding:1,paddingBottom:0,paddingTop:0,width:"100%"},e.createElement(c,{marginBottom:1,justifyContent:"space-between",width:"100%"},e.createElement(i,{color:l.text,bold:!0,underline:!0},"USAGE LIMITS"),e.createElement(i,{color:l.textMuted},"[ ESC to Close ]")),$?e.createElement(c,{padding:1,justifyContent:"center",alignItems:"center",width:"100%"},e.createElement(i,{color:l.text,bold:!0},"LIMITS NOT SET")):d&&B.length>0?e.createElement(c,{flexDirection:"column",gap:0,width:"100%"},(()=>{let z=s?.columns||X?.columns||80;if(z<115){let Z=Math.max(5,Math.min(30,z-50));return B.map(R=>{let it=w[R],Pe=0,Fe=Bn?.models?.[R]||{};for(let nt in Fe)Pe+=Fe[nt]?.tokens||0;let tt=0,ot=(Ue.resetMode==="Custom"?Gr:rr)?.models?.[R]||{};for(let nt in ot)tt+=ot[nt]?.tokens||0;return e.createElement(c,{key:R,flexDirection:"column",borderStyle:"single",borderColor:l.borderMuted,paddingX:1,width:"100%"},e.createElement(c,{marginBottom:0},e.createElement(i,{color:l.primary,bold:!0},"\u25C6 ",R)),cn("Daily",Pe,it.tokenLimit||99999999999999,Z,2,9),cn("Monthly",tt,it.monthlyTokenLimit||99999999999999,Z,2,9))})}let Oe=[];for(let Z=0;Z<B.length;Z+=2)Oe.push(B.slice(Z,Z+2));return Oe.map((Z,R)=>e.createElement(c,{key:R,flexDirection:"row",width:"100%"},Z.map(it=>{let Pe=w[it],Fe=0,tt=Bn?.models?.[it]||{};for(let U in tt)Fe+=tt[U]?.tokens||0;let Tt=0,nt=(Ue.resetMode==="Custom"?Gr:rr)?.models?.[it]||{};for(let U in nt)Tt+=nt[U]?.tokens||0;let Bt=Z.length===1,Io=Bt?z:Math.floor(z/2),ko=Math.max(5,Math.min(25,Io-36));return e.createElement(c,{key:it,flexDirection:"column",borderStyle:"single",borderColor:l.borderMuted,paddingX:1,width:Bt?"100%":"50%"},e.createElement(c,{marginBottom:0},e.createElement(i,{color:l.primary,bold:!0},"\u25C6 ",it)),cn("Daily",Fe,Pe.tokenLimit||99999999999999,ko,2,9),cn("Monthly",Tt,Pe.monthlyTokenLimit||99999999999999,ko,2,9))})))})(),oe?e.createElement(c,{marginLeft:2,marginTop:1},e.createElement(i,{color:l.textMuted},"Monthly Reset: "),e.createElement(i,{color:l.accent||"magenta",bold:!0},oe),ae?e.createElement(i,{color:l.textMuted},` ${ae}`):null):e.createElement(c,{marginLeft:2,marginTop:1},e.createElement(i,{color:l.textMuted},"Monthly Reset: "),e.createElement(i,{color:l.secondary||"blue",bold:!0},"Rolling 30-Day Window"))):e.createElement(c,{flexDirection:"column",borderStyle:"single",borderColor:l.borderMuted,paddingX:1,width:"100%"},cn("Daily Tokens",a,g,"green"),cn("Monthly Tokens",u,y,"yellow"),oe?e.createElement(c,{marginLeft:4,marginTop:1},e.createElement(i,{color:l.textMuted},"Monthly Reset: "),e.createElement(i,{color:l.accent||"magenta",bold:!0},oe),ae?e.createElement(i,{color:l.textMuted},` ${ae}`):null):e.createElement(c,{marginLeft:4,marginTop:1},e.createElement(i,{color:l.textMuted},"Monthly Reset: "),e.createElement(i,{color:l.secondary||"blue",bold:!0},"Rolling 30-Day Window"))))}case"input":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,padding:0,width:"100%"},e.createElement(c,{paddingX:1},e.createElement(i,{color:l.text,bold:!0},"DATA CONFIGURATION")),kt?.note&&e.createElement(c,{paddingX:1,marginBottom:1},e.createElement(i,{color:l.textMuted,italic:!0},kt.note)),e.createElement(c,{paddingX:1,flexDirection:"row"},e.createElement(i,{color:l.text,bold:!0},kt?.label," "),e.createElement(kr,{value:kt?.value||"",onChange:o=>_t(n=>({...n,value:o})),onSubmit:async o=>{let{key:n,subKey:a,next:g,onDone:u}=kt,y={...Ue},f={};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))),y[a]=d,Yt(y),f.quotas=y}else if(n==="providerBudgets"){let d=kt.providerKey,w=a.toLowerCase().includes("limit")?parseInt(o)||0:o,B=y.providerBudgets||{};y.providerBudgets={...B,[d]:{...B[d]||{},[a]:w}},Yt(y),f.quotas=y}else if(n==="activeModel")Jt(o),f.activeModel=o;else if(n==="janitorModel")F(o),f.janitorModel=o;else if(n==="autoApproveCommands"||n==="autoDisallowCommands"||n==="alwaysAskCommands"){let d={...de,[n]:o.trim(),sandboxPreset:"Custom"};At(d),f.systemSettings=d}else if(n==="externalDataPath"){let d={...de,useExternalData:!0,externalDataPath:o.trim()};At(d),f.systemSettings=d,_(w=>[...w,{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 w={...Eo,apiKey:d};er(w),f.imageSettings=w,_(B=>(V(B.length+1),[...B,{id:Date.now(),role:"system",text:"[IMAGE KEY] Custom API key saved successfully.",isMeta:!0}]))}}else if(n==="providerKey"){let d=o.trim(),w=kt.provider;(w==="Ollama"||w==="9router")&&(d==="LOCAL"||d==="")&&(d="LOCAL",w==="Ollama"&&(At(oe=>({...oe,ollamaEndpoint:"Local"})),f.systemSettings={...de,ollamaEndpoint:"Local"})),await is(w,d),ut(w),He(d),Hn(d,{aiProvider:w,onIDEApproval:lr});let B=(Ue.providerTiers||{})[w]||"Free",$=ao(w,B);Jt($),po(B),f.aiProvider=w,f.activeModel=$,f.apiTier=B,(w==="NVIDIA"&&process.env.NVIDIA_BASE_URL||w==="Ollama"||w==="CrofAI"||w==="InferX"||w==="SenseNova"||w==="AIHubMix"||w==="Poolside"||w==="9router"||w==="ExpLabs")&&(At(oe=>({...oe,memory:!1})),f.systemSettings={...de,memory:!1}),_(oe=>(V(oe.length+1),[...oe,{id:Date.now(),role:"system",text:`\u2726 ${w} API Key saved successfully! ${$?`
|
|
194
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: ${$}`:""}${w==="Ollama"&&d==="LOCAL"?`
|
|
195
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Ollama Endpoint automatically switched to Local`:""}${w==="Ollama"||w==="CrofAI"||w==="InferX"||w==="SenseNova"||w==="AIHubMix"||w==="Poolside"||w==="9router"||w==="ExpLabs"?`
|
|
196
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with ${w}`:""}${w==="NVIDIA"&&process.env.NVIDIA_BASE_URL?`
|
|
197
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available`:""}
|
|
198
|
+
\u2800\u2800`,isMeta:!0}]))}if(g){let d=g(n==="quotas"||n==="providerBudgets"?y:o);_t(d)}else u?(Lt({...f,apiTier:rt,quotas:y,imageSettings:f.imageSettings||Eo}),_t(null),u(y)):(Lt({...f,apiTier:rt,quotas:y,imageSettings:f.imageSettings||Eo}),_t(null),W(kt?.returnView||"settings"))}})),e.createElement(c,{paddingX:1,marginTop:1},e.createElement(i,{color:l.textMuted,dimColor:!0,italic:!0},"(Press Enter to confirm selection)")));case"stats":{let o=rn==="modelBreakdown"||rn==="dailyModelBreakdown",n=rn==="daily"||rn==="dailyModelBreakdown",a=n?Bn:rr,g=n?"TODAY's USAGE":"LAST 30 DAYS USAGE",u=n?"TODAY'S MODEL TOKEN BREAKDOWN":"30-DAY MODEL TOKEN BREAKDOWN",y="Wall Time:",f="Tokens Used:",d="Images Made:",w="Image Credits:",B="Code Changes:",$="Tool Calls:",oe=Math.max(4,(s?.rows||X?.rows||24)-15),ae=(Pe,Fe,tt,Tt,ot,nt=0,Bt=!1)=>{let Io=s?.columns||X?.columns||80,ko=Math.min(125,Io-2),U=Math.max(20,ko-6),be=Math.max(5,U-nt-tt.length-5),Ie=Fe;Ie.length>be&&(Ie=Ie.substring(0,be-1)+"\u2026");let ke=Math.max(2,U-nt-Ie.length-tt.length-2),lt=" "+".".repeat(ke)+" ",Ve=" ".repeat(nt);return e.createElement(c,{key:Pe,width:U},e.createElement(i,{wrap:"truncate"},e.createElement(i,null,Ve),e.createElement(i,{color:Tt,bold:Bt},Ie),e.createElement(i,{color:l.textMuted,dimColor:!0},lt),e.createElement(i,{color:ot,bold:Bt},tt)))},z=[],Ce=a?.models;if(!Ce||Object.keys(Ce).length===0)z.push(e.createElement(c,{key:"empty",marginTop:1},e.createElement(i,{color:l.textMuted,italic:!0},"No model token usage recorded for ",n?"today":"the last 30 days",".")));else{let Pe=(In||"").trim(),Fe="",tt="";if(Pe.includes(":")){let ot=Pe.indexOf(":");Fe=Pe.substring(0,ot).trim().toLowerCase(),tt=Pe.substring(ot+1).trim().toLowerCase()}else Fe=Pe.toLowerCase();let Tt=Object.entries(Ce).sort(([ot],[nt])=>ot.localeCompare(nt,void 0,{sensitivity:"base"})).filter(([ot,nt])=>Fe&&!ot.toLowerCase().includes(Fe)?!1:tt?Object.keys(nt).some(Bt=>Bt.toLowerCase().includes(tt)):!0);Tt.length===0?z.push(e.createElement(c,{key:"no-matches",marginTop:1},e.createElement(i,{color:l.textMuted,italic:!0},'No results found matching "',In,'".'))):Tt.forEach(([ot,nt],Bt)=>{let Io=Object.entries(nt).sort(([U],[be])=>U.localeCompare(be,void 0,{sensitivity:"base"})).filter(([U])=>!tt||U.toLowerCase().includes(tt));if(Io.length===0)return;let ko=Io.reduce((U,[,be])=>U+(be.tokens||0),0);Bt>0&&z.length>0&&z.push(e.createElement(c,{key:`space-prov-${ot}`},e.createElement(i,null," "))),z.push(ae(`prov-${ot}`,`${ot}:`,ft(ko),l.primary,l.text,0,!0)),Io.forEach(([U,be],Ie)=>{Ie>0&&z.push(e.createElement(c,{key:`space-mod-${ot}-${U}`},e.createElement(i,null," "))),z.push(ae(`mod-${ot}-${U}`,`\xBB ${U}:`,ft(be.tokens||0),l.secondary,l.text,2,!0)),z.push(ae(`in-${ot}-${U}`,"\xBB Input Tokens:",ft((be.tokens||0)-(be.candidateTokens||0)),l.textMuted,l.text,5,!1)),(be.cachedTokens||0)>0&&z.push(ae(`cache-${ot}-${U}`,"\xBB Cached:",ft(be.cachedTokens),l.textMuted,l.text,7,!1)),z.push(ae(`out-${ot}-${U}`,"\xBB Output Tokens:",ft(be.candidateTokens||0),l.textMuted,l.text,5,!1))})})}let Oe=z.length,Z=Math.max(0,Oe-oe);$e.current=Z;let R=Math.min(Hl,Z),it=z.slice(R,R+oe);return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,paddingX:3,paddingY:1,paddingBottom:0,width:Math.min(125,(s?.columns||100)-2)},o?e.createElement(c,{flexDirection:"column"},e.createElement(c,{justifyContent:"space-between"},e.createElement(i,{color:l.text,bold:!0,underline:!0},u),Oe>oe&&e.createElement(i,{color:l.textMuted,dimColor:!0},"[",R+1,"-",Math.min(Oe,R+oe)," of ",Oe,"] \u25B2\u25BC")),e.createElement(c,{marginTop:1},e.createElement(i,{color:l.secondary,bold:!0},"Filter (provider:model): "),e.createElement(i,{color:l.text},In),e.createElement(i,{color:l.primary,bold:!0},"\u258A"),In.length>0&&e.createElement(i,{color:l.textMuted,dimColor:!0,italic:!0}," (Type to search, Esc/Backspace to clear)")),e.createElement(c,{flexDirection:"column",height:oe,marginTop:1},it)):e.createElement(e.Fragment,null,e.createElement(c,{marginBottom:1},e.createElement(i,{color:l.text,bold:!0,underline:!0},"SESSION TELEMETRY")),e.createElement(c,{flexDirection:"column"},e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:l.secondary},"Session Duration:")),e.createElement(i,{color:l.text},Wo(Date.now()-Os))),Hs>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:l.secondary},"Model Requests:")),e.createElement(i,{color:l.text},Hs)),e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(i,{color:l.textMuted},"\xBB API Time:")),e.createElement(i,{color:l.text},Wo(tr))),e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(i,{color:l.textMuted},"\xBB Tool Time:")),e.createElement(i,{color:l.text},Wo(or)))),Ws>0&&e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:l.secondary},"Memory Agent:")),e.createElement(i,{color:l.text},Ws)),qt>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:l.secondary},"Tokens Consumed:")),e.createElement(i,{color:l.text},ft(qt))),e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(i,{color:l.textMuted},"\xBB Input Tokens:")),e.createElement(i,{color:l.text},ft(qt-nn))),io>0&&e.createElement(c,{marginLeft:4},e.createElement(c,{width:21},e.createElement(i,{color:l.textMuted},"\xBB Cached:")),e.createElement(i,{color:l.text},ft(io))),nn>0&&e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(i,{color:l.textMuted},"\xBB Output Tokens:")),e.createElement(i,{color:l.text},ft(nn)))),so?.tokens>0&&e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:l.secondary},"Active Context:")),e.createElement(i,{color:l.text},ft(so.tokens)," ",(()=>{let Pe=262144,Fe=process.env.HIGH_CONTEXT,tt=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1;if(Fe&&Fe!=="false"){let nt=parseInt(Fe,10);!isNaN(nt)&&nt>=32e3&&nt<=1e6&&(Pe=nt)}(P==="NVIDIA"&&(je?.includes("gpt")||je?.includes("qwen")||je?.includes("medium")||je.includes("muse"))||P==="Mistral")&&(Pe=128e3),P==="Google"&&je?.includes("gemma")&&tt&&(Pe=16e3);let Tt=so.tokens/Pe*100,ot=Tt<60?l.text:Tt<80?l.warning:l.danger;return e.createElement(i,{color:ot,dimColor:!0},"(",Tt.toFixed(0),"%)")})())),nr>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:l.secondary},"Images Made:")),e.createElement(i,{color:l.text},nr)),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:l.secondary},"Image Credits:")),e.createElement(i,{color:l.text},Number(((qs||0)*1e3).toFixed(0))," credits"))),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:l.secondary},"Code Changes (Sess):")),e.createElement(i,{color:l.text},e.createElement(i,{color:l.success||"green"},"+",Mt.linesAdded)," ",e.createElement(i,{color:l.danger||"red"},"-",Mt.linesRemoved))),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:l.secondary},"Tool Calls (Sess):")),e.createElement(i,{color:l.text},Mt.toolSuccess+Mt.toolFailure+Mt.toolDenied," ( "),e.createElement(i,{color:l.success||"green"},"\u2714 ",Mt.toolSuccess),e.createElement(i,{color:l.text}," "),e.createElement(i,{color:l.warning||"yellow"},"\u{1F6C7} ",Mt.toolDenied),e.createElement(i,{color:l.text}," "),e.createElement(i,{color:l.danger||"red"},"\u2718 ",Mt.toolFailure),e.createElement(i,{color:l.text}," )"))),e.createElement(c,{flexDirection:"column",marginTop:1},e.createElement(i,{color:l.text,bold:!0,underline:!0},g),e.createElement(c,{marginTop:1},e.createElement(c,{width:25},e.createElement(i,{color:l.secondary},y)),e.createElement(i,{color:l.text},oi(a?.duration||0))),(a?.agent||0)>0&&e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:l.secondary},"Model Requests:")),e.createElement(i,{color:l.text},a?.agent||0)),(a?.background||0)>0&&e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:l.secondary},"Memory Agent:")),e.createElement(i,{color:l.text},a?.background||0)),(a?.tokens||0)>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:l.secondary},f)),e.createElement(i,{color:l.text},ft(a?.tokens||0))),e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(i,{color:l.textMuted},"\xBB Input Tokens:")),e.createElement(i,{color:l.text},ft((a?.tokens||0)-(a?.candidateTokens||0)))),(a?.cachedTokens||0)>0&&e.createElement(c,{marginLeft:4},e.createElement(c,{width:21},e.createElement(i,{color:l.textMuted},"\xBB Cached:")),e.createElement(i,{color:l.text},ft(a.cachedTokens))),(a?.candidateTokens||0)>0&&e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(i,{color:l.textMuted},"\xBB Output Tokens:")),e.createElement(i,{color:l.text},ft(a.candidateTokens)))),(a?.imageCalls?.length||0)>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:l.secondary},d)),e.createElement(i,{color:l.text},a.imageCalls.length)),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:l.secondary},w)),e.createElement(i,{color:l.text},Number(((a.imageCalls.reduce((Pe,Fe)=>Pe+Fe.cost,0)||0)*1e3).toFixed(0))," credits"))),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:l.secondary},B)),e.createElement(i,{color:l.text},e.createElement(i,{color:l.success||"green"},"+",a?.linesAdded||0)," ",e.createElement(i,{color:l.danger||"red"},"-",a?.linesRemoved||0))),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:l.secondary},$)),e.createElement(i,{color:l.text},(a?.toolSuccess||0)+(a?.toolFailure||0)+(a?.toolDenied||0)," ( "),e.createElement(i,{color:l.success||"green"},"\u2714 ",a?.toolSuccess||0),e.createElement(i,{color:l.text}," "),e.createElement(i,{color:l.warning||"yellow"},"\u{1F6C7} ",a?.toolDenied||0),e.createElement(i,{color:l.text}," "),e.createElement(i,{color:l.danger||"red"},"\u2718 ",a?.toolFailure||0),e.createElement(i,{color:l.text}," )")))),e.createElement(i,{color:l.textMuted,dimColor:!0,italic:!0},`
|
|
199
|
+
`,"(Press TAB to toggle Today/30-Day views, SPACE to toggle Model Breakdown, ESC to return)"))}case"dynamicDirDanger":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:l.warning||"yellow",bold:!0,underline:!0},"DYNAMIC DIRECTORY AWARENESS"),e.createElement(i,{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(i,{color:l.text},`
|
|
200
|
+
`,"RECOMMENDED SCENARIOS TO TURN ON:"),e.createElement(i,{color:l.textMuted},"\u2022 Repo is small."),e.createElement(i,{color:l.textMuted},"\u2022 The task benefits from real-time filesystem awareness."),e.createElement(i,{color:l.textMuted},"\u2022 Files are often created, renamed, or deleted."),e.createElement(i,{color:l.textMuted},"\u2022 You know exactly what you're signing up for."),e.createElement(i,{color:l.textMuted},"\u2022 You don't have conflicting decisions regarding token bills."),e.createElement(i,{color:l.textMuted},"\u2022 You want to see your wallet crying at 3am."),e.createElement(c,{marginTop:1},e.createElement(xt,{title:"Confirm Intent",theme:de.theme,items:[{label:"Turn On Dynamic Directory Awareness",value:"on"},{label:"Keep Off (Recommended)",value:"off"}],onSelect:o=>{o.value==="on"&&At(n=>{let a={...n,dynamicDirAwareness:!0};return Lt({systemSettings:a,apiTier:rt,quotas:Ue}),a}),W("settings")}})));case"dynamicDirHelp":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:l.text,bold:!0,underline:!0},"DYNAMIC DIRECTORY AWARENESS \u2014 HELP & EXPLANATION"),e.createElement(i,{color:l.text,bold:!0},`
|
|
201
|
+
`,"OFF (Default):"),e.createElement(i,{color:l.textMuted},"\u2022 Takes a static directory snapshot at conversation/session start and places it in System Context."),e.createElement(i,{color:l.textMuted},"\u2022 Prompt cache remains stable across user turns, saving tokens and money."),e.createElement(i,{color:l.text,bold:!0},`
|
|
202
|
+
`,"ON:"),e.createElement(i,{color:l.textMuted},"\u2022 Rescans and updates the directory's state dynamically on every single user turn."),e.createElement(i,{color:l.textMuted},"\u2022 Provides real-time filesystem awareness if files are continuously created, renamed, or removed."),e.createElement(i,{color:l.textMuted},"\u2022 Changes Prompt Context on each turn, invalidating part of prompt caches and increasing token usage."),e.createElement(c,{marginTop:1},e.createElement(xt,{title:"Actions",theme:de.theme,items:[{label:"Back to Settings",value:"back"}],onSelect:()=>W("settings")})));case"autoExecDanger":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:l.warning||"yellow",bold:!0,underline:!0},"SECURITY WARNING: YOLO MODE"),e.createElement(i,{marginTop:1,color:l.text},"Turning this ON allows the agent to execute terminal commands automatically without requiring your approval for each step."),e.createElement(i,{marginTop:1,color:l.text,bold:!0},"RISKS INVOLVED:"),e.createElement(i,{color:l.textMuted},"\u2022 The agent may execute destructive commands (rm -rf, etc.) by mistake unless specified in sandbox rules."),e.createElement(i,{color:l.textMuted},"\u2022 Unintended system changes if the agent hallucinates a path or command."),e.createElement(i,{color:l.textMuted},"\u2022 Reduced control over the agent's step-by-step decision making."),e.createElement(c,{marginTop:1},e.createElement(xt,{title:"Confirm Intent",theme:de.theme,items:[{label:"I know the risk and turning on intentionally",value:"on"},{label:"Keep Off (Recommended)",value:"off"}],onSelect:o=>{o.value==="on"&&At(n=>({...n,autoExec:!0})),W("settings")}})));case"advanceRollbackDanger":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,paddingX:2,paddingY:1,paddingTop:0,width:"100%"},e.createElement(i,{color:l.warning||"yellow",bold:!0},"\u26A0 Emergency Rollback Notice"),e.createElement(i,{marginTop:1,color:l.text},"When enabled, full repo snapshots exist only during active AI turns."),e.createElement(i,{marginTop:1,color:l.text},"If catastrophic changes occur during a turn, avoid abruptly stopping the agent unless absolutely necessary (external damages out of codebase)."),e.createElement(i,{color:l.textMuted},"The agent may be able to automatically restore the repo to a safe state."),e.createElement(i,{marginTop:1,color:l.textMuted},"Once the turn ends, emergency snapshots are deleted and standard /revert takes over which may not retain full repo content."),e.createElement(i,{marginTop:1,color:l.textMuted},"(Requires Restart to take effect)"),e.createElement(c,{marginTop:1},e.createElement(xt,{title:"Confirm",theme:de.theme,items:[{label:"I understand and wish to enable",value:"on"},{label:"Keep Off",value:"off"}],onSelect:o=>{o.value==="on"&&At(n=>({...n,advanceRollback:!0})),W("settings")}})));case"externalDanger":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:l.warning||"yellow",bold:!0,underline:!0},"SECURITY WARNING: EXTERNAL WORKSPACE ACCESS"),e.createElement(i,{marginTop:1,color:l.text},"Turning this ON allows the agent to execute tools (Read/Write/Exec) outside of the current active workspace directory."),e.createElement(i,{marginTop:1,color:l.text,bold:!0},"RISKS INVOLVED:"),e.createElement(i,{color:l.textMuted},"\u2022 Access to sensitive system files (SSH keys, Browser data, etc.)"),e.createElement(i,{color:l.textMuted},"\u2022 Potential for accidental or malicious deletion of OS-critical files."),e.createElement(i,{color:l.textMuted},"\u2022 Unauthorized script execution across your entire file system."),e.createElement(c,{marginTop:1},e.createElement(xt,{title:"Confirm Intent",theme:de.theme,items:[{label:"I know the risk and turning on intentionally",value:"on"},{label:"Keep Off (Recommended)",value:"off"}],onSelect:o=>{o.value==="on"&&At(n=>({...n,allowExternalAccess:!0})),W("settings")}})));case"doubleDanger":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:l.danger||"red",bold:!0,underline:!0},"CRITICAL SECURITY WARNING: COMBINED SYSTEM RISK"),e.createElement(i,{marginTop:1,color:l.text},"You are attempting to enable BOTH [YOLO Mode] and [External Workspace Access] simultaneously."),e.createElement(i,{marginTop:1,color:l.danger||"red",bold:!0},"THIS IS NOT RECOMMENDED."),e.createElement(i,{marginTop:1,color:l.text,bold:!0},"THE CRITICAL RISK:"),e.createElement(i,{color:l.textMuted},"The agent will have the power to execute any command across your entire system WITHOUT your approval or supervision."),e.createElement(i,{color:l.danger||"red",italic:!0,marginTop:1},"A single hallucination or error could result in full system wipe or data theft."),e.createElement(c,{marginTop:1},e.createElement(xt,{title:"Final Confirmation",theme:de.theme,items:[{label:"I agree knowing the consequences",value:"on"},{label:"Keep Off",value:"off"}],onSelect:o=>{o.value==="on"&&At(n=>({...n,autoExec:!0,allowExternalAccess:!0})),W("settings")}})));case"key":return e.createElement(xt,{title:"API KEY MANAGEMENT",items:[{label:"Edit Current Key (Update)",value:"edit"},{label:"Remove Current Key (Delete)",value:"remove"},{label:"Cancel",value:"Cancel"}],onSelect:o=>{if(o.value==="edit"){He(null),W("chat");let n=Je(2);_(a=>[...a,{id:Date.now(),role:"system",text:`\u2726 Flux waiting for new API Key...
|
|
203
|
+
\u2800`}])}else o.value==="remove"?W("deleteKey"):W("chat")}});case"deleteKey":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:"grey",paddingX:2,paddingY:1},(()=>{let o=Je(2);return e.createElement(i,{color:"white",bold:!0},"DANGER: CLEAR CREDENTIALS")})(),e.createElement(i,{marginTop:1},"This will permanently delete all saved API keys in credential cache. You will need to enter it again to use Flux."),e.createElement(c,{marginTop:1},e.createElement(xt,{title:"Are you sure?",items:[{label:"YES, CLEAR CREDENTIALS",value:"yes"},{label:"NO, GO BACK",value:"no"}],onSelect:async o=>{if(o.value==="yes"){await vi(),He(null),W("chat");let n=Je(2);_(a=>[...a,{id:Date.now(),role:"system",text:"[CREDENTIAL CLEARED] API Key removed successfully."}])}else W("key")},theme:de.theme})));case"exit":return null;case"ask":return e.createElement(c,{width:"100%"},e.createElement(ll,{question:Go?.question,options:Go?.options,onResolve:o=>{Go?.resolve&&Go.resolve(o),qr(null),W("chat")},theme:de.theme}));case"revert":return e.createElement(c,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(As,{prompts:Jl,onSelect:async o=>{s&&(s.write("\x1B[2J\x1B[3J\x1B[H"),s.isTTY&&s.write("\x1B[?2004h"));try{let n=await $n.rollbackToBefore(o);if(n.success){let{targetPrompt:a}=n;Ki(st),ts(d=>d+1),bo(),Vt.current={completedIndex:0,columns:X.columns,historicalBlocks:[],seenSelections:new Set,chatId:st,clearKey:jo+1};let g=pt.findLastIndex(d=>d.role==="user"&&d.text&&(d.text.startsWith(a)||d.text.includes(a))),u=[...pt];g!==-1&&(u=pt.slice(0,g)),_(u),V(u.length),m(a),M(a.split(`
|
|
204
|
+
`).length>2);let y=u.filter(d=>!String(d.id).startsWith("welcome")&&(!d.isMeta||d.text&&d.text.includes("Request Cancelled")));await gn(st,null,y);let f=Je(2);_(d=>{let w=[...d,{id:"revert-ok-"+Date.now(),role:"system",text:`\u2726 Rollback Successful
|
|
205
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Reverted prompt loaded to input box.
|
|
206
|
+
\u2800`,isMeta:!0}];return V(w.length),w}),W("chat")}}catch(n){let a=Je(2);_(g=>{let u=[...g,{id:"revert-err-"+Date.now(),role:"system",text:`\u2726 ERROR
|
|
207
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${n.message}
|
|
208
|
+
\u2800`,isMeta:!0}];return V(u.length),u}),W("chat")}},onClose:()=>W("chat"),theme:de.theme}));case"resume":return e.createElement(c,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(vs,{onSelect:async o=>{let n=await Po();if(n[o]){if(s.write("\x1B[2J\x1B[3J\x1B[H"),process.stdout.isTTY){let y=n[o]?.name||"",f=y&&!y.startsWith("flow-")&&!y.startsWith("Session ")?y:"FluxFlow | Resumed";process.stdout.write(`\x1B]0;${f}\x07`),process.stdout.write(`\x1B]633;P;TerminalTitle=${f}\x07`)}bo(),Vo.current=!0,sr(o);let a=await br(o);Sn.current=qt-a.total,Mn.current=io,En.current=on,Vo.current=!1,yn(a.total),Cn(0),vn(0),Ho({tokens:a.context});let g=[...n[o].messages];g[0]?.text?.includes("\u2591\u2591\u2591\u2588\u2588\u2588")||g.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),_(g),W("chat"),_(y=>{let f=[...y,{id:"sys-"+Date.now(),role:"system",text:`\u2726 SESSION RESUMED
|
|
209
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${o}
|
|
210
|
+
\u2800`,isMeta:!0}];return V(f.length),f})}},onDelete:async o=>await wr(o),onClose:()=>W("chat"),theme:de.theme}));case"keybindingsPrompt":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:"grey",paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:"white",bold:!0,underline:!0},"CONFIGURE SHIFT+ENTER NEWLINE"),e.createElement(i,null,`
|
|
211
|
+
`,"To support multi-line inputs with ",e.createElement(i,{bold:!0,color:"white"},"Shift + Enter")," for newline, a terminal sequence keybinding needs to be added to your IDE configuration.",`
|
|
212
|
+
|
|
213
|
+
`,"Would you like FluxFlow to automatically add this to your ",Jo()," keybindings?"),e.createElement(c,{marginTop:1},e.createElement(xt,{title:"Add Keybinding?",items:[{label:"Yes, configure automatically",value:"yes"},{label:"No, skip",value:"no"}],onSelect:async o=>{o.value==="yes"?await Or(Jo()):Ar="\\ + Enter",W("chat")},theme:de.theme})));case"memory":return e.createElement(c,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(Bs,{onClose:()=>W("chat"),theme:de.theme}));case"parserDownload":return e.createElement(c,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(Ds,{onClose:()=>W("settings")}));case"profile":return e.createElement(Ss,{initialData:bn,onSave:o=>{_s(o),_(n=>[...n,{id:Date.now(),role:"system",text:`${o.name.length>0||o.nickname.length>0?`\u2726 Profile Updated${o.name.length>0?`
|
|
214
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Name: ${o.name} `:""}${o.nickname.length>0?`
|
|
215
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Nickname: ${o.nickname}`:""}`:`\u2726 Profile
|
|
216
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Nothing to Update`}
|
|
217
|
+
|
|
218
|
+
\u2726 Custom Instructions
|
|
219
|
+
${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."}
|
|
220
|
+
\u2800`,isMeta:!0}]),W("chat")},onCancel:()=>W("chat"),theme:de.theme});case"resolution":return e.createElement(c,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(Vd,{data:Zl,theme:de.theme,onResolve:o=>{es(null),W("chat"),setTimeout(()=>{pi(o,!0)},500)},onEdit:o=>{es(null),W("chat"),m(o)}}));case"approval":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:"white",bold:!0,underline:!0},"FILE WRITE PERMISSION"),e.createElement(i,{marginTop:1},"The agent is attempting to modify: ",e.createElement(i,{color:"cyan"},Xn(Bo?.args||"{}").path||"Unknown File")),Qo()?e.createElement(c,{marginTop:1,paddingX:1},e.createElement(i,{color:"cyan",italic:!0},"FluxFlow Companion is active. Review the changes in your editor.")):e.createElement(c,{marginTop:1,borderStyle:"single",borderColor:"#333",paddingX:1,flexDirection:"column"},e.createElement(i,{color:"gray"},"--- PROPOSED CONTENT ---"),(()=>{let o=Xn(Bo?.args||"{}"),n=[],a=new Set;if(Object.keys(o).forEach(y=>{let f=y.match(/^(searchContent|replaceContent|newContent|content_to_replace|content_to_add|TargetContent|ReplacementContent|replacementContent)(\d+)?$/);if(f){let d=f[2]?parseInt(f[2]):1;a.add(d)}}),Array.from(a).sort((y,f)=>y-f).forEach(y=>{let f,d;y===1?(f=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):(f=o[`searchContent${y}`]??o[`replaceContent${y}`]??o[`content_to_replace${y}`]??null,d=o[`newContent${y}`]??o[`content_to_add${y}`]??null),(f!==null||d!==null)&&n.push({replace:f,new:d})}),n.length>0)return e.createElement(c,{flexDirection:"column",marginTop:1},n.map((y,f)=>{let d=y.replace!==null,w=y.new!==null;return e.createElement(c,{key:f,flexDirection:"column",marginTop:f>0?1:0},n.length>1&&e.createElement(i,{color:"gray"},"Block ",f+1,":"),d&&e.createElement(c,null,e.createElement(i,{color:"red",wrap:"anywhere",bold:!0},"- ",y.replace)),w&&e.createElement(c,{marginTop:0},e.createElement(i,{color:"green",wrap:"anywhere",bold:!0},"+ ",y.new.replace(/\[\/n\]?/g,"\\n"))))}));let u=o.content||o.ReplacementContent||o.content_to_add||o.replacementContent||o.newContent||null;return e.createElement(i,{color:"white",wrap:"anywhere"},(u?u.replace(/\[\/n\]?/g,"\\n"):null)||"Updating file content...")})()),e.createElement(c,{marginTop:1},e.createElement(xt,{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"&&Vl(!0);let n=o.value==="deny"?"deny":"allow";Bo.resolve(n),an(null),W("chat")},theme:de.theme})));case"mode":return e.createElement(xt,{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:de.theme,onSelect:o=>{if(o.value==="chat"||o.value==="Back"){W("chat");return}let n=o.value;L(n),Xe(n==="Flow"?"Fast":"High"),_(a=>(V(a.length+1),[...a,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${Ls(n)}
|
|
221
|
+
\u2800`,isMeta:!0}])),W("chat")},onClose:()=>W("chat")});case"display":return e.createElement(xt,{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:de.theme,onSelect:o=>{if(o.value==="chat"||o.value==="Back"){W("chat");return}let n=Number(o.value);k(n),Lt({display:n}).catch(()=>{});let a=n===0?"Primary (Display 1)":"Secondary (Display 2)";_(g=>(V(g.length+1),[...g,{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(xt,{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"?(_t({label:"Enter Custom Update Command (Global install recommended):",key:"customUpdateCommand",value:de.customUpdateCommand,next:n=>(At(a=>({...a,updateManager:"custom",customUpdateCommand:n})),null)}),W("input")):(At(n=>({...n,updateManager:o.value})),W("settings"))},theme:de.theme});case"update":return e.createElement(ul,{latest:Wt,current:no,settings:de,onClose:()=>W("chat"),onSuccess:()=>{_(o=>(V(o.length+1),[...o,{id:"update-success-"+Date.now(),role:"system",text:`**[UPDATE COMPLETED]** Flux Flow successfully updated to v${Wt}.
|
|
222
|
+
**Restart to see changes.**`,isMeta:!0}])),W("chat")},onUpdateSettings:o=>{W("updateManager")}});case"terminalApproval":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:"white",bold:!0,underline:!0},"TERMINAL COMMAND OVERSIGHT"),e.createElement(c,{marginTop:1},e.createElement(i,null,"Agent requested to run: ",e.createElement(i,{color:"yellow",bold:!0},Xn(Bo?.args||"{}").command||"Unknown Command"))),e.createElement(c,{marginTop:1},e.createElement(xt,{title:"Risk Assessment Required",items:[{label:"Run",value:"allow"},{label:"Deny",value:"deny"}],onSelect:o=>{Bo.resolve(o.value),an(null),W("chat")},theme:de.theme})));default:return e.createElement(c,{flexDirection:"column",marginTop:1,flexShrink:0,width:"100%"},ci&&di&&e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,paddingX:2,paddingY:1,width:"100%",marginBottom:1},e.createElement(c,{justifyContent:"space-between",width:"100%"},e.createElement(i,{color:l.text,bold:!0,underline:!0},"INQUIRY RESPONSE"),e.createElement(i,{color:l.textMuted},"[ ESC to Close ]")),e.createElement(c,{marginTop:1,width:"100%"},e.createElement(Yn,{text:di,columns:X.columns-6,theme:de.theme}))),Wr.filter(o=>o.status==="running").length>0&&e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,paddingX:2,paddingY:0,width:"100%",marginBottom:1},e.createElement(c,{justifyContent:"space-between",width:"100%"},e.createElement(i,{color:l.text,bold:!0},"ACTIVE SUBAGENTS")),e.createElement(c,{flexDirection:"column",marginTop:1,width:"100%"},Wr.filter(o=>o.status==="running").map(o=>e.createElement(qd,{key:o.id,sa:o,showTPMEstimate:de.showTPMEstimate})))),Un&&e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,paddingX:2,paddingY:0,width:"100%",marginBottom:0},e.createElement(c,{justifyContent:"space-between",width:"100%"},e.createElement(c,{flexDirection:"row",gap:1},e.createElement(i,{color:l.warning||"yellow",bold:!0},"\u2726 ",Un.startsWith("/btw")?"Question Queued":"Steering Hint Queued"))),e.createElement(c,{marginTop:0,paddingLeft:2},e.createElement(i,{color:l.text,bold:!0},"\u2514\u2500 ",Un.startsWith("/btw")?Un.replace(/^\/btw\s*/,""):Un))),e.createElement(c,{paddingX:1,marginBottom:0,justifyContent:"space-between",width:"100%"},e.createElement(c,null,On?e.createElement(c,{gap:1},e.createElement(Ud,null),e.createElement(zn,{text:On.trimEnd(),baseColor:l.textExclusive||l.text,glintColor:l.textMutedExclusive||l.textMuted,speed:60,italic:!0,glintWidth:2,typeSpeed:10}),e.createElement(i,{color:l.textMuted},ri>0?`(${ri.toFixed(0)}s)`:"")):e.createElement(i,{color:l.textMuted,italic:!0},I.length>0&&li?"Press ESC again to clear input":jl?"Press CTRL + O to expand":"Waiting for input...")),e.createElement(c,null,(()=>{let o=On?.toLowerCase()??"";return dn&&Date.now()-Xs>15e3&&Wr.length===0&&(o.includes("connecting")||o.includes("working")||o.includes("queue"))?e.createElement(c,null,e.createElement(zn,{text:"Waiting for API",baseColor:l.text,glintColor:l.textMuted,glintWidth:4,speed:80}),e.createElement(i,{color:l.textMuted,dimColor:!0}," \u2503 ")):zr?e.createElement(c,null,e.createElement(zn,{text:zr,baseColor:l.text,glintColor:l.textMuted,italic:!0,speed:80,typeSpeed:15}),e.createElement(i,{color:l.textMuted,dimColor:!0}," \u2503 ")):null})(),e.createElement(zn,{text:Et.basename(je)||(je.length>1?je:"Use '/model model-id' to select model"),baseColor:l.text,glintColor:l.textMuted,glintWidth:3}),e.createElement(i,{color:l.textMuted}," ",je.length>0?`(${xe})`:""),Tr>0&&e.createElement(i,{color:l.textMuted}," [",Tr," ",Tr===1?"file":"files","]"))),e.createElement(c,{flexDirection:"column",width:"100%"},e.createElement(c,{width:"100%",height:1,overflow:"hidden"},e.createElement(i,{color:l.inputBorder},"\u2584".repeat(Math.max(1,X.columns)))),e.createElement(c,{backgroundColor:l.inputBg,paddingX:1,paddingY:0,width:"100%",flexDirection:"column"},e.createElement(c,{flexDirection:"column",width:"100%"},e.createElement(c,{flexDirection:"row",width:"100%",paddingY:0},e.createElement(c,{flexShrink:0,width:4},e.createElement(i,{color:l.inputPrompt,bold:!0},dn||ar?"\u2726 ":" \u276F ")),e.createElement(c,{flexGrow:1},e.createElement(c,{flexGrow:1,position:"relative"},I===""&&e.createElement(c,{position:"absolute",paddingLeft:0},eo&&!Ln?e.createElement(i,{color:"yellow"},oa?" Terminal is waiting for user input. Press TAB to interact":" Press TAB to interact with terminal..."):eo&&Ln?e.createElement(i,{color:"yellow",bold:!0}," [ TERMINAL FOCUSED ] Type to interact, press TAB to exit..."):li===1?e.createElement(i,{color:l.inputPrompt,bold:!0}," Press ESC again to ",I.length>0?"clear input":"revert codebase to checkpoint","..."):e.createElement(i,{color:l.inputPlaceholder},Ql?" Press ESC again to cancel the request.":ar?" Compacting session history, please wait...":dn?" Enter a prompt to steer the agent.":` Send message, @file or /cmd (${Wl.shortcut} for newline)`)),e.createElement(Qi,{key:`input-${v}`,onPasteStateChange:Kl,focus:!Ln&&!ar,showCursor:gt&&!ar,cursorColor:l.inputText,lastFocusEventTime:Ne.current,value:I,textStyle:{bold:!0,color:l.inputText},columns:X.columns,onChange:o=>{let n=o.replace(/\r\n/g,`
|
|
223
|
+
`).replace(/\r/g,`
|
|
224
|
+
`).replace(/\\\s*\n/g,`
|
|
225
|
+
`);m(n),q(!1)},onSubmit:pi,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(c,{width:"100%",height:1,overflow:"hidden"},e.createElement(i,{color:l.inputBorder},"\u2580".repeat(Math.max(1,X.columns))))))}};return e.createElement(c,{flexDirection:"column",width:"100%"},ge?null:re?e.createElement(Gd,{width:s?.columns||80,height:s?.rows||24,selectedIndex:De,aiProvider:P,theme:de.theme}):e.createElement(e.Fragment,null,e.createElement(c,{paddingX:1,flexDirection:"column",width:"100%"},e.createElement(Fd,{key:`static-${jo}-${st}-${X.columns}-${X.rows}-${de.theme}`,items:fi.completed},o=>e.createElement(vr,{key:o.key,block:o,columns:(s?.columns||80)-2,showFullThinking:Zo,aiProvider:P,version:no,theme:de.theme}))),e.createElement(c,{flexDirection:"column",paddingX:1,paddingBottom:0,width:"100%"},(dt==="chat"||["ask","approval","terminalApproval"].includes(dt))&&e.createElement(c,{flexDirection:"column",width:"100%"},fi.active.map(o=>e.createElement(vr,{key:o.key,block:o,columns:Math.max(20,(s?.columns||80)-2),showFullThinking:Zo,aiProvider:P,version:no,theme:de.theme})),eo&&e.createElement(c,{marginTop:1},e.createElement(Mr,{command:eo,output:sn,isFocused:Ln,isPty:mn,terminalHeight:X.rows,columns:X.columns}))),ge?e.createElement(c,{borderStyle:"double",borderColor:"grey",padding:1,flexShrink:0},e.createElement(i,{color:"white"},"Starting Flux Flow...")):St?na():e.createElement(c,{borderStyle:"round",borderColor:"white",padding:0,flexDirection:"column",flexShrink:0,width:"100%"},e.createElement(c,{paddingX:1,marginBottom:1},e.createElement(i,{color:"gray",bold:!0},"API KEY REQUIRED")),e.createElement(c,{paddingX:1,flexDirection:"column"},mt===0?e.createElement(e.Fragment,null,e.createElement(i,{color:"white"},"Select your Preferred Provider:"),e.createElement(c,{marginTop:1},e.createElement(xt,{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=>{ut(o.value),Ut(1)}}))):e.createElement(e.Fragment,null,e.createElement(i,{color:"white"},P==="Ollama"?"Enter Ollama API Key (or type LOCAL to use local host):":`Enter your ${P} API Key:`),e.createElement(c,{marginTop:1},e.createElement(i,{color:"gray",bold:!0}," ",">"," "),e.createElement(kr,{value:Zt,onChange:ro,onSubmit:hi,mask:"*"})))),e.createElement(c,{paddingX:1,marginTop:1},e.createElement(i,{color:"gray",italic:!0},mt===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(c,{borderStyle:"round",borderColor:l.borderMuted,paddingX:1,marginY:0,width:"100%"},e.createElement(i,null,e.createElement(i,{color:"red",bold:!0},"\u{1F534} EXIT: "),e.createElement(i,{color:l.text},"Press "),e.createElement(i,{color:l.text,bold:!0},"CTRL+C"),e.createElement(i,{color:l.text}," again to exit (",p,"s) \u2022 Press "),e.createElement(i,{color:l.textMuted,bold:!0},"ESC"),e.createElement(i,{color:l.text}," to cancel"))),Ge.length>0&&(()=>{let n=me.current,a=0;for(;a<Ge.length;){let y=Ge[a],f=y?.cmd||y||"";if(typeof f=="string"&&f.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,Ge.length-5))),me.current=n;let g=Ge.slice(n,n+5),u=Ge.length-(n+g.length);return e.createElement(c,{flexDirection:"column",width:"100%",marginBottom:1},e.createElement(c,{paddingX:1,marginBottom:0,justifyContent:"space-between",width:"100%"},e.createElement(i,{color:l.text,bold:!0},Ge[0]?.cmd?.startsWith("@")||Ge[0]?.cmd?.startsWith("\\@")?"FILE SUGGESTIONS":"COMMAND SUGGESTIONS"),Ge[0]?.cmd?.startsWith("@")||Ge[0]?.cmd?.startsWith("\\@")?e.createElement(i,{color:l.textMuted,italic:!0},"(Use #Lstart-Lend to specify line numbers)"):I.startsWith("/model")&&rt==="Free"?(()=>{let y="https://aistudio.google.com/billing",f="billing";P==="DeepSeek"?(y="https://platform.deepseek.com/usage",f="billing"):P==="OpenRouter"?(y="https://openrouter.ai/settings/profile",f="profile"):P==="NVIDIA"?(y="https://build.nvidia.com/settings/api-keys",f="billing"):P==="CrofAI"?(y="https://crof.ai",f="account"):P==="Poolside"&&(y="https://inference.poolside.ai",f="account")})():null),g.slice(0,ur).map((y,f)=>{let w=n+f===le,B=typeof y.cmd=="string"&&y.cmd.trimStart().startsWith("---"),$=y.cmd===ao("Google","Free")&&rt!=="Free";return e.createElement(c,{key:y.cmd,flexDirection:"row",backgroundColor:w?l.highlightBg:void 0,paddingX:1},e.createElement(c,{width:3},e.createElement(i,{color:w?l.text:l.textMuted,bold:w},w?" \u276F":" ")),e.createElement(c,{width:55},e.createElement(i,{color:B?l.textDim:$?l.textMuted:w?l.text:l.textDim,bold:!1},y.display||(y.cmd&&(y.cmd.startsWith("@[")||y.cmd.startsWith("\\@["))&&y.cmd.endsWith("]")?(()=>{let ae=(y.cmd.startsWith("\\@[")?y.cmd.slice(3,-1):y.cmd.slice(2,-1)).split(/[/\\]/);return ae[ae.length-1]})():y.cmd&&y.cmd.includes("/")?y.cmd.split("/").pop():y.cmd))),e.createElement(c,{flexGrow:1},e.createElement(i,{color:w?l.text:l.textMuted,italic:!0},y.desc)))}),Ge.length>5&&e.createElement(c,{paddingX:1,height:1},u>0?e.createElement(i,{color:l.textMuted,dimColor:!0,italic:!0}," ... (",u," more commands available)"):e.createElement(i,{color:l.textMuted,dimColor:!0,italic:!0}," (End of list)")))})(),e.createElement(c,{flexShrink:0,width:"100%"},e.createElement(rl,{mode:D,thinkingLevel:xe,tokens:so.tokens,tokensTotal:Al,cachedTokens:Ll,promptTokens:Ol,ther:!0,chatId:st,isMemoryEnabled:de.memory,apiTier:rt,aiProvider:P,activeModel:je,isProcessing:dn,lastChunkTime:Xs,theme:de.theme,wps:Xr.current.wps,showTPMEstimate:de.showTPMEstimate})),dt==="exit"&&(()=>{let o=Date.now()-Os,n=Mt.toolSuccess+Mt.toolFailure,a=n>0?(Mt.toolSuccess/n*100).toFixed(1):"0.0",g=tr+or,u=g>0?(tr/g*100).toFixed(1):"0.0",y=g>0?(or/g*100).toFixed(1):"0.0";return e.createElement(c,{flexDirection:"column",borderStyle:"round",paddingX:3,paddingY:1,borderColor:l.borderMuted,width:Math.min(100,(s?.columns||100)-2),marginTop:0,marginBottom:0},e.createElement(c,{marginBottom:1},e.createElement(i,{bold:!0},Xd(l.logoGradient||["blue","purple"])("Agent powering down. Goodbye!"))),e.createElement(c,{flexDirection:"column"},e.createElement(i,{color:l.text,bold:!0,underline:!0},"Interaction Summary"),e.createElement(c,{marginTop:1},e.createElement(c,{width:20},e.createElement(i,{color:l.secondary},"Session ID:")),e.createElement(i,{color:l.text},st)),e.createElement(c,null,e.createElement(c,{width:20},e.createElement(i,{color:l.secondary},"Tool Calls:")),e.createElement(i,{color:l.text},Mt.toolSuccess+Mt.toolFailure+Mt.toolDenied," ( ",e.createElement(i,{color:"green"},"\u2714 ",Mt.toolSuccess)," ",e.createElement(i,{color:"yellow"},"\u{1F6C7} ",Mt.toolDenied)," ",e.createElement(i,{color:"red"},"\u2718 ",Mt.toolFailure)," )")),e.createElement(c,null,e.createElement(c,{width:20},e.createElement(i,{color:l.secondary},"Success Rate:")),e.createElement(i,{color:l.text},a,"%")),e.createElement(c,null,e.createElement(c,{width:20},e.createElement(i,{color:l.secondary},"Code Changes:")),e.createElement(i,{color:l.text},e.createElement(i,{color:"green"},"+",Mt.linesAdded)," ",e.createElement(i,{color:"red"},"-",Mt.linesRemoved))),qt>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:20},e.createElement(i,{color:l.secondary},"Tokens Consumed:")),e.createElement(i,{color:l.text},ft(qt))),e.createElement(c,{marginLeft:2},e.createElement(c,{width:18},e.createElement(i,{color:l.textMuted},"\xBB Input Tokens:")),e.createElement(i,{color:l.text},ft(qt-nn))),io>0&&e.createElement(c,{marginLeft:4},e.createElement(c,{width:16},e.createElement(i,{color:l.textMuted},"\xBB Cached:")),e.createElement(i,{color:l.text},ft(io))),nn>0&&e.createElement(c,{marginLeft:2},e.createElement(c,{width:18},e.createElement(i,{color:l.textMuted},"\xBB Output Tokens:")),e.createElement(i,{color:l.text},ft(nn)))),nr>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:20},e.createElement(i,{color:l.secondary},"Images Made:")),e.createElement(i,{color:l.text},nr)),e.createElement(c,null,e.createElement(c,{width:20},e.createElement(i,{color:l.secondary},"Image Credits:")),e.createElement(i,{color:l.text},Number(((qs||0)*1e3).toFixed(0))," credits")))),e.createElement(c,{flexDirection:"column",marginTop:1},e.createElement(i,{color:l.text,bold:!0,underline:!0},"Performance"),e.createElement(c,{marginTop:1},e.createElement(c,{width:20},e.createElement(i,{color:l.secondary},"Wall Time:")),e.createElement(i,{color:l.text},Wo(o))),e.createElement(c,null,e.createElement(c,{width:20},e.createElement(i,{color:l.secondary},"Agent Active:")),e.createElement(i,{color:l.text},Wo(g))),e.createElement(c,{marginLeft:2},e.createElement(c,{width:18},e.createElement(i,{color:l.textMuted},"\xBB API Time:")),e.createElement(i,{color:l.text},Wo(tr)," (",u,"%)")),e.createElement(c,{marginLeft:2},e.createElement(c,{width:18},e.createElement(i,{color:l.textMuted},"\xBB Tool Time:")),e.createElement(i,{color:l.text},Wo(or)," (",y,"%)"))))})())))}export{Qd as default};
|