fluxflow-cli 4.36.0 → 4.36.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{ai-DUQ7JTFT.js → ai-CADJB6OC.js} +1 -1
- package/dist/chunks/app-VYIYEEZN.js +323 -0
- package/dist/chunks/chunk-BGIZLZQF.js +1 -0
- package/dist/chunks/{chunk-EKTQJIFL.js → chunk-IS6NOF47.js} +1 -1
- package/dist/chunks/{chunk-HWQD4HC4.js → chunk-OA7SWSBR.js} +1 -1
- package/dist/chunks/{chunk-PUCRX3HD.js → chunk-PQINB4JW.js} +5 -5
- package/dist/chunks/{chunk-NXGWQV2R.js → chunk-QWEEC3PP.js} +1 -1
- package/dist/chunks/{chunk-ARVJHIPP.js → chunk-QYNGDXPT.js} +1 -1
- package/dist/chunks/{click-YDLHTDEK.js → click-PNIGPARB.js} +2 -2
- package/dist/chunks/{computer_action-2JLV6MY4.js → computer_action-WORDXIQY.js} +1 -1
- package/dist/chunks/{drag-PUEGJCAB.js → drag-LC3MFJZ7.js} +1 -1
- package/dist/chunks/{generate_image-L2LXNTNE.js → generate_image-EKX5PUUR.js} +1 -1
- package/dist/chunks/{invoke-7S44ZFQY.js → invoke-AQ3E3T5N.js} +2 -2
- package/dist/chunks/{invokeSync-SAKOE3G5.js → invokeSync-AVVEKI3J.js} +2 -2
- package/dist/chunks/{key_press-KR2O7S6E.js → key_press-PDKXVENN.js} +1 -1
- package/dist/chunks/{keyboard_typing-V4ALD3BD.js → keyboard_typing-UTFSDB4P.js} +1 -1
- package/dist/chunks/{mistral-O5VGMA23.js → mistral-LNEFQAV5.js} +1 -1
- package/dist/chunks/{model_config-C72R7DKL.js → model_config-55WPIUYV.js} +1 -1
- package/dist/chunks/{nvidia-OVQSNJOT.js → nvidia-GMX2ROSD.js} +1 -1
- package/dist/chunks/{screen_grid-XZKZBWOH.js → screen_grid-PVVRYV5G.js} +1 -1
- package/dist/chunks/{scroll-YTLIQ6C5.js → scroll-UPGZCBPD.js} +1 -1
- package/dist/chunks/{settings-LO76WAO4.js → settings-GLFTNEAT.js} +1 -1
- package/dist/chunks/{update_file-HGCNRGTK.js → update_file-NBLTUYHL.js} +1 -1
- package/dist/chunks/{usage-MHRBABMW.js → usage-CAY5LYRU.js} +1 -1
- package/dist/chunks/{usageServer-YSHTV2E3.js → usageServer-PJOHIWJT.js} +44 -9
- package/dist/chunks/{write_file-A67UXLZ2.js → write_file-FZZRCU3L.js} +1 -1
- package/dist/cli.js +3 -3
- package/dist/package.json +1 -1
- package/package.json +1 -1
- package/dist/chunks/app-3RT5WIFW.js +0 -322
- package/dist/chunks/chunk-NJADNSYK.js +0 -1
|
@@ -1,322 +0,0 @@
|
|
|
1
|
-
import{A as ml,a as Qi,b as st,c as mt,d as Lr,e as Or,f as el,g as As,h as mn,i as Nr,s as al,v as dl,w as Fo,y as cl,z as ul}from"./chunk-PUCRX3HD.js";import{a as xl}from"./chunk-UEV335RW.js";import{a as qt,b as Zi,c as Ri}from"./chunk-JS5ZIGFR.js";import"./chunk-7SFAWGE2.js";import{b as rl,c as sl,d as il}from"./chunk-SZYN3VHU.js";import{a as ll}from"./chunk-56EJGQU3.js";import{a as kt,b as pt,d as ji,e as Tt,f as Ki,j as vs,k as Ds,l as or,m as qi,n as No}from"./chunk-4MDSKJGX.js";import{c as zi,e as Pn,f as to,g as Ji}from"./chunk-MTPBPPXV.js";import"./chunk-KAL5XSAQ.js";import{a as nl}from"./chunk-A73NNVCZ.js";import{a as Qo,b as Nn,d as Pr,e as Is,f as tl,h as ol,i as sr}from"./chunk-VYTQ6J56.js";import"./chunk-RZTZPIC5.js";import{a as rr}from"./chunk-FQBBOFNP.js";import{a as nr}from"./chunk-Y5JU726N.js";import{b as qo,c as Ss,k as Xi}from"./chunk-KHCAQOSP.js";import{a as Gi,b as Wi,i as Vi,j as Ar,k as kr,m as Mt,n as un,o as Bs,u as Yi}from"./chunk-HWQD4HC4.js";import{a as Es,b as Ot}from"./chunk-NXGWQV2R.js";import{d as Oi,e as Pi,f as Ni,g as Fi,h as Ui,i as $i,j as _i,l as Ir,n as Ko,o as eo,p as Ms,q as Hi}from"./chunk-NJADNSYK.js";import{c as vr,d as Li,e as Dr}from"./chunk-L3W2X74K.js";import{a as fo,b as cn,c as yo,d as ys,e as Cs,k as tr}from"./chunk-DSVLWYIT.js";import Qs from"os";import e,{useState as Z,useEffect as ut,useRef as ot,useMemo as Hn}from"react";import{Box as c,Text as i,useInput as nc,useStdout as rc,Static as sc}from"ink";import ic from"ink-spinner";import ct from"fs-extra";import It from"path";import{exec as Do}from"child_process";import{fileURLToPath as lc}from"url";import Wt,{useState as Fr,useEffect as ks,useMemo as ir,useCallback as Da,useRef as Uo}from"react";import{Box as Ia,Text as go,useInput as Aa}from"ink";function ka(t,f){return t.replace(/\t/g," ".repeat(f))}function Ur(t){return t==null?"":t.replace(/\r\n/g,`
|
|
2
|
-
`).replace(/\r/g,`
|
|
3
|
-
`)}function xn(t,f,g){let E=t,y=[...f].sort((l,w)=>l.start-w.start),p=0;for(let l of y){let w=l.start-p,T=Ur(l.text).split(`
|
|
4
|
-
`).length,S=l.text.length,N=(T>3?`[Pasted ${T} lines]`:`[Pasted ${S} chars]`).length,O=w+N;if(t<=w)break;if(t<O){E=l.end;break}else{let B=l.text.length-N;E+=B,p+=B}}return Math.min(E,g.length)}function Ls(t,f,g,E,y=[]){let p=(t||"").slice(0,f),l=E(p).length,w=E(t||""),T=[...y].sort(($,L)=>L.start-$.start);for(let $ of T){let L=E(t.slice(0,$.start)).length,W=E($.text),q=L+W.length,de=Ur($.text).split(`
|
|
5
|
-
`).length,ue=$.text.length,R=de>3?`[Pasted ${de} lines]`:`[Pasted ${ue} chars]`;w=w.slice(0,L)+R+w.slice(q),l>L&&l<q?l=L+R.length:l>=q&&(l=l-(q-L)+R.length)}let S=w.split(`
|
|
6
|
-
`),N=[],O=0,B=0,I=0,F=!1;for(let $=0;$<S.length;$++){let L=S[$];if(L.length===0){!F&&l===O&&(B=N.length,I=0,F=!0),N.push({text:"",globalStart:xn(O,y,t),formattedStart:O}),O+=1;continue}let q=pt(L,g).split(`
|
|
7
|
-
`),de=0,ue=[];for(let R=0;R<q.length;R++){let oe=q[R],me=oe.trim();if(me.length===0){let Me=oe.length||1;ue.push({text:oe,start:de,length:Me}),de+=Me}else{let Me=L.indexOf(me,de);if(Me!==-1){let Xe=de,Ve=R<q.length-1?q[R+1].trim():"",pe=L.length;if(Ve.length>0){let Te=L.indexOf(Ve,Me+me.length);Te!==-1&&(pe=Te)}ue.push({text:L.slice(Xe,pe),start:Xe,length:pe-Xe}),de=pe}else ue.push({text:oe,start:de,length:oe.length}),de+=oe.length}}for(let R=0;R<ue.length;R++){let oe=ue[R],me=oe.text,Me=O+oe.start,Xe=Me+oe.length;!F&&l>=Me&&(l<Xe||l===Xe&&R===ue.length-1)&&(B=N.length,I=l-Me,F=!0),N.push({text:me,globalStart:xn(Me,y,t),formattedStart:Me})}O+=L.length+1}return F||(N.length===0?N.push({text:"",globalStart:0,formattedStart:0}):w.endsWith(`
|
|
8
|
-
`)?(N.push({text:"",globalStart:xn(O,y,t),formattedStart:O}),B=N.length-1,I=0):(B=N.length-1,I=N[B].text.length)),{visualLines:N,cursorLine:B,cursorCol:I}}var La=({value:t,rows:f,maxRows:g,highlightStyle:E,textStyle:y,placeholder:p="",mask:l,showCursor:w=!0,focus:T=!0,tabSize:S=4,cursorIndex:N=0,highlight:O,columns:B=80,pasteBlocks:I=[],cursorColor:F})=>{let $=Uo(0),L=ir(()=>Math.max(20,B-10),[B]),W=Da((Ke,Ge=!1)=>{let Y=Ur(Ke);if(!Ge&&l)return Y.replace(/[^\n]/g,l);let ne=ka(Y,S);return Ge?ne:ne.replace(/@\[(.*?)\]/g,(ee,ae)=>{let Ce=ae.indexOf("#"),ye=ae.indexOf(":L"),Ne=ae,et="";Ce!==-1?(Ne=ae.slice(0,Ce),et=ae.slice(Ce)):ye!==-1&&(Ne=ae.slice(0,ye),et=ae.slice(ye));let lt=Ne.replace(/\\/g,"/"),Ie=(process.cwd()||"").replace(/\\/g,"/");Ie&<.toLowerCase().startsWith(Ie.toLowerCase()+"/")?lt=lt.slice(Ie.length+1):lt.startsWith("./")&&(lt=lt.slice(2));let ie=lt.split("/");return`[${ie[ie.length-1]}${et}]`})},[S,l]),{visualLines:q,cursorLine:de,cursorCol:ue}=ir(()=>Ls(t,N,L,W,I),[t,N,L,W,I]),R=q.length,oe=ir(()=>Math.max(f??g??1,Math.min(g??f??1,R)),[f,g,R]),me=de+1,Me=$.current+oe,Xe=$.current;me<=$.current?Xe=Math.max(0,me-1):me>Me?Xe=me-oe:R&&(R<oe?Xe=0:R<Me&&(Xe=R-oe)),$.current=Xe;let Ve=ir(()=>q.slice(Xe,Xe+oe),[q,Xe,oe]),[pe,Te]=Fr(!0);ks(()=>{if(Te(!0),!T||!w)return;let Ke=setInterval(()=>{Te(Ge=>!Ge)},530);return()=>clearInterval(Ke)},[T,w,t,N]);let we=ir(()=>({...y,color:w&&T&&pe?F||"white":void 0,bold:w&&T&&pe,inverse:w&&T&&pe}),[y,w,T,pe,F]),le=(Ke,Ge,Y,ne)=>{if(!Ke){let Ne=p&&t.length===0?W(p,!0):"";if(Ge){let et=Ne[0]||" ",lt=Ne.slice(1);return Wt.createElement(go,null,Wt.createElement(go,{...ne},et),Wt.createElement(go,{color:"gray",dimColor:!0},lt))}return Wt.createElement(go,{color:"gray",dimColor:!0},Ne||" ")}let ee=/(\[Pasted \d+ (?:lines|chars)\])/g,ae=Ke.split(ee),Ce=0,ye=[];for(let Ne=0;Ne<ae.length;Ne++){let et=ae[Ne];if(et==="")continue;let lt=et.match(/^\[Pasted \d+ (?:lines|chars)\]$/),Ie=et.length,ie=Ce+Ie;if(Ge&&Y>=Ce&&Y<ie){let fe=Y-Ce,De=et.slice(0,fe),v=et[fe]||" ",Ue=et.slice(fe+1);ye.push(Wt.createElement(go,{key:Ne},Wt.createElement(go,{color:lt?"magenta":void 0},De),Wt.createElement(go,{...ne},v),Wt.createElement(go,{color:lt?"magenta":void 0},Ue)))}else ye.push(Wt.createElement(go,{key:Ne,color:lt?"magenta":void 0},et));Ce=ie}return Ge&&Y>=Ke.length&&ye.push(Wt.createElement(go,{key:"cursor-end",...ne}," ")),Wt.createElement(Wt.Fragment,null,ye)};return Wt.createElement(Ia,{height:oe,width:L+1,overflow:"hidden",flexDirection:"column",flexGrow:0,flexShrink:0},Ve.map((Ke,Ge)=>{let Y=Xe+Ge,ne=Y===de&&T&&w;return Wt.createElement(go,{key:Y,...y,wrap:"truncate"},le(Ke.text,ne,ue,we))}))},fl=({value:t,onChange:f,onSubmit:g,keyBindings:E,showCursor:y=!0,highlightPastedText:p=!1,focus:l=!0,columns:w=80,useCustomInput:T=(B,I)=>Aa(B,{isActive:I}),onPasteStateChange:S,cursorColor:N,...O})=>{let[B,I]=Fr(t.length),[F,$]=Fr(0),[L,W]=Fr([]),q=Uo(t.length),de=Uo(t),ue=Uo(0),R=Uo([]),oe=Uo(""),me=Uo(-1),Me=Uo(null),Xe=Uo(0);q.current=B,de.current=t,ue.current=F,R.current=L,ks(()=>{q.current>t.length&&(q.current=t.length,I(t.length)),t?W(Te=>Te.filter(we=>we.end<=t.length&&we.start<=t.length)):(W([]),$(0))},[t]),ks(()=>{S?.(L.length>0)},[L,S]);let Ve=()=>{let Te=oe.current,we=me.current,le=we+Te.length,Ke=de.current,Ge=Ke.slice(0,we)+Te+Ke.slice(we);f(Ge),q.current=le,I(le),$(Te.length>1?Te.length:0);let Y=Ur(Te).split(`
|
|
9
|
-
`).length,ne=Te.length;if(ne>50&&(Y>3||Y<=3&&ne>200)){let ee={start:we,end:le,text:Te};W(ae=>{let Ce=Te.length;return[...ae.map(Ne=>we<=Ne.start?{...Ne,start:Ne.start+Ce,end:Ne.end+Ce}:Ne),ee]})}oe.current="",me.current=-1,Me.current=null},pe=()=>{Me.current&&(clearTimeout(Me.current),Ve())};return T((Te,we)=>{if(Te==="\x1B[I"||Te==="\x1B[O"||Te==="[I"||Te==="[O")return;let le=Te,Ke=!1,Ge=!1;le&&typeof le=="string"&&(le.includes("\x1B[200~")&&(Ke=!0,le=le.replace(/\x1b\[200~/g,"")),le.includes("\x1B[201~")&&(Ge=!0,le=le.replace(/\x1b\[201~/g,"")));let Y=q.current,ne=de.current,ee=R.current,ae=Math.max(20,w-10),Ce=(ie,fe)=>{if(ee.length===0)return;let De=ee.map(v=>ie<=v.start?{...v,start:v.start+fe,end:v.end+fe}:ie>v.start&&ie<v.end?null:v).filter(Boolean);W(De)},ye=ie=>{for(let fe of ee)if(ie>fe.start&&ie<fe.end)return fe.start;return ie};if(we.ctrl&&(le==="o"||le==="")){W([]);return}if(we.ctrl&&(le.toLowerCase()==="r"||le===""||le===""))return;if(we.upArrow||we.downArrow||we.leftArrow||we.rightArrow){pe();let ie=Date.now();if(ie-Xe.current<33)return;Xe.current=ie}let et=E?.submit??(ie=>ie.return&&ie.ctrl),lt=E?.newline??(ie=>ie.return);if(et(we)){pe(),g?.(ne);return}else if(lt(we)){pe(),Ce(Y,1);let ie=ne.slice(0,Y)+`
|
|
10
|
-
`+ne.slice(Y);f(ie),q.current=Y+1,I(Y+1),$(0);return}if(we.tab||we.shift&&we.tab||we.ctrl&&le==="c")return;let Ie=ie=>ie;if(we.upArrow||we.downArrow){if(pe(),y){let{visualLines:ie,cursorLine:fe,cursorCol:De}=Ls(ne,Y,ae,Ie,ee),v=we.upArrow?fe-1:fe+1;if(v>=0&&v<ie.length){let Ue=ie[v],nt=Math.min(De,Ue.text.length),At=Ue.formattedStart+nt,zt=xn(At,ee,ne);zt=ye(zt),q.current=zt,I(zt),$(0)}else if(we.upArrow&&fe===0)q.current=0,I(0),$(0);else if(we.downArrow&&fe===ie.length-1){let Ue=ie[ie.length-1],nt=Ue.formattedStart+Ue.text.length,At=xn(nt,ee,ne);At=ye(At),q.current=At,I(At),$(0)}}}else if(we.leftArrow){if(pe(),y){let ie=Math.max(0,Y-1),fe=ee.find(De=>Y===De.end);fe&&(ie=fe.start),q.current=ie,I(ie),$(0)}}else if(we.rightArrow){if(pe(),y){let ie=Math.min(ne.length,Y+1),fe=ee.find(De=>Y===De.start);fe&&(ie=fe.end),q.current=ie,I(ie),$(0)}}else if(we.backspace){pe();let ie=ee.findIndex(fe=>Y===fe.end);if(ie!==-1){let fe=ee[ie],De=-(fe.end-fe.start),v=ne.slice(0,fe.start)+ne.slice(fe.end);f(v),q.current=fe.start,I(fe.start),$(0);let Ue=ee.filter((nt,At)=>At!==ie).map(nt=>nt.start>=fe.end?{...nt,start:nt.start+De,end:nt.end+De}:nt);W(Ue)}else if(Y>0){Ce(Y-1,-1);let fe=ne.slice(0,Y-1)+ne.slice(Y);f(fe),q.current=Y-1,I(Y-1),$(0)}}else if(we.delete){pe();let ie=ee.findIndex(fe=>Y===fe.start);if(ie!==-1){let fe=ee[ie],De=-(fe.end-fe.start),v=ne.slice(0,fe.start)+ne.slice(fe.end);f(v),$(0);let Ue=ee.filter((nt,At)=>At!==ie).map(nt=>nt.start>=fe.end?{...nt,start:nt.start+De,end:nt.end+De}:nt);W(Ue)}else if(Ce(Y,-1),Y<ne.length){let fe=ne.slice(0,Y)+ne.slice(Y+1);f(fe),$(0)}}else if(we.home||we.end){if(pe(),y){let{visualLines:ie,cursorLine:fe}=Ls(ne,Y,ae,Ie,ee),De=ie[fe];if(De){let v;we.home?v=xn(De.formattedStart,ee,ne):we.end&&(v=xn(De.formattedStart+De.text.length,ee,ne)),v=ye(v),q.current=v,I(v),$(0)}}}else if(le!==""||Ke||Ge)if(Ke||Ge||le.length>1||Me.current!==null)Me.current?(clearTimeout(Me.current),oe.current+=le):(me.current=Y,oe.current=le),Ge?(Me.current=null,Ve()):Me.current=setTimeout(()=>{Ve()},80);else{Ce(Y,le.length);let fe=ne.slice(0,Y)+le+ne.slice(Y);f(fe);let De=Y+le.length;q.current=De,I(De),$(0)}},l),Wt.createElement(La,{...O,value:t,cursorIndex:B,showCursor:y,focus:l,columns:w,pasteBlocks:L,cursorColor:N})};import Xn from"ink-text-input";import"ink-select-input";import s from"react";import{Box as A,Text as se}from"ink";import Bt,{useState as gl,useEffect as Oa}from"react";import{Box as $o,Text as ho,useInput as Pa}from"ink";var $r=Bt.memo(({command:t,output:f,completed:g=!1,isFocused:E=!1,columns:y=80,isPty:p=!1,terminalHeight:l=24,theme:w="Dark"})=>{let T=st(w),N=(ne=>{if(!ne)return"";let ee=[[]],ae=0,Ce=0,ye="",Ne=/\x1b\[([0-9;]*?)([a-zA-Z])/g,et=0,lt,Ie=fe=>{for(let De=0;De<fe.length;De++){let v=fe[De];if(v===`
|
|
11
|
-
`)for(ae++,Ce=0;ae>=ee.length;)ee.push([]);else if(v==="\r")Ce=0;else{for(;ae>=ee.length;)ee.push([]);let Ue=ee[ae];for(;Ce>Ue.length;)Ue.push({char:" ",style:""});Ue[Ce]={char:v,style:ye},Ce++}}};for(;(lt=Ne.exec(ne))!==null;){Ie(ne.substring(et,lt.index));let fe=lt[1],De=lt[2],v=fe?fe.split(";").map(Number):[];if(De==="A"){let Ue=v[0]||1;ae=Math.max(0,ae-Ue)}else if(De==="B"){let Ue=v[0]||1;for(ae=ae+Ue;ae>=ee.length;)ee.push([])}else if(De==="C"){let Ue=v[0]||1;Ce=Ce+Ue}else if(De==="D"){let Ue=v[0]||1;Ce=Math.max(0,Ce-Ue)}else if(De==="G"){let Ue=(v[0]||1)-1;Ce=Math.max(0,Ue)}else if(De==="H"||De==="f"){let Ue=(v[0]||1)-1,nt=(v[1]||1)-1;for(ae=Math.max(0,Ue),Ce=Math.max(0,nt);ae>=ee.length;)ee.push([])}else if(De==="K"){let Ue=v[0]||0;if(ae<ee.length){let nt=ee[ae];if(Ue===0)nt.length=Ce;else if(Ue===1)for(let At=0;At<Ce&&At<nt.length;At++)nt[At]={char:" ",style:""};else Ue===2&&(nt.length=0)}}else if(De==="J"){let Ue=v[0]||0;(Ue===2||Ue===3)&&(ee.length=0,ee.push([]),ae=0,Ce=0)}else if(De==="m"){let Ue=lt[0];Ue==="\x1B[0m"?ye="":ye=Ue}et=Ne.lastIndex}Ie(ne.substring(et));let ie=ee.map(fe=>{let De="",v="";for(let Ue=0;Ue<fe.length;Ue++){let nt=fe[Ue]||{char:" ",style:""};nt.style!==v&&(v&&(De+="\x1B[0m"),De+=nt.style,v=nt.style),De+=nt.char}return v&&(De+="\x1B[0m"),De});for(;ie.length>0&&ie[ie.length-1]==="";)ie.pop();return ie.join(`
|
|
12
|
-
`)})(f).replace(/\n{3,}/g,`
|
|
13
|
-
|
|
14
|
-
`),O=Math.max(10,(y||80)-6),B=N?N.split(`
|
|
15
|
-
`).flatMap(ne=>ne?pt(ne,O).split(`
|
|
16
|
-
`):[""]):[],[I,F]=gl(!1),[$,L]=gl(0);Oa(()=>{E||L(0)},[E]);let W=l&&l>0?l:process.stdout.rows||24,q=W<=24,ue=Math.max(1,W-(q?11:14)),R=W<=16?4:W<=22?5:W<=28?6:10,oe=Math.min(R,ue),me=B.length>oe,Me=Math.max(0,B.length-oe);Pa((ne,ee)=>{if(!E)return;let ae=ee.pageUp||ne==="\x1B[5~"||ne==="[5~",Ce=ee.pageDown||ne==="\x1B[6~"||ne==="[6~";ee.ctrl&&(ne==="o"||ne==="")?(F(ye=>!ye),L(0)):ae?L(ye=>Math.min(Me,ye+5)):Ce&&L(ye=>Math.max(0,ye-5))},{isActive:E});let Xe;if(!me||I)Xe=B;else{let ne=Math.max(0,B.length-oe-$),ee=ne+oe;Xe=B.slice(ne,ee)}let Ve=(Xe||[]).join(`
|
|
17
|
-
`).trim(),pe=(Xe||[]).join(`
|
|
18
|
-
`),Te=me&&!I?Math.max(0,B.length-oe-$):0,we=me&&!I?$:0,le=g?"\u{1F3C1} FINISHED: ":"\u26A1 EXECUTING: ",Ke=Math.max(10,(y||80)-(p?24:14)),Ge=pt((t||"").replace(/\r?\n/g," ").trim(),Ke).split(`
|
|
19
|
-
`),Y=(t||"").replace(/\r?\n/g," ").trim();return Ge.length>1&&(Y=Ge[0].length>3?Ge[0].slice(0,-3)+"...":Ge[0]+"..."),Bt.createElement($o,{flexDirection:"column",borderStyle:E?"double":"single",borderLeft:!1,borderRight:!1,borderTop:!0,borderBottom:!0,borderColor:T.codeBorder,paddingLeft:2,paddingRight:0,paddingTop:q?0:1,paddingBottom:1,marginY:q?0:1,width:y-2},Bt.createElement($o,{marginBottom:q?0:1,justifyContent:"space-between",width:"100%"},Bt.createElement($o,{flexShrink:1,paddingRight:2},Bt.createElement(ho,null,Bt.createElement(ho,{color:T.text,bold:!0},le),Bt.createElement(ho,{color:T.text},Y))),p&&Bt.createElement($o,{flexShrink:0,paddingX:1},Bt.createElement(ho,{color:"green",bold:!0},"ADVANCE"))),Ve?Bt.createElement($o,{flexDirection:"column",marginTop:0,backgroundColor:p?void 0:T.codeBg,paddingX:1,width:"100%"},Te>0&&Bt.createElement($o,{marginBottom:0},Bt.createElement(ho,{color:"magenta"},"\u25B2 ...",Te," lines above (Use PageUp to scroll)...")),Bt.createElement(ho,{color:T.text},pe),we>0&&Bt.createElement($o,{marginTop:0},Bt.createElement(ho,{color:"magenta"},"\u25BC ...",we," lines below (Use PageDown to scroll)..."))):!g&&Bt.createElement($o,{marginTop:q?0:1,backgroundColor:p?void 0:T.codeBg,paddingX:1,width:"100%"},Bt.createElement(ho,{color:T.textMuted,italic:!0},"Waiting for output...")),Bt.createElement($o,{justifyContent:"space-between",marginTop:q?0:1},g?Bt.createElement(ho,{color:T.textMuted,italic:!0},E?"Use PgUp/PgDn to scroll \u2022 Ctrl+O to expand/collapse \u2022 TAB to unfocus.":"Press TAB to focus & scroll."):Bt.createElement(ho,{color:T.textMuted,italic:!0},E?"Use PgUp/PgDn to scroll \u2022 Ctrl+O to expand \u2022 TAB to unfocus \u2022 CTRL+C to stop.":"Press TAB to focus \u2022 CTRL+C to terminate."),Bt.createElement(ho,{color:T.textMuted,bold:!0},g?E?"\u25CF ARCHIVED (FOCUSED) ":"\u25CF ARCHIVED ":E?"\u25B6 TERMINAL FOCUSED ":"\u25CF LIVE (Press TAB to focus) ")))});import{diffWordsWithSpace as Na}from"diff";var lr=null,Tl=t=>{lr=t!==!1},bl=()=>{if(lr===null)try{lr=Dr(cn,{})?.systemSettings?.preserveThinking!==!1}catch{lr=!0}return lr},hl=(t,f,g)=>t,Fa=(t,f=80)=>{if(!t)return null;let g=t.replaceAll(" "," "),E=f-10,y=g.trim();if(!y.includes("```"))return s.createElement(A,{width:"100%",flexDirection:"column"},s.createElement(Un,{text:y,color:"#969696",columns:E,italic:!0}));let p=y.split(/(```\w*\n?[\s\S]*?(?:```|$))/g);return s.createElement(A,{width:"100%",flexDirection:"column"},p.map((l,w)=>{if(l.startsWith("```")){let S=l.match(/```(\w*)\n?([\s\S]*?)(?:```|$)/),N=S?S[2]:l.replace(/^```\w*\n?/,"").replace(/```$/,""),O=pt(N.trimEnd(),E);return s.createElement(A,{key:w,flexDirection:"column",width:"100%"},O.split(`
|
|
20
|
-
`).map((B,I)=>s.createElement(se,{key:I,color:"cyan"},B)))}let T=l;return w>0&&(T=T.replace(/^[\r\n]+/,"")),w<p.length-1&&(T=T.replace(/[\r\n]+$/,"")),T?s.createElement(Un,{key:w,text:T,color:"gray",columns:E,italic:!0}):null}))},Ua=/(```[\s\S]*?```|`[^`\r\n]+`|@\[.*?\]|\*\*.*?\*\*|\*.*?\*|\\\(.*?\\\)|\\\[.*?\\\]|\$.*?\$|\[.*?\]\s*\(.*?\)|\[.*?\]\s*\[.*?\]|https?:\/\/[^\s]+)/g;var $a=/\\frac\s*\{([^{}]*)\}\s*\{([^{}]*)\}/g,_a=/(\\(?:mathbf|textbf|textit|underline|texttt)\{[^{}]*\})/g,Ha=/^(#{1,6})\s+(.*)/,Xa=/\\multiply|\\mul|\\times/g,Ga=/\\div/g,Wa=/\\cdot/g,Va=/\\infty/g,Ya=/\\pm/g,ja=/\\leq/g,Ka=/\\geq/g,qa=/\\neq/g,Qa=/\\sqrt\s*\{([^}]+)\}/g,za=/\\sqrt\s*(\w+|\d+)/g,Ja=/\\alpha/g,Za=/\\beta/g,Ra=/\\theta/g,ed=/\\pi/g,td=/\\approx/g,od=/\\Delta/g,nd=/\\sigma/g,rd=/\\sum/g,sd=/\\prod/g,id=/\\rightarrow|\\to/g,ld=/\\left\b|\\right\b/g,ad=/\\left\(|\\right\)/g,dd=/\\left\[|\\right\]/g,cd=/\\\{|\\\}/g,ud=/\\text\s*\{([^}]+)\}/g,md=/\\text\s+(\w+)/g,xd=/\\%/g,fd=/\\\(|\\\)/g,gd=/\\\[|\\\]/g,hd=/@\[(.*?)\]/g,pl=/:L/gi,pd=/\[(.*?)\]\s*\((.*?)\)/,Td=/\[(.*?)\]\s*\[(.*?)\]/,bd=/\\(\w+)\{([^{}]*)\}/,wd=t=>t.replace(fd,f=>f.includes("(")?"(":")").replace(gd,f=>f.includes("[")?"[":"]").replace(Xa,"\xD7").replace(Ga,"\xF7").replace(Wa,"\u22C5").replace(Va,"\u221E").replace(Ya,"\xB1").replace(ja,"\u2264").replace(Ka,"\u2265").replace(qa,"\u2260").replace(Qa,"\u221A($1)").replace(za,"\u221A($1)").replace(Ja,"\u03B1").replace(Za,"\u03B2").replace(Ra,"\u03B8").replace(ed,"\u03C0").replace(td,"\u2248").replace(od,"\u0394").replace(nd,"\u03C3").replace(rd,"\u03A3").replace(sd,"\u03A0").replace(id,"\u2192").replace(ld,"").replace(ad,f=>f.includes("left")?"(":")").replace(dd,f=>f.includes("left")?"[":"]").replace(cd,f=>f.includes("{")?"{":"}").replace(ud,"$1").replace(md,"$1").replace(xd,"%"),yd=/\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/,Cd=[/((?<=\binclude\s+)(?:<[^>]+>|"[^"]+"))/.source,/((?<=\b(?:from|import|require\s*\(\s*)\s*)(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"))/.source,/(\/\/.*|#.*)/.source,/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^\`\\])*`)/.source,yd.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],Os=new RegExp(Cd.join("|"),"g"),Fn=new Map,Md=1e3,Sd=(t,f)=>{if(!t)return[];let g=`${f}:${t}`;if(Fn.has(g))return Fn.get(g);let E=0,y=[],p;for(Os.lastIndex=0;(p=Os.exec(t))!==null;){let l=p[0],w=p.index;w>E&&y.push({text:kt(t.substring(E,w))});let T,S=!1;p[1]||p[2]?T="#ce9178":p[3]?T="#9ece6a":p[4]?T="#fcfca4":p[5]?(T="#ff7b72",S=!0):p[6]?T="#b392f0":(p[7]||p[8])&&(T="#ff9e64"),y.push({text:kt(l),color:T,bold:S}),E=Os.lastIndex}if(E<t.length&&y.push({text:kt(t.substring(E))}),Fn.size>=Md){let l=Fn.keys().next().value;Fn.delete(l)}return Fn.set(g,y),y},Ht=(t,f,g=void 0,E=void 0)=>{if(!t)return s.createElement(se,{backgroundColor:E}," ");let y=Sd(t,f);return s.createElement(se,{color:g,backgroundColor:E},y.map((p,l)=>s.createElement(se,{key:l,color:p.color||g,backgroundColor:E,bold:p.bold},p.text)))},Ps=(t,f)=>{if(!t)return null;let g=t.replace($a,"($1/$2)");g=wd(g);let E=g.split(_a);return s.createElement(s.Fragment,{key:f},E.map((y,p)=>{if(y.startsWith("\\")){let l=y.match(bd);if(l){let w=l[1],T=l[2];return s.createElement(se,{key:p,bold:w==="mathbf"||w==="textbf",italic:w==="textit",underline:w==="underline",color:w==="texttt"?"cyan":void 0},T)}}return y}))},Vt=s.memo(({text:t,color:f,italic:g,theme:E="Dark"})=>{if(!t)return null;let y=t.replaceAll(" "," "),p=st(E),l=f||p.text,w=p.codeText||p.logoGradient&&p.logoGradient[0]||p.info||p.secondary||"cyan",T=y.split(Ua);return s.createElement(se,{color:l,wrap:"anywhere",italic:g},T.map((S,N)=>{if(!S)return null;if(S.startsWith("```")&&S.endsWith("```")){let O=S.slice(3,-3);return s.createElement(se,{key:N,color:w},O)}if(S.startsWith("**")&&S.endsWith("**"))return s.createElement(se,{key:N,bold:!0,color:l},s.createElement(Vt,{text:S.slice(2,-2),color:l,theme:E}));if(S.startsWith("*")&&S.endsWith("*"))return s.createElement(se,{key:N,italic:!0,color:l},s.createElement(Vt,{text:S.slice(1,-1),color:l,italic:g,theme:E}));if(S.startsWith("`"))if(S.endsWith("`")&&S.length>1){let O=S.slice(1,-1),B=O.replace(hd,(F,$)=>$.split("/").pop().split("\\").pop().replace(pl,"#L")),I=O.includes("@[");return s.createElement(se,{key:N,color:w,bold:I},B)}else return s.createElement(se,{key:N,color:w},S.slice(1));if(S.startsWith("@[")&&S.endsWith("]")){let B=S.slice(2,-1).split("/").pop().split("\\").pop().replace(pl,"#L");return s.createElement(se,{key:N,color:w,bold:!0},B)}if(S.startsWith("\\(")&&S.endsWith("\\)")||S.startsWith("\\[")&&S.endsWith("\\]")){let O=S.slice(2,-2);return s.createElement(se,{key:N,color:"yellow"},Ps(O,N))}if(S.startsWith("$")&&S.endsWith("$")){let O=S.slice(1,-1);return s.createElement(se,{key:N,color:"yellow"},Ps(O,N))}if(S.startsWith("[")&&(S.includes("](")||S.includes("] ("))){let O=S.match(pd);if(O){let B=O[1]||O[2],F=`\x1B]8;;${O[2]||O[1]}\x07${B}\x1B]8;;\x07`;return s.createElement(se,{key:N,color:w,underline:!0,italic:!0},F)}}if(S.startsWith("[")&&(S.includes("][")||S.includes("] ["))){let O=S.match(Td);if(O){let B=O[1]||O[2],F=`\x1B]8;;${O[2]||O[1]}\x07${B}\x1B]8;;\x07`;return s.createElement(se,{key:N,color:w,underline:!0,italic:!0},F)}}return S.startsWith("http")?s.createElement(se,{key:N,color:w,underline:!0,italic:!0},S):Ps(S,N)}))}),wl=s.memo(({buffer:t,terminalWidth:f=80,theme:g="Dark"})=>{if(t.length<2)return null;let E=st(g),y=E.codeText||E.secondary||E.info||"cyan",p=t.map(O=>{let B=O.split("|");return B[0]!==void 0&&B[0].trim()===""&&B.shift(),B.length>0&&B[B.length-1].trim()===""&&B.pop(),B.map(I=>I.trim())}),l=p[0],w=p.slice(2),T=Math.floor(100/l.length),S=f-8,N=Math.floor(S/l.length)-2;return s.createElement(A,{flexDirection:"column",borderStyle:"round",borderColor:E.borderMuted,paddingX:1,marginY:0,width:f-2},s.createElement(A,{flexDirection:"row",borderStyle:"single",borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,borderColor:E.borderMuted,marginBottom:1,paddingBottom:0,width:"100%"},l.map((O,B)=>s.createElement(A,{key:B,flexBasis:`${T}%`,flexGrow:1,flexShrink:0,paddingRight:2},s.createElement(Vt,{text:pt(O,N),color:y,theme:g})))),w.map((O,B)=>s.createElement(A,{key:B,flexDirection:"row",marginBottom:B===w.length-1?0:1,width:"100%"},O.map((I,F)=>s.createElement(A,{key:F,flexBasis:`${T}%`,flexGrow:1,flexShrink:0,paddingRight:2,flexDirection:"column"},s.createElement(Vt,{text:pt(I,N),color:E.text,theme:g}))))))}),Un=s.memo(({text:t,color:f,columns:g=80,italic:E=!1,theme:y="Dark"})=>{if(!t)return null;let p=t.replaceAll(" "," "),l=st(y),w=f||l.text,T=p.split(`
|
|
21
|
-
`),S=[],N=[],O=[],B=I=>{if(N.length>0&&(S.push(s.createElement(wl,{key:`table-${I}`,buffer:[...N],terminalWidth:g,theme:y})),N=[]),O.length>0){let F=g-6,$=O.flatMap(L=>pt(L,F).split(`
|
|
22
|
-
`));S.push(s.createElement(A,{key:`quote-${I}`,borderStyle:"bold",borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:l.borderMuted,paddingLeft:1,marginY:1,flexDirection:"column"},$.map((L,W)=>s.createElement(Vt,{key:W,text:L,color:l.textMuted,italic:E,theme:y})))),O=[]}};return T.forEach((I,F)=>{let $=I.trim(),L=$.startsWith("|"),W=$.startsWith(">");if(L)O.length>0&&B(F),N.push(I);else if(W)N.length>0&&B(F),O.push($.replace(/^>\s*/,""));else{if(B(F),$===""){S.push(s.createElement(A,{key:F,height:1}));return}if($==="---"||$==="***"||$==="___"){S.push(s.createElement(A,{key:F,marginY:0,borderStyle:"single",borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,width:"100%",borderColor:l.borderMuted}));return}let q=$.match(/^(#{1,6})\s+(.*)/);if(q){let me=q[1].length,Me=q[2];S.push(s.createElement(A,{key:F,marginTop:1,marginBottom:0,width:"100%"},s.createElement(se,{bold:!0,color:me===1?"yellow":me===2?"magenta":me===3?l.info||"cyan":me===4?"green":me===5?"blue":l.text,underline:!0},Me)));return}let de=/^[\*\-\+]\s/.test($),ue=/^\d+\.\s/.test($),R=I.includes("\u2588")||I.includes("\u2554")||I.includes("\u255A")||I.includes("\u2550"),oe="";if(R)oe=I;else if(de||ue){let me=de?" \u2022 ":$.match(/^\d+\.\s/)[0],Me=" ".repeat(me.length),Xe=pt($.replace(/^[\*\-\d+\.]+\s/,""),g-(me.length+6));oe=me+Xe.split(`
|
|
23
|
-
`).join(`
|
|
24
|
-
`+Me)}else oe=pt($,g-4);S.push(s.createElement(A,{key:F,flexDirection:"column",width:"100%"},s.createElement(Vt,{text:oe,color:w,italic:E,theme:y})))}}),B("final"),s.createElement(A,{flexDirection:"column",width:g-2},S)}),yl=s.memo(({line:t,pairContent:f,parentText:g,columns:E=80,extension:y,theme:p="Dark"})=>{let l=st(p),w=(t||"").replaceAll(" "," "),T=w.includes("[UI_CONTEXT]"),S=w.replace("[UI_CONTEXT]","");if(T&&S.includes("\u2550"))return s.createElement(A,{backgroundColor:l.codeBg,paddingX:1,width:E},s.createElement(se,{color:"gray"},"\u2550".repeat(Math.max(10,E-4))));let N=vs(w);if(!N)return s.createElement(A,{backgroundColor:l.codeBg,paddingX:1,width:E},s.createElement(A,{width:3,flexShrink:0}),s.createElement(A,{width:1,flexShrink:0,marginLeft:1}),s.createElement(A,{flexGrow:1,marginLeft:1},s.createElement(se,{color:"gray"},pt(S,E-14))));let{isR:O,isA:B,num:I,content:F}=N,$=f&&f.replaceAll(" "," "),L=[];if($!=null){let Me=O?F:$,Xe=O?$:F;try{L=Na(Me,Xe)}catch{L=[]}}let W=L.some(Me=>O&&Me.removed||B&&Me.added),q=!$&&(O||B),de=O?l.diffRemovalBg:B?l.diffAdditionBg:void 0,ue=O||B?O?l.diffRemovalNum:l.diffAdditionNum:l.textMuted,R=O?l.diffRemovalPrefix:l.diffAdditionPrefix,oe=O?"-":B?"+":" ",me=()=>{if(q){let Y=O?l.diffRemovalHighlightBg:l.diffAdditionHighlightBg;return s.createElement(A,{flexDirection:"column"},Ht(pt(F,E-15),y,void 0,Y))}if(!(O||B)||L.length===0||!W){let Y=O?l.diffRemovalText:B?l.diffAdditionText:l.textMuted;return s.createElement(A,{flexDirection:"column"},Ht(pt(F,E-15),y,Y,void 0))}let Me=Math.max(10,E-15),Xe=pt(F,Me).split(`
|
|
25
|
-
`),Ve=[];if(L.forEach((Y,ne)=>{let ee=/^\s+$/.test(Y.value);if(O){let ae=L[ne-1]?.removed||L[ne+1]?.removed;Y.removed||ee&&ae?Ve.push({text:Y.value,isHighlight:!0}):Y.added||Ve.push({text:Y.value,isHighlight:!1})}else if(B){let ae=L[ne-1]?.added||L[ne+1]?.added;Y.added||ee&&ae?Ve.push({text:Y.value,isHighlight:!0}):Y.removed||Ve.push({text:Y.value,isHighlight:!1})}}),Xe.length<=1)return s.createElement(se,{wrap:"wrap"},Ve.map((Y,ne)=>O?Y.isHighlight?s.createElement(s.Fragment,{key:ne},Ht(Y.text,y,l.diffRemovalText,l.diffRemovalHighlightBg)):s.createElement(s.Fragment,{key:ne},Ht(Y.text,y,l.diffRemovalText)):B?Y.isHighlight?s.createElement(s.Fragment,{key:ne},Ht(Y.text,y,l.diffAdditionText,l.diffAdditionHighlightBg)):s.createElement(s.Fragment,{key:ne},Ht(Y.text,y,l.diffAdditionText)):s.createElement(s.Fragment,{key:ne},Ht(Y.text,y,l.textMuted))));let pe=0,Te=0,we=F.match(/^(\s*)/),le=we?we[1]:"",Ke=le.substring(0,Math.min(le.length,8)),Ge=Xe.map((Y,ne)=>{let ee=[],ae=Y;ne>0&&Ke&&Y.startsWith(Ke)&&((Ve[pe]?Ve[pe].text.substring(Te):"").startsWith(Ke)||(ee.push({text:Ke,isHighlight:!1}),ae=Y.substring(Ke.length)));let Ce=ae.length;for(;Ce>0&&pe<Ve.length;){let ye=Ve[pe],Ne=ye.text.length-Te;if(Ne<=0){pe++,Te=0;continue}let et=Math.min(Ce,Ne);ee.push({text:ye.text.substring(Te,Te+et),isHighlight:ye.isHighlight}),Te+=et,Ce-=et,Te>=ye.text.length&&(pe++,Te=0)}for(;pe<Ve.length;){let ye=Ve[pe],Ne=ye.text.substring(Te);if(/^\s+$/.test(Ne))pe++,Te=0;else if(Ne.startsWith(" ")||Ne.startsWith(" ")){let et=0;for(;et<Ne.length&&(Ne[et]===" "||Ne[et]===" ");)et++;Te+=et,Te>=ye.text.length&&(pe++,Te=0);break}else break}return ee});if(pe<Ve.length){let Y=Ge[Ge.length-1];for(;pe<Ve.length;){let ne=Ve[pe];Y.push({text:ne.text.substring(Te),isHighlight:ne.isHighlight}),pe++,Te=0}}return s.createElement(A,{flexDirection:"column"},Ge.map((Y,ne)=>s.createElement(A,{key:ne},s.createElement(se,{wrap:"wrap"},Y.map((ee,ae)=>O?ee.isHighlight?s.createElement(s.Fragment,{key:ae},Ht(ee.text,y,l.diffRemovalText,l.diffRemovalHighlightBg)):s.createElement(s.Fragment,{key:ae},Ht(ee.text,y,l.diffRemovalText)):B?ee.isHighlight?s.createElement(s.Fragment,{key:ae},Ht(ee.text,y,l.diffAdditionText,l.diffAdditionHighlightBg)):s.createElement(s.Fragment,{key:ae},Ht(ee.text,y,l.diffAdditionText)):s.createElement(s.Fragment,{key:ae},Ht(ee.text,y,l.textMuted)))))))};return s.createElement(A,{backgroundColor:l.codeBg,paddingX:1,width:E},s.createElement(A,{width:4,flexShrink:0,justifyContent:"flex-end"},s.createElement(se,{color:ue},I)),s.createElement(A,{width:1,flexShrink:0,marginLeft:1},s.createElement(se,{color:R},oe)),s.createElement(A,{marginLeft:1,backgroundColor:de,flexGrow:1},me()))}),Ed=s.memo(({text:t,columns:f=80,extension:g,theme:E="Dark"})=>{let y=st(E),p=t.match(/\[DIFF_START\]([\s\S]*?)(?:\[DIFF_END\]|$)/),T=(p?p[1].trim():"").split(`
|
|
26
|
-
`).map(N=>{let O=N.replaceAll(" "," ");return{line:O,parsed:vs(O),pairContent:null}}),S=[];for(let N=0;N<T.length;N++){let O=T[N];O.parsed&&(O.parsed.isR||O.parsed.isA)?S.push(O):S.length>0&&(Ds(S),S=[])}return S.length>0&&Ds(S),s.createElement(A,{flexDirection:"column",width:f-3,marginBottom:1},s.createElement(A,{flexDirection:"column",paddingY:0,width:"100%"},s.createElement(A,{backgroundColor:y.codeBg,paddingX:1,width:"100%"},s.createElement(A,{width:3,flexShrink:0}),s.createElement(A,{width:1,flexShrink:0,marginLeft:1}),s.createElement(A,{flexGrow:1,marginLeft:1},s.createElement(se,null," "))),T.map((N,O)=>s.createElement(yl,{key:O,line:N.line,pairContent:N.pairContent,columns:f-3,extension:g,theme:E})),s.createElement(A,{backgroundColor:y.codeBg,paddingX:1,width:"100%"},s.createElement(A,{width:3,flexShrink:0}),s.createElement(A,{width:1,flexShrink:0,marginLeft:1}),s.createElement(A,{flexGrow:1,marginLeft:1},s.createElement(se,null," ")))))}),_r=s.memo(({text:t,columns:f=80,theme:g="Dark"})=>{if(!t)return null;let E=st(g),y="",p=t.match(/File\s+\[(.*?)\]/i);if(p&&(y=p[1].split(".").pop().toLowerCase()),t.includes("[DIFF_START]"))return s.createElement(Ed,{text:t,columns:f,extension:y,theme:g});if(t.includes("- Content Preview:")){let l=t.split("- Content Preview:"),w=l[0],T=l[1]||"",S="[SYSTEM] Check the content preview for verification [/SYSTEM]",N=T.split(S),O=(N[0]?.trim()||"").replaceAll(" "," "),B=N[1]?`${S}${N[1]}`:"",I=O.split(`
|
|
27
|
-
`),F=String(I.length).length;return s.createElement(A,{flexDirection:"column",width:f-3},s.createElement(A,{flexDirection:"column",borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:E.codeBorder,paddingLeft:2,paddingRight:0,width:"100%",marginBottom:1,backgroundColor:E.codeBg},s.createElement(A,{flexDirection:"column",width:"100%"},s.createElement(A,{width:"100%"},s.createElement(A,{width:F+2,flexShrink:0},s.createElement(se,null," ")),s.createElement(A,{flexGrow:1},s.createElement(se,null," "))),I.map(($,L)=>s.createElement(A,{key:L,width:"100%"},s.createElement(A,{width:F+2,flexShrink:0},s.createElement(se,{color:"gray",dimColor:!0},String(L+1).padStart(F," ")," ")),s.createElement(A,{flexGrow:1},Ht($,y,E.text)))),s.createElement(A,{width:"100%"},s.createElement(A,{width:F+2,flexShrink:0},s.createElement(se,null," ")),s.createElement(A,{flexGrow:1},s.createElement(se,null," "))))))}if(t.includes("```")){let l=t.split(/(```\w*\n?[\s\S]*?(?:```|$))/g);return s.createElement(A,{flexDirection:"column",width:f-3},l.map((w,T)=>{if(w.startsWith("```")){let N=w.match(/```(\w*)\n?([\s\S]*?)(?:```|$)/),O=N?N[1]:"code",B=(N?N[2]:w.replace(/^```\w*\n?/,"").replace(/```$/,"")).replaceAll(" "," "),I=B.trimEnd().split(`
|
|
28
|
-
`),F=String(I.length).length,$=f-7-F,W=($>5?pt(B,$):B).trimEnd().split(`
|
|
29
|
-
`);return s.createElement(A,{key:T,flexDirection:"column",marginY:0,paddingLeft:2,paddingRight:0,width:"100%"},s.createElement(A,null,s.createElement(se,{color:"gray",bold:!0},"\u25B6_ ",O.toUpperCase()||"TEXT")),s.createElement(A,{flexDirection:"column",width:"100%"},W.map((q,de)=>{let R=pt(q,Math.max(10,$)).split(`
|
|
30
|
-
`);return s.createElement(A,{key:de,flexDirection:"column",width:"100%"},R.map((oe,me)=>s.createElement(A,{key:me,width:"100%"},s.createElement(A,{width:F+2,flexShrink:0},s.createElement(se,{color:"gray"},me===0?String(de+1).padStart(F," ")+" ":" ".repeat(F+1))),s.createElement(A,{flexGrow:1},Ht(oe,O,E.text)))))})))}let S=w;return T>0&&(S=S.replace(/^[\r\n]+/,"")),T<l.length-1&&(S=S.replace(/[\r\n]+$/,"")),S?s.createElement(Un,{key:T,text:S,columns:f-3,theme:g}):null}))}return s.createElement(Un,{text:t,columns:f-3,theme:g})}),Hr=t=>{let f=Math.round(t/1e3);if(f<=0)return"0s";let g=Math.floor(f/60),E=f%60;return g>0?`${g}m ${E}s`:`${f}s`},Cl=s.memo(({msg:t,showFullThinking:f,columns:g=80,aiProvider:E,version:y,theme:p="Dark"})=>{let l=st(p),w=t.role==="system"&&(t.text?.includes("[DIFF_START]")||t.text?.includes("- Content Preview:")),T=t.role==="system"&&(t.text?.includes("[ACTION RESULT]: ERROR:")||t.text?.includes("[TOOL RESULT]: ERROR:"))&&!t.text?.includes("[DIFF_START]")&&(t.toolName==="update_file"||t.text?.includes("Could not find exact match")),S=t.isTerminalRecord;if(t.isHomeWarning)return s.createElement(A,{marginBottom:1,paddingX:1,width:"100%"},s.createElement(A,{flexDirection:"column",borderStyle:"round",borderColor:l.border,dimColor:!0,padding:0,width:"100%"},s.createElement(A,{paddingX:1},s.createElement(se,{color:l.text,bold:!0},t.text)),s.createElement(A,{paddingX:1,marginTop:0,marginBottom:0},s.createElement(se,{color:l.text},t.subText))));if(t.isLogo)return s.createElement(A,{flexDirection:"column",alignItems:"flex-start",width:"100%",marginY:1},s.createElement(se,null,Lr(y,E,p)));if(t.id&&String(t.id).startsWith("welcome"))return s.createElement(A,{flexDirection:"column",alignItems:"center",width:"100%",marginY:1},s.createElement(A,{borderStyle:"round",borderColor:l.borderMuted,paddingX:3,paddingY:0},s.createElement(se,{color:l.text,bold:!0},t.text.trim())));if(t.isVisualFeedback)return s.createElement(A,{marginBottom:0,marginTop:0,paddingX:1,width:"100%"},s.createElement(se,{color:l.text},t.text));if(t.isSteeringHint||t.role==="user"&&(t.text?.startsWith("[STEERING HINT]")||t.text?.startsWith("[QUESTION]"))){let $=t.hintContent||(t.text||"").replace(/^\[(?:STEERING HINT|QUESTION)\]\s*/i,"").trim();return s.createElement(A,{flexDirection:"column",width:g-1,marginBottom:0,marginTop:0},s.createElement(A,{width:g-1,height:1,overflow:"hidden"},s.createElement(se,{color:l.userMsgBorder},"\u2584".repeat(Math.max(1,g-1)))),s.createElement(A,{backgroundColor:l.userMsgBg,paddingX:1,paddingY:0,width:g-1,flexDirection:"column"},pt($.replace(/\r\n/g,`
|
|
31
|
-
`).replace(/\r/g,`
|
|
32
|
-
`).replace(/\\\n/g,`
|
|
33
|
-
`).replace(/\\$/,""),g-7).split(`
|
|
34
|
-
`).map((L,W)=>s.createElement(A,{key:W,flexDirection:"row",width:"100%"},s.createElement(A,{flexShrink:0,width:2},s.createElement(se,{bold:!0,color:l.userMsgText},W===0?"\u2726":" ")),s.createElement(A,{flexGrow:1,marginLeft:1},s.createElement(Vt,{text:L,color:l.userMsgText,theme:p}))))),s.createElement(A,{width:g-1,height:1,overflow:"hidden"},s.createElement(se,{color:l.userMsgBorder},"\u2580".repeat(Math.max(1,g-1)))))}if(T)return s.createElement(A,{marginBottom:1},s.createElement(A,{flexDirection:"column",borderStyle:"round",borderColor:l.border,paddingX:1,paddingY:0},s.createElement(se,{color:l.text,bold:!0,underline:!0},"\u2717 PATCH FAILED"),s.createElement(A,{marginTop:1},s.createElement(se,{color:l.textMuted,bold:!0},"Model generated malformed edit."))));if(t.role==="system"&&(t.text?.includes("[ACTION RESULT]")||t.text?.includes("[TOOL RESULT]"))&&!w&&!S&&!T)return null;if(t.isImageStats)return s.createElement(A,{marginBottom:1,paddingX:1,width:"100%"},s.createElement(A,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,padding:0,width:"100%"},s.createElement(A,{paddingX:1,backgroundColor:l.codeBg},s.createElement(se,{color:l.text,bold:!0},"IMAGE STATS")),s.createElement(A,{paddingX:1,marginTop:1,marginBottom:1,flexDirection:"column"},t.text.split(`
|
|
35
|
-
`).map(($,L)=>s.createElement(se,{key:L,color:l.textMuted},$)))));if(t.isAskRecord){let $=t.text.match(/Selection: (.*)/),L=$?$[1]:"No selection",W=t.text.match(/Question: (.*)/),q=W?W[1]:null,de=q==="Agent has been running for a long time. Do you want to continue execution?";return s.createElement(A,{marginBottom:0,paddingX:1,width:"100%"},s.createElement(A,{flexDirection:"column",borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!0,borderBottom:!0,borderColor:l.codeBorder,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,marginY:1,width:g-2},s.createElement(A,{paddingX:1},s.createElement(se,{color:l.success,bold:!0},de?"TURN SAFETY SYSTEM: RESOLVED":"AGENT REQUEST: RESOLVED")),q&&s.createElement(A,{paddingX:1,marginTop:1},s.createElement(se,{color:l.secondary},q)),s.createElement(A,{paddingX:1,marginTop:1,marginBottom:0},s.createElement(se,{color:l.text},"Selection: ",s.createElement(se,{color:l.textMuted,bold:!0},L)))))}if(t.isAboutRecord)return s.createElement(A,{marginBottom:0,paddingX:1,width:"100%"},s.createElement(A,{flexDirection:"column",borderStyle:"round",border:!0,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,backgroundColor:l.codeBg,width:"100%"},s.createElement(A,{paddingX:1},s.createElement(se,{color:l.text,bold:!0},"ABOUT FLUX FLOW")),s.createElement(A,{paddingX:1,marginTop:1,marginBottom:1},s.createElement(se,{color:l.text},t.text))));if(t.isUpdateNotification)return s.createElement(A,{marginBottom:1,paddingX:1,width:"100%"},s.createElement(A,{flexDirection:"column",borderStyle:"round",border:!0,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,backgroundColor:l.codeBg,width:"100%"},s.createElement(A,{paddingX:1},s.createElement(se,{color:l.text,bold:!0},"UPDATE AVAILABLE")),s.createElement(A,{paddingX:1,marginTop:1,marginBottom:1},s.createElement(_r,{text:t.text,columns:g,theme:p}))));if(t.isHelpRecord){let $=[{cmd:"/quit",desc:"Exit and shutdown Flux"},{cmd:"/kill",desc:"Kill a process by PID or list active processes"},{cmd:"/help",desc:"Show all available commands"},{cmd:"/compress",desc:"Summarize and compress chat history"},{cmd:"/truncate",desc:"Truncate tool results in chat history"},{cmd:"/clear",desc:"Clear terminal screen"},{cmd:"/resume",desc:"Load previous session"},{cmd:"/revert",desc:"Revert codebase to checkpoint"},{cmd:"/save",desc:"Force save current chat"},{cmd:"/export",desc:"Export current chat or error logs"},{cmd:"/chats",desc:"List all chat sessions"},{cmd:"/btw",desc:"Send raw inquiry mid-turn"},{cmd:"/budget",desc:"Set or View budget limits"},{cmd:"/mode",desc:"Toggle Flux/Flow modes"},{cmd:"/thinking",desc:"Set AI reasoning depth"},{cmd:"/model",desc:"Switch AI model"},{cmd:"/wildcard-tooling",desc:"Use if the model lacks Tooling Capability"},{cmd:"/wildercard-tooling",desc:"Extended version of /wildcard-tooling"},{cmd:"/provider",desc:"Select AI Provider"},{cmd:"/settings",desc:"Configure system prefs"},{cmd:"/theme",desc:"Customize UI color theme"},{cmd:"/key",desc:"Manage API keys"},{cmd:"/profile",desc:"Edit developer persona"},{cmd:"/memory",desc:"Manage agent memory"},{cmd:"/stats",desc:"Show session usage"},{cmd:"/usage",desc:"Open graphical token usage & analytics in browser"},{cmd:"/reset",desc:"Wipe all saved FluxFlow AppData"},{cmd:"/about",desc:"Project info & credits"},{cmd:"/changelog",desc:"View latest updates"},{cmd:"/docs",desc:"View documentation"},{cmd:"/fluxflow",desc:"Project management"},{cmd:"/update",desc:"Check/Install updates"}];return s.createElement(A,{marginBottom:1,paddingX:1,width:"100%"},s.createElement(A,{flexDirection:"column",borderStyle:"round",borderColor:l.borderMuted,paddingX:2,paddingY:1,width:"100%"},s.createElement(se,{color:l.text,bold:!0,underline:!0},"AVAILABLE COMMANDS IN FLUX-FLOW"),s.createElement(A,{flexDirection:"column",marginTop:1},$.map((L,W)=>s.createElement(A,{key:W,flexDirection:"row"},s.createElement(A,{width:20},s.createElement(se,{color:l.text,bold:!0},L.cmd)),s.createElement(se,{color:l.textMuted}," - ",L.desc))))))}if(t.isTerminalRecord){let $=t.text.match(/COMMAND: (.*)/),L=t.text.match(/PTY: (true|false)/),W=t.text.match(/OUTPUT: ([\s\S]*)/),q=$?$[1]:"No Command",de=L?L[1]==="true":!1,ue=W?W[1]:"";return s.createElement(A,{marginBottom:0,paddingX:1,width:"100%"},s.createElement($r,{command:q,output:ue,completed:!0,columns:g,isPty:de,theme:p}))}let[O,B]=s.useState(!t.isStreaming),I=s.useMemo(()=>(qi(t.text,t.role)||"").replaceAll(" "," "),[t.text,t.role]);s.useEffect(()=>{t.isStreaming&&B(!1)},[t.id]);let F=s.useMemo(()=>t.role==="think"&&!f?"Thinking...":t.isStreaming?I:I.trimEnd(),[I,t.role,f,t.isStreaming]);return t.role==="think"&&!bl()||t.role==="agent"&&F.trim()===""?null:s.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"?s.createElement(A,{flexDirection:"column",width:g-1},s.createElement(A,{width:g-1,height:1,overflow:"hidden"},s.createElement(se,{color:l.userMsgBorder},"\u2584".repeat(Math.max(1,g-1)))),s.createElement(A,{backgroundColor:l.userMsgBg,paddingX:1,paddingY:0,width:g-1,flexDirection:"column"},pt(F.replace(/\r\n/g,`
|
|
36
|
-
`).replace(/\r/g,`
|
|
37
|
-
`).replace(/\\\n/g,`
|
|
38
|
-
`).replace(/\\$/,""),g-7).split(`
|
|
39
|
-
`).map(($,L)=>s.createElement(A,{key:L,flexDirection:"row",width:"100%"},s.createElement(A,{flexShrink:0,width:2},s.createElement(se,{bold:!0,color:l.userMsgText},L===0?">":" ")),s.createElement(A,{flexGrow:1,marginLeft:1},s.createElement(Vt,{text:$,color:t.color||l.userMsgText,theme:p}))))),s.createElement(A,{width:g-1,height:1,overflow:"hidden"},s.createElement(se,{color:l.userMsgBorder},"\u2580".repeat(Math.max(1,g-1))))):t.role==="think"?s.createElement(A,{flexDirection:"column",marginTop:0,marginBottom:0,paddingX:0,width:"100%"},t.isStreaming&&!t.duration?s.createElement(se,{bold:!0,color:l.text},"\u2727 Thinking..."):s.createElement(se,{bold:!0,color:l.text},"\u2726 Thought",t.duration?s.createElement(se,{color:l.textMuted}," for ",s.createElement(se,{bold:!0,color:l.text},Hr(t.duration))):"s..."),s.createElement(A,{borderStyle:"single",borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:l.borderMuted,paddingLeft:2,paddingTop:0,paddingBottom:0,flexDirection:"column",width:"100%"},Fa(F,g))):s.createElement(A,{flexDirection:"column",paddingX:1,marginTop:0,width:"100%"},s.createElement(_r,{text:F.replace(/ \|\n\n/g,` |
|
|
40
|
-
`),columns:g,theme:p}),t.memoryUpdated&&s.createElement(A,{marginTop:1,width:"100%"},s.createElement(se,{color:l.text,italic:!0},"[Memory Updated]")),t.role==="agent"&&t.workedDuration?s.createElement(A,{marginTop:1,marginBottom:2,width:"100%"},s.createElement(se,{color:l.textMuted},"["),s.createElement(se,{color:l.textMuted},"Worked for ",s.createElement(se,{bold:!0,color:l.text},Hr(t.workedDuration))),s.createElement(se,{color:l.textMuted},"]")):null))}),Xr=s.memo(({block:t,columns:f=80,showFullThinking:g,aiProvider:E,version:y,theme:p="Dark"})=>{let l=st(p),{msg:w,type:T,text:S,isStreamingMsg:N,workedDuration:O}=t;if((T==="think-header"||T==="think-line"||T==="think-footer-padding")&&!bl())return null;if(T==="chunk")return s.createElement(A,{flexDirection:"column",width:"100%"},t.blocks.map(B=>s.createElement(Xr,{key:B.key,block:B,columns:f,showFullThinking:g,aiProvider:E,version:y,theme:p})));if(T==="full-message")return s.createElement(Cl,{msg:w,showFullThinking:g,columns:f,aiProvider:E,version:y,theme:p});if(T==="think-header")return s.createElement(A,{flexDirection:"column",paddingX:1,width:"100%",marginTop:0,marginBottom:0},(()=>{let B=t.duration||w?.duration||O;return N&&!B?s.createElement(se,{bold:!0,color:l.text},"\u2727 Thinking..."):s.createElement(se,{bold:!0,color:l.text},"\u2726 Thought",B?s.createElement(se,{color:l.textMuted}," for ",s.createElement(se,{bold:!0,color:l.text},Hr(B)),"..."):"s...")})(),g&&s.createElement(A,{flexDirection:"row",width:"100%"},s.createElement(se,{color:l.textMuted},"\u2502 ")));if(T==="think-line"){if(!g)return null;if(!S||S.trim()==="")return s.createElement(A,{flexDirection:"row",width:"100%",paddingX:1},s.createElement(se,{color:l.textMuted},"\u2502 "));let B=hl(S,N,t.isActiveBlock)?.replaceAll(" "," ")||"";return s.createElement(A,{flexDirection:"row",width:"100%",paddingX:1},s.createElement(se,{color:l.textMuted},"\u2502 "),s.createElement(A,{flexGrow:1,marginLeft:1},s.createElement(Vt,{text:B,color:l.textMuted,italic:!0,theme:p})))}if(T==="think-footer-padding")return g?s.createElement(A,{flexDirection:"row",width:"100%",paddingX:1},s.createElement(se,{color:l.textMuted},"\u2502 ")):null;if(T==="agent-line"){if(!S||S.trim()==="")return s.createElement(A,{height:1});let B=hl(S,N,t.isActiveBlock)?.replaceAll(" "," ")||"",I=B.trim();if(I==="---"||I==="***"||I==="___")return s.createElement(A,{flexDirection:"column",paddingX:1,width:"100%",marginY:0},s.createElement(A,{borderStyle:"single",borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,width:"100%",borderColor:l.borderMuted}));let F=I.match(Ha);if(F){let W=F[1].length,q=F[2],ue=["yellow",l.secondary||"magenta",l.info||"cyan","green","blue",l.text][W-1]||l.text;return s.createElement(A,{flexDirection:"column",paddingX:1,width:"100%",marginTop:0,marginBottom:0},s.createElement(se,{bold:!0,color:ue,underline:!0},s.createElement(Vt,{text:q,color:ue,theme:p})))}if(I.startsWith(">")){let W=I.replace(/^>\s*/,"");return s.createElement(A,{flexDirection:"column",paddingX:1,width:"100%"},s.createElement(A,{borderStyle:"bold",borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:l.borderMuted,paddingLeft:1,marginY:0},s.createElement(Vt,{text:W,color:l.textMuted,italic:!0,theme:p})))}let $=/^[\*\-\+]\s/.test(I),L=/^\d+\.\s/.test(I);if($||L){let W=$?" \u2022 ":I.match(/^\d+\.\s/)[0],q=I.replace(/^[\*\-\+\d+\.]+\s*/,"");return s.createElement(A,{flexDirection:"row",paddingX:1,width:"100%"},s.createElement(se,{color:l.info||l.textMuted},W),s.createElement(A,{flexGrow:1},s.createElement(Vt,{text:q,color:l.text,theme:p})))}return s.createElement(A,{flexDirection:"column",paddingX:1,width:"100%"},s.createElement(Vt,{text:B,color:l.text,theme:p}))}if(T==="table-header"||T==="table-row"){let B=T==="table-header",I=l.codeText||l.secondary||l.info||"cyan",F=t.colHeaders||[],$=B?F:t.cells||[],L=Math.max(1,t.colCount||F.length||$.length||1),W=Array.from({length:L},(pe,Te)=>$[Te]||""),q=Math.max(20,(f||80)-8),de=L>=4,ue=/^(#|no\.?|num\.?|status|state|type|ok|done|✔|✘|active)$/i,R=[],oe=0,me=0;for(let pe=0;pe<L;pe++){let Te=(F[pe]||"").trim();if(de&&(ue.test(Te)||Te==="#")){let we=Math.max(Te.length+4,8);R.push(we),oe+=we}else R.push(null),me++}let Me=Math.max(me*12,q-oe),Xe=me>0?Math.max(10,Math.floor(Me/me)):10;for(let pe=0;pe<L;pe++)R[pe]===null&&(R[pe]=Xe);let Ve=R.reduce((pe,Te)=>pe+Te,0);return B?s.createElement(A,{flexDirection:"column",paddingX:1,width:"100%",marginTop:0,marginBottom:1},s.createElement(A,{flexDirection:"row",borderStyle:"single",borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,borderColor:l.borderMuted,paddingBottom:0,width:Ve},F.map((pe,Te)=>{let we=R[Te]||6;return s.createElement(A,{key:Te,width:we,paddingRight:1,flexDirection:"column"},s.createElement(Vt,{text:pt(pe,Math.max(2,we-1)),color:I,theme:p}))}))):s.createElement(A,{flexDirection:"row",paddingX:1,width:"100%",marginBottom:1},W.map((pe,Te)=>{let we=R[Te]||6;return s.createElement(A,{key:Te,width:we,paddingRight:1,flexDirection:"column"},s.createElement(Vt,{text:pt(pe,Math.max(2,we-1)),color:l.text,theme:p}))}))}if(T==="table-close")return s.createElement(A,{height:0});if(T==="table")return s.createElement(A,{flexDirection:"column",paddingX:1,width:"100%"},s.createElement(wl,{buffer:S.split(`
|
|
41
|
-
`),terminalWidth:f,theme:p}));if(T==="diff-line"){let{isFirstLine:B,isLastLine:I}=t,F=($=!1)=>s.createElement(A,{backgroundColor:l.codeBg,paddingX:1,width:f,marginBottom:$?1:0},s.createElement(A,{width:3,flexShrink:0}),s.createElement(A,{width:1,flexShrink:0,marginLeft:1}),s.createElement(A,{flexGrow:1,marginLeft:1},s.createElement(se,null," ")));return s.createElement(A,{flexDirection:"column"},B&&F(!1),s.createElement(yl,{line:S,pairContent:t.pairContent,parentText:void 0,columns:f,theme:p}),I&&F(!0))}if(T==="code-fence-open"){let B={paddingLeft:2,width:"100%"};return s.createElement(A,{flexDirection:"column",marginTop:0,marginBottom:0,width:"100%"},s.createElement(A,{flexDirection:"row",...B},s.createElement(se,null," ")),s.createElement(A,{flexDirection:"row",...B},s.createElement(se,{color:"gray",bold:!0},"\u25B6_ ",(S||"TEXT").toUpperCase())))}if(T==="code-line"){let{lineNum:B,lang:I}=t,F=f-12,$=(S||"").replaceAll(" "," "),W=pt($,Math.max(10,F)).split(`
|
|
42
|
-
`);return s.createElement(A,{flexDirection:"column",width:"100%"},W.map((q,de)=>s.createElement(A,{key:de,flexDirection:"row",borderColor:l.codeBorder,paddingLeft:2,width:"100%"},s.createElement(A,{width:5,flexShrink:0},s.createElement(se,{color:"gray",dimColor:!0},de===0?String(B).padStart(4," ")+" ":" ")),s.createElement(A,{flexGrow:1},Ht(q,I,l.text)))))}if(T==="code-fence-close")return s.createElement(A,{flexDirection:"row",paddingLeft:2,marginBottom:1,width:"100%"},s.createElement(se,null," "));if(T==="write-header")return s.createElement(A,{flexDirection:"column",paddingX:1,width:f},s.createElement(Un,{text:S,columns:f,theme:p}));if(T==="write-line"){let{gutterWidth:B,lineNum:I,isFirstLine:F,isLastLine:$,extension:L,wrappedLines:W}=t,q=(de=!1)=>s.createElement(A,{flexDirection:"row",width:f,borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:l.codeBorder,paddingLeft:2,paddingRight:0,backgroundColor:l.codeBg,marginBottom:de?1:0},s.createElement(A,{width:B+2,flexShrink:0},s.createElement(se,null," ".repeat(B+2))),s.createElement(A,{flexGrow:1},s.createElement(se,null," ")));return s.createElement(A,{flexDirection:"column"},F&&q(!1),s.createElement(A,{flexDirection:"row",width:f,borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:l.codeBorder,paddingLeft:2,paddingRight:0,backgroundColor:l.codeBg},s.createElement(A,{width:B+2,flexShrink:0},s.createElement(se,{color:"gray",dimColor:!0},String(I).padStart(B," ")," ")),s.createElement(A,{flexGrow:1,flexDirection:"column"},(W||[S]).map((de,ue)=>s.createElement(A,{key:ue},Ht((de||"").replaceAll(" "," "),L,l.text))))),$&&q(!0))}return T==="write-footer"?s.createElement(A,{flexDirection:"column",paddingX:1,width:f,marginTop:1,marginBottom:1},s.createElement(Un,{text:S,columns:f,theme:p})):T==="worked-duration"?s.createElement(A,{marginTop:1,marginBottom:2,paddingX:1,width:"100%"},s.createElement(se,{color:l.textMuted},"["),s.createElement(se,{color:l.textMuted},"Worked for ",s.createElement(se,{bold:!0,color:l.text},Hr(O))),s.createElement(se,{color:l.textMuted},"]")):null}),Rc=s.memo(({messages:t,showFullThinking:f,columns:g=80,aiProvider:E,version:y,theme:p="Dark"})=>s.createElement(A,{flexDirection:"column",width:"100%"},t.map((l,w)=>s.createElement(Cl,{key:l.id||w,msg:l,showFullThinking:f,columns:g,aiProvider:E,version:y,theme:p}))));import bt from"react";import{Box as zo,Text as Co}from"ink";import{useState as ar,useEffect as dr,useRef as Gr}from"react";var cr=null;function Ml(){cr&&cr()}var Bd=t=>{if(t<=370)return"#00a564";if(t>=5e3)return"#ff0000";let f=[{t:370,r:0,g:165,b:100},{t:550,r:40,g:195,b:80},{t:800,r:120,g:220,b:50},{t:1100,r:190,g:225,b:20},{t:1500,r:250,g:210,b:15},{t:2e3,r:255,g:170,b:0},{t:2800,r:255,g:110,b:0},{t:3800,r:255,g:50,b:0},{t:5e3,r:255,g:0,b:0}];for(let g=0;g<f.length-1;g++){let E=f[g],y=f[g+1];if(t>=E.t&&t<=y.t){let p=(t-E.t)/(y.t-E.t);p=p*p*(3-2*p);let l=Math.round(E.r+(y.r-E.r)*p),w=Math.round(E.g+(y.g-E.g)*p),T=Math.round(E.b+(y.b-E.b)*p);return`#${((1<<24)+(l<<16)+(w<<8)+T).toString(16).slice(1)}`}}return"#ff0000"},vd=bt.memo(({mode:t,thinkingLevel:f,tokens:g="0.0k",tokensTotal:E="0.0k",cachedTokens:y=0,promptTokens:p=0,chatId:l="NEW-SESSION",isMemoryEnabled:w=!0,apiTier:T="Free",aiProvider:S="Google",activeModel:N="",isProcessing:O=!1,lastChunkTime:B=0,theme:I="Dark",wps:F=0,showTPMEstimate:$=!1})=>{let L=st(I),W="",[q,de]=ar(0),[ue,R]=ar(0),[oe,me]=ar("MB"),[Me,Xe]=ar("green"),[Ve,pe]=ar(0),Te=Gr([]),we=Gr(370),le=Gr([]),Ke=Gr(B);dr(()=>{Ke.current=B},[B]),dr(()=>{if(!O){le.current=[];return}if(F>0){let Y=le.current;Y.push(F),Y.length>3&&Y.shift()}},[O,F,B]),dr(()=>{if(!O){pe(0);return}let Y=setInterval(()=>{let ne=Ke.current,ee=ne>0?Date.now()-ne:0;if(ne>0&&ee>=1e3)le.current=[],pe(0);else if(ne>0&&ee>500){le.current.length>0&&le.current.shift();let ae=le.current;if(ae.length>0){let Ce=ae.reduce((ye,Ne)=>ye+Ne,0);pe(Math.round(Ce/ae.length))}else pe(0)}else{let ae=le.current;if(ae.length>0){let Ce=ae.reduce((ye,Ne)=>ye+Ne,0);pe(Math.round(Ce/ae.length))}else F>0&&pe(Math.round(F))}},750);return()=>clearInterval(Y)},[O]),dr(()=>{if(!O){Te.current=[];return}if(B>0){let ee=Te.current;(ee.length===0||ee[ee.length-1]!==B)&&(ee.push(B),ee.length>10&&ee.shift())}let Y=()=>{if(!B){Xe("#00a564");return}let ee=Te.current,ae=0;if(ee.length>1){let ie=0;for(let fe=1;fe<ee.length;fe++)ie+=ee[fe]-ee[fe-1];ae=ie/(ee.length-1)}let Ce=Date.now()-B,Ne=Ce>=2500,et=!Ne&&ae>0?Math.min(Ce,ae*3):Ce,lt=Math.max(ae,et),Ie=Ne?.4:.2;we.current=we.current*(1-Ie)+lt*Ie,Xe(Bd(we.current))};Y();let ne=setInterval(Y,100);return()=>clearInterval(ne)},[O,B]);let Ge=()=>{let Y=process.memoryUsage(),ne=Y.heapTotal/(1024*1024)>=1024,ee=ne?"GB":"MB",ae=(Ce,ye)=>{let Ne=Ce/(1048576*(ye?1024:1));return ye?parseFloat(Ne.toFixed(2)):Math.round(Ne)};me(ee),R(ae(Y.heapTotal,ne)),de(ae(Y.heapUsed,ne))};return dr(()=>{cr=Ge,Ge();let Y=setInterval(()=>{Ge()},6e4);return()=>{clearInterval(Y),cr===Ge&&(cr=null)}},[]),bt.createElement(zo,{flexDirection:"row",justifyContent:"space-between",paddingX:1,width:"100%"},bt.createElement(zo,null,bt.createElement(zo,{marginRight:1},bt.createElement(Co,{color:L.textMuted},t.toLowerCase()==="flow"?"Studio":t.toLowerCase()==="icu"?"Computer Use":t.toLowerCase()==="flux"?"Workspace":"Omni")),bt.createElement(Co,{color:L.textMuted,dimColor:!0},"\u2503 "),bt.createElement(zo,null,bt.createElement(Co,{color:L.text,italic:!0},Ki(process.cwd(),35)))),bt.createElement(zo,null,O&&!$?bt.createElement(zo,null,bt.createElement(Co,{color:Me},"\u25CF ")):null,O&&$&&bt.createElement(bt.Fragment,null,bt.createElement(Co,{color:L.textMuted},"~",Ve," tok/s"),bt.createElement(Co,{color:L.textMuted,dimColor:!0}," \u2503")),g>0&&bt.createElement(bt.Fragment,null,bt.createElement(zo,{marginX:1},bt.createElement(Co,{color:L.text},Tt(E)," tok",(()=>{let Y=typeof p=="number"?p:0,ne=typeof y=="number"?y:0,ee=Y>0?ne/Y*100:0;return ee<1?null:bt.createElement(Co,{color:L.success||"green",dimColor:!0}," [",ee.toFixed(0),"% cached]")})())),bt.createElement(Co,{color:L.textMuted,dimColor:!0},"\u2503")),bt.createElement(zo,{marginLeft:1},bt.createElement(Co,{color:L.textMuted,bold:!0},q," ",oe))))}),Sl=vd;import at,{useState as Wr,useMemo as Dd,useEffect as El}from"react";import{Box as Yt,Text as jt,useInput as Id}from"ink";import Ad from"ink-select-input";var kd=({label:t,isSelected:f,theme:g="Dark"})=>{let E=st(g),y=t==="Cancel"||t==="Back"||t.toLowerCase().includes("exit")||t.toLowerCase().includes("back");return at.createElement(Yt,{marginTop:y?1:0,backgroundColor:f?E.highlightBg:void 0,paddingX:1,width:"100%"},at.createElement(jt,{color:f?E.text:E.textMuted,bold:f},f?"\u276F ":" ",t))},Ld=8;function wt({title:t,subtitle:f,items:g=[],onSelect:E,theme:y="Dark",searchable:p=!1,maxVisible:l=Ld}){let w=st(y),[T,S]=Wr(""),[N,O]=Wr(0),[B,I]=Wr("list"),F=Dd(()=>{if(!p||!T.trim())return g;let ue=T.toLowerCase().trim();return g.filter(R=>R.label&&R.label.toLowerCase().includes(ue))},[g,T,p]);El(()=>{O(0)},[T]);let[$,L]=Wr(0);El(()=>{L(ue=>F.length<=l?0:N<ue?N:N>=ue+l?N-l+1:ue)},[N,F.length,l]),Id((ue,R)=>{if(p){if(R.upArrow){I("list"),O(oe=>F.length===0?0:oe>0?oe-1:F.length-1);return}if(R.downArrow){I("list"),O(oe=>F.length===0?0:oe<F.length-1?oe+1:0);return}if(R.return){F.length>0&&F[N]&&E(F[N]);return}if(R.escape){if(T)S(""),I("list"),O(0);else{let oe=g.find(me=>me.value==="Back"||me.label==="Back"||me.value==="Cancel"||me.label==="Cancel");oe&&E(oe)}return}if(R.backspace||R.delete){I("search"),S(oe=>oe.slice(0,-1));return}if(ue&&!R.ctrl&&!R.meta&&!R.tab){I("search"),S(oe=>oe+ue);return}}},{isActive:p});let W=F.length,q=$;W<=l?q=0:q=Math.max(0,Math.min($,W-l));let de=F.slice(q,q+l);return p?at.createElement(Yt,{flexDirection:"column",borderStyle:"round",borderColor:w.borderMuted,padding:0,marginTop:0,flexShrink:0,width:"100%"},at.createElement(Yt,{paddingX:1,paddingY:0,marginBottom:0,flexDirection:"row",justifyContent:"space-between"},t?at.createElement(jt,{color:w.text,bold:!0},typeof t=="string"?t.toUpperCase():t):at.createElement(Yt,null),W>0&&at.createElement(jt,{color:w.textMuted},N+1,"/",W)),f&&at.createElement(Yt,{paddingX:1,marginBottom:0},at.createElement(jt,{color:w.textMuted,italic:!0}," ",f)),at.createElement(Yt,{paddingX:1,marginTop:1,marginBottom:1,flexDirection:"row"},at.createElement(jt,{color:B==="search"?w.primary||"cyan":w.textMuted,bold:B==="search"},"\u{1F50D} Search:"),at.createElement(jt,{color:w.text,bold:!0}," ",T),B==="search"?at.createElement(jt,{color:w.primary||"cyan"},"\u2588"):T?null:at.createElement(jt,{color:w.textMuted,italic:!0}," (type to search...)")),at.createElement(Yt,{flexDirection:"column",width:"100%"},F.length===0?at.createElement(Yt,{paddingX:1,marginY:0},at.createElement(jt,{color:w.warning||"yellow",italic:!0}," No matching items found")):de.map((ue,R)=>{let oe=q+R,me=oe===N,Me=ue.label==="Cancel"||ue.label==="Back"||ue.label.toLowerCase().includes("exit")||ue.label.toLowerCase().includes("back");return at.createElement(Yt,{key:ue.value??ue.label??oe,marginTop:Me?1:0,backgroundColor:me?w.highlightBg:void 0,paddingX:1,width:"100%"},at.createElement(jt,{color:me?w.text:w.textMuted,bold:me},me?"\u276F ":" ",ue.label))})),at.createElement(Yt,{paddingX:1,marginTop:1},at.createElement(jt,{color:w.textMuted,italic:!0},B==="search"?"(Type letters to search \u2022 Arrows for list mode \u2022 Enter to select)":"(Arrows to navigate \u2022 Type letters to search \u2022 Enter to select)"))):at.createElement(Yt,{flexDirection:"column",borderStyle:"round",borderColor:w.borderMuted,padding:0,marginTop:0,flexShrink:0,width:"100%"},t&&at.createElement(Yt,{paddingX:1,paddingY:0,marginBottom:f?0:1,flexDirection:"row",justifyContent:"space-between"},at.createElement(jt,{color:w.text,bold:!0},typeof t=="string"?t.toUpperCase():t),g.length>l&&at.createElement(jt,{color:w.textMuted,italic:!0},g.length," options")),f&&at.createElement(Yt,{paddingX:1,marginBottom:1},at.createElement(jt,{color:w.textMuted,italic:!0}," ",f)),at.createElement(Yt,{flexDirection:"column",width:"100%"},at.createElement(Ad,{items:g,onSelect:E,limit:l,itemComponent:ue=>at.createElement(kd,{...ue,theme:y}),indicatorComponent:()=>null})),at.createElement(Yt,{paddingX:1,marginTop:1},at.createElement(jt,{color:w.textMuted,italic:!0},"(Arrows to select \u2022 Enter to confirm)")))}import D,{useState as Ut,useEffect as ur}from"react";import{Box as He,Text as K,useInput as Od}from"ink";import Pd from"ink-text-input";import Nd from"v8";import Bl from"os";var Mo=[...Object.keys(Qi),"Mystery"],So=[{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"}],vl=t=>{let f=t.autoApproveCommands||"",g=t.autoDisallowCommands||"",E=t.alwaysAskCommands||"",y=t.autoExec===!1&&t.allowExternalAccess===!1&&t.networkAccess===!1&&f===""&&g==="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"&&E==="killall, pkill, taskkill, shutdown, reboot, init 0, init 6, Stop-Process, Stop-Service, mv /*, move c:\\*, chmod 000, chmod -R 777, chown, icacls, netsh advfirewall, iptables -F, ufw disable, git reset --hard, git clean -fd, npm r, npm uninstall"&&t.autoApproveGit===!1,p=t.autoExec===!0&&t.allowExternalAccess===!1&&t.networkAccess!==!1&&f==="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"&&g==="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"&&E==="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,l=t.autoExec===!0&&t.allowExternalAccess===!0&&t.networkAccess!==!1&&f==="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"&&g===""&&E==="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 y?"Strict":p?"Balanced":l?"Autonomous":t.sandboxPreset||"Custom"},Ns=t=>!t||t.trim()===""?"None":t.length>40?t.substring(0,40)+"...":t;function Vr({systemSettings:t,setSystemSettings:f,apiTier:g,setActiveView:E,setInputConfig:y,saveSettings:p,quotas:l,setMessages:w,aiProvider:T,initialSelectingTheme:S=!1,onCloseTheme:N=null,setProviderReturnView:O=null}){let B=t.theme==="Chaos"||t.theme==="Mystery"?"Mystery":t.theme||"Dark",I=Mo.indexOf(B),[F,$]=Ut("categories"),[L,W]=Ut(0),[q,de]=Ut(0),[ue,R]=Ut(null),[oe,me]=Ut(""),[Me,Xe]=Ut(S),[Ve,pe]=Ut(I>=0?I:0),[Te,we]=Ut(t.theme||"Dark"),[le,Ke]=Ut(!1),[Ge,Y]=Ut(0),[ne,ee]=Ut(0),[ae,Ce]=Ut(""),[ye,Ne]=Ut("list"),[et,lt]=Ut({});ur(()=>{(async()=>{let b=["Google","DeepSeek","OpenRouter","NVIDIA","Mistral","Ollama","InferX","SenseNova","AIHubMix","Poolside","9router","ExpLabs","TokenHarbor","Infron","APInex","c_openai"],P={};for(let Ae of b)try{await qo(Ae)&&(P[Ae]=!0)}catch{}lt(P)})()},[]);let Ie=D.useMemo(()=>{let ge=["Google","DeepSeek","OpenRouter","NVIDIA","Mistral","Ollama","InferX","SenseNova","AIHubMix","Poolside","9router","ExpLabs","TokenHarbor","Infron","APInex","c_openai"],P=!!(process.env.SUBAGENT_MODEL&&process.env.SUBAGENT_MODEL.trim())?`ENV (${process.env.SUBAGENT_MODEL.trim()})`:"ENV",Ae=[{label:"Default (use the current model)",value:"Default",isHeader:!1},{label:P,value:"ENV",isHeader:!1}],Ye=l?.providerTiers?.[T]||g||"Free",dt=Ko(T,Ye)||[];dt.length>0&&(Ae.push({label:`\u2500\u2500 ${T.toUpperCase()}${Ye!=="Free"?` (${Ye})`:""} \u2500\u2500`,isHeader:!0}),dt.forEach(xt=>{let Qe=typeof xt=="string"?xt:xt.cmd||xt.name||xt.id||String(xt);Qe&&!Qe.trim().startsWith("---")&&!Qe.startsWith(`
|
|
43
|
-
---`)&&Ae.push({label:Qe,value:Qe,isHeader:!1,provider:T})}));for(let xt of ge)if(xt!==T&&et[xt]){let Qe=l?.providerTiers?.[xt]||"Free",oo=Ko(xt,Qe)||[];oo.length>0&&(Ae.push({label:`\u2500\u2500 ${xt.toUpperCase()}${Qe!=="Free"?` (${Qe})`:""} \u2500\u2500`,isHeader:!0}),oo.forEach(Ze=>{let Nt=typeof Ze=="string"?Ze:Ze.cmd||Ze.name||Ze.id||String(Ze);Nt&&!Nt.trim().startsWith("---")&&!Nt.startsWith(`
|
|
44
|
-
---`)&&Ae.push({label:Nt,value:Nt,isHeader:!1,provider:xt})}))}return Ae},[T,g,l,et]),ie=D.useMemo(()=>{if(!ae.trim())return Ie;let ge=ae.trim().toLowerCase(),b=[],P=null;for(let Ae of Ie)Ae.isHeader?P=Ae:(Ae.label.toLowerCase().includes(ge)||Ae.value&&Ae.value.toLowerCase().includes(ge))&&(P&&!b.includes(P)&&b.push(P),b.push(Ae));return b},[Ie,ae]);ur(()=>{if(le){let ge=ie.findIndex(b=>!b.isHeader);Y(ge>=0?ge:0),ee(0)}},[ae]),ur(()=>{if(le){if(ie.length===0){Y(0),ee(0);return}if(Ge>=ie.length||ie[Ge]?.isHeader){let ge=ie.findIndex(b=>!b.isHeader);Y(ge>=0?ge:0)}}},[ie,le]);let[fe,De]=Ut(0),[v,Ue]=Ut(0),[nt,At]=Ut("MB"),[zt,Jr]=Ut(!1);ur(()=>{let ge=!1;return import("./exec_command-ZPCKBWBK.js").then(b=>{ge||Jr(!!b.isPtyAvailable)}).catch(()=>{}),()=>{ge=!0}},[]),ur(()=>{let ge=Nd.getHeapStatistics().heap_size_limit,b=ge>=1024*1024*1024,P=b?"GB":"MB",Ae=b?1024*1024*1024:1024*1024;Ue(parseFloat((ge/Ae).toFixed(2))),At(P);let Ye=()=>{let oo=process.memoryUsage().rss/Ae,Ze=b?parseFloat(oo.toFixed(2)):Math.round(oo);De(Ze)};Ye();let dt=setInterval(()=>{Ye()},3e4);return()=>clearInterval(dt)},[]);let tn=ge=>{switch(ge){case"providers":{let P=[{label:"Current Provider",value:"aiProvider",status:T==="c_openai"?"Custom (OpenAI)":T}];return T==="Ollama"&&P.push({label:"Endpoint",value:"ollamaEndpoint",status:t.ollamaEndpoint||"Cloud"}),(T==="c_openai"||T==="Custom (OpenAI)")&&(P.push({label:"Base URL",value:"customOpenAIBaseUrl",status:t.customOpenAIBaseUrl||"Not Configured"}),P.push({label:"API Key (if needed)",value:"customOpenAIKey",status:et.c_openai?"Set":"None"})),P}case"appearance":return[{label:"Theme",value:"theme",status:t.theme||"Dark"},{label:"Loading Phrases",value:"loadingPhrases",status:t.loadingPhrases!==!1?"ON":"OFF"},{label:"Progressive Rendering [EXPERIMENTAL]",value:"progressiveRendering",status:t.progressiveRendering?"ON":"OFF"},{label:"Show TPM Estimate",value:"showTPMEstimate",status:t.showTPMEstimate?"ON":"OFF"},{label:"Verbose Thinking",value:"preserveThinking",status:t.preserveThinking!==!1?"ON":"OFF"}];case"memory":return[{label:"Toggle Memory [Legacy]",value:"memory",status:t.memory?"ON":"OFF"}];case"security":return[{label:"Sandbox Preset",value:"sandboxPreset",status:vl(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:Ns(t.alwaysAskCommands),section:"Sandbox"},{label:"Auto Approve Commands",value:"autoApprove",status:Ns(t.autoApproveCommands),section:"Sandbox"},{label:"Auto Disapprove Commands",value:"autoDisallow",status:Ns(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:"Directory Tree Design",value:"indentationTree",status:t.indentationTree!==!1?"Modern":"Legacy"},{label:"Compact Large Tool Results",value:"compressToolResults",status:t.compressToolResults?"ON":"OFF"},{label:"Auto Truncate Results",value:"autoTruncateResults",status:t.autoTruncateResults?"ON":"OFF"},{label:"Image History for CU",value:"imageHistoryCU",status:t.imageHistoryCU||"Standard"},{label:"Context Length",value:"contextLength",status:t.contextLength||"256k"},{label:"Keep Reasoning Context",value:"keepReasoningContext",status:t.keepReasoningContext?"ON":"OFF"},{label:"Auto Exclude Metadata",value:"autoExcludeMetadata",status:t.autoExcludeMetadata?"ON":"OFF"},{label:"Disable Todo",value:"disableTodo",status:t.disableTodo?"ON":"OFF"}];default:return[]}},gn=So[L].id,qe=tn(gn);Od((ge,b)=>{if(le){if(b.tab){Ne(P=>P==="search"?"list":"search");return}if(ye==="search"){b.escape?Ke(!1):b.downArrow||b.return?Ne("list"):b.backspace||b.delete?Ce(P=>P.slice(0,-1)):ge&&!b.ctrl&&!b.meta&&ge.length===1&&Ce(P=>P+ge);return}if(b.upArrow)Y(P=>{if(ie.length===0)return 0;let Ae=(P-1+ie.length)%ie.length,Ye=0;for(;ie[Ae]?.isHeader&&Ye<ie.length;)Ae=(Ae-1+ie.length)%ie.length,Ye++;return Ae});else if(b.downArrow)Y(P=>{if(ie.length===0)return 0;let Ae=(P+1)%ie.length,Ye=0;for(;ie[Ae]?.isHeader&&Ye<ie.length;)Ae=(Ae+1)%ie.length,Ye++;return Ae});else if(b.return){let P=ie[Ge];P&&!P.isHeader&&(f(Ae=>{let Ye=P.value==="Default",dt={...Ae,CustomSubAgent:!Ye,SubAgentModel:P.value,SubAgentProvider:Ye?"":P.provider||""};return p({systemSettings:dt,apiTier:g,quotas:l}),dt}),Ke(!1))}else b.escape?Ke(!1):ge&&!b.ctrl&&!b.meta&&ge.length===1&&(Ce(P=>P+ge),Ne("search"));return}if(Me){if(b.upArrow){let P=(Ve-1+Mo.length)%Mo.length;pe(P)}else if(b.downArrow){let P=(Ve+1)%Mo.length;pe(P)}else if(b.return){let P=Mo[Ve];f(Ae=>{let Ye={...Ae,theme:P};return p({systemSettings:Ye,apiTier:g,quotas:l}),Ye}),N?N():Xe(!1)}else b.escape&&(N?N():Xe(!1));return}if(ue){b.escape&&R(null);return}if(F==="categories")b.upArrow?W(P=>(P-1+So.length)%So.length):b.downArrow?W(P=>(P+1)%So.length):b.return||b.rightArrow?So[L].id==="exit"?E("chat"):($("items"),de(0)):b.escape&&E("chat");else if(F==="items"){if(b.upArrow)de(P=>(P-1+qe.length)%qe.length);else if(b.downArrow)de(P=>(P+1)%qe.length);else if(b.leftArrow||b.escape)$("categories");else if(b.return){let P=qe[q];Kt(P)}}});let Kt=ge=>{if(ge.value==="memory")f(b=>({...b,memory:!b.memory}));else if(ge.value==="sandboxPreset"){let b=vl(t),P=["Autonomous","Balanced","Strict"],Ye=(P.indexOf(b)+1)%P.length,dt=P[Ye];f(xt=>{let Qe={...xt,sandboxPreset:dt};return dt==="Strict"?(Qe.autoExec=!1,Qe.allowExternalAccess=!1,Qe.networkAccess=!1,Qe.autoApproveCommands="",Qe.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",Qe.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",Qe.autoApproveGit=!1):dt==="Balanced"?(Qe.autoExec=!0,Qe.allowExternalAccess=!1,Qe.networkAccess=!0,Qe.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",Qe.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",Qe.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",Qe.autoApproveGit=!1):dt==="Autonomous"&&(Qe.autoExec=!0,Qe.allowExternalAccess=!0,Qe.networkAccess=!0,Qe.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",Qe.autoDisallowCommands="",Qe.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",Qe.autoApproveGit=!0),Qe})}else if(ge.value==="autoExec")t.autoExec?f(b=>({...b,autoExec:!1,sandboxPreset:"Custom"})):t.allowExternalAccess?E("doubleDanger"):E("autoExecDanger");else if(ge.value==="externalAccess")t.allowExternalAccess?f(b=>({...b,allowExternalAccess:!1,sandboxPreset:"Custom"})):t.autoExec?E("doubleDanger"):E("externalDanger");else if(ge.value==="networkAccess")f(b=>({...b,networkAccess:b.networkAccess===!1,sandboxPreset:"Custom"}));else if(ge.value==="alwaysAsk")R("alwaysAskCommands"),me(t.alwaysAskCommands||"");else if(ge.value==="autoApprove")R("autoApproveCommands"),me(t.autoApproveCommands||"");else if(ge.value==="autoApproveGit")f(b=>({...b,autoApproveGit:!b.autoApproveGit,sandboxPreset:"Custom"}));else if(ge.value==="customOpenAIBaseUrl")R("customOpenAIBaseUrl"),me(t.customOpenAIBaseUrl||"");else if(ge.value==="customOpenAIKey")R("customOpenAIKey"),me("");else if(ge.value==="ollamaEndpoint")f(b=>{let P=b.ollamaEndpoint==="Local"?"Cloud":"Local",Ae={...b,ollamaEndpoint:P};return p({systemSettings:Ae,apiTier:g,quotas:l}),Ae});else if(ge.value==="apiTier")E("apiTier");else if(ge.value==="aiProvider")O&&O("settings"),E("selectProvider");else if(ge.value==="advanceRollback")t.advanceRollback?f(b=>{let P={...b,advanceRollback:!1};return p({systemSettings:P,apiTier:g,quotas:l}),P}):E("advanceRollbackDanger");else if(ge.value==="autoDelete"){let b=["1d","7d","30d"],Ae=(b.indexOf(t.autoDeleteHistory||"30d")+1)%b.length;f(Ye=>({...Ye,autoDeleteHistory:b[Ae]}))}else if(ge.value==="autoUpdate")f(b=>({...b,autoUpdate:!b.autoUpdate}));else if(ge.value==="externalData")if(!t.useExternalData)y({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||""}),E("input");else{let b={...t,useExternalData:!1};f(b),p({systemSettings:b,apiTier:g,quotas:l}),w(P=>[...P,{id:Date.now(),role:"system",text:"[STORAGE RESET] Flux Flow will return to default ~/.fluxflow after restart."}]),E("chat")}else if(ge.value==="updateManager")E("updateManager");else if(ge.value==="parserDownload")E("parserDownload");else if(ge.value==="indentationTree")f(b=>{let P={...b,indentationTree:b.indentationTree===!1};return p({systemSettings:P,apiTier:g,quotas:l}),P});else if(ge.value==="compressToolResults")f(b=>{let P={...b,compressToolResults:!b.compressToolResults};return p({systemSettings:P,apiTier:g,quotas:l}),P});else if(ge.value==="autoTruncateResults")f(b=>{let P={...b,autoTruncateResults:!b.autoTruncateResults};return p({systemSettings:P,apiTier:g,quotas:l}),P});else if(ge.value==="imageHistoryCU"){let b=["Low","Standard","Extended","Max"],Ae=(b.indexOf(t.imageHistoryCU||"Standard")+1)%b.length;f(Ye=>{let dt={...Ye,imageHistoryCU:b[Ae]};return p({systemSettings:dt,apiTier:g,quotas:l}),dt})}else if(ge.value==="contextLength"){let b=["16k","32k","64k","128k","256k","512k","1M"],Ae=(b.indexOf(t.contextLength||"256k")+1)%b.length;f(Ye=>{let dt={...Ye,contextLength:b[Ae]};return p({systemSettings:dt,apiTier:g,quotas:l}),dt})}else if(ge.value==="keepReasoningContext")f(b=>{let P={...b,keepReasoningContext:!b.keepReasoningContext};return p({systemSettings:P,apiTier:g,quotas:l}),P});else if(ge.value==="autoExcludeMetadata")f(b=>{let P={...b,autoExcludeMetadata:!b.autoExcludeMetadata};return p({systemSettings:P,apiTier:g,quotas:l}),P});else if(ge.value==="disableTodo")f(b=>{let P={...b,disableTodo:!b.disableTodo};return p({systemSettings:P,apiTier:g,quotas:l}),P});else if(ge.value==="subAgents")f(b=>{let P={...b,subAgents:b.subAgents===!1};return p({systemSettings:P,apiTier:g,quotas:l}),P});else if(ge.value==="subAgentModel"){let b=t.CustomSubAgent&&t.SubAgentModel?t.SubAgentModel:"Default",P=ie.findIndex(Ae=>Ae.value===b);Y(P>=0?P:0),Ke(!0)}else if(ge.value==="preserveThinking")f(b=>{let P={...b,preserveThinking:b.preserveThinking===!1};return Tl(P.preserveThinking),p({systemSettings:P,apiTier:g,quotas:l}),P});else if(ge.value==="loadingPhrases")f(b=>{let P={...b,loadingPhrases:b.loadingPhrases===!1};return p({systemSettings:P,apiTier:g,quotas:l}),P});else if(ge.value==="progressiveRendering")f(b=>{let P={...b,progressiveRendering:!b.progressiveRendering};return p({systemSettings:P,apiTier:g,quotas:l}),P});else if(ge.value==="showTPMEstimate")f(b=>{let P={...b,showTPMEstimate:!b.showTPMEstimate};return p({systemSettings:P,apiTier:g,quotas:l}),P});else if(ge.value==="theme"){let b=t.theme==="Chaos"||t.theme==="Mystery"?"Mystery":t.theme||"Dark",P=Mo.indexOf(b);pe(P>=0?P:0),we(t.theme||"Dark"),Xe(!0)}},Ee=st(t.theme);if(le){let ge=t.CustomSubAgent&&t.SubAgentModel?t.SubAgentModel:"Default",b=15,P=ne;Ge<P?P=Ge:Ge>=P+b&&(P=Ge-b+1),P=Math.max(0,Math.min(P,Math.max(0,ie.length-b))),P!==ne&&ee(P);let Ae=ie.slice(P,P+b);return D.createElement(He,{flexDirection:"column",borderStyle:"round",borderColor:Ee.border,padding:1,width:"100%",minHeight:32},D.createElement(He,{marginBottom:1,flexDirection:"row",justifyContent:"space-between"},D.createElement(K,{color:Ee.text,bold:!0,underline:!0},"Select Sub-Agent Model:"),ie.length>0&&D.createElement(K,{color:"gray"},Ge+1,"/",ie.length)),D.createElement(He,{borderStyle:"single",borderColor:ye==="search"?Ee.primary||"cyan":"gray",paddingX:1,marginBottom:1},D.createElement(K,{color:ye==="search"?Ee.primary||"cyan":"gray",bold:!0},"\u{1F50D} Search: "," "),D.createElement(K,{color:Ee.text},ae),ye==="search"&&D.createElement(K,{color:Ee.primary||"cyan"},"\u2588"),!ae&&ye!=="search"&&D.createElement(K,{color:"gray",italic:!0},"(Press TAB or type to filter models...)")),D.createElement(He,{flexDirection:"column",flexGrow:1,height:b},Ae.length>0?Ae.map((Ye,dt)=>{let xt=P+dt;if(Ye.isHeader)return D.createElement(He,{key:`hdr-${xt}`,paddingX:1},D.createElement(K,{color:"gray",bold:!0,underline:!0},Ye.label));let Qe=Ge===xt&&ye==="list",oo=ge===Ye.value;return D.createElement(He,{key:`item-${Ye.value}-${xt}`,paddingX:1,backgroundColor:Qe?Ee.highlightBg:void 0},D.createElement(K,{color:Qe?Ee.text:Ee.textDim,bold:Qe},Qe?"\u276F ":" ",Ye.label,oo?D.createElement(K,{color:Ee.primary||"cyan",italic:!0}," (active)"):""))}):D.createElement(He,{paddingX:1},D.createElement(K,{color:"gray",italic:!0},'No models matching "',ae,'"'))),D.createElement(He,{paddingX:1,marginTop:1,flexDirection:"row",justifyContent:"space-between"},D.createElement(K,{color:"gray",italic:!0},"TAB to switch search/list \u2022 \u25B2\u25BC Navigate \u2022 ENTER to Select \u2022 ESC to Cancel"),D.createElement(K,{color:ye==="search"?Ee.primary||"cyan":"gray",bold:!0},"[",ye.toUpperCase()," MODE]")))}if(Me){let ge=Mo[Ve],b=st(ge);return D.createElement(He,{flexDirection:"column",borderStyle:"round",borderColor:b.border,padding:1,width:"100%",minHeight:32},D.createElement(He,{marginBottom:1},D.createElement(K,{color:b.text,bold:!0},"Choose your color scheme:")),D.createElement(He,{flexDirection:"row",width:"100%",flexGrow:1},D.createElement(He,{flexDirection:"column",width:"30%",paddingRight:1},Mo.map((P,Ae)=>{let Ye=Ve===Ae,dt=(t.theme||"Dark")===P,xt=P==="Forest Sprite"||P==="Spookfest";return D.createElement(He,{key:P,paddingX:0},D.createElement(K,{color:Ye?b.text:b.textDim,bold:Ye},Ye?"> ":" ",P,xt&&D.createElement(K,{color:Ye?b.success||"#52b788":"green",bold:!0}," \u2605"),dt?D.createElement(K,{color:b.primary||"cyan",italic:!0}," (saved)"):""))})),D.createElement(He,{flexDirection:"column",flexGrow:1,borderStyle:"round",borderColor:b.borderMuted,paddingX:2,paddingY:1,backgroundColor:b.cardBg},D.createElement(He,{marginBottom:1},D.createElement(K,{color:b.secondary||"cyan",bold:!0},"> ","you: "),D.createElement(K,{color:b.text},"add a greeting function")),D.createElement(He,{marginBottom:1},D.createElement(K,{color:b.success||"green"}," Here's the change:")),D.createElement(He,{flexDirection:"column",marginLeft:2,marginBottom:1},D.createElement(K,null,D.createElement(K,{color:b.textDim},"3 "),D.createElement(K,{color:b.textDim},' import "fmt"')),D.createElement(K,{color:b.textDim},"4"),D.createElement(He,{backgroundColor:b.diffRemovalBg},D.createElement(K,null,D.createElement(K,{color:b.diffRemovalNum||b.diffRemovalText},"5 "),D.createElement(K,{color:b.diffRemovalPrefix||b.diffRemovalText},"- "),D.createElement(K,{color:b.diffRemovalText},"func "),D.createElement(K,{color:b.diffRemovalHighlightColor||b.diffRemovalText,backgroundColor:b.diffRemovalHighlightBg,bold:!0},"main()"),D.createElement(K,{color:b.diffRemovalText}," {"))),D.createElement(He,{backgroundColor:b.diffAdditionBg},D.createElement(K,null,D.createElement(K,{color:b.diffAdditionNum||b.diffAdditionText},"5 "),D.createElement(K,{color:b.diffAdditionPrefix||b.diffAdditionText},"+ "),D.createElement(K,{color:b.diffAdditionText},"func "),D.createElement(K,{color:b.diffAdditionHighlightColor||b.diffAdditionText,backgroundColor:b.diffAdditionHighlightBg,bold:!0},"greet(name string)"),D.createElement(K,{color:b.diffAdditionText}," {"))),D.createElement(He,{backgroundColor:b.diffAdditionBg},D.createElement(K,null,D.createElement(K,{color:b.diffAdditionNum||b.diffAdditionText},"6 "),D.createElement(K,{color:b.diffAdditionPrefix||b.diffAdditionText},"+ "),D.createElement(K,{color:b.diffAdditionText}," "),D.createElement(K,{color:b.diffAdditionHighlightColor||b.diffAdditionText,backgroundColor:b.diffAdditionHighlightBg},'fmt.Printf("Hello, %s!\\n", name)'))),D.createElement(K,{color:b.textDim},"7 }")),D.createElement(He,{flexDirection:"column",marginTop:1,marginBottom:1},D.createElement(K,{color:b.textDim},"\u25BE Thought Process"),D.createElement(K,{color:b.textMuted}," I need to add a greeting function. I'll use fmt.Printf.")),D.createElement(He,{flexDirection:"column"},D.createElement(K,null,D.createElement(K,{color:b.warning||"yellow"},"\u2699 tool: "),D.createElement(K,{color:b.text},"write_file main.go")),D.createElement(K,null,D.createElement(K,{color:b.accent||"magenta"},"\u29BF task: "),D.createElement(K,{color:b.text},"Implementing greeting")),D.createElement(K,null,D.createElement(K,{color:b.danger||"red"},"X error: "),D.createElement(K,{color:b.text},"compilation failed")),D.createElement(K,null,D.createElement(K,{color:b.warning||"yellow"},"\u26A0 warning: "),D.createElement(K,{color:b.text},"deprecation warning")),D.createElement(K,null,D.createElement(K,{color:b.info||"blue"},"\u2192 link: "),D.createElement(K,{color:b.info||"blue",underline:!0},"file:///path/to/main.go")),D.createElement(K,null,D.createElement(K,{color:b.accent||"magenta"},"\u2605 accent: "),D.createElement(K,{color:b.text},"highlighted text")),D.createElement(K,{color:b.textDim},"\xB7 dim: press Enter to continue")))),D.createElement(He,{paddingX:1,marginTop:1,flexDirection:"row",justifyContent:"space-between"},D.createElement(K,{color:"gray",italic:!0},"\u25B2\u25BC Navigate \u2022 ENTER to Select \u2022 ESC to Cancel"),D.createElement(K,{color:"gray"},"Previewing: ",Mo[Ve],Mo[Ve]==="Forest Sprite"?" \u2605":"")))}return D.createElement(He,{flexDirection:"column",borderStyle:"round",borderColor:Ee.border,padding:0,width:"100%",minHeight:32},D.createElement(He,{paddingX:1,paddingY:0,marginBottom:0,borderStyle:"single",borderColor:Ee.borderMuted,width:"100%"},D.createElement(K,{color:Ee.text,bold:!0},"SYSTEM CONFIGURATION")),D.createElement(He,{flexDirection:"row",width:"100%",minHeight:26},D.createElement(He,{flexDirection:"column",width:"30%",maxWidth:40,borderStyle:"round",borderColor:F==="categories"?Ee.border:Ee.borderMuted,padding:1,paddingY:0},D.createElement(He,{marginBottom:1},D.createElement(K,{color:F==="categories"?Ee.text:Ee.textDim,bold:!0,underline:!0},"CATEGORIES")),So.map((ge,b)=>{let P=L===b,Ae=ge.id==="exit";return D.createElement(He,{key:ge.id,marginTop:Ae?15:0,backgroundColor:P?F==="categories"?Ee.highlightBg:Ee.cardBg:void 0,paddingX:1},D.createElement(K,{color:P&&F==="categories"?Ee.text:Ee.textDim,bold:P},P?"\u276F ":" ",ge.label))})),D.createElement(He,{flexDirection:"column",flexGrow:1,borderStyle:"round",borderColor:F==="items"?Ee.border:Ee.borderMuted,paddingX:1,marginLeft:1,paddingY:0},D.createElement(He,{marginBottom:1},D.createElement(K,{color:F==="items"?Ee.text:Ee.textDim,bold:!0,underline:!0},So[L].label.toUpperCase().includes("EXIT")?"Runtime Information":`${So[L].label} Settings`)),qe.length>0?(()=>{let ge=null,b=[],P=Ze=>(Ze||"").split(",").map(Nt=>Nt.trim().toLowerCase()).filter(Boolean),Ae=P(t.autoApproveCommands),Ye=P(t.autoDisallowCommands),dt=P(t.alwaysAskCommands),xt=[...Ae,...Ye,...dt],Qe=new Set(xt),oo=gn==="security"&&xt.length!==Qe.size;return qe.forEach((Ze,Nt)=>{let _t=F==="items"&&q===Nt,Zr=Ze.label.length,on=Math.max(2,38-Zr),Rr=".".repeat(on),gt=Gt=>gn==="security"?(Gt.value==="autoExec"||Gt.value==="externalAccess")&&Gt.status==="ON"?Ee.statusOn:Ee.statusOff:Gt.status?.startsWith("\u2713")?Ee.statusOn:Gt.status?.startsWith("\u26A0")?Ee.statusOff:Gt.status==="ON"?Ee.statusOn:Gt.status==="OFF"?Ee.statusOff:Ee.text;Ze.section&&Ze.section!==ge&&(ge=Ze.section,b.push(D.createElement(He,{key:`sec-hdr-${Ze.section}`,marginTop:b.length>0?1:0,marginBottom:0,paddingX:1},D.createElement(K,{color:"gray",bold:!0,underline:!0},Ze.section.toUpperCase()))));let Q=_t&&ue&&(ue==="alwaysAskCommands"&&Ze.value==="alwaysAsk"||ue==="autoApproveCommands"&&Ze.value==="autoApprove"||ue==="autoDisallowCommands"&&Ze.value==="autoDisallow"||ue==="customOpenAIBaseUrl"&&Ze.value==="customOpenAIBaseUrl"||ue==="customOpenAIKey"&&Ze.value==="customOpenAIKey"),Wn=Ze.value==="alwaysAsk"||Ze.value==="autoApprove"||Ze.value==="autoDisallow",es=Ze.value==="parserDownload";b.push(D.createElement(He,{key:Ze.value,flexDirection:"column"},D.createElement(He,{backgroundColor:_t&&!Q?Ee.highlightBg:void 0,paddingX:2},D.createElement(K,{color:_t?Ee.text:Ee.textDim,bold:_t},_t?"\u276F ":" ",Ze.label),!Wn&&!es&&D.createElement(D.Fragment,null,D.createElement(K,{color:"gray"},Rr),D.createElement(K,{color:gt(Ze),bold:!0},Ze.value==="aiProvider"?Ze.status:`[ ${Ze.status} ]`))),Wn&&!Q&&Ze.status!=="None"&&D.createElement(He,{paddingX:4,marginBottom:1},D.createElement(K,{color:"gray"},"\u21B3 ",Ze.status)),Q&&D.createElement(He,{flexDirection:"column",marginLeft:4,marginBottom:1},D.createElement(He,{paddingX:1,borderStyle:"single",borderColor:"gray",flexDirection:"row"},D.createElement(K,{color:"gray",bold:!0},"> "," "),D.createElement(Pd,{value:oe,onChange:me,onSubmit:async Gt=>{if(ue==="customOpenAIBaseUrl"){let it=Gt.trim().replace(/\/+$/,""),no={...t,customOpenAIBaseUrl:it};f(no),p({systemSettings:no,apiTier:g,quotas:l})}else if(ue==="customOpenAIKey"){let{saveProviderAPIKey:it}=await import("./secrets-UNXNDOLK.js");await it("c_openai",Gt.trim()),lt(no=>({...no,c_openai:!!Gt.trim()}))}else{let it={...t,[ue]:Gt.trim(),sandboxPreset:"Custom"};f(it),p({systemSettings:it,apiTier:g,quotas:l})}R(null)}})),D.createElement(K,{color:"gray",italic:!0}," ",ue==="customOpenAIBaseUrl"?"Enter Base URL (.../v1) \u2022 Press Enter to save, Esc to cancel \u2022 Restart Required":ue==="customOpenAIKey"?"Enter API Key \u2022 Press Enter to save, Esc to cancel \u2022 Restart Required":"Comma separated \u2022 Press Enter to save, Esc to cancel"))))}),oo&&b.push(D.createElement(He,{key:"conflict-warning",marginTop:1,paddingX:1},D.createElement(K,{color:Ee.text,italic:!0},"* Conflicting commands will be ignored and defaulted to highest priority"))),b})():D.createElement(He,{paddingX:1,flexDirection:"column",width:"100%"},gn==="exit"?D.createElement(D.Fragment,null,D.createElement(He,{flexDirection:"column",marginBottom:1},D.createElement(He,{flexDirection:"row"},D.createElement(K,{color:Ee.textDim},"OS"," "),D.createElement(K,{color:"gray"},"..................... "),D.createElement(K,{color:Ee.text},process.env.OS||process.platform||"N/A")),D.createElement(He,{flexDirection:"row"},D.createElement(K,{color:Ee.textDim},"Computer Name"," "),D.createElement(K,{color:"gray"},".......... "),D.createElement(K,{color:Ee.text},process.env.COMPUTERNAME||process.env.HOSTNAME||"N/A")),D.createElement(He,{flexDirection:"row"},D.createElement(K,{color:Ee.textDim},"Processor Count"," "),D.createElement(K,{color:"gray"},"........ "),D.createElement(K,{color:Ee.text},process.env.NUMBER_OF_PROCESSORS||"N/A")),D.createElement(He,{flexDirection:"row"},D.createElement(K,{color:Ee.textDim},"Node.js Version"," "),D.createElement(K,{color:"gray"},"........ "),D.createElement(K,{color:Ee.text},"v",process.versions.node)),D.createElement(He,{flexDirection:"row"},D.createElement(K,{color:Ee.textDim},"V8 Version"," "),D.createElement(K,{color:"gray"},"...... ...... "),D.createElement(K,{color:Ee.text},"v",process.versions.v8)),D.createElement(He,{flexDirection:"row"},D.createElement(K,{color:Ee.textDim},"Data Directory"," "),D.createElement(K,{color:"gray"},"......... "),fo===yo?"":D.createElement(K,{color:Ee.text},fo.replaceAll(Bl.homedir(),"~").replaceAll("\\\\","/").replaceAll("\\","/"),", "),D.createElement(K,{color:Ee.text},yo.replaceAll(Bl.homedir(),"~").replaceAll("\\\\","/").replaceAll("\\","/"))),D.createElement(He,{flexDirection:"row"},D.createElement(K,{color:Ee.textDim},"Viewport"," "),D.createElement(K,{color:"gray"},"............... "),D.createElement(K,{color:Ee.text},process.stdout.rows||"?"," rows \xD7 ",process.stdout.columns||"?"," cols ",process.stdout.columns<90?"(too small width)":"")),D.createElement(He,{flexDirection:"row",marginBottom:0},D.createElement(K,{color:Ee.textDim},"Memory Load"," "),D.createElement(K,{color:"gray"},"............ "),D.createElement(K,{color:Ee.text},fe,"/",v," ",nt))),D.createElement(He,{key:"pty-notice",paddingX:0,marginTop:0},D.createElement(K,{color:zt?Ee.statusOn:Ee.warning},zt?"\u2713 Advance Interactive Terminal Supported":"\u26A0 Interactive Terminal is Limited"))):D.createElement(K,{color:"gray",italic:!0},So[L].desc)))),D.createElement(He,{paddingX:1,marginTop:0,flexDirection:"row",justifyContent:"space-between"},D.createElement(K,{color:"gray",italic:!0},F==="categories"?"\u25B2\u25BC Select Category \u2022 Enter/\u25BA to configure":"\u25B2\u25BC Select Option \u2022 Enter to Toggle \u2022 \u25C4/ESC to go back"),F==="categories"&&D.createElement(K,{color:"gray"},So[L].desc)))}import so,{useState as Fs,useEffect as Fd}from"react";import{Box as $n,Text as mr}from"ink";import Ud from"ink-text-input";function Us({initialData:t,onSave:f,onCancel:g,theme:E="Dark"}){let y=st(E),[p,l]=Fs(0),[w,T]=Fs(""),[S,N]=Fs(()=>({name:t?.name||"",nickname:t?.nickname||"",instructions:t?.instructions||""})),O=[{key:"nickname",label:"Enter a Nickname: ",maxLength:20},{key:"instructions",label:"System Instructions: ",maxLength:200}],B=O[p];Fd(()=>{let L=O[p].key;T((S[L]||"").slice(0,O[p].maxLength))},[p,S]);let I=L=>{L.length>B.maxLength?T(L.slice(0,B.maxLength)):T(L)},F=L=>{if(L.trim().toLowerCase()==="/cancel"){g();return}let W=B.key,q={...S,[W]:L.trim().slice(0,B.maxLength)};N(q),T(""),p<O.length-1?l(p+1):f(q)},$=w.length>=B.maxLength;return so.createElement($n,{borderStyle:"round",borderColor:y.borderMuted,padding:0,marginTop:1,flexShrink:0,flexDirection:"column",width:"100%"},so.createElement($n,{paddingX:1,marginBottom:1},so.createElement(mr,{color:y.text,bold:!0},"USER PROFILE CONFIGURATION")),so.createElement($n,{paddingX:1,flexDirection:"column"},so.createElement($n,null,so.createElement(mr,{color:y.text,bold:!0},B.label),so.createElement(Ud,{value:w,onChange:I,onSubmit:F})),so.createElement($n,{marginTop:1,justifyContent:"space-between"},so.createElement(mr,{color:y.textMuted,italic:!0},"Step ",p+1," of ",O.length),so.createElement(mr,{color:$?y.warning||"yellow":y.textMuted},"[",w.length,"/",B.maxLength,"]"))),so.createElement($n,{paddingX:1,marginTop:1},so.createElement(mr,{color:y.textMuted,italic:!0},"(Enter to submit \u2022 Type /cancel to abort)")))}import vt,{useState as $s}from"react";import{Box as io,Text as Jo,useInput as $d}from"ink";import _d from"ink-text-input";var Hd=({question:t,options:f,onResolve:g,theme:E="Dark"})=>{let y=st(E),[p,l]=$s(!1),[w,T]=$s(""),[S,N]=$s(0),O=!1,B=[],I=Array.isArray(f)&&f.length>0,F=t==="Agent has been running for a long time. Do you want to continue execution?";try{F&&I?B=[...f]:B=[...I?f:[],I?{id:"CUSTOM",label:"Suggest something else...",description:"Provide a custom response"}:{id:"CUSTOM",label:"Your Answer",description:""}]}catch{O=!0}$d((L,W)=>{if(!p&&((W.leftArrow||W.upArrow)&&N(q=>Math.max(0,q-1)),(W.rightArrow||W.downArrow)&&N(q=>Math.min(B.length-1,q+1)),W.return)){let q=B[S];q?.id==="CUSTOM"?l(!0):g(O?"Selected Nothing":q.label)}});let $=mt(2);return p?vt.createElement(io,{flexDirection:"column",borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,backgroundColor:y.codeBg,width:"100%"},vt.createElement(io,{paddingX:1},vt.createElement(Jo,{color:y.text,bold:!0},"SUGGEST SOMETHING")),vt.createElement(io,{marginTop:1,paddingX:1},vt.createElement(Jo,{italic:!0,color:y.textMuted},"Replying to: ",t)),vt.createElement(io,{marginTop:1,paddingX:1,flexDirection:"row"},vt.createElement(_d,{value:w,onChange:T,onSubmit:()=>g(w)})),vt.createElement(io,{marginTop:1,paddingX:1,marginBottom:1},vt.createElement(Jo,{color:y.textMuted,italic:!0},"(Press Enter to send)"))):vt.createElement(io,{flexDirection:"column",border:!0,borderStyle:"round",borderColor:y.codeBorder,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,marginY:1,marginRight:1,width:"100%"},vt.createElement(io,{paddingX:1,marginBottom:1},vt.createElement(Jo,{color:"yellow",bold:!0},F?"TURN SAFETY SYSTEM: EXECUTION LIMIT":"AGENT REQUEST: ACTION REQUIRED")),vt.createElement(io,{paddingX:1,marginBottom:1},vt.createElement(Jo,{color:y.text},t)),vt.createElement(io,{flexDirection:"column",width:"100%"},B.map((L,W)=>{let q=W===S;return vt.createElement(io,{key:L.id,flexDirection:"column",width:"100%",backgroundColor:q?y.highlightBg:void 0,paddingX:1,marginBottom:W===B.length-1?0:1},vt.createElement(Jo,{color:q?y.text:y.textMuted,bold:q},q?"\u276F ":" ",L.label),L.description&&vt.createElement(io,{marginLeft:4},vt.createElement(Jo,{color:y.textMuted,italic:!0},L.description)))})),vt.createElement(io,{paddingX:1,marginTop:1,marginBottom:1},vt.createElement(Jo,{color:y.textMuted,italic:!0},"(Use Arrows to navigate, Enter to confirm)")))},Dl=Hd;import ac from"gradient-string";import $t,{useState as _s,useEffect as Xd}from"react";import{Box as Eo,Text as Zo,useInput as Gd}from"ink";function Hs({onSelect:t,onDelete:f,onClose:g,theme:E="Dark"}){let y=st(E),[p,l]=_s({}),[w,T]=_s([]),[S,N]=_s(0);Xd(()=>{(async()=>{let L=await Qo();l(L),T(Object.keys(L).sort((W,q)=>(L[q].updatedAt||0)-(L[W].updatedAt||0)))})()},[]),Gd(($,L)=>{if(L.escape&&g(),L.upArrow&&N(W=>Math.max(0,W-1)),L.downArrow&&N(W=>Math.min(w.length-1,W+1)),L.return&&w[S]&&t(w[S]),$==="x"&&w[S]){let W=w[S];f(W).then(q=>{let de=q||{};l(de);let ue=Object.keys(de).sort((R,oe)=>(de[oe]?.updatedAt||0)-(de[R]?.updatedAt||0));T(ue),N(R=>Math.max(0,Math.min(ue.length-1,R)))})}});let O=mt(2),B=15,I=0;if(w.length>B){let $=Math.floor(B/2);I=S-$,I<0?I=0:I+B>w.length&&(I=w.length-B)}let F=w.slice(I,I+B);return $t.createElement(Eo,{flexDirection:"column",borderStyle:"round",borderColor:y.borderMuted,padding:0,width:"100%"},$t.createElement(Eo,{paddingX:1,marginBottom:1},$t.createElement(Zo,{color:y.text,bold:!0},"CHAT HISTORY: RESUME CONVERSATION")),w.length===0?$t.createElement(Eo,{paddingX:2,paddingY:1},$t.createElement(Zo,{italic:!0,color:y.textMuted},"No saved chats found.")):$t.createElement(Eo,{flexDirection:"column",width:"100%"},I>0&&$t.createElement(Eo,{paddingX:2,marginBottom:1},$t.createElement(Zo,{color:y.textMuted},"\u25B2 (+",I," more chats above)")),F.map(($,L)=>{let W=p[$],de=I+L===S,ue=Wd(W?.updatedAt);return $t.createElement(Eo,{key:$,paddingX:1,backgroundColor:de?y.highlightBg:void 0,width:"100%"},$t.createElement(Eo,{flexGrow:1},$t.createElement(Zo,{color:de?y.text:y.textMuted,bold:de},de?"\u276F ":" ",(()=>{let R=oe=>(oe||"").replace(/\[\/?(?:STEERING HINT|QUESTION)(?::\s*\w+)?\]/gi,"").trim();return W?.name&&!W.name.startsWith("Session")?R(W.name):W?.prompt?R(W.prompt):R(W?.name)||$})(),$t.createElement(Zo,{color:y.textMuted}," [",ue," \u2022 ",$,"]"))),de&&$t.createElement(Eo,{flexShrink:0},$t.createElement(Zo,{color:y.danger,bold:!0},"[X] DELETE ")))}),I+B<w.length&&$t.createElement(Eo,{paddingX:2,marginTop:1},$t.createElement(Zo,{color:y.textMuted},"\u25BC (+",w.length-(I+B)," more chats below)"))),$t.createElement(Eo,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:y.borderMuted},$t.createElement(Zo,{color:y.textMuted,italic:!0},"\u2191\u2193 navigate \u2022 Enter select \u2022 x delete \u2022 Esc close")))}function Wd(t){if(!t)return"N/A";let f=new Date(t);if(isNaN(f.getTime()))return"N/A";let g=w=>String(w).padStart(2,"0"),E=g(f.getMonth()+1),y=g(f.getDate()),p=g(f.getHours()),l=g(f.getMinutes());return`${E}-${y} ${p}:${l}`}import Dt,{useState as Xs,useEffect as Vd}from"react";import{Box as Bo,Text as po,useInput as Yd,useStdout as jd}from"ink";function Gs({onClose:t,theme:f="Dark"}){let g=st(f),{stdout:E}=jd(),y=E?.columns||80,[p,l]=Xs([]),[w,T]=Xs(0),[S,N]=Xs(!0),O=()=>{let R=vr(tr,[]);l(R);try{let me=Dr(cn,{}).systemSettings?.memory!==!1;N(me)}catch{N(!0)}};Vd(()=>{O()},[]),Yd((R,oe)=>{if(oe.escape&&t(),oe.upArrow&&T(me=>Math.max(0,me-1)),oe.downArrow&&T(me=>Math.min(p.length-1,me+1)),R==="x"&&p.length>0){let me=p[w].id,Me=p.filter(Xe=>Xe.id!==me);Li(tr,Me),l(Me),w>=Me.length&&Me.length>0&&T(Me.length-1)}});let B=(R,oe,me)=>{if(!R)return"";let Me=R.replace(/\[Saved on: .*?\]/g,"").replace(/\\+'/g,"'").trim(),Ve=`${me?"\u276F ":" "}${oe+1}. `.length,pe=me?22:2;return Me.split(`
|
|
45
|
-
`).map((we,le)=>{let Ke=le===0,Ge=Math.max(10,y-4-(Ke?Ve:3)-pe),Y=Math.max(10,y-4-3-pe),ne=we.split(/(\s+)/),ee=[],ae="";if(ne.forEach(ye=>{if(ye.length===0)return;let Ne=ee.length===0?Ge:Y;ae.length+ye.length>Ne?ae.trim().length>0?(ee.push(ae.trimEnd()),ae=ye):(ee.push(ye.substring(0,Ne)),ae=ye.substring(Ne)):ae+=ye}),ae.trimEnd().length>0&&ee.push(ae.trimEnd()),ee.length===0)return"";let Ce=ee.join(`
|
|
46
|
-
`);return Ke?Ce:" "+Ce}).join(`
|
|
47
|
-
`)},I=4*1024*2,F=p.reduce((R,oe)=>R+(oe.memory?.length||0),0),$=Math.min(100,Math.round(F/I*100)),L=12,W=Math.round($/100*L),q="\u2588".repeat(W)+"\u2591".repeat(Math.max(0,L-W)),de=()=>$<50?g.textMuted:$<90?g.warning:g.danger,ue=mt(2);return Dt.createElement(Bo,{flexDirection:"column",borderStyle:"round",borderColor:g.borderMuted,padding:0,width:"100%"},Dt.createElement(Bo,{paddingX:1,marginBottom:1,justifyContent:"space-between"},Dt.createElement(po,{color:g.text,bold:!0},"SAVED MEMORIES"),Dt.createElement(Bo,null,Dt.createElement(po,{color:g.textMuted},"Vault: "),Dt.createElement(po,{color:de()},q),Dt.createElement(po,{color:g.text,bold:!0}," ",$,"%"))),!S&&p.length>0?Dt.createElement(Bo,{paddingX:2,paddingY:1},Dt.createElement(po,{italic:!0,color:g.textMuted},"Memory is currently Off...")):p.length===0?Dt.createElement(Bo,{paddingX:2,paddingY:1},Dt.createElement(po,{italic:!0,color:g.textMuted},S?"Learning...":"Memory not available...")):Dt.createElement(Bo,{flexDirection:"column"},p.map((R,oe)=>{let me=oe===w;return Dt.createElement(Bo,{key:R.id,paddingX:1,backgroundColor:me?g.highlightBg:void 0,width:"100%"},Dt.createElement(Bo,{flexGrow:1},Dt.createElement(po,{color:me?g.text:g.textMuted,bold:me},me?"\u276F ":" ",oe+1,". ",B(R.memory,oe,me))),me&&Dt.createElement(Bo,{flexShrink:0},Dt.createElement(po,{color:g.textMuted,dimColor:!0}," [",Dt.createElement(po,{italic:!0},R.score),"] "),Dt.createElement(po,{color:g.danger,bold:!0},"[X] WIPE ")))})),Dt.createElement(Bo,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:g.borderMuted},Dt.createElement(po,{color:g.textMuted,italic:!0},"\u2191\u2193 navigate \u2022 x wipe memory \u2022 Esc close")))}import ht,{useState as Yr,useEffect as Il}from"react";import{Box as Ro,Text as Xt}from"ink";import{spawn as Al}from"child_process";var kl=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],Kd=({latest:t,current:f,settings:g,theme:E="Dark",onClose:y,onUpdateSettings:p,onSuccess:l})=>{let w=st(E),[T,S]=Yr("initializing"),[N,O]=Yr(""),[B,I]=Yr(null),[F,$]=Yr(0);if(Il(()=>{let L=setInterval(()=>{$(W=>(W+1)%1e3)},33);return()=>clearInterval(L)},[]),Il(()=>{let L;return(async()=>{let q=g?.updateManager||"npm";if(!g?.updateManager){p();return}let de="";q==="pnpm"?de=`pnpm add -g fluxflow-cli@${t}`:q==="bun"?de=`bun add -g fluxflow-cli@${t}`:q==="yarn"?de=`yarn global add fluxflow-cli@${t}`:q==="custom"?de=g.customUpdateCommand:de=`npm install -g fluxflow-cli@${t}`,S("downloading"),O(`Running: ${de}...`);let ue=process.platform==="win32",R=me=>new Promise(Me=>{let Xe=ue?me?"powershell.exe":"cmd.exe":process.env.SHELL||"bash",Ve=ue?me?["-NoProfile","-Command",de]:["/c",de]:["-c",de],pe=we=>{let Ke=we.toString().replace(/\x1B\[[0-?]*[ -/]*[@-~]|\x1B\][^\x07\x1B]*[\x07\x1B]|\b|\x07/g,"").replace(/\r/g,"").trim();Ke&&O(Ge=>{let Y=Ge.split(`
|
|
48
|
-
`);return Y[Y.length-1]?.startsWith("Progress:")&&Ke.startsWith("Progress:")?(Y[Y.length-1]=Ke,Y.slice(-5).join(`
|
|
49
|
-
`)):(Ge+`
|
|
50
|
-
`+Ke).split(`
|
|
51
|
-
`).slice(-10).join(`
|
|
52
|
-
`)})},Te=ue?Al(Xe,Ve,{cwd:process.cwd(),env:process.env}):Al(de,{shell:!0,cwd:process.cwd(),env:process.env});L=Te,Te.stdout.on("data",pe),Te.stderr.on("data",pe),Te.on("close",we=>{L=null,Me(we!==0?{error:`Process exited with code ${we}`}:{success:!0})}),Te.on("error",we=>{ue&&me&&we.code==="ENOENT"?Me({retryCmd:!0}):(L=null,Me({error:we.message}))})}),oe={};ue?(oe=await R(!0),oe.retryCmd&&(oe=await R(!1))):oe=await R(!1),oe.error?(I(oe.error),S("error")):oe.success&&(S("success"),l&&l())})(),()=>{if(L)try{typeof L.destroy=="function"?L.destroy():typeof L.kill=="function"&&L.kill()}catch{}}},[]),T==="initializing"||T==="downloading"){let L=kl[Math.floor(F/3)%kl.length];return ht.createElement(Ro,{flexDirection:"column",borderStyle:"round",borderColor:w.border,paddingX:2,paddingY:1},ht.createElement(Ro,null,ht.createElement(Xt,{color:w.accent||w.primary},L),ht.createElement(Xt,{marginLeft:1,bold:!0,color:w.text}," Updating Flux Flow to v",t,"...")),ht.createElement(Ro,{marginTop:1,paddingX:1,borderStyle:"single",borderColor:w.borderMuted},ht.createElement(Xt,{color:w.textMuted,italic:!0},N||"Preparing environment...")),ht.createElement(Xt,{marginTop:1,color:w.textDim||w.textMuted},"(Please do not close the terminal)"))}return T==="success"?ht.createElement(Ro,{flexDirection:"column",borderStyle:"round",borderColor:w.success||w.border,paddingX:2,paddingY:1},ht.createElement(Xt,{color:w.success||w.text,bold:!0},"\u2705 UPDATE SUCCESSFUL!"),ht.createElement(Xt,{marginTop:1,color:w.text},"Flux Flow has been updated to ",ht.createElement(Xt,{color:w.accent||w.primary},"v",t),"."),ht.createElement(Xt,{marginTop:1,color:w.text,bold:!0},"Please restart your terminal session to apply changes."),ht.createElement(Ro,{marginTop:1},ht.createElement(Xt,{color:w.textMuted},"(Press ESC to return to chat)"))):T==="error"?ht.createElement(Ro,{flexDirection:"column",borderStyle:"round",borderColor:w.danger||w.border,paddingX:2,paddingY:1},ht.createElement(Xt,{color:w.danger||w.text,bold:!0},"\u274C UPDATE FAILED"),ht.createElement(Ro,{marginTop:1,paddingX:1,borderStyle:"single",borderColor:w.borderMuted},ht.createElement(Xt,{color:w.danger||w.text},B)),ht.createElement(Xt,{marginTop:1,color:w.text,bold:!0},"Possible causes:"),ht.createElement(Xt,{color:w.textMuted},"\u2022 Missing permissions (Try running as Administrator/Sudo)"),ht.createElement(Xt,{color:w.textMuted},"\u2022 Package manager (",g?.updateManager,") not found"),ht.createElement(Xt,{color:w.textMuted},"\u2022 Network failure"),ht.createElement(Ro,{marginTop:1},ht.createElement(Xt,{color:w.textDim||w.textMuted},"(Press ESC to return to chat)"))):null},Ll=Kd;import Qt,{useState as Ol,useEffect as qd}from"react";import{Box as en,Text as _n,useInput as Qd}from"ink";var jr=[{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 Ws({onClose:t}){let[f,g]=Ol(0),[E,y]=Ol({});return qd(()=>{let p={};jr.forEach(l=>{sl(l.file)?p[l.file]="ready":p[l.file]="idle"}),y(p)},[]),Qd(async(p,l)=>{l.escape&&t(),l.upArrow&&g(T=>Math.max(0,T-1)),l.downArrow&&g(T=>Math.min(jr.length-1,T+1));let w=jr[f];if(p==="x"||p==="X"){if(E[w.file]==="downloading")return;try{await il(w.file),y(T=>({...T,[w.file]:"idle"}))}catch(T){y(S=>({...S,[w.file]:`error: ${T.message}`}))}}if(l.return){if(E[w.file]==="downloading")return;y(T=>({...T,[w.file]:"downloading"}));try{await rl(w.file),y(T=>({...T,[w.file]:"ready"}))}catch(T){y(S=>({...S,[w.file]:`error: ${T.message}`}))}}}),Qt.createElement(en,{flexDirection:"column",borderStyle:"round",borderColor:"gray",padding:0,width:"100%"},Qt.createElement(en,{paddingX:1,marginBottom:1},Qt.createElement(_n,{color:"white",bold:!0},"LANGUAGE PARSER MANAGER")),Qt.createElement(en,{flexDirection:"column"},jr.map((p,l)=>{let w=l===f,T=E[p.file]||"idle",S="[ DOWNLOAD ]",N="gray";T==="downloading"?(S="[ DOWNLOADING... ]",N="yellow"):T==="ready"?(S="[ READY ]",N="green"):T.startsWith("error")&&(S=`[ ${T.toUpperCase()} ]`,N="red");let O=`${p.label} (${p.exts.join(", ")})`,B=Math.max(2,45-O.length),I=".".repeat(B);return Qt.createElement(en,{key:p.file,paddingX:1,backgroundColor:w?"#2a2a2a":void 0,width:"100%"},Qt.createElement(en,null,Qt.createElement(_n,{color:w?"white":"grey",bold:w},w?"\u276F ":" ",p.label," ",Qt.createElement(_n,{dimColor:!0},"(",p.exts.join(", "),")"))),Qt.createElement(en,{flexGrow:1},Qt.createElement(_n,{color:"gray",dimColor:!0},I)),Qt.createElement(en,{width:20},Qt.createElement(_n,{color:N,bold:!0},S)))})),Qt.createElement(en,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:"gray"},Qt.createElement(_n,{color:"grey",italic:!0},"\u2191\u2193 navigate \u2022 Enter download \u2022 x delete \u2022 Esc close")))}import Pt,{useState as zd}from"react";import{Box as vo,Text as _o,useInput as Jd}from"ink";function Vs({prompts:t,onSelect:f,onClose:g,theme:E="Dark"}){let y=st(E),[p,l]=zd(0);Jd((O,B)=>{B.escape&&g(),B.upArrow&&l(I=>Math.max(0,I-1)),B.downArrow&&l(I=>Math.min(t.length-1,I+1)),B.return&&t[p]&&f(t[p].id)});let w=mt(2),T=10,S=0;if(t.length>T){let O=Math.floor(T/2);S=p-O,S<0?S=0:S+T>t.length&&(S=t.length-T)}let N=t.slice(S,S+T);return Pt.createElement(vo,{flexDirection:"column",borderStyle:"round",borderColor:y.borderMuted,padding:0,width:"100%"},Pt.createElement(vo,{paddingX:1,marginBottom:1},Pt.createElement(_o,{color:y.text,bold:!0},"CODEBASE TIME TRAVEL: SELECT UNDO POINT")),Pt.createElement(vo,{paddingX:2,marginBottom:1},Pt.createElement(_o,{color:y.text},"Select a prompt to revert the codebase back to the state ",Pt.createElement(_o,{bold:!0,color:y.secondary||"cyan"},"immediately before")," it was executed:")),t.length===0?Pt.createElement(vo,{paddingX:2,paddingY:1},Pt.createElement(_o,{italic:!0,color:y.textMuted},"No prompt checkpoints found for this session.")):Pt.createElement(vo,{flexDirection:"column",width:"100%"},S>0&&Pt.createElement(vo,{paddingX:2,marginBottom:1},Pt.createElement(_o,{color:y.textMuted},"\u25B2 (+",S," more prompts above)")),N.map((O,B)=>{let F=S+B===p,$=Rd(O.timestamp),L=O.changes?O.changes.length:0;return Pt.createElement(vo,{key:O.id,paddingX:1,backgroundColor:F?y.highlightBg:void 0,width:"100%"},Pt.createElement(vo,{flexGrow:1},Pt.createElement(_o,{color:F?y.text:y.textMuted,bold:F},F?"\u276F ":" ",'"',Zd(O.prompt),'"',Pt.createElement(_o,{color:y.textMuted}," [",$," \u2022 ",L," file(s) changed]"))))}),S+T<t.length&&Pt.createElement(vo,{paddingX:2,marginTop:1},Pt.createElement(_o,{color:y.textMuted},"\u25BC (+",t.length-(S+T)," more prompts below)"))),Pt.createElement(vo,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:y.borderMuted},Pt.createElement(_o,{color:y.textMuted,italic:!0},"\u2191\u2193 navigate \u2022 Enter select undo point \u2022 Esc close")))}function Zd(t){if(!t)return"";let g=(t.split(`
|
|
53
|
-
`)[0]||"").replace(/@\[(.*?)\]/g,(E,y)=>{let p=y.replace(/\\/g,"/").split("/");return`[${p[p.length-1]}]`});return g.length>69?g.slice(0,67)+"...":t.includes(`
|
|
54
|
-
`)?g+"...":g}function Rd(t){if(!t)return"N/A";let f=new Date(t);if(isNaN(f.getTime()))return"N/A";let g=l=>String(l).padStart(2,"0"),E=g(f.getHours()),y=g(f.getMinutes()),p=g(f.getSeconds());return`${E}:${y}:${p}`}import{exec as ec}from"child_process";import{promisify as tc}from"util";import Pl from"fs";var Nl=tc(ec),Fl=async()=>{try{let t=nl();if(t.executablePath&&Pl.existsSync(t.executablePath))return!0;let{default:f}=await import("puppeteer"),g=f.executablePath();if(g&&Pl.existsSync(g))return!0}catch{return!1}return!1},Ul=async t=>{t&&t("\u{1F4E5} Downloading Chromium engine (chrome@148)...");try{try{await Nl("pnpm exec puppeteer browsers install chrome@148")}catch{await Nl("npx -y puppeteer browsers install chrome@148")}return await new Promise(f=>setTimeout(f,1e3)),{success:!0}}catch(f){return console.error("[SETUP ERROR]",f),{success:!1,error:f.message}}};import $l,{useState as _l,useEffect as Hl}from"react";import{Text as Xl}from"ink";var oc=({text:t,baseColor:f="grey",glintColor:g="gray",speed:E=200,glintWidth:y=6,typeSpeed:p=30,...l})=>{let[w,T]=_l(-y),[S,N]=_l(t);return Hl(()=>{let O=setInterval(()=>{T(B=>B>S.length+y?-y-40:B+1)},E);return()=>clearInterval(O)},[S.length,E,y]),Hl(()=>{if(t&&(t.includes("Trying to reach")&&S&&S.includes("Trying to reach")||t.includes("Error Occurred")&&S&&S.includes("Error Occurred"))){N(t);return}if(S===t)return;let O=setTimeout(()=>{let B=0,I=Math.min(S.length,t.length);for(;B<I&&S[B]===t[B];)B++;S.length>B?N(F=>F.slice(0,-1)):S.length<t.length&&N(t.slice(0,S.length+1))},p);return()=>clearTimeout(O)},[t,S,p]),$l.createElement(Xl,null,S.split("").map((O,B)=>{let F=Math.abs(B-w)<=y/2?g:f;return $l.createElement(Xl,{key:B,color:F,...l},O)}))},xr=oc;var Kr=null,Gn=null,qr=null,Qr=null,lo=t=>{let f=String(t);return f.startsWith("999")&&f.endsWith("9")},Ys=async()=>{let t=process.env["9ROUTER_URL"]||process.env.NINEROUTER_URL||process.env["9ROUTER_BASE_URL"]||"http://127.0.0.1:20128",f=t;try{let g=new URL(t);f=`${g.protocol}//${g.host}`}catch{f=t.replace(/\/v1(\/chat\/completions)?\/?$/,"")}try{let g=await fetch(f,{method:"GET",signal:AbortSignal.timeout(800)});return{ok:!0,url:f}}catch(g){return{ok:!1,url:f,error:g.message}}},Ho=t=>t==null||t===0||lo(t)?"":String(t),fn=()=>{let t=(process.env.TERM_PROGRAM||"").toLowerCase(),f=(process.env.VSCODE_CWD||"").toLowerCase(),g=(process.env.VSCODE_CODE_CACHE_PATH||"").toLowerCase(),E=(process.env.GIT_ASKPASS||"").toLowerCase(),y=(process.env.VSCODE_GIT_ASKPASS_NODE||"").toLowerCase(),p=(process.env.VSCODE_GIT_ASKPASS_MAIN||"").toLowerCase();return t==="antigravity"||process.env.ANTIGRAVITY_AGENT||process.env.ANTIGRAVITY_PID||process.env.ANTIGRAVITY_EDITOR_APP_ROOT||process.env.ANTIGRAVITY_CLI_ALIAS||f.includes("antigravity")||g.includes("antigravity")||E.includes("antigravity")||y.includes("antigravity")||p.includes("antigravity")?"Antigravity":t==="cursor"||process.env.CURSOR_SETTINGS_DIR||process.env.CURSOR_CONFIG_DIR||f.includes("cursor")||g.includes("cursor")||E.includes("cursor")||y.includes("cursor")?"Cursor":t==="windsurf"||process.env.WINDSURF_SETTINGS_DIR||f.includes("windsurf")||g.includes("windsurf")||E.includes("windsurf")||y.includes("windsurf")?"Windsurf":t==="trae"||process.env.TRAE_SETTINGS_DIR||f.includes("trae")||y.includes("trae")?"Trae":t==="positron"||f.includes("positron")||y.includes("positron")?"Positron":t==="codium"||t==="vscode-oss"||f.includes("codium")||g.includes("codium")||y.includes("codium")?"VSCodium":t==="vscode-insiders"||f.includes("code - insiders")||g.includes("code - insiders")||y.includes("code - insiders")?"VS Code Insiders":t==="vscode"||process.env.VSCODE_GIT_IPC_HANDLE||process.env.VSCODE_PID||process.env.VSCODE_INJECTION||f.includes("code")||g.includes("code")||y.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"},dc=t=>{switch(t){case"VS Code":return"Code";case"VS Code Insiders":return"Code - Insiders";case"Antigravity":return"Antigravity IDE";default:return t}},Gl={Flux:"Workspace",Flow:"Studio",ICU:"Computer Use",FluxCU:"Omni"},js=t=>{if(!t)return"Workspace";let f=Object.keys(Gl).find(g=>g.toLowerCase()===t.toLowerCase());return f?Gl[f]:t},Wl=t=>{let f=dc(t),g=Qs.homedir();if(process.platform==="win32"){let E=process.env.APPDATA;return E?It.join(E,f,"User","keybindings.json"):null}else return process.platform==="darwin"?It.join(g,"Library","Application Support",f,"User","keybindings.json"):It.join(g,".config",f,"User","keybindings.json")},Vl=t=>{let f=t.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,"$1");return JSON.parse(f)},cc=t=>Array.isArray(t)?t.some(f=>f&&typeof f.key=="string"&&f.key.toLowerCase().replace(/\s+/g,"")==="shift+enter"&&f.command==="workbench.action.terminal.sendSequence"&&f.args&&f.args.text==="\x1B[13;2u"&&typeof f.when=="string"&&f.when.includes("terminalFocus")):!1,jl=t=>{let f=t==="VS Code",g=[];return f?(g.push({label:"Install Manually (VSIX)",url:"https://github.com/KushalRoyChowdhury/fluxflow-cli/releases"}),g.push({label:"Install from VS Code Marketplace",url:"https://marketplace.visualstudio.com/items?itemName=fluxflow-cli.fluxflow-cli-companion"})):g.push({label:`Download for ${t} (GitHub)`,url:"https://github.com/KushalRoyChowdhury/fluxflow-cli/releases"}),g.push({label:"Continue to CLI only",action:"dismiss"}),g},uc=({width:t,height:f,selectedIndex:g,aiProvider:E,theme:y="Dark"})=>{let p=fn(),l=jl(p);return e.createElement(c,{flexDirection:"column",alignItems:"center",justifyContent:"center",width:t,height:f},e.createElement(c,{marginBottom:1,width:Math.min(80,t-4),justifyContent:"flex-start"},e.createElement(i,null,Lr(To,E,y))),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"},p),", 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},l.map((w,T)=>e.createElement(c,{key:T},e.createElement(i,{color:g===T?"yellow":"white",bold:g===T},g===T?" \u276F ":" ",w.label)))),e.createElement(c,{marginTop:1,alignItems:"center",justifyContent:"center"},e.createElement(i,{dimColor:!0,italic:!0},"(Use arrows to navigate, Enter to select)"))))},Ks=Date.now(),Yl="https://fluxflow-cli.onrender.com/changelog",qs="https://fluxflow-cli.onrender.com/",mc=It.join(It.dirname(lc(import.meta.url)),"../package.json"),Kl=JSON.parse(ct.readFileSync(mc,"utf8")),To=Kl.version,xc=Kl.date||"2026-05-20";var fc=({data:t,onResolve:f,onEdit:g,theme:E="Dark"})=>{let y=st(E);return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:y.borderMuted,padding:0,width:"100%"},e.createElement(c,{paddingX:1},e.createElement(i,{color:y.text,bold:!0,underline:!0},t.startsWith("/btw")?"QUESTION":"STEERING HINT"," RESOLUTION")),e.createElement(c,{paddingX:1,marginTop:1},e.createElement(i,{color:y.text},"The agent already finished the task before your ",t.startsWith("/btw")?"question":"hint"," was consumed.")),e.createElement(c,{marginTop:1,backgroundColor:y.cardBg||y.codeBg||"#222",paddingX:2,width:"100%"},e.createElement(i,{italic:!0,color:y.textMuted},'"',t.replace("/btw","").trim(),'"')),e.createElement(c,{paddingX:1,marginTop:1},e.createElement(i,{color:y.textDim||y.textMuted},"How would you like to proceed?")),e.createElement(c,{marginTop:0},e.createElement(wt,{title:"Select Action",items:[{label:"Send Anyway",value:"send"},{label:"Edit Prompt",value:"edit"}],onSelect:p=>{(typeof p=="object"&&p!==null?p.value:p)==="send"?f(t):g(t)},theme:E})))};var gc=(()=>{let t=null,f=0;return g=>{let E=Date.now();if(t&&E-f<1e4)return t;let y=[],p=l=>{if(!(y.length>=2e3))try{let w=ct.readdirSync(l);for(let T of w){if(y.length>=2e3)return;if(["node_modules",".git",".gemini","dist","build",".next",".cache","out"].includes(T))continue;let S=It.join(l,T);ct.statSync(S).isDirectory()?p(S):y.push({name:kt(T),relativePath:kt(It.relative(process.cwd(),S))})}}catch{}};return p(g),t=y,f=E,y}})(),zr="Ctrl + Enter",hc=t=>{if(t<=370)return"#00a564";if(t>=5e3)return"#ff0000";let f=[{t:370,r:0,g:165,b:100},{t:550,r:40,g:195,b:80},{t:800,r:120,g:220,b:50},{t:1100,r:190,g:225,b:20},{t:1500,r:250,g:210,b:15},{t:2e3,r:255,g:170,b:0},{t:2800,r:255,g:110,b:0},{t:3800,r:255,g:50,b:0},{t:5e3,r:255,g:0,b:0}];for(let g=0;g<f.length-1;g++){let E=f[g],y=f[g+1];if(t>=E.t&&t<=y.t){let p=(t-E.t)/(y.t-E.t);p=p*p*(3-2*p);let l=Math.round(E.r+(y.r-E.r)*p),w=Math.round(E.g+(y.g-E.g)*p),T=Math.round(E.b+(y.b-E.b)*p);return`#${((1<<24)+(l<<16)+(w<<8)+T).toString(16).slice(1)}`}}return"#ff0000"},pc=e.memo(({sa:t,showTPMEstimate:f=!1})=>{let[g,E]=Z("green"),[y,p]=Z(0),l=ot([]),w=ot(370),T=ot([]),S=ot(t.lastChunkTime);return ut(()=>{S.current=t.lastChunkTime},[t.lastChunkTime]),ut(()=>{if(t.status!=="running"){T.current=[];return}if(t.wps>0){let N=T.current;N.push(t.wps),N.length>3&&N.shift()}},[t.status,t.wps,t.lastChunkTime]),ut(()=>{if(t.status!=="running"){p(0);return}let N=setInterval(()=>{let O=S.current,B=O>0?Date.now()-O:0;if(O>0&&B>=1e3)T.current=[],p(0);else if(O>0&&B>500){T.current.length>0&&T.current.shift();let I=T.current;if(I.length>0){let F=I.reduce(($,L)=>$+L,0);p(Math.round(F/I.length))}else p(0)}else{let I=T.current;if(I.length>0){let F=I.reduce(($,L)=>$+L,0);p(Math.round(F/I.length))}else t.wps>0&&p(Math.round(t.wps))}},750);return()=>clearInterval(N)},[t.status]),ut(()=>{if(t.status!=="running"){l.current=[];return}let N=t.lastChunkTime;if(N>0){let I=l.current;(I.length===0||I[I.length-1]!==N)&&(I.push(N),I.length>10&&I.shift())}let O=()=>{if(!N){E("#00a564");return}let I=l.current,F=0;if(I.length>1){let R=0;for(let oe=1;oe<I.length;oe++)R+=I[oe]-I[oe-1];F=R/(I.length-1)}let $=Date.now()-N,W=$>=2500,q=!W&&F>0?Math.min($,F*3):$,de=Math.max(F,q),ue=W?.4:.2;w.current=w.current*(1-ue)+de*ue,E(hc(w.current))};O();let B=setInterval(O,100);return()=>clearInterval(B)},[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"),!f&&e.createElement(i,{color:g}," \u25CF"),f&&e.createElement(i,{color:"white",dimColor:!0,bold:!0}," ~",y," tok/s")))});function Tc({args:t=[]}){let f=ot(1),[g,E]=Z(!1),[y,p]=Z(10),{stdout:l}=rc(),[w,T]=Z(""),[S,N]=Z(0),[O,B]=Z(!1),[I,F]=Z("Flux"),[$,L]=Z(0),[W,q]=Z({columns:l?.columns||80,rows:l?.rows||24}),[de,ue]=Z(0),[R,oe]=Z(!1),[me,Me]=Z(!1),[Xe,Ve]=Z(0),pe=ot(0),Te=ot(0),we=ot(null),le=ot(null),Ke=ot(0),[Ge,Y]=Z(0),ne=()=>Y(n=>n+1),ee=ot([]),ae=ot(null),Ce=()=>{let n=ee.current;if(n.length>0&&le.current){let o=n.join("");n.length=0,le.current.text=kt(le.current.text+o),ne()}},ye=()=>{if(Ce(),le.current){let n=kt(le.current.text);le.current.role==="think"&&(n=n.replace(/^\r?\n+/,"").replace(/\r?\n+$/,""));let o={...le.current,text:n,isStreaming:!1};k(d=>{let x=[...d,o];return _(x.length),x}),le.current=null}ei.current=0,rs.current={totalWords:0,startTime:0,wps:0,chunks:[]}},Ne=()=>{ae.current&&clearInterval(ae.current),ee.current=[],ae.current=setInterval(()=>{try{let n=ee.current;if(n.length>0&&le.current){let o=1;n.length>85?o=30:n.length>80?o=25:n.length>75?o=20:n.length>65?o=16:n.length>50?o=12:n.length>35?o=8:n.length>15?o=6:n.length>5?o=4:n.length>3&&(o=2);let d="";for(let x=0;x<o&&n.length>0;x++)d+=n.shift();le.current.text=kt(le.current.text+d),ne()}}catch{}},80)},et=async()=>{for(;xe.progressiveRendering&&ee.current.length>0;)await new Promise(n=>setTimeout(n,10))},lt=n=>{if(xe.progressiveRendering&&ae.current){let o=ji(n);for(let d of o)ee.current.push(d)}else le.current?le.current.text=kt(le.current.text+n):le.current={id:"agent-"+Date.now(),role:"agent",text:kt(n),isStreaming:!0},ne()};ut(()=>{let n=fn(),o=!["Terminal","Windows Terminal"].includes(n)||!!process.env.VSC_TERMINAL_URL,d=setTimeout(()=>{o&&!mn()&&Me(!0)},500),x=setInterval(()=>{mn()&&Me(!1)},1e3);f.current=Date.now();let m=setInterval(()=>{f.current&&(Date.now()-f.current||0)>3e4&&global.gc&&(async()=>{for(let a=0;a<1;a++)global.gc(),await new Promise(h=>setImmediate(h));f.current=Date.now()})()},3e3);return()=>{clearTimeout(d),clearInterval(x),clearInterval(m)}},[]),ut(()=>{(async()=>{try{let o=await Es(),d=o?.systemSettings||{},x=d.CustomSubAgent,m=d.SubAgentModel;if(!x||!m||m==="Default")return;let M=process.env.SUBAGENT_MODEL?process.env.SUBAGENT_MODEL.trim():null,u=process.env.SUBAGENT_PROVIDER?process.env.SUBAGENT_PROVIDER.trim():null,a=["Google","DeepSeek","OpenRouter","NVIDIA","Mistral","Ollama","InferX","SenseNova","AIHubMix","Poolside","9router","ExpLabs","TokenHarbor","Infron","APInex"],C=(te=>{if(!te)return null;let H=te.toLowerCase();return H==="google"?"Google":H==="deepseek"?"DeepSeek":H==="openrouter"?"OpenRouter":H==="nvidia"?"NVIDIA":H==="mistral"?"Mistral":H==="ollama"?"Ollama":H==="inferx"?"InferX":H==="sensenova"?"SenseNova":H==="poolside"?"Poolside":H==="9router"?"9router":H==="aihubmix"||H==="aihub"?"AIHubMix":H==="explabs"||H==="experientiallabs"||H==="experimentallabs"||H==="experiential labs"||H==="experimental labs"||H==="experiential"||H==="experimental"?"ExpLabs":H==="tokenharbor"||H==="token harbor"||H==="token_harbor"||H==="thk"?"TokenHarbor":H==="apinex"||H==="apx"?"APInex":H==="infron"?"Infron":null})(u);if(M&&!C){let te=o.aiProvider||v||"Google";k(H=>(_(H.length+1),[...H,{id:"subagent-env-noprov-"+Date.now(),role:"system",text:`[SUBAGENT CONFIG] SUBAGENT_MODEL found in ENV but SUBAGENT_PROVIDER is missing/invalid. Active provider (${te}) will be used.`,isMeta:!0}]))}if(m==="ENV"){M||k(te=>(_(te.length+1),[...te,{id:"subagent-model-noenv-"+Date.now(),role:"system",text:"No SubAgent model is found in ENV, Using Deafult until changed",isMeta:!0}]));return}let X=o.aiProvider||v||"Google",U=o.apiTier||it||"Free",G=o.quotas||$e||{},z=new Set;(Ko(X,U)||[]).forEach(te=>{let H=typeof te=="string"?te:te.cmd||te.name||te.id||String(te);H&&z.add(H)});for(let te of a)try{if(await qo(te)){let _e=G?.providerTiers?.[te]||"Free";(Ko(te,_e)||[]).forEach(ke=>{let ce=typeof ke=="string"?ke:ke.cmd||ke.name||ke.id||String(ke);ce&&z.add(ce)})}}catch{}let J=z.has(m);M?M!==m&&k(te=>(_(te.length+1),[...te,{id:"subagent-model-env-"+Date.now(),role:"system",text:"Current Seleted Sub-Agent model is not available in this provider. Using model from ENV unless changed.",isMeta:!0}])):J||k(te=>(_(te.length+1),[...te,{id:"subagent-model-err-"+Date.now(),role:"system",text:"Current Seleted Sub-Agent model is not available in this provider. Using Default until changed",isMeta:!0}]))}catch{}})()},[]);let Ie=Hn(()=>{let n={};for(let o=0;o<t.length;o++)if(t[o]==="--key"&&t[o+1]){let x=t[o+1];if(n.key=x,x.includes("@")){let m=x.split("@"),M=m[0],u=m[1].toLowerCase();if(["google","deepseek","openrouter","nvidia","mistral","ollama","inferx","sensenova","aihubmix","aihub","poolside","pool","9router","9r","explabs","tokenharbor","token_harbor","thk","infron","apinex","apx"].includes(u)){let a="Google";u==="google"?a="Google":u==="deepseek"?a="DeepSeek":u==="openrouter"?a="OpenRouter":u==="nvidia"?a="NVIDIA":u==="mistral"?a="Mistral":u==="ollama"?a="Ollama":u==="inferx"?a="InferX":u==="sensenova"?a="SenseNova":u==="poolside"||u==="pool"?a="Poolside":u==="9router"||u==="9r"?a="9router":u==="aihubmix"||u==="aihub"?a="AIHubMix":u==="explabs"?a="ExpLabs":u==="tokenharbor"||u==="token_harbor"||u==="thk"?a="TokenHarbor":u==="infron"?a="Infron":(u==="apinex"||u==="apx")&&(a="APInex"),n.key=M,n.provider=a}}}for(let o=0;o<t.length;o++){let d=t[o];if(d==="--key"){o++;continue}if(d==="--model"&&t[o+1])n.model=t[o+1],o++;else if(d==="--memory"&&t[o+1])n.memory=t[o+1].toLowerCase(),o++;else if(d==="--resume"&&t[o+1])n.resume=t[o+1],o++;else if(d==="--package"&&t[o+1]){let x=t[o+1].toLowerCase();["npm","pnpm","yarn","bun"].includes(x)&&(n.package=x),o++}else if(d==="--auto-del"&&t[o+1]){let x=t[o+1].toLowerCase();["1d","7d","30d"].includes(x)&&(n.autoDel=x),o++}else if(d==="--auto-exec"&&t[o+1])n.autoExec=t[o+1].toLowerCase(),o++;else if(d==="--yolo"&&t[o+1])n.autoExec=t[o+1].toLowerCase(),o++;else if(d==="--external-access"&&t[o+1])n.externalAccess=t[o+1].toLowerCase(),o++;else if(d==="--mode"&&t[o+1]){let m=t[o+1].toLowerCase();if(["flux","flow","icu","computer","fluxcu"].includes(m)){let M="Flux";m==="flux"?M="Flux":m==="flow"?M="Flow":m==="icu"||m==="computer"?M="ICU":m==="fluxcu"&&(M="FluxCU"),n.mode=M}o++}else if(d==="--thinking"&&t[o+1]){let m=t[o+1].toLowerCase();if(["fast","low","medium","high","xhigh","standard"].includes(m)){let M="Medium";m==="fast"?M="Fast":m==="low"?M="Low":m==="standard"?M="Standard":m==="medium"?M="Medium":m==="high"?M="High":m==="xhigh"&&(M="xHigh"),n.thinking=M}o++}else if(d==="--provider"&&t[o+1]){let x=t[o+1].toLowerCase();if(["google","deepseek","openrouter","nvidia","mistral","ollama","inferx","sensenova","aihubmix","aihub","poolside","pool","9router","9r","explabs","tokenharbor","token_harbor","thk","infron","apinex","apx"].includes(x)){let m="Google";x==="google"?m="Google":x==="deepseek"?m="DeepSeek":x==="openrouter"?m="OpenRouter":x==="nvidia"?m="NVIDIA":x==="mistral"?m="Mistral":x==="ollama"?m="Ollama":x==="inferx"?m="InferX":x==="sensenova"?m="SenseNova":x==="poolside"||x==="pool"?m="Poolside":x==="9router"||x==="9r"?m="9router":x==="aihubmix"||x==="aihub"?m="AIHubMix":x==="explabs"?m="ExpLabs":x==="tokenharbor"||x==="token_harbor"||x==="thk"?m="TokenHarbor":x==="infron"?m="Infron":(x==="apinex"||x==="apx")&&(m="APInex"),n.provider=m}o++}else(d==="--resume"||d==="-r")&&t[o+1]?(n.resume=t[o+1],o++):d==="--playground"?n.playground=!0:(d==="--original-cwd"||d==="--orginal-cwd")&&t[o+1]&&(n.originalCwd=t[o+1],o++)}return n},[t]),ie=async(n=!1,o=null)=>{let d=o||xe;n&&k(x=>(_(x.length+1),[...x,{id:"check-"+Date.now(),role:"system",text:"\u2726 Checking for updates...",isMeta:!0}]));try{let m=await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json(),M=m["dist-tags"]?.latest,u=m["dist-tags"]?.stable;if(M&&Jr(M),M&&M!==To){let a=M===u?`v${M}`:`v${M}`;!n&&d.autoUpdate?Q("update"):k(h=>{let C=[...h],X=n?C.length:Math.min(C.length,3);return C.splice(X,0,{id:"update-"+Date.now(),role:"system",text:`A new version (${a}) is here.
|
|
55
|
-
|
|
56
|
-
\u2022 Type \`/update latest\` to apply the update.
|
|
57
|
-
\u2022 Type \`/changelog\` to view the release notes.`,isUpdateNotification:!0,isMeta:!0}),C})}else n&&k(a=>{_(a.length+1);let h=M&&M===u?`${To}`:To;return[...a,{id:"uptodate-"+Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Already up to date (${h}).
|
|
58
|
-
\u2800`,isMeta:!0}]})}catch(x){n&&k(m=>(_(m.length+1),[...m,{id:"check-err-"+Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Failed to check for updates: ${x.message}.
|
|
59
|
-
\u2800`,isMeta:!0}]))}};ut(()=>{let n=l?.columns||80,o=()=>{let d=l?.columns||80,x=l?.rows||24;d!==n&&(n=d,l.write("\x1B[2J\x1B[3J\x1B[H")),q({columns:d,rows:x})};return l.on("resize",o),()=>{l.off("resize",o)}},[l]);let[fe,De]=Z("Medium"),[v,Ue]=Z("Google"),[nt,At]=Z(0),[zt,Jr]=Z(null),[tn,gn]=Z(!1),[qe,Kt]=Z(eo("Google","Free")||"gemma-4-31b-it"),[Ee,ge]=Z(!1),[b,P]=Z(!1),[Ae,Ye]=Z(Hi("gemma_janitor_fallback_google")||"gemma-4-26b-a4b-it"),[dt,xt]=Z(!0),[Qe,oo]=Z(!0),Ze=ot(0),[Nt,_t]=Z(null),[Zr,on]=Z(""),Rr=async n=>{let o=Wl(n);if(o)try{await ct.ensureDir(It.dirname(o));let d=[];if(ct.existsSync(o)){let x=ct.readFileSync(o,"utf8").trim();if(x)try{d=Vl(x)}catch{d=[]}}Array.isArray(d)||(d=[]),d.push({key:"shift+enter",command:"workbench.action.terminal.sendSequence",args:{text:"\x1B[13;2u"},when:"terminalFocus"}),ct.writeFileSync(o,JSON.stringify(d,null,4),"utf8"),zr="Shift + Enter",k(x=>(_(x.length+1),[...x,{id:"kb-success-"+Date.now(),role:"system",text:`\u2726 Successfully configured Shift+Enter in your ${n} keybindings!
|
|
60
|
-
`,isMeta:!0}]))}catch(d){k(x=>(_(x.length+1),[...x,{id:"kb-error-"+Date.now(),role:"system",text:`\u2726 Failed to update keybindings: ${d.message}.
|
|
61
|
-
\u2800`,isMeta:!0}]))}},[gt,Q]=Z("chat"),[Wn,es]=Z([]),Gt=w.startsWith("/k");ut(()=>{if(!Gt)return;let n=!0,o=async()=>{try{let x=await xl(process.pid);n&&es(x||[])}catch{}};o();let d=setInterval(o,5e3);return()=>{n=!1,clearInterval(d)}},[Gt]);let[it,no]=Z("Free"),[$e,ao]=Z({limitMode:"Daily",agentLimit:99999999,tokenLimit:99999999999999,backgroundLimit:999999,searchLimit:100,customModelId:"",customLimit:0,providerBudgets:{}}),[Xo,Jt]=Z(null),[Io,ql]=Z("chat"),[Go,ts]=Z("settings"),[hn,Ql]=Z([]),[bc,zl]=Z(0),[zs,fr]=Z(0),[os,Js]=Z({}),[Vn,Yn]=Z({}),[pn,co]=Z(0),[xe,St]=Z({memory:!0,theme:"Dark",compression:0,autoExec:!1,autoDeleteHistory:"7d",autoUpdate:!1,updateManager:"npm",customUpdateCommand:""}),r=Hn(()=>st(xe.theme),[xe.theme]),[Tn,Zs]=Z({name:null,nickname:null,instructions:null}),[Ao,gr]=Z({keyType:"Default",quality:"Low-High",apiKey:""}),[bo,Wo]=Z({tokens:0}),[Rs,ns]=Z(0),ei=ot(0),rs=ot({totalWords:0,startTime:0,wps:0,chunks:[]}),[ti,oi]=Z(0),[ni,Jl]=Z(0),[Zt,ri]=Z(0),[Zl,bn]=Z(0),wn=ot(0),[Rl,yn]=Z(0),Cn=ot(0),[ea,Mn]=Z(0),Sn=ot(0),[nn,si]=Z(0),[uo,ii]=Z(0),[En,li]=Z(0),[wc,ta]=Z(0),[yc,oa]=Z(0),[Cc,na]=Z(0),[hr,ra]=Z(0),[pr,sa]=Z(0),[Tr,ia]=Z(0),[ai,la]=Z(0),[Bn,ss]=Z(null),[jn,is]=Z(null),[br,di]=Z(null),[vn,Kn]=Z("daily"),[aa,mo]=Z(0),[qn,Qn]=Z(""),Dn="flow-playground",[ft,wr]=Z(t.includes("--playground")?Dn:Is());ut(()=>{if(Lo.current)return;let n=Zt-wn.current,o=uo-Cn.current,d=nn-Sn.current;bn(n),yn(o),Mn(Math.max(0,d)),ft&&ol(ft,n,bo.tokens).catch(()=>{})},[Zt,uo,nn,ft,bo.tokens]),ut(()=>{gt==="apiTier"&&(async()=>{let o=await Ar();ss(o);let d=await kr();is(d);let x=await Bs($e.resetDay||1);di(x)})()},[gt,$e.resetDay]);let[xo,ci]=Z(null),[In,An]=Z(""),[zn,ui]=Z(!1),[ls,da]=Z([]),[Mc,Sc]=Z(0),as=ot(!0),mi=ot(!0),ds=ot(v),cs=ot(!1),us=ot(!0);ut(()=>{(Ee||b)&&(k(n=>(_(n.length+1),[...n,{id:Date.now(),role:"system",text:`\u2726 Wild${b?"er":""}Card Tooling:
|
|
62
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Status: Disabled.
|
|
63
|
-
\u2800`,isMeta:!0}])),ge(!1),P(!1)),process.env.forcedReasoning&&(k(n=>(_(n.length+1),[...n,{id:Date.now(),role:"system",text:`\u2726 Forced Reasoning:
|
|
64
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Status: Disabled.
|
|
65
|
-
\u2800`,isMeta:!0}])),process.env.forcedReasoning=!1),fe==="xHigh"&&!as.current&&De("Medium")},[qe]);let xi;ut(()=>{if(mi.current){xi=setTimeout(()=>{mi.current=!1,ds.current=v},1e3);return}return ds.current!==v&&(ds.current=v,De(v==="SenseNova"||v==="Poolside"?"High":"Low")),()=>{clearTimeout(xi)}},[v,qe]);let fi;ut(()=>{if(!Nt)return;if(as.current){fi=setTimeout(()=>{as.current=!1},1500);return}let n=eo(v,it),o=n;return n.includes("gemma")?o="Gemma":n.includes("deepseek")?o="DeepSeek Flash":n.includes("devstral")?o="Devstral":n.includes("mistral")?o="Mistral":n.includes("gemini")&&(o="Gemini Flash"),Kt(n),Ot({apiTier:it,activeModel:n}),()=>{clearTimeout(fi)}},[it,v,Nt]);let ca=Hn(()=>{let n=fn();return{isIDE:!["Terminal","Windows Terminal"].includes(n)||!!process.env.VSC_TERMINAL_URL||!!process.env.INTELLIJ_TERMINAL_COMMAND_BLOCKS,get shortcut(){return zr}}},[]),yr=ot(null),ms=ot("");ut(()=>{yr.current=xo},[xo]),ut(()=>{ms.current=In},[In]);let[ua,ma]=Z(!1),[Vo,kn]=Z(null),[rn,xs]=Z(null),ko=n=>{kn(null),Q("chat")},gi=n=>{let o=Math.floor(n/3600),d=Math.floor(n%3600/60),x=n%60,m=[];return o>0&&m.push(`${o}h`),(d>0||o>0)&&m.push(`${d}m`),m.push(`${x}s`),m.join(" ")},sn=n=>n<1e3?`${n}ms`:gi(Math.floor(n/1e3)),[ln,fs]=Z(null),[gs,hi]=Z(""),[xa,fa]=Z(!1),[pi,Jn]=Z(0),Zn;ut(()=>{let n;if(ln&&xe.loadingPhrases!==!1){let o=x=>{hi(x[Math.floor(Math.random()*x.length)])},d=()=>{Gn?o(Gn):process.env.HALLOWEEN_EEGG==="true"||process.env.HALLOWEEN_EEGG===!0?import("./halloween_witty_phrases-IJGE3RWX.js").then(({HALLOWEEN_WITTY_PHRASES:m})=>{Gn=m,o(Gn)}):import("./witty_phrases-EEDEYYAH.js").then(({WITTY_LOADING_PHRASES:m})=>{Gn=m,o(Gn)})};gs||d(),n=setInterval(d,1e4)}else hi("");return()=>{clearInterval(n)}},[ln,xe]);let[Ec,ga]=Z(!0),[Ln,hs]=Z(!1),[Cr,Ti]=Z(!1),[ha,pa]=Z(!1),[bi,Bc]=Z(null),[wi,Rn]=Z(0),[Ta,yi]=Z([]),an=ot(null),Lo=ot(!1);ut(()=>()=>{an.current&&clearTimeout(an.current)},[]);let ps=ot(!1),[er,Ts]=Z(null),[ba,bs]=Z(null),[vc,wa]=Z(null);ut(()=>Rn(0),[w]);let[yt,ya]=Z(()=>{let n={id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0},o=process.cwd()===Qs.homedir(),d=(()=>{let m=process.cwd().toLowerCase();if(process.platform==="win32"){let M=process.env.SystemRoot?.toLowerCase()||"c:\\windows",u=process.env.ProgramFiles?.toLowerCase()||"c:\\program files",a=process.env["ProgramFiles(x86)"]?.toLowerCase()||"c:\\program files (x86)";return m.startsWith(M)||m.startsWith(u)||m.startsWith(a)}else return m==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(u=>m.startsWith(u))})(),x=[n];return d?x.push({id:"system-warning",role:"system",text:"[CRITICAL SECURITY ALERT] SYSTEM DIRECTORY DETECTED",subText:`You are currently in a PROTECTED SYSTEM DIRECTORY (${process.cwd()}). Operating here is EXTREMELY dangerous as the agent could accidentally corrupt your OS or installed applications. Open FluxFlow in project folder to work safely.`,isHomeWarning:!0}):o&&x.push({id:"home-warning",role:"system",text:"[SECURITY ALERT] HOME DIRECTORY DETECTED",subText:`You are currently in ${Qs.homedir()}. Working here is high-risk as the agent may modify system-sensitive configurations. Please open FluxFlow in project folder.`,isHomeWarning:!0}),x}),k=n=>{ya(o=>{let d=typeof n=="function"?n(o):n;if(d.length>1){let x=d[d.length-1],m=d[d.length-2];if(x?.text?.includes("Request Cancelled")&&m?.text?.includes("Request Cancelled"))return d.slice(0,-1)}return d})},Oo=ot(null),[Ci,Ca]=Z(""),[Mi,Si]=Z(!1),Ei=ot(""),Bi=ot(null);ut(()=>{if(yt.length===0)return;let n=yt[yt.length-1];if(n&&(n.role==="agent"||n.role==="assistant")){let d=(n.text||"").match(/\[ANSWER\]([\s\S]*?)(?:\[\/ANSWER\]|$)/i);if(d){let x=d[1].trim();x&&x!==Ei.current&&(Ca(x),Ei.current=x,Bi.current!==n.id&&Si(!0))}}},[yt]);let[Yo,_]=Z(yt.length),[dn,ws]=Z(0),Dc=ot([]),Rt=ot({completedIndex:0,columns:0,historicalBlocks:[],seenSelections:new Set,chatId:"",clearKey:0,theme:""}),vi=Hn(()=>{let n=W.columns||80,o=/Selection: (.*)/,d=[],x=new Set,m=Rt.current.columns!==n,M=Yo<Rt.current.completedIndex,u=Rt.current.chatId!==ft,a=Rt.current.clearKey!==dn,h=Rt.current.theme!==xe.theme;if(m||M||u||a||h){let z=yt.slice(0,Yo);for(let j=0;j<z.length;j++){let J=z[j];if(J.isAskRecord&&J.text){let H=J.text.match(o);if(H&&H[1].trim()){let _e=H[1].trim();if(x.has(_e))continue;x.add(_e)}}let te=or(J,n);for(let H=0;H<te.completed.length;H++)d.push(te.completed[H]);for(let H=0;H<te.active.length;H++)d.push(te.active[H])}Rt.current={completedIndex:Yo,columns:n,historicalBlocks:d,seenSelections:new Set(x),chatId:ft,clearKey:dn,theme:xe.theme}}else if(d=Rt.current.historicalBlocks,x=Rt.current.seenSelections,Yo>Rt.current.completedIndex){d=[...d],x=new Set(x);let z=yt.slice(Rt.current.completedIndex,Yo);for(let j=0;j<z.length;j++){let J=z[j];if(J.isAskRecord&&J.text){let H=J.text.match(o);if(H&&H[1].trim()){let _e=H[1].trim();if(x.has(_e))continue;x.add(_e)}}let te=or(J,n);for(let H=0;H<te.completed.length;H++)d.push(te.completed[H]);for(let H=0;H<te.active.length;H++)d.push(te.active[H])}Rt.current={completedIndex:Yo,columns:n,historicalBlocks:d,seenSelections:x,chatId:ft,clearKey:dn}}let C=yt.slice(Yo),X=[],U=[];for(let z=0;z<C.length;z++){let j=C[z];if(j.isAskRecord&&j.text){let te=j.text.match(o);if(te&&te[1].trim()){let H=te[1].trim();if(x.has(H))continue}}let J=or(j,n);for(let te=0;te<J.completed.length;te++)X.push(J.completed[te]);for(let te=0;te<J.active.length;te++)U.push(J.active[te])}if(le.current){let z=or(le.current,n);for(let j=0;j<z.completed.length;j++)X.push(z.completed[j]);for(let j=0;j<z.active.length;j++)U.push(z.active[j])}let G=X.length===0?d:d.concat(X);return G.length>=75e3&&(G=[...G],G.push({key:`memory-warning-block-${G.length}`,msg:{role:"system",text:"\u26A0\uFE0F MEMORY WARNING: CHAT IS GETTING VERY LONG",subText:`This session has reached ${G.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:G,active:U}},[yt,Yo,W.columns,dn,ft,Ge]),Ma=Hn(()=>{if(!xo||!In)return!1;let n=In.trim();return n.endsWith("?")||n.endsWith(":")||/\[[yYnN/]+\]\s*$/.test(n)||/\([yYnN]\)\s*$/.test(n)},[xo,In]);nc((n,o)=>{if(!(n==="\x1B[I"||n==="\x1B[O"||n==="[I"||n==="[O")){if(o.ctrl&&(n.toLowerCase()==="r"||n===""||n==="")){Ml();return}if(gt==="stats"){if(vn==="dailyModelBreakdown"||vn==="modelBreakdown"){if(o.tab&&!o.shift){Kn(x=>x==="dailyModelBreakdown"?"modelBreakdown":"dailyModelBreakdown"),mo(0);return}if(o.space||n===" "){Kn(x=>x==="dailyModelBreakdown"?"daily":"monthly"),mo(0),Qn("");return}if(o.escape){if(qn){Qn(""),mo(0);return}Q("chat");return}if(o.upArrow){mo(x=>Math.max(0,x-1));return}if(o.downArrow){mo(x=>Math.min(Te.current,x+1));return}if(o.backspace||o.delete){Qn(x=>x.slice(0,-1)),mo(0);return}if(n&&n!==" "&&!o.space&&!o.ctrl&&!o.meta&&n.length===1&&n.charCodeAt(0)>=32){Qn(x=>x+n),mo(0);return}return}if(o.tab&&!o.shift){Kn(x=>x==="daily"?"monthly":"daily"),mo(0);return}if(o.space||n===" "){Kn(x=>x==="daily"?"dailyModelBreakdown":"modelBreakdown"),mo(0),Qn("");return}if(o.upArrow){mo(x=>Math.max(0,x-1));return}if(o.downArrow){mo(x=>Math.min(Te.current,x+1));return}}if(me){let d=fn(),x=jl(d);if(o.upArrow)Ve(m=>m>0?m-1:x.length-1);else if(o.downArrow)Ve(m=>m<x.length-1?m+1:0);else if(o.return){let m=x[Xe];if(m.action==="dismiss")Me(!1);else if(m.url){let M=process.platform==="win32"?`start ${m.url}`:process.platform==="darwin"?`open ${m.url}`:`xdg-open ${m.url}`;Do(M),Me(!1)}}return}if(o.tab&&xo){ui(d=>!d);return}if(zn&&xo){let d=o.pageUp||n==="\x1B[5~"||n==="[5~",x=o.pageDown||n==="\x1B[6~"||n==="[6~",m=o.ctrl&&(n==="o"||n==="");if(d||x||m)return;if(o.return)if(Pn)to("\r");else{let M=process.platform==="win32";to(M?`\r
|
|
66
|
-
`:`
|
|
67
|
-
`),An(u=>u+`
|
|
68
|
-
`)}else if(o.backspace||o.delete)Pn?to("\x7F"):(to("\b \b"),An(M=>M.slice(0,-1)));else if(o.upArrow)to(o.shift?"\x1B[1;2A":"\x1B[A");else if(o.downArrow)to(o.shift?"\x1B[1;2B":"\x1B[B");else if(o.rightArrow)to(o.shift?"\x1B[1;2C":"\x1B[C");else if(o.leftArrow)to(o.shift?"\x1B[1;2D":"\x1B[D");else if(o.escape)to("\x1B");else if(o.ctrl&&n){let M=n.toLowerCase().charCodeAt(0);M>=97&&M<=122?to(String.fromCharCode(M-96)):to(n)}else n&&(to(n),Pn||An(M=>M+n));return}if(gt==="providerBudgetSelect"){let d=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","Infron","APInex"];if(o.upArrow){fr(x=>(x-1+d.length)%d.length);return}else if(o.downArrow){fr(x=>(x+1)%d.length);return}else if(n===" "){let x=d[zs];Js(m=>({...m,[x]:!m[x]}));return}else if(o.return){let x=d.filter(M=>os[M]);if(x.length===0)return;let m={...$e,providerBudgets:{...$e.providerBudgets||{},__useProvider:!0}};ao(m),Ql(x),zl(0),fr(0),Q("providerBudgetFlow");return}else if(o.escape){Q("budgetTypeSelect");return}return}if(gt==="providerBudgetFlow"){let d=hn.length,x=d*4+1;if(o.upArrow){co(m=>m===x-1?Math.max(0,(d-1)*4):m>=4?m-4:m);return}else if(o.downArrow){co(m=>m===x-1?m:m+4<x-1?m+4:x-1);return}else if(o.leftArrow){co(m=>m===x-1?m:m%4>0?m-1:m);return}else if(o.rightArrow||o.tab){co(m=>m===x-1?m:m+1<x?m+1:m);return}else if(o.return){if(pn===x-1){let m=$e.providerBudgets||{},M={__useProvider:!0};for(let h of hn){let C=Vn[h]||{};M[h]={agentLimit:9999999999,tokenLimit:parseInt(C.tokenLimit,10)||0,monthlyTokenLimit:parseInt(C.monthlyTokenLimit,10)||0,dailyCostLimit:parseFloat(C.dailyCostLimit)||0,monthlyCostLimit:parseFloat(C.monthlyCostLimit)||0}}let u={...$e,providerBudgets:M};ao(u),Ot({apiTier:it,quotas:u}),Q(Io==="settings"?"resetMode":"budgetResetMode")}else co(m=>Math.min(x-1,m+1));return}else if(o.escape){Q("providerBudgetSelect");return}return}if(o.escape){if(Mi){if(Si(!1),yt.length>0){let d=yt[yt.length-1];d&&(Bi.current=d.id)}return}if(tt.length>0&>==="chat"){oe(!0);return}if(g){E(!1);return}if(Ln||xo||Vo||rn)ps.current=!0,al(),Ji(),Vo&&(Vo.resolve("deny"),kn(null)),rn&&(rn.resolve(null),xs(null)),pa(!1),bi&&clearTimeout(bi);else if(gt==="revert")Q("chat"),Rn(0);else if(gt!=="chat"&>!=="settings")Q("chat");else{if(!Nt&&nt===1){At(0),on("");return}Rn(d=>{let x=d+1;return x===1?(an.current&&clearTimeout(an.current),an.current=setTimeout(()=>Rn(0),2e3)):x===2&&(an.current&&clearTimeout(an.current),Rn(0),w.length>0?T(""):rr.getChatHistory(ft).then(m=>{m.length>0?(yi(m.reverse()),Q("revert")):k(M=>(_(M.length+1),[...M,{id:"revert-empty-"+Date.now(),role:"system",text:`\u2726 Nothing to revert to.
|
|
69
|
-
\u2800`,isMeta:!0}]))})),x})}}if(tt.length>0&>==="chat"){if(o.upArrow){ue(d=>{let x=d>0?d-1:tt.length-1,m=0;for(;x!==d&&m<tt.length;){let M=tt[x],u=M?.cmd||M||"";if(typeof u=="string"&&u.trimStart().startsWith("---"))x=x>0?x-1:tt.length-1,m++;else break}return x});return}if(o.downArrow){ue(d=>{let x=d<tt.length-1?d+1:0,m=0;for(;x!==d&&m<tt.length;){let M=tt[x],u=M?.cmd||M||"";if(typeof u=="string"&&u.trimStart().startsWith("---"))x=x<tt.length-1?x+1:0,m++;else break}return x});return}if(o.return)return}if(o.tab&>==="chat"){if(tt.length>0){let d=tt[de]||tt[0],x=w.split(" ");if(x.length===1)T(d.cmd+" ");else{let m=x.slice(0,-1);T(m.join(" ")+" "+d.cmd+" ")}ue(0),N(m=>m+1);return}else if(w.trim()===""){let d=Date.now();if(d-Ke.current<500)return;Ke.current=d;let x=["Flux","Flow","ICU","FluxCU"],m=(x.indexOf(I)+1)%x.length,M=x[m>=0?m:0];F(M),M==="Flow"?De("Fast"):(M==="Flux"||M==="ICU"||M==="FluxCU")&&De("High"),k(u=>[...u,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${js(M)}
|
|
70
|
-
\u2800`,isMeta:!0}]);return}}if(o.ctrl&&n==="c"&>!=="exit"){if(w.length>0){T("");return}if(o.shift){Q("exit"),E(!1);return}g?(Q("exit"),E(!1)):E(!0)}o.return&&(o.shift||o.ctrl||o.meta||o.leftAlt||o.rightAlt)&&T(d=>d.replace(/\\\r?$/,"").replace(/\r?$/,"")+`
|
|
71
|
-
`)}}),ut(()=>{process.stdout.write("\x1B[?1004h");let n=o=>{let d=o.toString();d.includes("\x1B[I")?(oo(!0),Ze.current=Date.now()):d.includes("\x1B[O")&&(oo(!1),Ze.current=Date.now())};return process.stdin.on("data",n),()=>{process.stdout.write("\x1B[?1004l"),process.stdin.off("data",n)}},[]);let Mr=ot(xe.theme);ut(()=>{Mr.current&&Mr.current!==xe.theme?(Mr.current=xe.theme,l&&(l.write("\x1B[2J\x1B[3J\x1B[H"),l.isTTY&&l.write("\x1B[?2004h")),ws(n=>n+1),No()):Mr.current=xe.theme},[xe.theme,l]),ut(()=>{async function n(){try{let C=JSON.parse(ct.readFileSync(It.join(process.cwd(),"package.json"),"utf8"));As(To||C.version||"2.0.0")}catch{As("2.0.0")}process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07")),await Fl()||(k(C=>(_(C.length+1),[...C,{id:"setup-"+Date.now(),role:"system",text:"\u2726 Installing Required dependencies... (One-time setup)",isMeta:!0}])),await Ul(),k(C=>(_(C.length+1),[...C,{id:"setup-done-"+Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m All dependencies installed successfully.
|
|
72
|
-
\u2800`,isMeta:!0}])));let o=await Es();cs.current=o.systemSettings?.allowExternalAccess??!1,us.current=o.systemSettings?.memory??!0,Ie.mode?F(Ie.mode):F(o.mode),L(o.display??0),Ie.thinking?De(Ie.thinking):De(o.thinkingLevel);let d=Ie.provider||o.aiProvider||"Google";Ue(d);let m=(o.quotas?.providerTiers||{})[d]||o.apiTier||"Free";if(we.current=o.activeModel,Ie.model)Kt(Ie.model);else if(Ie.provider){let C=eo(d,m);Kt(C)}else Kt(o.activeModel);gn(o.showFullThinking),no(m),ao(o.quotas||{limitMode:"Daily",agentLimit:99999999,tokenLimit:99999999999999,backgroundLimit:999999,searchLimit:100,customModelId:"",customLimit:0,providerBudgets:{}});let M={memory:!0,compression:0,autoExec:!1,autoDeleteHistory:"7d",autoUpdate:!1,updateManager:"npm",customUpdateCommand:"",...o.systemSettings||{}};Ie.memory==="on"?M.memory=!0:Ie.memory==="off"&&(M.memory=!1),d==="NVIDIA"&&process.env.NVIDIA_BASE_URL&&(M.memory=!1,k(C=>[...C,{role:"system",text:`\u2726 MEMORY
|
|
73
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Currently not available.
|
|
74
|
-
\u2800`,isMeta:!0}])),Ie.package&&(M.updateManager=Ie.package),Ie.autoDel&&(M.autoDeleteHistory=Ie.autoDel),Ie.autoExec==="on"?M.autoExec=!0:Ie.autoExec==="off"&&(M.autoExec=!1),Ie.externalAccess==="on"?M.allowExternalAccess=!0:Ie.externalAccess==="off"&&(M.allowExternalAccess=!1),Ie.playground&&(M.allowExternalAccess=!1,M.memory=!1),St(M),Zs(o.profileData),gr(o.imageSettings||{keyType:"Default",quality:"Low-High",apiKey:""});let u=Ie.key;if(u||(u=await qo(d)),d==="c_openai"){let C=u||"";_t(C),Fo(C,{aiProvider:d,onIDEApproval:ko})}else u&&(_t(u),Fo(u,{aiProvider:d,onIDEApproval:ko}));if(o.systemSettings?.autoDeleteHistory&&tl(o.systemSettings.autoDeleteHistory),Ie.playground||(Pr(Dn).catch(()=>{}),ct.remove(It.join(yo,"playground")).catch(()=>{})),ie(!1,M),await Promise.all([Vi(),rr.recoverCrashedTransaction()]),Ie.resume){let C=await Qo(),X=Ie.resume;if(C[X]){Lo.current=!0,wr(X);let U=await sr(X);wn.current=Zt-U.total,Cn.current=uo,Sn.current=nn,bn(U.total),yn(0),Mn(0),Wo({tokens:U.context}),Lo.current=!1;let G=[...C[X].messages];G[0]?.text?.includes("\u2591\u2591\u2591\u2588\u2588\u2588")||G.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),k(G),Q("chat"),k(j=>{let J=[...j,{id:"sys-"+Date.now(),role:"system",text:`\u2726 SESSION RESUMED
|
|
75
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m '${X}'.
|
|
76
|
-
\u2800`,isMeta:!0}];return _(J.length),J})}else k(U=>[...U,{id:"sys-err-"+Date.now(),role:"system",text:`\u2726 Chat session [${X}] not found. Started new session.
|
|
77
|
-
\u2800`,isMeta:!0}])}if(Ie.playground){let C=It.join(yo,"playground");try{ct.ensureDirSync(C),process.chdir(C)}catch{}let X=await Qo();if(X[Dn]){Lo.current=!0;let U=await sr(Dn);wn.current=Zt-U.total,Cn.current=uo,Sn.current=nn,bn(U.total),yn(0),Mn(0),Wo({tokens:U.context}),Lo.current=!1;let G=[...X[Dn].messages];G[0]?.isLogo||G.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),k(G),k(z=>{let j=[...z,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND Session restored
|
|
78
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m CWD locked to: '${C}'.
|
|
79
|
-
\u2800`,isMeta:!0}];return _(j.length),j})}else k(U=>{let G=[...U,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND Mode active
|
|
80
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m CWD locked to: 'FluxFlow/playground'.
|
|
81
|
-
\u2800`,isMeta:!0}];return _(G.length),G})}let a=fn();if(!["Terminal","Windows Terminal"].includes(a)){let C=Wl(a);if(C)try{let X=[];if(ct.existsSync(C)){let U=ct.readFileSync(C,"utf8").trim();U&&(X=Vl(U))}cc(X)?zr="Shift + Enter":Q("keybindingsPrompt")}catch{}}xt(!1)}n()},[]),ut(()=>{let n;return g&&(p(10),n=setInterval(()=>{p(o=>o<=1?(E(!1),0):o-1)},1e3)),()=>{n&&clearInterval(n)}},[g]),ut(()=>{if(!dt){let n=Ie.model&&qe===Ie.model?we.current:qe,o=xe;Ie.playground&&(o={...xe,allowExternalAccess:cs.current,memory:us.current}),Ot({mode:I,thinkingLevel:fe,aiProvider:v,activeModel:n||qe,showFullThinking:tn,systemSettings:o,profileData:Tn,imageSettings:Ao,apiTier:it})}},[I,fe,v,qe,tn,xe,Tn,Ao,dt,Ie,it]);let Di=async n=>{let o=n.trim(),d={Google:{prefix:"AIzaSy",minLength:39},OpenRouter:{prefix:"sk-or-v1-",minLength:73},DeepSeek:{prefix:"sk-",minLength:35},Mistral:{prefix:"",minLength:32},NVIDIA:{prefix:"nvapi-",minLength:70},Ollama:{prefix:"",minLength:0},InferX:{prefix:"",minLength:0},SenseNova:{prefix:"",minLength:0},AIHubMix:{prefix:"sk-",minLength:10},Poolside:{prefix:"",minLength:0},"9router":{prefix:"",minLength:0},ExpLabs:{prefix:"xpl_",minLength:0},TokenHarbor:{prefix:"thk_",minLength:0},Infron:{prefix:"",minLength:0},APInex:{prefix:"sk-apx",minLength:0}},{prefix:x,minLength:m}=d[v]??{prefix:"",minLength:0},M=(v==="Ollama"||v==="9router")&&(o.trim()==="LOCAL"||o.trim()===""),u=v==="c_openai",a=M?"LOCAL":o;if(u){let h=o.trim().replace(/\/+$/,""),C={...xe,customOpenAIBaseUrl:h,memory:!1};St(C);let U=await qo("c_openai")||"";_t(U),Fo(U,{aiProvider:"c_openai",onIDEApproval:ko});let G=eo("c_openai",it)||"";Kt(G),await Ot({mode:I,thinkingLevel:fe,aiProvider:"c_openai",activeModel:G,showFullThinking:tn,systemSettings:C,profileData:Tn,imageSettings:Ao,apiTier:it}),k(z=>[...z,{role:"system",text:`\u2726 Custom (OpenAI) Base URL saved!
|
|
82
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Endpoint: ${h}${G?`
|
|
83
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: ${G}`:""}
|
|
84
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with Custom (OpenAI).
|
|
85
|
-
\u2800`,isMeta:!0}]),on("");return}if(M||o.startsWith(x)&&o.length>=m){await Ss(v,a),_t(a),Fo(a,{aiProvider:v,onIDEApproval:ko});let h="gemma-4-31b-it";v==="OpenRouter"?h="google/gemma-4-31b-it:free":v==="DeepSeek"?h="deepseek-v4-flash":v==="NVIDIA"?h="deepseek-ai/deepseek-v4-flash":v==="Ollama"||v==="9router"?h=qe||"":(v==="InferX"||v==="SenseNova"||v==="AIHubMix"||v==="Poolside"||v==="ExpLabs"||v==="TokenHarbor"||v==="Infron"||v==="APInex")&&(h=eo(v,it)||""),Kt(h);let C={...xe};M&&v==="Ollama"&&(C={...C,ollamaEndpoint:"Local"},St(C)),(v==="Ollama"||v==="InferX"||v==="SenseNova"||v==="AIHubMix"||v==="Poolside"||v==="9router"||v==="ExpLabs"||v==="TokenHarbor"||v==="Infron"||v==="APInex")&&(C={...C,memory:!1},St(C));let X="";if(v==="9router"){let U=await Ys();U.ok||(X=`
|
|
86
|
-
|
|
87
|
-
\x1B[33m\u2726 WARNING: 9router does not appear to be running on ${U.url}.\x1B[39m
|
|
88
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m To start 9router: \x1B[36mnpx 9router\x1B[39m or \x1B[36mnpm i -g 9router && 9router\x1B[39m`)}k(U=>[...U,{role:"system",text:`\u2726 ${v} API Key saved successfully! ${h?`
|
|
89
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model set to ${h}.`:""}${M&&v==="Ollama"?`
|
|
90
|
-
\u2726 Ollama Endpoint switched to Local.
|
|
91
|
-
\u2514\u2500\u2800`:`
|
|
92
|
-
|
|
93
|
-
\u2726\u2800`}${v==="Ollama"||v==="InferX"||v==="SenseNova"||v==="AIHubMix"||v==="Poolside"||v==="9router"||v==="ExpLabs"||v==="TokenHarbor"||v==="Infron"||v==="APInex"?`Memory is not available with ${v}.
|
|
94
|
-
\u2514\u2500\u2800`:""}Initialization complete.${X}
|
|
95
|
-
\u2800`,isMeta:!0}])}else k(h=>[...h,{role:"system",text:`\u2726 INVALID KEY
|
|
96
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${v} API key must start with "${x}" and be at least ${m} characters long.`,isMeta:!0}]),on("")},Sr=ot(Ks);ut(()=>{if(gt==="exit"){(async()=>{let d=Date.now(),x=Math.floor((d-Sr.current)/1e3);x>=1&&(await un("duration",x),Sr.current+=x*1e3),await Wi()})();let o=setTimeout(()=>{process.exit(0)},50);return()=>clearTimeout(o)}},[gt]),ut(()=>{let n=setInterval(async()=>{if(!dt){let o=Date.now(),d=Math.floor((o-Sr.current)/1e3);d>=1&&(await un("duration",d),Sr.current+=d*1e3),Gi()}},5e3);return()=>clearInterval(n)},[dt]);let Ii=[{cmd:"/quit",desc:"Exit and shutdown Flux"},{cmd:"/kill",desc:"Kill a process by PID",subs:Wn.map(n=>{let o;return n.isRoot?o="FluxFlow":n.url&&(n.url.includes(":52991")||n.url.includes(":52145")||n.url.includes(":52140"))?o="Internal":o=n.url||n.name,{cmd:String(n.pid),display:`PID: ${n.pid}`,rightDesc:o,desc:o}})},{cmd:"/help",desc:"Show all available commands"},...Ie.playground?[{cmd:"/move",desc:"Move playground directory to original CWD/playground-export"}]:[],{cmd:"/resume",desc:"Load previous session"},{cmd:"/clear",desc:"Clear terminal screen"},{cmd:"/compress",desc:"Summarize and compress chat history"},{cmd:"/truncate",desc:"Truncate tool results in chat history"},{cmd:"/revert",desc:"Revert codebase back to a checkpoint"},{cmd:"/gemini",desc:"Get a happy message from Gemini CLI"},{cmd:"/meow",desc:"Cat nonsense, delivered straight to the terminal"},...process.env.HALLOWEEN_EEGG==="true"||process.env.HALLOWEEN_EEGG===!0?[{cmd:"/trick-or-treat",desc:"Halloween surprise: Trick or Treat!"}]:[],{cmd:"/save",desc:"Force save current chat"},{cmd:"/export",desc:"Export current chat or error logs",subs:[{cmd:"chat",desc:"Export current active chat"},{cmd:"logs",desc:"Export error logs"}]},{cmd:"/chats",desc:"List all chat sessions"},{cmd:"/btw",desc:"Ask a question without intefering with ongoing tasks"},{cmd:"/thinking",desc:"Set AI reasoning depth",subs:[{cmd:"Low",display:qt(v,qe,"Low")!==null?`Low (${qt(v,qe,"Low")})`:"Low",desc:"Quick Reasoning"},{cmd:"Medium",display:qt(v,qe,"Medium")!==null?`Medium (${qt(v,qe,"Medium")})`:"Medium",desc:"Balanced Reasoning"},{cmd:"High",display:qt(v,qe,"High")!==null?`High (${qt(v,qe,"High")})`:"High",desc:"Deep Reasoning"},{cmd:"custom",display:qt(v,qe,"xHigh")!==null?`Custom (${qt(v,qe,"xHigh")})`:"Custom",desc:"Custom Reasoning Value"}]},{cmd:"/model",desc:"Select Agent Model",subs:I==="ICU"||I.toLowerCase()==="fluxcu"?Ko(v,it).filter(n=>Ir(n.cmd||n)):Ko(v,it)},{cmd:"/wildcard-tooling",desc:"Use if the model lacks Tooling Capability"},{cmd:"/provider",desc:"Select AI Provider"},{cmd:"/mode",desc:"Switch execution mode",subs:[{cmd:"flux",display:"workspace",desc:"Workspace, files & terminal tools"},{cmd:"flow",display:"studio",desc:"Creative studio, documents, PDF & conversation"},{cmd:"icu",display:"computer use",desc:"Interactive desktop & OS automation"},{cmd:"fluxcu",display:"omni",desc:"Autonomous tools & desktop execution"}]},{cmd:"/display",desc:"Select Active Display (Computer Use)",subs:[{cmd:"primary",desc:"Primary Display (Display 1)"},{cmd:"secondary",desc:"Secondary Display (Display 2)"}]},{cmd:"/settings",desc:"Configure system prefs"},{cmd:"/theme",desc:"Customize UI color theme"},{cmd:"/key",desc:"Manage API keys"},{cmd:"/files",desc:"List loaded instruction and skill files"},{cmd:"/profile",desc:"Edit developer persona"},{cmd:"/memory",desc:"Manage agent memory",subs:[{cmd:"view",desc:"View and manage agent persistent memory"},{cmd:"migrate",desc:"Migrate persistent memories to AGENTS.md"}]},{cmd:"/stats",desc:"Show session usage"},{cmd:"/usage",desc:"Open graphical token usage & analytics dashboard in browser"},{cmd:"/target",desc:"Show current provider and model"},{cmd:"/reset",desc:"Wipe all project data"},{cmd:"/about",desc:"Project info & credits"},{cmd:"/changelog",desc:"View latest updates"},{cmd:"/docs",desc:"View Documentation"},{cmd:"/fluxflow",desc:"Project management",subs:[{cmd:"global",desc:"Opens the Global FluxFlow Directory in File Explorer"},{cmd:"saves",desc:"Opens FluxFlow AppData Directory in File Explorer"}]},{cmd:"/budget",desc:"Set or View budget limits",subs:[{cmd:"view",desc:"View current usage budget bars"},{cmd:"web",desc:"Open graphical usage and budget dashboard in browser"},{cmd:"set",desc:"Configure budgets (Daily/Monthly limits)"},{cmd:"reset",desc:"Reset budgets to default limits"}]},{cmd:"/update",desc:"Check/Install updates",subs:[{cmd:"latest",desc:"Install latest release"},{cmd:"check",desc:"Check for new version"}]}],Ai=async(n,o=!1)=>{if(!o&&tt.length>0){let m=tt[de]||tt[0],M=n.split(" ");if(M.length===1)T(m.cmd+" ");else{let u=M.slice(0,-1);T(u.join(" ")+" "+m.cmd+" ")}ue(0),N(u=>u+1);return}ps.current=!1;let d=n.replace(/\r\n/g,`
|
|
97
|
-
`).replace(/\r/g,`
|
|
98
|
-
`).trimEnd();if(d.endsWith("\\")){T(d.slice(0,-1)+`
|
|
99
|
-
`);return}let x=d.replace(/\\\s*\n/g,`
|
|
100
|
-
`).split(/\r?\n/).map(m=>m.replace(/\\$/,"")).join(`
|
|
101
|
-
`);if(x.trim()){if(Ln){let m=x.trim();if(m.startsWith("/btw")){if(m.replace(/^\/btw\s*/,"").trim().length<=3){k(u=>(_(u.length+1),[...u,{id:"hint-err-"+Date.now(),role:"system",text:`\u2726 RESTRICTED
|
|
102
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Inquiry question must be more than 3 characters.
|
|
103
|
-
\u2800`,isMeta:!0}])),T("");return}}else if(m.startsWith("/")){k(M=>(_(M.length+1),[...M,{id:"hint-err-"+Date.now(),role:"system",text:`\u2726 RESTRICTED
|
|
104
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Steering Hints cannot start with '/'.
|
|
105
|
-
\u2800`,isMeta:!0}])),T("");return}Ts(m),Oo.current=m,T("");return}if(!Nt&&!(v==="c_openai"&&xe.customOpenAIBaseUrl)){Di(x),on("");return}if(x.startsWith("/")){T("");let m=x.split(" "),M=m[0]?.toLowerCase();switch(M){case"/quit":{Q("exit");break}case"/resume":{if(m[1]){let u=m[1];(async()=>{let h=await Qo(),C=h[u]||Object.values(h).find(X=>X.name.toLowerCase()===u.toLowerCase());if(C){if(l.write("\x1B[2J\x1B[3J\x1B[H"),process.stdout.isTTY){let z=C?.name||"",j=z&&!z.startsWith("flow-")&&!z.startsWith("Session ")?z:"FluxFlow | Resumed";process.stdout.write(`\x1B]0;${j}\x07`),process.stdout.write(`\x1B]633;P;TerminalTitle=${j}\x07`)}No(),Lo.current=!0,wr(u);let X=await sr(u);wn.current=Zt-X.total,Cn.current=uo,Sn.current=nn,bn(X.total),yn(0),Mn(0),Wo({tokens:X.context}),Lo.current=!1;let U=[...C.messages];U[0]?.text?.includes("\u2591\u2591\u2591\u2588\u2588\u2588")||U.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),k(U),k(z=>[...z,{id:"sys-"+Date.now(),role:"system",text:`\u2726 SESSION RESUMED
|
|
106
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${u}.
|
|
107
|
-
\u2800`,isMeta:!0}]),_(0)}else k(X=>[...X,{id:"err-"+Date.now(),role:"system",text:`\u2726 ERROR: Session [${u}] not found.
|
|
108
|
-
\u2800`,isMeta:!0}])})()}else Q("resume");break}case"/move":{if(!Ie.playground){k(C=>(_(C.length+1),[...C,{id:Date.now(),role:"system",text:`\u2726 RESTRICTED
|
|
109
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m '/move' is only available in playground mode.
|
|
110
|
-
\u2800`,isMeta:!0}]));break}if(!Ie.originalCwd){k(C=>(_(C.length+1),[...C,{id:Date.now(),role:"system",text:`\u2726 RESTRICTED
|
|
111
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Original CWD not found.
|
|
112
|
-
\u2800`,isMeta:!0}]));break}let u=It.join(yo,"playground"),a=It.join(Ie.originalCwd,"playground-export");(async()=>{try{k(X=>(_(X.length+1),[...X,{id:Date.now(),role:"system",text:`\u2726 EXPORTING PLAYGROUND CONTENT
|
|
113
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${a}
|
|
114
|
-
`,isMeta:!0}])),await ct.ensureDir(a);let C=["node_modules",".git",".venv","venv","env",".next","dist","build",".cache"];await ct.copy(u,a,{overwrite:!0,filter:X=>{let U=It.relative(u,X);return U?!U.split(It.sep).some(z=>C.includes(z)):!0}}),k(X=>(_(X.length+1),[...X,{id:Date.now(),role:"system",text:`\u2726 SUCCESS
|
|
115
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m playground content copied to ${a}
|
|
116
|
-
`,isMeta:!0}]))}catch(C){k(X=>(_(X.length+1),[...X,{id:Date.now(),role:"system",text:`\u2726 FAILED TO MOVE CONTENT
|
|
117
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${C.message}
|
|
118
|
-
`,isMeta:!0}]))}})();break}case"/clear":{if(l&&(l.write("\x1B[2J\x1B[3J\x1B[H"),l.isTTY&&(l.write("\x1B[?2004h"),process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07"))),k([{id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}]),_(1),ws(u=>u+1),No(),Rt.current={completedIndex:0,columns:W.columns,historicalBlocks:[],seenSelections:new Set,chatId:ft,clearKey:dn+1},Ie.playground){if(Ie.playground=!1,Pr(Dn).catch(()=>{}),Ie.originalCwd)try{process.chdir(Ie.originalCwd),k(u=>{let a=[...u,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND
|
|
119
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Restored Working Directory to ${Ie.originalCwd}
|
|
120
|
-
\u2800`,isMeta:!0}];return _(a.length),a})}catch{}setTimeout(()=>{ct.emptyDir(It.join(yo,"playground")).catch(u=>{k(a=>{let h=[...a,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND
|
|
121
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Failed to clear session: ${yo+"/playground"}`,isMeta:!0}];return _(h.length),h})})},500),St(u=>({...u,allowExternalAccess:cs.current,memory:us.current}))}wr(Is()),Wo({tokens:0}),B(!1),bn(0),yn(0),Mn(0),wn.current=Zt,Cn.current=uo,Sn.current=nn,setTimeout(()=>{global.gc&&(async()=>{for(let a=0;a<3;a++)global.gc(),await new Promise(h=>setImmediate(h));f.current=Date.now()})()},500);break}case"/revert":{rr.getChatHistory(ft).then(u=>{if(u.length>0)yi(u.reverse()),Q("revert");else{let a=mt(2);k(h=>(_(h.length+1),[...h,{id:"revert-empty-"+Date.now(),role:"system",text:`\u2726 Nothing to revert to.
|
|
122
|
-
\u2800`,isMeta:!0}]))}}),setTimeout(()=>{global.gc&&(async()=>{for(let a=0;a<3;a++)global.gc(),await new Promise(h=>setImmediate(h));f.current=Date.now()})()},500);break}case"/mode":{if(m[1]){let u=m[1].toLowerCase(),a="Flux";u==="flow"?a="Flow":u==="icu"?a="ICU":u==="fluxcu"?a="FluxCU":u==="flux"&&(a="Flux"),F(a),a==="Flow"&&De("Fast");let h=mt(2);k(C=>(_(C.length+1),[...C,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${js(a)}.
|
|
123
|
-
\u2800`,isMeta:!0}]))}else Q("mode");break}case"/display":{if(m[1]){let u=m[1].toLowerCase(),a=0;u==="secondary"||u==="1"||u==="2"?a=1:a=0,L(a),Ot({display:a}).catch(()=>{});let h=a===0?"Primary (Display 1)":"Secondary (Display 2)";k(C=>(_(C.length+1),[...C,{id:Date.now(),role:"system",text:`\u2726 Active Computer Use display set to: ${h}.
|
|
124
|
-
\u2800`,isMeta:!0}]))}else Q("display");break}case"/image_deprecated":{if(m[1]?.toLowerCase()==="stats"){let u=mt(2);if(Ao.keyType==="Custom")k(a=>(_(a.length+1),[...a,{id:Date.now(),role:"system",text:"[SYSTEM] Key strategy is Custom. Redirecting to Pollinations dashboard (https://enter.pollinations.ai/#pollen)...",isMeta:!0}])),Do("start https://enter.pollinations.ai/#pollen");else try{let a=await Yi();k(h=>(_(h.length+1),[...h,{id:Date.now(),role:"system",isImageStats:!0,text:`\u2022 Hourly Limit: ${Number((a.limit*1e3).toFixed(0))} credits
|
|
125
|
-
\u2022 Spent (Last 1hr): ${Number((a.totalSpent*1e3).toFixed(0))} credits
|
|
126
|
-
\u2022 Remaining: ${Number((a.remaining*1e3).toFixed(0))} credits
|
|
127
|
-
\u2022 Requests (Last 1hr): ${a.activeCallsCount} requests
|
|
128
|
-
`+(a.nextResetMin>0?`\u2022 Refreshes in: ${a.nextResetMin}m`:""),isMeta:!0}]))}catch{k(h=>(_(h.length+1),[...h,{id:Date.now(),role:"system",text:"[SYSTEM] Failed to load image quota stats.",isMeta:!0}]))}}else if(m[1]?.toLowerCase()==="setup")if(m[2]?.toLowerCase()==="key")if(m[3]){let u=["default","custom"].find(a=>a===m[3].toLowerCase());if(u){let a=u==="default"?"Default":"Custom";gr(C=>({...C,keyType:a}));let h=mt(2);k(C=>(_(C.length+1),[...C,{id:Date.now(),role:"system",text:`[SYSTEM] Image key strategy set to ${a}`,isMeta:!0}])),a==="Custom"&&(Jt({label:"Enter Pollinations API key (starting with sk_):",note:"Get a key from https://enter.pollinations.ai",key:"imageSettings",subKey:"apiKey",value:Ao.apiKey||"",returnView:"chat"}),Q("input"))}else{let a=mt(2);k(h=>(_(h.length+1),[...h,{id:Date.now(),role:"system",text:"[SYSTEM] Invalid key option. Choose: Default or Custom.",isMeta:!0}]))}}else{let u=mt(2);k(a=>(_(a.length+1),[...a,{id:Date.now(),role:"system",text:"[SYSTEM] Usage: /image setup Key <Default|Custom>",isMeta:!0}]))}else if(m[2]?.toLowerCase()==="quality")if(m[3]){let u=["low","low-high","medium","medium-high","high","ultra","premium"].find(a=>a===m[3].toLowerCase());if(u){let h={low:"Low","low-high":"Low-High",medium:"Medium","medium-high":"Medium-High",high:"High",ultra:"Ultra",premium:"Premium"}[u];gr(X=>({...X,quality:h}));let C=mt(2);k(X=>(_(X.length+1),[...X,{id:Date.now(),role:"system",text:`[SYSTEM] Image quality set to ${h}`,isMeta:!0}]))}else{let a=mt(2);k(h=>(_(h.length+1),[...h,{id:Date.now(),role:"system",text:"[SYSTEM] Invalid quality level. Choose from: Low, Low-High, Medium, Medium-High, High, Ultra, Premium.",isMeta:!0}]))}}else{let u=mt(2);k(a=>(_(a.length+1),[...a,{id:Date.now(),role:"system",text:"[SYSTEM] Usage: /image setup Quality <Low|Low-High|Medium|Medium-High|High|Ultra>",isMeta:!0}]))}else{let u=mt(2);k(a=>(_(a.length+1),[...a,{id:Date.now(),role:"system",text:"[SYSTEM] Usage: /image setup <Key|Quality> ...",isMeta:!0}]))}else{let u=mt(2);k(a=>(_(a.length+1),[...a,{id:Date.now(),role:"system",text:"[SYSTEM] Usage: /image setup <Key|Quality> ...",isMeta:!0}]))}break}case"/thinking":{let u;if(m[1]){let a=m.slice(1),h=a.includes("--bypass")||a.includes("-b"),C=a.includes("--force")||a.includes("-f"),X=a.findIndex(j=>j==="--map"||j==="-m");if(X!==-1){let j=a.slice(0,X).join(" ").trim(),J=a.slice(X+1).join(" ").trim(),te=["fast","low","medium","standard","high","xhigh","custom","max"];if(!j||!J)k(H=>(_(H.length+1),[...H,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mINVALID USAGE\x1B[0m
|
|
129
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Usage: \x1B[36m/thinking <level> --map <target_value>\x1B[0m (e.g. \x1B[33m/thinking Custom --map high\x1B[0m)
|
|
130
|
-
\u2800`,isMeta:!0}]));else if(!te.includes(j.toLowerCase()))k(H=>(_(H.length+1),[...H,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mUNKNOWN LEVEL\x1B[0m
|
|
131
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Unknown level "\x1B[33m${j}\x1B[0m" to map. Available: \x1B[36mLow, Medium, High, Custom\x1B[0m.
|
|
132
|
-
\u2800`,isMeta:!0}]));else if(J.toLowerCase()==="rm"||J.toLowerCase()==="--remove"||J.toLowerCase()==="-rm"){let H=j.toLowerCase()==="custom"?"xHigh":j,_e=Ri(v,qe,H);_e.success?k(Fe=>(_(Fe.length+1),[...Fe,{id:Date.now(),role:"system",text:`\u2726 Thinking Level Mapping Removed:
|
|
133
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Target: \x1B[36m${v}::${qe}\x1B[0m
|
|
134
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Removed mapping for: \x1B[33m${j}\x1B[0m
|
|
135
|
-
\u2800`,isMeta:!0}])):k(Fe=>(_(Fe.length+1),[...Fe,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mFAILED TO REMOVE MAPPING\x1B[0m
|
|
136
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${_e.reason}
|
|
137
|
-
\u2800`,isMeta:!0}]))}else{let H=j.toLowerCase()==="custom"?"xHigh":j,_e=isNaN(Number(J))?J:Number(J),Fe=Zi(v,qe,H,_e);Fe.success?k(ke=>(_(ke.length+1),[...ke,{id:Date.now(),role:"system",text:`\u2726 Thinking Level Mapped:
|
|
138
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Target: \x1B[36m${v}::${qe}\x1B[0m
|
|
139
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Mapping: \x1B[33m${j}\x1B[0m \u2794 \x1B[32m${J}\x1B[0m
|
|
140
|
-
\u2800`,isMeta:!0}])):k(ke=>(_(ke.length+1),[...ke,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mFAILED TO SAVE MAPPING\x1B[0m
|
|
141
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${Fe.reason}
|
|
142
|
-
\u2800`,isMeta:!0}]))}break}let U=a[0].toLowerCase();if(!["fast","low","medium","standard","high","xhigh","custom","max"].includes(U)){k(j=>(_(j.length+1),[...j,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mUNKNOWN THINKING LEVEL\x1B[0m
|
|
143
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Level "\x1B[33m${a[0]}\x1B[0m" is not supported. Available levels: \x1B[36mLow, Medium, High, Custom\x1B[0m.
|
|
144
|
-
\u2800`,isMeta:!0}]));break}if(U==="standard"&&(U="medium"),U==="custom"&&(U="xhigh"),u=U.charAt(0).toUpperCase()+U.slice(1),U==="xhigh"&&(u="xHigh"),u==="xHigh"&&!(qt(v,qe,"xHigh")!==null)){k(J=>(_(J.length+1),[...J,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mCUSTOM LEVEL NOT MAPPED\x1B[0m
|
|
145
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Custom Effort level is not mapped. Use \x1B[36m/thinking custom --map <target_value>\x1B[0m first.
|
|
146
|
-
\u2800`,isMeta:!0}]));break}let z="";if(C&&(process.env.NVIDIA_BASE_URL,z=`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Enabled Forced Reasoning.
|
|
147
|
-
\u2800`,process.env.forcedReasoning="true"),!h&&I==="Flow"&&u==="xHigh")k(j=>(_(j.length+1),[...j,{id:Date.now(),role:"system",text:`\u2726 RESTRICTED
|
|
148
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m"${u}" is restricted in Flow mode. Switch to Flux to enable Higher Thinking Levels.
|
|
149
|
-
\u2800${z}.`,isMeta:!0}]));else{De(u);let j=mt(1),J=u==="xHigh"?qt(v,qe,"xHigh")!==null?`Custom (${qt(v,qe,"xHigh")})`:"Custom":u;k(te=>(_(te.length+1),[...te,{id:Date.now(),role:"system",text:`\u2726 ${v}
|
|
150
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${qe}.
|
|
151
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Thinking Level: ${J}.
|
|
152
|
-
${z} \u2800`,isMeta:!0}]))}}else Q("thinking");break}case"/model":{if(m[1]){let u=m.slice(1).join(" "),a=null,h=null,C=u,X=/(?:^|\s)(?:--info|-i)(?:\s+(?:"([^"]*)"|'([^']*)'|\{([^}]*)\}|((?:(?!--[a-z]|-[a-z]\b).)+)))?(?=\s+--|\s+-[a-z]\b|$)/i,U=C.match(X);if(U&&(h=(U[1]??U[2]??U[3]??U[4]??"").trim(),C=(C.slice(0,U.index)+" "+C.slice(U.index+U[0].length)).trim(),a={IN:0,OUT:0,CR:0,CW:0},h)){let ce=h.split(",");for(let he of ce){let Re=he.trim().match(/^(IN|OUT|CR|CW)\s+([0-9]*\.?[0-9]+)$/i);Re&&(a[Re[1].toUpperCase()]=parseFloat(Re[2]))}}let G=C.split(/\s+/).filter(Boolean),z=G.some(ce=>ce==="--multimodal"||ce==="-m"||ce==="--vision"||ce==="-v"),j=G.some(ce=>ce==="--save"||ce==="-sv"||ce==="--add"),J=G.some(ce=>ce==="--remove"||ce==="-rm"),te=G.some(ce=>ce==="--rename"||ce==="-rn"||ce==="-mv"),H=G.some(ce=>ce==="--default"||ce==="-df"),_e=G.filter(ce=>!["--save","-sv","--add","--remove","-rm","--rename","-rn","-mv","--default","-df","--multimodal","-m","--vision","-v"].includes(ce)),Fe=()=>a?Object.keys(a).length>0?`
|
|
153
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Pricing:
|
|
154
|
-
`+Object.entries(a).map(([ce,he])=>` \x1B[2m\u2022\x1B[22m \x1B[36m${ce}\x1B[0m: $${he}`).join(`
|
|
155
|
-
`):h?`
|
|
156
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Pricing: \x1B[33mNo valid IN, OUT, CR, CW tokens parsed from: "${h}"\x1B[0m`:"":"";if(j||J||te||H){if(H){let ce=_e.join(" ").trim();if(!ce)k(he=>(_(he.length+1),[...he,{id:Date.now(),role:"system",text:"\x1B[31m[Error]\x1B[0m Please provide a model ID to set as default. Example: /model my-model --default",isMeta:!0}]));else{let he=Fi(v,ce,z,a);he.success?k(Le=>{_(Le.length+1);let Re=v==="c_openai"?xe?.customOpenAIBaseUrl||"Custom Endpoint":v.replace("c_openai","Custom Endpoint");return[...Le,{id:Date.now(),role:"system",text:`\u2726 Default Model Set:
|
|
157
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${Re}
|
|
158
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Default Model: \x1B[32m${ce}\x1B[0m
|
|
159
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Multimodal: ${z?"ON":"OFF"}${Fe()}
|
|
160
|
-
\u2800`,isMeta:!0}]}):k(Le=>(_(Le.length+1),[...Le,{id:Date.now(),role:"system",text:`\x1B[31m[Error]\x1B[0m Failed to set default model: ${he.reason}`,isMeta:!0}]))}}else if(j){let ce=_e.join(" ").trim();if(!ce)k(he=>(_(he.length+1),[...he,{id:Date.now(),role:"system",text:"\x1B[31m[Error]\x1B[0m Please provide a model ID to save. Example: /model my-custom-model --save",isMeta:!0}]));else{let he=Oi(v,ce,z,a);he.success?k(Le=>(_(Le.length+1),[...Le,{id:Date.now(),role:"system",text:`\u2726 Model Saved:
|
|
161
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${v}
|
|
162
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: \x1B[32m${ce}\x1B[0m
|
|
163
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Multimodal: ${z?"ON":"OFF"}${Fe()}
|
|
164
|
-
\u2800`,isMeta:!0}])):k(Le=>(_(Le.length+1),[...Le,{id:Date.now(),role:"system",text:`\x1B[31m[Error]\x1B[0m Failed to save model: ${he.reason}`,isMeta:!0}]))}}else if(J){let ce=_e.join(" ").trim();if(!ce)k(he=>(_(he.length+1),[...he,{id:Date.now(),role:"system",text:"\x1B[31m[Error]\x1B[0m Please provide a model ID to remove. Example: /model my-custom-model --remove",isMeta:!0}]));else{let he=Ui(v,ce);he.success?k(Le=>(_(Le.length+1),[...Le,{id:Date.now(),role:"system",text:`\u2726 Model Removed:
|
|
165
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${v}
|
|
166
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: \x1B[31m${ce}\x1B[0m
|
|
167
|
-
\u2800`,isMeta:!0}])):k(Le=>(_(Le.length+1),[...Le,{id:Date.now(),role:"system",text:`\x1B[31m[Error]\x1B[0m Failed to remove model: ${he.reason}`,isMeta:!0}]))}}else if(te)if(_e.length<2)k(ce=>(_(ce.length+1),[...ce,{id:Date.now(),role:"system",text:"\x1B[31m[Error]\x1B[0m Please provide both old and new model IDs. Example: /model old-model-id new-model-id --rename",isMeta:!0}]));else{let ce=_e[0].trim(),he=_e.slice(1).join(" ").trim(),Le=$i(v,ce,he);Le.success?k(Re=>(_(Re.length+1),[...Re,{id:Date.now(),role:"system",text:`\u2726 Model Renamed:
|
|
168
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${v}
|
|
169
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Old Model: \x1B[31m${ce}\x1B[0m
|
|
170
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m New Model: \x1B[32m${he}\x1B[0m
|
|
171
|
-
\u2800`,isMeta:!0}])):k(Re=>(_(Re.length+1),[...Re,{id:Date.now(),role:"system",text:`\x1B[31m[Error]\x1B[0m Failed to rename model: ${Le.reason}`,isMeta:!0}]))}break}if(a!==null){let ce=_e.join(" ").trim();if(!ce)k(he=>(_(he.length+1),[...he,{id:Date.now(),role:"system",text:'\x1B[31m[Error]\x1B[0m Please provide a model ID. Example: /model <id> -i "IN 0.15, OUT 0.6, CR 0.05, CW 0.1"',isMeta:!0}]));else{Object.keys(a).length>0&&Pi(v,ce,a);let he=v==="c_openai"?xe?.customOpenAIBaseUrl||"Custom Endpoint":v.replace("c_openai","Custom Endpoint");k(Le=>(_(Le.length+1),[...Le,{id:Date.now(),role:"system",text:`\u2726 Model Info Saved:
|
|
172
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${he}
|
|
173
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model ID: \x1B[32m${ce}\x1B[0m${Fe()}
|
|
174
|
-
\u2800`,isMeta:!0}]))}break}let ke=_e.join(" ").trim();if(_i(z),ke){z&&Ni(v,ke,!0);let ce=eo("Google","Free"),he=eo("Google","Paid");{Kt(ke);let Le=z||Ir(ke),Re=fe==="xHigh"?qt(v,ke,"xHigh")!==null?`Custom (${qt(v,ke,"xHigh")})`:"Custom":fe,We=v==="c_openai"?xe?.customOpenAIBaseUrl||"Custom Endpoint":v.replace("c_openai","Custom Endpoint");k(Et=>(_(Et.length+1),[...Et,{id:Date.now(),role:"system",text:`\u2726 ${We}
|
|
175
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${ke}
|
|
176
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Thinking Level: ${Re}
|
|
177
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Multimodal: ${Le?"ON":"OFF"}
|
|
178
|
-
\u2800`,isMeta:!0}]))}}}else Q("model");break}case"/wildcard-tooling":{ge(u=>{let a=!u;return k(h=>(_(h.length+1),[...h,{id:Date.now(),role:"system",text:`\u2726 Wildcard Tooling:
|
|
179
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Status: ${a?"Enabled":"Disabled"}
|
|
180
|
-
\u2800`,isMeta:!0}])),a});break}case"/wildercard-tooling":{P(u=>{let a=!u;return k(h=>(_(h.length+1),[...h,{id:Date.now(),role:"system",text:`\u2726 Wildercard Tooling:
|
|
181
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Status: ${a?"Enabled":"Disabled"}
|
|
182
|
-
\u2800`,isMeta:!0}])),a});break}case"/settings":{Q("settings");break}case"/provider":case"/providers":{ts("chat"),Q("selectProvider");break}case"/theme":{Q("theme");break}case"/key":{Q("key");break}case"/profile":{Q("profile");break}case"/stats":{(async()=>{let a=await Ar(),h=await kr();ss(a),is(h),Kn("daily"),Q("stats")})();break}case"/usage":{(async()=>{try{let{openUsageDashboard:a}=await import("./usageServer-YSHTV2E3.js"),{url:h}=await a();k(C=>(_(C.length+1),[...C,{id:Date.now(),role:"system",text:`\u2726 Launching Token Analytics Dashboard
|
|
183
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Serving at ${h}
|
|
184
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Opening in your default browser...
|
|
185
|
-
\u2800`,isMeta:!0}]))}catch(a){k(h=>(_(h.length+1),[...h,{id:Date.now(),role:"system",text:`\u2726 ERROR
|
|
186
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Failed to launch dashboard: ${a.message}
|
|
187
|
-
\u2800`,isMeta:!0}]))}})();break}case"/save":{let u,a=yt.find(C=>C.role==="user");if(a&&a.text){let C=a.text.replace(/\s*\n+\s*\[Prompted on:.*?\]/g,"").trim(),X=C.split(/\s+/),U;X.length>7?U=X.slice(0,7).join(" ")+"...":C.length>45?U=C.substring(0,45).trimEnd()+"...":U=C,u=U}let h=m.slice(1).join(" ")||u||`Session ${new Date().toLocaleTimeString()}`;Nn(ft,h,yt),k(C=>(_(C.length+1),[...C,{id:Date.now(),role:"system",text:`\u2726 Saved
|
|
188
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m "${h}" (ID: ${ft})
|
|
189
|
-
\u2800`,isMeta:!0}]));break}case"/export":{(async()=>{try{let{handleExport:a}=await import("./export-QFE76VEG.js"),h=await a(m,{chatId:ft,messages:yt});k(C=>(_(C.length+1),[...C,{id:Date.now(),role:"system",text:h.message,isMeta:!0}]))}catch(a){k(h=>(_(h.length+1),[...h,{id:Date.now(),role:"system",text:`[EXPORT ERROR] Failed to export: ${a.message}`,isMeta:!0}]))}})();break}case"/chats":{(async()=>{let a=await Qo(),h=Object.entries(a).sort((C,X)=>(X[1].updatedAt||0)-(C[1].updatedAt||0)).map(([C,X])=>`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${C}: ${X.name}${C===ft?" (current)":""}`).join(`
|
|
190
|
-
`);k(C=>(_(C.length+1),[...C,{id:Date.now(),role:"system",text:`\u2726 Saved Chats:
|
|
191
|
-
${h||"\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No saved chats found."}
|
|
192
|
-
\u2800`,isMeta:!0}]))})();break}case"/memory":{if((m[1]||"view").toLowerCase()==="migrate")try{let a=vr(tr,[]);if(!a||a.length===0){k(J=>(_(J.length+1),[...J,{id:Date.now(),role:"system",text:`\u2726 Memory Migration
|
|
193
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No persistent memories found in memories.json to migrate.
|
|
194
|
-
\u2800`,isMeta:!0}]));break}let h=a.map(J=>`- ${(J.memory||"").replace(/\[Saved on: .*?\]/g,"").replace(/\\+'/g,"'").trim()}`).filter(J=>J!=="- ").join(`
|
|
195
|
-
`);if(!h){k(J=>(_(J.length+1),[...J,{id:Date.now(),role:"system",text:`\u2726 Memory Migration
|
|
196
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No valid memory entries found to migrate.
|
|
197
|
-
\u2800`,isMeta:!0}]));break}ct.existsSync(fo)||ct.mkdirSync(fo,{recursive:!0});let C=It.join(fo,"AGENTS.md"),X="";ct.existsSync(C)&&(X=ct.readFileSync(C,"utf8"));let U=X.trimEnd(),z=`${U.length>0?`
|
|
198
|
-
|
|
199
|
-
`:""}User Memories:
|
|
200
|
-
${h}
|
|
201
|
-
`,j=`${U}${z}`;ct.writeFileSync(C,j,"utf8"),k(J=>(_(J.length+1),[...J,{id:Date.now(),role:"system",text:`\u2726 Memory Migration
|
|
202
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Successfully migrated ${a.length} memories to ${C.replaceAll("\\\\","/").replaceAll("\\","/")}
|
|
203
|
-
\u2800`,isMeta:!0}]))}catch(a){k(h=>(_(h.length+1),[...h,{id:Date.now(),role:"system",text:`\u2726 Memory Migration Failed
|
|
204
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Error: ${a.message}
|
|
205
|
-
\u2800`,isMeta:!0}]))}else Q("memory");break}case"/files":{k(u=>(_(u.length+1),[...u,{id:"files-"+Date.now(),role:"system",text:el(),isMeta:!0}]));break}case"/target":{k(u=>(_(u.length+1),[...u,{id:"target-"+Date.now(),role:"system",text:`\u2726 Unique Model Id for FluxFlow
|
|
206
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${v}@${qe}
|
|
207
|
-
\u2800`,isMeta:!0}]));break}case"/reset":{(async()=>{try{k(a=>(_(a.length+1),[...a,{id:Date.now(),role:"system",text:`\u2726 Initiating reset...
|
|
208
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Clearing logs, secrets, and settings.
|
|
209
|
-
\u2800`,isMeta:!0}])),ct.existsSync(ys)&&ct.removeSync(ys),ct.existsSync(Cs)&&ct.removeSync(Cs),ct.existsSync(cn)&&ct.removeSync(cn);try{ct.readdirSync(fo).length===0&&ct.removeSync(fo)}catch{}setTimeout(()=>{Q("exit"),setTimeout(()=>process.exit(0),500)},500)}catch(a){k(h=>(_(h.length+1),[...h,{id:Date.now(),role:"system",text:`\u2726 ERROR
|
|
210
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Failed to clear data: ${a.message}.
|
|
211
|
-
\u2800`}]))}})();break}case"/about":{let u=mt(2),a=`\u2022 FluxFlow Version: v${To}
|
|
212
|
-
\u2022 Status: ${zt&&zt!==To?`Update Available [v${zt}]`:"Up to date"}
|
|
213
|
-
\u2022 Released on: ${xc}`;k(h=>(_(h.length+1),[...h,{id:"about-"+Date.now(),role:"system",text:a,isAboutRecord:!0,isMeta:!0}]));break}case"/changelog":{let u=process.platform;Do(`${u==="win32"?"start":u==="darwin"?"open":"xdg-open"} ${Yl}`),k(h=>(_(h.length+1),[...h,{id:Date.now(),role:"system",text:`\u2726 Opening Changelog
|
|
214
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${Yl}.`,isMeta:!0}]));break}case"/docs":{if(!qs){k(h=>(_(h.length+1),[...h,{id:Date.now(),role:"system",text:`\u2726 ERROR
|
|
215
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Documentation URL is not configured.`,isMeta:!0}]));break}let u=process.platform;Do(`${u==="win32"?"start":u==="darwin"?"open":"xdg-open"} ${qs}`),k(h=>(_(h.length+1),[...h,{id:Date.now(),role:"system",text:`\u2726 Opening Documentation
|
|
216
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${qs}.
|
|
217
|
-
\u2800`,isMeta:!0}]));break}case"/budget":{let u=m[1]?.toLowerCase();if(u==="web"||u==="gui"||u==="dashboard")(async()=>{try{let{openUsageDashboard:h}=await import("./usageServer-YSHTV2E3.js"),{url:C}=await h();k(X=>(_(X.length+1),[...X,{id:Date.now(),role:"system",text:`\u2726 Token Usage & Budget Dashboard
|
|
218
|
-
\u2800\u2800\u2514\u2500 Opened at ${C}
|
|
219
|
-
\u2800`,isMeta:!0}]))}catch(h){k(C=>(_(C.length+1),[...C,{id:Date.now(),role:"system",text:`\u2726 ERROR: Failed to launch dashboard: ${h.message}
|
|
220
|
-
\u2800`,isMeta:!0}]))}})();else if(u==="set")ql("chat"),Q("budgetTypeSelect");else if(u==="view")(async()=>{let h=await Ar(),C=await kr(),X=await Bs($e.resetDay||1);ss(h),is(C),di(X),Q("budgetView")})();else if(u==="reset"){let a={limitMode:"Daily",agentLimit:99999999,tokenLimit:99999999999999,backgroundLimit:999999,searchLimit:100,customModelId:"",customLimit:0,providerBudgets:{},providerTiers:{Google:"Free",DeepSeek:"Free",NVIDIA:"Free",OpenRouter:"Free",InferX:"Free",SenseNova:"Free",AIHubMix:"Free",Poolside:"Free",ExpLabs:"Free",TokenHarbor:"Free",Infron:"Free",APInex:"Free"}};ao(a),no("Free"),Ot({apiTier:"Free",quotas:a}),k(h=>(_(h.length+1),[...h,{id:Date.now(),role:"system",text:`\u2726 Budgets reset successfully.
|
|
221
|
-
\u2800`,isMeta:!0}]))}else k(a=>(_(a.length+1),[...a,{id:Date.now(),role:"system",text:`\u2726 ERROR
|
|
222
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Usage: /budget <View|Web|Set|Reset>.
|
|
223
|
-
\u2800`,isMeta:!0}]));break}case"/fluxflow":{let a=m.slice(1)[0]?.toLowerCase()?.trim();if(a==="global"){let h=It.normalize(fo);try{ct.ensureDirSync(h)}catch{}let C=process.platform;C==="win32"?Do(`explorer "${h}"`):C==="darwin"?Do(`open "${h}"`):Do(`xdg-open "${h}"`)}else if(a==="saves"){let h=It.normalize(yo);try{ct.ensureDirSync(h)}catch{h=It.normalize(fo);try{ct.ensureDirSync(h)}catch{}}let C=process.platform;C==="win32"?Do(`explorer "${h}"`):C==="darwin"?Do(`open "${h}"`):Do(`xdg-open "${h}"`)}else k(h=>(_(h.length+1),[...h,{id:"ff-err-"+Date.now(),role:"system",text:"Usage: /fluxflow global/saves",isMeta:!0}]));break}case"/update":{if(m[1]?.toLowerCase()==="check"){ie(!0);break}let a=m.includes("--latest");Q("update");break}case"/gemini":{let u=a=>{let h=a[Math.floor(Math.random()*a.length)];k(C=>(_(C.length+1),[...C,{id:Date.now(),role:"system",text:`\u2728 GEMINI CLI
|
|
224
|
-
\u2800\u2800 \x1B[2m\u2514\u2500\x1B[22m ${h}
|
|
225
|
-
\u2800`}]))};Kr?u(Kr):import("./gemini_quotes-B5IXNP2I.js").then(({GEMINI_QUOTES:a})=>{Kr=a,u(Kr)}),T("");break}case"/meow":{let u=a=>{let h=a[Math.floor(Math.random()*a.length)];k(C=>(_(C.length+1),[...C,{id:Date.now(),role:"system",text:`\u{1F431} MEOW
|
|
226
|
-
\u2800\u2800 \x1B[2m\u2514\u2500\x1B[22m ${h}
|
|
227
|
-
\u2800`}]))};qr?u(qr):import("./meow-SQBRZB7H.js").then(({MEOW_LINES:a})=>{qr=a,u(qr)}),T("");break}case"/halloween":case"/trick-or-treat":{let u=a=>{let h=a[Math.floor(Math.random()*a.length)];k(C=>(_(C.length+1),[...C,{id:Date.now(),role:"system",text:`\u{1F383} TRICK OR TREAT
|
|
228
|
-
\u2800\u2800 \x1B[2m\u2514\u2500\x1B[22m ${h}
|
|
229
|
-
\u2800`}]))};Qr?u(Qr):import("./halloween-EZTJXDUW.js").then(({SPOOKY_LINES:a})=>{Qr=a,u(Qr)}),T("");break}case"/compress":{T("");let u=yt.filter(C=>(C.role==="user"||C.role==="agent"||C.role==="system")&&!String(C.id).startsWith("welcome")&&!C.isMeta).length,a=bo?.tokens||0;if(u<64||a<16384){let C=mt(2);k(X=>(_(X.length+1),[...X,{id:Date.now(),role:"system",text:`\u2726 Compression skipped
|
|
230
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m History requires at least 64 messages and 16k tokens
|
|
231
|
-
\u2800\u2800 \u2514\u2500 Current: ${u}/64 msgs, ${a}/16384 tokens.
|
|
232
|
-
\u2800`,isMeta:!0}]));break}(async()=>{Ti(!0);let C=mt(2);k(X=>(_(X.length+1),[...X,{id:Date.now(),role:"system",text:"\u2726 Compacting session history...",isMeta:!0}]));try{if(await cl({chatId:ft,aiProvider:v,apiKey:Nt,thinkingLevel:fe,mode:I,janitorModel:Ae,systemSettings:xe,sessionStats:bo},yt)){let G=mt(2);k(z=>{let j=[...z,{id:Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Chat History compacted saving tokens.
|
|
233
|
-
\u2800`,isMeta:!0}];return _(j.length),j})}else k(G=>(_(G.length+1),[...G,{id:Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Compaction failed.
|
|
234
|
-
\u2800`,isMeta:!0}]))}catch(X){k(U=>(_(U.length+1),[...U,{id:Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Error during compaction: ${X.message}
|
|
235
|
-
\u2800`,isMeta:!0}]))}finally{Ti(!1)}})();break}case"/truncate":{T("");let u=0;k(a=>{let C=[...a.map(X=>{let U=X.fullText||X.text||"";return!U.startsWith("[ACTION RESULT]:")&&!U.startsWith("[TOOL RESULT]:")||U.startsWith("[ACTION RESULT]: Goal")||U.startsWith("[ACTION RESULT]: USER CHOOSE")||U.includes("...Success result truncated to save tokens")?X:(u++,{...X,fullText:"[ACTION RESULT]: ...Success result truncated to save tokens"})}),{id:Date.now(),role:"system",text:`\u2726 Tool Truncation...
|
|
236
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Truncated ${u} tool result(s).
|
|
237
|
-
\u2800`,isMeta:!0}];return Nn(ft,null,C),_(C.length),C});break}case"/kill":{(async()=>{let a=m[1]?parseInt(m[1],10):null,{getProcessTree:h,killProcess:C}=await import("./process-6Y7LS2MS.js");if(!a||isNaN(a))k(X=>(_(X.length+1),[...X,{id:Date.now(),role:"system",text:`\u2726 Usage: \x1B[36m/kill <pid>\x1B[0m
|
|
238
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Select an active process PID from the autocomplete list.
|
|
239
|
-
\u2800`,isMeta:!0}]));else{let X=a===process.pid,U=Wn.some(G=>G.pid===a&&(G.isRoot||G.url&&G.url.includes(":52991")||G.cmd&&G.cmd.includes("usage-daemon-worker")));if(X||U){let G=X?"FluxFlow (Main Process)":"Internal Process";k(z=>(_(z.length+1),[...z,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mPROTECTED PROCESS\x1B[0m
|
|
240
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m PID: \x1B[33m${a}\x1B[0m (${G})
|
|
241
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Unable to kill protected core process. Use \x1B[36m/quit\x1B[0m to safely shutdown FluxFlow.
|
|
242
|
-
\u2800`,isMeta:!0}]));return}try{let G=await C(a);G.success?k(z=>(_(z.length+1),[...z,{id:Date.now(),role:"system",text:`\u2726 Process Terminated:
|
|
243
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m PID: \x1B[31m${a}\x1B[0m (${G.message})
|
|
244
|
-
\u2800`,isMeta:!0}])):k(z=>(_(z.length+1),[...z,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mFAILED TO KILL PROCESS\x1B[0m
|
|
245
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m PID: ${a}
|
|
246
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Reason: ${G.message}
|
|
247
|
-
\u2800`,isMeta:!0}]))}catch(G){k(z=>(_(z.length+1),[...z,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mERROR\x1B[0m
|
|
248
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${G.message}
|
|
249
|
-
\u2800`,isMeta:!0}]))}}})();break}case"/help":{k(u=>(_(u.length+1),[...u,{id:Date.now(),role:"system",isHelpRecord:!0,isMeta:!0}]));break}case"/btw":{k(u=>(_(u.length+1),[...u,{id:Date.now(),role:"system",text:`\u2726 RESTRICTED
|
|
250
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m '/btw' only available when agent is working
|
|
251
|
-
\u2800`,isMeta:!0}]));break}default:k(u=>(_(u.length+1),[...u,{id:Date.now(),role:"system",text:`\u2726 ERROR
|
|
252
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Unknown command: '${M}'
|
|
253
|
-
\u2800`,isMeta:!0}]))}}else{let m=`[Prompted on: ${new Date().toLocaleString(void 0,{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}]`,M={id:"user-"+Date.now(),role:"user",text:`${x}
|
|
254
|
-
|
|
255
|
-
${m}`};k(a=>(_(a.length+1),[...a,M])),(async()=>{let a=!1,h=()=>{a||(a=!0,k(G=>{let z=G[G.length-1];if(z&&z.text&&z.text.includes("Request Cancelled"))return G;let J=[...G.map(te=>te.isStreaming?{...te,isStreaming:!1}:te),{id:"cancel-"+Date.now(),role:"agent",text:`
|
|
256
|
-
|
|
257
|
-
\x1B[33m\u24D8 Request Cancelled\x1B[0m`,isMeta:!1}];return _(J.length),J}))},C=!1;hs(!0),ns(Date.now()),B(!1);let X=Date.now(),U=!0;try{let G=[...yt,M].filter(V=>V.role!=="think"&&!V.isVisualFeedback&&!V.isMeta&&!V.isTerminalRecord&&!(V.text&&V.text.includes("[TERMINAL_RECORD]"))&&!String(V.id).startsWith("welcome")),z=[],j=G.map((V,Be)=>{let Se=V.fullText||V.text||"";if(V.role==="user"&&Be<G.length-1)if(Se.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")){let ve=Se.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");if(ve!==-1){let Oe=Se.substring(0,ve).lastIndexOf("[SYSTEM METADATA]");Oe!==-1?Se=Se.substring(Oe).trim():Se=Se.substring(ve).trim()}}else{let ve=Se.lastIndexOf("[USER]"),rt=Se.lastIndexOf("[USER PROMPT]");ve!==-1?Se=Se.substring(ve+6).trim():rt!==-1&&(Se=Se.substring(rt).trim())}return{...V,text:Se}}),J=0;for(;J<j.length;){let V=j[J];if(V.role==="user")z.push(V),J++;else{let Be=[];for(;J<j.length&&j[J].role!=="user";)Be.push(j[J]),J++;let Se=[],ve=[],rt=null,Oe=!1,Je=()=>{Se.length>0&&(z.push({role:"agent",text:Se.join(`
|
|
258
|
-
`).trim()}),Se=[]),ve.length>0&&(z.push({role:"system",text:ve.join(`
|
|
259
|
-
|
|
260
|
-
`),...rt?{binaryPart:rt}:{}}),ve=[],rt=null),Oe=!1};for(let Ct=0;Ct<Be.length;Ct++){let re=Be[Ct],be=re.role==="system"&&(re.text?.startsWith("[ACTION RESULT]")||re.text?.startsWith("[TOOL RESULT]")||re.text?.startsWith("SUCCESS:")||re.text?.startsWith("ERROR:")||re.fullText?.startsWith("[ACTION RESULT]")||re.fullText?.startsWith("[TOOL RESULT]")||re.fullText?.startsWith("SUCCESS:")||re.fullText?.startsWith("ERROR:")),Pe=re.fullText||re.text||"",je=Pe.trim();if(!(!je&&!re.binaryPart)){if(be){let ze=!je.startsWith("[ACTION RESULT]")&&!je.startsWith("[TOOL RESULT]")?`[ACTION RESULT]: ${je}`:je;ve.push(ze),re.binaryPart&&(rt=re.binaryPart)}else if(re.role==="agent"){!Oe&&ve.length>0&&Je();let ze=Pe.endsWith(`
|
|
261
|
-
`),Ft=je.toLowerCase().includes("tool:")||je.toLowerCase().includes("action:"),wo=!1;for(let Po=Ct+1;Po<Be.length;Po++){let jo=Be[Po];if(jo.role==="agent"){let On=(jo.fullText||jo.text||"").trim();if(On){wo=On.startsWith("[");break}}}Se.push(je),Ft&&ze&&wo?Oe=!0:Oe=!1}}}Je()}}let te=ml(qe,z,{profile:Tn,thinkingLevel:fe,mode:I,systemSettings:xe,janitorModel:Ae,sessionStats:bo,chatId:ft,isPlayground:!!Ie.playground,aiProvider:v,apiKey:Nt,apiTier:it,wildcardTooling:Ee,wildercardTooling:b,cols:W.columns-6,rows:30,onTokenChunk:(V,Be)=>{let Se=Date.now();if(ns(Se),typeof Be=="number"){ei.current=Be;let ve=rs.current;ve.startTime||(ve.startTime=Se,ve.totalWords=0,ve.chunks=[]),ve.totalWords+=Be,ve.chunks||(ve.chunks=[]),ve.chunks.push({time:Se,words:Be});let Oe=Se-400;if(ve.chunks=ve.chunks.filter(Je=>Je.time>=Oe),ve.chunks.length>0){let Je=ve.chunks.reduce((be,Pe)=>be+Pe.words,0),Ct=ve.chunks[0].time,re=Math.max(.4,(Se-Ct)/1e3);ve.wps=Math.round(Je/re*10)/10}}},onVisualFeedback:V=>{k(Be=>[...Be.map(ve=>ve.isStreaming?{...ve,isStreaming:!1}:ve),{id:"visual-"+Date.now()+"-"+Math.random().toString(36).substring(2,9),role:"system",text:V,isVisualFeedback:!0}])},onSubagentUpdate:()=>{da(ll.map(V=>({...V})))},onExecStart:V=>{Ce(),ye(),ci(V),An("")},onExecChunk:V=>{An(Be=>Be+V)},onExecEnd:()=>{k(V=>{if(!yr.current)return V;let Be=ms.current||"",Se=zi(Be),ve=`[TERMINAL_RECORD]
|
|
262
|
-
COMMAND: ${yr.current}
|
|
263
|
-
PTY: ${Pn}
|
|
264
|
-
OUTPUT: ${Se.replace(/\n{3,}/g,`
|
|
265
|
-
|
|
266
|
-
`)}`,Oe=[...V.map(Je=>Je.isStreaming?{...Je,isStreaming:!1}:Je),{id:"term-"+Date.now(),role:"system",text:ve,isTerminalRecord:!0}];return _(Oe.length),Oe}),ci(null),ui(!1),An(""),yr.current=null,ms.current=""},onToolResult:(V,Be)=>{if(V==="success"){if(ta(Se=>Se+1),Be==="generate_image"){ia(rt=>rt+1);let ve={Low:.001,"Low-High":.002,Medium:.008,"Medium-High":.01,High:.045,Ultra:.0488,Premium:.1}[Ao.quality]||.002;la(rt=>rt+ve)}}else V==="denied"?na(Se=>Se+1):oa(Se=>Se+1)},onIDEApproval:ko,onToolApproval:async(V,Be)=>{let Se=ua||xe.autoExec;if(V==="exec_command"){let{command:ve}=nr(Be||"{}");return Se||ve&&/^(echo|ls|dir|pwd|cd|git status|git log|git diff|type|cat|help)\b/i.test(ve.trim())?"allow":new Promise(Oe=>{kn({tool:V,args:Be,resolve:Oe}),Q("terminalApproval")})}return Se?"allow":new Promise(ve=>{kn({tool:V,args:Be,resolve:ve}),Q("approval")})},onAskUser:async(V,Be)=>(Ce(),ye(),new Promise(Se=>{let ve=!1;xs({question:V,options:Be,resolve:rt=>{ve||(ve=!0,k(Oe=>{if(Oe.some(re=>re.isAskRecord&&re.text?.includes(`Selection: ${rt}`)))return Oe;let Ct=[...Oe,{id:"ask-"+Date.now(),role:"system",text:`\u{1F4AC} **Ask User**
|
|
267
|
-
Question: ${V}
|
|
268
|
-
Selection: ${rt}`,isAskRecord:!0}];return _(Ct.length),Ct}),Se(rt))}}),Q("ask")})),onUsage:V=>{let Be=V.totalTokenCount||0,Se=V.cachedContentTokenCount||0,ve=V.candidatesTokenCount||0,rt=Math.max(0,Be-ve);Wo({tokens:Be}),ri(Oe=>Oe+Be),rt>0&&si(Oe=>Oe+rt),Se>0&&ii(Oe=>Oe+Se),ve>0&&li(Oe=>Oe+ve),oi(Oe=>Oe+1)}},async()=>Oo.current?Oo.current:null,To),H=!1,_e=null,Fe=null,ke=!1,ce=!1,he=!1,Le=!1,Re=0,We=null,Et=/\[?\s*turn\s*:\s*.*?\s*\]?/gi;for await(let V of te){if(await new Promise(re=>setTimeout(re,3)),V.type==="text"&&ns(Date.now()),U&&V.type==="text"&&(X=Date.now(),U=!1,xe.progressiveRendering&&Ne()),V.type==="status"){if(V.content&&(V.content.includes("Steering Hint Injected")||V.content.includes("Question Forwarded"))){let re=Oo.current;re&&(k(be=>{_(be.length+1);let Pe=re.startsWith("/btw"),je=Pe?re.replace(/^\/btw\s*/,""):re,ze=Pe?"[QUESTION]":"[STEERING HINT]";return[...be,{id:"hint-"+Date.now(),role:"user",text:`${ze}
|
|
269
|
-
${je}`,color:"cyan",isSteeringHint:!0,hintType:Pe?"QUESTION":"STEERING HINT",hintContent:je}]}),Ts(null),Oo.current=null)}V.content?.includes("[start]")||fs(V.content),V.content?.includes("[start]")?(clearInterval(Zn),Jn(0),Zn=setInterval(()=>{Jn(re=>re+1)},1e3)):V.content?.includes("[end]")&&(Jn(0),clearInterval(Zn)),mn()&&Nr(V.content),V.content==="Request Cancelled"&&(Ce(),ye(),h());continue}if(V.type==="status_history"){fs(V.content),mn()&&Nr(V.content),k(re=>[...re,{id:"condense-"+Date.now(),role:"system",text:`\u2726 ${V.content}
|
|
270
|
-
\u2800`,isMeta:!0}]);continue}if(V.type==="summary_injected"){k(re=>re.map(be=>be.id===V.content.id?{...be,fullText:V.content.text}:be));continue}if(V.type==="spinner"){ga(V.content);continue}if(V.type==="model_update"){wa(V.content);continue}if(V.type==="turn_reset"){if(Ce(),ye(),_e=null,Fe=null,H=!1,ke=!1,ce=!1,Le=!1,he=!1,k(re=>{let be=re.map(Pe=>{if(Pe.isStreaming){let je=Pe.text?kt(Pe.text):Pe.text,ze=Pe.fullText?kt(Pe.fullText):Pe.fullText;return{...Pe,isStreaming:!1,text:je,fullText:ze}}return Pe});return _(be.length),be}),No(),global.gc){for(let re=0;re<2;re++)global.gc(),await new Promise(be=>setImmediate(be));f.current=Date.now()}continue}if(V.type==="interactive_turn_finished"){hs(!1),Jn(0),clearInterval(Zn),mn()&&Nr(null),C=!0,No(),xe?.autoTruncateResults&&k(re=>{let be=re.map(Pe=>{let je=Pe.fullText||Pe.text||"";return!je.startsWith("[ACTION RESULT]:")&&!je.startsWith("[TOOL RESULT]:")||je.startsWith("[ACTION RESULT]: Goal")||je.includes("...Success result truncated to save tokens")||je.startsWith("[ACTION RESULT]: USER CHOOSE")||je.startsWith("[ACTION RESULT]: Skill:")||je.startsWith("[ACTION RESULT]: DOCs:")||je.startsWith("[ACTION RESULT]: Markdown parsed")||je.startsWith("[ACTION RESULT]: Search results for [")||je.startsWith("[ACTION RESULT]: AI Mode temporarily failed")?Pe:{...Pe,fullText:"[ACTION RESULT]: ...Success result truncated to save tokens"}});return Nn(ft,null,be),_(be.length),be}),dl({profile:Tn,thinkingLevel:fe,mode:I,janitorModel:Ae,chatId:ft,systemSettings:xe,sessionStats:bo,aiProvider:v,apiKey:Nt},V.data.agentText,V.data.fullAgentTextRaw,V.data.history,{onMemoryUpdated:()=>k(re=>{let be=[...re];return be.length>0&&(be[be.length-1].memoryUpdated=!0),be}),onBackgroundIncrement:()=>Jl(re=>re+1)});continue}if(V.type==="visual_feedback"){Ce(),ye(),k(re=>{let be=[...re,{id:"feedback-"+Date.now()+"-"+Math.random().toString(36).substring(2,9),role:"system",text:kt(V.content),isVisualFeedback:!0}];return _(be.length),be});continue}if(V.type==="exec_start"){Ce(),ye();continue}if(V.type==="liveTokens"){Wo({tokens:V.content});continue}if(V.type==="usage"){let re=V.content.totalTokenCount||0,be=V.content.cachedContentTokenCount||0,Pe=V.content.candidatesTokenCount||0,je=Math.max(0,re-Pe);Wo({tokens:re}),ri(ze=>ze+re),je>0&&si(ze=>ze+je),be>0&&ii(ze=>ze+be),Pe>0&&li(ze=>ze+Pe),oi(ze=>ze+1);continue}if(V.type==="tool_time"){sa(re=>re+V.content);continue}if(V.type==="tool_result"){if(ye(),_e=null,Fe=null,H=!1,ke=!1,ce=!1,Le=!1,he=!1,Re=0,We=null,k(re=>{let be=[...re,{id:"tool-"+Date.now()+"-"+Math.random().toString(36).substring(2,7),role:"system",text:kt(V.content),fullText:kt(V.aiContent),binaryPart:V.binaryPart,toolName:V.toolName}];return _(be.length),be}),V.toolName==="update_file"&&V.aiContent){let re=V.aiContent.split(`
|
|
271
|
-
`),be=0,Pe=0,je=!1;for(let ze of re){if(ze.includes("[DIFF_START]")){je=!0;continue}if(ze.includes("[DIFF_END]")){je=!1;continue}je&&(/^\+\s*\d+/.test(ze)?be++:/^\-\s*\d+/.test(ze)&&Pe++)}un("linesAdded",be),un("linesRemoved",Pe)}else if(V.toolName==="write_file"&&V.aiContent){let re=V.aiContent.match(/- Stats: \[(\d+) lines/),be=re?parseInt(re[1]):0,Pe=0;if(V.aiContent.includes("Old File contents:")){let je=V.aiContent.split(`
|
|
272
|
-
`),ze=!1;for(let Ft of je){if(Ft.includes("Old File contents:")){ze=!0;continue}ze&&(Ft.startsWith("- Content Preview:")||Ft.trim()===""&&!/^\s*\d+\s*\|/.test(Ft)?ze=!1:/^\s*\d+\s*\|/.test(Ft)&&Pe++)}}(be>0||Pe>0)&&(un("linesAdded",be),un("linesRemoved",Pe))}continue}let Be=V.content;if(V.type==="text"&&Be.includes("Request Cancelled")){if(global.gc){for(let re=0;re<3;re++)global.gc(),await new Promise(be=>setImmediate(be));f.current=Date.now()}continue}let Se=Be.toLowerCase();if(Be.includes("```")&&(ke=!ke),(Se.includes("tool:")||Se.includes("action:"))&&(ce=!0,Re=0,We=null,(Be.includes("[tool:")||Be.includes("[action:"))&&(Re=0)),ce){for(let re=0;re<Be.length;re++){let be=Be[re];!We&&(be==="'"||be==='"'||be==="`")?We=be:We&&be===We&&Be[re-1]!=="\\"&&(We=null),We||(be==="("||be==="["?Re++:(be===")"||be==="]")&&Re--)}Re<=0&&!We&&(ce=!1)}let ve=/^\s*(?:<(think|thought|thoughts)[^>]*>|<\|channel>thought|\[(think|thought|thoughts)\])/i,rt=(re,be,Pe=1)=>{let je=be>0?re[be-1]:"",ze=be+Pe<re.length?re[be+Pe]:"";return je==="`"&&ze==="`"},Oe=re=>{let be=/(?:<\/(think|thought|thoughts)>|<channel\|>|\[\/(think|thought|thoughts)\])/gi,Pe;for(;(Pe=be.exec(re))!==null;)if(!rt(re,Pe.index,Pe[0].length))return{index:Pe.index,length:Pe[0].length};return{index:-1,length:0}},Je=le.current?.role==="agent"&&le.current.text||"",Ct=!he&&Je.trim().length===0;if(!H&&Ct&&(ve.test(Be)||ve.test(Je+Be))){let re=ve.test(Be)?Be:Je+Be,be=re.match(ve),Pe=be.index,je=be[0].length,ze=re.substring(Pe+je);Ce(),le.current=null,H=!0,he=!0,_e="think-"+Date.now(),le.current={id:_e,role:"think",text:"",isStreaming:!0,startTime:Date.now()};let Ft=Oe(ze);if(Ft.index!==-1){let Po=ze.substring(0,Ft.index).replace(/^\r?\n+/,"").replace(/\r?\n+$/,""),jo=ze.substring(Ft.index+Ft.length);le.current.text=kt(Po);let On=le.current.startTime||Date.now();le.current.duration=Date.now()-On,ye(),H=!1,Fe="agent-"+Date.now(),le.current={id:Fe,role:"agent",text:"",isStreaming:!0},jo&<(jo)}else{let wo=ze.replace(/^\r?\n+/,"");wo&<(wo)}continue}if(!H&&!he&&Be.trim().length>0&&(he=!0),H&&le.current?.role==="think"){Ce();let re=le.current.text+Be,be=Oe(re);if(be.index!==-1){let Pe=re.substring(0,be.index),je=re.substring(be.index+be.length);le.current.text=kt(Pe);let ze=le.current.startTime||Date.now();le.current.duration=Date.now()-ze,ye(),H=!1,Fe="agent-"+Date.now(),le.current={id:Fe,role:"agent",text:"",isStreaming:!0},je&<(je)}else lt(Be);continue}else if(!H){let re=Be.toLowerCase();!Le&&(re.includes("tool:")||re.includes("action:"))&&(Le=!0),!le.current||le.current.role!=="agent"?(Fe="agent-"+Date.now(),le.current={id:Fe,role:"agent",text:kt(Be),isStreaming:!0},ne()):lt(Be)}}let Lt=Date.now();ra(V=>V+(Lt-X))}catch(G){k(z=>(_(z.length+1),[...z,{id:"error-"+Date.now(),role:"system",text:`\u274C ERROR: ${G.message}`}]))}finally{let G=Date.now()-X;if(le.current&&(le.current.workedDuration=G),ae.current&&(await et(),clearInterval(ae.current),ae.current=null),hs(!1),fs(null),Jn(0),clearInterval(Zn),ye(),ps.current&&h(),No(),global.gc)try{for(let z=0;z<3;z++)global.gc(),await new Promise(j=>setImmediate(j));f.current=Date.now()}catch{}if(C||process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow | Idle\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow | Idle\x07")),Oo.current){bs(Oo.current),Ts(null);let z=Oo.current;Oo.current=null,k(j=>{let J=[...j],te=J.reverse().find(H=>H.text?.includes("[STEERING HINT: QUEUED]")||H.text?.includes("[QUESTION: QUEUED]"));return te&&(te.text.includes("[STEERING HINT: QUEUED]")?te.text=te.text.replace("[STEERING HINT: QUEUED]","[STEERING HINT: FINISHED_TURN]"):te.text.includes("[QUESTION: QUEUED]")&&(te.text=te.text.replace("[QUESTION: QUEUED]","[QUESTION: FINISHED_TURN]"))),J.reverse()}),Q("resolution")}k(z=>{let j=Date.now()-X,J=!1,te=[...z].reverse().map(Fe=>{let ke=Fe.isStreaming?{...Fe,isStreaming:!1}:Fe;return ke.text&&(ke.text=(" "+ke.text).slice(1)),!J&&ke.role==="agent"&&(J=!0,ke={...ke,workedDuration:j}),ke}).reverse();if(!te.some(Fe=>Fe.role==="agent"&&Fe.text?.trim().length>0)){let Fe=[...te].reverse().find(ke=>ke.role==="think"&&ke.text?.trim().length>0);Fe&&te.push({id:"agent-fallback-"+Date.now(),role:"agent",text:Fe.text,isStreaming:!1,workedDuration:j})}let _e=te.filter(Fe=>!String(Fe.id).startsWith("welcome")&&(!Fe.isMeta||Fe.text&&Fe.text.includes("Request Cancelled")));return Nn(ft,null,_e),_(te.length),te})}})()}T(""),B(!1)}},tt=Hn(()=>{if(w.startsWith("/")&&!R){let m=w.split(" "),M=m[m.length-1].toLowerCase();if(m.length===1){let a=M.startsWith("/")?M.slice(1):M;return Ii.filter(h=>(h.cmd.startsWith("/")?h.cmd.slice(1):h.cmd).toLowerCase().includes(a))}let u=Ii;for(let a=0;a<m.length-1;a++){let h=m[a].toLowerCase(),C=u.find(X=>X.cmd.toLowerCase()===h);if(C&&C.subs)u=C.subs;else return[]}return u.filter(a=>a.cmd.toLowerCase().includes(M))}let n=w.split(" "),o=n[n.length-1],d=o&&o.startsWith("\\@");if((o&&o.startsWith("@")||d)&&!R){let m=o.indexOf("#"),M=m!==-1,u=d?2:1,a=M?o.substring(u,m).toLowerCase():o.slice(u).toLowerCase(),h=M?o.substring(m):"";return gc(process.cwd()).filter(U=>U.name.toLowerCase().includes(a)).map(U=>{let G=U.relativePath.replace(/\\/g,"/"),z=G.startsWith(".")?G:"./"+G;return{cmd:(d?"\\@":"@")+"["+z+h+"]",desc:U.relativePath}})}return[]},[w,R]);ut(()=>{let n=0;for(;n<tt.length;){let o=tt[n],d=o?.cmd||o||"";if(typeof d=="string"&&d.trimStart().startsWith("---"))n++;else break}ue(n<tt.length?n:0)},[tt]);let[Er,Br]=Z(0),ki=ot(0);ut(()=>{let n=ki.current>0,o=tt.length>0;if(ki.current=tt.length,!o){Br(0);return}if(!n){Br(1);return}Br(tt.length)},[tt]),ut(()=>{if(Er>0&&Er<tt.length){let n=setTimeout(()=>{Br(o=>Math.min(o+1,tt.length))},1);return()=>clearTimeout(n)}},[Er,tt.length]),ut(()=>{if(gt!=="providerBudgetSelect")return;let n=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","Infron","APInex"],o=$e.providerBudgets||{},d=n.reduce((x,m)=>(x[m]=!!(o[m]&&(o[m].agentLimit||o[m].tokenLimit||o[m].monthlyTokenLimit||o[m].dailyCostLimit||o[m].monthlyCostLimit)),x),{});Js(d),fr(0)},[gt]),ut(()=>{if(gt!=="providerBudgetFlow")return;let n={},o=$e.providerBudgets||{};for(let d of hn){let x=o[d]||{};n[d]={agentLimit:Ho(x.agentLimit),tokenLimit:Ho(x.tokenLimit),monthlyTokenLimit:Ho(x.monthlyTokenLimit),dailyCostLimit:Ho(x.dailyCostLimit),monthlyCostLimit:Ho(x.monthlyCostLimit)}}Yn(n),co(0)},[gt,hn]);let Ic=({label:n,isSelected:o})=>{let d=n==="Cancel"||n==="Back"||n.toLowerCase().includes("exit")||n.toLowerCase().includes("back");return e.createElement(c,{marginTop:d?1:0,backgroundColor:o?"#2a2a2a":void 0,paddingX:1,width:"100%"},e.createElement(i,{color:o?"white":"gray",bold:o},o?"\u276F ":" ",n))},ro=(n,o,d,x=10,m=2,M=9)=>{let u=lo(d),a=!u&&d>0?Math.min(100,o/d*100):0,h=Math.round(a),C=Math.round(h/100*x),X="\u2588".repeat(C)+"\u2591".repeat(Math.max(0,x-C)),U=r.success||"green";h>=40&&h<=80?U=r.warning||"yellow":h>80&&(U=r.danger||"red");let G=n.toLowerCase().includes("cost")||n.toLowerCase().includes("spend"),z=!G&&(n.toLowerCase().includes("token")||n.toLowerCase().includes("daily")||n.toLowerCase().includes("monthly")),j=u?"\u221E":G?`$${Number(d).toFixed(2)}`:z?Tt(d):d,J=Number(o)||0,te=G?`$${J.toFixed(J<.01&&J>0?4:2)}`:z?Tt(o):o,H;return u||a===0?H="0%":a>0&&a<1?H="<1%":H=`${h}%`,e.createElement(c,{flexDirection:"row",paddingLeft:m,key:n},e.createElement(c,{width:M},e.createElement(i,{color:r.textMuted},n,": ")),e.createElement(i,{color:U},X),e.createElement(i,{color:r.textMuted}," ",H," (",te,"/",j,")"))},Sa=()=>{switch(gt){case"settings":return e.createElement(Vr,{systemSettings:xe,setSystemSettings:St,apiTier:it,setActiveView:Q,setInputConfig:Jt,saveSettings:Ot,quotas:$e,setMessages:k,aiProvider:v,setProviderReturnView:ts});case"theme":return e.createElement(Vr,{systemSettings:xe,setSystemSettings:St,apiTier:it,setActiveView:Q,setInputConfig:Jt,saveSettings:Ot,quotas:$e,setMessages:k,aiProvider:v,initialSelectingTheme:!0,onCloseTheme:()=>Q("chat"),setProviderReturnView:ts});case"selectProvider":return e.createElement(wt,{title:"SELECT AI PROVIDER",searchable:!0,items:[{label:"Google",value:"Google"},{label:"Nvidia",value:"NVIDIA"},{label:"DeepSeek",value:"DeepSeek"},{label:"InferX",value:"InferX"},{label:"SenseNova",value:"SenseNova"},{label:"Poolside",value:"Poolside"},{label:"Experiential Labs",value:"ExpLabs"},{label:"Token Harbor",value:"TokenHarbor"},{label:"Infron",value:"Infron"},{label:"APInex",value:"APInex"},{label:"Ollama",value:"Ollama"},...process.env.ENABLE_9ROUTER==="true"||process.env.ENABLE_9ROUTER===!0?[{label:"9router [Local Proxy]",value:"9router"}]:[],{label:"AIHubMix [Experimental]",value:"AIHubMix"},{label:"Mistral [Experimental]",value:"Mistral"},{label:"OpenRouter [Experimental]",value:"OpenRouter"},{label:"Custom [OpenAI Chat Completion]",value:"c_openai"},{label:"Back",value:Go}],theme:xe.theme,onSelect:async n=>{if(n.value===Go||n.value==="settings"||n.value==="Back"){Q(Go);return}let o=n.value,d=await qo(o),x="";if(o==="9router"){let m=await Ys();m.ok||(x=`
|
|
273
|
-
|
|
274
|
-
\x1B[33m\u2726 WARNING: 9router does not appear to be running on ${m.url}.\x1B[39m
|
|
275
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m To start 9router: \x1B[36mnpx 9router\x1B[39m or \x1B[36mnpm i -g 9router && 9router\x1B[39m`)}if(o==="c_openai"){if(!xe.customOpenAIBaseUrl){Jt({label:"Enter Custom OpenAI Base URL (.../v1):",key:"customOpenAIBaseUrl",value:"",returnView:Go}),Q("input");return}let m=d||"";Ue(o),_t(m),Fo(m,{aiProvider:o,onIDEApproval:ko});let M=($e.providerTiers||{})[o]||"Free",u=eo(o,M)||"";Kt(u),no(M),St(a=>({...a,memory:!1})),Ot({aiProvider:o,activeModel:u,apiTier:M,quotas:$e,systemSettings:{...xe,memory:!1}}),k(a=>[...a,{role:"system",text:`\u2726 Switched to Custom (OpenAI)!${u?`
|
|
276
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: ${u}.`:""}
|
|
277
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Endpoint: ${xe.customOpenAIBaseUrl}${xe.memory?`
|
|
278
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with Custom (OpenAI).`:""}
|
|
279
|
-
\u2800`,isMeta:!0}]),Q(Go);return}if(d){Ue(o),_t(d),Fo(d,{aiProvider:o,onIDEApproval:ko});let m=($e.providerTiers||{})[o]||"Free",M=eo(o,m);Kt(M),no(m),o==="NVIDIA"&&process.env.NVIDIA_BASE_URL||o==="Ollama"||o==="InferX"||o==="SenseNova"||o==="Poolside"||o==="9router"||o==="ExpLabs"||o==="TokenHarbor"||o==="Infron"||o==="APInex"||o==="c_openai"?(St(a=>({...a,memory:!1})),Ot({aiProvider:o,activeModel:M,apiTier:m,quotas:$e,systemSettings:{...xe,memory:!1}})):Ot({aiProvider:o,activeModel:M,apiTier:m,quotas:$e});let u=o==="c_openai"?"Custom (OpenAI)":o;k(a=>[...a,{role:"system",text:`\u2726 Switched to ${u} (cached)!${M?`
|
|
280
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: ${M}.`:""}${(o==="Ollama"||o==="InferX"||o==="SenseNova"||o==="AIHubMix"||o==="Poolside"||o==="9router"||o==="ExpLabs"||o==="TokenHarbor"||o==="Infron"||o==="APInex"||o==="c_openai")&&xe.memory?`
|
|
281
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with ${u}.`:""}${o==="NVIDIA"&&process.env.NVIDIA_BASE_URL&&xe.memory?`
|
|
282
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with Custom Endpoints.`:""}${x}
|
|
283
|
-
\u2800`,isMeta:!0}]),Q(Go)}else Jt({label:`Enter ${o==="c_openai"?"Custom (OpenAI)":o} API Key:`,key:"providerKey",provider:o,value:"",returnView:Go}),Q("input")},onClose:()=>Q(Go)});case"apiTier":return e.createElement(wt,{title:`Show Paid models from ${v.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] ${it==="Paid"?"\u25CF":""}`,value:"Paid"},{label:"Back",value:"settings"}],theme:xe.theme,onSelect:n=>{if(n.value==="settings"||n.value==="Back"){Q("settings");return}let o=n.value;no(o);let d={...$e.providerTiers||{},[v]:o},x={...$e,providerTiers:d};ao(x),Ot({apiTier:o,quotas:x}),Q("settings")}});case"resetMode":return e.createElement(wt,{title:"SELECT MONTHLY RESET MODE",items:[{label:"Default (Rolling 30-Day Window)",value:"Rolling"},{label:"Custom (Set reset day of month)",value:"Custom"},{label:"Back",value:"apiTier"}],theme:xe.theme,onSelect:n=>{if(n.value==="apiTier"||n.value==="Back"){Q("apiTier");return}let o=n.value,d={...$e,resetMode:o};ao(d),o==="Custom"?(Jt({label:"Enter monthly reset day (1-30):",key:"quotas",subKey:"resetDay",value:String($e.resetDay||1),returnView:"settings"}),Q("input")):(Ot({apiTier:it,quotas:d}),Q("settings"))},onClose:()=>Q("apiTier")});case"budgetTypeSelect":return e.createElement(wt,{title:"SELECT BUDGET TYPE",items:[{label:`Global Budget (single limit for all providers) ${it==="Paid"&&!$e.providerBudgets?.__useProvider?"\u25CF":""}`,value:"global"},{label:`Provider Budgets (set limits per provider individually) ${$e.providerBudgets?.__useProvider?"\u25CF":""}`,value:"provider"},{label:"Back",value:Io}],theme:xe.theme,onSelect:n=>{if(n.value===Io||n.value==="Back"){Q(Io);return}if(n.value==="global"){let o={...$e,agentLimit:99999999,tokenLimit:99999999999999,monthlyTokenLimit:99999999999999,providerBudgets:{__useProvider:!1}};ao(o);let d=Io==="settings"?"resetMode":"budgetResetMode";Jt({label:"Enter Agent daily budget (tokens used):",key:"quotas",subKey:"tokenLimit",value:Ho(o.tokenLimit),returnView:Io,next:x=>({label:"Enter Agent monthly budget (tokens used):",key:"quotas",subKey:"monthlyTokenLimit",value:Ho(x.monthlyTokenLimit),returnView:Io,next:m=>({label:"Enter Daily Cost Limit ($ or 0 for unlimited):",key:"quotas",subKey:"dailyCostLimit",value:Ho(m.dailyCostLimit),returnView:Io,next:M=>({label:"Enter Monthly Cost Limit ($ or 0 for unlimited):",key:"quotas",subKey:"monthlyCostLimit",value:Ho(M.monthlyCostLimit),returnView:d})})})}),Q("input")}else if(n.value==="provider"){let o={...$e,agentLimit:99999999,tokenLimit:99999999999999,monthlyTokenLimit:99999999999999,providerBudgets:{...$e.providerBudgets||{},__useProvider:!0}};ao(o),Q("providerBudgetSelect")}},onClose:()=>Q(Io)});case"providerBudgetSelect":{let n=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","Infron","APInex"],o=n.some(d=>os[d]);return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:r.borderMuted,padding:0,width:"100%"},e.createElement(c,{paddingX:1,marginBottom:1},e.createElement(i,{color:r.text,bold:!0},"SELECT PROVIDERS TO SET LIMITS FOR")),n.map((d,x)=>{let m=x===zs,M=!!os[d];return e.createElement(c,{key:d,backgroundColor:m?r.highlightBg||"#2a2a2a":void 0,paddingX:1,width:"100%",flexDirection:"row"},e.createElement(i,{color:m?r.text:r.textMuted,bold:m},m?"\u276F ":" "),e.createElement(i,{color:M?r.success||"green":r.textMuted},M?"\u2611":"\u2610"),e.createElement(i,{color:m?r.text:r.textMuted,bold:m}," ",d),M&&($e.providerBudgets?.[d]?.agentLimit||$e.providerBudgets?.[d]?.tokenLimit||$e.providerBudgets?.[d]?.monthlyTokenLimit||$e.providerBudgets?.[d]?.dailyCostLimit||$e.providerBudgets?.[d]?.monthlyCostLimit)?e.createElement(i,{color:r.primary||"cyan"}," (budget set)"):null)}),e.createElement(c,{paddingX:1,marginTop:1,flexDirection:"column"},e.createElement(i,{color:r.textMuted,italic:!0},"\u2191\u2193 Navigate \u2022 Space to toggle \u2022 Enter to confirm \u2022 ESC to go back"),!o&&e.createElement(i,{color:r.warning||"yellow",italic:!0}," Select at least one provider to continue")))}case"providerBudgetFlow":{let n=hn.length,o=n*4;return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:r.borderMuted,padding:0,width:"100%"},e.createElement(c,{paddingX:1,marginBottom:0,justifyContent:"space-between",flexDirection:"row"},e.createElement(i,{color:r.text,bold:!0},"PROVIDER BUDGET CONFIGURATION"),e.createElement(i,{color:r.textMuted,italic:!0},"(0 or blank = unlimited)")),e.createElement(c,{paddingX:1,marginTop:1,flexDirection:"row"},e.createElement(c,{width:13},e.createElement(i,{color:r.textMuted,bold:!0},"PROVIDER")),e.createElement(c,{width:20,paddingLeft:1},e.createElement(i,{color:r.textMuted,bold:!0},"DAILY TOKENS")),e.createElement(c,{width:22,paddingLeft:1},e.createElement(i,{color:r.textMuted,bold:!0},"MONTHLY TOKENS")),e.createElement(c,{width:18,paddingLeft:1},e.createElement(i,{color:r.textMuted,bold:!0},"DAILY COST ($)")),e.createElement(c,{width:20,paddingLeft:1},e.createElement(i,{color:r.textMuted,bold:!0},"MONTHLY COST ($)"))),e.createElement(c,{paddingX:1},e.createElement(i,{color:r.borderMuted},"\u2500".repeat(93))),hn.map((d,x)=>{let m=x*4,M=x*4+1,u=x*4+2,a=x*4+3,h=pn===m,C=pn===M,X=pn===u,U=pn===a,G=h||C||X||U,z=Vn[d]?.tokenLimit??"",j=Vn[d]?.monthlyTokenLimit??"",J=Vn[d]?.dailyCostLimit??"",te=Vn[d]?.monthlyCostLimit??"";return e.createElement(c,{key:d,flexDirection:"row",paddingX:1,marginY:0,backgroundColor:G?r.highlightBg||"#2a2a2a":void 0},e.createElement(c,{width:13,flexDirection:"row"},e.createElement(i,{color:G?r.primary||"cyan":r.text,bold:G},G?"\u276F ":" ",d)),e.createElement(c,{width:20,paddingLeft:1,flexDirection:"row"},h?e.createElement(c,{flexDirection:"row"},e.createElement(i,{color:r.primary||"cyan",bold:!0},"[ "),e.createElement(Xn,{value:z,onChange:H=>{Yn(_e=>({..._e,[d]:{..._e[d]||{},tokenLimit:H}}))},onSubmit:()=>co(M)}),e.createElement(i,{color:r.primary||"cyan",bold:!0}," ]")):e.createElement(i,{color:z?r.text:r.textMuted},"[ ",z||"0 (\u221E)"," ]")),e.createElement(c,{width:22,paddingLeft:1,flexDirection:"row"},C?e.createElement(c,{flexDirection:"row"},e.createElement(i,{color:r.primary||"cyan",bold:!0},"[ "),e.createElement(Xn,{value:j,onChange:H=>{Yn(_e=>({..._e,[d]:{..._e[d]||{},monthlyTokenLimit:H}}))},onSubmit:()=>co(u)}),e.createElement(i,{color:r.primary||"cyan",bold:!0}," ]")):e.createElement(i,{color:j?r.text:r.textMuted},"[ ",j||"0 (\u221E)"," ]")),e.createElement(c,{width:18,paddingLeft:1,flexDirection:"row"},X?e.createElement(c,{flexDirection:"row"},e.createElement(i,{color:r.primary||"cyan",bold:!0},"[ $"),e.createElement(Xn,{value:J,onChange:H=>{Yn(_e=>({..._e,[d]:{..._e[d]||{},dailyCostLimit:H}}))},onSubmit:()=>co(a)}),e.createElement(i,{color:r.primary||"cyan",bold:!0}," ]")):e.createElement(i,{color:J?r.warning||"yellow":r.textMuted},"[ ",J?`$${J}`:"0 (\u221E)"," ]")),e.createElement(c,{width:20,paddingLeft:1,flexDirection:"row"},U?e.createElement(c,{flexDirection:"row"},e.createElement(i,{color:r.primary||"cyan",bold:!0},"[ $"),e.createElement(Xn,{value:te,onChange:H=>{Yn(_e=>({..._e,[d]:{..._e[d]||{},monthlyCostLimit:H}}))},onSubmit:()=>{x+1<n?co((x+1)*4):co(o)}}),e.createElement(i,{color:r.primary||"cyan",bold:!0}," ]")):e.createElement(i,{color:te?r.warning||"yellow":r.textMuted},"[ ",te?`$${te}`:"0 (\u221E)"," ]")))}),e.createElement(c,{paddingX:1,marginTop:1},pn===o?e.createElement(c,{backgroundColor:r.highlightBg||"#2a2a2a",paddingX:1},e.createElement(i,{color:r.success||"green",bold:!0},"\u276F [ Save & Apply Budgets ]")):e.createElement(i,{color:r.textMuted}," [ Save & Apply Budgets ]")),e.createElement(c,{paddingX:1,marginTop:1,flexDirection:"column"},e.createElement(i,{color:r.textMuted,italic:!0},"\u2191\u2193/\u2190\u2192 Navigate \u2022 Enter next / save \u2022 ESC to go back")))}case"budgetResetMode":return e.createElement(wt,{title:"SELECT MONTHLY RESET MODE",items:[{label:"Default (Rolling 30-Day Window)",value:"Rolling"},{label:"Custom (Set reset day of month)",value:"Custom"},{label:"Back",value:"chat"}],theme:xe.theme,onSelect:n=>{if(n.value==="chat"||n.value==="Back"){Q("chat");return}let o=n.value,d={...$e,resetMode:o};ao(d),o==="Custom"?(Jt({label:"Enter monthly reset day (1-30):",key:"quotas",subKey:"resetDay",value:String($e.resetDay||1),returnView:"chat"}),Q("input")):(Ot({apiTier:it,quotas:d}),Q("chat"))},onClose:()=>Q("chat")});case"budgetView":{let n=Bn?.agent||0,o=$e.agentLimit||99999999,d=Bn?.tokens||0,x=$e.tokenLimit||99999999999999,m=$e.resetMode==="Custom"?br?.tokens||0:jn?.tokens||0,M=$e.monthlyTokenLimit||99999999999999,u=Bn?.cost||0,a=$e.dailyCostLimit||99999999999999,h=$e.resetMode==="Custom"?br?.cost||0:jn?.cost||0,C=$e.monthlyCostLimit||99999999999999,X=it!=="Paid",U=!!$e.providerBudgets?.__useProvider,G=$e.providerBudgets||{},z=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","Infron","APInex"].filter(H=>G[H]&&(G[H].agentLimit||G[H].tokenLimit||G[H].monthlyTokenLimit||G[H].dailyCostLimit||G[H].monthlyCostLimit)),j=!U&&(lo(x)||lo(M))&&(lo(a)||lo(C)),J="",te="";if($e.resetMode==="Custom"){let H=new Date,_e=$e.resetDay||1,Fe=H.getFullYear(),ke=H.getMonth();H.getDate()>=_e&&(ke+=1,ke>11&&(ke=0,Fe+=1));let ce=new Date(Fe,ke,_e,0,0,0);J=`${ce.toLocaleString("default",{month:"short"}).toUpperCase()}-${_e}`;let Le=Math.max(0,ce.getTime()-H.getTime()),Re=Math.floor(Le/(1e3*60*60)),We=Math.floor(Re/24),Et=Re%24;te=`(${We} days: ${Et} hrs left)`}return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:r.borderMuted,padding:1,paddingBottom:0,paddingTop:0,width:"100%"},e.createElement(c,{marginBottom:1,justifyContent:"space-between",width:"100%"},e.createElement(i,{color:r.text,bold:!0,underline:!0},"USAGE LIMITS"),e.createElement(i,{color:r.textMuted},"[ ESC to Close ]")),j?e.createElement(c,{padding:1,justifyContent:"center",alignItems:"center",width:"100%"},e.createElement(i,{color:r.text,bold:!0},"LIMITS NOT SET")):U&&z.length>0?e.createElement(c,{flexDirection:"column",gap:0,width:"100%"},(()=>{let H=l?.columns||W?.columns||80;if(H<115){let ke=Math.max(5,Math.min(30,H-50));return z.map(ce=>{let he=G[ce],Le=0,Re=Bn?.models?.[ce]||{};for(let Se in Re)Le+=Re[Se]?.tokens||0;let We=0,Lt=($e.resetMode==="Custom"?br:jn)?.models?.[ce]||{};for(let Se in Lt)We+=Lt[Se]?.tokens||0;let V=0;for(let Se in Re)V+=Re[Se]?.cost||0;let Be=0;for(let Se in Lt)Be+=Lt[Se]?.cost||0;return e.createElement(c,{key:ce,flexDirection:"column",borderStyle:"single",borderColor:r.borderMuted,paddingX:1,width:"100%"},e.createElement(c,{marginBottom:0},e.createElement(i,{color:r.primary,bold:!0},"\u25C6 ",ce)),ro("Daily",Le,he.tokenLimit||99999999999999,ke,2,9),ro("Monthly",We,he.monthlyTokenLimit||99999999999999,ke,2,9),(!lo(he.dailyCostLimit)||!lo(he.monthlyCostLimit))&&e.createElement(e.Fragment,null,ro("Daily Cost",V,he.dailyCostLimit||99999999999999,ke,2,11),ro("Monthly Cost",Be,he.monthlyCostLimit||99999999999999,ke,2,11)))})}let Fe=[];for(let ke=0;ke<z.length;ke+=2)Fe.push(z.slice(ke,ke+2));return Fe.map((ke,ce)=>e.createElement(c,{key:ce,flexDirection:"row",width:"100%"},ke.map(he=>{let Le=G[he],Re=0,We=Bn?.models?.[he]||{};for(let Je in We)Re+=We[Je]?.tokens||0;let Et=0,V=($e.resetMode==="Custom"?br:jn)?.models?.[he]||{};for(let Je in V)Et+=V[Je]?.tokens||0;let Be=0;for(let Je in We)Be+=We[Je]?.cost||0;let Se=0;for(let Je in V)Se+=V[Je]?.cost||0;let ve=ke.length===1,rt=ve?H:Math.floor(H/2),Oe=Math.max(5,Math.min(25,rt-36));return e.createElement(c,{key:he,flexDirection:"column",borderStyle:"single",borderColor:r.borderMuted,paddingX:1,width:ve?"100%":"50%"},e.createElement(c,{marginBottom:0},e.createElement(i,{color:r.primary,bold:!0},"\u25C6 ",he)),ro("Daily",Re,Le.tokenLimit||99999999999999,Oe,2,9),ro("Monthly",Et,Le.monthlyTokenLimit||99999999999999,Oe,2,9),(!lo(Le.dailyCostLimit)||!lo(Le.monthlyCostLimit))&&e.createElement(e.Fragment,null,ro("Daily Cost",Be,Le.dailyCostLimit||99999999999999,Oe,2,11),ro("Monthly Cost",Se,Le.monthlyCostLimit||99999999999999,Oe,2,11)))})))})(),J?e.createElement(c,{marginLeft:2,marginTop:1},e.createElement(i,{color:r.textMuted},"Monthly Reset: "),e.createElement(i,{color:r.accent||"magenta",bold:!0},J),te?e.createElement(i,{color:r.textMuted},` ${te}`):null):e.createElement(c,{marginLeft:2,marginTop:1},e.createElement(i,{color:r.textMuted},"Monthly Reset: "),e.createElement(i,{color:r.secondary||"blue",bold:!0},"Rolling 30-Day Window"))):e.createElement(c,{flexDirection:"column",borderStyle:"single",borderColor:r.borderMuted,paddingX:1,width:"100%"},ro("Daily Tokens",d,x,"green"),ro("Monthly Tokens",m,M,"yellow"),(!lo(a)||!lo(C))&&e.createElement(e.Fragment,null,ro("Daily Cost",u,a,"cyan"),ro("Monthly Cost",h,C,"magenta")),J?e.createElement(c,{marginLeft:4,marginTop:1},e.createElement(i,{color:r.textMuted},"Monthly Reset: "),e.createElement(i,{color:r.accent||"magenta",bold:!0},J),te?e.createElement(i,{color:r.textMuted},` ${te}`):null):e.createElement(c,{marginLeft:4,marginTop:1},e.createElement(i,{color:r.textMuted},"Monthly Reset: "),e.createElement(i,{color:r.secondary||"blue",bold:!0},"Rolling 30-Day Window"))))}case"input":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:r.borderMuted,padding:0,width:"100%"},e.createElement(c,{paddingX:1},e.createElement(i,{color:r.text,bold:!0},"DATA CONFIGURATION")),Xo?.note&&e.createElement(c,{paddingX:1,marginBottom:1},e.createElement(i,{color:r.textMuted,italic:!0},Xo.note)),e.createElement(c,{paddingX:1,flexDirection:"row"},e.createElement(i,{color:r.text,bold:!0},Xo?.label," "),e.createElement(Xn,{value:Xo?.value||"",onChange:n=>Jt(o=>({...o,value:n})),onSubmit:async n=>{let{key:o,subKey:d,next:x,onDone:m}=Xo,M={...$e},u={};if(o==="quotas"){let a;d.toLowerCase().includes("costlimit")?a=parseFloat(n)||0:d.toLowerCase().includes("limit")||d==="resetDay"?a=parseInt(n)||0:a=n,d==="resetDay"&&(a=Math.max(1,Math.min(30,a))),M[d]=a,ao(M),u.quotas=M}else if(o==="providerBudgets"){let a=Xo.providerKey,h=d.toLowerCase().includes("limit")?parseInt(n)||0:n,C=M.providerBudgets||{};M.providerBudgets={...C,[a]:{...C[a]||{},[d]:h}},ao(M),u.quotas=M}else if(o==="activeModel")Kt(n),u.activeModel=n;else if(o==="janitorModel")Ye(n),u.janitorModel=n;else if(o==="autoApproveCommands"||o==="autoDisallowCommands"||o==="alwaysAskCommands"){let a={...xe,[o]:n.trim(),sandboxPreset:"Custom"};St(a),u.systemSettings=a}else if(o==="externalDataPath"){let a={...xe,useExternalData:!0,externalDataPath:n.trim()};St(a),u.systemSettings=a,k(h=>[...h,{id:Date.now(),role:"system",text:"[EXTERNAL STORAGE] Flux Flow will use "+n.trim()+" for data after restart."}])}else if(o==="customOpenAIBaseUrl"){let a=n.trim().replace(/\/+$/,""),h={...xe,customOpenAIBaseUrl:a,memory:!1};St(h),u.systemSettings=h;let C=($e.providerTiers||{}).c_openai||"Free",X=eo("c_openai",C)||"";Ue("c_openai"),Kt(X),no(C),u.aiProvider="c_openai",u.activeModel=X,u.apiTier=C;let G=await qo("c_openai")||"";_t(G),Fo(G,{aiProvider:"c_openai",onIDEApproval:ko}),k(z=>[...z,{id:Date.now(),role:"system",text:`\u2726 Custom OpenAI Base URL saved!
|
|
284
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Switched to Custom (OpenAI)
|
|
285
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Endpoint: ${a}${X?`
|
|
286
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: ${X}`:""}
|
|
287
|
-
\u2800`,isMeta:!0}])}else if(o==="imageSettings"){let a=n.trim();if(a.startsWith("sk_")){let h={...Ao,apiKey:a};gr(h),u.imageSettings=h,k(C=>(_(C.length+1),[...C,{id:Date.now(),role:"system",text:"[IMAGE KEY] Custom API key saved successfully.",isMeta:!0}]))}}else if(o==="providerKey"){let a=n.trim(),h=Xo.provider;(h==="Ollama"||h==="9router")&&(a==="LOCAL"||a==="")&&(a="LOCAL",h==="Ollama"&&(St(G=>({...G,ollamaEndpoint:"Local"})),u.systemSettings={...xe,ollamaEndpoint:"Local"}));let C="";if(h==="9router"){let G=await Ys();G.ok||(C=`
|
|
288
|
-
|
|
289
|
-
\x1B[33m\u2726 WARNING: 9router does not appear to be running on ${G.url}.\x1B[39m
|
|
290
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m To start 9router: \x1B[36mnpx 9router\x1B[39m or \x1B[36mnpm i -g 9router && 9router\x1B[39m`)}await Ss(h,a),Ue(h),_t(a),Fo(a,{aiProvider:h,onIDEApproval:ko});let X=($e.providerTiers||{})[h]||"Free",U=eo(h,X);Kt(U),no(X),u.aiProvider=h,u.activeModel=U,u.apiTier=X,(h==="NVIDIA"&&process.env.NVIDIA_BASE_URL||h==="Ollama"||h==="CrofAI"||h==="InferX"||h==="SenseNova"||h==="AIHubMix"||h==="Poolside"||h==="9router"||h==="ExpLabs"||h==="TokenHarbor"||h==="Infron"||h==="APInex")&&(St(G=>({...G,memory:!1})),u.systemSettings={...xe,memory:!1}),k(G=>(_(G.length+1),[...G,{id:Date.now(),role:"system",text:`\u2726 ${h} API Key saved successfully! ${U?`
|
|
291
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: ${U}`:""}${h==="Ollama"&&a==="LOCAL"?`
|
|
292
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Ollama Endpoint automatically switched to Local`:""}${h==="Ollama"||h==="CrofAI"||h==="InferX"||h==="SenseNova"||h==="AIHubMix"||h==="Poolside"||h==="9router"||h==="ExpLabs"||h==="TokenHarbor"||h==="Infron"||h==="APInex"?`
|
|
293
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with ${h}`:""}${h==="NVIDIA"&&process.env.NVIDIA_BASE_URL?`
|
|
294
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available`:""}${C}
|
|
295
|
-
\u2800\u2800`,isMeta:!0}]))}if(x){let a=x(o==="quotas"||o==="providerBudgets"?M:n);Jt(a)}else m?(Ot({...u,apiTier:it,quotas:M,imageSettings:u.imageSettings||Ao}),Jt(null),m(M)):(Ot({...u,apiTier:it,quotas:M,imageSettings:u.imageSettings||Ao}),Jt(null),Q(Xo?.returnView||"settings"))}})),e.createElement(c,{paddingX:1,marginTop:1},e.createElement(i,{color:r.textMuted,dimColor:!0,italic:!0},"(Press Enter to confirm selection)")));case"stats":{let n=vn==="modelBreakdown"||vn==="dailyModelBreakdown",o=vn==="daily"||vn==="dailyModelBreakdown",d=o?Bn:jn,x=o?"TODAY's USAGE":"LAST 30 DAYS USAGE",m=o?"TODAY'S MODEL TOKEN BREAKDOWN":"30-DAY MODEL TOKEN BREAKDOWN",M="Wall Time:",u="Tokens Used:",a="Images Made:",h="Image Credits:",C="Code Changes:",X="Tool Calls:",U=Math.max(4,(l?.rows||W?.rows||24)-15),G=(ce,he,Le,Re,We,Et=0,Lt=!1)=>{let V=l?.columns||W?.columns||80,Be=Math.min(125,V-2),Se=Math.max(20,Be-6),ve=Math.max(5,Se-Et-Le.length-5),rt=he;rt.length>ve&&(rt=rt.substring(0,ve-1)+"\u2026");let Oe=Math.max(2,Se-Et-rt.length-Le.length-2),Je=" "+".".repeat(Oe)+" ",Ct=" ".repeat(Et);return e.createElement(c,{key:ce,width:Se},e.createElement(i,{wrap:"truncate"},e.createElement(i,null,Ct),e.createElement(i,{color:Re,bold:Lt},rt),e.createElement(i,{color:r.textMuted,dimColor:!0},Je),e.createElement(i,{color:We,bold:Lt},Le)))},z=ce=>{let he=Number(ce)||0;return he<=0?"":he<.001?" [<$0.001]":` [$${he.toFixed(he<.01?4:3)}]`},j=ce=>{let he=Number(ce)||0;return he<=0?"":he<.001?"<$0.001":`$${he.toFixed(he<.01?4:3)}`},J=[],te=d?.models;if(!te||Object.keys(te).length===0)J.push(e.createElement(c,{key:"empty",marginTop:1},e.createElement(i,{color:r.textMuted,italic:!0},"No model token usage recorded for ",o?"today":"the last 30 days",".")));else{let ce=(qn||"").trim(),he="",Le="";if(ce.includes(":")){let We=ce.indexOf(":");he=ce.substring(0,We).trim().toLowerCase(),Le=ce.substring(We+1).trim().toLowerCase()}else he=ce.toLowerCase();let Re=Object.entries(te).sort(([We],[Et])=>We.localeCompare(Et,void 0,{sensitivity:"base"})).filter(([We,Et])=>he&&!We.toLowerCase().includes(he)?!1:Le?Object.keys(Et).some(Lt=>Lt.toLowerCase().includes(Le)):!0);Re.length===0?J.push(e.createElement(c,{key:"no-matches",marginTop:1},e.createElement(i,{color:r.textMuted,italic:!0},'No results found matching "',qn,'".'))):Re.forEach(([We,Et],Lt)=>{let V=Object.entries(Et).sort(([Oe],[Je])=>Oe.localeCompare(Je,void 0,{sensitivity:"base"})).filter(([Oe])=>!Le||Oe.toLowerCase().includes(Le));if(V.length===0)return;let Be=V.reduce((Oe,[,Je])=>Oe+(Je.tokens||0),0),Se=V.reduce((Oe,[Je,Ct])=>{if((Ct.cost||0)>0)return Oe+Ct.cost;let re=Ms(We,Je);if(!re)return Oe;let be=(Ct.tokens||0)-(Ct.candidateTokens||0),Pe=Ct.cachedTokens||0,je=Math.max(0,be-Pe),ze=Ct.candidateTokens||0,Ft=je/1e6*re.IN+Pe/1e6*re.CR+ze/1e6*re.OUT;return Oe+Ft},0),ve=d?.providerRequests&&d.providerRequests[We]||0;Lt>0&&J.length>0&&J.push(e.createElement(c,{key:`space-prov-${We}`},e.createElement(i,null," ")));let rt=z(Se);J.push(G(`prov-${We}`,`${We}:`,`${Tt(Be)} (${ve})${rt}`,r.primary,r.text,0,!0)),V.forEach(([Oe,Je],Ct)=>{Ct>0&&J.push(e.createElement(c,{key:`space-mod-${We}-${Oe}`},e.createElement(i,null," ")));let re=Ms(We,Oe),be=(Je.tokens||0)-(Je.candidateTokens||0),Pe=Je.cachedTokens||0,je=Math.max(0,be-Pe),ze=Je.candidateTokens||0,Ft=0,wo=0,Po=0;re&&(Ft=je/1e6*re.IN,wo=Pe/1e6*re.CR,Po=ze/1e6*re.OUT);let jo=(Je.cost||0)>0?Je.cost:Ft+wo+Po,On=z(jo);J.push(G(`mod-${We}-${Oe}`,`\xBB ${Oe}:`,`${Tt(Je.tokens||0)}${On}`,r.secondary,r.text,2,!0));let Ea=z(Ft),Ba=z(wo),va=z(Po);J.push(G(`in-${We}-${Oe}`,"\xBB Input Tokens:",`${Tt(be)}${Ea}`,r.textMuted,r.text,5,!1)),Pe>0&&J.push(G(`cache-${We}-${Oe}`,"\xBB Cached:",`${Tt(Pe)}${Ba}`,r.textMuted,r.text,7,!1)),J.push(G(`out-${We}-${Oe}`,"\xBB Output Tokens:",`${Tt(ze)}${va}`,r.textMuted,r.text,5,!1))})})}let H=J.length,_e=Math.max(0,H-U);Te.current=_e;let Fe=Math.min(aa,_e),ke=J.slice(Fe,Fe+U);return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:r.borderMuted,paddingX:3,paddingY:1,paddingBottom:0,width:Math.min(125,(l?.columns||100)-2)},n?e.createElement(c,{flexDirection:"column"},e.createElement(c,{justifyContent:"space-between"},e.createElement(i,{color:r.text,bold:!0,underline:!0},m),H>U&&e.createElement(i,{color:r.textMuted,dimColor:!0},"[",Fe+1,"-",Math.min(H,Fe+U)," of ",H,"] \u25B2\u25BC")),e.createElement(c,{marginTop:1},e.createElement(i,{color:r.secondary,bold:!0},"Filter (provider:model): "),e.createElement(i,{color:r.text},qn),e.createElement(i,{color:r.primary,bold:!0},"\u258A"),qn.length>0&&e.createElement(i,{color:r.textMuted,dimColor:!0,italic:!0}," (Type to search, Esc/Backspace to clear)")),e.createElement(c,{flexDirection:"column",height:U,marginTop:1},ke)):e.createElement(e.Fragment,null,e.createElement(c,{marginBottom:1},e.createElement(i,{color:r.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:r.secondary},"Session Duration:")),e.createElement(i,{color:r.text},sn(Date.now()-Ks))),ti>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:r.secondary},"Model Requests:")),e.createElement(i,{color:r.text},ti)),e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(i,{color:r.textMuted},"\xBB API Time:")),e.createElement(i,{color:r.text},sn(hr))),e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(i,{color:r.textMuted},"\xBB Tool Time:")),e.createElement(i,{color:r.text},sn(pr)))),ni>0&&e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:r.secondary},"Memory Agent:")),e.createElement(i,{color:r.text},ni)),Zt>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:r.secondary},"Tokens Consumed:")),e.createElement(i,{color:r.text},Tt(Zt))),(Mt?.cost||0)>0&&e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(i,{color:r.textMuted},"\xBB Cost Estimate:")),e.createElement(i,{color:r.success||"green"},j(Mt.cost))),e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(i,{color:r.textMuted},"\xBB Input Tokens:")),e.createElement(i,{color:r.text},Tt(Zt-En))),uo>0&&e.createElement(c,{marginLeft:4},e.createElement(c,{width:21},e.createElement(i,{color:r.textMuted},"\xBB Cached:")),e.createElement(i,{color:r.text},Tt(uo))),En>0&&e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(i,{color:r.textMuted},"\xBB Output Tokens:")),e.createElement(i,{color:r.text},Tt(En)))),bo?.tokens>0&&e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:r.secondary},"Active Context:")),e.createElement(i,{color:r.text},Tt(bo.tokens)," ",(()=>{let he={"16k":16e3,"32k":32e3,"64k":64e3,"128k":128e3,"256k":256e3,"512k":512e3,"1M":1e6}[xe?.contextLength]||256e3,Le=process.env.HIGH_CONTEXT,Re=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1;if(Le&&Le!=="false"){let Lt=parseInt(Le,10);!isNaN(Lt)&&Lt>=0&&Lt<=1e6&&(he=Lt)}(v==="NVIDIA"&&(qe?.includes("gpt")||qe?.includes("qwen")||qe?.includes("medium")||qe.includes("muse"))||v==="Mistral")&&(he=126e3),v==="Google"&&qe?.includes("gemma")&&Re&&(he=16e3);let We=bo.tokens/he*100,Et=We<60?r.text:We<80?r.warning:r.danger;return e.createElement(i,{color:Et,dimColor:!0},"(",We.toFixed(0),"%)")})())),Tr>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:r.secondary},"Images Made:")),e.createElement(i,{color:r.text},Tr)),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:r.secondary},"Image Credits:")),e.createElement(i,{color:r.text},Number(((ai||0)*1e3).toFixed(0))," credits"))),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:r.secondary},"Code Changes (Sess):")),e.createElement(i,{color:r.text},e.createElement(i,{color:r.success||"green"},"+",Mt.linesAdded)," ",e.createElement(i,{color:r.danger||"red"},"-",Mt.linesRemoved))),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:r.secondary},"Tool Calls (Sess):")),e.createElement(i,{color:r.text},Mt.toolSuccess+Mt.toolFailure+Mt.toolDenied," ( "),e.createElement(i,{color:r.success||"green"},"\u2714 ",Mt.toolSuccess),e.createElement(i,{color:r.text}," "),e.createElement(i,{color:r.warning||"yellow"},"\u{1F6C7} ",Mt.toolDenied),e.createElement(i,{color:r.text}," "),e.createElement(i,{color:r.danger||"red"},"\u2718 ",Mt.toolFailure),e.createElement(i,{color:r.text}," )"))),e.createElement(c,{flexDirection:"column",marginTop:1},e.createElement(i,{color:r.text,bold:!0,underline:!0},x),e.createElement(c,{marginTop:1},e.createElement(c,{width:25},e.createElement(i,{color:r.secondary},M)),e.createElement(i,{color:r.text},gi(d?.duration||0))),(d?.agent||0)>0&&e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:r.secondary},"Model Requests:")),e.createElement(i,{color:r.text},d?.agent||0)),(d?.background||0)>0&&e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:r.secondary},"Memory Agent:")),e.createElement(i,{color:r.text},d?.background||0)),(d?.tokens||0)>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:r.secondary},u)),e.createElement(i,{color:r.text},Tt(d?.tokens||0))),(d?.cost||0)>0&&e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(i,{color:r.textMuted},"\xBB Cost Estimate:")),e.createElement(i,{color:r.success||"green"},j(d.cost))),e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(i,{color:r.textMuted},"\xBB Input Tokens:")),e.createElement(i,{color:r.text},Tt((d?.tokens||0)-(d?.candidateTokens||0)))),(d?.cachedTokens||0)>0&&e.createElement(c,{marginLeft:4},e.createElement(c,{width:21},e.createElement(i,{color:r.textMuted},"\xBB Cached:")),e.createElement(i,{color:r.text},Tt(d.cachedTokens))),(d?.candidateTokens||0)>0&&e.createElement(c,{marginLeft:2},e.createElement(c,{width:23},e.createElement(i,{color:r.textMuted},"\xBB Output Tokens:")),e.createElement(i,{color:r.text},Tt(d.candidateTokens)))),(d?.imageCalls?.length||0)>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:r.secondary},a)),e.createElement(i,{color:r.text},d.imageCalls.length)),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:r.secondary},h)),e.createElement(i,{color:r.text},Number(((d.imageCalls.reduce((ce,he)=>ce+he.cost,0)||0)*1e3).toFixed(0))," credits"))),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:r.secondary},C)),e.createElement(i,{color:r.text},e.createElement(i,{color:r.success||"green"},"+",d?.linesAdded||0)," ",e.createElement(i,{color:r.danger||"red"},"-",d?.linesRemoved||0))),e.createElement(c,null,e.createElement(c,{width:25},e.createElement(i,{color:r.secondary},X)),e.createElement(i,{color:r.text},(d?.toolSuccess||0)+(d?.toolFailure||0)+(d?.toolDenied||0)," ( "),e.createElement(i,{color:r.success||"green"},"\u2714 ",d?.toolSuccess||0),e.createElement(i,{color:r.text}," "),e.createElement(i,{color:r.warning||"yellow"},"\u{1F6C7} ",d?.toolDenied||0),e.createElement(i,{color:r.text}," "),e.createElement(i,{color:r.danger||"red"},"\u2718 ",d?.toolFailure||0),e.createElement(i,{color:r.text}," )")))),e.createElement(i,{color:r.textMuted,dimColor:!0,italic:!0},`
|
|
296
|
-
`,"(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:r.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:r.warning||"yellow",bold:!0,underline:!0},"DYNAMIC DIRECTORY AWARENESS"),e.createElement(i,{marginTop:1,color:r.text},"Enabling this keeps the agent aware of filesystem state in real time, but may reduce prompt cache efficiency."),e.createElement(i,{color:r.text},`
|
|
297
|
-
`,"RECOMMENDED SCENARIOS TO TURN ON:"),e.createElement(i,{color:r.textMuted},"\u2022 Repo is small."),e.createElement(i,{color:r.textMuted},"\u2022 The task benefits from real-time filesystem awareness."),e.createElement(i,{color:r.textMuted},"\u2022 Files are often created, renamed, or deleted."),e.createElement(i,{color:r.textMuted},"\u2022 You know exactly what you're signing up for."),e.createElement(i,{color:r.textMuted},"\u2022 You don't have conflicting decisions regarding token bills."),e.createElement(i,{color:r.textMuted},"\u2022 You want to see your wallet crying at 3am."),e.createElement(c,{marginTop:1},e.createElement(wt,{title:"Confirm Intent",theme:xe.theme,items:[{label:"Turn On Dynamic Directory Awareness",value:"on"},{label:"Keep Off (Recommended)",value:"off"}],onSelect:n=>{n.value==="on"&&St(o=>{let d={...o,dynamicDirAwareness:!0};return Ot({systemSettings:d,apiTier:it,quotas:$e}),d}),Q("settings")}})));case"dynamicDirHelp":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:r.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:r.text,bold:!0,underline:!0},"DYNAMIC DIRECTORY AWARENESS \u2014 HELP & EXPLANATION"),e.createElement(i,{color:r.text,bold:!0},`
|
|
298
|
-
`,"OFF (Default):"),e.createElement(i,{color:r.textMuted},"\u2022 Takes a static directory snapshot at conversation/session start and places it in System Context."),e.createElement(i,{color:r.textMuted},"\u2022 Prompt cache remains stable across user turns, saving tokens and money."),e.createElement(i,{color:r.text,bold:!0},`
|
|
299
|
-
`,"ON:"),e.createElement(i,{color:r.textMuted},"\u2022 Rescans and updates the directory's state dynamically on every single user turn."),e.createElement(i,{color:r.textMuted},"\u2022 Provides real-time filesystem awareness if files are continuously created, renamed, or removed."),e.createElement(i,{color:r.textMuted},"\u2022 Changes Prompt Context on each turn, invalidating part of prompt caches and increasing token usage."),e.createElement(c,{marginTop:1},e.createElement(wt,{title:"Actions",theme:xe.theme,items:[{label:"Back to Settings",value:"back"}],onSelect:()=>Q("settings")})));case"autoExecDanger":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:r.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:r.warning||"yellow",bold:!0,underline:!0},"SECURITY WARNING: YOLO MODE"),e.createElement(i,{marginTop:1,color:r.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:r.text,bold:!0},"RISKS INVOLVED:"),e.createElement(i,{color:r.textMuted},"\u2022 The agent may execute destructive commands (rm -rf, etc.) by mistake unless specified in sandbox rules."),e.createElement(i,{color:r.textMuted},"\u2022 Unintended system changes if the agent hallucinates a path or command."),e.createElement(i,{color:r.textMuted},"\u2022 Reduced control over the agent's step-by-step decision making."),e.createElement(c,{marginTop:1},e.createElement(wt,{title:"Confirm Intent",theme:xe.theme,items:[{label:"I know the risk and turning on intentionally",value:"on"},{label:"Keep Off (Recommended)",value:"off"}],onSelect:n=>{n.value==="on"&&St(o=>({...o,autoExec:!0})),Q("settings")}})));case"advanceRollbackDanger":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:r.borderMuted,paddingX:2,paddingY:1,paddingTop:0,width:"100%"},e.createElement(i,{color:r.warning||"yellow",bold:!0},"\u26A0 Emergency Rollback Notice"),e.createElement(i,{marginTop:1,color:r.text},"When enabled, full repo snapshots exist only during active AI turns."),e.createElement(i,{marginTop:1,color:r.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:r.textMuted},"The agent may be able to automatically restore the repo to a safe state."),e.createElement(i,{marginTop:1,color:r.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:r.textMuted},"(Requires Restart to take effect)"),e.createElement(c,{marginTop:1},e.createElement(wt,{title:"Confirm",theme:xe.theme,items:[{label:"I understand and wish to enable",value:"on"},{label:"Keep Off",value:"off"}],onSelect:n=>{n.value==="on"&&St(o=>({...o,advanceRollback:!0})),Q("settings")}})));case"externalDanger":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:r.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:r.warning||"yellow",bold:!0,underline:!0},"SECURITY WARNING: EXTERNAL WORKSPACE ACCESS"),e.createElement(i,{marginTop:1,color:r.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:r.text,bold:!0},"RISKS INVOLVED:"),e.createElement(i,{color:r.textMuted},"\u2022 Access to sensitive system files (SSH keys, Browser data, etc.)"),e.createElement(i,{color:r.textMuted},"\u2022 Potential for accidental or malicious deletion of OS-critical files."),e.createElement(i,{color:r.textMuted},"\u2022 Unauthorized script execution across your entire file system."),e.createElement(c,{marginTop:1},e.createElement(wt,{title:"Confirm Intent",theme:xe.theme,items:[{label:"I know the risk and turning on intentionally",value:"on"},{label:"Keep Off (Recommended)",value:"off"}],onSelect:n=>{n.value==="on"&&St(o=>({...o,allowExternalAccess:!0})),Q("settings")}})));case"doubleDanger":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:r.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:r.danger||"red",bold:!0,underline:!0},"CRITICAL SECURITY WARNING: COMBINED SYSTEM RISK"),e.createElement(i,{marginTop:1,color:r.text},"You are attempting to enable BOTH [YOLO Mode] and [External Workspace Access] simultaneously."),e.createElement(i,{marginTop:1,color:r.danger||"red",bold:!0},"THIS IS NOT RECOMMENDED."),e.createElement(i,{marginTop:1,color:r.text,bold:!0},"THE CRITICAL RISK:"),e.createElement(i,{color:r.textMuted},"The agent will have the power to execute any command across your entire system WITHOUT your approval or supervision."),e.createElement(i,{color:r.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(wt,{title:"Final Confirmation",theme:xe.theme,items:[{label:"I agree knowing the consequences",value:"on"},{label:"Keep Off",value:"off"}],onSelect:n=>{n.value==="on"&&St(o=>({...o,autoExec:!0,allowExternalAccess:!0})),Q("settings")}})));case"key":return e.createElement(wt,{title:"API KEY MANAGEMENT",items:[{label:"Edit Current Key (Update)",value:"edit"},{label:"Remove Current Key (Delete)",value:"remove"},{label:"Cancel",value:"Cancel"}],onSelect:n=>{if(n.value==="edit"){_t(null),Q("chat");let o=mt(2);k(d=>[...d,{id:Date.now(),role:"system",text:`\u2726 Flux waiting for new API Key...
|
|
300
|
-
\u2800`}])}else n.value==="remove"?Q("deleteKey"):Q("chat")}});case"deleteKey":return e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:"grey",paddingX:2,paddingY:1},(()=>{let n=mt(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(wt,{title:"Are you sure?",items:[{label:"YES, CLEAR CREDENTIALS",value:"yes"},{label:"NO, GO BACK",value:"no"}],onSelect:async n=>{if(n.value==="yes"){await Xi(),_t(null),Q("chat");let o=mt(2);k(d=>[...d,{id:Date.now(),role:"system",text:"[CREDENTIAL CLEARED] API Key removed successfully."}])}else Q("key")},theme:xe.theme})));case"exit":return null;case"ask":return e.createElement(c,{width:"100%"},e.createElement(Dl,{question:rn?.question,options:rn?.options,onResolve:n=>{rn?.resolve&&rn.resolve(n),xs(null),Q("chat")},theme:xe.theme}));case"revert":return e.createElement(c,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(Vs,{prompts:Ta,onSelect:async n=>{l&&(l.write("\x1B[2J\x1B[3J\x1B[H"),l.isTTY&&l.write("\x1B[?2004h"));try{let o=await rr.rollbackToBefore(n);if(o.success){let{targetPrompt:d}=o;ul(ft),ws(a=>a+1),No(),Rt.current={completedIndex:0,columns:W.columns,historicalBlocks:[],seenSelections:new Set,chatId:ft,clearKey:dn+1};let x=yt.findLastIndex(a=>a.role==="user"&&a.text&&(a.text.startsWith(d)||a.text.includes(d))),m=[...yt];x!==-1&&(m=yt.slice(0,x)),k(m),_(m.length),T(d),B(d.split(`
|
|
301
|
-
`).length>2);let M=m.filter(a=>!String(a.id).startsWith("welcome")&&(!a.isMeta||a.text&&a.text.includes("Request Cancelled")));await Nn(ft,null,M);let u=mt(2);k(a=>{let h=[...a,{id:"revert-ok-"+Date.now(),role:"system",text:`\u2726 Rollback Successful
|
|
302
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Reverted prompt loaded to input box.
|
|
303
|
-
\u2800`,isMeta:!0}];return _(h.length),h}),Q("chat")}}catch(o){let d=mt(2);k(x=>{let m=[...x,{id:"revert-err-"+Date.now(),role:"system",text:`\u2726 ERROR
|
|
304
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${o.message}
|
|
305
|
-
\u2800`,isMeta:!0}];return _(m.length),m}),Q("chat")}},onClose:()=>Q("chat"),theme:xe.theme}));case"resume":return e.createElement(c,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(Hs,{onSelect:async n=>{let o=await Qo();if(o[n]){if(l.write("\x1B[2J\x1B[3J\x1B[H"),process.stdout.isTTY){let M=o[n]?.name||"",u=M&&!M.startsWith("flow-")&&!M.startsWith("Session ")?M:"FluxFlow | Resumed";process.stdout.write(`\x1B]0;${u}\x07`),process.stdout.write(`\x1B]633;P;TerminalTitle=${u}\x07`)}No(),Lo.current=!0,wr(n);let d=await sr(n);wn.current=Zt-d.total,Cn.current=uo,Sn.current=nn,bn(d.total),yn(0),Mn(0),Wo({tokens:d.context}),Lo.current=!1;let x=[...o[n].messages];x[0]?.text?.includes("\u2591\u2591\u2591\u2588\u2588\u2588")||x.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),k(x),Q("chat"),k(M=>{let u=[...M,{id:"sys-"+Date.now(),role:"system",text:`\u2726 SESSION RESUMED
|
|
306
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${n}
|
|
307
|
-
\u2800`,isMeta:!0}];return _(u.length),u})}},onDelete:async n=>await Pr(n),onClose:()=>Q("chat"),theme:xe.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,`
|
|
308
|
-
`,"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.",`
|
|
309
|
-
|
|
310
|
-
`,"Would you like FluxFlow to automatically add this to your ",fn()," keybindings?"),e.createElement(c,{marginTop:1},e.createElement(wt,{title:"Add Keybinding?",items:[{label:"Yes, configure automatically",value:"yes"},{label:"No, skip",value:"no"}],onSelect:async n=>{n.value==="yes"?await Rr(fn()):zr="\\ + Enter",Q("chat")},theme:xe.theme})));case"memory":return e.createElement(c,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(Gs,{onClose:()=>Q("chat"),theme:xe.theme}));case"parserDownload":return e.createElement(c,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(Ws,{onClose:()=>Q("settings")}));case"profile":return e.createElement(Us,{initialData:Tn,onSave:n=>{Zs(n),k(o=>[...o,{id:Date.now(),role:"system",text:`${n.name.length>0||n.nickname.length>0?`\u2726 Profile Updated${n.name.length>0?`
|
|
311
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Name: ${n.name} `:""}${n.nickname.length>0?`
|
|
312
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Nickname: ${n.nickname}`:""}`:`\u2726 Profile
|
|
313
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Nothing to Update`}
|
|
314
|
-
|
|
315
|
-
\u2726 Custom Instructions
|
|
316
|
-
${n.instructions.length>0?`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${n.instructions.substring(0,30)}${n.instructions.length>30?"...":""}`:"\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No Instructions Provided."}
|
|
317
|
-
\u2800`,isMeta:!0}]),Q("chat")},onCancel:()=>Q("chat"),theme:xe.theme});case"resolution":return e.createElement(c,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(fc,{data:ba,theme:xe.theme,onResolve:n=>{bs(null),Q("chat"),setTimeout(()=>{Ai(n,!0)},500)},onEdit:n=>{bs(null),Q("chat"),T(n)}}));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"},nr(Vo?.args||"{}").path||"Unknown File")),mn()?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 n=nr(Vo?.args||"{}"),o=[],d=new Set;if(Object.keys(n).forEach(M=>{let u=M.match(/^(searchContent|replaceContent|newContent|content_to_replace|content_to_add|TargetContent|ReplacementContent|replacementContent)(\d+)?$/);if(u){let a=u[2]?parseInt(u[2]):1;d.add(a)}}),Array.from(d).sort((M,u)=>M-u).forEach(M=>{let u,a;M===1?(u=n.searchContent1??n.searchContent??n.replaceContent1??n.content_to_replace1??n.replaceContent??n.content_to_replace??n.TargetContent??null,a=n.newContent1??n.content_to_add1??n.newContent??n.content_to_add??n.ReplacementContent??n.replacementContent??null):(u=n[`searchContent${M}`]??n[`replaceContent${M}`]??n[`content_to_replace${M}`]??null,a=n[`newContent${M}`]??n[`content_to_add${M}`]??null),(u!==null||a!==null)&&o.push({replace:u,new:a})}),o.length>0)return e.createElement(c,{flexDirection:"column",marginTop:1},o.map((M,u)=>{let a=M.replace!==null,h=M.new!==null;return e.createElement(c,{key:u,flexDirection:"column",marginTop:u>0?1:0},o.length>1&&e.createElement(i,{color:"gray"},"Block ",u+1,":"),a&&e.createElement(c,null,e.createElement(i,{color:"red",wrap:"anywhere",bold:!0},"- ",M.replace)),h&&e.createElement(c,{marginTop:0},e.createElement(i,{color:"green",wrap:"anywhere",bold:!0},"+ ",M.new.replace(/\[\/n\]?/g,"\\n"))))}));let m=n.content||n.ReplacementContent||n.content_to_add||n.replacementContent||n.newContent||null;return e.createElement(i,{color:"white",wrap:"anywhere"},(m?m.replace(/\[\/n\]?/g,"\\n"):null)||"Updating file content...")})()),e.createElement(c,{marginTop:1},e.createElement(wt,{title:"Action Required",items:[{label:"Accept this time",value:"allow"},{label:"Accept for this session",value:"always"},{label:"Don't accept",value:"deny"}],onSelect:n=>{n.value==="always"&&ma(!0);let o=n.value==="deny"?"deny":"allow";Vo.resolve(o),kn(null),Q("chat")},theme:xe.theme})));case"mode":return e.createElement(wt,{title:"SELECT EXECUTION MODE",items:[{label:`Flux (Dev Toolset Mode) ${I==="Flux"?"\u25CF":""}`,value:"Flux"},{label:`Flow (Chat / Conversation Mode) ${I==="Flow"?"\u25CF":""}`,value:"Flow"},{label:`ICU (Interactive Computer Use) ${I==="ICU"?"\u25CF":""}`,value:"ICU"},{label:`FluxCU (Autonomous Flux Computer Use) ${I==="FluxCU"?"\u25CF":""}`,value:"FluxCU"},{label:"Back",value:"chat"}],theme:xe.theme,onSelect:n=>{if(n.value==="chat"||n.value==="Back"){Q("chat");return}let o=n.value;F(o),De(o==="Flow"?"Fast":"High"),k(d=>(_(d.length+1),[...d,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${js(o)}
|
|
318
|
-
\u2800`,isMeta:!0}])),Q("chat")},onClose:()=>Q("chat")});case"display":return e.createElement(wt,{title:"SELECT ACTIVE DISPLAY FOR COMPUTER USE",items:[{label:`Primary Display (Display 1) ${$===0?"\u25CF":""}`,value:0},{label:`Secondary Display (Display 2) ${$===1?"\u25CF":""}`,value:1},{label:"Back",value:"chat"}],theme:xe.theme,onSelect:n=>{if(n.value==="chat"||n.value==="Back"){Q("chat");return}let o=Number(n.value);L(o),Ot({display:o}).catch(()=>{});let d=o===0?"Primary (Display 1)":"Secondary (Display 2)";k(x=>(_(x.length+1),[...x,{id:Date.now(),role:"system",text:`\u2726 Active Computer Use display set to: ${d}`,isMeta:!0}])),Q("chat")},onClose:()=>Q("chat")});case"updateManager":return e.createElement(wt,{title:"Select Preferred Update Manager",subtitle:"NOTE: If you are unsure about these, go with NPM",items:[{label:"NPM (Standard)",value:"npm"},{label:"PNPM (Recommended)",value:"pnpm"},{label:"BUN (Ultra Fast)",value:"bun"},{label:"YARN (Classic)",value:"yarn"},{label:"Custom Command",value:"custom"},{label:"Back",value:"settings"}],onSelect:n=>{if(n.value==="settings"||n.value==="Back"){Q("settings");return}n.value==="custom"?(Jt({label:"Enter Custom Update Command (Global install recommended):",key:"customUpdateCommand",value:xe.customUpdateCommand,next:o=>(St(d=>({...d,updateManager:"custom",customUpdateCommand:o})),null)}),Q("input")):(St(o=>({...o,updateManager:n.value})),Q("settings"))},theme:xe.theme});case"update":return e.createElement(Ll,{latest:zt,current:To,settings:xe,theme:xe.theme,onClose:()=>Q("chat"),onSuccess:()=>{k(n=>(_(n.length+1),[...n,{id:"update-success-"+Date.now(),role:"system",text:`**[UPDATE COMPLETED]** Flux Flow successfully updated to v${zt}.
|
|
319
|
-
**Restart to see changes.**`,isMeta:!0}])),Q("chat")},onUpdateSettings:n=>{Q("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},nr(Vo?.args||"{}").command||"Unknown Command"))),e.createElement(c,{marginTop:1},e.createElement(wt,{title:"Risk Assessment Required",items:[{label:"Run",value:"allow"},{label:"Deny",value:"deny"}],onSelect:n=>{Vo.resolve(n.value),kn(null),Q("chat")},theme:xe.theme})));default:return e.createElement(c,{flexDirection:"column",marginTop:1,flexShrink:0,width:"100%"},Mi&&Ci&&e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:r.borderMuted,paddingX:2,paddingY:1,width:"100%",marginBottom:1},e.createElement(c,{justifyContent:"space-between",width:"100%"},e.createElement(i,{color:r.text,bold:!0,underline:!0},"INQUIRY RESPONSE"),e.createElement(i,{color:r.textMuted},"[ ESC to Close ]")),e.createElement(c,{marginTop:1,width:"100%"},e.createElement(_r,{text:Ci,columns:W.columns-6,theme:xe.theme}))),ls.filter(n=>n.status==="running").length>0&&e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:r.borderMuted,paddingX:2,paddingY:0,width:"100%",marginBottom:1},e.createElement(c,{justifyContent:"space-between",width:"100%"},e.createElement(i,{color:r.text,bold:!0},"ACTIVE SUBAGENTS")),e.createElement(c,{flexDirection:"column",marginTop:1,width:"100%"},ls.filter(n=>n.status==="running").map(n=>e.createElement(pc,{key:n.id,sa:n,showTPMEstimate:xe.showTPMEstimate})))),er&&e.createElement(c,{flexDirection:"column",borderStyle:"round",borderColor:r.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:r.warning||"yellow",bold:!0},"\u2726 ",er.startsWith("/btw")?"Question Queued":"Steering Hint Queued"))),e.createElement(c,{marginTop:0,paddingLeft:2},e.createElement(i,{color:r.text,bold:!0},"\u2514\u2500 ",er.startsWith("/btw")?er.replace(/^\/btw\s*/,""):er))),e.createElement(c,{paddingX:1,marginBottom:0,justifyContent:"space-between",width:"100%"},e.createElement(c,null,ln?e.createElement(c,{gap:1},e.createElement(ic,null),e.createElement(xr,{text:ln.trim().length>40?`${ln.trim().slice(0,40)}...`:ln.trim(),baseColor:r.textExclusive||r.text,glintColor:r.textMutedExclusive||r.textMuted,speed:60,italic:!0,glintWidth:2,typeSpeed:10}),e.createElement(i,{color:r.textMuted},pi>0?`(${pi.toFixed(0)}s)`:"")):e.createElement(i,{color:r.textMuted,italic:!0},w.length>0&&wi?"Press ESC again to clear input":xa?"Press CTRL + O to expand":process.env.HALLOWEEN_EEGG==="true"?"Listening for shadows...":"Waiting for input...")),e.createElement(c,null,(()=>{let n=ln?.toLowerCase()??"";return Ln&&Date.now()-Rs>15e3&&ls.length===0&&(n.includes("connecting")||n.includes("consulting")||n.includes("working")||n.includes("haunting")||n.includes("queue"))?e.createElement(c,null,e.createElement(xr,{text:"Waiting for API Response",baseColor:r.text,glintColor:r.textMuted,glintWidth:4,speed:100}),e.createElement(i,{color:r.textMuted,dimColor:!0}," \u2503 ")):gs?e.createElement(c,null,e.createElement(xr,{text:gs,baseColor:r.text,glintColor:r.textMuted,italic:!0,speed:85,typeSpeed:15}),e.createElement(i,{color:r.textMuted,dimColor:!0}," \u2503 ")):null})(),e.createElement(xr,{text:It.basename(qe)||(qe.length>1?qe:"Use '/model model-id' to select model"),baseColor:r.text,glintColor:r.textMuted,glintWidth:3,speed:80}),e.createElement(i,{color:r.textMuted},qe.length>0?fe.toLocaleLowerCase().includes("xhigh")?"":` (${fe})`:""),Or>0&&e.createElement(i,{color:r.textMuted}," [",Or," ",Or===1?"file":"files","]"))),e.createElement(c,{flexDirection:"column",width:"100%"},e.createElement(c,{width:"100%",height:1,overflow:"hidden"},e.createElement(i,{color:r.inputBorder},"\u2500".repeat(Math.max(1,W.columns)))),e.createElement(c,{paddingX:1,paddingY:0,width:"100%",flexDirection:"column"},e.createElement(c,{flexDirection:"column",width:"100%"},e.createElement(c,{flexDirection:"row",width:"100%",paddingY:0},e.createElement(c,{flexShrink:0,width:4},e.createElement(i,{color:r.inputPrompt,bold:!0},Ln||Cr?"\u2726 ":" \u276F ")),e.createElement(c,{flexGrow:1},e.createElement(c,{flexGrow:1,position:"relative"},w===""&&e.createElement(c,{position:"absolute",paddingLeft:0},xo&&!zn?e.createElement(i,{color:"yellow"},Ma?" Terminal is waiting for user input. Press TAB to interact":" Press TAB to interact with terminal..."):xo&&zn?e.createElement(i,{color:"yellow",bold:!0}," [ TERMINAL FOCUSED ] Type to interact, press TAB to exit..."):wi===1?e.createElement(i,{color:r.inputPrompt,bold:!0}," Press ESC again to ",w.length>0?"clear input":"revert codebase to checkpoint","..."):e.createElement(i,{color:r.inputPlaceholder},ha?" Press ESC again to cancel the request.":Cr?" Compacting session history, please wait...":Ln?" Enter a prompt to steer the agent.":yt.filter(n=>n.role==="user").length===0?` Send message, @file or /cmd (${ca.shortcut} for newline)`:" Ask Follow-ups")),e.createElement(fl,{key:`input-${S}`,onPasteStateChange:fa,focus:!zn&&!Cr,showCursor:Qe&&!Cr,cursorColor:r.inputText,lastFocusEventTime:Ze.current,value:w,textStyle:{bold:!0,color:r.inputText},columns:W.columns,onChange:n=>{let o=n.replace(/\r\n/g,`
|
|
320
|
-
`).replace(/\r/g,`
|
|
321
|
-
`).replace(/\\\s*\n/g,`
|
|
322
|
-
`);T(o),oe(!1)},onSubmit:Ai,rows:1,maxRows:10,keyBindings:{submit:n=>n.return&&!n.shift&&!n.ctrl,newline:n=>n.return&&n.shift||n.return&&n.ctrl}})))))),e.createElement(c,{width:"100%",height:1,overflow:"hidden"},e.createElement(i,{color:r.inputBorder},"\u2500".repeat(Math.max(1,W.columns))))))}};return e.createElement(c,{flexDirection:"column",width:"100%"},dt?null:me?e.createElement(uc,{width:l?.columns||80,height:l?.rows||24,selectedIndex:Xe,aiProvider:v,theme:xe.theme}):e.createElement(e.Fragment,null,e.createElement(c,{paddingX:1,flexDirection:"column",width:"100%"},e.createElement(sc,{key:`static-${dn}-${ft}-${W.columns}-${xe.theme}`,items:vi.completed},n=>e.createElement(Xr,{key:n.key,block:n,columns:(l?.columns||80)-2,showFullThinking:tn,aiProvider:v,version:To,theme:xe.theme}))),e.createElement(c,{flexDirection:"column",paddingX:1,paddingBottom:0,width:"100%"},(gt==="chat"||["ask","approval","terminalApproval"].includes(gt))&&e.createElement(c,{flexDirection:"column",width:"100%"},vi.active.map(n=>e.createElement(Xr,{key:n.key,block:n,columns:Math.max(20,(l?.columns||80)-2),showFullThinking:tn,aiProvider:v,version:To,theme:xe.theme})),xo&&e.createElement(c,{marginTop:1},e.createElement($r,{command:xo,output:In,isFocused:zn,isPty:Pn,terminalHeight:W.rows,columns:W.columns}))),dt?e.createElement(c,{borderStyle:"double",borderColor:"grey",padding:1,flexShrink:0},e.createElement(i,{color:"white"},"Starting Flux Flow...")):!Nt&&!(v==="c_openai"&&xe.customOpenAIBaseUrl)?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},v==="c_openai"?"CUSTOM BASE URL REQUIRED":"API KEY REQUIRED")),e.createElement(c,{paddingX:1,flexDirection:"column"},nt===0?e.createElement(e.Fragment,null,e.createElement(i,{color:"white"},"Select your Preferred Provider:"),e.createElement(c,{marginTop:1},e.createElement(wt,{searchable:!0,items:[{label:"Google",value:"Google"},{label:"Nvidia",value:"NVIDIA"},{label:"DeepSeek",value:"DeepSeek"},{label:"InferX",value:"InferX"},{label:"SenseNova",value:"SenseNova"},{label:"Poolside",value:"Poolside"},{label:"Experiential Labs",value:"ExpLabs"},{label:"Token Harbor",value:"TokenHarbor"},{label:"Infron",value:"Infron"},{label:"APInex",value:"APInex"},{label:"Ollama",value:"Ollama"},...process.env.ENABLE_9ROUTER==="true"||process.env.ENABLE_9ROUTER===!0?[{label:"9router [Local Proxy]",value:"9router"}]:[],{label:"AIHubMix [Experimental]",value:"AIHubMix"},{label:"Mistral [Experimental]",value:"Mistral"},{label:"OpenRouter [Experimental]",value:"OpenRouter"},{label:"Custom [OpenAI Chat Completion]",value:"c_openai"}],onSelect:n=>{Ue(n.value),At(1)}}))):e.createElement(e.Fragment,null,e.createElement(i,{color:"white"},v==="Ollama"?"Enter Ollama API Key (or type LOCAL to use local host):":v==="c_openai"?"Enter Custom OpenAI Base URL (.../v1):":`Enter your ${v} API Key:`),e.createElement(c,{marginTop:1},e.createElement(i,{color:"gray",bold:!0}," ",">"," "),e.createElement(Xn,{value:Zr,onChange:on,onSubmit:Di,mask:v==="c_openai"?void 0:"*"})))),e.createElement(c,{paddingX:1,marginTop:1},e.createElement(i,{color:"gray",italic:!0},nt===0?"(Use arrows to select and Enter to confirm, ESC to go back)":"(Press Enter to confirm and initialize, ESC to go back)"))):Sa(),g&&e.createElement(c,{borderStyle:"round",borderColor:r.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:r.text},"Press "),e.createElement(i,{color:r.text,bold:!0},"CTRL+C"),e.createElement(i,{color:r.text}," again to exit (",y,"s) \u2022 Press "),e.createElement(i,{color:r.textMuted,bold:!0},"ESC"),e.createElement(i,{color:r.text}," to cancel"))),tt.length>0&&(()=>{let o=pe.current,d=0;for(;d<tt.length;){let U=tt[d],G=U?.cmd||U||"";if(typeof G=="string"&&G.trimStart().startsWith("---"))d++;else break}de<=d?o=0:de<o?o=de:de>=o+5&&(o=de-5+1),o=Math.max(0,Math.min(o,Math.max(0,tt.length-5))),pe.current=o;let x=tt.slice(o,o+5),m=tt.length-(o+x.length),M=tt[0]?.cmd?.startsWith("@")||tt[0]?.cmd?.startsWith("\\@"),u=w.startsWith("/model"),a=w.startsWith("/kill"),h=w.startsWith("/thinking"),C=tt.length,X=Math.min(C,de+1);return e.createElement(c,{flexDirection:"column",width:"100%",marginBottom:1,marginTop:0},e.createElement(c,{paddingX:1,marginBottom:0,justifyContent:"space-between",width:"100%"},e.createElement(c,{flexDirection:"row"},e.createElement(i,{color:r.primary||r.text,bold:!0},M?"WORKSPACE FILES":u?"SAVED MODELS":a?"ACTIVE PROCESSES":h?"THINKING LEVELS":"COMMANDS"),e.createElement(i,{color:r.textMuted}," (",C,")")),e.createElement(c,{flexDirection:"row"},M?e.createElement(i,{color:r.textMuted,italic:!0},"Use #Lstart-Lend for line range \u2022 Tab to select"):e.createElement(i,{color:r.textMuted,italic:!0},"\u2191/\u2193 navigate \u2022 Tab / Enter select \u2022 Esc dismiss"))),e.createElement(c,{width:"100%",height:1,overflow:"hidden"},e.createElement(i,{color:r.borderDim||r.inputBorder||r.textDim},"\u2500".repeat(Math.max(1,W.columns)))),x.slice(0,Er).map((U,G)=>{let j=o+G===de,J=typeof U.cmd=="string"&&U.cmd.trimStart().startsWith("---"),te=U.cmd===eo("Google","Free")&&it!=="Free",H=U.display||(U.cmd&&(U.cmd.startsWith("@[")||U.cmd.startsWith("\\@["))&&U.cmd.endsWith("]")?(()=>{let Fe=(U.cmd.startsWith("\\@[")?U.cmd.slice(3,-1):U.cmd.slice(2,-1)).split(/[\/\\]/);return Fe[Fe.length-1]})():!u&&!a&&U.cmd&&U.cmd.includes("/")?U.cmd.split("/").pop():U.cmd);if(u){let Fe=U.multimodal===!0||Ir(U.cmd||U)?"Vision":"Text Only";return e.createElement(c,{key:U.cmd||G,flexDirection:"row",backgroundColor:j?r.highlightBg:void 0,paddingX:1,height:1,alignItems:"center",justifyContent:"space-between"},e.createElement(c,{flexDirection:"row",alignItems:"center",flexGrow:1,overflow:"hidden"},e.createElement(c,{width:3,flexShrink:0},e.createElement(i,{color:j?r.primary||r.text:r.textMuted,bold:j},j?"\u276F ":" ")),e.createElement(i,{color:J?r.textDim:te?r.textMuted:j&&r.inputText||r.text,bold:j},H)),e.createElement(c,{flexShrink:0,marginLeft:2},e.createElement(i,{color:j?r.text:r.textMuted,italic:!j},Fe)))}return a&&U.rightDesc?e.createElement(c,{key:U.cmd||G,flexDirection:"row",backgroundColor:j?r.highlightBg:void 0,paddingX:1,height:1,alignItems:"center",justifyContent:"space-between"},e.createElement(c,{flexDirection:"row",alignItems:"center",flexGrow:1,overflow:"hidden"},e.createElement(c,{width:3,flexShrink:0},e.createElement(i,{color:j?r.primary||r.text:r.textMuted,bold:j},j?"\u276F ":" ")),e.createElement(i,{color:j&&r.inputText||r.text,bold:j},H)),e.createElement(c,{flexShrink:0,marginLeft:2},e.createElement(i,{color:j?r.text:r.textMuted,italic:!j},U.rightDesc))):e.createElement(c,{key:U.cmd||G,flexDirection:"row",backgroundColor:j?r.highlightBg:void 0,paddingX:1,height:1,alignItems:"center"},e.createElement(c,{width:3,flexShrink:0},e.createElement(i,{color:j?r.primary||r.text:r.textMuted,bold:j},j?"\u276F ":" ")),e.createElement(c,{width:26,flexShrink:0},e.createElement(i,{color:J?r.textDim:te?r.textMuted:j&&r.inputText||r.text,bold:j},H)),e.createElement(c,{flexGrow:1,overflow:"hidden"},e.createElement(i,{color:j?r.text:r.textMuted,italic:!j},U.desc)))}),tt.length>5&&e.createElement(c,{paddingX:1,height:1,justifyContent:"space-between",width:"100%"},e.createElement(i,{color:r.textMuted,dimColor:!0,italic:!0},m>0?`... ${m} more available`:"(End of list)"),e.createElement(i,{color:r.textMuted,dimColor:!0},`${X}/${C}`)))})(),e.createElement(c,{flexShrink:0,width:"100%"},e.createElement(Sl,{mode:I,thinkingLevel:fe,tokens:bo.tokens,tokensTotal:Zl,cachedTokens:Rl,promptTokens:ea,chatId:ft,isMemoryEnabled:xe.memory,apiTier:it,aiProvider:v,activeModel:qe,isProcessing:Ln,lastChunkTime:Rs,theme:xe.theme,wps:rs.current.wps,showTPMEstimate:xe.showTPMEstimate})),gt==="exit"&&(()=>{let n=Date.now()-Ks,o=Mt.toolSuccess+Mt.toolFailure,d=o>0?(Mt.toolSuccess/o*100).toFixed(1):"0.0",x=hr+pr,m=x>0?(hr/x*100).toFixed(1):"0.0",M=x>0?(pr/x*100).toFixed(1):"0.0";return e.createElement(c,{flexDirection:"column",borderStyle:"round",paddingX:3,paddingY:1,borderColor:r.borderMuted,width:Math.min(100,(l?.columns||100)-2),marginTop:0,marginBottom:0},e.createElement(c,{marginBottom:1},e.createElement(i,{bold:!0},ac(r.logoGradient||["blue","purple"])("Agent powering down. Goodbye!"))),e.createElement(c,{flexDirection:"column"},e.createElement(i,{color:r.text,bold:!0,underline:!0},"Interaction Summary"),e.createElement(c,{marginTop:1},e.createElement(c,{width:20},e.createElement(i,{color:r.secondary},"Session ID:")),e.createElement(i,{color:r.text},ft)),e.createElement(c,null,e.createElement(c,{width:20},e.createElement(i,{color:r.secondary},"Tool Calls:")),e.createElement(i,{color:r.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:r.secondary},"Success Rate:")),e.createElement(i,{color:r.text},d,"%")),e.createElement(c,null,e.createElement(c,{width:20},e.createElement(i,{color:r.secondary},"Code Changes:")),e.createElement(i,{color:r.text},e.createElement(i,{color:"green"},"+",Mt.linesAdded)," ",e.createElement(i,{color:"red"},"-",Mt.linesRemoved))),Zt>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:20},e.createElement(i,{color:r.secondary},"Tokens Consumed:")),e.createElement(i,{color:r.text},Tt(Zt))),e.createElement(c,{marginLeft:2},e.createElement(c,{width:18},e.createElement(i,{color:r.textMuted},"\xBB Input Tokens:")),e.createElement(i,{color:r.text},Tt(Zt-En))),uo>0&&e.createElement(c,{marginLeft:4},e.createElement(c,{width:16},e.createElement(i,{color:r.textMuted},"\xBB Cached:")),e.createElement(i,{color:r.text},Tt(uo))),En>0&&e.createElement(c,{marginLeft:2},e.createElement(c,{width:18},e.createElement(i,{color:r.textMuted},"\xBB Output Tokens:")),e.createElement(i,{color:r.text},Tt(En)))),Tr>0&&e.createElement(e.Fragment,null,e.createElement(c,null,e.createElement(c,{width:20},e.createElement(i,{color:r.secondary},"Images Made:")),e.createElement(i,{color:r.text},Tr)),e.createElement(c,null,e.createElement(c,{width:20},e.createElement(i,{color:r.secondary},"Image Credits:")),e.createElement(i,{color:r.text},Number(((ai||0)*1e3).toFixed(0))," credits")))),e.createElement(c,{flexDirection:"column",marginTop:1},e.createElement(i,{color:r.text,bold:!0,underline:!0},"Performance"),e.createElement(c,{marginTop:1},e.createElement(c,{width:20},e.createElement(i,{color:r.secondary},"Wall Time:")),e.createElement(i,{color:r.text},sn(n))),e.createElement(c,null,e.createElement(c,{width:20},e.createElement(i,{color:r.secondary},"Agent Active:")),e.createElement(i,{color:r.text},sn(x))),e.createElement(c,{marginLeft:2},e.createElement(c,{width:18},e.createElement(i,{color:r.textMuted},"\xBB API Time:")),e.createElement(i,{color:r.text},sn(hr)," (",m,"%)")),e.createElement(c,{marginLeft:2},e.createElement(c,{width:18},e.createElement(i,{color:r.textMuted},"\xBB Tool Time:")),e.createElement(i,{color:r.text},sn(pr)," (",M,"%)"))))})())))}export{Ys as check9RouterReachable,Tc as default};
|