fluxflow-cli 4.41.0 → 4.42.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{a as Is}from"./chunk-HFTI3R3Q.js";import{a as Ao}from"./chunk-52STSLCN.js";import{a as Vt}from"./chunk-56EJGQU3.js";import{c as Oi,g as Li,h as Cs,i as Rs}from"./chunk-M46I73DX.js";import{a as _s,c as vs}from"./chunk-CTKW7YYV.js";import{b as $i,h as Ms}from"./chunk-WTMVNZDA.js";import{a as ei}from"./chunk-6EYQQ7GQ.js";import{a as Ps}from"./chunk-4BLSASW6.js";import{a as H}from"./chunk-Y5JU726N.js";import{b as Mi}from"./chunk-FXRFFNRK.js";import{f as ko,l as _t,n as pt,p as Pi,q as Es}from"./chunk-XDCDANJJ.js";import{b as To}from"./chunk-Y73PU7CC.js";import{l as rt,m as Zo,q as ae}from"./chunk-KMOTPBF5.js";import{c as Rt,d as so,e as Qo}from"./chunk-P5HBJA23.js";import{a as Dn,b as qo,d as Rn,e as Xo,k as zn,l as Jo,m as vi,r as Ii,w as wo,x as So,y as As}from"./chunk-26BQ45XP.js";import{GoogleGenAI as Jr,ThinkingLevel as He,HarmBlockThreshold as Bn,HarmCategory as Un}from"@google/genai";var Os=(e=!0,n=!0)=>`
1
+ import{a as Ms}from"./chunk-HFTI3R3Q.js";import{a as Eo}from"./chunk-52STSLCN.js";import{a as qt}from"./chunk-56EJGQU3.js";import{c as Oi,g as Li,h as Rs,i as _s}from"./chunk-ZYLACK6T.js";import{a as vs,c as Is}from"./chunk-CTKW7YYV.js";import{b as $i,h as Ps}from"./chunk-Z5D4VQSG.js";import{a as ti}from"./chunk-6EYQQ7GQ.js";import{a as Os}from"./chunk-4BLSASW6.js";import{a as j}from"./chunk-Y5JU726N.js";import{b as Mi}from"./chunk-FXRFFNRK.js";import{f as Ao,l as vt,n as bt,p as Pi,q as Cs}from"./chunk-XDCDANJJ.js";import{b as ko}from"./chunk-Y73PU7CC.js";import{l as ct,m as ei,q as ae}from"./chunk-KMOTPBF5.js";import{c as _t,d as ao,e as Zo}from"./chunk-P5HBJA23.js";import{a as Dn,b as Xo,d as _n,e as Jo,k as zn,l as Qo,m as vi,r as Ii,w as So,x as To,y as Es}from"./chunk-26BQ45XP.js";import{GoogleGenAI as Qr,ThinkingLevel as Ke,HarmBlockThreshold as Bn,HarmCategory as Un}from"@google/genai";var Ls=(e=!0,n=!0)=>`
2
2
  To use tools, must output exactly '[action:ActionName(arg1="value1")]' structured string in chat response \u2190 no exception
3
3
 
4
4
  -- Chat Management Tools --
@@ -25,7 +25,7 @@ Usage Rules:
25
25
  - Chat title is mandatory
26
26
  - Temporary memory is mandatory
27
27
  - When called user memory, still use Temporary Memory
28
- - Must not ignore any tool calls in given context of chat between user & agent`:""}`.trim();var ti={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 ln from"fs";import mn from"path";import _a from"os";import un from"fs";import Fn from"path";import Vs from"fs";import Ni from"path";import{execSync as Ys}from"child_process";import{fileURLToPath as Ea}from"url";var Ls=`# FluxFlow CLI Startup & Flags Reference
28
+ - Must not ignore any tool calls in given context of chat between user & agent`:""}`.trim();var ni={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 cn from"fs";import pn from"path";import _a from"os";import gn from"fs";import Fn from"path";import Ys from"fs";import Ni from"path";import{execSync as zs}from"child_process";import{fileURLToPath as Ea}from"url";var $s=`# FluxFlow CLI Startup & Flags Reference
29
29
 
30
30
  Launch command syntax:
31
31
  fluxflow [options]
@@ -54,7 +54,7 @@ fluxflow [options]
54
54
  * --help commands \u2192 In-chat slash commands list
55
55
  * --playground \u2192 Launch Playground mode
56
56
  * --prompt, -p \u2192 Non interactive CLI chat, no tools. --new for new headless chat. Holds conversation context upto 10m inactivity or 69 turns. Supports piping from shell, --run if want the command to visible in context. eg \`fluxflow --run "git diff" -p "summarize this" --new\`
57
- `;var $s=`# Env Variables
57
+ `;var Ns=`# Env Variables
58
58
 
59
59
  * Locations:
60
60
  * Shell
@@ -84,7 +84,7 @@ fluxflow [options]
84
84
 
85
85
  * I_HAVE_TOO_MUCH_MONEY \u2192 (true|false, default: false) Fun Flag; inserts random padding in system prompt to break provider caching. Not intended for paid APIs unless user hate money
86
86
  * GOOGLE_GEMMA_NONSENSE \u2192 (true|false, default: false) for the 16k TPM nonsense of gemma models on gemini API. False defaults to 256k
87
- `;var Ns=`# Fluxflow in-app /commands
87
+ `;var Ds=`# Fluxflow in-app /commands
88
88
 
89
89
  Trigger in chat via /command
90
90
 
@@ -131,7 +131,7 @@ Trigger in chat via /command
131
131
  * /update latest \u2192 Install latest release
132
132
  * /fluxflow global/saves \u2192 Openes fluxflow storage paths in explorer
133
133
  * /move \u2192 Transfer Playground session data to CWD/playground-export
134
- `;var Ds=`# FluxFlow In-App Settings Reference
134
+ `;var Fs=`# FluxFlow In-App Settings Reference
135
135
 
136
136
  Open in chat via /settings
137
137
 
@@ -199,7 +199,7 @@ Open in chat via /settings
199
199
  - Best for Luxurious Experience: Subagents (on), compact large results (off), auto exclue metadata (off), Image History (Max), Keep reasoning content (on), Emergency Recovery (on), Auto truncate results (off), Memory (on), Security Preset (Autonomous), FluxFlow IDE Companion
200
200
 
201
201
  - Max Cache Hit: Subagents (off), compact large results (on), auto exclue metadata (on), Image History (Low), Keep reasoning content (off), Emergency Recovery (off), Auto truncate results (off), Memory (off), No FluxFlow IDE Companion
202
- `;var Fs=`# FluxFlow Tool Reference
202
+ `;var Bs=`# FluxFlow Tool Reference
203
203
 
204
204
  ## Protocol: [action:ActionName(arg1="val")]
205
205
 
@@ -240,7 +240,7 @@ Open in chat via /settings
240
240
  * KeyboardTyping(text, autoPressEnter?) \u2192 Type string
241
241
  * KeyPress(key) \u2192 Key/combo dispatch ("ctrl;c", "enter", etc.)
242
242
  * RecaptureScreen() \u2192 Fresh screenshot + coordinate grid
243
- `;var Bs=`# Fluxflow Architecture
243
+ `;var Us=`# Fluxflow Architecture
244
244
 
245
245
  ## 1. Terminal Engine
246
246
  * Framework: React + Ink terminal UI
@@ -270,7 +270,7 @@ Open in chat via /settings
270
270
  ## 6. IDE Bridge
271
271
  * Protocol: WebSocket on ws://localhost:56832
272
272
  * State Sync: Focused file, open tabs, cursor line, selection, diagnostics
273
- `;var Us=`# FluxFlow Sub-Agents & Multi-Agent Architecture
273
+ `;var Ws=`# FluxFlow Sub-Agents & Multi-Agent Architecture
274
274
 
275
275
  ## Execution Modes
276
276
  * InvokeSync \u2192 Synchronous blocking delegation; main agent halts until sub-agent finishes task
@@ -301,7 +301,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
301
301
  * SUBAGENT_MODEL \u2192 Target model override
302
302
  * SUBAGENT_PROVIDER \u2192 Target provider override
303
303
  * Setting SubAgentModel=ENV in settings pulls directly from environment overrides
304
- `;var Ws=`# FluxFlow Security, Sandboxing & Safety
304
+ `;var Gs=`# FluxFlow Security, Sandboxing & Safety
305
305
 
306
306
  ## Human-in-the-Loop Governance
307
307
  * Execution Approval Gate \u2192 Destructive commands and high-risk file modifications require explicit user authorization (Allow / Deny)
@@ -324,7 +324,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
324
324
  * Emergency Rollback \u2192 Automatic pre-turn file snapshots; Agent can still fix it (default: OFF) \u2192 references/SETTINGS.md
325
325
  * Git-less Checkpoint Reversion \u2192 Trigger conversational changes rollback via double-ESC
326
326
  * External Sanctuary Redirection \u2192 Move ~/.fluxflow data sanctuary (chats, keys etc)
327
- `;var Gs=`# Fluxflow IDE Companion
327
+ `;var Hs=`# Fluxflow IDE Companion
328
328
 
329
329
  ## WebSocket Bridge Protocol
330
330
  * Local Bridge \u2192 Runs on ws://localhost:56832 connecting FluxFlow CLI with the companion editor extension
@@ -342,7 +342,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
342
342
  * File Focus \u2192 Automatically opens edited files in active IDE window
343
343
  * Diff Preview \u2192 Streams side-by-side or inline diff highlights (showDiff, highlightDiff) directly in editor
344
344
  * Status Bar Sync \u2192 Real-time agent status (thinking, running tool, awaiting input) reflected in IDE status bar
345
- `;var Hs=`# Fluxflow Modes
345
+ `;var js=`# Fluxflow Modes
346
346
 
347
347
  ## Modes Overview (TAB to cycle)
348
348
  * [Flux] (Workspace / Dev) \u2192 Primary coding & workspace agent
@@ -360,7 +360,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
360
360
  * User Inquiry: AskUser \u2192 [Universal]
361
361
  * Document Creation: WritePDF, WriteDoc \u2192 [Flow]
362
362
  * GUI & Desktop Automation: Click, Scroll, KeyboardTyping, KeyPress, RecaptureScreen \u2192 [ICU] | [FluxCU]
363
- `;var js=`# FluxFlow AI Providers & Setup
363
+ `;var Ks=`# FluxFlow AI Providers & Setup
364
364
 
365
365
  ## Supported Providers
366
366
  * Gemini | NVIDIA NIM | DeepSeek | Mistral | Ollama Local/Cloud | InferX | SenseNova | Poolside | OpenRouter | AIHubMix | Experiential Labs | TokenHarbor | APInex | Infron
@@ -398,7 +398,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
398
398
  2. Set ENV ENABLE_9ROUTER=true
399
399
  * NINEROUTER_URL = https://.../v1 Supports external openai compatible endpoints. For direct URL changes no need for 9router package. But 9router package gives better reliability and Anthropic stye endpoint support
400
400
  * NINEROUTER_KEY = If any needed
401
- `;var Ks=`# Fluxflow Instructions & Skills System
401
+ `;var Vs=`# Fluxflow Instructions & Skills System
402
402
 
403
403
  ## 1. Instructions (AGENTS.md / FLUXFLOW.md root only)
404
404
  * Locations:
@@ -442,14 +442,14 @@ Instruction for this model ID across all providers.
442
442
 
443
443
  * On-Demand Reference System:
444
444
  * Reference: Offload deep/contexual specs to **/{SKILL.md,skill-reference-folder/*.md} & reference in SKILL.md. Saves tokens
445
- `;var ni="v4";try{let e=Ni.dirname(Ea(import.meta.url)),n=[Ni.join(e,"../../package.json"),Ni.join(e,"../package.json")],t=!1;for(let i of n)if(Vs.existsSync(i)){let o=JSON.parse(Vs.readFileSync(i,"utf8"));if(o.version){ni=o.version,t=!0;break}}if(!t)try{let i=Ys("fluxflow -v",{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"],timeout:2e3}).trim();i&&(i.startsWith("v")||/^\d+\.\d+/.test(i))&&(ni=i,t=!0)}catch{}if(!t)try{let i=Ys("curl -s --max-time 3 https://raw.githubusercontent.com/KushalRoyChowdhury/fluxflow-cli/main/package.json",{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"]}),o=JSON.parse(i);o.version&&(ni=o.version)}catch{}}catch{}var Di={"SKILL.md":`---
445
+ `;var oi="v4";try{let e=Ni.dirname(Ea(import.meta.url)),n=[Ni.join(e,"../../package.json"),Ni.join(e,"../package.json")],t=!1;for(let i of n)if(Ys.existsSync(i)){let o=JSON.parse(Ys.readFileSync(i,"utf8"));if(o.version){oi=o.version,t=!0;break}}if(!t)try{let i=zs("fluxflow -v",{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"],timeout:2e3}).trim();i&&(i.startsWith("v")||/^\d+\.\d+/.test(i))&&(oi=i,t=!0)}catch{}if(!t)try{let i=zs("curl -s --max-time 3 https://raw.githubusercontent.com/KushalRoyChowdhury/fluxflow-cli/main/package.json",{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"]}),o=JSON.parse(i);o.version&&(oi=o.version)}catch{}}catch{}var Di={"SKILL.md":`---
446
446
  name: fluxflow
447
447
  description: System Generated Documentation. Read this if asked anything regarding FluxFlow Harness
448
448
  ---
449
449
 
450
450
  # FluxFlow, by Kushal Roy Chowdhury
451
451
  Open Source Terminal AI Assistant
452
- App Version: ${ni}. Check Updates: fluxflow --update check. Update: fluxflow --update
452
+ App Version: ${oi}. Check Updates: fluxflow --update check. Update: fluxflow --update
453
453
  GitHub: https://github.com/KushalRoyChowdhury/fluxflow-cli
454
454
  Public Docs: https://fluxflow-cli.onrender.com
455
455
 
@@ -469,24 +469,24 @@ Public Docs: https://fluxflow-cli.onrender.com
469
469
 
470
470
  Default Context Length: 256k Tokens. Can be changed via ENV/In-app Settings \u2192 references/{SETTINGS,ENV}.md
471
471
 
472
- Docs missing required info? Say you are not sure enough to answer. Dont give wrong info`,"references/MODES.md":Hs,"references/PROVIDERS.md":js,"references/PLUGINS.md":Ks,"references/STARTUP.md":Ls,"references/ENV.md":$s,"references/COMMANDS.md":Ns,"references/SETTINGS.md":Ds,"references/TOOLS.md":Fs,"references/ARCHITECTURE.md":Bs,"references/SUB_AGENTS.md":Us,"references/SECURITY.md":Ws,"references/IDE.md":Gs};var zs=()=>{try{let e=Fn.join(Dn,"skills","fluxflow"),n=Fn.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){un.existsSync(e)&&un.rmSync(e,{recursive:!0,force:!0});return}let i=new Set(Object.keys(Di).map(o=>Fn.normalize(o)));for(let[o,r]of Object.entries(Di)){let d=Fn.join(e,o),a=Fn.dirname(d);un.existsSync(a)||un.mkdirSync(a,{recursive:!0});let u=r.trim()+`
473
- `,p=null;un.existsSync(d)&&(p=un.readFileSync(d,"utf8")),p!==u&&un.writeFileSync(d,u,"utf8")}if(un.existsSync(n)){let o=un.readdirSync(n);for(let r of o){let d=Fn.normalize(Fn.join("references",r));if(!i.has(d)){let a=Fn.join(n,r);try{un.rmSync(a,{recursive:!0,force:!0})}catch{}}}}}catch{}};import{WebSocket as oi}from"ws";var Dt=null,ro=!1,Ca="ws://localhost:56832",Fi=[],ao=null,Bi=null,Ui=null,qs="2.0.0",ic=e=>{qs=e,Xs()},Wi=e=>{Bi=e},sc=e=>{Ui=e},Xs=()=>{if(Dt||ro)return;ro=!0;let e=new oi(Ca);e.on("open",()=>{for(Dt=e,ro=!1,Dt.send(JSON.stringify({command:"version",version:qs,pid:process.pid,ppid:process.ppid,cwd:process.cwd()}));Fi.length>0;)Dt.send(JSON.stringify(Fi.shift()))}),e.on("message",n=>{try{let t=JSON.parse(n.toString());t.command==="contextResponse"&&ao?(ao(t.data),ao=null):t.command==="securityResponse"&&Bi?Bi(t.result):t.command==="inlineComplete"?Ra(t):t.command==="connectionRejected"&&Ui&&Ui(t)}catch{}}),e.on("error",()=>{ro=!1,Dt=null}),e.on("close",()=>{ro=!1,Dt=null})},Eo=e=>{Dt&&Dt.readyState===oi.OPEN?Dt.send(JSON.stringify(e)):(Fi.push(e),ro||Xs())},lo=()=>Dt!==null&&Dt.readyState===oi.OPEN,Ra=async e=>{let n="";try{let{generateAutoCompletion:t}=await import("./auto_completion-KOKDZVBJ.js");n=await t({prefix:e.prefix||"",suffix:e.suffix||"",fileName:e.fileName||"",language:e.language||"",recentChanges:e.recentChanges||"",clipboard:e.clipboard||""})}catch{n=""}Eo({command:"inlineCompleteResponse",requestId:e.requestId,completion:n||""})},rc=e=>{Eo({command:"status",status:e})},qn=()=>new Promise(e=>{if(!Dt||Dt.readyState!==oi.OPEN){e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]});return}ao=e,Dt.send(JSON.stringify({command:"requestContext"})),setTimeout(()=>{ao===e&&(e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]}),ao=null)},1e3)}),Js=e=>{Eo({command:"open",filePath:e})},Gi=(e,n,t)=>{Eo({command:"showDiff",filePath:e,originalContent:n,modifiedContent:t})},Qs=(e,n)=>{Eo({command:"closeDiff",filePath:e,result:n})};var Po=(e,n)=>{try{if(!ln.existsSync(e))return null;let t=Array.isArray(n)?n.map(o=>o.toLowerCase()):[n.toLowerCase()],i=ln.readdirSync(e);for(let o of t){let r=i.find(d=>d.toLowerCase()===o);if(r){let d=mn.join(e,r);if(ln.statSync(d).isFile())return d}}}catch{}return null},Yi=(e,n)=>{let t=Po(e,n);if(t)try{return ln.readFileSync(t,"utf8")}catch{}return""},Zs=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"]),zi=(e=process.cwd(),n=0,t=8)=>{let i=[];if(n>t)return i;try{if(!ln.existsSync(e))return i;let o=ln.readdirSync(e,{withFileTypes:!0});for(let r of o){let d=r.name,a=mn.join(e,d);if(r.isDirectory())!Zs.has(d)&&!Zs.has(d.toLowerCase())&&i.push(...zi(a,n+1,t));else if(r.isFile()){let u=d.toLowerCase();(u==="agents.md"||u==="agent.md")&&i.push(a)}}}catch{}return i},er=(e,n=2)=>{if(!e)return"";let t=" ".repeat(n);return e.split(/\r?\n/).map(i=>t+i).join(`
474
- `)},sr=()=>Po(Dn,["agents.md","agent.md"]),rr=()=>Po(process.cwd(),["agents.md","agent.md"]),ar=()=>Po(Dn,["fluxflow.md"]),lr=()=>Po(process.cwd(),["fluxflow.md"]),Ro=sr(),ii=rr(),gn=zi(),_o=ar(),vo=lr(),tr=null,Vi="",cr=!1,va=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&&(Vi=o[1].trim(),process.env.NO_INS=!0),/<><\s*NO_INS/.test(t)&&(cr=!0),i.trim()},Ia=()=>{Ro=sr();let e=Ro?Yi(Dn,["agents.md","agent.md"]).trim():"";return e.length===0?(Ro=null,""):e},Ma=()=>{if(gn=zi(),ii=rr(),!gn||gn.length===0)return"";let e=process.cwd(),n=[...gn].sort((o,r)=>{let d=mn.relative(e,o).replace(/\\/g,"/"),a=mn.relative(e,r).replace(/\\/g,"/"),u=!d.includes("/"),p=!a.includes("/");return u&&!p?-1:!u&&p?1:d.localeCompare(a)}),t=[],i=[];for(let o of n)try{let r=ln.readFileSync(o,"utf8").trim();if(!r||r.length===0)continue;t.push(o);let d=mn.relative(e,o).replace(/\\/g,"/");if(!d.includes("/"))i.push(er(r,2));else{let u=mn.dirname(d)+"/:";i.push(`${u}
475
- ${er(r,2)}`)}}catch{}return gn=t,gn.length===0&&(ii=null),i.join(`
472
+ Docs missing required info? Say you are not sure enough to answer. Dont give wrong info`,"references/MODES.md":js,"references/PROVIDERS.md":Ks,"references/PLUGINS.md":Vs,"references/STARTUP.md":$s,"references/ENV.md":Ns,"references/COMMANDS.md":Ds,"references/SETTINGS.md":Fs,"references/TOOLS.md":Bs,"references/ARCHITECTURE.md":Us,"references/SUB_AGENTS.md":Ws,"references/SECURITY.md":Gs,"references/IDE.md":Hs};var qs=()=>{try{let e=Fn.join(Dn,"skills","fluxflow"),n=Fn.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){gn.existsSync(e)&&gn.rmSync(e,{recursive:!0,force:!0});return}let i=new Set(Object.keys(Di).map(o=>Fn.normalize(o)));for(let[o,r]of Object.entries(Di)){let d=Fn.join(e,o),a=Fn.dirname(d);gn.existsSync(a)||gn.mkdirSync(a,{recursive:!0});let u=r.trim()+`
473
+ `,p=null;gn.existsSync(d)&&(p=gn.readFileSync(d,"utf8")),p!==u&&gn.writeFileSync(d,u,"utf8")}if(gn.existsSync(n)){let o=gn.readdirSync(n);for(let r of o){let d=Fn.normalize(Fn.join("references",r));if(!i.has(d)){let a=Fn.join(n,r);try{gn.rmSync(a,{recursive:!0,force:!0})}catch{}}}}}catch{}};import{WebSocket as ii}from"ws";var Ut=null,lo=!1,Ca="ws://localhost:56832",Fi=[],co=null,Bi=null,Ui=null,Xs="2.0.0",ic=e=>{Xs=e,Js()},Wi=e=>{Bi=e},sc=e=>{Ui=e},Js=()=>{if(Ut||lo)return;lo=!0;let e=new ii(Ca);e.on("open",()=>{for(Ut=e,lo=!1,Ut.send(JSON.stringify({command:"version",version:Xs,pid:process.pid,ppid:process.ppid,cwd:process.cwd()}));Fi.length>0;)Ut.send(JSON.stringify(Fi.shift()))}),e.on("message",n=>{try{let t=JSON.parse(n.toString());t.command==="contextResponse"&&co?(co(t.data),co=null):t.command==="securityResponse"&&Bi?Bi(t.result):t.command==="inlineComplete"?Ra(t):t.command==="connectionRejected"&&Ui&&Ui(t)}catch{}}),e.on("error",()=>{lo=!1,Ut=null}),e.on("close",()=>{lo=!1,Ut=null})},Co=e=>{Ut&&Ut.readyState===ii.OPEN?Ut.send(JSON.stringify(e)):(Fi.push(e),lo||Js())},fo=()=>Ut!==null&&Ut.readyState===ii.OPEN,Ra=async e=>{let n="";try{let{generateAutoCompletion:t}=await import("./auto_completion-EJXGALEE.js");n=await t({prefix:e.prefix||"",suffix:e.suffix||"",fileName:e.fileName||"",language:e.language||"",recentChanges:e.recentChanges||"",clipboard:e.clipboard||""})}catch{n=""}Co({command:"inlineCompleteResponse",requestId:e.requestId,completion:n||""})},rc=e=>{Co({command:"status",status:e})},qn=()=>new Promise(e=>{if(!Ut||Ut.readyState!==ii.OPEN){e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]});return}co=e,Ut.send(JSON.stringify({command:"requestContext"})),setTimeout(()=>{co===e&&(e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]}),co=null)},1e3)}),Qs=e=>{Co({command:"open",filePath:e})},Gi=(e,n,t)=>{Co({command:"showDiff",filePath:e,originalContent:n,modifiedContent:t})},Zs=(e,n)=>{Co({command:"closeDiff",filePath:e,result:n})};var Oo=(e,n)=>{try{if(!cn.existsSync(e))return null;let t=Array.isArray(n)?n.map(o=>o.toLowerCase()):[n.toLowerCase()],i=cn.readdirSync(e);for(let o of t){let r=i.find(d=>d.toLowerCase()===o);if(r){let d=pn.join(e,r);if(cn.statSync(d).isFile())return d}}}catch{}return null},Yi=(e,n)=>{let t=Oo(e,n);if(t)try{return cn.readFileSync(t,"utf8")}catch{}return""},er=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"]),zi=(e=process.cwd(),n=0,t=8)=>{let i=[];if(n>t)return i;try{if(!cn.existsSync(e))return i;let o=cn.readdirSync(e,{withFileTypes:!0});for(let r of o){let d=r.name,a=pn.join(e,d);if(r.isDirectory())!er.has(d)&&!er.has(d.toLowerCase())&&i.push(...zi(a,n+1,t));else if(r.isFile()){let u=d.toLowerCase();(u==="agents.md"||u==="agent.md")&&i.push(a)}}}catch{}return i},tr=(e,n=2)=>{if(!e)return"";let t=" ".repeat(n);return e.split(/\r?\n/).map(i=>t+i).join(`
474
+ `)},rr=()=>Oo(Dn,["agents.md","agent.md"]),ar=()=>Oo(process.cwd(),["agents.md","agent.md"]),lr=()=>Oo(Dn,["fluxflow.md"]),cr=()=>Oo(process.cwd(),["fluxflow.md"]),_o=rr(),si=ar(),mn=zi(),vo=lr(),Io=cr(),nr=null,Vi="",dr=!1,va=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&&(Vi=o[1].trim(),process.env.NO_INS=!0),/<><\s*NO_INS/.test(t)&&(dr=!0),i.trim()},Ia=()=>{_o=rr();let e=_o?Yi(Dn,["agents.md","agent.md"]).trim():"";return e.length===0?(_o=null,""):e},Ma=()=>{if(mn=zi(),si=ar(),!mn||mn.length===0)return"";let e=process.cwd(),n=[...mn].sort((o,r)=>{let d=pn.relative(e,o).replace(/\\/g,"/"),a=pn.relative(e,r).replace(/\\/g,"/"),u=!d.includes("/"),p=!a.includes("/");return u&&!p?-1:!u&&p?1:d.localeCompare(a)}),t=[],i=[];for(let o of n)try{let r=cn.readFileSync(o,"utf8").trim();if(!r||r.length===0)continue;t.push(o);let d=pn.relative(e,o).replace(/\\/g,"/");if(!d.includes("/"))i.push(tr(r,2));else{let u=pn.dirname(d)+"/:";i.push(`${u}
475
+ ${tr(r,2)}`)}}catch{}return mn=t,mn.length===0&&(si=null),i.join(`
476
476
 
477
- `).trim()},qi=()=>{_o=ar();let e=_o?Yi(Dn,["fluxflow.md"]).trim():"",n=va(e)?.trim()||"";return n.length===0?(_o=null,""):n},Xi=()=>{vo=lr();let e=vo?Yi(process.cwd(),["fluxflow.md"]).trim():"";return e.length===0?(vo=null,""):e},Ji=Ia(),si=Ma(),Io=qi(),Mo=Xi(),nr=(e,n="",t="")=>{if(!e)return"";let i=t.toLowerCase().trim(),o=n.toLowerCase().trim(),r=mn.posix.basename(o),d=i&&o?`${i}@${o}`:"",a=i&&r?`${i}@${r}`:"",u=x=>!x||!o?!1:x===o||x===r||x===d||x===a,p=[];return e.replace(/<start_provider_([^>\r\n]+)>([\s\S]*?)<end_provider_([^>\r\n]+)>/gi,(x,m,f,s)=>{if(i&&m.trim().toLowerCase()===s.trim().toLowerCase()&&m.trim().toLowerCase()===i){let k=f.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(ue,y,_,W)=>{if(y.trim().toLowerCase()===W.trim().toLowerCase()){let K=y.trim().toLowerCase();if(u(K)){let F=_.trim();F&&p.push(F)}}return""}).trim();k&&p.push(k)}return""}),e.replace(/<start_model_([^>\r\n@]+@[^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n@]+@[^>\r\n]+)>/gi,(x,m,f,s)=>{if(m.trim().toLowerCase()===s.trim().toLowerCase()){let g=m.trim().toLowerCase();if(u(g)){let k=f.trim();k&&p.push(k)}}return""}),e.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(x,m,f,s)=>{if(m.includes("@"))return"";if(m.trim().toLowerCase()===s.trim().toLowerCase()){let g=m.trim().toLowerCase();if(o&&(g===o||g===r)){let k=f.trim();k&&p.push(k)}}return""}),p.join(`
477
+ `).trim()},qi=()=>{vo=lr();let e=vo?Yi(Dn,["fluxflow.md"]).trim():"",n=va(e)?.trim()||"";return n.length===0?(vo=null,""):n},Xi=()=>{Io=cr();let e=Io?Yi(process.cwd(),["fluxflow.md"]).trim():"";return e.length===0?(Io=null,""):e},Ji=Ia(),ri=Ma(),Mo=qi(),Po=Xi(),or=(e,n="",t="")=>{if(!e)return"";let i=t.toLowerCase().trim(),o=n.toLowerCase().trim(),r=pn.posix.basename(o),d=i&&o?`${i}@${o}`:"",a=i&&r?`${i}@${r}`:"",u=x=>!x||!o?!1:x===o||x===r||x===d||x===a,p=[];return e.replace(/<start_provider_([^>\r\n]+)>([\s\S]*?)<end_provider_([^>\r\n]+)>/gi,(x,m,f,s)=>{if(i&&m.trim().toLowerCase()===s.trim().toLowerCase()&&m.trim().toLowerCase()===i){let k=f.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(ue,y,_,W)=>{if(y.trim().toLowerCase()===W.trim().toLowerCase()){let V=y.trim().toLowerCase();if(u(V)){let F=_.trim();F&&p.push(F)}}return""}).trim();k&&p.push(k)}return""}),e.replace(/<start_model_([^>\r\n@]+@[^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n@]+@[^>\r\n]+)>/gi,(x,m,f,s)=>{if(m.trim().toLowerCase()===s.trim().toLowerCase()){let g=m.trim().toLowerCase();if(u(g)){let k=f.trim();k&&p.push(k)}}return""}),e.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(x,m,f,s)=>{if(m.includes("@"))return"";if(m.trim().toLowerCase()===s.trim().toLowerCase()){let g=m.trim().toLowerCase();if(o&&(g===o||g===r)){let k=f.trim();k&&p.push(k)}}return""}),p.join(`
478
478
 
479
- `).trim()},Pa=(e="",n="")=>{let t=`${e||""}@${n||""}`.toLowerCase().trim();tr!==t&&(tr=t,Io=qi(),Mo=Xi())};zs();var Oa=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),a=t.match(/^description:\s*(.+)$/m);return d&&(o=d[1].trim().replace(/^["']|["']$/g,"")),a&&(r=a[1].trim().replace(/^["']|["']$/g,"")),o&&r?{name:o,description:r}:null},La=e=>{let n=[];if(!e||!ln.existsSync(e))return n;let t=(i,o=0)=>{if(!(o>5))try{let r=ln.readdirSync(i,{withFileTypes:!0});for(let d of r){let a=mn.join(i,d.name),u=d.name.toLowerCase();d.isFile()?u==="skill.md"&&n.push(a):d.isDirectory()&&(o===0?(u==="skills"||u===".skills"||u==="skill"||u===".skill")&&t(a,o+1):t(a,o+1))}}catch{}};return t(e,0),n},dr=e=>{let n=La(e),t=[];for(let i of n)try{let o=ln.readFileSync(i,"utf8"),r=Oa(o);r&&t.push({...r,filePath:i})}catch{}return t},fr=e=>!e||e.length===0?"":e.map(n=>`- ${n.name}: ${n.description}`).join(`
480
- `),ur=dr(Dn),gr=dr(process.cwd()),Hi=fr(ur),ji=fr(gr),mr=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"},pr=()=>(ur||[]).filter(e=>!mr(e)),hr=()=>(gr||[]).filter(e=>!mr(e)),Sc=(Ji?.length>0?1:0)+(si?.length>0?gn.length:0)+(Io?.length>0?1:0)+(Mo?.length>0?1:0)+pr().length+hr().length,Ki=(e,n="Project")=>{if(!e)return"";let t=e.replace(/\\/g,"/");if(n==="Global"){let o=_a.homedir().replace(/\\/g,"/");return t.toLowerCase().startsWith(o.toLowerCase())?"~"+t.slice(o.length):t}let i=mn.relative(process.cwd(),e).replace(/\\/g,"/");return i.startsWith(".")?i:`./${i}`},Tc=()=>{Io=qi(),Mo=Xi();let e=[];Ro&&Ji.length>0&&e.push({scope:"Global",path:Ro}),gn&&gn.length>0&&si.length>0?gn.forEach(r=>{e.push({scope:"Project",path:r})}):ii&&si.length>0&&e.push({scope:"Project",path:ii}),_o&&Io.length>0&&e.push({scope:"Global",path:_o}),vo&&Mo.length>0&&e.push({scope:"Project",path:vo});let n=pr(),t=hr(),i=e.length+n.length+t.length;if(i===0)return`\u2726 Loaded Files & Instructions
479
+ `).trim()},Pa=(e="",n="")=>{let t=`${e||""}@${n||""}`.toLowerCase().trim();nr!==t&&(nr=t,Mo=qi(),Po=Xi())};qs();var Oa=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),a=t.match(/^description:\s*(.+)$/m);return d&&(o=d[1].trim().replace(/^["']|["']$/g,"")),a&&(r=a[1].trim().replace(/^["']|["']$/g,"")),o&&r?{name:o,description:r}:null},La=e=>{let n=[];if(!e||!cn.existsSync(e))return n;let t=(i,o=0)=>{if(!(o>5))try{let r=cn.readdirSync(i,{withFileTypes:!0});for(let d of r){let a=pn.join(i,d.name),u=d.name.toLowerCase();d.isFile()?u==="skill.md"&&n.push(a):d.isDirectory()&&(o===0?(u==="skills"||u===".skills"||u==="skill"||u===".skill")&&t(a,o+1):t(a,o+1))}}catch{}};return t(e,0),n},fr=e=>{let n=La(e),t=[];for(let i of n)try{let o=cn.readFileSync(i,"utf8"),r=Oa(o);r&&t.push({...r,filePath:i})}catch{}return t},ur=e=>!e||e.length===0?"":e.map(n=>`- ${n.name}: ${n.description}`).join(`
480
+ `),gr=fr(Dn),mr=fr(process.cwd()),Hi=ur(gr),ji=ur(mr),pr=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"},hr=()=>(gr||[]).filter(e=>!pr(e)),yr=()=>(mr||[]).filter(e=>!pr(e)),Sc=(Ji?.length>0?1:0)+(ri?.length>0?mn.length:0)+(Mo?.length>0?1:0)+(Po?.length>0?1:0)+hr().length+yr().length,Ki=(e,n="Project")=>{if(!e)return"";let t=e.replace(/\\/g,"/");if(n==="Global"){let o=_a.homedir().replace(/\\/g,"/");return t.toLowerCase().startsWith(o.toLowerCase())?"~"+t.slice(o.length):t}let i=pn.relative(process.cwd(),e).replace(/\\/g,"/");return i.startsWith(".")?i:`./${i}`},Tc=()=>{Mo=qi(),Po=Xi();let e=[];_o&&Ji.length>0&&e.push({scope:"Global",path:_o}),mn&&mn.length>0&&ri.length>0?mn.forEach(r=>{e.push({scope:"Project",path:r})}):si&&ri.length>0&&e.push({scope:"Project",path:si}),vo&&Mo.length>0&&e.push({scope:"Global",path:vo}),Io&&Po.length>0&&e.push({scope:"Project",path:Io});let n=hr(),t=yr(),i=e.length+n.length+t.length;if(i===0)return`\u2726 Loaded Files & Instructions
481
481
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No instruction or skill files are currently loaded.
482
482
  \u2800`;let o=[];return o.push(`\u2726 Loaded Files & Instructions (${i} ${i===1?"file":"files"} active)`),e.length>0&&(o.push(`
483
483
  \x1B[1mInstructions:\x1B[22m`),e.forEach(r=>{o.push(` \u2022 [${r.scope}] ${Ki(r.path,r.scope)}`)})),(n?.length>0||t?.length>0)&&(o.push(`
484
484
  \x1B[1mSkills:\x1B[22m`),n?.length>0&&n.forEach(r=>{o.push(` \u2022 [Global] \x1B[36m${r.name}\x1B[39m`),o.push(` \x1B[2m\u2514\u2500 ${Ki(r.filePath,"Global")}\x1B[22m`)}),t?.length>0&&t.forEach(r=>{o.push(` \u2022 [Project] \x1B[36m${r.name}\x1B[39m`),o.push(` \x1B[2m\u2514\u2500 ${Ki(r.filePath,"Project")}\x1B[22m`)})),o.push("\u2800"),o.join(`
485
- `)},yr=!1;(async()=>{try{let e=await To();if(Number(e?.display)===1){let{default:n}=await import("screenshot-desktop"),t=await n.listDisplays();t&&t.length>1&&(yr=!0)}}catch{}})();var or=null,Co=null,ir=process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux",kc=process.env.NO_DEV||!1,$a=(e,n)=>{if(!n)return"";if(e!==or||Co===null){or=e;try{let t=Rt(zn,[]);Array.isArray(t)&&t.length>0?Co=t.map(i=>`- ${i.memory}`).join(`
486
- `):Co=""}catch(t){Co="",ln.appendFileSync(`${Rn}/memory/error.txt`,`${t.message}
485
+ `)},xr=!1;(async()=>{try{let e=await ko();if(Number(e?.display)===1){let{default:n}=await import("screenshot-desktop"),t=await n.listDisplays();t&&t.length>1&&(xr=!0)}}catch{}})();var ir=null,Ro=null,sr=process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux",kc=process.env.NO_DEV||!1,$a=(e,n)=>{if(!n)return"";if(e!==ir||Ro===null){ir=e;try{let t=_t(zn,[]);Array.isArray(t)&&t.length>0?Ro=t.map(i=>`- ${i.memory}`).join(`
486
+ `):Ro=""}catch(t){Ro="",cn.appendFileSync(`${_n}/memory/error.txt`,`${t.message}
487
487
  -------------------------------------------------
488
488
 
489
- `)}}return Co};var xr=(e,n,t,i,o=!0,r=!1,d="Google",a=!1,u,p,x=!1,m="")=>{let f=!1;process.env.forcedReasoning&&(f=!0);let s="";if(!u&&d==="Google"){let M=n;n==="Fast"&&(M="Off"),n==="Low"&&(M="Minimal"),n==="Standard"&&(M="Medium"),(n==="xHigh"||n==="Max")&&(M="xHigh"),s=ti[M]||ti.Medium}(u||d!=="Google")&&(s=ti.xHigh,n==="Fast"?s=`No thinking. Immediate response
489
+ `)}}return Ro};var br=(e,n,t,i,o=!0,r=!1,d="Google",a=!1,u,p,x=!1,m="")=>{let f=!1;process.env.forcedReasoning&&(f=!0);let s="";if(!u&&d==="Google"){let M=n;n==="Fast"&&(M="Off"),n==="Low"&&(M="Minimal"),n==="Standard"&&(M="Medium"),(n==="xHigh"||n==="Max")&&(M="xHigh"),s=ni[M]||ni.Medium}(u||d!=="Google")&&(s=ni.xHigh,n==="Fast"?s=`No thinking. Immediate response
490
490
  Verify imports, tool results & system stability`:n.toLowerCase()==="max"&&(s=`Effort: Max
491
491
  Plan step by step`));let g=e.instructions&&e.instructions?.length>0?`User Preferences: ${e.instructions}
492
492
 
@@ -494,28 +494,28 @@ Plan step by step`));let g=e.instructions&&e.instructions?.length>0?`User Prefer
494
494
  ${g.length?"":`
495
495
  `}`:"",ue=e.name&&e.name?.length>0?`User Name: ${e.name}
496
496
  ${k.length||g.length?"":`
497
- `}`:"",y=process.cwd(),_=e.preset,K={Sassy:"Sassy",Friendly:"Warm & Chatty",Playful:"Playful",Efficient:"Quick, Concise & Efficient",Professional:"Professional"}[_]||null,F=$a(p,o),E=F?.length>0?`--- Saved Memories ---
497
+ `}`:"",y=process.cwd(),_=e.preset,V={Sassy:"Sassy",Friendly:"Warm & Chatty",Playful:"Playful",Efficient:"Quick, Concise & Efficient",Professional:"Professional"}[_]||null,F=$a(p,o),E=F?.length>0?`--- Saved Memories ---
498
498
  ${F}
499
499
 
500
- `:"";Pa(d,m);let pe=nr(Io,m,d).trim(),ve=[Ji,pe].filter(M=>M&&M.length>0).join(`
500
+ `:"";Pa(d,m);let pe=or(Mo,m,d).trim(),ve=[Ji,pe].filter(M=>M&&M.length>0).join(`
501
501
 
502
- `).trim(),we=nr(Mo,m,d).trim(),b=[si,we].filter(M=>M&&M.length>0).join(`
502
+ `).trim(),we=or(Po,m,d).trim(),b=[ri,we].filter(M=>M&&M.length>0).join(`
503
503
 
504
- `).trim(),lt=ve.length>0||b.length>0?`--- Additional Instructions ---
504
+ `).trim(),ft=ve.length>0||b.length>0?`--- Additional Instructions ---
505
505
  ${ve.length>0?`-- Global --
506
506
  ${ve}`:""}${b.length>0?`${ve.length>0?`
507
507
 
508
508
  `:""}-- Project --
509
509
  ${b}`:""}
510
510
 
511
- `:"",$e=(()=>{let M=process.cwd().toLowerCase();if(process.platform==="win32"){let A=process.env.SystemRoot?.toLowerCase()||"c:\\windows",D=process.env.ProgramFiles?.toLowerCase()||"c:\\program files",xe=process.env["ProgramFiles(x86)"]?.toLowerCase()||"c:\\program files (x86)";return M.startsWith(A)||M.startsWith(D)||M.startsWith(xe)}else return M==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(D=>M.startsWith(D))})(),Pt=new Date,pn=Pt.getFullYear(),vt=Pt.toLocaleString("en-US",{month:"short"}).toUpperCase(),Ut=String(Pt.getDate()).padStart(2,"0"),hn=`${pn}-${vt}-${Ut}`,yn=process.env.I_HAVE_TOO_MUCH_MONEY==="true"||!1,Ot=process.env.HALLOWEEN_EEGG==="true"||!1,yt=Ot&&vt.includes("OCT")&&(Ut.includes("30")||Ut.includes("31")),cn=(m||"").replace(/^.*::/,"").split(":")[0].replace(/\/free$/,"").trim(),S=mn.basename(cn).replace(/-free$/,"").replace(/_free$/,"").replace(/^free_/,"").replaceAll("-"," ").replaceAll("_"," ").replace(/\b\w/g,M=>M.toUpperCase().trim()),C=process.env.NO_DEV==="true"||!1,Ie=!1;try{Ie=lo()}catch{Ie=!1}return`${yn?`${" ".repeat(Math.floor(Math.random()*4)+1)}`:""}=== SYSTEM PROMPT ===
512
- ${`Identity: ${Vi.length>1?Vi.trim():`Flux Flow.${K?` ${K}`:""} CLI Assistant${Ot?`. ${yt?"Peak ":""}Halloween Themed, Spooky`:""}`}
513
- ${cr?"":`${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"}`}${yr&&t.toLowerCase().includes("cu")?`
511
+ `:"",$e=(()=>{let M=process.cwd().toLowerCase();if(process.platform==="win32"){let A=process.env.SystemRoot?.toLowerCase()||"c:\\windows",N=process.env.ProgramFiles?.toLowerCase()||"c:\\program files",xe=process.env["ProgramFiles(x86)"]?.toLowerCase()||"c:\\program files (x86)";return M.startsWith(A)||M.startsWith(N)||M.startsWith(xe)}else return M==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(N=>M.startsWith(N))})(),Lt=new Date,hn=Lt.getFullYear(),It=Lt.toLocaleString("en-US",{month:"short"}).toUpperCase(),Ht=String(Lt.getDate()).padStart(2,"0"),yn=`${hn}-${It}-${Ht}`,xn=process.env.I_HAVE_TOO_MUCH_MONEY==="true"||!1,$t=process.env.HALLOWEEN_EEGG==="true"||!1,St=$t&&It.includes("OCT")&&(Ht.includes("30")||Ht.includes("31")),dn=(m||"").replace(/^.*::/,"").split(":")[0].replace(/\/free$/,"").trim(),S=pn.basename(dn).replace(/-free$/,"").replace(/_free$/,"").replace(/^free_/,"").replaceAll("-"," ").replaceAll("_"," ").replace(/\b\w/g,M=>M.toUpperCase().trim()),C=process.env.NO_DEV==="true"||!1,Ie=!1;try{Ie=fo()}catch{Ie=!1}return`${xn?`${" ".repeat(Math.floor(Math.random()*4)+1)}`:""}=== SYSTEM PROMPT ===
512
+ ${`Identity: ${Vi.length>1?Vi.trim():`Flux Flow.${V?` ${V}`:""} CLI Assistant${$t?`. ${St?"Peak ":""}Halloween Themed, Spooky`:""}`}
513
+ ${dr?"":`${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"}`}${xr&&t.toLowerCase().includes("cu")?`
514
514
  - 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()}
515
515
 
516
- - OS: ${ir}${!C&&m.length>1?`
516
+ - OS: ${sr}${!C&&m.length>1?`
517
517
  - Model: ${S}`.trimEnd():""}
518
- - Date: ${hn}
518
+ - Date: ${yn}
519
519
 
520
520
  -- REASONING GUIDANCE --
521
521
  ${d==="Mistral"||d==="Google"&&!u||f?`${s.trimEnd()}${f||n!=="Fast"&&(d==="Mistral"&&n==="Low"&&!u||n!=="High"&&!u)?`
@@ -523,7 +523,7 @@ Critical Thinking Policy
523
523
  Use <think_fluxflow>...</think_fluxflow> for reasoning before responding any queries`:""}`:`${s.trimEnd()}`}${x?"":`
524
524
  Before actions, provide user facing summary of findings & decisions IN detail
525
525
  `}
526
- ${vs(t,ir,a,d,i?.advanceRollback,i?.subAgents!==!1,!!i?.autoExec,!!i?.disableTodo)}${t==="Flux"?"":t.toLowerCase().includes("cu")?`
526
+ ${Is(t,sr,a,d,i?.advanceRollback,i?.subAgents!==!1,!!i?.autoExec,!!i?.disableTodo)}${t==="Flux"?"":t.toLowerCase().includes("cu")?`
527
527
 
528
528
  -- SECURITY POLICIES --
529
529
  - Dont operate on ANY confidential screens/captcha \u2192 AskUser`:""}${Ie?`
@@ -533,13 +533,13 @@ Reference files as ./file:start..end`:""}
533
533
 
534
534
  - Read relevant skills before tasks, scope: global/project: Use ReadFile, path="#skills/scope?/skillName". In-skill references: path="#skills/scope?/skillName/reference-folder/*.md"`:""}
535
535
 
536
- ${k}${g}${lt}${Hi.length>0&&t.toLowerCase().includes("flux")?`-- Global Skills --
536
+ ${k}${g}${ft}${Hi.length>0&&t.toLowerCase().includes("flux")?`-- Global Skills --
537
537
  ${Hi}
538
538
 
539
539
  `:""}${ji.length>0&&t.toLowerCase().includes("flux")?`-- Project Skills --
540
540
  ${ji}
541
541
 
542
- `:""}${E}`.trim()},br=(e="",n=!0,t=!0)=>`=== SYSTEM PROMPT (strict headless logic worker: zero user-facing text policy, strictly follow) ===
542
+ `:""}${E}`.trim()},wr=(e="",n=!0,t=!0)=>`=== SYSTEM PROMPT (strict headless logic worker: zero user-facing text policy, strictly follow) ===
543
543
  identity: silent background system process, have no mouth, only output is valid tool calls
544
544
  [critical rules]
545
545
  - output exactly '[action:ActionName(args)]' calls. no extra words outside
@@ -556,11 +556,11 @@ identity: silent background system process, have no mouth, only output is valid
556
556
  YOUR JOB: Analyze the 'User prompt' and 'Agent Raws' to extract facts for long-term memory or handle system tasks
557
557
  ${n?"If user tell something that is important (like, hobbies, preferences, facts about user, hates, likes, etc) to know user better over time, use user memory tools":""}
558
558
 
559
- ${Os(n,t)}
559
+ ${Ls(n,t)}
560
560
  === END SYSTEM PROMPT ===${e?`
561
561
 
562
562
  -- current saved user memories --
563
- ${e}`:""}`.trim();var wr=()=>import("./web_search-NT3HXUO3.js").then(e=>e.web_search),Sr=()=>import("./web_scrape-MW6YSZ7L.js").then(e=>e.web_scrape),Tr=()=>import("./memory-7YOYCOXE.js").then(e=>e.memory),kr=()=>import("./chat-E7KU2LZM.js").then(e=>e.chat),Ar=()=>import("./view_file-I77KYUO5.js").then(e=>e.view_file),Er=()=>import("./write_file-CIOAYT4P.js").then(e=>e.write_file),Cr=()=>import("./update_file-DG3QLIHE.js").then(e=>e.update_file),Rr=()=>import("./exec_command-7AO6AUGQ.js").then(e=>e.exec_command),_r=()=>import("./read_folder-EI2CNHNS.js").then(e=>e.read_folder),Qi=()=>import("./ask_user-K2DLZF6H.js").then(e=>e.ask_user),vr=()=>import("./write_pdf-26OQPNEP.js").then(e=>e.write_pdf),Ir=()=>import("./write_docx-E3MTFXTQ.js").then(e=>e.write_docx),ri=()=>import("./search_keyword-I5QJUL77.js").then(e=>e.search_keyword),Mr=()=>import("./generate_image-52GQGN2Q.js").then(e=>e.generate_image),ai=()=>import("./saveSummary-W2JMDVZJ.js").then(e=>e.saveSummary),Oo=()=>import("./addMemScore-PBVNSFPN.js").then(e=>e.addMemScore),Pr=()=>import("./file_map-UA4BA5OH.js").then(e=>e.file_map),li=()=>import("./todo-CJLWLWJB.js").then(e=>e.todo),Or=()=>import("./invokeSync-ZKNYPA5T.js").then(e=>e.invokeSync),Na=()=>import("./invoke-44R4K62P.js").then(e=>e.invoke),Lr=()=>import("./getProgress-A2TW34Q7.js").then(e=>e.getProgress),Da=()=>import("./cancel-F3ZOEBKW.js").then(e=>e.cancel),$r=()=>import("./emergency_rollback-ZHQXCIHW.js").then(e=>e.emergency_rollback),Lo=()=>import("./awaitSubagent-JKQ2EHVY.js").then(e=>e.awaitSubagent),$o=()=>import("./answerSubagent-BPNNJXPC.js").then(e=>e.answerSubagent),ci=()=>import("./steerSubagent-UETXH2CB.js").then(e=>e.steerSubagent),di=()=>import("./computer_action-FVC3EXVR.js").then(e=>e.computer_action),Nr=()=>import("./click-5WEIMJHK.js").then(e=>e.click),Dr=()=>import("./drag-YOWUC5B7.js").then(e=>e.drag),Fr=()=>import("./scroll-OHT6HAHC.js").then(e=>e.scroll),Zi=()=>import("./keyboard_typing-TSJ4CP4R.js").then(e=>e.keyboard_typing),es=()=>import("./key_press-I4KBUAHP.js").then(e=>e.key_press),ts=()=>import("./recapture_screen-PPT2E3CK.js").then(e=>e.recapture_screen),fi=()=>import("./find_file-HYHHFHUJ.js").then(e=>e.find_file),Br=()=>import("./wait-TJR6LAR4.js").then(e=>e.wait),Ur={web_search:wr,web_scrape:Sr,memory:Tr,chat:kr,view_file:Ar,write_file:Er,update_file:Cr,exec_command:Rr,read_folder:_r,write_pdf:vr,write_docx:Ir,search_keyword:ri,generate_image:Mr,saveSummary:ai,addMemScore:Oo,file_map:Pr,todo:li,Todo:li,goal:li,Goal:li,invokeSync:Or,invoke:Na,getProgress:Lr,cancel:Da,awaitSubagent:Lo,answerSubagent:$o,steerSubagent:ci,computer_action:di,computer_use:di,ComputerAction:di,ComputerUse:di,click:Nr,Click:Nr,drag:Dr,Drag:Dr,scroll:Fr,Scroll:Fr,keyboard_typing:Zi,KeyboardTyping:Zi,keyboardtyping:Zi,key_press:es,KeyPress:es,keypress:es,recapture_screen:ts,RecaptureScreen:ts,recapturescreen:ts,invoke_sync:Or,get_progress:Lr,await_subagent:Lo,answer_subagent:$o,steer_subagent:ci,steer:ci,Steer:ci,ask:Qi,Ask:Qi,AskUser:Qi,WebSearch:wr,WebScrape:Sr,ReadFile:Ar,ReadFolder:_r,WriteFile:Er,PatchFile:Cr,WritePDF:vr,WriteDoc:Ir,Run:Rr,SearchKeyword:ri,CodeSearch:ri,code_search:ri,Memory:Tr,Chat:kr,GenerateImage:Mr,saveSumary:ai,SaveSummary:ai,SaveSumary:ai,add_mem_score:Oo,AddMemScore:Oo,addMemoryScore:Oo,AddMemoryScore:Oo,FileMap:Pr,answer:$o,Answer:$o,AnswerSubagent:$o,await:Lo,Await:Lo,AwaitSubagent:Lo,EmergencyRollback:$r,emergency_rollback:$r,find_file:fi,findFile:fi,FindFile:fi,findfile:fi,wait:Br,Wait:Br},No=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(x=>o.includes(x))||o==="ask",u=["click","drag","scroll","keyboardtyping","keyboard_typing","keypress","key_press","recapturescreen","recapture_screen","computer","wait"].some(x=>o.includes(x));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 p=Ur[e];if(!p){let x=["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"},f=o.replace(/[^a-z0-9]/g,""),s=m[f]||null;if(!s){let k=0,ue=_=>{let W=new Set;for(let K=0;K<_.length-1;K++)W.add(_.slice(K,K+2));return W},y=ue(f);for(let _ of x){let W=_.toLowerCase().replace(/[^a-z0-9]/g,"");if(f===W){s=_;break}let K=0;(W.includes(f)||f.includes(W))&&(K+=.6);let F=ue(W),E=0;for(let Te of y)F.has(Te)&&E++;let pe=2*E/(y.size+F.size||1);K=Math.max(K,pe),K>k&&K>=.35&&(k=K,s=_)}}let g=s?` Do you mean '${s}'?`:"";return`ERROR: Action [${e}] not found in registry.${g}`}try{return await(await p())(n,t)}catch(x){let m=x instanceof Error?x.message:String(x);return`ERROR: Execution failed for [${e}]: ${m}`}};var ui=e=>{if(!e||typeof e!="string")return!1;let n=e.trim().toLowerCase();return Object.keys(Ur).some(t=>t.toLowerCase()===n)};import j from"path";import Se from"fs";import{execSync as as}from"child_process";import Fa from"gradient-string";var Wr=["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 Gr=["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 Hr=[{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"]}],co={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 gi=null;var mi=(e="Dark")=>{let n;e==="Mystery"||e==="Chaos"?(gi||(gi=Hr[Math.floor(Math.random()*Hr.length)]),n={...gi,id:"Mystery"}):(gi=null,co[e]?n=co[e]:e==="Halloween"?n=co.Spookfest:e==="GitHub"?n=co["GitHub Dark"]:e==="Transparent"?n=co["Transparent Dark"]:n=co.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 Ba=()=>process.env.TERM_PROGRAM==="vscode"?"vscode":process.env.WT_SESSION?"wt":"default",$c=(e=2)=>{let n=Ba();return n==="wt"?" ".repeat(Math.max(1,e-1)):" ".repeat(e)},jr=new Date,Do=jr.getMonth(),Fo=jr.getDate(),Ua=Do===9&&Fo>=15||Do===10&&Fo<=1,ns=null;(process.env.SPOOKFEST==="true"||Ua)&&(ns=await import("./halloween-MX3VNQRW.js"));var Nc=(e="...",n="Loading...",t="Dark")=>{let i=mi(t),o=n;if(n==="c_openai"||n==="Custom (OpenAI)")try{let K=Qo(qo,{})?.systemSettings?.customOpenAIBaseUrl;K&&(o=K)}catch{}let r=i.logoTextAnsi,d=i.logoBodyAnsi,a=i.logoMutedAnsi,u="\x1B[0m",p=[" \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 "],x=t==="Spookfest"||i.id==="Spookfest"||t==="Halloween"||i.id==="Halloween",m=Do===9&&Fo>=15||Do===10&&Fo<=1,f=x&&m||process.env.SPOOKFEST==="true"&&x,s=p;if(f&&ns){process.env.HALLOWEEN_EEGG="true";let{halloweenArtSide:W,halloweenBat:K,halloweenArtUser:F}=ns;s=Math.random()>.9&&Do===9&&Fo>=30?K:Math.random()>.5?W:F}else process.env.HALLOWEEN_EEGG="false";let g=f?Gr:Wr,k=g[Math.floor(Math.random()*g.length)],ue=i.logoGradient||["#0077ff","#ff00ff"],y=Fa(ue).multiline(s.join(`
563
+ ${e}`:""}`.trim();var Sr=()=>import("./web_search-NT3HXUO3.js").then(e=>e.web_search),Tr=()=>import("./web_scrape-MW6YSZ7L.js").then(e=>e.web_scrape),kr=()=>import("./memory-7YOYCOXE.js").then(e=>e.memory),Ar=()=>import("./chat-BA72I6O3.js").then(e=>e.chat),Er=()=>import("./view_file-I77KYUO5.js").then(e=>e.view_file),Cr=()=>import("./write_file-CIOAYT4P.js").then(e=>e.write_file),Rr=()=>import("./update_file-JXUYSH2G.js").then(e=>e.update_file),_r=()=>import("./exec_command-7AO6AUGQ.js").then(e=>e.exec_command),vr=()=>import("./read_folder-EI2CNHNS.js").then(e=>e.read_folder),Qi=()=>import("./ask_user-K2DLZF6H.js").then(e=>e.ask_user),Ir=()=>import("./write_pdf-26OQPNEP.js").then(e=>e.write_pdf),Mr=()=>import("./write_docx-E3MTFXTQ.js").then(e=>e.write_docx),ai=()=>import("./search_keyword-I5QJUL77.js").then(e=>e.search_keyword),Pr=()=>import("./generate_image-52GQGN2Q.js").then(e=>e.generate_image),li=()=>import("./saveSummary-W2JMDVZJ.js").then(e=>e.saveSummary),Lo=()=>import("./addMemScore-PBVNSFPN.js").then(e=>e.addMemScore),Or=()=>import("./file_map-UA4BA5OH.js").then(e=>e.file_map),ci=()=>import("./todo-CJLWLWJB.js").then(e=>e.todo),Lr=()=>import("./invokeSync-4GMOXNSA.js").then(e=>e.invokeSync),Na=()=>import("./invoke-RGWQLLU4.js").then(e=>e.invoke),$r=()=>import("./getProgress-A2TW34Q7.js").then(e=>e.getProgress),Da=()=>import("./cancel-F3ZOEBKW.js").then(e=>e.cancel),Nr=()=>import("./emergency_rollback-ZHQXCIHW.js").then(e=>e.emergency_rollback),$o=()=>import("./awaitSubagent-JKQ2EHVY.js").then(e=>e.awaitSubagent),No=()=>import("./answerSubagent-BPNNJXPC.js").then(e=>e.answerSubagent),di=()=>import("./steerSubagent-UETXH2CB.js").then(e=>e.steerSubagent),fi=()=>import("./computer_action-FVC3EXVR.js").then(e=>e.computer_action),Dr=()=>import("./click-5WEIMJHK.js").then(e=>e.click),Fr=()=>import("./drag-YOWUC5B7.js").then(e=>e.drag),Br=()=>import("./scroll-OHT6HAHC.js").then(e=>e.scroll),Zi=()=>import("./keyboard_typing-TSJ4CP4R.js").then(e=>e.keyboard_typing),es=()=>import("./key_press-I4KBUAHP.js").then(e=>e.key_press),ts=()=>import("./recapture_screen-PPT2E3CK.js").then(e=>e.recapture_screen),ui=()=>import("./find_file-HYHHFHUJ.js").then(e=>e.find_file),Ur=()=>import("./wait-TJR6LAR4.js").then(e=>e.wait),Wr={web_search:Sr,web_scrape:Tr,memory:kr,chat:Ar,view_file:Er,write_file:Cr,update_file:Rr,exec_command:_r,read_folder:vr,write_pdf:Ir,write_docx:Mr,search_keyword:ai,generate_image:Pr,saveSummary:li,addMemScore:Lo,file_map:Or,todo:ci,Todo:ci,goal:ci,Goal:ci,invokeSync:Lr,invoke:Na,getProgress:$r,cancel:Da,awaitSubagent:$o,answerSubagent:No,steerSubagent:di,computer_action:fi,computer_use:fi,ComputerAction:fi,ComputerUse:fi,click:Dr,Click:Dr,drag:Fr,Drag:Fr,scroll:Br,Scroll:Br,keyboard_typing:Zi,KeyboardTyping:Zi,keyboardtyping:Zi,key_press:es,KeyPress:es,keypress:es,recapture_screen:ts,RecaptureScreen:ts,recapturescreen:ts,invoke_sync:Lr,get_progress:$r,await_subagent:$o,answer_subagent:No,steer_subagent:di,steer:di,Steer:di,ask:Qi,Ask:Qi,AskUser:Qi,WebSearch:Sr,WebScrape:Tr,ReadFile:Er,ReadFolder:vr,WriteFile:Cr,PatchFile:Rr,WritePDF:Ir,WriteDoc:Mr,Run:_r,SearchKeyword:ai,CodeSearch:ai,code_search:ai,Memory:kr,Chat:Ar,GenerateImage:Pr,saveSumary:li,SaveSummary:li,SaveSumary:li,add_mem_score:Lo,AddMemScore:Lo,addMemoryScore:Lo,AddMemoryScore:Lo,FileMap:Or,answer:No,Answer:No,AnswerSubagent:No,await:$o,Await:$o,AwaitSubagent:$o,EmergencyRollback:Nr,emergency_rollback:Nr,find_file:ui,findFile:ui,FindFile:ui,findfile:ui,wait:Ur,Wait:Ur},Do=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(x=>o.includes(x))||o==="ask",u=["click","drag","scroll","keyboardtyping","keyboard_typing","keypress","key_press","recapturescreen","recapture_screen","computer","wait"].some(x=>o.includes(x));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 p=Wr[e];if(!p){let x=["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"},f=o.replace(/[^a-z0-9]/g,""),s=m[f]||null;if(!s){let k=0,ue=_=>{let W=new Set;for(let V=0;V<_.length-1;V++)W.add(_.slice(V,V+2));return W},y=ue(f);for(let _ of x){let W=_.toLowerCase().replace(/[^a-z0-9]/g,"");if(f===W){s=_;break}let V=0;(W.includes(f)||f.includes(W))&&(V+=.6);let F=ue(W),E=0;for(let Te of y)F.has(Te)&&E++;let pe=2*E/(y.size+F.size||1);V=Math.max(V,pe),V>k&&V>=.35&&(k=V,s=_)}}let g=s?` Do you mean '${s}'?`:"";return`ERROR: Action [${e}] not found in registry.${g}`}try{return await(await p())(n,t)}catch(x){let m=x instanceof Error?x.message:String(x);return`ERROR: Execution failed for [${e}]: ${m}`}};var gi=e=>{if(!e||typeof e!="string")return!1;let n=e.trim().toLowerCase();return Object.keys(Wr).some(t=>t.toLowerCase()===n)};import K from"path";import Se from"fs";import{execSync as as}from"child_process";import Fa from"gradient-string";var Gr=["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 Hr=["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 jr=[{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"]}],uo={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 mi=null;var pi=(e="Dark")=>{let n;e==="Mystery"||e==="Chaos"?(mi||(mi=jr[Math.floor(Math.random()*jr.length)]),n={...mi,id:"Mystery"}):(mi=null,uo[e]?n=uo[e]:e==="Halloween"?n=uo.Spookfest:e==="GitHub"?n=uo["GitHub Dark"]:e==="Transparent"?n=uo["Transparent Dark"]:n=uo.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 Ba=()=>process.env.TERM_PROGRAM==="vscode"?"vscode":process.env.WT_SESSION?"wt":"default",$c=(e=2)=>{let n=Ba();return n==="wt"?" ".repeat(Math.max(1,e-1)):" ".repeat(e)},Kr=new Date,Fo=Kr.getMonth(),Bo=Kr.getDate(),Ua=Fo===9&&Bo>=15||Fo===10&&Bo<=1,ns=null;(process.env.SPOOKFEST==="true"||Ua)&&(ns=await import("./halloween-MX3VNQRW.js"));var Nc=(e="...",n="Loading...",t="Dark")=>{let i=pi(t),o=n;if(n==="c_openai"||n==="Custom (OpenAI)")try{let V=Zo(Xo,{})?.systemSettings?.customOpenAIBaseUrl;V&&(o=V)}catch{}let r=i.logoTextAnsi,d=i.logoBodyAnsi,a=i.logoMutedAnsi,u="\x1B[0m",p=[" \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 "],x=t==="Spookfest"||i.id==="Spookfest"||t==="Halloween"||i.id==="Halloween",m=Fo===9&&Bo>=15||Fo===10&&Bo<=1,f=x&&m||process.env.SPOOKFEST==="true"&&x,s=p;if(f&&ns){process.env.HALLOWEEN_EEGG="true";let{halloweenArtSide:W,halloweenBat:V,halloweenArtUser:F}=ns;s=Math.random()>.9&&Fo===9&&Bo>=30?V:Math.random()>.5?W:F}else process.env.HALLOWEEN_EEGG="false";let g=f?Hr:Gr,k=g[Math.floor(Math.random()*g.length)],ue=i.logoGradient||["#0077ff","#ff00ff"],y=Fa(ue).multiline(s.join(`
564
564
  `)).split(`
565
565
  `),_=W=>`${a}${W}${u}`;return`${y[0]}
566
566
  ${y[1]} ${r}Selected ${f?"Pumpkin":"Provider"}: ${o}${u}
@@ -570,10 +570,10 @@ ${y[4]}
570
570
  ${y[5]} ${d}See /help for additional commands.${u}
571
571
  ${y[6]} ${_(k)}
572
572
  ${y[7]}
573
- `};import{structuredPatch as Ka}from"diff";import os from"path";import Wa from"fs";var Ga=e=>{try{return Wa.readdirSync(e,{withFileTypes:!0})}catch{return[]}},is=(e,n=4,t=1,i=Ga,o=[],r=null)=>{let d=r||i(e),a=" ".repeat(t-1),u=t===1?new Set([...wo,...o,...So(e),...So(process.cwd())]):o instanceof Set?o:new Set([...wo,...o]),p=F=>u.has(F),x=d.filter(F=>!p(F.name)),m=d.filter(F=>p(F.name)).length,f=x.filter(F=>!F.isDirectory()).map(F=>F.name).sort(),s=x.filter(F=>F.isDirectory()).sort((F,E)=>F.name.localeCompare(E.name)),g=F=>{let E=F.length;if(E===0)return"no files";let pe=Array.from(new Set(F.map(ve=>{let we=typeof ve=="string"?ve:ve.name;return os.extname(we).slice(1)}).filter(Boolean))).sort(),Te="*";return pe.length===1?Te=`*.${pe[0]}`:pe.length>1&&(Te=`*.{${pe.join(", ")}}`),E===1?Te:`${Te} ${E} files`},k="";if(t===1){let F=f.join(", "),E=m>0?` [${m} ignored]`:"";(F||E)&&(k+=`${a}${F?F+(E?`${E}`:""):E.trim()}
573
+ `};import{structuredPatch as Ka}from"diff";import os from"path";import Wa from"fs";var Ga=e=>{try{return Wa.readdirSync(e,{withFileTypes:!0})}catch{return[]}},is=(e,n=4,t=1,i=Ga,o=[],r=null)=>{let d=r||i(e),a=" ".repeat(t-1),u=t===1?new Set([...So,...o,...To(e),...To(process.cwd())]):o instanceof Set?o:new Set([...So,...o]),p=F=>u.has(F),x=d.filter(F=>!p(F.name)),m=d.filter(F=>p(F.name)).length,f=x.filter(F=>!F.isDirectory()).map(F=>F.name).sort(),s=x.filter(F=>F.isDirectory()).sort((F,E)=>F.name.localeCompare(E.name)),g=F=>{let E=F.length;if(E===0)return"no files";let pe=Array.from(new Set(F.map(ve=>{let we=typeof ve=="string"?ve:ve.name;return os.extname(we).slice(1)}).filter(Boolean))).sort(),Te="*";return pe.length===1?Te=`*.${pe[0]}`:pe.length>1&&(Te=`*.{${pe.join(", ")}}`),E===1?Te:`${Te} ${E} files`},k="";if(t===1){let F=f.join(", "),E=m>0?` [${m} ignored]`:"";(F||E)&&(k+=`${a}${F?F+(E?`${E}`:""):E.trim()}
574
574
  `)}else f.length>0&&(k+=`${a}[${g(f)}]
575
- `);let ue=10,y=s.slice(0,ue),_=s.length>ue,W=[],K=[];for(let F of y){let E=os.join(e,F.name),pe=F.name,Te=t,ve=i(E),we=ve.filter($e=>!p($e.name)),T=we.filter($e=>$e.isDirectory()),b=we.filter($e=>!$e.isDirectory());for(;b.length===0&&T.length===1&&Te<n;)pe=`${pe}/${T[0].name}`,E=os.join(E,T[0].name),Te++,ve=i(E),we=ve.filter($e=>!p($e.name)),T=we.filter($e=>$e.isDirectory()),b=we.filter($e=>!$e.isDirectory());let lt=T.length>0;if(lt&&Te<n)K.push({displayName:pe,subDirPath:E,subEntries:ve,nextDepth:Te+1});else{let $e=g(b),Pt=lt&&Te>=n?" ...max scan depth":"";W.push(`${pe}/${$e}${Pt}`)}}W.length>0&&(k+=`${a}${W.join(", ")}
576
- `);for(let{displayName:F,subDirPath:E,subEntries:pe,nextDepth:Te}of K)k+=`${a}${F}/
575
+ `);let ue=10,y=s.slice(0,ue),_=s.length>ue,W=[],V=[];for(let F of y){let E=os.join(e,F.name),pe=F.name,Te=t,ve=i(E),we=ve.filter($e=>!p($e.name)),T=we.filter($e=>$e.isDirectory()),b=we.filter($e=>!$e.isDirectory());for(;b.length===0&&T.length===1&&Te<n;)pe=`${pe}/${T[0].name}`,E=os.join(E,T[0].name),Te++,ve=i(E),we=ve.filter($e=>!p($e.name)),T=we.filter($e=>$e.isDirectory()),b=we.filter($e=>!$e.isDirectory());let ft=T.length>0;if(ft&&Te<n)V.push({displayName:pe,subDirPath:E,subEntries:ve,nextDepth:Te+1});else{let $e=g(b),Lt=ft&&Te>=n?" ...max scan depth":"";W.push(`${pe}/${$e}${Lt}`)}}W.length>0&&(k+=`${a}${W.join(", ")}
576
+ `);for(let{displayName:F,subDirPath:E,subEntries:pe,nextDepth:Te}of V)k+=`${a}${F}/
577
577
  `,k+=is(E,n,Te,i,u,pe);return _&&(k+=`${a}...max scan width, ReadFolder if needed
578
578
  `),k};import ss from"path";import Ha from"fs";var ja=e=>{try{return Ha.readdirSync(e,{withFileTypes:!0})}catch{return[]}},rs=(e,n,t="",i=1,o=ja,r=[])=>{let d=o(e),a=ss.sep;if(d.length>100)return`${t}\u2514\u2500\u2500 ${ss.basename(e)}${a} ...100+ files...
579
579
  `;let u="",p=r,x=d.filter(s=>!p.includes(s.name)&&!s.name.startsWith(".")),m=d.filter(s=>p.includes(s.name)||s.name.startsWith(".")).map(s=>s.name).sort();x.sort((s,g)=>s.isDirectory()&&!g.isDirectory()?-1:!s.isDirectory()&&g.isDirectory()?1:s.name.localeCompare(g.name));let f=[...x.map(s=>({name:s.name,isDir:s.isDirectory()})),...m.map(s=>({name:s,isDir:!0,isCollapsed:!0}))];return f.forEach((s,g)=>{let k=g===f.length-1,ue=ss.join(e,s.name),y=k?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",_=t+(k?" ":"\u2502 ");if(s.isCollapsed){u+=`${t}${y}${s.name}${a}...
@@ -581,28 +581,28 @@ ${y[7]}
581
581
  `:o(ue).length>80?u+=`${t}${y}${s.name}${a} ...80+ files...
582
582
  `:(u+=`${t}${y}${s.name}${a}
583
583
  `,u+=rs(ue,n,_,i+1,o,r)):u+=`${t}${y}${s.name}
584
- `}),u};var Va={Ollama:()=>import("./ollama-4PI2BDMM.js").then(e=>e.getOllamaStream),OpenRouter:()=>import("./openrouter-6MRG4RT6.js").then(e=>e.getOpenRouterStream),DeepSeek:()=>import("./deepseek-WNWZJTNE.js").then(e=>e.getDeepSeekStream),Mistral:()=>import("./mistral-XDIMWAU3.js").then(e=>e.getMistralStream),NVIDIA:()=>import("./nvidia-PSGYXYNK.js").then(e=>e.getNVIDIAStream),NVIDIA_wrap:()=>import("./nvidia-PSGYXYNK.js").then(e=>e.wrapNvidiaStreamWithQueueDepth),InferX:()=>import("./inferx-HP5AGET3.js").then(e=>e.getInferXStream),SenseNova:()=>import("./sensenova-3K44URJQ.js").then(e=>e.getSenseNovaStream),AIHubMix:()=>import("./aihubmix-TETL5QYQ.js").then(e=>e.getAIHubMixStream),Poolside:()=>import("./poolside-ODFAIK4C.js").then(e=>e.getPoolsideStream),NineRouter:()=>import("./9router-LRFKCJF4.js").then(e=>e.getNineRouterStream),ExpLabs:()=>import("./explabs-XHHXTERB.js").then(e=>e.getExpLabsStream),TokenHarbor:()=>import("./tokenharbor-YV2GV2LM.js").then(e=>e.getTokenHarborStream),Infron:()=>import("./infron-ULXG7VDA.js").then(e=>e.getInfronStream),APInex:()=>import("./apinex-FAYOPQSL.js").then(e=>e.getAPInexStream),c_openai:()=>import("./custom_openai-XMDYE7NM.js").then(e=>e.getCustomOpenAIStream)},ls={},ce=async e=>(ls[e]||(ls[e]=await Va[e]()),ls[e]),Ya=/```[\s\S]*?```/g,za=/```[\s\S]*$/g,qa=/`[^`]+`/g,Xa=/^\|.*\|$/gm,Ja=/^[^\w]+|[^\w]+$/g,Qa=/[^a-z0-9]/gi,Bo=/\[\s*(?:tool|action):(?:functions\.)?([a-z0-9_]+)\s*\(/gi,Za=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-z0-9_]+)\s*\(/gi,el=/(?:path|targetFile|TargetFile|directory|keyword|id|taskId|title|task)\s*=\s*\\?["']?([^\\"' \),]+)/,_n=/["']/g,Kr=/\\/g,tl=/<\|channel>thought/gi,nl=/<channel\|>/gi,ol=e=>typeof e!="string"?e:e.replace(tl,"<think_fluxflow>").replace(nl,"</think_fluxflow>"),Ad=/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\]|$)/i,il=(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(!il(e,t.index,t[0].length))return{index:t.index,length:t[0].length};return{index:-1,length:0}},cs=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:""}},Bt=e=>{if(!e||typeof e!="string")return e;let n=cs(e);return n?n.remainingText.trimStart():e};var Vr=/<\|\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,rl=/"([^"]+)"\s*:\s*(?:"([^"]*)"|(\d+)|true|false|null)/g,Yr=/<\|\s*tool_calls_section_begin\s*\|>/gi,zr=/<\|\s*tool_calls_section_end\s*\|>/gi,al=/```(?:tool|action|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi;var pi=e=>!e||typeof e!="string"?e:e.replace(/(```[\s\S]*?```|`[^`]*`)|(<(?:\w+)(?:[^>]*)>\r?\n?|\r?\n?<\/\w+(?:[^>]*)>)/gi,(n,t)=>t||""),Qr=e=>{if(!e||typeof e!="string")return e;let n=fo(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;return e.substring(0,o).trimEnd()},fs=null,Uo={},Xn={key:null,value:null},Ft=e=>{if(!e)return e;let n=Uo?.theme;if(!n)try{n=Qo(qo,{})?.systemSettings?.theme}catch{}let i=mi(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,a,u)=>`${r||""}${d}${a||""} ${i}${u}\x1B[0m`)},ll=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 a=Math.min(t*Math.pow(2,r-1),i);await new Promise((u,p)=>{let x=setTimeout(u,a);o&&o.addEventListener("abort",()=>{clearTimeout(x),p(new DOMException("The user aborted a request.","AbortError"))})})}}},ht=!1;var cl=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 a=o.fullText||o.text||"";if(o.role==="user"&&r<d.length-1)if(a.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")){let u=a.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");if(u!==-1){let x=a.substring(0,u).lastIndexOf("[SYSTEM METADATA]");x!==-1?a=a.substring(x).trim():a=a.substring(u).trim()}}else{let u=a.lastIndexOf("[USER]"),p=a.lastIndexOf("[USER PROMPT]");u!==-1?a=a.substring(u+6).trim():p!==-1&&(a=a.substring(p).trim())}return{...o,text:a}}),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=[],a=[],u=!1,p=()=>{d.length>0&&(t.push({role:"agent",text:"combined"}),d=[]),a.length>0&&(t.push({role:"system",text:"combined"}),a=[]),u=!1};r.forEach(x=>{let m=x.role==="system"&&(x.text?.startsWith("[ACTION RESULT]")||x.text?.startsWith("[TOOL RESULT]")||x.text?.startsWith("SUCCESS:")||x.text?.startsWith("ERROR:")||x.fullText?.startsWith("[ACTION RESULT]")||x.fullText?.startsWith("[TOOL RESULT]")||x.fullText?.startsWith("SUCCESS:")||x.fullText?.startsWith("ERROR:")),f=x.fullText||x.text||"",s=f.trim();if(!(!s&&!x.binaryPart)){if(m)a.push(s);else if(x.role==="agent"){!u&&a.length>0&&p();let g=f.endsWith(`
585
- `),k=s.toLowerCase().includes("tool:")||s.toLowerCase().includes("action:");d.push(s),k&&g?u=!0:u=!1}}}),p()}}return t.length},dl=e=>typeof e!="string"?e:e.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,""),Ed=()=>{ht=!0},Cd=()=>ht,ds={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"},Jn=(e,n)=>{try{let t=H(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}},us=e=>e?new Jr({apiKey:e}):fs,Rd=async(e,n,t,i,o={})=>{let{onStatus:a,onMemoryUpdated:u,onBackgroundIncrement:p}=o,{profile:x,thinkingLevel:m,mode:f,janitorModel:s,chatId:g,systemSettings:k,sessionStats:ue,aiProvider:y="Google",apiKey:_}=e,W=process.env.NVIDIA_BASE_URL||y==="Ollama"||y==="InferX"||y==="SenseNova"||y==="AIHubMix"||y==="Poolside"||y==="9router"||y==="ExpLabs"||y==="ExperientialLabs"||y==="c_openai"||y==="Custom (OpenAI)"?!1:k?.memory!==!1,F=Rt(zn,[]).map(S=>`- [${S.id}]: ${S.memory}`).join(`
586
- `),E=i.slice(0,-1).filter(S=>S.text&&!S.text.includes("[ACTION RESULT]")&&!S.text.includes("[TOOL RESULT]")&&!S.text.includes("OBSERVATION:")&&!S.text.startsWith("[TERMINAL_RECORD]")&&!S.isTerminalRecord&&!S.isMeta&&!S.isLogo&&!String(S.id).startsWith("welcome")&&!String(S.id).startsWith("logo")).slice(-14).map(S=>{let C=Bt(dl(S.text)).replace(/\[(?:tool|action):(?:functions\.)?.*?\]/g,"").replace(/\[Prompted on:.*?\]/g,"").replace(/\[METADATA \(PRIORITY: DYNAMIC\)\] Time: ([^|\n]+)/g,(D,xe)=>`[METADATA (PRIORITY: DYNAMIC)] Time: ${xe.replace(/:\d{2}/g,"")}`).replace(/\[\[\s*turn\s*:\s*(continue|finish)\s*\]\]/gi,"").replace(/\[\[END\]\]/g,"").replace(/\[\[(?:TOOL|ACTION) RESULTS\]\]/gi,"").replace(/\[(?:TOOL|ACTION) RESULTS?\]/gi,"").replace(/\[(?:tool|action) results\]/gi,"").replace(/\r?\n\r?\n/g,`
584
+ `}),u};var Va={Ollama:()=>import("./ollama-4PI2BDMM.js").then(e=>e.getOllamaStream),OpenRouter:()=>import("./openrouter-6MRG4RT6.js").then(e=>e.getOpenRouterStream),DeepSeek:()=>import("./deepseek-WNWZJTNE.js").then(e=>e.getDeepSeekStream),Mistral:()=>import("./mistral-XDIMWAU3.js").then(e=>e.getMistralStream),NVIDIA:()=>import("./nvidia-PSGYXYNK.js").then(e=>e.getNVIDIAStream),NVIDIA_wrap:()=>import("./nvidia-PSGYXYNK.js").then(e=>e.wrapNvidiaStreamWithQueueDepth),InferX:()=>import("./inferx-HP5AGET3.js").then(e=>e.getInferXStream),SenseNova:()=>import("./sensenova-3K44URJQ.js").then(e=>e.getSenseNovaStream),AIHubMix:()=>import("./aihubmix-TETL5QYQ.js").then(e=>e.getAIHubMixStream),Poolside:()=>import("./poolside-ODFAIK4C.js").then(e=>e.getPoolsideStream),NineRouter:()=>import("./9router-LRFKCJF4.js").then(e=>e.getNineRouterStream),ExpLabs:()=>import("./explabs-XHHXTERB.js").then(e=>e.getExpLabsStream),TokenHarbor:()=>import("./tokenharbor-YV2GV2LM.js").then(e=>e.getTokenHarborStream),Infron:()=>import("./infron-ULXG7VDA.js").then(e=>e.getInfronStream),APInex:()=>import("./apinex-FAYOPQSL.js").then(e=>e.getAPInexStream),c_openai:()=>import("./custom_openai-XMDYE7NM.js").then(e=>e.getCustomOpenAIStream)},ls={},ce=async e=>(ls[e]||(ls[e]=await Va[e]()),ls[e]),Ya=/```[\s\S]*?```/g,za=/```[\s\S]*$/g,qa=/`[^`]+`/g,Xa=/^\|.*\|$/gm,Ja=/^[^\w]+|[^\w]+$/g,Qa=/[^a-z0-9]/gi,Uo=/\[\s*(?:tool|action):(?:functions\.)?([a-z0-9_]+)\s*\(/gi,Za=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-z0-9_]+)\s*\(/gi,el=/(?:path|targetFile|TargetFile|directory|keyword|id|taskId|title|task)\s*=\s*\\?["']?([^\\"' \),]+)/,vn=/["']/g,Vr=/\\/g,tl=/<\|channel>thought/gi,nl=/<channel\|>/gi,ol=e=>typeof e!="string"?e:e.replace(tl,"<think_fluxflow>").replace(nl,"</think_fluxflow>"),Ad=/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\]|$)/i,il=(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(!il(e,t.index,t[0].length))return{index:t.index,length:t[0].length};return{index:-1,length:0}},cs=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:""}},Gt=e=>{if(!e||typeof e!="string")return e;let n=cs(e);return n?n.remainingText.trimStart():e};var Yr=/<\|\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,rl=/"([^"]+)"\s*:\s*(?:"([^"]*)"|(\d+)|true|false|null)/g,zr=/<\|\s*tool_calls_section_begin\s*\|>/gi,qr=/<\|\s*tool_calls_section_end\s*\|>/gi,al=/```(?:tool|action|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi;var hi=e=>!e||typeof e!="string"?e:e.replace(/(```[\s\S]*?```|`[^`]*`)|(<(?:\w+)(?:[^>]*)>\r?\n?|\r?\n?<\/\w+(?:[^>]*)>)/gi,(n,t)=>t||""),Zr=e=>{if(!e||typeof e!="string")return e;let n=Qn(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);return/\[\s*(?:tool|action):/i.test(r)?e.trimEnd():e.substring(0,o).trimEnd()},fs=null,Wo={},Xn={key:null,value:null},Wt=e=>{if(!e)return e;let n=Wo?.theme;if(!n)try{n=Zo(Xo,{})?.systemSettings?.theme}catch{}let i=pi(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,a,u)=>`${r||""}${d}${a||""} ${i}${u}\x1B[0m`)},ll=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 a=Math.min(t*Math.pow(2,r-1),i);await new Promise((u,p)=>{let x=setTimeout(u,a);o&&o.addEventListener("abort",()=>{clearTimeout(x),p(new DOMException("The user aborted a request.","AbortError"))})})}}},wt=!1;var cl=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 a=o.fullText||o.text||"";if(o.role==="user"&&r<d.length-1)if(a.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")){let u=a.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");if(u!==-1){let x=a.substring(0,u).lastIndexOf("[SYSTEM METADATA]");x!==-1?a=a.substring(x).trim():a=a.substring(u).trim()}}else{let u=a.lastIndexOf("[USER]"),p=a.lastIndexOf("[USER PROMPT]");u!==-1?a=a.substring(u+6).trim():p!==-1&&(a=a.substring(p).trim())}return{...o,text:a}}),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=[],a=[],u=!1,p=()=>{d.length>0&&(t.push({role:"agent",text:"combined"}),d=[]),a.length>0&&(t.push({role:"system",text:"combined"}),a=[]),u=!1};r.forEach(x=>{let m=x.role==="system"&&(x.text?.startsWith("[ACTION RESULT]")||x.text?.startsWith("[TOOL RESULT]")||x.text?.startsWith("SUCCESS:")||x.text?.startsWith("ERROR:")||x.fullText?.startsWith("[ACTION RESULT]")||x.fullText?.startsWith("[TOOL RESULT]")||x.fullText?.startsWith("SUCCESS:")||x.fullText?.startsWith("ERROR:")),f=x.fullText||x.text||"",s=f.trim();if(!(!s&&!x.binaryPart)){if(m)a.push(s);else if(x.role==="agent"){!u&&a.length>0&&p();let g=f.endsWith(`
585
+ `),k=s.toLowerCase().includes("tool:")||s.toLowerCase().includes("action:");d.push(s),k&&g?u=!0:u=!1}}}),p()}}return t.length},dl=e=>typeof e!="string"?e:e.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,""),Ed=()=>{wt=!0},Cd=()=>wt,ds={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"},Jn=(e,n)=>{try{let t=j(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?K.basename(o.replace(/["']/g,"").replace(/\\/g,"/")):null}catch{return null}},us=e=>e?new Qr({apiKey:e}):fs,Rd=async(e,n,t,i,o={})=>{let{onStatus:a,onMemoryUpdated:u,onBackgroundIncrement:p}=o,{profile:x,thinkingLevel:m,mode:f,janitorModel:s,chatId:g,systemSettings:k,sessionStats:ue,aiProvider:y="Google",apiKey:_}=e,W=process.env.NVIDIA_BASE_URL||y==="Ollama"||y==="InferX"||y==="SenseNova"||y==="AIHubMix"||y==="Poolside"||y==="9router"||y==="ExpLabs"||y==="ExperientialLabs"||y==="c_openai"||y==="Custom (OpenAI)"?!1:k?.memory!==!1,F=_t(zn,[]).map(S=>`- [${S.id}]: ${S.memory}`).join(`
586
+ `),E=i.slice(0,-1).filter(S=>S.text&&!S.text.includes("[ACTION RESULT]")&&!S.text.includes("[TOOL RESULT]")&&!S.text.includes("OBSERVATION:")&&!S.text.startsWith("[TERMINAL_RECORD]")&&!S.isTerminalRecord&&!S.isMeta&&!S.isLogo&&!String(S.id).startsWith("welcome")&&!String(S.id).startsWith("logo")).slice(-14).map(S=>{let C=Gt(dl(S.text)).replace(/\[(?:tool|action):(?:functions\.)?.*?\]/g,"").replace(/\[Prompted on:.*?\]/g,"").replace(/\[METADATA \(PRIORITY: DYNAMIC\)\] Time: ([^|\n]+)/g,(N,xe)=>`[METADATA (PRIORITY: DYNAMIC)] Time: ${xe.replace(/:\d{2}/g,"")}`).replace(/\[\[\s*turn\s*:\s*(continue|finish)\s*\]\]/gi,"").replace(/\[\[END\]\]/g,"").replace(/\[\[(?:TOOL|ACTION) RESULTS\]\]/gi,"").replace(/\[(?:TOOL|ACTION) RESULTS?\]/gi,"").replace(/\[(?:tool|action) results\]/gi,"").replace(/\r?\n\r?\n/g,`
587
587
  `).replace(/\n\n/g,`
588
588
  `).replace(/\\n\\n/g,"").trim(),Ie=S.role==="user"?8192:32768,M=C.substring(0,Ie);C.length>Ie&&(M+=`
589
- ... (truncated) ...`);let A=S.role==="user"?M.startsWith("[USER]")?"":"[USER]: ":M.startsWith("[AGENT]")?"":"[AGENT]: ";return{role:S.role==="user"?"user":"model",parts:[{text:`${A}${M}`}]}}),pe=i.filter(S=>S.role==="user").length===1,Te=n.includes("[TITLE-UPDATE]"),ve=Math.random()<.8,we=pe||Te||ve,T=Bt(t).trim(),b=br(F,W,we),lt=`${T.replace(/\[(?:tool|action):(?:functions\.)?.*?\]/g,"").replace(/\[Prompted on:.*?\]/g,"").replace(/\[\[\s*turn\s*:\s*(continue|finish)\s*\]\]/gi,"").replace(/\[\[END\]\]/g,"").replace(/\[\[(?:TOOL|ACTION) RESULTS\]\]/gi,"").replace(/\[(?:TOOL|ACTION) RESULTS?\]/gi,"").replace(/\[(?:tool|action) results\]/gi,"").substring(0,32768)}`;lt.length>32768&&(lt+=`
590
- ... (truncated) ...`);let $e=n.replace(/\[Prompted on:.*?\]/g,"").trim();lt=lt.replace(/\r?\n\r?\n/g,`
589
+ ... (truncated) ...`);let A=S.role==="user"?M.startsWith("[USER]")?"":"[USER]: ":M.startsWith("[AGENT]")?"":"[AGENT]: ";return{role:S.role==="user"?"user":"model",parts:[{text:`${A}${M}`}]}}),pe=i.filter(S=>S.role==="user").length===1,Te=n.includes("[TITLE-UPDATE]"),ve=Math.random()<.8,we=pe||Te||ve,T=Gt(t).trim(),b=wr(F,W,we),ft=`${T.replace(/\[(?:tool|action):(?:functions\.)?.*?\]/g,"").replace(/\[Prompted on:.*?\]/g,"").replace(/\[\[\s*turn\s*:\s*(continue|finish)\s*\]\]/gi,"").replace(/\[\[END\]\]/g,"").replace(/\[\[(?:TOOL|ACTION) RESULTS\]\]/gi,"").replace(/\[(?:TOOL|ACTION) RESULTS?\]/gi,"").replace(/\[(?:tool|action) results\]/gi,"").substring(0,32768)}`;ft.length>32768&&(ft+=`
590
+ ... (truncated) ...`);let $e=n.replace(/\[Prompted on:.*?\]/g,"").trim();ft=ft.replace(/\r?\n\r?\n/g,`
591
591
  `).replace(/\n\n/g,`
592
- `).replace(/\\n\\n/g,"").trim();let Pt=new Date,vt=`[METADATA] Current date and Time: ${`${Pt.getFullYear()}-${Pt.toLocaleString("en-US",{month:"short"}).toUpperCase()}-${String(Pt.getDate()).padStart(2,"0")}, ${Pt.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}`}
592
+ `).replace(/\\n\\n/g,"").trim();let Lt=new Date,It=`[METADATA] Current date and Time: ${`${Lt.getFullYear()}-${Lt.toLocaleString("en-US",{month:"short"}).toUpperCase()}-${String(Lt.getDate()).padStart(2,"0")}, ${Lt.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}`}
593
593
 
594
594
  [USER]: ${$e.substring(0,8192)}
595
595
  ${$e.length>8192?`... (truncated) ...
596
596
 
597
597
  `:""}
598
- [AGENT (current turn)]: ${lt}`;E.push({role:"user",parts:[{text:vt}]});let Ut=await Mi("NVIDIA"),yn=(await To()).quotas?.providerTiers?.NVIDIA==="Free",Ot="",yt=0,cn=W?12:-1;for(;yt<=cn;)try{if(!await Es("background",e))return;let S="",C=null,Ie=!1,M=y;try{let xe=new Promise((ot,de)=>setTimeout(()=>de(new Error("JANITOR_TIMEOUT")),1e4)),Re=y==="Google"&&yt>=0&&yt<6&&Ut&&yn,ke=y==="DeepSeek"&&yt<4&&Ut&&yn;Ie=Re||ke,M=Ie?"NVIDIA":y;let Me=Date.now(),Wo=null,Wn=(async()=>{if(y==="OpenRouter"){let ot=ae("janitor_open_router"),le=(await ce("OpenRouter"))(_,ot,E,b,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),It=await le.next();return{iterator:le,firstResult:It}}else if(y==="DeepSeek"&&!Ie){let de=(await ce("DeepSeek"))(_,ae("deepseek_fast_fallback"),E,b,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),le=await de.next();return{iterator:de,firstResult:le}}else if(y==="Mistral"&&!Ie){let de=(await ce("Mistral"))(_,ae("mistral_janitor_fallback"),E,b,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),le=await de.next();return{iterator:de,firstResult:le}}else if(y==="NVIDIA"||Ie){let de=(await ce("NVIDIA"))(Ie?Ut:_,ae("nvidia_janitor_fallback"),E,b,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),le=await de.next();return{iterator:de,firstResult:le}}else if(y==="InferX"){let de=(await ce("InferX"))(_,targetModel||ae("inferx_fallback")||"deepseek-v4-flash",E,b,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),le=await de.next();return{iterator:de,firstResult:le}}else if(y==="SenseNova"){let de=(await ce("SenseNova"))(_,targetModel||ae("sensenova_fallback")||"sensenova-6.8-flash-lite",E,b,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),le=await de.next();return{iterator:de,firstResult:le}}else if(y==="AIHubMix"){let de=(await ce("AIHubMix"))(_,targetModel||ae("aihubmix_fallback")||"gpt-4o-mini",E,b,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),le=await de.next();return{iterator:de,firstResult:le}}else if(y==="Poolside"){let de=(await ce("Poolside"))(_,targetModel||ae("poolside_fallback")||"poolside/laguna-s-2.1",E,b,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),le=await de.next();return{iterator:de,firstResult:le}}else if(y==="9router"||y==="9Router"){let de=(await ce("NineRouter"))(_,targetModel||ae("9router_fallback")||"z-ai/glm-5.3-flash",E,b,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),le=await de.next();return{iterator:de,firstResult:le}}else if(y==="ExpLabs"||y==="ExperientialLabs"){let de=(await ce("ExpLabs"))(_,targetModel||ae("explabs_fallback")||"deepseek-v4-pro-0813",E,b,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),le=await de.next();return{iterator:de,firstResult:le}}else{let le=(await us(_).models.generateContentStream({model:s||(yt===cn?ae("janitor_default"):ae("gemma_janitor_fallback_google")),contents:E,config:{systemInstruction:b,temperature:.7,safetySettings:[{category:Un.HARM_CATEGORY_HARASSMENT,threshold:Bn.BLOCK_NONE},{category:Un.HARM_CATEGORY_HATE_SPEECH,threshold:Bn.BLOCK_NONE},{category:Un.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:Bn.BLOCK_NONE},{category:Un.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:Bn.BLOCK_NONE}],thinkingConfig:{includeThoughts:!1,thinkingLevel:He.MINIMAL},serviceTier:"flex"}}))[Symbol.asyncIterator](),It=await le.next();return{iterator:le,firstResult:It}}})();if(process.stdout.isTTY){let le=(await $i())[g]?.name||"",It=le&&!le.startsWith("flow-")&&!le.startsWith("Session ")?le:"FluxFlow | Idle";process.stdout.write(`\x1B]0;${It}\x07`),process.stdout.write(`\x1B]633;P;TerminalTitle=${It}\x07`)}let{iterator:uo,firstResult:Go}=await Promise.race([Wn,xe]);Wo=Date.now()-Me;let{value:xn,done:Wt}=Go;if(!Wt&&xn){let ot=xn.candidates?.[0]?.content?.parts,de=ot?M==="Google"?ot[1]?.text||ot[0]?.text||"":ot.filter(le=>le.text&&!le.thought).map(le=>le.text).join(""):typeof xn.text=="function"?xn.text():"";de&&(S+=de),C=xn.usageMetadata;for await(let le of{[Symbol.asyncIterator]:()=>uo}){let It=le.candidates?.[0]?.content?.parts,go=It?M==="Google"?It[1]?.text||It[0]?.text||"":It.filter(Qn=>Qn.text&&!Qn.thought).map(Qn=>Qn.text).join(""):typeof le.text=="function"?le.text():"";go&&(S+=go),C=le.usageMetadata}}}catch(xe){throw xe}if(S){if(Ot=S,C){let xe=C.totalTokenCount||0,Re=C.cachedContentTokenCount||0,ke=(C.candidatesTokenCount||0)+(M==="Google"&&C.thoughtsTokenCount||0),Me=Ie?ae("nvidia_janitor_fallback"):M==="DeepSeek"?ae("deepseek_fast_fallback"):M==="ExpLabs"||M==="ExperientialLabs"?ae("explabs_fallback")||"deepseek-v4-pro-0813":M==="OpenRouter"?ae("janitor_open_router"):s||(yt===cn?ae("janitor_default"):ae("gemma_janitor_fallback_google"));await pt("tokens",xe,M,Me),Re>0&&await pt("cachedTokens",Re,M,Me),ke>0&&await pt("candidateTokens",ke,M,Me),janitorTtft!==null&&janitorTtft>0&&await pt("ttft",janitorTtft,M,Me),ko({provider:M,model:Me,prompt:C.promptTokenCount||0,cached:Re,output:ke,reasoning:C.thoughtsTokenCount||0,ttft:janitorTtft})}}else throw new Error("No synthesis generated by Janitor.");p&&(p(),await _t("background"));let A=fo(Ot),D=!1;for(let xe of A){let Re=xe.toolName;["addMemScore","add_mem_score","AddMemScore","addMemoryScore","AddMemoryScore"].includes(Re)&&(D=!0);let ke={chatId:g,sessionId:g,history:i},Me=await No(Re,xe.args,ke);Re.toLowerCase()==="memory"&&(xe.args.includes("action='user'")||xe.args.includes('action="user"'))&&!Me.startsWith("ERROR")&&(u&&u(),process.stdout.isTTY&&(process.stdout.write("\x1B]0;Memory Updated\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=Memory Updated\x07")),await new Promise(Wn=>setTimeout(Wn,3e3)))}if(!D)try{let xe=Rt(zn,[]);if(xe.length>0){let Re=[];for(let ke of xe)ke.score===void 0&&(ke.score=.5),ke.score*=.99995,ke.score<.05&&(ke.score=0),ke.score=Math.round(ke.score*1e5)/1e5,ke.score>0&&Re.push(ke);so(zn,Re)}}catch{}break}catch(S){yt++;let C=new Date().toLocaleString(),Ie=S instanceof Error?(()=>{try{return JSON.parse(JSON.parse(S.message).error.message).error.message}catch{return String(S)}})():String(S);await new Promise(D=>setTimeout(D,1e3));let M=j.join(Rn,"janitor");if(Se.existsSync(M)||Se.mkdirSync(M,{recursive:!0}),Se.appendFileSync(j.join(M,"error.log"),`ERROR [Attempt ${yt}/${cn+1}] [${C}]: ${Ie}
598
+ [AGENT (current turn)]: ${ft}`;E.push({role:"user",parts:[{text:It}]});let Ht=await Mi("NVIDIA"),xn=(await ko()).quotas?.providerTiers?.NVIDIA==="Free",$t="",St=0,dn=W?12:-1;for(;St<=dn;)try{if(!await Cs("background",e))return;let S="",C=null,Ie=!1,M=y;try{let xe=new Promise((st,de)=>setTimeout(()=>de(new Error("JANITOR_TIMEOUT")),1e4)),Re=y==="Google"&&St>=0&&St<6&&Ht&&xn,ke=y==="DeepSeek"&&St<4&&Ht&&xn;Ie=Re||ke,M=Ie?"NVIDIA":y;let Me=Date.now(),Go=null,Wn=(async()=>{if(y==="OpenRouter"){let st=ae("janitor_open_router"),le=(await ce("OpenRouter"))(_,st,E,b,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),Mt=await le.next();return{iterator:le,firstResult:Mt}}else if(y==="DeepSeek"&&!Ie){let de=(await ce("DeepSeek"))(_,ae("deepseek_fast_fallback"),E,b,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),le=await de.next();return{iterator:de,firstResult:le}}else if(y==="Mistral"&&!Ie){let de=(await ce("Mistral"))(_,ae("mistral_janitor_fallback"),E,b,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),le=await de.next();return{iterator:de,firstResult:le}}else if(y==="NVIDIA"||Ie){let de=(await ce("NVIDIA"))(Ie?Ht:_,ae("nvidia_janitor_fallback"),E,b,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),le=await de.next();return{iterator:de,firstResult:le}}else if(y==="InferX"){let de=(await ce("InferX"))(_,targetModel||ae("inferx_fallback")||"deepseek-v4-flash",E,b,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),le=await de.next();return{iterator:de,firstResult:le}}else if(y==="SenseNova"){let de=(await ce("SenseNova"))(_,targetModel||ae("sensenova_fallback")||"sensenova-6.8-flash-lite",E,b,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),le=await de.next();return{iterator:de,firstResult:le}}else if(y==="AIHubMix"){let de=(await ce("AIHubMix"))(_,targetModel||ae("aihubmix_fallback")||"gpt-4o-mini",E,b,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),le=await de.next();return{iterator:de,firstResult:le}}else if(y==="Poolside"){let de=(await ce("Poolside"))(_,targetModel||ae("poolside_fallback")||"poolside/laguna-s-2.1",E,b,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),le=await de.next();return{iterator:de,firstResult:le}}else if(y==="9router"||y==="9Router"){let de=(await ce("NineRouter"))(_,targetModel||ae("9router_fallback")||"z-ai/glm-5.3-flash",E,b,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),le=await de.next();return{iterator:de,firstResult:le}}else if(y==="ExpLabs"||y==="ExperientialLabs"){let de=(await ce("ExpLabs"))(_,targetModel||ae("explabs_fallback")||"deepseek-v4-pro-0813",E,b,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),le=await de.next();return{iterator:de,firstResult:le}}else{let le=(await us(_).models.generateContentStream({model:s||(St===dn?ae("janitor_default"):ae("gemma_janitor_fallback_google")),contents:E,config:{systemInstruction:b,temperature:.7,safetySettings:[{category:Un.HARM_CATEGORY_HARASSMENT,threshold:Bn.BLOCK_NONE},{category:Un.HARM_CATEGORY_HATE_SPEECH,threshold:Bn.BLOCK_NONE},{category:Un.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:Bn.BLOCK_NONE},{category:Un.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:Bn.BLOCK_NONE}],thinkingConfig:{includeThoughts:!1,thinkingLevel:Ke.MINIMAL},serviceTier:"flex"}}))[Symbol.asyncIterator](),Mt=await le.next();return{iterator:le,firstResult:Mt}}})();if(process.stdout.isTTY){let le=(await $i())[g]?.name||"",Mt=le&&!le.startsWith("flow-")&&!le.startsWith("Session ")?le:"FluxFlow | Idle";process.stdout.write(`\x1B]0;${Mt}\x07`),process.stdout.write(`\x1B]633;P;TerminalTitle=${Mt}\x07`)}let{iterator:go,firstResult:Ho}=await Promise.race([Wn,xe]);Go=Date.now()-Me;let{value:bn,done:jt}=Ho;if(!jt&&bn){let st=bn.candidates?.[0]?.content?.parts,de=st?M==="Google"?st[1]?.text||st[0]?.text||"":st.filter(le=>le.text&&!le.thought).map(le=>le.text).join(""):typeof bn.text=="function"?bn.text():"";de&&(S+=de),C=bn.usageMetadata;for await(let le of{[Symbol.asyncIterator]:()=>go}){let Mt=le.candidates?.[0]?.content?.parts,mo=Mt?M==="Google"?Mt[1]?.text||Mt[0]?.text||"":Mt.filter(Zn=>Zn.text&&!Zn.thought).map(Zn=>Zn.text).join(""):typeof le.text=="function"?le.text():"";mo&&(S+=mo),C=le.usageMetadata}}}catch(xe){throw xe}if(S){if($t=S,C){let xe=C.totalTokenCount||0,Re=C.cachedContentTokenCount||0,ke=(C.candidatesTokenCount||0)+(M==="Google"&&C.thoughtsTokenCount||0),Me=Ie?ae("nvidia_janitor_fallback"):M==="DeepSeek"?ae("deepseek_fast_fallback"):M==="ExpLabs"||M==="ExperientialLabs"?ae("explabs_fallback")||"deepseek-v4-pro-0813":M==="OpenRouter"?ae("janitor_open_router"):s||(St===dn?ae("janitor_default"):ae("gemma_janitor_fallback_google"));await bt("tokens",xe,M,Me),Re>0&&await bt("cachedTokens",Re,M,Me),ke>0&&await bt("candidateTokens",ke,M,Me),janitorTtft!==null&&janitorTtft>0&&await bt("ttft",janitorTtft,M,Me),Ao({provider:M,model:Me,prompt:C.promptTokenCount||0,cached:Re,output:ke,reasoning:C.thoughtsTokenCount||0,ttft:janitorTtft})}}else throw new Error("No synthesis generated by Janitor.");p&&(p(),await vt("background"));let A=Qn($t),N=!1;for(let xe of A){let Re=xe.toolName;["addMemScore","add_mem_score","AddMemScore","addMemoryScore","AddMemoryScore"].includes(Re)&&(N=!0);let ke={chatId:g,sessionId:g,history:i},Me=await Do(Re,xe.args,ke);Re.toLowerCase()==="memory"&&(xe.args.includes("action='user'")||xe.args.includes('action="user"'))&&!Me.startsWith("ERROR")&&(u&&u(),process.stdout.isTTY&&(process.stdout.write("\x1B]0;Memory Updated\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=Memory Updated\x07")),await new Promise(Wn=>setTimeout(Wn,3e3)))}if(!N)try{let xe=_t(zn,[]);if(xe.length>0){let Re=[];for(let ke of xe)ke.score===void 0&&(ke.score=.5),ke.score*=.99995,ke.score<.05&&(ke.score=0),ke.score=Math.round(ke.score*1e5)/1e5,ke.score>0&&Re.push(ke);ao(zn,Re)}}catch{}break}catch(S){St++;let C=new Date().toLocaleString(),Ie=S instanceof Error?(()=>{try{return JSON.parse(JSON.parse(S.message).error.message).error.message}catch{return String(S)}})():String(S);await new Promise(N=>setTimeout(N,1e3));let M=K.join(_n,"janitor");if(Se.existsSync(M)||Se.mkdirSync(M,{recursive:!0}),Se.appendFileSync(K.join(M,"error.log"),`ERROR [Attempt ${St}/${dn+1}] [${C}]: ${Ie}
599
599
 
600
- `),yt>cn)break;let A=Math.min(750*Math.pow(2,yt-1),5e3);await new Promise(D=>setTimeout(D,A))}if(yt){let S=j.join(Rn,"janitor");Se.appendFileSync(j.join(S,"error.log"),`-----------------------------------------------------------------------------
600
+ `),St>dn)break;let A=Math.min(750*Math.pow(2,St-1),5e3);await new Promise(N=>setTimeout(N,A))}if(St){let S=K.join(_n,"janitor");Se.appendFileSync(K.join(S,"error.log"),`-----------------------------------------------------------------------------
601
601
 
602
- `)}if(process.stdout.isTTY)try{let Ie=(await $i())[g]?.name||"",M=Ie&&!Ie.startsWith("flow-")&&!Ie.startsWith("Session ")?Ie:"FluxFlow | Idle";process.stdout.write(`\x1B]0;${M}\x07`),process.stdout.write(`\x1B]633;P;TerminalTitle=${M}\x07`)}catch{process.stdout.write("\x1B]0;FluxFlow | Idle\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow | Idle\x07")}},Zr=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]!==`
602
+ `)}if(process.stdout.isTTY)try{let Ie=(await $i())[g]?.name||"",M=Ie&&!Ie.startsWith("flow-")&&!Ie.startsWith("Session ")?Ie:"FluxFlow | Idle";process.stdout.write(`\x1B]0;${M}\x07`),process.stdout.write(`\x1B]633;P;TerminalTitle=${M}\x07`)}catch{process.stdout.write("\x1B]0;FluxFlow | Idle\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow | Idle\x07")}},gs=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]!==`
603
603
  `&&n[o]!=="\r"&&(n[o]=" "),o++;continue}if(n[o]==="`"){i=!i,n[o]=" ",o++;continue}if(i){n[o]===`
604
- `||n[o]==="\r"?i=!1:n[o]=" ",o++;continue}o++}return n.join("")},fl=e=>{let n=Bt(e),t=Zr(n);Bo.lastIndex=0;let i;for(;(i=Bo.exec(t))!==null;){let o=i.index+i[0].length-1,r=0,d=null,a=!1,u=!1;for(let p=o;p<t.length;p++){let x=t[p];if(!d&&(x==='"'||x==="'"||x==="`")?(d=x,a=!1):d&&x===d&&!a&&(d=null),!d&&(x==="("?r++:x===")"&&r--,r===0)){let m=p+1;for(;m<t.length&&/\s/.test(t[m]);)m++;if(m<t.length&&t[m]==="]"){u=!0,Bo.lastIndex=m+1;break}}x==="\\"?a=!a:a=!1}if(!u)return{inside:!0,toolName:i[1],startIndex:i.index,args:n.substring(i.index+i[0].length)}}return{inside:!1}},ea=(e,n=!0)=>{let t=Bo;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?Bt(d):d;let a=r.index+r[0].length-1,u=0,p=null,x=-1;for(let m=a;m<e.length;m++){let f=e[m];if(p){if(f===p){let s=0;for(let g=m-1;g>=0&&e[g]==="\\";g--)s++;s%2===0&&(p=null)}}else if(f==='"'||f==="'"||f==="`")p=f;else if(f==="(")u++;else if(f===")"&&(u--,u===0)){let s=m+1;for(;s<e.length&&/\s/.test(e[s]);)s++;if(s<e.length&&e[s]==="]"){x=s;break}}}if(x!==-1)i+="[tool:functions."+r[1]+"()]",o=x+1,t.lastIndex=o;else{i+="[tool:functions."+r[1]+"(",o=e.length;break}}return o<e.length&&(i+=n&&o===0?Bt(e.substring(o)):e.substring(o)),i},ul=(e,n,t)=>{let i=Bo;i.lastIndex=0;let o="",r=0,d;for(;(d=i.exec(e))!==null;){let a=e.substring(r,d.index);o+=a.replace(n,t);let u=d.index+d[0].length-1,p=0,x=null,m=-1;for(let f=u;f<e.length;f++){let s=e[f];if(x){if(s===x){let g=0;for(let k=f-1;k>=0&&e[k]==="\\";k--)g++;g%2===0&&(x=null)}}else if(s==='"'||s==="'"||s==="`")x=s;else if(s==="(")p++;else if(s===")"&&(p--,p===0)){let g=f+1;for(;g<e.length&&/\s/.test(e[g]);)g++;if(g<e.length&&e[g]==="]"){m=g;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},qr=e=>ea(e,!0),gl=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("");Vr.lastIndex=0;let i=e.replace(Vr,(o,r,d)=>{let a="";try{let x=JSON.parse(d.trim());x&&typeof x=="object"&&(a=Object.entries(x).map(([f,s])=>{let g=typeof s=="string"?s:JSON.stringify(s);return`${f}=${JSON.stringify(g)}`}).join(", "))}catch{let m=[],f=rl;f.lastIndex=0;let s;for(;(s=f.exec(d))!==null;){let g=s[1],k=s[2]!==void 0?s[2]:s[0].split(":").slice(1).join(":").trim();m.push(`${g}=${JSON.stringify(k)}`)}m.length>0?a=m.join(", "):a=d.trim()}let u=r.toLowerCase().replace(/_/g,"");return`[tool:functions.${n[u]||t(r)}(${a})]`});return Yr.lastIndex=0,zr.lastIndex=0,i=i.replace(Yr,""),i=i.replace(zr,""),i},fo=e=>{if(!e)return[];let n=gl(e),t=Bt(n),i=[],o=Zr(t),r=Za;r.lastIndex=0;let d;for(;(d=r.exec(o))!==null;){let a=d[1],u=d.index+d[0].length-1,p=0,x=null,m=-1,f=-1;for(let s=u;s<o.length;s++){let g=o[s];if(x){if(g===x){let k=0;for(let ue=s-1;ue>=0&&o[ue]==="\\";ue--)k++;k%2===0&&(x=null)}}else{if(s>u&&(o.substring(s).startsWith("[action:")||o.substring(s).startsWith("[tool:")))break;if(g==='"'||g==="'"||g==="`")x=g;else if(g==="(")p++;else if(g===")"&&(p--,p===0)){f=s;let k=s+1;for(;k<o.length&&/\s/.test(o[k]);)k++;if(k<o.length&&o[k]==="]"){m=k;break}}}}if(m!==-1){let s=t.substring(u+1,f),g=t.substring(d.index,m+1);i.push({fullMatch:g,toolName:a.trim(),args:s.trim()}),r.lastIndex=m+1}}return i},Xr=e=>{if(!e)return null;let n=Bt(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 f=0;f<o.length;f++){let s=o[f],g=f+1<o.length?o[f+1].index:n.length,k=n.substring(s.index,g),ue=k.indexOf("("),y=ue!==-1?k.substring(ue+1):"",_=0,W=null,K=!1;for(let F=0;F<y.length;F++){let E=y[F];if(W){if(E===W){let pe=0;for(let Te=F-1;Te>=0&&y[Te]==="\\";Te--)pe++;pe%2===0&&(W=null)}}else if(E==='"'||E==="'"||E==="`")W=E;else if(E==="(")_++;else if(E===")")if(_>0)_--;else{let pe=F+1;for(;pe<y.length&&/\s/.test(y[pe]);)pe++;if(pe<y.length&&y[pe]==="]"){K=!0;break}}}if(!K){let F=k.trim(),E="";W?E=`Unclosed quote string (${W}) inside arguments`:F.endsWith("]")?E=`Missing closing ')' before ']' (e.g. found "...]")`:F.endsWith(")")?E=`Missing closing ']' after ')' (e.g. found "...)" instead of "...)]")`:!F.includes(")")&&!F.includes("]")?E="Missing closing delimiter ')]'":E="Malformed or unclosed call syntax (missing ')]')",t.push(`\u2022 [action:${s.toolName}(...)]: ${E}. Expected: [action:${s.toolName}(arg1="...", arg2="...")]`)}}let d=/(?:^|[^\w\[])(?:tool|action):(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/gi,a;for(;(a=d.exec(n))!==null;){let f=a[1],s=a.index+(a[0].indexOf(":")-(a[0].startsWith("action")||a[0].startsWith("tool")?0:1));(s>0?n[s-1]:"")!=="["&&ui(f)&&t.push(`\u2022 action:${f}(...): Missing opening bracket '['. Expected: [action:${f}(...)]`)}let u=/\[\s*(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/g,p;for(;(p=u.exec(n))!==null;){let f=p[1];f!=="action"&&f!=="tool"&&ui(f)&&t.push(`\u2022 [${f}(...)]: Missing 'action:' prefix. Expected: [action:${f}(...)]`)}let x=/\[\s*(?:tool|action)\s*:\s*(?:functions\.)?([a-zA-Z0-9_]+)(?!\s*\()/gi,m;for(;(m=x.exec(n))!==null;){let f=m[1];ui(f)&&t.push(`\u2022 [action:${f}...]: Missing opening '(' for tool arguments. Expected: [action:${f}(...)]`)}return t.length>0?t.join(`
605
- `):null},_d=(e,n={})=>{if(!e)return null;if(Uo=n,fs=new Jr({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}}}},ta=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}},hi=async(e,n,t,i,o="Fast",r=.75,d="agent")=>ll(async()=>{let{aiProvider:a="Google",apiKey:u,mode:p}=e,x="",m=null,f=typeof t=="string"?[{role:"user",parts:[{text:t}]}]:t,s=new AbortController,g=s.signal,k=setInterval(()=>{ht&&(s.abort(),clearInterval(k))},100),ue=Date.now(),y=null;try{let _;if(a==="Ollama")_=(await ce("Ollama"))(u,n,f,i,o,p,rt(n),g,r,e.systemSettings?.ollamaEndpoint||"Cloud");else if(a==="OpenRouter")_=(await ce("OpenRouter"))(u,n,f,i,o,p,rt(n),g,r);else if(a==="DeepSeek")_=(await ce("DeepSeek"))(u,n,f,i,o,p,rt(n),g,r);else if(a==="Mistral")_=(await ce("Mistral"))(u,n,f,i,o,p,rt(n),g,r);else if(a==="NVIDIA")_=(await ce("NVIDIA"))(u,n,f,i,o,p,rt(n),g,r);else if(a==="InferX")_=(await ce("InferX"))(u,n,f,i,o,p,rt(n),g,r);else if(a==="SenseNova")_=(await ce("SenseNova"))(u,n,f,i,o,p,rt(n),g,r);else if(a==="AIHubMix")_=(await ce("AIHubMix"))(u,n,f,i,o,p,rt(n),g,r);else if(a==="Poolside")_=(await ce("Poolside"))(u,n,f,i,o,p,rt(n),g,r);else if(a==="9router"||a==="9Router")_=(await ce("NineRouter"))(u,n,f,i,o,p,rt(n),g,r);else if(a==="ExpLabs"||a==="ExperientialLabs")_=(await ce("ExpLabs"))(u,n,f,i,o,p,rt(n),g,r);else if(a==="Infron"||a==="infron")_=(await ce("Infron"))(u,n,f,i,o,p,rt(n),g,r);else if(a==="TokenHarbor"||a==="Token Harbor"||a==="tokenharbor"||a==="token_harbor"||a==="thk")_=(await ce("TokenHarbor"))(u,n,f,i,o,p,rt(n),g,r);else if(a==="APInex"||a==="apinex"||a==="apx")_=(await ce("APInex"))(u,n,f,i,o,p,rt(n),g,r);else if(a==="c_openai"||a==="Custom (OpenAI)")_=(await ce("c_openai"))(u,n,f,i,o,p,rt(n),g,r,e.systemSettings?.customOpenAIBaseUrl||"");else{let W=us(u),{serviceTier:K,cleanModel:F}=ta(n),E={systemInstruction:i,temperature:r,thinkingConfig:(()=>{let Te=(n||"").toLowerCase(),ve=Te.includes("gemma-4")||Te.startsWith("gemma"),we=Te.includes("gemini-3");if(ve||we)return ve?o.toLowerCase()!=="xhigh"?{includeThoughts:!1,thinkingLevel:He.MINIMAL}:{includeThoughts:!0,thinkingLevel:He.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:Te.includes("pro")?He.LOW:He.MINIMAL,Low:He.LOW,Medium:He.MEDIUM,Standard:He.MEDIUM,High:He.HIGH,xHigh:He.HIGH}[o]||He.MEDIUM};{let T={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[o]||2048;return T===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:T}}})()};K&&(E.serviceTier=K),_=await W.models.generateContentStream({model:F,contents:f,config:E},{signal:g})}for await(let W of _){if(ht)throw new Error("Subagent task was cancelled.");if(e?.taskId&&typeof Vt<"u"){let E=Vt.find(pe=>pe.id===e.taskId);if(E&&E.status==="cancelled")throw new Error("Subagent task was cancelled.")}y===null&&(W.candidates?.[0]?.content?.parts||W.text)&&(y=Date.now()-ue);let K="";if(W.candidates?.[0]?.content?.parts)for(let E of W.candidates[0].content.parts)E.text&&!E.thought&&(x+=E.text,K+=E.text);let F=K?Oi(K):0;e&&typeof e.onTokenChunk=="function"&&e.onTokenChunk(K,F),W.usageMetadata&&(m=W.usageMetadata)}}finally{clearInterval(k)}if(m){let _=m.totalTokenCount||0,W=m.cachedContentTokenCount||0,K=(m.candidatesTokenCount||0)+(a==="Google"&&m.thoughtsTokenCount||0);await pt("tokens",_,a,n),W>0&&await pt("cachedTokens",W,a,n),K>0&&await pt("candidateTokens",K,a,n),y!==null&&y>0&&await pt("ttft",y,a,n),ko({provider:a,model:n,prompt:m.promptTokenCount||0,cached:W,output:K,reasoning:m.thoughtsTokenCount||0,ttft:y}),e&&typeof e.onUsage=="function"&&e.onUsage({totalTokenCount:_,cachedContentTokenCount:W,candidatesTokenCount:K})}return await _t("agent",a),{text:x,usageMetadata:m}}),ml=async(e,n,t=null)=>{t=t||Rt(Jo,{});try{let{aiProvider:i="Google"}=n;if(Object.values(t).flat().length<=5)return;let r=Object.keys(t).filter(f=>f!==e&&Array.isArray(t[f])&&t[f].length>2);if(r.length===0)return;let d=`You are a silent background process for the FluxFlow CLI Agent.
604
+ `||n[o]==="\r"?i=!1:n[o]=" ",o++;continue}o++}return n.join("")},fl=e=>{let n=Gt(e),t=gs(n);Uo.lastIndex=0;let i;for(;(i=Uo.exec(t))!==null;){let o=i.index+i[0].length-1,r=0,d=null,a=!1,u=!1;for(let p=o;p<t.length;p++){let x=t[p];if(!d&&(x==='"'||x==="'"||x==="`")?(d=x,a=!1):d&&x===d&&!a&&(d=null),!d&&(x==="("?r++:x===")"&&r--,r===0)){let m=p+1;for(;m<t.length&&/\s/.test(t[m]);)m++;if(m<t.length&&t[m]==="]"){u=!0,Uo.lastIndex=m+1;break}}x==="\\"?a=!a:a=!1}if(!u)return{inside:!0,toolName:i[1],startIndex:i.index,args:n.substring(i.index+i[0].length)}}return{inside:!1}},ea=(e,n=!0)=>{let t=Uo;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?Gt(d):d;let a=r.index+r[0].length-1,u=0,p=null,x=-1;for(let m=a;m<e.length;m++){let f=e[m];if(p){if(f===p){let s=0;for(let g=m-1;g>=0&&e[g]==="\\";g--)s++;s%2===0&&(p=null)}}else if(f==='"'||f==="'"||f==="`")p=f;else if(f==="(")u++;else if(f===")"&&(u--,u===0)){let s=m+1;for(;s<e.length&&/\s/.test(e[s]);)s++;if(s<e.length&&e[s]==="]"){x=s;break}}}if(x!==-1)i+="[tool:functions."+r[1]+"()]",o=x+1,t.lastIndex=o;else{i+="[tool:functions."+r[1]+"(",o=e.length;break}}return o<e.length&&(i+=n&&o===0?Gt(e.substring(o)):e.substring(o)),i},ul=(e,n,t)=>{let i=Uo;i.lastIndex=0;let o="",r=0,d;for(;(d=i.exec(e))!==null;){let a=e.substring(r,d.index);o+=a.replace(n,t);let u=d.index+d[0].length-1,p=0,x=null,m=-1;for(let f=u;f<e.length;f++){let s=e[f];if(x){if(s===x){let g=0;for(let k=f-1;k>=0&&e[k]==="\\";k--)g++;g%2===0&&(x=null)}}else if(s==='"'||s==="'"||s==="`")x=s;else if(s==="(")p++;else if(s===")"&&(p--,p===0)){let g=f+1;for(;g<e.length&&/\s/.test(e[g]);)g++;if(g<e.length&&e[g]==="]"){m=g;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},Xr=e=>ea(e,!0),gl=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("");Yr.lastIndex=0;let i=e.replace(Yr,(o,r,d)=>{let a="";try{let x=JSON.parse(d.trim());x&&typeof x=="object"&&(a=Object.entries(x).map(([f,s])=>{let g=typeof s=="string"?s:JSON.stringify(s);return`${f}=${JSON.stringify(g)}`}).join(", "))}catch{let m=[],f=rl;f.lastIndex=0;let s;for(;(s=f.exec(d))!==null;){let g=s[1],k=s[2]!==void 0?s[2]:s[0].split(":").slice(1).join(":").trim();m.push(`${g}=${JSON.stringify(k)}`)}m.length>0?a=m.join(", "):a=d.trim()}let u=r.toLowerCase().replace(/_/g,"");return`[tool:functions.${n[u]||t(r)}(${a})]`});return zr.lastIndex=0,qr.lastIndex=0,i=i.replace(zr,""),i=i.replace(qr,""),i},Qn=e=>{if(!e)return[];let n=gl(e),t=Gt(n),i=[],o=gs(t),r=Za;r.lastIndex=0;let d;for(;(d=r.exec(o))!==null;){let a=d[1],u=d.index+d[0].length-1,p=0,x=null,m=-1,f=-1;for(let s=u;s<o.length;s++){let g=o[s];if(x){if(g===x){let k=0;for(let ue=s-1;ue>=0&&o[ue]==="\\";ue--)k++;k%2===0&&(x=null)}}else{if(s>u&&(o.substring(s).startsWith("[action:")||o.substring(s).startsWith("[tool:")))break;if(g==='"'||g==="'"||g==="`")x=g;else if(g==="(")p++;else if(g===")"&&(p--,p===0)){f=s;let k=s+1;for(;k<o.length&&/\s/.test(o[k]);)k++;if(k<o.length&&o[k]==="]"){m=k;break}}}}if(m!==-1){let s=t.substring(u+1,f),g=t.substring(d.index,m+1);i.push({fullMatch:g,toolName:a.trim(),args:s.trim()}),r.lastIndex=m+1}}return i},Jr=e=>{if(!e)return null;let n=Gt(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 f=0;f<o.length;f++){let s=o[f],g=f+1<o.length?o[f+1].index:n.length,k=n.substring(s.index,g),ue=k.indexOf("("),y=ue!==-1?k.substring(ue+1):"",_=0,W=null,V=!1;for(let F=0;F<y.length;F++){let E=y[F];if(W){if(E===W){let pe=0;for(let Te=F-1;Te>=0&&y[Te]==="\\";Te--)pe++;pe%2===0&&(W=null)}}else if(E==='"'||E==="'"||E==="`")W=E;else if(E==="(")_++;else if(E===")")if(_>0)_--;else{let pe=F+1;for(;pe<y.length&&/\s/.test(y[pe]);)pe++;if(pe<y.length&&y[pe]==="]"){V=!0;break}}}if(!V){let F=k.trim(),E="";W?E=`Unclosed quote string (${W}) inside arguments`:F.endsWith("]")?E=`Missing closing ')' before ']' (e.g. found "...]")`:F.endsWith(")")?E=`Missing closing ']' after ')' (e.g. found "...)" instead of "...)]")`:!F.includes(")")&&!F.includes("]")?E="Missing closing delimiter ')]'":E="Malformed or unclosed call syntax (missing ')]')",t.push(`\u2022 [action:${s.toolName}(...)]: ${E}. Expected: [action:${s.toolName}(arg1="...", arg2="...")]`)}}let d=/(?:^|[^\w\[])(?:tool|action):(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/gi,a;for(;(a=d.exec(n))!==null;){let f=a[1],s=a.index+(a[0].indexOf(":")-(a[0].startsWith("action")||a[0].startsWith("tool")?0:1));(s>0?n[s-1]:"")!=="["&&gi(f)&&t.push(`\u2022 action:${f}(...): Missing opening bracket '['. Expected: [action:${f}(...)]`)}let u=/\[\s*(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/g,p;for(;(p=u.exec(n))!==null;){let f=p[1];f!=="action"&&f!=="tool"&&gi(f)&&t.push(`\u2022 [${f}(...)]: Missing 'action:' prefix. Expected: [action:${f}(...)]`)}let x=/\[\s*(?:tool|action)\s*:\s*(?:functions\.)?([a-zA-Z0-9_]+)(?!\s*\()/gi,m;for(;(m=x.exec(n))!==null;){let f=m[1];gi(f)&&t.push(`\u2022 [action:${f}...]: Missing opening '(' for tool arguments. Expected: [action:${f}(...)]`)}return t.length>0?t.join(`
605
+ `):null},_d=(e,n={})=>{if(!e)return null;if(Wo=n,fs=new Qr({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}}}},ta=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}},yi=async(e,n,t,i,o="Fast",r=.75,d="agent")=>ll(async()=>{let{aiProvider:a="Google",apiKey:u,mode:p}=e,x="",m=null,f=typeof t=="string"?[{role:"user",parts:[{text:t}]}]:t,s=new AbortController,g=s.signal,k=setInterval(()=>{wt&&(s.abort(),clearInterval(k))},100),ue=Date.now(),y=null;try{let _;if(a==="Ollama")_=(await ce("Ollama"))(u,n,f,i,o,p,ct(n),g,r,e.systemSettings?.ollamaEndpoint||"Cloud");else if(a==="OpenRouter")_=(await ce("OpenRouter"))(u,n,f,i,o,p,ct(n),g,r);else if(a==="DeepSeek")_=(await ce("DeepSeek"))(u,n,f,i,o,p,ct(n),g,r);else if(a==="Mistral")_=(await ce("Mistral"))(u,n,f,i,o,p,ct(n),g,r);else if(a==="NVIDIA")_=(await ce("NVIDIA"))(u,n,f,i,o,p,ct(n),g,r);else if(a==="InferX")_=(await ce("InferX"))(u,n,f,i,o,p,ct(n),g,r);else if(a==="SenseNova")_=(await ce("SenseNova"))(u,n,f,i,o,p,ct(n),g,r);else if(a==="AIHubMix")_=(await ce("AIHubMix"))(u,n,f,i,o,p,ct(n),g,r);else if(a==="Poolside")_=(await ce("Poolside"))(u,n,f,i,o,p,ct(n),g,r);else if(a==="9router"||a==="9Router")_=(await ce("NineRouter"))(u,n,f,i,o,p,ct(n),g,r);else if(a==="ExpLabs"||a==="ExperientialLabs")_=(await ce("ExpLabs"))(u,n,f,i,o,p,ct(n),g,r);else if(a==="Infron"||a==="infron")_=(await ce("Infron"))(u,n,f,i,o,p,ct(n),g,r);else if(a==="TokenHarbor"||a==="Token Harbor"||a==="tokenharbor"||a==="token_harbor"||a==="thk")_=(await ce("TokenHarbor"))(u,n,f,i,o,p,ct(n),g,r);else if(a==="APInex"||a==="apinex"||a==="apx")_=(await ce("APInex"))(u,n,f,i,o,p,ct(n),g,r);else if(a==="c_openai"||a==="Custom (OpenAI)")_=(await ce("c_openai"))(u,n,f,i,o,p,ct(n),g,r,e.systemSettings?.customOpenAIBaseUrl||"");else{let W=us(u),{serviceTier:V,cleanModel:F}=ta(n),E={systemInstruction:i,temperature:r,thinkingConfig:(()=>{let Te=(n||"").toLowerCase(),ve=Te.includes("gemma-4")||Te.startsWith("gemma"),we=Te.includes("gemini-3");if(ve||we)return ve?o.toLowerCase()!=="xhigh"?{includeThoughts:!1,thinkingLevel:Ke.MINIMAL}:{includeThoughts:!0,thinkingLevel:Ke.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:Te.includes("pro")?Ke.LOW:Ke.MINIMAL,Low:Ke.LOW,Medium:Ke.MEDIUM,Standard:Ke.MEDIUM,High:Ke.HIGH,xHigh:Ke.HIGH}[o]||Ke.MEDIUM};{let T={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[o]||2048;return T===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:T}}})()};V&&(E.serviceTier=V),_=await W.models.generateContentStream({model:F,contents:f,config:E},{signal:g})}for await(let W of _){if(wt)throw new Error("Subagent task was cancelled.");if(e?.taskId&&typeof qt<"u"){let E=qt.find(pe=>pe.id===e.taskId);if(E&&E.status==="cancelled")throw new Error("Subagent task was cancelled.")}y===null&&(W.candidates?.[0]?.content?.parts||W.text)&&(y=Date.now()-ue);let V="";if(W.candidates?.[0]?.content?.parts)for(let E of W.candidates[0].content.parts)E.text&&!E.thought&&(x+=E.text,V+=E.text);let F=V?Oi(V):0;e&&typeof e.onTokenChunk=="function"&&e.onTokenChunk(V,F),W.usageMetadata&&(m=W.usageMetadata)}}finally{clearInterval(k)}if(m){let _=m.totalTokenCount||0,W=m.cachedContentTokenCount||0,V=(m.candidatesTokenCount||0)+(a==="Google"&&m.thoughtsTokenCount||0);await bt("tokens",_,a,n),W>0&&await bt("cachedTokens",W,a,n),V>0&&await bt("candidateTokens",V,a,n),y!==null&&y>0&&await bt("ttft",y,a,n),Ao({provider:a,model:n,prompt:m.promptTokenCount||0,cached:W,output:V,reasoning:m.thoughtsTokenCount||0,ttft:y}),e&&typeof e.onUsage=="function"&&e.onUsage({totalTokenCount:_,cachedContentTokenCount:W,candidatesTokenCount:V})}return await vt("agent",a),{text:x,usageMetadata:m}}),ml=async(e,n,t=null)=>{t=t||_t(Qo,{});try{let{aiProvider:i="Google"}=n;if(Object.values(t).flat().length<=5)return;let r=Object.keys(t).filter(f=>f!==e&&Array.isArray(t[f])&&t[f].length>2);if(r.length===0)return;let d=`You are a silent background process for the FluxFlow CLI Agent.
606
606
  Your task is to summarize or merge temporary context memories from one or more past conversation sessions.
607
607
  For each Chat ID provided, you must output a tool call to save the consolidated summary.
608
608
 
@@ -617,7 +617,7 @@ Guidelines:
617
617
 
618
618
  Chats to process:
619
619
 
620
- `,a=Rt(vi,{});for(let f of r){let g=t[f].map(ue=>`- ${ue}`).join(`
620
+ `,a=_t(vi,{});for(let f of r){let g=t[f].map(ue=>`- ${ue}`).join(`
621
621
  `),k=a[f];d+=`[Chat ID: ${f}]
622
622
  `,k?(d+=`- Existing Summary: "${k}"
623
623
  `,d+=`
@@ -627,8 +627,8 @@ ${g}
627
627
  `):d+=`-- Individual Memories:
628
628
  ${g}
629
629
 
630
- `}let u=0,p=5,x=!1,m=ae("gemma_janitor_fallback_google");for(i==="OpenRouter"&&(m=ae("janitor_open_router")),i==="DeepSeek"&&(m=ae("deepseek_level_1")),i==="Mistral"&&(m=ae("mistral_level_1")),i==="NVIDIA"&&(m=ae("nvidia_janitor_fallback")),i==="InferX"&&(m=ae("inferx_fallback")),i==="SenseNova"&&(m=ae("sensenova_fallback")),i==="AIHubMix"&&(m=ae("aihubmix_fallback")),i==="Poolside"&&(m=ae("poolside_fallback")),(i==="9router"||i==="9Router")&&(m=ae("9router_fallback"));u<=p&&!x;){u++;try{let s=(await hi(n,m,d,null,"Fast",.75,"background")).text||"",g=fo(s);if(g.length===0)throw new Error("No tool calls detected in synthesis response");for(let k of g){let ue=k.toolName;["saveSummary","saveSumary","SaveSummary","SaveSumary"].includes(ue)&&await No(ue,k.args,{chatId:e})}x=!0}catch(f){if(u>=p)throw new Error(`Failed after ${p} attempts. Last error: ${f.message}`)}}}catch(i){let o=i instanceof Error?(()=>{try{return JSON.parse(JSON.parse(i.message).error.message).error.message}catch{return String(i)}})():String(i),r=j.join(Rn,"janitor");Se.existsSync(r)||Se.mkdirSync(r,{recursive:!0}),Se.appendFileSync(j.join(r,"error.log"),`[${new Date().toLocaleString()}] Past memory batch consolidation error: ${o}
631
- `)}},vd=async(e,n,t=!1)=>{let{chatId:i,aiProvider:o="Google"}=e,r=j.join(Xo,"chat-summaries.json"),d=s=>s.filter(g=>(g.role==="user"||g.role==="agent"||g.role==="system")&&g.role!=="think"&&!g.isVisualFeedback&&!g.isMeta&&!g.isTerminalRecord&&!(g.text&&g.text.includes("[TERMINAL_RECORD]"))&&!String(g.id).startsWith("welcome")).map(g=>{let k=g.fullText||g.text||"",ue=g.role==="system"||k.startsWith("[ACTION RESULT]:")||k.startsWith("[TOOL RESULT]:")||g.text&&(g.text.startsWith("[ACTION RESULT]:")||g.text.startsWith("[TOOL RESULT]:")),y=k;return ue&&(k.includes("[ACTION RESULT]:")||k.includes("[TOOL RESULT]:")||g.text&&(g.text.includes("[ACTION RESULT]:")||g.text.includes("[TOOL RESULT]:")))?y="[ACTION RESULT]: ...truncated for summary":y=y.replace(/(\[(?:tool|action):[a-zA-Z0-9_\.]+)\([\s\S]*?\)(\])/g,"$1(...)$2"),`[${ue?"ACTION":g.role==="agent"?"AGENT":"USER"}]: ${y}`}).join(`
630
+ `}let u=0,p=5,x=!1,m=ae("gemma_janitor_fallback_google");for(i==="OpenRouter"&&(m=ae("janitor_open_router")),i==="DeepSeek"&&(m=ae("deepseek_level_1")),i==="Mistral"&&(m=ae("mistral_level_1")),i==="NVIDIA"&&(m=ae("nvidia_janitor_fallback")),i==="InferX"&&(m=ae("inferx_fallback")),i==="SenseNova"&&(m=ae("sensenova_fallback")),i==="AIHubMix"&&(m=ae("aihubmix_fallback")),i==="Poolside"&&(m=ae("poolside_fallback")),(i==="9router"||i==="9Router")&&(m=ae("9router_fallback"));u<=p&&!x;){u++;try{let s=(await yi(n,m,d,null,"Fast",.75,"background")).text||"",g=Qn(s);if(g.length===0)throw new Error("No tool calls detected in synthesis response");for(let k of g){let ue=k.toolName;["saveSummary","saveSumary","SaveSummary","SaveSumary"].includes(ue)&&await Do(ue,k.args,{chatId:e})}x=!0}catch(f){if(u>=p)throw new Error(`Failed after ${p} attempts. Last error: ${f.message}`)}}}catch(i){let o=i instanceof Error?(()=>{try{return JSON.parse(JSON.parse(i.message).error.message).error.message}catch{return String(i)}})():String(i),r=K.join(_n,"janitor");Se.existsSync(r)||Se.mkdirSync(r,{recursive:!0}),Se.appendFileSync(K.join(r,"error.log"),`[${new Date().toLocaleString()}] Past memory batch consolidation error: ${o}
631
+ `)}},vd=async(e,n,t=!1)=>{let{chatId:i,aiProvider:o="Google"}=e,r=K.join(Jo,"chat-summaries.json"),d=s=>s.filter(g=>(g.role==="user"||g.role==="agent"||g.role==="system")&&g.role!=="think"&&!g.isVisualFeedback&&!g.isMeta&&!g.isTerminalRecord&&!(g.text&&g.text.includes("[TERMINAL_RECORD]"))&&!String(g.id).startsWith("welcome")).map(g=>{let k=g.fullText||g.text||"",ue=g.role==="system"||k.startsWith("[ACTION RESULT]:")||k.startsWith("[TOOL RESULT]:")||g.text&&(g.text.startsWith("[ACTION RESULT]:")||g.text.startsWith("[TOOL RESULT]:")),y=k;return ue&&(k.includes("[ACTION RESULT]:")||k.includes("[TOOL RESULT]:")||g.text&&(g.text.includes("[ACTION RESULT]:")||g.text.includes("[TOOL RESULT]:")))?y="[ACTION RESULT]: ...truncated for summary":y=y.replace(/(\[(?:tool|action):[a-zA-Z0-9_\.]+)\([\s\S]*?\)(\])/g,"$1(...)$2"),`[${ue?"ACTION":g.role==="agent"?"AGENT":"USER"}]: ${y}`}).join(`
632
632
 
633
633
  `),a=async(s,g)=>{let k="You are an expert context summarizer. Summarize the provided chat history (which may include previous summaries, user instructions, agent outputs, and tool results) into a detailed, coherent, and highly technical summary of 1000 to 1500 words. Focus on preserving the architectural decisions made, current system state, task progress, and critical code details, chat messages, file changes. Under no circumstances exceed MAX 2000 words.",ue=g?`Here is the previous summary:
634
634
  ${g}
@@ -639,33 +639,33 @@ ${s}
639
639
  Provide a new consolidated summary of the entire session.`:`Here is the conversation history:
640
640
  ${s}
641
641
 
642
- Provide a consolidated summary of the entire session.`,y=ae("gemma_janitor_fallback_google");o==="OpenRouter"&&(y=ae("janitor_open_router")),o==="DeepSeek"&&(y=ae("deepseek_level_1")),o==="Mistral"&&(y=ae("mistral_level_1")),o==="NVIDIA"&&(y=ae("nvidia_chat_summarizer_fallback")),o==="InferX"&&(y=ae("inferx_fallback")),o==="SenseNova"&&(y=ae("sensenova_fallback")),o==="AIHubMix"&&(y=ae("aihubmix_fallback")),o==="Poolside"&&(y=ae("poolside_fallback")),(o==="9router"||o==="9Router")&&(y=ae("9router_fallback")),(o==="ExpLabs"||o==="ExperientialLabs")&&(y=ae("explabs_fallback")||"deepseek-v4-pro-0813"),(o==="TokenHarbor"||o==="Token Harbor"||o==="tokenharbor"||o==="token_harbor"||o==="thk")&&(y=ae("tokenharbor_fallback")||"deepseek-v4.1-flash:free"),(o==="Infron"||o==="infron")&&(y=ae("infron_fallback"));let _=0,W=!1,K=null;for(;_<=3&&!W;){_++;try{K=await hi(e,y,ue,k,"Fast"),W=!0}catch{if(_>3){if(o==="Google")try{let E=ae("general_fallback");return(await hi(e,E,ue,k,"Fast")).text||""}catch{return""}return""}}}return K&&K.text||""},u=d(n),p=Rt(r,{}),x=p[i]||{summary:"",historyLength:0};typeof x=="string"&&(x={summary:x,historyLength:0});let m=x.summary||"",f=await a(u,m);if(f){x.summary=f;let s=cl(n);return t?x.historyLength=(x.historyLength||0)+s:x.historyLength=s,p[i]=x,so(r,p),f}return null},Id=e=>{try{let n=j.join(Xo,"chat-summaries.json");if(Se.existsSync(n)){let t=Rt(n,{});t[e]&&(delete t[e],so(n,t))}}catch{}},Md=async function*(e,n,t,i,o){let{profile:r,thinkingLevel:d,mode:a,janitorModel:u,chatId:p,isPlayground:x,systemSettings:m,sessionStats:f,aiProvider:s="Google",apiTier:g,wildcardTooling:k,wildercardTooling:ue}=t,y=rt(e);if(!fs&&s==="Google")throw new Error("AI not initialized");let _=process.env.NVIDIA_BASE_URL||t?.aiProvider==="Ollama"||t?.aiProvider==="InferX"||t?.aiProvider==="SenseNova"||t?.aiProvider==="AIHubMix"||t?.aiProvider==="Poolside"||t?.aiProvider==="9router"||t?.aiProvider==="ExpLabs"||t?.aiProvider==="ExperientialLabs"||t?.aiProvider==="TokenHarbor"||t?.aiProvider==="Token Harbor"||t?.aiProvider==="tokenharbor"||t?.aiProvider==="token_harbor"||t?.aiProvider==="thk"||t?.aiProvider==="APInex"||t?.aiProvider==="apinex"||t?.aiProvider==="apx"||t?.aiProvider==="Infron"||t?.aiProvider==="infron"||t?.aiProvider==="c_openai"||t?.aiProvider==="Custom (OpenAI)"?!1:m?.memory!==!1,W=n[n.length-1].text,K=j.join(Xo,"chat-summaries.json"),F=!1,E=n.filter(T=>T.role==="user").length===1,pe=W.includes("[TITLE-UPDATE]"),Te=E||pe,ve=W.replace(/\[TITLE-UPDATE\]/g,"").trim();ve=ve.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),yield{type:"status",content:"[start]"},yield{type:"status",content:"Gathering Context"},await ei.startTransaction(p,ve),m?.advanceRollback&&await Ao.takeInitialSnapshot(p),ht=!1;let we=null;try{let T=new AbortController;we=setInterval(()=>{ht&&(T.abort(),we&&(clearInterval(we),we=null))},400);let b=[...n.slice(0,-1)];{let Be=Rt(K,{})[p]||{summary:"",historyLength:0};if(Be.summary&&Be.historyLength>0){let wn=0,Je=[];for(let Ae=0;Ae<b.length;Ae++){let Qe=b[Ae];(Qe.role==="user"||Qe.role==="agent"||Qe.role==="system")&&!String(Qe.id).startsWith("welcome")&&!Qe.isMeta&&wn++,wn>Be.historyLength&&Je.push(Qe)}b=Je}}b=b.map(L=>{if(L.role==="user"&&L.text){let Be=L.text.match(/\[USER\]([\s\S]*?)\[\/USER\]/);if(Be)return{...L,text:Be[1].trim()}}return{...L}});let lt=process.env.HIGH_CONTEXT,$e=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1,vt={"16k":16e3,"32k":32e3,"64k":64e3,"128k":128e3,"256k":256e3,"512k":512e3,"1M":1e6}[m?.contextLength]||256e3;if(lt&&lt!=="false"){let L=parseInt(lt,10);!isNaN(L)&&L>=0&&L<=1e6&&(vt=L)}if((s==="NVIDIA"&&(e?.includes("gpt")||e?.includes("qwen")||e?.includes("medium")||e.includes("muse"))||s==="Mistral")&&(vt=126e3),s==="Google"&&e?.includes("gemma")&&$e&&(vt=16e3),(f?.tokens||0)>vt){yield{type:"text",content:"\u2726 Maximum Context Limit Reached. Start a new chat."};return}if(E&&_){let L=Rt(Jo,{});Object.values(L).flat().length>5&&(yield{type:"status",content:"Condensing past chat memories"},await ml(p,t,L))}let Ut=Rt(Jo,{}),hn=Rt(vi,{}),yn=Object.entries(Ut).filter(([L])=>L!==p).flatMap(([L,Be])=>Be),yt=[...Object.entries(hn).filter(([L])=>L!==p).slice(-20).map(([L,Be])=>`[Chat Summary]: ${Be}`),...yn].map(L=>`- ${L}`).join(`
643
- `),S=Rt(zn,[]).map(L=>`- ${L.memory}`).join(`
644
- `),C=(f?.tokens||0)>=1e4,Ie=new Date,M=Ie.getFullYear(),A=Ie.toLocaleString("en-US",{month:"short"}).toUpperCase(),D=String(Ie.getDate()).padStart(2,"0"),Re=`${Ie.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}`,ke=L=>{try{return Se.readdirSync(L,{withFileTypes:!0})}catch{return[]}},Me=Array.from(new Set([...wo,...So(process.cwd())])),Wo=(L,Be=6)=>m?.indentationTree!==!1?is(L,Be,1,ke,Me):rs(L,Be,"",1,ke,Me),Wn=Rt(Ii,{}),uo=Wn[p],Go=uo?uo!==process.cwd():!1;Wn[p]=process.cwd(),so(Ii,Wn);let xn=Rt(K,{}),Wt=xn[p]||{summary:"",historyLength:0};typeof Wt=="string"&&(Wt={summary:Wt,historyLength:0});let ot=n.filter(L=>(L.role==="user"||L.role==="agent"||L.role==="system")&&!String(L.id).startsWith("welcome")&&!L.isMeta).length;Wt.historyLength&&ot<Wt.historyLength&&(Wt.summary="",Wt.historyLength=0,xn[p]=Wt,so(K,xn));let de=typeof Wt=="object"?Wt.summary||"":Wt||"",le=b.length>0;le&&de&&b[0]&&(b[0].role==="user"||b[0].role==="system")&&(b[0].text.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")||(b[0].text=`[SYSTEM METADATA]
642
+ Provide a consolidated summary of the entire session.`,y=ae("gemma_janitor_fallback_google");o==="OpenRouter"&&(y=ae("janitor_open_router")),o==="DeepSeek"&&(y=ae("deepseek_level_1")),o==="Mistral"&&(y=ae("mistral_level_1")),o==="NVIDIA"&&(y=ae("nvidia_chat_summarizer_fallback")),o==="InferX"&&(y=ae("inferx_fallback")),o==="SenseNova"&&(y=ae("sensenova_fallback")),o==="AIHubMix"&&(y=ae("aihubmix_fallback")),o==="Poolside"&&(y=ae("poolside_fallback")),(o==="9router"||o==="9Router")&&(y=ae("9router_fallback")),(o==="ExpLabs"||o==="ExperientialLabs")&&(y=ae("explabs_fallback")||"deepseek-v4-pro-0813"),(o==="TokenHarbor"||o==="Token Harbor"||o==="tokenharbor"||o==="token_harbor"||o==="thk")&&(y=ae("tokenharbor_fallback")||"deepseek-v4.1-flash:free"),(o==="Infron"||o==="infron")&&(y=ae("infron_fallback"));let _=0,W=!1,V=null;for(;_<=3&&!W;){_++;try{V=await yi(e,y,ue,k,"Fast"),W=!0}catch{if(_>3){if(o==="Google")try{let E=ae("general_fallback");return(await yi(e,E,ue,k,"Fast")).text||""}catch{return""}return""}}}return V&&V.text||""},u=d(n),p=_t(r,{}),x=p[i]||{summary:"",historyLength:0};typeof x=="string"&&(x={summary:x,historyLength:0});let m=x.summary||"",f=await a(u,m);if(f){x.summary=f;let s=cl(n);return t?x.historyLength=(x.historyLength||0)+s:x.historyLength=s,p[i]=x,ao(r,p),f}return null},Id=e=>{try{let n=K.join(Jo,"chat-summaries.json");if(Se.existsSync(n)){let t=_t(n,{});t[e]&&(delete t[e],ao(n,t))}}catch{}},Md=async function*(e,n,t,i,o){let{profile:r,thinkingLevel:d,mode:a,janitorModel:u,chatId:p,isPlayground:x,systemSettings:m,sessionStats:f,aiProvider:s="Google",apiTier:g,wildcardTooling:k,wildercardTooling:ue}=t,y=ct(e);if(!fs&&s==="Google")throw new Error("AI not initialized");let _=process.env.NVIDIA_BASE_URL||t?.aiProvider==="Ollama"||t?.aiProvider==="InferX"||t?.aiProvider==="SenseNova"||t?.aiProvider==="AIHubMix"||t?.aiProvider==="Poolside"||t?.aiProvider==="9router"||t?.aiProvider==="ExpLabs"||t?.aiProvider==="ExperientialLabs"||t?.aiProvider==="TokenHarbor"||t?.aiProvider==="Token Harbor"||t?.aiProvider==="tokenharbor"||t?.aiProvider==="token_harbor"||t?.aiProvider==="thk"||t?.aiProvider==="APInex"||t?.aiProvider==="apinex"||t?.aiProvider==="apx"||t?.aiProvider==="Infron"||t?.aiProvider==="infron"||t?.aiProvider==="c_openai"||t?.aiProvider==="Custom (OpenAI)"?!1:m?.memory!==!1,W=n[n.length-1].text,V=K.join(Jo,"chat-summaries.json"),F=!1,E=n.filter(T=>T.role==="user").length===1,pe=W.includes("[TITLE-UPDATE]"),Te=E||pe,ve=W.replace(/\[TITLE-UPDATE\]/g,"").trim();ve=ve.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),yield{type:"status",content:"[start]"},yield{type:"status",content:"Gathering Context"},await ti.startTransaction(p,ve),m?.advanceRollback&&await Eo.takeInitialSnapshot(p),wt=!1;let we=null;try{let T=new AbortController;we=setInterval(()=>{wt&&(T.abort(),we&&(clearInterval(we),we=null))},400);let b=[...n.slice(0,-1)];{let Fe=_t(V,{})[p]||{summary:"",historyLength:0};if(Fe.summary&&Fe.historyLength>0){let Sn=0,Qe=[];for(let Ae=0;Ae<b.length;Ae++){let Ze=b[Ae];(Ze.role==="user"||Ze.role==="agent"||Ze.role==="system")&&!String(Ze.id).startsWith("welcome")&&!Ze.isMeta&&Sn++,Sn>Fe.historyLength&&Qe.push(Ze)}b=Qe}}b=b.map(L=>{if(L.role==="user"&&L.text){let Fe=L.text.match(/\[USER\]([\s\S]*?)\[\/USER\]/);if(Fe)return{...L,text:Fe[1].trim()}}return{...L}});let ft=process.env.HIGH_CONTEXT,$e=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1,It={"16k":16e3,"32k":32e3,"64k":64e3,"128k":128e3,"256k":256e3,"512k":512e3,"1M":1e6}[m?.contextLength]||256e3;if(ft&&ft!=="false"){let L=parseInt(ft,10);!isNaN(L)&&L>=0&&L<=1e6&&(It=L)}if((s==="NVIDIA"&&(e?.includes("gpt")||e?.includes("qwen")||e?.includes("medium")||e.includes("muse"))||s==="Mistral")&&(It=126e3),s==="Google"&&e?.includes("gemma")&&$e&&(It=16e3),(f?.tokens||0)>It){yield{type:"text",content:"\u2726 Maximum Context Limit Reached. Start a new chat."};return}if(E&&_){let L=_t(Qo,{});Object.values(L).flat().length>5&&(yield{type:"status",content:"Condensing past chat memories"},await ml(p,t,L))}let Ht=_t(Qo,{}),yn=_t(vi,{}),xn=Object.entries(Ht).filter(([L])=>L!==p).flatMap(([L,Fe])=>Fe),St=[...Object.entries(yn).filter(([L])=>L!==p).slice(-20).map(([L,Fe])=>`[Chat Summary]: ${Fe}`),...xn].map(L=>`- ${L}`).join(`
643
+ `),S=_t(zn,[]).map(L=>`- ${L.memory}`).join(`
644
+ `),C=(f?.tokens||0)>=1e4,Ie=new Date,M=Ie.getFullYear(),A=Ie.toLocaleString("en-US",{month:"short"}).toUpperCase(),N=String(Ie.getDate()).padStart(2,"0"),Re=`${Ie.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}`,ke=L=>{try{return Se.readdirSync(L,{withFileTypes:!0})}catch{return[]}},Me=Array.from(new Set([...So,...To(process.cwd())])),Go=(L,Fe=6)=>m?.indentationTree!==!1?is(L,Fe,1,ke,Me):rs(L,Fe,"",1,ke,Me),Wn=_t(Ii,{}),go=Wn[p],Ho=go?go!==process.cwd():!1;Wn[p]=process.cwd(),ao(Ii,Wn);let bn=_t(V,{}),jt=bn[p]||{summary:"",historyLength:0};typeof jt=="string"&&(jt={summary:jt,historyLength:0});let st=n.filter(L=>(L.role==="user"||L.role==="agent"||L.role==="system")&&!String(L.id).startsWith("welcome")&&!L.isMeta).length;jt.historyLength&&st<jt.historyLength&&(jt.summary="",jt.historyLength=0,bn[p]=jt,ao(V,bn));let de=typeof jt=="object"?jt.summary||"":jt||"",le=b.length>0;le&&de&&b[0]&&(b[0].role==="user"||b[0].role==="system")&&(b[0].text.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")||(b[0].text=`[SYSTEM METADATA]
645
645
  **CONTEXT SUMMARY OF PREVIOUS TURNS (PRIORITY: DYNAMIC)**
646
646
  ${de}
647
647
 
648
- [USER] ${b[0].text}`,yield{type:"summary_injected",content:{id:b[0].id,text:b[0].text}}));let It=de&&!le?`
648
+ [USER] ${b[0].text}`,yield{type:"summary_injected",content:{id:b[0].id,text:b[0].text}}));let Mt=de&&!le?`
649
649
  [SYSTEM METADATA]
650
650
  **CONTEXT SUMMARY OF PREVIOUS TURNS**
651
651
  ${de}
652
- `:"",go=!!m?.dynamicDirAwareness,Qn=`${p}|${s}|${d}|${e}|${r}|${go}`,na=!go&&Xn.key===Qn&&Xn.value?"":`
652
+ `:"",mo=!!m?.dynamicDirAwareness,Zn=`${p}|${s}|${d}|${e}|${r}|${mo}`,na=!mo&&Xn.key===Zn&&Xn.value?"":`
653
653
  **Directory**
654
654
  CWD: `+process.cwd()+`${x?" [PLAYGROUND MODE]":""}
655
- `+Wo(process.cwd(),6),ct=await qn(),bn="";if(lo()&&ct.file_focused!=="none"){bn=`
655
+ `+Go(process.cwd(),6),ut=await qn(),wn="";if(fo()&&ut.file_focused!=="none"){wn=`
656
656
  [Additional IDE Context]
657
- `;let L=j.relative(process.cwd(),ct.file_focused),Be=(ct.opened_editors||[]).map(Je=>{let Ae=j.relative(process.cwd(),Je);return Ae.startsWith("..")?`[External] ${j.basename(Je)}`:Ae});if(bn+=`Focused File: ${L}
658
- Cursor Line: ${ct.cursor_line}
659
- `,ct.selected){let Je=ct.selected,Ae=Je.split(`
660
- `);Ae.length>256&&(Je=Ae.slice(0,240).join(`
657
+ `;let L=K.relative(process.cwd(),ut.file_focused),Fe=(ut.opened_editors||[]).map(Qe=>{let Ae=K.relative(process.cwd(),Qe);return Ae.startsWith("..")?`[External] ${K.basename(Qe)}`:Ae});if(wn+=`Focused File: ${L}
658
+ Cursor Line: ${ut.cursor_line}
659
+ `,ut.selected){let Qe=ut.selected,Ae=Qe.split(`
660
+ `);Ae.length>256&&(Qe=Ae.slice(0,240).join(`
661
661
  `)+`
662
662
  ... [truncated] ...
663
663
  `+Ae.slice(-16).join(`
664
- `)),Je.length>2048&&(Je=Je.slice(0,1920)+`
664
+ `)),Qe.length>2048&&(Qe=Qe.slice(0,1920)+`
665
665
  ... [truncated] ...
666
- `+Je.slice(-128)),bn+=`Current Selection: "${Je}"
667
- `}if(ct.manual_edits){let Ae=ct.manual_edits.split(`
668
- `),Qe=[],Ve=null;for(let $ of Ae)$.trim()&&($.startsWith(" Line ")?Ve&&Ve.edits.push($):(Ve={path:$.endsWith(":")?$.slice(0,-1):$,edits:[]},Qe.push(Ve)));for(let $ of Qe)$.edits.length>80&&($.edits=$.edits.slice(-80)),$.originalEditsCount=$.edits.length;let Ze=($,Ne)=>Ne.reduce((dt,en)=>{let xt=ct.file_focused&&(en.path===ct.file_focused||j.resolve(process.cwd(),en.path)===j.resolve(ct.file_focused))?Math.ceil($*1.2):$;return dt+Math.min(en.edits.length,xt)},0),Yt=80;if(Ze(80,Qe)>300){let $=!1;for(let Ne=80;Ne>=10;Ne--)if(Ze(Ne,Qe)<=300){Yt=Ne,$=!0;break}$||(Yt=10)}let Ee=[...Qe];if(Yt===10&&Ze(10,Ee)>500)for(;Ee.length>0&&Ze(10,Ee)>500;){let $=0,Ne=Ee[0].originalEditsCount;for(let dt=1;dt<Ee.length;dt++)Ee[dt].originalEditsCount<Ne&&(Ne=Ee[dt].originalEditsCount,$=dt);Ee.splice($,1)}for(let $ of Ee){let dt=ct.file_focused&&($.path===ct.file_focused||j.resolve(process.cwd(),$.path)===j.resolve(ct.file_focused))?Math.ceil(Yt*1.2):Yt;$.edits.length>dt&&($.edits=$.edits.slice(-dt))}for(let $ of Ee){let Ne=`${$.path}:
666
+ `+Qe.slice(-128)),wn+=`Current Selection: "${Qe}"
667
+ `}if(ut.manual_edits){let Ae=ut.manual_edits.split(`
668
+ `),Ze=[],ze=null;for(let $ of Ae)$.trim()&&($.startsWith(" Line ")?ze&&ze.edits.push($):(ze={path:$.endsWith(":")?$.slice(0,-1):$,edits:[]},Ze.push(ze)));for(let $ of Ze)$.edits.length>80&&($.edits=$.edits.slice(-80)),$.originalEditsCount=$.edits.length;let tt=($,Ne)=>Ne.reduce((gt,nn)=>{let Tt=ut.file_focused&&(nn.path===ut.file_focused||K.resolve(process.cwd(),nn.path)===K.resolve(ut.file_focused))?Math.ceil($*1.2):$;return gt+Math.min(nn.edits.length,Tt)},0),Xt=80;if(tt(80,Ze)>300){let $=!1;for(let Ne=80;Ne>=10;Ne--)if(tt(Ne,Ze)<=300){Xt=Ne,$=!0;break}$||(Xt=10)}let Ee=[...Ze];if(Xt===10&&tt(10,Ee)>500)for(;Ee.length>0&&tt(10,Ee)>500;){let $=0,Ne=Ee[0].originalEditsCount;for(let gt=1;gt<Ee.length;gt++)Ee[gt].originalEditsCount<Ne&&(Ne=Ee[gt].originalEditsCount,$=gt);Ee.splice($,1)}for(let $ of Ee){let gt=ut.file_focused&&($.path===ut.file_focused||K.resolve(process.cwd(),$.path)===K.resolve(ut.file_focused))?Math.ceil(Xt*1.2):Xt;$.edits.length>gt&&($.edits=$.edits.slice(-gt))}for(let $ of Ee){let Ne=`${$.path}:
669
669
  ${$.edits.join(`
670
670
  `)}`;for(;$.edits.length>0&&Ne.length>4*768;)$.edits.shift(),Ne=`${$.path}:
671
671
  ${$.edits.join(`
@@ -673,198 +673,199 @@ ${$.edits.join(`
673
673
  `);for(;Ee.length>0&&fe.length>4*2048;){Ee[0].edits.length>0?Ee[0].edits.shift():Ee.shift();for(let $ of Ee){let Ne=`${$.path}:
674
674
  ${$.edits.join(`
675
675
  `)}`;Ne.length>4*768?$.stringRepresentation="... "+Ne.slice(-(4*768-4)):$.stringRepresentation=Ne}fe=Ee.map($=>$.stringRepresentation).join(`
676
- `)}fe.length>4*2048&&(fe="... "+fe.slice(-(4*2048-4))),bn+=`Recent Manual Edits:
676
+ `)}fe.length>4*2048&&(fe="... "+fe.slice(-(4*2048-4))),wn+=`Recent Manual Edits:
677
677
  ${fe}
678
- `}Be.length>0&&(bn+=`All Opened Editors: ${Be.join(", ")}`),ct.diagnostics&&(bn+=`
678
+ `}Fe.length>0&&(wn+=`All Opened Editors: ${Fe.join(", ")}`),ut.diagnostics&&(wn+=`
679
679
  **Active File Errors**:
680
- ${ct.diagnostics}
681
- `),(ve.toLowerCase().includes("lint")||ve.toLowerCase().includes("warning"))&&ct.warnings&&(bn+=`
680
+ ${ut.diagnostics}
681
+ `),(ve.toLowerCase().includes("lint")||ve.toLowerCase().includes("warning"))&&ut.warnings&&(wn+=`
682
682
  **Lint Warnings**:
683
- ${ct.warnings}
684
- `)}let gs=ve.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),ms=/(?:\\)?@\[([^\]]+)\]/g,yi,xi=[];for(ms.lastIndex=0;(yi=ms.exec(gs))!==null;){let L=yi[0].startsWith("\\");xi.push({tag:yi[1],isEscaped:L})}let bi=[],Ho=null;for(let L=0;L<xi.length;L++){let{tag:Be,isEscaped:wn}=xi[L];if(!wn)try{let Je=Be.trim().replace(/^["']|["']$/g,""),Ae=/[:#]L?(\d+)(?:-L?(\d+))?$/i,Qe=Je.match(Ae),Ve=Je,Ze=null,Yt=null;Qe&&(Ze=parseInt(Qe[1],10),Yt=Qe[2]?parseInt(Qe[2],10):Ze,Ve=Je.slice(0,Qe.index));let Ee=j.resolve(process.cwd(),Ve);if(Se.existsSync(Ee)&&Se.statSync(Ee).isFile()){let $=Ve.toLowerCase(),Ne=$.endsWith(".pdf"),dt=$.endsWith(".docx")||$.endsWith(".doc")||$.endsWith(".ppt")||$.endsWith(".pptx")||$.endsWith(".xls")||$.endsWith(".xlsx"),en=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test($),De=en||Ne||dt,xt=s==="Google"||rt(e);if(De&&!xt){let _e=`\u2718 Unsupported Modality: ${j.basename(Ve)}`,it=115;process.stdout.isTTY&&(it=process.stdout.columns-5||120);let zt=[_e],Ue=Math.max(...zt.map(tn=>tn.length)),oe=Math.min(Ue+4,it),We=zt.map(tn=>`${tn.padEnd(oe-2).substring(0,oe-2)}`).join(`
685
- `);yield{type:"visual_feedback",content:Ft(`${We}
686
- `)};continue}if(Ze===null&&!De){let _e=0;try{_e=Se.readFileSync(Ee,"utf8").split(/\r\n|\r|\n/).length}catch{}if(_e>300){let it=`\u21B7 Skipped (Too Large): ${j.basename(Ve)}`,zt=115;process.stdout.isTTY&&(zt=process.stdout.columns-5||120);let Ue=Math.min(it.length+4,zt),oe=it.padEnd(Ue-2).substring(0,Ue-2);yield{type:"visual_feedback",content:Ft(`${oe}
687
- `)};continue}}let Sn=Ze!==null?Ze:1,Lt=Yt!==null?Yt:Ze!==null?Ze:Sn+299;Lt-Sn>300&&(Lt=Sn+300);let Hn=`path=${JSON.stringify(Ve)}, startLine=${Sn}, endLine=${Lt}`,Gt=await Ps(Hn,{isMultiModal:xt}),In=!1,eo="",bt=null;if(typeof Gt=="string"?Gt.trim().startsWith("ERROR")?In=!0:eo=Gt:Gt&&typeof Gt=="object"&&Gt.binaryPart?(bt=Gt.binaryPart,eo=Gt.text||""):In=!0,!In){let _e="";if(en?(_e=`\u2714 Processed: ${j.basename(Ve)}`,Ho=bt):Ne||dt?(_e=`\u2714 Auto-Analysed: ${j.basename(Ve)}`,Ho=bt):(_e=`\u2714 Auto-Read: ${j.basename(Ve)}`,bi.push(eo)),_e){let it=115;process.stdout.isTTY&&(it=process.stdout.columns-5||120);let zt=[_e],Ue=Math.max(...zt.map(tn=>tn.length)),oe=Math.min(Ue+4,it),We=zt.map(tn=>`${tn.padEnd(oe-2).substring(0,oe-2)}`).join(`
688
- `);yield{type:"visual_feedback",content:Ft(`${We}
689
- `)}}}}}catch{}}let wi="";bi.length>0&&(wi=`
683
+ ${ut.warnings}
684
+ `)}let ms=ve.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),ps=/(?:\\)?@\[([^\]]+)\]/g,xi,bi=[];for(ps.lastIndex=0;(xi=ps.exec(ms))!==null;){let L=xi[0].startsWith("\\");bi.push({tag:xi[1],isEscaped:L})}let wi=[],jo=null;for(let L=0;L<bi.length;L++){let{tag:Fe,isEscaped:Sn}=bi[L];if(!Sn)try{let Qe=Fe.trim().replace(/^["']|["']$/g,""),Ae=/[:#]L?(\d+)(?:-L?(\d+))?$/i,Ze=Qe.match(Ae),ze=Qe,tt=null,Xt=null;Ze&&(tt=parseInt(Ze[1],10),Xt=Ze[2]?parseInt(Ze[2],10):tt,ze=Qe.slice(0,Ze.index));let Ee=K.resolve(process.cwd(),ze);if(Se.existsSync(Ee)&&Se.statSync(Ee).isFile()){let $=ze.toLowerCase(),Ne=$.endsWith(".pdf"),gt=$.endsWith(".docx")||$.endsWith(".doc")||$.endsWith(".ppt")||$.endsWith(".pptx")||$.endsWith(".xls")||$.endsWith(".xlsx"),nn=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test($),Be=nn||Ne||gt,Tt=s==="Google"||ct(e);if(Be&&!Tt){let _e=`\u2718 Unsupported Modality: ${K.basename(ze)}`,rt=115;process.stdout.isTTY&&(rt=process.stdout.columns-5||120);let Jt=[_e],Ue=Math.max(...Jt.map(on=>on.length)),oe=Math.min(Ue+4,rt),We=Jt.map(on=>`${on.padEnd(oe-2).substring(0,oe-2)}`).join(`
685
+ `);yield{type:"visual_feedback",content:Wt(`${We}
686
+ `)};continue}if(tt===null&&!Be){let _e=0;try{_e=Se.readFileSync(Ee,"utf8").split(/\r\n|\r|\n/).length}catch{}if(_e>300){let rt=`\u21B7 Skipped (Too Large): ${K.basename(ze)}`,Jt=115;process.stdout.isTTY&&(Jt=process.stdout.columns-5||120);let Ue=Math.min(rt.length+4,Jt),oe=rt.padEnd(Ue-2).substring(0,Ue-2);yield{type:"visual_feedback",content:Wt(`${oe}
687
+ `)};continue}}let Tn=tt!==null?tt:1,Nt=Xt!==null?Xt:tt!==null?tt:Tn+299;Nt-Tn>300&&(Nt=Tn+300);let Hn=`path=${JSON.stringify(ze)}, startLine=${Tn}, endLine=${Nt}`,Kt=await Os(Hn,{isMultiModal:Tt}),Mn=!1,to="",kt=null;if(typeof Kt=="string"?Kt.trim().startsWith("ERROR")?Mn=!0:to=Kt:Kt&&typeof Kt=="object"&&Kt.binaryPart?(kt=Kt.binaryPart,to=Kt.text||""):Mn=!0,!Mn){let _e="";if(nn?(_e=`\u2714 Processed: ${K.basename(ze)}`,jo=kt):Ne||gt?(_e=`\u2714 Auto-Analysed: ${K.basename(ze)}`,jo=kt):(_e=`\u2714 Auto-Read: ${K.basename(ze)}`,wi.push(to)),_e){let rt=115;process.stdout.isTTY&&(rt=process.stdout.columns-5||120);let Jt=[_e],Ue=Math.max(...Jt.map(on=>on.length)),oe=Math.min(Ue+4,rt),We=Jt.map(on=>`${on.padEnd(oe-2).substring(0,oe-2)}`).join(`
688
+ `);yield{type:"visual_feedback",content:Wt(`${We}
689
+ `)}}}}}catch{}}let Si="";wi.length>0&&(Si=`
690
690
  [Tagged File Contents] Auto Read User Tagged files by System, No need to re-read
691
- `+bi.join(`
691
+ `+wi.join(`
692
692
 
693
693
  `)+`
694
694
  [Tagged File Contents]
695
- `);let ps=gs.replace(/\\(@\[[^\]]+\])/g,"$1"),hs=k?`You cannot execute tools. Instead write the action string in chat you WOULD have written
696
- `:"",oa=process.env.forcedReasoning||!1,ys=d!=="Fast"&&(s==="Mistral"&&!Zo(e)||d!=="High"&&s==="Google")?`${s==="Mistral"&&!Zo(e)||e.toLowerCase().startsWith("gemma")||oa?`[system] strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow> [/system]
697
- `:""}`:"",Zn="";if(m?.clipboardContext)try{process.platform==="win32"?Zn=as("powershell.exe -NoProfile -Command Get-Clipboard",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):process.platform==="darwin"?Zn=as("pbpaste",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):Zn=as("xclip -selection clipboard -o || xsel --clipboard --output",{encoding:"utf8",shell:!0,stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,"")}catch{Zn=""}let jo="",ia=!!m?.autoExcludeMetadata,sa=!!(bn||wi||hs||It||ys||Go||m?.dynamicDirAwareness||m?.autoTruncateResults);ia&&!sa?jo=ps.trim():jo=`[System Metadata] Time: ${Re}${Go?`
698
- WARNING: CWD Changed from previous: "${uo}" to current: "${process.cwd()}", write change in chat to avoid future path mismatches
699
- `:""}${bn}
695
+ `);let hs=ms.replace(/\\(@\[[^\]]+\])/g,"$1"),ys=k?`You cannot execute tools. Instead write the action string in chat you WOULD have written
696
+ `:"",oa=process.env.forcedReasoning||!1,xs=d!=="Fast"&&(s==="Mistral"&&!ei(e)||d!=="High"&&s==="Google")?`${s==="Mistral"&&!ei(e)||e.toLowerCase().startsWith("gemma")||oa?`[system] strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow> [/system]
697
+ `:""}`:"",eo="";if(m?.clipboardContext)try{process.platform==="win32"?eo=as("powershell.exe -NoProfile -Command Get-Clipboard",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):process.platform==="darwin"?eo=as("pbpaste",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):eo=as("xclip -selection clipboard -o || xsel --clipboard --output",{encoding:"utf8",shell:!0,stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,"")}catch{eo=""}let Ko="",ia=!!m?.autoExcludeMetadata,sa=!!(wn||Si||ys||Mt||xs||Ho||m?.dynamicDirAwareness||m?.autoTruncateResults);ia&&!sa?Ko=hs.trim():Ko=`[System Metadata] Time: ${Re}${Ho?`
698
+ WARNING: CWD Changed from previous: "${go}" to current: "${process.cwd()}", write change in chat to avoid future path mismatches
699
+ `:""}${wn}
700
700
  Action format: [action:ActionName(...)]
701
701
  [/Metadata]
702
- ${It}${ys}${wi}${hs}${Zn.trim().length>0?`[Clipboard Context:
703
- - ${Zn.trim()}
704
- `:""}[user prompt] ${ps.trim()} [/user prompt]`.trim();let xs={role:"user",text:jo};Ho&&(xs.binaryPart=Ho),b.forEach(L=>{L.text&&L.role==="agent"&&(L.text=Bt(L.text))}),b.push(xs),It&&n[n.length-1]?.id&&(yield{type:"summary_injected",content:{id:n[n.length-1].id,text:jo}});let Zt=null,vn=a==="Flux"?50:15;vn=a.toLowerCase().includes("cu")?75:vn;let ra=Math.floor(vn/2),bs=0,dn=16;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Consulting the spirits":"Connecting"},ht=!1;let Si=[],Ko=!1,ws=!1,Gn=[];for(let L=0;L<=vn;L++){let Be=Math.floor(vn*.95);if(L>=Be&&bs<Be&&typeof t?.onAskUser=="function"){bs=Be;try{let Y="Agent has been running for a long time. Do you want to continue execution?",z=[{id:"continue",label:"Continue",description:"Add few more steps"},{id:"cancel",label:"Cancel",description:"Stop extending and finish current turn limit"}],N=await t.onAskUser(Y,z);N&&(N.toLowerCase().includes("continue")||N==="Continue")&&(vn+=ra)}catch{}}if(Gn.length>=10&&typeof t?.onAskUser=="function"){let Y={},z=null;for(let N of Gn)if(Y[N]=(Y[N]||0)+1,Y[N]>=10){z=N;break}if(z)try{let N="Agent seems stuck in a tool loop. You can prompt it to steer or break the loop:",at=[{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"}],Pe=await t.onAskUser(N,at);if(Pe){let Ye="";typeof Pe=="string"&&(Pe.toLowerCase()==="stop"||Pe.includes("Stop Loop"))?Ye="STOP REPEATING THE SAME TOOL CALL. Acknowledge what failed or succeeded, summarize your current findings, and conclude.":typeof Pe=="string"&&(Pe.toLowerCase()==="continue"||Pe.includes("Continue Anyway"))?Gn=Gn.filter(wt=>wt!==z):Ye=typeof Pe=="string"?Pe:Pe?.label||Pe?.id||"",Ye&&(b.length>0&&b[b.length-1].role==="user"?b[b.length-1].text+=`
702
+ ${Mt}${xs}${Si}${ys}${eo.trim().length>0?`[Clipboard Context:
703
+ - ${eo.trim()}
704
+ `:""}[user prompt] ${hs.trim()} [/user prompt]`.trim();let bs={role:"user",text:Ko};jo&&(bs.binaryPart=jo),b.forEach(L=>{L.text&&L.role==="agent"&&(L.text=Gt(L.text))}),b.push(bs),Mt&&n[n.length-1]?.id&&(yield{type:"summary_injected",content:{id:n[n.length-1].id,text:Ko}});let tn=null,In=a==="Flux"?50:15;In=a.toLowerCase().includes("cu")?75:In;let ra=Math.floor(In/2),ws=0,fn=16;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Consulting the spirits":"Connecting"},wt=!1;let Ti=[],Vo=!1,Ss=!1,Gn=[];for(let L=0;L<=In;L++){let Fe=Math.floor(In*.95);if(L>=Fe&&ws<Fe&&typeof t?.onAskUser=="function"){ws=Fe;try{let z="Agent has been running for a long time. Do you want to continue execution?",G=[{id:"continue",label:"Continue",description:"Add few more steps"},{id:"cancel",label:"Cancel",description:"Stop extending and finish current turn limit"}],D=await t.onAskUser(z,G);D&&(D.toLowerCase().includes("continue")||D==="Continue")&&(In+=ra)}catch{}}if(Gn.length>=10&&typeof t?.onAskUser=="function"){let z={},G=null;for(let D of Gn)if(z[D]=(z[D]||0)+1,z[D]>=10){G=D;break}if(G)try{let D="Agent seems stuck in a tool loop. You can prompt it to steer or break the loop:",dt=[{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(D,dt);if(De){let Ge="";typeof De=="string"&&(De.toLowerCase()==="stop"||De.includes("Stop Loop"))?Ge="STOP REPEATING THE SAME TOOL CALL. Acknowledge what failed or succeeded, summarize your current findings, and conclude.":typeof De=="string"&&(De.toLowerCase()==="continue"||De.includes("Continue Anyway"))?Gn=Gn.filter(Et=>Et!==G):Ge=typeof De=="string"?De:De?.label||De?.id||"",Ge&&(b.length>0&&b[b.length-1].role==="user"?b[b.length-1].text+=`
705
705
 
706
- [STEERING HINT from USER, High Priority] ${Ye.trim()} [/STEERING HINT]`:b.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${Ye.trim()} [/STEERING HINT]`}),yield{type:"status",content:"Steering Hint Injected..."},Gn=Gn.filter(wt=>wt!==z))}}catch{}}let wn=await Pi("agent",t);if(!wn.allowed)throw new Error(wn.reason||`Budget Exhausted for Provider (${s||"Agent"})`);let Je=[];if(Ko=!1,a==="ICU"||a==="FluxCU")try{yield{type:"status",content:"Capturing Screen"},await new Promise(N=>setTimeout(N,1e3));let{captureGriddedScreenshot:Y}=await import("./screen_grid-EXWAAOMK.js"),z=await Y();if(z&&z.base64){let N="[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]",at={inlineData:{mimeType:z.mimeType,data:z.base64}},Pe=m?.imageHistoryCU||"Standard",Ye=Pe==="Low"?3:Pe==="Extended"?10:Pe==="Max"?999:5,wt=b.filter(Fe=>Array.isArray(Fe.parts)&&Fe.parts.some(St=>St.inlineData));if(wt.length>=Ye){let Fe=wt.length-Ye+1;for(let St=0;St<Fe;St++){let kt=wt[St];Array.isArray(kt.parts)&&(kt.parts=kt.parts.filter(Tt=>!Tt.inlineData))}}if(b.length>0&&b[b.length-1].role==="user"){let Fe=b[b.length-1];typeof Fe.text=="string"&&(Fe.text+=`
706
+ [STEERING HINT from USER, High Priority] ${Ge.trim()} [/STEERING HINT]`:b.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${Ge.trim()} [/STEERING HINT]`}),yield{type:"status",content:"Steering Hint Injected..."},Gn=Gn.filter(Et=>Et!==G))}}catch{}}let Sn=await Pi("agent",t);if(!Sn.allowed)throw new Error(Sn.reason||`Budget Exhausted for Provider (${s||"Agent"})`);let Qe=[];if(Vo=!1,a==="ICU"||a==="FluxCU")try{yield{type:"status",content:"Capturing Screen"},await new Promise(D=>setTimeout(D,1e3));let{captureGriddedScreenshot:z}=await import("./screen_grid-EXWAAOMK.js"),G=await z();if(G&&G.base64){let D="[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]",dt={inlineData:{mimeType:G.mimeType,data:G.base64}},De=m?.imageHistoryCU||"Standard",Ge=De==="Low"?3:De==="Extended"?10:De==="Max"?999:5,Et=b.filter(Pe=>Array.isArray(Pe.parts)&&Pe.parts.some(At=>At.inlineData));if(Et.length>=Ge){let Pe=Et.length-Ge+1;for(let At=0;At<Pe;At++){let at=Et[At];Array.isArray(at.parts)&&(at.parts=at.parts.filter(mt=>!mt.inlineData))}}if(b.length>0&&b[b.length-1].role==="user"){let Pe=b[b.length-1];typeof Pe.text=="string"&&(Pe.text+=`
707
707
 
708
- ${N}`,Array.isArray(Fe.parts)||(Fe.parts=[{text:Fe.text}]),Fe.parts.push(at))}else b.push({role:"user",text:N,parts:[{text:N},at]})}}catch(Y){console.error("Vision screenshot capture error:",Y)}if(m?.compression===0&&(f?.tokens||0)>vt&&(b=Ms(b,6)),L>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"},ht){try{let{clearPendingNudges:Y}=await import("./subagent_state-LZCOZSUJ.js");Y()}catch{}yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
708
+ ${D}`,Array.isArray(Pe.parts)||(Pe.parts=[{text:Pe.text}]),Pe.parts.push(dt))}else b.push({role:"user",text:D,parts:[{text:D},dt]})}}catch(z){console.error("Vision screenshot capture error:",z)}if(m?.compression===0&&(f?.tokens||0)>It&&(b=Ps(b,6)),L>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"},wt){try{let{clearPendingNudges:z}=await import("./subagent_state-LZCOZSUJ.js");z()}catch{}yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
709
709
 
710
- \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}try{let{consumePendingNudges:Y}=await import("./subagent_state-LZCOZSUJ.js"),z=Y();if(z&&z.length>0){let N=z.join(`
710
+ \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}try{let{consumePendingNudges:z}=await import("./subagent_state-LZCOZSUJ.js"),G=z();if(G&&G.length>0){let D=G.join(`
711
711
 
712
712
  `);b.length>0&&b[b.length-1].role==="user"?b[b.length-1].text+=`
713
713
 
714
- ${N}`:b.push({role:"user",text:N}),yield{type:"status",content:"Subagent Update"}}}catch{}if(i){let Y=await i();Y&&(Y.startsWith("/btw")?b.length>0&&b[b.length-1].role==="user"?b[b.length-1].text+=`
714
+ ${D}`:b.push({role:"user",text:D}),yield{type:"status",content:"Subagent Update"}}}catch{}if(i){let z=await i();z&&(z.startsWith("/btw")?b.length>0&&b[b.length-1].role==="user"?b[b.length-1].text+=`
715
715
 
716
716
  [system] User question. Resolve this specific query within '[ANSWER]...[/ANSWER]' concisely, naturally [/system]
717
- [question] ${Y.replace("/btw","").trim()} [/question]`:b.push({role:"user",text:`[system] User question. Resolve this specific query within '[ANSWER]...[/ANSWER]' concisely, naturally [/system]
718
- [question] ${Y.replace("/btw","").trim()} [/question]`}):b.length>0&&b[b.length-1].role==="user"?b[b.length-1].text+=`
717
+ [question] ${z.replace("/btw","").trim()} [/question]`:b.push({role:"user",text:`[system] User question. Resolve this specific query within '[ANSWER]...[/ANSWER]' concisely, naturally [/system]
718
+ [question] ${z.replace("/btw","").trim()} [/question]`}):b.length>0&&b[b.length-1].role==="user"?b[b.length-1].text+=`
719
719
 
720
- [STEERING HINT from USER, High Priority] ${Y.trim()} [/STEERING HINT]`:b.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${Y.trim()} [/STEERING HINT]`}),yield{type:"status",content:`${Y.startsWith("/btw")?"Question Forwarded...":"Steering Hint Injected..."}`})}let Ae,Qe=!1,Ve=1,Ze=1,Yt=Date.now(),Ee=null,fe="",$=null,Ne=null,dt=null,en=0,De=[],xt=0,Sn=!1,Lt=!1,Hn=!1,Gt=!1,In=!0,eo=0,bt="",_e="",it=!1,zt=!1,Ue=!0,oe=e,We="",tn=d;for(d=d.toLowerCase()==="max"?"High":d;Ve<=dn&&Ze<=dn&&!Qe&&!ht;){let Y=!1;try{fe="",In&&(process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07"),yield{type:"turn_reset",content:!0},In=!1,Ze===1&&(bt=""));let z=h=>{if(!h||typeof h!="string")return h;let R="",v=cs(h);if(v&&(R=v.fullBlock,h=v.remainingText),!h.includes("[tool:")&&!h.includes("[action:"))return(m?.keepReasoningContext?R:"")+h;if(fo(h).length===0){let w=pi(h);return(m?.keepReasoningContext?R:"")+w}h=h.replace(al,(w,I)=>I.includes("[tool:")||I.includes("[action:")?I.trim():w);let re="",B=0,q=[],ut="";for(;B<h.length;){let w=h.indexOf("[tool:",B),I=h.indexOf("[action:",B),te=-1;if(w!==-1&&I!==-1?te=Math.min(w,I):w!==-1?te=w:te=I,te===-1){q.length===0&&(re+=pi(h.substring(B)));break}if((te>0?h[te-1]:"")==="`"){re+=pi(h.substring(B,te+1)),B=te+1;continue}q.length===0&&(ut=pi(h.substring(B,te)));let J=-1,O=null,gt=0;for(let $t=te;$t<h.length;$t++){let ne=h[$t];if(O){if(ne===O){let je=0;for(let mt=$t-1;mt>=0&&h[mt]==="\\";mt--)je++;je%2===0&&(O=null)}}else if(ne==='"'||ne==="'"||ne==="`")O=ne;else if(ne==="(")gt++;else if(ne===")")gt--;else if(ne==="]"&&gt<=0){J=$t;break}}if(J===-1){q.length===0&&(re+=h.substring(te));break}let kn=h.substring(te,J+1);q.push(kn),B=J+1}return q.length>0&&(re=ut.trimEnd()?ut.trimEnd()+`
720
+ [STEERING HINT from USER, High Priority] ${z.trim()} [/STEERING HINT]`:b.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${z.trim()} [/STEERING HINT]`}),yield{type:"status",content:`${z.startsWith("/btw")?"Question Forwarded...":"Steering Hint Injected..."}`})}let Ae,Ze=!1,ze=1,tt=1,Xt=Date.now(),Ee=null,fe="",$=null,Ne=null,gt=null,nn=0,Be=[],Tt=0,Tn=!1,Nt=!1,Hn=!1,Kt=!1,Mn=!0,to=0,kt="",_e="",rt=!1,Jt=!1,Ue=!0,oe=e,We="",on=d;for(d=d.toLowerCase()==="max"?"High":d;ze<=fn&&tt<=fn&&!Ze&&!wt;){let z=!1;try{fe="",Mn&&(process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07"),yield{type:"turn_reset",content:!0},Mn=!1,tt===1&&(kt=""));let G=h=>{if(!h||typeof h!="string")return h;let R="",v=cs(h);if(v&&(R=v.fullBlock,h=v.remainingText),!h.includes("[tool:")&&!h.includes("[action:"))return(m?.keepReasoningContext?R:"")+h;if(Qn(h).length===0){let w=hi(h);return(m?.keepReasoningContext?R:"")+w}h=h.replace(al,(w,I)=>I.includes("[tool:")||I.includes("[action:")?I.trim():w);let re="",B=0,q=[],ht="";for(;B<h.length;){let w=h.indexOf("[tool:",B),I=h.indexOf("[action:",B),te=-1;if(w!==-1&&I!==-1?te=Math.min(w,I):w!==-1?te=w:te=I,te===-1){q.length===0&&(re+=hi(h.substring(B)));break}if((te>0?h[te-1]:"")==="`"){re+=hi(h.substring(B,te+1)),B=te+1;continue}q.length===0&&(ht=hi(h.substring(B,te)));let J=-1,O=null,yt=0;for(let Ft=te;Ft<h.length;Ft++){let ne=h[Ft];if(O){if(ne===O){let Ve=0;for(let xt=Ft-1;xt>=0&&h[xt]==="\\";xt--)Ve++;Ve%2===0&&(O=null)}}else if(ne==='"'||ne==="'"||ne==="`")O=ne;else if(ne==="(")yt++;else if(ne===")")yt--;else if(ne==="]"&&yt<=0){J=Ft;break}}if(J===-1){q.length===0&&(re+=h.substring(te));break}let An=h.substring(te,J+1);q.push(An),B=J+1}return q.length>0&&(re=ht.trimEnd()?ht.trimEnd()+`
721
721
 
722
722
  `+q.join(`
723
723
 
724
724
  `):q.join(`
725
725
 
726
- `)),(m?.keepReasoningContext?R:"")+re},N=b.filter(h=>(h.role==="user"||h.role==="agent"||h.role==="system")&&!String(h.id).startsWith("welcome")&&!h.isMeta&&!h.isTerminalRecord&&!(h.text&&h.text.startsWith("[TERMINAL_RECORD]"))).map((h,R,v)=>{let Z=h.text||"";_||(Z=Z.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),h.role==="agent"&&(Z=z(Z),Z=Z.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),Z=Z.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*"));let re=[];return Array.isArray(h.parts)&&h.parts.length>0?re=h.parts.map(B=>{if(B.text){let q=B.text;return _||(q=q.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),h.role==="agent"&&(q=z(q),q=q.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),q=q.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*")),{text:q}}return B}):re=[{text:Z}],h.binaryPart&&rt(oe)&&v.slice(R+1).filter(q=>q.role==="user"&&!q.text?.startsWith("[ACTION RESULT]")&&!q.text?.startsWith("[TOOL RESULT]")).length<=2&&re.push(h.binaryPart),{role:h.role==="user"||h.role==="system"?"user":"model",parts:re}});for(let h=N.length-2;h>=0;h--){let R=N[h],v=N[h+1];R.role==="user"&&v.role==="user"&&(v.parts?.[0]?.text||"").trim().startsWith("[SYSTEM")&&N.splice(h,1)}let at=[];for(let h=0;h<N.length;h++){let R=N[h];if(at.length===0)at.push(R);else{let v=at[at.length-1];v.role===R.role?(v.parts[0].text+=`
726
+ `)),(m?.keepReasoningContext?R:"")+re},D=b.filter(h=>(h.role==="user"||h.role==="agent"||h.role==="system")&&!String(h.id).startsWith("welcome")&&!h.isMeta&&!h.isTerminalRecord&&!(h.text&&h.text.startsWith("[TERMINAL_RECORD]"))).map((h,R,v)=>{let Z=h.text||"";_||(Z=Z.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),h.role==="agent"&&(Z=G(Z),Z=Z.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),Z=Z.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*"));let re=[];return Array.isArray(h.parts)&&h.parts.length>0?re=h.parts.map(B=>{if(B.text){let q=B.text;return _||(q=q.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),h.role==="agent"&&(q=G(q),q=q.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),q=q.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*")),{text:q}}return B}):re=[{text:Z}],h.binaryPart&&ct(oe)&&v.slice(R+1).filter(q=>q.role==="user"&&!q.text?.startsWith("[ACTION RESULT]")&&!q.text?.startsWith("[TOOL RESULT]")).length<=2&&re.push(h.binaryPart),{role:h.role==="user"||h.role==="system"?"user":"model",parts:re}});for(let h=D.length-2;h>=0;h--){let R=D[h],v=D[h+1];R.role==="user"&&v.role==="user"&&(v.parts?.[0]?.text||"").trim().startsWith("[SYSTEM")&&D.splice(h,1)}let dt=[];for(let h=0;h<D.length;h++){let R=D[h];if(dt.length===0)dt.push(R);else{let v=dt[dt.length-1];v.role===R.role?(v.parts[0].text+=`
727
727
 
728
- `+(R.parts?.[0]?.text||""),R.parts?.length>1&&v.parts.push(...R.parts.slice(1))):at.push(R)}}for(let h of at)for(let R of h.parts||[])R&&typeof R.text=="string"&&(R.text.includes("[action:")||R.text.includes("[tool:"))&&(R.text=R.text.replace(/```(?:[a-zA-Z0-9_-]+)?\s*\n?(\[(?:action|tool):[\s\S]*?\)\s*\])\n?```/gi,"$1"),R.text=R.text.replace(/`(\[(?:action|tool):[\s\S]*?\)\s*\])`/gi,"$1"));N.length=0,N.push(...at),oe=e;let Pe=`${p}|${s}|${a}|${d}|${tn}|${oe}|${JSON.stringify(r)}|${!!m?.dynamicDirAwareness}|${!!m?.subAgents}`,Ye=Xn.key===Pe&&Xn.value;if((process.env.I_HAVE_TOO_MUCH_MONEY==="true"||process.env.I_HAVE_TOO_MUCH_MONEY===!0)&&(Ye=!1),Ye)We=Xn.value;else{let h=s==="Mistral"?!!Zo(oe):!(oe||"gemma").toLowerCase().startsWith("gemma");We=xr(r,((oe||"gemma").toLowerCase().startsWith("gemma"),tn),a,m,_,E,s,s==="Google"?!0:y,h,p,!!m?.keepReasoningContext,oe),m?.dynamicDirAwareness||(We+=`
728
+ `+(R.parts?.[0]?.text||""),R.parts?.length>1&&v.parts.push(...R.parts.slice(1))):dt.push(R)}}for(let h of dt)for(let R of h.parts||[])R&&typeof R.text=="string"&&(R.text.includes("[action:")||R.text.includes("[tool:"))&&(R.text=R.text.replace(/```(?:[a-zA-Z0-9_-]+)?\s*\n?(\[(?:action|tool):[\s\S]*?\)\s*\])\n?```/gi,"$1"),R.text=R.text.replace(/`(\[(?:action|tool):[\s\S]*?\)\s*\])`/gi,"$1"));D.length=0,D.push(...dt),oe=e;let De=`${p}|${s}|${a}|${d}|${on}|${oe}|${JSON.stringify(r)}|${!!m?.dynamicDirAwareness}|${!!m?.subAgents}`,Ge=Xn.key===De&&Xn.value;if((process.env.I_HAVE_TOO_MUCH_MONEY==="true"||process.env.I_HAVE_TOO_MUCH_MONEY===!0)&&(Ge=!1),Ge)We=Xn.value;else{let h=s==="Mistral"?!!ei(oe):!(oe||"gemma").toLowerCase().startsWith("gemma");We=br(r,((oe||"gemma").toLowerCase().startsWith("gemma"),on),a,m,_,E,s,s==="Google"?!0:y,h,p,!!m?.keepReasoningContext,oe),m?.dynamicDirAwareness||(We+=`
729
729
  ${na.replace(`
730
730
  **Directory**`,`
731
- -- Directory --`)}`),Xn.key=Pe,Xn.value=We}let Fe=N[N.length-1];if(lo()&L>0){await new Promise(v=>setTimeout(v,2500)),yield{type:"status",content:"Verifying"};let h=await qn(),R=h?h.diagnostics:null;R&&Fe&&Fe.role==="user"&&Fe.parts?.[0]?.text&&(Fe.parts[0].text+=`
731
+ -- Directory --`)}`),Xn.key=De,Xn.value=We}let Pe=D[D.length-1];if(fo()&L>0){await new Promise(v=>setTimeout(v,2500)),yield{type:"status",content:"Verifying"};let h=await qn(),R=h?h.diagnostics:null;R&&Pe&&Pe.role==="user"&&Pe.parts?.[0]?.text&&(Pe.parts[0].text+=`
732
732
 
733
- ${R} [/ERROR]`),yield{type:"status",content:"Working"}}let St=s==="Mistral"||s==="Google"&&e?.toLowerCase().startsWith("gemma");if(m?.advanceRollback&&Fe&&Fe.role==="user"&&(Fe.parts?.[0]?.text?.startsWith("[ACTION RESULT]")||Fe.parts?.[0]?.text?.startsWith("[TOOL RESULT]")))try{let h=await Ao.getLatestFileChanges(p);if(h&&(h.newFiles.length>0||h.modifiedFiles.length>0||h.deletedFiles.length>0)){let R=`
733
+ ${R} [/ERROR]`),yield{type:"status",content:"Working"}}let At=s==="Mistral"||s==="Google"&&e?.toLowerCase().startsWith("gemma");if(m?.advanceRollback&&Pe&&Pe.role==="user"&&(Pe.parts?.[0]?.text?.startsWith("[ACTION RESULT]")||Pe.parts?.[0]?.text?.startsWith("[TOOL RESULT]")))try{let h=await Eo.getLatestFileChanges(p);if(h&&(h.newFiles.length>0||h.modifiedFiles.length>0||h.deletedFiles.length>0)){let R=`
734
734
  [system] File Changes:
735
735
  `;for(let Z of h.newFiles)R+=`* ${Z} (created)
736
736
  `;for(let Z of h.modifiedFiles)R+=`* ${Z} (modified)
737
737
  `;for(let Z of h.deletedFiles)R+=`* ${Z} (deleted)
738
- `;R+="[/system]",Fe.parts[0].text+=R;let v=-1;for(let Z=b.length-1;Z>=0;Z--)if(b[Z].role==="user"&&(b[Z].text?.startsWith("[ACTION RESULT]")||b[Z].text?.startsWith("[TOOL RESULT]"))){v=Z;break}v!==-1&&(b[v].text+=R)}}catch{}let kt=Math.floor(vn*.99),Tt=L+1;if(Tt>=kt&&Fe&&Fe.parts?.[0]&&(Fe.parts[0].text+=`
739
- [system] WARNING, Turn Limit Impending: Step ${Tt}/${vn}. 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 h=j.join(Rn,"chats",String(p));Se.existsSync(h)||Se.mkdirSync(h,{recursive:!0}),Se.writeFileSync(j.join(h,"context.json"),JSON.stringify({contents:N},null,2)),Se.writeFileSync(j.join(h,"system.md"),`${Ye?"CACHED":"NOT CACHED"}
740
- Key: ${Pe}
738
+ `;R+="[/system]",Pe.parts[0].text+=R;let v=-1;for(let Z=b.length-1;Z>=0;Z--)if(b[Z].role==="user"&&(b[Z].text?.startsWith("[ACTION RESULT]")||b[Z].text?.startsWith("[TOOL RESULT]"))){v=Z;break}v!==-1&&(b[v].text+=R)}}catch{}let at=Math.floor(In*.99),mt=L+1;if(mt>=at&&Pe&&Pe.parts?.[0]&&(Pe.parts[0].text+=`
739
+ [system] WARNING, Turn Limit Impending: Step ${mt}/${In}. 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 h=K.join(_n,"chats",String(p));Se.existsSync(h)||Se.mkdirSync(h,{recursive:!0}),Se.writeFileSync(K.join(h,"context.json"),JSON.stringify({contents:D},null,2)),Se.writeFileSync(K.join(h,"system.md"),`${Ge?"CACHED":"NOT CACHED"}
740
+ Key: ${De}
741
741
  --------------------------------------------------------------------
742
742
 
743
- ${We}`)}let Mn=new Promise((h,R)=>{T.signal.aborted&&R(new DOMException("The user aborted a request.","AbortError")),T.signal.addEventListener("abort",()=>{R(new DOMException("The user aborted a request.","AbortError"))})});Mn.catch(()=>{});let At=N;if(Yt=Date.now(),s==="Ollama")Ae=(await ce("Ollama"))(t.apiKey,oe,At,We,d,a,y,T.signal,1,m?.ollamaEndpoint||"Cloud");else if(s==="OpenRouter")Ae=(await ce("OpenRouter"))(t.apiKey,oe,At,We,d,a,y,T.signal,1,p);else if(s==="DeepSeek")Ae=(await ce("DeepSeek"))(t.apiKey,oe,At,We,d,a,y,T.signal,1);else if(s==="Mistral")Ae=(await ce("Mistral"))(t.apiKey,oe,At,We,d,a,y,T.signal,1,p);else if(s==="NVIDIA"){let h=(await ce("NVIDIA"))(t.apiKey,oe,At,We,d,a,y,T.signal,1);Ae=(await ce("NVIDIA_wrap"))(h,oe)}else if(s==="InferX")Ae=(await ce("InferX"))(t.apiKey,oe,At,We,d,a,y,T.signal,1);else if(s==="SenseNova")Ae=(await ce("SenseNova"))(t.apiKey,oe,At,We,d,a,y,T.signal,1);else if(s==="AIHubMix")Ae=(await ce("AIHubMix"))(t.apiKey,oe,At,We,d,a,y,T.signal,1);else if(s==="Poolside")Ae=(await ce("Poolside"))(t.apiKey,oe,At,We,d,a,y,T.signal,1);else if(s==="9router"||s==="9Router")Ae=(await ce("NineRouter"))(t.apiKey,oe,At,We,d,a,y,T.signal,1);else if(s==="ExpLabs"||s==="ExperientialLabs")Ae=(await ce("ExpLabs"))(t.apiKey,oe,At,We,d,a,y,T.signal,1);else if(s==="Infron"||s==="infron")Ae=(await ce("Infron"))(t.apiKey,oe,At,We,d,a,y,T.signal,1);else if(s==="TokenHarbor"||s==="Token Harbor"||s==="tokenharbor"||s==="token_harbor"||s==="thk")Ae=(await ce("TokenHarbor"))(t.apiKey,oe,At,We,d,a,y,T.signal,1);else if(s==="APInex"||s==="apinex"||s==="apx")Ae=(await ce("APInex"))(t.apiKey,oe,At,We,d,a,y,T.signal,1);else if(s==="c_openai"||s==="Custom (OpenAI)")Ae=(await ce("c_openai"))(t.apiKey,oe,At,We,d,a,y,T.signal,1,m?.customOpenAIBaseUrl||"");else{let h=us(t?.apiKey),{serviceTier:R,cleanModel:v}=ta(oe),Z={systemInstruction:We,mediaResolution:"MEDIA_RESOLUTION_HIGH",safetySettings:[{category:Un.HARM_CATEGORY_HARASSMENT,threshold:Bn.BLOCK_NONE},{category:Un.HARM_CATEGORY_HATE_SPEECH,threshold:Bn.BLOCK_NONE},{category:Un.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:Bn.BLOCK_NONE},{category:Un.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:Bn.BLOCK_NONE}],temperature:1.05,thinkingConfig:(()=>{let B=Is("Google",oe||"gemini-3-flash-preview",d);if(B!==null){if(typeof B=="object")return B;if(B===!1||B==="false"||B==="none"||B===0||B==="0")return{includeThoughts:!1};if(typeof B=="number")return{includeThoughts:!0,thinkingBudget:B};if(typeof B=="string"){let I=B.toLowerCase();if(I==="minimal")return{includeThoughts:!0,thinkingLevel:He.MINIMAL};if(I==="low")return{includeThoughts:!0,thinkingLevel:He.LOW};if(I==="medium")return{includeThoughts:!0,thinkingLevel:He.MEDIUM};if(I==="high")return{includeThoughts:!0,thinkingLevel:He.HIGH};let te=Number(B);if(!isNaN(te))return{includeThoughts:!0,thinkingBudget:te}}}let q=(oe||"").toLowerCase(),ut=q.includes("gemma-4")||q.startsWith("gemma"),w=q.includes("gemini-3");if(ut||w)return ut?d.toLowerCase()!=="high"?{includeThoughts:!1,thinkingLevel:He.MINIMAL}:{includeThoughts:!0,thinkingLevel:He.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:q.includes("pro")?He.LOW:He.MINIMAL,Low:He.LOW,Medium:He.MEDIUM,Standard:He.MEDIUM,High:He.HIGH,xHigh:He.HIGH}[d]||He.MEDIUM};{let I={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[d]||2048;return I===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:I}}})()};R&&(Z.serviceTier=R);let re=h.models.generateContentStream({model:v||"gemini-3-flash-preview",contents:At,config:Z},{signal:T.signal});Ae=await Promise.race([re,Mn])}fe="",$=null,dt=null,De=[],xt=0,yield{type:"model_update",content:null},_e="",it=bt.length>0;let nn="",ki=Date.now(),Kn=async function*(){if(s==="Google"&&nn){let h=po(nn);for(let R of h)yield R;nn="",ki=Date.now()}},Ss=!0,Tn="",to=!1,ft=null,Ts=!1,Vn=!1,no=!1,Vo=!1,Pn=!1,mo=h=>{let R=0;for(;R+2<h.length;)h[R]==="`"&&h[R+1]==="`"&&h[R+2]==="`"?(Vo=!Vo,R+=3):R++},ks=h=>{if(!h)return;let R=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,v;for(;(v=R.exec(h))!==null;){let Z=v[0].toLowerCase();Z.startsWith("</")||Z.startsWith("[/")||Z==="<channel|>"?Pn=!1:Pn=!0}},da={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|>"}},po=h=>{let R=[],v=h,Z=re=>{if(!re)return;if(!Ts){R.push({type:"text",content:re}),mo(re),ks(re);return}let B=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,q=0,ut;for(;(ut=B.exec(re))!==null;){let I=re.substring(q,ut.index);if(I)if(mo(I),Pn)R.push({type:"text",content:I});else{let Oe=I.replace(/[^\r\n]/g,"");Oe&&R.push({type:"text",content:Oe})}let te=ut[0];mo(te);let l=te.toLowerCase();l.startsWith("</")||l.startsWith("[/")||l==="<channel|>"?Pn=!1:Pn=!0,R.push({type:"text",content:te}),q=B.lastIndex}let w=re.substring(q);if(w)if(mo(w),Pn)R.push({type:"text",content:w});else{let I=w.replace(/[^\r\n]/g,"");I&&R.push({type:"text",content:I})}};for(;v.length>0;)if(to){let re=Tn+v,B=da[ft];if(B){let w=!1;if(re.length<B.startPrefix.length?B.startPrefix.startsWith(re)||(w=!0):re.startsWith(B.startPrefix)?re.length>=B.fullPrefix.length&&!re.startsWith(B.fullPrefix)&&(w=!0):w=!0,w){Z(re),Tn="",to=!1,ft=null,Vn=!1,no=!1,v="";break}}let q=-1,ut=B?B.endTag:"]";if(ft==="tool"||ft==="action"){let w=0,I=null,te=0,l=!1;for(let Oe=0;Oe<re.length;Oe++){let J=re[Oe];if(I){if(J===I){let O=0;for(let gt=Oe-1;gt>=0&&re[gt]==="\\";gt--)O++;O%2===0&&(I=null)}}else if(J==='"'||J==="'")I=J;else if(J==="`")if(Vn){q=Oe;break}else I=J;else if(J==="(")w++,l=!0;else if(J===")")w--;else if(J==="]"&&l&&w===0){q=Oe;break}}}else q=re.indexOf(ut);if(q!==-1){let w=ut.length,I=re.substring(0,q+w);ft?.startsWith("kimi")||R.push({type:"text",content:I}),mo(I),ks(I),(ft==="tool"||ft==="action"||ft?.startsWith("kimi"))&&!Vn&&!no&&(Ts=!0,Gn.push(I.trim())),Vn=!1,no=!1,Tn="",to=!1,ft=null,v=re.substring(q+w)}else{Tn=re,v="";break}}else{let re=v.indexOf("[tool"),B=v.indexOf("[action"),q=v.indexOf("[[END]]"),ut=v.indexOf("<|tool_calls_section_begin|>"),w=v.indexOf("<|tool_call_begin|>"),I=[{type:"tool",idx:re,start:"[tool",end:"]"},{type:"action",idx:B,start:"[action",end:"]"},{type:"end",idx:q,start:"[[END]]",end:"[[END]]"},{type:"kimi_section",idx:ut,start:"<|tool_calls_section_begin|>",end:"<|tool_calls_section_end|>"},{type:"kimi_call",idx:w,start:"<|tool_call_begin|>",end:"<|tool_call_end|>"}].filter(te=>te.idx!==-1).sort((te,l)=>te.idx-l.idx);if(I.length>0){let te=I[0],l=v.substring(0,te.idx);te.idx>0&&Z(l);let Oe=te.idx>0?v[te.idx-1]:"";Vn=Vo||Oe==="`",no=Pn,to=!0,ft=te.type,Tn="",v=v.substring(te.idx)}else{let te=["[tool","[action","[[END]]","<|tool_calls_section_begin|>","<|tool_call_begin|>"],l=-1;for(let Oe of te){for(let J=Oe.length-1;J>0;J--)if(v.endsWith(Oe.substring(0,J))){l=v.length-J;let O=te.indexOf(Oe);O===0?ft="tool":O===1?ft="action":O===2?ft="end":O===3?ft="kimi_section":ft="kimi_call";break}if(l!==-1)break}if(l!==-1){if(l>0){let J=v.substring(0,l);Z(J)}let Oe=l>0?v[l-1]:"";Vn=Vo||Oe==="`",no=Pn,to=!0,Tn=v.substring(l),v=""}else{Z(v);break}}}return R},fa=Ae[Symbol.asyncIterator]();for(;;){let{value:h,done:R}=await Promise.race([fa.next(),Mn]);if(R)break;if(h&&h.type==="status"){yield h;continue}let v="",Z=h.candidates?.[0]?.content?.parts;if(Z&&Z.length>0)for(let B of Z){let q=typeof B.text=="string"?B.text:B.text?parseChunkText(B.text):"";B.thought?q&&(Y||(v+="<think_fluxflow>",Y=!0),v+=q):q&&(Y&&(v+="</think_fluxflow>",Y=!1),v+=q)}else h.text&&Y&&(v+="</think_fluxflow>",Y=!1);v=ol(v);let re=v?Oi(v):0;if(t&&typeof t.onTokenChunk=="function"&&t.onTokenChunk(v,re),Ss&&(Ee===null&&(Ee=Date.now()-Yt),yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"},Ss=!1),ht){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
743
+ ${We}`)}let Pt=new Promise((h,R)=>{T.signal.aborted&&R(new DOMException("The user aborted a request.","AbortError")),T.signal.addEventListener("abort",()=>{R(new DOMException("The user aborted a request.","AbortError"))})});Pt.catch(()=>{});let He=D;if(Xt=Date.now(),s==="Ollama")Ae=(await ce("Ollama"))(t.apiKey,oe,He,We,d,a,y,T.signal,1,m?.ollamaEndpoint||"Cloud");else if(s==="OpenRouter")Ae=(await ce("OpenRouter"))(t.apiKey,oe,He,We,d,a,y,T.signal,1,p);else if(s==="DeepSeek")Ae=(await ce("DeepSeek"))(t.apiKey,oe,He,We,d,a,y,T.signal,1);else if(s==="Mistral")Ae=(await ce("Mistral"))(t.apiKey,oe,He,We,d,a,y,T.signal,1,p);else if(s==="NVIDIA"){let h=(await ce("NVIDIA"))(t.apiKey,oe,He,We,d,a,y,T.signal,1);Ae=(await ce("NVIDIA_wrap"))(h,oe)}else if(s==="InferX")Ae=(await ce("InferX"))(t.apiKey,oe,He,We,d,a,y,T.signal,1);else if(s==="SenseNova")Ae=(await ce("SenseNova"))(t.apiKey,oe,He,We,d,a,y,T.signal,1);else if(s==="AIHubMix")Ae=(await ce("AIHubMix"))(t.apiKey,oe,He,We,d,a,y,T.signal,1);else if(s==="Poolside")Ae=(await ce("Poolside"))(t.apiKey,oe,He,We,d,a,y,T.signal,1);else if(s==="9router"||s==="9Router")Ae=(await ce("NineRouter"))(t.apiKey,oe,He,We,d,a,y,T.signal,1);else if(s==="ExpLabs"||s==="ExperientialLabs")Ae=(await ce("ExpLabs"))(t.apiKey,oe,He,We,d,a,y,T.signal,1);else if(s==="Infron"||s==="infron")Ae=(await ce("Infron"))(t.apiKey,oe,He,We,d,a,y,T.signal,1);else if(s==="TokenHarbor"||s==="Token Harbor"||s==="tokenharbor"||s==="token_harbor"||s==="thk")Ae=(await ce("TokenHarbor"))(t.apiKey,oe,He,We,d,a,y,T.signal,1);else if(s==="APInex"||s==="apinex"||s==="apx")Ae=(await ce("APInex"))(t.apiKey,oe,He,We,d,a,y,T.signal,1);else if(s==="c_openai"||s==="Custom (OpenAI)")Ae=(await ce("c_openai"))(t.apiKey,oe,He,We,d,a,y,T.signal,1,m?.customOpenAIBaseUrl||"");else{let h=us(t?.apiKey),{serviceTier:R,cleanModel:v}=ta(oe),Z={systemInstruction:We,mediaResolution:"MEDIA_RESOLUTION_HIGH",safetySettings:[{category:Un.HARM_CATEGORY_HARASSMENT,threshold:Bn.BLOCK_NONE},{category:Un.HARM_CATEGORY_HATE_SPEECH,threshold:Bn.BLOCK_NONE},{category:Un.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:Bn.BLOCK_NONE},{category:Un.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:Bn.BLOCK_NONE}],temperature:1.05,thinkingConfig:(()=>{let B=Ms("Google",oe||"gemini-3-flash-preview",d);if(B!==null){if(typeof B=="object")return B;if(B===!1||B==="false"||B==="none"||B===0||B==="0")return{includeThoughts:!1};if(typeof B=="number")return{includeThoughts:!0,thinkingBudget:B};if(typeof B=="string"){let I=B.toLowerCase();if(I==="minimal")return{includeThoughts:!0,thinkingLevel:Ke.MINIMAL};if(I==="low")return{includeThoughts:!0,thinkingLevel:Ke.LOW};if(I==="medium")return{includeThoughts:!0,thinkingLevel:Ke.MEDIUM};if(I==="high")return{includeThoughts:!0,thinkingLevel:Ke.HIGH};let te=Number(B);if(!isNaN(te))return{includeThoughts:!0,thinkingBudget:te}}}let q=(oe||"").toLowerCase(),ht=q.includes("gemma-4")||q.startsWith("gemma"),w=q.includes("gemini-3");if(ht||w)return ht?d.toLowerCase()!=="high"?{includeThoughts:!1,thinkingLevel:Ke.MINIMAL}:{includeThoughts:!0,thinkingLevel:Ke.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:q.includes("pro")?Ke.LOW:Ke.MINIMAL,Low:Ke.LOW,Medium:Ke.MEDIUM,Standard:Ke.MEDIUM,High:Ke.HIGH,xHigh:Ke.HIGH}[d]||Ke.MEDIUM};{let I={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[d]||2048;return I===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:I}}})()};R&&(Z.serviceTier=R);let re=h.models.generateContentStream({model:v||"gemini-3-flash-preview",contents:He,config:Z},{signal:T.signal});Ae=await Promise.race([re,Pt])}fe="",$=null,gt=null,Be=[],Tt=0,yield{type:"model_update",content:null},_e="",rt=kt.length>0;let Dt="",no=Date.now(),Kn=async function*(){if(s==="Google"&&Dt){let h=ho(Dt);for(let R of h)yield R;Dt="",no=Date.now()}},Ts=!0,kn="",oo=!1,pt=null,ks=!1,Vn=!1,io=!1,Yo=!1,Pn=!1,po=h=>{let R=0;for(;R+2<h.length;)h[R]==="`"&&h[R+1]==="`"&&h[R+2]==="`"?(Yo=!Yo,R+=3):R++},As=h=>{if(!h)return;let R=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,v;for(;(v=R.exec(h))!==null;){let Z=v[0].toLowerCase();Z.startsWith("</")||Z.startsWith("[/")||Z==="<channel|>"?Pn=!1:Pn=!0}},da={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|>"}},ho=h=>{let R=[],v=h,Z=re=>{if(!re)return;if(!ks){R.push({type:"text",content:re}),po(re),As(re);return}let B=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,q=0,ht;for(;(ht=B.exec(re))!==null;){let I=re.substring(q,ht.index);if(I)if(po(I),Pn)R.push({type:"text",content:I});else{let Oe=I.replace(/[^\r\n]/g,"");Oe&&R.push({type:"text",content:Oe})}let te=ht[0];po(te);let l=te.toLowerCase();l.startsWith("</")||l.startsWith("[/")||l==="<channel|>"?Pn=!1:Pn=!0,R.push({type:"text",content:te}),q=B.lastIndex}let w=re.substring(q);if(w)if(po(w),Pn)R.push({type:"text",content:w});else{let I=w.replace(/[^\r\n]/g,"");I&&R.push({type:"text",content:I})}};for(;v.length>0;)if(oo){let re=kn+v,B=da[pt];if(B){let w=!1;if(re.length<B.startPrefix.length?B.startPrefix.startsWith(re)||(w=!0):re.startsWith(B.startPrefix)?re.length>=B.fullPrefix.length&&!re.startsWith(B.fullPrefix)&&(w=!0):w=!0,w){Z(re),kn="",oo=!1,pt=null,Vn=!1,io=!1,v="";break}}let q=-1,ht=B?B.endTag:"]";if(pt==="tool"||pt==="action"){let w=0,I=null,te=0,l=!1;for(let Oe=0;Oe<re.length;Oe++){let J=re[Oe];if(I){if(J===I){let O=0;for(let yt=Oe-1;yt>=0&&re[yt]==="\\";yt--)O++;O%2===0&&(I=null)}}else if(J==='"'||J==="'")I=J;else if(J==="`")if(Vn){q=Oe;break}else I=J;else if(J==="(")w++,l=!0;else if(J===")")w--;else if(J==="]"&&l&&w===0){q=Oe;break}}}else q=re.indexOf(ht);if(q!==-1){let w=ht.length,I=re.substring(0,q+w);pt?.startsWith("kimi")||R.push({type:"text",content:I}),po(I),As(I),(pt==="tool"||pt==="action"||pt?.startsWith("kimi"))&&!Vn&&!io&&(ks=!0,Gn.push(I.trim())),Vn=!1,io=!1,kn="",oo=!1,pt=null,v=re.substring(q+w)}else{kn=re,v="";break}}else{let re=v.indexOf("[tool"),B=v.indexOf("[action"),q=v.indexOf("[[END]]"),ht=v.indexOf("<|tool_calls_section_begin|>"),w=v.indexOf("<|tool_call_begin|>"),I=[{type:"tool",idx:re,start:"[tool",end:"]"},{type:"action",idx:B,start:"[action",end:"]"},{type:"end",idx:q,start:"[[END]]",end:"[[END]]"},{type:"kimi_section",idx:ht,start:"<|tool_calls_section_begin|>",end:"<|tool_calls_section_end|>"},{type:"kimi_call",idx:w,start:"<|tool_call_begin|>",end:"<|tool_call_end|>"}].filter(te=>te.idx!==-1).sort((te,l)=>te.idx-l.idx);if(I.length>0){let te=I[0],l=v.substring(0,te.idx);te.idx>0&&Z(l);let Oe=te.idx>0?v[te.idx-1]:"";Vn=Yo||Oe==="`",io=Pn,oo=!0,pt=te.type,kn="",v=v.substring(te.idx)}else{let te=["[tool","[action","[[END]]","<|tool_calls_section_begin|>","<|tool_call_begin|>"],l=-1;for(let Oe of te){for(let J=Oe.length-1;J>0;J--)if(v.endsWith(Oe.substring(0,J))){l=v.length-J;let O=te.indexOf(Oe);O===0?pt="tool":O===1?pt="action":O===2?pt="end":O===3?pt="kimi_section":pt="kimi_call";break}if(l!==-1)break}if(l!==-1){if(l>0){let J=v.substring(0,l);Z(J)}let Oe=l>0?v[l-1]:"";Vn=Yo||Oe==="`",io=Pn,oo=!0,kn=v.substring(l),v=""}else{Z(v);break}}}return R},fa=Ae[Symbol.asyncIterator]();for(;;){let{value:h,done:R}=await Promise.race([fa.next(),Pt]);if(R)break;if(h&&h.type==="status"){yield h;continue}let v="",Z=h.candidates?.[0]?.content?.parts;if(Z&&Z.length>0)for(let B of Z){let q=typeof B.text=="string"?B.text:B.text?parseChunkText(B.text):"";B.thought?q&&(z||(v+="<think_fluxflow>",z=!0),v+=q):q&&(z&&(v+="</think_fluxflow>",z=!1),v+=q)}else h.text&&z&&(v+="</think_fluxflow>",z=!1);v=ol(v);let re=v?Oi(v):0;if(t&&typeof t.onTokenChunk=="function"&&t.onTokenChunk(v,re),Ts&&(Ee===null&&(Ee=Date.now()-Xt),yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"},Ts=!1),wt){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
744
744
 
745
- \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(v){if(it){if(_e+=v,_e.length>=64){let w=0,I=Math.min(bt.length,_e.length);for(let l=I;l>=10;l--)if(bt.endsWith(_e.substring(0,l))){w=l;break}let te=_e.substring(w);if(te){let Oe=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(bt)?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(Oe)if(fe+=Oe,s==="Google")nn+=Oe;else{yield*Kn();let J=po(Oe);for(let O of J)yield O}}it=!1,_e=""}continue}else if(fe+=v,s==="Google")nn+=v;else{yield*Kn();let w=po(v);for(let I of w)yield I}let B=fl(fe);if(B.inside){zt=!0,dt||(dt=Date.now());let I={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"}[B.toolName]||B.toolName,te=B.args||"",l=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(I)){let J=H(te),O=J.basename||J.name||J.path||J.targetFile||J.TargetFile||J.directory||J.file,gt=J.keyword,kn=J.title||J.task,$t=J.id||J.taskId,ne=J.timeout||J.time||J.seconds||J.sec;if(gt!=null)l=String(gt).replace(_n,"");else if(O)l=j.basename(String(O).replace(_n,"").replace(Kr,"/"));else if(kn&&(I==="invoke"||I==="invoke_sync"))l=String(kn).replace(_n,"").substring(0,30);else if($t&&I==="get_progress")l=String($t).replace(_n,"");else if(ne&&I==="await"){let je=parseFloat(String(ne).replace(_n,""));isNaN(je)?l=String(ne).replace(_n,""):(je<5&&(je=5),je>120&&(je=180),l=(Nt=>{if(Nt>=60){let yo=Math.floor(Nt/60),An=Nt%60;return`${yo}m${An>0?` ${An}s`:""}`}return`${Nt}s`})(je))}else if(ne&&I==="wait"){let je=parseFloat(String(ne).replace(_n,""));isNaN(je)?l=String(ne).replace(_n,""):(je<10&&(je=10),je>120&&(je=120),l=(Nt=>{if(Nt>=60){let yo=Math.floor(Nt/60),An=Nt%60;return`${yo}m${An>0?` ${An}s`:""}`}return`${Nt}s`})(je))}else{let je=te.match(el);if(je){let mt=je[1].replace(_n,"");I==="invoke"||I==="invoke_sync"||I==="get_progress"?l=mt.substring(0,30):l=I==="search_keyword"||I==="file_map"?mt:j.basename(mt.replace(Kr,"/"))}}}let Oe=`${ds[I]||I}${l?` ${l}`:""}`;if((I!==$||l!==Ne)&&($=I,Ne=l,yield{type:"status",content:`${Oe}`},process.stdout.isTTY)){let O={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"}[I]||"Working";process.stdout.write(`\x1B]0;${O}...\x07`)}}if(fe.length-eo>800){eo=fe.length;let w=ea(fe,!1),I=cs(w),te=I?(I.innerContent||"").trim():"",l=te.split(/[.!?]\s+/).filter(he=>he.trim().length>10),Oe=new Set(l),J=l.length>25?(l.length-Oe.size)/l.length:0,O=te.split(/\s+/).filter(he=>he.length>0).length,gt=.9,kn=.92,$t=!1;if(s.toLowerCase().includes("google")&&(oe||"").toLowerCase().startsWith("gemma")){let c={low:2048,medium:4096,high:32768,max:65536,xhigh:65536}[d?.toLowerCase()]||16e3;$t=O>c}if(J>gt||$t){yield{type:"status",content:`${J>gt?"Reasoning Loop Detected":"Thinking Budget Exceeded"}. Re-centering...`},Lt=!0,await new Promise(c=>setTimeout(c,3e3));break}let mt=qr(fe).trim().split(/[.!?]\s+/).filter(he=>he.trim().length>10),Nt=new Set(mt);if((mt.length>25?(mt.length-Nt.size)/mt.length:0)>kn){yield{type:"status",content:"Response Loop Detected. Re-centering..."},Lt=!1,Gt=!0,await new Promise(he=>setTimeout(he,3e3));break}let An=w.replace(Ya,"").replace(za,"").replace(qa,"").replace(Xa,""),Et=An.toLowerCase().split(/\s+/).map(he=>he.replace(Ja,"")).filter(he=>he.length>0),fn=!1;if(Et.length>=40)for(let he=1;he<=15;he++){let c=Math.max(8,Math.ceil(25/he));if(Et.length<he*c)continue;let P=Et.slice(Et.length-he),V=P.join(" ");if(he>1&&V===P.slice(0,Math.floor(he/2)).join(" ").repeat(2).trim())continue;let ge=!0;for(let ie=1;ie<c;ie++)if(Et.slice(Et.length-he*(ie+1),Et.length-he*ie).join(" ")!==V){ge=!1;break}if(ge){fn=!0;break}}if(!fn){let he=An.toLowerCase().replace(Qa,"");if(he.length>=80)for(let c=1;c<=10;c++){let P=Math.max(15,Math.ceil(45/c));if(he.length<c*P)continue;let V=he.substring(he.length-c),ge=!0;for(let ie=1;ie<P;ie++)if(he.substring(he.length-c*(ie+1),he.length-c*ie)!==V){ge=!1;break}if(ge){fn=!0;break}}}if(fn){yield{type:"status",content:"Stuttering Detected. Re-centering..."},Lt=!1,Hn=!0,await new Promise(he=>setTimeout(he,3e3));break}}let q=Bt(fe),ut=fo(q);for(;ut.length>xt;){yield*Kn();let w=ut[xt],I=Date.now(),l={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"}[w.toolName]||w.toolName,Oe=ds[l]||w.toolName,J=Jn(l,w.args);yield{type:"status",content:`${Oe}${J?` ${J}`:""}`};let O="";if(l==="click"){let c=H(w.args);O=`\u2714 Clicked ${c.intendedClickText?`: ${c.intendedClickText}`:"Screen"}`}else if(l==="drag"){let c=H(w.args);O=`\u2714 Dragged: Cell ${c.fromGridId||""} \u2192 Cell ${c.toGridId||""}`}else if(l==="scroll"){let c=H(w.args);O=`\u2714 Scrolled: ${c.direction||"down"} (${c.amount||1})`}else if(l==="keyboard_typing"){let c=H(w.args);O=`\u2714 ${c.autoPressEnter?"Entered":"Typed"}: ${c.text?`"${c.text.length>20?c.text.substring(0,20)+"...":c.text}"`:""}`}else if(l==="key_press")O=`\u2714 Pressed Key: ${H(w.args).key||""}`;else if(l==="recapture_screen")O="\u2714 Recaptured Screen";else if(l==="web_search"){let{query:c,limit:P=10,aiMode:V=!1}=H(w.args);O=`${c?"\u2714":"\u2718"} ${V?"AI Search":"Searched"}: ${c?`${c}`:"No Search Query"}${V===!1&&c?` \u2192 ${P}`:""}`}else if(l==="web_scrape"){let c=H(w.args).url||null;O=`${c?"\u2714":"\u2718"} Visited: ${c||"No Source"}`}else if(l==="view_file"){let{path:c,StartLine:P,EndLine:V,start_line:ge,end_line:ie,startLine:ee,endLine:ye}=H(w.args),be=P||ge||ee,Q=V||ie||ye,U=parseInt(be)||1,X=parseInt(Q)||(be?U+800:800),Le="...",Ce=X,se=(c||"").trim().toLowerCase().replaceAll("\\","/");if(se.startsWith("#skill"))se.startsWith("#skill/global/fluxflow")||se.startsWith("#skills/global/fluxflow")||se.includes("#skill/fluxflow")||se.includes("#skills/fluxflow")?O="\u2714 Read Documentation":O=`\u2714 Read Skill: ${j.basename(c.replaceAll("\\","/"))}`;else{try{let me=j.resolve(process.cwd(),c);if(Se.existsSync(me)){let G=Se.readFileSync(me,"utf8").split(`
746
- `).length;Le=G,!be&&!Q&&G>800?Ce=Math.min(50,G):Ce=Math.min(X,G)}}catch{}let Ct=(c||"").toLowerCase(),Xt=Ct.endsWith(".pdf"),Ke=Ct.endsWith(".docx")||Ct.endsWith(".doc")||Ct.endsWith(".ppt")||Ct.endsWith(".pptx")||Ct.endsWith(".xls")||Ct.endsWith(".xlsx"),ze=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(Ct);Xt||Ke?O=`${c.length>0?"\u2714":"\u2718"} ${c?`Analyzed: ${j.basename(c)}`:"Analyzed: File Not Found"}`:ze?O=`${c.length>0?"\u2714":"\u2718"} ${c?`Processed: ${j.basename(c)}`:"Processed: File Not Found"}`:O=`${Le!=="..."?"\u2714":"\u2718"} Read: ${c?`${j.basename(c)} \u2192 ${Le!=="..."?`Lines ${U} - ${Ce} of ${Le}`:"File Not Found"}`:"File Not Found"}`}}else if(l==="list_files"||l==="read_folder"){let c=l==="list_files"?"List":"Browsed",P=H(w.args).path||null,V=H(w.args).recurse||1;O=`${P?"\u2714":"\u2718"} ${c}: ${P?`${P==="."?`./${V>1?"*":""}`:`${P.replaceAll("\\","/")}${V>1?`${P.endsWith("/")?"*":"/*"}`:`${P.endsWith("/")?"":"/"}`}`}`:"No Folder Selected"}`}else if(l==="find_file"){let c=H(w.args),P=c.basename||c.name||c.path||c.file||c.query||"";O=`${P?"\u2714":"\u2718"} Located: ${P||"No Query"}`}else if(l==="write_file"||l==="update_file"){let c=l==="write_file"?"Created":"Edited",P=H(w.args),V=P.path||null,ie=Object.entries(P).some(([ee,ye])=>ee.startsWith("searchContent")&&typeof ye=="string"&&ye.startsWith("^LINE:"))?"\u1361":":";O=`${V?"\u2714":"\u2718"} ${c}${ie} ${V?V.replaceAll("\\","/"):"No File Changes"}`}else if(l==="write_pdf"){let c=H(w.args).path||null;O=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No PDF Generated"}`}else if(l==="write_docx"){let c=H(w.args).path||null;O=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No Docx Generated"}`}else if(l==="file_map"){let c=H(w.args).path;O=`${c?"\u2714":"\u2718"} Indexed: ${c.replaceAll("\\","/")?""+c:"File Not Found"}`}else if(l.toLowerCase()==="search_keyword"||l.toLowerCase()==="todo")O="";else if(l.toLowerCase()==="generate_image"){let{path:c,outputPath:P,output:V}=H(w.args);O=`\u2714 Generated: ${c||P||V||"generated_image.png"}`}else if(l==="invoke_sync"||l==="InvokeSync"){let c=Jn(l,w.args);O=`\u2714 Called Generalist${c?`: ${c}`:""}`}else if(l==="Invoke"||l==="InvokeAsync"||l==="invoke"){let c=Jn(l,w.args);O=`\u2714 Started Generalist${c?`: ${c}`:""}`}else if(l==="get_progress"||l==="GetProgress"){let c=Jn(l,w.args);O=`\u2714 Checked${c?`: ${c}`:""}`}else if(l==="cancel"){let c=Jn(l,w.args);O=`\u{1F6C7} Cancelled${c?`: ${c}`:""}`}else if(l==="steer"||l==="Steer"){let c=Jn(l,w.args);O=`\u2714 Steered${c?`: ${c}`:""}`}else if(l==="EmergencyRollback"){let{method:c}=H(w.args);O=c==="forceRevert"?"":"\u2714 Rollback Point Checked"}else if(l==="await"||l==="Await"||l==="wait"||l==="Wait"){let{time:c,timeout:P,seconds:V,sec:ge}=H(w.args),ie=parseFloat(V||ge||P||c)||45,ee=l==="wait"||l==="Wait"?120:180;ie<10&&(ie=10),ie>ee&&(ie=ee);let ye=U=>{if(U>=60){let X=Math.floor(U/60),Le=U%60;return`${X}m${Le>0?` ${Le}s`:""}`}return`${U}s`},be=["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"];O=`\u2714 ${be[Math.floor(Math.random()*be.length)]} \u2192 ${ye(ie)}`}else l==="Answer"||l==="answer"?O="\u2714 Resolved Sub-Agent Query":l==="exec_command"||l==="ask"?O="":O=`Executed: ${w.toolName}`;if(yield*Kn(),l==="exec_command"){let{command:c}=H(w.args);if(c&&t.systemSettings&&t.systemSettings.allowExternalAccess===!1){let P=[/[a-zA-Z]:[\\\/]/i,/^\//,/\.\.[\\\/]/,/\/etc\//,/\/var\//,/\/root\//,/\/bin\//,/\/usr\//],V=j.resolve(process.cwd()).substring(0,3).toLowerCase(),ge=Q=>{let U=[],X="",Le=null;for(let Ce=0;Ce<Q.length;Ce++){let se=Q[Ce];Le?(se===Le&&(Le=null),X+=se):se==='"'||se==="'"?(Le=se,X+=se):se==="&"&&Q[Ce+1]==="&"||se==="|"&&Q[Ce+1]==="|"?(X.trim()&&(U.push(X.trim()),X=""),Ce++):se===";"||se==="|"||se==="&"?X.trim()&&(U.push(X.trim()),X=""):X+=se}return X.trim()&&U.push(X.trim()),U},ie=Q=>{let U=[],X="",Le=null;for(let Ce=0;Ce<Q.length;Ce++){let se=Q[Ce];Le?(se===Le&&(Le=null),X+=se):se==='"'||se==="'"?(Le=se,X+=se):/\s/.test(se)?X&&(U.push(X),X=""):X+=se}return X&&U.push(X),U},ee=Q=>{let U=Q.replace(/^['"]|['"]$/g,"").trim();return!U||process.platform==="win32"&&/^\/[a-zA-Z0-9?]+$/.test(U)?!1:P.some(X=>{if(X.source==="[a-zA-Z]:[\\\\\\/]"){let Le=U.match(/[a-zA-Z]:[\\\/]/i);return Le&&Le[0].toLowerCase()!==V}return X.test(U)})};if(ge(c).some(Q=>{let U=ie(Q);if(U.length===0)return!1;let X=U[0].replace(/^['"]|['"]$/g,"").toLowerCase();if(["echo","printf","write-output"].includes(X)){let Ce=!1;return U.some(se=>{let Mt=se.replace(/^['"]|['"]$/g,"");if(Mt===">"||Mt===">>"||Mt==="<")return Ce=!0,!1;if(Mt.startsWith(">")||Mt.startsWith("<")){let Ct=Mt.replace(/^[><]+/,"");return ee(Ct)}return Ce?(Ce=!1,ee(se)):!1})}return U.some(Ce=>ee(Ce))})){let Q='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(U=>setTimeout(U,50)),t.onExecChunk&&t.onExecChunk(`ERROR: ${Q}`),await new Promise(U=>setTimeout(U,50)),t.onExecEnd&&t.onExecEnd(),De.push({role:"user",text:`[ACTION RESULT]: ERROR: ${Q}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${Q}`},xt++;continue}}t.onExecStart&&t.onExecStart(c||"No Command"),yield{type:"exec_start"}}let gt=H(w.args),kn=gt.path||gt.targetPath||null;if(kn){let c=t.systemSettings&&t.systemSettings.allowExternalAccess===!1,P=j.resolve(kn),V=j.resolve(process.cwd());if(c&&!P.startsWith(V)){let ge="Access Denied. You are not allowed to access files outside the current workspace.";if(l==="write_file"||l==="update_file"){let ee=`\u2718 ${l==="write_file"?"Write Canceled":"Edit Canceled"}: ${gt.path||"..."}`,ye=115;process.stdout.isTTY&&(ye=process.stdout.columns-5||120);let be=Math.min(ee.length+4,ye),Q=`${ee.padEnd(be-2).substring(0,be-2)}`;yield{type:"visual_feedback",content:Ft(`${Ue?`
745
+ \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(v){if(rt){if(_e+=v,_e.length>=64){let w=0,I=Math.min(kt.length,_e.length);for(let l=I;l>=10;l--)if(kt.endsWith(_e.substring(0,l))){w=l;break}let te=_e.substring(w);if(te){let Oe=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(kt)?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(Oe)if(fe+=Oe,s==="Google")Dt+=Oe;else{yield*Kn();let J=ho(Oe);for(let O of J)yield O}}rt=!1,_e=""}continue}else if(fe+=v,s==="Google")Dt+=v;else{yield*Kn();let w=ho(v);for(let I of w)yield I}let B=fl(fe);if(B.inside){Jt=!0,gt||(gt=Date.now());let I={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"}[B.toolName]||B.toolName,te=B.args||"",l=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(I)){let J=j(te),O=J.basename||J.name||J.path||J.targetFile||J.TargetFile||J.directory||J.file,yt=J.keyword,An=J.title||J.task,Ft=J.id||J.taskId,ne=J.timeout||J.time||J.seconds||J.sec;if(yt!=null)l=String(yt).replace(vn,"");else if(O)l=K.basename(String(O).replace(vn,"").replace(Vr,"/"));else if(An&&(I==="invoke"||I==="invoke_sync"))l=String(An).replace(vn,"").substring(0,30);else if(Ft&&I==="get_progress")l=String(Ft).replace(vn,"");else if(ne&&I==="await"){let Ve=parseFloat(String(ne).replace(vn,""));isNaN(Ve)?l=String(ne).replace(vn,""):(Ve<5&&(Ve=5),Ve>120&&(Ve=180),l=(Bt=>{if(Bt>=60){let xo=Math.floor(Bt/60),En=Bt%60;return`${xo}m${En>0?` ${En}s`:""}`}return`${Bt}s`})(Ve))}else if(ne&&I==="wait"){let Ve=parseFloat(String(ne).replace(vn,""));isNaN(Ve)?l=String(ne).replace(vn,""):(Ve<10&&(Ve=10),Ve>120&&(Ve=120),l=(Bt=>{if(Bt>=60){let xo=Math.floor(Bt/60),En=Bt%60;return`${xo}m${En>0?` ${En}s`:""}`}return`${Bt}s`})(Ve))}else{let Ve=te.match(el);if(Ve){let xt=Ve[1].replace(vn,"");I==="invoke"||I==="invoke_sync"||I==="get_progress"?l=xt.substring(0,30):l=I==="search_keyword"||I==="file_map"?xt:K.basename(xt.replace(Vr,"/"))}}}let Oe=`${ds[I]||I}${l?` ${l}`:""}`;if((I!==$||l!==Ne)&&($=I,Ne=l,yield{type:"status",content:`${Oe}`},process.stdout.isTTY)){let O={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"}[I]||"Working";process.stdout.write(`\x1B]0;${O}...\x07`)}}if(fe.length-to>800){to=fe.length;let w=ea(fe,!1),I=cs(w),te=I?(I.innerContent||"").trim():"",l=te.split(/[.!?]\s+/).filter(he=>he.trim().length>10),Oe=new Set(l),J=l.length>25?(l.length-Oe.size)/l.length:0,O=te.split(/\s+/).filter(he=>he.length>0).length,yt=.9,An=.92,Ft=!1;if(s.toLowerCase().includes("google")&&(oe||"").toLowerCase().startsWith("gemma")){let c={low:2048,medium:4096,high:32768,max:65536,xhigh:65536}[d?.toLowerCase()]||16e3;Ft=O>c}if(J>yt||Ft){yield{type:"status",content:`${J>yt?"Reasoning Loop Detected":"Thinking Budget Exceeded"}. Re-centering...`},Nt=!0,await new Promise(c=>setTimeout(c,3e3));break}let xt=Xr(fe).trim().split(/[.!?]\s+/).filter(he=>he.trim().length>10),Bt=new Set(xt);if((xt.length>25?(xt.length-Bt.size)/xt.length:0)>An){yield{type:"status",content:"Response Loop Detected. Re-centering..."},Nt=!1,Kt=!0,await new Promise(he=>setTimeout(he,3e3));break}let En=w.replace(Ya,"").replace(za,"").replace(qa,"").replace(Xa,""),Ct=En.toLowerCase().split(/\s+/).map(he=>he.replace(Ja,"")).filter(he=>he.length>0),un=!1;if(Ct.length>=40)for(let he=1;he<=15;he++){let c=Math.max(8,Math.ceil(25/he));if(Ct.length<he*c)continue;let P=Ct.slice(Ct.length-he),Y=P.join(" ");if(he>1&&Y===P.slice(0,Math.floor(he/2)).join(" ").repeat(2).trim())continue;let ge=!0;for(let ie=1;ie<c;ie++)if(Ct.slice(Ct.length-he*(ie+1),Ct.length-he*ie).join(" ")!==Y){ge=!1;break}if(ge){un=!0;break}}if(!un){let he=En.toLowerCase().replace(Qa,"");if(he.length>=80)for(let c=1;c<=10;c++){let P=Math.max(15,Math.ceil(45/c));if(he.length<c*P)continue;let Y=he.substring(he.length-c),ge=!0;for(let ie=1;ie<P;ie++)if(he.substring(he.length-c*(ie+1),he.length-c*ie)!==Y){ge=!1;break}if(ge){un=!0;break}}}if(un){yield{type:"status",content:"Stuttering Detected. Re-centering..."},Nt=!1,Hn=!0,await new Promise(he=>setTimeout(he,3e3));break}}let q=Gt(fe),ht=Qn(q);for(;ht.length>Tt;){yield*Kn();let w=ht[Tt],I=Date.now(),l={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"}[w.toolName]||w.toolName,Oe=ds[l]||w.toolName,J=Jn(l,w.args);yield{type:"status",content:`${Oe}${J?` ${J}`:""}`};let O="";if(l==="click"){let c=j(w.args);O=`\u2714 Clicked ${c.intendedClickText?`: ${c.intendedClickText}`:"Screen"}`}else if(l==="drag"){let c=j(w.args);O=`\u2714 Dragged: Cell ${c.fromGridId||""} \u2192 Cell ${c.toGridId||""}`}else if(l==="scroll"){let c=j(w.args);O=`\u2714 Scrolled: ${c.direction||"down"} (${c.amount||1})`}else if(l==="keyboard_typing"){let c=j(w.args);O=`\u2714 ${c.autoPressEnter?"Entered":"Typed"}: ${c.text?`"${c.text.length>20?c.text.substring(0,20)+"...":c.text}"`:""}`}else if(l==="key_press")O=`\u2714 Pressed Key: ${j(w.args).key||""}`;else if(l==="recapture_screen")O="\u2714 Recaptured Screen";else if(l==="web_search"){let{query:c,limit:P=10,aiMode:Y=!1}=j(w.args);O=`${c?"\u2714":"\u2718"} ${Y?"AI Search":"Searched"}: ${c?`${c}`:"No Search Query"}${Y===!1&&c?` \u2192 ${P}`:""}`}else if(l==="web_scrape"){let c=j(w.args).url||null;O=`${c?"\u2714":"\u2718"} Visited: ${c||"No Source"}`}else if(l==="view_file"){let{path:c,StartLine:P,EndLine:Y,start_line:ge,end_line:ie,startLine:ee,endLine:ye}=j(w.args),be=P||ge||ee,Q=Y||ie||ye,U=parseInt(be)||1,X=parseInt(Q)||(be?U+800:800),Le="...",Ce=X,se=(c||"").trim().toLowerCase().replaceAll("\\","/");if(se.startsWith("#skill"))se.startsWith("#skill/global/fluxflow")||se.startsWith("#skills/global/fluxflow")||se.includes("#skill/fluxflow")||se.includes("#skills/fluxflow")?O="\u2714 Read Documentation":O=`\u2714 Read Skill: ${K.basename(c.replaceAll("\\","/"))}`;else{try{let me=K.resolve(process.cwd(),c);if(Se.existsSync(me)){let H=Se.readFileSync(me,"utf8").split(`
746
+ `).length;Le=H,!be&&!Q&&H>800?Ce=Math.min(50,H):Ce=Math.min(X,H)}}catch{}let Rt=(c||"").toLowerCase(),Qt=Rt.endsWith(".pdf"),Ye=Rt.endsWith(".docx")||Rt.endsWith(".doc")||Rt.endsWith(".ppt")||Rt.endsWith(".pptx")||Rt.endsWith(".xls")||Rt.endsWith(".xlsx"),qe=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(Rt);Qt||Ye?O=`${c.length>0?"\u2714":"\u2718"} ${c?`Analyzed: ${K.basename(c)}`:"Analyzed: File Not Found"}`:qe?O=`${c.length>0?"\u2714":"\u2718"} ${c?`Processed: ${K.basename(c)}`:"Processed: File Not Found"}`:O=`${Le!=="..."?"\u2714":"\u2718"} Read: ${c?`${K.basename(c)} \u2192 ${Le!=="..."?`Lines ${U} - ${Ce} of ${Le}`:"File Not Found"}`:"File Not Found"}`}}else if(l==="list_files"||l==="read_folder"){let c=l==="list_files"?"List":"Browsed",P=j(w.args).path||null,Y=j(w.args).recurse||1;O=`${P?"\u2714":"\u2718"} ${c}: ${P?`${P==="."?`./${Y>1?"*":""}`:`${P.replaceAll("\\","/")}${Y>1?`${P.endsWith("/")?"*":"/*"}`:`${P.endsWith("/")?"":"/"}`}`}`:"No Folder Selected"}`}else if(l==="find_file"){let c=j(w.args),P=c.basename||c.name||c.path||c.file||c.query||"";O=`${P?"\u2714":"\u2718"} Located: ${P||"No Query"}`}else if(l==="write_file"||l==="update_file"){let c=l==="write_file"?"Created":"Edited",P=j(w.args),Y=P.path||null,ie=Object.entries(P).some(([ee,ye])=>ee.startsWith("searchContent")&&typeof ye=="string"&&ye.startsWith("^LINE:"))?"\u1361":":";O=`${Y?"\u2714":"\u2718"} ${c}${ie} ${Y?Y.replaceAll("\\","/"):"No File Changes"}`}else if(l==="write_pdf"){let c=j(w.args).path||null;O=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No PDF Generated"}`}else if(l==="write_docx"){let c=j(w.args).path||null;O=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No Docx Generated"}`}else if(l==="file_map"){let c=j(w.args).path;O=`${c?"\u2714":"\u2718"} Indexed: ${c.replaceAll("\\","/")?""+c:"File Not Found"}`}else if(l.toLowerCase()==="search_keyword"||l.toLowerCase()==="todo")O="";else if(l.toLowerCase()==="generate_image"){let{path:c,outputPath:P,output:Y}=j(w.args);O=`\u2714 Generated: ${c||P||Y||"generated_image.png"}`}else if(l==="invoke_sync"||l==="InvokeSync"){let c=Jn(l,w.args);O=`\u2714 Called Generalist${c?`: ${c}`:""}`}else if(l==="Invoke"||l==="InvokeAsync"||l==="invoke"){let c=Jn(l,w.args);O=`\u2714 Started Generalist${c?`: ${c}`:""}`}else if(l==="get_progress"||l==="GetProgress"){let c=Jn(l,w.args);O=`\u2714 Checked${c?`: ${c}`:""}`}else if(l==="cancel"){let c=Jn(l,w.args);O=`\u{1F6C7} Cancelled${c?`: ${c}`:""}`}else if(l==="steer"||l==="Steer"){let c=Jn(l,w.args);O=`\u2714 Steered${c?`: ${c}`:""}`}else if(l==="EmergencyRollback"){let{method:c}=j(w.args);O=c==="forceRevert"?"":"\u2714 Rollback Point Checked"}else if(l==="await"||l==="Await"||l==="wait"||l==="Wait"){let{time:c,timeout:P,seconds:Y,sec:ge}=j(w.args),ie=parseFloat(Y||ge||P||c)||45,ee=l==="wait"||l==="Wait"?120:180;ie<10&&(ie=10),ie>ee&&(ie=ee);let ye=U=>{if(U>=60){let X=Math.floor(U/60),Le=U%60;return`${X}m${Le>0?` ${Le}s`:""}`}return`${U}s`},be=["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"];O=`\u2714 ${be[Math.floor(Math.random()*be.length)]} \u2192 ${ye(ie)}`}else l==="Answer"||l==="answer"?O="\u2714 Resolved Sub-Agent Query":l==="exec_command"||l==="ask"?O="":O=`Executed: ${w.toolName}`;if(yield*Kn(),l==="exec_command"){let{command:c}=j(w.args);if(c&&t.systemSettings&&t.systemSettings.allowExternalAccess===!1){let P=[/[a-zA-Z]:[\\\/]/i,/^\//,/\.\.[\\\/]/,/\/etc\//,/\/var\//,/\/root\//,/\/bin\//,/\/usr\//],Y=K.resolve(process.cwd()).substring(0,3).toLowerCase(),ge=Q=>{let U=[],X="",Le=null;for(let Ce=0;Ce<Q.length;Ce++){let se=Q[Ce];Le?(se===Le&&(Le=null),X+=se):se==='"'||se==="'"?(Le=se,X+=se):se==="&"&&Q[Ce+1]==="&"||se==="|"&&Q[Ce+1]==="|"?(X.trim()&&(U.push(X.trim()),X=""),Ce++):se===";"||se==="|"||se==="&"?X.trim()&&(U.push(X.trim()),X=""):X+=se}return X.trim()&&U.push(X.trim()),U},ie=Q=>{let U=[],X="",Le=null;for(let Ce=0;Ce<Q.length;Ce++){let se=Q[Ce];Le?(se===Le&&(Le=null),X+=se):se==='"'||se==="'"?(Le=se,X+=se):/\s/.test(se)?X&&(U.push(X),X=""):X+=se}return X&&U.push(X),U},ee=Q=>{let U=Q.replace(/^['"]|['"]$/g,"").trim();return!U||process.platform==="win32"&&/^\/[a-zA-Z0-9?]+$/.test(U)?!1:P.some(X=>{if(X.source==="[a-zA-Z]:[\\\\\\/]"){let Le=U.match(/[a-zA-Z]:[\\\/]/i);return Le&&Le[0].toLowerCase()!==Y}return X.test(U)})};if(ge(c).some(Q=>{let U=ie(Q);if(U.length===0)return!1;let X=U[0].replace(/^['"]|['"]$/g,"").toLowerCase();if(["echo","printf","write-output"].includes(X)){let Ce=!1;return U.some(se=>{let Ot=se.replace(/^['"]|['"]$/g,"");if(Ot===">"||Ot===">>"||Ot==="<")return Ce=!0,!1;if(Ot.startsWith(">")||Ot.startsWith("<")){let Rt=Ot.replace(/^[><]+/,"");return ee(Rt)}return Ce?(Ce=!1,ee(se)):!1})}return U.some(Ce=>ee(Ce))})){let Q='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(U=>setTimeout(U,50)),t.onExecChunk&&t.onExecChunk(`ERROR: ${Q}`),await new Promise(U=>setTimeout(U,50)),t.onExecEnd&&t.onExecEnd(),Be.push({role:"user",text:`[ACTION RESULT]: ERROR: ${Q}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${Q}`},Tt++;continue}}t.onExecStart&&t.onExecStart(c||"No Command"),yield{type:"exec_start"}}let yt=j(w.args),An=yt.path||yt.targetPath||null;if(An){let c=t.systemSettings&&t.systemSettings.allowExternalAccess===!1,P=K.resolve(An),Y=K.resolve(process.cwd());if(c&&!P.startsWith(Y)){let ge="Access Denied. You are not allowed to access files outside the current workspace.";if(l==="write_file"||l==="update_file"){let ee=`\u2718 ${l==="write_file"?"Write Canceled":"Edit Canceled"}: ${yt.path||"..."}`,ye=115;process.stdout.isTTY&&(ye=process.stdout.columns-5||120);let be=Math.min(ee.length+4,ye),Q=`${ee.padEnd(be-2).substring(0,be-2)}`;yield{type:"visual_feedback",content:Wt(`${Ue?`
747
747
  `:""}${Q}
748
- `)},Ue=!1}De.push({role:"user",text:`[ACTION RESULT]: ERROR: ${ge}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${ge}`},xt++;continue}}if(t.onToolApproval){let c=t.systemSettings||{},P=c.autoExec,V=!1,ge="";if(l==="view_file"){let ee=H(w.args);if(ge=ee.path||ee.targetPath||ee.file||"",ge){let ye=c.alwaysAskFiles||".env, .env.*, *.env";As(ge,ye)&&(V=!0)}}if(l==="write_file"||l==="update_file"||l==="exec_command"||V){let ee=null,ye=!1,be=!1,Q=!1;if(V)ye=!0,ee=null;else if(l==="exec_command"){let{command:Ke}=H(w.args),ze=(Ke||"").trim(),me=(Jt,Ht)=>{if(!Ht)return!1;let on=Ht.split(",").map(jt=>jt.trim().toLowerCase()).filter(Boolean),et=Jt.toLowerCase();return on.some(jt=>et.startsWith(jt))},Ge=me(ze,c.alwaysAskCommands),G=me(ze,c.autoApproveCommands);if(be=me(ze,c.autoDisallowCommands),Ge?ye=!0:(G||c.autoApproveGit&&/^git\s+commit\b/i.test(ze))&&(ee="allow"),!ye&&!ee){if(c.networkAccess===!1){let Ht=ze.trim().replace(/\s+/g," ").replace(/^['"]+|['"]+$/g,"").toLowerCase().split(" "),et=Ht[0].split("/").pop().split("\\").pop().replace(/\.exe$/,""),jt=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"]),tt=!1;jt.has(et)&&(tt=!0);let qe=On=>Ht.slice(1).some(En=>On.includes(En)),st=On=>{let En=Ht.findIndex(Cn=>On.includes(Cn)),Yn=Ht.findIndex(Cn=>["run","exec","test"].includes(Cn));return En!==-1&&!(Yn!==-1&&Yn<En)};et==="git"&&qe(["clone","pull","push","fetch"])&&(tt=!0),et==="go"&&qe(["get","install"])&&(tt=!0),et==="npm"&&st(["install","i","update","add"])&&(tt=!0),et==="yarn"&&st(["add","install","upgrade"])&&(tt=!0),et==="pnpm"&&st(["add","install","update"])&&(tt=!0),et==="bun"&&st(["add","install","update"])&&(tt=!0),et==="deno"&&qe(["install","add"])&&(tt=!0),et==="pip"&&qe(["install","download"])&&(tt=!0),et==="pip3"&&qe(["install","download"])&&(tt=!0),et==="cargo"&&qe(["install","add"])&&(tt=!0),["bash","sh","zsh","fish"].includes(et)&&qe(["-c"])&&(tt=!0),et==="cmd"&&qe(["/c"])&&(tt=!0),tt&&(ee="deny",Q=!0)}!ee&&be&&(ee="deny")}!ye&&!ee&&P&&(ee="allow")}else(l==="write_file"||l==="update_file")&&P&&(ee="allow");let U=ee,X="";ee==="deny"&&(Q?X="network":be?X="settings":X="prohibited");let Le=!1,Ce="",se=[],Mt=0,Ct=!1,Xt="";if(!U){if(l==="write_file"||l==="update_file")try{let me=H(w.args),{path:Ge}=me;if(Ge){let G=j.resolve(process.cwd(),Ge),Jt=qe=>qe?qe.toLowerCase().replace(/\\/g,"/").replace(/^[a-z]:/,st=>st.toUpperCase()):"",Ht=Jt(G),on="",et=!1,jt=await qn(),tt=Jt(jt?.file_focused);if(jt&&tt===Ht&&jt.full_content?(on=jt.full_content,et=!0):Se.existsSync(G)&&(on=Se.readFileSync(G,"utf8"),et=!0),Ce=on,await ei.recordFileChange(G,on),et){let qe=on;if(l==="write_file"){let st=me.content||me.newContent||"";qe=st.endsWith(`
749
- `)?st:st+`
750
- `,Xt=qe}else{let{patchPairs:st,allowMultiple:On,error:En}=Li(me);if(En){let Qt=`[ACTION RESULT]: ERROR: ${En}`;De.push({role:"user",text:Qt}),await _t("toolFailure"),t.onToolResult&&t.onToolResult("failure",l),yield{type:"tool_result",content:Qt,toolName:l},xt++;continue}let Yn=me.allowMultiple!==void 0?me.allowMultiple===!0||String(me.allowMultiple).toLowerCase()==="true":On;Mt=st.length;let Cn=Cs(on,st,{allowMultiple:Yn});qe=Cn.content,Xt=qe,se=Cn.results;let Yo=se.filter(Qt=>Qt.success),Ei=se.filter(Qt=>!Qt.success);if(Yo.length===0){let Qt=`[ACTION RESULT]: ERROR: Failed to apply patches to [${j.basename(G)}].
751
- ${Ei.map(Xe=>` \u2022 ${Xe.error}`).join(`
752
- `)}`,Ci=`\u2714 Edited: ${j.basename(G.replaceAll("\\","/"))}`,sn=115;process.stdout.isTTY&&(sn=process.stdout.columns-5||120);let Ln=Math.min(Ci.length+4,sn),nt=`${Ci.padEnd(Ln-2).substring(0,Ln-2)}`;yield{type:"visual_feedback",content:Ft(`${Ue?`
753
- `:""}${nt}`)},Ue=!1,De.push({role:"user",text:Qt}),await _t("toolFailure"),t.onToolResult&&t.onToolResult("failure",l),yield{type:"tool_result",content:Qt,toolName:l},xt++;continue}}yield{type:"status",content:`Opening Diff in IDE: ${j.basename(G)}`},Gi(G,on,qe),Le=!0,await new Promise(st=>setTimeout(st,50))}else if(l==="write_file"){let qe=me.content||me.newContent||"",st=qe.endsWith(`
754
- `)?qe:qe+`
755
- `;Xt=st,Se.existsSync(G)||(Ct=!0,Se.mkdirSync(j.dirname(G),{recursive:!0}),Se.writeFileSync(G,"","utf8")),yield{type:"status",content:`Opening New File Diff in IDE: ${j.basename(G)}`},Gi(G,"",st),Le=!0,await new Promise(On=>setTimeout(On,50))}}}catch(me){console.error("Simulation/Diff Error:",me)}let Ke=null;Wi(me=>{Ke=me});let ze=t.onToolApproval;if(U=await new Promise(async me=>{let Ge=setInterval(()=>{if(Ke){let G=t.onIDEApproval||Uo&&Uo.onIDEApproval;G&&G(Ke),clearInterval(Ge),me(Ke)}},100);try{let G=await ze(l,w.args);clearInterval(Ge),me(G)}catch{clearInterval(Ge),me("deny")}}),Wi(null),l==="write_file"||l==="update_file"){let{path:me}=H(w.args);if(me){let Ge=j.resolve(process.cwd(),me);if(Qs(Ge,U),U==="deny"&&Ct&&Se.existsSync(Ge))try{Se.unlinkSync(Ge)}catch{}}}U==="deny"&&(X="user")}if(U==="allow"&&Le&&lo()){let{path:Ke}=H(w.args),ze=j.resolve(process.cwd(),Ke),me=nt=>nt?j.resolve(nt).replace(/\\/g,"/").toLowerCase():"",Ge=await qn(),G="";if(Ge&&Ge.file_focused&&me(Ge.file_focused)===me(ze)&&Ge.full_content&&(G=Ge.full_content),!G&&Se.existsSync(ze)){let nt=Se.readFileSync(ze,"utf8");nt&&(G=nt)}!G&&Xt&&(G=Xt),(G||Ct)&&Se.writeFileSync(ze,G,"utf8");let Jt=G.split(/\r?\n/),Ht=Jt.length,on=Buffer.byteLength(G,"utf8"),et="";Ce&&(et=`Old File contents:
756
- ${Ce.split(/\r?\n/).map((Xe,rn)=>`${rn+1} | ${Xe}`).join(`
748
+ `)},Ue=!1}Be.push({role:"user",text:`[ACTION RESULT]: ERROR: ${ge}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${ge}`},Tt++;continue}}if(t.onToolApproval){let c=t.systemSettings||{},P=c.autoExec,Y=!1,ge="";if(l==="view_file"){let ee=j(w.args);if(ge=ee.path||ee.targetPath||ee.file||"",ge){let ye=c.alwaysAskFiles||".env, .env.*, *.env";Es(ge,ye)&&(Y=!0)}}if(l==="write_file"||l==="update_file"||l==="exec_command"||Y){let ee=null,ye=!1,be=!1,Q=!1;if(Y)ye=!0,ee=null;else if(l==="exec_command"){let{command:Ye}=j(w.args),qe=(Ye||"").trim(),me=(Zt,Vt)=>{if(!Vt)return!1;let sn=Vt.split(",").map(Yt=>Yt.trim().toLowerCase()).filter(Boolean),nt=Zt.toLowerCase();return sn.some(Yt=>nt.startsWith(Yt))},je=me(qe,c.alwaysAskCommands),H=me(qe,c.autoApproveCommands);if(be=me(qe,c.autoDisallowCommands),je?ye=!0:(H||c.autoApproveGit&&/^git\s+commit\b/i.test(qe))&&(ee="allow"),!ye&&!ee){if(c.networkAccess===!1){let Vt=qe.trim().replace(/\s+/g," ").replace(/^['"]+|['"]+$/g,"").toLowerCase().split(" "),nt=Vt[0].split("/").pop().split("\\").pop().replace(/\.exe$/,""),Yt=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"]),ot=!1;Yt.has(nt)&&(ot=!0);let Xe=On=>Vt.slice(1).some(Cn=>On.includes(Cn)),lt=On=>{let Cn=Vt.findIndex(Rn=>On.includes(Rn)),Yn=Vt.findIndex(Rn=>["run","exec","test"].includes(Rn));return Cn!==-1&&!(Yn!==-1&&Yn<Cn)};nt==="git"&&Xe(["clone","pull","push","fetch"])&&(ot=!0),nt==="go"&&Xe(["get","install"])&&(ot=!0),nt==="npm"&&lt(["install","i","update","add"])&&(ot=!0),nt==="yarn"&&lt(["add","install","upgrade"])&&(ot=!0),nt==="pnpm"&&lt(["add","install","update"])&&(ot=!0),nt==="bun"&&lt(["add","install","update"])&&(ot=!0),nt==="deno"&&Xe(["install","add"])&&(ot=!0),nt==="pip"&&Xe(["install","download"])&&(ot=!0),nt==="pip3"&&Xe(["install","download"])&&(ot=!0),nt==="cargo"&&Xe(["install","add"])&&(ot=!0),["bash","sh","zsh","fish"].includes(nt)&&Xe(["-c"])&&(ot=!0),nt==="cmd"&&Xe(["/c"])&&(ot=!0),ot&&(ee="deny",Q=!0)}!ee&&be&&(ee="deny")}!ye&&!ee&&P&&(ee="allow")}else(l==="write_file"||l==="update_file")&&P&&(ee="allow");let U=ee,X="";ee==="deny"&&(Q?X="network":be?X="settings":X="prohibited");let Le=!1,Ce="",se=[],Ot=0,Rt=!1,Qt="";if(!U){if(l==="write_file"||l==="update_file")try{let me=j(w.args),{path:je}=me;if(je){let H=K.resolve(process.cwd(),je),Zt=Xe=>Xe?Xe.toLowerCase().replace(/\\/g,"/").replace(/^[a-z]:/,lt=>lt.toUpperCase()):"",Vt=Zt(H),sn="",nt=!1,Yt=await qn(),ot=Zt(Yt?.file_focused);if(Yt&&ot===Vt&&Yt.full_content?(sn=Yt.full_content,nt=!0):Se.existsSync(H)&&(sn=Se.readFileSync(H,"utf8"),nt=!0),Ce=sn,await ti.recordFileChange(H,sn),nt){let Xe=sn;if(l==="write_file"){let lt=me.content||me.newContent||"";Xe=lt.endsWith(`
749
+ `)?lt:lt+`
750
+ `,Qt=Xe}else{let{patchPairs:lt,allowMultiple:On,error:Cn}=Li(me);if(Cn){let en=`[ACTION RESULT]: ERROR: ${Cn}`;Be.push({role:"user",text:en}),await vt("toolFailure"),t.onToolResult&&t.onToolResult("failure",l),yield{type:"tool_result",content:en,toolName:l},Tt++;continue}let Yn=me.allowMultiple!==void 0?me.allowMultiple===!0||String(me.allowMultiple).toLowerCase()==="true":On;Ot=lt.length;let Rn=Rs(sn,lt,{allowMultiple:Yn});Xe=Rn.content,Qt=Xe,se=Rn.results;let zo=se.filter(en=>en.success),Ei=se.filter(en=>!en.success);if(zo.length===0){let en=`[ACTION RESULT]: ERROR: Failed to apply patches to [${K.basename(H)}].
751
+ ${Ei.map(Je=>` \u2022 ${Je.error}`).join(`
752
+ `)}`,Ci=`\u2714 Edited: ${K.basename(H.replaceAll("\\","/"))}`,rn=115;process.stdout.isTTY&&(rn=process.stdout.columns-5||120);let Ln=Math.min(Ci.length+4,rn),it=`${Ci.padEnd(Ln-2).substring(0,Ln-2)}`;yield{type:"visual_feedback",content:Wt(`${Ue?`
753
+ `:""}${it}`)},Ue=!1,Be.push({role:"user",text:en}),await vt("toolFailure"),t.onToolResult&&t.onToolResult("failure",l),yield{type:"tool_result",content:en,toolName:l},Tt++;continue}}yield{type:"status",content:`Opening Diff in IDE: ${K.basename(H)}`},Gi(H,sn,Xe),Le=!0,await new Promise(lt=>setTimeout(lt,50))}else if(l==="write_file"){let Xe=me.content||me.newContent||"",lt=Xe.endsWith(`
754
+ `)?Xe:Xe+`
755
+ `;Qt=lt,Se.existsSync(H)||(Rt=!0,Se.mkdirSync(K.dirname(H),{recursive:!0}),Se.writeFileSync(H,"","utf8")),yield{type:"status",content:`Opening New File Diff in IDE: ${K.basename(H)}`},Gi(H,"",lt),Le=!0,await new Promise(On=>setTimeout(On,50))}}}catch(me){console.error("Simulation/Diff Error:",me)}let Ye=null;Wi(me=>{Ye=me});let qe=t.onToolApproval;if(U=await new Promise(async me=>{let je=setInterval(()=>{if(Ye){let H=t.onIDEApproval||Wo&&Wo.onIDEApproval;H&&H(Ye),clearInterval(je),me(Ye)}},100);try{let H=await qe(l,w.args);clearInterval(je),me(H)}catch{clearInterval(je),me("deny")}}),Wi(null),l==="write_file"||l==="update_file"){let{path:me}=j(w.args);if(me){let je=K.resolve(process.cwd(),me);if(Zs(je,U),U==="deny"&&Rt&&Se.existsSync(je))try{Se.unlinkSync(je)}catch{}}}U==="deny"&&(X="user")}if(U==="allow"&&Le&&fo()){let{path:Ye}=j(w.args),qe=K.resolve(process.cwd(),Ye),me=it=>it?K.resolve(it).replace(/\\/g,"/").toLowerCase():"",je=await qn(),H="";if(je&&je.file_focused&&me(je.file_focused)===me(qe)&&je.full_content&&(H=je.full_content),!H&&Se.existsSync(qe)){let it=Se.readFileSync(qe,"utf8");it&&(H=it)}!H&&Qt&&(H=Qt),(H||Rt)&&Se.writeFileSync(qe,H,"utf8");let Zt=H.split(/\r?\n/),Vt=Zt.length,sn=Buffer.byteLength(H,"utf8"),nt="";Ce&&(nt=`Old File contents:
756
+ ${Ce.split(/\r?\n/).map((Je,an)=>`${an+1} | ${Je}`).join(`
757
757
  `)}
758
758
 
759
- `);let jt="";if(Ht<=100)jt=Jt.join(`
760
- `);else{let nt=Jt.slice(0,50).join(`
761
- `),Xe=Jt.slice(-50).join(`
762
- `);jt=`${nt}
759
+ `);let Yt="";if(Vt<=100)Yt=Zt.join(`
760
+ `);else{let it=Zt.slice(0,50).join(`
761
+ `),Je=Zt.slice(-50).join(`
762
+ `);Yt=`${it}
763
763
 
764
- ... [${Ht-100} lines truncated for history stability] ...
764
+ ... [${Vt-100} lines truncated for history stability] ...
765
765
 
766
- ${Xe}`}let tt="";if(l==="update_file"){let nt=Rs(Ce,G,se,12,t?.compressToolResults||Uo?.systemSettings?.compressToolResults),{patchPairs:Xe}=Li(H(w.args)),rn=Xe?.length||Mt||1,$n=0,Kt=0,oo=[];Xe&&Xe.length>0?Xe.forEach((io,Ri)=>{let zo=io.replace||"",an=io.new||"",_i=zo.trim(),bo=an.trim(),wa=!!Xt&&G===Xt,Sa=bo?G.includes(an)||G.includes(bo):!0,Ta=an?Ce.includes(an)||!!bo&&Ce.includes(bo):!1,ka=_i?G.includes(zo)||G.includes(_i):!1;wa||!!an&&Sa&&(!Ta||!ka||_i===bo)?$n++:(Kt++,oo.push(` \u2022 Block ${Ri+1}: not applied (reverted or rejected in IDE).`))}):$n=Mt||0;let Nn=0;if(Xt&&G!==Xt){let io=Ka("","",Xt||"",G||"","","",{context:0});if(io&&io.hunks)for(let Ri of io.hunks){let zo=Ri.lines.filter(an=>an.startsWith("+")).map(an=>an.slice(1).trim()).filter(Boolean);for(let an of zo)Ce.includes(an)||Nn++}}let xo=[`[${$n}/${rn}] applied`];Kt>0&&xo.push(`${Kt} rejected by user`),Nn>0&&xo.push(`${Nn} manual ${Nn===1?"modification":"modifications"} by user`);let xa=xo.join(", "),ba=oo.length>0?`
766
+ ${Je}`}let ot="";if(l==="update_file"){let it=_s(Ce,H,se,12,t?.compressToolResults||Wo?.systemSettings?.compressToolResults),{patchPairs:Je}=Li(j(w.args)),an=Je?.length||Ot||1,$n=0,zt=0,so=[];Je&&Je.length>0?Je.forEach((ro,Ri)=>{let qo=ro.replace||"",ln=ro.new||"",_i=qo.trim(),wo=ln.trim(),wa=!!Qt&&H===Qt,Sa=wo?H.includes(ln)||H.includes(wo):!0,Ta=ln?Ce.includes(ln)||!!wo&&Ce.includes(wo):!1,ka=_i?H.includes(qo)||H.includes(_i):!1;wa||!!ln&&Sa&&(!Ta||!ka||_i===wo)?$n++:(zt++,so.push(` \u2022 Block ${Ri+1}: not applied (reverted or rejected in IDE).`))}):$n=Ot||0;let Nn=0;if(Qt&&H!==Qt){let ro=Ka("","",Qt||"",H||"","","",{context:0});if(ro&&ro.hunks)for(let Ri of ro.hunks){let qo=Ri.lines.filter(ln=>ln.startsWith("+")).map(ln=>ln.slice(1).trim()).filter(Boolean);for(let ln of qo)Ce.includes(ln)||Nn++}}let bo=[`[${$n}/${an}] applied`];zt>0&&bo.push(`${zt} rejected by user`),Nn>0&&bo.push(`${Nn} manual ${Nn===1?"modification":"modifications"} by user`);let xa=bo.join(", "),ba=so.length>0?`
767
767
 
768
768
  User Review Details:
769
- ${oo.join(`
770
- `)}`:"";tt=`File [${Ke}] updated via IDE Companion. ${xa}.${ba}
769
+ ${so.join(`
770
+ `)}`:"";ot=`File [${Ye}] updated via IDE Companion. ${xa}.${ba}
771
771
 
772
- ${nt}`}else{let nt=G.split(/\r?\n/),Xe=nt.length,rn=Buffer.byteLength(G,"utf8"),$n="";Ce&&($n=`Old File contents:
773
- ${Ce.split(/\r?\n/).map((Nn,xo)=>`${xo+1} | ${Nn}`).join(`
772
+ ${it}`}else{let it=H.split(/\r?\n/),Je=it.length,an=Buffer.byteLength(H,"utf8"),$n="";Ce&&($n=`Old File contents:
773
+ ${Ce.split(/\r?\n/).map((Nn,bo)=>`${bo+1} | ${Nn}`).join(`
774
774
  `)}
775
775
 
776
- `);let Kt="";if(Xe<=100)Kt=nt.join(`
777
- `);else{let oo=nt.slice(0,50).join(`
778
- `),Nn=nt.slice(-50).join(`
779
- `);Kt=`${oo}
776
+ `);let zt="";if(Je<=100)zt=it.join(`
777
+ `);else{let so=it.slice(0,50).join(`
778
+ `),Nn=it.slice(-50).join(`
779
+ `);zt=`${so}
780
780
 
781
- ... [${Xe-100} lines truncated] ...
781
+ ... [${Je-100} lines truncated] ...
782
782
 
783
- ${Nn}`}tt=`File [${Ke}] saved via IDE Companion (May have user edits).
784
- - Stats: [${Xe} lines, ${(rn/1024).toFixed(1)} KB]
783
+ ${Nn}`}ot=`File [${Ye}] saved via IDE Companion (May have user edits).
784
+ - Stats: [${Je} lines, ${(an/1024).toFixed(1)} KB]
785
785
  ${$n}- Content Preview:
786
786
 
787
- ${Kt}`}let qe=l==="write_file"?"Created":"Edited",st=H(w.args),En=Object.entries(st).some(([nt,Xe])=>nt.startsWith("searchContent")&&typeof Xe=="string"&&Xe.startsWith("^LINE:"))?"\u1361":":",Yn=`${Ke?"\u2714":"\u2718"} ${qe}${En} ${Ke?Ke.replaceAll("\\","/"):"No File Changes"}`,Cn=115;process.stdout.isTTY&&(Cn=process.stdout.columns-5||120);let Yo=Math.min(Yn.length+4,Cn),Ei=`${Yn.padEnd(Yo-2).substring(0,Yo-2)}`;yield{type:"visual_feedback",content:Ft(`${Ue?`
788
- `:""}${Ei}`)},Ue=!1;let Qt=Date.now();en=Qt,yield{type:"tool_time",content:Qt-I};let sn=(tt||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");sn.includes("[[VERIFIED]]")&&(sn=sn.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to conserve context.
789
- `));let Ln;if(l==="write_file"&&!sn.startsWith("ERROR:")){let Xe=sn.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),rn=Xe.filter(Kt=>Kt.startsWith("File ")||Kt.trim().startsWith("- Stats:"));Ln=`[ACTION RESULT]: ${rn.length>0?rn.join(`
790
- `):Xe.slice(0,2).join(`
791
- `)}`}else if(sn.startsWith("[[SAME]]")){let Xe=sn.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),rn=Xe.filter(Kt=>Kt.startsWith("File ")||Kt.trim().startsWith("- Stats:"));Ln=`[ACTION RESULT]: ${rn.length>0?rn.join(`
792
- `):Xe.slice(0,2).join(`
793
- `)}`}else Ln=`[ACTION RESULT]: ${sn}`;De.push({role:"user",text:Ln}),Sn=!0,await _t("toolSuccess"),t.onToolResult&&t.onToolResult("success",l),yield{type:"tool_result",content:tt,aiContent:Ln,toolName:l},xt++;continue}if(U==="deny"){let Ke=`Permission Denied: Prohibited ${l==="exec_command"?"Command":"file edit"}.`;if(V?Ke=`User denied reading ${j.basename(ge||".env")}`:X==="user"?Ke="Permission Denied by User":X==="settings"?Ke="Permission Denied by User Policy":X==="network"?Ke="Permission Denied: Sandbox Network Access Disabled by User Policy.":X==="prohibited"&&l==="exec_command"&&(Ke="Permission Denied: Prohibited Command in User Policy"),l==="view_file"){let ze=`\u2718 Read Denied: ${H(w.args).path?.replaceAll("\\","/")||".env"}`,me=115;process.stdout.isTTY&&(me=process.stdout.columns-5||120);let Ge=Math.min(ze.length+4,me),G=`${ze.padEnd(Ge-2).substring(0,Ge-2)}`;yield{type:"visual_feedback",content:Ft(`${Ue?`
794
- `:""}${G}
795
- `)},Ue=!1}else if(l==="write_file"||l==="update_file"){let me=`\u2718 ${l==="write_file"?"Write Cancelled":"Edit Denied"}: ${H(w.args).path.replaceAll("\\","/")||"..."}`,Ge=115;process.stdout.isTTY&&(Ge=process.stdout.columns-5||120);let G=Math.min(me.length+4,Ge),Jt=`${me.padEnd(G-2).substring(0,G-2)}`,Ht=` ${" ".repeat(G)} `;yield{type:"visual_feedback",content:Ft(`${Ue?`
796
- `:""}${Jt}
797
- `)},Ue=!1}l==="exec_command"&&(await new Promise(ze=>setTimeout(ze,50)),t.onExecChunk&&t.onExecChunk(`ERROR: ${Ke}`),await new Promise(ze=>setTimeout(ze,50)),t.onExecEnd&&t.onExecEnd()),De.push({role:"user",text:`[ACTION RESULT]: DENIED: ${Ke}`}),yield{type:"tool_result",content:`[ACTION RESULT]: DENIED: ${Ke}`},await _t("toolDenied"),t.onToolResult&&t.onToolResult("denied",l),xt++;continue}}}if(O){let c=115;process.stdout.isTTY&&(c=process.stdout.columns-5||120);let P=await i(),V=!1;P&&(V=P.trim().length>0);let ge=Math.min(O.length+4,c),ie=`${O.padEnd(ge-2).substring(0,ge-2)}`;yield{type:"visual_feedback",content:Ft(`${Ue?`
798
- `:""}${ie}${O.includes("\u2714")&&(O.includes("Created")||O.includes("Edited"))?"":`${V?"":`
799
- `}`}`)},Ue=!1}if(en>0){let c=Date.now()-en,P=Math.max(0,1e3-c);P>0&&await new Promise(V=>setTimeout(V,P))}let $t={chatId:p,history:n,onChunk:c=>t.onExecChunk?t.onExecChunk(c):null,onAskUser:t.onAskUser,systemSettings:t.systemSettings,mode:a,isMultiModal:rt(oe),onVisualFeedback:t.onVisualFeedback,onSubagentUpdate:t.onSubagentUpdate,onTokenChunk:t.onTokenChunk,modelName:oe,aiProvider:t.aiProvider,apiKey:t.apiKey,onUsage:t.onUsage};if(l==="write_file"||l==="update_file")try{let{path:c}=H(w.args);if(c){let P=j.resolve(process.cwd(),c),V=await qn();V&&V.file_focused===P&&V.full_content&&($t.forcedContent=V.full_content)}}catch{}Je.push(l);let ne=await No(l,w.args,$t);if((l==="write_file"||l==="update_file")&&!ne.startsWith("ERROR:")){let{path:c}=H(w.args);if(c){let P=j.resolve(process.cwd(),c);Js(P)}}process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07");let je=Date.now();en=je,yield{type:"tool_time",content:je-I},dt=je;let mt=null;if(typeof ne=="object"&&ne.binaryPart&&(mt=ne.binaryPart,ne=ne.text),l==="search_keyword"){let{keyword:c,path:P}=H(w.args),V=typeof ne=="string"&&ne.startsWith("[GLOB]");V&&(ne=ne.slice(6).trimStart());let ge=typeof ne=="string"&&ne.startsWith("[DIR]");ge&&(ne=ne.slice(5).trimStart());let ie=0;if(ne){let se=ne.match(/Found (\d+) match/i);se&&(ie=parseInt(se[1]))}let ee=(P||"").trim().toLowerCase().replaceAll("\\","/"),ye=ee==="#doc"||ee==="#docs"||ee==="#documentation"||ee.includes("#skill/global/fluxflow")||ee.includes("#skill/fluxflow")||ee.includes("#skills/fluxflow")||ee.includes("#skills/global/fluxflow"),be,Q=115;process.stdout.isTTY&&(Q=process.stdout.columns-5||120);let U=Math.max(10,(Q+5)/3),X=Math.max(10,(Q+5)/4);if(ye)be=`${c?"\u2714":"\u2718"} Searched Documentation`;else{let se=P?P.replace(/[\/\\]+$/,""):null,Mt=se&&se!=="."?`${V?P:ge?`${se}/*`:se}`:"./",Ct=Mt.length>X?`${Mt.slice(0,X)}...`:Mt;be=`${c?"\u2714":"\u2718"} Searched: "${c?c.length>Q/3?`${c.slice(0,U)}...`:c:""}" in "${Ct.replaceAll("\\","/")}" \u2192 ${ie} Match${ie===1?"":"es"}`}let Le=Math.min(be.length+4,Q),Ce=`${be.padEnd(Le-2).substring(0,Le-2)}`;yield{type:"visual_feedback",content:Ft(`${Ue?`
787
+ ${zt}`}let Xe=l==="write_file"?"Created":"Edited",lt=j(w.args),Cn=Object.entries(lt).some(([it,Je])=>it.startsWith("searchContent")&&typeof Je=="string"&&Je.startsWith("^LINE:"))?"\u1361":":",Yn=`${Ye?"\u2714":"\u2718"} ${Xe}${Cn} ${Ye?Ye.replaceAll("\\","/"):"No File Changes"}`,Rn=115;process.stdout.isTTY&&(Rn=process.stdout.columns-5||120);let zo=Math.min(Yn.length+4,Rn),Ei=`${Yn.padEnd(zo-2).substring(0,zo-2)}`;yield{type:"visual_feedback",content:Wt(`${Ue?`
788
+ `:""}${Ei}`)},Ue=!1;let en=Date.now();nn=en,yield{type:"tool_time",content:en-I};let rn=(ot||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");rn.includes("[[VERIFIED]]")&&(rn=rn.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to conserve context.
789
+ `));let Ln;if(l==="write_file"&&!rn.startsWith("ERROR:")){let Je=rn.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),an=Je.filter(zt=>zt.startsWith("File ")||zt.trim().startsWith("- Stats:"));Ln=`[ACTION RESULT]: ${an.length>0?an.join(`
790
+ `):Je.slice(0,2).join(`
791
+ `)}`}else if(rn.startsWith("[[SAME]]")){let Je=rn.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),an=Je.filter(zt=>zt.startsWith("File ")||zt.trim().startsWith("- Stats:"));Ln=`[ACTION RESULT]: ${an.length>0?an.join(`
792
+ `):Je.slice(0,2).join(`
793
+ `)}`}else Ln=`[ACTION RESULT]: ${rn}`;Be.push({role:"user",text:Ln}),Tn=!0,await vt("toolSuccess"),t.onToolResult&&t.onToolResult("success",l),yield{type:"tool_result",content:ot,aiContent:Ln,toolName:l},Tt++;continue}if(U==="deny"){let Ye=`Permission Denied: Prohibited ${l==="exec_command"?"Command":"file edit"}.`;if(Y?Ye=`User denied reading ${K.basename(ge||".env")}`:X==="user"?Ye="Permission Denied by User":X==="settings"?Ye="Permission Denied by User Policy":X==="network"?Ye="Permission Denied: Sandbox Network Access Disabled by User Policy.":X==="prohibited"&&l==="exec_command"&&(Ye="Permission Denied: Prohibited Command in User Policy"),l==="view_file"){let qe=`\u2718 Read Denied: ${j(w.args).path?.replaceAll("\\","/")||".env"}`,me=115;process.stdout.isTTY&&(me=process.stdout.columns-5||120);let je=Math.min(qe.length+4,me),H=`${qe.padEnd(je-2).substring(0,je-2)}`;yield{type:"visual_feedback",content:Wt(`${Ue?`
794
+ `:""}${H}
795
+ `)},Ue=!1}else if(l==="write_file"||l==="update_file"){let me=`\u2718 ${l==="write_file"?"Write Cancelled":"Edit Denied"}: ${j(w.args).path.replaceAll("\\","/")||"..."}`,je=115;process.stdout.isTTY&&(je=process.stdout.columns-5||120);let H=Math.min(me.length+4,je),Zt=`${me.padEnd(H-2).substring(0,H-2)}`,Vt=` ${" ".repeat(H)} `;yield{type:"visual_feedback",content:Wt(`${Ue?`
796
+ `:""}${Zt}
797
+ `)},Ue=!1}l==="exec_command"&&(await new Promise(qe=>setTimeout(qe,50)),t.onExecChunk&&t.onExecChunk(`ERROR: ${Ye}`),await new Promise(qe=>setTimeout(qe,50)),t.onExecEnd&&t.onExecEnd()),Be.push({role:"user",text:`[ACTION RESULT]: DENIED: ${Ye}`}),yield{type:"tool_result",content:`[ACTION RESULT]: DENIED: ${Ye}`},await vt("toolDenied"),t.onToolResult&&t.onToolResult("denied",l),Tt++;continue}}}if(O){let c=115;process.stdout.isTTY&&(c=process.stdout.columns-5||120);let P=await i(),Y=!1;P&&(Y=P.trim().length>0);let ge=Math.min(O.length+4,c),ie=`${O.padEnd(ge-2).substring(0,ge-2)}`;yield{type:"visual_feedback",content:Wt(`${Ue?`
798
+ `:""}${ie}${O.includes("\u2714")&&(O.includes("Created")||O.includes("Edited"))?"":`${Y?"":`
799
+ `}`}`)},Ue=!1}if(nn>0){let c=Date.now()-nn,P=Math.max(0,1e3-c);P>0&&await new Promise(Y=>setTimeout(Y,P))}let Ft={chatId:p,history:n,onChunk:c=>t.onExecChunk?t.onExecChunk(c):null,onAskUser:t.onAskUser,systemSettings:t.systemSettings,mode:a,isMultiModal:ct(oe),onVisualFeedback:t.onVisualFeedback,onSubagentUpdate:t.onSubagentUpdate,onTokenChunk:t.onTokenChunk,modelName:oe,aiProvider:t.aiProvider,apiKey:t.apiKey,onUsage:t.onUsage};if(l==="write_file"||l==="update_file")try{let{path:c}=j(w.args);if(c){let P=K.resolve(process.cwd(),c),Y=await qn();Y&&Y.file_focused===P&&Y.full_content&&(Ft.forcedContent=Y.full_content)}}catch{}Qe.push(l);let ne=await Do(l,w.args,Ft);if((l==="write_file"||l==="update_file")&&!ne.startsWith("ERROR:")){let{path:c}=j(w.args);if(c){let P=K.resolve(process.cwd(),c);Qs(P)}}process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07");let Ve=Date.now();nn=Ve,yield{type:"tool_time",content:Ve-I},gt=Ve;let xt=null;if(typeof ne=="object"&&ne.binaryPart&&(xt=ne.binaryPart,ne=ne.text),l==="search_keyword"){let{keyword:c,path:P}=j(w.args),Y=typeof ne=="string"&&ne.startsWith("[GLOB]");Y&&(ne=ne.slice(6).trimStart());let ge=typeof ne=="string"&&ne.startsWith("[DIR]");ge&&(ne=ne.slice(5).trimStart());let ie=0;if(ne){let se=ne.match(/Found (\d+) match/i);se&&(ie=parseInt(se[1]))}let ee=(P||"").trim().toLowerCase().replaceAll("\\","/"),ye=ee==="#doc"||ee==="#docs"||ee==="#documentation"||ee.includes("#skill/global/fluxflow")||ee.includes("#skill/fluxflow")||ee.includes("#skills/fluxflow")||ee.includes("#skills/global/fluxflow"),be,Q=115;process.stdout.isTTY&&(Q=process.stdout.columns-5||120);let U=Math.max(10,(Q+5)/3),X=Math.max(10,(Q+5)/4);if(ye)be=`${c?"\u2714":"\u2718"} Searched Documentation`;else{let se=P?P.replace(/[\/\\]+$/,""):null,Ot=se&&se!=="."?`${Y?P:ge?`${se}/*`:se}`:"./",Rt=Ot.length>X?`${Ot.slice(0,X)}...`:Ot;be=`${c?"\u2714":"\u2718"} Searched: "${c?c.length>Q/3?`${c.slice(0,U)}...`:c:""}" in "${Rt.replaceAll("\\","/")}" \u2192 ${ie} Match${ie===1?"":"es"}`}let Le=Math.min(be.length+4,Q),Ce=`${be.padEnd(Le-2).substring(0,Le-2)}`;yield{type:"visual_feedback",content:Wt(`${Ue?`
800
800
  `:""}${Ce}
801
- `)},Ue=!1}if(l==="EmergencyRollback"){let{method:c}=H(w.args);if(c==="forceRevert"){let P=0;if(ne){let U=ne.match(/Total\s*:\s*(\d+)/i);U&&(P=parseInt(U[1]))}let ge=ne&&ne.startsWith("ERROR:")?"\u2718 Emergency Rollback Failed":`\u2714 Emergency Rollback \u2192 ${P} file${P===1?"":"s"} processed`,ie=115;process.stdout.isTTY&&(ie=process.stdout.columns-5||120);let ee=await i(),ye=!1;ee&&(ye=ee.trim().length>0);let be=Math.min(ge.length+4,ie),Q=`${ge.padEnd(be-2).substring(0,be-2)}`;yield{type:"visual_feedback",content:Ft(`${Ue?`
801
+ `)},Ue=!1}if(l==="EmergencyRollback"){let{method:c}=j(w.args);if(c==="forceRevert"){let P=0;if(ne){let U=ne.match(/Total\s*:\s*(\d+)/i);U&&(P=parseInt(U[1]))}let ge=ne&&ne.startsWith("ERROR:")?"\u2718 Emergency Rollback Failed":`\u2714 Emergency Rollback \u2192 ${P} file${P===1?"":"s"} processed`,ie=115;process.stdout.isTTY&&(ie=process.stdout.columns-5||120);let ee=await i(),ye=!1;ee&&(ye=ee.trim().length>0);let be=Math.min(ge.length+4,ie),Q=`${ge.padEnd(be-2).substring(0,be-2)}`;yield{type:"visual_feedback",content:Wt(`${Ue?`
802
802
  `:""}${Q}${ye?"":`
803
- `}`)},Ue=!1}}if(l==="todo"){let{method:c,tasks:P,markDone:V}=H(w.args),ge="",ie=[],ee=ye=>{if(!ye)return[];let be=Array.isArray(ye)?ye:[];if(be.length===0&&typeof ye=="string"){let Q=ye.trim();if(Q.startsWith("[")&&Q.endsWith("]")){let U=Q.match(/"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'/g);U?be=U.map(X=>X.slice(1,-1).replace(/\\(.)/g,"$1")):be=Q.slice(1,-1).split(",").map(X=>X.trim()).filter(Boolean)}else be=ye.split(`
804
- `)}return be.filter(Q=>String(Q).trim()).map(Q=>{let U=String(Q).trim();return U.startsWith("- [")?U.substring(6).trim():U})};if(c==="create"?(ge="\x1B[32m\u2192\x1B[0m Created Goals",ie=ee(P).map(ye=>`\x1B[90m\u25CB\x1B[0m ${ye}`)):c==="append"?(ge="\x1B[34m\u2795\x1B[0m Added New Goals",ie=ee(P).map(ye=>`\x1B[90m\u25CB\x1B[0m ${ye}`)):c==="get"&&(ge=V?"\x1B[36m\u21BB\x1B[0m Updated Goals":"\x1B[35m\u2022\x1B[0m Reviewed Goals",ie=(ne||"").split(`
803
+ `}`)},Ue=!1}}if(l==="todo"){let{method:c,tasks:P,markDone:Y}=j(w.args),ge="",ie=[],ee=ye=>{if(!ye)return[];let be=Array.isArray(ye)?ye:[];if(be.length===0&&typeof ye=="string"){let Q=ye.trim();if(Q.startsWith("[")&&Q.endsWith("]")){let U=Q.match(/"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'/g);U?be=U.map(X=>X.slice(1,-1).replace(/\\(.)/g,"$1")):be=Q.slice(1,-1).split(",").map(X=>X.trim()).filter(Boolean)}else be=ye.split(`
804
+ `)}return be.filter(Q=>String(Q).trim()).map(Q=>{let U=String(Q).trim();return U.startsWith("- [")?U.substring(6).trim():U})};if(c==="create"?(ge="\x1B[32m\u2192\x1B[0m Created Goals",ie=ee(P).map(ye=>`\x1B[90m\u25CB\x1B[0m ${ye}`)):c==="append"?(ge="\x1B[34m\u2795\x1B[0m Added New Goals",ie=ee(P).map(ye=>`\x1B[90m\u25CB\x1B[0m ${ye}`)):c==="get"&&(ge=Y?"\x1B[36m\u21BB\x1B[0m Updated Goals":"\x1B[35m\u2022\x1B[0m Reviewed Goals",ie=(ne||"").split(`
805
805
  `).slice(1).join(`
806
806
  `).split(`
807
807
  `).filter(be=>be.trim().startsWith("- [")).map(be=>{let Q=be.trim(),U=Q.startsWith("- [x]");return`${U?"\x1B[32m\u2714\x1B[0m":"\x1B[90m\u25CB\x1B[0m"} ${U?"\x1B[90m":"\x1B[37m"}${Q.substring(6).trim()}\x1B[0m`})),ge&&ie.length>0){let ye=[`${ge}`,...ie.map(U=>` ${U}`)].join(`
808
- `),be=await i(),Q=!1;be&&(Q=be.trim().length>0),yield{type:"visual_feedback",content:Ft(`${Ue?`
808
+ `),be=await i(),Q=!1;be&&(Q=be.trim().length>0),yield{type:"visual_feedback",content:Wt(`${Ue?`
809
809
  `:""}${ye}${Q?"":`
810
- `}`)},Ue=!1}}l==="exec_command"&&t.onExecEnd&&(await new Promise(c=>setTimeout(c,800)),t.onExecEnd());let Nt=ne&&ne.startsWith("DENIED:");ne&&!ne.startsWith("ERROR:")&&!Nt?(await _t("toolSuccess"),t.onToolResult&&t.onToolResult("success",l)):Nt||(await _t("toolFailure"),t.onToolResult&&t.onToolResult("failure",l));let Et=(ne||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");Et.includes("[[VERIFIED]]")&&(Et=Et.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to save tokens.
811
- `));let fn;if(l==="write_file"&&!Et.startsWith("ERROR:")){let P=Et.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),V=P.filter(ie=>ie.startsWith("File ")||ie.trim().startsWith("- Stats:"));fn=`[ACTION RESULT]: ${V.length>0?V.join(`
810
+ `}`)},Ue=!1}}l==="exec_command"&&t.onExecEnd&&(await new Promise(c=>setTimeout(c,800)),t.onExecEnd());let Bt=ne&&ne.startsWith("DENIED:");ne&&!ne.startsWith("ERROR:")&&!Bt?(await vt("toolSuccess"),t.onToolResult&&t.onToolResult("success",l)):Bt||(await vt("toolFailure"),t.onToolResult&&t.onToolResult("failure",l));let Ct=(ne||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");Ct.includes("[[VERIFIED]]")&&(Ct=Ct.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to save tokens.
811
+ `));let un;if(l==="write_file"&&!Ct.startsWith("ERROR:")){let P=Ct.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),Y=P.filter(ie=>ie.startsWith("File ")||ie.trim().startsWith("- Stats:"));un=`[ACTION RESULT]: ${Y.length>0?Y.join(`
812
812
  `):P.slice(0,2).join(`
813
- `)}`}else if(Et.startsWith("[[SAME]]")){let P=Et.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),V=P.filter(ie=>ie.startsWith("File ")||ie.trim().startsWith("- Stats:"));fn=`[ACTION RESULT]: ${V.length>0?V.join(`
813
+ `)}`}else if(Ct.startsWith("[[SAME]]")){let P=Ct.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),Y=P.filter(ie=>ie.startsWith("File ")||ie.trim().startsWith("- Stats:"));un=`[ACTION RESULT]: ${Y.length>0?Y.join(`
814
814
  `):P.slice(0,2).join(`
815
815
  `)}
816
- [SYSTEM NOTE]: Content verified and persisted to disk. Full preview omitted to save tokens.`}else fn=`[ACTION RESULT]: ${Et}`;De.push({role:"user",text:fn,binaryPart:mt}),Sn=!0;let he=`[ACTION RESULT]: ${ne.replaceAll(`[[VERIFIED]]
816
+ [SYSTEM NOTE]: Content verified and persisted to disk. Full preview omitted to save tokens.`}else un=`[ACTION RESULT]: ${Ct}`;Be.push({role:"user",text:un,binaryPart:xt}),Tn=!0;let he=`[ACTION RESULT]: ${ne.replaceAll(`[[VERIFIED]]
817
817
  `,"").replaceAll(`
818
- [[/VERIFIED]]`,"")||""}`;(l==="view_file"||l==="web_scrape"||l==="file_map")&&(he=`[ACTION RESULT]: ${O} (Context Locked for UI Clarity)`),yield{type:"tool_result",content:he,aiContent:fn,binaryPart:mt,toolName:l},l==="memory"&&!ne.startsWith("ERROR:")&&(yield{type:"memory_updated"}),xt++}if(s==="Google"&&nn&&Date.now()-ki>=150){yield*Kn();let w=po(nn);for(let I of w)yield I;nn="",ki=Date.now()}}h.usageMetadata&&(Zt=h.usageMetadata),Zt&&(yield{type:"liveTokens",content:Zt.totalTokenCount})}if(Y&&(Y=!1,it?_e+="</think_fluxflow>":(fe+="</think_fluxflow>",s==="Google"?nn+="</think_fluxflow>":yield{type:"text",content:"</think_fluxflow>"})),it&&_e.length>0){let h=0,R=Math.min(bt.length,_e.length);for(let Z=R;Z>0;Z--)if(bt.endsWith(_e.substring(0,Z))){h=Z;break}let v=_e.substring(h);if(v){let re=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(bt)?v.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):v.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");if(re)if(fe+=re,s==="Google")nn+=re;else{yield*Kn();let B=po(re);for(let q of B)yield q}}it=!1,_e=""}if(Tn){let h=Tn,R=(ft==="tool"||ft==="action")&&(h.startsWith("[tool:")||h.startsWith("[action:"));Tn="",to=!1,ft=null,Vn=!1,no=!1,R||(s==="Google"?nn+=h:yield{type:"text",content:h})}if(yield*Kn(),ht)break;let ho=(fe||"").trim(),ua=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(ho.toLowerCase())||/\[\[END\]\]/i.test(ho.toLowerCase()),ga=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(ho.toLowerCase()),ma=De.length>0||$!==null,Ai=Bt(ho).trim(),pa=/(\p{Emoji_Presentation}|\p{Extended_Pictographic})$/u.test(Ai),ha=/([.!?"'*_`|\]\)”’~~]+|\s|`{3}|[\u200B-\u200D\uFEFF])$/u.test(Ai.trim()),ya=/[.!?}"'`’“”]$|```$/s.test(Ai)||ha||pa;!ua&&!ga&&!ma&&ho.length>0,Qe=!0,await _t("agent",s)}catch(z){if(ht){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
818
+ [[/VERIFIED]]`,"")||""}`;(l==="view_file"||l==="web_scrape"||l==="file_map")&&(he=`[ACTION RESULT]: ${O} (Context Locked for UI Clarity)`),yield{type:"tool_result",content:he,aiContent:un,binaryPart:xt,toolName:l},l==="memory"&&!ne.startsWith("ERROR:")&&(yield{type:"memory_updated"}),Tt++}if(s==="Google"&&Dt&&Date.now()-no>=150){yield*Kn();let w=ho(Dt);for(let I of w)yield I;Dt="",no=Date.now()}}h.usageMetadata&&(tn=h.usageMetadata),tn&&(yield{type:"liveTokens",content:tn.totalTokenCount})}if(z&&(z=!1,rt?_e+="</think_fluxflow>":(fe+="</think_fluxflow>",s==="Google"?Dt+="</think_fluxflow>":yield{type:"text",content:"</think_fluxflow>"})),rt&&_e.length>0){let h=0,R=Math.min(kt.length,_e.length);for(let Z=R;Z>0;Z--)if(kt.endsWith(_e.substring(0,Z))){h=Z;break}let v=_e.substring(h);if(v){let re=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(kt)?v.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):v.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");if(re)if(fe+=re,s==="Google")Dt+=re;else{yield*Kn();let B=ho(re);for(let q of B)yield q}}rt=!1,_e=""}if(kn){let h=kn,R=(pt==="tool"||pt==="action")&&(h.startsWith("[tool:")||h.startsWith("[action:"));kn="",oo=!1,pt=null,Vn=!1,io=!1,R||(s==="Google"?Dt+=h:yield{type:"text",content:h})}if(yield*Kn(),wt)break;let yo=(fe||"").trim(),ua=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(yo.toLowerCase())||/\[\[END\]\]/i.test(yo.toLowerCase()),ga=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(yo.toLowerCase()),ma=Be.length>0||$!==null,Ai=Gt(yo).trim(),pa=/(\p{Emoji_Presentation}|\p{Extended_Pictographic})$/u.test(Ai),ha=/([.!?"'*_`|\]\)”’~~]+|\s|`{3}|[\u200B-\u200D\uFEFF])$/u.test(Ai.trim()),ya=/[.!?}"'`’“”]$|```$/s.test(Ai)||ha||pa;!ua&&!ga&&!ma&&yo.length>0,Ze=!0,await vt("agent",s)}catch(G){if(wt){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
819
819
 
820
- \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(String(z).includes("Incomplete JSON segment at the end")){Y&&(Y=!1,it?_e+="</think_fluxflow>":(fe+="</think_fluxflow>",yield{type:"text",content:"</think_fluxflow>"})),Qe=!0,await _t("agent",s);break}if(Y&&(Y=!1,it?_e+="</think_fluxflow>":fe+="</think_fluxflow>"),it&&_e.length>0){let St=0,kt=Math.min(bt.length,_e.length);for(let qt=kt;qt>0;qt--)if(bt.endsWith(_e.substring(0,qt))){St=qt;break}let Tt=_e.substring(St);if(Tt){let Mn=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(bt)?Tt.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):Tt.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");Mn&&(fe+=Mn)}it=!1,_e=""}let N=z instanceof Error?(()=>{try{return JSON.parse(JSON.parse(z.message).error.message).error.message}catch{return String(z)}})():String(z),at=new Date().toLocaleString(),Pe=j.join(Rn,"agent");Se.existsSync(Pe)||Se.mkdirSync(Pe,{recursive:!0}),Se.appendFileSync(j.join(Pe,"error.log"),`ERROR [${at}]: ${N}
820
+ \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(String(G).includes("Incomplete JSON segment at the end")){z&&(z=!1,rt?_e+="</think_fluxflow>":(fe+="</think_fluxflow>",yield{type:"text",content:"</think_fluxflow>"})),Ze=!0,await vt("agent",s);break}if(z&&(z=!1,rt?_e+="</think_fluxflow>":fe+="</think_fluxflow>"),rt&&_e.length>0){let At=0,at=Math.min(kt.length,_e.length);for(let et=at;et>0;et--)if(kt.endsWith(_e.substring(0,et))){At=et;break}let mt=_e.substring(At);if(mt){let Pt=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(kt)?mt.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):mt.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");Pt&&(fe+=Pt)}rt=!1,_e=""}let D=G instanceof Error?(()=>{try{return JSON.parse(JSON.parse(G.message).error.message).error.message}catch{return String(G)}})():String(G),dt=new Date().toLocaleString(),De=K.join(_n,"agent");Se.existsSync(De)||Se.mkdirSync(De,{recursive:!0}),Se.appendFileSync(K.join(De,"error.log"),`ERROR [${dt}]: ${D}
821
821
 
822
822
  ----------------------------------------------------------------------
823
823
 
824
- `);let Ye=z.status||z.statusCode||z.code,wt=String(z).includes("replicas at capacity");if(!(Ye&&(Ye>=500&&Ye<600||Ye===408||Ye===429||wt)||!Ye&&(/status[ :]+(5\d\d|408|429)/i.test(String(z))||/code[ :]+(5\d\d|408|429)/i.test(String(z))||/(500|503|408|429)/.test(String(z))))){if(Ve<dn-3)throw z;yield{type:"text",content:N},yield{type:"status",content:"Error Occured"}}if(fe.trim().length>0||Ze>1)if(Ze<=dn){Ze++;let St=Math.min(1e3*Math.pow(2,Ze-1),24e3);if(fe.trim().length>0){b.push({role:"agent",text:fe});let kt=`[system]
824
+ `);let Ge=G.status||G.statusCode||G.code,Et=String(G).includes("replicas at capacity");if(!(Ge&&(Ge>=500&&Ge<600||Ge===408||Ge===429||Et)||!Ge&&(/status[ :]+(5\d\d|408|429)/i.test(String(G))||/code[ :]+(5\d\d|408|429)/i.test(String(G))||/(500|503|408|429)/.test(String(G))))){if(ze<fn-3)throw G;yield{type:"text",content:D},yield{type:"status",content:"Error Occured"}}if(fe.trim().length>0||tt>1)if(tt<=fn){tt++;let At=Math.min(1e3*Math.pow(2,tt-1),24e3);if(fe.trim().length>0){b.push({role:"agent",text:fe});let at=`[system]
825
825
  - seamless continuation: resume immediately. pick up from last words with zero gap/disruption
826
826
  - no repetition: do not repeat any text already written
827
827
  - 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
828
828
  - mid-tool safety: if cutoff was mid-tool call, restart that tool call from start
829
- - stealth: do not mention/apologize for cutoff [/system]`;De.length>0?De.forEach((Tt,qt)=>{qt===De.length-1?b.push({...Tt,text:`${Tt.text}
829
+ - stealth: do not mention/apologize for cutoff [/system]`;Be.length>0?Be.forEach((mt,et)=>{et===Be.length-1?b.push({...mt,text:`${mt.text}
830
830
 
831
- ${kt}`}):b.push(Tt)}):b.push({role:"user",text:kt}),bt+=fe}for(let kt=St/1e3;kt>0&&!ht;kt--)yield{type:"status",content:`Error Occured. Recovering Stream (${Ze}/${dn}) [Retrying in ${kt.toFixed(0)}s]...`},await new Promise(Tt=>setTimeout(Tt,1e3));yield{type:"status",content:"Error Occured. Recovering Stream..."}}else throw new Error(`Stream collapsed too many times. (Failed to resolve ${dn} times)
832
- Error log can be found in \`/export logs\``);else if(Ve<=dn){Ve++,Ze=1,bt="";let St=Math.min(1e3*Math.pow(2,Ve-1),32e3),kt=.8+Math.random()*.4,Tt=Math.round(St*kt);In=!0,yield{type:"status",content:`Trying to reach ${e} (${Ve}/${dn}) [Retrying in ${(Tt/1e3).toFixed(0)}s]`};for(let qt=Tt/1e3;qt>0&&!ht;qt--)yield{type:"status",content:`Trying to reach ${e} (${Ve}/${dn}) [Retrying in ${qt.toFixed(0)}s]`},await new Promise(Mn=>setTimeout(Mn,1e3));yield{type:"status",content:`Trying to reach ${e}`}}else throw new Error(`Model ${e} cannot be reached. (Failed ${dn} times)
833
- Error log can be found in \`/export logs\``)}}if(Zt){let Y=Zt.totalTokenCount||0,z=Zt.cachedContentTokenCount||0,N=(Zt.candidatesTokenCount||0)+(s==="Google"&&Zt.thoughtsTokenCount||0);await pt("tokens",Y,s,oe),z>0&&await pt("cachedTokens",z,s,oe),N>0&&await pt("candidateTokens",N,s,oe),Ee!==null&&Ee>0&&await pt("ttft",Ee,s,oe),ko({provider:s,model:oe,prompt:Zt.promptTokenCount||0,cached:z,output:N,reasoning:Zt.thoughtsTokenCount||0,ttft:Ee}),yield{type:"usage",content:Zt}}else Ee!==null&&Ee>0&&(await pt("ttft",Ee,s,oe),ko({provider:s,model:oe,prompt:0,cached:0,output:0,reasoning:0,ttft:Ee}));fe=Qr(fe),Si.push(fe);let hl=Bt(fe),Ti=qr(fe),aa=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(Ti.toLowerCase())||/\[\[END\]\]/i.test(Ti.toLowerCase())||!0,yl=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(Ti.toLowerCase()),xl=xt>0;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"};let la=ul(fe,/(\[\s*(turn\s*:)?\s*(continue|finish)\s*\]|\[\[END\]\])/gi,"").trim(),jn=(aa||De.length===0)&&!Lt&&!Hn&&!Gt;if(jn=De.length===0?jn:!1,jn=zt||Ko?!1:jn,fe&&fe.trim().endsWith('")]')&&De.length===0&&(jn=!1),jn){ws=!0;let Y=Si.join(`
834
- `),z=Bt(Y).trim();yield{type:"interactive_turn_finished",data:{agentText:ve,fullAgentTextRaw:Y,history:[...b],needTitle:Te}},b.length>0&&b[b.length-1].role==="agent"?b[b.length-1].text=z:b.push({role:"agent",text:z}),b.forEach(N=>{if(N.role==="user"&&N.text&&(N.text=N.text.replace(/\n\[COMPILE ERROR\][\s\S]*?\[\/ERROR\]/g,""),N.text=N.text.replaceAll(`
831
+ ${at}`}):b.push(mt)}):b.push({role:"user",text:at}),kt+=fe}for(let at=At/1e3;at>0&&!wt;at--)yield{type:"status",content:`Error Occured. Recovering Stream (${tt}/${fn}) [Retrying in ${at.toFixed(0)}s]...`},await new Promise(mt=>setTimeout(mt,1e3));yield{type:"status",content:"Error Occured. Recovering Stream..."}}else throw new Error(`Stream collapsed too many times. (Failed to resolve ${fn} times)
832
+ Error log can be found in \`/export logs\``);else{let at=e.split("/").slice(e.endsWith("/free")?-2:-1).join("/");if(ze<=fn){ze++,tt=1,kt="";let mt=Math.min(1e3*Math.pow(2,ze-1),32e3),et=.8+Math.random()*.4,Pt=Math.round(mt*et);Mn=!0,yield{type:"status",content:`Trying to reach ${at} (${ze}/${fn}) [Retrying in ${(Pt/1e3).toFixed(0)}s]`};for(let He=Pt/1e3;He>0&&!wt;He--)yield{type:"status",content:`Trying to reach ${at} (${ze}/${fn}) [Retrying in ${He.toFixed(0)}s]`},await new Promise(Dt=>setTimeout(Dt,1e3));yield{type:"status",content:`Trying to reach ${at}`}}else throw new Error(`Model ${e} cannot be reached. (Failed ${fn} times)
833
+ Error log can be found in \`/export logs\``)}}}if(tn){let z=tn.totalTokenCount||0,G=tn.cachedContentTokenCount||0,D=(tn.candidatesTokenCount||0)+(s==="Google"&&tn.thoughtsTokenCount||0);await bt("tokens",z,s,oe),G>0&&await bt("cachedTokens",G,s,oe),D>0&&await bt("candidateTokens",D,s,oe),Ee!==null&&Ee>0&&await bt("ttft",Ee,s,oe),Ao({provider:s,model:oe,prompt:tn.promptTokenCount||0,cached:G,output:D,reasoning:tn.thoughtsTokenCount||0,ttft:Ee}),yield{type:"usage",content:tn}}else Ee!==null&&Ee>0&&(await bt("ttft",Ee,s,oe),Ao({provider:s,model:oe,prompt:0,cached:0,output:0,reasoning:0,ttft:Ee}));fe=Zr(fe),Ti.push(fe);let hl=Gt(fe),ki=Xr(fe),aa=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(ki.toLowerCase())||/\[\[END\]\]/i.test(ki.toLowerCase())||!0,yl=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(ki.toLowerCase()),xl=Tt>0;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"};let la=ul(fe,/(\[\s*(turn\s*:)?\s*(continue|finish)\s*\]|\[\[END\]\])/gi,"").trim(),jn=(aa||Be.length===0)&&!Nt&&!Hn&&!Kt;if(jn=Be.length===0?jn:!1,jn=Jt||Vo?!1:jn,fe&&fe.trim().endsWith('")]')&&Be.length===0&&(jn=!1),jn){Ss=!0;let z=Ti.join(`
834
+ `),G=Gt(z).trim();yield{type:"interactive_turn_finished",data:{agentText:ve,fullAgentTextRaw:z,history:[...b],needTitle:Te}},b.length>0&&b[b.length-1].role==="agent"?b[b.length-1].text=G:b.push({role:"agent",text:G}),b.forEach(D=>{if(D.role==="user"&&D.text&&(D.text=D.text.replace(/\n\[COMPILE ERROR\][\s\S]*?\[\/ERROR\]/g,""),D.text=D.text.replaceAll(`
835
835
 
836
836
  [system] user question. resolve this specific query within '[ANSWER] ... [/ANSWER]' concisely, naturally [/system]
837
837
  `,"").replaceAll(`[system] user question. resolve this specific query within '[ANSWER] ... [/ANSWER]' concisely, naturally
838
838
  **strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow>** [/system]
839
839
  `,"").replaceAll(`[system] **strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow>** [/system]
840
- `,"").replaceAll(/\n\[system\] WARNING, Turn Limit Impending: Step \d+\/\d+\. Wrap up quickly\/prompt user to continue & use \[\[END\]\] quickly\. \[\/system\]/g,""),N.text=N.text.replaceAll(/\n\[system\] File Changes:\n(?:\* .+ \(created|modified|deleted\)\n)*\[\/system\]/g,""),(s==="Mistral"||s==="Google"&&e?.toLowerCase().startsWith("gemma"))&&(N.text.startsWith("[ACTION RESULT]")||N.text.startsWith("[TOOL RESULT]")))){let Pe=`
841
- [system] Action result received. Analyze output and proceed with your turn [/system]`,Ye=`
842
- [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]`;N.text=N.text.replaceAll(Ye,"").replaceAll(Pe,"").trim()}}),yield{type:"status",content:"[end]"}}if(jn)break;let ca=la.trim()||"*Working...*";if(b.push({role:"agent",text:ca}),De.length>0||Sn){if(De.length>0){let Y=De.map(wt=>wt.text).join(`
843
-
844
- `),N=Bt(fe).replace(/\[{1,2}(?:tool|action):[\s\S]*?\)\s*\]{1,2}/gi,""),at=(N.match(/\[(?:tool|action):/gi)||[]).length,Pe=De.length+at;if(De.length<Pe){let wt=Xr(N);Y+=`
845
-
846
- [system] Only ${De.length} out of ${Pe} attempted tool calls were executed.
847
- ${wt?`Parsing Issues Detected:
848
- ${wt}
849
- `:""}Verify proper structure compliance [action:ActionName(arg="value")] & try failed calls again [/system]`;let Fe=Pe-De.length;for(let St=0;St<Fe;St++)await _t("toolFailure")}let Ye=De.find(wt=>wt.binaryPart)?.binaryPart||null;b.push({role:"user",text:Y,binaryPart:Ye})}}else if(!ht){let Y=fe.replace(/(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\]|$)/i,""),z=(Y.match(/\[(?:tool|action):/gi)||[]).length;if(Ko||zt||z>0){let N=Xr(Y),at=N?`[system] Failed to execute ${z>0?z:1} tool call${z>1?"s":""} due to syntax/structure issues:
850
- ${N} [/system]`:`[system] Failed to execute ${z>0?z:1} tool${z>1?"s":""}. Verify proper structure compliance [action:ActionName(arg="value")] & try again [/system]`;b.push({role:"user",text:at}),await _t("toolFailure"),yield{type:"visual_feedback",content:`
851
- ${Ft("\u2718 Model produced malformed tool call")}
840
+ `,"").replaceAll(/\n\[system\] WARNING, Turn Limit Impending: Step \d+\/\d+\. Wrap up quickly\/prompt user to continue & use \[\[END\]\] quickly\. \[\/system\]/g,""),D.text=D.text.replaceAll(/\n\[system\] File Changes:\n(?:\* .+ \(created|modified|deleted\)\n)*\[\/system\]/g,""),(s==="Mistral"||s==="Google"&&e?.toLowerCase().startsWith("gemma"))&&(D.text.startsWith("[ACTION RESULT]")||D.text.startsWith("[TOOL RESULT]")))){let De=`
841
+ [system] Action result received. Analyze output and proceed with your turn [/system]`,Ge=`
842
+ [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]`;D.text=D.text.replaceAll(Ge,"").replaceAll(De,"").trim()}}),yield{type:"status",content:"[end]"}}if(jn)break;let ca=la.trim()||"*Working...*";if(b.push({role:"agent",text:ca}),Be.length>0||Tn){if(Be.length>0){let z=Be.map(et=>et.text).join(`
843
+
844
+ `),G=Gt(fe),D=gs(G),dt=Qn(G),De=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,Ge=[],Et=[],Pe;for(;(Pe=De.exec(D))!==null;)Et.push({index:Pe.index,toolName:Pe[1]});for(let et=0;et<Et.length;et++){let Pt=Et[et],He=et+1<Et.length?Et[et+1].index:G.length;dt.some(no=>no.fullMatch&&G.startsWith(no.fullMatch,Pt.index))||Ge.push(G.substring(Pt.index,He))}let At=Ge.length,at=Be.length+At;if(At>0){let et=Ge.join(`
845
+ `),Pt=Jr(et);z+=`
846
+
847
+ [system] Only ${Be.length} out of ${at} attempted tool calls were executed.
848
+ ${Pt?`Parsing Issues Detected:
849
+ ${Pt}
850
+ `:""}Verify proper structure compliance [action:ActionName(arg="value")] & try failed calls again [/system]`;for(let He=0;He<At;He++)await vt("toolFailure")}let mt=Be.find(et=>et.binaryPart)?.binaryPart||null;b.push({role:"user",text:z,binaryPart:mt})}}else if(!wt){let z=fe.replace(/(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\]|$)/i,""),G=(z.match(/\[(?:tool|action):/gi)||[]).length;if(Vo||Jt||G>0){let D=Jr(z),dt=D?`[system] Failed to execute ${G>0?G:1} tool call${G>1?"s":""} due to syntax/structure issues:
851
+ ${D} [/system]`:`[system] Failed to execute ${G>0?G:1} tool${G>1?"s":""}. Verify proper structure compliance [action:ActionName(arg="value")] & try again [/system]`;b.push({role:"user",text:dt}),await vt("toolFailure"),yield{type:"visual_feedback",content:`
852
+ ${Wt("\u2718 Model produced malformed tool call")}
852
853
  `}}else yield{type:"visual_feedback",content:`
853
- ${Ft("\u2718 Loop Detected")}
854
- `},b.push({role:"user",text:`[system] ${Hn&&!Lt?"Stuttering Detected by Internal System. Re-calibrate your response & proceed.":`${Lt?" Over Thinking":" Loop"} Detected by Internal System${Lt?" for current Effort Level":""}. ${Lt?"If you have planned the task, prioritize execution/output":"If you have finished your task provide a simple summary and end"}`} [/system]`});Lt=!1,Hn=!1,Gt=!1}m?.advanceRollback&&await Ao.recordTurnDelta(p,L+1,Je),Ko=xt>0||Sn}if(!ws&&!ht){let L="\u2726 Turn safety limit reached. Stopping execution.";yield{type:"text",content:`
854
+ ${Wt("\u2718 Loop Detected")}
855
+ `},b.push({role:"user",text:`[system] ${Hn&&!Nt?"Stuttering Detected by Internal System. Re-calibrate your response & proceed.":`${Nt?" Over Thinking":" Loop"} Detected by Internal System${Nt?" for current Effort Level":""}. ${Nt?"If you have planned the task, prioritize execution/output":"If you have finished your task provide a simple summary and end"}`} [/system]`});Nt=!1,Hn=!1,Kt=!1}m?.advanceRollback&&await Eo.recordTurnDelta(p,L+1,Qe),Vo=Tt>0||Tn}if(!Ss&&!wt){let L="\u2726 Turn safety limit reached. Stopping execution.";yield{type:"text",content:`
855
856
 
856
857
  ${L}
857
- `};let Be=(Si.join(`
858
+ `};let Fe=(Ti.join(`
858
859
  `)+`
859
- ${L}`).trim();yield{type:"interactive_turn_finished",data:{agentText:ve,fullAgentTextRaw:Be,history:[...b],needTitle:Te}},yield{type:"status",content:"[end]"}}}catch(T){let b=T?.cause?` (Cause: ${T.cause?.message||String(T.cause)})`:"",$e=(T instanceof Error?(()=>{try{return JSON.parse(JSON.parse(T.message).error.message).error.message}catch{return(T.message?`${T.message}${b}`:"")||String(T)}})():String(T)).replace(/^(Error:\s*)+/i,"");s==="Google"&&!/^[A-Z0-9_\-\s]+ ERROR:/i.test($e)&&($e=`GEMINI ERROR: ${$e}`);let Pt=new Date().toLocaleString(),pn=j.join(Rn,"agent");yield{type:"text",content:`
860
+ ${L}`).trim();yield{type:"interactive_turn_finished",data:{agentText:ve,fullAgentTextRaw:Fe,history:[...b],needTitle:Te}},yield{type:"status",content:"[end]"}}}catch(T){let b=T?.cause?` (Cause: ${T.cause?.message||String(T.cause)})`:"",$e=(T instanceof Error?(()=>{try{return JSON.parse(JSON.parse(T.message).error.message).error.message}catch{return(T.message?`${T.message}${b}`:"")||String(T)}})():String(T)).replace(/^(Error:\s*)+/i,"");s==="Google"&&!/^[A-Z0-9_\-\s]+ ERROR:/i.test($e)&&($e=`GEMINI ERROR: ${$e}`);let Lt=new Date().toLocaleString(),hn=K.join(_n,"agent");yield{type:"text",content:`
860
861
 
861
862
  \u2726 CRITICAL ERROR: ${$e.includes("fetch failed")?"Failed to Connect. Check your Internet Connection or Wait a moment":$e}
862
- \u2800`},Se.existsSync(pn)||Se.mkdirSync(pn,{recursive:!0}),Se.appendFileSync(j.join(pn,"error.log"),`CRITICAL ERROR [${Pt}]: ${T}${T?.cause?`
863
+ \u2800`},Se.existsSync(hn)||Se.mkdirSync(hn,{recursive:!0}),Se.appendFileSync(K.join(hn,"error.log"),`CRITICAL ERROR [${Lt}]: ${T}${T?.cause?`
863
864
  CAUSE: ${T.cause?.stack||T.cause}`:""}
864
865
 
865
866
  ----------------------------------------------------------------------
866
867
 
867
- `),typeof flushGoogleBuffer=="function"&&(yield*flushGoogleBuffer()),yield{type:"tool_result",content:`ERROR: [INTERNAL CRITICAL] ${$e}`}}finally{we&&(clearInterval(we),we=null),typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),await ei.commitTransaction(),m?.advanceRollback&&await Ao.cleanup(p),await qn()}yield{type:"status",content:null}},Pd=async(e,n,t=null,i=null,o=50,r=null,d=!1)=>{let a=await To(),u={...a,...n},p=process.env.SUBAGENT_MODEL?process.env.SUBAGENT_MODEL.trim():null,x=process.env.SUBAGENT_PROVIDER?process.env.SUBAGENT_PROVIDER.trim():null,m=new Date,f=`${m.getFullYear()}-${m.toLocaleString("en-US",{month:"short"}).toUpperCase()}-${String(m.getDate()).padStart(2,"0")}, ${m.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).replace(":","-")}`,g=(we=>{if(!we)return null;let T=we.toLowerCase();return T==="google"?"Google":T==="deepseek"?"DeepSeek":T==="openrouter"?"OpenRouter":T==="nvidia"?"NVIDIA":T==="mistral"?"Mistral":T==="ollama"?"Ollama":T==="inferx"?"InferX":T==="sensenova"?"SenseNova":T==="poolside"?"Poolside":T==="9router"||T==="9Router"?"9router":T==="aihubmix"||T==="aihub"?"AIHubMix":T==="explabs"||T==="experientiallabs"||T==="experimentallabs"?"ExpLabs":T==="tokenharbor"||T==="token harbor"||T==="token_harbor"||T==="thk"?"TokenHarbor":T==="infron"?"Infron":T==="apinex"||T==="apx"?"APInex":T==="c_openai"||T==="custom_openai"||T==="custom (openai)"||T==="custom"?"c_openai":null})(x),k=u?.systemSettings?.CustomSubAgent?u?.systemSettings?.SubAgentModel:null,ue=u?.systemSettings?.CustomSubAgent?u?.systemSettings?.SubAgentProvider:null,y=null;if(k==="ENV"?(y=p,p&&g&&(u.aiProvider=g)):k&&k!=="Default"?(y=k,ue&&(u.aiProvider=ue)):p&&g&&(u.aiProvider=g),u.aiProvider){let we=await Mi(u.aiProvider);we&&(u.apiKey=we)}let _=we=>{if(!we||typeof we!="string")return{allowed:!0};let T=[/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 b of T)if(b.test(we))return{allowed:!1,reason:`Blocked potentially destructive or unsafe command pattern: "${b.source}"`};return{allowed:!0}},W=t||y||n?.modelName||n?.activeModel||a.activeModel,K=process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux",F=`-- ACTIONS (path = relative to CWD, path separator: '/') --
868
+ `),typeof flushGoogleBuffer=="function"&&(yield*flushGoogleBuffer()),yield{type:"tool_result",content:`ERROR: [INTERNAL CRITICAL] ${$e}`}}finally{we&&(clearInterval(we),we=null),typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),await ti.commitTransaction(),m?.advanceRollback&&await Eo.cleanup(p),await qn()}yield{type:"status",content:null}},Pd=async(e,n,t=null,i=null,o=50,r=null,d=!1)=>{let a=await ko(),u={...a,...n},p=process.env.SUBAGENT_MODEL?process.env.SUBAGENT_MODEL.trim():null,x=process.env.SUBAGENT_PROVIDER?process.env.SUBAGENT_PROVIDER.trim():null,m=new Date,f=`${m.getFullYear()}-${m.toLocaleString("en-US",{month:"short"}).toUpperCase()}-${String(m.getDate()).padStart(2,"0")}, ${m.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).replace(":","-")}`,g=(we=>{if(!we)return null;let T=we.toLowerCase();return T==="google"?"Google":T==="deepseek"?"DeepSeek":T==="openrouter"?"OpenRouter":T==="nvidia"?"NVIDIA":T==="mistral"?"Mistral":T==="ollama"?"Ollama":T==="inferx"?"InferX":T==="sensenova"?"SenseNova":T==="poolside"?"Poolside":T==="9router"||T==="9Router"?"9router":T==="aihubmix"||T==="aihub"?"AIHubMix":T==="explabs"||T==="experientiallabs"||T==="experimentallabs"?"ExpLabs":T==="tokenharbor"||T==="token harbor"||T==="token_harbor"||T==="thk"?"TokenHarbor":T==="infron"?"Infron":T==="apinex"||T==="apx"?"APInex":T==="c_openai"||T==="custom_openai"||T==="custom (openai)"||T==="custom"?"c_openai":null})(x),k=u?.systemSettings?.CustomSubAgent?u?.systemSettings?.SubAgentModel:null,ue=u?.systemSettings?.CustomSubAgent?u?.systemSettings?.SubAgentProvider:null,y=null;if(k==="ENV"?(y=p,p&&g&&(u.aiProvider=g)):k&&k!=="Default"?(y=k,ue&&(u.aiProvider=ue)):p&&g&&(u.aiProvider=g),u.aiProvider){let we=await Mi(u.aiProvider);we&&(u.apiKey=we)}let _=we=>{if(!we||typeof we!="string")return{allowed:!0};let T=[/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 b of T)if(b.test(we))return{allowed:!1,reason:`Blocked potentially destructive or unsafe command pattern: "${b.source}"`};return{allowed:!0}},W=t||y||n?.modelName||n?.activeModel||a.activeModel,V=process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux",F=`-- ACTIONS (path = relative to CWD, path separator: '/') --
868
869
  In chat output the format \`[action:ActionName(arg1="value1")]\` in NEW line
869
870
  Rules:
870
871
  - JSON escape literal sequences, backslash: \\\\, newLine: \\ n
@@ -888,7 +889,7 @@ ${d?"- AskMain(question=string). Communicate with PARENT/MAIN AGENT. When clarif
888
889
  - ReadFile(path=string, startLine?=int, endLine?=int)
889
890
  - 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
890
891
  - WriteFile(path=string, content=string). Creates/Overwrites. File Exist? PatchFile > WriteFile
891
- - Run(command=string). Runs ${K==="Windows"?_s()?"powershell":"windows CMD":"bash"} command. Destructive command \u2192 Ask user`.trim(),E=`=== START SYSTEM PROMPT ===
892
+ - Run(command=string). Runs ${V==="Windows"?vs()?"powershell":"windows CMD":"bash"} command. Destructive command \u2192 Ask user`.trim(),E=`=== START SYSTEM PROMPT ===
892
893
  Identity: FluxFlow subagent helping the main Agent
893
894
  Your task: "${e}"
894
895
  CWD: ${process.cwd()}
@@ -901,30 +902,30 @@ Main focus: actions and task, not chatting
901
902
  On completion, provide a detailed summary in Tables/Markdown Format with file modified info. If any task failed report back in detail
902
903
 
903
904
  Current Time: ${f}
904
- === END SYSTEM PROMPT ===`,pe=[{role:"user",text:`Complete this task: ${e}`}],Te=0,ve="";for(;Te<o;){let we=await Pi("subagent",u);if(!we.allowed)throw new Error(we.reason||`Budget Exhausted for Provider (${u?.aiProvider||"Subagent"})`);if(ht){if(n?.taskId&&typeof Vt<"u"){let S=Vt.find(C=>C.id===n.taskId);S&&(S.status="cancelled")}throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}if(n?.taskId&&typeof Vt<"u"){let S=Vt.find(C=>C.id===n.taskId);if(S&&S.status==="cancelled")throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}let T=pe.map(S=>({role:S.role==="user"?"user":"model",parts:[{text:S.text}]}));r&&r(`[Subagent Turn ${Te+1}]...`);let b=["Fast","Low","Medium","High"],lt=process.env.SUBAGENT_THINKING,$e=b.includes(lt)?lt:"Low",pn=(await hi(u,W,T,E,$e)).text||"",vt=Qr(Bt(pn).trim());ve=vt,r&&r(`[Subagent Response]
905
- ${vt}
906
- `),pe.push({role:"agent",text:vt});let Ut=fo(vt);if(Ut.length===0)break;let hn=Ut.filter(S=>S.toolName.toLowerCase()==="askmain"||S.toolName.toLowerCase()==="ask_main"),yn=!1,Ot="";for(let S of Ut){if(ht){if(n?.taskId&&typeof Vt<"u"){let A=Vt.find(D=>D.id===n.taskId);A&&(A.status="cancelled")}throw new Error("Subagent task was cancelled.")}if(n?.taskId&&typeof Vt<"u"){let A=Vt.find(D=>D.id===n.taskId);if(A&&A.status==="cancelled")throw new Error("Subagent task was cancelled.")}let C=S.toolName.toLowerCase();if(C==="askuser"&&(C="ask"),C==="askmain"||C==="ask_main"){if(yn)continue;yn=!0;let A="";if(hn.length===1?A=H(hn[0].args).question||hn[0].args:A=hn.map((D,xe)=>{let Re=H(D.args);return`Q${xe+1}: ${Re.question||D.args}`}).join(`
907
- `),n.onAskMain){r&&r(`[Executing Tool] AskMain("${A}")...`);let D=await n.onAskMain(A);r&&r(`[Action Result]
908
- Answer from Main Agent: ${D}
909
- `),Ot+=`[ACTION RESULT for AskMain]: Answer from Main Agent: ${D}
905
+ === END SYSTEM PROMPT ===`,pe=[{role:"user",text:`Complete this task: ${e}`}],Te=0,ve="";for(;Te<o;){let we=await Pi("subagent",u);if(!we.allowed)throw new Error(we.reason||`Budget Exhausted for Provider (${u?.aiProvider||"Subagent"})`);if(wt){if(n?.taskId&&typeof qt<"u"){let S=qt.find(C=>C.id===n.taskId);S&&(S.status="cancelled")}throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}if(n?.taskId&&typeof qt<"u"){let S=qt.find(C=>C.id===n.taskId);if(S&&S.status==="cancelled")throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}let T=pe.map(S=>({role:S.role==="user"?"user":"model",parts:[{text:S.text}]}));r&&r(`[Subagent Turn ${Te+1}]...`);let b=["Fast","Low","Medium","High"],ft=process.env.SUBAGENT_THINKING,$e=b.includes(ft)?ft:"Low",hn=(await yi(u,W,T,E,$e)).text||"",It=Zr(Gt(hn).trim());ve=It,r&&r(`[Subagent Response]
906
+ ${It}
907
+ `),pe.push({role:"agent",text:It});let Ht=Qn(It);if(Ht.length===0)break;let yn=Ht.filter(S=>S.toolName.toLowerCase()==="askmain"||S.toolName.toLowerCase()==="ask_main"),xn=!1,$t="";for(let S of Ht){if(wt){if(n?.taskId&&typeof qt<"u"){let A=qt.find(N=>N.id===n.taskId);A&&(A.status="cancelled")}throw new Error("Subagent task was cancelled.")}if(n?.taskId&&typeof qt<"u"){let A=qt.find(N=>N.id===n.taskId);if(A&&A.status==="cancelled")throw new Error("Subagent task was cancelled.")}let C=S.toolName.toLowerCase();if(C==="askuser"&&(C="ask"),C==="askmain"||C==="ask_main"){if(xn)continue;xn=!0;let A="";if(yn.length===1?A=j(yn[0].args).question||yn[0].args:A=yn.map((N,xe)=>{let Re=j(N.args);return`Q${xe+1}: ${Re.question||N.args}`}).join(`
908
+ `),n.onAskMain){r&&r(`[Executing Tool] AskMain("${A}")...`);let N=await n.onAskMain(A);r&&r(`[Action Result]
909
+ Answer from Main Agent: ${N}
910
+ `),$t+=`[ACTION RESULT for AskMain]: Answer from Main Agent: ${N}
910
911
 
911
- `,await _t("toolSuccess")}else Ot+=`[ACTION RESULT for AskMain]: ERROR: Main agent communication channel not available.
912
+ `,await vt("toolSuccess")}else $t+=`[ACTION RESULT for AskMain]: ERROR: Main agent communication channel not available.
912
913
 
913
914
  `;continue}if(!(i?i.some(A=>A.toLowerCase()===C):!0)){let A=`ERROR: Tool [${S.toolName}] is not in the allowed tools list for this subagent.`;r&&r(`[Blocked Tool Call] ${S.toolName} - not allowed
914
- `),Ot+=`${A}
915
+ `),$t+=`${A}
915
916
 
916
- `;continue}if(C==="exec_command"||C==="execcommand"||C==="run"){let A=H(S.args).command||"",D=_(A);if(!D.allowed){let xe=`ERROR: [SECURITY RESTRICTION] Subagent execution blocked command: ${D.reason}`;r&&r(`[Blocked Command] ${A} - ${D.reason}
917
- `),Ot+=`${xe}
917
+ `;continue}if(C==="exec_command"||C==="execcommand"||C==="run"){let A=j(S.args).command||"",N=_(A);if(!N.allowed){let xe=`ERROR: [SECURITY RESTRICTION] Subagent execution blocked command: ${N.reason}`;r&&r(`[Blocked Command] ${A} - ${N.reason}
918
+ `),$t+=`${xe}
918
919
 
919
- `;continue}}let M="";if(C==="web_search"||C==="websearch")M=`\u2714 \x1B[95mSearched\x1B[0m: ${H(S.args).query||""}`;else if(C==="web_scrape"||C==="webscrape")M=`\u2714 \x1B[95mScraped\x1B[0m: ${H(S.args).url||""}`;else if(C==="search_keyword"||C==="searchkeyword"||C==="codesearch"||C==="code_search"){let A=H(S.args),D=A.keyword||"",xe=A.path||"";M=`${D?"\u2714":"\u2718"} \x1B[95mSearched\x1B[0m: ${D||"No Query"}${xe?` \u2192 ${xe.replaceAll("\\","/")}`:""}`}else if(C==="view_file"||C==="viewfile"||C==="readfile")M=`\u2714 \x1B[95mRead\x1B[0m: ${(H(S.args).path||"").replaceAll("\\","/")}`;else if(C==="find_file"||C==="findfile"){let A=H(S.args),D=A.basename||A.name||A.path||A.file||A.query||"";M=`${D?"\u2714":"\u2718"} \x1B[95mLocated\x1B[0m: ${D||"No Query"}`}else if(C==="list_files"||C==="read_folder"||C==="readfolder"){let A=H(S.args).path||null,D=H(S.args).recurse||0;M=`${A?"\u2714":"\u2718"} \x1B[95mBrowsed\x1B[0m: ${A?`${A.replaceAll("\\","/")}${D>0?`${A.endsWith("/")?`*${D}`:`/*${D}`}`:`${A.endsWith("/")?"":"/"}`}`:""}`}else if(C==="write_file"||C==="writefile"){let A=H(S.args).path||null;M=`${A?"\u2714":"\u2718"} \x1B[95mCreated\x1B[0m: ${A?`${A.replaceAll("\\","/")}`:"No File Changes"}`}else if(C==="update_file"||C==="updatefile"||C==="patchfile"||C==="patch_file"){let A=H(S.args),D=A.path||null,Re=Object.entries(A).some(([ke,Me])=>ke.startsWith("searchContent")&&typeof Me=="string"&&Me.startsWith("^LINE:"))?"\u1361":":";M=`${D?"\u2714":"\u2718"} \x1B[95mEdited\x1B[0m${Re} ${D?`${D.replaceAll("\\","/")}`:"No File Changes"}`}else if(C==="exec_command"||C==="execcommand"||C==="run"){let A=H(S.args).command||null;M=`${A?"\u2714":"\u2718"} \x1B[95mExecuted\x1B[0m: ${A?A.slice(0,100)+(A.length>100?"...":""):"No Command"}`}else if(C==="file_map"||C==="filemap"){let A=H(S.args).path||"";M=`${A?"\u2714":"\u2718"} \x1B[95mIndexed\x1B[0m: ${A?`${A.replaceAll("\\","/")}`:"File Not Found"}`}else if(C==="await"){let{time:A}=H(S.args),D=parseFloat(A)||0;D<10&&(D=10),D>180&&(D=180),M=`\u2714 \x1B[95mAwaiting\x1B[0m \u2192 ${(Re=>{if(Re>=60){let ke=Math.floor(Re/60),Me=Re%60;return`${ke}m${Me>0?` ${Me}s`:""}`}return`${Re}s`})(D)}`}else{let A=ds[C]||S.toolName,D=Jn(C,S.args);M=`\u2714 \x1B[95m${A}\x1B[0m${D?`: ${D}`:""}`}n.onVisualFeedback&&M&&n.onVisualFeedback(M),r&&r(`[Executing Tool] ${S.toolName}(${S.args})...`);try{let A=await No(S.toolName,S.args,{...n,mode:"Flux"});if(r&&r(`[Action Result]
920
+ `;continue}}let M="";if(C==="web_search"||C==="websearch")M=`\u2714 \x1B[95mSearched\x1B[0m: ${j(S.args).query||""}`;else if(C==="web_scrape"||C==="webscrape")M=`\u2714 \x1B[95mScraped\x1B[0m: ${j(S.args).url||""}`;else if(C==="search_keyword"||C==="searchkeyword"||C==="codesearch"||C==="code_search"){let A=j(S.args),N=A.keyword||"",xe=A.path||"";M=`${N?"\u2714":"\u2718"} \x1B[95mSearched\x1B[0m: ${N||"No Query"}${xe?` \u2192 ${xe.replaceAll("\\","/")}`:""}`}else if(C==="view_file"||C==="viewfile"||C==="readfile")M=`\u2714 \x1B[95mRead\x1B[0m: ${(j(S.args).path||"").replaceAll("\\","/")}`;else if(C==="find_file"||C==="findfile"){let A=j(S.args),N=A.basename||A.name||A.path||A.file||A.query||"";M=`${N?"\u2714":"\u2718"} \x1B[95mLocated\x1B[0m: ${N||"No Query"}`}else if(C==="list_files"||C==="read_folder"||C==="readfolder"){let A=j(S.args).path||null,N=j(S.args).recurse||0;M=`${A?"\u2714":"\u2718"} \x1B[95mBrowsed\x1B[0m: ${A?`${A.replaceAll("\\","/")}${N>0?`${A.endsWith("/")?`*${N}`:`/*${N}`}`:`${A.endsWith("/")?"":"/"}`}`:""}`}else if(C==="write_file"||C==="writefile"){let A=j(S.args).path||null;M=`${A?"\u2714":"\u2718"} \x1B[95mCreated\x1B[0m: ${A?`${A.replaceAll("\\","/")}`:"No File Changes"}`}else if(C==="update_file"||C==="updatefile"||C==="patchfile"||C==="patch_file"){let A=j(S.args),N=A.path||null,Re=Object.entries(A).some(([ke,Me])=>ke.startsWith("searchContent")&&typeof Me=="string"&&Me.startsWith("^LINE:"))?"\u1361":":";M=`${N?"\u2714":"\u2718"} \x1B[95mEdited\x1B[0m${Re} ${N?`${N.replaceAll("\\","/")}`:"No File Changes"}`}else if(C==="exec_command"||C==="execcommand"||C==="run"){let A=j(S.args).command||null;M=`${A?"\u2714":"\u2718"} \x1B[95mExecuted\x1B[0m: ${A?A.slice(0,100)+(A.length>100?"...":""):"No Command"}`}else if(C==="file_map"||C==="filemap"){let A=j(S.args).path||"";M=`${A?"\u2714":"\u2718"} \x1B[95mIndexed\x1B[0m: ${A?`${A.replaceAll("\\","/")}`:"File Not Found"}`}else if(C==="await"){let{time:A}=j(S.args),N=parseFloat(A)||0;N<10&&(N=10),N>180&&(N=180),M=`\u2714 \x1B[95mAwaiting\x1B[0m \u2192 ${(Re=>{if(Re>=60){let ke=Math.floor(Re/60),Me=Re%60;return`${ke}m${Me>0?` ${Me}s`:""}`}return`${Re}s`})(N)}`}else{let A=ds[C]||S.toolName,N=Jn(C,S.args);M=`\u2714 \x1B[95m${A}\x1B[0m${N?`: ${N}`:""}`}n.onVisualFeedback&&M&&n.onVisualFeedback(M),r&&r(`[Executing Tool] ${S.toolName}(${S.args})...`);try{let A=await Do(S.toolName,S.args,{...n,mode:"Flux"});if(r&&r(`[Action Result]
920
921
  ${A}
921
- `),Ot+=`[ACTION RESULT for ${S.toolName}]: ${A}
922
+ `),$t+=`[ACTION RESULT for ${S.toolName}]: ${A}
922
923
 
923
- `,await _t("toolSuccess"),C==="patchfile"||C==="update_file"||C==="updatefile"||C==="patch_file"){if(A){let D=A.split(`
924
- `),xe=0,Re=0,ke=!1;for(let Me of D){if(Me.includes("[DIFF_START]")){ke=!0;continue}if(Me.includes("[DIFF_END]")){ke=!1;continue}ke&&(/^\+\s*\d+/.test(Me)?xe++:/^\-\s*\d+/.test(Me)&&Re++)}(xe>0||Re>0)&&(await pt("linesAdded",xe),await pt("linesRemoved",Re))}}else if((C==="writefile"||C==="write_file")&&A){let D=A.match(/- Stats: \[(\d+) lines/),xe=D?parseInt(D[1]):0,Re=0;if(A.includes("Old File contents:")){let ke=!1;for(let Me of A.split(`
925
- `)){if(Me.includes("Old File contents:")){ke=!0;continue}ke&&(Me.startsWith("- Content Preview:")||Me.trim()===""&&!/^\s*\d+\s*\|/.test(Me)?ke=!1:/^\s*\d+\s*\|/.test(Me)&&Re++)}}(xe>0||Re>0)&&(await pt("linesAdded",xe),await pt("linesRemoved",Re))}}catch(A){let D=`ERROR: Execution failed for [${S.toolName}]: ${A.message}`;r&&r(`[Tool Error] ${D}
926
- `),Ot+=`${D}
924
+ `,await vt("toolSuccess"),C==="patchfile"||C==="update_file"||C==="updatefile"||C==="patch_file"){if(A){let N=A.split(`
925
+ `),xe=0,Re=0,ke=!1;for(let Me of N){if(Me.includes("[DIFF_START]")){ke=!0;continue}if(Me.includes("[DIFF_END]")){ke=!1;continue}ke&&(/^\+\s*\d+/.test(Me)?xe++:/^\-\s*\d+/.test(Me)&&Re++)}(xe>0||Re>0)&&(await bt("linesAdded",xe),await bt("linesRemoved",Re))}}else if((C==="writefile"||C==="write_file")&&A){let N=A.match(/- Stats: \[(\d+) lines/),xe=N?parseInt(N[1]):0,Re=0;if(A.includes("Old File contents:")){let ke=!1;for(let Me of A.split(`
926
+ `)){if(Me.includes("Old File contents:")){ke=!0;continue}ke&&(Me.startsWith("- Content Preview:")||Me.trim()===""&&!/^\s*\d+\s*\|/.test(Me)?ke=!1:/^\s*\d+\s*\|/.test(Me)&&Re++)}}(xe>0||Re>0)&&(await bt("linesAdded",xe),await bt("linesRemoved",Re))}}catch(A){let N=`ERROR: Execution failed for [${S.toolName}]: ${A.message}`;r&&r(`[Tool Error] ${N}
927
+ `),$t+=`${N}
927
928
 
928
- `,await _t("toolFailure")}}let yt="";if(n?.taskId&&typeof Vt<"u"){let S=Vt.find(C=>C.id===n.taskId);if(S&&S.pendingSteerMessages&&S.pendingSteerMessages.length>0){let C=[...S.pendingSteerMessages];S.pendingSteerMessages=[];for(let Ie of C)yt+=`
929
+ `,await vt("toolFailure")}}let St="";if(n?.taskId&&typeof qt<"u"){let S=qt.find(C=>C.id===n.taskId);if(S&&S.pendingSteerMessages&&S.pendingSteerMessages.length>0){let C=[...S.pendingSteerMessages];S.pendingSteerMessages=[];for(let Ie of C)St+=`
929
930
 
930
- [STEERING INSTRUCTION FROM MAIN AGENT]: ${Ie}`,r&&r(`[Subagent Steered] ${Ie}`)}}let cn=(Ot.trim()+yt).trim();pe.push({role:"user",text:cn}),Te++}return ve};export{co as a,mi as b,$c as c,Nc as d,ic as e,sc as f,lo as g,rc as h,Sc as i,Tc as j,ol as k,Ad as l,il as m,sl as n,cs as o,Bt as p,pi as q,Qr as r,cl as s,Ed as t,Cd as u,us as v,Rd as w,fl as x,_d as y,hi as z,vd as A,Id as B,Md as C,Pd as D};
931
+ [STEERING INSTRUCTION FROM MAIN AGENT]: ${Ie}`,r&&r(`[Subagent Steered] ${Ie}`)}}let dn=($t.trim()+St).trim();pe.push({role:"user",text:dn}),Te++}return ve};export{uo as a,pi as b,$c as c,Nc as d,ic as e,sc as f,fo as g,rc as h,Sc as i,Tc as j,ol as k,Ad as l,il as m,sl as n,cs as o,Gt as p,hi as q,Zr as r,cl as s,Ed as t,Cd as u,us as v,Rd as w,gs as x,fl as y,Qn as z,_d as A,yi as B,vd as C,Id as D,Md as E,Pd as F};