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.
- package/README.md +24 -14
- package/dist/chunks/{ai-7IGEWDC4.js → ai-6F3WLAXU.js} +1 -1
- package/dist/chunks/{app-TEFKZ7BF.js → app-RDB7EBDV.js} +74 -74
- package/dist/chunks/{auto_completion-YLQZ35AI.js → auto_completion-LLOLRQTZ.js} +1 -1
- package/dist/chunks/chunk-2Q6KKC74.js +2 -0
- package/dist/chunks/chunk-3XJQTYIL.js +1 -0
- package/dist/chunks/{chunk-CGNNVGKZ.js → chunk-63PXA3SA.js} +238 -236
- package/dist/chunks/{chunk-GRJHGYAU.js → chunk-E3RSSW5O.js} +1 -1
- package/dist/chunks/{chunk-RGQWDXID.js → chunk-F36PAVKE.js} +1 -1
- package/dist/chunks/{chunk-DWQSI6JO.js → chunk-HGHBCWE5.js} +1 -1
- package/dist/chunks/{chunk-LTNOPF2E.js → chunk-IZBOTHQP.js} +9 -9
- package/dist/chunks/{chunk-I3Q4EEDY.js → chunk-JWB2S22X.js} +1 -1
- package/dist/chunks/{chunk-JMMO76HS.js → chunk-OO34QR3O.js} +21 -21
- package/dist/chunks/{chunk-AJML3MQG.js → chunk-S62UXLFZ.js} +1 -1
- package/dist/chunks/{chunk-A3ZRC52P.js → chunk-VDQPTW23.js} +1 -1
- package/dist/chunks/{click-J3HGKREV.js → click-VXWUG5T3.js} +2 -2
- package/dist/chunks/{computer_action-GJV76M3H.js → computer_action-SI6AMRJ6.js} +1 -1
- package/dist/chunks/{custom_openai-XRPZ25BZ.js → custom_openai-EYI4WXHZ.js} +1 -1
- package/dist/chunks/{drag-CXZGQ6VL.js → drag-6XCBUY73.js} +1 -1
- package/dist/chunks/{exec_command-22LIHPPH.js → exec_command-E3D5BY3N.js} +1 -1
- package/dist/chunks/{generate_image-RB3HJFO6.js → generate_image-5ZVJ7ELI.js} +1 -1
- package/dist/chunks/{invoke-WXMEB2A5.js → invoke-QOBG7JPO.js} +2 -2
- package/dist/chunks/{invokeSync-O3ZJBM6T.js → invokeSync-UZHY6U2N.js} +2 -2
- package/dist/chunks/{key_press-GP35GCNC.js → key_press-ISGXEO42.js} +1 -1
- package/dist/chunks/{keyboard_typing-37C44KPF.js → keyboard_typing-TK55ZAVR.js} +1 -1
- package/dist/chunks/{mistral-GA36HVZJ.js → mistral-7L7XGX6U.js} +1 -1
- package/dist/chunks/{model_config-OPJXDFKG.js → model_config-D3A73AS7.js} +1 -1
- package/dist/chunks/{nvidia-Z6TAXVPB.js → nvidia-4SWYYBQP.js} +1 -1
- package/dist/chunks/{ollama-6LZL7OKW.js → ollama-22NU2XBD.js} +1 -1
- package/dist/chunks/{recapture_screen-MOGI4IMA.js → recapture_screen-BY4Q4D5X.js} +1 -1
- package/dist/chunks/{screen_grid-SUWYGRSE.js → screen_grid-3FHYFJVG.js} +1 -1
- package/dist/chunks/{scroll-ULY2O6WE.js → scroll-6SPRL73L.js} +1 -1
- package/dist/chunks/search_keyword-F6L5WB2S.js +9 -0
- package/dist/chunks/{secrets-C2QF3PYO.js → secrets-GLYKU2YR.js} +1 -1
- package/dist/chunks/{secrets_v2-LTEHILT6.js → secrets_v2-ZSQLFEIS.js} +1 -1
- package/dist/chunks/{settings-MOI6W4VL.js → settings-YRMZZJ3F.js} +1 -1
- package/dist/chunks/{update_file-74CZ4JRC.js → update_file-VIKPZENG.js} +1 -1
- package/dist/chunks/{usage-H47IV3LH.js → usage-23Z3SVXU.js} +1 -1
- package/dist/chunks/{usageServer-7DVP2CP7.js → usageServer-7KEKAGPH.js} +1 -1
- package/dist/chunks/{write_file-G4QVTNSH.js → write_file-O3YKZSFP.js} +1 -1
- package/dist/cli.js +5 -5
- package/dist/package.json +2 -2
- package/package.json +2 -2
- package/dist/chunks/chunk-OXM7FOYK.js +0 -1
- package/dist/chunks/chunk-Y6O7SAPD.js +0 -2
- package/dist/chunks/search_keyword-D7D7PMSR.js +0 -9
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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: ${
|
|
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":
|
|
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
|
|
464
|
-
`)},
|
|
465
|
-
${
|
|
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()},
|
|
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();
|
|
470
|
-
`),
|
|
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}] ${
|
|
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 ${
|
|
475
|
-
`)},
|
|
476
|
-
`)
|
|
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
|
|
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
|
-
`}`:"",
|
|
485
|
+
`}`:"",Ye=e.name&&e.name?.length>0?`User Name: ${e.name}
|
|
485
486
|
${I.length||x.length?"":`
|
|
486
|
-
`}`:"",C=process.cwd(),
|
|
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
|
|
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(),
|
|
492
|
+
`).trim(),et=Cr(Go,p,d).trim(),w=[wi,et].filter(De=>De&&De.length>0).join(`
|
|
492
493
|
|
|
493
|
-
`).trim(),
|
|
494
|
-
${
|
|
495
|
-
${
|
|
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
|
-
`:"",
|
|
501
|
-
${`Identity: ${
|
|
502
|
-
${
|
|
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: ${
|
|
506
|
-
- Date: ${
|
|
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
|
-
${
|
|
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`:""}${
|
|
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 ===${(
|
|
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}${
|
|
528
|
-
${
|
|
528
|
+
${I}${x}${rn}${ls.length>0&&n.toLowerCase().includes("flux")?`-- Global Skills --
|
|
529
|
+
${ls}
|
|
529
530
|
|
|
530
|
-
`:""}${
|
|
531
|
-
${
|
|
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
|
-
`),
|
|
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":""} ${
|
|
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]} ${
|
|
542
|
+
${C[6]} ${P(I)}
|
|
542
543
|
${C[7]}
|
|
543
|
-
`};import{structuredPatch as ul}from"diff";import
|
|
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
|
|
546
|
-
`);for(let{displayName:$,subDirPath:
|
|
547
|
-
`,I+=
|
|
548
|
-
`),I};import
|
|
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,
|
|
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(
|
|
552
|
+
`:o(Ye).length>80?m+=`${n}${C}${i.name}${a} ...80+ files...
|
|
552
553
|
`:(m+=`${n}${C}${i.name}${a}
|
|
553
|
-
`,m+=
|
|
554
|
-
`}),m};var gl={Ollama:()=>import("./ollama-
|
|
555
|
-
`:"")},
|
|
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,
|
|
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("")},
|
|
559
|
-
`&&s[d]!=="\r"&&(s[d]=" ");r+=o.fullMatch.length}}return s.join("")},Il=e=>{let t=
|
|
560
|
-
`):null},of=(e,t={})=>{if(!e)return null;if(
|
|
561
|
-
`),
|
|
562
|
-
`),
|
|
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
|
-
${
|
|
565
|
+
${V}
|
|
565
566
|
|
|
566
|
-
[USER] ${w[0].text}`,yield{type:"summary_injected",content:{id:w[0].id,text:w[0].text}}));let
|
|
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
|
-
${
|
|
570
|
-
`:"",
|
|
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
|
-
`+
|
|
574
|
-
`)},
|
|
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=
|
|
577
|
-
Cursor Line: ${
|
|
578
|
-
`,
|
|
579
|
-
`);
|
|
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
|
-
`+
|
|
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(
|
|
587
|
-
`),
|
|
588
|
-
${
|
|
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(", ")}`),
|
|
591
|
+
`}ge.length>0&&(Tn+=`All Opened Editors: ${ge.join(", ")}`),at.diagnostics&&(Tn+=`
|
|
591
592
|
**Active File Errors**:
|
|
592
|
-
${
|
|
593
|
-
`),(
|
|
593
|
+
${at.diagnostics}
|
|
594
|
+
`),(Be.toLowerCase().includes("lint")||Be.toLowerCase().includes("warning"))&&at.warnings&&(Tn+=`
|
|
594
595
|
**Lint Warnings**:
|
|
595
|
-
${
|
|
596
|
-
`)}let
|
|
597
|
-
`);yield{type:"visual_feedback",content:
|
|
598
|
-
`)};continue}if(
|
|
599
|
-
`)};continue}}let
|
|
600
|
-
`)};continue}let
|
|
601
|
-
`);yield{type:"visual_feedback",content:
|
|
602
|
-
`)}}}}}catch{}}let
|
|
603
|
-
[Tagged File Contents] Auto Read User Tagged files by System${
|
|
604
|
-
`+
|
|
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
|
-
`:
|
|
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=
|
|
611
|
-
`:"",Ca=process.env.forcedReasoning||!1,
|
|
612
|
-
`:""}`:"",
|
|
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"){
|
|
630
|
-
${
|
|
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||
|
|
640
|
-
WARNING: CWD Changed from previous: "${
|
|
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
|
-
${
|
|
643
|
-
- ${
|
|
644
|
-
`:""}${
|
|
645
|
-
${
|
|
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
|
-
${
|
|
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..."},
|
|
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(
|
|
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:
|
|
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
|
|
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] ${
|
|
662
|
-
[question] ${
|
|
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] ${
|
|
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
|
-
`+
|
|
667
|
+
`+q.join(`
|
|
667
668
|
|
|
668
|
-
`):
|
|
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,
|
|
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&&
|
|
673
|
-
${
|
|
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 --`)}`),
|
|
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}`),
|
|
678
|
+
${S}`),lo&&me&&me.role==="user"&&me.parts?.[0]?.text&&(me.parts[0].text+=`
|
|
678
679
|
|
|
679
680
|
[Additional Comments]
|
|
680
|
-
${
|
|
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
|
|
683
|
-
`;for(let
|
|
684
|
-
`;for(let
|
|
685
|
-
`;S+="[/system]",me.parts[0].text+=S;let
|
|
686
|
-
[system] WARNING, Turn Limit Impending: Step ${mt}/${
|
|
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
|
-
${
|
|
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(
|
|
693
|
-
`).length;ue=
|
|
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
|
-
`)},
|
|
696
|
-
`)?
|
|
697
|
-
`,zt=
|
|
698
|
-
${
|
|
699
|
-
`)}`,
|
|
700
|
-
`:""}${gn}`)},
|
|
701
|
-
`)?
|
|
702
|
-
`;zt=
|
|
703
|
-
${
|
|
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
|
|
707
|
-
`);else{let Ke=
|
|
708
|
-
`),
|
|
709
|
-
`);
|
|
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
|
-
... [${
|
|
712
|
+
... [${dt-100} lines truncated for history stability] ...
|
|
712
713
|
|
|
713
|
-
${
|
|
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
|
-
${
|
|
717
|
-
`)}`:"";
|
|
717
|
+
${Gn.join(`
|
|
718
|
+
`)}`:"";X=`File [${ye}] updated via IDE Companion. ${po}.${Hn}
|
|
718
719
|
|
|
719
|
-
${Ke}${
|
|
720
|
+
${Ke}${Le?`
|
|
720
721
|
|
|
721
|
-
[Note: '~' resolved to user home directory. To target literal '~' in current directory, escape it as '\\~']`:""}`;let{added:
|
|
722
|
-
${
|
|
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
|
|
726
|
-
- Renamed old file as ${
|
|
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
|
|
729
|
-
`);else{let
|
|
730
|
-
`),
|
|
731
|
-
`);
|
|
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
|
-
... [${
|
|
734
|
+
... [${st-100} lines truncated] ...
|
|
734
735
|
|
|
735
|
-
${
|
|
736
|
+
${Hn}`}let vn=Le?`
|
|
736
737
|
|
|
737
|
-
[Note: '~' resolved to user home directory. To target literal '~' in current directory, escape it as '\\~']`:"";
|
|
738
|
-
- Stats: [${
|
|
739
|
-
${
|
|
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
|
-
${
|
|
742
|
-
`:""}${
|
|
743
|
-
`));let
|
|
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
|
-
${
|
|
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]${
|
|
748
|
-
`)
|
|
749
|
-
`)}${
|
|
750
|
-
`):
|
|
751
|
-
`)}`}else
|
|
752
|
-
`:""}${
|
|
753
|
-
`)},
|
|
754
|
-
`:""}${
|
|
755
|
-
`)},
|
|
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
|
-
`}`}`)},
|
|
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
|
-
`)},
|
|
760
|
-
`:""}${
|
|
761
|
-
`}`)},
|
|
762
|
-
`)}return
|
|
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(
|
|
766
|
-
`);yield{type:"visual_feedback",content:
|
|
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
|
-
`}`)},
|
|
769
|
-
`));let
|
|
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);
|
|
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/),
|
|
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(
|
|
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
|
|
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")&&(
|
|
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")){
|
|
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,
|
|
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
|
-
${
|
|
793
|
-
Error log can be found in \`/export logs\``);else{let
|
|
794
|
-
Error log can be found in \`/export logs\``)}}}if(
|
|
795
|
-
`),Q=
|
|
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(
|
|
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=
|
|
806
|
-
`),_e=
|
|
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<
|
|
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:
|
|
813
|
-
${
|
|
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
|
-
${
|
|
816
|
-
`},w.push({role:"user",text:`[system] ${
|
|
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=(
|
|
820
|
+
`};let ge=(Ui.join(`
|
|
820
821
|
`)+`
|
|
821
|
-
${b}`).trim();yield{type:"interactive_turn_finished",data:{agentText:
|
|
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: ${
|
|
824
|
-
\u2800`},
|
|
825
|
-
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] ${
|
|
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
|
|
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
|
-
- ${
|
|
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
|
-
${
|
|
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 ===`,
|
|
867
|
-
${
|
|
868
|
-
`),
|
|
869
|
-
`),t.onAskMain){r&&r(`[Executing Tool] AskMain("${
|
|
870
|
-
Answer from Main Agent: ${
|
|
871
|
-
`),
|
|
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
|
|
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(
|
|
876
|
-
`),
|
|
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(
|
|
879
|
-
`),
|
|
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
|
|
882
|
-
${
|
|
883
|
-
`);let
|
|
884
|
-
`));let
|
|
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
|
-
${
|
|
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]${
|
|
889
|
-
`):
|
|
890
|
-
`)}${
|
|
891
|
-
`):
|
|
892
|
-
`)}`}else
|
|
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
|
|
895
|
-
`),
|
|
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
|
|
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]: ${
|
|
900
|
-
`).trim();let
|
|
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};
|