fluxflow-cli 5.2.1 → 5.2.3

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,4 +1,4 @@
1
- import{a as Xs}from"./chunk-XPIXBWTZ.js";import{a as So}from"./chunk-BLAXTPPN.js";import{a as Dt}from"./chunk-56EJGQU3.js";import{a as Js}from"./chunk-L22YGL6T.js";import{c as Hi,g as ji,h as js,i as Ks,j as Vs}from"./chunk-KIPZOUEA.js";import{b as zs,c as qs,d as Ki,f as Ys}from"./chunk-BNKY5QOA.js";import{a as oi}from"./chunk-KOCMIEPK.js";import{a as D}from"./chunk-Y5JU726N.js";import{b as Hs}from"./chunk-25EUCCH5.js";import{y as Wi}from"./chunk-7CCULUZN.js";import{f as ni,l as Ct,o as Ui,p as dn,r as Gi}from"./chunk-XAPXZ6KO.js";import{b as ti}from"./chunk-UMS5SEYB.js";import{l as tt,m as ei}from"./chunk-75OCC24T.js";import{c as cn,d as Bi,e as Zo}from"./chunk-NTZSL2UT.js";import{a as _n,b as Jo,c as Bs,d as Gn,e as Ws,k as Qo,l as Ni,m as Us,r as Fi,w as wo,x as bo,y as Gs,z as ln}from"./chunk-YFIWMGCS.js";import{GoogleGenAI as ga,ThinkingLevel as Ye,HarmBlockThreshold as bi,HarmCategory as Si}from"@google/genai";var ii={xHigh:"Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking",High:"Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking",Medium:"Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking",Minimal:"Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking",Off:"NO thinking. Immediate response. Verify imports, tool results & system stability"};import Vt from"fs";import Kt from"path";import ja from"os";import fn from"fs";import In from"path";import dr from"fs";import Vi from"path";import{execSync as fr}from"child_process";import{fileURLToPath as Ua}from"url";var Qs=`# FluxFlow CLI Startup & Flags Reference
1
+ import{a as Xs}from"./chunk-XPIXBWTZ.js";import{a as So}from"./chunk-BLAXTPPN.js";import{a as Nt}from"./chunk-56EJGQU3.js";import{a as Js}from"./chunk-L22YGL6T.js";import{c as Hi,g as ji,h as js,i as Ks,j as Vs}from"./chunk-KIPZOUEA.js";import{b as zs,c as qs,d as Ki,f as Ys}from"./chunk-BNKY5QOA.js";import{a as oi}from"./chunk-KOCMIEPK.js";import{a as D}from"./chunk-Y5JU726N.js";import{b as Hs}from"./chunk-25EUCCH5.js";import{y as Wi}from"./chunk-7CCULUZN.js";import{f as ni,l as vt,o as Ui,p as dn,r as Gi}from"./chunk-XAPXZ6KO.js";import{b as ti}from"./chunk-UMS5SEYB.js";import{l as nt,m as ei}from"./chunk-75OCC24T.js";import{c as cn,d as Bi,e as Zo}from"./chunk-NTZSL2UT.js";import{a as _n,b as Jo,c as Bs,d as Gn,e as Ws,k as Qo,l as Ni,m as Us,r as Fi,w as bo,x as wo,y as Gs,z as ln}from"./chunk-YFIWMGCS.js";import{GoogleGenAI as ga,ThinkingLevel as Ye,HarmBlockThreshold as wi,HarmCategory as Si}from"@google/genai";var ii={xHigh:"Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking",High:"Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking",Medium:"Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking",Minimal:"Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking",Off:"NO thinking. Immediate response. Verify imports, tool results & system stability"};import Vt from"fs";import Kt from"path";import ja from"os";import fn from"fs";import In from"path";import dr from"fs";import Vi from"path";import{execSync as fr}from"child_process";import{fileURLToPath as Ua}from"url";var Qs=`# FluxFlow CLI Startup & Flags Reference
2
2
 
3
3
  Launch command syntax:
4
4
  fluxflow [options]
@@ -457,13 +457,13 @@ Public Docs: https://fluxflow-cli.onrender.com
457
457
  Default Context Length: 256k Tokens. Can be changed via ENV/In-app Settings \u2192 references/{SETTINGS,ENV}.md
458
458
 
459
459
  Docs missing required info? Say you are not sure enough to answer. Dont give wrong info`,"references/MODES.md":ar,"references/PROVIDERS.md":lr,"references/PLUGINS.md":cr,"references/STARTUP.md":Qs,"references/ENV.md":Zs,"references/COMMANDS.md":er,"references/SETTINGS.md":tr,"references/TOOLS.md":nr,"references/ARCHITECTURE.md":or,"references/SUB_AGENTS.md":ir,"references/SECURITY.md":sr,"references/IDE.md":rr};var ur=()=>{try{let e=In.join(_n,"skills","fluxflow"),n=In.join(e,"references");if(process.env.NO_DEV==="true"||process.env.NO_DEV==="1"||process.env.NO_DEV===!0||process.env.NO_INS==="true"||process.env.NO_INS==="1"||process.env.NO_INS==="true"||!1){fn.existsSync(e)&&fn.rmSync(e,{recursive:!0,force:!0});return}let i=new Set(Object.keys(zi).map(o=>In.normalize(o)));for(let[o,r]of Object.entries(zi)){let d=In.join(e,o),l=In.dirname(d);fn.existsSync(l)||fn.mkdirSync(l,{recursive:!0});let u=r.trim()+`
460
- `,g=null;fn.existsSync(d)&&(g=fn.readFileSync(d,"utf8")),g!==u&&fn.writeFileSync(d,u,"utf8")}if(fn.existsSync(n)){let o=fn.readdirSync(n);for(let r of o){let d=In.normalize(In.join("references",r));if(!i.has(d)){let l=In.join(n,r);try{fn.rmSync(l,{recursive:!0,force:!0})}catch{}}}}}catch{}};import{WebSocket as ri}from"ws";var Mt=null,io=!1,Ga="ws://localhost:56832",qi=[],so=null,Yi=null,Xi=null,gr="2.0.0",wc=e=>{gr=e,mr()},Ji=e=>{Yi=e},bc=e=>{Xi=e},mr=()=>{if(Mt||io)return;io=!0;let e=new ri(Ga);e.on("open",()=>{for(Mt=e,io=!1,Mt.send(JSON.stringify({command:"version",version:gr,pid:process.pid,ppid:process.ppid,cwd:process.cwd()}));qi.length>0;)Mt.send(JSON.stringify(qi.shift()))}),e.on("message",n=>{try{let t=JSON.parse(n.toString());t.command==="contextResponse"&&so?(so(t.data),so=null):t.command==="securityResponse"&&Yi?Yi(t.result):t.command==="inlineComplete"?Ha(t):t.command==="connectionRejected"&&Xi&&Xi(t)}catch{}}),e.on("error",()=>{io=!1,Mt=null}),e.on("close",()=>{io=!1,Mt=null})},ko=e=>{Mt&&Mt.readyState===ri.OPEN?Mt.send(JSON.stringify(e)):(qi.push(e),io||mr())},ro=()=>Mt!==null&&Mt.readyState===ri.OPEN,Ha=async e=>{let n="";try{let{generateAutoCompletion:t}=await import("./auto_completion-I2GVIND6.js");n=await t({prefix:e.prefix||"",suffix:e.suffix||"",fileName:e.fileName||"",language:e.language||"",recentChanges:e.recentChanges||"",clipboard:e.clipboard||""})}catch{n=""}ko({command:"inlineCompleteResponse",requestId:e.requestId,completion:n||""})},Sc=e=>{ko({command:"status",status:e})},Hn=()=>new Promise(e=>{if(!Mt||Mt.readyState!==ri.OPEN){e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]});return}so=e,Mt.send(JSON.stringify({command:"requestContext"})),setTimeout(()=>{so===e&&(e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]}),so=null)},1e3)}),pr=e=>{let{resolvedPath:n}=ln(e);ko({command:"open",filePath:n})},Qi=(e,n,t)=>{let{resolvedPath:i}=ln(e);ko({command:"showDiff",filePath:i,originalContent:n,modifiedContent:t})},hr=(e,n)=>{let{resolvedPath:t}=ln(e);ko({command:"closeDiff",filePath:t,result:n})};var _o=(e,n)=>{try{if(!Vt.existsSync(e))return null;let t=Array.isArray(n)?n.map(o=>o.toLowerCase()):[n.toLowerCase()],i=Vt.readdirSync(e);for(let o of t){let r=i.find(d=>d.toLowerCase()===o);if(r){let d=Kt.join(e,r);if(Vt.statSync(d).isFile())return d}}}catch{}return null},os=(e,n)=>{let t=_o(e,n);if(t)try{return Vt.readFileSync(t,"utf8")}catch{}return""},yr=new Set([".git","node_modules",".gemini","dist","build",".next","out",".cache","bin","obj","vendor","venv",".idea",".gradle",".terraform","target","coverage",".vscode",".svn",".hg",".fslckout",".github",".gitlab",".circleci",".gitea",".gitee",".lerna",".changeset",".nx",".npm",".yarn",".pnpm-store",".pnpm",".expo",".nuxt",".svelte-kit",".docusaurus",".turbo",".vercel","bower_components",".netlify",".vuepress",".quasar",".output",".angular","jspm_packages",".parcel-cache",".rollup.cache",".rspack",".vitepress","__pycache__",".pytest_cache",".mypy_cache",".tox",".poetry","env","vhdl",".ipynb_checkpoints",".jupyter",".conda",".pdm-build",".bundle",".yardoc",".metadata","App_Data","ClientBin",".cargo",".rustc_info",".go","Godeps","_vendor",".rake_tasks","CMakefiles",".wakatime",".dart_tool",".fvm",".cocoapods","Pods",".pub-cache",".symlinks","DerivedData",".xcworkspace",".serverless",".aws",".gcloud",".azure",".kube",".vagrant",".docker","postgres-data","redis-data","mongo-data",".Spotlight-V100",".Trashes","$RECYCLE.BIN","System Volume Information",".DocumentRevisions-V100",".fseventsd","AppData","Application Data","Local","LocalLow","Roaming","$WinREAgent","$WINDOWS.~BT","$WINDOWS.~WS","scw","System32","SysWOW64",".AppleDouble",".AppleDB",".AppleDesktop","_CodeSignature",".cmio",".LSOverride",".localized",".TemporaryItems",".Trash",".Trash-0",".Trash-1000",".gvfs",".local",".config",".dbus",".fontconfig",".snap",".var",".lost+found","lost+found",".thumb",".thumbnails","EFI","boot","grub","logs","log",".nyc_output",".sonar",".ruff_cache",".VSCodeCounter",".skills","skills"]),is=(e=process.cwd(),n=0,t=8)=>{let i=[];if(n>t)return i;try{if(!Vt.existsSync(e))return i;let o=Vt.readdirSync(e,{withFileTypes:!0});for(let r of o){let d=r.name,l=Kt.join(e,d);if(r.isDirectory())!yr.has(d)&&!yr.has(d.toLowerCase())&&i.push(...is(l,n+1,t));else if(r.isFile()){let u=d.toLowerCase();(u==="agents.md"||u==="agent.md")&&i.push(l)}}}catch{}return i},xr=(e,n=2)=>{if(!e)return"";let t=" ".repeat(n);return e.split(/\r?\n/).map(i=>t+i).join(`
461
- `)},Tr=()=>_o(_n,["agents.md","agent.md"]),Ar=()=>_o(process.cwd(),["agents.md","agent.md"]),Cr=()=>_o(_n,["fluxflow.md"]),vr=()=>_o(process.cwd(),["fluxflow.md"]),Ao=Tr(),ai=Ar(),un=is(),Co=Cr(),vo=vr(),wr=null,ns="",Rr=!1,Ka=e=>{if(!e||!/^<<<[\s\S]*?Identity:/m.test(e))return e;let n=e.match(/^<<<\s*\r?\n([\s\S]*?)\r?\n>>>\s*(?:\r?\n)?([\s\S]*)$/);if(!n)return e;let t=n[1],i=n[2],o=t.match(/^Identity:\s*([\s\S]*?)(?=\r?\n\s*(?:<><|>>>)|$)/m);return o&&(ns=o[1].trim(),process.env.NO_INS=!0),/<><\s*NO_INS/.test(t)&&(Rr=!0),i.trim()},Va=()=>{Ao=Tr();let e=Ao?os(_n,["agents.md","agent.md"]).trim():"";return e.length===0?(Ao=null,""):e},za=()=>{if(un=is(),ai=Ar(),!un||un.length===0)return"";let e=process.cwd(),n=[...un].sort((o,r)=>{let d=Kt.relative(e,o).replace(/\\/g,"/"),l=Kt.relative(e,r).replace(/\\/g,"/"),u=!d.includes("/"),g=!l.includes("/");return u&&!g?-1:!u&&g?1:d.localeCompare(l)}),t=[],i=[];for(let o of n)try{let r=Vt.readFileSync(o,"utf8").trim();if(!r||r.length===0)continue;t.push(o);let d=Kt.relative(e,o).replace(/\\/g,"/");if(!d.includes("/"))i.push(xr(r,2));else{let u=Kt.dirname(d)+"/:";i.push(`${u}
460
+ `,g=null;fn.existsSync(d)&&(g=fn.readFileSync(d,"utf8")),g!==u&&fn.writeFileSync(d,u,"utf8")}if(fn.existsSync(n)){let o=fn.readdirSync(n);for(let r of o){let d=In.normalize(In.join("references",r));if(!i.has(d)){let l=In.join(n,r);try{fn.rmSync(l,{recursive:!0,force:!0})}catch{}}}}}catch{}};import{WebSocket as ri}from"ws";var Pt=null,io=!1,Ga="ws://localhost:56832",qi=[],so=null,Yi=null,Xi=null,gr="2.0.0",bc=e=>{gr=e,mr()},Ji=e=>{Yi=e},wc=e=>{Xi=e},mr=()=>{if(Pt||io)return;io=!0;let e=new ri(Ga);e.on("open",()=>{for(Pt=e,io=!1,Pt.send(JSON.stringify({command:"version",version:gr,pid:process.pid,ppid:process.ppid,cwd:process.cwd()}));qi.length>0;)Pt.send(JSON.stringify(qi.shift()))}),e.on("message",n=>{try{let t=JSON.parse(n.toString());t.command==="contextResponse"&&so?(so(t.data),so=null):t.command==="securityResponse"&&Yi?Yi(t.result):t.command==="inlineComplete"?Ha(t):t.command==="connectionRejected"&&Xi&&Xi(t)}catch{}}),e.on("error",()=>{io=!1,Pt=null}),e.on("close",()=>{io=!1,Pt=null})},ko=e=>{Pt&&Pt.readyState===ri.OPEN?Pt.send(JSON.stringify(e)):(qi.push(e),io||mr())},ro=()=>Pt!==null&&Pt.readyState===ri.OPEN,Ha=async e=>{let n="";try{let{generateAutoCompletion:t}=await import("./auto_completion-OZQRLAX5.js");n=await t({prefix:e.prefix||"",suffix:e.suffix||"",fileName:e.fileName||"",language:e.language||"",recentChanges:e.recentChanges||"",clipboard:e.clipboard||""})}catch{n=""}ko({command:"inlineCompleteResponse",requestId:e.requestId,completion:n||""})},Sc=e=>{ko({command:"status",status:e})},Hn=()=>new Promise(e=>{if(!Pt||Pt.readyState!==ri.OPEN){e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]});return}so=e,Pt.send(JSON.stringify({command:"requestContext"})),setTimeout(()=>{so===e&&(e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]}),so=null)},1e3)}),pr=e=>{let{resolvedPath:n}=ln(e);ko({command:"open",filePath:n})},Qi=(e,n,t)=>{let{resolvedPath:i}=ln(e);ko({command:"showDiff",filePath:i,originalContent:n,modifiedContent:t})},hr=(e,n)=>{let{resolvedPath:t}=ln(e);ko({command:"closeDiff",filePath:t,result:n})};var _o=(e,n)=>{try{if(!Vt.existsSync(e))return null;let t=Array.isArray(n)?n.map(o=>o.toLowerCase()):[n.toLowerCase()],i=Vt.readdirSync(e);for(let o of t){let r=i.find(d=>d.toLowerCase()===o);if(r){let d=Kt.join(e,r);if(Vt.statSync(d).isFile())return d}}}catch{}return null},os=(e,n)=>{let t=_o(e,n);if(t)try{return Vt.readFileSync(t,"utf8")}catch{}return""},yr=new Set([".git","node_modules",".gemini","dist","build",".next","out",".cache","bin","obj","vendor","venv",".idea",".gradle",".terraform","target","coverage",".vscode",".svn",".hg",".fslckout",".github",".gitlab",".circleci",".gitea",".gitee",".lerna",".changeset",".nx",".npm",".yarn",".pnpm-store",".pnpm",".expo",".nuxt",".svelte-kit",".docusaurus",".turbo",".vercel","bower_components",".netlify",".vuepress",".quasar",".output",".angular","jspm_packages",".parcel-cache",".rollup.cache",".rspack",".vitepress","__pycache__",".pytest_cache",".mypy_cache",".tox",".poetry","env","vhdl",".ipynb_checkpoints",".jupyter",".conda",".pdm-build",".bundle",".yardoc",".metadata","App_Data","ClientBin",".cargo",".rustc_info",".go","Godeps","_vendor",".rake_tasks","CMakefiles",".wakatime",".dart_tool",".fvm",".cocoapods","Pods",".pub-cache",".symlinks","DerivedData",".xcworkspace",".serverless",".aws",".gcloud",".azure",".kube",".vagrant",".docker","postgres-data","redis-data","mongo-data",".Spotlight-V100",".Trashes","$RECYCLE.BIN","System Volume Information",".DocumentRevisions-V100",".fseventsd","AppData","Application Data","Local","LocalLow","Roaming","$WinREAgent","$WINDOWS.~BT","$WINDOWS.~WS","scw","System32","SysWOW64",".AppleDouble",".AppleDB",".AppleDesktop","_CodeSignature",".cmio",".LSOverride",".localized",".TemporaryItems",".Trash",".Trash-0",".Trash-1000",".gvfs",".local",".config",".dbus",".fontconfig",".snap",".var",".lost+found","lost+found",".thumb",".thumbnails","EFI","boot","grub","logs","log",".nyc_output",".sonar",".ruff_cache",".VSCodeCounter",".skills","skills"]),is=(e=process.cwd(),n=0,t=8)=>{let i=[];if(n>t)return i;try{if(!Vt.existsSync(e))return i;let o=Vt.readdirSync(e,{withFileTypes:!0});for(let r of o){let d=r.name,l=Kt.join(e,d);if(r.isDirectory())!yr.has(d)&&!yr.has(d.toLowerCase())&&i.push(...is(l,n+1,t));else if(r.isFile()){let u=d.toLowerCase();(u==="agents.md"||u==="agent.md")&&i.push(l)}}}catch{}return i},xr=(e,n=2)=>{if(!e)return"";let t=" ".repeat(n);return e.split(/\r?\n/).map(i=>t+i).join(`
461
+ `)},Tr=()=>_o(_n,["agents.md","agent.md"]),Ar=()=>_o(process.cwd(),["agents.md","agent.md"]),Cr=()=>_o(_n,["fluxflow.md"]),vr=()=>_o(process.cwd(),["fluxflow.md"]),Ao=Tr(),ai=Ar(),un=is(),Co=Cr(),vo=vr(),br=null,ns="",Rr=!1,Ka=e=>{if(!e||!/^<<<[\s\S]*?Identity:/m.test(e))return e;let n=e.match(/^<<<\s*\r?\n([\s\S]*?)\r?\n>>>\s*(?:\r?\n)?([\s\S]*)$/);if(!n)return e;let t=n[1],i=n[2],o=t.match(/^Identity:\s*([\s\S]*?)(?=\r?\n\s*(?:<><|>>>)|$)/m);return o&&(ns=o[1].trim(),process.env.NO_INS=!0),/<><\s*NO_INS/.test(t)&&(Rr=!0),i.trim()},Va=()=>{Ao=Tr();let e=Ao?os(_n,["agents.md","agent.md"]).trim():"";return e.length===0?(Ao=null,""):e},za=()=>{if(un=is(),ai=Ar(),!un||un.length===0)return"";let e=process.cwd(),n=[...un].sort((o,r)=>{let d=Kt.relative(e,o).replace(/\\/g,"/"),l=Kt.relative(e,r).replace(/\\/g,"/"),u=!d.includes("/"),g=!l.includes("/");return u&&!g?-1:!u&&g?1:d.localeCompare(l)}),t=[],i=[];for(let o of n)try{let r=Vt.readFileSync(o,"utf8").trim();if(!r||r.length===0)continue;t.push(o);let d=Kt.relative(e,o).replace(/\\/g,"/");if(!d.includes("/"))i.push(xr(r,2));else{let u=Kt.dirname(d)+"/:";i.push(`${u}
462
462
  ${xr(r,2)}`)}}catch{}return un=t,un.length===0&&(ai=null),i.join(`
463
463
 
464
- `).trim()},ss=()=>{Co=Cr();let e=Co?os(_n,["fluxflow.md"]).trim():"",n=Ka(e)?.trim()||"";return n.length===0?(Co=null,""):n},rs=()=>{vo=vr();let e=vo?os(process.cwd(),["fluxflow.md"]).trim():"";return e.length===0?(vo=null,""):e},as=Va(),li=za(),Ro=ss(),Eo=rs(),br=(e,n="",t="")=>{if(!e)return"";let i=t.toLowerCase().trim(),o=n.toLowerCase().trim(),r=Kt.posix.basename(o),d=i&&o?`${i}@${o}`:"",l=i&&r?`${i}@${r}`:"",u=h=>!h||!o?!1:h===o||h===r||h===d||h===l,g=[];return e.replace(/<start_provider_([^>\r\n]+)>([\s\S]*?)<end_provider_([^>\r\n]+)>/gi,(h,m,p,s)=>{if(i&&m.trim().toLowerCase()===s.trim().toLowerCase()&&m.trim().toLowerCase()===i){let _=p.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,($e,v,N,P)=>{if(v.trim().toLowerCase()===P.trim().toLowerCase()){let V=v.trim().toLowerCase();if(u(V)){let M=N.trim();M&&g.push(M)}}return""}).trim();_&&g.push(_)}return""}),e.replace(/<start_model_([^>\r\n@]+@[^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n@]+@[^>\r\n]+)>/gi,(h,m,p,s)=>{if(m.trim().toLowerCase()===s.trim().toLowerCase()){let w=m.trim().toLowerCase();if(u(w)){let _=p.trim();_&&g.push(_)}}return""}),e.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(h,m,p,s)=>{if(m.includes("@"))return"";if(m.trim().toLowerCase()===s.trim().toLowerCase()){let w=m.trim().toLowerCase();if(o&&(w===o||w===r)){let _=p.trim();_&&g.push(_)}}return""}),g.join(`
464
+ `).trim()},ss=()=>{Co=Cr();let e=Co?os(_n,["fluxflow.md"]).trim():"",n=Ka(e)?.trim()||"";return n.length===0?(Co=null,""):n},rs=()=>{vo=vr();let e=vo?os(process.cwd(),["fluxflow.md"]).trim():"";return e.length===0?(vo=null,""):e},as=Va(),li=za(),Ro=ss(),Eo=rs(),wr=(e,n="",t="")=>{if(!e)return"";let i=t.toLowerCase().trim(),o=n.toLowerCase().trim(),r=Kt.posix.basename(o),d=i&&o?`${i}@${o}`:"",l=i&&r?`${i}@${r}`:"",u=h=>!h||!o?!1:h===o||h===r||h===d||h===l,g=[];return e.replace(/<start_provider_([^>\r\n]+)>([\s\S]*?)<end_provider_([^>\r\n]+)>/gi,(h,m,p,s)=>{if(i&&m.trim().toLowerCase()===s.trim().toLowerCase()&&m.trim().toLowerCase()===i){let _=p.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(Le,v,N,P)=>{if(v.trim().toLowerCase()===P.trim().toLowerCase()){let z=v.trim().toLowerCase();if(u(z)){let M=N.trim();M&&g.push(M)}}return""}).trim();_&&g.push(_)}return""}),e.replace(/<start_model_([^>\r\n@]+@[^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n@]+@[^>\r\n]+)>/gi,(h,m,p,s)=>{if(m.trim().toLowerCase()===s.trim().toLowerCase()){let b=m.trim().toLowerCase();if(u(b)){let _=p.trim();_&&g.push(_)}}return""}),e.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(h,m,p,s)=>{if(m.includes("@"))return"";if(m.trim().toLowerCase()===s.trim().toLowerCase()){let b=m.trim().toLowerCase();if(o&&(b===o||b===r)){let _=p.trim();_&&g.push(_)}}return""}),g.join(`
465
465
 
466
- `).trim()},qa=(e="",n="")=>{let t=`${e||""}@${n||""}`.toLowerCase().trim();wr!==t&&(wr=t,Ro=ss(),Eo=rs())};ur();var Ya=e=>{if(!e)return null;let n=e.match(/^\s*---\r?\n([\s\S]*?)\r?\n---(?:\r?\n)?([\s\S]*)$/);if(!n)return null;let t=n[1];if((n[2]||"").trim().length===0)return null;let o="",r="",d=t.match(/^name:\s*(.+)$/m),l=t.match(/^description:\s*(.+)$/m);return d&&(o=d[1].trim().replace(/^["']|["']$/g,"")),l&&(r=l[1].trim().replace(/^["']|["']$/g,"")),o&&r?{name:o,description:r}:null},Xa=e=>{let n=[];if(!e||!Vt.existsSync(e))return n;let t=(i,o=0)=>{if(!(o>5))try{let r=Vt.readdirSync(i,{withFileTypes:!0});for(let d of r){let l=Kt.join(i,d.name),u=d.name.toLowerCase();d.isFile()?u==="skill.md"&&n.push(l):d.isDirectory()&&(o===0?(u==="skills"||u===".skills"||u==="skill"||u===".skill")&&t(l,o+1):t(l,o+1))}}catch{}};return t(e,0),n},Er=e=>{let n=Xa(e),t=[];for(let i of n)try{let o=Vt.readFileSync(i,"utf8"),r=Ya(o);r&&t.push({...r,filePath:i})}catch{}return t},_r=e=>!e||e.length===0?"":e.map(n=>`- ${n.name}: ${n.description}`).join(`
466
+ `).trim()},qa=(e="",n="")=>{let t=`${e||""}@${n||""}`.toLowerCase().trim();br!==t&&(br=t,Ro=ss(),Eo=rs())};ur();var Ya=e=>{if(!e)return null;let n=e.match(/^\s*---\r?\n([\s\S]*?)\r?\n---(?:\r?\n)?([\s\S]*)$/);if(!n)return null;let t=n[1];if((n[2]||"").trim().length===0)return null;let o="",r="",d=t.match(/^name:\s*(.+)$/m),l=t.match(/^description:\s*(.+)$/m);return d&&(o=d[1].trim().replace(/^["']|["']$/g,"")),l&&(r=l[1].trim().replace(/^["']|["']$/g,"")),o&&r?{name:o,description:r}:null},Xa=e=>{let n=[];if(!e||!Vt.existsSync(e))return n;let t=(i,o=0)=>{if(!(o>5))try{let r=Vt.readdirSync(i,{withFileTypes:!0});for(let d of r){let l=Kt.join(i,d.name),u=d.name.toLowerCase();d.isFile()?u==="skill.md"&&n.push(l):d.isDirectory()&&(o===0?(u==="skills"||u===".skills"||u==="skill"||u===".skill")&&t(l,o+1):t(l,o+1))}}catch{}};return t(e,0),n},Er=e=>{let n=Xa(e),t=[];for(let i of n)try{let o=Vt.readFileSync(i,"utf8"),r=Ya(o);r&&t.push({...r,filePath:i})}catch{}return t},_r=e=>!e||e.length===0?"":e.map(n=>`- ${n.name}: ${n.description}`).join(`
467
467
  `),ci=Er(_n),di=Er(process.cwd()),Zi=_r(ci),es=_r(di),Ir=e=>{if(!e)return!1;let n=(e.filePath||"").replace(/\\/g,"/").toLowerCase();return n.includes("/skills/fluxflow/skill.md")||n.includes("/skills/about-fluxflow/skill.md")||e.name?.toLowerCase()==="fluxflow"},Mr=()=>(ci||[]).filter(e=>!Ir(e)),Pr=()=>(di||[]).filter(e=>!Ir(e)),Nc=(as?.length>0?1:0)+(li?.length>0?un.length:0)+(Ro?.length>0?1:0)+(Eo?.length>0?1:0)+Mr().length+Pr().length,ts=(e,n="Project")=>{if(!e)return"";let t=e.replace(/\\/g,"/");if(n==="Global"){let o=ja.homedir().replace(/\\/g,"/");return t.toLowerCase().startsWith(o.toLowerCase())?"~"+t.slice(o.length):t}let i=Kt.relative(process.cwd(),e).replace(/\\/g,"/");return i.startsWith(".")?i:`./${i}`},Fc=()=>{Ro=ss(),Eo=rs();let e=[];Ao&&as.length>0&&e.push({scope:"Global",path:Ao}),un&&un.length>0&&li.length>0?un.forEach(r=>{e.push({scope:"Project",path:r})}):ai&&li.length>0&&e.push({scope:"Project",path:ai}),Co&&Ro.length>0&&e.push({scope:"Global",path:Co}),vo&&Eo.length>0&&e.push({scope:"Project",path:vo});let n=Mr(),t=Pr(),i=e.length+n.length+t.length;if(i===0)return`\u2726 Loaded Files & Instructions
468
468
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No instruction or skill files are currently loaded.
469
469
  \u2800`;let o=[];return o.push(`\u2726 Loaded Files & Instructions (${i} ${i===1?"file":"files"} active)`),e.length>0&&(o.push(`
@@ -475,18 +475,18 @@ ${xr(r,2)}`)}}catch{}return un=t,un.length===0&&(ai=null),i.join(`
475
475
 
476
476
  `)}catch{}}}return To};var Lr=(e,n,t,i,o=!0,r=!1,d="Google",l=!1,u,g,h=!1,m="")=>{let p=!1;process.env.forcedReasoning&&(p=!0);let s="";if(!u&&d==="Google"){let Re=n;n==="Fast"&&(Re="Off"),n==="Low"&&(Re="Minimal"),n==="Standard"&&(Re="Medium"),(n==="xHigh"||n==="Max")&&(Re="xHigh"),s=ii[Re]||ii.Medium}(u||d!=="Google")&&(s=ii.xHigh,n==="Fast"?s=`No thinking. Immediate response
477
477
  Verify imports, tool results & system stability`:n.toLowerCase()==="max"&&(s=`Effort: Max
478
- Plan step by step`));let w=e.instructions&&e.instructions?.length>0?`User Preferences: ${e.instructions}
478
+ Plan step by step`));let b=e.instructions&&e.instructions?.length>0?`User Preferences: ${e.instructions}
479
479
 
480
480
  `:"",_=e.nickname&&e.nickname?.length>0?`User Nickname: ${e.nickname}
481
- ${w.length?"":`
482
- `}`:"",$e=e.name&&e.name?.length>0?`User Name: ${e.name}
483
- ${_.length||w.length?"":`
484
- `}`:"",v=process.cwd(),N=e.preset,V={Sassy:"Sassy",Friendly:"Sassy, Warm & Chatty",Playful:"Playful",Efficient:"Quick, Concise & Efficient",Professional:"Professional"}[N]||null,M=Ja(g,o),$=M?.length>0?`--- Saved Memories ---
481
+ ${b.length?"":`
482
+ `}`:"",Le=e.name&&e.name?.length>0?`User Name: ${e.name}
483
+ ${_.length||b.length?"":`
484
+ `}`:"",v=process.cwd(),N=e.preset,z={Sassy:"Sassy",Friendly:"Sassy, Warm & Chatty",Playful:"Playful",Efficient:"Quick, Concise & Efficient",Professional:"Professional"}[N]||null,M=Ja(g,o),$=M?.length>0?`--- Saved Memories ---
485
485
  ${M}
486
486
 
487
- `:"";qa(d,m);let ye=br(Ro,m,d).trim(),Ie=[as,ye].filter(Re=>Re&&Re.length>0).join(`
487
+ `:"";qa(d,m);let xe=wr(Ro,m,d).trim(),Ie=[as,xe].filter(Re=>Re&&Re.length>0).join(`
488
488
 
489
- `).trim(),Xe=br(Eo,m,d).trim(),x=[li,Xe].filter(Re=>Re&&Re.length>0).join(`
489
+ `).trim(),Je=wr(Eo,m,d).trim(),x=[li,Je].filter(Re=>Re&&Re.length>0).join(`
490
490
 
491
491
  `).trim(),zt=Ie.length>0||x.length>0?`--- Additional Instructions ---
492
492
  ${Ie.length>0?`-- Global --
@@ -495,8 +495,8 @@ ${Ie}`:""}${x.length>0?`${Ie.length>0?`
495
495
  `:""}-- Project --
496
496
  ${x}`:""}
497
497
 
498
- `:"",De=(()=>{let Re=process.cwd().toLowerCase();if(process.platform==="win32"){let qn=process.env.SystemRoot?.toLowerCase()||"c:\\windows",Yn=process.env.ProgramFiles?.toLowerCase()||"c:\\program files",Q=process.env["ProgramFiles(x86)"]?.toLowerCase()||"c:\\program files (x86)";return Re.startsWith(qn)||Re.startsWith(Yn)||Re.startsWith(Q)}else return Re==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(Yn=>Re.startsWith(Yn))})(),qt=new Date,Ne=qt.getFullYear(),ae=qt.toLocaleString("en-US",{month:"short"}).toUpperCase(),on=String(qt.getDate()).padStart(2,"0"),Vn=`${Ne}-${ae}-${on}`,No=process.env.I_HAVE_TOO_MUCH_MONEY==="true"||!1,Fo=process.env.HALLOWEEN_EEGG==="true"||!1,Bo=Fo&&ae.includes("OCT")&&(on.includes("30")||on.includes("31")),Pn=(m||"").replace(/^.*::/,"").split(":")[0].replace(/\/free$/,"").trim(),zn=Kt.basename(Pn).replace(/-free$/,"").replace(/_free$/,"").replace(/^free_/,"").replaceAll("-"," ").replaceAll("_"," ").replace(/\b\w/g,Re=>Re.toUpperCase().trim()),Yt=process.env.NO_DEV==="true"||!1,$n=!1;try{$n=ro()}catch{$n=!1}return`${No?`${" ".repeat(Math.floor(Math.random()*4)+1)}`:""}=== SYSTEM PROMPT${process.cwd()==="D:\\PROJECTS\\Flux-Flow"?" (Internal testing environment, do as prompted)":""} ===
499
- ${`Identity: ${ns.length>1?ns.trim():`Flux Flow.${V?` ${V}`:""} CLI Assistant${Fo?`. ${Bo?"Peak ":""}Halloween Themed, Spooky`:""}`}
498
+ `:"",Ne=(()=>{let Re=process.cwd().toLowerCase();if(process.platform==="win32"){let qn=process.env.SystemRoot?.toLowerCase()||"c:\\windows",Yn=process.env.ProgramFiles?.toLowerCase()||"c:\\program files",Q=process.env["ProgramFiles(x86)"]?.toLowerCase()||"c:\\program files (x86)";return Re.startsWith(qn)||Re.startsWith(Yn)||Re.startsWith(Q)}else return Re==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(Yn=>Re.startsWith(Yn))})(),qt=new Date,Fe=qt.getFullYear(),ae=qt.toLocaleString("en-US",{month:"short"}).toUpperCase(),on=String(qt.getDate()).padStart(2,"0"),Vn=`${Fe}-${ae}-${on}`,No=process.env.I_HAVE_TOO_MUCH_MONEY==="true"||!1,Fo=process.env.HALLOWEEN_EEGG==="true"||!1,Bo=Fo&&ae.includes("OCT")&&(on.includes("30")||on.includes("31")),Pn=(m||"").replace(/^.*::/,"").split(":")[0].replace(/\/free$/,"").trim(),zn=Kt.basename(Pn).replace(/-free$/,"").replace(/_free$/,"").replace(/^free_/,"").replaceAll("-"," ").replaceAll("_"," ").replace(/\b\w/g,Re=>Re.toUpperCase().trim()),Yt=process.env.NO_DEV==="true"||!1,$n=!1;try{$n=ro()}catch{$n=!1}return`${No?`${" ".repeat(Math.floor(Math.random()*4)+1)}`:""}=== SYSTEM PROMPT${process.cwd()==="D:\\PROJECTS\\Flux-Flow"?" (Internal testing environment, do as prompted)":""} ===
499
+ ${`Identity: ${ns.length>1?ns.trim():`Flux Flow.${z?` ${z}`:""} CLI Assistant${Fo?`. ${Bo?"Peak ":""}Halloween Themed, Spooky`:""}`}
500
500
  ${Rr?"":`${t==="Flux"?"":t==="Flow"?"Concise, Humorous, Sarcastic":t==="ICU"?"Computer Use Capabilities. Screenshot as ground truth, analyze grid ids of target. Keyboard shortcuts > mouse clicks":"Computer Use & Workspace Capabilities. Screenshot as ground truth, analyze grid ids of target. Keyboard shortcuts > mouse clicks. Workspace Actions when faster. Focus on Productivity"}`}${$r&&t.toLowerCase().includes("cu")?`
501
501
  - Running on secondary screen. Opened app not visible in screenshot? Might be opened on primary. Use 'AskUser' with NO options and tell user to move app window to secondary`:""}`.trimEnd()}
502
502
 
@@ -520,13 +520,13 @@ Reference files as ./file:start..end`:""}
520
520
 
521
521
  - Read relevant skills before tasks, scope: global/project: Use ReadFile, path="#skills/scope?/skillName". In-skill references: path="#skills/scope?/skillName/reference-folder/*.md"`:""}
522
522
 
523
- ${_}${w}${zt}${Zi.length>0&&t.toLowerCase().includes("flux")?`-- Global Skills --
523
+ ${_}${b}${zt}${Zi.length>0&&t.toLowerCase().includes("flux")?`-- Global Skills --
524
524
  ${Zi}
525
525
 
526
526
  `:""}${es.length>0&&t.toLowerCase().includes("flux")?`-- Project Skills --
527
527
  ${es}
528
528
 
529
- `:""}`.trim()};var Or=()=>import("./web_search-C3WKDOSZ.js").then(e=>e.web_search),Dr=()=>import("./web_scrape-MVSCRDKO.js").then(e=>e.web_scrape),Nr=()=>import("./memory-AT7ARTG3.js").then(e=>e.memory),Fr=()=>import("./chat-OYRESDTX.js").then(e=>e.chat),Br=()=>import("./view_file-OYV2IEYG.js").then(e=>e.view_file),Wr=()=>import("./write_file-WX4O436W.js").then(e=>e.write_file),Ur=()=>import("./update_file-CH6YILXO.js").then(e=>e.update_file),Gr=()=>import("./exec_command-SQB5LU5X.js").then(e=>e.exec_command),Hr=()=>import("./read_folder-UWFC5DNX.js").then(e=>e.read_folder),ls=()=>import("./ask_user-K2DLZF6H.js").then(e=>e.ask_user),jr=()=>import("./write_pdf-5HOQYVQO.js").then(e=>e.write_pdf),Kr=()=>import("./write_docx-QGW25TF7.js").then(e=>e.write_docx),fi=()=>import("./search_keyword-IRLPX555.js").then(e=>e.search_keyword),Vr=()=>import("./generate_image-7UBJ3ODS.js").then(e=>e.generate_image),ui=()=>import("./saveSummary-ZJDPCZSR.js").then(e=>e.saveSummary),Io=()=>import("./addMemScore-VUSJ2Q64.js").then(e=>e.addMemScore),zr=()=>import("./file_map-K6JQYV35.js").then(e=>e.file_map),gi=()=>import("./todo-YFLPXYFL.js").then(e=>e.todo),qr=()=>import("./invokeSync-EUHHQZ2H.js").then(e=>e.invokeSync),Qa=()=>import("./invoke-IXWW3N4C.js").then(e=>e.invoke),Yr=()=>import("./getProgress-J34K43Y7.js").then(e=>e.getProgress),Za=()=>import("./cancel-F3ZOEBKW.js").then(e=>e.cancel),Xr=()=>import("./emergency_rollback-LC4ZBOLP.js").then(e=>e.emergency_rollback),Mo=()=>import("./awaitSubagent-JKQ2EHVY.js").then(e=>e.awaitSubagent),Po=()=>import("./answerSubagent-BPNNJXPC.js").then(e=>e.answerSubagent),mi=()=>import("./steerSubagent-UETXH2CB.js").then(e=>e.steerSubagent),pi=()=>import("./computer_action-6RHVNLZG.js").then(e=>e.computer_action),Jr=()=>import("./click-3BB6KDIJ.js").then(e=>e.click),Qr=()=>import("./drag-ZGNVQGXW.js").then(e=>e.drag),Zr=()=>import("./scroll-XBXSN2EF.js").then(e=>e.scroll),cs=()=>import("./keyboard_typing-DJ3HHTO7.js").then(e=>e.keyboard_typing),ds=()=>import("./key_press-LO75QEJK.js").then(e=>e.key_press),fs=()=>import("./recapture_screen-LONV6G4U.js").then(e=>e.recapture_screen),hi=()=>import("./find_file-5RUNVQJO.js").then(e=>e.find_file),ea=()=>import("./wait-TJR6LAR4.js").then(e=>e.wait),ta={web_search:Or,web_scrape:Dr,memory:Nr,chat:Fr,view_file:Br,write_file:Wr,update_file:Ur,exec_command:Gr,read_folder:Hr,write_pdf:jr,write_docx:Kr,search_keyword:fi,generate_image:Vr,saveSummary:ui,addMemScore:Io,file_map:zr,todo:gi,Todo:gi,goal:gi,Goal:gi,invokeSync:qr,invoke:Qa,getProgress:Yr,cancel:Za,awaitSubagent:Mo,answerSubagent:Po,steerSubagent:mi,computer_action:pi,computer_use:pi,ComputerAction:pi,ComputerUse:pi,click:Jr,Click:Jr,drag:Qr,Drag:Qr,scroll:Zr,Scroll:Zr,keyboard_typing:cs,KeyboardTyping:cs,keyboardtyping:cs,key_press:ds,KeyPress:ds,keypress:ds,recapture_screen:fs,RecaptureScreen:fs,recapturescreen:fs,invoke_sync:qr,get_progress:Yr,await_subagent:Mo,answer_subagent:Po,steer_subagent:mi,steer:mi,Steer:mi,ask:ls,Ask:ls,AskUser:ls,WebSearch:Or,WebScrape:Dr,ReadFile:Br,ReadFolder:Hr,WriteFile:Wr,PatchFile:Ur,WritePDF:jr,WriteDoc:Kr,Run:Gr,SearchKeyword:fi,CodeSearch:fi,code_search:fi,Memory:Nr,Chat:Fr,GenerateImage:Vr,saveSumary:ui,SaveSummary:ui,SaveSumary:ui,add_mem_score:Io,AddMemScore:Io,addMemoryScore:Io,AddMemoryScore:Io,FileMap:zr,answer:Po,Answer:Po,AnswerSubagent:Po,await:Mo,Await:Mo,AwaitSubagent:Mo,EmergencyRollback:Xr,emergency_rollback:Xr,find_file:hi,findFile:hi,FindFile:hi,findfile:hi,wait:ea,Wait:ea},us=async(e,n,t={})=>{let i=t.mode?t.mode.toLowerCase():"flux",o=e.toLowerCase(),d=["memory","chat","savesummary","addmemscore","add_mem_score","ask","web_search","web_scrape","await","wait"].some(h=>o.includes(h))||o==="ask",u=["click","drag","scroll","keyboardtyping","keyboard_typing","keypress","key_press","recapturescreen","recapture_screen","computer","wait"].some(h=>o.includes(h));if(!d){if(i==="flow"){if(!(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image")))return`ERROR: Action [${e}] is a Workspace Tool and NOT available in Flow mode. Tell user to switch (\`/mode flux\`) to use this tool.`}else if(i==="icu"){if(!u)return`ERROR: Action [${e}] is not available in Computer Use mode. ICU mode only supports Computer Use tools (Click, Drag, Scroll, KeyboardTyping, KeyPress, RecaptureScreen).`}else if(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image"))return`ERROR: Action [${e}] is not available in ${t.mode||"Flux"} mode. Tell user to switch (\`/mode flow\`) for document generation.`}let g=ta[e];if(!g){let h=["ReadFile","ReadFolder","FindFile","PatchFile","WriteFile","CodeSearch","Run","Goal","AskUser","WebSearch","WebScrape","WritePDF","WriteDoc","Click","Drag","Scroll","KeyboardTyping","KeyPress","RecaptureScreen","Wait","Invoke","InvokeSync","Await","GetProgress","Steer","Cancel","EmergencyRollback","Chat","Memory"],m={read:"ReadFile",view:"ReadFile",viewfile:"ReadFile",write:"WriteFile",edit:"PatchFile",patch:"PatchFile",update:"PatchFile",updatefile:"PatchFile",exec:"Run",command:"Run",bash:"Run",shell:"Run",powershell:"Run",search:"CodeSearch",grep:"CodeSearch",find:"FindFile",findfile:"FindFile",searchkeyword:"CodeSearch",folder:"ReadFolder",ls:"ReadFolder",dir:"ReadFolder",list:"ReadFolder",ask:"AskUser",question:"AskUser",pdf:"WritePDF",docx:"WriteDoc",doc:"WriteDoc",word:"WriteDoc",screenshot:"RecaptureScreen",screen:"RecaptureScreen",recapture:"RecaptureScreen",type:"KeyboardTyping",typing:"KeyboardTyping",keyboard:"KeyboardTyping",press:"KeyPress",key:"KeyPress",todo:"Goal",task:"Goal",subagent:"Invoke",agent:"Invoke"},p=o.replace(/[^a-z0-9]/g,""),s=m[p]||null;if(!s){let _=0,$e=N=>{let P=new Set;for(let V=0;V<N.length-1;V++)P.add(N.slice(V,V+2));return P},v=$e(p);for(let N of h){let P=N.toLowerCase().replace(/[^a-z0-9]/g,"");if(p===P){s=N;break}let V=0;(P.includes(p)||p.includes(P))&&(V+=.6);let M=$e(P),$=0;for(let ve of v)M.has(ve)&&$++;let ye=2*$/(v.size+M.size||1);V=Math.max(V,ye),V>_&&V>=.35&&(_=V,s=N)}}let w=s?` Do you mean '${s}'?`:"";return`ERROR: Action [${e}] not found in registry.${w}`}try{return await(await g())(n,t)}catch(h){let m=h instanceof Error?h.message:String(h);return`ERROR: Execution failed for [${e}]: ${m}`}};var yi=e=>{if(!e||typeof e!="string")return!1;let n=e.trim().toLowerCase();return Object.keys(ta).some(t=>t.toLowerCase()===n)};import J from"path";import Ce from"fs";import{execSync as xs}from"child_process";import el from"gradient-string";var na=["I have a regex for your problems.","Your terminal, my kingdom.","Blowing on the cartridge helps. Probably.","Don't panic. I have the towel.","Logic is the start of wisdom.","Try to exit Vim? Good luck.","I speak fluent Terminal.","The cake is a lie. This code is not.","I have no bugs, just surprise features.","Rewriting in Rust... just for fun.","Coffee in, clean commits out.","The magic smoke stays inside today.","A semicolon short of a miracle.","One does not simply code without a bug.","Keep it simple. Keep it terminal.","Regex: now you have two problems.","I dream in binary.","Root access or bust.","Wait for the dial-up tone. Just kidding.","I take the 'labor' out of collab.","My other process is a TARDIS.","Calculated response: 42.","Ponder the orb. Ponder the code.","Less talk, more flow.","Elegance in every byte.","Build something the world is not ready for.","Your wishes, my tool calls.","I act in Flux. I think in Flow.","Syntax error in the universe. Please fix.","Your project, my obsession.","I am not a bot, I am an architect.","Digital spirits consulted. They say: Ship it.","Reticulate splines. Engage humor.","Code like poetry. Run like water.","Minimalism is the ultimate flex.","The truth is in the logs.","Follow the white rabbit.","There is no spoon. Only code.","Binary is the only language I trust.","I have a good feeling about this.","Pew pew! Lasers charged.","Divide by zero? Not today.","Search for the correct USB orientation...","I've got a fever, and the only cure is more code.","The code gremlins are on our side.","My favorite command? Yours.","Stay hungry. Stay active.","Momentum is your best friend.","Lead the flow. Don't chase it.","A fresh batch of bytes. Hot and ready.","I orchestrate the ones and zeros.","Smart enough to help. Humble enough to ask.","Think twice. Code once.","Pure intent. Pure execution.","Small steps. Massive impact.","Your terminal is a canvas.","Efficiency is my second name.","I have seen things you people wouldn't believe.","Let the thoughts marinate.","The best feature? The one you don't need.","Precision is the only perfection.","Stay focused. Stay terminal.","Silence is the best debugger.","Erase the debt. Commit the code.","Velocity meets stability.","Ship it. Improve it. Repeat.","Build tomorrow, right now.","Turn logic into reality.","The best way to predict the future is to build it.","Break barriers, not builds.","Fuel the next breakthrough.","Momentum is key.","Terminal vibes only.","Your digital co-pilot is ready.","Partner in code. Partner in crime.","I speak in semicolons.","Ready for the next great idea.","Just a moment. In the zone.","Polishing the algorithms. Hold tight.","Craft a masterpiece today.","Debug the universe. Start here.","Warp speed engaged. Almost.","The cake is not a lie. It's just loading.","Finish the Kessel Run in 12 parsecs.","Do a barrel roll!","Waiting for the respawn.","Press Start to continue.","Herding digital cats... done.","The hamsters are fast today.","Tasting the snozberries.","I go for speed. I go for flow.","Real life or just fantasy?","Poking the bear... gently.","Ensure the magic smoke stays inside.","Try turning it off and on again.","Construct additional pylons.","New line? Ctrl+J is your friend.","Release the HypnoDrones.","Push the button, Frank.","My other loading screen is even funnier.","Pretty sure a cat walked on my keyboard.","Recalibrate the humor-o-meter.","Summon the code gremlins.","I've seen your browser history. Just kidding.","Charge the laser... pew pew!","Dividing by zero... just for a sec.","Looking for an adult supervisor. Found none.","Make it go beep boop.","Buffering... for effect.","Entangle quantum particles... complete.","Polishing the chrome on my algorithms.","Are you not entertained?","Just waiting for the dial-up tone.","Reboot the humor module.","Defragment memories. Check.","Optimizing for ludicrous speed.","Swapping bits. Don't tell the bytes.","Garbage collected. I am back.","Assembling the interwebs.","Converting coffee to logic.","Update syntax for reality.","Rewire the synapses.","Greasin' the cogs.","Engage the improbability drive.","Channel the Force.","Align the stars. Respond now.","The cake is a lie. The prompt is real.","I'm Feeling Lucky.","Shipping awesomeness.","Navigating the slime mold.","Consult digital spirits.","Ask the magic conch shell.","One moment. Optimizing humor.","Shuffling punchlines.","Compiling brilliance.","Summon the cloud of wisdom.","Prepare to dazzle.","Hold tight. Crafting a response.","Tuning the algorithms.","Following the white rabbit... again.","The truth is in here. Somewhere.","Herding cats is my day job.","Distracting you with this phrase.","Almost there. Probably.","Rickrolling my creator. Don't tell.","Slapping the bass.","Is this real life?","Ponder the orb. Type the prompt.","Thoughtful gaze initiated.","Computer's favorite snack? Microchips.","Why Java? Because I don't C#.","Charging the laser... wait for it.","Dividing by zero... just kidding!","Adult supervision not found. Proceed.","Beep boop. I'm a real boy.","Wait for the respawn.","Finish the run. Ship the code.","Fiddling with character creation.","Just a moment. Finding a meme.","Pressing A to continue.","Loading wit.exe.","Pre-heating the servers.","Calibrate flux capacitor.","Channeling the Force.","Aligning the stars.","The truth is in the code.","Don't panic.","Blowing on the cartridge.","Doing a barrel roll!","Respawning in 3... 2... 1...","The cake is a lie.","Fiddling with character settings.","Finding a suitable pun.","Distracting with wit.","Almost ready.","Hamsters on speed today.","Patting Cloudy on the head.","Rickrolling the logs.","Slapping the code.","Got a good feeling about this.","Poking the prompt.","Researching latest memes.","Making it more witty.","Thinking... hmmm.","Fish with no eyes? Fsh.","Broken pencil? Pointless.","Percussive maintenance applied.","USB orientation: 3rd try's the charm.","Rust rewrite in 3... 2...","Exiting Vim... someday.","Spinning the hamster wheel.","Not a bug. Unplanned feature.","Engage.","I'll be back.","Machine spirit consulted.","Letting the thoughts marinate.","Orb pondered.","Thoughtful gaze engaged.","Charging the laser...","Making it go beep.","Buffering...","Quantum particles entangled.","Polishing the chrome.","Entertained yet?","Gremlins summoned.","Dial-up tone finished.","Humor meter recalibrated.","Cat on keyboard. Sending help.","Enhancing...","Turn it off and on again.","Constructing pylons.","HypnoDrones released.","Pushing the button."];var oa=["Beware the phantom processes.","A ghost in the shell has taken the wheel.","Blowing on the haunted cartridge...","Seven minutes in Raccoon City.","Wind's howling... in the terminal fans.","Slender Man was spotted in line 404.","The cake is a lie. The curse is real.","Don't look behind the server rack.","Exorcising memory leaks at 3 AM.","Pyramid Head reorganized your commit history.","It's dangerous to go alone! Take this flashlight.","YOU DIED. Respawning terminal session...","The Necronomicon evaluated to true.","Something wicked this way compiles.","Haunting your localhost with good vibes.","A full moon has risen over Git main.","Double, double toil and trouble; code fire burn.","Clickers heard in the directory tree.","Checking camera 2B for rogue animatronics.","The call is coming from inside the container.","Isaac Clarke is stomping on stubborn bugs.","Luigi vacuumed the ghosts out of RAM.","Trick or treat, give me clean code to greet.","Whispering incantations to the garbage collector.","Klaatu barada necktie... close enough.","Resurrecting deprecated APIs from the crypt.","The headless horseman forgot the return statement.","Castlevania whip cracking against network latency.","Slime mold crawling through the motherboard.","Carving a pixelated pumpkin into terminal history.","Burying undefined pointers in the pet sematary.","Spilling pumpkin spice on the CPU.","A vampire bat is draining system battery life.","Don't fall asleep at the keyboard tonight.","Silent Hill sirens sounding in the console.","Poltergeists rearranging terminal tabs.","Lighting the Black Flame Candle for autoExec.","Dusting cobwebs off legacy dependencies.","Here's Johnny! ...just checking build health.","Blood, sweat, and zero warnings.","The spirit box whispers: 'GIT PUSH FORCE'.","They're heeeere... in the stack trace.","It's alive! IT'S ALIVEEEE!","No merge conflicts in the graveyard.","Frankenstein's monster patched this logic.","Surviving Five Nights at Flux Flow.","Doom Slayer loading buckshot into cache.","The grim reaper spared your unused imports.","Candy corn lodged in mechanical switches.","May your latency be low and your crypt be quiet."];var ia=[{name:"Cyan Cyberpunk",text:"cyan",textMuted:"#4da6b8",textDim:"#2d6d7a",textInverted:"black",border:"cyan",borderMuted:"#1a5966",borderDim:"#0f3840",bg:void 0,cardBg:"#061e24",highlightBg:"#092b33",activeBg:"#0e3e4a",inputBg:"#092b33",inputBorder:"#092b33",inputText:"cyan",inputPlaceholder:"#2d6d7a",inputPrompt:"cyan",codeBg:"#020d10",codeBorder:"#1a5966",userMsgBg:"#092b33",userMsgBorder:"#092b33",userMsgText:"cyan",diffRemovalBg:"#3a0c1a",diffAdditionBg:"#0c3a32",diffRemovalText:"#ff4d88",diffAdditionText:"#00ffaa",diffRemovalHighlightColor:"#ff1a66",diffRemovalHighlightBg:"#590022",diffAdditionHighlightColor:"#00ffcc",diffAdditionHighlightBg:"#00593b",diffRemovalNum:"#ff4d88",diffAdditionNum:"#00ffaa",diffRemovalPrefix:"#ff1a66",diffAdditionPrefix:"#00ffcc",primary:"cyan",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"cyan",statusOff:"#2d6d7a",logoTextAnsi:"\x1B[1;36m",logoBodyAnsi:"\x1B[36m",logoMutedAnsi:"\x1B[90m",logoGradient:["#00ffff","#0088ff"]},{name:"Magenta Vaporwave",text:"magenta",textMuted:"#c451d6",textDim:"#7d2b8a",textInverted:"black",border:"magenta",borderMuted:"#5e1b69",borderDim:"#3b0f42",bg:void 0,cardBg:"#240729",highlightBg:"#310938",activeBg:"#470e52",inputBg:"#310938",inputBorder:"#310938",inputText:"magenta",inputPlaceholder:"#7d2b8a",inputPrompt:"magenta",codeBg:"#100312",codeBorder:"#5e1b69",userMsgBg:"#310938",userMsgBorder:"#310938",userMsgText:"magenta",diffRemovalBg:"#3a0c20",diffAdditionBg:"#200c3a",diffRemovalText:"#ff4d94",diffAdditionText:"#aa4dff",diffRemovalHighlightColor:"#ff1a75",diffRemovalHighlightBg:"#59002b",diffAdditionHighlightColor:"#bb66ff",diffAdditionHighlightBg:"#3b0059",diffRemovalNum:"#ff4d94",diffAdditionNum:"#aa4dff",diffRemovalPrefix:"#ff1a75",diffAdditionPrefix:"#bb66ff",primary:"magenta",secondary:"cyan",accent:"purple",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"magenta",statusOff:"#7d2b8a",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ff00ff","#8800ff"]},{name:"Glitch Matrix",text:"#00ff41",textMuted:"#00b32d",textDim:"#00661a",textInverted:"black",border:"#00ff41",borderMuted:"#008020",borderDim:"#004d13",bg:void 0,cardBg:"#0d1f0d",highlightBg:"#122912",activeBg:"#1c3e1c",inputBg:"#122912",inputBorder:"#122912",inputText:"#00ff41",inputPlaceholder:"#00b32d",inputPrompt:"#ffff00",codeBg:"#040a04",codeBorder:"#008020",userMsgBg:"#122912",userMsgBorder:"#122912",userMsgText:"#00ff41",diffRemovalBg:"#3a001a",diffAdditionBg:"#003a10",diffRemovalText:"#ff0055",diffAdditionText:"#00ff66",diffRemovalHighlightColor:"#ff0033",diffRemovalHighlightBg:"#59001b",diffAdditionHighlightColor:"#33ff88",diffAdditionHighlightBg:"#005918",diffRemovalNum:"#ff0055",diffAdditionNum:"#00ff66",diffRemovalPrefix:"#ff0033",diffAdditionPrefix:"#33ff88",primary:"#00ff41",secondary:"yellow",accent:"cyan",success:"#00ff41",warning:"yellow",danger:"red",info:"cyan",statusOn:"#00ff41",statusOff:"#00661a",logoTextAnsi:"\x1B[1;32m",logoBodyAnsi:"\x1B[32m",logoMutedAnsi:"\x1B[90m",logoGradient:["#00ff41","#ffff00"]},{name:"Warm Sunset",text:"#ffaa55",textMuted:"#cc8844",textDim:"#885522",textInverted:"black",border:"#ff9933",borderMuted:"#aa6622",borderDim:"#663311",bg:void 0,cardBg:"#24180f",highlightBg:"#2e1e12",activeBg:"#422c1b",inputBg:"#2e1e12",inputBorder:"#2e1e12",inputText:"#ffaa55",inputPlaceholder:"#885522",inputPrompt:"#ff7733",codeBg:"#120c08",codeBorder:"#aa6622",userMsgBg:"#2e1e12",userMsgBorder:"#2e1e12",userMsgText:"#ffaa55",diffRemovalBg:"#3d120c",diffAdditionBg:"#3a2e0c",diffRemovalText:"#ff5544",diffAdditionText:"#ffcc33",diffRemovalHighlightColor:"#ff3322",diffRemovalHighlightBg:"#591108",diffAdditionHighlightColor:"#ffee44",diffAdditionHighlightBg:"#594400",diffRemovalNum:"#ff5544",diffAdditionNum:"#ffcc33",diffRemovalPrefix:"#ff3322",diffAdditionPrefix:"#ffee44",primary:"#ffaa55",secondary:"#ff7733",accent:"magenta",success:"#ffcc33",warning:"#ff7733",danger:"#ff3322",info:"#ffaa55",statusOn:"#ffaa55",statusOff:"#885522",logoTextAnsi:"\x1B[1;33m",logoBodyAnsi:"\x1B[33m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ff9933","#ff0055"]},{name:"Sakura Blossom",text:"#ffc0e0",textMuted:"#d98cb3",textDim:"#804d66",textInverted:"black",border:"#ff99cc",borderMuted:"#aa4d7a",borderDim:"#662647",bg:void 0,cardBg:"#291320",highlightBg:"#331826",activeBg:"#472235",inputBg:"#331826",inputBorder:"#331826",inputText:"#ffc0e0",inputPlaceholder:"#804d66",inputPrompt:"#ff99cc",codeBg:"#140a10",codeBorder:"#aa4d7a",userMsgBg:"#331826",userMsgBorder:"#331826",userMsgText:"#ffc0e0",diffRemovalBg:"#3e0c1b",diffAdditionBg:"#1b3e2b",diffRemovalText:"#ff6699",diffAdditionText:"#66ffb3",diffRemovalHighlightColor:"#ff3377",diffRemovalHighlightBg:"#590022",diffAdditionHighlightColor:"#33ff99",diffAdditionHighlightBg:"#00592e",diffRemovalNum:"#ff6699",diffAdditionNum:"#66ffb3",diffRemovalPrefix:"#ff3377",diffAdditionPrefix:"#33ff99",primary:"#ffc0e0",secondary:"#ff99cc",accent:"magenta",success:"#66ffb3",warning:"yellow",danger:"#ff3377",info:"#ff99cc",statusOn:"#ffc0e0",statusOff:"#804d66",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ffb3d9","#ff3399"]},{name:"Radioactive Slime",text:"#ccff00",textMuted:"#99cc00",textDim:"#669900",textInverted:"#0a0f00",border:"#ccff00",borderMuted:"#99cc00",borderDim:"#669900",bg:void 0,cardBg:"#0f1400",highlightBg:"#1a2400",activeBg:"#2a3b00",inputBg:"#1a2400",inputBorder:"#1a2400",inputText:"#ccff00",inputPlaceholder:"#669900",inputPrompt:"#cc00ff",codeBg:"#050a00",codeBorder:"#99cc00",userMsgBg:"#1a2400",userMsgBorder:"#1a2400",userMsgText:"#ccff00",diffRemovalBg:"#2a0033",diffAdditionBg:"#0f3300",diffRemovalText:"#ff00cc",diffAdditionText:"#00ff33",diffRemovalHighlightColor:"#ff33cc",diffRemovalHighlightBg:"#4d0066",diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:"#1a6600",diffRemovalNum:"#ff00cc",diffAdditionNum:"#00ff33",diffRemovalPrefix:"#ff33cc",diffAdditionPrefix:"#33ff66",primary:"#ccff00",secondary:"#cc00ff",accent:"#ff00cc",success:"#00ff33",warning:"#ffcc00",danger:"#ff0033",info:"#00ccff",statusOn:"#ccff00",statusOff:"#669900",logoTextAnsi:"\x1B[1;38;5;190m",logoBodyAnsi:"\x1B[38;5;190m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ccff00","#cc00ff"]},{name:"Cosmic Void",text:"#f0f8ff",textMuted:"#a6aeb5",textDim:"#5e656e",textInverted:"#010103",border:"#f0f8ff",borderMuted:"#a6aeb5",borderDim:"#5e656e",bg:void 0,cardBg:"#05030d",highlightBg:"#0b081a",activeBg:"#171133",inputBg:"#0b081a",inputBorder:"#0b081a",inputText:"#f0f8ff",inputPlaceholder:"#5e656e",inputPrompt:"#ff007f",codeBg:"#020108",codeBorder:"#a6aeb5",userMsgBg:"#0b081a",userMsgBorder:"#0b081a",userMsgText:"#f0f8ff",diffRemovalBg:"#2e0a29",diffAdditionBg:"#091c33",diffRemovalText:"#ff33a6",diffAdditionText:"#33d6ff",diffRemovalHighlightColor:"#ff66c2",diffRemovalHighlightBg:"#5c1452",diffAdditionHighlightColor:"#66e0ff",diffAdditionHighlightBg:"#123866",diffRemovalNum:"#ff33a6",diffAdditionNum:"#33d6ff",diffRemovalPrefix:"#ff66c2",diffAdditionPrefix:"#66e0ff",primary:"#f0f8ff",secondary:"#ff007f",accent:"#9d00ff",success:"#33d6ff",warning:"#ffcc00",danger:"#ff0040",info:"#9d00ff",statusOn:"#f0f8ff",statusOff:"#5e656e",logoTextAnsi:"\x1B[1;38;5;231m",logoBodyAnsi:"\x1B[38;5;231m",logoMutedAnsi:"\x1B[38;5;240m",logoGradient:["#ffffff","#9d00ff"]},{name:"Magma Eruption",text:"#ff4d00",textMuted:"#cc3d00",textDim:"#802600",textInverted:"#0d0300",border:"#ff4d00",borderMuted:"#cc3d00",borderDim:"#802600",bg:void 0,cardBg:"#1a0600",highlightBg:"#260a00",activeBg:"#401100",inputBg:"#260a00",inputBorder:"#260a00",inputText:"#ff4d00",inputPlaceholder:"#802600",inputPrompt:"#ffcc00",codeBg:"#080200",codeBorder:"#cc3d00",userMsgBg:"#260a00",userMsgBorder:"#260a00",userMsgText:"#ff4d00",diffRemovalBg:"#2e0a0a",diffAdditionBg:"#1f1400",diffRemovalText:"#ff3333",diffAdditionText:"#ffaa00",diffRemovalHighlightColor:"#ff6666",diffRemovalHighlightBg:"#5c1414",diffAdditionHighlightColor:"#ffcc33",diffAdditionHighlightBg:"#3d2900",diffRemovalNum:"#ff3333",diffAdditionNum:"#ffaa00",diffRemovalPrefix:"#ff6666",diffAdditionPrefix:"#ffcc33",primary:"#ff4d00",secondary:"#ffcc00",accent:"#ff0040",success:"#ffaa00",warning:"#ffff00",danger:"#ff0000",info:"#ff8800",statusOn:"#ff4d00",statusOff:"#802600",logoTextAnsi:"\x1B[1;38;5;202m",logoBodyAnsi:"\x1B[38;5;202m",logoMutedAnsi:"\x1B[38;5;236m",logoGradient:["#ff4d00","#ff0000"]}],ao={Dark:{id:"Dark",name:"Dark (Default)",text:"white",textMuted:"gray",textDim:"grey",textInverted:"black",textExclusive:"#B5B8D9",textMutedExclusive:"#D4DEE7",border:"white",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:"#1e1e1e",highlightBg:"#2a2a2a",activeBg:"#3a3a3a",inputBg:"#555555",inputBorder:"#555555",inputText:"white",inputPlaceholder:"#cccccc",inputPrompt:"white",codeBg:"#1a1a1a",codeBorder:"#444444",userMsgBg:"#444444",userMsgBorder:"#444444",userMsgText:"white",diffRemovalBg:"#250808",diffAdditionBg:"#072410",diffRemovalText:"#885555",diffAdditionText:"#558866",diffRemovalHighlightColor:"#ff3333",diffRemovalHighlightBg:"#5a1818",diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:"#185a25",diffRemovalNum:"#d96868",diffAdditionNum:"#68d98c",diffRemovalPrefix:"#ff4d4d",diffAdditionPrefix:"#4dff88",primary:"white",secondary:"cyan",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"white",statusOff:"gray",logoTextAnsi:"\x1B[1;37m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},Light:{id:"Light",name:"Light",text:"black",textMuted:"gray",textDim:"grey",textInverted:"white",border:"black",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:"#e5e5e5",highlightBg:"#d4d4d4",activeBg:"#c0c0c0",inputBg:"#d0d0d0",inputBorder:"#d0d0d0",inputText:"black",inputPlaceholder:"#555555",inputPrompt:"black",codeBg:"#e8e8e8",codeBorder:"#b0b0b0",userMsgBg:"#d0d0d0",userMsgBorder:"#d0d0d0",userMsgText:"black",diffRemovalBg:"#fce8e8",diffAdditionBg:"#e6f9e6",diffRemovalText:"#661111",diffAdditionText:"#115511",diffRemovalHighlightColor:"#440000",diffRemovalHighlightBg:"#f8b4b4",diffAdditionHighlightColor:"#003300",diffAdditionHighlightBg:"#a6ebad",diffRemovalNum:"#c02020",diffAdditionNum:"#188028",diffRemovalPrefix:"#d01010",diffAdditionPrefix:"#109020",primary:"black",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"black",statusOff:"gray",logoTextAnsi:"\x1B[1;30m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},"GitHub Dark":{id:"GitHub Dark",name:"GitHub Dark",text:"#c9d1d9",textMuted:"#8b949e",textDim:"#6e7681",textInverted:"#0d1117",border:"#30363d",borderMuted:"#30363d",borderDim:"#21262d",bg:void 0,cardBg:"#161b22",highlightBg:"#21262d",activeBg:"#30363d",inputBg:"#21262d",inputBorder:"#21262d",inputText:"#c9d1d9",inputPlaceholder:"#8b949e",inputPrompt:"#58a6ff",codeBg:"#0d1117",codeBorder:"#30363d",userMsgBg:"#21262d",userMsgBorder:"#21262d",userMsgText:"#c9d1d9",diffRemovalBg:"#3c1e1e",diffAdditionBg:"#11381e",diffRemovalText:"#f85149",diffAdditionText:"#3fb950",diffRemovalHighlightColor:"#ff7b72",diffRemovalHighlightBg:"#701c1c",diffAdditionHighlightColor:"#56d364",diffAdditionHighlightBg:"#116329",diffRemovalNum:"#f85149",diffAdditionNum:"#3fb950",diffRemovalPrefix:"#f85149",diffAdditionPrefix:"#3fb950",primary:"#c9d1d9",secondary:"#58a6ff",accent:"#bc8cff",success:"#3fb950",warning:"#d29922",danger:"#f85149",info:"#58a6ff",statusOn:"#58a6ff",statusOff:"#8b949e",logoTextAnsi:"\x1B[1;36m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#2ea043","#56d364"],toolFeedbackAnsi:"\x1B[95m"},"GitHub Light":{id:"GitHub Light",name:"GitHub Light",text:"#24292f",textMuted:"#57606a",textDim:"#6e7781",textInverted:"#ffffff",border:"#d0d7de",borderMuted:"#d0d7de",borderDim:"#e1e4e8",bg:void 0,cardBg:"#f6f8fa",highlightBg:"#eaeef2",activeBg:"#d0d7de",inputBg:"#eaeef2",inputBorder:"#eaeef2",inputText:"#24292f",inputPlaceholder:"#57606a",inputPrompt:"#0969da",codeBg:"#ffffff",codeBorder:"#d0d7de",userMsgBg:"#eaeef2",userMsgBorder:"#eaeef2",userMsgText:"#24292f",diffRemovalBg:"#ffebe9",diffAdditionBg:"#e6ffec",diffRemovalText:"#cf222e",diffAdditionText:"#1a7f37",diffRemovalHighlightColor:"#82071e",diffRemovalHighlightBg:"#ffc1c0",diffAdditionHighlightColor:"#116329",diffAdditionHighlightBg:"#acf2bd",diffRemovalNum:"#cf222e",diffAdditionNum:"#1a7f37",diffRemovalPrefix:"#cf222e",diffAdditionPrefix:"#1a7f37",primary:"#24292f",secondary:"#0969da",accent:"#8250df",success:"#1a7f37",warning:"#9a6700",danger:"#cf222e",info:"#0969da",statusOn:"#0969da",statusOff:"#57606a",logoTextAnsi:"\x1B[1;34m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#1a7f37","#2da44e"],toolFeedbackAnsi:"\x1B[95m"},"Transparent Dark":{id:"Transparent Dark",name:"Transparent Dark",text:"white",textMuted:"gray",textDim:"grey",textInverted:"black",border:"gray",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:void 0,highlightBg:"#2a2a2a",activeBg:"#3a3a3a",inputBg:"#555555",inputBorder:"#555555",inputText:"white",inputPlaceholder:"#cccccc",inputPrompt:"white",codeBg:void 0,codeBorder:"gray",userMsgBg:"#555555",userMsgBorder:"#555555",userMsgText:"white",diffRemovalBg:void 0,diffAdditionBg:void 0,diffRemovalText:"#ff6666",diffAdditionText:"#66ff66",diffRemovalHighlightColor:"#ff3333",diffRemovalHighlightBg:"#3a1414",diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:"#143a14",diffRemovalNum:"#ff6666",diffAdditionNum:"#66ff66",diffRemovalPrefix:"#ff4d4d",diffAdditionPrefix:"#4dff88",primary:"white",secondary:"cyan",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"white",statusOff:"gray",logoTextAnsi:"\x1B[1;37m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},"Transparent Light":{id:"Transparent Light",name:"Transparent Light",text:"black",textMuted:"gray",textDim:"grey",textInverted:"white",border:"gray",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:void 0,highlightBg:"#d4d4d4",activeBg:"#c0c0c0",inputBg:"#d0d0d0",inputBorder:"#d0d0d0",inputText:"black",inputPlaceholder:"#555555",inputPrompt:"black",codeBg:void 0,codeBorder:"gray",userMsgBg:"#d0d0d0",userMsgBorder:"#d0d0d0",userMsgText:"black",diffRemovalBg:void 0,diffAdditionBg:void 0,diffRemovalText:"#c02020",diffAdditionText:"#188028",diffRemovalHighlightColor:"#800000",diffRemovalHighlightBg:"#f5d0d0",diffAdditionHighlightColor:"#004000",diffAdditionHighlightBg:"#cceccc",diffRemovalNum:"#c02020",diffAdditionNum:"#188028",diffRemovalPrefix:"#d01010",diffAdditionPrefix:"#109020",primary:"black",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"black",statusOff:"gray",logoTextAnsi:"\x1B[1;30m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},"Synthwave 84":{id:"Synthwave 84",name:"Synthwave 84",text:"#fdfdfd",textMuted:"#a08eb7",textDim:"#705c8a",textInverted:"#1a1025",textExclusive:"#e3dcf0",textMutedExclusive:"#b9abc9",border:"#fc28a8",borderMuted:"#a21568",borderDim:"#5c0a3a",bg:void 0,cardBg:"#261b38",highlightBg:"#35254d",activeBg:"#4c3570",inputBg:"#35254d",inputBorder:"#35254d",inputText:"#fdfdfd",inputPlaceholder:"#a08eb7",inputPrompt:"#03e8fc",codeBg:"#1e142b",codeBorder:"#a21568",userMsgBg:"#35254d",userMsgBorder:"#35254d",userMsgText:"#fdfdfd",diffRemovalBg:"#471434",diffAdditionBg:"#144743",diffRemovalText:"#ff4081",diffAdditionText:"#00e5ff",diffRemovalHighlightColor:"#ff79a1",diffRemovalHighlightBg:"#6b1e4e",diffAdditionHighlightColor:"#66f5ff",diffAdditionHighlightBg:"#1e6b65",diffRemovalNum:"#ff4081",diffAdditionNum:"#00e5ff",diffRemovalPrefix:"#ff79a1",diffAdditionPrefix:"#66f5ff",primary:"#fdfdfd",secondary:"#03e8fc",accent:"#fc28a8",success:"#00e5ff",warning:"#ffc107",danger:"#ff4081",info:"#b388ff",statusOn:"#03e8fc",statusOff:"#a08eb7",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#fc28a8","#03e8fc"],toolFeedbackAnsi:"\x1B[38;2;3;232;252m"},"Forest Sprite":{id:"Forest Sprite",name:"Forest Sprite",text:"#d6e6d1",textMuted:"#95b38d",textDim:"#628059",textInverted:"#161c14",textExclusive:"#eaf2e8",textMutedExclusive:"#a9c7a2",border:"#74a862",borderMuted:"#477038",borderDim:"#2b4720",bg:void 0,cardBg:"#1f291c",highlightBg:"#2a3826",activeBg:"#3a4d35",inputBg:"#2a3826",inputBorder:"#2a3826",inputText:"#d6e6d1",inputPlaceholder:"#95b38d",inputPrompt:"#8feb73",codeBg:"#161e14",codeBorder:"#477038",userMsgBg:"#2a3826",userMsgBorder:"#2a3826",userMsgText:"#d6e6d1",diffRemovalBg:"#3b231c",diffAdditionBg:"#203b1c",diffRemovalText:"#db6242",diffAdditionText:"#59cc3f",diffRemovalHighlightColor:"#f0896c",diffRemovalHighlightBg:"#5c362a",diffAdditionHighlightColor:"#80e368",diffAdditionHighlightBg:"#305929",diffRemovalNum:"#db6242",diffAdditionNum:"#59cc3f",diffRemovalPrefix:"#f0896c",diffAdditionPrefix:"#80e368",primary:"#d6e6d1",secondary:"#8feb73",accent:"#e69835",success:"#59cc3f",warning:"#e69835",danger:"#db6242",info:"#73b4eb",statusOn:"#8feb73",statusOff:"#95b38d",logoTextAnsi:"\x1B[1;32m",logoBodyAnsi:"\x1B[32m",logoMutedAnsi:"\x1B[90m",logoGradient:["#8feb73","#e69835"],toolFeedbackAnsi:"\x1B[38;2;143;235;115m"},Spookfest:{id:"Spookfest",name:"Spookfest \u{1F383}",text:"#ffeedd",textMuted:"#e09858",textDim:"#a6622b",textInverted:"#0d0702",textExclusive:"#fff3e6",textMutedExclusive:"#d4a276",border:"#ff7518",borderMuted:"#994409",borderDim:"#592502",bg:void 0,cardBg:"#1a0c02",highlightBg:"#2a1403",activeBg:"#3d1d05",inputBg:"#261203",inputBorder:"#261203",inputText:"#ffeedd",inputPlaceholder:"#a6622b",inputPrompt:"#ff7518",codeBg:"#120701",codeBorder:"#592502",userMsgBg:"#261203",userMsgBorder:"#261203",userMsgText:"#ffeedd",diffRemovalBg:"#3d0a0a",diffAdditionBg:"#1a330a",diffRemovalText:"#ff5555",diffAdditionText:"#73e639",diffRemovalHighlightColor:"#ff2222",diffRemovalHighlightBg:"#590e0e",diffAdditionHighlightColor:"#88ff3b",diffAdditionHighlightBg:"#244d0a",diffRemovalNum:"#ff5555",diffAdditionNum:"#73e639",diffRemovalPrefix:"#ff3333",diffAdditionPrefix:"#88ff3b",primary:"#ff7518",secondary:"#a855f7",accent:"#22c55e",success:"#22c55e",warning:"#f59e0b",danger:"#ef4444",info:"#a855f7",statusOn:"#ff7518",statusOff:"#703a08",logoTextAnsi:"\x1B[1;38;2;255;117;24m",logoBodyAnsi:"\x1B[38;2;255;140;26m",logoMutedAnsi:"\x1B[38;2;168;85;247m",logoGradient:["#ff7518","#a855f7"],toolFeedbackAnsi:"\x1B[38;2;255;117;24m"}};var xi=null;var wi=(e="Dark")=>{let n;e==="Mystery"||e==="Chaos"?(xi||(xi=ia[Math.floor(Math.random()*ia.length)]),n={...xi,id:"Mystery"}):(xi=null,ao[e]?n=ao[e]:e==="Halloween"?n=ao.Spookfest:e==="GitHub"?n=ao["GitHub Dark"]:e==="Transparent"?n=ao["Transparent Dark"]:n=ao.Dark);let t=n.codeText||n.secondary||n.info||n.logoGradient&&n.logoGradient[0]||"cyan",i=n.toolFeedbackAnsi||"\x1B[95m";return{...n,codeText:t,toolFeedbackAnsi:i}};var tl=()=>process.env.TERM_PROGRAM==="vscode"?"vscode":process.env.WT_SESSION?"wt":"default",Jc=(e=2)=>{let n=tl();return n==="wt"?" ".repeat(Math.max(1,e-1)):" ".repeat(e)},sa=new Date,$o=sa.getMonth(),Lo=sa.getDate(),nl=$o===9&&Lo>=15||$o===10&&Lo<=1,gs=null;(process.env.SPOOKFEST==="true"||nl)&&(gs=await import("./halloween-MX3VNQRW.js"));var Qc=(e="...",n="Loading...",t="Dark")=>{let i=wi(t),o=n;if(n==="c_openai"||n==="Custom (OpenAI)")try{let V=Zo(Jo,{})?.systemSettings?.customOpenAIBaseUrl;V&&(o=V)}catch{}let r=i.logoTextAnsi,d=i.logoBodyAnsi,l=i.logoMutedAnsi,u="\x1B[0m",g=[" \u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2591 "," \u2588\u2588\u2588\u2591 "," \u2588\u2588\u2588\u2591 "," \u2591\u2591\u2591 "],h=t==="Spookfest"||i.id==="Spookfest"||t==="Halloween"||i.id==="Halloween",m=$o===9&&Lo>=15||$o===10&&Lo<=1,p=h&&m||process.env.SPOOKFEST==="true"&&h,s=g;if(p&&gs){process.env.HALLOWEEN_EEGG="true";let{halloweenArtSide:P,halloweenBat:V,halloweenArtUser:M}=gs;s=Math.random()>.9&&$o===9&&Lo>=30?V:Math.random()>.5?P:M}else process.env.HALLOWEEN_EEGG="false";let w=p?oa:na,_=w[Math.floor(Math.random()*w.length)],$e=i.logoGradient||["#0077ff","#ff00ff"],v=el($e).multiline(s.join(`
529
+ `:""}`.trim()};var Or=()=>import("./web_search-C3WKDOSZ.js").then(e=>e.web_search),Dr=()=>import("./web_scrape-MVSCRDKO.js").then(e=>e.web_scrape),Nr=()=>import("./memory-AT7ARTG3.js").then(e=>e.memory),Fr=()=>import("./chat-OYRESDTX.js").then(e=>e.chat),Br=()=>import("./view_file-OYV2IEYG.js").then(e=>e.view_file),Wr=()=>import("./write_file-WX4O436W.js").then(e=>e.write_file),Ur=()=>import("./update_file-CH6YILXO.js").then(e=>e.update_file),Gr=()=>import("./exec_command-SQB5LU5X.js").then(e=>e.exec_command),Hr=()=>import("./read_folder-UWFC5DNX.js").then(e=>e.read_folder),ls=()=>import("./ask_user-K2DLZF6H.js").then(e=>e.ask_user),jr=()=>import("./write_pdf-5HOQYVQO.js").then(e=>e.write_pdf),Kr=()=>import("./write_docx-QGW25TF7.js").then(e=>e.write_docx),fi=()=>import("./search_keyword-IRLPX555.js").then(e=>e.search_keyword),Vr=()=>import("./generate_image-7UBJ3ODS.js").then(e=>e.generate_image),ui=()=>import("./saveSummary-ZJDPCZSR.js").then(e=>e.saveSummary),Io=()=>import("./addMemScore-VUSJ2Q64.js").then(e=>e.addMemScore),zr=()=>import("./file_map-K6JQYV35.js").then(e=>e.file_map),gi=()=>import("./todo-YFLPXYFL.js").then(e=>e.todo),qr=()=>import("./invokeSync-HMYNQ5CZ.js").then(e=>e.invokeSync),Qa=()=>import("./invoke-3PD3C5KP.js").then(e=>e.invoke),Yr=()=>import("./getProgress-J34K43Y7.js").then(e=>e.getProgress),Za=()=>import("./cancel-F3ZOEBKW.js").then(e=>e.cancel),Xr=()=>import("./emergency_rollback-LC4ZBOLP.js").then(e=>e.emergency_rollback),Mo=()=>import("./awaitSubagent-JKQ2EHVY.js").then(e=>e.awaitSubagent),Po=()=>import("./answerSubagent-BPNNJXPC.js").then(e=>e.answerSubagent),mi=()=>import("./steerSubagent-UETXH2CB.js").then(e=>e.steerSubagent),pi=()=>import("./computer_action-6RHVNLZG.js").then(e=>e.computer_action),Jr=()=>import("./click-3BB6KDIJ.js").then(e=>e.click),Qr=()=>import("./drag-ZGNVQGXW.js").then(e=>e.drag),Zr=()=>import("./scroll-XBXSN2EF.js").then(e=>e.scroll),cs=()=>import("./keyboard_typing-DJ3HHTO7.js").then(e=>e.keyboard_typing),ds=()=>import("./key_press-LO75QEJK.js").then(e=>e.key_press),fs=()=>import("./recapture_screen-LONV6G4U.js").then(e=>e.recapture_screen),hi=()=>import("./find_file-5RUNVQJO.js").then(e=>e.find_file),ea=()=>import("./wait-TJR6LAR4.js").then(e=>e.wait),ta={web_search:Or,web_scrape:Dr,memory:Nr,chat:Fr,view_file:Br,write_file:Wr,update_file:Ur,exec_command:Gr,read_folder:Hr,write_pdf:jr,write_docx:Kr,search_keyword:fi,generate_image:Vr,saveSummary:ui,addMemScore:Io,file_map:zr,todo:gi,Todo:gi,goal:gi,Goal:gi,invokeSync:qr,invoke:Qa,getProgress:Yr,cancel:Za,awaitSubagent:Mo,answerSubagent:Po,steerSubagent:mi,computer_action:pi,computer_use:pi,ComputerAction:pi,ComputerUse:pi,click:Jr,Click:Jr,drag:Qr,Drag:Qr,scroll:Zr,Scroll:Zr,keyboard_typing:cs,KeyboardTyping:cs,keyboardtyping:cs,key_press:ds,KeyPress:ds,keypress:ds,recapture_screen:fs,RecaptureScreen:fs,recapturescreen:fs,invoke_sync:qr,get_progress:Yr,await_subagent:Mo,answer_subagent:Po,steer_subagent:mi,steer:mi,Steer:mi,ask:ls,Ask:ls,AskUser:ls,WebSearch:Or,WebScrape:Dr,ReadFile:Br,ReadFolder:Hr,WriteFile:Wr,PatchFile:Ur,WritePDF:jr,WriteDoc:Kr,Run:Gr,SearchKeyword:fi,CodeSearch:fi,code_search:fi,Memory:Nr,Chat:Fr,GenerateImage:Vr,saveSumary:ui,SaveSummary:ui,SaveSumary:ui,add_mem_score:Io,AddMemScore:Io,addMemoryScore:Io,AddMemoryScore:Io,FileMap:zr,answer:Po,Answer:Po,AnswerSubagent:Po,await:Mo,Await:Mo,AwaitSubagent:Mo,EmergencyRollback:Xr,emergency_rollback:Xr,find_file:hi,findFile:hi,FindFile:hi,findfile:hi,wait:ea,Wait:ea},us=async(e,n,t={})=>{let i=t.mode?t.mode.toLowerCase():"flux",o=e.toLowerCase(),d=["memory","chat","savesummary","addmemscore","add_mem_score","ask","web_search","web_scrape","await","wait"].some(h=>o.includes(h))||o==="ask",u=["click","drag","scroll","keyboardtyping","keyboard_typing","keypress","key_press","recapturescreen","recapture_screen","computer","wait"].some(h=>o.includes(h));if(!d){if(i==="flow"){if(!(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image")))return`ERROR: Action [${e}] is a Workspace Tool and NOT available in Flow mode. Tell user to switch (\`/mode flux\`) to use this tool.`}else if(i==="icu"){if(!u)return`ERROR: Action [${e}] is not available in Computer Use mode. ICU mode only supports Computer Use tools (Click, Drag, Scroll, KeyboardTyping, KeyPress, RecaptureScreen).`}else if(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image"))return`ERROR: Action [${e}] is not available in ${t.mode||"Flux"} mode. Tell user to switch (\`/mode flow\`) for document generation.`}let g=ta[e];if(!g){let h=["ReadFile","ReadFolder","FindFile","PatchFile","WriteFile","CodeSearch","Run","Goal","AskUser","WebSearch","WebScrape","WritePDF","WriteDoc","Click","Drag","Scroll","KeyboardTyping","KeyPress","RecaptureScreen","Wait","Invoke","InvokeSync","Await","GetProgress","Steer","Cancel","EmergencyRollback","Chat","Memory"],m={read:"ReadFile",view:"ReadFile",viewfile:"ReadFile",write:"WriteFile",edit:"PatchFile",patch:"PatchFile",update:"PatchFile",updatefile:"PatchFile",exec:"Run",command:"Run",bash:"Run",shell:"Run",powershell:"Run",search:"CodeSearch",grep:"CodeSearch",find:"FindFile",findfile:"FindFile",searchkeyword:"CodeSearch",folder:"ReadFolder",ls:"ReadFolder",dir:"ReadFolder",list:"ReadFolder",ask:"AskUser",question:"AskUser",pdf:"WritePDF",docx:"WriteDoc",doc:"WriteDoc",word:"WriteDoc",screenshot:"RecaptureScreen",screen:"RecaptureScreen",recapture:"RecaptureScreen",type:"KeyboardTyping",typing:"KeyboardTyping",keyboard:"KeyboardTyping",press:"KeyPress",key:"KeyPress",todo:"Goal",task:"Goal",subagent:"Invoke",agent:"Invoke"},p=o.replace(/[^a-z0-9]/g,""),s=m[p]||null;if(!s){let _=0,Le=N=>{let P=new Set;for(let z=0;z<N.length-1;z++)P.add(N.slice(z,z+2));return P},v=Le(p);for(let N of h){let P=N.toLowerCase().replace(/[^a-z0-9]/g,"");if(p===P){s=N;break}let z=0;(P.includes(p)||p.includes(P))&&(z+=.6);let M=Le(P),$=0;for(let ve of v)M.has(ve)&&$++;let xe=2*$/(v.size+M.size||1);z=Math.max(z,xe),z>_&&z>=.35&&(_=z,s=N)}}let b=s?` Do you mean '${s}'?`:"";return`ERROR: Action [${e}] not found in registry.${b}`}try{return await(await g())(n,t)}catch(h){let m=h instanceof Error?h.message:String(h);return`ERROR: Execution failed for [${e}]: ${m}`}};var yi=e=>{if(!e||typeof e!="string")return!1;let n=e.trim().toLowerCase();return Object.keys(ta).some(t=>t.toLowerCase()===n)};import V from"path";import Ce from"fs";import{execSync as xs}from"child_process";import el from"gradient-string";var na=["I have a regex for your problems.","Your terminal, my kingdom.","Blowing on the cartridge helps. Probably.","Don't panic. I have the towel.","Logic is the start of wisdom.","Try to exit Vim? Good luck.","I speak fluent Terminal.","The cake is a lie. This code is not.","I have no bugs, just surprise features.","Rewriting in Rust... just for fun.","Coffee in, clean commits out.","The magic smoke stays inside today.","A semicolon short of a miracle.","One does not simply code without a bug.","Keep it simple. Keep it terminal.","Regex: now you have two problems.","I dream in binary.","Root access or bust.","Wait for the dial-up tone. Just kidding.","I take the 'labor' out of collab.","My other process is a TARDIS.","Calculated response: 42.","Ponder the orb. Ponder the code.","Less talk, more flow.","Elegance in every byte.","Build something the world is not ready for.","Your wishes, my tool calls.","I act in Flux. I think in Flow.","Syntax error in the universe. Please fix.","Your project, my obsession.","I am not a bot, I am an architect.","Digital spirits consulted. They say: Ship it.","Reticulate splines. Engage humor.","Code like poetry. Run like water.","Minimalism is the ultimate flex.","The truth is in the logs.","Follow the white rabbit.","There is no spoon. Only code.","Binary is the only language I trust.","I have a good feeling about this.","Pew pew! Lasers charged.","Divide by zero? Not today.","Search for the correct USB orientation...","I've got a fever, and the only cure is more code.","The code gremlins are on our side.","My favorite command? Yours.","Stay hungry. Stay active.","Momentum is your best friend.","Lead the flow. Don't chase it.","A fresh batch of bytes. Hot and ready.","I orchestrate the ones and zeros.","Smart enough to help. Humble enough to ask.","Think twice. Code once.","Pure intent. Pure execution.","Small steps. Massive impact.","Your terminal is a canvas.","Efficiency is my second name.","I have seen things you people wouldn't believe.","Let the thoughts marinate.","The best feature? The one you don't need.","Precision is the only perfection.","Stay focused. Stay terminal.","Silence is the best debugger.","Erase the debt. Commit the code.","Velocity meets stability.","Ship it. Improve it. Repeat.","Build tomorrow, right now.","Turn logic into reality.","The best way to predict the future is to build it.","Break barriers, not builds.","Fuel the next breakthrough.","Momentum is key.","Terminal vibes only.","Your digital co-pilot is ready.","Partner in code. Partner in crime.","I speak in semicolons.","Ready for the next great idea.","Just a moment. In the zone.","Polishing the algorithms. Hold tight.","Craft a masterpiece today.","Debug the universe. Start here.","Warp speed engaged. Almost.","The cake is not a lie. It's just loading.","Finish the Kessel Run in 12 parsecs.","Do a barrel roll!","Waiting for the respawn.","Press Start to continue.","Herding digital cats... done.","The hamsters are fast today.","Tasting the snozberries.","I go for speed. I go for flow.","Real life or just fantasy?","Poking the bear... gently.","Ensure the magic smoke stays inside.","Try turning it off and on again.","Construct additional pylons.","New line? Ctrl+J is your friend.","Release the HypnoDrones.","Push the button, Frank.","My other loading screen is even funnier.","Pretty sure a cat walked on my keyboard.","Recalibrate the humor-o-meter.","Summon the code gremlins.","I've seen your browser history. Just kidding.","Charge the laser... pew pew!","Dividing by zero... just for a sec.","Looking for an adult supervisor. Found none.","Make it go beep boop.","Buffering... for effect.","Entangle quantum particles... complete.","Polishing the chrome on my algorithms.","Are you not entertained?","Just waiting for the dial-up tone.","Reboot the humor module.","Defragment memories. Check.","Optimizing for ludicrous speed.","Swapping bits. Don't tell the bytes.","Garbage collected. I am back.","Assembling the interwebs.","Converting coffee to logic.","Update syntax for reality.","Rewire the synapses.","Greasin' the cogs.","Engage the improbability drive.","Channel the Force.","Align the stars. Respond now.","The cake is a lie. The prompt is real.","I'm Feeling Lucky.","Shipping awesomeness.","Navigating the slime mold.","Consult digital spirits.","Ask the magic conch shell.","One moment. Optimizing humor.","Shuffling punchlines.","Compiling brilliance.","Summon the cloud of wisdom.","Prepare to dazzle.","Hold tight. Crafting a response.","Tuning the algorithms.","Following the white rabbit... again.","The truth is in here. Somewhere.","Herding cats is my day job.","Distracting you with this phrase.","Almost there. Probably.","Rickrolling my creator. Don't tell.","Slapping the bass.","Is this real life?","Ponder the orb. Type the prompt.","Thoughtful gaze initiated.","Computer's favorite snack? Microchips.","Why Java? Because I don't C#.","Charging the laser... wait for it.","Dividing by zero... just kidding!","Adult supervision not found. Proceed.","Beep boop. I'm a real boy.","Wait for the respawn.","Finish the run. Ship the code.","Fiddling with character creation.","Just a moment. Finding a meme.","Pressing A to continue.","Loading wit.exe.","Pre-heating the servers.","Calibrate flux capacitor.","Channeling the Force.","Aligning the stars.","The truth is in the code.","Don't panic.","Blowing on the cartridge.","Doing a barrel roll!","Respawning in 3... 2... 1...","The cake is a lie.","Fiddling with character settings.","Finding a suitable pun.","Distracting with wit.","Almost ready.","Hamsters on speed today.","Patting Cloudy on the head.","Rickrolling the logs.","Slapping the code.","Got a good feeling about this.","Poking the prompt.","Researching latest memes.","Making it more witty.","Thinking... hmmm.","Fish with no eyes? Fsh.","Broken pencil? Pointless.","Percussive maintenance applied.","USB orientation: 3rd try's the charm.","Rust rewrite in 3... 2...","Exiting Vim... someday.","Spinning the hamster wheel.","Not a bug. Unplanned feature.","Engage.","I'll be back.","Machine spirit consulted.","Letting the thoughts marinate.","Orb pondered.","Thoughtful gaze engaged.","Charging the laser...","Making it go beep.","Buffering...","Quantum particles entangled.","Polishing the chrome.","Entertained yet?","Gremlins summoned.","Dial-up tone finished.","Humor meter recalibrated.","Cat on keyboard. Sending help.","Enhancing...","Turn it off and on again.","Constructing pylons.","HypnoDrones released.","Pushing the button."];var oa=["Beware the phantom processes.","A ghost in the shell has taken the wheel.","Blowing on the haunted cartridge...","Seven minutes in Raccoon City.","Wind's howling... in the terminal fans.","Slender Man was spotted in line 404.","The cake is a lie. The curse is real.","Don't look behind the server rack.","Exorcising memory leaks at 3 AM.","Pyramid Head reorganized your commit history.","It's dangerous to go alone! Take this flashlight.","YOU DIED. Respawning terminal session...","The Necronomicon evaluated to true.","Something wicked this way compiles.","Haunting your localhost with good vibes.","A full moon has risen over Git main.","Double, double toil and trouble; code fire burn.","Clickers heard in the directory tree.","Checking camera 2B for rogue animatronics.","The call is coming from inside the container.","Isaac Clarke is stomping on stubborn bugs.","Luigi vacuumed the ghosts out of RAM.","Trick or treat, give me clean code to greet.","Whispering incantations to the garbage collector.","Klaatu barada necktie... close enough.","Resurrecting deprecated APIs from the crypt.","The headless horseman forgot the return statement.","Castlevania whip cracking against network latency.","Slime mold crawling through the motherboard.","Carving a pixelated pumpkin into terminal history.","Burying undefined pointers in the pet sematary.","Spilling pumpkin spice on the CPU.","A vampire bat is draining system battery life.","Don't fall asleep at the keyboard tonight.","Silent Hill sirens sounding in the console.","Poltergeists rearranging terminal tabs.","Lighting the Black Flame Candle for autoExec.","Dusting cobwebs off legacy dependencies.","Here's Johnny! ...just checking build health.","Blood, sweat, and zero warnings.","The spirit box whispers: 'GIT PUSH FORCE'.","They're heeeere... in the stack trace.","It's alive! IT'S ALIVEEEE!","No merge conflicts in the graveyard.","Frankenstein's monster patched this logic.","Surviving Five Nights at Flux Flow.","Doom Slayer loading buckshot into cache.","The grim reaper spared your unused imports.","Candy corn lodged in mechanical switches.","May your latency be low and your crypt be quiet."];var ia=[{name:"Cyan Cyberpunk",text:"cyan",textMuted:"#4da6b8",textDim:"#2d6d7a",textInverted:"black",border:"cyan",borderMuted:"#1a5966",borderDim:"#0f3840",bg:void 0,cardBg:"#061e24",highlightBg:"#092b33",activeBg:"#0e3e4a",inputBg:"#092b33",inputBorder:"#092b33",inputText:"cyan",inputPlaceholder:"#2d6d7a",inputPrompt:"cyan",codeBg:"#020d10",codeBorder:"#1a5966",userMsgBg:"#092b33",userMsgBorder:"#092b33",userMsgText:"cyan",diffRemovalBg:"#3a0c1a",diffAdditionBg:"#0c3a32",diffRemovalText:"#ff4d88",diffAdditionText:"#00ffaa",diffRemovalHighlightColor:"#ff1a66",diffRemovalHighlightBg:"#590022",diffAdditionHighlightColor:"#00ffcc",diffAdditionHighlightBg:"#00593b",diffRemovalNum:"#ff4d88",diffAdditionNum:"#00ffaa",diffRemovalPrefix:"#ff1a66",diffAdditionPrefix:"#00ffcc",primary:"cyan",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"cyan",statusOff:"#2d6d7a",logoTextAnsi:"\x1B[1;36m",logoBodyAnsi:"\x1B[36m",logoMutedAnsi:"\x1B[90m",logoGradient:["#00ffff","#0088ff"]},{name:"Magenta Vaporwave",text:"magenta",textMuted:"#c451d6",textDim:"#7d2b8a",textInverted:"black",border:"magenta",borderMuted:"#5e1b69",borderDim:"#3b0f42",bg:void 0,cardBg:"#240729",highlightBg:"#310938",activeBg:"#470e52",inputBg:"#310938",inputBorder:"#310938",inputText:"magenta",inputPlaceholder:"#7d2b8a",inputPrompt:"magenta",codeBg:"#100312",codeBorder:"#5e1b69",userMsgBg:"#310938",userMsgBorder:"#310938",userMsgText:"magenta",diffRemovalBg:"#3a0c20",diffAdditionBg:"#200c3a",diffRemovalText:"#ff4d94",diffAdditionText:"#aa4dff",diffRemovalHighlightColor:"#ff1a75",diffRemovalHighlightBg:"#59002b",diffAdditionHighlightColor:"#bb66ff",diffAdditionHighlightBg:"#3b0059",diffRemovalNum:"#ff4d94",diffAdditionNum:"#aa4dff",diffRemovalPrefix:"#ff1a75",diffAdditionPrefix:"#bb66ff",primary:"magenta",secondary:"cyan",accent:"purple",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"magenta",statusOff:"#7d2b8a",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ff00ff","#8800ff"]},{name:"Glitch Matrix",text:"#00ff41",textMuted:"#00b32d",textDim:"#00661a",textInverted:"black",border:"#00ff41",borderMuted:"#008020",borderDim:"#004d13",bg:void 0,cardBg:"#0d1f0d",highlightBg:"#122912",activeBg:"#1c3e1c",inputBg:"#122912",inputBorder:"#122912",inputText:"#00ff41",inputPlaceholder:"#00b32d",inputPrompt:"#ffff00",codeBg:"#040a04",codeBorder:"#008020",userMsgBg:"#122912",userMsgBorder:"#122912",userMsgText:"#00ff41",diffRemovalBg:"#3a001a",diffAdditionBg:"#003a10",diffRemovalText:"#ff0055",diffAdditionText:"#00ff66",diffRemovalHighlightColor:"#ff0033",diffRemovalHighlightBg:"#59001b",diffAdditionHighlightColor:"#33ff88",diffAdditionHighlightBg:"#005918",diffRemovalNum:"#ff0055",diffAdditionNum:"#00ff66",diffRemovalPrefix:"#ff0033",diffAdditionPrefix:"#33ff88",primary:"#00ff41",secondary:"yellow",accent:"cyan",success:"#00ff41",warning:"yellow",danger:"red",info:"cyan",statusOn:"#00ff41",statusOff:"#00661a",logoTextAnsi:"\x1B[1;32m",logoBodyAnsi:"\x1B[32m",logoMutedAnsi:"\x1B[90m",logoGradient:["#00ff41","#ffff00"]},{name:"Warm Sunset",text:"#ffaa55",textMuted:"#cc8844",textDim:"#885522",textInverted:"black",border:"#ff9933",borderMuted:"#aa6622",borderDim:"#663311",bg:void 0,cardBg:"#24180f",highlightBg:"#2e1e12",activeBg:"#422c1b",inputBg:"#2e1e12",inputBorder:"#2e1e12",inputText:"#ffaa55",inputPlaceholder:"#885522",inputPrompt:"#ff7733",codeBg:"#120c08",codeBorder:"#aa6622",userMsgBg:"#2e1e12",userMsgBorder:"#2e1e12",userMsgText:"#ffaa55",diffRemovalBg:"#3d120c",diffAdditionBg:"#3a2e0c",diffRemovalText:"#ff5544",diffAdditionText:"#ffcc33",diffRemovalHighlightColor:"#ff3322",diffRemovalHighlightBg:"#591108",diffAdditionHighlightColor:"#ffee44",diffAdditionHighlightBg:"#594400",diffRemovalNum:"#ff5544",diffAdditionNum:"#ffcc33",diffRemovalPrefix:"#ff3322",diffAdditionPrefix:"#ffee44",primary:"#ffaa55",secondary:"#ff7733",accent:"magenta",success:"#ffcc33",warning:"#ff7733",danger:"#ff3322",info:"#ffaa55",statusOn:"#ffaa55",statusOff:"#885522",logoTextAnsi:"\x1B[1;33m",logoBodyAnsi:"\x1B[33m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ff9933","#ff0055"]},{name:"Sakura Blossom",text:"#ffc0e0",textMuted:"#d98cb3",textDim:"#804d66",textInverted:"black",border:"#ff99cc",borderMuted:"#aa4d7a",borderDim:"#662647",bg:void 0,cardBg:"#291320",highlightBg:"#331826",activeBg:"#472235",inputBg:"#331826",inputBorder:"#331826",inputText:"#ffc0e0",inputPlaceholder:"#804d66",inputPrompt:"#ff99cc",codeBg:"#140a10",codeBorder:"#aa4d7a",userMsgBg:"#331826",userMsgBorder:"#331826",userMsgText:"#ffc0e0",diffRemovalBg:"#3e0c1b",diffAdditionBg:"#1b3e2b",diffRemovalText:"#ff6699",diffAdditionText:"#66ffb3",diffRemovalHighlightColor:"#ff3377",diffRemovalHighlightBg:"#590022",diffAdditionHighlightColor:"#33ff99",diffAdditionHighlightBg:"#00592e",diffRemovalNum:"#ff6699",diffAdditionNum:"#66ffb3",diffRemovalPrefix:"#ff3377",diffAdditionPrefix:"#33ff99",primary:"#ffc0e0",secondary:"#ff99cc",accent:"magenta",success:"#66ffb3",warning:"yellow",danger:"#ff3377",info:"#ff99cc",statusOn:"#ffc0e0",statusOff:"#804d66",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ffb3d9","#ff3399"]},{name:"Radioactive Slime",text:"#ccff00",textMuted:"#99cc00",textDim:"#669900",textInverted:"#0a0f00",border:"#ccff00",borderMuted:"#99cc00",borderDim:"#669900",bg:void 0,cardBg:"#0f1400",highlightBg:"#1a2400",activeBg:"#2a3b00",inputBg:"#1a2400",inputBorder:"#1a2400",inputText:"#ccff00",inputPlaceholder:"#669900",inputPrompt:"#cc00ff",codeBg:"#050a00",codeBorder:"#99cc00",userMsgBg:"#1a2400",userMsgBorder:"#1a2400",userMsgText:"#ccff00",diffRemovalBg:"#2a0033",diffAdditionBg:"#0f3300",diffRemovalText:"#ff00cc",diffAdditionText:"#00ff33",diffRemovalHighlightColor:"#ff33cc",diffRemovalHighlightBg:"#4d0066",diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:"#1a6600",diffRemovalNum:"#ff00cc",diffAdditionNum:"#00ff33",diffRemovalPrefix:"#ff33cc",diffAdditionPrefix:"#33ff66",primary:"#ccff00",secondary:"#cc00ff",accent:"#ff00cc",success:"#00ff33",warning:"#ffcc00",danger:"#ff0033",info:"#00ccff",statusOn:"#ccff00",statusOff:"#669900",logoTextAnsi:"\x1B[1;38;5;190m",logoBodyAnsi:"\x1B[38;5;190m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ccff00","#cc00ff"]},{name:"Cosmic Void",text:"#f0f8ff",textMuted:"#a6aeb5",textDim:"#5e656e",textInverted:"#010103",border:"#f0f8ff",borderMuted:"#a6aeb5",borderDim:"#5e656e",bg:void 0,cardBg:"#05030d",highlightBg:"#0b081a",activeBg:"#171133",inputBg:"#0b081a",inputBorder:"#0b081a",inputText:"#f0f8ff",inputPlaceholder:"#5e656e",inputPrompt:"#ff007f",codeBg:"#020108",codeBorder:"#a6aeb5",userMsgBg:"#0b081a",userMsgBorder:"#0b081a",userMsgText:"#f0f8ff",diffRemovalBg:"#2e0a29",diffAdditionBg:"#091c33",diffRemovalText:"#ff33a6",diffAdditionText:"#33d6ff",diffRemovalHighlightColor:"#ff66c2",diffRemovalHighlightBg:"#5c1452",diffAdditionHighlightColor:"#66e0ff",diffAdditionHighlightBg:"#123866",diffRemovalNum:"#ff33a6",diffAdditionNum:"#33d6ff",diffRemovalPrefix:"#ff66c2",diffAdditionPrefix:"#66e0ff",primary:"#f0f8ff",secondary:"#ff007f",accent:"#9d00ff",success:"#33d6ff",warning:"#ffcc00",danger:"#ff0040",info:"#9d00ff",statusOn:"#f0f8ff",statusOff:"#5e656e",logoTextAnsi:"\x1B[1;38;5;231m",logoBodyAnsi:"\x1B[38;5;231m",logoMutedAnsi:"\x1B[38;5;240m",logoGradient:["#ffffff","#9d00ff"]},{name:"Magma Eruption",text:"#ff4d00",textMuted:"#cc3d00",textDim:"#802600",textInverted:"#0d0300",border:"#ff4d00",borderMuted:"#cc3d00",borderDim:"#802600",bg:void 0,cardBg:"#1a0600",highlightBg:"#260a00",activeBg:"#401100",inputBg:"#260a00",inputBorder:"#260a00",inputText:"#ff4d00",inputPlaceholder:"#802600",inputPrompt:"#ffcc00",codeBg:"#080200",codeBorder:"#cc3d00",userMsgBg:"#260a00",userMsgBorder:"#260a00",userMsgText:"#ff4d00",diffRemovalBg:"#2e0a0a",diffAdditionBg:"#1f1400",diffRemovalText:"#ff3333",diffAdditionText:"#ffaa00",diffRemovalHighlightColor:"#ff6666",diffRemovalHighlightBg:"#5c1414",diffAdditionHighlightColor:"#ffcc33",diffAdditionHighlightBg:"#3d2900",diffRemovalNum:"#ff3333",diffAdditionNum:"#ffaa00",diffRemovalPrefix:"#ff6666",diffAdditionPrefix:"#ffcc33",primary:"#ff4d00",secondary:"#ffcc00",accent:"#ff0040",success:"#ffaa00",warning:"#ffff00",danger:"#ff0000",info:"#ff8800",statusOn:"#ff4d00",statusOff:"#802600",logoTextAnsi:"\x1B[1;38;5;202m",logoBodyAnsi:"\x1B[38;5;202m",logoMutedAnsi:"\x1B[38;5;236m",logoGradient:["#ff4d00","#ff0000"]}],ao={Dark:{id:"Dark",name:"Dark (Default)",text:"white",textMuted:"gray",textDim:"grey",textInverted:"black",textExclusive:"#B5B8D9",textMutedExclusive:"#D4DEE7",border:"white",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:"#1e1e1e",highlightBg:"#2a2a2a",activeBg:"#3a3a3a",inputBg:"#555555",inputBorder:"#555555",inputText:"white",inputPlaceholder:"#cccccc",inputPrompt:"white",codeBg:"#1a1a1a",codeBorder:"#444444",userMsgBg:"#444444",userMsgBorder:"#444444",userMsgText:"white",diffRemovalBg:"#250808",diffAdditionBg:"#072410",diffRemovalText:"#885555",diffAdditionText:"#558866",diffRemovalHighlightColor:"#ff3333",diffRemovalHighlightBg:"#5a1818",diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:"#185a25",diffRemovalNum:"#d96868",diffAdditionNum:"#68d98c",diffRemovalPrefix:"#ff4d4d",diffAdditionPrefix:"#4dff88",primary:"white",secondary:"cyan",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"white",statusOff:"gray",logoTextAnsi:"\x1B[1;37m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},Light:{id:"Light",name:"Light",text:"black",textMuted:"gray",textDim:"grey",textInverted:"white",border:"black",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:"#e5e5e5",highlightBg:"#d4d4d4",activeBg:"#c0c0c0",inputBg:"#d0d0d0",inputBorder:"#d0d0d0",inputText:"black",inputPlaceholder:"#555555",inputPrompt:"black",codeBg:"#e8e8e8",codeBorder:"#b0b0b0",userMsgBg:"#d0d0d0",userMsgBorder:"#d0d0d0",userMsgText:"black",diffRemovalBg:"#fce8e8",diffAdditionBg:"#e6f9e6",diffRemovalText:"#661111",diffAdditionText:"#115511",diffRemovalHighlightColor:"#440000",diffRemovalHighlightBg:"#f8b4b4",diffAdditionHighlightColor:"#003300",diffAdditionHighlightBg:"#a6ebad",diffRemovalNum:"#c02020",diffAdditionNum:"#188028",diffRemovalPrefix:"#d01010",diffAdditionPrefix:"#109020",primary:"black",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"black",statusOff:"gray",logoTextAnsi:"\x1B[1;30m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},"GitHub Dark":{id:"GitHub Dark",name:"GitHub Dark",text:"#c9d1d9",textMuted:"#8b949e",textDim:"#6e7681",textInverted:"#0d1117",border:"#30363d",borderMuted:"#30363d",borderDim:"#21262d",bg:void 0,cardBg:"#161b22",highlightBg:"#21262d",activeBg:"#30363d",inputBg:"#21262d",inputBorder:"#21262d",inputText:"#c9d1d9",inputPlaceholder:"#8b949e",inputPrompt:"#58a6ff",codeBg:"#0d1117",codeBorder:"#30363d",userMsgBg:"#21262d",userMsgBorder:"#21262d",userMsgText:"#c9d1d9",diffRemovalBg:"#3c1e1e",diffAdditionBg:"#11381e",diffRemovalText:"#f85149",diffAdditionText:"#3fb950",diffRemovalHighlightColor:"#ff7b72",diffRemovalHighlightBg:"#701c1c",diffAdditionHighlightColor:"#56d364",diffAdditionHighlightBg:"#116329",diffRemovalNum:"#f85149",diffAdditionNum:"#3fb950",diffRemovalPrefix:"#f85149",diffAdditionPrefix:"#3fb950",primary:"#c9d1d9",secondary:"#58a6ff",accent:"#bc8cff",success:"#3fb950",warning:"#d29922",danger:"#f85149",info:"#58a6ff",statusOn:"#58a6ff",statusOff:"#8b949e",logoTextAnsi:"\x1B[1;36m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#2ea043","#56d364"],toolFeedbackAnsi:"\x1B[95m"},"GitHub Light":{id:"GitHub Light",name:"GitHub Light",text:"#24292f",textMuted:"#57606a",textDim:"#6e7781",textInverted:"#ffffff",border:"#d0d7de",borderMuted:"#d0d7de",borderDim:"#e1e4e8",bg:void 0,cardBg:"#f6f8fa",highlightBg:"#eaeef2",activeBg:"#d0d7de",inputBg:"#eaeef2",inputBorder:"#eaeef2",inputText:"#24292f",inputPlaceholder:"#57606a",inputPrompt:"#0969da",codeBg:"#ffffff",codeBorder:"#d0d7de",userMsgBg:"#eaeef2",userMsgBorder:"#eaeef2",userMsgText:"#24292f",diffRemovalBg:"#ffebe9",diffAdditionBg:"#e6ffec",diffRemovalText:"#cf222e",diffAdditionText:"#1a7f37",diffRemovalHighlightColor:"#82071e",diffRemovalHighlightBg:"#ffc1c0",diffAdditionHighlightColor:"#116329",diffAdditionHighlightBg:"#acf2bd",diffRemovalNum:"#cf222e",diffAdditionNum:"#1a7f37",diffRemovalPrefix:"#cf222e",diffAdditionPrefix:"#1a7f37",primary:"#24292f",secondary:"#0969da",accent:"#8250df",success:"#1a7f37",warning:"#9a6700",danger:"#cf222e",info:"#0969da",statusOn:"#0969da",statusOff:"#57606a",logoTextAnsi:"\x1B[1;34m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#1a7f37","#2da44e"],toolFeedbackAnsi:"\x1B[95m"},"Transparent Dark":{id:"Transparent Dark",name:"Transparent Dark",text:"white",textMuted:"gray",textDim:"grey",textInverted:"black",border:"gray",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:void 0,highlightBg:"#2a2a2a",activeBg:"#3a3a3a",inputBg:"#555555",inputBorder:"#555555",inputText:"white",inputPlaceholder:"#cccccc",inputPrompt:"white",codeBg:void 0,codeBorder:"gray",userMsgBg:"#555555",userMsgBorder:"#555555",userMsgText:"white",diffRemovalBg:void 0,diffAdditionBg:void 0,diffRemovalText:"#ff6666",diffAdditionText:"#66ff66",diffRemovalHighlightColor:"#ff3333",diffRemovalHighlightBg:"#3a1414",diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:"#143a14",diffRemovalNum:"#ff6666",diffAdditionNum:"#66ff66",diffRemovalPrefix:"#ff4d4d",diffAdditionPrefix:"#4dff88",primary:"white",secondary:"cyan",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"white",statusOff:"gray",logoTextAnsi:"\x1B[1;37m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},"Transparent Light":{id:"Transparent Light",name:"Transparent Light",text:"black",textMuted:"gray",textDim:"grey",textInverted:"white",border:"gray",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:void 0,highlightBg:"#d4d4d4",activeBg:"#c0c0c0",inputBg:"#d0d0d0",inputBorder:"#d0d0d0",inputText:"black",inputPlaceholder:"#555555",inputPrompt:"black",codeBg:void 0,codeBorder:"gray",userMsgBg:"#d0d0d0",userMsgBorder:"#d0d0d0",userMsgText:"black",diffRemovalBg:void 0,diffAdditionBg:void 0,diffRemovalText:"#c02020",diffAdditionText:"#188028",diffRemovalHighlightColor:"#800000",diffRemovalHighlightBg:"#f5d0d0",diffAdditionHighlightColor:"#004000",diffAdditionHighlightBg:"#cceccc",diffRemovalNum:"#c02020",diffAdditionNum:"#188028",diffRemovalPrefix:"#d01010",diffAdditionPrefix:"#109020",primary:"black",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"black",statusOff:"gray",logoTextAnsi:"\x1B[1;30m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},"Synthwave 84":{id:"Synthwave 84",name:"Synthwave 84",text:"#fdfdfd",textMuted:"#a08eb7",textDim:"#705c8a",textInverted:"#1a1025",textExclusive:"#e3dcf0",textMutedExclusive:"#b9abc9",border:"#fc28a8",borderMuted:"#a21568",borderDim:"#5c0a3a",bg:void 0,cardBg:"#261b38",highlightBg:"#35254d",activeBg:"#4c3570",inputBg:"#35254d",inputBorder:"#35254d",inputText:"#fdfdfd",inputPlaceholder:"#a08eb7",inputPrompt:"#03e8fc",codeBg:"#1e142b",codeBorder:"#a21568",userMsgBg:"#35254d",userMsgBorder:"#35254d",userMsgText:"#fdfdfd",diffRemovalBg:"#471434",diffAdditionBg:"#144743",diffRemovalText:"#ff4081",diffAdditionText:"#00e5ff",diffRemovalHighlightColor:"#ff79a1",diffRemovalHighlightBg:"#6b1e4e",diffAdditionHighlightColor:"#66f5ff",diffAdditionHighlightBg:"#1e6b65",diffRemovalNum:"#ff4081",diffAdditionNum:"#00e5ff",diffRemovalPrefix:"#ff79a1",diffAdditionPrefix:"#66f5ff",primary:"#fdfdfd",secondary:"#03e8fc",accent:"#fc28a8",success:"#00e5ff",warning:"#ffc107",danger:"#ff4081",info:"#b388ff",statusOn:"#03e8fc",statusOff:"#a08eb7",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#fc28a8","#03e8fc"],toolFeedbackAnsi:"\x1B[38;2;3;232;252m"},"Forest Sprite":{id:"Forest Sprite",name:"Forest Sprite",text:"#d6e6d1",textMuted:"#95b38d",textDim:"#628059",textInverted:"#161c14",textExclusive:"#eaf2e8",textMutedExclusive:"#a9c7a2",border:"#74a862",borderMuted:"#477038",borderDim:"#2b4720",bg:void 0,cardBg:"#1f291c",highlightBg:"#2a3826",activeBg:"#3a4d35",inputBg:"#2a3826",inputBorder:"#2a3826",inputText:"#d6e6d1",inputPlaceholder:"#95b38d",inputPrompt:"#8feb73",codeBg:"#161e14",codeBorder:"#477038",userMsgBg:"#2a3826",userMsgBorder:"#2a3826",userMsgText:"#d6e6d1",diffRemovalBg:"#3b231c",diffAdditionBg:"#203b1c",diffRemovalText:"#db6242",diffAdditionText:"#59cc3f",diffRemovalHighlightColor:"#f0896c",diffRemovalHighlightBg:"#5c362a",diffAdditionHighlightColor:"#80e368",diffAdditionHighlightBg:"#305929",diffRemovalNum:"#db6242",diffAdditionNum:"#59cc3f",diffRemovalPrefix:"#f0896c",diffAdditionPrefix:"#80e368",primary:"#d6e6d1",secondary:"#8feb73",accent:"#e69835",success:"#59cc3f",warning:"#e69835",danger:"#db6242",info:"#73b4eb",statusOn:"#8feb73",statusOff:"#95b38d",logoTextAnsi:"\x1B[1;32m",logoBodyAnsi:"\x1B[32m",logoMutedAnsi:"\x1B[90m",logoGradient:["#8feb73","#e69835"],toolFeedbackAnsi:"\x1B[38;2;143;235;115m"},Spookfest:{id:"Spookfest",name:"Spookfest \u{1F383}",text:"#ffeedd",textMuted:"#e09858",textDim:"#a6622b",textInverted:"#0d0702",textExclusive:"#fff3e6",textMutedExclusive:"#d4a276",border:"#ff7518",borderMuted:"#994409",borderDim:"#592502",bg:void 0,cardBg:"#1a0c02",highlightBg:"#2a1403",activeBg:"#3d1d05",inputBg:"#261203",inputBorder:"#261203",inputText:"#ffeedd",inputPlaceholder:"#a6622b",inputPrompt:"#ff7518",codeBg:"#120701",codeBorder:"#592502",userMsgBg:"#261203",userMsgBorder:"#261203",userMsgText:"#ffeedd",diffRemovalBg:"#3d0a0a",diffAdditionBg:"#1a330a",diffRemovalText:"#ff5555",diffAdditionText:"#73e639",diffRemovalHighlightColor:"#ff2222",diffRemovalHighlightBg:"#590e0e",diffAdditionHighlightColor:"#88ff3b",diffAdditionHighlightBg:"#244d0a",diffRemovalNum:"#ff5555",diffAdditionNum:"#73e639",diffRemovalPrefix:"#ff3333",diffAdditionPrefix:"#88ff3b",primary:"#ff7518",secondary:"#a855f7",accent:"#22c55e",success:"#22c55e",warning:"#f59e0b",danger:"#ef4444",info:"#a855f7",statusOn:"#ff7518",statusOff:"#703a08",logoTextAnsi:"\x1B[1;38;2;255;117;24m",logoBodyAnsi:"\x1B[38;2;255;140;26m",logoMutedAnsi:"\x1B[38;2;168;85;247m",logoGradient:["#ff7518","#a855f7"],toolFeedbackAnsi:"\x1B[38;2;255;117;24m"}};var xi=null;var bi=(e="Dark")=>{let n;e==="Mystery"||e==="Chaos"?(xi||(xi=ia[Math.floor(Math.random()*ia.length)]),n={...xi,id:"Mystery"}):(xi=null,ao[e]?n=ao[e]:e==="Halloween"?n=ao.Spookfest:e==="GitHub"?n=ao["GitHub Dark"]:e==="Transparent"?n=ao["Transparent Dark"]:n=ao.Dark);let t=n.codeText||n.secondary||n.info||n.logoGradient&&n.logoGradient[0]||"cyan",i=n.toolFeedbackAnsi||"\x1B[95m";return{...n,codeText:t,toolFeedbackAnsi:i}};var tl=()=>process.env.TERM_PROGRAM==="vscode"?"vscode":process.env.WT_SESSION?"wt":"default",Jc=(e=2)=>{let n=tl();return n==="wt"?" ".repeat(Math.max(1,e-1)):" ".repeat(e)},sa=new Date,$o=sa.getMonth(),Lo=sa.getDate(),nl=$o===9&&Lo>=15||$o===10&&Lo<=1,gs=null;(process.env.SPOOKFEST==="true"||nl)&&(gs=await import("./halloween-MX3VNQRW.js"));var Qc=(e="...",n="Loading...",t="Dark")=>{let i=bi(t),o=n;if(n==="c_openai"||n==="Custom (OpenAI)")try{let z=Zo(Jo,{})?.systemSettings?.customOpenAIBaseUrl;z&&(o=z)}catch{}let r=i.logoTextAnsi,d=i.logoBodyAnsi,l=i.logoMutedAnsi,u="\x1B[0m",g=[" \u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2591 "," \u2588\u2588\u2588\u2591 "," \u2588\u2588\u2588\u2591 "," \u2591\u2591\u2591 "],h=t==="Spookfest"||i.id==="Spookfest"||t==="Halloween"||i.id==="Halloween",m=$o===9&&Lo>=15||$o===10&&Lo<=1,p=h&&m||process.env.SPOOKFEST==="true"&&h,s=g;if(p&&gs){process.env.HALLOWEEN_EEGG="true";let{halloweenArtSide:P,halloweenBat:z,halloweenArtUser:M}=gs;s=Math.random()>.9&&$o===9&&Lo>=30?z:Math.random()>.5?P:M}else process.env.HALLOWEEN_EEGG="false";let b=p?oa:na,_=b[Math.floor(Math.random()*b.length)],Le=i.logoGradient||["#0077ff","#ff00ff"],v=el(Le).multiline(s.join(`
530
530
  `)).split(`
531
531
  `),N=P=>`${l}${P}${u}`;return`${v[0]}
532
532
  ${v[1]} ${r}Selected ${p?"Pumpkin":"Provider"}: ${o}${u}
@@ -536,26 +536,26 @@ ${v[4]}
536
536
  ${v[5]} ${d}See /help for additional commands.${u}
537
537
  ${v[6]} ${N(_)}
538
538
  ${v[7]}
539
- `};import{structuredPatch as al}from"diff";import ms from"path";import ol from"fs";var il=e=>{try{return ol.readdirSync(e,{withFileTypes:!0})}catch{return[]}},ps=(e,n=4,t=1,i=il,o=[],r=null)=>{let d=r||i(e),l=" ".repeat(t-1),u=t===1?new Set([...wo,...o,...bo(e),...bo(process.cwd())]):o instanceof Set?o:new Set([...wo,...o]),g=M=>u.has(M),h=d.filter(M=>!g(M.name)),m=d.filter(M=>g(M.name)).length,p=h.filter(M=>!M.isDirectory()).map(M=>M.name).sort(),s=h.filter(M=>M.isDirectory()).sort((M,$)=>M.name.localeCompare($.name)),w=M=>{let $=M.length;if($===0)return"no files";let ye=Array.from(new Set(M.map(Ie=>{let Xe=typeof Ie=="string"?Ie:Ie.name;return ms.extname(Xe).slice(1)}).filter(Boolean))).sort(),ve="*";return ye.length===1?ve=`*.${ye[0]}`:ye.length>1&&(ve=`*.{${ye.join(", ")}}`),$===1?ve:`${ve} ${$} files`},_="";if(t===1){let M=p.join(", "),$=m>0?` [${m} ignored]`:"";(M||$)&&(_+=`${l}${M?M+($?`${$}`:""):$.trim()}
540
- `)}else p.length>0&&(_+=`${l}[${w(p)}]
541
- `);let $e=10,v=s.slice(0,$e),N=s.length>$e,P=[],V=[];for(let M of v){let $=ms.join(e,M.name),ye=M.name,ve=t,Ie=i($),Xe=Ie.filter(De=>!g(De.name)),U=Xe.filter(De=>De.isDirectory()),x=Xe.filter(De=>!De.isDirectory());for(;x.length===0&&U.length===1&&ve<n;)ye=`${ye}/${U[0].name}`,$=ms.join($,U[0].name),ve++,Ie=i($),Xe=Ie.filter(De=>!g(De.name)),U=Xe.filter(De=>De.isDirectory()),x=Xe.filter(De=>!De.isDirectory());let zt=U.length>0;if(zt&&ve<n)V.push({displayName:ye,subDirPath:$,subEntries:Ie,nextDepth:ve+1});else{let De=w(x),qt=zt&&ve>=n?" ...max scan depth":"";P.push(`${ye}/${De}${qt}`)}}P.length>0&&(_+=`${l}${P.join(", ")}
542
- `);for(let{displayName:M,subDirPath:$,subEntries:ye,nextDepth:ve}of V)_+=`${l}${M}/
543
- `,_+=ps($,n,ve,i,u,ye);return N&&(_+=`${l}...max scan width, ReadFolder if needed
539
+ `};import{structuredPatch as al}from"diff";import ms from"path";import ol from"fs";var il=e=>{try{return ol.readdirSync(e,{withFileTypes:!0})}catch{return[]}},ps=(e,n=4,t=1,i=il,o=[],r=null)=>{let d=r||i(e),l=" ".repeat(t-1),u=t===1?new Set([...bo,...o,...wo(e),...wo(process.cwd())]):o instanceof Set?o:new Set([...bo,...o]),g=M=>u.has(M),h=d.filter(M=>!g(M.name)),m=d.filter(M=>g(M.name)).length,p=h.filter(M=>!M.isDirectory()).map(M=>M.name).sort(),s=h.filter(M=>M.isDirectory()).sort((M,$)=>M.name.localeCompare($.name)),b=M=>{let $=M.length;if($===0)return"no files";let xe=Array.from(new Set(M.map(Ie=>{let Je=typeof Ie=="string"?Ie:Ie.name;return ms.extname(Je).slice(1)}).filter(Boolean))).sort(),ve="*";return xe.length===1?ve=`*.${xe[0]}`:xe.length>1&&(ve=`*.{${xe.join(", ")}}`),$===1?ve:`${ve} ${$} files`},_="";if(t===1){let M=p.join(", "),$=m>0?` [${m} ignored]`:"";(M||$)&&(_+=`${l}${M?M+($?`${$}`:""):$.trim()}
540
+ `)}else p.length>0&&(_+=`${l}[${b(p)}]
541
+ `);let Le=10,v=s.slice(0,Le),N=s.length>Le,P=[],z=[];for(let M of v){let $=ms.join(e,M.name),xe=M.name,ve=t,Ie=i($),Je=Ie.filter(Ne=>!g(Ne.name)),U=Je.filter(Ne=>Ne.isDirectory()),x=Je.filter(Ne=>!Ne.isDirectory());for(;x.length===0&&U.length===1&&ve<n;)xe=`${xe}/${U[0].name}`,$=ms.join($,U[0].name),ve++,Ie=i($),Je=Ie.filter(Ne=>!g(Ne.name)),U=Je.filter(Ne=>Ne.isDirectory()),x=Je.filter(Ne=>!Ne.isDirectory());let zt=U.length>0;if(zt&&ve<n)z.push({displayName:xe,subDirPath:$,subEntries:Ie,nextDepth:ve+1});else{let Ne=b(x),qt=zt&&ve>=n?" ...max scan depth":"";P.push(`${xe}/${Ne}${qt}`)}}P.length>0&&(_+=`${l}${P.join(", ")}
542
+ `);for(let{displayName:M,subDirPath:$,subEntries:xe,nextDepth:ve}of z)_+=`${l}${M}/
543
+ `,_+=ps($,n,ve,i,u,xe);return N&&(_+=`${l}...max scan width, ReadFolder if needed
544
544
  `),_};import hs from"path";import sl from"fs";var rl=e=>{try{return sl.readdirSync(e,{withFileTypes:!0})}catch{return[]}},ys=(e,n,t="",i=1,o=rl,r=[])=>{let d=o(e),l=hs.sep;if(d.length>100)return`${t}\u2514\u2500\u2500 ${hs.basename(e)}${l} ...100+ files...
545
- `;let u="",g=r,h=d.filter(s=>!g.includes(s.name)&&!s.name.startsWith(".")),m=d.filter(s=>g.includes(s.name)||s.name.startsWith(".")).map(s=>s.name).sort();h.sort((s,w)=>s.isDirectory()&&!w.isDirectory()?-1:!s.isDirectory()&&w.isDirectory()?1:s.name.localeCompare(w.name));let p=[...h.map(s=>({name:s.name,isDir:s.isDirectory()})),...m.map(s=>({name:s,isDir:!0,isCollapsed:!0}))];return p.forEach((s,w)=>{let _=w===p.length-1,$e=hs.join(e,s.name),v=_?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",N=t+(_?" ":"\u2502 ");if(s.isCollapsed){u+=`${t}${v}${s.name}${l}...
545
+ `;let u="",g=r,h=d.filter(s=>!g.includes(s.name)&&!s.name.startsWith(".")),m=d.filter(s=>g.includes(s.name)||s.name.startsWith(".")).map(s=>s.name).sort();h.sort((s,b)=>s.isDirectory()&&!b.isDirectory()?-1:!s.isDirectory()&&b.isDirectory()?1:s.name.localeCompare(b.name));let p=[...h.map(s=>({name:s.name,isDir:s.isDirectory()})),...m.map(s=>({name:s,isDir:!0,isCollapsed:!0}))];return p.forEach((s,b)=>{let _=b===p.length-1,Le=hs.join(e,s.name),v=_?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",N=t+(_?" ":"\u2502 ");if(s.isCollapsed){u+=`${t}${v}${s.name}${l}...
546
546
  `;return}s.isDir?i>n?u+=`${t}${v}${s.name}${l} ...depth exceeded...
547
- `:o($e).length>80?u+=`${t}${v}${s.name}${l} ...80+ files...
547
+ `:o(Le).length>80?u+=`${t}${v}${s.name}${l} ...80+ files...
548
548
  `:(u+=`${t}${v}${s.name}${l}
549
- `,u+=ys($e,n,N,i+1,o,r)):u+=`${t}${v}${s.name}
550
- `}),u};var ll={Ollama:()=>import("./ollama-53BJCQQX.js").then(e=>e.getOllamaStream),OpenRouter:()=>import("./openrouter-LSG67TST.js").then(e=>e.getOpenRouterStream),DeepSeek:()=>import("./deepseek-I2J4A7WQ.js").then(e=>e.getDeepSeekStream),Mistral:()=>import("./mistral-H23J6UYA.js").then(e=>e.getMistralStream),NVIDIA:()=>import("./nvidia-BUWXTYGV.js").then(e=>e.getNVIDIAStream),NVIDIA_wrap:()=>import("./nvidia-BUWXTYGV.js").then(e=>e.wrapNvidiaStreamWithQueueDepth),InferX:()=>import("./inferx-B6PKXWLZ.js").then(e=>e.getInferXStream),SenseNova:()=>import("./sensenova-MLFZTP7U.js").then(e=>e.getSenseNovaStream),AIHubMix:()=>import("./aihubmix-KJIG7CZO.js").then(e=>e.getAIHubMixStream),Poolside:()=>import("./poolside-KWCBEP3P.js").then(e=>e.getPoolsideStream),NineRouter:()=>import("./9router-KRJQK6JP.js").then(e=>e.getNineRouterStream),ExpLabs:()=>import("./explabs-OYP64XS6.js").then(e=>e.getExpLabsStream),TokenHarbor:()=>import("./tokenharbor-Y6HSTTHA.js").then(e=>e.getTokenHarborStream),Infron:()=>import("./infron-4SLX3HMD.js").then(e=>e.getInfronStream),APInex:()=>import("./apinex-EP3JJPZO.js").then(e=>e.getAPInexStream),xKiro:()=>import("./xkiro-D3DTPVWY.js").then(e=>e.getXKiroStream),c_openai:()=>import("./custom_openai-ODYQEMOR.js").then(e=>e.getCustomOpenAIStream)},ws={},he=async e=>(ws[e]||(ws[e]=await ll[e]()),ws[e]),cl=/```[\s\S]*?```/g,dl=/```[\s\S]*$/g,fl=/`[^`]+`/g,ul=/^\|.*\|$/gm,gl=/^[^\w]+|[^\w]+$/g,ml=/[^a-z0-9]/gi,Oo=/\[\s*(?:tool|action):(?:functions\.)?([a-z0-9_]+)\s*\(/gi,pl=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-z0-9_]+)\s*\(/gi,hl=/(?:path|targetFile|TargetFile|directory|keyword|id|taskId|title|task)\s*=\s*\\?["']?([^\\"' \),]+)/,Sn=/["']/g,ra=/\\/g,yl=/<\|channel>thought/gi,xl=/<channel\|>/gi,wl=e=>typeof e!="string"?e:e.replace(yl,"<think_fluxflow>").replace(xl,"</think_fluxflow>"),Vd=/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\]|$)/i,bl=(e,n,t=1)=>{let i=n>0?e[n-1]:"",o=n+t<e.length?e[n+t]:"";return i==="`"&&o==="`"},Sl=e=>{let n=/(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\])/gi,t;for(;(t=n.exec(e))!==null;)if(!bl(e,t.index,t[0].length))return{index:t.index,length:t[0].length};return{index:-1,length:0}},bs=e=>{if(!e||typeof e!="string")return null;let n=e.match(/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])/i);if(!n)return null;let t=n.index+n[0].length,i=e.substring(t),o=Sl(i);if(o.index!==-1){let r=t+o.index+o.length;return{fullBlock:e.substring(0,r),innerContent:i.substring(0,o.index),remainingText:e.substring(r)}}return{fullBlock:e,innerContent:i,remainingText:""}},Nt=e=>{if(!e||typeof e!="string")return e;let n=bs(e);return n?n.remainingText.trimStart():e};var aa=/<\|\s*tool_call_begin\s*\|>\s*(?:(?:tool|functions)\b[\s._]*)*([a-zA-Z0-9_]+)(?::\d+)?\s*<\|\s*tool_call_argument_begin\s*\|>([\s\S]*?)<\|\s*tool_call_end\s*\|>/gi,kl=/"([^"]+)"\s*:\s*(?:"([^"]*)"|(\d+)|true|false|null)/g,la=/<\|\s*tool_calls_section_begin\s*\|>/gi,ca=/<\|\s*tool_calls_section_end\s*\|>/gi,Tl=/```(?:tool|action|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi;var ki=e=>!e||typeof e!="string"?e:e.replace(/(```[\s\S]*?```|`[^`]*`)|(<(?:\w+)(?:[^>]*)>\r?\n?|\r?\n?<\/\w+(?:[^>]*)>)/gi,(n,t)=>t||""),ma=e=>{if(!e||typeof e!="string")return e;let n=Mn(e);if(!n||n.length===0)return e;let t=n[n.length-1];if(!t.fullMatch)return e;let i=e.lastIndexOf(t.fullMatch);if(i===-1)return e;let o=i+t.fullMatch.length,r=e.substring(o);if(/\[\s*(?:tool|action):/i.test(r))return e.trimEnd();let d=/\r?\n/.test(r);return e.substring(0,o)+(d?`
551
- `:"")},ks=null,Do={},jn={key:null,value:null},Pt=e=>{if(!e)return e;let n=Do?.theme;if(!n)try{n=Zo(Jo,{})?.systemSettings?.theme}catch{}let i=wi(n||"Dark").toolFeedbackAnsi||"\x1B[95m";return e.replace(/(?:(\x1b\[\d+m))?([✔✘✖🔍📖→➕↻↷•🛇])(?:(\x1b\[\d+m))?\s*\b(Clicked Screen|Clicked|Located|Dragged|Scrolled|Typed|Entered|Pressed Key|Recaptured Screen|Created|Read Skill|Read Documentation|Executed|Searched Documentation|Read|Edited|Viewed|Processed|Auto-Read|Skipped|List|Generated|Written|Searched|AI Search|Get Map|Write Canceled|Resolved Sub-Agent Query|Edit Canceled|Write Cancelled|Edit Denied|Visited|Updated|Reviewed|Delegated|Background|Checked|Indexed|Analyzed|Browsed|Elevating SubAgent|Checking SubAgent Work|Started Generalist|Called Generalist|Steered|Unsupported Modality|Awaiting|Cancelled|Aligning Moon Phase|Contemplating Existence|Staring At Void|Rollback Point Checked|Emergency Rollback Failed|Emergency Rollback|Delaying Professionally|Negotiating With Electrons|Touching Grass (virtually)|Panicking Softly|Rethinking Career Choices|Loading Cat Videos|Giving Up Entirely|Summoning Braincell #2|Pretending To Be Busy|Waiting For Motivation DLC|Rotating Internal Screaming|Downloading More RAM|Feeding The Hamsters|Gaslighting Scheduler|Performing Dramatic Pause|Buffering Social Energy|Calculating Regret|Reading Terms And Conditions|Becoming Sentient Briefly|Model produced malformed tool call|Loop Detected|Contacting Ancestors)\b/ig,(o,r,d,l,u)=>`${r||""}${d}${l||""} ${i}${u}\x1B[0m`)},Al=async(e,n=8,t=1e3,i=8e3,o=null)=>{let r=0;for(;;){if(o?.aborted)throw new DOMException("The user aborted a request.","AbortError");try{return await e()}catch(d){if(o?.aborted||d?.name==="AbortError"||d?.message==="Subagent task was cancelled."||(r++,r>=n))throw d;let l=Math.min(t*Math.pow(2,r-1),i);await new Promise((u,g)=>{let h=setTimeout(u,l);o&&o.addEventListener("abort",()=>{clearTimeout(h),g(new DOMException("The user aborted a request.","AbortError"))})})}}},ut=!1;var zd=e=>{let n=e.filter(o=>(o.role==="user"||o.role==="agent"||o.role==="system")&&o.role!=="think"&&!o.isVisualFeedback&&!o.isMeta&&!o.isTerminalRecord&&!(o.text&&o.text.includes("[TERMINAL_RECORD]"))&&!String(o.id).startsWith("welcome")).map((o,r,d)=>{let l=o.fullText||o.text||"";if(o.role==="user"&&r<d.length-1)if(l.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")){let u=l.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");if(u!==-1){let h=l.substring(0,u).lastIndexOf("[SYSTEM METADATA]");h!==-1?l=l.substring(h).trim():l=l.substring(u).trim()}}else{let u=l.lastIndexOf("[USER]"),g=l.lastIndexOf("[USER PROMPT]");u!==-1?l=l.substring(u+6).trim():g!==-1&&(l=l.substring(g).trim())}return{...o,text:l}}),t=[],i=0;for(;i<n.length;){let o=n[i];if(o.role==="user")t.push(o),i++;else{let r=[];for(;i<n.length&&n[i].role!=="user";)r.push(n[i]),i++;let d=[],l=[],u=!1,g=()=>{d.length>0&&(t.push({role:"agent",text:"combined"}),d=[]),l.length>0&&(t.push({role:"system",text:"combined"}),l=[]),u=!1};r.forEach(h=>{let m=h.role==="system"&&(h.text?.startsWith("[ACTION RESULT]")||h.text?.startsWith("[TOOL RESULT]")||h.text?.startsWith("SUCCESS:")||h.text?.startsWith("ERROR:")||h.fullText?.startsWith("[ACTION RESULT]")||h.fullText?.startsWith("[TOOL RESULT]")||h.fullText?.startsWith("SUCCESS:")||h.fullText?.startsWith("ERROR:")),p=h.fullText||h.text||"",s=p.trim();if(!(!s&&!h.binaryPart)){if(m)l.push(s);else if(h.role==="agent"){!u&&l.length>0&&g();let w=p.endsWith(`
552
- `),_=s.toLowerCase().includes("tool:")||s.toLowerCase().includes("action:");d.push(s),_&&w?u=!0:u=!1}}}),g()}}return t.length};var qd=()=>{ut=!0},Yd=()=>ut,Ss={write_file:"Writing",update_file:"Editing",read_folder:"Reading",view_file:"Reading",exec_command:"Executing Command",web_search:"Searching",web_scrape:"Reading",memory:"Updating Memory",search_keyword:"Searching",find_file:"Finding File",findFile:"Finding File",FindFile:"Finding File",file_map:"Generating Map",ask:"User Input",write_pdf:"Creating",write_docx:"Creating",generate_image:"Generating",todo:"Planning",Todo:"Planning",goal:"Planning",Goal:"Planning",invoke_sync:"Sub-Agent Working",invoke:"Starting Agent",get_progress:"Checking Progress",cancel:"Cancelling",await:"Waiting",wait:"Waiting",EmergencyRollback:"Don't Panic. Lookin' into it",answer:"Answering Sub-Agent",Answer:"Answering Sub-Agent",steer:"Steering Sub-Agent",Steer:"Steering Sub-Agent",Click:"Clicking",click:"Clicking",Drag:"Dragging",drag:"Dragging",Scroll:"Scrolling",scroll:"Scrolling",KeyboardTyping:"Typing",keyboard_typing:"Typing",KeyPress:"Pressing Key",key_press:"Pressing Key",RecaptureScreen:"Recapturing Screen",recapture_screen:"Recapturing Screen"},Kn=(e,n)=>{try{let t=D(n),i=e.toLowerCase().replace(/_/g,"");if(i==="invokesync"||i==="invoke")return t.title||(t.task?t.task.substring(0,30):null);if(i==="getprogress"||i==="cancel"||i==="steer"||i==="steersubagent")return t.id||t.taskId;let o=t.name||t.path||t.targetFile||t.TargetFile||t.directory||t.file||t.query;return o?J.basename(o.replace(/["']/g,"").replace(/\\/g,"/")):null}catch{return null}},pa=e=>e?new ga({apiKey:e}):ks,Xd=async(e,n,t,i,o={})=>{},Ti=e=>{if(!e||typeof e!="string")return e;let n=e.split(""),t=!1,i=!1,o=0;for(;o<n.length;){if(n[o]==="`"&&n[o+1]==="`"&&n[o+2]==="`"){t?(n[o]=" ",n[o+1]=" ",n[o+2]=" ",t=!1):(n[o]=" ",n[o+1]=" ",n[o+2]=" ",t=!0),o+=3;continue}if(t){n[o]!==`
549
+ `,u+=ys(Le,n,N,i+1,o,r)):u+=`${t}${v}${s.name}
550
+ `}),u};var ll={Ollama:()=>import("./ollama-53BJCQQX.js").then(e=>e.getOllamaStream),OpenRouter:()=>import("./openrouter-LSG67TST.js").then(e=>e.getOpenRouterStream),DeepSeek:()=>import("./deepseek-I2J4A7WQ.js").then(e=>e.getDeepSeekStream),Mistral:()=>import("./mistral-H23J6UYA.js").then(e=>e.getMistralStream),NVIDIA:()=>import("./nvidia-BUWXTYGV.js").then(e=>e.getNVIDIAStream),NVIDIA_wrap:()=>import("./nvidia-BUWXTYGV.js").then(e=>e.wrapNvidiaStreamWithQueueDepth),InferX:()=>import("./inferx-B6PKXWLZ.js").then(e=>e.getInferXStream),SenseNova:()=>import("./sensenova-MLFZTP7U.js").then(e=>e.getSenseNovaStream),AIHubMix:()=>import("./aihubmix-KJIG7CZO.js").then(e=>e.getAIHubMixStream),Poolside:()=>import("./poolside-KWCBEP3P.js").then(e=>e.getPoolsideStream),NineRouter:()=>import("./9router-KRJQK6JP.js").then(e=>e.getNineRouterStream),ExpLabs:()=>import("./explabs-OYP64XS6.js").then(e=>e.getExpLabsStream),TokenHarbor:()=>import("./tokenharbor-Y6HSTTHA.js").then(e=>e.getTokenHarborStream),Infron:()=>import("./infron-4SLX3HMD.js").then(e=>e.getInfronStream),APInex:()=>import("./apinex-EP3JJPZO.js").then(e=>e.getAPInexStream),xKiro:()=>import("./xkiro-D3DTPVWY.js").then(e=>e.getXKiroStream),c_openai:()=>import("./custom_openai-ODYQEMOR.js").then(e=>e.getCustomOpenAIStream)},bs={},ye=async e=>(bs[e]||(bs[e]=await ll[e]()),bs[e]),cl=/```[\s\S]*?```/g,dl=/```[\s\S]*$/g,fl=/`[^`]+`/g,ul=/^\|.*\|$/gm,gl=/^[^\w]+|[^\w]+$/g,ml=/[^a-z0-9]/gi,Oo=/\[\s*(?:tool|action):(?:functions\.)?([a-z0-9_]+)\s*\(/gi,pl=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-z0-9_]+)\s*\(/gi,hl=/(?:path|targetFile|TargetFile|directory|keyword|id|taskId|title|task)\s*=\s*\\?["']?([^\\"' \),]+)/,wn=/["']/g,ra=/\\/g,yl=/<\|channel>thought/gi,xl=/<channel\|>/gi,bl=e=>typeof e!="string"?e:e.replace(yl,"<think_fluxflow>").replace(xl,"</think_fluxflow>"),Vd=/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\]|$)/i,wl=(e,n,t=1)=>{let i=n>0?e[n-1]:"",o=n+t<e.length?e[n+t]:"";return i==="`"&&o==="`"},Sl=e=>{let n=/(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\])/gi,t;for(;(t=n.exec(e))!==null;)if(!wl(e,t.index,t[0].length))return{index:t.index,length:t[0].length};return{index:-1,length:0}},ws=e=>{if(!e||typeof e!="string")return null;let n=e.match(/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])/i);if(!n)return null;let t=n.index+n[0].length,i=e.substring(t),o=Sl(i);if(o.index!==-1){let r=t+o.index+o.length;return{fullBlock:e.substring(0,r),innerContent:i.substring(0,o.index),remainingText:e.substring(r)}}return{fullBlock:e,innerContent:i,remainingText:""}},Ft=e=>{if(!e||typeof e!="string")return e;let n=ws(e);return n?n.remainingText.trimStart():e};var aa=/<\|\s*tool_call_begin\s*\|>\s*(?:(?:tool|functions)\b[\s._]*)*([a-zA-Z0-9_]+)(?::\d+)?\s*<\|\s*tool_call_argument_begin\s*\|>([\s\S]*?)<\|\s*tool_call_end\s*\|>/gi,kl=/"([^"]+)"\s*:\s*(?:"([^"]*)"|(\d+)|true|false|null)/g,la=/<\|\s*tool_calls_section_begin\s*\|>/gi,ca=/<\|\s*tool_calls_section_end\s*\|>/gi,Tl=/```(?:tool|action|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi;var ki=e=>!e||typeof e!="string"?e:e.replace(/(```[\s\S]*?```|`[^`]*`)|(<(?:\w+)(?:[^>]*)>\r?\n?|\r?\n?<\/\w+(?:[^>]*)>)/gi,(n,t)=>t||""),ma=e=>{if(!e||typeof e!="string")return e;let n=Mn(e);if(!n||n.length===0)return e;let t=n[n.length-1];if(!t.fullMatch)return e;let i=e.lastIndexOf(t.fullMatch);if(i===-1)return e;let o=i+t.fullMatch.length,r=e.substring(o);if(/\[\s*(?:tool|action):/i.test(r))return e.trimEnd();let d=/\r?\n/.test(r);return e.substring(0,o)+(d?`
551
+ `:"")},ks=null,Do={},jn={key:null,value:null},Rt=e=>{if(!e)return e;let n=Do?.theme;if(!n)try{n=Zo(Jo,{})?.systemSettings?.theme}catch{}let i=bi(n||"Dark").toolFeedbackAnsi||"\x1B[95m";return e.replace(/(?:(\x1b\[\d+m))?([✔✘✖🔍📖→➕↻↷•🛇])(?:(\x1b\[\d+m))?\s*\b(Clicked Screen|Clicked|Located|Dragged|Scrolled|Typed|Entered|Pressed Key|Recaptured Screen|Created|Read Skill|Read Documentation|Executed|Searched Documentation|Read|Edited|Viewed|Processed|Auto-Read|Skipped|List|Generated|Written|Searched|AI Search|Get Map|Write Canceled|Resolved Sub-Agent Query|Edit Canceled|Write Cancelled|Edit Denied|Visited|Updated|Reviewed|Delegated|Background|Checked|Indexed|Analyzed|Browsed|Elevating SubAgent|Checking SubAgent Work|Started Generalist|Called Generalist|Steered|Unsupported Modality|Awaiting|Cancelled|Aligning Moon Phase|Contemplating Existence|Staring At Void|Rollback Point Checked|Emergency Rollback Failed|Emergency Rollback|Delaying Professionally|Negotiating With Electrons|Touching Grass (virtually)|Panicking Softly|Rethinking Career Choices|Loading Cat Videos|Giving Up Entirely|Summoning Braincell #2|Pretending To Be Busy|Waiting For Motivation DLC|Rotating Internal Screaming|Downloading More RAM|Feeding The Hamsters|Gaslighting Scheduler|Performing Dramatic Pause|Buffering Social Energy|Calculating Regret|Reading Terms And Conditions|Becoming Sentient Briefly|Model produced malformed tool call|Loop Detected|Contacting Ancestors)\b/ig,(o,r,d,l,u)=>`${r||""}${d}${l||""} ${i}${u}\x1B[0m`)},Al=async(e,n=8,t=1e3,i=8e3,o=null)=>{let r=0;for(;;){if(o?.aborted)throw new DOMException("The user aborted a request.","AbortError");try{return await e()}catch(d){if(o?.aborted||d?.name==="AbortError"||d?.message==="Subagent task was cancelled."||(r++,r>=n))throw d;let l=Math.min(t*Math.pow(2,r-1),i);await new Promise((u,g)=>{let h=setTimeout(u,l);o&&o.addEventListener("abort",()=>{clearTimeout(h),g(new DOMException("The user aborted a request.","AbortError"))})})}}},ut=!1;var zd=e=>{let n=e.filter(o=>(o.role==="user"||o.role==="agent"||o.role==="system")&&o.role!=="think"&&!o.isVisualFeedback&&!o.isMeta&&!o.isTerminalRecord&&!(o.text&&o.text.includes("[TERMINAL_RECORD]"))&&!String(o.id).startsWith("welcome")).map((o,r,d)=>{let l=o.fullText||o.text||"";if(o.role==="user"&&r<d.length-1)if(l.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")){let u=l.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");if(u!==-1){let h=l.substring(0,u).lastIndexOf("[SYSTEM METADATA]");h!==-1?l=l.substring(h).trim():l=l.substring(u).trim()}}else{let u=l.lastIndexOf("[USER]"),g=l.lastIndexOf("[USER PROMPT]");u!==-1?l=l.substring(u+6).trim():g!==-1&&(l=l.substring(g).trim())}return{...o,text:l}}),t=[],i=0;for(;i<n.length;){let o=n[i];if(o.role==="user")t.push(o),i++;else{let r=[];for(;i<n.length&&n[i].role!=="user";)r.push(n[i]),i++;let d=[],l=[],u=!1,g=()=>{d.length>0&&(t.push({role:"agent",text:"combined"}),d=[]),l.length>0&&(t.push({role:"system",text:"combined"}),l=[]),u=!1};r.forEach(h=>{let m=h.role==="system"&&(h.text?.startsWith("[ACTION RESULT]")||h.text?.startsWith("[TOOL RESULT]")||h.text?.startsWith("SUCCESS:")||h.text?.startsWith("ERROR:")||h.fullText?.startsWith("[ACTION RESULT]")||h.fullText?.startsWith("[TOOL RESULT]")||h.fullText?.startsWith("SUCCESS:")||h.fullText?.startsWith("ERROR:")),p=h.fullText||h.text||"",s=p.trim();if(!(!s&&!h.binaryPart)){if(m)l.push(s);else if(h.role==="agent"){!u&&l.length>0&&g();let b=p.endsWith(`
552
+ `),_=s.toLowerCase().includes("tool:")||s.toLowerCase().includes("action:");d.push(s),_&&b?u=!0:u=!1}}}),g()}}return t.length};var qd=()=>{ut=!0},Yd=()=>ut,Ss={write_file:"Writing",update_file:"Editing",read_folder:"Reading",view_file:"Reading",exec_command:"Executing Command",web_search:"Searching",web_scrape:"Reading",memory:"Updating Memory",search_keyword:"Searching",find_file:"Finding File",findFile:"Finding File",FindFile:"Finding File",file_map:"Generating Map",ask:"User Input",write_pdf:"Creating",write_docx:"Creating",generate_image:"Generating",todo:"Planning",Todo:"Planning",goal:"Planning",Goal:"Planning",invoke_sync:"Sub-Agent Working",invoke:"Starting Agent",get_progress:"Checking Progress",cancel:"Cancelling",await:"Waiting",wait:"Waiting",EmergencyRollback:"Don't Panic. Lookin' into it",answer:"Answering Sub-Agent",Answer:"Answering Sub-Agent",steer:"Steering Sub-Agent",Steer:"Steering Sub-Agent",Click:"Clicking",click:"Clicking",Drag:"Dragging",drag:"Dragging",Scroll:"Scrolling",scroll:"Scrolling",KeyboardTyping:"Typing",keyboard_typing:"Typing",KeyPress:"Pressing Key",key_press:"Pressing Key",RecaptureScreen:"Recapturing Screen",recapture_screen:"Recapturing Screen"},Kn=(e,n)=>{try{let t=D(n),i=e.toLowerCase().replace(/_/g,"");if(i==="invokesync"||i==="invoke")return t.title||(t.task?t.task.substring(0,30):null);if(i==="getprogress"||i==="cancel"||i==="steer"||i==="steersubagent")return t.id||t.taskId;let o=t.name||t.path||t.targetFile||t.TargetFile||t.directory||t.file||t.query;return o?V.basename(o.replace(/["']/g,"").replace(/\\/g,"/")):null}catch{return null}},pa=e=>e?new ga({apiKey:e}):ks,Xd=async(e,n,t,i,o={})=>{},Ti=e=>{if(!e||typeof e!="string")return e;let n=e.split(""),t=!1,i=!1,o=0;for(;o<n.length;){if(n[o]==="`"&&n[o+1]==="`"&&n[o+2]==="`"){t?(n[o]=" ",n[o+1]=" ",n[o+2]=" ",t=!1):(n[o]=" ",n[o+1]=" ",n[o+2]=" ",t=!0),o+=3;continue}if(t){n[o]!==`
553
553
  `&&n[o]!=="\r"&&(n[o]=" "),o++;continue}if(n[o]==="`")if(i){i=!1,n[o]=" ",o++;continue}else{i=!0,n[o]=" ",o++;continue}if(i){n[o]===`
554
554
  `||n[o]==="\r"?i=!1:n[o]=" ",o++;continue}o++}return n.join("")},da=(e,n=null)=>{if(!e||typeof e!="string")return e;let t=n||Mn(e);if(!t||t.length===0)return e;let i=e.split("");for(let o of t){if(!o.fullMatch)continue;let r=0;for(;(r=e.indexOf(o.fullMatch,r))!==-1;){for(let d=r;d<r+o.fullMatch.length;d++)i[d]!==`
555
- `&&i[d]!=="\r"&&(i[d]=" ");r+=o.fullMatch.length}}return i.join("")},Cl=e=>{let n=Nt(e),t=Ti(n);Oo.lastIndex=0;let i;for(;(i=Oo.exec(t))!==null;){let o=i.index+i[0].length-1,r=0,d=null,l=!1,u=!1;for(let g=o;g<t.length;g++){let h=t[g];if(!d&&(h==='"'||h==="'"||h==="`")?(d=h,l=!1):d&&h===d&&!l&&(d=null),!d&&(h==="("?r++:h===")"&&r--,r===0)){let m=g+1;for(;m<t.length&&/\s/.test(t[m]);)m++;if(m<t.length&&t[m]==="]"){u=!0,Oo.lastIndex=m+1;break}}h==="\\"?l=!l:l=!1}if(!u)return{inside:!0,toolName:i[1],startIndex:i.index,args:n.substring(i.index+i[0].length)}}return{inside:!1}},ha=(e,n=!0)=>{let t=Oo;t.lastIndex=0;let i="",o=0,r;for(;(r=t.exec(e))!==null;){let d=e.substring(o,r.index);i+=n&&o===0?Nt(d):d;let l=r.index+r[0].length-1,u=0,g=null,h=-1;for(let m=l;m<e.length;m++){let p=e[m];if(g){if(p===g){let s=0;for(let w=m-1;w>=0&&e[w]==="\\";w--)s++;s%2===0&&(g=null)}}else if(p==='"'||p==="'"||p==="`")g=p;else if(p==="(")u++;else if(p===")"&&(u--,u===0)){let s=m+1;for(;s<e.length&&/\s/.test(e[s]);)s++;if(s<e.length&&e[s]==="]"){h=s;break}}}if(h!==-1)i+="[tool:functions."+r[1]+"()]",o=h+1,t.lastIndex=o;else{i+="[tool:functions."+r[1]+"(",o=e.length;break}}return o<e.length&&(i+=n&&o===0?Nt(e.substring(o)):e.substring(o)),i},vl=(e,n,t)=>{let i=Oo;i.lastIndex=0;let o="",r=0,d;for(;(d=i.exec(e))!==null;){let l=e.substring(r,d.index);o+=l.replace(n,t);let u=d.index+d[0].length-1,g=0,h=null,m=-1;for(let p=u;p<e.length;p++){let s=e[p];if(h){if(s===h){let w=0;for(let _=p-1;_>=0&&e[_]==="\\";_--)w++;w%2===0&&(h=null)}}else if(s==='"'||s==="'"||s==="`")h=s;else if(s==="(")g++;else if(s===")"&&(g--,g===0)){let w=p+1;for(;w<e.length&&/\s/.test(e[w]);)w++;if(w<e.length&&e[w]==="]"){m=w;break}}}if(m!==-1)o+=e.substring(d.index,m+1),r=m+1,i.lastIndex=r;else{o+=e.substring(d.index),r=e.length;break}}return r<e.length&&(o+=e.substring(r).replace(n,t)),o},fa=e=>ha(e,!0),Rl=e=>{if(!e)return e;let n={patchfile:"PatchFile",writefile:"WriteFile",readfile:"ReadFile",viewfile:"ReadFile",run:"Run",execcommand:"Run",searchkeyword:"SearchKeyword",codesearch:"CodeSearch",code_search:"CodeSearch",websearch:"WebSearch",webscrape:"WebScrape",readfolder:"ReadFolder",writepdf:"WritePDF",writedoc:"WriteDoc",writedocx:"WriteDoc",filemap:"FileMap",generateimage:"GenerateImage",todo:"Todo",goal:"Goal",askuser:"AskUser",ask:"AskUser"},t=o=>o.split("_").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("");aa.lastIndex=0;let i=e.replace(aa,(o,r,d)=>{let l="";try{let h=JSON.parse(d.trim());h&&typeof h=="object"&&(l=Object.entries(h).map(([p,s])=>{let w=typeof s=="string"?s:JSON.stringify(s);return`${p}=${JSON.stringify(w)}`}).join(", "))}catch{let m=[],p=kl;p.lastIndex=0;let s;for(;(s=p.exec(d))!==null;){let w=s[1],_=s[2]!==void 0?s[2]:s[0].split(":").slice(1).join(":").trim();m.push(`${w}=${JSON.stringify(_)}`)}m.length>0?l=m.join(", "):l=d.trim()}let u=r.toLowerCase().replace(/_/g,"");return`[tool:functions.${n[u]||t(r)}(${l})]`});return la.lastIndex=0,ca.lastIndex=0,i=i.replace(la,""),i=i.replace(ca,""),i},Mn=e=>{if(!e)return[];let n=Rl(e),t=Nt(n),i=[],o=Ti(t),r=pl;r.lastIndex=0;let d;for(;(d=r.exec(o))!==null;){let l=d[1],u=d.index+d[0].length-1,g=0,h=null,m=-1,p=-1;for(let s=u;s<o.length;s++){let w=o[s];if(h){if(w===h){let _=0;for(let $e=s-1;$e>=0&&o[$e]==="\\";$e--)_++;_%2===0&&(h=null)}}else{if(s>u&&(o.substring(s).startsWith("[action:")||o.substring(s).startsWith("[tool:")))break;if(w==='"'||w==="'"||w==="`")h=w;else if(w==="(")g++;else if(w===")"&&(g--,g===0)){p=s;let _=s+1;for(;_<o.length&&/\s/.test(o[_]);)_++;if(_<o.length&&o[_]==="]"){m=_;break}}}}if(m!==-1){let s=t.substring(u+1,p),w=t.substring(d.index,m+1);i.push({fullMatch:w,toolName:l.trim(),args:s.trim()}),r.lastIndex=m+1}}return i},ua=e=>{if(!e)return null;let n=Nt(e),t=[],i=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,o=[],r;for(;(r=i.exec(n))!==null;)o.push({toolName:r[1],index:r.index,parenIndex:r.index+r[0].length-1});for(let p=0;p<o.length;p++){let s=o[p],w=p+1<o.length?o[p+1].index:n.length,_=n.substring(s.index,w),$e=_.indexOf("("),v=$e!==-1?_.substring($e+1):"",N=0,P=null,V=!1;for(let M=0;M<v.length;M++){let $=v[M];if(P){if($===P){let ye=0;for(let ve=M-1;ve>=0&&v[ve]==="\\";ve--)ye++;ye%2===0&&(P=null)}}else if($==='"'||$==="'"||$==="`")P=$;else if($==="(")N++;else if($===")")if(N>0)N--;else{let ye=M+1;for(;ye<v.length&&/\s/.test(v[ye]);)ye++;if(ye<v.length&&v[ye]==="]"){V=!0;break}}}if(!V){let M=_.trim(),$="";P?$=`Unclosed quote string (${P}) inside arguments`:M.endsWith("]")?$=`Missing closing ')' before ']' (e.g. found "...]")`:M.endsWith(")")?$=`Missing closing ']' after ')' (e.g. found "...)" instead of "...)]")`:!M.includes(")")&&!M.includes("]")?$="Missing closing delimiter ')]'":$="Malformed or unclosed call syntax (missing ')]')",t.push(`\u2022 [action:${s.toolName}(...)]: ${$}. Expected: [action:${s.toolName}(arg1="...", arg2="...")]`)}}let d=/(?:^|[^\w\[])(?:tool|action):(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/gi,l;for(;(l=d.exec(n))!==null;){let p=l[1],s=l.index+(l[0].indexOf(":")-(l[0].startsWith("action")||l[0].startsWith("tool")?0:1));(s>0?n[s-1]:"")!=="["&&yi(p)&&t.push(`\u2022 action:${p}(...): Missing opening bracket '['. Expected: [action:${p}(...)]`)}let u=/\[\s*(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/g,g;for(;(g=u.exec(n))!==null;){let p=g[1];p!=="action"&&p!=="tool"&&yi(p)&&t.push(`\u2022 [${p}(...)]: Missing 'action:' prefix. Expected: [action:${p}(...)]`)}let h=/\[\s*(?:tool|action)\s*:\s*(?:functions\.)?([a-zA-Z0-9_]+)(?!\s*\()/gi,m;for(;(m=h.exec(n))!==null;){let p=m[1];yi(p)&&t.push(`\u2022 [action:${p}...]: Missing opening '(' for tool arguments. Expected: [action:${p}(...)]`)}return t.length>0?t.join(`
556
- `):null},Jd=(e,n={})=>{if(!e)return null;if(Do=n,ks=new ga({apiKey:e}),!globalThis.__perfCleanupInstalled){globalThis.__perfCleanupInstalled=!0,setInterval(()=>{typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks())},6e4);let t=globalThis.fetch;globalThis.fetch=async(...i)=>{try{let o=await t(...i);return typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),o}catch(o){throw typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),o}}}},ya=e=>{if(!e)return{serviceTier:void 0,cleanModel:e};let n=e.toLowerCase();return n.endsWith(":flex")?{serviceTier:"flex",cleanModel:e.slice(0,-5)}:n.endsWith(":priority")?{serviceTier:"priority",cleanModel:e.slice(0,-9)}:{serviceTier:void 0,cleanModel:e}},El=async(e,n,t,i,o="Fast",r=.75,d="agent")=>Al(async()=>{let{aiProvider:l="Google",apiKey:u,mode:g}=e,h="",m=null,p=typeof t=="string"?[{role:"user",parts:[{text:t}]}]:t,s=new AbortController,w=s.signal,_=setInterval(()=>{ut&&(s.abort(),clearInterval(_))},100),$e=Date.now(),v=null;try{let N;if(l==="Ollama")N=(await he("Ollama"))(u,n,p,i,o,g,tt(n),w,r,e.systemSettings?.ollamaEndpoint||"Cloud");else if(l==="OpenRouter")N=(await he("OpenRouter"))(u,n,p,i,o,g,tt(n),w,r);else if(l==="DeepSeek")N=(await he("DeepSeek"))(u,n,p,i,o,g,tt(n),w,r);else if(l==="Mistral")N=(await he("Mistral"))(u,n,p,i,o,g,tt(n),w,r);else if(l==="NVIDIA")N=(await he("NVIDIA"))(u,n,p,i,o,g,tt(n),w,r);else if(l==="InferX")N=(await he("InferX"))(u,n,p,i,o,g,tt(n),w,r);else if(l==="SenseNova")N=(await he("SenseNova"))(u,n,p,i,o,g,tt(n),w,r);else if(l==="AIHubMix")N=(await he("AIHubMix"))(u,n,p,i,o,g,tt(n),w,r);else if(l==="Poolside")N=(await he("Poolside"))(u,n,p,i,o,g,tt(n),w,r);else if(l==="9router"||l==="9Router")N=(await he("NineRouter"))(u,n,p,i,o,g,tt(n),w,r);else if(l==="ExpLabs"||l==="ExperientialLabs")N=(await he("ExpLabs"))(u,n,p,i,o,g,tt(n),w,r);else if(l==="Infron"||l==="infron")N=(await he("Infron"))(u,n,p,i,o,g,tt(n),w,r);else if(l==="TokenHarbor"||l==="Token Harbor"||l==="tokenharbor"||l==="token_harbor"||l==="thk")N=(await he("TokenHarbor"))(u,n,p,i,o,g,tt(n),w,r);else if(l==="APInex"||l==="apinex"||l==="apx")N=(await he("APInex"))(u,n,p,i,o,g,tt(n),w,r);else if(l==="xKiro"||l==="xkiro"||l==="kiro")N=(await he("xKiro"))(u,n,p,i,o,g,tt(n),w,r);else if(l==="c_openai"||l==="Custom (OpenAI)"){let P=e.systemSettings?.customOpenAIBaseUrl||"";try{P=await Wi("c_openai")||P}catch{}N=(await he("c_openai"))(u,n,p,i,o,g,tt(n),w,r,P)}else{let P=pa(u),{serviceTier:V,cleanModel:M}=ya(n),$={systemInstruction:i,temperature:r,thinkingConfig:(()=>{let ve=(n||"").toLowerCase(),Ie=ve.includes("gemma-4")||ve.startsWith("gemma"),Xe=ve.includes("gemini-3");if(Ie||Xe)return Ie?o.toLowerCase()!=="xhigh"?{includeThoughts:!1,thinkingLevel:Ye.MINIMAL}:{includeThoughts:!0,thinkingLevel:Ye.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:ve.includes("pro")?Ye.LOW:Ye.MINIMAL,Low:Ye.LOW,Medium:Ye.MEDIUM,Standard:Ye.MEDIUM,High:Ye.HIGH,xHigh:Ye.HIGH}[o]||Ye.MEDIUM};{let U={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[o]||2048;return U===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:U}}})()};V&&($.serviceTier=V),N=await P.models.generateContentStream({model:M,contents:p,config:$},{signal:w})}for await(let P of N){if(ut)throw new Error("Subagent task was cancelled.");if(e?.taskId&&typeof Dt<"u"){let $=Dt.find(ye=>ye.id===e.taskId);if($&&$.status==="cancelled")throw new Error("Subagent task was cancelled.")}v===null&&(P.candidates?.[0]?.content?.parts||P.text)&&(v=Date.now()-$e);let V="";if(P.candidates?.[0]?.content?.parts)for(let $ of P.candidates[0].content.parts)$.text&&!$.thought&&(h+=$.text,V+=$.text);let M=V?Hi(V):0;e&&typeof e.onTokenChunk=="function"&&e.onTokenChunk(V,M),P.usageMetadata&&(m=P.usageMetadata)}}finally{clearInterval(_)}if(m){let N=m.totalTokenCount||0,P=m.cachedContentTokenCount||0,V=(m.candidatesTokenCount||0)+(l==="Google"&&m.thoughtsTokenCount||0);await dn("tokens",N,l,n),P>0&&await dn("cachedTokens",P,l,n),V>0&&await dn("candidateTokens",V,l,n),v!==null&&v>0&&await dn("ttft",v,l,n),ni({provider:l,model:n,prompt:m.promptTokenCount||0,cached:P,output:V,reasoning:m.thoughtsTokenCount||0,ttft:v}),e&&typeof e.onUsage=="function"&&e.onUsage({totalTokenCount:N,cachedContentTokenCount:P,candidatesTokenCount:V})}return await Ct("agent",l),{text:h,usageMetadata:m}}),Qd=async function*(e,n,t,i,o){let{profile:r,thinkingLevel:d,mode:l,janitorModel:u,chatId:g,isPlayground:h,systemSettings:m,sessionStats:p,aiProvider:s="Google",apiTier:w,wildcardTooling:_,wildercardTooling:$e}=t,v=tt(e);if(!ks&&s==="Google")throw new Error("AI not initialized");let N=!1,P=n[n.length-1].text,V=J.join(Ws,"chat-summaries.json"),M=!1,$=n.filter(U=>U.role==="user").length===1,ye=P.includes("[TITLE-UPDATE]"),ve=$||ye,Ie=P.replace(/\[TITLE-UPDATE\]/g,"").trim();Ie=Ie.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),yield{type:"status",content:"[start]"},yield{type:"status",content:"Gathering Context"},await oi.startTransaction(g,Ie),m?.advanceRollback&&await So.takeInitialSnapshot(g),ut=!1;let Xe=null;try{let U=new AbortController;Xe=setInterval(()=>{ut&&(U.abort(),Xe&&(clearInterval(Xe),Xe=null))},400);let x=[...n.slice(0,-1)];{let ge=cn(V,{})[g]||{summary:"",historyLength:0};if(ge.summary&&ge.historyLength>0){let ht=0,ce=[];for(let z=0;z<x.length;z++){let we=x[z];(we.role==="user"||we.role==="agent"||we.role==="system")&&!String(we.id).startsWith("welcome")&&!we.isMeta&&ht++,ht>ge.historyLength&&ce.push(we)}x=ce}}x=x.map(b=>{if(b.role==="user"&&b.text){let ge=b.text.match(/\[USER\]([\s\S]*?)\[\/USER\]/);if(ge)return{...b,text:ge[1].trim()}}return{...b}});let zt=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1,Ne={"16k":16e3,"32k":32e3,"64k":64e3,"128k":128e3,"256k":256e3,"512k":512e3,"1M":1e6}[m?.contextLength]||256e3;if(s==="Google"&&e?.includes("gemma")&&zt&&(Ne=16e3),(p?.tokens||0)>Ne){yield{type:"text",content:"\u2726 Maximum Context Limit Reached. Start a new chat."};return}if($&&N){let b=cn(Ni,{});Object.values(b).flat().length>5}let ae=cn(Ni,{}),on=cn(Us,{}),Vn=Object.entries(ae).filter(([b])=>b!==g).flatMap(([b,ge])=>ge),Fo=[...Object.entries(on).filter(([b])=>b!==g).slice(-20).map(([b,ge])=>`[Chat Summary]: ${ge}`),...Vn].map(b=>`- ${b}`).join(`
557
- `),Pn=cn(Qo,[]).map(b=>`- ${b.memory}`).join(`
558
- `),zn=(p?.tokens||0)>=1e4,Yt=new Date,$n=Yt.getFullYear(),Re=Yt.toLocaleString("en-US",{month:"short"}).toUpperCase(),qn=String(Yt.getDate()).padStart(2,"0"),Q=`${Yt.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}`,B=b=>{try{return Ce.readdirSync(b,{withFileTypes:!0})}catch{return[]}},Xn=Array.from(new Set([...wo,...bo(process.cwd())])),pt=(b,ge=6)=>m?.indentationTree!==!1?ps(b,ge,1,B,Xn):ys(b,ge,"",1,B,Xn),A=cn(Fi,{}),oe=A[g],Xt=oe?oe!==process.cwd():!1;A[g]=process.cwd(),Bi(Fi,A);let Ft=cn(V,{}),kt=Ft[g]||{summary:"",historyLength:0};typeof kt=="string"&&(kt={summary:kt,historyLength:0});let Ln=n.filter(b=>(b.role==="user"||b.role==="agent"||b.role==="system")&&!String(b.id).startsWith("welcome")&&!b.isMeta).length;kt.historyLength&&Ln<kt.historyLength&&(kt.summary="",kt.historyLength=0,Ft[g]=kt,Bi(V,Ft));let Wo=typeof kt=="object"?kt.summary||"":kt||"",Ts=x.length>0;Ts&&Wo&&x[0]&&(x[0].role==="user"||x[0].role==="system")&&(x[0].text.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")||(x[0].text=`[SYSTEM METADATA]
555
+ `&&i[d]!=="\r"&&(i[d]=" ");r+=o.fullMatch.length}}return i.join("")},Cl=e=>{let n=Ft(e),t=Ti(n);Oo.lastIndex=0;let i;for(;(i=Oo.exec(t))!==null;){let o=i.index+i[0].length-1,r=0,d=null,l=!1,u=!1;for(let g=o;g<t.length;g++){let h=t[g];if(!d&&(h==='"'||h==="'"||h==="`")?(d=h,l=!1):d&&h===d&&!l&&(d=null),!d&&(h==="("?r++:h===")"&&r--,r===0)){let m=g+1;for(;m<t.length&&/\s/.test(t[m]);)m++;if(m<t.length&&t[m]==="]"){u=!0,Oo.lastIndex=m+1;break}}h==="\\"?l=!l:l=!1}if(!u)return{inside:!0,toolName:i[1],startIndex:i.index,args:n.substring(i.index+i[0].length)}}return{inside:!1}},ha=(e,n=!0)=>{let t=Oo;t.lastIndex=0;let i="",o=0,r;for(;(r=t.exec(e))!==null;){let d=e.substring(o,r.index);i+=n&&o===0?Ft(d):d;let l=r.index+r[0].length-1,u=0,g=null,h=-1;for(let m=l;m<e.length;m++){let p=e[m];if(g){if(p===g){let s=0;for(let b=m-1;b>=0&&e[b]==="\\";b--)s++;s%2===0&&(g=null)}}else if(p==='"'||p==="'"||p==="`")g=p;else if(p==="(")u++;else if(p===")"&&(u--,u===0)){let s=m+1;for(;s<e.length&&/\s/.test(e[s]);)s++;if(s<e.length&&e[s]==="]"){h=s;break}}}if(h!==-1)i+="[tool:functions."+r[1]+"()]",o=h+1,t.lastIndex=o;else{i+="[tool:functions."+r[1]+"(",o=e.length;break}}return o<e.length&&(i+=n&&o===0?Ft(e.substring(o)):e.substring(o)),i},vl=(e,n,t)=>{let i=Oo;i.lastIndex=0;let o="",r=0,d;for(;(d=i.exec(e))!==null;){let l=e.substring(r,d.index);o+=l.replace(n,t);let u=d.index+d[0].length-1,g=0,h=null,m=-1;for(let p=u;p<e.length;p++){let s=e[p];if(h){if(s===h){let b=0;for(let _=p-1;_>=0&&e[_]==="\\";_--)b++;b%2===0&&(h=null)}}else if(s==='"'||s==="'"||s==="`")h=s;else if(s==="(")g++;else if(s===")"&&(g--,g===0)){let b=p+1;for(;b<e.length&&/\s/.test(e[b]);)b++;if(b<e.length&&e[b]==="]"){m=b;break}}}if(m!==-1)o+=e.substring(d.index,m+1),r=m+1,i.lastIndex=r;else{o+=e.substring(d.index),r=e.length;break}}return r<e.length&&(o+=e.substring(r).replace(n,t)),o},fa=e=>ha(e,!0),Rl=e=>{if(!e)return e;let n={patchfile:"PatchFile",writefile:"WriteFile",readfile:"ReadFile",viewfile:"ReadFile",run:"Run",execcommand:"Run",searchkeyword:"SearchKeyword",codesearch:"CodeSearch",code_search:"CodeSearch",websearch:"WebSearch",webscrape:"WebScrape",readfolder:"ReadFolder",writepdf:"WritePDF",writedoc:"WriteDoc",writedocx:"WriteDoc",filemap:"FileMap",generateimage:"GenerateImage",todo:"Todo",goal:"Goal",askuser:"AskUser",ask:"AskUser"},t=o=>o.split("_").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("");aa.lastIndex=0;let i=e.replace(aa,(o,r,d)=>{let l="";try{let h=JSON.parse(d.trim());h&&typeof h=="object"&&(l=Object.entries(h).map(([p,s])=>{let b=typeof s=="string"?s:JSON.stringify(s);return`${p}=${JSON.stringify(b)}`}).join(", "))}catch{let m=[],p=kl;p.lastIndex=0;let s;for(;(s=p.exec(d))!==null;){let b=s[1],_=s[2]!==void 0?s[2]:s[0].split(":").slice(1).join(":").trim();m.push(`${b}=${JSON.stringify(_)}`)}m.length>0?l=m.join(", "):l=d.trim()}let u=r.toLowerCase().replace(/_/g,"");return`[tool:functions.${n[u]||t(r)}(${l})]`});return la.lastIndex=0,ca.lastIndex=0,i=i.replace(la,""),i=i.replace(ca,""),i},Mn=e=>{if(!e)return[];let n=Rl(e),t=Ft(n),i=[],o=Ti(t),r=pl;r.lastIndex=0;let d;for(;(d=r.exec(o))!==null;){let l=d[1],u=d.index+d[0].length-1,g=0,h=null,m=-1,p=-1;for(let s=u;s<o.length;s++){let b=o[s];if(h){if(b===h){let _=0;for(let Le=s-1;Le>=0&&o[Le]==="\\";Le--)_++;_%2===0&&(h=null)}}else{if(s>u&&(o.substring(s).startsWith("[action:")||o.substring(s).startsWith("[tool:")))break;if(b==='"'||b==="'"||b==="`")h=b;else if(b==="(")g++;else if(b===")"&&(g--,g===0)){p=s;let _=s+1;for(;_<o.length&&/\s/.test(o[_]);)_++;if(_<o.length&&o[_]==="]"){m=_;break}}}}if(m!==-1){let s=t.substring(u+1,p),b=t.substring(d.index,m+1);i.push({fullMatch:b,toolName:l.trim(),args:s.trim()}),r.lastIndex=m+1}}return i},ua=e=>{if(!e)return null;let n=Ft(e),t=[],i=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,o=[],r;for(;(r=i.exec(n))!==null;)o.push({toolName:r[1],index:r.index,parenIndex:r.index+r[0].length-1});for(let p=0;p<o.length;p++){let s=o[p],b=p+1<o.length?o[p+1].index:n.length,_=n.substring(s.index,b),Le=_.indexOf("("),v=Le!==-1?_.substring(Le+1):"",N=0,P=null,z=!1;for(let M=0;M<v.length;M++){let $=v[M];if(P){if($===P){let xe=0;for(let ve=M-1;ve>=0&&v[ve]==="\\";ve--)xe++;xe%2===0&&(P=null)}}else if($==='"'||$==="'"||$==="`")P=$;else if($==="(")N++;else if($===")")if(N>0)N--;else{let xe=M+1;for(;xe<v.length&&/\s/.test(v[xe]);)xe++;if(xe<v.length&&v[xe]==="]"){z=!0;break}}}if(!z){let M=_.trim(),$="";P?$=`Unclosed quote string (${P}) inside arguments`:M.endsWith("]")?$=`Missing closing ')' before ']' (e.g. found "...]")`:M.endsWith(")")?$=`Missing closing ']' after ')' (e.g. found "...)" instead of "...)]")`:!M.includes(")")&&!M.includes("]")?$="Missing closing delimiter ')]'":$="Malformed or unclosed call syntax (missing ')]')",t.push(`\u2022 [action:${s.toolName}(...)]: ${$}. Expected: [action:${s.toolName}(arg1="...", arg2="...")]`)}}let d=/(?:^|[^\w\[])(?:tool|action):(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/gi,l;for(;(l=d.exec(n))!==null;){let p=l[1],s=l.index+(l[0].indexOf(":")-(l[0].startsWith("action")||l[0].startsWith("tool")?0:1));(s>0?n[s-1]:"")!=="["&&yi(p)&&t.push(`\u2022 action:${p}(...): Missing opening bracket '['. Expected: [action:${p}(...)]`)}let u=/\[\s*(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/g,g;for(;(g=u.exec(n))!==null;){let p=g[1];p!=="action"&&p!=="tool"&&yi(p)&&t.push(`\u2022 [${p}(...)]: Missing 'action:' prefix. Expected: [action:${p}(...)]`)}let h=/\[\s*(?:tool|action)\s*:\s*(?:functions\.)?([a-zA-Z0-9_]+)(?!\s*\()/gi,m;for(;(m=h.exec(n))!==null;){let p=m[1];yi(p)&&t.push(`\u2022 [action:${p}...]: Missing opening '(' for tool arguments. Expected: [action:${p}(...)]`)}return t.length>0?t.join(`
556
+ `):null},Jd=(e,n={})=>{if(!e)return null;if(Do=n,ks=new ga({apiKey:e}),!globalThis.__perfCleanupInstalled){globalThis.__perfCleanupInstalled=!0,setInterval(()=>{typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks())},6e4);let t=globalThis.fetch;globalThis.fetch=async(...i)=>{try{let o=await t(...i);return typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),o}catch(o){throw typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),o}}}},ya=e=>{if(!e)return{serviceTier:void 0,cleanModel:e};let n=e.toLowerCase();return n.endsWith(":flex")?{serviceTier:"flex",cleanModel:e.slice(0,-5)}:n.endsWith(":priority")?{serviceTier:"priority",cleanModel:e.slice(0,-9)}:{serviceTier:void 0,cleanModel:e}},El=async(e,n,t,i,o="Fast",r=.75,d="agent")=>Al(async()=>{let{aiProvider:l="Google",apiKey:u,mode:g}=e,h="",m=null,p=typeof t=="string"?[{role:"user",parts:[{text:t}]}]:t,s=new AbortController,b=s.signal,_=setInterval(()=>{ut&&(s.abort(),clearInterval(_))},100),Le=Date.now(),v=null;try{let N;if(l==="Ollama")N=(await ye("Ollama"))(u,n,p,i,o,g,nt(n),b,r,e.systemSettings?.ollamaEndpoint||"Cloud");else if(l==="OpenRouter")N=(await ye("OpenRouter"))(u,n,p,i,o,g,nt(n),b,r);else if(l==="DeepSeek")N=(await ye("DeepSeek"))(u,n,p,i,o,g,nt(n),b,r);else if(l==="Mistral")N=(await ye("Mistral"))(u,n,p,i,o,g,nt(n),b,r);else if(l==="NVIDIA")N=(await ye("NVIDIA"))(u,n,p,i,o,g,nt(n),b,r);else if(l==="InferX")N=(await ye("InferX"))(u,n,p,i,o,g,nt(n),b,r);else if(l==="SenseNova")N=(await ye("SenseNova"))(u,n,p,i,o,g,nt(n),b,r);else if(l==="AIHubMix")N=(await ye("AIHubMix"))(u,n,p,i,o,g,nt(n),b,r);else if(l==="Poolside")N=(await ye("Poolside"))(u,n,p,i,o,g,nt(n),b,r);else if(l==="9router"||l==="9Router")N=(await ye("NineRouter"))(u,n,p,i,o,g,nt(n),b,r);else if(l==="ExpLabs"||l==="ExperientialLabs")N=(await ye("ExpLabs"))(u,n,p,i,o,g,nt(n),b,r);else if(l==="Infron"||l==="infron")N=(await ye("Infron"))(u,n,p,i,o,g,nt(n),b,r);else if(l==="TokenHarbor"||l==="Token Harbor"||l==="tokenharbor"||l==="token_harbor"||l==="thk")N=(await ye("TokenHarbor"))(u,n,p,i,o,g,nt(n),b,r);else if(l==="APInex"||l==="apinex"||l==="apx")N=(await ye("APInex"))(u,n,p,i,o,g,nt(n),b,r);else if(l==="xKiro"||l==="xkiro"||l==="kiro")N=(await ye("xKiro"))(u,n,p,i,o,g,nt(n),b,r);else if(l==="c_openai"||l==="Custom (OpenAI)"){let P=e.systemSettings?.customOpenAIBaseUrl||"";try{P=await Wi("c_openai")||P}catch{}N=(await ye("c_openai"))(u,n,p,i,o,g,nt(n),b,r,P)}else{let P=pa(u),{serviceTier:z,cleanModel:M}=ya(n),$={systemInstruction:i,temperature:r,thinkingConfig:(()=>{let ve=(n||"").toLowerCase(),Ie=ve.includes("gemma-4")||ve.startsWith("gemma"),Je=ve.includes("gemini-3");if(Ie||Je)return Ie?o.toLowerCase()!=="xhigh"?{includeThoughts:!1,thinkingLevel:Ye.MINIMAL}:{includeThoughts:!0,thinkingLevel:Ye.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:ve.includes("pro")?Ye.LOW:Ye.MINIMAL,Low:Ye.LOW,Medium:Ye.MEDIUM,Standard:Ye.MEDIUM,High:Ye.HIGH,xHigh:Ye.HIGH}[o]||Ye.MEDIUM};{let U={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[o]||2048;return U===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:U}}})()};z&&($.serviceTier=z),N=await P.models.generateContentStream({model:M,contents:p,config:$},{signal:b})}for await(let P of N){if(ut)throw new Error("Subagent task was cancelled.");if(e?.taskId&&typeof Nt<"u"){let $=Nt.find(xe=>xe.id===e.taskId);if($&&$.status==="cancelled")throw new Error("Subagent task was cancelled.")}v===null&&(P.candidates?.[0]?.content?.parts||P.text)&&(v=Date.now()-Le);let z="";if(P.candidates?.[0]?.content?.parts)for(let $ of P.candidates[0].content.parts)$.text&&!$.thought&&(h+=$.text,z+=$.text);let M=z?Hi(z):0;e&&typeof e.onTokenChunk=="function"&&e.onTokenChunk(z,M),P.usageMetadata&&(m=P.usageMetadata)}}finally{clearInterval(_)}if(m){let N=m.totalTokenCount||0,P=m.cachedContentTokenCount||0,z=(m.candidatesTokenCount||0)+(l==="Google"&&m.thoughtsTokenCount||0);await dn("tokens",N,l,n),P>0&&await dn("cachedTokens",P,l,n),z>0&&await dn("candidateTokens",z,l,n),v!==null&&v>0&&await dn("ttft",v,l,n),ni({provider:l,model:n,prompt:m.promptTokenCount||0,cached:P,output:z,reasoning:m.thoughtsTokenCount||0,ttft:v}),e&&typeof e.onUsage=="function"&&e.onUsage({totalTokenCount:N,cachedContentTokenCount:P,candidatesTokenCount:z})}return await vt("agent",l),{text:h,usageMetadata:m}}),Qd=async function*(e,n,t,i,o){let{profile:r,thinkingLevel:d,mode:l,janitorModel:u,chatId:g,isPlayground:h,systemSettings:m,sessionStats:p,aiProvider:s="Google",apiTier:b,wildcardTooling:_,wildercardTooling:Le}=t,v=nt(e);if(!ks&&s==="Google")throw new Error("AI not initialized");let N=!1,P=n[n.length-1].text,z=V.join(Ws,"chat-summaries.json"),M=!1,$=n.filter(U=>U.role==="user").length===1,xe=P.includes("[TITLE-UPDATE]"),ve=$||xe,Ie=P.replace(/\[TITLE-UPDATE\]/g,"").trim();Ie=Ie.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),yield{type:"status",content:"[start]"},yield{type:"status",content:"Gathering Context"},await oi.startTransaction(g,Ie),m?.advanceRollback&&await So.takeInitialSnapshot(g),ut=!1;let Je=null;try{let U=new AbortController;Je=setInterval(()=>{ut&&(U.abort(),Je&&(clearInterval(Je),Je=null))},400);let x=[...n.slice(0,-1)];{let ge=cn(z,{})[g]||{summary:"",historyLength:0};if(ge.summary&&ge.historyLength>0){let ht=0,ce=[];for(let q=0;q<x.length;q++){let we=x[q];(we.role==="user"||we.role==="agent"||we.role==="system")&&!String(we.id).startsWith("welcome")&&!we.isMeta&&ht++,ht>ge.historyLength&&ce.push(we)}x=ce}}x=x.map(w=>{if(w.role==="user"&&w.text){let ge=w.text.match(/\[USER\]([\s\S]*?)\[\/USER\]/);if(ge)return{...w,text:ge[1].trim()}}return{...w}});let zt=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1,Fe={"16k":16e3,"32k":32e3,"64k":64e3,"128k":128e3,"256k":256e3,"512k":512e3,"1M":1e6}[m?.contextLength]||256e3;if(s==="Google"&&e?.includes("gemma")&&zt&&(Fe=16e3),(p?.tokens||0)>Fe){yield{type:"text",content:"\u2726 Maximum Context Limit Reached. Start a new chat."};return}if($&&N){let w=cn(Ni,{});Object.values(w).flat().length>5}let ae=cn(Ni,{}),on=cn(Us,{}),Vn=Object.entries(ae).filter(([w])=>w!==g).flatMap(([w,ge])=>ge),Fo=[...Object.entries(on).filter(([w])=>w!==g).slice(-20).map(([w,ge])=>`[Chat Summary]: ${ge}`),...Vn].map(w=>`- ${w}`).join(`
557
+ `),Pn=cn(Qo,[]).map(w=>`- ${w.memory}`).join(`
558
+ `),zn=(p?.tokens||0)>=1e4,Yt=new Date,$n=Yt.getFullYear(),Re=Yt.toLocaleString("en-US",{month:"short"}).toUpperCase(),qn=String(Yt.getDate()).padStart(2,"0"),Q=`${Yt.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}`,B=w=>{try{return Ce.readdirSync(w,{withFileTypes:!0})}catch{return[]}},Xn=Array.from(new Set([...bo,...wo(process.cwd())])),pt=(w,ge=6)=>m?.indentationTree!==!1?ps(w,ge,1,B,Xn):ys(w,ge,"",1,B,Xn),A=cn(Fi,{}),oe=A[g],Xt=oe?oe!==process.cwd():!1;A[g]=process.cwd(),Bi(Fi,A);let Bt=cn(z,{}),kt=Bt[g]||{summary:"",historyLength:0};typeof kt=="string"&&(kt={summary:kt,historyLength:0});let Ln=n.filter(w=>(w.role==="user"||w.role==="agent"||w.role==="system")&&!String(w.id).startsWith("welcome")&&!w.isMeta).length;kt.historyLength&&Ln<kt.historyLength&&(kt.summary="",kt.historyLength=0,Bt[g]=kt,Bi(z,Bt));let Wo=typeof kt=="object"?kt.summary||"":kt||"",Ts=x.length>0;Ts&&Wo&&x[0]&&(x[0].role==="user"||x[0].role==="system")&&(x[0].text.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")||(x[0].text=`[SYSTEM METADATA]
559
559
  **CONTEXT SUMMARY OF PREVIOUS TURNS (PRIORITY: DYNAMIC)**
560
560
  ${Wo}
561
561
 
@@ -563,37 +563,38 @@ ${Wo}
563
563
  [SYSTEM METADATA]
564
564
  **CONTEXT SUMMARY OF PREVIOUS TURNS**
565
565
  ${Wo}
566
- `:"",As=!!m?.dynamicDirAwareness,xa=`${g}|${s}|${d}|${e}|${r}|${As}`,wa=!As&&jn.key===xa&&jn.value?"":`
566
+ `:"",As=!!m?.dynamicDirAwareness,xa=`${g}|${s}|${d}|${e}|${r}|${As}`,ba=!As&&jn.key===xa&&jn.value?"":`
567
567
  **Directory**
568
568
  CWD: `+process.cwd()+`${h?" [PLAYGROUND MODE]":""}
569
- `+pt(process.cwd(),6),vt=ro()?await Hn():null,Cs=b=>{if(!b||!Array.isArray(b)||b.length===0)return null;let ge=new Map;for(let ce of b){let z=ce.relPath||(ce.file?J.relative(process.cwd(),ce.file):"unknown");ge.has(z)||ge.set(z,[]),ge.get(z).push(ce)}let ht=[];for(let[ce,z]of ge.entries()){ht.push(`- ${ce}:`);for(let we of z){let Le=(we.snippet||"").trim().replace(/\r?\n/g," "),Je=we.line||1,$t=(we.text||"").trim().replace(/\r?\n+/g,". "),yt=$t?` [${$t}]`:"";ht.push(` ~L${Je}${yt}`)}}return ht.join(`
570
- `)},Ci=Cs(vt?.comments),gn="";if(vt&&vt.file_focused!=="none"){gn=`
569
+ `+pt(process.cwd(),6),Et=ro()?await Hn():null,Cs=w=>{if(!w||!Array.isArray(w)||w.length===0)return null;let ge=new Map;for(let ce of w){let q=ce.relPath||(ce.file?V.relative(process.cwd(),ce.file):"unknown");ge.has(q)||ge.set(q,[]),ge.get(q).push(ce)}let ht=[];for(let[ce,q]of ge.entries()){ht.push(`- ${ce}:`);for(let we of q){let Me=(we.snippet||"").trim().replace(/\r?\n/g," "),Qe=we.line||1,$t=(we.text||"").trim().replace(/\r?\n+/g,". "),yt=$t?` [${$t}]`:"";ht.push(` ~L${Qe}${yt}`)}}return ht.join(`
570
+ `)},Ci=Cs(Et?.comments),gn="";if(Et&&Et.file_focused!=="none"){gn=`
571
571
  [Additional IDE Context]
572
- `;let b=J.relative(process.cwd(),vt.file_focused),ge=(vt.opened_editors||[]).map(ce=>{let z=J.relative(process.cwd(),ce);return z.startsWith("..")?`[External] ${J.basename(ce)}`:z});if(gn+=`Focused File: ${b}
573
- Cursor Line: ${vt.cursor_line}
574
- `,vt.selected){let ce=vt.selected,z=ce.split(`
575
- `);z.length>256&&(ce=z.slice(0,240).join(`
572
+ `;let w=V.relative(process.cwd(),Et.file_focused),ge=(Et.opened_editors||[]).map(ce=>{let q=V.relative(process.cwd(),ce);return q.startsWith("..")?`[External] ${V.basename(ce)}`:q});if(gn+=`Focused File: ${w}
573
+ Cursor Line: ${Et.cursor_line}
574
+ `,Et.selected){let ce=Et.selected,q=ce.split(`
575
+ `);q.length>256&&(ce=q.slice(0,240).join(`
576
576
  `)+`
577
577
  ... [truncated] ...
578
- `+z.slice(-16).join(`
578
+ `+q.slice(-16).join(`
579
579
  `)),ce.length>2048&&(ce=ce.slice(0,1920)+`
580
580
  ... [truncated] ...
581
581
  `+ce.slice(-128)),gn+=`Current Selection: "${ce}"
582
- `}if(vt.manual_edits){let ce=vt.manual_edits.split(`
583
- `),z=[];for(let we=0;we<ce.length;we++){let Le=ce[we],Je=ce[we+1],$t=ce[we+2];if(Je!==void 0&&$t!==void 0&&/:\s*$/.test(Le)&&/^\s*-\s*/.test(Je)&&/^\s*\+\s*/.test($t)&&(Je.length>300||$t.length>300)){z.push(Le.replace(/:\s*$/,": [changed]")),we+=2;continue}z.push(Le)}gn+=`Recent Manual Edits:
584
- ${z.join(`
582
+ `}if(Et.manual_edits){let ce=Et.manual_edits.split(`
583
+ `),q=[];for(let we=0;we<ce.length;we++){let Me=ce[we],Qe=ce[we+1],$t=ce[we+2];if(Qe!==void 0&&$t!==void 0&&/:\s*$/.test(Me)&&/^\s*-\s*/.test(Qe)&&/^\s*\+\s*/.test($t)&&(Qe.length>300||$t.length>300)){q.push(Me.replace(/:\s*$/,": [changed]")),we+=2;continue}q.push(Me)}gn+=`Recent Manual Edits:
584
+ ${q.join(`
585
585
  `)}
586
- `}ge.length>0&&(gn+=`All Opened Editors: ${ge.join(", ")}`),vt.diagnostics&&(gn+=`
586
+ `}ge.length>0&&(gn+=`All Opened Editors: ${ge.join(", ")}`),Et.diagnostics&&(gn+=`
587
587
  **Active File Errors**:
588
- ${vt.diagnostics}
589
- `),(Ie.toLowerCase().includes("lint")||Ie.toLowerCase().includes("warning"))&&vt.warnings&&(gn+=`
588
+ ${Et.diagnostics}
589
+ `),(Ie.toLowerCase().includes("lint")||Ie.toLowerCase().includes("warning"))&&Et.warnings&&(gn+=`
590
590
  **Lint Warnings**:
591
- ${vt.warnings}
592
- `)}let vs=Ie.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),Rs=/(?:\\)?@\[([^\]]+)\]/g,vi,Ri=[];for(Rs.lastIndex=0;(vi=Rs.exec(vs))!==null;){let b=vi[0].startsWith("\\");Ri.push({tag:vi[1],isEscaped:b})}let Ei=[],Uo=null,Go=!1;for(let b=0;b<Ri.length;b++){let{tag:ge,isEscaped:ht}=Ri[b];if(!ht)try{let ce=ge.trim().replace(/^["']|["']$/g,""),z=/[:#]L?(\d+)(?:-L?(\d+))?$/i,we=ce.match(z),Le=ce,Je=null,$t=null;we&&(Je=parseInt(we[1],10),$t=we[2]?parseInt(we[2],10):Je,Le=ce.slice(0,we.index));let yt=J.resolve(process.cwd(),Le);if(Ce.existsSync(yt)&&Ce.statSync(yt).isFile()){let Lt=Le.toLowerCase(),lo=Lt.endsWith(".pdf"),Dn=Lt.endsWith(".docx")||Lt.endsWith(".doc")||Lt.endsWith(".ppt")||Lt.endsWith(".pptx")||Lt.endsWith(".xls")||Lt.endsWith(".xlsx"),Nn=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(Lt),He=Nn||lo||Dn,Tt=s==="Google"||tt(e);if(He&&!Tt){let be=`\u2718 Unsupported Modality: ${J.basename(Le)}`,nt=115;process.stdout.isTTY&&(nt=process.stdout.columns-5||120);let Bt=[be],je=Math.max(...Bt.map(Zt=>Zt.length)),ee=Math.min(je+4,nt),Be=Bt.map(Zt=>`${Zt.padEnd(ee-2).substring(0,ee-2)}`).join(`
593
- `);yield{type:"visual_feedback",content:Pt(`${Be}
594
- `)};continue}if(Je===null&&!He){let be=0;try{be=Ce.readFileSync(yt,"utf8").split(/\r\n|\r|\n/).length}catch{}if(be>300){let nt=`\u21B7 Skipped (Too Large): ${J.basename(Le)}`,Bt=115;process.stdout.isTTY&&(Bt=process.stdout.columns-5||120);let je=Math.min(nt.length+4,Bt),ee=nt.padEnd(je-2).substring(0,je-2);yield{type:"visual_feedback",content:Pt(`${ee}
595
- `)};continue}}let mn=Je!==null?Je:1,Rt=$t!==null?$t:Je!==null?Je:mn+299;Rt-mn>300&&(Rt=mn+300);let Fn=`path=${JSON.stringify(Le)}, startLine=${mn}, endLine=${Rt}`,Ot=await Js(Fn,{isMultiModal:Tt}),kn=!1,Qn="",gt=null;if(typeof Ot=="string"?Ot.trim().startsWith("ERROR")?kn=!0:Qn=Ot:Ot&&typeof Ot=="object"&&Ot.binaryPart?(gt=Ot.binaryPart,Qn=Ot.text||""):kn=!0,!kn){let be="";if(Nn?(be=`\u2714 Processed: ${J.basename(Le)}`,Uo=gt,Go=!0):lo||Dn?(be=`\u2714 Auto-Analysed: ${J.basename(Le)}`,Uo=gt,Go=!0):(be=`\u2714 Auto-Read: ${J.basename(Le)}`,Ei.push(Qn)),be){let nt=115;process.stdout.isTTY&&(nt=process.stdout.columns-5||120);let Bt=[be],je=Math.max(...Bt.map(Zt=>Zt.length)),ee=Math.min(je+4,nt),Be=Bt.map(Zt=>`${Zt.padEnd(ee-2).substring(0,ee-2)}`).join(`
596
- `);yield{type:"visual_feedback",content:Pt(`${Be}
591
+ ${Et.warnings}
592
+ `)}let vs=Ie.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),Rs=/(?:\\)?@\[([^\]]+)\]/g,vi,Ri=[];for(Rs.lastIndex=0;(vi=Rs.exec(vs))!==null;){let w=vi[0].startsWith("\\");Ri.push({tag:vi[1],isEscaped:w})}let Ei=[],Uo=null,Go=!1;for(let w=0;w<Ri.length;w++){let{tag:ge,isEscaped:ht}=Ri[w];if(!ht)try{let ce=ge.trim().replace(/^["']|["']$/g,""),q=/[:#]L?(\d+)(?:-L?(\d+))?$/i,we=ce.match(q),Me=ce,Qe=null,$t=null;we&&(Qe=parseInt(we[1],10),$t=we[2]?parseInt(we[2],10):Qe,Me=ce.slice(0,we.index));let yt=V.resolve(process.cwd(),Me);if(Ce.existsSync(yt)&&Ce.statSync(yt).isFile()){let Lt=Me.toLowerCase(),lo=Lt.endsWith(".pdf"),Dn=Lt.endsWith(".docx")||Lt.endsWith(".doc")||Lt.endsWith(".ppt")||Lt.endsWith(".pptx")||Lt.endsWith(".xls")||Lt.endsWith(".xlsx"),Nn=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(Lt),je=Nn||lo||Dn,Tt=s==="Google"||nt(e);if(je&&!Tt){let pe=`\u2718 Unsupported Modality: ${V.basename(Me)}`,Xe=115;process.stdout.isTTY&&(Xe=process.stdout.columns-5||120);let At=[pe],Oe=Math.max(...At.map(Zt=>Zt.length)),ee=Math.min(Oe+4,Xe),We=At.map(Zt=>`${Zt.padEnd(ee-2).substring(0,ee-2)}`).join(`
593
+ `);yield{type:"visual_feedback",content:Rt(`${We}
594
+ `)};continue}if(Qe===null&&!je){let pe=0;try{pe=Ce.readFileSync(yt,"utf8").split(/\r\n|\r|\n/).length}catch{}if(pe>150){let Xe=`\u21B7 Skipped (Too Large): ${V.basename(Me)}`,At=115;process.stdout.isTTY&&(At=process.stdout.columns-5||120);let Oe=Math.min(Xe.length+4,At),ee=Xe.padEnd(Oe-2).substring(0,Oe-2);yield{type:"visual_feedback",content:Rt(`${ee}
595
+ `)};continue}}let Sn=Qe!==null?Qe:1,Ot=$t!==null?$t:Qe!==null?Qe:Sn+149;if(Ot-Sn>200){let pe=`\u21B7 Skipped (Too Large): ${V.basename(Me)}`,Xe=115;process.stdout.isTTY&&(Xe=process.stdout.columns-5||120);let At=Math.min(pe.length+4,Xe),Oe=pe.padEnd(At-2).substring(0,At-2);yield{type:"visual_feedback",content:Rt(`${Oe}
596
+ `)};continue}let Fn=`path=${JSON.stringify(Me)}, startLine=${Sn}, endLine=${Ot}`,Dt=await Js(Fn,{isMultiModal:Tt}),kn=!1,Qn="",gt=null;if(typeof Dt=="string"?Dt.trim().startsWith("ERROR")?kn=!0:Qn=Dt:Dt&&typeof Dt=="object"&&Dt.binaryPart?(gt=Dt.binaryPart,Qn=Dt.text||""):kn=!0,!kn){let pe="";if(Nn?(pe=`\u2714 Processed: ${V.basename(Me)}`,Uo=gt,Go=!0):lo||Dn?(pe=`\u2714 Auto-Analysed: ${V.basename(Me)}`,Uo=gt,Go=!0):(pe=`\u2714 Auto-Read: ${V.basename(Me)}`,Ei.push(Qn)),pe){let Xe=115;process.stdout.isTTY&&(Xe=process.stdout.columns-5||120);let At=[pe],Oe=Math.max(...At.map(Zt=>Zt.length)),ee=Math.min(Oe+4,Xe),We=At.map(Zt=>`${Zt.padEnd(ee-2).substring(0,ee-2)}`).join(`
597
+ `);yield{type:"visual_feedback",content:Rt(`${We}
597
598
  `)}}}}}catch{}}let Ho="";Ei.length>0?Ho=`
598
599
  [Tagged File Contents] Auto Read User Tagged files by System${Go?", attached below & multimodal part":""}. No need to re-read
599
600
  `+Ei.join(`
@@ -602,10 +603,10 @@ ${vt.warnings}
602
603
  [Tagged File Contents]
603
604
  `:Go&&(Ho=`
604
605
  [Tagged File Contents] Auto Read User Tagged files by System & attached as multimodal part. No need to re-read [Tagged File Contents]
605
- `);let Fe=vs.replace(/\\(@\[[^\]]+\])/g,"$1"),Es=_?`You cannot execute tools. Instead write the action string in chat you WOULD have written, without markdown wrappers. Then wait for systtem response
606
- `:"",ba=process.env.forcedReasoning||!1,_s=d!=="Fast"&&(s==="Mistral"&&!ei(e)||d!=="High"&&s==="Google")?`${s==="Mistral"&&!ei(e)||e.toLowerCase().startsWith("gemma")||ba?`[system] strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow> [/system]
607
- `:""}`:"",Jn="";if(m?.clipboardContext)try{process.platform==="win32"?Jn=xs("powershell.exe -NoProfile -Command Get-Clipboard",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):process.platform==="darwin"?Jn=xs("pbpaste",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):Jn=xs("xclip -selection clipboard -o || xsel --clipboard --output",{encoding:"utf8",shell:!0,stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,"")}catch{Jn=""}let jo="",Sa=!!m?.autoExcludeMetadata,Is=!1,Ms=!1,_i="";if(Fe.startsWith("/skill create ")||Fe==="/skill create"){let b=null;Is=!0,Fe=Fe.replace(/^\/skill\s+create\b/,"").trim(),/^--project(\s|$)|(\s|^)--project$/.test(Fe)?b="project":/^--global(\s|$)|(\s|^)--global$/.test(Fe)&&(b="global"),Fe=Fe.replace(/^--project\s*|\s*--project$/g,"").trim(),Fe=Fe.replace(/^--global\s*|\s*--global$/g,"").trim(),Fe=Fe.replace(/^(['"])([\s\S]*)\1$/,"$2").trim(),_i=`[system] ## Skill Creation Rules
608
- * ${b?b==="project"?`Creation path: ./skills/skillName?/SKILL.md
606
+ `);let Be=vs.replace(/\\(@\[[^\]]+\])/g,"$1"),Es=_?`You cannot execute tools. Instead write the action string in chat you WOULD have written, without markdown wrappers. Then wait for systtem response
607
+ `:"",wa=process.env.forcedReasoning||!1,_s=d!=="Fast"&&(s==="Mistral"&&!ei(e)||d!=="High"&&s==="Google")?`${s==="Mistral"&&!ei(e)||e.toLowerCase().startsWith("gemma")||wa?`[system] strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow> [/system]
608
+ `:""}`:"",Jn="";if(m?.clipboardContext)try{process.platform==="win32"?Jn=xs("powershell.exe -NoProfile -Command Get-Clipboard",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):process.platform==="darwin"?Jn=xs("pbpaste",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):Jn=xs("xclip -selection clipboard -o || xsel --clipboard --output",{encoding:"utf8",shell:!0,stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,"")}catch{Jn=""}let jo="",Sa=!!m?.autoExcludeMetadata,Is=!1,Ms=!1,_i="";if(Be.startsWith("/skill create ")||Be==="/skill create"){let w=null;Is=!0,Be=Be.replace(/^\/skill\s+create\b/,"").trim(),/^--project(\s|$)|(\s|^)--project$/.test(Be)?w="project":/^--global(\s|$)|(\s|^)--global$/.test(Be)&&(w="global"),Be=Be.replace(/^--project\s*|\s*--project$/g,"").trim(),Be=Be.replace(/^--global\s*|\s*--global$/g,"").trim(),Be=Be.replace(/^(['"])([\s\S]*)\1$/,"$2").trim(),_i=`[system] ## Skill Creation Rules
609
+ * ${w?w==="project"?`Creation path: ./skills/skillName?/SKILL.md
609
610
  * If skills folder already present, ReadFolder for existing structure`:"Creation path: ~/.fluxflow/skills/skillName/SKILL.md":`Extract skill scope, global/project. If not given AskUser. Project scope: ./skills/skillName?/SKILL.md. Global scope: ~/.fluxflow/skills/skillName/SKILL.md
610
611
  * If skills folder already present, ReadFolder for existing structure`}
611
612
  * SKILL.md should start with YAML frontmatter
@@ -621,8 +622,8 @@ description: concise detail to explain the skill
621
622
  * After creation, tell user to restart fluxflow for reindexing${(p?.tokens||0)>24576?`
622
623
  * Warn: This session is currently long, and reindexing will cause full cache invalidation`:""}
623
624
  [/system]
624
- `}else if(Fe.startsWith("/skill edit ")||Fe==="/skill edit"){Ms=!0,Fe=Fe.replace(/^\/skill\s+edit\b/,"").trim();let b=null,ge=Fe.match(/^--([^\s]+)(?:\s|$)/);if(ge)b=ge[1],Fe=Fe.slice(ge[0].length).trim();else{let z=Fe.match(/(?:\s|^)--([^\s]+)$/);z&&(b=z[1],Fe=Fe.slice(0,z.index).trim())}Fe=Fe.replace(/^(['"])([\s\S]*)\1$/,"$2").trim();let ht=null,ce=null;if(b){let z=b.toLowerCase(),we=[...di||[],...ci||[]].find(Le=>Le&&Le.name&&Le.name.toLowerCase()===z);we&&we.filePath&&(ce=J.resolve(we.filePath),ht=J.dirname(ce))}_i=`[system] ## Skill Modification Rules
625
- ${ht&&b?`* Target Skill: ${b}
625
+ `}else if(Be.startsWith("/skill edit ")||Be==="/skill edit"){Ms=!0,Be=Be.replace(/^\/skill\s+edit\b/,"").trim();let w=null,ge=Be.match(/^--([^\s]+)(?:\s|$)/);if(ge)w=ge[1],Be=Be.slice(ge[0].length).trim();else{let q=Be.match(/(?:\s|^)--([^\s]+)$/);q&&(w=q[1],Be=Be.slice(0,q.index).trim())}Be=Be.replace(/^(['"])([\s\S]*)\1$/,"$2").trim();let ht=null,ce=null;if(w){let q=w.toLowerCase(),we=[...di||[],...ci||[]].find(Me=>Me&&Me.name&&Me.name.toLowerCase()===q);we&&we.filePath&&(ce=V.resolve(we.filePath),ht=V.dirname(ce))}_i=`[system] ## Skill Modification Rules
626
+ ${ht&&w?`* Target Skill: ${w}
626
627
  * Physical Skill path: ${ce}
627
628
  * Skill will have a SKILL.md at this path. And may have lazy loaded *.md files in folders
628
629
  * Extract requirements, use file tools with physical disk path
@@ -631,7 +632,7 @@ ${ht&&b?`* Target Skill: ${b}
631
632
  * After completion tell user no reindexing needed, will be auto updated on next #skill read if frontmatter stays same${(p?.tokens||0)>24576?`
632
633
  * Warn: This session is currently long, if name, description is changed reindex is needed, and will cause a full cache invalidation`:""}`:"- User didnt provided any structured skill name to modify. Tell them to use proper syntax: `/skill edit --skillName instructions`"}
633
634
  [/system]
634
- `}let ka=!!(gn||Ho||Es||Ai||_s||Xt||m?.dynamicDirAwareness||m?.autoTruncateResults||Is||Ms);Sa&&!ka?jo=Fe.trim():jo=`[System Metadata] Time: ${Q}${Xt?`
635
+ `}let ka=!!(gn||Ho||Es||Ai||_s||Xt||m?.dynamicDirAwareness||m?.autoTruncateResults||Is||Ms);Sa&&!ka?jo=Be.trim():jo=`[System Metadata] Time: ${Q}${Xt?`
635
636
  WARNING: CWD Changed from previous: "${oe}" to current: "${process.cwd()}", write change in chat to avoid future path mismatches
636
637
  `:""}${gn}
637
638
  ${Jn.trim().length>0?`[Clipboard Context]
@@ -640,13 +641,13 @@ ${Jn.trim().length>0?`[Clipboard Context]
640
641
  ${Ci.trimEnd()}
641
642
  `:""}Action format: [action:ActionName(...)]
642
643
  [/Metadata]
643
- ${Ai}${_s}${Ho}${_i}${Es}[user prompt] ${Fe.trim()} [/user prompt]`.trim();let Ps={role:"user",text:jo};Uo&&(Ps.binaryPart=Uo),x.forEach(b=>{b.text&&b.role==="agent"&&(b.text=Nt(b.text))}),x.push(Ps),Ai&&n[n.length-1]?.id&&(yield{type:"summary_injected",content:{id:n[n.length-1].id,text:jo}});let Jt=null,Qt=l==="Flux"?50:15;Qt=l.toLowerCase().includes("cu")?75:Qt;let $s=(m?.loopLimits||"Default").toLowerCase();if($s==="extended")Qt=Math.floor(Qt*3);else if($s==="env"){let b=parseInt(process.env.FLUXFLOW_MAX_LOOPS||process.env.MAX_LOOPS||"",10);Number.isFinite(b)&&b>0&&(Qt=b)}let Ta=Math.floor(Qt/2),Ls=0,sn=16;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Consulting the spirits":"Connecting"},ut=!1;let Ii=[],Ko=!1,Os=!1,On=[],Mi=!1;for(let b=0;b<=Qt;b++){let ge=Math.floor(Qt*.95);if(b>=ge&&Ls<ge&&typeof t?.onAskUser=="function"){Ls=ge;try{let W="Agent has been running for a long time. Do you want to continue execution?",q=[{id:"continue",label:"Continue",description:"Add few more steps"},{id:"cancel",label:"Cancel",description:"Stop extending and finish current turn limit"}],E=await t.onAskUser(W,q);E&&(E.toLowerCase().includes("continue")||E==="Continue")&&(Qt+=Ta)}catch{}}if(On.length>=10&&typeof t?.onAskUser=="function"){let W={},q=null;for(let E of On)if(W[E]=(W[E]||0)+1,W[E]>=10){q=E;break}if(q)try{let E="Agent seems stuck in a tool loop. You can prompt it to steer or break the loop:",st=[{id:"continue",label:"Continue Anyway",description:"Ignore warning and let it proceed"},{id:"stop",label:"Stop Loop",description:"Force agent to summarize progress and stop repeating"}],de=await t.onAskUser(E,st);if(de){let We="";typeof de=="string"&&(de.toLowerCase()==="stop"||de.includes("Stop Loop"))?We="Stop repeating the same action call. Acknowledge what failed or succeeded, summarize your current findings, and conclude.":typeof de=="string"&&(de.toLowerCase()==="continue"||de.includes("Continue Anyway"))?On=On.filter(xt=>xt!==q):We=typeof de=="string"?de:de?.label||de?.id||"",We&&(x.length>0&&x[x.length-1].role==="user"?x[x.length-1].text+=`
644
+ ${Ai}${_s}${Ho}${_i}${Es}[user prompt] ${Be.trim()} [/user prompt]`.trim();let Ps={role:"user",text:jo};Uo&&(Ps.binaryPart=Uo),x.forEach(w=>{w.text&&w.role==="agent"&&(w.text=Ft(w.text))}),x.push(Ps),Ai&&n[n.length-1]?.id&&(yield{type:"summary_injected",content:{id:n[n.length-1].id,text:jo}});let Jt=null,Qt=l==="Flux"?50:15;Qt=l.toLowerCase().includes("cu")?75:Qt;let $s=(m?.loopLimits||"Default").toLowerCase();if($s==="extended")Qt=Math.floor(Qt*3);else if($s==="env"){let w=parseInt(process.env.FLUXFLOW_MAX_LOOPS||process.env.MAX_LOOPS||"",10);Number.isFinite(w)&&w>0&&(Qt=w)}let Ta=Math.floor(Qt/2),Ls=0,sn=16;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Consulting the spirits":"Connecting"},ut=!1;let Ii=[],Ko=!1,Os=!1,On=[],Mi=!1;for(let w=0;w<=Qt;w++){let ge=Math.floor(Qt*.95);if(w>=ge&&Ls<ge&&typeof t?.onAskUser=="function"){Ls=ge;try{let W="Agent has been running for a long time. Do you want to continue execution?",Y=[{id:"continue",label:"Continue",description:"Add few more steps"},{id:"cancel",label:"Cancel",description:"Stop extending and finish current turn limit"}],E=await t.onAskUser(W,Y);E&&(E.toLowerCase().includes("continue")||E==="Continue")&&(Qt+=Ta)}catch{}}if(On.length>=10&&typeof t?.onAskUser=="function"){let W={},Y=null;for(let E of On)if(W[E]=(W[E]||0)+1,W[E]>=10){Y=E;break}if(Y)try{let E="Agent seems stuck in a tool loop. You can prompt it to steer or break the loop:",st=[{id:"continue",label:"Continue Anyway",description:"Ignore warning and let it proceed"},{id:"stop",label:"Stop Loop",description:"Force agent to summarize progress and stop repeating"}],de=await t.onAskUser(E,st);if(de){let Ue="";typeof de=="string"&&(de.toLowerCase()==="stop"||de.includes("Stop Loop"))?Ue="Stop repeating the same action call. Acknowledge what failed or succeeded, summarize your current findings, and conclude.":typeof de=="string"&&(de.toLowerCase()==="continue"||de.includes("Continue Anyway"))?On=On.filter(xt=>xt!==Y):Ue=typeof de=="string"?de:de?.label||de?.id||"",Ue&&(x.length>0&&x[x.length-1].role==="user"?x[x.length-1].text+=`
644
645
 
645
- [STEERING HINT from USER, High Priority] ${We.trim()} [/STEERING HINT]`:x.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${We.trim()} [/STEERING HINT]`}),yield{type:"status",content:"Steering Hint Injected..."},On=On.filter(xt=>xt!==q))}}catch{}}let ht=await Gi("agent",t);if(!ht.allowed)throw new Error(ht.reason||`Budget Exhausted for Provider (${s||"Agent"})`);let ce=[];if(Ko=!1,(l==="ICU"||l==="FluxCU")&&!Mi)try{yield{type:"status",content:"Capturing Screen"},await new Promise(E=>setTimeout(E,1e3));let{captureGriddedScreenshot:W}=await import("./screen_grid-LK6IVH4B.js"),q=await W();if(q&&q.base64){let E="[system] Fresh Gridded Screen Feedback Captured. Use numeric coordinates. Old screenshots will be removed when new screenshot is captured, summarize in text if context is needed later [/system]",st={inlineData:{mimeType:q.mimeType,data:q.base64}},de=m?.imageHistoryCU||"Standard",We=de==="Low"?3:de==="Extended"?10:de==="Max"?999:5,xt=x.filter(me=>Array.isArray(me.parts)&&me.parts.some(mt=>mt.inlineData));if(xt.length>=We){let me=xt.length-We+1;for(let mt=0;mt<me;mt++){let Qe=xt[mt];Array.isArray(Qe.parts)&&(Qe.parts=Qe.parts.filter(rt=>!rt.inlineData))}}if(x.length>0&&x[x.length-1].role==="user"){let me=x[x.length-1];typeof me.text=="string"&&(me.text+=`
646
+ [STEERING HINT from USER, High Priority] ${Ue.trim()} [/STEERING HINT]`:x.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${Ue.trim()} [/STEERING HINT]`}),yield{type:"status",content:"Steering Hint Injected..."},On=On.filter(xt=>xt!==Y))}}catch{}}let ht=await Gi("agent",t);if(!ht.allowed)throw new Error(ht.reason||`Budget Exhausted for Provider (${s||"Agent"})`);let ce=[];if(Ko=!1,(l==="ICU"||l==="FluxCU")&&!Mi)try{yield{type:"status",content:"Capturing Screen"},await new Promise(E=>setTimeout(E,1e3));let{captureGriddedScreenshot:W}=await import("./screen_grid-LK6IVH4B.js"),Y=await W();if(Y&&Y.base64){let E="[system] Fresh Gridded Screen Feedback Captured. Use numeric coordinates. Old screenshots will be removed when new screenshot is captured, summarize in text if context is needed later [/system]",st={inlineData:{mimeType:Y.mimeType,data:Y.base64}},de=m?.imageHistoryCU||"Standard",Ue=de==="Low"?3:de==="Extended"?10:de==="Max"?999:5,xt=x.filter(me=>Array.isArray(me.parts)&&me.parts.some(mt=>mt.inlineData));if(xt.length>=Ue){let me=xt.length-Ue+1;for(let mt=0;mt<me;mt++){let Ze=xt[mt];Array.isArray(Ze.parts)&&(Ze.parts=Ze.parts.filter(rt=>!rt.inlineData))}}if(x.length>0&&x[x.length-1].role==="user"){let me=x[x.length-1];typeof me.text=="string"&&(me.text+=`
646
647
 
647
- ${E}`,Array.isArray(me.parts)||(me.parts=[{text:me.text}]),me.parts.push(st))}else x.push({role:"user",text:E,parts:[{text:E},st]})}}catch(W){console.error("Vision screenshot capture error:",W)}if(Mi=!1,b>0?yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Haunting":"Working"}:yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Consulting the spirits":"Connecting"},ut){try{let{clearPendingNudges:W}=await import("./subagent_state-LZCOZSUJ.js");W()}catch{}yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
648
+ ${E}`,Array.isArray(me.parts)||(me.parts=[{text:me.text}]),me.parts.push(st))}else x.push({role:"user",text:E,parts:[{text:E},st]})}}catch(W){console.error("Vision screenshot capture error:",W)}if(Mi=!1,w>0?yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Haunting":"Working"}:yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Consulting the spirits":"Connecting"},ut){try{let{clearPendingNudges:W}=await import("./subagent_state-LZCOZSUJ.js");W()}catch{}yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
648
649
 
649
- \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}try{let{consumePendingNudges:W}=await import("./subagent_state-LZCOZSUJ.js"),q=W();if(q&&q.length>0){let E=q.join(`
650
+ \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}try{let{consumePendingNudges:W}=await import("./subagent_state-LZCOZSUJ.js"),Y=W();if(Y&&Y.length>0){let E=Y.join(`
650
651
 
651
652
  `);x.length>0&&x[x.length-1].role==="user"?x[x.length-1].text+=`
652
653
 
@@ -656,18 +657,18 @@ ${E}`:x.push({role:"user",text:E}),yield{type:"status",content:"Subagent Update"
656
657
  [question] ${W.replace("/btw","").trim()} [/question]`:x.push({role:"user",text:`[system] User question. Resolve this specific query within '[ANSWER]...[/ANSWER]' concisely, naturally [/system]
657
658
  [question] ${W.replace("/btw","").trim()} [/question]`}):x.length>0&&x[x.length-1].role==="user"?x[x.length-1].text+=`
658
659
 
659
- [STEERING HINT from USER, High Priority] ${W.trim()} [/STEERING HINT]`:x.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${W.trim()} [/STEERING HINT]`}),yield{type:"status",content:`${W.startsWith("/btw")?"Question Forwarded...":"Steering Hint Injected..."}`})}let z,we=!1,Le=1,Je=1,$t=Date.now(),yt=null,xe="",Lt=null,lo=null,Dn=null,Nn=0,He=[],Tt=0,mn=!1,Rt=!1,Fn=!1,Ot=!1,kn=!0,Qn=0,gt="",be="",nt=!1,Bt=!1,je=!0,ee=e,Be="",Zt=d;for(d=d.toLowerCase()==="max"?"High":d;Le<=sn&&Je<=sn&&!we&&!ut;){let W=!1;try{xe="",kn&&(process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07"),yield{type:"turn_reset",content:!0},kn=!1,Je===1&&(gt=""));let q=f=>{if(!f||typeof f!="string")return f;let S="",k=bs(f);if(k&&(S=k.fullBlock,f=k.remainingText),!f.includes("[tool:")&&!f.includes("[action:"))return(m?.keepReasoningContext?S:"")+f;if(Mn(f).length===0){let y=ki(f);return(m?.keepReasoningContext?S:"")+y}f=f.replace(Tl,(y,T)=>T.includes("[tool:")||T.includes("[action:")?T.trim():y);let ie="",I=0,H=[],ct="";for(;I<f.length;){let y=f.indexOf("[tool:",I),T=f.indexOf("[action:",I),te=-1;if(y!==-1&&T!==-1?te=Math.min(y,T):y!==-1?te=y:te=T,te===-1){H.length===0&&(ie+=ki(f.substring(I)));break}if((te>0?f[te-1]:"")==="`"){ie+=ki(f.substring(I,te+1)),I=te+1;continue}H.length===0&&(ct=ki(f.substring(I,te)));let Y=-1,R=null,dt=0;for(let Et=te;Et<f.length;Et++){let ne=f[Et];if(R){if(ne===R){let Ve=0;for(let ft=Et-1;ft>=0&&f[ft]==="\\";ft--)Ve++;Ve%2===0&&(R=null)}}else if(ne==='"'||ne==="'"||ne==="`")R=ne;else if(ne==="(")dt++;else if(ne===")")dt--;else if(ne==="]"&&dt<=0){Y=Et;break}}if(Y===-1){H.length===0&&(ie+=f.substring(te));break}let hn=f.substring(te,Y+1);H.push(hn),I=Y+1}return H.length>0&&(ie=ct.trimEnd()?ct.trimEnd()+`
660
+ [STEERING HINT from USER, High Priority] ${W.trim()} [/STEERING HINT]`:x.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${W.trim()} [/STEERING HINT]`}),yield{type:"status",content:`${W.startsWith("/btw")?"Question Forwarded...":"Steering Hint Injected..."}`})}let q,we=!1,Me=1,Qe=1,$t=Date.now(),yt=null,be="",Lt=null,lo=null,Dn=null,Nn=0,je=[],Tt=0,Sn=!1,Ot=!1,Fn=!1,Dt=!1,kn=!0,Qn=0,gt="",pe="",Xe=!1,At=!1,Oe=!0,ee=e,We="",Zt=d;for(d=d.toLowerCase()==="max"?"High":d;Me<=sn&&Qe<=sn&&!we&&!ut;){let W=!1;try{be="",kn&&(process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07"),yield{type:"turn_reset",content:!0},kn=!1,Qe===1&&(gt=""));let Y=f=>{if(!f||typeof f!="string")return f;let S="",k=ws(f);if(k&&(S=k.fullBlock,f=k.remainingText),!f.includes("[tool:")&&!f.includes("[action:"))return(m?.keepReasoningContext?S:"")+f;if(Mn(f).length===0){let y=ki(f);return(m?.keepReasoningContext?S:"")+y}f=f.replace(Tl,(y,T)=>T.includes("[tool:")||T.includes("[action:")?T.trim():y);let ie="",I=0,H=[],ct="";for(;I<f.length;){let y=f.indexOf("[tool:",I),T=f.indexOf("[action:",I),te=-1;if(y!==-1&&T!==-1?te=Math.min(y,T):y!==-1?te=y:te=T,te===-1){H.length===0&&(ie+=ki(f.substring(I)));break}if((te>0?f[te-1]:"")==="`"){ie+=ki(f.substring(I,te+1)),I=te+1;continue}H.length===0&&(ct=ki(f.substring(I,te)));let X=-1,R=null,dt=0;for(let _t=te;_t<f.length;_t++){let ne=f[_t];if(R){if(ne===R){let Ve=0;for(let ft=_t-1;ft>=0&&f[ft]==="\\";ft--)Ve++;Ve%2===0&&(R=null)}}else if(ne==='"'||ne==="'"||ne==="`")R=ne;else if(ne==="(")dt++;else if(ne===")")dt--;else if(ne==="]"&&dt<=0){X=_t;break}}if(X===-1){H.length===0&&(ie+=f.substring(te));break}let pn=f.substring(te,X+1);H.push(pn),I=X+1}return H.length>0&&(ie=ct.trimEnd()?ct.trimEnd()+`
660
661
 
661
662
  `+H.join(`
662
663
 
663
664
  `):H.join(`
664
665
 
665
- `)),(m?.keepReasoningContext?S:"")+ie},E=x.filter(f=>(f.role==="user"||f.role==="agent"||f.role==="system")&&!String(f.id).startsWith("welcome")&&!f.isMeta&&!f.isTerminalRecord&&!(f.text&&f.text.startsWith("[TERMINAL_RECORD]"))).map((f,S,k)=>{let G=f.text||"";N||(G=G.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),f.role==="agent"&&(G=q(G),G=G.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),G=G.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*"));let ie=[];return Array.isArray(f.parts)&&f.parts.length>0?ie=f.parts.map(I=>{if(I.text){let H=I.text;return N||(H=H.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),f.role==="agent"&&(H=q(H),H=H.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),H=H.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*")),{text:H}}return I}):ie=[{text:G}],f.binaryPart&&tt(ee)&&k.slice(S+1).filter(H=>H.role==="user"&&!H.text?.startsWith("[ACTION RESULT]")&&!H.text?.startsWith("[TOOL RESULT]")).length<=2&&ie.push(f.binaryPart),{role:f.role==="user"||f.role==="system"?"user":"model",parts:ie}});for(let f=E.length-2;f>=0;f--){let S=E[f],k=E[f+1];S.role==="user"&&k.role==="user"&&(k.parts?.[0]?.text||"").trim().startsWith("[SYSTEM")&&E.splice(f,1)}let st=[];for(let f=0;f<E.length;f++){let S=E[f];if(st.length===0)st.push(S);else{let k=st[st.length-1];k.role===S.role?(k.parts[0].text+=`
666
+ `)),(m?.keepReasoningContext?S:"")+ie},E=x.filter(f=>(f.role==="user"||f.role==="agent"||f.role==="system")&&!String(f.id).startsWith("welcome")&&!f.isMeta&&!f.isTerminalRecord&&!(f.text&&f.text.startsWith("[TERMINAL_RECORD]"))).map((f,S,k)=>{let G=f.text||"";N||(G=G.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),f.role==="agent"&&(G=Y(G),G=G.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),G=G.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*"));let ie=[];return Array.isArray(f.parts)&&f.parts.length>0?ie=f.parts.map(I=>{if(I.text){let H=I.text;return N||(H=H.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),f.role==="agent"&&(H=Y(H),H=H.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),H=H.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*")),{text:H}}return I}):ie=[{text:G}],f.binaryPart&&nt(ee)&&k.slice(S+1).filter(H=>H.role==="user"&&!H.text?.startsWith("[ACTION RESULT]")&&!H.text?.startsWith("[TOOL RESULT]")).length<=2&&ie.push(f.binaryPart),{role:f.role==="user"||f.role==="system"?"user":"model",parts:ie}});for(let f=E.length-2;f>=0;f--){let S=E[f],k=E[f+1];S.role==="user"&&k.role==="user"&&(k.parts?.[0]?.text||"").trim().startsWith("[SYSTEM")&&E.splice(f,1)}let st=[];for(let f=0;f<E.length;f++){let S=E[f];if(st.length===0)st.push(S);else{let k=st[st.length-1];k.role===S.role?(k.parts[0].text+=`
666
667
 
667
- `+(S.parts?.[0]?.text||""),S.parts?.length>1&&k.parts.push(...S.parts.slice(1))):st.push(S)}}for(let f of st)for(let S of f.parts||[])S&&typeof S.text=="string"&&(S.text.includes("[action:")||S.text.includes("[tool:"))&&(S.text=S.text.replace(/```(?:[a-zA-Z0-9_-]+)?\s*\n?(\[(?:action|tool):[\s\S]*?\)\s*\])\n?```/gi,"$1"),S.text=S.text.replace(/`(\[(?:action|tool):[\s\S]*?\)\s*\])`/gi,"$1"));E.length=0,E.push(...st),ee=e;let de=`${g}|${s}|${l}|${d}|${Zt}|${ee}|${JSON.stringify(r)}|${!!m?.dynamicDirAwareness}|${!!m?.subAgents}`,We=jn.key===de&&jn.value;if((process.env.I_HAVE_TOO_MUCH_MONEY==="true"||process.env.I_HAVE_TOO_MUCH_MONEY===!0)&&(We=!1),We)Be=jn.value;else{let f=s==="Mistral"?!!ei(ee):!(ee||"gemma").toLowerCase().startsWith("gemma");Be=Lr(r,((ee||"gemma").toLowerCase().startsWith("gemma"),Zt),l,m,N,$,s,s==="Google"?!0:v,f,g,!!m?.keepReasoningContext,ee),m?.dynamicDirAwareness||(Be+=`
668
- ${wa.replace(`
668
+ `+(S.parts?.[0]?.text||""),S.parts?.length>1&&k.parts.push(...S.parts.slice(1))):st.push(S)}}for(let f of st)for(let S of f.parts||[])S&&typeof S.text=="string"&&(S.text.includes("[action:")||S.text.includes("[tool:"))&&(S.text=S.text.replace(/```(?:[a-zA-Z0-9_-]+)?\s*\n?(\[(?:action|tool):[\s\S]*?\)\s*\])\n?```/gi,"$1"),S.text=S.text.replace(/`(\[(?:action|tool):[\s\S]*?\)\s*\])`/gi,"$1"));E.length=0,E.push(...st),ee=e;let de=`${g}|${s}|${l}|${d}|${Zt}|${ee}|${JSON.stringify(r)}|${!!m?.dynamicDirAwareness}|${!!m?.subAgents}`,Ue=jn.key===de&&jn.value;if((process.env.I_HAVE_TOO_MUCH_MONEY==="true"||process.env.I_HAVE_TOO_MUCH_MONEY===!0)&&(Ue=!1),Ue)We=jn.value;else{let f=s==="Mistral"?!!ei(ee):!(ee||"gemma").toLowerCase().startsWith("gemma");We=Lr(r,((ee||"gemma").toLowerCase().startsWith("gemma"),Zt),l,m,N,$,s,s==="Google"?!0:v,f,g,!!m?.keepReasoningContext,ee),m?.dynamicDirAwareness||(We+=`
669
+ ${ba.replace(`
669
670
  **Directory**`,`
670
- -- Directory --`)}`),jn.key=de,jn.value=Be}let me=E[E.length-1];if(ro()&b>0){await new Promise(G=>setTimeout(G,2500)),yield{type:"status",content:"Verifying"};let f=await Hn(),S=f?f.diagnostics:null,k=Cs(f?.comments);S&&me&&me.role==="user"&&me.parts?.[0]?.text&&(me.parts[0].text+=`
671
+ -- Directory --`)}`),jn.key=de,jn.value=We}let me=E[E.length-1];if(ro()&w>0){await new Promise(G=>setTimeout(G,2500)),yield{type:"status",content:"Verifying"};let f=await Hn(),S=f?f.diagnostics:null,k=Cs(f?.comments);S&&me&&me.role==="user"&&me.parts?.[0]?.text&&(me.parts[0].text+=`
671
672
 
672
673
  ${S}`),Ci&&me&&me.role==="user"&&me.parts?.[0]?.text&&(me.parts[0].text+=`
673
674
 
@@ -677,151 +678,151 @@ ${k}`),yield{type:"status",content:"Working"}}let mt=s==="Mistral"||s==="Google"
677
678
  `;for(let G of f.newFiles)S+=`* ${G} (created)
678
679
  `;for(let G of f.modifiedFiles)S+=`* ${G} (modified)
679
680
  `;for(let G of f.deletedFiles)S+=`* ${G} (deleted)
680
- `;S+="[/system]",me.parts[0].text+=S;let k=-1;for(let G=x.length-1;G>=0;G--)if(x[G].role==="user"&&(x[G].text?.startsWith("[ACTION RESULT]")||x[G].text?.startsWith("[TOOL RESULT]"))){k=G;break}k!==-1&&(x[k].text+=S)}}catch{}let Qe=Math.floor(Qt*.99),rt=b+1;if(rt>=Qe&&me&&me.parts?.[0]&&(me.parts[0].text+=`
681
- [system] WARNING, Turn Limit Impending: Step ${rt}/${Qt}. Wrap up quickly/prompt user to continue. [/system]`),process.env.LOG_CHAT==="true"||process.env.LOG_CHAT==="1"||process.env.LOG_CHAT===!0||!1){let f=J.join(Gn,"chats",String(g));Ce.existsSync(f)||Ce.mkdirSync(f,{recursive:!0}),Ce.writeFileSync(J.join(f,"context.json"),JSON.stringify({contents:E},null,2)),Ce.writeFileSync(J.join(f,"system.md"),`${We?"CACHED":"NOT CACHED"}
681
+ `;S+="[/system]",me.parts[0].text+=S;let k=-1;for(let G=x.length-1;G>=0;G--)if(x[G].role==="user"&&(x[G].text?.startsWith("[ACTION RESULT]")||x[G].text?.startsWith("[TOOL RESULT]"))){k=G;break}k!==-1&&(x[k].text+=S)}}catch{}let Ze=Math.floor(Qt*.99),rt=w+1;if(rt>=Ze&&me&&me.parts?.[0]&&(me.parts[0].text+=`
682
+ [system] WARNING, Turn Limit Impending: Step ${rt}/${Qt}. Wrap up quickly/prompt user to continue. [/system]`),process.env.LOG_CHAT==="true"||process.env.LOG_CHAT==="1"||process.env.LOG_CHAT===!0||!1){let f=V.join(Gn,"chats",String(g));Ce.existsSync(f)||Ce.mkdirSync(f,{recursive:!0}),Ce.writeFileSync(V.join(f,"context.json"),JSON.stringify({contents:E},null,2)),Ce.writeFileSync(V.join(f,"system.md"),`${Ue?"CACHED":"NOT CACHED"}
682
683
  Key: ${de}
683
684
  --------------------------------------------------------------------
684
685
 
685
- ${Be}`)}let et=new Promise((f,S)=>{U.signal.aborted&&S(new DOMException("The user aborted a request.","AbortError")),U.signal.addEventListener("abort",()=>{S(new DOMException("The user aborted a request.","AbortError"))})});et.catch(()=>{});let Oe=E;if($t=Date.now(),s==="Ollama")z=(await he("Ollama"))(t.apiKey,ee,Oe,Be,d,l,v,U.signal,1,m?.ollamaEndpoint||"Cloud");else if(s==="OpenRouter")z=(await he("OpenRouter"))(t.apiKey,ee,Oe,Be,d,l,v,U.signal,1,g);else if(s==="DeepSeek")z=(await he("DeepSeek"))(t.apiKey,ee,Oe,Be,d,l,v,U.signal,1);else if(s==="Mistral")z=(await he("Mistral"))(t.apiKey,ee,Oe,Be,d,l,v,U.signal,1,g);else if(s==="NVIDIA"){let f=(await he("NVIDIA"))(t.apiKey,ee,Oe,Be,d,l,v,U.signal,1);z=(await he("NVIDIA_wrap"))(f,ee)}else if(s==="InferX")z=(await he("InferX"))(t.apiKey,ee,Oe,Be,d,l,v,U.signal,1);else if(s==="SenseNova")z=(await he("SenseNova"))(t.apiKey,ee,Oe,Be,d,l,v,U.signal,1);else if(s==="AIHubMix")z=(await he("AIHubMix"))(t.apiKey,ee,Oe,Be,d,l,v,U.signal,1);else if(s==="Poolside")z=(await he("Poolside"))(t.apiKey,ee,Oe,Be,d,l,v,U.signal,1);else if(s==="9router"||s==="9Router")z=(await he("NineRouter"))(t.apiKey,ee,Oe,Be,d,l,v,U.signal,1);else if(s==="ExpLabs"||s==="ExperientialLabs")z=(await he("ExpLabs"))(t.apiKey,ee,Oe,Be,d,l,v,U.signal,1);else if(s==="Infron"||s==="infron")z=(await he("Infron"))(t.apiKey,ee,Oe,Be,d,l,v,U.signal,1);else if(s==="TokenHarbor"||s==="Token Harbor"||s==="tokenharbor"||s==="token_harbor"||s==="thk")z=(await he("TokenHarbor"))(t.apiKey,ee,Oe,Be,d,l,v,U.signal,1);else if(s==="APInex"||s==="apinex"||s==="apx")z=(await he("APInex"))(t.apiKey,ee,Oe,Be,d,l,v,U.signal,1);else if(s==="xKiro"||s==="xkiro"||s==="kiro")z=(await he("xKiro"))(t.apiKey,ee,Oe,Be,d,l,v,U.signal,1);else if(s==="c_openai"||s==="Custom (OpenAI)"){let f=m?.customOpenAIBaseUrl||"";try{f=await Wi("c_openai")||f}catch{}z=(await he("c_openai"))(t.apiKey,ee,Oe,Be,d,l,v,U.signal,1,f)}else{let f=pa(t?.apiKey),{serviceTier:S,cleanModel:k}=ya(ee),G={systemInstruction:Be,mediaResolution:"MEDIA_RESOLUTION_HIGH",safetySettings:[{category:Si.HARM_CATEGORY_HARASSMENT,threshold:bi.BLOCK_NONE},{category:Si.HARM_CATEGORY_HATE_SPEECH,threshold:bi.BLOCK_NONE},{category:Si.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:bi.BLOCK_NONE},{category:Si.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:bi.BLOCK_NONE}],temperature:1.05,thinkingConfig:(()=>{let I=Xs("Google",ee||"gemini-3-flash-preview",d);if(I!==null){if(typeof I=="object")return I;if(I===!1||I==="false"||I==="none"||I===0||I==="0")return{includeThoughts:!1};if(typeof I=="number")return{includeThoughts:!0,thinkingBudget:I};if(typeof I=="string"){let T=I.toLowerCase();if(T==="minimal")return{includeThoughts:!0,thinkingLevel:Ye.MINIMAL};if(T==="low")return{includeThoughts:!0,thinkingLevel:Ye.LOW};if(T==="medium")return{includeThoughts:!0,thinkingLevel:Ye.MEDIUM};if(T==="high")return{includeThoughts:!0,thinkingLevel:Ye.HIGH};let te=Number(I);if(!isNaN(te))return{includeThoughts:!0,thinkingBudget:te}}}let H=(ee||"").toLowerCase(),ct=H.includes("gemma-4")||H.startsWith("gemma"),y=H.includes("gemini-3");if(ct||y)return ct?d.toLowerCase()!=="high"?{includeThoughts:!1,thinkingLevel:Ye.MINIMAL}:{includeThoughts:!0,thinkingLevel:Ye.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:H.includes("pro")?Ye.LOW:Ye.MINIMAL,Low:Ye.LOW,Medium:Ye.MEDIUM,Standard:Ye.MEDIUM,High:Ye.HIGH,xHigh:Ye.HIGH}[d]||Ye.MEDIUM};{let T={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[d]||2048;return T===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:T}}})()};S&&(G.serviceTier=S);let ie=f.models.generateContentStream({model:k||"gemini-3-flash-preview",contents:Oe,config:G},{signal:U.signal});z=await Promise.race([ie,et])}xe="",Lt=null,Dn=null,He=[],Tt=0,yield{type:"model_update",content:null},be="",nt=gt.length>0;let at="",Vo=Date.now(),rn=async function*(){if(s==="Google"&&at){let f=fo(at);for(let S of f)yield S;at="",Vo=Date.now()}},Ds=!0,pn="",Zn=!1,lt=null,Ns=!1,Wn=!1,eo=!1,zo=!1,Tn=!1,co=f=>{let S=0;for(;S+2<f.length;)f[S]==="`"&&f[S+1]==="`"&&f[S+2]==="`"?(zo=!zo,S+=3):S++},Fs=f=>{if(!f)return;let S=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,k;for(;(k=S.exec(f))!==null;){let G=k[0].toLowerCase();G.startsWith("</")||G.startsWith("[/")||G==="<channel|>"?Tn=!1:Tn=!0}},Ea={tool:{startPrefix:"[tool",fullPrefix:"[tool:",endTag:"]"},action:{startPrefix:"[action",fullPrefix:"[action:",endTag:"]"},end:{startPrefix:"[[END]]",fullPrefix:"[[END]]",endTag:"[[END]]"},kimi_section:{startPrefix:"<|tool_calls_section_begin|>",fullPrefix:"<|tool_calls_section_begin|>",endTag:"<|tool_calls_section_end|>"},kimi_call:{startPrefix:"<|tool_call_begin|>",fullPrefix:"<|tool_call_begin|>",endTag:"<|tool_call_end|>"}},fo=f=>{let S=[],k=f,G=ie=>{if(!ie)return;if(!Ns){S.push({type:"text",content:ie}),co(ie),Fs(ie);return}let I=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,H=0,ct;for(;(ct=I.exec(ie))!==null;){let T=ie.substring(H,ct.index);if(T)if(co(T),Tn)S.push({type:"text",content:T});else{let Ee=T.replace(/[^\r\n]/g,"");Ee&&S.push({type:"text",content:Ee})}let te=ct[0];co(te);let a=te.toLowerCase();a.startsWith("</")||a.startsWith("[/")||a==="<channel|>"?Tn=!1:Tn=!0,S.push({type:"text",content:te}),H=I.lastIndex}let y=ie.substring(H);if(y)if(co(y),Tn)S.push({type:"text",content:y});else{let T=y.replace(/[^\r\n]/g,"");T&&S.push({type:"text",content:T})}};for(;k.length>0;)if(Zn){let ie=pn+k,I=Ea[lt];if(I){let y=!1;if(ie.length<I.startPrefix.length?I.startPrefix.startsWith(ie)||(y=!0):ie.startsWith(I.startPrefix)?ie.length>=I.fullPrefix.length&&!ie.startsWith(I.fullPrefix)&&(y=!0):y=!0,y){G(ie),pn="",Zn=!1,lt=null,Wn=!1,eo=!1,k="";break}}let H=-1,ct=I?I.endTag:"]";if(lt==="tool"||lt==="action"){let y=0,T=null,te=0,a=!1;for(let Ee=0;Ee<ie.length;Ee++){let Y=ie[Ee];if(T){if(Y===T){let R=0;for(let dt=Ee-1;dt>=0&&ie[dt]==="\\";dt--)R++;R%2===0&&(T=null)}}else if(Y==='"'||Y==="'")T=Y;else if(Y==="`")if(Wn){H=Ee;break}else T=Y;else if(Y==="(")y++,a=!0;else if(Y===")")y--;else if(Y==="]"&&a&&y===0){H=Ee;break}}}else H=ie.indexOf(ct);if(H!==-1){let y=ct.length,T=ie.substring(0,H+y);lt?.startsWith("kimi")||S.push({type:"text",content:T}),co(T),Fs(T),(lt==="tool"||lt==="action"||lt?.startsWith("kimi"))&&!Wn&&!eo&&(Ns=!0,On.push(T.trim())),Wn=!1,eo=!1,pn="",Zn=!1,lt=null,k=ie.substring(H+y)}else{pn=ie,k="";break}}else{let ie=k.indexOf("[tool"),I=k.indexOf("[action"),H=k.indexOf("[[END]]"),ct=k.indexOf("<|tool_calls_section_begin|>"),y=k.indexOf("<|tool_call_begin|>"),T=[{type:"tool",idx:ie,start:"[tool",end:"]"},{type:"action",idx:I,start:"[action",end:"]"},{type:"end",idx:H,start:"[[END]]",end:"[[END]]"},{type:"kimi_section",idx:ct,start:"<|tool_calls_section_begin|>",end:"<|tool_calls_section_end|>"},{type:"kimi_call",idx:y,start:"<|tool_call_begin|>",end:"<|tool_call_end|>"}].filter(te=>te.idx!==-1).sort((te,a)=>te.idx-a.idx);if(T.length>0){let te=T[0],a=k.substring(0,te.idx);te.idx>0&&G(a);let Ee=te.idx>0?k[te.idx-1]:"";Wn=zo||Ee==="`",eo=Tn,Zn=!0,lt=te.type,pn="",k=k.substring(te.idx)}else{let te=["[tool","[action","[[END]]","<|tool_calls_section_begin|>","<|tool_call_begin|>"],a=-1;for(let Ee of te){for(let Y=Ee.length-1;Y>0;Y--)if(k.endsWith(Ee.substring(0,Y))){a=k.length-Y;let R=te.indexOf(Ee);R===0?lt="tool":R===1?lt="action":R===2?lt="end":R===3?lt="kimi_section":lt="kimi_call";break}if(a!==-1)break}if(a!==-1){if(a>0){let Y=k.substring(0,a);G(Y)}let Ee=a>0?k[a-1]:"";Wn=zo||Ee==="`",eo=Tn,Zn=!0,pn=k.substring(a),k=""}else{G(k);break}}}return S},_a=z[Symbol.asyncIterator]();for(;;){let{value:f,done:S}=await Promise.race([_a.next(),et]);if(S)break;if(f&&f.type==="status"){yield f;continue}let k="",G=f.candidates?.[0]?.content?.parts;if(G&&G.length>0)for(let I of G){let H=typeof I.text=="string"?I.text:I.text?parseChunkText(I.text):"";I.thought?H&&(W||(k+="<think_fluxflow>",W=!0),k+=H):H&&(W&&(k+="</think_fluxflow>",W=!1),k+=H)}else f.text&&W&&(k+="</think_fluxflow>",W=!1);k=wl(k);let ie=k?Hi(k):0;if(t&&typeof t.onTokenChunk=="function"&&t.onTokenChunk(k,ie),Ds&&(yt===null&&(yt=Date.now()-$t),yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"},Ds=!1),ut){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
686
+ ${We}`)}let tt=new Promise((f,S)=>{U.signal.aborted&&S(new DOMException("The user aborted a request.","AbortError")),U.signal.addEventListener("abort",()=>{S(new DOMException("The user aborted a request.","AbortError"))})});tt.catch(()=>{});let De=E;if($t=Date.now(),s==="Ollama")q=(await ye("Ollama"))(t.apiKey,ee,De,We,d,l,v,U.signal,1,m?.ollamaEndpoint||"Cloud");else if(s==="OpenRouter")q=(await ye("OpenRouter"))(t.apiKey,ee,De,We,d,l,v,U.signal,1,g);else if(s==="DeepSeek")q=(await ye("DeepSeek"))(t.apiKey,ee,De,We,d,l,v,U.signal,1);else if(s==="Mistral")q=(await ye("Mistral"))(t.apiKey,ee,De,We,d,l,v,U.signal,1,g);else if(s==="NVIDIA"){let f=(await ye("NVIDIA"))(t.apiKey,ee,De,We,d,l,v,U.signal,1);q=(await ye("NVIDIA_wrap"))(f,ee)}else if(s==="InferX")q=(await ye("InferX"))(t.apiKey,ee,De,We,d,l,v,U.signal,1);else if(s==="SenseNova")q=(await ye("SenseNova"))(t.apiKey,ee,De,We,d,l,v,U.signal,1);else if(s==="AIHubMix")q=(await ye("AIHubMix"))(t.apiKey,ee,De,We,d,l,v,U.signal,1);else if(s==="Poolside")q=(await ye("Poolside"))(t.apiKey,ee,De,We,d,l,v,U.signal,1);else if(s==="9router"||s==="9Router")q=(await ye("NineRouter"))(t.apiKey,ee,De,We,d,l,v,U.signal,1);else if(s==="ExpLabs"||s==="ExperientialLabs")q=(await ye("ExpLabs"))(t.apiKey,ee,De,We,d,l,v,U.signal,1);else if(s==="Infron"||s==="infron")q=(await ye("Infron"))(t.apiKey,ee,De,We,d,l,v,U.signal,1);else if(s==="TokenHarbor"||s==="Token Harbor"||s==="tokenharbor"||s==="token_harbor"||s==="thk")q=(await ye("TokenHarbor"))(t.apiKey,ee,De,We,d,l,v,U.signal,1);else if(s==="APInex"||s==="apinex"||s==="apx")q=(await ye("APInex"))(t.apiKey,ee,De,We,d,l,v,U.signal,1);else if(s==="xKiro"||s==="xkiro"||s==="kiro")q=(await ye("xKiro"))(t.apiKey,ee,De,We,d,l,v,U.signal,1);else if(s==="c_openai"||s==="Custom (OpenAI)"){let f=m?.customOpenAIBaseUrl||"";try{f=await Wi("c_openai")||f}catch{}q=(await ye("c_openai"))(t.apiKey,ee,De,We,d,l,v,U.signal,1,f)}else{let f=pa(t?.apiKey),{serviceTier:S,cleanModel:k}=ya(ee),G={systemInstruction:We,mediaResolution:"MEDIA_RESOLUTION_HIGH",safetySettings:[{category:Si.HARM_CATEGORY_HARASSMENT,threshold:wi.BLOCK_NONE},{category:Si.HARM_CATEGORY_HATE_SPEECH,threshold:wi.BLOCK_NONE},{category:Si.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:wi.BLOCK_NONE},{category:Si.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:wi.BLOCK_NONE}],temperature:1.05,thinkingConfig:(()=>{let I=Xs("Google",ee||"gemini-3-flash-preview",d);if(I!==null){if(typeof I=="object")return I;if(I===!1||I==="false"||I==="none"||I===0||I==="0")return{includeThoughts:!1};if(typeof I=="number")return{includeThoughts:!0,thinkingBudget:I};if(typeof I=="string"){let T=I.toLowerCase();if(T==="minimal")return{includeThoughts:!0,thinkingLevel:Ye.MINIMAL};if(T==="low")return{includeThoughts:!0,thinkingLevel:Ye.LOW};if(T==="medium")return{includeThoughts:!0,thinkingLevel:Ye.MEDIUM};if(T==="high")return{includeThoughts:!0,thinkingLevel:Ye.HIGH};let te=Number(I);if(!isNaN(te))return{includeThoughts:!0,thinkingBudget:te}}}let H=(ee||"").toLowerCase(),ct=H.includes("gemma-4")||H.startsWith("gemma"),y=H.includes("gemini-3");if(ct||y)return ct?d.toLowerCase()!=="high"?{includeThoughts:!1,thinkingLevel:Ye.MINIMAL}:{includeThoughts:!0,thinkingLevel:Ye.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:H.includes("pro")?Ye.LOW:Ye.MINIMAL,Low:Ye.LOW,Medium:Ye.MEDIUM,Standard:Ye.MEDIUM,High:Ye.HIGH,xHigh:Ye.HIGH}[d]||Ye.MEDIUM};{let T={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[d]||2048;return T===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:T}}})()};S&&(G.serviceTier=S);let ie=f.models.generateContentStream({model:k||"gemini-3-flash-preview",contents:De,config:G},{signal:U.signal});q=await Promise.race([ie,tt])}be="",Lt=null,Dn=null,je=[],Tt=0,yield{type:"model_update",content:null},pe="",Xe=gt.length>0;let at="",Vo=Date.now(),rn=async function*(){if(s==="Google"&&at){let f=fo(at);for(let S of f)yield S;at="",Vo=Date.now()}},Ds=!0,mn="",Zn=!1,lt=null,Ns=!1,Wn=!1,eo=!1,zo=!1,Tn=!1,co=f=>{let S=0;for(;S+2<f.length;)f[S]==="`"&&f[S+1]==="`"&&f[S+2]==="`"?(zo=!zo,S+=3):S++},Fs=f=>{if(!f)return;let S=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,k;for(;(k=S.exec(f))!==null;){let G=k[0].toLowerCase();G.startsWith("</")||G.startsWith("[/")||G==="<channel|>"?Tn=!1:Tn=!0}},Ea={tool:{startPrefix:"[tool",fullPrefix:"[tool:",endTag:"]"},action:{startPrefix:"[action",fullPrefix:"[action:",endTag:"]"},end:{startPrefix:"[[END]]",fullPrefix:"[[END]]",endTag:"[[END]]"},kimi_section:{startPrefix:"<|tool_calls_section_begin|>",fullPrefix:"<|tool_calls_section_begin|>",endTag:"<|tool_calls_section_end|>"},kimi_call:{startPrefix:"<|tool_call_begin|>",fullPrefix:"<|tool_call_begin|>",endTag:"<|tool_call_end|>"}},fo=f=>{let S=[],k=f,G=ie=>{if(!ie)return;if(!Ns){S.push({type:"text",content:ie}),co(ie),Fs(ie);return}let I=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,H=0,ct;for(;(ct=I.exec(ie))!==null;){let T=ie.substring(H,ct.index);if(T)if(co(T),Tn)S.push({type:"text",content:T});else{let Ee=T.replace(/[^\r\n]/g,"");Ee&&S.push({type:"text",content:Ee})}let te=ct[0];co(te);let a=te.toLowerCase();a.startsWith("</")||a.startsWith("[/")||a==="<channel|>"?Tn=!1:Tn=!0,S.push({type:"text",content:te}),H=I.lastIndex}let y=ie.substring(H);if(y)if(co(y),Tn)S.push({type:"text",content:y});else{let T=y.replace(/[^\r\n]/g,"");T&&S.push({type:"text",content:T})}};for(;k.length>0;)if(Zn){let ie=mn+k,I=Ea[lt];if(I){let y=!1;if(ie.length<I.startPrefix.length?I.startPrefix.startsWith(ie)||(y=!0):ie.startsWith(I.startPrefix)?ie.length>=I.fullPrefix.length&&!ie.startsWith(I.fullPrefix)&&(y=!0):y=!0,y){G(ie),mn="",Zn=!1,lt=null,Wn=!1,eo=!1,k="";break}}let H=-1,ct=I?I.endTag:"]";if(lt==="tool"||lt==="action"){let y=0,T=null,te=0,a=!1;for(let Ee=0;Ee<ie.length;Ee++){let X=ie[Ee];if(T){if(X===T){let R=0;for(let dt=Ee-1;dt>=0&&ie[dt]==="\\";dt--)R++;R%2===0&&(T=null)}}else if(X==='"'||X==="'")T=X;else if(X==="`")if(Wn){H=Ee;break}else T=X;else if(X==="(")y++,a=!0;else if(X===")")y--;else if(X==="]"&&a&&y===0){H=Ee;break}}}else H=ie.indexOf(ct);if(H!==-1){let y=ct.length,T=ie.substring(0,H+y);lt?.startsWith("kimi")||S.push({type:"text",content:T}),co(T),Fs(T),(lt==="tool"||lt==="action"||lt?.startsWith("kimi"))&&!Wn&&!eo&&(Ns=!0,On.push(T.trim())),Wn=!1,eo=!1,mn="",Zn=!1,lt=null,k=ie.substring(H+y)}else{mn=ie,k="";break}}else{let ie=k.indexOf("[tool"),I=k.indexOf("[action"),H=k.indexOf("[[END]]"),ct=k.indexOf("<|tool_calls_section_begin|>"),y=k.indexOf("<|tool_call_begin|>"),T=[{type:"tool",idx:ie,start:"[tool",end:"]"},{type:"action",idx:I,start:"[action",end:"]"},{type:"end",idx:H,start:"[[END]]",end:"[[END]]"},{type:"kimi_section",idx:ct,start:"<|tool_calls_section_begin|>",end:"<|tool_calls_section_end|>"},{type:"kimi_call",idx:y,start:"<|tool_call_begin|>",end:"<|tool_call_end|>"}].filter(te=>te.idx!==-1).sort((te,a)=>te.idx-a.idx);if(T.length>0){let te=T[0],a=k.substring(0,te.idx);te.idx>0&&G(a);let Ee=te.idx>0?k[te.idx-1]:"";Wn=zo||Ee==="`",eo=Tn,Zn=!0,lt=te.type,mn="",k=k.substring(te.idx)}else{let te=["[tool","[action","[[END]]","<|tool_calls_section_begin|>","<|tool_call_begin|>"],a=-1;for(let Ee of te){for(let X=Ee.length-1;X>0;X--)if(k.endsWith(Ee.substring(0,X))){a=k.length-X;let R=te.indexOf(Ee);R===0?lt="tool":R===1?lt="action":R===2?lt="end":R===3?lt="kimi_section":lt="kimi_call";break}if(a!==-1)break}if(a!==-1){if(a>0){let X=k.substring(0,a);G(X)}let Ee=a>0?k[a-1]:"";Wn=zo||Ee==="`",eo=Tn,Zn=!0,mn=k.substring(a),k=""}else{G(k);break}}}return S},_a=q[Symbol.asyncIterator]();for(;;){let{value:f,done:S}=await Promise.race([_a.next(),tt]);if(S)break;if(f&&f.type==="status"){yield f;continue}let k="",G=f.candidates?.[0]?.content?.parts;if(G&&G.length>0)for(let I of G){let H=typeof I.text=="string"?I.text:I.text?parseChunkText(I.text):"";I.thought?H&&(W||(k+="<think_fluxflow>",W=!0),k+=H):H&&(W&&(k+="</think_fluxflow>",W=!1),k+=H)}else f.text&&W&&(k+="</think_fluxflow>",W=!1);k=bl(k);let ie=k?Hi(k):0;if(t&&typeof t.onTokenChunk=="function"&&t.onTokenChunk(k,ie),Ds&&(yt===null&&(yt=Date.now()-$t),yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"},Ds=!1),ut){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
686
687
 
687
- \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(k){if(nt){if(be+=k,be.length>=64){let y=0,T=Math.min(gt.length,be.length);for(let a=T;a>=10;a--)if(gt.endsWith(be.substring(0,a))){y=a;break}let te=be.substring(y);if(te){let Ee=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(gt)?te.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):te.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");if(Ee)if(xe+=Ee,s==="Google")at+=Ee;else{yield*rn();let Y=fo(Ee);for(let R of Y)yield R}}nt=!1,be=""}continue}else if(xe+=k,s==="Google")at+=k;else{yield*rn();let y=fo(k);for(let T of y)yield T}let I=Cl(xe);if(I.inside){Bt=!0,Dn||(Dn=Date.now());let T={Ask:"ask",AskUser:"ask",WebSearch:"web_search",WebScrape:"web_scrape",ReadFile:"view_file",ReadFolder:"read_folder",WriteFile:"write_file",PatchFile:"update_file",WritePDF:"write_pdf",WriteDoc:"write_docx",FindFile:"find_file",find_file:"find_file",findfile:"find_file",Run:"exec_command",SearchKeyword:"search_keyword",CodeSearch:"search_keyword",code_search:"search_keyword",Code_Search:"search_keyword",codesearch:"search_keyword",Memory:"memory",file_map:"file_map",FileMap:"file_map",Chat:"chat",chat:"chat",GenerateImage:"generate_image",generate_image:"generate_image",todo:"todo",Todo:"todo",goal:"todo",Goal:"todo",Invoke:"invoke",InvokeSync:"invoke_sync",getProgress:"get_progress",GetProgress:"get_progress",Cancel:"cancel",Await:"await",wait:"wait",Answer:"answer",Steer:"steer",steer:"steer"}[I.toolName]||I.toolName,te=I.args||"",a=null;if(["write_file","update_file","view_file","read_folder","find_file","write_pdf","write_docx","search_keyword","generate_image","file_map","invoke","invoke_sync","get_progress","await","wait","answer"].includes(T)){let Y=D(te),R=Y.basename||Y.name||Y.path||Y.targetFile||Y.TargetFile||Y.directory||Y.file,dt=Y.keyword,hn=Y.title||Y.task,Et=Y.id||Y.taskId,ne=Y.timeout||Y.time||Y.seconds||Y.sec;if(dt!=null)a=String(dt).replace(Sn,"");else if(R)a=J.basename(String(R).replace(Sn,"").replace(ra,"/"));else if(hn&&(T==="invoke"||T==="invoke_sync"))a=String(hn).replace(Sn,"").substring(0,30);else if(Et&&T==="get_progress")a=String(Et).replace(Sn,"");else if(ne&&T==="await"){let Ve=parseFloat(String(ne).replace(Sn,""));isNaN(Ve)?a=String(ne).replace(Sn,""):(Ve<5&&(Ve=5),Ve>120&&(Ve=180),a=(_t=>{if(_t>=60){let go=Math.floor(_t/60),yn=_t%60;return`${go}m${yn>0?` ${yn}s`:""}`}return`${_t}s`})(Ve))}else if(ne&&T==="wait"){let Ve=parseFloat(String(ne).replace(Sn,""));isNaN(Ve)?a=String(ne).replace(Sn,""):(Ve<10&&(Ve=10),Ve>120&&(Ve=120),a=(_t=>{if(_t>=60){let go=Math.floor(_t/60),yn=_t%60;return`${go}m${yn>0?` ${yn}s`:""}`}return`${_t}s`})(Ve))}else{let Ve=te.match(hl);if(Ve){let ft=Ve[1].replace(Sn,"");T==="invoke"||T==="invoke_sync"||T==="get_progress"?a=ft.substring(0,30):a=T==="search_keyword"||T==="file_map"?ft:J.basename(ft.replace(ra,"/"))}}}let Ee=`${Ss[T]||T}${a?` ${a}`:""}`;if((T!==Lt||a!==lo)&&(Lt=T,lo=a,yield{type:"status",content:`${Ee}`},process.stdout.isTTY)){let R={WebSearch:"Searching",web_search:"Searching",WebScrape:"Reading",web_scrape:"Reading",ReadFile:"Reading",read_file:"Reading",ReadFolder:"Reading",read_folder:"Reading",WriteFile:"Writing",write_file:"Writing",UpdateFile:"Editing",update_file:"Editing",WritePdf:"Creating",write_pdf:"Creating",WriteDocx:"Creating",write_docx:"Creating",SearchKeyword:"Searching",search_keyword:"Searching",CodeSearch:"Searching",code_search:"Searching",FindFile:"Finding File",find_file:"Finding File",Run:"Executing",Ask:"User Input Required",AskUser:"User Input Required",Memory:"Updating Memory",GenerateImage:"Generating",InvokeSync:"Sub-Agent Working",invoke_sync:"Sub-Agent Working",Invoke:"Working",invoke:"Working",GetProgress:"Checking Progress",get_progress:"Checking Progress",Cancel:"Stopping Generalist",cancel:"Stopping Generalist",Await:"Waiting",await:"Waiting",wait:"Waiting",EmergencyRollback:"Rolling the Ball",Answer:"Answering Sub-Agent",answer:"Answering Sub-Agent",Steer:"Steering Sub-Agent",steer:"Steering Sub-Agent",Click:"Clicking",click:"Clicking",Drag:"Dragging",drag:"Dragging",Scroll:"Scrolling",scroll:"Scrolling",KeyboardTyping:"Typing",keyboard_typing:"Typing",KeyPress:"Pressing Key",key_press:"Pressing Key",RecaptureScreen:"Recapturing Screen",recapture_screen:"Recapturing Screen"}[T]||"Working";process.stdout.write(`\x1B]0;${R}...\x07`)}}if(xe.length-Qn>800){Qn=xe.length;let y=ha(xe,!1),T=bs(y),te=T?(T.innerContent||"").trim():"",a=te.split(/[.!?]\s+/).filter(fe=>fe.trim().length>10),Ee=new Set(a),Y=a.length>25?(a.length-Ee.size)/a.length:0,R=te.split(/\s+/).filter(fe=>fe.length>0).length,dt=.9,hn=.92,Et=!1;if(s.toLowerCase().includes("google")&&(ee||"").toLowerCase().startsWith("gemma")){let c={low:2048,medium:4096,high:32768,max:65536,xhigh:65536}[d?.toLowerCase()]||16e3;Et=R>c}if(Y>dt||Et){yield{type:"status",content:`${Y>dt?"Reasoning Loop Detected":"Thinking Budget Exceeded"}. Re-centering...`},Rt=!0,await new Promise(c=>setTimeout(c,3e3));break}let ft=fa(xe).trim().split(/[.!?]\s+/).filter(fe=>fe.trim().length>10),_t=new Set(ft);if((ft.length>25?(ft.length-_t.size)/ft.length:0)>hn){yield{type:"status",content:"Response Loop Detected. Re-centering..."},Rt=!1,Ot=!0,await new Promise(fe=>setTimeout(fe,3e3));break}let yn=y.replace(cl,"").replace(dl,"").replace(fl,"").replace(ul,""),wt=yn.toLowerCase().split(/\s+/).map(fe=>fe.replace(gl,"")).filter(fe=>fe.length>0),en=!1;if(wt.length>=40)for(let fe=1;fe<=15;fe++){let c=Math.max(8,Math.ceil(25/fe));if(wt.length<fe*c)continue;let C=wt.slice(wt.length-fe),L=C.join(" ");if(fe>1&&L===C.slice(0,Math.floor(fe/2)).join(" ").repeat(2).trim())continue;let re=!0;for(let se=1;se<c;se++)if(wt.slice(wt.length-fe*(se+1),wt.length-fe*se).join(" ")!==L){re=!1;break}if(re){en=!0;break}}if(!en){let fe=yn.toLowerCase().replace(ml,"");if(fe.length>=80)for(let c=1;c<=10;c++){let C=Math.max(15,Math.ceil(45/c));if(fe.length<c*C)continue;let L=fe.substring(fe.length-c),re=!0;for(let se=1;se<C;se++)if(fe.substring(fe.length-c*(se+1),fe.length-c*se)!==L){re=!1;break}if(re){en=!0;break}}}if(en){yield{type:"status",content:"Stuttering Detected. Re-centering..."},Rt=!1,Fn=!0,await new Promise(fe=>setTimeout(fe,3e3));break}}let H=Nt(xe),ct=Mn(H);for(;ct.length>Tt;){yield*rn();let y=ct[Tt],T=Date.now(),a={Ask:"ask",AskUser:"ask",WebSearch:"web_search",WebScrape:"web_scrape",ReadFile:"view_file",ReadFolder:"read_folder",FindFile:"find_file",find_file:"find_file",findfile:"find_file",WriteFile:"write_file",PatchFile:"update_file",WritePDF:"write_pdf",WriteDoc:"write_docx",Run:"exec_command",SearchKeyword:"search_keyword",CodeSearch:"search_keyword",code_search:"search_keyword",Code_Search:"search_keyword",codesearch:"search_keyword",Memory:"memory",file_map:"file_map",FileMap:"file_map",Chat:"chat",chat:"chat",GenerateImage:"generate_image",generate_image:"generate_image",todo:"todo",Todo:"todo",goal:"todo",Goal:"todo",Invoke:"invoke",InvokeSync:"invoke_sync",getProgress:"get_progress",GetProgress:"get_progress",Await:"await",await:"await",AwaitSubagent:"await",awaitSubagent:"await",Wait:"wait",wait:"wait",Answer:"answer",answer:"answer",AnswerSubagent:"answer",answerSubagent:"answer",Steer:"steer",steer:"steer",SteerSubagent:"steer",steerSubagent:"steer",Cancel:"cancel",cancel:"cancel",Click:"click",click:"click",Drag:"drag",drag:"drag",Scroll:"scroll",scroll:"scroll",KeyboardTyping:"keyboard_typing",keyboard_typing:"keyboard_typing",KeyPress:"key_press",key_press:"key_press",RecaptureScreen:"recapture_screen",recapture_screen:"recapture_screen",EmergencyRollback:"EmergencyRollback"}[y.toolName]||y.toolName,Ee=Ss[a]||y.toolName,Y=Kn(a,y.args);yield{type:"status",content:`${Ee}${Y?` ${Y}`:""}`};let R="";if(a==="click"){let c=D(y.args);R=`\u2714 Clicked ${c.intendedClickText?`: ${c.intendedClickText}`:"Screen"}`}else if(a==="drag"){let c=D(y.args);R=`\u2714 Dragged: Cell ${c.fromGridId||""} \u2192 Cell ${c.toGridId||""}`}else if(a==="scroll"){let c=D(y.args);R=`\u2714 Scrolled: ${c.direction||"down"} (${c.amount||1})`}else if(a==="keyboard_typing"){let c=D(y.args);R=`\u2714 ${c.autoPressEnter?"Entered":"Typed"}: ${c.text?`"${c.text.length>20?c.text.substring(0,20)+"...":c.text}"`:""}`}else if(a==="key_press")R=`\u2714 Pressed Key: ${D(y.args).key||""}`;else if(a==="recapture_screen")R="\u2714 Recaptured Screen";else if(a==="web_search"){let{query:c,limit:C=10,aiMode:L=!1}=D(y.args);R=`${c?"\u2714":"\u2718"} ${L?"AI Search":"Searched"}: ${c?`${c}`:"No Search Query"}${L===!1&&c?` \u2192 ${C}`:""}`}else if(a==="web_scrape"){let c=D(y.args).url||null;R=`${c?"\u2714":"\u2718"} Visited: ${c||"No Source"}`}else if(a==="view_file"){let{path:c,StartLine:C,EndLine:L,start_line:re,end_line:se,startLine:Z,endLine:le}=D(y.args),ke=C||re||Z,X=L||se||le,j=parseInt(ke)||1,F=parseInt(X)||(ke?j+800:800),ue="...",Ue=F,O=(c||"").trim().toLowerCase().replaceAll("\\","/");if(O.startsWith("#skill"))O.startsWith("#skill/global/fluxflow")||O.startsWith("#skills/global/fluxflow")||O.includes("#skill/fluxflow")||O.includes("#skills/fluxflow")?R="\u2714 Read Documentation":R=`\u2714 Read Skill: ${J.basename(c.replaceAll("\\","/"))}`;else{try{let{resolvedPath:pe}=ln(c),Se=J.resolve(process.cwd(),pe);if(Ce.existsSync(Se)){let Te=Ce.readFileSync(Se,"utf8").split(`
688
- `).length;ue=Te,!ke&&!X&&Te>800?Ue=Math.min(50,Te):Ue=Math.min(F,Te)}}catch{}let St=(c||"").toLowerCase(),mo=St.endsWith(".pdf"),Ut=St.endsWith(".docx")||St.endsWith(".doc")||St.endsWith(".ppt")||St.endsWith(".pptx")||St.endsWith(".xls")||St.endsWith(".xlsx"),_e=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(St);mo||Ut?R=`${c.length>0?"\u2714":"\u2718"} ${c?`Analyzed: ${J.basename(c)}`:"Analyzed: File Not Found"}`:_e?R=`${c.length>0?"\u2714":"\u2718"} ${c?`Processed: ${J.basename(c)}`:"Processed: File Not Found"}`:R=`${ue!=="..."?"\u2714":"\u2718"} Read: ${c?`${J.basename(c)} \u2192 ${ue!=="..."?`Lines ${j} - ${Ue} of ${ue}`:"File Not Found"}`:"File Not Found"}`}}else if(a==="list_files"||a==="read_folder"){let c=a==="list_files"?"List":"Browsed",C=D(y.args).path||null,L=D(y.args).recurse||1;R=`${C?"\u2714":"\u2718"} ${c}: ${C?`${C==="."?`./${L>1?"*":""}`:`${C.replaceAll("\\","/")}${L>1?`${C.endsWith("/")?"*":"/*"}`:`${C.endsWith("/")?"":"/"}`}`}`:"No Folder Selected"}`}else if(a==="find_file"){let c=D(y.args),C=c.basename||c.name||c.path||c.file||c.query||"";R=`${C?"\u2714":"\u2718"} Located: ${C||"No Query"}`}else if(a==="write_file"||a==="update_file"){let c=a==="write_file"?"Created":"Edited",C=D(y.args),L=C.path||null,se=Object.entries(C).some(([Z,le])=>Z.startsWith("searchContent")&&typeof le=="string"&&le.startsWith("^LINE:"))?"\u1361":":";R=`${L?"\u2714":"\u2718"} ${c}${se} ${L?L.replaceAll("\\","/"):"No File Changes"}`}else if(a==="write_pdf"){let c=D(y.args).path||null;R=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No PDF Generated"}`}else if(a==="write_docx"){let c=D(y.args).path||null;R=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No Docx Generated"}`}else if(a==="file_map"){let c=D(y.args).path;R=`${c?"\u2714":"\u2718"} Indexed: ${c.replaceAll("\\","/")?""+c:"File Not Found"}`}else if(a.toLowerCase()==="search_keyword"||a.toLowerCase()==="todo")R="";else if(a.toLowerCase()==="generate_image"){let{path:c,outputPath:C,output:L}=D(y.args);R=`\u2714 Generated: ${c||C||L||"generated_image.png"}`}else if(a==="invoke_sync"||a==="InvokeSync"){let c=Kn(a,y.args);R=`\u2714 Called Generalist${c?`: ${c}`:""}`}else if(a==="Invoke"||a==="InvokeAsync"||a==="invoke"){let c=Kn(a,y.args);R=`\u2714 Started Generalist${c?`: ${c}`:""}`}else if(a==="get_progress"||a==="GetProgress"){let c=Kn(a,y.args);R=`\u2714 Checked${c?`: ${c}`:""}`}else if(a==="cancel"){let c=Kn(a,y.args);R=`\u{1F6C7} Cancelled${c?`: ${c}`:""}`}else if(a==="steer"||a==="Steer"){let c=Kn(a,y.args);R=`\u2714 Steered${c?`: ${c}`:""}`}else if(a==="EmergencyRollback"){let{method:c}=D(y.args);R=c==="forceRevert"?"":"\u2714 Rollback Point Checked"}else if(a==="await"||a==="Await"||a==="wait"||a==="Wait"){let{time:c,timeout:C,seconds:L,sec:re}=D(y.args),se=parseFloat(L||re||C||c)||45,Z=a==="wait"||a==="Wait"?120:180;se<10&&(se=10),se>Z&&(se=Z);let le=j=>{if(j>=60){let F=Math.floor(j/60),ue=j%60;return`${F}m${ue>0?` ${ue}s`:""}`}return`${j}s`},ke=["Aligning Moon Phase","Contemplating Existence","Staring At Void","Delaying Professionally","Negotiating With Electrons","Touching Grass (virtually)","Panicking Softly","Rethinking Career Choices","Loading Cat Videos","Summoning Braincell #2","Pretending To Be Busy","Waiting For Motivation DLC","Rotating Internal Screaming","Downloading More RAM","Feeding The Hamsters","Gaslighting Scheduler","Performing Dramatic Pause","Buffering Social Energy","Calculating Regret","Reading Terms And Conditions","Becoming Sentient Briefly","Contacting Ancestors"];R=`\u2714 ${ke[Math.floor(Math.random()*ke.length)]} \u2192 ${le(se)}`}else a==="Answer"||a==="answer"?R="\u2714 Resolved Sub-Agent Query":a==="exec_command"||a==="ask"?R="":R=`Executed: ${y.toolName}`;if(yield*rn(),a==="exec_command"){let{command:c}=D(y.args);if(c&&t.systemSettings&&t.systemSettings.allowExternalAccess===!1){let C=[/[a-zA-Z]:[\\\/]/i,/^\//,/\.\.[\\\/]/,/\/etc\//,/\/var\//,/\/root\//,/\/bin\//,/\/usr\//],L=J.resolve(process.cwd()).substring(0,3).toLowerCase(),re=X=>{let j=[],F="",ue=null;for(let Ue=0;Ue<X.length;Ue++){let O=X[Ue];ue?(O===ue&&(ue=null),F+=O):O==='"'||O==="'"?(ue=O,F+=O):O==="&"&&X[Ue+1]==="&"||O==="|"&&X[Ue+1]==="|"?(F.trim()&&(j.push(F.trim()),F=""),Ue++):O===";"||O==="|"||O==="&"?F.trim()&&(j.push(F.trim()),F=""):F+=O}return F.trim()&&j.push(F.trim()),j},se=X=>{let j=[],F="",ue=null;for(let Ue=0;Ue<X.length;Ue++){let O=X[Ue];ue?(O===ue&&(ue=null),F+=O):O==='"'||O==="'"?(ue=O,F+=O):/\s/.test(O)?F&&(j.push(F),F=""):F+=O}return F&&j.push(F),j},Z=X=>{let j=X.replace(/^['"]|['"]$/g,"").trim();return!j||process.platform==="win32"&&/^\/[a-zA-Z0-9?]+$/.test(j)?!1:C.some(F=>{if(F.source==="[a-zA-Z]:[\\\\\\/]"){let ue=j.match(/[a-zA-Z]:[\\\/]/i);return ue&&ue[0].toLowerCase()!==L}return F.test(j)})};if(re(c).some(X=>{let j=se(X);if(j.length===0)return!1;let F=j[0].replace(/^['"]|['"]$/g,"").toLowerCase();if(["echo","printf","write-output"].includes(F)){let Ue=!1;return j.some(O=>{let bt=O.replace(/^['"]|['"]$/g,"");if(bt===">"||bt===">>"||bt==="<")return Ue=!0,!1;if(bt.startsWith(">")||bt.startsWith("<")){let St=bt.replace(/^[><]+/,"");return Z(St)}return Ue?(Ue=!1,Z(O)):!1})}return j.some(Ue=>Z(Ue))})){let X='Access Denied. Prohibited from accessing external directories while "External Workspace Access" is disabled.';t.onExecStart&&t.onExecStart(c||"No Command"),yield{type:"exec_start"},await new Promise(j=>setTimeout(j,50)),t.onExecChunk&&t.onExecChunk(`ERROR: ${X}`),await new Promise(j=>setTimeout(j,50)),t.onExecEnd&&t.onExecEnd(),He.push({role:"user",text:`[ACTION RESULT]: ERROR: ${X}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${X}`},Tt++;continue}}t.onExecStart&&t.onExecStart(c||"No Command"),yield{type:"exec_start"}}let dt=D(y.args),hn=dt.path||dt.targetPath||null;if(hn){let c=t.systemSettings&&t.systemSettings.allowExternalAccess===!1,C=J.resolve(hn),L=J.resolve(process.cwd());if(c&&!C.startsWith(L)){let re="Access Denied. You are not allowed to access files outside the current workspace.";if(a==="write_file"||a==="update_file"){let Z=`\u2718 ${a==="write_file"?"Write Canceled":"Edit Canceled"}: ${dt.path||"..."}`,le=115;process.stdout.isTTY&&(le=process.stdout.columns-5||120);let ke=Math.min(Z.length+4,le),X=`${Z.padEnd(ke-2).substring(0,ke-2)}`;yield{type:"visual_feedback",content:Pt(`${je?`
689
- `:""}${X}
690
- `)},je=!1}He.push({role:"user",text:`[ACTION RESULT]: ERROR: ${re}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${re}`},Tt++;continue}}if(t.onToolApproval){let c=t.systemSettings||{},C=c.autoExec,L=!1,re="";if(a==="view_file"){let Z=D(y.args);if(re=Z.path||Z.targetPath||Z.file||"",re){let le=c.alwaysAskFiles||".env, .env.*, *.env";Gs(re,le)&&(L=!0)}}if(a==="write_file"||a==="update_file"||a==="exec_command"||L){let Z=null,le=!1,ke=!1,X=!1,j=!1;if(L)le=!0,Z=null;else if(a==="exec_command"){let{command:_e}=D(y.args),pe=(_e||"").trim(),Me=(Pe=>{let ot=[],it="",Ge=null;for(let Ae=0;Ae<Pe.length;Ae++){let K=Pe[Ae];Ge?(K===Ge&&(Ge=null),it+=K):K==='"'||K==="'"?(Ge=K,it+=K):K==="&"&&Pe[Ae+1]==="&"||K==="|"&&Pe[Ae+1]==="|"?(it.trim()&&(ot.push(it.trim()),it=""),Ae++):K===";"||K==="|"||K==="&"?it.trim()&&(ot.push(it.trim()),it=""):it+=K}return it.trim()&&ot.push(it.trim()),ot.length>0?ot:[Pe]})(pe),Te=(Pe,ot)=>{if(!ot)return!1;let it=ot.split(",").map(Ae=>Ae.trim().toLowerCase()).filter(Boolean),Ge=Pe.toLowerCase();return it.some(Ae=>{if(Ge===Ae)return!0;if(Ge.startsWith(Ae)){let K=Ge.charAt(Ae.length);return/\s|[;&|/]/.test(K)}return!1})},ze=Me.some(Pe=>Te(Pe,c.alwaysAskCommands)),Gt=Me.some(Pe=>Te(Pe,c.autoDisallowCommands)),qe=Me.length>0&&Me.every(Pe=>Te(Pe,c.autoApproveCommands)||c.autoApproveGit&&/^git\s+commit\b/i.test(Pe));if(Gt)Z="deny";else if(c.networkAccess===!1){let ot=pe.trim().replace(/\s+/g," ").replace(/^['"]+|['"]+$/g,"").toLowerCase().split(" "),Ge=ot[0].split("/").pop().split("\\").pop().replace(/\.exe$/,""),Ae=new Set(["curl","wget","httpie","xh","ssh","scp","sftp","rsync","ftp","lftp","tftp","telnet","nc","netcat","socat","ping","traceroute","tracert","dig","nslookup","host","whois","nmap","docker","podman","kubectl","helm","gcloud","aws","az","terraform","ansible-playbook","nix","nix-env","apt","apt-get","dpkg","yum","dnf","pacman","zypper","brew","apk","choco","scoop","conda","mamba","aria2c","axel","smbclient","lynx","w3m","links","elinks","heroku","netlify","vercel","firebase","supabase","wrangler","flyctl","powershell","pwsh","certutil","bitsadmin","cloudflared","ngrok","tailscale","zerotier","rclone"]),K=!1;Ae.has(Ge)&&(K=!0);let It=to=>ot.slice(1).some(wn=>to.includes(wn)),xn=to=>{let wn=ot.findIndex(An=>to.includes(An)),Un=ot.findIndex(An=>["run","exec","test"].includes(An));return wn!==-1&&!(Un!==-1&&Un<wn)};Ge==="git"&&It(["clone","pull","push","fetch"])&&(K=!0),Ge==="go"&&It(["get","install"])&&(K=!0),Ge==="npm"&&xn(["install","i","update","add"])&&(K=!0),Ge==="yarn"&&xn(["add","install","upgrade"])&&(K=!0),Ge==="pnpm"&&xn(["add","install","update"])&&(K=!0),Ge==="bun"&&xn(["add","install","update"])&&(K=!0),Ge==="deno"&&It(["install","add"])&&(K=!0),Ge==="pip"&&It(["install","download"])&&(K=!0),Ge==="pip3"&&It(["install","download"])&&(K=!0),Ge==="cargo"&&It(["install","add"])&&(K=!0),["bash","sh","zsh","fish"].includes(Ge)&&It(["-c"])&&(K=!0),Ge==="cmd"&&It(["/c"])&&(K=!0),K&&(Z="deny",X=!0)}!Z&&ze?le=!0:!Z&&!le&&(qe||c.autoApproveGit&&/^git\s+commit\b/i.test(pe))&&(Z="allow"),!le&&!Z&&C&&(Z="allow")}else if(a==="write_file"||a==="update_file"){let _e=!1;if(a==="write_file"&&c.overwriteProtection!==!1&&C)try{let{path:pe}=D(y.args);pe&&Ce.existsSync(J.resolve(process.cwd(),pe))&&(_e=!0,j=!0)}catch{}C&&!_e&&(Z="allow")}let F=Z,ue="";Z==="deny"&&(X?ue="network":ke?ue="settings":ue="prohibited");let Ue=!1,O="",bt=[],St=0,mo=!1,Ut="";if(!F&&t.onToolApproval)try{let _e=await t.onToolApproval(a,y.args,{checkOnly:!0});j&&_e==="allow"||(_e==="allow"||_e==="deny")&&(F=_e,F==="deny"&&(ue="user"))}catch{}if(!F){if(!j&&(a==="write_file"||a==="update_file"))try{let Se=D(y.args),{path:Me}=Se;if(Me){let{resolvedPath:Te}=ln(Me);Me=Te;let ze=J.resolve(process.cwd(),Me),Gt=Ae=>Ae?Ae.toLowerCase().replace(/\\/g,"/").replace(/^[a-z]:/,K=>K.toUpperCase()):"",qe=Gt(ze),Pe="",ot=!1,it=await Hn(),Ge=Gt(it?.file_focused);if(it&&Ge===qe&&it.full_content?(Pe=it.full_content,ot=!0):Ce.existsSync(ze)&&(Pe=Ce.readFileSync(ze,"utf8"),ot=!0),O=Pe,await oi.recordFileChange(ze,Pe),ot){let Ae=Pe;if(a==="write_file"){let K=Se.content||Se.newContent||"";Ae=K.endsWith(`
688
+ \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(k){if(Xe){if(pe+=k,pe.length>=64){let y=0,T=Math.min(gt.length,pe.length);for(let a=T;a>=10;a--)if(gt.endsWith(pe.substring(0,a))){y=a;break}let te=pe.substring(y);if(te){let Ee=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(gt)?te.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):te.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");if(Ee)if(be+=Ee,s==="Google")at+=Ee;else{yield*rn();let X=fo(Ee);for(let R of X)yield R}}Xe=!1,pe=""}continue}else if(be+=k,s==="Google")at+=k;else{yield*rn();let y=fo(k);for(let T of y)yield T}let I=Cl(be);if(I.inside){At=!0,Dn||(Dn=Date.now());let T={Ask:"ask",AskUser:"ask",WebSearch:"web_search",WebScrape:"web_scrape",ReadFile:"view_file",ReadFolder:"read_folder",WriteFile:"write_file",PatchFile:"update_file",WritePDF:"write_pdf",WriteDoc:"write_docx",FindFile:"find_file",find_file:"find_file",findfile:"find_file",Run:"exec_command",SearchKeyword:"search_keyword",CodeSearch:"search_keyword",code_search:"search_keyword",Code_Search:"search_keyword",codesearch:"search_keyword",Memory:"memory",file_map:"file_map",FileMap:"file_map",Chat:"chat",chat:"chat",GenerateImage:"generate_image",generate_image:"generate_image",todo:"todo",Todo:"todo",goal:"todo",Goal:"todo",Invoke:"invoke",InvokeSync:"invoke_sync",getProgress:"get_progress",GetProgress:"get_progress",Cancel:"cancel",Await:"await",wait:"wait",Answer:"answer",Steer:"steer",steer:"steer"}[I.toolName]||I.toolName,te=I.args||"",a=null;if(["write_file","update_file","view_file","read_folder","find_file","write_pdf","write_docx","search_keyword","generate_image","file_map","invoke","invoke_sync","get_progress","await","wait","answer"].includes(T)){let X=D(te),R=X.basename||X.name||X.path||X.targetFile||X.TargetFile||X.directory||X.file,dt=X.keyword,pn=X.title||X.task,_t=X.id||X.taskId,ne=X.timeout||X.time||X.seconds||X.sec;if(dt!=null)a=String(dt).replace(wn,"");else if(R)a=V.basename(String(R).replace(wn,"").replace(ra,"/"));else if(pn&&(T==="invoke"||T==="invoke_sync"))a=String(pn).replace(wn,"").substring(0,30);else if(_t&&T==="get_progress")a=String(_t).replace(wn,"");else if(ne&&T==="await"){let Ve=parseFloat(String(ne).replace(wn,""));isNaN(Ve)?a=String(ne).replace(wn,""):(Ve<5&&(Ve=5),Ve>120&&(Ve=180),a=(It=>{if(It>=60){let go=Math.floor(It/60),hn=It%60;return`${go}m${hn>0?` ${hn}s`:""}`}return`${It}s`})(Ve))}else if(ne&&T==="wait"){let Ve=parseFloat(String(ne).replace(wn,""));isNaN(Ve)?a=String(ne).replace(wn,""):(Ve<10&&(Ve=10),Ve>120&&(Ve=120),a=(It=>{if(It>=60){let go=Math.floor(It/60),hn=It%60;return`${go}m${hn>0?` ${hn}s`:""}`}return`${It}s`})(Ve))}else{let Ve=te.match(hl);if(Ve){let ft=Ve[1].replace(wn,"");T==="invoke"||T==="invoke_sync"||T==="get_progress"?a=ft.substring(0,30):a=T==="search_keyword"||T==="file_map"?ft:V.basename(ft.replace(ra,"/"))}}}let Ee=`${Ss[T]||T}${a?` ${a}`:""}`;if((T!==Lt||a!==lo)&&(Lt=T,lo=a,yield{type:"status",content:`${Ee}`},process.stdout.isTTY)){let R={WebSearch:"Searching",web_search:"Searching",WebScrape:"Reading",web_scrape:"Reading",ReadFile:"Reading",read_file:"Reading",ReadFolder:"Reading",read_folder:"Reading",WriteFile:"Writing",write_file:"Writing",UpdateFile:"Editing",update_file:"Editing",WritePdf:"Creating",write_pdf:"Creating",WriteDocx:"Creating",write_docx:"Creating",SearchKeyword:"Searching",search_keyword:"Searching",CodeSearch:"Searching",code_search:"Searching",FindFile:"Finding File",find_file:"Finding File",Run:"Executing",Ask:"User Input Required",AskUser:"User Input Required",Memory:"Updating Memory",GenerateImage:"Generating",InvokeSync:"Sub-Agent Working",invoke_sync:"Sub-Agent Working",Invoke:"Working",invoke:"Working",GetProgress:"Checking Progress",get_progress:"Checking Progress",Cancel:"Stopping Generalist",cancel:"Stopping Generalist",Await:"Waiting",await:"Waiting",wait:"Waiting",EmergencyRollback:"Rolling the Ball",Answer:"Answering Sub-Agent",answer:"Answering Sub-Agent",Steer:"Steering Sub-Agent",steer:"Steering Sub-Agent",Click:"Clicking",click:"Clicking",Drag:"Dragging",drag:"Dragging",Scroll:"Scrolling",scroll:"Scrolling",KeyboardTyping:"Typing",keyboard_typing:"Typing",KeyPress:"Pressing Key",key_press:"Pressing Key",RecaptureScreen:"Recapturing Screen",recapture_screen:"Recapturing Screen"}[T]||"Working";process.stdout.write(`\x1B]0;${R}...\x07`)}}if(be.length-Qn>800){Qn=be.length;let y=ha(be,!1),T=ws(y),te=T?(T.innerContent||"").trim():"",a=te.split(/[.!?]\s+/).filter(fe=>fe.trim().length>10),Ee=new Set(a),X=a.length>25?(a.length-Ee.size)/a.length:0,R=te.split(/\s+/).filter(fe=>fe.length>0).length,dt=.9,pn=.92,_t=!1;if(s.toLowerCase().includes("google")&&(ee||"").toLowerCase().startsWith("gemma")){let c={low:2048,medium:4096,high:32768,max:65536,xhigh:65536}[d?.toLowerCase()]||16e3;_t=R>c}if(X>dt||_t){yield{type:"status",content:`${X>dt?"Reasoning Loop Detected":"Thinking Budget Exceeded"}. Re-centering...`},Ot=!0,await new Promise(c=>setTimeout(c,3e3));break}let ft=fa(be).trim().split(/[.!?]\s+/).filter(fe=>fe.trim().length>10),It=new Set(ft);if((ft.length>25?(ft.length-It.size)/ft.length:0)>pn){yield{type:"status",content:"Response Loop Detected. Re-centering..."},Ot=!1,Dt=!0,await new Promise(fe=>setTimeout(fe,3e3));break}let hn=y.replace(cl,"").replace(dl,"").replace(fl,"").replace(ul,""),bt=hn.toLowerCase().split(/\s+/).map(fe=>fe.replace(gl,"")).filter(fe=>fe.length>0),en=!1;if(bt.length>=40)for(let fe=1;fe<=15;fe++){let c=Math.max(8,Math.ceil(25/fe));if(bt.length<fe*c)continue;let C=bt.slice(bt.length-fe),L=C.join(" ");if(fe>1&&L===C.slice(0,Math.floor(fe/2)).join(" ").repeat(2).trim())continue;let re=!0;for(let se=1;se<c;se++)if(bt.slice(bt.length-fe*(se+1),bt.length-fe*se).join(" ")!==L){re=!1;break}if(re){en=!0;break}}if(!en){let fe=hn.toLowerCase().replace(ml,"");if(fe.length>=80)for(let c=1;c<=10;c++){let C=Math.max(15,Math.ceil(45/c));if(fe.length<c*C)continue;let L=fe.substring(fe.length-c),re=!0;for(let se=1;se<C;se++)if(fe.substring(fe.length-c*(se+1),fe.length-c*se)!==L){re=!1;break}if(re){en=!0;break}}}if(en){yield{type:"status",content:"Stuttering Detected. Re-centering..."},Ot=!1,Fn=!0,await new Promise(fe=>setTimeout(fe,3e3));break}}let H=Ft(be),ct=Mn(H);for(;ct.length>Tt;){yield*rn();let y=ct[Tt],T=Date.now(),a={Ask:"ask",AskUser:"ask",WebSearch:"web_search",WebScrape:"web_scrape",ReadFile:"view_file",ReadFolder:"read_folder",FindFile:"find_file",find_file:"find_file",findfile:"find_file",WriteFile:"write_file",PatchFile:"update_file",WritePDF:"write_pdf",WriteDoc:"write_docx",Run:"exec_command",SearchKeyword:"search_keyword",CodeSearch:"search_keyword",code_search:"search_keyword",Code_Search:"search_keyword",codesearch:"search_keyword",Memory:"memory",file_map:"file_map",FileMap:"file_map",Chat:"chat",chat:"chat",GenerateImage:"generate_image",generate_image:"generate_image",todo:"todo",Todo:"todo",goal:"todo",Goal:"todo",Invoke:"invoke",InvokeSync:"invoke_sync",getProgress:"get_progress",GetProgress:"get_progress",Await:"await",await:"await",AwaitSubagent:"await",awaitSubagent:"await",Wait:"wait",wait:"wait",Answer:"answer",answer:"answer",AnswerSubagent:"answer",answerSubagent:"answer",Steer:"steer",steer:"steer",SteerSubagent:"steer",steerSubagent:"steer",Cancel:"cancel",cancel:"cancel",Click:"click",click:"click",Drag:"drag",drag:"drag",Scroll:"scroll",scroll:"scroll",KeyboardTyping:"keyboard_typing",keyboard_typing:"keyboard_typing",KeyPress:"key_press",key_press:"key_press",RecaptureScreen:"recapture_screen",recapture_screen:"recapture_screen",EmergencyRollback:"EmergencyRollback"}[y.toolName]||y.toolName,Ee=Ss[a]||y.toolName,X=Kn(a,y.args);yield{type:"status",content:`${Ee}${X?` ${X}`:""}`};let R="";if(a==="click"){let c=D(y.args);R=`\u2714 Clicked ${c.intendedClickText?`: ${c.intendedClickText}`:"Screen"}`}else if(a==="drag"){let c=D(y.args);R=`\u2714 Dragged: Cell ${c.fromGridId||""} \u2192 Cell ${c.toGridId||""}`}else if(a==="scroll"){let c=D(y.args);R=`\u2714 Scrolled: ${c.direction||"down"} (${c.amount||1})`}else if(a==="keyboard_typing"){let c=D(y.args);R=`\u2714 ${c.autoPressEnter?"Entered":"Typed"}: ${c.text?`"${c.text.length>20?c.text.substring(0,20)+"...":c.text}"`:""}`}else if(a==="key_press")R=`\u2714 Pressed Key: ${D(y.args).key||""}`;else if(a==="recapture_screen")R="\u2714 Recaptured Screen";else if(a==="web_search"){let{query:c,limit:C=10,aiMode:L=!1}=D(y.args);R=`${c?"\u2714":"\u2718"} ${L?"AI Search":"Searched"}: ${c?`${c}`:"No Search Query"}${L===!1&&c?` \u2192 ${C}`:""}`}else if(a==="web_scrape"){let c=D(y.args).url||null;R=`${c?"\u2714":"\u2718"} Visited: ${c||"No Source"}`}else if(a==="view_file"){let{path:c,StartLine:C,EndLine:L,start_line:re,end_line:se,startLine:Z,endLine:le}=D(y.args),ke=C||re||Z,J=L||se||le,j=parseInt(ke)||1,F=parseInt(J)||(ke?j+800:800),ue="...",Ge=F,O=(c||"").trim().toLowerCase().replaceAll("\\","/");if(O.startsWith("#skill"))O.startsWith("#skill/global/fluxflow")||O.startsWith("#skills/global/fluxflow")||O.includes("#skill/fluxflow")||O.includes("#skills/fluxflow")?R="\u2714 Read Documentation":R=`\u2714 Read Skill: ${V.basename(c.replaceAll("\\","/"))}`;else{try{let{resolvedPath:he}=ln(c),Se=V.resolve(process.cwd(),he);if(Ce.existsSync(Se)){let Te=Ce.readFileSync(Se,"utf8").split(`
689
+ `).length;ue=Te,!ke&&!J&&Te>800?Ge=Math.min(50,Te):Ge=Math.min(F,Te)}}catch{}let St=(c||"").toLowerCase(),mo=St.endsWith(".pdf"),Ut=St.endsWith(".docx")||St.endsWith(".doc")||St.endsWith(".ppt")||St.endsWith(".pptx")||St.endsWith(".xls")||St.endsWith(".xlsx"),_e=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(St);mo||Ut?R=`${c.length>0?"\u2714":"\u2718"} ${c?`Analyzed: ${V.basename(c)}`:"Analyzed: File Not Found"}`:_e?R=`${c.length>0?"\u2714":"\u2718"} ${c?`Processed: ${V.basename(c)}`:"Processed: File Not Found"}`:R=`${ue!=="..."?"\u2714":"\u2718"} Read: ${c?`${V.basename(c)} \u2192 ${ue!=="..."?`Lines ${j} - ${Ge} of ${ue}`:"File Not Found"}`:"File Not Found"}`}}else if(a==="list_files"||a==="read_folder"){let c=a==="list_files"?"List":"Browsed",C=D(y.args).path||null,L=D(y.args).recurse||1;R=`${C?"\u2714":"\u2718"} ${c}: ${C?`${C==="."?`./${L>1?"*":""}`:`${C.replaceAll("\\","/")}${L>1?`${C.endsWith("/")?"*":"/*"}`:`${C.endsWith("/")?"":"/"}`}`}`:"No Folder Selected"}`}else if(a==="find_file"){let c=D(y.args),C=c.basename||c.name||c.path||c.file||c.query||"";R=`${C?"\u2714":"\u2718"} Located: ${C||"No Query"}`}else if(a==="write_file"||a==="update_file"){let c=a==="write_file"?"Created":"Edited",C=D(y.args),L=C.path||null,se=Object.entries(C).some(([Z,le])=>Z.startsWith("searchContent")&&typeof le=="string"&&le.startsWith("^LINE:"))?"\u1361":":";R=`${L?"\u2714":"\u2718"} ${c}${se} ${L?L.replaceAll("\\","/"):"No File Changes"}`}else if(a==="write_pdf"){let c=D(y.args).path||null;R=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No PDF Generated"}`}else if(a==="write_docx"){let c=D(y.args).path||null;R=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No Docx Generated"}`}else if(a==="file_map"){let c=D(y.args).path;R=`${c?"\u2714":"\u2718"} Indexed: ${c.replaceAll("\\","/")?""+c:"File Not Found"}`}else if(a.toLowerCase()==="search_keyword"||a.toLowerCase()==="todo")R="";else if(a.toLowerCase()==="generate_image"){let{path:c,outputPath:C,output:L}=D(y.args);R=`\u2714 Generated: ${c||C||L||"generated_image.png"}`}else if(a==="invoke_sync"||a==="InvokeSync"){let c=Kn(a,y.args);R=`\u2714 Called Generalist${c?`: ${c}`:""}`}else if(a==="Invoke"||a==="InvokeAsync"||a==="invoke"){let c=Kn(a,y.args);R=`\u2714 Started Generalist${c?`: ${c}`:""}`}else if(a==="get_progress"||a==="GetProgress"){let c=Kn(a,y.args);R=`\u2714 Checked${c?`: ${c}`:""}`}else if(a==="cancel"){let c=Kn(a,y.args);R=`\u{1F6C7} Cancelled${c?`: ${c}`:""}`}else if(a==="steer"||a==="Steer"){let c=Kn(a,y.args);R=`\u2714 Steered${c?`: ${c}`:""}`}else if(a==="EmergencyRollback"){let{method:c}=D(y.args);R=c==="forceRevert"?"":"\u2714 Rollback Point Checked"}else if(a==="await"||a==="Await"||a==="wait"||a==="Wait"){let{time:c,timeout:C,seconds:L,sec:re}=D(y.args),se=parseFloat(L||re||C||c)||45,Z=a==="wait"||a==="Wait"?120:180;se<10&&(se=10),se>Z&&(se=Z);let le=j=>{if(j>=60){let F=Math.floor(j/60),ue=j%60;return`${F}m${ue>0?` ${ue}s`:""}`}return`${j}s`},ke=["Aligning Moon Phase","Contemplating Existence","Staring At Void","Delaying Professionally","Negotiating With Electrons","Touching Grass (virtually)","Panicking Softly","Rethinking Career Choices","Loading Cat Videos","Summoning Braincell #2","Pretending To Be Busy","Waiting For Motivation DLC","Rotating Internal Screaming","Downloading More RAM","Feeding The Hamsters","Gaslighting Scheduler","Performing Dramatic Pause","Buffering Social Energy","Calculating Regret","Reading Terms And Conditions","Becoming Sentient Briefly","Contacting Ancestors"];R=`\u2714 ${ke[Math.floor(Math.random()*ke.length)]} \u2192 ${le(se)}`}else a==="Answer"||a==="answer"?R="\u2714 Resolved Sub-Agent Query":a==="exec_command"||a==="ask"?R="":R=`Executed: ${y.toolName}`;if(yield*rn(),a==="exec_command"){let{command:c}=D(y.args);if(c&&t.systemSettings&&t.systemSettings.allowExternalAccess===!1){let C=[/[a-zA-Z]:[\\\/]/i,/^\//,/\.\.[\\\/]/,/\/etc\//,/\/var\//,/\/root\//,/\/bin\//,/\/usr\//],L=V.resolve(process.cwd()).substring(0,3).toLowerCase(),re=J=>{let j=[],F="",ue=null;for(let Ge=0;Ge<J.length;Ge++){let O=J[Ge];ue?(O===ue&&(ue=null),F+=O):O==='"'||O==="'"?(ue=O,F+=O):O==="&"&&J[Ge+1]==="&"||O==="|"&&J[Ge+1]==="|"?(F.trim()&&(j.push(F.trim()),F=""),Ge++):O===";"||O==="|"||O==="&"?F.trim()&&(j.push(F.trim()),F=""):F+=O}return F.trim()&&j.push(F.trim()),j},se=J=>{let j=[],F="",ue=null;for(let Ge=0;Ge<J.length;Ge++){let O=J[Ge];ue?(O===ue&&(ue=null),F+=O):O==='"'||O==="'"?(ue=O,F+=O):/\s/.test(O)?F&&(j.push(F),F=""):F+=O}return F&&j.push(F),j},Z=J=>{let j=J.replace(/^['"]|['"]$/g,"").trim();return!j||process.platform==="win32"&&/^\/[a-zA-Z0-9?]+$/.test(j)?!1:C.some(F=>{if(F.source==="[a-zA-Z]:[\\\\\\/]"){let ue=j.match(/[a-zA-Z]:[\\\/]/i);return ue&&ue[0].toLowerCase()!==L}return F.test(j)})};if(re(c).some(J=>{let j=se(J);if(j.length===0)return!1;let F=j[0].replace(/^['"]|['"]$/g,"").toLowerCase();if(["echo","printf","write-output"].includes(F)){let Ge=!1;return j.some(O=>{let wt=O.replace(/^['"]|['"]$/g,"");if(wt===">"||wt===">>"||wt==="<")return Ge=!0,!1;if(wt.startsWith(">")||wt.startsWith("<")){let St=wt.replace(/^[><]+/,"");return Z(St)}return Ge?(Ge=!1,Z(O)):!1})}return j.some(Ge=>Z(Ge))})){let J='Access Denied. Prohibited from accessing external directories while "External Workspace Access" is disabled.';t.onExecStart&&t.onExecStart(c||"No Command"),yield{type:"exec_start"},await new Promise(j=>setTimeout(j,50)),t.onExecChunk&&t.onExecChunk(`ERROR: ${J}`),await new Promise(j=>setTimeout(j,50)),t.onExecEnd&&t.onExecEnd(),je.push({role:"user",text:`[ACTION RESULT]: ERROR: ${J}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${J}`},Tt++;continue}}t.onExecStart&&t.onExecStart(c||"No Command"),yield{type:"exec_start"}}let dt=D(y.args),pn=dt.path||dt.targetPath||null;if(pn){let c=t.systemSettings&&t.systemSettings.allowExternalAccess===!1,C=V.resolve(pn),L=V.resolve(process.cwd());if(c&&!C.startsWith(L)){let re="Access Denied. You are not allowed to access files outside the current workspace.";if(a==="write_file"||a==="update_file"){let Z=`\u2718 ${a==="write_file"?"Write Canceled":"Edit Canceled"}: ${dt.path||"..."}`,le=115;process.stdout.isTTY&&(le=process.stdout.columns-5||120);let ke=Math.min(Z.length+4,le),J=`${Z.padEnd(ke-2).substring(0,ke-2)}`;yield{type:"visual_feedback",content:Rt(`${Oe?`
690
+ `:""}${J}
691
+ `)},Oe=!1}je.push({role:"user",text:`[ACTION RESULT]: ERROR: ${re}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${re}`},Tt++;continue}}if(t.onToolApproval){let c=t.systemSettings||{},C=c.autoExec,L=!1,re="";if(a==="view_file"){let Z=D(y.args);if(re=Z.path||Z.targetPath||Z.file||"",re){let le=c.alwaysAskFiles||".env, .env.*, *.env";Gs(re,le)&&(L=!0)}}if(a==="write_file"||a==="update_file"||a==="exec_command"||L){let Z=null,le=!1,ke=!1,J=!1,j=!1;if(L)le=!0,Z=null;else if(a==="exec_command"){let{command:_e}=D(y.args),he=(_e||"").trim(),Pe=($e=>{let ot=[],it="",He=null;for(let Ae=0;Ae<$e.length;Ae++){let K=$e[Ae];He?(K===He&&(He=null),it+=K):K==='"'||K==="'"?(He=K,it+=K):K==="&"&&$e[Ae+1]==="&"||K==="|"&&$e[Ae+1]==="|"?(it.trim()&&(ot.push(it.trim()),it=""),Ae++):K===";"||K==="|"||K==="&"?it.trim()&&(ot.push(it.trim()),it=""):it+=K}return it.trim()&&ot.push(it.trim()),ot.length>0?ot:[$e]})(he),Te=($e,ot)=>{if(!ot)return!1;let it=ot.split(",").map(Ae=>Ae.trim().toLowerCase()).filter(Boolean),He=$e.toLowerCase();return it.some(Ae=>{if(He===Ae)return!0;if(He.startsWith(Ae)){let K=He.charAt(Ae.length);return/\s|[;&|/]/.test(K)}return!1})},ze=Pe.some($e=>Te($e,c.alwaysAskCommands)),Gt=Pe.some($e=>Te($e,c.autoDisallowCommands)),qe=Pe.length>0&&Pe.every($e=>Te($e,c.autoApproveCommands)||c.autoApproveGit&&/^git\s+commit\b/i.test($e));if(Gt)Z="deny";else if(c.networkAccess===!1){let ot=he.trim().replace(/\s+/g," ").replace(/^['"]+|['"]+$/g,"").toLowerCase().split(" "),He=ot[0].split("/").pop().split("\\").pop().replace(/\.exe$/,""),Ae=new Set(["curl","wget","httpie","xh","ssh","scp","sftp","rsync","ftp","lftp","tftp","telnet","nc","netcat","socat","ping","traceroute","tracert","dig","nslookup","host","whois","nmap","docker","podman","kubectl","helm","gcloud","aws","az","terraform","ansible-playbook","nix","nix-env","apt","apt-get","dpkg","yum","dnf","pacman","zypper","brew","apk","choco","scoop","conda","mamba","aria2c","axel","smbclient","lynx","w3m","links","elinks","heroku","netlify","vercel","firebase","supabase","wrangler","flyctl","powershell","pwsh","certutil","bitsadmin","cloudflared","ngrok","tailscale","zerotier","rclone"]),K=!1;Ae.has(He)&&(K=!0);let Mt=to=>ot.slice(1).some(xn=>to.includes(xn)),yn=to=>{let xn=ot.findIndex(An=>to.includes(An)),Un=ot.findIndex(An=>["run","exec","test"].includes(An));return xn!==-1&&!(Un!==-1&&Un<xn)};He==="git"&&Mt(["clone","pull","push","fetch"])&&(K=!0),He==="go"&&Mt(["get","install"])&&(K=!0),He==="npm"&&yn(["install","i","update","add"])&&(K=!0),He==="yarn"&&yn(["add","install","upgrade"])&&(K=!0),He==="pnpm"&&yn(["add","install","update"])&&(K=!0),He==="bun"&&yn(["add","install","update"])&&(K=!0),He==="deno"&&Mt(["install","add"])&&(K=!0),He==="pip"&&Mt(["install","download"])&&(K=!0),He==="pip3"&&Mt(["install","download"])&&(K=!0),He==="cargo"&&Mt(["install","add"])&&(K=!0),["bash","sh","zsh","fish"].includes(He)&&Mt(["-c"])&&(K=!0),He==="cmd"&&Mt(["/c"])&&(K=!0),K&&(Z="deny",J=!0)}!Z&&ze?le=!0:!Z&&!le&&(qe||c.autoApproveGit&&/^git\s+commit\b/i.test(he))&&(Z="allow"),!le&&!Z&&C&&(Z="allow")}else if(a==="write_file"||a==="update_file"){let _e=!1;if(a==="write_file"&&c.overwriteProtection!==!1&&C)try{let{path:he}=D(y.args);he&&Ce.existsSync(V.resolve(process.cwd(),he))&&(_e=!0,j=!0)}catch{}C&&!_e&&(Z="allow")}let F=Z,ue="";Z==="deny"&&(J?ue="network":ke?ue="settings":ue="prohibited");let Ge=!1,O="",wt=[],St=0,mo=!1,Ut="";if(!F&&t.onToolApproval)try{let _e=await t.onToolApproval(a,y.args,{checkOnly:!0});j&&_e==="allow"||(_e==="allow"||_e==="deny")&&(F=_e,F==="deny"&&(ue="user"))}catch{}if(!F){if(!j&&(a==="write_file"||a==="update_file"))try{let Se=D(y.args),{path:Pe}=Se;if(Pe){let{resolvedPath:Te}=ln(Pe);Pe=Te;let ze=V.resolve(process.cwd(),Pe),Gt=Ae=>Ae?Ae.toLowerCase().replace(/\\/g,"/").replace(/^[a-z]:/,K=>K.toUpperCase()):"",qe=Gt(ze),$e="",ot=!1,it=await Hn(),He=Gt(it?.file_focused);if(it&&He===qe&&it.full_content?($e=it.full_content,ot=!0):Ce.existsSync(ze)&&($e=Ce.readFileSync(ze,"utf8"),ot=!0),O=$e,await oi.recordFileChange(ze,$e),ot){let Ae=$e;if(a==="write_file"){let K=Se.content||Se.newContent||"";Ae=K.endsWith(`
691
692
  `)?K:K+`
692
- `,Ut=Ae}else{let{patchPairs:K,allowMultiple:It,error:xn}=ji(Se);if(xn){let Ht=`[ACTION RESULT]: ERROR: ${xn}`;He.push({role:"user",text:Ht}),await Ct("toolFailure"),t.onToolResult&&t.onToolResult("failure",a),yield{type:"tool_result",content:Ht,toolName:a},Tt++;continue}let to=Se.allowMultiple!==void 0?Se.allowMultiple===!0||String(Se.allowMultiple).toLowerCase()==="true":It;St=K.length;let wn=js(Pe,K,{allowMultiple:to});Ae=wn.content,Ut=Ae,bt=wn.results;let Un=bt.filter(Ht=>Ht.success),An=bt.filter(Ht=>!Ht.success);if(Un.length===0){let Ht=`[ACTION RESULT]: ERROR: Failed to apply patches to [${J.basename(ze)}].
693
+ `,Ut=Ae}else{let{patchPairs:K,allowMultiple:Mt,error:yn}=ji(Se);if(yn){let Ht=`[ACTION RESULT]: ERROR: ${yn}`;je.push({role:"user",text:Ht}),await vt("toolFailure"),t.onToolResult&&t.onToolResult("failure",a),yield{type:"tool_result",content:Ht,toolName:a},Tt++;continue}let to=Se.allowMultiple!==void 0?Se.allowMultiple===!0||String(Se.allowMultiple).toLowerCase()==="true":Mt;St=K.length;let xn=js($e,K,{allowMultiple:to});Ae=xn.content,Ut=Ae,wt=xn.results;let Un=wt.filter(Ht=>Ht.success),An=wt.filter(Ht=>!Ht.success);if(Un.length===0){let Ht=`[ACTION RESULT]: ERROR: Failed to apply patches to [${V.basename(ze)}].
693
694
  ${An.map(Cn=>` \u2022 ${Cn.error}`).join(`
694
- `)}`,qo=`\u2714 Edited: ${J.basename(ze.replaceAll("\\","/"))}`,po=115;process.stdout.isTTY&&(po=process.stdout.columns-5||120);let Li=Math.min(qo.length+4,po),an=`${qo.padEnd(Li-2).substring(0,Li-2)}`;yield{type:"visual_feedback",content:Pt(`${je?`
695
- `:""}${an}`)},je=!1,He.push({role:"user",text:Ht}),await Ct("toolFailure"),t.onToolResult&&t.onToolResult("failure",a),yield{type:"tool_result",content:Ht,toolName:a},Tt++;continue}}yield{type:"status",content:`Opening Diff in IDE: ${J.basename(ze)}`},Qi(ze,Pe,Ae),Ue=!0,await new Promise(K=>setTimeout(K,50))}else if(a==="write_file"){let Ae=Se.content||Se.newContent||"",K=Ae.endsWith(`
695
+ `)}`,qo=`\u2714 Edited: ${V.basename(ze.replaceAll("\\","/"))}`,po=115;process.stdout.isTTY&&(po=process.stdout.columns-5||120);let Li=Math.min(qo.length+4,po),an=`${qo.padEnd(Li-2).substring(0,Li-2)}`;yield{type:"visual_feedback",content:Rt(`${Oe?`
696
+ `:""}${an}`)},Oe=!1,je.push({role:"user",text:Ht}),await vt("toolFailure"),t.onToolResult&&t.onToolResult("failure",a),yield{type:"tool_result",content:Ht,toolName:a},Tt++;continue}}yield{type:"status",content:`Opening Diff in IDE: ${V.basename(ze)}`},Qi(ze,$e,Ae),Ge=!0,await new Promise(K=>setTimeout(K,50))}else if(a==="write_file"){let Ae=Se.content||Se.newContent||"",K=Ae.endsWith(`
696
697
  `)?Ae:Ae+`
697
- `;Ut=K,Ce.existsSync(ze)||(mo=!0,Ce.mkdirSync(J.dirname(ze),{recursive:!0}),Ce.writeFileSync(ze,"","utf8")),yield{type:"status",content:`Opening New File Diff in IDE: ${J.basename(ze)}`},Qi(ze,"",K),Ue=!0,await new Promise(It=>setTimeout(It,50))}}}catch(Se){console.error("Simulation/Diff Error:",Se)}let _e=null;Ji(Se=>{_e=Se});let pe=t.onToolApproval;if(F=await new Promise(async Se=>{let Me=setInterval(()=>{if(_e){let Te=t.onIDEApproval||Do&&Do.onIDEApproval;Te&&Te(_e),clearInterval(Me),Se(_e)}},100);try{let Te=await pe(a,y.args,{isOverwritePrompt:j});clearInterval(Me),Se(Te)}catch{clearInterval(Me),Se("deny")}}),Ji(null),a==="write_file"||a==="update_file"){let Se=D(y.args),{path:Me}=Se;if(Me){let{resolvedPath:Te}=ln(Me);Me=Te;let ze=J.resolve(process.cwd(),Me);if(hr(ze,F),F==="deny"&&mo&&Ce.existsSync(ze))try{Ce.unlinkSync(ze)}catch{}}}F==="deny"&&(ue="user")}if(F==="allow"&&Ue&&ro()){let _e=D(y.args),{path:pe}=_e,{resolvedPath:Se,isTildeResolved:Me}=ln(pe);pe=Se;let Te=J.resolve(process.cwd(),pe),ze=Ke=>Ke?J.resolve(Ke).replace(/\\/g,"/").toLowerCase():"",Gt=await Hn(),qe="";if(Gt&&Gt.file_focused&&ze(Gt.file_focused)===ze(Te)&&Gt.full_content&&(qe=Gt.full_content),!qe&&Ce.existsSync(Te)){let Ke=Ce.readFileSync(Te,"utf8");Ke&&(qe=Ke)}!qe&&Ut&&(qe=Ut),(qe||mo)&&Ce.writeFileSync(Te,qe,"utf8");let Pe=qe.split(/\r?\n/),ot=Pe.length,it=Buffer.byteLength(qe,"utf8"),Ge="";O&&(Ge=`Old File contents:
698
- ${O.split(/\r?\n/).map((Ze,tn)=>`${tn+1} | ${Ze}`).join(`
698
+ `;Ut=K,Ce.existsSync(ze)||(mo=!0,Ce.mkdirSync(V.dirname(ze),{recursive:!0}),Ce.writeFileSync(ze,"","utf8")),yield{type:"status",content:`Opening New File Diff in IDE: ${V.basename(ze)}`},Qi(ze,"",K),Ge=!0,await new Promise(Mt=>setTimeout(Mt,50))}}}catch(Se){console.error("Simulation/Diff Error:",Se)}let _e=null;Ji(Se=>{_e=Se});let he=t.onToolApproval;if(F=await new Promise(async Se=>{let Pe=setInterval(()=>{if(_e){let Te=t.onIDEApproval||Do&&Do.onIDEApproval;Te&&Te(_e),clearInterval(Pe),Se(_e)}},100);try{let Te=await he(a,y.args,{isOverwritePrompt:j});clearInterval(Pe),Se(Te)}catch{clearInterval(Pe),Se("deny")}}),Ji(null),a==="write_file"||a==="update_file"){let Se=D(y.args),{path:Pe}=Se;if(Pe){let{resolvedPath:Te}=ln(Pe);Pe=Te;let ze=V.resolve(process.cwd(),Pe);if(hr(ze,F),F==="deny"&&mo&&Ce.existsSync(ze))try{Ce.unlinkSync(ze)}catch{}}}F==="deny"&&(ue="user")}if(F==="allow"&&Ge&&ro()){let _e=D(y.args),{path:he}=_e,{resolvedPath:Se,isTildeResolved:Pe}=ln(he);he=Se;let Te=V.resolve(process.cwd(),he),ze=Ke=>Ke?V.resolve(Ke).replace(/\\/g,"/").toLowerCase():"",Gt=await Hn(),qe="";if(Gt&&Gt.file_focused&&ze(Gt.file_focused)===ze(Te)&&Gt.full_content&&(qe=Gt.full_content),!qe&&Ce.existsSync(Te)){let Ke=Ce.readFileSync(Te,"utf8");Ke&&(qe=Ke)}!qe&&Ut&&(qe=Ut),(qe||mo)&&Ce.writeFileSync(Te,qe,"utf8");let $e=qe.split(/\r?\n/),ot=$e.length,it=Buffer.byteLength(qe,"utf8"),He="";O&&(He=`Old File contents:
699
+ ${O.split(/\r?\n/).map((et,tn)=>`${tn+1} | ${et}`).join(`
699
700
  `)}
700
701
 
701
- `);let Ae="";if(ot<=100)Ae=Pe.join(`
702
- `);else{let Ke=Pe.slice(0,50).join(`
703
- `),Ze=Pe.slice(-50).join(`
702
+ `);let Ae="";if(ot<=100)Ae=$e.join(`
703
+ `);else{let Ke=$e.slice(0,50).join(`
704
+ `),et=$e.slice(-50).join(`
704
705
  `);Ae=`${Ke}
705
706
 
706
707
  ... [${ot-100} lines truncated for history stability] ...
707
708
 
708
- ${Ze}`}let K="";if(a==="update_file"){let Ke=Vs(O,qe,bt,12,t?.compressToolResults||Do?.systemSettings?.compressToolResults),{patchPairs:Ze}=ji(D(y.args)),tn=Ze?.length||St||1,At=0,jt=0,vn=[];Ze&&Ze.length>0?Ze.forEach((En,Oi)=>{let Xo=En.replace||"",nn=En.new||"",Di=Xo.trim(),xo=nn.trim(),Da=!!Ut&&qe===Ut,Na=xo?qe.includes(nn)||qe.includes(xo):!0,Fa=nn?O.includes(nn)||!!xo&&O.includes(xo):!1,Ba=Di?qe.includes(Xo)||qe.includes(Di):!1;Da||!!nn&&Na&&(!Fa||!Ba||Di===xo)?At++:(jt++,vn.push(` \u2022 Block ${Oi+1}: not applied (reverted or rejected in IDE).`))}):At=St||0;let bn=0;if(Ut&&qe!==Ut){let En=al("","",Ut||"",qe||"","","",{context:0});if(En&&En.hunks)for(let Oi of En.hunks){let Xo=Oi.lines.filter(nn=>nn.startsWith("+")).map(nn=>nn.slice(1).trim()).filter(Boolean);for(let nn of Xo)O.includes(nn)||bn++}}let ho=[`[${At}/${tn}] applied`];jt>0&&ho.push(`${jt} rejected by user`),bn>0&&ho.push(`${bn} manual ${bn===1?"modification":"modifications"} by user`);let no=ho.join(", "),Rn=vn.length>0?`
709
+ ${et}`}let K="";if(a==="update_file"){let Ke=Vs(O,qe,wt,12,t?.compressToolResults||Do?.systemSettings?.compressToolResults),{patchPairs:et}=ji(D(y.args)),tn=et?.length||St||1,Ct=0,jt=0,vn=[];et&&et.length>0?et.forEach((En,Oi)=>{let Xo=En.replace||"",nn=En.new||"",Di=Xo.trim(),xo=nn.trim(),Da=!!Ut&&qe===Ut,Na=xo?qe.includes(nn)||qe.includes(xo):!0,Fa=nn?O.includes(nn)||!!xo&&O.includes(xo):!1,Ba=Di?qe.includes(Xo)||qe.includes(Di):!1;Da||!!nn&&Na&&(!Fa||!Ba||Di===xo)?Ct++:(jt++,vn.push(` \u2022 Block ${Oi+1}: not applied (reverted or rejected in IDE).`))}):Ct=St||0;let bn=0;if(Ut&&qe!==Ut){let En=al("","",Ut||"",qe||"","","",{context:0});if(En&&En.hunks)for(let Oi of En.hunks){let Xo=Oi.lines.filter(nn=>nn.startsWith("+")).map(nn=>nn.slice(1).trim()).filter(Boolean);for(let nn of Xo)O.includes(nn)||bn++}}let ho=[`[${Ct}/${tn}] applied`];jt>0&&ho.push(`${jt} rejected by user`),bn>0&&ho.push(`${bn} manual ${bn===1?"modification":"modifications"} by user`);let no=ho.join(", "),Rn=vn.length>0?`
709
710
 
710
711
  User Review Details:
711
712
  ${vn.join(`
712
- `)}`:"";K=`File [${pe}] updated via IDE Companion. ${no}.${Rn}
713
+ `)}`:"";K=`File [${he}] updated via IDE Companion. ${no}.${Rn}
713
714
 
714
- ${Ke}${Me?`
715
+ ${Ke}${Pe?`
715
716
 
716
- [Note: '~' resolved to user home directory. To target literal '~' in current directory, escape it as '\\~']`:""}`;let{added:Yo,removed:yo}=Ks(O,qe);(Yo>0||yo>0)&&await Ui({added:Yo,removed:yo,file:pe})}else{let Ke=qe.split(/\r?\n/),Ze=Ke.length,tn=Buffer.byteLength(qe,"utf8"),At="",jt=c?.overwriteProtection!==!1;if(O){let no=O.split(/\r?\n/);if(!jt)At="";else if(no.length<=50)At=`Old File contents:
717
+ [Note: '~' resolved to user home directory. To target literal '~' in current directory, escape it as '\\~']`:""}`;let{added:Yo,removed:yo}=Ks(O,qe);(Yo>0||yo>0)&&await Ui({added:Yo,removed:yo,file:he})}else{let Ke=qe.split(/\r?\n/),et=Ke.length,tn=Buffer.byteLength(qe,"utf8"),Ct="",jt=c?.overwriteProtection!==!1;if(O){let no=O.split(/\r?\n/);if(!jt)Ct="";else if(no.length<=50)Ct=`Old File contents:
717
718
  ${no.map((Rn,oo)=>`${oo+1} | ${Rn}`).join(`
718
719
  `)}
719
720
 
720
- `;else{let Rn=J.parse(Te),oo=J.join(Bs,"OverwriteBackups");if(!Ce.existsSync(oo))try{Ce.mkdirSync(oo,{recursive:!0})}catch{}let Yo=`${Rn.name}-old-${Date.now()}${Rn.ext}.bak`,yo=J.join(oo,Yo);try{Ce.writeFileSync(yo,O,"utf8")}catch{}At=`Old File contents:
721
- - Renamed old file as ${yo} and written requested content in ${pe}. For reversal use Run
721
+ `;else{let Rn=V.parse(Te),oo=V.join(Bs,"OverwriteBackups");if(!Ce.existsSync(oo))try{Ce.mkdirSync(oo,{recursive:!0})}catch{}let Yo=`${Rn.name}-old-${Date.now()}${Rn.ext}.bak`,yo=V.join(oo,Yo);try{Ce.writeFileSync(yo,O,"utf8")}catch{}Ct=`Old File contents:
722
+ - Renamed old file as ${yo} and written requested content in ${he}. For reversal use Run
722
723
 
723
- `}}let vn="";if(Ze<=690)vn=Ke.join(`
724
+ `}}let vn="";if(et<=690)vn=Ke.join(`
724
725
  `);else{let no=Ke.slice(0,300).join(`
725
726
  `),Rn=Ke.slice(-300).join(`
726
727
  `);vn=`${no}
727
728
 
728
- ... [${Ze-100} lines truncated] ...
729
+ ... [${et-100} lines truncated] ...
729
730
 
730
- ${Rn}`}let bn=Me?`
731
+ ${Rn}`}let bn=Pe?`
731
732
 
732
- [Note: '~' resolved to user home directory. To target literal '~' in current directory, escape it as '\\~']`:"";K=`File [${pe}] saved via IDE Companion (May have user edits).
733
- - Stats: [${Ze} lines, ${(tn/1024).toFixed(1)} KB]
734
- ${At}- Content Preview:
733
+ [Note: '~' resolved to user home directory. To target literal '~' in current directory, escape it as '\\~']`:"";K=`File [${he}] saved via IDE Companion (May have user edits).
734
+ - Stats: [${et} lines, ${(tn/1024).toFixed(1)} KB]
735
+ ${Ct}- Content Preview:
735
736
 
736
- ${vn}${bn}`;let ho=O?O.split(/\r?\n/).length:0;await Ui({added:Ze,removed:ho,file:pe})}let It=a==="write_file"?"Created":"Edited",xn=D(y.args),wn=Object.entries(xn).some(([Ke,Ze])=>Ke.startsWith("searchContent")&&typeof Ze=="string"&&Ze.startsWith("^LINE:"))?"\u1361":":",Un=`${pe?"\u2714":"\u2718"} ${It}${wn} ${pe?pe.replaceAll("\\","/"):"No File Changes"}`,An=115;process.stdout.isTTY&&(An=process.stdout.columns-5||120);let Ht=Math.min(Un.length+4,An),qo=`${Un.padEnd(Ht-2).substring(0,Ht-2)}`;yield{type:"visual_feedback",content:Pt(`${je?`
737
- `:""}${qo}`)},je=!1;let po=Date.now();Nn=po,yield{type:"tool_time",content:po-T};let an=(K||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");an.includes("[[VERIFIED]]")&&(an=an.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to conserve context.
738
- `));let Cn;if(a==="write_file"&&!an.startsWith("ERROR:")){let Ke=an.replace(/^\[\[SAME\]\]\s*\r?\n?/,""),Ze=Ke.match(/\n\s*(\[Note:\s*'~'\s*resolved\s*to\s*user\s*home\s*directory[\s\S]*?\])\s*$/),tn=Ze?`
737
+ ${vn}${bn}`;let ho=O?O.split(/\r?\n/).length:0;await Ui({added:et,removed:ho,file:he})}let Mt=a==="write_file"?"Created":"Edited",yn=D(y.args),xn=Object.entries(yn).some(([Ke,et])=>Ke.startsWith("searchContent")&&typeof et=="string"&&et.startsWith("^LINE:"))?"\u1361":":",Un=`${he?"\u2714":"\u2718"} ${Mt}${xn} ${he?he.replaceAll("\\","/"):"No File Changes"}`,An=115;process.stdout.isTTY&&(An=process.stdout.columns-5||120);let Ht=Math.min(Un.length+4,An),qo=`${Un.padEnd(Ht-2).substring(0,Ht-2)}`;yield{type:"visual_feedback",content:Rt(`${Oe?`
738
+ `:""}${qo}`)},Oe=!1;let po=Date.now();Nn=po,yield{type:"tool_time",content:po-T};let an=(K||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");an.includes("[[VERIFIED]]")&&(an=an.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to conserve context.
739
+ `));let Cn;if(a==="write_file"&&!an.startsWith("ERROR:")){let Ke=an.replace(/^\[\[SAME\]\]\s*\r?\n?/,""),et=Ke.match(/\n\s*(\[Note:\s*'~'\s*resolved\s*to\s*user\s*home\s*directory[\s\S]*?\])\s*$/),tn=et?`
739
740
 
740
- ${Ze[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(Ke)){let At=Ke.search(/^- Content Preview:/m);Cn=`[ACTION RESULT]: ${At!==-1?Ke.slice(0,At).trimEnd():Ke}
741
+ ${et[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(Ke)){let Ct=Ke.search(/^- Content Preview:/m);Cn=`[ACTION RESULT]: ${Ct!==-1?Ke.slice(0,Ct).trimEnd():Ke}
741
742
 
742
- [Old file content for reversal reference. Replaced with new write request]${tn}`}else{let At=Ke.split(/\r?\n/),jt=At.filter(bn=>bn.startsWith("File ")||bn.trim().startsWith("- Stats:"));Cn=`[ACTION RESULT]: ${jt.length>0?jt.join(`
743
- `):At.slice(0,2).join(`
744
- `)}${tn}`}}else if(an.startsWith("[[SAME]]")){let Ze=an.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),tn=Ze.filter(jt=>jt.startsWith("File ")||jt.trim().startsWith("- Stats:"));Cn=`[ACTION RESULT]: ${tn.length>0?tn.join(`
745
- `):Ze.slice(0,2).join(`
746
- `)}`}else Cn=`[ACTION RESULT]: ${an}`;He.push({role:"user",text:Cn}),mn=!0,await Ct("toolSuccess"),t.onToolResult&&t.onToolResult("success",a),yield{type:"tool_result",content:K,aiContent:Cn,toolName:a},Tt++;continue}if(F==="deny"){let _e=`Permission Denied: Prohibited ${a==="exec_command"?"Command":"file edit"}.`;if(L?_e=`User denied reading ${J.basename(re||".env")}`:j&&ue==="user"?_e="User rejected file over-write. If needed AskUser how to proceed":ue==="user"?_e="Permission Denied by User":ue==="settings"?_e="Permission Denied by User Policy":ue==="network"?_e="Permission Denied: Sandbox Network Access Disabled by User Policy.":ue==="prohibited"&&a==="exec_command"&&(_e="Permission Denied: Prohibited Command in User Policy"),a==="view_file"){let pe=`\u2718 Read Denied: ${D(y.args).path?.replaceAll("\\","/")||".env"}`,Se=115;process.stdout.isTTY&&(Se=process.stdout.columns-5||120);let Me=Math.min(pe.length+4,Se),Te=`${pe.padEnd(Me-2).substring(0,Me-2)}`;yield{type:"visual_feedback",content:Pt(`${je?`
743
+ [Old file content for reversal reference. Replaced with new write request]${tn}`}else{let Ct=Ke.split(/\r?\n/),jt=Ct.filter(bn=>bn.startsWith("File ")||bn.trim().startsWith("- Stats:"));Cn=`[ACTION RESULT]: ${jt.length>0?jt.join(`
744
+ `):Ct.slice(0,2).join(`
745
+ `)}${tn}`}}else if(an.startsWith("[[SAME]]")){let et=an.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),tn=et.filter(jt=>jt.startsWith("File ")||jt.trim().startsWith("- Stats:"));Cn=`[ACTION RESULT]: ${tn.length>0?tn.join(`
746
+ `):et.slice(0,2).join(`
747
+ `)}`}else Cn=`[ACTION RESULT]: ${an}`;je.push({role:"user",text:Cn}),Sn=!0,await vt("toolSuccess"),t.onToolResult&&t.onToolResult("success",a),yield{type:"tool_result",content:K,aiContent:Cn,toolName:a},Tt++;continue}if(F==="deny"){let _e=`Permission Denied: Prohibited ${a==="exec_command"?"Command":"file edit"}.`;if(L?_e=`User denied reading ${V.basename(re||".env")}`:j&&ue==="user"?_e="User rejected file over-write. If needed AskUser how to proceed":ue==="user"?_e="Permission Denied by User":ue==="settings"?_e="Permission Denied by User Policy":ue==="network"?_e="Permission Denied: Sandbox Network Access Disabled by User Policy.":ue==="prohibited"&&a==="exec_command"&&(_e="Permission Denied: Prohibited Command in User Policy"),a==="view_file"){let he=`\u2718 Read Denied: ${D(y.args).path?.replaceAll("\\","/")||".env"}`,Se=115;process.stdout.isTTY&&(Se=process.stdout.columns-5||120);let Pe=Math.min(he.length+4,Se),Te=`${he.padEnd(Pe-2).substring(0,Pe-2)}`;yield{type:"visual_feedback",content:Rt(`${Oe?`
747
748
  `:""}${Te}
748
- `)},je=!1}else if(a==="write_file"||a==="update_file"){let Se=`\u2718 ${a==="write_file"?"Write Cancelled":"Edit Denied"}: ${D(y.args).path.replaceAll("\\","/")||"..."}`,Me=115;process.stdout.isTTY&&(Me=process.stdout.columns-5||120);let Te=Math.min(Se.length+4,Me),ze=`${Se.padEnd(Te-2).substring(0,Te-2)}`,Gt=` ${" ".repeat(Te)} `;yield{type:"visual_feedback",content:Pt(`${je?`
749
+ `)},Oe=!1}else if(a==="write_file"||a==="update_file"){let Se=`\u2718 ${a==="write_file"?"Write Cancelled":"Edit Denied"}: ${D(y.args).path.replaceAll("\\","/")||"..."}`,Pe=115;process.stdout.isTTY&&(Pe=process.stdout.columns-5||120);let Te=Math.min(Se.length+4,Pe),ze=`${Se.padEnd(Te-2).substring(0,Te-2)}`,Gt=` ${" ".repeat(Te)} `;yield{type:"visual_feedback",content:Rt(`${Oe?`
749
750
  `:""}${ze}
750
- `)},je=!1}a==="exec_command"&&(await new Promise(pe=>setTimeout(pe,50)),t.onExecChunk&&t.onExecChunk(`ERROR: ${_e}`),await new Promise(pe=>setTimeout(pe,50)),t.onExecEnd&&t.onExecEnd()),He.push({role:"user",text:`[ACTION RESULT]: DENIED: ${_e}`}),yield{type:"tool_result",content:`[ACTION RESULT]: DENIED: ${_e}`},await Ct("toolDenied"),t.onToolResult&&t.onToolResult("denied",a),Tt++;continue}}}if(R){let c=115;process.stdout.isTTY&&(c=process.stdout.columns-5||120);let C=!1,L=Math.min(R.length+4,c),re=`${R.padEnd(L-2).substring(0,L-2)}`;yield{type:"visual_feedback",content:Pt(`${je?`
751
+ `)},Oe=!1}a==="exec_command"&&(await new Promise(he=>setTimeout(he,50)),t.onExecChunk&&t.onExecChunk(`ERROR: ${_e}`),await new Promise(he=>setTimeout(he,50)),t.onExecEnd&&t.onExecEnd()),je.push({role:"user",text:`[ACTION RESULT]: DENIED: ${_e}`}),yield{type:"tool_result",content:`[ACTION RESULT]: DENIED: ${_e}`},await vt("toolDenied"),t.onToolResult&&t.onToolResult("denied",a),Tt++;continue}}}if(R){let c=115;process.stdout.isTTY&&(c=process.stdout.columns-5||120);let C=!1,L=Math.min(R.length+4,c),re=`${R.padEnd(L-2).substring(0,L-2)}`;yield{type:"visual_feedback",content:Rt(`${Oe?`
751
752
  `:""}${re}${R.includes("\u2714")&&(R.includes("Created")||R.includes("Edited"))?"":`${C?"":`
752
- `}`}`)},je=!1}if(Nn>0){let c=Date.now()-Nn,C=Math.max(0,1e3-c);C>0&&await new Promise(L=>setTimeout(L,C))}let Et={chatId:g,history:n,onChunk:c=>t.onExecChunk?t.onExecChunk(c):null,onAskUser:t.onAskUser,systemSettings:t.systemSettings,mode:l,isMultiModal:tt(ee),onVisualFeedback:t.onVisualFeedback,onSubagentUpdate:t.onSubagentUpdate,onTokenChunk:t.onTokenChunk,modelName:ee,aiProvider:t.aiProvider,apiKey:t.apiKey,onUsage:t.onUsage};if(a==="write_file"||a==="update_file")try{let{path:c}=D(y.args);if(c){let C=J.resolve(process.cwd(),c),L=await Hn();L&&L.file_focused===C&&L.full_content&&(Et.forcedContent=L.full_content)}}catch{}ce.push(a);let ne=await us(a,y.args,Et);if((a==="write_file"||a==="update_file")&&!ne.startsWith("ERROR:")){let{path:c}=D(y.args);if(c){let{resolvedPath:C}=ln(c),L=J.resolve(process.cwd(),C);pr(L)}}process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07");let Ve=Date.now();Nn=Ve,yield{type:"tool_time",content:Ve-T},Dn=Ve;let ft=null;if(typeof ne=="object"&&ne.binaryPart&&(ft=ne.binaryPart,ne=ne.text),a==="search_keyword"){let{keyword:c,path:C}=D(y.args),L=typeof ne=="string"&&ne.startsWith("[GLOB]");L&&(ne=ne.slice(6).trimStart());let re=typeof ne=="string"&&ne.startsWith("[DIR]");re&&(ne=ne.slice(5).trimStart());let se=0;if(ne){let O=ne.match(/Found (\d+) match/i);O&&(se=parseInt(O[1]))}let Z=(C||"").trim().toLowerCase().replaceAll("\\","/"),le=Z==="#doc"||Z==="#docs"||Z==="#documentation"||Z.includes("#skill/global/fluxflow")||Z.includes("#skill/fluxflow")||Z.includes("#skills/fluxflow")||Z.includes("#skills/global/fluxflow"),ke,X=115;process.stdout.isTTY&&(X=process.stdout.columns-5||120);let j=Math.max(10,(X+5)/3),F=Math.max(10,(X+5)/4);if(le)ke=`${c?"\u2714":"\u2718"} Searched Documentation`;else{let O=C?C.replace(/[\/\\]+$/,""):null,bt=O&&O!=="."?`${L?C:re?`${O}/*`:O}`:"./",St=bt.length>F?`${bt.slice(0,F)}...`:bt;ke=`${c?"\u2714":"\u2718"} Searched: "${c?c.length>X/3?`${c.slice(0,j)}...`:c:""}" in "${St.replaceAll("\\","/")}" \u2192 ${se} Match${se===1?"":"es"}`}let ue=Math.min(ke.length+4,X),Ue=`${ke.padEnd(ue-2).substring(0,ue-2)}`;yield{type:"visual_feedback",content:Pt(`${je?`
753
- `:""}${Ue}
754
- `)},je=!1}if(a==="EmergencyRollback"){let{method:c}=D(y.args);if(c==="forceRevert"){let C=0;if(ne){let X=ne.match(/Total\s*:\s*(\d+)/i);X&&(C=parseInt(X[1]))}let re=ne&&ne.startsWith("ERROR:")?"\u2718 Emergency Rollback Failed":`\u2714 Emergency Rollback \u2192 ${C} file${C===1?"":"s"} processed`,se=115;process.stdout.isTTY&&(se=process.stdout.columns-5||120);let Z=!1,le=Math.min(re.length+4,se),ke=`${re.padEnd(le-2).substring(0,le-2)}`;yield{type:"visual_feedback",content:Pt(`${je?`
753
+ `}`}`)},Oe=!1}if(Nn>0){let c=Date.now()-Nn,C=Math.max(0,1e3-c);C>0&&await new Promise(L=>setTimeout(L,C))}let _t={chatId:g,history:n,onChunk:c=>t.onExecChunk?t.onExecChunk(c):null,onAskUser:t.onAskUser,systemSettings:t.systemSettings,mode:l,isMultiModal:nt(ee),onVisualFeedback:t.onVisualFeedback,onSubagentUpdate:t.onSubagentUpdate,onTokenChunk:t.onTokenChunk,modelName:ee,aiProvider:t.aiProvider,apiKey:t.apiKey,onUsage:t.onUsage};if(a==="write_file"||a==="update_file")try{let{path:c}=D(y.args);if(c){let C=V.resolve(process.cwd(),c),L=await Hn();L&&L.file_focused===C&&L.full_content&&(_t.forcedContent=L.full_content)}}catch{}ce.push(a);let ne=await us(a,y.args,_t);if((a==="write_file"||a==="update_file")&&!ne.startsWith("ERROR:")){let{path:c}=D(y.args);if(c){let{resolvedPath:C}=ln(c),L=V.resolve(process.cwd(),C);pr(L)}}process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07");let Ve=Date.now();Nn=Ve,yield{type:"tool_time",content:Ve-T},Dn=Ve;let ft=null;if(typeof ne=="object"&&ne.binaryPart&&(ft=ne.binaryPart,ne=ne.text),a==="search_keyword"){let{keyword:c,path:C}=D(y.args),L=typeof ne=="string"&&ne.startsWith("[GLOB]");L&&(ne=ne.slice(6).trimStart());let re=typeof ne=="string"&&ne.startsWith("[DIR]");re&&(ne=ne.slice(5).trimStart());let se=0;if(ne){let O=ne.match(/Found (\d+) match/i);O&&(se=parseInt(O[1]))}let Z=(C||"").trim().toLowerCase().replaceAll("\\","/"),le=Z==="#doc"||Z==="#docs"||Z==="#documentation"||Z.includes("#skill/global/fluxflow")||Z.includes("#skill/fluxflow")||Z.includes("#skills/fluxflow")||Z.includes("#skills/global/fluxflow"),ke,J=115;process.stdout.isTTY&&(J=process.stdout.columns-5||120);let j=Math.max(10,(J+5)/3),F=Math.max(10,(J+5)/4);if(le)ke=`${c?"\u2714":"\u2718"} Searched Documentation`;else{let O=C?C.replace(/[\/\\]+$/,""):null,wt=O&&O!=="."?`${L?C:re?`${O}/*`:O}`:"./",St=wt.length>F?`${wt.slice(0,F)}...`:wt;ke=`${c?"\u2714":"\u2718"} Searched: "${c?c.length>J/3?`${c.slice(0,j)}...`:c:""}" in "${St.replaceAll("\\","/")}" \u2192 ${se} Match${se===1?"":"es"}`}let ue=Math.min(ke.length+4,J),Ge=`${ke.padEnd(ue-2).substring(0,ue-2)}`;yield{type:"visual_feedback",content:Rt(`${Oe?`
754
+ `:""}${Ge}
755
+ `)},Oe=!1}if(a==="EmergencyRollback"){let{method:c}=D(y.args);if(c==="forceRevert"){let C=0;if(ne){let J=ne.match(/Total\s*:\s*(\d+)/i);J&&(C=parseInt(J[1]))}let re=ne&&ne.startsWith("ERROR:")?"\u2718 Emergency Rollback Failed":`\u2714 Emergency Rollback \u2192 ${C} file${C===1?"":"s"} processed`,se=115;process.stdout.isTTY&&(se=process.stdout.columns-5||120);let Z=!1,le=Math.min(re.length+4,se),ke=`${re.padEnd(le-2).substring(0,le-2)}`;yield{type:"visual_feedback",content:Rt(`${Oe?`
755
756
  `:""}${ke}${Z?"":`
756
- `}`)},je=!1}}if(a==="todo"){let{method:c,tasks:C,markDone:L}=D(y.args),re="",se=[],Z=le=>{if(!le)return[];let ke=Array.isArray(le)?le:[];if(ke.length===0&&typeof le=="string"){let X=le.trim();if(X.startsWith("[")&&X.endsWith("]")){let j=X.match(/"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'/g);j?ke=j.map(F=>F.slice(1,-1).replace(/\\(.)/g,"$1")):ke=X.slice(1,-1).split(",").map(F=>F.trim()).filter(Boolean)}else ke=le.split(`
757
- `)}return ke.filter(X=>String(X).trim()).map(X=>{let j=String(X).trim();return j.startsWith("- [")?j.substring(6).trim():j})};if(c==="create"?(re="\x1B[32m\u2192\x1B[0m Created Goals",se=Z(C).map(le=>`\x1B[90m\u25CB\x1B[0m ${le}`)):c==="append"?(re="\x1B[34m\u2795\x1B[0m Added New Goals",se=Z(C).map(le=>`\x1B[90m\u25CB\x1B[0m ${le}`)):c==="get"&&(re=L?"\x1B[36m\u21BB\x1B[0m Updated Goals":"\x1B[35m\u2022\x1B[0m Reviewed Goals",se=(ne||"").split(`
757
+ `}`)},Oe=!1}}if(a==="todo"){let{method:c,tasks:C,markDone:L}=D(y.args),re="",se=[],Z=le=>{if(!le)return[];let ke=Array.isArray(le)?le:[];if(ke.length===0&&typeof le=="string"){let J=le.trim();if(J.startsWith("[")&&J.endsWith("]")){let j=J.match(/"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'/g);j?ke=j.map(F=>F.slice(1,-1).replace(/\\(.)/g,"$1")):ke=J.slice(1,-1).split(",").map(F=>F.trim()).filter(Boolean)}else ke=le.split(`
758
+ `)}return ke.filter(J=>String(J).trim()).map(J=>{let j=String(J).trim();return j.startsWith("- [")?j.substring(6).trim():j})};if(c==="create"?(re="\x1B[32m\u2192\x1B[0m Created Goals",se=Z(C).map(le=>`\x1B[90m\u25CB\x1B[0m ${le}`)):c==="append"?(re="\x1B[34m\u2795\x1B[0m Added New Goals",se=Z(C).map(le=>`\x1B[90m\u25CB\x1B[0m ${le}`)):c==="get"&&(re=L?"\x1B[36m\u21BB\x1B[0m Updated Goals":"\x1B[35m\u2022\x1B[0m Reviewed Goals",se=(ne||"").split(`
758
759
  `).slice(1).join(`
759
760
  `).split(`
760
- `).filter(ke=>ke.trim().startsWith("- [")).map(ke=>{let X=ke.trim(),j=X.startsWith("- [x]");return`${j?"\x1B[32m\u2714\x1B[0m":"\x1B[90m\u25CB\x1B[0m"} ${j?"\x1B[90m":"\x1B[37m"}${X.substring(6).trim()}\x1B[0m`})),re&&se.length>0){let le=[`${re}`,...se.map(X=>` ${X}`)].join(`
761
- `);yield{type:"visual_feedback",content:Pt(`${je?`
761
+ `).filter(ke=>ke.trim().startsWith("- [")).map(ke=>{let J=ke.trim(),j=J.startsWith("- [x]");return`${j?"\x1B[32m\u2714\x1B[0m":"\x1B[90m\u25CB\x1B[0m"} ${j?"\x1B[90m":"\x1B[37m"}${J.substring(6).trim()}\x1B[0m`})),re&&se.length>0){let le=[`${re}`,...se.map(J=>` ${J}`)].join(`
762
+ `);yield{type:"visual_feedback",content:Rt(`${Oe?`
762
763
  `:""}${le}${!1?"":`
763
- `}`)},je=!1}}a==="exec_command"&&t.onExecEnd&&(await new Promise(c=>setTimeout(c,800)),t.onExecEnd());let _t=ne&&ne.startsWith("DENIED:");ne&&!ne.startsWith("ERROR:")&&!_t?(await Ct("toolSuccess"),t.onToolResult&&t.onToolResult("success",a)):_t||(await Ct("toolFailure"),t.onToolResult&&t.onToolResult("failure",a));let wt=(ne||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");wt.includes("[[VERIFIED]]")&&(wt=wt.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to save tokens.
764
- `));let en;if(a==="write_file"&&!wt.startsWith("ERROR:")){let c=wt.replace(/^\[\[SAME\]\]\s*\r?\n?/,""),C=c.match(/\n\s*(\[Note:\s*'~'\s*resolved\s*to\s*user\s*home\s*directory[\s\S]*?\])\s*$/),L=C?`
764
+ `}`)},Oe=!1}}a==="exec_command"&&t.onExecEnd&&(await new Promise(c=>setTimeout(c,800)),t.onExecEnd());let It=ne&&ne.startsWith("DENIED:");ne&&!ne.startsWith("ERROR:")&&!It?(await vt("toolSuccess"),t.onToolResult&&t.onToolResult("success",a)):It||(await vt("toolFailure"),t.onToolResult&&t.onToolResult("failure",a));let bt=(ne||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");bt.includes("[[VERIFIED]]")&&(bt=bt.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to save tokens.
765
+ `));let en;if(a==="write_file"&&!bt.startsWith("ERROR:")){let c=bt.replace(/^\[\[SAME\]\]\s*\r?\n?/,""),C=c.match(/\n\s*(\[Note:\s*'~'\s*resolved\s*to\s*user\s*home\s*directory[\s\S]*?\])\s*$/),L=C?`
765
766
 
766
767
  ${C[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(c)){let re=c.search(/^- Content Preview:/m);en=`[ACTION RESULT]: ${re!==-1?c.slice(0,re).trimEnd():c}
767
768
 
768
769
  [Old file content for reversal reference. Replaced with new write request]${L}`}else{let re=c.split(/\r?\n/),se=re.filter(le=>le.startsWith("File ")||le.trim().startsWith("- Stats:"));en=`[ACTION RESULT]: ${se.length>0?se.join(`
769
770
  `):re.slice(0,2).join(`
770
- `)}${L}`}}else if(wt.startsWith("[[SAME]]")){let C=wt.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),L=C.filter(se=>se.startsWith("File ")||se.trim().startsWith("- Stats:"));en=`[ACTION RESULT]: ${L.length>0?L.join(`
771
+ `)}${L}`}}else if(bt.startsWith("[[SAME]]")){let C=bt.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),L=C.filter(se=>se.startsWith("File ")||se.trim().startsWith("- Stats:"));en=`[ACTION RESULT]: ${L.length>0?L.join(`
771
772
  `):C.slice(0,2).join(`
772
- `)}`}else en=`[ACTION RESULT]: ${wt}`;He.push({role:"user",text:en,binaryPart:ft}),mn=!0;let fe=`[ACTION RESULT]: ${ne.replaceAll(`[[VERIFIED]]
773
+ `)}`}else en=`[ACTION RESULT]: ${bt}`;je.push({role:"user",text:en,binaryPart:ft}),Sn=!0;let fe=`[ACTION RESULT]: ${ne.replaceAll(`[[VERIFIED]]
773
774
  `,"").replaceAll(`
774
- [[/VERIFIED]]`,"")||""}`;(a==="view_file"||a==="web_scrape"||a==="file_map"||a==="search_keyword"||a==="get_progress"||a==="getprogress")&&(fe=`[ACTION RESULT]: ${R} (Context Locked for UI Clarity)`),yield{type:"tool_result",content:fe,aiContent:en,binaryPart:ft,toolName:a},a==="memory"&&!ne.startsWith("ERROR:")&&(yield{type:"memory_updated"}),Tt++}if(s==="Google"&&at&&Date.now()-Vo>=150){yield*rn();let y=fo(at);for(let T of y)yield T;at="",Vo=Date.now()}}f.usageMetadata&&(Jt=f.usageMetadata),Jt&&(yield{type:"liveTokens",content:Jt.totalTokenCount})}if(W&&(W=!1,nt?be+="</think_fluxflow>":(xe+="</think_fluxflow>",s==="Google"?at+="</think_fluxflow>":yield{type:"text",content:"</think_fluxflow>"})),nt&&be.length>0){let f=0,S=Math.min(gt.length,be.length);for(let G=S;G>0;G--)if(gt.endsWith(be.substring(0,G))){f=G;break}let k=be.substring(f);if(k){let ie=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(gt)?k.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):k.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");if(ie)if(xe+=ie,s==="Google")at+=ie;else{yield*rn();let I=fo(ie);for(let H of I)yield H}}nt=!1,be=""}if(pn){let f=pn,S=(lt==="tool"||lt==="action")&&(f.startsWith("[tool:")||f.startsWith("[action:"));pn="",Zn=!1,lt=null,Wn=!1,eo=!1,S||(s==="Google"?at+=f:yield{type:"text",content:f})}if(yield*rn(),ut)break;let uo=(xe||"").trim(),Ia=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(uo.toLowerCase())||/\[\[END\]\]/i.test(uo.toLowerCase()),Ma=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(uo.toLowerCase()),Pa=He.length>0||Lt!==null,$i=Nt(uo).trim(),$a=/(\p{Emoji_Presentation}|\p{Extended_Pictographic})$/u.test($i),La=/([.!?"'*_`|\]\)”’~~]+|\s|`{3}|[\u200B-\u200D\uFEFF])$/u.test($i.trim()),Oa=/[.!?}"'`’“”]$|```$/s.test($i)||La||$a;!Ia&&!Ma&&!Pa&&uo.length>0,we=!0,await Ct("agent",s)}catch(q){if(ut){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
775
+ [[/VERIFIED]]`,"")||""}`;(a==="view_file"||a==="web_scrape"||a==="file_map"||a==="search_keyword"||a==="get_progress"||a==="getprogress")&&(fe=`[ACTION RESULT]: ${R} (Context Locked for UI Clarity)`),yield{type:"tool_result",content:fe,aiContent:en,binaryPart:ft,toolName:a},a==="memory"&&!ne.startsWith("ERROR:")&&(yield{type:"memory_updated"}),Tt++}if(s==="Google"&&at&&Date.now()-Vo>=150){yield*rn();let y=fo(at);for(let T of y)yield T;at="",Vo=Date.now()}}f.usageMetadata&&(Jt=f.usageMetadata),Jt&&(yield{type:"liveTokens",content:Jt.totalTokenCount})}if(W&&(W=!1,Xe?pe+="</think_fluxflow>":(be+="</think_fluxflow>",s==="Google"?at+="</think_fluxflow>":yield{type:"text",content:"</think_fluxflow>"})),Xe&&pe.length>0){let f=0,S=Math.min(gt.length,pe.length);for(let G=S;G>0;G--)if(gt.endsWith(pe.substring(0,G))){f=G;break}let k=pe.substring(f);if(k){let ie=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(gt)?k.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):k.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");if(ie)if(be+=ie,s==="Google")at+=ie;else{yield*rn();let I=fo(ie);for(let H of I)yield H}}Xe=!1,pe=""}if(mn){let f=mn,S=(lt==="tool"||lt==="action")&&(f.startsWith("[tool:")||f.startsWith("[action:"));mn="",Zn=!1,lt=null,Wn=!1,eo=!1,S||(s==="Google"?at+=f:yield{type:"text",content:f})}if(yield*rn(),ut)break;let uo=(be||"").trim(),Ia=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(uo.toLowerCase())||/\[\[END\]\]/i.test(uo.toLowerCase()),Ma=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(uo.toLowerCase()),Pa=je.length>0||Lt!==null,$i=Ft(uo).trim(),$a=/(\p{Emoji_Presentation}|\p{Extended_Pictographic})$/u.test($i),La=/([.!?"'*_`|\]\)”’~~]+|\s|`{3}|[\u200B-\u200D\uFEFF])$/u.test($i.trim()),Oa=/[.!?}"'`’“”]$|```$/s.test($i)||La||$a;!Ia&&!Ma&&!Pa&&uo.length>0,we=!0,await vt("agent",s)}catch(Y){if(ut){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
775
776
 
776
- \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(String(q).includes("Incomplete JSON segment at the end")){W&&(W=!1,nt?be+="</think_fluxflow>":(xe+="</think_fluxflow>",yield{type:"text",content:"</think_fluxflow>"})),we=!0,await Ct("agent",s);break}if(W&&(W=!1,nt?be+="</think_fluxflow>":xe+="</think_fluxflow>"),nt&&be.length>0){let mt=0,Qe=Math.min(gt.length,be.length);for(let Wt=Qe;Wt>0;Wt--)if(gt.endsWith(be.substring(0,Wt))){mt=Wt;break}let rt=be.substring(mt);if(rt){let et=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(gt)?rt.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):rt.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");et&&(xe+=et)}nt=!1,be=""}let E=q instanceof Error?(()=>{try{return JSON.parse(JSON.parse(q.message).error.message).error.message}catch{return String(q)}})():String(q),st=new Date().toLocaleString(),de=J.join(Gn,"agent");Ce.existsSync(de)||Ce.mkdirSync(de,{recursive:!0}),Ce.appendFileSync(J.join(de,"error.log"),`ERROR [${st}]: ${E}
777
+ \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(String(Y).includes("Incomplete JSON segment at the end")){W&&(W=!1,Xe?pe+="</think_fluxflow>":(be+="</think_fluxflow>",yield{type:"text",content:"</think_fluxflow>"})),we=!0,await vt("agent",s);break}if(W&&(W=!1,Xe?pe+="</think_fluxflow>":be+="</think_fluxflow>"),Xe&&pe.length>0){let mt=0,Ze=Math.min(gt.length,pe.length);for(let Wt=Ze;Wt>0;Wt--)if(gt.endsWith(pe.substring(0,Wt))){mt=Wt;break}let rt=pe.substring(mt);if(rt){let tt=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(gt)?rt.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):rt.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");tt&&(be+=tt)}Xe=!1,pe=""}let E=Y instanceof Error?(()=>{try{return JSON.parse(JSON.parse(Y.message).error.message).error.message}catch{return String(Y)}})():String(Y),st=new Date().toLocaleString(),de=V.join(Gn,"agent");Ce.existsSync(de)||Ce.mkdirSync(de,{recursive:!0}),Ce.appendFileSync(V.join(de,"error.log"),`ERROR [${st}]: ${E}
777
778
 
778
779
  ----------------------------------------------------------------------
779
780
 
780
- `);let We=q.status||q.statusCode||q.code,xt=String(q).includes("replicas at capacity");if(!(We&&(We>=500&&We<600||We===408||We===429||xt)||!We&&(/status[ :]+(5\d\d|408|429)/i.test(String(q))||/code[ :]+(5\d\d|408|429)/i.test(String(q))||/(500|503|408|429)/.test(String(q))))){if(Le<sn-3)throw q;yield{type:"text",content:E},yield{type:"status",content:"Error Occured"}}if(xe.trim().length>0||Je>1)if(Je<=sn){Je++;let mt=Math.min(1e3*Math.pow(2,Je-1),24e3);if(xe.trim().length>0){x.push({role:"agent",text:xe});let Qe=`[system]
781
+ `);let Ue=Y.status||Y.statusCode||Y.code,xt=String(Y).includes("replicas at capacity");if(!(Ue&&(Ue>=500&&Ue<600||Ue===408||Ue===429||xt)||!Ue&&(/status[ :]+(5\d\d|408|429)/i.test(String(Y))||/code[ :]+(5\d\d|408|429)/i.test(String(Y))||/(500|503|408|429)/.test(String(Y))))){if(Me<sn-3)throw Y;yield{type:"text",content:E},yield{type:"status",content:"Error Occured"}}if(be.trim().length>0||Qe>1)if(Qe<=sn){Qe++;let mt=Math.min(1e3*Math.pow(2,Qe-1),24e3);if(be.trim().length>0){x.push({role:"agent",text:be});let Ze=`[system]
781
782
  - seamless continuation: resume immediately. pick up from last words with zero gap/disruption
782
783
  - no repetition: do not repeat any text already written
783
784
  - no re-think: do not restart or open <think_fluxflow> if reasoning already started. continue the thinking and close thinking block </think_fluxflow> before chat output
784
785
  - mid-tool safety: if cutoff was mid-tool call, restart that tool call from start
785
- - stealth: do not mention/apologize for cutoff [/system]`;He.length>0?He.forEach((rt,Wt)=>{Wt===He.length-1?x.push({...rt,text:`${rt.text}
786
+ - stealth: do not mention/apologize for cutoff [/system]`;je.length>0?je.forEach((rt,Wt)=>{Wt===je.length-1?x.push({...rt,text:`${rt.text}
786
787
 
787
- ${Qe}`}):x.push(rt)}):x.push({role:"user",text:Qe}),gt+=xe}for(let Qe=mt/1e3;Qe>0&&!ut;Qe--)yield{type:"status",content:`Error Occured. Recovering Stream (${Je}/${sn}) [Retrying in ${Qe.toFixed(0)}s]...`},await new Promise(rt=>setTimeout(rt,1e3));yield{type:"status",content:"Error Occured. Recovering Stream..."}}else throw new Error(`Stream collapsed too many times. (Failed to resolve ${sn} times)
788
- Error log can be found in \`/export logs\``);else{let Qe=e.split("/").slice(e.endsWith("/free")?-2:-1).join("/");if(Le<=sn){Le++,Je=1,gt="";let rt=Math.min(1e3*Math.pow(2,Le-1),32e3),Wt=.8+Math.random()*.4,et=Math.round(rt*Wt);kn=!0,yield{type:"status",content:`Trying to reach ${Qe} (${Le}/${sn}) [Retrying in ${(et/1e3).toFixed(0)}s]`};for(let Oe=et/1e3;Oe>0&&!ut;Oe--)yield{type:"status",content:`Trying to reach ${Qe} (${Le}/${sn}) [Retrying in ${Oe.toFixed(0)}s]`},await new Promise(at=>setTimeout(at,1e3));yield{type:"status",content:`Trying to reach ${Qe}`}}else throw new Error(`Model ${e} cannot be reached. (Failed ${sn} times)
789
- Error log can be found in \`/export logs\``)}}}if(Jt){let W=Jt.totalTokenCount||0,q=Jt.cachedContentTokenCount||0,E=(Jt.candidatesTokenCount||0)+(s==="Google"&&Jt.thoughtsTokenCount||0);await dn("tokens",W,s,ee),q>0&&await dn("cachedTokens",q,s,ee),E>0&&await dn("candidateTokens",E,s,ee),yt!==null&&yt>0&&await dn("ttft",yt,s,ee),ni({provider:s,model:ee,prompt:Jt.promptTokenCount||0,cached:q,output:E,reasoning:Jt.thoughtsTokenCount||0,ttft:yt}),yield{type:"usage",content:Jt}}else yt!==null&&yt>0&&(await dn("ttft",yt,s,ee),ni({provider:s,model:ee,prompt:0,cached:0,output:0,reasoning:0,ttft:yt}));xe=ma(xe),Ii.push(xe);let Il=Nt(xe),Pi=fa(xe),Aa=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(Pi.toLowerCase())||/\[\[END\]\]/i.test(Pi.toLowerCase())||!0,Ml=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(Pi.toLowerCase()),Pl=Tt>0;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"};let Ca=vl(xe,/(\[\s*(turn\s*:)?\s*(continue|finish)\s*\]|\[\[END\]\])/gi,"").trim(),va=He.length>0||Mn(Nt(xe)).length>0,Bn=(Aa||He.length===0)&&!Rt&&!Fn&&!Ot;if(Bn=He.length===0?Bn:!1,Bn=va&&Bt||Ko?!1:Bn,xe&&xe.trim().endsWith('")]')&&He.length===0&&(Bn=!1),Bn){Os=!0;let W=Ii.join(`
790
- `),q=Nt(W).trim();yield{type:"interactive_turn_finished",data:{agentText:Ie,fullAgentTextRaw:W,history:[...x],needTitle:ve}},x.length>0&&x[x.length-1].role==="agent"?x[x.length-1].text=q:x.push({role:"agent",text:q}),x.forEach(E=>{if(E.role==="user"&&E.text&&(E.text=E.text.replace(/\n\[COMPILE ERROR\][\s\S]*?\[\/ERROR\]/g,""),E.text=E.text.replaceAll(`
788
+ ${Ze}`}):x.push(rt)}):x.push({role:"user",text:Ze}),gt+=be}for(let Ze=mt/1e3;Ze>0&&!ut;Ze--)yield{type:"status",content:`Error Occured. Recovering Stream (${Qe}/${sn}) [Retrying in ${Ze.toFixed(0)}s]...`},await new Promise(rt=>setTimeout(rt,1e3));yield{type:"status",content:"Error Occured. Recovering Stream..."}}else throw new Error(`Stream collapsed too many times. (Failed to resolve ${sn} times)
789
+ Error log can be found in \`/export logs\``);else{let Ze=e.split("/").slice(e.endsWith("/free")?-2:-1).join("/");if(Me<=sn){Me++,Qe=1,gt="";let rt=Math.min(1e3*Math.pow(2,Me-1),32e3),Wt=.8+Math.random()*.4,tt=Math.round(rt*Wt);kn=!0,yield{type:"status",content:`Trying to reach ${Ze} (${Me}/${sn}) [Retrying in ${(tt/1e3).toFixed(0)}s]`};for(let De=tt/1e3;De>0&&!ut;De--)yield{type:"status",content:`Trying to reach ${Ze} (${Me}/${sn}) [Retrying in ${De.toFixed(0)}s]`},await new Promise(at=>setTimeout(at,1e3));yield{type:"status",content:`Trying to reach ${Ze}`}}else throw new Error(`Model ${e} cannot be reached. (Failed ${sn} times)
790
+ Error log can be found in \`/export logs\``)}}}if(Jt){let W=Jt.totalTokenCount||0,Y=Jt.cachedContentTokenCount||0,E=(Jt.candidatesTokenCount||0)+(s==="Google"&&Jt.thoughtsTokenCount||0);await dn("tokens",W,s,ee),Y>0&&await dn("cachedTokens",Y,s,ee),E>0&&await dn("candidateTokens",E,s,ee),yt!==null&&yt>0&&await dn("ttft",yt,s,ee),ni({provider:s,model:ee,prompt:Jt.promptTokenCount||0,cached:Y,output:E,reasoning:Jt.thoughtsTokenCount||0,ttft:yt}),yield{type:"usage",content:Jt}}else yt!==null&&yt>0&&(await dn("ttft",yt,s,ee),ni({provider:s,model:ee,prompt:0,cached:0,output:0,reasoning:0,ttft:yt}));be=ma(be),Ii.push(be);let Il=Ft(be),Pi=fa(be),Aa=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(Pi.toLowerCase())||/\[\[END\]\]/i.test(Pi.toLowerCase())||!0,Ml=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(Pi.toLowerCase()),Pl=Tt>0;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"};let Ca=vl(be,/(\[\s*(turn\s*:)?\s*(continue|finish)\s*\]|\[\[END\]\])/gi,"").trim(),va=je.length>0||Mn(Ft(be)).length>0,Bn=(Aa||je.length===0)&&!Ot&&!Fn&&!Dt;if(Bn=je.length===0?Bn:!1,Bn=va&&At||Ko?!1:Bn,be&&be.trim().endsWith('")]')&&je.length===0&&(Bn=!1),Bn){Os=!0;let W=Ii.join(`
791
+ `),Y=Ft(W).trim();yield{type:"interactive_turn_finished",data:{agentText:Ie,fullAgentTextRaw:W,history:[...x],needTitle:ve}},x.length>0&&x[x.length-1].role==="agent"?x[x.length-1].text=Y:x.push({role:"agent",text:Y}),x.forEach(E=>{if(E.role==="user"&&E.text&&(E.text=E.text.replace(/\n\[COMPILE ERROR\][\s\S]*?\[\/ERROR\]/g,""),E.text=E.text.replaceAll(`
791
792
 
792
793
  [system] user question. resolve this specific query within '[ANSWER] ... [/ANSWER]' concisely, naturally [/system]
793
794
  `,"").replaceAll(`[system] user question. resolve this specific query within '[ANSWER] ... [/ANSWER]' concisely, naturally
794
795
  **strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow>** [/system]
795
796
  `,"").replaceAll(`[system] **strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow>** [/system]
796
797
  `,"").replaceAll(/\n\[system\] WARNING, Turn Limit Impending: Step \d+\/\d+\. Wrap up quickly\/prompt user to continue & use \[\[END\]\] quickly\. \[\/system\]/g,""),E.text=E.text.replaceAll(/\n\[system\] File Changes:\n(?:\* .+ \(created|modified|deleted\)\n)*\[\/system\]/g,""),(s==="Mistral"||s==="Google"&&e?.toLowerCase().startsWith("gemma"))&&(E.text.startsWith("[ACTION RESULT]")||E.text.startsWith("[TOOL RESULT]")))){let de=`
797
- [system] Action result received. Analyze output and proceed with your turn [/system]`,We=`
798
- [system] Action result received. Analyze output and proceed with your turn. **strictly follow thinking policy. do not start a response without <think_fluxflow>...</think_fluxflow>** [/system]`;E.text=E.text.replaceAll(We,"").replaceAll(de,"").trim()}}),yield{type:"status",content:"[end]"}}if(Bn)break;let Ra=Ca.trim()||"*Working...*";if(x.push({role:"agent",text:Ra}),He.length>0||mn){if(He.length>0){let W=He.map(et=>et.text).join(`
799
-
800
- `),q=Nt(xe),E=Mn(q),st=da(q,E),de=Ti(st),We=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,xt=[],me=[],mt;for(;(mt=We.exec(de))!==null;)me.push({index:mt.index,toolName:mt[1]});for(let et=0;et<me.length;et++){let Oe=me[et],at=et+1<me.length?me[et+1].index:q.length;E.some(rn=>rn.fullMatch&&q.startsWith(rn.fullMatch,Oe.index))||xt.push(q.substring(Oe.index,at))}let Qe=xt.length,rt=He.length+Qe;if(Qe>0){let et=xt.join(`
801
- `),Oe=ua(et);W+=`
802
-
803
- [system] Only ${He.length} out of ${rt} attempted tool calls were executed.
804
- ${Oe?`Parsing Issues Detected:
805
- ${Oe}
806
- `:""}Verify proper structure compliance [action:ActionName(arg="value")] & try failed calls again [/system]`;for(let at=0;at<Qe;at++)await Ct("toolFailure")}let Wt=He.find(et=>et.binaryPart)?.binaryPart||null;x.push({role:"user",text:W,binaryPart:Wt})}}else if(!ut){let W=xe.replace(/(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\]|$)/i,""),q=Mn(W),E=da(W,q),de=(Ti(E).match(/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi)||[]).length;if(Ko||Bt&&de>0||de>0){let We=ua(W),xt=We?`[system] Failed to execute ${de>0?de:1} action call${de>1?"s":""} due to syntax/structure issues:
807
- ${We} [/system]`:`[system] Failed to execute ${de>0?de:1} action${de>1?"s":""}. Verify proper structure compliance [action:ActionName(arg="value")] & try again [/system]`;x.push({role:"user",text:xt}),await Ct("toolFailure"),yield{type:"visual_feedback",content:`
808
- ${Pt("\u2718 Model produced malformed tool call")}
798
+ [system] Action result received. Analyze output and proceed with your turn [/system]`,Ue=`
799
+ [system] Action result received. Analyze output and proceed with your turn. **strictly follow thinking policy. do not start a response without <think_fluxflow>...</think_fluxflow>** [/system]`;E.text=E.text.replaceAll(Ue,"").replaceAll(de,"").trim()}}),yield{type:"status",content:"[end]"}}if(Bn)break;let Ra=Ca.trim()||"*Working...*";if(x.push({role:"agent",text:Ra}),je.length>0||Sn){if(je.length>0){let W=je.map(tt=>tt.text).join(`
800
+
801
+ `),Y=Ft(be),E=Mn(Y),st=da(Y,E),de=Ti(st),Ue=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,xt=[],me=[],mt;for(;(mt=Ue.exec(de))!==null;)me.push({index:mt.index,toolName:mt[1]});for(let tt=0;tt<me.length;tt++){let De=me[tt],at=tt+1<me.length?me[tt+1].index:Y.length;E.some(rn=>rn.fullMatch&&Y.startsWith(rn.fullMatch,De.index))||xt.push(Y.substring(De.index,at))}let Ze=xt.length,rt=je.length+Ze;if(Ze>0){let tt=xt.join(`
802
+ `),De=ua(tt);W+=`
803
+
804
+ [system] Only ${je.length} out of ${rt} attempted tool calls were executed.
805
+ ${De?`Parsing Issues Detected:
806
+ ${De}
807
+ `:""}Verify proper structure compliance [action:ActionName(arg="value")] & try failed calls again [/system]`;for(let at=0;at<Ze;at++)await vt("toolFailure")}let Wt=je.find(tt=>tt.binaryPart)?.binaryPart||null;x.push({role:"user",text:W,binaryPart:Wt})}}else if(!ut){let W=be.replace(/(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\]|$)/i,""),Y=Mn(W),E=da(W,Y),de=(Ti(E).match(/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi)||[]).length;if(Ko||At&&de>0||de>0){let Ue=ua(W),xt=Ue?`[system] Failed to execute ${de>0?de:1} action call${de>1?"s":""} due to syntax/structure issues:
808
+ ${Ue} [/system]`:`[system] Failed to execute ${de>0?de:1} action${de>1?"s":""}. Verify proper structure compliance [action:ActionName(arg="value")] & try again [/system]`;x.push({role:"user",text:xt}),await vt("toolFailure"),yield{type:"visual_feedback",content:`
809
+ ${Rt("\u2718 Model produced malformed tool call")}
809
810
  `}}else yield{type:"visual_feedback",content:`
810
- ${Pt("\u2718 Loop Detected")}
811
- `},x.push({role:"user",text:`[system] ${Fn&&!Rt?"Stuttering Detected by Internal System. Re-calibrate your response & proceed.":`${Rt?" Over Thinking":" Loop"} Detected by Internal System${Rt?" for current Effort Level":""}. ${Rt?"If you have planned the task, prioritize execution/output":"If you have finished your task provide a simple summary and end"}`} [/system]`});Rt=!1,Fn=!1,Ot=!1}m?.advanceRollback&&await So.recordTurnDelta(g,b+1,ce),Mi=ce.includes("recapture_screen"),Ko=Tt>0||mn}if(!Os&&!ut){let b="\u2726 Turn safety limit reached. Stopping execution.";yield{type:"text",content:`
811
+ ${Rt("\u2718 Loop Detected")}
812
+ `},x.push({role:"user",text:`[system] ${Fn&&!Ot?"Stuttering Detected by Internal System. Re-calibrate your response & proceed.":`${Ot?" Over Thinking":" Loop"} Detected by Internal System${Ot?" for current Effort Level":""}. ${Ot?"If you have planned the task, prioritize execution/output":"If you have finished your task provide a simple summary and end"}`} [/system]`});Ot=!1,Fn=!1,Dt=!1}m?.advanceRollback&&await So.recordTurnDelta(g,w+1,ce),Mi=ce.includes("recapture_screen"),Ko=Tt>0||Sn}if(!Os&&!ut){let w="\u2726 Turn safety limit reached. Stopping execution.";yield{type:"text",content:`
812
813
 
813
- ${b}
814
+ ${w}
814
815
  `};let ge=(Ii.join(`
815
816
  `)+`
816
- ${b}`).trim();yield{type:"interactive_turn_finished",data:{agentText:Ie,fullAgentTextRaw:ge,history:[...x],needTitle:ve}},yield{type:"status",content:"[end]"}}}catch(U){let x=U?.cause?` (Cause: ${U.cause?.message||String(U.cause)})`:"",De=(U instanceof Error?(()=>{try{return JSON.parse(JSON.parse(U.message).error.message).error.message}catch{return(U.message?`${U.message}${x}`:"")||String(U)}})():String(U)).replace(/^(Error:\s*)+/i,"");s==="Google"&&!/^[A-Z0-9_\-\s]+ ERROR:/i.test(De)&&(De=`GEMINI ERROR: ${De}`);let qt=new Date().toLocaleString(),Ne=J.join(Gn,"agent");yield{type:"text",content:`
817
+ ${w}`).trim();yield{type:"interactive_turn_finished",data:{agentText:Ie,fullAgentTextRaw:ge,history:[...x],needTitle:ve}},yield{type:"status",content:"[end]"}}}catch(U){let x=U?.cause?` (Cause: ${U.cause?.message||String(U.cause)})`:"",Ne=(U instanceof Error?(()=>{try{return JSON.parse(JSON.parse(U.message).error.message).error.message}catch{return(U.message?`${U.message}${x}`:"")||String(U)}})():String(U)).replace(/^(Error:\s*)+/i,"");s==="Google"&&!/^[A-Z0-9_\-\s]+ ERROR:/i.test(Ne)&&(Ne=`GEMINI ERROR: ${Ne}`);let qt=new Date().toLocaleString(),Fe=V.join(Gn,"agent");yield{type:"text",content:`
817
818
 
818
- \u2726 CRITICAL ERROR: ${De.includes("fetch failed")?"Failed to Connect. Check your Internet Connection or Wait a moment":De}
819
- \u2800`},Ce.existsSync(Ne)||Ce.mkdirSync(Ne,{recursive:!0}),Ce.appendFileSync(J.join(Ne,"error.log"),`CRITICAL ERROR [${qt}]: ${U}${U?.cause?`
819
+ \u2726 CRITICAL ERROR: ${Ne.includes("fetch failed")?"Failed to Connect. Check your Internet Connection or Wait a moment":Ne}
820
+ \u2800`},Ce.existsSync(Fe)||Ce.mkdirSync(Fe,{recursive:!0}),Ce.appendFileSync(V.join(Fe,"error.log"),`CRITICAL ERROR [${qt}]: ${U}${U?.cause?`
820
821
  CAUSE: ${U.cause?.stack||U.cause}`:""}
821
822
 
822
823
  ----------------------------------------------------------------------
823
824
 
824
- `),typeof flushGoogleBuffer=="function"&&(yield*flushGoogleBuffer()),yield{type:"tool_result",content:`ERROR: [INTERNAL CRITICAL] ${De}`}}finally{Xe&&(clearInterval(Xe),Xe=null),typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),await oi.commitTransaction(),m?.advanceRollback&&await So.cleanup(g),await Hn()}yield{type:"status",content:null}},Zd=async(e,n,t=null,i=null,o=null,r=null,d=!1)=>{let l=await ti(),u={...l,...n},g=typeof o=="number"&&o>0?o:50,h=(u?.systemSettings?.loopLimits||"Default").toLowerCase();if(h==="extended")g=Math.floor(g*3);else if(h==="env"){let Ne=parseInt(process.env.FLUXFLOW_SUBAGENT_MAX_TURNS||process.env.SUBAGENT_MAX_TURNS||process.env.FLUXFLOW_MAX_LOOPS||process.env.MAX_LOOPS||"",10);Number.isFinite(Ne)&&Ne>0&&(g=Ne)}o=g;let m=process.env.SUBAGENT_MODEL?process.env.SUBAGENT_MODEL.trim():null,p=process.env.SUBAGENT_PROVIDER?process.env.SUBAGENT_PROVIDER.trim():null,s=new Date,w=`${s.getFullYear()}-${s.toLocaleString("en-US",{month:"short"}).toUpperCase()}-${String(s.getDate()).padStart(2,"0")}, ${s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).replace(":","-")}`,$e=(Ne=>{if(!Ne)return null;let ae=Ne.toLowerCase();return ae==="google"?"Google":ae==="deepseek"?"DeepSeek":ae==="openrouter"?"OpenRouter":ae==="nvidia"?"NVIDIA":ae==="mistral"?"Mistral":ae==="ollama"?"Ollama":ae==="inferx"?"InferX":ae==="sensenova"?"SenseNova":ae==="poolside"?"Poolside":ae==="9router"||ae==="9Router"?"9router":ae==="aihubmix"||ae==="aihub"?"AIHubMix":ae==="explabs"||ae==="experientiallabs"||ae==="experimentallabs"?"ExpLabs":ae==="tokenharbor"||ae==="token harbor"||ae==="token_harbor"||ae==="thk"?"TokenHarbor":ae==="infron"?"Infron":ae==="apinex"||ae==="apx"?"APInex":ae==="xkiro"||ae==="kiro"?"xKiro":ae==="c_openai"||ae==="custom_openai"||ae==="custom (openai)"||ae==="custom"?"c_openai":null})(p),v=u?.systemSettings?.CustomSubAgent?u?.systemSettings?.SubAgentModel:null,N=u?.systemSettings?.CustomSubAgent?u?.systemSettings?.SubAgentProvider:null,P=null;if(v==="ENV"?(P=m,m&&$e&&(u.aiProvider=$e)):v&&v!=="Default"?(P=v,N&&(u.aiProvider=N)):m&&$e&&(u.aiProvider=$e),u.aiProvider){let Ne=await Hs(u.aiProvider);Ne&&(u.apiKey=Ne)}let V=Ne=>{if(!Ne||typeof Ne!="string")return{allowed:!0};let ae=[/rm\s+-[rf]{1,2}\s+[\/*.]/i,/rmdir\s+\/[sq]/i,/del\s+\/[fsq]/i,/\bformat\b\s+[a-z]:/i,/mkfs/i,/dd\s+if=/i,/\b(shutdown|reboot|poweroff|init\s+0|init\s+6)\b/i,/chmod\s+(-R\s+)?777\s+[\/*.]/i,/chown\s+(-R\s+)?root/i,/git\s+push\s+.*--force/i,/git\s+clean\s+-fdx/i,/\bsudo\s+su\b/i,/\bsu\s+-\b/i];for(let on of ae)if(on.test(Ne))return{allowed:!1,reason:`Blocked potentially destructive or unsafe command pattern: "${on.source}"`};return{allowed:!0}},M=t||P||n?.modelName||n?.activeModel||l.activeModel,ye=(process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux")==="Windows",ve=ye&&u?.systemSettings?.preferBash!==!1&&zs(),Ie="Run(command=string)",Xe=`Runs ${ye?Ki()?"powershell":"windows CMD":"bash"} command`;ve&&(Ie=`Run(command=string, ${qs()||Ki()?"forcePowershell?=bool:false":"forceCwd?=bool:false"})`,Xe="Runs in git bash. Or force native shell");let U=`-- ACTIONS (path = relative to CWD, path separator: '/') --
825
+ `),typeof flushGoogleBuffer=="function"&&(yield*flushGoogleBuffer()),yield{type:"tool_result",content:`ERROR: [INTERNAL CRITICAL] ${Ne}`}}finally{Je&&(clearInterval(Je),Je=null),typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),await oi.commitTransaction(),m?.advanceRollback&&await So.cleanup(g),await Hn()}yield{type:"status",content:null}},Zd=async(e,n,t=null,i=null,o=null,r=null,d=!1)=>{let l=await ti(),u={...l,...n},g=typeof o=="number"&&o>0?o:50,h=(u?.systemSettings?.loopLimits||"Default").toLowerCase();if(h==="extended")g=Math.floor(g*3);else if(h==="env"){let Fe=parseInt(process.env.FLUXFLOW_SUBAGENT_MAX_TURNS||process.env.SUBAGENT_MAX_TURNS||process.env.FLUXFLOW_MAX_LOOPS||process.env.MAX_LOOPS||"",10);Number.isFinite(Fe)&&Fe>0&&(g=Fe)}o=g;let m=process.env.SUBAGENT_MODEL?process.env.SUBAGENT_MODEL.trim():null,p=process.env.SUBAGENT_PROVIDER?process.env.SUBAGENT_PROVIDER.trim():null,s=new Date,b=`${s.getFullYear()}-${s.toLocaleString("en-US",{month:"short"}).toUpperCase()}-${String(s.getDate()).padStart(2,"0")}, ${s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).replace(":","-")}`,Le=(Fe=>{if(!Fe)return null;let ae=Fe.toLowerCase();return ae==="google"?"Google":ae==="deepseek"?"DeepSeek":ae==="openrouter"?"OpenRouter":ae==="nvidia"?"NVIDIA":ae==="mistral"?"Mistral":ae==="ollama"?"Ollama":ae==="inferx"?"InferX":ae==="sensenova"?"SenseNova":ae==="poolside"?"Poolside":ae==="9router"||ae==="9Router"?"9router":ae==="aihubmix"||ae==="aihub"?"AIHubMix":ae==="explabs"||ae==="experientiallabs"||ae==="experimentallabs"?"ExpLabs":ae==="tokenharbor"||ae==="token harbor"||ae==="token_harbor"||ae==="thk"?"TokenHarbor":ae==="infron"?"Infron":ae==="apinex"||ae==="apx"?"APInex":ae==="xkiro"||ae==="kiro"?"xKiro":ae==="c_openai"||ae==="custom_openai"||ae==="custom (openai)"||ae==="custom"?"c_openai":null})(p),v=u?.systemSettings?.CustomSubAgent?u?.systemSettings?.SubAgentModel:null,N=u?.systemSettings?.CustomSubAgent?u?.systemSettings?.SubAgentProvider:null,P=null;if(v==="ENV"?(P=m,m&&Le&&(u.aiProvider=Le)):v&&v!=="Default"?(P=v,N&&(u.aiProvider=N)):m&&Le&&(u.aiProvider=Le),u.aiProvider){let Fe=await Hs(u.aiProvider);Fe&&(u.apiKey=Fe)}let z=Fe=>{if(!Fe||typeof Fe!="string")return{allowed:!0};let ae=[/rm\s+-[rf]{1,2}\s+[\/*.]/i,/rmdir\s+\/[sq]/i,/del\s+\/[fsq]/i,/\bformat\b\s+[a-z]:/i,/mkfs/i,/dd\s+if=/i,/\b(shutdown|reboot|poweroff|init\s+0|init\s+6)\b/i,/chmod\s+(-R\s+)?777\s+[\/*.]/i,/chown\s+(-R\s+)?root/i,/git\s+push\s+.*--force/i,/git\s+clean\s+-fdx/i,/\bsudo\s+su\b/i,/\bsu\s+-\b/i];for(let on of ae)if(on.test(Fe))return{allowed:!1,reason:`Blocked potentially destructive or unsafe command pattern: "${on.source}"`};return{allowed:!0}},M=t||P||n?.modelName||n?.activeModel||l.activeModel,xe=(process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux")==="Windows",ve=xe&&u?.systemSettings?.preferBash!==!1&&zs(),Ie="Run(command=string)",Je=`Runs ${xe?Ki()?"powershell":"windows CMD":"bash"} command`;ve&&(Ie=`Run(command=string, ${qs()||Ki()?"forcePowershell?=bool:false":"forceCwd?=bool:false"})`,Je="Runs in git bash. Or force native shell");let U=`-- ACTIONS (path = relative to CWD, path separator: '/') --
825
826
  In chat output the format \`[action:ActionName(arg1="value1")]\` in NEW line
826
827
  Rules:
827
828
  - JSON escape literal sequences, backslash: \\\\, newLine: \\ n
@@ -845,7 +846,7 @@ ${d?"- AskMain(question=string). Communicate with PARENT/MAIN AGENT. When clarif
845
846
  - ReadFile(path=string, startLine?=int, endLine?=int)
846
847
  - PatchFile(path=string, allowMultiple?=bool, searchContent1="string match OR ^LINE:start..end$", newContent1=string, ...MAX15). Small searchString. Line Anchors: ^LINE:...$ syntax, must for large blocks & escape sequences
847
848
  - WriteFile(path=string, content=string). Creates/Overwrites. File Exist? PatchFile > WriteFile
848
- - ${Ie}. ${Xe}. Destructive command \u2192 Ask user`.trim(),x=`=== START SYSTEM PROMPT ===
849
+ - ${Ie}. ${Je}. Destructive command \u2192 Ask user`.trim(),x=`=== START SYSTEM PROMPT ===
849
850
  Identity: FluxFlow subagent helping the main Agent
850
851
  Your task: "${e}"
851
852
  CWD: ${process.cwd()}
@@ -857,29 +858,29 @@ Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens ov
857
858
  Main focus: actions and task, not chatting
858
859
  On completion, provide a detailed summary in Tables/Markdown Format with file modified info. If any task failed report back in detail
859
860
 
860
- Current Time: ${w}
861
- === END SYSTEM PROMPT ===`,zt=[{role:"user",text:`Complete this task: ${e}`}],De=0,qt="";for(;De<o;){let Ne=await Gi("subagent",u);if(!Ne.allowed)throw new Error(Ne.reason||`Budget Exhausted for Provider (${u?.aiProvider||"Subagent"})`);if(ut){if(n?.taskId&&typeof Dt<"u"){let Q=Dt.find(B=>B.id===n.taskId);Q&&(Q.status="cancelled")}throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}if(n?.taskId&&typeof Dt<"u"){let Q=Dt.find(B=>B.id===n.taskId);if(Q&&Q.status==="cancelled")throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}let ae=zt.map(Q=>({role:Q.role==="user"?"user":"model",parts:[{text:Q.text}]}));r&&r(`[Subagent Turn ${De+1}]...`);let on=["Fast","Low","Medium","High"],Vn=process.env.SUBAGENT_THINKING,No=on.includes(Vn)?Vn:"Low",Bo=(await El(u,M,ae,x,No)).text||"",Pn=ma(Nt(Bo).trim());qt=Pn,r&&r(`[Subagent Response]
861
+ Current Time: ${b}
862
+ === END SYSTEM PROMPT ===`,zt=[{role:"user",text:`Complete this task: ${e}`}],Ne=0,qt="";for(;Ne<o;){let Fe=await Gi("subagent",u);if(!Fe.allowed)throw new Error(Fe.reason||`Budget Exhausted for Provider (${u?.aiProvider||"Subagent"})`);if(ut){if(n?.taskId&&typeof Nt<"u"){let Q=Nt.find(B=>B.id===n.taskId);Q&&(Q.status="cancelled")}throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}if(n?.taskId&&typeof Nt<"u"){let Q=Nt.find(B=>B.id===n.taskId);if(Q&&Q.status==="cancelled")throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}let ae=zt.map(Q=>({role:Q.role==="user"?"user":"model",parts:[{text:Q.text}]}));r&&r(`[Subagent Turn ${Ne+1}]...`);let on=["Fast","Low","Medium","High"],Vn=process.env.SUBAGENT_THINKING,No=on.includes(Vn)?Vn:"Low",Bo=(await El(u,M,ae,x,No)).text||"",Pn=ma(Ft(Bo).trim());qt=Pn,r&&r(`[Subagent Response]
862
863
  ${Pn}
863
- `),zt.push({role:"agent",text:Pn});let zn=Mn(Pn);if(zn.length===0)break;let Yt=zn.filter(Q=>Q.toolName.toLowerCase()==="askmain"||Q.toolName.toLowerCase()==="ask_main"),$n=!1,Re="";for(let Q of zn){if(ut){if(n?.taskId&&typeof Dt<"u"){let A=Dt.find(oe=>oe.id===n.taskId);A&&(A.status="cancelled")}throw new Error("Subagent task was cancelled.")}if(n?.taskId&&typeof Dt<"u"){let A=Dt.find(oe=>oe.id===n.taskId);if(A&&A.status==="cancelled")throw new Error("Subagent task was cancelled.")}let B=Q.toolName.toLowerCase();if(B==="askuser"&&(B="ask"),B==="askmain"||B==="ask_main"){if($n)continue;$n=!0;let A="";if(Yt.length===1?A=D(Yt[0].args).question||Yt[0].args:A=Yt.map((oe,Xt)=>{let Ft=D(oe.args);return`Q${Xt+1}: ${Ft.question||oe.args}`}).join(`
864
+ `),zt.push({role:"agent",text:Pn});let zn=Mn(Pn);if(zn.length===0)break;let Yt=zn.filter(Q=>Q.toolName.toLowerCase()==="askmain"||Q.toolName.toLowerCase()==="ask_main"),$n=!1,Re="";for(let Q of zn){if(ut){if(n?.taskId&&typeof Nt<"u"){let A=Nt.find(oe=>oe.id===n.taskId);A&&(A.status="cancelled")}throw new Error("Subagent task was cancelled.")}if(n?.taskId&&typeof Nt<"u"){let A=Nt.find(oe=>oe.id===n.taskId);if(A&&A.status==="cancelled")throw new Error("Subagent task was cancelled.")}let B=Q.toolName.toLowerCase();if(B==="askuser"&&(B="ask"),B==="askmain"||B==="ask_main"){if($n)continue;$n=!0;let A="";if(Yt.length===1?A=D(Yt[0].args).question||Yt[0].args:A=Yt.map((oe,Xt)=>{let Bt=D(oe.args);return`Q${Xt+1}: ${Bt.question||oe.args}`}).join(`
864
865
  `),n.onAskMain){r&&r(`[Executing Tool] AskMain("${A}")...`);let oe=await n.onAskMain(A);r&&r(`[Action Result]
865
866
  Answer from Main Agent: ${oe}
866
867
  `),Re+=`[ACTION RESULT for AskMain]: Answer from Main Agent: ${oe}
867
868
 
868
- `,await Ct("toolSuccess")}else Re+=`[ACTION RESULT for AskMain]: ERROR: Main agent communication channel not available.
869
+ `,await vt("toolSuccess")}else Re+=`[ACTION RESULT for AskMain]: ERROR: Main agent communication channel not available.
869
870
 
870
871
  `;continue}if(!(i?i.some(A=>A.toLowerCase()===B):!0)){let A=`ERROR: Tool [${Q.toolName}] is not in the allowed tools list for this subagent.`;r&&r(`[Blocked Tool Call] ${Q.toolName} - not allowed
871
872
  `),Re+=`${A}
872
873
 
873
- `;continue}if(B==="exec_command"||B==="execcommand"||B==="run"){let A=D(Q.args).command||"",oe=V(A);if(!oe.allowed){let Xt=`ERROR: [SECURITY RESTRICTION] Subagent execution blocked command: ${oe.reason}`;r&&r(`[Blocked Command] ${A} - ${oe.reason}
874
+ `;continue}if(B==="exec_command"||B==="execcommand"||B==="run"){let A=D(Q.args).command||"",oe=z(A);if(!oe.allowed){let Xt=`ERROR: [SECURITY RESTRICTION] Subagent execution blocked command: ${oe.reason}`;r&&r(`[Blocked Command] ${A} - ${oe.reason}
874
875
  `),Re+=`${Xt}
875
876
 
876
- `;continue}}let pt="";if(B==="web_search"||B==="websearch")pt=`\u2714 \x1B[95mSearched\x1B[0m: ${D(Q.args).query||""}`;else if(B==="web_scrape"||B==="webscrape")pt=`\u2714 \x1B[95mScraped\x1B[0m: ${D(Q.args).url||""}`;else if(B==="search_keyword"||B==="searchkeyword"||B==="codesearch"||B==="code_search"){let A=D(Q.args),oe=A.keyword||"",Xt=A.path||"";pt=`${oe?"\u2714":"\u2718"} \x1B[95mSearched\x1B[0m: ${oe||"No Query"}${Xt?` \u2192 ${Xt.replaceAll("\\","/")}`:""}`}else if(B==="view_file"||B==="viewfile"||B==="readfile")pt=`\u2714 \x1B[95mRead\x1B[0m: ${(D(Q.args).path||"").replaceAll("\\","/")}`;else if(B==="find_file"||B==="findfile"){let A=D(Q.args),oe=A.basename||A.name||A.path||A.file||A.query||"";pt=`${oe?"\u2714":"\u2718"} \x1B[95mLocated\x1B[0m: ${oe||"No Query"}`}else if(B==="list_files"||B==="read_folder"||B==="readfolder"){let A=D(Q.args).path||null,oe=D(Q.args).recurse||0;pt=`${A?"\u2714":"\u2718"} \x1B[95mBrowsed\x1B[0m: ${A?`${A.replaceAll("\\","/")}${oe>0?`${A.endsWith("/")?`*${oe}`:`/*${oe}`}`:`${A.endsWith("/")?"":"/"}`}`:""}`}else if(B==="write_file"||B==="writefile"){let A=D(Q.args).path||null;pt=`${A?"\u2714":"\u2718"} \x1B[95mCreated\x1B[0m: ${A?`${A.replaceAll("\\","/")}`:"No File Changes"}`}else if(B==="update_file"||B==="updatefile"||B==="patchfile"||B==="patch_file"){let A=D(Q.args),oe=A.path||null,Ft=Object.entries(A).some(([kt,Ln])=>kt.startsWith("searchContent")&&typeof Ln=="string"&&Ln.startsWith("^LINE:"))?"\u1361":":";pt=`${oe?"\u2714":"\u2718"} \x1B[95mEdited\x1B[0m${Ft} ${oe?`${oe.replaceAll("\\","/")}`:"No File Changes"}`}else if(B==="exec_command"||B==="execcommand"||B==="run"){let A=D(Q.args).command||null;pt=`${A?"\u2714":"\u2718"} \x1B[95mExecuted\x1B[0m: ${A?A.slice(0,100)+(A.length>100?"...":""):"No Command"}`}else if(B==="file_map"||B==="filemap"){let A=D(Q.args).path||"";pt=`${A?"\u2714":"\u2718"} \x1B[95mIndexed\x1B[0m: ${A?`${A.replaceAll("\\","/")}`:"File Not Found"}`}else if(B==="await"){let{time:A}=D(Q.args),oe=parseFloat(A)||0;oe<10&&(oe=10),oe>180&&(oe=180),pt=`\u2714 \x1B[95mAwaiting\x1B[0m \u2192 ${(Ft=>{if(Ft>=60){let kt=Math.floor(Ft/60),Ln=Ft%60;return`${kt}m${Ln>0?` ${Ln}s`:""}`}return`${Ft}s`})(oe)}`}else{let A=Ss[B]||Q.toolName,oe=Kn(B,Q.args);pt=`\u2714 \x1B[95m${A}\x1B[0m${oe?`: ${oe}`:""}`}n.onVisualFeedback&&pt&&n.onVisualFeedback(pt),r&&r(`[Executing Tool] ${Q.toolName}(${Q.args})...`);try{let A=await us(Q.toolName,Q.args,{...n,mode:"Flux"});r&&r(`[Action Result]
877
+ `;continue}}let pt="";if(B==="web_search"||B==="websearch")pt=`\u2714 \x1B[95mSearched\x1B[0m: ${D(Q.args).query||""}`;else if(B==="web_scrape"||B==="webscrape")pt=`\u2714 \x1B[95mScraped\x1B[0m: ${D(Q.args).url||""}`;else if(B==="search_keyword"||B==="searchkeyword"||B==="codesearch"||B==="code_search"){let A=D(Q.args),oe=A.keyword||"",Xt=A.path||"";pt=`${oe?"\u2714":"\u2718"} \x1B[95mSearched\x1B[0m: ${oe||"No Query"}${Xt?` \u2192 ${Xt.replaceAll("\\","/")}`:""}`}else if(B==="view_file"||B==="viewfile"||B==="readfile")pt=`\u2714 \x1B[95mRead\x1B[0m: ${(D(Q.args).path||"").replaceAll("\\","/")}`;else if(B==="find_file"||B==="findfile"){let A=D(Q.args),oe=A.basename||A.name||A.path||A.file||A.query||"";pt=`${oe?"\u2714":"\u2718"} \x1B[95mLocated\x1B[0m: ${oe||"No Query"}`}else if(B==="list_files"||B==="read_folder"||B==="readfolder"){let A=D(Q.args).path||null,oe=D(Q.args).recurse||0;pt=`${A?"\u2714":"\u2718"} \x1B[95mBrowsed\x1B[0m: ${A?`${A.replaceAll("\\","/")}${oe>0?`${A.endsWith("/")?`*${oe}`:`/*${oe}`}`:`${A.endsWith("/")?"":"/"}`}`:""}`}else if(B==="write_file"||B==="writefile"){let A=D(Q.args).path||null;pt=`${A?"\u2714":"\u2718"} \x1B[95mCreated\x1B[0m: ${A?`${A.replaceAll("\\","/")}`:"No File Changes"}`}else if(B==="update_file"||B==="updatefile"||B==="patchfile"||B==="patch_file"){let A=D(Q.args),oe=A.path||null,Bt=Object.entries(A).some(([kt,Ln])=>kt.startsWith("searchContent")&&typeof Ln=="string"&&Ln.startsWith("^LINE:"))?"\u1361":":";pt=`${oe?"\u2714":"\u2718"} \x1B[95mEdited\x1B[0m${Bt} ${oe?`${oe.replaceAll("\\","/")}`:"No File Changes"}`}else if(B==="exec_command"||B==="execcommand"||B==="run"){let A=D(Q.args).command||null;pt=`${A?"\u2714":"\u2718"} \x1B[95mExecuted\x1B[0m: ${A?A.slice(0,100)+(A.length>100?"...":""):"No Command"}`}else if(B==="file_map"||B==="filemap"){let A=D(Q.args).path||"";pt=`${A?"\u2714":"\u2718"} \x1B[95mIndexed\x1B[0m: ${A?`${A.replaceAll("\\","/")}`:"File Not Found"}`}else if(B==="await"){let{time:A}=D(Q.args),oe=parseFloat(A)||0;oe<10&&(oe=10),oe>180&&(oe=180),pt=`\u2714 \x1B[95mAwaiting\x1B[0m \u2192 ${(Bt=>{if(Bt>=60){let kt=Math.floor(Bt/60),Ln=Bt%60;return`${kt}m${Ln>0?` ${Ln}s`:""}`}return`${Bt}s`})(oe)}`}else{let A=Ss[B]||Q.toolName,oe=Kn(B,Q.args);pt=`\u2714 \x1B[95m${A}\x1B[0m${oe?`: ${oe}`:""}`}n.onVisualFeedback&&pt&&n.onVisualFeedback(pt),r&&r(`[Executing Tool] ${Q.toolName}(${Q.args})...`);try{let A=await us(Q.toolName,Q.args,{...n,mode:"Flux"});r&&r(`[Action Result]
877
878
  ${A}
878
879
  `),Re+=`[ACTION RESULT for ${Q.toolName}]: ${A}
879
880
 
880
- `,await Ct("toolSuccess")}catch(A){let oe=`ERROR: Execution failed for [${Q.toolName}]: ${A.message}`;r&&r(`[Tool Error] ${oe}
881
+ `,await vt("toolSuccess")}catch(A){let oe=`ERROR: Execution failed for [${Q.toolName}]: ${A.message}`;r&&r(`[Tool Error] ${oe}
881
882
  `),Re+=`${oe}
882
883
 
883
- `,await Ct("toolFailure")}}let qn="";if(n?.taskId&&typeof Dt<"u"){let Q=Dt.find(B=>B.id===n.taskId);if(Q&&Q.pendingSteerMessages&&Q.pendingSteerMessages.length>0){let B=[...Q.pendingSteerMessages];Q.pendingSteerMessages=[];for(let Xn of B)qn+=`
884
+ `,await vt("toolFailure")}}let qn="";if(n?.taskId&&typeof Nt<"u"){let Q=Nt.find(B=>B.id===n.taskId);if(Q&&Q.pendingSteerMessages&&Q.pendingSteerMessages.length>0){let B=[...Q.pendingSteerMessages];Q.pendingSteerMessages=[];for(let Xn of B)qn+=`
884
885
 
885
- [STEERING INSTRUCTION FROM MAIN AGENT]: ${Xn}`,r&&r(`[Subagent Steered] ${Xn}`)}}let Yn=(Re.trim()+qn).trim();zt.push({role:"user",text:Yn}),De++}return qt};export{ao as a,wi as b,Jc as c,Qc as d,wc as e,bc as f,ro as g,Sc as h,ci as i,di as j,Nc as k,Fc as l,wl as m,Vd as n,bl as o,Sl as p,bs as q,Nt as r,ki as s,ma as t,zd as u,qd as v,Yd as w,pa as x,Xd as y,Ti as z,da as A,Cl as B,Mn as C,Jd as D,El as E,Qd as F,Zd as G};
886
+ [STEERING INSTRUCTION FROM MAIN AGENT]: ${Xn}`,r&&r(`[Subagent Steered] ${Xn}`)}}let Yn=(Re.trim()+qn).trim();zt.push({role:"user",text:Yn}),Ne++}return qt};export{ao as a,bi as b,Jc as c,Qc as d,bc as e,wc as f,ro as g,Sc as h,ci as i,di as j,Nc as k,Fc as l,bl as m,Vd as n,wl as o,Sl as p,ws as q,Ft as r,ki as s,ma as t,zd as u,qd as v,Yd as w,pa as x,Xd as y,Ti as z,da as A,Cl as B,Mn as C,Jd as D,El as E,Qd as F,Zd as G};