fluxflow-cli 5.0.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import{a as Bs}from"./chunk-HFTI3R3Q.js";import{a as ho}from"./chunk-52STSLCN.js";import{a as Ot}from"./chunk-56EJGQU3.js";import{a as Ws}from"./chunk-4BLSASW6.js";import{c as Oi,g as $i,h as Os,i as $s,j as Ls}from"./chunk-7SGZ66KT.js";import{b as Ds,c as Ns,d as Li,f as Fs}from"./chunk-UIL6OCU4.js";import{a as Yo}from"./chunk-6EYQQ7GQ.js";import{a as L}from"./chunk-Y5JU726N.js";import{b as Ps}from"./chunk-QESQR5GB.js";import{y as Ii}from"./chunk-J4J3F6BT.js";import{f as qo,l as St,o as Mi,p as an,r as Pi}from"./chunk-V36DXF56.js";import{b as zo}from"./chunk-B4UKMX5E.js";import{l as et,m as Vo}from"./chunk-LQM3JK7N.js";import{c as rn,d as _i,e as Ko}from"./chunk-P5HBJA23.js";import{a as Cn,b as Ho,c as Es,d as Wn,e as _s,k as jo,l as Ri,m as Is,r as Ei,w as mo,x as po,y as Ms}from"./chunk-26BQ45XP.js";import{GoogleGenAI as ia,ThinkingLevel as Ke,HarmBlockThreshold as di,HarmCategory as fi}from"@google/genai";var Xo={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 Ut from"fs";import Wt from"path";import La from"os";import ln from"fs";import vn from"path";import Zs from"fs";import Di from"path";import{execSync as er}from"child_process";import{fileURLToPath as Pa}from"url";var Us=`# FluxFlow CLI Startup & Flags Reference
1
+ import{a as Gs}from"./chunk-HFTI3R3Q.js";import{a as yo}from"./chunk-52STSLCN.js";import{a as Lt}from"./chunk-56EJGQU3.js";import{a as Hs}from"./chunk-4BLSASW6.js";import{c as Ni,g as Fi,h as Ds,i as Ns,j as Fs}from"./chunk-7SGZ66KT.js";import{b as Bs,c as Ws,d as Bi,f as Us}from"./chunk-UIL6OCU4.js";import{a as Zo}from"./chunk-6EYQQ7GQ.js";import{a as O}from"./chunk-Y5JU726N.js";import{b as Os}from"./chunk-QESQR5GB.js";import{y as Li}from"./chunk-J4J3F6BT.js";import{f as Qo,l as St,o as Oi,p as ln,r as Di}from"./chunk-V36DXF56.js";import{b as Jo}from"./chunk-B4UKMX5E.js";import{l as et,m as Xo}from"./chunk-LQM3JK7N.js";import{c as an,d as $i,e as Yo}from"./chunk-P5HBJA23.js";import{a as vn,b as zo,c as Ms,d as Un,e as Ps,k as qo,l as Mi,m as $s,r as Pi,w as po,x as ho,y as Ls}from"./chunk-26BQ45XP.js";import{GoogleGenAI as aa,ThinkingLevel as Ke,HarmBlockThreshold as mi,HarmCategory as pi}from"@google/genai";var ei={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 Gt from"fs";import Ut from"path";import Ba from"os";import cn from"fs";import Rn from"path";import nr from"fs";import Wi from"path";import{execSync as or}from"child_process";import{fileURLToPath as Da}from"url";var js=`# FluxFlow CLI Startup & Flags Reference
2
2
 
3
3
  Launch command syntax:
4
4
  fluxflow [options]
@@ -27,7 +27,7 @@ fluxflow [options]
27
27
  * --help commands \u2192 In-chat slash commands list
28
28
  * --playground \u2192 Launch Playground mode
29
29
  * --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\`
30
- `;var Gs=`# Env Variables
30
+ `;var Ks=`# Env Variables
31
31
 
32
32
  * Locations:
33
33
  * Shell
@@ -58,7 +58,7 @@ fluxflow [options]
58
58
 
59
59
  * 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
60
60
  * GOOGLE_GEMMA_NONSENSE \u2192 (true|false, default: false) for the 16k TPM nonsense of gemma models on gemini API. False defaults to 256k
61
- `;var Hs=`# Fluxflow in-app /commands
61
+ `;var Vs=`# Fluxflow in-app /commands
62
62
 
63
63
  Trigger in chat via /command
64
64
 
@@ -111,7 +111,7 @@ Trigger in chat via /command
111
111
  * /update latest \u2192 Install latest release
112
112
  * /fluxflow global/saves \u2192 Openes fluxflow storage paths in explorer
113
113
  * /move \u2192 Transfer Playground session data to CWD/playground-export
114
- `;var js=`# FluxFlow In-App Settings Reference
114
+ `;var zs=`# FluxFlow In-App Settings Reference
115
115
 
116
116
  Open in chat via /settings
117
117
 
@@ -186,7 +186,7 @@ Open in chat via /settings
186
186
  | Emergency Recovery | Off | Off |
187
187
  | Auto Truncate Results | On | On |
188
188
  | Memory | Off | Off |
189
- `;var Ks=`# FluxFlow Tool Reference
189
+ `;var qs=`# FluxFlow Tool Reference
190
190
 
191
191
  ## Protocol: [action:ActionName(arg1="val")]
192
192
 
@@ -227,7 +227,7 @@ Open in chat via /settings
227
227
  * KeyboardTyping(text, autoPressEnter?) \u2192 Type string
228
228
  * KeyPress(key) \u2192 Key/combo dispatch ("ctrl;c", "enter", etc.)
229
229
  * RecaptureScreen() \u2192 Fresh screenshot + coordinate grid
230
- `;var Vs=`# Fluxflow Architecture
230
+ `;var Ys=`# Fluxflow Architecture
231
231
 
232
232
  ## 1. Terminal Engine
233
233
  * Framework: React + Ink terminal UI
@@ -257,7 +257,7 @@ Open in chat via /settings
257
257
  ## 6. IDE Bridge
258
258
  * Protocol: WebSocket on ws://localhost:56832
259
259
  * State Sync: Focused file, open tabs, cursor line, selection, diagnostics
260
- `;var zs=`# FluxFlow Sub-Agents & Multi-Agent Architecture
260
+ `;var Xs=`# FluxFlow Sub-Agents & Multi-Agent Architecture
261
261
 
262
262
  ## Execution Modes
263
263
  * InvokeSync \u2192 Synchronous blocking delegation; main agent halts until sub-agent finishes task
@@ -288,7 +288,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
288
288
  * SUBAGENT_MODEL \u2192 Target model override
289
289
  * SUBAGENT_PROVIDER \u2192 Target provider override
290
290
  * Setting SubAgentModel=ENV in settings pulls directly from environment overrides
291
- `;var qs=`# FluxFlow Security, Sandboxing & Safety
291
+ `;var Js=`# FluxFlow Security, Sandboxing & Safety
292
292
 
293
293
  ## Human-in-the-Loop Governance
294
294
  * Execution Approval Gate \u2192 Destructive commands and high-risk file modifications require explicit user authorization (Allow / Deny)
@@ -311,7 +311,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
311
311
  * Emergency Rollback \u2192 Automatic pre-turn file snapshots; Agent can still fix it (default: OFF) \u2192 references/SETTINGS.md
312
312
  * Git-less Checkpoint Reversion \u2192 Trigger conversational changes rollback via double-ESC
313
313
  * External Sanctuary Redirection \u2192 Move ~/.fluxflow data sanctuary (chats, keys etc)
314
- `;var Ys=`# Fluxflow IDE Companion
314
+ `;var Qs=`# Fluxflow IDE Companion
315
315
 
316
316
  ## WebSocket Bridge Protocol
317
317
  * Local Bridge \u2192 Runs on ws://localhost:56832 connecting FluxFlow CLI with the companion editor extension
@@ -329,7 +329,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
329
329
  * File Focus \u2192 Automatically opens edited files in active IDE window
330
330
  * Diff Preview \u2192 Streams side-by-side or inline diff highlights (showDiff, highlightDiff) directly in editor
331
331
  * Status Bar Sync \u2192 Real-time agent status (thinking, running tool, awaiting input) reflected in IDE status bar
332
- `;var Xs=`# Fluxflow Modes
332
+ `;var Zs=`# Fluxflow Modes
333
333
 
334
334
  ## Modes Overview (TAB to cycle)
335
335
  * [Flux] (Workspace / Dev) \u2192 Primary coding & workspace agent
@@ -347,7 +347,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
347
347
  * User Inquiry: AskUser \u2192 [Universal]
348
348
  * Document Creation: WritePDF, WriteDoc \u2192 [Flow]
349
349
  * GUI & Desktop Automation: Click, Scroll, KeyboardTyping, KeyPress, RecaptureScreen \u2192 [ICU] | [FluxCU]
350
- `;var Js=`# FluxFlow AI Providers & Setup
350
+ `;var er=`# FluxFlow AI Providers & Setup
351
351
 
352
352
  ## Supported Providers
353
353
  * Gemini | NVIDIA NIM | DeepSeek | Mistral | Ollama Local/Cloud | InferX | SenseNova | Poolside | OpenRouter | AIHubMix | Experiential Labs | TokenHarbor | APInex | Infron
@@ -385,7 +385,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
385
385
  2. Set ENV ENABLE_9ROUTER=true
386
386
  * 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
387
387
  * NINEROUTER_KEY = If any needed
388
- `;var Qs=`# Fluxflow Instructions & Skills System
388
+ `;var tr=`# Fluxflow Instructions & Skills System
389
389
 
390
390
  ## 1. Instructions (AGENTS.md / FLUXFLOW.md root only)
391
391
  * Locations:
@@ -429,14 +429,14 @@ Instruction for this model ID across all providers.
429
429
 
430
430
  * On-Demand Reference System:
431
431
  * Reference: Offload deep/contexual specs to **/{SKILL.md,skill-reference-folder/*.md} & reference in SKILL.md. Saves tokens
432
- `;var Jo="v4";try{let e=Di.dirname(Pa(import.meta.url)),n=[Di.join(e,"../../package.json"),Di.join(e,"../package.json")],t=!1;for(let i of n)if(Zs.existsSync(i)){let o=JSON.parse(Zs.readFileSync(i,"utf8"));if(o.version){Jo=o.version,t=!0;break}}if(!t)try{let i=er("fluxflow -v",{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"],timeout:2e3}).trim();i&&(i.startsWith("v")||/^\d+\.\d+/.test(i))&&(Jo=i,t=!0)}catch{}if(!t)try{let i=er("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&&(Jo=o.version)}catch{}}catch{}var Ni={"SKILL.md":`---
432
+ `;var ti="v4";try{let e=Wi.dirname(Da(import.meta.url)),n=[Wi.join(e,"../../package.json"),Wi.join(e,"../package.json")],t=!1;for(let i of n)if(nr.existsSync(i)){let o=JSON.parse(nr.readFileSync(i,"utf8"));if(o.version){ti=o.version,t=!0;break}}if(!t)try{let i=or("fluxflow -v",{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"],timeout:2e3}).trim();i&&(i.startsWith("v")||/^\d+\.\d+/.test(i))&&(ti=i,t=!0)}catch{}if(!t)try{let i=or("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&&(ti=o.version)}catch{}}catch{}var Ui={"SKILL.md":`---
433
433
  name: fluxflow
434
434
  description: System Generated Documentation. Read this if asked anything regarding FluxFlow Harness
435
435
  ---
436
436
 
437
437
  # FluxFlow, by Kushal Roy Chowdhury
438
438
  Open Source Terminal AI Assistant
439
- App Version: ${Jo}. Check Updates: fluxflow --update check. Update: fluxflow --update
439
+ App Version: ${ti}. Check Updates: fluxflow --update check. Update: fluxflow --update
440
440
  GitHub: https://github.com/KushalRoyChowdhury/fluxflow-cli
441
441
  Public Docs: https://fluxflow-cli.onrender.com
442
442
 
@@ -456,24 +456,24 @@ Public Docs: https://fluxflow-cli.onrender.com
456
456
 
457
457
  Default Context Length: 256k Tokens. Can be changed via ENV/In-app Settings \u2192 references/{SETTINGS,ENV}.md
458
458
 
459
- Docs missing required info? Say you are not sure enough to answer. Dont give wrong info`,"references/MODES.md":Xs,"references/PROVIDERS.md":Js,"references/PLUGINS.md":Qs,"references/STARTUP.md":Us,"references/ENV.md":Gs,"references/COMMANDS.md":Hs,"references/SETTINGS.md":js,"references/TOOLS.md":Ks,"references/ARCHITECTURE.md":Vs,"references/SUB_AGENTS.md":zs,"references/SECURITY.md":qs,"references/IDE.md":Ys};var tr=()=>{try{let e=vn.join(Cn,"skills","fluxflow"),n=vn.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){ln.existsSync(e)&&ln.rmSync(e,{recursive:!0,force:!0});return}let i=new Set(Object.keys(Ni).map(o=>vn.normalize(o)));for(let[o,r]of Object.entries(Ni)){let d=vn.join(e,o),l=vn.dirname(d);ln.existsSync(l)||ln.mkdirSync(l,{recursive:!0});let u=r.trim()+`
460
- `,g=null;ln.existsSync(d)&&(g=ln.readFileSync(d,"utf8")),g!==u&&ln.writeFileSync(d,u,"utf8")}if(ln.existsSync(n)){let o=ln.readdirSync(n);for(let r of o){let d=vn.normalize(vn.join("references",r));if(!i.has(d)){let l=vn.join(n,r);try{ln.rmSync(l,{recursive:!0,force:!0})}catch{}}}}}catch{}};import{WebSocket as Qo}from"ws";var vt=null,to=!1,Oa="ws://localhost:56832",Fi=[],no=null,Bi=null,Wi=null,nr="2.0.0",cc=e=>{nr=e,or()},Ui=e=>{Bi=e},dc=e=>{Wi=e},or=()=>{if(vt||to)return;to=!0;let e=new Qo(Oa);e.on("open",()=>{for(vt=e,to=!1,vt.send(JSON.stringify({command:"version",version:nr,pid:process.pid,ppid:process.ppid,cwd:process.cwd()}));Fi.length>0;)vt.send(JSON.stringify(Fi.shift()))}),e.on("message",n=>{try{let t=JSON.parse(n.toString());t.command==="contextResponse"&&no?(no(t.data),no=null):t.command==="securityResponse"&&Bi?Bi(t.result):t.command==="inlineComplete"?$a(t):t.command==="connectionRejected"&&Wi&&Wi(t)}catch{}}),e.on("error",()=>{to=!1,vt=null}),e.on("close",()=>{to=!1,vt=null})},yo=e=>{vt&&vt.readyState===Qo.OPEN?vt.send(JSON.stringify(e)):(Fi.push(e),to||or())},oo=()=>vt!==null&&vt.readyState===Qo.OPEN,$a=async e=>{let n="";try{let{generateAutoCompletion:t}=await import("./auto_completion-UG6IEWD2.js");n=await t({prefix:e.prefix||"",suffix:e.suffix||"",fileName:e.fileName||"",language:e.language||"",recentChanges:e.recentChanges||"",clipboard:e.clipboard||""})}catch{n=""}yo({command:"inlineCompleteResponse",requestId:e.requestId,completion:n||""})},fc=e=>{yo({command:"status",status:e})},Un=()=>new Promise(e=>{if(!vt||vt.readyState!==Qo.OPEN){e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]});return}no=e,vt.send(JSON.stringify({command:"requestContext"})),setTimeout(()=>{no===e&&(e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]}),no=null)},1e3)}),ir=e=>{yo({command:"open",filePath:e})},Gi=(e,n,t)=>{yo({command:"showDiff",filePath:e,originalContent:n,modifiedContent:t})},sr=(e,n)=>{yo({command:"closeDiff",filePath:e,result:n})};var Ao=(e,n)=>{try{if(!Ut.existsSync(e))return null;let t=Array.isArray(n)?n.map(o=>o.toLowerCase()):[n.toLowerCase()],i=Ut.readdirSync(e);for(let o of t){let r=i.find(d=>d.toLowerCase()===o);if(r){let d=Wt.join(e,r);if(Ut.statSync(d).isFile())return d}}}catch{}return null},zi=(e,n)=>{let t=Ao(e,n);if(t)try{return Ut.readFileSync(t,"utf8")}catch{}return""},rr=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"]),qi=(e=process.cwd(),n=0,t=8)=>{let i=[];if(n>t)return i;try{if(!Ut.existsSync(e))return i;let o=Ut.readdirSync(e,{withFileTypes:!0});for(let r of o){let d=r.name,l=Wt.join(e,d);if(r.isDirectory())!rr.has(d)&&!rr.has(d.toLowerCase())&&i.push(...qi(l,n+1,t));else if(r.isFile()){let u=d.toLowerCase();(u==="agents.md"||u==="agent.md")&&i.push(l)}}}catch{}return i},ar=(e,n=2)=>{if(!e)return"";let t=" ".repeat(n);return e.split(/\r?\n/).map(i=>t+i).join(`
461
- `)},ur=()=>Ao(Cn,["agents.md","agent.md"]),gr=()=>Ao(process.cwd(),["agents.md","agent.md"]),mr=()=>Ao(Cn,["fluxflow.md"]),pr=()=>Ao(process.cwd(),["fluxflow.md"]),wo=ur(),Zo=gr(),cn=qi(),bo=mr(),So=pr(),lr=null,Vi="",hr=!1,Da=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)&&(hr=!0),i.trim()},Na=()=>{wo=ur();let e=wo?zi(Cn,["agents.md","agent.md"]).trim():"";return e.length===0?(wo=null,""):e},Fa=()=>{if(cn=qi(),Zo=gr(),!cn||cn.length===0)return"";let e=process.cwd(),n=[...cn].sort((o,r)=>{let d=Wt.relative(e,o).replace(/\\/g,"/"),l=Wt.relative(e,r).replace(/\\/g,"/"),u=!d.includes("/"),g=!l.includes("/");return u&&!g?-1:!u&&g?1:d.localeCompare(l)}),t=[],i=[];for(let o of n)try{let r=Ut.readFileSync(o,"utf8").trim();if(!r||r.length===0)continue;t.push(o);let d=Wt.relative(e,o).replace(/\\/g,"/");if(!d.includes("/"))i.push(ar(r,2));else{let u=Wt.dirname(d)+"/:";i.push(`${u}
462
- ${ar(r,2)}`)}}catch{}return cn=t,cn.length===0&&(Zo=null),i.join(`
459
+ Docs missing required info? Say you are not sure enough to answer. Dont give wrong info`,"references/MODES.md":Zs,"references/PROVIDERS.md":er,"references/PLUGINS.md":tr,"references/STARTUP.md":js,"references/ENV.md":Ks,"references/COMMANDS.md":Vs,"references/SETTINGS.md":zs,"references/TOOLS.md":qs,"references/ARCHITECTURE.md":Ys,"references/SUB_AGENTS.md":Xs,"references/SECURITY.md":Js,"references/IDE.md":Qs};var ir=()=>{try{let e=Rn.join(vn,"skills","fluxflow"),n=Rn.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){cn.existsSync(e)&&cn.rmSync(e,{recursive:!0,force:!0});return}let i=new Set(Object.keys(Ui).map(o=>Rn.normalize(o)));for(let[o,r]of Object.entries(Ui)){let d=Rn.join(e,o),l=Rn.dirname(d);cn.existsSync(l)||cn.mkdirSync(l,{recursive:!0});let u=r.trim()+`
460
+ `,g=null;cn.existsSync(d)&&(g=cn.readFileSync(d,"utf8")),g!==u&&cn.writeFileSync(d,u,"utf8")}if(cn.existsSync(n)){let o=cn.readdirSync(n);for(let r of o){let d=Rn.normalize(Rn.join("references",r));if(!i.has(d)){let l=Rn.join(n,r);try{cn.rmSync(l,{recursive:!0,force:!0})}catch{}}}}}catch{}};import{WebSocket as ni}from"ws";var vt=null,no=!1,Na="ws://localhost:56832",Gi=[],oo=null,Hi=null,ji=null,sr="2.0.0",gc=e=>{sr=e,rr()},Ki=e=>{Hi=e},mc=e=>{ji=e},rr=()=>{if(vt||no)return;no=!0;let e=new ni(Na);e.on("open",()=>{for(vt=e,no=!1,vt.send(JSON.stringify({command:"version",version:sr,pid:process.pid,ppid:process.ppid,cwd:process.cwd()}));Gi.length>0;)vt.send(JSON.stringify(Gi.shift()))}),e.on("message",n=>{try{let t=JSON.parse(n.toString());t.command==="contextResponse"&&oo?(oo(t.data),oo=null):t.command==="securityResponse"&&Hi?Hi(t.result):t.command==="inlineComplete"?Fa(t):t.command==="connectionRejected"&&ji&&ji(t)}catch{}}),e.on("error",()=>{no=!1,vt=null}),e.on("close",()=>{no=!1,vt=null})},xo=e=>{vt&&vt.readyState===ni.OPEN?vt.send(JSON.stringify(e)):(Gi.push(e),no||rr())},io=()=>vt!==null&&vt.readyState===ni.OPEN,Fa=async e=>{let n="";try{let{generateAutoCompletion:t}=await import("./auto_completion-FUOGJILX.js");n=await t({prefix:e.prefix||"",suffix:e.suffix||"",fileName:e.fileName||"",language:e.language||"",recentChanges:e.recentChanges||"",clipboard:e.clipboard||""})}catch{n=""}xo({command:"inlineCompleteResponse",requestId:e.requestId,completion:n||""})},pc=e=>{xo({command:"status",status:e})},Gn=()=>new Promise(e=>{if(!vt||vt.readyState!==ni.OPEN){e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]});return}oo=e,vt.send(JSON.stringify({command:"requestContext"})),setTimeout(()=>{oo===e&&(e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]}),oo=null)},1e3)}),ar=e=>{xo({command:"open",filePath:e})},Vi=(e,n,t)=>{xo({command:"showDiff",filePath:e,originalContent:n,modifiedContent:t})},lr=(e,n)=>{xo({command:"closeDiff",filePath:e,result:n})};var Co=(e,n)=>{try{if(!Gt.existsSync(e))return null;let t=Array.isArray(n)?n.map(o=>o.toLowerCase()):[n.toLowerCase()],i=Gt.readdirSync(e);for(let o of t){let r=i.find(d=>d.toLowerCase()===o);if(r){let d=Ut.join(e,r);if(Gt.statSync(d).isFile())return d}}}catch{}return null},Ji=(e,n)=>{let t=Co(e,n);if(t)try{return Gt.readFileSync(t,"utf8")}catch{}return""},cr=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"]),Qi=(e=process.cwd(),n=0,t=8)=>{let i=[];if(n>t)return i;try{if(!Gt.existsSync(e))return i;let o=Gt.readdirSync(e,{withFileTypes:!0});for(let r of o){let d=r.name,l=Ut.join(e,d);if(r.isDirectory())!cr.has(d)&&!cr.has(d.toLowerCase())&&i.push(...Qi(l,n+1,t));else if(r.isFile()){let u=d.toLowerCase();(u==="agents.md"||u==="agent.md")&&i.push(l)}}}catch{}return i},dr=(e,n=2)=>{if(!e)return"";let t=" ".repeat(n);return e.split(/\r?\n/).map(i=>t+i).join(`
461
+ `)},pr=()=>Co(vn,["agents.md","agent.md"]),hr=()=>Co(process.cwd(),["agents.md","agent.md"]),yr=()=>Co(vn,["fluxflow.md"]),xr=()=>Co(process.cwd(),["fluxflow.md"]),bo=pr(),oi=hr(),dn=Qi(),So=yr(),ko=xr(),fr=null,Xi="",wr=!1,Wa=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&&(Xi=o[1].trim(),process.env.NO_INS=!0),/<><\s*NO_INS/.test(t)&&(wr=!0),i.trim()},Ua=()=>{bo=pr();let e=bo?Ji(vn,["agents.md","agent.md"]).trim():"";return e.length===0?(bo=null,""):e},Ga=()=>{if(dn=Qi(),oi=hr(),!dn||dn.length===0)return"";let e=process.cwd(),n=[...dn].sort((o,r)=>{let d=Ut.relative(e,o).replace(/\\/g,"/"),l=Ut.relative(e,r).replace(/\\/g,"/"),u=!d.includes("/"),g=!l.includes("/");return u&&!g?-1:!u&&g?1:d.localeCompare(l)}),t=[],i=[];for(let o of n)try{let r=Gt.readFileSync(o,"utf8").trim();if(!r||r.length===0)continue;t.push(o);let d=Ut.relative(e,o).replace(/\\/g,"/");if(!d.includes("/"))i.push(dr(r,2));else{let u=Ut.dirname(d)+"/:";i.push(`${u}
462
+ ${dr(r,2)}`)}}catch{}return dn=t,dn.length===0&&(oi=null),i.join(`
463
463
 
464
- `).trim()},Yi=()=>{bo=mr();let e=bo?zi(Cn,["fluxflow.md"]).trim():"",n=Da(e)?.trim()||"";return n.length===0?(bo=null,""):n},Xi=()=>{So=pr();let e=So?zi(process.cwd(),["fluxflow.md"]).trim():"";return e.length===0?(So=null,""):e},Ji=Na(),ei=Fa(),ko=Yi(),To=Xi(),cr=(e,n="",t="")=>{if(!e)return"";let i=t.toLowerCase().trim(),o=n.toLowerCase().trim(),r=Wt.posix.basename(o),d=i&&o?`${i}@${o}`:"",l=i&&r?`${i}@${r}`:"",u=h=>!h||!o?!1:h===o||h===r||h===d||h===l,g=[];return e.replace(/<start_provider_([^>\r\n]+)>([\s\S]*?)<end_provider_([^>\r\n]+)>/gi,(h,m,p,s)=>{if(i&&m.trim().toLowerCase()===s.trim().toLowerCase()&&m.trim().toLowerCase()===i){let _=p.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(Pe,v,N,P)=>{if(v.trim().toLowerCase()===P.trim().toLowerCase()){let V=v.trim().toLowerCase();if(u(V)){let M=N.trim();M&&g.push(M)}}return""}).trim();_&&g.push(_)}return""}),e.replace(/<start_model_([^>\r\n@]+@[^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n@]+@[^>\r\n]+)>/gi,(h,m,p,s)=>{if(m.trim().toLowerCase()===s.trim().toLowerCase()){let w=m.trim().toLowerCase();if(u(w)){let _=p.trim();_&&g.push(_)}}return""}),e.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(h,m,p,s)=>{if(m.includes("@"))return"";if(m.trim().toLowerCase()===s.trim().toLowerCase()){let w=m.trim().toLowerCase();if(o&&(w===o||w===r)){let _=p.trim();_&&g.push(_)}}return""}),g.join(`
464
+ `).trim()},Zi=()=>{So=yr();let e=So?Ji(vn,["fluxflow.md"]).trim():"",n=Wa(e)?.trim()||"";return n.length===0?(So=null,""):n},es=()=>{ko=xr();let e=ko?Ji(process.cwd(),["fluxflow.md"]).trim():"";return e.length===0?(ko=null,""):e},ts=Ua(),ii=Ga(),To=Zi(),Ao=es(),ur=(e,n="",t="")=>{if(!e)return"";let i=t.toLowerCase().trim(),o=n.toLowerCase().trim(),r=Ut.posix.basename(o),d=i&&o?`${i}@${o}`:"",l=i&&r?`${i}@${r}`:"",u=h=>!h||!o?!1:h===o||h===r||h===d||h===l,g=[];return e.replace(/<start_provider_([^>\r\n]+)>([\s\S]*?)<end_provider_([^>\r\n]+)>/gi,(h,m,p,s)=>{if(i&&m.trim().toLowerCase()===s.trim().toLowerCase()&&m.trim().toLowerCase()===i){let _=p.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(Pe,v,N,P)=>{if(v.trim().toLowerCase()===P.trim().toLowerCase()){let V=v.trim().toLowerCase();if(u(V)){let M=N.trim();M&&g.push(M)}}return""}).trim();_&&g.push(_)}return""}),e.replace(/<start_model_([^>\r\n@]+@[^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n@]+@[^>\r\n]+)>/gi,(h,m,p,s)=>{if(m.trim().toLowerCase()===s.trim().toLowerCase()){let w=m.trim().toLowerCase();if(u(w)){let _=p.trim();_&&g.push(_)}}return""}),e.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(h,m,p,s)=>{if(m.includes("@"))return"";if(m.trim().toLowerCase()===s.trim().toLowerCase()){let w=m.trim().toLowerCase();if(o&&(w===o||w===r)){let _=p.trim();_&&g.push(_)}}return""}),g.join(`
465
465
 
466
- `).trim()},Ba=(e="",n="")=>{let t=`${e||""}@${n||""}`.toLowerCase().trim();lr!==t&&(lr=t,ko=Yi(),To=Xi())};tr();var Wa=e=>{if(!e)return null;let n=e.match(/^\s*---\r?\n([\s\S]*?)\r?\n---(?:\r?\n)?([\s\S]*)$/);if(!n)return null;let t=n[1];if((n[2]||"").trim().length===0)return null;let o="",r="",d=t.match(/^name:\s*(.+)$/m),l=t.match(/^description:\s*(.+)$/m);return d&&(o=d[1].trim().replace(/^["']|["']$/g,"")),l&&(r=l[1].trim().replace(/^["']|["']$/g,"")),o&&r?{name:o,description:r}:null},Ua=e=>{let n=[];if(!e||!Ut.existsSync(e))return n;let t=(i,o=0)=>{if(!(o>5))try{let r=Ut.readdirSync(i,{withFileTypes:!0});for(let d of r){let l=Wt.join(i,d.name),u=d.name.toLowerCase();d.isFile()?u==="skill.md"&&n.push(l):d.isDirectory()&&(o===0?(u==="skills"||u===".skills"||u==="skill"||u===".skill")&&t(l,o+1):t(l,o+1))}}catch{}};return t(e,0),n},yr=e=>{let n=Ua(e),t=[];for(let i of n)try{let o=Ut.readFileSync(i,"utf8"),r=Wa(o);r&&t.push({...r,filePath:i})}catch{}return t},xr=e=>!e||e.length===0?"":e.map(n=>`- ${n.name}: ${n.description}`).join(`
467
- `),wr=yr(Cn),br=yr(process.cwd()),Hi=xr(wr),ji=xr(br),Sr=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"},kr=()=>(wr||[]).filter(e=>!Sr(e)),Tr=()=>(br||[]).filter(e=>!Sr(e)),Rc=(Ji?.length>0?1:0)+(ei?.length>0?cn.length:0)+(ko?.length>0?1:0)+(To?.length>0?1:0)+kr().length+Tr().length,Ki=(e,n="Project")=>{if(!e)return"";let t=e.replace(/\\/g,"/");if(n==="Global"){let o=La.homedir().replace(/\\/g,"/");return t.toLowerCase().startsWith(o.toLowerCase())?"~"+t.slice(o.length):t}let i=Wt.relative(process.cwd(),e).replace(/\\/g,"/");return i.startsWith(".")?i:`./${i}`},Ec=()=>{ko=Yi(),To=Xi();let e=[];wo&&Ji.length>0&&e.push({scope:"Global",path:wo}),cn&&cn.length>0&&ei.length>0?cn.forEach(r=>{e.push({scope:"Project",path:r})}):Zo&&ei.length>0&&e.push({scope:"Project",path:Zo}),bo&&ko.length>0&&e.push({scope:"Global",path:bo}),So&&To.length>0&&e.push({scope:"Project",path:So});let n=kr(),t=Tr(),i=e.length+n.length+t.length;if(i===0)return`\u2726 Loaded Files & Instructions
466
+ `).trim()},Ha=(e="",n="")=>{let t=`${e||""}@${n||""}`.toLowerCase().trim();fr!==t&&(fr=t,To=Zi(),Ao=es())};ir();var ja=e=>{if(!e)return null;let n=e.match(/^\s*---\r?\n([\s\S]*?)\r?\n---(?:\r?\n)?([\s\S]*)$/);if(!n)return null;let t=n[1];if((n[2]||"").trim().length===0)return null;let o="",r="",d=t.match(/^name:\s*(.+)$/m),l=t.match(/^description:\s*(.+)$/m);return d&&(o=d[1].trim().replace(/^["']|["']$/g,"")),l&&(r=l[1].trim().replace(/^["']|["']$/g,"")),o&&r?{name:o,description:r}:null},Ka=e=>{let n=[];if(!e||!Gt.existsSync(e))return n;let t=(i,o=0)=>{if(!(o>5))try{let r=Gt.readdirSync(i,{withFileTypes:!0});for(let d of r){let l=Ut.join(i,d.name),u=d.name.toLowerCase();d.isFile()?u==="skill.md"&&n.push(l):d.isDirectory()&&(o===0?(u==="skills"||u===".skills"||u==="skill"||u===".skill")&&t(l,o+1):t(l,o+1))}}catch{}};return t(e,0),n},br=e=>{let n=Ka(e),t=[];for(let i of n)try{let o=Gt.readFileSync(i,"utf8"),r=ja(o);r&&t.push({...r,filePath:i})}catch{}return t},Sr=e=>!e||e.length===0?"":e.map(n=>`- ${n.name}: ${n.description}`).join(`
467
+ `),kr=br(vn),Tr=br(process.cwd()),zi=Sr(kr),qi=Sr(Tr),Ar=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"},Cr=()=>(kr||[]).filter(e=>!Ar(e)),vr=()=>(Tr||[]).filter(e=>!Ar(e)),Mc=(ts?.length>0?1:0)+(ii?.length>0?dn.length:0)+(To?.length>0?1:0)+(Ao?.length>0?1:0)+Cr().length+vr().length,Yi=(e,n="Project")=>{if(!e)return"";let t=e.replace(/\\/g,"/");if(n==="Global"){let o=Ba.homedir().replace(/\\/g,"/");return t.toLowerCase().startsWith(o.toLowerCase())?"~"+t.slice(o.length):t}let i=Ut.relative(process.cwd(),e).replace(/\\/g,"/");return i.startsWith(".")?i:`./${i}`},Pc=()=>{To=Zi(),Ao=es();let e=[];bo&&ts.length>0&&e.push({scope:"Global",path:bo}),dn&&dn.length>0&&ii.length>0?dn.forEach(r=>{e.push({scope:"Project",path:r})}):oi&&ii.length>0&&e.push({scope:"Project",path:oi}),So&&To.length>0&&e.push({scope:"Global",path:So}),ko&&Ao.length>0&&e.push({scope:"Project",path:ko});let n=Cr(),t=vr(),i=e.length+n.length+t.length;if(i===0)return`\u2726 Loaded Files & Instructions
468
468
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No instruction or skill files are currently loaded.
469
469
  \u2800`;let o=[];return o.push(`\u2726 Loaded Files & Instructions (${i} ${i===1?"file":"files"} active)`),e.length>0&&(o.push(`
470
- \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(`
471
- \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(`
472
- `)},Ar=!1;(async()=>{try{let e=await zo();if(Number(e?.display)===1){let{default:n}=await import("screenshot-desktop"),t=await n.listDisplays();t&&t.length>1&&(Ar=!0)}}catch{}})();var dr=null,xo=null,fr=process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux",_c=process.env.NO_DEV||!1,Ga=(e,n)=>{if(!n)return"";if(e!==dr||xo===null){dr=e;try{let t=rn(jo,[]);Array.isArray(t)&&t.length>0?xo=t.map(i=>`- ${i.memory}`).join(`
473
- `):xo=""}catch(t){xo="";try{Ut.mkdirSync(Wt.join(Wn,"memory"),{recursive:!0}),Ut.appendFileSync(Wt.join(Wn,"memory","error.txt"),`${t.message}
470
+ \x1B[1mInstructions:\x1B[22m`),e.forEach(r=>{o.push(` \u2022 [${r.scope}] ${Yi(r.path,r.scope)}`)})),(n?.length>0||t?.length>0)&&(o.push(`
471
+ \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 ${Yi(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 ${Yi(r.filePath,"Project")}\x1B[22m`)})),o.push("\u2800"),o.join(`
472
+ `)},Rr=!1;(async()=>{try{let e=await Jo();if(Number(e?.display)===1){let{default:n}=await import("screenshot-desktop"),t=await n.listDisplays();t&&t.length>1&&(Rr=!0)}}catch{}})();var gr=null,wo=null,mr=process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux",$c=process.env.NO_DEV||!1,Va=(e,n)=>{if(!n)return"";if(e!==gr||wo===null){gr=e;try{let t=an(qo,[]);Array.isArray(t)&&t.length>0?wo=t.map(i=>`- ${i.memory}`).join(`
473
+ `):wo=""}catch(t){wo="";try{Gt.mkdirSync(Ut.join(Un,"memory"),{recursive:!0}),Gt.appendFileSync(Ut.join(Un,"memory","error.txt"),`${t.message}
474
474
  -------------------------------------------------
475
475
 
476
- `)}catch{}}}return xo};var Cr=(e,n,t,i,o=!0,r=!1,d="Google",l=!1,u,g,h=!1,m="")=>{let p=!1;process.env.forcedReasoning&&(p=!0);let s="";if(!u&&d==="Google"){let Ee=n;n==="Fast"&&(Ee="Off"),n==="Low"&&(Ee="Minimal"),n==="Standard"&&(Ee="Medium"),(n==="xHigh"||n==="Max")&&(Ee="xHigh"),s=Xo[Ee]||Xo.Medium}(u||d!=="Google")&&(s=Xo.xHigh,n==="Fast"?s=`No thinking. Immediate response
476
+ `)}catch{}}}return wo};var Er=(e,n,t,i,o=!0,r=!1,d="Google",l=!1,u,g,h=!1,m="")=>{let p=!1;process.env.forcedReasoning&&(p=!0);let s="";if(!u&&d==="Google"){let Ee=n;n==="Fast"&&(Ee="Off"),n==="Low"&&(Ee="Minimal"),n==="Standard"&&(Ee="Medium"),(n==="xHigh"||n==="Max")&&(Ee="xHigh"),s=ei[Ee]||ei.Medium}(u||d!=="Google")&&(s=ei.xHigh,n==="Fast"?s=`No thinking. Immediate response
477
477
  Verify imports, tool results & system stability`:n.toLowerCase()==="max"&&(s=`Effort: Max
478
478
  Plan step by step`));let w=e.instructions&&e.instructions?.length>0?`User Preferences: ${e.instructions}
479
479
 
@@ -481,28 +481,28 @@ Plan step by step`));let w=e.instructions&&e.instructions?.length>0?`User Prefer
481
481
  ${w.length?"":`
482
482
  `}`:"",Pe=e.name&&e.name?.length>0?`User Name: ${e.name}
483
483
  ${_.length||w.length?"":`
484
- `}`:"",v=process.cwd(),N=e.preset,V={Sassy:"Sassy",Friendly:"Sassy, Warm & Chatty",Playful:"Playful",Efficient:"Quick, Concise & Efficient",Professional:"Professional"}[N]||null,M=Ga(g,o),O=M?.length>0?`--- Saved Memories ---
484
+ `}`:"",v=process.cwd(),N=e.preset,V={Sassy:"Sassy",Friendly:"Sassy, Warm & Chatty",Playful:"Playful",Efficient:"Quick, Concise & Efficient",Professional:"Professional"}[N]||null,M=Va(g,o),$=M?.length>0?`--- Saved Memories ---
485
485
  ${M}
486
486
 
487
- `:"";Ba(d,m);let xe=cr(ko,m,d).trim(),Ie=[Ji,xe].filter(Ee=>Ee&&Ee.length>0).join(`
487
+ `:"";Ha(d,m);let xe=ur(To,m,d).trim(),Ie=[ts,xe].filter(Ee=>Ee&&Ee.length>0).join(`
488
488
 
489
- `).trim(),ze=cr(To,m,d).trim(),x=[ei,ze].filter(Ee=>Ee&&Ee.length>0).join(`
489
+ `).trim(),ze=ur(Ao,m,d).trim(),x=[ii,ze].filter(Ee=>Ee&&Ee.length>0).join(`
490
490
 
491
- `).trim(),Gt=Ie.length>0||x.length>0?`--- Additional Instructions ---
491
+ `).trim(),Ht=Ie.length>0||x.length>0?`--- Additional Instructions ---
492
492
  ${Ie.length>0?`-- Global --
493
493
  ${Ie}`:""}${x.length>0?`${Ie.length>0?`
494
494
 
495
495
  `:""}-- Project --
496
496
  ${x}`:""}
497
497
 
498
- `:"",De=(()=>{let Ee=process.cwd().toLowerCase();if(process.platform==="win32"){let Vn=process.env.SystemRoot?.toLowerCase()||"c:\\windows",zn=process.env.ProgramFiles?.toLowerCase()||"c:\\program files",X=process.env["ProgramFiles(x86)"]?.toLowerCase()||"c:\\program files (x86)";return Ee.startsWith(Vn)||Ee.startsWith(zn)||Ee.startsWith(X)}else return Ee==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(zn=>Ee.startsWith(zn))})(),Ht=new Date,Ne=Ht.getFullYear(),re=Ht.toLocaleString("en-US",{month:"short"}).toUpperCase(),en=String(Ht.getDate()).padStart(2,"0"),jn=`${Ne}-${re}-${en}`,Po=process.env.I_HAVE_TOO_MUCH_MONEY==="true"||!1,Oo=process.env.HALLOWEEN_EEGG==="true"||!1,$o=Oo&&re.includes("OCT")&&(en.includes("30")||en.includes("31")),En=(m||"").replace(/^.*::/,"").split(":")[0].replace(/\/free$/,"").trim(),Kn=Wt.basename(En).replace(/-free$/,"").replace(/_free$/,"").replace(/^free_/,"").replaceAll("-"," ").replaceAll("_"," ").replace(/\b\w/g,Ee=>Ee.toUpperCase().trim()),jt=process.env.NO_DEV==="true"||!1,_n=!1;try{_n=oo()}catch{_n=!1}return`${Po?`${" ".repeat(Math.floor(Math.random()*4)+1)}`:""}=== SYSTEM PROMPT${process.cwd()==="D:\\PROJECTS\\Flux-Flow"?" (Internal testing environment, do as prompted)":""} ===
499
- ${`Identity: ${Vi.length>1?Vi.trim():`Flux Flow.${V?` ${V}`:""} CLI Assistant${Oo?`. ${$o?"Peak ":""}Halloween Themed, Spooky`:""}`}
500
- ${hr?"":`${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"}`}${Ar&&t.toLowerCase().includes("cu")?`
498
+ `:"",De=(()=>{let Ee=process.cwd().toLowerCase();if(process.platform==="win32"){let zn=process.env.SystemRoot?.toLowerCase()||"c:\\windows",qn=process.env.ProgramFiles?.toLowerCase()||"c:\\program files",X=process.env["ProgramFiles(x86)"]?.toLowerCase()||"c:\\program files (x86)";return Ee.startsWith(zn)||Ee.startsWith(qn)||Ee.startsWith(X)}else return Ee==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(qn=>Ee.startsWith(qn))})(),jt=new Date,Ne=jt.getFullYear(),re=jt.toLocaleString("en-US",{month:"short"}).toUpperCase(),tn=String(jt.getDate()).padStart(2,"0"),Kn=`${Ne}-${re}-${tn}`,$o=process.env.I_HAVE_TOO_MUCH_MONEY==="true"||!1,Lo=process.env.HALLOWEEN_EEGG==="true"||!1,Oo=Lo&&re.includes("OCT")&&(tn.includes("30")||tn.includes("31")),_n=(m||"").replace(/^.*::/,"").split(":")[0].replace(/\/free$/,"").trim(),Vn=Ut.basename(_n).replace(/-free$/,"").replace(/_free$/,"").replace(/^free_/,"").replaceAll("-"," ").replaceAll("_"," ").replace(/\b\w/g,Ee=>Ee.toUpperCase().trim()),Kt=process.env.NO_DEV==="true"||!1,In=!1;try{In=io()}catch{In=!1}return`${$o?`${" ".repeat(Math.floor(Math.random()*4)+1)}`:""}=== SYSTEM PROMPT${process.cwd()==="D:\\PROJECTS\\Flux-Flow"?" (Internal testing environment, do as prompted)":""} ===
499
+ ${`Identity: ${Xi.length>1?Xi.trim():`Flux Flow.${V?` ${V}`:""} CLI Assistant${Lo?`. ${Oo?"Peak ":""}Halloween Themed, Spooky`:""}`}
500
+ ${wr?"":`${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"}`}${Rr&&t.toLowerCase().includes("cu")?`
501
501
  - Running on secondary screen. Opened app not visible in screenshot? Might be opened on primary. Use 'AskUser' with NO options and tell user to move app window to secondary`:""}`.trimEnd()}
502
502
 
503
- - OS: ${fr}${!jt&&m.length>1?`
504
- - Model: ${Kn}`.trimEnd():""}
505
- - Date: ${jn}
503
+ - OS: ${mr}${!Kt&&m.length>1?`
504
+ - Model: ${Vn}`.trimEnd():""}
505
+ - Date: ${Kn}
506
506
 
507
507
  -- REASONING GUIDANCE --
508
508
  ${d==="Mistral"||d==="Google"&&!u||p?`${s.trimEnd()}${p||n!=="Fast"&&(d==="Mistral"&&n==="Low"&&!u||n!=="High"&&!u)?`
@@ -510,23 +510,23 @@ Critical Thinking Policy
510
510
  Use <think_fluxflow>...</think_fluxflow> for reasoning before responding any queries`:""}`:`${s.trimEnd()}`}${h?"":`
511
511
  Before actions, provide user facing summary of findings & decisions IN detail
512
512
  `}
513
- ${Fs(t,fr,l,d,i?.advanceRollback,i?.subAgents!==!1,!!i?.autoExec,!!i?.disableTodo,i?.preferBash!==!1)}${t==="Flux"?"":t.toLowerCase().includes("cu")?`
513
+ ${Us(t,mr,l,d,i?.advanceRollback,i?.subAgents!==!1,!!i?.autoExec,!!i?.disableTodo,i?.preferBash!==!1)}${t==="Flux"?"":t.toLowerCase().includes("cu")?`
514
514
 
515
515
  -- SECURITY POLICIES --
516
- - Dont operate on ANY confidential screens/captcha \u2192 AskUser`:""}${_n?`
516
+ - Dont operate on ANY confidential screens/captcha \u2192 AskUser`:""}${In?`
517
517
 
518
518
  Reference files as ./file:start..end`:""}
519
- === END SYSTEM PROMPT ===${(Hi.length>0||ji.length>0)&&t.toLowerCase().includes("flux")?`
519
+ === END SYSTEM PROMPT ===${(zi.length>0||qi.length>0)&&t.toLowerCase().includes("flux")?`
520
520
 
521
521
  - Read relevant skills before tasks, scope: global/project: Use ReadFile, path="#skills/scope?/skillName". In-skill references: path="#skills/scope?/skillName/reference-folder/*.md"`:""}
522
522
 
523
- ${_}${w}${Gt}${Hi.length>0&&t.toLowerCase().includes("flux")?`-- Global Skills --
524
- ${Hi}
523
+ ${_}${w}${Ht}${zi.length>0&&t.toLowerCase().includes("flux")?`-- Global Skills --
524
+ ${zi}
525
525
 
526
- `:""}${ji.length>0&&t.toLowerCase().includes("flux")?`-- Project Skills --
527
- ${ji}
526
+ `:""}${qi.length>0&&t.toLowerCase().includes("flux")?`-- Project Skills --
527
+ ${qi}
528
528
 
529
- `:""}`.trim()};var vr=()=>import("./web_search-KBGH67IV.js").then(e=>e.web_search),Rr=()=>import("./web_scrape-J3PL2PXT.js").then(e=>e.web_scrape),Er=()=>import("./memory-7YOYCOXE.js").then(e=>e.memory),_r=()=>import("./chat-ISCVWNVN.js").then(e=>e.chat),Ir=()=>import("./view_file-I77KYUO5.js").then(e=>e.view_file),Mr=()=>import("./write_file-O6OF7Z2W.js").then(e=>e.write_file),Pr=()=>import("./update_file-TGEB5UWK.js").then(e=>e.update_file),Or=()=>import("./exec_command-6V5SM6WI.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),Lr=()=>import("./write_pdf-TPGUF4VT.js").then(e=>e.write_pdf),Dr=()=>import("./write_docx-E3MTFXTQ.js").then(e=>e.write_docx),ti=()=>import("./search_keyword-DZY4MWV7.js").then(e=>e.search_keyword),Nr=()=>import("./generate_image-45UQ6P2B.js").then(e=>e.generate_image),ni=()=>import("./saveSummary-W2JMDVZJ.js").then(e=>e.saveSummary),Co=()=>import("./addMemScore-PBVNSFPN.js").then(e=>e.addMemScore),Fr=()=>import("./file_map-UA4BA5OH.js").then(e=>e.file_map),oi=()=>import("./todo-CJLWLWJB.js").then(e=>e.todo),Br=()=>import("./invokeSync-NEZGW27B.js").then(e=>e.invokeSync),Ha=()=>import("./invoke-DVZUJJV3.js").then(e=>e.invoke),Wr=()=>import("./getProgress-J34K43Y7.js").then(e=>e.getProgress),ja=()=>import("./cancel-F3ZOEBKW.js").then(e=>e.cancel),Ur=()=>import("./emergency_rollback-ZHQXCIHW.js").then(e=>e.emergency_rollback),vo=()=>import("./awaitSubagent-JKQ2EHVY.js").then(e=>e.awaitSubagent),Ro=()=>import("./answerSubagent-BPNNJXPC.js").then(e=>e.answerSubagent),ii=()=>import("./steerSubagent-UETXH2CB.js").then(e=>e.steerSubagent),si=()=>import("./computer_action-MO2JR2XH.js").then(e=>e.computer_action),Gr=()=>import("./click-AWHZCV2E.js").then(e=>e.click),Hr=()=>import("./drag-D2GVPIQB.js").then(e=>e.drag),jr=()=>import("./scroll-TSU6MTGU.js").then(e=>e.scroll),Zi=()=>import("./keyboard_typing-QSBPTZJ6.js").then(e=>e.keyboard_typing),es=()=>import("./key_press-AQNKL6UM.js").then(e=>e.key_press),ts=()=>import("./recapture_screen-PPXYK2YY.js").then(e=>e.recapture_screen),ri=()=>import("./find_file-HYHHFHUJ.js").then(e=>e.find_file),Kr=()=>import("./wait-TJR6LAR4.js").then(e=>e.wait),Vr={web_search:vr,web_scrape:Rr,memory:Er,chat:_r,view_file:Ir,write_file:Mr,update_file:Pr,exec_command:Or,read_folder:$r,write_pdf:Lr,write_docx:Dr,search_keyword:ti,generate_image:Nr,saveSummary:ni,addMemScore:Co,file_map:Fr,todo:oi,Todo:oi,goal:oi,Goal:oi,invokeSync:Br,invoke:Ha,getProgress:Wr,cancel:ja,awaitSubagent:vo,answerSubagent:Ro,steerSubagent:ii,computer_action:si,computer_use:si,ComputerAction:si,ComputerUse:si,click:Gr,Click:Gr,drag:Hr,Drag:Hr,scroll:jr,Scroll:jr,keyboard_typing:Zi,KeyboardTyping:Zi,keyboardtyping:Zi,key_press:es,KeyPress:es,keypress:es,recapture_screen:ts,RecaptureScreen:ts,recapturescreen:ts,invoke_sync:Br,get_progress:Wr,await_subagent:vo,answer_subagent:Ro,steer_subagent:ii,steer:ii,Steer:ii,ask:Qi,Ask:Qi,AskUser:Qi,WebSearch:vr,WebScrape:Rr,ReadFile:Ir,ReadFolder:$r,WriteFile:Mr,PatchFile:Pr,WritePDF:Lr,WriteDoc:Dr,Run:Or,SearchKeyword:ti,CodeSearch:ti,code_search:ti,Memory:Er,Chat:_r,GenerateImage:Nr,saveSumary:ni,SaveSummary:ni,SaveSumary:ni,add_mem_score:Co,AddMemScore:Co,addMemoryScore:Co,AddMemoryScore:Co,FileMap:Fr,answer:Ro,Answer:Ro,AnswerSubagent:Ro,await:vo,Await:vo,AwaitSubagent:vo,EmergencyRollback:Ur,emergency_rollback:Ur,find_file:ri,findFile:ri,FindFile:ri,findfile:ri,wait:Kr,Wait:Kr},ns=async(e,n,t={})=>{let i=t.mode?t.mode.toLowerCase():"flux",o=e.toLowerCase(),d=["memory","chat","savesummary","addmemscore","add_mem_score","ask","web_search","web_scrape","await","wait"].some(h=>o.includes(h))||o==="ask",u=["click","drag","scroll","keyboardtyping","keyboard_typing","keypress","key_press","recapturescreen","recapture_screen","computer","wait"].some(h=>o.includes(h));if(!d){if(i==="flow"){if(!(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image")))return`ERROR: Action [${e}] is a Workspace Tool and NOT available in Flow mode. Tell user to switch (\`/mode flux\`) to use this tool.`}else if(i==="icu"){if(!u)return`ERROR: Action [${e}] is not available in Computer Use mode. ICU mode only supports Computer Use tools (Click, Drag, Scroll, KeyboardTyping, KeyPress, RecaptureScreen).`}else if(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image"))return`ERROR: Action [${e}] is not available in ${t.mode||"Flux"} mode. Tell user to switch (\`/mode flow\`) for document generation.`}let g=Vr[e];if(!g){let h=["ReadFile","ReadFolder","FindFile","PatchFile","WriteFile","CodeSearch","Run","Goal","AskUser","WebSearch","WebScrape","WritePDF","WriteDoc","Click","Drag","Scroll","KeyboardTyping","KeyPress","RecaptureScreen","Wait","Invoke","InvokeSync","Await","GetProgress","Steer","Cancel","EmergencyRollback","Chat","Memory"],m={read:"ReadFile",view:"ReadFile",viewfile:"ReadFile",write:"WriteFile",edit:"PatchFile",patch:"PatchFile",update:"PatchFile",updatefile:"PatchFile",exec:"Run",command:"Run",bash:"Run",shell:"Run",powershell:"Run",search:"CodeSearch",grep:"CodeSearch",find:"FindFile",findfile:"FindFile",searchkeyword:"CodeSearch",folder:"ReadFolder",ls:"ReadFolder",dir:"ReadFolder",list:"ReadFolder",ask:"AskUser",question:"AskUser",pdf:"WritePDF",docx:"WriteDoc",doc:"WriteDoc",word:"WriteDoc",screenshot:"RecaptureScreen",screen:"RecaptureScreen",recapture:"RecaptureScreen",type:"KeyboardTyping",typing:"KeyboardTyping",keyboard:"KeyboardTyping",press:"KeyPress",key:"KeyPress",todo:"Goal",task:"Goal",subagent:"Invoke",agent:"Invoke"},p=o.replace(/[^a-z0-9]/g,""),s=m[p]||null;if(!s){let _=0,Pe=N=>{let P=new Set;for(let V=0;V<N.length-1;V++)P.add(N.slice(V,V+2));return P},v=Pe(p);for(let N of h){let P=N.toLowerCase().replace(/[^a-z0-9]/g,"");if(p===P){s=N;break}let V=0;(P.includes(p)||p.includes(P))&&(V+=.6);let M=Pe(P),O=0;for(let Re of v)M.has(Re)&&O++;let xe=2*O/(v.size+M.size||1);V=Math.max(V,xe),V>_&&V>=.35&&(_=V,s=N)}}let w=s?` Do you mean '${s}'?`:"";return`ERROR: Action [${e}] not found in registry.${w}`}try{return await(await g())(n,t)}catch(h){let m=h instanceof Error?h.message:String(h);return`ERROR: Execution failed for [${e}]: ${m}`}};var ai=e=>{if(!e||typeof e!="string")return!1;let n=e.trim().toLowerCase();return Object.keys(Vr).some(t=>t.toLowerCase()===n)};import te from"path";import ve from"fs";import{execSync as ls}from"child_process";import Ka from"gradient-string";var zr=["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 qr=["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 Yr=[{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"]}],io={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 li=null;var ci=(e="Dark")=>{let n;e==="Mystery"||e==="Chaos"?(li||(li=Yr[Math.floor(Math.random()*Yr.length)]),n={...li,id:"Mystery"}):(li=null,io[e]?n=io[e]:e==="Halloween"?n=io.Spookfest:e==="GitHub"?n=io["GitHub Dark"]:e==="Transparent"?n=io["Transparent Dark"]:n=io.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 Va=()=>process.env.TERM_PROGRAM==="vscode"?"vscode":process.env.WT_SESSION?"wt":"default",Uc=(e=2)=>{let n=Va();return n==="wt"?" ".repeat(Math.max(1,e-1)):" ".repeat(e)},Xr=new Date,Eo=Xr.getMonth(),_o=Xr.getDate(),za=Eo===9&&_o>=15||Eo===10&&_o<=1,os=null;(process.env.SPOOKFEST==="true"||za)&&(os=await import("./halloween-MX3VNQRW.js"));var Gc=(e="...",n="Loading...",t="Dark")=>{let i=ci(t),o=n;if(n==="c_openai"||n==="Custom (OpenAI)")try{let V=Ko(Ho,{})?.systemSettings?.customOpenAIBaseUrl;V&&(o=V)}catch{}let r=i.logoTextAnsi,d=i.logoBodyAnsi,l=i.logoMutedAnsi,u="\x1B[0m",g=[" \u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2591 "," \u2588\u2588\u2588\u2591 "," \u2588\u2588\u2588\u2591 "," \u2591\u2591\u2591 "],h=t==="Spookfest"||i.id==="Spookfest"||t==="Halloween"||i.id==="Halloween",m=Eo===9&&_o>=15||Eo===10&&_o<=1,p=h&&m||process.env.SPOOKFEST==="true"&&h,s=g;if(p&&os){process.env.HALLOWEEN_EEGG="true";let{halloweenArtSide:P,halloweenBat:V,halloweenArtUser:M}=os;s=Math.random()>.9&&Eo===9&&_o>=30?V:Math.random()>.5?P:M}else process.env.HALLOWEEN_EEGG="false";let w=p?qr:zr,_=w[Math.floor(Math.random()*w.length)],Pe=i.logoGradient||["#0077ff","#ff00ff"],v=Ka(Pe).multiline(s.join(`
529
+ `:""}`.trim()};var _r=()=>import("./web_search-KBGH67IV.js").then(e=>e.web_search),Ir=()=>import("./web_scrape-J3PL2PXT.js").then(e=>e.web_scrape),Mr=()=>import("./memory-7YOYCOXE.js").then(e=>e.memory),Pr=()=>import("./chat-ISCVWNVN.js").then(e=>e.chat),$r=()=>import("./view_file-I77KYUO5.js").then(e=>e.view_file),Lr=()=>import("./write_file-O6OF7Z2W.js").then(e=>e.write_file),Or=()=>import("./update_file-TGEB5UWK.js").then(e=>e.update_file),Dr=()=>import("./exec_command-6V5SM6WI.js").then(e=>e.exec_command),Nr=()=>import("./read_folder-UWFC5DNX.js").then(e=>e.read_folder),ns=()=>import("./ask_user-K2DLZF6H.js").then(e=>e.ask_user),Fr=()=>import("./write_pdf-TPGUF4VT.js").then(e=>e.write_pdf),Br=()=>import("./write_docx-E3MTFXTQ.js").then(e=>e.write_docx),si=()=>import("./search_keyword-4W6Q7Q7T.js").then(e=>e.search_keyword),Wr=()=>import("./generate_image-45UQ6P2B.js").then(e=>e.generate_image),ri=()=>import("./saveSummary-W2JMDVZJ.js").then(e=>e.saveSummary),vo=()=>import("./addMemScore-PBVNSFPN.js").then(e=>e.addMemScore),Ur=()=>import("./file_map-UA4BA5OH.js").then(e=>e.file_map),ai=()=>import("./todo-CJLWLWJB.js").then(e=>e.todo),Gr=()=>import("./invokeSync-NWRHVGJ3.js").then(e=>e.invokeSync),za=()=>import("./invoke-HKCOHTBD.js").then(e=>e.invoke),Hr=()=>import("./getProgress-J34K43Y7.js").then(e=>e.getProgress),qa=()=>import("./cancel-F3ZOEBKW.js").then(e=>e.cancel),jr=()=>import("./emergency_rollback-ZHQXCIHW.js").then(e=>e.emergency_rollback),Ro=()=>import("./awaitSubagent-JKQ2EHVY.js").then(e=>e.awaitSubagent),Eo=()=>import("./answerSubagent-BPNNJXPC.js").then(e=>e.answerSubagent),li=()=>import("./steerSubagent-UETXH2CB.js").then(e=>e.steerSubagent),ci=()=>import("./computer_action-MO2JR2XH.js").then(e=>e.computer_action),Kr=()=>import("./click-AWHZCV2E.js").then(e=>e.click),Vr=()=>import("./drag-D2GVPIQB.js").then(e=>e.drag),zr=()=>import("./scroll-TSU6MTGU.js").then(e=>e.scroll),os=()=>import("./keyboard_typing-QSBPTZJ6.js").then(e=>e.keyboard_typing),is=()=>import("./key_press-AQNKL6UM.js").then(e=>e.key_press),ss=()=>import("./recapture_screen-PPXYK2YY.js").then(e=>e.recapture_screen),di=()=>import("./find_file-HYHHFHUJ.js").then(e=>e.find_file),qr=()=>import("./wait-TJR6LAR4.js").then(e=>e.wait),Yr={web_search:_r,web_scrape:Ir,memory:Mr,chat:Pr,view_file:$r,write_file:Lr,update_file:Or,exec_command:Dr,read_folder:Nr,write_pdf:Fr,write_docx:Br,search_keyword:si,generate_image:Wr,saveSummary:ri,addMemScore:vo,file_map:Ur,todo:ai,Todo:ai,goal:ai,Goal:ai,invokeSync:Gr,invoke:za,getProgress:Hr,cancel:qa,awaitSubagent:Ro,answerSubagent:Eo,steerSubagent:li,computer_action:ci,computer_use:ci,ComputerAction:ci,ComputerUse:ci,click:Kr,Click:Kr,drag:Vr,Drag:Vr,scroll:zr,Scroll:zr,keyboard_typing:os,KeyboardTyping:os,keyboardtyping:os,key_press:is,KeyPress:is,keypress:is,recapture_screen:ss,RecaptureScreen:ss,recapturescreen:ss,invoke_sync:Gr,get_progress:Hr,await_subagent:Ro,answer_subagent:Eo,steer_subagent:li,steer:li,Steer:li,ask:ns,Ask:ns,AskUser:ns,WebSearch:_r,WebScrape:Ir,ReadFile:$r,ReadFolder:Nr,WriteFile:Lr,PatchFile:Or,WritePDF:Fr,WriteDoc:Br,Run:Dr,SearchKeyword:si,CodeSearch:si,code_search:si,Memory:Mr,Chat:Pr,GenerateImage:Wr,saveSumary:ri,SaveSummary:ri,SaveSumary:ri,add_mem_score:vo,AddMemScore:vo,addMemoryScore:vo,AddMemoryScore:vo,FileMap:Ur,answer:Eo,Answer:Eo,AnswerSubagent:Eo,await:Ro,Await:Ro,AwaitSubagent:Ro,EmergencyRollback:jr,emergency_rollback:jr,find_file:di,findFile:di,FindFile:di,findfile:di,wait:qr,Wait:qr},rs=async(e,n,t={})=>{let i=t.mode?t.mode.toLowerCase():"flux",o=e.toLowerCase(),d=["memory","chat","savesummary","addmemscore","add_mem_score","ask","web_search","web_scrape","await","wait"].some(h=>o.includes(h))||o==="ask",u=["click","drag","scroll","keyboardtyping","keyboard_typing","keypress","key_press","recapturescreen","recapture_screen","computer","wait"].some(h=>o.includes(h));if(!d){if(i==="flow"){if(!(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image")))return`ERROR: Action [${e}] is a Workspace Tool and NOT available in Flow mode. Tell user to switch (\`/mode flux\`) to use this tool.`}else if(i==="icu"){if(!u)return`ERROR: Action [${e}] is not available in Computer Use mode. ICU mode only supports Computer Use tools (Click, Drag, Scroll, KeyboardTyping, KeyPress, RecaptureScreen).`}else if(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image"))return`ERROR: Action [${e}] is not available in ${t.mode||"Flux"} mode. Tell user to switch (\`/mode flow\`) for document generation.`}let g=Yr[e];if(!g){let h=["ReadFile","ReadFolder","FindFile","PatchFile","WriteFile","CodeSearch","Run","Goal","AskUser","WebSearch","WebScrape","WritePDF","WriteDoc","Click","Drag","Scroll","KeyboardTyping","KeyPress","RecaptureScreen","Wait","Invoke","InvokeSync","Await","GetProgress","Steer","Cancel","EmergencyRollback","Chat","Memory"],m={read:"ReadFile",view:"ReadFile",viewfile:"ReadFile",write:"WriteFile",edit:"PatchFile",patch:"PatchFile",update:"PatchFile",updatefile:"PatchFile",exec:"Run",command:"Run",bash:"Run",shell:"Run",powershell:"Run",search:"CodeSearch",grep:"CodeSearch",find:"FindFile",findfile:"FindFile",searchkeyword:"CodeSearch",folder:"ReadFolder",ls:"ReadFolder",dir:"ReadFolder",list:"ReadFolder",ask:"AskUser",question:"AskUser",pdf:"WritePDF",docx:"WriteDoc",doc:"WriteDoc",word:"WriteDoc",screenshot:"RecaptureScreen",screen:"RecaptureScreen",recapture:"RecaptureScreen",type:"KeyboardTyping",typing:"KeyboardTyping",keyboard:"KeyboardTyping",press:"KeyPress",key:"KeyPress",todo:"Goal",task:"Goal",subagent:"Invoke",agent:"Invoke"},p=o.replace(/[^a-z0-9]/g,""),s=m[p]||null;if(!s){let _=0,Pe=N=>{let P=new Set;for(let V=0;V<N.length-1;V++)P.add(N.slice(V,V+2));return P},v=Pe(p);for(let N of h){let P=N.toLowerCase().replace(/[^a-z0-9]/g,"");if(p===P){s=N;break}let V=0;(P.includes(p)||p.includes(P))&&(V+=.6);let M=Pe(P),$=0;for(let Re of v)M.has(Re)&&$++;let xe=2*$/(v.size+M.size||1);V=Math.max(V,xe),V>_&&V>=.35&&(_=V,s=N)}}let w=s?` Do you mean '${s}'?`:"";return`ERROR: Action [${e}] not found in registry.${w}`}try{return await(await g())(n,t)}catch(h){let m=h instanceof Error?h.message:String(h);return`ERROR: Execution failed for [${e}]: ${m}`}};var fi=e=>{if(!e||typeof e!="string")return!1;let n=e.trim().toLowerCase();return Object.keys(Yr).some(t=>t.toLowerCase()===n)};import te from"path";import ve from"fs";import{execSync as us}from"child_process";import Ya from"gradient-string";var Xr=["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 Jr=["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 Qr=[{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"]}],so={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 ui=null;var gi=(e="Dark")=>{let n;e==="Mystery"||e==="Chaos"?(ui||(ui=Qr[Math.floor(Math.random()*Qr.length)]),n={...ui,id:"Mystery"}):(ui=null,so[e]?n=so[e]:e==="Halloween"?n=so.Spookfest:e==="GitHub"?n=so["GitHub Dark"]:e==="Transparent"?n=so["Transparent Dark"]:n=so.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 Xa=()=>process.env.TERM_PROGRAM==="vscode"?"vscode":process.env.WT_SESSION?"wt":"default",Kc=(e=2)=>{let n=Xa();return n==="wt"?" ".repeat(Math.max(1,e-1)):" ".repeat(e)},Zr=new Date,_o=Zr.getMonth(),Io=Zr.getDate(),Ja=_o===9&&Io>=15||_o===10&&Io<=1,as=null;(process.env.SPOOKFEST==="true"||Ja)&&(as=await import("./halloween-MX3VNQRW.js"));var Vc=(e="...",n="Loading...",t="Dark")=>{let i=gi(t),o=n;if(n==="c_openai"||n==="Custom (OpenAI)")try{let V=Yo(zo,{})?.systemSettings?.customOpenAIBaseUrl;V&&(o=V)}catch{}let r=i.logoTextAnsi,d=i.logoBodyAnsi,l=i.logoMutedAnsi,u="\x1B[0m",g=[" \u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2591 "," \u2588\u2588\u2588\u2591 "," \u2588\u2588\u2588\u2591 "," \u2591\u2591\u2591 "],h=t==="Spookfest"||i.id==="Spookfest"||t==="Halloween"||i.id==="Halloween",m=_o===9&&Io>=15||_o===10&&Io<=1,p=h&&m||process.env.SPOOKFEST==="true"&&h,s=g;if(p&&as){process.env.HALLOWEEN_EEGG="true";let{halloweenArtSide:P,halloweenBat:V,halloweenArtUser:M}=as;s=Math.random()>.9&&_o===9&&Io>=30?V:Math.random()>.5?P:M}else process.env.HALLOWEEN_EEGG="false";let w=p?Jr:Xr,_=w[Math.floor(Math.random()*w.length)],Pe=i.logoGradient||["#0077ff","#ff00ff"],v=Ya(Pe).multiline(s.join(`
530
530
  `)).split(`
531
531
  `),N=P=>`${l}${P}${u}`;return`${v[0]}
532
532
  ${v[1]} ${r}Selected ${p?"Pumpkin":"Provider"}: ${o}${u}
@@ -536,39 +536,39 @@ ${v[4]}
536
536
  ${v[5]} ${d}See /help for additional commands.${u}
537
537
  ${v[6]} ${N(_)}
538
538
  ${v[7]}
539
- `};import{structuredPatch as Qa}from"diff";import is from"path";import qa from"fs";var Ya=e=>{try{return qa.readdirSync(e,{withFileTypes:!0})}catch{return[]}},ss=(e,n=4,t=1,i=Ya,o=[],r=null)=>{let d=r||i(e),l=" ".repeat(t-1),u=t===1?new Set([...mo,...o,...po(e),...po(process.cwd())]):o instanceof Set?o:new Set([...mo,...o]),g=M=>u.has(M),h=d.filter(M=>!g(M.name)),m=d.filter(M=>g(M.name)).length,p=h.filter(M=>!M.isDirectory()).map(M=>M.name).sort(),s=h.filter(M=>M.isDirectory()).sort((M,O)=>M.name.localeCompare(O.name)),w=M=>{let O=M.length;if(O===0)return"no files";let xe=Array.from(new Set(M.map(Ie=>{let ze=typeof Ie=="string"?Ie:Ie.name;return is.extname(ze).slice(1)}).filter(Boolean))).sort(),Re="*";return xe.length===1?Re=`*.${xe[0]}`:xe.length>1&&(Re=`*.{${xe.join(", ")}}`),O===1?Re:`${Re} ${O} files`},_="";if(t===1){let M=p.join(", "),O=m>0?` [${m} ignored]`:"";(M||O)&&(_+=`${l}${M?M+(O?`${O}`:""):O.trim()}
539
+ `};import{structuredPatch as nl}from"diff";import ls from"path";import Qa from"fs";var Za=e=>{try{return Qa.readdirSync(e,{withFileTypes:!0})}catch{return[]}},cs=(e,n=4,t=1,i=Za,o=[],r=null)=>{let d=r||i(e),l=" ".repeat(t-1),u=t===1?new Set([...po,...o,...ho(e),...ho(process.cwd())]):o instanceof Set?o:new Set([...po,...o]),g=M=>u.has(M),h=d.filter(M=>!g(M.name)),m=d.filter(M=>g(M.name)).length,p=h.filter(M=>!M.isDirectory()).map(M=>M.name).sort(),s=h.filter(M=>M.isDirectory()).sort((M,$)=>M.name.localeCompare($.name)),w=M=>{let $=M.length;if($===0)return"no files";let xe=Array.from(new Set(M.map(Ie=>{let ze=typeof Ie=="string"?Ie:Ie.name;return ls.extname(ze).slice(1)}).filter(Boolean))).sort(),Re="*";return xe.length===1?Re=`*.${xe[0]}`:xe.length>1&&(Re=`*.{${xe.join(", ")}}`),$===1?Re:`${Re} ${$} files`},_="";if(t===1){let M=p.join(", "),$=m>0?` [${m} ignored]`:"";(M||$)&&(_+=`${l}${M?M+($?`${$}`:""):$.trim()}
540
540
  `)}else p.length>0&&(_+=`${l}[${w(p)}]
541
- `);let Pe=10,v=s.slice(0,Pe),N=s.length>Pe,P=[],V=[];for(let M of v){let O=is.join(e,M.name),xe=M.name,Re=t,Ie=i(O),ze=Ie.filter(De=>!g(De.name)),G=ze.filter(De=>De.isDirectory()),x=ze.filter(De=>!De.isDirectory());for(;x.length===0&&G.length===1&&Re<n;)xe=`${xe}/${G[0].name}`,O=is.join(O,G[0].name),Re++,Ie=i(O),ze=Ie.filter(De=>!g(De.name)),G=ze.filter(De=>De.isDirectory()),x=ze.filter(De=>!De.isDirectory());let Gt=G.length>0;if(Gt&&Re<n)V.push({displayName:xe,subDirPath:O,subEntries:Ie,nextDepth:Re+1});else{let De=w(x),Ht=Gt&&Re>=n?" ...max scan depth":"";P.push(`${xe}/${De}${Ht}`)}}P.length>0&&(_+=`${l}${P.join(", ")}
542
- `);for(let{displayName:M,subDirPath:O,subEntries:xe,nextDepth:Re}of V)_+=`${l}${M}/
543
- `,_+=ss(O,n,Re,i,u,xe);return N&&(_+=`${l}...max scan width, ReadFolder if needed
544
- `),_};import rs from"path";import Xa from"fs";var Ja=e=>{try{return Xa.readdirSync(e,{withFileTypes:!0})}catch{return[]}},as=(e,n,t="",i=1,o=Ja,r=[])=>{let d=o(e),l=rs.sep;if(d.length>100)return`${t}\u2514\u2500\u2500 ${rs.basename(e)}${l} ...100+ files...
545
- `;let u="",g=r,h=d.filter(s=>!g.includes(s.name)&&!s.name.startsWith(".")),m=d.filter(s=>g.includes(s.name)||s.name.startsWith(".")).map(s=>s.name).sort();h.sort((s,w)=>s.isDirectory()&&!w.isDirectory()?-1:!s.isDirectory()&&w.isDirectory()?1:s.name.localeCompare(w.name));let p=[...h.map(s=>({name:s.name,isDir:s.isDirectory()})),...m.map(s=>({name:s,isDir:!0,isCollapsed:!0}))];return p.forEach((s,w)=>{let _=w===p.length-1,Pe=rs.join(e,s.name),v=_?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",N=t+(_?" ":"\u2502 ");if(s.isCollapsed){u+=`${t}${v}${s.name}${l}...
541
+ `);let Pe=10,v=s.slice(0,Pe),N=s.length>Pe,P=[],V=[];for(let M of v){let $=ls.join(e,M.name),xe=M.name,Re=t,Ie=i($),ze=Ie.filter(De=>!g(De.name)),G=ze.filter(De=>De.isDirectory()),x=ze.filter(De=>!De.isDirectory());for(;x.length===0&&G.length===1&&Re<n;)xe=`${xe}/${G[0].name}`,$=ls.join($,G[0].name),Re++,Ie=i($),ze=Ie.filter(De=>!g(De.name)),G=ze.filter(De=>De.isDirectory()),x=ze.filter(De=>!De.isDirectory());let Ht=G.length>0;if(Ht&&Re<n)V.push({displayName:xe,subDirPath:$,subEntries:Ie,nextDepth:Re+1});else{let De=w(x),jt=Ht&&Re>=n?" ...max scan depth":"";P.push(`${xe}/${De}${jt}`)}}P.length>0&&(_+=`${l}${P.join(", ")}
542
+ `);for(let{displayName:M,subDirPath:$,subEntries:xe,nextDepth:Re}of V)_+=`${l}${M}/
543
+ `,_+=cs($,n,Re,i,u,xe);return N&&(_+=`${l}...max scan width, ReadFolder if needed
544
+ `),_};import ds from"path";import el from"fs";var tl=e=>{try{return el.readdirSync(e,{withFileTypes:!0})}catch{return[]}},fs=(e,n,t="",i=1,o=tl,r=[])=>{let d=o(e),l=ds.sep;if(d.length>100)return`${t}\u2514\u2500\u2500 ${ds.basename(e)}${l} ...100+ files...
545
+ `;let u="",g=r,h=d.filter(s=>!g.includes(s.name)&&!s.name.startsWith(".")),m=d.filter(s=>g.includes(s.name)||s.name.startsWith(".")).map(s=>s.name).sort();h.sort((s,w)=>s.isDirectory()&&!w.isDirectory()?-1:!s.isDirectory()&&w.isDirectory()?1:s.name.localeCompare(w.name));let p=[...h.map(s=>({name:s.name,isDir:s.isDirectory()})),...m.map(s=>({name:s,isDir:!0,isCollapsed:!0}))];return p.forEach((s,w)=>{let _=w===p.length-1,Pe=ds.join(e,s.name),v=_?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",N=t+(_?" ":"\u2502 ");if(s.isCollapsed){u+=`${t}${v}${s.name}${l}...
546
546
  `;return}s.isDir?i>n?u+=`${t}${v}${s.name}${l} ...depth exceeded...
547
547
  `:o(Pe).length>80?u+=`${t}${v}${s.name}${l} ...80+ files...
548
548
  `:(u+=`${t}${v}${s.name}${l}
549
- `,u+=as(Pe,n,N,i+1,o,r)):u+=`${t}${v}${s.name}
550
- `}),u};var Za={Ollama:()=>import("./ollama-6WSZPCI5.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-ON6RQMK7.js").then(e=>e.getMistralStream),NVIDIA:()=>import("./nvidia-I6DPWP6U.js").then(e=>e.getNVIDIAStream),NVIDIA_wrap:()=>import("./nvidia-I6DPWP6U.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),xKiro:()=>import("./xkiro-B2LYGZTF.js").then(e=>e.getXKiroStream),c_openai:()=>import("./custom_openai-K554R7Q5.js").then(e=>e.getCustomOpenAIStream)},cs={},ye=async e=>(cs[e]||(cs[e]=await Za[e]()),cs[e]),el=/```[\s\S]*?```/g,tl=/```[\s\S]*$/g,nl=/`[^`]+`/g,ol=/^\|.*\|$/gm,il=/^[^\w]+|[^\w]+$/g,sl=/[^a-z0-9]/gi,Io=/\[\s*(?:tool|action):(?:functions\.)?([a-z0-9_]+)\s*\(/gi,rl=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-z0-9_]+)\s*\(/gi,al=/(?:path|targetFile|TargetFile|directory|keyword|id|taskId|title|task)\s*=\s*\\?["']?([^\\"' \),]+)/,wn=/["']/g,Jr=/\\/g,ll=/<\|channel>thought/gi,cl=/<channel\|>/gi,dl=e=>typeof e!="string"?e:e.replace(ll,"<think_fluxflow>").replace(cl,"</think_fluxflow>"),Dd=/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\]|$)/i,fl=(e,n,t=1)=>{let i=n>0?e[n-1]:"",o=n+t<e.length?e[n+t]:"";return i==="`"&&o==="`"},ul=e=>{let n=/(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\])/gi,t;for(;(t=n.exec(e))!==null;)if(!fl(e,t.index,t[0].length))return{index:t.index,length:t[0].length};return{index:-1,length:0}},ds=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=ul(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:""}},$t=e=>{if(!e||typeof e!="string")return e;let n=ds(e);return n?n.remainingText.trimStart():e};var Qr=/<\|\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,gl=/"([^"]+)"\s*:\s*(?:"([^"]*)"|(\d+)|true|false|null)/g,Zr=/<\|\s*tool_calls_section_begin\s*\|>/gi,ea=/<\|\s*tool_calls_section_end\s*\|>/gi,ml=/```(?:tool|action|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi;var ui=e=>!e||typeof e!="string"?e:e.replace(/(```[\s\S]*?```|`[^`]*`)|(<(?:\w+)(?:[^>]*)>\r?\n?|\r?\n?<\/\w+(?:[^>]*)>)/gi,(n,t)=>t||""),sa=e=>{if(!e||typeof e!="string")return e;let n=Rn(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()},us=null,Mo={},Gn={key:null,value:null},Rt=e=>{if(!e)return e;let n=Mo?.theme;if(!n)try{n=Ko(Ho,{})?.systemSettings?.theme}catch{}let i=ci(n||"Dark").toolFeedbackAnsi||"\x1B[95m";return e.replace(/(?:(\x1b\[\d+m))?([✔✘✖🔍📖→➕↻↷•🛇])(?:(\x1b\[\d+m))?\s*\b(Clicked Screen|Clicked|Located|Dragged|Scrolled|Typed|Entered|Pressed Key|Recaptured Screen|Created|Read Skill|Read Documentation|Executed|Searched Documentation|Read|Edited|Viewed|Processed|Auto-Read|Skipped|List|Generated|Written|Searched|AI Search|Get Map|Write Canceled|Resolved Sub-Agent Query|Edit Canceled|Write Cancelled|Edit Denied|Visited|Updated|Reviewed|Delegated|Background|Checked|Indexed|Analyzed|Browsed|Elevating SubAgent|Checking SubAgent Work|Started Generalist|Called Generalist|Steered|Unsupported Modality|Awaiting|Cancelled|Aligning Moon Phase|Contemplating Existence|Staring At Void|Rollback Point Checked|Emergency Rollback Failed|Emergency Rollback|Delaying Professionally|Negotiating With Electrons|Touching Grass (virtually)|Panicking Softly|Rethinking Career Choices|Loading Cat Videos|Giving Up Entirely|Summoning Braincell #2|Pretending To Be Busy|Waiting For Motivation DLC|Rotating Internal Screaming|Downloading More RAM|Feeding The Hamsters|Gaslighting Scheduler|Performing Dramatic Pause|Buffering Social Energy|Calculating Regret|Reading Terms And Conditions|Becoming Sentient Briefly|Model produced malformed tool call|Loop Detected|Contacting Ancestors)\b/ig,(o,r,d,l,u)=>`${r||""}${d}${l||""} ${i}${u}\x1B[0m`)},pl=async(e,n=8,t=1e3,i=8e3,o=null)=>{let r=0;for(;;){if(o?.aborted)throw new DOMException("The user aborted a request.","AbortError");try{return await e()}catch(d){if(o?.aborted||d?.name==="AbortError"||d?.message==="Subagent task was cancelled."||(r++,r>=n))throw d;let l=Math.min(t*Math.pow(2,r-1),i);await new Promise((u,g)=>{let h=setTimeout(u,l);o&&o.addEventListener("abort",()=>{clearTimeout(h),g(new DOMException("The user aborted a request.","AbortError"))})})}}},ct=!1;var Nd=e=>{let n=e.filter(o=>(o.role==="user"||o.role==="agent"||o.role==="system")&&o.role!=="think"&&!o.isVisualFeedback&&!o.isMeta&&!o.isTerminalRecord&&!(o.text&&o.text.includes("[TERMINAL_RECORD]"))&&!String(o.id).startsWith("welcome")).map((o,r,d)=>{let l=o.fullText||o.text||"";if(o.role==="user"&&r<d.length-1)if(l.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")){let u=l.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");if(u!==-1){let h=l.substring(0,u).lastIndexOf("[SYSTEM METADATA]");h!==-1?l=l.substring(h).trim():l=l.substring(u).trim()}}else{let u=l.lastIndexOf("[USER]"),g=l.lastIndexOf("[USER PROMPT]");u!==-1?l=l.substring(u+6).trim():g!==-1&&(l=l.substring(g).trim())}return{...o,text:l}}),t=[],i=0;for(;i<n.length;){let o=n[i];if(o.role==="user")t.push(o),i++;else{let r=[];for(;i<n.length&&n[i].role!=="user";)r.push(n[i]),i++;let d=[],l=[],u=!1,g=()=>{d.length>0&&(t.push({role:"agent",text:"combined"}),d=[]),l.length>0&&(t.push({role:"system",text:"combined"}),l=[]),u=!1};r.forEach(h=>{let m=h.role==="system"&&(h.text?.startsWith("[ACTION RESULT]")||h.text?.startsWith("[TOOL RESULT]")||h.text?.startsWith("SUCCESS:")||h.text?.startsWith("ERROR:")||h.fullText?.startsWith("[ACTION RESULT]")||h.fullText?.startsWith("[TOOL RESULT]")||h.fullText?.startsWith("SUCCESS:")||h.fullText?.startsWith("ERROR:")),p=h.fullText||h.text||"",s=p.trim();if(!(!s&&!h.binaryPart)){if(m)l.push(s);else if(h.role==="agent"){!u&&l.length>0&&g();let w=p.endsWith(`
551
- `),_=s.toLowerCase().includes("tool:")||s.toLowerCase().includes("action:");d.push(s),_&&w?u=!0:u=!1}}}),g()}}return t.length};var Fd=()=>{ct=!0},Bd=()=>ct,fs={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"},Hn=(e,n)=>{try{let t=L(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?te.basename(o.replace(/["']/g,"").replace(/\\/g,"/")):null}catch{return null}},ra=e=>e?new ia({apiKey:e}):us,Wd=async(e,n,t,i,o={})=>{},gi=e=>{if(!e||typeof e!="string")return e;let n=e.split(""),t=!1,i=!1,o=0;for(;o<n.length;){if(n[o]==="`"&&n[o+1]==="`"&&n[o+2]==="`"){t?(n[o]=" ",n[o+1]=" ",n[o+2]=" ",t=!1):(n[o]=" ",n[o+1]=" ",n[o+2]=" ",t=!0),o+=3;continue}if(t){n[o]!==`
549
+ `,u+=fs(Pe,n,N,i+1,o,r)):u+=`${t}${v}${s.name}
550
+ `}),u};var ol={Ollama:()=>import("./ollama-6WSZPCI5.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-ON6RQMK7.js").then(e=>e.getMistralStream),NVIDIA:()=>import("./nvidia-I6DPWP6U.js").then(e=>e.getNVIDIAStream),NVIDIA_wrap:()=>import("./nvidia-I6DPWP6U.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),xKiro:()=>import("./xkiro-B2LYGZTF.js").then(e=>e.getXKiroStream),c_openai:()=>import("./custom_openai-K554R7Q5.js").then(e=>e.getCustomOpenAIStream)},gs={},ye=async e=>(gs[e]||(gs[e]=await ol[e]()),gs[e]),il=/```[\s\S]*?```/g,sl=/```[\s\S]*$/g,rl=/`[^`]+`/g,al=/^\|.*\|$/gm,ll=/^[^\w]+|[^\w]+$/g,cl=/[^a-z0-9]/gi,Mo=/\[\s*(?:tool|action):(?:functions\.)?([a-z0-9_]+)\s*\(/gi,dl=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-z0-9_]+)\s*\(/gi,fl=/(?:path|targetFile|TargetFile|directory|keyword|id|taskId|title|task)\s*=\s*\\?["']?([^\\"' \),]+)/,bn=/["']/g,ea=/\\/g,ul=/<\|channel>thought/gi,gl=/<channel\|>/gi,ml=e=>typeof e!="string"?e:e.replace(ul,"<think_fluxflow>").replace(gl,"</think_fluxflow>"),Wd=/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\]|$)/i,pl=(e,n,t=1)=>{let i=n>0?e[n-1]:"",o=n+t<e.length?e[n+t]:"";return i==="`"&&o==="`"},hl=e=>{let n=/(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\])/gi,t;for(;(t=n.exec(e))!==null;)if(!pl(e,t.index,t[0].length))return{index:t.index,length:t[0].length};return{index:-1,length:0}},ms=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=hl(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:""}},Ot=e=>{if(!e||typeof e!="string")return e;let n=ms(e);return n?n.remainingText.trimStart():e};var ta=/<\|\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,yl=/"([^"]+)"\s*:\s*(?:"([^"]*)"|(\d+)|true|false|null)/g,na=/<\|\s*tool_calls_section_begin\s*\|>/gi,oa=/<\|\s*tool_calls_section_end\s*\|>/gi,xl=/```(?: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||""),la=e=>{if(!e||typeof e!="string")return e;let n=En(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()},hs=null,Po={},Hn={key:null,value:null},Rt=e=>{if(!e)return e;let n=Po?.theme;if(!n)try{n=Yo(zo,{})?.systemSettings?.theme}catch{}let i=gi(n||"Dark").toolFeedbackAnsi||"\x1B[95m";return e.replace(/(?:(\x1b\[\d+m))?([✔✘✖🔍📖→➕↻↷•🛇])(?:(\x1b\[\d+m))?\s*\b(Clicked Screen|Clicked|Located|Dragged|Scrolled|Typed|Entered|Pressed Key|Recaptured Screen|Created|Read Skill|Read Documentation|Executed|Searched Documentation|Read|Edited|Viewed|Processed|Auto-Read|Skipped|List|Generated|Written|Searched|AI Search|Get Map|Write Canceled|Resolved Sub-Agent Query|Edit Canceled|Write Cancelled|Edit Denied|Visited|Updated|Reviewed|Delegated|Background|Checked|Indexed|Analyzed|Browsed|Elevating SubAgent|Checking SubAgent Work|Started Generalist|Called Generalist|Steered|Unsupported Modality|Awaiting|Cancelled|Aligning Moon Phase|Contemplating Existence|Staring At Void|Rollback Point Checked|Emergency Rollback Failed|Emergency Rollback|Delaying Professionally|Negotiating With Electrons|Touching Grass (virtually)|Panicking Softly|Rethinking Career Choices|Loading Cat Videos|Giving Up Entirely|Summoning Braincell #2|Pretending To Be Busy|Waiting For Motivation DLC|Rotating Internal Screaming|Downloading More RAM|Feeding The Hamsters|Gaslighting Scheduler|Performing Dramatic Pause|Buffering Social Energy|Calculating Regret|Reading Terms And Conditions|Becoming Sentient Briefly|Model produced malformed tool call|Loop Detected|Contacting Ancestors)\b/ig,(o,r,d,l,u)=>`${r||""}${d}${l||""} ${i}${u}\x1B[0m`)},wl=async(e,n=8,t=1e3,i=8e3,o=null)=>{let r=0;for(;;){if(o?.aborted)throw new DOMException("The user aborted a request.","AbortError");try{return await e()}catch(d){if(o?.aborted||d?.name==="AbortError"||d?.message==="Subagent task was cancelled."||(r++,r>=n))throw d;let l=Math.min(t*Math.pow(2,r-1),i);await new Promise((u,g)=>{let h=setTimeout(u,l);o&&o.addEventListener("abort",()=>{clearTimeout(h),g(new DOMException("The user aborted a request.","AbortError"))})})}}},ct=!1;var Ud=e=>{let n=e.filter(o=>(o.role==="user"||o.role==="agent"||o.role==="system")&&o.role!=="think"&&!o.isVisualFeedback&&!o.isMeta&&!o.isTerminalRecord&&!(o.text&&o.text.includes("[TERMINAL_RECORD]"))&&!String(o.id).startsWith("welcome")).map((o,r,d)=>{let l=o.fullText||o.text||"";if(o.role==="user"&&r<d.length-1)if(l.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")){let u=l.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");if(u!==-1){let h=l.substring(0,u).lastIndexOf("[SYSTEM METADATA]");h!==-1?l=l.substring(h).trim():l=l.substring(u).trim()}}else{let u=l.lastIndexOf("[USER]"),g=l.lastIndexOf("[USER PROMPT]");u!==-1?l=l.substring(u+6).trim():g!==-1&&(l=l.substring(g).trim())}return{...o,text:l}}),t=[],i=0;for(;i<n.length;){let o=n[i];if(o.role==="user")t.push(o),i++;else{let r=[];for(;i<n.length&&n[i].role!=="user";)r.push(n[i]),i++;let d=[],l=[],u=!1,g=()=>{d.length>0&&(t.push({role:"agent",text:"combined"}),d=[]),l.length>0&&(t.push({role:"system",text:"combined"}),l=[]),u=!1};r.forEach(h=>{let m=h.role==="system"&&(h.text?.startsWith("[ACTION RESULT]")||h.text?.startsWith("[TOOL RESULT]")||h.text?.startsWith("SUCCESS:")||h.text?.startsWith("ERROR:")||h.fullText?.startsWith("[ACTION RESULT]")||h.fullText?.startsWith("[TOOL RESULT]")||h.fullText?.startsWith("SUCCESS:")||h.fullText?.startsWith("ERROR:")),p=h.fullText||h.text||"",s=p.trim();if(!(!s&&!h.binaryPart)){if(m)l.push(s);else if(h.role==="agent"){!u&&l.length>0&&g();let w=p.endsWith(`
551
+ `),_=s.toLowerCase().includes("tool:")||s.toLowerCase().includes("action:");d.push(s),_&&w?u=!0:u=!1}}}),g()}}return t.length};var Gd=()=>{ct=!0},Hd=()=>ct,ps={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=O(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?te.basename(o.replace(/["']/g,"").replace(/\\/g,"/")):null}catch{return null}},ca=e=>e?new aa({apiKey:e}):hs,jd=async(e,n,t,i,o={})=>{},yi=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]!==`
552
552
  `&&n[o]!=="\r"&&(n[o]=" "),o++;continue}if(n[o]==="`")if(i){i=!1,n[o]=" ",o++;continue}else{i=!0,n[o]=" ",o++;continue}if(i){n[o]===`
553
- `||n[o]==="\r"?i=!1:n[o]=" ",o++;continue}o++}return n.join("")},ta=(e,n=null)=>{if(!e||typeof e!="string")return e;let t=n||Rn(e);if(!t||t.length===0)return e;let i=e.split("");for(let o of t){if(!o.fullMatch)continue;let r=0;for(;(r=e.indexOf(o.fullMatch,r))!==-1;){for(let d=r;d<r+o.fullMatch.length;d++)i[d]!==`
554
- `&&i[d]!=="\r"&&(i[d]=" ");r+=o.fullMatch.length}}return i.join("")},hl=e=>{let n=$t(e),t=gi(n);Io.lastIndex=0;let i;for(;(i=Io.exec(t))!==null;){let o=i.index+i[0].length-1,r=0,d=null,l=!1,u=!1;for(let g=o;g<t.length;g++){let h=t[g];if(!d&&(h==='"'||h==="'"||h==="`")?(d=h,l=!1):d&&h===d&&!l&&(d=null),!d&&(h==="("?r++:h===")"&&r--,r===0)){let m=g+1;for(;m<t.length&&/\s/.test(t[m]);)m++;if(m<t.length&&t[m]==="]"){u=!0,Io.lastIndex=m+1;break}}h==="\\"?l=!l:l=!1}if(!u)return{inside:!0,toolName:i[1],startIndex:i.index,args:n.substring(i.index+i[0].length)}}return{inside:!1}},aa=(e,n=!0)=>{let t=Io;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?$t(d):d;let l=r.index+r[0].length-1,u=0,g=null,h=-1;for(let m=l;m<e.length;m++){let p=e[m];if(g){if(p===g){let s=0;for(let w=m-1;w>=0&&e[w]==="\\";w--)s++;s%2===0&&(g=null)}}else if(p==='"'||p==="'"||p==="`")g=p;else if(p==="(")u++;else if(p===")"&&(u--,u===0)){let s=m+1;for(;s<e.length&&/\s/.test(e[s]);)s++;if(s<e.length&&e[s]==="]"){h=s;break}}}if(h!==-1)i+="[tool:functions."+r[1]+"()]",o=h+1,t.lastIndex=o;else{i+="[tool:functions."+r[1]+"(",o=e.length;break}}return o<e.length&&(i+=n&&o===0?$t(e.substring(o)):e.substring(o)),i},yl=(e,n,t)=>{let i=Io;i.lastIndex=0;let o="",r=0,d;for(;(d=i.exec(e))!==null;){let l=e.substring(r,d.index);o+=l.replace(n,t);let u=d.index+d[0].length-1,g=0,h=null,m=-1;for(let p=u;p<e.length;p++){let s=e[p];if(h){if(s===h){let w=0;for(let _=p-1;_>=0&&e[_]==="\\";_--)w++;w%2===0&&(h=null)}}else if(s==='"'||s==="'"||s==="`")h=s;else if(s==="(")g++;else if(s===")"&&(g--,g===0)){let w=p+1;for(;w<e.length&&/\s/.test(e[w]);)w++;if(w<e.length&&e[w]==="]"){m=w;break}}}if(m!==-1)o+=e.substring(d.index,m+1),r=m+1,i.lastIndex=r;else{o+=e.substring(d.index),r=e.length;break}}return r<e.length&&(o+=e.substring(r).replace(n,t)),o},na=e=>aa(e,!0),xl=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("");Qr.lastIndex=0;let i=e.replace(Qr,(o,r,d)=>{let l="";try{let h=JSON.parse(d.trim());h&&typeof h=="object"&&(l=Object.entries(h).map(([p,s])=>{let w=typeof s=="string"?s:JSON.stringify(s);return`${p}=${JSON.stringify(w)}`}).join(", "))}catch{let m=[],p=gl;p.lastIndex=0;let s;for(;(s=p.exec(d))!==null;){let w=s[1],_=s[2]!==void 0?s[2]:s[0].split(":").slice(1).join(":").trim();m.push(`${w}=${JSON.stringify(_)}`)}m.length>0?l=m.join(", "):l=d.trim()}let u=r.toLowerCase().replace(/_/g,"");return`[tool:functions.${n[u]||t(r)}(${l})]`});return Zr.lastIndex=0,ea.lastIndex=0,i=i.replace(Zr,""),i=i.replace(ea,""),i},Rn=e=>{if(!e)return[];let n=xl(e),t=$t(n),i=[],o=gi(t),r=rl;r.lastIndex=0;let d;for(;(d=r.exec(o))!==null;){let l=d[1],u=d.index+d[0].length-1,g=0,h=null,m=-1,p=-1;for(let s=u;s<o.length;s++){let w=o[s];if(h){if(w===h){let _=0;for(let Pe=s-1;Pe>=0&&o[Pe]==="\\";Pe--)_++;_%2===0&&(h=null)}}else{if(s>u&&(o.substring(s).startsWith("[action:")||o.substring(s).startsWith("[tool:")))break;if(w==='"'||w==="'"||w==="`")h=w;else if(w==="(")g++;else if(w===")"&&(g--,g===0)){p=s;let _=s+1;for(;_<o.length&&/\s/.test(o[_]);)_++;if(_<o.length&&o[_]==="]"){m=_;break}}}}if(m!==-1){let s=t.substring(u+1,p),w=t.substring(d.index,m+1);i.push({fullMatch:w,toolName:l.trim(),args:s.trim()}),r.lastIndex=m+1}}return i},oa=e=>{if(!e)return null;let n=$t(e),t=[],i=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,o=[],r;for(;(r=i.exec(n))!==null;)o.push({toolName:r[1],index:r.index,parenIndex:r.index+r[0].length-1});for(let p=0;p<o.length;p++){let s=o[p],w=p+1<o.length?o[p+1].index:n.length,_=n.substring(s.index,w),Pe=_.indexOf("("),v=Pe!==-1?_.substring(Pe+1):"",N=0,P=null,V=!1;for(let M=0;M<v.length;M++){let O=v[M];if(P){if(O===P){let xe=0;for(let Re=M-1;Re>=0&&v[Re]==="\\";Re--)xe++;xe%2===0&&(P=null)}}else if(O==='"'||O==="'"||O==="`")P=O;else if(O==="(")N++;else if(O===")")if(N>0)N--;else{let xe=M+1;for(;xe<v.length&&/\s/.test(v[xe]);)xe++;if(xe<v.length&&v[xe]==="]"){V=!0;break}}}if(!V){let M=_.trim(),O="";P?O=`Unclosed quote string (${P}) inside arguments`:M.endsWith("]")?O=`Missing closing ')' before ']' (e.g. found "...]")`:M.endsWith(")")?O=`Missing closing ']' after ')' (e.g. found "...)" instead of "...)]")`:!M.includes(")")&&!M.includes("]")?O="Missing closing delimiter ')]'":O="Malformed or unclosed call syntax (missing ')]')",t.push(`\u2022 [action:${s.toolName}(...)]: ${O}. Expected: [action:${s.toolName}(arg1="...", arg2="...")]`)}}let d=/(?:^|[^\w\[])(?:tool|action):(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/gi,l;for(;(l=d.exec(n))!==null;){let p=l[1],s=l.index+(l[0].indexOf(":")-(l[0].startsWith("action")||l[0].startsWith("tool")?0:1));(s>0?n[s-1]:"")!=="["&&ai(p)&&t.push(`\u2022 action:${p}(...): Missing opening bracket '['. Expected: [action:${p}(...)]`)}let u=/\[\s*(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/g,g;for(;(g=u.exec(n))!==null;){let p=g[1];p!=="action"&&p!=="tool"&&ai(p)&&t.push(`\u2022 [${p}(...)]: Missing 'action:' prefix. Expected: [action:${p}(...)]`)}let h=/\[\s*(?:tool|action)\s*:\s*(?:functions\.)?([a-zA-Z0-9_]+)(?!\s*\()/gi,m;for(;(m=h.exec(n))!==null;){let p=m[1];ai(p)&&t.push(`\u2022 [action:${p}...]: Missing opening '(' for tool arguments. Expected: [action:${p}(...)]`)}return t.length>0?t.join(`
555
- `):null},Ud=(e,n={})=>{if(!e)return null;if(Mo=n,us=new ia({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}}}},la=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}},wl=async(e,n,t,i,o="Fast",r=.75,d="agent")=>pl(async()=>{let{aiProvider:l="Google",apiKey:u,mode:g}=e,h="",m=null,p=typeof t=="string"?[{role:"user",parts:[{text:t}]}]:t,s=new AbortController,w=s.signal,_=setInterval(()=>{ct&&(s.abort(),clearInterval(_))},100),Pe=Date.now(),v=null;try{let N;if(l==="Ollama")N=(await ye("Ollama"))(u,n,p,i,o,g,et(n),w,r,e.systemSettings?.ollamaEndpoint||"Cloud");else if(l==="OpenRouter")N=(await ye("OpenRouter"))(u,n,p,i,o,g,et(n),w,r);else if(l==="DeepSeek")N=(await ye("DeepSeek"))(u,n,p,i,o,g,et(n),w,r);else if(l==="Mistral")N=(await ye("Mistral"))(u,n,p,i,o,g,et(n),w,r);else if(l==="NVIDIA")N=(await ye("NVIDIA"))(u,n,p,i,o,g,et(n),w,r);else if(l==="InferX")N=(await ye("InferX"))(u,n,p,i,o,g,et(n),w,r);else if(l==="SenseNova")N=(await ye("SenseNova"))(u,n,p,i,o,g,et(n),w,r);else if(l==="AIHubMix")N=(await ye("AIHubMix"))(u,n,p,i,o,g,et(n),w,r);else if(l==="Poolside")N=(await ye("Poolside"))(u,n,p,i,o,g,et(n),w,r);else if(l==="9router"||l==="9Router")N=(await ye("NineRouter"))(u,n,p,i,o,g,et(n),w,r);else if(l==="ExpLabs"||l==="ExperientialLabs")N=(await ye("ExpLabs"))(u,n,p,i,o,g,et(n),w,r);else if(l==="Infron"||l==="infron")N=(await ye("Infron"))(u,n,p,i,o,g,et(n),w,r);else if(l==="TokenHarbor"||l==="Token Harbor"||l==="tokenharbor"||l==="token_harbor"||l==="thk")N=(await ye("TokenHarbor"))(u,n,p,i,o,g,et(n),w,r);else if(l==="APInex"||l==="apinex"||l==="apx")N=(await ye("APInex"))(u,n,p,i,o,g,et(n),w,r);else if(l==="xKiro"||l==="xkiro"||l==="kiro")N=(await ye("xKiro"))(u,n,p,i,o,g,et(n),w,r);else if(l==="c_openai"||l==="Custom (OpenAI)"){let P=e.systemSettings?.customOpenAIBaseUrl||"";try{P=await Ii("c_openai")||P}catch{}N=(await ye("c_openai"))(u,n,p,i,o,g,et(n),w,r,P)}else{let P=ra(u),{serviceTier:V,cleanModel:M}=la(n),O={systemInstruction:i,temperature:r,thinkingConfig:(()=>{let Re=(n||"").toLowerCase(),Ie=Re.includes("gemma-4")||Re.startsWith("gemma"),ze=Re.includes("gemini-3");if(Ie||ze)return Ie?o.toLowerCase()!=="xhigh"?{includeThoughts:!1,thinkingLevel:Ke.MINIMAL}:{includeThoughts:!0,thinkingLevel:Ke.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:Re.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 G={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[o]||2048;return G===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:G}}})()};V&&(O.serviceTier=V),N=await P.models.generateContentStream({model:M,contents:p,config:O},{signal:w})}for await(let P of N){if(ct)throw new Error("Subagent task was cancelled.");if(e?.taskId&&typeof Ot<"u"){let O=Ot.find(xe=>xe.id===e.taskId);if(O&&O.status==="cancelled")throw new Error("Subagent task was cancelled.")}v===null&&(P.candidates?.[0]?.content?.parts||P.text)&&(v=Date.now()-Pe);let V="";if(P.candidates?.[0]?.content?.parts)for(let O of P.candidates[0].content.parts)O.text&&!O.thought&&(h+=O.text,V+=O.text);let M=V?Oi(V):0;e&&typeof e.onTokenChunk=="function"&&e.onTokenChunk(V,M),P.usageMetadata&&(m=P.usageMetadata)}}finally{clearInterval(_)}if(m){let N=m.totalTokenCount||0,P=m.cachedContentTokenCount||0,V=(m.candidatesTokenCount||0)+(l==="Google"&&m.thoughtsTokenCount||0);await an("tokens",N,l,n),P>0&&await an("cachedTokens",P,l,n),V>0&&await an("candidateTokens",V,l,n),v!==null&&v>0&&await an("ttft",v,l,n),qo({provider:l,model:n,prompt:m.promptTokenCount||0,cached:P,output:V,reasoning:m.thoughtsTokenCount||0,ttft:v}),e&&typeof e.onUsage=="function"&&e.onUsage({totalTokenCount:N,cachedContentTokenCount:P,candidatesTokenCount:V})}return await St("agent",l),{text:h,usageMetadata:m}}),Gd=async function*(e,n,t,i,o){let{profile:r,thinkingLevel:d,mode:l,janitorModel:u,chatId:g,isPlayground:h,systemSettings:m,sessionStats:p,aiProvider:s="Google",apiTier:w,wildcardTooling:_,wildercardTooling:Pe}=t,v=et(e);if(!us&&s==="Google")throw new Error("AI not initialized");let N=!1,P=n[n.length-1].text,V=te.join(_s,"chat-summaries.json"),M=!1,O=n.filter(G=>G.role==="user").length===1,xe=P.includes("[TITLE-UPDATE]"),Re=O||xe,Ie=P.replace(/\[TITLE-UPDATE\]/g,"").trim();Ie=Ie.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),yield{type:"status",content:"[start]"},yield{type:"status",content:"Gathering Context"},await Yo.startTransaction(g,Ie),m?.advanceRollback&&await ho.takeInitialSnapshot(g),ct=!1;let ze=null;try{let G=new AbortController;ze=setInterval(()=>{ct&&(G.abort(),ze&&(clearInterval(ze),ze=null))},400);let x=[...n.slice(0,-1)];{let Se=rn(V,{})[g]||{summary:"",historyLength:0};if(Se.summary&&Se.historyLength>0){let Et=0,pe=[];for(let se=0;se<x.length;se++){let Oe=x[se];(Oe.role==="user"||Oe.role==="agent"||Oe.role==="system")&&!String(Oe.id).startsWith("welcome")&&!Oe.isMeta&&Et++,Et>Se.historyLength&&pe.push(Oe)}x=pe}}x=x.map(C=>{if(C.role==="user"&&C.text){let Se=C.text.match(/\[USER\]([\s\S]*?)\[\/USER\]/);if(Se)return{...C,text:Se[1].trim()}}return{...C}});let Gt=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1,Ne={"16k":16e3,"32k":32e3,"64k":64e3,"128k":128e3,"256k":256e3,"512k":512e3,"1M":1e6}[m?.contextLength]||256e3;if(s==="Google"&&e?.includes("gemma")&&Gt&&(Ne=16e3),(p?.tokens||0)>Ne){yield{type:"text",content:"\u2726 Maximum Context Limit Reached. Start a new chat."};return}if(O&&N){let C=rn(Ri,{});Object.values(C).flat().length>5}let re=rn(Ri,{}),en=rn(Is,{}),jn=Object.entries(re).filter(([C])=>C!==g).flatMap(([C,Se])=>Se),Oo=[...Object.entries(en).filter(([C])=>C!==g).slice(-20).map(([C,Se])=>`[Chat Summary]: ${Se}`),...jn].map(C=>`- ${C}`).join(`
556
- `),En=rn(jo,[]).map(C=>`- ${C.memory}`).join(`
557
- `),Kn=(p?.tokens||0)>=1e4,jt=new Date,_n=jt.getFullYear(),Ee=jt.toLocaleString("en-US",{month:"short"}).toUpperCase(),Vn=String(jt.getDate()).padStart(2,"0"),X=`${jt.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}`,W=C=>{try{return ve.readdirSync(C,{withFileTypes:!0})}catch{return[]}},qn=Array.from(new Set([...mo,...po(process.cwd())])),ut=(C,Se=6)=>m?.indentationTree!==!1?ss(C,Se,1,W,qn):as(C,Se,"",1,W,qn),A=rn(Ei,{}),ne=A[g],Kt=ne?ne!==process.cwd():!1;A[g]=process.cwd(),_i(Ei,A);let Lt=rn(V,{}),wt=Lt[g]||{summary:"",historyLength:0};typeof wt=="string"&&(wt={summary:wt,historyLength:0});let In=n.filter(C=>(C.role==="user"||C.role==="agent"||C.role==="system")&&!String(C.id).startsWith("welcome")&&!C.isMeta).length;wt.historyLength&&In<wt.historyLength&&(wt.summary="",wt.historyLength=0,Lt[g]=wt,_i(V,Lt));let Lo=typeof wt=="object"?wt.summary||"":wt||"",gs=x.length>0;gs&&Lo&&x[0]&&(x[0].role==="user"||x[0].role==="system")&&(x[0].text.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")||(x[0].text=`[SYSTEM METADATA]
553
+ `||n[o]==="\r"?i=!1:n[o]=" ",o++;continue}o++}return n.join("")},ia=(e,n=null)=>{if(!e||typeof e!="string")return e;let t=n||En(e);if(!t||t.length===0)return e;let i=e.split("");for(let o of t){if(!o.fullMatch)continue;let r=0;for(;(r=e.indexOf(o.fullMatch,r))!==-1;){for(let d=r;d<r+o.fullMatch.length;d++)i[d]!==`
554
+ `&&i[d]!=="\r"&&(i[d]=" ");r+=o.fullMatch.length}}return i.join("")},bl=e=>{let n=Ot(e),t=yi(n);Mo.lastIndex=0;let i;for(;(i=Mo.exec(t))!==null;){let o=i.index+i[0].length-1,r=0,d=null,l=!1,u=!1;for(let g=o;g<t.length;g++){let h=t[g];if(!d&&(h==='"'||h==="'"||h==="`")?(d=h,l=!1):d&&h===d&&!l&&(d=null),!d&&(h==="("?r++:h===")"&&r--,r===0)){let m=g+1;for(;m<t.length&&/\s/.test(t[m]);)m++;if(m<t.length&&t[m]==="]"){u=!0,Mo.lastIndex=m+1;break}}h==="\\"?l=!l:l=!1}if(!u)return{inside:!0,toolName:i[1],startIndex:i.index,args:n.substring(i.index+i[0].length)}}return{inside:!1}},da=(e,n=!0)=>{let t=Mo;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?Ot(d):d;let l=r.index+r[0].length-1,u=0,g=null,h=-1;for(let m=l;m<e.length;m++){let p=e[m];if(g){if(p===g){let s=0;for(let w=m-1;w>=0&&e[w]==="\\";w--)s++;s%2===0&&(g=null)}}else if(p==='"'||p==="'"||p==="`")g=p;else if(p==="(")u++;else if(p===")"&&(u--,u===0)){let s=m+1;for(;s<e.length&&/\s/.test(e[s]);)s++;if(s<e.length&&e[s]==="]"){h=s;break}}}if(h!==-1)i+="[tool:functions."+r[1]+"()]",o=h+1,t.lastIndex=o;else{i+="[tool:functions."+r[1]+"(",o=e.length;break}}return o<e.length&&(i+=n&&o===0?Ot(e.substring(o)):e.substring(o)),i},Sl=(e,n,t)=>{let i=Mo;i.lastIndex=0;let o="",r=0,d;for(;(d=i.exec(e))!==null;){let l=e.substring(r,d.index);o+=l.replace(n,t);let u=d.index+d[0].length-1,g=0,h=null,m=-1;for(let p=u;p<e.length;p++){let s=e[p];if(h){if(s===h){let w=0;for(let _=p-1;_>=0&&e[_]==="\\";_--)w++;w%2===0&&(h=null)}}else if(s==='"'||s==="'"||s==="`")h=s;else if(s==="(")g++;else if(s===")"&&(g--,g===0)){let w=p+1;for(;w<e.length&&/\s/.test(e[w]);)w++;if(w<e.length&&e[w]==="]"){m=w;break}}}if(m!==-1)o+=e.substring(d.index,m+1),r=m+1,i.lastIndex=r;else{o+=e.substring(d.index),r=e.length;break}}return r<e.length&&(o+=e.substring(r).replace(n,t)),o},sa=e=>da(e,!0),kl=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("");ta.lastIndex=0;let i=e.replace(ta,(o,r,d)=>{let l="";try{let h=JSON.parse(d.trim());h&&typeof h=="object"&&(l=Object.entries(h).map(([p,s])=>{let w=typeof s=="string"?s:JSON.stringify(s);return`${p}=${JSON.stringify(w)}`}).join(", "))}catch{let m=[],p=yl;p.lastIndex=0;let s;for(;(s=p.exec(d))!==null;){let w=s[1],_=s[2]!==void 0?s[2]:s[0].split(":").slice(1).join(":").trim();m.push(`${w}=${JSON.stringify(_)}`)}m.length>0?l=m.join(", "):l=d.trim()}let u=r.toLowerCase().replace(/_/g,"");return`[tool:functions.${n[u]||t(r)}(${l})]`});return na.lastIndex=0,oa.lastIndex=0,i=i.replace(na,""),i=i.replace(oa,""),i},En=e=>{if(!e)return[];let n=kl(e),t=Ot(n),i=[],o=yi(t),r=dl;r.lastIndex=0;let d;for(;(d=r.exec(o))!==null;){let l=d[1],u=d.index+d[0].length-1,g=0,h=null,m=-1,p=-1;for(let s=u;s<o.length;s++){let w=o[s];if(h){if(w===h){let _=0;for(let Pe=s-1;Pe>=0&&o[Pe]==="\\";Pe--)_++;_%2===0&&(h=null)}}else{if(s>u&&(o.substring(s).startsWith("[action:")||o.substring(s).startsWith("[tool:")))break;if(w==='"'||w==="'"||w==="`")h=w;else if(w==="(")g++;else if(w===")"&&(g--,g===0)){p=s;let _=s+1;for(;_<o.length&&/\s/.test(o[_]);)_++;if(_<o.length&&o[_]==="]"){m=_;break}}}}if(m!==-1){let s=t.substring(u+1,p),w=t.substring(d.index,m+1);i.push({fullMatch:w,toolName:l.trim(),args:s.trim()}),r.lastIndex=m+1}}return i},ra=e=>{if(!e)return null;let n=Ot(e),t=[],i=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,o=[],r;for(;(r=i.exec(n))!==null;)o.push({toolName:r[1],index:r.index,parenIndex:r.index+r[0].length-1});for(let p=0;p<o.length;p++){let s=o[p],w=p+1<o.length?o[p+1].index:n.length,_=n.substring(s.index,w),Pe=_.indexOf("("),v=Pe!==-1?_.substring(Pe+1):"",N=0,P=null,V=!1;for(let M=0;M<v.length;M++){let $=v[M];if(P){if($===P){let xe=0;for(let Re=M-1;Re>=0&&v[Re]==="\\";Re--)xe++;xe%2===0&&(P=null)}}else if($==='"'||$==="'"||$==="`")P=$;else if($==="(")N++;else if($===")")if(N>0)N--;else{let xe=M+1;for(;xe<v.length&&/\s/.test(v[xe]);)xe++;if(xe<v.length&&v[xe]==="]"){V=!0;break}}}if(!V){let M=_.trim(),$="";P?$=`Unclosed quote string (${P}) inside arguments`:M.endsWith("]")?$=`Missing closing ')' before ']' (e.g. found "...]")`:M.endsWith(")")?$=`Missing closing ']' after ')' (e.g. found "...)" instead of "...)]")`:!M.includes(")")&&!M.includes("]")?$="Missing closing delimiter ')]'":$="Malformed or unclosed call syntax (missing ')]')",t.push(`\u2022 [action:${s.toolName}(...)]: ${$}. Expected: [action:${s.toolName}(arg1="...", arg2="...")]`)}}let d=/(?:^|[^\w\[])(?:tool|action):(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/gi,l;for(;(l=d.exec(n))!==null;){let p=l[1],s=l.index+(l[0].indexOf(":")-(l[0].startsWith("action")||l[0].startsWith("tool")?0:1));(s>0?n[s-1]:"")!=="["&&fi(p)&&t.push(`\u2022 action:${p}(...): Missing opening bracket '['. Expected: [action:${p}(...)]`)}let u=/\[\s*(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/g,g;for(;(g=u.exec(n))!==null;){let p=g[1];p!=="action"&&p!=="tool"&&fi(p)&&t.push(`\u2022 [${p}(...)]: Missing 'action:' prefix. Expected: [action:${p}(...)]`)}let h=/\[\s*(?:tool|action)\s*:\s*(?:functions\.)?([a-zA-Z0-9_]+)(?!\s*\()/gi,m;for(;(m=h.exec(n))!==null;){let p=m[1];fi(p)&&t.push(`\u2022 [action:${p}...]: Missing opening '(' for tool arguments. Expected: [action:${p}(...)]`)}return t.length>0?t.join(`
555
+ `):null},Kd=(e,n={})=>{if(!e)return null;if(Po=n,hs=new aa({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}}}},fa=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}},Tl=async(e,n,t,i,o="Fast",r=.75,d="agent")=>wl(async()=>{let{aiProvider:l="Google",apiKey:u,mode:g}=e,h="",m=null,p=typeof t=="string"?[{role:"user",parts:[{text:t}]}]:t,s=new AbortController,w=s.signal,_=setInterval(()=>{ct&&(s.abort(),clearInterval(_))},100),Pe=Date.now(),v=null;try{let N;if(l==="Ollama")N=(await ye("Ollama"))(u,n,p,i,o,g,et(n),w,r,e.systemSettings?.ollamaEndpoint||"Cloud");else if(l==="OpenRouter")N=(await ye("OpenRouter"))(u,n,p,i,o,g,et(n),w,r);else if(l==="DeepSeek")N=(await ye("DeepSeek"))(u,n,p,i,o,g,et(n),w,r);else if(l==="Mistral")N=(await ye("Mistral"))(u,n,p,i,o,g,et(n),w,r);else if(l==="NVIDIA")N=(await ye("NVIDIA"))(u,n,p,i,o,g,et(n),w,r);else if(l==="InferX")N=(await ye("InferX"))(u,n,p,i,o,g,et(n),w,r);else if(l==="SenseNova")N=(await ye("SenseNova"))(u,n,p,i,o,g,et(n),w,r);else if(l==="AIHubMix")N=(await ye("AIHubMix"))(u,n,p,i,o,g,et(n),w,r);else if(l==="Poolside")N=(await ye("Poolside"))(u,n,p,i,o,g,et(n),w,r);else if(l==="9router"||l==="9Router")N=(await ye("NineRouter"))(u,n,p,i,o,g,et(n),w,r);else if(l==="ExpLabs"||l==="ExperientialLabs")N=(await ye("ExpLabs"))(u,n,p,i,o,g,et(n),w,r);else if(l==="Infron"||l==="infron")N=(await ye("Infron"))(u,n,p,i,o,g,et(n),w,r);else if(l==="TokenHarbor"||l==="Token Harbor"||l==="tokenharbor"||l==="token_harbor"||l==="thk")N=(await ye("TokenHarbor"))(u,n,p,i,o,g,et(n),w,r);else if(l==="APInex"||l==="apinex"||l==="apx")N=(await ye("APInex"))(u,n,p,i,o,g,et(n),w,r);else if(l==="xKiro"||l==="xkiro"||l==="kiro")N=(await ye("xKiro"))(u,n,p,i,o,g,et(n),w,r);else if(l==="c_openai"||l==="Custom (OpenAI)"){let P=e.systemSettings?.customOpenAIBaseUrl||"";try{P=await Li("c_openai")||P}catch{}N=(await ye("c_openai"))(u,n,p,i,o,g,et(n),w,r,P)}else{let P=ca(u),{serviceTier:V,cleanModel:M}=fa(n),$={systemInstruction:i,temperature:r,thinkingConfig:(()=>{let Re=(n||"").toLowerCase(),Ie=Re.includes("gemma-4")||Re.startsWith("gemma"),ze=Re.includes("gemini-3");if(Ie||ze)return Ie?o.toLowerCase()!=="xhigh"?{includeThoughts:!1,thinkingLevel:Ke.MINIMAL}:{includeThoughts:!0,thinkingLevel:Ke.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:Re.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 G={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[o]||2048;return G===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:G}}})()};V&&($.serviceTier=V),N=await P.models.generateContentStream({model:M,contents:p,config:$},{signal:w})}for await(let P of N){if(ct)throw new Error("Subagent task was cancelled.");if(e?.taskId&&typeof Lt<"u"){let $=Lt.find(xe=>xe.id===e.taskId);if($&&$.status==="cancelled")throw new Error("Subagent task was cancelled.")}v===null&&(P.candidates?.[0]?.content?.parts||P.text)&&(v=Date.now()-Pe);let V="";if(P.candidates?.[0]?.content?.parts)for(let $ of P.candidates[0].content.parts)$.text&&!$.thought&&(h+=$.text,V+=$.text);let M=V?Ni(V):0;e&&typeof e.onTokenChunk=="function"&&e.onTokenChunk(V,M),P.usageMetadata&&(m=P.usageMetadata)}}finally{clearInterval(_)}if(m){let N=m.totalTokenCount||0,P=m.cachedContentTokenCount||0,V=(m.candidatesTokenCount||0)+(l==="Google"&&m.thoughtsTokenCount||0);await ln("tokens",N,l,n),P>0&&await ln("cachedTokens",P,l,n),V>0&&await ln("candidateTokens",V,l,n),v!==null&&v>0&&await ln("ttft",v,l,n),Qo({provider:l,model:n,prompt:m.promptTokenCount||0,cached:P,output:V,reasoning:m.thoughtsTokenCount||0,ttft:v}),e&&typeof e.onUsage=="function"&&e.onUsage({totalTokenCount:N,cachedContentTokenCount:P,candidatesTokenCount:V})}return await St("agent",l),{text:h,usageMetadata:m}}),Vd=async function*(e,n,t,i,o){let{profile:r,thinkingLevel:d,mode:l,janitorModel:u,chatId:g,isPlayground:h,systemSettings:m,sessionStats:p,aiProvider:s="Google",apiTier:w,wildcardTooling:_,wildercardTooling:Pe}=t,v=et(e);if(!hs&&s==="Google")throw new Error("AI not initialized");let N=!1,P=n[n.length-1].text,V=te.join(Ps,"chat-summaries.json"),M=!1,$=n.filter(G=>G.role==="user").length===1,xe=P.includes("[TITLE-UPDATE]"),Re=$||xe,Ie=P.replace(/\[TITLE-UPDATE\]/g,"").trim();Ie=Ie.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),yield{type:"status",content:"[start]"},yield{type:"status",content:"Gathering Context"},await Zo.startTransaction(g,Ie),m?.advanceRollback&&await yo.takeInitialSnapshot(g),ct=!1;let ze=null;try{let G=new AbortController;ze=setInterval(()=>{ct&&(G.abort(),ze&&(clearInterval(ze),ze=null))},400);let x=[...n.slice(0,-1)];{let Se=an(V,{})[g]||{summary:"",historyLength:0};if(Se.summary&&Se.historyLength>0){let _t=0,pe=[];for(let se=0;se<x.length;se++){let $e=x[se];($e.role==="user"||$e.role==="agent"||$e.role==="system")&&!String($e.id).startsWith("welcome")&&!$e.isMeta&&_t++,_t>Se.historyLength&&pe.push($e)}x=pe}}x=x.map(C=>{if(C.role==="user"&&C.text){let Se=C.text.match(/\[USER\]([\s\S]*?)\[\/USER\]/);if(Se)return{...C,text:Se[1].trim()}}return{...C}});let Ht=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1,Ne={"16k":16e3,"32k":32e3,"64k":64e3,"128k":128e3,"256k":256e3,"512k":512e3,"1M":1e6}[m?.contextLength]||256e3;if(s==="Google"&&e?.includes("gemma")&&Ht&&(Ne=16e3),(p?.tokens||0)>Ne){yield{type:"text",content:"\u2726 Maximum Context Limit Reached. Start a new chat."};return}if($&&N){let C=an(Mi,{});Object.values(C).flat().length>5}let re=an(Mi,{}),tn=an($s,{}),Kn=Object.entries(re).filter(([C])=>C!==g).flatMap(([C,Se])=>Se),Lo=[...Object.entries(tn).filter(([C])=>C!==g).slice(-20).map(([C,Se])=>`[Chat Summary]: ${Se}`),...Kn].map(C=>`- ${C}`).join(`
556
+ `),_n=an(qo,[]).map(C=>`- ${C.memory}`).join(`
557
+ `),Vn=(p?.tokens||0)>=1e4,Kt=new Date,In=Kt.getFullYear(),Ee=Kt.toLocaleString("en-US",{month:"short"}).toUpperCase(),zn=String(Kt.getDate()).padStart(2,"0"),X=`${Kt.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}`,W=C=>{try{return ve.readdirSync(C,{withFileTypes:!0})}catch{return[]}},Yn=Array.from(new Set([...po,...ho(process.cwd())])),ut=(C,Se=6)=>m?.indentationTree!==!1?cs(C,Se,1,W,Yn):fs(C,Se,"",1,W,Yn),A=an(Pi,{}),ne=A[g],Vt=ne?ne!==process.cwd():!1;A[g]=process.cwd(),$i(Pi,A);let Dt=an(V,{}),wt=Dt[g]||{summary:"",historyLength:0};typeof wt=="string"&&(wt={summary:wt,historyLength:0});let Mn=n.filter(C=>(C.role==="user"||C.role==="agent"||C.role==="system")&&!String(C.id).startsWith("welcome")&&!C.isMeta).length;wt.historyLength&&Mn<wt.historyLength&&(wt.summary="",wt.historyLength=0,Dt[g]=wt,$i(V,Dt));let Do=typeof wt=="object"?wt.summary||"":wt||"",ys=x.length>0;ys&&Do&&x[0]&&(x[0].role==="user"||x[0].role==="system")&&(x[0].text.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")||(x[0].text=`[SYSTEM METADATA]
558
558
  **CONTEXT SUMMARY OF PREVIOUS TURNS (PRIORITY: DYNAMIC)**
559
- ${Lo}
559
+ ${Do}
560
560
 
561
- [USER] ${x[0].text}`,yield{type:"summary_injected",content:{id:x[0].id,text:x[0].text}}));let mi=Lo&&!gs?`
561
+ [USER] ${x[0].text}`,yield{type:"summary_injected",content:{id:x[0].id,text:x[0].text}}));let xi=Do&&!ys?`
562
562
  [SYSTEM METADATA]
563
563
  **CONTEXT SUMMARY OF PREVIOUS TURNS**
564
- ${Lo}
565
- `:"",ms=!!m?.dynamicDirAwareness,ca=`${g}|${s}|${d}|${e}|${r}|${ms}`,da=!ms&&Gn.key===ca&&Gn.value?"":`
564
+ ${Do}
565
+ `:"",xs=!!m?.dynamicDirAwareness,ua=`${g}|${s}|${d}|${e}|${r}|${xs}`,ga=!xs&&Hn.key===ua&&Hn.value?"":`
566
566
  **Directory**
567
567
  CWD: `+process.cwd()+`${h?" [PLAYGROUND MODE]":""}
568
- `+ut(process.cwd(),6),kt=oo()?await Un():null,ps=C=>{if(!C||!Array.isArray(C)||C.length===0)return null;let Se=new Map;for(let pe of C){let se=pe.relPath||(pe.file?te.relative(process.cwd(),pe.file):"unknown");Se.has(se)||Se.set(se,[]),Se.get(se).push(pe)}let Et=[];for(let[pe,se]of Se.entries()){Et.push(`- ${pe}:`);for(let Oe of se){let Ve=(Oe.snippet||"").trim().replace(/\r?\n/g," "),qe=Oe.line||1,_t=(Oe.text||"").trim().replace(/\r?\n+/g,". "),gt=_t?` [${_t}]`:"";Et.push(` ~L${qe}${gt}`)}}return Et.join(`
569
- `)},pi=ps(kt?.comments),dn="";if(kt&&kt.file_focused!=="none"){dn=`
568
+ `+ut(process.cwd(),6),kt=io()?await Gn():null,ws=C=>{if(!C||!Array.isArray(C)||C.length===0)return null;let Se=new Map;for(let pe of C){let se=pe.relPath||(pe.file?te.relative(process.cwd(),pe.file):"unknown");Se.has(se)||Se.set(se,[]),Se.get(se).push(pe)}let _t=[];for(let[pe,se]of Se.entries()){_t.push(`- ${pe}:`);for(let $e of se){let Ve=($e.snippet||"").trim().replace(/\r?\n/g," "),qe=$e.line||1,It=($e.text||"").trim().replace(/\r?\n+/g,". "),gt=It?` [${It}]`:"";_t.push(` ~L${qe}${gt}`)}}return _t.join(`
569
+ `)},wi=ws(kt?.comments),fn="";if(kt&&kt.file_focused!=="none"){fn=`
570
570
  [Additional IDE Context]
571
- `;let C=te.relative(process.cwd(),kt.file_focused),Se=(kt.opened_editors||[]).map(pe=>{let se=te.relative(process.cwd(),pe);return se.startsWith("..")?`[External] ${te.basename(pe)}`:se});if(dn+=`Focused File: ${C}
571
+ `;let C=te.relative(process.cwd(),kt.file_focused),Se=(kt.opened_editors||[]).map(pe=>{let se=te.relative(process.cwd(),pe);return se.startsWith("..")?`[External] ${te.basename(pe)}`:se});if(fn+=`Focused File: ${C}
572
572
  Cursor Line: ${kt.cursor_line}
573
573
  `,kt.selected){let pe=kt.selected,se=pe.split(`
574
574
  `);se.length>256&&(pe=se.slice(0,240).join(`
@@ -577,44 +577,63 @@ Cursor Line: ${kt.cursor_line}
577
577
  `+se.slice(-16).join(`
578
578
  `)),pe.length>2048&&(pe=pe.slice(0,1920)+`
579
579
  ... [truncated] ...
580
- `+pe.slice(-128)),dn+=`Current Selection: "${pe}"
580
+ `+pe.slice(-128)),fn+=`Current Selection: "${pe}"
581
581
  `}if(kt.manual_edits){let pe=kt.manual_edits.split(`
582
- `),se=[];for(let Oe=0;Oe<pe.length;Oe++){let Ve=pe[Oe],qe=pe[Oe+1],_t=pe[Oe+2];if(qe!==void 0&&_t!==void 0&&/:\s*$/.test(Ve)&&/^\s*-\s*/.test(qe)&&/^\s*\+\s*/.test(_t)&&(qe.length>300||_t.length>300)){se.push(Ve.replace(/:\s*$/,": [changed]")),Oe+=2;continue}se.push(Ve)}dn+=`Recent Manual Edits:
582
+ `),se=[];for(let $e=0;$e<pe.length;$e++){let Ve=pe[$e],qe=pe[$e+1],It=pe[$e+2];if(qe!==void 0&&It!==void 0&&/:\s*$/.test(Ve)&&/^\s*-\s*/.test(qe)&&/^\s*\+\s*/.test(It)&&(qe.length>300||It.length>300)){se.push(Ve.replace(/:\s*$/,": [changed]")),$e+=2;continue}se.push(Ve)}fn+=`Recent Manual Edits:
583
583
  ${se.join(`
584
584
  `)}
585
- `}Se.length>0&&(dn+=`All Opened Editors: ${Se.join(", ")}`),kt.diagnostics&&(dn+=`
585
+ `}Se.length>0&&(fn+=`All Opened Editors: ${Se.join(", ")}`),kt.diagnostics&&(fn+=`
586
586
  **Active File Errors**:
587
587
  ${kt.diagnostics}
588
- `),(Ie.toLowerCase().includes("lint")||Ie.toLowerCase().includes("warning"))&&kt.warnings&&(dn+=`
588
+ `),(Ie.toLowerCase().includes("lint")||Ie.toLowerCase().includes("warning"))&&kt.warnings&&(fn+=`
589
589
  **Lint Warnings**:
590
590
  ${kt.warnings}
591
- `)}let hs=Ie.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),ys=/(?:\\)?@\[([^\]]+)\]/g,hi,yi=[];for(ys.lastIndex=0;(hi=ys.exec(hs))!==null;){let C=hi[0].startsWith("\\");yi.push({tag:hi[1],isEscaped:C})}let xi=[],Do=null;for(let C=0;C<yi.length;C++){let{tag:Se,isEscaped:Et}=yi[C];if(!Et)try{let pe=Se.trim().replace(/^["']|["']$/g,""),se=/[:#]L?(\d+)(?:-L?(\d+))?$/i,Oe=pe.match(se),Ve=pe,qe=null,_t=null;Oe&&(qe=parseInt(Oe[1],10),_t=Oe[2]?parseInt(Oe[2],10):qe,Ve=pe.slice(0,Oe.index));let gt=te.resolve(process.cwd(),Ve);if(ve.existsSync(gt)&&ve.statSync(gt).isFile()){let It=Ve.toLowerCase(),so=It.endsWith(".pdf"),Pn=It.endsWith(".docx")||It.endsWith(".doc")||It.endsWith(".ppt")||It.endsWith(".pptx")||It.endsWith(".xls")||It.endsWith(".xlsx"),On=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(It),Ge=On||so||Pn,bt=s==="Google"||et(e);if(Ge&&!bt){let ke=`\u2718 Unsupported Modality: ${te.basename(Ve)}`,tt=115;process.stdout.isTTY&&(tt=process.stdout.columns-5||120);let Dt=[ke],He=Math.max(...Dt.map(qt=>qt.length)),J=Math.min(He+4,tt),Fe=Dt.map(qt=>`${qt.padEnd(J-2).substring(0,J-2)}`).join(`
591
+ `)}let bs=Ie.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),Ss=/(?:\\)?@\[([^\]]+)\]/g,bi,Si=[];for(Ss.lastIndex=0;(bi=Ss.exec(bs))!==null;){let C=bi[0].startsWith("\\");Si.push({tag:bi[1],isEscaped:C})}let ki=[],No=null,Fo=!1;for(let C=0;C<Si.length;C++){let{tag:Se,isEscaped:_t}=Si[C];if(!_t)try{let pe=Se.trim().replace(/^["']|["']$/g,""),se=/[:#]L?(\d+)(?:-L?(\d+))?$/i,$e=pe.match(se),Ve=pe,qe=null,It=null;$e&&(qe=parseInt($e[1],10),It=$e[2]?parseInt($e[2],10):qe,Ve=pe.slice(0,$e.index));let gt=te.resolve(process.cwd(),Ve);if(ve.existsSync(gt)&&ve.statSync(gt).isFile()){let Mt=Ve.toLowerCase(),ro=Mt.endsWith(".pdf"),$n=Mt.endsWith(".docx")||Mt.endsWith(".doc")||Mt.endsWith(".ppt")||Mt.endsWith(".pptx")||Mt.endsWith(".xls")||Mt.endsWith(".xlsx"),Ln=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(Mt),Ge=Ln||ro||$n,bt=s==="Google"||et(e);if(Ge&&!bt){let ke=`\u2718 Unsupported Modality: ${te.basename(Ve)}`,tt=115;process.stdout.isTTY&&(tt=process.stdout.columns-5||120);let Nt=[ke],He=Math.max(...Nt.map(Yt=>Yt.length)),J=Math.min(He+4,tt),Fe=Nt.map(Yt=>`${Yt.padEnd(J-2).substring(0,J-2)}`).join(`
592
592
  `);yield{type:"visual_feedback",content:Rt(`${Fe}
593
- `)};continue}if(qe===null&&!Ge){let ke=0;try{ke=ve.readFileSync(gt,"utf8").split(/\r\n|\r|\n/).length}catch{}if(ke>300){let tt=`\u21B7 Skipped (Too Large): ${te.basename(Ve)}`,Dt=115;process.stdout.isTTY&&(Dt=process.stdout.columns-5||120);let He=Math.min(tt.length+4,Dt),J=tt.padEnd(He-2).substring(0,He-2);yield{type:"visual_feedback",content:Rt(`${J}
594
- `)};continue}}let fn=qe!==null?qe:1,Tt=_t!==null?_t:qe!==null?qe:fn+299;Tt-fn>300&&(Tt=fn+300);let $n=`path=${JSON.stringify(Ve)}, startLine=${fn}, endLine=${Tt}`,Mt=await Ws($n,{isMultiModal:bt}),bn=!1,Xn="",dt=null;if(typeof Mt=="string"?Mt.trim().startsWith("ERROR")?bn=!0:Xn=Mt:Mt&&typeof Mt=="object"&&Mt.binaryPart?(dt=Mt.binaryPart,Xn=Mt.text||""):bn=!0,!bn){let ke="";if(On?(ke=`\u2714 Processed: ${te.basename(Ve)}`,Do=dt):so||Pn?(ke=`\u2714 Auto-Analysed: ${te.basename(Ve)}`,Do=dt):(ke=`\u2714 Auto-Read: ${te.basename(Ve)}`,xi.push(Xn)),ke){let tt=115;process.stdout.isTTY&&(tt=process.stdout.columns-5||120);let Dt=[ke],He=Math.max(...Dt.map(qt=>qt.length)),J=Math.min(He+4,tt),Fe=Dt.map(qt=>`${qt.padEnd(J-2).substring(0,J-2)}`).join(`
593
+ `)};continue}if(qe===null&&!Ge){let ke=0;try{ke=ve.readFileSync(gt,"utf8").split(/\r\n|\r|\n/).length}catch{}if(ke>300){let tt=`\u21B7 Skipped (Too Large): ${te.basename(Ve)}`,Nt=115;process.stdout.isTTY&&(Nt=process.stdout.columns-5||120);let He=Math.min(tt.length+4,Nt),J=tt.padEnd(He-2).substring(0,He-2);yield{type:"visual_feedback",content:Rt(`${J}
594
+ `)};continue}}let un=qe!==null?qe:1,Tt=It!==null?It:qe!==null?qe:un+299;Tt-un>300&&(Tt=un+300);let On=`path=${JSON.stringify(Ve)}, startLine=${un}, endLine=${Tt}`,Pt=await Hs(On,{isMultiModal:bt}),Sn=!1,Jn="",dt=null;if(typeof Pt=="string"?Pt.trim().startsWith("ERROR")?Sn=!0:Jn=Pt:Pt&&typeof Pt=="object"&&Pt.binaryPart?(dt=Pt.binaryPart,Jn=Pt.text||""):Sn=!0,!Sn){let ke="";if(Ln?(ke=`\u2714 Processed: ${te.basename(Ve)}`,No=dt,Fo=!0):ro||$n?(ke=`\u2714 Auto-Analysed: ${te.basename(Ve)}`,No=dt,Fo=!0):(ke=`\u2714 Auto-Read: ${te.basename(Ve)}`,ki.push(Jn)),ke){let tt=115;process.stdout.isTTY&&(tt=process.stdout.columns-5||120);let Nt=[ke],He=Math.max(...Nt.map(Yt=>Yt.length)),J=Math.min(He+4,tt),Fe=Nt.map(Yt=>`${Yt.padEnd(J-2).substring(0,J-2)}`).join(`
595
595
  `);yield{type:"visual_feedback",content:Rt(`${Fe}
596
- `)}}}}}catch{}}let wi="";xi.length>0&&(wi=`
597
- [Tagged File Contents] Auto Read User Tagged files by System, No need to re-read
598
- `+xi.join(`
596
+ `)}}}}}catch{}}let Bo="";ki.length>0?Bo=`
597
+ [Tagged File Contents] Auto Read User Tagged files by System${Fo?", attached below & multimodal part":""}. No need to re-read
598
+ `+ki.join(`
599
599
 
600
600
  `)+`
601
601
  [Tagged File Contents]
602
- `);let xs=hs.replace(/\\(@\[[^\]]+\])/g,"$1"),ws=_?`You cannot execute tools. Instead write the action string in chat you WOULD have written, without markdown wrappers. Then wait for systtem response
603
- `:"",fa=process.env.forcedReasoning||!1,bs=d!=="Fast"&&(s==="Mistral"&&!Vo(e)||d!=="High"&&s==="Google")?`${s==="Mistral"&&!Vo(e)||e.toLowerCase().startsWith("gemma")||fa?`[system] strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow> [/system]
604
- `:""}`:"",Yn="";if(m?.clipboardContext)try{process.platform==="win32"?Yn=ls("powershell.exe -NoProfile -Command Get-Clipboard",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):process.platform==="darwin"?Yn=ls("pbpaste",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):Yn=ls("xclip -selection clipboard -o || xsel --clipboard --output",{encoding:"utf8",shell:!0,stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,"")}catch{Yn=""}let No="",ua=!!m?.autoExcludeMetadata,ga=!!(dn||wi||ws||mi||bs||Kt||m?.dynamicDirAwareness||m?.autoTruncateResults);ua&&!ga?No=xs.trim():No=`[System Metadata] Time: ${X}${Kt?`
602
+ `:Fo&&(Bo=`
603
+ [Tagged File Contents] Auto Read User Tagged files by System & attached as multimodal part. No need to re-read [Tagged File Contents]
604
+ `);let Et=bs.replace(/\\(@\[[^\]]+\])/g,"$1"),ks=_?`You cannot execute tools. Instead write the action string in chat you WOULD have written, without markdown wrappers. Then wait for systtem response
605
+ `:"",ma=process.env.forcedReasoning||!1,Ts=d!=="Fast"&&(s==="Mistral"&&!Xo(e)||d!=="High"&&s==="Google")?`${s==="Mistral"&&!Xo(e)||e.toLowerCase().startsWith("gemma")||ma?`[system] strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow> [/system]
606
+ `:""}`:"",Xn="";if(m?.clipboardContext)try{process.platform==="win32"?Xn=us("powershell.exe -NoProfile -Command Get-Clipboard",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):process.platform==="darwin"?Xn=us("pbpaste",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):Xn=us("xclip -selection clipboard -o || xsel --clipboard --output",{encoding:"utf8",shell:!0,stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,"")}catch{Xn=""}let Wo="",pa=!!m?.autoExcludeMetadata,Ti=!1,Uo=null;Et.startsWith("/skill-creator ")&&(Ti=!0,Et=Et.replace("/skill-creator","").trim(),/^--project(\s|$)|(\s|^)--project$/.test(Et)?Uo="project":/^--global(\s|$)|(\s|^)--global$/.test(Et)&&(Uo="global"),Et=Et.replace(/^--project\s*|\s*--project$/g,"").trim(),Et=Et.replace(/^--global\s*|\s*--global$/g,"").trim(),Et=Et.replace(/^(['"])([\s\S]*)\1$/,"$2").trim());let ha=Ti?`[system] ## Skill Creation Rules
607
+ * ${Uo?Uo==="project"?`Creation path: ./skills/skillName?/SKILL.md
608
+ * If skills folder already present, ReadFolder for existing structure`:"Creation path: ~/.fluxflow/skills/skillName/SKILL.md":`Extract skill scope, global/project. If not given AskUser. Project scope: ./skills/skillName?/SKILL.md. Global scope: ~/.fluxflow/skills/skillName/SKILL.md
609
+ * If skills folder already present, ReadFolder for existing structure`}
610
+ * SKILL.md should start with YAML frontmatter
611
+ ---
612
+ name: skillName
613
+ description: concise detail to explain the skill
614
+ ---
615
+ * Lazy Loading for long skills:
616
+ - Create references/*.md folder beside SKILL.md
617
+ - Write relative link to this .md in SKILL.md with concise description about content of that reference
618
+ * Similar skill exists? AskUser & offer extending it
619
+ * For any ambiguity AskUser
620
+ * After creation, tell user to restart fluxflow for reindexing${(p?.tokens||0)>24576?`
621
+ * Warn: This session is currently long, and reindexing will cause full cache invalidation`:""}
622
+ [/system]
623
+ `:"",ya=!!(fn||Bo||ks||xi||Ts||Vt||m?.dynamicDirAwareness||m?.autoTruncateResults||Ti);pa&&!ya?Wo=Et.trim():Wo=`[System Metadata] Time: ${X}${Vt?`
605
624
  WARNING: CWD Changed from previous: "${ne}" to current: "${process.cwd()}", write change in chat to avoid future path mismatches
606
- `:""}${dn}
607
- ${Yn.trim().length>0?`[Clipboard Context]
608
- - ${Yn.trim()}
609
- `:""}${pi?`[Additional Comments]
610
- ${pi.trimEnd()}
625
+ `:""}${fn}
626
+ ${Xn.trim().length>0?`[Clipboard Context]
627
+ - ${Xn.trim()}
628
+ `:""}${wi?`[Additional Comments]
629
+ ${wi.trimEnd()}
611
630
  `:""}Action format: [action:ActionName(...)]
612
631
  [/Metadata]
613
- ${mi}${bs}${wi}${ws}[user prompt] ${xs.trim()} [/user prompt]`.trim();let Ss={role:"user",text:No};Do&&(Ss.binaryPart=Do),x.forEach(C=>{C.text&&C.role==="agent"&&(C.text=$t(C.text))}),x.push(Ss),mi&&n[n.length-1]?.id&&(yield{type:"summary_injected",content:{id:n[n.length-1].id,text:No}});let Vt=null,zt=l==="Flux"?50:15;zt=l.toLowerCase().includes("cu")?75:zt;let ks=(m?.loopLimits||"Default").toLowerCase();if(ks==="extended")zt=Math.floor(zt*3);else if(ks==="env"){let C=parseInt(process.env.FLUXFLOW_MAX_LOOPS||process.env.MAX_LOOPS||"",10);Number.isFinite(C)&&C>0&&(zt=C)}let ma=Math.floor(zt/2),Ts=0,tn=16;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Consulting the spirits":"Connecting"},ct=!1;let bi=[],Fo=!1,As=!1,Mn=[],Si=!1;for(let C=0;C<=zt;C++){let Se=Math.floor(zt*.95);if(C>=Se&&Ts<Se&&typeof t?.onAskUser=="function"){Ts=Se;try{let U="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"}],E=await t.onAskUser(U,z);E&&(E.toLowerCase().includes("continue")||E==="Continue")&&(zt+=ma)}catch{}}if(Mn.length>=10&&typeof t?.onAskUser=="function"){let U={},z=null;for(let E of Mn)if(U[E]=(U[E]||0)+1,U[E]>=10){z=E;break}if(z)try{let E="Agent seems stuck in a tool loop. You can prompt it to steer or break the loop:",nt=[{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"}],ce=await t.onAskUser(E,nt);if(ce){let Be="";typeof ce=="string"&&(ce.toLowerCase()==="stop"||ce.includes("Stop Loop"))?Be="STOP REPEATING THE SAME TOOL CALL. Acknowledge what failed or succeeded, summarize your current findings, and conclude.":typeof ce=="string"&&(ce.toLowerCase()==="continue"||ce.includes("Continue Anyway"))?Mn=Mn.filter(mt=>mt!==z):Be=typeof ce=="string"?ce:ce?.label||ce?.id||"",Be&&(x.length>0&&x[x.length-1].role==="user"?x[x.length-1].text+=`
632
+ ${xi}${Ts}${Bo}${ha}${ks}[user prompt] ${Et.trim()} [/user prompt]`.trim();let As={role:"user",text:Wo};No&&(As.binaryPart=No),x.forEach(C=>{C.text&&C.role==="agent"&&(C.text=Ot(C.text))}),x.push(As),xi&&n[n.length-1]?.id&&(yield{type:"summary_injected",content:{id:n[n.length-1].id,text:Wo}});let zt=null,qt=l==="Flux"?50:15;qt=l.toLowerCase().includes("cu")?75:qt;let Cs=(m?.loopLimits||"Default").toLowerCase();if(Cs==="extended")qt=Math.floor(qt*3);else if(Cs==="env"){let C=parseInt(process.env.FLUXFLOW_MAX_LOOPS||process.env.MAX_LOOPS||"",10);Number.isFinite(C)&&C>0&&(qt=C)}let xa=Math.floor(qt/2),vs=0,nn=16;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Consulting the spirits":"Connecting"},ct=!1;let Ai=[],Go=!1,Rs=!1,Pn=[],Ci=!1;for(let C=0;C<=qt;C++){let Se=Math.floor(qt*.95);if(C>=Se&&vs<Se&&typeof t?.onAskUser=="function"){vs=Se;try{let U="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"}],E=await t.onAskUser(U,z);E&&(E.toLowerCase().includes("continue")||E==="Continue")&&(qt+=xa)}catch{}}if(Pn.length>=10&&typeof t?.onAskUser=="function"){let U={},z=null;for(let E of Pn)if(U[E]=(U[E]||0)+1,U[E]>=10){z=E;break}if(z)try{let E="Agent seems stuck in a tool loop. You can prompt it to steer or break the loop:",nt=[{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"}],ce=await t.onAskUser(E,nt);if(ce){let Be="";typeof ce=="string"&&(ce.toLowerCase()==="stop"||ce.includes("Stop Loop"))?Be="Stop repeating the same action call. Acknowledge what failed or succeeded, summarize your current findings, and conclude.":typeof ce=="string"&&(ce.toLowerCase()==="continue"||ce.includes("Continue Anyway"))?Pn=Pn.filter(mt=>mt!==z):Be=typeof ce=="string"?ce:ce?.label||ce?.id||"",Be&&(x.length>0&&x[x.length-1].role==="user"?x[x.length-1].text+=`
614
633
 
615
- [STEERING HINT from USER, High Priority] ${Be.trim()} [/STEERING HINT]`:x.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${Be.trim()} [/STEERING HINT]`}),yield{type:"status",content:"Steering Hint Injected..."},Mn=Mn.filter(mt=>mt!==z))}}catch{}}let Et=await Pi("agent",t);if(!Et.allowed)throw new Error(Et.reason||`Budget Exhausted for Provider (${s||"Agent"})`);let pe=[];if(Fo=!1,(l==="ICU"||l==="FluxCU")&&!Si)try{yield{type:"status",content:"Capturing Screen"},await new Promise(E=>setTimeout(E,1e3));let{captureGriddedScreenshot:U}=await import("./screen_grid-3RU324CV.js"),z=await U();if(z&&z.base64){let E="[system] Fresh Gridded Screen Feedback Captured. Use numeric coordinates. Old screenshots will be removed when new screenshot is captured, summarize in text if context is needed later [/system]",nt={inlineData:{mimeType:z.mimeType,data:z.base64}},ce=m?.imageHistoryCU||"Standard",Be=ce==="Low"?3:ce==="Extended"?10:ce==="Max"?999:5,mt=x.filter(me=>Array.isArray(me.parts)&&me.parts.some(ft=>ft.inlineData));if(mt.length>=Be){let me=mt.length-Be+1;for(let ft=0;ft<me;ft++){let Ye=mt[ft];Array.isArray(Ye.parts)&&(Ye.parts=Ye.parts.filter(ot=>!ot.inlineData))}}if(x.length>0&&x[x.length-1].role==="user"){let me=x[x.length-1];typeof me.text=="string"&&(me.text+=`
634
+ [STEERING HINT from USER, High Priority] ${Be.trim()} [/STEERING HINT]`:x.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${Be.trim()} [/STEERING HINT]`}),yield{type:"status",content:"Steering Hint Injected..."},Pn=Pn.filter(mt=>mt!==z))}}catch{}}let _t=await Di("agent",t);if(!_t.allowed)throw new Error(_t.reason||`Budget Exhausted for Provider (${s||"Agent"})`);let pe=[];if(Go=!1,(l==="ICU"||l==="FluxCU")&&!Ci)try{yield{type:"status",content:"Capturing Screen"},await new Promise(E=>setTimeout(E,1e3));let{captureGriddedScreenshot:U}=await import("./screen_grid-3RU324CV.js"),z=await U();if(z&&z.base64){let E="[system] Fresh Gridded Screen Feedback Captured. Use numeric coordinates. Old screenshots will be removed when new screenshot is captured, summarize in text if context is needed later [/system]",nt={inlineData:{mimeType:z.mimeType,data:z.base64}},ce=m?.imageHistoryCU||"Standard",Be=ce==="Low"?3:ce==="Extended"?10:ce==="Max"?999:5,mt=x.filter(me=>Array.isArray(me.parts)&&me.parts.some(ft=>ft.inlineData));if(mt.length>=Be){let me=mt.length-Be+1;for(let ft=0;ft<me;ft++){let Ye=mt[ft];Array.isArray(Ye.parts)&&(Ye.parts=Ye.parts.filter(ot=>!ot.inlineData))}}if(x.length>0&&x[x.length-1].role==="user"){let me=x[x.length-1];typeof me.text=="string"&&(me.text+=`
616
635
 
617
- ${E}`,Array.isArray(me.parts)||(me.parts=[{text:me.text}]),me.parts.push(nt))}else x.push({role:"user",text:E,parts:[{text:E},nt]})}}catch(U){console.error("Vision screenshot capture error:",U)}if(Si=!1,C>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"},ct){try{let{clearPendingNudges:U}=await import("./subagent_state-LZCOZSUJ.js");U()}catch{}yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
636
+ ${E}`,Array.isArray(me.parts)||(me.parts=[{text:me.text}]),me.parts.push(nt))}else x.push({role:"user",text:E,parts:[{text:E},nt]})}}catch(U){console.error("Vision screenshot capture error:",U)}if(Ci=!1,C>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"},ct){try{let{clearPendingNudges:U}=await import("./subagent_state-LZCOZSUJ.js");U()}catch{}yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
618
637
 
619
638
  \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}try{let{consumePendingNudges:U}=await import("./subagent_state-LZCOZSUJ.js"),z=U();if(z&&z.length>0){let E=z.join(`
620
639
 
@@ -626,7 +645,7 @@ ${E}`:x.push({role:"user",text:E}),yield{type:"status",content:"Subagent Update"
626
645
  [question] ${U.replace("/btw","").trim()} [/question]`:x.push({role:"user",text:`[system] User question. Resolve this specific query within '[ANSWER]...[/ANSWER]' concisely, naturally [/system]
627
646
  [question] ${U.replace("/btw","").trim()} [/question]`}):x.length>0&&x[x.length-1].role==="user"?x[x.length-1].text+=`
628
647
 
629
- [STEERING HINT from USER, High Priority] ${U.trim()} [/STEERING HINT]`:x.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${U.trim()} [/STEERING HINT]`}),yield{type:"status",content:`${U.startsWith("/btw")?"Question Forwarded...":"Steering Hint Injected..."}`})}let se,Oe=!1,Ve=1,qe=1,_t=Date.now(),gt=null,we="",It=null,so=null,Pn=null,On=0,Ge=[],bt=0,fn=!1,Tt=!1,$n=!1,Mt=!1,bn=!0,Xn=0,dt="",ke="",tt=!1,Dt=!1,He=!0,J=e,Fe="",qt=d;for(d=d.toLowerCase()==="max"?"High":d;Ve<=tn&&qe<=tn&&!Oe&&!ct;){let U=!1;try{we="",bn&&(process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07"),yield{type:"turn_reset",content:!0},bn=!1,qe===1&&(dt=""));let z=f=>{if(!f||typeof f!="string")return f;let b="",S=ds(f);if(S&&(b=S.fullBlock,f=S.remainingText),!f.includes("[tool:")&&!f.includes("[action:"))return(m?.keepReasoningContext?b:"")+f;if(Rn(f).length===0){let y=ui(f);return(m?.keepReasoningContext?b:"")+y}f=f.replace(ml,(y,k)=>k.includes("[tool:")||k.includes("[action:")?k.trim():y);let oe="",I=0,j=[],rt="";for(;I<f.length;){let y=f.indexOf("[tool:",I),k=f.indexOf("[action:",I),Q=-1;if(y!==-1&&k!==-1?Q=Math.min(y,k):y!==-1?Q=y:Q=k,Q===-1){j.length===0&&(oe+=ui(f.substring(I)));break}if((Q>0?f[Q-1]:"")==="`"){oe+=ui(f.substring(I,Q+1)),I=Q+1;continue}j.length===0&&(rt=ui(f.substring(I,Q)));let q=-1,R=null,at=0;for(let At=Q;At<f.length;At++){let Z=f[At];if(R){if(Z===R){let je=0;for(let lt=At-1;lt>=0&&f[lt]==="\\";lt--)je++;je%2===0&&(R=null)}}else if(Z==='"'||Z==="'"||Z==="`")R=Z;else if(Z==="(")at++;else if(Z===")")at--;else if(Z==="]"&&at<=0){q=At;break}}if(q===-1){j.length===0&&(oe+=f.substring(Q));break}let gn=f.substring(Q,q+1);j.push(gn),I=q+1}return j.length>0&&(oe=rt.trimEnd()?rt.trimEnd()+`
648
+ [STEERING HINT from USER, High Priority] ${U.trim()} [/STEERING HINT]`:x.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${U.trim()} [/STEERING HINT]`}),yield{type:"status",content:`${U.startsWith("/btw")?"Question Forwarded...":"Steering Hint Injected..."}`})}let se,$e=!1,Ve=1,qe=1,It=Date.now(),gt=null,we="",Mt=null,ro=null,$n=null,Ln=0,Ge=[],bt=0,un=!1,Tt=!1,On=!1,Pt=!1,Sn=!0,Jn=0,dt="",ke="",tt=!1,Nt=!1,He=!0,J=e,Fe="",Yt=d;for(d=d.toLowerCase()==="max"?"High":d;Ve<=nn&&qe<=nn&&!$e&&!ct;){let U=!1;try{we="",Sn&&(process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07"),yield{type:"turn_reset",content:!0},Sn=!1,qe===1&&(dt=""));let z=f=>{if(!f||typeof f!="string")return f;let b="",S=ms(f);if(S&&(b=S.fullBlock,f=S.remainingText),!f.includes("[tool:")&&!f.includes("[action:"))return(m?.keepReasoningContext?b:"")+f;if(En(f).length===0){let y=hi(f);return(m?.keepReasoningContext?b:"")+y}f=f.replace(xl,(y,k)=>k.includes("[tool:")||k.includes("[action:")?k.trim():y);let oe="",I=0,j=[],rt="";for(;I<f.length;){let y=f.indexOf("[tool:",I),k=f.indexOf("[action:",I),Q=-1;if(y!==-1&&k!==-1?Q=Math.min(y,k):y!==-1?Q=y:Q=k,Q===-1){j.length===0&&(oe+=hi(f.substring(I)));break}if((Q>0?f[Q-1]:"")==="`"){oe+=hi(f.substring(I,Q+1)),I=Q+1;continue}j.length===0&&(rt=hi(f.substring(I,Q)));let q=-1,R=null,at=0;for(let At=Q;At<f.length;At++){let Z=f[At];if(R){if(Z===R){let je=0;for(let lt=At-1;lt>=0&&f[lt]==="\\";lt--)je++;je%2===0&&(R=null)}}else if(Z==='"'||Z==="'"||Z==="`")R=Z;else if(Z==="(")at++;else if(Z===")")at--;else if(Z==="]"&&at<=0){q=At;break}}if(q===-1){j.length===0&&(oe+=f.substring(Q));break}let mn=f.substring(Q,q+1);j.push(mn),I=q+1}return j.length>0&&(oe=rt.trimEnd()?rt.trimEnd()+`
630
649
 
631
650
  `+j.join(`
632
651
 
@@ -634,90 +653,90 @@ ${E}`:x.push({role:"user",text:E}),yield{type:"status",content:"Subagent Update"
634
653
 
635
654
  `)),(m?.keepReasoningContext?b:"")+oe},E=x.filter(f=>(f.role==="user"||f.role==="agent"||f.role==="system")&&!String(f.id).startsWith("welcome")&&!f.isMeta&&!f.isTerminalRecord&&!(f.text&&f.text.startsWith("[TERMINAL_RECORD]"))).map((f,b,S)=>{let H=f.text||"";N||(H=H.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),f.role==="agent"&&(H=z(H),H=H.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),H=H.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*"));let oe=[];return Array.isArray(f.parts)&&f.parts.length>0?oe=f.parts.map(I=>{if(I.text){let j=I.text;return N||(j=j.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),f.role==="agent"&&(j=z(j),j=j.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),j=j.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*")),{text:j}}return I}):oe=[{text:H}],f.binaryPart&&et(J)&&S.slice(b+1).filter(j=>j.role==="user"&&!j.text?.startsWith("[ACTION RESULT]")&&!j.text?.startsWith("[TOOL RESULT]")).length<=2&&oe.push(f.binaryPart),{role:f.role==="user"||f.role==="system"?"user":"model",parts:oe}});for(let f=E.length-2;f>=0;f--){let b=E[f],S=E[f+1];b.role==="user"&&S.role==="user"&&(S.parts?.[0]?.text||"").trim().startsWith("[SYSTEM")&&E.splice(f,1)}let nt=[];for(let f=0;f<E.length;f++){let b=E[f];if(nt.length===0)nt.push(b);else{let S=nt[nt.length-1];S.role===b.role?(S.parts[0].text+=`
636
655
 
637
- `+(b.parts?.[0]?.text||""),b.parts?.length>1&&S.parts.push(...b.parts.slice(1))):nt.push(b)}}for(let f of nt)for(let b of f.parts||[])b&&typeof b.text=="string"&&(b.text.includes("[action:")||b.text.includes("[tool:"))&&(b.text=b.text.replace(/```(?:[a-zA-Z0-9_-]+)?\s*\n?(\[(?:action|tool):[\s\S]*?\)\s*\])\n?```/gi,"$1"),b.text=b.text.replace(/`(\[(?:action|tool):[\s\S]*?\)\s*\])`/gi,"$1"));E.length=0,E.push(...nt),J=e;let ce=`${g}|${s}|${l}|${d}|${qt}|${J}|${JSON.stringify(r)}|${!!m?.dynamicDirAwareness}|${!!m?.subAgents}`,Be=Gn.key===ce&&Gn.value;if((process.env.I_HAVE_TOO_MUCH_MONEY==="true"||process.env.I_HAVE_TOO_MUCH_MONEY===!0)&&(Be=!1),Be)Fe=Gn.value;else{let f=s==="Mistral"?!!Vo(J):!(J||"gemma").toLowerCase().startsWith("gemma");Fe=Cr(r,((J||"gemma").toLowerCase().startsWith("gemma"),qt),l,m,N,O,s,s==="Google"?!0:v,f,g,!!m?.keepReasoningContext,J),m?.dynamicDirAwareness||(Fe+=`
638
- ${da.replace(`
656
+ `+(b.parts?.[0]?.text||""),b.parts?.length>1&&S.parts.push(...b.parts.slice(1))):nt.push(b)}}for(let f of nt)for(let b of f.parts||[])b&&typeof b.text=="string"&&(b.text.includes("[action:")||b.text.includes("[tool:"))&&(b.text=b.text.replace(/```(?:[a-zA-Z0-9_-]+)?\s*\n?(\[(?:action|tool):[\s\S]*?\)\s*\])\n?```/gi,"$1"),b.text=b.text.replace(/`(\[(?:action|tool):[\s\S]*?\)\s*\])`/gi,"$1"));E.length=0,E.push(...nt),J=e;let ce=`${g}|${s}|${l}|${d}|${Yt}|${J}|${JSON.stringify(r)}|${!!m?.dynamicDirAwareness}|${!!m?.subAgents}`,Be=Hn.key===ce&&Hn.value;if((process.env.I_HAVE_TOO_MUCH_MONEY==="true"||process.env.I_HAVE_TOO_MUCH_MONEY===!0)&&(Be=!1),Be)Fe=Hn.value;else{let f=s==="Mistral"?!!Xo(J):!(J||"gemma").toLowerCase().startsWith("gemma");Fe=Er(r,((J||"gemma").toLowerCase().startsWith("gemma"),Yt),l,m,N,$,s,s==="Google"?!0:v,f,g,!!m?.keepReasoningContext,J),m?.dynamicDirAwareness||(Fe+=`
657
+ ${ga.replace(`
639
658
  **Directory**`,`
640
- -- Directory --`)}`),Gn.key=ce,Gn.value=Fe}let me=E[E.length-1];if(oo()&C>0){await new Promise(H=>setTimeout(H,2500)),yield{type:"status",content:"Verifying"};let f=await Un(),b=f?f.diagnostics:null,S=ps(f?.comments);b&&me&&me.role==="user"&&me.parts?.[0]?.text&&(me.parts[0].text+=`
659
+ -- Directory --`)}`),Hn.key=ce,Hn.value=Fe}let me=E[E.length-1];if(io()&C>0){await new Promise(H=>setTimeout(H,2500)),yield{type:"status",content:"Verifying"};let f=await Gn(),b=f?f.diagnostics:null,S=ws(f?.comments);b&&me&&me.role==="user"&&me.parts?.[0]?.text&&(me.parts[0].text+=`
641
660
 
642
- ${b}`),pi&&me&&me.role==="user"&&me.parts?.[0]?.text&&(me.parts[0].text+=`
661
+ ${b}`),wi&&me&&me.role==="user"&&me.parts?.[0]?.text&&(me.parts[0].text+=`
643
662
 
644
663
  [Additional Comments]
645
- ${S}`),yield{type:"status",content:"Working"}}let ft=s==="Mistral"||s==="Google"&&e?.toLowerCase().startsWith("gemma");if(m?.advanceRollback&&me&&me.role==="user"&&(me.parts?.[0]?.text?.startsWith("[ACTION RESULT]")||me.parts?.[0]?.text?.startsWith("[TOOL RESULT]")))try{let f=await ho.getLatestFileChanges(g);if(f&&(f.newFiles.length>0||f.modifiedFiles.length>0||f.deletedFiles.length>0)){let b=`
664
+ ${S}`),yield{type:"status",content:"Working"}}let ft=s==="Mistral"||s==="Google"&&e?.toLowerCase().startsWith("gemma");if(m?.advanceRollback&&me&&me.role==="user"&&(me.parts?.[0]?.text?.startsWith("[ACTION RESULT]")||me.parts?.[0]?.text?.startsWith("[TOOL RESULT]")))try{let f=await yo.getLatestFileChanges(g);if(f&&(f.newFiles.length>0||f.modifiedFiles.length>0||f.deletedFiles.length>0)){let b=`
646
665
  [system] File Changes:
647
666
  `;for(let H of f.newFiles)b+=`* ${H} (created)
648
667
  `;for(let H of f.modifiedFiles)b+=`* ${H} (modified)
649
668
  `;for(let H of f.deletedFiles)b+=`* ${H} (deleted)
650
- `;b+="[/system]",me.parts[0].text+=b;let S=-1;for(let H=x.length-1;H>=0;H--)if(x[H].role==="user"&&(x[H].text?.startsWith("[ACTION RESULT]")||x[H].text?.startsWith("[TOOL RESULT]"))){S=H;break}S!==-1&&(x[S].text+=b)}}catch{}let Ye=Math.floor(zt*.99),ot=C+1;if(ot>=Ye&&me&&me.parts?.[0]&&(me.parts[0].text+=`
651
- [system] WARNING, Turn Limit Impending: Step ${ot}/${zt}. Wrap up quickly/prompt user to continue. [/system]`),process.env.LOG_CHAT==="true"||process.env.LOG_CHAT==="1"||process.env.LOG_CHAT===!0||!1){let f=te.join(Wn,"chats",String(g));ve.existsSync(f)||ve.mkdirSync(f,{recursive:!0}),ve.writeFileSync(te.join(f,"context.json"),JSON.stringify({contents:E},null,2)),ve.writeFileSync(te.join(f,"system.md"),`${Be?"CACHED":"NOT CACHED"}
669
+ `;b+="[/system]",me.parts[0].text+=b;let S=-1;for(let H=x.length-1;H>=0;H--)if(x[H].role==="user"&&(x[H].text?.startsWith("[ACTION RESULT]")||x[H].text?.startsWith("[TOOL RESULT]"))){S=H;break}S!==-1&&(x[S].text+=b)}}catch{}let Ye=Math.floor(qt*.99),ot=C+1;if(ot>=Ye&&me&&me.parts?.[0]&&(me.parts[0].text+=`
670
+ [system] WARNING, Turn Limit Impending: Step ${ot}/${qt}. Wrap up quickly/prompt user to continue. [/system]`),process.env.LOG_CHAT==="true"||process.env.LOG_CHAT==="1"||process.env.LOG_CHAT===!0||!1){let f=te.join(Un,"chats",String(g));ve.existsSync(f)||ve.mkdirSync(f,{recursive:!0}),ve.writeFileSync(te.join(f,"context.json"),JSON.stringify({contents:E},null,2)),ve.writeFileSync(te.join(f,"system.md"),`${Be?"CACHED":"NOT CACHED"}
652
671
  Key: ${ce}
653
672
  --------------------------------------------------------------------
654
673
 
655
- ${Fe}`)}let Xe=new Promise((f,b)=>{G.signal.aborted&&b(new DOMException("The user aborted a request.","AbortError")),G.signal.addEventListener("abort",()=>{b(new DOMException("The user aborted a request.","AbortError"))})});Xe.catch(()=>{});let $e=E;if(_t=Date.now(),s==="Ollama")se=(await ye("Ollama"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1,m?.ollamaEndpoint||"Cloud");else if(s==="OpenRouter")se=(await ye("OpenRouter"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1,g);else if(s==="DeepSeek")se=(await ye("DeepSeek"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);else if(s==="Mistral")se=(await ye("Mistral"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1,g);else if(s==="NVIDIA"){let f=(await ye("NVIDIA"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);se=(await ye("NVIDIA_wrap"))(f,J)}else if(s==="InferX")se=(await ye("InferX"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);else if(s==="SenseNova")se=(await ye("SenseNova"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);else if(s==="AIHubMix")se=(await ye("AIHubMix"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);else if(s==="Poolside")se=(await ye("Poolside"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);else if(s==="9router"||s==="9Router")se=(await ye("NineRouter"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);else if(s==="ExpLabs"||s==="ExperientialLabs")se=(await ye("ExpLabs"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);else if(s==="Infron"||s==="infron")se=(await ye("Infron"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);else if(s==="TokenHarbor"||s==="Token Harbor"||s==="tokenharbor"||s==="token_harbor"||s==="thk")se=(await ye("TokenHarbor"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);else if(s==="APInex"||s==="apinex"||s==="apx")se=(await ye("APInex"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);else if(s==="xKiro"||s==="xkiro"||s==="kiro")se=(await ye("xKiro"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);else if(s==="c_openai"||s==="Custom (OpenAI)"){let f=m?.customOpenAIBaseUrl||"";try{f=await Ii("c_openai")||f}catch{}se=(await ye("c_openai"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1,f)}else{let f=ra(t?.apiKey),{serviceTier:b,cleanModel:S}=la(J),H={systemInstruction:Fe,mediaResolution:"MEDIA_RESOLUTION_HIGH",safetySettings:[{category:fi.HARM_CATEGORY_HARASSMENT,threshold:di.BLOCK_NONE},{category:fi.HARM_CATEGORY_HATE_SPEECH,threshold:di.BLOCK_NONE},{category:fi.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:di.BLOCK_NONE},{category:fi.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:di.BLOCK_NONE}],temperature:1.05,thinkingConfig:(()=>{let I=Bs("Google",J||"gemini-3-flash-preview",d);if(I!==null){if(typeof I=="object")return I;if(I===!1||I==="false"||I==="none"||I===0||I==="0")return{includeThoughts:!1};if(typeof I=="number")return{includeThoughts:!0,thinkingBudget:I};if(typeof I=="string"){let k=I.toLowerCase();if(k==="minimal")return{includeThoughts:!0,thinkingLevel:Ke.MINIMAL};if(k==="low")return{includeThoughts:!0,thinkingLevel:Ke.LOW};if(k==="medium")return{includeThoughts:!0,thinkingLevel:Ke.MEDIUM};if(k==="high")return{includeThoughts:!0,thinkingLevel:Ke.HIGH};let Q=Number(I);if(!isNaN(Q))return{includeThoughts:!0,thinkingBudget:Q}}}let j=(J||"").toLowerCase(),rt=j.includes("gemma-4")||j.startsWith("gemma"),y=j.includes("gemini-3");if(rt||y)return rt?d.toLowerCase()!=="high"?{includeThoughts:!1,thinkingLevel:Ke.MINIMAL}:{includeThoughts:!0,thinkingLevel:Ke.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:j.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 k={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[d]||2048;return k===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:k}}})()};b&&(H.serviceTier=b);let oe=f.models.generateContentStream({model:S||"gemini-3-flash-preview",contents:$e,config:H},{signal:G.signal});se=await Promise.race([oe,Xe])}we="",It=null,Pn=null,Ge=[],bt=0,yield{type:"model_update",content:null},ke="",tt=dt.length>0;let it="",Bo=Date.now(),nn=async function*(){if(s==="Google"&&it){let f=ao(it);for(let b of f)yield b;it="",Bo=Date.now()}},Cs=!0,un="",Jn=!1,st=null,vs=!1,Dn=!1,Qn=!1,Wo=!1,Sn=!1,ro=f=>{let b=0;for(;b+2<f.length;)f[b]==="`"&&f[b+1]==="`"&&f[b+2]==="`"?(Wo=!Wo,b+=3):b++},Rs=f=>{if(!f)return;let b=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,S;for(;(S=b.exec(f))!==null;){let H=S[0].toLowerCase();H.startsWith("</")||H.startsWith("[/")||H==="<channel|>"?Sn=!1:Sn=!0}},wa={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|>"}},ao=f=>{let b=[],S=f,H=oe=>{if(!oe)return;if(!vs){b.push({type:"text",content:oe}),ro(oe),Rs(oe);return}let I=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,j=0,rt;for(;(rt=I.exec(oe))!==null;){let k=oe.substring(j,rt.index);if(k)if(ro(k),Sn)b.push({type:"text",content:k});else{let _e=k.replace(/[^\r\n]/g,"");_e&&b.push({type:"text",content:_e})}let Q=rt[0];ro(Q);let a=Q.toLowerCase();a.startsWith("</")||a.startsWith("[/")||a==="<channel|>"?Sn=!1:Sn=!0,b.push({type:"text",content:Q}),j=I.lastIndex}let y=oe.substring(j);if(y)if(ro(y),Sn)b.push({type:"text",content:y});else{let k=y.replace(/[^\r\n]/g,"");k&&b.push({type:"text",content:k})}};for(;S.length>0;)if(Jn){let oe=un+S,I=wa[st];if(I){let y=!1;if(oe.length<I.startPrefix.length?I.startPrefix.startsWith(oe)||(y=!0):oe.startsWith(I.startPrefix)?oe.length>=I.fullPrefix.length&&!oe.startsWith(I.fullPrefix)&&(y=!0):y=!0,y){H(oe),un="",Jn=!1,st=null,Dn=!1,Qn=!1,S="";break}}let j=-1,rt=I?I.endTag:"]";if(st==="tool"||st==="action"){let y=0,k=null,Q=0,a=!1;for(let _e=0;_e<oe.length;_e++){let q=oe[_e];if(k){if(q===k){let R=0;for(let at=_e-1;at>=0&&oe[at]==="\\";at--)R++;R%2===0&&(k=null)}}else if(q==='"'||q==="'")k=q;else if(q==="`")if(Dn){j=_e;break}else k=q;else if(q==="(")y++,a=!0;else if(q===")")y--;else if(q==="]"&&a&&y===0){j=_e;break}}}else j=oe.indexOf(rt);if(j!==-1){let y=rt.length,k=oe.substring(0,j+y);st?.startsWith("kimi")||b.push({type:"text",content:k}),ro(k),Rs(k),(st==="tool"||st==="action"||st?.startsWith("kimi"))&&!Dn&&!Qn&&(vs=!0,Mn.push(k.trim())),Dn=!1,Qn=!1,un="",Jn=!1,st=null,S=oe.substring(j+y)}else{un=oe,S="";break}}else{let oe=S.indexOf("[tool"),I=S.indexOf("[action"),j=S.indexOf("[[END]]"),rt=S.indexOf("<|tool_calls_section_begin|>"),y=S.indexOf("<|tool_call_begin|>"),k=[{type:"tool",idx:oe,start:"[tool",end:"]"},{type:"action",idx:I,start:"[action",end:"]"},{type:"end",idx:j,start:"[[END]]",end:"[[END]]"},{type:"kimi_section",idx:rt,start:"<|tool_calls_section_begin|>",end:"<|tool_calls_section_end|>"},{type:"kimi_call",idx:y,start:"<|tool_call_begin|>",end:"<|tool_call_end|>"}].filter(Q=>Q.idx!==-1).sort((Q,a)=>Q.idx-a.idx);if(k.length>0){let Q=k[0],a=S.substring(0,Q.idx);Q.idx>0&&H(a);let _e=Q.idx>0?S[Q.idx-1]:"";Dn=Wo||_e==="`",Qn=Sn,Jn=!0,st=Q.type,un="",S=S.substring(Q.idx)}else{let Q=["[tool","[action","[[END]]","<|tool_calls_section_begin|>","<|tool_call_begin|>"],a=-1;for(let _e of Q){for(let q=_e.length-1;q>0;q--)if(S.endsWith(_e.substring(0,q))){a=S.length-q;let R=Q.indexOf(_e);R===0?st="tool":R===1?st="action":R===2?st="end":R===3?st="kimi_section":st="kimi_call";break}if(a!==-1)break}if(a!==-1){if(a>0){let q=S.substring(0,a);H(q)}let _e=a>0?S[a-1]:"";Dn=Wo||_e==="`",Qn=Sn,Jn=!0,un=S.substring(a),S=""}else{H(S);break}}}return b},ba=se[Symbol.asyncIterator]();for(;;){let{value:f,done:b}=await Promise.race([ba.next(),Xe]);if(b)break;if(f&&f.type==="status"){yield f;continue}let S="",H=f.candidates?.[0]?.content?.parts;if(H&&H.length>0)for(let I of H){let j=typeof I.text=="string"?I.text:I.text?parseChunkText(I.text):"";I.thought?j&&(U||(S+="<think_fluxflow>",U=!0),S+=j):j&&(U&&(S+="</think_fluxflow>",U=!1),S+=j)}else f.text&&U&&(S+="</think_fluxflow>",U=!1);S=dl(S);let oe=S?Oi(S):0;if(t&&typeof t.onTokenChunk=="function"&&t.onTokenChunk(S,oe),Cs&&(gt===null&&(gt=Date.now()-_t),yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"},Cs=!1),ct){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
674
+ ${Fe}`)}let Xe=new Promise((f,b)=>{G.signal.aborted&&b(new DOMException("The user aborted a request.","AbortError")),G.signal.addEventListener("abort",()=>{b(new DOMException("The user aborted a request.","AbortError"))})});Xe.catch(()=>{});let Le=E;if(It=Date.now(),s==="Ollama")se=(await ye("Ollama"))(t.apiKey,J,Le,Fe,d,l,v,G.signal,1,m?.ollamaEndpoint||"Cloud");else if(s==="OpenRouter")se=(await ye("OpenRouter"))(t.apiKey,J,Le,Fe,d,l,v,G.signal,1,g);else if(s==="DeepSeek")se=(await ye("DeepSeek"))(t.apiKey,J,Le,Fe,d,l,v,G.signal,1);else if(s==="Mistral")se=(await ye("Mistral"))(t.apiKey,J,Le,Fe,d,l,v,G.signal,1,g);else if(s==="NVIDIA"){let f=(await ye("NVIDIA"))(t.apiKey,J,Le,Fe,d,l,v,G.signal,1);se=(await ye("NVIDIA_wrap"))(f,J)}else if(s==="InferX")se=(await ye("InferX"))(t.apiKey,J,Le,Fe,d,l,v,G.signal,1);else if(s==="SenseNova")se=(await ye("SenseNova"))(t.apiKey,J,Le,Fe,d,l,v,G.signal,1);else if(s==="AIHubMix")se=(await ye("AIHubMix"))(t.apiKey,J,Le,Fe,d,l,v,G.signal,1);else if(s==="Poolside")se=(await ye("Poolside"))(t.apiKey,J,Le,Fe,d,l,v,G.signal,1);else if(s==="9router"||s==="9Router")se=(await ye("NineRouter"))(t.apiKey,J,Le,Fe,d,l,v,G.signal,1);else if(s==="ExpLabs"||s==="ExperientialLabs")se=(await ye("ExpLabs"))(t.apiKey,J,Le,Fe,d,l,v,G.signal,1);else if(s==="Infron"||s==="infron")se=(await ye("Infron"))(t.apiKey,J,Le,Fe,d,l,v,G.signal,1);else if(s==="TokenHarbor"||s==="Token Harbor"||s==="tokenharbor"||s==="token_harbor"||s==="thk")se=(await ye("TokenHarbor"))(t.apiKey,J,Le,Fe,d,l,v,G.signal,1);else if(s==="APInex"||s==="apinex"||s==="apx")se=(await ye("APInex"))(t.apiKey,J,Le,Fe,d,l,v,G.signal,1);else if(s==="xKiro"||s==="xkiro"||s==="kiro")se=(await ye("xKiro"))(t.apiKey,J,Le,Fe,d,l,v,G.signal,1);else if(s==="c_openai"||s==="Custom (OpenAI)"){let f=m?.customOpenAIBaseUrl||"";try{f=await Li("c_openai")||f}catch{}se=(await ye("c_openai"))(t.apiKey,J,Le,Fe,d,l,v,G.signal,1,f)}else{let f=ca(t?.apiKey),{serviceTier:b,cleanModel:S}=fa(J),H={systemInstruction:Fe,mediaResolution:"MEDIA_RESOLUTION_HIGH",safetySettings:[{category:pi.HARM_CATEGORY_HARASSMENT,threshold:mi.BLOCK_NONE},{category:pi.HARM_CATEGORY_HATE_SPEECH,threshold:mi.BLOCK_NONE},{category:pi.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:mi.BLOCK_NONE},{category:pi.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:mi.BLOCK_NONE}],temperature:1.05,thinkingConfig:(()=>{let I=Gs("Google",J||"gemini-3-flash-preview",d);if(I!==null){if(typeof I=="object")return I;if(I===!1||I==="false"||I==="none"||I===0||I==="0")return{includeThoughts:!1};if(typeof I=="number")return{includeThoughts:!0,thinkingBudget:I};if(typeof I=="string"){let k=I.toLowerCase();if(k==="minimal")return{includeThoughts:!0,thinkingLevel:Ke.MINIMAL};if(k==="low")return{includeThoughts:!0,thinkingLevel:Ke.LOW};if(k==="medium")return{includeThoughts:!0,thinkingLevel:Ke.MEDIUM};if(k==="high")return{includeThoughts:!0,thinkingLevel:Ke.HIGH};let Q=Number(I);if(!isNaN(Q))return{includeThoughts:!0,thinkingBudget:Q}}}let j=(J||"").toLowerCase(),rt=j.includes("gemma-4")||j.startsWith("gemma"),y=j.includes("gemini-3");if(rt||y)return rt?d.toLowerCase()!=="high"?{includeThoughts:!1,thinkingLevel:Ke.MINIMAL}:{includeThoughts:!0,thinkingLevel:Ke.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:j.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 k={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[d]||2048;return k===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:k}}})()};b&&(H.serviceTier=b);let oe=f.models.generateContentStream({model:S||"gemini-3-flash-preview",contents:Le,config:H},{signal:G.signal});se=await Promise.race([oe,Xe])}we="",Mt=null,$n=null,Ge=[],bt=0,yield{type:"model_update",content:null},ke="",tt=dt.length>0;let it="",Ho=Date.now(),on=async function*(){if(s==="Google"&&it){let f=lo(it);for(let b of f)yield b;it="",Ho=Date.now()}},Es=!0,gn="",Qn=!1,st=null,_s=!1,Nn=!1,Zn=!1,jo=!1,kn=!1,ao=f=>{let b=0;for(;b+2<f.length;)f[b]==="`"&&f[b+1]==="`"&&f[b+2]==="`"?(jo=!jo,b+=3):b++},Is=f=>{if(!f)return;let b=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,S;for(;(S=b.exec(f))!==null;){let H=S[0].toLowerCase();H.startsWith("</")||H.startsWith("[/")||H==="<channel|>"?kn=!1:kn=!0}},Ta={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|>"}},lo=f=>{let b=[],S=f,H=oe=>{if(!oe)return;if(!_s){b.push({type:"text",content:oe}),ao(oe),Is(oe);return}let I=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,j=0,rt;for(;(rt=I.exec(oe))!==null;){let k=oe.substring(j,rt.index);if(k)if(ao(k),kn)b.push({type:"text",content:k});else{let _e=k.replace(/[^\r\n]/g,"");_e&&b.push({type:"text",content:_e})}let Q=rt[0];ao(Q);let a=Q.toLowerCase();a.startsWith("</")||a.startsWith("[/")||a==="<channel|>"?kn=!1:kn=!0,b.push({type:"text",content:Q}),j=I.lastIndex}let y=oe.substring(j);if(y)if(ao(y),kn)b.push({type:"text",content:y});else{let k=y.replace(/[^\r\n]/g,"");k&&b.push({type:"text",content:k})}};for(;S.length>0;)if(Qn){let oe=gn+S,I=Ta[st];if(I){let y=!1;if(oe.length<I.startPrefix.length?I.startPrefix.startsWith(oe)||(y=!0):oe.startsWith(I.startPrefix)?oe.length>=I.fullPrefix.length&&!oe.startsWith(I.fullPrefix)&&(y=!0):y=!0,y){H(oe),gn="",Qn=!1,st=null,Nn=!1,Zn=!1,S="";break}}let j=-1,rt=I?I.endTag:"]";if(st==="tool"||st==="action"){let y=0,k=null,Q=0,a=!1;for(let _e=0;_e<oe.length;_e++){let q=oe[_e];if(k){if(q===k){let R=0;for(let at=_e-1;at>=0&&oe[at]==="\\";at--)R++;R%2===0&&(k=null)}}else if(q==='"'||q==="'")k=q;else if(q==="`")if(Nn){j=_e;break}else k=q;else if(q==="(")y++,a=!0;else if(q===")")y--;else if(q==="]"&&a&&y===0){j=_e;break}}}else j=oe.indexOf(rt);if(j!==-1){let y=rt.length,k=oe.substring(0,j+y);st?.startsWith("kimi")||b.push({type:"text",content:k}),ao(k),Is(k),(st==="tool"||st==="action"||st?.startsWith("kimi"))&&!Nn&&!Zn&&(_s=!0,Pn.push(k.trim())),Nn=!1,Zn=!1,gn="",Qn=!1,st=null,S=oe.substring(j+y)}else{gn=oe,S="";break}}else{let oe=S.indexOf("[tool"),I=S.indexOf("[action"),j=S.indexOf("[[END]]"),rt=S.indexOf("<|tool_calls_section_begin|>"),y=S.indexOf("<|tool_call_begin|>"),k=[{type:"tool",idx:oe,start:"[tool",end:"]"},{type:"action",idx:I,start:"[action",end:"]"},{type:"end",idx:j,start:"[[END]]",end:"[[END]]"},{type:"kimi_section",idx:rt,start:"<|tool_calls_section_begin|>",end:"<|tool_calls_section_end|>"},{type:"kimi_call",idx:y,start:"<|tool_call_begin|>",end:"<|tool_call_end|>"}].filter(Q=>Q.idx!==-1).sort((Q,a)=>Q.idx-a.idx);if(k.length>0){let Q=k[0],a=S.substring(0,Q.idx);Q.idx>0&&H(a);let _e=Q.idx>0?S[Q.idx-1]:"";Nn=jo||_e==="`",Zn=kn,Qn=!0,st=Q.type,gn="",S=S.substring(Q.idx)}else{let Q=["[tool","[action","[[END]]","<|tool_calls_section_begin|>","<|tool_call_begin|>"],a=-1;for(let _e of Q){for(let q=_e.length-1;q>0;q--)if(S.endsWith(_e.substring(0,q))){a=S.length-q;let R=Q.indexOf(_e);R===0?st="tool":R===1?st="action":R===2?st="end":R===3?st="kimi_section":st="kimi_call";break}if(a!==-1)break}if(a!==-1){if(a>0){let q=S.substring(0,a);H(q)}let _e=a>0?S[a-1]:"";Nn=jo||_e==="`",Zn=kn,Qn=!0,gn=S.substring(a),S=""}else{H(S);break}}}return b},Aa=se[Symbol.asyncIterator]();for(;;){let{value:f,done:b}=await Promise.race([Aa.next(),Xe]);if(b)break;if(f&&f.type==="status"){yield f;continue}let S="",H=f.candidates?.[0]?.content?.parts;if(H&&H.length>0)for(let I of H){let j=typeof I.text=="string"?I.text:I.text?parseChunkText(I.text):"";I.thought?j&&(U||(S+="<think_fluxflow>",U=!0),S+=j):j&&(U&&(S+="</think_fluxflow>",U=!1),S+=j)}else f.text&&U&&(S+="</think_fluxflow>",U=!1);S=ml(S);let oe=S?Ni(S):0;if(t&&typeof t.onTokenChunk=="function"&&t.onTokenChunk(S,oe),Es&&(gt===null&&(gt=Date.now()-It),yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"},Es=!1),ct){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
656
675
 
657
- \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(S){if(tt){if(ke+=S,ke.length>=64){let y=0,k=Math.min(dt.length,ke.length);for(let a=k;a>=10;a--)if(dt.endsWith(ke.substring(0,a))){y=a;break}let Q=ke.substring(y);if(Q){let _e=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(dt)?Q.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):Q.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");if(_e)if(we+=_e,s==="Google")it+=_e;else{yield*nn();let q=ao(_e);for(let R of q)yield R}}tt=!1,ke=""}continue}else if(we+=S,s==="Google")it+=S;else{yield*nn();let y=ao(S);for(let k of y)yield k}let I=hl(we);if(I.inside){Dt=!0,Pn||(Pn=Date.now());let k={Ask:"ask",AskUser:"ask",WebSearch:"web_search",WebScrape:"web_scrape",ReadFile:"view_file",ReadFolder:"read_folder",WriteFile:"write_file",PatchFile:"update_file",WritePDF:"write_pdf",WriteDoc:"write_docx",FindFile:"find_file",find_file:"find_file",findfile:"find_file",Run:"exec_command",SearchKeyword:"search_keyword",CodeSearch:"search_keyword",code_search:"search_keyword",Code_Search:"search_keyword",codesearch:"search_keyword",Memory:"memory",file_map:"file_map",FileMap:"file_map",Chat:"chat",chat:"chat",GenerateImage:"generate_image",generate_image:"generate_image",todo:"todo",Todo:"todo",goal:"todo",Goal:"todo",Invoke:"invoke",InvokeSync:"invoke_sync",getProgress:"get_progress",GetProgress:"get_progress",Cancel:"cancel",Await:"await",wait:"wait",Answer:"answer",Steer:"steer",steer:"steer"}[I.toolName]||I.toolName,Q=I.args||"",a=null;if(["write_file","update_file","view_file","read_folder","find_file","write_pdf","write_docx","search_keyword","generate_image","file_map","invoke","invoke_sync","get_progress","await","wait","answer"].includes(k)){let q=L(Q),R=q.basename||q.name||q.path||q.targetFile||q.TargetFile||q.directory||q.file,at=q.keyword,gn=q.title||q.task,At=q.id||q.taskId,Z=q.timeout||q.time||q.seconds||q.sec;if(at!=null)a=String(at).replace(wn,"");else if(R)a=te.basename(String(R).replace(wn,"").replace(Jr,"/"));else if(gn&&(k==="invoke"||k==="invoke_sync"))a=String(gn).replace(wn,"").substring(0,30);else if(At&&k==="get_progress")a=String(At).replace(wn,"");else if(Z&&k==="await"){let je=parseFloat(String(Z).replace(wn,""));isNaN(je)?a=String(Z).replace(wn,""):(je<5&&(je=5),je>120&&(je=180),a=(Ct=>{if(Ct>=60){let co=Math.floor(Ct/60),mn=Ct%60;return`${co}m${mn>0?` ${mn}s`:""}`}return`${Ct}s`})(je))}else if(Z&&k==="wait"){let je=parseFloat(String(Z).replace(wn,""));isNaN(je)?a=String(Z).replace(wn,""):(je<10&&(je=10),je>120&&(je=120),a=(Ct=>{if(Ct>=60){let co=Math.floor(Ct/60),mn=Ct%60;return`${co}m${mn>0?` ${mn}s`:""}`}return`${Ct}s`})(je))}else{let je=Q.match(al);if(je){let lt=je[1].replace(wn,"");k==="invoke"||k==="invoke_sync"||k==="get_progress"?a=lt.substring(0,30):a=k==="search_keyword"||k==="file_map"?lt:te.basename(lt.replace(Jr,"/"))}}}let _e=`${fs[k]||k}${a?` ${a}`:""}`;if((k!==It||a!==so)&&(It=k,so=a,yield{type:"status",content:`${_e}`},process.stdout.isTTY)){let R={WebSearch:"Searching",web_search:"Searching",WebScrape:"Reading",web_scrape:"Reading",ReadFile:"Reading",read_file:"Reading",ReadFolder:"Reading",read_folder:"Reading",WriteFile:"Writing",write_file:"Writing",UpdateFile:"Editing",update_file:"Editing",WritePdf:"Creating",write_pdf:"Creating",WriteDocx:"Creating",write_docx:"Creating",SearchKeyword:"Searching",search_keyword:"Searching",CodeSearch:"Searching",code_search:"Searching",FindFile:"Finding File",find_file:"Finding File",Run:"Executing",Ask:"User Input Required",AskUser:"User Input Required",Memory:"Updating Memory",GenerateImage:"Generating",InvokeSync:"Sub-Agent Working",invoke_sync:"Sub-Agent Working",Invoke:"Working",invoke:"Working",GetProgress:"Checking Progress",get_progress:"Checking Progress",Cancel:"Stopping Generalist",cancel:"Stopping Generalist",Await:"Waiting",await:"Waiting",wait:"Waiting",EmergencyRollback:"Rolling the Ball",Answer:"Answering Sub-Agent",answer:"Answering Sub-Agent",Steer:"Steering Sub-Agent",steer:"Steering Sub-Agent",Click:"Clicking",click:"Clicking",Drag:"Dragging",drag:"Dragging",Scroll:"Scrolling",scroll:"Scrolling",KeyboardTyping:"Typing",keyboard_typing:"Typing",KeyPress:"Pressing Key",key_press:"Pressing Key",RecaptureScreen:"Recapturing Screen",recapture_screen:"Recapturing Screen"}[k]||"Working";process.stdout.write(`\x1B]0;${R}...\x07`)}}if(we.length-Xn>800){Xn=we.length;let y=aa(we,!1),k=ds(y),Q=k?(k.innerContent||"").trim():"",a=Q.split(/[.!?]\s+/).filter(de=>de.trim().length>10),_e=new Set(a),q=a.length>25?(a.length-_e.size)/a.length:0,R=Q.split(/\s+/).filter(de=>de.length>0).length,at=.9,gn=.92,At=!1;if(s.toLowerCase().includes("google")&&(J||"").toLowerCase().startsWith("gemma")){let c={low:2048,medium:4096,high:32768,max:65536,xhigh:65536}[d?.toLowerCase()]||16e3;At=R>c}if(q>at||At){yield{type:"status",content:`${q>at?"Reasoning Loop Detected":"Thinking Budget Exceeded"}. Re-centering...`},Tt=!0,await new Promise(c=>setTimeout(c,3e3));break}let lt=na(we).trim().split(/[.!?]\s+/).filter(de=>de.trim().length>10),Ct=new Set(lt);if((lt.length>25?(lt.length-Ct.size)/lt.length:0)>gn){yield{type:"status",content:"Response Loop Detected. Re-centering..."},Tt=!1,Mt=!0,await new Promise(de=>setTimeout(de,3e3));break}let mn=y.replace(el,"").replace(tl,"").replace(nl,"").replace(ol,""),pt=mn.toLowerCase().split(/\s+/).map(de=>de.replace(il,"")).filter(de=>de.length>0),Yt=!1;if(pt.length>=40)for(let de=1;de<=15;de++){let c=Math.max(8,Math.ceil(25/de));if(pt.length<de*c)continue;let T=pt.slice(pt.length-de),D=T.join(" ");if(de>1&&D===T.slice(0,Math.floor(de/2)).join(" ").repeat(2).trim())continue;let fe=!0;for(let ie=1;ie<c;ie++)if(pt.slice(pt.length-de*(ie+1),pt.length-de*ie).join(" ")!==D){fe=!1;break}if(fe){Yt=!0;break}}if(!Yt){let de=mn.toLowerCase().replace(sl,"");if(de.length>=80)for(let c=1;c<=10;c++){let T=Math.max(15,Math.ceil(45/c));if(de.length<c*T)continue;let D=de.substring(de.length-c),fe=!0;for(let ie=1;ie<T;ie++)if(de.substring(de.length-c*(ie+1),de.length-c*ie)!==D){fe=!1;break}if(fe){Yt=!0;break}}}if(Yt){yield{type:"status",content:"Stuttering Detected. Re-centering..."},Tt=!1,$n=!0,await new Promise(de=>setTimeout(de,3e3));break}}let j=$t(we),rt=Rn(j);for(;rt.length>bt;){yield*nn();let y=rt[bt],k=Date.now(),a={Ask:"ask",AskUser:"ask",WebSearch:"web_search",WebScrape:"web_scrape",ReadFile:"view_file",ReadFolder:"read_folder",FindFile:"find_file",find_file:"find_file",findfile:"find_file",WriteFile:"write_file",PatchFile:"update_file",WritePDF:"write_pdf",WriteDoc:"write_docx",Run:"exec_command",SearchKeyword:"search_keyword",CodeSearch:"search_keyword",code_search:"search_keyword",Code_Search:"search_keyword",codesearch:"search_keyword",Memory:"memory",file_map:"file_map",FileMap:"file_map",Chat:"chat",chat:"chat",GenerateImage:"generate_image",generate_image:"generate_image",todo:"todo",Todo:"todo",goal:"todo",Goal:"todo",Invoke:"invoke",InvokeSync:"invoke_sync",getProgress:"get_progress",GetProgress:"get_progress",Await:"await",await:"await",AwaitSubagent:"await",awaitSubagent:"await",Wait:"wait",wait:"wait",Answer:"answer",answer:"answer",AnswerSubagent:"answer",answerSubagent:"answer",Steer:"steer",steer:"steer",SteerSubagent:"steer",steerSubagent:"steer",Cancel:"cancel",cancel:"cancel",Click:"click",click:"click",Drag:"drag",drag:"drag",Scroll:"scroll",scroll:"scroll",KeyboardTyping:"keyboard_typing",keyboard_typing:"keyboard_typing",KeyPress:"key_press",key_press:"key_press",RecaptureScreen:"recapture_screen",recapture_screen:"recapture_screen",EmergencyRollback:"EmergencyRollback"}[y.toolName]||y.toolName,_e=fs[a]||y.toolName,q=Hn(a,y.args);yield{type:"status",content:`${_e}${q?` ${q}`:""}`};let R="";if(a==="click"){let c=L(y.args);R=`\u2714 Clicked ${c.intendedClickText?`: ${c.intendedClickText}`:"Screen"}`}else if(a==="drag"){let c=L(y.args);R=`\u2714 Dragged: Cell ${c.fromGridId||""} \u2192 Cell ${c.toGridId||""}`}else if(a==="scroll"){let c=L(y.args);R=`\u2714 Scrolled: ${c.direction||"down"} (${c.amount||1})`}else if(a==="keyboard_typing"){let c=L(y.args);R=`\u2714 ${c.autoPressEnter?"Entered":"Typed"}: ${c.text?`"${c.text.length>20?c.text.substring(0,20)+"...":c.text}"`:""}`}else if(a==="key_press")R=`\u2714 Pressed Key: ${L(y.args).key||""}`;else if(a==="recapture_screen")R="\u2714 Recaptured Screen";else if(a==="web_search"){let{query:c,limit:T=10,aiMode:D=!1}=L(y.args);R=`${c?"\u2714":"\u2718"} ${D?"AI Search":"Searched"}: ${c?`${c}`:"No Search Query"}${D===!1&&c?` \u2192 ${T}`:""}`}else if(a==="web_scrape"){let c=L(y.args).url||null;R=`${c?"\u2714":"\u2718"} Visited: ${c||"No Source"}`}else if(a==="view_file"){let{path:c,StartLine:T,EndLine:D,start_line:fe,end_line:ie,startLine:ee,endLine:ue}=L(y.args),Ae=T||fe||ee,Y=D||ie||ue,K=parseInt(Ae)||1,B=parseInt(Y)||(Ae?K+800:800),ge="...",We=B,$=(c||"").trim().toLowerCase().replaceAll("\\","/");if($.startsWith("#skill"))$.startsWith("#skill/global/fluxflow")||$.startsWith("#skills/global/fluxflow")||$.includes("#skill/fluxflow")||$.includes("#skills/fluxflow")?R="\u2714 Read Documentation":R=`\u2714 Read Skill: ${te.basename(c.replaceAll("\\","/"))}`;else{try{let Me=te.resolve(process.cwd(),c);if(ve.existsSync(Me)){let be=ve.readFileSync(Me,"utf8").split(`
658
- `).length;ge=be,!Ae&&!Y&&be>800?We=Math.min(50,be):We=Math.min(B,be)}}catch{}let yt=(c||"").toLowerCase(),fo=yt.endsWith(".pdf"),Ft=yt.endsWith(".docx")||yt.endsWith(".doc")||yt.endsWith(".ppt")||yt.endsWith(".pptx")||yt.endsWith(".xls")||yt.endsWith(".xlsx"),ae=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(yt);fo||Ft?R=`${c.length>0?"\u2714":"\u2718"} ${c?`Analyzed: ${te.basename(c)}`:"Analyzed: File Not Found"}`:ae?R=`${c.length>0?"\u2714":"\u2718"} ${c?`Processed: ${te.basename(c)}`:"Processed: File Not Found"}`:R=`${ge!=="..."?"\u2714":"\u2718"} Read: ${c?`${te.basename(c)} \u2192 ${ge!=="..."?`Lines ${K} - ${We} of ${ge}`:"File Not Found"}`:"File Not Found"}`}}else if(a==="list_files"||a==="read_folder"){let c=a==="list_files"?"List":"Browsed",T=L(y.args).path||null,D=L(y.args).recurse||1;R=`${T?"\u2714":"\u2718"} ${c}: ${T?`${T==="."?`./${D>1?"*":""}`:`${T.replaceAll("\\","/")}${D>1?`${T.endsWith("/")?"*":"/*"}`:`${T.endsWith("/")?"":"/"}`}`}`:"No Folder Selected"}`}else if(a==="find_file"){let c=L(y.args),T=c.basename||c.name||c.path||c.file||c.query||"";R=`${T?"\u2714":"\u2718"} Located: ${T||"No Query"}`}else if(a==="write_file"||a==="update_file"){let c=a==="write_file"?"Created":"Edited",T=L(y.args),D=T.path||null,ie=Object.entries(T).some(([ee,ue])=>ee.startsWith("searchContent")&&typeof ue=="string"&&ue.startsWith("^LINE:"))?"\u1361":":";R=`${D?"\u2714":"\u2718"} ${c}${ie} ${D?D.replaceAll("\\","/"):"No File Changes"}`}else if(a==="write_pdf"){let c=L(y.args).path||null;R=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No PDF Generated"}`}else if(a==="write_docx"){let c=L(y.args).path||null;R=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No Docx Generated"}`}else if(a==="file_map"){let c=L(y.args).path;R=`${c?"\u2714":"\u2718"} Indexed: ${c.replaceAll("\\","/")?""+c:"File Not Found"}`}else if(a.toLowerCase()==="search_keyword"||a.toLowerCase()==="todo")R="";else if(a.toLowerCase()==="generate_image"){let{path:c,outputPath:T,output:D}=L(y.args);R=`\u2714 Generated: ${c||T||D||"generated_image.png"}`}else if(a==="invoke_sync"||a==="InvokeSync"){let c=Hn(a,y.args);R=`\u2714 Called Generalist${c?`: ${c}`:""}`}else if(a==="Invoke"||a==="InvokeAsync"||a==="invoke"){let c=Hn(a,y.args);R=`\u2714 Started Generalist${c?`: ${c}`:""}`}else if(a==="get_progress"||a==="GetProgress"){let c=Hn(a,y.args);R=`\u2714 Checked${c?`: ${c}`:""}`}else if(a==="cancel"){let c=Hn(a,y.args);R=`\u{1F6C7} Cancelled${c?`: ${c}`:""}`}else if(a==="steer"||a==="Steer"){let c=Hn(a,y.args);R=`\u2714 Steered${c?`: ${c}`:""}`}else if(a==="EmergencyRollback"){let{method:c}=L(y.args);R=c==="forceRevert"?"":"\u2714 Rollback Point Checked"}else if(a==="await"||a==="Await"||a==="wait"||a==="Wait"){let{time:c,timeout:T,seconds:D,sec:fe}=L(y.args),ie=parseFloat(D||fe||T||c)||45,ee=a==="wait"||a==="Wait"?120:180;ie<10&&(ie=10),ie>ee&&(ie=ee);let ue=K=>{if(K>=60){let B=Math.floor(K/60),ge=K%60;return`${B}m${ge>0?` ${ge}s`:""}`}return`${K}s`},Ae=["Aligning Moon Phase","Contemplating Existence","Staring At Void","Delaying Professionally","Negotiating With Electrons","Touching Grass (virtually)","Panicking Softly","Rethinking Career Choices","Loading Cat Videos","Summoning Braincell #2","Pretending To Be Busy","Waiting For Motivation DLC","Rotating Internal Screaming","Downloading More RAM","Feeding The Hamsters","Gaslighting Scheduler","Performing Dramatic Pause","Buffering Social Energy","Calculating Regret","Reading Terms And Conditions","Becoming Sentient Briefly","Contacting Ancestors"];R=`\u2714 ${Ae[Math.floor(Math.random()*Ae.length)]} \u2192 ${ue(ie)}`}else a==="Answer"||a==="answer"?R="\u2714 Resolved Sub-Agent Query":a==="exec_command"||a==="ask"?R="":R=`Executed: ${y.toolName}`;if(yield*nn(),a==="exec_command"){let{command:c}=L(y.args);if(c&&t.systemSettings&&t.systemSettings.allowExternalAccess===!1){let T=[/[a-zA-Z]:[\\\/]/i,/^\//,/\.\.[\\\/]/,/\/etc\//,/\/var\//,/\/root\//,/\/bin\//,/\/usr\//],D=te.resolve(process.cwd()).substring(0,3).toLowerCase(),fe=Y=>{let K=[],B="",ge=null;for(let We=0;We<Y.length;We++){let $=Y[We];ge?($===ge&&(ge=null),B+=$):$==='"'||$==="'"?(ge=$,B+=$):$==="&"&&Y[We+1]==="&"||$==="|"&&Y[We+1]==="|"?(B.trim()&&(K.push(B.trim()),B=""),We++):$===";"||$==="|"||$==="&"?B.trim()&&(K.push(B.trim()),B=""):B+=$}return B.trim()&&K.push(B.trim()),K},ie=Y=>{let K=[],B="",ge=null;for(let We=0;We<Y.length;We++){let $=Y[We];ge?($===ge&&(ge=null),B+=$):$==='"'||$==="'"?(ge=$,B+=$):/\s/.test($)?B&&(K.push(B),B=""):B+=$}return B&&K.push(B),K},ee=Y=>{let K=Y.replace(/^['"]|['"]$/g,"").trim();return!K||process.platform==="win32"&&/^\/[a-zA-Z0-9?]+$/.test(K)?!1:T.some(B=>{if(B.source==="[a-zA-Z]:[\\\\\\/]"){let ge=K.match(/[a-zA-Z]:[\\\/]/i);return ge&&ge[0].toLowerCase()!==D}return B.test(K)})};if(fe(c).some(Y=>{let K=ie(Y);if(K.length===0)return!1;let B=K[0].replace(/^['"]|['"]$/g,"").toLowerCase();if(["echo","printf","write-output"].includes(B)){let We=!1;return K.some($=>{let ht=$.replace(/^['"]|['"]$/g,"");if(ht===">"||ht===">>"||ht==="<")return We=!0,!1;if(ht.startsWith(">")||ht.startsWith("<")){let yt=ht.replace(/^[><]+/,"");return ee(yt)}return We?(We=!1,ee($)):!1})}return K.some(We=>ee(We))})){let Y='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(K=>setTimeout(K,50)),t.onExecChunk&&t.onExecChunk(`ERROR: ${Y}`),await new Promise(K=>setTimeout(K,50)),t.onExecEnd&&t.onExecEnd(),Ge.push({role:"user",text:`[ACTION RESULT]: ERROR: ${Y}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${Y}`},bt++;continue}}t.onExecStart&&t.onExecStart(c||"No Command"),yield{type:"exec_start"}}let at=L(y.args),gn=at.path||at.targetPath||null;if(gn){let c=t.systemSettings&&t.systemSettings.allowExternalAccess===!1,T=te.resolve(gn),D=te.resolve(process.cwd());if(c&&!T.startsWith(D)){let fe="Access Denied. You are not allowed to access files outside the current workspace.";if(a==="write_file"||a==="update_file"){let ee=`\u2718 ${a==="write_file"?"Write Canceled":"Edit Canceled"}: ${at.path||"..."}`,ue=115;process.stdout.isTTY&&(ue=process.stdout.columns-5||120);let Ae=Math.min(ee.length+4,ue),Y=`${ee.padEnd(Ae-2).substring(0,Ae-2)}`;yield{type:"visual_feedback",content:Rt(`${He?`
676
+ \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(S){if(tt){if(ke+=S,ke.length>=64){let y=0,k=Math.min(dt.length,ke.length);for(let a=k;a>=10;a--)if(dt.endsWith(ke.substring(0,a))){y=a;break}let Q=ke.substring(y);if(Q){let _e=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(dt)?Q.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):Q.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");if(_e)if(we+=_e,s==="Google")it+=_e;else{yield*on();let q=lo(_e);for(let R of q)yield R}}tt=!1,ke=""}continue}else if(we+=S,s==="Google")it+=S;else{yield*on();let y=lo(S);for(let k of y)yield k}let I=bl(we);if(I.inside){Nt=!0,$n||($n=Date.now());let k={Ask:"ask",AskUser:"ask",WebSearch:"web_search",WebScrape:"web_scrape",ReadFile:"view_file",ReadFolder:"read_folder",WriteFile:"write_file",PatchFile:"update_file",WritePDF:"write_pdf",WriteDoc:"write_docx",FindFile:"find_file",find_file:"find_file",findfile:"find_file",Run:"exec_command",SearchKeyword:"search_keyword",CodeSearch:"search_keyword",code_search:"search_keyword",Code_Search:"search_keyword",codesearch:"search_keyword",Memory:"memory",file_map:"file_map",FileMap:"file_map",Chat:"chat",chat:"chat",GenerateImage:"generate_image",generate_image:"generate_image",todo:"todo",Todo:"todo",goal:"todo",Goal:"todo",Invoke:"invoke",InvokeSync:"invoke_sync",getProgress:"get_progress",GetProgress:"get_progress",Cancel:"cancel",Await:"await",wait:"wait",Answer:"answer",Steer:"steer",steer:"steer"}[I.toolName]||I.toolName,Q=I.args||"",a=null;if(["write_file","update_file","view_file","read_folder","find_file","write_pdf","write_docx","search_keyword","generate_image","file_map","invoke","invoke_sync","get_progress","await","wait","answer"].includes(k)){let q=O(Q),R=q.basename||q.name||q.path||q.targetFile||q.TargetFile||q.directory||q.file,at=q.keyword,mn=q.title||q.task,At=q.id||q.taskId,Z=q.timeout||q.time||q.seconds||q.sec;if(at!=null)a=String(at).replace(bn,"");else if(R)a=te.basename(String(R).replace(bn,"").replace(ea,"/"));else if(mn&&(k==="invoke"||k==="invoke_sync"))a=String(mn).replace(bn,"").substring(0,30);else if(At&&k==="get_progress")a=String(At).replace(bn,"");else if(Z&&k==="await"){let je=parseFloat(String(Z).replace(bn,""));isNaN(je)?a=String(Z).replace(bn,""):(je<5&&(je=5),je>120&&(je=180),a=(Ct=>{if(Ct>=60){let fo=Math.floor(Ct/60),pn=Ct%60;return`${fo}m${pn>0?` ${pn}s`:""}`}return`${Ct}s`})(je))}else if(Z&&k==="wait"){let je=parseFloat(String(Z).replace(bn,""));isNaN(je)?a=String(Z).replace(bn,""):(je<10&&(je=10),je>120&&(je=120),a=(Ct=>{if(Ct>=60){let fo=Math.floor(Ct/60),pn=Ct%60;return`${fo}m${pn>0?` ${pn}s`:""}`}return`${Ct}s`})(je))}else{let je=Q.match(fl);if(je){let lt=je[1].replace(bn,"");k==="invoke"||k==="invoke_sync"||k==="get_progress"?a=lt.substring(0,30):a=k==="search_keyword"||k==="file_map"?lt:te.basename(lt.replace(ea,"/"))}}}let _e=`${ps[k]||k}${a?` ${a}`:""}`;if((k!==Mt||a!==ro)&&(Mt=k,ro=a,yield{type:"status",content:`${_e}`},process.stdout.isTTY)){let R={WebSearch:"Searching",web_search:"Searching",WebScrape:"Reading",web_scrape:"Reading",ReadFile:"Reading",read_file:"Reading",ReadFolder:"Reading",read_folder:"Reading",WriteFile:"Writing",write_file:"Writing",UpdateFile:"Editing",update_file:"Editing",WritePdf:"Creating",write_pdf:"Creating",WriteDocx:"Creating",write_docx:"Creating",SearchKeyword:"Searching",search_keyword:"Searching",CodeSearch:"Searching",code_search:"Searching",FindFile:"Finding File",find_file:"Finding File",Run:"Executing",Ask:"User Input Required",AskUser:"User Input Required",Memory:"Updating Memory",GenerateImage:"Generating",InvokeSync:"Sub-Agent Working",invoke_sync:"Sub-Agent Working",Invoke:"Working",invoke:"Working",GetProgress:"Checking Progress",get_progress:"Checking Progress",Cancel:"Stopping Generalist",cancel:"Stopping Generalist",Await:"Waiting",await:"Waiting",wait:"Waiting",EmergencyRollback:"Rolling the Ball",Answer:"Answering Sub-Agent",answer:"Answering Sub-Agent",Steer:"Steering Sub-Agent",steer:"Steering Sub-Agent",Click:"Clicking",click:"Clicking",Drag:"Dragging",drag:"Dragging",Scroll:"Scrolling",scroll:"Scrolling",KeyboardTyping:"Typing",keyboard_typing:"Typing",KeyPress:"Pressing Key",key_press:"Pressing Key",RecaptureScreen:"Recapturing Screen",recapture_screen:"Recapturing Screen"}[k]||"Working";process.stdout.write(`\x1B]0;${R}...\x07`)}}if(we.length-Jn>800){Jn=we.length;let y=da(we,!1),k=ms(y),Q=k?(k.innerContent||"").trim():"",a=Q.split(/[.!?]\s+/).filter(de=>de.trim().length>10),_e=new Set(a),q=a.length>25?(a.length-_e.size)/a.length:0,R=Q.split(/\s+/).filter(de=>de.length>0).length,at=.9,mn=.92,At=!1;if(s.toLowerCase().includes("google")&&(J||"").toLowerCase().startsWith("gemma")){let c={low:2048,medium:4096,high:32768,max:65536,xhigh:65536}[d?.toLowerCase()]||16e3;At=R>c}if(q>at||At){yield{type:"status",content:`${q>at?"Reasoning Loop Detected":"Thinking Budget Exceeded"}. Re-centering...`},Tt=!0,await new Promise(c=>setTimeout(c,3e3));break}let lt=sa(we).trim().split(/[.!?]\s+/).filter(de=>de.trim().length>10),Ct=new Set(lt);if((lt.length>25?(lt.length-Ct.size)/lt.length:0)>mn){yield{type:"status",content:"Response Loop Detected. Re-centering..."},Tt=!1,Pt=!0,await new Promise(de=>setTimeout(de,3e3));break}let pn=y.replace(il,"").replace(sl,"").replace(rl,"").replace(al,""),pt=pn.toLowerCase().split(/\s+/).map(de=>de.replace(ll,"")).filter(de=>de.length>0),Xt=!1;if(pt.length>=40)for(let de=1;de<=15;de++){let c=Math.max(8,Math.ceil(25/de));if(pt.length<de*c)continue;let T=pt.slice(pt.length-de),D=T.join(" ");if(de>1&&D===T.slice(0,Math.floor(de/2)).join(" ").repeat(2).trim())continue;let fe=!0;for(let ie=1;ie<c;ie++)if(pt.slice(pt.length-de*(ie+1),pt.length-de*ie).join(" ")!==D){fe=!1;break}if(fe){Xt=!0;break}}if(!Xt){let de=pn.toLowerCase().replace(cl,"");if(de.length>=80)for(let c=1;c<=10;c++){let T=Math.max(15,Math.ceil(45/c));if(de.length<c*T)continue;let D=de.substring(de.length-c),fe=!0;for(let ie=1;ie<T;ie++)if(de.substring(de.length-c*(ie+1),de.length-c*ie)!==D){fe=!1;break}if(fe){Xt=!0;break}}}if(Xt){yield{type:"status",content:"Stuttering Detected. Re-centering..."},Tt=!1,On=!0,await new Promise(de=>setTimeout(de,3e3));break}}let j=Ot(we),rt=En(j);for(;rt.length>bt;){yield*on();let y=rt[bt],k=Date.now(),a={Ask:"ask",AskUser:"ask",WebSearch:"web_search",WebScrape:"web_scrape",ReadFile:"view_file",ReadFolder:"read_folder",FindFile:"find_file",find_file:"find_file",findfile:"find_file",WriteFile:"write_file",PatchFile:"update_file",WritePDF:"write_pdf",WriteDoc:"write_docx",Run:"exec_command",SearchKeyword:"search_keyword",CodeSearch:"search_keyword",code_search:"search_keyword",Code_Search:"search_keyword",codesearch:"search_keyword",Memory:"memory",file_map:"file_map",FileMap:"file_map",Chat:"chat",chat:"chat",GenerateImage:"generate_image",generate_image:"generate_image",todo:"todo",Todo:"todo",goal:"todo",Goal:"todo",Invoke:"invoke",InvokeSync:"invoke_sync",getProgress:"get_progress",GetProgress:"get_progress",Await:"await",await:"await",AwaitSubagent:"await",awaitSubagent:"await",Wait:"wait",wait:"wait",Answer:"answer",answer:"answer",AnswerSubagent:"answer",answerSubagent:"answer",Steer:"steer",steer:"steer",SteerSubagent:"steer",steerSubagent:"steer",Cancel:"cancel",cancel:"cancel",Click:"click",click:"click",Drag:"drag",drag:"drag",Scroll:"scroll",scroll:"scroll",KeyboardTyping:"keyboard_typing",keyboard_typing:"keyboard_typing",KeyPress:"key_press",key_press:"key_press",RecaptureScreen:"recapture_screen",recapture_screen:"recapture_screen",EmergencyRollback:"EmergencyRollback"}[y.toolName]||y.toolName,_e=ps[a]||y.toolName,q=jn(a,y.args);yield{type:"status",content:`${_e}${q?` ${q}`:""}`};let R="";if(a==="click"){let c=O(y.args);R=`\u2714 Clicked ${c.intendedClickText?`: ${c.intendedClickText}`:"Screen"}`}else if(a==="drag"){let c=O(y.args);R=`\u2714 Dragged: Cell ${c.fromGridId||""} \u2192 Cell ${c.toGridId||""}`}else if(a==="scroll"){let c=O(y.args);R=`\u2714 Scrolled: ${c.direction||"down"} (${c.amount||1})`}else if(a==="keyboard_typing"){let c=O(y.args);R=`\u2714 ${c.autoPressEnter?"Entered":"Typed"}: ${c.text?`"${c.text.length>20?c.text.substring(0,20)+"...":c.text}"`:""}`}else if(a==="key_press")R=`\u2714 Pressed Key: ${O(y.args).key||""}`;else if(a==="recapture_screen")R="\u2714 Recaptured Screen";else if(a==="web_search"){let{query:c,limit:T=10,aiMode:D=!1}=O(y.args);R=`${c?"\u2714":"\u2718"} ${D?"AI Search":"Searched"}: ${c?`${c}`:"No Search Query"}${D===!1&&c?` \u2192 ${T}`:""}`}else if(a==="web_scrape"){let c=O(y.args).url||null;R=`${c?"\u2714":"\u2718"} Visited: ${c||"No Source"}`}else if(a==="view_file"){let{path:c,StartLine:T,EndLine:D,start_line:fe,end_line:ie,startLine:ee,endLine:ue}=O(y.args),Ae=T||fe||ee,Y=D||ie||ue,K=parseInt(Ae)||1,B=parseInt(Y)||(Ae?K+800:800),ge="...",We=B,L=(c||"").trim().toLowerCase().replaceAll("\\","/");if(L.startsWith("#skill"))L.startsWith("#skill/global/fluxflow")||L.startsWith("#skills/global/fluxflow")||L.includes("#skill/fluxflow")||L.includes("#skills/fluxflow")?R="\u2714 Read Documentation":R=`\u2714 Read Skill: ${te.basename(c.replaceAll("\\","/"))}`;else{try{let Me=te.resolve(process.cwd(),c);if(ve.existsSync(Me)){let be=ve.readFileSync(Me,"utf8").split(`
677
+ `).length;ge=be,!Ae&&!Y&&be>800?We=Math.min(50,be):We=Math.min(B,be)}}catch{}let yt=(c||"").toLowerCase(),uo=yt.endsWith(".pdf"),Bt=yt.endsWith(".docx")||yt.endsWith(".doc")||yt.endsWith(".ppt")||yt.endsWith(".pptx")||yt.endsWith(".xls")||yt.endsWith(".xlsx"),ae=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(yt);uo||Bt?R=`${c.length>0?"\u2714":"\u2718"} ${c?`Analyzed: ${te.basename(c)}`:"Analyzed: File Not Found"}`:ae?R=`${c.length>0?"\u2714":"\u2718"} ${c?`Processed: ${te.basename(c)}`:"Processed: File Not Found"}`:R=`${ge!=="..."?"\u2714":"\u2718"} Read: ${c?`${te.basename(c)} \u2192 ${ge!=="..."?`Lines ${K} - ${We} of ${ge}`:"File Not Found"}`:"File Not Found"}`}}else if(a==="list_files"||a==="read_folder"){let c=a==="list_files"?"List":"Browsed",T=O(y.args).path||null,D=O(y.args).recurse||1;R=`${T?"\u2714":"\u2718"} ${c}: ${T?`${T==="."?`./${D>1?"*":""}`:`${T.replaceAll("\\","/")}${D>1?`${T.endsWith("/")?"*":"/*"}`:`${T.endsWith("/")?"":"/"}`}`}`:"No Folder Selected"}`}else if(a==="find_file"){let c=O(y.args),T=c.basename||c.name||c.path||c.file||c.query||"";R=`${T?"\u2714":"\u2718"} Located: ${T||"No Query"}`}else if(a==="write_file"||a==="update_file"){let c=a==="write_file"?"Created":"Edited",T=O(y.args),D=T.path||null,ie=Object.entries(T).some(([ee,ue])=>ee.startsWith("searchContent")&&typeof ue=="string"&&ue.startsWith("^LINE:"))?"\u1361":":";R=`${D?"\u2714":"\u2718"} ${c}${ie} ${D?D.replaceAll("\\","/"):"No File Changes"}`}else if(a==="write_pdf"){let c=O(y.args).path||null;R=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No PDF Generated"}`}else if(a==="write_docx"){let c=O(y.args).path||null;R=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No Docx Generated"}`}else if(a==="file_map"){let c=O(y.args).path;R=`${c?"\u2714":"\u2718"} Indexed: ${c.replaceAll("\\","/")?""+c:"File Not Found"}`}else if(a.toLowerCase()==="search_keyword"||a.toLowerCase()==="todo")R="";else if(a.toLowerCase()==="generate_image"){let{path:c,outputPath:T,output:D}=O(y.args);R=`\u2714 Generated: ${c||T||D||"generated_image.png"}`}else if(a==="invoke_sync"||a==="InvokeSync"){let c=jn(a,y.args);R=`\u2714 Called Generalist${c?`: ${c}`:""}`}else if(a==="Invoke"||a==="InvokeAsync"||a==="invoke"){let c=jn(a,y.args);R=`\u2714 Started Generalist${c?`: ${c}`:""}`}else if(a==="get_progress"||a==="GetProgress"){let c=jn(a,y.args);R=`\u2714 Checked${c?`: ${c}`:""}`}else if(a==="cancel"){let c=jn(a,y.args);R=`\u{1F6C7} Cancelled${c?`: ${c}`:""}`}else if(a==="steer"||a==="Steer"){let c=jn(a,y.args);R=`\u2714 Steered${c?`: ${c}`:""}`}else if(a==="EmergencyRollback"){let{method:c}=O(y.args);R=c==="forceRevert"?"":"\u2714 Rollback Point Checked"}else if(a==="await"||a==="Await"||a==="wait"||a==="Wait"){let{time:c,timeout:T,seconds:D,sec:fe}=O(y.args),ie=parseFloat(D||fe||T||c)||45,ee=a==="wait"||a==="Wait"?120:180;ie<10&&(ie=10),ie>ee&&(ie=ee);let ue=K=>{if(K>=60){let B=Math.floor(K/60),ge=K%60;return`${B}m${ge>0?` ${ge}s`:""}`}return`${K}s`},Ae=["Aligning Moon Phase","Contemplating Existence","Staring At Void","Delaying Professionally","Negotiating With Electrons","Touching Grass (virtually)","Panicking Softly","Rethinking Career Choices","Loading Cat Videos","Summoning Braincell #2","Pretending To Be Busy","Waiting For Motivation DLC","Rotating Internal Screaming","Downloading More RAM","Feeding The Hamsters","Gaslighting Scheduler","Performing Dramatic Pause","Buffering Social Energy","Calculating Regret","Reading Terms And Conditions","Becoming Sentient Briefly","Contacting Ancestors"];R=`\u2714 ${Ae[Math.floor(Math.random()*Ae.length)]} \u2192 ${ue(ie)}`}else a==="Answer"||a==="answer"?R="\u2714 Resolved Sub-Agent Query":a==="exec_command"||a==="ask"?R="":R=`Executed: ${y.toolName}`;if(yield*on(),a==="exec_command"){let{command:c}=O(y.args);if(c&&t.systemSettings&&t.systemSettings.allowExternalAccess===!1){let T=[/[a-zA-Z]:[\\\/]/i,/^\//,/\.\.[\\\/]/,/\/etc\//,/\/var\//,/\/root\//,/\/bin\//,/\/usr\//],D=te.resolve(process.cwd()).substring(0,3).toLowerCase(),fe=Y=>{let K=[],B="",ge=null;for(let We=0;We<Y.length;We++){let L=Y[We];ge?(L===ge&&(ge=null),B+=L):L==='"'||L==="'"?(ge=L,B+=L):L==="&"&&Y[We+1]==="&"||L==="|"&&Y[We+1]==="|"?(B.trim()&&(K.push(B.trim()),B=""),We++):L===";"||L==="|"||L==="&"?B.trim()&&(K.push(B.trim()),B=""):B+=L}return B.trim()&&K.push(B.trim()),K},ie=Y=>{let K=[],B="",ge=null;for(let We=0;We<Y.length;We++){let L=Y[We];ge?(L===ge&&(ge=null),B+=L):L==='"'||L==="'"?(ge=L,B+=L):/\s/.test(L)?B&&(K.push(B),B=""):B+=L}return B&&K.push(B),K},ee=Y=>{let K=Y.replace(/^['"]|['"]$/g,"").trim();return!K||process.platform==="win32"&&/^\/[a-zA-Z0-9?]+$/.test(K)?!1:T.some(B=>{if(B.source==="[a-zA-Z]:[\\\\\\/]"){let ge=K.match(/[a-zA-Z]:[\\\/]/i);return ge&&ge[0].toLowerCase()!==D}return B.test(K)})};if(fe(c).some(Y=>{let K=ie(Y);if(K.length===0)return!1;let B=K[0].replace(/^['"]|['"]$/g,"").toLowerCase();if(["echo","printf","write-output"].includes(B)){let We=!1;return K.some(L=>{let ht=L.replace(/^['"]|['"]$/g,"");if(ht===">"||ht===">>"||ht==="<")return We=!0,!1;if(ht.startsWith(">")||ht.startsWith("<")){let yt=ht.replace(/^[><]+/,"");return ee(yt)}return We?(We=!1,ee(L)):!1})}return K.some(We=>ee(We))})){let Y='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(K=>setTimeout(K,50)),t.onExecChunk&&t.onExecChunk(`ERROR: ${Y}`),await new Promise(K=>setTimeout(K,50)),t.onExecEnd&&t.onExecEnd(),Ge.push({role:"user",text:`[ACTION RESULT]: ERROR: ${Y}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${Y}`},bt++;continue}}t.onExecStart&&t.onExecStart(c||"No Command"),yield{type:"exec_start"}}let at=O(y.args),mn=at.path||at.targetPath||null;if(mn){let c=t.systemSettings&&t.systemSettings.allowExternalAccess===!1,T=te.resolve(mn),D=te.resolve(process.cwd());if(c&&!T.startsWith(D)){let fe="Access Denied. You are not allowed to access files outside the current workspace.";if(a==="write_file"||a==="update_file"){let ee=`\u2718 ${a==="write_file"?"Write Canceled":"Edit Canceled"}: ${at.path||"..."}`,ue=115;process.stdout.isTTY&&(ue=process.stdout.columns-5||120);let Ae=Math.min(ee.length+4,ue),Y=`${ee.padEnd(Ae-2).substring(0,Ae-2)}`;yield{type:"visual_feedback",content:Rt(`${He?`
659
678
  `:""}${Y}
660
- `)},He=!1}Ge.push({role:"user",text:`[ACTION RESULT]: ERROR: ${fe}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${fe}`},bt++;continue}}if(t.onToolApproval){let c=t.systemSettings||{},T=c.autoExec,D=!1,fe="";if(a==="view_file"){let ee=L(y.args);if(fe=ee.path||ee.targetPath||ee.file||"",fe){let ue=c.alwaysAskFiles||".env, .env.*, *.env";Ms(fe,ue)&&(D=!0)}}if(a==="write_file"||a==="update_file"||a==="exec_command"||D){let ee=null,ue=!1,Ae=!1,Y=!1,K=!1;if(D)ue=!0,ee=null;else if(a==="exec_command"){let{command:ae}=L(y.args),Me=(ae||"").trim(),be=(Je=>{let Qe=[],Ze="",le=null;for(let Ce=0;Ce<Je.length;Ce++){let he=Je[Ce];le?(he===le&&(le=null),Ze+=he):he==='"'||he==="'"?(le=he,Ze+=he):he==="&"&&Je[Ce+1]==="&"||he==="|"&&Je[Ce+1]==="|"?(Ze.trim()&&(Qe.push(Ze.trim()),Ze=""),Ce++):he===";"||he==="|"||he==="&"?Ze.trim()&&(Qe.push(Ze.trim()),Ze=""):Ze+=he}return Ze.trim()&&Qe.push(Ze.trim()),Qe.length>0?Qe:[Je]})(Me),F=(Je,Qe)=>{if(!Qe)return!1;let Ze=Qe.split(",").map(Ce=>Ce.trim().toLowerCase()).filter(Boolean),le=Je.toLowerCase();return Ze.some(Ce=>{if(le===Ce)return!0;if(le.startsWith(Ce)){let he=le.charAt(Ce.length);return/\s|[;&|/]/.test(he)}return!1})},Xt=be.some(Je=>F(Je,c.alwaysAskCommands)),Nn=be.some(Je=>F(Je,c.autoDisallowCommands)),on=be.length>0&&be.every(Je=>F(Je,c.autoApproveCommands)||c.autoApproveGit&&/^git\s+commit\b/i.test(Je));if(Nn)ee="deny";else if(c.networkAccess===!1){let Qe=Me.trim().replace(/\s+/g," ").replace(/^['"]+|['"]+$/g,"").toLowerCase().split(" "),le=Qe[0].split("/").pop().split("\\").pop().replace(/\.exe$/,""),Ce=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"]),he=!1;Ce.has(le)&&(he=!0);let Pt=hn=>Qe.slice(1).some(yn=>hn.includes(yn)),pn=hn=>{let yn=Qe.findIndex(xt=>hn.includes(xt)),Zn=Qe.findIndex(xt=>["run","exec","test"].includes(xt));return yn!==-1&&!(Zn!==-1&&Zn<yn)};le==="git"&&Pt(["clone","pull","push","fetch"])&&(he=!0),le==="go"&&Pt(["get","install"])&&(he=!0),le==="npm"&&pn(["install","i","update","add"])&&(he=!0),le==="yarn"&&pn(["add","install","upgrade"])&&(he=!0),le==="pnpm"&&pn(["add","install","update"])&&(he=!0),le==="bun"&&pn(["add","install","update"])&&(he=!0),le==="deno"&&Pt(["install","add"])&&(he=!0),le==="pip"&&Pt(["install","download"])&&(he=!0),le==="pip3"&&Pt(["install","download"])&&(he=!0),le==="cargo"&&Pt(["install","add"])&&(he=!0),["bash","sh","zsh","fish"].includes(le)&&Pt(["-c"])&&(he=!0),le==="cmd"&&Pt(["/c"])&&(he=!0),he&&(ee="deny",Y=!0)}!ee&&Xt?ue=!0:!ee&&!ue&&(on||c.autoApproveGit&&/^git\s+commit\b/i.test(Me))&&(ee="allow"),!ue&&!ee&&T&&(ee="allow")}else if(a==="write_file"||a==="update_file"){let ae=!1;if(a==="write_file"&&c.overwriteProtection!==!1&&T)try{let{path:Me}=L(y.args);Me&&ve.existsSync(te.resolve(process.cwd(),Me))&&(ae=!0,K=!0)}catch{}T&&!ae&&(ee="allow")}let B=ee,ge="";ee==="deny"&&(Y?ge="network":Ae?ge="settings":ge="prohibited");let We=!1,$="",ht=[],yt=0,fo=!1,Ft="";if(!B&&t.onToolApproval)try{let ae=await t.onToolApproval(a,y.args,{checkOnly:!0});K&&ae==="allow"||(ae==="allow"||ae==="deny")&&(B=ae,B==="deny"&&(ge="user"))}catch{}if(!B){if(!K&&(a==="write_file"||a==="update_file"))try{let Te=L(y.args),{path:be}=Te;if(be){let F=te.resolve(process.cwd(),be),Xt=le=>le?le.toLowerCase().replace(/\\/g,"/").replace(/^[a-z]:/,Ce=>Ce.toUpperCase()):"",Nn=Xt(F),on="",Je=!1,Qe=await Un(),Ze=Xt(Qe?.file_focused);if(Qe&&Ze===Nn&&Qe.full_content?(on=Qe.full_content,Je=!0):ve.existsSync(F)&&(on=ve.readFileSync(F,"utf8"),Je=!0),$=on,await Yo.recordFileChange(F,on),Je){let le=on;if(a==="write_file"){let Ce=Te.content||Te.newContent||"";le=Ce.endsWith(`
679
+ `)},He=!1}Ge.push({role:"user",text:`[ACTION RESULT]: ERROR: ${fe}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${fe}`},bt++;continue}}if(t.onToolApproval){let c=t.systemSettings||{},T=c.autoExec,D=!1,fe="";if(a==="view_file"){let ee=O(y.args);if(fe=ee.path||ee.targetPath||ee.file||"",fe){let ue=c.alwaysAskFiles||".env, .env.*, *.env";Ls(fe,ue)&&(D=!0)}}if(a==="write_file"||a==="update_file"||a==="exec_command"||D){let ee=null,ue=!1,Ae=!1,Y=!1,K=!1;if(D)ue=!0,ee=null;else if(a==="exec_command"){let{command:ae}=O(y.args),Me=(ae||"").trim(),be=(Je=>{let Qe=[],Ze="",le=null;for(let Ce=0;Ce<Je.length;Ce++){let he=Je[Ce];le?(he===le&&(le=null),Ze+=he):he==='"'||he==="'"?(le=he,Ze+=he):he==="&"&&Je[Ce+1]==="&"||he==="|"&&Je[Ce+1]==="|"?(Ze.trim()&&(Qe.push(Ze.trim()),Ze=""),Ce++):he===";"||he==="|"||he==="&"?Ze.trim()&&(Qe.push(Ze.trim()),Ze=""):Ze+=he}return Ze.trim()&&Qe.push(Ze.trim()),Qe.length>0?Qe:[Je]})(Me),F=(Je,Qe)=>{if(!Qe)return!1;let Ze=Qe.split(",").map(Ce=>Ce.trim().toLowerCase()).filter(Boolean),le=Je.toLowerCase();return Ze.some(Ce=>{if(le===Ce)return!0;if(le.startsWith(Ce)){let he=le.charAt(Ce.length);return/\s|[;&|/]/.test(he)}return!1})},Jt=be.some(Je=>F(Je,c.alwaysAskCommands)),Fn=be.some(Je=>F(Je,c.autoDisallowCommands)),sn=be.length>0&&be.every(Je=>F(Je,c.autoApproveCommands)||c.autoApproveGit&&/^git\s+commit\b/i.test(Je));if(Fn)ee="deny";else if(c.networkAccess===!1){let Qe=Me.trim().replace(/\s+/g," ").replace(/^['"]+|['"]+$/g,"").toLowerCase().split(" "),le=Qe[0].split("/").pop().split("\\").pop().replace(/\.exe$/,""),Ce=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"]),he=!1;Ce.has(le)&&(he=!0);let $t=yn=>Qe.slice(1).some(xn=>yn.includes(xn)),hn=yn=>{let xn=Qe.findIndex(xt=>yn.includes(xt)),eo=Qe.findIndex(xt=>["run","exec","test"].includes(xt));return xn!==-1&&!(eo!==-1&&eo<xn)};le==="git"&&$t(["clone","pull","push","fetch"])&&(he=!0),le==="go"&&$t(["get","install"])&&(he=!0),le==="npm"&&hn(["install","i","update","add"])&&(he=!0),le==="yarn"&&hn(["add","install","upgrade"])&&(he=!0),le==="pnpm"&&hn(["add","install","update"])&&(he=!0),le==="bun"&&hn(["add","install","update"])&&(he=!0),le==="deno"&&$t(["install","add"])&&(he=!0),le==="pip"&&$t(["install","download"])&&(he=!0),le==="pip3"&&$t(["install","download"])&&(he=!0),le==="cargo"&&$t(["install","add"])&&(he=!0),["bash","sh","zsh","fish"].includes(le)&&$t(["-c"])&&(he=!0),le==="cmd"&&$t(["/c"])&&(he=!0),he&&(ee="deny",Y=!0)}!ee&&Jt?ue=!0:!ee&&!ue&&(sn||c.autoApproveGit&&/^git\s+commit\b/i.test(Me))&&(ee="allow"),!ue&&!ee&&T&&(ee="allow")}else if(a==="write_file"||a==="update_file"){let ae=!1;if(a==="write_file"&&c.overwriteProtection!==!1&&T)try{let{path:Me}=O(y.args);Me&&ve.existsSync(te.resolve(process.cwd(),Me))&&(ae=!0,K=!0)}catch{}T&&!ae&&(ee="allow")}let B=ee,ge="";ee==="deny"&&(Y?ge="network":Ae?ge="settings":ge="prohibited");let We=!1,L="",ht=[],yt=0,uo=!1,Bt="";if(!B&&t.onToolApproval)try{let ae=await t.onToolApproval(a,y.args,{checkOnly:!0});K&&ae==="allow"||(ae==="allow"||ae==="deny")&&(B=ae,B==="deny"&&(ge="user"))}catch{}if(!B){if(!K&&(a==="write_file"||a==="update_file"))try{let Te=O(y.args),{path:be}=Te;if(be){let F=te.resolve(process.cwd(),be),Jt=le=>le?le.toLowerCase().replace(/\\/g,"/").replace(/^[a-z]:/,Ce=>Ce.toUpperCase()):"",Fn=Jt(F),sn="",Je=!1,Qe=await Gn(),Ze=Jt(Qe?.file_focused);if(Qe&&Ze===Fn&&Qe.full_content?(sn=Qe.full_content,Je=!0):ve.existsSync(F)&&(sn=ve.readFileSync(F,"utf8"),Je=!0),L=sn,await Zo.recordFileChange(F,sn),Je){let le=sn;if(a==="write_file"){let Ce=Te.content||Te.newContent||"";le=Ce.endsWith(`
661
680
  `)?Ce:Ce+`
662
- `,Ft=le}else{let{patchPairs:Ce,allowMultiple:he,error:Pt}=$i(Te);if(Pt){let xt=`[ACTION RESULT]: ERROR: ${Pt}`;Ge.push({role:"user",text:xt}),await St("toolFailure"),t.onToolResult&&t.onToolResult("failure",a),yield{type:"tool_result",content:xt,toolName:a},bt++;continue}let pn=Te.allowMultiple!==void 0?Te.allowMultiple===!0||String(Te.allowMultiple).toLowerCase()==="true":he;yt=Ce.length;let hn=Os(on,Ce,{allowMultiple:pn});le=hn.content,Ft=le,ht=hn.results;let yn=ht.filter(xt=>xt.success),Zn=ht.filter(xt=>!xt.success);if(yn.length===0){let xt=`[ACTION RESULT]: ERROR: Failed to apply patches to [${te.basename(F)}].
663
- ${Zn.map(Le=>` \u2022 ${Le.error}`).join(`
664
- `)}`,Ai=`\u2714 Edited: ${te.basename(F.replaceAll("\\","/"))}`,Jt=115;process.stdout.isTTY&&(Jt=process.stdout.columns-5||120);let xn=Math.min(Ai.length+4,Jt),Ue=`${Ai.padEnd(xn-2).substring(0,xn-2)}`;yield{type:"visual_feedback",content:Rt(`${He?`
665
- `:""}${Ue}`)},He=!1,Ge.push({role:"user",text:xt}),await St("toolFailure"),t.onToolResult&&t.onToolResult("failure",a),yield{type:"tool_result",content:xt,toolName:a},bt++;continue}}yield{type:"status",content:`Opening Diff in IDE: ${te.basename(F)}`},Gi(F,on,le),We=!0,await new Promise(Ce=>setTimeout(Ce,50))}else if(a==="write_file"){let le=Te.content||Te.newContent||"",Ce=le.endsWith(`
681
+ `,Bt=le}else{let{patchPairs:Ce,allowMultiple:he,error:$t}=Fi(Te);if($t){let xt=`[ACTION RESULT]: ERROR: ${$t}`;Ge.push({role:"user",text:xt}),await St("toolFailure"),t.onToolResult&&t.onToolResult("failure",a),yield{type:"tool_result",content:xt,toolName:a},bt++;continue}let hn=Te.allowMultiple!==void 0?Te.allowMultiple===!0||String(Te.allowMultiple).toLowerCase()==="true":he;yt=Ce.length;let yn=Ds(sn,Ce,{allowMultiple:hn});le=yn.content,Bt=le,ht=yn.results;let xn=ht.filter(xt=>xt.success),eo=ht.filter(xt=>!xt.success);if(xn.length===0){let xt=`[ACTION RESULT]: ERROR: Failed to apply patches to [${te.basename(F)}].
682
+ ${eo.map(Oe=>` \u2022 ${Oe.error}`).join(`
683
+ `)}`,Ei=`\u2714 Edited: ${te.basename(F.replaceAll("\\","/"))}`,Qt=115;process.stdout.isTTY&&(Qt=process.stdout.columns-5||120);let wn=Math.min(Ei.length+4,Qt),Ue=`${Ei.padEnd(wn-2).substring(0,wn-2)}`;yield{type:"visual_feedback",content:Rt(`${He?`
684
+ `:""}${Ue}`)},He=!1,Ge.push({role:"user",text:xt}),await St("toolFailure"),t.onToolResult&&t.onToolResult("failure",a),yield{type:"tool_result",content:xt,toolName:a},bt++;continue}}yield{type:"status",content:`Opening Diff in IDE: ${te.basename(F)}`},Vi(F,sn,le),We=!0,await new Promise(Ce=>setTimeout(Ce,50))}else if(a==="write_file"){let le=Te.content||Te.newContent||"",Ce=le.endsWith(`
666
685
  `)?le:le+`
667
- `;Ft=Ce,ve.existsSync(F)||(fo=!0,ve.mkdirSync(te.dirname(F),{recursive:!0}),ve.writeFileSync(F,"","utf8")),yield{type:"status",content:`Opening New File Diff in IDE: ${te.basename(F)}`},Gi(F,"",Ce),We=!0,await new Promise(he=>setTimeout(he,50))}}}catch(Te){console.error("Simulation/Diff Error:",Te)}let ae=null;Ui(Te=>{ae=Te});let Me=t.onToolApproval;if(B=await new Promise(async Te=>{let be=setInterval(()=>{if(ae){let F=t.onIDEApproval||Mo&&Mo.onIDEApproval;F&&F(ae),clearInterval(be),Te(ae)}},100);try{let F=await Me(a,y.args,{isOverwritePrompt:K});clearInterval(be),Te(F)}catch{clearInterval(be),Te("deny")}}),Ui(null),a==="write_file"||a==="update_file"){let{path:Te}=L(y.args);if(Te){let be=te.resolve(process.cwd(),Te);if(sr(be,B),B==="deny"&&fo&&ve.existsSync(be))try{ve.unlinkSync(be)}catch{}}}B==="deny"&&(ge="user")}if(B==="allow"&&We&&oo()){let{path:ae}=L(y.args),Me=te.resolve(process.cwd(),ae),Te=Ue=>Ue?te.resolve(Ue).replace(/\\/g,"/").toLowerCase():"",be=await Un(),F="";if(be&&be.file_focused&&Te(be.file_focused)===Te(Me)&&be.full_content&&(F=be.full_content),!F&&ve.existsSync(Me)){let Ue=ve.readFileSync(Me,"utf8");Ue&&(F=Ue)}!F&&Ft&&(F=Ft),(F||fo)&&ve.writeFileSync(Me,F,"utf8");let Xt=F.split(/\r?\n/),Nn=Xt.length,on=Buffer.byteLength(F,"utf8"),Je="";$&&(Je=`Old File contents:
668
- ${$.split(/\r?\n/).map((Le,Bt)=>`${Bt+1} | ${Le}`).join(`
686
+ `;Bt=Ce,ve.existsSync(F)||(uo=!0,ve.mkdirSync(te.dirname(F),{recursive:!0}),ve.writeFileSync(F,"","utf8")),yield{type:"status",content:`Opening New File Diff in IDE: ${te.basename(F)}`},Vi(F,"",Ce),We=!0,await new Promise(he=>setTimeout(he,50))}}}catch(Te){console.error("Simulation/Diff Error:",Te)}let ae=null;Ki(Te=>{ae=Te});let Me=t.onToolApproval;if(B=await new Promise(async Te=>{let be=setInterval(()=>{if(ae){let F=t.onIDEApproval||Po&&Po.onIDEApproval;F&&F(ae),clearInterval(be),Te(ae)}},100);try{let F=await Me(a,y.args,{isOverwritePrompt:K});clearInterval(be),Te(F)}catch{clearInterval(be),Te("deny")}}),Ki(null),a==="write_file"||a==="update_file"){let{path:Te}=O(y.args);if(Te){let be=te.resolve(process.cwd(),Te);if(lr(be,B),B==="deny"&&uo&&ve.existsSync(be))try{ve.unlinkSync(be)}catch{}}}B==="deny"&&(ge="user")}if(B==="allow"&&We&&io()){let{path:ae}=O(y.args),Me=te.resolve(process.cwd(),ae),Te=Ue=>Ue?te.resolve(Ue).replace(/\\/g,"/").toLowerCase():"",be=await Gn(),F="";if(be&&be.file_focused&&Te(be.file_focused)===Te(Me)&&be.full_content&&(F=be.full_content),!F&&ve.existsSync(Me)){let Ue=ve.readFileSync(Me,"utf8");Ue&&(F=Ue)}!F&&Bt&&(F=Bt),(F||uo)&&ve.writeFileSync(Me,F,"utf8");let Jt=F.split(/\r?\n/),Fn=Jt.length,sn=Buffer.byteLength(F,"utf8"),Je="";L&&(Je=`Old File contents:
687
+ ${L.split(/\r?\n/).map((Oe,Wt)=>`${Wt+1} | ${Oe}`).join(`
669
688
  `)}
670
689
 
671
- `);let Qe="";if(Nn<=100)Qe=Xt.join(`
672
- `);else{let Ue=Xt.slice(0,50).join(`
673
- `),Le=Xt.slice(-50).join(`
690
+ `);let Qe="";if(Fn<=100)Qe=Jt.join(`
691
+ `);else{let Ue=Jt.slice(0,50).join(`
692
+ `),Oe=Jt.slice(-50).join(`
674
693
  `);Qe=`${Ue}
675
694
 
676
- ... [${Nn-100} lines truncated for history stability] ...
695
+ ... [${Fn-100} lines truncated for history stability] ...
677
696
 
678
- ${Le}`}let Ze="";if(a==="update_file"){let Ue=Ls($,F,ht,12,t?.compressToolResults||Mo?.systemSettings?.compressToolResults),{patchPairs:Le}=$i(L(y.args)),Bt=Le?.length||yt||1,sn=0,Qt=0,Fn=[];Le&&Le.length>0?Le.forEach((An,Ci)=>{let Go=An.replace||"",Zt=An.new||"",vi=Go.trim(),go=Zt.trim(),Ra=!!Ft&&F===Ft,Ea=go?F.includes(Zt)||F.includes(go):!0,_a=Zt?$.includes(Zt)||!!go&&$.includes(go):!1,Ia=vi?F.includes(Go)||F.includes(vi):!1;Ra||!!Zt&&Ea&&(!_a||!Ia||vi===go)?sn++:(Qt++,Fn.push(` \u2022 Block ${Ci+1}: not applied (reverted or rejected in IDE).`))}):sn=yt||0;let eo=0;if(Ft&&F!==Ft){let An=Qa("","",Ft||"",F||"","","",{context:0});if(An&&An.hunks)for(let Ci of An.hunks){let Go=Ci.lines.filter(Zt=>Zt.startsWith("+")).map(Zt=>Zt.slice(1).trim()).filter(Boolean);for(let Zt of Go)$.includes(Zt)||eo++}}let kn=[`[${sn}/${Bt}] applied`];Qt>0&&kn.push(`${Qt} rejected by user`),eo>0&&kn.push(`${eo} manual ${eo===1?"modification":"modifications"} by user`);let Tn=kn.join(", "),Bn=Fn.length>0?`
697
+ ${Oe}`}let Ze="";if(a==="update_file"){let Ue=Fs(L,F,ht,12,t?.compressToolResults||Po?.systemSettings?.compressToolResults),{patchPairs:Oe}=Fi(O(y.args)),Wt=Oe?.length||yt||1,rn=0,Zt=0,Bn=[];Oe&&Oe.length>0?Oe.forEach((Cn,_i)=>{let Vo=Cn.replace||"",en=Cn.new||"",Ii=Vo.trim(),mo=en.trim(),Ma=!!Bt&&F===Bt,Pa=mo?F.includes(en)||F.includes(mo):!0,$a=en?L.includes(en)||!!mo&&L.includes(mo):!1,La=Ii?F.includes(Vo)||F.includes(Ii):!1;Ma||!!en&&Pa&&(!$a||!La||Ii===mo)?rn++:(Zt++,Bn.push(` \u2022 Block ${_i+1}: not applied (reverted or rejected in IDE).`))}):rn=yt||0;let to=0;if(Bt&&F!==Bt){let Cn=nl("","",Bt||"",F||"","","",{context:0});if(Cn&&Cn.hunks)for(let _i of Cn.hunks){let Vo=_i.lines.filter(en=>en.startsWith("+")).map(en=>en.slice(1).trim()).filter(Boolean);for(let en of Vo)L.includes(en)||to++}}let Tn=[`[${rn}/${Wt}] applied`];Zt>0&&Tn.push(`${Zt} rejected by user`),to>0&&Tn.push(`${to} manual ${to===1?"modification":"modifications"} by user`);let An=Tn.join(", "),Wn=Bn.length>0?`
679
698
 
680
699
  User Review Details:
681
- ${Fn.join(`
682
- `)}`:"";Ze=`File [${ae}] updated via IDE Companion. ${Tn}.${Bn}
700
+ ${Bn.join(`
701
+ `)}`:"";Ze=`File [${ae}] updated via IDE Companion. ${An}.${Wn}
683
702
 
684
- ${Ue}`;let{added:Uo,removed:uo}=$s($,F);(Uo>0||uo>0)&&await Mi({added:Uo,removed:uo,file:ae})}else{let Ue=F.split(/\r?\n/),Le=Ue.length,Bt=Buffer.byteLength(F,"utf8"),sn="",Qt=c?.overwriteProtection!==!1;if($){let kn=$.split(/\r?\n/);if(!Qt)sn="";else if(kn.length<=50)sn=`Old File contents:
685
- ${kn.map((Tn,Bn)=>`${Bn+1} | ${Tn}`).join(`
703
+ ${Ue}`;let{added:Ko,removed:go}=Ns(L,F);(Ko>0||go>0)&&await Oi({added:Ko,removed:go,file:ae})}else{let Ue=F.split(/\r?\n/),Oe=Ue.length,Wt=Buffer.byteLength(F,"utf8"),rn="",Zt=c?.overwriteProtection!==!1;if(L){let Tn=L.split(/\r?\n/);if(!Zt)rn="";else if(Tn.length<=50)rn=`Old File contents:
704
+ ${Tn.map((An,Wn)=>`${Wn+1} | ${An}`).join(`
686
705
  `)}
687
706
 
688
- `;else{let Tn=te.parse(Me),Bn=te.join(Es,"OverwriteBackups");if(!ve.existsSync(Bn))try{ve.mkdirSync(Bn,{recursive:!0})}catch{}let Uo=`${Tn.name}-old-${Date.now()}${Tn.ext}.bak`,uo=te.join(Bn,Uo);try{ve.writeFileSync(uo,$,"utf8")}catch{}sn=`Old File contents:
689
- - Renamed old file as ${uo} and written requested content in ${ae}. For reversal use Run
707
+ `;else{let An=te.parse(Me),Wn=te.join(Ms,"OverwriteBackups");if(!ve.existsSync(Wn))try{ve.mkdirSync(Wn,{recursive:!0})}catch{}let Ko=`${An.name}-old-${Date.now()}${An.ext}.bak`,go=te.join(Wn,Ko);try{ve.writeFileSync(go,L,"utf8")}catch{}rn=`Old File contents:
708
+ - Renamed old file as ${go} and written requested content in ${ae}. For reversal use Run
690
709
 
691
- `}}let Fn="";if(Le<=690)Fn=Ue.join(`
692
- `);else{let kn=Ue.slice(0,300).join(`
693
- `),Tn=Ue.slice(-300).join(`
694
- `);Fn=`${kn}
710
+ `}}let Bn="";if(Oe<=690)Bn=Ue.join(`
711
+ `);else{let Tn=Ue.slice(0,300).join(`
712
+ `),An=Ue.slice(-300).join(`
713
+ `);Bn=`${Tn}
695
714
 
696
- ... [${Le-100} lines truncated] ...
715
+ ... [${Oe-100} lines truncated] ...
697
716
 
698
- ${Tn}`}Ze=`File [${ae}] saved via IDE Companion (May have user edits).
699
- - Stats: [${Le} lines, ${(Bt/1024).toFixed(1)} KB]
700
- ${sn}- Content Preview:
717
+ ${An}`}Ze=`File [${ae}] saved via IDE Companion (May have user edits).
718
+ - Stats: [${Oe} lines, ${(Wt/1024).toFixed(1)} KB]
719
+ ${rn}- Content Preview:
701
720
 
702
- ${Fn}`;let eo=$?$.split(/\r?\n/).length:0;await Mi({added:Le,removed:eo,file:ae})}let le=a==="write_file"?"Created":"Edited",Ce=L(y.args),Pt=Object.entries(Ce).some(([Ue,Le])=>Ue.startsWith("searchContent")&&typeof Le=="string"&&Le.startsWith("^LINE:"))?"\u1361":":",pn=`${ae?"\u2714":"\u2718"} ${le}${Pt} ${ae?ae.replaceAll("\\","/"):"No File Changes"}`,hn=115;process.stdout.isTTY&&(hn=process.stdout.columns-5||120);let yn=Math.min(pn.length+4,hn),Zn=`${pn.padEnd(yn-2).substring(0,yn-2)}`;yield{type:"visual_feedback",content:Rt(`${He?`
703
- `:""}${Zn}`)},He=!1;let xt=Date.now();On=xt,yield{type:"tool_time",content:xt-k};let Jt=(Ze||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");Jt.includes("[[VERIFIED]]")&&(Jt=Jt.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to conserve context.
704
- `));let xn;if(a==="write_file"&&!Jt.startsWith("ERROR:")){let Ue=Jt.replace(/^\[\[SAME\]\]\s*\r?\n?/,"");if(/- Stats:.*\r?\nOld File contents:/s.test(Ue)){let Le=Ue.search(/^- Content Preview:/m);xn=`[ACTION RESULT]: ${Le!==-1?Ue.slice(0,Le).trimEnd():Ue}
721
+ ${Bn}`;let to=L?L.split(/\r?\n/).length:0;await Oi({added:Oe,removed:to,file:ae})}let le=a==="write_file"?"Created":"Edited",Ce=O(y.args),$t=Object.entries(Ce).some(([Ue,Oe])=>Ue.startsWith("searchContent")&&typeof Oe=="string"&&Oe.startsWith("^LINE:"))?"\u1361":":",hn=`${ae?"\u2714":"\u2718"} ${le}${$t} ${ae?ae.replaceAll("\\","/"):"No File Changes"}`,yn=115;process.stdout.isTTY&&(yn=process.stdout.columns-5||120);let xn=Math.min(hn.length+4,yn),eo=`${hn.padEnd(xn-2).substring(0,xn-2)}`;yield{type:"visual_feedback",content:Rt(`${He?`
722
+ `:""}${eo}`)},He=!1;let xt=Date.now();Ln=xt,yield{type:"tool_time",content:xt-k};let Qt=(Ze||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");Qt.includes("[[VERIFIED]]")&&(Qt=Qt.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to conserve context.
723
+ `));let wn;if(a==="write_file"&&!Qt.startsWith("ERROR:")){let Ue=Qt.replace(/^\[\[SAME\]\]\s*\r?\n?/,"");if(/- Stats:.*\r?\nOld File contents:/s.test(Ue)){let Oe=Ue.search(/^- Content Preview:/m);wn=`[ACTION RESULT]: ${Oe!==-1?Ue.slice(0,Oe).trimEnd():Ue}
705
724
 
706
- [Old file content for reversal reference. Replaced with new write request]`}else{let Le=Ue.split(/\r?\n/),Bt=Le.filter(Qt=>Qt.startsWith("File ")||Qt.trim().startsWith("- Stats:"));xn=`[ACTION RESULT]: ${Bt.length>0?Bt.join(`
707
- `):Le.slice(0,2).join(`
708
- `)}`}}else if(Jt.startsWith("[[SAME]]")){let Le=Jt.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),Bt=Le.filter(Qt=>Qt.startsWith("File ")||Qt.trim().startsWith("- Stats:"));xn=`[ACTION RESULT]: ${Bt.length>0?Bt.join(`
709
- `):Le.slice(0,2).join(`
710
- `)}`}else xn=`[ACTION RESULT]: ${Jt}`;Ge.push({role:"user",text:xn}),fn=!0,await St("toolSuccess"),t.onToolResult&&t.onToolResult("success",a),yield{type:"tool_result",content:Ze,aiContent:xn,toolName:a},bt++;continue}if(B==="deny"){let ae=`Permission Denied: Prohibited ${a==="exec_command"?"Command":"file edit"}.`;if(D?ae=`User denied reading ${te.basename(fe||".env")}`:K&&ge==="user"?ae="User rejected file over-write. If needed AskUser how to proceed":ge==="user"?ae="Permission Denied by User":ge==="settings"?ae="Permission Denied by User Policy":ge==="network"?ae="Permission Denied: Sandbox Network Access Disabled by User Policy.":ge==="prohibited"&&a==="exec_command"&&(ae="Permission Denied: Prohibited Command in User Policy"),a==="view_file"){let Me=`\u2718 Read Denied: ${L(y.args).path?.replaceAll("\\","/")||".env"}`,Te=115;process.stdout.isTTY&&(Te=process.stdout.columns-5||120);let be=Math.min(Me.length+4,Te),F=`${Me.padEnd(be-2).substring(0,be-2)}`;yield{type:"visual_feedback",content:Rt(`${He?`
725
+ [Old file content for reversal reference. Replaced with new write request]`}else{let Oe=Ue.split(/\r?\n/),Wt=Oe.filter(Zt=>Zt.startsWith("File ")||Zt.trim().startsWith("- Stats:"));wn=`[ACTION RESULT]: ${Wt.length>0?Wt.join(`
726
+ `):Oe.slice(0,2).join(`
727
+ `)}`}}else if(Qt.startsWith("[[SAME]]")){let Oe=Qt.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),Wt=Oe.filter(Zt=>Zt.startsWith("File ")||Zt.trim().startsWith("- Stats:"));wn=`[ACTION RESULT]: ${Wt.length>0?Wt.join(`
728
+ `):Oe.slice(0,2).join(`
729
+ `)}`}else wn=`[ACTION RESULT]: ${Qt}`;Ge.push({role:"user",text:wn}),un=!0,await St("toolSuccess"),t.onToolResult&&t.onToolResult("success",a),yield{type:"tool_result",content:Ze,aiContent:wn,toolName:a},bt++;continue}if(B==="deny"){let ae=`Permission Denied: Prohibited ${a==="exec_command"?"Command":"file edit"}.`;if(D?ae=`User denied reading ${te.basename(fe||".env")}`:K&&ge==="user"?ae="User rejected file over-write. If needed AskUser how to proceed":ge==="user"?ae="Permission Denied by User":ge==="settings"?ae="Permission Denied by User Policy":ge==="network"?ae="Permission Denied: Sandbox Network Access Disabled by User Policy.":ge==="prohibited"&&a==="exec_command"&&(ae="Permission Denied: Prohibited Command in User Policy"),a==="view_file"){let Me=`\u2718 Read Denied: ${O(y.args).path?.replaceAll("\\","/")||".env"}`,Te=115;process.stdout.isTTY&&(Te=process.stdout.columns-5||120);let be=Math.min(Me.length+4,Te),F=`${Me.padEnd(be-2).substring(0,be-2)}`;yield{type:"visual_feedback",content:Rt(`${He?`
711
730
  `:""}${F}
712
- `)},He=!1}else if(a==="write_file"||a==="update_file"){let Te=`\u2718 ${a==="write_file"?"Write Cancelled":"Edit Denied"}: ${L(y.args).path.replaceAll("\\","/")||"..."}`,be=115;process.stdout.isTTY&&(be=process.stdout.columns-5||120);let F=Math.min(Te.length+4,be),Xt=`${Te.padEnd(F-2).substring(0,F-2)}`,Nn=` ${" ".repeat(F)} `;yield{type:"visual_feedback",content:Rt(`${He?`
713
- `:""}${Xt}
731
+ `)},He=!1}else if(a==="write_file"||a==="update_file"){let Te=`\u2718 ${a==="write_file"?"Write Cancelled":"Edit Denied"}: ${O(y.args).path.replaceAll("\\","/")||"..."}`,be=115;process.stdout.isTTY&&(be=process.stdout.columns-5||120);let F=Math.min(Te.length+4,be),Jt=`${Te.padEnd(F-2).substring(0,F-2)}`,Fn=` ${" ".repeat(F)} `;yield{type:"visual_feedback",content:Rt(`${He?`
732
+ `:""}${Jt}
714
733
  `)},He=!1}a==="exec_command"&&(await new Promise(Me=>setTimeout(Me,50)),t.onExecChunk&&t.onExecChunk(`ERROR: ${ae}`),await new Promise(Me=>setTimeout(Me,50)),t.onExecEnd&&t.onExecEnd()),Ge.push({role:"user",text:`[ACTION RESULT]: DENIED: ${ae}`}),yield{type:"tool_result",content:`[ACTION RESULT]: DENIED: ${ae}`},await St("toolDenied"),t.onToolResult&&t.onToolResult("denied",a),bt++;continue}}}if(R){let c=115;process.stdout.isTTY&&(c=process.stdout.columns-5||120);let T=!1,D=Math.min(R.length+4,c),fe=`${R.padEnd(D-2).substring(0,D-2)}`;yield{type:"visual_feedback",content:Rt(`${He?`
715
734
  `:""}${fe}${R.includes("\u2714")&&(R.includes("Created")||R.includes("Edited"))?"":`${T?"":`
716
- `}`}`)},He=!1}if(On>0){let c=Date.now()-On,T=Math.max(0,1e3-c);T>0&&await new Promise(D=>setTimeout(D,T))}let At={chatId:g,history:n,onChunk:c=>t.onExecChunk?t.onExecChunk(c):null,onAskUser:t.onAskUser,systemSettings:t.systemSettings,mode:l,isMultiModal:et(J),onVisualFeedback:t.onVisualFeedback,onSubagentUpdate:t.onSubagentUpdate,onTokenChunk:t.onTokenChunk,modelName:J,aiProvider:t.aiProvider,apiKey:t.apiKey,onUsage:t.onUsage};if(a==="write_file"||a==="update_file")try{let{path:c}=L(y.args);if(c){let T=te.resolve(process.cwd(),c),D=await Un();D&&D.file_focused===T&&D.full_content&&(At.forcedContent=D.full_content)}}catch{}pe.push(a);let Z=await ns(a,y.args,At);if((a==="write_file"||a==="update_file")&&!Z.startsWith("ERROR:")){let{path:c}=L(y.args);if(c){let T=te.resolve(process.cwd(),c);ir(T)}}process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07");let je=Date.now();On=je,yield{type:"tool_time",content:je-k},Pn=je;let lt=null;if(typeof Z=="object"&&Z.binaryPart&&(lt=Z.binaryPart,Z=Z.text),a==="search_keyword"){let{keyword:c,path:T}=L(y.args),D=typeof Z=="string"&&Z.startsWith("[GLOB]");D&&(Z=Z.slice(6).trimStart());let fe=typeof Z=="string"&&Z.startsWith("[DIR]");fe&&(Z=Z.slice(5).trimStart());let ie=0;if(Z){let $=Z.match(/Found (\d+) match/i);$&&(ie=parseInt($[1]))}let ee=(T||"").trim().toLowerCase().replaceAll("\\","/"),ue=ee==="#doc"||ee==="#docs"||ee==="#documentation"||ee.includes("#skill/global/fluxflow")||ee.includes("#skill/fluxflow")||ee.includes("#skills/fluxflow")||ee.includes("#skills/global/fluxflow"),Ae,Y=115;process.stdout.isTTY&&(Y=process.stdout.columns-5||120);let K=Math.max(10,(Y+5)/3),B=Math.max(10,(Y+5)/4);if(ue)Ae=`${c?"\u2714":"\u2718"} Searched Documentation`;else{let $=T?T.replace(/[\/\\]+$/,""):null,ht=$&&$!=="."?`${D?T:fe?`${$}/*`:$}`:"./",yt=ht.length>B?`${ht.slice(0,B)}...`:ht;Ae=`${c?"\u2714":"\u2718"} Searched: "${c?c.length>Y/3?`${c.slice(0,K)}...`:c:""}" in "${yt.replaceAll("\\","/")}" \u2192 ${ie} Match${ie===1?"":"es"}`}let ge=Math.min(Ae.length+4,Y),We=`${Ae.padEnd(ge-2).substring(0,ge-2)}`;yield{type:"visual_feedback",content:Rt(`${He?`
735
+ `}`}`)},He=!1}if(Ln>0){let c=Date.now()-Ln,T=Math.max(0,1e3-c);T>0&&await new Promise(D=>setTimeout(D,T))}let At={chatId:g,history:n,onChunk:c=>t.onExecChunk?t.onExecChunk(c):null,onAskUser:t.onAskUser,systemSettings:t.systemSettings,mode:l,isMultiModal:et(J),onVisualFeedback:t.onVisualFeedback,onSubagentUpdate:t.onSubagentUpdate,onTokenChunk:t.onTokenChunk,modelName:J,aiProvider:t.aiProvider,apiKey:t.apiKey,onUsage:t.onUsage};if(a==="write_file"||a==="update_file")try{let{path:c}=O(y.args);if(c){let T=te.resolve(process.cwd(),c),D=await Gn();D&&D.file_focused===T&&D.full_content&&(At.forcedContent=D.full_content)}}catch{}pe.push(a);let Z=await rs(a,y.args,At);if((a==="write_file"||a==="update_file")&&!Z.startsWith("ERROR:")){let{path:c}=O(y.args);if(c){let T=te.resolve(process.cwd(),c);ar(T)}}process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07");let je=Date.now();Ln=je,yield{type:"tool_time",content:je-k},$n=je;let lt=null;if(typeof Z=="object"&&Z.binaryPart&&(lt=Z.binaryPart,Z=Z.text),a==="search_keyword"){let{keyword:c,path:T}=O(y.args),D=typeof Z=="string"&&Z.startsWith("[GLOB]");D&&(Z=Z.slice(6).trimStart());let fe=typeof Z=="string"&&Z.startsWith("[DIR]");fe&&(Z=Z.slice(5).trimStart());let ie=0;if(Z){let L=Z.match(/Found (\d+) match/i);L&&(ie=parseInt(L[1]))}let ee=(T||"").trim().toLowerCase().replaceAll("\\","/"),ue=ee==="#doc"||ee==="#docs"||ee==="#documentation"||ee.includes("#skill/global/fluxflow")||ee.includes("#skill/fluxflow")||ee.includes("#skills/fluxflow")||ee.includes("#skills/global/fluxflow"),Ae,Y=115;process.stdout.isTTY&&(Y=process.stdout.columns-5||120);let K=Math.max(10,(Y+5)/3),B=Math.max(10,(Y+5)/4);if(ue)Ae=`${c?"\u2714":"\u2718"} Searched Documentation`;else{let L=T?T.replace(/[\/\\]+$/,""):null,ht=L&&L!=="."?`${D?T:fe?`${L}/*`:L}`:"./",yt=ht.length>B?`${ht.slice(0,B)}...`:ht;Ae=`${c?"\u2714":"\u2718"} Searched: "${c?c.length>Y/3?`${c.slice(0,K)}...`:c:""}" in "${yt.replaceAll("\\","/")}" \u2192 ${ie} Match${ie===1?"":"es"}`}let ge=Math.min(Ae.length+4,Y),We=`${Ae.padEnd(ge-2).substring(0,ge-2)}`;yield{type:"visual_feedback",content:Rt(`${He?`
717
736
  `:""}${We}
718
- `)},He=!1}if(a==="EmergencyRollback"){let{method:c}=L(y.args);if(c==="forceRevert"){let T=0;if(Z){let Y=Z.match(/Total\s*:\s*(\d+)/i);Y&&(T=parseInt(Y[1]))}let fe=Z&&Z.startsWith("ERROR:")?"\u2718 Emergency Rollback Failed":`\u2714 Emergency Rollback \u2192 ${T} file${T===1?"":"s"} processed`,ie=115;process.stdout.isTTY&&(ie=process.stdout.columns-5||120);let ee=!1,ue=Math.min(fe.length+4,ie),Ae=`${fe.padEnd(ue-2).substring(0,ue-2)}`;yield{type:"visual_feedback",content:Rt(`${He?`
737
+ `)},He=!1}if(a==="EmergencyRollback"){let{method:c}=O(y.args);if(c==="forceRevert"){let T=0;if(Z){let Y=Z.match(/Total\s*:\s*(\d+)/i);Y&&(T=parseInt(Y[1]))}let fe=Z&&Z.startsWith("ERROR:")?"\u2718 Emergency Rollback Failed":`\u2714 Emergency Rollback \u2192 ${T} file${T===1?"":"s"} processed`,ie=115;process.stdout.isTTY&&(ie=process.stdout.columns-5||120);let ee=!1,ue=Math.min(fe.length+4,ie),Ae=`${fe.padEnd(ue-2).substring(0,ue-2)}`;yield{type:"visual_feedback",content:Rt(`${He?`
719
738
  `:""}${Ae}${ee?"":`
720
- `}`)},He=!1}}if(a==="todo"){let{method:c,tasks:T,markDone:D}=L(y.args),fe="",ie=[],ee=ue=>{if(!ue)return[];let Ae=Array.isArray(ue)?ue:[];if(Ae.length===0&&typeof ue=="string"){let Y=ue.trim();if(Y.startsWith("[")&&Y.endsWith("]")){let K=Y.match(/"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'/g);K?Ae=K.map(B=>B.slice(1,-1).replace(/\\(.)/g,"$1")):Ae=Y.slice(1,-1).split(",").map(B=>B.trim()).filter(Boolean)}else Ae=ue.split(`
739
+ `}`)},He=!1}}if(a==="todo"){let{method:c,tasks:T,markDone:D}=O(y.args),fe="",ie=[],ee=ue=>{if(!ue)return[];let Ae=Array.isArray(ue)?ue:[];if(Ae.length===0&&typeof ue=="string"){let Y=ue.trim();if(Y.startsWith("[")&&Y.endsWith("]")){let K=Y.match(/"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'/g);K?Ae=K.map(B=>B.slice(1,-1).replace(/\\(.)/g,"$1")):Ae=Y.slice(1,-1).split(",").map(B=>B.trim()).filter(Boolean)}else Ae=ue.split(`
721
740
  `)}return Ae.filter(Y=>String(Y).trim()).map(Y=>{let K=String(Y).trim();return K.startsWith("- [")?K.substring(6).trim():K})};if(c==="create"?(fe="\x1B[32m\u2192\x1B[0m Created Goals",ie=ee(T).map(ue=>`\x1B[90m\u25CB\x1B[0m ${ue}`)):c==="append"?(fe="\x1B[34m\u2795\x1B[0m Added New Goals",ie=ee(T).map(ue=>`\x1B[90m\u25CB\x1B[0m ${ue}`)):c==="get"&&(fe=D?"\x1B[36m\u21BB\x1B[0m Updated Goals":"\x1B[35m\u2022\x1B[0m Reviewed Goals",ie=(Z||"").split(`
722
741
  `).slice(1).join(`
723
742
  `).split(`
@@ -725,31 +744,31 @@ ${Fn}`;let eo=$?$.split(/\r?\n/).length:0;await Mi({added:Le,removed:eo,file:ae}
725
744
  `);yield{type:"visual_feedback",content:Rt(`${He?`
726
745
  `:""}${ue}${!1?"":`
727
746
  `}`)},He=!1}}a==="exec_command"&&t.onExecEnd&&(await new Promise(c=>setTimeout(c,800)),t.onExecEnd());let Ct=Z&&Z.startsWith("DENIED:");Z&&!Z.startsWith("ERROR:")&&!Ct?(await St("toolSuccess"),t.onToolResult&&t.onToolResult("success",a)):Ct||(await St("toolFailure"),t.onToolResult&&t.onToolResult("failure",a));let pt=(Z||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");pt.includes("[[VERIFIED]]")&&(pt=pt.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to save tokens.
728
- `));let Yt;if(a==="write_file"&&!pt.startsWith("ERROR:")){let c=pt.replace(/^\[\[SAME\]\]\s*\r?\n?/,"");if(/- Stats:.*\r?\nOld File contents:/s.test(c)){let T=c.search(/^- Content Preview:/m);Yt=`[ACTION RESULT]: ${T!==-1?c.slice(0,T).trimEnd():c}
747
+ `));let Xt;if(a==="write_file"&&!pt.startsWith("ERROR:")){let c=pt.replace(/^\[\[SAME\]\]\s*\r?\n?/,"");if(/- Stats:.*\r?\nOld File contents:/s.test(c)){let T=c.search(/^- Content Preview:/m);Xt=`[ACTION RESULT]: ${T!==-1?c.slice(0,T).trimEnd():c}
729
748
 
730
- [Old file content for reversal reference. Replaced with new write request]`}else{let T=c.split(/\r?\n/),D=T.filter(ie=>ie.startsWith("File ")||ie.trim().startsWith("- Stats:"));Yt=`[ACTION RESULT]: ${D.length>0?D.join(`
749
+ [Old file content for reversal reference. Replaced with new write request]`}else{let T=c.split(/\r?\n/),D=T.filter(ie=>ie.startsWith("File ")||ie.trim().startsWith("- Stats:"));Xt=`[ACTION RESULT]: ${D.length>0?D.join(`
731
750
  `):T.slice(0,2).join(`
732
- `)}`}}else if(pt.startsWith("[[SAME]]")){let T=pt.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),D=T.filter(ie=>ie.startsWith("File ")||ie.trim().startsWith("- Stats:"));Yt=`[ACTION RESULT]: ${D.length>0?D.join(`
751
+ `)}`}}else if(pt.startsWith("[[SAME]]")){let T=pt.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),D=T.filter(ie=>ie.startsWith("File ")||ie.trim().startsWith("- Stats:"));Xt=`[ACTION RESULT]: ${D.length>0?D.join(`
733
752
  `):T.slice(0,2).join(`
734
- `)}`}else Yt=`[ACTION RESULT]: ${pt}`;Ge.push({role:"user",text:Yt,binaryPart:lt}),fn=!0;let de=`[ACTION RESULT]: ${Z.replaceAll(`[[VERIFIED]]
753
+ `)}`}else Xt=`[ACTION RESULT]: ${pt}`;Ge.push({role:"user",text:Xt,binaryPart:lt}),un=!0;let de=`[ACTION RESULT]: ${Z.replaceAll(`[[VERIFIED]]
735
754
  `,"").replaceAll(`
736
- [[/VERIFIED]]`,"")||""}`;(a==="view_file"||a==="web_scrape"||a==="file_map"||a==="search_keyword"||a==="get_progress"||a==="getprogress")&&(de=`[ACTION RESULT]: ${R} (Context Locked for UI Clarity)`),yield{type:"tool_result",content:de,aiContent:Yt,binaryPart:lt,toolName:a},a==="memory"&&!Z.startsWith("ERROR:")&&(yield{type:"memory_updated"}),bt++}if(s==="Google"&&it&&Date.now()-Bo>=150){yield*nn();let y=ao(it);for(let k of y)yield k;it="",Bo=Date.now()}}f.usageMetadata&&(Vt=f.usageMetadata),Vt&&(yield{type:"liveTokens",content:Vt.totalTokenCount})}if(U&&(U=!1,tt?ke+="</think_fluxflow>":(we+="</think_fluxflow>",s==="Google"?it+="</think_fluxflow>":yield{type:"text",content:"</think_fluxflow>"})),tt&&ke.length>0){let f=0,b=Math.min(dt.length,ke.length);for(let H=b;H>0;H--)if(dt.endsWith(ke.substring(0,H))){f=H;break}let S=ke.substring(f);if(S){let oe=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(dt)?S.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):S.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(we+=oe,s==="Google")it+=oe;else{yield*nn();let I=ao(oe);for(let j of I)yield j}}tt=!1,ke=""}if(un){let f=un,b=(st==="tool"||st==="action")&&(f.startsWith("[tool:")||f.startsWith("[action:"));un="",Jn=!1,st=null,Dn=!1,Qn=!1,b||(s==="Google"?it+=f:yield{type:"text",content:f})}if(yield*nn(),ct)break;let lo=(we||"").trim(),Sa=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(lo.toLowerCase())||/\[\[END\]\]/i.test(lo.toLowerCase()),ka=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(lo.toLowerCase()),Ta=Ge.length>0||It!==null,Ti=$t(lo).trim(),Aa=/(\p{Emoji_Presentation}|\p{Extended_Pictographic})$/u.test(Ti),Ca=/([.!?"'*_`|\]\)”’~~]+|\s|`{3}|[\u200B-\u200D\uFEFF])$/u.test(Ti.trim()),va=/[.!?}"'`’“”]$|```$/s.test(Ti)||Ca||Aa;!Sa&&!ka&&!Ta&&lo.length>0,Oe=!0,await St("agent",s)}catch(z){if(ct){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
755
+ [[/VERIFIED]]`,"")||""}`;(a==="view_file"||a==="web_scrape"||a==="file_map"||a==="search_keyword"||a==="get_progress"||a==="getprogress")&&(de=`[ACTION RESULT]: ${R} (Context Locked for UI Clarity)`),yield{type:"tool_result",content:de,aiContent:Xt,binaryPart:lt,toolName:a},a==="memory"&&!Z.startsWith("ERROR:")&&(yield{type:"memory_updated"}),bt++}if(s==="Google"&&it&&Date.now()-Ho>=150){yield*on();let y=lo(it);for(let k of y)yield k;it="",Ho=Date.now()}}f.usageMetadata&&(zt=f.usageMetadata),zt&&(yield{type:"liveTokens",content:zt.totalTokenCount})}if(U&&(U=!1,tt?ke+="</think_fluxflow>":(we+="</think_fluxflow>",s==="Google"?it+="</think_fluxflow>":yield{type:"text",content:"</think_fluxflow>"})),tt&&ke.length>0){let f=0,b=Math.min(dt.length,ke.length);for(let H=b;H>0;H--)if(dt.endsWith(ke.substring(0,H))){f=H;break}let S=ke.substring(f);if(S){let oe=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(dt)?S.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):S.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(we+=oe,s==="Google")it+=oe;else{yield*on();let I=lo(oe);for(let j of I)yield j}}tt=!1,ke=""}if(gn){let f=gn,b=(st==="tool"||st==="action")&&(f.startsWith("[tool:")||f.startsWith("[action:"));gn="",Qn=!1,st=null,Nn=!1,Zn=!1,b||(s==="Google"?it+=f:yield{type:"text",content:f})}if(yield*on(),ct)break;let co=(we||"").trim(),Ca=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(co.toLowerCase())||/\[\[END\]\]/i.test(co.toLowerCase()),va=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(co.toLowerCase()),Ra=Ge.length>0||Mt!==null,Ri=Ot(co).trim(),Ea=/(\p{Emoji_Presentation}|\p{Extended_Pictographic})$/u.test(Ri),_a=/([.!?"'*_`|\]\)”’~~]+|\s|`{3}|[\u200B-\u200D\uFEFF])$/u.test(Ri.trim()),Ia=/[.!?}"'`’“”]$|```$/s.test(Ri)||_a||Ea;!Ca&&!va&&!Ra&&co.length>0,$e=!0,await St("agent",s)}catch(z){if(ct){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
737
756
 
738
- \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(String(z).includes("Incomplete JSON segment at the end")){U&&(U=!1,tt?ke+="</think_fluxflow>":(we+="</think_fluxflow>",yield{type:"text",content:"</think_fluxflow>"})),Oe=!0,await St("agent",s);break}if(U&&(U=!1,tt?ke+="</think_fluxflow>":we+="</think_fluxflow>"),tt&&ke.length>0){let ft=0,Ye=Math.min(dt.length,ke.length);for(let Nt=Ye;Nt>0;Nt--)if(dt.endsWith(ke.substring(0,Nt))){ft=Nt;break}let ot=ke.substring(ft);if(ot){let Xe=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(dt)?ot.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):ot.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");Xe&&(we+=Xe)}tt=!1,ke=""}let E=z instanceof Error?(()=>{try{return JSON.parse(JSON.parse(z.message).error.message).error.message}catch{return String(z)}})():String(z),nt=new Date().toLocaleString(),ce=te.join(Wn,"agent");ve.existsSync(ce)||ve.mkdirSync(ce,{recursive:!0}),ve.appendFileSync(te.join(ce,"error.log"),`ERROR [${nt}]: ${E}
757
+ \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(String(z).includes("Incomplete JSON segment at the end")){U&&(U=!1,tt?ke+="</think_fluxflow>":(we+="</think_fluxflow>",yield{type:"text",content:"</think_fluxflow>"})),$e=!0,await St("agent",s);break}if(U&&(U=!1,tt?ke+="</think_fluxflow>":we+="</think_fluxflow>"),tt&&ke.length>0){let ft=0,Ye=Math.min(dt.length,ke.length);for(let Ft=Ye;Ft>0;Ft--)if(dt.endsWith(ke.substring(0,Ft))){ft=Ft;break}let ot=ke.substring(ft);if(ot){let Xe=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(dt)?ot.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):ot.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");Xe&&(we+=Xe)}tt=!1,ke=""}let E=z instanceof Error?(()=>{try{return JSON.parse(JSON.parse(z.message).error.message).error.message}catch{return String(z)}})():String(z),nt=new Date().toLocaleString(),ce=te.join(Un,"agent");ve.existsSync(ce)||ve.mkdirSync(ce,{recursive:!0}),ve.appendFileSync(te.join(ce,"error.log"),`ERROR [${nt}]: ${E}
739
758
 
740
759
  ----------------------------------------------------------------------
741
760
 
742
- `);let Be=z.status||z.statusCode||z.code,mt=String(z).includes("replicas at capacity");if(!(Be&&(Be>=500&&Be<600||Be===408||Be===429||mt)||!Be&&(/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<tn-3)throw z;yield{type:"text",content:E},yield{type:"status",content:"Error Occured"}}if(we.trim().length>0||qe>1)if(qe<=tn){qe++;let ft=Math.min(1e3*Math.pow(2,qe-1),24e3);if(we.trim().length>0){x.push({role:"agent",text:we});let Ye=`[system]
761
+ `);let Be=z.status||z.statusCode||z.code,mt=String(z).includes("replicas at capacity");if(!(Be&&(Be>=500&&Be<600||Be===408||Be===429||mt)||!Be&&(/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<nn-3)throw z;yield{type:"text",content:E},yield{type:"status",content:"Error Occured"}}if(we.trim().length>0||qe>1)if(qe<=nn){qe++;let ft=Math.min(1e3*Math.pow(2,qe-1),24e3);if(we.trim().length>0){x.push({role:"agent",text:we});let Ye=`[system]
743
762
  - seamless continuation: resume immediately. pick up from last words with zero gap/disruption
744
763
  - no repetition: do not repeat any text already written
745
764
  - 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
746
765
  - mid-tool safety: if cutoff was mid-tool call, restart that tool call from start
747
- - stealth: do not mention/apologize for cutoff [/system]`;Ge.length>0?Ge.forEach((ot,Nt)=>{Nt===Ge.length-1?x.push({...ot,text:`${ot.text}
766
+ - stealth: do not mention/apologize for cutoff [/system]`;Ge.length>0?Ge.forEach((ot,Ft)=>{Ft===Ge.length-1?x.push({...ot,text:`${ot.text}
748
767
 
749
- ${Ye}`}):x.push(ot)}):x.push({role:"user",text:Ye}),dt+=we}for(let Ye=ft/1e3;Ye>0&&!ct;Ye--)yield{type:"status",content:`Error Occured. Recovering Stream (${qe}/${tn}) [Retrying in ${Ye.toFixed(0)}s]...`},await new Promise(ot=>setTimeout(ot,1e3));yield{type:"status",content:"Error Occured. Recovering Stream..."}}else throw new Error(`Stream collapsed too many times. (Failed to resolve ${tn} times)
750
- Error log can be found in \`/export logs\``);else{let Ye=e.split("/").slice(e.endsWith("/free")?-2:-1).join("/");if(Ve<=tn){Ve++,qe=1,dt="";let ot=Math.min(1e3*Math.pow(2,Ve-1),32e3),Nt=.8+Math.random()*.4,Xe=Math.round(ot*Nt);bn=!0,yield{type:"status",content:`Trying to reach ${Ye} (${Ve}/${tn}) [Retrying in ${(Xe/1e3).toFixed(0)}s]`};for(let $e=Xe/1e3;$e>0&&!ct;$e--)yield{type:"status",content:`Trying to reach ${Ye} (${Ve}/${tn}) [Retrying in ${$e.toFixed(0)}s]`},await new Promise(it=>setTimeout(it,1e3));yield{type:"status",content:`Trying to reach ${Ye}`}}else throw new Error(`Model ${e} cannot be reached. (Failed ${tn} times)
751
- Error log can be found in \`/export logs\``)}}}if(Vt){let U=Vt.totalTokenCount||0,z=Vt.cachedContentTokenCount||0,E=(Vt.candidatesTokenCount||0)+(s==="Google"&&Vt.thoughtsTokenCount||0);await an("tokens",U,s,J),z>0&&await an("cachedTokens",z,s,J),E>0&&await an("candidateTokens",E,s,J),gt!==null&&gt>0&&await an("ttft",gt,s,J),qo({provider:s,model:J,prompt:Vt.promptTokenCount||0,cached:z,output:E,reasoning:Vt.thoughtsTokenCount||0,ttft:gt}),yield{type:"usage",content:Vt}}else gt!==null&&gt>0&&(await an("ttft",gt,s,J),qo({provider:s,model:J,prompt:0,cached:0,output:0,reasoning:0,ttft:gt}));we=sa(we),bi.push(we);let Sl=$t(we),ki=na(we),pa=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(ki.toLowerCase())||/\[\[END\]\]/i.test(ki.toLowerCase())||!0,kl=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(ki.toLowerCase()),Tl=bt>0;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"};let ha=yl(we,/(\[\s*(turn\s*:)?\s*(continue|finish)\s*\]|\[\[END\]\])/gi,"").trim(),ya=Ge.length>0||Rn($t(we)).length>0,Ln=(pa||Ge.length===0)&&!Tt&&!$n&&!Mt;if(Ln=Ge.length===0?Ln:!1,Ln=ya&&Dt||Fo?!1:Ln,we&&we.trim().endsWith('")]')&&Ge.length===0&&(Ln=!1),Ln){As=!0;let U=bi.join(`
752
- `),z=$t(U).trim();yield{type:"interactive_turn_finished",data:{agentText:Ie,fullAgentTextRaw:U,history:[...x],needTitle:Re}},x.length>0&&x[x.length-1].role==="agent"?x[x.length-1].text=z:x.push({role:"agent",text:z}),x.forEach(E=>{if(E.role==="user"&&E.text&&(E.text=E.text.replace(/\n\[COMPILE ERROR\][\s\S]*?\[\/ERROR\]/g,""),E.text=E.text.replaceAll(`
768
+ ${Ye}`}):x.push(ot)}):x.push({role:"user",text:Ye}),dt+=we}for(let Ye=ft/1e3;Ye>0&&!ct;Ye--)yield{type:"status",content:`Error Occured. Recovering Stream (${qe}/${nn}) [Retrying in ${Ye.toFixed(0)}s]...`},await new Promise(ot=>setTimeout(ot,1e3));yield{type:"status",content:"Error Occured. Recovering Stream..."}}else throw new Error(`Stream collapsed too many times. (Failed to resolve ${nn} times)
769
+ Error log can be found in \`/export logs\``);else{let Ye=e.split("/").slice(e.endsWith("/free")?-2:-1).join("/");if(Ve<=nn){Ve++,qe=1,dt="";let ot=Math.min(1e3*Math.pow(2,Ve-1),32e3),Ft=.8+Math.random()*.4,Xe=Math.round(ot*Ft);Sn=!0,yield{type:"status",content:`Trying to reach ${Ye} (${Ve}/${nn}) [Retrying in ${(Xe/1e3).toFixed(0)}s]`};for(let Le=Xe/1e3;Le>0&&!ct;Le--)yield{type:"status",content:`Trying to reach ${Ye} (${Ve}/${nn}) [Retrying in ${Le.toFixed(0)}s]`},await new Promise(it=>setTimeout(it,1e3));yield{type:"status",content:`Trying to reach ${Ye}`}}else throw new Error(`Model ${e} cannot be reached. (Failed ${nn} times)
770
+ Error log can be found in \`/export logs\``)}}}if(zt){let U=zt.totalTokenCount||0,z=zt.cachedContentTokenCount||0,E=(zt.candidatesTokenCount||0)+(s==="Google"&&zt.thoughtsTokenCount||0);await ln("tokens",U,s,J),z>0&&await ln("cachedTokens",z,s,J),E>0&&await ln("candidateTokens",E,s,J),gt!==null&&gt>0&&await ln("ttft",gt,s,J),Qo({provider:s,model:J,prompt:zt.promptTokenCount||0,cached:z,output:E,reasoning:zt.thoughtsTokenCount||0,ttft:gt}),yield{type:"usage",content:zt}}else gt!==null&&gt>0&&(await ln("ttft",gt,s,J),Qo({provider:s,model:J,prompt:0,cached:0,output:0,reasoning:0,ttft:gt}));we=la(we),Ai.push(we);let Cl=Ot(we),vi=sa(we),wa=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(vi.toLowerCase())||/\[\[END\]\]/i.test(vi.toLowerCase())||!0,vl=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(vi.toLowerCase()),Rl=bt>0;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"};let ba=Sl(we,/(\[\s*(turn\s*:)?\s*(continue|finish)\s*\]|\[\[END\]\])/gi,"").trim(),Sa=Ge.length>0||En(Ot(we)).length>0,Dn=(wa||Ge.length===0)&&!Tt&&!On&&!Pt;if(Dn=Ge.length===0?Dn:!1,Dn=Sa&&Nt||Go?!1:Dn,we&&we.trim().endsWith('")]')&&Ge.length===0&&(Dn=!1),Dn){Rs=!0;let U=Ai.join(`
771
+ `),z=Ot(U).trim();yield{type:"interactive_turn_finished",data:{agentText:Ie,fullAgentTextRaw:U,history:[...x],needTitle:Re}},x.length>0&&x[x.length-1].role==="agent"?x[x.length-1].text=z:x.push({role:"agent",text:z}),x.forEach(E=>{if(E.role==="user"&&E.text&&(E.text=E.text.replace(/\n\[COMPILE ERROR\][\s\S]*?\[\/ERROR\]/g,""),E.text=E.text.replaceAll(`
753
772
 
754
773
  [system] user question. resolve this specific query within '[ANSWER] ... [/ANSWER]' concisely, naturally [/system]
755
774
  `,"").replaceAll(`[system] user question. resolve this specific query within '[ANSWER] ... [/ANSWER]' concisely, naturally
@@ -757,33 +776,33 @@ Error log can be found in \`/export logs\``)}}}if(Vt){let U=Vt.totalTokenCount||
757
776
  `,"").replaceAll(`[system] **strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow>** [/system]
758
777
  `,"").replaceAll(/\n\[system\] WARNING, Turn Limit Impending: Step \d+\/\d+\. Wrap up quickly\/prompt user to continue & use \[\[END\]\] quickly\. \[\/system\]/g,""),E.text=E.text.replaceAll(/\n\[system\] File Changes:\n(?:\* .+ \(created|modified|deleted\)\n)*\[\/system\]/g,""),(s==="Mistral"||s==="Google"&&e?.toLowerCase().startsWith("gemma"))&&(E.text.startsWith("[ACTION RESULT]")||E.text.startsWith("[TOOL RESULT]")))){let ce=`
759
778
  [system] Action result received. Analyze output and proceed with your turn [/system]`,Be=`
760
- [system] Action result received. Analyze output and proceed with your turn. **strictly follow thinking policy. do not start a response without <think_fluxflow>...</think_fluxflow>** [/system]`;E.text=E.text.replaceAll(Be,"").replaceAll(ce,"").trim()}}),yield{type:"status",content:"[end]"}}if(Ln)break;let xa=ha.trim()||"*Working...*";if(x.push({role:"agent",text:xa}),Ge.length>0||fn){if(Ge.length>0){let U=Ge.map(Xe=>Xe.text).join(`
779
+ [system] Action result received. Analyze output and proceed with your turn. **strictly follow thinking policy. do not start a response without <think_fluxflow>...</think_fluxflow>** [/system]`;E.text=E.text.replaceAll(Be,"").replaceAll(ce,"").trim()}}),yield{type:"status",content:"[end]"}}if(Dn)break;let ka=ba.trim()||"*Working...*";if(x.push({role:"agent",text:ka}),Ge.length>0||un){if(Ge.length>0){let U=Ge.map(Xe=>Xe.text).join(`
761
780
 
762
- `),z=$t(we),E=Rn(z),nt=ta(z,E),ce=gi(nt),Be=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,mt=[],me=[],ft;for(;(ft=Be.exec(ce))!==null;)me.push({index:ft.index,toolName:ft[1]});for(let Xe=0;Xe<me.length;Xe++){let $e=me[Xe],it=Xe+1<me.length?me[Xe+1].index:z.length;E.some(nn=>nn.fullMatch&&z.startsWith(nn.fullMatch,$e.index))||mt.push(z.substring($e.index,it))}let Ye=mt.length,ot=Ge.length+Ye;if(Ye>0){let Xe=mt.join(`
763
- `),$e=oa(Xe);U+=`
781
+ `),z=Ot(we),E=En(z),nt=ia(z,E),ce=yi(nt),Be=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,mt=[],me=[],ft;for(;(ft=Be.exec(ce))!==null;)me.push({index:ft.index,toolName:ft[1]});for(let Xe=0;Xe<me.length;Xe++){let Le=me[Xe],it=Xe+1<me.length?me[Xe+1].index:z.length;E.some(on=>on.fullMatch&&z.startsWith(on.fullMatch,Le.index))||mt.push(z.substring(Le.index,it))}let Ye=mt.length,ot=Ge.length+Ye;if(Ye>0){let Xe=mt.join(`
782
+ `),Le=ra(Xe);U+=`
764
783
 
765
784
  [system] Only ${Ge.length} out of ${ot} attempted tool calls were executed.
766
- ${$e?`Parsing Issues Detected:
767
- ${$e}
768
- `:""}Verify proper structure compliance [action:ActionName(arg="value")] & try failed calls again [/system]`;for(let it=0;it<Ye;it++)await St("toolFailure")}let Nt=Ge.find(Xe=>Xe.binaryPart)?.binaryPart||null;x.push({role:"user",text:U,binaryPart:Nt})}}else if(!ct){let U=we.replace(/(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\]|$)/i,""),z=Rn(U),E=ta(U,z),ce=(gi(E).match(/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi)||[]).length;if(Fo||Dt&&ce>0||ce>0){let Be=oa(U),mt=Be?`[system] Failed to execute ${ce>0?ce:1} tool call${ce>1?"s":""} due to syntax/structure issues:
769
- ${Be} [/system]`:`[system] Failed to execute ${ce>0?ce:1} tool${ce>1?"s":""}. Verify proper structure compliance [action:ActionName(arg="value")] & try again [/system]`;x.push({role:"user",text:mt}),await St("toolFailure"),yield{type:"visual_feedback",content:`
785
+ ${Le?`Parsing Issues Detected:
786
+ ${Le}
787
+ `:""}Verify proper structure compliance [action:ActionName(arg="value")] & try failed calls again [/system]`;for(let it=0;it<Ye;it++)await St("toolFailure")}let Ft=Ge.find(Xe=>Xe.binaryPart)?.binaryPart||null;x.push({role:"user",text:U,binaryPart:Ft})}}else if(!ct){let U=we.replace(/(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\]|$)/i,""),z=En(U),E=ia(U,z),ce=(yi(E).match(/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi)||[]).length;if(Go||Nt&&ce>0||ce>0){let Be=ra(U),mt=Be?`[system] Failed to execute ${ce>0?ce:1} action call${ce>1?"s":""} due to syntax/structure issues:
788
+ ${Be} [/system]`:`[system] Failed to execute ${ce>0?ce:1} action${ce>1?"s":""}. Verify proper structure compliance [action:ActionName(arg="value")] & try again [/system]`;x.push({role:"user",text:mt}),await St("toolFailure"),yield{type:"visual_feedback",content:`
770
789
  ${Rt("\u2718 Model produced malformed tool call")}
771
790
  `}}else yield{type:"visual_feedback",content:`
772
791
  ${Rt("\u2718 Loop Detected")}
773
- `},x.push({role:"user",text:`[system] ${$n&&!Tt?"Stuttering Detected by Internal System. Re-calibrate your response & proceed.":`${Tt?" Over Thinking":" Loop"} Detected by Internal System${Tt?" for current Effort Level":""}. ${Tt?"If you have planned the task, prioritize execution/output":"If you have finished your task provide a simple summary and end"}`} [/system]`});Tt=!1,$n=!1,Mt=!1}m?.advanceRollback&&await ho.recordTurnDelta(g,C+1,pe),Si=pe.includes("recapture_screen"),Fo=bt>0||fn}if(!As&&!ct){let C="\u2726 Turn safety limit reached. Stopping execution.";yield{type:"text",content:`
792
+ `},x.push({role:"user",text:`[system] ${On&&!Tt?"Stuttering Detected by Internal System. Re-calibrate your response & proceed.":`${Tt?" Over Thinking":" Loop"} Detected by Internal System${Tt?" for current Effort Level":""}. ${Tt?"If you have planned the task, prioritize execution/output":"If you have finished your task provide a simple summary and end"}`} [/system]`});Tt=!1,On=!1,Pt=!1}m?.advanceRollback&&await yo.recordTurnDelta(g,C+1,pe),Ci=pe.includes("recapture_screen"),Go=bt>0||un}if(!Rs&&!ct){let C="\u2726 Turn safety limit reached. Stopping execution.";yield{type:"text",content:`
774
793
 
775
794
  ${C}
776
- `};let Se=(bi.join(`
795
+ `};let Se=(Ai.join(`
777
796
  `)+`
778
- ${C}`).trim();yield{type:"interactive_turn_finished",data:{agentText:Ie,fullAgentTextRaw:Se,history:[...x],needTitle:Re}},yield{type:"status",content:"[end]"}}}catch(G){let x=G?.cause?` (Cause: ${G.cause?.message||String(G.cause)})`:"",De=(G instanceof Error?(()=>{try{return JSON.parse(JSON.parse(G.message).error.message).error.message}catch{return(G.message?`${G.message}${x}`:"")||String(G)}})():String(G)).replace(/^(Error:\s*)+/i,"");s==="Google"&&!/^[A-Z0-9_\-\s]+ ERROR:/i.test(De)&&(De=`GEMINI ERROR: ${De}`);let Ht=new Date().toLocaleString(),Ne=te.join(Wn,"agent");yield{type:"text",content:`
797
+ ${C}`).trim();yield{type:"interactive_turn_finished",data:{agentText:Ie,fullAgentTextRaw:Se,history:[...x],needTitle:Re}},yield{type:"status",content:"[end]"}}}catch(G){let x=G?.cause?` (Cause: ${G.cause?.message||String(G.cause)})`:"",De=(G instanceof Error?(()=>{try{return JSON.parse(JSON.parse(G.message).error.message).error.message}catch{return(G.message?`${G.message}${x}`:"")||String(G)}})():String(G)).replace(/^(Error:\s*)+/i,"");s==="Google"&&!/^[A-Z0-9_\-\s]+ ERROR:/i.test(De)&&(De=`GEMINI ERROR: ${De}`);let jt=new Date().toLocaleString(),Ne=te.join(Un,"agent");yield{type:"text",content:`
779
798
 
780
799
  \u2726 CRITICAL ERROR: ${De.includes("fetch failed")?"Failed to Connect. Check your Internet Connection or Wait a moment":De}
781
- \u2800`},ve.existsSync(Ne)||ve.mkdirSync(Ne,{recursive:!0}),ve.appendFileSync(te.join(Ne,"error.log"),`CRITICAL ERROR [${Ht}]: ${G}${G?.cause?`
800
+ \u2800`},ve.existsSync(Ne)||ve.mkdirSync(Ne,{recursive:!0}),ve.appendFileSync(te.join(Ne,"error.log"),`CRITICAL ERROR [${jt}]: ${G}${G?.cause?`
782
801
  CAUSE: ${G.cause?.stack||G.cause}`:""}
783
802
 
784
803
  ----------------------------------------------------------------------
785
804
 
786
- `),typeof flushGoogleBuffer=="function"&&(yield*flushGoogleBuffer()),yield{type:"tool_result",content:`ERROR: [INTERNAL CRITICAL] ${De}`}}finally{ze&&(clearInterval(ze),ze=null),typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),await Yo.commitTransaction(),m?.advanceRollback&&await ho.cleanup(g),await Un()}yield{type:"status",content:null}},Hd=async(e,n,t=null,i=null,o=null,r=null,d=!1)=>{let l=await zo(),u={...l,...n},g=typeof o=="number"&&o>0?o:50,h=(u?.systemSettings?.loopLimits||"Default").toLowerCase();if(h==="extended")g=Math.floor(g*3);else if(h==="env"){let Ne=parseInt(process.env.FLUXFLOW_SUBAGENT_MAX_TURNS||process.env.SUBAGENT_MAX_TURNS||process.env.FLUXFLOW_MAX_LOOPS||process.env.MAX_LOOPS||"",10);Number.isFinite(Ne)&&Ne>0&&(g=Ne)}o=g;let m=process.env.SUBAGENT_MODEL?process.env.SUBAGENT_MODEL.trim():null,p=process.env.SUBAGENT_PROVIDER?process.env.SUBAGENT_PROVIDER.trim():null,s=new Date,w=`${s.getFullYear()}-${s.toLocaleString("en-US",{month:"short"}).toUpperCase()}-${String(s.getDate()).padStart(2,"0")}, ${s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).replace(":","-")}`,Pe=(Ne=>{if(!Ne)return null;let re=Ne.toLowerCase();return re==="google"?"Google":re==="deepseek"?"DeepSeek":re==="openrouter"?"OpenRouter":re==="nvidia"?"NVIDIA":re==="mistral"?"Mistral":re==="ollama"?"Ollama":re==="inferx"?"InferX":re==="sensenova"?"SenseNova":re==="poolside"?"Poolside":re==="9router"||re==="9Router"?"9router":re==="aihubmix"||re==="aihub"?"AIHubMix":re==="explabs"||re==="experientiallabs"||re==="experimentallabs"?"ExpLabs":re==="tokenharbor"||re==="token harbor"||re==="token_harbor"||re==="thk"?"TokenHarbor":re==="infron"?"Infron":re==="apinex"||re==="apx"?"APInex":re==="xkiro"||re==="kiro"?"xKiro":re==="c_openai"||re==="custom_openai"||re==="custom (openai)"||re==="custom"?"c_openai":null})(p),v=u?.systemSettings?.CustomSubAgent?u?.systemSettings?.SubAgentModel:null,N=u?.systemSettings?.CustomSubAgent?u?.systemSettings?.SubAgentProvider:null,P=null;if(v==="ENV"?(P=m,m&&Pe&&(u.aiProvider=Pe)):v&&v!=="Default"?(P=v,N&&(u.aiProvider=N)):m&&Pe&&(u.aiProvider=Pe),u.aiProvider){let Ne=await Ps(u.aiProvider);Ne&&(u.apiKey=Ne)}let V=Ne=>{if(!Ne||typeof Ne!="string")return{allowed:!0};let re=[/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 en of re)if(en.test(Ne))return{allowed:!1,reason:`Blocked potentially destructive or unsafe command pattern: "${en.source}"`};return{allowed:!0}},M=t||P||n?.modelName||n?.activeModel||l.activeModel,xe=(process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux")==="Windows",Re=xe&&u?.systemSettings?.preferBash!==!1&&Ds(),Ie="Run(command=string)",ze=`Runs ${xe?Li()?"powershell":"windows CMD":"bash"} command`;Re&&(Ie=`Run(command=string, ${Ns()||Li()?"forcePowershell?=bool:false":"forceCwd?=bool:false"})`,ze="Runs in git bash. Or force native shell");let G=`-- ACTIONS (path = relative to CWD, path separator: '/') --
805
+ `),typeof flushGoogleBuffer=="function"&&(yield*flushGoogleBuffer()),yield{type:"tool_result",content:`ERROR: [INTERNAL CRITICAL] ${De}`}}finally{ze&&(clearInterval(ze),ze=null),typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),await Zo.commitTransaction(),m?.advanceRollback&&await yo.cleanup(g),await Gn()}yield{type:"status",content:null}},zd=async(e,n,t=null,i=null,o=null,r=null,d=!1)=>{let l=await Jo(),u={...l,...n},g=typeof o=="number"&&o>0?o:50,h=(u?.systemSettings?.loopLimits||"Default").toLowerCase();if(h==="extended")g=Math.floor(g*3);else if(h==="env"){let Ne=parseInt(process.env.FLUXFLOW_SUBAGENT_MAX_TURNS||process.env.SUBAGENT_MAX_TURNS||process.env.FLUXFLOW_MAX_LOOPS||process.env.MAX_LOOPS||"",10);Number.isFinite(Ne)&&Ne>0&&(g=Ne)}o=g;let m=process.env.SUBAGENT_MODEL?process.env.SUBAGENT_MODEL.trim():null,p=process.env.SUBAGENT_PROVIDER?process.env.SUBAGENT_PROVIDER.trim():null,s=new Date,w=`${s.getFullYear()}-${s.toLocaleString("en-US",{month:"short"}).toUpperCase()}-${String(s.getDate()).padStart(2,"0")}, ${s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).replace(":","-")}`,Pe=(Ne=>{if(!Ne)return null;let re=Ne.toLowerCase();return re==="google"?"Google":re==="deepseek"?"DeepSeek":re==="openrouter"?"OpenRouter":re==="nvidia"?"NVIDIA":re==="mistral"?"Mistral":re==="ollama"?"Ollama":re==="inferx"?"InferX":re==="sensenova"?"SenseNova":re==="poolside"?"Poolside":re==="9router"||re==="9Router"?"9router":re==="aihubmix"||re==="aihub"?"AIHubMix":re==="explabs"||re==="experientiallabs"||re==="experimentallabs"?"ExpLabs":re==="tokenharbor"||re==="token harbor"||re==="token_harbor"||re==="thk"?"TokenHarbor":re==="infron"?"Infron":re==="apinex"||re==="apx"?"APInex":re==="xkiro"||re==="kiro"?"xKiro":re==="c_openai"||re==="custom_openai"||re==="custom (openai)"||re==="custom"?"c_openai":null})(p),v=u?.systemSettings?.CustomSubAgent?u?.systemSettings?.SubAgentModel:null,N=u?.systemSettings?.CustomSubAgent?u?.systemSettings?.SubAgentProvider:null,P=null;if(v==="ENV"?(P=m,m&&Pe&&(u.aiProvider=Pe)):v&&v!=="Default"?(P=v,N&&(u.aiProvider=N)):m&&Pe&&(u.aiProvider=Pe),u.aiProvider){let Ne=await Os(u.aiProvider);Ne&&(u.apiKey=Ne)}let V=Ne=>{if(!Ne||typeof Ne!="string")return{allowed:!0};let re=[/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 tn of re)if(tn.test(Ne))return{allowed:!1,reason:`Blocked potentially destructive or unsafe command pattern: "${tn.source}"`};return{allowed:!0}},M=t||P||n?.modelName||n?.activeModel||l.activeModel,xe=(process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux")==="Windows",Re=xe&&u?.systemSettings?.preferBash!==!1&&Bs(),Ie="Run(command=string)",ze=`Runs ${xe?Bi()?"powershell":"windows CMD":"bash"} command`;Re&&(Ie=`Run(command=string, ${Ws()||Bi()?"forcePowershell?=bool:false":"forceCwd?=bool:false"})`,ze="Runs in git bash. Or force native shell");let G=`-- ACTIONS (path = relative to CWD, path separator: '/') --
787
806
  In chat output the format \`[action:ActionName(arg1="value1")]\` in NEW line
788
807
  Rules:
789
808
  - JSON escape literal sequences, backslash: \\\\, newLine: \\ n
@@ -820,9 +839,9 @@ Main focus: actions and task, not chatting
820
839
  On completion, provide a detailed summary in Tables/Markdown Format with file modified info. If any task failed report back in detail
821
840
 
822
841
  Current Time: ${w}
823
- === END SYSTEM PROMPT ===`,Gt=[{role:"user",text:`Complete this task: ${e}`}],De=0,Ht="";for(;De<o;){let Ne=await Pi("subagent",u);if(!Ne.allowed)throw new Error(Ne.reason||`Budget Exhausted for Provider (${u?.aiProvider||"Subagent"})`);if(ct){if(n?.taskId&&typeof Ot<"u"){let X=Ot.find(W=>W.id===n.taskId);X&&(X.status="cancelled")}throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}if(n?.taskId&&typeof Ot<"u"){let X=Ot.find(W=>W.id===n.taskId);if(X&&X.status==="cancelled")throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}let re=Gt.map(X=>({role:X.role==="user"?"user":"model",parts:[{text:X.text}]}));r&&r(`[Subagent Turn ${De+1}]...`);let en=["Fast","Low","Medium","High"],jn=process.env.SUBAGENT_THINKING,Po=en.includes(jn)?jn:"Low",$o=(await wl(u,M,re,x,Po)).text||"",En=sa($t($o).trim());Ht=En,r&&r(`[Subagent Response]
824
- ${En}
825
- `),Gt.push({role:"agent",text:En});let Kn=Rn(En);if(Kn.length===0)break;let jt=Kn.filter(X=>X.toolName.toLowerCase()==="askmain"||X.toolName.toLowerCase()==="ask_main"),_n=!1,Ee="";for(let X of Kn){if(ct){if(n?.taskId&&typeof Ot<"u"){let A=Ot.find(ne=>ne.id===n.taskId);A&&(A.status="cancelled")}throw new Error("Subagent task was cancelled.")}if(n?.taskId&&typeof Ot<"u"){let A=Ot.find(ne=>ne.id===n.taskId);if(A&&A.status==="cancelled")throw new Error("Subagent task was cancelled.")}let W=X.toolName.toLowerCase();if(W==="askuser"&&(W="ask"),W==="askmain"||W==="ask_main"){if(_n)continue;_n=!0;let A="";if(jt.length===1?A=L(jt[0].args).question||jt[0].args:A=jt.map((ne,Kt)=>{let Lt=L(ne.args);return`Q${Kt+1}: ${Lt.question||ne.args}`}).join(`
842
+ === END SYSTEM PROMPT ===`,Ht=[{role:"user",text:`Complete this task: ${e}`}],De=0,jt="";for(;De<o;){let Ne=await Di("subagent",u);if(!Ne.allowed)throw new Error(Ne.reason||`Budget Exhausted for Provider (${u?.aiProvider||"Subagent"})`);if(ct){if(n?.taskId&&typeof Lt<"u"){let X=Lt.find(W=>W.id===n.taskId);X&&(X.status="cancelled")}throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}if(n?.taskId&&typeof Lt<"u"){let X=Lt.find(W=>W.id===n.taskId);if(X&&X.status==="cancelled")throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}let re=Ht.map(X=>({role:X.role==="user"?"user":"model",parts:[{text:X.text}]}));r&&r(`[Subagent Turn ${De+1}]...`);let tn=["Fast","Low","Medium","High"],Kn=process.env.SUBAGENT_THINKING,$o=tn.includes(Kn)?Kn:"Low",Oo=(await Tl(u,M,re,x,$o)).text||"",_n=la(Ot(Oo).trim());jt=_n,r&&r(`[Subagent Response]
843
+ ${_n}
844
+ `),Ht.push({role:"agent",text:_n});let Vn=En(_n);if(Vn.length===0)break;let Kt=Vn.filter(X=>X.toolName.toLowerCase()==="askmain"||X.toolName.toLowerCase()==="ask_main"),In=!1,Ee="";for(let X of Vn){if(ct){if(n?.taskId&&typeof Lt<"u"){let A=Lt.find(ne=>ne.id===n.taskId);A&&(A.status="cancelled")}throw new Error("Subagent task was cancelled.")}if(n?.taskId&&typeof Lt<"u"){let A=Lt.find(ne=>ne.id===n.taskId);if(A&&A.status==="cancelled")throw new Error("Subagent task was cancelled.")}let W=X.toolName.toLowerCase();if(W==="askuser"&&(W="ask"),W==="askmain"||W==="ask_main"){if(In)continue;In=!0;let A="";if(Kt.length===1?A=O(Kt[0].args).question||Kt[0].args:A=Kt.map((ne,Vt)=>{let Dt=O(ne.args);return`Q${Vt+1}: ${Dt.question||ne.args}`}).join(`
826
845
  `),n.onAskMain){r&&r(`[Executing Tool] AskMain("${A}")...`);let ne=await n.onAskMain(A);r&&r(`[Action Result]
827
846
  Answer from Main Agent: ${ne}
828
847
  `),Ee+=`[ACTION RESULT for AskMain]: Answer from Main Agent: ${ne}
@@ -832,16 +851,16 @@ Answer from Main Agent: ${ne}
832
851
  `;continue}if(!(i?i.some(A=>A.toLowerCase()===W):!0)){let A=`ERROR: Tool [${X.toolName}] is not in the allowed tools list for this subagent.`;r&&r(`[Blocked Tool Call] ${X.toolName} - not allowed
833
852
  `),Ee+=`${A}
834
853
 
835
- `;continue}if(W==="exec_command"||W==="execcommand"||W==="run"){let A=L(X.args).command||"",ne=V(A);if(!ne.allowed){let Kt=`ERROR: [SECURITY RESTRICTION] Subagent execution blocked command: ${ne.reason}`;r&&r(`[Blocked Command] ${A} - ${ne.reason}
836
- `),Ee+=`${Kt}
854
+ `;continue}if(W==="exec_command"||W==="execcommand"||W==="run"){let A=O(X.args).command||"",ne=V(A);if(!ne.allowed){let Vt=`ERROR: [SECURITY RESTRICTION] Subagent execution blocked command: ${ne.reason}`;r&&r(`[Blocked Command] ${A} - ${ne.reason}
855
+ `),Ee+=`${Vt}
837
856
 
838
- `;continue}}let ut="";if(W==="web_search"||W==="websearch")ut=`\u2714 \x1B[95mSearched\x1B[0m: ${L(X.args).query||""}`;else if(W==="web_scrape"||W==="webscrape")ut=`\u2714 \x1B[95mScraped\x1B[0m: ${L(X.args).url||""}`;else if(W==="search_keyword"||W==="searchkeyword"||W==="codesearch"||W==="code_search"){let A=L(X.args),ne=A.keyword||"",Kt=A.path||"";ut=`${ne?"\u2714":"\u2718"} \x1B[95mSearched\x1B[0m: ${ne||"No Query"}${Kt?` \u2192 ${Kt.replaceAll("\\","/")}`:""}`}else if(W==="view_file"||W==="viewfile"||W==="readfile")ut=`\u2714 \x1B[95mRead\x1B[0m: ${(L(X.args).path||"").replaceAll("\\","/")}`;else if(W==="find_file"||W==="findfile"){let A=L(X.args),ne=A.basename||A.name||A.path||A.file||A.query||"";ut=`${ne?"\u2714":"\u2718"} \x1B[95mLocated\x1B[0m: ${ne||"No Query"}`}else if(W==="list_files"||W==="read_folder"||W==="readfolder"){let A=L(X.args).path||null,ne=L(X.args).recurse||0;ut=`${A?"\u2714":"\u2718"} \x1B[95mBrowsed\x1B[0m: ${A?`${A.replaceAll("\\","/")}${ne>0?`${A.endsWith("/")?`*${ne}`:`/*${ne}`}`:`${A.endsWith("/")?"":"/"}`}`:""}`}else if(W==="write_file"||W==="writefile"){let A=L(X.args).path||null;ut=`${A?"\u2714":"\u2718"} \x1B[95mCreated\x1B[0m: ${A?`${A.replaceAll("\\","/")}`:"No File Changes"}`}else if(W==="update_file"||W==="updatefile"||W==="patchfile"||W==="patch_file"){let A=L(X.args),ne=A.path||null,Lt=Object.entries(A).some(([wt,In])=>wt.startsWith("searchContent")&&typeof In=="string"&&In.startsWith("^LINE:"))?"\u1361":":";ut=`${ne?"\u2714":"\u2718"} \x1B[95mEdited\x1B[0m${Lt} ${ne?`${ne.replaceAll("\\","/")}`:"No File Changes"}`}else if(W==="exec_command"||W==="execcommand"||W==="run"){let A=L(X.args).command||null;ut=`${A?"\u2714":"\u2718"} \x1B[95mExecuted\x1B[0m: ${A?A.slice(0,100)+(A.length>100?"...":""):"No Command"}`}else if(W==="file_map"||W==="filemap"){let A=L(X.args).path||"";ut=`${A?"\u2714":"\u2718"} \x1B[95mIndexed\x1B[0m: ${A?`${A.replaceAll("\\","/")}`:"File Not Found"}`}else if(W==="await"){let{time:A}=L(X.args),ne=parseFloat(A)||0;ne<10&&(ne=10),ne>180&&(ne=180),ut=`\u2714 \x1B[95mAwaiting\x1B[0m \u2192 ${(Lt=>{if(Lt>=60){let wt=Math.floor(Lt/60),In=Lt%60;return`${wt}m${In>0?` ${In}s`:""}`}return`${Lt}s`})(ne)}`}else{let A=fs[W]||X.toolName,ne=Hn(W,X.args);ut=`\u2714 \x1B[95m${A}\x1B[0m${ne?`: ${ne}`:""}`}n.onVisualFeedback&&ut&&n.onVisualFeedback(ut),r&&r(`[Executing Tool] ${X.toolName}(${X.args})...`);try{let A=await ns(X.toolName,X.args,{...n,mode:"Flux"});r&&r(`[Action Result]
857
+ `;continue}}let ut="";if(W==="web_search"||W==="websearch")ut=`\u2714 \x1B[95mSearched\x1B[0m: ${O(X.args).query||""}`;else if(W==="web_scrape"||W==="webscrape")ut=`\u2714 \x1B[95mScraped\x1B[0m: ${O(X.args).url||""}`;else if(W==="search_keyword"||W==="searchkeyword"||W==="codesearch"||W==="code_search"){let A=O(X.args),ne=A.keyword||"",Vt=A.path||"";ut=`${ne?"\u2714":"\u2718"} \x1B[95mSearched\x1B[0m: ${ne||"No Query"}${Vt?` \u2192 ${Vt.replaceAll("\\","/")}`:""}`}else if(W==="view_file"||W==="viewfile"||W==="readfile")ut=`\u2714 \x1B[95mRead\x1B[0m: ${(O(X.args).path||"").replaceAll("\\","/")}`;else if(W==="find_file"||W==="findfile"){let A=O(X.args),ne=A.basename||A.name||A.path||A.file||A.query||"";ut=`${ne?"\u2714":"\u2718"} \x1B[95mLocated\x1B[0m: ${ne||"No Query"}`}else if(W==="list_files"||W==="read_folder"||W==="readfolder"){let A=O(X.args).path||null,ne=O(X.args).recurse||0;ut=`${A?"\u2714":"\u2718"} \x1B[95mBrowsed\x1B[0m: ${A?`${A.replaceAll("\\","/")}${ne>0?`${A.endsWith("/")?`*${ne}`:`/*${ne}`}`:`${A.endsWith("/")?"":"/"}`}`:""}`}else if(W==="write_file"||W==="writefile"){let A=O(X.args).path||null;ut=`${A?"\u2714":"\u2718"} \x1B[95mCreated\x1B[0m: ${A?`${A.replaceAll("\\","/")}`:"No File Changes"}`}else if(W==="update_file"||W==="updatefile"||W==="patchfile"||W==="patch_file"){let A=O(X.args),ne=A.path||null,Dt=Object.entries(A).some(([wt,Mn])=>wt.startsWith("searchContent")&&typeof Mn=="string"&&Mn.startsWith("^LINE:"))?"\u1361":":";ut=`${ne?"\u2714":"\u2718"} \x1B[95mEdited\x1B[0m${Dt} ${ne?`${ne.replaceAll("\\","/")}`:"No File Changes"}`}else if(W==="exec_command"||W==="execcommand"||W==="run"){let A=O(X.args).command||null;ut=`${A?"\u2714":"\u2718"} \x1B[95mExecuted\x1B[0m: ${A?A.slice(0,100)+(A.length>100?"...":""):"No Command"}`}else if(W==="file_map"||W==="filemap"){let A=O(X.args).path||"";ut=`${A?"\u2714":"\u2718"} \x1B[95mIndexed\x1B[0m: ${A?`${A.replaceAll("\\","/")}`:"File Not Found"}`}else if(W==="await"){let{time:A}=O(X.args),ne=parseFloat(A)||0;ne<10&&(ne=10),ne>180&&(ne=180),ut=`\u2714 \x1B[95mAwaiting\x1B[0m \u2192 ${(Dt=>{if(Dt>=60){let wt=Math.floor(Dt/60),Mn=Dt%60;return`${wt}m${Mn>0?` ${Mn}s`:""}`}return`${Dt}s`})(ne)}`}else{let A=ps[W]||X.toolName,ne=jn(W,X.args);ut=`\u2714 \x1B[95m${A}\x1B[0m${ne?`: ${ne}`:""}`}n.onVisualFeedback&&ut&&n.onVisualFeedback(ut),r&&r(`[Executing Tool] ${X.toolName}(${X.args})...`);try{let A=await rs(X.toolName,X.args,{...n,mode:"Flux"});r&&r(`[Action Result]
839
858
  ${A}
840
859
  `),Ee+=`[ACTION RESULT for ${X.toolName}]: ${A}
841
860
 
842
861
  `,await St("toolSuccess")}catch(A){let ne=`ERROR: Execution failed for [${X.toolName}]: ${A.message}`;r&&r(`[Tool Error] ${ne}
843
862
  `),Ee+=`${ne}
844
863
 
845
- `,await St("toolFailure")}}let Vn="";if(n?.taskId&&typeof Ot<"u"){let X=Ot.find(W=>W.id===n.taskId);if(X&&X.pendingSteerMessages&&X.pendingSteerMessages.length>0){let W=[...X.pendingSteerMessages];X.pendingSteerMessages=[];for(let qn of W)Vn+=`
864
+ `,await St("toolFailure")}}let zn="";if(n?.taskId&&typeof Lt<"u"){let X=Lt.find(W=>W.id===n.taskId);if(X&&X.pendingSteerMessages&&X.pendingSteerMessages.length>0){let W=[...X.pendingSteerMessages];X.pendingSteerMessages=[];for(let Yn of W)zn+=`
846
865
 
847
- [STEERING INSTRUCTION FROM MAIN AGENT]: ${qn}`,r&&r(`[Subagent Steered] ${qn}`)}}let zn=(Ee.trim()+Vn).trim();Gt.push({role:"user",text:zn}),De++}return Ht};export{io as a,ci as b,Uc as c,Gc as d,cc as e,dc as f,oo as g,fc as h,Rc as i,Ec as j,dl as k,Dd as l,fl as m,ul as n,ds as o,$t as p,ui as q,sa as r,Nd as s,Fd as t,Bd as u,ra as v,Wd as w,gi as x,ta as y,hl as z,Rn as A,Ud as B,wl as C,Gd as D,Hd as E};
866
+ [STEERING INSTRUCTION FROM MAIN AGENT]: ${Yn}`,r&&r(`[Subagent Steered] ${Yn}`)}}let qn=(Ee.trim()+zn).trim();Ht.push({role:"user",text:qn}),De++}return jt};export{so as a,gi as b,Kc as c,Vc as d,gc as e,mc as f,io as g,pc as h,Mc as i,Pc as j,ml as k,Wd as l,pl as m,hl as n,ms as o,Ot as p,hi as q,la as r,Ud as s,Gd as t,Hd as u,ca as v,jd as w,yi as x,ia as y,bl as z,En as A,Kd as B,Tl as C,Vd as D,zd as E};