fluxflow-cli 5.9.0 → 5.9.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/chunks/{ai-CCVRDJ5Y.js → ai-CVCVF3DD.js} +1 -1
- package/dist/chunks/{app-5NONP3DN.js → app-LQXDWH7I.js} +5 -5
- package/dist/chunks/{auto_completion-X5BQ67LH.js → auto_completion-TEHSGPVF.js} +1 -1
- package/dist/chunks/{chunk-B3TQ7NL3.js → chunk-3XK664J6.js} +153 -146
- package/dist/chunks/{chunk-IZBOTHQP.js → chunk-EDZ6JZYO.js} +1 -1
- package/dist/chunks/{chunk-HGHBCWE5.js → chunk-SUE3R7AU.js} +1 -1
- package/dist/chunks/{exec_command-E3D5BY3N.js → exec_command-UDMFBLEM.js} +1 -1
- package/dist/chunks/{invoke-Y5UH42ZS.js → invoke-NIH3KWWP.js} +2 -2
- package/dist/chunks/{invokeSync-B72TXIKL.js → invokeSync-AJOLZRTM.js} +2 -2
- package/dist/chunks/{usageServer-R4WIRTGA.js → usageServer-QZWQWLGJ.js} +1 -1
- package/dist/cli.js +20 -20
- package/dist/package.json +1 -1
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as nr}from"./chunk-UM5SNZ6X.js";import{a as Oo}from"./chunk-NJTM7OYZ.js";import{a as Ht}from"./chunk-56EJGQU3.js";import{a as or}from"./chunk-4CWGKQHX.js";import{c as Zi,g as es,h as Xs,i as Js,j as Qs}from"./chunk-OO34QR3O.js";import{b as Zs,c as er,d as ts,f as tr}from"./chunk-EDZ6JZYO.js";import{a as pi}from"./chunk-2RTYI6K3.js";import{a as O}from"./chunk-6LM3YRRE.js";import{b as Ys}from"./chunk-BA3CAHVB.js";import{B as Xi}from"./chunk-2GG7YBNM.js";import{f as mi,l as Lt,o as Ji,p as hn,r as Qi}from"./chunk-QPUQJOH3.js";import{b as gi}from"./chunk-4KFOL3UU.js";import{l as Ze,m as ui}from"./chunk-2Q6KKC74.js";import{c as pn,d as Yi,e as fi}from"./chunk-ZGORMZE5.js";import{a as En,b as li,c as ci,d as oo,e as Vs,k as di,l as zi,m as zs,r as qi,w as $o,x as Lo,y as qs,z as mn}from"./chunk-NPXJIGAI.js";import{GoogleGenAI as wa,ThinkingLevel as qe,HarmBlockThreshold as Pi,HarmCategory as $i}from"@google/genai";var hi={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 Ft from"fs";import Qt from"path";import Xa from"os";import yn from"fs";import _n from"path";import hr from"fs";import ns from"path";import{execSync as yr}from"child_process";import{fileURLToPath as za}from"url";var ir=`# 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 sr=`# Env Variables
|
|
31
31
|
|
|
32
32
|
* Locations:
|
|
33
33
|
* Shell
|
|
@@ -46,9 +46,11 @@ fluxflow [options]
|
|
|
46
46
|
* ENABLE_9ROUTER \u2192 Enables 9Router provider. Can use OAuth subscription like Codex, Claude Code, GitHub Copilot etc. or use providers not natively in Fluxflow. Set ENV ENABLE_9ROUTER=true, needs 9router package installed (via npm/npx etc) & running
|
|
47
47
|
* NINEROUTER_URL \u2192 If different from default, Any OpenAI Compatible
|
|
48
48
|
* NINEROUTER_KEY \u2192 if any
|
|
49
|
-
* MAX_LOOPS
|
|
49
|
+
* MAX_LOOPS \u2192 ENV control for number of max turns for main agent
|
|
50
50
|
* SUBAGENT_MAX_TURNS
|
|
51
51
|
|
|
52
|
+
* DASHBOARD_SYSTEM_FONT \u2192 Wheather to use system font in GUI dashboard. Defaults to Plus Jakarta Sans when undefined
|
|
53
|
+
|
|
52
54
|
## Diagnostic & Optimization Flags
|
|
53
55
|
* SHOW_DEBUG_GRID \u2192 (true|false, default: false) Coordinate grid overlay for Computer Use tooling
|
|
54
56
|
* DEBUG_OCR \u2192 (true|false, default: false) Enables verbose OCR diagnostic logs
|
|
@@ -58,7 +60,7 @@ fluxflow [options]
|
|
|
58
60
|
|
|
59
61
|
* 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
62
|
* 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
|
|
63
|
+
`;var rr=`# Fluxflow in-app /commands
|
|
62
64
|
|
|
63
65
|
Trigger in chat via /command
|
|
64
66
|
|
|
@@ -111,7 +113,7 @@ Trigger in chat via /command
|
|
|
111
113
|
* /update latest \u2192 Install latest release
|
|
112
114
|
* /fluxflow global/saves \u2192 Openes fluxflow storage paths in explorer
|
|
113
115
|
* /move \u2192 Transfer Playground session data to ./playground-export
|
|
114
|
-
`;var
|
|
116
|
+
`;var ar=`# FluxFlow In-App Settings Reference
|
|
115
117
|
|
|
116
118
|
Open in chat via /settings
|
|
117
119
|
|
|
@@ -187,7 +189,7 @@ Open in chat via /settings
|
|
|
187
189
|
| Emergency Recovery | Off | Off |
|
|
188
190
|
| Auto Truncate Results | On | On |
|
|
189
191
|
| Memory | Off | Off |
|
|
190
|
-
`;var
|
|
192
|
+
`;var lr=`# FluxFlow Tool Reference
|
|
191
193
|
|
|
192
194
|
## Protocol: [action:ActionName(arg1="val")]
|
|
193
195
|
|
|
@@ -228,7 +230,7 @@ Open in chat via /settings
|
|
|
228
230
|
* KeyboardTyping(text, autoPressEnter?) \u2192 Type string
|
|
229
231
|
* KeyPress(key) \u2192 Key/combo dispatch ("ctrl;c", "enter", etc.)
|
|
230
232
|
* RecaptureScreen() \u2192 Fresh screenshot + coordinate grid
|
|
231
|
-
`;var
|
|
233
|
+
`;var cr=`# Fluxflow Architecture
|
|
232
234
|
|
|
233
235
|
## 1. Terminal Engine
|
|
234
236
|
* Framework: React + Ink terminal UI
|
|
@@ -258,7 +260,7 @@ Open in chat via /settings
|
|
|
258
260
|
## 6. IDE Bridge
|
|
259
261
|
* Protocol: WebSocket on ws://localhost:56832
|
|
260
262
|
* State Sync: Focused file, open tabs, cursor line, selection, diagnostics
|
|
261
|
-
`;var
|
|
263
|
+
`;var dr=`# FluxFlow Sub-Agents & Multi-Agent Architecture
|
|
262
264
|
|
|
263
265
|
## Execution Modes
|
|
264
266
|
* InvokeSync \u2192 Synchronous blocking delegation; main agent halts until sub-agent finishes task
|
|
@@ -289,7 +291,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
|
|
|
289
291
|
* SUBAGENT_MODEL \u2192 Target model override
|
|
290
292
|
* SUBAGENT_PROVIDER \u2192 Target provider override
|
|
291
293
|
* Setting SubAgentModel=ENV in settings pulls directly from environment overrides
|
|
292
|
-
`;var
|
|
294
|
+
`;var fr=`# FluxFlow Security, Sandboxing & Safety
|
|
293
295
|
|
|
294
296
|
## Human-in-the-Loop Governance
|
|
295
297
|
* Execution Approval Gate \u2192 Destructive commands and high-risk file modifications require explicit user authorization (Allow / Deny)
|
|
@@ -312,7 +314,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
|
|
|
312
314
|
* Emergency Rollback \u2192 Automatic pre-turn file snapshots; Agent can still fix it (default: OFF) \u2192 references/SETTINGS.md
|
|
313
315
|
* Git-less Checkpoint Reversion \u2192 Trigger conversational changes rollback via double-ESC
|
|
314
316
|
* External Sanctuary Redirection \u2192 Move ~/.fluxflow data sanctuary (chats, keys etc)
|
|
315
|
-
`;var
|
|
317
|
+
`;var ur=`# Fluxflow IDE Companion
|
|
316
318
|
|
|
317
319
|
## WebSocket Bridge Protocol
|
|
318
320
|
* Local Bridge \u2192 Runs on ws://localhost:56832 connecting FluxFlow CLI with the companion editor extension
|
|
@@ -330,7 +332,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
|
|
|
330
332
|
* File Focus \u2192 Automatically opens edited files in active IDE window
|
|
331
333
|
* Diff Preview \u2192 Streams side-by-side or inline diff highlights (showDiff, highlightDiff) directly in editor
|
|
332
334
|
* Status Bar Sync \u2192 Real-time agent status (thinking, running tool, awaiting input) reflected in IDE status bar
|
|
333
|
-
`;var
|
|
335
|
+
`;var gr=`# Fluxflow Modes
|
|
334
336
|
|
|
335
337
|
## Modes Overview (TAB to cycle)
|
|
336
338
|
* [Flux] (Workspace / Dev) \u2192 Primary coding & workspace agent
|
|
@@ -348,7 +350,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
|
|
|
348
350
|
* User Inquiry: AskUser \u2192 [Universal]
|
|
349
351
|
* Document Creation: WritePDF, WriteDoc \u2192 [Flow]
|
|
350
352
|
* GUI & Desktop Automation: Click, Scroll, KeyboardTyping, KeyPress, RecaptureScreen \u2192 [ICU] | [FluxCU]
|
|
351
|
-
`;var
|
|
353
|
+
`;var mr=`# FluxFlow AI Providers & Setup
|
|
352
354
|
|
|
353
355
|
## Supported Providers
|
|
354
356
|
* Gemini | NVIDIA NIM | DeepSeek | Mistral | Ollama Local/Cloud | InferX | SenseNova | Poolside | OpenRouter | AIHubMix | Experiential Labs | TokenHarbor | APInex | Infron | Coarena | Numes
|
|
@@ -390,7 +392,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
|
|
|
390
392
|
2. Set ENV ENABLE_9ROUTER=true
|
|
391
393
|
* 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
|
|
392
394
|
* NINEROUTER_KEY = If any needed
|
|
393
|
-
`;var
|
|
395
|
+
`;var pr=`# Fluxflow Instructions & Skills System
|
|
394
396
|
|
|
395
397
|
## 1. Instructions (AGENTS.md / FLUXFLOW.md root only)
|
|
396
398
|
* Locations:
|
|
@@ -434,14 +436,14 @@ Instruction for this model ID across all providers.
|
|
|
434
436
|
|
|
435
437
|
* On-Demand Reference System:
|
|
436
438
|
* Reference: Offload deep/contexual specs to **/{SKILL.md,skill-reference-folder/*.md} & reference in SKILL.md. Saves tokens
|
|
437
|
-
`;var
|
|
439
|
+
`;var yi="v4";try{let e=ns.dirname(za(import.meta.url)),t=[ns.join(e,"../../package.json"),ns.join(e,"../package.json")],n=!1;for(let s of t)if(hr.existsSync(s)){let o=JSON.parse(hr.readFileSync(s,"utf8"));if(o.version){yi=o.version,n=!0;break}}if(!n)try{let s=yr("fluxflow -v",{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"],timeout:2e3}).trim();s&&(s.startsWith("v")||/^\d+\.\d+/.test(s))&&(yi=s,n=!0)}catch{}if(!n)try{let s=yr("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&&(yi=o.version)}catch{}}catch{}var os={"SKILL.md":`---
|
|
438
440
|
name: fluxflow
|
|
439
441
|
description: System Generated Documentation. Read this if asked anything regarding FluxFlow Harness, model info
|
|
440
442
|
---
|
|
441
443
|
|
|
442
444
|
# FluxFlow, by Kushal Roy Chowdhury
|
|
443
445
|
Open Source Terminal AI Assistant
|
|
444
|
-
App Version: ${
|
|
446
|
+
App Version: ${yi}. Check Updates: fluxflow --update check. Update: fluxflow --update
|
|
445
447
|
GitHub: https://github.com/KushalRoyChowdhury/fluxflow-cli
|
|
446
448
|
Public Docs: https://fluxflow-cli.onrender.com, /changelog or /changelog/{version} endpoints for release notes
|
|
447
449
|
|
|
@@ -459,37 +461,38 @@ Public Docs: https://fluxflow-cli.onrender.com, /changelog or /changelog/{versio
|
|
|
459
461
|
* Priority Instructions (AGENTS.md/FLUXFLOW.md) & Skill System \u2192 references/PLUGINS.md
|
|
460
462
|
* Agent Architecture & Memory System \u2192 references/ARCHITECTURE.md
|
|
461
463
|
|
|
462
|
-
Docs missing required info? Say you are not sure enough to answer. Dont give wrong info`,"references/MODES.md":
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
464
|
+
Docs missing required info? Say you are not sure enough to answer. Dont give wrong info`,"references/MODES.md":gr,"references/PROVIDERS.md":mr,"references/PLUGINS.md":pr,"references/STARTUP.md":ir,"references/ENV.md":sr,"references/COMMANDS.md":rr,"references/SETTINGS.md":ar,"references/TOOLS.md":lr,"references/ARCHITECTURE.md":cr,"references/SUB_AGENTS.md":dr,"references/SECURITY.md":fr,"references/IDE.md":ur};var xr=(e=null)=>{try{let t=_n.join(En,"skills","fluxflow"),n=_n.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(os).map(m=>_n.normalize(m))),d=(e||""||"").replace(/^.*::/,"").split(":")[0].replace(/\/free$/,"").trim(),a=_n.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(os)){let h=_n.join(t,m),p=_n.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]||""}
|
|
465
|
+
|
|
466
|
+
Session Model: ${a}`));let i=g.trim()+`
|
|
467
|
+
`,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=_n.normalize(_n.join("references",f));if(!o.has(h)){let p=_n.join(n,f);try{yn.rmSync(p,{recursive:!0,force:!0})}catch{}}}}}catch{}};import{WebSocket as xi}from"ws";var Dt=null,wo=!1,qa="ws://localhost:56832",is=[],bo=null,ss=null,rs=null,wr="2.0.0",Ac=e=>{wr=e,br()},as=e=>{ss=e},Cc=e=>{rs=e},br=()=>{if(Dt||wo)return;wo=!0;let e=new xi(qa);e.on("open",()=>{for(Dt=e,wo=!1,Dt.send(JSON.stringify({command:"version",version:wr,pid:process.pid,ppid:process.ppid,cwd:process.cwd()}));is.length>0;)Dt.send(JSON.stringify(is.shift()))}),e.on("message",t=>{try{let n=JSON.parse(t.toString());n.command==="contextResponse"&&bo?(bo(n.data),bo=null):n.command==="securityResponse"&&ss?ss(n.result):n.command==="inlineComplete"?Ya(n):n.command==="connectionRejected"&&rs&&rs(n)}catch{}}),e.on("error",()=>{wo=!1,Dt=null}),e.on("close",()=>{wo=!1,Dt=null})},No=e=>{Dt&&Dt.readyState===xi.OPEN?Dt.send(JSON.stringify(e)):(is.push(e),wo||br())},So=()=>Dt!==null&&Dt.readyState===xi.OPEN,Ya=async e=>{let t="";try{let{generateAutoCompletion:n}=await import("./auto_completion-TEHSGPVF.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||""})},Rc=e=>{No({command:"status",status:e})},io=()=>new Promise(e=>{if(!Dt||Dt.readyState!==xi.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)}),Sr=e=>{let{resolvedPath:t}=mn(e);No({command:"open",filePath:t})},ls=(e,t,n)=>{let{resolvedPath:s}=mn(e);No({command:"showDiff",filePath:s,originalContent:t,modifiedContent:n})},kr=(e,t)=>{let{resolvedPath:n}=mn(e);No({command:"closeDiff",filePath:n,result:t})};var Fo="";try{let e=Qt.join(En,"security_policy.md");Ft.existsSync(e)&&(Fo=Ft.readFileSync(e,"utf8").trim())}catch{}var jo=(e,t)=>{try{if(!Ft.existsSync(e))return null;let n=Array.isArray(t)?t.map(o=>o.toLowerCase()):[t.toLowerCase()],s=Ft.readdirSync(e);for(let o of n){let r=s.find(d=>d.toLowerCase()===o);if(r){let d=Qt.join(e,r);if(Ft.statSync(d).isFile())return d}}}catch{}return null},gs=(e,t)=>{let n=jo(e,t);if(n)try{return Ft.readFileSync(n,"utf8")}catch{}return""},Tr=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"]),ms=(e=process.cwd(),t=0,n=8)=>{let s=[];if(t>n)return s;try{if(!Ft.existsSync(e))return s;let o=Ft.readdirSync(e,{withFileTypes:!0});for(let r of o){let d=r.name,a=Qt.join(e,d);if(r.isDirectory())!Tr.has(d)&&!Tr.has(d.toLowerCase())&&s.push(...ms(a,t+1,n));else if(r.isFile()){let m=d.toLowerCase();(m==="agents.md"||m==="agent.md")&&s.push(a)}}}catch{}return s},Ar=(e,t=2)=>{if(!e)return"";let n=" ".repeat(t);return e.split(/\r?\n/).map(s=>n+s).join(`
|
|
468
|
+
`)},_r=()=>jo(En,["agents.md","agent.md"]),Ir=()=>jo(process.cwd(),["agents.md","agent.md"]),Mr=()=>jo(En,["fluxflow.md"]),Pr=()=>jo(process.cwd(),["fluxflow.md"]),Bo=_r(),wi=Ir(),xn=ms(),Uo=Mr(),Wo=Pr(),Cr=null,us="",$r=!1,Ja=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&&(us=o[1].trim(),process.env.NO_INS=!0),/<><\s*NO_INS/.test(n)&&($r=!0),s.trim()},Qa=()=>{Bo=_r();let e=Bo?gs(En,["agents.md","agent.md"]).trim():"";return e.length===0?(Bo=null,""):e},Za=()=>{if(xn=ms(),wi=Ir(),!xn||xn.length===0)return"";let e=process.cwd(),t=[...xn].sort((o,r)=>{let d=Qt.relative(e,o).replace(/\\/g,"/"),a=Qt.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=Ft.readFileSync(o,"utf8").trim();if(!r||r.length===0)continue;n.push(o);let d=Qt.relative(e,o).replace(/\\/g,"/");if(!d.includes("/"))s.push(Ar(r,2));else{let m=Qt.dirname(d)+"/:";s.push(`${m}
|
|
469
|
+
${Ar(r,2)}`)}}catch{}return xn=n,xn.length===0&&(wi=null),s.join(`
|
|
467
470
|
|
|
468
|
-
`).trim()},
|
|
471
|
+
`).trim()},ps=()=>{Uo=Mr();let e=Uo?gs(En,["fluxflow.md"]).trim():"",t=Ja(e)?.trim()||"";return t.length===0?(Uo=null,""):t},hs=()=>{Wo=Pr();let e=Wo?gs(process.cwd(),["fluxflow.md"]).trim():"";return e.length===0?(Wo=null,""):e},ys=Qa(),bi=Za(),Go=ps(),Ho=hs(),Rr=(e,t="",n="")=>{if(!e)return"";let s=n.toLowerCase().trim(),o=t.toLowerCase().trim(),r=Qt.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(`
|
|
469
472
|
|
|
470
|
-
`).trim()},
|
|
471
|
-
`),
|
|
473
|
+
`).trim()},el=(e="",t="")=>{let n=`${e||""}@${t||""}`.toLowerCase().trim();Cr!==n&&(Cr=n,Go=ps(),Ho=hs())};xr();var tl=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},nl=e=>{let t=[];if(!e||!Ft.existsSync(e))return t;let n=(s,o=0)=>{if(!(o>5))try{let r=Ft.readdirSync(s,{withFileTypes:!0});for(let d of r){let a=Qt.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},Lr=e=>{let t=nl(e),n=[];for(let s of t)try{let o=Ft.readFileSync(s,"utf8"),r=tl(o);r&&n.push({...r,filePath:s})}catch{}return n},Or=e=>!e||e.length===0?"":e.map(t=>`- ${t.name}: ${t.description}`).join(`
|
|
474
|
+
`),Si=Lr(En),ki=Lr(process.cwd()),cs=Or(Si),ds=Or(ki),Nr=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"},Dr=()=>(Si||[]).filter(e=>!Nr(e)),Fr=()=>(ki||[]).filter(e=>!Nr(e)),Gc=(ys?.length>0?1:0)+(bi?.length>0?xn.length:0)+(Go?.length>0?1:0)+(Ho?.length>0?1:0)+Dr().length+Fr().length,fs=(e,t="Project")=>{if(!e)return"";let n=e.replace(/\\/g,"/");if(t==="Global"){let o=Xa.homedir().replace(/\\/g,"/");return n.toLowerCase().startsWith(o.toLowerCase())?"~"+n.slice(o.length):n}let s=Qt.relative(process.cwd(),e).replace(/\\/g,"/");return s.startsWith(".")?s:`./${s}`},Hc=()=>{Go=ps(),Ho=hs();let e=[];Bo&&ys.length>0&&e.push({scope:"Global",path:Bo}),xn&&xn.length>0&&bi.length>0?xn.forEach(r=>{e.push({scope:"Project",path:r})}):wi&&bi.length>0&&e.push({scope:"Project",path:wi}),Uo&&Go.length>0&&e.push({scope:"Global",path:Uo}),Wo&&Ho.length>0&&e.push({scope:"Project",path:Wo});let t=Dr(),n=Fr(),s=e.length+t.length+n.length;if(s===0)return`\u2726 Loaded Files & Instructions
|
|
472
475
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No instruction or skill files are currently loaded.
|
|
473
476
|
\u2800`;let o=[];return o.push(`\u2726 Loaded Files & Instructions (${s} ${s===1?"file":"files"} active)`),e.length>0&&(o.push(`
|
|
474
|
-
\x1B[1mInstructions:\x1B[22m`),e.forEach(r=>{o.push(` \u2022 [${r.scope}] ${
|
|
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 ${
|
|
476
|
-
`)},
|
|
477
|
-
`):Do=""}catch(n){Do="";try{
|
|
477
|
+
\x1B[1mInstructions:\x1B[22m`),e.forEach(r=>{o.push(` \u2022 [${r.scope}] ${fs(r.path,r.scope)}`)})),(t?.length>0||n?.length>0)&&(o.push(`
|
|
478
|
+
\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 ${fs(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 ${fs(r.filePath,"Project")}\x1B[22m`)})),o.push("\u2800"),o.join(`
|
|
479
|
+
`)},Br=!1;(async()=>{try{let e=await gi();if(Number(e?.display)===1){let{default:t}=await import("screenshot-desktop"),n=await t.listDisplays();n&&n.length>1&&(Br=!0)}}catch{}})();var vr=null,Do=null,Er=process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux",jc=process.env.NO_DEV||!1,ol=(e,t)=>{if(!t)return"";if(e!==vr||Do===null){vr=e;try{let n=pn(di,[]);Array.isArray(n)&&n.length>0?Do=n.map(s=>`- ${s.memory}`).join(`
|
|
480
|
+
`):Do=""}catch(n){Do="";try{Ft.mkdirSync(Qt.join(oo,"memory"),{recursive:!0}),Ft.appendFileSync(Qt.join(oo,"memory","error.txt"),`${n.message}
|
|
478
481
|
-------------------------------------------------
|
|
479
482
|
|
|
480
|
-
`)}catch{}}}return Do};var
|
|
483
|
+
`)}catch{}}}return Do};var Ur=(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=hi[De]||hi.Medium}(m||d!=="Google")&&(i=hi.xHigh,t==="Fast"?i=`No thinking. Immediate response
|
|
481
484
|
Verify imports, tool results & system stability`:t.toLowerCase()==="max"&&(i=null));let x=e.instructions&&e.instructions?.length>0?`User Preferences: ${e.instructions}
|
|
482
485
|
|
|
483
486
|
`:"",I=e.nickname&&e.nickname?.length>0?`User Nickname: ${e.nickname}
|
|
484
487
|
${x.length?"":`
|
|
485
488
|
`}`:"",Ye=e.name&&e.name?.length>0?`User Name: ${e.name}
|
|
486
489
|
${I.length||x.length?"":`
|
|
487
|
-
`}`:"",C=process.cwd(),P=e.preset,U={Sassy:"Sassy",Friendly:"Sassy, Warm & Chatty",Playful:"Playful",Efficient:"Quick, Concise & Efficient",Professional:"Professional"}[P]||null,$=
|
|
490
|
+
`}`:"",C=process.cwd(),P=e.preset,U={Sassy:"Sassy",Friendly:"Sassy, Warm & Chatty",Playful:"Playful",Efficient:"Quick, Concise & Efficient",Professional:"Professional"}[P]||null,$=ol(f,o),M=$?.length>0?`--- Saved Memories ---
|
|
488
491
|
${$}
|
|
489
492
|
|
|
490
|
-
`:"";
|
|
493
|
+
`:"";el(d,p);let Se=Rr(Go,p,d).trim(),Be=[ys,Se].filter(De=>De&&De.length>0).join(`
|
|
491
494
|
|
|
492
|
-
`).trim(),et=
|
|
495
|
+
`).trim(),et=Rr(Ho,p,d).trim(),w=[bi,et].filter(De=>De&&De.length>0).join(`
|
|
493
496
|
|
|
494
497
|
`).trim(),rn=Be.length>0||w.length>0?`--- Additional Instructions ---
|
|
495
498
|
${Be.length>0?`-- Global --
|
|
@@ -498,12 +501,12 @@ ${Be}`:""}${w.length>0?`${Be.length>0?`
|
|
|
498
501
|
`:""}-- Project --
|
|
499
502
|
${w}`:""}
|
|
500
503
|
|
|
501
|
-
`:"",Xe=(()=>{let De=process.cwd().toLowerCase();if(process.platform==="win32"){let
|
|
502
|
-
${`Identity: ${
|
|
503
|
-
${
|
|
504
|
+
`:"",Xe=(()=>{let De=process.cwd().toLowerCase();if(process.platform==="win32"){let Kt=process.env.SystemRoot?.toLowerCase()||"c:\\windows",Mn=process.env.ProgramFiles?.toLowerCase()||"c:\\program files",qn=process.env["ProgramFiles(x86)"]?.toLowerCase()||"c:\\program files (x86)";return De.startsWith(Kt)||De.startsWith(Mn)||De.startsWith(qn)}else return De==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(Mn=>De.startsWith(Mn))})(),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)":""} ===
|
|
505
|
+
${`Identity: ${us.length>1?us.trim():`FluxFlow.${U?` ${U}`:""} CLI Assistant${we?`. ${te?"Peak ":""}Halloween Themed, Spooky`:""}`}
|
|
506
|
+
${$r?"":`${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"}`}${Br&&n.toLowerCase().includes("cu")?`
|
|
504
507
|
- 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()}
|
|
505
508
|
|
|
506
|
-
- OS: ${
|
|
509
|
+
- OS: ${Er}
|
|
507
510
|
- Date: ${zn}
|
|
508
511
|
${t.toLowerCase()!=="max"&&process.env.rawReasoning!=="true"?`
|
|
509
512
|
-- REASONING GUIDANCE --
|
|
@@ -515,23 +518,27 @@ Use <think_fluxflow>...</think_fluxflow> for reasoning before responding any que
|
|
|
515
518
|
-- REASONING GUIDANCE --
|
|
516
519
|
`:""}Before actions, provide user facing summary of findings & decisions IN detail
|
|
517
520
|
`}
|
|
518
|
-
${
|
|
521
|
+
${tr(n,Er,a,d,s?.advanceRollback,s?.subAgents!==!1,!!s?.autoExec,!!s?.disableTodo,s?.preferBash!==!1)}${n.toLowerCase().includes("cu")?`
|
|
522
|
+
|
|
523
|
+
-- SECURITY POLICY --
|
|
524
|
+
- Dont operate on ANY confidential/logins/captcha screens if not local dev server \u2192 Tell user to complete it${Fo?`
|
|
525
|
+
${Fo}`:""}`:Fo?`
|
|
519
526
|
|
|
520
|
-
-- SECURITY
|
|
521
|
-
|
|
527
|
+
-- SECURITY POLICY --
|
|
528
|
+
${Fo}`:""}${Ne?`
|
|
522
529
|
|
|
523
530
|
Reference files as file:start..end`:""}
|
|
524
|
-
=== END SYSTEM PROMPT ===${(
|
|
531
|
+
=== END SYSTEM PROMPT ===${(cs.length>0||ds.length>0)&&n.toLowerCase().includes("flux")?`
|
|
525
532
|
|
|
526
533
|
- Read relevant skills before tasks, scope: global/project: Use ReadFile, path="#skills/scope?/skillName". In-skill references: path="#skills/scope?/skillName/reference-folder/*.md"`:""}
|
|
527
534
|
|
|
528
|
-
${I}${x}${rn}${
|
|
529
|
-
${ls}
|
|
530
|
-
|
|
531
|
-
`:""}${cs.length>0&&n.toLowerCase().includes("flux")?`-- Project Skills --
|
|
535
|
+
${I}${x}${rn}${cs.length>0&&n.toLowerCase().includes("flux")?`-- Global Skills --
|
|
532
536
|
${cs}
|
|
533
537
|
|
|
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-A6R4JKA3.js").then(e=>e.write_file),Vr=()=>import("./update_file-EM4ZG6UL.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-HIPJ7GZH.js").then(e=>e.search_keyword),Jr=()=>import("./generate_image-7SELLJ3D.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-B72TXIKL.js").then(e=>e.invokeSync),ol=()=>import("./invoke-Y5UH42ZS.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-5SFGUE7P.js").then(e=>e.computer_action),na=()=>import("./click-UEI5LVOE.js").then(e=>e.click),oa=()=>import("./drag-L7GQYYL3.js").then(e=>e.drag),ia=()=>import("./scroll-JYIYNVSL.js").then(e=>e.scroll),xs=()=>import("./keyboard_typing-56IA2FB3.js").then(e=>e.keyboard_typing),ws=()=>import("./key_press-7KZSEFAE.js").then(e=>e.key_press),bs=()=>import("./recapture_screen-OXAETNVY.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(`
|
|
538
|
+
`:""}${ds.length>0&&n.toLowerCase().includes("flux")?`-- Project Skills --
|
|
539
|
+
${ds}
|
|
540
|
+
|
|
541
|
+
`:""}`.trim()};var Wr=()=>import("./web_search-XBV7AJF7.js").then(e=>e.web_search),Gr=()=>import("./web_scrape-SJBA3RQF.js").then(e=>e.web_scrape),Hr=()=>import("./memory-QTLQAFG7.js").then(e=>e.memory),jr=()=>import("./chat-YMCO5JNQ.js").then(e=>e.chat),Kr=()=>import("./view_file-LWURM2CE.js").then(e=>e.view_file),Vr=()=>import("./write_file-A6R4JKA3.js").then(e=>e.write_file),zr=()=>import("./update_file-EM4ZG6UL.js").then(e=>e.update_file),qr=()=>import("./exec_command-UDMFBLEM.js").then(e=>e.exec_command),Yr=()=>import("./read_folder-BJ3HS63A.js").then(e=>e.read_folder),xs=()=>import("./ask_user-XQ423UXL.js").then(e=>e.ask_user),Xr=()=>import("./write_pdf-UOCME2OY.js").then(e=>e.write_pdf),Jr=()=>import("./write_docx-54LANNV2.js").then(e=>e.write_docx),Ti=()=>import("./search_keyword-HIPJ7GZH.js").then(e=>e.search_keyword),Qr=()=>import("./generate_image-7SELLJ3D.js").then(e=>e.generate_image),Ai=()=>import("./saveSummary-CVZIOQ4L.js").then(e=>e.saveSummary),Ko=()=>import("./addMemScore-U2KYMALL.js").then(e=>e.addMemScore),Zr=()=>import("./file_map-4WUEPRMI.js").then(e=>e.file_map),Ci=()=>import("./todo-3EQZ7LZM.js").then(e=>e.todo),ea=()=>import("./invokeSync-AJOLZRTM.js").then(e=>e.invokeSync),il=()=>import("./invoke-NIH3KWWP.js").then(e=>e.invoke),ta=()=>import("./getProgress-MJZDAMSP.js").then(e=>e.getProgress),sl=()=>import("./cancel-2PAHCMGB.js").then(e=>e.cancel),na=()=>import("./emergency_rollback-PHH3BKRP.js").then(e=>e.emergency_rollback),Vo=()=>import("./awaitSubagent-KLH7CRKF.js").then(e=>e.awaitSubagent),zo=()=>import("./answerSubagent-PIZJSLZN.js").then(e=>e.answerSubagent),Ri=()=>import("./steerSubagent-B34P33YV.js").then(e=>e.steerSubagent),vi=()=>import("./computer_action-5SFGUE7P.js").then(e=>e.computer_action),oa=()=>import("./click-UEI5LVOE.js").then(e=>e.click),ia=()=>import("./drag-L7GQYYL3.js").then(e=>e.drag),sa=()=>import("./scroll-JYIYNVSL.js").then(e=>e.scroll),ws=()=>import("./keyboard_typing-56IA2FB3.js").then(e=>e.keyboard_typing),bs=()=>import("./key_press-7KZSEFAE.js").then(e=>e.key_press),Ss=()=>import("./recapture_screen-OXAETNVY.js").then(e=>e.recapture_screen),Ei=()=>import("./find_file-LHPOW4ZM.js").then(e=>e.find_file),ra=()=>import("./wait-6WFCZDO7.js").then(e=>e.wait),aa={web_search:Wr,web_scrape:Gr,memory:Hr,chat:jr,view_file:Kr,write_file:Vr,update_file:zr,exec_command:qr,read_folder:Yr,write_pdf:Xr,write_docx:Jr,search_keyword:Ti,generate_image:Qr,saveSummary:Ai,addMemScore:Ko,file_map:Zr,todo:Ci,Todo:Ci,goal:Ci,Goal:Ci,invokeSync:ea,invoke:il,getProgress:ta,cancel:sl,awaitSubagent:Vo,answerSubagent:zo,steerSubagent:Ri,computer_action:vi,computer_use:vi,ComputerAction:vi,ComputerUse:vi,click:oa,Click:oa,drag:ia,Drag:ia,scroll:sa,Scroll:sa,keyboard_typing:ws,KeyboardTyping:ws,keyboardtyping:ws,key_press:bs,KeyPress:bs,keypress:bs,recapture_screen:Ss,RecaptureScreen:Ss,recapturescreen:Ss,invoke_sync:ea,get_progress:ta,await_subagent:Vo,answer_subagent:zo,steer_subagent:Ri,steer:Ri,Steer:Ri,ask:xs,Ask:xs,AskUser:xs,WebSearch:Wr,WebScrape:Gr,ReadFile:Kr,ReadFolder:Yr,WriteFile:Vr,PatchFile:zr,WritePDF:Xr,WriteDoc:Jr,Run:qr,SearchKeyword:Ti,CodeSearch:Ti,code_search:Ti,Memory:Hr,Chat:jr,GenerateImage:Qr,saveSumary:Ai,SaveSummary:Ai,SaveSumary:Ai,add_mem_score:Ko,AddMemScore:Ko,addMemoryScore:Ko,AddMemoryScore:Ko,FileMap:Zr,answer:zo,Answer:zo,AnswerSubagent:zo,await:Vo,Await:Vo,AwaitSubagent:Vo,EmergencyRollback:na,emergency_rollback:na,find_file:Ei,findFile:Ei,FindFile:Ei,findfile:Ei,wait:ra,Wait:ra},ks=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=aa[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 _i=e=>{if(!e||typeof e!="string")return!1;let t=e.trim().toLowerCase();return Object.keys(aa).some(n=>n.toLowerCase()===t)};import B from"path";import xe from"fs";import ba from"os";import Sa from"crypto";import{execSync as Es}from"child_process";import rl from"gradient-string";var la=["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 ca=["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 da=[{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 Ii=null;var Mi=(e="Dark")=>{let t;e==="Mystery"||e==="Chaos"?(Ii||(Ii=da[Math.floor(Math.random()*da.length)]),t={...Ii,id:"Mystery"}):(Ii=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 al=()=>process.env.TERM_PROGRAM==="vscode"?"vscode":process.env.WT_SESSION?"wt":"default",nd=(e=2)=>{let t=al();return t==="wt"?" ".repeat(Math.max(1,e-1)):" ".repeat(e)},fa=new Date,qo=fa.getMonth(),Yo=fa.getDate(),ll=qo===9&&Yo>=15||qo===10&&Yo<=1,Ts=null;(process.env.SPOOKFEST==="true"||ll)&&(Ts=await import("./halloween-MX3VNQRW.js"));var od=(e="...",t="Loading...",n="Dark")=>{let s=Mi(n),o=t;if(t==="c_openai"||t==="Custom (OpenAI)")try{let U=fi(li,{})?.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=qo===9&&Yo>=15||qo===10&&Yo<=1,g=h&&p||process.env.SPOOKFEST==="true"&&h,i=f;if(g&&Ts){process.env.HALLOWEEN_EEGG="true";let{halloweenArtSide:N,halloweenBat:U,halloweenArtUser:$}=Ts;i=Math.random()>.9&&qo===9&&Yo>=30?U:Math.random()>.5?N:$}else process.env.HALLOWEEN_EEGG="false";let x=g?ca:la,I=x[Math.floor(Math.random()*x.length)],Ye=s.logoGradient||["#0077ff","#ff00ff"],C=rl(Ye).multiline(i.join(`
|
|
535
542
|
`)).split(`
|
|
536
543
|
`),P=N=>`${a}${N}${m}`;return`${C[0]}
|
|
537
544
|
${C[1]} ${r}Selected ${g?"Pumpkin":"Provider"}: ${o}${m}
|
|
@@ -541,26 +548,26 @@ ${C[4]}
|
|
|
541
548
|
${C[5]} ${d}See /help for additional commands.${m}
|
|
542
549
|
${C[6]} ${P(I)}
|
|
543
550
|
${C[7]}
|
|
544
|
-
`};import{structuredPatch as
|
|
551
|
+
`};import{structuredPatch as gl}from"diff";import As from"path";import cl from"fs";var dl=e=>{try{return cl.readdirSync(e,{withFileTypes:!0})}catch{return[]}},Cs=(e,t=4,n=1,s=dl,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 As.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()}
|
|
545
552
|
`)}else g.length>0&&(I+=`${a}[${x(g)}]
|
|
546
|
-
`);let Ye=10,C=i.slice(0,Ye),P=i.length>Ye,N=[],U=[];for(let $ of C){let M=
|
|
553
|
+
`);let Ye=10,C=i.slice(0,Ye),P=i.length>Ye,N=[],U=[];for(let $ of C){let M=As.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=As.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
554
|
`);for(let{displayName:$,subDirPath:M,subEntries:Se,nextDepth:ve}of U)I+=`${a}${$}/
|
|
548
|
-
`,I+=
|
|
549
|
-
`),I};import
|
|
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=
|
|
555
|
+
`,I+=Cs(M,t,ve,s,m,Se);return P&&(I+=`${a}...max scan width, ReadFolder if needed
|
|
556
|
+
`),I};import Rs from"path";import fl from"fs";var ul=e=>{try{return fl.readdirSync(e,{withFileTypes:!0})}catch{return[]}},vs=(e,t,n="",s=1,o=ul,r=[])=>{let d=o(e),a=Rs.sep;if(d.length>100)return`${n}\u2514\u2500\u2500 ${Rs.basename(e)}${a} ...100+ files...
|
|
557
|
+
`;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=Rs.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}...
|
|
551
558
|
`;return}i.isDir?s>t?m+=`${n}${C}${i.name}${a} ...depth exceeded...
|
|
552
559
|
`:o(Ye).length>80?m+=`${n}${C}${i.name}${a} ...80+ files...
|
|
553
560
|
`:(m+=`${n}${C}${i.name}${a}
|
|
554
|
-
`,m+=
|
|
555
|
-
`}),m};var
|
|
556
|
-
`:"")},
|
|
557
|
-
`),I=i.toLowerCase().includes("tool:")||i.toLowerCase().includes("action:");d.push(i),I&&x?m=!0:m=!1}}}),f()}}return n.length};var
|
|
561
|
+
`,m+=vs(Ye,t,P,s+1,o,r)):m+=`${n}${C}${i.name}
|
|
562
|
+
`}),m};var ml={Ollama:()=>import("./ollama-7OZHJOT7.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-ACLWXYRS.js").then(e=>e.getCustomOpenAIStream)},_s={},de=async e=>(_s[e]||(_s[e]=await ml[e]()),_s[e]),pl=/```[\s\S]*?```/g,hl=/```[\s\S]*$/g,yl=/`[^`]+`/g,xl=/^\|.*\|$/gm,wl=/^[^\w]+|[^\w]+$/g,bl=/[^a-z0-9]/gi,Xo=/\[\s*(?:tool|action):(?:functions\.)?([a-z0-9_]+)\s*\(/gi,Sl=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-z0-9_]+)\s*\(/gi,kl=/(?:path|targetFile|TargetFile|directory|keyword|id|taskId|title|task)\s*=\s*\\?["']?([^\\"' \),]+)/,In=/["']/g,ua=/\\/g,Tl=/<\|channel>thought/gi,Al=/<channel\|>/gi,Cl=e=>typeof e!="string"?e:e.replace(Tl,"<think_fluxflow>").replace(Al,"</think_fluxflow>"),Zd=/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\]|$)/i,Rl=(e,t,n=1)=>{let s=t>0?e[t-1]:"",o=t+n<e.length?e[t+n]:"";return s==="`"&&o==="`"},vl=e=>{let t=/(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\])/gi,n;for(;(n=t.exec(e))!==null;)if(!Rl(e,n.index,n[0].length))return{index:n.index,length:n[0].length};return{index:-1,length:0}},Is=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=vl(s);if(o.index!==-1){let r=n+o.index+o.length;return{fullBlock:e.substring(0,r),innerContent:s.substring(0,o.index),remainingText:e.substring(r)}}return{fullBlock:e,innerContent:s,remainingText:""}},jt=e=>{if(!e||typeof e!="string")return e;let t=Is(e);return t?t.remainingText.trimStart():e};var ga=/<\|\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,El=/"([^"]+)"\s*:\s*(?:"([^"]*)"|(\d+)|true|false|null)/g,ma=/<\|\s*tool_calls_section_begin\s*\|>/gi,pa=/<\|\s*tool_calls_section_end\s*\|>/gi,_l=/```(?:tool|action|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi;var Li=e=>!e||typeof e!="string"?e:e.replace(/(```[\s\S]*?```|`[^`]*`)|(<(?:\w+)(?:[^>]*)>\r?\n?|\r?\n?<\/\w+(?:[^>]*)>)/gi,(t,n)=>n||""),ka=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?`
|
|
563
|
+
`:"")},Ps=null,Jo={},so={key:null,value:null},Ot=e=>{if(!e)return e;let t=Jo?.theme;if(!t)try{t=fi(li,{})?.systemSettings?.theme}catch{}let s=Mi(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`)},Il=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 ef=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(`
|
|
564
|
+
`),I=i.toLowerCase().includes("tool:")||i.toLowerCase().includes("action:");d.push(i),I&&x?m=!0:m=!1}}}),f()}}return n.length};var tf=()=>{xt=!0},nf=()=>xt,Ms={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}},Ta=e=>e?new wa({apiKey:e}):Ps,of=async(e,t,n,s,o={})=>{},Oi=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]!==`
|
|
558
565
|
`&&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]===`
|
|
559
|
-
`||t[o]==="\r"?s=!1:t[o]=" ",o++;continue}o++}return t.join("")},
|
|
560
|
-
`&&s[d]!=="\r"&&(s[d]=" ");r+=o.fullMatch.length}}return s.join("")},
|
|
561
|
-
`):null},
|
|
562
|
-
`),Ne=pn(
|
|
563
|
-
`),De=(g?.tokens||0)>=1e4,
|
|
566
|
+
`||t[o]==="\r"?s=!1:t[o]=" ",o++;continue}o++}return t.join("")},ha=(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]!==`
|
|
567
|
+
`&&s[d]!=="\r"&&(s[d]=" ");r+=o.fullMatch.length}}return s.join("")},Ml=e=>{let t=jt(e),n=Oi(t);Xo.lastIndex=0;let s;for(;(s=Xo.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,Xo.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}},Aa=(e,t=!0)=>{let n=Xo;n.lastIndex=0;let s="",o=0,r;for(;(r=n.exec(e))!==null;){let d=e.substring(o,r.index);s+=t&&o===0?jt(d):d;let a=r.index+r[0].length-1,m=0,f=null,h=-1;for(let p=a;p<e.length;p++){let g=e[p];if(f){if(g===f){let i=0;for(let x=p-1;x>=0&&e[x]==="\\";x--)i++;i%2===0&&(f=null)}}else if(g==='"'||g==="'"||g==="`")f=g;else if(g==="(")m++;else if(g===")"&&(m--,m===0)){let i=p+1;for(;i<e.length&&/\s/.test(e[i]);)i++;if(i<e.length&&e[i]==="]"){h=i;break}}}if(h!==-1)s+="[tool:functions."+r[1]+"()]",o=h+1,n.lastIndex=o;else{s+="[tool:functions."+r[1]+"(",o=e.length;break}}return o<e.length&&(s+=t&&o===0?jt(e.substring(o)):e.substring(o)),s},Pl=(e,t,n)=>{let s=Xo;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},ya=e=>Aa(e,!0),$l=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("");ga.lastIndex=0;let s=e.replace(ga,(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=El;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 ma.lastIndex=0,pa.lastIndex=0,s=s.replace(ma,""),s=s.replace(pa,""),s},Vn=e=>{if(!e)return[];let t=$l(e),n=jt(t),s=[],o=Oi(n),r=Sl;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},xa=e=>{if(!e)return null;let t=jt(e),n=[],s=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,o=[],r;for(;(r=s.exec(t))!==null;)o.push({toolName:r[1],index:r.index,parenIndex:r.index+r[0].length-1});for(let g=0;g<o.length;g++){let i=o[g],x=g+1<o.length?o[g+1].index:t.length,I=t.substring(i.index,x),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]:"")!=="["&&_i(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"&&_i(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];_i(g)&&n.push(`\u2022 [action:${g}...]: Missing opening '(' for tool arguments. Expected: [action:${g}(...)]`)}return n.length>0?n.join(`
|
|
568
|
+
`):null},sf=(e,t={})=>{if(!e)return null;if(Jo=t,Ps=new wa({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}}}},Ca=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}},Ll=async(e,t,n,s,o="Fast",r=.75,d="agent")=>Il(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 Xi("c_openai")||N}catch{}P=(await de("c_openai"))(m,t,g,s,o,f,Ze(t),x,r,N)}else{let N=Ta(m),{serviceTier:U,cleanModel:$}=Ca(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 Ht<"u"){let M=Ht.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?Zi(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),mi({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}}),rf=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(!Ps&&i==="Google")throw new Error("AI not initialized");let P=!1,N=t[t.length-1].text,U=B.join(Vs,"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 pi.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(zi,{});Object.values(b).flat().length>5}let ao=pn(zi,{}),wt=pn(zs,{}),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(`
|
|
569
|
+
`),Ne=pn(di,[]).map(b=>`- ${b.memory}`).join(`
|
|
570
|
+
`),De=(g?.tokens||0)>=1e4,Kt=new Date,Mn=Kt.getFullYear(),qn=Kt.toLocaleString("en-US",{month:"short"}).toUpperCase(),Pn=String(Kt.getDate()).padStart(2,"0"),dn=`${Kt.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}`,wn=b=>{try{return xe.readdirSync(b,{withFileTypes:!0})}catch{return[]}},Vt=Array.from(new Set([...$o,...Lo(process.cwd())])),bn=(b,ge=6)=>p?.indentationTree!==!1?Cs(b,ge,1,wn,Vt):vs(b,ge,"",1,wn,Vt),Yn=pn(qi,{}),H=Yn[f],D=H?H!==process.cwd():!1;Yn[f]=process.cwd(),Yi(qi,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,Yi(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]
|
|
564
571
|
**CONTEXT SUMMARY OF PREVIOUS TURNS (PRIORITY: DYNAMIC)**
|
|
565
572
|
${V}
|
|
566
573
|
|
|
@@ -568,11 +575,11 @@ ${V}
|
|
|
568
575
|
[SYSTEM METADATA]
|
|
569
576
|
**CONTEXT SUMMARY OF PREVIOUS TURNS**
|
|
570
577
|
${V}
|
|
571
|
-
`:"",rt=!!p?.dynamicDirAwareness,kt=`${f}|${i}|${d}|${e}|${r}|${rt}
|
|
578
|
+
`:"",rt=!!p?.dynamicDirAwareness,kt=`${f}|${i}|${d}|${e}|${r}|${rt}`,$n=!rt&&so.key===kt&&so.value?"":`
|
|
572
579
|
**Directory**
|
|
573
580
|
CWD: `+process.cwd()+`${h?" [PLAYGROUND MODE]":""}
|
|
574
|
-
`+bn(process.cwd(),6),at=So()?await io():null,
|
|
575
|
-
`)},lo=
|
|
581
|
+
`+bn(process.cwd(),6),at=So()?await io():null,Ni=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,Bt=(ke.text||"").trim().replace(/\r?\n+/g,". "),At=Bt?` [${Bt}]`:"";Tt.push(` ~L${ot}${At}`)}}return Tt.join(`
|
|
582
|
+
`)},lo=Ni(at?.comments),Tn="";if(at&&at.file_focused!=="none"){Tn=`
|
|
576
583
|
[Additional IDE Context]
|
|
577
584
|
`;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
585
|
Cursor Line: ${at.cursor_line}
|
|
@@ -585,7 +592,7 @@ Cursor Line: ${at.cursor_line}
|
|
|
585
592
|
... [truncated] ...
|
|
586
593
|
`+le.slice(-128)),Tn+=`Current Selection: "${le}"
|
|
587
594
|
`}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],
|
|
595
|
+
`),j=[];for(let ke=0;ke<le.length;ke++){let Pe=le[ke],ot=le[ke+1],Bt=le[ke+2];if(ot!==void 0&&Bt!==void 0&&/:\s*$/.test(Pe)&&/^\s*-\s*/.test(ot)&&/^\s*\+\s*/.test(Bt)&&(ot.length>300||Bt.length>300)){j.push(Pe.replace(/:\s*$/,": [changed]")),ke+=2;continue}j.push(Pe)}Tn+=`Recent Manual Edits:
|
|
589
596
|
${j.join(`
|
|
590
597
|
`)}
|
|
591
598
|
`}ge.length>0&&(Tn+=`All Opened Editors: ${ge.join(", ")}`),at.diagnostics&&(Tn+=`
|
|
@@ -594,23 +601,23 @@ ${at.diagnostics}
|
|
|
594
601
|
`),(Be.toLowerCase().includes("lint")||Be.toLowerCase().includes("warning"))&&at.warnings&&(Tn+=`
|
|
595
602
|
**Lint Warnings**:
|
|
596
603
|
${at.warnings}
|
|
597
|
-
`)}let
|
|
604
|
+
`)}let $s=Be.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),Ls=/(?:\\)?@\[([^\]]+)\]/g,Di,Fi=[];for(Ls.lastIndex=0;(Di=Ls.exec($s))!==null;){let b=Di[0].startsWith("\\");Fi.push({tag:Di[1],isEscaped:b})}let Bi=[],Qo=null,Zo=!1;for(let b=0;b<Fi.length;b++){let{tag:ge,isEscaped:Tt}=Fi[b];if(!Tt)try{let le=ge.trim().replace(/^["']|["']$/g,""),j=/[:#]L?(\d+)(?:-L?(\d+))?$/i,ke=le.match(j),Pe=le,ot=null,Bt=null;ke&&(ot=parseInt(ke[1],10),Bt=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 Ut=Pe.toLowerCase(),Ao=Ut.endsWith(".pdf"),Jn=Ut.endsWith(".docx")||Ut.endsWith(".doc")||Ut.endsWith(".ppt")||Ut.endsWith(".pptx")||Ut.endsWith(".xls")||Ut.endsWith(".xlsx"),Qn=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(Ut),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(tn=>tn.length)),J=Math.min(Fe+4,Je),$e=It.map(tn=>`${tn.padEnd(J-2).substring(0,J-2)}`).join(`
|
|
598
605
|
`);yield{type:"visual_feedback",content:Ot(`${$e}
|
|
599
606
|
`)};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
|
|
601
|
-
`)};continue}let Zn=`path=${JSON.stringify(Pe)}, startLine=${
|
|
607
|
+
`)};continue}}let Ln=ot!==null?ot:1,Wt=Bt!==null?Bt:ot!==null?ot:Ln+149;if(Wt-Ln>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}
|
|
608
|
+
`)};continue}let Zn=`path=${JSON.stringify(Pe)}, startLine=${Ln}, endLine=${Wt}`,Gt=await or(Zn,{isMultiModal:_t}),On=!1,fo="",bt=null;if(typeof Gt=="string"?Gt.trim().startsWith("ERROR")?On=!0:fo=Gt:Gt&&typeof Gt=="object"&&Gt.binaryPart?(bt=Gt.binaryPart,fo=Gt.text||""):On=!0,!On){let pe="";if(Qn?(pe=`\u2714 Processed: ${B.basename(Pe)}`,Qo=bt,Zo=!0):Ao||Jn?(pe=`\u2714 Auto-Analysed: ${B.basename(Pe)}`,Qo=bt,Zo=!0):(pe=`\u2714 Auto-Read: ${B.basename(Pe)}`,Bi.push(fo)),pe){let Je=115;process.stdout.isTTY&&(Je=process.stdout.columns-5||120);let It=[pe],Fe=Math.max(...It.map(tn=>tn.length)),J=Math.min(Fe+4,Je),$e=It.map(tn=>`${tn.padEnd(J-2).substring(0,J-2)}`).join(`
|
|
602
609
|
`);yield{type:"visual_feedback",content:Ot(`${$e}
|
|
603
|
-
`)}}}}}catch{}}let
|
|
604
|
-
[Tagged File Contents] Auto Read User Tagged files by System${
|
|
605
|
-
`+
|
|
610
|
+
`)}}}}}catch{}}let ei="";Bi.length>0?ei=`
|
|
611
|
+
[Tagged File Contents] Auto Read User Tagged files by System${Zo?", attached below & multimodal part":""}. No need to re-read
|
|
612
|
+
`+Bi.join(`
|
|
606
613
|
|
|
607
614
|
`)+`
|
|
608
615
|
[Tagged File Contents]
|
|
609
|
-
`:
|
|
616
|
+
`:Zo&&(ei=`
|
|
610
617
|
[Tagged File Contents] Auto Read User Tagged files by System & attached as multimodal part. No need to re-read [Tagged File Contents]
|
|
611
|
-
`);let Ue
|
|
612
|
-
`:"",
|
|
613
|
-
`:""}`:"",co="";if(p?.clipboardContext)try{process.platform==="win32"?co=
|
|
618
|
+
`);let Ue=$s.replace(/\\(@\[[^\]]+\])/g,"$1"),Os=I?`You cannot execute tools. Instead write the action string in chat you WOULD have written, without markdown wrappers. Then wait for system response
|
|
619
|
+
`:"",Ra=process.env.forcedReasoning||!1,Ns=d!=="Fast"&&(i==="Mistral"&&!ui(e)||d!=="High"&&i==="Google")?`${i==="Mistral"&&!ui(e)||e.toLowerCase().startsWith("gemma")||Ra?`[system] strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow> [/system]
|
|
620
|
+
`:""}`:"",co="";if(p?.clipboardContext)try{process.platform==="win32"?co=Es("powershell.exe -NoProfile -Command Get-Clipboard",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):process.platform==="darwin"?co=Es("pbpaste",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):co=Es("xclip -selection clipboard -o || xsel --clipboard --output",{encoding:"utf8",shell:!0,stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,"")}catch{co=""}let ti="",va=!!p?.autoExcludeMetadata,Ds=!1,Fs=!1,Ui="";if(Ue.startsWith("/skill create ")||Ue==="/skill create"){let b=null;Ds=!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(),Ui=`[system] ## Skill Creation Rules
|
|
614
621
|
* ${b?b==="project"?`Creation path: ./skills/skillName?/SKILL.md
|
|
615
622
|
* 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
|
|
616
623
|
* If skills folder already present, ReadFolder for existing structure`}
|
|
@@ -627,7 +634,7 @@ description: concise detail to explain the skill
|
|
|
627
634
|
* After creation, tell user to restart fluxflow for reindexing${(g?.tokens||0)>24576?`
|
|
628
635
|
* Warn: This session is currently long, and reindexing will cause full cache invalidation`:""}
|
|
629
636
|
[/system]
|
|
630
|
-
`}else if(Ue.startsWith("/skill edit ")||Ue==="/skill edit"){
|
|
637
|
+
`}else if(Ue.startsWith("/skill edit ")||Ue==="/skill edit"){Fs=!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=[...ki||[],...Si||[]].find(Pe=>Pe&&Pe.name&&Pe.name.toLowerCase()===j);ke&&ke.filePath&&(le=B.resolve(ke.filePath),Tt=B.dirname(le))}Ui=`[system] ## Skill Modification Rules
|
|
631
638
|
${Tt&&b?`* Target Skill: ${b}
|
|
632
639
|
* Physical Skill path: ${le}
|
|
633
640
|
* Skill will have a SKILL.md at this path. And may have lazy loaded *.md files in folders
|
|
@@ -637,7 +644,7 @@ ${Tt&&b?`* Target Skill: ${b}
|
|
|
637
644
|
* After completion tell user no reindexing needed, will be auto updated on next #skill read if frontmatter stays same${(g?.tokens||0)>24576?`
|
|
638
645
|
* 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`"}
|
|
639
646
|
[/system]
|
|
640
|
-
`}let
|
|
647
|
+
`}let Ea=!!(Tn||ei||Os||nt||Ns||D||p?.dynamicDirAwareness||p?.autoTruncateResults||Ds||Fs);va&&!Ea?ti=Ue.trim():ti=`[System Metadata] Time: ${dn}${D?`
|
|
641
648
|
WARNING: CWD Changed from previous: "${H}" to current: "${process.cwd()}", write change in chat to avoid future path mismatches
|
|
642
649
|
`:""}${Tn}
|
|
643
650
|
${co.trim().length>0?`[Clipboard Context]
|
|
@@ -646,11 +653,11 @@ ${co.trim().length>0?`[Clipboard Context]
|
|
|
646
653
|
${lo.trimEnd()}
|
|
647
654
|
`:""}Action format: [action:ActionName(...)]
|
|
648
655
|
[/Metadata]
|
|
649
|
-
${nt}${
|
|
656
|
+
${nt}${Ns}${ei}${Ui}${Os}[user prompt] ${Ue.trim()} [/user prompt]`.trim();let Bs={role:"user",text:ti};Qo&&(Bs.binaryPart=Qo),w.forEach(b=>{b.text&&b.role==="agent"&&(b.text=jt(b.text))}),w.push(Bs),nt&&t[t.length-1]?.id&&(yield{type:"summary_injected",content:{id:t[t.length-1].id,text:ti}});let Zt=null,en=a==="Flux"?50:15;en=a.toLowerCase().includes("cu")?75:en;let Us=(p?.loopLimits||"Default").toLowerCase();if(Us==="extended")en=Math.floor(en*3);else if(Us==="env"){let b=parseInt(process.env.FLUXFLOW_MAX_LOOPS||process.env.MAX_LOOPS||"",10);Number.isFinite(b)&&b>0&&(en=b)}let _a=Math.floor(en/2),Ws=0,fn=16;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Consulting the spirits":"Connecting"},xt=!1;let Wi=[],ni=!1,Gs=!1,Xn=[],Gi=!1;for(let b=0;b<=en;b++){let ge=Math.floor(en*.95);if(b>=ge&&Ws<ge&&typeof n?.onAskUser=="function"){Ws=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")&&(en+=_a)}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+=`
|
|
650
657
|
|
|
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
|
|
658
|
+
[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 Qi("agent",n);if(!Tt.allowed)throw new Error(Tt.reason||`Budget Exhausted for Provider (${i||"Agent"})`);let le=[];if(ni=!1,(a==="ICU"||a==="FluxCU")&&!Gi)try{yield{type:"status",content:"Capturing Screen"},await new Promise(E=>setTimeout(E,1e3));let{captureGriddedScreenshot:K}=await import("./screen_grid-RN2WVT2W.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+=`
|
|
652
659
|
|
|
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(
|
|
660
|
+
${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(Gi=!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:`
|
|
654
661
|
|
|
655
662
|
\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(`
|
|
656
663
|
|
|
@@ -662,7 +669,7 @@ ${E}`:w.push({role:"user",text:E}),yield{type:"status",content:"Subagent Update"
|
|
|
662
669
|
[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
670
|
[question] ${K.replace("/btw","").trim()} [/question]`}):w.length>0&&w[w.length-1].role==="user"?w[w.length-1].text+=`
|
|
664
671
|
|
|
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,
|
|
672
|
+
[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,Bt=Date.now(),At=null,be="",Ut=null,Ao=null,Jn=null,Qn=0,je=[],_t=0,Ln=!1,Wt=!1,Zn=!1,Gt=!1,On=!0,fo=0,bt="",pe="",Je=!1,It=!1,Fe=!0,J=e,$e="",tn=d;for(d=d.toLowerCase()==="max"?"High":d;Pe<=fn&&ot<=fn&&!ke&&!xt;){let K=!1;try{be="",On&&(process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07"),yield{type:"turn_reset",content:!0},On=!1,ot===1&&(bt=""));let Q=u=>{if(!u||typeof u!="string")return u;let S="",k=Is(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=Li(u);return(p?.keepReasoningContext?S:"")+y}u=u.replace(_l,(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+=Li(u.substring(L)));break}if((ne>0?u[ne-1]:"")==="`"){ie+=Li(u.substring(L,ne+1)),L=ne+1;continue}q.length===0&&(yt=Li(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 Dn=u.substring(ne,Z+1);q.push(Dn),L=Z+1}return q.length>0&&(ie=yt.trimEnd()?yt.trimEnd()+`
|
|
666
673
|
|
|
667
674
|
`+q.join(`
|
|
668
675
|
|
|
@@ -670,10 +677,10 @@ ${E}`:w.push({role:"user",text:E}),yield{type:"status",content:"Subagent Update"
|
|
|
670
677
|
|
|
671
678
|
`)),(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+=`
|
|
672
679
|
|
|
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}|${
|
|
674
|
-
${
|
|
680
|
+
`+(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}|${tn}|${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"?!!ui(J):!(J||"gemma").toLowerCase().startsWith("gemma");$e=Ur(r,((J||"gemma").toLowerCase().startsWith("gemma"),tn),a,p,P,M,i,i==="Google"?!0:C,u,f,!!p?.keepReasoningContext,J),p?.dynamicDirAwareness||($e+=`
|
|
681
|
+
${$n.replace(`
|
|
675
682
|
**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=
|
|
683
|
+
-- 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=Ni(u?.comments);S&&me&&me.role==="user"&&me.parts?.[0]?.text&&(me.parts[0].text+=`
|
|
677
684
|
|
|
678
685
|
${S}`),lo&&me&&me.role==="user"&&me.parts?.[0]?.text&&(me.parts[0].text+=`
|
|
679
686
|
|
|
@@ -683,25 +690,25 @@ ${k}`),yield{type:"status",content:"Working"}}let St=i==="Mistral"||i==="Google"
|
|
|
683
690
|
`;for(let z of u.newFiles)S+=`* ${z} (created)
|
|
684
691
|
`;for(let z of u.modifiedFiles)S+=`* ${z} (modified)
|
|
685
692
|
`;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(
|
|
687
|
-
[system] WARNING, Turn Limit Impending: Step ${mt}/${
|
|
693
|
+
`;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(en*.99),mt=b+1;if(mt>=it&&me&&me.parts?.[0]&&(me.parts[0].text+=`
|
|
694
|
+
[system] WARNING, Turn Limit Impending: Step ${mt}/${en}. 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"}
|
|
688
695
|
Key: ${fe}
|
|
689
696
|
--------------------------------------------------------------------
|
|
690
697
|
|
|
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(
|
|
698
|
+
${$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(Bt=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 Xi("c_openai")||u}catch{}j=(await de("c_openai"))(n.apiKey,J,_e,$e,d,a,C,W.signal,1,u)}else{let u=Ta(n?.apiKey),{serviceTier:S,cleanModel:k}=Ca(J),z={systemInstruction:$e,mediaResolution:"MEDIA_RESOLUTION_HIGH",safetySettings:[{category:$i.HARM_CATEGORY_HARASSMENT,threshold:Pi.BLOCK_NONE},{category:$i.HARM_CATEGORY_HATE_SPEECH,threshold:Pi.BLOCK_NONE},{category:$i.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:Pi.BLOCK_NONE},{category:$i.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:Pi.BLOCK_NONE}],temperature:1.05,thinkingConfig:(()=>{let L=nr("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="",Ut=null,Jn=null,je=[],_t=0,yield{type:"model_update",content:null},pe="",Je=bt.length>0;let pt="",oi=Date.now(),un=async function*(){if(i==="Google"&&pt){let u=Ro(pt);for(let S of u)yield S;pt="",oi=Date.now()}},Hs=!0,An="",uo=!1,ht=null,js=!1,to=!1,go=!1,ii=!1,Nn=!1,Co=u=>{let S=0;for(;S+2<u.length;)u[S]==="`"&&u[S+1]==="`"&&u[S+2]==="`"?(ii=!ii,S+=3):S++},Ks=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|>"?Nn=!1:Nn=!0}},La={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(!js){S.push({type:"text",content:ie}),Co(ie),Ks(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),Nn)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|>"?Nn=!1:Nn=!0,S.push({type:"text",content:ne}),q=L.lastIndex}let y=ie.substring(q);if(y)if(Co(y),Nn)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=La[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),Ks(T),(ht==="tool"||ht==="action"||ht?.startsWith("kimi"))&&!to&&!go&&(js=!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=ii||Ie==="`",go=Nn,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=ii||Ie==="`",go=Nn,uo=!0,An=k.substring(l),k=""}else{z(k);break}}}return S},Oa=j[Symbol.asyncIterator]();for(;;){let{value:u,done:S}=await Promise.race([Oa.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=Cl(k);let ie=k?Zi(k):0;if(n&&typeof n.onTokenChunk=="function"&&n.onTokenChunk(k,ie),Hs&&(At===null&&(At=Date.now()-Bt),yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"},Hs=!1),xt){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
|
|
692
699
|
|
|
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=
|
|
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"),
|
|
700
|
+
\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=Ml(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,Dn=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(In,"");else if(v)l=B.basename(String(v).replace(In,"").replace(ua,"/"));else if(Dn&&(T==="invoke"||T==="invoke_sync"))l=String(Dn).replace(In,"").substring(0,30);else if(Mt&&T==="get_progress")l=String(Mt).replace(In,"");else if(ut&&T==="await"){let Qe=parseFloat(String(ut).replace(In,""));isNaN(Qe)?l=String(ut).replace(In,""):(Qe<5&&(Qe=5),Qe>120&&(Qe=180),l=(Pt=>{if(Pt>=60){let Fn=Math.floor(Pt/60),nn=Pt%60;return`${Fn}m${nn>0?` ${nn}s`:""}`}return`${Pt}s`})(Qe))}else if(ut&&T==="wait"){let Qe=parseFloat(String(ut).replace(In,""));isNaN(Qe)?l=String(ut).replace(In,""):(Qe<10&&(Qe=10),Qe>120&&(Qe=120),l=(Pt=>{if(Pt>=60){let Fn=Math.floor(Pt/60),nn=Pt%60;return`${Fn}m${nn>0?` ${nn}s`:""}`}return`${Pt}s`})(Qe))}else{let Qe=ne.match(kl);if(Qe){let se=Qe[1].replace(In,"");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(ua,"/"))}}}let Ie=`${Ms[T]||T}${l?` ${l}`:""}`;if((T!==Ut||l!==Ao)&&(Ut=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=Aa(be,!1),T=Is(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,Dn=.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...`},Wt=!0,await new Promise(ct=>setTimeout(ct,3e3));break}let se=ya(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)>Dn){yield{type:"status",content:"Response Loop Detected. Re-centering..."},Wt=!1,Gt=!0,await new Promise(re=>setTimeout(re,3e3));break}let nn=y.replace(pl,"").replace(hl,"").replace(yl,"").replace(xl,""),Bn=nn.toLowerCase().split(/\s+/).map(re=>re.replace(wl,"")).filter(re=>re.length>0),Eo=!1;if(Bn.length>=40)for(let re=1;re<=15;re++){let ct=Math.max(8,Math.ceil(25/re));if(Bn.length<re*ct)continue;let Un=Bn.slice(Bn.length-re),c=Un.join(" ");if(re>1&&c===Un.slice(0,Math.floor(re/2)).join(" ").repeat(2).trim())continue;let R=!0;for(let _=1;_<ct;_++)if(Bn.slice(Bn.length-re*(_+1),Bn.length-re*_).join(" ")!==c){R=!1;break}if(R){Eo=!0;break}}if(!Eo){let re=nn.toLowerCase().replace(bl,"");if(re.length>=80)for(let ct=1;ct<=10;ct++){let Un=Math.max(15,Math.ceil(45/ct));if(re.length<ct*Un)continue;let c=re.substring(re.length-ct),R=!0;for(let _=1;_<Un;_++)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..."},Wt=!1,Zn=!0,await new Promise(re=>setTimeout(re,3e3));break}}let q=jt(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=Ms[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(`
|
|
701
|
+
`).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"),qt=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||qt?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"],Dn=["path","targetPath","file","content","searchContent*","replaceContent*","newContent*","recurse","include","StartLine","EndLine","start_line","end_line","startLine","endLine"],Mt=Rt.includes(l)?O(y.args,Dn):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?`
|
|
695
702
|
`:""}${ee}
|
|
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";
|
|
703
|
+
`)},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";qs(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)),Yt=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(Yt)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(Wn=>mo.includes(Wn)),no=dt.findIndex(Wn=>["run","exec","test"].includes(Wn));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,qt="";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),Yt=Re=>Re?Re.toLowerCase().replace(/\\/g,"/").replace(/^[a-z]:/,X=>X.toUpperCase()):"",ze=Yt(Ve),Oe="",dt=!1,ft=await io(),He=Yt(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 pi.recordFileChange(Ve,Oe),dt){let Re=Oe;if(l==="write_file"){let X=Te.content||Te.newContent||"";Re=X.endsWith(`
|
|
697
704
|
`)?X:X+`
|
|
698
|
-
`,
|
|
699
|
-
${
|
|
700
|
-
`)}`,
|
|
701
|
-
`:""}${gn}`)},Fe=!1,je.push({role:"user",text:
|
|
705
|
+
`,qt=Re}else{let{patchPairs:X,allowMultiple:Nt,error:Cn}=es(Te);if(Cn){let Xt=`[ACTION RESULT]: ERROR: ${Cn}`;je.push({role:"user",text:Xt}),await Lt("toolFailure"),n.onToolResult&&n.onToolResult("failure",l),yield{type:"tool_result",content:Xt,toolName:l},_t++;continue}let mo=Te.allowMultiple!==void 0?Te.allowMultiple===!0||String(Te.allowMultiple).toLowerCase()==="true":Nt;Et=X.length;let Rn=Xs(Oe,X,{allowMultiple:mo});Re=Rn.content,qt=Re,vt=Rn.results;let no=vt.filter(Xt=>Xt.success),Wn=vt.filter(Xt=>!Xt.success);if(no.length===0){let Xt=`[ACTION RESULT]: ERROR: Failed to apply patches to [${B.basename(Ve)}].
|
|
706
|
+
${Wn.map(Gn=>` \u2022 ${Gn.error}`).join(`
|
|
707
|
+
`)}`,si=`\u2714 Edited: ${B.basename(Ve.replaceAll("\\","/"))}`,Io=115;process.stdout.isTTY&&(Io=process.stdout.columns-5||120);let Ki=Math.min(si.length+4,Io),gn=`${si.padEnd(Ki-2).substring(0,Ki-2)}`;yield{type:"visual_feedback",content:Ot(`${Fe?`
|
|
708
|
+
`:""}${gn}`)},Fe=!1,je.push({role:"user",text:Xt}),await Lt("toolFailure"),n.onToolResult&&n.onToolResult("failure",l),yield{type:"tool_result",content:Xt,toolName:l},_t++;continue}}yield{type:"status",content:`Opening Diff in IDE: ${B.basename(Ve)}`},ls(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
709
|
`)?Re:Re+`
|
|
703
|
-
`;
|
|
704
|
-
${F.split(/\r?\n/).map((st,
|
|
710
|
+
`;qt=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)}`},ls(Ve,"",X),Ge=!0,await new Promise(Nt=>setTimeout(Nt,50))}}}catch(Te){console.error("Simulation/Diff Error:",Te)}let Me=null;as(Te=>{Me=Te});let ye=n.onToolApproval;if(G=await new Promise(async Te=>{let Le=setInterval(()=>{if(Me){let Ce=n.onIDEApproval||Jo&&Jo.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")}}),as(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(kr(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():"",Yt=await io(),ze="";if(Yt&&Yt.file_focused&&Ve(Yt.file_focused)===Ve(Ce)&&Yt.full_content&&(ze=Yt.full_content),!ze&&xe.existsSync(Ce)){let Ke=xe.readFileSync(Ce,"utf8");Ke&&(ze=Ke)}!ze&&qt&&(ze=qt),(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:
|
|
711
|
+
${F.split(/\r?\n/).map((st,on)=>`${on+1} | ${st}`).join(`
|
|
705
712
|
`)}
|
|
706
713
|
|
|
707
714
|
`);let Re="";if(dt<=100)Re=Oe.join(`
|
|
@@ -711,51 +718,51 @@ ${F.split(/\r?\n/).map((st,nn)=>`${nn+1} | ${st}`).join(`
|
|
|
711
718
|
|
|
712
719
|
... [${dt-100} lines truncated for history stability] ...
|
|
713
720
|
|
|
714
|
-
${st}`}let X="";if(l==="update_file"){let Ke=
|
|
721
|
+
${st}`}let X="";if(l==="update_file"){let Ke=Qs(F,ze,vt,12,n?.compressToolResults||Jo?.systemSettings?.compressToolResults),{patchPairs:st}=es(O(y.args,["path","searchContent*","replaceContent*","newContent*"])),on=st?.length||Et||1,$t=0,Jt=0,Hn=[];st&&st.length>0?st.forEach((Kn,yo)=>{let xo=Kn.replace||"",sn=Kn.new||"",Vi=xo.trim(),Po=sn.trim(),Ga=!!qt&&ze===qt,Ha=Po?ze.includes(sn)||ze.includes(Po):!0,ja=sn?F.includes(sn)||!!Po&&F.includes(Po):!1,Ka=Vi?ze.includes(xo)||ze.includes(Vi):!1;Ga||!!sn&&Ha&&(!ja||!Ka||Vi===Po)?$t++:(Jt++,Hn.push(` \u2022 Block ${yo+1}: not applied (reverted or rejected in IDE).`))}):$t=Et||0;let vn=0;if(qt&&ze!==qt){let Kn=gl("","",qt||"",ze||"","","",{context:0});if(Kn&&Kn.hunks)for(let yo of Kn.hunks){let xo=yo.lines.filter(sn=>sn.startsWith("+")).map(sn=>sn.slice(1).trim()).filter(Boolean);for(let sn of xo)F.includes(sn)||vn++}}let Mo=[`[${$t}/${on}] applied`];Jt>0&&Mo.push(`${Jt} rejected by user`),vn>0&&Mo.push(`${vn} manual ${vn===1?"modification":"modifications"} by user`);let po=Mo.join(", "),jn=Hn.length>0?`
|
|
715
722
|
|
|
716
723
|
User Review Details:
|
|
717
|
-
${
|
|
718
|
-
`)}`:"";X=`File [${ye}] updated via IDE Companion. ${po}.${
|
|
724
|
+
${Hn.join(`
|
|
725
|
+
`)}`:"";X=`File [${ye}] updated via IDE Companion. ${po}.${jn}
|
|
719
726
|
|
|
720
727
|
${Ke}${Le?`
|
|
721
728
|
|
|
722
|
-
[Note: '~' resolved to user home directory. To target literal '~' in current directory, escape it as '\\~']`:""}`;let{added:
|
|
723
|
-
${po.map((
|
|
729
|
+
[Note: '~' resolved to user home directory. To target literal '~' in current directory, escape it as '\\~']`:""}`;let{added:ri,removed:ai}=Js(F,ze);(ri>0||ai>0)&&await Ji({added:ri,removed:ai,file:ye})}else{let Ke=ze.split(/\r?\n/),st=Ke.length,on=Buffer.byteLength(ze,"utf8"),$t="",Jt=c?.overwriteProtection!==!1;if(F){let po=F.split(/\r?\n/);if(!Jt)$t="";else if(po.length<=50)$t=`Old File contents:
|
|
730
|
+
${po.map((jn,ho)=>`${ho+1} | ${jn}`).join(`
|
|
724
731
|
`)}
|
|
725
732
|
|
|
726
|
-
`;else{let
|
|
727
|
-
- Renamed old file as ${yo.replaceAll("\\","/").replace(
|
|
733
|
+
`;else{let jn=B.parse(Ce),ho=B.join(ci,"OverwriteBackups");if(!xe.existsSync(ho))try{xe.mkdirSync(ho,{recursive:!0})}catch{}let ri=String(Date.now()).slice(-5),ai=Sa.randomBytes(2).toString("hex"),Kn=`${jn.name}-old-${ri}-${ai}${jn.ext}.bak`,yo=B.join(ho,Kn);try{xe.writeFileSync(yo,F,"utf8")}catch{}$t=`Old File contents:
|
|
734
|
+
- Renamed old file as ${yo.replaceAll("\\","/").replace(ba.homedir().replaceAll("\\","/"),"~")} and written requested content in ${ye}. For reversal use Run
|
|
728
735
|
|
|
729
|
-
`}}let
|
|
736
|
+
`}}let Hn="";if(st<=690)Hn=Ke.join(`
|
|
730
737
|
`);else{let po=Ke.slice(0,300).join(`
|
|
731
|
-
`),
|
|
732
|
-
`);
|
|
738
|
+
`),jn=Ke.slice(-300).join(`
|
|
739
|
+
`);Hn=`${po}
|
|
733
740
|
|
|
734
741
|
... [${st-100} lines truncated] ...
|
|
735
742
|
|
|
736
|
-
${
|
|
743
|
+
${jn}`}let vn=Le?`
|
|
737
744
|
|
|
738
745
|
[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, ${(
|
|
746
|
+
- Stats: [${st} lines, ${(on/1024).toFixed(1)} KB]
|
|
740
747
|
${$t}- Content Preview:
|
|
741
748
|
|
|
742
|
-
${
|
|
743
|
-
`:""}${
|
|
744
|
-
`));let
|
|
749
|
+
${Hn}${vn}`;let Mo=F?F.split(/\r?\n/).length:0;await Ji({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"}`,Wn=115;process.stdout.isTTY&&(Wn=process.stdout.columns-5||120);let Xt=Math.min(no.length+4,Wn),si=`${no.padEnd(Xt-2).substring(0,Xt-2)}`;yield{type:"visual_feedback",content:Ot(`${Fe?`
|
|
750
|
+
`:""}${si}`)},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.
|
|
751
|
+
`));let Gn;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*$/),on=st?`
|
|
745
752
|
|
|
746
|
-
${st[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(Ke)){let $t=Ke.search(/^- Content Preview:/m);
|
|
753
|
+
${st[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(Ke)){let $t=Ke.search(/^- Content Preview:/m);Gn=`[ACTION RESULT]: ${$t!==-1?Ke.slice(0,$t).trimEnd():Ke}
|
|
747
754
|
|
|
748
|
-
[Old file content for reversal reference. Replaced with new write request]${
|
|
755
|
+
[Old file content for reversal reference. Replaced with new write request]${on}`}else{let $t=Ke.split(/\r?\n/),Jt=$t.filter(vn=>vn.startsWith("File ")||vn.trim().startsWith("- Stats:"));Gn=`[ACTION RESULT]: ${Jt.length>0?Jt.join(`
|
|
749
756
|
`):$t.slice(0,2).join(`
|
|
750
|
-
`)}${
|
|
757
|
+
`)}${on}`}}else if(gn.startsWith("[[SAME]]")){let st=gn.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),on=st.filter(Jt=>Jt.startsWith("File ")||Jt.trim().startsWith("- Stats:"));Gn=`[ACTION RESULT]: ${on.length>0?on.join(`
|
|
751
758
|
`):st.slice(0,2).join(`
|
|
752
|
-
`)}`}else
|
|
759
|
+
`)}`}else Gn=`[ACTION RESULT]: ${gn}`;je.push({role:"user",text:Gn}),Ln=!0,await Lt("toolSuccess"),n.onToolResult&&n.onToolResult("success",l),yield{type:"tool_result",content:X,aiContent:Gn,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
760
|
`:""}${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)}`,
|
|
761
|
+
`)},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)}`,Yt=` ${" ".repeat(Ce)} `;yield{type:"visual_feedback",content:Ot(`${Fe?`
|
|
755
762
|
`:""}${Ve}
|
|
756
763
|
`)},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?`
|
|
757
764
|
`:""}${ce}${v.includes("\u2714")&&(v.includes("Created")||v.includes("Edited"))?"":`${R?"":`
|
|
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
|
|
765
|
+
`}`}`)},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 ks(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);Sr(_)}}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 Fn=null;if(typeof se=="object"&&se.binaryPart&&(Fn=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?`
|
|
759
766
|
`:""}${Ge}
|
|
760
767
|
`)},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
768
|
`:""}${Ae}${oe?"":`
|
|
@@ -766,7 +773,7 @@ ${st[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(Ke)){let $t=Ke.search(
|
|
|
766
773
|
`).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
774
|
`);yield{type:"visual_feedback",content:Ot(`${Fe?`
|
|
768
775
|
`:""}${ae}${!1?"":`
|
|
769
|
-
`}`)},Fe=!1}}l==="exec_command"&&n.onExecEnd&&(await new Promise(c=>setTimeout(c,800)),n.onExecEnd());let
|
|
776
|
+
`}`)},Fe=!1}}l==="exec_command"&&n.onExecEnd&&(await new Promise(c=>setTimeout(c,800)),n.onExecEnd());let nn=se&&se.startsWith("DENIED:");se&&!se.startsWith("ERROR:")&&!nn?(await Lt("toolSuccess"),n.onToolResult&&n.onToolResult("success",l)):nn||(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
777
|
`));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?`
|
|
771
778
|
|
|
772
779
|
${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}
|
|
@@ -775,11 +782,11 @@ ${R[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(c)){let ce=c.search(/^-
|
|
|
775
782
|
`):ce.slice(0,2).join(`
|
|
776
783
|
`)}${_}`}}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(`
|
|
777
784
|
`):R.slice(0,2).join(`
|
|
778
|
-
`)}`}else ct=`[ACTION RESULT]: ${re}`;je.push({role:"user",text:ct,binaryPart:
|
|
785
|
+
`)}`}else ct=`[ACTION RESULT]: ${re}`;je.push({role:"user",text:ct,binaryPart:Fn}),Ln=!0;let Un=`[ACTION RESULT]: ${se.replaceAll(`[[VERIFIED]]
|
|
779
786
|
`,"").replaceAll(`
|
|
780
|
-
[[/VERIFIED]]`,"")||""}`;(l==="view_file"||l==="web_scrape"||l==="file_map"||l==="search_keyword"||l==="get_progress"||l==="getprogress")&&(
|
|
787
|
+
[[/VERIFIED]]`,"")||""}`;(l==="view_file"||l==="web_scrape"||l==="file_map"||l==="search_keyword"||l==="get_progress"||l==="getprogress")&&(Un=`[ACTION RESULT]: ${v} (Context Locked for UI Clarity)`),yield{type:"tool_result",content:Un,aiContent:ct,binaryPart:Fn,toolName:l},l==="memory"&&!se.startsWith("ERROR:")&&(yield{type:"memory_updated"}),_t++}if(i==="Google"&&pt&&Date.now()-oi>=150){yield*un();let y=Ro(pt);for(let T of y)yield T;pt="",oi=Date.now()}}u.usageMetadata&&(Zt=u.usageMetadata),Zt&&(yield{type:"liveTokens",content:Zt.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(),Na=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(vo.toLowerCase())||/\[\[END\]\]/i.test(vo.toLowerCase()),Da=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(vo.toLowerCase()),Fa=je.length>0||Ut!==null,ji=jt(vo).trim(),Ba=/(\p{Emoji_Presentation}|\p{Extended_Pictographic})$/u.test(ji),Ua=/([.!?"'*_`|\]\)”’~~]+|\s|`{3}|[\u200B-\u200D\uFEFF])$/u.test(ji.trim()),Wa=/[.!?}"'`’“”]$|```$/s.test(ji)||Ua||Ba;!Na&&!Da&&!Fa&&vo.length>0,ke=!0,await Lt("agent",i)}catch(Q){if(xt){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
|
|
781
788
|
|
|
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
|
|
789
|
+
\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 zt=it;zt>0;zt--)if(bt.endsWith(pe.substring(0,zt))){St=zt;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}
|
|
783
790
|
|
|
784
791
|
----------------------------------------------------------------------
|
|
785
792
|
|
|
@@ -788,12 +795,12 @@ ${R[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(c)){let ce=c.search(/^-
|
|
|
788
795
|
- no repetition: do not repeat any text already written
|
|
789
796
|
- 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
|
|
790
797
|
- mid-tool safety: if cutoff was mid-tool call, restart that tool call from start
|
|
791
|
-
- stealth: do not mention/apologize for cutoff [/system]`;je.length>0?je.forEach((mt,
|
|
798
|
+
- stealth: do not mention/apologize for cutoff [/system]`;je.length>0?je.forEach((mt,zt)=>{zt===je.length-1?w.push({...mt,text:`${mt.text}
|
|
792
799
|
|
|
793
800
|
${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),
|
|
795
|
-
Error log can be found in \`/export logs\``)}}}if(
|
|
796
|
-
`),Q=
|
|
801
|
+
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),zt=.8+Math.random()*.4,lt=Math.round(mt*zt);On=!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)
|
|
802
|
+
Error log can be found in \`/export logs\``)}}}if(Zt){let K=Zt.totalTokenCount||0,Q=Zt.cachedContentTokenCount||0,E=(Zt.candidatesTokenCount||0)+(i==="Google"&&Zt.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),mi({provider:i,model:J,prompt:Zt.promptTokenCount||0,cached:Q,output:E,reasoning:Zt.thoughtsTokenCount||0,ttft:At}),yield{type:"usage",content:Zt}}else At!==null&&At>0&&(await hn("ttft",At,i,J),mi({provider:i,model:J,prompt:0,cached:0,output:0,reasoning:0,ttft:At}));be=ka(be),Wi.push(be);let Ol=jt(be),Hi=ya(be),Ia=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(Hi.toLowerCase())||/\[\[END\]\]/i.test(Hi.toLowerCase())||!0,Nl=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(Hi.toLowerCase()),Dl=_t>0;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"};let Ma=Pl(be,/(\[\s*(turn\s*:)?\s*(continue|finish)\s*\]|\[\[END\]\])/gi,"").trim(),Pa=je.length>0||Vn(jt(be)).length>0,eo=(Ia||je.length===0)&&!Wt&&!Zn&&!Gt;if(eo=je.length===0?eo:!1,eo=Pa&&It||ni?!1:eo,be&&be.trim().endsWith('")]')&&je.length===0&&(eo=!1),eo){Gs=!0;let K=Wi.join(`
|
|
803
|
+
`),Q=jt(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(`
|
|
797
804
|
|
|
798
805
|
[system] user question. resolve this specific query within '[ANSWER] ... [/ANSWER]' concisely, naturally [/system]
|
|
799
806
|
`,"").replaceAll(`[system] user question. resolve this specific query within '[ANSWER] ... [/ANSWER]' concisely, naturally
|
|
@@ -801,23 +808,23 @@ Error log can be found in \`/export logs\``)}}}if(Qt){let K=Qt.totalTokenCount||
|
|
|
801
808
|
`,"").replaceAll(`[system] **strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow>** [/system]
|
|
802
809
|
`,"").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=`
|
|
803
810
|
[system] Action result received. Analyze output and proceed with your turn [/system]`,We=`
|
|
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
|
|
811
|
+
[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 $a=Ma.trim()||"*Working...*";if(w.push({role:"agent",text:$a}),je.length>0||Ln){if(je.length>0){let K=je.map(lt=>lt.text).join(`
|
|
805
812
|
|
|
806
|
-
`),Q=
|
|
807
|
-
`),_e=
|
|
813
|
+
`),Q=jt(be),E=Vn(Q),gt=ha(Q,E),fe=Oi(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(`
|
|
814
|
+
`),_e=xa(lt);K+=`
|
|
808
815
|
|
|
809
816
|
[system] Only ${je.length} out of ${mt} attempted tool calls were executed.
|
|
810
817
|
${_e?`Parsing Issues Detected:
|
|
811
818
|
${_e}
|
|
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
|
|
819
|
+
`:""}Verify proper structure compliance [action:ActionName(arg="value")] & try failed calls again [/system]`;for(let pt=0;pt<it;pt++)await Lt("toolFailure")}let zt=je.find(lt=>lt.binaryPart)?.binaryPart||null;w.push({role:"user",text:K,binaryPart:zt})}}else if(!xt){let K=be.replace(/(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\]|$)/i,""),Q=Vn(K),E=ha(K,Q),fe=(Oi(E).match(/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi)||[]).length;if(ni||It&&fe>0||fe>0){let We=xa(K),Ct=We?`[system] Failed to execute ${fe>0?fe:1} action call${fe>1?"s":""} due to syntax/structure issues:
|
|
813
820
|
${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
821
|
${Ot("\u2718 Model produced malformed tool call")}
|
|
815
822
|
`}}else yield{type:"visual_feedback",content:`
|
|
816
823
|
${Ot("\u2718 Loop Detected")}
|
|
817
|
-
`},w.push({role:"user",text:`[system] ${Zn&&!
|
|
824
|
+
`},w.push({role:"user",text:`[system] ${Zn&&!Wt?"Stuttering Detected by Internal System. Re-calibrate your response & proceed.":`${Wt?" Over Thinking":" Loop"} Detected by Internal System${Wt?" for current Effort Level":""}. ${Wt?"If you have planned the task, prioritize execution/output":"If you have finished your task provide a simple summary and end"}`} [/system]`});Wt=!1,Zn=!1,Gt=!1}p?.advanceRollback&&await Oo.recordTurnDelta(f,b+1,le),Gi=le.includes("recapture_screen"),ni=_t>0||Ln}if(!Gs&&!xt){let b="\u2726 Turn safety limit reached. Stopping execution.";yield{type:"text",content:`
|
|
818
825
|
|
|
819
826
|
${b}
|
|
820
|
-
`};let ge=(
|
|
827
|
+
`};let ge=(Wi.join(`
|
|
821
828
|
`)+`
|
|
822
829
|
${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:`
|
|
823
830
|
|
|
@@ -827,8 +834,8 @@ CAUSE: ${W.cause?.stack||W.cause}`:""}
|
|
|
827
834
|
|
|
828
835
|
----------------------------------------------------------------------
|
|
829
836
|
|
|
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
|
|
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
|
|
837
|
+
`),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 pi.commitTransaction(),p?.advanceRollback&&await Oo.cleanup(f),await io()}yield{type:"status",content:null}},af=async(e,t,n=null,s=null,o=null,r=null,d=!1,a=null)=>{let m=await gi(),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
|
|
838
|
+
`,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 Ys(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&&Zs(),w="Run(command=string)",rn=`Runs ${et?ts()?"powershell":"windows CMD":"bash"} command`;W&&(w=`Run(command=string, ${er()||ts()?"forcePowershell?=bool:false":"forceCwd?=bool:false"})`,rn="Runs in git bash. Or force native shell");let an=`-- ACTIONS (path = relative to CWD, path separator: '/') --
|
|
832
839
|
In chat output the format \`[action:ActionName(arg1="value1")]\` in NEW line
|
|
833
840
|
Rules:
|
|
834
841
|
- Max ${process.env.MAX_TOOL_LIMIT||"3"} actions/turn
|
|
@@ -865,38 +872,38 @@ Main focus: actions and task, not chatting
|
|
|
865
872
|
On completion, provide a detailed summary in Tables/Markdown Format with file modified info. If any task failed report back in detail
|
|
866
873
|
|
|
867
874
|
Current Time: ${I}
|
|
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
|
|
869
|
-
${
|
|
870
|
-
`),wt.push({role:"agent",text:
|
|
875
|
+
=== 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 Qi("subagent",f);if(!we.allowed)throw new Error(we.reason||`Budget Exhausted for Provider (${f?.aiProvider||"Subagent"})`);if(xt){if(t?.taskId&&typeof Ht<"u"){let H=Ht.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 Ht<"u"){let H=Ht.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,Kt=Ne.includes(De)?De:"Low",qn=(await Ll(f,ve,te,ln,Kt)).text||"",Pn=ka(jt(qn).trim());To=Pn,r&&r(`[Subagent Response]
|
|
876
|
+
${Pn}
|
|
877
|
+
`),wt.push({role:"agent",text:Pn});let cn=Vn(Pn);if(cn.length===0)break;let dn=cn.filter(H=>H.toolName.toLowerCase()==="askmain"||H.toolName.toLowerCase()==="ask_main"),wn=!1,Vt="";for(let H of cn){if(xt){if(t?.taskId&&typeof Ht<"u"){let A=Ht.find(V=>V.id===t.taskId);A&&(A.status="cancelled")}throw new Error("Subagent task was cancelled.")}if(t?.taskId&&typeof Ht<"u"){let A=Ht.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
878
|
`),t.onAskMain){r&&r(`[Executing Tool] AskMain("${A}")...`);let V=await t.onAskMain(A);r&&r(`[Action Result]
|
|
872
879
|
Answer from Main Agent: ${V}
|
|
873
|
-
`),
|
|
880
|
+
`),Vt+=`[ACTION RESULT for AskMain]: Answer from Main Agent: ${V}
|
|
874
881
|
|
|
875
|
-
`,await Lt("toolSuccess")}else
|
|
882
|
+
`,await Lt("toolSuccess")}else Vt+=`[ACTION RESULT for AskMain]: ERROR: Main agent communication channel not available.
|
|
876
883
|
|
|
877
884
|
`;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
|
-
`),
|
|
885
|
+
`),Vt+=`${A}
|
|
879
886
|
|
|
880
887
|
`;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
|
-
`),
|
|
888
|
+
`),Vt+=`${tt}
|
|
882
889
|
|
|
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=
|
|
890
|
+
`;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=Ms[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 ks(H.toolName,H.args,{...t,mode:"Flux"});r&&r(`[Action Result]
|
|
884
891
|
${A}
|
|
885
892
|
`);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
893
|
`));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?`
|
|
887
894
|
|
|
888
|
-
${kt[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(rt)){let
|
|
895
|
+
${kt[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(rt)){let $n=rt.search(/^- Content Preview:/m);nt=`[ACTION RESULT]: ${$n!==-1?rt.slice(0,$n).trimEnd():rt}
|
|
889
896
|
|
|
890
|
-
[Old file content for reversal reference. Replaced with new write request]${kn}`}else{let
|
|
891
|
-
`)
|
|
897
|
+
[Old file content for reversal reference. Replaced with new write request]${kn}`}else{let $n=rt.split(/\r?\n/),at=$n.filter(lo=>lo.startsWith("File ")||lo.trim().startsWith("- Stats:"));nt=`[ACTION RESULT]: ${at.length>0?at.join(`
|
|
898
|
+
`):$n.slice(0,2).join(`
|
|
892
899
|
`)}${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
900
|
`):kt.slice(0,2).join(`
|
|
894
|
-
`)}`}else nt=`[ACTION RESULT]: ${tt}`;
|
|
901
|
+
`)}`}else nt=`[ACTION RESULT]: ${tt}`;Vt+=`${nt}
|
|
895
902
|
|
|
896
903
|
`,await Lt("toolSuccess")}catch(A){let V=`ERROR: Execution failed for [${H.toolName}]: ${A.message}`;r&&r(`[Tool Error] ${V}
|
|
897
|
-
`),
|
|
904
|
+
`),Vt+=`[ACTION RESULT]: ${V}
|
|
898
905
|
|
|
899
|
-
`,await Lt("toolFailure")}}let bn="";if(t?.taskId&&typeof
|
|
906
|
+
`,await Lt("toolFailure")}}let bn="";if(t?.taskId&&typeof Ht<"u"){let H=Ht.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+=`
|
|
900
907
|
|
|
901
|
-
[STEERING INSTRUCTION FROM MAIN AGENT]: ${Sn}`,r&&r(`[Subagent Steered] ${Sn}`)}}let Yn=(
|
|
902
|
-
`).trim();let dn=0,wn=0,
|
|
908
|
+
[STEERING INSTRUCTION FROM MAIN AGENT]: ${Sn}`,r&&r(`[Subagent Steered] ${Sn}`)}}let Yn=(Vt.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 Kt=De[1],Mn=De[2]||"",qn=De[3]||"",Pn=B.basename(Kt),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(`
|
|
909
|
+
`).trim();let dn=0,wn=0,Vt=qn.matchAll(/@@\s*([^@]+?)\s*@@/g);for(let nt of Vt){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(ci,"DiffBackups");xe.existsSync(H)||xe.mkdirSync(H,{recursive:!0});let D=String(Date.now()).slice(-5),Sn=Sa.randomBytes(2).toString("hex"),Ee=`${Pn}-diff-${D}-${Sn}.txt`,A=B.join(H,Ee);xe.writeFileSync(A,cn,"utf8");let V=`${ci.replaceAll("\\","/").replace(ba.homedir().replaceAll("\\","/"),"~")}/DiffBackups/${Ee}`,tt=Mn?` ${Mn} blocks.`:"";wt[we]={...te,text:`[ACTION RESULT]: Diff result ${Pn} 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,Mi as b,nd as c,od as d,xr as e,Ac as f,Cc as g,So as h,Rc as i,Si as j,ki as k,Gc as l,Hc as m,Cl as n,Zd as o,Rl as p,vl as q,Is as r,jt as s,Li as t,ka as u,ef as v,tf as w,nf as x,Ta as y,of as z,Oi as A,ha as B,Ml as C,Vn as D,sf as E,Ll as F,rf as G,af as H};
|