fluxflow-cli 4.50.0 → 5.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ARCHITECTURE.md +7 -16
- package/README.md +1 -4
- package/TOOLS.md +0 -9
- package/UI_FEATURES.md +1 -2
- package/dist/chunks/ai-WBRHU7IH.js +1 -0
- package/dist/chunks/app-YYK3S5Y5.js +325 -0
- package/dist/chunks/{auto_completion-5WD4TTIP.js → auto_completion-UG6IEWD2.js} +1 -1
- package/dist/chunks/{chat-BA72I6O3.js → chat-ISCVWNVN.js} +1 -1
- package/dist/chunks/chunk-24LJKH4G.js +847 -0
- package/dist/chunks/chunk-7SGZ66KT.js +44 -0
- package/dist/chunks/chunk-B4UKMX5E.js +1 -0
- package/dist/chunks/{chunk-Z5D4VQSG.js → chunk-EXT42EJZ.js} +1 -1
- package/dist/chunks/{chunk-6JMPGZPV.js → chunk-GBH7XI5A.js} +1 -1
- package/dist/chunks/{chunk-5KSNFTQN.js → chunk-J4J3F6BT.js} +1 -1
- package/dist/chunks/chunk-LQM3JK7N.js +1 -0
- package/dist/chunks/{chunk-ZURGYQ4L.js → chunk-QESQR5GB.js} +1 -1
- package/dist/chunks/chunk-V36DXF56.js +13 -0
- package/dist/chunks/{chunk-TRVRMCHV.js → chunk-ZNO55RNG.js} +1 -1
- package/dist/chunks/{click-F4M4FVLQ.js → click-AWHZCV2E.js} +2 -2
- package/dist/chunks/{computer_action-72ZORSKW.js → computer_action-MO2JR2XH.js} +1 -1
- package/dist/chunks/{custom_openai-BLC4CWOL.js → custom_openai-K554R7Q5.js} +1 -1
- package/dist/chunks/{drag-OT2BJZ4P.js → drag-D2GVPIQB.js} +1 -1
- package/dist/chunks/{generate_image-V4OMOT7Z.js → generate_image-45UQ6P2B.js} +1 -1
- package/dist/chunks/{invoke-L2V4QMJG.js → invoke-DVZUJJV3.js} +2 -2
- package/dist/chunks/{invokeSync-7NWIYBX5.js → invokeSync-NEZGW27B.js} +2 -2
- package/dist/chunks/{key_press-IVB7R7CK.js → key_press-AQNKL6UM.js} +1 -1
- package/dist/chunks/{keyboard_typing-A6VFLI7Q.js → keyboard_typing-QSBPTZJ6.js} +1 -1
- package/dist/chunks/{mistral-YTTOZB2J.js → mistral-ON6RQMK7.js} +1 -1
- package/dist/chunks/{model_config-JTMSQGKH.js → model_config-QRYAVWHF.js} +1 -1
- package/dist/chunks/{nvidia-ON4Q6Q26.js → nvidia-I6DPWP6U.js} +2 -2
- package/dist/chunks/{ollama-DIFOZ4PM.js → ollama-6WSZPCI5.js} +1 -1
- package/dist/chunks/{recapture_screen-TVTRNE7C.js → recapture_screen-PPXYK2YY.js} +1 -1
- package/dist/chunks/{screen_grid-AEHMTXP3.js → screen_grid-3RU324CV.js} +1 -1
- package/dist/chunks/{scroll-KFID5QKZ.js → scroll-TSU6MTGU.js} +1 -1
- package/dist/chunks/search_keyword-DZY4MWV7.js +8 -0
- package/dist/chunks/{secrets-JMSL57D2.js → secrets-TNMLVMST.js} +1 -1
- package/dist/chunks/{secrets_v2-U7JR7ZO6.js → secrets_v2-OBRWR3UT.js} +1 -1
- package/dist/chunks/{settings-3VSVCZDF.js → settings-PUFSRWT3.js} +1 -1
- package/dist/chunks/update_file-TGEB5UWK.js +13 -0
- package/dist/chunks/usage-EBE2OVES.js +1 -0
- package/dist/chunks/{usageServer-4X7T4FDJ.js → usageServer-RTK5N5KE.js} +1 -2
- package/dist/chunks/write_file-O6OF7Z2W.js +32 -0
- package/dist/cli.js +25 -22
- package/dist/model_config.json +2 -30
- package/dist/package.json +2 -2
- package/model_config.json +2 -30
- package/package.json +2 -2
- package/dist/chunks/ai-EWDCEXLL.js +0 -1
- package/dist/chunks/app-C7G3NWAQ.js +0 -333
- package/dist/chunks/chunk-HTOLY3HR.js +0 -1
- package/dist/chunks/chunk-OB2V6ZNC.js +0 -951
- package/dist/chunks/chunk-PACSPBDP.js +0 -1
- package/dist/chunks/chunk-T5CUPXCW.js +0 -13
- package/dist/chunks/chunk-TX3H7HDF.js +0 -44
- package/dist/chunks/search_keyword-666PL7YG.js +0 -8
- package/dist/chunks/update_file-RG5QSLR2.js +0 -13
- package/dist/chunks/usage-AJDMLXTH.js +0 -1
- package/dist/chunks/write_file-AQJXPIUV.js +0 -32
|
@@ -1,333 +0,0 @@
|
|
|
1
|
-
import{a as xa}from"./chunk-UEV335RW.js";import{b as ta,c as oa,d as na}from"./chunk-IHDJDAG3.js";import{c as Yl,e as Rn,f as wo,g as jl}from"./chunk-GM5VNNTU.js";import{A as da,B as yo,D as ua,E as ma,F as fa,a as Vl,b as ut,c as yt,d as Mr,e as di,f as Ql,g as Pn,h as rs,i as ss,j as Jl,r as sa,t as ia,w as la,x as aa,z as ca}from"./chunk-OB2V6ZNC.js";import{a as lo,b as ql,c as zl}from"./chunk-HFTI3R3Q.js";import"./chunk-52STSLCN.js";import{a as ra}from"./chunk-56EJGQU3.js";import"./chunk-4BLSASW6.js";import{a as Vt,b as Lt,d as Xl,e as Pt,f as Gl,j as ai,k as ci,l as Cr,m as Kl,n as Qo}from"./chunk-TX3H7HDF.js";import"./chunk-UIL6OCU4.js";import{a as ea}from"./chunk-YX4X2ZTX.js";import{a as vr,b as Jo,c as On,e as is,f as ui,g as Zl,i as Rl,j as Br}from"./chunk-Z5D4VQSG.js";import{a as Sr}from"./chunk-6EYQQ7GQ.js";import{a as mn}from"./chunk-Y5JU726N.js";import{b as un,c as si}from"./chunk-ZURGYQ4L.js";import{A as Ll,C as Pl,D as Ol,E as Nl,H as Fl,c as Ml,e as ti,g as Sl,k as vl,l as Bl,m as El,n as Dl,o as Il,q as kl,r as Al,u as oi,v as ni,w as ri}from"./chunk-5KSNFTQN.js";import{a as Ul,b as _l,i as Hl,j as os,k as ns,m as Dt,n as Ln,o as li,u as Wl}from"./chunk-T5CUPXCW.js";import{a as $l,b as ii,c as qt}from"./chunk-PACSPBDP.js";import{d as hl,e as ei,f as pl,g as bl,h as wl,i as Tl,j as yl,l as ts,n as dn,o as bo,p as yr,q as Cl}from"./chunk-HTOLY3HR.js";import{c as Rr,d as gl,e as es}from"./chunk-P5HBJA23.js";import{a as ko,b as An,c as $o,d as Zs,e as Rs,k as Tr,y as xl}from"./chunk-26BQ45XP.js";import ki from"os";import e,{useState as R,useEffect as xt,useRef as Ze,useMemo as nr}from"react";import{Box as u,Text as i,useInput as iu,useStdout as lu,Static as au}from"ink";import cu from"ink-spinner";import ft from"fs-extra";import Ct from"path";import{exec as Ko}from"child_process";import{fileURLToPath as du}from"url";import oo,{useState as ls,useEffect as mi,useMemo as Er,useCallback as kc,useRef as Zo}from"react";import{Box as Ac,Text as Ao,useInput as Lc}from"ink";function Pc(t,m){return t.replace(/\t/g," ".repeat(m))}function as(t){return t==null?"":t.replace(/\r\n/g,`
|
|
2
|
-
`).replace(/\r/g,`
|
|
3
|
-
`)}function Nn(t,m,d){let v=t,y=[...m].sort((r,C)=>r.start-C.start),b=0;for(let r of y){let C=r.start-b,w=as(r.text).split(`
|
|
4
|
-
`).length,M=r.text.length,O=(w>3?`[Pasted ${w} lines]`:`[Pasted ${M} chars]`).length,U=C+O;if(t<=C)break;if(t<U){v=r.end;break}else{let D=r.text.length-O;v+=D,b+=D}}return Math.min(v,d.length)}function fi(t,m,d,v,y=[]){let b=(t||"").slice(0,m),r=v(b).length,C=v(t||""),w=[...y].sort((X,_)=>_.start-X.start);for(let X of w){let _=v(t.slice(0,X.start)).length,V=v(X.text),Y=_+V.length,ue=as(X.text).split(`
|
|
5
|
-
`).length,me=X.text.length,le=ue>3?`[Pasted ${ue} lines]`:`[Pasted ${me} chars]`;C=C.slice(0,_)+le+C.slice(Y),r>_&&r<Y?r=_+le.length:r>=Y&&(r=r-(Y-_)+le.length)}let M=C.split(`
|
|
6
|
-
`),O=[],U=0,D=0,P=0,W=!1;for(let X=0;X<M.length;X++){let _=M[X];if(_.length===0){!W&&r===U&&(D=O.length,P=0,W=!0),O.push({text:"",globalStart:Nn(U,y,t),formattedStart:U}),U+=1;continue}let Y=Lt(_,d).split(`
|
|
7
|
-
`),ue=0,me=[];for(let le=0;le<Y.length;le++){let H=Y[le],be=H.trim();if(be.length===0){let Oe=H.length||1;me.push({text:H,start:ue,length:Oe}),ue+=Oe}else{let Oe=_.indexOf(be,ue);if(Oe!==-1){let Ne=ue,tt=le<Y.length-1?Y[le+1].trim():"",Se=_.length;if(tt.length>0){let xe=_.indexOf(tt,Oe+be.length);xe!==-1&&(Se=xe)}me.push({text:_.slice(Ne,Se),start:Ne,length:Se-Ne}),ue=Se}else me.push({text:H,start:ue,length:H.length}),ue+=H.length}}for(let le=0;le<me.length;le++){let H=me[le],be=H.text,Oe=U+H.start,Ne=Oe+H.length;!W&&r>=Oe&&(r<Ne||r===Ne&&le===me.length-1)&&(D=O.length,P=r-Oe,W=!0),O.push({text:be,globalStart:Nn(Oe,y,t),formattedStart:Oe})}U+=_.length+1}return W||(O.length===0?O.push({text:"",globalStart:0,formattedStart:0}):C.endsWith(`
|
|
8
|
-
`)?(O.push({text:"",globalStart:Nn(U,y,t),formattedStart:U}),D=O.length-1,P=0):(D=O.length-1,P=O[D].text.length)),{visualLines:O,cursorLine:D,cursorCol:P}}var Oc=({value:t,rows:m,maxRows:d,highlightStyle:v,textStyle:y,placeholder:b="",mask:r,showCursor:C=!0,focus:w=!0,tabSize:M=4,cursorIndex:O=0,highlight:U,columns:D=80,pasteBlocks:P=[],cursorColor:W})=>{let X=Zo(0),_=Er(()=>Math.max(20,D-10),[D]),V=kc((Xe,Pe=!1)=>{let Ce=as(Xe);if(!Pe&&r)return Ce.replace(/[^\n]/g,r);let J=Pc(Ce,M);return Pe?J:J.replace(/@\[(.*?)\]/g,(fe,we)=>{let ee=we.indexOf("#"),he=we.indexOf(":L"),j=we,Ge="";ee!==-1?(j=we.slice(0,ee),Ge=we.slice(ee)):he!==-1&&(j=we.slice(0,he),Ge=we.slice(he));let $e=j.replace(/\\/g,"/"),Tt=(process.cwd()||"").replace(/\\/g,"/");Tt&&$e.toLowerCase().startsWith(Tt.toLowerCase()+"/")?$e=$e.slice(Tt.length+1):$e.startsWith("./")&&($e=$e.slice(2));let it=$e.split("/");return`[${it[it.length-1]}${Ge}]`})},[M,r]),{visualLines:Y,cursorLine:ue,cursorCol:me}=Er(()=>fi(t,O,_,V,P),[t,O,_,V,P]),le=Y.length,H=Er(()=>Math.max(m??d??1,Math.min(d??m??1,le)),[m,d,le]),be=ue+1,Oe=X.current+H,Ne=X.current;be<=X.current?Ne=Math.max(0,be-1):be>Oe?Ne=be-H:le&&(le<H?Ne=0:le<Oe&&(Ne=le-H)),X.current=Ne;let tt=Er(()=>Y.slice(Ne,Ne+H),[Y,Ne,H]),[Se,xe]=ls(!0);mi(()=>{if(xe(!0),!w||!C)return;let Xe=setInterval(()=>{xe(Pe=>!Pe)},530);return()=>clearInterval(Xe)},[w,C,t,O]);let Me=Er(()=>({...y,color:C&&w&&Se?W||"white":void 0,bold:C&&w&&Se,inverse:C&&w&&Se}),[y,C,w,Se,W]),St=(Xe,Pe,Ce,J)=>{if(!Xe){let j=b&&t.length===0?V(b,!0):"";if(Pe){let Ge=j[0]||" ",$e=j.slice(1);return oo.createElement(Ao,null,oo.createElement(Ao,{...J},Ge),oo.createElement(Ao,{color:"gray",dimColor:!0},$e))}return oo.createElement(Ao,{color:"gray",dimColor:!0},j||" ")}let fe=/(\[Pasted \d+ (?:lines|chars)\])/g,we=Xe.split(fe),ee=0,he=[];for(let j=0;j<we.length;j++){let Ge=we[j];if(Ge==="")continue;let $e=Ge.match(/^\[Pasted \d+ (?:lines|chars)\]$/),Tt=Ge.length,it=ee+Tt;if(Pe&&Ce>=ee&&Ce<it){let bt=Ce-ee,nt=Ge.slice(0,bt),ze=Ge[bt]||" ",ae=Ge.slice(bt+1);he.push(oo.createElement(Ao,{key:j},oo.createElement(Ao,{color:$e?"magenta":void 0},nt),oo.createElement(Ao,{...J},ze),oo.createElement(Ao,{color:$e?"magenta":void 0},ae)))}else he.push(oo.createElement(Ao,{key:j,color:$e?"magenta":void 0},Ge));ee=it}return Pe&&Ce>=Xe.length&&he.push(oo.createElement(Ao,{key:"cursor-end",...J}," ")),oo.createElement(oo.Fragment,null,he)};return oo.createElement(Ac,{height:H,width:_+1,overflow:"hidden",flexDirection:"column",flexGrow:0,flexShrink:0},tt.map((Xe,Pe)=>{let Ce=Ne+Pe,J=Ce===ue&&w&&C;return oo.createElement(Ao,{key:Ce,...y,wrap:"truncate"},St(Xe.text,J,me,Me))}))},ga=({value:t,onChange:m,onSubmit:d,keyBindings:v,showCursor:y=!0,highlightPastedText:b=!1,focus:r=!0,columns:C=80,useCustomInput:w=(_,V)=>Lc(_,{isActive:V}),onPasteStateChange:M,cursorColor:O,historyEnabled:U=!1,isBrowsingHistory:D=!1,onHistoryPrev:P,onHistoryNext:W,...X})=>{let[_,V]=ls(t.length),[Y,ue]=ls(0),[me,le]=ls([]),H=Zo(t.length),be=Zo(t),Oe=Zo(0),Ne=Zo([]),tt=Zo(""),Se=Zo(-1),xe=Zo(null),Me=Zo(0);H.current=_,be.current=t,Oe.current=Y,Ne.current=me,mi(()=>{H.current>t.length&&(H.current=t.length,V(t.length)),t?le(Pe=>Pe.filter(Ce=>Ce.end<=t.length&&Ce.start<=t.length)):(le([]),ue(0))},[t]),mi(()=>{M?.(me.length>0)},[me,M]);let St=()=>{let Pe=tt.current,Ce=Se.current,J=Ce+Pe.length,fe=be.current,we=fe.slice(0,Ce)+Pe+fe.slice(Ce);m(we),H.current=J,V(J),ue(Pe.length>1?Pe.length:0);let ee=as(Pe).split(`
|
|
9
|
-
`).length,he=Pe.length;if(he>50&&(ee>3||ee<=3&&he>200)){let j={start:Ce,end:J,text:Pe};le(Ge=>{let $e=Pe.length;return[...Ge.map(it=>Ce<=it.start?{...it,start:it.start+$e,end:it.end+$e}:it),j]})}tt.current="",Se.current=-1,xe.current=null},Xe=()=>{xe.current&&(clearTimeout(xe.current),St())};return w((Pe,Ce)=>{if(Pe==="\x1B[I"||Pe==="\x1B[O"||Pe==="[I"||Pe==="[O")return;let J=Pe,fe=!1,we=!1;J&&typeof J=="string"&&(J.includes("\x1B[200~")&&(fe=!0,J=J.replace(/\x1b\[200~/g,"")),J.includes("\x1B[201~")&&(we=!0,J=J.replace(/\x1b\[201~/g,"")));let ee=H.current,he=be.current,j=Ne.current,Ge=Math.max(20,C-10),$e=(ae,De)=>{if(j.length===0)return;let ct=j.map(dt=>ae<=dt.start?{...dt,start:dt.start+De,end:dt.end+De}:ae>dt.start&&ae<dt.end?null:dt).filter(Boolean);le(ct)},Tt=ae=>{for(let De of j)if(ae>De.start&&ae<De.end)return De.start;return ae};if(Ce.ctrl&&(J==="o"||J==="")){le([]);return}if(Ce.ctrl&&(J.toLowerCase()==="r"||J===""||J===""))return;if(Ce.upArrow||Ce.downArrow||Ce.leftArrow||Ce.rightArrow){Xe();let ae=Date.now();if(ae-Me.current<33)return;Me.current=ae}let bt=v?.submit??(ae=>ae.return&&ae.ctrl),nt=v?.newline??(ae=>ae.return);if(bt(Ce)){Xe(),d?.(he);return}else if(nt(Ce)){Xe(),$e(ee,1);let ae=he.slice(0,ee)+`
|
|
10
|
-
`+he.slice(ee);m(ae),H.current=ee+1,V(ee+1),ue(0);return}if(Ce.tab||Ce.shift&&Ce.tab||Ce.ctrl&&J==="c")return;let ze=ae=>ae;if(Ce.upArrow||Ce.downArrow){if(Xe(),U){if(Ce.upArrow&&(he===""||D)){P?.();return}if(Ce.downArrow&&D){W?.();return}}if(y){let{visualLines:ae,cursorLine:De,cursorCol:ct}=fi(he,ee,Ge,ze,j),dt=Ce.upArrow?De-1:De+1;if(dt>=0&&dt<ae.length){let We=ae[dt],Et=Math.min(ct,We.text.length),Ke=We.formattedStart+Et,co=Nn(Ke,j,he);co=Tt(co),H.current=co,V(co),ue(0)}else if(Ce.upArrow&&De===0)H.current=0,V(0),ue(0);else if(Ce.downArrow&&De===ae.length-1){let We=ae[ae.length-1],Et=We.formattedStart+We.text.length,Ke=Nn(Et,j,he);Ke=Tt(Ke),H.current=Ke,V(Ke),ue(0)}}}else if(Ce.leftArrow){if(Xe(),y){let ae=Math.max(0,ee-1),De=j.find(ct=>ee===ct.end);De&&(ae=De.start),H.current=ae,V(ae),ue(0)}}else if(Ce.rightArrow){if(Xe(),y){let ae=Math.min(he.length,ee+1),De=j.find(ct=>ee===ct.start);De&&(ae=De.end),H.current=ae,V(ae),ue(0)}}else if(Ce.backspace){Xe();let ae=j.findIndex(De=>ee===De.end);if(ae!==-1){let De=j[ae],ct=-(De.end-De.start),dt=he.slice(0,De.start)+he.slice(De.end);m(dt),H.current=De.start,V(De.start),ue(0);let We=j.filter((Et,Ke)=>Ke!==ae).map(Et=>Et.start>=De.end?{...Et,start:Et.start+ct,end:Et.end+ct}:Et);le(We)}else if(ee>0){$e(ee-1,-1);let De=he.slice(0,ee-1)+he.slice(ee);m(De),H.current=ee-1,V(ee-1),ue(0)}}else if(Ce.delete){Xe();let ae=j.findIndex(De=>ee===De.start);if(ae!==-1){let De=j[ae],ct=-(De.end-De.start),dt=he.slice(0,De.start)+he.slice(De.end);m(dt),ue(0);let We=j.filter((Et,Ke)=>Ke!==ae).map(Et=>Et.start>=De.end?{...Et,start:Et.start+ct,end:Et.end+ct}:Et);le(We)}else if($e(ee,-1),ee<he.length){let De=he.slice(0,ee)+he.slice(ee+1);m(De),ue(0)}}else if(Ce.home||Ce.end){if(Xe(),y){let{visualLines:ae,cursorLine:De}=fi(he,ee,Ge,ze,j),ct=ae[De];if(ct){let dt;Ce.home?dt=Nn(ct.formattedStart,j,he):Ce.end&&(dt=Nn(ct.formattedStart+ct.text.length,j,he)),dt=Tt(dt),H.current=dt,V(dt),ue(0)}}}else if(J!==""||fe||we)if(fe||we||J.length>1||xe.current!==null)xe.current?(clearTimeout(xe.current),tt.current+=J):(Se.current=ee,tt.current=J),we?(xe.current=null,St()):xe.current=setTimeout(()=>{St()},80);else{$e(ee,J.length);let De=he.slice(0,ee)+J+he.slice(ee);m(De);let ct=ee+J.length;H.current=ct,V(ct),ue(0)}},r),oo.createElement(Oc,{...X,value:t,cursorIndex:_,showCursor:y,focus:r,columns:C,pasteBlocks:me,cursorColor:O})};import rr from"ink-text-input";import"ink-select-input";import l from"react";import{Box as I,Text as de}from"ink";import Wt,{useState as ha,useEffect as Nc}from"react";import{Box as Ro,Text as Lo,useInput as Fc}from"ink";var cs=Wt.memo(({command:t,output:m,completed:d=!1,isFocused:v=!1,columns:y=80,isPty:b=!1,terminalHeight:r=24,theme:C="Dark"})=>{let w=ut(C),O=(J=>{if(!J)return"";let fe=[[]],we=0,ee=0,he="",j=/\x1b\[([0-9;]*?)([a-zA-Z])/g,Ge=0,$e,Tt=bt=>{for(let nt=0;nt<bt.length;nt++){let ze=bt[nt];if(ze===`
|
|
11
|
-
`)for(we++,ee=0;we>=fe.length;)fe.push([]);else if(ze==="\r")ee=0;else{for(;we>=fe.length;)fe.push([]);let ae=fe[we];for(;ee>ae.length;)ae.push({char:" ",style:""});ae[ee]={char:ze,style:he},ee++}}};for(;($e=j.exec(J))!==null;){Tt(J.substring(Ge,$e.index));let bt=$e[1],nt=$e[2],ze=bt?bt.split(";").map(Number):[];if(nt==="A"){let ae=ze[0]||1;we=Math.max(0,we-ae)}else if(nt==="B"){let ae=ze[0]||1;for(we=we+ae;we>=fe.length;)fe.push([])}else if(nt==="C"){let ae=ze[0]||1;ee=ee+ae}else if(nt==="D"){let ae=ze[0]||1;ee=Math.max(0,ee-ae)}else if(nt==="G"){let ae=(ze[0]||1)-1;ee=Math.max(0,ae)}else if(nt==="H"||nt==="f"){let ae=(ze[0]||1)-1,De=(ze[1]||1)-1;for(we=Math.max(0,ae),ee=Math.max(0,De);we>=fe.length;)fe.push([])}else if(nt==="K"){let ae=ze[0]||0;if(we<fe.length){let De=fe[we];if(ae===0)De.length=ee;else if(ae===1)for(let ct=0;ct<ee&&ct<De.length;ct++)De[ct]={char:" ",style:""};else ae===2&&(De.length=0)}}else if(nt==="J"){let ae=ze[0]||0;(ae===2||ae===3)&&(fe.length=0,fe.push([]),we=0,ee=0)}else if(nt==="m"){let ae=$e[0];ae==="\x1B[0m"?he="":he=ae}Ge=j.lastIndex}Tt(J.substring(Ge));let it=fe.map(bt=>{let nt="",ze="";for(let ae=0;ae<bt.length;ae++){let De=bt[ae]||{char:" ",style:""};De.style!==ze&&(ze&&(nt+="\x1B[0m"),nt+=De.style,ze=De.style),nt+=De.char}return ze&&(nt+="\x1B[0m"),nt});for(;it.length>0&&it[it.length-1]==="";)it.pop();return it.join(`
|
|
12
|
-
`)})(m).replace(/\n{3,}/g,`
|
|
13
|
-
|
|
14
|
-
`),U=Math.max(10,(y||80)-6),D=O?O.split(`
|
|
15
|
-
`).flatMap(J=>J?Lt(J,U).split(`
|
|
16
|
-
`):[""]):[],[P,W]=ha(!1),[X,_]=ha(0);Nc(()=>{v||_(0)},[v]);let V=r&&r>0?r:process.stdout.rows||24,Y=V<=24,me=Math.max(1,V-(Y?11:14)),le=V<=16?4:V<=22?5:V<=28?6:10,H=Math.min(le,me),be=D.length>H,Oe=Math.max(0,D.length-H);Fc((J,fe)=>{if(!v)return;let we=fe.pageUp||J==="\x1B[5~"||J==="[5~",ee=fe.pageDown||J==="\x1B[6~"||J==="[6~";fe.ctrl&&(J==="o"||J==="")?(W(he=>!he),_(0)):we?_(he=>Math.min(Oe,he+5)):ee&&_(he=>Math.max(0,he-5))},{isActive:v});let Ne;if(!be||P)Ne=D;else{let J=Math.max(0,D.length-H-X),fe=J+H;Ne=D.slice(J,fe)}let tt=(Ne||[]).join(`
|
|
17
|
-
`).trim(),Se=(Ne||[]).join(`
|
|
18
|
-
`),xe=be&&!P?Math.max(0,D.length-H-X):0,Me=be&&!P?X:0,St=d?"\u{1F3C1} FINISHED: ":"\u26A1 EXECUTING: ",Xe=Math.max(10,(y||80)-(b?24:14)),Pe=Lt((t||"").replace(/\r?\n/g," ").trim(),Xe).split(`
|
|
19
|
-
`),Ce=(t||"").replace(/\r?\n/g," ").trim();return Pe.length>1&&(Ce=Pe[0].length>3?Pe[0].slice(0,-3)+"...":Pe[0]+"..."),Wt.createElement(Ro,{flexDirection:"column",borderStyle:v?"double":"single",borderLeft:!1,borderRight:!1,borderTop:!0,borderBottom:!0,borderColor:w.codeBorder,paddingLeft:2,paddingRight:0,paddingTop:Y?0:1,paddingBottom:1,marginY:Y?0:1,width:y-2},Wt.createElement(Ro,{marginBottom:Y?0:1,justifyContent:"space-between",width:"100%"},Wt.createElement(Ro,{flexShrink:1,paddingRight:2},Wt.createElement(Lo,null,Wt.createElement(Lo,{color:w.text,bold:!0},St),Wt.createElement(Lo,{color:w.text},Ce))),b&&Wt.createElement(Ro,{flexShrink:0,paddingX:1},Wt.createElement(Lo,{color:"green",bold:!0},"ADVANCE"))),tt?Wt.createElement(Ro,{flexDirection:"column",marginTop:0,backgroundColor:b?void 0:w.codeBg,paddingX:1,width:"100%"},xe>0&&Wt.createElement(Ro,{marginBottom:0},Wt.createElement(Lo,{color:"magenta"},"\u25B2 ...",xe," lines above (Use PageUp to scroll)...")),Wt.createElement(Lo,{color:w.text},Se),Me>0&&Wt.createElement(Ro,{marginTop:0},Wt.createElement(Lo,{color:"magenta"},"\u25BC ...",Me," lines below (Use PageDown to scroll)..."))):!d&&Wt.createElement(Ro,{marginTop:Y?0:1,backgroundColor:b?void 0:w.codeBg,paddingX:1,width:"100%"},Wt.createElement(Lo,{color:w.textMuted,italic:!0},"Waiting for output...")),Wt.createElement(Ro,{justifyContent:"space-between",marginTop:Y?0:1},d?Wt.createElement(Lo,{color:w.textMuted,italic:!0},v?"Use PgUp/PgDn to scroll \u2022 Ctrl+O to expand/collapse \u2022 TAB to unfocus.":"Press TAB to focus & scroll."):Wt.createElement(Lo,{color:w.textMuted,italic:!0},v?"Use PgUp/PgDn to scroll \u2022 Ctrl+O to expand \u2022 TAB to unfocus \u2022 CTRL+C to stop.":"Press TAB to focus \u2022 CTRL+C to terminate."),Wt.createElement(Lo,{color:w.textMuted,bold:!0},d?v?"\u25CF ARCHIVED (FOCUSED) ":"\u25CF ARCHIVED ":v?"\u25B6 TERMINAL FOCUSED ":"\u25CF LIVE (Press TAB to focus) ")))});import{diffWordsWithSpace as $c}from"diff";var Dr=null,wa=t=>{Dr=t!==!1},Ta=()=>{if(Dr===null)try{Dr=es(An,{})?.systemSettings?.preserveThinking!==!1}catch{Dr=!0}return Dr},pa=(t,m,d)=>t,Uc=(t,m=80)=>{if(!t)return null;let d=t.replaceAll(" "," "),v=m-10,y=d.trim();if(!y.includes("```"))return l.createElement(I,{width:"100%",flexDirection:"column"},l.createElement(tr,{text:y,color:"#969696",columns:v,italic:!0}));let b=y.split(/(```\w*\n?[\s\S]*?(?:```|$))/g);return l.createElement(I,{width:"100%",flexDirection:"column"},b.map((r,C)=>{if(r.startsWith("```")){let M=r.match(/```(\w*)\n?([\s\S]*?)(?:```|$)/),O=M?M[2]:r.replace(/^```\w*\n?/,"").replace(/```$/,""),U=Lt(O.trimEnd(),v);return l.createElement(I,{key:C,flexDirection:"column",width:"100%"},U.split(`
|
|
20
|
-
`).map((D,P)=>l.createElement(de,{key:P,color:"cyan"},D)))}let w=r;return C>0&&(w=w.replace(/^[\r\n]+/,"")),C<b.length-1&&(w=w.replace(/[\r\n]+$/,"")),w?l.createElement(tr,{key:C,text:w,color:"gray",columns:v,italic:!0}):null}))},_c=/(```[\s\S]*?```|`[^`\r\n]+`|@\[.*?\]|\*\*.*?\*\*|\*.*?\*|\\\(.*?\\\)|\\\[.*?\\\]|\$.*?\$|\[.*?\]\s*\(.*?\)|\[[^\x1b\[\]\r\n]+\]\s*\[(?:https?:\/\/[^\s\]]+|#[^\s\]]+)\]|https?:\/\/[^\s)]+)/g;var Hc=/\\frac\s*\{([^{}]*)\}\s*\{([^{}]*)\}/g,Wc=/(\\(?:mathbf|textbf|textit|underline|texttt)\{[^{}]*\})/g,Xc=/^(#{1,6})\s+(.*)/,Gc=/\\multiply|\\mul|\\times/g,Kc=/\\div/g,Vc=/\\cdot/g,Yc=/\\infty/g,jc=/\\pm/g,qc=/\\leq/g,zc=/\\geq/g,Qc=/\\neq/g,Jc=/\\sqrt\s*\{([^}]+)\}/g,Zc=/\\sqrt\s*(\w+|\d+)/g,Rc=/\\alpha/g,ed=/\\beta/g,td=/\\theta/g,od=/\\pi/g,nd=/\\approx/g,rd=/\\Delta/g,sd=/\\sigma/g,id=/\\sum/g,ld=/\\prod/g,ad=/\\rightarrow|\\to/g,cd=/\\left\b|\\right\b/g,dd=/\\left\(|\\right\)/g,ud=/\\left\[|\\right\]/g,md=/\\\{|\\\}/g,fd=/\\text\s*\{([^}]+)\}/g,xd=/\\text\s+(\w+)/g,gd=/\\%/g,hd=/\\\(|\\\)/g,pd=/\\\[|\\\]/g,bd=/@\[(.*?)\]/g,ba=/:L/gi,wd=/\[(.*?)\]\s*\((.*?)\)/,Td=/\[([^\x1b\[\]\r\n]+)\]\s*\[(https?:\/\/[^\s\]]+|#[^\s\]]+)\]/,yd=/\\(\w+)\{([^{}]*)\}/,Cd=t=>t.replace(hd,m=>m.includes("(")?"(":")").replace(pd,m=>m.includes("[")?"[":"]").replace(Gc,"\xD7").replace(Kc,"\xF7").replace(Vc,"\u22C5").replace(Yc,"\u221E").replace(jc,"\xB1").replace(qc,"\u2264").replace(zc,"\u2265").replace(Qc,"\u2260").replace(Jc,"\u221A($1)").replace(Zc,"\u221A($1)").replace(Rc,"\u03B1").replace(ed,"\u03B2").replace(td,"\u03B8").replace(od,"\u03C0").replace(nd,"\u2248").replace(rd,"\u0394").replace(sd,"\u03C3").replace(id,"\u03A3").replace(ld,"\u03A0").replace(ad,"\u2192").replace(cd,"").replace(dd,m=>m.includes("left")?"(":")").replace(ud,m=>m.includes("left")?"[":"]").replace(md,m=>m.includes("{")?"{":"}").replace(fd,"$1").replace(xd,"$1").replace(gd,"%"),Md=/\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/,Sd=[/((?<=\binclude\s+)(?:<[^>]+>|"[^"]+"))/.source,/((?<=\b(?:from|import|require\s*\(\s*)\s*)(?:'(?:[^'\\]|\\.)*'|"(?:[^"\\]|\\.)*"))/.source,/(\/\/.*|#.*)/.source,/("(?:\\.|[^"\\])*"|'(?:\\.|[^'\\])*'|`(?:\\.|[^\`\\])*`)/.source,Md.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],xi=new RegExp(Sd.join("|"),"g"),er=new Map,vd=1e3,Bd=(t,m)=>{if(!t)return[];let d=`${m}:${t}`;if(er.has(d))return er.get(d);let v=0,y=[],b;for(xi.lastIndex=0;(b=xi.exec(t))!==null;){let r=b[0],C=b.index;C>v&&y.push({text:Vt(t.substring(v,C))});let w,M=!1;b[1]||b[2]?w="#ce9178":b[3]?w="#9ece6a":b[4]?w="#fcfca4":b[5]?(w="#ff7b72",M=!0):b[6]?w="#b392f0":(b[7]||b[8])&&(w="#ff9e64"),y.push({text:Vt(r),color:w,bold:M}),v=xi.lastIndex}if(v<t.length&&y.push({text:Vt(t.substring(v))}),er.size>=vd){let r=er.keys().next().value;er.delete(r)}return er.set(d,y),y},Bt=(t,m,d=void 0,v=void 0)=>{if(!t)return l.createElement(de,{backgroundColor:v}," ");let y=Bd(t,m);return l.createElement(de,{color:d,backgroundColor:v},y.map((b,r)=>l.createElement(de,{key:r,color:b.color||d,backgroundColor:v,bold:b.bold},b.text)))},gi=(t,m)=>{if(!t)return null;let d=t.replace(Hc,"($1/$2)");d=Cd(d);let v=d.split(Wc);return l.createElement(l.Fragment,{key:m},v.map((y,b)=>{if(y.startsWith("\\")){let r=y.match(yd);if(r){let C=r[1],w=r[2];return l.createElement(de,{key:b,bold:C==="mathbf"||C==="textbf",italic:C==="textit",underline:C==="underline",color:C==="texttt"?"cyan":void 0},w)}}return y}))},no=l.memo(({text:t,color:m,italic:d,theme:v="Dark"})=>{if(!t)return null;let y=t.replaceAll(" "," "),b=ut(v),r=m||b.text,C=b.codeText||b.logoGradient&&b.logoGradient[0]||b.info||b.secondary||"cyan",w=y.split(_c);return l.createElement(de,{color:r,wrap:"anywhere",italic:d},w.map((M,O)=>{if(!M)return null;if(M.startsWith("```")&&M.endsWith("```")){let U=M.slice(3,-3);return l.createElement(de,{key:O,color:C},U)}if(M.startsWith("**")&&M.endsWith("**"))return l.createElement(de,{key:O,bold:!0,color:r},l.createElement(no,{text:M.slice(2,-2),color:r,theme:v}));if(M.startsWith("*")&&M.endsWith("*"))return l.createElement(de,{key:O,italic:!0,color:r},l.createElement(no,{text:M.slice(1,-1),color:r,italic:d,theme:v}));if(M.startsWith("`"))if(M.endsWith("`")&&M.length>1){let U=M.slice(1,-1),D=U.replace(bd,(W,X)=>X.split("/").pop().split("\\").pop().replace(ba,"#L")),P=U.includes("@[");return l.createElement(de,{key:O,color:C,bold:P},D)}else return l.createElement(de,{key:O,color:C},M.slice(1));if(M.startsWith("@[")&&M.endsWith("]")){let D=M.slice(2,-1).split("/").pop().split("\\").pop().replace(ba,"#L");return l.createElement(de,{key:O,color:C,bold:!0},D)}if(M.startsWith("\\(")&&M.endsWith("\\)")||M.startsWith("\\[")&&M.endsWith("\\]")){let U=M.slice(2,-2);return l.createElement(de,{key:O,color:"yellow"},gi(U,O))}if(M.startsWith("$")&&M.endsWith("$")){let U=M.slice(1,-1);return l.createElement(de,{key:O,color:"yellow"},gi(U,O))}if(M.startsWith("[")&&(M.includes("](")||M.includes("] ("))){let U=M.match(wd);if(U){let D=U[1]||U[2],W=`\x1B]8;;${U[2]||U[1]}\x07${D}\x1B]8;;\x07`;return l.createElement(de,{key:O,color:C,underline:!0,italic:!0},W)}}if(M.startsWith("[")&&(M.includes("][")||M.includes("] ["))){let U=M.match(Td);if(U){let D=U[1]||U[2],W=`\x1B]8;;${U[2]||U[1]}\x07${D}\x1B]8;;\x07`;return l.createElement(de,{key:O,color:C,underline:!0,italic:!0},W)}}return M.startsWith("http")?l.createElement(de,{key:O,color:C,underline:!0,italic:!0},M):gi(M,O)}))}),ya=l.memo(({buffer:t,terminalWidth:m=80,theme:d="Dark"})=>{if(t.length<2)return null;let v=ut(d),y=v.codeText||v.secondary||v.info||"cyan",b=t.map(U=>{let D=U.split("|");return D[0]!==void 0&&D[0].trim()===""&&D.shift(),D.length>0&&D[D.length-1].trim()===""&&D.pop(),D.map(P=>P.trim())}),r=b[0],C=b.slice(2),w=Math.floor(100/r.length),M=m-8,O=Math.floor(M/r.length)-2;return l.createElement(I,{flexDirection:"column",borderStyle:"round",borderColor:v.borderMuted,paddingX:1,marginY:0,width:m-2},l.createElement(I,{flexDirection:"row",borderStyle:"single",borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,borderColor:v.borderMuted,marginBottom:1,paddingBottom:0,width:"100%"},r.map((U,D)=>l.createElement(I,{key:D,flexBasis:`${w}%`,flexGrow:1,flexShrink:0,paddingRight:2},l.createElement(no,{text:Lt(U,O),color:y,theme:d})))),C.map((U,D)=>l.createElement(I,{key:D,flexDirection:"row",marginBottom:D===C.length-1?0:1,width:"100%"},U.map((P,W)=>l.createElement(I,{key:W,flexBasis:`${w}%`,flexGrow:1,flexShrink:0,paddingRight:2,flexDirection:"column"},l.createElement(no,{text:Lt(P,O),color:v.text,theme:d}))))))}),tr=l.memo(({text:t,color:m,columns:d=80,italic:v=!1,theme:y="Dark"})=>{if(!t)return null;let b=t.replaceAll(" "," "),r=ut(y),C=m||r.text,w=b.split(`
|
|
21
|
-
`),M=[],O=[],U=[],D=P=>{if(O.length>0&&(M.push(l.createElement(ya,{key:`table-${P}`,buffer:[...O],terminalWidth:d,theme:y})),O=[]),U.length>0){let W=d-6,X=U.flatMap(_=>Lt(_,W).split(`
|
|
22
|
-
`));M.push(l.createElement(I,{key:`quote-${P}`,borderStyle:"bold",borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:r.borderMuted,paddingLeft:1,marginY:1,flexDirection:"column"},X.map((_,V)=>l.createElement(no,{key:V,text:_,color:r.textMuted,italic:v,theme:y})))),U=[]}};return w.forEach((P,W)=>{let X=P.trim(),_=X.startsWith("|"),V=X.startsWith(">");if(_)U.length>0&&D(W),O.push(P);else if(V)O.length>0&&D(W),U.push(X.replace(/^>\s*/,""));else{if(D(W),X===""){M.push(l.createElement(I,{key:W,height:1}));return}if(X==="---"||X==="***"||X==="___"){M.push(l.createElement(I,{key:W,marginY:0,borderStyle:"single",borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,width:"100%",borderColor:r.borderMuted}));return}let Y=X.match(/^(#{1,6})\s+(.*)/);if(Y){let be=Y[1].length,Oe=Y[2];M.push(l.createElement(I,{key:W,marginTop:1,marginBottom:0,width:"100%"},l.createElement(de,{bold:!0,color:be===1?"yellow":be===2?"magenta":be===3?r.info||"cyan":be===4?"green":be===5?"blue":r.text,underline:!0},Oe)));return}let ue=/^[\*\-\+]\s/.test(X),me=/^\d+\.\s/.test(X),le=P.includes("\u2588")||P.includes("\u2554")||P.includes("\u255A")||P.includes("\u2550"),H="";if(le)H=P;else if(ue||me){let be=ue?" \u2022 ":X.match(/^\d+\.\s/)[0],Oe=" ".repeat(be.length),Ne=Lt(X.replace(/^[\*\-\d+\.]+\s/,""),d-(be.length+6));H=be+Ne.split(`
|
|
23
|
-
`).join(`
|
|
24
|
-
`+Oe)}else H=Lt(X,d-4);M.push(l.createElement(I,{key:W,flexDirection:"column",width:"100%"},l.createElement(no,{text:H,color:C,italic:v,theme:y})))}}),D("final"),l.createElement(I,{flexDirection:"column",width:d-2},M)}),Ca=l.memo(({line:t,pairContent:m,parentText:d,columns:v=80,extension:y,theme:b="Dark"})=>{let r=ut(b),C=(t||"").replaceAll(" "," "),w=C.includes("[UI_CONTEXT]"),M=C.replace("[UI_CONTEXT]","");if(w&&M.trim().startsWith("@@")){let tt=M.trim().split(/\s+/);return l.createElement(I,{backgroundColor:r.codeBg,paddingX:1,width:v,marginY:0},l.createElement(I,{width:v-2,flexDirection:"row"},tt.map((Se,xe)=>{let Me=r.info||"cyan";return Se.startsWith("+")?Me=r.diffAdditionNum||"green":Se.startsWith("-")&&(Me=r.diffRemovalNum||"red"),l.createElement(de,{key:xe,color:Me,bold:Se.startsWith("+")||Se.startsWith("-")},Se,xe<tt.length-1?" ":"")})))}if(w&&M.includes("\u2550"))return l.createElement(I,{backgroundColor:r.codeBg,paddingX:1,width:v},l.createElement(de,{color:"gray"},"\u2550".repeat(Math.max(10,v-4))));let U=ai(C);if(!U)return l.createElement(I,{backgroundColor:r.codeBg,paddingX:1,width:v},l.createElement(I,{width:3,flexShrink:0}),l.createElement(I,{width:1,flexShrink:0,marginLeft:1}),l.createElement(I,{flexGrow:1,marginLeft:1},l.createElement(de,{color:"gray"},Lt(M,v-14))));let{isR:D,isA:P,num:W,content:X}=U,_=m&&m.replaceAll(" "," "),V=[];if(_!=null){let Ne=D?X:_,tt=D?_:X;try{V=$c(Ne,tt)}catch{V=[]}}let Y=V.some(Ne=>D&&Ne.removed||P&&Ne.added),ue=!_&&(D||P),me=D?r.diffRemovalBg:P?r.diffAdditionBg:void 0,le=D||P?D?r.diffRemovalNum:r.diffAdditionNum:r.textMuted,H=D?r.diffRemovalPrefix:r.diffAdditionPrefix,be=D?"-":P?"+":" ",Oe=()=>{if(ue){let J=D?r.diffRemovalHighlightBg:r.diffAdditionHighlightBg;return l.createElement(I,{flexDirection:"column"},Bt(Lt(X,v-15),y,void 0,J))}if(!(D||P)||V.length===0||!Y)return l.createElement(I,{flexDirection:"column"},Bt(Lt(X,v-15),y,void 0,void 0));let Ne=Math.max(10,v-15),tt=Lt(X,Ne).split(`
|
|
25
|
-
`),Se=[];if(V.forEach((J,fe)=>{let we=/^\s+$/.test(J.value);if(D){let ee=V[fe-1]?.removed||V[fe+1]?.removed;J.removed||we&&ee?Se.push({text:J.value,isHighlight:!0}):J.added||Se.push({text:J.value,isHighlight:!1})}else if(P){let ee=V[fe-1]?.added||V[fe+1]?.added;J.added||we&&ee?Se.push({text:J.value,isHighlight:!0}):J.removed||Se.push({text:J.value,isHighlight:!1})}}),tt.length<=1)return l.createElement(de,{wrap:"wrap"},Se.map((J,fe)=>D?J.isHighlight?l.createElement(l.Fragment,{key:fe},Bt(J.text,y,void 0,r.diffRemovalHighlightBg)):l.createElement(l.Fragment,{key:fe},Bt(J.text,y,void 0)):P?J.isHighlight?l.createElement(l.Fragment,{key:fe},Bt(J.text,y,void 0,r.diffAdditionHighlightBg)):l.createElement(l.Fragment,{key:fe},Bt(J.text,y,void 0)):l.createElement(l.Fragment,{key:fe},Bt(J.text,y,void 0))));let xe=0,Me=0,St=X.match(/^(\s*)/),Xe=St?St[1]:"",Pe=Xe.substring(0,Math.min(Xe.length,8)),Ce=tt.map((J,fe)=>{let we=[],ee=J;fe>0&&Pe&&J.startsWith(Pe)&&((Se[xe]?Se[xe].text.substring(Me):"").startsWith(Pe)||(we.push({text:Pe,isHighlight:!1}),ee=J.substring(Pe.length)));let he=ee.length;for(;he>0&&xe<Se.length;){let j=Se[xe],Ge=j.text.length-Me;if(Ge<=0){xe++,Me=0;continue}let $e=Math.min(he,Ge);we.push({text:j.text.substring(Me,Me+$e),isHighlight:j.isHighlight}),Me+=$e,he-=$e,Me>=j.text.length&&(xe++,Me=0)}for(;xe<Se.length;){let j=Se[xe],Ge=j.text.substring(Me);if(/^\s+$/.test(Ge))xe++,Me=0;else if(Ge.startsWith(" ")||Ge.startsWith(" ")){let $e=0;for(;$e<Ge.length&&(Ge[$e]===" "||Ge[$e]===" ");)$e++;Me+=$e,Me>=j.text.length&&(xe++,Me=0);break}else break}return we});if(xe<Se.length){let J=Ce[Ce.length-1];for(;xe<Se.length;){let fe=Se[xe];J.push({text:fe.text.substring(Me),isHighlight:fe.isHighlight}),xe++,Me=0}}return l.createElement(I,{flexDirection:"column"},Ce.map((J,fe)=>l.createElement(I,{key:fe},l.createElement(de,{wrap:"wrap"},J.map((we,ee)=>D?we.isHighlight?l.createElement(l.Fragment,{key:ee},Bt(we.text,y,void 0,r.diffRemovalHighlightBg)):l.createElement(l.Fragment,{key:ee},Bt(we.text,y,void 0)):P?we.isHighlight?l.createElement(l.Fragment,{key:ee},Bt(we.text,y,void 0,r.diffAdditionHighlightBg)):l.createElement(l.Fragment,{key:ee},Bt(we.text,y,void 0)):l.createElement(l.Fragment,{key:ee},Bt(we.text,y,void 0)))))))};return l.createElement(I,{backgroundColor:r.codeBg,paddingX:1,width:v},l.createElement(I,{width:4,flexShrink:0,justifyContent:"flex-end"},l.createElement(de,{color:le},W)),l.createElement(I,{width:1,flexShrink:0,marginLeft:1},l.createElement(de,{color:H},be)),l.createElement(I,{marginLeft:1,backgroundColor:me,flexGrow:1},Oe()))}),Ed=l.memo(({text:t,columns:m=80,extension:d,theme:v="Dark"})=>{let y=ut(v),b=t.match(/\[DIFF_START\]([\s\S]*?)(?:\[DIFF_END\]|$)/),w=(b?b[1].trim():"").split(`
|
|
26
|
-
`).map(O=>{let U=O.replaceAll(" "," ");return{line:U,parsed:ai(U),pairContent:null}}),M=[];for(let O=0;O<w.length;O++){let U=w[O];U.parsed&&(U.parsed.isR||U.parsed.isA)?M.push(U):M.length>0&&(ci(M),M=[])}return M.length>0&&ci(M),l.createElement(I,{flexDirection:"column",width:m-3,marginBottom:1},l.createElement(I,{flexDirection:"column",paddingY:0,width:"100%"},l.createElement(I,{backgroundColor:y.codeBg,paddingX:1,width:"100%"},l.createElement(I,{width:3,flexShrink:0}),l.createElement(I,{width:1,flexShrink:0,marginLeft:1}),l.createElement(I,{flexGrow:1,marginLeft:1},l.createElement(de,null," "))),w.map((O,U)=>l.createElement(Ca,{key:U,line:O.line,pairContent:O.pairContent,columns:m-3,extension:d,theme:v})),l.createElement(I,{backgroundColor:y.codeBg,paddingX:1,width:"100%"},l.createElement(I,{width:3,flexShrink:0}),l.createElement(I,{width:1,flexShrink:0,marginLeft:1}),l.createElement(I,{flexGrow:1,marginLeft:1},l.createElement(de,null," ")))))}),ds=l.memo(({text:t,columns:m=80,theme:d="Dark"})=>{if(!t)return null;let v=ut(d),y="",b=t.match(/File\s+\[(.*?)\]/i);if(b&&(y=b[1].split(".").pop().toLowerCase()),t.includes("[DIFF_START]"))return l.createElement(Ed,{text:t,columns:m,extension:y,theme:d});if(t.includes("- Content Preview:")){let r=t.split("- Content Preview:"),C=r[0],w=r[1]||"",M="[SYSTEM] Check the content preview for verification [/SYSTEM]",O=w.split(M),U=(O[0]?.trim()||"").replaceAll(" "," "),D=O[1]?`${M}${O[1]}`:"",P=U.split(`
|
|
27
|
-
`),W=String(P.length).length;return l.createElement(I,{flexDirection:"column",width:m-3},l.createElement(I,{flexDirection:"column",borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:v.codeBorder,paddingLeft:2,paddingRight:0,width:"100%",marginBottom:1,backgroundColor:v.codeBg},l.createElement(I,{flexDirection:"column",width:"100%"},l.createElement(I,{width:"100%"},l.createElement(I,{width:W+2,flexShrink:0},l.createElement(de,null," ")),l.createElement(I,{flexGrow:1},l.createElement(de,null," "))),P.map((X,_)=>l.createElement(I,{key:_,width:"100%"},l.createElement(I,{width:W+2,flexShrink:0},l.createElement(de,{color:"gray",dimColor:!0},String(_+1).padStart(W," ")," ")),l.createElement(I,{flexGrow:1},Bt(X,y,v.text)))),l.createElement(I,{width:"100%"},l.createElement(I,{width:W+2,flexShrink:0},l.createElement(de,null," ")),l.createElement(I,{flexGrow:1},l.createElement(de,null," "))))))}if(t.includes("```")){let r=t.split(/(```\w*\n?[\s\S]*?(?:```|$))/g);return l.createElement(I,{flexDirection:"column",width:m-3},r.map((C,w)=>{if(C.startsWith("```")){let O=C.match(/```(\w*)\n?([\s\S]*?)(?:```|$)/),U=O?O[1]:"code",D=(O?O[2]:C.replace(/^```\w*\n?/,"").replace(/```$/,"")).replaceAll(" "," "),P=D.trimEnd().split(`
|
|
28
|
-
`),W=String(P.length).length,X=m-7-W,V=(X>5?Lt(D,X):D).trimEnd().split(`
|
|
29
|
-
`);return l.createElement(I,{key:w,flexDirection:"column",marginY:0,paddingLeft:2,paddingRight:0,width:"100%"},l.createElement(I,null,l.createElement(de,{color:"gray",bold:!0},"\u25B6_ ",U.toUpperCase()||"TEXT")),l.createElement(I,{flexDirection:"column",width:"100%"},V.map((Y,ue)=>{let le=Lt(Y,Math.max(10,X)).split(`
|
|
30
|
-
`);return l.createElement(I,{key:ue,flexDirection:"column",width:"100%"},le.map((H,be)=>l.createElement(I,{key:be,width:"100%"},l.createElement(I,{width:W+2,flexShrink:0},l.createElement(de,{color:"gray"},be===0?String(ue+1).padStart(W," ")+" ":" ".repeat(W+1))),l.createElement(I,{flexGrow:1},Bt(H,U,v.text)))))})))}let M=C;return w>0&&(M=M.replace(/^[\r\n]+/,"")),w<r.length-1&&(M=M.replace(/[\r\n]+$/,"")),M?l.createElement(tr,{key:w,text:M,columns:m-3,theme:d}):null}))}return l.createElement(tr,{text:t,columns:m-3,theme:d})}),us=t=>{let m=Math.round(t/1e3);if(m<=0)return"0s";let d=Math.floor(m/60),v=m%60;return d>0?`${d}m ${v}s`:`${m}s`},Ma=l.memo(({msg:t,showFullThinking:m,columns:d=80,aiProvider:v,version:y,theme:b="Dark"})=>{let r=ut(b),C=t.role==="system"&&(t.text?.includes("[DIFF_START]")||t.text?.includes("- Content Preview:")),w=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")),M=t.isTerminalRecord;if(t.isHomeWarning)return l.createElement(I,{marginBottom:1,paddingX:1,width:"100%"},l.createElement(I,{flexDirection:"column",borderStyle:"round",borderColor:r.border,dimColor:!0,padding:0,width:"100%"},l.createElement(I,{paddingX:1},l.createElement(de,{color:r.text,bold:!0},t.text)),l.createElement(I,{paddingX:1,marginTop:0,marginBottom:0},l.createElement(de,{color:r.text},t.subText))));if(t.isLogo)return l.createElement(I,{flexDirection:"column",alignItems:"flex-start",width:"100%",marginY:1},l.createElement(de,null,Mr(y,v,b)));if(t.id&&String(t.id).startsWith("welcome"))return l.createElement(I,{flexDirection:"column",alignItems:"center",width:"100%",marginY:1},l.createElement(I,{borderStyle:"round",borderColor:r.borderMuted,paddingX:3,paddingY:0},l.createElement(de,{color:r.text,bold:!0},t.text.trim())));if(t.isVisualFeedback)return l.createElement(I,{marginBottom:0,marginTop:0,paddingX:1,width:"100%"},l.createElement(de,{color:r.text},t.text));if(t.isSteeringHint||t.role==="user"&&(t.text?.startsWith("[STEERING HINT]")||t.text?.startsWith("[QUESTION]"))){let X=t.hintContent||(t.text||"").replace(/^\[(?:STEERING HINT|QUESTION)\]\s*/i,"").trim();return l.createElement(I,{flexDirection:"column",width:d-1,marginBottom:0,marginTop:0},l.createElement(I,{width:d-1,height:1,overflow:"hidden"},l.createElement(de,{color:r.userMsgBorder},"\u2584".repeat(Math.max(1,d-1)))),l.createElement(I,{backgroundColor:r.userMsgBg,paddingX:1,paddingY:0,width:d-1,flexDirection:"column"},Lt(X.replace(/\r\n/g,`
|
|
31
|
-
`).replace(/\r/g,`
|
|
32
|
-
`).replace(/\\\n/g,`
|
|
33
|
-
`).replace(/\\$/,""),d-7).split(`
|
|
34
|
-
`).map((_,V)=>l.createElement(I,{key:V,flexDirection:"row",width:"100%"},l.createElement(I,{flexShrink:0,width:2},l.createElement(de,{bold:!0,color:r.userMsgText},V===0?"\u2726":" ")),l.createElement(I,{flexGrow:1,marginLeft:1},l.createElement(no,{text:_,color:r.userMsgText,theme:b}))))),l.createElement(I,{width:d-1,height:1,overflow:"hidden"},l.createElement(de,{color:r.userMsgBorder},"\u2580".repeat(Math.max(1,d-1)))))}if(w)return l.createElement(I,{marginBottom:1},l.createElement(I,{flexDirection:"column",borderStyle:"round",borderColor:r.border,paddingX:1,paddingY:0},l.createElement(de,{color:r.text,bold:!0,underline:!0},"\u2717 PATCH FAILED"),l.createElement(I,{marginTop:1},l.createElement(de,{color:r.textMuted,bold:!0},"Model generated malformed edit."))));if(t.role==="system"&&(t.text?.includes("[ACTION RESULT]")||t.text?.includes("[TOOL RESULT]"))&&!C&&!M&&!w)return null;if(t.isImageStats)return l.createElement(I,{marginBottom:1,paddingX:1,width:"100%"},l.createElement(I,{flexDirection:"column",borderStyle:"round",borderColor:r.borderMuted,padding:0,width:"100%"},l.createElement(I,{paddingX:1,backgroundColor:r.codeBg},l.createElement(de,{color:r.text,bold:!0},"IMAGE STATS")),l.createElement(I,{paddingX:1,marginTop:1,marginBottom:1,flexDirection:"column"},t.text.split(`
|
|
35
|
-
`).map((X,_)=>l.createElement(de,{key:_,color:r.textMuted},X)))));if(t.isAskRecord){let X=t.text.match(/Selection: (.*)/),_=X?X[1]:"No selection",V=t.text.match(/Question: (.*)/),Y=V?V[1]:null,ue=Y==="Agent has been running for a long time. Do you want to continue execution?";return l.createElement(I,{marginBottom:0,paddingX:1,width:"100%"},l.createElement(I,{flexDirection:"column",borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!0,borderBottom:!0,borderColor:r.codeBorder,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,marginY:1,width:d-2},l.createElement(I,{paddingX:1},l.createElement(de,{color:r.success,bold:!0},ue?"TURN SAFETY SYSTEM: RESOLVED":"AGENT REQUEST: RESOLVED")),Y&&l.createElement(I,{paddingX:1,marginTop:1},l.createElement(de,{color:r.secondary},Y)),l.createElement(I,{paddingX:1,marginTop:1,marginBottom:0},l.createElement(de,{color:r.text},"Selection: ",l.createElement(de,{color:r.textMuted,bold:!0},_)))))}if(t.isAboutRecord)return l.createElement(I,{marginBottom:0,paddingX:1,width:"100%"},l.createElement(I,{flexDirection:"column",borderStyle:"round",border:!0,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,backgroundColor:r.codeBg,width:"100%"},l.createElement(I,{paddingX:1},l.createElement(de,{color:r.text,bold:!0},"ABOUT FLUX FLOW")),l.createElement(I,{paddingX:1,marginTop:1,marginBottom:1},l.createElement(de,{color:r.text},t.text))));if(t.isUpdateNotification)return l.createElement(I,{marginBottom:1,paddingX:1,width:"100%"},l.createElement(I,{flexDirection:"column",borderStyle:"round",border:!0,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,backgroundColor:r.codeBg,width:"100%"},l.createElement(I,{paddingX:1},l.createElement(de,{color:r.text,bold:!0},"UPDATE AVAILABLE")),l.createElement(I,{paddingX:1,marginTop:1,marginBottom:1},l.createElement(ds,{text:t.text,columns:d,theme:b}))));if(t.isHelpRecord){let X=[{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 (list/add/remove/use/clean)"},{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 l.createElement(I,{marginBottom:1,paddingX:1,width:"100%"},l.createElement(I,{flexDirection:"column",borderStyle:"round",borderColor:r.borderMuted,paddingX:2,paddingY:1,width:"100%"},l.createElement(de,{color:r.text,bold:!0,underline:!0},"AVAILABLE COMMANDS IN FLUX-FLOW"),l.createElement(I,{flexDirection:"column",marginTop:1},X.map((_,V)=>l.createElement(I,{key:V,flexDirection:"row"},l.createElement(I,{width:20},l.createElement(de,{color:r.text,bold:!0},_.cmd)),l.createElement(de,{color:r.textMuted}," - ",_.desc))))))}if(t.isTerminalRecord){let X=t.text.match(/COMMAND: (.*)/),_=t.text.match(/PTY: (true|false)/),V=t.text.match(/OUTPUT: ([\s\S]*)/),Y=X?X[1]:"No Command",ue=_?_[1]==="true":!1,me=V?V[1]:"";return l.createElement(I,{marginBottom:0,paddingX:1,width:"100%"},l.createElement(cs,{command:Y,output:me,completed:!0,columns:d,isPty:ue,theme:b}))}let[U,D]=l.useState(!t.isStreaming),P=l.useMemo(()=>(Kl(t.text,t.role)||"").replaceAll(" "," "),[t.text,t.role]);l.useEffect(()=>{t.isStreaming&&D(!1)},[t.id]);let W=l.useMemo(()=>t.role==="think"&&!m?"Thinking...":t.isStreaming?P:P.trimEnd(),[P,t.role,m,t.isStreaming]);return t.role==="think"&&!Ta()||t.role==="agent"&&W.trim()===""?null:l.createElement(I,{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"?l.createElement(I,{flexDirection:"column",width:d-1},l.createElement(I,{width:d-1,height:1,overflow:"hidden"},l.createElement(de,{color:r.userMsgBorder},"\u2584".repeat(Math.max(1,d-1)))),l.createElement(I,{backgroundColor:r.userMsgBg,paddingX:1,paddingY:0,width:d-1,flexDirection:"column"},Lt(W.replace(/\r\n/g,`
|
|
36
|
-
`).replace(/\r/g,`
|
|
37
|
-
`).replace(/\\\n/g,`
|
|
38
|
-
`).replace(/\\$/,""),d-7).split(`
|
|
39
|
-
`).map((X,_)=>l.createElement(I,{key:_,flexDirection:"row",width:"100%"},l.createElement(I,{flexShrink:0,width:2},l.createElement(de,{bold:!0,color:r.userMsgText},_===0?">":" ")),l.createElement(I,{flexGrow:1,marginLeft:1},l.createElement(no,{text:X,color:t.color||r.userMsgText,theme:b}))))),l.createElement(I,{width:d-1,height:1,overflow:"hidden"},l.createElement(de,{color:r.userMsgBorder},"\u2580".repeat(Math.max(1,d-1))))):t.role==="think"?l.createElement(I,{flexDirection:"column",marginTop:0,marginBottom:0,paddingX:0,width:"100%"},t.isStreaming&&!t.duration?l.createElement(de,{bold:!0,color:r.text},"\u2727 Thinking..."):l.createElement(de,{bold:!0,color:r.text},"\u2726 Thought",t.duration?l.createElement(de,{color:r.textMuted}," for ",l.createElement(de,{bold:!0,color:r.text},us(t.duration))):"s..."),l.createElement(I,{borderStyle:"single",borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:r.borderMuted,paddingLeft:2,paddingTop:0,paddingBottom:0,flexDirection:"column",width:"100%"},Uc(W,d))):l.createElement(I,{flexDirection:"column",paddingX:1,marginTop:0,width:"100%"},l.createElement(ds,{text:W.replace(/ \|\n\n/g,` |
|
|
40
|
-
`),columns:d,theme:b}),t.memoryUpdated&&l.createElement(I,{marginTop:1,width:"100%"},l.createElement(de,{color:r.text,italic:!0},"[Memory Updated]")),t.role==="agent"&&t.workedDuration?l.createElement(I,{marginTop:1,marginBottom:2,width:"100%"},l.createElement(de,{color:r.textMuted},"["),l.createElement(de,{color:r.textMuted},"Worked for ",l.createElement(de,{bold:!0,color:r.text},us(t.workedDuration))),l.createElement(de,{color:r.textMuted},"]")):null))}),ms=l.memo(({block:t,columns:m=80,showFullThinking:d,aiProvider:v,version:y,theme:b="Dark"})=>{let r=ut(b),{msg:C,type:w,text:M,isStreamingMsg:O,workedDuration:U}=t;if((w==="think-header"||w==="think-line"||w==="think-footer-padding")&&!Ta())return null;if(w==="chunk")return l.createElement(I,{flexDirection:"column",width:"100%"},t.blocks.map(D=>l.createElement(ms,{key:D.key,block:D,columns:m,showFullThinking:d,aiProvider:v,version:y,theme:b})));if(w==="full-message")return l.createElement(Ma,{msg:C,showFullThinking:d,columns:m,aiProvider:v,version:y,theme:b});if(w==="think-header")return l.createElement(I,{flexDirection:"column",paddingX:1,width:"100%",marginTop:0,marginBottom:0},(()=>{let D=t.duration||C?.duration||U;return O&&!D?l.createElement(de,{bold:!0,color:r.text},"\u2727 Thinking..."):l.createElement(de,{bold:!0,color:r.text},"\u2726 Thought",D?l.createElement(de,{color:r.textMuted}," for ",l.createElement(de,{bold:!0,color:r.text},us(D)),"..."):"s...")})(),d&&l.createElement(I,{flexDirection:"row",width:"100%"},l.createElement(de,{color:r.textMuted},"\u2502 ")));if(w==="think-line"){if(!d)return null;if(!M||M.trim()==="")return l.createElement(I,{flexDirection:"row",width:"100%",paddingX:1},l.createElement(de,{color:r.textMuted},"\u2502 "));let D=pa(M,O,t.isActiveBlock)?.replaceAll(" "," ")||"";return l.createElement(I,{flexDirection:"row",width:"100%",paddingX:1},l.createElement(de,{color:r.textMuted},"\u2502 "),l.createElement(I,{flexGrow:1,marginLeft:1},l.createElement(no,{text:D,color:r.textMuted,italic:!0,theme:b})))}if(w==="think-footer-padding")return d?l.createElement(I,{flexDirection:"row",width:"100%",paddingX:1},l.createElement(de,{color:r.textMuted},"\u2502 ")):null;if(w==="agent-line"){if(!M||M.trim()==="")return l.createElement(I,{height:1});let D=pa(M,O,t.isActiveBlock)?.replaceAll(" "," ")||"",P=D.trim();if(P==="---"||P==="***"||P==="___")return l.createElement(I,{flexDirection:"column",paddingX:1,width:"100%",marginY:0},l.createElement(I,{borderStyle:"single",borderTop:!0,borderBottom:!1,borderLeft:!1,borderRight:!1,width:"100%",borderColor:r.borderMuted}));let W=P.match(Xc);if(W){let V=W[1].length,Y=W[2],me=["yellow",r.secondary||"magenta",r.info||"cyan","green","blue",r.text][V-1]||r.text;return l.createElement(I,{flexDirection:"column",paddingX:1,width:"100%",marginTop:0,marginBottom:0},l.createElement(de,{bold:!0,color:me,underline:!0},l.createElement(no,{text:Y,color:me,theme:b})))}if(P.startsWith(">")){let V=P.replace(/^>\s*/,"");return l.createElement(I,{flexDirection:"column",paddingX:1,width:"100%"},l.createElement(I,{borderStyle:"bold",borderLeft:!0,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:r.borderMuted,paddingLeft:1,marginY:0},l.createElement(no,{text:V,color:r.textMuted,italic:!0,theme:b})))}let X=/^[\*\-\+]\s/.test(P),_=/^\d+\.\s/.test(P);if(X||_){let V=X?" \u2022 ":P.match(/^\d+\.\s/)[0],Y=P.replace(/^[\*\-\+\d+\.]+\s*/,"");return l.createElement(I,{flexDirection:"row",paddingX:1,width:"100%"},l.createElement(de,{color:r.info||r.textMuted},V),l.createElement(I,{flexGrow:1},l.createElement(no,{text:Y,color:r.text,theme:b})))}return l.createElement(I,{flexDirection:"column",paddingX:1,width:"100%"},l.createElement(no,{text:D,color:r.text,theme:b}))}if(w==="table-header"||w==="table-row"){let D=w==="table-header",P=r.codeText||r.secondary||r.info||"cyan",W=t.colHeaders||[],X=D?W:t.cells||[],_=Math.max(1,t.colCount||W.length||X.length||1),V=Array.from({length:_},(Se,xe)=>X[xe]||""),Y=Math.max(20,(m||80)-8),ue=_>=4,me=/^(#|no\.?|num\.?|status|state|type|ok|done|✔|✘|active)$/i,le=[],H=0,be=0;for(let Se=0;Se<_;Se++){let xe=(W[Se]||"").trim();if(ue&&(me.test(xe)||xe==="#")){let Me=Math.max(xe.length+4,8);le.push(Me),H+=Me}else le.push(null),be++}let Oe=Math.max(be*12,Y-H),Ne=be>0?Math.max(10,Math.floor(Oe/be)):10;for(let Se=0;Se<_;Se++)le[Se]===null&&(le[Se]=Ne);let tt=le.reduce((Se,xe)=>Se+xe,0);return D?l.createElement(I,{flexDirection:"column",paddingX:1,width:"100%",marginTop:0,marginBottom:1},l.createElement(I,{flexDirection:"row",borderStyle:"single",borderBottom:!0,borderTop:!1,borderLeft:!1,borderRight:!1,borderColor:r.borderMuted,paddingBottom:0,width:tt},W.map((Se,xe)=>{let Me=le[xe]||6;return l.createElement(I,{key:xe,width:Me,paddingRight:1,flexDirection:"column"},l.createElement(no,{text:Lt(Se,Math.max(2,Me-1)),color:P,theme:b}))}))):l.createElement(I,{flexDirection:"row",paddingX:1,width:"100%",marginBottom:1},V.map((Se,xe)=>{let Me=le[xe]||6;return l.createElement(I,{key:xe,width:Me,paddingRight:1,flexDirection:"column"},l.createElement(no,{text:Lt(Se,Math.max(2,Me-1)),color:r.text,theme:b}))}))}if(w==="table-close")return l.createElement(I,{height:0});if(w==="table")return l.createElement(I,{flexDirection:"column",paddingX:1,width:"100%"},l.createElement(ya,{buffer:M.split(`
|
|
41
|
-
`),terminalWidth:m,theme:b}));if(w==="diff-line"){let{isFirstLine:D,isLastLine:P}=t,W=(X=!1)=>l.createElement(I,{backgroundColor:r.codeBg,paddingX:1,width:m,marginBottom:X?1:0},l.createElement(I,{width:3,flexShrink:0}),l.createElement(I,{width:1,flexShrink:0,marginLeft:1}),l.createElement(I,{flexGrow:1,marginLeft:1},l.createElement(de,null," ")));return l.createElement(I,{flexDirection:"column"},D&&W(!1),l.createElement(Ca,{line:M,pairContent:t.pairContent,parentText:void 0,columns:m,theme:b}),P&&W(!0))}if(w==="code-fence-open"){let D={paddingLeft:2,width:"100%"};return l.createElement(I,{flexDirection:"column",marginTop:0,marginBottom:0,width:"100%"},l.createElement(I,{flexDirection:"row",...D},l.createElement(de,null," ")),l.createElement(I,{flexDirection:"row",...D},l.createElement(de,{color:"gray",bold:!0},"\u25B6_ ",(M||"TEXT").toUpperCase())))}if(w==="code-line"){let{lineNum:D,lang:P}=t,W=m-12,X=(M||"").replaceAll(" "," "),V=Lt(X,Math.max(10,W)).split(`
|
|
42
|
-
`);return l.createElement(I,{flexDirection:"column",width:"100%"},V.map((Y,ue)=>l.createElement(I,{key:ue,flexDirection:"row",borderColor:r.codeBorder,paddingLeft:2,width:"100%"},l.createElement(I,{width:5,flexShrink:0},l.createElement(de,{color:"gray",dimColor:!0},ue===0?String(D).padStart(4," ")+" ":" ")),l.createElement(I,{flexGrow:1},Bt(Y,P,r.text)))))}if(w==="code-fence-close")return l.createElement(I,{flexDirection:"row",paddingLeft:2,marginBottom:1,width:"100%"},l.createElement(de,null," "));if(w==="write-header")return l.createElement(I,{flexDirection:"column",paddingX:1,width:m},l.createElement(tr,{text:M,columns:m,theme:b}));if(w==="write-line"){let{gutterWidth:D,lineNum:P,isFirstLine:W,isLastLine:X,extension:_,wrappedLines:V}=t,Y=(ue=!1)=>l.createElement(I,{flexDirection:"row",width:m,borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:r.codeBorder,paddingLeft:2,paddingRight:0,backgroundColor:r.codeBg,marginBottom:ue?1:0},l.createElement(I,{width:D+2,flexShrink:0},l.createElement(de,null," ".repeat(D+2))),l.createElement(I,{flexGrow:1},l.createElement(de,null," ")));return l.createElement(I,{flexDirection:"column"},W&&Y(!1),l.createElement(I,{flexDirection:"row",width:m,borderStyle:"single",borderLeft:!1,borderRight:!1,borderTop:!1,borderBottom:!1,borderColor:r.codeBorder,paddingLeft:2,paddingRight:0,backgroundColor:r.codeBg},l.createElement(I,{width:D+2,flexShrink:0},l.createElement(de,{color:"gray",dimColor:!0},String(P).padStart(D," ")," ")),l.createElement(I,{flexGrow:1,flexDirection:"column"},(V||[M]).map((ue,me)=>l.createElement(I,{key:me},Bt((ue||"").replaceAll(" "," "),_,r.text))))),X&&Y(!0))}return w==="write-footer"?l.createElement(I,{flexDirection:"column",paddingX:1,width:m,marginTop:1,marginBottom:1},l.createElement(tr,{text:M,columns:m,theme:b})):w==="worked-duration"?l.createElement(I,{marginTop:1,marginBottom:2,paddingX:1,width:"100%"},l.createElement(de,{color:r.textMuted},"["),l.createElement(de,{color:r.textMuted},"Worked for ",l.createElement(de,{bold:!0,color:r.text},us(U))),l.createElement(de,{color:r.textMuted},"]")):null}),nm=l.memo(({messages:t,showFullThinking:m,columns:d=80,aiProvider:v,version:y,theme:b="Dark"})=>l.createElement(I,{flexDirection:"column",width:"100%"},t.map((r,C)=>l.createElement(Ma,{key:r.id||C,msg:r,showFullThinking:m,columns:d,aiProvider:v,version:y,theme:b}))));import Ot from"react";import{Box as fn,Text as Uo}from"ink";import{useState as Ir,useEffect as kr,useRef as fs}from"react";var Ar=null;function Sa(){Ar&&Ar()}var Dd=t=>{if(t<=370)return"#00a564";if(t>=5e3)return"#ff0000";let m=[{t:370,r:0,g:165,b:100},{t:550,r:40,g:195,b:80},{t:800,r:120,g:220,b:50},{t:1100,r:190,g:225,b:20},{t:1500,r:250,g:210,b:15},{t:2e3,r:255,g:170,b:0},{t:2800,r:255,g:110,b:0},{t:3800,r:255,g:50,b:0},{t:5e3,r:255,g:0,b:0}];for(let d=0;d<m.length-1;d++){let v=m[d],y=m[d+1];if(t>=v.t&&t<=y.t){let b=(t-v.t)/(y.t-v.t);b=b*b*(3-2*b);let r=Math.round(v.r+(y.r-v.r)*b),C=Math.round(v.g+(y.g-v.g)*b),w=Math.round(v.b+(y.b-v.b)*b);return`#${((1<<24)+(r<<16)+(C<<8)+w).toString(16).slice(1)}`}}return"#ff0000"},Id=Ot.memo(({mode:t,thinkingLevel:m,tokens:d="0.0k",tokensTotal:v="0.0k",cachedTokens:y=0,promptTokens:b=0,chatCacheTokenLatest:r=0,cacheCalculateMode:C="Session",chatId:w="NEW-SESSION",isMemoryEnabled:M=!0,apiTier:O="Free",aiProvider:U="Google",activeModel:D="",isProcessing:P=!1,lastChunkTime:W=0,theme:X="Dark",wps:_=0,showTPMEstimate:V=!1})=>{let Y=ut(X),ue="",[me,le]=Ir(0),[H,be]=Ir(0),[Oe,Ne]=Ir("MB"),[tt,Se]=Ir("green"),[xe,Me]=Ir(0),St=fs([]),Xe=fs(370),Pe=fs([]),Ce=fs(W);kr(()=>{Ce.current=W},[W]),kr(()=>{if(!P){Pe.current=[];return}if(_>0){let fe=Pe.current;fe.push(_),fe.length>3&&fe.shift()}},[P,_,W]),kr(()=>{if(!P){Me(0);return}let fe=setInterval(()=>{let we=Ce.current,ee=we>0?Date.now()-we:0;if(we>0&&ee>=1e3)Pe.current=[],Me(0);else if(we>0&&ee>500){Pe.current.length>0&&Pe.current.shift();let he=Pe.current;if(he.length>0){let j=he.reduce((Ge,$e)=>Ge+$e,0);Me(Math.round(j/he.length))}else Me(0)}else{let he=Pe.current;if(he.length>0){let j=he.reduce((Ge,$e)=>Ge+$e,0);Me(Math.round(j/he.length))}else _>0&&Me(Math.round(_))}},750);return()=>clearInterval(fe)},[P]),kr(()=>{if(!P){St.current=[];return}if(W>0){let ee=St.current;(ee.length===0||ee[ee.length-1]!==W)&&(ee.push(W),ee.length>10&&ee.shift())}let fe=()=>{if(!W){Se("#00a564");return}let ee=St.current,he=0;if(ee.length>1){let nt=0;for(let ze=1;ze<ee.length;ze++)nt+=ee[ze]-ee[ze-1];he=nt/(ee.length-1)}let j=Date.now()-W,$e=j>=2500,Tt=!$e&&he>0?Math.min(j,he*3):j,it=Math.max(he,Tt),bt=$e?.4:.2;Xe.current=Xe.current*(1-bt)+it*bt,Se(Dd(Xe.current))};fe();let we=setInterval(fe,100);return()=>clearInterval(we)},[P,W]);let J=()=>{let fe=process.memoryUsage(),we=fe.heapTotal/(1024*1024)>=1024,ee=we?"GB":"MB",he=(j,Ge)=>{let $e=j/(1048576*(Ge?1024:1));return Ge?parseFloat($e.toFixed(2)):Math.round($e)};Ne(ee),be(he(fe.heapTotal,we)),le(he(fe.heapUsed,we))};return kr(()=>{Ar=J,J();let fe=setInterval(()=>{J()},6e4);return()=>{clearInterval(fe),Ar===J&&(Ar=null)}},[]),Ot.createElement(fn,{flexDirection:"row",justifyContent:"space-between",paddingX:1,width:"100%"},Ot.createElement(fn,null,Ot.createElement(fn,{marginRight:1},Ot.createElement(Uo,{color:Y.textMuted},t.toLowerCase()==="flow"?"Studio":t.toLowerCase()==="icu"?"Computer Use":t.toLowerCase()==="flux"?"Workspace":"Omni")),Ot.createElement(Uo,{color:Y.textMuted,dimColor:!0},"\u2503 "),Ot.createElement(fn,null,Ot.createElement(Uo,{color:Y.text,italic:!0},Gl(process.cwd(),35)))),Ot.createElement(fn,null,P&&!V?Ot.createElement(fn,null,Ot.createElement(Uo,{color:tt},"\u25CF ")):null,P&&V&&Ot.createElement(Ot.Fragment,null,Ot.createElement(Uo,{color:Y.textMuted},"~",xe," tok/s"),Ot.createElement(Uo,{color:Y.textMuted,dimColor:!0}," \u2503")),d>0&&Ot.createElement(Ot.Fragment,null,Ot.createElement(fn,{marginX:1},Ot.createElement(Uo,{color:Y.text},Pt(v)," tok",(()=>{let fe=0;if(C==="Current")fe=typeof r=="number"?r:0;else{let we=typeof b=="number"?b:0,ee=typeof y=="number"?y:0;fe=we>0?ee/we*100:0}return fe<1?null:Ot.createElement(Uo,{color:Y.success||"green",dimColor:!0}," [",fe.toFixed(0),"% cached]")})())),Ot.createElement(Uo,{color:Y.textMuted,dimColor:!0},"\u2503")),Ot.createElement(fn,{marginLeft:1},Ot.createElement(Uo,{color:Y.textMuted,bold:!0},me," ",Oe))))}),va=Id;import mt,{useState as xs,useMemo as kd,useEffect as Ba}from"react";import{Box as ro,Text as so,useInput as Ad}from"ink";import Ld from"ink-select-input";var Pd=({label:t,isSelected:m,theme:d="Dark"})=>{let v=ut(d),y=t==="Cancel"||t==="Back"||t.toLowerCase().includes("exit")||t.toLowerCase().includes("back");return mt.createElement(ro,{marginTop:y?1:0,backgroundColor:m?v.highlightBg:void 0,paddingX:1,width:"100%"},mt.createElement(so,{color:m?v.text:v.textMuted,bold:m},m?"\u276F ":" ",t))},Od=8;function _t({title:t,subtitle:m,items:d=[],onSelect:v,theme:y="Dark",searchable:b=!1,maxVisible:r=Od}){let C=ut(y),[w,M]=xs(""),[O,U]=xs(0),[D,P]=xs("list"),W=kd(()=>{if(!b||!w.trim())return d;let me=w.toLowerCase().trim();return d.filter(le=>le.label&&le.label.toLowerCase().includes(me))},[d,w,b]);Ba(()=>{U(0)},[w]);let[X,_]=xs(0);Ba(()=>{_(me=>W.length<=r?0:O<me?O:O>=me+r?O-r+1:me)},[O,W.length,r]),Ad((me,le)=>{if(b){if(le.upArrow){P("list"),U(H=>W.length===0?0:H>0?H-1:W.length-1);return}if(le.downArrow){P("list"),U(H=>W.length===0?0:H<W.length-1?H+1:0);return}if(le.return){W.length>0&&W[O]&&v(W[O]);return}if(le.escape){if(w)M(""),P("list"),U(0);else{let H=d.find(be=>be.value==="Back"||be.label==="Back"||be.value==="Cancel"||be.label==="Cancel");H&&v(H)}return}if(le.backspace||le.delete){P("search"),M(H=>H.slice(0,-1));return}if(me&&!le.ctrl&&!le.meta&&!le.tab){P("search"),M(H=>H+me);return}}},{isActive:b});let V=W.length,Y=X;V<=r?Y=0:Y=Math.max(0,Math.min(X,V-r));let ue=W.slice(Y,Y+r);return b?mt.createElement(ro,{flexDirection:"column",borderStyle:"round",borderColor:C.borderMuted,padding:0,marginTop:0,flexShrink:0,width:"100%"},mt.createElement(ro,{paddingX:1,paddingY:0,marginBottom:0,flexDirection:"row",justifyContent:"space-between"},t?mt.createElement(so,{color:C.text,bold:!0},typeof t=="string"?t.toUpperCase():t):mt.createElement(ro,null),V>0&&mt.createElement(so,{color:C.textMuted},O+1,"/",V)),m&&mt.createElement(ro,{paddingX:1,marginBottom:0},mt.createElement(so,{color:C.textMuted,italic:!0}," ",m)),mt.createElement(ro,{paddingX:1,marginTop:1,marginBottom:1,flexDirection:"row"},mt.createElement(so,{color:D==="search"?C.primary||"cyan":C.textMuted,bold:D==="search"},"\u{1F50D} Search:"),mt.createElement(so,{color:C.text,bold:!0}," ",w),D==="search"?mt.createElement(so,{color:C.primary||"cyan"},"\u2588"):w?null:mt.createElement(so,{color:C.textMuted,italic:!0}," (type to search...)")),mt.createElement(ro,{flexDirection:"column",width:"100%"},W.length===0?mt.createElement(ro,{paddingX:1,marginY:0},mt.createElement(so,{color:C.warning||"yellow",italic:!0}," No matching items found")):ue.map((me,le)=>{let H=Y+le,be=H===O,Oe=me.label==="Cancel"||me.label==="Back"||me.label.toLowerCase().includes("exit")||me.label.toLowerCase().includes("back");return mt.createElement(ro,{key:me.value??me.label??H,marginTop:Oe?1:0,backgroundColor:be?C.highlightBg:void 0,paddingX:1,width:"100%"},mt.createElement(so,{color:be?C.text:C.textMuted,bold:be},be?"\u276F ":" ",me.label))})),mt.createElement(ro,{paddingX:1,marginTop:1},mt.createElement(so,{color:C.textMuted,italic:!0},D==="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)"))):mt.createElement(ro,{flexDirection:"column",borderStyle:"round",borderColor:C.borderMuted,padding:0,marginTop:0,flexShrink:0,width:"100%"},t&&mt.createElement(ro,{paddingX:1,paddingY:0,marginBottom:m?0:1,flexDirection:"row",justifyContent:"space-between"},mt.createElement(so,{color:C.text,bold:!0},typeof t=="string"?t.toUpperCase():t),d.length>r&&mt.createElement(so,{color:C.textMuted,italic:!0},d.length," options")),m&&mt.createElement(ro,{paddingX:1,marginBottom:1},mt.createElement(so,{color:C.textMuted,italic:!0}," ",m)),mt.createElement(ro,{flexDirection:"column",width:"100%"},mt.createElement(Ld,{items:d,onSelect:v,limit:r,itemComponent:me=>mt.createElement(Pd,{...me,theme:y}),indicatorComponent:()=>null})),mt.createElement(ro,{paddingX:1,marginTop:1},mt.createElement(so,{color:C.textMuted,italic:!0},"(Arrows to select \u2022 Enter to confirm)")))}import A,{useState as Yt,useEffect as Lr}from"react";import{Box as He,Text as oe,useInput as Nd}from"ink";import Fd from"ink-text-input";import $d from"v8";import Ea from"os";var _o=[...Object.keys(Vl),"Mystery"],Ho=[{id:"appearance",label:"Appearance",desc:"Customize UI theme & rendering options"},{id:"memory",label:"Personalization",desc:"Manage system context & agent's memory"},{id:"secondaryModels",label:"Secondary Models",desc:"Sub-agents & auto-completion models"},{id:"other",label:"Miscellaneous",desc:"Miscellaneous preferences"},{id:"providers",label:"Providers",desc:"Configure AI models"},{id:"security",label:"Security",desc:"Configure permissions & data safety"},{id:"updater",label:"Updater",desc:"Manage application updates"},{id:"exit",label:"Exit Settings",desc:"Return to chat view"}],Da=t=>{let m=t.autoApproveCommands||"",d=t.autoDisallowCommands||"",v=t.alwaysAskCommands||"",y=t.autoExec===!1&&t.allowExternalAccess===!1&&t.networkAccess===!1&&m===""&&d==="rm -rf, rm -f, del /f, del /q, rd /s, rmdir /s, format, mkfs, dd if=/dev, shred, srm, Remove-Item -Recurse -Force, Initialize-Disk, Clear-Disk, format c:, flashrom, nvram -c"&&v==="killall, pkill, taskkill, shutdown, reboot, init 0, init 6, Stop-Process, Stop-Service, mv /*, move c:\\*, chmod 000, chmod -R 777, chown, icacls, netsh advfirewall, iptables -F, ufw disable, git reset --hard, git clean -fd, npm r, npm uninstall"&&t.autoApproveGit===!1&&t.overwriteProtection!==!1,b=t.autoExec===!0&&t.allowExternalAccess===!1&&t.networkAccess!==!1&&m==="ls, dir, cat, type, echo, pwd, cd, git status, git log, git diff, git branch, git show, help, mkdir, touch, md, whoami, hostname, ps, Get-Process, date, time, mkdir"&&d==="rm -rf, rm -f, del /f, del /q, rd /s, rmdir /s, format, mkfs, dd if=/dev, shred, srm, Remove-Item -Recurse -Force, Initialize-Disk, Clear-Disk, format c:, flashrom, nvram -c"&&v==="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&&t.overwriteProtection!==!1,r=t.autoExec===!0&&t.allowExternalAccess===!0&&t.networkAccess!==!1&&m==="ls, dir, cat, type, echo, pwd, cd, git status, git log, git diff, git branch, git show, help, mkdir, touch, md, whoami, hostname, ps, Get-Process, date, time, mkdir"&&d===""&&v==="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&&t.overwriteProtection===!1;return y?"Strict":b?"Balanced":r?"Autonomous":t.sandboxPreset||"Custom"},Pr=t=>!t||t.trim()===""?"None":t.length>40?t.substring(0,40)+"...":t;function gs({systemSettings:t,setSystemSettings:m,apiTier:d,setActiveView:v,setInputConfig:y,saveSettings:b,quotas:r,setMessages:C,aiProvider:w,autoCompletion:M,setAutoCompletion:O,profileData:U,setProfileData:D,initialSelectingTheme:P=!1,onCloseTheme:W=null,setProviderReturnView:X=null,setApiKey:_=null,initAI:V=null}){let Y=t.theme==="Chaos"||t.theme==="Mystery"?"Mystery":t.theme||"Dark",ue=_o.indexOf(Y),[me,le]=Yt("categories"),[H,be]=Yt(0),[Oe,Ne]=Yt(0),[tt,Se]=Yt("Sandbox"),[xe,Me]=Yt(null),[St,Xe]=Yt(""),[Pe,Ce]=Yt(P),[J,fe]=Yt(ue>=0?ue:0),[we,ee]=Yt(t.theme||"Dark"),[he,j]=Yt(!1),[Ge,$e]=Yt("subAgent"),[Tt,it]=Yt(0),[bt,nt]=Yt(0),[ze,ae]=Yt(""),[De,ct]=Yt("list"),[dt,We]=Yt({});Lr(()=>{(async()=>{let T=["Google","DeepSeek","OpenRouter","NVIDIA","Mistral","Ollama","InferX","SenseNova","AIHubMix","Poolside","9router","ExpLabs","TokenHarbor","Infron","APInex","xKiro","c_openai"],k={};for(let ye of T)try{await un(ye,{silent:!0})&&(k[ye]=!0)}catch{}We(k)})()},[]);let Et=A.useMemo(()=>{let ce=["Google","DeepSeek","OpenRouter","NVIDIA","Mistral","Ollama","InferX","SenseNova","AIHubMix","Poolside","9router","ExpLabs","TokenHarbor","Infron","APInex","xKiro","c_openai"],k=!!(process.env.SUBAGENT_MODEL&&process.env.SUBAGENT_MODEL.trim())?`ENV (${process.env.SUBAGENT_MODEL.trim()})`:"ENV",ye=[{label:"Default (use the current model)",value:"Default",isHeader:!1},{label:k,value:"ENV",isHeader:!1}],Ae=r?.providerTiers?.[w]||d||"Free",ot=dn(w,Ae,t?.customOpenAIBaseUrl)||[];ot.length>0&&(ye.push({label:`\u2500\u2500 ${w.toUpperCase()}${Ae!=="Free"?` (${Ae})`:""} \u2500\u2500`,isHeader:!0}),ot.forEach(lt=>{let Qe=typeof lt=="string"?lt:lt.cmd||lt.name||lt.id||String(lt);Qe&&!Qe.trim().startsWith("---")&&!Qe.startsWith(`
|
|
43
|
-
---`)&&ye.push({label:Qe,value:Qe,isHeader:!1,provider:w})}));for(let lt of ce)if(lt!==w&&dt[lt]){let Qe=r?.providerTiers?.[lt]||"Free",uo=dn(lt,Qe)||[];uo.length>0&&(ye.push({label:`\u2500\u2500 ${lt.toUpperCase()}${Qe!=="Free"?` (${Qe})`:""} \u2500\u2500`,isHeader:!0}),uo.forEach(Ye=>{let Nt=typeof Ye=="string"?Ye:Ye.cmd||Ye.name||Ye.id||String(Ye);Nt&&!Nt.trim().startsWith("---")&&!Nt.startsWith(`
|
|
44
|
-
---`)&&ye.push({label:Nt,value:Nt,isHeader:!1,provider:lt})}))}return ye},[w,d,r,dt]),Ke=A.useMemo(()=>{if(!ze.trim())return Et;let ce=ze.trim().toLowerCase(),T=[],k=null;for(let ye of Et)ye.isHeader?k=ye:(ye.label.toLowerCase().includes(ce)||ye.value&&ye.value.toLowerCase().includes(ce))&&(k&&!T.includes(k)&&T.push(k),T.push(ye));return T},[Et,ze]);Lr(()=>{if(he){let ce=Ke.findIndex(T=>!T.isHeader);it(ce>=0?ce:0),nt(0)}},[ze]),Lr(()=>{if(he){if(Ke.length===0){it(0),nt(0);return}if(Tt>=Ke.length||Ke[Tt]?.isHeader){let ce=Ke.findIndex(T=>!T.isHeader);it(ce>=0?ce:0)}}},[Ke,he]);let[co,$]=Yt(0),[nn,ir]=Yt(0),[$r,wn]=Yt("MB"),[Ur,Tn]=Yt(!1);Lr(()=>{let ce=!1;return import("./exec_command-6V5SM6WI.js").then(T=>{ce||Tn(!!T.isPtyAvailable)}).catch(()=>{}),()=>{ce=!0}},[]),Lr(()=>{let ce=$d.getHeapStatistics().heap_size_limit,T=ce>=1024*1024*1024,k=T?"GB":"MB",ye=T?1024*1024*1024:1024*1024;ir(parseFloat((ce/ye).toFixed(2))),wn(k);let Ae=()=>{let uo=process.memoryUsage().rss/ye,Ye=T?parseFloat(uo.toFixed(2)):Math.round(uo);$(Ye)};Ae();let ot=setInterval(()=>{Ae()},3e4);return()=>clearInterval(ot)},[]);let Ss=ce=>{switch(ce){case"providers":{let T=[{label:"Current Provider",value:"aiProvider",status:w==="c_openai"?"Custom (OpenAI)":w}];return w==="Ollama"&&T.push({label:"Endpoint",value:"ollamaEndpoint",status:t.ollamaEndpoint||"Cloud"}),(w==="c_openai"||w==="Custom (OpenAI)")&&(T.push({label:"Base URL",value:"customOpenAIBaseUrl",status:t.customOpenAIBaseUrl||"Not Configured"}),T.push({label:"API Key (if needed)",value:"customOpenAIKey",status:dt.c_openai?"Set":"None"})),T}case"appearance":return[{label:"Theme",value:"theme",status:t.theme||"Dark"},{label:"Loading Phrases",value:"loadingPhrases",status:t.loadingPhrases!==!1?"ON":"OFF"},{label:"Progressive Rendering [EXPERIMENTAL]",value:"progressiveRendering",status:t.progressiveRendering?"ON":"OFF"},{label:"Show TPM Estimate",value:"showTPMEstimate",status:t.showTPMEstimate?"ON":"OFF"},{label:"Verbose Thinking",value:"preserveThinking",status:t.preserveThinking!==!1?"ON":"OFF"}];case"memory":return[{label:"Base Personality",value:"profilePreset",status:U?.preset||"Default"},{label:"Nickname",value:"profileNickname",status:U?.nickname||"None"},{label:"Custom Instructions",value:"profileInstructions",status:Pr(U?.instructions)},{label:"Toggle Memory [Legacy]",value:"memory",status:t.memory?"ON":"OFF"}];case"security":return[{label:"Sandbox Preset",value:"sandboxPreset",status:Da(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:Pr(t.alwaysAskCommands),section:"Sandbox"},{label:"Always Ask Files/Paths",value:"alwaysAskFiles",status:Pr(t.alwaysAskFiles||".env, .env.*, *.env"),section:"Sandbox"},{label:"Auto Approve Commands",value:"autoApprove",status:Pr(t.autoApproveCommands),section:"Sandbox"},{label:"Auto Disapprove Commands",value:"autoDisallow",status:Pr(t.autoDisallowCommands),section:"Sandbox"},{label:"Auto Approve Git Commits",value:"autoApproveGit",status:t.autoApproveGit?"ON":"OFF",section:"Sandbox"},{label:"Overwrite Protection",value:"overwriteProtection",status:t.overwriteProtection!==!1?"ON":"OFF",section:"Sandbox"},{label:"Advanced Recovery [EXPERIMENTAL]",value:"advanceRollback",status:t.advanceRollback?"ON":"OFF",section:"Other"},{label:"Auto-Delete History",value:"autoDelete",status:t.autoDeleteHistory||"30d",section:"Other"},{label:"Save AppData Externally",value:"externalData",status:t.useExternalData?"ON":"OFF",section:"Other"},{label:"Agent Clipboard Context",value:"clipboardContext",status:t.clipboardContext?"ON":"OFF",section:"Other"},{label:"Loop Limits",value:"loopLimits",status:t.loopLimits||"Default",section:"Other"}].filter(ye=>ye.section.toLowerCase()===tt.toLowerCase());case"updater":return[{label:"Auto-Update",value:"autoUpdate",status:t.autoUpdate?"ON":"OFF"},{label:"Preferred Package Manager",value:"updateManager",status:(t.updateManager||"npm")==="custom"?"Custom":(t.updateManager||"npm").toUpperCase()}];case"secondaryModels":return[{label:"Sub-Agents",value:"subAgents",status:t.subAgents!==!1?"ON":"OFF"},{label:"Sub-Agent Model",value:"subAgentModel",status:t.CustomSubAgent&&t.SubAgentModel?t.SubAgentModel:"Default"},{label:"Enable Auto-Completion",value:"autoCompletionEnabled",status:M?.enabled?"ON":"OFF"},{label:"Auto-Completion Model",value:"autoCompletionModel",status:M?.model&&M.model!=="Default"?M.model:"Default"},{label:"Commit Message Model",value:"commitMessageModel",status:t.commitMessageModel&&t.commitMessageModel!=="Default"?t.commitMessageModel:"Default"}];case"other":return[{label:"Directory Tree Design",value:"indentationTree",status:t.indentationTree!==!1?"Modern":"Legacy"},{label:"Compact Large Tool Results",value:"compressToolResults",status:t.compressToolResults?"ON":"OFF"},{label:"Auto Truncate Results",value:"autoTruncateResults",status:t.autoTruncateResults?"ON":"OFF"},{label:"Agent Finish Notification",value:"agentFinishSound",status:t.agentFinishSound?"ON":"OFF"},{label:"Image History for CU",value:"imageHistoryCU",status:t.imageHistoryCU||"Standard"},{label:"Context Length",value:"contextLength",status:t.contextLength||"256k"},{label:"Keep Reasoning Context",value:"keepReasoningContext",status:t.keepReasoningContext?"ON":"OFF"},{label:"Auto Exclude Metadata",value:"autoExcludeMetadata",status:t.autoExcludeMetadata?"ON":"OFF"},{label:"Disable Todo",value:"disableTodo",status:t.disableTodo?"ON":"OFF"},...process.platform==="win32"?[{label:"Prefer Bash",value:"preferBash",status:t.preferBash!==!1?"ON":"OFF"}]:[],{label:"Cache Calculate Mode",value:"cacheCalculateMode",status:t.cacheCalculateMode||"Session"}];default:return[]}},qe=Ho[H].id,jt=Ss(qe);Nd((ce,T)=>{if(he){if(T.tab){ct(k=>k==="search"?"list":"search");return}if(De==="search"){T.escape?j(!1):T.downArrow||T.return?ct("list"):T.backspace||T.delete?ae(k=>k.slice(0,-1)):ce&&!T.ctrl&&!T.meta&&ce.length===1&&ae(k=>k+ce);return}if(T.upArrow)it(k=>{if(Ke.length===0)return 0;let ye=(k-1+Ke.length)%Ke.length,Ae=0;for(;Ke[ye]?.isHeader&&Ae<Ke.length;)ye=(ye-1+Ke.length)%Ke.length,Ae++;return ye});else if(T.downArrow)it(k=>{if(Ke.length===0)return 0;let ye=(k+1)%Ke.length,Ae=0;for(;Ke[ye]?.isHeader&&Ae<Ke.length;)ye=(ye+1)%Ke.length,Ae++;return ye});else if(T.return){let k=Ke[Tt];if(k&&!k.isHeader){let ye=k.value==="Default";Ge==="autoCompletion"?O(Ae=>{let ot=ye?"":k.provider||"",lt={...Ae,model:k.value,provider:ot,baseUrl:ye?"":$l[ot]||""};return b({autoCompletion:lt,apiTier:d,quotas:r}),lt}):m(Ge==="commitMessage"?Ae=>{let ot={...Ae,commitMessageModel:ye?"Default":k.value,commitMessageProvider:ye?"":k.provider||""};return b({systemSettings:ot,apiTier:d,quotas:r}),ot}:Ae=>{let ot={...Ae,CustomSubAgent:!ye,SubAgentModel:k.value,SubAgentProvider:ye?"":k.provider||""};return b({systemSettings:ot,apiTier:d,quotas:r}),ot}),j(!1)}}else T.escape?j(!1):ce&&!T.ctrl&&!T.meta&&ce.length===1&&(ae(k=>k+ce),ct("search"));return}if(Pe){if(T.upArrow){let k=(J-1+_o.length)%_o.length;fe(k)}else if(T.downArrow){let k=(J+1)%_o.length;fe(k)}else if(T.return){let k=_o[J];m(ye=>{let Ae={...ye,theme:k};return b({systemSettings:Ae,apiTier:d,quotas:r}),Ae}),W?W():Ce(!1)}else T.escape&&(W?W():Ce(!1));return}if(xe){T.escape&&Me(null);return}if(me==="categories")T.upArrow?be(k=>(k-1+Ho.length)%Ho.length):T.downArrow?be(k=>(k+1)%Ho.length):T.return||T.rightArrow?Ho[H].id==="exit"?v("chat"):(le("items"),Ne(0)):T.escape&&v("chat");else if(me==="items"){if(qe==="security"&&(T.tab||ce===" ")){Se(k=>k==="Sandbox"?"Other":"Sandbox"),Ne(0);return}if(T.upArrow)Ne(k=>(k-1+jt.length)%jt.length);else if(T.downArrow)Ne(k=>(k+1)%jt.length);else if(T.leftArrow)qe==="security"&&tt==="Other"?(Se("Sandbox"),Ne(0)):le("categories");else if(T.rightArrow&&qe==="security"&&tt==="Sandbox")Se("Other"),Ne(0);else if(T.escape)le("categories");else if(T.return){let k=jt[Oe];_r(k)}}});let _r=ce=>{if(ce.value==="profilePreset"){let T=["Default","Sassy","Friendly","Playful","Efficient","Professional"],k=U?.preset||"Default",Ae=(T.indexOf(k)+1)%T.length,ot=T[Ae>=0?Ae:0],lt={...U||{},preset:ot};D&&D(lt),b({profileData:lt,systemSettings:t,apiTier:d,quotas:r})}else if(ce.value==="profileNickname")Me("profileNickname"),Xe(U?.nickname||"");else if(ce.value==="profileInstructions")Me("profileInstructions"),Xe(U?.instructions||"");else if(ce.value==="memory")m(T=>({...T,memory:!T.memory}));else if(ce.value==="sandboxPreset"){let T=Da(t),k=["Autonomous","Balanced","Strict"],Ae=(k.indexOf(T)+1)%k.length,ot=k[Ae];m(lt=>{let Qe={...lt,sandboxPreset:ot};return ot==="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,Qe.overwriteProtection=!0):ot==="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,Qe.overwriteProtection=!0):ot==="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.overwriteProtection=!1),Qe})}else if(ce.value==="autoExec")t.autoExec?m(T=>({...T,autoExec:!1,sandboxPreset:"Custom"})):t.allowExternalAccess?v("doubleDanger"):v("autoExecDanger");else if(ce.value==="externalAccess")t.allowExternalAccess?m(T=>({...T,allowExternalAccess:!1,sandboxPreset:"Custom"})):t.autoExec?v("doubleDanger"):v("externalDanger");else if(ce.value==="networkAccess")m(T=>({...T,networkAccess:T.networkAccess===!1,sandboxPreset:"Custom"}));else if(ce.value==="alwaysAsk")Me("alwaysAskCommands"),Xe(t.alwaysAskCommands||"");else if(ce.value==="alwaysAskFiles")Me("alwaysAskFiles"),Xe(t.alwaysAskFiles||".env, .env.*, *.env");else if(ce.value==="autoApprove")Me("autoApproveCommands"),Xe(t.autoApproveCommands||"");else if(ce.value==="autoDisallow")Me("autoDisallowCommands"),Xe(t.autoDisallowCommands||"");else if(ce.value==="autoApproveGit")m(T=>({...T,autoApproveGit:!T.autoApproveGit,sandboxPreset:"Custom"}));else if(ce.value==="overwriteProtection")m(T=>({...T,overwriteProtection:T.overwriteProtection===!1,sandboxPreset:"Custom"}));else if(ce.value==="customOpenAIBaseUrl")Me("customOpenAIBaseUrl"),Xe(t.customOpenAIBaseUrl||"");else if(ce.value==="customOpenAIKey")Me("customOpenAIKey"),Xe("");else if(ce.value==="ollamaEndpoint")m(T=>{let k=T.ollamaEndpoint==="Local"?"Cloud":"Local",ye={...T,ollamaEndpoint:k};return b({systemSettings:ye,apiTier:d,quotas:r}),ye});else if(ce.value==="apiTier")v("apiTier");else if(ce.value==="aiProvider")X&&X("settings"),v("selectProvider");else if(ce.value==="advanceRollback")t.advanceRollback?m(T=>{let k={...T,advanceRollback:!1};return b({systemSettings:k,apiTier:d,quotas:r}),k}):v("advanceRollbackDanger");else if(ce.value==="autoDelete"){let T=["1d","7d","30d"],ye=(T.indexOf(t.autoDeleteHistory||"30d")+1)%T.length;m(Ae=>({...Ae,autoDeleteHistory:T[ye]}))}else if(ce.value==="autoUpdate")m(T=>({...T,autoUpdate:!T.autoUpdate}));else if(ce.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||""}),v("input");else{let T={...t,useExternalData:!1};m(T),b({systemSettings:T,apiTier:d,quotas:r}),C(k=>[...k,{id:Date.now(),role:"system",text:"[STORAGE RESET] Flux Flow will return to default ~/.fluxflow after restart."}]),v("chat")}else if(ce.value==="updateManager")v("updateManager");else if(ce.value==="parserDownload")v("parserDownload");else if(ce.value==="indentationTree")m(T=>{let k={...T,indentationTree:T.indentationTree===!1};return b({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="compressToolResults")m(T=>{let k={...T,compressToolResults:!T.compressToolResults};return b({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="autoTruncateResults")m(T=>{let k={...T,autoTruncateResults:!T.autoTruncateResults};return b({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="agentFinishSound")m(T=>{let k={...T,agentFinishSound:!T.agentFinishSound};return b({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="loopLimits"){let T=["Default","Extended","ENV"],ye=(T.indexOf(t.loopLimits||"Default")+1)%T.length;m(Ae=>{let ot={...Ae,loopLimits:T[ye]};return b({systemSettings:ot,apiTier:d,quotas:r}),ot})}else if(ce.value==="imageHistoryCU"){let T=["Low","Standard","Extended","Max"],ye=(T.indexOf(t.imageHistoryCU||"Standard")+1)%T.length;m(Ae=>{let ot={...Ae,imageHistoryCU:T[ye]};return b({systemSettings:ot,apiTier:d,quotas:r}),ot})}else if(ce.value==="contextLength"){let T=["16k","32k","64k","128k","256k","512k","1M"],ye=(T.indexOf(t.contextLength||"256k")+1)%T.length;m(Ae=>{let ot={...Ae,contextLength:T[ye]};return b({systemSettings:ot,apiTier:d,quotas:r}),ot})}else if(ce.value==="keepReasoningContext")m(T=>{let k={...T,keepReasoningContext:!T.keepReasoningContext};return b({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="autoExcludeMetadata")m(T=>{let k={...T,autoExcludeMetadata:!T.autoExcludeMetadata};return b({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="disableTodo")m(T=>{let k={...T,disableTodo:!T.disableTodo};return b({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="preferBash")m(T=>{let k=T.preferBash!==!1,ye={...T,preferBash:!k};return b({systemSettings:ye,apiTier:d,quotas:r}),ye});else if(ce.value==="cacheCalculateMode"){let T=["Session","Current"],ye=(T.indexOf(t.cacheCalculateMode||"Session")+1)%T.length;m(Ae=>{let ot={...Ae,cacheCalculateMode:T[ye]};return b({systemSettings:ot,apiTier:d,quotas:r}),ot})}else if(ce.value==="subAgents")m(T=>{let k={...T,subAgents:T.subAgents===!1};return b({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="subAgentModel"){let T=t.CustomSubAgent&&t.SubAgentModel?t.SubAgentModel:"Default",k=Ke.findIndex(ye=>ye.value===T);it(k>=0?k:0),$e("subAgent"),j(!0)}else if(ce.value==="autoCompletionEnabled")O(T=>{let k={...T,enabled:!T.enabled};return b({autoCompletion:k,apiTier:d,quotas:r}),k});else if(ce.value==="clipboardContext")m(T=>{let k={...T,clipboardContext:!T.clipboardContext};return b({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="autoCompletionModel"){let T=M?.model||"Default",k=Ke.findIndex(ye=>ye.value===T);it(k>=0?k:0),$e("autoCompletion"),j(!0)}else if(ce.value==="commitMessageModel"){let T=t.commitMessageModel||"Default",k=Ke.findIndex(ye=>ye.value===T);it(k>=0?k:0),$e("commitMessage"),j(!0)}else if(ce.value==="preserveThinking")m(T=>{let k={...T,preserveThinking:T.preserveThinking===!1};return wa(k.preserveThinking),b({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="loadingPhrases")m(T=>{let k={...T,loadingPhrases:T.loadingPhrases===!1};return b({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="progressiveRendering")m(T=>{let k={...T,progressiveRendering:!T.progressiveRendering};return b({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="showTPMEstimate")m(T=>{let k={...T,showTPMEstimate:!T.showTPMEstimate};return b({systemSettings:k,apiTier:d,quotas:r}),k});else if(ce.value==="theme"){let T=t.theme==="Chaos"||t.theme==="Mystery"?"Mystery":t.theme||"Dark",k=_o.indexOf(T);fe(k>=0?k:0),ee(t.theme||"Dark"),Ce(!0)}},Be=ut(t.theme);if(he){let ce=Ge==="autoCompletion"?M?.model||"Default":Ge==="commitMessage"?t.commitMessageModel||"Default":t.CustomSubAgent&&t.SubAgentModel?t.SubAgentModel:"Default",T=15,k=bt;Tt<k?k=Tt:Tt>=k+T&&(k=Tt-T+1),k=Math.max(0,Math.min(k,Math.max(0,Ke.length-T))),k!==bt&&nt(k);let ye=Ke.slice(k,k+T);return A.createElement(He,{flexDirection:"column",borderStyle:"round",borderColor:Be.border,padding:1,width:"100%",minHeight:32},A.createElement(He,{marginBottom:1,flexDirection:"row",justifyContent:"space-between"},A.createElement(oe,{color:Be.text,bold:!0,underline:!0},Ge==="autoCompletion"?"Select Auto-Completion Model:":Ge==="commitMessage"?"Select Commit Message Model:":"Select Sub-Agent Model:"),Ke.length>0&&A.createElement(oe,{color:"gray"},Tt+1,"/",Ke.length)),A.createElement(He,{borderStyle:"single",borderColor:De==="search"?Be.primary||"cyan":"gray",paddingX:1,marginBottom:1},A.createElement(oe,{color:De==="search"?Be.primary||"cyan":"gray",bold:!0},"\u{1F50D} Search: "," "),A.createElement(oe,{color:Be.text},ze),De==="search"&&A.createElement(oe,{color:Be.primary||"cyan"},"\u2588"),!ze&&De!=="search"&&A.createElement(oe,{color:"gray",italic:!0},"(Press TAB or type to filter models...)")),A.createElement(He,{flexDirection:"column",flexGrow:1,height:T},ye.length>0?ye.map((Ae,ot)=>{let lt=k+ot;if(Ae.isHeader)return A.createElement(He,{key:`hdr-${lt}`,paddingX:1},A.createElement(oe,{color:"gray",bold:!0,underline:!0},Ae.label));let Qe=Tt===lt&&De==="list",uo=ce===Ae.value;return A.createElement(He,{key:`item-${Ae.value}-${lt}`,paddingX:1,backgroundColor:Qe?Be.highlightBg:void 0},A.createElement(oe,{color:Qe?Be.text:Be.textDim,bold:Qe},Qe?"\u276F ":" ",Ae.label,uo?A.createElement(oe,{color:Be.primary||"cyan",italic:!0}," (active)"):""))}):A.createElement(He,{paddingX:1},A.createElement(oe,{color:"gray",italic:!0},'No models matching "',ze,'"'))),A.createElement(He,{paddingX:1,marginTop:1,flexDirection:"row",justifyContent:"space-between"},A.createElement(oe,{color:"gray",italic:!0},"TAB to switch search/list \u2022 \u25B2\u25BC Navigate \u2022 ENTER to Select \u2022 ESC to Cancel"),A.createElement(oe,{color:De==="search"?Be.primary||"cyan":"gray",bold:!0},"[",De.toUpperCase()," MODE]")))}if(Pe){let ce=_o[J],T=ut(ce);return A.createElement(He,{flexDirection:"column",borderStyle:"round",borderColor:T.border,padding:1,width:"100%",minHeight:32},A.createElement(He,{marginBottom:1},A.createElement(oe,{color:T.text,bold:!0},"Choose your color scheme:")),A.createElement(He,{flexDirection:"row",width:"100%",flexGrow:1},A.createElement(He,{flexDirection:"column",width:"30%",paddingRight:1},_o.map((k,ye)=>{let Ae=J===ye,ot=(t.theme||"Dark")===k,lt=k==="Forest Sprite"||k==="Spookfest";return A.createElement(He,{key:k,paddingX:0},A.createElement(oe,{color:Ae?T.text:T.textDim,bold:Ae},Ae?"> ":" ",k,lt&&A.createElement(oe,{color:Ae?T.success||"#52b788":"green",bold:!0}," \u2605"),ot?A.createElement(oe,{color:T.primary||"cyan",italic:!0}," (saved)"):""))})),A.createElement(He,{flexDirection:"column",flexGrow:1,borderStyle:"round",borderColor:T.borderMuted,paddingX:2,paddingY:1,backgroundColor:T.cardBg},A.createElement(He,{marginBottom:1},A.createElement(oe,{color:T.secondary||"cyan",bold:!0},"> ","you: "),A.createElement(oe,{color:T.text},"add a greeting function")),A.createElement(He,{marginBottom:1},A.createElement(oe,{color:T.success||"green"}," Here's the change:")),A.createElement(He,{flexDirection:"column",marginLeft:2,marginBottom:1},A.createElement(oe,null,A.createElement(oe,{color:T.textDim},"3 "),Bt(' import "fmt"',".go",void 0)),A.createElement(oe,{color:T.textDim},"4"),A.createElement(He,{backgroundColor:T.diffRemovalBg},A.createElement(oe,null,A.createElement(oe,{color:T.diffRemovalNum||T.diffRemovalText},"5 "),A.createElement(oe,{color:T.diffRemovalPrefix||T.diffRemovalText},"- "),Bt("func ",".go",void 0),Bt("main()",".go",void 0,T.diffRemovalHighlightBg),Bt(" {",".go",void 0))),A.createElement(He,{backgroundColor:T.diffAdditionBg},A.createElement(oe,null,A.createElement(oe,{color:T.diffAdditionNum||T.diffAdditionText},"5 "),A.createElement(oe,{color:T.diffAdditionPrefix||T.diffAdditionText},"+ "),Bt("func ",".go",void 0),Bt("greet(name string)",".go",void 0,T.diffAdditionHighlightBg),Bt(" {",".go",void 0))),A.createElement(He,{backgroundColor:T.diffAdditionBg},A.createElement(oe,null,A.createElement(oe,{color:T.diffAdditionNum||T.diffAdditionText},"6 "),A.createElement(oe,{color:T.diffAdditionPrefix||T.diffAdditionText},"+ "),A.createElement(oe,null," "),Bt('fmt.Printf("Hello, %s!\\n", name)',".go",void 0,T.diffAdditionHighlightBg))),A.createElement(oe,null,"7 }")),A.createElement(He,{flexDirection:"column",marginTop:1,marginBottom:1},A.createElement(oe,{color:T.textDim},"\u25BE Thought Process"),A.createElement(oe,{color:T.textMuted}," I need to add a greeting function. I'll use fmt.Printf.")),A.createElement(He,{flexDirection:"column"},A.createElement(oe,null,A.createElement(oe,{color:T.warning||"yellow"},"\u2699 tool: "),A.createElement(oe,{color:T.text},"write_file main.go")),A.createElement(oe,null,A.createElement(oe,{color:T.accent||"magenta"},"\u29BF task: "),A.createElement(oe,{color:T.text},"Implementing greeting")),A.createElement(oe,null,A.createElement(oe,{color:T.danger||"red"},"X error: "),A.createElement(oe,{color:T.text},"compilation failed")),A.createElement(oe,null,A.createElement(oe,{color:T.warning||"yellow"},"\u26A0 warning: "),A.createElement(oe,{color:T.text},"deprecation warning")),A.createElement(oe,null,A.createElement(oe,{color:T.info||"blue"},"\u2192 link: "),A.createElement(oe,{color:T.info||"blue",underline:!0},"file:///path/to/main.go")),A.createElement(oe,null,A.createElement(oe,{color:T.accent||"magenta"},"\u2605 accent: "),A.createElement(oe,{color:T.text},"highlighted text")),A.createElement(oe,{color:T.textDim},"\xB7 dim: press Enter to continue")))),A.createElement(He,{paddingX:1,marginTop:1,flexDirection:"row",justifyContent:"space-between"},A.createElement(oe,{color:"gray",italic:!0},"\u25B2\u25BC Navigate \u2022 ENTER to Select \u2022 ESC to Cancel"),A.createElement(oe,{color:"gray"},"Previewing: ",_o[J],_o[J]==="Forest Sprite"?" \u2605":"")))}return A.createElement(He,{flexDirection:"column",borderStyle:"round",borderColor:Be.border,padding:0,width:"100%",minHeight:26},A.createElement(He,{paddingX:1,paddingY:0,marginBottom:0,borderStyle:"single",borderColor:Be.borderMuted,width:"100%"},A.createElement(oe,{color:Be.text,bold:!0},"SYSTEM CONFIGURATION")),A.createElement(He,{flexDirection:"row",width:"100%",minHeight:20},A.createElement(He,{flexDirection:"column",width:"30%",maxWidth:40,borderStyle:"round",borderColor:me==="categories"?Be.border:Be.borderMuted,padding:1,paddingY:0},A.createElement(He,{marginBottom:1},A.createElement(oe,{color:me==="categories"?Be.text:Be.textDim,bold:!0,underline:!0},"CATEGORIES")),Ho.map((ce,T)=>{let k=H===T,ye=ce.id==="exit";return A.createElement(He,{key:ce.id,marginTop:ye?9:0,backgroundColor:k?me==="categories"?Be.highlightBg:Be.cardBg:void 0,paddingX:1},A.createElement(oe,{color:k&&me==="categories"?Be.text:Be.textDim,bold:k},k?"\u276F ":" ",ce.label))})),A.createElement(He,{flexDirection:"column",flexGrow:1,borderStyle:"round",borderColor:me==="items"?Be.border:Be.borderMuted,paddingX:1,marginLeft:1,paddingY:0},A.createElement(He,{marginBottom:1,flexDirection:"row",justifyContent:"space-between",alignItems:"center"},A.createElement(oe,{color:me==="items"?Be.text:Be.textDim,bold:!0,underline:!0},Ho[H].label.toUpperCase().includes("EXIT")?"Runtime Information":`${Ho[H].label} Settings`),qe==="security"&&A.createElement(He,{flexDirection:"row"},A.createElement(He,{paddingX:1,backgroundColor:tt==="Sandbox"?me==="items"?Be.highlightBg:Be.cardBg:void 0},A.createElement(oe,{bold:tt==="Sandbox",color:tt==="Sandbox"?Be.primary||"cyan":Be.textDim},"[ Sandbox ]")),A.createElement(He,{paddingX:1,backgroundColor:tt==="Other"?me==="items"?Be.highlightBg:Be.cardBg:void 0},A.createElement(oe,{bold:tt==="Other",color:tt==="Other"?Be.primary||"cyan":Be.textDim},"[ Others ]")))),jt.length>0?(()=>{let ce=null,T=[],k=Ye=>(Ye||"").split(",").map(Nt=>Nt.trim().toLowerCase()).filter(Boolean),ye=k(t.autoApproveCommands),Ae=k(t.autoDisallowCommands),ot=k(t.alwaysAskCommands),lt=[...ye,...Ae,...ot],Qe=new Set(lt),uo=qe==="security"&<.length!==Qe.size;return jt.forEach((Ye,Nt)=>{let yn=me==="items"&&Oe===Nt,Cn=Ye.label.length,vs=Math.max(2,38-Cn),vt=".".repeat(vs),ie=et=>qe==="security"?(et.value==="autoExec"||et.value==="externalAccess")&&et.status==="ON"?Be.statusOn:Be.statusOff:et.status?.startsWith("\u2713")?Be.statusOn:et.status?.startsWith("\u26A0")?Be.statusOff:et.status==="ON"?Be.statusOn:et.status==="OFF"?Be.statusOff:Be.text;Ye.section&&Ye.section!==ce&&qe!=="security"&&(ce=Ye.section,T.push(A.createElement(He,{key:`sec-hdr-${Ye.section}`,marginTop:T.length>0?1:0,marginBottom:0,paddingX:1},A.createElement(oe,{color:"gray",bold:!0,underline:!0},Ye.section.toUpperCase()))));let Fn=yn&&xe&&(xe==="alwaysAskCommands"&&Ye.value==="alwaysAsk"||xe==="alwaysAskFiles"&&Ye.value==="alwaysAskFiles"||xe==="autoApproveCommands"&&Ye.value==="autoApprove"||xe==="autoDisallowCommands"&&Ye.value==="autoDisallow"||xe==="customOpenAIBaseUrl"&&Ye.value==="customOpenAIBaseUrl"||xe==="customOpenAIKey"&&Ye.value==="customOpenAIKey"||xe==="profileNickname"&&Ye.value==="profileNickname"||xe==="profileInstructions"&&Ye.value==="profileInstructions"),Hr=Ye.value==="alwaysAsk"||Ye.value==="alwaysAskFiles"||Ye.value==="autoApprove"||Ye.value==="autoDisallow"||Ye.value==="profileInstructions",Wr=Ye.value==="parserDownload";T.push(A.createElement(He,{key:Ye.value,flexDirection:"column"},A.createElement(He,{backgroundColor:yn&&!Fn?Be.highlightBg:void 0,paddingX:2},A.createElement(oe,{color:yn?Be.text:Be.textDim,bold:yn},yn?"\u276F ":" ",Ye.label),!Hr&&!Wr&&A.createElement(A.Fragment,null,A.createElement(oe,{color:"gray"},vt),A.createElement(oe,{color:ie(Ye),bold:!0},Ye.value==="aiProvider"?Ye.status:`[ ${Ye.status} ]`))),Hr&&!Fn&&Ye.status!=="None"&&A.createElement(He,{paddingX:4,marginBottom:1},A.createElement(oe,{color:"gray"},"\u21B3 ",Ye.status)),Fn&&A.createElement(He,{flexDirection:"column",marginLeft:4,marginBottom:1},A.createElement(He,{paddingX:1,borderStyle:"single",borderColor:"gray",flexDirection:"row"},A.createElement(oe,{color:"gray",bold:!0},"> "," "),A.createElement(Fd,{value:St,onChange:et=>{let kt=xe==="profileNickname"?20:xe==="profileInstructions"?250:1/0;Xe(et.slice(0,kt))},onSubmit:async et=>{if(xe==="customOpenAIBaseUrl"){let kt=et.trim().replace(/\/+$/,""),Ie={...t,customOpenAIBaseUrl:kt};m(Ie),b({systemSettings:Ie,apiTier:d,quotas:r})}else if(xe==="customOpenAIKey"){let kt=et.trim(),{replaceActiveProviderKey:Ie}=await import("./secrets-JMSL57D2.js"),io=await Ie("c_openai",kt);kt&&(!io||io.ok!==!1)&&(We(Oo=>({...Oo,c_openai:!0})),w==="c_openai"&&(_&&_(kt),V&&V(kt,{aiProvider:"c_openai"})))}else if(xe==="profileNickname"){let kt=et.trim().slice(0,20),Ie={...U||{},nickname:kt};D&&D(Ie),b({profileData:Ie,systemSettings:t,apiTier:d,quotas:r})}else if(xe==="profileInstructions"){let kt=et.trim().slice(0,250),Ie={...U||{},instructions:kt};D&&D(Ie),b({profileData:Ie,systemSettings:t,apiTier:d,quotas:r})}else{let kt={...t,[xe]:et.trim(),sandboxPreset:"Custom"};m(kt),b({systemSettings:kt,apiTier:d,quotas:r})}Me(null)}})),A.createElement(oe,{color:"gray",italic:!0}," ",xe==="customOpenAIBaseUrl"?"Enter Base URL (.../v1) \u2022 Press Enter to save, Esc to cancel":xe==="customOpenAIKey"?"Enter API Key \u2022 Press Enter to save, Esc to cancel":xe==="profileNickname"?`Enter Nickname (${St.length}/20) \u2022 Press Enter to save, Esc to cancel`:xe==="profileInstructions"?`Enter Custom Instructions (${St.length}/250) \u2022 Press Enter to save, Esc to cancel`:"Comma separated \u2022 Press Enter to save, Esc to cancel"))))}),uo&&T.push(A.createElement(He,{key:"conflict-warning",marginTop:1,paddingX:1},A.createElement(oe,{color:Be.text,italic:!0},"* Conflicting commands will be ignored and defaulted to highest priority"))),T})():A.createElement(He,{paddingX:1,flexDirection:"column",width:"100%"},qe==="exit"?A.createElement(A.Fragment,null,A.createElement(He,{flexDirection:"column",marginBottom:1},A.createElement(He,{flexDirection:"row"},A.createElement(oe,{color:Be.textDim},"OS"," "),A.createElement(oe,{color:"gray"},"..................... "),A.createElement(oe,{color:Be.text},process.env.OS||process.platform||"N/A")),A.createElement(He,{flexDirection:"row"},A.createElement(oe,{color:Be.textDim},"Computer Name"," "),A.createElement(oe,{color:"gray"},".......... "),A.createElement(oe,{color:Be.text},process.env.COMPUTERNAME||process.env.HOSTNAME||"N/A")),A.createElement(He,{flexDirection:"row"},A.createElement(oe,{color:Be.textDim},"Processor Count"," "),A.createElement(oe,{color:"gray"},"........ "),A.createElement(oe,{color:Be.text},process.env.NUMBER_OF_PROCESSORS||"N/A")),A.createElement(He,{flexDirection:"row"},A.createElement(oe,{color:Be.textDim},"Node.js Version"," "),A.createElement(oe,{color:"gray"},"........ "),A.createElement(oe,{color:Be.text},"v",process.versions.node)),A.createElement(He,{flexDirection:"row"},A.createElement(oe,{color:Be.textDim},"V8 Version"," "),A.createElement(oe,{color:"gray"},"...... ...... "),A.createElement(oe,{color:Be.text},"v",process.versions.v8)),A.createElement(He,{flexDirection:"row"},A.createElement(oe,{color:Be.textDim},"Data Directory"," "),A.createElement(oe,{color:"gray"},"......... "),ko===$o?"":A.createElement(oe,{color:Be.text},ko.replaceAll(Ea.homedir(),"~").replaceAll("\\\\","/").replaceAll("\\","/"),", "),A.createElement(oe,{color:Be.text},$o.replaceAll(Ea.homedir(),"~").replaceAll("\\\\","/").replaceAll("\\","/"))),A.createElement(He,{flexDirection:"row"},A.createElement(oe,{color:Be.textDim},"Viewport"," "),A.createElement(oe,{color:"gray"},"............... "),A.createElement(oe,{color:Be.text},process.stdout.rows||"?"," rows \xD7 ",process.stdout.columns||"?"," cols ",process.stdout.columns<90?"(too small width)":"")),A.createElement(He,{flexDirection:"row",marginBottom:0},A.createElement(oe,{color:Be.textDim},"Memory Load"," "),A.createElement(oe,{color:"gray"},"............ "),A.createElement(oe,{color:Be.text},co,"/",nn," ",$r))),A.createElement(He,{key:"pty-notice",paddingX:0,marginTop:0},A.createElement(oe,{color:Ur?Be.statusOn:Be.warning},Ur?"\u2713 Advance Interactive Terminal Supported":"\u26A0 Interactive Terminal is Limited"))):A.createElement(oe,{color:"gray",italic:!0},Ho[H].desc)))),A.createElement(He,{paddingX:1,marginTop:0,flexDirection:"row",justifyContent:"space-between"},A.createElement(oe,{color:"gray",italic:!0},me==="categories"?"\u25B2\u25BC Select Category \u2022 Enter/\u25BA to configure":qe==="security"?"\u25B2\u25BC Select Option \u2022 TAB/\u25C4\u25BA Switch Tab \u2022 Enter to Edit/Toggle \u2022 ESC to go back":"\u25B2\u25BC Select Option \u2022 Enter to Toggle \u2022 \u25C4/ESC to go back"),me==="categories"&&A.createElement(oe,{color:"gray"},Ho[H].desc)))}import Xt,{useState as hi}from"react";import{Box as Co,Text as xn,useInput as Ud}from"ink";import _d from"ink-text-input";var Hd=({question:t,options:m,onResolve:d,theme:v="Dark"})=>{let y=ut(v),[b,r]=hi(!1),[C,w]=hi(""),[M,O]=hi(0),U=!1,D=[],P=Array.isArray(m)&&m.length>0,W=t==="Agent has been running for a long time. Do you want to continue execution?";try{W&&P?D=[...m]:D=[...P?m:[],P?{id:"CUSTOM",label:"Suggest something else...",description:"Provide a custom response"}:{id:"CUSTOM",label:"Your Answer",description:""}]}catch{U=!0}Ud((_,V)=>{if(!b&&((V.leftArrow||V.upArrow)&&O(Y=>Math.max(0,Y-1)),(V.rightArrow||V.downArrow)&&O(Y=>Math.min(D.length-1,Y+1)),V.return)){let Y=D[M];Y?.id==="CUSTOM"?r(!0):d(U?"Selected Nothing":Y.label)}});let X=yt(2);return b?Xt.createElement(Co,{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%"},Xt.createElement(Co,{paddingX:1},Xt.createElement(xn,{color:y.text,bold:!0},"SUGGEST SOMETHING")),Xt.createElement(Co,{marginTop:1,paddingX:1},Xt.createElement(xn,{italic:!0,color:y.textMuted},"Replying to: ",t)),Xt.createElement(Co,{marginTop:1,paddingX:1,flexDirection:"row"},Xt.createElement(_d,{value:C,onChange:w,onSubmit:()=>d(C)})),Xt.createElement(Co,{marginTop:1,paddingX:1,marginBottom:1},Xt.createElement(xn,{color:y.textMuted,italic:!0},"(Press Enter to send)"))):Xt.createElement(Co,{flexDirection:"column",border:!0,borderStyle:"round",borderColor:y.codeBorder,paddingLeft:2,paddingRight:0,paddingTop:1,paddingBottom:1,marginY:1,marginRight:1,width:"100%"},Xt.createElement(Co,{paddingX:1,marginBottom:1},Xt.createElement(xn,{color:"yellow",bold:!0},W?"TURN SAFETY SYSTEM: EXECUTION LIMIT":"AGENT REQUEST: ACTION REQUIRED")),Xt.createElement(Co,{paddingX:1,marginBottom:1},Xt.createElement(xn,{color:y.text},t)),Xt.createElement(Co,{flexDirection:"column",width:"100%"},D.map((_,V)=>{let Y=V===M;return Xt.createElement(Co,{key:_.id,flexDirection:"column",width:"100%",backgroundColor:Y?y.highlightBg:void 0,paddingX:1,marginBottom:V===D.length-1?0:1},Xt.createElement(xn,{color:Y?y.text:y.textMuted,bold:Y},Y?"\u276F ":" ",_.label),_.description&&Xt.createElement(Co,{marginLeft:4},Xt.createElement(xn,{color:y.textMuted,italic:!0},_.description)))})),Xt.createElement(Co,{paddingX:1,marginTop:1,marginBottom:1},Xt.createElement(xn,{color:y.textMuted,italic:!0},"(Use Arrows to navigate, Enter to confirm)")))},Ia=Hd;import uu from"gradient-string";var Wd=t=>{let m=String(t||"").trim().split(/\s+/).filter(Boolean),d={sub:null,args:[],provider:null,providerBare:!1,index:null,url:null,temp:!1,all:!1,unmask:!1,nullMode:!1},v=[];for(let y=0;y<m.length;y++){let b=m[y];if(b==="--provider"){let r=m[y+1];r&&!r.startsWith("--")?(d.provider=r,y++):d.providerBare=!0}else if(b==="--index"){let r=m[y+1];r&&/^\d+$/.test(r)&&(d.index=parseInt(r,10)-1,y++)}else if(b==="--url"){let r=m[y+1];r&&!r.startsWith("--")&&(d.url=r,y++)}else b==="--temp"?d.temp=!0:b==="--null"?d.nullMode=!0:b==="--all"?d.all=!0:b==="--unmask"||b==="--reveal"?d.unmask=!0:b==="--mask"?d.unmask=!1:v.push(b)}return d.sub=v.length?v[0].toLowerCase():null,d.args=v.slice(1),d},ka=["\u2726 API KEY MANAGEMENT","\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m /key list [--provider <name>] [--unmask]","\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m /key add <key> [--index <n>] [--provider <name>] [--url <endpoint>]","\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m /key remove [<index>|<key>|--all] [--provider <name>]","\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m /key use <index>|<key> | /key use <key> --temp","\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m /key use --null (no key sent; c_openai / Ollama only)","\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m /key clean [--provider <name>]","\u2800"],Aa=async(t,m={})=>{let d=Wd(t),v=m.currentProvider||"Google",y=[],b=(w={})=>({lines:y,...w}),r=v;if(d.provider){let w=Ml(d.provider);if(!w)return{lines:[`\u2726 Unknown provider: ${d.provider}`]};r=w}let C=d.sub;if(!C)return{lines:ka};if(C==="list"){if(d.providerBare){let M=vl();y.push("\u2726 SAVED API KEYS");for(let O of M)y.push(`- ${O.provider} (${O.hasKeys?O.count:"No Saved Keys"})`);return y.push("\u2800"),b()}let w=await Fl(r,{unmask:d.unmask});return y.push(`\u2726 ${Sl(r.replace("c_openai","Custom Endpoints"))} API KEYS`),y.push(...w),y.push("\u2800"),b()}if(C==="add"||C==="new"){let w=d.args.join(" ").trim();if(!w)return b({promptNewKey:!0});let M=await Ll(r,w,{index:d.index!==null?d.index:void 0,baseUrl:d.url!==null?d.url:void 0});return M.ok?(await Bl(r)===null&&await El(r,M.index),y.push(`\u2726 Key added to ${r.replace("c_openai","Custom Endpoints")} slot ${M.index+1}.`),d.url!==null&&ti(r)&&y.push(`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Using URL: ${d.url}`),b()):M.full?{lines:[`\u2726 ${M.error}`,"\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Use /key add <key> --index <n> to overwrite a slot."]}:{lines:[`\u2726 Failed to add key: ${M.error}`]}}if(C==="remove"){let w;if(d.all)w=void 0;else if(d.args.length){let O=d.args.join(" ");w=/^\d+$/.test(O)?parseInt(O,10)-1:O}let M=await Pl(r,w,{all:d.all});return M.ok?M.all?(y.push(`\u2726 Cleared all keys for ${r.replace("c_openai","Custom Endpoints")}.`),b({promptNewKey:!0})):(y.push(`\u2726 Removed key from ${r.replace("c_openai","Custom Endpoints")} slot ${M.removedIndex+1}.`),M.needsNewKey?(y.push(`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No keys remain for ${r}. Please enter a new key.`),b({promptNewKey:!0})):b()):{lines:[`\u2726 ${M.error}`]}}if(C==="use"){let w=d.args.join(" ").trim();if(d.nullMode){if(!Il(r))return{lines:["\u2726 --null is only supported for Custom Endpoints and Ollama."]};await kl(r,!0),ni(r);let U=r.replace("c_openai","Custom Endpoints");return y.push(`\u2726 ${U} now using NO API key (persisted).`),y.push("\u2800\u2800\u2514\u2500 Saved key slots were kept, they are just ignored."),r==="c_openai"&&y.push("\u2800\u2800\u2514\u2500 No Authorization header will be sent. Base URL is unchanged."),b({switchedKey:Dl})}if(!w)return{lines:["\u2726 Usage: /key use <index> | <key> [--temp] | /key use --null"]};if(d.temp)return Al(r,w),y.push(`\u2726 Temporary key set for ${r.replace("c_openai","Custom Endpoints")} (session only).`),ti(r)&&y.push("\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Will use the current Custom base URL."),b({switchedKey:w});let M=/^\d+$/.test(w)?parseInt(w,10)-1:w,O=await Ol(r,M);return O.ok?(ni(r),y.push(`\u2726 ${r.replace("c_openai","Custom Endpoints")} now using slot ${O.index+1}.`),O.switchedBaseUrl&&y.push(`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Switched Base URL to: ${O.switchedBaseUrl}`),b({switchedBaseUrl:O.switchedBaseUrl,switchedKey:O.key})):{lines:[`\u2726 ${O.error}`]}}if(C==="clean"){let w=d.provider?r:null,M=await Nl(w);return y.push(w?`\u2726 Compacted ${w.replace("c_openai","Custom Endpoints")} key slots.`:`\u2726 Compacted all key stores (${M.touched} provider(s) touched).`),b()}return{lines:[`\u2726 Unknown subcommand: ${C}`,...ka]}};import Oa from"node-notifier";import en from"path";import La from"fs";import{execSync as Xd}from"child_process";import{fileURLToPath as Gd}from"url";var hs=en.dirname(Gd(import.meta.url)),Or=t=>{let m=[en.resolve(hs,"../assets",t),en.resolve(hs,"../../assets",t),en.resolve(hs,"../../src/assets",t),en.resolve(process.cwd(),"src/assets",t),en.resolve(process.cwd(),"dist/assets",t)];for(let d of m)if(La.existsSync(d))return d;return m[0]},Pa=en.join(process.env.APPDATA,"Microsoft","Windows","Start Menu","Programs","FluxFlow"),Gm=en.join(Pa,"FluxFlow.lnk"),Km=en.resolve(hs,"../../node_modules/node-notifier/vendor/snoreToast/snoretoast-x64.exe"),pi=()=>{if(process.platform==="win32")try{let t=Or("logo.png"),m=Or("logo.ico"),v=`
|
|
45
|
-
$key = 'HKCU:\\Software\\Classes\\AppUserModelId\\FluxFlow'
|
|
46
|
-
New-Item -Path $key -Force | Out-Null
|
|
47
|
-
Set-ItemProperty -Path $key -Name 'DisplayName' -Value 'FluxFlow'
|
|
48
|
-
Set-ItemProperty -Path $key -Name 'IconUri' -Value '${(La.existsSync(t)?t:m).replace(/'/g,"''")}'
|
|
49
|
-
Set-ItemProperty -Path $key -Name 'IconBackgroundColor' -Value '00000000'
|
|
50
|
-
Set-ItemProperty -Path $key -Name 'ShowInSettings' -Value 0 -Type DWord -ErrorAction SilentlyContinue
|
|
51
|
-
Remove-Item -Path '${Pa.replace(/'/g,"''")}' -Recurse -Force -ErrorAction SilentlyContinue
|
|
52
|
-
`.replace(/\r?\n\s*/g,"; ");Xd(`powershell -NoProfile -Command "${v}"`,{stdio:"ignore"})}catch{}},bi=()=>"FluxFlow";var ps=!1,wi=(t="")=>{let m="FluxFlow",d=`Agent finished - ${t||"Session"}`;try{ps||(pi(),ps=!0);let v=process.platform==="win32"?bi():"FluxFlow",y=Or("logo.png");Oa.notify({title:m,message:d,appID:v,icon:y,contentImage:y,wait:!1})}catch{}},Nr=(t="User action required")=>{let m="FluxFlow";try{ps||(pi(),ps=!0);let d=process.platform==="win32"?bi():"FluxFlow",v=Or("logo.png");Oa.notify({title:m,message:t,appID:d,icon:v,contentImage:v,wait:!1})}catch{}};import Jt,{useState as Ti,useEffect as Kd}from"react";import{Box as Wo,Text as gn,useInput as Vd}from"ink";function yi({onSelect:t,onDelete:m,onClose:d,theme:v="Dark"}){let y=ut(v),[b,r]=Ti({}),[C,w]=Ti([]),[M,O]=Ti(0);Kd(()=>{(async()=>{let _=await Jo();r(_),w(Object.keys(_).sort((V,Y)=>(_[Y].updatedAt||0)-(_[V].updatedAt||0)))})()},[]),Vd((X,_)=>{if(_.escape&&d(),_.upArrow&&O(V=>Math.max(0,V-1)),_.downArrow&&O(V=>Math.min(C.length-1,V+1)),_.return&&C[M]&&t(C[M]),X==="x"&&C[M]){let V=C[M];m(V).then(Y=>{let ue=Y||{};r(ue);let me=Object.keys(ue).sort((le,H)=>(ue[H]?.updatedAt||0)-(ue[le]?.updatedAt||0));w(me),O(le=>Math.max(0,Math.min(me.length-1,le)))})}});let U=yt(2),D=15,P=0;if(C.length>D){let X=Math.floor(D/2);P=M-X,P<0?P=0:P+D>C.length&&(P=C.length-D)}let W=C.slice(P,P+D);return Jt.createElement(Wo,{flexDirection:"column",borderStyle:"round",borderColor:y.borderMuted,padding:0,width:"100%"},Jt.createElement(Wo,{paddingX:1,marginBottom:1},Jt.createElement(gn,{color:y.text,bold:!0},"CHAT HISTORY: RESUME CONVERSATION")),C.length===0?Jt.createElement(Wo,{paddingX:2,paddingY:1},Jt.createElement(gn,{italic:!0,color:y.textMuted},"No saved chats found.")):Jt.createElement(Wo,{flexDirection:"column",width:"100%"},P>0&&Jt.createElement(Wo,{paddingX:2,marginBottom:1},Jt.createElement(gn,{color:y.textMuted},"\u25B2 (+",P," more chats above)")),W.map((X,_)=>{let V=b[X],ue=P+_===M,me=Yd(V?.updatedAt);return Jt.createElement(Wo,{key:X,paddingX:1,backgroundColor:ue?y.highlightBg:void 0,width:"100%"},Jt.createElement(Wo,{flexGrow:1},Jt.createElement(gn,{color:ue?y.text:y.textMuted,bold:ue},ue?"\u276F ":" ",vr(V,X),Jt.createElement(gn,{color:y.textMuted}," [",me," \u2022 ",X,"]"))),ue&&Jt.createElement(Wo,{flexShrink:0},Jt.createElement(gn,{color:y.danger,bold:!0},"[X] DELETE ")))}),P+D<C.length&&Jt.createElement(Wo,{paddingX:2,marginTop:1},Jt.createElement(gn,{color:y.textMuted},"\u25BC (+",C.length-(P+D)," more chats below)"))),Jt.createElement(Wo,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:y.borderMuted},Jt.createElement(gn,{color:y.textMuted,italic:!0},"\u2191\u2193 navigate \u2022 Enter select \u2022 x delete \u2022 Esc close")))}function Yd(t){if(!t)return"N/A";let m=new Date(t);if(isNaN(m.getTime()))return"N/A";let d=C=>String(C).padStart(2,"0"),v=d(m.getMonth()+1),y=d(m.getDate()),b=d(m.getHours()),r=d(m.getMinutes());return`${v}-${y} ${b}:${r}`}import Gt,{useState as Ci,useEffect as jd}from"react";import{Box as Xo,Text as Po,useInput as qd,useStdout as zd}from"ink";function Mi({onClose:t,theme:m="Dark"}){let d=ut(m),{stdout:v}=zd(),y=v?.columns||80,[b,r]=Ci([]),[C,w]=Ci(0),[M,O]=Ci(!0),U=()=>{let le=Rr(Tr,[]);r(le);try{let be=es(An,{}).systemSettings?.memory!==!1;O(be)}catch{O(!0)}};jd(()=>{U()},[]),qd((le,H)=>{if(H.escape&&t(),H.upArrow&&w(be=>Math.max(0,be-1)),H.downArrow&&w(be=>Math.min(b.length-1,be+1)),le==="x"&&b.length>0){let be=b[C].id,Oe=b.filter(Ne=>Ne.id!==be);gl(Tr,Oe),r(Oe),C>=Oe.length&&Oe.length>0&&w(Oe.length-1)}});let D=(le,H,be)=>{if(!le)return"";let Oe=le.replace(/\[Saved on: .*?\]/g,"").replace(/\\+'/g,"'").trim(),tt=`${be?"\u276F ":" "}${H+1}. `.length,Se=be?22:2;return Oe.split(`
|
|
53
|
-
`).map((Me,St)=>{let Xe=St===0,Pe=Math.max(10,y-4-(Xe?tt:3)-Se),Ce=Math.max(10,y-4-3-Se),J=Me.split(/(\s+)/),fe=[],we="";if(J.forEach(he=>{if(he.length===0)return;let j=fe.length===0?Pe:Ce;we.length+he.length>j?we.trim().length>0?(fe.push(we.trimEnd()),we=he):(fe.push(he.substring(0,j)),we=he.substring(j)):we+=he}),we.trimEnd().length>0&&fe.push(we.trimEnd()),fe.length===0)return"";let ee=fe.join(`
|
|
54
|
-
`);return Xe?ee:" "+ee}).join(`
|
|
55
|
-
`)},P=4*1024*2,W=b.reduce((le,H)=>le+(H.memory?.length||0),0),X=Math.min(100,Math.round(W/P*100)),_=12,V=Math.round(X/100*_),Y="\u2588".repeat(V)+"\u2591".repeat(Math.max(0,_-V)),ue=()=>X<50?d.textMuted:X<90?d.warning:d.danger,me=yt(2);return Gt.createElement(Xo,{flexDirection:"column",borderStyle:"round",borderColor:d.borderMuted,padding:0,width:"100%"},Gt.createElement(Xo,{paddingX:1,marginBottom:1,justifyContent:"space-between"},Gt.createElement(Po,{color:d.text,bold:!0},"SAVED MEMORIES"),Gt.createElement(Xo,null,Gt.createElement(Po,{color:d.textMuted},"Vault: "),Gt.createElement(Po,{color:ue()},Y),Gt.createElement(Po,{color:d.text,bold:!0}," ",X,"%"))),!M&&b.length>0?Gt.createElement(Xo,{paddingX:2,paddingY:1},Gt.createElement(Po,{italic:!0,color:d.textMuted},"Memory is currently Off...")):b.length===0?Gt.createElement(Xo,{paddingX:2,paddingY:1},Gt.createElement(Po,{italic:!0,color:d.textMuted},M?"Learning...":"Memory not available...")):Gt.createElement(Xo,{flexDirection:"column"},b.map((le,H)=>{let be=H===C;return Gt.createElement(Xo,{key:le.id,paddingX:1,backgroundColor:be?d.highlightBg:void 0,width:"100%"},Gt.createElement(Xo,{flexGrow:1},Gt.createElement(Po,{color:be?d.text:d.textMuted,bold:be},be?"\u276F ":" ",H+1,". ",D(le.memory,H,be))),be&&Gt.createElement(Xo,{flexShrink:0},Gt.createElement(Po,{color:d.textMuted,dimColor:!0}," [",Gt.createElement(Po,{italic:!0},le.score),"] "),Gt.createElement(Po,{color:d.danger,bold:!0},"[X] WIPE ")))})),Gt.createElement(Xo,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:d.borderMuted},Gt.createElement(Po,{color:d.textMuted,italic:!0},"\u2191\u2193 navigate \u2022 x wipe memory \u2022 Esc close")))}import It,{useState as bs,useEffect as Na}from"react";import{Box as hn,Text as eo}from"ink";import{spawn as Fa}from"child_process";var $a=["\u280B","\u2819","\u2839","\u2838","\u283C","\u2834","\u2826","\u2827","\u2807","\u280F"],Qd=({latest:t,current:m,settings:d,theme:v="Dark",onClose:y,onUpdateSettings:b,onSuccess:r})=>{let C=ut(v),[w,M]=bs("initializing"),[O,U]=bs(""),[D,P]=bs(null),[W,X]=bs(0);if(Na(()=>{let _=setInterval(()=>{X(V=>(V+1)%1e3)},33);return()=>clearInterval(_)},[]),Na(()=>{let _;return(async()=>{let Y=d?.updateManager||"npm";if(!d?.updateManager){b();return}let ue="";Y==="pnpm"?ue=`pnpm add -g fluxflow-cli@${t}`:Y==="bun"?ue=`bun add -g fluxflow-cli@${t}`:Y==="yarn"?ue=`yarn global add fluxflow-cli@${t}`:Y==="custom"?ue=d.customUpdateCommand:ue=`npm install -g fluxflow-cli@${t}`,M("downloading"),U(`Running: ${ue}...`);let me=process.platform==="win32",le=be=>new Promise(Oe=>{let Ne=me?be?"powershell.exe":"cmd.exe":process.env.SHELL||"bash",tt=me?be?["-NoProfile","-Command",ue]:["/c",ue]:["-c",ue],Se=Me=>{let Xe=Me.toString().replace(/\x1B\[[0-?]*[ -/]*[@-~]|\x1B\][^\x07\x1B]*[\x07\x1B]|\b|\x07/g,"").replace(/\r/g,"").trim();Xe&&U(Pe=>{let Ce=Pe.split(`
|
|
56
|
-
`);return Ce[Ce.length-1]?.startsWith("Progress:")&&Xe.startsWith("Progress:")?(Ce[Ce.length-1]=Xe,Ce.slice(-5).join(`
|
|
57
|
-
`)):(Pe+`
|
|
58
|
-
`+Xe).split(`
|
|
59
|
-
`).slice(-10).join(`
|
|
60
|
-
`)})},xe=me?Fa(Ne,tt,{cwd:process.cwd(),env:process.env}):Fa(ue,{shell:!0,cwd:process.cwd(),env:process.env});_=xe,xe.stdout.on("data",Se),xe.stderr.on("data",Se),xe.on("close",Me=>{_=null,Oe(Me!==0?{error:`Process exited with code ${Me}`}:{success:!0})}),xe.on("error",Me=>{me&&be&&Me.code==="ENOENT"?Oe({retryCmd:!0}):(_=null,Oe({error:Me.message}))})}),H={};me?(H=await le(!0),H.retryCmd&&(H=await le(!1))):H=await le(!1),H.error?(P(H.error),M("error")):H.success&&(M("success"),r&&r())})(),()=>{if(_)try{typeof _.destroy=="function"?_.destroy():typeof _.kill=="function"&&_.kill()}catch{}}},[]),w==="initializing"||w==="downloading"){let _=$a[Math.floor(W/3)%$a.length];return It.createElement(hn,{flexDirection:"column",borderStyle:"round",borderColor:C.border,paddingX:2,paddingY:1},It.createElement(hn,null,It.createElement(eo,{color:C.accent||C.primary},_),It.createElement(eo,{marginLeft:1,bold:!0,color:C.text}," Updating Flux Flow to v",t,"...")),It.createElement(hn,{marginTop:1,paddingX:1,borderStyle:"single",borderColor:C.borderMuted},It.createElement(eo,{color:C.textMuted,italic:!0},O||"Preparing environment...")),It.createElement(eo,{marginTop:1,color:C.textDim||C.textMuted},"(Please do not close the terminal)"))}return w==="success"?It.createElement(hn,{flexDirection:"column",borderStyle:"round",borderColor:C.success||C.border,paddingX:2,paddingY:1},It.createElement(eo,{color:C.success||C.text,bold:!0},"\u2705 UPDATE SUCCESSFUL!"),It.createElement(eo,{marginTop:1,color:C.text},"Flux Flow has been updated to ",It.createElement(eo,{color:C.accent||C.primary},"v",t),"."),It.createElement(eo,{marginTop:1,color:C.text,bold:!0},"Please restart your terminal session to apply changes."),It.createElement(hn,{marginTop:1},It.createElement(eo,{color:C.textMuted},"(Press ESC to return to chat)"))):w==="error"?It.createElement(hn,{flexDirection:"column",borderStyle:"round",borderColor:C.danger||C.border,paddingX:2,paddingY:1},It.createElement(eo,{color:C.danger||C.text,bold:!0},"\u274C UPDATE FAILED"),It.createElement(hn,{marginTop:1,paddingX:1,borderStyle:"single",borderColor:C.borderMuted},It.createElement(eo,{color:C.danger||C.text},D)),It.createElement(eo,{marginTop:1,color:C.text,bold:!0},"Possible causes:"),It.createElement(eo,{color:C.textMuted},"\u2022 Missing permissions (Try running as Administrator/Sudo)"),It.createElement(eo,{color:C.textMuted},"\u2022 Package manager (",d?.updateManager,") not found"),It.createElement(eo,{color:C.textMuted},"\u2022 Network failure"),It.createElement(hn,{marginTop:1},It.createElement(eo,{color:C.textDim||C.textMuted},"(Press ESC to return to chat)"))):null},Ua=Qd;import ao,{useState as _a,useEffect as Jd}from"react";import{Box as pn,Text as or,useInput as Zd}from"ink";var ws=[{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 Si({onClose:t}){let[m,d]=_a(0),[v,y]=_a({});return Jd(()=>{let b={};ws.forEach(r=>{oa(r.file)?b[r.file]="ready":b[r.file]="idle"}),y(b)},[]),Zd(async(b,r)=>{r.escape&&t(),r.upArrow&&d(w=>Math.max(0,w-1)),r.downArrow&&d(w=>Math.min(ws.length-1,w+1));let C=ws[m];if(b==="x"||b==="X"){if(v[C.file]==="downloading")return;try{await na(C.file),y(w=>({...w,[C.file]:"idle"}))}catch(w){y(M=>({...M,[C.file]:`error: ${w.message}`}))}}if(r.return){if(v[C.file]==="downloading")return;y(w=>({...w,[C.file]:"downloading"}));try{await ta(C.file),y(w=>({...w,[C.file]:"ready"}))}catch(w){y(M=>({...M,[C.file]:`error: ${w.message}`}))}}}),ao.createElement(pn,{flexDirection:"column",borderStyle:"round",borderColor:"gray",padding:0,width:"100%"},ao.createElement(pn,{paddingX:1,marginBottom:1},ao.createElement(or,{color:"white",bold:!0},"LANGUAGE PARSER MANAGER")),ao.createElement(pn,{flexDirection:"column"},ws.map((b,r)=>{let C=r===m,w=v[b.file]||"idle",M="[ DOWNLOAD ]",O="gray";w==="downloading"?(M="[ DOWNLOADING... ]",O="yellow"):w==="ready"?(M="[ READY ]",O="green"):w.startsWith("error")&&(M=`[ ${w.toUpperCase()} ]`,O="red");let U=`${b.label} (${b.exts.join(", ")})`,D=Math.max(2,45-U.length),P=".".repeat(D);return ao.createElement(pn,{key:b.file,paddingX:1,backgroundColor:C?"#2a2a2a":void 0,width:"100%"},ao.createElement(pn,null,ao.createElement(or,{color:C?"white":"grey",bold:C},C?"\u276F ":" ",b.label," ",ao.createElement(or,{dimColor:!0},"(",b.exts.join(", "),")"))),ao.createElement(pn,{flexGrow:1},ao.createElement(or,{color:"gray",dimColor:!0},P)),ao.createElement(pn,{width:20},ao.createElement(or,{color:O,bold:!0},M)))})),ao.createElement(pn,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:"gray"},ao.createElement(or,{color:"grey",italic:!0},"\u2191\u2193 navigate \u2022 Enter download \u2022 x delete \u2022 Esc close")))}import zt,{useState as Rd}from"react";import{Box as Go,Text as tn,useInput as eu}from"ink";function vi({prompts:t,onSelect:m,onClose:d,theme:v="Dark"}){let y=ut(v),[b,r]=Rd(0);eu((U,D)=>{D.escape&&d(),D.upArrow&&r(P=>Math.max(0,P-1)),D.downArrow&&r(P=>Math.min(t.length-1,P+1)),D.return&&t[b]&&m(t[b].id)});let C=yt(2),w=10,M=0;if(t.length>w){let U=Math.floor(w/2);M=b-U,M<0?M=0:M+w>t.length&&(M=t.length-w)}let O=t.slice(M,M+w);return zt.createElement(Go,{flexDirection:"column",borderStyle:"round",borderColor:y.borderMuted,padding:0,width:"100%"},zt.createElement(Go,{paddingX:1,marginBottom:1},zt.createElement(tn,{color:y.text,bold:!0},"CODEBASE TIME TRAVEL: SELECT UNDO POINT")),zt.createElement(Go,{paddingX:2,marginBottom:1},zt.createElement(tn,{color:y.text},"Select a prompt to revert the codebase back to the state ",zt.createElement(tn,{bold:!0,color:y.secondary||"cyan"},"immediately before")," it was executed:")),t.length===0?zt.createElement(Go,{paddingX:2,paddingY:1},zt.createElement(tn,{italic:!0,color:y.textMuted},"No prompt checkpoints found for this session.")):zt.createElement(Go,{flexDirection:"column",width:"100%"},M>0&&zt.createElement(Go,{paddingX:2,marginBottom:1},zt.createElement(tn,{color:y.textMuted},"\u25B2 (+",M," more prompts above)")),O.map((U,D)=>{let W=M+D===b,X=ou(U.timestamp),_=U.changes?U.changes.length:0;return zt.createElement(Go,{key:U.id,paddingX:1,backgroundColor:W?y.highlightBg:void 0,width:"100%"},zt.createElement(Go,{flexGrow:1},zt.createElement(tn,{color:W?y.text:y.textMuted,bold:W},W?"\u276F ":" ",'"',tu(U.prompt),'"',zt.createElement(tn,{color:y.textMuted}," [",X," \u2022 ",_," file(s) changed]"))))}),M+w<t.length&&zt.createElement(Go,{paddingX:2,marginTop:1},zt.createElement(tn,{color:y.textMuted},"\u25BC (+",t.length-(M+w)," more prompts below)"))),zt.createElement(Go,{marginTop:1,paddingX:1,borderStyle:"single",borderLeft:!1,borderRight:!1,borderBottom:!1,borderColor:y.borderMuted},zt.createElement(tn,{color:y.textMuted,italic:!0},"\u2191\u2193 navigate \u2022 Enter select undo point \u2022 Esc close")))}function tu(t){if(!t)return"";let d=(t.split(`
|
|
61
|
-
`)[0]||"").replace(/@\[(.*?)\]/g,(v,y)=>{let b=y.replace(/\\/g,"/").split("/");return`[${b[b.length-1]}]`});return d.length>69?d.slice(0,67)+"...":t.includes(`
|
|
62
|
-
`)?d+"...":d}function ou(t){if(!t)return"N/A";let m=new Date(t);if(isNaN(m.getTime()))return"N/A";let d=r=>String(r).padStart(2,"0"),v=d(m.getHours()),y=d(m.getMinutes()),b=d(m.getSeconds());return`${v}:${y}:${b}`}import{exec as nu}from"child_process";import{promisify as ru}from"util";import Ha from"fs";var Wa=ru(nu),Xa=async()=>{try{let t=ea();if(t.executablePath&&Ha.existsSync(t.executablePath))return!0;let{default:m}=await import("puppeteer"),d=m.executablePath();if(d&&Ha.existsSync(d))return!0}catch{return!1}return!1},Ga=async t=>{t&&t("\u{1F4E5} Downloading Chromium engine (chrome@148)...");try{try{await Wa("pnpm exec puppeteer browsers install chrome@148")}catch{await Wa("npx -y puppeteer browsers install chrome@148")}return await new Promise(m=>setTimeout(m,1e3)),{success:!0}}catch(m){return console.error("[SETUP ERROR]",m),{success:!1,error:m.message}}};import Ka,{useState as Va,useEffect as Ya}from"react";import{Text as ja}from"ink";var su=({text:t,baseColor:m="grey",glintColor:d="gray",speed:v=200,glintWidth:y=6,typeSpeed:b=30,...r})=>{let[C,w]=Va(-y),[M,O]=Va(t);return Ya(()=>{let U=setInterval(()=>{w(D=>D>M.length+y?-y-40:D+1)},v);return()=>clearInterval(U)},[M.length,v,y]),Ya(()=>{if(t&&(t.includes("Trying to reach")&&M&&M.includes("Trying to reach")||t.includes("Error Occurred")&&M&&M.includes("Error Occurred"))){O(t);return}if(M===t)return;let U=setTimeout(()=>{let D=0,P=Math.min(M.length,t.length);for(;D<P&&M[D]===t[D];)D++;M.length>D?O(W=>W.slice(0,-1)):M.length<t.length&&O(t.slice(0,M.length+1))},b);return()=>clearTimeout(U)},[t,M,b]),Ka.createElement(ja,null,M.split("").map((U,D)=>{let W=Math.abs(D-C)<=y/2?d:m;return Ka.createElement(ja,{key:D,color:W,...r},U)}))},Fr=su;var Ts=null,sr=null,ys=null,Cs=null,Mo=t=>{let m=String(t);return m.startsWith("999")&&m.endsWith("9")},Bi=async()=>{let t=process.env["9ROUTER_URL"]||process.env.NINEROUTER_URL||process.env["9ROUTER_BASE_URL"]||"http://127.0.0.1:20128",m=t;try{let d=new URL(t);m=`${d.protocol}//${d.host}`}catch{m=t.replace(/\/v1(\/chat\/completions)?\/?$/,"")}try{let d=await fetch(m,{method:"GET",signal:AbortSignal.timeout(800)});return{ok:!0,url:m}}catch(d){return{ok:!1,url:m,error:d.message}}},on=t=>t==null||t===0||Mo(t)?"":String(t),bn=()=>{let t=(process.env.TERM_PROGRAM||"").toLowerCase(),m=(process.env.VSCODE_CWD||"").toLowerCase(),d=(process.env.VSCODE_CODE_CACHE_PATH||"").toLowerCase(),v=(process.env.GIT_ASKPASS||"").toLowerCase(),y=(process.env.VSCODE_GIT_ASKPASS_NODE||"").toLowerCase(),b=(process.env.VSCODE_GIT_ASKPASS_MAIN||"").toLowerCase();return t==="antigravity"||process.env.ANTIGRAVITY_AGENT||process.env.ANTIGRAVITY_PID||process.env.ANTIGRAVITY_EDITOR_APP_ROOT||process.env.ANTIGRAVITY_CLI_ALIAS||m.includes("antigravity")||d.includes("antigravity")||v.includes("antigravity")||y.includes("antigravity")||b.includes("antigravity")?"Antigravity":t==="cursor"||process.env.CURSOR_SETTINGS_DIR||process.env.CURSOR_CONFIG_DIR||m.includes("cursor")||d.includes("cursor")||v.includes("cursor")||y.includes("cursor")?"Cursor":t==="windsurf"||process.env.WINDSURF_SETTINGS_DIR||m.includes("windsurf")||d.includes("windsurf")||v.includes("windsurf")||y.includes("windsurf")?"Windsurf":t==="trae"||process.env.TRAE_SETTINGS_DIR||m.includes("trae")||y.includes("trae")?"Trae":t==="positron"||m.includes("positron")||y.includes("positron")?"Positron":t==="codium"||t==="vscode-oss"||m.includes("codium")||d.includes("codium")||y.includes("codium")?"VSCodium":t==="vscode-insiders"||m.includes("code - insiders")||d.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||m.includes("code")||d.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"},mu=t=>{switch(t){case"VS Code":return"Code";case"VS Code Insiders":return"Code - Insiders";case"Antigravity":return"Antigravity IDE";default:return t}},qa={Flux:"Workspace",Flow:"Studio",ICU:"Computer Use",FluxCU:"Omni"},Ei=t=>{if(!t)return"Workspace";let m=Object.keys(qa).find(d=>d.toLowerCase()===t.toLowerCase());return m?qa[m]:t},za=t=>{let m=mu(t),d=ki.homedir();if(process.platform==="win32"){let v=process.env.APPDATA;return v?Ct.join(v,m,"User","keybindings.json"):null}else return process.platform==="darwin"?Ct.join(d,"Library","Application Support",m,"User","keybindings.json"):Ct.join(d,".config",m,"User","keybindings.json")},Qa=t=>{let m=t.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm,"$1");return JSON.parse(m)},fu=t=>Array.isArray(t)?t.some(m=>m&&typeof m.key=="string"&&m.key.toLowerCase().replace(/\s+/g,"")==="shift+enter"&&m.command==="workbench.action.terminal.sendSequence"&&m.args&&m.args.text==="\x1B[13;2u"&&typeof m.when=="string"&&m.when.includes("terminalFocus")):!1,Za=t=>{let m=t==="VS Code",d=[];return m?(d.push({label:"Install Manually (VSIX)",url:"https://github.com/KushalRoyChowdhury/fluxflow-cli/releases"}),d.push({label:"Install from VS Code Marketplace",url:"https://marketplace.visualstudio.com/items?itemName=fluxflow-cli.fluxflow-cli-companion"})):d.push({label:`Download for ${t} (GitHub)`,url:"https://github.com/KushalRoyChowdhury/fluxflow-cli/releases"}),d.push({label:"Continue to CLI only",action:"dismiss"}),d},xu=({width:t,height:m,selectedIndex:d,aiProvider:v,theme:y="Dark"})=>{let b=bn(),r=Za(b);return e.createElement(u,{flexDirection:"column",alignItems:"center",justifyContent:"center",width:t,height:m},e.createElement(u,{marginBottom:1,width:Math.min(80,t-4),justifyContent:"flex-start"},e.createElement(i,null,Mr(So,v,y))),e.createElement(u,{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(u,{marginY:1,flexDirection:"column",alignItems:"left"},e.createElement(i,null,"You're in ",e.createElement(i,{bold:!0,color:"cyan"},b),", but the ",e.createElement(i,{bold:!0,color:"white"},"FluxFlow-CLI Companion")," is not installed."),e.createElement(u,{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(u,{flexDirection:"column",marginTop:1},r.map((C,w)=>e.createElement(u,{key:w},e.createElement(i,{color:d===w?"yellow":"white",bold:d===w},d===w?" \u276F ":" ",C.label)))),e.createElement(u,{marginTop:1,alignItems:"center",justifyContent:"center"},e.createElement(i,{dimColor:!0,italic:!0},"(Use arrows to navigate, Enter to select)"))))},gu=({width:t,height:m,aiProvider:d,theme:v="Dark",reason:y})=>{let b=bn(),r=y==="version_mismatch";return e.createElement(u,{flexDirection:"column",alignItems:"center",justifyContent:"center",width:t,height:m},e.createElement(u,{marginBottom:1,width:Math.min(80,t-4),justifyContent:"flex-start"},e.createElement(i,null,Mr(So,d,v))),e.createElement(u,{flexDirection:"column",borderStyle:"double",paddingX:3,paddingY:1,width:Math.min(80,t-4)},e.createElement(i,{bold:!0,color:"yellow",textAlign:"center"},r?"\u26A0 VERSION MISMATCH":"\u26A0 CWD MISMATCH"),e.createElement(u,{marginY:1,flexDirection:"column",alignItems:"left"},e.createElement(i,null,r?"Your FluxFlow CLI version is not supported by the ":"CWD mismatch from ",!r&&e.createElement(i,{bold:!0,color:"white"},b),!r&&" workspace. ","IDE features aren't available right now."),!r&&e.createElement(u,{marginTop:1},e.createElement(i,{dimColor:!0},"Tip: Launch FluxFlow CLI from the same folder open in ",b,"."))),e.createElement(u,{marginTop:1},e.createElement(i,{color:"yellow",bold:!0}," \u276F Understood")),e.createElement(u,{marginTop:1,alignItems:"center",justifyContent:"center"},e.createElement(i,{dimColor:!0,italic:!0},"(Press Enter to dismiss)"))))},Di=Date.now(),Ja="https://fluxflow-cli.onrender.com/changelog",Ii="https://fluxflow-cli.onrender.com/",hu=Ct.join(Ct.dirname(du(import.meta.url)),"../package.json"),Ra=JSON.parse(ft.readFileSync(hu,"utf8")),So=Ra.version,pu=Ra.date||"2026-05-20";var bu=({data:t,onResolve:m,onEdit:d,theme:v="Dark"})=>{let y=ut(v);return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:y.borderMuted,padding:0,width:"100%"},e.createElement(u,{paddingX:1},e.createElement(i,{color:y.text,bold:!0,underline:!0},t.startsWith("/btw")?"QUESTION":"STEERING HINT"," RESOLUTION")),e.createElement(u,{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(u,{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(u,{paddingX:1,marginTop:1},e.createElement(i,{color:y.textDim||y.textMuted},"How would you like to proceed?")),e.createElement(u,{marginTop:0},e.createElement(_t,{title:"Select Action",items:[{label:"Send Anyway",value:"send"},{label:"Edit Prompt",value:"edit"}],onSelect:b=>{(typeof b=="object"&&b!==null?b.value:b)==="send"?m(t):d(t)},theme:v})))};var wu=(()=>{let t=null,m=0;return d=>{let v=Date.now();if(t&&v-m<1e4)return t;let y=[],b=r=>{if(!(y.length>=2e3))try{let C=ft.readdirSync(r);for(let w of C){if(y.length>=2e3)return;if(["node_modules",".git",".gemini","dist","build",".next",".cache","out"].includes(w))continue;let M=Ct.join(r,w);ft.statSync(M).isDirectory()?b(M):y.push({name:Vt(w),relativePath:Vt(Ct.relative(process.cwd(),M))})}}catch{}};return b(d),t=y,m=v,y}})(),Ms="Ctrl + Enter",Tu=t=>{if(t<=370)return"#00a564";if(t>=5e3)return"#ff0000";let m=[{t:370,r:0,g:165,b:100},{t:550,r:40,g:195,b:80},{t:800,r:120,g:220,b:50},{t:1100,r:190,g:225,b:20},{t:1500,r:250,g:210,b:15},{t:2e3,r:255,g:170,b:0},{t:2800,r:255,g:110,b:0},{t:3800,r:255,g:50,b:0},{t:5e3,r:255,g:0,b:0}];for(let d=0;d<m.length-1;d++){let v=m[d],y=m[d+1];if(t>=v.t&&t<=y.t){let b=(t-v.t)/(y.t-v.t);b=b*b*(3-2*b);let r=Math.round(v.r+(y.r-v.r)*b),C=Math.round(v.g+(y.g-v.g)*b),w=Math.round(v.b+(y.b-v.b)*b);return`#${((1<<24)+(r<<16)+(C<<8)+w).toString(16).slice(1)}`}}return"#ff0000"},yu=e.memo(({sa:t,showTPMEstimate:m=!1})=>{let[d,v]=R("green"),[y,b]=R(0),r=Ze([]),C=Ze(370),w=Ze([]),M=Ze(t.lastChunkTime);return xt(()=>{M.current=t.lastChunkTime},[t.lastChunkTime]),xt(()=>{if(t.status!=="running"){w.current=[];return}if(t.wps>0){let O=w.current;O.push(t.wps),O.length>3&&O.shift()}},[t.status,t.wps,t.lastChunkTime]),xt(()=>{if(t.status!=="running"){b(0);return}let O=setInterval(()=>{let U=M.current,D=U>0?Date.now()-U:0;if(U>0&&D>=1e3)w.current=[],b(0);else if(U>0&&D>500){w.current.length>0&&w.current.shift();let P=w.current;if(P.length>0){let W=P.reduce((X,_)=>X+_,0);b(Math.round(W/P.length))}else b(0)}else{let P=w.current;if(P.length>0){let W=P.reduce((X,_)=>X+_,0);b(Math.round(W/P.length))}else t.wps>0&&b(Math.round(t.wps))}},750);return()=>clearInterval(O)},[t.status]),xt(()=>{if(t.status!=="running"){r.current=[];return}let O=t.lastChunkTime;if(O>0){let P=r.current;(P.length===0||P[P.length-1]!==O)&&(P.push(O),P.length>10&&P.shift())}let U=()=>{if(!O){v("#00a564");return}let P=r.current,W=0;if(P.length>1){let le=0;for(let H=1;H<P.length;H++)le+=P[H]-P[H-1];W=le/(P.length-1)}let X=Date.now()-O,V=X>=2500,Y=!V&&W>0?Math.min(X,W*3):X,ue=Math.max(W,Y),me=V?.4:.2;C.current=C.current*(1-me)+ue*me,v(Tu(C.current))};U();let D=setInterval(U,100);return()=>clearInterval(D)},[t.status,t.lastChunkTime]),e.createElement(u,{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"),!m&&e.createElement(i,{color:d}," \u25CF"),m&&e.createElement(i,{color:"white",dimColor:!0,bold:!0}," ~",y," tok/s")))});function Cu({args:t=[]}){let m=Ze(1),[d,v]=R(!1),[y,b]=R(10),{stdout:r}=lu(),[C,w]=R(""),[M,O]=R(0),U=Ze([]),[D,P]=R(-1),W=Ze(""),X=Ze(null),[_,V]=R(!1),[Y,ue]=R("Flux"),[me,le]=R(0),[H,be]=R({columns:r?.columns||80,rows:r?.rows||24}),[Oe,Ne]=R(0),[tt,Se]=R(!1),[xe,Me]=R(!1),[St,Xe]=R(null),[Pe,Ce]=R(0),J=Ze(null),fe=Ze(!1),we=Ze(0),ee=Ze(0),he=Ze(null),j=Ze(null),Ge=Ze(0),[$e,Tt]=R(0),it=()=>Tt(x=>x+1),bt=Ze([]),nt=Ze(null),ze=()=>{let x=bt.current;if(x.length>0&&j.current){let a=x.join("");x.length=0,j.current.text=Vt(j.current.text+a),it()}},ae=()=>{if(ze(),j.current){let x=Vt(j.current.text||""),a="";if(j.current.role==="agent"&&x){let o=ca(x);o.inside&&typeof o.startIndex=="number"&&o.startIndex>=0?(a=x.substring(o.startIndex),x=x.substring(0,o.startIndex)):x=sa(x)}let B=x;if(j.current.role==="think"&&(B=B.replace(/^\r?\n+/,"").replace(/\r?\n+$/,"")),B.trim().length>0||j.current.role!=="agent"){let o={...j.current,text:B,isStreaming:!1};L(n=>[...n,o]),F(n=>n+1)}a?j.current={id:"agent-"+Date.now(),role:"agent",text:a,isStreaming:!0}:j.current=null}Oi.current=0,As.current={totalWords:0,startTime:0,wps:0,chunks:[]}},De=()=>{nt.current&&clearInterval(nt.current),bt.current=[],nt.current=setInterval(()=>{try{let x=bt.current;if(x.length>0&&j.current){let a=1;x.length>85?a=30:x.length>80?a=25:x.length>75?a=20:x.length>65?a=16:x.length>50?a=12:x.length>35?a=8:x.length>15?a=6:x.length>5?a=4:x.length>3&&(a=2);let B="";for(let o=0;o<a&&x.length>0;o++)B+=x.shift();j.current.text=Vt(j.current.text+B),it()}}catch{}},80)},ct=async()=>{for(;re.progressiveRendering&&bt.current.length>0;)await new Promise(x=>setTimeout(x,10))},dt=x=>{if(re.progressiveRendering&&nt.current){let a=x.trim();if((a.startsWith("[action:")||a.startsWith("[tool:"))&&a.endsWith("]")){bt.current.push(x);return}let o=Xl(x);for(let n of o)bt.current.push(n)}else j.current?j.current.text=Vt(j.current.text+x):j.current={id:"agent-"+Date.now(),role:"agent",text:Vt(x),isStreaming:!0},it()};xt(()=>{let x=bn(),a=!["Terminal","Windows Terminal"].includes(x)||!!process.env.VSC_TERMINAL_URL,B=setTimeout(()=>{a&&!Pn()&&!J.current&&Me(!0)},500),o=setInterval(()=>{Pn()&&(Me(!1),Xe(null),J.current=null,fe.current=!1)},1e3);m.current=Date.now();let n=setInterval(()=>{m.current&&(Date.now()-m.current||0)>3e4&&global.gc&&(async()=>{for(let c=0;c<1;c++)global.gc(),await new Promise(g=>setImmediate(g));m.current=Date.now()})()},3e3);return()=>{clearTimeout(B),clearInterval(o),clearInterval(n)}},[]),xt(()=>{(async()=>{try{let a=await ii(),B=a?.systemSettings||{},o=B.CustomSubAgent,n=B.SubAgentModel;if(!o||!n||n==="Default")return;let h=process.env.SUBAGENT_MODEL?process.env.SUBAGENT_MODEL.trim():null,f=process.env.SUBAGENT_PROVIDER?process.env.SUBAGENT_PROVIDER.trim():null,c=["Google","DeepSeek","OpenRouter","NVIDIA","Mistral","Ollama","InferX","SenseNova","AIHubMix","Poolside","9router","ExpLabs","TokenHarbor","Infron","APInex","xKiro"],p=(te=>{if(!te)return null;let q=te.toLowerCase();return q==="google"?"Google":q==="deepseek"?"DeepSeek":q==="openrouter"?"OpenRouter":q==="nvidia"?"NVIDIA":q==="mistral"?"Mistral":q==="ollama"?"Ollama":q==="inferx"?"InferX":q==="sensenova"?"SenseNova":q==="poolside"?"Poolside":q==="9router"?"9router":q==="aihubmix"||q==="aihub"?"AIHubMix":q==="explabs"||q==="experientiallabs"||q==="experimentallabs"||q==="experiential labs"||q==="experimental labs"||q==="experiential"||q==="experimental"?"ExpLabs":q==="tokenharbor"||q==="token harbor"||q==="token_harbor"||q==="thk"?"TokenHarbor":q==="apinex"||q==="apx"?"APInex":q==="xkiro"||q==="kiro"?"xKiro":q==="infron"?"Infron":null})(f);if(h&&!p){let te=a.aiProvider||$||"Google";L(q=>(F(q.length+1),[...q,{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(n==="ENV"){h||L(te=>(F(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 S=a.aiProvider||$||"Google",E=a.apiTier||et||"Free",z=a.quotas||Ie||{},Z=new Set;(dn(S,E)||[]).forEach(te=>{let q=typeof te=="string"?te:te.cmd||te.name||te.id||String(te);q&&Z.add(q)});for(let te of c)try{if(await un(te,{silent:!0})){let je=z?.providerTiers?.[te]||"Free";(dn(te,je)||[]).forEach(ke=>{let rt=typeof ke=="string"?ke:ke.cmd||ke.name||ke.id||String(ke);rt&&Z.add(rt)})}}catch{}let Q=Z.has(n);h?h!==n&&L(te=>(F(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}])):Q||L(te=>(F(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 We=nr(()=>{let x={};for(let a=0;a<t.length;a++)if(t[a]==="--key"&&t[a+1]){let o=t[a+1];if(x.key=o,o.includes("@")){let n=o.split("@"),h=n[0],f=n[1].toLowerCase();if(["google","deepseek","openrouter","nvidia","mistral","ollama","inferx","sensenova","aihubmix","aihub","poolside","pool","9router","9r","explabs","tokenharbor","token_harbor","thk","infron","apinex","apx","xkiro","kiro"].includes(f)){let c="Google";f==="google"?c="Google":f==="deepseek"?c="DeepSeek":f==="openrouter"?c="OpenRouter":f==="nvidia"?c="NVIDIA":f==="mistral"?c="Mistral":f==="ollama"?c="Ollama":f==="inferx"?c="InferX":f==="sensenova"?c="SenseNova":f==="poolside"||f==="pool"?c="Poolside":f==="9router"||f==="9r"?c="9router":f==="aihubmix"||f==="aihub"?c="AIHubMix":f==="explabs"?c="ExpLabs":f==="tokenharbor"||f==="token_harbor"||f==="thk"?c="TokenHarbor":f==="infron"?c="Infron":f==="apinex"||f==="apx"?c="APInex":(f==="xkiro"||f==="kiro")&&(c="xKiro"),x.key=h,x.provider=c}}}for(let a=0;a<t.length;a++){let B=t[a];if(B==="--key"){a++;continue}if(B==="--model"&&t[a+1])x.model=t[a+1],a++;else if(B==="--memory"&&t[a+1])x.memory=t[a+1].toLowerCase(),a++;else if(B==="--resume"&&t[a+1])x.resume=t[a+1],a++;else if(B==="--package"&&t[a+1]){let o=t[a+1].toLowerCase();["npm","pnpm","yarn","bun"].includes(o)&&(x.package=o),a++}else if(B==="--auto-del"&&t[a+1]){let o=t[a+1].toLowerCase();["1d","7d","30d"].includes(o)&&(x.autoDel=o),a++}else if(B==="--auto-exec"&&t[a+1])x.autoExec=t[a+1].toLowerCase(),a++;else if(B==="--yolo"&&t[a+1])x.autoExec=t[a+1].toLowerCase(),a++;else if(B==="--external-access"&&t[a+1])x.externalAccess=t[a+1].toLowerCase(),a++;else if(B==="--mode"&&t[a+1]){let n=t[a+1].toLowerCase();if(["flux","flow","icu","computer","fluxcu"].includes(n)){let h="Flux";n==="flux"?h="Flux":n==="flow"?h="Flow":n==="icu"||n==="computer"?h="ICU":n==="fluxcu"&&(h="FluxCU"),x.mode=h}a++}else if(B==="--thinking"&&t[a+1]){let n=t[a+1].toLowerCase();if(["fast","low","medium","high","xhigh","standard"].includes(n)){let h="Medium";n==="fast"?h="Fast":n==="low"?h="Low":n==="standard"?h="Standard":n==="medium"?h="Medium":n==="high"?h="High":n==="xhigh"&&(h="xHigh"),x.thinking=h}a++}else if(B==="--provider"&&t[a+1]){let o=t[a+1].toLowerCase();if(["google","deepseek","openrouter","nvidia","mistral","ollama","inferx","sensenova","aihubmix","aihub","poolside","pool","9router","9r","explabs","tokenharbor","token_harbor","thk","infron","apinex","apx","xkiro","kiro"].includes(o)){let n="Google";o==="google"?n="Google":o==="deepseek"?n="DeepSeek":o==="openrouter"?n="OpenRouter":o==="nvidia"?n="NVIDIA":o==="mistral"?n="Mistral":o==="ollama"?n="Ollama":o==="inferx"?n="InferX":o==="sensenova"?n="SenseNova":o==="poolside"||o==="pool"?n="Poolside":o==="9router"||o==="9r"?n="9router":o==="aihubmix"||o==="aihub"?n="AIHubMix":o==="explabs"?n="ExpLabs":o==="tokenharbor"||o==="token_harbor"||o==="thk"?n="TokenHarbor":o==="infron"?n="Infron":o==="apinex"||o==="apx"?n="APInex":(o==="xkiro"||o==="kiro")&&(n="xKiro"),x.provider=n}a++}else(B==="--resume"||B==="-r")&&t[a+1]?(x.resume=t[a+1],a++):B==="--playground"?x.playground=!0:(B==="--original-cwd"||B==="--orginal-cwd")&&t[a+1]&&(x.originalCwd=t[a+1],a++)}return x},[t]),Et=async(x=!1,a=null)=>{let B=a||re;x&&L(o=>(F(o.length+1),[...o,{id:"check-"+Date.now(),role:"system",text:"\u2726 Checking for updates...",isMeta:!0}]));try{let n=await(await fetch("https://registry.npmjs.org/fluxflow-cli",{cache:"no-store"})).json(),h=n["dist-tags"]?.latest,f=n["dist-tags"]?.stable;if(h&&Ur(h),h&&h!==So){let c=h===f?`v${h}`:`v${h}`;!x&&B.autoUpdate?ie("update"):L(g=>{let p=[...g],S=x?p.length:Math.min(p.length,3);return p.splice(S,0,{id:"update-"+Date.now(),role:"system",text:`A new version (${c}) is here.
|
|
63
|
-
|
|
64
|
-
\u2022 Type \`/update latest\` to apply the update.
|
|
65
|
-
\u2022 Type \`/changelog\` to view the release notes.`,isUpdateNotification:!0,isMeta:!0}),p})}else x&&L(c=>{F(c.length+1);let g=h&&h===f?`${So}`:So;return[...c,{id:"uptodate-"+Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Already up to date (${g}).
|
|
66
|
-
\u2800`,isMeta:!0}]})}catch(o){x&&L(n=>(F(n.length+1),[...n,{id:"check-err-"+Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Failed to check for updates: ${o.message}.
|
|
67
|
-
\u2800`,isMeta:!0}]))}};xt(()=>{let x=r?.columns||80,a=()=>{let B=r?.columns||80,o=r?.rows||24;B!==x&&(x=B,r.write("\x1B[2J\x1B[3J\x1B[H")),be({columns:B,rows:o})};return r.on("resize",a),()=>{r.off("resize",a)}},[r]);let[Ke,co]=R("Medium"),[$,nn]=R("Google"),[ir,$r]=R(0),[wn,Ur]=R(null),[Tn,Ss]=R(!1),[qe,jt]=R(bo("Google","Free")||"gemma-4-31b-it"),[_r,Be]=R(!1),[ce,T]=R(!1),[k,ye]=R(Cl("gemma_janitor_fallback_google")||"gemma-4-26b-a4b-it"),[Ae,ot]=R(!0),[lt,Qe]=R(!0),uo=Ze(0),[Ye,Nt]=R(null),[yn,Cn]=R(""),vs=async x=>{let a=za(x);if(a)try{await ft.ensureDir(Ct.dirname(a));let B=[];if(ft.existsSync(a)){let o=ft.readFileSync(a,"utf8").trim();if(o)try{B=Qa(o)}catch{B=[]}}Array.isArray(B)||(B=[]),B.push({key:"shift+enter",command:"workbench.action.terminal.sendSequence",args:{text:"\x1B[13;2u"},when:"terminalFocus"}),ft.writeFileSync(a,JSON.stringify(B,null,4),"utf8"),Ms="Shift + Enter",L(o=>(F(o.length+1),[...o,{id:"kb-success-"+Date.now(),role:"system",text:`\u2726 Successfully configured Shift+Enter in your ${x} keybindings!
|
|
68
|
-
`,isMeta:!0}]))}catch(B){L(o=>(F(o.length+1),[...o,{id:"kb-error-"+Date.now(),role:"system",text:`\u2726 Failed to update keybindings: ${B.message}.
|
|
69
|
-
\u2800`,isMeta:!0}]))}},[vt,ie]=R("chat"),[Fn,Hr]=R([]),Wr=C.startsWith("/k");xt(()=>{if(!Wr)return;let x=!0,a=async()=>{try{let o=await xa(process.pid);x&&Hr(o||[])}catch{}};a();let B=setInterval(a,5e3);return()=>{x=!1,clearInterval(B)}},[Wr]);let[et,kt]=R("Free"),[Ie,io]=R({limitMode:"Daily",agentLimit:99999999,tokenLimit:99999999999999,backgroundLimit:999999,searchLimit:100,customModelId:"",customLimit:0,providerBudgets:{}}),[Oo,mo]=R(null),[Vo,ec]=R("chat"),[rn,Bs]=R("settings"),[$n,tc]=R([]),[Mu,oc]=R(0),[Ai,Xr]=R(0),[Es,Li]=R({}),[lr,ar]=R({}),[Un,vo]=R(0),[re,Ft]=R({memory:!0,theme:"Dark",compression:0,autoExec:!1,autoDeleteHistory:"7d",autoUpdate:!1,updateManager:"npm",customUpdateCommand:"",clipboardContext:!1}),s=nr(()=>ut(re.theme),[re.theme]),[Mn,Ds]=R({preset:"Default",name:null,nickname:null,instructions:null}),[Yo,Gr]=R({keyType:"Default",quality:"Low-High",apiKey:""}),[cr,Is]=R({enabled:!1,model:"Default",provider:"",baseUrl:""}),[No,sn]=R({tokens:0}),[Pi,ks]=R(0),Oi=Ze(0),As=Ze({totalWords:0,startTime:0,wps:0,chunks:[]}),[Ni,Fi]=R(0),[$i,nc]=R(0),[fo,Ui]=R(0),[rc,_n]=R(0),Hn=Ze(0),[sc,Wn]=R(0),[ic,Sn]=R(0),to=Ze([]),Xn=Ze(0),[lc,Gn]=R(0),Kn=Ze(0),[vn,_i]=R(0),[Bo,Hi]=R(0),[Vn,Wi]=R(0),[Su,ac]=R(0),[vu,cc]=R(0),[Bu,dc]=R(0),[Kr,uc]=R(0),[Vr,mc]=R(0),[Yr,fc]=R(0),[Xi,xc]=R(0),[Yn,Ls]=R(null),[dr,Ps]=R(null),[jr,Gi]=R(null),[jn,ur]=R("daily"),[gc,Eo]=R(0),[mr,fr]=R(""),qn="flow-playground",[gt,qr]=R(t.includes("--playground")?qn:ui());xt(()=>{if(jo.current)return;let x=fo-Hn.current,a=Bo-Xn.current,B=vn-Kn.current;_n(x),Wn(a),Gn(Math.max(0,B)),gt&&Rl(gt,x,No.tokens).catch(()=>{})},[fo,Bo,vn,gt,No.tokens]),xt(()=>{vt==="apiTier"&&(async()=>{let a=await os();Ls(a);let B=await ns();Ps(B);let o=await li(Ie.resetDay||1);Gi(o)})()},[vt,Ie.resetDay]);let[Do,Ki]=R(null),[zn,Qn]=R(""),[xr,Vi]=R(!1),[Os,hc]=R([]),[Eu,Du]=R(0),Ns=Ze(!0),Yi=Ze(!0),Fs=Ze($),$s=Ze(!1),Us=Ze(!0);xt(()=>{(_r||ce)&&(L(x=>(F(x.length+1),[...x,{id:Date.now(),role:"system",text:`\u2726 Wild${ce?"er":""}Card Tooling:
|
|
70
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Status: Disabled.
|
|
71
|
-
\u2800`,isMeta:!0}])),Be(!1),T(!1)),process.env.forcedReasoning&&(L(x=>(F(x.length+1),[...x,{id:Date.now(),role:"system",text:`\u2726 Forced Reasoning:
|
|
72
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Status: Disabled.
|
|
73
|
-
\u2800`,isMeta:!0}])),process.env.forcedReasoning=!1),Ke==="xHigh"&&!Ns.current&&co("Medium")},[qe]);let ji;xt(()=>{if(Yi.current){ji=setTimeout(()=>{Yi.current=!1,Fs.current=$},1e3);return}return Fs.current!==$&&(Fs.current=$,co($==="SenseNova"||$==="Poolside"?"High":"Low")),()=>{clearTimeout(ji)}},[$,qe]);let qi;xt(()=>{if(!Ye)return;if(Ns.current){qi=setTimeout(()=>{Ns.current=!1},1500);return}let x=bo($,et),a=x;return x.includes("gemma")?a="Gemma":x.includes("deepseek")?a="DeepSeek Flash":x.includes("devstral")?a="Devstral":x.includes("mistral")?a="Mistral":x.includes("gemini")&&(a="Gemini Flash"),jt(x),qt({apiTier:et,activeModel:x}),()=>{clearTimeout(qi)}},[et,$,Ye]);let pc=nr(()=>{let x=bn();return{isIDE:!["Terminal","Windows Terminal"].includes(x)||!!process.env.VSC_TERMINAL_URL||!!process.env.INTELLIJ_TERMINAL_COMMAND_BLOCKS,get shortcut(){return Ms}}},[]),_s=Ze(null),Hs=Ze("");xt(()=>{_s.current=Do},[Do]),xt(()=>{Hs.current=zn},[zn]);let[Ws,Xs]=R(!1),Gs=Ze(new Set),zi=Ze(new Set),Qi=Ze(new Set),[Zt,ln]=R(null),[Bn,Ks]=R(null),Fo=x=>{ln(null),ie("chat")},Ji=x=>{let a=Math.floor(x/3600),B=Math.floor(x%3600/60),o=x%60,n=[];return a>0&&n.push(`${a}h`),(B>0||a>0)&&n.push(`${B}m`),n.push(`${o}s`),n.join(" ")},En=x=>x<1e3?`${x}ms`:Ji(Math.floor(x/1e3)),[an,Vs]=R(null),[Ys,Zi]=R(""),[bc,wc]=R(!1),[Ri,gr]=R(0),hr;xt(()=>{let x;if(an&&re.loadingPhrases!==!1){let a=o=>{Zi(o[Math.floor(Math.random()*o.length)])},B=()=>{sr?a(sr):process.env.HALLOWEEN_EEGG==="true"||process.env.HALLOWEEN_EEGG===!0?import("./halloween_witty_phrases-IJGE3RWX.js").then(({HALLOWEEN_WITTY_PHRASES:n})=>{sr=n,a(sr)}):import("./witty_phrases-EEDEYYAH.js").then(({WITTY_LOADING_PHRASES:n})=>{sr=n,a(sr)})};Ys||B(),x=setInterval(B,1e4)}else Zi("");return()=>{clearInterval(x)}},[an,re]);let[Iu,Tc]=R(!0),[Jn,js]=R(!1),[pr,el]=R(!1),[yc,Cc]=R(!1),[tl,ku]=R(null),[ol,br]=R(0),[Mc,nl]=R([]),Dn=Ze(null),jo=Ze(!1);xt(()=>()=>{Dn.current&&clearTimeout(Dn.current)},[]);let qs=Ze(!1),[wr,zs]=R(null),[Sc,Qs]=R(null),[Au,vc]=R(null);xt(()=>br(0),[C]);let[$t,Bc]=R(()=>{let x={id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0},a=process.cwd()===ki.homedir(),B=(()=>{let n=process.cwd().toLowerCase();if(process.platform==="win32"){let h=process.env.SystemRoot?.toLowerCase()||"c:\\windows",f=process.env.ProgramFiles?.toLowerCase()||"c:\\program files",c=process.env["ProgramFiles(x86)"]?.toLowerCase()||"c:\\program files (x86)";return n.startsWith(h)||n.startsWith(f)||n.startsWith(c)}else return n==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(f=>n.startsWith(f))})(),o=[x];return B?o.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}):a&&o.push({id:"home-warning",role:"system",text:"[SECURITY ALERT] HOME DIRECTORY DETECTED",subText:`You are currently in ${ki.homedir()}. Working here is high-risk as the agent may modify system-sensitive configurations. Please open FluxFlow in project folder.`,isHomeWarning:!0}),o}),L=x=>{Bc(a=>{let B=typeof x=="function"?x(a):x;if(B.length>1){let o=B[B.length-1],n=B[B.length-2];if(o?.text?.includes("Request Cancelled")&&n?.text?.includes("Request Cancelled"))return B.slice(0,-1)}return B})},qo=Ze(null),[rl,Ec]=R(""),[sl,il]=R(!1),ll=Ze(""),al=Ze(null);xt(()=>{if($t.length===0)return;let x=$t[$t.length-1];if(x&&(x.role==="agent"||x.role==="assistant")){let B=(x.text||"").match(/\[ANSWER\]([\s\S]*?)(?:\[\/ANSWER\]|$)/i);if(B){let o=B[1].trim();o&&o!==ll.current&&(Ec(o),ll.current=o,al.current!==x.id&&il(!0))}}},[$t]);let[cn,F]=R($t.length),[In,Js]=R(0),Lu=Ze([]),xo=Ze({completedIndex:0,columns:0,historicalBlocks:[],seenSelections:new Set,chatId:"",clearKey:0,theme:""}),cl=nr(()=>{let x=H.columns||80,a=/Selection: (.*)/,B=[],o=new Set,n=xo.current.columns!==x,h=cn<xo.current.completedIndex,f=xo.current.chatId!==gt,c=xo.current.clearKey!==In,g=xo.current.theme!==re.theme;if(n||h||f||c||g){let Z=$t.slice(0,cn);for(let G=0;G<Z.length;G++){let Q=Z[G];if(Q.isAskRecord&&Q.text){let q=Q.text.match(a);if(q&&q[1].trim()){let je=q[1].trim();if(o.has(je))continue;o.add(je)}}let te=Cr(Q,x);for(let q=0;q<te.completed.length;q++)B.push(te.completed[q]);for(let q=0;q<te.active.length;q++)B.push(te.active[q])}xo.current={completedIndex:cn,columns:x,historicalBlocks:B,seenSelections:new Set(o),chatId:gt,clearKey:In,theme:re.theme}}else if(B=xo.current.historicalBlocks,o=xo.current.seenSelections,cn>xo.current.completedIndex){B=[...B],o=new Set(o);let Z=$t.slice(xo.current.completedIndex,cn);for(let G=0;G<Z.length;G++){let Q=Z[G];if(Q.isAskRecord&&Q.text){let q=Q.text.match(a);if(q&&q[1].trim()){let je=q[1].trim();if(o.has(je))continue;o.add(je)}}let te=Cr(Q,x);for(let q=0;q<te.completed.length;q++)B.push(te.completed[q]);for(let q=0;q<te.active.length;q++)B.push(te.active[q])}xo.current={completedIndex:cn,columns:x,historicalBlocks:B,seenSelections:o,chatId:gt,clearKey:In}}let p=$t.slice(cn),S=[],E=[];for(let Z=0;Z<p.length;Z++){let G=p[Z];if(G.isAskRecord&&G.text){let te=G.text.match(a);if(te&&te[1].trim()){let q=te[1].trim();if(o.has(q))continue}}let Q=Cr(G,x);for(let te=0;te<Q.completed.length;te++)S.push(Q.completed[te]);for(let te=0;te<Q.active.length;te++)E.push(Q.active[te])}if(j.current){let Z=Cr(j.current,x);for(let G=0;G<Z.completed.length;G++)S.push(Z.completed[G]);for(let G=0;G<Z.active.length;G++)E.push(Z.active[G])}let z=S.length===0?B:B.concat(S);return z.length>=75e3&&(z=[...z],z.push({key:`memory-warning-block-${z.length}`,msg:{role:"system",text:"\u26A0\uFE0F MEMORY WARNING: CHAT IS GETTING VERY LONG",subText:`This session has reached ${z.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:z,active:E}},[$t,cn,H.columns,In,gt,$e]),Dc=nr(()=>{if(!Do||!zn)return!1;let x=zn.trim();return x.endsWith("?")||x.endsWith(":")||/\[[yYnN/]+\]\s*$/.test(x)||/\([yYnN]\)\s*$/.test(x)},[Do,zn]);iu((x,a)=>{if(!(x==="\x1B[I"||x==="\x1B[O"||x==="[I"||x==="[O")){if(a.ctrl&&(x.toLowerCase()==="r"||x===""||x==="")){Sa();return}if(vt==="stats"){if(jn==="dailyModelBreakdown"||jn==="modelBreakdown"){if(a.tab&&!a.shift){ur(o=>o==="dailyModelBreakdown"?"modelBreakdown":"dailyModelBreakdown"),Eo(0);return}if(a.space||x===" "){ur(o=>o==="dailyModelBreakdown"?"daily":"monthly"),Eo(0),fr("");return}if(a.escape){if(mr){fr(""),Eo(0);return}ie("chat");return}if(a.upArrow){Eo(o=>Math.max(0,o-1));return}if(a.downArrow){Eo(o=>Math.min(ee.current,o+1));return}if(a.backspace||a.delete){fr(o=>o.slice(0,-1)),Eo(0);return}if(x&&x!==" "&&!a.space&&!a.ctrl&&!a.meta&&x.length===1&&x.charCodeAt(0)>=32){fr(o=>o+x),Eo(0);return}return}if(a.tab&&!a.shift){ur(o=>o==="daily"?"monthly":"daily"),Eo(0);return}if(a.space||x===" "){ur(o=>o==="daily"?"dailyModelBreakdown":"modelBreakdown"),Eo(0),fr("");return}if(a.upArrow){Eo(o=>Math.max(0,o-1));return}if(a.downArrow){Eo(o=>Math.min(ee.current,o+1));return}}if(St){(a.return||a.escape)&&(fe.current=!0,Xe(null));return}if(xe){let B=bn(),o=Za(B);if(a.upArrow)Ce(n=>n>0?n-1:o.length-1);else if(a.downArrow)Ce(n=>n<o.length-1?n+1:0);else if(a.return){let n=o[Pe];if(n.action==="dismiss")Me(!1);else if(n.url){let h=process.platform==="win32"?`start ${n.url}`:process.platform==="darwin"?`open ${n.url}`:`xdg-open ${n.url}`;Ko(h),Me(!1)}}return}if(a.tab&&Do){Vi(B=>!B);return}if(xr&&Do){let B=a.pageUp||x==="\x1B[5~"||x==="[5~",o=a.pageDown||x==="\x1B[6~"||x==="[6~",n=a.ctrl&&(x==="o"||x==="");if(B||o||n)return;if(a.return)if(Rn)wo("\r");else{let h=process.platform==="win32";wo(h?`\r
|
|
74
|
-
`:`
|
|
75
|
-
`),Qn(f=>f+`
|
|
76
|
-
`)}else if(a.backspace||a.delete)Rn?wo("\x7F"):(wo("\b \b"),Qn(h=>h.slice(0,-1)));else if(a.upArrow)wo(a.shift?"\x1B[1;2A":"\x1B[A");else if(a.downArrow)wo(a.shift?"\x1B[1;2B":"\x1B[B");else if(a.rightArrow)wo(a.shift?"\x1B[1;2C":"\x1B[C");else if(a.leftArrow)wo(a.shift?"\x1B[1;2D":"\x1B[D");else if(a.escape)wo("\x1B");else if(a.ctrl&&x){let h=x.toLowerCase().charCodeAt(0);h>=97&&h<=122?wo(String.fromCharCode(h-96)):wo(x)}else x&&(wo(x),Rn||Qn(h=>h+x));return}if(vt==="providerBudgetSelect"){let B=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","Infron","APInex","xKiro"];if(a.upArrow){Xr(o=>(o-1+B.length)%B.length);return}else if(a.downArrow){Xr(o=>(o+1)%B.length);return}else if(x===" "){let o=B[Ai];Li(n=>({...n,[o]:!n[o]}));return}else if(a.return){let o=B.filter(h=>Es[h]);if(o.length===0)return;let n={...Ie,providerBudgets:{...Ie.providerBudgets||{},__useProvider:!0}};io(n),tc(o),oc(0),Xr(0),ie("providerBudgetFlow");return}else if(a.escape){ie("budgetTypeSelect");return}return}if(vt==="providerBudgetFlow"){let B=$n.length,o=B*4+1;if(a.upArrow){vo(n=>n===o-1?Math.max(0,(B-1)*4):n>=4?n-4:n);return}else if(a.downArrow){vo(n=>n===o-1?n:n+4<o-1?n+4:o-1);return}else if(a.leftArrow){vo(n=>n===o-1?n:n%4>0?n-1:n);return}else if(a.rightArrow||a.tab){vo(n=>n===o-1?n:n+1<o?n+1:n);return}else if(a.return){if(Un===o-1){let n=Ie.providerBudgets||{},h={__useProvider:!0};for(let g of $n){let p=lr[g]||{};h[g]={agentLimit:9999999999,tokenLimit:parseInt(p.tokenLimit,10)||0,monthlyTokenLimit:parseInt(p.monthlyTokenLimit,10)||0,dailyCostLimit:parseFloat(p.dailyCostLimit)||0,monthlyCostLimit:parseFloat(p.monthlyCostLimit)||0}}let f={...Ie,providerBudgets:h};io(f),qt({apiTier:et,quotas:f}),ie(Vo==="settings"?"resetMode":"budgetResetMode")}else vo(n=>Math.min(o-1,n+1));return}else if(a.escape){ie("providerBudgetSelect");return}return}if(a.escape){if(sl){if(il(!1),$t.length>0){let B=$t[$t.length-1];B&&(al.current=B.id)}return}if(st.length>0&&vt==="chat"){Se(!0);return}if(d){v(!1);return}if(Jn||Do||Zt||Bn)qs.current=!0,ia(),jl(),Zt&&(Zt.resolve("deny"),ln(null)),Bn&&(Bn.resolve(null),Ks(null)),Cc(!1),tl&&clearTimeout(tl);else if(vt==="revert")ie("chat"),br(0);else if(vt!=="chat"&&vt!=="settings")ie("chat");else{if(!Ye&&ir===1){$r(0),Cn("");return}br(B=>{let o=B+1;return o===1?(Dn.current&&clearTimeout(Dn.current),Dn.current=setTimeout(()=>br(0),2e3)):o===2&&(Dn.current&&clearTimeout(Dn.current),br(0),C.length>0?w(""):Sr.getChatHistory(gt).then(n=>{n.length>0?(nl(n.reverse()),ie("revert")):L(h=>(F(h.length+1),[...h,{id:"revert-empty-"+Date.now(),role:"system",text:`\u2726 Nothing to revert to.
|
|
77
|
-
\u2800`,isMeta:!0}]))})),o})}}if(st.length>0&&vt==="chat"&&D===-1){if(a.upArrow){Ne(B=>{let o=B>0?B-1:st.length-1,n=0;for(;o!==B&&n<st.length;){let h=st[o],f=h?.cmd||h||"";if(typeof f=="string"&&f.trimStart().startsWith("---"))o=o>0?o-1:st.length-1,n++;else break}return o});return}if(a.downArrow){Ne(B=>{let o=B<st.length-1?B+1:0,n=0;for(;o!==B&&n<st.length;){let h=st[o],f=h?.cmd||h||"";if(typeof f=="string"&&f.trimStart().startsWith("---"))o=o<st.length-1?o+1:0,n++;else break}return o});return}if(a.return)return}if(a.tab&&vt==="chat"){if(st.length>0){let B=st[Oe]||st[0],o=C.split(" ");if(o.length===1)w(B.cmd+" ");else{let n=o.slice(0,-1);w(n.join(" ")+" "+B.cmd+" ")}Ne(0),O(n=>n+1);return}else if(C.trim()===""){let B=Date.now();if(B-Ge.current<500)return;Ge.current=B;let o=["Flux","Flow","ICU","FluxCU"],n=(o.indexOf(Y)+1)%o.length,h=o[n>=0?n:0];ue(h),L(f=>[...f,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${Ei(h)}
|
|
78
|
-
\u2800`,isMeta:!0}]);return}}if(a.ctrl&&x==="c"&&vt!=="exit"){if(C.length>0){w("");return}if(a.shift){ie("exit"),v(!1);return}d?(ie("exit"),v(!1)):v(!0)}a.return&&(a.shift||a.ctrl||a.meta||a.leftAlt||a.rightAlt)&&w(B=>B.replace(/\\\r?$/,"").replace(/\r?$/,"")+`
|
|
79
|
-
`)}}),xt(()=>{process.stdout.write("\x1B[?1004h");let x=a=>{let B=a.toString();B.includes("\x1B[I")?(Qe(!0),uo.current=Date.now()):B.includes("\x1B[O")&&(Qe(!1),uo.current=Date.now())};return process.stdin.on("data",x),()=>{process.stdout.write("\x1B[?1004l"),process.stdin.off("data",x)}},[]);let zr=Ze(re.theme);xt(()=>{zr.current&&zr.current!==re.theme?(zr.current=re.theme,r&&(r.write("\x1B[2J\x1B[3J\x1B[H"),r.isTTY&&r.write("\x1B[?2004h")),Js(x=>x+1),Qo()):zr.current=re.theme},[re.theme,r]),xt(()=>{async function x(){Ql(p=>{let S=p?.reason||"cwd_mismatch";J.current=S,Me(!1),fe.current||Xe(S)});try{let p=JSON.parse(ft.readFileSync(Ct.join(process.cwd(),"package.json"),"utf8"));di(So||p.version||"2.0.0")}catch{di("2.0.0")}process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07")),await Xa()||(L(p=>(F(p.length+1),[...p,{id:"setup-"+Date.now(),role:"system",text:"\u2726 Installing Required dependencies... (One-time setup)",isMeta:!0}])),await Ga(),L(p=>(F(p.length+1),[...p,{id:"setup-done-"+Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m All dependencies installed successfully.
|
|
80
|
-
\u2800`,isMeta:!0}])));let a=await ii();$s.current=a.systemSettings?.allowExternalAccess??!1,Us.current=a.systemSettings?.memory??!0,We.mode?ue(We.mode):ue(a.mode),le(a.display??0),We.thinking?co(We.thinking):co(a.thinkingLevel);let B=We.provider||a.aiProvider||"Google";nn(B);let n=(a.quotas?.providerTiers||{})[B]||a.apiTier||"Free";if(he.current=a.activeModel,We.model)jt(We.model);else if(We.provider){let p=bo(B,n);jt(p)}else jt(a.activeModel);Ss(a.showFullThinking),kt(n),io(a.quotas||{limitMode:"Daily",agentLimit:99999999,tokenLimit:99999999999999,backgroundLimit:999999,searchLimit:100,customModelId:"",customLimit:0,providerBudgets:{}});let h={memory:!0,compression:0,autoExec:!1,autoDeleteHistory:"7d",autoUpdate:!1,updateManager:"npm",customUpdateCommand:"",...a.systemSettings||{}};We.memory==="on"?h.memory=!0:We.memory==="off"&&(h.memory=!1),B==="NVIDIA"&&process.env.NVIDIA_BASE_URL&&(h.memory=!1,L(p=>[...p,{role:"system",text:`\u2726 MEMORY
|
|
81
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Currently not available.
|
|
82
|
-
\u2800`,isMeta:!0}])),We.package&&(h.updateManager=We.package),We.autoDel&&(h.autoDeleteHistory=We.autoDel),We.autoExec==="on"?h.autoExec=!0:We.autoExec==="off"&&(h.autoExec=!1),We.externalAccess==="on"?h.allowExternalAccess=!0:We.externalAccess==="off"&&(h.allowExternalAccess=!1),We.playground&&(h.allowExternalAccess=!1,h.memory=!1),Ft(h),Ds(a.profileData),Gr(a.imageSettings||{keyType:"Default",quality:"Low-High",apiKey:""}),Is({enabled:!1,model:"Default",provider:"",baseUrl:"",...a.autoCompletion||{}});let f=We.key;if(f||(f=await un(B)),B==="c_openai"){let p=f||"";Nt(p),yo(p,{aiProvider:B,onIDEApproval:Fo})}else f&&(Nt(f),yo(f,{aiProvider:B,onIDEApproval:Fo}));if(a.systemSettings?.autoDeleteHistory&&Zl(a.systemSettings.autoDeleteHistory),We.playground||(is(qn).catch(()=>{}),ft.remove(Ct.join($o,"playground")).catch(()=>{})),Et(!1,h),await Promise.all([Hl(),Sr.recoverCrashedTransaction()]),We.resume){let p=await Jo(),S=We.resume;if(p[S]){jo.current=!0,qr(S);let E=await Br(S);Hn.current=fo-E.total,Xn.current=Bo,Kn.current=vn,to.current=[],_n(E.total),Wn(0),Sn(0),Gn(0),sn({tokens:E.context}),jo.current=!1;let z=[...p[S].messages];z[0]?.text?.includes("\u2591\u2591\u2591\u2588\u2588\u2588")||z.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),L(z),ie("chat"),L(G=>{let Q=[...G,{id:"sys-"+Date.now(),role:"system",text:`\u2726 SESSION RESUMED
|
|
83
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m '${S}'.
|
|
84
|
-
\u2800`,isMeta:!0}];return F(Q.length),Q})}else L(E=>[...E,{id:"sys-err-"+Date.now(),role:"system",text:`\u2726 Chat session [${S}] not found. Started new session.
|
|
85
|
-
\u2800`,isMeta:!0}])}if(We.playground){let p=Ct.join($o,"playground");try{ft.ensureDirSync(p),process.chdir(p)}catch{}let S=await Jo();if(S[qn]){jo.current=!0;let E=await Br(qn);Hn.current=fo-E.total,Xn.current=Bo,Kn.current=vn,to.current=[],_n(E.total),Wn(0),Sn(0),Gn(0),sn({tokens:E.context}),jo.current=!1;let z=[...S[qn].messages];z[0]?.isLogo||z.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),L(z),L(Z=>{let G=[...Z,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND Session restored
|
|
86
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m CWD locked to: '${p}'.
|
|
87
|
-
\u2800`,isMeta:!0}];return F(G.length),G})}else L(E=>{let z=[...E,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND Mode active
|
|
88
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m CWD locked to: 'FluxFlow/playground'.
|
|
89
|
-
\u2800`,isMeta:!0}];return F(z.length),z})}let c=bn();if(!["Terminal","Windows Terminal"].includes(c)){let p=za(c);if(p)try{let S=[];if(ft.existsSync(p)){let E=ft.readFileSync(p,"utf8").trim();E&&(S=Qa(E))}fu(S)?Ms="Shift + Enter":ie("keybindingsPrompt")}catch{}}ot(!1)}x()},[]),xt(()=>{let x;return d&&(b(10),x=setInterval(()=>{b(a=>a<=1?(v(!1),0):a-1)},1e3)),()=>{x&&clearInterval(x)}},[d]),xt(()=>{if(!Ae){let x=We.model&&qe===We.model?he.current:qe,a=re;We.playground&&(a={...re,allowExternalAccess:$s.current,memory:Us.current}),qt({mode:Y,thinkingLevel:Ke,aiProvider:$,activeModel:x||qe,showFullThinking:Tn,systemSettings:a,profileData:Mn,imageSettings:Yo,autoCompletion:cr,apiTier:et})}},[Y,Ke,$,qe,Tn,re,Mn,Yo,cr,Ae,We,et]);let dl=async x=>{let a=x.trim(),B={Google:{prefix:"",minLength:0},OpenRouter:{prefix:"",minLength:0},DeepSeek:{prefix:"",minLength:0},Mistral:{prefix:"",minLength:0},NVIDIA:{prefix:"",minLength:0},Ollama:{prefix:"",minLength:0},InferX:{prefix:"",minLength:0},SenseNova:{prefix:"",minLength:0},AIHubMix:{prefix:"",minLength:0},Poolside:{prefix:"",minLength:0},"9router":{prefix:"",minLength:0},ExpLabs:{prefix:"",minLength:0},TokenHarbor:{prefix:"",minLength:0},Infron:{prefix:"",minLength:0},APInex:{prefix:"",minLength:0},xKiro:{prefix:"",minLength:0}},{prefix:o,minLength:n}=B[$]??{prefix:"",minLength:0},h=($==="Ollama"||$==="9router")&&(a.trim()==="LOCAL"||a.trim()===""),f=$==="c_openai",c=h?"LOCAL":a;if(f){let g=a.trim().replace(/\/+$/,""),p={...re,customOpenAIBaseUrl:g,memory:!1};Ft(p);let E=await un("c_openai")||"";Nt(E),yo(E,{aiProvider:"c_openai",onIDEApproval:Fo});let z=bo("c_openai",et)||"";jt(z),await qt({mode:Y,thinkingLevel:Ke,aiProvider:"c_openai",activeModel:z,showFullThinking:Tn,systemSettings:p,profileData:Mn,imageSettings:Yo,autoCompletion:cr,apiTier:et}),L(Z=>[...Z,{role:"system",text:`\u2726 Custom (OpenAI) Base URL saved!
|
|
90
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Endpoint: ${g}${z?`
|
|
91
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: ${z}`:""}
|
|
92
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with Custom (OpenAI).
|
|
93
|
-
\u2800`,isMeta:!0}]),Cn("");return}if(h||a.startsWith(o)&&a.length>=n){await si($,c),Nt(c),yo(c,{aiProvider:$,onIDEApproval:Fo});let g="gemma-4-31b-it";$==="OpenRouter"?g="google/gemma-4-31b-it:free":$==="DeepSeek"?g="deepseek-v4-flash":$==="NVIDIA"?g="deepseek-ai/deepseek-v4-flash":$==="Ollama"||$==="9router"?g=qe||"":($==="InferX"||$==="SenseNova"||$==="AIHubMix"||$==="Poolside"||$==="ExpLabs"||$==="TokenHarbor"||$==="Infron"||$==="APInex"||$==="xKiro")&&(g=bo($,et)||""),jt(g);let p={...re};h&&$==="Ollama"&&(p={...p,ollamaEndpoint:"Local"},Ft(p)),($==="Ollama"||$==="InferX"||$==="SenseNova"||$==="AIHubMix"||$==="Poolside"||$==="9router"||$==="ExpLabs"||$==="TokenHarbor"||$==="Infron"||$==="APInex"||$==="xKiro")&&(p={...p,memory:!1},Ft(p));let S="";if($==="9router"){let E=await Bi();E.ok||(S=`
|
|
94
|
-
|
|
95
|
-
\x1B[33m\u2726 WARNING: 9router does not appear to be running on ${E.url}.\x1B[39m
|
|
96
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m To start 9router: \x1B[36mnpx 9router\x1B[39m or \x1B[36mnpm i -g 9router && 9router\x1B[39m`)}L(E=>[...E,{role:"system",text:`\u2726 ${$} API Key saved successfully! ${g?`
|
|
97
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model set to ${g}.`:""}${h&&$==="Ollama"?`
|
|
98
|
-
\u2726 Ollama Endpoint switched to Local.
|
|
99
|
-
\u2514\u2500\u2800`:`
|
|
100
|
-
|
|
101
|
-
\u2726\u2800`}${$==="Ollama"||$==="InferX"||$==="SenseNova"||$==="AIHubMix"||$==="Poolside"||$==="9router"||$==="ExpLabs"||$==="TokenHarbor"||$==="Infron"||$==="APInex"||$==="xKiro"?`Memory is not available with ${$}.
|
|
102
|
-
\u2514\u2500\u2800`:""}Initialization complete.${S}
|
|
103
|
-
\u2800`,isMeta:!0}])}else L(g=>[...g,{role:"system",text:`\u2726 INVALID KEY
|
|
104
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${$} API key must start with "${o}" and be at least ${n} characters long.`,isMeta:!0}]),Cn("")},Qr=Ze(Di);xt(()=>{if(vt==="exit"){(async()=>{let B=Date.now(),o=Math.floor((B-Qr.current)/1e3);o>=1&&(await Ln("duration",o),Qr.current+=o*1e3),await _l()})();let a=setTimeout(()=>{process.exit(0)},50);return()=>clearTimeout(a)}},[vt]),xt(()=>{try{ri(x=>{L(a=>(F(a.length+1),[...a,{id:"keynotice-"+Date.now(),role:"system",text:`\u2726 ${x}
|
|
105
|
-
\u2800`,isMeta:!0}]))})}catch{}return()=>{try{ri(null)}catch{}}},[]),xt(()=>{let x=setInterval(async()=>{if(!Ae){let a=Date.now(),B=Math.floor((a-Qr.current)/1e3);B>=1&&(await Ln("duration",B),Qr.current+=B*1e3),Ul()}},5e3);return()=>clearInterval(x)},[Ae]);let ul=[{cmd:"/quit",desc:"Exit and shutdown Flux"},{cmd:"/kill",desc:"Kill a process by PID",subs:Fn.map(x=>{let a;return x.isRoot?a="FluxFlow":x.url&&(x.url.includes(":52991")||x.url.includes(":52145")||x.url.includes(":52140"))?a="Internal":a=x.url||x.name,{cmd:String(x.pid),display:`PID: ${x.pid}`,rightDesc:a,desc:a}})},{cmd:"/help",desc:"Show all available commands"},...We.playground?[{cmd:"/move",desc:"Move playground directory to original CWD/playground-export"}]:[],{cmd:"/resume",desc:"Load previous session"},{cmd:"/clear",desc:"Clear terminal screen"},{cmd:"/compress",desc:"Summarize and compress chat history"},{cmd:"/truncate",desc:"Truncate tool results in chat history"},{cmd:"/revert",desc:"Revert codebase back to a checkpoint"},{cmd:"/gemini",desc:"Get a happy message from Gemini CLI"},{cmd:"/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:lo($,qe,"Low")!==null?`Low (${lo($,qe,"Low")})`:"Low",desc:"Quick Reasoning"},{cmd:"Medium",display:lo($,qe,"Medium")!==null?`Medium (${lo($,qe,"Medium")})`:"Medium",desc:"Balanced Reasoning"},{cmd:"High",display:lo($,qe,"High")!==null?`High (${lo($,qe,"High")})`:"High",desc:"Deep Reasoning"},{cmd:"custom",display:lo($,qe,"xHigh")!==null?`Custom (${lo($,qe,"xHigh")})`:"Custom",desc:"Custom Reasoning Value"}]},{cmd:"/model",desc:"Select Agent Model",subs:Y==="ICU"||Y.toLowerCase()==="fluxcu"?dn($,et,re?.customOpenAIBaseUrl).filter(x=>ts(x.cmd||x)):dn($,et,re?.customOpenAIBaseUrl)},{cmd:"/wildcard-tooling",desc:"Use if the model lacks Tooling Capability"},{cmd:"/provider",desc:"Select AI Provider"},{cmd:"/mode",desc:"Switch execution mode",subs:[{cmd:"flux",display:"workspace",desc:"Workspace, files & terminal tools"},{cmd:"flow",display:"studio",desc:"Creative studio, documents, PDF & conversation"},{cmd:"icu",display:"computer use",desc:"Interactive desktop & OS automation"},{cmd:"fluxcu",display:"omni",desc:"Autonomous tools & desktop execution"}]},{cmd:"/display",desc:"Select Active Display (Computer Use)",subs:[{cmd:"primary",desc:"Primary Display (Display 1)"},{cmd:"secondary",desc:"Secondary Display (Display 2)"}]},{cmd:"/settings",desc:"Configure system prefs"},{cmd:"/theme",desc:"Customize UI color theme"},{cmd:"/key",desc:"Manage API keys",subs:[{cmd:"list",desc:"List saved keys"},{cmd:"add",desc:"Add a key"},{cmd:"remove",desc:"Remove a key"},{cmd:"use",desc:"Select active key"},{cmd:"clean",desc:"Remove gaps between slots"}]},{cmd:"/files",desc:"List loaded instruction and skill files"},{cmd:"/memory",desc:"Manage agent memory",subs:[{cmd:"view",desc:"View and manage agent persistent memory"},{cmd:"migrate",desc:"Migrate persistent memories to AGENTS.md"}]},{cmd:"/stats",desc:"Show session usage"},{cmd:"/usage",desc:"Open graphical token usage & analytics dashboard in browser"},{cmd:"/target",desc:"Show current provider and model"},{cmd:"/reset",desc:"Wipe all project data"},{cmd:"/about",desc:"Project info & credits"},{cmd:"/changelog",desc:"View latest updates"},{cmd:"/docs",desc:"View Documentation"},{cmd:"/fluxflow",desc:"Project management",subs:[{cmd:"global",desc:"Opens the Global FluxFlow Directory in File Explorer"},{cmd:"saves",desc:"Opens FluxFlow AppData Directory in File Explorer"}]},{cmd:"/budget",desc:"Set or View budget limits",subs:[{cmd:"view",desc:"View current usage budget bars"},{cmd:"web",desc:"Open graphical usage and budget dashboard in browser"},{cmd:"set",desc:"Configure budgets (Daily/Monthly limits)"},{cmd:"reset",desc:"Reset budgets to default limits"}]},{cmd:"/update",desc:"Check/Install updates",subs:[{cmd:"latest",desc:"Install latest release"},{cmd:"check",desc:"Check for new version"}]}],ml=async(x,a=!1)=>{if(!a&&st.length>0){let n=st[Oe]||st[0],h=x.split(" "),f=h.length===1?n.cmd:h.slice(0,-1).join(" ")+" "+n.cmd;if(f.trim()!==x.trim()){w(f+" "),Ne(0),O(c=>c+1);return}}qs.current=!1;let B=x.replace(/\r\n/g,`
|
|
106
|
-
`).replace(/\r/g,`
|
|
107
|
-
`).trimEnd();if(B.endsWith("\\")){w(B.slice(0,-1)+`
|
|
108
|
-
`);return}let o=B.replace(/\\\s*\n/g,`
|
|
109
|
-
`).split(/\r?\n/).map(n=>n.replace(/\\$/,"")).join(`
|
|
110
|
-
`);if(o.trim()){if(!a)try{let n=U.current;n[n.length-1]!==o&&n.push(o),n.length>200&&n.shift(),P(-1),W.current=""}catch{}if(Jn){let n=o.trim();if(n.startsWith("/btw")){if(n.replace(/^\/btw\s*/,"").trim().length<=3){L(f=>(F(f.length+1),[...f,{id:"hint-err-"+Date.now(),role:"system",text:`\u2726 RESTRICTED
|
|
111
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Inquiry question must be more than 3 characters.
|
|
112
|
-
\u2800`,isMeta:!0}])),w("");return}}else if(n.startsWith("/")){L(h=>(F(h.length+1),[...h,{id:"hint-err-"+Date.now(),role:"system",text:`\u2726 RESTRICTED
|
|
113
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Steering Hints cannot start with '/'.
|
|
114
|
-
\u2800`,isMeta:!0}])),w("");return}zs(n),qo.current=n,w("");return}if(!Ye&&!($==="c_openai"&&re.customOpenAIBaseUrl)){dl(o),Cn("");return}if(o.startsWith("/")){w("");let n=o.split(" "),h=n[0]?.toLowerCase();switch(h){case"/quit":{ie("exit");break}case"/resume":{if(n[1]){let f=n[1];(async()=>{let g=await Jo(),p=g[f]||Object.values(g).find(S=>S.name.toLowerCase()===f.toLowerCase());if(p){if(r.write("\x1B[2J\x1B[3J\x1B[H"),process.stdout.isTTY){let Z=p?.name||"",G=Z&&!Z.startsWith("flow-")&&!Z.startsWith("Session ")?Z:"FluxFlow | Resumed";process.stdout.write(`\x1B]0;${G}\x07`),process.stdout.write(`\x1B]633;P;TerminalTitle=${G}\x07`)}Qo(),jo.current=!0,qr(f);let S=await Br(f);Hn.current=fo-S.total,Xn.current=Bo,Kn.current=vn,to.current=[],_n(S.total),Wn(0),Sn(0),Gn(0),sn({tokens:S.context}),jo.current=!1;let E=[...p.messages];E[0]?.text?.includes("\u2591\u2591\u2591\u2588\u2588\u2588")||E.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),L(E),L(Z=>[...Z,{id:"sys-"+Date.now(),role:"system",text:`\u2726 SESSION RESUMED
|
|
115
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${f}.
|
|
116
|
-
\u2800`,isMeta:!0}]),F(0)}else L(S=>[...S,{id:"err-"+Date.now(),role:"system",text:`\u2726 ERROR: Session [${f}] not found.
|
|
117
|
-
\u2800`,isMeta:!0}])})()}else ie("resume");break}case"/move":{if(!We.playground){L(p=>(F(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 RESTRICTED
|
|
118
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m '/move' is only available in playground mode.
|
|
119
|
-
\u2800`,isMeta:!0}]));break}if(!We.originalCwd){L(p=>(F(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 RESTRICTED
|
|
120
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Original CWD not found.
|
|
121
|
-
\u2800`,isMeta:!0}]));break}let f=Ct.join($o,"playground"),c=Ct.join(We.originalCwd,"playground-export");(async()=>{try{L(S=>(F(S.length+1),[...S,{id:Date.now(),role:"system",text:`\u2726 EXPORTING PLAYGROUND CONTENT
|
|
122
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${c}
|
|
123
|
-
`,isMeta:!0}])),await ft.ensureDir(c);let p=["node_modules",".git",".venv","venv","env",".next","dist","build",".cache"];await ft.copy(f,c,{overwrite:!0,filter:S=>{let E=Ct.relative(f,S);return E?!E.split(Ct.sep).some(Z=>p.includes(Z)):!0}}),L(S=>(F(S.length+1),[...S,{id:Date.now(),role:"system",text:`\u2726 SUCCESS
|
|
124
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m playground content copied to ${c}
|
|
125
|
-
`,isMeta:!0}]))}catch(p){L(S=>(F(S.length+1),[...S,{id:Date.now(),role:"system",text:`\u2726 FAILED TO MOVE CONTENT
|
|
126
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${p.message}
|
|
127
|
-
`,isMeta:!0}]))}})();break}case"/clear":{if(r&&(r.write("\x1B[2J\x1B[3J\x1B[H"),r.isTTY&&(r.write("\x1B[?2004h"),process.stdout.write("\x1B]0;FluxFlow\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow\x07"))),L([{id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}]),F(1),Js(f=>f+1),Qo(),xo.current={completedIndex:0,columns:H.columns,historicalBlocks:[],seenSelections:new Set,chatId:gt,clearKey:In+1},We.playground){if(We.playground=!1,is(qn).catch(()=>{}),We.originalCwd)try{process.chdir(We.originalCwd),L(f=>{let c=[...f,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND
|
|
128
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Restored Working Directory to ${We.originalCwd}
|
|
129
|
-
\u2800`,isMeta:!0}];return F(c.length),c})}catch{}setTimeout(()=>{ft.emptyDir(Ct.join($o,"playground")).catch(f=>{L(c=>{let g=[...c,{id:"playground-"+Date.now(),role:"system",text:`\u2726 PLAYGROUND
|
|
130
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Failed to clear session: ${$o+"/playground"}`,isMeta:!0}];return F(g.length),g})})},500),Ft(f=>({...f,allowExternalAccess:$s.current,memory:Us.current}))}qr(ui()),sn({tokens:0}),V(!1),_n(0),Wn(0),Sn(0),Gn(0),to.current=[],Hn.current=fo,Xn.current=Bo,Kn.current=vn,setTimeout(()=>{global.gc&&(async()=>{for(let c=0;c<3;c++)global.gc(),await new Promise(g=>setImmediate(g));m.current=Date.now()})()},500);break}case"/revert":{Sr.getChatHistory(gt).then(f=>{if(f.length>0)nl(f.reverse()),ie("revert");else{let c=yt(2);L(g=>(F(g.length+1),[...g,{id:"revert-empty-"+Date.now(),role:"system",text:`\u2726 Nothing to revert to.
|
|
131
|
-
\u2800`,isMeta:!0}]))}}),setTimeout(()=>{global.gc&&(async()=>{for(let c=0;c<3;c++)global.gc(),await new Promise(g=>setImmediate(g));m.current=Date.now()})()},500);break}case"/mode":{if(n[1]){let f=n[1].toLowerCase(),c="Flux";f==="flow"?c="Flow":f==="icu"?c="ICU":f==="fluxcu"?c="FluxCU":f==="flux"&&(c="Flux"),ue(c);let g=yt(2);L(p=>(F(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${Ei(c)}.
|
|
132
|
-
\u2800`,isMeta:!0}]))}else ie("mode");break}case"/display":{if(n[1]){let f=n[1].toLowerCase(),c=0;f==="secondary"||f==="1"||f==="2"?c=1:c=0,le(c),qt({display:c}).catch(()=>{});let g=c===0?"Primary (Display 1)":"Secondary (Display 2)";L(p=>(F(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 Active Computer Use display set to: ${g}.
|
|
133
|
-
\u2800`,isMeta:!0}]))}else ie("display");break}case"/image_deprecated":{if(n[1]?.toLowerCase()==="stats"){let f=yt(2);if(Yo.keyType==="Custom")L(c=>(F(c.length+1),[...c,{id:Date.now(),role:"system",text:"[SYSTEM] Key strategy is Custom. Redirecting to Pollinations dashboard (https://enter.pollinations.ai/#pollen)...",isMeta:!0}])),Ko("start https://enter.pollinations.ai/#pollen");else try{let c=await Wl();L(g=>(F(g.length+1),[...g,{id:Date.now(),role:"system",isImageStats:!0,text:`\u2022 Hourly Limit: ${Number((c.limit*1e3).toFixed(0))} credits
|
|
134
|
-
\u2022 Spent (Last 1hr): ${Number((c.totalSpent*1e3).toFixed(0))} credits
|
|
135
|
-
\u2022 Remaining: ${Number((c.remaining*1e3).toFixed(0))} credits
|
|
136
|
-
\u2022 Requests (Last 1hr): ${c.activeCallsCount} requests
|
|
137
|
-
`+(c.nextResetMin>0?`\u2022 Refreshes in: ${c.nextResetMin}m`:""),isMeta:!0}]))}catch{L(g=>(F(g.length+1),[...g,{id:Date.now(),role:"system",text:"[SYSTEM] Failed to load image quota stats.",isMeta:!0}]))}}else if(n[1]?.toLowerCase()==="setup")if(n[2]?.toLowerCase()==="key")if(n[3]){let f=["default","custom"].find(c=>c===n[3].toLowerCase());if(f){let c=f==="default"?"Default":"Custom";Gr(p=>({...p,keyType:c}));let g=yt(2);L(p=>(F(p.length+1),[...p,{id:Date.now(),role:"system",text:`[SYSTEM] Image key strategy set to ${c}`,isMeta:!0}])),c==="Custom"&&(mo({label:"Enter Pollinations API key (starting with sk_):",note:"Get a key from https://enter.pollinations.ai",key:"imageSettings",subKey:"apiKey",value:Yo.apiKey||"",returnView:"chat"}),ie("input"))}else{let c=yt(2);L(g=>(F(g.length+1),[...g,{id:Date.now(),role:"system",text:"[SYSTEM] Invalid key option. Choose: Default or Custom.",isMeta:!0}]))}}else{let f=yt(2);L(c=>(F(c.length+1),[...c,{id:Date.now(),role:"system",text:"[SYSTEM] Usage: /image setup Key <Default|Custom>",isMeta:!0}]))}else if(n[2]?.toLowerCase()==="quality")if(n[3]){let f=["low","low-high","medium","medium-high","high","ultra","premium"].find(c=>c===n[3].toLowerCase());if(f){let g={low:"Low","low-high":"Low-High",medium:"Medium","medium-high":"Medium-High",high:"High",ultra:"Ultra",premium:"Premium"}[f];Gr(S=>({...S,quality:g}));let p=yt(2);L(S=>(F(S.length+1),[...S,{id:Date.now(),role:"system",text:`[SYSTEM] Image quality set to ${g}`,isMeta:!0}]))}else{let c=yt(2);L(g=>(F(g.length+1),[...g,{id:Date.now(),role:"system",text:"[SYSTEM] Invalid quality level. Choose from: Low, Low-High, Medium, Medium-High, High, Ultra, Premium.",isMeta:!0}]))}}else{let f=yt(2);L(c=>(F(c.length+1),[...c,{id:Date.now(),role:"system",text:"[SYSTEM] Usage: /image setup Quality <Low|Low-High|Medium|Medium-High|High|Ultra>",isMeta:!0}]))}else{let f=yt(2);L(c=>(F(c.length+1),[...c,{id:Date.now(),role:"system",text:"[SYSTEM] Usage: /image setup <Key|Quality> ...",isMeta:!0}]))}else{let f=yt(2);L(c=>(F(c.length+1),[...c,{id:Date.now(),role:"system",text:"[SYSTEM] Usage: /image setup <Key|Quality> ...",isMeta:!0}]))}break}case"/thinking":{let f;if(n[1]){let c=n.slice(1),g=c.includes("--bypass")||c.includes("-b"),p=c.includes("--force")||c.includes("-f"),S=c.findIndex(G=>G==="--map"||G==="-m");if(S!==-1){let G=c.slice(0,S).join(" ").trim(),Q=c.slice(S+1).join(" ").trim(),te=["fast","low","medium","standard","high","xhigh","custom","max"];if(!G||!Q)L(q=>(F(q.length+1),[...q,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mINVALID USAGE\x1B[0m
|
|
138
|
-
\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)
|
|
139
|
-
\u2800`,isMeta:!0}]));else if(!te.includes(G.toLowerCase()))L(q=>(F(q.length+1),[...q,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mUNKNOWN LEVEL\x1B[0m
|
|
140
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Unknown level "\x1B[33m${G}\x1B[0m" to map. Available: \x1B[36mLow, Medium, High, Custom\x1B[0m.
|
|
141
|
-
\u2800`,isMeta:!0}]));else if(Q.toLowerCase()==="rm"||Q.toLowerCase()==="--remove"||Q.toLowerCase()==="-rm"){let q=G.toLowerCase()==="custom"?"xHigh":G,je=zl($,qe,q);je.success?L(Fe=>(F(Fe.length+1),[...Fe,{id:Date.now(),role:"system",text:`\u2726 Thinking Level Mapping Removed:
|
|
142
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Target: \x1B[36m${$}::${qe}\x1B[0m
|
|
143
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Removed mapping for: \x1B[33m${G}\x1B[0m
|
|
144
|
-
\u2800`,isMeta:!0}])):L(Fe=>(F(Fe.length+1),[...Fe,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mFAILED TO REMOVE MAPPING\x1B[0m
|
|
145
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${je.reason}
|
|
146
|
-
\u2800`,isMeta:!0}]))}else{let q=G.toLowerCase()==="custom"?"xHigh":G,je=isNaN(Number(Q))?Q:Number(Q),Fe=ql($,qe,q,je);Fe.success?L(ke=>(F(ke.length+1),[...ke,{id:Date.now(),role:"system",text:`\u2726 Thinking Level Mapped:
|
|
147
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Target: \x1B[36m${$}::${qe}\x1B[0m
|
|
148
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Mapping: \x1B[33m${G}\x1B[0m \u2794 \x1B[32m${Q}\x1B[0m
|
|
149
|
-
\u2800`,isMeta:!0}])):L(ke=>(F(ke.length+1),[...ke,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mFAILED TO SAVE MAPPING\x1B[0m
|
|
150
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${Fe.reason}
|
|
151
|
-
\u2800`,isMeta:!0}]))}break}let E=c[0].toLowerCase();if(!["fast","low","medium","standard","high","xhigh","custom","max"].includes(E)){L(G=>(F(G.length+1),[...G,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mUNKNOWN THINKING LEVEL\x1B[0m
|
|
152
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Level "\x1B[33m${c[0]}\x1B[0m" is not supported. Available levels: \x1B[36mLow, Medium, High, Custom\x1B[0m.
|
|
153
|
-
\u2800`,isMeta:!0}]));break}if(E==="standard"&&(E="medium"),E==="custom"&&(E="xhigh"),f=E.charAt(0).toUpperCase()+E.slice(1),E==="xhigh"&&(f="xHigh"),f==="xHigh"&&!(lo($,qe,"xHigh")!==null)){L(Q=>(F(Q.length+1),[...Q,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mCUSTOM LEVEL NOT MAPPED\x1B[0m
|
|
154
|
-
\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.
|
|
155
|
-
\u2800`,isMeta:!0}]));break}let Z="";if(p&&(process.env.NVIDIA_BASE_URL,Z=`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Enabled Forced Reasoning.
|
|
156
|
-
\u2800`,process.env.forcedReasoning="true"),!g&&Y==="Flow"&&f==="xHigh")L(G=>(F(G.length+1),[...G,{id:Date.now(),role:"system",text:`\u2726 RESTRICTED
|
|
157
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m"${f}" is restricted in Flow mode. Switch to Flux to enable Higher Thinking Levels.
|
|
158
|
-
\u2800${Z}.`,isMeta:!0}]));else{co(f);let G=yt(1),Q=f==="xHigh"?lo($,qe,"xHigh")!==null?`Custom (${lo($,qe,"xHigh")})`:"Custom":f;L(te=>(F(te.length+1),[...te,{id:Date.now(),role:"system",text:`\u2726 ${$}
|
|
159
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${qe}.
|
|
160
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Thinking Level: ${Q}.
|
|
161
|
-
${Z} \u2800`,isMeta:!0}]))}}else ie("thinking");break}case"/model":{if(n[1]){let f=n.slice(1).join(" "),c=null,g=!1,p=null,S=f,E=/(?:^|\s)(?:--info|-i)(?:\s+(?:"([^"]*)"|'([^']*)'|\{([^}]*)\}|((?:(?!--[a-z]|-[a-z]\b).)+)))?(?=\s+--|\s+-[a-z]\b|$)/i,z=S.match(E);if(z){if(p=(z[1]??z[2]??z[3]??z[4]??"").trim(),S=(S.slice(0,z.index)+" "+S.slice(z.index+z[0].length)).trim(),p==="0")g=!0,c=null;else if(c={},p){let se=p.split(",");for(let ge of se){let Je=ge.trim().match(/^(IN|OUT|CR|CW)\s+([0-9]*\.?[0-9]+)$/i);Je&&(c[Je[1].toUpperCase()]=parseFloat(Je[2]))}}}let Z=S.split(/\s+/).filter(Boolean),G=Z.some(se=>se==="--multimodal"||se==="-m"||se==="--vision"||se==="-v"),Q=Z.some(se=>se==="--save"||se==="-sv"||se==="--add"),te=Z.some(se=>se==="--remove"||se==="-rm"),q=Z.some(se=>se==="--rename"||se==="-rn"||se==="-mv"),je=Z.some(se=>se==="--default"||se==="-df"),Fe=Z.some(se=>se==="--price"||se==="-p"),ke=Z.some(se=>se==="--raw"||se==="-r"),rt=Z.filter(se=>!se.startsWith("-")),Ht=(se=c)=>g?`
|
|
162
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Pricing: \x1B[33mReset (info removed)\x1B[0m`:se?Object.keys(se).length>0?`
|
|
163
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Pricing:
|
|
164
|
-
`+Object.entries(se).map(([ge,Ue])=>` \x1B[2m\u2022\x1B[22m \x1B[36m${ge}\x1B[0m: $${Ue}`).join(`
|
|
165
|
-
`):p?`
|
|
166
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Pricing: \x1B[33mNo valid IN, OUT, CR, CW tokens parsed from: "${p}"\x1B[0m`:"":"";if(Q||te||q||je){if(je){let se=rt.join(" ").trim();if(!se)L(ge=>(F(ge.length+1),[...ge,{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 ge=bl($,se,G,c);ge.success?L(Ue=>{F(Ue.length+1);let Je=$==="c_openai"?re?.customOpenAIBaseUrl||"Custom Endpoint":$.replace("c_openai","Custom Endpoint");return[...Ue,{id:Date.now(),role:"system",text:`\u2726 Default Model Set:
|
|
167
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${Je}
|
|
168
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Default Model: \x1B[32m${se}\x1B[0m
|
|
169
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Multimodal: ${G?"ON":"OFF"}${Ht()}
|
|
170
|
-
\u2800`,isMeta:!0}]}):L(Ue=>(F(Ue.length+1),[...Ue,{id:Date.now(),role:"system",text:`\x1B[31m[Error]\x1B[0m Failed to set default model: ${ge.reason}`,isMeta:!0}]))}}else if(Q){let se=rt.join(" ").trim();if(!se)L(ge=>(F(ge.length+1),[...ge,{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 ge=$==="c_openai"?re.customOpenAIBaseUrl:null,Ue=hl($,se,G,c,ge);Ue.success?L(Je=>(F(Je.length+1),[...Je,{id:Date.now(),role:"system",text:`\u2726 Model Saved:
|
|
171
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${$}
|
|
172
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: \x1B[32m${se}\x1B[0m
|
|
173
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Multimodal: ${G?"ON":"OFF"}${Ht()}
|
|
174
|
-
\u2800`,isMeta:!0}])):L(Je=>(F(Je.length+1),[...Je,{id:Date.now(),role:"system",text:`\x1B[31m[Error]\x1B[0m Failed to save model: ${Ue.reason}`,isMeta:!0}]))}}else if(te){let se=rt.join(" ").trim();if(!se)L(ge=>(F(ge.length+1),[...ge,{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 ge=wl($,se);ge.success?L(Ue=>(F(Ue.length+1),[...Ue,{id:Date.now(),role:"system",text:`\u2726 Model Removed:
|
|
175
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${$}
|
|
176
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: \x1B[31m${se}\x1B[0m
|
|
177
|
-
\u2800`,isMeta:!0}])):L(Ue=>(F(Ue.length+1),[...Ue,{id:Date.now(),role:"system",text:`\x1B[31m[Error]\x1B[0m Failed to remove model: ${ge.reason}`,isMeta:!0}]))}}else if(q)if(rt.length<2)L(se=>(F(se.length+1),[...se,{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 se=rt[0].trim(),ge=rt.slice(1).join(" ").trim(),Ue=Tl($,se,ge);Ue.success?L(Je=>(F(Je.length+1),[...Je,{id:Date.now(),role:"system",text:`\u2726 Model Renamed:
|
|
178
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${$}
|
|
179
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Old Model: \x1B[31m${se}\x1B[0m
|
|
180
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m New Model: \x1B[32m${ge}\x1B[0m
|
|
181
|
-
\u2800`,isMeta:!0}])):L(Je=>(F(Je.length+1),[...Je,{id:Date.now(),role:"system",text:`\x1B[31m[Error]\x1B[0m Failed to rename model: ${Ue.reason}`,isMeta:!0}]))}break}if(Fe){let se=rt.join(" ").trim()||qe,ge=yr($,se),Ue=$==="c_openai"?re?.customOpenAIBaseUrl||"Custom Endpoint":$.replace("c_openai","Custom Endpoint"),Je=ge&&Object.keys(ge).length>0;if(ke){let pe=Je?Object.entries(ge).map(([Te,ve])=>`${Te}=${ve}`).join(" "):`Price not set for ${se}`;L(Te=>(F(Te.length+1),[...Te,{id:Date.now(),role:"system",text:pe,isMeta:!0}]));break}let N=Je?`
|
|
182
|
-
`+Object.entries(ge).map(([pe,Te])=>`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m \x1B[36m${pe}\x1B[0m: $${Te}`).join(`
|
|
183
|
-
`):`
|
|
184
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m \x1B[33mPrice not set\x1B[0m
|
|
185
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m \x1B[2mHint: /model ${se} -i 'IN 0.15, OUT 0.6, CR 0.05, CW 0.1'
|
|
186
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m \x1B[2mNote: CR = Cache Read, CW = Cache Write\x1B[0m`;L(pe=>(F(pe.length+1),[...pe,{id:Date.now(),role:"system",text:`\u2726 Model Price:
|
|
187
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${Ue}
|
|
188
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model ID: \x1B[32m${se}\x1B[0m${N}
|
|
189
|
-
\u2800`,isMeta:!0}]));break}if(c!==null||g){let se=rt.join(" ").trim();if(!se)L(ge=>(F(ge.length+1),[...ge,{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{g?ei($,se,null):Object.keys(c).length>0&&ei($,se,c);let ge=g?null:yr($,se),Ue=$==="c_openai"?re?.customOpenAIBaseUrl||"Custom Endpoint":$.replace("c_openai","Custom Endpoint");L(Je=>(F(Je.length+1),[...Je,{id:Date.now(),role:"system",text:`\u2726 Model Info ${g?"Reset":"Saved"}:
|
|
190
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Provider: ${Ue}
|
|
191
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model ID: \x1B[32m${se}\x1B[0m${Ht(ge||c)}
|
|
192
|
-
\u2800`,isMeta:!0}]))}break}let at=rt.join(" ").trim();if(yl(G),at){G&&pl($,at,!0);let se=bo("Google","Free"),ge=bo("Google","Paid");{jt(at);let Ue=G||ts(at),Je=Ke==="xHigh"?lo($,at,"xHigh")!==null?`Custom (${lo($,at,"xHigh")})`:"Custom":Ke,N=$==="c_openai"?re?.customOpenAIBaseUrl||"Custom Endpoint":$.replace("c_openai","Custom Endpoint");L(pe=>(F(pe.length+1),[...pe,{id:Date.now(),role:"system",text:`\u2726 ${N}
|
|
193
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${at}
|
|
194
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Thinking Level: ${Je}
|
|
195
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Multimodal: ${Ue?"ON":"OFF"}
|
|
196
|
-
\u2800`,isMeta:!0}]))}}}else ie("model");break}case"/wildcard-tooling":{Be(f=>{let c=!f;return L(g=>(F(g.length+1),[...g,{id:Date.now(),role:"system",text:`\u2726 Wildcard Tooling:
|
|
197
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Status: ${c?"Enabled":"Disabled"}
|
|
198
|
-
\u2800`,isMeta:!0}])),c});break}case"/wildercard-tooling":{T(f=>{let c=!f;return L(g=>(F(g.length+1),[...g,{id:Date.now(),role:"system",text:`\u2726 Wildercard Tooling:
|
|
199
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Status: ${c?"Enabled":"Disabled"}
|
|
200
|
-
\u2800`,isMeta:!0}])),c});break}case"/settings":{ie("settings");break}case"/provider":case"/providers":{Bs("chat"),ie("selectProvider");break}case"/theme":{ie("theme");break}case"/key":{(async()=>{try{let c=n.slice(1).join(" "),g=await Aa(c,{currentProvider:$}),p=(g.lines||[]).join(`
|
|
201
|
-
`);p&&L(S=>(F(S.length+1),[...S,{id:Date.now(),role:"system",text:p,isMeta:!0}])),g.switchedBaseUrl&&Ft(S=>({...S,customOpenAIBaseUrl:g.switchedBaseUrl,memory:!1})),g.switchedKey!==void 0&&(Nt(g.switchedKey),yo(g.switchedKey,{aiProvider:$,onIDEApproval:Fo})),g.promptNewKey&&(Nt(null),ie("chat"))}catch(c){L(g=>(F(g.length+1),[...g,{id:Date.now(),role:"system",text:`\u2726 Key command error: ${c.message}`,isMeta:!0}]))}})();break}case"/stats":{(async()=>{let c=await os(),g=await ns();Ls(c),Ps(g),ur("daily"),ie("stats")})();break}case"/usage":{(async()=>{try{let{openUsageDashboard:c}=await import("./usageServer-4X7T4FDJ.js"),{url:g}=await c();L(p=>(F(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 Launching Token Analytics Dashboard
|
|
202
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Serving at ${g}
|
|
203
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Opening in your default browser...
|
|
204
|
-
\u2800`,isMeta:!0}]))}catch(c){L(g=>(F(g.length+1),[...g,{id:Date.now(),role:"system",text:`\u2726 ERROR
|
|
205
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Failed to launch dashboard: ${c.message}
|
|
206
|
-
\u2800`,isMeta:!0}]))}})();break}case"/save":{let f,c=$t.find(p=>p.role==="user");if(c&&c.text){let p=c.text.replace(/\s*\n+\s*\[Prompted on:.*?\]/g,"").trim(),S=p.split(/\s+/),E;S.length>7?E=S.slice(0,7).join(" ")+"...":p.length>45?E=p.substring(0,45).trimEnd()+"...":E=p,f=E}let g=n.slice(1).join(" ")||f||`Session ${new Date().toLocaleTimeString()}`;On(gt,g,$t),L(p=>(F(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 Saved
|
|
207
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m "${g}" (ID: ${gt})
|
|
208
|
-
\u2800`,isMeta:!0}]));break}case"/export":{(async()=>{try{let{handleExport:c}=await import("./export-RU6LCZUB.js"),g=await c(n,{chatId:gt,messages:$t});L(p=>(F(p.length+1),[...p,{id:Date.now(),role:"system",text:g.message,isMeta:!0}]))}catch(c){L(g=>(F(g.length+1),[...g,{id:Date.now(),role:"system",text:`[EXPORT ERROR] Failed to export: ${c.message}`,isMeta:!0}]))}})();break}case"/chats":{(async()=>{let c=await Jo(),g=Object.entries(c).sort((p,S)=>(S[1].updatedAt||0)-(p[1].updatedAt||0)).map(([p,S])=>`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${p}: ${vr(S,p)}${p===gt?" (current)":""}`).join(`
|
|
209
|
-
`);L(p=>(F(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 Saved Chats:
|
|
210
|
-
${g||"\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No saved chats found."}
|
|
211
|
-
\u2800`,isMeta:!0}]))})();break}case"/memory":{if((n[1]||"view").toLowerCase()==="migrate")try{let c=Rr(Tr,[]);if(!c||c.length===0){L(Q=>(F(Q.length+1),[...Q,{id:Date.now(),role:"system",text:`\u2726 Memory Migration
|
|
212
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No persistent memories found in memories.json to migrate.
|
|
213
|
-
\u2800`,isMeta:!0}]));break}let g=c.map(Q=>`- ${(Q.memory||"").replace(/\[Saved on: .*?\]/g,"").replace(/\\+'/g,"'").trim()}`).filter(Q=>Q!=="- ").join(`
|
|
214
|
-
`);if(!g){L(Q=>(F(Q.length+1),[...Q,{id:Date.now(),role:"system",text:`\u2726 Memory Migration
|
|
215
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No valid memory entries found to migrate.
|
|
216
|
-
\u2800`,isMeta:!0}]));break}ft.existsSync(ko)||ft.mkdirSync(ko,{recursive:!0});let p=Ct.join(ko,"AGENTS.md"),S="";ft.existsSync(p)&&(S=ft.readFileSync(p,"utf8"));let E=S.trimEnd(),Z=`${E.length>0?`
|
|
217
|
-
|
|
218
|
-
`:""}User Memories:
|
|
219
|
-
${g}
|
|
220
|
-
`,G=`${E}${Z}`;ft.writeFileSync(p,G,"utf8"),L(Q=>(F(Q.length+1),[...Q,{id:Date.now(),role:"system",text:`\u2726 Memory Migration
|
|
221
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Successfully migrated ${c.length} memories to ${p.replaceAll("\\\\","/").replaceAll("\\","/")}
|
|
222
|
-
\u2800`,isMeta:!0}]))}catch(c){L(g=>(F(g.length+1),[...g,{id:Date.now(),role:"system",text:`\u2726 Memory Migration Failed
|
|
223
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Error: ${c.message}
|
|
224
|
-
\u2800`,isMeta:!0}]))}else ie("memory");break}case"/files":{L(f=>(F(f.length+1),[...f,{id:"files-"+Date.now(),role:"system",text:Jl(),isMeta:!0}]));break}case"/target":{L(f=>(F(f.length+1),[...f,{id:"target-"+Date.now(),role:"system",text:`\u2726 Unique Model Id for FluxFlow
|
|
225
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${$}@${qe}
|
|
226
|
-
\u2800`,isMeta:!0}]));break}case"/reset":{(async()=>{try{L(c=>(F(c.length+1),[...c,{id:Date.now(),role:"system",text:`\u2726 Initiating reset...
|
|
227
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Clearing logs, secrets, and settings.
|
|
228
|
-
\u2800`,isMeta:!0}])),ft.existsSync(Zs)&&ft.removeSync(Zs),ft.existsSync(Rs)&&ft.removeSync(Rs),ft.existsSync(An)&&ft.removeSync(An);try{ft.readdirSync(ko).length===0&&ft.removeSync(ko)}catch{}setTimeout(()=>{ie("exit"),setTimeout(()=>process.exit(0),500)},500)}catch(c){L(g=>(F(g.length+1),[...g,{id:Date.now(),role:"system",text:`\u2726 ERROR
|
|
229
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Failed to clear data: ${c.message}.
|
|
230
|
-
\u2800`}]))}})();break}case"/about":{let f=yt(2),c=`\u2022 FluxFlow Version: v${So}
|
|
231
|
-
\u2022 Status: ${wn&&wn!==So?`Update Available [v${wn}]`:"Up to date"}
|
|
232
|
-
\u2022 Released on: ${pu}`;L(g=>(F(g.length+1),[...g,{id:"about-"+Date.now(),role:"system",text:c,isAboutRecord:!0,isMeta:!0}]));break}case"/changelog":{let f=process.platform;Ko(`${f==="win32"?"start":f==="darwin"?"open":"xdg-open"} ${Ja}`),L(g=>(F(g.length+1),[...g,{id:Date.now(),role:"system",text:`\u2726 Opening Changelog
|
|
233
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${Ja}.`,isMeta:!0}]));break}case"/docs":{if(!Ii){L(g=>(F(g.length+1),[...g,{id:Date.now(),role:"system",text:`\u2726 ERROR
|
|
234
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Documentation URL is not configured.`,isMeta:!0}]));break}let f=process.platform;Ko(`${f==="win32"?"start":f==="darwin"?"open":"xdg-open"} ${Ii}`),L(g=>(F(g.length+1),[...g,{id:Date.now(),role:"system",text:`\u2726 Opening Documentation
|
|
235
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${Ii}.
|
|
236
|
-
\u2800`,isMeta:!0}]));break}case"/budget":{let f=n[1]?.toLowerCase();if(f==="web"||f==="gui"||f==="dashboard")(async()=>{try{let{openUsageDashboard:g}=await import("./usageServer-4X7T4FDJ.js"),{url:p}=await g();L(S=>(F(S.length+1),[...S,{id:Date.now(),role:"system",text:`\u2726 Token Usage & Budget Dashboard
|
|
237
|
-
\u2800\u2800\u2514\u2500 Opened at ${p}
|
|
238
|
-
\u2800`,isMeta:!0}]))}catch(g){L(p=>(F(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2726 ERROR: Failed to launch dashboard: ${g.message}
|
|
239
|
-
\u2800`,isMeta:!0}]))}})();else if(f==="set")ec("chat"),ie("budgetTypeSelect");else if(f==="view")(async()=>{let g=await os(),p=await ns(),S=await li(Ie.resetDay||1);Ls(g),Ps(p),Gi(S),ie("budgetView")})();else if(f==="reset"){let c={limitMode:"Daily",agentLimit:99999999,tokenLimit:99999999999999,backgroundLimit:999999,searchLimit:100,customModelId:"",customLimit:0,providerBudgets:{},providerTiers:{Google:"Free",DeepSeek:"Free",NVIDIA:"Free",OpenRouter:"Free",InferX:"Free",SenseNova:"Free",AIHubMix:"Free",Poolside:"Free",ExpLabs:"Free",TokenHarbor:"Free",Infron:"Free",APInex:"Free",xKiro:"Free"}};io(c),kt("Free"),qt({apiTier:"Free",quotas:c}),L(g=>(F(g.length+1),[...g,{id:Date.now(),role:"system",text:`\u2726 Budgets reset successfully.
|
|
240
|
-
\u2800`,isMeta:!0}]))}else L(c=>(F(c.length+1),[...c,{id:Date.now(),role:"system",text:`\u2726 ERROR
|
|
241
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Usage: /budget <View|Web|Set|Reset>.
|
|
242
|
-
\u2800`,isMeta:!0}]));break}case"/fluxflow":{let c=n.slice(1)[0]?.toLowerCase()?.trim();if(c==="global"){let g=Ct.normalize(ko);try{ft.ensureDirSync(g)}catch{}let p=process.platform;p==="win32"?Ko(`explorer "${g}"`):p==="darwin"?Ko(`open "${g}"`):Ko(`xdg-open "${g}"`)}else if(c==="saves"){let g=Ct.normalize($o);try{ft.ensureDirSync(g)}catch{g=Ct.normalize(ko);try{ft.ensureDirSync(g)}catch{}}let p=process.platform;p==="win32"?Ko(`explorer "${g}"`):p==="darwin"?Ko(`open "${g}"`):Ko(`xdg-open "${g}"`)}else L(g=>(F(g.length+1),[...g,{id:"ff-err-"+Date.now(),role:"system",text:"Usage: /fluxflow global/saves",isMeta:!0}]));break}case"/update":{if(n[1]?.toLowerCase()==="check"){Et(!0);break}let c=n.includes("--latest");ie("update");break}case"/gemini":{let f=c=>{let g=c[Math.floor(Math.random()*c.length)];L(p=>(F(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u2728 GEMINI CLI
|
|
243
|
-
\u2800\u2800 \x1B[2m\u2514\u2500\x1B[22m ${g}
|
|
244
|
-
\u2800`}]))};Ts?f(Ts):import("./gemini_quotes-B5IXNP2I.js").then(({GEMINI_QUOTES:c})=>{Ts=c,f(Ts)}),w("");break}case"/meow":{let f=c=>{let g=c[Math.floor(Math.random()*c.length)];L(p=>(F(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u{1F431} MEOW
|
|
245
|
-
\u2800\u2800 \x1B[2m\u2514\u2500\x1B[22m ${g}
|
|
246
|
-
\u2800`}]))};ys?f(ys):import("./meow-SQBRZB7H.js").then(({MEOW_LINES:c})=>{ys=c,f(ys)}),w("");break}case"/halloween":case"/trick-or-treat":{let f=c=>{let g=c[Math.floor(Math.random()*c.length)];L(p=>(F(p.length+1),[...p,{id:Date.now(),role:"system",text:`\u{1F383} TRICK OR TREAT
|
|
247
|
-
\u2800\u2800 \x1B[2m\u2514\u2500\x1B[22m ${g}
|
|
248
|
-
\u2800`}]))};Cs?f(Cs):import("./halloween-EZTJXDUW.js").then(({SPOOKY_LINES:c})=>{Cs=c,f(Cs)}),w("");break}case"/compress":{w("");let f=$t.filter(p=>(p.role==="user"||p.role==="agent"||p.role==="system")&&!String(p.id).startsWith("welcome")&&!p.isMeta).length,c=No?.tokens||0;if(f<64||c<16384){let p=yt(2);L(S=>(F(S.length+1),[...S,{id:Date.now(),role:"system",text:`\u2726 Compression skipped
|
|
249
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m History requires at least 64 messages and 16k tokens
|
|
250
|
-
\u2800\u2800 \u2514\u2500 Current: ${f}/64 msgs, ${c}/16384 tokens.
|
|
251
|
-
\u2800`,isMeta:!0}]));break}(async()=>{el(!0);let p=yt(2);L(S=>(F(S.length+1),[...S,{id:Date.now(),role:"system",text:"\u2726 Compacting session history...",isMeta:!0}]));try{if(await ua({chatId:gt,aiProvider:$,apiKey:Ye,thinkingLevel:Ke,mode:Y,janitorModel:k,systemSettings:re,sessionStats:No},$t)){let z=yt(2);L(Z=>{let G=[...Z,{id:Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Chat History compacted saving tokens.
|
|
252
|
-
\u2800`,isMeta:!0}];return F(G.length),G})}else L(z=>(F(z.length+1),[...z,{id:Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Compaction failed.
|
|
253
|
-
\u2800`,isMeta:!0}]))}catch(S){L(E=>(F(E.length+1),[...E,{id:Date.now(),role:"system",text:`\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Error during compaction: ${S.message}
|
|
254
|
-
\u2800`,isMeta:!0}]))}finally{el(!1)}})();break}case"/truncate":{w("");let f=0;L(c=>{let p=[...c.map(S=>{let E=S.fullText||S.text||"";return!E.startsWith("[ACTION RESULT]:")&&!E.startsWith("[TOOL RESULT]:")||E.startsWith("[ACTION RESULT]: Goal")||E.startsWith("[ACTION RESULT]: USER CHOOSE")||E.startsWith("[ACTION RESULT]: Background subagent started. Task ID:")||E.includes("...Success result truncated to save tokens")?S:(f++,{...S,fullText:"[ACTION RESULT]: ...Success result truncated to save tokens"})}),{id:Date.now(),role:"system",text:`\u2726 Tool Truncation...
|
|
255
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Truncated ${f} tool result(s).
|
|
256
|
-
\u2800`,isMeta:!0}];return On(gt,null,p),F(p.length),p});break}case"/kill":{(async()=>{let c=n[1]?parseInt(n[1],10):null,{getProcessTree:g,killProcess:p}=await import("./process-6Y7LS2MS.js");if(!c||isNaN(c))L(S=>(F(S.length+1),[...S,{id:Date.now(),role:"system",text:`\u2726 Usage: \x1B[36m/kill <pid>\x1B[0m
|
|
257
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Select an active process PID from the autocomplete list.
|
|
258
|
-
\u2800`,isMeta:!0}]));else{let S=c===process.pid,E=Fn.some(z=>z.pid===c&&(z.isRoot||z.url&&z.url.includes(":52991")||z.cmd&&z.cmd.includes("usage-daemon-worker")));if(S||E){let z=S?"FluxFlow (Main Process)":"Internal Process";L(Z=>(F(Z.length+1),[...Z,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mPROTECTED PROCESS\x1B[0m
|
|
259
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m PID: \x1B[33m${c}\x1B[0m (${z})
|
|
260
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Unable to kill protected core process. Use \x1B[36m/quit\x1B[0m to safely shutdown FluxFlow.
|
|
261
|
-
\u2800`,isMeta:!0}]));return}try{let z=await p(c);z.success?L(Z=>(F(Z.length+1),[...Z,{id:Date.now(),role:"system",text:`\u2726 Process Terminated:
|
|
262
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m PID: \x1B[31m${c}\x1B[0m (${z.message})
|
|
263
|
-
\u2800`,isMeta:!0}])):L(Z=>(F(Z.length+1),[...Z,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mFAILED TO KILL PROCESS\x1B[0m
|
|
264
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m PID: ${c}
|
|
265
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Reason: ${z.message}
|
|
266
|
-
\u2800`,isMeta:!0}]))}catch(z){L(Z=>(F(Z.length+1),[...Z,{id:Date.now(),role:"system",text:`\u2726 \x1B[31mERROR\x1B[0m
|
|
267
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${z.message}
|
|
268
|
-
\u2800`,isMeta:!0}]))}}})();break}case"/help":{L(f=>(F(f.length+1),[...f,{id:Date.now(),role:"system",isHelpRecord:!0,isMeta:!0}]));break}case"/btw":{L(f=>(F(f.length+1),[...f,{id:Date.now(),role:"system",text:`\u2726 RESTRICTED
|
|
269
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m '/btw' only available when agent is working
|
|
270
|
-
\u2800`,isMeta:!0}]));break}default:L(f=>(F(f.length+1),[...f,{id:Date.now(),role:"system",text:`\u2726 ERROR
|
|
271
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Unknown command: '${h}'
|
|
272
|
-
\u2800`,isMeta:!0}]))}}else{let n=`[Prompted on: ${new Date().toLocaleString(void 0,{year:"numeric",month:"numeric",day:"numeric",hour:"2-digit",minute:"2-digit"})}]`,h={id:"user-"+Date.now(),role:"user",text:`${o}
|
|
273
|
-
|
|
274
|
-
${n}`};L(c=>{let g=[...c,h];return F(g.length),On(gt,null,g),g}),(async()=>{let c=!1,g=()=>{c||(c=!0,L(z=>{let Z=z[z.length-1];if(Z&&Z.text&&Z.text.includes("Request Cancelled"))return z;let Q=[...z.map(te=>te.isStreaming?{...te,isStreaming:!1}:te),{id:"cancel-"+Date.now(),role:"agent",text:`
|
|
275
|
-
|
|
276
|
-
\x1B[33m\u24D8 Request Cancelled\x1B[0m`,isMeta:!1}];return F(Q.length),Q}))},p=!1;js(!0),ks(Date.now()),V(!1);let S=Date.now(),E=!0;try{let z=[...$t,h].filter(N=>N.role!=="think"&&!N.isVisualFeedback&&!N.isMeta&&!N.isTerminalRecord&&!(N.text&&N.text.includes("[TERMINAL_RECORD]"))&&!String(N.id).startsWith("welcome")),Z=[],G=z.map((N,pe)=>{let Te=N.fullText||N.text||"";if(N.role==="user"&&pe<z.length-1)if(Te.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")){let ve=Te.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");if(ve!==-1){let Ve=Te.substring(0,ve).lastIndexOf("[SYSTEM METADATA]");Ve!==-1?Te=Te.substring(Ve).trim():Te=Te.substring(ve).trim()}}else{let ve=Te.lastIndexOf("[USER]"),Re=Te.lastIndexOf("[USER PROMPT]");ve!==-1?Te=Te.substring(ve+6).trim():Re!==-1&&(Te=Te.substring(Re).trim())}return{...N,text:Te}}),Q=0;for(;Q<G.length;){let N=G[Q];if(N.role==="user")Z.push(N),Q++;else{let pe=[];for(;Q<G.length&&G[Q].role!=="user";)pe.push(G[Q]),Q++;let Te=[],ve=[],Re=null,Ve=!1,Mt=()=>{Te.length>0&&(Z.push({role:"agent",text:Te.join(`
|
|
277
|
-
`).trim()}),Te=[]),ve.length>0&&(Z.push({role:"system",text:ve.join(`
|
|
278
|
-
|
|
279
|
-
`),...Re?{binaryPart:Re}:{}}),ve=[],Re=null),Ve=!1};for(let ht=0;ht<pe.length;ht++){let K=pe[ht],ne=K.role==="system"&&(K.text?.startsWith("[ACTION RESULT]")||K.text?.startsWith("[TOOL RESULT]")||K.text?.startsWith("SUCCESS:")||K.text?.startsWith("ERROR:")||K.fullText?.startsWith("[ACTION RESULT]")||K.fullText?.startsWith("[TOOL RESULT]")||K.fullText?.startsWith("SUCCESS:")||K.fullText?.startsWith("ERROR:")),Ee=K.fullText||K.text||"",_e=Ee.trim();if(!(!_e&&!K.binaryPart)){if(ne){let Le=!_e.startsWith("[ACTION RESULT]")&&!_e.startsWith("[TOOL RESULT]")?`[ACTION RESULT]: ${_e}`:_e;ve.push(Le),K.binaryPart&&(Re=K.binaryPart)}else if(K.role==="agent"){!Ve&&ve.length>0&&Mt();let Le=_e,pt=aa(Le),go=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,Qt=[],Kt;for(;(Kt=go.exec(pt))!==null;)Qt.push(Kt.index);if(Qt.length>0){let zo=da(Le),wt=[];for(let At=0;At<Qt.length;At++){let Ut=Qt[At],ho=At+1<Qt.length?Qt[At+1]:Le.length;zo.find(Rt=>Rt.fullMatch&&Le.startsWith(Rt.fullMatch,Ut))||wt.push({start:Ut,end:ho})}if(wt.length>0){let At="",Ut=0;for(let ho of wt)At+=Le.substring(Ut,ho.start),Ut=ho.end;At+=Le.substring(Ut),Le=At.trim()}}if(!Le)continue;let Io=Ee.endsWith(`
|
|
280
|
-
`),kn=Le.toLowerCase().includes("tool:")||Le.toLowerCase().includes("action:"),Zn=!1;for(let zo=ht+1;zo<pe.length;zo++){let wt=pe[zo];if(wt.role==="agent"){let At=(wt.fullText||wt.text||"").trim();if(At){Zn=At.startsWith("[");break}}}Te.push(Le),kn&&Io&&Zn?Ve=!0:Ve=!1}}}Mt()}}let te=fa(qe,Z,{profile:Mn,thinkingLevel:Ke,mode:Y,systemSettings:re,janitorModel:k,sessionStats:No,chatId:gt,isPlayground:!!We.playground,aiProvider:$,apiKey:Ye,apiTier:et,wildcardTooling:_r,wildercardTooling:ce,cols:H.columns-6,rows:30,onTokenChunk:(N,pe)=>{let Te=Date.now();if(ks(Te),typeof pe=="number"){Oi.current=pe;let ve=As.current;ve.startTime||(ve.startTime=Te,ve.totalWords=0,ve.chunks=[]),ve.totalWords+=pe,ve.chunks||(ve.chunks=[]),ve.chunks.push({time:Te,words:pe});let Ve=Te-400;if(ve.chunks=ve.chunks.filter(Mt=>Mt.time>=Ve),ve.chunks.length>0){let Mt=ve.chunks.reduce((ne,Ee)=>ne+Ee.words,0),ht=ve.chunks[0].time,K=Math.max(.4,(Te-ht)/1e3);ve.wps=Math.round(Mt/K*10)/10}}},onVisualFeedback:N=>{L(pe=>[...pe.map(ve=>ve.isStreaming?{...ve,isStreaming:!1}:ve),{id:"visual-"+Date.now()+"-"+Math.random().toString(36).substring(2,9),role:"system",text:N,isVisualFeedback:!0}])},onSubagentUpdate:()=>{hc(ra.map(N=>({...N})))},onExecStart:N=>{ze(),ae(),Ki(N),Qn("")},onExecChunk:N=>{Qn(pe=>pe+N)},onExecEnd:()=>{let N=_s.current,pe=Hs.current||"";_s.current=null,Hs.current="",L(Te=>{if(!N)return Te;let ve=Yl(pe),Re=`[TERMINAL_RECORD]
|
|
281
|
-
COMMAND: ${N}
|
|
282
|
-
PTY: ${Rn}
|
|
283
|
-
OUTPUT: ${ve.replace(/\n{3,}/g,`
|
|
284
|
-
|
|
285
|
-
`)}`,Mt=[...Te.map(ht=>ht.isStreaming?{...ht,isStreaming:!1}:ht),{id:"term-"+Date.now(),role:"system",text:Re,isTerminalRecord:!0}];return F(Mt.length),Mt}),Ki(null),Vi(!1),Qn("")},onToolResult:(N,pe)=>{if(N==="success"){if(ac(Te=>Te+1),pe==="generate_image"){fc(Re=>Re+1);let ve={Low:.001,"Low-High":.002,Medium:.008,"Medium-High":.01,High:.045,Ultra:.0488,Premium:.1}[Yo.quality]||.002;xc(Re=>Re+ve)}}else N==="denied"?dc(Te=>Te+1):cc(Te=>Te+1)},onIDEApproval:Fo,onToolApproval:async(N,pe,Te={})=>{let ve=mn(pe||"{}"),Re=ve.path||ve.targetPath||ve.file||"",Ve=re?.alwaysAskFiles||".env, .env.*, *.env",Mt=(N==="view_file"||N==="write_file"||N==="update_file")&&xl(Re,Ve),ht=Re?Ct.resolve(Re).toLowerCase():"",K=Re?Ct.extname(Re).toLowerCase():"",Ee=N==="write_file"&&re.overwriteProtection!==!1&&Re&&ft.existsSync(Ct.resolve(process.cwd(),Re))&&(re.autoExec||Ws||K&&Gs.current.has(K)),_e=!Mt&&!Ee&&(re.autoExec||Ws||N==="write_file"&&K&&Gs.current.has(K)||N==="update_file"&&ht&&zi.current.has(ht));if(N==="exec_command"){let{command:Le}=ve,pt=(Le||"").trim(),go=/^(echo|ls|dir|pwd|cd|git status|git log|git diff|type|cat|help)\b/i,Kt=(wt=>{let At=[],Ut="",ho=null;for(let po=0;po<wt.length;po++){let Rt=wt[po];ho?(Rt===ho&&(ho=null),Ut+=Rt):Rt==='"'||Rt==="'"?(ho=Rt,Ut+=Rt):Rt==="&"&&wt[po+1]==="&"||Rt==="|"&&wt[po+1]==="|"?(Ut.trim()&&(At.push(Ut.trim()),Ut=""),po++):Rt===";"||Rt==="|"||Rt==="&"?Ut.trim()&&(At.push(Ut.trim()),Ut=""):Ut+=Rt}return Ut.trim()&&At.push(Ut.trim()),At.length>0?At:[wt]})(pt),Io=(wt,At)=>{if(!At)return!1;let Ut=At.split(",").map(po=>po.trim().toLowerCase()).filter(Boolean),ho=wt.toLowerCase();return Ut.some(po=>{if(ho===po)return!0;if(ho.startsWith(po)){let Rt=ho.charAt(po.length);return/\s|[;&|/]/.test(Rt)}return!1})},kn=Kt.some(wt=>Io(wt,re?.autoDisallowCommands)),Zn=Kt.some(wt=>Io(wt,re?.alwaysAskCommands)),zo=Kt.length>0&&Kt.every(wt=>Io(wt,re?.autoApproveCommands)||re?.autoApproveGit&&/^git\s+commit\b/i.test(wt));return kn?"deny":Zn?Te.checkOnly?null:new Promise(wt=>{Nr(),ln({tool:N,args:pe,resolve:wt}),ie("terminalApproval")}):zo||re?.autoApproveGit&&/^git\s+commit\b/i.test(pt)||re.autoExec||Ws||Qi.current.has(pt)||pt&&go.test(pt)?"allow":Te.checkOnly?null:new Promise(wt=>{Nr(),ln({tool:N,args:pe,resolve:wt}),ie("terminalApproval")})}return _e?"allow":Te.checkOnly?null:new Promise(Le=>{Nr(),ln({tool:N,args:pe,resolve:Le,isOverwrite:!!(Te.isOverwritePrompt||Ee)}),ie("approval")})},onAskUser:async(N,pe)=>(ze(),ae(),Nr(),new Promise(Te=>{let ve=!1;Ks({question:N,options:pe,resolve:Re=>{ve||(ve=!0,L(Ve=>{if(Ve.some(K=>K.isAskRecord&&K.text?.includes(`Selection: ${Re}`)))return Ve;let ht=[...Ve,{id:"ask-"+Date.now(),role:"system",text:`\u{1F4AC} **Ask User**
|
|
286
|
-
Question: ${N}
|
|
287
|
-
Selection: ${Re}`,isAskRecord:!0}];return F(ht.length),ht}),Te(Re))}}),ie("ask")})),onUsage:N=>{let pe=N.totalTokenCount||0,Te=N.cachedContentTokenCount||0,ve=N.candidatesTokenCount||0,Re=Math.max(0,pe-ve);if(sn({tokens:pe}),Ui(Ve=>Ve+pe),Re>0&&_i(Ve=>Ve+Re),Te>0&&Hi(Ve=>Ve+Te),ve>0&&Wi(Ve=>Ve+ve),Re>0||Te>0){to.current.push({input:Re,cached:Te}),to.current.length>3&&to.current.shift();let Ve=to.current.reduce((K,ne)=>K+ne.input,0),Mt=to.current.reduce((K,ne)=>K+ne.cached,0),ht=Ve>0?Mt/Ve*100:0;Sn(ht)}Fi(Ve=>Ve+1)}},async()=>qo.current?qo.current:null,So),q=!1,je=null,Fe=null,ke=!1,rt=!1,Ht=!1,at=!1,se=0,ge=null,Ue=/\[?\s*turn\s*:\s*.*?\s*\]?/gi;for await(let N of te){if(await new Promise(K=>setTimeout(K,3)),N.type==="text"&&ks(Date.now()),E&&N.type==="text"&&(S=Date.now(),E=!1,re.progressiveRendering&&De()),N.type==="status"){if(N.content&&(N.content.includes("Steering Hint Injected")||N.content.includes("Question Forwarded"))){let K=qo.current;K&&(L(ne=>{F(ne.length+1);let Ee=K.startsWith("/btw"),_e=Ee?K.replace(/^\/btw\s*/,""):K,Le=Ee?"[QUESTION]":"[STEERING HINT]";return[...ne,{id:"hint-"+Date.now(),role:"user",text:`${Le}
|
|
288
|
-
${_e}`,color:"cyan",isSteeringHint:!0,hintType:Ee?"QUESTION":"STEERING HINT",hintContent:_e}]}),zs(null),qo.current=null)}N.content?.includes("[start]")||Vs(N.content),N.content?.includes("[start]")?(clearInterval(hr),gr(0),hr=setInterval(()=>{gr(K=>K+1)},1e3)):N.content?.includes("[end]")&&(gr(0),clearInterval(hr)),Pn()&&rs(N.content),N.content==="Request Cancelled"&&(ze(),ae(),g());continue}if(N.type==="status_history"){Vs(N.content),Pn()&&rs(N.content),L(K=>[...K,{id:"condense-"+Date.now(),role:"system",text:`\u2726 ${N.content}
|
|
289
|
-
\u2800`,isMeta:!0}]);continue}if(N.type==="summary_injected"){L(K=>K.map(ne=>ne.id===N.content.id?{...ne,fullText:N.content.text}:ne));continue}if(N.type==="spinner"){Tc(N.content);continue}if(N.type==="model_update"){vc(N.content);continue}if(N.type==="turn_reset"){if(ze(),ae(),je=null,Fe=null,q=!1,ke=!1,rt=!1,at=!1,Ht=!1,L(K=>{let ne=K.map(Ee=>{if(Ee.isStreaming){let _e=Ee.text?Vt(Ee.text):Ee.text,Le=Ee.fullText?Vt(Ee.fullText):Ee.fullText;return{...Ee,isStreaming:!1,text:_e,fullText:Le}}return Ee});return F(ne.length),ne}),Qo(),global.gc){for(let K=0;K<2;K++)global.gc(),await new Promise(ne=>setImmediate(ne));m.current=Date.now()}continue}if(N.type==="interactive_turn_finished"){js(!1),gr(0),clearInterval(hr),Pn()&&rs(null),p=!0,re?.agentFinishSound&&(async()=>{try{let ne=(await Jo())[gt],Ee=vr(ne,String(gt));wi(Ee)}catch{wi(String(gt))}})(),Qo(),re?.autoTruncateResults&&L(K=>{let ne=K.map(Ee=>{let _e=Ee.fullText||Ee.text||"";return!_e.startsWith("[ACTION RESULT]:")&&!_e.startsWith("[TOOL RESULT]:")||_e.startsWith("[ACTION RESULT]: Goal")||_e.includes("...Success result truncated to save tokens")||_e.startsWith("[ACTION RESULT]: USER CHOOSE")||_e.startsWith("[ACTION RESULT]: Skill:")||_e.startsWith("[ACTION RESULT]: DOCs:")||_e.startsWith("[ACTION RESULT]: Markdown parsed")||_e.startsWith("[ACTION RESULT]: Search results for [")||_e.startsWith("[ACTION RESULT]: AI Mode temporarily failed")||_e.startsWith("[ACTION RESULT]: Background subagent started. Task ID:")||/^\[ACTION RESULT\]: File \[.*?\] saved/s.test(_e)?Ee:{...Ee,fullText:"[ACTION RESULT]: ...Success result truncated to save tokens"}});return On(gt,null,ne),F(ne.length),ne}),la({profile:Mn,thinkingLevel:Ke,mode:Y,janitorModel:k,chatId:gt,systemSettings:re,sessionStats:No,aiProvider:$,apiKey:Ye},N.data.agentText,N.data.fullAgentTextRaw,N.data.history,{onMemoryUpdated:()=>L(K=>{let ne=[...K];return ne.length>0&&(ne[ne.length-1].memoryUpdated=!0),ne}),onBackgroundIncrement:()=>nc(K=>K+1)});continue}if(N.type==="visual_feedback"){ze(),ae(),L(K=>{let ne=[...K,{id:"feedback-"+Date.now()+"-"+Math.random().toString(36).substring(2,9),role:"system",text:Vt(N.content),isVisualFeedback:!0}];return F(ne.length),ne});continue}if(N.type==="exec_start"){ze(),ae();continue}if(N.type==="liveTokens"){sn({tokens:N.content});continue}if(N.type==="usage"){let K=N.content.totalTokenCount||0,ne=N.content.cachedContentTokenCount||0,Ee=N.content.candidatesTokenCount||0,_e=Math.max(0,K-Ee);if(sn({tokens:K}),Ui(Le=>Le+K),_e>0&&_i(Le=>Le+_e),ne>0&&Hi(Le=>Le+ne),Ee>0&&Wi(Le=>Le+Ee),_e>0||ne>0){to.current.push({input:_e,cached:ne}),to.current.length>3&&to.current.shift();let Le=to.current.reduce((Qt,Kt)=>Qt+Kt.input,0),pt=to.current.reduce((Qt,Kt)=>Qt+Kt.cached,0),go=Le>0?pt/Le*100:0;Sn(go)}Fi(Le=>Le+1);continue}if(N.type==="tool_time"){mc(K=>K+N.content);continue}if(N.type==="tool_result"){if(ae(),je=null,Fe=null,q=!1,ke=!1,rt=!1,at=!1,Ht=!1,se=0,ge=null,L(K=>{let ne=[...K,{id:"tool-"+Date.now()+"-"+Math.random().toString(36).substring(2,7),role:"system",text:Vt(N.content),fullText:Vt(N.aiContent),binaryPart:N.binaryPart,toolName:N.toolName}];return F(ne.length),ne}),j.current&&(Fe=j.current.id,rt=!0),N.toolName==="update_file"&&N.aiContent){let K=N.aiContent.split(`
|
|
290
|
-
`),ne=0,Ee=0,_e=!1;for(let Le of K){if(Le.includes("[DIFF_START]")){_e=!0;continue}if(Le.includes("[DIFF_END]")){_e=!1;continue}_e&&(/^\+\s*\d+/.test(Le)?ne++:/^\-\s*\d+/.test(Le)&&Ee++)}Ln("linesAdded",ne),Ln("linesRemoved",Ee)}else if(N.toolName==="write_file"&&N.aiContent){let K=N.aiContent.match(/- Stats: \[(\d+) lines/),ne=K?parseInt(K[1]):0,Ee=0;if(N.aiContent.includes("Old File contents:")){let _e=N.aiContent.split(`
|
|
291
|
-
`),Le=!1;for(let pt of _e){if(pt.includes("Old File contents:")){Le=!0;continue}Le&&(pt.startsWith("- Content Preview:")||pt.startsWith("- Stats:")?Le=!1:/^\s*\d+\s*\|/.test(pt)&&Ee++)}}(ne>0||Ee>0)&&(Ln("linesAdded",ne),Ln("linesRemoved",Ee))}continue}let pe=N.content;if(N.type==="text"&&pe.includes("Request Cancelled")){if(global.gc){for(let K=0;K<3;K++)global.gc(),await new Promise(ne=>setImmediate(ne));m.current=Date.now()}continue}let Te=pe.toLowerCase();if(pe.includes("```")&&(ke=!ke),(Te.includes("tool:")||Te.includes("action:"))&&(rt=!0,se=0,ge=null,(pe.includes("[tool:")||pe.includes("[action:"))&&(se=0)),rt){for(let K=0;K<pe.length;K++){let ne=pe[K];!ge&&(ne==="'"||ne==='"'||ne==="`")?ge=ne:ge&&ne===ge&&pe[K-1]!=="\\"&&(ge=null),ge||(ne==="("||ne==="["?se++:(ne===")"||ne==="]")&&se--)}se<=0&&!ge&&(rt=!1)}let ve=/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])/i,Re=(K,ne,Ee=1)=>{let _e=ne>0?K[ne-1]:"",Le=ne+Ee<K.length?K[ne+Ee]:"";return _e==="`"&&Le==="`"},Ve=K=>{let ne=/(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\])/gi,Ee;for(;(Ee=ne.exec(K))!==null;)if(!Re(K,Ee.index,Ee[0].length))return{index:Ee.index,length:Ee[0].length};return{index:-1,length:0}},Mt=j.current?.role==="agent"&&j.current.text||"",ht=!Ht&&Mt.trim().length===0;if(!q&&ht&&(ve.test(pe)||ve.test(Mt+pe))){let K=ve.test(pe)?pe:Mt+pe,ne=K.match(ve),Ee=ne.index,_e=ne[0].length,Le=K.substring(Ee+_e);ze(),j.current=null,q=!0,Ht=!0,je="think-"+Date.now(),j.current={id:je,role:"think",text:"",isStreaming:!0,startTime:Date.now()};let pt=Ve(Le);if(pt.index!==-1){let Qt=Le.substring(0,pt.index).replace(/^\r?\n+/,"").replace(/\r?\n+$/,""),Kt=Le.substring(pt.index+pt.length);j.current.text=Vt(Qt);let Io=j.current.startTime||Date.now();j.current.duration=Date.now()-Io,ae(),q=!1,Fe="agent-"+Date.now(),j.current={id:Fe,role:"agent",text:"",isStreaming:!0},Kt&&dt(Kt)}else{let go=Le.replace(/^\r?\n+/,"");go&&dt(go)}continue}if(!q&&!Ht&&pe.trim().length>0&&(Ht=!0),q&&j.current?.role==="think"){ze();let ne=(j.current.text||"")+pe,Ee=Ve(ne);if(Ee.index!==-1){let _e=ne.substring(0,Ee.index),Le=ne.substring(Ee.index+Ee.length);j.current.text=Vt(_e);let pt=j.current.startTime||Date.now();j.current.duration=Date.now()-pt,ae(),q=!1,Fe="agent-"+Date.now(),j.current={id:Fe,role:"agent",text:"",isStreaming:!0},Le&&dt(Le)}else dt(pe);continue}else if(!q){let K=pe.toLowerCase();!at&&(K.includes("tool:")||K.includes("action:"))&&(at=!0),!j.current||j.current.role!=="agent"?(Fe="agent-"+Date.now(),j.current={id:Fe,role:"agent",text:Vt(pe),isStreaming:!0},it()):dt(pe)}}let Je=Date.now();uc(N=>N+(Je-S))}catch(z){L(Z=>(F(Z.length+1),[...Z,{id:"error-"+Date.now(),role:"system",text:`\u274C ERROR: ${z.message}`}]))}finally{let z=Date.now()-S;if(j.current&&(j.current.workedDuration=z),nt.current&&(await ct(),clearInterval(nt.current),nt.current=null),js(!1),Vs(null),gr(0),clearInterval(hr),ae(),qs.current&&g(),Qo(),global.gc)try{for(let Z=0;Z<3;Z++)global.gc(),await new Promise(G=>setImmediate(G));m.current=Date.now()}catch{}if(p||process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow | Idle\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow | Idle\x07")),qo.current){Qs(qo.current),zs(null);let Z=qo.current;qo.current=null,L(G=>{let Q=[...G],te=Q.reverse().find(q=>q.text?.includes("[STEERING HINT: QUEUED]")||q.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]"))),Q.reverse()}),ie("resolution")}L(Z=>{let G=Date.now()-S,Q=!1,te=[...Z].reverse().map(Fe=>{let ke=Fe.isStreaming?{...Fe,isStreaming:!1}:Fe;return ke.text&&(ke.text=(" "+ke.text).slice(1)),!Q&&ke.role==="agent"&&(Q=!0,ke={...ke,workedDuration:G}),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:G})}let je=te.filter(Fe=>!String(Fe.id).startsWith("welcome")&&(!Fe.isMeta||Fe.text&&Fe.text.includes("Request Cancelled")));return On(gt,null,je),F(te.length),te})}})()}w(""),V(!1)}},st=nr(()=>{if(C.startsWith("/")&&!tt){let n=C.split(" "),h=n[n.length-1].toLowerCase();if(n.length===1){let c=h.startsWith("/")?h.slice(1):h;return ul.filter(g=>(g.cmd.startsWith("/")?g.cmd.slice(1):g.cmd).toLowerCase().includes(c))}let f=ul;for(let c=0;c<n.length-1;c++){let g=n[c].toLowerCase(),p=f.find(S=>S.cmd.toLowerCase()===g);if(p&&p.subs)f=p.subs;else return[]}return f.filter(c=>c.cmd.toLowerCase().includes(h))}let x=C.split(" "),a=x[x.length-1],B=a&&a.startsWith("\\@");if((a&&a.startsWith("@")||B)&&!tt){let n=a.indexOf("#"),h=n!==-1,f=B?2:1,c=h?a.substring(f,n).toLowerCase():a.slice(f).toLowerCase(),g=h?a.substring(n):"";return wu(process.cwd()).filter(E=>E.name.toLowerCase().includes(c)).map(E=>{let z=E.relativePath.replace(/\\/g,"/"),Z=z.startsWith(".")?z:"./"+z;return{cmd:(B?"\\@":"@")+"["+Z+g+"]",desc:E.relativePath}})}return[]},[C,tt]);xt(()=>{let x=0;for(;x<st.length;){let a=st[x],B=a?.cmd||a||"";if(typeof B=="string"&&B.trimStart().startsWith("---"))x++;else break}Ne(x<st.length?x:0)},[st]);let[Jr,Zr]=R(0),fl=Ze(0);xt(()=>{let x=fl.current>0,a=st.length>0;if(fl.current=st.length,!a){Zr(0);return}if(!x){Zr(1);return}Zr(st.length)},[st]),xt(()=>{if(Jr>0&&Jr<st.length){let x=setTimeout(()=>{Zr(a=>Math.min(a+1,st.length))},1);return()=>clearTimeout(x)}},[Jr,st.length]),xt(()=>{if(vt!=="providerBudgetSelect")return;let x=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","Infron","APInex","xKiro"],a=Ie.providerBudgets||{},B=x.reduce((o,n)=>(o[n]=!!(a[n]&&(a[n].agentLimit||a[n].tokenLimit||a[n].monthlyTokenLimit||a[n].dailyCostLimit||a[n].monthlyCostLimit)),o),{});Li(B),Xr(0)},[vt]),xt(()=>{if(vt!=="providerBudgetFlow")return;let x={},a=Ie.providerBudgets||{};for(let B of $n){let o=a[B]||{};x[B]={agentLimit:on(o.agentLimit),tokenLimit:on(o.tokenLimit),monthlyTokenLimit:on(o.monthlyTokenLimit),dailyCostLimit:on(o.dailyCostLimit),monthlyCostLimit:on(o.monthlyCostLimit)}}ar(x),vo(0)},[vt,$n]);let Pu=({label:x,isSelected:a})=>{let B=x==="Cancel"||x==="Back"||x.toLowerCase().includes("exit")||x.toLowerCase().includes("back");return e.createElement(u,{marginTop:B?1:0,backgroundColor:a?"#2a2a2a":void 0,paddingX:1,width:"100%"},e.createElement(i,{color:a?"white":"gray",bold:a},a?"\u276F ":" ",x))},To=(x,a,B,o=10,n=2,h=9)=>{let f=Mo(B),c=!f&&B>0?Math.min(100,a/B*100):0,g=Math.round(c),p=Math.round(g/100*o),S="\u2588".repeat(p)+"\u2591".repeat(Math.max(0,o-p)),E=s.success||"green";g>=40&&g<=80?E=s.warning||"yellow":g>80&&(E=s.danger||"red");let z=x.toLowerCase().includes("cost")||x.toLowerCase().includes("spend"),Z=!z&&(x.toLowerCase().includes("token")||x.toLowerCase().includes("daily")||x.toLowerCase().includes("monthly")),G=f?"\u221E":z?`$${Number(B).toFixed(2)}`:Z?Pt(B):B,Q=Number(a)||0,te=z?`$${Q.toFixed(Q<.01&&Q>0?4:2)}`:Z?Pt(a):a,q;return f||c===0?q="0%":c>0&&c<1?q="<1%":q=`${g}%`,e.createElement(u,{flexDirection:"row",paddingLeft:n,key:x},e.createElement(u,{width:h},e.createElement(i,{color:s.textMuted},x,": ")),e.createElement(i,{color:E},S),e.createElement(i,{color:s.textMuted}," ",q," (",te,"/",G,")"))},Ic=()=>{switch(vt){case"settings":return e.createElement(gs,{systemSettings:re,setSystemSettings:Ft,apiTier:et,setActiveView:ie,setInputConfig:mo,saveSettings:qt,quotas:Ie,setMessages:L,aiProvider:$,autoCompletion:cr,setAutoCompletion:Is,profileData:Mn,setProfileData:Ds,setProviderReturnView:Bs,setApiKey:Nt,initAI:yo});case"theme":return e.createElement(gs,{systemSettings:re,setSystemSettings:Ft,apiTier:et,setActiveView:ie,setInputConfig:mo,saveSettings:qt,quotas:Ie,setMessages:L,aiProvider:$,autoCompletion:cr,setAutoCompletion:Is,profileData:Mn,setProfileData:Ds,initialSelectingTheme:!0,onCloseTheme:()=>ie("chat"),setProviderReturnView:Bs,setApiKey:Nt,initAI:yo});case"selectProvider":return e.createElement(_t,{title:"SELECT AI PROVIDER",searchable:!0,items:[{label:"Google",value:"Google"},{label:"Nvidia",value:"NVIDIA"},{label:"DeepSeek",value:"DeepSeek"},{label:"InferX",value:"InferX"},{label:"SenseNova",value:"SenseNova"},{label:"Poolside",value:"Poolside"},{label:"Experiential Labs",value:"ExpLabs"},{label:"Token Harbor",value:"TokenHarbor"},{label:"Infron",value:"Infron"},{label:"APInex",value:"APInex"},{label:"xKiro",value:"xKiro"},{label:"Ollama",value:"Ollama"},...process.env.ENABLE_9ROUTER==="true"||process.env.ENABLE_9ROUTER===!0?[{label:"9router [Local Proxy]",value:"9router"}]:[],{label:"AIHubMix [Experimental]",value:"AIHubMix"},{label:"Mistral [Experimental]",value:"Mistral"},{label:"OpenRouter [Experimental]",value:"OpenRouter"},{label:"Custom [OpenAI Chat Completion]",value:"c_openai"},{label:"Back",value:rn}],theme:re.theme,onSelect:async o=>{if(o.value===rn||o.value==="settings"||o.value==="Back"){ie(rn);return}let n=o.value,h=await un(n),f="";if(n==="9router"){let c=await Bi();c.ok||(f=`
|
|
292
|
-
|
|
293
|
-
\x1B[33m\u2726 WARNING: 9router does not appear to be running on ${c.url}.\x1B[39m
|
|
294
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m To start 9router: \x1B[36mnpx 9router\x1B[39m or \x1B[36mnpm i -g 9router && 9router\x1B[39m`)}if(n==="c_openai"){if(!re.customOpenAIBaseUrl){mo({label:"Enter Custom OpenAI Base URL (.../v1):",key:"customOpenAIBaseUrl",value:"",returnView:rn}),ie("input");return}let c=h||"";try{oi()}catch{}nn(n),Nt(c),yo(c,{aiProvider:n,onIDEApproval:Fo});let g=(Ie.providerTiers||{})[n]||"Free",p=bo(n,g)||"";jt(p),kt(g),Ft(S=>({...S,memory:!1})),qt({aiProvider:n,activeModel:p,apiTier:g,quotas:Ie,systemSettings:{...re,memory:!1}}),L(S=>[...S,{role:"system",text:`\u2726 Switched to Custom (OpenAI)!${p?`
|
|
295
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: ${p}.`:""}
|
|
296
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Endpoint: ${re.customOpenAIBaseUrl}${re.memory?`
|
|
297
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with Custom (OpenAI).`:""}
|
|
298
|
-
\u2800`,isMeta:!0}]),ie(rn);return}if(h){try{oi()}catch{}nn(n),Nt(h),yo(h,{aiProvider:n,onIDEApproval:Fo});let c=(Ie.providerTiers||{})[n]||"Free",g=bo(n,c);jt(g),kt(c),n==="NVIDIA"&&process.env.NVIDIA_BASE_URL||n==="Ollama"||n==="InferX"||n==="SenseNova"||n==="Poolside"||n==="9router"||n==="ExpLabs"||n==="TokenHarbor"||n==="Infron"||n==="APInex"||n==="xKiro"||n==="c_openai"?(Ft(S=>({...S,memory:!1})),qt({aiProvider:n,activeModel:g,apiTier:c,quotas:Ie,systemSettings:{...re,memory:!1}})):qt({aiProvider:n,activeModel:g,apiTier:c,quotas:Ie});let p=n==="c_openai"?"Custom (OpenAI)":n;L(S=>[...S,{role:"system",text:`\u2726 Switched to ${p} (cached)!${g?`
|
|
299
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: ${g}.`:""}${(n==="Ollama"||n==="InferX"||n==="SenseNova"||n==="AIHubMix"||n==="Poolside"||n==="9router"||n==="ExpLabs"||n==="TokenHarbor"||n==="Infron"||n==="APInex"||n==="xKiro"||n==="c_openai")&&re.memory?`
|
|
300
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with ${p}.`:""}${n==="NVIDIA"&&process.env.NVIDIA_BASE_URL&&re.memory?`
|
|
301
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with Custom Endpoints.`:""}${f}
|
|
302
|
-
\u2800`,isMeta:!0}]),ie(rn)}else mo({label:`Enter ${n==="c_openai"?"Custom (OpenAI)":n} API Key:`,key:"providerKey",provider:n,value:"",returnView:rn}),ie("input")},onClose:()=>ie(rn)});case"apiTier":return e.createElement(_t,{title:`Show Paid models from ${$.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] ${et==="Paid"?"\u25CF":""}`,value:"Paid"},{label:"Back",value:"settings"}],theme:re.theme,onSelect:o=>{if(o.value==="settings"||o.value==="Back"){ie("settings");return}let n=o.value;kt(n);let h={...Ie.providerTiers||{},[$]:n},f={...Ie,providerTiers:h};io(f),qt({apiTier:n,quotas:f}),ie("settings")}});case"resetMode":return e.createElement(_t,{title:"SELECT MONTHLY RESET MODE",items:[{label:"Default (Rolling 30-Day Window)",value:"Rolling"},{label:"Custom (Set reset day of month)",value:"Custom"},{label:"Back",value:"apiTier"}],theme:re.theme,onSelect:o=>{if(o.value==="apiTier"||o.value==="Back"){ie("apiTier");return}let n=o.value,h={...Ie,resetMode:n};io(h),n==="Custom"?(mo({label:"Enter monthly reset day (1-30):",key:"quotas",subKey:"resetDay",value:String(Ie.resetDay||1),returnView:"settings"}),ie("input")):(qt({apiTier:et,quotas:h}),ie("settings"))},onClose:()=>ie("apiTier")});case"budgetTypeSelect":return e.createElement(_t,{title:"SELECT BUDGET TYPE",items:[{label:`Global Budget (single limit for all providers) ${et==="Paid"&&!Ie.providerBudgets?.__useProvider?"\u25CF":""}`,value:"global"},{label:`Provider Budgets (set limits per provider individually) ${Ie.providerBudgets?.__useProvider?"\u25CF":""}`,value:"provider"},{label:"Back",value:Vo}],theme:re.theme,onSelect:o=>{if(o.value===Vo||o.value==="Back"){ie(Vo);return}if(o.value==="global"){let n={...Ie,agentLimit:99999999,tokenLimit:99999999999999,monthlyTokenLimit:99999999999999,providerBudgets:{__useProvider:!1}};io(n);let h=Vo==="settings"?"resetMode":"budgetResetMode";mo({label:"Enter Agent daily budget (tokens used):",key:"quotas",subKey:"tokenLimit",value:on(n.tokenLimit),returnView:Vo,next:f=>({label:"Enter Agent monthly budget (tokens used):",key:"quotas",subKey:"monthlyTokenLimit",value:on(f.monthlyTokenLimit),returnView:Vo,next:c=>({label:"Enter Daily Cost Limit ($ or 0 for unlimited):",key:"quotas",subKey:"dailyCostLimit",value:on(c.dailyCostLimit),returnView:Vo,next:g=>({label:"Enter Monthly Cost Limit ($ or 0 for unlimited):",key:"quotas",subKey:"monthlyCostLimit",value:on(g.monthlyCostLimit),returnView:h})})})}),ie("input")}else if(o.value==="provider"){let n={...Ie,agentLimit:99999999,tokenLimit:99999999999999,monthlyTokenLimit:99999999999999,providerBudgets:{...Ie.providerBudgets||{},__useProvider:!0}};io(n),ie("providerBudgetSelect")}},onClose:()=>ie(Vo)});case"providerBudgetSelect":{let o=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","Infron","APInex","xKiro"],n=o.some(h=>Es[h]);return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,padding:0,width:"100%"},e.createElement(u,{paddingX:1,marginBottom:1},e.createElement(i,{color:s.text,bold:!0},"SELECT PROVIDERS TO SET LIMITS FOR")),o.map((h,f)=>{let c=f===Ai,g=!!Es[h];return e.createElement(u,{key:h,backgroundColor:c?s.highlightBg||"#2a2a2a":void 0,paddingX:1,width:"100%",flexDirection:"row"},e.createElement(i,{color:c?s.text:s.textMuted,bold:c},c?"\u276F ":" "),e.createElement(i,{color:g?s.success||"green":s.textMuted},g?"\u2611":"\u2610"),e.createElement(i,{color:c?s.text:s.textMuted,bold:c}," ",h),g&&(Ie.providerBudgets?.[h]?.agentLimit||Ie.providerBudgets?.[h]?.tokenLimit||Ie.providerBudgets?.[h]?.monthlyTokenLimit||Ie.providerBudgets?.[h]?.dailyCostLimit||Ie.providerBudgets?.[h]?.monthlyCostLimit)?e.createElement(i,{color:s.primary||"cyan"}," (budget set)"):null)}),e.createElement(u,{paddingX:1,marginTop:1,flexDirection:"column"},e.createElement(i,{color:s.textMuted,italic:!0},"\u2191\u2193 Navigate \u2022 Space to toggle \u2022 Enter to confirm \u2022 ESC to go back"),!n&&e.createElement(i,{color:s.warning||"yellow",italic:!0}," Select at least one provider to continue")))}case"providerBudgetFlow":{let o=$n.length,n=o*4;return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,padding:0,width:"100%"},e.createElement(u,{paddingX:1,marginBottom:0,justifyContent:"space-between",flexDirection:"row"},e.createElement(i,{color:s.text,bold:!0},"PROVIDER BUDGET CONFIGURATION"),e.createElement(i,{color:s.textMuted,italic:!0},"(0 or blank = unlimited)")),e.createElement(u,{paddingX:1,marginTop:1,flexDirection:"row"},e.createElement(u,{width:13},e.createElement(i,{color:s.textMuted,bold:!0},"PROVIDER")),e.createElement(u,{width:20,paddingLeft:1},e.createElement(i,{color:s.textMuted,bold:!0},"DAILY TOKENS")),e.createElement(u,{width:22,paddingLeft:1},e.createElement(i,{color:s.textMuted,bold:!0},"MONTHLY TOKENS")),e.createElement(u,{width:18,paddingLeft:1},e.createElement(i,{color:s.textMuted,bold:!0},"DAILY COST ($)")),e.createElement(u,{width:20,paddingLeft:1},e.createElement(i,{color:s.textMuted,bold:!0},"MONTHLY COST ($)"))),e.createElement(u,{paddingX:1},e.createElement(i,{color:s.borderMuted},"\u2500".repeat(93))),$n.map((h,f)=>{let c=f*4,g=f*4+1,p=f*4+2,S=f*4+3,E=Un===c,z=Un===g,Z=Un===p,G=Un===S,Q=E||z||Z||G,te=lr[h]?.tokenLimit??"",q=lr[h]?.monthlyTokenLimit??"",je=lr[h]?.dailyCostLimit??"",Fe=lr[h]?.monthlyCostLimit??"";return e.createElement(u,{key:h,flexDirection:"row",paddingX:1,marginY:0,backgroundColor:Q?s.highlightBg||"#2a2a2a":void 0},e.createElement(u,{width:13,flexDirection:"row"},e.createElement(i,{color:Q?s.primary||"cyan":s.text,bold:Q},Q?"\u276F ":" ",h)),e.createElement(u,{width:20,paddingLeft:1,flexDirection:"row"},E?e.createElement(u,{flexDirection:"row"},e.createElement(i,{color:s.primary||"cyan",bold:!0},"[ "),e.createElement(rr,{value:te,onChange:ke=>{ar(rt=>({...rt,[h]:{...rt[h]||{},tokenLimit:ke}}))},onSubmit:()=>vo(g)}),e.createElement(i,{color:s.primary||"cyan",bold:!0}," ]")):e.createElement(i,{color:te?s.text:s.textMuted},"[ ",te||"0 (\u221E)"," ]")),e.createElement(u,{width:22,paddingLeft:1,flexDirection:"row"},z?e.createElement(u,{flexDirection:"row"},e.createElement(i,{color:s.primary||"cyan",bold:!0},"[ "),e.createElement(rr,{value:q,onChange:ke=>{ar(rt=>({...rt,[h]:{...rt[h]||{},monthlyTokenLimit:ke}}))},onSubmit:()=>vo(p)}),e.createElement(i,{color:s.primary||"cyan",bold:!0}," ]")):e.createElement(i,{color:q?s.text:s.textMuted},"[ ",q||"0 (\u221E)"," ]")),e.createElement(u,{width:18,paddingLeft:1,flexDirection:"row"},Z?e.createElement(u,{flexDirection:"row"},e.createElement(i,{color:s.primary||"cyan",bold:!0},"[ $"),e.createElement(rr,{value:je,onChange:ke=>{ar(rt=>({...rt,[h]:{...rt[h]||{},dailyCostLimit:ke}}))},onSubmit:()=>vo(S)}),e.createElement(i,{color:s.primary||"cyan",bold:!0}," ]")):e.createElement(i,{color:je?s.warning||"yellow":s.textMuted},"[ ",je?`$${je}`:"0 (\u221E)"," ]")),e.createElement(u,{width:20,paddingLeft:1,flexDirection:"row"},G?e.createElement(u,{flexDirection:"row"},e.createElement(i,{color:s.primary||"cyan",bold:!0},"[ $"),e.createElement(rr,{value:Fe,onChange:ke=>{ar(rt=>({...rt,[h]:{...rt[h]||{},monthlyCostLimit:ke}}))},onSubmit:()=>{f+1<o?vo((f+1)*4):vo(n)}}),e.createElement(i,{color:s.primary||"cyan",bold:!0}," ]")):e.createElement(i,{color:Fe?s.warning||"yellow":s.textMuted},"[ ",Fe?`$${Fe}`:"0 (\u221E)"," ]")))}),e.createElement(u,{paddingX:1,marginTop:1},Un===n?e.createElement(u,{backgroundColor:s.highlightBg||"#2a2a2a",paddingX:1},e.createElement(i,{color:s.success||"green",bold:!0},"\u276F [ Save & Apply Budgets ]")):e.createElement(i,{color:s.textMuted}," [ Save & Apply Budgets ]")),e.createElement(u,{paddingX:1,marginTop:1,flexDirection:"column"},e.createElement(i,{color:s.textMuted,italic:!0},"\u2191\u2193/\u2190\u2192 Navigate \u2022 Enter next / save \u2022 ESC to go back")))}case"budgetResetMode":return e.createElement(_t,{title:"SELECT MONTHLY RESET MODE",items:[{label:"Default (Rolling 30-Day Window)",value:"Rolling"},{label:"Custom (Set reset day of month)",value:"Custom"},{label:"Back",value:"chat"}],theme:re.theme,onSelect:o=>{if(o.value==="chat"||o.value==="Back"){ie("chat");return}let n=o.value,h={...Ie,resetMode:n};io(h),n==="Custom"?(mo({label:"Enter monthly reset day (1-30):",key:"quotas",subKey:"resetDay",value:String(Ie.resetDay||1),returnView:"chat"}),ie("input")):(qt({apiTier:et,quotas:h}),ie("chat"))},onClose:()=>ie("chat")});case"budgetView":{let o=Yn?.agent||0,n=Ie.agentLimit||99999999,h=Yn?.tokens||0,f=Ie.tokenLimit||99999999999999,c=Ie.resetMode==="Custom"?jr?.tokens||0:dr?.tokens||0,g=Ie.monthlyTokenLimit||99999999999999,p=Yn?.cost||0,S=Ie.dailyCostLimit||99999999999999,E=Ie.resetMode==="Custom"?jr?.cost||0:dr?.cost||0,z=Ie.monthlyCostLimit||99999999999999,Z=et!=="Paid",G=!!Ie.providerBudgets?.__useProvider,Q=Ie.providerBudgets||{},te=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","Infron","APInex","xKiro"].filter(ke=>Q[ke]&&(Q[ke].agentLimit||Q[ke].tokenLimit||Q[ke].monthlyTokenLimit||Q[ke].dailyCostLimit||Q[ke].monthlyCostLimit)),q=!G&&(Mo(f)||Mo(g))&&(Mo(S)||Mo(z)),je="",Fe="";if(Ie.resetMode==="Custom"){let ke=new Date,rt=Ie.resetDay||1,Ht=ke.getFullYear(),at=ke.getMonth();ke.getDate()>=rt&&(at+=1,at>11&&(at=0,Ht+=1));let se=new Date(Ht,at,rt,0,0,0);je=`${se.toLocaleString("default",{month:"short"}).toUpperCase()}-${rt}`;let Ue=Math.max(0,se.getTime()-ke.getTime()),Je=Math.floor(Ue/(1e3*60*60)),N=Math.floor(Je/24),pe=Je%24;Fe=`(${N} days: ${pe} hrs left)`}return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,padding:1,paddingBottom:0,paddingTop:0,width:"100%"},e.createElement(u,{marginBottom:1,justifyContent:"space-between",width:"100%"},e.createElement(i,{color:s.text,bold:!0,underline:!0},"USAGE LIMITS"),e.createElement(i,{color:s.textMuted},"[ ESC to Close ]")),q?e.createElement(u,{padding:1,justifyContent:"center",alignItems:"center",width:"100%"},e.createElement(i,{color:s.text,bold:!0},"LIMITS NOT SET")):G&&te.length>0?e.createElement(u,{flexDirection:"column",gap:0,width:"100%"},(()=>{let ke=r?.columns||H?.columns||80;if(ke<115){let at=Math.max(5,Math.min(30,ke-50));return te.map(se=>{let ge=Q[se],Ue=0,Je=Yn?.models?.[se]||{};for(let Ve in Je)Ue+=Je[Ve]?.tokens||0;let N=0,Te=(Ie.resetMode==="Custom"?jr:dr)?.models?.[se]||{};for(let Ve in Te)N+=Te[Ve]?.tokens||0;let ve=0;for(let Ve in Je)ve+=Je[Ve]?.cost||0;let Re=0;for(let Ve in Te)Re+=Te[Ve]?.cost||0;return e.createElement(u,{key:se,flexDirection:"column",borderStyle:"single",borderColor:s.borderMuted,paddingX:1,width:"100%"},e.createElement(u,{marginBottom:0},e.createElement(i,{color:s.primary,bold:!0},"\u25C6 ",se)),To("Daily",Ue,ge.tokenLimit||99999999999999,at,2,9),To("Monthly",N,ge.monthlyTokenLimit||99999999999999,at,2,9),(!Mo(ge.dailyCostLimit)||!Mo(ge.monthlyCostLimit))&&e.createElement(e.Fragment,null,To("Daily Cost",ve,ge.dailyCostLimit||99999999999999,at,2,11),To("Monthly Cost",Re,ge.monthlyCostLimit||99999999999999,at,2,11)))})}let Ht=[];for(let at=0;at<te.length;at+=2)Ht.push(te.slice(at,at+2));return Ht.map((at,se)=>e.createElement(u,{key:se,flexDirection:"row",width:"100%"},at.map(ge=>{let Ue=Q[ge],Je=0,N=Yn?.models?.[ge]||{};for(let ne in N)Je+=N[ne]?.tokens||0;let pe=0,ve=(Ie.resetMode==="Custom"?jr:dr)?.models?.[ge]||{};for(let ne in ve)pe+=ve[ne]?.tokens||0;let Re=0;for(let ne in N)Re+=N[ne]?.cost||0;let Ve=0;for(let ne in ve)Ve+=ve[ne]?.cost||0;let Mt=at.length===1,ht=Mt?ke:Math.floor(ke/2),K=Math.max(5,Math.min(25,ht-36));return e.createElement(u,{key:ge,flexDirection:"column",borderStyle:"single",borderColor:s.borderMuted,paddingX:1,width:Mt?"100%":"50%"},e.createElement(u,{marginBottom:0},e.createElement(i,{color:s.primary,bold:!0},"\u25C6 ",ge)),To("Daily",Je,Ue.tokenLimit||99999999999999,K,2,9),To("Monthly",pe,Ue.monthlyTokenLimit||99999999999999,K,2,9),(!Mo(Ue.dailyCostLimit)||!Mo(Ue.monthlyCostLimit))&&e.createElement(e.Fragment,null,To("Daily Cost",Re,Ue.dailyCostLimit||99999999999999,K,2,11),To("Monthly Cost",Ve,Ue.monthlyCostLimit||99999999999999,K,2,11)))})))})(),je?e.createElement(u,{marginLeft:2,marginTop:1},e.createElement(i,{color:s.textMuted},"Monthly Reset: "),e.createElement(i,{color:s.accent||"magenta",bold:!0},je),Fe?e.createElement(i,{color:s.textMuted},` ${Fe}`):null):e.createElement(u,{marginLeft:2,marginTop:1},e.createElement(i,{color:s.textMuted},"Monthly Reset: "),e.createElement(i,{color:s.secondary||"blue",bold:!0},"Rolling 30-Day Window"))):e.createElement(u,{flexDirection:"column",borderStyle:"single",borderColor:s.borderMuted,paddingX:1,width:"100%"},To("Daily Tokens",h,f,"green"),To("Monthly Tokens",c,g,"yellow"),(!Mo(S)||!Mo(z))&&e.createElement(e.Fragment,null,To("Daily Cost",p,S,"cyan"),To("Monthly Cost",E,z,"magenta")),je?e.createElement(u,{marginLeft:4,marginTop:1},e.createElement(i,{color:s.textMuted},"Monthly Reset: "),e.createElement(i,{color:s.accent||"magenta",bold:!0},je),Fe?e.createElement(i,{color:s.textMuted},` ${Fe}`):null):e.createElement(u,{marginLeft:4,marginTop:1},e.createElement(i,{color:s.textMuted},"Monthly Reset: "),e.createElement(i,{color:s.secondary||"blue",bold:!0},"Rolling 30-Day Window"))))}case"input":return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,padding:0,width:"100%"},e.createElement(u,{paddingX:1},e.createElement(i,{color:s.text,bold:!0},"DATA CONFIGURATION")),Oo?.note&&e.createElement(u,{paddingX:1,marginBottom:1},e.createElement(i,{color:s.textMuted,italic:!0},Oo.note)),e.createElement(u,{paddingX:1,flexDirection:"row"},e.createElement(i,{color:s.text,bold:!0},Oo?.label," "),e.createElement(rr,{value:Oo?.value||"",onChange:o=>mo(n=>({...n,value:o})),onSubmit:async o=>{let{key:n,subKey:h,next:f,onDone:c}=Oo,g={...Ie},p={};if(n==="quotas"){let S;h.toLowerCase().includes("costlimit")?S=parseFloat(o)||0:h.toLowerCase().includes("limit")||h==="resetDay"?S=parseInt(o)||0:S=o,h==="resetDay"&&(S=Math.max(1,Math.min(30,S))),g[h]=S,io(g),p.quotas=g}else if(n==="providerBudgets"){let S=Oo.providerKey,E=h.toLowerCase().includes("limit")?parseInt(o)||0:o,z=g.providerBudgets||{};g.providerBudgets={...z,[S]:{...z[S]||{},[h]:E}},io(g),p.quotas=g}else if(n==="activeModel")jt(o),p.activeModel=o;else if(n==="janitorModel")ye(o),p.janitorModel=o;else if(n==="autoApproveCommands"||n==="autoDisallowCommands"||n==="alwaysAskCommands"){let S={...re,[n]:o.trim(),sandboxPreset:"Custom"};Ft(S),p.systemSettings=S}else if(n==="externalDataPath"){let S={...re,useExternalData:!0,externalDataPath:o.trim()};Ft(S),p.systemSettings=S,L(E=>[...E,{id:Date.now(),role:"system",text:"[EXTERNAL STORAGE] Flux Flow will use "+o.trim()+" for data after restart."}])}else if(n==="customOpenAIBaseUrl"){let S=o.trim().replace(/\/+$/,""),E={...re,customOpenAIBaseUrl:S,memory:!1};Ft(E),p.systemSettings=E;let z=(Ie.providerTiers||{}).c_openai||"Free",Z=bo("c_openai",z)||"";nn("c_openai"),jt(Z),kt(z),p.aiProvider="c_openai",p.activeModel=Z,p.apiTier=z;let Q=await un("c_openai")||"";Nt(Q),yo(Q,{aiProvider:"c_openai",onIDEApproval:Fo}),L(te=>[...te,{id:Date.now(),role:"system",text:`\u2726 Custom OpenAI Base URL saved!
|
|
303
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Switched to Custom (OpenAI)
|
|
304
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Endpoint: ${S}${Z?`
|
|
305
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: ${Z}`:""}
|
|
306
|
-
\u2800`,isMeta:!0}])}else if(n==="imageSettings"){let S=o.trim();if(S.startsWith("sk_")){let E={...Yo,apiKey:S};Gr(E),p.imageSettings=E,L(z=>(F(z.length+1),[...z,{id:Date.now(),role:"system",text:"[IMAGE KEY] Custom API key saved successfully.",isMeta:!0}]))}}else if(n==="providerKey"){let S=o.trim(),E=Oo.provider;(E==="Ollama"||E==="9router")&&(S==="LOCAL"||S==="")&&(S="LOCAL",E==="Ollama"&&(Ft(Q=>({...Q,ollamaEndpoint:"Local"})),p.systemSettings={...re,ollamaEndpoint:"Local"}));let z="";if(E==="9router"){let Q=await Bi();Q.ok||(z=`
|
|
307
|
-
|
|
308
|
-
\x1B[33m\u2726 WARNING: 9router does not appear to be running on ${Q.url}.\x1B[39m
|
|
309
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m To start 9router: \x1B[36mnpx 9router\x1B[39m or \x1B[36mnpm i -g 9router && 9router\x1B[39m`)}await si(E,S),nn(E),Nt(S),yo(S,{aiProvider:E,onIDEApproval:Fo});let Z=(Ie.providerTiers||{})[E]||"Free",G=bo(E,Z);jt(G),kt(Z),p.aiProvider=E,p.activeModel=G,p.apiTier=Z,(E==="NVIDIA"&&process.env.NVIDIA_BASE_URL||E==="Ollama"||E==="CrofAI"||E==="InferX"||E==="SenseNova"||E==="AIHubMix"||E==="Poolside"||E==="9router"||E==="ExpLabs"||E==="TokenHarbor"||E==="Infron"||E==="APInex"||E==="xKiro")&&(Ft(Q=>({...Q,memory:!1})),p.systemSettings={...re,memory:!1}),L(Q=>(F(Q.length+1),[...Q,{id:Date.now(),role:"system",text:`\u2726 ${E} API Key saved successfully! ${G?`
|
|
310
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Model: ${G}`:""}${E==="Ollama"&&S==="LOCAL"?`
|
|
311
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Ollama Endpoint automatically switched to Local`:""}${E==="Ollama"||E==="CrofAI"||E==="InferX"||E==="SenseNova"||E==="AIHubMix"||E==="Poolside"||E==="9router"||E==="ExpLabs"||E==="TokenHarbor"||E==="Infron"||E==="APInex"||E==="xKiro"?`
|
|
312
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available with ${E}`:""}${E==="NVIDIA"&&process.env.NVIDIA_BASE_URL?`
|
|
313
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Memory is not available`:""}${z}
|
|
314
|
-
\u2800\u2800`,isMeta:!0}]))}if(f){let S=f(n==="quotas"||n==="providerBudgets"?g:o);mo(S)}else c?(qt({...p,apiTier:et,quotas:g,imageSettings:p.imageSettings||Yo}),mo(null),c(g)):(qt({...p,apiTier:et,quotas:g,imageSettings:p.imageSettings||Yo}),mo(null),ie(Oo?.returnView||"settings"))}})),e.createElement(u,{paddingX:1,marginTop:1},e.createElement(i,{color:s.textMuted,dimColor:!0,italic:!0},"(Press Enter to confirm selection)")));case"stats":{let o=jn==="modelBreakdown"||jn==="dailyModelBreakdown",n=jn==="daily"||jn==="dailyModelBreakdown",h=n?Yn:dr,f=n?"TODAY's USAGE":"LAST 30 DAYS USAGE",c=n?"TODAY'S MODEL TOKEN BREAKDOWN":"30-DAY MODEL TOKEN BREAKDOWN",g="Wall Time:",p="Tokens Used:",S="Images Made:",E="Image Credits:",z="Code Changes:",Z="Tool Calls:",G=Math.max(4,(r?.rows||H?.rows||24)-15),Q=(se,ge,Ue,Je,N,pe=0,Te=!1)=>{let ve=r?.columns||H?.columns||80,Re=Math.min(125,ve-2),Ve=Math.max(20,Re-6),Mt=Math.max(5,Ve-pe-Ue.length-5),ht=ge;ht.length>Mt&&(ht=ht.substring(0,Mt-1)+"\u2026");let K=Math.max(2,Ve-pe-ht.length-Ue.length-2),ne=" "+".".repeat(K)+" ",Ee=" ".repeat(pe);return e.createElement(u,{key:se,width:Ve},e.createElement(i,{wrap:"truncate"},e.createElement(i,null,Ee),e.createElement(i,{color:Je,bold:Te},ht),e.createElement(i,{color:s.textMuted,dimColor:!0},ne),e.createElement(i,{color:N,bold:Te},Ue)))},te=se=>{let ge=Number(se)||0;return ge<=0?"":ge<.001?" [<$0.001]":` [$${ge.toFixed(ge<.01?4:3)}]`},q=se=>{let ge=Number(se)||0;return ge<=0?"":ge<.001?"<$0.001":`$${ge.toFixed(ge<.01?4:3)}`},je=[],Fe=h?.models;if(!Fe||Object.keys(Fe).length===0)je.push(e.createElement(u,{key:"empty",marginTop:1},e.createElement(i,{color:s.textMuted,italic:!0},"No model token usage recorded for ",n?"today":"the last 30 days",".")));else{let se=(mr||"").trim(),ge="",Ue="";if(se.includes(":")){let N=se.indexOf(":");ge=se.substring(0,N).trim().toLowerCase(),Ue=se.substring(N+1).trim().toLowerCase()}else ge=se.toLowerCase();let Je=Object.entries(Fe).sort(([N],[pe])=>N.localeCompare(pe,void 0,{sensitivity:"base"})).filter(([N,pe])=>ge&&!N.toLowerCase().includes(ge)?!1:Ue?Object.keys(pe).some(Te=>Te.toLowerCase().includes(Ue)):!0);Je.length===0?je.push(e.createElement(u,{key:"no-matches",marginTop:1},e.createElement(i,{color:s.textMuted,italic:!0},'No results found matching "',mr,'".'))):Je.forEach(([N,pe],Te)=>{let ve=Object.entries(pe).sort(([K],[ne])=>K.localeCompare(ne,void 0,{sensitivity:"base"})).filter(([K])=>!Ue||K.toLowerCase().includes(Ue));if(ve.length===0)return;let Re=ve.reduce((K,[,ne])=>K+(ne.tokens||0),0),Ve=ve.reduce((K,[ne,Ee])=>{if((Ee.cost||0)>0)return K+Ee.cost;let _e=yr(N,ne);if(!_e)return K;let Le=(Ee.tokens||0)-(Ee.candidateTokens||0),pt=Ee.cachedTokens||0,go=Math.max(0,Le-pt),Qt=Ee.candidateTokens||0,Kt=go/1e6*_e.IN+pt/1e6*_e.CR+Qt/1e6*_e.OUT;return K+Kt},0),Mt=h?.providerRequests&&h.providerRequests[N]||0;Te>0&&je.length>0&&je.push(e.createElement(u,{key:`space-prov-${N}`},e.createElement(i,null," ")));let ht=te(Ve);je.push(Q(`prov-${N}`,`${N}:`,`${Pt(Re)} (${Mt})${ht}`,s.primary,s.text,0,!0)),ve.forEach(([K,ne],Ee)=>{Ee>0&&je.push(e.createElement(u,{key:`space-mod-${N}-${K}`},e.createElement(i,null," ")));let _e=yr(N,K),Le=(ne.tokens||0)-(ne.candidateTokens||0),pt=ne.cachedTokens||0,go=Math.max(0,Le-pt),Qt=ne.candidateTokens||0,Kt=0,Io=0,kn=0;_e&&(Kt=go/1e6*_e.IN,Io=pt/1e6*_e.CR,kn=Qt/1e6*_e.OUT);let Zn=(ne.cost||0)>0?ne.cost:Kt+Io+kn,zo=te(Zn);je.push(Q(`mod-${N}-${K}`,`\xBB ${K}:`,`${Pt(ne.tokens||0)}${zo}`,s.secondary,s.text,2,!0));let wt=te(Kt),At=te(Io),Ut=te(kn);je.push(Q(`in-${N}-${K}`,"\xBB Input Tokens:",`${Pt(Le)}${wt}`,s.textMuted,s.text,5,!1)),pt>0&&je.push(Q(`cache-${N}-${K}`,"\xBB Cached:",`${Pt(pt)}${At}`,s.textMuted,s.text,7,!1)),je.push(Q(`out-${N}-${K}`,"\xBB Output Tokens:",`${Pt(Qt)}${Ut}`,s.textMuted,s.text,5,!1))})})}let ke=je.length,rt=Math.max(0,ke-G);ee.current=rt;let Ht=Math.min(gc,rt),at=je.slice(Ht,Ht+G);return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:3,paddingY:1,paddingBottom:0,width:Math.min(125,(r?.columns||100)-2)},o?e.createElement(u,{flexDirection:"column"},e.createElement(u,{justifyContent:"space-between"},e.createElement(i,{color:s.text,bold:!0,underline:!0},c),ke>G&&e.createElement(i,{color:s.textMuted,dimColor:!0},"[",Ht+1,"-",Math.min(ke,Ht+G)," of ",ke,"] \u25B2\u25BC")),e.createElement(u,{marginTop:1},e.createElement(i,{color:s.secondary,bold:!0},"Filter (provider:model): "),e.createElement(i,{color:s.text},mr),e.createElement(i,{color:s.primary,bold:!0},"\u258A"),mr.length>0&&e.createElement(i,{color:s.textMuted,dimColor:!0,italic:!0}," (Type to search, Esc/Backspace to clear)")),e.createElement(u,{flexDirection:"column",height:G,marginTop:1},at)):e.createElement(e.Fragment,null,e.createElement(u,{marginBottom:1},e.createElement(i,{color:s.text,bold:!0,underline:!0},"SESSION TELEMETRY")),e.createElement(u,{flexDirection:"column"},e.createElement(u,null,e.createElement(u,{width:25},e.createElement(i,{color:s.secondary},"Session Duration:")),e.createElement(i,{color:s.text},En(Date.now()-Di))),Ni>0&&e.createElement(e.Fragment,null,e.createElement(u,null,e.createElement(u,{width:25},e.createElement(i,{color:s.secondary},"Model Requests:")),e.createElement(i,{color:s.text},Ni)),e.createElement(u,{marginLeft:2},e.createElement(u,{width:23},e.createElement(i,{color:s.textMuted},"\xBB API Time:")),e.createElement(i,{color:s.text},En(Kr))),e.createElement(u,{marginLeft:2},e.createElement(u,{width:23},e.createElement(i,{color:s.textMuted},"\xBB Tool Time:")),e.createElement(i,{color:s.text},En(Vr)))),$i>0&&e.createElement(u,null,e.createElement(u,{width:25},e.createElement(i,{color:s.secondary},"Memory Agent:")),e.createElement(i,{color:s.text},$i)),fo>0&&e.createElement(e.Fragment,null,e.createElement(u,null,e.createElement(u,{width:25},e.createElement(i,{color:s.secondary},"Tokens Consumed:")),e.createElement(i,{color:s.text},Pt(fo))),(Dt?.cost||0)>0&&e.createElement(u,{marginLeft:2},e.createElement(u,{width:23},e.createElement(i,{color:s.textMuted},"\xBB Cost Estimate:")),e.createElement(i,{color:s.success||"green"},q(Dt.cost))),e.createElement(u,{marginLeft:2},e.createElement(u,{width:23},e.createElement(i,{color:s.textMuted},"\xBB Input Tokens:")),e.createElement(i,{color:s.text},Pt(fo-Vn))),Bo>0&&e.createElement(u,{marginLeft:4},e.createElement(u,{width:21},e.createElement(i,{color:s.textMuted},"\xBB Cached:")),e.createElement(i,{color:s.text},Pt(Bo))),Vn>0&&e.createElement(u,{marginLeft:2},e.createElement(u,{width:23},e.createElement(i,{color:s.textMuted},"\xBB Output Tokens:")),e.createElement(i,{color:s.text},Pt(Vn)))),No?.tokens>0&&e.createElement(u,null,e.createElement(u,{width:25},e.createElement(i,{color:s.secondary},"Active Context:")),e.createElement(i,{color:s.text},Pt(No.tokens)," ",(()=>{let ge={"16k":16e3,"32k":32e3,"64k":64e3,"128k":128e3,"256k":256e3,"512k":512e3,"1M":1e6}[re?.contextLength]||256e3,Ue=process.env.HIGH_CONTEXT,Je=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1;if(Ue&&Ue!=="false"){let Te=parseInt(Ue,10);!isNaN(Te)&&Te>=0&&Te<=1e6&&(ge=Te)}($==="NVIDIA"&&(qe?.includes("gpt")||qe?.includes("qwen")||qe?.includes("medium")||qe.includes("muse"))||$==="Mistral")&&(ge=126e3),$==="Google"&&qe?.includes("gemma")&&Je&&(ge=16e3);let N=No.tokens/ge*100,pe=N<60?s.text:N<80?s.warning:s.danger;return e.createElement(i,{color:pe,dimColor:!0},"(",N.toFixed(0),"%)")})())),Yr>0&&e.createElement(e.Fragment,null,e.createElement(u,null,e.createElement(u,{width:25},e.createElement(i,{color:s.secondary},"Images Made:")),e.createElement(i,{color:s.text},Yr)),e.createElement(u,null,e.createElement(u,{width:25},e.createElement(i,{color:s.secondary},"Image Credits:")),e.createElement(i,{color:s.text},Number(((Xi||0)*1e3).toFixed(0))," credits"))),e.createElement(u,null,e.createElement(u,{width:25},e.createElement(i,{color:s.secondary},"Code Changes (Sess):")),e.createElement(i,{color:s.text},e.createElement(i,{color:s.success||"green"},"+",Dt.linesAdded)," ",e.createElement(i,{color:s.danger||"red"},"-",Dt.linesRemoved))),e.createElement(u,null,e.createElement(u,{width:25},e.createElement(i,{color:s.secondary},"Tool Calls (Sess):")),e.createElement(i,{color:s.text},Dt.toolSuccess+Dt.toolFailure+Dt.toolDenied," ( "),e.createElement(i,{color:s.success||"green"},"\u2714 ",Dt.toolSuccess),e.createElement(i,{color:s.text}," "),e.createElement(i,{color:s.warning||"yellow"},"\u{1F6C7} ",Dt.toolDenied),e.createElement(i,{color:s.text}," "),e.createElement(i,{color:s.danger||"red"},"\u2718 ",Dt.toolFailure),e.createElement(i,{color:s.text}," )"))),e.createElement(u,{flexDirection:"column",marginTop:1},e.createElement(i,{color:s.text,bold:!0,underline:!0},f),e.createElement(u,{marginTop:1},e.createElement(u,{width:25},e.createElement(i,{color:s.secondary},g)),e.createElement(i,{color:s.text},Ji(h?.duration||0))),(h?.agent||0)>0&&e.createElement(u,null,e.createElement(u,{width:25},e.createElement(i,{color:s.secondary},"Model Requests:")),e.createElement(i,{color:s.text},h?.agent||0)),(h?.background||0)>0&&e.createElement(u,null,e.createElement(u,{width:25},e.createElement(i,{color:s.secondary},"Memory Agent:")),e.createElement(i,{color:s.text},h?.background||0)),(h?.tokens||0)>0&&e.createElement(e.Fragment,null,e.createElement(u,null,e.createElement(u,{width:25},e.createElement(i,{color:s.secondary},p)),e.createElement(i,{color:s.text},Pt(h?.tokens||0))),(h?.cost||0)>0&&e.createElement(u,{marginLeft:2},e.createElement(u,{width:23},e.createElement(i,{color:s.textMuted},"\xBB Cost Estimate:")),e.createElement(i,{color:s.success||"green"},q(h.cost))),e.createElement(u,{marginLeft:2},e.createElement(u,{width:23},e.createElement(i,{color:s.textMuted},"\xBB Input Tokens:")),e.createElement(i,{color:s.text},Pt((h?.tokens||0)-(h?.candidateTokens||0)))),(h?.cachedTokens||0)>0&&e.createElement(u,{marginLeft:4},e.createElement(u,{width:21},e.createElement(i,{color:s.textMuted},"\xBB Cached:")),e.createElement(i,{color:s.text},Pt(h.cachedTokens))),(h?.candidateTokens||0)>0&&e.createElement(u,{marginLeft:2},e.createElement(u,{width:23},e.createElement(i,{color:s.textMuted},"\xBB Output Tokens:")),e.createElement(i,{color:s.text},Pt(h.candidateTokens)))),(h?.imageCalls?.length||0)>0&&e.createElement(e.Fragment,null,e.createElement(u,null,e.createElement(u,{width:25},e.createElement(i,{color:s.secondary},S)),e.createElement(i,{color:s.text},h.imageCalls.length)),e.createElement(u,null,e.createElement(u,{width:25},e.createElement(i,{color:s.secondary},E)),e.createElement(i,{color:s.text},Number(((h.imageCalls.reduce((se,ge)=>se+ge.cost,0)||0)*1e3).toFixed(0))," credits"))),e.createElement(u,null,e.createElement(u,{width:25},e.createElement(i,{color:s.secondary},z)),e.createElement(i,{color:s.text},e.createElement(i,{color:s.success||"green"},"+",h?.linesAdded||0)," ",e.createElement(i,{color:s.danger||"red"},"-",h?.linesRemoved||0))),e.createElement(u,null,e.createElement(u,{width:25},e.createElement(i,{color:s.secondary},Z)),e.createElement(i,{color:s.text},(h?.toolSuccess||0)+(h?.toolFailure||0)+(h?.toolDenied||0)," ( "),e.createElement(i,{color:s.success||"green"},"\u2714 ",h?.toolSuccess||0),e.createElement(i,{color:s.text}," "),e.createElement(i,{color:s.warning||"yellow"},"\u{1F6C7} ",h?.toolDenied||0),e.createElement(i,{color:s.text}," "),e.createElement(i,{color:s.danger||"red"},"\u2718 ",h?.toolFailure||0),e.createElement(i,{color:s.text}," )")))),e.createElement(i,{color:s.textMuted,dimColor:!0,italic:!0},`
|
|
315
|
-
`,"(Press TAB to toggle Today/30-Day views, SPACE to toggle Model Breakdown, ESC to return)"))}case"dynamicDirDanger":return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:s.warning||"yellow",bold:!0,underline:!0},"DYNAMIC DIRECTORY AWARENESS"),e.createElement(i,{marginTop:1,color:s.text},"Enabling this keeps the agent aware of filesystem state in real time, but may reduce prompt cache efficiency."),e.createElement(i,{color:s.text},`
|
|
316
|
-
`,"RECOMMENDED SCENARIOS TO TURN ON:"),e.createElement(i,{color:s.textMuted},"\u2022 Repo is small."),e.createElement(i,{color:s.textMuted},"\u2022 The task benefits from real-time filesystem awareness."),e.createElement(i,{color:s.textMuted},"\u2022 Files are often created, renamed, or deleted."),e.createElement(i,{color:s.textMuted},"\u2022 You know exactly what you're signing up for."),e.createElement(i,{color:s.textMuted},"\u2022 You don't have conflicting decisions regarding token bills."),e.createElement(i,{color:s.textMuted},"\u2022 You want to see your wallet crying at 3am."),e.createElement(u,{marginTop:1},e.createElement(_t,{title:"Confirm Intent",theme:re.theme,items:[{label:"Turn On Dynamic Directory Awareness",value:"on"},{label:"Keep Off (Recommended)",value:"off"}],onSelect:o=>{o.value==="on"&&Ft(n=>{let h={...n,dynamicDirAwareness:!0};return qt({systemSettings:h,apiTier:et,quotas:Ie}),h}),ie("settings")}})));case"dynamicDirHelp":return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:s.text,bold:!0,underline:!0},"DYNAMIC DIRECTORY AWARENESS \u2014 HELP & EXPLANATION"),e.createElement(i,{color:s.text,bold:!0},`
|
|
317
|
-
`,"OFF (Default):"),e.createElement(i,{color:s.textMuted},"\u2022 Takes a static directory snapshot at conversation/session start and places it in System Context."),e.createElement(i,{color:s.textMuted},"\u2022 Prompt cache remains stable across user turns, saving tokens and money."),e.createElement(i,{color:s.text,bold:!0},`
|
|
318
|
-
`,"ON:"),e.createElement(i,{color:s.textMuted},"\u2022 Rescans and updates the directory's state dynamically on every single user turn."),e.createElement(i,{color:s.textMuted},"\u2022 Provides real-time filesystem awareness if files are continuously created, renamed, or removed."),e.createElement(i,{color:s.textMuted},"\u2022 Changes Prompt Context on each turn, invalidating part of prompt caches and increasing token usage."),e.createElement(u,{marginTop:1},e.createElement(_t,{title:"Actions",theme:re.theme,items:[{label:"Back to Settings",value:"back"}],onSelect:()=>ie("settings")})));case"autoExecDanger":return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:s.warning||"yellow",bold:!0,underline:!0},"SECURITY WARNING: YOLO MODE"),e.createElement(i,{marginTop:1,color:s.text},"Turning this ON allows the agent to execute terminal commands automatically without requiring your approval for each step."),e.createElement(i,{marginTop:1,color:s.text,bold:!0},"RISKS INVOLVED:"),e.createElement(i,{color:s.textMuted},"\u2022 The agent may execute destructive commands (rm -rf, etc.) by mistake unless specified in sandbox rules."),e.createElement(i,{color:s.textMuted},"\u2022 Unintended system changes if the agent hallucinates a path or command."),e.createElement(i,{color:s.textMuted},"\u2022 Reduced control over the agent's step-by-step decision making."),e.createElement(u,{marginTop:1},e.createElement(_t,{title:"Confirm Intent",theme:re.theme,items:[{label:"I know the risk and turning on intentionally",value:"on"},{label:"Keep Off (Recommended)",value:"off"}],onSelect:o=>{o.value==="on"&&Ft(n=>({...n,autoExec:!0})),ie("settings")}})));case"advanceRollbackDanger":return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:1,paddingTop:0,width:"100%"},e.createElement(i,{color:s.warning||"yellow",bold:!0},"\u26A0 Emergency Rollback Notice"),e.createElement(i,{marginTop:1,color:s.text},"When enabled, full repo snapshots exist only during active AI turns."),e.createElement(i,{marginTop:1,color:s.text},"If catastrophic changes occur during a turn, avoid abruptly stopping the agent unless absolutely necessary (external damages out of codebase)."),e.createElement(i,{color:s.textMuted},"The agent may be able to automatically restore the repo to a safe state."),e.createElement(i,{marginTop:1,color:s.textMuted},"Once the turn ends, emergency snapshots are deleted and standard /revert takes over which may not retain full repo content."),e.createElement(i,{marginTop:1,color:s.textMuted},"(Requires Restart to take effect)"),e.createElement(u,{marginTop:1},e.createElement(_t,{title:"Confirm",theme:re.theme,items:[{label:"I understand and wish to enable",value:"on"},{label:"Keep Off",value:"off"}],onSelect:o=>{o.value==="on"&&Ft(n=>({...n,advanceRollback:!0})),ie("settings")}})));case"externalDanger":return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:s.warning||"yellow",bold:!0,underline:!0},"SECURITY WARNING: EXTERNAL WORKSPACE ACCESS"),e.createElement(i,{marginTop:1,color:s.text},"Turning this ON allows the agent to execute tools (Read/Write/Exec) outside of the current active workspace directory."),e.createElement(i,{marginTop:1,color:s.text,bold:!0},"RISKS INVOLVED:"),e.createElement(i,{color:s.textMuted},"\u2022 Access to sensitive system files (SSH keys, Browser data, etc.)"),e.createElement(i,{color:s.textMuted},"\u2022 Potential for accidental or malicious deletion of OS-critical files."),e.createElement(i,{color:s.textMuted},"\u2022 Unauthorized script execution across your entire file system."),e.createElement(u,{marginTop:1},e.createElement(_t,{title:"Confirm Intent",theme:re.theme,items:[{label:"I know the risk and turning on intentionally",value:"on"},{label:"Keep Off (Recommended)",value:"off"}],onSelect:o=>{o.value==="on"&&Ft(n=>({...n,allowExternalAccess:!0})),ie("settings")}})));case"doubleDanger":return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:s.danger||"red",bold:!0,underline:!0},"CRITICAL SECURITY WARNING: COMBINED SYSTEM RISK"),e.createElement(i,{marginTop:1,color:s.text},"You are attempting to enable BOTH [YOLO Mode] and [External Workspace Access] simultaneously."),e.createElement(i,{marginTop:1,color:s.danger||"red",bold:!0},"THIS IS NOT RECOMMENDED."),e.createElement(i,{marginTop:1,color:s.text,bold:!0},"THE CRITICAL RISK:"),e.createElement(i,{color:s.textMuted},"The agent will have the power to execute any command across your entire system WITHOUT your approval or supervision."),e.createElement(i,{color:s.danger||"red",italic:!0,marginTop:1},"A single hallucination or error could result in full system wipe or data theft."),e.createElement(u,{marginTop:1},e.createElement(_t,{title:"Final Confirmation",theme:re.theme,items:[{label:"I agree knowing the consequences",value:"on"},{label:"Keep Off",value:"off"}],onSelect:o=>{o.value==="on"&&Ft(n=>({...n,autoExec:!0,allowExternalAccess:!0})),ie("settings")}})));case"key":case"deleteKey":return null;case"exit":return null;case"ask":return e.createElement(u,{width:"100%"},e.createElement(Ia,{question:Bn?.question,options:Bn?.options,onResolve:o=>{Bn?.resolve&&Bn.resolve(o),Ks(null),ie("chat")},theme:re.theme}));case"revert":return e.createElement(u,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(vi,{prompts:Mc,onSelect:async o=>{r&&(r.write("\x1B[2J\x1B[3J\x1B[H"),r.isTTY&&r.write("\x1B[?2004h"));try{let n=await Sr.rollbackToBefore(o);if(n.success){let{targetPrompt:h}=n;ma(gt),Js(S=>S+1),Qo(),xo.current={completedIndex:0,columns:H.columns,historicalBlocks:[],seenSelections:new Set,chatId:gt,clearKey:In+1};let f=$t.findLastIndex(S=>S.role==="user"&&S.text&&(S.text.startsWith(h)||S.text.includes(h))),c=[...$t];f!==-1&&(c=$t.slice(0,f)),L(c),F(c.length),w(h),V(h.split(`
|
|
319
|
-
`).length>2);let g=c.filter(S=>!String(S.id).startsWith("welcome")&&(!S.isMeta||S.text&&S.text.includes("Request Cancelled")));await On(gt,null,g);let p=yt(2);L(S=>{let E=[...S,{id:"revert-ok-"+Date.now(),role:"system",text:`\u2726 Rollback Successful
|
|
320
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Reverted prompt loaded to input box.
|
|
321
|
-
\u2800`,isMeta:!0}];return F(E.length),E}),ie("chat")}}catch(n){let h=yt(2);L(f=>{let c=[...f,{id:"revert-err-"+Date.now(),role:"system",text:`\u2726 ERROR
|
|
322
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${n.message}
|
|
323
|
-
\u2800`,isMeta:!0}];return F(c.length),c}),ie("chat")}},onClose:()=>ie("chat"),theme:re.theme}));case"resume":return e.createElement(u,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(yi,{onSelect:async o=>{let n=await Jo();if(n[o]){if(r.write("\x1B[2J\x1B[3J\x1B[H"),process.stdout.isTTY){let g=n[o]?.name||"",p=g&&!g.startsWith("flow-")&&!g.startsWith("Session ")?g:"FluxFlow | Resumed";process.stdout.write(`\x1B]0;${p}\x07`),process.stdout.write(`\x1B]633;P;TerminalTitle=${p}\x07`)}Qo(),jo.current=!0,qr(o);let h=await Br(o);Hn.current=fo-h.total,Xn.current=Bo,Kn.current=vn,to.current=[],_n(h.total),Wn(0),Sn(0),Gn(0),sn({tokens:h.context}),jo.current=!1;let f=[...n[o].messages];f[0]?.text?.includes("\u2591\u2591\u2591\u2588\u2588\u2588")||f.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),L(f),ie("chat"),L(g=>{let p=[...g,{id:"sys-"+Date.now(),role:"system",text:`\u2726 SESSION RESUMED
|
|
324
|
-
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${o}
|
|
325
|
-
\u2800`,isMeta:!0}];return F(p.length),p})}},onDelete:async o=>await is(o),onClose:()=>ie("chat"),theme:re.theme}));case"keybindingsPrompt":return e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:"grey",paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:"white",bold:!0,underline:!0},"CONFIGURE SHIFT+ENTER NEWLINE"),e.createElement(i,null,`
|
|
326
|
-
`,"To support multi-line inputs with ",e.createElement(i,{bold:!0,color:"white"},"Shift + Enter")," for newline, a terminal sequence keybinding needs to be added to your IDE configuration.",`
|
|
327
|
-
|
|
328
|
-
`,"Would you like FluxFlow to automatically add this to your ",bn()," keybindings?"),e.createElement(u,{marginTop:1},e.createElement(_t,{title:"Add Keybinding?",items:[{label:"Yes, configure automatically",value:"yes"},{label:"No, skip",value:"no"}],onSelect:async o=>{o.value==="yes"?await vs(bn()):Ms="\\ + Enter",ie("chat")},theme:re.theme})));case"memory":return e.createElement(u,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(Mi,{onClose:()=>ie("chat"),theme:re.theme}));case"parserDownload":return e.createElement(u,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(Si,{onClose:()=>ie("settings")}));case"resolution":return e.createElement(u,{width:"100%",alignItems:"center",justifyContent:"center"},e.createElement(bu,{data:Sc,theme:re.theme,onResolve:o=>{Qs(null),ie("chat"),setTimeout(()=>{ml(o,!0)},500)},onEdit:o=>{Qs(null),ie("chat"),w(o)}}));case"approval":let x=!!Zt?.isOverwrite,a=mn(Zt?.args||"{}"),B=a.path||a.targetPath||a.file||"";return x?e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:"white",bold:!0,underline:!0},"OVERWRITE PROTECTION"),e.createElement(i,{marginTop:1},"Agent wants to rewrite ",e.createElement(i,{color:"cyan",bold:!0},B||"file"),". This will overwrite the existing file content completely."),e.createElement(u,{marginTop:1},e.createElement(_t,{title:"Action Required",items:[{label:"Accept",value:"allow"},{label:"Deny",value:"deny"}],onSelect:o=>{let n=o.value==="deny"?"deny":"allow";Zt.resolve(n),ln(null),ie("chat")},theme:re.theme}))):e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:"white",paddingX:2,paddingY:1,width:"100%"},e.createElement(i,{color:"white",bold:!0,underline:!0},Zt?.tool==="view_file"?"FILE READ PERMISSION":"FILE WRITE PERMISSION"),e.createElement(i,{marginTop:1},"The agent is attempting to ",Zt?.tool==="view_file"?"read":"modify",": ",e.createElement(i,{color:"cyan"},mn(Zt?.args||"{}").path||"Unknown File")),Zt?.tool==="view_file"?null:Pn()?e.createElement(u,{marginTop:1,paddingX:1},e.createElement(i,{color:"cyan",italic:!0},"FluxFlow Companion is active. Review the changes in your editor.")):e.createElement(u,{marginTop:1,borderStyle:"single",borderColor:"#333",paddingX:1,flexDirection:"column"},e.createElement(i,{color:"gray"},"--- PROPOSED CONTENT ---"),(()=>{let o=mn(Zt?.args||"{}"),n=[],h=new Set;if(Object.keys(o).forEach(g=>{let p=g.match(/^(searchContent|replaceContent|newContent|content_to_replace|content_to_add|TargetContent|ReplacementContent|replacementContent)(\d+)?$/);if(p){let S=p[2]?parseInt(p[2]):1;h.add(S)}}),Array.from(h).sort((g,p)=>g-p).forEach(g=>{let p,S;g===1?(p=o.searchContent1??o.searchContent??o.replaceContent1??o.content_to_replace1??o.replaceContent??o.content_to_replace??o.TargetContent??null,S=o.newContent1??o.content_to_add1??o.newContent??o.content_to_add??o.ReplacementContent??o.replacementContent??null):(p=o[`searchContent${g}`]??o[`replaceContent${g}`]??o[`content_to_replace${g}`]??null,S=o[`newContent${g}`]??o[`content_to_add${g}`]??null),(p!==null||S!==null)&&n.push({replace:p,new:S})}),n.length>0)return e.createElement(u,{flexDirection:"column",marginTop:1},n.map((g,p)=>{let S=g.replace!==null,E=g.new!==null;return e.createElement(u,{key:p,flexDirection:"column",marginTop:p>0?1:0},n.length>1&&e.createElement(i,{color:"gray"},"Block ",p+1,":"),S&&e.createElement(u,null,e.createElement(i,{color:"red",wrap:"anywhere",bold:!0},"- ",g.replace)),E&&e.createElement(u,{marginTop:0},e.createElement(i,{color:"green",wrap:"anywhere",bold:!0},"+ ",g.new.replace(/\[\/n\]?/g,"\\n"))))}));let c=o.content||o.ReplacementContent||o.content_to_add||o.replacementContent||o.newContent||null;return e.createElement(i,{color:"white",wrap:"anywhere"},(c?c.replace(/\[\/n\]?/g,"\\n"):null)||"Updating file content...")})()),e.createElement(u,{marginTop:1},(()=>{let o=Zt?.tool,n=mn(Zt?.args||"{}"),h=n.path||n.targetPath||n.file||"",f=h?Ct.extname(h).toLowerCase():"",c=h?Ct.basename(h):"this file",g="Accept for this session";return o==="write_file"&&f?g=`Accept for this session (*${f})`:o==="update_file"&&c&&(g=`Accept for this session (${c})`),e.createElement(_t,{title:"Action Required",items:[{label:"Accept this time",value:"allow"},...o==="view_file"?[]:[{label:g,value:"always"}],{label:"Don't accept",value:"deny"}],onSelect:p=>{p.value==="always"&&(o==="write_file"?f?Gs.current.add(f):Xs(!0):o==="update_file"&&h?zi.current.add(Ct.resolve(h).toLowerCase()):Xs(!0));let S=p.value==="deny"?"deny":"allow";Zt.resolve(S),ln(null),ie("chat")},theme:re.theme})})()));case"mode":return e.createElement(_t,{title:"SELECT EXECUTION MODE",items:[{label:`Flux (Dev Toolset Mode) ${Y==="Flux"?"\u25CF":""}`,value:"Flux"},{label:`Flow (Chat / Conversation Mode) ${Y==="Flow"?"\u25CF":""}`,value:"Flow"},{label:`ICU (Interactive Computer Use) ${Y==="ICU"?"\u25CF":""}`,value:"ICU"},{label:`FluxCU (Autonomous Flux Computer Use) ${Y==="FluxCU"?"\u25CF":""}`,value:"FluxCU"},{label:"Back",value:"chat"}],theme:re.theme,onSelect:o=>{if(o.value==="chat"||o.value==="Back"){ie("chat");return}let n=o.value;ue(n),L(h=>(F(h.length+1),[...h,{id:Date.now(),role:"system",text:`\u2726 Mode switched to ${Ei(n)}
|
|
329
|
-
\u2800`,isMeta:!0}])),ie("chat")},onClose:()=>ie("chat")});case"display":return e.createElement(_t,{title:"SELECT ACTIVE DISPLAY FOR COMPUTER USE",items:[{label:`Primary Display (Display 1) ${me===0?"\u25CF":""}`,value:0},{label:`Secondary Display (Display 2) ${me===1?"\u25CF":""}`,value:1},{label:"Back",value:"chat"}],theme:re.theme,onSelect:o=>{if(o.value==="chat"||o.value==="Back"){ie("chat");return}let n=Number(o.value);le(n),qt({display:n}).catch(()=>{});let h=n===0?"Primary (Display 1)":"Secondary (Display 2)";L(f=>(F(f.length+1),[...f,{id:Date.now(),role:"system",text:`\u2726 Active Computer Use display set to: ${h}`,isMeta:!0}])),ie("chat")},onClose:()=>ie("chat")});case"updateManager":return e.createElement(_t,{title:"Select Preferred Update Manager",subtitle:"NOTE: If you are unsure about these, go with NPM",items:[{label:"NPM (Standard)",value:"npm"},{label:"PNPM (Recommended)",value:"pnpm"},{label:"BUN (Ultra Fast)",value:"bun"},{label:"YARN (Classic)",value:"yarn"},{label:"Custom Command",value:"custom"},{label:"Back",value:"settings"}],onSelect:o=>{if(o.value==="settings"||o.value==="Back"){ie("settings");return}o.value==="custom"?(mo({label:"Enter Custom Update Command (Global install recommended):",key:"customUpdateCommand",value:re.customUpdateCommand,next:n=>(Ft(h=>({...h,updateManager:"custom",customUpdateCommand:n})),null)}),ie("input")):(Ft(n=>({...n,updateManager:o.value})),ie("settings"))},theme:re.theme});case"update":return e.createElement(Ua,{latest:wn,current:So,settings:re,theme:re.theme,onClose:()=>ie("chat"),onSuccess:()=>{L(o=>(F(o.length+1),[...o,{id:"update-success-"+Date.now(),role:"system",text:`**[UPDATE COMPLETED]** Flux Flow successfully updated to v${wn}.
|
|
330
|
-
**Restart to see changes.**`,isMeta:!0}])),ie("chat")},onUpdateSettings:o=>{ie("updateManager")}});case"terminalApproval":return e.createElement(u,{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(u,{marginTop:1},e.createElement(i,null,"Agent requested to run: ",e.createElement(i,{color:"yellow",bold:!0},mn(Zt?.args||"{}").command||"Unknown Command"))),e.createElement(u,{marginTop:1},(()=>{let n=(mn(Zt?.args||"{}").command||"").trim();return e.createElement(_t,{title:"Risk Assessment Required",items:[{label:"Run",value:"allow"},{label:"Accept for this session",value:"always"},{label:"Deny",value:"deny"}],onSelect:h=>{h.value==="always"&&n&&Qi.current.add(n);let f=h.value==="deny"?"deny":"allow";Zt.resolve(f),ln(null),ie("chat")},theme:re.theme})})()));default:return e.createElement(u,{flexDirection:"column",marginTop:1,flexShrink:0,width:"100%"},sl&&rl&&e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:1,width:"100%",marginBottom:1},e.createElement(u,{justifyContent:"space-between",width:"100%"},e.createElement(i,{color:s.text,bold:!0,underline:!0},"INQUIRY RESPONSE"),e.createElement(i,{color:s.textMuted},"[ ESC to Close ]")),e.createElement(u,{marginTop:1,width:"100%"},e.createElement(ds,{text:rl,columns:H.columns-6,theme:re.theme}))),Os.filter(o=>o.status==="running").length>0&&e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:0,width:"100%",marginBottom:1},e.createElement(u,{justifyContent:"space-between",width:"100%"},e.createElement(i,{color:s.text,bold:!0},"ACTIVE SUBAGENTS")),e.createElement(u,{flexDirection:"column",marginTop:1,width:"100%"},Os.filter(o=>o.status==="running").map(o=>e.createElement(yu,{key:o.id,sa:o,showTPMEstimate:re.showTPMEstimate})))),wr&&e.createElement(u,{flexDirection:"column",borderStyle:"round",borderColor:s.borderMuted,paddingX:2,paddingY:0,width:"100%",marginBottom:0},e.createElement(u,{justifyContent:"space-between",width:"100%"},e.createElement(u,{flexDirection:"row",gap:1},e.createElement(i,{color:s.warning||"yellow",bold:!0},"\u2726 ",wr.startsWith("/btw")?"Question Queued":"Steering Hint Queued"))),e.createElement(u,{marginTop:0,paddingLeft:2},e.createElement(i,{color:s.text,bold:!0},"\u2514\u2500 ",wr.startsWith("/btw")?wr.replace(/^\/btw\s*/,""):wr))),e.createElement(u,{paddingX:1,marginBottom:0,justifyContent:"space-between",width:"100%"},e.createElement(u,null,an?e.createElement(u,{gap:1},e.createElement(cu,null),e.createElement(Fr,{text:an.trim().length>40&&!an.toLowerCase().includes("trying")?`${an.trim().slice(0,40)}...`:an.trim(),baseColor:s.textExclusive||s.text,glintColor:s.textMutedExclusive||s.textMuted,speed:60,italic:!0,glintWidth:2,typeSpeed:10}),e.createElement(i,{color:s.textMuted},Ri>0?`(${Ri.toFixed(0)}s)`:"")):e.createElement(i,{color:s.textMuted,italic:!0},C.length>0&&ol?"Press ESC again to clear input":bc?"Press CTRL + O to expand":process.env.HALLOWEEN_EEGG==="true"?"Listening for shadows...":"Waiting for input...")),e.createElement(u,null,(()=>{let o=an?.toLowerCase()??"";return Jn&&Date.now()-Pi>15e3&&Os.length===0&&(o.includes("connecting")||o.includes("consulting")||o.includes("working")||o.includes("haunting")||o.includes("queue"))?e.createElement(u,null,e.createElement(Fr,{text:"Waiting for API Response",baseColor:s.text,glintColor:s.textMuted,glintWidth:4,speed:100}),e.createElement(i,{color:s.textMuted,dimColor:!0}," \u2503 ")):Ys?e.createElement(u,null,e.createElement(Fr,{text:Ys,baseColor:s.text,glintColor:s.textMuted,italic:!0,speed:85,typeSpeed:15}),e.createElement(i,{color:s.textMuted,dimColor:!0}," \u2503 ")):null})(),e.createElement(Fr,{text:Ct.basename(qe)||(qe.length>1?qe:"Use '/model model-id' to select model"),baseColor:s.text,glintColor:s.textMuted,glintWidth:3,speed:80}),e.createElement(i,{color:s.textMuted},qe.length>0?Ke.toLocaleLowerCase().includes("xhigh")?"":` (${Ke})`:""),ss>0&&e.createElement(i,{color:s.textMuted}," [",ss," ",ss===1?"file":"files","]"))),e.createElement(u,{flexDirection:"column",width:"100%"},e.createElement(u,{width:"100%",height:1,overflow:"hidden"},e.createElement(i,{color:s.inputBorder},"\u2500".repeat(Math.max(1,H.columns)))),e.createElement(u,{paddingX:1,paddingY:0,width:"100%",flexDirection:"column"},e.createElement(u,{flexDirection:"column",width:"100%"},e.createElement(u,{flexDirection:"row",width:"100%",paddingY:0},e.createElement(u,{flexShrink:0,width:4},e.createElement(i,{color:s.inputPrompt,bold:!0},Jn||pr?"\u2726 ":" \u276F ")),e.createElement(u,{flexGrow:1},e.createElement(u,{flexGrow:1,position:"relative"},C===""&&e.createElement(u,{position:"absolute",paddingLeft:0},Do&&!xr?e.createElement(i,{color:"yellow"},Dc?" Terminal is waiting for user input. Press TAB to interact":" Press TAB to interact with terminal..."):Do&&xr?e.createElement(i,{color:"yellow",bold:!0}," [ TERMINAL FOCUSED ] Type to interact, press TAB to exit..."):ol===1?e.createElement(i,{color:s.inputPrompt,bold:!0}," Press ESC again to ",C.length>0?"clear input":"revert codebase to checkpoint","..."):e.createElement(i,{color:s.inputPlaceholder},yc?" Press ESC again to cancel the request.":pr?" Compacting session history, please wait...":Jn?" Enter a prompt to steer the agent.":$t.filter(o=>o.role==="user").length===0?` Send message, @file or /cmd (${pc.shortcut} for newline)`:" Ask Follow-ups")),e.createElement(ga,{key:`input-${M}`,onPasteStateChange:wc,focus:!xr&&!pr,showCursor:lt&&!pr,cursorColor:s.inputText,lastFocusEventTime:uo.current,value:C,textStyle:{bold:!0,color:s.inputText},columns:H.columns,onChange:o=>{let n=o.replace(/\r\n/g,`
|
|
331
|
-
`).replace(/\r/g,`
|
|
332
|
-
`).replace(/\\\s*\n/g,`
|
|
333
|
-
`);w(n),Se(!1),X.current!==null&&n===X.current?X.current=null:D!==-1&&P(-1)},historyEnabled:vt==="chat"&&!pr&&(st.length===0||D!==-1),isBrowsingHistory:D!==-1,onHistoryPrev:()=>{let o=U.current;if(o.length!==0){if(D===-1){W.current=C;let n=o.length-1;X.current=o[n],P(n),w(o[n]),O(h=>h+1)}else if(D>0){let n=D-1;X.current=o[n],P(n),w(o[n]),O(h=>h+1)}}},onHistoryNext:()=>{let o=U.current;if(D!==-1)if(D<o.length-1){let n=D+1;X.current=o[n],P(n),w(o[n]),O(h=>h+1)}else{let n=W.current||"";X.current=n,P(-1),w(n),O(h=>h+1)}},onSubmit:ml,rows:1,maxRows:10,keyBindings:{submit:o=>o.return&&!o.shift&&!o.ctrl,newline:o=>o.return&&o.shift||o.return&&o.ctrl}})))))),e.createElement(u,{width:"100%",height:1,overflow:"hidden"},e.createElement(i,{color:s.inputBorder},"\u2500".repeat(Math.max(1,H.columns))))))}};return e.createElement(u,{flexDirection:"column",width:"100%"},Ae?null:St?e.createElement(gu,{width:r?.columns||80,height:r?.rows||24,aiProvider:$,theme:re.theme,reason:St}):xe?e.createElement(xu,{width:r?.columns||80,height:r?.rows||24,selectedIndex:Pe,aiProvider:$,theme:re.theme}):e.createElement(e.Fragment,null,e.createElement(u,{paddingX:1,flexDirection:"column",width:"100%"},e.createElement(au,{key:`static-${In}-${gt}-${H.columns}-${re.theme}`,items:cl.completed},x=>e.createElement(ms,{key:x.key,block:x,columns:(r?.columns||80)-2,showFullThinking:Tn,aiProvider:$,version:So,theme:re.theme}))),e.createElement(u,{flexDirection:"column",paddingX:1,paddingBottom:0,width:"100%"},(vt==="chat"||["ask","approval","terminalApproval"].includes(vt))&&e.createElement(u,{flexDirection:"column",width:"100%"},cl.active.map(x=>e.createElement(ms,{key:x.key,block:x,columns:Math.max(20,(r?.columns||80)-2),showFullThinking:Tn,aiProvider:$,version:So,theme:re.theme})),Do&&e.createElement(u,{marginTop:1},e.createElement(cs,{command:Do,output:zn,isFocused:xr,isPty:Rn,terminalHeight:H.rows,columns:H.columns}))),Ae?e.createElement(u,{borderStyle:"double",borderColor:"grey",padding:1,flexShrink:0},e.createElement(i,{color:"white"},"Starting Flux Flow...")):!Ye&&!($==="c_openai"&&re.customOpenAIBaseUrl)?e.createElement(u,{borderStyle:"round",borderColor:"white",padding:0,flexDirection:"column",flexShrink:0,width:"100%"},e.createElement(u,{paddingX:1,marginBottom:1},e.createElement(i,{color:"gray",bold:!0},$==="c_openai"?"CUSTOM BASE URL REQUIRED":"API KEY REQUIRED")),e.createElement(u,{paddingX:1,flexDirection:"column"},ir===0?e.createElement(e.Fragment,null,e.createElement(i,{color:"white"},"Select your Preferred Provider:"),e.createElement(u,{marginTop:1},e.createElement(_t,{searchable:!0,items:[{label:"Google",value:"Google"},{label:"Nvidia",value:"NVIDIA"},{label:"DeepSeek",value:"DeepSeek"},{label:"InferX",value:"InferX"},{label:"SenseNova",value:"SenseNova"},{label:"Poolside",value:"Poolside"},{label:"Experiential Labs",value:"ExpLabs"},{label:"Token Harbor",value:"TokenHarbor"},{label:"Infron",value:"Infron"},{label:"APInex",value:"APInex"},{label:"xKiro",value:"xKiro"},{label:"Ollama",value:"Ollama"},...process.env.ENABLE_9ROUTER==="true"||process.env.ENABLE_9ROUTER===!0?[{label:"9router [Local Proxy]",value:"9router"}]:[],{label:"AIHubMix [Experimental]",value:"AIHubMix"},{label:"Mistral [Experimental]",value:"Mistral"},{label:"OpenRouter [Experimental]",value:"OpenRouter"},{label:"Custom [OpenAI Chat Completion]",value:"c_openai"}],onSelect:x=>{nn(x.value),$r(1)}}))):e.createElement(e.Fragment,null,e.createElement(i,{color:"white"},$==="Ollama"?"Enter Ollama API Key (or type LOCAL to use local host):":$==="c_openai"?"Enter Custom OpenAI Base URL (.../v1):":`Enter your ${$} API Key:`),e.createElement(u,{marginTop:1},e.createElement(i,{color:"gray",bold:!0}," ",">"," "),e.createElement(rr,{value:yn,onChange:Cn,onSubmit:dl,mask:$==="c_openai"?void 0:"*"})))),e.createElement(u,{paddingX:1,marginTop:1},e.createElement(i,{color:"gray",italic:!0},ir===0?"(Use arrows to select and Enter to confirm, ESC to go back)":"(Press Enter to confirm and initialize, ESC to go back)"))):Ic(),d&&e.createElement(u,{borderStyle:"round",borderColor:s.borderMuted,paddingX:1,marginY:0,width:"100%"},e.createElement(i,null,e.createElement(i,{color:"red",bold:!0},"\u{1F534} EXIT: "),e.createElement(i,{color:s.text},"Press "),e.createElement(i,{color:s.text,bold:!0},"CTRL+C"),e.createElement(i,{color:s.text}," again to exit (",y,"s) \u2022 Press "),e.createElement(i,{color:s.textMuted,bold:!0},"ESC"),e.createElement(i,{color:s.text}," to cancel"))),st.length>0&&(()=>{let a=we.current,B=0;for(;B<st.length;){let E=st[B],z=E?.cmd||E||"";if(typeof z=="string"&&z.trimStart().startsWith("---"))B++;else break}Oe<=B?a=0:Oe<a?a=Oe:Oe>=a+5&&(a=Oe-5+1),a=Math.max(0,Math.min(a,Math.max(0,st.length-5))),we.current=a;let o=st.slice(a,a+5),n=st.length-(a+o.length),h=st[0]?.cmd?.startsWith("@")||st[0]?.cmd?.startsWith("\\@"),f=C.startsWith("/model"),c=C.startsWith("/kill"),g=C.startsWith("/thinking"),p=st.length,S=Math.min(p,Oe+1);return e.createElement(u,{flexDirection:"column",width:"100%",marginBottom:1,marginTop:0},e.createElement(u,{paddingX:1,marginBottom:0,justifyContent:"space-between",width:"100%"},e.createElement(u,{flexDirection:"row"},e.createElement(i,{color:s.primary||s.text,bold:!0},h?"WORKSPACE FILES":f?"SAVED MODELS":c?"ACTIVE PROCESSES":g?"THINKING LEVELS":"COMMANDS"),e.createElement(i,{color:s.textMuted}," (",p,")")),e.createElement(u,{flexDirection:"row"},h?e.createElement(i,{color:s.textMuted,italic:!0},"Use #Lstart-Lend for line range \u2022 Tab to select"):e.createElement(i,{color:s.textMuted,italic:!0},"\u2191/\u2193 navigate \u2022 Tab / Enter select \u2022 Esc dismiss"))),e.createElement(u,{width:"100%",height:1,overflow:"hidden"},e.createElement(i,{color:s.borderDim||s.inputBorder||s.textDim},"\u2500".repeat(Math.max(1,H.columns)))),o.slice(0,Jr).map((E,z)=>{let G=a+z===Oe,Q=typeof E.cmd=="string"&&E.cmd.trimStart().startsWith("---"),te=E.cmd===bo("Google","Free")&&et!=="Free",q=E.display||(E.cmd&&(E.cmd.startsWith("@[")||E.cmd.startsWith("\\@["))&&E.cmd.endsWith("]")?(()=>{let Fe=(E.cmd.startsWith("\\@[")?E.cmd.slice(3,-1):E.cmd.slice(2,-1)).split(/[\/\\]/);return Fe[Fe.length-1]})():!f&&!c&&E.cmd&&E.cmd.includes("/")?E.cmd.split("/").pop():E.cmd);if(f){let Fe=E.multimodal===!0||ts(E.cmd||E)?"Vision":"Text Only";return e.createElement(u,{key:E.cmd||z,flexDirection:"row",backgroundColor:G?s.highlightBg:void 0,paddingX:1,height:1,alignItems:"center",justifyContent:"space-between"},e.createElement(u,{flexDirection:"row",alignItems:"center",flexGrow:1,overflow:"hidden"},e.createElement(u,{width:3,flexShrink:0},e.createElement(i,{color:G?s.primary||s.text:s.textMuted,bold:G},G?"\u276F ":" ")),e.createElement(i,{color:Q?s.textDim:te?s.textMuted:G&&s.inputText||s.text,bold:G},q)),e.createElement(u,{flexShrink:0,marginLeft:2},e.createElement(i,{color:G?s.text:s.textMuted,italic:!G},Fe)))}return c&&E.rightDesc?e.createElement(u,{key:E.cmd||z,flexDirection:"row",backgroundColor:G?s.highlightBg:void 0,paddingX:1,height:1,alignItems:"center",justifyContent:"space-between"},e.createElement(u,{flexDirection:"row",alignItems:"center",flexGrow:1,overflow:"hidden"},e.createElement(u,{width:3,flexShrink:0},e.createElement(i,{color:G?s.primary||s.text:s.textMuted,bold:G},G?"\u276F ":" ")),e.createElement(i,{color:G&&s.inputText||s.text,bold:G},q)),e.createElement(u,{flexShrink:0,marginLeft:2},e.createElement(i,{color:G?s.text:s.textMuted,italic:!G},E.rightDesc))):e.createElement(u,{key:E.cmd||z,flexDirection:"row",backgroundColor:G?s.highlightBg:void 0,paddingX:1,height:1,alignItems:"center"},e.createElement(u,{width:3,flexShrink:0},e.createElement(i,{color:G?s.primary||s.text:s.textMuted,bold:G},G?"\u276F ":" ")),e.createElement(u,{width:26,flexShrink:0},e.createElement(i,{color:Q?s.textDim:te?s.textMuted:G&&s.inputText||s.text,bold:G},q)),e.createElement(u,{flexGrow:1,overflow:"hidden"},e.createElement(i,{color:G?s.text:s.textMuted,italic:!G},E.desc)))}),st.length>5&&e.createElement(u,{paddingX:1,height:1,justifyContent:"space-between",width:"100%"},e.createElement(i,{color:s.textMuted,dimColor:!0,italic:!0},n>0?`... ${n} more available`:"(End of list)"),e.createElement(i,{color:s.textMuted,dimColor:!0},`${S}/${p}`)))})(),e.createElement(u,{flexShrink:0,width:"100%"},e.createElement(va,{mode:Y,thinkingLevel:Ke,tokens:No.tokens,tokensTotal:rc,cachedTokens:sc,promptTokens:lc,chatCacheTokenLatest:ic,cacheCalculateMode:re.cacheCalculateMode||"Session",chatId:gt,isMemoryEnabled:re.memory,apiTier:et,aiProvider:$,activeModel:qe,isProcessing:Jn,lastChunkTime:Pi,theme:re.theme,wps:As.current.wps,showTPMEstimate:re.showTPMEstimate})),vt==="exit"&&(()=>{let x=Date.now()-Di,a=Dt.toolSuccess+Dt.toolFailure,B=a>0?(Dt.toolSuccess/a*100).toFixed(1):"0.0",o=Kr+Vr,n=o>0?(Kr/o*100).toFixed(1):"0.0",h=o>0?(Vr/o*100).toFixed(1):"0.0";return e.createElement(u,{flexDirection:"column",borderStyle:"round",paddingX:3,paddingY:1,borderColor:s.borderMuted,width:Math.min(100,(r?.columns||100)-2),marginTop:0,marginBottom:0},e.createElement(u,{marginBottom:1},e.createElement(i,{bold:!0},uu(s.logoGradient||["blue","purple"])("Agent powering down. Goodbye!"))),e.createElement(u,{flexDirection:"column"},e.createElement(i,{color:s.text,bold:!0,underline:!0},"Interaction Summary"),e.createElement(u,{marginTop:1},e.createElement(u,{width:20},e.createElement(i,{color:s.secondary},"Session ID:")),e.createElement(i,{color:s.text},gt)),e.createElement(u,null,e.createElement(u,{width:20},e.createElement(i,{color:s.secondary},"Tool Calls:")),e.createElement(i,{color:s.text},Dt.toolSuccess+Dt.toolFailure+Dt.toolDenied," ( ",e.createElement(i,{color:"green"},"\u2714 ",Dt.toolSuccess)," ",e.createElement(i,{color:"yellow"},"\u{1F6C7} ",Dt.toolDenied)," ",e.createElement(i,{color:"red"},"\u2718 ",Dt.toolFailure)," )")),e.createElement(u,null,e.createElement(u,{width:20},e.createElement(i,{color:s.secondary},"Success Rate:")),e.createElement(i,{color:s.text},B,"%")),e.createElement(u,null,e.createElement(u,{width:20},e.createElement(i,{color:s.secondary},"Code Changes:")),e.createElement(i,{color:s.text},e.createElement(i,{color:"green"},"+",Dt.linesAdded)," ",e.createElement(i,{color:"red"},"-",Dt.linesRemoved))),fo>0&&e.createElement(e.Fragment,null,e.createElement(u,null,e.createElement(u,{width:20},e.createElement(i,{color:s.secondary},"Tokens Consumed:")),e.createElement(i,{color:s.text},Pt(fo))),(Dt?.cost||0)>0&&e.createElement(u,{marginLeft:2},e.createElement(u,{width:18},e.createElement(i,{color:s.textMuted},"\xBB Cost Estimate:")),e.createElement(i,{color:s.success||"green"},(()=>{let f=Number(Dt.cost)||0;return f<=0?"":f<.001?"<$0.001":`$${f.toFixed(f<.01?4:3)}`})())),e.createElement(u,{marginLeft:2},e.createElement(u,{width:18},e.createElement(i,{color:s.textMuted},"\xBB Input Tokens:")),e.createElement(i,{color:s.text},Pt(fo-Vn))),Bo>0&&e.createElement(u,{marginLeft:4},e.createElement(u,{width:16},e.createElement(i,{color:s.textMuted},"\xBB Cached:")),e.createElement(i,{color:s.text},Pt(Bo))),Vn>0&&e.createElement(u,{marginLeft:2},e.createElement(u,{width:18},e.createElement(i,{color:s.textMuted},"\xBB Output Tokens:")),e.createElement(i,{color:s.text},Pt(Vn)))),Yr>0&&e.createElement(e.Fragment,null,e.createElement(u,null,e.createElement(u,{width:20},e.createElement(i,{color:s.secondary},"Images Made:")),e.createElement(i,{color:s.text},Yr)),e.createElement(u,null,e.createElement(u,{width:20},e.createElement(i,{color:s.secondary},"Image Credits:")),e.createElement(i,{color:s.text},Number(((Xi||0)*1e3).toFixed(0))," credits")))),e.createElement(u,{flexDirection:"column",marginTop:1},e.createElement(i,{color:s.text,bold:!0,underline:!0},"Performance"),e.createElement(u,{marginTop:1},e.createElement(u,{width:20},e.createElement(i,{color:s.secondary},"Wall Time:")),e.createElement(i,{color:s.text},En(x))),e.createElement(u,null,e.createElement(u,{width:20},e.createElement(i,{color:s.secondary},"Agent Active:")),e.createElement(i,{color:s.text},En(o))),e.createElement(u,{marginLeft:2},e.createElement(u,{width:18},e.createElement(i,{color:s.textMuted},"\xBB API Time:")),e.createElement(i,{color:s.text},En(Kr)," (",n,"%)")),e.createElement(u,{marginLeft:2},e.createElement(u,{width:18},e.createElement(i,{color:s.textMuted},"\xBB Tool Time:")),e.createElement(i,{color:s.text},En(Vr)," (",h,"%)"))))})())))}export{Bi as check9RouterReachable,Cu as default};
|