fluxflow-cli 4.37.3 → 4.38.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{9router-CKETGMBB.js → 9router-E4LQZ5XF.js} +1 -1
- package/dist/chunks/{addMemScore-76XLEW3K.js → addMemScore-PBVNSFPN.js} +1 -1
- package/dist/chunks/{ai-JI4UX2WD.js → ai-YQJYUPXQ.js} +1 -1
- package/dist/chunks/{aihubmix-YSGVPUM4.js → aihubmix-UBV5ARET.js} +1 -1
- package/dist/chunks/{apinex-VI576FVJ.js → apinex-L3Y6BP6J.js} +1 -1
- package/dist/chunks/{app-3NZMHG65.js → app-SIXVPE6Z.js} +5 -5
- package/dist/chunks/{chat-RLEHK3MX.js → chat-C7HYXKVZ.js} +1 -1
- package/dist/chunks/chunk-26BQ45XP.js +2 -0
- package/dist/chunks/{chunk-T4ZG2WCV.js → chunk-4BLSASW6.js} +1 -1
- package/dist/chunks/{chunk-QOT4BYHM.js → chunk-52STSLCN.js} +1 -1
- package/dist/chunks/{chunk-3JI2CRXK.js → chunk-6EYQQ7GQ.js} +1 -1
- package/dist/chunks/{chunk-HOZQBBAO.js → chunk-6H2P5XUL.js} +1 -1
- package/dist/chunks/{chunk-MJL6DHQM.js → chunk-77QN4HDY.js} +1 -1
- package/dist/chunks/{chunk-CBFC5KUU.js → chunk-CZK3QF2C.js} +1 -1
- package/dist/chunks/{chunk-2VV5ZE53.js → chunk-EYTM4NZD.js} +1 -1
- package/dist/chunks/{chunk-ET66XVIM.js → chunk-FXRFFNRK.js} +1 -1
- package/dist/chunks/{chunk-FAEB3V5R.js → chunk-HFTI3R3Q.js} +1 -1
- package/dist/chunks/{chunk-BTMPM5BT.js → chunk-IHDJDAG3.js} +1 -1
- package/dist/chunks/{chunk-FSE4BZZZ.js → chunk-IZQAF6KJ.js} +1 -1
- package/dist/chunks/{chunk-PRTGV2R4.js → chunk-KMOTPBF5.js} +1 -1
- package/dist/chunks/chunk-P5HBJA23.js +1 -0
- package/dist/chunks/{chunk-K4AZXTU6.js → chunk-QW6IGMYV.js} +1 -1
- package/dist/chunks/{chunk-M4GC3CRN.js → chunk-ZCXQPXVK.js} +171 -171
- package/dist/chunks/{click-B4ZRHV4Z.js → click-J7DMHVDU.js} +2 -2
- package/dist/chunks/{computer_action-2RYMIFAM.js → computer_action-D52LLX3E.js} +1 -1
- package/dist/chunks/{custom_openai-TLPPKENJ.js → custom_openai-S6YIOHQN.js} +1 -1
- package/dist/chunks/{deepseek-2GJCWFSR.js → deepseek-CQRKTOL6.js} +1 -1
- package/dist/chunks/{drag-RNGTIO2V.js → drag-CMUD2ZB5.js} +1 -1
- package/dist/chunks/{emergency_rollback-NXD2JKBG.js → emergency_rollback-ZHQXCIHW.js} +1 -1
- package/dist/chunks/{explabs-YICY4AMR.js → explabs-6TWS34VQ.js} +1 -1
- package/dist/chunks/{export-C6VVIYP5.js → export-RU6LCZUB.js} +1 -1
- package/dist/chunks/{file_map-T5FHB3F6.js → file_map-UA4BA5OH.js} +1 -1
- package/dist/chunks/{find_file-LZR7NET3.js → find_file-HYHHFHUJ.js} +1 -1
- package/dist/chunks/{generate_image-75IV5P3L.js → generate_image-5D57XGLP.js} +1 -1
- package/dist/chunks/{inferx-YMU7LMOQ.js → inferx-A42H43ZV.js} +1 -1
- package/dist/chunks/{infron-A4BOV2AA.js → infron-NZI2FQFA.js} +1 -1
- package/dist/chunks/{invoke-7JAD5QTF.js → invoke-4P5QQPCF.js} +2 -2
- package/dist/chunks/{invokeSync-WUKJNYGQ.js → invokeSync-BSFWXLD7.js} +2 -2
- package/dist/chunks/{key_press-3VU6SHNQ.js → key_press-LWJGR25H.js} +1 -1
- package/dist/chunks/{keyboard_typing-PCW3ISET.js → keyboard_typing-A72GI7EW.js} +1 -1
- package/dist/chunks/{memory-4DXO4K5C.js → memory-7YOYCOXE.js} +1 -1
- package/dist/chunks/{mistral-2CZKHKDT.js → mistral-OXTDZX3G.js} +1 -1
- package/dist/chunks/{model_config-VYWFV55M.js → model_config-32SB7PTZ.js} +1 -1
- package/dist/chunks/{nvidia-EOLGFGFZ.js → nvidia-5DDRU422.js} +1 -1
- package/dist/chunks/{ollama-OHD5BFI7.js → ollama-4PI2BDMM.js} +1 -1
- package/dist/chunks/{openrouter-SK7LO52I.js → openrouter-YU3RE7RH.js} +1 -1
- package/dist/chunks/{paths-EQFOJDZC.js → paths-RQRI2XRY.js} +1 -1
- package/dist/chunks/{poolside-SAAXTNGR.js → poolside-H2NCP5XT.js} +1 -1
- package/dist/chunks/{saveSummary-ZSJ2UKLG.js → saveSummary-W2JMDVZJ.js} +1 -1
- package/dist/chunks/{screen_grid-Z2S4GMN5.js → screen_grid-4Z2EBIB2.js} +1 -1
- package/dist/chunks/{scroll-YSFTTROP.js → scroll-LXQJ25NK.js} +1 -1
- package/dist/chunks/{search_keyword-SD6Q3UZE.js → search_keyword-ABVAWJKX.js} +1 -1
- package/dist/chunks/{secrets-GHW6AWRR.js → secrets-5TCTEPEV.js} +1 -1
- package/dist/chunks/{sensenova-MQKZ7TNO.js → sensenova-UT5CZFCW.js} +1 -1
- package/dist/chunks/settings-ZBXCJL25.js +1 -0
- package/dist/chunks/{todo-KQCKHQBJ.js → todo-CJLWLWJB.js} +1 -1
- package/dist/chunks/{tokenharbor-QL33UGF4.js → tokenharbor-S66MGK52.js} +1 -1
- package/dist/chunks/{update_file-OQMKLO6R.js → update_file-6F64CFSU.js} +1 -1
- package/dist/chunks/{usage-2WRVNL44.js → usage-WOYKJLZL.js} +1 -1
- package/dist/chunks/{usageServer-6XH36WK3.js → usageServer-3KLDOFIX.js} +1 -1
- package/dist/chunks/view_file-I77KYUO5.js +1 -0
- package/dist/chunks/{web_scrape-KBKSNVBI.js → web_scrape-MW6YSZ7L.js} +1 -1
- package/dist/chunks/{web_search-HACFAHXR.js → web_search-NT3HXUO3.js} +1 -1
- package/dist/chunks/{write_docx-M5RMUI4W.js → write_docx-E3MTFXTQ.js} +1 -1
- package/dist/chunks/{write_file-2ZFCDYSW.js → write_file-JDMRLJKT.js} +1 -1
- package/dist/chunks/{write_pdf-E5HQYOTR.js → write_pdf-26OQPNEP.js} +1 -1
- package/dist/cli.js +6 -6
- package/dist/package.json +1 -1
- package/flux-flow.cjs +17 -17
- package/package.json +1 -1
- package/dist/chunks/chunk-L3W2X74K.js +0 -1
- package/dist/chunks/chunk-M2ULCOL3.js +0 -2
- package/dist/chunks/settings-5R5ADGXX.js +0 -1
- package/dist/chunks/view_file-TZD6DAER.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as Cs}from"./chunk-HFTI3R3Q.js";import{a as wo}from"./chunk-52STSLCN.js";import{a as Kt}from"./chunk-56EJGQU3.js";import{c as Mi,g as Oi,h as ks,i as Ts}from"./chunk-EYTM4NZD.js";import{a as As,c as Es}from"./chunk-MQCO3GXM.js";import{a as Pi,g as Rs}from"./chunk-6H2P5XUL.js";import{a as vs}from"./chunk-4BLSASW6.js";import{a as Xo}from"./chunk-6EYQQ7GQ.js";import{a as W}from"./chunk-Y5JU726N.js";import{b as _i}from"./chunk-FXRFFNRK.js";import{f as xo,l as Rt,n as ut,p as Ii,q as Ss}from"./chunk-QW6IGMYV.js";import{a as bo}from"./chunk-IZQAF6KJ.js";import{l as st,m as qo,q as se}from"./chunk-KMOTPBF5.js";import{c as Ct,d as oo,e as zo}from"./chunk-P5HBJA23.js";import{a as $n,b as Ko,d as En,e as Vo,k as Yn,l as Yo,m as Ri,r as vi,w as po,x as yo,y as ws}from"./chunk-26BQ45XP.js";import{GoogleGenAI as Yr,ThinkingLevel as He,HarmBlockThreshold as Dn,HarmCategory as Fn}from"@google/genai";var _s=(e=!0,n=!0)=>`
|
|
2
2
|
To use tools, must output exactly '[action:ActionName(arg1="value1")]' structured string in chat response \u2190 no exception
|
|
3
3
|
|
|
4
4
|
-- Chat Management Tools --
|
|
@@ -25,7 +25,7 @@ Usage Rules:
|
|
|
25
25
|
- Chat title is mandatory
|
|
26
26
|
- Temporary memory is mandatory
|
|
27
27
|
- When called user memory, still use Temporary Memory
|
|
28
|
-
- Must not ignore any tool calls in given context of chat between user & agent`:""}`.trim();var
|
|
28
|
+
- Must not ignore any tool calls in given context of chat between user & agent`:""}`.trim();var Jo={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 on from"fs";import dn from"path";import wa from"os";import ln from"fs";import Nn from"path";import Gs from"fs";import Li from"path";import{execSync as Hs}from"child_process";import{fileURLToPath as xa}from"url";var Is=`# FluxFlow CLI Startup & Flags Reference
|
|
29
29
|
|
|
30
30
|
Launch command syntax:
|
|
31
31
|
fluxflow [options]
|
|
@@ -54,7 +54,7 @@ fluxflow [options]
|
|
|
54
54
|
* --help commands \u2192 In-chat slash commands list
|
|
55
55
|
* --playground \u2192 Launch Playground mode
|
|
56
56
|
* --prompt, -p \u2192 Non interactive CLI chat, no tools. --new for new headless chat. Holds conversation context upto 10m inactivity or 69 turns. Supports piping from shell, --run if want the command to visible in context. eg \`fluxflow --run "git diff" -p "summarize this" --new\`
|
|
57
|
-
`;var
|
|
57
|
+
`;var Ms=`# Env Variables
|
|
58
58
|
|
|
59
59
|
* Locations:
|
|
60
60
|
* Shell
|
|
@@ -84,7 +84,7 @@ fluxflow [options]
|
|
|
84
84
|
|
|
85
85
|
* I_HAVE_TOO_MUCH_MONEY \u2192 (true|false, default: false) Fun Flag; inserts random padding in system prompt to break provider caching. Not intended for paid APIs unless user hate money
|
|
86
86
|
* GOOGLE_GEMMA_NONSENSE \u2192 (true|false, default: false) for the 16k TPM nonsense of gemma models on gemini API. False defaults to 256k
|
|
87
|
-
`;var
|
|
87
|
+
`;var Os=`# Fluxflow in-app /commands
|
|
88
88
|
|
|
89
89
|
Trigger in chat via /command
|
|
90
90
|
|
|
@@ -132,7 +132,7 @@ Trigger in chat via /command
|
|
|
132
132
|
* /update latest \u2192 Install latest release
|
|
133
133
|
* /fluxflow global/saves \u2192 Openes fluxflow storage paths in explorer
|
|
134
134
|
* /move \u2192 Transfer Playground session data to CWD/playground-export
|
|
135
|
-
`;var
|
|
135
|
+
`;var Ps=`# FluxFlow In-App Settings Reference
|
|
136
136
|
|
|
137
137
|
Open in chat via /settings
|
|
138
138
|
|
|
@@ -197,7 +197,7 @@ Open in chat via /settings
|
|
|
197
197
|
- Best for Luxurious Experience: Subagents (on), compact large results (off), auto exclue metadata (off), Image History (Max), Keep reasoning content (on), Emergency Recovery (on), Auto truncate results (off), Memory (on), Security Preset (Autonomous), FluxFlow IDE Companion
|
|
198
198
|
|
|
199
199
|
- Max Cache Hit: Subagents (off), compact large results (on), auto exclue metadata (on), Image History (Low), Keep reasoning content (off), Emergency Recovery (off), Auto truncate results (off), Memory (off), No FluxFlow IDE Companion
|
|
200
|
-
`;var
|
|
200
|
+
`;var Ls=`# FluxFlow Tool Reference
|
|
201
201
|
|
|
202
202
|
## Protocol: [action:ActionName(arg1="val")]
|
|
203
203
|
|
|
@@ -238,7 +238,7 @@ Open in chat via /settings
|
|
|
238
238
|
* KeyboardTyping(text, autoPressEnter?) \u2192 Type string
|
|
239
239
|
* KeyPress(key) \u2192 Key/combo dispatch ("ctrl;c", "enter", etc.)
|
|
240
240
|
* RecaptureScreen() \u2192 Fresh screenshot + coordinate grid
|
|
241
|
-
`;var
|
|
241
|
+
`;var $s=`# Fluxflow Architecture
|
|
242
242
|
|
|
243
243
|
## 1. Terminal Engine
|
|
244
244
|
* Framework: React + Ink terminal UI
|
|
@@ -268,7 +268,7 @@ Open in chat via /settings
|
|
|
268
268
|
## 6. IDE Bridge
|
|
269
269
|
* Protocol: WebSocket on ws://localhost:56832
|
|
270
270
|
* State Sync: Focused file, open tabs, cursor line, selection, diagnostics
|
|
271
|
-
`;var
|
|
271
|
+
`;var Ns=`# FluxFlow Sub-Agents & Multi-Agent Architecture
|
|
272
272
|
|
|
273
273
|
## Execution Modes
|
|
274
274
|
* InvokeSync \u2192 Synchronous blocking delegation; main agent halts until sub-agent finishes task
|
|
@@ -299,7 +299,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
|
|
|
299
299
|
* SUBAGENT_MODEL \u2192 Target model override
|
|
300
300
|
* SUBAGENT_PROVIDER \u2192 Target provider override
|
|
301
301
|
* Setting SubAgentModel=ENV in settings pulls directly from environment overrides
|
|
302
|
-
`;var
|
|
302
|
+
`;var Ds=`# FluxFlow Security, Sandboxing & Safety
|
|
303
303
|
|
|
304
304
|
## Human-in-the-Loop Governance
|
|
305
305
|
* Execution Approval Gate \u2192 Destructive commands and high-risk file modifications require explicit user authorization (Allow / Deny)
|
|
@@ -322,7 +322,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
|
|
|
322
322
|
* Emergency Rollback \u2192 Automatic pre-turn file snapshots; Agent can still fix it (default: OFF) \u2192 references/SETTINGS.md
|
|
323
323
|
* Git-less Checkpoint Reversion \u2192 Trigger conversational changes rollback via double-ESC
|
|
324
324
|
* External Sanctuary Redirection \u2192 Move ~/.fluxflow data sanctuary (chats, keys etc)
|
|
325
|
-
`;var
|
|
325
|
+
`;var Fs=`# Fluxflow IDE Companion
|
|
326
326
|
|
|
327
327
|
## WebSocket Bridge Protocol
|
|
328
328
|
* Local Bridge \u2192 Runs on ws://localhost:56832 connecting FluxFlow CLI with the companion editor extension
|
|
@@ -340,7 +340,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
|
|
|
340
340
|
* File Focus \u2192 Automatically opens edited files in active IDE window
|
|
341
341
|
* Diff Preview \u2192 Streams side-by-side or inline diff highlights (showDiff, highlightDiff) directly in editor
|
|
342
342
|
* Status Bar Sync \u2192 Real-time agent status (thinking, running tool, awaiting input) reflected in IDE status bar
|
|
343
|
-
`;var
|
|
343
|
+
`;var Bs=`# Fluxflow Modes
|
|
344
344
|
|
|
345
345
|
## Modes Overview (TAB to cycle)
|
|
346
346
|
* [Flux] (Workspace / Dev) \u2192 Primary coding & workspace agent
|
|
@@ -358,7 +358,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
|
|
|
358
358
|
* User Inquiry: AskUser \u2192 [Universal]
|
|
359
359
|
* Document Creation: WritePDF, WriteDoc \u2192 [Flow]
|
|
360
360
|
* GUI & Desktop Automation: Click, Scroll, KeyboardTyping, KeyPress, RecaptureScreen \u2192 [ICU] | [FluxCU]
|
|
361
|
-
`;var
|
|
361
|
+
`;var Us=`# FluxFlow AI Providers & Setup
|
|
362
362
|
|
|
363
363
|
## Supported Providers
|
|
364
364
|
* Gemini | NVIDIA NIM | DeepSeek | Mistral | Ollama Local/Cloud | InferX | SenseNova | Poolside | OpenRouter | AIHubMix | Experiential Labs | TokenHarbor | APInex | Infron
|
|
@@ -396,7 +396,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
|
|
|
396
396
|
2. Set ENV ENABLE_9ROUTER=true
|
|
397
397
|
* 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
|
|
398
398
|
* NINEROUTER_KEY = If any needed
|
|
399
|
-
`;var
|
|
399
|
+
`;var Ws=`# Fluxflow Instructions & Skills System
|
|
400
400
|
|
|
401
401
|
## 1. Instructions (AGENTS.md / FLUXFLOW.md root only)
|
|
402
402
|
* Locations:
|
|
@@ -440,14 +440,14 @@ Instruction for this model ID across all providers.
|
|
|
440
440
|
|
|
441
441
|
* On-Demand Reference System:
|
|
442
442
|
* Reference: Offload deep/contexual specs to **/{SKILL.md,skill-reference-folder/*.md} & reference in SKILL.md. Saves tokens
|
|
443
|
-
`;var
|
|
443
|
+
`;var Qo="v4";try{let e=Li.dirname(xa(import.meta.url)),n=[Li.join(e,"../../package.json"),Li.join(e,"../package.json")],t=!1;for(let i of n)if(Gs.existsSync(i)){let o=JSON.parse(Gs.readFileSync(i,"utf8"));if(o.version){Qo=o.version,t=!0;break}}if(!t)try{let i=Hs("fluxflow -v",{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"],timeout:2e3}).trim();i&&(i.startsWith("v")||/^\d+\.\d+/.test(i))&&(Qo=i,t=!0)}catch{}if(!t)try{let i=Hs("curl -s --max-time 3 https://raw.githubusercontent.com/KushalRoyChowdhury/fluxflow-cli/main/package.json",{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"]}),o=JSON.parse(i);o.version&&(Qo=o.version)}catch{}}catch{}var $i={"SKILL.md":`---
|
|
444
444
|
name: fluxflow
|
|
445
445
|
description: System Generated Documentation. Read this if asked anything regarding FluxFlow Harness
|
|
446
446
|
---
|
|
447
447
|
|
|
448
448
|
# FluxFlow, by Kushal Roy Chowdhury
|
|
449
449
|
Open Source Terminal AI Assistant
|
|
450
|
-
App Version: ${
|
|
450
|
+
App Version: ${Qo}. Check Updates: fluxflow --update check. Update: fluxflow --update
|
|
451
451
|
GitHub: https://github.com/KushalRoyChowdhury/fluxflow-cli
|
|
452
452
|
Public Docs: https://fluxflow-cli.onrender.com
|
|
453
453
|
|
|
@@ -467,24 +467,24 @@ Public Docs: https://fluxflow-cli.onrender.com
|
|
|
467
467
|
|
|
468
468
|
Default Context Length: 256k Tokens. Can be changed via ENV/In-app Settings \u2192 references/{SETTINGS,ENV}.md
|
|
469
469
|
|
|
470
|
-
Docs missing required info? Say you are not sure enough to answer. Dont give wrong info`,"references/MODES.md":
|
|
471
|
-
`,m=null;
|
|
472
|
-
`)},
|
|
473
|
-
${
|
|
470
|
+
Docs missing required info? Say you are not sure enough to answer. Dont give wrong info`,"references/MODES.md":Bs,"references/PROVIDERS.md":Us,"references/PLUGINS.md":Ws,"references/STARTUP.md":Is,"references/ENV.md":Ms,"references/COMMANDS.md":Os,"references/SETTINGS.md":Ps,"references/TOOLS.md":Ls,"references/ARCHITECTURE.md":$s,"references/SUB_AGENTS.md":Ns,"references/SECURITY.md":Ds,"references/IDE.md":Fs};var js=()=>{try{let e=Nn.join($n,"skills","fluxflow"),n=Nn.join(e,"references");if(process.env.NO_DEV==="true"||process.env.NO_DEV==="1"||process.env.NO_DEV===!0||process.env.NO_INS==="true"||process.env.NO_INS==="1"||process.env.NO_INS==="true"||!1){ln.existsSync(e)&&ln.rmSync(e,{recursive:!0,force:!0});return}let i=new Set(Object.keys($i).map(o=>Nn.normalize(o)));for(let[o,r]of Object.entries($i)){let d=Nn.join(e,o),a=Nn.dirname(d);ln.existsSync(a)||ln.mkdirSync(a,{recursive:!0});let u=r.trim()+`
|
|
471
|
+
`,m=null;ln.existsSync(d)&&(m=ln.readFileSync(d,"utf8")),m!==u&&ln.writeFileSync(d,u,"utf8")}if(ln.existsSync(n)){let o=ln.readdirSync(n);for(let r of o){let d=Nn.normalize(Nn.join("references",r));if(!i.has(d)){let a=Nn.join(n,r);try{ln.rmSync(a,{recursive:!0,force:!0})}catch{}}}}}catch{}};var Ro=(e,n)=>{try{if(!on.existsSync(e))return null;let t=Array.isArray(n)?n.map(o=>o.toLowerCase()):[n.toLowerCase()],i=on.readdirSync(e);for(let o of t){let r=i.find(d=>d.toLowerCase()===o);if(r){let d=dn.join(e,r);if(on.statSync(d).isFile())return d}}}catch{}return null},Ui=(e,n)=>{let t=Ro(e,n);if(t)try{return on.readFileSync(t,"utf8")}catch{}return""},Ks=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"]),Wi=(e=process.cwd(),n=0,t=8)=>{let i=[];if(n>t)return i;try{if(!on.existsSync(e))return i;let o=on.readdirSync(e,{withFileTypes:!0});for(let r of o){let d=r.name,a=dn.join(e,d);if(r.isDirectory())!Ks.has(d)&&!Ks.has(d.toLowerCase())&&i.push(...Wi(a,n+1,t));else if(r.isFile()){let u=d.toLowerCase();(u==="agents.md"||u==="agent.md")&&i.push(a)}}}catch{}return i},Vs=(e,n=2)=>{if(!e)return"";let t=" ".repeat(n);return e.split(/\r?\n/).map(i=>t+i).join(`
|
|
472
|
+
`)},Js=()=>Ro($n,["agents.md","agent.md"]),Qs=()=>Ro(process.cwd(),["agents.md","agent.md"]),Zs=()=>Ro($n,["fluxflow.md"]),er=()=>Ro(process.cwd(),["fluxflow.md"]),ko=Js(),Zo=Qs(),cn=Wi(),To=Zs(),Ao=er(),Ys=null,Bi="",tr=!1,Sa=e=>{if(!e||!/^<<<[\s\S]*?Identity:/m.test(e))return e;let n=e.match(/^<<<\s*\r?\n([\s\S]*?)\r?\n>>>\s*(?:\r?\n)?([\s\S]*)$/);if(!n)return e;let t=n[1],i=n[2],o=t.match(/^Identity:\s*([\s\S]*?)(?=\r?\n\s*(?:<><|>>>)|$)/m);return o&&(Bi=o[1].trim(),process.env.NO_INS=!0),/<><\s*NO_INS/.test(t)&&(tr=!0),i.trim()},ka=()=>{ko=Js();let e=ko?Ui($n,["agents.md","agent.md"]).trim():"";return e.length===0?(ko=null,""):e},Ta=()=>{if(cn=Wi(),Zo=Qs(),!cn||cn.length===0)return"";let e=process.cwd(),n=[...cn].sort((o,r)=>{let d=dn.relative(e,o).replace(/\\/g,"/"),a=dn.relative(e,r).replace(/\\/g,"/"),u=!d.includes("/"),m=!a.includes("/");return u&&!m?-1:!u&&m?1:d.localeCompare(a)}),t=[],i=[];for(let o of n)try{let r=on.readFileSync(o,"utf8").trim();if(!r||r.length===0)continue;t.push(o);let d=dn.relative(e,o).replace(/\\/g,"/");if(!d.includes("/"))i.push(Vs(r,2));else{let u=dn.dirname(d)+"/:";i.push(`${u}
|
|
473
|
+
${Vs(r,2)}`)}}catch{}return cn=t,cn.length===0&&(Zo=null),i.join(`
|
|
474
474
|
|
|
475
|
-
`).trim()},
|
|
475
|
+
`).trim()},Gi=()=>{To=Zs();let e=To?Ui($n,["fluxflow.md"]).trim():"",n=Sa(e)?.trim()||"";return n.length===0?(To=null,""):n},Hi=()=>{Ao=er();let e=Ao?Ui(process.cwd(),["fluxflow.md"]).trim():"";return e.length===0?(Ao=null,""):e},ji=ka(),ei=Ta(),Eo=Gi(),Co=Hi(),zs=(e,n="",t="")=>{if(!e)return"";let i=t.toLowerCase().trim(),o=n.toLowerCase().trim(),r=dn.posix.basename(o),d=i&&o?`${i}@${o}`:"",a=i&&r?`${i}@${r}`:"",u=b=>!b||!o?!1:b===o||b===r||b===d||b===a,m=[];return e.replace(/<start_provider_([^>\r\n]+)>([\s\S]*?)<end_provider_([^>\r\n]+)>/gi,(b,h,f,s)=>{if(i&&h.trim().toLowerCase()===s.trim().toLowerCase()&&h.trim().toLowerCase()===i){let T=f.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(ue,y,R,F)=>{if(y.trim().toLowerCase()===F.trim().toLowerCase()){let j=y.trim().toLowerCase();if(u(j)){let $=R.trim();$&&m.push($)}}return""}).trim();T&&m.push(T)}return""}),e.replace(/<start_model_([^>\r\n@]+@[^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n@]+@[^>\r\n]+)>/gi,(b,h,f,s)=>{if(h.trim().toLowerCase()===s.trim().toLowerCase()){let g=h.trim().toLowerCase();if(u(g)){let T=f.trim();T&&m.push(T)}}return""}),e.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(b,h,f,s)=>{if(h.includes("@"))return"";if(h.trim().toLowerCase()===s.trim().toLowerCase()){let g=h.trim().toLowerCase();if(o&&(g===o||g===r)){let T=f.trim();T&&m.push(T)}}return""}),m.join(`
|
|
476
476
|
|
|
477
|
-
`).trim()},
|
|
478
|
-
`),
|
|
477
|
+
`).trim()},Aa=(e="",n="")=>{let t=`${e||""}@${n||""}`.toLowerCase().trim();Ys!==t&&(Ys=t,Eo=Gi(),Co=Hi())};js();var Ea=e=>{if(!e)return null;let n=e.match(/^\s*---\r?\n([\s\S]*?)\r?\n---(?:\r?\n)?([\s\S]*)$/);if(!n)return null;let t=n[1];if((n[2]||"").trim().length===0)return null;let o="",r="",d=t.match(/^name:\s*(.+)$/m),a=t.match(/^description:\s*(.+)$/m);return d&&(o=d[1].trim().replace(/^["']|["']$/g,"")),a&&(r=a[1].trim().replace(/^["']|["']$/g,"")),o&&r?{name:o,description:r}:null},Ca=e=>{let n=[];if(!e||!on.existsSync(e))return n;let t=(i,o=0)=>{if(!(o>5))try{let r=on.readdirSync(i,{withFileTypes:!0});for(let d of r){let a=dn.join(i,d.name),u=d.name.toLowerCase();d.isFile()?u==="skill.md"&&n.push(a):d.isDirectory()&&(o===0?(u==="skills"||u===".skills"||u==="skill"||u===".skill")&&t(a,o+1):t(a,o+1))}}catch{}};return t(e,0),n},nr=e=>{let n=Ca(e),t=[];for(let i of n)try{let o=on.readFileSync(i,"utf8"),r=Ea(o);r&&t.push({...r,filePath:i})}catch{}return t},or=e=>!e||e.length===0?"":e.map(n=>`- ${n.name}: ${n.description}`).join(`
|
|
478
|
+
`),ir=nr($n),sr=nr(process.cwd()),Ni=or(ir),Di=or(sr),rr=e=>{if(!e)return!1;let n=(e.filePath||"").replace(/\\/g,"/").toLowerCase();return n.includes("/skills/fluxflow/skill.md")||n.includes("/skills/about-fluxflow/skill.md")||e.name?.toLowerCase()==="fluxflow"},ar=()=>(ir||[]).filter(e=>!rr(e)),lr=()=>(sr||[]).filter(e=>!rr(e)),lc=(ji?.length>0?1:0)+(ei?.length>0?cn.length:0)+(Eo?.length>0?1:0)+(Co?.length>0?1:0)+ar().length+lr().length,Fi=(e,n="Project")=>{if(!e)return"";let t=e.replace(/\\/g,"/");if(n==="Global"){let o=wa.homedir().replace(/\\/g,"/");return t.toLowerCase().startsWith(o.toLowerCase())?"~"+t.slice(o.length):t}let i=dn.relative(process.cwd(),e).replace(/\\/g,"/");return i.startsWith(".")?i:`./${i}`},cc=()=>{Eo=Gi(),Co=Hi();let e=[];ko&&ji.length>0&&e.push({scope:"Global",path:ko}),cn&&cn.length>0&&ei.length>0?cn.forEach(r=>{e.push({scope:"Project",path:r})}):Zo&&ei.length>0&&e.push({scope:"Project",path:Zo}),To&&Eo.length>0&&e.push({scope:"Global",path:To}),Ao&&Co.length>0&&e.push({scope:"Project",path:Ao});let n=ar(),t=lr(),i=e.length+n.length+t.length;if(i===0)return`\u2726 Loaded Files & Instructions
|
|
479
479
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No instruction or skill files are currently loaded.
|
|
480
480
|
\u2800`;let o=[];return o.push(`\u2726 Loaded Files & Instructions (${i} ${i===1?"file":"files"} active)`),e.length>0&&(o.push(`
|
|
481
|
-
\x1B[1mInstructions:\x1B[22m`),e.forEach(r=>{o.push(` \u2022 [${r.scope}] ${
|
|
482
|
-
\x1B[1mSkills:\x1B[22m`),n?.length>0&&n.forEach(r=>{o.push(` \u2022 [Global] \x1B[36m${r.name}\x1B[39m`),o.push(` \x1B[2m\u2514\u2500 ${
|
|
483
|
-
`)},
|
|
484
|
-
`):
|
|
481
|
+
\x1B[1mInstructions:\x1B[22m`),e.forEach(r=>{o.push(` \u2022 [${r.scope}] ${Fi(r.path,r.scope)}`)})),(n?.length>0||t?.length>0)&&(o.push(`
|
|
482
|
+
\x1B[1mSkills:\x1B[22m`),n?.length>0&&n.forEach(r=>{o.push(` \u2022 [Global] \x1B[36m${r.name}\x1B[39m`),o.push(` \x1B[2m\u2514\u2500 ${Fi(r.filePath,"Global")}\x1B[22m`)}),t?.length>0&&t.forEach(r=>{o.push(` \u2022 [Project] \x1B[36m${r.name}\x1B[39m`),o.push(` \x1B[2m\u2514\u2500 ${Fi(r.filePath,"Project")}\x1B[22m`)})),o.push("\u2800"),o.join(`
|
|
483
|
+
`)},cr=!1;(async()=>{try{let e=await bo();if(Number(e?.display)===1){let{default:n}=await import("screenshot-desktop"),t=await n.listDisplays();t&&t.length>1&&(cr=!0)}}catch{}})();var qs=null,So=null,Xs=process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux",dc=process.env.NO_DEV||!1,Ra=(e,n)=>{if(!n)return"";if(e!==qs||So===null){qs=e;try{let t=Ct(Yn,[]);Array.isArray(t)&&t.length>0?So=t.map(i=>`- ${i.memory}`).join(`
|
|
484
|
+
`):So=""}catch(t){So="",on.appendFileSync(`${En}/memory/error.txt`,`${t.message}
|
|
485
485
|
-------------------------------------------------
|
|
486
486
|
|
|
487
|
-
`)}}return
|
|
487
|
+
`)}}return So};var dr=(e,n,t,i,o=!0,r=!1,d="Google",a=!1,u,m,b=!1,h="")=>{let f=!1;process.env.forcedReasoning&&(f=!0);let s="";if(!u&&d==="Google"){let Le=n;n==="Fast"&&(Le="Off"),n==="Low"&&(Le="Minimal"),n==="Standard"&&(Le="Medium"),(n==="xHigh"||n==="Max")&&(Le="xHigh"),s=Jo[Le]||Jo.Medium}(u||d!=="Google")&&(s=Jo.xHigh,n==="Fast"?s=`No thinking. Immediate response
|
|
488
488
|
Verify imports, tool results & system stability`:n.toLowerCase()==="max"&&(s=`Effort: Max
|
|
489
489
|
Plan step by step`));let g=e.instructions&&e.instructions?.length>0?`User Preferences: ${e.instructions}
|
|
490
490
|
|
|
@@ -492,28 +492,28 @@ Plan step by step`));let g=e.instructions&&e.instructions?.length>0?`User Prefer
|
|
|
492
492
|
${g.length?"":`
|
|
493
493
|
`}`:"",ue=e.name&&e.name?.length>0?`User Name: ${e.name}
|
|
494
494
|
${T.length||g.length?"":`
|
|
495
|
-
`}`:"",y=process.cwd(),R=
|
|
495
|
+
`}`:"",y=process.cwd(),R=Ra(m,o),F=R?.length>0?`--- Saved Memories ---
|
|
496
496
|
${R}
|
|
497
497
|
|
|
498
|
-
`:"";
|
|
498
|
+
`:"";Aa(d,h);let j=zs(Eo,h,d).trim(),A=[ji,j].filter(Le=>Le&&Le.length>0).join(`
|
|
499
499
|
|
|
500
|
-
`).trim(),he=
|
|
500
|
+
`).trim(),he=zs(Co,h,d).trim(),Ie=[ei,he].filter(Le=>Le&&Le.length>0).join(`
|
|
501
501
|
|
|
502
|
-
`).trim(),xe=A.length>0||
|
|
502
|
+
`).trim(),xe=A.length>0||Ie.length>0?`--- Additional Instructions ---
|
|
503
503
|
${A.length>0?`-- Global --
|
|
504
|
-
${A}`:""}${
|
|
504
|
+
${A}`:""}${Ie.length>0?`${A.length>0?`
|
|
505
505
|
|
|
506
506
|
`:""}-- Project --
|
|
507
|
-
${
|
|
507
|
+
${Ie}`:""}
|
|
508
508
|
|
|
509
|
-
`:"",k=(()=>{let Le=process.cwd().toLowerCase();if(process.platform==="win32"){let S=process.env.SystemRoot?.toLowerCase()||"c:\\windows",E=process.env.ProgramFiles?.toLowerCase()||"c:\\program files",$e=process.env["ProgramFiles(x86)"]?.toLowerCase()||"c:\\program files (x86)";return Le.startsWith(S)||Le.startsWith(E)||Le.startsWith($e)}else return Le==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(E=>Le.startsWith(E))})(),x=new Date,rt=x.getFullYear(),ve=x.toLocaleString("en-US",{month:"short"}).toUpperCase(),
|
|
510
|
-
${`Identity: ${
|
|
511
|
-
${
|
|
509
|
+
`:"",k=(()=>{let Le=process.cwd().toLowerCase();if(process.platform==="win32"){let S=process.env.SystemRoot?.toLowerCase()||"c:\\windows",E=process.env.ProgramFiles?.toLowerCase()||"c:\\program files",$e=process.env["ProgramFiles(x86)"]?.toLowerCase()||"c:\\program files (x86)";return Le.startsWith(S)||Le.startsWith(E)||Le.startsWith($e)}else return Le==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(E=>Le.startsWith(E))})(),x=new Date,rt=x.getFullYear(),ve=x.toLocaleString("en-US",{month:"short"}).toUpperCase(),It=String(x.getDate()).padStart(2,"0"),fn=`${rt}-${ve}-${It}`,Mt=process.env.I_HAVE_TOO_MUCH_MONEY==="true"||!1,Vt=process.env.HALLOWEEN_EEGG==="true"||!1,un=Vt&&ve.includes("OCT")&&(It.includes("30")||It.includes("31")),gn=(h||"").replace(/^.*::/,"").split(":")[0].replace(/\/free$/,"").trim(),Bt=dn.basename(gn).replace(/-free$/,"").replace(/_free$/,"").replace(/^free_/,"").replaceAll("-"," ").replaceAll("_"," ").replace(/\b\w/g,Le=>Le.toUpperCase().trim()),ht=process.env.NO_DEV==="true"||!1;return`${Mt?`${" ".repeat(Math.floor(Math.random()*4)+1)}`:""}=== SYSTEM PROMPT ===
|
|
510
|
+
${`Identity: ${Bi.length>1?Bi.trim():`Flux Flow. Sassy, CLI Assistant${Vt?`. ${un?"Peak ":""}Halloween Themed, Spooky`:""}`}
|
|
511
|
+
${tr?"":`${t==="Flux"?"":t==="Flow"?"Concise, Humorous, Sarcastic":t==="ICU"?"Computer Use Capabilities. Screenshot as ground truth, analyze grid ids of target. Keyboard shortcuts > mouse clicks":"Computer Use & Workspace Capabilities. Screenshot as ground truth, analyze grid ids of target. Keyboard shortcuts > mouse clicks. Workspace Actions when faster. Focus on Productivity"}`}${cr&&t.toLowerCase().includes("cu")?`
|
|
512
512
|
- 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()}
|
|
513
513
|
|
|
514
|
-
- OS: ${
|
|
514
|
+
- OS: ${Xs}${!ht&&h.length>1?`
|
|
515
515
|
- Model: ${Bt}`.trimEnd():""}
|
|
516
|
-
- Date: ${
|
|
516
|
+
- Date: ${fn}
|
|
517
517
|
|
|
518
518
|
-- REASONING GUIDANCE --
|
|
519
519
|
${d==="Mistral"||d==="Google"&&!u||f?`${s.trimEnd()}${f||n!=="Fast"&&(d==="Mistral"&&n==="Low"&&!u||n!=="High"&&!u)?`
|
|
@@ -521,21 +521,21 @@ Critical Thinking Policy
|
|
|
521
521
|
Use <think>...</think> for reasoning before responding any queries`:""}`:`${s.trimEnd()}`}${b?"":`
|
|
522
522
|
Before actions, provide user facing summary of findings & decisions IN detail for next turn
|
|
523
523
|
`}
|
|
524
|
-
${
|
|
524
|
+
${Es(t,Xs,a,d,i?.advanceRollback,i?.subAgents!==!1,!!i?.autoExec,!!i?.disableTodo)}${t==="Flux"?"":t.toLowerCase().includes("cu")?`
|
|
525
525
|
|
|
526
526
|
-- SECURITY POLICIES --
|
|
527
527
|
- Dont operate on ANY confidential screens/captcha \u2192 AskUser`:""}
|
|
528
|
-
=== END SYSTEM PROMPT ===${(
|
|
528
|
+
=== END SYSTEM PROMPT ===${(Ni.length>0||Di.length>0)&&t.toLowerCase().includes("flux")?`
|
|
529
529
|
|
|
530
530
|
- Read relevant skills before tasks, scope: global/project: Use ReadFile, path="#skills/scope?/skillName". In-skill references: path="#skills/scope?/skillName/reference-folder/*.md"`:""}
|
|
531
531
|
|
|
532
|
-
${T}${g}${xe}${
|
|
533
|
-
${
|
|
532
|
+
${T}${g}${xe}${Ni.length>0&&t.toLowerCase().includes("flux")?`-- Global Skills --
|
|
533
|
+
${Ni}
|
|
534
534
|
|
|
535
|
-
`:""}${
|
|
536
|
-
${
|
|
535
|
+
`:""}${Di.length>0&&t.toLowerCase().includes("flux")?`-- Project Skills --
|
|
536
|
+
${Di}
|
|
537
537
|
|
|
538
|
-
`:""}${F}`.trim()},
|
|
538
|
+
`:""}${F}`.trim()},fr=(e="",n=!0,t=!0)=>`=== SYSTEM PROMPT (strict headless logic worker: zero user-facing text policy, strictly follow) ===
|
|
539
539
|
identity: silent background system process, have no mouth, only output is valid tool calls
|
|
540
540
|
[critical rules]
|
|
541
541
|
- output exactly '[action:ActionName(args)]' calls. no extra words outside
|
|
@@ -552,11 +552,11 @@ identity: silent background system process, have no mouth, only output is valid
|
|
|
552
552
|
YOUR JOB: Analyze the 'User prompt' and 'Agent Raws' to extract facts for long-term memory or handle system tasks
|
|
553
553
|
${n?"If user tell something that is important (like, hobbies, preferences, facts about user, hates, likes, etc) to know user better over time, use user memory tools":""}
|
|
554
554
|
|
|
555
|
-
${
|
|
555
|
+
${_s(n,t)}
|
|
556
556
|
=== END SYSTEM PROMPT ===${e?`
|
|
557
557
|
|
|
558
558
|
-- current saved user memories --
|
|
559
|
-
${e}`:""}`.trim();var ar=()=>import("./web_search-HACFAHXR.js").then(e=>e.web_search),lr=()=>import("./web_scrape-KBKSNVBI.js").then(e=>e.web_scrape),cr=()=>import("./memory-4DXO4K5C.js").then(e=>e.memory),dr=()=>import("./chat-RLEHK3MX.js").then(e=>e.chat),fr=()=>import("./view_file-TZD6DAER.js").then(e=>e.view_file),ur=()=>import("./write_file-2ZFCDYSW.js").then(e=>e.write_file),gr=()=>import("./update_file-OQMKLO6R.js").then(e=>e.update_file),hr=()=>import("./exec_command-A5JWE55Q.js").then(e=>e.exec_command),mr=()=>import("./read_folder-EI2CNHNS.js").then(e=>e.read_folder),Ui=()=>import("./ask_user-K2DLZF6H.js").then(e=>e.ask_user),pr=()=>import("./write_pdf-E5HQYOTR.js").then(e=>e.write_pdf),yr=()=>import("./write_docx-M5RMUI4W.js").then(e=>e.write_docx),Jo=()=>import("./search_keyword-SD6Q3UZE.js").then(e=>e.search_keyword),br=()=>import("./generate_image-75IV5P3L.js").then(e=>e.generate_image),Qo=()=>import("./saveSummary-ZSJ2UKLG.js").then(e=>e.saveSummary),Co=()=>import("./addMemScore-76XLEW3K.js").then(e=>e.addMemScore),xr=()=>import("./file_map-T5FHB3F6.js").then(e=>e.file_map),Zo=()=>import("./todo-KQCKHQBJ.js").then(e=>e.todo),wr=()=>import("./invokeSync-WUKJNYGQ.js").then(e=>e.invokeSync),Sa=()=>import("./invoke-7JAD5QTF.js").then(e=>e.invoke),Sr=()=>import("./getProgress-A2TW34Q7.js").then(e=>e.getProgress),ka=()=>import("./cancel-F3ZOEBKW.js").then(e=>e.cancel),kr=()=>import("./emergency_rollback-NXD2JKBG.js").then(e=>e.emergency_rollback),Ro=()=>import("./awaitSubagent-JKQ2EHVY.js").then(e=>e.awaitSubagent),vo=()=>import("./answerSubagent-BPNNJXPC.js").then(e=>e.answerSubagent),ei=()=>import("./steerSubagent-UETXH2CB.js").then(e=>e.steerSubagent),ti=()=>import("./computer_action-2RYMIFAM.js").then(e=>e.computer_action),Tr=()=>import("./click-B4ZRHV4Z.js").then(e=>e.click),Ar=()=>import("./drag-RNGTIO2V.js").then(e=>e.drag),Er=()=>import("./scroll-YSFTTROP.js").then(e=>e.scroll),Wi=()=>import("./keyboard_typing-PCW3ISET.js").then(e=>e.keyboard_typing),Gi=()=>import("./key_press-3VU6SHNQ.js").then(e=>e.key_press),Hi=()=>import("./recapture_screen-PPT2E3CK.js").then(e=>e.recapture_screen),ni=()=>import("./find_file-LZR7NET3.js").then(e=>e.find_file),Cr=()=>import("./wait-TJR6LAR4.js").then(e=>e.wait),Rr={web_search:ar,web_scrape:lr,memory:cr,chat:dr,view_file:fr,write_file:ur,update_file:gr,exec_command:hr,read_folder:mr,write_pdf:pr,write_docx:yr,search_keyword:Jo,generate_image:br,saveSummary:Qo,addMemScore:Co,file_map:xr,todo:Zo,Todo:Zo,goal:Zo,Goal:Zo,invokeSync:wr,invoke:Sa,getProgress:Sr,cancel:ka,awaitSubagent:Ro,answerSubagent:vo,steerSubagent:ei,computer_action:ti,computer_use:ti,ComputerAction:ti,ComputerUse:ti,click:Tr,Click:Tr,drag:Ar,Drag:Ar,scroll:Er,Scroll:Er,keyboard_typing:Wi,KeyboardTyping:Wi,keyboardtyping:Wi,key_press:Gi,KeyPress:Gi,keypress:Gi,recapture_screen:Hi,RecaptureScreen:Hi,recapturescreen:Hi,invoke_sync:wr,get_progress:Sr,await_subagent:Ro,answer_subagent:vo,steer_subagent:ei,steer:ei,Steer:ei,ask:Ui,Ask:Ui,AskUser:Ui,WebSearch:ar,WebScrape:lr,ReadFile:fr,ReadFolder:mr,WriteFile:ur,PatchFile:gr,WritePDF:pr,WriteDoc:yr,Run:hr,SearchKeyword:Jo,CodeSearch:Jo,code_search:Jo,Memory:cr,Chat:dr,GenerateImage:br,saveSumary:Qo,SaveSummary:Qo,SaveSumary:Qo,add_mem_score:Co,AddMemScore:Co,addMemoryScore:Co,AddMemoryScore:Co,FileMap:xr,answer:vo,Answer:vo,AnswerSubagent:vo,await:Ro,Await:Ro,AwaitSubagent:Ro,EmergencyRollback:kr,emergency_rollback:kr,find_file:ni,findFile:ni,FindFile:ni,findfile:ni,wait:Cr,Wait:Cr},_o=async(e,n,t={})=>{let i=t.mode?t.mode.toLowerCase():"flux",o=e.toLowerCase(),d=["memory","chat","savesummary","addmemscore","add_mem_score","ask","web_search","web_scrape","await","wait"].some(b=>o.includes(b))||o==="ask",u=["click","drag","scroll","keyboardtyping","keyboard_typing","keypress","key_press","recapturescreen","recapture_screen","computer","wait"].some(b=>o.includes(b));if(!d){if(i==="flow"){if(!(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image")))return`ERROR: Action [${e}] is a Workspace Tool and NOT available in Flow mode. Tell user to switch (\`/mode flux\`) to use this tool.`}else if(i==="icu"){if(!u)return`ERROR: Action [${e}] is not available in Computer Use mode. ICU mode only supports Computer Use tools (Click, Drag, Scroll, KeyboardTyping, KeyPress, RecaptureScreen).`}else if(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image"))return`ERROR: Action [${e}] is not available in ${t.mode||"Flux"} mode. Tell user to switch (\`/mode flow\`) for document generation.`}let m=Rr[e];if(!m){let b=["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"],h={read:"ReadFile",view:"ReadFile",viewfile:"ReadFile",write:"WriteFile",edit:"PatchFile",patch:"PatchFile",update:"PatchFile",updatefile:"PatchFile",exec:"Run",command:"Run",bash:"Run",shell:"Run",powershell:"Run",search:"CodeSearch",grep:"CodeSearch",find:"FindFile",findfile:"FindFile",searchkeyword:"CodeSearch",folder:"ReadFolder",ls:"ReadFolder",dir:"ReadFolder",list:"ReadFolder",ask:"AskUser",question:"AskUser",pdf:"WritePDF",docx:"WriteDoc",doc:"WriteDoc",word:"WriteDoc",screenshot:"RecaptureScreen",screen:"RecaptureScreen",recapture:"RecaptureScreen",type:"KeyboardTyping",typing:"KeyboardTyping",keyboard:"KeyboardTyping",press:"KeyPress",key:"KeyPress",todo:"Goal",task:"Goal",subagent:"Invoke",agent:"Invoke"},f=o.replace(/[^a-z0-9]/g,""),s=h[f]||null;if(!s){let T=0,ue=R=>{let F=new Set;for(let H=0;H<R.length-1;H++)F.add(R.slice(H,H+2));return F},y=ue(f);for(let R of b){let F=R.toLowerCase().replace(/[^a-z0-9]/g,"");if(f===F){s=R;break}let H=0;(F.includes(f)||f.includes(F))&&(H+=.6);let $=ue(F),A=0;for(let Se of y)$.has(Se)&&A++;let he=2*A/(y.size+$.size||1);H=Math.max(H,he),H>T&&H>=.35&&(T=H,s=R)}}let g=s?` Do you mean '${s}'?`:"";return`ERROR: Action [${e}] not found in registry.${g}`}try{return await(await m())(n,t)}catch(b){let h=b instanceof Error?b.message:String(b);return`ERROR: Execution failed for [${e}]: ${h}`}};var oi=e=>{if(!e||typeof e!="string")return!1;let n=e.trim().toLowerCase();return Object.keys(Rr).some(t=>t.toLowerCase()===n)};import U from"path";import we from"fs";import Ta from"gradient-string";var vr=["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 _r=["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 Ir=[{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"]}],to={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 si=(e="Dark")=>{let n;e==="Mystery"||e==="Chaos"?(ii||(ii=Ir[Math.floor(Math.random()*Ir.length)]),n={...ii,id:"Mystery"}):(ii=null,to[e]?n=to[e]:e==="Halloween"?n=to.Spookfest:e==="GitHub"?n=to["GitHub Dark"]:e==="Transparent"?n=to["Transparent Dark"]:n=to.Dark);let t=n.codeText||n.secondary||n.info||n.logoGradient&&n.logoGradient[0]||"cyan",i=n.toolFeedbackAnsi||"\x1B[95m";return{...n,codeText:t,toolFeedbackAnsi:i}};var Aa=()=>process.env.TERM_PROGRAM==="vscode"?"vscode":process.env.WT_SESSION?"wt":"default",gc=(e=2)=>{let n=Aa();return n==="wt"?" ".repeat(Math.max(1,e-1)):" ".repeat(e)},Mr=new Date,Io=Mr.getMonth(),Mo=Mr.getDate(),Ea=Io===9&&Mo>=15||Io===10&&Mo<=1,ji=null;(process.env.SPOOKFEST==="true"||Ea)&&(ji=await import("./halloween-MX3VNQRW.js"));var hc=(e="...",n="Loading...",t="Dark")=>{let i=si(t),o=n;if(n==="c_openai"||n==="Custom (OpenAI)")try{let H=jo(Wo,{})?.systemSettings?.customOpenAIBaseUrl;H&&(o=H)}catch{}let r=i.logoTextAnsi,d=i.logoBodyAnsi,a=i.logoMutedAnsi,u="\x1B[0m",m=[" \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 "],b=t==="Spookfest"||i.id==="Spookfest"||t==="Halloween"||i.id==="Halloween",h=Io===9&&Mo>=15||Io===10&&Mo<=1,f=b&&h||process.env.SPOOKFEST==="true"&&b,s=m;if(f&&ji){process.env.HALLOWEEN_EEGG="true";let{halloweenArtSide:F,halloweenBat:H,halloweenArtUser:$}=ji;s=Math.random()>.9&&Io===9&&Mo>=30?H:Math.random()>.5?F:$}else process.env.HALLOWEEN_EEGG="false";let g=f?_r:vr,T=g[Math.floor(Math.random()*g.length)],ue=i.logoGradient||["#0077ff","#ff00ff"],y=Ta(ue).multiline(s.join(`
|
|
559
|
+
${e}`:""}`.trim();var ur=()=>import("./web_search-NT3HXUO3.js").then(e=>e.web_search),gr=()=>import("./web_scrape-MW6YSZ7L.js").then(e=>e.web_scrape),hr=()=>import("./memory-7YOYCOXE.js").then(e=>e.memory),mr=()=>import("./chat-C7HYXKVZ.js").then(e=>e.chat),pr=()=>import("./view_file-I77KYUO5.js").then(e=>e.view_file),yr=()=>import("./write_file-JDMRLJKT.js").then(e=>e.write_file),br=()=>import("./update_file-6F64CFSU.js").then(e=>e.update_file),xr=()=>import("./exec_command-A5JWE55Q.js").then(e=>e.exec_command),wr=()=>import("./read_folder-EI2CNHNS.js").then(e=>e.read_folder),Ki=()=>import("./ask_user-K2DLZF6H.js").then(e=>e.ask_user),Sr=()=>import("./write_pdf-26OQPNEP.js").then(e=>e.write_pdf),kr=()=>import("./write_docx-E3MTFXTQ.js").then(e=>e.write_docx),ti=()=>import("./search_keyword-ABVAWJKX.js").then(e=>e.search_keyword),Tr=()=>import("./generate_image-5D57XGLP.js").then(e=>e.generate_image),ni=()=>import("./saveSummary-W2JMDVZJ.js").then(e=>e.saveSummary),vo=()=>import("./addMemScore-PBVNSFPN.js").then(e=>e.addMemScore),Ar=()=>import("./file_map-UA4BA5OH.js").then(e=>e.file_map),oi=()=>import("./todo-CJLWLWJB.js").then(e=>e.todo),Er=()=>import("./invokeSync-BSFWXLD7.js").then(e=>e.invokeSync),va=()=>import("./invoke-4P5QQPCF.js").then(e=>e.invoke),Cr=()=>import("./getProgress-A2TW34Q7.js").then(e=>e.getProgress),_a=()=>import("./cancel-F3ZOEBKW.js").then(e=>e.cancel),Rr=()=>import("./emergency_rollback-ZHQXCIHW.js").then(e=>e.emergency_rollback),_o=()=>import("./awaitSubagent-JKQ2EHVY.js").then(e=>e.awaitSubagent),Io=()=>import("./answerSubagent-BPNNJXPC.js").then(e=>e.answerSubagent),ii=()=>import("./steerSubagent-UETXH2CB.js").then(e=>e.steerSubagent),si=()=>import("./computer_action-D52LLX3E.js").then(e=>e.computer_action),vr=()=>import("./click-J7DMHVDU.js").then(e=>e.click),_r=()=>import("./drag-CMUD2ZB5.js").then(e=>e.drag),Ir=()=>import("./scroll-LXQJ25NK.js").then(e=>e.scroll),Vi=()=>import("./keyboard_typing-A72GI7EW.js").then(e=>e.keyboard_typing),Yi=()=>import("./key_press-LWJGR25H.js").then(e=>e.key_press),zi=()=>import("./recapture_screen-PPT2E3CK.js").then(e=>e.recapture_screen),ri=()=>import("./find_file-HYHHFHUJ.js").then(e=>e.find_file),Mr=()=>import("./wait-TJR6LAR4.js").then(e=>e.wait),Or={web_search:ur,web_scrape:gr,memory:hr,chat:mr,view_file:pr,write_file:yr,update_file:br,exec_command:xr,read_folder:wr,write_pdf:Sr,write_docx:kr,search_keyword:ti,generate_image:Tr,saveSummary:ni,addMemScore:vo,file_map:Ar,todo:oi,Todo:oi,goal:oi,Goal:oi,invokeSync:Er,invoke:va,getProgress:Cr,cancel:_a,awaitSubagent:_o,answerSubagent:Io,steerSubagent:ii,computer_action:si,computer_use:si,ComputerAction:si,ComputerUse:si,click:vr,Click:vr,drag:_r,Drag:_r,scroll:Ir,Scroll:Ir,keyboard_typing:Vi,KeyboardTyping:Vi,keyboardtyping:Vi,key_press:Yi,KeyPress:Yi,keypress:Yi,recapture_screen:zi,RecaptureScreen:zi,recapturescreen:zi,invoke_sync:Er,get_progress:Cr,await_subagent:_o,answer_subagent:Io,steer_subagent:ii,steer:ii,Steer:ii,ask:Ki,Ask:Ki,AskUser:Ki,WebSearch:ur,WebScrape:gr,ReadFile:pr,ReadFolder:wr,WriteFile:yr,PatchFile:br,WritePDF:Sr,WriteDoc:kr,Run:xr,SearchKeyword:ti,CodeSearch:ti,code_search:ti,Memory:hr,Chat:mr,GenerateImage:Tr,saveSumary:ni,SaveSummary:ni,SaveSumary:ni,add_mem_score:vo,AddMemScore:vo,addMemoryScore:vo,AddMemoryScore:vo,FileMap:Ar,answer:Io,Answer:Io,AnswerSubagent:Io,await:_o,Await:_o,AwaitSubagent:_o,EmergencyRollback:Rr,emergency_rollback:Rr,find_file:ri,findFile:ri,FindFile:ri,findfile:ri,wait:Mr,Wait:Mr},Mo=async(e,n,t={})=>{let i=t.mode?t.mode.toLowerCase():"flux",o=e.toLowerCase(),d=["memory","chat","savesummary","addmemscore","add_mem_score","ask","web_search","web_scrape","await","wait"].some(b=>o.includes(b))||o==="ask",u=["click","drag","scroll","keyboardtyping","keyboard_typing","keypress","key_press","recapturescreen","recapture_screen","computer","wait"].some(b=>o.includes(b));if(!d){if(i==="flow"){if(!(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image")))return`ERROR: Action [${e}] is a Workspace Tool and NOT available in Flow mode. Tell user to switch (\`/mode flux\`) to use this tool.`}else if(i==="icu"){if(!u)return`ERROR: Action [${e}] is not available in Computer Use mode. ICU mode only supports Computer Use tools (Click, Drag, Scroll, KeyboardTyping, KeyPress, RecaptureScreen).`}else if(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image"))return`ERROR: Action [${e}] is not available in ${t.mode||"Flux"} mode. Tell user to switch (\`/mode flow\`) for document generation.`}let m=Or[e];if(!m){let b=["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"],h={read:"ReadFile",view:"ReadFile",viewfile:"ReadFile",write:"WriteFile",edit:"PatchFile",patch:"PatchFile",update:"PatchFile",updatefile:"PatchFile",exec:"Run",command:"Run",bash:"Run",shell:"Run",powershell:"Run",search:"CodeSearch",grep:"CodeSearch",find:"FindFile",findfile:"FindFile",searchkeyword:"CodeSearch",folder:"ReadFolder",ls:"ReadFolder",dir:"ReadFolder",list:"ReadFolder",ask:"AskUser",question:"AskUser",pdf:"WritePDF",docx:"WriteDoc",doc:"WriteDoc",word:"WriteDoc",screenshot:"RecaptureScreen",screen:"RecaptureScreen",recapture:"RecaptureScreen",type:"KeyboardTyping",typing:"KeyboardTyping",keyboard:"KeyboardTyping",press:"KeyPress",key:"KeyPress",todo:"Goal",task:"Goal",subagent:"Invoke",agent:"Invoke"},f=o.replace(/[^a-z0-9]/g,""),s=h[f]||null;if(!s){let T=0,ue=R=>{let F=new Set;for(let j=0;j<R.length-1;j++)F.add(R.slice(j,j+2));return F},y=ue(f);for(let R of b){let F=R.toLowerCase().replace(/[^a-z0-9]/g,"");if(f===F){s=R;break}let j=0;(F.includes(f)||f.includes(F))&&(j+=.6);let $=ue(F),A=0;for(let Se of y)$.has(Se)&&A++;let he=2*A/(y.size+$.size||1);j=Math.max(j,he),j>T&&j>=.35&&(T=j,s=R)}}let g=s?` Do you mean '${s}'?`:"";return`ERROR: Action [${e}] not found in registry.${g}`}try{return await(await m())(n,t)}catch(b){let h=b instanceof Error?b.message:String(b);return`ERROR: Execution failed for [${e}]: ${h}`}};var ai=e=>{if(!e||typeof e!="string")return!1;let n=e.trim().toLowerCase();return Object.keys(Or).some(t=>t.toLowerCase()===n)};import G from"path";import we from"fs";import Ia from"gradient-string";var Pr=["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 Lr=["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 $r=[{name:"Cyan Cyberpunk",text:"cyan",textMuted:"#4da6b8",textDim:"#2d6d7a",textInverted:"black",border:"cyan",borderMuted:"#1a5966",borderDim:"#0f3840",bg:void 0,cardBg:"#061e24",highlightBg:"#092b33",activeBg:"#0e3e4a",inputBg:"#092b33",inputBorder:"#092b33",inputText:"cyan",inputPlaceholder:"#2d6d7a",inputPrompt:"cyan",codeBg:"#020d10",codeBorder:"#1a5966",userMsgBg:"#092b33",userMsgBorder:"#092b33",userMsgText:"cyan",diffRemovalBg:"#3a0c1a",diffAdditionBg:"#0c3a32",diffRemovalText:"#ff4d88",diffAdditionText:"#00ffaa",diffRemovalHighlightColor:"#ff1a66",diffRemovalHighlightBg:"#590022",diffAdditionHighlightColor:"#00ffcc",diffAdditionHighlightBg:"#00593b",diffRemovalNum:"#ff4d88",diffAdditionNum:"#00ffaa",diffRemovalPrefix:"#ff1a66",diffAdditionPrefix:"#00ffcc",primary:"cyan",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"cyan",statusOff:"#2d6d7a",logoTextAnsi:"\x1B[1;36m",logoBodyAnsi:"\x1B[36m",logoMutedAnsi:"\x1B[90m",logoGradient:["#00ffff","#0088ff"]},{name:"Magenta Vaporwave",text:"magenta",textMuted:"#c451d6",textDim:"#7d2b8a",textInverted:"black",border:"magenta",borderMuted:"#5e1b69",borderDim:"#3b0f42",bg:void 0,cardBg:"#240729",highlightBg:"#310938",activeBg:"#470e52",inputBg:"#310938",inputBorder:"#310938",inputText:"magenta",inputPlaceholder:"#7d2b8a",inputPrompt:"magenta",codeBg:"#100312",codeBorder:"#5e1b69",userMsgBg:"#310938",userMsgBorder:"#310938",userMsgText:"magenta",diffRemovalBg:"#3a0c20",diffAdditionBg:"#200c3a",diffRemovalText:"#ff4d94",diffAdditionText:"#aa4dff",diffRemovalHighlightColor:"#ff1a75",diffRemovalHighlightBg:"#59002b",diffAdditionHighlightColor:"#bb66ff",diffAdditionHighlightBg:"#3b0059",diffRemovalNum:"#ff4d94",diffAdditionNum:"#aa4dff",diffRemovalPrefix:"#ff1a75",diffAdditionPrefix:"#bb66ff",primary:"magenta",secondary:"cyan",accent:"purple",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"magenta",statusOff:"#7d2b8a",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ff00ff","#8800ff"]},{name:"Glitch Matrix",text:"#00ff41",textMuted:"#00b32d",textDim:"#00661a",textInverted:"black",border:"#00ff41",borderMuted:"#008020",borderDim:"#004d13",bg:void 0,cardBg:"#0d1f0d",highlightBg:"#122912",activeBg:"#1c3e1c",inputBg:"#122912",inputBorder:"#122912",inputText:"#00ff41",inputPlaceholder:"#00b32d",inputPrompt:"#ffff00",codeBg:"#040a04",codeBorder:"#008020",userMsgBg:"#122912",userMsgBorder:"#122912",userMsgText:"#00ff41",diffRemovalBg:"#3a001a",diffAdditionBg:"#003a10",diffRemovalText:"#ff0055",diffAdditionText:"#00ff66",diffRemovalHighlightColor:"#ff0033",diffRemovalHighlightBg:"#59001b",diffAdditionHighlightColor:"#33ff88",diffAdditionHighlightBg:"#005918",diffRemovalNum:"#ff0055",diffAdditionNum:"#00ff66",diffRemovalPrefix:"#ff0033",diffAdditionPrefix:"#33ff88",primary:"#00ff41",secondary:"yellow",accent:"cyan",success:"#00ff41",warning:"yellow",danger:"red",info:"cyan",statusOn:"#00ff41",statusOff:"#00661a",logoTextAnsi:"\x1B[1;32m",logoBodyAnsi:"\x1B[32m",logoMutedAnsi:"\x1B[90m",logoGradient:["#00ff41","#ffff00"]},{name:"Warm Sunset",text:"#ffaa55",textMuted:"#cc8844",textDim:"#885522",textInverted:"black",border:"#ff9933",borderMuted:"#aa6622",borderDim:"#663311",bg:void 0,cardBg:"#24180f",highlightBg:"#2e1e12",activeBg:"#422c1b",inputBg:"#2e1e12",inputBorder:"#2e1e12",inputText:"#ffaa55",inputPlaceholder:"#885522",inputPrompt:"#ff7733",codeBg:"#120c08",codeBorder:"#aa6622",userMsgBg:"#2e1e12",userMsgBorder:"#2e1e12",userMsgText:"#ffaa55",diffRemovalBg:"#3d120c",diffAdditionBg:"#3a2e0c",diffRemovalText:"#ff5544",diffAdditionText:"#ffcc33",diffRemovalHighlightColor:"#ff3322",diffRemovalHighlightBg:"#591108",diffAdditionHighlightColor:"#ffee44",diffAdditionHighlightBg:"#594400",diffRemovalNum:"#ff5544",diffAdditionNum:"#ffcc33",diffRemovalPrefix:"#ff3322",diffAdditionPrefix:"#ffee44",primary:"#ffaa55",secondary:"#ff7733",accent:"magenta",success:"#ffcc33",warning:"#ff7733",danger:"#ff3322",info:"#ffaa55",statusOn:"#ffaa55",statusOff:"#885522",logoTextAnsi:"\x1B[1;33m",logoBodyAnsi:"\x1B[33m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ff9933","#ff0055"]},{name:"Sakura Blossom",text:"#ffc0e0",textMuted:"#d98cb3",textDim:"#804d66",textInverted:"black",border:"#ff99cc",borderMuted:"#aa4d7a",borderDim:"#662647",bg:void 0,cardBg:"#291320",highlightBg:"#331826",activeBg:"#472235",inputBg:"#331826",inputBorder:"#331826",inputText:"#ffc0e0",inputPlaceholder:"#804d66",inputPrompt:"#ff99cc",codeBg:"#140a10",codeBorder:"#aa4d7a",userMsgBg:"#331826",userMsgBorder:"#331826",userMsgText:"#ffc0e0",diffRemovalBg:"#3e0c1b",diffAdditionBg:"#1b3e2b",diffRemovalText:"#ff6699",diffAdditionText:"#66ffb3",diffRemovalHighlightColor:"#ff3377",diffRemovalHighlightBg:"#590022",diffAdditionHighlightColor:"#33ff99",diffAdditionHighlightBg:"#00592e",diffRemovalNum:"#ff6699",diffAdditionNum:"#66ffb3",diffRemovalPrefix:"#ff3377",diffAdditionPrefix:"#33ff99",primary:"#ffc0e0",secondary:"#ff99cc",accent:"magenta",success:"#66ffb3",warning:"yellow",danger:"#ff3377",info:"#ff99cc",statusOn:"#ffc0e0",statusOff:"#804d66",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ffb3d9","#ff3399"]},{name:"Radioactive Slime",text:"#ccff00",textMuted:"#99cc00",textDim:"#669900",textInverted:"#0a0f00",border:"#ccff00",borderMuted:"#99cc00",borderDim:"#669900",bg:void 0,cardBg:"#0f1400",highlightBg:"#1a2400",activeBg:"#2a3b00",inputBg:"#1a2400",inputBorder:"#1a2400",inputText:"#ccff00",inputPlaceholder:"#669900",inputPrompt:"#cc00ff",codeBg:"#050a00",codeBorder:"#99cc00",userMsgBg:"#1a2400",userMsgBorder:"#1a2400",userMsgText:"#ccff00",diffRemovalBg:"#2a0033",diffAdditionBg:"#0f3300",diffRemovalText:"#ff00cc",diffAdditionText:"#00ff33",diffRemovalHighlightColor:"#ff33cc",diffRemovalHighlightBg:"#4d0066",diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:"#1a6600",diffRemovalNum:"#ff00cc",diffAdditionNum:"#00ff33",diffRemovalPrefix:"#ff33cc",diffAdditionPrefix:"#33ff66",primary:"#ccff00",secondary:"#cc00ff",accent:"#ff00cc",success:"#00ff33",warning:"#ffcc00",danger:"#ff0033",info:"#00ccff",statusOn:"#ccff00",statusOff:"#669900",logoTextAnsi:"\x1B[1;38;5;190m",logoBodyAnsi:"\x1B[38;5;190m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ccff00","#cc00ff"]},{name:"Cosmic Void",text:"#f0f8ff",textMuted:"#a6aeb5",textDim:"#5e656e",textInverted:"#010103",border:"#f0f8ff",borderMuted:"#a6aeb5",borderDim:"#5e656e",bg:void 0,cardBg:"#05030d",highlightBg:"#0b081a",activeBg:"#171133",inputBg:"#0b081a",inputBorder:"#0b081a",inputText:"#f0f8ff",inputPlaceholder:"#5e656e",inputPrompt:"#ff007f",codeBg:"#020108",codeBorder:"#a6aeb5",userMsgBg:"#0b081a",userMsgBorder:"#0b081a",userMsgText:"#f0f8ff",diffRemovalBg:"#2e0a29",diffAdditionBg:"#091c33",diffRemovalText:"#ff33a6",diffAdditionText:"#33d6ff",diffRemovalHighlightColor:"#ff66c2",diffRemovalHighlightBg:"#5c1452",diffAdditionHighlightColor:"#66e0ff",diffAdditionHighlightBg:"#123866",diffRemovalNum:"#ff33a6",diffAdditionNum:"#33d6ff",diffRemovalPrefix:"#ff66c2",diffAdditionPrefix:"#66e0ff",primary:"#f0f8ff",secondary:"#ff007f",accent:"#9d00ff",success:"#33d6ff",warning:"#ffcc00",danger:"#ff0040",info:"#9d00ff",statusOn:"#f0f8ff",statusOff:"#5e656e",logoTextAnsi:"\x1B[1;38;5;231m",logoBodyAnsi:"\x1B[38;5;231m",logoMutedAnsi:"\x1B[38;5;240m",logoGradient:["#ffffff","#9d00ff"]},{name:"Magma Eruption",text:"#ff4d00",textMuted:"#cc3d00",textDim:"#802600",textInverted:"#0d0300",border:"#ff4d00",borderMuted:"#cc3d00",borderDim:"#802600",bg:void 0,cardBg:"#1a0600",highlightBg:"#260a00",activeBg:"#401100",inputBg:"#260a00",inputBorder:"#260a00",inputText:"#ff4d00",inputPlaceholder:"#802600",inputPrompt:"#ffcc00",codeBg:"#080200",codeBorder:"#cc3d00",userMsgBg:"#260a00",userMsgBorder:"#260a00",userMsgText:"#ff4d00",diffRemovalBg:"#2e0a0a",diffAdditionBg:"#1f1400",diffRemovalText:"#ff3333",diffAdditionText:"#ffaa00",diffRemovalHighlightColor:"#ff6666",diffRemovalHighlightBg:"#5c1414",diffAdditionHighlightColor:"#ffcc33",diffAdditionHighlightBg:"#3d2900",diffRemovalNum:"#ff3333",diffAdditionNum:"#ffaa00",diffRemovalPrefix:"#ff6666",diffAdditionPrefix:"#ffcc33",primary:"#ff4d00",secondary:"#ffcc00",accent:"#ff0040",success:"#ffaa00",warning:"#ffff00",danger:"#ff0000",info:"#ff8800",statusOn:"#ff4d00",statusOff:"#802600",logoTextAnsi:"\x1B[1;38;5;202m",logoBodyAnsi:"\x1B[38;5;202m",logoMutedAnsi:"\x1B[38;5;236m",logoGradient:["#ff4d00","#ff0000"]}],io={Dark:{id:"Dark",name:"Dark (Default)",text:"white",textMuted:"gray",textDim:"grey",textInverted:"black",textExclusive:"#B5B8D9",textMutedExclusive:"#D4DEE7",border:"white",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:"#1e1e1e",highlightBg:"#2a2a2a",activeBg:"#3a3a3a",inputBg:"#555555",inputBorder:"#555555",inputText:"white",inputPlaceholder:"#cccccc",inputPrompt:"white",codeBg:"#1a1a1a",codeBorder:"#444444",userMsgBg:"#444444",userMsgBorder:"#444444",userMsgText:"white",diffRemovalBg:"#250808",diffAdditionBg:"#072410",diffRemovalText:"#885555",diffAdditionText:"#558866",diffRemovalHighlightColor:"#ff3333",diffRemovalHighlightBg:"#5a1818",diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:"#185a25",diffRemovalNum:"#d96868",diffAdditionNum:"#68d98c",diffRemovalPrefix:"#ff4d4d",diffAdditionPrefix:"#4dff88",primary:"white",secondary:"cyan",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"white",statusOff:"gray",logoTextAnsi:"\x1B[1;37m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},Light:{id:"Light",name:"Light",text:"black",textMuted:"gray",textDim:"grey",textInverted:"white",border:"black",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:"#e5e5e5",highlightBg:"#d4d4d4",activeBg:"#c0c0c0",inputBg:"#d0d0d0",inputBorder:"#d0d0d0",inputText:"black",inputPlaceholder:"#555555",inputPrompt:"black",codeBg:"#e8e8e8",codeBorder:"#b0b0b0",userMsgBg:"#d0d0d0",userMsgBorder:"#d0d0d0",userMsgText:"black",diffRemovalBg:"#fce8e8",diffAdditionBg:"#e6f9e6",diffRemovalText:"#661111",diffAdditionText:"#115511",diffRemovalHighlightColor:"#440000",diffRemovalHighlightBg:"#f8b4b4",diffAdditionHighlightColor:"#003300",diffAdditionHighlightBg:"#a6ebad",diffRemovalNum:"#c02020",diffAdditionNum:"#188028",diffRemovalPrefix:"#d01010",diffAdditionPrefix:"#109020",primary:"black",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"black",statusOff:"gray",logoTextAnsi:"\x1B[1;30m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},"GitHub Dark":{id:"GitHub Dark",name:"GitHub Dark",text:"#c9d1d9",textMuted:"#8b949e",textDim:"#6e7681",textInverted:"#0d1117",border:"#30363d",borderMuted:"#30363d",borderDim:"#21262d",bg:void 0,cardBg:"#161b22",highlightBg:"#21262d",activeBg:"#30363d",inputBg:"#21262d",inputBorder:"#21262d",inputText:"#c9d1d9",inputPlaceholder:"#8b949e",inputPrompt:"#58a6ff",codeBg:"#0d1117",codeBorder:"#30363d",userMsgBg:"#21262d",userMsgBorder:"#21262d",userMsgText:"#c9d1d9",diffRemovalBg:"#3c1e1e",diffAdditionBg:"#11381e",diffRemovalText:"#f85149",diffAdditionText:"#3fb950",diffRemovalHighlightColor:"#ff7b72",diffRemovalHighlightBg:"#701c1c",diffAdditionHighlightColor:"#56d364",diffAdditionHighlightBg:"#116329",diffRemovalNum:"#f85149",diffAdditionNum:"#3fb950",diffRemovalPrefix:"#f85149",diffAdditionPrefix:"#3fb950",primary:"#c9d1d9",secondary:"#58a6ff",accent:"#bc8cff",success:"#3fb950",warning:"#d29922",danger:"#f85149",info:"#58a6ff",statusOn:"#58a6ff",statusOff:"#8b949e",logoTextAnsi:"\x1B[1;36m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#2ea043","#56d364"],toolFeedbackAnsi:"\x1B[95m"},"GitHub Light":{id:"GitHub Light",name:"GitHub Light",text:"#24292f",textMuted:"#57606a",textDim:"#6e7781",textInverted:"#ffffff",border:"#d0d7de",borderMuted:"#d0d7de",borderDim:"#e1e4e8",bg:void 0,cardBg:"#f6f8fa",highlightBg:"#eaeef2",activeBg:"#d0d7de",inputBg:"#eaeef2",inputBorder:"#eaeef2",inputText:"#24292f",inputPlaceholder:"#57606a",inputPrompt:"#0969da",codeBg:"#ffffff",codeBorder:"#d0d7de",userMsgBg:"#eaeef2",userMsgBorder:"#eaeef2",userMsgText:"#24292f",diffRemovalBg:"#ffebe9",diffAdditionBg:"#e6ffec",diffRemovalText:"#cf222e",diffAdditionText:"#1a7f37",diffRemovalHighlightColor:"#82071e",diffRemovalHighlightBg:"#ffc1c0",diffAdditionHighlightColor:"#116329",diffAdditionHighlightBg:"#acf2bd",diffRemovalNum:"#cf222e",diffAdditionNum:"#1a7f37",diffRemovalPrefix:"#cf222e",diffAdditionPrefix:"#1a7f37",primary:"#24292f",secondary:"#0969da",accent:"#8250df",success:"#1a7f37",warning:"#9a6700",danger:"#cf222e",info:"#0969da",statusOn:"#0969da",statusOff:"#57606a",logoTextAnsi:"\x1B[1;34m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#1a7f37","#2da44e"],toolFeedbackAnsi:"\x1B[95m"},"Transparent Dark":{id:"Transparent Dark",name:"Transparent Dark",text:"white",textMuted:"gray",textDim:"grey",textInverted:"black",border:"gray",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:void 0,highlightBg:"#2a2a2a",activeBg:"#3a3a3a",inputBg:"#555555",inputBorder:"#555555",inputText:"white",inputPlaceholder:"#cccccc",inputPrompt:"white",codeBg:void 0,codeBorder:"gray",userMsgBg:"#555555",userMsgBorder:"#555555",userMsgText:"white",diffRemovalBg:void 0,diffAdditionBg:void 0,diffRemovalText:"#ff6666",diffAdditionText:"#66ff66",diffRemovalHighlightColor:"#ff3333",diffRemovalHighlightBg:"#3a1414",diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:"#143a14",diffRemovalNum:"#ff6666",diffAdditionNum:"#66ff66",diffRemovalPrefix:"#ff4d4d",diffAdditionPrefix:"#4dff88",primary:"white",secondary:"cyan",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"white",statusOff:"gray",logoTextAnsi:"\x1B[1;37m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},"Transparent Light":{id:"Transparent Light",name:"Transparent Light",text:"black",textMuted:"gray",textDim:"grey",textInverted:"white",border:"gray",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:void 0,highlightBg:"#d4d4d4",activeBg:"#c0c0c0",inputBg:"#d0d0d0",inputBorder:"#d0d0d0",inputText:"black",inputPlaceholder:"#555555",inputPrompt:"black",codeBg:void 0,codeBorder:"gray",userMsgBg:"#d0d0d0",userMsgBorder:"#d0d0d0",userMsgText:"black",diffRemovalBg:void 0,diffAdditionBg:void 0,diffRemovalText:"#c02020",diffAdditionText:"#188028",diffRemovalHighlightColor:"#800000",diffRemovalHighlightBg:"#f5d0d0",diffAdditionHighlightColor:"#004000",diffAdditionHighlightBg:"#cceccc",diffRemovalNum:"#c02020",diffAdditionNum:"#188028",diffRemovalPrefix:"#d01010",diffAdditionPrefix:"#109020",primary:"black",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"black",statusOff:"gray",logoTextAnsi:"\x1B[1;30m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},"Synthwave 84":{id:"Synthwave 84",name:"Synthwave 84",text:"#fdfdfd",textMuted:"#a08eb7",textDim:"#705c8a",textInverted:"#1a1025",textExclusive:"#e3dcf0",textMutedExclusive:"#b9abc9",border:"#fc28a8",borderMuted:"#a21568",borderDim:"#5c0a3a",bg:void 0,cardBg:"#261b38",highlightBg:"#35254d",activeBg:"#4c3570",inputBg:"#35254d",inputBorder:"#35254d",inputText:"#fdfdfd",inputPlaceholder:"#a08eb7",inputPrompt:"#03e8fc",codeBg:"#1e142b",codeBorder:"#a21568",userMsgBg:"#35254d",userMsgBorder:"#35254d",userMsgText:"#fdfdfd",diffRemovalBg:"#471434",diffAdditionBg:"#144743",diffRemovalText:"#ff4081",diffAdditionText:"#00e5ff",diffRemovalHighlightColor:"#ff79a1",diffRemovalHighlightBg:"#6b1e4e",diffAdditionHighlightColor:"#66f5ff",diffAdditionHighlightBg:"#1e6b65",diffRemovalNum:"#ff4081",diffAdditionNum:"#00e5ff",diffRemovalPrefix:"#ff79a1",diffAdditionPrefix:"#66f5ff",primary:"#fdfdfd",secondary:"#03e8fc",accent:"#fc28a8",success:"#00e5ff",warning:"#ffc107",danger:"#ff4081",info:"#b388ff",statusOn:"#03e8fc",statusOff:"#a08eb7",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#fc28a8","#03e8fc"],toolFeedbackAnsi:"\x1B[38;2;3;232;252m"},"Forest Sprite":{id:"Forest Sprite",name:"Forest Sprite",text:"#d6e6d1",textMuted:"#95b38d",textDim:"#628059",textInverted:"#161c14",textExclusive:"#eaf2e8",textMutedExclusive:"#a9c7a2",border:"#74a862",borderMuted:"#477038",borderDim:"#2b4720",bg:void 0,cardBg:"#1f291c",highlightBg:"#2a3826",activeBg:"#3a4d35",inputBg:"#2a3826",inputBorder:"#2a3826",inputText:"#d6e6d1",inputPlaceholder:"#95b38d",inputPrompt:"#8feb73",codeBg:"#161e14",codeBorder:"#477038",userMsgBg:"#2a3826",userMsgBorder:"#2a3826",userMsgText:"#d6e6d1",diffRemovalBg:"#3b231c",diffAdditionBg:"#203b1c",diffRemovalText:"#db6242",diffAdditionText:"#59cc3f",diffRemovalHighlightColor:"#f0896c",diffRemovalHighlightBg:"#5c362a",diffAdditionHighlightColor:"#80e368",diffAdditionHighlightBg:"#305929",diffRemovalNum:"#db6242",diffAdditionNum:"#59cc3f",diffRemovalPrefix:"#f0896c",diffAdditionPrefix:"#80e368",primary:"#d6e6d1",secondary:"#8feb73",accent:"#e69835",success:"#59cc3f",warning:"#e69835",danger:"#db6242",info:"#73b4eb",statusOn:"#8feb73",statusOff:"#95b38d",logoTextAnsi:"\x1B[1;32m",logoBodyAnsi:"\x1B[32m",logoMutedAnsi:"\x1B[90m",logoGradient:["#8feb73","#e69835"],toolFeedbackAnsi:"\x1B[38;2;143;235;115m"},Spookfest:{id:"Spookfest",name:"Spookfest \u{1F383}",text:"#ffeedd",textMuted:"#e09858",textDim:"#a6622b",textInverted:"#0d0702",textExclusive:"#fff3e6",textMutedExclusive:"#d4a276",border:"#ff7518",borderMuted:"#994409",borderDim:"#592502",bg:void 0,cardBg:"#1a0c02",highlightBg:"#2a1403",activeBg:"#3d1d05",inputBg:"#261203",inputBorder:"#261203",inputText:"#ffeedd",inputPlaceholder:"#a6622b",inputPrompt:"#ff7518",codeBg:"#120701",codeBorder:"#592502",userMsgBg:"#261203",userMsgBorder:"#261203",userMsgText:"#ffeedd",diffRemovalBg:"#3d0a0a",diffAdditionBg:"#1a330a",diffRemovalText:"#ff5555",diffAdditionText:"#73e639",diffRemovalHighlightColor:"#ff2222",diffRemovalHighlightBg:"#590e0e",diffAdditionHighlightColor:"#88ff3b",diffAdditionHighlightBg:"#244d0a",diffRemovalNum:"#ff5555",diffAdditionNum:"#73e639",diffRemovalPrefix:"#ff3333",diffAdditionPrefix:"#88ff3b",primary:"#ff7518",secondary:"#a855f7",accent:"#22c55e",success:"#22c55e",warning:"#f59e0b",danger:"#ef4444",info:"#a855f7",statusOn:"#ff7518",statusOff:"#703a08",logoTextAnsi:"\x1B[1;38;2;255;117;24m",logoBodyAnsi:"\x1B[38;2;255;140;26m",logoMutedAnsi:"\x1B[38;2;168;85;247m",logoGradient:["#ff7518","#a855f7"],toolFeedbackAnsi:"\x1B[38;2;255;117;24m"}};var li=null;var ci=(e="Dark")=>{let n;e==="Mystery"||e==="Chaos"?(li||(li=$r[Math.floor(Math.random()*$r.length)]),n={...li,id:"Mystery"}):(li=null,io[e]?n=io[e]:e==="Halloween"?n=io.Spookfest:e==="GitHub"?n=io["GitHub Dark"]:e==="Transparent"?n=io["Transparent Dark"]:n=io.Dark);let t=n.codeText||n.secondary||n.info||n.logoGradient&&n.logoGradient[0]||"cyan",i=n.toolFeedbackAnsi||"\x1B[95m";return{...n,codeText:t,toolFeedbackAnsi:i}};var Ma=()=>process.env.TERM_PROGRAM==="vscode"?"vscode":process.env.WT_SESSION?"wt":"default",kc=(e=2)=>{let n=Ma();return n==="wt"?" ".repeat(Math.max(1,e-1)):" ".repeat(e)},Nr=new Date,Oo=Nr.getMonth(),Po=Nr.getDate(),Oa=Oo===9&&Po>=15||Oo===10&&Po<=1,qi=null;(process.env.SPOOKFEST==="true"||Oa)&&(qi=await import("./halloween-MX3VNQRW.js"));var Tc=(e="...",n="Loading...",t="Dark")=>{let i=ci(t),o=n;if(n==="c_openai"||n==="Custom (OpenAI)")try{let j=zo(Ko,{})?.systemSettings?.customOpenAIBaseUrl;j&&(o=j)}catch{}let r=i.logoTextAnsi,d=i.logoBodyAnsi,a=i.logoMutedAnsi,u="\x1B[0m",m=[" \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 "],b=t==="Spookfest"||i.id==="Spookfest"||t==="Halloween"||i.id==="Halloween",h=Oo===9&&Po>=15||Oo===10&&Po<=1,f=b&&h||process.env.SPOOKFEST==="true"&&b,s=m;if(f&&qi){process.env.HALLOWEEN_EEGG="true";let{halloweenArtSide:F,halloweenBat:j,halloweenArtUser:$}=qi;s=Math.random()>.9&&Oo===9&&Po>=30?j:Math.random()>.5?F:$}else process.env.HALLOWEEN_EEGG="false";let g=f?Lr:Pr,T=g[Math.floor(Math.random()*g.length)],ue=i.logoGradient||["#0077ff","#ff00ff"],y=Ia(ue).multiline(s.join(`
|
|
560
560
|
`)).split(`
|
|
561
561
|
`),R=F=>`${a}${F}${u}`;return`${y[0]}
|
|
562
562
|
${y[1]} ${r}Selected ${f?"Pumpkin":"Provider"}: ${o}${u}
|
|
@@ -566,39 +566,39 @@ ${y[4]}
|
|
|
566
566
|
${y[5]} ${d}See /help for additional commands.${u}
|
|
567
567
|
${y[6]} ${R(T)}
|
|
568
568
|
${y[7]}
|
|
569
|
-
`};import{WebSocket as
|
|
569
|
+
`};import{structuredPatch as Fa}from"diff";import{WebSocket as di}from"ws";var Nt=null,so=!1,Pa="ws://localhost:56832",Xi=[],ro=null,Ji=null,Dr="2.0.0",Cc=e=>{Dr=e,Fr()},Qi=e=>{Ji=e},Fr=()=>{if(Nt||so)return;so=!0;let e=new di(Pa);e.on("open",()=>{for(Nt=e,so=!1,Nt.send(JSON.stringify({command:"version",version:Dr,pid:process.pid,ppid:process.ppid}));Xi.length>0;)Nt.send(JSON.stringify(Xi.shift()))}),e.on("message",n=>{try{let t=JSON.parse(n.toString());t.command==="contextResponse"&&ro?(ro(t.data),ro=null):t.command==="securityResponse"&&Ji&&Ji(t.result)}catch{}}),e.on("error",()=>{so=!1,Nt=null}),e.on("close",()=>{so=!1,Nt=null})},fi=e=>{Nt&&Nt.readyState===di.OPEN?Nt.send(JSON.stringify(e)):(Xi.push(e),so||Fr())},ui=()=>Nt!==null&&Nt.readyState===di.OPEN,Rc=e=>{fi({command:"status",status:e})},zn=()=>new Promise(e=>{if(!Nt||Nt.readyState!==di.OPEN){e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]});return}ro=e,Nt.send(JSON.stringify({command:"requestContext"})),setTimeout(()=>{ro===e&&(e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]}),ro=null)},1e3)}),Br=e=>{fi({command:"open",filePath:e})},Zi=(e,n,t)=>{fi({command:"showDiff",filePath:e,originalContent:n,modifiedContent:t})},Ur=(e,n)=>{fi({command:"closeDiff",filePath:e,result:n})};import es from"path";import La from"fs";var $a=e=>{try{return La.readdirSync(e,{withFileTypes:!0})}catch{return[]}},ts=(e,n=4,t=1,i=$a,o=[],r=null)=>{let d=r||i(e),a=" ".repeat(t-1),u=t===1?new Set([...po,...o,...yo(e),...yo(process.cwd())]):o instanceof Set?o:new Set([...po,...o]),m=$=>u.has($),b=d.filter($=>!m($.name)),h=d.filter($=>m($.name)).length,f=b.filter($=>!$.isDirectory()).map($=>$.name).sort(),s=b.filter($=>$.isDirectory()).sort(($,A)=>$.name.localeCompare(A.name)),g=$=>{let A=$.length;if(A===0)return"no files";let he=Array.from(new Set($.map(Ie=>{let xe=typeof Ie=="string"?Ie:Ie.name;return es.extname(xe).slice(1)}).filter(Boolean))).sort(),Se="*";return he.length===1?Se=`*.${he[0]}`:he.length>1&&(Se=`*.{${he.join(", ")}}`),A===1?Se:`${Se} ${A} files`},T="";if(t===1){let $=f.join(", "),A=h>0?` [${h} ignored]`:"";($||A)&&(T+=`${a}${$?$+(A?`${A}`:""):A.trim()}
|
|
570
570
|
`)}else f.length>0&&(T+=`${a}[${g(f)}]
|
|
571
|
-
`);let ue=10,y=s.slice(0,ue),R=s.length>ue,F=[],
|
|
572
|
-
`);for(let{displayName:$,subDirPath:A,subEntries:he,nextDepth:Se}of
|
|
573
|
-
`,T+=
|
|
574
|
-
`),T};import
|
|
575
|
-
`;let u="",m=r,b=d.filter(s=>!m.includes(s.name)&&!s.name.startsWith(".")),h=d.filter(s=>m.includes(s.name)||s.name.startsWith(".")).map(s=>s.name).sort();b.sort((s,g)=>s.isDirectory()&&!g.isDirectory()?-1:!s.isDirectory()&&g.isDirectory()?1:s.name.localeCompare(g.name));let f=[...b.map(s=>({name:s.name,isDir:s.isDirectory()})),...h.map(s=>({name:s,isDir:!0,isCollapsed:!0}))];return f.forEach((s,g)=>{let T=g===f.length-1,ue=
|
|
571
|
+
`);let ue=10,y=s.slice(0,ue),R=s.length>ue,F=[],j=[];for(let $ of y){let A=es.join(e,$.name),he=$.name,Se=t,Ie=i(A),xe=Ie.filter(ve=>!m(ve.name)),k=xe.filter(ve=>ve.isDirectory()),x=xe.filter(ve=>!ve.isDirectory());for(;x.length===0&&k.length===1&&Se<n;)he=`${he}/${k[0].name}`,A=es.join(A,k[0].name),Se++,Ie=i(A),xe=Ie.filter(ve=>!m(ve.name)),k=xe.filter(ve=>ve.isDirectory()),x=xe.filter(ve=>!ve.isDirectory());let rt=k.length>0;if(rt&&Se<n)j.push({displayName:he,subDirPath:A,subEntries:Ie,nextDepth:Se+1});else{let ve=g(x),It=rt&&Se>=n?" ...max scan depth":"";F.push(`${he}/${ve}${It}`)}}F.length>0&&(T+=`${a}${F.join(", ")}
|
|
572
|
+
`);for(let{displayName:$,subDirPath:A,subEntries:he,nextDepth:Se}of j)T+=`${a}${$}/
|
|
573
|
+
`,T+=ts(A,n,Se,i,u,he);return R&&(T+=`${a}...max scan width, ReadFolder if needed
|
|
574
|
+
`),T};import ns from"path";import Na from"fs";var Da=e=>{try{return Na.readdirSync(e,{withFileTypes:!0})}catch{return[]}},os=(e,n,t="",i=1,o=Da,r=[])=>{let d=o(e),a=ns.sep;if(d.length>100)return`${t}\u2514\u2500\u2500 ${ns.basename(e)}${a} ...100+ files...
|
|
575
|
+
`;let u="",m=r,b=d.filter(s=>!m.includes(s.name)&&!s.name.startsWith(".")),h=d.filter(s=>m.includes(s.name)||s.name.startsWith(".")).map(s=>s.name).sort();b.sort((s,g)=>s.isDirectory()&&!g.isDirectory()?-1:!s.isDirectory()&&g.isDirectory()?1:s.name.localeCompare(g.name));let f=[...b.map(s=>({name:s.name,isDir:s.isDirectory()})),...h.map(s=>({name:s,isDir:!0,isCollapsed:!0}))];return f.forEach((s,g)=>{let T=g===f.length-1,ue=ns.join(e,s.name),y=T?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",R=t+(T?" ":"\u2502 ");if(s.isCollapsed){u+=`${t}${y}${s.name}${a}...
|
|
576
576
|
`;return}s.isDir?i>n?u+=`${t}${y}${s.name}${a} ...depth exceeded...
|
|
577
577
|
`:o(ue).length>80?u+=`${t}${y}${s.name}${a} ...80+ files...
|
|
578
578
|
`:(u+=`${t}${y}${s.name}${a}
|
|
579
|
-
`,u+=
|
|
580
|
-
`}),u};var
|
|
581
|
-
`),T=s.toLowerCase().includes("tool:")||s.toLowerCase().includes("action:");d.push(s),T&&g?u=!0:u=!1}}}),m()}}return t.length},
|
|
582
|
-
`),A=i.slice(0,-1).filter(S=>S.text&&!S.text.includes("[ACTION RESULT]")&&!S.text.includes("[TOOL RESULT]")&&!S.text.includes("OBSERVATION:")&&!S.text.startsWith("[TERMINAL_RECORD]")&&!S.isTerminalRecord&&!S.isMeta&&!S.isLogo&&!String(S.id).startsWith("welcome")&&!String(S.id).startsWith("logo")).slice(-14).map(S=>{let E=Ft(
|
|
579
|
+
`,u+=os(ue,n,R,i+1,o,r)):u+=`${t}${y}${s.name}
|
|
580
|
+
`}),u};var Ba={Ollama:()=>import("./ollama-4PI2BDMM.js").then(e=>e.getOllamaStream),OpenRouter:()=>import("./openrouter-YU3RE7RH.js").then(e=>e.getOpenRouterStream),DeepSeek:()=>import("./deepseek-CQRKTOL6.js").then(e=>e.getDeepSeekStream),Mistral:()=>import("./mistral-OXTDZX3G.js").then(e=>e.getMistralStream),NVIDIA:()=>import("./nvidia-5DDRU422.js").then(e=>e.getNVIDIAStream),NVIDIA_wrap:()=>import("./nvidia-5DDRU422.js").then(e=>e.wrapNvidiaStreamWithQueueDepth),InferX:()=>import("./inferx-A42H43ZV.js").then(e=>e.getInferXStream),SenseNova:()=>import("./sensenova-UT5CZFCW.js").then(e=>e.getSenseNovaStream),AIHubMix:()=>import("./aihubmix-UBV5ARET.js").then(e=>e.getAIHubMixStream),Poolside:()=>import("./poolside-H2NCP5XT.js").then(e=>e.getPoolsideStream),NineRouter:()=>import("./9router-E4LQZ5XF.js").then(e=>e.getNineRouterStream),ExpLabs:()=>import("./explabs-6TWS34VQ.js").then(e=>e.getExpLabsStream),TokenHarbor:()=>import("./tokenharbor-S66MGK52.js").then(e=>e.getTokenHarborStream),Infron:()=>import("./infron-NZI2FQFA.js").then(e=>e.getInfronStream),APInex:()=>import("./apinex-L3Y6BP6J.js").then(e=>e.getAPInexStream),c_openai:()=>import("./custom_openai-S6YIOHQN.js").then(e=>e.getCustomOpenAIStream)},is={},ce=async e=>(is[e]||(is[e]=await Ba[e]()),is[e]),Ua=/```[\s\S]*?```/g,Wa=/```[\s\S]*$/g,Ga=/`[^`]+`/g,Ha=/^\|.*\|$/gm,ja=/^[^\w]+|[^\w]+$/g,Ka=/[^a-z0-9]/gi,Lo=/\[\s*(?:tool|action):(?:functions\.)?([a-z0-9_]+)\s*\(/gi,Va=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-z0-9_]+)\s*\(/gi,Ya=/(?:path|targetFile|TargetFile|directory|keyword|id|taskId|title|task)\s*=\s*\\?["']?([^\\"' \),]+)/,Cn=/["']/g,Wr=/\\/g,za=/<\|channel>thought/gi,qa=/<channel\|>/gi,Xa=e=>typeof e!="string"?e:e.replace(za,"<think>").replace(qa,"</think>"),hd=/^\s*(?:<(think|thought|thoughts)[^>]*>|<\|channel>thought|\[(think|thought|thoughts)\])[\s\S]*?(?:<\/(think|thought|thoughts)>|<channel\|>|\[\/(think|thought|thoughts)\]|$)/i,Ja=(e,n,t=1)=>{let i=n>0?e[n-1]:"",o=n+t<e.length?e[n+t]:"";return i==="`"&&o==="`"},Qa=e=>{let n=/(?:<\/(think|thought|thoughts)>|<channel\|>|\[\/(think|thought|thoughts)\])/gi,t;for(;(t=n.exec(e))!==null;)if(!Ja(e,t.index,t[0].length))return{index:t.index,length:t[0].length};return{index:-1,length:0}},ss=e=>{if(!e||typeof e!="string")return null;let n=e.match(/^\s*(?:<(think|thought|thoughts)[^>]*>|<\|channel>thought|\[(think|thought|thoughts)\])/i);if(!n)return null;let t=n.index+n[0].length,i=e.substring(t),o=Qa(i);if(o.index!==-1){let r=t+o.index+o.length;return{fullBlock:e.substring(0,r),innerContent:i.substring(0,o.index),remainingText:e.substring(r)}}return{fullBlock:e,innerContent:i,remainingText:""}},Ft=e=>{if(!e||typeof e!="string")return e;let n=ss(e);return n?n.remainingText.trimStart():e};var Gr=/<\|\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,Za=/"([^"]+)"\s*:\s*(?:"([^"]*)"|(\d+)|true|false|null)/g,Hr=/<\|\s*tool_calls_section_begin\s*\|>/gi,jr=/<\|\s*tool_calls_section_end\s*\|>/gi,el=/```(?:tool|action|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi;var gi=e=>!e||typeof e!="string"?e:e.replace(/(```[\s\S]*?```|`[^`]*`)|(<(?:\w+)(?:[^>]*)>\r?\n?|\r?\n?<\/\w+(?:[^>]*)>)/gi,(n,t)=>t||""),zr=e=>{if(!e||typeof e!="string")return e;let n=ao(e);if(!n||n.length===0)return e;let t=n[n.length-1];if(!t.fullMatch)return e;let i=e.lastIndexOf(t.fullMatch);if(i===-1)return e;let o=i+t.fullMatch.length;return e.substring(0,o).trimEnd()},as=null,$o={},qn={key:null,value:null},Dt=e=>{if(!e)return e;let n=$o?.theme;if(!n)try{n=zo(Ko,{})?.systemSettings?.theme}catch{}let i=ci(n||"Dark").toolFeedbackAnsi||"\x1B[95m";return e.replace(/(?:(\x1b\[\d+m))?([✔✘✖🔍📖→➕↻↷•🛇])(?:(\x1b\[\d+m))?\s*\b(Clicked Screen|Clicked|Located|Dragged|Scrolled|Typed|Entered|Pressed Key|Recaptured Screen|Created|Read Skill|Read Documentation|Executed|Searched Documentation|Read|Edited|Viewed|Processed|Auto-Read|Skipped|List|Generated|Written|Searched|AI Search|Get Map|Write Canceled|Resolved Sub-Agent Query|Edit Canceled|Write Cancelled|Edit Denied|Visited|Updated|Reviewed|Delegated|Background|Checked|Indexed|Analyzed|Browsed|Elevating SubAgent|Checking SubAgent Work|Started Generalist|Called Generalist|Steered|Unsupported Modality|Awaiting|Cancelled|Aligning Moon Phase|Contemplating Existence|Staring At Void|Rollback Point Checked|Emergency Rollback Failed|Emergency Rollback|Delaying Professionally|Negotiating With Electrons|Touching Grass (virtually)|Panicking Softly|Rethinking Career Choices|Loading Cat Videos|Giving Up Entirely|Summoning Braincell #2|Pretending To Be Busy|Waiting For Motivation DLC|Rotating Internal Screaming|Downloading More RAM|Feeding The Hamsters|Gaslighting Scheduler|Performing Dramatic Pause|Buffering Social Energy|Calculating Regret|Reading Terms And Conditions|Becoming Sentient Briefly|Model produced malformed tool call|Loop Detected|Contacting Ancestors)\b/ig,(o,r,d,a,u)=>`${r||""}${d}${a||""} ${i}${u}\x1B[0m`)},tl=async(e,n=8,t=1e3,i=8e3,o=null)=>{let r=0;for(;;){if(o?.aborted)throw new DOMException("The user aborted a request.","AbortError");try{return await e()}catch(d){if(o?.aborted||d?.name==="AbortError"||d?.message==="Subagent task was cancelled."||(r++,r>=n))throw d;let a=Math.min(t*Math.pow(2,r-1),i);await new Promise((u,m)=>{let b=setTimeout(u,a);o&&o.addEventListener("abort",()=>{clearTimeout(b),m(new DOMException("The user aborted a request.","AbortError"))})})}}},gt=!1;var nl=e=>{let n=e.filter(o=>(o.role==="user"||o.role==="agent"||o.role==="system")&&o.role!=="think"&&!o.isVisualFeedback&&!o.isMeta&&!o.isTerminalRecord&&!(o.text&&o.text.includes("[TERMINAL_RECORD]"))&&!String(o.id).startsWith("welcome")).map((o,r,d)=>{let a=o.fullText||o.text||"";if(o.role==="user"&&r<d.length-1)if(a.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")){let u=a.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");if(u!==-1){let b=a.substring(0,u).lastIndexOf("[SYSTEM METADATA]");b!==-1?a=a.substring(b).trim():a=a.substring(u).trim()}}else{let u=a.lastIndexOf("[USER]"),m=a.lastIndexOf("[USER PROMPT]");u!==-1?a=a.substring(u+6).trim():m!==-1&&(a=a.substring(m).trim())}return{...o,text:a}}),t=[],i=0;for(;i<n.length;){let o=n[i];if(o.role==="user")t.push(o),i++;else{let r=[];for(;i<n.length&&n[i].role!=="user";)r.push(n[i]),i++;let d=[],a=[],u=!1,m=()=>{d.length>0&&(t.push({role:"agent",text:"combined"}),d=[]),a.length>0&&(t.push({role:"system",text:"combined"}),a=[]),u=!1};r.forEach(b=>{let h=b.role==="system"&&(b.text?.startsWith("[ACTION RESULT]")||b.text?.startsWith("[TOOL RESULT]")||b.text?.startsWith("SUCCESS:")||b.text?.startsWith("ERROR:")||b.fullText?.startsWith("[ACTION RESULT]")||b.fullText?.startsWith("[TOOL RESULT]")||b.fullText?.startsWith("SUCCESS:")||b.fullText?.startsWith("ERROR:")),f=b.fullText||b.text||"",s=f.trim();if(!(!s&&!b.binaryPart)){if(h)a.push(s);else if(b.role==="agent"){!u&&a.length>0&&m();let g=f.endsWith(`
|
|
581
|
+
`),T=s.toLowerCase().includes("tool:")||s.toLowerCase().includes("action:");d.push(s),T&&g?u=!0:u=!1}}}),m()}}return t.length},ol=e=>typeof e!="string"?e:e.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,""),md=()=>{gt=!0},pd=()=>gt,rs={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"},Xn=(e,n)=>{try{let t=W(n),i=e.toLowerCase().replace(/_/g,"");if(i==="invokesync"||i==="invoke")return t.title||(t.task?t.task.substring(0,30):null);if(i==="getprogress"||i==="cancel"||i==="steer"||i==="steersubagent")return t.id||t.taskId;let o=t.name||t.path||t.targetFile||t.TargetFile||t.directory||t.file||t.query;return o?G.basename(o.replace(/["']/g,"").replace(/\\/g,"/")):null}catch{return null}},ls=e=>e?new Yr({apiKey:e}):as,yd=async(e,n,t,i,o={})=>{let{onStatus:a,onMemoryUpdated:u,onBackgroundIncrement:m}=o,{profile:b,thinkingLevel:h,mode:f,janitorModel:s,chatId:g,systemSettings:T,sessionStats:ue,aiProvider:y="Google",apiKey:R}=e,F=process.env.NVIDIA_BASE_URL||y==="Ollama"||y==="InferX"||y==="SenseNova"||y==="AIHubMix"||y==="Poolside"||y==="9router"||y==="ExpLabs"||y==="ExperientialLabs"||y==="c_openai"||y==="Custom (OpenAI)"?!1:T?.memory!==!1,$=Ct(Yn,[]).map(S=>`- [${S.id}]: ${S.memory}`).join(`
|
|
582
|
+
`),A=i.slice(0,-1).filter(S=>S.text&&!S.text.includes("[ACTION RESULT]")&&!S.text.includes("[TOOL RESULT]")&&!S.text.includes("OBSERVATION:")&&!S.text.startsWith("[TERMINAL_RECORD]")&&!S.isTerminalRecord&&!S.isMeta&&!S.isLogo&&!String(S.id).startsWith("welcome")&&!String(S.id).startsWith("logo")).slice(-14).map(S=>{let E=Ft(ol(S.text)).replace(/\[(?:tool|action):(?:functions\.)?.*?\]/g,"").replace(/\[Prompted on:.*?\]/g,"").replace(/\[METADATA \(PRIORITY: DYNAMIC\)\] Time: ([^|\n]+)/g,(B,ke)=>`[METADATA (PRIORITY: DYNAMIC)] Time: ${ke.replace(/:\d{2}/g,"")}`).replace(/\[\[\s*turn\s*:\s*(continue|finish)\s*\]\]/gi,"").replace(/\[\[END\]\]/g,"").replace(/\[\[(?:TOOL|ACTION) RESULTS\]\]/gi,"").replace(/\[(?:TOOL|ACTION) RESULTS?\]/gi,"").replace(/\[(?:tool|action) results\]/gi,"").replace(/\r?\n\r?\n/g,`
|
|
583
583
|
`).replace(/\n\n/g,`
|
|
584
584
|
`).replace(/\\n\\n/g,"").trim(),$e=S.role==="user"?8192:32768,re=E.substring(0,$e);E.length>$e&&(re+=`
|
|
585
|
-
... (truncated) ...`);let C=S.role==="user"?re.startsWith("[USER]")?"":"[USER]: ":re.startsWith("[AGENT]")?"":"[AGENT]: ";return{role:S.role==="user"?"user":"model",parts:[{text:`${C}${re}`}]}}),he=i.filter(S=>S.role==="user").length===1,Se=n.includes("[TITLE-UPDATE]"),
|
|
585
|
+
... (truncated) ...`);let C=S.role==="user"?re.startsWith("[USER]")?"":"[USER]: ":re.startsWith("[AGENT]")?"":"[AGENT]: ";return{role:S.role==="user"?"user":"model",parts:[{text:`${C}${re}`}]}}),he=i.filter(S=>S.role==="user").length===1,Se=n.includes("[TITLE-UPDATE]"),Ie=Math.random()<.8,xe=he||Se||Ie,k=Ft(t).trim(),x=fr($,F,xe),rt=`${k.replace(/\[(?:tool|action):(?:functions\.)?.*?\]/g,"").replace(/\[Prompted on:.*?\]/g,"").replace(/\[\[\s*turn\s*:\s*(continue|finish)\s*\]\]/gi,"").replace(/\[\[END\]\]/g,"").replace(/\[\[(?:TOOL|ACTION) RESULTS\]\]/gi,"").replace(/\[(?:TOOL|ACTION) RESULTS?\]/gi,"").replace(/\[(?:tool|action) results\]/gi,"").substring(0,32768)}`;rt.length>32768&&(rt+=`
|
|
586
586
|
... (truncated) ...`);let ve=n.replace(/\[Prompted on:.*?\]/g,"").trim();rt=rt.replace(/\r?\n\r?\n/g,`
|
|
587
587
|
`).replace(/\n\n/g,`
|
|
588
|
-
`).replace(/\\n\\n/g,"").trim();let
|
|
588
|
+
`).replace(/\\n\\n/g,"").trim();let It=new Date,Mt=`[METADATA] Current date and Time: ${`${It.getFullYear()}-${It.toLocaleString("en-US",{month:"short"}).toUpperCase()}-${String(It.getDate()).padStart(2,"0")}, ${It.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}`}
|
|
589
589
|
|
|
590
590
|
[USER]: ${ve.substring(0,8192)}
|
|
591
591
|
${ve.length>8192?`... (truncated) ...
|
|
592
592
|
|
|
593
593
|
`:""}
|
|
594
|
-
[AGENT (current turn)]: ${rt}`;A.push({role:"user",parts:[{text:
|
|
594
|
+
[AGENT (current turn)]: ${rt}`;A.push({role:"user",parts:[{text:Mt}]});let Vt=await _i("NVIDIA"),gn=(await bo()).quotas?.providerTiers?.NVIDIA==="Free",Bt="",ht=0,Le=F?12:-1;for(;ht<=Le;)try{if(!await Ss("background",e))return;let S="",E=null,$e=!1,re=y;try{let ke=new Promise((et,de)=>setTimeout(()=>de(new Error("JANITOR_TIMEOUT")),1e4)),Ce=y==="Google"&&ht>=0&&ht<6&&Vt&&gn,Te=y==="DeepSeek"&&ht<4&&Vt&&gn;$e=Ce||Te,re=$e?"NVIDIA":y;let Me=Date.now(),No=null,Bn=(async()=>{if(y==="OpenRouter"){let et=se("janitor_open_router"),ae=(await ce("OpenRouter"))(R,et,A,x,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),vt=await ae.next();return{iterator:ae,firstResult:vt}}else if(y==="DeepSeek"&&!$e){let de=(await ce("DeepSeek"))(R,se("deepseek_fast_fallback"),A,x,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),ae=await de.next();return{iterator:de,firstResult:ae}}else if(y==="Mistral"&&!$e){let de=(await ce("Mistral"))(R,se("mistral_janitor_fallback"),A,x,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),ae=await de.next();return{iterator:de,firstResult:ae}}else if(y==="NVIDIA"||$e){let de=(await ce("NVIDIA"))($e?Vt:R,se("nvidia_janitor_fallback"),A,x,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),ae=await de.next();return{iterator:de,firstResult:ae}}else if(y==="InferX"){let de=(await ce("InferX"))(R,targetModel||se("inferx_fallback")||"deepseek-v4-flash",A,x,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),ae=await de.next();return{iterator:de,firstResult:ae}}else if(y==="SenseNova"){let de=(await ce("SenseNova"))(R,targetModel||se("sensenova_fallback")||"sensenova-6.8-flash-lite",A,x,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),ae=await de.next();return{iterator:de,firstResult:ae}}else if(y==="AIHubMix"){let de=(await ce("AIHubMix"))(R,targetModel||se("aihubmix_fallback")||"gpt-4o-mini",A,x,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),ae=await de.next();return{iterator:de,firstResult:ae}}else if(y==="Poolside"){let de=(await ce("Poolside"))(R,targetModel||se("poolside_fallback")||"poolside/laguna-s-2.1",A,x,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),ae=await de.next();return{iterator:de,firstResult:ae}}else if(y==="9router"||y==="9Router"){let de=(await ce("NineRouter"))(R,targetModel||se("9router_fallback")||"z-ai/glm-5.3-flash",A,x,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),ae=await de.next();return{iterator:de,firstResult:ae}}else if(y==="ExpLabs"||y==="ExperientialLabs"){let de=(await ce("ExpLabs"))(R,targetModel||se("explabs_fallback")||"deepseek-v4-pro-0813",A,x,"Fast",f,!1,null,.7)[Symbol.asyncIterator](),ae=await de.next();return{iterator:de,firstResult:ae}}else{let ae=(await ls(R).models.generateContentStream({model:s||(ht===Le?se("janitor_default"):se("gemma_janitor_fallback_google")),contents:A,config:{systemInstruction:x,temperature:.7,safetySettings:[{category:Fn.HARM_CATEGORY_HARASSMENT,threshold:Dn.BLOCK_NONE},{category:Fn.HARM_CATEGORY_HATE_SPEECH,threshold:Dn.BLOCK_NONE},{category:Fn.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:Dn.BLOCK_NONE},{category:Fn.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:Dn.BLOCK_NONE}],thinkingConfig:{includeThoughts:!1,thinkingLevel:He.MINIMAL},serviceTier:"flex"}}))[Symbol.asyncIterator](),vt=await ae.next();return{iterator:ae,firstResult:vt}}})();if(process.stdout.isTTY){let ae=(await Pi())[g]?.name||"",vt=ae&&!ae.startsWith("flow-")&&!ae.startsWith("Session ")?ae:"FluxFlow | Idle";process.stdout.write(`\x1B]0;${vt}\x07`),process.stdout.write(`\x1B]633;P;TerminalTitle=${vt}\x07`)}let{iterator:lo,firstResult:Do}=await Promise.race([Bn,ke]);No=Date.now()-Me;let{value:hn,done:Ut}=Do;if(!Ut&&hn){let et=hn.candidates?.[0]?.content?.parts,de=et?re==="Google"?et[1]?.text||et[0]?.text||"":et.filter(ae=>ae.text&&!ae.thought).map(ae=>ae.text).join(""):typeof hn.text=="function"?hn.text():"";de&&(S+=de),E=hn.usageMetadata;for await(let ae of{[Symbol.asyncIterator]:()=>lo}){let vt=ae.candidates?.[0]?.content?.parts,co=vt?re==="Google"?vt[1]?.text||vt[0]?.text||"":vt.filter(Jn=>Jn.text&&!Jn.thought).map(Jn=>Jn.text).join(""):typeof ae.text=="function"?ae.text():"";co&&(S+=co),E=ae.usageMetadata}}}catch(ke){throw ke}if(S){if(Bt=S,E){let ke=E.totalTokenCount||0,Ce=E.cachedContentTokenCount||0,Te=(E.candidatesTokenCount||0)+(re==="Google"&&E.thoughtsTokenCount||0),Me=$e?se("nvidia_janitor_fallback"):re==="DeepSeek"?se("deepseek_fast_fallback"):re==="ExpLabs"||re==="ExperientialLabs"?se("explabs_fallback")||"deepseek-v4-pro-0813":re==="OpenRouter"?se("janitor_open_router"):s||(ht===Le?se("janitor_default"):se("gemma_janitor_fallback_google"));await ut("tokens",ke,re,Me),Ce>0&&await ut("cachedTokens",Ce,re,Me),Te>0&&await ut("candidateTokens",Te,re,Me),janitorTtft!==null&&janitorTtft>0&&await ut("ttft",janitorTtft,re,Me),xo({provider:re,model:Me,prompt:E.promptTokenCount||0,cached:Ce,output:Te,reasoning:E.thoughtsTokenCount||0,ttft:janitorTtft})}}else throw new Error("No synthesis generated by Janitor.");m&&(m(),await Rt("background"));let C=ao(Bt),B=!1;for(let ke of C){let Ce=ke.toolName;["addMemScore","add_mem_score","AddMemScore","addMemoryScore","AddMemoryScore"].includes(Ce)&&(B=!0);let Te={chatId:g,sessionId:g,history:i},Me=await Mo(Ce,ke.args,Te);Ce.toLowerCase()==="memory"&&(ke.args.includes("action='user'")||ke.args.includes('action="user"'))&&!Me.startsWith("ERROR")&&(u&&u(),process.stdout.isTTY&&(process.stdout.write("\x1B]0;Memory Updated\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=Memory Updated\x07")),await new Promise(Bn=>setTimeout(Bn,3e3)))}if(!B)try{let ke=Ct(Yn,[]);if(ke.length>0){let Ce=[];for(let Te of ke)Te.score===void 0&&(Te.score=.5),Te.score*=.99995,Te.score<.05&&(Te.score=0),Te.score=Math.round(Te.score*1e5)/1e5,Te.score>0&&Ce.push(Te);oo(Yn,Ce)}}catch{}break}catch(S){ht++;let E=new Date().toLocaleString(),$e=S instanceof Error?(()=>{try{return JSON.parse(JSON.parse(S.message).error.message).error.message}catch{return String(S)}})():String(S);await new Promise(B=>setTimeout(B,1e3));let re=G.join(En,"janitor");if(we.existsSync(re)||we.mkdirSync(re,{recursive:!0}),we.appendFileSync(G.join(re,"error.log"),`ERROR [Attempt ${ht}/${Le+1}] [${E}]: ${$e}
|
|
595
595
|
|
|
596
|
-
`),ht>Le)break;let C=Math.min(750*Math.pow(2,ht-1),5e3);await new Promise(B=>setTimeout(B,C))}if(ht){let S=
|
|
596
|
+
`),ht>Le)break;let C=Math.min(750*Math.pow(2,ht-1),5e3);await new Promise(B=>setTimeout(B,C))}if(ht){let S=G.join(En,"janitor");we.appendFileSync(G.join(S,"error.log"),`-----------------------------------------------------------------------------
|
|
597
597
|
|
|
598
|
-
`)}if(process.stdout.isTTY)try{let $e=(await
|
|
598
|
+
`)}if(process.stdout.isTTY)try{let $e=(await Pi())[g]?.name||"",re=$e&&!$e.startsWith("flow-")&&!$e.startsWith("Session ")?$e:"FluxFlow | Idle";process.stdout.write(`\x1B]0;${re}\x07`),process.stdout.write(`\x1B]633;P;TerminalTitle=${re}\x07`)}catch{process.stdout.write("\x1B]0;FluxFlow | Idle\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow | Idle\x07")}},qr=e=>{if(!e||typeof e!="string")return e;let n=e.split(""),t=!1,i=!1,o=0;for(;o<n.length;){if(n[o]==="`"&&n[o+1]==="`"&&n[o+2]==="`"){t?(n[o]=" ",n[o+1]=" ",n[o+2]=" ",t=!1):(n[o]=" ",n[o+1]=" ",n[o+2]=" ",t=!0),o+=3;continue}if(t){n[o]!==`
|
|
599
599
|
`&&n[o]!=="\r"&&(n[o]=" "),o++;continue}if(n[o]==="`"){i=!i,n[o]=" ",o++;continue}if(i){n[o]===`
|
|
600
|
-
`||n[o]==="\r"?i=!1:n[o]=" ",o++;continue}o++}return n.join("")},
|
|
601
|
-
`):null},
|
|
600
|
+
`||n[o]==="\r"?i=!1:n[o]=" ",o++;continue}o++}return n.join("")},il=e=>{let n=Ft(e),t=qr(n);Lo.lastIndex=0;let i;for(;(i=Lo.exec(t))!==null;){let o=i.index+i[0].length-1,r=0,d=null,a=!1,u=!1;for(let m=o;m<t.length;m++){let b=t[m];if(!d&&(b==='"'||b==="'"||b==="`")?(d=b,a=!1):d&&b===d&&!a&&(d=null),!d&&(b==="("?r++:b===")"&&r--,r===0)){let h=m+1;for(;h<t.length&&/\s/.test(t[h]);)h++;if(h<t.length&&t[h]==="]"){u=!0,Lo.lastIndex=h+1;break}}b==="\\"?a=!a:a=!1}if(!u)return{inside:!0,toolName:i[1],startIndex:i.index,args:n.substring(i.index+i[0].length)}}return{inside:!1}},Xr=(e,n=!0)=>{let t=Lo;t.lastIndex=0;let i="",o=0,r;for(;(r=t.exec(e))!==null;){let d=e.substring(o,r.index);i+=n&&o===0?Ft(d):d;let a=r.index+r[0].length-1,u=0,m=null,b=-1;for(let h=a;h<e.length;h++){let f=e[h];if(m){if(f===m){let s=0;for(let g=h-1;g>=0&&e[g]==="\\";g--)s++;s%2===0&&(m=null)}}else if(f==='"'||f==="'"||f==="`")m=f;else if(f==="(")u++;else if(f===")"&&(u--,u===0)){let s=h+1;for(;s<e.length&&/\s/.test(e[s]);)s++;if(s<e.length&&e[s]==="]"){b=s;break}}}if(b!==-1)i+="[tool:functions."+r[1]+"()]",o=b+1,t.lastIndex=o;else{i+="[tool:functions."+r[1]+"(",o=e.length;break}}return o<e.length&&(i+=n&&o===0?Ft(e.substring(o)):e.substring(o)),i},sl=(e,n,t)=>{let i=Lo;i.lastIndex=0;let o="",r=0,d;for(;(d=i.exec(e))!==null;){let a=e.substring(r,d.index);o+=a.replace(n,t);let u=d.index+d[0].length-1,m=0,b=null,h=-1;for(let f=u;f<e.length;f++){let s=e[f];if(b){if(s===b){let g=0;for(let T=f-1;T>=0&&e[T]==="\\";T--)g++;g%2===0&&(b=null)}}else if(s==='"'||s==="'"||s==="`")b=s;else if(s==="(")m++;else if(s===")"&&(m--,m===0)){let g=f+1;for(;g<e.length&&/\s/.test(e[g]);)g++;if(g<e.length&&e[g]==="]"){h=g;break}}}if(h!==-1)o+=e.substring(d.index,h+1),r=h+1,i.lastIndex=r;else{o+=e.substring(d.index),r=e.length;break}}return r<e.length&&(o+=e.substring(r).replace(n,t)),o},Kr=e=>Xr(e,!0),rl=e=>{if(!e)return e;let n={patchfile:"PatchFile",writefile:"WriteFile",readfile:"ReadFile",viewfile:"ReadFile",run:"Run",execcommand:"Run",searchkeyword:"SearchKeyword",codesearch:"CodeSearch",code_search:"CodeSearch",websearch:"WebSearch",webscrape:"WebScrape",readfolder:"ReadFolder",writepdf:"WritePDF",writedoc:"WriteDoc",writedocx:"WriteDoc",filemap:"FileMap",generateimage:"GenerateImage",todo:"Todo",goal:"Goal",askuser:"AskUser",ask:"AskUser"},t=o=>o.split("_").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("");Gr.lastIndex=0;let i=e.replace(Gr,(o,r,d)=>{let a="";try{let b=JSON.parse(d.trim());b&&typeof b=="object"&&(a=Object.entries(b).map(([f,s])=>{let g=typeof s=="string"?s:JSON.stringify(s);return`${f}=${JSON.stringify(g)}`}).join(", "))}catch{let h=[],f=Za;f.lastIndex=0;let s;for(;(s=f.exec(d))!==null;){let g=s[1],T=s[2]!==void 0?s[2]:s[0].split(":").slice(1).join(":").trim();h.push(`${g}=${JSON.stringify(T)}`)}h.length>0?a=h.join(", "):a=d.trim()}let u=r.toLowerCase().replace(/_/g,"");return`[tool:functions.${n[u]||t(r)}(${a})]`});return Hr.lastIndex=0,jr.lastIndex=0,i=i.replace(Hr,""),i=i.replace(jr,""),i},ao=e=>{if(!e)return[];let n=rl(e),t=Ft(n),i=[],o=qr(t),r=Va;r.lastIndex=0;let d;for(;(d=r.exec(o))!==null;){let a=d[1],u=d.index+d[0].length-1,m=0,b=null,h=-1,f=-1;for(let s=u;s<o.length;s++){let g=o[s];if(b){if(g===b){let T=0;for(let ue=s-1;ue>=0&&o[ue]==="\\";ue--)T++;T%2===0&&(b=null)}}else{if(s>u&&(o.substring(s).startsWith("[action:")||o.substring(s).startsWith("[tool:")))break;if(g==='"'||g==="'"||g==="`")b=g;else if(g==="(")m++;else if(g===")"&&(m--,m===0)){f=s;let T=s+1;for(;T<o.length&&/\s/.test(o[T]);)T++;if(T<o.length&&o[T]==="]"){h=T;break}}}}if(h!==-1){let s=t.substring(u+1,f),g=t.substring(d.index,h+1);i.push({fullMatch:g,toolName:a.trim(),args:s.trim()}),r.lastIndex=h+1}}return i},Vr=e=>{if(!e)return null;let n=Ft(e),t=[],i=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,o=[],r;for(;(r=i.exec(n))!==null;)o.push({toolName:r[1],index:r.index,parenIndex:r.index+r[0].length-1});for(let f=0;f<o.length;f++){let s=o[f],g=f+1<o.length?o[f+1].index:n.length,T=n.substring(s.index,g),ue=T.indexOf("("),y=ue!==-1?T.substring(ue+1):"",R=0,F=null,j=!1;for(let $=0;$<y.length;$++){let A=y[$];if(F){if(A===F){let he=0;for(let Se=$-1;Se>=0&&y[Se]==="\\";Se--)he++;he%2===0&&(F=null)}}else if(A==='"'||A==="'"||A==="`")F=A;else if(A==="(")R++;else if(A===")")if(R>0)R--;else{let he=$+1;for(;he<y.length&&/\s/.test(y[he]);)he++;if(he<y.length&&y[he]==="]"){j=!0;break}}}if(!j){let $=T.trim(),A="";F?A=`Unclosed quote string (${F}) inside arguments`:$.endsWith("]")?A=`Missing closing ')' before ']' (e.g. found "...]")`:$.endsWith(")")?A=`Missing closing ']' after ')' (e.g. found "...)" instead of "...)]")`:!$.includes(")")&&!$.includes("]")?A="Missing closing delimiter ')]'":A="Malformed or unclosed call syntax (missing ')]')",t.push(`\u2022 [action:${s.toolName}(...)]: ${A}. Expected: [action:${s.toolName}(arg1="...", arg2="...")]`)}}let d=/(?:^|[^\w\[])(?:tool|action):(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/gi,a;for(;(a=d.exec(n))!==null;){let f=a[1],s=a.index+(a[0].indexOf(":")-(a[0].startsWith("action")||a[0].startsWith("tool")?0:1));(s>0?n[s-1]:"")!=="["&&ai(f)&&t.push(`\u2022 action:${f}(...): Missing opening bracket '['. Expected: [action:${f}(...)]`)}let u=/\[\s*(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/g,m;for(;(m=u.exec(n))!==null;){let f=m[1];f!=="action"&&f!=="tool"&&ai(f)&&t.push(`\u2022 [${f}(...)]: Missing 'action:' prefix. Expected: [action:${f}(...)]`)}let b=/\[\s*(?:tool|action)\s*:\s*(?:functions\.)?([a-zA-Z0-9_]+)(?!\s*\()/gi,h;for(;(h=b.exec(n))!==null;){let f=h[1];ai(f)&&t.push(`\u2022 [action:${f}...]: Missing opening '(' for tool arguments. Expected: [action:${f}(...)]`)}return t.length>0?t.join(`
|
|
601
|
+
`):null},bd=(e,n={})=>{if(!e)return null;if($o=n,as=new Yr({apiKey:e}),!globalThis.__perfCleanupInstalled){globalThis.__perfCleanupInstalled=!0,setInterval(()=>{typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks())},6e4);let t=globalThis.fetch;globalThis.fetch=async(...i)=>{try{let o=await t(...i);return typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),o}catch(o){throw typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),o}}}},Jr=e=>{if(!e)return{serviceTier:void 0,cleanModel:e};let n=e.toLowerCase();return n.endsWith(":flex")?{serviceTier:"flex",cleanModel:e.slice(0,-5)}:n.endsWith(":priority")?{serviceTier:"priority",cleanModel:e.slice(0,-9)}:{serviceTier:void 0,cleanModel:e}},hi=async(e,n,t,i,o="Fast",r=.75,d="agent")=>tl(async()=>{let{aiProvider:a="Google",apiKey:u,mode:m}=e,b="",h=null,f=typeof t=="string"?[{role:"user",parts:[{text:t}]}]:t,s=new AbortController,g=s.signal,T=setInterval(()=>{gt&&(s.abort(),clearInterval(T))},100),ue=Date.now(),y=null;try{let R;if(a==="Ollama")R=(await ce("Ollama"))(u,n,f,i,o,m,st(n),g,r,e.systemSettings?.ollamaEndpoint||"Cloud");else if(a==="OpenRouter")R=(await ce("OpenRouter"))(u,n,f,i,o,m,st(n),g,r);else if(a==="DeepSeek")R=(await ce("DeepSeek"))(u,n,f,i,o,m,st(n),g,r);else if(a==="Mistral")R=(await ce("Mistral"))(u,n,f,i,o,m,st(n),g,r);else if(a==="NVIDIA")R=(await ce("NVIDIA"))(u,n,f,i,o,m,st(n),g,r);else if(a==="InferX")R=(await ce("InferX"))(u,n,f,i,o,m,st(n),g,r);else if(a==="SenseNova")R=(await ce("SenseNova"))(u,n,f,i,o,m,st(n),g,r);else if(a==="AIHubMix")R=(await ce("AIHubMix"))(u,n,f,i,o,m,st(n),g,r);else if(a==="Poolside")R=(await ce("Poolside"))(u,n,f,i,o,m,st(n),g,r);else if(a==="9router"||a==="9Router")R=(await ce("NineRouter"))(u,n,f,i,o,m,st(n),g,r);else if(a==="ExpLabs"||a==="ExperientialLabs")R=(await ce("ExpLabs"))(u,n,f,i,o,m,st(n),g,r);else if(a==="Infron"||a==="infron")R=(await ce("Infron"))(u,n,f,i,o,m,st(n),g,r);else if(a==="TokenHarbor"||a==="Token Harbor"||a==="tokenharbor"||a==="token_harbor"||a==="thk")R=(await ce("TokenHarbor"))(u,n,f,i,o,m,st(n),g,r);else if(a==="APInex"||a==="apinex"||a==="apx")R=(await ce("APInex"))(u,n,f,i,o,m,st(n),g,r);else if(a==="c_openai"||a==="Custom (OpenAI)")R=(await ce("c_openai"))(u,n,f,i,o,m,st(n),g,r,e.systemSettings?.customOpenAIBaseUrl||"");else{let F=ls(u),{serviceTier:j,cleanModel:$}=Jr(n),A={systemInstruction:i,temperature:r,thinkingConfig:(()=>{let Se=(n||"").toLowerCase(),Ie=Se.includes("gemma-4")||Se.startsWith("gemma"),xe=Se.includes("gemini-3");if(Ie||xe)return Ie?o.toLowerCase()!=="xhigh"?{includeThoughts:!1,thinkingLevel:He.MINIMAL}:{includeThoughts:!0,thinkingLevel:He.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:Se.includes("pro")?He.LOW:He.MINIMAL,Low:He.LOW,Medium:He.MEDIUM,Standard:He.MEDIUM,High:He.HIGH,xHigh:He.HIGH}[o]||He.MEDIUM};{let k={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[o]||2048;return k===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:k}}})()};j&&(A.serviceTier=j),R=await F.models.generateContentStream({model:$,contents:f,config:A},{signal:g})}for await(let F of R){if(gt)throw new Error("Subagent task was cancelled.");if(e?.taskId&&typeof Kt<"u"){let A=Kt.find(he=>he.id===e.taskId);if(A&&A.status==="cancelled")throw new Error("Subagent task was cancelled.")}y===null&&(F.candidates?.[0]?.content?.parts||F.text)&&(y=Date.now()-ue);let j="";if(F.candidates?.[0]?.content?.parts)for(let A of F.candidates[0].content.parts)A.text&&!A.thought&&(b+=A.text,j+=A.text);let $=j?Mi(j):0;e&&typeof e.onTokenChunk=="function"&&e.onTokenChunk(j,$),F.usageMetadata&&(h=F.usageMetadata)}}finally{clearInterval(T)}if(h){let R=h.totalTokenCount||0,F=h.cachedContentTokenCount||0,j=(h.candidatesTokenCount||0)+(a==="Google"&&h.thoughtsTokenCount||0);await ut("tokens",R,a,n),F>0&&await ut("cachedTokens",F,a,n),j>0&&await ut("candidateTokens",j,a,n),y!==null&&y>0&&await ut("ttft",y,a,n),xo({provider:a,model:n,prompt:h.promptTokenCount||0,cached:F,output:j,reasoning:h.thoughtsTokenCount||0,ttft:y}),e&&typeof e.onUsage=="function"&&e.onUsage({totalTokenCount:R,cachedContentTokenCount:F,candidatesTokenCount:j})}return await Rt("agent",a),{text:b,usageMetadata:h}}),al=async(e,n,t=null)=>{t=t||Ct(Yo,{});try{let{aiProvider:i="Google"}=n;if(Object.values(t).flat().length<=5)return;let r=Object.keys(t).filter(f=>f!==e&&Array.isArray(t[f])&&t[f].length>2);if(r.length===0)return;let d=`You are a silent background process for the FluxFlow CLI Agent.
|
|
602
602
|
Your task is to summarize or merge temporary context memories from one or more past conversation sessions.
|
|
603
603
|
For each Chat ID provided, you must output a tool call to save the consolidated summary.
|
|
604
604
|
|
|
@@ -613,7 +613,7 @@ Guidelines:
|
|
|
613
613
|
|
|
614
614
|
Chats to process:
|
|
615
615
|
|
|
616
|
-
`,a=Ct(
|
|
616
|
+
`,a=Ct(Ri,{});for(let f of r){let g=t[f].map(ue=>`- ${ue}`).join(`
|
|
617
617
|
`),T=a[f];d+=`[Chat ID: ${f}]
|
|
618
618
|
`,T?(d+=`- Existing Summary: "${T}"
|
|
619
619
|
`,d+=`
|
|
@@ -623,8 +623,8 @@ ${g}
|
|
|
623
623
|
`):d+=`-- Individual Memories:
|
|
624
624
|
${g}
|
|
625
625
|
|
|
626
|
-
`}let u=0,m=5,b=!1,h=se("gemma_janitor_fallback_google");for(i==="OpenRouter"&&(h=se("janitor_open_router")),i==="DeepSeek"&&(h=se("deepseek_level_1")),i==="Mistral"&&(h=se("mistral_level_1")),i==="NVIDIA"&&(h=se("nvidia_janitor_fallback")),i==="InferX"&&(h=se("inferx_fallback")),i==="SenseNova"&&(h=se("sensenova_fallback")),i==="AIHubMix"&&(h=se("aihubmix_fallback")),i==="Poolside"&&(h=se("poolside_fallback")),(i==="9router"||i==="9Router")&&(h=se("9router_fallback"));u<=m&&!b;){u++;try{let s=(await
|
|
627
|
-
`)}},
|
|
626
|
+
`}let u=0,m=5,b=!1,h=se("gemma_janitor_fallback_google");for(i==="OpenRouter"&&(h=se("janitor_open_router")),i==="DeepSeek"&&(h=se("deepseek_level_1")),i==="Mistral"&&(h=se("mistral_level_1")),i==="NVIDIA"&&(h=se("nvidia_janitor_fallback")),i==="InferX"&&(h=se("inferx_fallback")),i==="SenseNova"&&(h=se("sensenova_fallback")),i==="AIHubMix"&&(h=se("aihubmix_fallback")),i==="Poolside"&&(h=se("poolside_fallback")),(i==="9router"||i==="9Router")&&(h=se("9router_fallback"));u<=m&&!b;){u++;try{let s=(await hi(n,h,d,null,"Fast",.75,"background")).text||"",g=ao(s);if(g.length===0)throw new Error("No tool calls detected in synthesis response");for(let T of g){let ue=T.toolName;["saveSummary","saveSumary","SaveSummary","SaveSumary"].includes(ue)&&await Mo(ue,T.args,{chatId:e})}b=!0}catch(f){if(u>=m)throw new Error(`Failed after ${m} attempts. Last error: ${f.message}`)}}}catch(i){let o=i instanceof Error?(()=>{try{return JSON.parse(JSON.parse(i.message).error.message).error.message}catch{return String(i)}})():String(i),r=G.join(En,"janitor");we.existsSync(r)||we.mkdirSync(r,{recursive:!0}),we.appendFileSync(G.join(r,"error.log"),`[${new Date().toLocaleString()}] Past memory batch consolidation error: ${o}
|
|
627
|
+
`)}},xd=async(e,n,t=!1)=>{let{chatId:i,aiProvider:o="Google"}=e,r=G.join(Vo,"chat-summaries.json"),d=s=>s.filter(g=>(g.role==="user"||g.role==="agent"||g.role==="system")&&g.role!=="think"&&!g.isVisualFeedback&&!g.isMeta&&!g.isTerminalRecord&&!(g.text&&g.text.includes("[TERMINAL_RECORD]"))&&!String(g.id).startsWith("welcome")).map(g=>{let T=g.fullText||g.text||"",ue=g.role==="system"||T.startsWith("[ACTION RESULT]:")||T.startsWith("[TOOL RESULT]:")||g.text&&(g.text.startsWith("[ACTION RESULT]:")||g.text.startsWith("[TOOL RESULT]:")),y=T;return ue&&(T.includes("[ACTION RESULT]:")||T.includes("[TOOL RESULT]:")||g.text&&(g.text.includes("[ACTION RESULT]:")||g.text.includes("[TOOL RESULT]:")))?y="[ACTION RESULT]: ...truncated for summary":y=y.replace(/(\[(?:tool|action):[a-zA-Z0-9_\.]+)\([\s\S]*?\)(\])/g,"$1(...)$2"),`[${ue?"ACTION":g.role==="agent"?"AGENT":"USER"}]: ${y}`}).join(`
|
|
628
628
|
|
|
629
629
|
`),a=async(s,g)=>{let T="You are an expert context summarizer. Summarize the provided chat history (which may include previous summaries, user instructions, agent outputs, and tool results) into a detailed, coherent, and highly technical summary of 1000 to 1500 words. Focus on preserving the architectural decisions made, current system state, task progress, and critical code details, chat messages, file changes. Under no circumstances exceed MAX 2000 words.",ue=g?`Here is the previous summary:
|
|
630
630
|
${g}
|
|
@@ -635,9 +635,9 @@ ${s}
|
|
|
635
635
|
Provide a new consolidated summary of the entire session.`:`Here is the conversation history:
|
|
636
636
|
${s}
|
|
637
637
|
|
|
638
|
-
Provide a consolidated summary of the entire session.`,y=se("gemma_janitor_fallback_google");o==="OpenRouter"&&(y=se("janitor_open_router")),o==="DeepSeek"&&(y=se("deepseek_level_1")),o==="Mistral"&&(y=se("mistral_level_1")),o==="NVIDIA"&&(y=se("nvidia_chat_summarizer_fallback")),o==="InferX"&&(y=se("inferx_fallback")),o==="SenseNova"&&(y=se("sensenova_fallback")),o==="AIHubMix"&&(y=se("aihubmix_fallback")),o==="Poolside"&&(y=se("poolside_fallback")),(o==="9router"||o==="9Router")&&(y=se("9router_fallback")),(o==="ExpLabs"||o==="ExperientialLabs")&&(y=se("explabs_fallback")||"deepseek-v4-pro-0813"),(o==="TokenHarbor"||o==="Token Harbor"||o==="tokenharbor"||o==="token_harbor"||o==="thk")&&(y=se("tokenharbor_fallback")||"deepseek-v4.1-flash:free"),(o==="Infron"||o==="infron")&&(y=se("infron_fallback"));let R=0,F=!1,
|
|
639
|
-
`),S=Ct(
|
|
640
|
-
`),E=(f?.tokens||0)>=1e4,$e=new Date,re=$e.getFullYear(),C=$e.toLocaleString("en-US",{month:"short"}).toUpperCase(),B=String($e.getDate()).padStart(2,"0"),Ce=`${$e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}`,Te=O=>{try{return we.readdirSync(O,{withFileTypes:!0})}catch{return[]}},
|
|
638
|
+
Provide a consolidated summary of the entire session.`,y=se("gemma_janitor_fallback_google");o==="OpenRouter"&&(y=se("janitor_open_router")),o==="DeepSeek"&&(y=se("deepseek_level_1")),o==="Mistral"&&(y=se("mistral_level_1")),o==="NVIDIA"&&(y=se("nvidia_chat_summarizer_fallback")),o==="InferX"&&(y=se("inferx_fallback")),o==="SenseNova"&&(y=se("sensenova_fallback")),o==="AIHubMix"&&(y=se("aihubmix_fallback")),o==="Poolside"&&(y=se("poolside_fallback")),(o==="9router"||o==="9Router")&&(y=se("9router_fallback")),(o==="ExpLabs"||o==="ExperientialLabs")&&(y=se("explabs_fallback")||"deepseek-v4-pro-0813"),(o==="TokenHarbor"||o==="Token Harbor"||o==="tokenharbor"||o==="token_harbor"||o==="thk")&&(y=se("tokenharbor_fallback")||"deepseek-v4.1-flash:free"),(o==="Infron"||o==="infron")&&(y=se("infron_fallback"));let R=0,F=!1,j=null;for(;R<=3&&!F;){R++;try{j=await hi(e,y,ue,T,"Fast"),F=!0}catch{if(R>3){if(o==="Google")try{let A=se("general_fallback");return(await hi(e,A,ue,T,"Fast")).text||""}catch{return""}return""}}}return j&&j.text||""},u=d(n),m=Ct(r,{}),b=m[i]||{summary:"",historyLength:0};typeof b=="string"&&(b={summary:b,historyLength:0});let h=b.summary||"",f=await a(u,h);if(f){b.summary=f;let s=nl(n);return t?b.historyLength=(b.historyLength||0)+s:b.historyLength=s,m[i]=b,oo(r,m),f}return null},wd=e=>{try{let n=G.join(Vo,"chat-summaries.json");if(we.existsSync(n)){let t=Ct(n,{});t[e]&&(delete t[e],oo(n,t))}}catch{}},Sd=async function*(e,n,t,i,o){let{profile:r,thinkingLevel:d,mode:a,janitorModel:u,chatId:m,isPlayground:b,systemSettings:h,sessionStats:f,aiProvider:s="Google",apiTier:g,wildcardTooling:T,wildercardTooling:ue}=t,y=st(e);if(!as&&s==="Google")throw new Error("AI not initialized");let R=process.env.NVIDIA_BASE_URL||t?.aiProvider==="Ollama"||t?.aiProvider==="InferX"||t?.aiProvider==="SenseNova"||t?.aiProvider==="AIHubMix"||t?.aiProvider==="Poolside"||t?.aiProvider==="9router"||t?.aiProvider==="ExpLabs"||t?.aiProvider==="ExperientialLabs"||t?.aiProvider==="TokenHarbor"||t?.aiProvider==="Token Harbor"||t?.aiProvider==="tokenharbor"||t?.aiProvider==="token_harbor"||t?.aiProvider==="thk"||t?.aiProvider==="APInex"||t?.aiProvider==="apinex"||t?.aiProvider==="apx"||t?.aiProvider==="Infron"||t?.aiProvider==="infron"||t?.aiProvider==="c_openai"||t?.aiProvider==="Custom (OpenAI)"?!1:h?.memory!==!1,F=n[n.length-1].text,j=G.join(Vo,"chat-summaries.json"),$=!1,A=n.filter(k=>k.role==="user").length===1,he=F.includes("[TITLE-UPDATE]"),Se=A||he,Ie=F.replace(/\[TITLE-UPDATE\]/g,"").trim();Ie=Ie.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),yield{type:"status",content:"[start]"},yield{type:"status",content:"Gathering Context"},await Xo.startTransaction(m,Ie),h?.advanceRollback&&await wo.takeInitialSnapshot(m),gt=!1;let xe=null;try{let k=new AbortController;xe=setInterval(()=>{gt&&(k.abort(),xe&&(clearInterval(xe),xe=null))},400);let x=[...n.slice(0,-1)];{let Be=Ct(j,{})[m]||{summary:"",historyLength:0};if(Be.summary&&Be.historyLength>0){let pn=0,qe=[];for(let Ae=0;Ae<x.length;Ae++){let Xe=x[Ae];(Xe.role==="user"||Xe.role==="agent"||Xe.role==="system")&&!String(Xe.id).startsWith("welcome")&&!Xe.isMeta&&pn++,pn>Be.historyLength&&qe.push(Xe)}x=qe}}x=x.map(O=>{if(O.role==="user"&&O.text){let Be=O.text.match(/\[USER\]([\s\S]*?)\[\/USER\]/);if(Be)return{...O,text:Be[1].trim()}}return{...O}});let rt=process.env.HIGH_CONTEXT,ve=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1,Mt={"16k":16e3,"32k":32e3,"64k":64e3,"128k":128e3,"256k":256e3,"512k":512e3,"1M":1e6}[h?.contextLength]||256e3;if(rt&&rt!=="false"){let O=parseInt(rt,10);!isNaN(O)&&O>=0&&O<=1e6&&(Mt=O)}if((s==="NVIDIA"&&(e?.includes("gpt")||e?.includes("qwen")||e?.includes("medium")||e.includes("muse"))||s==="Mistral")&&(Mt=126e3),s==="Google"&&e?.includes("gemma")&&ve&&(Mt=16e3),(f?.tokens||0)>Mt){yield{type:"text",content:"\u2726 Maximum Context Limit Reached. Start a new chat."};return}if(A&&R){let O=Ct(Yo,{});Object.values(O).flat().length>5&&(yield{type:"status",content:"Condensing past chat memories"},await al(m,t,O))}let Vt=Ct(Yo,{}),un=Ct(Ri,{}),gn=Object.entries(Vt).filter(([O])=>O!==m).flatMap(([O,Be])=>Be),ht=[...Object.entries(un).filter(([O])=>O!==m).slice(-20).map(([O,Be])=>`[Chat Summary]: ${Be}`),...gn].map(O=>`- ${O}`).join(`
|
|
639
|
+
`),S=Ct(Yn,[]).map(O=>`- ${O.memory}`).join(`
|
|
640
|
+
`),E=(f?.tokens||0)>=1e4,$e=new Date,re=$e.getFullYear(),C=$e.toLocaleString("en-US",{month:"short"}).toUpperCase(),B=String($e.getDate()).padStart(2,"0"),Ce=`${$e.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}`,Te=O=>{try{return we.readdirSync(O,{withFileTypes:!0})}catch{return[]}},Me=Array.from(new Set([...po,...yo(process.cwd())])),No=(O,Be=6)=>h?.indentationTree!==!1?ts(O,Be,1,Te,Me):os(O,Be,"",1,Te,Me),Bn=Ct(vi,{}),lo=Bn[m],Do=lo?lo!==process.cwd():!1;Bn[m]=process.cwd(),oo(vi,Bn);let hn=Ct(j,{}),Ut=hn[m]||{summary:"",historyLength:0};typeof Ut=="string"&&(Ut={summary:Ut,historyLength:0});let et=n.filter(O=>(O.role==="user"||O.role==="agent"||O.role==="system")&&!String(O.id).startsWith("welcome")&&!O.isMeta).length;Ut.historyLength&&et<Ut.historyLength&&(Ut.summary="",Ut.historyLength=0,hn[m]=Ut,oo(j,hn));let de=typeof Ut=="object"?Ut.summary||"":Ut||"",ae=x.length>0;ae&&de&&x[0]&&(x[0].role==="user"||x[0].role==="system")&&(x[0].text.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")||(x[0].text=`[SYSTEM METADATA]
|
|
641
641
|
**CONTEXT SUMMARY OF PREVIOUS TURNS (PRIORITY: DYNAMIC)**
|
|
642
642
|
${de}
|
|
643
643
|
|
|
@@ -645,12 +645,12 @@ ${de}
|
|
|
645
645
|
[SYSTEM METADATA]
|
|
646
646
|
**CONTEXT SUMMARY OF PREVIOUS TURNS**
|
|
647
647
|
${de}
|
|
648
|
-
`:"",
|
|
648
|
+
`:"",co=!!h?.dynamicDirAwareness,Jn=`${m}|${s}|${d}|${e}|${r}|${co}`,Qr=!co&&qn.key===Jn&&qn.value?"":`
|
|
649
649
|
**Directory**
|
|
650
650
|
CWD: `+process.cwd()+`${b?" [PLAYGROUND MODE]":""}
|
|
651
|
-
`+
|
|
651
|
+
`+No(process.cwd(),6),at=await zn(),mn="";if(ui()&&at.file_focused!=="none"){mn=`
|
|
652
652
|
[Additional IDE Context]
|
|
653
|
-
`;let O=
|
|
653
|
+
`;let O=G.relative(process.cwd(),at.file_focused),Be=(at.opened_editors||[]).map(qe=>{let Ae=G.relative(process.cwd(),qe);return Ae.startsWith("..")?`[External] ${G.basename(qe)}`:Ae});if(mn+=`Focused File: ${O}
|
|
654
654
|
Cursor Line: ${at.cursor_line}
|
|
655
655
|
`,at.selected){let qe=at.selected,Ae=qe.split(`
|
|
656
656
|
`);Ae.length>256&&(qe=Ae.slice(0,240).join(`
|
|
@@ -659,9 +659,9 @@ Cursor Line: ${at.cursor_line}
|
|
|
659
659
|
`+Ae.slice(-16).join(`
|
|
660
660
|
`)),qe.length>2048&&(qe=qe.slice(0,1920)+`
|
|
661
661
|
... [truncated] ...
|
|
662
|
-
`+qe.slice(-128)),
|
|
662
|
+
`+qe.slice(-128)),mn+=`Current Selection: "${qe}"
|
|
663
663
|
`}if(at.manual_edits){let Ae=at.manual_edits.split(`
|
|
664
|
-
`),Xe=[],Ve=null;for(let P of Ae)P.trim()&&(P.startsWith(" Line ")?Ve&&Ve.edits.push(P):(Ve={path:P.endsWith(":")?P.slice(0,-1):P,edits:[]},Xe.push(Ve)));for(let P of Xe)P.edits.length>80&&(P.edits=P.edits.slice(-80)),P.originalEditsCount=P.edits.length;let Je=(P,Ne)=>Ne.reduce((lt,Zt)=>{let mt=at.file_focused&&(Zt.path===at.file_focused||
|
|
664
|
+
`),Xe=[],Ve=null;for(let P of Ae)P.trim()&&(P.startsWith(" Line ")?Ve&&Ve.edits.push(P):(Ve={path:P.endsWith(":")?P.slice(0,-1):P,edits:[]},Xe.push(Ve)));for(let P of Xe)P.edits.length>80&&(P.edits=P.edits.slice(-80)),P.originalEditsCount=P.edits.length;let Je=(P,Ne)=>Ne.reduce((lt,Zt)=>{let mt=at.file_focused&&(Zt.path===at.file_focused||G.resolve(process.cwd(),Zt.path)===G.resolve(at.file_focused))?Math.ceil(P*1.2):P;return lt+Math.min(Zt.edits.length,mt)},0),Yt=80;if(Je(80,Xe)>300){let P=!1;for(let Ne=80;Ne>=10;Ne--)if(Je(Ne,Xe)<=300){Yt=Ne,P=!0;break}P||(Yt=10)}let Ee=[...Xe];if(Yt===10&&Je(10,Ee)>500)for(;Ee.length>0&&Je(10,Ee)>500;){let P=0,Ne=Ee[0].originalEditsCount;for(let lt=1;lt<Ee.length;lt++)Ee[lt].originalEditsCount<Ne&&(Ne=Ee[lt].originalEditsCount,P=lt);Ee.splice(P,1)}for(let P of Ee){let lt=at.file_focused&&(P.path===at.file_focused||G.resolve(process.cwd(),P.path)===G.resolve(at.file_focused))?Math.ceil(Yt*1.2):Yt;P.edits.length>lt&&(P.edits=P.edits.slice(-lt))}for(let P of Ee){let Ne=`${P.path}:
|
|
665
665
|
${P.edits.join(`
|
|
666
666
|
`)}`;for(;P.edits.length>0&&Ne.length>4*768;)P.edits.shift(),Ne=`${P.path}:
|
|
667
667
|
${P.edits.join(`
|
|
@@ -669,147 +669,147 @@ ${P.edits.join(`
|
|
|
669
669
|
`);for(;Ee.length>0&&fe.length>4*2048;){Ee[0].edits.length>0?Ee[0].edits.shift():Ee.shift();for(let P of Ee){let Ne=`${P.path}:
|
|
670
670
|
${P.edits.join(`
|
|
671
671
|
`)}`;Ne.length>4*768?P.stringRepresentation="... "+Ne.slice(-(4*768-4)):P.stringRepresentation=Ne}fe=Ee.map(P=>P.stringRepresentation).join(`
|
|
672
|
-
`)}fe.length>4*2048&&(fe="... "+fe.slice(-(4*2048-4))),
|
|
672
|
+
`)}fe.length>4*2048&&(fe="... "+fe.slice(-(4*2048-4))),mn+=`Recent Manual Edits:
|
|
673
673
|
${fe}
|
|
674
|
-
`}Be.length>0&&(
|
|
674
|
+
`}Be.length>0&&(mn+=`All Opened Editors: ${Be.join(", ")}`),at.diagnostics&&(mn+=`
|
|
675
675
|
**Active File Errors**:
|
|
676
676
|
${at.diagnostics}
|
|
677
|
-
`),(
|
|
677
|
+
`),(Ie.toLowerCase().includes("lint")||Ie.toLowerCase().includes("warning"))&&at.warnings&&(mn+=`
|
|
678
678
|
**Lint Warnings**:
|
|
679
679
|
${at.warnings}
|
|
680
|
-
`)}let
|
|
680
|
+
`)}let cs=Ie.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),ds=/(?:\\)?@\[([^\]]+)\]/g,mi,pi=[];for(ds.lastIndex=0;(mi=ds.exec(cs))!==null;){let O=mi[0].startsWith("\\");pi.push({tag:mi[1],isEscaped:O})}let yi=[],Fo=null;for(let O=0;O<pi.length;O++){let{tag:Be,isEscaped:pn}=pi[O];if(!pn)try{let qe=Be.trim().replace(/^["']|["']$/g,""),Ae=/[:#]L?(\d+)(?:-L?(\d+))?$/i,Xe=qe.match(Ae),Ve=qe,Je=null,Yt=null;Xe&&(Je=parseInt(Xe[1],10),Yt=Xe[2]?parseInt(Xe[2],10):Je,Ve=qe.slice(0,Xe.index));let Ee=G.resolve(process.cwd(),Ve);if(we.existsSync(Ee)&&we.statSync(Ee).isFile()){let P=Ve.toLowerCase(),Ne=P.endsWith(".pdf"),lt=P.endsWith(".docx")||P.endsWith(".doc")||P.endsWith(".ppt")||P.endsWith(".pptx")||P.endsWith(".xls")||P.endsWith(".xlsx"),Zt=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(P),De=Zt||Ne||lt,mt=s==="Google"||st(e);if(De&&!mt){let Re=`\u2718 Unsupported Modality: ${G.basename(Ve)}`,tt=115;process.stdout.isTTY&&(tt=process.stdout.columns-5||120);let zt=[Re],Ue=Math.max(...zt.map(en=>en.length)),ee=Math.min(Ue+4,tt),We=zt.map(en=>`${en.padEnd(ee-2).substring(0,ee-2)}`).join(`
|
|
681
681
|
`);yield{type:"visual_feedback",content:Dt(`${We}
|
|
682
|
-
`)};continue}if(Je===null&&!De){let Re=0;try{Re=we.readFileSync(Ee,"utf8").split(/\r\n|\r|\n/).length}catch{}if(Re>300){let tt=`\u21B7 Skipped (Too Large): ${
|
|
683
|
-
`)};continue}}let
|
|
682
|
+
`)};continue}if(Je===null&&!De){let Re=0;try{Re=we.readFileSync(Ee,"utf8").split(/\r\n|\r|\n/).length}catch{}if(Re>300){let tt=`\u21B7 Skipped (Too Large): ${G.basename(Ve)}`,zt=115;process.stdout.isTTY&&(zt=process.stdout.columns-5||120);let Ue=Math.min(tt.length+4,zt),ee=tt.padEnd(Ue-2).substring(0,Ue-2);yield{type:"visual_feedback",content:Dt(`${ee}
|
|
683
|
+
`)};continue}}let yn=Je!==null?Je:1,Ot=Yt!==null?Yt:Je!==null?Je:yn+299;Ot-yn>300&&(Ot=yn+300);let Un=`path=${JSON.stringify(Ve)}, startLine=${yn}, endLine=${Ot}`,Wt=await vs(Un,{isMultiModal:mt}),vn=!1,Qn="",pt=null;if(typeof Wt=="string"?Wt.trim().startsWith("ERROR")?vn=!0:Qn=Wt:Wt&&typeof Wt=="object"&&Wt.binaryPart?(pt=Wt.binaryPart,Qn=Wt.text||""):vn=!0,!vn){let Re="";if(Zt?(Re=`\u2714 Processed: ${G.basename(Ve)}`,Fo=pt):Ne||lt?(Re=`\u2714 Auto-Analysed: ${G.basename(Ve)}`,Fo=pt):(Re=`\u2714 Auto-Read: ${G.basename(Ve)}`,yi.push(Qn)),Re){let tt=115;process.stdout.isTTY&&(tt=process.stdout.columns-5||120);let zt=[Re],Ue=Math.max(...zt.map(en=>en.length)),ee=Math.min(Ue+4,tt),We=zt.map(en=>`${en.padEnd(ee-2).substring(0,ee-2)}`).join(`
|
|
684
684
|
`);yield{type:"visual_feedback",content:Dt(`${We}
|
|
685
|
-
`)}}}}}catch{}}let
|
|
685
|
+
`)}}}}}catch{}}let bi="";yi.length>0&&(bi=`
|
|
686
686
|
[Tagged File Contents] Auto Read User Tagged files by System, No need to re-read
|
|
687
|
-
`+
|
|
687
|
+
`+yi.join(`
|
|
688
688
|
|
|
689
689
|
`)+`
|
|
690
690
|
[Tagged File Contents]
|
|
691
|
-
`);let
|
|
692
|
-
`:"",
|
|
693
|
-
`:""}`:"",
|
|
694
|
-
WARNING: CWD Changed from previous: "${
|
|
695
|
-
`:""}${
|
|
691
|
+
`);let fs=cs.replace(/\\(@\[[^\]]+\])/g,"$1"),us=T?`You cannot execute tools. Instead write the action string in chat you WOULD have written
|
|
692
|
+
`:"",Zr=process.env.forcedReasoning||!1,gs=d!=="Fast"&&(s==="Mistral"&&!qo(e)||d!=="High"&&s==="Google")?`${s==="Mistral"&&!qo(e)||e.toLowerCase().startsWith("gemma")||Zr?`[system] strictly follow thinking policy as high priority. do not start a response without <think>...</think> [/system]
|
|
693
|
+
`:""}`:"",Bo="",ea=!!h?.autoExcludeMetadata,ta=!!(mn||bi||us||vt||gs||Do||h?.dynamicDirAwareness||h?.autoTruncateResults);ea&&!ta?Bo=fs.trim():Bo=`[System Metadata] Time: ${Ce}${Do?`
|
|
694
|
+
WARNING: CWD Changed from previous: "${lo}" to current: "${process.cwd()}", write change in chat to avoid future path mismatches
|
|
695
|
+
`:""}${mn}
|
|
696
696
|
Action format: [action:ActionName(...)]
|
|
697
697
|
[/Metadata]
|
|
698
|
-
${vt}${
|
|
698
|
+
${vt}${gs}${bi}${us}[user prompt] ${fs.trim()} [/user prompt]`.trim();let hs={role:"user",text:Bo};Fo&&(hs.binaryPart=Fo),x.forEach(O=>{O.text&&O.role==="agent"&&(O.text=Ft(O.text))}),x.push(hs),vt&&n[n.length-1]?.id&&(yield{type:"summary_injected",content:{id:n[n.length-1].id,text:Bo}});let Qt=null,Rn=a==="Flux"?50:15;Rn=a.toLowerCase().includes("cu")?75:Rn;let na=Math.floor(Rn/2),ms=0,sn=16;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Consulting the spirits":"Connecting"},gt=!1;let xi=[],Uo=!1,ps=!1;for(let O=0;O<=Rn;O++){let Be=Math.floor(Rn*.95);if(O>=Be&&ms<Be&&typeof t?.onAskUser=="function"){ms=Be;try{let te="Agent has been running for a long time. Do you want to continue execution?",oe=[{id:"continue",label:"Continue",description:"Add few more steps"},{id:"cancel",label:"Cancel",description:"Stop extending and finish current turn limit"}],H=await t.onAskUser(te,oe);H&&(H.toLowerCase().includes("continue")||H==="Continue")&&(Rn+=na)}catch{}}let pn=await Ii("agent",t);if(!pn.allowed)throw new Error(pn.reason||`Budget Exhausted for Provider (${s||"Agent"})`);let qe=[];if(Uo=!1,a==="ICU"||a==="FluxCU")try{yield{type:"status",content:"Capturing Screen"},await new Promise(H=>setTimeout(H,1e3));let{captureGriddedScreenshot:te}=await import("./screen_grid-4Z2EBIB2.js"),oe=await te();if(oe&&oe.base64){let H="[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]",yt={inlineData:{mimeType:oe.mimeType,data:oe.base64}},bt=h?.imageHistoryCU||"Standard",xt=bt==="Low"?3:bt==="Extended"?10:bt==="Max"?999:5,Gt=x.filter(Fe=>Array.isArray(Fe.parts)&&Fe.parts.some(wt=>wt.inlineData));if(Gt.length>=xt){let Fe=Gt.length-xt+1;for(let wt=0;wt<Fe;wt++){let kt=Gt[wt];Array.isArray(kt.parts)&&(kt.parts=kt.parts.filter(St=>!St.inlineData))}}if(x.length>0&&x[x.length-1].role==="user"){let Fe=x[x.length-1];typeof Fe.text=="string"&&(Fe.text+=`
|
|
699
699
|
|
|
700
|
-
${
|
|
700
|
+
${H}`,Array.isArray(Fe.parts)||(Fe.parts=[{text:Fe.text}]),Fe.parts.push(yt))}else x.push({role:"user",text:H,parts:[{text:H},yt]})}}catch(te){console.error("Vision screenshot capture error:",te)}if(h?.compression===0&&(f?.tokens||0)>Mt&&(x=Rs(x,6)),O>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"},gt){try{let{clearPendingNudges:te}=await import("./subagent_state-LZCOZSUJ.js");te()}catch{}yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
|
|
701
701
|
|
|
702
|
-
\x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}try{let{consumePendingNudges:
|
|
702
|
+
\x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}try{let{consumePendingNudges:te}=await import("./subagent_state-LZCOZSUJ.js"),oe=te();if(oe&&oe.length>0){let H=oe.join(`
|
|
703
703
|
|
|
704
704
|
`);x.length>0&&x[x.length-1].role==="user"?x[x.length-1].text+=`
|
|
705
705
|
|
|
706
|
-
${
|
|
706
|
+
${H}`:x.push({role:"user",text:H}),yield{type:"status",content:"Subagent Update"}}}catch{}if(i){let te=await i();te&&(te.startsWith("/btw")?x.length>0&&x[x.length-1].role==="user"?x[x.length-1].text+=`
|
|
707
707
|
|
|
708
708
|
[system] User question. Resolve this specific query within '[ANSWER]...[/ANSWER]' concisely, naturally [/system]
|
|
709
|
-
[question] ${
|
|
710
|
-
[question] ${
|
|
709
|
+
[question] ${te.replace("/btw","").trim()} [/question]`:x.push({role:"user",text:`[system] User question. Resolve this specific query within '[ANSWER]...[/ANSWER]' concisely, naturally [/system]
|
|
710
|
+
[question] ${te.replace("/btw","").trim()} [/question]`}):x.length>0&&x[x.length-1].role==="user"?x[x.length-1].text+=`
|
|
711
711
|
|
|
712
|
-
[STEERING HINT from USER, High Priority] ${
|
|
712
|
+
[STEERING HINT from USER, High Priority] ${te.trim()} [/STEERING HINT]`:x.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${te.trim()} [/STEERING HINT]`}),yield{type:"status",content:`${te.startsWith("/btw")?"Question Forwarded...":"Steering Hint Injected..."}`})}let Ae,Xe=!1,Ve=1,Je=1,Yt=Date.now(),Ee=null,fe="",P=null,Ne=null,lt=null,Zt=0,De=[],mt=0,yn=!1,Ot=!1,Un=!1,Wt=!1,vn=!0,Qn=0,pt="",Re="",tt=!1,zt=!1,Ue=!0,ee=e,We="",en=d;for(d=d.toLowerCase()==="max"?"High":d;Ve<=sn&&Je<=sn&&!Xe&&!gt;){let te=!1;try{fe="",vn&&(process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07"),yield{type:"turn_reset",content:!0},vn=!1,Je===1&&(pt=""));let oe=p=>{if(!p||typeof p!="string")return p;let _="",v=ss(p);if(v&&(_=v.fullBlock,p=v.remainingText),!p.includes("[tool:")&&!p.includes("[action:"))return(h?.keepReasoningContext?_:"")+p;if(ao(p).length===0){let w=gi(p);return(h?.keepReasoningContext?_:"")+w}p=p.replace(el,(w,I)=>I.includes("[tool:")||I.includes("[action:")?I.trim():w);let ie="",N=0,K=[],ct="";for(;N<p.length;){let w=p.indexOf("[tool:",N),I=p.indexOf("[action:",N),Q=-1;if(w!==-1&&I!==-1?Q=Math.min(w,I):w!==-1?Q=w:Q=I,Q===-1){K.length===0&&(ie+=gi(p.substring(N)));break}if((Q>0?p[Q-1]:"")==="`"){ie+=gi(p.substring(N,Q+1)),N=Q+1;continue}K.length===0&&(ct=gi(p.substring(N,Q)));let z=-1,M=null,dt=0;for(let Pt=Q;Pt<p.length;Pt++){let Z=p[Pt];if(M){if(Z===M){let je=0;for(let ft=Pt-1;ft>=0&&p[ft]==="\\";ft--)je++;je%2===0&&(M=null)}}else if(Z==='"'||Z==="'"||Z==="`")M=Z;else if(Z==="(")dt++;else if(Z===")")dt--;else if(Z==="]"&&dt<=0){z=Pt;break}}if(z===-1){K.length===0&&(ie+=p.substring(Q));break}let xn=p.substring(Q,z+1);K.push(xn),N=z+1}return K.length>0&&(ie=ct.trimEnd()?ct.trimEnd()+`
|
|
713
713
|
|
|
714
|
-
`+
|
|
714
|
+
`+K.join(`
|
|
715
715
|
|
|
716
|
-
`):
|
|
716
|
+
`):K.join(`
|
|
717
717
|
|
|
718
|
-
`)),(h?.keepReasoningContext?_:"")+ie},
|
|
718
|
+
`)),(h?.keepReasoningContext?_:"")+ie},H=x.filter(p=>(p.role==="user"||p.role==="agent"||p.role==="system")&&!String(p.id).startsWith("welcome")&&!p.isMeta&&!p.isTerminalRecord&&!(p.text&&p.text.startsWith("[TERMINAL_RECORD]"))).map((p,_,v)=>{let X=p.text||"";R||(X=X.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),p.role==="agent"&&(X=oe(X),X=X.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),X=X.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*"));let ie=[];return Array.isArray(p.parts)&&p.parts.length>0?ie=p.parts.map(N=>{if(N.text){let K=N.text;return R||(K=K.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),p.role==="agent"&&(K=oe(K),K=K.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),K=K.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*")),{text:K}}return N}):ie=[{text:X}],p.binaryPart&&st(ee)&&v.slice(_+1).filter(K=>K.role==="user"&&!K.text?.startsWith("[ACTION RESULT]")&&!K.text?.startsWith("[TOOL RESULT]")).length<=2&&ie.push(p.binaryPart),{role:p.role==="user"||p.role==="system"?"user":"model",parts:ie}});for(let p=H.length-2;p>=0;p--){let _=H[p],v=H[p+1];_.role==="user"&&v.role==="user"&&(v.parts?.[0]?.text||"").trim().startsWith("[SYSTEM")&&H.splice(p,1)}let yt=[];for(let p=0;p<H.length;p++){let _=H[p];if(yt.length===0)yt.push(_);else{let v=yt[yt.length-1];v.role===_.role?(v.parts[0].text+=`
|
|
719
719
|
|
|
720
|
-
`+(_.parts?.[0]?.text||""),_.parts?.length>1&&v.parts.push(..._.parts.slice(1))):yt.push(_)}}for(let p of yt)for(let _ of p.parts||[])_&&typeof _.text=="string"&&(_.text.includes("[action:")||_.text.includes("[tool:"))&&(_.text=_.text.replace(/```(?:[a-zA-Z0-9_-]+)?\s*\n?(\[(?:action|tool):[\s\S]*?\)\s*\])\n?```/gi,"$1"),_.text=_.text.replace(/`(\[(?:action|tool):[\s\S]*?\)\s*\])`/gi,"$1"));
|
|
721
|
-
${
|
|
720
|
+
`+(_.parts?.[0]?.text||""),_.parts?.length>1&&v.parts.push(..._.parts.slice(1))):yt.push(_)}}for(let p of yt)for(let _ of p.parts||[])_&&typeof _.text=="string"&&(_.text.includes("[action:")||_.text.includes("[tool:"))&&(_.text=_.text.replace(/```(?:[a-zA-Z0-9_-]+)?\s*\n?(\[(?:action|tool):[\s\S]*?\)\s*\])\n?```/gi,"$1"),_.text=_.text.replace(/`(\[(?:action|tool):[\s\S]*?\)\s*\])`/gi,"$1"));H.length=0,H.push(...yt),ee=e;let bt=`${m}|${s}|${a}|${d}|${en}|${ee}|${JSON.stringify(r)}|${!!h?.dynamicDirAwareness}|${!!h?.subAgents}`,xt=qn.key===bt&&qn.value;if((process.env.I_HAVE_TOO_MUCH_MONEY==="true"||process.env.I_HAVE_TOO_MUCH_MONEY===!0)&&(xt=!1),xt)We=qn.value;else{let p=s==="Mistral"?!!qo(ee):!(ee||"gemma").toLowerCase().startsWith("gemma");We=dr(r,((ee||"gemma").toLowerCase().startsWith("gemma"),en),a,h,R,A,s,s==="Google"?!0:y,p,m,!!h?.keepReasoningContext,ee),h?.dynamicDirAwareness||(We+=`
|
|
721
|
+
${Qr.replace(`
|
|
722
722
|
**Directory**`,`
|
|
723
|
-
-- Directory --`)}`),
|
|
723
|
+
-- Directory --`)}`),qn.key=bt,qn.value=We}let Fe=H[H.length-1];if(ui()&O>0){await new Promise(v=>setTimeout(v,2500)),yield{type:"status",content:"Verifying"};let p=await zn(),_=p?p.diagnostics:null;_&&Fe&&Fe.role==="user"&&Fe.parts?.[0]?.text&&(Fe.parts[0].text+=`
|
|
724
724
|
|
|
725
|
-
${_} [/ERROR]`),yield{type:"status",content:"Working"}}let wt=s==="Mistral"||s==="Google"&&e?.toLowerCase().startsWith("gemma");if(h?.advanceRollback&&Fe&&Fe.role==="user"&&(Fe.parts?.[0]?.text?.startsWith("[ACTION RESULT]")||Fe.parts?.[0]?.text?.startsWith("[TOOL RESULT]")))try{let p=await
|
|
725
|
+
${_} [/ERROR]`),yield{type:"status",content:"Working"}}let wt=s==="Mistral"||s==="Google"&&e?.toLowerCase().startsWith("gemma");if(h?.advanceRollback&&Fe&&Fe.role==="user"&&(Fe.parts?.[0]?.text?.startsWith("[ACTION RESULT]")||Fe.parts?.[0]?.text?.startsWith("[TOOL RESULT]")))try{let p=await wo.getLatestFileChanges(m);if(p&&(p.newFiles.length>0||p.modifiedFiles.length>0||p.deletedFiles.length>0)){let _=`
|
|
726
726
|
[system] File Changes:
|
|
727
727
|
`;for(let X of p.newFiles)_+=`* ${X} (created)
|
|
728
728
|
`;for(let X of p.modifiedFiles)_+=`* ${X} (modified)
|
|
729
729
|
`;for(let X of p.deletedFiles)_+=`* ${X} (deleted)
|
|
730
|
-
`;_+="[/system]",Fe.parts[0].text+=_;let v=-1;for(let X=x.length-1;X>=0;X--)if(x[X].role==="user"&&(x[X].text?.startsWith("[ACTION RESULT]")||x[X].text?.startsWith("[TOOL RESULT]"))){v=X;break}v!==-1&&(x[v].text+=_)}}catch{}let kt=Math.floor(
|
|
731
|
-
[system] WARNING, Turn Limit Impending: Step ${St}/${
|
|
730
|
+
`;_+="[/system]",Fe.parts[0].text+=_;let v=-1;for(let X=x.length-1;X>=0;X--)if(x[X].role==="user"&&(x[X].text?.startsWith("[ACTION RESULT]")||x[X].text?.startsWith("[TOOL RESULT]"))){v=X;break}v!==-1&&(x[v].text+=_)}}catch{}let kt=Math.floor(Rn*.99),St=O+1;if(St>=kt&&Fe&&Fe.parts?.[0]&&(Fe.parts[0].text+=`
|
|
731
|
+
[system] WARNING, Turn Limit Impending: Step ${St}/${Rn}. Wrap up quickly/prompt user to continue. [/system]`),!(process.env.NO_DEV==="true"||process.env.NO_DEV==="1"||process.env.NO_DEV===!0||!1)){let p=G.join(En,"chats",String(m));we.existsSync(p)||we.mkdirSync(p,{recursive:!0}),we.writeFileSync(G.join(p,"context.json"),JSON.stringify({contents:H},null,2)),we.writeFileSync(G.join(p,"system.md"),`${xt?"CACHED":"NOT CACHED"}
|
|
732
732
|
Key: ${bt}
|
|
733
733
|
|
|
734
|
-
${We}`)}let
|
|
734
|
+
${We}`)}let _n=new Promise((p,_)=>{k.signal.aborted&&_(new DOMException("The user aborted a request.","AbortError")),k.signal.addEventListener("abort",()=>{_(new DOMException("The user aborted a request.","AbortError"))})});_n.catch(()=>{});let Tt=H;if(Yt=Date.now(),s==="Ollama")Ae=(await ce("Ollama"))(t.apiKey,ee,Tt,We,d,a,y,k.signal,1,h?.ollamaEndpoint||"Cloud");else if(s==="OpenRouter")Ae=(await ce("OpenRouter"))(t.apiKey,ee,Tt,We,d,a,y,k.signal,1,m);else if(s==="DeepSeek")Ae=(await ce("DeepSeek"))(t.apiKey,ee,Tt,We,d,a,y,k.signal,1);else if(s==="Mistral")Ae=(await ce("Mistral"))(t.apiKey,ee,Tt,We,d,a,y,k.signal,1,m);else if(s==="NVIDIA"){let p=(await ce("NVIDIA"))(t.apiKey,ee,Tt,We,d,a,y,k.signal,1);Ae=(await ce("NVIDIA_wrap"))(p,ee)}else if(s==="InferX")Ae=(await ce("InferX"))(t.apiKey,ee,Tt,We,d,a,y,k.signal,1);else if(s==="SenseNova")Ae=(await ce("SenseNova"))(t.apiKey,ee,Tt,We,d,a,y,k.signal,1);else if(s==="AIHubMix")Ae=(await ce("AIHubMix"))(t.apiKey,ee,Tt,We,d,a,y,k.signal,1);else if(s==="Poolside")Ae=(await ce("Poolside"))(t.apiKey,ee,Tt,We,d,a,y,k.signal,1);else if(s==="9router"||s==="9Router")Ae=(await ce("NineRouter"))(t.apiKey,ee,Tt,We,d,a,y,k.signal,1);else if(s==="ExpLabs"||s==="ExperientialLabs")Ae=(await ce("ExpLabs"))(t.apiKey,ee,Tt,We,d,a,y,k.signal,1);else if(s==="Infron"||s==="infron")Ae=(await ce("Infron"))(t.apiKey,ee,Tt,We,d,a,y,k.signal,1);else if(s==="TokenHarbor"||s==="Token Harbor"||s==="tokenharbor"||s==="token_harbor"||s==="thk")Ae=(await ce("TokenHarbor"))(t.apiKey,ee,Tt,We,d,a,y,k.signal,1);else if(s==="APInex"||s==="apinex"||s==="apx")Ae=(await ce("APInex"))(t.apiKey,ee,Tt,We,d,a,y,k.signal,1);else if(s==="c_openai"||s==="Custom (OpenAI)")Ae=(await ce("c_openai"))(t.apiKey,ee,Tt,We,d,a,y,k.signal,1,h?.customOpenAIBaseUrl||"");else{let p=ls(t?.apiKey),{serviceTier:_,cleanModel:v}=Jr(ee),X={systemInstruction:We,mediaResolution:"MEDIA_RESOLUTION_HIGH",safetySettings:[{category:Fn.HARM_CATEGORY_HARASSMENT,threshold:Dn.BLOCK_NONE},{category:Fn.HARM_CATEGORY_HATE_SPEECH,threshold:Dn.BLOCK_NONE},{category:Fn.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:Dn.BLOCK_NONE},{category:Fn.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:Dn.BLOCK_NONE}],temperature:1.05,thinkingConfig:(()=>{let N=Cs("Google",ee||"gemini-3-flash-preview",d);if(N!==null){if(typeof N=="object")return N;if(N===!1||N==="false"||N==="none"||N===0||N==="0")return{includeThoughts:!1};if(typeof N=="number")return{includeThoughts:!0,thinkingBudget:N};if(typeof N=="string"){let I=N.toLowerCase();if(I==="minimal")return{includeThoughts:!0,thinkingLevel:He.MINIMAL};if(I==="low")return{includeThoughts:!0,thinkingLevel:He.LOW};if(I==="medium")return{includeThoughts:!0,thinkingLevel:He.MEDIUM};if(I==="high")return{includeThoughts:!0,thinkingLevel:He.HIGH};let Q=Number(N);if(!isNaN(Q))return{includeThoughts:!0,thinkingBudget:Q}}}let K=(ee||"").toLowerCase(),ct=K.includes("gemma-4")||K.startsWith("gemma"),w=K.includes("gemini-3");if(ct||w)return ct?d.toLowerCase()!=="high"?{includeThoughts:!1,thinkingLevel:He.MINIMAL}:{includeThoughts:!0,thinkingLevel:He.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:K.includes("pro")?He.LOW:He.MINIMAL,Low:He.LOW,Medium:He.MEDIUM,Standard:He.MEDIUM,High:He.HIGH,xHigh:He.HIGH}[d]||He.MEDIUM};{let I={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[d]||2048;return I===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:I}}})()};_&&(X.serviceTier=_);let ie=p.models.generateContentStream({model:v||"gemini-3-flash-preview",contents:Tt,config:X},{signal:k.signal});Ae=await Promise.race([ie,_n])}fe="",P=null,lt=null,De=[],mt=0,yield{type:"model_update",content:null},Re="",tt=pt.length>0;let tn="",Si=Date.now(),Gn=async function*(){if(s==="Google"&&tn){let p=uo(tn);for(let _ of p)yield _;tn="",Si=Date.now()}},ys=!0,bn="",Zn=!1,At=null,bs=!1,Hn=!1,eo=!1,Wo=!1,In=!1,fo=p=>{let _=0;for(;_+2<p.length;)p[_]==="`"&&p[_+1]==="`"&&p[_+2]==="`"?(Wo=!Wo,_+=3):_++},xs=p=>{if(!p)return;let _=/(?:<(\/?)(?:think|thought|thoughts)[^>]*>|\[(\/?)(?:think|thought|thoughts)\]|<\/?channel\|?>|<\|channel>thought)/gi,v;for(;(v=_.exec(p))!==null;){let X=v[0].toLowerCase();X.startsWith("</")||X.startsWith("[/")||X==="<channel|>"?In=!1:In=!0}},ra={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|>"}},uo=p=>{let _=[],v=p,X=ie=>{if(!ie)return;if(!bs){_.push({type:"text",content:ie}),fo(ie),xs(ie);return}let N=/(?:<(\/?)(?:think|thought|thoughts)[^>]*>|\[(\/?)(?:think|thought|thoughts)\]|<\/?channel\|?>|<\|channel>thought)/gi,K=0,ct;for(;(ct=N.exec(ie))!==null;){let I=ie.substring(K,ct.index);if(I)if(fo(I),In)_.push({type:"text",content:I});else{let Oe=I.replace(/[^\r\n]/g,"");Oe&&_.push({type:"text",content:Oe})}let Q=ct[0];fo(Q);let l=Q.toLowerCase();l.startsWith("</")||l.startsWith("[/")||l==="<channel|>"?In=!1:In=!0,_.push({type:"text",content:Q}),K=N.lastIndex}let w=ie.substring(K);if(w)if(fo(w),In)_.push({type:"text",content:w});else{let I=w.replace(/[^\r\n]/g,"");I&&_.push({type:"text",content:I})}};for(;v.length>0;)if(Zn){let ie=bn+v,N=ra[At];if(N){let w=!1;if(ie.length<N.startPrefix.length?N.startPrefix.startsWith(ie)||(w=!0):ie.startsWith(N.startPrefix)?ie.length>=N.fullPrefix.length&&!ie.startsWith(N.fullPrefix)&&(w=!0):w=!0,w){X(ie),bn="",Zn=!1,At=null,Hn=!1,eo=!1,v="";break}}let K=-1,ct=N?N.endTag:"]";if(At==="tool"||At==="action"){let w=0,I=null,Q=0,l=!1;for(let Oe=0;Oe<ie.length;Oe++){let z=ie[Oe];if(I){if(z===I){let M=0;for(let dt=Oe-1;dt>=0&&ie[dt]==="\\";dt--)M++;M%2===0&&(I=null)}}else if(z==='"'||z==="'")I=z;else if(z==="`")if(Hn){K=Oe;break}else I=z;else if(z==="(")w++,l=!0;else if(z===")")w--;else if(z==="]"&&l&&w===0){K=Oe;break}}}else K=ie.indexOf(ct);if(K!==-1){let w=ct.length,I=ie.substring(0,K+w);At?.startsWith("kimi")||_.push({type:"text",content:I}),fo(I),xs(I),(At==="tool"||At==="action"||At?.startsWith("kimi"))&&!Hn&&!eo&&(bs=!0),Hn=!1,eo=!1,bn="",Zn=!1,At=null,v=ie.substring(K+w)}else{bn=ie,v="";break}}else{let ie=v.indexOf("[tool"),N=v.indexOf("[action"),K=v.indexOf("[[END]]"),ct=v.indexOf("<|tool_calls_section_begin|>"),w=v.indexOf("<|tool_call_begin|>"),I=[{type:"tool",idx:ie,start:"[tool",end:"]"},{type:"action",idx:N,start:"[action",end:"]"},{type:"end",idx:K,start:"[[END]]",end:"[[END]]"},{type:"kimi_section",idx:ct,start:"<|tool_calls_section_begin|>",end:"<|tool_calls_section_end|>"},{type:"kimi_call",idx:w,start:"<|tool_call_begin|>",end:"<|tool_call_end|>"}].filter(Q=>Q.idx!==-1).sort((Q,l)=>Q.idx-l.idx);if(I.length>0){let Q=I[0],l=v.substring(0,Q.idx);Q.idx>0&&X(l);let Oe=Q.idx>0?v[Q.idx-1]:"";Hn=Wo||Oe==="`",eo=In,Zn=!0,At=Q.type,bn="",v=v.substring(Q.idx)}else{let Q=["[tool","[action","[[END]]","<|tool_calls_section_begin|>","<|tool_call_begin|>"],l=-1;for(let Oe of Q){for(let z=Oe.length-1;z>0;z--)if(v.endsWith(Oe.substring(0,z))){l=v.length-z;let M=Q.indexOf(Oe);M===0?At="tool":M===1?At="action":M===2?At="end":M===3?At="kimi_section":At="kimi_call";break}if(l!==-1)break}if(l!==-1){if(l>0){let z=v.substring(0,l);X(z)}let Oe=l>0?v[l-1]:"";Hn=Wo||Oe==="`",eo=In,Zn=!0,bn=v.substring(l),v=""}else{X(v);break}}}return _},aa=Ae[Symbol.asyncIterator]();for(;;){let{value:p,done:_}=await Promise.race([aa.next(),_n]);if(_)break;if(p&&p.type==="status"){yield p;continue}let v="",X=p.candidates?.[0]?.content?.parts;if(X&&X.length>0)for(let N of X){let K=typeof N.text=="string"?N.text:N.text?parseChunkText(N.text):"";N.thought?K&&(te||(v+="<think>",te=!0),v+=K):K&&(te&&(v+="</think>",te=!1),v+=K)}else p.text&&te&&(v+="</think>",te=!1);v=Xa(v);let ie=v?Mi(v):0;if(t&&typeof t.onTokenChunk=="function"&&t.onTokenChunk(v,ie),ys&&(Ee===null&&(Ee=Date.now()-Yt),yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"},ys=!1),gt){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
|
|
735
735
|
|
|
736
|
-
\x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(v){if(tt){if(Re+=v,Re.length>=64){let w=0,I=Math.min(pt.length,Re.length);for(let l=I;l>=10;l--)if(pt.endsWith(Re.substring(0,l))){w=l;break}let Q=Re.substring(w);if(Q){let
|
|
737
|
-
`).length;
|
|
736
|
+
\x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(v){if(tt){if(Re+=v,Re.length>=64){let w=0,I=Math.min(pt.length,Re.length);for(let l=I;l>=10;l--)if(pt.endsWith(Re.substring(0,l))){w=l;break}let Q=Re.substring(w);if(Q){let Oe=/(?:<(think|thought)>|\[(think|thought)\])(?:(?!(?:<\/(?:think|thought)>|\[\/(?:think|thought)\]))[\s\S])*$/i.test(pt)?Q.replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])\s*/gi,""):Q.replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])[\s\S]*?(?:<\/(think|thought)>|\[\/(think|thought)\])\s*/gi,"").replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])\s*/gi,"");if(Oe)if(fe+=Oe,s==="Google")tn+=Oe;else{yield*Gn();let z=uo(Oe);for(let M of z)yield M}}tt=!1,Re=""}continue}else if(fe+=v,s==="Google")tn+=v;else{yield*Gn();let w=uo(v);for(let I of w)yield I}let N=il(fe);if(N.inside){zt=!0,lt||(lt=Date.now());let I={Ask:"ask",AskUser:"ask",WebSearch:"web_search",WebScrape:"web_scrape",ReadFile:"view_file",ReadFolder:"read_folder",WriteFile:"write_file",PatchFile:"update_file",WritePDF:"write_pdf",WriteDoc:"write_docx",FindFile:"find_file",find_file:"find_file",findfile:"find_file",Run:"exec_command",SearchKeyword:"search_keyword",CodeSearch:"search_keyword",code_search:"search_keyword",Code_Search:"search_keyword",codesearch:"search_keyword",Memory:"memory",file_map:"file_map",FileMap:"file_map",Chat:"chat",chat:"chat",GenerateImage:"generate_image",generate_image:"generate_image",todo:"todo",Todo:"todo",goal:"todo",Goal:"todo",Invoke:"invoke",InvokeSync:"invoke_sync",getProgress:"get_progress",GetProgress:"get_progress",Cancel:"cancel",Await:"await",wait:"wait",Answer:"answer",Steer:"steer",steer:"steer"}[N.toolName]||N.toolName,Q=N.args||"",l=null;if(["write_file","update_file","view_file","read_folder","find_file","write_pdf","write_docx","search_keyword","generate_image","file_map","invoke","invoke_sync","get_progress","await","wait","answer"].includes(I)){let z=W(Q),M=z.basename||z.name||z.path||z.targetFile||z.TargetFile||z.directory||z.file,dt=z.keyword,xn=z.title||z.task,Pt=z.id||z.taskId,Z=z.timeout||z.time||z.seconds||z.sec;if(dt!=null)l=String(dt).replace(Cn,"");else if(M)l=G.basename(String(M).replace(Cn,"").replace(Wr,"/"));else if(xn&&(I==="invoke"||I==="invoke_sync"))l=String(xn).replace(Cn,"").substring(0,30);else if(Pt&&I==="get_progress")l=String(Pt).replace(Cn,"");else if(Z&&I==="await"){let je=parseFloat(String(Z).replace(Cn,""));isNaN(je)?l=String(Z).replace(Cn,""):(je<5&&(je=5),je>120&&(je=180),l=(Lt=>{if(Lt>=60){let ho=Math.floor(Lt/60),wn=Lt%60;return`${ho}m${wn>0?` ${wn}s`:""}`}return`${Lt}s`})(je))}else if(Z&&I==="wait"){let je=parseFloat(String(Z).replace(Cn,""));isNaN(je)?l=String(Z).replace(Cn,""):(je<10&&(je=10),je>120&&(je=120),l=(Lt=>{if(Lt>=60){let ho=Math.floor(Lt/60),wn=Lt%60;return`${ho}m${wn>0?` ${wn}s`:""}`}return`${Lt}s`})(je))}else{let je=Q.match(Ya);if(je){let ft=je[1].replace(Cn,"");I==="invoke"||I==="invoke_sync"||I==="get_progress"?l=ft.substring(0,30):l=I==="search_keyword"||I==="file_map"?ft:G.basename(ft.replace(Wr,"/"))}}}let Oe=`${rs[I]||I}${l?` ${l}`:""}`;if((I!==P||l!==Ne)&&(P=I,Ne=l,yield{type:"status",content:`${Oe}`},process.stdout.isTTY)){let M={WebSearch:"Searching",web_search:"Searching",WebScrape:"Reading",web_scrape:"Reading",ReadFile:"Reading",read_file:"Reading",ReadFolder:"Reading",read_folder:"Reading",WriteFile:"Writing",write_file:"Writing",UpdateFile:"Editing",update_file:"Editing",WritePdf:"Creating",write_pdf:"Creating",WriteDocx:"Creating",write_docx:"Creating",SearchKeyword:"Searching",search_keyword:"Searching",CodeSearch:"Searching",code_search:"Searching",FindFile:"Finding File",find_file:"Finding File",Run:"Executing",Ask:"User Input Required",AskUser:"User Input Required",Memory:"Updating Memory",GenerateImage:"Generating",InvokeSync:"Sub-Agent Working",invoke_sync:"Sub-Agent Working",Invoke:"Working",invoke:"Working",GetProgress:"Checking Progress",get_progress:"Checking Progress",Cancel:"Stopping Generalist",cancel:"Stopping Generalist",Await:"Waiting",await:"Waiting",wait:"Waiting",EmergencyRollback:"Rolling the Ball",Answer:"Answering Sub-Agent",answer:"Answering Sub-Agent",Steer:"Steering Sub-Agent",steer:"Steering Sub-Agent",Click:"Clicking",click:"Clicking",Drag:"Dragging",drag:"Dragging",Scroll:"Scrolling",scroll:"Scrolling",KeyboardTyping:"Typing",keyboard_typing:"Typing",KeyPress:"Pressing Key",key_press:"Pressing Key",RecaptureScreen:"Recapturing Screen",recapture_screen:"Recapturing Screen"}[I]||"Working";process.stdout.write(`\x1B]0;${M}...\x07`)}}if(fe.length-Qn>800){Qn=fe.length;let w=Xr(fe,!1),I=ss(w),Q=I?(I.innerContent||"").trim():"",l=Q.split(/[.!?]\s+/).filter(me=>me.trim().length>10),Oe=new Set(l),z=l.length>25?(l.length-Oe.size)/l.length:0,M=Q.split(/\s+/).filter(me=>me.length>0).length,dt=.9,xn=.92,Pt=!1;if(s.toLowerCase().includes("google")&&(ee||"").toLowerCase().startsWith("gemma")){let c={low:2048,medium:4096,high:32768,max:65536,xhigh:65536}[d?.toLowerCase()]||16e3;Pt=M>c}if(z>dt||Pt){yield{type:"status",content:`${z>dt?"Reasoning Loop Detected":"Thinking Budget Exceeded"}. Re-centering...`},Ot=!0,await new Promise(c=>setTimeout(c,3e3));break}let ft=Kr(fe).trim().split(/[.!?]\s+/).filter(me=>me.trim().length>10),Lt=new Set(ft);if((ft.length>25?(ft.length-Lt.size)/ft.length:0)>xn){yield{type:"status",content:"Response Loop Detected. Re-centering..."},Ot=!1,Wt=!0,await new Promise(me=>setTimeout(me,3e3));break}let wn=w.replace(Ua,"").replace(Wa,"").replace(Ga,"").replace(Ha,""),$t=wn.toLowerCase().split(/\s+/).map(me=>me.replace(ja,"")).filter(me=>me.length>0),Sn=!1;if($t.length>=40)for(let me=1;me<=15;me++){let c=Math.max(8,Math.ceil(25/me));if($t.length<me*c)continue;let L=$t.slice($t.length-me),V=L.join(" ");if(me>1&&V===L.slice(0,Math.floor(me/2)).join(" ").repeat(2).trim())continue;let pe=!0;for(let le=1;le<c;le++)if($t.slice($t.length-me*(le+1),$t.length-me*le).join(" ")!==V){pe=!1;break}if(pe){Sn=!0;break}}if(!Sn){let me=wn.toLowerCase().replace(Ka,"");if(me.length>=80)for(let c=1;c<=10;c++){let L=Math.max(15,Math.ceil(45/c));if(me.length<c*L)continue;let V=me.substring(me.length-c),pe=!0;for(let le=1;le<L;le++)if(me.substring(me.length-c*(le+1),me.length-c*le)!==V){pe=!1;break}if(pe){Sn=!0;break}}}if(Sn){yield{type:"status",content:"Stuttering Detected. Re-centering..."},Ot=!1,Un=!0,await new Promise(me=>setTimeout(me,3e3));break}}let K=Ft(fe),ct=ao(K);for(;ct.length>mt;){yield*Gn();let w=ct[mt],I=Date.now(),l={Ask:"ask",AskUser:"ask",WebSearch:"web_search",WebScrape:"web_scrape",ReadFile:"view_file",ReadFolder:"read_folder",FindFile:"find_file",find_file:"find_file",findfile:"find_file",WriteFile:"write_file",PatchFile:"update_file",WritePDF:"write_pdf",WriteDoc:"write_docx",Run:"exec_command",SearchKeyword:"search_keyword",CodeSearch:"search_keyword",code_search:"search_keyword",Code_Search:"search_keyword",codesearch:"search_keyword",Memory:"memory",file_map:"file_map",FileMap:"file_map",Chat:"chat",chat:"chat",GenerateImage:"generate_image",generate_image:"generate_image",todo:"todo",Todo:"todo",goal:"todo",Goal:"todo",Invoke:"invoke",InvokeSync:"invoke_sync",getProgress:"get_progress",GetProgress:"get_progress",Await:"await",await:"await",AwaitSubagent:"await",awaitSubagent:"await",Wait:"wait",wait:"wait",Answer:"answer",answer:"answer",AnswerSubagent:"answer",answerSubagent:"answer",Steer:"steer",steer:"steer",SteerSubagent:"steer",steerSubagent:"steer",Cancel:"cancel",cancel:"cancel",Click:"click",click:"click",Drag:"drag",drag:"drag",Scroll:"scroll",scroll:"scroll",KeyboardTyping:"keyboard_typing",keyboard_typing:"keyboard_typing",KeyPress:"key_press",key_press:"key_press",RecaptureScreen:"recapture_screen",recapture_screen:"recapture_screen",EmergencyRollback:"EmergencyRollback"}[w.toolName]||w.toolName,Oe=rs[l]||w.toolName,z=Xn(l,w.args);yield{type:"status",content:`${Oe}${z?` ${z}`:""}`};let M="";if(l==="click"){let c=W(w.args);M=`\u2714 Clicked ${c.intendedClickText?`: ${c.intendedClickText}`:"Screen"}`}else if(l==="drag"){let c=W(w.args);M=`\u2714 Dragged: Cell ${c.fromGridId||""} \u2192 Cell ${c.toGridId||""}`}else if(l==="scroll"){let c=W(w.args);M=`\u2714 Scrolled: ${c.direction||"down"} (${c.amount||1})`}else if(l==="keyboard_typing"){let c=W(w.args);M=`\u2714 ${c.autoPressEnter?"Entered":"Typed"}: ${c.text?`"${c.text.length>20?c.text.substring(0,20)+"...":c.text}"`:""}`}else if(l==="key_press")M=`\u2714 Pressed Key: ${W(w.args).key||""}`;else if(l==="recapture_screen")M="\u2714 Recaptured Screen";else if(l==="web_search"){let{query:c,limit:L=10,aiMode:V=!1}=W(w.args);M=`${c?"\u2714":"\u2718"} ${V?"AI Search":"Searched"}: ${c?`${c}`:"No Search Query"}${V===!1&&c?` \u2192 ${L}`:""}`}else if(l==="web_scrape"){let c=W(w.args).url||null;M=`${c?"\u2714":"\u2718"} Visited: ${c||"No Source"}`}else if(l==="view_file"){let{path:c,StartLine:L,EndLine:V,start_line:pe,end_line:le,startLine:J,endLine:ye}=W(w.args),be=L||pe||J,q=V||le||ye,D=parseInt(be)||1,Y=parseInt(q)||(be?D+800:800),Pe="...",_e=Y,ne=(c||"").trim().toLowerCase().replaceAll("\\","/");if(ne.startsWith("#skill"))ne.startsWith("#skill/global/fluxflow")||ne.startsWith("#skills/global/fluxflow")||ne.includes("#skill/fluxflow")||ne.includes("#skills/fluxflow")?M="\u2714 Read Documentation":M=`\u2714 Read Skill: ${G.basename(c.replaceAll("\\","/"))}`;else{try{let ge=G.resolve(process.cwd(),c);if(we.existsSync(ge)){let U=we.readFileSync(ge,"utf8").split(`
|
|
737
|
+
`).length;Pe=U,!be&&!q&&U>800?_e=Math.min(50,U):_e=Math.min(Y,U)}}catch{}let Et=(c||"").toLowerCase(),rn=Et.endsWith(".pdf"),Ke=Et.endsWith(".docx")||Et.endsWith(".doc")||Et.endsWith(".ppt")||Et.endsWith(".pptx")||Et.endsWith(".xls")||Et.endsWith(".xlsx"),Ye=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(Et);rn||Ke?M=`${c.length>0?"\u2714":"\u2718"} ${c?`Analyzed: ${G.basename(c)}`:"Analyzed: File Not Found"}`:Ye?M=`${c.length>0?"\u2714":"\u2718"} ${c?`Processed: ${G.basename(c)}`:"Processed: File Not Found"}`:M=`${Pe!=="..."?"\u2714":"\u2718"} Read: ${c?`${G.basename(c)} \u2192 ${Pe!=="..."?`Lines ${D} - ${_e} of ${Pe}`:"File Not Found"}`:"File Not Found"}`}}else if(l==="list_files"||l==="read_folder"){let c=l==="list_files"?"List":"Browsed",L=W(w.args).path||null,V=W(w.args).recurse||1;M=`${L?"\u2714":"\u2718"} ${c}: ${L?`${L==="."?`./${V>1?"*":""}`:`${L.replaceAll("\\","/")}${V>1?`${L.endsWith("/")?"*":"/*"}`:`${L.endsWith("/")?"":"/"}`}`}`:"No Folder Selected"}`}else if(l==="find_file"){let c=W(w.args),L=c.basename||c.name||c.path||c.file||c.query||"";M=`${L?"\u2714":"\u2718"} Located: ${L||"No Query"}`}else if(l==="write_file"||l==="update_file"){let c=l==="write_file"?"Created":"Edited",L=W(w.args),V=L.path||null,le=Object.entries(L).some(([J,ye])=>J.startsWith("searchContent")&&typeof ye=="string"&&ye.startsWith("^LINE:"))?"\u1361":":";M=`${V?"\u2714":"\u2718"} ${c}${le} ${V?V.replaceAll("\\","/"):"No File Changes"}`}else if(l==="write_pdf"){let c=W(w.args).path||null;M=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No PDF Generated"}`}else if(l==="write_docx"){let c=W(w.args).path||null;M=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No Docx Generated"}`}else if(l==="file_map"){let c=W(w.args).path;M=`${c?"\u2714":"\u2718"} Indexed: ${c.replaceAll("\\","/")?""+c:"File Not Found"}`}else if(l.toLowerCase()==="search_keyword"||l.toLowerCase()==="todo")M="";else if(l.toLowerCase()==="generate_image"){let{path:c,outputPath:L,output:V}=W(w.args);M=`\u2714 Generated: ${c||L||V||"generated_image.png"}`}else if(l==="invoke_sync"||l==="InvokeSync"){let c=Xn(l,w.args);M=`\u2714 Called Generalist${c?`: ${c}`:""}`}else if(l==="Invoke"||l==="InvokeAsync"||l==="invoke"){let c=Xn(l,w.args);M=`\u2714 Started Generalist${c?`: ${c}`:""}`}else if(l==="get_progress"||l==="GetProgress"){let c=Xn(l,w.args);M=`\u2714 Checked${c?`: ${c}`:""}`}else if(l==="cancel"){let c=Xn(l,w.args);M=`\u{1F6C7} Cancelled${c?`: ${c}`:""}`}else if(l==="steer"||l==="Steer"){let c=Xn(l,w.args);M=`\u2714 Steered${c?`: ${c}`:""}`}else if(l==="EmergencyRollback"){let{method:c}=W(w.args);M=c==="forceRevert"?"":"\u2714 Rollback Point Checked"}else if(l==="await"||l==="Await"||l==="wait"||l==="Wait"){let{time:c,timeout:L,seconds:V,sec:pe}=W(w.args),le=parseFloat(V||pe||L||c)||45,J=l==="wait"||l==="Wait"?120:180;le<10&&(le=10),le>J&&(le=J);let ye=D=>{if(D>=60){let Y=Math.floor(D/60),Pe=D%60;return`${Y}m${Pe>0?` ${Pe}s`:""}`}return`${D}s`},be=["Aligning Moon Phase","Contemplating Existence","Staring At Void","Delaying Professionally","Negotiating With Electrons","Touching Grass (virtually)","Panicking Softly","Rethinking Career Choices","Loading Cat Videos","Summoning Braincell #2","Pretending To Be Busy","Waiting For Motivation DLC","Rotating Internal Screaming","Downloading More RAM","Feeding The Hamsters","Gaslighting Scheduler","Performing Dramatic Pause","Buffering Social Energy","Calculating Regret","Reading Terms And Conditions","Becoming Sentient Briefly","Contacting Ancestors"];M=`\u2714 ${be[Math.floor(Math.random()*be.length)]} \u2192 ${ye(le)}`}else l==="Answer"||l==="answer"?M="\u2714 Resolved Sub-Agent Query":l==="exec_command"||l==="ask"?M="":M=`Executed: ${w.toolName}`;if(yield*Gn(),l==="exec_command"){let{command:c}=W(w.args);if(c&&t.systemSettings&&t.systemSettings.allowExternalAccess===!1){let L=[/[a-zA-Z]:[\\\/]/i,/^\//,/\.\.[\\\/]/,/\/etc\//,/\/var\//,/\/root\//,/\/bin\//,/\/usr\//],V=G.resolve(process.cwd()).substring(0,3).toLowerCase(),pe=q=>{let D=[],Y="",Pe=null;for(let _e=0;_e<q.length;_e++){let ne=q[_e];Pe?(ne===Pe&&(Pe=null),Y+=ne):ne==='"'||ne==="'"?(Pe=ne,Y+=ne):ne==="&"&&q[_e+1]==="&"||ne==="|"&&q[_e+1]==="|"?(Y.trim()&&(D.push(Y.trim()),Y=""),_e++):ne===";"||ne==="|"||ne==="&"?Y.trim()&&(D.push(Y.trim()),Y=""):Y+=ne}return Y.trim()&&D.push(Y.trim()),D},le=q=>{let D=[],Y="",Pe=null;for(let _e=0;_e<q.length;_e++){let ne=q[_e];Pe?(ne===Pe&&(Pe=null),Y+=ne):ne==='"'||ne==="'"?(Pe=ne,Y+=ne):/\s/.test(ne)?Y&&(D.push(Y),Y=""):Y+=ne}return Y&&D.push(Y),D},J=q=>{let D=q.replace(/^['"]|['"]$/g,"").trim();return!D||process.platform==="win32"&&/^\/[a-zA-Z0-9?]+$/.test(D)?!1:L.some(Y=>{if(Y.source==="[a-zA-Z]:[\\\\\\/]"){let Pe=D.match(/[a-zA-Z]:[\\\/]/i);return Pe&&Pe[0].toLowerCase()!==V}return Y.test(D)})};if(pe(c).some(q=>{let D=le(q);if(D.length===0)return!1;let Y=D[0].replace(/^['"]|['"]$/g,"").toLowerCase();if(["echo","printf","write-output"].includes(Y)){let _e=!1;return D.some(ne=>{let _t=ne.replace(/^['"]|['"]$/g,"");if(_t===">"||_t===">>"||_t==="<")return _e=!0,!1;if(_t.startsWith(">")||_t.startsWith("<")){let Et=_t.replace(/^[><]+/,"");return J(Et)}return _e?(_e=!1,J(ne)):!1})}return D.some(_e=>J(_e))})){let q='Access Denied. Prohibited from accessing external directories while "External Workspace Access" is disabled.';t.onExecStart&&t.onExecStart(c||"No Command"),yield{type:"exec_start"},await new Promise(D=>setTimeout(D,50)),t.onExecChunk&&t.onExecChunk(`ERROR: ${q}`),await new Promise(D=>setTimeout(D,50)),t.onExecEnd&&t.onExecEnd(),De.push({role:"user",text:`[ACTION RESULT]: ERROR: ${q}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${q}`},mt++;continue}}t.onExecStart&&t.onExecStart(c||"No Command"),yield{type:"exec_start"}}let dt=W(w.args),xn=dt.path||dt.targetPath||null;if(xn){let c=t.systemSettings&&t.systemSettings.allowExternalAccess===!1,L=G.resolve(xn),V=G.resolve(process.cwd());if(c&&!L.startsWith(V)){let pe="Access Denied. You are not allowed to access files outside the current workspace.";if(l==="write_file"||l==="update_file"){let J=`\u2718 ${l==="write_file"?"Write Canceled":"Edit Canceled"}: ${dt.path||"..."}`,ye=115;process.stdout.isTTY&&(ye=process.stdout.columns-5||120);let be=Math.min(J.length+4,ye),q=`${J.padEnd(be-2).substring(0,be-2)}`;yield{type:"visual_feedback",content:Dt(`${Ue?`
|
|
738
738
|
`:""}${q}
|
|
739
|
-
`)},Ue=!1}De.push({role:"user",text:`[ACTION RESULT]: ERROR: ${pe}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${pe}`},mt++;continue}}if(t.onToolApproval){let c=t.systemSettings||{},L=c.autoExec,
|
|
739
|
+
`)},Ue=!1}De.push({role:"user",text:`[ACTION RESULT]: ERROR: ${pe}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${pe}`},mt++;continue}}if(t.onToolApproval){let c=t.systemSettings||{},L=c.autoExec,V=!1,pe="";if(l==="view_file"){let J=W(w.args);if(pe=J.path||J.targetPath||J.file||"",pe){let ye=c.alwaysAskFiles||".env, .env.*, *.env";ws(pe,ye)&&(V=!0)}}if(l==="write_file"||l==="update_file"||l==="exec_command"||V){let J=null,ye=!1,be=!1,q=!1;if(V)ye=!0,J=null;else if(l==="exec_command"){let{command:Ke}=W(w.args),Ye=(Ke||"").trim(),ge=(Xt,Ht)=>{if(!Ht)return!1;let nn=Ht.split(",").map(jt=>jt.trim().toLowerCase()).filter(Boolean),Qe=Xt.toLowerCase();return nn.some(jt=>Qe.startsWith(jt))},Ge=ge(Ye,c.alwaysAskCommands),U=ge(Ye,c.autoApproveCommands);if(be=ge(Ye,c.autoDisallowCommands),Ge?ye=!0:(U||c.autoApproveGit&&/^git\s+commit\b/i.test(Ye))&&(J="allow"),!ye&&!J){if(c.networkAccess===!1){let Ht=Ye.trim().replace(/\s+/g," ").replace(/^['"]+|['"]+$/g,"").toLowerCase().split(" "),Qe=Ht[0].split("/").pop().split("\\").pop().replace(/\.exe$/,""),jt=new Set(["curl","wget","httpie","xh","ssh","scp","sftp","rsync","ftp","lftp","tftp","telnet","nc","netcat","socat","ping","traceroute","tracert","dig","nslookup","host","whois","nmap","docker","podman","kubectl","helm","gcloud","aws","az","terraform","ansible-playbook","nix","nix-env","apt","apt-get","dpkg","yum","dnf","pacman","zypper","brew","apk","choco","scoop","conda","mamba","aria2c","axel","smbclient","lynx","w3m","links","elinks","heroku","netlify","vercel","firebase","supabase","wrangler","flyctl","powershell","pwsh","certutil","bitsadmin","cloudflared","ngrok","tailscale","zerotier","rclone"]),Ze=!1;jt.has(Qe)&&(Ze=!0);let ze=Mn=>Ht.slice(1).some(kn=>Mn.includes(kn)),nt=Mn=>{let kn=Ht.findIndex(Tn=>Mn.includes(Tn)),jn=Ht.findIndex(Tn=>["run","exec","test"].includes(Tn));return kn!==-1&&!(jn!==-1&&jn<kn)};Qe==="git"&&ze(["clone","pull","push","fetch"])&&(Ze=!0),Qe==="go"&&ze(["get","install"])&&(Ze=!0),Qe==="npm"&&nt(["install","i","update","add"])&&(Ze=!0),Qe==="yarn"&&nt(["add","install","upgrade"])&&(Ze=!0),Qe==="pnpm"&&nt(["add","install","update"])&&(Ze=!0),Qe==="bun"&&nt(["add","install","update"])&&(Ze=!0),Qe==="deno"&&ze(["install","add"])&&(Ze=!0),Qe==="pip"&&ze(["install","download"])&&(Ze=!0),Qe==="pip3"&&ze(["install","download"])&&(Ze=!0),Qe==="cargo"&&ze(["install","add"])&&(Ze=!0),["bash","sh","zsh","fish"].includes(Qe)&&ze(["-c"])&&(Ze=!0),Qe==="cmd"&&ze(["/c"])&&(Ze=!0),Ze&&(J="deny",q=!0)}!J&&be&&(J="deny")}!ye&&!J&&L&&(J="allow")}else(l==="write_file"||l==="update_file")&&L&&(J="allow");let D=J,Y="";J==="deny"&&(q?Y="network":be?Y="settings":Y="prohibited");let Pe=!1,_e="",ne=[],_t=0,Et=!1,rn="";if(!D){if(l==="write_file"||l==="update_file")try{let ge=W(w.args),{path:Ge}=ge;if(Ge){let U=G.resolve(process.cwd(),Ge),Xt=ze=>ze?ze.toLowerCase().replace(/\\/g,"/").replace(/^[a-z]:/,nt=>nt.toUpperCase()):"",Ht=Xt(U),nn="",Qe=!1,jt=await zn(),Ze=Xt(jt?.file_focused);if(jt&&Ze===Ht&&jt.full_content?(nn=jt.full_content,Qe=!0):we.existsSync(U)&&(nn=we.readFileSync(U,"utf8"),Qe=!0),_e=nn,await Xo.recordFileChange(U,nn),Qe){let ze=nn;if(l==="write_file"){let nt=ge.content||ge.newContent||"";ze=nt.endsWith(`
|
|
740
740
|
`)?nt:nt+`
|
|
741
|
-
`,
|
|
742
|
-
${
|
|
743
|
-
`)}`,
|
|
744
|
-
`:""}${ot}`)},Ue=!1,De.push({role:"user",text:Jt}),await Rt("toolFailure"),t.onToolResult&&t.onToolResult("failure",l),yield{type:"tool_result",content:Jt,toolName:l},mt++;continue}}yield{type:"status",content:`Opening Diff in IDE: ${
|
|
741
|
+
`,rn=ze}else{let{patchPairs:nt,allowMultiple:Mn,error:kn}=Oi(ge);if(kn){let Jt=`[ACTION RESULT]: ERROR: ${kn}`;De.push({role:"user",text:Jt}),await Rt("toolFailure"),t.onToolResult&&t.onToolResult("failure",l),yield{type:"tool_result",content:Jt,toolName:l},mt++;continue}let jn=ge.allowMultiple!==void 0?ge.allowMultiple===!0||String(ge.allowMultiple).toLowerCase()==="true":Mn;_t=nt.length;let Tn=ks(nn,nt,{allowMultiple:jn});ze=Tn.content,rn=ze,ne=Tn.results;let Go=ne.filter(Jt=>Jt.success),Ti=ne.filter(Jt=>!Jt.success);if(Go.length===0){let Jt=`[ACTION RESULT]: ERROR: Failed to apply patches to [${G.basename(U)}].
|
|
742
|
+
${Ti.map(it=>` \u2022 ${it.error}`).join(`
|
|
743
|
+
`)}`,Ai=`\u2714 Edited: ${G.basename(U.replaceAll("\\","/"))}`,An=115;process.stdout.isTTY&&(An=process.stdout.columns-5||120);let Kn=Math.min(Ai.length+4,An),ot=`${Ai.padEnd(Kn-2).substring(0,Kn-2)}`;yield{type:"visual_feedback",content:Dt(`${Ue?`
|
|
744
|
+
`:""}${ot}`)},Ue=!1,De.push({role:"user",text:Jt}),await Rt("toolFailure"),t.onToolResult&&t.onToolResult("failure",l),yield{type:"tool_result",content:Jt,toolName:l},mt++;continue}}yield{type:"status",content:`Opening Diff in IDE: ${G.basename(U)}`},Zi(U,nn,ze),Pe=!0,await new Promise(nt=>setTimeout(nt,50))}else if(l==="write_file"){let ze=ge.content||ge.newContent||"",nt=ze.endsWith(`
|
|
745
745
|
`)?ze:ze+`
|
|
746
|
-
`;
|
|
747
|
-
${
|
|
746
|
+
`;rn=nt,we.existsSync(U)||(Et=!0,we.mkdirSync(G.dirname(U),{recursive:!0}),we.writeFileSync(U,"","utf8")),yield{type:"status",content:`Opening New File Diff in IDE: ${G.basename(U)}`},Zi(U,"",nt),Pe=!0,await new Promise(Mn=>setTimeout(Mn,50))}}}catch(ge){console.error("Simulation/Diff Error:",ge)}let Ke=null;Qi(ge=>{Ke=ge});let Ye=t.onToolApproval;if(D=await new Promise(async ge=>{let Ge=setInterval(()=>{if(Ke){let U=t.onIDEApproval||$o&&$o.onIDEApproval;U&&U(Ke),clearInterval(Ge),ge(Ke)}},100);try{let U=await Ye(l,w.args);clearInterval(Ge),ge(U)}catch{clearInterval(Ge),ge("deny")}}),Qi(null),l==="write_file"||l==="update_file"){let{path:ge}=W(w.args);if(ge){let Ge=G.resolve(process.cwd(),ge);if(Ur(Ge,D),D==="deny"&&Et&&we.existsSync(Ge))try{we.unlinkSync(Ge)}catch{}}}D==="deny"&&(Y="user")}if(D==="allow"&&Pe&&ui()){let{path:Ke}=W(w.args),Ye=G.resolve(process.cwd(),Ke),ge=ot=>ot?G.resolve(ot).replace(/\\/g,"/").toLowerCase():"",Ge=await zn(),U="";if(Ge&&Ge.file_focused&&ge(Ge.file_focused)===ge(Ye)&&Ge.full_content&&(U=Ge.full_content),!U&&we.existsSync(Ye)){let ot=we.readFileSync(Ye,"utf8");ot&&(U=ot)}!U&&rn&&(U=rn),(U||Et)&&we.writeFileSync(Ye,U,"utf8");let Xt=U.split(/\r?\n/),Ht=Xt.length,nn=Buffer.byteLength(U,"utf8"),Qe="";_e&&(Qe=`Old File contents:
|
|
747
|
+
${_e.split(/\r?\n/).map((it,On)=>`${On+1} | ${it}`).join(`
|
|
748
748
|
`)}
|
|
749
749
|
|
|
750
750
|
`);let jt="";if(Ht<=100)jt=Xt.join(`
|
|
751
751
|
`);else{let ot=Xt.slice(0,50).join(`
|
|
752
|
-
`),
|
|
752
|
+
`),it=Xt.slice(-50).join(`
|
|
753
753
|
`);jt=`${ot}
|
|
754
754
|
|
|
755
755
|
... [${Ht-100} lines truncated for history stability] ...
|
|
756
756
|
|
|
757
|
-
${
|
|
757
|
+
${it}`}let Ze="";if(l==="update_file"){let ot=Ts(_e,U,ne,12,t?.compressToolResults||$o?.systemSettings?.compressToolResults),{patchPairs:it}=Oi(W(w.args)),On=it?.length||_t||1,Vn=0,an=0,to=[];it&&it.length>0?it.forEach((no,Ei)=>{let Ho=no.replace||"",Ln=no.new||"",jo=Ho.trim(),Ci=Ln.trim(),pa=Ci?U.includes(Ln)||U.includes(Ci):!0,ya=jo?U.includes(Ho)||U.includes(jo):!1;pa&&(!jo||!ya||jo===Ci)?Vn++:(an++,to.push(` \u2022 Block ${Ei+1}: Rejected by user in IDE (reverted to original).`))}):Vn=_t||0;let Pn=0;if(rn&&U!==rn){let no=Fa("","",rn||"",U||"","","",{context:0});if(no&&no.hunks)for(let Ei of no.hunks){let Ho=Ei.lines.filter(Ln=>Ln.startsWith("+")).map(Ln=>Ln.slice(1).trim()).filter(Boolean);for(let Ln of Ho)_e.includes(Ln)||Pn++}}let mo=[`[${Vn}/${On}] applied`];an>0&&mo.push(`${an} rejected by user`),Pn>0&&mo.push(`${Pn} manual ${Pn===1?"modification":"modifications"} by user`);let ha=mo.join(", "),ma=to.length>0?`
|
|
758
758
|
|
|
759
|
-
|
|
760
|
-
${
|
|
761
|
-
`)}`:"";Ze=`File [${Ke}] updated via IDE Companion
|
|
759
|
+
User Review Details:
|
|
760
|
+
${to.join(`
|
|
761
|
+
`)}`:"";Ze=`File [${Ke}] updated via IDE Companion. ${ha}.${ma}
|
|
762
762
|
|
|
763
|
-
${ot}`}else{let ot=
|
|
764
|
-
${
|
|
763
|
+
${ot}`}else{let ot=U.split(/\r?\n/),it=ot.length,On=Buffer.byteLength(U,"utf8"),Vn="";_e&&(Vn=`Old File contents:
|
|
764
|
+
${_e.split(/\r?\n/).map((Pn,mo)=>`${mo+1} | ${Pn}`).join(`
|
|
765
765
|
`)}
|
|
766
766
|
|
|
767
|
-
`);let
|
|
768
|
-
`);else{let
|
|
769
|
-
`),
|
|
770
|
-
`);
|
|
767
|
+
`);let an="";if(it<=100)an=ot.join(`
|
|
768
|
+
`);else{let to=ot.slice(0,50).join(`
|
|
769
|
+
`),Pn=ot.slice(-50).join(`
|
|
770
|
+
`);an=`${to}
|
|
771
771
|
|
|
772
|
-
... [${
|
|
772
|
+
... [${it-100} lines truncated] ...
|
|
773
773
|
|
|
774
|
-
${
|
|
775
|
-
- Stats: [${
|
|
776
|
-
${
|
|
774
|
+
${Pn}`}Ze=`File [${Ke}] saved via IDE Companion (May have user edits).
|
|
775
|
+
- Stats: [${it} lines, ${(On/1024).toFixed(1)} KB]
|
|
776
|
+
${Vn}- Content Preview:
|
|
777
777
|
|
|
778
|
-
${
|
|
779
|
-
`:""}${
|
|
780
|
-
`));let
|
|
781
|
-
`):
|
|
778
|
+
${an}`}let ze=l==="write_file"?"Created":"Edited",nt=W(w.args),kn=Object.entries(nt).some(([ot,it])=>ot.startsWith("searchContent")&&typeof it=="string"&&it.startsWith("^LINE:"))?"\u1361":":",jn=`${Ke?"\u2714":"\u2718"} ${ze}${kn} ${Ke?Ke.replaceAll("\\","/"):"No File Changes"}`,Tn=115;process.stdout.isTTY&&(Tn=process.stdout.columns-5||120);let Go=Math.min(jn.length+4,Tn),Ti=`${jn.padEnd(Go-2).substring(0,Go-2)}`;yield{type:"visual_feedback",content:Dt(`${Ue?`
|
|
779
|
+
`:""}${Ti}`)},Ue=!1;let Jt=Date.now();Zt=Jt,yield{type:"tool_time",content:Jt-I};let An=(Ze||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");An.includes("[[VERIFIED]]")&&(An=An.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to conserve context.
|
|
780
|
+
`));let Kn;if(An.startsWith("[[SAME]]")){let it=An.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),On=it.filter(an=>an.startsWith("File ")||an.trim().startsWith("- Stats:"));Kn=`[ACTION RESULT]: ${On.length>0?On.join(`
|
|
781
|
+
`):it.slice(0,2).join(`
|
|
782
782
|
`)}
|
|
783
|
-
[SYSTEM NOTE]: Content verified and persisted to disk. Full preview omitted to conserve context.`}else
|
|
784
|
-
`:""}${
|
|
785
|
-
`)},Ue=!1}else if(l==="write_file"||l==="update_file"){let ge=`\u2718 ${l==="write_file"?"Write Cancelled":"Edit Denied"}: ${
|
|
783
|
+
[SYSTEM NOTE]: Content verified and persisted to disk. Full preview omitted to conserve context.`}else Kn=`[ACTION RESULT]: ${An}`;De.push({role:"user",text:Kn}),yn=!0,await Rt("toolSuccess"),t.onToolResult&&t.onToolResult("success",l),yield{type:"tool_result",content:Ze,aiContent:Kn,toolName:l},mt++;continue}if(D==="deny"){let Ke=`Permission Denied: Prohibited ${l==="exec_command"?"Command":"file edit"}.`;if(V?Ke=`User denied reading ${G.basename(pe||".env")}`:Y==="user"?Ke="Permission Denied by User":Y==="settings"?Ke="Permission Denied by User Policy":Y==="network"?Ke="Permission Denied: Sandbox Network Access Disabled by User Policy.":Y==="prohibited"&&l==="exec_command"&&(Ke="Permission Denied: Prohibited Command in User Policy"),l==="view_file"){let Ye=`\u2718 Read Denied: ${W(w.args).path?.replaceAll("\\","/")||".env"}`,ge=115;process.stdout.isTTY&&(ge=process.stdout.columns-5||120);let Ge=Math.min(Ye.length+4,ge),U=`${Ye.padEnd(Ge-2).substring(0,Ge-2)}`;yield{type:"visual_feedback",content:Dt(`${Ue?`
|
|
784
|
+
`:""}${U}
|
|
785
|
+
`)},Ue=!1}else if(l==="write_file"||l==="update_file"){let ge=`\u2718 ${l==="write_file"?"Write Cancelled":"Edit Denied"}: ${W(w.args).path.replaceAll("\\","/")||"..."}`,Ge=115;process.stdout.isTTY&&(Ge=process.stdout.columns-5||120);let U=Math.min(ge.length+4,Ge),Xt=`${ge.padEnd(U-2).substring(0,U-2)}`,Ht=` ${" ".repeat(U)} `;yield{type:"visual_feedback",content:Dt(`${Ue?`
|
|
786
786
|
`:""}${Xt}
|
|
787
|
-
`)},Ue=!1}l==="exec_command"&&(await new Promise(Ye=>setTimeout(Ye,50)),t.onExecChunk&&t.onExecChunk(`ERROR: ${Ke}`),await new Promise(Ye=>setTimeout(Ye,50)),t.onExecEnd&&t.onExecEnd()),De.push({role:"user",text:`[ACTION RESULT]: DENIED: ${Ke}`}),yield{type:"tool_result",content:`[ACTION RESULT]: DENIED: ${Ke}`},await Rt("toolDenied"),t.onToolResult&&t.onToolResult("denied",l),mt++;continue}}}if(M){let c=115;process.stdout.isTTY&&(c=process.stdout.columns-5||120);let L=await i(),
|
|
788
|
-
`:""}${le}${M.includes("\u2714")&&(M.includes("Created")||M.includes("Edited"))?"":`${
|
|
789
|
-
`}`}`)},Ue=!1}if(Zt>0){let c=Date.now()-Zt,L=Math.max(0,1e3-c);L>0&&await new Promise(
|
|
790
|
-
`:""}${
|
|
791
|
-
`)},Ue=!1}if(l==="EmergencyRollback"){let{method:c}=
|
|
787
|
+
`)},Ue=!1}l==="exec_command"&&(await new Promise(Ye=>setTimeout(Ye,50)),t.onExecChunk&&t.onExecChunk(`ERROR: ${Ke}`),await new Promise(Ye=>setTimeout(Ye,50)),t.onExecEnd&&t.onExecEnd()),De.push({role:"user",text:`[ACTION RESULT]: DENIED: ${Ke}`}),yield{type:"tool_result",content:`[ACTION RESULT]: DENIED: ${Ke}`},await Rt("toolDenied"),t.onToolResult&&t.onToolResult("denied",l),mt++;continue}}}if(M){let c=115;process.stdout.isTTY&&(c=process.stdout.columns-5||120);let L=await i(),V=!1;L&&(V=L.trim().length>0);let pe=Math.min(M.length+4,c),le=`${M.padEnd(pe-2).substring(0,pe-2)}`;yield{type:"visual_feedback",content:Dt(`${Ue?`
|
|
788
|
+
`:""}${le}${M.includes("\u2714")&&(M.includes("Created")||M.includes("Edited"))?"":`${V?"":`
|
|
789
|
+
`}`}`)},Ue=!1}if(Zt>0){let c=Date.now()-Zt,L=Math.max(0,1e3-c);L>0&&await new Promise(V=>setTimeout(V,L))}let Pt={chatId:m,history:n,onChunk:c=>t.onExecChunk?t.onExecChunk(c):null,onAskUser:t.onAskUser,systemSettings:t.systemSettings,mode:a,isMultiModal:st(ee),onVisualFeedback:t.onVisualFeedback,onSubagentUpdate:t.onSubagentUpdate,onTokenChunk:t.onTokenChunk,modelName:ee,aiProvider:t.aiProvider,apiKey:t.apiKey,onUsage:t.onUsage};if(l==="write_file"||l==="update_file")try{let{path:c}=W(w.args);if(c){let L=G.resolve(process.cwd(),c),V=await zn();V&&V.file_focused===L&&V.full_content&&(Pt.forcedContent=V.full_content)}}catch{}qe.push(l);let Z=await Mo(l,w.args,Pt);if((l==="write_file"||l==="update_file")&&!Z.startsWith("ERROR:")){let{path:c}=W(w.args);if(c){let L=G.resolve(process.cwd(),c);Br(L)}}process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07");let je=Date.now();Zt=je,yield{type:"tool_time",content:je-I},lt=je;let ft=null;if(typeof Z=="object"&&Z.binaryPart&&(ft=Z.binaryPart,Z=Z.text),l==="search_keyword"){let{keyword:c,path:L}=W(w.args),V=typeof Z=="string"&&Z.startsWith("[GLOB]");V&&(Z=Z.slice(6).trimStart());let pe=typeof Z=="string"&&Z.startsWith("[DIR]");pe&&(Z=Z.slice(5).trimStart());let le=0;if(Z){let ne=Z.match(/Found (\d+) match/i);ne&&(le=parseInt(ne[1]))}let J=(L||"").trim().toLowerCase().replaceAll("\\","/"),ye=J==="#doc"||J==="#docs"||J==="#documentation"||J.includes("#skill/global/fluxflow")||J.includes("#skill/fluxflow")||J.includes("#skills/fluxflow")||J.includes("#skills/global/fluxflow"),be,q=115;process.stdout.isTTY&&(q=process.stdout.columns-5||120);let D=Math.max(10,(q+5)/3),Y=Math.max(10,(q+5)/4);if(ye)be=`${c?"\u2714":"\u2718"} Searched Documentation`;else{let ne=L?L.replace(/[\/\\]+$/,""):null,_t=ne&&ne!=="."?`${V?L:pe?`${ne}/*`:ne}`:"./",Et=_t.length>Y?`${_t.slice(0,Y)}...`:_t;be=`${c?"\u2714":"\u2718"} Searched: "${c?c.length>q/3?`${c.slice(0,D)}...`:c:""}" in "${Et.replaceAll("\\","/")}" \u2192 ${le} Match${le===1?"":"es"}`}let Pe=Math.min(be.length+4,q),_e=`${be.padEnd(Pe-2).substring(0,Pe-2)}`;yield{type:"visual_feedback",content:Dt(`${Ue?`
|
|
790
|
+
`:""}${_e}
|
|
791
|
+
`)},Ue=!1}if(l==="EmergencyRollback"){let{method:c}=W(w.args);if(c==="forceRevert"){let L=0;if(Z){let D=Z.match(/Total\s*:\s*(\d+)/i);D&&(L=parseInt(D[1]))}let pe=Z&&Z.startsWith("ERROR:")?"\u2718 Emergency Rollback Failed":`\u2714 Emergency Rollback \u2192 ${L} file${L===1?"":"s"} processed`,le=115;process.stdout.isTTY&&(le=process.stdout.columns-5||120);let J=await i(),ye=!1;J&&(ye=J.trim().length>0);let be=Math.min(pe.length+4,le),q=`${pe.padEnd(be-2).substring(0,be-2)}`;yield{type:"visual_feedback",content:Dt(`${Ue?`
|
|
792
792
|
`:""}${q}${ye?"":`
|
|
793
|
-
`}`)},Ue=!1}}if(l==="todo"){let{method:c,tasks:L,markDone:
|
|
794
|
-
`)}return be.filter(q=>String(q).trim()).map(q=>{let D=String(q).trim();return D.startsWith("- [")?D.substring(6).trim():D})};if(c==="create"?(pe="\x1B[32m\u2192\x1B[0m Created Goals",le=J(L).map(ye=>`\x1B[90m\u25CB\x1B[0m ${ye}`)):c==="append"?(pe="\x1B[34m\u2795\x1B[0m Added New Goals",le=J(L).map(ye=>`\x1B[90m\u25CB\x1B[0m ${ye}`)):c==="get"&&(pe=
|
|
793
|
+
`}`)},Ue=!1}}if(l==="todo"){let{method:c,tasks:L,markDone:V}=W(w.args),pe="",le=[],J=ye=>{if(!ye)return[];let be=Array.isArray(ye)?ye:[];if(be.length===0&&typeof ye=="string"){let q=ye.trim();if(q.startsWith("[")&&q.endsWith("]")){let D=q.match(/"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'/g);D?be=D.map(Y=>Y.slice(1,-1).replace(/\\(.)/g,"$1")):be=q.slice(1,-1).split(",").map(Y=>Y.trim()).filter(Boolean)}else be=ye.split(`
|
|
794
|
+
`)}return be.filter(q=>String(q).trim()).map(q=>{let D=String(q).trim();return D.startsWith("- [")?D.substring(6).trim():D})};if(c==="create"?(pe="\x1B[32m\u2192\x1B[0m Created Goals",le=J(L).map(ye=>`\x1B[90m\u25CB\x1B[0m ${ye}`)):c==="append"?(pe="\x1B[34m\u2795\x1B[0m Added New Goals",le=J(L).map(ye=>`\x1B[90m\u25CB\x1B[0m ${ye}`)):c==="get"&&(pe=V?"\x1B[36m\u21BB\x1B[0m Updated Goals":"\x1B[35m\u2022\x1B[0m Reviewed Goals",le=(Z||"").split(`
|
|
795
795
|
`).slice(1).join(`
|
|
796
796
|
`).split(`
|
|
797
797
|
`).filter(be=>be.trim().startsWith("- [")).map(be=>{let q=be.trim(),D=q.startsWith("- [x]");return`${D?"\x1B[32m\u2714\x1B[0m":"\x1B[90m\u25CB\x1B[0m"} ${D?"\x1B[90m":"\x1B[37m"}${q.substring(6).trim()}\x1B[0m`})),pe&&le.length>0){let ye=[`${pe}`,...le.map(D=>` ${D}`)].join(`
|
|
798
798
|
`),be=await i(),q=!1;be&&(q=be.trim().length>0),yield{type:"visual_feedback",content:Dt(`${Ue?`
|
|
799
799
|
`:""}${ye}${q?"":`
|
|
800
|
-
`}`)},Ue=!1}}l==="exec_command"&&t.onExecEnd&&(await new Promise(c=>setTimeout(c,800)),t.onExecEnd());let
|
|
801
|
-
`));let
|
|
800
|
+
`}`)},Ue=!1}}l==="exec_command"&&t.onExecEnd&&(await new Promise(c=>setTimeout(c,800)),t.onExecEnd());let Lt=Z&&Z.startsWith("DENIED:");Z&&!Z.startsWith("ERROR:")&&!Lt?(await Rt("toolSuccess"),t.onToolResult&&t.onToolResult("success",l)):Lt||(await Rt("toolFailure"),t.onToolResult&&t.onToolResult("failure",l));let $t=(Z||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");$t.includes("[[VERIFIED]]")&&($t=$t.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to save tokens.
|
|
801
|
+
`));let Sn;if($t.startsWith("[[SAME]]")){let L=$t.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),V=L.filter(le=>le.startsWith("File ")||le.trim().startsWith("- Stats:"));Sn=`[ACTION RESULT]: ${V.length>0?V.join(`
|
|
802
802
|
`):L.slice(0,2).join(`
|
|
803
803
|
`)}
|
|
804
|
-
[SYSTEM NOTE]: Content verified and persisted to disk. Full preview omitted to save tokens.`}else
|
|
804
|
+
[SYSTEM NOTE]: Content verified and persisted to disk. Full preview omitted to save tokens.`}else Sn=`[ACTION RESULT]: ${$t}`;De.push({role:"user",text:Sn,binaryPart:ft}),yn=!0;let me=`[ACTION RESULT]: ${Z.replaceAll(`[[VERIFIED]]
|
|
805
805
|
`,"").replaceAll(`
|
|
806
|
-
[[/VERIFIED]]`,"")||""}`;(l==="view_file"||l==="web_scrape"||l==="file_map")&&(me=`[ACTION RESULT]: ${M} (Context Locked for UI Clarity)`),yield{type:"tool_result",content:me,aiContent:
|
|
806
|
+
[[/VERIFIED]]`,"")||""}`;(l==="view_file"||l==="web_scrape"||l==="file_map")&&(me=`[ACTION RESULT]: ${M} (Context Locked for UI Clarity)`),yield{type:"tool_result",content:me,aiContent:Sn,binaryPart:ft,toolName:l},l==="memory"&&!Z.startsWith("ERROR:")&&(yield{type:"memory_updated"}),mt++}if(s==="Google"&&tn&&Date.now()-Si>=150){yield*Gn();let w=uo(tn);for(let I of w)yield I;tn="",Si=Date.now()}}p.usageMetadata&&(Qt=p.usageMetadata),Qt&&(yield{type:"liveTokens",content:Qt.totalTokenCount})}if(te&&(te=!1,tt?Re+="</think>":(fe+="</think>",s==="Google"?tn+="</think>":yield{type:"text",content:"</think>"})),tt&&Re.length>0){let p=0,_=Math.min(pt.length,Re.length);for(let X=_;X>0;X--)if(pt.endsWith(Re.substring(0,X))){p=X;break}let v=Re.substring(p);if(v){let ie=/(?:<(think|thought)>|\[(think|thought)\])(?:(?!(?:<\/(?:think|thought)>|\[\/(?:think|thought)\]))[\s\S])*$/i.test(pt)?v.replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])\s*/gi,""):v.replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])[\s\S]*?(?:<\/(think|thought)>|\[\/(think|thought)\])\s*/gi,"").replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])\s*/gi,"");if(ie)if(fe+=ie,s==="Google")tn+=ie;else{yield*Gn();let N=uo(ie);for(let K of N)yield K}}tt=!1,Re=""}if(bn){let p=bn;bn="",Zn=!1,At=null,Hn=!1,eo=!1,s==="Google"?tn+=p:yield{type:"text",content:p}}if(yield*Gn(),gt)break;let go=(fe||"").trim(),la=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(go.toLowerCase())||/\[\[END\]\]/i.test(go.toLowerCase()),ca=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(go.toLowerCase()),da=De.length>0||P!==null,ki=Ft(go).trim(),fa=/(\p{Emoji_Presentation}|\p{Extended_Pictographic})$/u.test(ki),ua=/([.!?"'*_`|\]\)”’~~]+|\s|`{3}|[\u200B-\u200D\uFEFF])$/u.test(ki.trim()),ga=/[.!?}"'`’“”]$|```$/s.test(ki)||ua||fa;!la&&!ca&&!da&&go.length>0,Xe=!0,await Rt("agent",s)}catch(oe){if(gt){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
|
|
807
807
|
|
|
808
|
-
\x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(String(oe).includes("Incomplete JSON segment at the end")){
|
|
808
|
+
\x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(String(oe).includes("Incomplete JSON segment at the end")){te&&(te=!1,tt?Re+="</think>":(fe+="</think>",yield{type:"text",content:"</think>"})),Xe=!0,await Rt("agent",s);break}if(te&&(te=!1,tt?Re+="</think>":fe+="</think>"),tt&&Re.length>0){let wt=0,kt=Math.min(pt.length,Re.length);for(let qt=kt;qt>0;qt--)if(pt.endsWith(Re.substring(0,qt))){wt=qt;break}let St=Re.substring(wt);if(St){let _n=/(?:<(think|thought)>|\[(think|thought)\])(?:(?!(?:<\/(?:think|thought)>|\[\/(?:think|thought)\]))[\s\S])*$/i.test(pt)?St.replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])\s*/gi,""):St.replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])[\s\S]*?(?:<\/(think|thought)>|\[\/(think|thought)\])\s*/gi,"").replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])\s*/gi,"");_n&&(fe+=_n)}tt=!1,Re=""}let H=oe instanceof Error?(()=>{try{return JSON.parse(JSON.parse(oe.message).error.message).error.message}catch{return String(oe)}})():String(oe),yt=new Date().toLocaleString(),bt=G.join(En,"agent");we.existsSync(bt)||we.mkdirSync(bt,{recursive:!0}),we.appendFileSync(G.join(bt,"error.log"),`ERROR [${yt}]: ${H}
|
|
809
809
|
|
|
810
810
|
----------------------------------------------------------------------
|
|
811
811
|
|
|
812
|
-
`);let xt=oe.status||oe.statusCode||oe.code,Gt=String(oe).includes("replicas at capacity");if(!(xt&&(xt>=500&&xt<600||xt===408||xt===429||Gt)||!xt&&(/status[ :]+(5\d\d|408|429)/i.test(String(oe))||/code[ :]+(5\d\d|408|429)/i.test(String(oe))||/(500|503|408|429)/.test(String(oe))))){if(Ve<sn-3)throw oe;yield{type:"text",content:
|
|
812
|
+
`);let xt=oe.status||oe.statusCode||oe.code,Gt=String(oe).includes("replicas at capacity");if(!(xt&&(xt>=500&&xt<600||xt===408||xt===429||Gt)||!xt&&(/status[ :]+(5\d\d|408|429)/i.test(String(oe))||/code[ :]+(5\d\d|408|429)/i.test(String(oe))||/(500|503|408|429)/.test(String(oe))))){if(Ve<sn-3)throw oe;yield{type:"text",content:H},yield{type:"status",content:"Error Occured"}}if(fe.trim().length>0||Je>1)if(Je<=sn){Je++;let wt=Math.min(1e3*Math.pow(2,Je-1),24e3);if(fe.trim().length>0){x.push({role:"agent",text:fe});let kt=`[system]
|
|
813
813
|
- seamless continuation: resume immediately. pick up from last words with zero gap/disruption
|
|
814
814
|
- no repetition: do not repeat any text already written
|
|
815
815
|
- no re-think: do not restart or open <think> if reasoning already started. continue the thinking and close thinking block </think> before chat output
|
|
@@ -817,42 +817,42 @@ ${Mn}`}let ze=l==="write_file"?"Created":"Edited",nt=G(w.args),Sn=Object.entries
|
|
|
817
817
|
- stealth: do not mention/apologize for cutoff [/system]`;De.length>0?De.forEach((St,qt)=>{qt===De.length-1?x.push({...St,text:`${St.text}
|
|
818
818
|
|
|
819
819
|
${kt}`}):x.push(St)}):x.push({role:"user",text:kt}),pt+=fe}for(let kt=wt/1e3;kt>0&&!gt;kt--)yield{type:"status",content:`Error Occured. Recovering Stream (${Je}/${sn}) [Retrying in ${kt.toFixed(0)}s]...`},await new Promise(St=>setTimeout(St,1e3));yield{type:"status",content:"Error Occured. Recovering Stream..."}}else throw new Error(`Stream collapsed too many times. (Failed to resolve ${sn} times)
|
|
820
|
-
Error log can be found in \`/export logs\``);else if(Ve<=sn){Ve++,Je=1,pt="";let wt=Math.min(1e3*Math.pow(2,Ve-1),32e3),kt=.8+Math.random()*.4,St=Math.round(wt*kt);
|
|
821
|
-
Error log can be found in \`/export logs\``)}}if(Qt){let
|
|
822
|
-
`),oe=Ft(
|
|
820
|
+
Error log can be found in \`/export logs\``);else if(Ve<=sn){Ve++,Je=1,pt="";let wt=Math.min(1e3*Math.pow(2,Ve-1),32e3),kt=.8+Math.random()*.4,St=Math.round(wt*kt);vn=!0,yield{type:"status",content:`Trying to reach ${e} (${Ve}/${sn}) [Retrying in ${(St/1e3).toFixed(0)}s]`};for(let qt=St/1e3;qt>0&&!gt;qt--)yield{type:"status",content:`Trying to reach ${e} (${Ve}/${sn}) [Retrying in ${qt.toFixed(0)}s]`},await new Promise(_n=>setTimeout(_n,1e3));yield{type:"status",content:`Trying to reach ${e}`}}else throw new Error(`Model ${e} cannot be reached. (Failed ${sn} times)
|
|
821
|
+
Error log can be found in \`/export logs\``)}}if(Qt){let te=Qt.totalTokenCount||0,oe=Qt.cachedContentTokenCount||0,H=(Qt.candidatesTokenCount||0)+(s==="Google"&&Qt.thoughtsTokenCount||0);await ut("tokens",te,s,ee),oe>0&&await ut("cachedTokens",oe,s,ee),H>0&&await ut("candidateTokens",H,s,ee),Ee!==null&&Ee>0&&await ut("ttft",Ee,s,ee),xo({provider:s,model:ee,prompt:Qt.promptTokenCount||0,cached:oe,output:H,reasoning:Qt.thoughtsTokenCount||0,ttft:Ee}),yield{type:"usage",content:Qt}}else Ee!==null&&Ee>0&&(await ut("ttft",Ee,s,ee),xo({provider:s,model:ee,prompt:0,cached:0,output:0,reasoning:0,ttft:Ee}));fe=zr(fe),xi.push(fe);let cl=Ft(fe),wi=Kr(fe),oa=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(wi.toLowerCase())||/\[\[END\]\]/i.test(wi.toLowerCase())||!0,dl=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(wi.toLowerCase()),fl=mt>0;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"};let ia=sl(fe,/(\[\s*(turn\s*:)?\s*(continue|finish)\s*\]|\[\[END\]\])/gi,"").trim(),Wn=(oa||De.length===0)&&!Ot&&!Un&&!Wt;if(Wn=De.length===0?Wn:!1,Wn=zt||Uo?!1:Wn,fe&&fe.trim().endsWith('")]')&&De.length===0&&(Wn=!1),Wn){ps=!0;let te=xi.join(`
|
|
822
|
+
`),oe=Ft(te).trim();yield{type:"interactive_turn_finished",data:{agentText:Ie,fullAgentTextRaw:te,history:[...x],needTitle:Se}},x.length>0&&x[x.length-1].role==="agent"?x[x.length-1].text=oe:x.push({role:"agent",text:oe}),x.forEach(H=>{if(H.role==="user"&&H.text&&(H.text=H.text.replace(/\n\[COMPILE ERROR\][\s\S]*?\[\/ERROR\]/g,""),H.text=H.text.replaceAll(`
|
|
823
823
|
|
|
824
824
|
[system] user question. resolve this specific query within '[ANSWER] ... [/ANSWER]' concisely, naturally [/system]
|
|
825
825
|
`,"").replaceAll(`[system] user question. resolve this specific query within '[ANSWER] ... [/ANSWER]' concisely, naturally
|
|
826
826
|
**strictly follow thinking policy as high priority. do not start a response without <think>...</think>** [/system]
|
|
827
827
|
`,"").replaceAll(`[system] **strictly follow thinking policy as high priority. do not start a response without <think>...</think>** [/system]
|
|
828
|
-
`,"").replaceAll(/\n\[system\] WARNING, Turn Limit Impending: Step \d+\/\d+\. Wrap up quickly\/prompt user to continue & use \[\[END\]\] quickly\. \[\/system\]/g,""),
|
|
828
|
+
`,"").replaceAll(/\n\[system\] WARNING, Turn Limit Impending: Step \d+\/\d+\. Wrap up quickly\/prompt user to continue & use \[\[END\]\] quickly\. \[\/system\]/g,""),H.text=H.text.replaceAll(/\n\[system\] File Changes:\n(?:\* .+ \(created|modified|deleted\)\n)*\[\/system\]/g,""),(s==="Mistral"||s==="Google"&&e?.toLowerCase().startsWith("gemma"))&&(H.text.startsWith("[ACTION RESULT]")||H.text.startsWith("[TOOL RESULT]")))){let bt=`
|
|
829
829
|
[system] Action result received. Analyze output and proceed with your turn [/system]`,xt=`
|
|
830
|
-
[system] Action result received. Analyze output and proceed with your turn. **strictly follow thinking policy. do not start a response without <think>...</think>** [/system]`;
|
|
830
|
+
[system] Action result received. Analyze output and proceed with your turn. **strictly follow thinking policy. do not start a response without <think>...</think>** [/system]`;H.text=H.text.replaceAll(xt,"").replaceAll(bt,"").trim()}}),yield{type:"status",content:"[end]"}}if(Wn)break;let sa=ia.trim()||"*Working...*";if(x.push({role:"agent",text:sa}),De.length>0||yn){if(De.length>0){let te=De.map(Gt=>Gt.text).join(`
|
|
831
831
|
|
|
832
|
-
`),
|
|
832
|
+
`),H=Ft(fe).replace(/\[{1,2}(?:tool|action):[\s\S]*?\)\s*\]{1,2}/gi,""),yt=(H.match(/\[(?:tool|action):/gi)||[]).length,bt=De.length+yt;if(De.length<bt){let Gt=Vr(H);te+=`
|
|
833
833
|
|
|
834
834
|
[system] Only ${De.length} out of ${bt} attempted tool calls were executed.
|
|
835
835
|
${Gt?`Parsing Issues Detected:
|
|
836
836
|
${Gt}
|
|
837
|
-
`:""}Verify proper structure compliance [action:ActionName(arg="value")] & try failed calls again [/system]`;let Fe=bt-De.length;for(let wt=0;wt<Fe;wt++)await Rt("toolFailure")}let xt=De.find(Gt=>Gt.binaryPart)?.binaryPart||null;x.push({role:"user",text:
|
|
838
|
-
${
|
|
837
|
+
`:""}Verify proper structure compliance [action:ActionName(arg="value")] & try failed calls again [/system]`;let Fe=bt-De.length;for(let wt=0;wt<Fe;wt++)await Rt("toolFailure")}let xt=De.find(Gt=>Gt.binaryPart)?.binaryPart||null;x.push({role:"user",text:te,binaryPart:xt})}}else if(!gt){let te=fe.replace(/(?:<(think|thought|thoughts)>|\[(think|thought|thoughts)\])[\s\S]*?(?:<\/(think|thought|thoughts)>|\[\/(think|thought|thoughts)\]|$)/i,""),oe=(te.match(/\[(?:tool|action):/gi)||[]).length;if(Uo||zt||oe>0){let H=Vr(te),yt=H?`[system] Failed to execute ${oe>0?oe:1} tool call${oe>1?"s":""} due to syntax/structure issues:
|
|
838
|
+
${H} [/system]`:`[system] Failed to execute ${oe>0?oe:1} tool${oe>1?"s":""}. Verify proper structure compliance [action:ActionName(arg="value")] & try again [/system]`;x.push({role:"user",text:yt}),await Rt("toolFailure"),yield{type:"visual_feedback",content:`
|
|
839
839
|
${Dt("\u2718 Model produced malformed tool call")}
|
|
840
840
|
`}}else yield{type:"visual_feedback",content:`
|
|
841
841
|
${Dt("\u2718 Loop Detected")}
|
|
842
|
-
`},x.push({role:"user",text:`[system] ${
|
|
842
|
+
`},x.push({role:"user",text:`[system] ${Un&&!Ot?"Stuttering Detected by Internal System. Re-calibrate your response & proceed.":`${Ot?" Over Thinking":" Loop"} Detected by Internal System${Ot?" for current Effort Level":""}. ${Ot?"If you have planned the task, prioritize execution/output":"If you have finished your task provide a simple summary and end"}`} [/system]`});Ot=!1,Un=!1,Wt=!1}h?.advanceRollback&&await wo.recordTurnDelta(m,O+1,qe),Uo=mt>0||yn}if(!ps&&!gt){let O="\u2726 Turn safety limit reached. Stopping execution.";yield{type:"text",content:`
|
|
843
843
|
|
|
844
844
|
${O}
|
|
845
|
-
`};let Be=(
|
|
845
|
+
`};let Be=(xi.join(`
|
|
846
846
|
`)+`
|
|
847
|
-
${O}`).trim();yield{type:"interactive_turn_finished",data:{agentText:
|
|
847
|
+
${O}`).trim();yield{type:"interactive_turn_finished",data:{agentText:Ie,fullAgentTextRaw:Be,history:[...x],needTitle:Se}},yield{type:"status",content:"[end]"}}}catch(k){let x=k?.cause?` (Cause: ${k.cause?.message||String(k.cause)})`:"",ve=(k instanceof Error?(()=>{try{return JSON.parse(JSON.parse(k.message).error.message).error.message}catch{return(k.message?`${k.message}${x}`:"")||String(k)}})():String(k)).replace(/^(Error:\s*)+/i,"");s==="Google"&&!/^[A-Z0-9_\-\s]+ ERROR:/i.test(ve)&&(ve=`GEMINI ERROR: ${ve}`);let It=new Date().toLocaleString(),fn=G.join(En,"agent");yield{type:"text",content:`
|
|
848
848
|
|
|
849
849
|
\u2726 CRITICAL ERROR: ${ve.includes("fetch failed")?"Failed to Connect. Check your Internet Connection or Wait a moment":ve}
|
|
850
|
-
\u2800`},we.existsSync(
|
|
850
|
+
\u2800`},we.existsSync(fn)||we.mkdirSync(fn,{recursive:!0}),we.appendFileSync(G.join(fn,"error.log"),`CRITICAL ERROR [${It}]: ${k}${k?.cause?`
|
|
851
851
|
CAUSE: ${k.cause?.stack||k.cause}`:""}
|
|
852
852
|
|
|
853
853
|
----------------------------------------------------------------------
|
|
854
854
|
|
|
855
|
-
`),typeof flushGoogleBuffer=="function"&&(yield*flushGoogleBuffer()),yield{type:"tool_result",content:`ERROR: [INTERNAL CRITICAL] ${ve}`}}finally{xe&&(clearInterval(xe),xe=null),typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),await
|
|
855
|
+
`),typeof flushGoogleBuffer=="function"&&(yield*flushGoogleBuffer()),yield{type:"tool_result",content:`ERROR: [INTERNAL CRITICAL] ${ve}`}}finally{xe&&(clearInterval(xe),xe=null),typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),await Xo.commitTransaction(),h?.advanceRollback&&await wo.cleanup(m),await zn()}yield{type:"status",content:null}},kd=async(e,n,t=null,i=null,o=50,r=null,d=!1)=>{let a=await bo(),u={...a,...n},m=process.env.SUBAGENT_MODEL?process.env.SUBAGENT_MODEL.trim():null,b=process.env.SUBAGENT_PROVIDER?process.env.SUBAGENT_PROVIDER.trim():null,h=new Date,f=`${h.getFullYear()}-${h.toLocaleString("en-US",{month:"short"}).toUpperCase()}-${String(h.getDate()).padStart(2,"0")}, ${h.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).replace(":","-")}`,g=(xe=>{if(!xe)return null;let k=xe.toLowerCase();return k==="google"?"Google":k==="deepseek"?"DeepSeek":k==="openrouter"?"OpenRouter":k==="nvidia"?"NVIDIA":k==="mistral"?"Mistral":k==="ollama"?"Ollama":k==="inferx"?"InferX":k==="sensenova"?"SenseNova":k==="poolside"?"Poolside":k==="9router"||k==="9Router"?"9router":k==="aihubmix"||k==="aihub"?"AIHubMix":k==="explabs"||k==="experientiallabs"||k==="experimentallabs"?"ExpLabs":k==="tokenharbor"||k==="token harbor"||k==="token_harbor"||k==="thk"?"TokenHarbor":k==="infron"?"Infron":k==="apinex"||k==="apx"?"APInex":k==="c_openai"||k==="custom_openai"||k==="custom (openai)"||k==="custom"?"c_openai":null})(b),T=u?.systemSettings?.CustomSubAgent?u?.systemSettings?.SubAgentModel:null,ue=u?.systemSettings?.CustomSubAgent?u?.systemSettings?.SubAgentProvider:null,y=null;if(T==="ENV"?(y=m,m&&g&&(u.aiProvider=g)):T&&T!=="Default"?(y=T,ue&&(u.aiProvider=ue)):m&&g&&(u.aiProvider=g),u.aiProvider){let xe=await _i(u.aiProvider);xe&&(u.apiKey=xe)}let R=xe=>{if(!xe||typeof xe!="string")return{allowed:!0};let k=[/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 x of k)if(x.test(xe))return{allowed:!1,reason:`Blocked potentially destructive or unsafe command pattern: "${x.source}"`};return{allowed:!0}},F=t||y||n?.modelName||n?.activeModel||a.activeModel,j=process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux",$=`-- ACTIONS (path = relative to CWD, path separator: '/') --
|
|
856
856
|
In chat output the format \`[action:ActionName(arg1="value1")]\` in NEW line
|
|
857
857
|
Rules:
|
|
858
858
|
- JSON escape literal sequences, backslash: \\\\, newLine: \\ n
|
|
@@ -877,7 +877,7 @@ ${d?"- AskMain(question=string). Communicate with PARENT/MAIN AGENT. When clarif
|
|
|
877
877
|
- ReadFile(path=string, startLine?=int, endLine?=int)
|
|
878
878
|
- PatchFile(path=string, allowMultiple?=bool, searchContent1="string match OR ^LINE:start..end$", newContent1=string, ...MAX15). Small searchString. Line Anchors: ^LINE:...$ syntax, must for large blocks & escape sequences
|
|
879
879
|
- WriteFile(path=string, content=string). Creates/Overwrites. File Exist? PatchFile > WriteFile
|
|
880
|
-
- Run(command=string). Runs ${
|
|
880
|
+
- Run(command=string). Runs ${j==="Windows"?As()?"powershell":"windows CMD":"bash"} command. Destructive command \u2192 Ask user`.trim(),A=`=== START SYSTEM PROMPT ===
|
|
881
881
|
Identity: FluxFlow subagent helping the main Agent
|
|
882
882
|
Your task is: "${e}"
|
|
883
883
|
CWD: ${process.cwd()}
|
|
@@ -890,9 +890,9 @@ Main focus: actions and task, not chatting
|
|
|
890
890
|
On completion, provide a detailed summary in Tables/Markdown Format with file modified info. If any task failed report back in detail
|
|
891
891
|
|
|
892
892
|
Current Time: ${f}
|
|
893
|
-
=== END SYSTEM PROMPT ===`,he=[{role:"user",text:`Complete this task: ${e}`}],Se=0,
|
|
894
|
-
${
|
|
895
|
-
`),he.push({role:"agent",text:
|
|
893
|
+
=== END SYSTEM PROMPT ===`,he=[{role:"user",text:`Complete this task: ${e}`}],Se=0,Ie="";for(;Se<o;){let xe=await Ii("subagent",u);if(!xe.allowed)throw new Error(xe.reason||`Budget Exhausted for Provider (${u?.aiProvider||"Subagent"})`);if(gt){if(n?.taskId&&typeof Kt<"u"){let S=Kt.find(E=>E.id===n.taskId);S&&(S.status="cancelled")}throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}if(n?.taskId&&typeof Kt<"u"){let S=Kt.find(E=>E.id===n.taskId);if(S&&S.status==="cancelled")throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}let k=he.map(S=>({role:S.role==="user"?"user":"model",parts:[{text:S.text}]}));r&&r(`[Subagent Turn ${Se+1}]...`);let x=["Fast","Low","Medium","High"],rt=process.env.SUBAGENT_THINKING,ve=x.includes(rt)?rt:"Low",fn=(await hi(u,F,k,A,ve)).text||"",Mt=zr(Ft(fn).trim());Ie=Mt,r&&r(`[Subagent Response]
|
|
894
|
+
${Mt}
|
|
895
|
+
`),he.push({role:"agent",text:Mt});let Vt=ao(Mt);if(Vt.length===0)break;let un=Vt.filter(S=>S.toolName.toLowerCase()==="askmain"||S.toolName.toLowerCase()==="ask_main"),gn=!1,Bt="";for(let S of Vt){if(gt){if(n?.taskId&&typeof Kt<"u"){let C=Kt.find(B=>B.id===n.taskId);C&&(C.status="cancelled")}throw new Error("Subagent task was cancelled.")}if(n?.taskId&&typeof Kt<"u"){let C=Kt.find(B=>B.id===n.taskId);if(C&&C.status==="cancelled")throw new Error("Subagent task was cancelled.")}let E=S.toolName.toLowerCase();if(E==="askuser"&&(E="ask"),E==="askmain"||E==="ask_main"){if(gn)continue;gn=!0;let C="";if(un.length===1?C=W(un[0].args).question||un[0].args:C=un.map((B,ke)=>{let Ce=W(B.args);return`Q${ke+1}: ${Ce.question||B.args}`}).join(`
|
|
896
896
|
`),n.onAskMain){r&&r(`[Executing Tool] AskMain("${C}")...`);let B=await n.onAskMain(C);r&&r(`[Action Result]
|
|
897
897
|
Answer from Main Agent: ${B}
|
|
898
898
|
`),Bt+=`[ACTION RESULT for AskMain]: Answer from Main Agent: ${B}
|
|
@@ -902,18 +902,18 @@ Answer from Main Agent: ${B}
|
|
|
902
902
|
`;continue}if(!(i?i.some(C=>C.toLowerCase()===E):!0)){let C=`ERROR: Tool [${S.toolName}] is not in the allowed tools list for this subagent.`;r&&r(`[Blocked Tool Call] ${S.toolName} - not allowed
|
|
903
903
|
`),Bt+=`${C}
|
|
904
904
|
|
|
905
|
-
`;continue}if(E==="exec_command"||E==="execcommand"||E==="run"){let C=
|
|
905
|
+
`;continue}if(E==="exec_command"||E==="execcommand"||E==="run"){let C=W(S.args).command||"",B=R(C);if(!B.allowed){let ke=`ERROR: [SECURITY RESTRICTION] Subagent execution blocked command: ${B.reason}`;r&&r(`[Blocked Command] ${C} - ${B.reason}
|
|
906
906
|
`),Bt+=`${ke}
|
|
907
907
|
|
|
908
|
-
`;continue}}let re="";if(E==="web_search"||E==="websearch")re=`\u2714 \x1B[95mSearched\x1B[0m: ${
|
|
908
|
+
`;continue}}let re="";if(E==="web_search"||E==="websearch")re=`\u2714 \x1B[95mSearched\x1B[0m: ${W(S.args).query||""}`;else if(E==="web_scrape"||E==="webscrape")re=`\u2714 \x1B[95mScraped\x1B[0m: ${W(S.args).url||""}`;else if(E==="search_keyword"||E==="searchkeyword"||E==="codesearch"||E==="code_search"){let C=W(S.args),B=C.keyword||"",ke=C.path||"";re=`${B?"\u2714":"\u2718"} \x1B[95mSearched\x1B[0m: ${B||"No Query"}${ke?` \u2192 ${ke.replaceAll("\\","/")}`:""}`}else if(E==="view_file"||E==="viewfile"||E==="readfile")re=`\u2714 \x1B[95mRead\x1B[0m: ${(W(S.args).path||"").replaceAll("\\","/")}`;else if(E==="find_file"||E==="findfile"){let C=W(S.args),B=C.basename||C.name||C.path||C.file||C.query||"";re=`${B?"\u2714":"\u2718"} \x1B[95mLocated\x1B[0m: ${B||"No Query"}`}else if(E==="list_files"||E==="read_folder"||E==="readfolder"){let C=W(S.args).path||null,B=W(S.args).recurse||0;re=`${C?"\u2714":"\u2718"} \x1B[95mBrowsed\x1B[0m: ${C?`${C.replaceAll("\\","/")}${B>0?`${C.endsWith("/")?`*${B}`:`/*${B}`}`:`${C.endsWith("/")?"":"/"}`}`:""}`}else if(E==="write_file"||E==="writefile"){let C=W(S.args).path||null;re=`${C?"\u2714":"\u2718"} \x1B[95mCreated\x1B[0m: ${C?`${C.replaceAll("\\","/")}`:"No File Changes"}`}else if(E==="update_file"||E==="updatefile"||E==="patchfile"||E==="patch_file"){let C=W(S.args),B=C.path||null,Ce=Object.entries(C).some(([Te,Me])=>Te.startsWith("searchContent")&&typeof Me=="string"&&Me.startsWith("^LINE:"))?"\u1361":":";re=`${B?"\u2714":"\u2718"} \x1B[95mEdited\x1B[0m${Ce} ${B?`${B.replaceAll("\\","/")}`:"No File Changes"}`}else if(E==="exec_command"||E==="execcommand"||E==="run"){let C=W(S.args).command||null;re=`${C?"\u2714":"\u2718"} \x1B[95mExecuted\x1B[0m: ${C?C.slice(0,100)+(C.length>100?"...":""):"No Command"}`}else if(E==="file_map"||E==="filemap"){let C=W(S.args).path||"";re=`${C?"\u2714":"\u2718"} \x1B[95mIndexed\x1B[0m: ${C?`${C.replaceAll("\\","/")}`:"File Not Found"}`}else if(E==="await"){let{time:C}=W(S.args),B=parseFloat(C)||0;B<10&&(B=10),B>180&&(B=180),re=`\u2714 \x1B[95mAwaiting\x1B[0m \u2192 ${(Ce=>{if(Ce>=60){let Te=Math.floor(Ce/60),Me=Ce%60;return`${Te}m${Me>0?` ${Me}s`:""}`}return`${Ce}s`})(B)}`}else{let C=rs[E]||S.toolName,B=Xn(E,S.args);re=`\u2714 \x1B[95m${C}\x1B[0m${B?`: ${B}`:""}`}n.onVisualFeedback&&re&&n.onVisualFeedback(re),r&&r(`[Executing Tool] ${S.toolName}(${S.args})...`);try{let C=await Mo(S.toolName,S.args,{...n,mode:"Flux"});if(r&&r(`[Action Result]
|
|
909
909
|
${C}
|
|
910
910
|
`),Bt+=`[ACTION RESULT for ${S.toolName}]: ${C}
|
|
911
911
|
|
|
912
912
|
`,await Rt("toolSuccess"),E==="patchfile"||E==="update_file"||E==="updatefile"||E==="patch_file"){if(C){let B=C.split(`
|
|
913
|
-
`),ke=0,Ce=0,Te=!1;for(let
|
|
914
|
-
`)){if(
|
|
913
|
+
`),ke=0,Ce=0,Te=!1;for(let Me of B){if(Me.includes("[DIFF_START]")){Te=!0;continue}if(Me.includes("[DIFF_END]")){Te=!1;continue}Te&&(/^\+\s*\d+/.test(Me)?ke++:/^\-\s*\d+/.test(Me)&&Ce++)}(ke>0||Ce>0)&&(await ut("linesAdded",ke),await ut("linesRemoved",Ce))}}else if((E==="writefile"||E==="write_file")&&C){let B=C.match(/- Stats: \[(\d+) lines/),ke=B?parseInt(B[1]):0,Ce=0;if(C.includes("Old File contents:")){let Te=!1;for(let Me of C.split(`
|
|
914
|
+
`)){if(Me.includes("Old File contents:")){Te=!0;continue}Te&&(Me.startsWith("- Content Preview:")||Me.trim()===""&&!/^\s*\d+\s*\|/.test(Me)?Te=!1:/^\s*\d+\s*\|/.test(Me)&&Ce++)}}(ke>0||Ce>0)&&(await ut("linesAdded",ke),await ut("linesRemoved",Ce))}}catch(C){let B=`ERROR: Execution failed for [${S.toolName}]: ${C.message}`;r&&r(`[Tool Error] ${B}
|
|
915
915
|
`),Bt+=`${B}
|
|
916
916
|
|
|
917
917
|
`,await Rt("toolFailure")}}let ht="";if(n?.taskId&&typeof Kt<"u"){let S=Kt.find(E=>E.id===n.taskId);if(S&&S.pendingSteerMessages&&S.pendingSteerMessages.length>0){let E=[...S.pendingSteerMessages];S.pendingSteerMessages=[];for(let $e of E)ht+=`
|
|
918
918
|
|
|
919
|
-
[STEERING INSTRUCTION FROM MAIN AGENT]: ${$e}`,r&&r(`[Subagent Steered] ${$e}`)}}let Le=(Bt.trim()+ht).trim();he.push({role:"user",text:Le}),Se++}return
|
|
919
|
+
[STEERING INSTRUCTION FROM MAIN AGENT]: ${$e}`,r&&r(`[Subagent Steered] ${$e}`)}}let Le=(Bt.trim()+ht).trim();he.push({role:"user",text:Le}),Se++}return Ie};export{io as a,ci as b,kc as c,Tc as d,lc as e,cc as f,Cc as g,ui as h,Rc as i,Xa as j,hd as k,Ja as l,Qa as m,ss as n,Ft as o,gi as p,zr as q,nl as r,md as s,pd as t,ls as u,yd as v,bd as w,hi as x,xd as y,wd as z,Sd as A,kd as B};
|