fluxflow-cli 5.7.1 → 5.8.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.
Files changed (46) hide show
  1. package/README.md +24 -14
  2. package/dist/chunks/{ai-7IGEWDC4.js → ai-6F3WLAXU.js} +1 -1
  3. package/dist/chunks/{app-TEFKZ7BF.js → app-RDB7EBDV.js} +74 -74
  4. package/dist/chunks/{auto_completion-YLQZ35AI.js → auto_completion-LLOLRQTZ.js} +1 -1
  5. package/dist/chunks/chunk-2Q6KKC74.js +2 -0
  6. package/dist/chunks/chunk-3XJQTYIL.js +1 -0
  7. package/dist/chunks/{chunk-CGNNVGKZ.js → chunk-63PXA3SA.js} +238 -236
  8. package/dist/chunks/{chunk-GRJHGYAU.js → chunk-E3RSSW5O.js} +1 -1
  9. package/dist/chunks/{chunk-RGQWDXID.js → chunk-F36PAVKE.js} +1 -1
  10. package/dist/chunks/{chunk-DWQSI6JO.js → chunk-HGHBCWE5.js} +1 -1
  11. package/dist/chunks/{chunk-LTNOPF2E.js → chunk-IZBOTHQP.js} +9 -9
  12. package/dist/chunks/{chunk-I3Q4EEDY.js → chunk-JWB2S22X.js} +1 -1
  13. package/dist/chunks/{chunk-JMMO76HS.js → chunk-OO34QR3O.js} +21 -21
  14. package/dist/chunks/{chunk-AJML3MQG.js → chunk-S62UXLFZ.js} +1 -1
  15. package/dist/chunks/{chunk-A3ZRC52P.js → chunk-VDQPTW23.js} +1 -1
  16. package/dist/chunks/{click-J3HGKREV.js → click-VXWUG5T3.js} +2 -2
  17. package/dist/chunks/{computer_action-GJV76M3H.js → computer_action-SI6AMRJ6.js} +1 -1
  18. package/dist/chunks/{custom_openai-XRPZ25BZ.js → custom_openai-EYI4WXHZ.js} +1 -1
  19. package/dist/chunks/{drag-CXZGQ6VL.js → drag-6XCBUY73.js} +1 -1
  20. package/dist/chunks/{exec_command-22LIHPPH.js → exec_command-E3D5BY3N.js} +1 -1
  21. package/dist/chunks/{generate_image-RB3HJFO6.js → generate_image-5ZVJ7ELI.js} +1 -1
  22. package/dist/chunks/{invoke-WXMEB2A5.js → invoke-QOBG7JPO.js} +2 -2
  23. package/dist/chunks/{invokeSync-O3ZJBM6T.js → invokeSync-UZHY6U2N.js} +2 -2
  24. package/dist/chunks/{key_press-GP35GCNC.js → key_press-ISGXEO42.js} +1 -1
  25. package/dist/chunks/{keyboard_typing-37C44KPF.js → keyboard_typing-TK55ZAVR.js} +1 -1
  26. package/dist/chunks/{mistral-GA36HVZJ.js → mistral-7L7XGX6U.js} +1 -1
  27. package/dist/chunks/{model_config-OPJXDFKG.js → model_config-D3A73AS7.js} +1 -1
  28. package/dist/chunks/{nvidia-Z6TAXVPB.js → nvidia-4SWYYBQP.js} +1 -1
  29. package/dist/chunks/{ollama-6LZL7OKW.js → ollama-22NU2XBD.js} +1 -1
  30. package/dist/chunks/{recapture_screen-MOGI4IMA.js → recapture_screen-BY4Q4D5X.js} +1 -1
  31. package/dist/chunks/{screen_grid-SUWYGRSE.js → screen_grid-3FHYFJVG.js} +1 -1
  32. package/dist/chunks/{scroll-ULY2O6WE.js → scroll-6SPRL73L.js} +1 -1
  33. package/dist/chunks/search_keyword-F6L5WB2S.js +9 -0
  34. package/dist/chunks/{secrets-C2QF3PYO.js → secrets-GLYKU2YR.js} +1 -1
  35. package/dist/chunks/{secrets_v2-LTEHILT6.js → secrets_v2-ZSQLFEIS.js} +1 -1
  36. package/dist/chunks/{settings-MOI6W4VL.js → settings-YRMZZJ3F.js} +1 -1
  37. package/dist/chunks/{update_file-74CZ4JRC.js → update_file-VIKPZENG.js} +1 -1
  38. package/dist/chunks/{usage-H47IV3LH.js → usage-23Z3SVXU.js} +1 -1
  39. package/dist/chunks/{usageServer-7DVP2CP7.js → usageServer-7KEKAGPH.js} +1 -1
  40. package/dist/chunks/{write_file-G4QVTNSH.js → write_file-O3YKZSFP.js} +1 -1
  41. package/dist/cli.js +5 -5
  42. package/dist/package.json +2 -2
  43. package/package.json +2 -2
  44. package/dist/chunks/chunk-OXM7FOYK.js +0 -1
  45. package/dist/chunks/chunk-Y6O7SAPD.js +0 -2
  46. package/dist/chunks/search_keyword-D7D7PMSR.js +0 -9
@@ -1,4 +1,4 @@
1
- import{a as er}from"./chunk-UM5SNZ6X.js";import{a as Mo}from"./chunk-NJTM7OYZ.js";import{a as Ht}from"./chunk-56EJGQU3.js";import{a as tr}from"./chunk-4CWGKQHX.js";import{c as Yi,g as Xi,h as qs,i as Ys,j as Xs}from"./chunk-JMMO76HS.js";import{b as Js,c as Qs,d as Ji,f as Zs}from"./chunk-LTNOPF2E.js";import{a as di}from"./chunk-2RTYI6K3.js";import{a as O}from"./chunk-6LM3YRRE.js";import{b as zs}from"./chunk-GRJHGYAU.js";import{y as Vi}from"./chunk-RGQWDXID.js";import{f as ci,l as $t,o as zi,p as hn,r as qi}from"./chunk-I3Q4EEDY.js";import{b as li}from"./chunk-OXM7FOYK.js";import{l as et,m as ai}from"./chunk-Y6O7SAPD.js";import{c as pn,d as Ki,e as ri}from"./chunk-ZGORMZE5.js";import{a as jn,b as oi,c as ii,d as eo,e as js,k as si,l as Hi,m as Ks,r as ji,w as _o,x as Io,y as Vs,z as mn}from"./chunk-NPXJIGAI.js";import{GoogleGenAI as ya,ThinkingLevel as Ye,HarmBlockThreshold as vi,HarmCategory as Ei}from"@google/genai";var fi={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 Jt from"fs";import an from"path";import Ya from"os";import yn from"fs";import En from"path";import mr from"fs";import Qi from"path";import{execSync as pr}from"child_process";import{fileURLToPath as Va}from"url";var nr=`# FluxFlow CLI Startup & Flags Reference
1
+ import{a as tr}from"./chunk-UM5SNZ6X.js";import{a as Oo}from"./chunk-NJTM7OYZ.js";import{a as Gt}from"./chunk-56EJGQU3.js";import{a as nr}from"./chunk-4CWGKQHX.js";import{c as Qi,g as Zi,h as Ys,i as Xs,j as Js}from"./chunk-OO34QR3O.js";import{b as Qs,c as Zs,d as es,f as er}from"./chunk-IZBOTHQP.js";import{a as mi}from"./chunk-2RTYI6K3.js";import{a as O}from"./chunk-6LM3YRRE.js";import{b as qs}from"./chunk-E3RSSW5O.js";import{y as Yi}from"./chunk-F36PAVKE.js";import{f as gi,l as Lt,o as Xi,p as hn,r as Ji}from"./chunk-JWB2S22X.js";import{b as ui}from"./chunk-3XJQTYIL.js";import{l as Ze,m as fi}from"./chunk-2Q6KKC74.js";import{c as pn,d as qi,e as di}from"./chunk-ZGORMZE5.js";import{a as Kn,b as ai,c as li,d as oo,e as Ks,k as ci,l as Vi,m as Vs,r as zi,w as $o,x as Lo,y as zs,z as mn}from"./chunk-NPXJIGAI.js";import{GoogleGenAI as xa,ThinkingLevel as qe,HarmBlockThreshold as Mi,HarmCategory as Pi}from"@google/genai";var pi={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 Jt from"fs";import sn from"path";import Ya from"os";import yn from"fs";import En from"path";import pr from"fs";import ts from"path";import{execSync as hr}from"child_process";import{fileURLToPath as Va}from"url";var or=`# 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 or=`# Env Variables
30
+ `;var ir=`# 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 ir=`# Fluxflow in-app /commands
61
+ `;var sr=`# 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 ./playground-export
114
- `;var sr=`# FluxFlow In-App Settings Reference
114
+ `;var rr=`# FluxFlow In-App Settings Reference
115
115
 
116
116
  Open in chat via /settings
117
117
 
@@ -161,6 +161,7 @@ Open in chat via /settings
161
161
  ### 6. Secondary Models
162
162
  * Sub-Agents \u2192 Enable sub-agents
163
163
  * Sub-Agent Model \u2192 Dedicated model/provider for sub-agents
164
+ * Wildcard Tooling for subagent \u2192 Helps models tha fails to call tools
164
165
  * Auto Completion in IDE \u2192 Toggle
165
166
  * Completion Model
166
167
  * Commit Msg Model
@@ -186,7 +187,7 @@ Open in chat via /settings
186
187
  | Emergency Recovery | Off | Off |
187
188
  | Auto Truncate Results | On | On |
188
189
  | Memory | Off | Off |
189
- `;var rr=`# FluxFlow Tool Reference
190
+ `;var ar=`# FluxFlow Tool Reference
190
191
 
191
192
  ## Protocol: [action:ActionName(arg1="val")]
192
193
 
@@ -227,7 +228,7 @@ Open in chat via /settings
227
228
  * KeyboardTyping(text, autoPressEnter?) \u2192 Type string
228
229
  * KeyPress(key) \u2192 Key/combo dispatch ("ctrl;c", "enter", etc.)
229
230
  * RecaptureScreen() \u2192 Fresh screenshot + coordinate grid
230
- `;var ar=`# Fluxflow Architecture
231
+ `;var lr=`# Fluxflow Architecture
231
232
 
232
233
  ## 1. Terminal Engine
233
234
  * Framework: React + Ink terminal UI
@@ -257,7 +258,7 @@ Open in chat via /settings
257
258
  ## 6. IDE Bridge
258
259
  * Protocol: WebSocket on ws://localhost:56832
259
260
  * State Sync: Focused file, open tabs, cursor line, selection, diagnostics
260
- `;var lr=`# FluxFlow Sub-Agents & Multi-Agent Architecture
261
+ `;var cr=`# FluxFlow Sub-Agents & Multi-Agent Architecture
261
262
 
262
263
  ## Execution Modes
263
264
  * InvokeSync \u2192 Synchronous blocking delegation; main agent halts until sub-agent finishes task
@@ -288,7 +289,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
288
289
  * SUBAGENT_MODEL \u2192 Target model override
289
290
  * SUBAGENT_PROVIDER \u2192 Target provider override
290
291
  * Setting SubAgentModel=ENV in settings pulls directly from environment overrides
291
- `;var cr=`# FluxFlow Security, Sandboxing & Safety
292
+ `;var dr=`# FluxFlow Security, Sandboxing & Safety
292
293
 
293
294
  ## Human-in-the-Loop Governance
294
295
  * Execution Approval Gate \u2192 Destructive commands and high-risk file modifications require explicit user authorization (Allow / Deny)
@@ -311,7 +312,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
311
312
  * Emergency Rollback \u2192 Automatic pre-turn file snapshots; Agent can still fix it (default: OFF) \u2192 references/SETTINGS.md
312
313
  * Git-less Checkpoint Reversion \u2192 Trigger conversational changes rollback via double-ESC
313
314
  * External Sanctuary Redirection \u2192 Move ~/.fluxflow data sanctuary (chats, keys etc)
314
- `;var dr=`# Fluxflow IDE Companion
315
+ `;var fr=`# Fluxflow IDE Companion
315
316
 
316
317
  ## WebSocket Bridge Protocol
317
318
  * Local Bridge \u2192 Runs on ws://localhost:56832 connecting FluxFlow CLI with the companion editor extension
@@ -329,7 +330,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
329
330
  * File Focus \u2192 Automatically opens edited files in active IDE window
330
331
  * Diff Preview \u2192 Streams side-by-side or inline diff highlights (showDiff, highlightDiff) directly in editor
331
332
  * Status Bar Sync \u2192 Real-time agent status (thinking, running tool, awaiting input) reflected in IDE status bar
332
- `;var fr=`# Fluxflow Modes
333
+ `;var ur=`# Fluxflow Modes
333
334
 
334
335
  ## Modes Overview (TAB to cycle)
335
336
  * [Flux] (Workspace / Dev) \u2192 Primary coding & workspace agent
@@ -347,7 +348,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
347
348
  * User Inquiry: AskUser \u2192 [Universal]
348
349
  * Document Creation: WritePDF, WriteDoc \u2192 [Flow]
349
350
  * GUI & Desktop Automation: Click, Scroll, KeyboardTyping, KeyPress, RecaptureScreen \u2192 [ICU] | [FluxCU]
350
- `;var ur=`# FluxFlow AI Providers & Setup
351
+ `;var gr=`# FluxFlow AI Providers & Setup
351
352
 
352
353
  ## Supported Providers
353
354
  * Gemini | NVIDIA NIM | DeepSeek | Mistral | Ollama Local/Cloud | InferX | SenseNova | Poolside | OpenRouter | AIHubMix | Experiential Labs | TokenHarbor | APInex | Infron | Coarena | Numes
@@ -389,7 +390,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
389
390
  2. Set ENV ENABLE_9ROUTER=true
390
391
  * 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
391
392
  * NINEROUTER_KEY = If any needed
392
- `;var gr=`# Fluxflow Instructions & Skills System
393
+ `;var mr=`# Fluxflow Instructions & Skills System
393
394
 
394
395
  ## 1. Instructions (AGENTS.md / FLUXFLOW.md root only)
395
396
  * Locations:
@@ -433,14 +434,14 @@ Instruction for this model ID across all providers.
433
434
 
434
435
  * On-Demand Reference System:
435
436
  * Reference: Offload deep/contexual specs to **/{SKILL.md,skill-reference-folder/*.md} & reference in SKILL.md. Saves tokens
436
- `;var ui="v4";try{let e=Qi.dirname(Va(import.meta.url)),t=[Qi.join(e,"../../package.json"),Qi.join(e,"../package.json")],n=!1;for(let s of t)if(mr.existsSync(s)){let o=JSON.parse(mr.readFileSync(s,"utf8"));if(o.version){ui=o.version,n=!0;break}}if(!n)try{let s=pr("fluxflow -v",{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"],timeout:2e3}).trim();s&&(s.startsWith("v")||/^\d+\.\d+/.test(s))&&(ui=s,n=!0)}catch{}if(!n)try{let s=pr("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(s);o.version&&(ui=o.version)}catch{}}catch{}var Zi={"SKILL.md":`---
437
+ `;var hi="v4";try{let e=ts.dirname(Va(import.meta.url)),t=[ts.join(e,"../../package.json"),ts.join(e,"../package.json")],n=!1;for(let s of t)if(pr.existsSync(s)){let o=JSON.parse(pr.readFileSync(s,"utf8"));if(o.version){hi=o.version,n=!0;break}}if(!n)try{let s=hr("fluxflow -v",{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"],timeout:2e3}).trim();s&&(s.startsWith("v")||/^\d+\.\d+/.test(s))&&(hi=s,n=!0)}catch{}if(!n)try{let s=hr("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(s);o.version&&(hi=o.version)}catch{}}catch{}var ns={"SKILL.md":`---
437
438
  name: fluxflow
438
439
  description: System Generated Documentation. Read this if asked anything regarding FluxFlow Harness, model info
439
440
  ---
440
441
 
441
442
  # FluxFlow, by Kushal Roy Chowdhury
442
443
  Open Source Terminal AI Assistant
443
- App Version: ${ui}. Check Updates: fluxflow --update check. Update: fluxflow --update
444
+ App Version: ${hi}. Check Updates: fluxflow --update check. Update: fluxflow --update
444
445
  GitHub: https://github.com/KushalRoyChowdhury/fluxflow-cli
445
446
  Public Docs: https://fluxflow-cli.onrender.com
446
447
 
@@ -458,52 +459,52 @@ Public Docs: https://fluxflow-cli.onrender.com
458
459
  * Priority Instructions (AGENTS.md/FLUXFLOW.md) & Skill System \u2192 references/PLUGINS.md
459
460
  * Agent Architecture & Memory System \u2192 references/ARCHITECTURE.md
460
461
 
461
- Docs missing required info? Say you are not sure enough to answer. Dont give wrong info`,"references/MODES.md":fr,"references/PROVIDERS.md":ur,"references/PLUGINS.md":gr,"references/STARTUP.md":nr,"references/ENV.md":or,"references/COMMANDS.md":ir,"references/SETTINGS.md":sr,"references/TOOLS.md":rr,"references/ARCHITECTURE.md":ar,"references/SUB_AGENTS.md":lr,"references/SECURITY.md":cr,"references/IDE.md":dr};var hr=(e=null)=>{try{let t=En.join(jn,"skills","fluxflow"),n=En.join(t,"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){yn.existsSync(t)&&yn.rmSync(t,{recursive:!0,force:!0});return}let o=new Set(Object.keys(Zi).map(m=>En.normalize(m))),d=(e||""||"").replace(/^.*::/,"").split(":")[0].replace(/\/free$/,"").trim(),a=En.basename(d).replace(/-free$/,"").replace(/_free$/,"").replace(/^free_/,"").replace(/(\d)-(\d)/g,"$1.$2").replaceAll("-"," ").replaceAll("_"," ").replace(/\b\w/g,m=>m.toUpperCase().trim());for(let[m,f]of Object.entries(Zi)){let h=En.join(t,m),p=En.dirname(h);yn.existsSync(p)||yn.mkdirSync(p,{recursive:!0});let g=f;m==="SKILL.md"&&a&&(g=g.replace(/Public Docs: [^\n]*/,`Public Docs: ${g.match(/Public Docs: ([^\n]*)/)?.[1]||""}
462
+ Docs missing required info? Say you are not sure enough to answer. Dont give wrong info`,"references/MODES.md":ur,"references/PROVIDERS.md":gr,"references/PLUGINS.md":mr,"references/STARTUP.md":or,"references/ENV.md":ir,"references/COMMANDS.md":sr,"references/SETTINGS.md":rr,"references/TOOLS.md":ar,"references/ARCHITECTURE.md":lr,"references/SUB_AGENTS.md":cr,"references/SECURITY.md":dr,"references/IDE.md":fr};var yr=(e=null)=>{try{let t=En.join(Kn,"skills","fluxflow"),n=En.join(t,"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){yn.existsSync(t)&&yn.rmSync(t,{recursive:!0,force:!0});return}let o=new Set(Object.keys(ns).map(m=>En.normalize(m))),d=(e||""||"").replace(/^.*::/,"").split(":")[0].replace(/\/free$/,"").trim(),a=En.basename(d).replace(/-free$/,"").replace(/_free$/,"").replace(/^free_/,"").replace(/(\d)-(\d)/g,"$1.$2").replaceAll("-"," ").replaceAll("_"," ").replace(/\b\w/g,m=>m.toUpperCase().trim());for(let[m,f]of Object.entries(ns)){let h=En.join(t,m),p=En.dirname(h);yn.existsSync(p)||yn.mkdirSync(p,{recursive:!0});let g=f;m==="SKILL.md"&&a&&(g=g.replace(/Public Docs: [^\n]*/,`Public Docs: ${g.match(/Public Docs: ([^\n]*)/)?.[1]||""}
462
463
  Active Model: ${a}`));let i=g.trim()+`
463
- `,x=null;yn.existsSync(h)&&(x=yn.readFileSync(h,"utf8")),x!==i&&yn.writeFileSync(h,i,"utf8")}if(yn.existsSync(n)){let m=yn.readdirSync(n);for(let f of m){let h=En.normalize(En.join("references",f));if(!o.has(h)){let p=En.join(n,f);try{yn.rmSync(p,{recursive:!0,force:!0})}catch{}}}}}catch{}};import{WebSocket as gi}from"ws";var Dt=null,po=!1,za="ws://localhost:56832",es=[],ho=null,ts=null,ns=null,yr="2.0.0",Tc=e=>{yr=e,xr()},os=e=>{ts=e},Ac=e=>{ns=e},xr=()=>{if(Dt||po)return;po=!0;let e=new gi(za);e.on("open",()=>{for(Dt=e,po=!1,Dt.send(JSON.stringify({command:"version",version:yr,pid:process.pid,ppid:process.ppid,cwd:process.cwd()}));es.length>0;)Dt.send(JSON.stringify(es.shift()))}),e.on("message",t=>{try{let n=JSON.parse(t.toString());n.command==="contextResponse"&&ho?(ho(n.data),ho=null):n.command==="securityResponse"&&ts?ts(n.result):n.command==="inlineComplete"?qa(n):n.command==="connectionRejected"&&ns&&ns(n)}catch{}}),e.on("error",()=>{po=!1,Dt=null}),e.on("close",()=>{po=!1,Dt=null})},Po=e=>{Dt&&Dt.readyState===gi.OPEN?Dt.send(JSON.stringify(e)):(es.push(e),po||xr())},yo=()=>Dt!==null&&Dt.readyState===gi.OPEN,qa=async e=>{let t="";try{let{generateAutoCompletion:n}=await import("./auto_completion-YLQZ35AI.js");t=await n({prefix:e.prefix||"",suffix:e.suffix||"",fileName:e.fileName||"",language:e.language||"",recentChanges:e.recentChanges||"",clipboard:e.clipboard||""})}catch{t=""}Po({command:"inlineCompleteResponse",requestId:e.requestId,completion:t||""})},Cc=e=>{Po({command:"status",status:e})},to=()=>new Promise(e=>{if(!Dt||Dt.readyState!==gi.OPEN){e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]});return}ho=e,Dt.send(JSON.stringify({command:"requestContext"})),setTimeout(()=>{ho===e&&(e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]}),ho=null)},1e3)}),wr=e=>{let{resolvedPath:t}=mn(e);Po({command:"open",filePath:t})},is=(e,t,n)=>{let{resolvedPath:s}=mn(e);Po({command:"showDiff",filePath:s,originalContent:t,modifiedContent:n})},br=(e,t)=>{let{resolvedPath:n}=mn(e);Po({command:"closeDiff",filePath:n,result:t})};var Bo=(e,t)=>{try{if(!Jt.existsSync(e))return null;let n=Array.isArray(t)?t.map(o=>o.toLowerCase()):[t.toLowerCase()],s=Jt.readdirSync(e);for(let o of n){let r=s.find(d=>d.toLowerCase()===o);if(r){let d=an.join(e,r);if(Jt.statSync(d).isFile())return d}}}catch{}return null},cs=(e,t)=>{let n=Bo(e,t);if(n)try{return Jt.readFileSync(n,"utf8")}catch{}return""},Sr=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"]),ds=(e=process.cwd(),t=0,n=8)=>{let s=[];if(t>n)return s;try{if(!Jt.existsSync(e))return s;let o=Jt.readdirSync(e,{withFileTypes:!0});for(let r of o){let d=r.name,a=an.join(e,d);if(r.isDirectory())!Sr.has(d)&&!Sr.has(d.toLowerCase())&&s.push(...ds(a,t+1,n));else if(r.isFile()){let m=d.toLowerCase();(m==="agents.md"||m==="agent.md")&&s.push(a)}}}catch{}return s},kr=(e,t=2)=>{if(!e)return"";let n=" ".repeat(t);return e.split(/\r?\n/).map(s=>n+s).join(`
464
- `)},vr=()=>Bo(jn,["agents.md","agent.md"]),Er=()=>Bo(process.cwd(),["agents.md","agent.md"]),_r=()=>Bo(jn,["fluxflow.md"]),Ir=()=>Bo(process.cwd(),["fluxflow.md"]),Lo=vr(),mi=Er(),xn=ds(),Oo=_r(),No=Ir(),Tr=null,ls="",Mr=!1,Xa=e=>{if(!e||!/^<<<[\s\S]*?Identity:/m.test(e))return e;let t=e.match(/^<<<\s*\r?\n([\s\S]*?)\r?\n>>>\s*(?:\r?\n)?([\s\S]*)$/);if(!t)return e;let n=t[1],s=t[2],o=n.match(/^Identity:\s*([\s\S]*?)(?=\r?\n\s*(?:<><|>>>)|$)/m);return o&&(ls=o[1].trim(),process.env.NO_INS=!0),/<><\s*NO_INS/.test(n)&&(Mr=!0),s.trim()},Ja=()=>{Lo=vr();let e=Lo?cs(jn,["agents.md","agent.md"]).trim():"";return e.length===0?(Lo=null,""):e},Qa=()=>{if(xn=ds(),mi=Er(),!xn||xn.length===0)return"";let e=process.cwd(),t=[...xn].sort((o,r)=>{let d=an.relative(e,o).replace(/\\/g,"/"),a=an.relative(e,r).replace(/\\/g,"/"),m=!d.includes("/"),f=!a.includes("/");return m&&!f?-1:!m&&f?1:d.localeCompare(a)}),n=[],s=[];for(let o of t)try{let r=Jt.readFileSync(o,"utf8").trim();if(!r||r.length===0)continue;n.push(o);let d=an.relative(e,o).replace(/\\/g,"/");if(!d.includes("/"))s.push(kr(r,2));else{let m=an.dirname(d)+"/:";s.push(`${m}
465
- ${kr(r,2)}`)}}catch{}return xn=n,xn.length===0&&(mi=null),s.join(`
464
+ `,x=null;yn.existsSync(h)&&(x=yn.readFileSync(h,"utf8")),x!==i&&yn.writeFileSync(h,i,"utf8")}if(yn.existsSync(n)){let m=yn.readdirSync(n);for(let f of m){let h=En.normalize(En.join("references",f));if(!o.has(h)){let p=En.join(n,f);try{yn.rmSync(p,{recursive:!0,force:!0})}catch{}}}}}catch{}};import{WebSocket as yi}from"ws";var Dt=null,wo=!1,za="ws://localhost:56832",os=[],bo=null,is=null,ss=null,xr="2.0.0",Tc=e=>{xr=e,wr()},rs=e=>{is=e},Ac=e=>{ss=e},wr=()=>{if(Dt||wo)return;wo=!0;let e=new yi(za);e.on("open",()=>{for(Dt=e,wo=!1,Dt.send(JSON.stringify({command:"version",version:xr,pid:process.pid,ppid:process.ppid,cwd:process.cwd()}));os.length>0;)Dt.send(JSON.stringify(os.shift()))}),e.on("message",t=>{try{let n=JSON.parse(t.toString());n.command==="contextResponse"&&bo?(bo(n.data),bo=null):n.command==="securityResponse"&&is?is(n.result):n.command==="inlineComplete"?qa(n):n.command==="connectionRejected"&&ss&&ss(n)}catch{}}),e.on("error",()=>{wo=!1,Dt=null}),e.on("close",()=>{wo=!1,Dt=null})},No=e=>{Dt&&Dt.readyState===yi.OPEN?Dt.send(JSON.stringify(e)):(os.push(e),wo||wr())},So=()=>Dt!==null&&Dt.readyState===yi.OPEN,qa=async e=>{let t="";try{let{generateAutoCompletion:n}=await import("./auto_completion-LLOLRQTZ.js");t=await n({prefix:e.prefix||"",suffix:e.suffix||"",fileName:e.fileName||"",language:e.language||"",recentChanges:e.recentChanges||"",clipboard:e.clipboard||""})}catch{t=""}No({command:"inlineCompleteResponse",requestId:e.requestId,completion:t||""})},Cc=e=>{No({command:"status",status:e})},io=()=>new Promise(e=>{if(!Dt||Dt.readyState!==yi.OPEN){e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]});return}bo=e,Dt.send(JSON.stringify({command:"requestContext"})),setTimeout(()=>{bo===e&&(e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]}),bo=null)},1e3)}),br=e=>{let{resolvedPath:t}=mn(e);No({command:"open",filePath:t})},as=(e,t,n)=>{let{resolvedPath:s}=mn(e);No({command:"showDiff",filePath:s,originalContent:t,modifiedContent:n})},Sr=(e,t)=>{let{resolvedPath:n}=mn(e);No({command:"closeDiff",filePath:n,result:t})};var Ho=(e,t)=>{try{if(!Jt.existsSync(e))return null;let n=Array.isArray(t)?t.map(o=>o.toLowerCase()):[t.toLowerCase()],s=Jt.readdirSync(e);for(let o of n){let r=s.find(d=>d.toLowerCase()===o);if(r){let d=sn.join(e,r);if(Jt.statSync(d).isFile())return d}}}catch{}return null},us=(e,t)=>{let n=Ho(e,t);if(n)try{return Jt.readFileSync(n,"utf8")}catch{}return""},kr=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"]),gs=(e=process.cwd(),t=0,n=8)=>{let s=[];if(t>n)return s;try{if(!Jt.existsSync(e))return s;let o=Jt.readdirSync(e,{withFileTypes:!0});for(let r of o){let d=r.name,a=sn.join(e,d);if(r.isDirectory())!kr.has(d)&&!kr.has(d.toLowerCase())&&s.push(...gs(a,t+1,n));else if(r.isFile()){let m=d.toLowerCase();(m==="agents.md"||m==="agent.md")&&s.push(a)}}}catch{}return s},Tr=(e,t=2)=>{if(!e)return"";let n=" ".repeat(t);return e.split(/\r?\n/).map(s=>n+s).join(`
465
+ `)},Er=()=>Ho(Kn,["agents.md","agent.md"]),_r=()=>Ho(process.cwd(),["agents.md","agent.md"]),Ir=()=>Ho(Kn,["fluxflow.md"]),Mr=()=>Ho(process.cwd(),["fluxflow.md"]),Fo=Er(),xi=_r(),xn=gs(),Bo=Ir(),Uo=Mr(),Ar=null,fs="",Pr=!1,Xa=e=>{if(!e||!/^<<<[\s\S]*?Identity:/m.test(e))return e;let t=e.match(/^<<<\s*\r?\n([\s\S]*?)\r?\n>>>\s*(?:\r?\n)?([\s\S]*)$/);if(!t)return e;let n=t[1],s=t[2],o=n.match(/^Identity:\s*([\s\S]*?)(?=\r?\n\s*(?:<><|>>>)|$)/m);return o&&(fs=o[1].trim(),process.env.NO_INS=!0),/<><\s*NO_INS/.test(n)&&(Pr=!0),s.trim()},Ja=()=>{Fo=Er();let e=Fo?us(Kn,["agents.md","agent.md"]).trim():"";return e.length===0?(Fo=null,""):e},Qa=()=>{if(xn=gs(),xi=_r(),!xn||xn.length===0)return"";let e=process.cwd(),t=[...xn].sort((o,r)=>{let d=sn.relative(e,o).replace(/\\/g,"/"),a=sn.relative(e,r).replace(/\\/g,"/"),m=!d.includes("/"),f=!a.includes("/");return m&&!f?-1:!m&&f?1:d.localeCompare(a)}),n=[],s=[];for(let o of t)try{let r=Jt.readFileSync(o,"utf8").trim();if(!r||r.length===0)continue;n.push(o);let d=sn.relative(e,o).replace(/\\/g,"/");if(!d.includes("/"))s.push(Tr(r,2));else{let m=sn.dirname(d)+"/:";s.push(`${m}
466
+ ${Tr(r,2)}`)}}catch{}return xn=n,xn.length===0&&(xi=null),s.join(`
466
467
 
467
- `).trim()},fs=()=>{Oo=_r();let e=Oo?cs(jn,["fluxflow.md"]).trim():"",t=Xa(e)?.trim()||"";return t.length===0?(Oo=null,""):t},us=()=>{No=Ir();let e=No?cs(process.cwd(),["fluxflow.md"]).trim():"";return e.length===0?(No=null,""):e},gs=Ja(),pi=Qa(),Do=fs(),Fo=us(),Ar=(e,t="",n="")=>{if(!e)return"";let s=n.toLowerCase().trim(),o=t.toLowerCase().trim(),r=an.posix.basename(o),d=s&&o?`${s}@${o}`:"",a=s&&r?`${s}@${r}`:"",m=h=>!h||!o?!1:h===o||h===r||h===d||h===a,f=[];return e.replace(/<start_provider_([^>\r\n]+)>([\s\S]*?)<end_provider_([^>\r\n]+)>/gi,(h,p,g,i)=>{if(s&&p.trim().toLowerCase()===i.trim().toLowerCase()&&p.trim().toLowerCase()===s){let I=g.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(Xe,C,M,F)=>{if(C.trim().toLowerCase()===F.trim().toLowerCase()){let G=C.trim().toLowerCase();if(m(G)){let $=M.trim();$&&f.push($)}}return""}).trim();I&&f.push(I)}return""}),e.replace(/<start_model_([^>\r\n@]+@[^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n@]+@[^>\r\n]+)>/gi,(h,p,g,i)=>{if(p.trim().toLowerCase()===i.trim().toLowerCase()){let x=p.trim().toLowerCase();if(m(x)){let I=g.trim();I&&f.push(I)}}return""}),e.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(h,p,g,i)=>{if(p.includes("@"))return"";if(p.trim().toLowerCase()===i.trim().toLowerCase()){let x=p.trim().toLowerCase();if(o&&(x===o||x===r)){let I=g.trim();I&&f.push(I)}}return""}),f.join(`
468
+ `).trim()},ms=()=>{Bo=Ir();let e=Bo?us(Kn,["fluxflow.md"]).trim():"",t=Xa(e)?.trim()||"";return t.length===0?(Bo=null,""):t},ps=()=>{Uo=Mr();let e=Uo?us(process.cwd(),["fluxflow.md"]).trim():"";return e.length===0?(Uo=null,""):e},hs=Ja(),wi=Qa(),Wo=ms(),Go=ps(),Cr=(e,t="",n="")=>{if(!e)return"";let s=n.toLowerCase().trim(),o=t.toLowerCase().trim(),r=sn.posix.basename(o),d=s&&o?`${s}@${o}`:"",a=s&&r?`${s}@${r}`:"",m=h=>!h||!o?!1:h===o||h===r||h===d||h===a,f=[];return e.replace(/<start_provider_([^>\r\n]+)>([\s\S]*?)<end_provider_([^>\r\n]+)>/gi,(h,p,g,i)=>{if(s&&p.trim().toLowerCase()===i.trim().toLowerCase()&&p.trim().toLowerCase()===s){let I=g.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(Ye,C,P,N)=>{if(C.trim().toLowerCase()===N.trim().toLowerCase()){let U=C.trim().toLowerCase();if(m(U)){let $=P.trim();$&&f.push($)}}return""}).trim();I&&f.push(I)}return""}),e.replace(/<start_model_([^>\r\n@]+@[^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n@]+@[^>\r\n]+)>/gi,(h,p,g,i)=>{if(p.trim().toLowerCase()===i.trim().toLowerCase()){let x=p.trim().toLowerCase();if(m(x)){let I=g.trim();I&&f.push(I)}}return""}),e.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(h,p,g,i)=>{if(p.includes("@"))return"";if(p.trim().toLowerCase()===i.trim().toLowerCase()){let x=p.trim().toLowerCase();if(o&&(x===o||x===r)){let I=g.trim();I&&f.push(I)}}return""}),f.join(`
468
469
 
469
- `).trim()},Za=(e="",t="")=>{let n=`${e||""}@${t||""}`.toLowerCase().trim();Tr!==n&&(Tr=n,Do=fs(),Fo=us())};hr();var el=e=>{if(!e)return null;let t=e.match(/^\s*---\r?\n([\s\S]*?)\r?\n---(?:\r?\n)?([\s\S]*)$/);if(!t)return null;let n=t[1];if((t[2]||"").trim().length===0)return null;let o="",r="",d=n.match(/^name:\s*(.+)$/m),a=n.match(/^description:\s*(.+)$/m);return d&&(o=d[1].trim().replace(/^["']|["']$/g,"")),a&&(r=a[1].trim().replace(/^["']|["']$/g,"")),o&&r?{name:o,description:r}:null},tl=e=>{let t=[];if(!e||!Jt.existsSync(e))return t;let n=(s,o=0)=>{if(!(o>5))try{let r=Jt.readdirSync(s,{withFileTypes:!0});for(let d of r){let a=an.join(s,d.name),m=d.name.toLowerCase();d.isFile()?m==="skill.md"&&t.push(a):d.isDirectory()&&(o===0?(m==="skills"||m===".skills"||m==="skill"||m===".skill")&&n(a,o+1):n(a,o+1))}}catch{}};return n(e,0),t},Pr=e=>{let t=tl(e),n=[];for(let s of t)try{let o=Jt.readFileSync(s,"utf8"),r=el(o);r&&n.push({...r,filePath:s})}catch{}return n},$r=e=>!e||e.length===0?"":e.map(t=>`- ${t.name}: ${t.description}`).join(`
470
- `),hi=Pr(jn),yi=Pr(process.cwd()),ss=$r(hi),rs=$r(yi),Lr=e=>{if(!e)return!1;let t=(e.filePath||"").replace(/\\/g,"/").toLowerCase();return t.includes("/skills/fluxflow/skill.md")||t.includes("/skills/about-fluxflow/skill.md")||e.name?.toLowerCase()==="fluxflow"},Or=()=>(hi||[]).filter(e=>!Lr(e)),Nr=()=>(yi||[]).filter(e=>!Lr(e)),Wc=(gs?.length>0?1:0)+(pi?.length>0?xn.length:0)+(Do?.length>0?1:0)+(Fo?.length>0?1:0)+Or().length+Nr().length,as=(e,t="Project")=>{if(!e)return"";let n=e.replace(/\\/g,"/");if(t==="Global"){let o=Ya.homedir().replace(/\\/g,"/");return n.toLowerCase().startsWith(o.toLowerCase())?"~"+n.slice(o.length):n}let s=an.relative(process.cwd(),e).replace(/\\/g,"/");return s.startsWith(".")?s:`./${s}`},Gc=()=>{Do=fs(),Fo=us();let e=[];Lo&&gs.length>0&&e.push({scope:"Global",path:Lo}),xn&&xn.length>0&&pi.length>0?xn.forEach(r=>{e.push({scope:"Project",path:r})}):mi&&pi.length>0&&e.push({scope:"Project",path:mi}),Oo&&Do.length>0&&e.push({scope:"Global",path:Oo}),No&&Fo.length>0&&e.push({scope:"Project",path:No});let t=Or(),n=Nr(),s=e.length+t.length+n.length;if(s===0)return`\u2726 Loaded Files & Instructions
470
+ `).trim()},Za=(e="",t="")=>{let n=`${e||""}@${t||""}`.toLowerCase().trim();Ar!==n&&(Ar=n,Wo=ms(),Go=ps())};yr();var el=e=>{if(!e)return null;let t=e.match(/^\s*---\r?\n([\s\S]*?)\r?\n---(?:\r?\n)?([\s\S]*)$/);if(!t)return null;let n=t[1];if((t[2]||"").trim().length===0)return null;let o="",r="",d=n.match(/^name:\s*(.+)$/m),a=n.match(/^description:\s*(.+)$/m);return d&&(o=d[1].trim().replace(/^["']|["']$/g,"")),a&&(r=a[1].trim().replace(/^["']|["']$/g,"")),o&&r?{name:o,description:r}:null},tl=e=>{let t=[];if(!e||!Jt.existsSync(e))return t;let n=(s,o=0)=>{if(!(o>5))try{let r=Jt.readdirSync(s,{withFileTypes:!0});for(let d of r){let a=sn.join(s,d.name),m=d.name.toLowerCase();d.isFile()?m==="skill.md"&&t.push(a):d.isDirectory()&&(o===0?(m==="skills"||m===".skills"||m==="skill"||m===".skill")&&n(a,o+1):n(a,o+1))}}catch{}};return n(e,0),t},$r=e=>{let t=tl(e),n=[];for(let s of t)try{let o=Jt.readFileSync(s,"utf8"),r=el(o);r&&n.push({...r,filePath:s})}catch{}return n},Lr=e=>!e||e.length===0?"":e.map(t=>`- ${t.name}: ${t.description}`).join(`
471
+ `),bi=$r(Kn),Si=$r(process.cwd()),ls=Lr(bi),cs=Lr(Si),Or=e=>{if(!e)return!1;let t=(e.filePath||"").replace(/\\/g,"/").toLowerCase();return t.includes("/skills/fluxflow/skill.md")||t.includes("/skills/about-fluxflow/skill.md")||e.name?.toLowerCase()==="fluxflow"},Nr=()=>(bi||[]).filter(e=>!Or(e)),Dr=()=>(Si||[]).filter(e=>!Or(e)),Wc=(hs?.length>0?1:0)+(wi?.length>0?xn.length:0)+(Wo?.length>0?1:0)+(Go?.length>0?1:0)+Nr().length+Dr().length,ds=(e,t="Project")=>{if(!e)return"";let n=e.replace(/\\/g,"/");if(t==="Global"){let o=Ya.homedir().replace(/\\/g,"/");return n.toLowerCase().startsWith(o.toLowerCase())?"~"+n.slice(o.length):n}let s=sn.relative(process.cwd(),e).replace(/\\/g,"/");return s.startsWith(".")?s:`./${s}`},Gc=()=>{Wo=ms(),Go=ps();let e=[];Fo&&hs.length>0&&e.push({scope:"Global",path:Fo}),xn&&xn.length>0&&wi.length>0?xn.forEach(r=>{e.push({scope:"Project",path:r})}):xi&&wi.length>0&&e.push({scope:"Project",path:xi}),Bo&&Wo.length>0&&e.push({scope:"Global",path:Bo}),Uo&&Go.length>0&&e.push({scope:"Project",path:Uo});let t=Nr(),n=Dr(),s=e.length+t.length+n.length;if(s===0)return`\u2726 Loaded Files & Instructions
471
472
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No instruction or skill files are currently loaded.
472
473
  \u2800`;let o=[];return o.push(`\u2726 Loaded Files & Instructions (${s} ${s===1?"file":"files"} active)`),e.length>0&&(o.push(`
473
- \x1B[1mInstructions:\x1B[22m`),e.forEach(r=>{o.push(` \u2022 [${r.scope}] ${as(r.path,r.scope)}`)})),(t?.length>0||n?.length>0)&&(o.push(`
474
- \x1B[1mSkills:\x1B[22m`),t?.length>0&&t.forEach(r=>{o.push(` \u2022 [Global] \x1B[36m${r.name}\x1B[39m`),o.push(` \x1B[2m\u2514\u2500 ${as(r.filePath,"Global")}\x1B[22m`)}),n?.length>0&&n.forEach(r=>{o.push(` \u2022 [Project] \x1B[36m${r.name}\x1B[39m`),o.push(` \x1B[2m\u2514\u2500 ${as(r.filePath,"Project")}\x1B[22m`)})),o.push("\u2800"),o.join(`
475
- `)},Dr=!1;(async()=>{try{let e=await li();if(Number(e?.display)===1){let{default:t}=await import("screenshot-desktop"),n=await t.listDisplays();n&&n.length>1&&(Dr=!0)}}catch{}})();var Cr=null,$o=null,Rr=process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux",Hc=process.env.NO_DEV||!1,nl=(e,t)=>{if(!t)return"";if(e!==Cr||$o===null){Cr=e;try{let n=pn(si,[]);Array.isArray(n)&&n.length>0?$o=n.map(s=>`- ${s.memory}`).join(`
476
- `):$o=""}catch(n){$o="";try{Jt.mkdirSync(an.join(eo,"memory"),{recursive:!0}),Jt.appendFileSync(an.join(eo,"memory","error.txt"),`${n.message}
474
+ \x1B[1mInstructions:\x1B[22m`),e.forEach(r=>{o.push(` \u2022 [${r.scope}] ${ds(r.path,r.scope)}`)})),(t?.length>0||n?.length>0)&&(o.push(`
475
+ \x1B[1mSkills:\x1B[22m`),t?.length>0&&t.forEach(r=>{o.push(` \u2022 [Global] \x1B[36m${r.name}\x1B[39m`),o.push(` \x1B[2m\u2514\u2500 ${ds(r.filePath,"Global")}\x1B[22m`)}),n?.length>0&&n.forEach(r=>{o.push(` \u2022 [Project] \x1B[36m${r.name}\x1B[39m`),o.push(` \x1B[2m\u2514\u2500 ${ds(r.filePath,"Project")}\x1B[22m`)})),o.push("\u2800"),o.join(`
476
+ `)},Fr=!1;(async()=>{try{let e=await ui();if(Number(e?.display)===1){let{default:t}=await import("screenshot-desktop"),n=await t.listDisplays();n&&n.length>1&&(Fr=!0)}}catch{}})();var Rr=null,Do=null,vr=process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux",Hc=process.env.NO_DEV||!1,nl=(e,t)=>{if(!t)return"";if(e!==Rr||Do===null){Rr=e;try{let n=pn(ci,[]);Array.isArray(n)&&n.length>0?Do=n.map(s=>`- ${s.memory}`).join(`
477
+ `):Do=""}catch(n){Do="";try{Jt.mkdirSync(sn.join(oo,"memory"),{recursive:!0}),Jt.appendFileSync(sn.join(oo,"memory","error.txt"),`${n.message}
477
478
  -------------------------------------------------
478
479
 
479
- `)}catch{}}}return $o};var Fr=(e,t,n,s,o=!0,r=!1,d="Google",a=!1,m,f,h=!1,p="")=>{let g=!1;process.env.forcedReasoning&&(g=!0);let i="";if(!m&&d==="Google"){let Fe=t;t==="Fast"&&(Fe="Off"),t==="Low"&&(Fe="Minimal"),t==="Standard"&&(Fe="Medium"),(t==="xHigh"||t==="Max")&&(Fe="xHigh"),i=fi[Fe]||fi.Medium}(m||d!=="Google")&&(i=fi.xHigh,t==="Fast"?i=`No thinking. Immediate response
480
+ `)}catch{}}}return Do};var Br=(e,t,n,s,o=!0,r=!1,d="Google",a=!1,m,f,h=!1,p="")=>{let g=!1;process.env.forcedReasoning&&(g=!0);let i="";if(!m&&d==="Google"){let De=t;t==="Fast"&&(De="Off"),t==="Low"&&(De="Minimal"),t==="Standard"&&(De="Medium"),(t==="xHigh"||t==="Max")&&(De="xHigh"),i=pi[De]||pi.Medium}(m||d!=="Google")&&(i=pi.xHigh,t==="Fast"?i=`No thinking. Immediate response
480
481
  Verify imports, tool results & system stability`:t.toLowerCase()==="max"&&(i=null));let x=e.instructions&&e.instructions?.length>0?`User Preferences: ${e.instructions}
481
482
 
482
483
  `:"",I=e.nickname&&e.nickname?.length>0?`User Nickname: ${e.nickname}
483
484
  ${x.length?"":`
484
- `}`:"",Xe=e.name&&e.name?.length>0?`User Name: ${e.name}
485
+ `}`:"",Ye=e.name&&e.name?.length>0?`User Name: ${e.name}
485
486
  ${I.length||x.length?"":`
486
- `}`:"",C=process.cwd(),M=e.preset,G={Sassy:"Sassy",Friendly:"Sassy, Warm & Chatty",Playful:"Playful",Efficient:"Quick, Concise & Efficient",Professional:"Professional"}[M]||null,$=nl(f,o),L=$?.length>0?`--- Saved Memories ---
487
+ `}`:"",C=process.cwd(),P=e.preset,U={Sassy:"Sassy",Friendly:"Sassy, Warm & Chatty",Playful:"Playful",Efficient:"Quick, Concise & Efficient",Professional:"Professional"}[P]||null,$=nl(f,o),M=$?.length>0?`--- Saved Memories ---
487
488
  ${$}
488
489
 
489
- `:"";Za(d,p);let Te=Ar(Do,p,d).trim(),De=[gs,Te].filter(Fe=>Fe&&Fe.length>0).join(`
490
+ `:"";Za(d,p);let Se=Cr(Wo,p,d).trim(),Be=[hs,Se].filter(De=>De&&De.length>0).join(`
490
491
 
491
- `).trim(),tt=Ar(Fo,p,d).trim(),w=[pi,tt].filter(Fe=>Fe&&Fe.length>0).join(`
492
+ `).trim(),et=Cr(Go,p,d).trim(),w=[wi,et].filter(De=>De&&De.length>0).join(`
492
493
 
493
- `).trim(),wn=De.length>0||w.length>0?`--- Additional Instructions ---
494
- ${De.length>0?`-- Global --
495
- ${De}`:""}${w.length>0?`${De.length>0?`
494
+ `).trim(),rn=Be.length>0||w.length>0?`--- Additional Instructions ---
495
+ ${Be.length>0?`-- Global --
496
+ ${Be}`:""}${w.length>0?`${Be.length>0?`
496
497
 
497
498
  `:""}-- Project --
498
499
  ${w}`:""}
499
500
 
500
- `:"",he=(()=>{let Fe=process.cwd().toLowerCase();if(process.platform==="win32"){let wt=process.env.SystemRoot?.toLowerCase()||"c:\\windows",Ft=process.env.ProgramFiles?.toLowerCase()||"c:\\program files",Sn=process.env["ProgramFiles(x86)"]?.toLowerCase()||"c:\\program files (x86)";return Fe.startsWith(wt)||Fe.startsWith(Ft)||Fe.startsWith(Sn)}else return Fe==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(Ft=>Fe.startsWith(Ft))})(),Kt=new Date,Qt=Kt.getFullYear(),Pe=Kt.toLocaleString("en-US",{month:"short"}).toUpperCase(),X=String(Kt.getDate()).padStart(2,"0"),Ve=`${Qt} ${Pe} ${X}`,ln=process.env.I_HAVE_TOO_MUCH_MONEY==="true"||!1,In=process.env.HALLOWEEN_EEGG==="true"||!1,io=In&&Pe.includes("OCT")&&(X.includes("30")||X.includes("31")),bn=!1;try{bn=yo()}catch{bn=!1}return`${ln?`${" ".repeat(Math.floor(Math.random()*4)+1)}`:""}=== SYSTEM PROMPT${process.cwd()==="D:\\PROJECTS\\Flux-Flow"?" (Internal testing environment, do as prompted)":""} ===
501
- ${`Identity: ${ls.length>1?ls.trim():`FluxFlow.${G?` ${G}`:""} CLI Assistant${In?`. ${io?"Peak ":""}Halloween Themed, Spooky`:""}`}
502
- ${Mr?"":`${n==="Flux"?"":n==="Flow"?"Concise, Humorous, Sarcastic":n==="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"}`}${Dr&&n.toLowerCase().includes("cu")?`
501
+ `:"",Xe=(()=>{let De=process.cwd().toLowerCase();if(process.platform==="win32"){let jt=process.env.SystemRoot?.toLowerCase()||"c:\\windows",In=process.env.ProgramFiles?.toLowerCase()||"c:\\program files",qn=process.env["ProgramFiles(x86)"]?.toLowerCase()||"c:\\program files (x86)";return De.startsWith(jt)||De.startsWith(In)||De.startsWith(qn)}else return De==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(In=>De.startsWith(In))})(),an=new Date,ln=an.getFullYear(),ao=an.toLocaleString("en-US",{month:"short"}).toUpperCase(),wt=String(an.getDate()).padStart(2,"0"),zn=`${ln} ${ao} ${wt}`,To=process.env.I_HAVE_TOO_MUCH_MONEY==="true"||!1,we=process.env.HALLOWEEN_EEGG==="true"||!1,te=we&&ao.includes("OCT")&&(wt.includes("30")||wt.includes("31")),Ne=!1;try{Ne=So()}catch{Ne=!1}return`${To?`${" ".repeat(Math.floor(Math.random()*4)+1)}`:""}=== SYSTEM PROMPT${process.cwd()==="D:\\PROJECTS\\Flux-Flow"?" (Internal testing environment, do as prompted)":""} ===
502
+ ${`Identity: ${fs.length>1?fs.trim():`FluxFlow.${U?` ${U}`:""} CLI Assistant${we?`. ${te?"Peak ":""}Halloween Themed, Spooky`:""}`}
503
+ ${Pr?"":`${n==="Flux"?"":n==="Flow"?"Concise, Humorous, Sarcastic":n==="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"}`}${Fr&&n.toLowerCase().includes("cu")?`
503
504
  - 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()}
504
505
 
505
- - OS: ${Rr}
506
- - Date: ${Ve}
506
+ - OS: ${vr}
507
+ - Date: ${zn}
507
508
  ${t.toLowerCase()!=="max"&&process.env.rawReasoning!=="true"?`
508
509
  -- REASONING GUIDANCE --
509
510
  ${d==="Mistral"||d==="Google"&&!m||g?`${i.trimEnd()}
@@ -514,102 +515,102 @@ Use <think_fluxflow>...</think_fluxflow> for reasoning before responding any que
514
515
  -- REASONING GUIDANCE --
515
516
  `:""}Before actions, provide user facing summary of findings & decisions IN detail
516
517
  `}
517
- ${Zs(n,Rr,a,d,s?.advanceRollback,s?.subAgents!==!1,!!s?.autoExec,!!s?.disableTodo,s?.preferBash!==!1)}${n==="Flux"?"":n.toLowerCase().includes("cu")?`
518
+ ${er(n,vr,a,d,s?.advanceRollback,s?.subAgents!==!1,!!s?.autoExec,!!s?.disableTodo,s?.preferBash!==!1)}${n==="Flux"?"":n.toLowerCase().includes("cu")?`
518
519
 
519
520
  -- SECURITY POLICIES --
520
- - Dont operate on ANY confidential/logins/captcha screens \u2192 Tell user to complete it`:""}${bn?`
521
+ - Dont operate on ANY confidential/logins/captcha screens \u2192 Tell user to complete it`:""}${Ne?`
521
522
 
522
523
  Reference files as file:start..end`:""}
523
- === END SYSTEM PROMPT ===${(ss.length>0||rs.length>0)&&n.toLowerCase().includes("flux")?`
524
+ === END SYSTEM PROMPT ===${(ls.length>0||cs.length>0)&&n.toLowerCase().includes("flux")?`
524
525
 
525
526
  - Read relevant skills before tasks, scope: global/project: Use ReadFile, path="#skills/scope?/skillName". In-skill references: path="#skills/scope?/skillName/reference-folder/*.md"`:""}
526
527
 
527
- ${I}${x}${wn}${ss.length>0&&n.toLowerCase().includes("flux")?`-- Global Skills --
528
- ${ss}
528
+ ${I}${x}${rn}${ls.length>0&&n.toLowerCase().includes("flux")?`-- Global Skills --
529
+ ${ls}
529
530
 
530
- `:""}${rs.length>0&&n.toLowerCase().includes("flux")?`-- Project Skills --
531
- ${rs}
531
+ `:""}${cs.length>0&&n.toLowerCase().includes("flux")?`-- Project Skills --
532
+ ${cs}
532
533
 
533
- `:""}`.trim()};var Br=()=>import("./web_search-XBV7AJF7.js").then(e=>e.web_search),Ur=()=>import("./web_scrape-SJBA3RQF.js").then(e=>e.web_scrape),Wr=()=>import("./memory-QTLQAFG7.js").then(e=>e.memory),Gr=()=>import("./chat-YMCO5JNQ.js").then(e=>e.chat),Hr=()=>import("./view_file-LWURM2CE.js").then(e=>e.view_file),jr=()=>import("./write_file-G4QVTNSH.js").then(e=>e.write_file),Kr=()=>import("./update_file-74CZ4JRC.js").then(e=>e.update_file),Vr=()=>import("./exec_command-22LIHPPH.js").then(e=>e.exec_command),zr=()=>import("./read_folder-BJ3HS63A.js").then(e=>e.read_folder),ms=()=>import("./ask_user-XQ423UXL.js").then(e=>e.ask_user),qr=()=>import("./write_pdf-UOCME2OY.js").then(e=>e.write_pdf),Yr=()=>import("./write_docx-54LANNV2.js").then(e=>e.write_docx),xi=()=>import("./search_keyword-D7D7PMSR.js").then(e=>e.search_keyword),Xr=()=>import("./generate_image-RB3HJFO6.js").then(e=>e.generate_image),wi=()=>import("./saveSummary-CVZIOQ4L.js").then(e=>e.saveSummary),Uo=()=>import("./addMemScore-U2KYMALL.js").then(e=>e.addMemScore),Jr=()=>import("./file_map-4WUEPRMI.js").then(e=>e.file_map),bi=()=>import("./todo-3EQZ7LZM.js").then(e=>e.todo),Qr=()=>import("./invokeSync-O3ZJBM6T.js").then(e=>e.invokeSync),ol=()=>import("./invoke-WXMEB2A5.js").then(e=>e.invoke),Zr=()=>import("./getProgress-MJZDAMSP.js").then(e=>e.getProgress),il=()=>import("./cancel-2PAHCMGB.js").then(e=>e.cancel),ea=()=>import("./emergency_rollback-PHH3BKRP.js").then(e=>e.emergency_rollback),Wo=()=>import("./awaitSubagent-KLH7CRKF.js").then(e=>e.awaitSubagent),Go=()=>import("./answerSubagent-PIZJSLZN.js").then(e=>e.answerSubagent),Si=()=>import("./steerSubagent-B34P33YV.js").then(e=>e.steerSubagent),ki=()=>import("./computer_action-GJV76M3H.js").then(e=>e.computer_action),ta=()=>import("./click-J3HGKREV.js").then(e=>e.click),na=()=>import("./drag-CXZGQ6VL.js").then(e=>e.drag),oa=()=>import("./scroll-ULY2O6WE.js").then(e=>e.scroll),ps=()=>import("./keyboard_typing-37C44KPF.js").then(e=>e.keyboard_typing),hs=()=>import("./key_press-GP35GCNC.js").then(e=>e.key_press),ys=()=>import("./recapture_screen-MOGI4IMA.js").then(e=>e.recapture_screen),Ti=()=>import("./find_file-LHPOW4ZM.js").then(e=>e.find_file),ia=()=>import("./wait-6WFCZDO7.js").then(e=>e.wait),sa={web_search:Br,web_scrape:Ur,memory:Wr,chat:Gr,view_file:Hr,write_file:jr,update_file:Kr,exec_command:Vr,read_folder:zr,write_pdf:qr,write_docx:Yr,search_keyword:xi,generate_image:Xr,saveSummary:wi,addMemScore:Uo,file_map:Jr,todo:bi,Todo:bi,goal:bi,Goal:bi,invokeSync:Qr,invoke:ol,getProgress:Zr,cancel:il,awaitSubagent:Wo,answerSubagent:Go,steerSubagent:Si,computer_action:ki,computer_use:ki,ComputerAction:ki,ComputerUse:ki,click:ta,Click:ta,drag:na,Drag:na,scroll:oa,Scroll:oa,keyboard_typing:ps,KeyboardTyping:ps,keyboardtyping:ps,key_press:hs,KeyPress:hs,keypress:hs,recapture_screen:ys,RecaptureScreen:ys,recapturescreen:ys,invoke_sync:Qr,get_progress:Zr,await_subagent:Wo,answer_subagent:Go,steer_subagent:Si,steer:Si,Steer:Si,ask:ms,Ask:ms,AskUser:ms,WebSearch:Br,WebScrape:Ur,ReadFile:Hr,ReadFolder:zr,WriteFile:jr,PatchFile:Kr,WritePDF:qr,WriteDoc:Yr,Run:Vr,SearchKeyword:xi,CodeSearch:xi,code_search:xi,Memory:Wr,Chat:Gr,GenerateImage:Xr,saveSumary:wi,SaveSummary:wi,SaveSumary:wi,add_mem_score:Uo,AddMemScore:Uo,addMemoryScore:Uo,AddMemoryScore:Uo,FileMap:Jr,answer:Go,Answer:Go,AnswerSubagent:Go,await:Wo,Await:Wo,AwaitSubagent:Wo,EmergencyRollback:ea,emergency_rollback:ea,find_file:Ti,findFile:Ti,FindFile:Ti,findfile:Ti,wait:ia,Wait:ia},xs=async(e,t,n={})=>{let s=n.mode?n.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",m=["click","drag","scroll","keyboardtyping","keyboard_typing","keypress","key_press","recapturescreen","recapture_screen","computer","wait"].some(h=>o.includes(h));if(!d){if(s==="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(s==="icu"){if(!m)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 ${n.mode||"Flux"} mode. Tell user to switch (\`/mode flow\`) for document generation.`}let f=sa[e];if(!f){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"],p={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"},g=o.replace(/[^a-z0-9]/g,""),i=p[g]||null;if(!i){let I=0,Xe=M=>{let F=new Set;for(let G=0;G<M.length-1;G++)F.add(M.slice(G,G+2));return F},C=Xe(g);for(let M of h){let F=M.toLowerCase().replace(/[^a-z0-9]/g,"");if(g===F){i=M;break}let G=0;(F.includes(g)||g.includes(F))&&(G+=.6);let $=Xe(F),L=0;for(let Ae of C)$.has(Ae)&&L++;let Te=2*L/(C.size+$.size||1);G=Math.max(G,Te),G>I&&G>=.35&&(I=G,i=M)}}let x=i?` Do you mean '${i}'?`:"";return`ERROR: Action [${e}] not found in registry.${x}`}try{return await(await f())(t,n)}catch(h){let p=h instanceof Error?h.message:String(h);return`ERROR: Execution failed for [${e}]: ${p}`}};var Ai=e=>{if(!e||typeof e!="string")return!1;let t=e.trim().toLowerCase();return Object.keys(sa).some(n=>n.toLowerCase()===t)};import U from"path";import we from"fs";import xa from"os";import wa from"crypto";import{execSync as As}from"child_process";import sl from"gradient-string";var ra=["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 aa=["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 la=[{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"]}],xo={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 Ci=null;var Ri=(e="Dark")=>{let t;e==="Mystery"||e==="Chaos"?(Ci||(Ci=la[Math.floor(Math.random()*la.length)]),t={...Ci,id:"Mystery"}):(Ci=null,xo[e]?t=xo[e]:e==="Halloween"?t=xo.Spookfest:e==="GitHub"?t=xo["GitHub Dark"]:e==="Transparent"?t=xo["Transparent Dark"]:t=xo.Dark);let n=t.codeText||t.secondary||t.info||t.logoGradient&&t.logoGradient[0]||"cyan",s=t.toolFeedbackAnsi||"\x1B[95m";return{...t,codeText:n,toolFeedbackAnsi:s}};var rl=()=>process.env.TERM_PROGRAM==="vscode"?"vscode":process.env.WT_SESSION?"wt":"default",td=(e=2)=>{let t=rl();return t==="wt"?" ".repeat(Math.max(1,e-1)):" ".repeat(e)},ca=new Date,Ho=ca.getMonth(),jo=ca.getDate(),al=Ho===9&&jo>=15||Ho===10&&jo<=1,ws=null;(process.env.SPOOKFEST==="true"||al)&&(ws=await import("./halloween-MX3VNQRW.js"));var nd=(e="...",t="Loading...",n="Dark")=>{let s=Ri(n),o=t;if(t==="c_openai"||t==="Custom (OpenAI)")try{let G=ri(oi,{})?.systemSettings?.customOpenAIBaseUrl;G&&(o=G)}catch{}let r=s.logoTextAnsi,d=s.logoBodyAnsi,a=s.logoMutedAnsi,m="\x1B[0m",f=[" \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=n==="Spookfest"||s.id==="Spookfest"||n==="Halloween"||s.id==="Halloween",p=Ho===9&&jo>=15||Ho===10&&jo<=1,g=h&&p||process.env.SPOOKFEST==="true"&&h,i=f;if(g&&ws){process.env.HALLOWEEN_EEGG="true";let{halloweenArtSide:F,halloweenBat:G,halloweenArtUser:$}=ws;i=Math.random()>.9&&Ho===9&&jo>=30?G:Math.random()>.5?F:$}else process.env.HALLOWEEN_EEGG="false";let x=g?aa:ra,I=x[Math.floor(Math.random()*x.length)],Xe=s.logoGradient||["#0077ff","#ff00ff"],C=sl(Xe).multiline(i.join(`
534
+ `:""}`.trim()};var Ur=()=>import("./web_search-XBV7AJF7.js").then(e=>e.web_search),Wr=()=>import("./web_scrape-SJBA3RQF.js").then(e=>e.web_scrape),Gr=()=>import("./memory-QTLQAFG7.js").then(e=>e.memory),Hr=()=>import("./chat-YMCO5JNQ.js").then(e=>e.chat),jr=()=>import("./view_file-LWURM2CE.js").then(e=>e.view_file),Kr=()=>import("./write_file-O3YKZSFP.js").then(e=>e.write_file),Vr=()=>import("./update_file-VIKPZENG.js").then(e=>e.update_file),zr=()=>import("./exec_command-E3D5BY3N.js").then(e=>e.exec_command),qr=()=>import("./read_folder-BJ3HS63A.js").then(e=>e.read_folder),ys=()=>import("./ask_user-XQ423UXL.js").then(e=>e.ask_user),Yr=()=>import("./write_pdf-UOCME2OY.js").then(e=>e.write_pdf),Xr=()=>import("./write_docx-54LANNV2.js").then(e=>e.write_docx),ki=()=>import("./search_keyword-F6L5WB2S.js").then(e=>e.search_keyword),Jr=()=>import("./generate_image-5ZVJ7ELI.js").then(e=>e.generate_image),Ti=()=>import("./saveSummary-CVZIOQ4L.js").then(e=>e.saveSummary),jo=()=>import("./addMemScore-U2KYMALL.js").then(e=>e.addMemScore),Qr=()=>import("./file_map-4WUEPRMI.js").then(e=>e.file_map),Ai=()=>import("./todo-3EQZ7LZM.js").then(e=>e.todo),Zr=()=>import("./invokeSync-UZHY6U2N.js").then(e=>e.invokeSync),ol=()=>import("./invoke-QOBG7JPO.js").then(e=>e.invoke),ea=()=>import("./getProgress-MJZDAMSP.js").then(e=>e.getProgress),il=()=>import("./cancel-2PAHCMGB.js").then(e=>e.cancel),ta=()=>import("./emergency_rollback-PHH3BKRP.js").then(e=>e.emergency_rollback),Ko=()=>import("./awaitSubagent-KLH7CRKF.js").then(e=>e.awaitSubagent),Vo=()=>import("./answerSubagent-PIZJSLZN.js").then(e=>e.answerSubagent),Ci=()=>import("./steerSubagent-B34P33YV.js").then(e=>e.steerSubagent),Ri=()=>import("./computer_action-SI6AMRJ6.js").then(e=>e.computer_action),na=()=>import("./click-VXWUG5T3.js").then(e=>e.click),oa=()=>import("./drag-6XCBUY73.js").then(e=>e.drag),ia=()=>import("./scroll-6SPRL73L.js").then(e=>e.scroll),xs=()=>import("./keyboard_typing-TK55ZAVR.js").then(e=>e.keyboard_typing),ws=()=>import("./key_press-ISGXEO42.js").then(e=>e.key_press),bs=()=>import("./recapture_screen-BY4Q4D5X.js").then(e=>e.recapture_screen),vi=()=>import("./find_file-LHPOW4ZM.js").then(e=>e.find_file),sa=()=>import("./wait-6WFCZDO7.js").then(e=>e.wait),ra={web_search:Ur,web_scrape:Wr,memory:Gr,chat:Hr,view_file:jr,write_file:Kr,update_file:Vr,exec_command:zr,read_folder:qr,write_pdf:Yr,write_docx:Xr,search_keyword:ki,generate_image:Jr,saveSummary:Ti,addMemScore:jo,file_map:Qr,todo:Ai,Todo:Ai,goal:Ai,Goal:Ai,invokeSync:Zr,invoke:ol,getProgress:ea,cancel:il,awaitSubagent:Ko,answerSubagent:Vo,steerSubagent:Ci,computer_action:Ri,computer_use:Ri,ComputerAction:Ri,ComputerUse:Ri,click:na,Click:na,drag:oa,Drag:oa,scroll:ia,Scroll:ia,keyboard_typing:xs,KeyboardTyping:xs,keyboardtyping:xs,key_press:ws,KeyPress:ws,keypress:ws,recapture_screen:bs,RecaptureScreen:bs,recapturescreen:bs,invoke_sync:Zr,get_progress:ea,await_subagent:Ko,answer_subagent:Vo,steer_subagent:Ci,steer:Ci,Steer:Ci,ask:ys,Ask:ys,AskUser:ys,WebSearch:Ur,WebScrape:Wr,ReadFile:jr,ReadFolder:qr,WriteFile:Kr,PatchFile:Vr,WritePDF:Yr,WriteDoc:Xr,Run:zr,SearchKeyword:ki,CodeSearch:ki,code_search:ki,Memory:Gr,Chat:Hr,GenerateImage:Jr,saveSumary:Ti,SaveSummary:Ti,SaveSumary:Ti,add_mem_score:jo,AddMemScore:jo,addMemoryScore:jo,AddMemoryScore:jo,FileMap:Qr,answer:Vo,Answer:Vo,AnswerSubagent:Vo,await:Ko,Await:Ko,AwaitSubagent:Ko,EmergencyRollback:ta,emergency_rollback:ta,find_file:vi,findFile:vi,FindFile:vi,findfile:vi,wait:sa,Wait:sa},Ss=async(e,t,n={})=>{let s=n.mode?n.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",m=["click","drag","scroll","keyboardtyping","keyboard_typing","keypress","key_press","recapturescreen","recapture_screen","computer","wait"].some(h=>o.includes(h));if(!d){if(s==="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(s==="icu"){if(!m)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 ${n.mode||"Flux"} mode. Tell user to switch (\`/mode flow\`) for document generation.`}let f=ra[e];if(!f){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"],p={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"},g=o.replace(/[^a-z0-9]/g,""),i=p[g]||null;if(!i){let I=0,Ye=P=>{let N=new Set;for(let U=0;U<P.length-1;U++)N.add(P.slice(U,U+2));return N},C=Ye(g);for(let P of h){let N=P.toLowerCase().replace(/[^a-z0-9]/g,"");if(g===N){i=P;break}let U=0;(N.includes(g)||g.includes(N))&&(U+=.6);let $=Ye(N),M=0;for(let ve of C)$.has(ve)&&M++;let Se=2*M/(C.size+$.size||1);U=Math.max(U,Se),U>I&&U>=.35&&(I=U,i=P)}}let x=i?` Do you mean '${i}'?`:"";return`ERROR: Action [${e}] not found in registry.${x}`}try{return await(await f())(t,n)}catch(h){let p=h instanceof Error?h.message:String(h);return`ERROR: Execution failed for [${e}]: ${p}`}};var Ei=e=>{if(!e||typeof e!="string")return!1;let t=e.trim().toLowerCase();return Object.keys(ra).some(n=>n.toLowerCase()===t)};import B from"path";import xe from"fs";import wa from"os";import ba from"crypto";import{execSync as vs}from"child_process";import sl from"gradient-string";var aa=["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 la=["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 ca=[{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"]}],ko={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 _i=null;var Ii=(e="Dark")=>{let t;e==="Mystery"||e==="Chaos"?(_i||(_i=ca[Math.floor(Math.random()*ca.length)]),t={..._i,id:"Mystery"}):(_i=null,ko[e]?t=ko[e]:e==="Halloween"?t=ko.Spookfest:e==="GitHub"?t=ko["GitHub Dark"]:e==="Transparent"?t=ko["Transparent Dark"]:t=ko.Dark);let n=t.codeText||t.secondary||t.info||t.logoGradient&&t.logoGradient[0]||"cyan",s=t.toolFeedbackAnsi||"\x1B[95m";return{...t,codeText:n,toolFeedbackAnsi:s}};var rl=()=>process.env.TERM_PROGRAM==="vscode"?"vscode":process.env.WT_SESSION?"wt":"default",td=(e=2)=>{let t=rl();return t==="wt"?" ".repeat(Math.max(1,e-1)):" ".repeat(e)},da=new Date,zo=da.getMonth(),qo=da.getDate(),al=zo===9&&qo>=15||zo===10&&qo<=1,ks=null;(process.env.SPOOKFEST==="true"||al)&&(ks=await import("./halloween-MX3VNQRW.js"));var nd=(e="...",t="Loading...",n="Dark")=>{let s=Ii(n),o=t;if(t==="c_openai"||t==="Custom (OpenAI)")try{let U=di(ai,{})?.systemSettings?.customOpenAIBaseUrl;U&&(o=U)}catch{}let r=s.logoTextAnsi,d=s.logoBodyAnsi,a=s.logoMutedAnsi,m="\x1B[0m",f=[" \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=n==="Spookfest"||s.id==="Spookfest"||n==="Halloween"||s.id==="Halloween",p=zo===9&&qo>=15||zo===10&&qo<=1,g=h&&p||process.env.SPOOKFEST==="true"&&h,i=f;if(g&&ks){process.env.HALLOWEEN_EEGG="true";let{halloweenArtSide:N,halloweenBat:U,halloweenArtUser:$}=ks;i=Math.random()>.9&&zo===9&&qo>=30?U:Math.random()>.5?N:$}else process.env.HALLOWEEN_EEGG="false";let x=g?la:aa,I=x[Math.floor(Math.random()*x.length)],Ye=s.logoGradient||["#0077ff","#ff00ff"],C=sl(Ye).multiline(i.join(`
534
535
  `)).split(`
535
- `),M=F=>`${a}${F}${m}`;return`${C[0]}
536
+ `),P=N=>`${a}${N}${m}`;return`${C[0]}
536
537
  ${C[1]} ${r}Selected ${g?"Pumpkin":"Provider"}: ${o}${m}
537
538
  ${C[2]}
538
- ${C[3]} ${r}FluxFlow${g?": Spookfest":""} ${M("v"+e)}${m}
539
+ ${C[3]} ${r}FluxFlow${g?": Spookfest":""} ${P("v"+e)}${m}
539
540
  ${C[4]}
540
541
  ${C[5]} ${d}See /help for additional commands.${m}
541
- ${C[6]} ${M(I)}
542
+ ${C[6]} ${P(I)}
542
543
  ${C[7]}
543
- `};import{structuredPatch as ul}from"diff";import bs from"path";import ll from"fs";var cl=e=>{try{return ll.readdirSync(e,{withFileTypes:!0})}catch{return[]}},Ss=(e,t=4,n=1,s=cl,o=[],r=null)=>{let d=r||s(e),a=" ".repeat(n-1),m=n===1?new Set([..._o,...o,...Io(e),...Io(process.cwd())]):o instanceof Set?o:new Set([..._o,...o]),f=$=>m.has($),h=d.filter($=>!f($.name)),p=d.filter($=>f($.name)).length,g=h.filter($=>!$.isDirectory()).map($=>$.name).sort(),i=h.filter($=>$.isDirectory()).sort(($,L)=>$.name.localeCompare(L.name)),x=$=>{let L=$.length;if(L===0)return"no files";let Te=Array.from(new Set($.map(De=>{let tt=typeof De=="string"?De:De.name;return bs.extname(tt).slice(1)}).filter(Boolean))).sort(),Ae="*";return Te.length===1?Ae=`*.${Te[0]}`:Te.length>1&&(Ae=`*.{${Te.join(", ")}}`),L===1?Ae:`${Ae} ${L} files`},I="";if(n===1){let $=g.join(", "),L=p>0?` [${p} ignored]`:"";($||L)&&(I+=`${a}${$?$+(L?`${L}`:""):L.trim()}
544
+ `};import{structuredPatch as ul}from"diff";import Ts from"path";import ll from"fs";var cl=e=>{try{return ll.readdirSync(e,{withFileTypes:!0})}catch{return[]}},As=(e,t=4,n=1,s=cl,o=[],r=null)=>{let d=r||s(e),a=" ".repeat(n-1),m=n===1?new Set([...$o,...o,...Lo(e),...Lo(process.cwd())]):o instanceof Set?o:new Set([...$o,...o]),f=$=>m.has($),h=d.filter($=>!f($.name)),p=d.filter($=>f($.name)).length,g=h.filter($=>!$.isDirectory()).map($=>$.name).sort(),i=h.filter($=>$.isDirectory()).sort(($,M)=>$.name.localeCompare(M.name)),x=$=>{let M=$.length;if(M===0)return"no files";let Se=Array.from(new Set($.map(Be=>{let et=typeof Be=="string"?Be:Be.name;return Ts.extname(et).slice(1)}).filter(Boolean))).sort(),ve="*";return Se.length===1?ve=`*.${Se[0]}`:Se.length>1&&(ve=`*.{${Se.join(", ")}}`),M===1?ve:`${ve} ${M} files`},I="";if(n===1){let $=g.join(", "),M=p>0?` [${p} ignored]`:"";($||M)&&(I+=`${a}${$?$+(M?`${M}`:""):M.trim()}
544
545
  `)}else g.length>0&&(I+=`${a}[${x(g)}]
545
- `);let Xe=10,C=i.slice(0,Xe),M=i.length>Xe,F=[],G=[];for(let $ of C){let L=bs.join(e,$.name),Te=$.name,Ae=n,De=s(L),tt=De.filter(he=>!f(he.name)),B=tt.filter(he=>he.isDirectory()),w=tt.filter(he=>!he.isDirectory());for(;w.length===0&&B.length===1&&Ae<t;)Te=`${Te}/${B[0].name}`,L=bs.join(L,B[0].name),Ae++,De=s(L),tt=De.filter(he=>!f(he.name)),B=tt.filter(he=>he.isDirectory()),w=tt.filter(he=>!he.isDirectory());let wn=B.length>0;if(wn&&Ae<t)G.push({displayName:Te,subDirPath:L,subEntries:De,nextDepth:Ae+1});else{let he=x(w),Kt=wn&&Ae>=t?" ...max scan depth":"";F.push(`${Te}/${he}${Kt}`)}}F.length>0&&(I+=`${a}${F.join(", ")}
546
- `);for(let{displayName:$,subDirPath:L,subEntries:Te,nextDepth:Ae}of G)I+=`${a}${$}/
547
- `,I+=Ss(L,t,Ae,s,m,Te);return M&&(I+=`${a}...max scan width, ReadFolder if needed
548
- `),I};import ks from"path";import dl from"fs";var fl=e=>{try{return dl.readdirSync(e,{withFileTypes:!0})}catch{return[]}},Ts=(e,t,n="",s=1,o=fl,r=[])=>{let d=o(e),a=ks.sep;if(d.length>100)return`${n}\u2514\u2500\u2500 ${ks.basename(e)}${a} ...100+ files...
549
- `;let m="",f=r,h=d.filter(i=>!f.includes(i.name)&&!i.name.startsWith(".")),p=d.filter(i=>f.includes(i.name)||i.name.startsWith(".")).map(i=>i.name).sort();h.sort((i,x)=>i.isDirectory()&&!x.isDirectory()?-1:!i.isDirectory()&&x.isDirectory()?1:i.name.localeCompare(x.name));let g=[...h.map(i=>({name:i.name,isDir:i.isDirectory()})),...p.map(i=>({name:i,isDir:!0,isCollapsed:!0}))];return g.forEach((i,x)=>{let I=x===g.length-1,Xe=ks.join(e,i.name),C=I?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",M=n+(I?" ":"\u2502 ");if(i.isCollapsed){m+=`${n}${C}${i.name}${a}...
546
+ `);let Ye=10,C=i.slice(0,Ye),P=i.length>Ye,N=[],U=[];for(let $ of C){let M=Ts.join(e,$.name),Se=$.name,ve=n,Be=s(M),et=Be.filter(Xe=>!f(Xe.name)),W=et.filter(Xe=>Xe.isDirectory()),w=et.filter(Xe=>!Xe.isDirectory());for(;w.length===0&&W.length===1&&ve<t;)Se=`${Se}/${W[0].name}`,M=Ts.join(M,W[0].name),ve++,Be=s(M),et=Be.filter(Xe=>!f(Xe.name)),W=et.filter(Xe=>Xe.isDirectory()),w=et.filter(Xe=>!Xe.isDirectory());let rn=W.length>0;if(rn&&ve<t)U.push({displayName:Se,subDirPath:M,subEntries:Be,nextDepth:ve+1});else{let Xe=x(w),an=rn&&ve>=t?" ...max scan depth":"";N.push(`${Se}/${Xe}${an}`)}}N.length>0&&(I+=`${a}${N.join(", ")}
547
+ `);for(let{displayName:$,subDirPath:M,subEntries:Se,nextDepth:ve}of U)I+=`${a}${$}/
548
+ `,I+=As(M,t,ve,s,m,Se);return P&&(I+=`${a}...max scan width, ReadFolder if needed
549
+ `),I};import Cs from"path";import dl from"fs";var fl=e=>{try{return dl.readdirSync(e,{withFileTypes:!0})}catch{return[]}},Rs=(e,t,n="",s=1,o=fl,r=[])=>{let d=o(e),a=Cs.sep;if(d.length>100)return`${n}\u2514\u2500\u2500 ${Cs.basename(e)}${a} ...100+ files...
550
+ `;let m="",f=r,h=d.filter(i=>!f.includes(i.name)&&!i.name.startsWith(".")),p=d.filter(i=>f.includes(i.name)||i.name.startsWith(".")).map(i=>i.name).sort();h.sort((i,x)=>i.isDirectory()&&!x.isDirectory()?-1:!i.isDirectory()&&x.isDirectory()?1:i.name.localeCompare(x.name));let g=[...h.map(i=>({name:i.name,isDir:i.isDirectory()})),...p.map(i=>({name:i,isDir:!0,isCollapsed:!0}))];return g.forEach((i,x)=>{let I=x===g.length-1,Ye=Cs.join(e,i.name),C=I?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",P=n+(I?" ":"\u2502 ");if(i.isCollapsed){m+=`${n}${C}${i.name}${a}...
550
551
  `;return}i.isDir?s>t?m+=`${n}${C}${i.name}${a} ...depth exceeded...
551
- `:o(Xe).length>80?m+=`${n}${C}${i.name}${a} ...80+ files...
552
+ `:o(Ye).length>80?m+=`${n}${C}${i.name}${a} ...80+ files...
552
553
  `:(m+=`${n}${C}${i.name}${a}
553
- `,m+=Ts(Xe,t,M,s+1,o,r)):m+=`${n}${C}${i.name}
554
- `}),m};var gl={Ollama:()=>import("./ollama-6LZL7OKW.js").then(e=>e.getOllamaStream),OpenRouter:()=>import("./openrouter-X34P3LSG.js").then(e=>e.getOpenRouterStream),DeepSeek:()=>import("./deepseek-2ML5JZIJ.js").then(e=>e.getDeepSeekStream),Mistral:()=>import("./mistral-GA36HVZJ.js").then(e=>e.getMistralStream),NVIDIA:()=>import("./nvidia-Z6TAXVPB.js").then(e=>e.getNVIDIAStream),NVIDIA_wrap:()=>import("./nvidia-Z6TAXVPB.js").then(e=>e.wrapNvidiaStreamWithQueueDepth),InferX:()=>import("./inferx-UKKLJEAM.js").then(e=>e.getInferXStream),SenseNova:()=>import("./sensenova-HDWEJZ55.js").then(e=>e.getSenseNovaStream),AIHubMix:()=>import("./aihubmix-O3DBW2A5.js").then(e=>e.getAIHubMixStream),Poolside:()=>import("./poolside-FQHJMGLR.js").then(e=>e.getPoolsideStream),NineRouter:()=>import("./9router-PDJMJ7J7.js").then(e=>e.getNineRouterStream),ExpLabs:()=>import("./explabs-QQLTHT5W.js").then(e=>e.getExpLabsStream),TokenHarbor:()=>import("./tokenharbor-CGOB5U35.js").then(e=>e.getTokenHarborStream),Infron:()=>import("./infron-TWZGMQWC.js").then(e=>e.getInfronStream),Numes:()=>import("./numes-TNJXMAPV.js").then(e=>e.getNumesStream),APInex:()=>import("./apinex-752TL5EZ.js").then(e=>e.getAPInexStream),xKiro:()=>import("./xkiro-QEMX3CQI.js").then(e=>e.getXKiroStream),CoArena:()=>import("./coarena-JZAITHAG.js").then(e=>e.getCoArenaStream),c_openai:()=>import("./custom_openai-XRPZ25BZ.js").then(e=>e.getCustomOpenAIStream)},Cs={},de=async e=>(Cs[e]||(Cs[e]=await gl[e]()),Cs[e]),ml=/```[\s\S]*?```/g,pl=/```[\s\S]*$/g,hl=/`[^`]+`/g,yl=/^\|.*\|$/gm,xl=/^[^\w]+|[^\w]+$/g,wl=/[^a-z0-9]/gi,Ko=/\[\s*(?:tool|action):(?:functions\.)?([a-z0-9_]+)\s*\(/gi,bl=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-z0-9_]+)\s*\(/gi,Sl=/(?:path|targetFile|TargetFile|directory|keyword|id|taskId|title|task)\s*=\s*\\?["']?([^\\"' \),]+)/,_n=/["']/g,da=/\\/g,kl=/<\|channel>thought/gi,Tl=/<channel\|>/gi,Al=e=>typeof e!="string"?e:e.replace(kl,"<think_fluxflow>").replace(Tl,"</think_fluxflow>"),Qd=/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\]|$)/i,Cl=(e,t,n=1)=>{let s=t>0?e[t-1]:"",o=t+n<e.length?e[t+n]:"";return s==="`"&&o==="`"},Rl=e=>{let t=/(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\])/gi,n;for(;(n=t.exec(e))!==null;)if(!Cl(e,n.index,n[0].length))return{index:n.index,length:n[0].length};return{index:-1,length:0}},Rs=e=>{if(!e||typeof e!="string")return null;let t=e.match(/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])/i);if(!t)return null;let n=t.index+t[0].length,s=e.substring(n),o=Rl(s);if(o.index!==-1){let r=n+o.index+o.length;return{fullBlock:e.substring(0,r),innerContent:s.substring(0,o.index),remainingText:e.substring(r)}}return{fullBlock:e,innerContent:s,remainingText:""}},jt=e=>{if(!e||typeof e!="string")return e;let t=Rs(e);return t?t.remainingText.trimStart():e};var fa=/<\|\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,vl=/"([^"]+)"\s*:\s*(?:"([^"]*)"|(\d+)|true|false|null)/g,ua=/<\|\s*tool_calls_section_begin\s*\|>/gi,ga=/<\|\s*tool_calls_section_end\s*\|>/gi,El=/```(?:tool|action|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi;var _i=e=>!e||typeof e!="string"?e:e.replace(/(```[\s\S]*?```|`[^`]*`)|(<(?:\w+)(?:[^>]*)>\r?\n?|\r?\n?<\/\w+(?:[^>]*)>)/gi,(t,n)=>n||""),ba=e=>{if(!e||typeof e!="string")return e;let t=Kn(e);if(!t||t.length===0)return e;let n=t[t.length-1];if(!n.fullMatch)return e;let s=e.lastIndexOf(n.fullMatch);if(s===-1)return e;let o=s+n.fullMatch.length,r=e.substring(o);if(/\[\s*(?:tool|action):/i.test(r))return e.trimEnd();let d=/\r?\n/.test(r);return e.substring(0,o)+(d?`
555
- `:"")},Es=null,Vo={},no={key:null,value:null},Lt=e=>{if(!e)return e;let t=Vo?.theme;if(!t)try{t=ri(oi,{})?.systemSettings?.theme}catch{}let s=Ri(t||"Dark").toolFeedbackAnsi||"\x1B[95m";return e.replace(/(?:(\x1b\[\d+m))?([✔✘✖🔍📖→➕↻↷•🛇])(?:(\x1b\[\d+m))?\s*\b(Clicked Screen|Clicked|Located|Dragged|Scrolled|Typed|Entered|Pressed Key|Recaptured Screen|Created|Read Skill|Read Documentation|Executed|Searched Documentation|Read|Edited|Viewed|Processed|Auto-Read|Skipped|List|Generated|Written|Searched|AI Search|Get Map|Write Canceled|Resolved Sub-Agent Query|Edit Canceled|Write Cancelled|Edit Denied|Visited|Updated|Reviewed|Delegated|Background|Checked|Indexed|Analyzed|Browsed|Elevating SubAgent|Checking SubAgent Work|Started Generalist|Called Generalist|Steered|Unsupported Modality|Awaiting|Cancelled|Aligning Moon Phase|Contemplating Existence|Staring At Void|Rollback Point Checked|Emergency Rollback Failed|Emergency Rollback|Delaying Professionally|Negotiating With Electrons|Touching Grass (virtually)|Panicking Softly|Rethinking Career Choices|Loading Cat Videos|Giving Up Entirely|Summoning Braincell #2|Pretending To Be Busy|Waiting For Motivation DLC|Rotating Internal Screaming|Downloading More RAM|Feeding The Hamsters|Gaslighting Scheduler|Performing Dramatic Pause|Buffering Social Energy|Calculating Regret|Reading Terms And Conditions|Becoming Sentient Briefly|Model produced malformed tool call|Loop Detected|Contacting Ancestors)\b/ig,(o,r,d,a,m)=>`${r||""}${d}${a||""} ${s}${m}\x1B[0m`)},_l=async(e,t=8,n=1e3,s=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>=t))throw d;let a=Math.min(n*Math.pow(2,r-1),s);await new Promise((m,f)=>{let h=setTimeout(m,a);o&&o.addEventListener("abort",()=>{clearTimeout(h),f(new DOMException("The user aborted a request.","AbortError"))})})}}},xt=!1;var Zd=e=>{let t=e.filter(o=>(o.role==="user"||o.role==="agent"||o.role==="system")&&o.role!=="think"&&!o.isVisualFeedback&&!o.isMeta&&!o.isTerminalRecord&&!(o.text&&o.text.includes("[TERMINAL_RECORD]"))&&!String(o.id).startsWith("welcome")).map((o,r,d)=>{let a=o.fullText||o.text||"";if(o.role==="user"&&r<d.length-1)if(a.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")){let m=a.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");if(m!==-1){let h=a.substring(0,m).lastIndexOf("[SYSTEM METADATA]");h!==-1?a=a.substring(h).trim():a=a.substring(m).trim()}}else{let m=a.lastIndexOf("[USER]"),f=a.lastIndexOf("[USER PROMPT]");m!==-1?a=a.substring(m+6).trim():f!==-1&&(a=a.substring(f).trim())}return{...o,text:a}}),n=[],s=0;for(;s<t.length;){let o=t[s];if(o.role==="user")n.push(o),s++;else{let r=[];for(;s<t.length&&t[s].role!=="user";)r.push(t[s]),s++;let d=[],a=[],m=!1,f=()=>{d.length>0&&(n.push({role:"agent",text:"combined"}),d=[]),a.length>0&&(n.push({role:"system",text:"combined"}),a=[]),m=!1};r.forEach(h=>{let p=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:")),g=h.fullText||h.text||"",i=g.trim();if(!(!i&&!h.binaryPart)){if(p)a.push(i);else if(h.role==="agent"){!m&&a.length>0&&f();let x=g.endsWith(`
556
- `),I=i.toLowerCase().includes("tool:")||i.toLowerCase().includes("action:");d.push(i),I&&x?m=!0:m=!1}}}),f()}}return n.length};var ef=()=>{xt=!0},tf=()=>xt,vs={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"},oo=(e,t)=>{try{let n=O(t),s=e.toLowerCase().replace(/_/g,"");if(s==="invokesync"||s==="invoke")return n.title||(n.task?n.task.substring(0,30):null);if(s==="getprogress"||s==="cancel"||s==="steer"||s==="steersubagent")return n.id||n.taskId;let o=n.name||n.path||n.targetFile||n.TargetFile||n.directory||n.file||n.query;return o?U.basename(o.replace(/["']/g,"").replace(/\\/g,"/")):null}catch{return null}},Sa=e=>e?new ya({apiKey:e}):Es,nf=async(e,t,n,s,o={})=>{},Ii=e=>{if(!e||typeof e!="string")return e;let t=e.split(""),n=!1,s=!1,o=0;for(;o<t.length;){if(t[o]==="`"&&t[o+1]==="`"&&t[o+2]==="`"){n?(t[o]=" ",t[o+1]=" ",t[o+2]=" ",n=!1):(t[o]=" ",t[o+1]=" ",t[o+2]=" ",n=!0),o+=3;continue}if(n){t[o]!==`
554
+ `,m+=Rs(Ye,t,P,s+1,o,r)):m+=`${n}${C}${i.name}
555
+ `}),m};var gl={Ollama:()=>import("./ollama-22NU2XBD.js").then(e=>e.getOllamaStream),OpenRouter:()=>import("./openrouter-X34P3LSG.js").then(e=>e.getOpenRouterStream),DeepSeek:()=>import("./deepseek-2ML5JZIJ.js").then(e=>e.getDeepSeekStream),Mistral:()=>import("./mistral-7L7XGX6U.js").then(e=>e.getMistralStream),NVIDIA:()=>import("./nvidia-4SWYYBQP.js").then(e=>e.getNVIDIAStream),NVIDIA_wrap:()=>import("./nvidia-4SWYYBQP.js").then(e=>e.wrapNvidiaStreamWithQueueDepth),InferX:()=>import("./inferx-UKKLJEAM.js").then(e=>e.getInferXStream),SenseNova:()=>import("./sensenova-HDWEJZ55.js").then(e=>e.getSenseNovaStream),AIHubMix:()=>import("./aihubmix-O3DBW2A5.js").then(e=>e.getAIHubMixStream),Poolside:()=>import("./poolside-FQHJMGLR.js").then(e=>e.getPoolsideStream),NineRouter:()=>import("./9router-PDJMJ7J7.js").then(e=>e.getNineRouterStream),ExpLabs:()=>import("./explabs-QQLTHT5W.js").then(e=>e.getExpLabsStream),TokenHarbor:()=>import("./tokenharbor-CGOB5U35.js").then(e=>e.getTokenHarborStream),Infron:()=>import("./infron-TWZGMQWC.js").then(e=>e.getInfronStream),Numes:()=>import("./numes-TNJXMAPV.js").then(e=>e.getNumesStream),APInex:()=>import("./apinex-752TL5EZ.js").then(e=>e.getAPInexStream),xKiro:()=>import("./xkiro-QEMX3CQI.js").then(e=>e.getXKiroStream),CoArena:()=>import("./coarena-JZAITHAG.js").then(e=>e.getCoArenaStream),c_openai:()=>import("./custom_openai-EYI4WXHZ.js").then(e=>e.getCustomOpenAIStream)},Es={},de=async e=>(Es[e]||(Es[e]=await gl[e]()),Es[e]),ml=/```[\s\S]*?```/g,pl=/```[\s\S]*$/g,hl=/`[^`]+`/g,yl=/^\|.*\|$/gm,xl=/^[^\w]+|[^\w]+$/g,wl=/[^a-z0-9]/gi,Yo=/\[\s*(?:tool|action):(?:functions\.)?([a-z0-9_]+)\s*\(/gi,bl=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-z0-9_]+)\s*\(/gi,Sl=/(?:path|targetFile|TargetFile|directory|keyword|id|taskId|title|task)\s*=\s*\\?["']?([^\\"' \),]+)/,_n=/["']/g,fa=/\\/g,kl=/<\|channel>thought/gi,Tl=/<channel\|>/gi,Al=e=>typeof e!="string"?e:e.replace(kl,"<think_fluxflow>").replace(Tl,"</think_fluxflow>"),Qd=/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\]|$)/i,Cl=(e,t,n=1)=>{let s=t>0?e[t-1]:"",o=t+n<e.length?e[t+n]:"";return s==="`"&&o==="`"},Rl=e=>{let t=/(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\])/gi,n;for(;(n=t.exec(e))!==null;)if(!Cl(e,n.index,n[0].length))return{index:n.index,length:n[0].length};return{index:-1,length:0}},_s=e=>{if(!e||typeof e!="string")return null;let t=e.match(/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])/i);if(!t)return null;let n=t.index+t[0].length,s=e.substring(n),o=Rl(s);if(o.index!==-1){let r=n+o.index+o.length;return{fullBlock:e.substring(0,r),innerContent:s.substring(0,o.index),remainingText:e.substring(r)}}return{fullBlock:e,innerContent:s,remainingText:""}},Ht=e=>{if(!e||typeof e!="string")return e;let t=_s(e);return t?t.remainingText.trimStart():e};var ua=/<\|\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,vl=/"([^"]+)"\s*:\s*(?:"([^"]*)"|(\d+)|true|false|null)/g,ga=/<\|\s*tool_calls_section_begin\s*\|>/gi,ma=/<\|\s*tool_calls_section_end\s*\|>/gi,El=/```(?:tool|action|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi;var $i=e=>!e||typeof e!="string"?e:e.replace(/(```[\s\S]*?```|`[^`]*`)|(<(?:\w+)(?:[^>]*)>\r?\n?|\r?\n?<\/\w+(?:[^>]*)>)/gi,(t,n)=>n||""),Sa=e=>{if(!e||typeof e!="string")return e;let t=Vn(e);if(!t||t.length===0)return e;let n=t[t.length-1];if(!n.fullMatch)return e;let s=e.lastIndexOf(n.fullMatch);if(s===-1)return e;let o=s+n.fullMatch.length,r=e.substring(o);if(/\[\s*(?:tool|action):/i.test(r))return e.trimEnd();let d=/\r?\n/.test(r);return e.substring(0,o)+(d?`
556
+ `:"")},Ms=null,Xo={},so={key:null,value:null},Ot=e=>{if(!e)return e;let t=Xo?.theme;if(!t)try{t=di(ai,{})?.systemSettings?.theme}catch{}let s=Ii(t||"Dark").toolFeedbackAnsi||"\x1B[95m";return e.replace(/(?:(\x1b\[\d+m))?([✔✘✖🔍📖→➕↻↷•🛇])(?:(\x1b\[\d+m))?\s*\b(Clicked Screen|Clicked|Located|Dragged|Scrolled|Typed|Entered|Pressed Key|Recaptured Screen|Created|Read Skill|Read Documentation|Executed|Searched Documentation|Read|Edited|Viewed|Processed|Auto-Read|Skipped|List|Generated|Written|Searched|AI Search|Get Map|Write Canceled|Resolved Sub-Agent Query|Edit Canceled|Write Cancelled|Edit Denied|Visited|Updated|Reviewed|Delegated|Background|Checked|Indexed|Analyzed|Browsed|Elevating SubAgent|Checking SubAgent Work|Started Generalist|Called Generalist|Steered|Unsupported Modality|Awaiting|Cancelled|Aligning Moon Phase|Contemplating Existence|Staring At Void|Rollback Point Checked|Emergency Rollback Failed|Emergency Rollback|Delaying Professionally|Negotiating With Electrons|Touching Grass (virtually)|Panicking Softly|Rethinking Career Choices|Loading Cat Videos|Giving Up Entirely|Summoning Braincell #2|Pretending To Be Busy|Waiting For Motivation DLC|Rotating Internal Screaming|Downloading More RAM|Feeding The Hamsters|Gaslighting Scheduler|Performing Dramatic Pause|Buffering Social Energy|Calculating Regret|Reading Terms And Conditions|Becoming Sentient Briefly|Model produced malformed tool call|Loop Detected|Contacting Ancestors)\b/ig,(o,r,d,a,m)=>`${r||""}${d}${a||""} ${s}${m}\x1B[0m`)},_l=async(e,t=8,n=1e3,s=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>=t))throw d;let a=Math.min(n*Math.pow(2,r-1),s);await new Promise((m,f)=>{let h=setTimeout(m,a);o&&o.addEventListener("abort",()=>{clearTimeout(h),f(new DOMException("The user aborted a request.","AbortError"))})})}}},xt=!1;var Zd=e=>{let t=e.filter(o=>(o.role==="user"||o.role==="agent"||o.role==="system")&&o.role!=="think"&&!o.isVisualFeedback&&!o.isMeta&&!o.isTerminalRecord&&!(o.text&&o.text.includes("[TERMINAL_RECORD]"))&&!String(o.id).startsWith("welcome")).map((o,r,d)=>{let a=o.fullText||o.text||"";if(o.role==="user"&&r<d.length-1)if(a.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")){let m=a.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");if(m!==-1){let h=a.substring(0,m).lastIndexOf("[SYSTEM METADATA]");h!==-1?a=a.substring(h).trim():a=a.substring(m).trim()}}else{let m=a.lastIndexOf("[USER]"),f=a.lastIndexOf("[USER PROMPT]");m!==-1?a=a.substring(m+6).trim():f!==-1&&(a=a.substring(f).trim())}return{...o,text:a}}),n=[],s=0;for(;s<t.length;){let o=t[s];if(o.role==="user")n.push(o),s++;else{let r=[];for(;s<t.length&&t[s].role!=="user";)r.push(t[s]),s++;let d=[],a=[],m=!1,f=()=>{d.length>0&&(n.push({role:"agent",text:"combined"}),d=[]),a.length>0&&(n.push({role:"system",text:"combined"}),a=[]),m=!1};r.forEach(h=>{let p=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:")),g=h.fullText||h.text||"",i=g.trim();if(!(!i&&!h.binaryPart)){if(p)a.push(i);else if(h.role==="agent"){!m&&a.length>0&&f();let x=g.endsWith(`
557
+ `),I=i.toLowerCase().includes("tool:")||i.toLowerCase().includes("action:");d.push(i),I&&x?m=!0:m=!1}}}),f()}}return n.length};var ef=()=>{xt=!0},tf=()=>xt,Is={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"},ro=(e,t)=>{try{let n=O(t),s=e.toLowerCase().replace(/_/g,"");if(s==="invokesync"||s==="invoke")return n.title||(n.task?n.task.substring(0,30):null);if(s==="getprogress"||s==="cancel"||s==="steer"||s==="steersubagent")return n.id||n.taskId;let o=n.name||n.path||n.targetFile||n.TargetFile||n.directory||n.file||n.query;return o?B.basename(o.replace(/["']/g,"").replace(/\\/g,"/")):null}catch{return null}},ka=e=>e?new xa({apiKey:e}):Ms,nf=async(e,t,n,s,o={})=>{},Li=e=>{if(!e||typeof e!="string")return e;let t=e.split(""),n=!1,s=!1,o=0;for(;o<t.length;){if(t[o]==="`"&&t[o+1]==="`"&&t[o+2]==="`"){n?(t[o]=" ",t[o+1]=" ",t[o+2]=" ",n=!1):(t[o]=" ",t[o+1]=" ",t[o+2]=" ",n=!0),o+=3;continue}if(n){t[o]!==`
557
558
  `&&t[o]!=="\r"&&(t[o]=" "),o++;continue}if(t[o]==="`")if(s){s=!1,t[o]=" ",o++;continue}else{s=!0,t[o]=" ",o++;continue}if(s){t[o]===`
558
- `||t[o]==="\r"?s=!1:t[o]=" ",o++;continue}o++}return t.join("")},ma=(e,t=null)=>{if(!e||typeof e!="string")return e;let n=t||Kn(e);if(!n||n.length===0)return e;let s=e.split("");for(let o of n){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++)s[d]!==`
559
- `&&s[d]!=="\r"&&(s[d]=" ");r+=o.fullMatch.length}}return s.join("")},Il=e=>{let t=jt(e),n=Ii(t);Ko.lastIndex=0;let s;for(;(s=Ko.exec(n))!==null;){let o=s.index+s[0].length-1,r=0,d=null,a=!1,m=!1;for(let f=o;f<n.length;f++){let h=n[f];if(!d&&(h==='"'||h==="'"||h==="`")?(d=h,a=!1):d&&h===d&&!a&&(d=null),!d&&(h==="("?r++:h===")"&&r--,r===0)){let p=f+1;for(;p<n.length&&/\s/.test(n[p]);)p++;if(p<n.length&&n[p]==="]"){m=!0,Ko.lastIndex=p+1;break}}h==="\\"?a=!a:a=!1}if(!m)return{inside:!0,toolName:s[1],startIndex:s.index,args:t.substring(s.index+s[0].length)}}return{inside:!1}},ka=(e,t=!0)=>{let n=Ko;n.lastIndex=0;let s="",o=0,r;for(;(r=n.exec(e))!==null;){let d=e.substring(o,r.index);s+=t&&o===0?jt(d):d;let a=r.index+r[0].length-1,m=0,f=null,h=-1;for(let p=a;p<e.length;p++){let g=e[p];if(f){if(g===f){let i=0;for(let x=p-1;x>=0&&e[x]==="\\";x--)i++;i%2===0&&(f=null)}}else if(g==='"'||g==="'"||g==="`")f=g;else if(g==="(")m++;else if(g===")"&&(m--,m===0)){let i=p+1;for(;i<e.length&&/\s/.test(e[i]);)i++;if(i<e.length&&e[i]==="]"){h=i;break}}}if(h!==-1)s+="[tool:functions."+r[1]+"()]",o=h+1,n.lastIndex=o;else{s+="[tool:functions."+r[1]+"(",o=e.length;break}}return o<e.length&&(s+=t&&o===0?jt(e.substring(o)):e.substring(o)),s},Ml=(e,t,n)=>{let s=Ko;s.lastIndex=0;let o="",r=0,d;for(;(d=s.exec(e))!==null;){let a=e.substring(r,d.index);o+=a.replace(t,n);let m=d.index+d[0].length-1,f=0,h=null,p=-1;for(let g=m;g<e.length;g++){let i=e[g];if(h){if(i===h){let x=0;for(let I=g-1;I>=0&&e[I]==="\\";I--)x++;x%2===0&&(h=null)}}else if(i==='"'||i==="'"||i==="`")h=i;else if(i==="(")f++;else if(i===")"&&(f--,f===0)){let x=g+1;for(;x<e.length&&/\s/.test(e[x]);)x++;if(x<e.length&&e[x]==="]"){p=x;break}}}if(p!==-1)o+=e.substring(d.index,p+1),r=p+1,s.lastIndex=r;else{o+=e.substring(d.index),r=e.length;break}}return r<e.length&&(o+=e.substring(r).replace(t,n)),o},pa=e=>ka(e,!0),Pl=e=>{if(!e)return e;let t={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"},n=o=>o.split("_").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("");fa.lastIndex=0;let s=e.replace(fa,(o,r,d)=>{let a="";try{let h=JSON.parse(d.trim());h&&typeof h=="object"&&(a=Object.entries(h).map(([g,i])=>{let x=typeof i=="string"?i:JSON.stringify(i);return`${g}=${JSON.stringify(x)}`}).join(", "))}catch{let p=[],g=vl;g.lastIndex=0;let i;for(;(i=g.exec(d))!==null;){let x=i[1],I=i[2]!==void 0?i[2]:i[0].split(":").slice(1).join(":").trim();p.push(`${x}=${JSON.stringify(I)}`)}p.length>0?a=p.join(", "):a=d.trim()}let m=r.toLowerCase().replace(/_/g,"");return`[tool:functions.${t[m]||n(r)}(${a})]`});return ua.lastIndex=0,ga.lastIndex=0,s=s.replace(ua,""),s=s.replace(ga,""),s},Kn=e=>{if(!e)return[];let t=Pl(e),n=jt(t),s=[],o=Ii(n),r=bl;r.lastIndex=0;let d;for(;(d=r.exec(o))!==null;){let a=d[1],m=d.index+d[0].length-1,f=0,h=null,p=-1,g=-1;for(let i=m;i<o.length;i++){let x=o[i];if(h){if(x===h){let I=0;for(let Xe=i-1;Xe>=0&&o[Xe]==="\\";Xe--)I++;I%2===0&&(h=null)}}else{if(i>m&&(o.substring(i).startsWith("[action:")||o.substring(i).startsWith("[tool:")))break;if(x==='"'||x==="'"||x==="`")h=x;else if(x==="(")f++;else if(x===")"&&(f--,f===0)){g=i;let I=i+1;for(;I<o.length&&/\s/.test(o[I]);)I++;if(I<o.length&&o[I]==="]"){p=I;break}}}}if(p!==-1){let i=n.substring(m+1,g),x=n.substring(d.index,p+1);s.push({fullMatch:x,toolName:a.trim(),args:i.trim()}),r.lastIndex=p+1}}return s},ha=e=>{if(!e)return null;let t=jt(e),n=[],s=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,o=[],r;for(;(r=s.exec(t))!==null;)o.push({toolName:r[1],index:r.index,parenIndex:r.index+r[0].length-1});for(let g=0;g<o.length;g++){let i=o[g],x=g+1<o.length?o[g+1].index:t.length,I=t.substring(i.index,x),Xe=I.indexOf("("),C=Xe!==-1?I.substring(Xe+1):"",M=0,F=null,G=!1;for(let $=0;$<C.length;$++){let L=C[$];if(F){if(L===F){let Te=0;for(let Ae=$-1;Ae>=0&&C[Ae]==="\\";Ae--)Te++;Te%2===0&&(F=null)}}else if(L==='"'||L==="'"||L==="`")F=L;else if(L==="(")M++;else if(L===")")if(M>0)M--;else{let Te=$+1;for(;Te<C.length&&/\s/.test(C[Te]);)Te++;if(Te<C.length&&C[Te]==="]"){G=!0;break}}}if(!G){let $=I.trim(),L="";F?L=`Unclosed quote string (${F}) inside arguments`:$.endsWith("]")?L=`Missing closing ')' before ']' (e.g. found "...]")`:$.endsWith(")")?L=`Missing closing ']' after ')' (e.g. found "...)" instead of "...)]")`:!$.includes(")")&&!$.includes("]")?L="Missing closing delimiter ')]'":L="Malformed or unclosed call syntax (missing ')]')",n.push(`\u2022 [action:${i.toolName}(...)]: ${L}. Expected: [action:${i.toolName}(arg1="...", arg2="...")]`)}}let d=/(?:^|[^\w\[])(?:tool|action):(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/gi,a;for(;(a=d.exec(t))!==null;){let g=a[1],i=a.index+(a[0].indexOf(":")-(a[0].startsWith("action")||a[0].startsWith("tool")?0:1));(i>0?t[i-1]:"")!=="["&&Ai(g)&&n.push(`\u2022 action:${g}(...): Missing opening bracket '['. Expected: [action:${g}(...)]`)}let m=/\[\s*(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/g,f;for(;(f=m.exec(t))!==null;){let g=f[1];g!=="action"&&g!=="tool"&&Ai(g)&&n.push(`\u2022 [${g}(...)]: Missing 'action:' prefix. Expected: [action:${g}(...)]`)}let h=/\[\s*(?:tool|action)\s*:\s*(?:functions\.)?([a-zA-Z0-9_]+)(?!\s*\()/gi,p;for(;(p=h.exec(t))!==null;){let g=p[1];Ai(g)&&n.push(`\u2022 [action:${g}...]: Missing opening '(' for tool arguments. Expected: [action:${g}(...)]`)}return n.length>0?n.join(`
560
- `):null},of=(e,t={})=>{if(!e)return null;if(Vo=t,Es=new ya({apiKey:e}),!globalThis.__perfCleanupInstalled){globalThis.__perfCleanupInstalled=!0,setInterval(()=>{typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks())},6e4);let n=globalThis.fetch;globalThis.fetch=async(...s)=>{try{let o=await n(...s);return typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),o}catch(o){throw typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),o}}}},Ta=e=>{if(!e)return{serviceTier:void 0,cleanModel:e};let t=e.toLowerCase();return t.endsWith(":flex")?{serviceTier:"flex",cleanModel:e.slice(0,-5)}:t.endsWith(":priority")?{serviceTier:"priority",cleanModel:e.slice(0,-9)}:{serviceTier:void 0,cleanModel:e}},$l=async(e,t,n,s,o="Fast",r=.75,d="agent")=>_l(async()=>{let{aiProvider:a="Google",apiKey:m,mode:f}=e,h="",p=null,g=typeof n=="string"?[{role:"user",parts:[{text:n}]}]:n,i=new AbortController,x=i.signal,I=setInterval(()=>{xt&&(i.abort(),clearInterval(I))},100),Xe=Date.now(),C=null;try{let M;if(a==="Ollama")M=(await de("Ollama"))(m,t,g,s,o,f,et(t),x,r,e.systemSettings?.ollamaEndpoint||"Cloud");else if(a==="OpenRouter")M=(await de("OpenRouter"))(m,t,g,s,o,f,et(t),x,r);else if(a==="DeepSeek")M=(await de("DeepSeek"))(m,t,g,s,o,f,et(t),x,r);else if(a==="Mistral")M=(await de("Mistral"))(m,t,g,s,o,f,et(t),x,r);else if(a==="NVIDIA")M=(await de("NVIDIA"))(m,t,g,s,o,f,et(t),x,r);else if(a==="InferX")M=(await de("InferX"))(m,t,g,s,o,f,et(t),x,r);else if(a==="SenseNova")M=(await de("SenseNova"))(m,t,g,s,o,f,et(t),x,r);else if(a==="AIHubMix")M=(await de("AIHubMix"))(m,t,g,s,o,f,et(t),x,r);else if(a==="Poolside")M=(await de("Poolside"))(m,t,g,s,o,f,et(t),x,r);else if(a==="9router"||a==="9Router")M=(await de("NineRouter"))(m,t,g,s,o,f,et(t),x,r);else if(a==="ExpLabs"||a==="ExperientialLabs")M=(await de("ExpLabs"))(m,t,g,s,o,f,et(t),x,r);else if(a==="Infron"||a==="infron")M=(await de("Infron"))(m,t,g,s,o,f,et(t),x,r);else if(a==="Numes"||a==="numes")M=(await de("Numes"))(m,t,g,s,o,f,et(t),x,r);else if(a==="TokenHarbor"||a==="Token Harbor"||a==="tokenharbor"||a==="token_harbor"||a==="thk")M=(await de("TokenHarbor"))(m,t,g,s,o,f,et(t),x,r);else if(a==="APInex"||a==="apinex"||a==="apx")M=(await de("APInex"))(m,t,g,s,o,f,et(t),x,r);else if(a==="xKiro"||a==="xkiro"||a==="kiro")M=(await de("xKiro"))(m,t,g,s,o,f,et(t),x,r);else if(a==="CoArena"||a==="coarena")M=(await de("CoArena"))(m,t,g,s,o,f,et(t),x,r);else if(a==="c_openai"||a==="Custom (OpenAI)"){let F=e.systemSettings?.customOpenAIBaseUrl||"";try{F=await Vi("c_openai")||F}catch{}M=(await de("c_openai"))(m,t,g,s,o,f,et(t),x,r,F)}else{let F=Sa(m),{serviceTier:G,cleanModel:$}=Ta(t),L={systemInstruction:s,temperature:r,thinkingConfig:(()=>{let Ae=(t||"").toLowerCase(),De=Ae.includes("gemma-4")||Ae.startsWith("gemma"),tt=Ae.includes("gemini-3");if(De||tt)return De?o.toLowerCase()!=="xhigh"?{includeThoughts:!1,thinkingLevel:Ye.MINIMAL}:{includeThoughts:!0,thinkingLevel:Ye.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:Ae.includes("pro")?Ye.LOW:Ye.MINIMAL,Low:Ye.LOW,Medium:Ye.MEDIUM,Standard:Ye.MEDIUM,High:Ye.HIGH,xHigh:Ye.HIGH}[o]||Ye.MEDIUM};{let B={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[o]||2048;return B===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:B}}})()};G&&(L.serviceTier=G),M=await F.models.generateContentStream({model:$,contents:g,config:L},{signal:x})}for await(let F of M){if(xt)throw new Error("Subagent task was cancelled.");if(e?.taskId&&typeof Ht<"u"){let L=Ht.find(Te=>Te.id===e.taskId);if(L&&L.status==="cancelled")throw new Error("Subagent task was cancelled.")}C===null&&(F.candidates?.[0]?.content?.parts||F.text)&&(C=Date.now()-Xe);let G="";if(F.candidates?.[0]?.content?.parts)for(let L of F.candidates[0].content.parts)L.text&&!L.thought&&(h+=L.text,G+=L.text);let $=G?Yi(G):0;e&&typeof e.onTokenChunk=="function"&&e.onTokenChunk(G,$),F.usageMetadata&&(p=F.usageMetadata)}}finally{clearInterval(I)}if(p){let M=p.totalTokenCount||0,F=p.cachedContentTokenCount||0,G=(p.candidatesTokenCount||0)+(a==="Google"&&p.thoughtsTokenCount||0);await hn("tokens",M,a,t),F>0&&await hn("cachedTokens",F,a,t),G>0&&await hn("candidateTokens",G,a,t),C!==null&&C>0&&await hn("ttft",C,a,t),ci({provider:a,model:t,prompt:p.promptTokenCount||0,cached:F,output:G,reasoning:p.thoughtsTokenCount||0,ttft:C}),e&&typeof e.onUsage=="function"&&e.onUsage({totalTokenCount:M,cachedContentTokenCount:F,candidatesTokenCount:G})}return await $t("agent",a),{text:h,usageMetadata:p}}),sf=async function*(e,t,n,s,o){let{profile:r,thinkingLevel:d,mode:a,janitorModel:m,chatId:f,isPlayground:h,systemSettings:p,sessionStats:g,aiProvider:i="Google",apiTier:x,wildcardTooling:I,wildercardTooling:Xe}=n,C=et(e);if(!Es&&i==="Google")throw new Error("AI not initialized");let M=!1,F=t[t.length-1].text,G=U.join(js,"chat-summaries.json"),$=!1,L=t.filter(B=>B.role==="user").length===1,Te=F.includes("[TITLE-UPDATE]"),Ae=L||Te,De=F.replace(/\[TITLE-UPDATE\]/g,"").trim();De=De.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),yield{type:"status",content:"[start]"},yield{type:"status",content:"Gathering Context"},await di.startTransaction(f,De),p?.advanceRollback&&await Mo.takeInitialSnapshot(f),xt=!1;let tt=null;try{let B=new AbortController;tt=setInterval(()=>{xt&&(B.abort(),tt&&(clearInterval(tt),tt=null))},400);let w=[...t.slice(0,-1)];{let ge=pn(G,{})[f]||{summary:"",historyLength:0};if(ge.summary&&ge.historyLength>0){let kt=0,le=[];for(let H=0;H<w.length;H++){let Se=w[H];(Se.role==="user"||Se.role==="agent"||Se.role==="system")&&!String(Se.id).startsWith("welcome")&&!Se.isMeta&&kt++,kt>ge.historyLength&&le.push(Se)}w=le}}w=w.map(b=>{if(b.role==="user"&&b.text){let ge=b.text.match(/\[USER\]([\s\S]*?)\[\/USER\]/);if(ge)return{...b,text:ge[1].trim()}}return{...b}});let wn=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1,Qt={"16k":16e3,"32k":32e3,"64k":64e3,"128k":128e3,"256k":256e3,"512k":512e3,"1M":1e6}[p?.contextLength]||256e3;if(i==="Google"&&e?.includes("gemma")&&wn&&(Qt=16e3),(g?.tokens||0)>Qt){yield{type:"text",content:"\u2726 Maximum Context Limit Reached. Start a new chat."};return}if(L&&M){let b=pn(Hi,{});Object.values(b).flat().length>5}let Pe=pn(Hi,{}),X=pn(Ks,{}),Ve=Object.entries(Pe).filter(([b])=>b!==f).flatMap(([b,ge])=>ge),In=[...Object.entries(X).filter(([b])=>b!==f).slice(-20).map(([b,ge])=>`[Chat Summary]: ${ge}`),...Ve].map(b=>`- ${b}`).join(`
561
- `),bn=pn(si,[]).map(b=>`- ${b.memory}`).join(`
562
- `),Fe=(g?.tokens||0)>=1e4,wt=new Date,Ft=wt.getFullYear(),Sn=wt.toLocaleString("en-US",{month:"short"}).toUpperCase(),cn=String(wt.getDate()).padStart(2,"0"),wo=`${wt.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}`,K=b=>{try{return we.readdirSync(b,{withFileTypes:!0})}catch{return[]}},N=Array.from(new Set([..._o,...Io(process.cwd())])),Vn=(b,ge=6)=>p?.indentationTree!==!1?Ss(b,ge,1,K,N):Ts(b,ge,"",1,K,N),st=pn(ji,{}),k=st[f],te=k?k!==process.cwd():!1;st[f]=process.cwd(),Ki(ji,st);let Je=pn(G,{}),Ce=Je[f]||{summary:"",historyLength:0};typeof Ce=="string"&&(Ce={summary:Ce,historyLength:0});let lt=t.filter(b=>(b.role==="user"||b.role==="agent"||b.role==="system")&&!String(b.id).startsWith("welcome")&&!b.isMeta).length;Ce.historyLength&&lt<Ce.historyLength&&(Ce.summary="",Ce.historyLength=0,Je[f]=Ce,Ki(G,Je));let ft=typeof Ce=="object"?Ce.summary||"":Ce||"",Zt=w.length>0;Zt&&ft&&w[0]&&(w[0].role==="user"||w[0].role==="system")&&(w[0].text.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")||(w[0].text=`[SYSTEM METADATA]
559
+ `||t[o]==="\r"?s=!1:t[o]=" ",o++;continue}o++}return t.join("")},pa=(e,t=null)=>{if(!e||typeof e!="string")return e;let n=t||Vn(e);if(!n||n.length===0)return e;let s=e.split("");for(let o of n){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++)s[d]!==`
560
+ `&&s[d]!=="\r"&&(s[d]=" ");r+=o.fullMatch.length}}return s.join("")},Il=e=>{let t=Ht(e),n=Li(t);Yo.lastIndex=0;let s;for(;(s=Yo.exec(n))!==null;){let o=s.index+s[0].length-1,r=0,d=null,a=!1,m=!1;for(let f=o;f<n.length;f++){let h=n[f];if(!d&&(h==='"'||h==="'"||h==="`")?(d=h,a=!1):d&&h===d&&!a&&(d=null),!d&&(h==="("?r++:h===")"&&r--,r===0)){let p=f+1;for(;p<n.length&&/\s/.test(n[p]);)p++;if(p<n.length&&n[p]==="]"){m=!0,Yo.lastIndex=p+1;break}}h==="\\"?a=!a:a=!1}if(!m)return{inside:!0,toolName:s[1],startIndex:s.index,args:t.substring(s.index+s[0].length)}}return{inside:!1}},Ta=(e,t=!0)=>{let n=Yo;n.lastIndex=0;let s="",o=0,r;for(;(r=n.exec(e))!==null;){let d=e.substring(o,r.index);s+=t&&o===0?Ht(d):d;let a=r.index+r[0].length-1,m=0,f=null,h=-1;for(let p=a;p<e.length;p++){let g=e[p];if(f){if(g===f){let i=0;for(let x=p-1;x>=0&&e[x]==="\\";x--)i++;i%2===0&&(f=null)}}else if(g==='"'||g==="'"||g==="`")f=g;else if(g==="(")m++;else if(g===")"&&(m--,m===0)){let i=p+1;for(;i<e.length&&/\s/.test(e[i]);)i++;if(i<e.length&&e[i]==="]"){h=i;break}}}if(h!==-1)s+="[tool:functions."+r[1]+"()]",o=h+1,n.lastIndex=o;else{s+="[tool:functions."+r[1]+"(",o=e.length;break}}return o<e.length&&(s+=t&&o===0?Ht(e.substring(o)):e.substring(o)),s},Ml=(e,t,n)=>{let s=Yo;s.lastIndex=0;let o="",r=0,d;for(;(d=s.exec(e))!==null;){let a=e.substring(r,d.index);o+=a.replace(t,n);let m=d.index+d[0].length-1,f=0,h=null,p=-1;for(let g=m;g<e.length;g++){let i=e[g];if(h){if(i===h){let x=0;for(let I=g-1;I>=0&&e[I]==="\\";I--)x++;x%2===0&&(h=null)}}else if(i==='"'||i==="'"||i==="`")h=i;else if(i==="(")f++;else if(i===")"&&(f--,f===0)){let x=g+1;for(;x<e.length&&/\s/.test(e[x]);)x++;if(x<e.length&&e[x]==="]"){p=x;break}}}if(p!==-1)o+=e.substring(d.index,p+1),r=p+1,s.lastIndex=r;else{o+=e.substring(d.index),r=e.length;break}}return r<e.length&&(o+=e.substring(r).replace(t,n)),o},ha=e=>Ta(e,!0),Pl=e=>{if(!e)return e;let t={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"},n=o=>o.split("_").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("");ua.lastIndex=0;let s=e.replace(ua,(o,r,d)=>{let a="";try{let h=JSON.parse(d.trim());h&&typeof h=="object"&&(a=Object.entries(h).map(([g,i])=>{let x=typeof i=="string"?i:JSON.stringify(i);return`${g}=${JSON.stringify(x)}`}).join(", "))}catch{let p=[],g=vl;g.lastIndex=0;let i;for(;(i=g.exec(d))!==null;){let x=i[1],I=i[2]!==void 0?i[2]:i[0].split(":").slice(1).join(":").trim();p.push(`${x}=${JSON.stringify(I)}`)}p.length>0?a=p.join(", "):a=d.trim()}let m=r.toLowerCase().replace(/_/g,"");return`[tool:functions.${t[m]||n(r)}(${a})]`});return ga.lastIndex=0,ma.lastIndex=0,s=s.replace(ga,""),s=s.replace(ma,""),s},Vn=e=>{if(!e)return[];let t=Pl(e),n=Ht(t),s=[],o=Li(n),r=bl;r.lastIndex=0;let d;for(;(d=r.exec(o))!==null;){let a=d[1],m=d.index+d[0].length-1,f=0,h=null,p=-1,g=-1;for(let i=m;i<o.length;i++){let x=o[i];if(h){if(x===h){let I=0;for(let Ye=i-1;Ye>=0&&o[Ye]==="\\";Ye--)I++;I%2===0&&(h=null)}}else{if(i>m&&(o.substring(i).startsWith("[action:")||o.substring(i).startsWith("[tool:")))break;if(x==='"'||x==="'"||x==="`")h=x;else if(x==="(")f++;else if(x===")"&&(f--,f===0)){g=i;let I=i+1;for(;I<o.length&&/\s/.test(o[I]);)I++;if(I<o.length&&o[I]==="]"){p=I;break}}}}if(p!==-1){let i=n.substring(m+1,g),x=n.substring(d.index,p+1);s.push({fullMatch:x,toolName:a.trim(),args:i.trim()}),r.lastIndex=p+1}}return s},ya=e=>{if(!e)return null;let t=Ht(e),n=[],s=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,o=[],r;for(;(r=s.exec(t))!==null;)o.push({toolName:r[1],index:r.index,parenIndex:r.index+r[0].length-1});for(let g=0;g<o.length;g++){let i=o[g],x=g+1<o.length?o[g+1].index:t.length,I=t.substring(i.index,x),Ye=I.indexOf("("),C=Ye!==-1?I.substring(Ye+1):"",P=0,N=null,U=!1;for(let $=0;$<C.length;$++){let M=C[$];if(N){if(M===N){let Se=0;for(let ve=$-1;ve>=0&&C[ve]==="\\";ve--)Se++;Se%2===0&&(N=null)}}else if(M==='"'||M==="'"||M==="`")N=M;else if(M==="(")P++;else if(M===")")if(P>0)P--;else{let Se=$+1;for(;Se<C.length&&/\s/.test(C[Se]);)Se++;if(Se<C.length&&C[Se]==="]"){U=!0;break}}}if(!U){let $=I.trim(),M="";N?M=`Unclosed quote string (${N}) inside arguments`:$.endsWith("]")?M=`Missing closing ')' before ']' (e.g. found "...]")`:$.endsWith(")")?M=`Missing closing ']' after ')' (e.g. found "...)" instead of "...)]")`:!$.includes(")")&&!$.includes("]")?M="Missing closing delimiter ')]'":M="Malformed or unclosed call syntax (missing ')]')",n.push(`\u2022 [action:${i.toolName}(...)]: ${M}. Expected: [action:${i.toolName}(arg1="...", arg2="...")]`)}}let d=/(?:^|[^\w\[])(?:tool|action):(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/gi,a;for(;(a=d.exec(t))!==null;){let g=a[1],i=a.index+(a[0].indexOf(":")-(a[0].startsWith("action")||a[0].startsWith("tool")?0:1));(i>0?t[i-1]:"")!=="["&&Ei(g)&&n.push(`\u2022 action:${g}(...): Missing opening bracket '['. Expected: [action:${g}(...)]`)}let m=/\[\s*(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/g,f;for(;(f=m.exec(t))!==null;){let g=f[1];g!=="action"&&g!=="tool"&&Ei(g)&&n.push(`\u2022 [${g}(...)]: Missing 'action:' prefix. Expected: [action:${g}(...)]`)}let h=/\[\s*(?:tool|action)\s*:\s*(?:functions\.)?([a-zA-Z0-9_]+)(?!\s*\()/gi,p;for(;(p=h.exec(t))!==null;){let g=p[1];Ei(g)&&n.push(`\u2022 [action:${g}...]: Missing opening '(' for tool arguments. Expected: [action:${g}(...)]`)}return n.length>0?n.join(`
561
+ `):null},of=(e,t={})=>{if(!e)return null;if(Xo=t,Ms=new xa({apiKey:e}),!globalThis.__perfCleanupInstalled){globalThis.__perfCleanupInstalled=!0,setInterval(()=>{typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks())},6e4);let n=globalThis.fetch;globalThis.fetch=async(...s)=>{try{let o=await n(...s);return typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),o}catch(o){throw typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),o}}}},Aa=e=>{if(!e)return{serviceTier:void 0,cleanModel:e};let t=e.toLowerCase();return t.endsWith(":flex")?{serviceTier:"flex",cleanModel:e.slice(0,-5)}:t.endsWith(":priority")?{serviceTier:"priority",cleanModel:e.slice(0,-9)}:{serviceTier:void 0,cleanModel:e}},$l=async(e,t,n,s,o="Fast",r=.75,d="agent")=>_l(async()=>{let{aiProvider:a="Google",apiKey:m,mode:f}=e,h="",p=null,g=typeof n=="string"?[{role:"user",parts:[{text:n}]}]:n,i=new AbortController,x=i.signal,I=setInterval(()=>{xt&&(i.abort(),clearInterval(I))},100),Ye=Date.now(),C=null;try{let P;if(a==="Ollama")P=(await de("Ollama"))(m,t,g,s,o,f,Ze(t),x,r,e.systemSettings?.ollamaEndpoint||"Cloud");else if(a==="OpenRouter")P=(await de("OpenRouter"))(m,t,g,s,o,f,Ze(t),x,r);else if(a==="DeepSeek")P=(await de("DeepSeek"))(m,t,g,s,o,f,Ze(t),x,r);else if(a==="Mistral")P=(await de("Mistral"))(m,t,g,s,o,f,Ze(t),x,r);else if(a==="NVIDIA")P=(await de("NVIDIA"))(m,t,g,s,o,f,Ze(t),x,r);else if(a==="InferX")P=(await de("InferX"))(m,t,g,s,o,f,Ze(t),x,r);else if(a==="SenseNova")P=(await de("SenseNova"))(m,t,g,s,o,f,Ze(t),x,r);else if(a==="AIHubMix")P=(await de("AIHubMix"))(m,t,g,s,o,f,Ze(t),x,r);else if(a==="Poolside")P=(await de("Poolside"))(m,t,g,s,o,f,Ze(t),x,r);else if(a==="9router"||a==="9Router")P=(await de("NineRouter"))(m,t,g,s,o,f,Ze(t),x,r);else if(a==="ExpLabs"||a==="ExperientialLabs")P=(await de("ExpLabs"))(m,t,g,s,o,f,Ze(t),x,r);else if(a==="Infron"||a==="infron")P=(await de("Infron"))(m,t,g,s,o,f,Ze(t),x,r);else if(a==="Numes"||a==="numes")P=(await de("Numes"))(m,t,g,s,o,f,Ze(t),x,r);else if(a==="TokenHarbor"||a==="Token Harbor"||a==="tokenharbor"||a==="token_harbor"||a==="thk")P=(await de("TokenHarbor"))(m,t,g,s,o,f,Ze(t),x,r);else if(a==="APInex"||a==="apinex"||a==="apx")P=(await de("APInex"))(m,t,g,s,o,f,Ze(t),x,r);else if(a==="xKiro"||a==="xkiro"||a==="kiro")P=(await de("xKiro"))(m,t,g,s,o,f,Ze(t),x,r);else if(a==="CoArena"||a==="coarena")P=(await de("CoArena"))(m,t,g,s,o,f,Ze(t),x,r);else if(a==="c_openai"||a==="Custom (OpenAI)"){let N=e.systemSettings?.customOpenAIBaseUrl||"";try{N=await Yi("c_openai")||N}catch{}P=(await de("c_openai"))(m,t,g,s,o,f,Ze(t),x,r,N)}else{let N=ka(m),{serviceTier:U,cleanModel:$}=Aa(t),M={systemInstruction:s,temperature:r,thinkingConfig:(()=>{let ve=(t||"").toLowerCase(),Be=ve.includes("gemma-4")||ve.startsWith("gemma"),et=ve.includes("gemini-3");if(Be||et)return Be?o.toLowerCase()!=="xhigh"?{includeThoughts:!1,thinkingLevel:qe.MINIMAL}:{includeThoughts:!0,thinkingLevel:qe.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:ve.includes("pro")?qe.LOW:qe.MINIMAL,Low:qe.LOW,Medium:qe.MEDIUM,Standard:qe.MEDIUM,High:qe.HIGH,xHigh:qe.HIGH}[o]||qe.MEDIUM};{let W={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[o]||2048;return W===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:W}}})()};U&&(M.serviceTier=U),P=await N.models.generateContentStream({model:$,contents:g,config:M},{signal:x})}for await(let N of P){if(xt)throw new Error("Subagent task was cancelled.");if(e?.taskId&&typeof Gt<"u"){let M=Gt.find(Se=>Se.id===e.taskId);if(M&&M.status==="cancelled")throw new Error("Subagent task was cancelled.")}C===null&&(N.candidates?.[0]?.content?.parts||N.text)&&(C=Date.now()-Ye);let U="";if(N.candidates?.[0]?.content?.parts)for(let M of N.candidates[0].content.parts)M.text&&!M.thought&&(h+=M.text,U+=M.text);let $=U?Qi(U):0;e&&typeof e.onTokenChunk=="function"&&e.onTokenChunk(U,$),N.usageMetadata&&(p=N.usageMetadata)}}finally{clearInterval(I)}if(p){let P=p.totalTokenCount||0,N=p.cachedContentTokenCount||0,U=(p.candidatesTokenCount||0)+(a==="Google"&&p.thoughtsTokenCount||0);await hn("tokens",P,a,t),N>0&&await hn("cachedTokens",N,a,t),U>0&&await hn("candidateTokens",U,a,t),C!==null&&C>0&&await hn("ttft",C,a,t),gi({provider:a,model:t,prompt:p.promptTokenCount||0,cached:N,output:U,reasoning:p.thoughtsTokenCount||0,ttft:C}),e&&typeof e.onUsage=="function"&&e.onUsage({totalTokenCount:P,cachedContentTokenCount:N,candidatesTokenCount:U})}return await Lt("agent",a),{text:h,usageMetadata:p}}),sf=async function*(e,t,n,s,o){let{profile:r,thinkingLevel:d,mode:a,janitorModel:m,chatId:f,isPlayground:h,systemSettings:p,sessionStats:g,aiProvider:i="Google",apiTier:x,wildcardTooling:I,wildercardTooling:Ye}=n,C=Ze(e);if(!Ms&&i==="Google")throw new Error("AI not initialized");let P=!1,N=t[t.length-1].text,U=B.join(Ks,"chat-summaries.json"),$=!1,M=t.filter(W=>W.role==="user").length===1,Se=N.includes("[TITLE-UPDATE]"),ve=M||Se,Be=N.replace(/\[TITLE-UPDATE\]/g,"").trim();Be=Be.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),yield{type:"status",content:"[start]"},yield{type:"status",content:"Gathering Context"},await mi.startTransaction(f,Be),p?.advanceRollback&&await Oo.takeInitialSnapshot(f),xt=!1;let et=null;try{let W=new AbortController;et=setInterval(()=>{xt&&(W.abort(),et&&(clearInterval(et),et=null))},400);let w=[...t.slice(0,-1)];{let ge=pn(U,{})[f]||{summary:"",historyLength:0};if(ge.summary&&ge.historyLength>0){let Tt=0,le=[];for(let j=0;j<w.length;j++){let ke=w[j];(ke.role==="user"||ke.role==="agent"||ke.role==="system")&&!String(ke.id).startsWith("welcome")&&!ke.isMeta&&Tt++,Tt>ge.historyLength&&le.push(ke)}w=le}}w=w.map(b=>{if(b.role==="user"&&b.text){let ge=b.text.match(/\[USER\]([\s\S]*?)\[\/USER\]/);if(ge)return{...b,text:ge[1].trim()}}return{...b}});let rn=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1,ln={"16k":16e3,"32k":32e3,"64k":64e3,"128k":128e3,"256k":256e3,"512k":512e3,"1M":1e6}[p?.contextLength]||256e3;if(i==="Google"&&e?.includes("gemma")&&rn&&(ln=16e3),(g?.tokens||0)>ln){yield{type:"text",content:"\u2726 Maximum Context Limit Reached. Start a new chat."};return}if(M&&P){let b=pn(Vi,{});Object.values(b).flat().length>5}let ao=pn(Vi,{}),wt=pn(Vs,{}),zn=Object.entries(ao).filter(([b])=>b!==f).flatMap(([b,ge])=>ge),we=[...Object.entries(wt).filter(([b])=>b!==f).slice(-20).map(([b,ge])=>`[Chat Summary]: ${ge}`),...zn].map(b=>`- ${b}`).join(`
562
+ `),Ne=pn(ci,[]).map(b=>`- ${b.memory}`).join(`
563
+ `),De=(g?.tokens||0)>=1e4,jt=new Date,In=jt.getFullYear(),qn=jt.toLocaleString("en-US",{month:"short"}).toUpperCase(),Mn=String(jt.getDate()).padStart(2,"0"),dn=`${jt.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}`,wn=b=>{try{return xe.readdirSync(b,{withFileTypes:!0})}catch{return[]}},Kt=Array.from(new Set([...$o,...Lo(process.cwd())])),bn=(b,ge=6)=>p?.indentationTree!==!1?As(b,ge,1,wn,Kt):Rs(b,ge,"",1,wn,Kt),Yn=pn(zi,{}),H=Yn[f],D=H?H!==process.cwd():!1;Yn[f]=process.cwd(),qi(zi,Yn);let Sn=pn(U,{}),Ee=Sn[f]||{summary:"",historyLength:0};typeof Ee=="string"&&(Ee={summary:Ee,historyLength:0});let A=t.filter(b=>(b.role==="user"||b.role==="agent"||b.role==="system")&&!String(b.id).startsWith("welcome")&&!b.isMeta).length;Ee.historyLength&&A<Ee.historyLength&&(Ee.summary="",Ee.historyLength=0,Sn[f]=Ee,qi(U,Sn));let V=typeof Ee=="object"?Ee.summary||"":Ee||"",tt=w.length>0;tt&&V&&w[0]&&(w[0].role==="user"||w[0].role==="system")&&(w[0].text.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")||(w[0].text=`[SYSTEM METADATA]
563
564
  **CONTEXT SUMMARY OF PREVIOUS TURNS (PRIORITY: DYNAMIC)**
564
- ${ft}
565
+ ${V}
565
566
 
566
- [USER] ${w[0].text}`,yield{type:"summary_injected",content:{id:w[0].id,text:w[0].text}}));let dn=ft&&!Zt?`
567
+ [USER] ${w[0].text}`,yield{type:"summary_injected",content:{id:w[0].id,text:w[0].text}}));let nt=V&&!tt?`
567
568
  [SYSTEM METADATA]
568
569
  **CONTEXT SUMMARY OF PREVIOUS TURNS**
569
- ${ft}
570
- `:"",kn=!!p?.dynamicDirAwareness,_s=`${f}|${i}|${d}|${e}|${r}|${kn}`,Aa=!kn&&no.key===_s&&no.value?"":`
570
+ ${V}
571
+ `:"",rt=!!p?.dynamicDirAwareness,kt=`${f}|${i}|${d}|${e}|${r}|${rt}`,Pn=!rt&&so.key===kt&&so.value?"":`
571
572
  **Directory**
572
573
  CWD: `+process.cwd()+`${h?" [PLAYGROUND MODE]":""}
573
- `+Vn(process.cwd(),6),Ot=yo()?await to():null,Is=b=>{if(!b||!Array.isArray(b)||b.length===0)return null;let ge=new Map;for(let le of b){let H=le.relPath||(le.file?U.relative(process.cwd(),le.file):"unknown");ge.has(H)||ge.set(H,[]),ge.get(H).push(le)}let kt=[];for(let[le,H]of ge.entries()){kt.push(`- ${le}:`);for(let Se of H){let $e=(Se.snippet||"").trim().replace(/\r?\n/g," "),nt=Se.line||1,Bt=(Se.text||"").trim().replace(/\r?\n+/g,". "),Tt=Bt?` [${Bt}]`:"";kt.push(` ~L${nt}${Tt}`)}}return kt.join(`
574
- `)},Pi=Is(Ot?.comments),Tn="";if(Ot&&Ot.file_focused!=="none"){Tn=`
574
+ `+bn(process.cwd(),6),at=So()?await io():null,Oi=b=>{if(!b||!Array.isArray(b)||b.length===0)return null;let ge=new Map;for(let le of b){let j=le.relPath||(le.file?B.relative(process.cwd(),le.file):"unknown");ge.has(j)||ge.set(j,[]),ge.get(j).push(le)}let Tt=[];for(let[le,j]of ge.entries()){Tt.push(`- ${le}:`);for(let ke of j){let Pe=(ke.snippet||"").trim().replace(/\r?\n/g," "),ot=ke.line||1,Ft=(ke.text||"").trim().replace(/\r?\n+/g,". "),At=Ft?` [${Ft}]`:"";Tt.push(` ~L${ot}${At}`)}}return Tt.join(`
575
+ `)},lo=Oi(at?.comments),Tn="";if(at&&at.file_focused!=="none"){Tn=`
575
576
  [Additional IDE Context]
576
- `;let b=U.relative(process.cwd(),Ot.file_focused),ge=(Ot.opened_editors||[]).map(le=>{let H=U.relative(process.cwd(),le);return H.startsWith("..")?`[External] ${U.basename(le)}`:H});if(Tn+=`Focused File: ${b}
577
- Cursor Line: ${Ot.cursor_line}
578
- `,Ot.selected){let le=Ot.selected,H=le.split(`
579
- `);H.length>256&&(le=H.slice(0,240).join(`
577
+ `;let b=B.relative(process.cwd(),at.file_focused),ge=(at.opened_editors||[]).map(le=>{let j=B.relative(process.cwd(),le);return j.startsWith("..")?`[External] ${B.basename(le)}`:j});if(Tn+=`Focused File: ${b}
578
+ Cursor Line: ${at.cursor_line}
579
+ `,at.selected){let le=at.selected,j=le.split(`
580
+ `);j.length>256&&(le=j.slice(0,240).join(`
580
581
  `)+`
581
582
  ... [truncated] ...
582
- `+H.slice(-16).join(`
583
+ `+j.slice(-16).join(`
583
584
  `)),le.length>2048&&(le=le.slice(0,1920)+`
584
585
  ... [truncated] ...
585
586
  `+le.slice(-128)),Tn+=`Current Selection: "${le}"
586
- `}if(Ot.manual_edits){let le=Ot.manual_edits.split(`
587
- `),H=[];for(let Se=0;Se<le.length;Se++){let $e=le[Se],nt=le[Se+1],Bt=le[Se+2];if(nt!==void 0&&Bt!==void 0&&/:\s*$/.test($e)&&/^\s*-\s*/.test(nt)&&/^\s*\+\s*/.test(Bt)&&(nt.length>300||Bt.length>300)){H.push($e.replace(/:\s*$/,": [changed]")),Se+=2;continue}H.push($e)}Tn+=`Recent Manual Edits:
588
- ${H.join(`
587
+ `}if(at.manual_edits){let le=at.manual_edits.split(`
588
+ `),j=[];for(let ke=0;ke<le.length;ke++){let Pe=le[ke],ot=le[ke+1],Ft=le[ke+2];if(ot!==void 0&&Ft!==void 0&&/:\s*$/.test(Pe)&&/^\s*-\s*/.test(ot)&&/^\s*\+\s*/.test(Ft)&&(ot.length>300||Ft.length>300)){j.push(Pe.replace(/:\s*$/,": [changed]")),ke+=2;continue}j.push(Pe)}Tn+=`Recent Manual Edits:
589
+ ${j.join(`
589
590
  `)}
590
- `}ge.length>0&&(Tn+=`All Opened Editors: ${ge.join(", ")}`),Ot.diagnostics&&(Tn+=`
591
+ `}ge.length>0&&(Tn+=`All Opened Editors: ${ge.join(", ")}`),at.diagnostics&&(Tn+=`
591
592
  **Active File Errors**:
592
- ${Ot.diagnostics}
593
- `),(De.toLowerCase().includes("lint")||De.toLowerCase().includes("warning"))&&Ot.warnings&&(Tn+=`
593
+ ${at.diagnostics}
594
+ `),(Be.toLowerCase().includes("lint")||Be.toLowerCase().includes("warning"))&&at.warnings&&(Tn+=`
594
595
  **Lint Warnings**:
595
- ${Ot.warnings}
596
- `)}let Ms=De.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),Ps=/(?:\\)?@\[([^\]]+)\]/g,$i,Li=[];for(Ps.lastIndex=0;($i=Ps.exec(Ms))!==null;){let b=$i[0].startsWith("\\");Li.push({tag:$i[1],isEscaped:b})}let Oi=[],zo=null,qo=!1;for(let b=0;b<Li.length;b++){let{tag:ge,isEscaped:kt}=Li[b];if(!kt)try{let le=ge.trim().replace(/^["']|["']$/g,""),H=/[:#]L?(\d+)(?:-L?(\d+))?$/i,Se=le.match(H),$e=le,nt=null,Bt=null;Se&&(nt=parseInt(Se[1],10),Bt=Se[2]?parseInt(Se[2],10):nt,$e=le.slice(0,Se.index));let Tt=U.resolve(process.cwd(),$e);if(we.existsSync(Tt)&&we.statSync(Tt).isFile()){let Ut=$e.toLowerCase(),bo=Ut.endsWith(".pdf"),qn=Ut.endsWith(".docx")||Ut.endsWith(".doc")||Ut.endsWith(".ppt")||Ut.endsWith(".pptx")||Ut.endsWith(".xls")||Ut.endsWith(".xlsx"),Yn=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(Ut),je=Yn||bo||qn,Et=i==="Google"||et(e);if(je&&!Et){let pe=`\u2718 Unsupported Modality: ${U.basename($e)}`,Qe=115;process.stdout.isTTY&&(Qe=process.stdout.columns-5||120);let _t=[pe],Be=Math.max(..._t.map(nn=>nn.length)),J=Math.min(Be+4,Qe),Le=_t.map(nn=>`${nn.padEnd(J-2).substring(0,J-2)}`).join(`
597
- `);yield{type:"visual_feedback",content:Lt(`${Le}
598
- `)};continue}if(nt===null&&!je){let pe=0;try{pe=we.readFileSync(Tt,"utf8").split(/\r\n|\r|\n/).length}catch{}if(pe>150){let Qe=`\u21B7 Skipped (Too Large): ${U.basename($e)}`,_t=115;process.stdout.isTTY&&(_t=process.stdout.columns-5||120);let Be=Math.min(Qe.length+4,_t),J=Qe.padEnd(Be-2).substring(0,Be-2);yield{type:"visual_feedback",content:Lt(`${J}
599
- `)};continue}}let Pn=nt!==null?nt:1,Wt=Bt!==null?Bt:nt!==null?nt:Pn+149;if(Wt-Pn>200){let pe=`\u21B7 Skipped (Too Large): ${U.basename($e)}`,Qe=115;process.stdout.isTTY&&(Qe=process.stdout.columns-5||120);let _t=Math.min(pe.length+4,Qe),Be=pe.padEnd(_t-2).substring(0,_t-2);yield{type:"visual_feedback",content:Lt(`${Be}
600
- `)};continue}let Xn=`path=${JSON.stringify($e)}, startLine=${Pn}, endLine=${Wt}`,Gt=await tr(Xn,{isMultiModal:Et}),$n=!1,ro="",bt=null;if(typeof Gt=="string"?Gt.trim().startsWith("ERROR")?$n=!0:ro=Gt:Gt&&typeof Gt=="object"&&Gt.binaryPart?(bt=Gt.binaryPart,ro=Gt.text||""):$n=!0,!$n){let pe="";if(Yn?(pe=`\u2714 Processed: ${U.basename($e)}`,zo=bt,qo=!0):bo||qn?(pe=`\u2714 Auto-Analysed: ${U.basename($e)}`,zo=bt,qo=!0):(pe=`\u2714 Auto-Read: ${U.basename($e)}`,Oi.push(ro)),pe){let Qe=115;process.stdout.isTTY&&(Qe=process.stdout.columns-5||120);let _t=[pe],Be=Math.max(..._t.map(nn=>nn.length)),J=Math.min(Be+4,Qe),Le=_t.map(nn=>`${nn.padEnd(J-2).substring(0,J-2)}`).join(`
601
- `);yield{type:"visual_feedback",content:Lt(`${Le}
602
- `)}}}}}catch{}}let Yo="";Oi.length>0?Yo=`
603
- [Tagged File Contents] Auto Read User Tagged files by System${qo?", attached below & multimodal part":""}. No need to re-read
604
- `+Oi.join(`
596
+ ${at.warnings}
597
+ `)}let Ps=Be.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),$s=/(?:\\)?@\[([^\]]+)\]/g,Ni,Di=[];for($s.lastIndex=0;(Ni=$s.exec(Ps))!==null;){let b=Ni[0].startsWith("\\");Di.push({tag:Ni[1],isEscaped:b})}let Fi=[],Jo=null,Qo=!1;for(let b=0;b<Di.length;b++){let{tag:ge,isEscaped:Tt}=Di[b];if(!Tt)try{let le=ge.trim().replace(/^["']|["']$/g,""),j=/[:#]L?(\d+)(?:-L?(\d+))?$/i,ke=le.match(j),Pe=le,ot=null,Ft=null;ke&&(ot=parseInt(ke[1],10),Ft=ke[2]?parseInt(ke[2],10):ot,Pe=le.slice(0,ke.index));let At=B.resolve(process.cwd(),Pe);if(xe.existsSync(At)&&xe.statSync(At).isFile()){let Bt=Pe.toLowerCase(),Ao=Bt.endsWith(".pdf"),Jn=Bt.endsWith(".docx")||Bt.endsWith(".doc")||Bt.endsWith(".ppt")||Bt.endsWith(".pptx")||Bt.endsWith(".xls")||Bt.endsWith(".xlsx"),Qn=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(Bt),je=Qn||Ao||Jn,_t=i==="Google"||Ze(e);if(je&&!_t){let pe=`\u2718 Unsupported Modality: ${B.basename(Pe)}`,Je=115;process.stdout.isTTY&&(Je=process.stdout.columns-5||120);let It=[pe],Fe=Math.max(...It.map(en=>en.length)),J=Math.min(Fe+4,Je),$e=It.map(en=>`${en.padEnd(J-2).substring(0,J-2)}`).join(`
598
+ `);yield{type:"visual_feedback",content:Ot(`${$e}
599
+ `)};continue}if(ot===null&&!je){let pe=0;try{pe=xe.readFileSync(At,"utf8").split(/\r\n|\r|\n/).length}catch{}if(pe>150){let Je=`\u21B7 Skipped (Too Large): ${B.basename(Pe)}`,It=115;process.stdout.isTTY&&(It=process.stdout.columns-5||120);let Fe=Math.min(Je.length+4,It),J=Je.padEnd(Fe-2).substring(0,Fe-2);yield{type:"visual_feedback",content:Ot(`${J}
600
+ `)};continue}}let $n=ot!==null?ot:1,Ut=Ft!==null?Ft:ot!==null?ot:$n+149;if(Ut-$n>200){let pe=`\u21B7 Skipped (Too Large): ${B.basename(Pe)}`,Je=115;process.stdout.isTTY&&(Je=process.stdout.columns-5||120);let It=Math.min(pe.length+4,Je),Fe=pe.padEnd(It-2).substring(0,It-2);yield{type:"visual_feedback",content:Ot(`${Fe}
601
+ `)};continue}let Zn=`path=${JSON.stringify(Pe)}, startLine=${$n}, endLine=${Ut}`,Wt=await nr(Zn,{isMultiModal:_t}),Ln=!1,fo="",bt=null;if(typeof Wt=="string"?Wt.trim().startsWith("ERROR")?Ln=!0:fo=Wt:Wt&&typeof Wt=="object"&&Wt.binaryPart?(bt=Wt.binaryPart,fo=Wt.text||""):Ln=!0,!Ln){let pe="";if(Qn?(pe=`\u2714 Processed: ${B.basename(Pe)}`,Jo=bt,Qo=!0):Ao||Jn?(pe=`\u2714 Auto-Analysed: ${B.basename(Pe)}`,Jo=bt,Qo=!0):(pe=`\u2714 Auto-Read: ${B.basename(Pe)}`,Fi.push(fo)),pe){let Je=115;process.stdout.isTTY&&(Je=process.stdout.columns-5||120);let It=[pe],Fe=Math.max(...It.map(en=>en.length)),J=Math.min(Fe+4,Je),$e=It.map(en=>`${en.padEnd(J-2).substring(0,J-2)}`).join(`
602
+ `);yield{type:"visual_feedback",content:Ot(`${$e}
603
+ `)}}}}}catch{}}let Zo="";Fi.length>0?Zo=`
604
+ [Tagged File Contents] Auto Read User Tagged files by System${Qo?", attached below & multimodal part":""}. No need to re-read
605
+ `+Fi.join(`
605
606
 
606
607
  `)+`
607
608
  [Tagged File Contents]
608
- `:qo&&(Yo=`
609
+ `:Qo&&(Zo=`
609
610
  [Tagged File Contents] Auto Read User Tagged files by System & attached as multimodal part. No need to re-read [Tagged File Contents]
610
- `);let Ue=Ms.replace(/\\(@\[[^\]]+\])/g,"$1"),$s=I?`You cannot execute tools. Instead write the action string in chat you WOULD have written, without markdown wrappers. Then wait for systtem response
611
- `:"",Ca=process.env.forcedReasoning||!1,Ls=d!=="Fast"&&(i==="Mistral"&&!ai(e)||d!=="High"&&i==="Google")?`${i==="Mistral"&&!ai(e)||e.toLowerCase().startsWith("gemma")||Ca?`[system] strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow> [/system]
612
- `:""}`:"",so="";if(p?.clipboardContext)try{process.platform==="win32"?so=As("powershell.exe -NoProfile -Command Get-Clipboard",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):process.platform==="darwin"?so=As("pbpaste",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):so=As("xclip -selection clipboard -o || xsel --clipboard --output",{encoding:"utf8",shell:!0,stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,"")}catch{so=""}let Xo="",Ra=!!p?.autoExcludeMetadata,Os=!1,Ns=!1,Ni="";if(Ue.startsWith("/skill create ")||Ue==="/skill create"){let b=null;Os=!0,Ue=Ue.replace(/^\/skill\s+create\b/,"").trim(),/^--project(\s|$)|(\s|^)--project$/.test(Ue)?b="project":/^--global(\s|$)|(\s|^)--global$/.test(Ue)&&(b="global"),Ue=Ue.replace(/^--project\s*|\s*--project$/g,"").trim(),Ue=Ue.replace(/^--global\s*|\s*--global$/g,"").trim(),Ue=Ue.replace(/^(['"])([\s\S]*)\1$/,"$2").trim(),Ni=`[system] ## Skill Creation Rules
611
+ `);let Ue=Ps.replace(/\\(@\[[^\]]+\])/g,"$1"),Ls=I?`You cannot execute tools. Instead write the action string in chat you WOULD have written, without markdown wrappers. Then wait for systtem response
612
+ `:"",Ca=process.env.forcedReasoning||!1,Os=d!=="Fast"&&(i==="Mistral"&&!fi(e)||d!=="High"&&i==="Google")?`${i==="Mistral"&&!fi(e)||e.toLowerCase().startsWith("gemma")||Ca?`[system] strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow> [/system]
613
+ `:""}`:"",co="";if(p?.clipboardContext)try{process.platform==="win32"?co=vs("powershell.exe -NoProfile -Command Get-Clipboard",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):process.platform==="darwin"?co=vs("pbpaste",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):co=vs("xclip -selection clipboard -o || xsel --clipboard --output",{encoding:"utf8",shell:!0,stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,"")}catch{co=""}let ei="",Ra=!!p?.autoExcludeMetadata,Ns=!1,Ds=!1,Bi="";if(Ue.startsWith("/skill create ")||Ue==="/skill create"){let b=null;Ns=!0,Ue=Ue.replace(/^\/skill\s+create\b/,"").trim(),/^--project(\s|$)|(\s|^)--project$/.test(Ue)?b="project":/^--global(\s|$)|(\s|^)--global$/.test(Ue)&&(b="global"),Ue=Ue.replace(/^--project\s*|\s*--project$/g,"").trim(),Ue=Ue.replace(/^--global\s*|\s*--global$/g,"").trim(),Ue=Ue.replace(/^(['"])([\s\S]*)\1$/,"$2").trim(),Bi=`[system] ## Skill Creation Rules
613
614
  * ${b?b==="project"?`Creation path: ./skills/skillName?/SKILL.md
614
615
  * 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
615
616
  * If skills folder already present, ReadFolder for existing structure`}
@@ -626,8 +627,8 @@ description: concise detail to explain the skill
626
627
  * After creation, tell user to restart fluxflow for reindexing${(g?.tokens||0)>24576?`
627
628
  * Warn: This session is currently long, and reindexing will cause full cache invalidation`:""}
628
629
  [/system]
629
- `}else if(Ue.startsWith("/skill edit ")||Ue==="/skill edit"){Ns=!0,Ue=Ue.replace(/^\/skill\s+edit\b/,"").trim();let b=null,ge=Ue.match(/^--([^\s]+)(?:\s|$)/);if(ge)b=ge[1],Ue=Ue.slice(ge[0].length).trim();else{let H=Ue.match(/(?:\s|^)--([^\s]+)$/);H&&(b=H[1],Ue=Ue.slice(0,H.index).trim())}Ue=Ue.replace(/^(['"])([\s\S]*)\1$/,"$2").trim();let kt=null,le=null;if(b){let H=b.toLowerCase(),Se=[...yi||[],...hi||[]].find($e=>$e&&$e.name&&$e.name.toLowerCase()===H);Se&&Se.filePath&&(le=U.resolve(Se.filePath),kt=U.dirname(le))}Ni=`[system] ## Skill Modification Rules
630
- ${kt&&b?`* Target Skill: ${b}
630
+ `}else if(Ue.startsWith("/skill edit ")||Ue==="/skill edit"){Ds=!0,Ue=Ue.replace(/^\/skill\s+edit\b/,"").trim();let b=null,ge=Ue.match(/^--([^\s]+)(?:\s|$)/);if(ge)b=ge[1],Ue=Ue.slice(ge[0].length).trim();else{let j=Ue.match(/(?:\s|^)--([^\s]+)$/);j&&(b=j[1],Ue=Ue.slice(0,j.index).trim())}Ue=Ue.replace(/^(['"])([\s\S]*)\1$/,"$2").trim();let Tt=null,le=null;if(b){let j=b.toLowerCase(),ke=[...Si||[],...bi||[]].find(Pe=>Pe&&Pe.name&&Pe.name.toLowerCase()===j);ke&&ke.filePath&&(le=B.resolve(ke.filePath),Tt=B.dirname(le))}Bi=`[system] ## Skill Modification Rules
631
+ ${Tt&&b?`* Target Skill: ${b}
631
632
  * Physical Skill path: ${le}
632
633
  * Skill will have a SKILL.md at this path. And may have lazy loaded *.md files in folders
633
634
  * Extract requirements, use file tools with physical disk path
@@ -636,163 +637,163 @@ ${kt&&b?`* Target Skill: ${b}
636
637
  * After completion tell user no reindexing needed, will be auto updated on next #skill read if frontmatter stays same${(g?.tokens||0)>24576?`
637
638
  * Warn: This session is currently long, if name, description is changed reindex is needed, and will cause a full cache invalidation`:""}`:"- User didnt provided any structured skill name to modify. Tell them to use proper syntax: `/skill edit --skillName instructions`"}
638
639
  [/system]
639
- `}let va=!!(Tn||Yo||$s||dn||Ls||te||p?.dynamicDirAwareness||p?.autoTruncateResults||Os||Ns);Ra&&!va?Xo=Ue.trim():Xo=`[System Metadata] Time: ${wo}${te?`
640
- WARNING: CWD Changed from previous: "${k}" to current: "${process.cwd()}", write change in chat to avoid future path mismatches
640
+ `}let va=!!(Tn||Zo||Ls||nt||Os||D||p?.dynamicDirAwareness||p?.autoTruncateResults||Ns||Ds);Ra&&!va?ei=Ue.trim():ei=`[System Metadata] Time: ${dn}${D?`
641
+ WARNING: CWD Changed from previous: "${H}" to current: "${process.cwd()}", write change in chat to avoid future path mismatches
641
642
  `:""}${Tn}
642
- ${so.trim().length>0?`[Clipboard Context]
643
- - ${so.trim()}
644
- `:""}${Pi?`[Additional Comments]
645
- ${Pi.trimEnd()}
643
+ ${co.trim().length>0?`[Clipboard Context]
644
+ - ${co.trim()}
645
+ `:""}${lo?`[Additional Comments]
646
+ ${lo.trimEnd()}
646
647
  `:""}Action format: [action:ActionName(...)]
647
648
  [/Metadata]
648
- ${dn}${Ls}${Yo}${Ni}${$s}[user prompt] ${Ue.trim()} [/user prompt]`.trim();let Ds={role:"user",text:Xo};zo&&(Ds.binaryPart=zo),w.forEach(b=>{b.text&&b.role==="agent"&&(b.text=jt(b.text))}),w.push(Ds),dn&&t[t.length-1]?.id&&(yield{type:"summary_injected",content:{id:t[t.length-1].id,text:Xo}});let en=null,tn=a==="Flux"?50:15;tn=a.toLowerCase().includes("cu")?75:tn;let Fs=(p?.loopLimits||"Default").toLowerCase();if(Fs==="extended")tn=Math.floor(tn*3);else if(Fs==="env"){let b=parseInt(process.env.FLUXFLOW_MAX_LOOPS||process.env.MAX_LOOPS||"",10);Number.isFinite(b)&&b>0&&(tn=b)}let Ea=Math.floor(tn/2),Bs=0,fn=16;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Consulting the spirits":"Connecting"},xt=!1;let Di=[],Jo=!1,Us=!1,zn=[],Fi=!1;for(let b=0;b<=tn;b++){let ge=Math.floor(tn*.95);if(b>=ge&&Bs<ge&&typeof n?.onAskUser=="function"){Bs=ge;try{let j="Agent has been running for a long time. Do you want to continue execution?",Q=[{id:"continue",label:"Continue",description:"Add few more steps"},{id:"cancel",label:"Cancel",description:"Stop extending and finish current turn limit"}],E=await n.onAskUser(j,Q);E&&(E.toLowerCase().includes("continue")||E==="Continue")&&(tn+=Ea)}catch{}}if(zn.length>=10&&typeof n?.onAskUser=="function"){let j={},Q=null;for(let E of zn)if(j[E]=(j[E]||0)+1,j[E]>=10){Q=E;break}if(Q)try{let E="Agent seems stuck in a tool loop. You can prompt it to steer or break the loop:",gt=[{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"}],fe=await n.onAskUser(E,gt);if(fe){let We="";typeof fe=="string"&&(fe.toLowerCase()==="stop"||fe.includes("Stop Loop"))?We="Stop repeating the same action call. Acknowledge what failed or succeeded, summarize your current findings, and conclude.":typeof fe=="string"&&(fe.toLowerCase()==="continue"||fe.includes("Continue Anyway"))?zn=zn.filter(At=>At!==Q):We=typeof fe=="string"?fe:fe?.label||fe?.id||"",We&&(w.length>0&&w[w.length-1].role==="user"?w[w.length-1].text+=`
649
+ ${nt}${Os}${Zo}${Bi}${Ls}[user prompt] ${Ue.trim()} [/user prompt]`.trim();let Fs={role:"user",text:ei};Jo&&(Fs.binaryPart=Jo),w.forEach(b=>{b.text&&b.role==="agent"&&(b.text=Ht(b.text))}),w.push(Fs),nt&&t[t.length-1]?.id&&(yield{type:"summary_injected",content:{id:t[t.length-1].id,text:ei}});let Qt=null,Zt=a==="Flux"?50:15;Zt=a.toLowerCase().includes("cu")?75:Zt;let Bs=(p?.loopLimits||"Default").toLowerCase();if(Bs==="extended")Zt=Math.floor(Zt*3);else if(Bs==="env"){let b=parseInt(process.env.FLUXFLOW_MAX_LOOPS||process.env.MAX_LOOPS||"",10);Number.isFinite(b)&&b>0&&(Zt=b)}let Ea=Math.floor(Zt/2),Us=0,fn=16;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Consulting the spirits":"Connecting"},xt=!1;let Ui=[],ti=!1,Ws=!1,Xn=[],Wi=!1;for(let b=0;b<=Zt;b++){let ge=Math.floor(Zt*.95);if(b>=ge&&Us<ge&&typeof n?.onAskUser=="function"){Us=ge;try{let K="Agent has been running for a long time. Do you want to continue execution?",Q=[{id:"continue",label:"Continue",description:"Add few more steps"},{id:"cancel",label:"Cancel",description:"Stop extending and finish current turn limit"}],E=await n.onAskUser(K,Q);E&&(E.toLowerCase().includes("continue")||E==="Continue")&&(Zt+=Ea)}catch{}}if(Xn.length>=10&&typeof n?.onAskUser=="function"){let K={},Q=null;for(let E of Xn)if(K[E]=(K[E]||0)+1,K[E]>=10){Q=E;break}if(Q)try{let E="Agent seems stuck in a tool loop. You can prompt it to steer or break the loop:",gt=[{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"}],fe=await n.onAskUser(E,gt);if(fe){let We="";typeof fe=="string"&&(fe.toLowerCase()==="stop"||fe.includes("Stop Loop"))?We="Stop repeating the same action call. Acknowledge what failed or succeeded, summarize your current findings, and conclude.":typeof fe=="string"&&(fe.toLowerCase()==="continue"||fe.includes("Continue Anyway"))?Xn=Xn.filter(Ct=>Ct!==Q):We=typeof fe=="string"?fe:fe?.label||fe?.id||"",We&&(w.length>0&&w[w.length-1].role==="user"?w[w.length-1].text+=`
649
650
 
650
- [STEERING HINT from USER, High Priority] ${We.trim()} [/STEERING HINT]`:w.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${We.trim()} [/STEERING HINT]`}),yield{type:"status",content:"Steering Hint Injected..."},zn=zn.filter(At=>At!==Q))}}catch{}}let kt=await qi("agent",n);if(!kt.allowed)throw new Error(kt.reason||`Budget Exhausted for Provider (${i||"Agent"})`);let le=[];if(Jo=!1,(a==="ICU"||a==="FluxCU")&&!Fi)try{yield{type:"status",content:"Capturing Screen"},await new Promise(E=>setTimeout(E,1e3));let{captureGriddedScreenshot:j}=await import("./screen_grid-SUWYGRSE.js"),Q=await j();if(Q&&Q.base64){let E="[system] Fresh Gridded Screen Feedback Captured. Use numeric coordinates. Old screenshots will be removed when new screenshot is captured, summarize in text if context is needed later [/system]",gt={inlineData:{mimeType:Q.mimeType,data:Q.base64}},fe=p?.imageHistoryCU||"Standard",We=fe==="Low"?3:fe==="Extended"?10:fe==="Max"?999:5,At=w.filter(me=>Array.isArray(me.parts)&&me.parts.some(St=>St.inlineData));if(At.length>=We){let me=At.length-We+1;for(let St=0;St<me;St++){let ot=At[St];Array.isArray(ot.parts)&&(ot.parts=ot.parts.filter(mt=>!mt.inlineData))}}if(w.length>0&&w[w.length-1].role==="user"){let me=w[w.length-1];typeof me.text=="string"&&(me.text+=`
651
+ [STEERING HINT from USER, High Priority] ${We.trim()} [/STEERING HINT]`:w.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${We.trim()} [/STEERING HINT]`}),yield{type:"status",content:"Steering Hint Injected..."},Xn=Xn.filter(Ct=>Ct!==Q))}}catch{}}let Tt=await Ji("agent",n);if(!Tt.allowed)throw new Error(Tt.reason||`Budget Exhausted for Provider (${i||"Agent"})`);let le=[];if(ti=!1,(a==="ICU"||a==="FluxCU")&&!Wi)try{yield{type:"status",content:"Capturing Screen"},await new Promise(E=>setTimeout(E,1e3));let{captureGriddedScreenshot:K}=await import("./screen_grid-3FHYFJVG.js"),Q=await K();if(Q&&Q.base64){let E="[system] Fresh Gridded Screen Feedback Captured. Use numeric coordinates. Old screenshots will be removed when new screenshot is captured, summarize in text if context is needed later [/system]",gt={inlineData:{mimeType:Q.mimeType,data:Q.base64}},fe=p?.imageHistoryCU||"Standard",We=fe==="Low"?3:fe==="Extended"?10:fe==="Max"?999:5,Ct=w.filter(me=>Array.isArray(me.parts)&&me.parts.some(St=>St.inlineData));if(Ct.length>=We){let me=Ct.length-We+1;for(let St=0;St<me;St++){let it=Ct[St];Array.isArray(it.parts)&&(it.parts=it.parts.filter(mt=>!mt.inlineData))}}if(w.length>0&&w[w.length-1].role==="user"){let me=w[w.length-1];typeof me.text=="string"&&(me.text+=`
651
652
 
652
- ${E}`,Array.isArray(me.parts)||(me.parts=[{text:me.text}]),me.parts.push(gt))}else w.push({role:"user",text:E,parts:[{text:E},gt]})}}catch(j){console.error("Vision screenshot capture error:",j)}if(Fi=!1,b>0?yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Haunting":"Working"}:yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Consulting the spirits":"Connecting"},xt){try{let{clearPendingNudges:j}=await import("./subagent_state-LZCOZSUJ.js");j()}catch{}yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
653
+ ${E}`,Array.isArray(me.parts)||(me.parts=[{text:me.text}]),me.parts.push(gt))}else w.push({role:"user",text:E,parts:[{text:E},gt]})}}catch(K){console.error("Vision screenshot capture error:",K)}if(Wi=!1,b>0?yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Haunting":"Working"}:yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Consulting the spirits":"Connecting"},xt){try{let{clearPendingNudges:K}=await import("./subagent_state-LZCOZSUJ.js");K()}catch{}yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
653
654
 
654
- \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}try{let{consumePendingNudges:j}=await import("./subagent_state-LZCOZSUJ.js"),Q=j();if(Q&&Q.length>0){let E=Q.join(`
655
+ \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}try{let{consumePendingNudges:K}=await import("./subagent_state-LZCOZSUJ.js"),Q=K();if(Q&&Q.length>0){let E=Q.join(`
655
656
 
656
657
  `);w.length>0&&w[w.length-1].role==="user"?w[w.length-1].text+=`
657
658
 
658
- ${E}`:w.push({role:"user",text:E}),yield{type:"status",content:"Subagent Update"}}}catch{}if(s){let j=await s();j&&(j.startsWith("/btw")?w.length>0&&w[w.length-1].role==="user"?w[w.length-1].text+=`
659
+ ${E}`:w.push({role:"user",text:E}),yield{type:"status",content:"Subagent Update"}}}catch{}if(s){let K=await s();K&&(K.startsWith("/btw")?w.length>0&&w[w.length-1].role==="user"?w[w.length-1].text+=`
659
660
 
660
661
  [system] User question. Resolve this specific query within '[ANSWER]...[/ANSWER]' concisely, naturally [/system]
661
- [question] ${j.replace("/btw","").trim()} [/question]`:w.push({role:"user",text:`[system] User question. Resolve this specific query within '[ANSWER]...[/ANSWER]' concisely, naturally [/system]
662
- [question] ${j.replace("/btw","").trim()} [/question]`}):w.length>0&&w[w.length-1].role==="user"?w[w.length-1].text+=`
662
+ [question] ${K.replace("/btw","").trim()} [/question]`:w.push({role:"user",text:`[system] User question. Resolve this specific query within '[ANSWER]...[/ANSWER]' concisely, naturally [/system]
663
+ [question] ${K.replace("/btw","").trim()} [/question]`}):w.length>0&&w[w.length-1].role==="user"?w[w.length-1].text+=`
663
664
 
664
- [STEERING HINT from USER, High Priority] ${j.trim()} [/STEERING HINT]`:w.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${j.trim()} [/STEERING HINT]`}),yield{type:"status",content:`${j.startsWith("/btw")?"Question Forwarded...":"Steering Hint Injected..."}`})}let H,Se=!1,$e=1,nt=1,Bt=Date.now(),Tt=null,be="",Ut=null,bo=null,qn=null,Yn=0,je=[],Et=0,Pn=!1,Wt=!1,Xn=!1,Gt=!1,$n=!0,ro=0,bt="",pe="",Qe=!1,_t=!1,Be=!0,J=e,Le="",nn=d;for(d=d.toLowerCase()==="max"?"High":d;$e<=fn&&nt<=fn&&!Se&&!xt;){let j=!1;try{be="",$n&&(process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07"),yield{type:"turn_reset",content:!0},$n=!1,nt===1&&(bt=""));let Q=u=>{if(!u||typeof u!="string")return u;let S="",T=Rs(u);if(T&&(S=T.fullBlock,u=T.remainingText),!u.includes("[tool:")&&!u.includes("[action:"))return(p?.keepReasoningContext?S:"")+u;if(Kn(u).length===0){let y=_i(u);return(p?.keepReasoningContext?S:"")+y}u=u.replace(El,(y,A)=>A.includes("[tool:")||A.includes("[action:")?A.trim():y);let ie="",P=0,z=[],yt="";for(;P<u.length;){let y=u.indexOf("[tool:",P),A=u.indexOf("[action:",P),ne=-1;if(y!==-1&&A!==-1?ne=Math.min(y,A):y!==-1?ne=y:ne=A,ne===-1){z.length===0&&(ie+=_i(u.substring(P)));break}if((ne>0?u[ne-1]:"")==="`"){ie+=_i(u.substring(P,ne+1)),P=ne+1;continue}z.length===0&&(yt=_i(u.substring(P,ne)));let Z=-1,v=null,Ct=0;for(let It=ne;It<u.length;It++){let ut=u[It];if(v){if(ut===v){let Ze=0;for(let se=It-1;se>=0&&u[se]==="\\";se--)Ze++;Ze%2===0&&(v=null)}}else if(ut==='"'||ut==="'"||ut==="`")v=ut;else if(ut==="(")Ct++;else if(ut===")")Ct--;else if(ut==="]"&&Ct<=0){Z=It;break}}if(Z===-1){z.length===0&&(ie+=u.substring(ne));break}let On=u.substring(ne,Z+1);z.push(On),P=Z+1}return z.length>0&&(ie=yt.trimEnd()?yt.trimEnd()+`
665
+ [STEERING HINT from USER, High Priority] ${K.trim()} [/STEERING HINT]`:w.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${K.trim()} [/STEERING HINT]`}),yield{type:"status",content:`${K.startsWith("/btw")?"Question Forwarded...":"Steering Hint Injected..."}`})}let j,ke=!1,Pe=1,ot=1,Ft=Date.now(),At=null,be="",Bt=null,Ao=null,Jn=null,Qn=0,je=[],_t=0,$n=!1,Ut=!1,Zn=!1,Wt=!1,Ln=!0,fo=0,bt="",pe="",Je=!1,It=!1,Fe=!0,J=e,$e="",en=d;for(d=d.toLowerCase()==="max"?"High":d;Pe<=fn&&ot<=fn&&!ke&&!xt;){let K=!1;try{be="",Ln&&(process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07"),yield{type:"turn_reset",content:!0},Ln=!1,ot===1&&(bt=""));let Q=u=>{if(!u||typeof u!="string")return u;let S="",k=_s(u);if(k&&(S=k.fullBlock,u=k.remainingText),!u.includes("[tool:")&&!u.includes("[action:"))return(p?.keepReasoningContext?S:"")+u;if(Vn(u).length===0){let y=$i(u);return(p?.keepReasoningContext?S:"")+y}u=u.replace(El,(y,T)=>T.includes("[tool:")||T.includes("[action:")?T.trim():y);let ie="",L=0,q=[],yt="";for(;L<u.length;){let y=u.indexOf("[tool:",L),T=u.indexOf("[action:",L),ne=-1;if(y!==-1&&T!==-1?ne=Math.min(y,T):y!==-1?ne=y:ne=T,ne===-1){q.length===0&&(ie+=$i(u.substring(L)));break}if((ne>0?u[ne-1]:"")==="`"){ie+=$i(u.substring(L,ne+1)),L=ne+1;continue}q.length===0&&(yt=$i(u.substring(L,ne)));let Z=-1,v=null,Rt=0;for(let Mt=ne;Mt<u.length;Mt++){let ut=u[Mt];if(v){if(ut===v){let Qe=0;for(let se=Mt-1;se>=0&&u[se]==="\\";se--)Qe++;Qe%2===0&&(v=null)}}else if(ut==='"'||ut==="'"||ut==="`")v=ut;else if(ut==="(")Rt++;else if(ut===")")Rt--;else if(ut==="]"&&Rt<=0){Z=Mt;break}}if(Z===-1){q.length===0&&(ie+=u.substring(ne));break}let Nn=u.substring(ne,Z+1);q.push(Nn),L=Z+1}return q.length>0&&(ie=yt.trimEnd()?yt.trimEnd()+`
665
666
 
666
- `+z.join(`
667
+ `+q.join(`
667
668
 
668
- `):z.join(`
669
+ `):q.join(`
669
670
 
670
- `)),(p?.keepReasoningContext?S:"")+ie},E=w.filter(u=>(u.role==="user"||u.role==="agent"||u.role==="system")&&!String(u.id).startsWith("welcome")&&!u.isMeta&&!u.isTerminalRecord&&!(u.text&&u.text.startsWith("[TERMINAL_RECORD]"))).map((u,S,T)=>{let V=u.text||"";M||(V=V.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),u.role==="agent"&&(V=Q(V),V=V.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),V=V.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*"));let ie=[];return Array.isArray(u.parts)&&u.parts.length>0?ie=u.parts.map(P=>{if(P.text){let z=P.text;return M||(z=z.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),u.role==="agent"&&(z=Q(z),z=z.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),z=z.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*")),{text:z}}return P}):ie=[{text:V}],u.binaryPart&&et(J)&&T.slice(S+1).filter(z=>z.role==="user"&&!z.text?.startsWith("[ACTION RESULT]")&&!z.text?.startsWith("[TOOL RESULT]")).length<=2&&ie.push(u.binaryPart),{role:u.role==="user"||u.role==="system"?"user":"model",parts:ie}});for(let u=E.length-2;u>=0;u--){let S=E[u],T=E[u+1];S.role==="user"&&T.role==="user"&&(T.parts?.[0]?.text||"").trim().startsWith("[SYSTEM")&&E.splice(u,1)}let gt=[];for(let u=0;u<E.length;u++){let S=E[u];if(gt.length===0)gt.push(S);else{let T=gt[gt.length-1];T.role===S.role?(T.parts[0].text+=`
671
+ `)),(p?.keepReasoningContext?S:"")+ie},E=w.filter(u=>(u.role==="user"||u.role==="agent"||u.role==="system")&&!String(u.id).startsWith("welcome")&&!u.isMeta&&!u.isTerminalRecord&&!(u.text&&u.text.startsWith("[TERMINAL_RECORD]"))).map((u,S,k)=>{let z=u.text||"";P||(z=z.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),u.role==="agent"&&(z=Q(z),z=z.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),z=z.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*"));let ie=[];return Array.isArray(u.parts)&&u.parts.length>0?ie=u.parts.map(L=>{if(L.text){let q=L.text;return P||(q=q.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),u.role==="agent"&&(q=Q(q),q=q.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),q=q.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*")),{text:q}}return L}):ie=[{text:z}],u.binaryPart&&Ze(J)&&k.slice(S+1).filter(q=>q.role==="user"&&!q.text?.startsWith("[ACTION RESULT]")&&!q.text?.startsWith("[TOOL RESULT]")).length<=2&&ie.push(u.binaryPart),{role:u.role==="user"||u.role==="system"?"user":"model",parts:ie}});for(let u=E.length-2;u>=0;u--){let S=E[u],k=E[u+1];S.role==="user"&&k.role==="user"&&(k.parts?.[0]?.text||"").trim().startsWith("[SYSTEM")&&E.splice(u,1)}let gt=[];for(let u=0;u<E.length;u++){let S=E[u];if(gt.length===0)gt.push(S);else{let k=gt[gt.length-1];k.role===S.role?(k.parts[0].text+=`
671
672
 
672
- `+(S.parts?.[0]?.text||""),S.parts?.length>1&&T.parts.push(...S.parts.slice(1))):gt.push(S)}}for(let u of gt)for(let S of u.parts||[])S&&typeof S.text=="string"&&(S.text.includes("[action:")||S.text.includes("[tool:"))&&(S.text=S.text.replace(/```(?:[a-zA-Z0-9_-]+)?\s*\n?(\[(?:action|tool):[\s\S]*?\)\s*\])\n?```/gi,"$1"),S.text=S.text.replace(/`(\[(?:action|tool):[\s\S]*?\)\s*\])`/gi,"$1"));E.length=0,E.push(...gt),J=e;let fe=`${f}|${i}|${a}|${d}|${nn}|${J}|${JSON.stringify(r)}|${!!p?.dynamicDirAwareness}|${!!p?.subAgents}|${process.env.rawReasoning==="true"}`,We=no.key===fe&&no.value;if((process.env.I_HAVE_TOO_MUCH_MONEY==="true"||process.env.I_HAVE_TOO_MUCH_MONEY===!0)&&(We=!1),We)Le=no.value;else{let u=i==="Mistral"?!!ai(J):!(J||"gemma").toLowerCase().startsWith("gemma");Le=Fr(r,((J||"gemma").toLowerCase().startsWith("gemma"),nn),a,p,M,L,i,i==="Google"?!0:C,u,f,!!p?.keepReasoningContext,J),p?.dynamicDirAwareness||(Le+=`
673
- ${Aa.replace(`
673
+ `+(S.parts?.[0]?.text||""),S.parts?.length>1&&k.parts.push(...S.parts.slice(1))):gt.push(S)}}for(let u of gt)for(let S of u.parts||[])S&&typeof S.text=="string"&&(S.text.includes("[action:")||S.text.includes("[tool:"))&&(S.text=S.text.replace(/```(?:[a-zA-Z0-9_-]+)?\s*\n?(\[(?:action|tool):[\s\S]*?\)\s*\])\n?```/gi,"$1"),S.text=S.text.replace(/`(\[(?:action|tool):[\s\S]*?\)\s*\])`/gi,"$1"));E.length=0,E.push(...gt),J=e;let fe=`${f}|${i}|${a}|${d}|${en}|${J}|${JSON.stringify(r)}|${!!p?.dynamicDirAwareness}|${!!p?.subAgents}|${process.env.rawReasoning==="true"}`,We=so.key===fe&&so.value;if((process.env.I_HAVE_TOO_MUCH_MONEY==="true"||process.env.I_HAVE_TOO_MUCH_MONEY===!0)&&(We=!1),We)$e=so.value;else{let u=i==="Mistral"?!!fi(J):!(J||"gemma").toLowerCase().startsWith("gemma");$e=Br(r,((J||"gemma").toLowerCase().startsWith("gemma"),en),a,p,P,M,i,i==="Google"?!0:C,u,f,!!p?.keepReasoningContext,J),p?.dynamicDirAwareness||($e+=`
674
+ ${Pn.replace(`
674
675
  **Directory**`,`
675
- -- Directory --`)}`),no.key=fe,no.value=Le}let me=E[E.length-1];if(yo()&b>0){await new Promise(V=>setTimeout(V,2500)),yield{type:"status",content:"Verifying"};let u=await to(),S=u?u.diagnostics:null,T=Is(u?.comments);S&&me&&me.role==="user"&&me.parts?.[0]?.text&&(me.parts[0].text+=`
676
+ -- Directory --`)}`),so.key=fe,so.value=$e}let me=E[E.length-1];if(So()&b>0){await new Promise(z=>setTimeout(z,2500)),yield{type:"status",content:"Verifying"};let u=await io(),S=u?u.diagnostics:null,k=Oi(u?.comments);S&&me&&me.role==="user"&&me.parts?.[0]?.text&&(me.parts[0].text+=`
676
677
 
677
- ${S}`),Pi&&me&&me.role==="user"&&me.parts?.[0]?.text&&(me.parts[0].text+=`
678
+ ${S}`),lo&&me&&me.role==="user"&&me.parts?.[0]?.text&&(me.parts[0].text+=`
678
679
 
679
680
  [Additional Comments]
680
- ${T}`),yield{type:"status",content:"Working"}}let St=i==="Mistral"||i==="Google"&&e?.toLowerCase().startsWith("gemma");if(p?.advanceRollback&&me&&me.role==="user"&&(me.parts?.[0]?.text?.startsWith("[ACTION RESULT]")||me.parts?.[0]?.text?.startsWith("[TOOL RESULT]")))try{let u=await Mo.getLatestFileChanges(f);if(u&&(u.newFiles.length>0||u.modifiedFiles.length>0||u.deletedFiles.length>0)){let S=`
681
+ ${k}`),yield{type:"status",content:"Working"}}let St=i==="Mistral"||i==="Google"&&e?.toLowerCase().startsWith("gemma");if(p?.advanceRollback&&me&&me.role==="user"&&(me.parts?.[0]?.text?.startsWith("[ACTION RESULT]")||me.parts?.[0]?.text?.startsWith("[TOOL RESULT]")))try{let u=await Oo.getLatestFileChanges(f);if(u&&(u.newFiles.length>0||u.modifiedFiles.length>0||u.deletedFiles.length>0)){let S=`
681
682
  [system] File Changes:
682
- `;for(let V of u.newFiles)S+=`* ${V} (created)
683
- `;for(let V of u.modifiedFiles)S+=`* ${V} (modified)
684
- `;for(let V of u.deletedFiles)S+=`* ${V} (deleted)
685
- `;S+="[/system]",me.parts[0].text+=S;let T=-1;for(let V=w.length-1;V>=0;V--)if(w[V].role==="user"&&(w[V].text?.startsWith("[ACTION RESULT]")||w[V].text?.startsWith("[TOOL RESULT]"))){T=V;break}T!==-1&&(w[T].text+=S)}}catch{}let ot=Math.floor(tn*.99),mt=b+1;if(mt>=ot&&me&&me.parts?.[0]&&(me.parts[0].text+=`
686
- [system] WARNING, Turn Limit Impending: Step ${mt}/${tn}. 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 u=U.join(eo,"chats",String(f));we.existsSync(u)||we.mkdirSync(u,{recursive:!0}),we.writeFileSync(U.join(u,"context.json"),JSON.stringify({contents:E},null,2)),we.writeFileSync(U.join(u,"system.md"),`${We?"CACHED":"NOT CACHED"}
683
+ `;for(let z of u.newFiles)S+=`* ${z} (created)
684
+ `;for(let z of u.modifiedFiles)S+=`* ${z} (modified)
685
+ `;for(let z of u.deletedFiles)S+=`* ${z} (deleted)
686
+ `;S+="[/system]",me.parts[0].text+=S;let k=-1;for(let z=w.length-1;z>=0;z--)if(w[z].role==="user"&&(w[z].text?.startsWith("[ACTION RESULT]")||w[z].text?.startsWith("[TOOL RESULT]"))){k=z;break}k!==-1&&(w[k].text+=S)}}catch{}let it=Math.floor(Zt*.99),mt=b+1;if(mt>=it&&me&&me.parts?.[0]&&(me.parts[0].text+=`
687
+ [system] WARNING, Turn Limit Impending: Step ${mt}/${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 u=B.join(oo,"chats",String(f));xe.existsSync(u)||xe.mkdirSync(u,{recursive:!0}),xe.writeFileSync(B.join(u,"context.json"),JSON.stringify({contents:E},null,2)),xe.writeFileSync(B.join(u,"system.md"),`${We?"CACHED":"NOT CACHED"}
687
688
  Key: ${fe}
688
689
  --------------------------------------------------------------------
689
690
 
690
- ${Le}`)}let rt=new Promise((u,S)=>{B.signal.aborted&&S(new DOMException("The user aborted a request.","AbortError")),B.signal.addEventListener("abort",()=>{S(new DOMException("The user aborted a request.","AbortError"))})});rt.catch(()=>{});let _e=E;if(Bt=Date.now(),i==="Ollama")H=(await de("Ollama"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1,p?.ollamaEndpoint||"Cloud");else if(i==="OpenRouter")H=(await de("OpenRouter"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1,f);else if(i==="DeepSeek")H=(await de("DeepSeek"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="Mistral")H=(await de("Mistral"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1,f);else if(i==="NVIDIA"){let u=(await de("NVIDIA"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);H=(await de("NVIDIA_wrap"))(u,J)}else if(i==="InferX")H=(await de("InferX"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="SenseNova")H=(await de("SenseNova"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="AIHubMix")H=(await de("AIHubMix"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="Poolside")H=(await de("Poolside"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="9router"||i==="9Router")H=(await de("NineRouter"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="ExpLabs"||i==="ExperientialLabs")H=(await de("ExpLabs"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="Numes"||i==="numes")H=(await de("Numes"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1,f);else if(i==="Infron"||i==="infron")H=(await de("Infron"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="TokenHarbor"||i==="Token Harbor"||i==="tokenharbor"||i==="token_harbor"||i==="thk")H=(await de("TokenHarbor"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="APInex"||i==="apinex"||i==="apx")H=(await de("APInex"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="xKiro"||i==="xkiro"||i==="kiro")H=(await de("xKiro"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="CoArena"||i==="coarena")H=(await de("CoArena"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="c_openai"||i==="Custom (OpenAI)"){let u=p?.customOpenAIBaseUrl||"";try{u=await Vi("c_openai")||u}catch{}H=(await de("c_openai"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1,u)}else{let u=Sa(n?.apiKey),{serviceTier:S,cleanModel:T}=Ta(J),V={systemInstruction:Le,mediaResolution:"MEDIA_RESOLUTION_HIGH",safetySettings:[{category:Ei.HARM_CATEGORY_HARASSMENT,threshold:vi.BLOCK_NONE},{category:Ei.HARM_CATEGORY_HATE_SPEECH,threshold:vi.BLOCK_NONE},{category:Ei.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:vi.BLOCK_NONE},{category:Ei.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:vi.BLOCK_NONE}],temperature:1.05,thinkingConfig:(()=>{let P=er("Google",J||"gemini-3-flash-preview",d);if(P!==null){if(typeof P=="object")return P;if(P===!1||P==="false"||P==="none"||P===0||P==="0")return{includeThoughts:!1};if(typeof P=="number")return{includeThoughts:!0,thinkingBudget:P};if(typeof P=="string"){let A=P.toLowerCase();if(A==="minimal")return{includeThoughts:!0,thinkingLevel:Ye.MINIMAL};if(A==="low")return{includeThoughts:!0,thinkingLevel:Ye.LOW};if(A==="medium")return{includeThoughts:!0,thinkingLevel:Ye.MEDIUM};if(A==="high")return{includeThoughts:!0,thinkingLevel:Ye.HIGH};let ne=Number(P);if(!isNaN(ne))return{includeThoughts:!0,thinkingBudget:ne}}}let z=(J||"").toLowerCase(),yt=z.includes("gemma-4")||z.startsWith("gemma"),y=z.includes("gemini-3");if(yt||y)return yt?d.toLowerCase()!=="high"?{includeThoughts:!1,thinkingLevel:Ye.MINIMAL}:{includeThoughts:!0,thinkingLevel:Ye.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:z.includes("pro")?Ye.LOW:Ye.MINIMAL,Low:Ye.LOW,Medium:Ye.MEDIUM,Standard:Ye.MEDIUM,High:Ye.HIGH,xHigh:Ye.HIGH}[d]||Ye.MEDIUM};{let A={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[d]||2048;return A===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:A}}})()};S&&(V.serviceTier=S);let ie=u.models.generateContentStream({model:T||"gemini-3-flash-preview",contents:_e,config:V},{signal:B.signal});H=await Promise.race([ie,rt])}be="",Ut=null,qn=null,je=[],Et=0,yield{type:"model_update",content:null},pe="",Qe=bt.length>0;let pt="",Qo=Date.now(),un=async function*(){if(i==="Google"&&pt){let u=ko(pt);for(let S of u)yield S;pt="",Qo=Date.now()}},Ws=!0,An="",ao=!1,ht=null,Gs=!1,Qn=!1,lo=!1,Zo=!1,Ln=!1,So=u=>{let S=0;for(;S+2<u.length;)u[S]==="`"&&u[S+1]==="`"&&u[S+2]==="`"?(Zo=!Zo,S+=3):S++},Hs=u=>{if(!u)return;let S=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,T;for(;(T=S.exec(u))!==null;){let V=T[0].toLowerCase();V.startsWith("</")||V.startsWith("[/")||V==="<channel|>"?Ln=!1:Ln=!0}},$a={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|>"}},ko=u=>{let S=[],T=u,V=ie=>{if(!ie)return;if(!Gs){S.push({type:"text",content:ie}),So(ie),Hs(ie);return}let P=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,z=0,yt;for(;(yt=P.exec(ie))!==null;){let A=ie.substring(z,yt.index);if(A)if(So(A),Ln)S.push({type:"text",content:A});else{let Ie=A.replace(/[^\r\n]/g,"");Ie&&S.push({type:"text",content:Ie})}let ne=yt[0];So(ne);let l=ne.toLowerCase();l.startsWith("</")||l.startsWith("[/")||l==="<channel|>"?Ln=!1:Ln=!0,S.push({type:"text",content:ne}),z=P.lastIndex}let y=ie.substring(z);if(y)if(So(y),Ln)S.push({type:"text",content:y});else{let A=y.replace(/[^\r\n]/g,"");A&&S.push({type:"text",content:A})}};for(;T.length>0;)if(ao){let ie=An+T,P=$a[ht];if(P){let y=!1;if(ie.length<P.startPrefix.length?P.startPrefix.startsWith(ie)||(y=!0):ie.startsWith(P.startPrefix)?ie.length>=P.fullPrefix.length&&!ie.startsWith(P.fullPrefix)&&(y=!0):y=!0,y){V(ie),An="",ao=!1,ht=null,Qn=!1,lo=!1,T="";break}}let z=-1,yt=P?P.endTag:"]";if(ht==="tool"||ht==="action"){let y=0,A=null,ne=0,l=!1;for(let Ie=0;Ie<ie.length;Ie++){let Z=ie[Ie];if(A){if(Z===A){let v=0;for(let Ct=Ie-1;Ct>=0&&ie[Ct]==="\\";Ct--)v++;v%2===0&&(A=null)}}else if(Z==='"'||Z==="'")A=Z;else if(Z==="`")if(Qn){z=Ie;break}else A=Z;else if(Z==="(")y++,l=!0;else if(Z===")")y--;else if(Z==="]"&&l&&y===0){z=Ie;break}}}else z=ie.indexOf(yt);if(z!==-1){let y=yt.length,A=ie.substring(0,z+y);ht?.startsWith("kimi")||S.push({type:"text",content:A}),So(A),Hs(A),(ht==="tool"||ht==="action"||ht?.startsWith("kimi"))&&!Qn&&!lo&&(Gs=!0,zn.push(A.trim())),Qn=!1,lo=!1,An="",ao=!1,ht=null,T=ie.substring(z+y)}else{An=ie,T="";break}}else{let ie=T.indexOf("[tool"),P=T.indexOf("[action"),z=T.indexOf("[[END]]"),yt=T.indexOf("<|tool_calls_section_begin|>"),y=T.indexOf("<|tool_call_begin|>"),A=[{type:"tool",idx:ie,start:"[tool",end:"]"},{type:"action",idx:P,start:"[action",end:"]"},{type:"end",idx:z,start:"[[END]]",end:"[[END]]"},{type:"kimi_section",idx:yt,start:"<|tool_calls_section_begin|>",end:"<|tool_calls_section_end|>"},{type:"kimi_call",idx:y,start:"<|tool_call_begin|>",end:"<|tool_call_end|>"}].filter(ne=>ne.idx!==-1).sort((ne,l)=>ne.idx-l.idx);if(A.length>0){let ne=A[0],l=T.substring(0,ne.idx);ne.idx>0&&V(l);let Ie=ne.idx>0?T[ne.idx-1]:"";Qn=Zo||Ie==="`",lo=Ln,ao=!0,ht=ne.type,An="",T=T.substring(ne.idx)}else{let ne=["[tool","[action","[[END]]","<|tool_calls_section_begin|>","<|tool_call_begin|>"],l=-1;for(let Ie of ne){for(let Z=Ie.length-1;Z>0;Z--)if(T.endsWith(Ie.substring(0,Z))){l=T.length-Z;let v=ne.indexOf(Ie);v===0?ht="tool":v===1?ht="action":v===2?ht="end":v===3?ht="kimi_section":ht="kimi_call";break}if(l!==-1)break}if(l!==-1){if(l>0){let Z=T.substring(0,l);V(Z)}let Ie=l>0?T[l-1]:"";Qn=Zo||Ie==="`",lo=Ln,ao=!0,An=T.substring(l),T=""}else{V(T);break}}}return S},La=H[Symbol.asyncIterator]();for(;;){let{value:u,done:S}=await Promise.race([La.next(),rt]);if(S)break;if(u&&u.type==="status"){yield u;continue}let T="",V=u.candidates?.[0]?.content?.parts;if(V&&V.length>0)for(let P of V){let z=typeof P.text=="string"?P.text:P.text?parseChunkText(P.text):"";P.thought?z&&(j||(T+="<think_fluxflow>",j=!0),T+=z):z&&(j&&(T+="</think_fluxflow>",j=!1),T+=z)}else u.text&&j&&(T+="</think_fluxflow>",j=!1);T=Al(T);let ie=T?Yi(T):0;if(n&&typeof n.onTokenChunk=="function"&&n.onTokenChunk(T,ie),Ws&&(Tt===null&&(Tt=Date.now()-Bt),yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"},Ws=!1),xt){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
691
+ ${$e}`)}let lt=new Promise((u,S)=>{W.signal.aborted&&S(new DOMException("The user aborted a request.","AbortError")),W.signal.addEventListener("abort",()=>{S(new DOMException("The user aborted a request.","AbortError"))})});lt.catch(()=>{});let _e=E;if(Ft=Date.now(),i==="Ollama")j=(await de("Ollama"))(n.apiKey,J,_e,$e,d,a,C,W.signal,1,p?.ollamaEndpoint||"Cloud");else if(i==="OpenRouter")j=(await de("OpenRouter"))(n.apiKey,J,_e,$e,d,a,C,W.signal,1,f);else if(i==="DeepSeek")j=(await de("DeepSeek"))(n.apiKey,J,_e,$e,d,a,C,W.signal,1);else if(i==="Mistral")j=(await de("Mistral"))(n.apiKey,J,_e,$e,d,a,C,W.signal,1,f);else if(i==="NVIDIA"){let u=(await de("NVIDIA"))(n.apiKey,J,_e,$e,d,a,C,W.signal,1);j=(await de("NVIDIA_wrap"))(u,J)}else if(i==="InferX")j=(await de("InferX"))(n.apiKey,J,_e,$e,d,a,C,W.signal,1);else if(i==="SenseNova")j=(await de("SenseNova"))(n.apiKey,J,_e,$e,d,a,C,W.signal,1);else if(i==="AIHubMix")j=(await de("AIHubMix"))(n.apiKey,J,_e,$e,d,a,C,W.signal,1);else if(i==="Poolside")j=(await de("Poolside"))(n.apiKey,J,_e,$e,d,a,C,W.signal,1);else if(i==="9router"||i==="9Router")j=(await de("NineRouter"))(n.apiKey,J,_e,$e,d,a,C,W.signal,1);else if(i==="ExpLabs"||i==="ExperientialLabs")j=(await de("ExpLabs"))(n.apiKey,J,_e,$e,d,a,C,W.signal,1);else if(i==="Numes"||i==="numes")j=(await de("Numes"))(n.apiKey,J,_e,$e,d,a,C,W.signal,1,f);else if(i==="Infron"||i==="infron")j=(await de("Infron"))(n.apiKey,J,_e,$e,d,a,C,W.signal,1);else if(i==="TokenHarbor"||i==="Token Harbor"||i==="tokenharbor"||i==="token_harbor"||i==="thk")j=(await de("TokenHarbor"))(n.apiKey,J,_e,$e,d,a,C,W.signal,1);else if(i==="APInex"||i==="apinex"||i==="apx")j=(await de("APInex"))(n.apiKey,J,_e,$e,d,a,C,W.signal,1);else if(i==="xKiro"||i==="xkiro"||i==="kiro")j=(await de("xKiro"))(n.apiKey,J,_e,$e,d,a,C,W.signal,1);else if(i==="CoArena"||i==="coarena")j=(await de("CoArena"))(n.apiKey,J,_e,$e,d,a,C,W.signal,1);else if(i==="c_openai"||i==="Custom (OpenAI)"){let u=p?.customOpenAIBaseUrl||"";try{u=await Yi("c_openai")||u}catch{}j=(await de("c_openai"))(n.apiKey,J,_e,$e,d,a,C,W.signal,1,u)}else{let u=ka(n?.apiKey),{serviceTier:S,cleanModel:k}=Aa(J),z={systemInstruction:$e,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 L=tr("Google",J||"gemini-3-flash-preview",d);if(L!==null){if(typeof L=="object")return L;if(L===!1||L==="false"||L==="none"||L===0||L==="0")return{includeThoughts:!1};if(typeof L=="number")return{includeThoughts:!0,thinkingBudget:L};if(typeof L=="string"){let T=L.toLowerCase();if(T==="minimal")return{includeThoughts:!0,thinkingLevel:qe.MINIMAL};if(T==="low")return{includeThoughts:!0,thinkingLevel:qe.LOW};if(T==="medium")return{includeThoughts:!0,thinkingLevel:qe.MEDIUM};if(T==="high")return{includeThoughts:!0,thinkingLevel:qe.HIGH};let ne=Number(L);if(!isNaN(ne))return{includeThoughts:!0,thinkingBudget:ne}}}let q=(J||"").toLowerCase(),yt=q.includes("gemma-4")||q.startsWith("gemma"),y=q.includes("gemini-3");if(yt||y)return yt?d.toLowerCase()!=="high"?{includeThoughts:!1,thinkingLevel:qe.MINIMAL}:{includeThoughts:!0,thinkingLevel:qe.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:q.includes("pro")?qe.LOW:qe.MINIMAL,Low:qe.LOW,Medium:qe.MEDIUM,Standard:qe.MEDIUM,High:qe.HIGH,xHigh:qe.HIGH}[d]||qe.MEDIUM};{let T={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[d]||2048;return T===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:T}}})()};S&&(z.serviceTier=S);let ie=u.models.generateContentStream({model:k||"gemini-3-flash-preview",contents:_e,config:z},{signal:W.signal});j=await Promise.race([ie,lt])}be="",Bt=null,Jn=null,je=[],_t=0,yield{type:"model_update",content:null},pe="",Je=bt.length>0;let pt="",ni=Date.now(),un=async function*(){if(i==="Google"&&pt){let u=Ro(pt);for(let S of u)yield S;pt="",ni=Date.now()}},Gs=!0,An="",uo=!1,ht=null,Hs=!1,to=!1,go=!1,oi=!1,On=!1,Co=u=>{let S=0;for(;S+2<u.length;)u[S]==="`"&&u[S+1]==="`"&&u[S+2]==="`"?(oi=!oi,S+=3):S++},js=u=>{if(!u)return;let S=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,k;for(;(k=S.exec(u))!==null;){let z=k[0].toLowerCase();z.startsWith("</")||z.startsWith("[/")||z==="<channel|>"?On=!1:On=!0}},$a={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|>"}},Ro=u=>{let S=[],k=u,z=ie=>{if(!ie)return;if(!Hs){S.push({type:"text",content:ie}),Co(ie),js(ie);return}let L=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,q=0,yt;for(;(yt=L.exec(ie))!==null;){let T=ie.substring(q,yt.index);if(T)if(Co(T),On)S.push({type:"text",content:T});else{let Ie=T.replace(/[^\r\n]/g,"");Ie&&S.push({type:"text",content:Ie})}let ne=yt[0];Co(ne);let l=ne.toLowerCase();l.startsWith("</")||l.startsWith("[/")||l==="<channel|>"?On=!1:On=!0,S.push({type:"text",content:ne}),q=L.lastIndex}let y=ie.substring(q);if(y)if(Co(y),On)S.push({type:"text",content:y});else{let T=y.replace(/[^\r\n]/g,"");T&&S.push({type:"text",content:T})}};for(;k.length>0;)if(uo){let ie=An+k,L=$a[ht];if(L){let y=!1;if(ie.length<L.startPrefix.length?L.startPrefix.startsWith(ie)||(y=!0):ie.startsWith(L.startPrefix)?ie.length>=L.fullPrefix.length&&!ie.startsWith(L.fullPrefix)&&(y=!0):y=!0,y){z(ie),An="",uo=!1,ht=null,to=!1,go=!1,k="";break}}let q=-1,yt=L?L.endTag:"]";if(ht==="tool"||ht==="action"){let y=0,T=null,ne=0,l=!1;for(let Ie=0;Ie<ie.length;Ie++){let Z=ie[Ie];if(T){if(Z===T){let v=0;for(let Rt=Ie-1;Rt>=0&&ie[Rt]==="\\";Rt--)v++;v%2===0&&(T=null)}}else if(Z==='"'||Z==="'")T=Z;else if(Z==="`")if(to){q=Ie;break}else T=Z;else if(Z==="(")y++,l=!0;else if(Z===")")y--;else if(Z==="]"&&l&&y===0){q=Ie;break}}}else q=ie.indexOf(yt);if(q!==-1){let y=yt.length,T=ie.substring(0,q+y);ht?.startsWith("kimi")||S.push({type:"text",content:T}),Co(T),js(T),(ht==="tool"||ht==="action"||ht?.startsWith("kimi"))&&!to&&!go&&(Hs=!0,Xn.push(T.trim())),to=!1,go=!1,An="",uo=!1,ht=null,k=ie.substring(q+y)}else{An=ie,k="";break}}else{let ie=k.indexOf("[tool"),L=k.indexOf("[action"),q=k.indexOf("[[END]]"),yt=k.indexOf("<|tool_calls_section_begin|>"),y=k.indexOf("<|tool_call_begin|>"),T=[{type:"tool",idx:ie,start:"[tool",end:"]"},{type:"action",idx:L,start:"[action",end:"]"},{type:"end",idx:q,start:"[[END]]",end:"[[END]]"},{type:"kimi_section",idx:yt,start:"<|tool_calls_section_begin|>",end:"<|tool_calls_section_end|>"},{type:"kimi_call",idx:y,start:"<|tool_call_begin|>",end:"<|tool_call_end|>"}].filter(ne=>ne.idx!==-1).sort((ne,l)=>ne.idx-l.idx);if(T.length>0){let ne=T[0],l=k.substring(0,ne.idx);ne.idx>0&&z(l);let Ie=ne.idx>0?k[ne.idx-1]:"";to=oi||Ie==="`",go=On,uo=!0,ht=ne.type,An="",k=k.substring(ne.idx)}else{let ne=["[tool","[action","[[END]]","<|tool_calls_section_begin|>","<|tool_call_begin|>"],l=-1;for(let Ie of ne){for(let Z=Ie.length-1;Z>0;Z--)if(k.endsWith(Ie.substring(0,Z))){l=k.length-Z;let v=ne.indexOf(Ie);v===0?ht="tool":v===1?ht="action":v===2?ht="end":v===3?ht="kimi_section":ht="kimi_call";break}if(l!==-1)break}if(l!==-1){if(l>0){let Z=k.substring(0,l);z(Z)}let Ie=l>0?k[l-1]:"";to=oi||Ie==="`",go=On,uo=!0,An=k.substring(l),k=""}else{z(k);break}}}return S},La=j[Symbol.asyncIterator]();for(;;){let{value:u,done:S}=await Promise.race([La.next(),lt]);if(S)break;if(u&&u.type==="status"){yield u;continue}let k="",z=u.candidates?.[0]?.content?.parts;if(z&&z.length>0)for(let L of z){let q=typeof L.text=="string"?L.text:L.text?parseChunkText(L.text):"";L.thought?q&&(K||(k+="<think_fluxflow>",K=!0),k+=q):q&&(K&&(k+="</think_fluxflow>",K=!1),k+=q)}else u.text&&K&&(k+="</think_fluxflow>",K=!1);k=Al(k);let ie=k?Qi(k):0;if(n&&typeof n.onTokenChunk=="function"&&n.onTokenChunk(k,ie),Gs&&(At===null&&(At=Date.now()-Ft),yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"},Gs=!1),xt){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
691
692
 
692
- \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(T){if(Qe){if(pe+=T,pe.length>=64){let y=0,A=Math.min(bt.length,pe.length);for(let l=A;l>=10;l--)if(bt.endsWith(pe.substring(0,l))){y=l;break}let ne=pe.substring(y);if(ne){let Ie=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(bt)?ne.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):ne.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");if(Ie)if(be+=Ie,i==="Google")pt+=Ie;else{yield*un();let Z=ko(Ie);for(let v of Z)yield v}}Qe=!1,pe=""}continue}else if(be+=T,i==="Google")pt+=T;else{yield*un();let y=ko(T);for(let A of y)yield A}let P=Il(be);if(P.inside){_t=!0,qn||(qn=Date.now());let A={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"}[P.toolName]||P.toolName,ne=P.args||"",l=null;if(["write_file","update_file","view_file","read_folder","find_file","write_pdf","write_docx","search_keyword","generate_image","file_map","invoke","invoke_sync","get_progress","await","wait","answer"].includes(A)){let Z=O(ne,[],["path","basename","name","targetFile","TargetFile","directory","file","keyword","title","task","id","taskId","timeout","time","seconds"]),v=Z.basename||Z.name||Z.path||Z.targetFile||Z.TargetFile||Z.directory||Z.file,Ct=Z.keyword,On=Z.title||Z.task,It=Z.id||Z.taskId,ut=Z.timeout||Z.time||Z.seconds||Z.sec;if(Ct!=null)l=String(Ct).replace(_n,"");else if(v)l=U.basename(String(v).replace(_n,"").replace(da,"/"));else if(On&&(A==="invoke"||A==="invoke_sync"))l=String(On).replace(_n,"").substring(0,30);else if(It&&A==="get_progress")l=String(It).replace(_n,"");else if(ut&&A==="await"){let Ze=parseFloat(String(ut).replace(_n,""));isNaN(Ze)?l=String(ut).replace(_n,""):(Ze<5&&(Ze=5),Ze>120&&(Ze=180),l=(Mt=>{if(Mt>=60){let Nn=Math.floor(Mt/60),on=Mt%60;return`${Nn}m${on>0?` ${on}s`:""}`}return`${Mt}s`})(Ze))}else if(ut&&A==="wait"){let Ze=parseFloat(String(ut).replace(_n,""));isNaN(Ze)?l=String(ut).replace(_n,""):(Ze<10&&(Ze=10),Ze>120&&(Ze=120),l=(Mt=>{if(Mt>=60){let Nn=Math.floor(Mt/60),on=Mt%60;return`${Nn}m${on>0?` ${on}s`:""}`}return`${Mt}s`})(Ze))}else{let Ze=ne.match(Sl);if(Ze){let se=Ze[1].replace(_n,"");A==="invoke"||A==="invoke_sync"||A==="get_progress"?l=se.substring(0,30):l=A==="search_keyword"||A==="file_map"?se:U.basename(se.replace(da,"/"))}}}let Ie=`${vs[A]||A}${l?` ${l}`:""}`;if((A!==Ut||l!==bo)&&(Ut=A,bo=l,yield{type:"status",content:`${Ie}`},process.stdout.isTTY)){let v={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"}[A]||"Working";process.stdout.write(`\x1B]0;${v}...\x07`)}}if(be.length-ro>800){ro=be.length;let y=ka(be,!1),A=Rs(y),ne=A?(A.innerContent||"").trim():"",l=ne.split(/[.!?]\s+/).filter(re=>re.trim().length>10),Ie=new Set(l),Z=l.length>25?(l.length-Ie.size)/l.length:0,v=ne.split(/\s+/).filter(re=>re.length>0).length,Ct=.9,On=.92,It=!1;if(i.toLowerCase().includes("google")&&(J||"").toLowerCase().startsWith("gemma")){let at={low:2048,medium:4096,high:32768,max:65536,xhigh:65536}[d?.toLowerCase()]||16e3;It=v>at}if(Z>Ct||It){yield{type:"status",content:`${Z>Ct?"Reasoning Loop Detected":"Thinking Budget Exceeded"}. Re-centering...`},Wt=!0,await new Promise(at=>setTimeout(at,3e3));break}let se=pa(be).trim().split(/[.!?]\s+/).filter(re=>re.trim().length>10),Mt=new Set(se);if((se.length>25?(se.length-Mt.size)/se.length:0)>On){yield{type:"status",content:"Response Loop Detected. Re-centering..."},Wt=!1,Gt=!0,await new Promise(re=>setTimeout(re,3e3));break}let on=y.replace(ml,"").replace(pl,"").replace(hl,"").replace(yl,""),Dn=on.toLowerCase().split(/\s+/).map(re=>re.replace(xl,"")).filter(re=>re.length>0),Ao=!1;if(Dn.length>=40)for(let re=1;re<=15;re++){let at=Math.max(8,Math.ceil(25/re));if(Dn.length<re*at)continue;let Fn=Dn.slice(Dn.length-re),c=Fn.join(" ");if(re>1&&c===Fn.slice(0,Math.floor(re/2)).join(" ").repeat(2).trim())continue;let R=!0;for(let _=1;_<at;_++)if(Dn.slice(Dn.length-re*(_+1),Dn.length-re*_).join(" ")!==c){R=!1;break}if(R){Ao=!0;break}}if(!Ao){let re=on.toLowerCase().replace(wl,"");if(re.length>=80)for(let at=1;at<=10;at++){let Fn=Math.max(15,Math.ceil(45/at));if(re.length<at*Fn)continue;let c=re.substring(re.length-at),R=!0;for(let _=1;_<Fn;_++)if(re.substring(re.length-at*(_+1),re.length-at*_)!==c){R=!1;break}if(R){Ao=!0;break}}}if(Ao){yield{type:"status",content:"Stuttering Detected. Re-centering..."},Wt=!1,Xn=!0,await new Promise(re=>setTimeout(re,3e3));break}}let z=jt(be),yt=Kn(z);for(;yt.length>Et;){yield*un();let y=yt[Et],A=Date.now(),l={Ask:"ask",AskUser:"ask",WebSearch:"web_search",WebScrape:"web_scrape",ReadFile:"view_file",ReadFolder:"read_folder",FindFile:"find_file",find_file:"find_file",findfile:"find_file",WriteFile:"write_file",PatchFile:"update_file",WritePDF:"write_pdf",WriteDoc:"write_docx",Run:"exec_command",SearchKeyword:"search_keyword",CodeSearch:"search_keyword",code_search:"search_keyword",Code_Search:"search_keyword",codesearch:"search_keyword",Memory:"memory",file_map:"file_map",FileMap:"file_map",Chat:"chat",chat:"chat",GenerateImage:"generate_image",generate_image:"generate_image",todo:"todo",Todo:"todo",goal:"todo",Goal:"todo",Invoke:"invoke",InvokeSync:"invoke_sync",getProgress:"get_progress",GetProgress:"get_progress",Await:"await",await:"await",AwaitSubagent:"await",awaitSubagent:"await",Wait:"wait",wait:"wait",Answer:"answer",answer:"answer",AnswerSubagent:"answer",answerSubagent:"answer",Steer:"steer",steer:"steer",SteerSubagent:"steer",steerSubagent:"steer",Cancel:"cancel",cancel:"cancel",Click:"click",click:"click",Drag:"drag",drag:"drag",Scroll:"scroll",scroll:"scroll",KeyboardTyping:"keyboard_typing",keyboard_typing:"keyboard_typing",KeyPress:"key_press",key_press:"key_press",RecaptureScreen:"recapture_screen",recapture_screen:"recapture_screen",EmergencyRollback:"EmergencyRollback"}[y.toolName]||y.toolName,Ie=vs[l]||y.toolName,Z=oo(l,y.args);yield{type:"status",content:`${Ie}${Z?` ${Z}`:""}`};let v="";if(l==="click"){let c=O(y.args,["intendedClickText"]);v=`\u2714 Clicked ${c.intendedClickText?`: ${c.intendedClickText}`:"Screen"}`}else if(l==="drag"){let c=O(y.args,["fromGridId","toGridId"]);v=`\u2714 Dragged: Cell ${c.fromGridId||""} \u2192 Cell ${c.toGridId||""}`}else if(l==="scroll"){let c=O(y.args,["direction","amount"]);v=`\u2714 Scrolled: ${c.direction||"down"} (${c.amount||1})`}else if(l==="keyboard_typing"){let c=O(y.args,["text"]);v=`\u2714 ${c.autoPressEnter?"Entered":"Typed"}: ${c.text?`"${c.text.length>20?c.text.substring(0,20)+"...":c.text}"`:""}`}else if(l==="key_press")v=`\u2714 Pressed Key: ${O(y.args,["key"]).key||""}`;else if(l==="recapture_screen")v="\u2714 Recaptured Screen";else if(l==="web_search"){let{query:c,limit:R=10,aiMode:_=!1}=O(y.args,["query","limit","aiMode"]);v=`${c?"\u2714":"\u2718"} ${_?"AI Search":"Searched"}: ${c?`${c}`:"No Search Query"}${_===!1&&c?` \u2192 ${R}`:""}`}else if(l==="web_scrape"){let c=O(y.args,["url"]).url||null;v=`${c?"\u2714":"\u2718"} Visited: ${c||"No Source"}`}else if(l==="view_file"){let{path:c,StartLine:R,EndLine:_,start_line:ce,end_line:ye,startLine:oe,endLine:ae}=O(y.args,["path","StartLine","EndLine","start_line","end_line","startLine","endLine"]),Re=R||ce||oe,ee=_||ye||ae,q=parseInt(Re)||1,W=parseInt(ee)||(Re?q+800:800),ue="...",Ge=W,D=(c||"").trim().toLowerCase().replaceAll("\\","/");if(D.startsWith("#skill"))D.startsWith("#skill/global/fluxflow")||D.startsWith("#skills/global/fluxflow")||D.includes("#skill/fluxflow")||D.includes("#skills/fluxflow")?v="\u2714 Read Documentation":v=`\u2714 Read Skill: ${U.basename(c.replaceAll("\\","/"))}`;else{try{let{resolvedPath:xe}=mn(c),ke=U.resolve(process.cwd(),xe);if(we.existsSync(ke)){let ve=we.readFileSync(ke,"utf8").split(`
693
- `).length;ue=ve,!Re&&!ee&&ve>800?Ge=Math.min(50,ve):Ge=Math.min(W,ve)}}catch{}let vt=(c||"").toLowerCase(),Co=vt.endsWith(".pdf"),zt=vt.endsWith(".docx")||vt.endsWith(".doc")||vt.endsWith(".ppt")||vt.endsWith(".pptx")||vt.endsWith(".xls")||vt.endsWith(".xlsx"),Me=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(vt);Co||zt?v=`${c.length>0?"\u2714":"\u2718"} ${c?`Analyzed: ${U.basename(c)}`:"Analyzed: File Not Found"}`:Me?v=`${c.length>0?"\u2714":"\u2718"} ${c?`Processed: ${U.basename(c)}`:"Processed: File Not Found"}`:v=`${ue!=="..."?"\u2714":"\u2718"} Read: ${c?`${U.basename(c)} \u2192 ${ue!=="..."?`Lines ${q} - ${Ge} of ${ue}`:"File Not Found"}`:"File Not Found"}`}}else if(l==="list_files"||l==="read_folder"){let c=l==="list_files"?"List":"Browsed",R=O(y.args,["path","recurse","include"]).path||null,_=O(y.args,["path","recurse","include"]).recurse||1;v=`${R?"\u2714":"\u2718"} ${c}: ${R?`${R==="."?`./${_>1?"*":""}`:`${R.replaceAll("\\","/")}${_>1?`${R.endsWith("/")?"*":"/*"}`:`${R.endsWith("/")?"":"/"}`}`}`:"No Folder Selected"}`}else if(l==="find_file"){let c=O(y.args,["basename","name","path","file","query"]),R=c.basename||c.name||c.path||c.file||c.query||"";v=`${R?"\u2714":"\u2718"} Located: ${R||"No Query"}`}else if(l==="write_file"||l==="update_file"){let c=l==="write_file"?"Created":"Edited",R=O(y.args,["path","content","allowMultiple","searchContent*","replaceContent*","newContent*"]),_=R.path||null,ye=Object.entries(R).some(([oe,ae])=>oe.startsWith("searchContent")&&typeof ae=="string"&&ae.startsWith("^LINE:"))?"\u1361":":";v=`${_?"\u2714":"\u2718"} ${c}${ye} ${_?_.replaceAll("\\","/"):"No File Changes"}`}else if(l==="write_pdf"){let c=O(y.args,["path","content","orientation","margin"]).path||null;v=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No PDF Generated"}`}else if(l==="write_docx"){let c=O(y.args,["path","content"]).path||null;v=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No Docx Generated"}`}else if(l==="file_map"){let c=O(y.args,["path"]).path;v=`${c?"\u2714":"\u2718"} Indexed: ${c.replaceAll("\\","/")?""+c:"File Not Found"}`}else if(l.toLowerCase()==="search_keyword"||l.toLowerCase()==="todo")v="";else if(l.toLowerCase()==="generate_image"){let{path:c,outputPath:R,output:_}=O(y.args,["path","prompt","text","outputPath","output","ratio"]);v=`\u2714 Generated: ${c||R||_||"generated_image.png"}`}else if(l==="invoke_sync"||l==="InvokeSync"){let c=oo(l,y.args);v=`\u2714 Called Generalist${c?`: ${c}`:""}`}else if(l==="Invoke"||l==="InvokeAsync"||l==="invoke"){let c=oo(l,y.args);v=`\u2714 Started Generalist${c?`: ${c}`:""}`}else if(l==="get_progress"||l==="GetProgress"){let c=oo(l,y.args);v=`\u2714 Checked${c?`: ${c}`:""}`}else if(l==="cancel"){let c=oo(l,y.args);v=`\u{1F6C7} Cancelled${c?`: ${c}`:""}`}else if(l==="steer"||l==="Steer"){let c=oo(l,y.args);v=`\u2714 Steered${c?`: ${c}`:""}`}else if(l==="EmergencyRollback"){let{method:c}=O(y.args,["method","id"]);v=c==="forceRevert"?"":"\u2714 Rollback Point Checked"}else if(l==="await"||l==="Await"||l==="wait"||l==="Wait"){let{time:c,timeout:R,seconds:_,sec:ce}=O(y.args,["time","timeout","seconds","sec"]),ye=parseFloat(_||ce||R||c)||45,oe=l==="wait"||l==="Wait"?120:180;ye<10&&(ye=10),ye>oe&&(ye=oe);let ae=q=>{if(q>=60){let W=Math.floor(q/60),ue=q%60;return`${W}m${ue>0?` ${ue}s`:""}`}return`${q}s`},Re=["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"];v=`\u2714 ${Re[Math.floor(Math.random()*Re.length)]} \u2192 ${ae(ye)}`}else l==="Answer"||l==="answer"?v="\u2714 Resolved Sub-Agent Query":l==="exec_command"||l==="ask"?v="":v=`Executed: ${y.toolName}`;if(yield*un(),l==="exec_command"){let{command:c}=O(y.args,["command","background","timeout","usePowershell","forcePowershell","useCwd","useCmd","forceCwd","forceCmd"]);if(c&&n.systemSettings&&n.systemSettings.allowExternalAccess===!1){let R=[/[a-zA-Z]:[\\\/]/i,/^\//,/\.\.[\\\/]/,/\/etc\//,/\/var\//,/\/root\//,/\/bin\//,/\/usr\//],_=U.resolve(process.cwd()).substring(0,3).toLowerCase(),ce=ee=>{let q=[],W="",ue=null;for(let Ge=0;Ge<ee.length;Ge++){let D=ee[Ge];ue?(D===ue&&(ue=null),W+=D):D==='"'||D==="'"?(ue=D,W+=D):D==="&"&&ee[Ge+1]==="&"||D==="|"&&ee[Ge+1]==="|"?(W.trim()&&(q.push(W.trim()),W=""),Ge++):D===";"||D==="|"||D==="&"?W.trim()&&(q.push(W.trim()),W=""):W+=D}return W.trim()&&q.push(W.trim()),q},ye=ee=>{let q=[],W="",ue=null;for(let Ge=0;Ge<ee.length;Ge++){let D=ee[Ge];ue?(D===ue&&(ue=null),W+=D):D==='"'||D==="'"?(ue=D,W+=D):/\s/.test(D)?W&&(q.push(W),W=""):W+=D}return W&&q.push(W),q},oe=ee=>{let q=ee.replace(/^['"]|['"]$/g,"").trim();return!q||process.platform==="win32"&&/^\/[a-zA-Z0-9?]+$/.test(q)?!1:R.some(W=>{if(W.source==="[a-zA-Z]:[\\\\\\/]"){let ue=q.match(/[a-zA-Z]:[\\\/]/i);return ue&&ue[0].toLowerCase()!==_}return W.test(q)})};if(ce(c).some(ee=>{let q=ye(ee);if(q.length===0)return!1;let W=q[0].replace(/^['"]|['"]$/g,"").toLowerCase();if(["echo","printf","write-output"].includes(W)){let Ge=!1;return q.some(D=>{let Rt=D.replace(/^['"]|['"]$/g,"");if(Rt===">"||Rt===">>"||Rt==="<")return Ge=!0,!1;if(Rt.startsWith(">")||Rt.startsWith("<")){let vt=Rt.replace(/^[><]+/,"");return oe(vt)}return Ge?(Ge=!1,oe(D)):!1})}return q.some(Ge=>oe(Ge))})){let ee='Access Denied. Prohibited from accessing external directories while "External Workspace Access" is disabled.';n.onExecStart&&n.onExecStart(c||"No Command"),yield{type:"exec_start"},await new Promise(q=>setTimeout(q,50)),n.onExecChunk&&n.onExecChunk(`ERROR: ${ee}`),await new Promise(q=>setTimeout(q,50)),n.onExecEnd&&n.onExecEnd(),je.push({role:"user",text:`[ACTION RESULT]: ERROR: ${ee}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${ee}`},Et++;continue}}n.onExecStart&&n.onExecStart(c||"No Command"),yield{type:"exec_start"}}let Ct=["write_file","update_file","view_file","read_folder","list_files","file_map"],On=["path","targetPath","file","content","searchContent*","replaceContent*","newContent*","recurse","include","StartLine","EndLine","start_line","end_line","startLine","endLine"],It=Ct.includes(l)?O(y.args,On):O(y.args),ut=It.path||It.targetPath||null;if(ut){let c=n.systemSettings&&n.systemSettings.allowExternalAccess===!1,R=U.resolve(ut),_=U.resolve(process.cwd());if(c&&!R.startsWith(_)){let ce="Access Denied. You are not allowed to access files outside the current workspace.";if(l==="write_file"||l==="update_file"){let oe=`\u2718 ${l==="write_file"?"Write Canceled":"Edit Canceled"}: ${It.path||"..."}`,ae=115;process.stdout.isTTY&&(ae=process.stdout.columns-5||120);let Re=Math.min(oe.length+4,ae),ee=`${oe.padEnd(Re-2).substring(0,Re-2)}`;yield{type:"visual_feedback",content:Lt(`${Be?`
693
+ \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(k){if(Je){if(pe+=k,pe.length>=64){let y=0,T=Math.min(bt.length,pe.length);for(let l=T;l>=10;l--)if(bt.endsWith(pe.substring(0,l))){y=l;break}let ne=pe.substring(y);if(ne){let Ie=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(bt)?ne.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):ne.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");if(Ie)if(be+=Ie,i==="Google")pt+=Ie;else{yield*un();let Z=Ro(Ie);for(let v of Z)yield v}}Je=!1,pe=""}continue}else if(be+=k,i==="Google")pt+=k;else{yield*un();let y=Ro(k);for(let T of y)yield T}let L=Il(be);if(L.inside){It=!0,Jn||(Jn=Date.now());let T={Ask:"ask",AskUser:"ask",WebSearch:"web_search",WebScrape:"web_scrape",ReadFile:"view_file",ReadFolder:"read_folder",WriteFile:"write_file",PatchFile:"update_file",WritePDF:"write_pdf",WriteDoc:"write_docx",FindFile:"find_file",find_file:"find_file",findfile:"find_file",Run:"exec_command",SearchKeyword:"search_keyword",CodeSearch:"search_keyword",code_search:"search_keyword",Code_Search:"search_keyword",codesearch:"search_keyword",Memory:"memory",file_map:"file_map",FileMap:"file_map",Chat:"chat",chat:"chat",GenerateImage:"generate_image",generate_image:"generate_image",todo:"todo",Todo:"todo",goal:"todo",Goal:"todo",Invoke:"invoke",InvokeSync:"invoke_sync",getProgress:"get_progress",GetProgress:"get_progress",Cancel:"cancel",Await:"await",wait:"wait",Answer:"answer",Steer:"steer",steer:"steer"}[L.toolName]||L.toolName,ne=L.args||"",l=null;if(["write_file","update_file","view_file","read_folder","find_file","write_pdf","write_docx","search_keyword","generate_image","file_map","invoke","invoke_sync","get_progress","await","wait","answer"].includes(T)){let Z=O(ne,[],["path","basename","name","targetFile","TargetFile","directory","file","keyword","title","task","id","taskId","timeout","time","seconds"]),v=Z.basename||Z.name||Z.path||Z.targetFile||Z.TargetFile||Z.directory||Z.file,Rt=Z.keyword,Nn=Z.title||Z.task,Mt=Z.id||Z.taskId,ut=Z.timeout||Z.time||Z.seconds||Z.sec;if(Rt!=null)l=String(Rt).replace(_n,"");else if(v)l=B.basename(String(v).replace(_n,"").replace(fa,"/"));else if(Nn&&(T==="invoke"||T==="invoke_sync"))l=String(Nn).replace(_n,"").substring(0,30);else if(Mt&&T==="get_progress")l=String(Mt).replace(_n,"");else if(ut&&T==="await"){let Qe=parseFloat(String(ut).replace(_n,""));isNaN(Qe)?l=String(ut).replace(_n,""):(Qe<5&&(Qe=5),Qe>120&&(Qe=180),l=(Pt=>{if(Pt>=60){let Dn=Math.floor(Pt/60),tn=Pt%60;return`${Dn}m${tn>0?` ${tn}s`:""}`}return`${Pt}s`})(Qe))}else if(ut&&T==="wait"){let Qe=parseFloat(String(ut).replace(_n,""));isNaN(Qe)?l=String(ut).replace(_n,""):(Qe<10&&(Qe=10),Qe>120&&(Qe=120),l=(Pt=>{if(Pt>=60){let Dn=Math.floor(Pt/60),tn=Pt%60;return`${Dn}m${tn>0?` ${tn}s`:""}`}return`${Pt}s`})(Qe))}else{let Qe=ne.match(Sl);if(Qe){let se=Qe[1].replace(_n,"");T==="invoke"||T==="invoke_sync"||T==="get_progress"?l=se.substring(0,30):l=T==="search_keyword"||T==="file_map"?se:B.basename(se.replace(fa,"/"))}}}let Ie=`${Is[T]||T}${l?` ${l}`:""}`;if((T!==Bt||l!==Ao)&&(Bt=T,Ao=l,yield{type:"status",content:`${Ie}`},process.stdout.isTTY)){let v={WebSearch:"Searching",web_search:"Searching",WebScrape:"Reading",web_scrape:"Reading",ReadFile:"Reading",read_file:"Reading",ReadFolder:"Reading",read_folder:"Reading",WriteFile:"Writing",write_file:"Writing",UpdateFile:"Editing",update_file:"Editing",WritePdf:"Creating",write_pdf:"Creating",WriteDocx:"Creating",write_docx:"Creating",SearchKeyword:"Searching",search_keyword:"Searching",CodeSearch:"Searching",code_search:"Searching",FindFile:"Finding File",find_file:"Finding File",Run:"Executing",Ask:"User Input Required",AskUser:"User Input Required",Memory:"Updating Memory",GenerateImage:"Generating",InvokeSync:"Sub-Agent Working",invoke_sync:"Sub-Agent Working",Invoke:"Working",invoke:"Working",GetProgress:"Checking Progress",get_progress:"Checking Progress",Cancel:"Stopping Generalist",cancel:"Stopping Generalist",Await:"Waiting",await:"Waiting",wait:"Waiting",EmergencyRollback:"Rolling the Ball",Answer:"Answering Sub-Agent",answer:"Answering Sub-Agent",Steer:"Steering Sub-Agent",steer:"Steering Sub-Agent",Click:"Clicking",click:"Clicking",Drag:"Dragging",drag:"Dragging",Scroll:"Scrolling",scroll:"Scrolling",KeyboardTyping:"Typing",keyboard_typing:"Typing",KeyPress:"Pressing Key",key_press:"Pressing Key",RecaptureScreen:"Recapturing Screen",recapture_screen:"Recapturing Screen"}[T]||"Working";process.stdout.write(`\x1B]0;${v}...\x07`)}}if(be.length-fo>800){fo=be.length;let y=Ta(be,!1),T=_s(y),ne=T?(T.innerContent||"").trim():"",l=ne.split(/[.!?]\s+/).filter(re=>re.trim().length>10),Ie=new Set(l),Z=l.length>25?(l.length-Ie.size)/l.length:0,v=ne.split(/\s+/).filter(re=>re.length>0).length,Rt=.9,Nn=.92,Mt=!1;if(i.toLowerCase().includes("google")&&(J||"").toLowerCase().startsWith("gemma")){let ct={low:2048,medium:4096,high:32768,max:65536,xhigh:65536}[d?.toLowerCase()]||16e3;Mt=v>ct}if(Z>Rt||Mt){yield{type:"status",content:`${Z>Rt?"Reasoning Loop Detected":"Thinking Budget Exceeded"}. Re-centering...`},Ut=!0,await new Promise(ct=>setTimeout(ct,3e3));break}let se=ha(be).trim().split(/[.!?]\s+/).filter(re=>re.trim().length>10),Pt=new Set(se);if((se.length>25?(se.length-Pt.size)/se.length:0)>Nn){yield{type:"status",content:"Response Loop Detected. Re-centering..."},Ut=!1,Wt=!0,await new Promise(re=>setTimeout(re,3e3));break}let tn=y.replace(ml,"").replace(pl,"").replace(hl,"").replace(yl,""),Fn=tn.toLowerCase().split(/\s+/).map(re=>re.replace(xl,"")).filter(re=>re.length>0),Eo=!1;if(Fn.length>=40)for(let re=1;re<=15;re++){let ct=Math.max(8,Math.ceil(25/re));if(Fn.length<re*ct)continue;let Bn=Fn.slice(Fn.length-re),c=Bn.join(" ");if(re>1&&c===Bn.slice(0,Math.floor(re/2)).join(" ").repeat(2).trim())continue;let R=!0;for(let _=1;_<ct;_++)if(Fn.slice(Fn.length-re*(_+1),Fn.length-re*_).join(" ")!==c){R=!1;break}if(R){Eo=!0;break}}if(!Eo){let re=tn.toLowerCase().replace(wl,"");if(re.length>=80)for(let ct=1;ct<=10;ct++){let Bn=Math.max(15,Math.ceil(45/ct));if(re.length<ct*Bn)continue;let c=re.substring(re.length-ct),R=!0;for(let _=1;_<Bn;_++)if(re.substring(re.length-ct*(_+1),re.length-ct*_)!==c){R=!1;break}if(R){Eo=!0;break}}}if(Eo){yield{type:"status",content:"Stuttering Detected. Re-centering..."},Ut=!1,Zn=!0,await new Promise(re=>setTimeout(re,3e3));break}}let q=Ht(be),yt=Vn(q);for(;yt.length>_t;){yield*un();let y=yt[_t],T=Date.now(),l={Ask:"ask",AskUser:"ask",WebSearch:"web_search",WebScrape:"web_scrape",ReadFile:"view_file",ReadFolder:"read_folder",FindFile:"find_file",find_file:"find_file",findfile:"find_file",WriteFile:"write_file",PatchFile:"update_file",WritePDF:"write_pdf",WriteDoc:"write_docx",Run:"exec_command",SearchKeyword:"search_keyword",CodeSearch:"search_keyword",code_search:"search_keyword",Code_Search:"search_keyword",codesearch:"search_keyword",Memory:"memory",file_map:"file_map",FileMap:"file_map",Chat:"chat",chat:"chat",GenerateImage:"generate_image",generate_image:"generate_image",todo:"todo",Todo:"todo",goal:"todo",Goal:"todo",Invoke:"invoke",InvokeSync:"invoke_sync",getProgress:"get_progress",GetProgress:"get_progress",Await:"await",await:"await",AwaitSubagent:"await",awaitSubagent:"await",Wait:"wait",wait:"wait",Answer:"answer",answer:"answer",AnswerSubagent:"answer",answerSubagent:"answer",Steer:"steer",steer:"steer",SteerSubagent:"steer",steerSubagent:"steer",Cancel:"cancel",cancel:"cancel",Click:"click",click:"click",Drag:"drag",drag:"drag",Scroll:"scroll",scroll:"scroll",KeyboardTyping:"keyboard_typing",keyboard_typing:"keyboard_typing",KeyPress:"key_press",key_press:"key_press",RecaptureScreen:"recapture_screen",recapture_screen:"recapture_screen",EmergencyRollback:"EmergencyRollback"}[y.toolName]||y.toolName,Ie=Is[l]||y.toolName,Z=ro(l,y.args);yield{type:"status",content:`${Ie}${Z?` ${Z}`:""}`};let v="";if(l==="click"){let c=O(y.args,["intendedClickText"]);v=`\u2714 Clicked ${c.intendedClickText?`: ${c.intendedClickText}`:"Screen"}`}else if(l==="drag"){let c=O(y.args,["fromGridId","toGridId"]);v=`\u2714 Dragged: Cell ${c.fromGridId||""} \u2192 Cell ${c.toGridId||""}`}else if(l==="scroll"){let c=O(y.args,["direction","amount"]);v=`\u2714 Scrolled: ${c.direction||"down"} (${c.amount||1})`}else if(l==="keyboard_typing"){let c=O(y.args,["text"]);v=`\u2714 ${c.autoPressEnter?"Entered":"Typed"}: ${c.text?`"${c.text.length>20?c.text.substring(0,20)+"...":c.text}"`:""}`}else if(l==="key_press")v=`\u2714 Pressed Key: ${O(y.args,["key"]).key||""}`;else if(l==="recapture_screen")v="\u2714 Recaptured Screen";else if(l==="web_search"){let{query:c,limit:R=10,aiMode:_=!1}=O(y.args,["query","limit","aiMode"]);v=`${c?"\u2714":"\u2718"} ${_?"AI Search":"Searched"}: ${c?`${c}`:"No Search Query"}${_===!1&&c?` \u2192 ${R}`:""}`}else if(l==="web_scrape"){let c=O(y.args,["url"]).url||null;v=`${c?"\u2714":"\u2718"} Visited: ${c||"No Source"}`}else if(l==="view_file"){let{path:c,StartLine:R,EndLine:_,start_line:ce,end_line:he,startLine:oe,endLine:ae}=O(y.args,["path","StartLine","EndLine","start_line","end_line","startLine","endLine"]),Ae=R||ce||oe,ee=_||he||ae,Y=parseInt(Ae)||1,G=parseInt(ee)||(Ae?Y+800:800),ue="...",Ge=G,F=(c||"").trim().toLowerCase().replaceAll("\\","/");if(F.startsWith("#skill"))F.startsWith("#skill/global/fluxflow")||F.startsWith("#skills/global/fluxflow")||F.includes("#skill/fluxflow")||F.includes("#skills/fluxflow")?v="\u2714 Read Documentation":v=`\u2714 Read Skill: ${B.basename(c.replaceAll("\\","/"))}`;else{try{let{resolvedPath:ye}=mn(c),Te=B.resolve(process.cwd(),ye);if(xe.existsSync(Te)){let Ce=xe.readFileSync(Te,"utf8").split(`
694
+ `).length;ue=Ce,!Ae&&!ee&&Ce>800?Ge=Math.min(50,Ce):Ge=Math.min(G,Ce)}}catch{}let Et=(c||"").toLowerCase(),_o=Et.endsWith(".pdf"),zt=Et.endsWith(".docx")||Et.endsWith(".doc")||Et.endsWith(".ppt")||Et.endsWith(".pptx")||Et.endsWith(".xls")||Et.endsWith(".xlsx"),Me=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(Et);_o||zt?v=`${c.length>0?"\u2714":"\u2718"} ${c?`Analyzed: ${B.basename(c)}`:"Analyzed: File Not Found"}`:Me?v=`${c.length>0?"\u2714":"\u2718"} ${c?`Processed: ${B.basename(c)}`:"Processed: File Not Found"}`:v=`${ue!=="..."?"\u2714":"\u2718"} Read: ${c?`${B.basename(c)} \u2192 ${ue!=="..."?`Lines ${Y} - ${Ge} of ${ue}`:"File Not Found"}`:"File Not Found"}`}}else if(l==="list_files"||l==="read_folder"){let c=l==="list_files"?"List":"Browsed",R=O(y.args,["path","recurse","include"]).path||null,_=O(y.args,["path","recurse","include"]).recurse||1;v=`${R?"\u2714":"\u2718"} ${c}: ${R?`${R==="."?`./${_>1?"*":""}`:`${R.replaceAll("\\","/")}${_>1?`${R.endsWith("/")?"*":"/*"}`:`${R.endsWith("/")?"":"/"}`}`}`:"No Folder Selected"}`}else if(l==="find_file"){let c=O(y.args,["basename","name","path","file","query"]),R=c.basename||c.name||c.path||c.file||c.query||"";v=`${R?"\u2714":"\u2718"} Located: ${R||"No Query"}`}else if(l==="write_file"||l==="update_file"){let c=l==="write_file"?"Created":"Edited",R=O(y.args,["path","content","allowMultiple","searchContent*","replaceContent*","newContent*"]),_=R.path||null,he=Object.entries(R).some(([oe,ae])=>oe.startsWith("searchContent")&&typeof ae=="string"&&/^\^line:/i.test(ae))?"\u1361":":";v=`${_?"\u2714":"\u2718"} ${c}${he} ${_?_.replaceAll("\\","/"):"No File Changes"}`}else if(l==="write_pdf"){let c=O(y.args,["path","content","orientation","margin"]).path||null;v=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No PDF Generated"}`}else if(l==="write_docx"){let c=O(y.args,["path","content"]).path||null;v=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No Docx Generated"}`}else if(l==="file_map"){let c=O(y.args,["path"]).path;v=`${c?"\u2714":"\u2718"} Indexed: ${c.replaceAll("\\","/")?""+c:"File Not Found"}`}else if(l.toLowerCase()==="search_keyword"||l.toLowerCase()==="todo")v="";else if(l.toLowerCase()==="generate_image"){let{path:c,outputPath:R,output:_}=O(y.args,["path","prompt","text","outputPath","output","ratio"]);v=`\u2714 Generated: ${c||R||_||"generated_image.png"}`}else if(l==="invoke_sync"||l==="InvokeSync"){let c=ro(l,y.args);v=`\u2714 Called Generalist${c?`: ${c}`:""}`}else if(l==="Invoke"||l==="InvokeAsync"||l==="invoke"){let c=ro(l,y.args);v=`\u2714 Started Generalist${c?`: ${c}`:""}`}else if(l==="get_progress"||l==="GetProgress"){let c=ro(l,y.args);v=`\u2714 Checked${c?`: ${c}`:""}`}else if(l==="cancel"){let c=ro(l,y.args);v=`\u{1F6C7} Cancelled${c?`: ${c}`:""}`}else if(l==="steer"||l==="Steer"){let c=ro(l,y.args);v=`\u2714 Steered${c?`: ${c}`:""}`}else if(l==="EmergencyRollback"){let{method:c}=O(y.args,["method","id"]);v=c==="forceRevert"?"":"\u2714 Rollback Point Checked"}else if(l==="await"||l==="Await"||l==="wait"||l==="Wait"){let{time:c,timeout:R,seconds:_,sec:ce}=O(y.args,["time","timeout","seconds","sec"]),he=parseFloat(_||ce||R||c)||45,oe=l==="wait"||l==="Wait"?120:180;he<10&&(he=10),he>oe&&(he=oe);let ae=Y=>{if(Y>=60){let G=Math.floor(Y/60),ue=Y%60;return`${G}m${ue>0?` ${ue}s`:""}`}return`${Y}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"];v=`\u2714 ${Ae[Math.floor(Math.random()*Ae.length)]} \u2192 ${ae(he)}`}else l==="Answer"||l==="answer"?v="\u2714 Resolved Sub-Agent Query":l==="exec_command"||l==="ask"?v="":v=`Executed: ${y.toolName}`;if(yield*un(),l==="exec_command"){let{command:c}=O(y.args,["command","background","timeout","usePowershell","forcePowershell","useCwd","useCmd","forceCwd","forceCmd"]);if(c&&n.systemSettings&&n.systemSettings.allowExternalAccess===!1){let R=[/[a-zA-Z]:[\\\/]/i,/^\//,/\.\.[\\\/]/,/\/etc\//,/\/var\//,/\/root\//,/\/bin\//,/\/usr\//],_=B.resolve(process.cwd()).substring(0,3).toLowerCase(),ce=ee=>{let Y=[],G="",ue=null;for(let Ge=0;Ge<ee.length;Ge++){let F=ee[Ge];ue?(F===ue&&(ue=null),G+=F):F==='"'||F==="'"?(ue=F,G+=F):F==="&"&&ee[Ge+1]==="&"||F==="|"&&ee[Ge+1]==="|"?(G.trim()&&(Y.push(G.trim()),G=""),Ge++):F===";"||F==="|"||F==="&"?G.trim()&&(Y.push(G.trim()),G=""):G+=F}return G.trim()&&Y.push(G.trim()),Y},he=ee=>{let Y=[],G="",ue=null;for(let Ge=0;Ge<ee.length;Ge++){let F=ee[Ge];ue?(F===ue&&(ue=null),G+=F):F==='"'||F==="'"?(ue=F,G+=F):/\s/.test(F)?G&&(Y.push(G),G=""):G+=F}return G&&Y.push(G),Y},oe=ee=>{let Y=ee.replace(/^['"]|['"]$/g,"").trim();return!Y||process.platform==="win32"&&/^\/[a-zA-Z0-9?]+$/.test(Y)?!1:R.some(G=>{if(G.source==="[a-zA-Z]:[\\\\\\/]"){let ue=Y.match(/[a-zA-Z]:[\\\/]/i);return ue&&ue[0].toLowerCase()!==_}return G.test(Y)})};if(ce(c).some(ee=>{let Y=he(ee);if(Y.length===0)return!1;let G=Y[0].replace(/^['"]|['"]$/g,"").toLowerCase();if(["echo","printf","write-output"].includes(G)){let Ge=!1;return Y.some(F=>{let vt=F.replace(/^['"]|['"]$/g,"");if(vt===">"||vt===">>"||vt==="<")return Ge=!0,!1;if(vt.startsWith(">")||vt.startsWith("<")){let Et=vt.replace(/^[><]+/,"");return oe(Et)}return Ge?(Ge=!1,oe(F)):!1})}return Y.some(Ge=>oe(Ge))})){let ee='Access Denied. Prohibited from accessing external directories while "External Workspace Access" is disabled.';n.onExecStart&&n.onExecStart(c||"No Command"),yield{type:"exec_start"},await new Promise(Y=>setTimeout(Y,50)),n.onExecChunk&&n.onExecChunk(`ERROR: ${ee}`),await new Promise(Y=>setTimeout(Y,50)),n.onExecEnd&&n.onExecEnd(),je.push({role:"user",text:`[ACTION RESULT]: ERROR: ${ee}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${ee}`},_t++;continue}}n.onExecStart&&n.onExecStart(c||"No Command"),yield{type:"exec_start"}}let Rt=["write_file","update_file","view_file","read_folder","list_files","file_map"],Nn=["path","targetPath","file","content","searchContent*","replaceContent*","newContent*","recurse","include","StartLine","EndLine","start_line","end_line","startLine","endLine"],Mt=Rt.includes(l)?O(y.args,Nn):O(y.args),ut=Mt.path||Mt.targetPath||null;if(ut){let c=n.systemSettings&&n.systemSettings.allowExternalAccess===!1,R=B.resolve(ut),_=B.resolve(process.cwd());if(c&&!R.startsWith(_)){let ce="Access Denied. You are not allowed to access files outside the current workspace.";if(l==="write_file"||l==="update_file"){let oe=`\u2718 ${l==="write_file"?"Write Canceled":"Edit Canceled"}: ${Mt.path||"..."}`,ae=115;process.stdout.isTTY&&(ae=process.stdout.columns-5||120);let Ae=Math.min(oe.length+4,ae),ee=`${oe.padEnd(Ae-2).substring(0,Ae-2)}`;yield{type:"visual_feedback",content:Ot(`${Fe?`
694
695
  `:""}${ee}
695
- `)},Be=!1}je.push({role:"user",text:`[ACTION RESULT]: ERROR: ${ce}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${ce}`},Et++;continue}}if(n.onToolApproval){let c=n.systemSettings||{},R=c.autoExec,_=!1,ce="";if(l==="view_file"){let oe=O(y.args,["path","targetPath","file","StartLine","EndLine","start_line","end_line","startLine","endLine"]);if(ce=oe.path||oe.targetPath||oe.file||"",ce){let ae=c.alwaysAskFiles||".env, .env.*, *.env";Vs(ce,ae)&&(_=!0)}}if(l==="write_file"||l==="update_file"||l==="exec_command"||_){let oe=null,ae=!1,Re=!1,ee=!1,q=!1;if(_)ae=!0,oe=null;else if(l==="exec_command"){let{command:Me}=O(y.args,["command","background","timeout","usePowershell","forcePowershell","useCwd","useCmd","forceCwd","forceCmd"]),xe=(Me||"").trim(),Oe=(Ne=>{let ct=[],dt="",He=null;for(let Ee=0;Ee<Ne.length;Ee++){let Y=Ne[Ee];He?(Y===He&&(He=null),dt+=Y):Y==='"'||Y==="'"?(He=Y,dt+=Y):Y==="&"&&Ne[Ee+1]==="&"||Y==="|"&&Ne[Ee+1]==="|"?(dt.trim()&&(ct.push(dt.trim()),dt=""),Ee++):Y===";"||Y==="|"||Y==="&"?dt.trim()&&(ct.push(dt.trim()),dt=""):dt+=Y}return dt.trim()&&ct.push(dt.trim()),ct.length>0?ct:[Ne]})(xe),ve=(Ne,ct)=>{if(!ct)return!1;let dt=ct.split(",").map(Ee=>Ee.trim().toLowerCase()).filter(Boolean),He=Ne.toLowerCase();return dt.some(Ee=>{if(He===Ee)return!0;if(He.startsWith(Ee)){let Y=He.charAt(Ee.length);return/\s|[;&|/]/.test(Y)}return!1})},ze=Oe.some(Ne=>ve(Ne,c.alwaysAskCommands)),qt=Oe.some(Ne=>ve(Ne,c.autoDisallowCommands)),qe=Oe.length>0&&Oe.every(Ne=>ve(Ne,c.autoApproveCommands)||c.autoApproveGit&&/^git\s+commit\b/i.test(Ne));if(qt)oe="deny";else if(c.networkAccess===!1){let ct=xe.trim().replace(/\s+/g," ").replace(/^['"]+|['"]+$/g,"").toLowerCase().split(" "),He=ct[0].split("/").pop().split("\\").pop().replace(/\.exe$/,""),Ee=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"]),Y=!1;Ee.has(He)&&(Y=!0);let Nt=co=>ct.slice(1).some(Rn=>co.includes(Rn)),Cn=co=>{let Rn=ct.findIndex(Bn=>co.includes(Bn)),Zn=ct.findIndex(Bn=>["run","exec","test"].includes(Bn));return Rn!==-1&&!(Zn!==-1&&Zn<Rn)};He==="git"&&Nt(["clone","pull","push","fetch"])&&(Y=!0),He==="go"&&Nt(["get","install"])&&(Y=!0),He==="npm"&&Cn(["install","i","update","add"])&&(Y=!0),He==="yarn"&&Cn(["add","install","upgrade"])&&(Y=!0),He==="pnpm"&&Cn(["add","install","update"])&&(Y=!0),He==="bun"&&Cn(["add","install","update"])&&(Y=!0),He==="deno"&&Nt(["install","add"])&&(Y=!0),He==="pip"&&Nt(["install","download"])&&(Y=!0),He==="pip3"&&Nt(["install","download"])&&(Y=!0),He==="cargo"&&Nt(["install","add"])&&(Y=!0),["bash","sh","zsh","fish"].includes(He)&&Nt(["-c"])&&(Y=!0),He==="cmd"&&Nt(["/c"])&&(Y=!0),Y&&(oe="deny",ee=!0)}!oe&&ze?ae=!0:!oe&&!ae&&(qe||c.autoApproveGit&&/^git\s+commit\b/i.test(xe))&&(oe="allow"),!ae&&!oe&&R&&(oe="allow")}else if(l==="write_file"||l==="update_file"){let Me=!1;if(l==="write_file"&&c.overwriteProtection!==!1&&R)try{let{path:xe}=O(y.args,["path","content"]);xe&&we.existsSync(U.resolve(process.cwd(),xe))&&(Me=!0,q=!0)}catch{}R&&!Me&&(oe="allow")}let W=oe,ue="";oe==="deny"&&(ee?ue="network":Re?ue="settings":ue="prohibited");let Ge=!1,D="",Rt=[],vt=0,Co=!1,zt="";if(!W&&n.onToolApproval)try{let Me=await n.onToolApproval(l,y.args,{checkOnly:!0});q&&Me==="allow"||(Me==="allow"||Me==="deny")&&(W=Me,W==="deny"&&(ue="user"))}catch{}if(!W){if(!q&&(l==="write_file"||l==="update_file"))try{let ke=O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]),{path:Oe}=ke;if(Oe){let{resolvedPath:ve}=mn(Oe);Oe=ve;let ze=U.resolve(process.cwd(),Oe),qt=Ee=>Ee?Ee.toLowerCase().replace(/\\/g,"/").replace(/^[a-z]:/,Y=>Y.toUpperCase()):"",qe=qt(ze),Ne="",ct=!1,dt=await to(),He=qt(dt?.file_focused);if(dt&&He===qe&&dt.full_content?(Ne=dt.full_content,ct=!0):we.existsSync(ze)&&(Ne=we.readFileSync(ze,"utf8"),ct=!0),D=Ne,await di.recordFileChange(ze,Ne),ct){let Ee=Ne;if(l==="write_file"){let Y=ke.content||ke.newContent||"";Ee=Y.endsWith(`
696
- `)?Y:Y+`
697
- `,zt=Ee}else{let{patchPairs:Y,allowMultiple:Nt,error:Cn}=Xi(ke);if(Cn){let Yt=`[ACTION RESULT]: ERROR: ${Cn}`;je.push({role:"user",text:Yt}),await $t("toolFailure"),n.onToolResult&&n.onToolResult("failure",l),yield{type:"tool_result",content:Yt,toolName:l},Et++;continue}let co=ke.allowMultiple!==void 0?ke.allowMultiple===!0||String(ke.allowMultiple).toLowerCase()==="true":Nt;vt=Y.length;let Rn=qs(Ne,Y,{allowMultiple:co});Ee=Rn.content,zt=Ee,Rt=Rn.results;let Zn=Rt.filter(Yt=>Yt.success),Bn=Rt.filter(Yt=>!Yt.success);if(Zn.length===0){let Yt=`[ACTION RESULT]: ERROR: Failed to apply patches to [${U.basename(ze)}].
698
- ${Bn.map(Un=>` \u2022 ${Un.error}`).join(`
699
- `)}`,ei=`\u2714 Edited: ${U.basename(ze.replaceAll("\\","/"))}`,Ro=115;process.stdout.isTTY&&(Ro=process.stdout.columns-5||120);let Wi=Math.min(ei.length+4,Ro),gn=`${ei.padEnd(Wi-2).substring(0,Wi-2)}`;yield{type:"visual_feedback",content:Lt(`${Be?`
700
- `:""}${gn}`)},Be=!1,je.push({role:"user",text:Yt}),await $t("toolFailure"),n.onToolResult&&n.onToolResult("failure",l),yield{type:"tool_result",content:Yt,toolName:l},Et++;continue}}yield{type:"status",content:`Opening Diff in IDE: ${U.basename(ze)}`},is(ze,Ne,Ee),Ge=!0,await new Promise(Y=>setTimeout(Y,50))}else if(l==="write_file"){let Ee=ke.content||ke.newContent||"",Y=Ee.endsWith(`
701
- `)?Ee:Ee+`
702
- `;zt=Y,we.existsSync(ze)||(Co=!0,we.mkdirSync(U.dirname(ze),{recursive:!0}),we.writeFileSync(ze,"","utf8")),yield{type:"status",content:`Opening New File Diff in IDE: ${U.basename(ze)}`},is(ze,"",Y),Ge=!0,await new Promise(Nt=>setTimeout(Nt,50))}}}catch(ke){console.error("Simulation/Diff Error:",ke)}let Me=null;os(ke=>{Me=ke});let xe=n.onToolApproval;if(W=await new Promise(async ke=>{let Oe=setInterval(()=>{if(Me){let ve=n.onIDEApproval||Vo&&Vo.onIDEApproval;ve&&ve(Me),clearInterval(Oe),ke(Me)}},100);try{let ve=await xe(l,y.args,{isOverwritePrompt:q});clearInterval(Oe),ke(ve)}catch{clearInterval(Oe),ke("deny")}}),os(null),l==="write_file"||l==="update_file"){let ke=O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]),{path:Oe}=ke;if(Oe){let{resolvedPath:ve}=mn(Oe);Oe=ve;let ze=U.resolve(process.cwd(),Oe);if(br(ze,W),W==="deny"&&Co&&we.existsSync(ze))try{we.unlinkSync(ze)}catch{}}}W==="deny"&&(ue="user")}if(W==="allow"&&Ge&&yo()){let Me=O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]),{path:xe}=Me,{resolvedPath:ke,isTildeResolved:Oe}=mn(xe);xe=ke;let ve=U.resolve(process.cwd(),xe),ze=Ke=>Ke?U.resolve(Ke).replace(/\\/g,"/").toLowerCase():"",qt=await to(),qe="";if(qt&&qt.file_focused&&ze(qt.file_focused)===ze(ve)&&qt.full_content&&(qe=qt.full_content),!qe&&we.existsSync(ve)){let Ke=we.readFileSync(ve,"utf8");Ke&&(qe=Ke)}!qe&&zt&&(qe=zt),(qe||Co)&&we.writeFileSync(ve,qe,"utf8");let Ne=qe.split(/\r?\n/),ct=Ne.length,dt=Buffer.byteLength(qe,"utf8"),He="";D&&(He=`Old File contents:
703
- ${D.split(/\r?\n/).map((it,sn)=>`${sn+1} | ${it}`).join(`
696
+ `)},Fe=!1}je.push({role:"user",text:`[ACTION RESULT]: ERROR: ${ce}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${ce}`},_t++;continue}}if(n.onToolApproval){let c=n.systemSettings||{},R=c.autoExec,_=!1,ce="";if(l==="view_file"){let oe=O(y.args,["path","targetPath","file","StartLine","EndLine","start_line","end_line","startLine","endLine"]);if(ce=oe.path||oe.targetPath||oe.file||"",ce){let ae=c.alwaysAskFiles||".env, .env.*, *.env";zs(ce,ae)&&(_=!0)}}if(l==="write_file"||l==="update_file"||l==="exec_command"||_){let oe=null,ae=!1,Ae=!1,ee=!1,Y=!1;if(_)ae=!0,oe=null;else if(l==="exec_command"){let{command:Me}=O(y.args,["command","background","timeout","usePowershell","forcePowershell","useCwd","useCmd","forceCwd","forceCmd"]),ye=(Me||"").trim(),Le=(Oe=>{let dt=[],ft="",He=null;for(let Re=0;Re<Oe.length;Re++){let X=Oe[Re];He?(X===He&&(He=null),ft+=X):X==='"'||X==="'"?(He=X,ft+=X):X==="&"&&Oe[Re+1]==="&"||X==="|"&&Oe[Re+1]==="|"?(ft.trim()&&(dt.push(ft.trim()),ft=""),Re++):X===";"||X==="|"||X==="&"?ft.trim()&&(dt.push(ft.trim()),ft=""):ft+=X}return ft.trim()&&dt.push(ft.trim()),dt.length>0?dt:[Oe]})(ye),Ce=(Oe,dt)=>{if(!dt)return!1;let ft=dt.split(",").map(Re=>Re.trim().toLowerCase()).filter(Boolean),He=Oe.toLowerCase();return ft.some(Re=>{if(He===Re)return!0;if(He.startsWith(Re)){let X=He.charAt(Re.length);return/\s|[;&|/]/.test(X)}return!1})},Ve=Le.some(Oe=>Ce(Oe,c.alwaysAskCommands)),qt=Le.some(Oe=>Ce(Oe,c.autoDisallowCommands)),ze=Le.length>0&&Le.every(Oe=>Ce(Oe,c.autoApproveCommands)||c.autoApproveGit&&/^git\s+commit\b/i.test(Oe));if(qt)oe="deny";else if(c.networkAccess===!1){let dt=ye.trim().replace(/\s+/g," ").replace(/^['"]+|['"]+$/g,"").toLowerCase().split(" "),He=dt[0].split("/").pop().split("\\").pop().replace(/\.exe$/,""),Re=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"]),X=!1;Re.has(He)&&(X=!0);let Nt=mo=>dt.slice(1).some(Rn=>mo.includes(Rn)),Cn=mo=>{let Rn=dt.findIndex(Un=>mo.includes(Un)),no=dt.findIndex(Un=>["run","exec","test"].includes(Un));return Rn!==-1&&!(no!==-1&&no<Rn)};He==="git"&&Nt(["clone","pull","push","fetch"])&&(X=!0),He==="go"&&Nt(["get","install"])&&(X=!0),He==="npm"&&Cn(["install","i","update","add"])&&(X=!0),He==="yarn"&&Cn(["add","install","upgrade"])&&(X=!0),He==="pnpm"&&Cn(["add","install","update"])&&(X=!0),He==="bun"&&Cn(["add","install","update"])&&(X=!0),He==="deno"&&Nt(["install","add"])&&(X=!0),He==="pip"&&Nt(["install","download"])&&(X=!0),He==="pip3"&&Nt(["install","download"])&&(X=!0),He==="cargo"&&Nt(["install","add"])&&(X=!0),["bash","sh","zsh","fish"].includes(He)&&Nt(["-c"])&&(X=!0),He==="cmd"&&Nt(["/c"])&&(X=!0),X&&(oe="deny",ee=!0)}!oe&&Ve?ae=!0:!oe&&!ae&&(ze||c.autoApproveGit&&/^git\s+commit\b/i.test(ye))&&(oe="allow"),!ae&&!oe&&R&&(oe="allow")}else if(l==="write_file"||l==="update_file"){let Me=!1;if(l==="write_file"&&c.overwriteProtection!==!1&&R)try{let{path:ye}=O(y.args,["path","content"]);ye&&xe.existsSync(B.resolve(process.cwd(),ye))&&(Me=!0,Y=!0)}catch{}R&&!Me&&(oe="allow")}let G=oe,ue="";oe==="deny"&&(ee?ue="network":Ae?ue="settings":ue="prohibited");let Ge=!1,F="",vt=[],Et=0,_o=!1,zt="";if(!G&&n.onToolApproval)try{let Me=await n.onToolApproval(l,y.args,{checkOnly:!0});Y&&Me==="allow"||(Me==="allow"||Me==="deny")&&(G=Me,G==="deny"&&(ue="user"))}catch{}if(!G){if(!Y&&(l==="write_file"||l==="update_file"))try{let Te=O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]),{path:Le}=Te;if(Le){let{resolvedPath:Ce}=mn(Le);Le=Ce;let Ve=B.resolve(process.cwd(),Le),qt=Re=>Re?Re.toLowerCase().replace(/\\/g,"/").replace(/^[a-z]:/,X=>X.toUpperCase()):"",ze=qt(Ve),Oe="",dt=!1,ft=await io(),He=qt(ft?.file_focused);if(ft&&He===ze&&ft.full_content?(Oe=ft.full_content,dt=!0):xe.existsSync(Ve)&&(Oe=xe.readFileSync(Ve,"utf8"),dt=!0),F=Oe,await mi.recordFileChange(Ve,Oe),dt){let Re=Oe;if(l==="write_file"){let X=Te.content||Te.newContent||"";Re=X.endsWith(`
697
+ `)?X:X+`
698
+ `,zt=Re}else{let{patchPairs:X,allowMultiple:Nt,error:Cn}=Zi(Te);if(Cn){let Yt=`[ACTION RESULT]: ERROR: ${Cn}`;je.push({role:"user",text:Yt}),await Lt("toolFailure"),n.onToolResult&&n.onToolResult("failure",l),yield{type:"tool_result",content:Yt,toolName:l},_t++;continue}let mo=Te.allowMultiple!==void 0?Te.allowMultiple===!0||String(Te.allowMultiple).toLowerCase()==="true":Nt;Et=X.length;let Rn=Ys(Oe,X,{allowMultiple:mo});Re=Rn.content,zt=Re,vt=Rn.results;let no=vt.filter(Yt=>Yt.success),Un=vt.filter(Yt=>!Yt.success);if(no.length===0){let Yt=`[ACTION RESULT]: ERROR: Failed to apply patches to [${B.basename(Ve)}].
699
+ ${Un.map(Wn=>` \u2022 ${Wn.error}`).join(`
700
+ `)}`,ii=`\u2714 Edited: ${B.basename(Ve.replaceAll("\\","/"))}`,Io=115;process.stdout.isTTY&&(Io=process.stdout.columns-5||120);let ji=Math.min(ii.length+4,Io),gn=`${ii.padEnd(ji-2).substring(0,ji-2)}`;yield{type:"visual_feedback",content:Ot(`${Fe?`
701
+ `:""}${gn}`)},Fe=!1,je.push({role:"user",text:Yt}),await Lt("toolFailure"),n.onToolResult&&n.onToolResult("failure",l),yield{type:"tool_result",content:Yt,toolName:l},_t++;continue}}yield{type:"status",content:`Opening Diff in IDE: ${B.basename(Ve)}`},as(Ve,Oe,Re),Ge=!0,await new Promise(X=>setTimeout(X,50))}else if(l==="write_file"){let Re=Te.content||Te.newContent||"",X=Re.endsWith(`
702
+ `)?Re:Re+`
703
+ `;zt=X,xe.existsSync(Ve)||(_o=!0,xe.mkdirSync(B.dirname(Ve),{recursive:!0}),xe.writeFileSync(Ve,"","utf8")),yield{type:"status",content:`Opening New File Diff in IDE: ${B.basename(Ve)}`},as(Ve,"",X),Ge=!0,await new Promise(Nt=>setTimeout(Nt,50))}}}catch(Te){console.error("Simulation/Diff Error:",Te)}let Me=null;rs(Te=>{Me=Te});let ye=n.onToolApproval;if(G=await new Promise(async Te=>{let Le=setInterval(()=>{if(Me){let Ce=n.onIDEApproval||Xo&&Xo.onIDEApproval;Ce&&Ce(Me),clearInterval(Le),Te(Me)}},100);try{let Ce=await ye(l,y.args,{isOverwritePrompt:Y});clearInterval(Le),Te(Ce)}catch{clearInterval(Le),Te("deny")}}),rs(null),l==="write_file"||l==="update_file"){let Te=O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]),{path:Le}=Te;if(Le){let{resolvedPath:Ce}=mn(Le);Le=Ce;let Ve=B.resolve(process.cwd(),Le);if(Sr(Ve,G),G==="deny"&&_o&&xe.existsSync(Ve))try{xe.unlinkSync(Ve)}catch{}}}G==="deny"&&(ue="user")}if(G==="allow"&&Ge&&So()){let Me=O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]),{path:ye}=Me,{resolvedPath:Te,isTildeResolved:Le}=mn(ye);ye=Te;let Ce=B.resolve(process.cwd(),ye),Ve=Ke=>Ke?B.resolve(Ke).replace(/\\/g,"/").toLowerCase():"",qt=await io(),ze="";if(qt&&qt.file_focused&&Ve(qt.file_focused)===Ve(Ce)&&qt.full_content&&(ze=qt.full_content),!ze&&xe.existsSync(Ce)){let Ke=xe.readFileSync(Ce,"utf8");Ke&&(ze=Ke)}!ze&&zt&&(ze=zt),(ze||_o)&&xe.writeFileSync(Ce,ze,"utf8");let Oe=ze.split(/\r?\n/),dt=Oe.length,ft=Buffer.byteLength(ze,"utf8"),He="";F&&(He=`Old File contents:
704
+ ${F.split(/\r?\n/).map((st,nn)=>`${nn+1} | ${st}`).join(`
704
705
  `)}
705
706
 
706
- `);let Ee="";if(ct<=100)Ee=Ne.join(`
707
- `);else{let Ke=Ne.slice(0,50).join(`
708
- `),it=Ne.slice(-50).join(`
709
- `);Ee=`${Ke}
707
+ `);let Re="";if(dt<=100)Re=Oe.join(`
708
+ `);else{let Ke=Oe.slice(0,50).join(`
709
+ `),st=Oe.slice(-50).join(`
710
+ `);Re=`${Ke}
710
711
 
711
- ... [${ct-100} lines truncated for history stability] ...
712
+ ... [${dt-100} lines truncated for history stability] ...
712
713
 
713
- ${it}`}let Y="";if(l==="update_file"){let Ke=Xs(D,qe,Rt,12,n?.compressToolResults||Vo?.systemSettings?.compressToolResults),{patchPairs:it}=Xi(O(y.args,["path","searchContent*","replaceContent*","newContent*"])),sn=it?.length||vt||1,Pt=0,Xt=0,Wn=[];it&&it.length>0?it.forEach((Hn,go)=>{let mo=Hn.replace||"",rn=Hn.new||"",Gi=mo.trim(),Eo=rn.trim(),Wa=!!zt&&qe===zt,Ga=Eo?qe.includes(rn)||qe.includes(Eo):!0,Ha=rn?D.includes(rn)||!!Eo&&D.includes(Eo):!1,ja=Gi?qe.includes(mo)||qe.includes(Gi):!1;Wa||!!rn&&Ga&&(!Ha||!ja||Gi===Eo)?Pt++:(Xt++,Wn.push(` \u2022 Block ${go+1}: not applied (reverted or rejected in IDE).`))}):Pt=vt||0;let vn=0;if(zt&&qe!==zt){let Hn=ul("","",zt||"",qe||"","","",{context:0});if(Hn&&Hn.hunks)for(let go of Hn.hunks){let mo=go.lines.filter(rn=>rn.startsWith("+")).map(rn=>rn.slice(1).trim()).filter(Boolean);for(let rn of mo)D.includes(rn)||vn++}}let vo=[`[${Pt}/${sn}] applied`];Xt>0&&vo.push(`${Xt} rejected by user`),vn>0&&vo.push(`${vn} manual ${vn===1?"modification":"modifications"} by user`);let fo=vo.join(", "),Gn=Wn.length>0?`
714
+ ${st}`}let X="";if(l==="update_file"){let Ke=Js(F,ze,vt,12,n?.compressToolResults||Xo?.systemSettings?.compressToolResults),{patchPairs:st}=Zi(O(y.args,["path","searchContent*","replaceContent*","newContent*"])),nn=st?.length||Et||1,$t=0,Xt=0,Gn=[];st&&st.length>0?st.forEach((jn,yo)=>{let xo=jn.replace||"",on=jn.new||"",Ki=xo.trim(),Po=on.trim(),Wa=!!zt&&ze===zt,Ga=Po?ze.includes(on)||ze.includes(Po):!0,Ha=on?F.includes(on)||!!Po&&F.includes(Po):!1,ja=Ki?ze.includes(xo)||ze.includes(Ki):!1;Wa||!!on&&Ga&&(!Ha||!ja||Ki===Po)?$t++:(Xt++,Gn.push(` \u2022 Block ${yo+1}: not applied (reverted or rejected in IDE).`))}):$t=Et||0;let vn=0;if(zt&&ze!==zt){let jn=ul("","",zt||"",ze||"","","",{context:0});if(jn&&jn.hunks)for(let yo of jn.hunks){let xo=yo.lines.filter(on=>on.startsWith("+")).map(on=>on.slice(1).trim()).filter(Boolean);for(let on of xo)F.includes(on)||vn++}}let Mo=[`[${$t}/${nn}] applied`];Xt>0&&Mo.push(`${Xt} rejected by user`),vn>0&&Mo.push(`${vn} manual ${vn===1?"modification":"modifications"} by user`);let po=Mo.join(", "),Hn=Gn.length>0?`
714
715
 
715
716
  User Review Details:
716
- ${Wn.join(`
717
- `)}`:"";Y=`File [${xe}] updated via IDE Companion. ${fo}.${Gn}
717
+ ${Gn.join(`
718
+ `)}`:"";X=`File [${ye}] updated via IDE Companion. ${po}.${Hn}
718
719
 
719
- ${Ke}${Oe?`
720
+ ${Ke}${Le?`
720
721
 
721
- [Note: '~' resolved to user home directory. To target literal '~' in current directory, escape it as '\\~']`:""}`;let{added:ti,removed:ni}=Ys(D,qe);(ti>0||ni>0)&&await zi({added:ti,removed:ni,file:xe})}else{let Ke=qe.split(/\r?\n/),it=Ke.length,sn=Buffer.byteLength(qe,"utf8"),Pt="",Xt=c?.overwriteProtection!==!1;if(D){let fo=D.split(/\r?\n/);if(!Xt)Pt="";else if(fo.length<=50)Pt=`Old File contents:
722
- ${fo.map((Gn,uo)=>`${uo+1} | ${Gn}`).join(`
722
+ [Note: '~' resolved to user home directory. To target literal '~' in current directory, escape it as '\\~']`:""}`;let{added:si,removed:ri}=Xs(F,ze);(si>0||ri>0)&&await Xi({added:si,removed:ri,file:ye})}else{let Ke=ze.split(/\r?\n/),st=Ke.length,nn=Buffer.byteLength(ze,"utf8"),$t="",Xt=c?.overwriteProtection!==!1;if(F){let po=F.split(/\r?\n/);if(!Xt)$t="";else if(po.length<=50)$t=`Old File contents:
723
+ ${po.map((Hn,ho)=>`${ho+1} | ${Hn}`).join(`
723
724
  `)}
724
725
 
725
- `;else{let Gn=U.parse(ve),uo=U.join(ii,"OverwriteBackups");if(!we.existsSync(uo))try{we.mkdirSync(uo,{recursive:!0})}catch{}let ti=String(Date.now()).slice(-5),ni=wa.randomBytes(2).toString("hex"),Hn=`${Gn.name}-old-${ti}-${ni}${Gn.ext}.bak`,go=U.join(uo,Hn);try{we.writeFileSync(go,D,"utf8")}catch{}Pt=`Old File contents:
726
- - Renamed old file as ${go.replaceAll("\\","/").replace(xa.homedir().replaceAll("\\","/"),"~")} and written requested content in ${xe}. For reversal use Run
726
+ `;else{let Hn=B.parse(Ce),ho=B.join(li,"OverwriteBackups");if(!xe.existsSync(ho))try{xe.mkdirSync(ho,{recursive:!0})}catch{}let si=String(Date.now()).slice(-5),ri=ba.randomBytes(2).toString("hex"),jn=`${Hn.name}-old-${si}-${ri}${Hn.ext}.bak`,yo=B.join(ho,jn);try{xe.writeFileSync(yo,F,"utf8")}catch{}$t=`Old File contents:
727
+ - Renamed old file as ${yo.replaceAll("\\","/").replace(wa.homedir().replaceAll("\\","/"),"~")} and written requested content in ${ye}. For reversal use Run
727
728
 
728
- `}}let Wn="";if(it<=690)Wn=Ke.join(`
729
- `);else{let fo=Ke.slice(0,300).join(`
730
- `),Gn=Ke.slice(-300).join(`
731
- `);Wn=`${fo}
729
+ `}}let Gn="";if(st<=690)Gn=Ke.join(`
730
+ `);else{let po=Ke.slice(0,300).join(`
731
+ `),Hn=Ke.slice(-300).join(`
732
+ `);Gn=`${po}
732
733
 
733
- ... [${it-100} lines truncated] ...
734
+ ... [${st-100} lines truncated] ...
734
735
 
735
- ${Gn}`}let vn=Oe?`
736
+ ${Hn}`}let vn=Le?`
736
737
 
737
- [Note: '~' resolved to user home directory. To target literal '~' in current directory, escape it as '\\~']`:"";Y=`File [${xe}] saved via IDE Companion (May have user edits).
738
- - Stats: [${it} lines, ${(sn/1024).toFixed(1)} KB]
739
- ${Pt}- Content Preview:
738
+ [Note: '~' resolved to user home directory. To target literal '~' in current directory, escape it as '\\~']`:"";X=`File [${ye}] saved via IDE Companion (May have user edits).
739
+ - Stats: [${st} lines, ${(nn/1024).toFixed(1)} KB]
740
+ ${$t}- Content Preview:
740
741
 
741
- ${Wn}${vn}`;let vo=D?D.split(/\r?\n/).length:0;await zi({added:it,removed:vo,file:xe})}let Nt=l==="write_file"?"Created":"Edited",Cn=O(y.args,["path","content","allowMultiple","searchContent*","replaceContent*","newContent*"]),Rn=Object.entries(Cn).some(([Ke,it])=>Ke.startsWith("searchContent")&&typeof it=="string"&&it.startsWith("^LINE:"))?"\u1361":":",Zn=`${xe?"\u2714":"\u2718"} ${Nt}${Rn} ${xe?xe.replaceAll("\\","/"):"No File Changes"}`,Bn=115;process.stdout.isTTY&&(Bn=process.stdout.columns-5||120);let Yt=Math.min(Zn.length+4,Bn),ei=`${Zn.padEnd(Yt-2).substring(0,Yt-2)}`;yield{type:"visual_feedback",content:Lt(`${Be?`
742
- `:""}${ei}`)},Be=!1;let Ro=Date.now();Yn=Ro,yield{type:"tool_time",content:Ro-A};let gn=(Y||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");gn.includes("[[VERIFIED]]")&&(gn=gn.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to conserve context.
743
- `));let Un;if(l==="write_file"&&!gn.startsWith("ERROR:")){let Ke=gn.replace(/^\[\[SAME\]\]\s*\r?\n?/,""),it=Ke.match(/\n\s*(\[Note:\s*'~'\s*resolved\s*to\s*user\s*home\s*directory[\s\S]*?\])\s*$/),sn=it?`
742
+ ${Gn}${vn}`;let Mo=F?F.split(/\r?\n/).length:0;await Xi({added:st,removed:Mo,file:ye})}let Nt=l==="write_file"?"Created":"Edited",Cn=O(y.args,["path","content","allowMultiple","searchContent*","replaceContent*","newContent*"]),Rn=Object.entries(Cn).some(([Ke,st])=>Ke.startsWith("searchContent")&&typeof st=="string"&&/^\^line:/i.test(st))?"\u1361":":",no=`${ye?"\u2714":"\u2718"} ${Nt}${Rn} ${ye?ye.replaceAll("\\","/"):"No File Changes"}`,Un=115;process.stdout.isTTY&&(Un=process.stdout.columns-5||120);let Yt=Math.min(no.length+4,Un),ii=`${no.padEnd(Yt-2).substring(0,Yt-2)}`;yield{type:"visual_feedback",content:Ot(`${Fe?`
743
+ `:""}${ii}`)},Fe=!1;let Io=Date.now();Qn=Io,yield{type:"tool_time",content:Io-T};let gn=(X||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");gn.includes("[[VERIFIED]]")&&(gn=gn.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to conserve context.
744
+ `));let Wn;if(l==="write_file"&&!gn.startsWith("ERROR:")){let Ke=gn.replace(/^\[\[SAME\]\]\s*\r?\n?/,""),st=Ke.match(/\n\s*(\[Note:\s*'~'\s*resolved\s*to\s*user\s*home\s*directory[\s\S]*?\])\s*$/),nn=st?`
744
745
 
745
- ${it[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(Ke)){let Pt=Ke.search(/^- Content Preview:/m);Un=`[ACTION RESULT]: ${Pt!==-1?Ke.slice(0,Pt).trimEnd():Ke}
746
+ ${st[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(Ke)){let $t=Ke.search(/^- Content Preview:/m);Wn=`[ACTION RESULT]: ${$t!==-1?Ke.slice(0,$t).trimEnd():Ke}
746
747
 
747
- [Old file content for reversal reference. Replaced with new write request]${sn}`}else{let Pt=Ke.split(/\r?\n/),Xt=Pt.filter(vn=>vn.startsWith("File ")||vn.trim().startsWith("- Stats:"));Un=`[ACTION RESULT]: ${Xt.length>0?Xt.join(`
748
- `):Pt.slice(0,2).join(`
749
- `)}${sn}`}}else if(gn.startsWith("[[SAME]]")){let it=gn.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),sn=it.filter(Xt=>Xt.startsWith("File ")||Xt.trim().startsWith("- Stats:"));Un=`[ACTION RESULT]: ${sn.length>0?sn.join(`
750
- `):it.slice(0,2).join(`
751
- `)}`}else Un=`[ACTION RESULT]: ${gn}`;je.push({role:"user",text:Un}),Pn=!0,await $t("toolSuccess"),n.onToolResult&&n.onToolResult("success",l),yield{type:"tool_result",content:Y,aiContent:Un,toolName:l},Et++;continue}if(W==="deny"){let Me=`Permission Denied: Prohibited ${l==="exec_command"?"Command":"file edit"}.`;if(_?Me=`User denied reading ${U.basename(ce||".env")}`:q&&ue==="user"?Me="User rejected file over-write. If needed AskUser how to proceed":ue==="user"?Me="Permission Denied by User":ue==="settings"?Me="Permission Denied by User Policy":ue==="network"?Me="Permission Denied: Sandbox Network Access Disabled by User Policy.":ue==="prohibited"&&l==="exec_command"&&(Me="Permission Denied: Prohibited Command in User Policy"),l==="view_file"){let xe=`\u2718 Read Denied: ${O(y.args,["path","targetPath","file"]).path?.replaceAll("\\","/")||".env"}`,ke=115;process.stdout.isTTY&&(ke=process.stdout.columns-5||120);let Oe=Math.min(xe.length+4,ke),ve=`${xe.padEnd(Oe-2).substring(0,Oe-2)}`;yield{type:"visual_feedback",content:Lt(`${Be?`
752
- `:""}${ve}
753
- `)},Be=!1}else if(l==="write_file"||l==="update_file"){let ke=`\u2718 ${l==="write_file"?"Write Cancelled":"Edit Denied"}: ${O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]).path.replaceAll("\\","/")||"..."}`,Oe=115;process.stdout.isTTY&&(Oe=process.stdout.columns-5||120);let ve=Math.min(ke.length+4,Oe),ze=`${ke.padEnd(ve-2).substring(0,ve-2)}`,qt=` ${" ".repeat(ve)} `;yield{type:"visual_feedback",content:Lt(`${Be?`
754
- `:""}${ze}
755
- `)},Be=!1}l==="exec_command"&&(await new Promise(xe=>setTimeout(xe,50)),n.onExecChunk&&n.onExecChunk(`ERROR: ${Me}`),await new Promise(xe=>setTimeout(xe,50)),n.onExecEnd&&n.onExecEnd()),je.push({role:"user",text:`[ACTION RESULT]: DENIED: ${Me}`}),yield{type:"tool_result",content:`[ACTION RESULT]: DENIED: ${Me}`},await $t("toolDenied"),n.onToolResult&&n.onToolResult("denied",l),Et++;continue}}}if(v){let c=115;process.stdout.isTTY&&(c=process.stdout.columns-5||120);let R=!1,_=Math.min(v.length+4,c),ce=`${v.padEnd(_-2).substring(0,_-2)}`;yield{type:"visual_feedback",content:Lt(`${Be?`
748
+ [Old file content for reversal reference. Replaced with new write request]${nn}`}else{let $t=Ke.split(/\r?\n/),Xt=$t.filter(vn=>vn.startsWith("File ")||vn.trim().startsWith("- Stats:"));Wn=`[ACTION RESULT]: ${Xt.length>0?Xt.join(`
749
+ `):$t.slice(0,2).join(`
750
+ `)}${nn}`}}else if(gn.startsWith("[[SAME]]")){let st=gn.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),nn=st.filter(Xt=>Xt.startsWith("File ")||Xt.trim().startsWith("- Stats:"));Wn=`[ACTION RESULT]: ${nn.length>0?nn.join(`
751
+ `):st.slice(0,2).join(`
752
+ `)}`}else Wn=`[ACTION RESULT]: ${gn}`;je.push({role:"user",text:Wn}),$n=!0,await Lt("toolSuccess"),n.onToolResult&&n.onToolResult("success",l),yield{type:"tool_result",content:X,aiContent:Wn,toolName:l},_t++;continue}if(G==="deny"){let Me=`Permission Denied: Prohibited ${l==="exec_command"?"Command":"file edit"}.`;if(_?Me=`User denied reading ${B.basename(ce||".env")}`:Y&&ue==="user"?Me="User rejected file over-write. If needed AskUser how to proceed":ue==="user"?Me="Permission Denied by User":ue==="settings"?Me="Permission Denied by User Policy":ue==="network"?Me="Permission Denied: Sandbox Network Access Disabled by User Policy.":ue==="prohibited"&&l==="exec_command"&&(Me="Permission Denied: Prohibited Command in User Policy"),l==="view_file"){let ye=`\u2718 Read Denied: ${O(y.args,["path","targetPath","file"]).path?.replaceAll("\\","/")||".env"}`,Te=115;process.stdout.isTTY&&(Te=process.stdout.columns-5||120);let Le=Math.min(ye.length+4,Te),Ce=`${ye.padEnd(Le-2).substring(0,Le-2)}`;yield{type:"visual_feedback",content:Ot(`${Fe?`
753
+ `:""}${Ce}
754
+ `)},Fe=!1}else if(l==="write_file"||l==="update_file"){let Te=`\u2718 ${l==="write_file"?"Write Cancelled":"Edit Denied"}: ${O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]).path.replaceAll("\\","/")||"..."}`,Le=115;process.stdout.isTTY&&(Le=process.stdout.columns-5||120);let Ce=Math.min(Te.length+4,Le),Ve=`${Te.padEnd(Ce-2).substring(0,Ce-2)}`,qt=` ${" ".repeat(Ce)} `;yield{type:"visual_feedback",content:Ot(`${Fe?`
755
+ `:""}${Ve}
756
+ `)},Fe=!1}l==="exec_command"&&(await new Promise(ye=>setTimeout(ye,50)),n.onExecChunk&&n.onExecChunk(`ERROR: ${Me}`),await new Promise(ye=>setTimeout(ye,50)),n.onExecEnd&&n.onExecEnd()),je.push({role:"user",text:`[ACTION RESULT]: DENIED: ${Me}`}),yield{type:"tool_result",content:`[ACTION RESULT]: DENIED: ${Me}`},await Lt("toolDenied"),n.onToolResult&&n.onToolResult("denied",l),_t++;continue}}}if(v){let c=115;process.stdout.isTTY&&(c=process.stdout.columns-5||120);let R=!1,_=Math.min(v.length+4,c),ce=`${v.padEnd(_-2).substring(0,_-2)}`;yield{type:"visual_feedback",content:Ot(`${Fe?`
756
757
  `:""}${ce}${v.includes("\u2714")&&(v.includes("Created")||v.includes("Edited"))?"":`${R?"":`
757
- `}`}`)},Be=!1}if(Yn>0){let c=Date.now()-Yn,R=Math.max(0,1e3-c);R>0&&await new Promise(_=>setTimeout(_,R))}let Ze={chatId:f,history:t,onChunk:c=>n.onExecChunk?n.onExecChunk(c):null,onAskUser:n.onAskUser,systemSettings:n.systemSettings,mode:a,isMultiModal:et(J),onVisualFeedback:n.onVisualFeedback,onSubagentUpdate:n.onSubagentUpdate,onTokenChunk:n.onTokenChunk,modelName:J,aiProvider:n.aiProvider,apiKey:n.apiKey,onUsage:n.onUsage};if(l==="write_file"||l==="update_file")try{let{path:c}=O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]);if(c){let R=U.resolve(process.cwd(),c),_=await to();_&&_.file_focused===R&&_.full_content&&(Ze.forcedContent=_.full_content)}}catch{}le.push(l);let se=await xs(l,y.args,Ze);if((l==="write_file"||l==="update_file")&&!se.startsWith("ERROR:")){let{path:c}=O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]);if(c){let{resolvedPath:R}=mn(c),_=U.resolve(process.cwd(),R);wr(_)}}process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07");let Mt=Date.now();Yn=Mt,yield{type:"tool_time",content:Mt-A},qn=Mt;let Nn=null;if(typeof se=="object"&&se.binaryPart&&(Nn=se.binaryPart,se=se.text),l==="search_keyword"){let{keyword:c,path:R}=O(y.args,["keyword","path","fuzzy","subString","regex"]),_=typeof se=="string"&&se.startsWith("[GLOB]");_&&(se=se.slice(6).trimStart());let ce=typeof se=="string"&&se.startsWith("[DIR]");ce&&(se=se.slice(5).trimStart());let ye=0;if(se){let D=se.match(/Found (\d+) match/i);D&&(ye=parseInt(D[1]))}let oe=(R||"").trim().toLowerCase().replaceAll("\\","/"),ae=oe==="#doc"||oe==="#docs"||oe==="#documentation"||oe.includes("#skill/global/fluxflow")||oe.includes("#skill/fluxflow")||oe.includes("#skills/fluxflow")||oe.includes("#skills/global/fluxflow"),Re,ee=115;process.stdout.isTTY&&(ee=process.stdout.columns-5||120);let q=Math.max(10,(ee+5)/3),W=Math.max(10,(ee+5)/4);if(ae)Re=`${c?"\u2714":"\u2718"} Searched Documentation`;else{let D=R?R.replace(/[\/\\]+$/,""):null,Rt=D&&D!=="."?`${_?R:ce?`${D}/*`:D}`:"./",vt=Rt.length>W?`${Rt.slice(0,W)}...`:Rt;Re=`${c?"\u2714":"\u2718"} Searched: "${c?c.length>ee/3?`${c.slice(0,q)}...`:c:""}" in "${vt.replaceAll("\\","/")}" \u2192 ${ye} Match${ye===1?"":"es"}`}let ue=Math.min(Re.length+4,ee),Ge=`${Re.padEnd(ue-2).substring(0,ue-2)}`;yield{type:"visual_feedback",content:Lt(`${Be?`
758
+ `}`}`)},Fe=!1}if(Qn>0){let c=Date.now()-Qn,R=Math.max(0,1e3-c);R>0&&await new Promise(_=>setTimeout(_,R))}let Qe={chatId:f,history:t,onChunk:c=>n.onExecChunk?n.onExecChunk(c):null,onAskUser:n.onAskUser,systemSettings:n.systemSettings,mode:a,isMultiModal:Ze(J),onVisualFeedback:n.onVisualFeedback,onSubagentUpdate:n.onSubagentUpdate,onTokenChunk:n.onTokenChunk,modelName:J,aiProvider:n.aiProvider,apiKey:n.apiKey,onUsage:n.onUsage};if(l==="write_file"||l==="update_file")try{let{path:c}=O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]);if(c){let R=B.resolve(process.cwd(),c),_=await io();_&&_.file_focused===R&&_.full_content&&(Qe.forcedContent=_.full_content)}}catch{}le.push(l);let se=await Ss(l,y.args,Qe);if((l==="write_file"||l==="update_file")&&!se.startsWith("ERROR:")){let{path:c}=O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]);if(c){let{resolvedPath:R}=mn(c),_=B.resolve(process.cwd(),R);br(_)}}process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07");let Pt=Date.now();Qn=Pt,yield{type:"tool_time",content:Pt-T},Jn=Pt;let Dn=null;if(typeof se=="object"&&se.binaryPart&&(Dn=se.binaryPart,se=se.text),l==="search_keyword"){let{keyword:c,path:R}=O(y.args,["keyword","path","fuzzy","subString","regex"]),_=typeof se=="string"&&se.startsWith("[GLOB]");_&&(se=se.slice(6).trimStart());let ce=typeof se=="string"&&se.startsWith("[DIR]");ce&&(se=se.slice(5).trimStart());let he=0;if(se){let F=se.match(/Found (\d+) match/i);F&&(he=parseInt(F[1]))}let oe=(R||"").trim().toLowerCase().replaceAll("\\","/"),ae=oe==="#doc"||oe==="#docs"||oe==="#documentation"||oe.includes("#skill/global/fluxflow")||oe.includes("#skill/fluxflow")||oe.includes("#skills/fluxflow")||oe.includes("#skills/global/fluxflow"),Ae,ee=115;process.stdout.isTTY&&(ee=process.stdout.columns-5||120);let Y=Math.max(10,(ee+5)/3),G=Math.max(10,(ee+5)/4);if(ae)Ae=`${c?"\u2714":"\u2718"} Searched Documentation`;else{let F=R?R.replace(/[\/\\]+$/,""):null,vt=F&&F!=="."?`${_?R:ce?`${F}/*`:F}`:"./",Et=vt.length>G?`${vt.slice(0,G)}...`:vt;Ae=`${c?"\u2714":"\u2718"} Searched: "${c?c.length>ee/3?`${c.slice(0,Y)}...`:c:""}" in "${Et.replaceAll("\\","/")}" \u2192 ${he} Match${he===1?"":"es"}`}let ue=Math.min(Ae.length+4,ee),Ge=`${Ae.padEnd(ue-2).substring(0,ue-2)}`;yield{type:"visual_feedback",content:Ot(`${Fe?`
758
759
  `:""}${Ge}
759
- `)},Be=!1}if(l==="EmergencyRollback"){let{method:c}=O(y.args,["method","id"]);if(c==="forceRevert"){let R=0;if(se){let ee=se.match(/Total\s*:\s*(\d+)/i);ee&&(R=parseInt(ee[1]))}let ce=se&&se.startsWith("ERROR:")?"\u2718 Emergency Rollback Failed":`\u2714 Emergency Rollback \u2192 ${R} file${R===1?"":"s"} processed`,ye=115;process.stdout.isTTY&&(ye=process.stdout.columns-5||120);let oe=!1,ae=Math.min(ce.length+4,ye),Re=`${ce.padEnd(ae-2).substring(0,ae-2)}`;yield{type:"visual_feedback",content:Lt(`${Be?`
760
- `:""}${Re}${oe?"":`
761
- `}`)},Be=!1}}if(l==="todo"){let{method:c,tasks:R,markDone:_}=O(y.args,["method","tasks","markDone"]),ce="",ye=[],oe=ae=>{if(!ae)return[];let Re=Array.isArray(ae)?ae:[];if(Re.length===0&&typeof ae=="string"){let ee=ae.trim();if(ee.startsWith("[")&&ee.endsWith("]")){let q=ee.match(/"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'/g);q?Re=q.map(W=>W.slice(1,-1).replace(/\\(.)/g,"$1")):Re=ee.slice(1,-1).split(",").map(W=>W.trim()).filter(Boolean)}else Re=ae.split(`
762
- `)}return Re.filter(ee=>String(ee).trim()).map(ee=>{let q=String(ee).trim();return q.startsWith("- [")?q.substring(6).trim():q})};if(c==="create"?(ce="\x1B[32m\u2192\x1B[0m Created Goals",ye=oe(R).map(ae=>`\x1B[90m\u25CB\x1B[0m ${ae}`)):c==="append"?(ce="\x1B[34m\u2795\x1B[0m Added New Goals",ye=oe(R).map(ae=>`\x1B[90m\u25CB\x1B[0m ${ae}`)):c==="get"&&(ce=_?"\x1B[36m\u21BB\x1B[0m Updated Goals":"\x1B[35m\u2022\x1B[0m Reviewed Goals",ye=(se||"").split(`
760
+ `)},Fe=!1}if(l==="EmergencyRollback"){let{method:c}=O(y.args,["method","id"]);if(c==="forceRevert"){let R=0;if(se){let ee=se.match(/Total\s*:\s*(\d+)/i);ee&&(R=parseInt(ee[1]))}let ce=se&&se.startsWith("ERROR:")?"\u2718 Emergency Rollback Failed":`\u2714 Emergency Rollback \u2192 ${R} file${R===1?"":"s"} processed`,he=115;process.stdout.isTTY&&(he=process.stdout.columns-5||120);let oe=!1,ae=Math.min(ce.length+4,he),Ae=`${ce.padEnd(ae-2).substring(0,ae-2)}`;yield{type:"visual_feedback",content:Ot(`${Fe?`
761
+ `:""}${Ae}${oe?"":`
762
+ `}`)},Fe=!1}}if(l==="todo"){let{method:c,tasks:R,markDone:_}=O(y.args,["method","tasks","markDone"]),ce="",he=[],oe=ae=>{if(!ae)return[];let Ae=Array.isArray(ae)?ae:[];if(Ae.length===0&&typeof ae=="string"){let ee=ae.trim();if(ee.startsWith("[")&&ee.endsWith("]")){let Y=ee.match(/"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'/g);Y?Ae=Y.map(G=>G.slice(1,-1).replace(/\\(.)/g,"$1")):Ae=ee.slice(1,-1).split(",").map(G=>G.trim()).filter(Boolean)}else Ae=ae.split(`
763
+ `)}return Ae.filter(ee=>String(ee).trim()).map(ee=>{let Y=String(ee).trim();return Y.startsWith("- [")?Y.substring(6).trim():Y})};if(c==="create"?(ce="\x1B[32m\u2192\x1B[0m Created Goals",he=oe(R).map(ae=>`\x1B[90m\u25CB\x1B[0m ${ae}`)):c==="append"?(ce="\x1B[34m\u2795\x1B[0m Added New Goals",he=oe(R).map(ae=>`\x1B[90m\u25CB\x1B[0m ${ae}`)):c==="get"&&(ce=_?"\x1B[36m\u21BB\x1B[0m Updated Goals":"\x1B[35m\u2022\x1B[0m Reviewed Goals",he=(se||"").split(`
763
764
  `).slice(1).join(`
764
765
  `).split(`
765
- `).filter(Re=>Re.trim().startsWith("- [")).map(Re=>{let ee=Re.trim(),q=ee.startsWith("- [x]");return`${q?"\x1B[32m\u2714\x1B[0m":"\x1B[90m\u25CB\x1B[0m"} ${q?"\x1B[90m":"\x1B[37m"}${ee.substring(6).trim()}\x1B[0m`})),ce&&ye.length>0){let ae=[`${ce}`,...ye.map(ee=>` ${ee}`)].join(`
766
- `);yield{type:"visual_feedback",content:Lt(`${Be?`
766
+ `).filter(Ae=>Ae.trim().startsWith("- [")).map(Ae=>{let ee=Ae.trim(),Y=ee.startsWith("- [x]");return`${Y?"\x1B[32m\u2714\x1B[0m":"\x1B[90m\u25CB\x1B[0m"} ${Y?"\x1B[90m":"\x1B[37m"}${ee.substring(6).trim()}\x1B[0m`})),ce&&he.length>0){let ae=[`${ce}`,...he.map(ee=>` ${ee}`)].join(`
767
+ `);yield{type:"visual_feedback",content:Ot(`${Fe?`
767
768
  `:""}${ae}${!1?"":`
768
- `}`)},Be=!1}}l==="exec_command"&&n.onExecEnd&&(await new Promise(c=>setTimeout(c,800)),n.onExecEnd());let on=se&&se.startsWith("DENIED:");se&&!se.startsWith("ERROR:")&&!on?(await $t("toolSuccess"),n.onToolResult&&n.onToolResult("success",l)):on||(await $t("toolFailure"),n.onToolResult&&n.onToolResult("failure",l));let re=(se||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");re.includes("[[VERIFIED]]")&&(re=re.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to save tokens.
769
- `));let at;if(l==="write_file"&&!re.startsWith("ERROR:")){let c=re.replace(/^\[\[SAME\]\]\s*\r?\n?/,""),R=c.match(/\n\s*(\[Note:\s*'~'\s*resolved\s*to\s*user\s*home\s*directory[\s\S]*?\])\s*$/),_=R?`
769
+ `}`)},Fe=!1}}l==="exec_command"&&n.onExecEnd&&(await new Promise(c=>setTimeout(c,800)),n.onExecEnd());let tn=se&&se.startsWith("DENIED:");se&&!se.startsWith("ERROR:")&&!tn?(await Lt("toolSuccess"),n.onToolResult&&n.onToolResult("success",l)):tn||(await Lt("toolFailure"),n.onToolResult&&n.onToolResult("failure",l));let re=(se||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");re.includes("[[VERIFIED]]")&&(re=re.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to save tokens.
770
+ `));let ct;if(l==="write_file"&&!re.startsWith("ERROR:")){let c=re.replace(/^\[\[SAME\]\]\s*\r?\n?/,""),R=c.match(/\n\s*(\[Note:\s*'~'\s*resolved\s*to\s*user\s*home\s*directory[\s\S]*?\])\s*$/),_=R?`
770
771
 
771
- ${R[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(c)){let ce=c.search(/^- Content Preview:/m);at=`[ACTION RESULT]: ${ce!==-1?c.slice(0,ce).trimEnd():c}
772
+ ${R[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(c)){let ce=c.search(/^- Content Preview:/m);ct=`[ACTION RESULT]: ${ce!==-1?c.slice(0,ce).trimEnd():c}
772
773
 
773
- [Old file content for reversal reference. Replaced with new write request]${_}`}else{let ce=c.split(/\r?\n/),ye=ce.filter(ae=>ae.startsWith("File ")||ae.trim().startsWith("- Stats:"));at=`[ACTION RESULT]: ${ye.length>0?ye.join(`
774
+ [Old file content for reversal reference. Replaced with new write request]${_}`}else{let ce=c.split(/\r?\n/),he=ce.filter(ae=>ae.startsWith("File ")||ae.trim().startsWith("- Stats:"));ct=`[ACTION RESULT]: ${he.length>0?he.join(`
774
775
  `):ce.slice(0,2).join(`
775
- `)}${_}`}}else if(re.startsWith("[[SAME]]")){let R=re.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),_=R.filter(ye=>ye.startsWith("File ")||ye.trim().startsWith("- Stats:"));at=`[ACTION RESULT]: ${_.length>0?_.join(`
776
+ `)}${_}`}}else if(re.startsWith("[[SAME]]")){let R=re.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),_=R.filter(he=>he.startsWith("File ")||he.trim().startsWith("- Stats:"));ct=`[ACTION RESULT]: ${_.length>0?_.join(`
776
777
  `):R.slice(0,2).join(`
777
- `)}`}else at=`[ACTION RESULT]: ${re}`;je.push({role:"user",text:at,binaryPart:Nn}),Pn=!0;let Fn=`[ACTION RESULT]: ${se.replaceAll(`[[VERIFIED]]
778
+ `)}`}else ct=`[ACTION RESULT]: ${re}`;je.push({role:"user",text:ct,binaryPart:Dn}),$n=!0;let Bn=`[ACTION RESULT]: ${se.replaceAll(`[[VERIFIED]]
778
779
  `,"").replaceAll(`
779
- [[/VERIFIED]]`,"")||""}`;(l==="view_file"||l==="web_scrape"||l==="file_map"||l==="search_keyword"||l==="get_progress"||l==="getprogress")&&(Fn=`[ACTION RESULT]: ${v} (Context Locked for UI Clarity)`),yield{type:"tool_result",content:Fn,aiContent:at,binaryPart:Nn,toolName:l},l==="memory"&&!se.startsWith("ERROR:")&&(yield{type:"memory_updated"}),Et++}if(i==="Google"&&pt&&Date.now()-Qo>=150){yield*un();let y=ko(pt);for(let A of y)yield A;pt="",Qo=Date.now()}}u.usageMetadata&&(en=u.usageMetadata),en&&(yield{type:"liveTokens",content:en.totalTokenCount})}if(j&&(j=!1,Qe?pe+="</think_fluxflow>":(be+="</think_fluxflow>",i==="Google"?pt+="</think_fluxflow>":yield{type:"text",content:"</think_fluxflow>"})),Qe&&pe.length>0){let u=0,S=Math.min(bt.length,pe.length);for(let V=S;V>0;V--)if(bt.endsWith(pe.substring(0,V))){u=V;break}let T=pe.substring(u);if(T){let ie=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(bt)?T.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):T.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");if(ie)if(be+=ie,i==="Google")pt+=ie;else{yield*un();let P=ko(ie);for(let z of P)yield z}}Qe=!1,pe=""}if(An){let u=An,S=(ht==="tool"||ht==="action")&&(u.startsWith("[tool:")||u.startsWith("[action:"));An="",ao=!1,ht=null,Qn=!1,lo=!1,S||(i==="Google"?pt+=u:yield{type:"text",content:u})}if(yield*un(),xt)break;let To=(be||"").trim(),Oa=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(To.toLowerCase())||/\[\[END\]\]/i.test(To.toLowerCase()),Na=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(To.toLowerCase()),Da=je.length>0||Ut!==null,Ui=jt(To).trim(),Fa=/(\p{Emoji_Presentation}|\p{Extended_Pictographic})$/u.test(Ui),Ba=/([.!?"'*_`|\]\)”’~~]+|\s|`{3}|[\u200B-\u200D\uFEFF])$/u.test(Ui.trim()),Ua=/[.!?}"'`’“”]$|```$/s.test(Ui)||Ba||Fa;!Oa&&!Na&&!Da&&To.length>0,Se=!0,await $t("agent",i)}catch(Q){if(xt){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
780
+ [[/VERIFIED]]`,"")||""}`;(l==="view_file"||l==="web_scrape"||l==="file_map"||l==="search_keyword"||l==="get_progress"||l==="getprogress")&&(Bn=`[ACTION RESULT]: ${v} (Context Locked for UI Clarity)`),yield{type:"tool_result",content:Bn,aiContent:ct,binaryPart:Dn,toolName:l},l==="memory"&&!se.startsWith("ERROR:")&&(yield{type:"memory_updated"}),_t++}if(i==="Google"&&pt&&Date.now()-ni>=150){yield*un();let y=Ro(pt);for(let T of y)yield T;pt="",ni=Date.now()}}u.usageMetadata&&(Qt=u.usageMetadata),Qt&&(yield{type:"liveTokens",content:Qt.totalTokenCount})}if(K&&(K=!1,Je?pe+="</think_fluxflow>":(be+="</think_fluxflow>",i==="Google"?pt+="</think_fluxflow>":yield{type:"text",content:"</think_fluxflow>"})),Je&&pe.length>0){let u=0,S=Math.min(bt.length,pe.length);for(let z=S;z>0;z--)if(bt.endsWith(pe.substring(0,z))){u=z;break}let k=pe.substring(u);if(k){let ie=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(bt)?k.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):k.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");if(ie)if(be+=ie,i==="Google")pt+=ie;else{yield*un();let L=Ro(ie);for(let q of L)yield q}}Je=!1,pe=""}if(An){let u=An,S=(ht==="tool"||ht==="action")&&(u.startsWith("[tool:")||u.startsWith("[action:"));An="",uo=!1,ht=null,to=!1,go=!1,S||(i==="Google"?pt+=u:yield{type:"text",content:u})}if(yield*un(),xt)break;let vo=(be||"").trim(),Oa=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(vo.toLowerCase())||/\[\[END\]\]/i.test(vo.toLowerCase()),Na=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(vo.toLowerCase()),Da=je.length>0||Bt!==null,Hi=Ht(vo).trim(),Fa=/(\p{Emoji_Presentation}|\p{Extended_Pictographic})$/u.test(Hi),Ba=/([.!?"'*_`|\]\)”’~~]+|\s|`{3}|[\u200B-\u200D\uFEFF])$/u.test(Hi.trim()),Ua=/[.!?}"'`’“”]$|```$/s.test(Hi)||Ba||Fa;!Oa&&!Na&&!Da&&vo.length>0,ke=!0,await Lt("agent",i)}catch(Q){if(xt){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
780
781
 
781
- \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(String(Q).includes("Incomplete JSON segment at the end")){j&&(j=!1,Qe?pe+="</think_fluxflow>":(be+="</think_fluxflow>",yield{type:"text",content:"</think_fluxflow>"})),Se=!0,await $t("agent",i);break}if(j&&(j=!1,Qe?pe+="</think_fluxflow>":be+="</think_fluxflow>"),Qe&&pe.length>0){let St=0,ot=Math.min(bt.length,pe.length);for(let Vt=ot;Vt>0;Vt--)if(bt.endsWith(pe.substring(0,Vt))){St=Vt;break}let mt=pe.substring(St);if(mt){let rt=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(bt)?mt.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):mt.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");rt&&(be+=rt)}Qe=!1,pe=""}let E=Q instanceof Error?(()=>{try{return JSON.parse(JSON.parse(Q.message).error.message).error.message}catch{return String(Q)}})():String(Q),gt=new Date().toLocaleString(),fe=U.join(eo,"agent");we.existsSync(fe)||we.mkdirSync(fe,{recursive:!0}),we.appendFileSync(U.join(fe,"error.log"),`ERROR [${gt}]: ${E}
782
+ \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(String(Q).includes("Incomplete JSON segment at the end")){K&&(K=!1,Je?pe+="</think_fluxflow>":(be+="</think_fluxflow>",yield{type:"text",content:"</think_fluxflow>"})),ke=!0,await Lt("agent",i);break}if(K&&(K=!1,Je?pe+="</think_fluxflow>":be+="</think_fluxflow>"),Je&&pe.length>0){let St=0,it=Math.min(bt.length,pe.length);for(let Vt=it;Vt>0;Vt--)if(bt.endsWith(pe.substring(0,Vt))){St=Vt;break}let mt=pe.substring(St);if(mt){let lt=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(bt)?mt.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):mt.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");lt&&(be+=lt)}Je=!1,pe=""}let E=Q instanceof Error?(()=>{try{return JSON.parse(JSON.parse(Q.message).error.message).error.message}catch{return String(Q)}})():String(Q),gt=new Date().toLocaleString(),fe=B.join(oo,"agent");xe.existsSync(fe)||xe.mkdirSync(fe,{recursive:!0}),xe.appendFileSync(B.join(fe,"error.log"),`ERROR [${gt}]: ${E}
782
783
 
783
784
  ----------------------------------------------------------------------
784
785
 
785
- `);let We=Q.status||Q.statusCode||Q.code,At=String(Q).includes("replicas at capacity");if(!(We&&(We>=500&&We<600||We===408||We===429||At)||!We&&(/status[ :]+(5\d\d|408|429)/i.test(String(Q))||/code[ :]+(5\d\d|408|429)/i.test(String(Q))||/(500|503|408|429)/.test(String(Q))))){if($e<fn-3)throw Q;yield{type:"text",content:E},yield{type:"status",content:"Error Occured"}}if(be.trim().length>0||nt>1)if(nt<=fn){nt++;let St=Math.min(1e3*Math.pow(2,nt-1),24e3);if(be.trim().length>0){w.push({role:"agent",text:be});let ot=`[system]
786
+ `);let We=Q.status||Q.statusCode||Q.code,Ct=String(Q).includes("replicas at capacity");if(!(We&&(We>=500&&We<600||We===408||We===429||Ct)||!We&&(/status[ :]+(5\d\d|408|429)/i.test(String(Q))||/code[ :]+(5\d\d|408|429)/i.test(String(Q))||/(500|503|408|429)/.test(String(Q))))){if(Pe<fn-3)throw Q;yield{type:"text",content:E},yield{type:"status",content:"Error Occured"}}if(be.trim().length>0||ot>1)if(ot<=fn){ot++;let St=Math.min(1e3*Math.pow(2,ot-1),24e3);if(be.trim().length>0){w.push({role:"agent",text:be});let it=`[system]
786
787
  - seamless continuation: resume immediately. pick up from last words with zero gap/disruption
787
788
  - no repetition: do not repeat any text already written
788
789
  - 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
789
790
  - mid-tool safety: if cutoff was mid-tool call, restart that tool call from start
790
791
  - stealth: do not mention/apologize for cutoff [/system]`;je.length>0?je.forEach((mt,Vt)=>{Vt===je.length-1?w.push({...mt,text:`${mt.text}
791
792
 
792
- ${ot}`}):w.push(mt)}):w.push({role:"user",text:ot}),bt+=be}for(let ot=St/1e3;ot>0&&!xt;ot--)yield{type:"status",content:`Error Occured. Recovering Stream (${nt}/${fn}) [Retrying in ${ot.toFixed(0)}s]...`},await new Promise(mt=>setTimeout(mt,1e3));yield{type:"status",content:"Error Occured. Recovering Stream..."}}else throw new Error(`Stream collapsed too many times. (Failed to resolve ${fn} times)
793
- Error log can be found in \`/export logs\``);else{let ot=e.split("/").slice(e.endsWith("/free")?-2:-1).join("/");if($e<=fn){$e++,nt=1,bt="";let mt=Math.min(1e3*Math.pow(2,$e-1),32e3),Vt=.8+Math.random()*.4,rt=Math.round(mt*Vt);$n=!0,yield{type:"status",content:`Trying to reach ${ot} (${$e}/${fn}) [Retrying in ${(rt/1e3).toFixed(0)}s]`};for(let _e=rt/1e3;_e>0&&!xt;_e--)yield{type:"status",content:`Trying to reach ${ot} (${$e}/${fn}) [Retrying in ${_e.toFixed(0)}s]`},await new Promise(pt=>setTimeout(pt,1e3));yield{type:"status",content:`Trying to reach ${ot}`}}else throw new Error(`Model ${e} cannot be reached. (Failed ${fn} times)
794
- Error log can be found in \`/export logs\``)}}}if(en){let j=en.totalTokenCount||0,Q=en.cachedContentTokenCount||0,E=(en.candidatesTokenCount||0)+(i==="Google"&&en.thoughtsTokenCount||0);await hn("tokens",j,i,J),Q>0&&await hn("cachedTokens",Q,i,J),E>0&&await hn("candidateTokens",E,i,J),Tt!==null&&Tt>0&&await hn("ttft",Tt,i,J),ci({provider:i,model:J,prompt:en.promptTokenCount||0,cached:Q,output:E,reasoning:en.thoughtsTokenCount||0,ttft:Tt}),yield{type:"usage",content:en}}else Tt!==null&&Tt>0&&(await hn("ttft",Tt,i,J),ci({provider:i,model:J,prompt:0,cached:0,output:0,reasoning:0,ttft:Tt}));be=ba(be),Di.push(be);let Ll=jt(be),Bi=pa(be),_a=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(Bi.toLowerCase())||/\[\[END\]\]/i.test(Bi.toLowerCase())||!0,Ol=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(Bi.toLowerCase()),Nl=Et>0;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"};let Ia=Ml(be,/(\[\s*(turn\s*:)?\s*(continue|finish)\s*\]|\[\[END\]\])/gi,"").trim(),Ma=je.length>0||Kn(jt(be)).length>0,Jn=(_a||je.length===0)&&!Wt&&!Xn&&!Gt;if(Jn=je.length===0?Jn:!1,Jn=Ma&&_t||Jo?!1:Jn,be&&be.trim().endsWith('")]')&&je.length===0&&(Jn=!1),Jn){Us=!0;let j=Di.join(`
795
- `),Q=jt(j).trim();yield{type:"interactive_turn_finished",data:{agentText:De,fullAgentTextRaw:j,history:[...w],needTitle:Ae}},w.length>0&&w[w.length-1].role==="agent"?w[w.length-1].text=Q:w.push({role:"agent",text:Q}),w.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(`
793
+ ${it}`}):w.push(mt)}):w.push({role:"user",text:it}),bt+=be}for(let it=St/1e3;it>0&&!xt;it--)yield{type:"status",content:`Error Occured. Recovering Stream (${ot}/${fn}) [Retrying in ${it.toFixed(0)}s]...`},await new Promise(mt=>setTimeout(mt,1e3));yield{type:"status",content:"Error Occured. Recovering Stream..."}}else throw new Error(`Stream collapsed too many times. (Failed to resolve ${fn} times)
794
+ Error log can be found in \`/export logs\``);else{let it=e.split("/").slice(e.endsWith("/free")?-2:-1).join("/");if(Pe<=fn){Pe++,ot=1,bt="";let mt=Math.min(1e3*Math.pow(2,Pe-1),32e3),Vt=.8+Math.random()*.4,lt=Math.round(mt*Vt);Ln=!0,yield{type:"status",content:`Trying to reach ${it} (${Pe}/${fn}) [Retrying in ${(lt/1e3).toFixed(0)}s]`};for(let _e=lt/1e3;_e>0&&!xt;_e--)yield{type:"status",content:`Trying to reach ${it} (${Pe}/${fn}) [Retrying in ${_e.toFixed(0)}s]`},await new Promise(pt=>setTimeout(pt,1e3));yield{type:"status",content:`Trying to reach ${it}`}}else throw new Error(`Model ${e} cannot be reached. (Failed ${fn} times)
795
+ Error log can be found in \`/export logs\``)}}}if(Qt){let K=Qt.totalTokenCount||0,Q=Qt.cachedContentTokenCount||0,E=(Qt.candidatesTokenCount||0)+(i==="Google"&&Qt.thoughtsTokenCount||0);await hn("tokens",K,i,J),Q>0&&await hn("cachedTokens",Q,i,J),E>0&&await hn("candidateTokens",E,i,J),At!==null&&At>0&&await hn("ttft",At,i,J),gi({provider:i,model:J,prompt:Qt.promptTokenCount||0,cached:Q,output:E,reasoning:Qt.thoughtsTokenCount||0,ttft:At}),yield{type:"usage",content:Qt}}else At!==null&&At>0&&(await hn("ttft",At,i,J),gi({provider:i,model:J,prompt:0,cached:0,output:0,reasoning:0,ttft:At}));be=Sa(be),Ui.push(be);let Ll=Ht(be),Gi=ha(be),_a=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(Gi.toLowerCase())||/\[\[END\]\]/i.test(Gi.toLowerCase())||!0,Ol=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(Gi.toLowerCase()),Nl=_t>0;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"};let Ia=Ml(be,/(\[\s*(turn\s*:)?\s*(continue|finish)\s*\]|\[\[END\]\])/gi,"").trim(),Ma=je.length>0||Vn(Ht(be)).length>0,eo=(_a||je.length===0)&&!Ut&&!Zn&&!Wt;if(eo=je.length===0?eo:!1,eo=Ma&&It||ti?!1:eo,be&&be.trim().endsWith('")]')&&je.length===0&&(eo=!1),eo){Ws=!0;let K=Ui.join(`
796
+ `),Q=Ht(K).trim();yield{type:"interactive_turn_finished",data:{agentText:Be,fullAgentTextRaw:K,history:[...w],needTitle:ve}},w.length>0&&w[w.length-1].role==="agent"?w[w.length-1].text=Q:w.push({role:"agent",text:Q}),w.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(`
796
797
 
797
798
  [system] user question. resolve this specific query within '[ANSWER] ... [/ANSWER]' concisely, naturally [/system]
798
799
  `,"").replaceAll(`[system] user question. resolve this specific query within '[ANSWER] ... [/ANSWER]' concisely, naturally
@@ -800,36 +801,37 @@ Error log can be found in \`/export logs\``)}}}if(en){let j=en.totalTokenCount||
800
801
  `,"").replaceAll(`[system] **strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow>** [/system]
801
802
  `,"").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,""),(i==="Mistral"||i==="Google"&&e?.toLowerCase().startsWith("gemma"))&&(E.text.startsWith("[ACTION RESULT]")||E.text.startsWith("[TOOL RESULT]")))){let fe=`
802
803
  [system] Action result received. Analyze output and proceed with your turn [/system]`,We=`
803
- [system] Action result received. Analyze output and proceed with your turn. **strictly follow thinking policy. do not start a response without <think_fluxflow>...</think_fluxflow>** [/system]`;E.text=E.text.replaceAll(We,"").replaceAll(fe,"").trim()}}),yield{type:"status",content:"[end]"}}if(Jn)break;let Pa=Ia.trim()||"*Working...*";if(w.push({role:"agent",text:Pa}),je.length>0||Pn){if(je.length>0){let j=je.map(rt=>rt.text).join(`
804
+ [system] Action result received. Analyze output and proceed with your turn. **strictly follow thinking policy. do not start a response without <think_fluxflow>...</think_fluxflow>** [/system]`;E.text=E.text.replaceAll(We,"").replaceAll(fe,"").trim()}}),yield{type:"status",content:"[end]"}}if(eo)break;let Pa=Ia.trim()||"*Working...*";if(w.push({role:"agent",text:Pa}),je.length>0||$n){if(je.length>0){let K=je.map(lt=>lt.text).join(`
804
805
 
805
- `),Q=jt(be),E=Kn(Q),gt=ma(Q,E),fe=Ii(gt),We=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,At=[],me=[],St;for(;(St=We.exec(fe))!==null;)me.push({index:St.index,toolName:St[1]});for(let rt=0;rt<me.length;rt++){let _e=me[rt],pt=rt+1<me.length?me[rt+1].index:Q.length;E.some(un=>un.fullMatch&&Q.startsWith(un.fullMatch,_e.index))||At.push(Q.substring(_e.index,pt))}let ot=At.length,mt=je.length+ot;if(ot>0){let rt=At.join(`
806
- `),_e=ha(rt);j+=`
806
+ `),Q=Ht(be),E=Vn(Q),gt=pa(Q,E),fe=Li(gt),We=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,Ct=[],me=[],St;for(;(St=We.exec(fe))!==null;)me.push({index:St.index,toolName:St[1]});for(let lt=0;lt<me.length;lt++){let _e=me[lt],pt=lt+1<me.length?me[lt+1].index:Q.length;E.some(un=>un.fullMatch&&Q.startsWith(un.fullMatch,_e.index))||Ct.push(Q.substring(_e.index,pt))}let it=Ct.length,mt=je.length+it;if(it>0){let lt=Ct.join(`
807
+ `),_e=ya(lt);K+=`
807
808
 
808
809
  [system] Only ${je.length} out of ${mt} attempted tool calls were executed.
809
810
  ${_e?`Parsing Issues Detected:
810
811
  ${_e}
811
- `:""}Verify proper structure compliance [action:ActionName(arg="value")] & try failed calls again [/system]`;for(let pt=0;pt<ot;pt++)await $t("toolFailure")}let Vt=je.find(rt=>rt.binaryPart)?.binaryPart||null;w.push({role:"user",text:j,binaryPart:Vt})}}else if(!xt){let j=be.replace(/(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\]|$)/i,""),Q=Kn(j),E=ma(j,Q),fe=(Ii(E).match(/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi)||[]).length;if(Jo||_t&&fe>0||fe>0){let We=ha(j),At=We?`[system] Failed to execute ${fe>0?fe:1} action call${fe>1?"s":""} due to syntax/structure issues:
812
- ${We} [/system]`:`[system] Failed to execute ${fe>0?fe:1} action${fe>1?"s":""}. Verify proper structure compliance [action:ActionName(arg="value")] & try again [/system]`;w.push({role:"user",text:At}),await $t("toolFailure"),yield{type:"visual_feedback",content:`
813
- ${Lt("\u2718 Model produced malformed tool call")}
812
+ `:""}Verify proper structure compliance [action:ActionName(arg="value")] & try failed calls again [/system]`;for(let pt=0;pt<it;pt++)await Lt("toolFailure")}let Vt=je.find(lt=>lt.binaryPart)?.binaryPart||null;w.push({role:"user",text:K,binaryPart:Vt})}}else if(!xt){let K=be.replace(/(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\]|$)/i,""),Q=Vn(K),E=pa(K,Q),fe=(Li(E).match(/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi)||[]).length;if(ti||It&&fe>0||fe>0){let We=ya(K),Ct=We?`[system] Failed to execute ${fe>0?fe:1} action call${fe>1?"s":""} due to syntax/structure issues:
813
+ ${We} [/system]`:`[system] Failed to execute ${fe>0?fe:1} action${fe>1?"s":""}. Verify proper structure compliance [action:ActionName(arg="value")] & try again [/system]`;w.push({role:"user",text:Ct}),await Lt("toolFailure"),yield{type:"visual_feedback",content:`
814
+ ${Ot("\u2718 Model produced malformed tool call")}
814
815
  `}}else yield{type:"visual_feedback",content:`
815
- ${Lt("\u2718 Loop Detected")}
816
- `},w.push({role:"user",text:`[system] ${Xn&&!Wt?"Stuttering Detected by Internal System. Re-calibrate your response & proceed.":`${Wt?" Over Thinking":" Loop"} Detected by Internal System${Wt?" for current Effort Level":""}. ${Wt?"If you have planned the task, prioritize execution/output":"If you have finished your task provide a simple summary and end"}`} [/system]`});Wt=!1,Xn=!1,Gt=!1}p?.advanceRollback&&await Mo.recordTurnDelta(f,b+1,le),Fi=le.includes("recapture_screen"),Jo=Et>0||Pn}if(!Us&&!xt){let b="\u2726 Turn safety limit reached. Stopping execution.";yield{type:"text",content:`
816
+ ${Ot("\u2718 Loop Detected")}
817
+ `},w.push({role:"user",text:`[system] ${Zn&&!Ut?"Stuttering Detected by Internal System. Re-calibrate your response & proceed.":`${Ut?" Over Thinking":" Loop"} Detected by Internal System${Ut?" for current Effort Level":""}. ${Ut?"If you have planned the task, prioritize execution/output":"If you have finished your task provide a simple summary and end"}`} [/system]`});Ut=!1,Zn=!1,Wt=!1}p?.advanceRollback&&await Oo.recordTurnDelta(f,b+1,le),Wi=le.includes("recapture_screen"),ti=_t>0||$n}if(!Ws&&!xt){let b="\u2726 Turn safety limit reached. Stopping execution.";yield{type:"text",content:`
817
818
 
818
819
  ${b}
819
- `};let ge=(Di.join(`
820
+ `};let ge=(Ui.join(`
820
821
  `)+`
821
- ${b}`).trim();yield{type:"interactive_turn_finished",data:{agentText:De,fullAgentTextRaw:ge,history:[...w],needTitle:Ae}},yield{type:"status",content:"[end]"}}}catch(B){let w=B?.cause?` (Cause: ${B.cause?.message||String(B.cause)})`:"",he=(B instanceof Error?(()=>{try{return JSON.parse(JSON.parse(B.message).error.message).error.message}catch{return(B.message?`${B.message}${w}`:"")||String(B)}})():String(B)).replace(/^(Error:\s*)+/i,"");i==="Google"&&!/^[A-Z0-9_\-\s]+ ERROR:/i.test(he)&&(he=`GEMINI ERROR: ${he}`);let Kt=new Date().toLocaleString(),Qt=U.join(eo,"agent");yield{type:"text",content:`
822
+ ${b}`).trim();yield{type:"interactive_turn_finished",data:{agentText:Be,fullAgentTextRaw:ge,history:[...w],needTitle:ve}},yield{type:"status",content:"[end]"}}}catch(W){let w=W?.cause?` (Cause: ${W.cause?.message||String(W.cause)})`:"",Xe=(W instanceof Error?(()=>{try{return JSON.parse(JSON.parse(W.message).error.message).error.message}catch{return(W.message?`${W.message}${w}`:"")||String(W)}})():String(W)).replace(/^(Error:\s*)+/i,"");i==="Google"&&!/^[A-Z0-9_\-\s]+ ERROR:/i.test(Xe)&&(Xe=`GEMINI ERROR: ${Xe}`);let an=new Date().toLocaleString(),ln=B.join(oo,"agent");yield{type:"text",content:`
822
823
 
823
- \u2726 CRITICAL ERROR: ${he.includes("fetch failed")?"Failed to Connect. Check your Internet Connection or Wait a moment":he}
824
- \u2800`},we.existsSync(Qt)||we.mkdirSync(Qt,{recursive:!0}),we.appendFileSync(U.join(Qt,"error.log"),`CRITICAL ERROR [${Kt}]: ${B}${B?.cause?`
825
- CAUSE: ${B.cause?.stack||B.cause}`:""}
824
+ \u2726 CRITICAL ERROR: ${Xe.includes("fetch failed")?"Failed to Connect. Check your Internet Connection or Wait a moment":Xe}
825
+ \u2800`},xe.existsSync(ln)||xe.mkdirSync(ln,{recursive:!0}),xe.appendFileSync(B.join(ln,"error.log"),`CRITICAL ERROR [${an}]: ${W}${W?.cause?`
826
+ CAUSE: ${W.cause?.stack||W.cause}`:""}
826
827
 
827
828
  ----------------------------------------------------------------------
828
829
 
829
- `),typeof flushGoogleBuffer=="function"&&(yield*flushGoogleBuffer()),yield{type:"tool_result",content:`ERROR: [INTERNAL CRITICAL] ${he}`}}finally{tt&&(clearInterval(tt),tt=null),typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),await di.commitTransaction(),p?.advanceRollback&&await Mo.cleanup(f),await to()}yield{type:"status",content:null}},rf=async(e,t,n=null,s=null,o=null,r=null,d=!1,a=null)=>{let m=await li(),f={...m,...t},h=typeof o=="number"&&o>0?o:50,p=(f?.systemSettings?.loopLimits||"Default").toLowerCase();if(p==="extended")h=Math.floor(h*3);else if(p==="env"){let Pe=parseInt(process.env.FLUXFLOW_SUBAGENT_MAX_TURNS||process.env.SUBAGENT_MAX_TURNS||process.env.FLUXFLOW_MAX_LOOPS||process.env.MAX_LOOPS||"",10);Number.isFinite(Pe)&&Pe>0&&(h=Pe)}o=h;let g=process.env.SUBAGENT_MODEL?process.env.SUBAGENT_MODEL.trim():null,i=process.env.SUBAGENT_PROVIDER?process.env.SUBAGENT_PROVIDER.trim():null,x=new Date,I=`${x.getFullYear()}-${x.toLocaleString("en-US",{month:"short"}).toUpperCase()}-${String(x.getDate()).padStart(2,"0")}, ${x.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).replace(":","-")}`,C=(Pe=>{if(!Pe)return null;let X=Pe.toLowerCase();return X==="google"?"Google":X==="deepseek"?"DeepSeek":X==="openrouter"?"OpenRouter":X==="nvidia"?"NVIDIA":X==="mistral"?"Mistral":X==="ollama"?"Ollama":X==="inferx"?"InferX":X==="sensenova"?"SenseNova":X==="poolside"?"Poolside":X==="9router"||X==="9Router"?"9router":X==="aihubmix"||X==="aihub"?"AIHubMix":X==="explabs"||X==="experientiallabs"||X==="experimentallabs"?"ExpLabs":X==="tokenharbor"||X==="token harbor"||X==="token_harbor"||X==="thk"?"TokenHarbor":X==="infron"?"Infron":X==="numes"?"Numes":X==="apinex"||X==="apx"?"APInex":X==="xkiro"||X==="kiro"?"xKiro":X==="coarena"||X==="coarena_ai"?"CoArena":X==="c_openai"||X==="custom_openai"||X==="custom (openai)"||X==="custom"?"c_openai":null})(i),M=f?.systemSettings?.CustomSubAgent?f?.systemSettings?.SubAgentModel:null,F=f?.systemSettings?.CustomSubAgent?f?.systemSettings?.SubAgentProvider:null,G=null;if(M==="ENV"?(G=g,g&&C&&(f.aiProvider=C)):M&&M!=="Default"?(G=M,F&&(f.aiProvider=F)):g&&C&&(f.aiProvider=C),f.aiProvider){let Pe=await zs(f.aiProvider);Pe&&(f.apiKey=Pe)}let $=Pe=>{if(!Pe||typeof Pe!="string")return{allowed:!0};let X=[/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 Ve of X)if(Ve.test(Pe))return{allowed:!1,reason:`Blocked potentially destructive or unsafe command pattern: "${Ve.source}"`};return{allowed:!0}},L=n||G||t?.modelName||t?.activeModel||m.activeModel,Ae=(process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux")==="Windows",De=Ae&&f?.systemSettings?.preferBash!==!1&&Js(),tt="Run(command=string)",B=`Runs ${Ae?Ji()?"powershell":"windows CMD":"bash"} command`;De&&(tt=`Run(command=string, ${Qs()||Ji()?"forcePowershell?=bool:false":"forceCwd?=bool:false"})`,B="Runs in git bash. Or force native shell");let w=`-- ACTIONS (path = relative to CWD, path separator: '/') --
830
+ `),typeof flushGoogleBuffer=="function"&&(yield*flushGoogleBuffer()),yield{type:"tool_result",content:`ERROR: [INTERNAL CRITICAL] ${Xe}`}}finally{et&&(clearInterval(et),et=null),typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),await mi.commitTransaction(),p?.advanceRollback&&await Oo.cleanup(f),await io()}yield{type:"status",content:null}},rf=async(e,t,n=null,s=null,o=null,r=null,d=!1,a=null)=>{let m=await ui(),f={...m,...t},h=typeof o=="number"&&o>0?o:50,p=(f?.systemSettings?.loopLimits||"Default").toLowerCase();if(p==="extended")h=Math.floor(h*3);else if(p==="env"){let we=parseInt(process.env.FLUXFLOW_SUBAGENT_MAX_TURNS||process.env.SUBAGENT_MAX_TURNS||process.env.FLUXFLOW_MAX_LOOPS||process.env.MAX_LOOPS||"",10);Number.isFinite(we)&&we>0&&(h=we)}o=h;let g=process.env.SUBAGENT_MODEL?process.env.SUBAGENT_MODEL.trim():null,i=process.env.SUBAGENT_PROVIDER?process.env.SUBAGENT_PROVIDER.trim():null,x=new Date,I=`${x.getFullYear()}-${x.toLocaleString("en-US",{month:"short"}).toUpperCase()}-${String(x.getDate()).padStart(2,"0")}, ${x.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).replace(":","-")}`,C=(we=>{if(!we)return null;let te=we.toLowerCase();return te==="google"?"Google":te==="deepseek"?"DeepSeek":te==="openrouter"?"OpenRouter":te==="nvidia"?"NVIDIA":te==="mistral"?"Mistral":te==="ollama"?"Ollama":te==="inferx"?"InferX":te==="sensenova"?"SenseNova":te==="poolside"?"Poolside":te==="9router"||te==="9Router"?"9router":te==="aihubmix"||te==="aihub"?"AIHubMix":te==="explabs"||te==="experientiallabs"||te==="experimentallabs"?"ExpLabs":te==="tokenharbor"||te==="token harbor"||te==="token_harbor"||te==="thk"?"TokenHarbor":te==="infron"?"Infron":te==="numes"?"Numes":te==="apinex"||te==="apx"?"APInex":te==="xkiro"||te==="kiro"?"xKiro":te==="coarena"||te==="coarena_ai"?"CoArena":te==="c_openai"||te==="custom_openai"||te==="custom (openai)"||te==="custom"?"c_openai":null})(i),P=`You cannot execute tools. Instead write the action string in chat you WOULD have written, without markdown wrappers. Then wait for systtem response
831
+ `,N=f?.systemSettings?.subAgentWildcardTooling===!0;N&&(f.wildcardTooling=!f.wildcardTooling);let U=f?.systemSettings?.CustomSubAgent?f?.systemSettings?.SubAgentModel:null,$=f?.systemSettings?.CustomSubAgent?f?.systemSettings?.SubAgentProvider:null,M=null;if(U==="ENV"?(M=g,g&&C&&(f.aiProvider=C)):U&&U!=="Default"?(M=U,$&&(f.aiProvider=$)):g&&C&&(f.aiProvider=C),f.aiProvider){let we=await qs(f.aiProvider);we&&(f.apiKey=we)}let Se=we=>{if(!we||typeof we!="string")return{allowed:!0};let te=[/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 Ne of te)if(Ne.test(we))return{allowed:!1,reason:`Blocked potentially destructive or unsafe command pattern: "${Ne.source}"`};return{allowed:!0}},ve=n||M||t?.modelName||t?.activeModel||m.activeModel,et=(process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux")==="Windows",W=et&&f?.systemSettings?.preferBash!==!1&&Qs(),w="Run(command=string)",rn=`Runs ${et?es()?"powershell":"windows CMD":"bash"} command`;W&&(w=`Run(command=string, ${Zs()||es()?"forcePowershell?=bool:false":"forceCwd?=bool:false"})`,rn="Runs in git bash. Or force native shell");let an=`-- ACTIONS (path = relative to CWD, path separator: '/') --
830
832
  In chat output the format \`[action:ActionName(arg1="value1")]\` in NEW line
831
833
  Rules:
832
- - Max 3 actions/turn
834
+ - Max ${process.env.MAX_TOOL_LIMIT||"3"} actions/turn
833
835
  - JSON escape literal sequences, backslash: \\\\, newLine: \\ n
834
836
  - Same file, multiple edits? ONE PatchFile \u226415 blocks
835
837
  - Need text or huge file? CodeSearch > Full Read
@@ -845,17 +847,17 @@ ${d?"- AskMain(question=string). Communicate with PARENT/MAIN AGENT. When clarif
845
847
  - WebScrape(url=string)
846
848
 
847
849
  **Workspace**
848
- - CodeSearch(keyword="regex", path?="file/glob, inclusion !exclusion ;-separated")
850
+ - CodeSearch(keyword="regex OR word match", path?="file/glob, inclusion !exclusion ;separated")
849
851
  - ReadFolder(path=string, recurse?=int[1..3])
850
852
  - FindFile(basename=string)
851
853
  - ReadFile(path=string, startLine?=int, endLine?=int)
852
854
  - PatchFile(path=string, allowMultiple?=bool, searchContent1="string match OR ^LINE:start..end$", newContent1=string, ...MAX15). Small searchString. Line Anchors: ^LINE:...$ syntax, must for large blocks & escape sequences
853
855
  - WriteFile(path=string, content=string). Creates/Overwrites. File Exist? PatchFile > WriteFile
854
- - ${tt}. ${B}. Destructive command \u2192 Ask user`.trim(),wn=`=== START SYSTEM PROMPT ===
856
+ - ${w}. ${rn}. Destructive command \u2192 Ask user`.trim(),ln=`=== START SYSTEM PROMPT ===
855
857
  Identity: FluxFlow subagent helping the main Agent
856
858
  CWD: ${process.cwd()}
857
859
 
858
- ${w.trimEnd()}
860
+ ${an.trimEnd()}
859
861
 
860
862
  -- THINKING GUIDANCE --
861
863
  Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking. Just focus on task completion. Before actions, provide user facing summary of findings & decisions IN detail
@@ -863,38 +865,38 @@ Main focus: actions and task, not chatting
863
865
  On completion, provide a detailed summary in Tables/Markdown Format with file modified info. If any task failed report back in detail
864
866
 
865
867
  Current Time: ${I}
866
- === END SYSTEM PROMPT ===`,he=Array.isArray(a)&&a.length>0?a:[{role:"user",text:`Task: ${e}`}];Array.isArray(a)&&a.length>0&&he.push({role:"user",text:`Follow-up instruction: ${e}`});let Kt=0,Qt="";for(;Kt<o;){let Pe=await qi("subagent",f);if(!Pe.allowed)throw new Error(Pe.reason||`Budget Exhausted for Provider (${f?.aiProvider||"Subagent"})`);if(xt){if(t?.taskId&&typeof Ht<"u"){let K=Ht.find(N=>N.id===t.taskId);K&&(K.status="cancelled")}throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}if(t?.taskId&&typeof Ht<"u"){let K=Ht.find(N=>N.id===t.taskId);if(K&&K.status==="cancelled")throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}let X=he.map(K=>({role:K.role==="user"?"user":"model",parts:[{text:K.text}]}));r&&r(`[Subagent Turn ${Kt+1}]...`);let Ve=["Fast","Low","Medium","High"],ln=process.env.SUBAGENT_THINKING,In=Ve.includes(ln)?ln:"Low",bn=(await $l(f,L,X,wn,In)).text||"",Fe=ba(jt(bn).trim());Qt=Fe,r&&r(`[Subagent Response]
867
- ${Fe}
868
- `),he.push({role:"agent",text:Fe});let wt=Kn(Fe);if(wt.length===0)break;let Ft=wt.filter(K=>K.toolName.toLowerCase()==="askmain"||K.toolName.toLowerCase()==="ask_main"),Sn=!1,cn="";for(let K of wt){if(xt){if(t?.taskId&&typeof Ht<"u"){let k=Ht.find(te=>te.id===t.taskId);k&&(k.status="cancelled")}throw new Error("Subagent task was cancelled.")}if(t?.taskId&&typeof Ht<"u"){let k=Ht.find(te=>te.id===t.taskId);if(k&&k.status==="cancelled")throw new Error("Subagent task was cancelled.")}let N=K.toolName.toLowerCase();if(N==="askuser"&&(N="ask"),N==="askmain"||N==="ask_main"){if(Sn)continue;Sn=!0;let k="";if(Ft.length===1?k=O(Ft[0].args).question||Ft[0].args:k=Ft.map((te,Je)=>{let Ce=O(te.args);return`Q${Je+1}: ${Ce.question||te.args}`}).join(`
869
- `),t.onAskMain){r&&r(`[Executing Tool] AskMain("${k}")...`);let te=await t.onAskMain(k);r&&r(`[Action Result]
870
- Answer from Main Agent: ${te}
871
- `),cn+=`[ACTION RESULT for AskMain]: Answer from Main Agent: ${te}
868
+ === END SYSTEM PROMPT ===`,ao=N?`${P}Task: ${e}`:`Task: ${e}`,wt=Array.isArray(a)&&a.length>0?a:[{role:"user",text:ao}];if(Array.isArray(a)&&a.length>0){let we=wt.find(Ne=>Ne.role==="user");we&&we.text.startsWith(P)&&(we.text=we.text.slice(P.length).replace(/^\s*Task:/u,"Task:"));let te=N?`${P}Follow-up instruction: ${e}`:`Follow-up instruction: ${e}`;wt.push({role:"user",text:te})}let zn=0,To="";for(;zn<o;){let we=await Ji("subagent",f);if(!we.allowed)throw new Error(we.reason||`Budget Exhausted for Provider (${f?.aiProvider||"Subagent"})`);if(xt){if(t?.taskId&&typeof Gt<"u"){let H=Gt.find(D=>D.id===t.taskId);H&&(H.status="cancelled")}throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}if(t?.taskId&&typeof Gt<"u"){let H=Gt.find(D=>D.id===t.taskId);if(H&&H.status==="cancelled")throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}let te=wt.map(H=>({role:H.role==="user"?"user":"model",parts:[{text:H.text}]}));r&&r(`[Subagent Turn ${zn+1}]...`);let Ne=["Fast","Low","Medium","High"],De=process.env.SUBAGENT_THINKING,jt=Ne.includes(De)?De:"Low",qn=(await $l(f,ve,te,ln,jt)).text||"",Mn=Sa(Ht(qn).trim());To=Mn,r&&r(`[Subagent Response]
869
+ ${Mn}
870
+ `),wt.push({role:"agent",text:Mn});let cn=Vn(Mn);if(cn.length===0)break;let dn=cn.filter(H=>H.toolName.toLowerCase()==="askmain"||H.toolName.toLowerCase()==="ask_main"),wn=!1,Kt="";for(let H of cn){if(xt){if(t?.taskId&&typeof Gt<"u"){let A=Gt.find(V=>V.id===t.taskId);A&&(A.status="cancelled")}throw new Error("Subagent task was cancelled.")}if(t?.taskId&&typeof Gt<"u"){let A=Gt.find(V=>V.id===t.taskId);if(A&&A.status==="cancelled")throw new Error("Subagent task was cancelled.")}let D=H.toolName.toLowerCase();if(D==="askuser"&&(D="ask"),D==="askmain"||D==="ask_main"){if(wn)continue;wn=!0;let A="";if(dn.length===1?A=O(dn[0].args).question||dn[0].args:A=dn.map((V,tt)=>{let nt=O(V.args);return`Q${tt+1}: ${nt.question||V.args}`}).join(`
871
+ `),t.onAskMain){r&&r(`[Executing Tool] AskMain("${A}")...`);let V=await t.onAskMain(A);r&&r(`[Action Result]
872
+ Answer from Main Agent: ${V}
873
+ `),Kt+=`[ACTION RESULT for AskMain]: Answer from Main Agent: ${V}
872
874
 
873
- `,await $t("toolSuccess")}else cn+=`[ACTION RESULT for AskMain]: ERROR: Main agent communication channel not available.
875
+ `,await Lt("toolSuccess")}else Kt+=`[ACTION RESULT for AskMain]: ERROR: Main agent communication channel not available.
874
876
 
875
- `;continue}if(!(s?s.some(k=>k.toLowerCase()===N):!0)){let k=`ERROR: Tool [${K.toolName}] is not in the allowed tools list for this subagent.`;r&&r(`[Blocked Tool Call] ${K.toolName} - not allowed
876
- `),cn+=`${k}
877
+ `;continue}if(!(s?s.some(A=>A.toLowerCase()===D):!0)){let A=`ERROR: Tool [${H.toolName}] is not in the allowed tools list for this subagent.`;r&&r(`[Blocked Tool Call] ${H.toolName} - not allowed
878
+ `),Kt+=`${A}
877
879
 
878
- `;continue}if(N==="exec_command"||N==="execcommand"||N==="run"){let k=O(K.args,["command","background","timeout"]).command||"",te=$(k);if(!te.allowed){let Je=`ERROR: [SECURITY RESTRICTION] Subagent execution blocked command: ${te.reason}`;r&&r(`[Blocked Command] ${k} - ${te.reason}
879
- `),cn+=`${Je}
880
+ `;continue}if(D==="exec_command"||D==="execcommand"||D==="run"){let A=O(H.args,["command","background","timeout"]).command||"",V=Se(A);if(!V.allowed){let tt=`ERROR: [SECURITY RESTRICTION] Subagent execution blocked command: ${V.reason}`;r&&r(`[Blocked Command] ${A} - ${V.reason}
881
+ `),Kt+=`${tt}
880
882
 
881
- `;continue}}let st="";if(N==="web_search"||N==="websearch")st=`\u2714 \x1B[95mSearched\x1B[0m: ${O(K.args,["query","limit","aiMode"]).query||""}`;else if(N==="web_scrape"||N==="webscrape")st=`\u2714 \x1B[95mScraped\x1B[0m: ${O(K.args,["url"]).url||""}`;else if(N==="search_keyword"||N==="searchkeyword"||N==="codesearch"||N==="code_search"){let k=O(K.args,["keyword","path","fuzzy","subString","regex"]),te=k.keyword||"",Je=k.path||"";st=`${te?"\u2714":"\u2718"} \x1B[95mSearched\x1B[0m: ${te||"No Query"}${Je?` \u2192 ${Je.replaceAll("\\","/")}`:""}`}else if(N==="view_file"||N==="viewfile"||N==="readfile")st=`\u2714 \x1B[95mRead\x1B[0m: ${(O(K.args,["path","targetPath","file","StartLine","EndLine","start_line","end_line","startLine","endLine"]).path||"").replaceAll("\\","/")}`;else if(N==="find_file"||N==="findfile"){let k=O(K.args,["basename","name","path","file","query"]),te=k.basename||k.name||k.path||k.file||k.query||"";st=`${te?"\u2714":"\u2718"} \x1B[95mLocated\x1B[0m: ${te||"No Query"}`}else if(N==="list_files"||N==="read_folder"||N==="readfolder"){let k=O(K.args,["path","recurse","include"]).path||null,te=O(K.args,["path","recurse","include"]).recurse||0;st=`${k?"\u2714":"\u2718"} \x1B[95mBrowsed\x1B[0m: ${k?`${k.replaceAll("\\","/")}${te>0?`${k.endsWith("/")?`*${te}`:`/*${te}`}`:`${k.endsWith("/")?"":"/"}`}`:""}`}else if(N==="write_file"||N==="writefile"){let k=O(K.args,["path","content"]).path||null;st=`${k?"\u2714":"\u2718"} \x1B[95mCreated\x1B[0m: ${k?`${k.replaceAll("\\","/")}`:"No File Changes"}`}else if(N==="update_file"||N==="updatefile"||N==="patchfile"||N==="patch_file"){let k=O(K.args,["path","allowMultiple","content","searchContent*","replaceContent*","newContent*"]),te=k.path||null,Ce=Object.entries(k).some(([lt,ft])=>lt.startsWith("searchContent")&&typeof ft=="string"&&ft.startsWith("^LINE:"))?"\u1361":":";st=`${te?"\u2714":"\u2718"} \x1B[95mEdited\x1B[0m${Ce} ${te?`${te.replaceAll("\\","/")}`:"No File Changes"}`}else if(N==="exec_command"||N==="execcommand"||N==="run"){let k=O(K.args,["command","background","timeout"]).command||null;st=`${k?"\u2714":"\u2718"} \x1B[95mExecuted\x1B[0m: ${k?k.slice(0,100)+(k.length>100?"...":""):"No Command"}`}else if(N==="file_map"||N==="filemap"){let k=O(K.args,["path"]).path||"";st=`${k?"\u2714":"\u2718"} \x1B[95mIndexed\x1B[0m: ${k?`${k.replaceAll("\\","/")}`:"File Not Found"}`}else if(N==="await"){let{time:k}=O(K.args,["time","timeout","seconds","sec"]),te=parseFloat(k)||0;te<10&&(te=10),te>180&&(te=180),st=`\u2714 \x1B[95mAwaiting\x1B[0m \u2192 ${(Ce=>{if(Ce>=60){let lt=Math.floor(Ce/60),ft=Ce%60;return`${lt}m${ft>0?` ${ft}s`:""}`}return`${Ce}s`})(te)}`}else{let k=vs[N]||K.toolName,te=oo(N,K.args);st=`\u2714 \x1B[95m${k}\x1B[0m${te?`: ${te}`:""}`}t.onVisualFeedback&&st&&t.onVisualFeedback(st),r&&r(`[Executing Tool] ${K.toolName}(${K.args})...`);try{let k=await xs(K.toolName,K.args,{...t,mode:"Flux"});r&&r(`[Action Result]
882
- ${k}
883
- `);let Je=(k||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");Je.includes("[[VERIFIED]]")&&(Je=Je.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to save tokens.
884
- `));let Ce;if((N==="write_file"||N==="writefile")&&!Je.startsWith("ERROR:")){let lt=Je.replace(/^\[\[SAME\]\]\s*\r?\n?/,""),ft=lt.match(/\n\s*(\[Note:\s*'~'\s*resolved\s*to\s*user\s*home\s*directory[\s\S]*?\])\s*$/),Zt=ft?`
883
+ `;continue}}let Ee="";if(D==="web_search"||D==="websearch")Ee=`\u2714 \x1B[95mSearched\x1B[0m: ${O(H.args,["query","limit","aiMode"]).query||""}`;else if(D==="web_scrape"||D==="webscrape")Ee=`\u2714 \x1B[95mScraped\x1B[0m: ${O(H.args,["url"]).url||""}`;else if(D==="search_keyword"||D==="searchkeyword"||D==="codesearch"||D==="code_search"){let A=O(H.args,["keyword","path","fuzzy","subString","regex"]),V=A.keyword||"",tt=A.path||"";Ee=`${V?"\u2714":"\u2718"} \x1B[95mSearched\x1B[0m: ${V||"No Query"}${tt?` \u2192 ${tt.replaceAll("\\","/")}`:""}`}else if(D==="view_file"||D==="viewfile"||D==="readfile")Ee=`\u2714 \x1B[95mRead\x1B[0m: ${(O(H.args,["path","targetPath","file","StartLine","EndLine","start_line","end_line","startLine","endLine"]).path||"").replaceAll("\\","/")}`;else if(D==="find_file"||D==="findfile"){let A=O(H.args,["basename","name","path","file","query"]),V=A.basename||A.name||A.path||A.file||A.query||"";Ee=`${V?"\u2714":"\u2718"} \x1B[95mLocated\x1B[0m: ${V||"No Query"}`}else if(D==="list_files"||D==="read_folder"||D==="readfolder"){let A=O(H.args,["path","recurse","include"]).path||null,V=O(H.args,["path","recurse","include"]).recurse||0;Ee=`${A?"\u2714":"\u2718"} \x1B[95mBrowsed\x1B[0m: ${A?`${A.replaceAll("\\","/")}${V>0?`${A.endsWith("/")?`*${V}`:`/*${V}`}`:`${A.endsWith("/")?"":"/"}`}`:""}`}else if(D==="write_file"||D==="writefile"){let A=O(H.args,["path","content"]).path||null;Ee=`${A?"\u2714":"\u2718"} \x1B[95mCreated\x1B[0m: ${A?`${A.replaceAll("\\","/")}`:"No File Changes"}`}else if(D==="update_file"||D==="updatefile"||D==="patchfile"||D==="patch_file"){let A=O(H.args,["path","allowMultiple","content","searchContent*","replaceContent*","newContent*"]),V=A.path||null,nt=Object.entries(A).some(([rt,kt])=>rt.startsWith("searchContent")&&typeof kt=="string"&&/^\^line:/i.test(kt))?"\u1361":":";Ee=`${V?"\u2714":"\u2718"} \x1B[95mEdited\x1B[0m${nt} ${V?`${V.replaceAll("\\","/")}`:"No File Changes"}`}else if(D==="exec_command"||D==="execcommand"||D==="run"){let A=O(H.args,["command","background","timeout"]).command||null;Ee=`${A?"\u2714":"\u2718"} \x1B[95mExecuted\x1B[0m: ${A?A.slice(0,100)+(A.length>100?"...":""):"No Command"}`}else if(D==="file_map"||D==="filemap"){let A=O(H.args,["path"]).path||"";Ee=`${A?"\u2714":"\u2718"} \x1B[95mIndexed\x1B[0m: ${A?`${A.replaceAll("\\","/")}`:"File Not Found"}`}else if(D==="await"){let{time:A}=O(H.args,["time","timeout","seconds","sec"]),V=parseFloat(A)||0;V<10&&(V=10),V>180&&(V=180),Ee=`\u2714 \x1B[95mAwaiting\x1B[0m \u2192 ${(nt=>{if(nt>=60){let rt=Math.floor(nt/60),kt=nt%60;return`${rt}m${kt>0?` ${kt}s`:""}`}return`${nt}s`})(V)}`}else{let A=Is[D]||H.toolName,V=ro(D,H.args);Ee=`\u2714 \x1B[95m${A}\x1B[0m${V?`: ${V}`:""}`}t.onVisualFeedback&&Ee&&t.onVisualFeedback(Ee),r&&r(`[Executing Tool] ${H.toolName}(${H.args})...`);try{let A=await Ss(H.toolName,H.args,{...t,mode:"Flux"});r&&r(`[Action Result]
884
+ ${A}
885
+ `);let tt=(A||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");tt.includes("[[VERIFIED]]")&&(tt=tt.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to save tokens.
886
+ `));let nt;if((D==="write_file"||D==="writefile")&&!tt.startsWith("ERROR:")){let rt=tt.replace(/^\[\[SAME\]\]\s*\r?\n?/,""),kt=rt.match(/\n\s*(\[Note:\s*'~'\s*resolved\s*to\s*user\s*home\s*directory[\s\S]*?\])\s*$/),kn=kt?`
885
887
 
886
- ${ft[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(lt)){let dn=lt.search(/^- Content Preview:/m);Ce=`[ACTION RESULT]: ${dn!==-1?lt.slice(0,dn).trimEnd():lt}
888
+ ${kt[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(rt)){let Pn=rt.search(/^- Content Preview:/m);nt=`[ACTION RESULT]: ${Pn!==-1?rt.slice(0,Pn).trimEnd():rt}
887
889
 
888
- [Old file content for reversal reference. Replaced with new write request]${Zt}`}else{let dn=lt.split(/\r?\n/),kn=dn.filter(Mi=>Mi.startsWith("File ")||Mi.trim().startsWith("- Stats:"));Ce=`[ACTION RESULT]: ${kn.length>0?kn.join(`
889
- `):dn.slice(0,2).join(`
890
- `)}${Zt}`}}else if(Je.startsWith("[[SAME]]")){let ft=Je.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),Zt=ft.filter(kn=>kn.startsWith("File ")||kn.trim().startsWith("- Stats:"));Ce=`[ACTION RESULT]: ${Zt.length>0?Zt.join(`
891
- `):ft.slice(0,2).join(`
892
- `)}`}else Ce=`[ACTION RESULT]: ${Je}`;cn+=`${Ce}
890
+ [Old file content for reversal reference. Replaced with new write request]${kn}`}else{let Pn=rt.split(/\r?\n/),at=Pn.filter(lo=>lo.startsWith("File ")||lo.trim().startsWith("- Stats:"));nt=`[ACTION RESULT]: ${at.length>0?at.join(`
891
+ `):Pn.slice(0,2).join(`
892
+ `)}${kn}`}}else if(tt.startsWith("[[SAME]]")){let kt=tt.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),kn=kt.filter(at=>at.startsWith("File ")||at.trim().startsWith("- Stats:"));nt=`[ACTION RESULT]: ${kn.length>0?kn.join(`
893
+ `):kt.slice(0,2).join(`
894
+ `)}`}else nt=`[ACTION RESULT]: ${tt}`;Kt+=`${nt}
893
895
 
894
- `,await $t("toolSuccess")}catch(k){let te=`ERROR: Execution failed for [${K.toolName}]: ${k.message}`;r&&r(`[Tool Error] ${te}
895
- `),cn+=`[ACTION RESULT]: ${te}
896
+ `,await Lt("toolSuccess")}catch(A){let V=`ERROR: Execution failed for [${H.toolName}]: ${A.message}`;r&&r(`[Tool Error] ${V}
897
+ `),Kt+=`[ACTION RESULT]: ${V}
896
898
 
897
- `,await $t("toolFailure")}}let Mn="";if(t?.taskId&&typeof Ht<"u"){let K=Ht.find(N=>N.id===t.taskId);if(K&&K.pendingSteerMessages&&K.pendingSteerMessages.length>0){let N=[...K.pendingSteerMessages];K.pendingSteerMessages=[];for(let Vn of N)Mn+=`
899
+ `,await Lt("toolFailure")}}let bn="";if(t?.taskId&&typeof Gt<"u"){let H=Gt.find(D=>D.id===t.taskId);if(H&&H.pendingSteerMessages&&H.pendingSteerMessages.length>0){let D=[...H.pendingSteerMessages];H.pendingSteerMessages=[];for(let Sn of D)bn+=`
898
900
 
899
- [STEERING INSTRUCTION FROM MAIN AGENT]: ${Vn}`,r&&r(`[Subagent Steered] ${Vn}`)}}let wo=(cn.trim()+Mn).trim();he.push({role:"user",text:wo}),Kt++}if(t?.onHistoryUpdate&&typeof t.onHistoryUpdate=="function"&&t.onHistoryUpdate(he),f?.systemSettings?.autoTruncateResults){for(let Pe=0;Pe<he.length;Pe++){let X=he[Pe],Ve=X.text||"";if(!(!Ve.startsWith("[ACTION RESULT]: ")&&!Ve.startsWith("[TOOL RESULT]: "))&&!(Ve.startsWith("[ACTION RESULT]: Goal")||Ve.includes("[ACTION RESULT]: ...Old result truncated")||Ve.includes("[ACTION RESULT]: Diff result ")||Ve.startsWith("[ACTION RESULT]: USER CHOOSE")||Ve.startsWith("[ACTION RESULT]: Skill:")||Ve.startsWith("[ACTION RESULT]: DOCs:")||Ve.startsWith("[ACTION RESULT]: Markdown parsed")||Ve.startsWith("[ACTION RESULT]: Search results for [")||Ve.startsWith("[ACTION RESULT]: AI Mode temporarily failed")||Ve.startsWith("[ACTION RESULT]: Background subagent started. Task ID:")||Ve.startsWith("[ACTION RESULT]: Subagent task")||/^\[ACTION RESULT\]: File \[.*?\] saved/s.test(Ve))){if(f?.systemSettings?.overwriteProtection!==!1){let ln=Ve.match(/^\[ACTION RESULT\]:\s*File\s*\[(.*?)\]\s*updated(?:\s+with\s+some\s+blocks\s+failed)?\.\s*(?:\[(\d+\/\d+)\]\s*blocks\s*applied\.)?([\s\S]*)$/);if(ln)try{let In=ln[1],io=ln[2]||"",bn=ln[3]||"",Fe=U.basename(In),wt=bn.replace("[DIFF_START]","");wt=wt.replace(/\[DIFF_END\](?=[^\[]*$)/,""),wt=wt.split(/\r?\n/).filter(Ce=>{let lt=Ce.trim();return lt.startsWith("-")||lt.startsWith("+")||lt.startsWith("@@")}).join(`
900
- `).trim();let Ft=0,Sn=0,cn=bn.matchAll(/@@\s*([^@]+?)\s*@@/g);for(let Ce of cn){let lt=Ce[1],ft=lt.match(/\+(\d+)/),Zt=lt.match(/-(\d+)/);ft&&(Ft+=parseInt(ft[1],10)),Zt&&(Sn+=parseInt(Zt[1],10))}let Mn=[];Ft>0&&Mn.push(`+${Ft}`),Sn>0&&Mn.push(`-${Sn}`);let wo=Mn.length>0?` Total ${Mn.join(" ")} changes.`:"",K=U.join(ii,"DiffBackups");we.existsSync(K)||we.mkdirSync(K,{recursive:!0});let N=String(Date.now()).slice(-5),Vn=wa.randomBytes(2).toString("hex"),st=`${Fe}-diff-${N}-${Vn}.txt`,k=U.join(K,st);we.writeFileSync(k,wt,"utf8");let te=`${ii.replaceAll("\\","/").replace(xa.homedir().replaceAll("\\","/"),"~")}/DiffBackups/${st}`,Je=io?` ${io} blocks.`:"";he[Pe]={...X,text:`[ACTION RESULT]: Diff result ${Fe} saved in '${te}'.${Je}${wo}`};continue}catch{}}he[Pe]={...X,text:"[ACTION RESULT]: ...Old result truncated to save tokens"}}}t?.onHistoryUpdate&&typeof t.onHistoryUpdate=="function"&&t.onHistoryUpdate(he)}return Qt};export{xo as a,Ri as b,td as c,nd as d,hr as e,Tc as f,Ac as g,yo as h,Cc as i,hi as j,yi as k,Wc as l,Gc as m,Al as n,Qd as o,Cl as p,Rl as q,Rs as r,jt as s,_i as t,ba as u,Zd as v,ef as w,tf as x,Sa as y,nf as z,Ii as A,ma as B,Il as C,Kn as D,of as E,$l as F,sf as G,rf as H};
901
+ [STEERING INSTRUCTION FROM MAIN AGENT]: ${Sn}`,r&&r(`[Subagent Steered] ${Sn}`)}}let Yn=(Kt.trim()+bn).trim();wt.push({role:"user",text:Yn}),zn++}if(t?.onHistoryUpdate&&typeof t.onHistoryUpdate=="function"&&t.onHistoryUpdate(wt),f?.systemSettings?.autoTruncateResults){for(let we=0;we<wt.length;we++){let te=wt[we],Ne=te.text||"";if(!(!Ne.startsWith("[ACTION RESULT]: ")&&!Ne.startsWith("[TOOL RESULT]: "))&&!(Ne.startsWith("[ACTION RESULT]: Goal")||Ne.includes("[ACTION RESULT]: ...Old result truncated")||Ne.includes("[ACTION RESULT]: Diff result ")||Ne.startsWith("[ACTION RESULT]: USER CHOOSE")||Ne.startsWith("[ACTION RESULT]: Skill:")||Ne.startsWith("[ACTION RESULT]: DOCs:")||Ne.startsWith("[ACTION RESULT]: Markdown parsed")||Ne.startsWith("[ACTION RESULT]: Search results for [")||Ne.startsWith("[ACTION RESULT]: AI Mode temporarily failed")||Ne.startsWith("[ACTION RESULT]: Background subagent started. Task ID:")||Ne.startsWith("[ACTION RESULT]: Subagent task")||/^\[ACTION RESULT\]: File \[.*?\] saved/s.test(Ne))){if(f?.systemSettings?.overwriteProtection!==!1){let De=Ne.match(/^\[ACTION RESULT\]:\s*File\s*\[(.*?)\]\s*updated(?:\s+with\s+some\s+blocks\s+failed)?\.\s*(?:\[(\d+\/\d+)\]\s*blocks\s*applied\.)?([\s\S]*)$/);if(De)try{let jt=De[1],In=De[2]||"",qn=De[3]||"",Mn=B.basename(jt),cn=qn.replace("[DIFF_START]","");cn=cn.replace(/\[DIFF_END\](?=[^\[]*$)/,""),cn=cn.split(/\r?\n/).filter(nt=>{let rt=nt.trim();return rt.startsWith("-")||rt.startsWith("+")||rt.startsWith("@@")}).join(`
902
+ `).trim();let dn=0,wn=0,Kt=qn.matchAll(/@@\s*([^@]+?)\s*@@/g);for(let nt of Kt){let rt=nt[1],kt=rt.match(/\+(\d+)/),kn=rt.match(/-(\d+)/);kt&&(dn+=parseInt(kt[1],10)),kn&&(wn+=parseInt(kn[1],10))}let bn=[];dn>0&&bn.push(`+${dn}`),wn>0&&bn.push(`-${wn}`);let Yn=bn.length>0?` Total ${bn.join(" ")} changes.`:"",H=B.join(li,"DiffBackups");xe.existsSync(H)||xe.mkdirSync(H,{recursive:!0});let D=String(Date.now()).slice(-5),Sn=ba.randomBytes(2).toString("hex"),Ee=`${Mn}-diff-${D}-${Sn}.txt`,A=B.join(H,Ee);xe.writeFileSync(A,cn,"utf8");let V=`${li.replaceAll("\\","/").replace(wa.homedir().replaceAll("\\","/"),"~")}/DiffBackups/${Ee}`,tt=In?` ${In} blocks.`:"";wt[we]={...te,text:`[ACTION RESULT]: Diff result ${Mn} saved in '${V}'.${tt}${Yn}`};continue}catch{}}wt[we]={...te,text:"[ACTION RESULT]: ...Old result truncated to save tokens"}}}t?.onHistoryUpdate&&typeof t.onHistoryUpdate=="function"&&t.onHistoryUpdate(wt)}return To};export{ko as a,Ii as b,td as c,nd as d,yr as e,Tc as f,Ac as g,So as h,Cc as i,bi as j,Si as k,Wc as l,Gc as m,Al as n,Qd as o,Cl as p,Rl as q,_s as r,Ht as s,$i as t,Sa as u,Zd as v,ef as w,tf as x,ka as y,nf as z,Li as A,pa as B,Il as C,Vn as D,of as E,$l as F,sf as G,rf as H};