fluxflow-cli 5.0.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- import{A as r,B as s,C as t,D as u,E as v,k as b,l as c,m as d,n as e,o as f,p as g,q as h,r as i,s as j,t as k,u as l,v as m,w as n,x as o,y as p,z as q}from"./chunk-24LJKH4G.js";import"./chunk-HFTI3R3Q.js";import"./chunk-52STSLCN.js";import"./chunk-56EJGQU3.js";import"./chunk-4BLSASW6.js";import"./chunk-7SGZ66KT.js";import"./chunk-UIL6OCU4.js";import"./chunk-EXT42EJZ.js";import"./chunk-6EYQQ7GQ.js";import"./chunk-Y5JU726N.js";import"./chunk-QESQR5GB.js";import"./chunk-J4J3F6BT.js";import"./chunk-V36DXF56.js";import"./chunk-B4UKMX5E.js";import{l as a}from"./chunk-LQM3JK7N.js";import"./chunk-P5HBJA23.js";import"./chunk-26BQ45XP.js";export{c as RE_LEADING_THINK,b as convertChannelThinkTags,r as detectToolCalls,e as findGenuineThinkClose,t as generateSimpleContent,u as getAIStream,q as getActiveToolContext,j as getCleanGroupedLength,m as getGoogleClient,f as getLeadingThinkBlock,s as initAI,d as isInsideBacktick,a as isModelMultimodal,l as isTerminationSignaled,o as maskCodeSpans,p as maskExecutedTools,n as runJanitorTask,v as runSubagent,k as signalTermination,g as stripLeadingThinking,h as stripNakedXmlTags,i as stripTrailingFluffAfterTools};
1
+ import{A as r,B as s,C as t,D as u,E as v,k as b,l as c,m as d,n as e,o as f,p as g,q as h,r as i,s as j,t as k,u as l,v as m,w as n,x as o,y as p,z as q}from"./chunk-WS35FH7W.js";import"./chunk-HFTI3R3Q.js";import"./chunk-52STSLCN.js";import"./chunk-56EJGQU3.js";import"./chunk-4BLSASW6.js";import"./chunk-7SGZ66KT.js";import"./chunk-UIL6OCU4.js";import"./chunk-EXT42EJZ.js";import"./chunk-6EYQQ7GQ.js";import"./chunk-Y5JU726N.js";import"./chunk-QESQR5GB.js";import"./chunk-J4J3F6BT.js";import"./chunk-V36DXF56.js";import"./chunk-B4UKMX5E.js";import{l as a}from"./chunk-LQM3JK7N.js";import"./chunk-P5HBJA23.js";import"./chunk-26BQ45XP.js";export{c as RE_LEADING_THINK,b as convertChannelThinkTags,r as detectToolCalls,e as findGenuineThinkClose,t as generateSimpleContent,u as getAIStream,q as getActiveToolContext,j as getCleanGroupedLength,m as getGoogleClient,f as getLeadingThinkBlock,s as initAI,d as isInsideBacktick,a as isModelMultimodal,l as isTerminationSignaled,o as maskCodeSpans,p as maskExecutedTools,n as runJanitorTask,v as runSubagent,k as signalTermination,g as stripLeadingThinking,h as stripNakedXmlTags,i as stripTrailingFluffAfterTools};
@@ -1,4 +1,4 @@
1
- import{a as ma}from"./chunk-UEV335RW.js";import{b as oa,c as na,d as ra}from"./chunk-IHDJDAG3.js";import{c as jl,e as Zn,f as wo,g as ql}from"./chunk-GM5VNNTU.js";import{A as da,B as yo,D as ua,a as Yl,b as mt,c as Dt,d as Cr,e as ui,f as Jl,g as An,h as ns,i as rs,j as Zl,r as ia,t as la,x as aa,z as ca}from"./chunk-24LJKH4G.js";import{a as lo,b as Ql,c as zl}from"./chunk-HFTI3R3Q.js";import"./chunk-52STSLCN.js";import{a as sa}from"./chunk-56EJGQU3.js";import"./chunk-4BLSASW6.js";import{a as Vt,b as Lt,d as Gl,e as Pt,f as Kl,k as ai,l as ci,m as yr,n as di,o as Vl,p as Qo}from"./chunk-7SGZ66KT.js";import"./chunk-UIL6OCU4.js";import{a as ta}from"./chunk-YX4X2ZTX.js";import{a as Sr,b as zo,c as Ln,e as ss,f as mi,g as Rl,h as ea,i as vr}from"./chunk-EXT42EJZ.js";import{a as Mr}from"./chunk-6EYQQ7GQ.js";import{a as un}from"./chunk-Y5JU726N.js";import{b as dn,c as ri}from"./chunk-QESQR5GB.js";import{A as Ll,C as Pl,D as Ol,E as Nl,H as Fl,c as Ml,e as ei,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 ti,v as oi,w as ni}from"./chunk-J4J3F6BT.js";import{a as Ul,b as _l,i as Hl,j as ts,k as os,m as Et,n as Wl,p as ii,q as li,w as Xl}from"./chunk-V36DXF56.js";import{a as $l,b as si,c as qt}from"./chunk-B4UKMX5E.js";import{d as hl,e as Rs,f as pl,g as bl,h as wl,i as Tl,j as yl,l as es,n as cn,o as bo,p as Tr,q as Cl}from"./chunk-LQM3JK7N.js";import{c as Zr,d as gl,e as Rr}from"./chunk-P5HBJA23.js";import{a as ko,b as kn,c as Fo,d as Js,e as Zs,k as wr,y as fl}from"./chunk-26BQ45XP.js";import Ai from"os";import e,{useState as J,useEffect as ct,useRef as Ze,useMemo as or}from"react";import{Box as u,Text as i,useInput as su,useStdout as iu,Static as lu}from"ink";import au from"ink-spinner";import ft from"fs-extra";import Tt from"path";import{exec as Go}from"child_process";import{fileURLToPath as cu}from"url";import oo,{useState as is,useEffect as xi,useMemo as Br,useCallback as Ic,useRef as Jo}from"react";import{Box as kc,Text as Ao,useInput as Ac}from"ink";function Lc(t,m){return t.replace(/\t/g," ".repeat(m))}function ls(t){return t==null?"":t.replace(/\r\n/g,`
1
+ import{a as ma}from"./chunk-UEV335RW.js";import{b as oa,c as na,d as ra}from"./chunk-IHDJDAG3.js";import{c as jl,e as Zn,f as wo,g as ql}from"./chunk-GM5VNNTU.js";import{A as da,B as yo,D as ua,a as Yl,b as mt,c as Dt,d as Cr,e as ui,f as Jl,g as An,h as ns,i as rs,j as Zl,r as ia,t as la,x as aa,z as ca}from"./chunk-WS35FH7W.js";import{a as lo,b as Ql,c as zl}from"./chunk-HFTI3R3Q.js";import"./chunk-52STSLCN.js";import{a as sa}from"./chunk-56EJGQU3.js";import"./chunk-4BLSASW6.js";import{a as Vt,b as Lt,d as Gl,e as Pt,f as Kl,k as ai,l as ci,m as yr,n as di,o as Vl,p as Qo}from"./chunk-7SGZ66KT.js";import"./chunk-UIL6OCU4.js";import{a as ta}from"./chunk-YX4X2ZTX.js";import{a as Sr,b as zo,c as Ln,e as ss,f as mi,g as Rl,h as ea,i as vr}from"./chunk-EXT42EJZ.js";import{a as Mr}from"./chunk-6EYQQ7GQ.js";import{a as un}from"./chunk-Y5JU726N.js";import{b as dn,c as ri}from"./chunk-QESQR5GB.js";import{A as Ll,C as Pl,D as Ol,E as Nl,H as Fl,c as Ml,e as ei,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 ti,v as oi,w as ni}from"./chunk-J4J3F6BT.js";import{a as Ul,b as _l,i as Hl,j as ts,k as os,m as Et,n as Wl,p as ii,q as li,w as Xl}from"./chunk-V36DXF56.js";import{a as $l,b as si,c as qt}from"./chunk-B4UKMX5E.js";import{d as hl,e as Rs,f as pl,g as bl,h as wl,i as Tl,j as yl,l as es,n as cn,o as bo,p as Tr,q as Cl}from"./chunk-LQM3JK7N.js";import{c as Zr,d as gl,e as Rr}from"./chunk-P5HBJA23.js";import{a as ko,b as kn,c as Fo,d as Js,e as Zs,k as wr,y as fl}from"./chunk-26BQ45XP.js";import Ai from"os";import e,{useState as J,useEffect as ct,useRef as Ze,useMemo as or}from"react";import{Box as u,Text as i,useInput as su,useStdout as iu,Static as lu}from"ink";import au from"ink-spinner";import ft from"fs-extra";import Tt from"path";import{exec as Go}from"child_process";import{fileURLToPath as cu}from"url";import oo,{useState as is,useEffect as xi,useMemo as Br,useCallback as Ic,useRef as Jo}from"react";import{Box as kc,Text as Ao,useInput as Ac}from"ink";function Lc(t,m){return t.replace(/\t/g," ".repeat(m))}function ls(t){return t==null?"":t.replace(/\r\n/g,`
2
2
  `).replace(/\r/g,`
3
3
  `)}function Pn(t,m,c){let S=t,T=[...m].sort((r,C)=>r.start-C.start),p=0;for(let r of T){let C=r.start-p,y=ls(r.text).split(`
4
4
  `).length,M=r.text.length,P=(y>3?`[Pasted ${y} lines]`:`[Pasted ${M} chars]`).length,N=C+P;if(t<=C)break;if(t<N){S=r.end;break}else{let E=r.text.length-P;S+=E,p+=E}}return Math.min(S,c.length)}function fi(t,m,c,S,T=[]){let p=(t||"").slice(0,m),r=S(p).length,C=S(t||""),y=[...T].sort((V,H)=>H.start-V.start);for(let V of y){let H=S(t.slice(0,V.start)).length,X=S(V.text),G=H+X.length,se=ls(V.text).split(`
@@ -102,7 +102,7 @@ Remove-Item -Path '${Aa.replace(/'/g,"''")}' -Recurse -Force -ErrorAction Silent
102
102
  \u2514\u2500\u2800`:""}Initialization complete.${v}
103
103
  \u2800`,isMeta:!0}])}else L(f=>[...f,{role:"system",text:`\u2726 INVALID KEY
104
104
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${U} API key must start with "${o}" and be at least ${n} characters long.`,isMeta:!0}]),yn("")},Qr=Ze(Ii);ct(()=>{if(Mt==="exit"){(async()=>{let B=Date.now(),o=Math.floor((B-Qr.current)/1e3);o>=1&&(await ii("duration",o),Qr.current+=o*1e3),await _l()})();let a=setTimeout(()=>{process.exit(0)},50);return()=>clearTimeout(a)}},[Mt]),ct(()=>{try{ni(x=>{L(a=>($(a.length+1),[...a,{id:"keynotice-"+Date.now(),role:"system",text:`\u2726 ${x}
105
- \u2800`,isMeta:!0}]))})}catch{}return()=>{try{ni(null)}catch{}}},[]),ct(()=>{let x=setInterval(async()=>{if(!Le){let a=Date.now(),B=Math.floor((a-Qr.current)/1e3);B>=1&&(await ii("duration",B),Qr.current+=B*1e3),Ul()}},5e3);return()=>clearInterval(x)},[Le]);let ul=[{cmd:"/quit",desc:"Exit and shutdown Flux"},{cmd:"/kill",desc:"Kill a process by PID",subs:On.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"},...Ue.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:"/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(U,Ye,"Low")!==null?`Low (${lo(U,Ye,"Low")})`:"Low",desc:"Quick Reasoning"},{cmd:"Medium",display:lo(U,Ye,"Medium")!==null?`Medium (${lo(U,Ye,"Medium")})`:"Medium",desc:"Balanced Reasoning"},{cmd:"High",display:lo(U,Ye,"High")!==null?`High (${lo(U,Ye,"High")})`:"High",desc:"Deep Reasoning"},{cmd:"custom",display:lo(U,Ye,"xHigh")!==null?`Custom (${lo(U,Ye,"xHigh")})`:"Custom",desc:"Custom Reasoning Value"}]},{cmd:"/model",desc:"Select Agent Model",subs:G==="ICU"||G.toLowerCase()==="fluxcu"?cn(U,et,le?.customOpenAIBaseUrl).filter(x=>es(x.cmd||x)):cn(U,et,le?.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[Pe]||st[0],h=x.split(" "),g=h.length===1?n.cmd:h.slice(0,-1).join(" ")+" "+n.cmd;if(g.trim()!==x.trim()){y(g+" "),Ae(0),P(d=>d+1);return}}js.current=!1;let B=x.replace(/\r\n/g,`
105
+ \u2800`,isMeta:!0}]))})}catch{}return()=>{try{ni(null)}catch{}}},[]),ct(()=>{let x=setInterval(async()=>{if(!Le){let a=Date.now(),B=Math.floor((a-Qr.current)/1e3);B>=1&&(await ii("duration",B),Qr.current+=B*1e3),Ul()}},5e3);return()=>clearInterval(x)},[Le]);let ul=[{cmd:"/quit",desc:"Exit and shutdown Flux"},{cmd:"/kill",desc:"Kill a process by PID",subs:On.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"},...Ue.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:"/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(U,Ye,"Low")!==null?`Low (${lo(U,Ye,"Low")})`:"Low",desc:"Quick Reasoning"},{cmd:"Medium",display:lo(U,Ye,"Medium")!==null?`Medium (${lo(U,Ye,"Medium")})`:"Medium",desc:"Balanced Reasoning"},{cmd:"High",display:lo(U,Ye,"High")!==null?`High (${lo(U,Ye,"High")})`:"High",desc:"Deep Reasoning"},{cmd:"custom",display:lo(U,Ye,"xHigh")!==null?`Custom (${lo(U,Ye,"xHigh")})`:"Custom",desc:"Custom Reasoning Value"}]},{cmd:"/model",desc:"Select Agent Model",subs:G==="ICU"||G.toLowerCase()==="fluxcu"?cn(U,et,le?.customOpenAIBaseUrl).filter(x=>es(x.cmd||x)):cn(U,et,le?.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"}]},{cmd:"/skill-creator",desc:'Generate new skills with natural language. /skills-creator "describe" --project/global.'}],ml=async(x,a=!1)=>{if(!a&&st.length>0){let n=st[Pe]||st[0],h=x.split(" "),g=h.length===1?n.cmd:h.slice(0,-1).join(" ")+" "+n.cmd;if(g.trim()!==x.trim()){y(g+" "),Ae(0),P(d=>d+1);return}}js.current=!1;let B=x.replace(/\r\n/g,`
106
106
  `).replace(/\r/g,`
107
107
  `).trimEnd();if(B.endsWith("\\")){y(B.slice(0,-1)+`
108
108
  `);return}let o=B.replace(/\\\s*\n/g,`
@@ -111,7 +111,7 @@ Remove-Item -Path '${Aa.replace(/'/g,"''")}' -Recurse -Force -ErrorAction Silent
111
111
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Inquiry question must be more than 3 characters.
112
112
  \u2800`,isMeta:!0}])),y("");return}}else if(n.startsWith("/")){L(h=>($(h.length+1),[...h,{id:"hint-err-"+Date.now(),role:"system",text:`\u2726 RESTRICTED
113
113
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m Steering Hints cannot start with '/'.
114
- \u2800`,isMeta:!0}])),y("");return}qs(n),jo.current=n,y("");return}if(!Je&&!(U==="c_openai"&&le.customOpenAIBaseUrl)){dl(o),yn("");return}if(o.startsWith("/")){y("");let n=o.split(" "),h=n[0]?.toLowerCase();switch(h){case"/quit":{ie("exit");break}case"/resume":{if(n[1]){let g=n[1];(async()=>{let f=await zo(),b=f[g]||Object.values(f).find(v=>v.name.toLowerCase()===g.toLowerCase());if(b){if(r.write("\x1B[2J\x1B[3J\x1B[H"),process.stdout.isTTY){let te=b?.name||"",W=te&&!te.startsWith("flow-")&&!te.startsWith("Session ")?te:"FluxFlow | Resumed";process.stdout.write(`\x1B]0;${W}\x07`),process.stdout.write(`\x1B]633;P;TerminalTitle=${W}\x07`)}Qo(),Yo.current=!0,jr(g);let v=await vr(g);_n.current=xo-v.total,Wn.current=Bo,Gn.current=Sn,to.current=[],Un(v.total),Hn(0),Mn(0),Xn(0),rn({tokens:v.context}),Yo.current=!1;let D=[...b.messages];D[0]?.text?.includes("\u2591\u2591\u2591\u2588\u2588\u2588")||D.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),L(D),L(te=>[...te,{id:"sys-"+Date.now(),role:"system",text:`\u2726 SESSION RESUMED
114
+ \u2800`,isMeta:!0}])),y("");return}qs(n),jo.current=n,y("");return}if(!Je&&!(U==="c_openai"&&le.customOpenAIBaseUrl)){dl(o),yn("");return}if(o.startsWith("/")&&!o.startsWith("/skill-creator")){y("");let n=o.split(" "),h=n[0]?.toLowerCase();switch(h){case"/quit":{ie("exit");break}case"/resume":{if(n[1]){let g=n[1];(async()=>{let f=await zo(),b=f[g]||Object.values(f).find(v=>v.name.toLowerCase()===g.toLowerCase());if(b){if(r.write("\x1B[2J\x1B[3J\x1B[H"),process.stdout.isTTY){let te=b?.name||"",W=te&&!te.startsWith("flow-")&&!te.startsWith("Session ")?te:"FluxFlow | Resumed";process.stdout.write(`\x1B]0;${W}\x07`),process.stdout.write(`\x1B]633;P;TerminalTitle=${W}\x07`)}Qo(),Yo.current=!0,jr(g);let v=await vr(g);_n.current=xo-v.total,Wn.current=Bo,Gn.current=Sn,to.current=[],Un(v.total),Hn(0),Mn(0),Xn(0),rn({tokens:v.context}),Yo.current=!1;let D=[...b.messages];D[0]?.text?.includes("\u2591\u2591\u2591\u2588\u2588\u2588")||D.unshift({id:"logo-"+Date.now(),role:"system",isLogo:!0,isMeta:!0}),L(D),L(te=>[...te,{id:"sys-"+Date.now(),role:"system",text:`\u2726 SESSION RESUMED
115
115
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m ${g}.
116
116
  \u2800`,isMeta:!0}]),$(0)}else L(v=>[...v,{id:"err-"+Date.now(),role:"system",text:`\u2726 ERROR: Session [${g}] not found.
117
117
  \u2800`,isMeta:!0}])})()}else ie("resume");break}case"/move":{if(!Ue.playground){L(b=>($(b.length+1),[...b,{id:Date.now(),role:"system",text:`\u2726 RESTRICTED
@@ -280,7 +280,7 @@ ${n}`};L(d=>{let f=[...d,h];return $(f.length),Ln(wt,null,f),f}),(async()=>{let
280
280
  Question: ${F}
281
281
  Selection: ${Re}`,isAskRecord:!0}];return $(gt.length),gt}),Ce(Re))}}),ie("ask")})),onUsage:F=>{let pe=F.totalTokenCount||0,Ce=F.cachedContentTokenCount||0,ve=F.candidatesTokenCount||0,Re=Math.max(0,pe-ve);if(rn({tokens:pe}),_i(Xe=>Xe+pe),Re>0&&Hi(Xe=>Xe+Re),Ce>0&&Wi(Xe=>Xe+Ce),ve>0&&Xi(Xe=>Xe+ve),Re>0||Ce>0){to.current.push({input:Re,cached:Ce}),to.current.length>3&&to.current.shift();let Xe=to.current.reduce((q,me)=>q+me.input,0),yt=to.current.reduce((q,me)=>q+me.cached,0),gt=Xe>0?yt/Xe*100:0;Mn(gt)}$i(Xe=>Xe+1)}},async()=>jo.current?jo.current:null,So),j=!1,Ve=null,Ne=null,Ie=!1,rt=!1,_t=!1,at=!1,re=0,ge=null,_e=/\[?\s*turn\s*:\s*.*?\s*\]?/gi;for await(let F of oe){if(await new Promise(q=>setTimeout(q,3)),F.type==="text"&&Is(Date.now()),D&&F.type==="text"&&(v=Date.now(),D=!1,le.progressiveRendering&&Ee()),F.type==="status"){if(F.content&&(F.content.includes("Steering Hint Injected")||F.content.includes("Question Forwarded"))){let q=jo.current;q&&(L(me=>{$(me.length+1);let ke=q.startsWith("/btw"),qe=ke?q.replace(/^\/btw\s*/,""):q,Ge=ke?"[QUESTION]":"[STEERING HINT]";return[...me,{id:"hint-"+Date.now(),role:"user",text:`${Ge}
282
282
  ${qe}`,color:"cyan",isSteeringHint:!0,hintType:ke?"QUESTION":"STEERING HINT",hintContent:qe}]}),qs(null),jo.current=null)}F.content?.includes("[start]")||Ks(F.content),F.content?.includes("[start]")?(clearInterval(gr),fr(0),gr=setInterval(()=>{fr(q=>q+1)},1e3)):F.content?.includes("[end]")&&(fr(0),clearInterval(gr)),An()&&ns(F.content),F.content==="Request Cancelled"&&(Qe(),ae(),f());continue}if(F.type==="status_history"){Ks(F.content),An()&&ns(F.content),L(q=>[...q,{id:"condense-"+Date.now(),role:"system",text:`\u2726 ${F.content}
283
- \u2800`,isMeta:!0}]);continue}if(F.type==="summary_injected"){L(q=>q.map(me=>me.id===F.content.id?{...me,fullText:F.content.text}:me));continue}if(F.type==="spinner"){wc(F.content);continue}if(F.type==="model_update"){Sc(F.content);continue}if(F.type==="turn_reset"){if(Qe(),ae(),Ve=null,Ne=null,j=!1,Ie=!1,rt=!1,at=!1,_t=!1,L(q=>{let me=q.map(ke=>{if(ke.isStreaming){let qe=ke.text?Vt(ke.text):ke.text,Ge=ke.fullText?Vt(ke.fullText):ke.fullText;return{...ke,isStreaming:!1,text:qe,fullText:Ge}}return ke});return $(me.length),me}),Qo(),global.gc){for(let q=0;q<2;q++)global.gc(),await new Promise(me=>setImmediate(me));m.current=Date.now()}continue}if(F.type==="interactive_turn_finished"){Ys(!1),fr(0),clearInterval(gr),An()&&ns(null),b=!0,le?.agentFinishSound&&(async()=>{try{let me=(await zo())[wt],ke=Sr(me,String(wt));Ti(ke)}catch{Ti(String(wt))}})(),Qo(),le?.autoTruncateResults&&L(q=>{let me=q.map(ke=>{let qe=ke.fullText||ke.text||"";return!qe.startsWith("[ACTION RESULT]:")&&!qe.startsWith("[TOOL RESULT]:")||qe.startsWith("[ACTION RESULT]: Goal")||qe.includes("...Old result truncated to save tokens")||qe.startsWith("[ACTION RESULT]: USER CHOOSE")||qe.startsWith("[ACTION RESULT]: Skill:")||qe.startsWith("[ACTION RESULT]: DOCs:")||qe.startsWith("[ACTION RESULT]: Markdown parsed")||qe.startsWith("[ACTION RESULT]: Search results for [")||qe.startsWith("[ACTION RESULT]: AI Mode temporarily failed")||qe.startsWith("[ACTION RESULT]: Background subagent started. Task ID:")||/^\[ACTION RESULT\]: File \[.*?\] saved/s.test(qe)?ke:{...ke,fullText:"[ACTION RESULT]: ...Old result truncated to save tokens"}});return Ln(wt,null,me),$(me.length),me});continue}if(F.type==="visual_feedback"){Qe(),ae(),L(q=>{let me=[...q,{id:"feedback-"+Date.now()+"-"+Math.random().toString(36).substring(2,9),role:"system",text:Vt(F.content),isVisualFeedback:!0}];return $(me.length),me});continue}if(F.type==="exec_start"){Qe(),ae();continue}if(F.type==="liveTokens"){rn({tokens:F.content});continue}if(F.type==="usage"){let q=F.content.totalTokenCount||0,me=F.content.cachedContentTokenCount||0,ke=F.content.candidatesTokenCount||0,qe=Math.max(0,q-ke);if(rn({tokens:q}),_i(Ge=>Ge+q),qe>0&&Hi(Ge=>Ge+qe),me>0&&Wi(Ge=>Ge+me),ke>0&&Xi(Ge=>Ge+ke),qe>0||me>0){to.current.push({input:qe,cached:me}),to.current.length>3&&to.current.shift();let Ge=to.current.reduce((zt,Kt)=>zt+Kt.input,0),Bt=to.current.reduce((zt,Kt)=>zt+Kt.cached,0),go=Ge>0?Bt/Ge*100:0;Mn(go)}$i(Ge=>Ge+1);continue}if(F.type==="tool_time"){uc(q=>q+F.content);continue}if(F.type==="tool_result"){ae(),Ve=null,Ne=null,j=!1,Ie=!1,rt=!1,at=!1,_t=!1,re=0,ge=null,L(q=>{let me=[...q,{id:"tool-"+Date.now()+"-"+Math.random().toString(36).substring(2,7),role:"system",text:Vt(F.content),fullText:Vt(F.aiContent),binaryPart:F.binaryPart,toolName:F.toolName}];return $(me.length),me}),Y.current&&(Ne=Y.current.id,rt=!0);continue}let pe=F.content;if(F.type==="text"&&pe.includes("Request Cancelled")){if(global.gc){for(let q=0;q<3;q++)global.gc(),await new Promise(me=>setImmediate(me));m.current=Date.now()}continue}let Ce=pe.toLowerCase();if(pe.includes("```")&&(Ie=!Ie),(Ce.includes("tool:")||Ce.includes("action:"))&&(rt=!0,re=0,ge=null,(pe.includes("[tool:")||pe.includes("[action:"))&&(re=0)),rt){for(let q=0;q<pe.length;q++){let me=pe[q];!ge&&(me==="'"||me==='"'||me==="`")?ge=me:ge&&me===ge&&pe[q-1]!=="\\"&&(ge=null),ge||(me==="("||me==="["?re++:(me===")"||me==="]")&&re--)}re<=0&&!ge&&(rt=!1)}let ve=/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])/i,Re=(q,me,ke=1)=>{let qe=me>0?q[me-1]:"",Ge=me+ke<q.length?q[me+ke]:"";return qe==="`"&&Ge==="`"},Xe=q=>{let me=/(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\])/gi,ke;for(;(ke=me.exec(q))!==null;)if(!Re(q,ke.index,ke[0].length))return{index:ke.index,length:ke[0].length};return{index:-1,length:0}},yt=Y.current?.role==="agent"&&Y.current.text||"",gt=!_t&&yt.trim().length===0;if(!j&&gt&&(ve.test(pe)||ve.test(yt+pe))){let q=ve.test(pe)?pe:yt+pe,me=q.match(ve),ke=me.index,qe=me[0].length,Ge=q.substring(ke+qe);Qe(),Y.current=null,j=!0,_t=!0,Ve="think-"+Date.now(),Y.current={id:Ve,role:"think",text:"",isStreaming:!0,startTime:Date.now()};let Bt=Xe(Ge);if(Bt.index!==-1){let zt=Ge.substring(0,Bt.index).replace(/^\r?\n+/,"").replace(/\r?\n+$/,""),Kt=Ge.substring(Bt.index+Bt.length);Y.current.text=Vt(zt);let Io=Y.current.startTime||Date.now();Y.current.duration=Date.now()-Io,ae(),j=!1,Ne="agent-"+Date.now(),Y.current={id:Ne,role:"agent",text:"",isStreaming:!0},Kt&&ut(Kt)}else{let go=Ge.replace(/^\r?\n+/,"");go&&ut(go)}continue}if(!j&&!_t&&pe.trim().length>0&&(_t=!0),j&&Y.current?.role==="think"){Qe();let me=(Y.current.text||"")+pe,ke=Xe(me);if(ke.index!==-1){let qe=me.substring(0,ke.index),Ge=me.substring(ke.index+ke.length);Y.current.text=Vt(qe);let Bt=Y.current.startTime||Date.now();Y.current.duration=Date.now()-Bt,ae(),j=!1,Ne="agent-"+Date.now(),Y.current={id:Ne,role:"agent",text:"",isStreaming:!0},Ge&&ut(Ge)}else ut(pe);continue}else if(!j){let q=pe.toLowerCase();!at&&(q.includes("tool:")||q.includes("action:"))&&(at=!0),!Y.current||Y.current.role!=="agent"?(Ne="agent-"+Date.now(),Y.current={id:Ne,role:"agent",text:Vt(pe),isStreaming:!0},it()):ut(pe)}}let je=Date.now();dc(F=>F+(je-v))}catch(z){L(te=>($(te.length+1),[...te,{id:"error-"+Date.now(),role:"system",text:`\u274C ERROR: ${z.message}`}]))}finally{let z=Date.now()-v;if(Y.current&&(Y.current.workedDuration=z),nt.current&&(await dt(),clearInterval(nt.current),nt.current=null),Ys(!1),Ks(null),fr(0),clearInterval(gr),ae(),js.current&&f(),Qo(),global.gc)try{for(let te=0;te<3;te++)global.gc(),await new Promise(W=>setImmediate(W));m.current=Date.now()}catch{}if(b||process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow | Idle\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow | Idle\x07")),jo.current){Qs(jo.current),qs(null);let te=jo.current;jo.current=null,L(W=>{let Q=[...W],oe=Q.reverse().find(j=>j.text?.includes("[STEERING HINT: QUEUED]")||j.text?.includes("[QUESTION: QUEUED]"));return oe&&(oe.text.includes("[STEERING HINT: QUEUED]")?oe.text=oe.text.replace("[STEERING HINT: QUEUED]","[STEERING HINT: FINISHED_TURN]"):oe.text.includes("[QUESTION: QUEUED]")&&(oe.text=oe.text.replace("[QUESTION: QUEUED]","[QUESTION: FINISHED_TURN]"))),Q.reverse()}),ie("resolution")}L(te=>{let W=Date.now()-v,Q=!1,oe=[...te].reverse().map(Ne=>{let Ie=Ne.isStreaming?{...Ne,isStreaming:!1}:Ne;return Ie.text&&(Ie.text=(" "+Ie.text).slice(1)),!Q&&Ie.role==="agent"&&(Q=!0,Ie={...Ie,workedDuration:W}),Ie}).reverse();if(!oe.some(Ne=>Ne.role==="agent"&&Ne.text?.trim().length>0)){let Ne=[...oe].reverse().find(Ie=>Ie.role==="think"&&Ie.text?.trim().length>0);Ne&&oe.push({id:"agent-fallback-"+Date.now(),role:"agent",text:Ne.text,isStreaming:!1,workedDuration:W})}let Ve=oe.filter(Ne=>!String(Ne.id).startsWith("welcome")&&(!Ne.isMeta||Ne.text&&Ne.text.includes("Request Cancelled")));return Ln(wt,null,Ve),$(oe.length),oe})}})()}y(""),X(!1)}},st=or(()=>{if(C.startsWith("/")&&!tt){let n=C.split(" "),h=n[n.length-1].toLowerCase();if(n.length===1){let d=h.startsWith("/")?h.slice(1):h;return ul.filter(f=>(f.cmd.startsWith("/")?f.cmd.slice(1):f.cmd).toLowerCase().includes(d))}let g=ul;for(let d=0;d<n.length-1;d++){let f=n[d].toLowerCase(),b=g.find(v=>v.cmd.toLowerCase()===f);if(b&&b.subs)g=b.subs;else return[]}return g.filter(d=>d.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,g=B?2:1,d=h?a.substring(g,n).toLowerCase():a.slice(g).toLowerCase(),f=h?a.substring(n):"";return bu(process.cwd()).filter(D=>D.name.toLowerCase().includes(d)).map(D=>{let z=D.relativePath.replace(/\\/g,"/"),te=z.startsWith(".")?z:"./"+z;return{cmd:(B?"\\@":"@")+"["+te+f+"]",desc:D.relativePath}})}return[]},[C,tt]);ct(()=>{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}Ae(x<st.length?x:0)},[st]);let[zr,Jr]=J(0),xl=Ze(0);ct(()=>{let x=xl.current>0,a=st.length>0;if(xl.current=st.length,!a){Jr(0);return}if(!x){Jr(1);return}Jr(st.length)},[st]),ct(()=>{if(zr>0&&zr<st.length){let x=setTimeout(()=>{Jr(a=>Math.min(a+1,st.length))},1);return()=>clearTimeout(x)}},[zr,st.length]),ct(()=>{if(Mt!=="providerBudgetSelect")return;let x=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","Infron","APInex","xKiro"],a=De.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),{});Pi(B),Wr(0)},[Mt]),ct(()=>{if(Mt!=="providerBudgetFlow")return;let x={},a=De.providerBudgets||{};for(let B of Nn){let o=a[B]||{};x[B]={agentLimit:tn(o.agentLimit),tokenLimit:tn(o.tokenLimit),monthlyTokenLimit:tn(o.monthlyTokenLimit),dailyCostLimit:tn(o.dailyCostLimit),monthlyCostLimit:tn(o.monthlyCostLimit)}}lr(x),vo(0)},[Mt,Nn]);let Fu=({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 g=Mo(B),d=!g&&B>0?Math.min(100,a/B*100):0,f=Math.round(d),b=Math.round(f/100*o),v="\u2588".repeat(b)+"\u2591".repeat(Math.max(0,o-b)),D=s.success||"green";f>=40&&f<=80?D=s.warning||"yellow":f>80&&(D=s.danger||"red");let z=x.toLowerCase().includes("cost")||x.toLowerCase().includes("spend"),te=!z&&(x.toLowerCase().includes("token")||x.toLowerCase().includes("daily")||x.toLowerCase().includes("monthly")),W=g?"\u221E":z?`$${Number(B).toFixed(2)}`:te?Pt(B):B,Q=Number(a)||0,oe=z?`$${Q.toFixed(Q<.01&&Q>0?4:2)}`:te?Pt(a):a,j;return g||d===0?j="0%":d>0&&d<1?j="<1%":j=`${f}%`,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:D},v),e.createElement(i,{color:s.textMuted}," ",j," (",oe,"/",W,")"))},Dc=()=>{switch(Mt){case"settings":return e.createElement(fs,{systemSettings:le,setSystemSettings:Ft,apiTier:et,setActiveView:ie,setInputConfig:mo,saveSettings:qt,quotas:De,setMessages:L,aiProvider:U,autoCompletion:ar,setAutoCompletion:Ds,profileData:$n,setProfileData:Es,setProviderReturnView:vs,setApiKey:Nt,initAI:yo});case"theme":return e.createElement(fs,{systemSettings:le,setSystemSettings:Ft,apiTier:et,setActiveView:ie,setInputConfig:mo,saveSettings:qt,quotas:De,setMessages:L,aiProvider:U,autoCompletion:ar,setAutoCompletion:Ds,profileData:$n,setProfileData:Es,initialSelectingTheme:!0,onCloseTheme:()=>ie("chat"),setProviderReturnView:vs,setApiKey:Nt,initAI:yo});case"selectProvider":return e.createElement(Ut,{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:nn}],theme:le.theme,onSelect:async o=>{if(o.value===nn||o.value==="settings"||o.value==="Back"){ie(nn);return}let n=o.value,h=await dn(n),g="";if(n==="9router"){let d=await Ei();d.ok||(g=`
283
+ \u2800`,isMeta:!0}]);continue}if(F.type==="summary_injected"){L(q=>q.map(me=>me.id===F.content.id?{...me,fullText:F.content.text}:me));continue}if(F.type==="spinner"){wc(F.content);continue}if(F.type==="model_update"){Sc(F.content);continue}if(F.type==="turn_reset"){if(Qe(),ae(),Ve=null,Ne=null,j=!1,Ie=!1,rt=!1,at=!1,_t=!1,L(q=>{let me=q.map(ke=>{if(ke.isStreaming){let qe=ke.text?Vt(ke.text):ke.text,Ge=ke.fullText?Vt(ke.fullText):ke.fullText;return{...ke,isStreaming:!1,text:qe,fullText:Ge}}return ke});return $(me.length),me}),Qo(),global.gc){for(let q=0;q<2;q++)global.gc(),await new Promise(me=>setImmediate(me));m.current=Date.now()}continue}if(F.type==="interactive_turn_finished"){Ys(!1),fr(0),clearInterval(gr),An()&&ns(null),b=!0,le?.agentFinishSound&&(async()=>{try{let me=(await zo())[wt],ke=Sr(me,String(wt));Ti(ke)}catch{Ti(String(wt))}})(),Qo(),le?.autoTruncateResults&&L(q=>{let me=q.map(ke=>{let qe=ke.fullText||ke.text||"";return!qe.startsWith("[ACTION RESULT]:")&&!qe.startsWith("[TOOL RESULT]:")||qe.startsWith("[ACTION RESULT]: Goal")||qe.includes("...Old result truncated to save tokens")||qe.startsWith("[ACTION RESULT]: USER CHOOSE")||qe.startsWith("[ACTION RESULT]: Skill:")||qe.startsWith("[ACTION RESULT]: DOCs:")||qe.startsWith("[ACTION RESULT]: Markdown parsed")||qe.startsWith("[ACTION RESULT]: Search results for [")||qe.startsWith("[ACTION RESULT]: AI Mode temporarily failed")||qe.startsWith("[ACTION RESULT]: Background subagent started. Task ID:")||/^\[ACTION RESULT\]: File \[.*?\] saved/s.test(qe)?ke:{...ke,fullText:"[ACTION RESULT]: ...Old result truncated to save tokens"}});return Ln(wt,null,me),$(me.length),me}),process.stdout.isTTY&&(async()=>{try{process.stdout.write("\x1B]0;FluxFlow | Idle\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow | Idle\x07")}catch{process.stdout.write("\x1B]0;FluxFlow | Idle\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow | Idle\x07")}})();continue}if(F.type==="visual_feedback"){Qe(),ae(),L(q=>{let me=[...q,{id:"feedback-"+Date.now()+"-"+Math.random().toString(36).substring(2,9),role:"system",text:Vt(F.content),isVisualFeedback:!0}];return $(me.length),me});continue}if(F.type==="exec_start"){Qe(),ae();continue}if(F.type==="liveTokens"){rn({tokens:F.content});continue}if(F.type==="usage"){let q=F.content.totalTokenCount||0,me=F.content.cachedContentTokenCount||0,ke=F.content.candidatesTokenCount||0,qe=Math.max(0,q-ke);if(rn({tokens:q}),_i(Ge=>Ge+q),qe>0&&Hi(Ge=>Ge+qe),me>0&&Wi(Ge=>Ge+me),ke>0&&Xi(Ge=>Ge+ke),qe>0||me>0){to.current.push({input:qe,cached:me}),to.current.length>3&&to.current.shift();let Ge=to.current.reduce((zt,Kt)=>zt+Kt.input,0),Bt=to.current.reduce((zt,Kt)=>zt+Kt.cached,0),go=Ge>0?Bt/Ge*100:0;Mn(go)}$i(Ge=>Ge+1);continue}if(F.type==="tool_time"){uc(q=>q+F.content);continue}if(F.type==="tool_result"){ae(),Ve=null,Ne=null,j=!1,Ie=!1,rt=!1,at=!1,_t=!1,re=0,ge=null,L(q=>{let me=[...q,{id:"tool-"+Date.now()+"-"+Math.random().toString(36).substring(2,7),role:"system",text:Vt(F.content),fullText:Vt(F.aiContent),binaryPart:F.binaryPart,toolName:F.toolName}];return $(me.length),me}),Y.current&&(Ne=Y.current.id,rt=!0);continue}let pe=F.content;if(F.type==="text"&&pe.includes("Request Cancelled")){if(global.gc){for(let q=0;q<3;q++)global.gc(),await new Promise(me=>setImmediate(me));m.current=Date.now()}continue}let Ce=pe.toLowerCase();if(pe.includes("```")&&(Ie=!Ie),(Ce.includes("tool:")||Ce.includes("action:"))&&(rt=!0,re=0,ge=null,(pe.includes("[tool:")||pe.includes("[action:"))&&(re=0)),rt){for(let q=0;q<pe.length;q++){let me=pe[q];!ge&&(me==="'"||me==='"'||me==="`")?ge=me:ge&&me===ge&&pe[q-1]!=="\\"&&(ge=null),ge||(me==="("||me==="["?re++:(me===")"||me==="]")&&re--)}re<=0&&!ge&&(rt=!1)}let ve=/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])/i,Re=(q,me,ke=1)=>{let qe=me>0?q[me-1]:"",Ge=me+ke<q.length?q[me+ke]:"";return qe==="`"&&Ge==="`"},Xe=q=>{let me=/(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\])/gi,ke;for(;(ke=me.exec(q))!==null;)if(!Re(q,ke.index,ke[0].length))return{index:ke.index,length:ke[0].length};return{index:-1,length:0}},yt=Y.current?.role==="agent"&&Y.current.text||"",gt=!_t&&yt.trim().length===0;if(!j&&gt&&(ve.test(pe)||ve.test(yt+pe))){let q=ve.test(pe)?pe:yt+pe,me=q.match(ve),ke=me.index,qe=me[0].length,Ge=q.substring(ke+qe);Qe(),Y.current=null,j=!0,_t=!0,Ve="think-"+Date.now(),Y.current={id:Ve,role:"think",text:"",isStreaming:!0,startTime:Date.now()};let Bt=Xe(Ge);if(Bt.index!==-1){let zt=Ge.substring(0,Bt.index).replace(/^\r?\n+/,"").replace(/\r?\n+$/,""),Kt=Ge.substring(Bt.index+Bt.length);Y.current.text=Vt(zt);let Io=Y.current.startTime||Date.now();Y.current.duration=Date.now()-Io,ae(),j=!1,Ne="agent-"+Date.now(),Y.current={id:Ne,role:"agent",text:"",isStreaming:!0},Kt&&ut(Kt)}else{let go=Ge.replace(/^\r?\n+/,"");go&&ut(go)}continue}if(!j&&!_t&&pe.trim().length>0&&(_t=!0),j&&Y.current?.role==="think"){Qe();let me=(Y.current.text||"")+pe,ke=Xe(me);if(ke.index!==-1){let qe=me.substring(0,ke.index),Ge=me.substring(ke.index+ke.length);Y.current.text=Vt(qe);let Bt=Y.current.startTime||Date.now();Y.current.duration=Date.now()-Bt,ae(),j=!1,Ne="agent-"+Date.now(),Y.current={id:Ne,role:"agent",text:"",isStreaming:!0},Ge&&ut(Ge)}else ut(pe);continue}else if(!j){let q=pe.toLowerCase();!at&&(q.includes("tool:")||q.includes("action:"))&&(at=!0),!Y.current||Y.current.role!=="agent"?(Ne="agent-"+Date.now(),Y.current={id:Ne,role:"agent",text:Vt(pe),isStreaming:!0},it()):ut(pe)}}let je=Date.now();dc(F=>F+(je-v))}catch(z){L(te=>($(te.length+1),[...te,{id:"error-"+Date.now(),role:"system",text:`\u274C ERROR: ${z.message}`}]))}finally{let z=Date.now()-v;if(Y.current&&(Y.current.workedDuration=z),nt.current&&(await dt(),clearInterval(nt.current),nt.current=null),Ys(!1),Ks(null),fr(0),clearInterval(gr),ae(),js.current&&f(),Qo(),global.gc)try{for(let te=0;te<3;te++)global.gc(),await new Promise(W=>setImmediate(W));m.current=Date.now()}catch{}if(b||process.stdout.isTTY&&(process.stdout.write("\x1B]0;FluxFlow | Idle\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow | Idle\x07")),jo.current){Qs(jo.current),qs(null);let te=jo.current;jo.current=null,L(W=>{let Q=[...W],oe=Q.reverse().find(j=>j.text?.includes("[STEERING HINT: QUEUED]")||j.text?.includes("[QUESTION: QUEUED]"));return oe&&(oe.text.includes("[STEERING HINT: QUEUED]")?oe.text=oe.text.replace("[STEERING HINT: QUEUED]","[STEERING HINT: FINISHED_TURN]"):oe.text.includes("[QUESTION: QUEUED]")&&(oe.text=oe.text.replace("[QUESTION: QUEUED]","[QUESTION: FINISHED_TURN]"))),Q.reverse()}),ie("resolution")}L(te=>{let W=Date.now()-v,Q=!1,oe=[...te].reverse().map(Ne=>{let Ie=Ne.isStreaming?{...Ne,isStreaming:!1}:Ne;return Ie.text&&(Ie.text=(" "+Ie.text).slice(1)),!Q&&Ie.role==="agent"&&(Q=!0,Ie={...Ie,workedDuration:W}),Ie}).reverse();if(!oe.some(Ne=>Ne.role==="agent"&&Ne.text?.trim().length>0)){let Ne=[...oe].reverse().find(Ie=>Ie.role==="think"&&Ie.text?.trim().length>0);Ne&&oe.push({id:"agent-fallback-"+Date.now(),role:"agent",text:Ne.text,isStreaming:!1,workedDuration:W})}let Ve=oe.filter(Ne=>!String(Ne.id).startsWith("welcome")&&(!Ne.isMeta||Ne.text&&Ne.text.includes("Request Cancelled")));return Ln(wt,null,Ve),$(oe.length),oe})}})()}y(""),X(!1)}},st=or(()=>{if(C.startsWith("/")&&!tt){let n=C.split(" "),h=n[n.length-1].toLowerCase();if(n.length===1){let d=h.startsWith("/")?h.slice(1):h;return ul.filter(f=>(f.cmd.startsWith("/")?f.cmd.slice(1):f.cmd).toLowerCase().includes(d))}let g=ul;for(let d=0;d<n.length-1;d++){let f=n[d].toLowerCase(),b=g.find(v=>v.cmd.toLowerCase()===f);if(b&&b.subs)g=b.subs;else return[]}return g.filter(d=>d.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,g=B?2:1,d=h?a.substring(g,n).toLowerCase():a.slice(g).toLowerCase(),f=h?a.substring(n):"";return bu(process.cwd()).filter(D=>D.name.toLowerCase().includes(d)).map(D=>{let z=D.relativePath.replace(/\\/g,"/"),te=z.startsWith(".")?z:"./"+z;return{cmd:(B?"\\@":"@")+"["+te+f+"]",desc:D.relativePath}})}return[]},[C,tt]);ct(()=>{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}Ae(x<st.length?x:0)},[st]);let[zr,Jr]=J(0),xl=Ze(0);ct(()=>{let x=xl.current>0,a=st.length>0;if(xl.current=st.length,!a){Jr(0);return}if(!x){Jr(1);return}Jr(st.length)},[st]),ct(()=>{if(zr>0&&zr<st.length){let x=setTimeout(()=>{Jr(a=>Math.min(a+1,st.length))},1);return()=>clearTimeout(x)}},[zr,st.length]),ct(()=>{if(Mt!=="providerBudgetSelect")return;let x=["Google","DeepSeek","Mistral","NVIDIA","OpenRouter","Ollama","InferX","SenseNova","AIHubMix","Poolside","ExpLabs","TokenHarbor","Infron","APInex","xKiro"],a=De.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),{});Pi(B),Wr(0)},[Mt]),ct(()=>{if(Mt!=="providerBudgetFlow")return;let x={},a=De.providerBudgets||{};for(let B of Nn){let o=a[B]||{};x[B]={agentLimit:tn(o.agentLimit),tokenLimit:tn(o.tokenLimit),monthlyTokenLimit:tn(o.monthlyTokenLimit),dailyCostLimit:tn(o.dailyCostLimit),monthlyCostLimit:tn(o.monthlyCostLimit)}}lr(x),vo(0)},[Mt,Nn]);let Fu=({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 g=Mo(B),d=!g&&B>0?Math.min(100,a/B*100):0,f=Math.round(d),b=Math.round(f/100*o),v="\u2588".repeat(b)+"\u2591".repeat(Math.max(0,o-b)),D=s.success||"green";f>=40&&f<=80?D=s.warning||"yellow":f>80&&(D=s.danger||"red");let z=x.toLowerCase().includes("cost")||x.toLowerCase().includes("spend"),te=!z&&(x.toLowerCase().includes("token")||x.toLowerCase().includes("daily")||x.toLowerCase().includes("monthly")),W=g?"\u221E":z?`$${Number(B).toFixed(2)}`:te?Pt(B):B,Q=Number(a)||0,oe=z?`$${Q.toFixed(Q<.01&&Q>0?4:2)}`:te?Pt(a):a,j;return g||d===0?j="0%":d>0&&d<1?j="<1%":j=`${f}%`,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:D},v),e.createElement(i,{color:s.textMuted}," ",j," (",oe,"/",W,")"))},Dc=()=>{switch(Mt){case"settings":return e.createElement(fs,{systemSettings:le,setSystemSettings:Ft,apiTier:et,setActiveView:ie,setInputConfig:mo,saveSettings:qt,quotas:De,setMessages:L,aiProvider:U,autoCompletion:ar,setAutoCompletion:Ds,profileData:$n,setProfileData:Es,setProviderReturnView:vs,setApiKey:Nt,initAI:yo});case"theme":return e.createElement(fs,{systemSettings:le,setSystemSettings:Ft,apiTier:et,setActiveView:ie,setInputConfig:mo,saveSettings:qt,quotas:De,setMessages:L,aiProvider:U,autoCompletion:ar,setAutoCompletion:Ds,profileData:$n,setProfileData:Es,initialSelectingTheme:!0,onCloseTheme:()=>ie("chat"),setProviderReturnView:vs,setApiKey:Nt,initAI:yo});case"selectProvider":return e.createElement(Ut,{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:nn}],theme:le.theme,onSelect:async o=>{if(o.value===nn||o.value==="settings"||o.value==="Back"){ie(nn);return}let n=o.value,h=await dn(n),g="";if(n==="9router"){let d=await Ei();d.ok||(g=`
284
284
 
285
285
  \x1B[33m\u2726 WARNING: 9router does not appear to be running on ${d.url}.\x1B[39m
286
286
  \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(!le.customOpenAIBaseUrl){mo({label:"Enter Custom OpenAI Base URL (.../v1):",key:"customOpenAIBaseUrl",value:"",returnView:nn}),ie("input");return}let d=h||"";try{ti()}catch{}on(n),Nt(d),yo(d,{aiProvider:n,onIDEApproval:No});let f=(De.providerTiers||{})[n]||"Free",b=bo(n,f)||"";jt(b),kt(f),Ft(v=>({...v,memory:!1})),qt({aiProvider:n,activeModel:b,apiTier:f,quotas:De,systemSettings:{...le,memory:!1}}),L(v=>[...v,{role:"system",text:`\u2726 Switched to Custom (OpenAI)!${b?`
@@ -1,3 +1,3 @@
1
- import{C as u}from"./chunk-24LJKH4G.js";import"./chunk-HFTI3R3Q.js";import"./chunk-52STSLCN.js";import"./chunk-56EJGQU3.js";import"./chunk-4BLSASW6.js";import"./chunk-7SGZ66KT.js";import"./chunk-UIL6OCU4.js";import"./chunk-EXT42EJZ.js";import"./chunk-6EYQQ7GQ.js";import"./chunk-Y5JU726N.js";import{b as p}from"./chunk-QESQR5GB.js";import"./chunk-J4J3F6BT.js";import"./chunk-V36DXF56.js";import{b as d}from"./chunk-B4UKMX5E.js";import{o as a}from"./chunk-LQM3JK7N.js";import"./chunk-P5HBJA23.js";import{a as l}from"./chunk-26BQ45XP.js";import m from"fs";import g from"path";var f=["Identity: Embedded IDE code completion engine","Context given: Code \xB1 cursor, file name & language","Task: Predict contextually accurate code at cursor position","","Rules:","- Return ONLY the raw code to insert at the cursor. No explanations, commentary or rambling","- Do NOT wrap in markdown code fences","- NEVER repeat code that exist before & after cursor, if nothing sensible possible to predict, return empty string","- Match surrounding indentation and code style","- Complete the current line statement","- Never include placeholder comments like // TODO or # your code here","- Do not put anything except the code to insert between the tags"].join(`
1
+ import{C as u}from"./chunk-WS35FH7W.js";import"./chunk-HFTI3R3Q.js";import"./chunk-52STSLCN.js";import"./chunk-56EJGQU3.js";import"./chunk-4BLSASW6.js";import"./chunk-7SGZ66KT.js";import"./chunk-UIL6OCU4.js";import"./chunk-EXT42EJZ.js";import"./chunk-6EYQQ7GQ.js";import"./chunk-Y5JU726N.js";import{b as p}from"./chunk-QESQR5GB.js";import"./chunk-J4J3F6BT.js";import"./chunk-V36DXF56.js";import{b as d}from"./chunk-B4UKMX5E.js";import{o as a}from"./chunk-LQM3JK7N.js";import"./chunk-P5HBJA23.js";import{a as l}from"./chunk-26BQ45XP.js";import m from"fs";import g from"path";var f=["Identity: Embedded IDE code completion engine","Context given: Code \xB1 cursor, file name & language","Task: Predict contextually accurate code at cursor position","","Rules:","- Return ONLY the raw code to insert at the cursor. No explanations, commentary or rambling","- Do NOT wrap in markdown code fences","- NEVER repeat code that exist before & after cursor, if nothing sensible possible to predict, return empty string","- Match surrounding indentation and code style","- Complete the current line statement","- Never include placeholder comments like // TODO or # your code here","- Do not put anything except the code to insert between the tags"].join(`
2
2
  `);try{let t=g.join(l,".cache");m.existsSync(t)||m.mkdirSync(t,{recursive:!0}),m.writeFileSync(g.join(t,"completion.json"),JSON.stringify({systemPrompt:f},null,2))}catch{}var y=t=>{if(!t)return"";let e=t.match(/<completion>([\s\S]*?)<\/completion>/i);return e?e[1]:t},x=({prefix:t="",suffix:e="",fileName:o="",language:n="",recentChanges:r="",clipboard:i=""})=>{let c=r?["### Recent manual changes (context):",r,""]:[],s=i?["### Clipboard (context):",i,""]:[];return[`File: ${o}`,`Language: ${n}`,"","### Code before cursor:",t,"","[cursor here]","","### Code after cursor:",e,"",...c,...s,"### Completion to insert at cursor:"].join(`
3
3
  `)},T=async(t={})=>{try{let e=await d(),o=e.autoCompletion||{};if(!o.enabled)return"";let n=o.provider||e.aiProvider||"Google",r=o.model&&o.model!=="Default"?o.model:e.activeModel||a(n,e.apiTier)||a(n,"paid");if(!r)return"";let i=await p(n);if(!i&&!(n==="c_openai"&&e.systemSettings?.customOpenAIBaseUrl))return"";let c={aiProvider:n,apiKey:i,model:r,mode:"flow",thinkingLevel:"Fast",systemSettings:e.systemSettings||{}},s=[{role:"user",parts:[{text:x(t)}]}],{text:h}=await u(c,r,s,f,"Fast");return y(h||"")}catch{return""}};export{f as AUTOCOMPLETE_SYSTEM_PROMPT,y as extractCompletion,T as generateAutoCompletion};