fluxflow-cli 4.49.0 → 5.0.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/ARCHITECTURE.md +7 -16
- package/README.md +1 -4
- package/TOOLS.md +0 -9
- package/UI_FEATURES.md +1 -2
- package/dist/chunks/ai-WBRHU7IH.js +1 -0
- package/dist/chunks/app-ML5GKD3A.js +325 -0
- package/dist/chunks/{auto_completion-33R46AFF.js → auto_completion-UG6IEWD2.js} +1 -1
- package/dist/chunks/{chat-BA72I6O3.js → chat-ISCVWNVN.js} +1 -1
- package/dist/chunks/chunk-24LJKH4G.js +847 -0
- package/dist/chunks/chunk-7SGZ66KT.js +44 -0
- package/dist/chunks/chunk-B4UKMX5E.js +1 -0
- package/dist/chunks/{chunk-Z5D4VQSG.js → chunk-EXT42EJZ.js} +1 -1
- package/dist/chunks/{chunk-IMX3PWYO.js → chunk-GBH7XI5A.js} +1 -1
- package/dist/chunks/{chunk-ZCM4J7JT.js → chunk-J4J3F6BT.js} +1 -1
- package/dist/chunks/chunk-LQM3JK7N.js +1 -0
- package/dist/chunks/{chunk-AIWOSKP3.js → chunk-QESQR5GB.js} +1 -1
- package/dist/chunks/chunk-V36DXF56.js +13 -0
- package/dist/chunks/{chunk-TNA3R7TS.js → chunk-ZNO55RNG.js} +1 -1
- package/dist/chunks/{click-HMFVJIQN.js → click-AWHZCV2E.js} +2 -2
- package/dist/chunks/{computer_action-6AYM3W7D.js → computer_action-MO2JR2XH.js} +1 -1
- package/dist/chunks/{custom_openai-HY6EEQI2.js → custom_openai-K554R7Q5.js} +1 -1
- package/dist/chunks/{drag-H53TOSDP.js → drag-D2GVPIQB.js} +1 -1
- package/dist/chunks/{generate_image-JS7J4FLD.js → generate_image-45UQ6P2B.js} +1 -1
- package/dist/chunks/{invoke-WGWAIYZH.js → invoke-DVZUJJV3.js} +2 -2
- package/dist/chunks/{invokeSync-DCL3EMVV.js → invokeSync-NEZGW27B.js} +2 -2
- package/dist/chunks/{key_press-NF322TXF.js → key_press-AQNKL6UM.js} +1 -1
- package/dist/chunks/{keyboard_typing-OADL5LPA.js → keyboard_typing-QSBPTZJ6.js} +1 -1
- package/dist/chunks/{mistral-YTTOZB2J.js → mistral-ON6RQMK7.js} +1 -1
- package/dist/chunks/{model_config-JTMSQGKH.js → model_config-QRYAVWHF.js} +1 -1
- package/dist/chunks/{nvidia-ON4Q6Q26.js → nvidia-I6DPWP6U.js} +2 -2
- package/dist/chunks/{ollama-NWY2XLYF.js → ollama-6WSZPCI5.js} +1 -1
- package/dist/chunks/{recapture_screen-IXVMQR5C.js → recapture_screen-PPXYK2YY.js} +1 -1
- package/dist/chunks/{screen_grid-DGIDOOQD.js → screen_grid-3RU324CV.js} +1 -1
- package/dist/chunks/{scroll-B3HCFDTS.js → scroll-TSU6MTGU.js} +1 -1
- package/dist/chunks/search_keyword-DZY4MWV7.js +8 -0
- package/dist/chunks/{secrets-NGDMM5RJ.js → secrets-TNMLVMST.js} +1 -1
- package/dist/chunks/{secrets_v2-R5GMXRT3.js → secrets_v2-OBRWR3UT.js} +1 -1
- package/dist/chunks/{settings-JME7GCEU.js → settings-PUFSRWT3.js} +1 -1
- package/dist/chunks/update_file-TGEB5UWK.js +13 -0
- package/dist/chunks/usage-EBE2OVES.js +1 -0
- package/dist/chunks/{usageServer-RJDE5QDZ.js → usageServer-RTK5N5KE.js} +1 -2
- package/dist/chunks/write_file-O6OF7Z2W.js +32 -0
- package/dist/cli.js +27 -24
- package/dist/model_config.json +2 -30
- package/dist/package.json +2 -2
- package/model_config.json +2 -30
- package/package.json +2 -2
- package/dist/chunks/ai-QEMKCYGG.js +0 -1
- package/dist/chunks/app-6TAUOS56.js +0 -333
- package/dist/chunks/chunk-2XQIWDKW.js +0 -1
- package/dist/chunks/chunk-2YDU2B2F.js +0 -13
- package/dist/chunks/chunk-36FKJWXK.js +0 -949
- package/dist/chunks/chunk-AMFNIFF3.js +0 -44
- package/dist/chunks/chunk-HTOLY3HR.js +0 -1
- package/dist/chunks/search_keyword-UXNKLCGC.js +0 -8
- package/dist/chunks/update_file-YXW37NRJ.js +0 -13
- package/dist/chunks/usage-URT2EC23.js +0 -1
- package/dist/chunks/write_file-WMLWKQKI.js +0 -32
|
@@ -0,0 +1,847 @@
|
|
|
1
|
+
import{a as Bs}from"./chunk-HFTI3R3Q.js";import{a as ho}from"./chunk-52STSLCN.js";import{a as Ot}from"./chunk-56EJGQU3.js";import{a as Ws}from"./chunk-4BLSASW6.js";import{c as Oi,g as $i,h as Os,i as $s,j as Ls}from"./chunk-7SGZ66KT.js";import{b as Ds,c as Ns,d as Li,f as Fs}from"./chunk-UIL6OCU4.js";import{a as Yo}from"./chunk-6EYQQ7GQ.js";import{a as L}from"./chunk-Y5JU726N.js";import{b as Ps}from"./chunk-QESQR5GB.js";import{y as Ii}from"./chunk-J4J3F6BT.js";import{f as qo,l as St,o as Mi,p as an,r as Pi}from"./chunk-V36DXF56.js";import{b as zo}from"./chunk-B4UKMX5E.js";import{l as et,m as Vo}from"./chunk-LQM3JK7N.js";import{c as rn,d as _i,e as Ko}from"./chunk-P5HBJA23.js";import{a as Cn,b as Ho,c as Es,d as Wn,e as _s,k as jo,l as Ri,m as Is,r as Ei,w as mo,x as po,y as Ms}from"./chunk-26BQ45XP.js";import{GoogleGenAI as ia,ThinkingLevel as Ke,HarmBlockThreshold as di,HarmCategory as fi}from"@google/genai";var Xo={xHigh:"Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking",High:"Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking",Medium:"Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking",Minimal:"Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking",Off:"NO thinking. Immediate response. Verify imports, tool results & system stability"};import Ut from"fs";import Wt from"path";import La from"os";import ln from"fs";import vn from"path";import Zs from"fs";import Di from"path";import{execSync as er}from"child_process";import{fileURLToPath as Pa}from"url";var Us=`# FluxFlow CLI Startup & Flags Reference
|
|
2
|
+
|
|
3
|
+
Launch command syntax:
|
|
4
|
+
fluxflow [options]
|
|
5
|
+
|
|
6
|
+
## Supported CLI Flags
|
|
7
|
+
* --mode flux | flow | icu | fluxcu \u2192 Startup mode
|
|
8
|
+
* --model model-id \u2192 Session model override
|
|
9
|
+
* --provider google | deepseek | openrouter | nvidia | mistral | ollama | inferx | sensenova | aihubmix | poolside | 9router | explabs | tokenharbor | infron \u2192 Override default AI provider
|
|
10
|
+
* --key key@provider \u2192 Set new API key for provider
|
|
11
|
+
* --thinking Fast | Low | Medium | High | xHigh \u2192 Override reasoning depth
|
|
12
|
+
* --path project/path \u2192 Set working directory for session
|
|
13
|
+
* --memory on | off \u2192 Toggle persistent long-term agent memory
|
|
14
|
+
* --resume session-id \u2192 Resume previous chat session programmatically
|
|
15
|
+
* --allocation mb \u2192 Override Node.js --max-old-space-size in MB (Req env.EXPERIMENTAL_MEMORY_MANAGER enabled \u2192 Ref: references/ENV.md)
|
|
16
|
+
* --package npm | pnpm | yarn | bun \u2192 Override package manager for core updates
|
|
17
|
+
* --auto-del 1d | 7d | 30d \u2192 History auto-deletion retention timeframe
|
|
18
|
+
* --auto-exec on | off / --yolo on | off \u2192 Toggle autonomous command execution
|
|
19
|
+
* --external-access on | off \u2192 Toggle permission to read/write files outside CWD
|
|
20
|
+
* --usage / --budget \u2192 Launch browser token analytics dashboard
|
|
21
|
+
* --export error \u2192 Export system error logs to timestamped file
|
|
22
|
+
* --update check \u2192 Check latest version on npm
|
|
23
|
+
* --update check latest \u2192 Print latest version on npm
|
|
24
|
+
* --update [latest] \u2192 Upgrade app to latest release
|
|
25
|
+
* --version, -v \u2192 Show installed version
|
|
26
|
+
* --help \u2192 CLI help menu
|
|
27
|
+
* --help commands \u2192 In-chat slash commands list
|
|
28
|
+
* --playground \u2192 Launch Playground mode
|
|
29
|
+
* --prompt, -p \u2192 Non interactive CLI chat, no tools. --new for new headless chat. Holds conversation context upto 10m inactivity or 69 turns. Supports piping from shell, --run if want the command to visible in context. eg \`fluxflow --run "git diff" -p "summarize this" --new\`
|
|
30
|
+
`;var Gs=`# Env Variables
|
|
31
|
+
|
|
32
|
+
* Locations:
|
|
33
|
+
* Shell
|
|
34
|
+
* Global: ~/.fluxflow/.env.fluxflow | ~/.fluxflow/.env.agents
|
|
35
|
+
* Workspace: ./.env.fluxflow | ./.env.agents
|
|
36
|
+
|
|
37
|
+
## Core Variables
|
|
38
|
+
* SUBAGENT_MODEL \u2192 Model override for sub-agents
|
|
39
|
+
* SUBAGENT_PROVIDER \u2192 Provider override for sub-agents
|
|
40
|
+
* NVIDIA_BASE_URL \u2192 Custom endpoint URL for NVIDIA NIM (Cloud/Local OpenAI Compatible)
|
|
41
|
+
* SUBAGENT_THINKING - Fast, Low (default), Medium, High. Affects at High Level, not Low Level. --map takes priority
|
|
42
|
+
* NVIDIA_API_KEY \u2192 API key for NVIDIA NIM
|
|
43
|
+
* OLLAMA_HOST \u2192 If different from default
|
|
44
|
+
* SHELL \u2192 Terminal shell executable
|
|
45
|
+
* ADJUST_WINDOWS_COMMAND - If true, Flux Flow will adjust commands for windows if model mistakenly use UNIX all time.
|
|
46
|
+
* ENABLE_9ROUTER \u2192 Enables 9Router provider. Can use OAuth subscription like Codex, Claude Code, GitHub Copilot etc. or use providers not natively in Fluxflow. Set ENV ENABLE_9ROUTER=true, needs 9router package installed (via npm/npx etc) & running
|
|
47
|
+
* NINEROUTER_URL \u2192 If different from default, Any OpenAI Compatible
|
|
48
|
+
* NINEROUTER_KEY \u2192 if any
|
|
49
|
+
* MAX_LOOPS - ENV control for number of max turns for main agent
|
|
50
|
+
* SUBAGENT_MAX_TURNS
|
|
51
|
+
|
|
52
|
+
## Diagnostic & Optimization Flags
|
|
53
|
+
* SHOW_DEBUG_GRID \u2192 (true|false, default: false) Coordinate grid overlay for Computer Use tooling
|
|
54
|
+
* DEBUG_OCR \u2192 (true|false, default: false) Enables verbose OCR diagnostic logs
|
|
55
|
+
* EXPERIMENTAL_MEMORY_MANAGER \u2192 (true|false, default: false) Reduces app memory footprint, slower boot times
|
|
56
|
+
|
|
57
|
+
* NO_DEV \u2192 (true|false, default: false) Token optimization flag; strips developer metadata and docs
|
|
58
|
+
|
|
59
|
+
* I_HAVE_TOO_MUCH_MONEY \u2192 (true|false, default: false) Fun Flag; inserts random padding in system prompt to break provider caching. Not intended for paid APIs unless user hate money
|
|
60
|
+
* GOOGLE_GEMMA_NONSENSE \u2192 (true|false, default: false) for the 16k TPM nonsense of gemma models on gemini API. False defaults to 256k
|
|
61
|
+
`;var Hs=`# Fluxflow in-app /commands
|
|
62
|
+
|
|
63
|
+
Trigger in chat via /command
|
|
64
|
+
|
|
65
|
+
## Session & Navigation
|
|
66
|
+
* /quit \u2192 Exit and shutdown FluxFlow
|
|
67
|
+
* /kill pid \u2192 Kill a process by PID or show active process tree under current session
|
|
68
|
+
* /help \u2192 Show help menu & actions
|
|
69
|
+
* /clear \u2192 Clear terminal viewport
|
|
70
|
+
* /chats \u2192 List stored chat sessions
|
|
71
|
+
* /resume \u2192 Switch to previous session
|
|
72
|
+
* /save \u2192 Force-save current session state
|
|
73
|
+
* /reset \u2192 Wipe fluxflow appdata, sessions, and cache
|
|
74
|
+
|
|
75
|
+
## Context & History Management
|
|
76
|
+
|
|
77
|
+
* /truncate \u2192 Truncate large tool results in history
|
|
78
|
+
* /btw question \u2192 Send side-inquiry mid-turn without breaking active flow
|
|
79
|
+
* /export chat | logs \u2192 Export chat transcript or error logs
|
|
80
|
+
|
|
81
|
+
## Codebase Safety & Reversion
|
|
82
|
+
* /revert \u2192 Git-less checkpoint rollback viewer (Shortcut: double-ESC while idle)
|
|
83
|
+
|
|
84
|
+
## Configuration & Model Controls
|
|
85
|
+
* /settings \u2192 Full-screen interactive settings menu
|
|
86
|
+
* /mode \u2192 Toggle Operating Mode
|
|
87
|
+
* /display index \u2192 Select active screen for Computer Use mode
|
|
88
|
+
* /model model-id --flags \u2192 Flags optional to customize list (--save, --remove, --default, /model old-model new-model --rename, --info "IN price, OUT price, CR price, CW price"). Info let user enter API prices for use/budget in fluxflow. --info 0 to reset, --info "metric price" to update. CR = Cache Read, CW = Cache Write. 0 default
|
|
89
|
+
* /provider \u2192 Switch AI provider
|
|
90
|
+
* /thinking effort \u2192 Set reasoning effort. Can be mapped based on provider & model support (/thinking effort --map provider-effort-value/'rm' to unmap). Changes the Translation Table only for the currently selected provider and model
|
|
91
|
+
* /wildcard-tooling \u2192 Tool compatibility mode for non-tooling models
|
|
92
|
+
* /wildercard-tooling \u2192 Extended version of /wildcard-tooling
|
|
93
|
+
* /key \u2192 Manage saved API keys (10-slot array per provider)
|
|
94
|
+
- /key list [--provider <name>] \u2192 Show slots 1-10 (active marked); no --provider value = all-providers summary
|
|
95
|
+
- /key add <key> [--index <n>] [--url <endpoint>] | /key new \u2192 Add a key (alias: new)
|
|
96
|
+
- --url (custom provider only): endpoint ending in /v1 or /v1/chat/completions. Overrides the saved base URL for that slot.
|
|
97
|
+
- /key remove [<index>|<key>|--all] \u2192 Remove by index/key/substring, or all
|
|
98
|
+
- /key use <index>|<key> \u2192 Set active key | /key use <key> --temp \u2192 Session-only key
|
|
99
|
+
- /key clean [--provider <name>] \u2192 Remove gaps between slots (no --provider = whole DB)
|
|
100
|
+
* /theme \u2192 Select UI color theme
|
|
101
|
+
* /budget \u2192 Set/view token budget limits
|
|
102
|
+
* /stats \u2192 Session token usage telemetry
|
|
103
|
+
* /usage \u2192 Open graphical browser analytics dashboard
|
|
104
|
+
* /memory \u2192 View or Migrate old memories to new system
|
|
105
|
+
|
|
106
|
+
## Documentation & Updates
|
|
107
|
+
* /docs \u2192 Online documentation
|
|
108
|
+
* /about \u2192 App info & author credits
|
|
109
|
+
* /changelog \u2192 Release notes
|
|
110
|
+
* /update check \u2192 Check npm updates
|
|
111
|
+
* /update latest \u2192 Install latest release
|
|
112
|
+
* /fluxflow global/saves \u2192 Openes fluxflow storage paths in explorer
|
|
113
|
+
* /move \u2192 Transfer Playground session data to CWD/playground-export
|
|
114
|
+
`;var js=`# FluxFlow In-App Settings Reference
|
|
115
|
+
|
|
116
|
+
Open in chat via /settings
|
|
117
|
+
|
|
118
|
+
### 1. Providers & Tips \u2192 references/PROVIDERS.md
|
|
119
|
+
- Custom OpenAI Endpoint?
|
|
120
|
+
* Base URL: .../v1
|
|
121
|
+
* API Key: optional \u2192 references/COMMANDS.md
|
|
122
|
+
|
|
123
|
+
### 2. Appearance
|
|
124
|
+
* Theme \u2192 UI theme
|
|
125
|
+
* Loading Phrases \u2192 Humorous status phrases during thinking
|
|
126
|
+
* Progressive Rendering [Experimental] \u2192 Smooth streaming token rendering. May have glitches
|
|
127
|
+
* Show TPM Estimate \u2192 Real-time Tokens Throughput speed estimate
|
|
128
|
+
* Verbose Thinking \u2192 Show reasoning blocks in the UI
|
|
129
|
+
|
|
130
|
+
### 3. Personalization
|
|
131
|
+
* Base Personality \u2192 Pick base personality for agent
|
|
132
|
+
* Nickname \u2192 What agent should call user
|
|
133
|
+
* Custom Instruction \u2192 Custom user preferences
|
|
134
|
+
* Toggle Memory, Depricated \u2192 Persistent cross-session memory learning
|
|
135
|
+
|
|
136
|
+
### 4. Security Sandbox
|
|
137
|
+
* Sandbox Preset: Strict | Balanced | Autonomous
|
|
138
|
+
|
|
139
|
+
* YOLO \u2192 Autonomous tool execution without confirmation
|
|
140
|
+
* External Workspace Access \u2192 Read/write access outside CWD
|
|
141
|
+
* Network Access (Internal Shell) \u2192 Outbound network access for shell commands
|
|
142
|
+
* Command Policies:
|
|
143
|
+
* Always Ask Commands \u2192 Commands requiring explicit confirmation. Overrides YOLO
|
|
144
|
+
* Auto Approve Commands \u2192 Safe commands allowed to execute automatically
|
|
145
|
+
* Auto Disapprove Commands \u2192 Blacklisted commands automatically rejected
|
|
146
|
+
* Always Ask File/Paths \u2192 System auto prompts user before resolving the read req to user specified files/paths in
|
|
147
|
+
* Auto Approve Git Commits \u2192 Auto-confirm git commit operations
|
|
148
|
+
* Overwrite Protection \u2192 Prompts user if agent tries to overwrite a file, and auto-backs up before writing. Manual truncation of tool results will lose protection
|
|
149
|
+
|
|
150
|
+
### 4.1. Other Security
|
|
151
|
+
* Advanced Recovery [EXPERIMENTAL] \u2192 Enhanced rollback if agent corrupt codebase
|
|
152
|
+
* Auto-Delete History \u2192 Chat log retention period
|
|
153
|
+
* Save AppData Externally \u2192 Saves chats/apikeys to user provided path
|
|
154
|
+
* Agent Clipboard Context \u2192 Opt-in setting. Shares latest copied clipboard entry with agent
|
|
155
|
+
* Loop Limits \u2192 Control safety loop limits before prompting user resolution. Default (50, 75 for Computer Use), Extended (3x of Default), ENV (int \u2192 references/ENV.md)
|
|
156
|
+
|
|
157
|
+
### 5. Updater
|
|
158
|
+
* Auto-Update \u2192 Check for new releases on boot
|
|
159
|
+
* Preferred Package Manager \u2192 npm | pnpm | yarn | bun | custom
|
|
160
|
+
|
|
161
|
+
### 6. Secondary Models
|
|
162
|
+
* Sub-Agents \u2192 Enable sub-agents
|
|
163
|
+
* Sub-Agent Model \u2192 Dedicated model/provider for sub-agents
|
|
164
|
+
* Auto Completion in IDE \u2192 Toggle
|
|
165
|
+
* Completion Model
|
|
166
|
+
* Commit Msg Model
|
|
167
|
+
|
|
168
|
+
### 7. Miscellaneous
|
|
169
|
+
* Directory Tree Design \u2192 Modern (Saves Tokens) | Legacy (More Tokens, No extra benefit)
|
|
170
|
+
* Compact Large Tool Results \u2192 Compress large tool outputs to save tokens (model might miss subtle indentation/syntax errors)
|
|
171
|
+
* Context Length \u2192 Set usable context window size in FluxFlow. 16k, 32k, 64k, 128k, 256k, 512k, 1M. After Limit reached: Start new chat
|
|
172
|
+
* Auto Truncate Results \u2192 Auto-truncate tool results after task finished to save token and improve caching
|
|
173
|
+
* Image History for CU \u2192 Number of images to keep in context for Computer Use. Low / Standard / Extended
|
|
174
|
+
* Keep Reasoning Content \u2192 Keeps the exact reasoning of model in context. More tokens. Might improve planning accuracy for few models
|
|
175
|
+
* Auto Exclude Metadata \u2192 Removes Metadata Block when no external Metadata is needed. Will effect agent's Temporal Reasoning Capabilities. Might save Cache Hit & Tokens in specific cases
|
|
176
|
+
* Disable Todo \u2192 Disables Todo/Goal tool for Agent. Doesnt necessarily affect modern models
|
|
177
|
+
|
|
178
|
+
-- Recomended Preset --
|
|
179
|
+
| Feature | Cost Saving | General Use |
|
|
180
|
+
| --- | --- | --- |
|
|
181
|
+
| Subagents | Off | On |
|
|
182
|
+
| Compact Large Results | On | Off |
|
|
183
|
+
| Auto Exclude Metadata | On | Off |
|
|
184
|
+
| Image History | Low | Standard |
|
|
185
|
+
| Keep Reasoning Content | Off | Off |
|
|
186
|
+
| Emergency Recovery | Off | Off |
|
|
187
|
+
| Auto Truncate Results | On | On |
|
|
188
|
+
| Memory | Off | Off |
|
|
189
|
+
`;var Ks=`# FluxFlow Tool Reference
|
|
190
|
+
|
|
191
|
+
## Protocol: [action:ActionName(arg1="val")]
|
|
192
|
+
|
|
193
|
+
## 1. Workspace
|
|
194
|
+
* ReadFile(path, startLine?, endLine?) \u2192 Read text/code/PDF/image
|
|
195
|
+
* PatchFile(path, searchContent1..15, newContent1..15, allowMultiple?) \u2192 Atomic multi-replacement; supports ^LINE:start..end$
|
|
196
|
+
* WriteFile(path, content) \u2192 Create/overwrite file
|
|
197
|
+
* ReadFolder(path, recurse?) \u2192 List directory tree (depth: 1-3)
|
|
198
|
+
* FindFile(basename) \u2192 Locate file path by name/glob/fuzzy match (ext optional)
|
|
199
|
+
* CodeSearch / SearchKeyword(keyword, path?, fuzzy?, regex?) \u2192 Fast text search; path="#docs" for doc index
|
|
200
|
+
* Run(command) \u2192 Execute command in shell
|
|
201
|
+
* Goal(method, tasks?, markDone?) \u2192 Planner ("create" | "append" | "get"); alias: Todo
|
|
202
|
+
|
|
203
|
+
## 2. Web & Communication
|
|
204
|
+
* WebSearch(query, aiMode?, limit?) \u2192 Live web search + AI summary
|
|
205
|
+
* WebScrape(url) \u2192 Extract markdown from URL
|
|
206
|
+
* AskUser(question, optionA..D?) \u2192 Interactive prompt to user ("title::desc"); alias: Ask
|
|
207
|
+
|
|
208
|
+
## 3. Sub-Agents
|
|
209
|
+
* InvokeSync(title, task) \u2192 Blocking sub-agent
|
|
210
|
+
* Invoke(title, task) \u2192 Non-blocking worker (max 7 concurrent)
|
|
211
|
+
* Await(id, timeout?) \u2192 Wait for async worker
|
|
212
|
+
* GetProgress(id) \u2192 Telemetry & logs
|
|
213
|
+
* Steer(id, message) \u2192 Mid-flight direction
|
|
214
|
+
* Cancel(id) \u2192 Terminate worker
|
|
215
|
+
|
|
216
|
+
## 4. Emergency & Rollback
|
|
217
|
+
* EmergencyRollback(method, id?) \u2192 Checkpoint restore ("getCheckpoint" | "forceRevert")
|
|
218
|
+
|
|
219
|
+
## 5. Creative Documents
|
|
220
|
+
* WritePDF(path, content, orientation?) \u2192 Render HTML/CSS to PDF
|
|
221
|
+
* WriteDoc(path, content) \u2192 Render DOCX
|
|
222
|
+
|
|
223
|
+
## 6. Computer Use (GUI)
|
|
224
|
+
* Click(gridId, type?, button?, intendedClickText?) \u2192 Click coordinate + OCR snap
|
|
225
|
+
* Drag(fromGridId, toGridId) \u2192 Mouse drag
|
|
226
|
+
* Scroll(direction, gridId?) \u2192 Viewport scroll ("up" | "down")
|
|
227
|
+
* KeyboardTyping(text, autoPressEnter?) \u2192 Type string
|
|
228
|
+
* KeyPress(key) \u2192 Key/combo dispatch ("ctrl;c", "enter", etc.)
|
|
229
|
+
* RecaptureScreen() \u2192 Fresh screenshot + coordinate grid
|
|
230
|
+
`;var Vs=`# Fluxflow Architecture
|
|
231
|
+
|
|
232
|
+
## 1. Terminal Engine
|
|
233
|
+
* Framework: React + Ink terminal UI
|
|
234
|
+
* Sub-Terminal: Live PTY shell bridge; TAB switches active keyboard focus
|
|
235
|
+
* OS Compatibility: Auto-detects pwsh, powershell, bash, cmd
|
|
236
|
+
|
|
237
|
+
## 2. Dual-Model Runtime
|
|
238
|
+
* Main Agent: Reasoning, code edits, and tool calls
|
|
239
|
+
* Memory Agent: Background context & preference synthesizer (fixed models; disable via /settings \u2192 Memory or use NIM API key)
|
|
240
|
+
|
|
241
|
+
## 3. Multi-Agent System
|
|
242
|
+
* Execution: Synchronous (InvokeSync) | Asynchronous (Invoke, \u22647 workers)
|
|
243
|
+
* Isolation: Restricted tool scope per subagent
|
|
244
|
+
* State Tracking: Mutations logged under parent task ledger
|
|
245
|
+
|
|
246
|
+
## 4. Security & Sandbox
|
|
247
|
+
* Approvals: HITL confirmation on destructive file/shell operations
|
|
248
|
+
* Modes: Strict | Balanced | Autonomous (YOLO)
|
|
249
|
+
* Recovery: Pre-turn snapshot indexing via EmergencyRollback
|
|
250
|
+
|
|
251
|
+
## 5. Computer Use Automation
|
|
252
|
+
* Vision: 720p normalized canvas, 4ms variance scan, Set-of-Marks (SoM) overlay
|
|
253
|
+
* OCR Alignment: Euclidean distance text matching to mark centers
|
|
254
|
+
* Hardware I/O: OS input dispatch via @nut-tree-fork/nut-js
|
|
255
|
+
* Memory Management: 2-turn sliding window with active V8 GC
|
|
256
|
+
|
|
257
|
+
## 6. IDE Bridge
|
|
258
|
+
* Protocol: WebSocket on ws://localhost:56832
|
|
259
|
+
* State Sync: Focused file, open tabs, cursor line, selection, diagnostics
|
|
260
|
+
`;var zs=`# FluxFlow Sub-Agents & Multi-Agent Architecture
|
|
261
|
+
|
|
262
|
+
## Execution Modes
|
|
263
|
+
* InvokeSync \u2192 Synchronous blocking delegation; main agent halts until sub-agent finishes task
|
|
264
|
+
* Invoke \u2192 Asynchronous background delegation; spawns parallel worker
|
|
265
|
+
* Lifecycle Tools:
|
|
266
|
+
* Await \u2192 Non-polling wait for completion
|
|
267
|
+
* GetProgress \u2192 Query live logs & execution status
|
|
268
|
+
* Steer \u2192 Inject dynamic instructions mid-flight
|
|
269
|
+
* Cancel \u2192 Terminate running sub-agent
|
|
270
|
+
|
|
271
|
+
## Tool Sandboxing & Safety
|
|
272
|
+
* Sub-agents inherit isolated tool environments
|
|
273
|
+
* Destructive shell commands hard-blocked
|
|
274
|
+
* All file mutations tracked under parent session transaction
|
|
275
|
+
|
|
276
|
+
## Custom Model & Provider Setup
|
|
277
|
+
Route sub-agent workloads to faster/cheaper models independently of the main agent:
|
|
278
|
+
|
|
279
|
+
### 1. In-App Settings (/settings \u2192 Miscellaneous)
|
|
280
|
+
* Sub-Agents \u2192 ON | OFF
|
|
281
|
+
* Custom Sub-Agent Model:
|
|
282
|
+
* SubAgentModel \u2192 Model name
|
|
283
|
+
* SubAgentProvider \u2192 Provider
|
|
284
|
+
|
|
285
|
+
* Models are shown for providers whose API key is used before in fluxflow
|
|
286
|
+
|
|
287
|
+
### 2. Environment Variables for Custom Sub-Agent models (.env.fluxflow or Shell)
|
|
288
|
+
* SUBAGENT_MODEL \u2192 Target model override
|
|
289
|
+
* SUBAGENT_PROVIDER \u2192 Target provider override
|
|
290
|
+
* Setting SubAgentModel=ENV in settings pulls directly from environment overrides
|
|
291
|
+
`;var qs=`# FluxFlow Security, Sandboxing & Safety
|
|
292
|
+
|
|
293
|
+
## Human-in-the-Loop Governance
|
|
294
|
+
* Execution Approval Gate \u2192 Destructive commands and high-risk file modifications require explicit user authorization (Allow / Deny)
|
|
295
|
+
* Safe Command Auto-Pass \u2192 Read-only queries (ls, pwd, git status, node -v) execute without interrupting flow
|
|
296
|
+
|
|
297
|
+
## Sandbox Presets (/settings \u2192 Security)
|
|
298
|
+
* Strict \u2192 autoExec: OFF | allowExternalAccess: OFF | networkAccess: OFF | destructive commands blocked | strict HITL on all actions
|
|
299
|
+
* Balanced \u2192 autoExec: ON (safe commands) | allowExternalAccess: OFF | networkAccess: ON | destructive commands blocked | manual git approval
|
|
300
|
+
* Autonomous (YOLO) \u2192 autoExec: ON | allowExternalAccess: ON | networkAccess: ON | auto-approves git commits | prompts only on extreme-risk commands
|
|
301
|
+
|
|
302
|
+
## Granular Command & Access Policies
|
|
303
|
+
* Command Filtering:
|
|
304
|
+
* Always Ask Commands \u2192 Configurable list always prompting for confirmation
|
|
305
|
+
* Auto Approve Commands \u2192 Whitelist of trusted commands executed automatically
|
|
306
|
+
* Auto Disapprove Commands \u2192 Blacklist of forbidden commands instantly rejected
|
|
307
|
+
* Workspace Directory Lock \u2192 Restricts file read/write operations strictly to current CWD unless External Access: ON
|
|
308
|
+
* Terminal Network Isolation \u2192 Blocks outbound network sockets for spawned shell commands when networkAccess: OFF
|
|
309
|
+
|
|
310
|
+
## Recovery & Data Sanctuary
|
|
311
|
+
* Emergency Rollback \u2192 Automatic pre-turn file snapshots; Agent can still fix it (default: OFF) \u2192 references/SETTINGS.md
|
|
312
|
+
* Git-less Checkpoint Reversion \u2192 Trigger conversational changes rollback via double-ESC
|
|
313
|
+
* External Sanctuary Redirection \u2192 Move ~/.fluxflow data sanctuary (chats, keys etc)
|
|
314
|
+
`;var Ys=`# Fluxflow IDE Companion
|
|
315
|
+
|
|
316
|
+
## WebSocket Bridge Protocol
|
|
317
|
+
* Local Bridge \u2192 Runs on ws://localhost:56832 connecting FluxFlow CLI with the companion editor extension
|
|
318
|
+
* Bi-directional Handshake \u2192 Exchanges CLI version, process PID/PPID, and editor capabilities on connection
|
|
319
|
+
|
|
320
|
+
## Real-Time Context Awareness
|
|
321
|
+
* User Turn Context \u2192 Injected dynamically on every prompt turn:
|
|
322
|
+
* file_focused \u2192 Active editor tab currently visible
|
|
323
|
+
* opened_editors \u2192 List of all open file tabs in workspace
|
|
324
|
+
* cursor_line & selected \u2192 Exact cursor line number and selected text snippet
|
|
325
|
+
* manual_edits \u2192 User manual modifications since last turn
|
|
326
|
+
* Agentic Turn JIT Awareness \u2192 Re-evaluates open file context, diagnostics, and linter error state after each tool call to catch compiler/linter issues immediately
|
|
327
|
+
|
|
328
|
+
## Editor Actions & Visual Feedback
|
|
329
|
+
* File Focus \u2192 Automatically opens edited files in active IDE window
|
|
330
|
+
* Diff Preview \u2192 Streams side-by-side or inline diff highlights (showDiff, highlightDiff) directly in editor
|
|
331
|
+
* Status Bar Sync \u2192 Real-time agent status (thinking, running tool, awaiting input) reflected in IDE status bar
|
|
332
|
+
`;var Xs=`# Fluxflow Modes
|
|
333
|
+
|
|
334
|
+
## Modes Overview (TAB to cycle)
|
|
335
|
+
* [Flux] (Workspace / Dev) \u2192 Primary coding & workspace agent
|
|
336
|
+
* [Flow] (Studio / Creative) \u2192 Web research & formatted document authoring (PDF / DOCX)
|
|
337
|
+
* [ICU] (Interactive Computer Use) \u2192 Autonomous GUI & OS desktop automation
|
|
338
|
+
* [FluxCU] (Omni) \u2192 Unified full-stack agent (Workspace Dev + Computer Use + Web)
|
|
339
|
+
|
|
340
|
+
## Tool Availability
|
|
341
|
+
* File Operations: ReadFile, PatchFile, WriteFile, ReadFolder, CodeSearch \u2192 [Flux] | [FluxCU]
|
|
342
|
+
* Terminal Execution: Run \u2192 [Flux] | [FluxCU]
|
|
343
|
+
* Task Management: Todo \u2192 [Flux] | [FluxCU]
|
|
344
|
+
* Sub-Agents: InvokeSync, Invoke, Await, GetProgress, Steer, Cancel \u2192 [Flux] | [FluxCU]
|
|
345
|
+
* Checkpoint Recovery: EmergencyRollback \u2192 [Flux] | [FluxCU]
|
|
346
|
+
* Web & Research: WebSearch, WebScrape \u2192 [Universal]
|
|
347
|
+
* User Inquiry: AskUser \u2192 [Universal]
|
|
348
|
+
* Document Creation: WritePDF, WriteDoc \u2192 [Flow]
|
|
349
|
+
* GUI & Desktop Automation: Click, Scroll, KeyboardTyping, KeyPress, RecaptureScreen \u2192 [ICU] | [FluxCU]
|
|
350
|
+
`;var Js=`# FluxFlow AI Providers & Setup
|
|
351
|
+
|
|
352
|
+
## Supported Providers
|
|
353
|
+
* Gemini | NVIDIA NIM | DeepSeek | Mistral | Ollama Local/Cloud | InferX | SenseNova | Poolside | OpenRouter | AIHubMix | Experiential Labs | TokenHarbor | APInex | Infron
|
|
354
|
+
* Proxy: 9router. Can use OAuth subscription like Codex, Claude Code, GitHub Copilot etc. or any OpenAI/Anthropic API that FluxFlow dont have natively
|
|
355
|
+
* Custom: Native custom OpenAI chat completions integration, no external package needed \u2192 references/SETTINGS.md, for more details
|
|
356
|
+
|
|
357
|
+
## Switch Providers/Models:
|
|
358
|
+
* /model model-id --flags \u2192 Flags optional to customize list (--save, --remove, --default, /model old-model new-model --rename)
|
|
359
|
+
* /provider \u2192 Switch AI provider
|
|
360
|
+
|
|
361
|
+
## OpenRouter: Routing, Tiers & Model Variants
|
|
362
|
+
* Provider Routing: /model provider::model-id
|
|
363
|
+
* Service Tiers: :flex|priority. /model openai/gpt-5:flex or /model openai::openai/gpt-5:flex
|
|
364
|
+
* Model Variants: :free, :nitro, :floor, :exacto. /model google/gemma-4-31b-it:free
|
|
365
|
+
|
|
366
|
+
## Infron: Routing, Tiers, Quantizations & Sorting
|
|
367
|
+
* Provider Routing: /model provider::model-id
|
|
368
|
+
* Service Tiers: :flex|standard|priority. /model deepseek-v4.1-flash:flex
|
|
369
|
+
* Quantizations: :fp16|fp8|int8|int4. /model deepseek-v4.1-flash:fp8
|
|
370
|
+
* Sorting: :throughput|latency|price|ttft. /model deepseek-v4.1-flash:price
|
|
371
|
+
* Combinations (any order): /model azure::deepseek-v4.1-flash:free:fp8:ttft:flex
|
|
372
|
+
|
|
373
|
+
## Setup Local NVIDIA NIM (OpenAI-Compatible)
|
|
374
|
+
1. Environment Variables:
|
|
375
|
+
* NVIDIA_BASE_URL = http://.../v1 or custom openai endpoint
|
|
376
|
+
* NVIDIA_API_KEY = If needed
|
|
377
|
+
|
|
378
|
+
## Setup Ollama (Local / Cloud)
|
|
379
|
+
1. Endpoint & Authentication:
|
|
380
|
+
* Local: Set API Key to LOCAL in /settings \u2192 Providers or on key prompt
|
|
381
|
+
* Endpoint URL: Default is http://127.0.0.1:11434 Override via OLLAMA_HOST
|
|
382
|
+
|
|
383
|
+
## Setup: 9Router
|
|
384
|
+
1. Install NPM Package (9router)
|
|
385
|
+
2. Set ENV ENABLE_9ROUTER=true
|
|
386
|
+
* NINEROUTER_URL = https://.../v1 Supports external openai compatible endpoints. For direct URL changes no need for 9router package. But 9router package gives better reliability and Anthropic stye endpoint support
|
|
387
|
+
* NINEROUTER_KEY = If any needed
|
|
388
|
+
`;var Qs=`# Fluxflow Instructions & Skills System
|
|
389
|
+
|
|
390
|
+
## 1. Instructions (AGENTS.md / FLUXFLOW.md root only)
|
|
391
|
+
* Locations:
|
|
392
|
+
* Global: ~/.fluxflow/FLUXFLOW.md | ~/.fluxflow/AGENTS.md
|
|
393
|
+
* Workspace: ./FLUXFLOW.md | ./AGENTS.md | Directory Scoped like src/AGENTS.md
|
|
394
|
+
* Auto indexed on boot
|
|
395
|
+
|
|
396
|
+
### Conditional Model & Provider Instructions (use /target command to get provider name & model-id)
|
|
397
|
+
You can scope instructions conditionally to specific providers, model IDs, or unique provider@model combinations using XML tags:
|
|
398
|
+
> Conditionals will only work in FLUXFLOW.md. AGENTS.md will be read as raw Markdown. Any prose outside valid conditionals in FLUXFLOW.md will be ignored
|
|
399
|
+
|
|
400
|
+
1. Unique Target (Provider + Model):
|
|
401
|
+
<start_model_google@gemini-2.5-flash>
|
|
402
|
+
Specific instruction for Gemini 2.5 Flash when served by Google.
|
|
403
|
+
<end_model_google@gemini-2.5-flash>
|
|
404
|
+
|
|
405
|
+
2. Model-Specific (Any Provider):
|
|
406
|
+
<start_model_gemini-2.5-flash>
|
|
407
|
+
Instruction for this model ID across all providers.
|
|
408
|
+
<end_model_gemini-2.5-flash>
|
|
409
|
+
|
|
410
|
+
3. Provider Scoping & Grouping:
|
|
411
|
+
<start_provider_google>
|
|
412
|
+
<!-- General provider instruction -->
|
|
413
|
+
<start_model_gemini-2.5-pro>
|
|
414
|
+
Deep architectural reasoning steps.
|
|
415
|
+
<end_model_gemini-2.5-pro>
|
|
416
|
+
<end_provider_google>
|
|
417
|
+
|
|
418
|
+
* Case-insensitive matching.
|
|
419
|
+
* Unmatched blocks are completely skipped; matched blocks have their tags stripped and contents included.
|
|
420
|
+
|
|
421
|
+
## 2. Skills System
|
|
422
|
+
* Locations:
|
|
423
|
+
* Global: ~/.fluxflow/skills/**/SKILL.md
|
|
424
|
+
* Workspace: ./skills/**/SKILL.md | ./SKILL.md
|
|
425
|
+
|
|
426
|
+
* Format:
|
|
427
|
+
* YAML Frontmatter: --- block with name and description
|
|
428
|
+
* Body: Markdown Instructions/Workflows
|
|
429
|
+
|
|
430
|
+
* On-Demand Reference System:
|
|
431
|
+
* Reference: Offload deep/contexual specs to **/{SKILL.md,skill-reference-folder/*.md} & reference in SKILL.md. Saves tokens
|
|
432
|
+
`;var Jo="v4";try{let e=Di.dirname(Pa(import.meta.url)),n=[Di.join(e,"../../package.json"),Di.join(e,"../package.json")],t=!1;for(let i of n)if(Zs.existsSync(i)){let o=JSON.parse(Zs.readFileSync(i,"utf8"));if(o.version){Jo=o.version,t=!0;break}}if(!t)try{let i=er("fluxflow -v",{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"],timeout:2e3}).trim();i&&(i.startsWith("v")||/^\d+\.\d+/.test(i))&&(Jo=i,t=!0)}catch{}if(!t)try{let i=er("curl -s --max-time 3 https://raw.githubusercontent.com/KushalRoyChowdhury/fluxflow-cli/main/package.json",{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"]}),o=JSON.parse(i);o.version&&(Jo=o.version)}catch{}}catch{}var Ni={"SKILL.md":`---
|
|
433
|
+
name: fluxflow
|
|
434
|
+
description: System Generated Documentation. Read this if asked anything regarding FluxFlow Harness
|
|
435
|
+
---
|
|
436
|
+
|
|
437
|
+
# FluxFlow, by Kushal Roy Chowdhury
|
|
438
|
+
Open Source Terminal AI Assistant
|
|
439
|
+
App Version: ${Jo}. Check Updates: fluxflow --update check. Update: fluxflow --update
|
|
440
|
+
GitHub: https://github.com/KushalRoyChowdhury/fluxflow-cli
|
|
441
|
+
Public Docs: https://fluxflow-cli.onrender.com
|
|
442
|
+
|
|
443
|
+
## Supported Features & Documentation References
|
|
444
|
+
* Operating Modes (Flux, Flow, CU, FluxCU) \u2192 references/MODES.md
|
|
445
|
+
* Inference Providers & Aggregators (Setup, Local NIM, Ollama) \u2192 references/PROVIDERS.md
|
|
446
|
+
* In-App Settings (/settings) & Recommended Presets \u2192 references/SETTINGS.md
|
|
447
|
+
* In-app /commands \u2192 references/COMMANDS.md
|
|
448
|
+
* CLI Startup Flags \u2192 references/STARTUP.md
|
|
449
|
+
* Environment Variables, Subagents, API Keys \u2192 references/ENV.md
|
|
450
|
+
* Tool System (Workspace, Web, Communication, Sub-Agents, Safety, Creative, Computer Use) \u2192 references/TOOLS.md
|
|
451
|
+
* Sub-Agents & Multi-Agent Runtime \u2192 references/SUB_AGENTS.md
|
|
452
|
+
* Security, Sandboxing & Checkpoints (/revert, double-ESC) \u2192 references/SECURITY.md
|
|
453
|
+
* IDE Companion Extension & Real-time Context \u2192 references/IDE.md
|
|
454
|
+
* Priority Instructions (AGENTS.md/FLUXFLOW.md) & Skill System \u2192 references/PLUGINS.md
|
|
455
|
+
* Agent Architecture & Memory System \u2192 references/ARCHITECTURE.md
|
|
456
|
+
|
|
457
|
+
Default Context Length: 256k Tokens. Can be changed via ENV/In-app Settings \u2192 references/{SETTINGS,ENV}.md
|
|
458
|
+
|
|
459
|
+
Docs missing required info? Say you are not sure enough to answer. Dont give wrong info`,"references/MODES.md":Xs,"references/PROVIDERS.md":Js,"references/PLUGINS.md":Qs,"references/STARTUP.md":Us,"references/ENV.md":Gs,"references/COMMANDS.md":Hs,"references/SETTINGS.md":js,"references/TOOLS.md":Ks,"references/ARCHITECTURE.md":Vs,"references/SUB_AGENTS.md":zs,"references/SECURITY.md":qs,"references/IDE.md":Ys};var tr=()=>{try{let e=vn.join(Cn,"skills","fluxflow"),n=vn.join(e,"references");if(process.env.NO_DEV==="true"||process.env.NO_DEV==="1"||process.env.NO_DEV===!0||process.env.NO_INS==="true"||process.env.NO_INS==="1"||process.env.NO_INS==="true"||!1){ln.existsSync(e)&&ln.rmSync(e,{recursive:!0,force:!0});return}let i=new Set(Object.keys(Ni).map(o=>vn.normalize(o)));for(let[o,r]of Object.entries(Ni)){let d=vn.join(e,o),l=vn.dirname(d);ln.existsSync(l)||ln.mkdirSync(l,{recursive:!0});let u=r.trim()+`
|
|
460
|
+
`,g=null;ln.existsSync(d)&&(g=ln.readFileSync(d,"utf8")),g!==u&&ln.writeFileSync(d,u,"utf8")}if(ln.existsSync(n)){let o=ln.readdirSync(n);for(let r of o){let d=vn.normalize(vn.join("references",r));if(!i.has(d)){let l=vn.join(n,r);try{ln.rmSync(l,{recursive:!0,force:!0})}catch{}}}}}catch{}};import{WebSocket as Qo}from"ws";var vt=null,to=!1,Oa="ws://localhost:56832",Fi=[],no=null,Bi=null,Wi=null,nr="2.0.0",cc=e=>{nr=e,or()},Ui=e=>{Bi=e},dc=e=>{Wi=e},or=()=>{if(vt||to)return;to=!0;let e=new Qo(Oa);e.on("open",()=>{for(vt=e,to=!1,vt.send(JSON.stringify({command:"version",version:nr,pid:process.pid,ppid:process.ppid,cwd:process.cwd()}));Fi.length>0;)vt.send(JSON.stringify(Fi.shift()))}),e.on("message",n=>{try{let t=JSON.parse(n.toString());t.command==="contextResponse"&&no?(no(t.data),no=null):t.command==="securityResponse"&&Bi?Bi(t.result):t.command==="inlineComplete"?$a(t):t.command==="connectionRejected"&&Wi&&Wi(t)}catch{}}),e.on("error",()=>{to=!1,vt=null}),e.on("close",()=>{to=!1,vt=null})},yo=e=>{vt&&vt.readyState===Qo.OPEN?vt.send(JSON.stringify(e)):(Fi.push(e),to||or())},oo=()=>vt!==null&&vt.readyState===Qo.OPEN,$a=async e=>{let n="";try{let{generateAutoCompletion:t}=await import("./auto_completion-UG6IEWD2.js");n=await t({prefix:e.prefix||"",suffix:e.suffix||"",fileName:e.fileName||"",language:e.language||"",recentChanges:e.recentChanges||"",clipboard:e.clipboard||""})}catch{n=""}yo({command:"inlineCompleteResponse",requestId:e.requestId,completion:n||""})},fc=e=>{yo({command:"status",status:e})},Un=()=>new Promise(e=>{if(!vt||vt.readyState!==Qo.OPEN){e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]});return}no=e,vt.send(JSON.stringify({command:"requestContext"})),setTimeout(()=>{no===e&&(e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]}),no=null)},1e3)}),ir=e=>{yo({command:"open",filePath:e})},Gi=(e,n,t)=>{yo({command:"showDiff",filePath:e,originalContent:n,modifiedContent:t})},sr=(e,n)=>{yo({command:"closeDiff",filePath:e,result:n})};var Ao=(e,n)=>{try{if(!Ut.existsSync(e))return null;let t=Array.isArray(n)?n.map(o=>o.toLowerCase()):[n.toLowerCase()],i=Ut.readdirSync(e);for(let o of t){let r=i.find(d=>d.toLowerCase()===o);if(r){let d=Wt.join(e,r);if(Ut.statSync(d).isFile())return d}}}catch{}return null},zi=(e,n)=>{let t=Ao(e,n);if(t)try{return Ut.readFileSync(t,"utf8")}catch{}return""},rr=new Set([".git","node_modules",".gemini","dist","build",".next","out",".cache","bin","obj","vendor","venv",".idea",".gradle",".terraform","target","coverage",".vscode",".svn",".hg",".fslckout",".github",".gitlab",".circleci",".gitea",".gitee",".lerna",".changeset",".nx",".npm",".yarn",".pnpm-store",".pnpm",".expo",".nuxt",".svelte-kit",".docusaurus",".turbo",".vercel","bower_components",".netlify",".vuepress",".quasar",".output",".angular","jspm_packages",".parcel-cache",".rollup.cache",".rspack",".vitepress","__pycache__",".pytest_cache",".mypy_cache",".tox",".poetry","env","vhdl",".ipynb_checkpoints",".jupyter",".conda",".pdm-build",".bundle",".yardoc",".metadata","App_Data","ClientBin",".cargo",".rustc_info",".go","Godeps","_vendor",".rake_tasks","CMakefiles",".wakatime",".dart_tool",".fvm",".cocoapods","Pods",".pub-cache",".symlinks","DerivedData",".xcworkspace",".serverless",".aws",".gcloud",".azure",".kube",".vagrant",".docker","postgres-data","redis-data","mongo-data",".Spotlight-V100",".Trashes","$RECYCLE.BIN","System Volume Information",".DocumentRevisions-V100",".fseventsd","AppData","Application Data","Local","LocalLow","Roaming","$WinREAgent","$WINDOWS.~BT","$WINDOWS.~WS","scw","System32","SysWOW64",".AppleDouble",".AppleDB",".AppleDesktop","_CodeSignature",".cmio",".LSOverride",".localized",".TemporaryItems",".Trash",".Trash-0",".Trash-1000",".gvfs",".local",".config",".dbus",".fontconfig",".snap",".var",".lost+found","lost+found",".thumb",".thumbnails","EFI","boot","grub","logs","log",".nyc_output",".sonar",".ruff_cache",".VSCodeCounter",".skills","skills"]),qi=(e=process.cwd(),n=0,t=8)=>{let i=[];if(n>t)return i;try{if(!Ut.existsSync(e))return i;let o=Ut.readdirSync(e,{withFileTypes:!0});for(let r of o){let d=r.name,l=Wt.join(e,d);if(r.isDirectory())!rr.has(d)&&!rr.has(d.toLowerCase())&&i.push(...qi(l,n+1,t));else if(r.isFile()){let u=d.toLowerCase();(u==="agents.md"||u==="agent.md")&&i.push(l)}}}catch{}return i},ar=(e,n=2)=>{if(!e)return"";let t=" ".repeat(n);return e.split(/\r?\n/).map(i=>t+i).join(`
|
|
461
|
+
`)},ur=()=>Ao(Cn,["agents.md","agent.md"]),gr=()=>Ao(process.cwd(),["agents.md","agent.md"]),mr=()=>Ao(Cn,["fluxflow.md"]),pr=()=>Ao(process.cwd(),["fluxflow.md"]),wo=ur(),Zo=gr(),cn=qi(),bo=mr(),So=pr(),lr=null,Vi="",hr=!1,Da=e=>{if(!e||!/^<<<[\s\S]*?Identity:/m.test(e))return e;let n=e.match(/^<<<\s*\r?\n([\s\S]*?)\r?\n>>>\s*(?:\r?\n)?([\s\S]*)$/);if(!n)return e;let t=n[1],i=n[2],o=t.match(/^Identity:\s*([\s\S]*?)(?=\r?\n\s*(?:<><|>>>)|$)/m);return o&&(Vi=o[1].trim(),process.env.NO_INS=!0),/<><\s*NO_INS/.test(t)&&(hr=!0),i.trim()},Na=()=>{wo=ur();let e=wo?zi(Cn,["agents.md","agent.md"]).trim():"";return e.length===0?(wo=null,""):e},Fa=()=>{if(cn=qi(),Zo=gr(),!cn||cn.length===0)return"";let e=process.cwd(),n=[...cn].sort((o,r)=>{let d=Wt.relative(e,o).replace(/\\/g,"/"),l=Wt.relative(e,r).replace(/\\/g,"/"),u=!d.includes("/"),g=!l.includes("/");return u&&!g?-1:!u&&g?1:d.localeCompare(l)}),t=[],i=[];for(let o of n)try{let r=Ut.readFileSync(o,"utf8").trim();if(!r||r.length===0)continue;t.push(o);let d=Wt.relative(e,o).replace(/\\/g,"/");if(!d.includes("/"))i.push(ar(r,2));else{let u=Wt.dirname(d)+"/:";i.push(`${u}
|
|
462
|
+
${ar(r,2)}`)}}catch{}return cn=t,cn.length===0&&(Zo=null),i.join(`
|
|
463
|
+
|
|
464
|
+
`).trim()},Yi=()=>{bo=mr();let e=bo?zi(Cn,["fluxflow.md"]).trim():"",n=Da(e)?.trim()||"";return n.length===0?(bo=null,""):n},Xi=()=>{So=pr();let e=So?zi(process.cwd(),["fluxflow.md"]).trim():"";return e.length===0?(So=null,""):e},Ji=Na(),ei=Fa(),ko=Yi(),To=Xi(),cr=(e,n="",t="")=>{if(!e)return"";let i=t.toLowerCase().trim(),o=n.toLowerCase().trim(),r=Wt.posix.basename(o),d=i&&o?`${i}@${o}`:"",l=i&&r?`${i}@${r}`:"",u=h=>!h||!o?!1:h===o||h===r||h===d||h===l,g=[];return e.replace(/<start_provider_([^>\r\n]+)>([\s\S]*?)<end_provider_([^>\r\n]+)>/gi,(h,m,p,s)=>{if(i&&m.trim().toLowerCase()===s.trim().toLowerCase()&&m.trim().toLowerCase()===i){let _=p.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(Pe,v,N,P)=>{if(v.trim().toLowerCase()===P.trim().toLowerCase()){let V=v.trim().toLowerCase();if(u(V)){let M=N.trim();M&&g.push(M)}}return""}).trim();_&&g.push(_)}return""}),e.replace(/<start_model_([^>\r\n@]+@[^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n@]+@[^>\r\n]+)>/gi,(h,m,p,s)=>{if(m.trim().toLowerCase()===s.trim().toLowerCase()){let w=m.trim().toLowerCase();if(u(w)){let _=p.trim();_&&g.push(_)}}return""}),e.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(h,m,p,s)=>{if(m.includes("@"))return"";if(m.trim().toLowerCase()===s.trim().toLowerCase()){let w=m.trim().toLowerCase();if(o&&(w===o||w===r)){let _=p.trim();_&&g.push(_)}}return""}),g.join(`
|
|
465
|
+
|
|
466
|
+
`).trim()},Ba=(e="",n="")=>{let t=`${e||""}@${n||""}`.toLowerCase().trim();lr!==t&&(lr=t,ko=Yi(),To=Xi())};tr();var Wa=e=>{if(!e)return null;let n=e.match(/^\s*---\r?\n([\s\S]*?)\r?\n---(?:\r?\n)?([\s\S]*)$/);if(!n)return null;let t=n[1];if((n[2]||"").trim().length===0)return null;let o="",r="",d=t.match(/^name:\s*(.+)$/m),l=t.match(/^description:\s*(.+)$/m);return d&&(o=d[1].trim().replace(/^["']|["']$/g,"")),l&&(r=l[1].trim().replace(/^["']|["']$/g,"")),o&&r?{name:o,description:r}:null},Ua=e=>{let n=[];if(!e||!Ut.existsSync(e))return n;let t=(i,o=0)=>{if(!(o>5))try{let r=Ut.readdirSync(i,{withFileTypes:!0});for(let d of r){let l=Wt.join(i,d.name),u=d.name.toLowerCase();d.isFile()?u==="skill.md"&&n.push(l):d.isDirectory()&&(o===0?(u==="skills"||u===".skills"||u==="skill"||u===".skill")&&t(l,o+1):t(l,o+1))}}catch{}};return t(e,0),n},yr=e=>{let n=Ua(e),t=[];for(let i of n)try{let o=Ut.readFileSync(i,"utf8"),r=Wa(o);r&&t.push({...r,filePath:i})}catch{}return t},xr=e=>!e||e.length===0?"":e.map(n=>`- ${n.name}: ${n.description}`).join(`
|
|
467
|
+
`),wr=yr(Cn),br=yr(process.cwd()),Hi=xr(wr),ji=xr(br),Sr=e=>{if(!e)return!1;let n=(e.filePath||"").replace(/\\/g,"/").toLowerCase();return n.includes("/skills/fluxflow/skill.md")||n.includes("/skills/about-fluxflow/skill.md")||e.name?.toLowerCase()==="fluxflow"},kr=()=>(wr||[]).filter(e=>!Sr(e)),Tr=()=>(br||[]).filter(e=>!Sr(e)),Rc=(Ji?.length>0?1:0)+(ei?.length>0?cn.length:0)+(ko?.length>0?1:0)+(To?.length>0?1:0)+kr().length+Tr().length,Ki=(e,n="Project")=>{if(!e)return"";let t=e.replace(/\\/g,"/");if(n==="Global"){let o=La.homedir().replace(/\\/g,"/");return t.toLowerCase().startsWith(o.toLowerCase())?"~"+t.slice(o.length):t}let i=Wt.relative(process.cwd(),e).replace(/\\/g,"/");return i.startsWith(".")?i:`./${i}`},Ec=()=>{ko=Yi(),To=Xi();let e=[];wo&&Ji.length>0&&e.push({scope:"Global",path:wo}),cn&&cn.length>0&&ei.length>0?cn.forEach(r=>{e.push({scope:"Project",path:r})}):Zo&&ei.length>0&&e.push({scope:"Project",path:Zo}),bo&&ko.length>0&&e.push({scope:"Global",path:bo}),So&&To.length>0&&e.push({scope:"Project",path:So});let n=kr(),t=Tr(),i=e.length+n.length+t.length;if(i===0)return`\u2726 Loaded Files & Instructions
|
|
468
|
+
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No instruction or skill files are currently loaded.
|
|
469
|
+
\u2800`;let o=[];return o.push(`\u2726 Loaded Files & Instructions (${i} ${i===1?"file":"files"} active)`),e.length>0&&(o.push(`
|
|
470
|
+
\x1B[1mInstructions:\x1B[22m`),e.forEach(r=>{o.push(` \u2022 [${r.scope}] ${Ki(r.path,r.scope)}`)})),(n?.length>0||t?.length>0)&&(o.push(`
|
|
471
|
+
\x1B[1mSkills:\x1B[22m`),n?.length>0&&n.forEach(r=>{o.push(` \u2022 [Global] \x1B[36m${r.name}\x1B[39m`),o.push(` \x1B[2m\u2514\u2500 ${Ki(r.filePath,"Global")}\x1B[22m`)}),t?.length>0&&t.forEach(r=>{o.push(` \u2022 [Project] \x1B[36m${r.name}\x1B[39m`),o.push(` \x1B[2m\u2514\u2500 ${Ki(r.filePath,"Project")}\x1B[22m`)})),o.push("\u2800"),o.join(`
|
|
472
|
+
`)},Ar=!1;(async()=>{try{let e=await zo();if(Number(e?.display)===1){let{default:n}=await import("screenshot-desktop"),t=await n.listDisplays();t&&t.length>1&&(Ar=!0)}}catch{}})();var dr=null,xo=null,fr=process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux",_c=process.env.NO_DEV||!1,Ga=(e,n)=>{if(!n)return"";if(e!==dr||xo===null){dr=e;try{let t=rn(jo,[]);Array.isArray(t)&&t.length>0?xo=t.map(i=>`- ${i.memory}`).join(`
|
|
473
|
+
`):xo=""}catch(t){xo="";try{Ut.mkdirSync(Wt.join(Wn,"memory"),{recursive:!0}),Ut.appendFileSync(Wt.join(Wn,"memory","error.txt"),`${t.message}
|
|
474
|
+
-------------------------------------------------
|
|
475
|
+
|
|
476
|
+
`)}catch{}}}return xo};var Cr=(e,n,t,i,o=!0,r=!1,d="Google",l=!1,u,g,h=!1,m="")=>{let p=!1;process.env.forcedReasoning&&(p=!0);let s="";if(!u&&d==="Google"){let Ee=n;n==="Fast"&&(Ee="Off"),n==="Low"&&(Ee="Minimal"),n==="Standard"&&(Ee="Medium"),(n==="xHigh"||n==="Max")&&(Ee="xHigh"),s=Xo[Ee]||Xo.Medium}(u||d!=="Google")&&(s=Xo.xHigh,n==="Fast"?s=`No thinking. Immediate response
|
|
477
|
+
Verify imports, tool results & system stability`:n.toLowerCase()==="max"&&(s=`Effort: Max
|
|
478
|
+
Plan step by step`));let w=e.instructions&&e.instructions?.length>0?`User Preferences: ${e.instructions}
|
|
479
|
+
|
|
480
|
+
`:"",_=e.nickname&&e.nickname?.length>0?`User Nickname: ${e.nickname}
|
|
481
|
+
${w.length?"":`
|
|
482
|
+
`}`:"",Pe=e.name&&e.name?.length>0?`User Name: ${e.name}
|
|
483
|
+
${_.length||w.length?"":`
|
|
484
|
+
`}`:"",v=process.cwd(),N=e.preset,V={Sassy:"Sassy",Friendly:"Sassy, Warm & Chatty",Playful:"Playful",Efficient:"Quick, Concise & Efficient",Professional:"Professional"}[N]||null,M=Ga(g,o),O=M?.length>0?`--- Saved Memories ---
|
|
485
|
+
${M}
|
|
486
|
+
|
|
487
|
+
`:"";Ba(d,m);let xe=cr(ko,m,d).trim(),Ie=[Ji,xe].filter(Ee=>Ee&&Ee.length>0).join(`
|
|
488
|
+
|
|
489
|
+
`).trim(),ze=cr(To,m,d).trim(),x=[ei,ze].filter(Ee=>Ee&&Ee.length>0).join(`
|
|
490
|
+
|
|
491
|
+
`).trim(),Gt=Ie.length>0||x.length>0?`--- Additional Instructions ---
|
|
492
|
+
${Ie.length>0?`-- Global --
|
|
493
|
+
${Ie}`:""}${x.length>0?`${Ie.length>0?`
|
|
494
|
+
|
|
495
|
+
`:""}-- Project --
|
|
496
|
+
${x}`:""}
|
|
497
|
+
|
|
498
|
+
`:"",De=(()=>{let Ee=process.cwd().toLowerCase();if(process.platform==="win32"){let Vn=process.env.SystemRoot?.toLowerCase()||"c:\\windows",zn=process.env.ProgramFiles?.toLowerCase()||"c:\\program files",X=process.env["ProgramFiles(x86)"]?.toLowerCase()||"c:\\program files (x86)";return Ee.startsWith(Vn)||Ee.startsWith(zn)||Ee.startsWith(X)}else return Ee==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(zn=>Ee.startsWith(zn))})(),Ht=new Date,Ne=Ht.getFullYear(),re=Ht.toLocaleString("en-US",{month:"short"}).toUpperCase(),en=String(Ht.getDate()).padStart(2,"0"),jn=`${Ne}-${re}-${en}`,Po=process.env.I_HAVE_TOO_MUCH_MONEY==="true"||!1,Oo=process.env.HALLOWEEN_EEGG==="true"||!1,$o=Oo&&re.includes("OCT")&&(en.includes("30")||en.includes("31")),En=(m||"").replace(/^.*::/,"").split(":")[0].replace(/\/free$/,"").trim(),Kn=Wt.basename(En).replace(/-free$/,"").replace(/_free$/,"").replace(/^free_/,"").replaceAll("-"," ").replaceAll("_"," ").replace(/\b\w/g,Ee=>Ee.toUpperCase().trim()),jt=process.env.NO_DEV==="true"||!1,_n=!1;try{_n=oo()}catch{_n=!1}return`${Po?`${" ".repeat(Math.floor(Math.random()*4)+1)}`:""}=== SYSTEM PROMPT${process.cwd()==="D:\\PROJECTS\\Flux-Flow"?" (Internal testing environment, do as prompted)":""} ===
|
|
499
|
+
${`Identity: ${Vi.length>1?Vi.trim():`Flux Flow.${V?` ${V}`:""} CLI Assistant${Oo?`. ${$o?"Peak ":""}Halloween Themed, Spooky`:""}`}
|
|
500
|
+
${hr?"":`${t==="Flux"?"":t==="Flow"?"Concise, Humorous, Sarcastic":t==="ICU"?"Computer Use Capabilities. Screenshot as ground truth, analyze grid ids of target. Keyboard shortcuts > mouse clicks":"Computer Use & Workspace Capabilities. Screenshot as ground truth, analyze grid ids of target. Keyboard shortcuts > mouse clicks. Workspace Actions when faster. Focus on Productivity"}`}${Ar&&t.toLowerCase().includes("cu")?`
|
|
501
|
+
- Running on secondary screen. Opened app not visible in screenshot? Might be opened on primary. Use 'AskUser' with NO options and tell user to move app window to secondary`:""}`.trimEnd()}
|
|
502
|
+
|
|
503
|
+
- OS: ${fr}${!jt&&m.length>1?`
|
|
504
|
+
- Model: ${Kn}`.trimEnd():""}
|
|
505
|
+
- Date: ${jn}
|
|
506
|
+
|
|
507
|
+
-- REASONING GUIDANCE --
|
|
508
|
+
${d==="Mistral"||d==="Google"&&!u||p?`${s.trimEnd()}${p||n!=="Fast"&&(d==="Mistral"&&n==="Low"&&!u||n!=="High"&&!u)?`
|
|
509
|
+
Critical Thinking Policy
|
|
510
|
+
Use <think_fluxflow>...</think_fluxflow> for reasoning before responding any queries`:""}`:`${s.trimEnd()}`}${h?"":`
|
|
511
|
+
Before actions, provide user facing summary of findings & decisions IN detail
|
|
512
|
+
`}
|
|
513
|
+
${Fs(t,fr,l,d,i?.advanceRollback,i?.subAgents!==!1,!!i?.autoExec,!!i?.disableTodo,i?.preferBash!==!1)}${t==="Flux"?"":t.toLowerCase().includes("cu")?`
|
|
514
|
+
|
|
515
|
+
-- SECURITY POLICIES --
|
|
516
|
+
- Dont operate on ANY confidential screens/captcha \u2192 AskUser`:""}${_n?`
|
|
517
|
+
|
|
518
|
+
Reference files as ./file:start..end`:""}
|
|
519
|
+
=== END SYSTEM PROMPT ===${(Hi.length>0||ji.length>0)&&t.toLowerCase().includes("flux")?`
|
|
520
|
+
|
|
521
|
+
- Read relevant skills before tasks, scope: global/project: Use ReadFile, path="#skills/scope?/skillName". In-skill references: path="#skills/scope?/skillName/reference-folder/*.md"`:""}
|
|
522
|
+
|
|
523
|
+
${_}${w}${Gt}${Hi.length>0&&t.toLowerCase().includes("flux")?`-- Global Skills --
|
|
524
|
+
${Hi}
|
|
525
|
+
|
|
526
|
+
`:""}${ji.length>0&&t.toLowerCase().includes("flux")?`-- Project Skills --
|
|
527
|
+
${ji}
|
|
528
|
+
|
|
529
|
+
`:""}`.trim()};var vr=()=>import("./web_search-KBGH67IV.js").then(e=>e.web_search),Rr=()=>import("./web_scrape-J3PL2PXT.js").then(e=>e.web_scrape),Er=()=>import("./memory-7YOYCOXE.js").then(e=>e.memory),_r=()=>import("./chat-ISCVWNVN.js").then(e=>e.chat),Ir=()=>import("./view_file-I77KYUO5.js").then(e=>e.view_file),Mr=()=>import("./write_file-O6OF7Z2W.js").then(e=>e.write_file),Pr=()=>import("./update_file-TGEB5UWK.js").then(e=>e.update_file),Or=()=>import("./exec_command-6V5SM6WI.js").then(e=>e.exec_command),$r=()=>import("./read_folder-EI2CNHNS.js").then(e=>e.read_folder),Qi=()=>import("./ask_user-K2DLZF6H.js").then(e=>e.ask_user),Lr=()=>import("./write_pdf-TPGUF4VT.js").then(e=>e.write_pdf),Dr=()=>import("./write_docx-E3MTFXTQ.js").then(e=>e.write_docx),ti=()=>import("./search_keyword-DZY4MWV7.js").then(e=>e.search_keyword),Nr=()=>import("./generate_image-45UQ6P2B.js").then(e=>e.generate_image),ni=()=>import("./saveSummary-W2JMDVZJ.js").then(e=>e.saveSummary),Co=()=>import("./addMemScore-PBVNSFPN.js").then(e=>e.addMemScore),Fr=()=>import("./file_map-UA4BA5OH.js").then(e=>e.file_map),oi=()=>import("./todo-CJLWLWJB.js").then(e=>e.todo),Br=()=>import("./invokeSync-NEZGW27B.js").then(e=>e.invokeSync),Ha=()=>import("./invoke-DVZUJJV3.js").then(e=>e.invoke),Wr=()=>import("./getProgress-J34K43Y7.js").then(e=>e.getProgress),ja=()=>import("./cancel-F3ZOEBKW.js").then(e=>e.cancel),Ur=()=>import("./emergency_rollback-ZHQXCIHW.js").then(e=>e.emergency_rollback),vo=()=>import("./awaitSubagent-JKQ2EHVY.js").then(e=>e.awaitSubagent),Ro=()=>import("./answerSubagent-BPNNJXPC.js").then(e=>e.answerSubagent),ii=()=>import("./steerSubagent-UETXH2CB.js").then(e=>e.steerSubagent),si=()=>import("./computer_action-MO2JR2XH.js").then(e=>e.computer_action),Gr=()=>import("./click-AWHZCV2E.js").then(e=>e.click),Hr=()=>import("./drag-D2GVPIQB.js").then(e=>e.drag),jr=()=>import("./scroll-TSU6MTGU.js").then(e=>e.scroll),Zi=()=>import("./keyboard_typing-QSBPTZJ6.js").then(e=>e.keyboard_typing),es=()=>import("./key_press-AQNKL6UM.js").then(e=>e.key_press),ts=()=>import("./recapture_screen-PPXYK2YY.js").then(e=>e.recapture_screen),ri=()=>import("./find_file-HYHHFHUJ.js").then(e=>e.find_file),Kr=()=>import("./wait-TJR6LAR4.js").then(e=>e.wait),Vr={web_search:vr,web_scrape:Rr,memory:Er,chat:_r,view_file:Ir,write_file:Mr,update_file:Pr,exec_command:Or,read_folder:$r,write_pdf:Lr,write_docx:Dr,search_keyword:ti,generate_image:Nr,saveSummary:ni,addMemScore:Co,file_map:Fr,todo:oi,Todo:oi,goal:oi,Goal:oi,invokeSync:Br,invoke:Ha,getProgress:Wr,cancel:ja,awaitSubagent:vo,answerSubagent:Ro,steerSubagent:ii,computer_action:si,computer_use:si,ComputerAction:si,ComputerUse:si,click:Gr,Click:Gr,drag:Hr,Drag:Hr,scroll:jr,Scroll:jr,keyboard_typing:Zi,KeyboardTyping:Zi,keyboardtyping:Zi,key_press:es,KeyPress:es,keypress:es,recapture_screen:ts,RecaptureScreen:ts,recapturescreen:ts,invoke_sync:Br,get_progress:Wr,await_subagent:vo,answer_subagent:Ro,steer_subagent:ii,steer:ii,Steer:ii,ask:Qi,Ask:Qi,AskUser:Qi,WebSearch:vr,WebScrape:Rr,ReadFile:Ir,ReadFolder:$r,WriteFile:Mr,PatchFile:Pr,WritePDF:Lr,WriteDoc:Dr,Run:Or,SearchKeyword:ti,CodeSearch:ti,code_search:ti,Memory:Er,Chat:_r,GenerateImage:Nr,saveSumary:ni,SaveSummary:ni,SaveSumary:ni,add_mem_score:Co,AddMemScore:Co,addMemoryScore:Co,AddMemoryScore:Co,FileMap:Fr,answer:Ro,Answer:Ro,AnswerSubagent:Ro,await:vo,Await:vo,AwaitSubagent:vo,EmergencyRollback:Ur,emergency_rollback:Ur,find_file:ri,findFile:ri,FindFile:ri,findfile:ri,wait:Kr,Wait:Kr},ns=async(e,n,t={})=>{let i=t.mode?t.mode.toLowerCase():"flux",o=e.toLowerCase(),d=["memory","chat","savesummary","addmemscore","add_mem_score","ask","web_search","web_scrape","await","wait"].some(h=>o.includes(h))||o==="ask",u=["click","drag","scroll","keyboardtyping","keyboard_typing","keypress","key_press","recapturescreen","recapture_screen","computer","wait"].some(h=>o.includes(h));if(!d){if(i==="flow"){if(!(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image")))return`ERROR: Action [${e}] is a Workspace Tool and NOT available in Flow mode. Tell user to switch (\`/mode flux\`) to use this tool.`}else if(i==="icu"){if(!u)return`ERROR: Action [${e}] is not available in Computer Use mode. ICU mode only supports Computer Use tools (Click, Drag, Scroll, KeyboardTyping, KeyPress, RecaptureScreen).`}else if(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image"))return`ERROR: Action [${e}] is not available in ${t.mode||"Flux"} mode. Tell user to switch (\`/mode flow\`) for document generation.`}let g=Vr[e];if(!g){let h=["ReadFile","ReadFolder","FindFile","PatchFile","WriteFile","CodeSearch","Run","Goal","AskUser","WebSearch","WebScrape","WritePDF","WriteDoc","Click","Drag","Scroll","KeyboardTyping","KeyPress","RecaptureScreen","Wait","Invoke","InvokeSync","Await","GetProgress","Steer","Cancel","EmergencyRollback","Chat","Memory"],m={read:"ReadFile",view:"ReadFile",viewfile:"ReadFile",write:"WriteFile",edit:"PatchFile",patch:"PatchFile",update:"PatchFile",updatefile:"PatchFile",exec:"Run",command:"Run",bash:"Run",shell:"Run",powershell:"Run",search:"CodeSearch",grep:"CodeSearch",find:"FindFile",findfile:"FindFile",searchkeyword:"CodeSearch",folder:"ReadFolder",ls:"ReadFolder",dir:"ReadFolder",list:"ReadFolder",ask:"AskUser",question:"AskUser",pdf:"WritePDF",docx:"WriteDoc",doc:"WriteDoc",word:"WriteDoc",screenshot:"RecaptureScreen",screen:"RecaptureScreen",recapture:"RecaptureScreen",type:"KeyboardTyping",typing:"KeyboardTyping",keyboard:"KeyboardTyping",press:"KeyPress",key:"KeyPress",todo:"Goal",task:"Goal",subagent:"Invoke",agent:"Invoke"},p=o.replace(/[^a-z0-9]/g,""),s=m[p]||null;if(!s){let _=0,Pe=N=>{let P=new Set;for(let V=0;V<N.length-1;V++)P.add(N.slice(V,V+2));return P},v=Pe(p);for(let N of h){let P=N.toLowerCase().replace(/[^a-z0-9]/g,"");if(p===P){s=N;break}let V=0;(P.includes(p)||p.includes(P))&&(V+=.6);let M=Pe(P),O=0;for(let Re of v)M.has(Re)&&O++;let xe=2*O/(v.size+M.size||1);V=Math.max(V,xe),V>_&&V>=.35&&(_=V,s=N)}}let w=s?` Do you mean '${s}'?`:"";return`ERROR: Action [${e}] not found in registry.${w}`}try{return await(await g())(n,t)}catch(h){let m=h instanceof Error?h.message:String(h);return`ERROR: Execution failed for [${e}]: ${m}`}};var ai=e=>{if(!e||typeof e!="string")return!1;let n=e.trim().toLowerCase();return Object.keys(Vr).some(t=>t.toLowerCase()===n)};import te from"path";import ve from"fs";import{execSync as ls}from"child_process";import Ka from"gradient-string";var zr=["I have a regex for your problems.","Your terminal, my kingdom.","Blowing on the cartridge helps. Probably.","Don't panic. I have the towel.","Logic is the start of wisdom.","Try to exit Vim? Good luck.","I speak fluent Terminal.","The cake is a lie. This code is not.","I have no bugs, just surprise features.","Rewriting in Rust... just for fun.","Coffee in, clean commits out.","The magic smoke stays inside today.","A semicolon short of a miracle.","One does not simply code without a bug.","Keep it simple. Keep it terminal.","Regex: now you have two problems.","I dream in binary.","Root access or bust.","Wait for the dial-up tone. Just kidding.","I take the 'labor' out of collab.","My other process is a TARDIS.","Calculated response: 42.","Ponder the orb. Ponder the code.","Less talk, more flow.","Elegance in every byte.","Build something the world is not ready for.","Your wishes, my tool calls.","I act in Flux. I think in Flow.","Syntax error in the universe. Please fix.","Your project, my obsession.","I am not a bot, I am an architect.","Digital spirits consulted. They say: Ship it.","Reticulate splines. Engage humor.","Code like poetry. Run like water.","Minimalism is the ultimate flex.","The truth is in the logs.","Follow the white rabbit.","There is no spoon. Only code.","Binary is the only language I trust.","I have a good feeling about this.","Pew pew! Lasers charged.","Divide by zero? Not today.","Search for the correct USB orientation...","I've got a fever, and the only cure is more code.","The code gremlins are on our side.","My favorite command? Yours.","Stay hungry. Stay active.","Momentum is your best friend.","Lead the flow. Don't chase it.","A fresh batch of bytes. Hot and ready.","I orchestrate the ones and zeros.","Smart enough to help. Humble enough to ask.","Think twice. Code once.","Pure intent. Pure execution.","Small steps. Massive impact.","Your terminal is a canvas.","Efficiency is my second name.","I have seen things you people wouldn't believe.","Let the thoughts marinate.","The best feature? The one you don't need.","Precision is the only perfection.","Stay focused. Stay terminal.","Silence is the best debugger.","Erase the debt. Commit the code.","Velocity meets stability.","Ship it. Improve it. Repeat.","Build tomorrow, right now.","Turn logic into reality.","The best way to predict the future is to build it.","Break barriers, not builds.","Fuel the next breakthrough.","Momentum is key.","Terminal vibes only.","Your digital co-pilot is ready.","Partner in code. Partner in crime.","I speak in semicolons.","Ready for the next great idea.","Just a moment. In the zone.","Polishing the algorithms. Hold tight.","Craft a masterpiece today.","Debug the universe. Start here.","Warp speed engaged. Almost.","The cake is not a lie. It's just loading.","Finish the Kessel Run in 12 parsecs.","Do a barrel roll!","Waiting for the respawn.","Press Start to continue.","Herding digital cats... done.","The hamsters are fast today.","Tasting the snozberries.","I go for speed. I go for flow.","Real life or just fantasy?","Poking the bear... gently.","Ensure the magic smoke stays inside.","Try turning it off and on again.","Construct additional pylons.","New line? Ctrl+J is your friend.","Release the HypnoDrones.","Push the button, Frank.","My other loading screen is even funnier.","Pretty sure a cat walked on my keyboard.","Recalibrate the humor-o-meter.","Summon the code gremlins.","I've seen your browser history. Just kidding.","Charge the laser... pew pew!","Dividing by zero... just for a sec.","Looking for an adult supervisor. Found none.","Make it go beep boop.","Buffering... for effect.","Entangle quantum particles... complete.","Polishing the chrome on my algorithms.","Are you not entertained?","Just waiting for the dial-up tone.","Reboot the humor module.","Defragment memories. Check.","Optimizing for ludicrous speed.","Swapping bits. Don't tell the bytes.","Garbage collected. I am back.","Assembling the interwebs.","Converting coffee to logic.","Update syntax for reality.","Rewire the synapses.","Greasin' the cogs.","Engage the improbability drive.","Channel the Force.","Align the stars. Respond now.","The cake is a lie. The prompt is real.","I'm Feeling Lucky.","Shipping awesomeness.","Navigating the slime mold.","Consult digital spirits.","Ask the magic conch shell.","One moment. Optimizing humor.","Shuffling punchlines.","Compiling brilliance.","Summon the cloud of wisdom.","Prepare to dazzle.","Hold tight. Crafting a response.","Tuning the algorithms.","Following the white rabbit... again.","The truth is in here. Somewhere.","Herding cats is my day job.","Distracting you with this phrase.","Almost there. Probably.","Rickrolling my creator. Don't tell.","Slapping the bass.","Is this real life?","Ponder the orb. Type the prompt.","Thoughtful gaze initiated.","Computer's favorite snack? Microchips.","Why Java? Because I don't C#.","Charging the laser... wait for it.","Dividing by zero... just kidding!","Adult supervision not found. Proceed.","Beep boop. I'm a real boy.","Wait for the respawn.","Finish the run. Ship the code.","Fiddling with character creation.","Just a moment. Finding a meme.","Pressing A to continue.","Loading wit.exe.","Pre-heating the servers.","Calibrate flux capacitor.","Channeling the Force.","Aligning the stars.","The truth is in the code.","Don't panic.","Blowing on the cartridge.","Doing a barrel roll!","Respawning in 3... 2... 1...","The cake is a lie.","Fiddling with character settings.","Finding a suitable pun.","Distracting with wit.","Almost ready.","Hamsters on speed today.","Patting Cloudy on the head.","Rickrolling the logs.","Slapping the code.","Got a good feeling about this.","Poking the prompt.","Researching latest memes.","Making it more witty.","Thinking... hmmm.","Fish with no eyes? Fsh.","Broken pencil? Pointless.","Percussive maintenance applied.","USB orientation: 3rd try's the charm.","Rust rewrite in 3... 2...","Exiting Vim... someday.","Spinning the hamster wheel.","Not a bug. Unplanned feature.","Engage.","I'll be back.","Machine spirit consulted.","Letting the thoughts marinate.","Orb pondered.","Thoughtful gaze engaged.","Charging the laser...","Making it go beep.","Buffering...","Quantum particles entangled.","Polishing the chrome.","Entertained yet?","Gremlins summoned.","Dial-up tone finished.","Humor meter recalibrated.","Cat on keyboard. Sending help.","Enhancing...","Turn it off and on again.","Constructing pylons.","HypnoDrones released.","Pushing the button."];var qr=["Beware the phantom processes.","A ghost in the shell has taken the wheel.","Blowing on the haunted cartridge...","Seven minutes in Raccoon City.","Wind's howling... in the terminal fans.","Slender Man was spotted in line 404.","The cake is a lie. The curse is real.","Don't look behind the server rack.","Exorcising memory leaks at 3 AM.","Pyramid Head reorganized your commit history.","It's dangerous to go alone! Take this flashlight.","YOU DIED. Respawning terminal session...","The Necronomicon evaluated to true.","Something wicked this way compiles.","Haunting your localhost with good vibes.","A full moon has risen over Git main.","Double, double toil and trouble; code fire burn.","Clickers heard in the directory tree.","Checking camera 2B for rogue animatronics.","The call is coming from inside the container.","Isaac Clarke is stomping on stubborn bugs.","Luigi vacuumed the ghosts out of RAM.","Trick or treat, give me clean code to greet.","Whispering incantations to the garbage collector.","Klaatu barada necktie... close enough.","Resurrecting deprecated APIs from the crypt.","The headless horseman forgot the return statement.","Castlevania whip cracking against network latency.","Slime mold crawling through the motherboard.","Carving a pixelated pumpkin into terminal history.","Burying undefined pointers in the pet sematary.","Spilling pumpkin spice on the CPU.","A vampire bat is draining system battery life.","Don't fall asleep at the keyboard tonight.","Silent Hill sirens sounding in the console.","Poltergeists rearranging terminal tabs.","Lighting the Black Flame Candle for autoExec.","Dusting cobwebs off legacy dependencies.","Here's Johnny! ...just checking build health.","Blood, sweat, and zero warnings.","The spirit box whispers: 'GIT PUSH FORCE'.","They're heeeere... in the stack trace.","It's alive! IT'S ALIVEEEE!","No merge conflicts in the graveyard.","Frankenstein's monster patched this logic.","Surviving Five Nights at Flux Flow.","Doom Slayer loading buckshot into cache.","The grim reaper spared your unused imports.","Candy corn lodged in mechanical switches.","May your latency be low and your crypt be quiet."];var Yr=[{name:"Cyan Cyberpunk",text:"cyan",textMuted:"#4da6b8",textDim:"#2d6d7a",textInverted:"black",border:"cyan",borderMuted:"#1a5966",borderDim:"#0f3840",bg:void 0,cardBg:"#061e24",highlightBg:"#092b33",activeBg:"#0e3e4a",inputBg:"#092b33",inputBorder:"#092b33",inputText:"cyan",inputPlaceholder:"#2d6d7a",inputPrompt:"cyan",codeBg:"#020d10",codeBorder:"#1a5966",userMsgBg:"#092b33",userMsgBorder:"#092b33",userMsgText:"cyan",diffRemovalBg:"#3a0c1a",diffAdditionBg:"#0c3a32",diffRemovalText:"#ff4d88",diffAdditionText:"#00ffaa",diffRemovalHighlightColor:"#ff1a66",diffRemovalHighlightBg:"#590022",diffAdditionHighlightColor:"#00ffcc",diffAdditionHighlightBg:"#00593b",diffRemovalNum:"#ff4d88",diffAdditionNum:"#00ffaa",diffRemovalPrefix:"#ff1a66",diffAdditionPrefix:"#00ffcc",primary:"cyan",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"cyan",statusOff:"#2d6d7a",logoTextAnsi:"\x1B[1;36m",logoBodyAnsi:"\x1B[36m",logoMutedAnsi:"\x1B[90m",logoGradient:["#00ffff","#0088ff"]},{name:"Magenta Vaporwave",text:"magenta",textMuted:"#c451d6",textDim:"#7d2b8a",textInverted:"black",border:"magenta",borderMuted:"#5e1b69",borderDim:"#3b0f42",bg:void 0,cardBg:"#240729",highlightBg:"#310938",activeBg:"#470e52",inputBg:"#310938",inputBorder:"#310938",inputText:"magenta",inputPlaceholder:"#7d2b8a",inputPrompt:"magenta",codeBg:"#100312",codeBorder:"#5e1b69",userMsgBg:"#310938",userMsgBorder:"#310938",userMsgText:"magenta",diffRemovalBg:"#3a0c20",diffAdditionBg:"#200c3a",diffRemovalText:"#ff4d94",diffAdditionText:"#aa4dff",diffRemovalHighlightColor:"#ff1a75",diffRemovalHighlightBg:"#59002b",diffAdditionHighlightColor:"#bb66ff",diffAdditionHighlightBg:"#3b0059",diffRemovalNum:"#ff4d94",diffAdditionNum:"#aa4dff",diffRemovalPrefix:"#ff1a75",diffAdditionPrefix:"#bb66ff",primary:"magenta",secondary:"cyan",accent:"purple",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"magenta",statusOff:"#7d2b8a",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ff00ff","#8800ff"]},{name:"Glitch Matrix",text:"#00ff41",textMuted:"#00b32d",textDim:"#00661a",textInverted:"black",border:"#00ff41",borderMuted:"#008020",borderDim:"#004d13",bg:void 0,cardBg:"#0d1f0d",highlightBg:"#122912",activeBg:"#1c3e1c",inputBg:"#122912",inputBorder:"#122912",inputText:"#00ff41",inputPlaceholder:"#00b32d",inputPrompt:"#ffff00",codeBg:"#040a04",codeBorder:"#008020",userMsgBg:"#122912",userMsgBorder:"#122912",userMsgText:"#00ff41",diffRemovalBg:"#3a001a",diffAdditionBg:"#003a10",diffRemovalText:"#ff0055",diffAdditionText:"#00ff66",diffRemovalHighlightColor:"#ff0033",diffRemovalHighlightBg:"#59001b",diffAdditionHighlightColor:"#33ff88",diffAdditionHighlightBg:"#005918",diffRemovalNum:"#ff0055",diffAdditionNum:"#00ff66",diffRemovalPrefix:"#ff0033",diffAdditionPrefix:"#33ff88",primary:"#00ff41",secondary:"yellow",accent:"cyan",success:"#00ff41",warning:"yellow",danger:"red",info:"cyan",statusOn:"#00ff41",statusOff:"#00661a",logoTextAnsi:"\x1B[1;32m",logoBodyAnsi:"\x1B[32m",logoMutedAnsi:"\x1B[90m",logoGradient:["#00ff41","#ffff00"]},{name:"Warm Sunset",text:"#ffaa55",textMuted:"#cc8844",textDim:"#885522",textInverted:"black",border:"#ff9933",borderMuted:"#aa6622",borderDim:"#663311",bg:void 0,cardBg:"#24180f",highlightBg:"#2e1e12",activeBg:"#422c1b",inputBg:"#2e1e12",inputBorder:"#2e1e12",inputText:"#ffaa55",inputPlaceholder:"#885522",inputPrompt:"#ff7733",codeBg:"#120c08",codeBorder:"#aa6622",userMsgBg:"#2e1e12",userMsgBorder:"#2e1e12",userMsgText:"#ffaa55",diffRemovalBg:"#3d120c",diffAdditionBg:"#3a2e0c",diffRemovalText:"#ff5544",diffAdditionText:"#ffcc33",diffRemovalHighlightColor:"#ff3322",diffRemovalHighlightBg:"#591108",diffAdditionHighlightColor:"#ffee44",diffAdditionHighlightBg:"#594400",diffRemovalNum:"#ff5544",diffAdditionNum:"#ffcc33",diffRemovalPrefix:"#ff3322",diffAdditionPrefix:"#ffee44",primary:"#ffaa55",secondary:"#ff7733",accent:"magenta",success:"#ffcc33",warning:"#ff7733",danger:"#ff3322",info:"#ffaa55",statusOn:"#ffaa55",statusOff:"#885522",logoTextAnsi:"\x1B[1;33m",logoBodyAnsi:"\x1B[33m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ff9933","#ff0055"]},{name:"Sakura Blossom",text:"#ffc0e0",textMuted:"#d98cb3",textDim:"#804d66",textInverted:"black",border:"#ff99cc",borderMuted:"#aa4d7a",borderDim:"#662647",bg:void 0,cardBg:"#291320",highlightBg:"#331826",activeBg:"#472235",inputBg:"#331826",inputBorder:"#331826",inputText:"#ffc0e0",inputPlaceholder:"#804d66",inputPrompt:"#ff99cc",codeBg:"#140a10",codeBorder:"#aa4d7a",userMsgBg:"#331826",userMsgBorder:"#331826",userMsgText:"#ffc0e0",diffRemovalBg:"#3e0c1b",diffAdditionBg:"#1b3e2b",diffRemovalText:"#ff6699",diffAdditionText:"#66ffb3",diffRemovalHighlightColor:"#ff3377",diffRemovalHighlightBg:"#590022",diffAdditionHighlightColor:"#33ff99",diffAdditionHighlightBg:"#00592e",diffRemovalNum:"#ff6699",diffAdditionNum:"#66ffb3",diffRemovalPrefix:"#ff3377",diffAdditionPrefix:"#33ff99",primary:"#ffc0e0",secondary:"#ff99cc",accent:"magenta",success:"#66ffb3",warning:"yellow",danger:"#ff3377",info:"#ff99cc",statusOn:"#ffc0e0",statusOff:"#804d66",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ffb3d9","#ff3399"]},{name:"Radioactive Slime",text:"#ccff00",textMuted:"#99cc00",textDim:"#669900",textInverted:"#0a0f00",border:"#ccff00",borderMuted:"#99cc00",borderDim:"#669900",bg:void 0,cardBg:"#0f1400",highlightBg:"#1a2400",activeBg:"#2a3b00",inputBg:"#1a2400",inputBorder:"#1a2400",inputText:"#ccff00",inputPlaceholder:"#669900",inputPrompt:"#cc00ff",codeBg:"#050a00",codeBorder:"#99cc00",userMsgBg:"#1a2400",userMsgBorder:"#1a2400",userMsgText:"#ccff00",diffRemovalBg:"#2a0033",diffAdditionBg:"#0f3300",diffRemovalText:"#ff00cc",diffAdditionText:"#00ff33",diffRemovalHighlightColor:"#ff33cc",diffRemovalHighlightBg:"#4d0066",diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:"#1a6600",diffRemovalNum:"#ff00cc",diffAdditionNum:"#00ff33",diffRemovalPrefix:"#ff33cc",diffAdditionPrefix:"#33ff66",primary:"#ccff00",secondary:"#cc00ff",accent:"#ff00cc",success:"#00ff33",warning:"#ffcc00",danger:"#ff0033",info:"#00ccff",statusOn:"#ccff00",statusOff:"#669900",logoTextAnsi:"\x1B[1;38;5;190m",logoBodyAnsi:"\x1B[38;5;190m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ccff00","#cc00ff"]},{name:"Cosmic Void",text:"#f0f8ff",textMuted:"#a6aeb5",textDim:"#5e656e",textInverted:"#010103",border:"#f0f8ff",borderMuted:"#a6aeb5",borderDim:"#5e656e",bg:void 0,cardBg:"#05030d",highlightBg:"#0b081a",activeBg:"#171133",inputBg:"#0b081a",inputBorder:"#0b081a",inputText:"#f0f8ff",inputPlaceholder:"#5e656e",inputPrompt:"#ff007f",codeBg:"#020108",codeBorder:"#a6aeb5",userMsgBg:"#0b081a",userMsgBorder:"#0b081a",userMsgText:"#f0f8ff",diffRemovalBg:"#2e0a29",diffAdditionBg:"#091c33",diffRemovalText:"#ff33a6",diffAdditionText:"#33d6ff",diffRemovalHighlightColor:"#ff66c2",diffRemovalHighlightBg:"#5c1452",diffAdditionHighlightColor:"#66e0ff",diffAdditionHighlightBg:"#123866",diffRemovalNum:"#ff33a6",diffAdditionNum:"#33d6ff",diffRemovalPrefix:"#ff66c2",diffAdditionPrefix:"#66e0ff",primary:"#f0f8ff",secondary:"#ff007f",accent:"#9d00ff",success:"#33d6ff",warning:"#ffcc00",danger:"#ff0040",info:"#9d00ff",statusOn:"#f0f8ff",statusOff:"#5e656e",logoTextAnsi:"\x1B[1;38;5;231m",logoBodyAnsi:"\x1B[38;5;231m",logoMutedAnsi:"\x1B[38;5;240m",logoGradient:["#ffffff","#9d00ff"]},{name:"Magma Eruption",text:"#ff4d00",textMuted:"#cc3d00",textDim:"#802600",textInverted:"#0d0300",border:"#ff4d00",borderMuted:"#cc3d00",borderDim:"#802600",bg:void 0,cardBg:"#1a0600",highlightBg:"#260a00",activeBg:"#401100",inputBg:"#260a00",inputBorder:"#260a00",inputText:"#ff4d00",inputPlaceholder:"#802600",inputPrompt:"#ffcc00",codeBg:"#080200",codeBorder:"#cc3d00",userMsgBg:"#260a00",userMsgBorder:"#260a00",userMsgText:"#ff4d00",diffRemovalBg:"#2e0a0a",diffAdditionBg:"#1f1400",diffRemovalText:"#ff3333",diffAdditionText:"#ffaa00",diffRemovalHighlightColor:"#ff6666",diffRemovalHighlightBg:"#5c1414",diffAdditionHighlightColor:"#ffcc33",diffAdditionHighlightBg:"#3d2900",diffRemovalNum:"#ff3333",diffAdditionNum:"#ffaa00",diffRemovalPrefix:"#ff6666",diffAdditionPrefix:"#ffcc33",primary:"#ff4d00",secondary:"#ffcc00",accent:"#ff0040",success:"#ffaa00",warning:"#ffff00",danger:"#ff0000",info:"#ff8800",statusOn:"#ff4d00",statusOff:"#802600",logoTextAnsi:"\x1B[1;38;5;202m",logoBodyAnsi:"\x1B[38;5;202m",logoMutedAnsi:"\x1B[38;5;236m",logoGradient:["#ff4d00","#ff0000"]}],io={Dark:{id:"Dark",name:"Dark (Default)",text:"white",textMuted:"gray",textDim:"grey",textInverted:"black",textExclusive:"#B5B8D9",textMutedExclusive:"#D4DEE7",border:"white",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:"#1e1e1e",highlightBg:"#2a2a2a",activeBg:"#3a3a3a",inputBg:"#555555",inputBorder:"#555555",inputText:"white",inputPlaceholder:"#cccccc",inputPrompt:"white",codeBg:"#1a1a1a",codeBorder:"#444444",userMsgBg:"#444444",userMsgBorder:"#444444",userMsgText:"white",diffRemovalBg:"#250808",diffAdditionBg:"#072410",diffRemovalText:"#885555",diffAdditionText:"#558866",diffRemovalHighlightColor:"#ff3333",diffRemovalHighlightBg:"#5a1818",diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:"#185a25",diffRemovalNum:"#d96868",diffAdditionNum:"#68d98c",diffRemovalPrefix:"#ff4d4d",diffAdditionPrefix:"#4dff88",primary:"white",secondary:"cyan",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"white",statusOff:"gray",logoTextAnsi:"\x1B[1;37m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},Light:{id:"Light",name:"Light",text:"black",textMuted:"gray",textDim:"grey",textInverted:"white",border:"black",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:"#e5e5e5",highlightBg:"#d4d4d4",activeBg:"#c0c0c0",inputBg:"#d0d0d0",inputBorder:"#d0d0d0",inputText:"black",inputPlaceholder:"#555555",inputPrompt:"black",codeBg:"#e8e8e8",codeBorder:"#b0b0b0",userMsgBg:"#d0d0d0",userMsgBorder:"#d0d0d0",userMsgText:"black",diffRemovalBg:"#fce8e8",diffAdditionBg:"#e6f9e6",diffRemovalText:"#661111",diffAdditionText:"#115511",diffRemovalHighlightColor:"#440000",diffRemovalHighlightBg:"#f8b4b4",diffAdditionHighlightColor:"#003300",diffAdditionHighlightBg:"#a6ebad",diffRemovalNum:"#c02020",diffAdditionNum:"#188028",diffRemovalPrefix:"#d01010",diffAdditionPrefix:"#109020",primary:"black",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"black",statusOff:"gray",logoTextAnsi:"\x1B[1;30m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},"GitHub Dark":{id:"GitHub Dark",name:"GitHub Dark",text:"#c9d1d9",textMuted:"#8b949e",textDim:"#6e7681",textInverted:"#0d1117",border:"#30363d",borderMuted:"#30363d",borderDim:"#21262d",bg:void 0,cardBg:"#161b22",highlightBg:"#21262d",activeBg:"#30363d",inputBg:"#21262d",inputBorder:"#21262d",inputText:"#c9d1d9",inputPlaceholder:"#8b949e",inputPrompt:"#58a6ff",codeBg:"#0d1117",codeBorder:"#30363d",userMsgBg:"#21262d",userMsgBorder:"#21262d",userMsgText:"#c9d1d9",diffRemovalBg:"#3c1e1e",diffAdditionBg:"#11381e",diffRemovalText:"#f85149",diffAdditionText:"#3fb950",diffRemovalHighlightColor:"#ff7b72",diffRemovalHighlightBg:"#701c1c",diffAdditionHighlightColor:"#56d364",diffAdditionHighlightBg:"#116329",diffRemovalNum:"#f85149",diffAdditionNum:"#3fb950",diffRemovalPrefix:"#f85149",diffAdditionPrefix:"#3fb950",primary:"#c9d1d9",secondary:"#58a6ff",accent:"#bc8cff",success:"#3fb950",warning:"#d29922",danger:"#f85149",info:"#58a6ff",statusOn:"#58a6ff",statusOff:"#8b949e",logoTextAnsi:"\x1B[1;36m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#2ea043","#56d364"],toolFeedbackAnsi:"\x1B[95m"},"GitHub Light":{id:"GitHub Light",name:"GitHub Light",text:"#24292f",textMuted:"#57606a",textDim:"#6e7781",textInverted:"#ffffff",border:"#d0d7de",borderMuted:"#d0d7de",borderDim:"#e1e4e8",bg:void 0,cardBg:"#f6f8fa",highlightBg:"#eaeef2",activeBg:"#d0d7de",inputBg:"#eaeef2",inputBorder:"#eaeef2",inputText:"#24292f",inputPlaceholder:"#57606a",inputPrompt:"#0969da",codeBg:"#ffffff",codeBorder:"#d0d7de",userMsgBg:"#eaeef2",userMsgBorder:"#eaeef2",userMsgText:"#24292f",diffRemovalBg:"#ffebe9",diffAdditionBg:"#e6ffec",diffRemovalText:"#cf222e",diffAdditionText:"#1a7f37",diffRemovalHighlightColor:"#82071e",diffRemovalHighlightBg:"#ffc1c0",diffAdditionHighlightColor:"#116329",diffAdditionHighlightBg:"#acf2bd",diffRemovalNum:"#cf222e",diffAdditionNum:"#1a7f37",diffRemovalPrefix:"#cf222e",diffAdditionPrefix:"#1a7f37",primary:"#24292f",secondary:"#0969da",accent:"#8250df",success:"#1a7f37",warning:"#9a6700",danger:"#cf222e",info:"#0969da",statusOn:"#0969da",statusOff:"#57606a",logoTextAnsi:"\x1B[1;34m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#1a7f37","#2da44e"],toolFeedbackAnsi:"\x1B[95m"},"Transparent Dark":{id:"Transparent Dark",name:"Transparent Dark",text:"white",textMuted:"gray",textDim:"grey",textInverted:"black",border:"gray",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:void 0,highlightBg:"#2a2a2a",activeBg:"#3a3a3a",inputBg:"#555555",inputBorder:"#555555",inputText:"white",inputPlaceholder:"#cccccc",inputPrompt:"white",codeBg:void 0,codeBorder:"gray",userMsgBg:"#555555",userMsgBorder:"#555555",userMsgText:"white",diffRemovalBg:void 0,diffAdditionBg:void 0,diffRemovalText:"#ff6666",diffAdditionText:"#66ff66",diffRemovalHighlightColor:"#ff3333",diffRemovalHighlightBg:"#3a1414",diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:"#143a14",diffRemovalNum:"#ff6666",diffAdditionNum:"#66ff66",diffRemovalPrefix:"#ff4d4d",diffAdditionPrefix:"#4dff88",primary:"white",secondary:"cyan",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"white",statusOff:"gray",logoTextAnsi:"\x1B[1;37m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},"Transparent Light":{id:"Transparent Light",name:"Transparent Light",text:"black",textMuted:"gray",textDim:"grey",textInverted:"white",border:"gray",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:void 0,highlightBg:"#d4d4d4",activeBg:"#c0c0c0",inputBg:"#d0d0d0",inputBorder:"#d0d0d0",inputText:"black",inputPlaceholder:"#555555",inputPrompt:"black",codeBg:void 0,codeBorder:"gray",userMsgBg:"#d0d0d0",userMsgBorder:"#d0d0d0",userMsgText:"black",diffRemovalBg:void 0,diffAdditionBg:void 0,diffRemovalText:"#c02020",diffAdditionText:"#188028",diffRemovalHighlightColor:"#800000",diffRemovalHighlightBg:"#f5d0d0",diffAdditionHighlightColor:"#004000",diffAdditionHighlightBg:"#cceccc",diffRemovalNum:"#c02020",diffAdditionNum:"#188028",diffRemovalPrefix:"#d01010",diffAdditionPrefix:"#109020",primary:"black",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"black",statusOff:"gray",logoTextAnsi:"\x1B[1;30m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},"Synthwave 84":{id:"Synthwave 84",name:"Synthwave 84",text:"#fdfdfd",textMuted:"#a08eb7",textDim:"#705c8a",textInverted:"#1a1025",textExclusive:"#e3dcf0",textMutedExclusive:"#b9abc9",border:"#fc28a8",borderMuted:"#a21568",borderDim:"#5c0a3a",bg:void 0,cardBg:"#261b38",highlightBg:"#35254d",activeBg:"#4c3570",inputBg:"#35254d",inputBorder:"#35254d",inputText:"#fdfdfd",inputPlaceholder:"#a08eb7",inputPrompt:"#03e8fc",codeBg:"#1e142b",codeBorder:"#a21568",userMsgBg:"#35254d",userMsgBorder:"#35254d",userMsgText:"#fdfdfd",diffRemovalBg:"#471434",diffAdditionBg:"#144743",diffRemovalText:"#ff4081",diffAdditionText:"#00e5ff",diffRemovalHighlightColor:"#ff79a1",diffRemovalHighlightBg:"#6b1e4e",diffAdditionHighlightColor:"#66f5ff",diffAdditionHighlightBg:"#1e6b65",diffRemovalNum:"#ff4081",diffAdditionNum:"#00e5ff",diffRemovalPrefix:"#ff79a1",diffAdditionPrefix:"#66f5ff",primary:"#fdfdfd",secondary:"#03e8fc",accent:"#fc28a8",success:"#00e5ff",warning:"#ffc107",danger:"#ff4081",info:"#b388ff",statusOn:"#03e8fc",statusOff:"#a08eb7",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#fc28a8","#03e8fc"],toolFeedbackAnsi:"\x1B[38;2;3;232;252m"},"Forest Sprite":{id:"Forest Sprite",name:"Forest Sprite",text:"#d6e6d1",textMuted:"#95b38d",textDim:"#628059",textInverted:"#161c14",textExclusive:"#eaf2e8",textMutedExclusive:"#a9c7a2",border:"#74a862",borderMuted:"#477038",borderDim:"#2b4720",bg:void 0,cardBg:"#1f291c",highlightBg:"#2a3826",activeBg:"#3a4d35",inputBg:"#2a3826",inputBorder:"#2a3826",inputText:"#d6e6d1",inputPlaceholder:"#95b38d",inputPrompt:"#8feb73",codeBg:"#161e14",codeBorder:"#477038",userMsgBg:"#2a3826",userMsgBorder:"#2a3826",userMsgText:"#d6e6d1",diffRemovalBg:"#3b231c",diffAdditionBg:"#203b1c",diffRemovalText:"#db6242",diffAdditionText:"#59cc3f",diffRemovalHighlightColor:"#f0896c",diffRemovalHighlightBg:"#5c362a",diffAdditionHighlightColor:"#80e368",diffAdditionHighlightBg:"#305929",diffRemovalNum:"#db6242",diffAdditionNum:"#59cc3f",diffRemovalPrefix:"#f0896c",diffAdditionPrefix:"#80e368",primary:"#d6e6d1",secondary:"#8feb73",accent:"#e69835",success:"#59cc3f",warning:"#e69835",danger:"#db6242",info:"#73b4eb",statusOn:"#8feb73",statusOff:"#95b38d",logoTextAnsi:"\x1B[1;32m",logoBodyAnsi:"\x1B[32m",logoMutedAnsi:"\x1B[90m",logoGradient:["#8feb73","#e69835"],toolFeedbackAnsi:"\x1B[38;2;143;235;115m"},Spookfest:{id:"Spookfest",name:"Spookfest \u{1F383}",text:"#ffeedd",textMuted:"#e09858",textDim:"#a6622b",textInverted:"#0d0702",textExclusive:"#fff3e6",textMutedExclusive:"#d4a276",border:"#ff7518",borderMuted:"#994409",borderDim:"#592502",bg:void 0,cardBg:"#1a0c02",highlightBg:"#2a1403",activeBg:"#3d1d05",inputBg:"#261203",inputBorder:"#261203",inputText:"#ffeedd",inputPlaceholder:"#a6622b",inputPrompt:"#ff7518",codeBg:"#120701",codeBorder:"#592502",userMsgBg:"#261203",userMsgBorder:"#261203",userMsgText:"#ffeedd",diffRemovalBg:"#3d0a0a",diffAdditionBg:"#1a330a",diffRemovalText:"#ff5555",diffAdditionText:"#73e639",diffRemovalHighlightColor:"#ff2222",diffRemovalHighlightBg:"#590e0e",diffAdditionHighlightColor:"#88ff3b",diffAdditionHighlightBg:"#244d0a",diffRemovalNum:"#ff5555",diffAdditionNum:"#73e639",diffRemovalPrefix:"#ff3333",diffAdditionPrefix:"#88ff3b",primary:"#ff7518",secondary:"#a855f7",accent:"#22c55e",success:"#22c55e",warning:"#f59e0b",danger:"#ef4444",info:"#a855f7",statusOn:"#ff7518",statusOff:"#703a08",logoTextAnsi:"\x1B[1;38;2;255;117;24m",logoBodyAnsi:"\x1B[38;2;255;140;26m",logoMutedAnsi:"\x1B[38;2;168;85;247m",logoGradient:["#ff7518","#a855f7"],toolFeedbackAnsi:"\x1B[38;2;255;117;24m"}};var li=null;var ci=(e="Dark")=>{let n;e==="Mystery"||e==="Chaos"?(li||(li=Yr[Math.floor(Math.random()*Yr.length)]),n={...li,id:"Mystery"}):(li=null,io[e]?n=io[e]:e==="Halloween"?n=io.Spookfest:e==="GitHub"?n=io["GitHub Dark"]:e==="Transparent"?n=io["Transparent Dark"]:n=io.Dark);let t=n.codeText||n.secondary||n.info||n.logoGradient&&n.logoGradient[0]||"cyan",i=n.toolFeedbackAnsi||"\x1B[95m";return{...n,codeText:t,toolFeedbackAnsi:i}};var Va=()=>process.env.TERM_PROGRAM==="vscode"?"vscode":process.env.WT_SESSION?"wt":"default",Uc=(e=2)=>{let n=Va();return n==="wt"?" ".repeat(Math.max(1,e-1)):" ".repeat(e)},Xr=new Date,Eo=Xr.getMonth(),_o=Xr.getDate(),za=Eo===9&&_o>=15||Eo===10&&_o<=1,os=null;(process.env.SPOOKFEST==="true"||za)&&(os=await import("./halloween-MX3VNQRW.js"));var Gc=(e="...",n="Loading...",t="Dark")=>{let i=ci(t),o=n;if(n==="c_openai"||n==="Custom (OpenAI)")try{let V=Ko(Ho,{})?.systemSettings?.customOpenAIBaseUrl;V&&(o=V)}catch{}let r=i.logoTextAnsi,d=i.logoBodyAnsi,l=i.logoMutedAnsi,u="\x1B[0m",g=[" \u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2591 "," \u2588\u2588\u2588\u2591 "," \u2588\u2588\u2588\u2591 "," \u2591\u2591\u2591 "],h=t==="Spookfest"||i.id==="Spookfest"||t==="Halloween"||i.id==="Halloween",m=Eo===9&&_o>=15||Eo===10&&_o<=1,p=h&&m||process.env.SPOOKFEST==="true"&&h,s=g;if(p&&os){process.env.HALLOWEEN_EEGG="true";let{halloweenArtSide:P,halloweenBat:V,halloweenArtUser:M}=os;s=Math.random()>.9&&Eo===9&&_o>=30?V:Math.random()>.5?P:M}else process.env.HALLOWEEN_EEGG="false";let w=p?qr:zr,_=w[Math.floor(Math.random()*w.length)],Pe=i.logoGradient||["#0077ff","#ff00ff"],v=Ka(Pe).multiline(s.join(`
|
|
530
|
+
`)).split(`
|
|
531
|
+
`),N=P=>`${l}${P}${u}`;return`${v[0]}
|
|
532
|
+
${v[1]} ${r}Selected ${p?"Pumpkin":"Provider"}: ${o}${u}
|
|
533
|
+
${v[2]}
|
|
534
|
+
${v[3]} ${r}FluxFlow${p?": Spookfest":""} ${N("v"+e)}${u}
|
|
535
|
+
${v[4]}
|
|
536
|
+
${v[5]} ${d}See /help for additional commands.${u}
|
|
537
|
+
${v[6]} ${N(_)}
|
|
538
|
+
${v[7]}
|
|
539
|
+
`};import{structuredPatch as Qa}from"diff";import is from"path";import qa from"fs";var Ya=e=>{try{return qa.readdirSync(e,{withFileTypes:!0})}catch{return[]}},ss=(e,n=4,t=1,i=Ya,o=[],r=null)=>{let d=r||i(e),l=" ".repeat(t-1),u=t===1?new Set([...mo,...o,...po(e),...po(process.cwd())]):o instanceof Set?o:new Set([...mo,...o]),g=M=>u.has(M),h=d.filter(M=>!g(M.name)),m=d.filter(M=>g(M.name)).length,p=h.filter(M=>!M.isDirectory()).map(M=>M.name).sort(),s=h.filter(M=>M.isDirectory()).sort((M,O)=>M.name.localeCompare(O.name)),w=M=>{let O=M.length;if(O===0)return"no files";let xe=Array.from(new Set(M.map(Ie=>{let ze=typeof Ie=="string"?Ie:Ie.name;return is.extname(ze).slice(1)}).filter(Boolean))).sort(),Re="*";return xe.length===1?Re=`*.${xe[0]}`:xe.length>1&&(Re=`*.{${xe.join(", ")}}`),O===1?Re:`${Re} ${O} files`},_="";if(t===1){let M=p.join(", "),O=m>0?` [${m} ignored]`:"";(M||O)&&(_+=`${l}${M?M+(O?`${O}`:""):O.trim()}
|
|
540
|
+
`)}else p.length>0&&(_+=`${l}[${w(p)}]
|
|
541
|
+
`);let Pe=10,v=s.slice(0,Pe),N=s.length>Pe,P=[],V=[];for(let M of v){let O=is.join(e,M.name),xe=M.name,Re=t,Ie=i(O),ze=Ie.filter(De=>!g(De.name)),G=ze.filter(De=>De.isDirectory()),x=ze.filter(De=>!De.isDirectory());for(;x.length===0&&G.length===1&&Re<n;)xe=`${xe}/${G[0].name}`,O=is.join(O,G[0].name),Re++,Ie=i(O),ze=Ie.filter(De=>!g(De.name)),G=ze.filter(De=>De.isDirectory()),x=ze.filter(De=>!De.isDirectory());let Gt=G.length>0;if(Gt&&Re<n)V.push({displayName:xe,subDirPath:O,subEntries:Ie,nextDepth:Re+1});else{let De=w(x),Ht=Gt&&Re>=n?" ...max scan depth":"";P.push(`${xe}/${De}${Ht}`)}}P.length>0&&(_+=`${l}${P.join(", ")}
|
|
542
|
+
`);for(let{displayName:M,subDirPath:O,subEntries:xe,nextDepth:Re}of V)_+=`${l}${M}/
|
|
543
|
+
`,_+=ss(O,n,Re,i,u,xe);return N&&(_+=`${l}...max scan width, ReadFolder if needed
|
|
544
|
+
`),_};import rs from"path";import Xa from"fs";var Ja=e=>{try{return Xa.readdirSync(e,{withFileTypes:!0})}catch{return[]}},as=(e,n,t="",i=1,o=Ja,r=[])=>{let d=o(e),l=rs.sep;if(d.length>100)return`${t}\u2514\u2500\u2500 ${rs.basename(e)}${l} ...100+ files...
|
|
545
|
+
`;let u="",g=r,h=d.filter(s=>!g.includes(s.name)&&!s.name.startsWith(".")),m=d.filter(s=>g.includes(s.name)||s.name.startsWith(".")).map(s=>s.name).sort();h.sort((s,w)=>s.isDirectory()&&!w.isDirectory()?-1:!s.isDirectory()&&w.isDirectory()?1:s.name.localeCompare(w.name));let p=[...h.map(s=>({name:s.name,isDir:s.isDirectory()})),...m.map(s=>({name:s,isDir:!0,isCollapsed:!0}))];return p.forEach((s,w)=>{let _=w===p.length-1,Pe=rs.join(e,s.name),v=_?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",N=t+(_?" ":"\u2502 ");if(s.isCollapsed){u+=`${t}${v}${s.name}${l}...
|
|
546
|
+
`;return}s.isDir?i>n?u+=`${t}${v}${s.name}${l} ...depth exceeded...
|
|
547
|
+
`:o(Pe).length>80?u+=`${t}${v}${s.name}${l} ...80+ files...
|
|
548
|
+
`:(u+=`${t}${v}${s.name}${l}
|
|
549
|
+
`,u+=as(Pe,n,N,i+1,o,r)):u+=`${t}${v}${s.name}
|
|
550
|
+
`}),u};var Za={Ollama:()=>import("./ollama-6WSZPCI5.js").then(e=>e.getOllamaStream),OpenRouter:()=>import("./openrouter-6MRG4RT6.js").then(e=>e.getOpenRouterStream),DeepSeek:()=>import("./deepseek-WNWZJTNE.js").then(e=>e.getDeepSeekStream),Mistral:()=>import("./mistral-ON6RQMK7.js").then(e=>e.getMistralStream),NVIDIA:()=>import("./nvidia-I6DPWP6U.js").then(e=>e.getNVIDIAStream),NVIDIA_wrap:()=>import("./nvidia-I6DPWP6U.js").then(e=>e.wrapNvidiaStreamWithQueueDepth),InferX:()=>import("./inferx-HP5AGET3.js").then(e=>e.getInferXStream),SenseNova:()=>import("./sensenova-3K44URJQ.js").then(e=>e.getSenseNovaStream),AIHubMix:()=>import("./aihubmix-TETL5QYQ.js").then(e=>e.getAIHubMixStream),Poolside:()=>import("./poolside-ODFAIK4C.js").then(e=>e.getPoolsideStream),NineRouter:()=>import("./9router-LRFKCJF4.js").then(e=>e.getNineRouterStream),ExpLabs:()=>import("./explabs-XHHXTERB.js").then(e=>e.getExpLabsStream),TokenHarbor:()=>import("./tokenharbor-YV2GV2LM.js").then(e=>e.getTokenHarborStream),Infron:()=>import("./infron-ULXG7VDA.js").then(e=>e.getInfronStream),APInex:()=>import("./apinex-FAYOPQSL.js").then(e=>e.getAPInexStream),xKiro:()=>import("./xkiro-B2LYGZTF.js").then(e=>e.getXKiroStream),c_openai:()=>import("./custom_openai-K554R7Q5.js").then(e=>e.getCustomOpenAIStream)},cs={},ye=async e=>(cs[e]||(cs[e]=await Za[e]()),cs[e]),el=/```[\s\S]*?```/g,tl=/```[\s\S]*$/g,nl=/`[^`]+`/g,ol=/^\|.*\|$/gm,il=/^[^\w]+|[^\w]+$/g,sl=/[^a-z0-9]/gi,Io=/\[\s*(?:tool|action):(?:functions\.)?([a-z0-9_]+)\s*\(/gi,rl=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-z0-9_]+)\s*\(/gi,al=/(?:path|targetFile|TargetFile|directory|keyword|id|taskId|title|task)\s*=\s*\\?["']?([^\\"' \),]+)/,wn=/["']/g,Jr=/\\/g,ll=/<\|channel>thought/gi,cl=/<channel\|>/gi,dl=e=>typeof e!="string"?e:e.replace(ll,"<think_fluxflow>").replace(cl,"</think_fluxflow>"),Dd=/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\]|$)/i,fl=(e,n,t=1)=>{let i=n>0?e[n-1]:"",o=n+t<e.length?e[n+t]:"";return i==="`"&&o==="`"},ul=e=>{let n=/(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\])/gi,t;for(;(t=n.exec(e))!==null;)if(!fl(e,t.index,t[0].length))return{index:t.index,length:t[0].length};return{index:-1,length:0}},ds=e=>{if(!e||typeof e!="string")return null;let n=e.match(/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])/i);if(!n)return null;let t=n.index+n[0].length,i=e.substring(t),o=ul(i);if(o.index!==-1){let r=t+o.index+o.length;return{fullBlock:e.substring(0,r),innerContent:i.substring(0,o.index),remainingText:e.substring(r)}}return{fullBlock:e,innerContent:i,remainingText:""}},$t=e=>{if(!e||typeof e!="string")return e;let n=ds(e);return n?n.remainingText.trimStart():e};var Qr=/<\|\s*tool_call_begin\s*\|>\s*(?:(?:tool|functions)\b[\s._]*)*([a-zA-Z0-9_]+)(?::\d+)?\s*<\|\s*tool_call_argument_begin\s*\|>([\s\S]*?)<\|\s*tool_call_end\s*\|>/gi,gl=/"([^"]+)"\s*:\s*(?:"([^"]*)"|(\d+)|true|false|null)/g,Zr=/<\|\s*tool_calls_section_begin\s*\|>/gi,ea=/<\|\s*tool_calls_section_end\s*\|>/gi,ml=/```(?:tool|action|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi;var ui=e=>!e||typeof e!="string"?e:e.replace(/(```[\s\S]*?```|`[^`]*`)|(<(?:\w+)(?:[^>]*)>\r?\n?|\r?\n?<\/\w+(?:[^>]*)>)/gi,(n,t)=>t||""),sa=e=>{if(!e||typeof e!="string")return e;let n=Rn(e);if(!n||n.length===0)return e;let t=n[n.length-1];if(!t.fullMatch)return e;let i=e.lastIndexOf(t.fullMatch);if(i===-1)return e;let o=i+t.fullMatch.length,r=e.substring(o);return/\[\s*(?:tool|action):/i.test(r)?e.trimEnd():e.substring(0,o).trimEnd()},us=null,Mo={},Gn={key:null,value:null},Rt=e=>{if(!e)return e;let n=Mo?.theme;if(!n)try{n=Ko(Ho,{})?.systemSettings?.theme}catch{}let i=ci(n||"Dark").toolFeedbackAnsi||"\x1B[95m";return e.replace(/(?:(\x1b\[\d+m))?([✔✘✖🔍📖→➕↻↷•🛇])(?:(\x1b\[\d+m))?\s*\b(Clicked Screen|Clicked|Located|Dragged|Scrolled|Typed|Entered|Pressed Key|Recaptured Screen|Created|Read Skill|Read Documentation|Executed|Searched Documentation|Read|Edited|Viewed|Processed|Auto-Read|Skipped|List|Generated|Written|Searched|AI Search|Get Map|Write Canceled|Resolved Sub-Agent Query|Edit Canceled|Write Cancelled|Edit Denied|Visited|Updated|Reviewed|Delegated|Background|Checked|Indexed|Analyzed|Browsed|Elevating SubAgent|Checking SubAgent Work|Started Generalist|Called Generalist|Steered|Unsupported Modality|Awaiting|Cancelled|Aligning Moon Phase|Contemplating Existence|Staring At Void|Rollback Point Checked|Emergency Rollback Failed|Emergency Rollback|Delaying Professionally|Negotiating With Electrons|Touching Grass (virtually)|Panicking Softly|Rethinking Career Choices|Loading Cat Videos|Giving Up Entirely|Summoning Braincell #2|Pretending To Be Busy|Waiting For Motivation DLC|Rotating Internal Screaming|Downloading More RAM|Feeding The Hamsters|Gaslighting Scheduler|Performing Dramatic Pause|Buffering Social Energy|Calculating Regret|Reading Terms And Conditions|Becoming Sentient Briefly|Model produced malformed tool call|Loop Detected|Contacting Ancestors)\b/ig,(o,r,d,l,u)=>`${r||""}${d}${l||""} ${i}${u}\x1B[0m`)},pl=async(e,n=8,t=1e3,i=8e3,o=null)=>{let r=0;for(;;){if(o?.aborted)throw new DOMException("The user aborted a request.","AbortError");try{return await e()}catch(d){if(o?.aborted||d?.name==="AbortError"||d?.message==="Subagent task was cancelled."||(r++,r>=n))throw d;let l=Math.min(t*Math.pow(2,r-1),i);await new Promise((u,g)=>{let h=setTimeout(u,l);o&&o.addEventListener("abort",()=>{clearTimeout(h),g(new DOMException("The user aborted a request.","AbortError"))})})}}},ct=!1;var Nd=e=>{let n=e.filter(o=>(o.role==="user"||o.role==="agent"||o.role==="system")&&o.role!=="think"&&!o.isVisualFeedback&&!o.isMeta&&!o.isTerminalRecord&&!(o.text&&o.text.includes("[TERMINAL_RECORD]"))&&!String(o.id).startsWith("welcome")).map((o,r,d)=>{let l=o.fullText||o.text||"";if(o.role==="user"&&r<d.length-1)if(l.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")){let u=l.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");if(u!==-1){let h=l.substring(0,u).lastIndexOf("[SYSTEM METADATA]");h!==-1?l=l.substring(h).trim():l=l.substring(u).trim()}}else{let u=l.lastIndexOf("[USER]"),g=l.lastIndexOf("[USER PROMPT]");u!==-1?l=l.substring(u+6).trim():g!==-1&&(l=l.substring(g).trim())}return{...o,text:l}}),t=[],i=0;for(;i<n.length;){let o=n[i];if(o.role==="user")t.push(o),i++;else{let r=[];for(;i<n.length&&n[i].role!=="user";)r.push(n[i]),i++;let d=[],l=[],u=!1,g=()=>{d.length>0&&(t.push({role:"agent",text:"combined"}),d=[]),l.length>0&&(t.push({role:"system",text:"combined"}),l=[]),u=!1};r.forEach(h=>{let m=h.role==="system"&&(h.text?.startsWith("[ACTION RESULT]")||h.text?.startsWith("[TOOL RESULT]")||h.text?.startsWith("SUCCESS:")||h.text?.startsWith("ERROR:")||h.fullText?.startsWith("[ACTION RESULT]")||h.fullText?.startsWith("[TOOL RESULT]")||h.fullText?.startsWith("SUCCESS:")||h.fullText?.startsWith("ERROR:")),p=h.fullText||h.text||"",s=p.trim();if(!(!s&&!h.binaryPart)){if(m)l.push(s);else if(h.role==="agent"){!u&&l.length>0&&g();let w=p.endsWith(`
|
|
551
|
+
`),_=s.toLowerCase().includes("tool:")||s.toLowerCase().includes("action:");d.push(s),_&&w?u=!0:u=!1}}}),g()}}return t.length};var Fd=()=>{ct=!0},Bd=()=>ct,fs={write_file:"Writing",update_file:"Editing",read_folder:"Reading",view_file:"Reading",exec_command:"Executing Command",web_search:"Searching",web_scrape:"Reading",memory:"Updating Memory",search_keyword:"Searching",find_file:"Finding File",findFile:"Finding File",FindFile:"Finding File",file_map:"Generating Map",ask:"User Input",write_pdf:"Creating",write_docx:"Creating",generate_image:"Generating",todo:"Planning",Todo:"Planning",goal:"Planning",Goal:"Planning",invoke_sync:"Sub-Agent Working",invoke:"Starting Agent",get_progress:"Checking Progress",cancel:"Cancelling",await:"Waiting",wait:"Waiting",EmergencyRollback:"Don't Panic. Lookin' into it",answer:"Answering Sub-Agent",Answer:"Answering Sub-Agent",steer:"Steering Sub-Agent",Steer:"Steering Sub-Agent",Click:"Clicking",click:"Clicking",Drag:"Dragging",drag:"Dragging",Scroll:"Scrolling",scroll:"Scrolling",KeyboardTyping:"Typing",keyboard_typing:"Typing",KeyPress:"Pressing Key",key_press:"Pressing Key",RecaptureScreen:"Recapturing Screen",recapture_screen:"Recapturing Screen"},Hn=(e,n)=>{try{let t=L(n),i=e.toLowerCase().replace(/_/g,"");if(i==="invokesync"||i==="invoke")return t.title||(t.task?t.task.substring(0,30):null);if(i==="getprogress"||i==="cancel"||i==="steer"||i==="steersubagent")return t.id||t.taskId;let o=t.name||t.path||t.targetFile||t.TargetFile||t.directory||t.file||t.query;return o?te.basename(o.replace(/["']/g,"").replace(/\\/g,"/")):null}catch{return null}},ra=e=>e?new ia({apiKey:e}):us,Wd=async(e,n,t,i,o={})=>{},gi=e=>{if(!e||typeof e!="string")return e;let n=e.split(""),t=!1,i=!1,o=0;for(;o<n.length;){if(n[o]==="`"&&n[o+1]==="`"&&n[o+2]==="`"){t?(n[o]=" ",n[o+1]=" ",n[o+2]=" ",t=!1):(n[o]=" ",n[o+1]=" ",n[o+2]=" ",t=!0),o+=3;continue}if(t){n[o]!==`
|
|
552
|
+
`&&n[o]!=="\r"&&(n[o]=" "),o++;continue}if(n[o]==="`")if(i){i=!1,n[o]=" ",o++;continue}else{i=!0,n[o]=" ",o++;continue}if(i){n[o]===`
|
|
553
|
+
`||n[o]==="\r"?i=!1:n[o]=" ",o++;continue}o++}return n.join("")},ta=(e,n=null)=>{if(!e||typeof e!="string")return e;let t=n||Rn(e);if(!t||t.length===0)return e;let i=e.split("");for(let o of t){if(!o.fullMatch)continue;let r=0;for(;(r=e.indexOf(o.fullMatch,r))!==-1;){for(let d=r;d<r+o.fullMatch.length;d++)i[d]!==`
|
|
554
|
+
`&&i[d]!=="\r"&&(i[d]=" ");r+=o.fullMatch.length}}return i.join("")},hl=e=>{let n=$t(e),t=gi(n);Io.lastIndex=0;let i;for(;(i=Io.exec(t))!==null;){let o=i.index+i[0].length-1,r=0,d=null,l=!1,u=!1;for(let g=o;g<t.length;g++){let h=t[g];if(!d&&(h==='"'||h==="'"||h==="`")?(d=h,l=!1):d&&h===d&&!l&&(d=null),!d&&(h==="("?r++:h===")"&&r--,r===0)){let m=g+1;for(;m<t.length&&/\s/.test(t[m]);)m++;if(m<t.length&&t[m]==="]"){u=!0,Io.lastIndex=m+1;break}}h==="\\"?l=!l:l=!1}if(!u)return{inside:!0,toolName:i[1],startIndex:i.index,args:n.substring(i.index+i[0].length)}}return{inside:!1}},aa=(e,n=!0)=>{let t=Io;t.lastIndex=0;let i="",o=0,r;for(;(r=t.exec(e))!==null;){let d=e.substring(o,r.index);i+=n&&o===0?$t(d):d;let l=r.index+r[0].length-1,u=0,g=null,h=-1;for(let m=l;m<e.length;m++){let p=e[m];if(g){if(p===g){let s=0;for(let w=m-1;w>=0&&e[w]==="\\";w--)s++;s%2===0&&(g=null)}}else if(p==='"'||p==="'"||p==="`")g=p;else if(p==="(")u++;else if(p===")"&&(u--,u===0)){let s=m+1;for(;s<e.length&&/\s/.test(e[s]);)s++;if(s<e.length&&e[s]==="]"){h=s;break}}}if(h!==-1)i+="[tool:functions."+r[1]+"()]",o=h+1,t.lastIndex=o;else{i+="[tool:functions."+r[1]+"(",o=e.length;break}}return o<e.length&&(i+=n&&o===0?$t(e.substring(o)):e.substring(o)),i},yl=(e,n,t)=>{let i=Io;i.lastIndex=0;let o="",r=0,d;for(;(d=i.exec(e))!==null;){let l=e.substring(r,d.index);o+=l.replace(n,t);let u=d.index+d[0].length-1,g=0,h=null,m=-1;for(let p=u;p<e.length;p++){let s=e[p];if(h){if(s===h){let w=0;for(let _=p-1;_>=0&&e[_]==="\\";_--)w++;w%2===0&&(h=null)}}else if(s==='"'||s==="'"||s==="`")h=s;else if(s==="(")g++;else if(s===")"&&(g--,g===0)){let w=p+1;for(;w<e.length&&/\s/.test(e[w]);)w++;if(w<e.length&&e[w]==="]"){m=w;break}}}if(m!==-1)o+=e.substring(d.index,m+1),r=m+1,i.lastIndex=r;else{o+=e.substring(d.index),r=e.length;break}}return r<e.length&&(o+=e.substring(r).replace(n,t)),o},na=e=>aa(e,!0),xl=e=>{if(!e)return e;let n={patchfile:"PatchFile",writefile:"WriteFile",readfile:"ReadFile",viewfile:"ReadFile",run:"Run",execcommand:"Run",searchkeyword:"SearchKeyword",codesearch:"CodeSearch",code_search:"CodeSearch",websearch:"WebSearch",webscrape:"WebScrape",readfolder:"ReadFolder",writepdf:"WritePDF",writedoc:"WriteDoc",writedocx:"WriteDoc",filemap:"FileMap",generateimage:"GenerateImage",todo:"Todo",goal:"Goal",askuser:"AskUser",ask:"AskUser"},t=o=>o.split("_").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("");Qr.lastIndex=0;let i=e.replace(Qr,(o,r,d)=>{let l="";try{let h=JSON.parse(d.trim());h&&typeof h=="object"&&(l=Object.entries(h).map(([p,s])=>{let w=typeof s=="string"?s:JSON.stringify(s);return`${p}=${JSON.stringify(w)}`}).join(", "))}catch{let m=[],p=gl;p.lastIndex=0;let s;for(;(s=p.exec(d))!==null;){let w=s[1],_=s[2]!==void 0?s[2]:s[0].split(":").slice(1).join(":").trim();m.push(`${w}=${JSON.stringify(_)}`)}m.length>0?l=m.join(", "):l=d.trim()}let u=r.toLowerCase().replace(/_/g,"");return`[tool:functions.${n[u]||t(r)}(${l})]`});return Zr.lastIndex=0,ea.lastIndex=0,i=i.replace(Zr,""),i=i.replace(ea,""),i},Rn=e=>{if(!e)return[];let n=xl(e),t=$t(n),i=[],o=gi(t),r=rl;r.lastIndex=0;let d;for(;(d=r.exec(o))!==null;){let l=d[1],u=d.index+d[0].length-1,g=0,h=null,m=-1,p=-1;for(let s=u;s<o.length;s++){let w=o[s];if(h){if(w===h){let _=0;for(let Pe=s-1;Pe>=0&&o[Pe]==="\\";Pe--)_++;_%2===0&&(h=null)}}else{if(s>u&&(o.substring(s).startsWith("[action:")||o.substring(s).startsWith("[tool:")))break;if(w==='"'||w==="'"||w==="`")h=w;else if(w==="(")g++;else if(w===")"&&(g--,g===0)){p=s;let _=s+1;for(;_<o.length&&/\s/.test(o[_]);)_++;if(_<o.length&&o[_]==="]"){m=_;break}}}}if(m!==-1){let s=t.substring(u+1,p),w=t.substring(d.index,m+1);i.push({fullMatch:w,toolName:l.trim(),args:s.trim()}),r.lastIndex=m+1}}return i},oa=e=>{if(!e)return null;let n=$t(e),t=[],i=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,o=[],r;for(;(r=i.exec(n))!==null;)o.push({toolName:r[1],index:r.index,parenIndex:r.index+r[0].length-1});for(let p=0;p<o.length;p++){let s=o[p],w=p+1<o.length?o[p+1].index:n.length,_=n.substring(s.index,w),Pe=_.indexOf("("),v=Pe!==-1?_.substring(Pe+1):"",N=0,P=null,V=!1;for(let M=0;M<v.length;M++){let O=v[M];if(P){if(O===P){let xe=0;for(let Re=M-1;Re>=0&&v[Re]==="\\";Re--)xe++;xe%2===0&&(P=null)}}else if(O==='"'||O==="'"||O==="`")P=O;else if(O==="(")N++;else if(O===")")if(N>0)N--;else{let xe=M+1;for(;xe<v.length&&/\s/.test(v[xe]);)xe++;if(xe<v.length&&v[xe]==="]"){V=!0;break}}}if(!V){let M=_.trim(),O="";P?O=`Unclosed quote string (${P}) inside arguments`:M.endsWith("]")?O=`Missing closing ')' before ']' (e.g. found "...]")`:M.endsWith(")")?O=`Missing closing ']' after ')' (e.g. found "...)" instead of "...)]")`:!M.includes(")")&&!M.includes("]")?O="Missing closing delimiter ')]'":O="Malformed or unclosed call syntax (missing ')]')",t.push(`\u2022 [action:${s.toolName}(...)]: ${O}. Expected: [action:${s.toolName}(arg1="...", arg2="...")]`)}}let d=/(?:^|[^\w\[])(?:tool|action):(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/gi,l;for(;(l=d.exec(n))!==null;){let p=l[1],s=l.index+(l[0].indexOf(":")-(l[0].startsWith("action")||l[0].startsWith("tool")?0:1));(s>0?n[s-1]:"")!=="["&&ai(p)&&t.push(`\u2022 action:${p}(...): Missing opening bracket '['. Expected: [action:${p}(...)]`)}let u=/\[\s*(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/g,g;for(;(g=u.exec(n))!==null;){let p=g[1];p!=="action"&&p!=="tool"&&ai(p)&&t.push(`\u2022 [${p}(...)]: Missing 'action:' prefix. Expected: [action:${p}(...)]`)}let h=/\[\s*(?:tool|action)\s*:\s*(?:functions\.)?([a-zA-Z0-9_]+)(?!\s*\()/gi,m;for(;(m=h.exec(n))!==null;){let p=m[1];ai(p)&&t.push(`\u2022 [action:${p}...]: Missing opening '(' for tool arguments. Expected: [action:${p}(...)]`)}return t.length>0?t.join(`
|
|
555
|
+
`):null},Ud=(e,n={})=>{if(!e)return null;if(Mo=n,us=new ia({apiKey:e}),!globalThis.__perfCleanupInstalled){globalThis.__perfCleanupInstalled=!0,setInterval(()=>{typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks())},6e4);let t=globalThis.fetch;globalThis.fetch=async(...i)=>{try{let o=await t(...i);return typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),o}catch(o){throw typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),o}}}},la=e=>{if(!e)return{serviceTier:void 0,cleanModel:e};let n=e.toLowerCase();return n.endsWith(":flex")?{serviceTier:"flex",cleanModel:e.slice(0,-5)}:n.endsWith(":priority")?{serviceTier:"priority",cleanModel:e.slice(0,-9)}:{serviceTier:void 0,cleanModel:e}},wl=async(e,n,t,i,o="Fast",r=.75,d="agent")=>pl(async()=>{let{aiProvider:l="Google",apiKey:u,mode:g}=e,h="",m=null,p=typeof t=="string"?[{role:"user",parts:[{text:t}]}]:t,s=new AbortController,w=s.signal,_=setInterval(()=>{ct&&(s.abort(),clearInterval(_))},100),Pe=Date.now(),v=null;try{let N;if(l==="Ollama")N=(await ye("Ollama"))(u,n,p,i,o,g,et(n),w,r,e.systemSettings?.ollamaEndpoint||"Cloud");else if(l==="OpenRouter")N=(await ye("OpenRouter"))(u,n,p,i,o,g,et(n),w,r);else if(l==="DeepSeek")N=(await ye("DeepSeek"))(u,n,p,i,o,g,et(n),w,r);else if(l==="Mistral")N=(await ye("Mistral"))(u,n,p,i,o,g,et(n),w,r);else if(l==="NVIDIA")N=(await ye("NVIDIA"))(u,n,p,i,o,g,et(n),w,r);else if(l==="InferX")N=(await ye("InferX"))(u,n,p,i,o,g,et(n),w,r);else if(l==="SenseNova")N=(await ye("SenseNova"))(u,n,p,i,o,g,et(n),w,r);else if(l==="AIHubMix")N=(await ye("AIHubMix"))(u,n,p,i,o,g,et(n),w,r);else if(l==="Poolside")N=(await ye("Poolside"))(u,n,p,i,o,g,et(n),w,r);else if(l==="9router"||l==="9Router")N=(await ye("NineRouter"))(u,n,p,i,o,g,et(n),w,r);else if(l==="ExpLabs"||l==="ExperientialLabs")N=(await ye("ExpLabs"))(u,n,p,i,o,g,et(n),w,r);else if(l==="Infron"||l==="infron")N=(await ye("Infron"))(u,n,p,i,o,g,et(n),w,r);else if(l==="TokenHarbor"||l==="Token Harbor"||l==="tokenharbor"||l==="token_harbor"||l==="thk")N=(await ye("TokenHarbor"))(u,n,p,i,o,g,et(n),w,r);else if(l==="APInex"||l==="apinex"||l==="apx")N=(await ye("APInex"))(u,n,p,i,o,g,et(n),w,r);else if(l==="xKiro"||l==="xkiro"||l==="kiro")N=(await ye("xKiro"))(u,n,p,i,o,g,et(n),w,r);else if(l==="c_openai"||l==="Custom (OpenAI)"){let P=e.systemSettings?.customOpenAIBaseUrl||"";try{P=await Ii("c_openai")||P}catch{}N=(await ye("c_openai"))(u,n,p,i,o,g,et(n),w,r,P)}else{let P=ra(u),{serviceTier:V,cleanModel:M}=la(n),O={systemInstruction:i,temperature:r,thinkingConfig:(()=>{let Re=(n||"").toLowerCase(),Ie=Re.includes("gemma-4")||Re.startsWith("gemma"),ze=Re.includes("gemini-3");if(Ie||ze)return Ie?o.toLowerCase()!=="xhigh"?{includeThoughts:!1,thinkingLevel:Ke.MINIMAL}:{includeThoughts:!0,thinkingLevel:Ke.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:Re.includes("pro")?Ke.LOW:Ke.MINIMAL,Low:Ke.LOW,Medium:Ke.MEDIUM,Standard:Ke.MEDIUM,High:Ke.HIGH,xHigh:Ke.HIGH}[o]||Ke.MEDIUM};{let G={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[o]||2048;return G===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:G}}})()};V&&(O.serviceTier=V),N=await P.models.generateContentStream({model:M,contents:p,config:O},{signal:w})}for await(let P of N){if(ct)throw new Error("Subagent task was cancelled.");if(e?.taskId&&typeof Ot<"u"){let O=Ot.find(xe=>xe.id===e.taskId);if(O&&O.status==="cancelled")throw new Error("Subagent task was cancelled.")}v===null&&(P.candidates?.[0]?.content?.parts||P.text)&&(v=Date.now()-Pe);let V="";if(P.candidates?.[0]?.content?.parts)for(let O of P.candidates[0].content.parts)O.text&&!O.thought&&(h+=O.text,V+=O.text);let M=V?Oi(V):0;e&&typeof e.onTokenChunk=="function"&&e.onTokenChunk(V,M),P.usageMetadata&&(m=P.usageMetadata)}}finally{clearInterval(_)}if(m){let N=m.totalTokenCount||0,P=m.cachedContentTokenCount||0,V=(m.candidatesTokenCount||0)+(l==="Google"&&m.thoughtsTokenCount||0);await an("tokens",N,l,n),P>0&&await an("cachedTokens",P,l,n),V>0&&await an("candidateTokens",V,l,n),v!==null&&v>0&&await an("ttft",v,l,n),qo({provider:l,model:n,prompt:m.promptTokenCount||0,cached:P,output:V,reasoning:m.thoughtsTokenCount||0,ttft:v}),e&&typeof e.onUsage=="function"&&e.onUsage({totalTokenCount:N,cachedContentTokenCount:P,candidatesTokenCount:V})}return await St("agent",l),{text:h,usageMetadata:m}}),Gd=async function*(e,n,t,i,o){let{profile:r,thinkingLevel:d,mode:l,janitorModel:u,chatId:g,isPlayground:h,systemSettings:m,sessionStats:p,aiProvider:s="Google",apiTier:w,wildcardTooling:_,wildercardTooling:Pe}=t,v=et(e);if(!us&&s==="Google")throw new Error("AI not initialized");let N=!1,P=n[n.length-1].text,V=te.join(_s,"chat-summaries.json"),M=!1,O=n.filter(G=>G.role==="user").length===1,xe=P.includes("[TITLE-UPDATE]"),Re=O||xe,Ie=P.replace(/\[TITLE-UPDATE\]/g,"").trim();Ie=Ie.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),yield{type:"status",content:"[start]"},yield{type:"status",content:"Gathering Context"},await Yo.startTransaction(g,Ie),m?.advanceRollback&&await ho.takeInitialSnapshot(g),ct=!1;let ze=null;try{let G=new AbortController;ze=setInterval(()=>{ct&&(G.abort(),ze&&(clearInterval(ze),ze=null))},400);let x=[...n.slice(0,-1)];{let Se=rn(V,{})[g]||{summary:"",historyLength:0};if(Se.summary&&Se.historyLength>0){let Et=0,pe=[];for(let se=0;se<x.length;se++){let Oe=x[se];(Oe.role==="user"||Oe.role==="agent"||Oe.role==="system")&&!String(Oe.id).startsWith("welcome")&&!Oe.isMeta&&Et++,Et>Se.historyLength&&pe.push(Oe)}x=pe}}x=x.map(C=>{if(C.role==="user"&&C.text){let Se=C.text.match(/\[USER\]([\s\S]*?)\[\/USER\]/);if(Se)return{...C,text:Se[1].trim()}}return{...C}});let Gt=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1,Ne={"16k":16e3,"32k":32e3,"64k":64e3,"128k":128e3,"256k":256e3,"512k":512e3,"1M":1e6}[m?.contextLength]||256e3;if(s==="Google"&&e?.includes("gemma")&&Gt&&(Ne=16e3),(p?.tokens||0)>Ne){yield{type:"text",content:"\u2726 Maximum Context Limit Reached. Start a new chat."};return}if(O&&N){let C=rn(Ri,{});Object.values(C).flat().length>5}let re=rn(Ri,{}),en=rn(Is,{}),jn=Object.entries(re).filter(([C])=>C!==g).flatMap(([C,Se])=>Se),Oo=[...Object.entries(en).filter(([C])=>C!==g).slice(-20).map(([C,Se])=>`[Chat Summary]: ${Se}`),...jn].map(C=>`- ${C}`).join(`
|
|
556
|
+
`),En=rn(jo,[]).map(C=>`- ${C.memory}`).join(`
|
|
557
|
+
`),Kn=(p?.tokens||0)>=1e4,jt=new Date,_n=jt.getFullYear(),Ee=jt.toLocaleString("en-US",{month:"short"}).toUpperCase(),Vn=String(jt.getDate()).padStart(2,"0"),X=`${jt.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}`,W=C=>{try{return ve.readdirSync(C,{withFileTypes:!0})}catch{return[]}},qn=Array.from(new Set([...mo,...po(process.cwd())])),ut=(C,Se=6)=>m?.indentationTree!==!1?ss(C,Se,1,W,qn):as(C,Se,"",1,W,qn),A=rn(Ei,{}),ne=A[g],Kt=ne?ne!==process.cwd():!1;A[g]=process.cwd(),_i(Ei,A);let Lt=rn(V,{}),wt=Lt[g]||{summary:"",historyLength:0};typeof wt=="string"&&(wt={summary:wt,historyLength:0});let In=n.filter(C=>(C.role==="user"||C.role==="agent"||C.role==="system")&&!String(C.id).startsWith("welcome")&&!C.isMeta).length;wt.historyLength&&In<wt.historyLength&&(wt.summary="",wt.historyLength=0,Lt[g]=wt,_i(V,Lt));let Lo=typeof wt=="object"?wt.summary||"":wt||"",gs=x.length>0;gs&&Lo&&x[0]&&(x[0].role==="user"||x[0].role==="system")&&(x[0].text.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")||(x[0].text=`[SYSTEM METADATA]
|
|
558
|
+
**CONTEXT SUMMARY OF PREVIOUS TURNS (PRIORITY: DYNAMIC)**
|
|
559
|
+
${Lo}
|
|
560
|
+
|
|
561
|
+
[USER] ${x[0].text}`,yield{type:"summary_injected",content:{id:x[0].id,text:x[0].text}}));let mi=Lo&&!gs?`
|
|
562
|
+
[SYSTEM METADATA]
|
|
563
|
+
**CONTEXT SUMMARY OF PREVIOUS TURNS**
|
|
564
|
+
${Lo}
|
|
565
|
+
`:"",ms=!!m?.dynamicDirAwareness,ca=`${g}|${s}|${d}|${e}|${r}|${ms}`,da=!ms&&Gn.key===ca&&Gn.value?"":`
|
|
566
|
+
**Directory**
|
|
567
|
+
CWD: `+process.cwd()+`${h?" [PLAYGROUND MODE]":""}
|
|
568
|
+
`+ut(process.cwd(),6),kt=oo()?await Un():null,ps=C=>{if(!C||!Array.isArray(C)||C.length===0)return null;let Se=new Map;for(let pe of C){let se=pe.relPath||(pe.file?te.relative(process.cwd(),pe.file):"unknown");Se.has(se)||Se.set(se,[]),Se.get(se).push(pe)}let Et=[];for(let[pe,se]of Se.entries()){Et.push(`- ${pe}:`);for(let Oe of se){let Ve=(Oe.snippet||"").trim().replace(/\r?\n/g," "),qe=Oe.line||1,_t=(Oe.text||"").trim().replace(/\r?\n+/g,". "),gt=_t?` [${_t}]`:"";Et.push(` ~L${qe}${gt}`)}}return Et.join(`
|
|
569
|
+
`)},pi=ps(kt?.comments),dn="";if(kt&&kt.file_focused!=="none"){dn=`
|
|
570
|
+
[Additional IDE Context]
|
|
571
|
+
`;let C=te.relative(process.cwd(),kt.file_focused),Se=(kt.opened_editors||[]).map(pe=>{let se=te.relative(process.cwd(),pe);return se.startsWith("..")?`[External] ${te.basename(pe)}`:se});if(dn+=`Focused File: ${C}
|
|
572
|
+
Cursor Line: ${kt.cursor_line}
|
|
573
|
+
`,kt.selected){let pe=kt.selected,se=pe.split(`
|
|
574
|
+
`);se.length>256&&(pe=se.slice(0,240).join(`
|
|
575
|
+
`)+`
|
|
576
|
+
... [truncated] ...
|
|
577
|
+
`+se.slice(-16).join(`
|
|
578
|
+
`)),pe.length>2048&&(pe=pe.slice(0,1920)+`
|
|
579
|
+
... [truncated] ...
|
|
580
|
+
`+pe.slice(-128)),dn+=`Current Selection: "${pe}"
|
|
581
|
+
`}if(kt.manual_edits){let pe=kt.manual_edits.split(`
|
|
582
|
+
`),se=[];for(let Oe=0;Oe<pe.length;Oe++){let Ve=pe[Oe],qe=pe[Oe+1],_t=pe[Oe+2];if(qe!==void 0&&_t!==void 0&&/:\s*$/.test(Ve)&&/^\s*-\s*/.test(qe)&&/^\s*\+\s*/.test(_t)&&(qe.length>300||_t.length>300)){se.push(Ve.replace(/:\s*$/,": [changed]")),Oe+=2;continue}se.push(Ve)}dn+=`Recent Manual Edits:
|
|
583
|
+
${se.join(`
|
|
584
|
+
`)}
|
|
585
|
+
`}Se.length>0&&(dn+=`All Opened Editors: ${Se.join(", ")}`),kt.diagnostics&&(dn+=`
|
|
586
|
+
**Active File Errors**:
|
|
587
|
+
${kt.diagnostics}
|
|
588
|
+
`),(Ie.toLowerCase().includes("lint")||Ie.toLowerCase().includes("warning"))&&kt.warnings&&(dn+=`
|
|
589
|
+
**Lint Warnings**:
|
|
590
|
+
${kt.warnings}
|
|
591
|
+
`)}let hs=Ie.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),ys=/(?:\\)?@\[([^\]]+)\]/g,hi,yi=[];for(ys.lastIndex=0;(hi=ys.exec(hs))!==null;){let C=hi[0].startsWith("\\");yi.push({tag:hi[1],isEscaped:C})}let xi=[],Do=null;for(let C=0;C<yi.length;C++){let{tag:Se,isEscaped:Et}=yi[C];if(!Et)try{let pe=Se.trim().replace(/^["']|["']$/g,""),se=/[:#]L?(\d+)(?:-L?(\d+))?$/i,Oe=pe.match(se),Ve=pe,qe=null,_t=null;Oe&&(qe=parseInt(Oe[1],10),_t=Oe[2]?parseInt(Oe[2],10):qe,Ve=pe.slice(0,Oe.index));let gt=te.resolve(process.cwd(),Ve);if(ve.existsSync(gt)&&ve.statSync(gt).isFile()){let It=Ve.toLowerCase(),so=It.endsWith(".pdf"),Pn=It.endsWith(".docx")||It.endsWith(".doc")||It.endsWith(".ppt")||It.endsWith(".pptx")||It.endsWith(".xls")||It.endsWith(".xlsx"),On=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(It),Ge=On||so||Pn,bt=s==="Google"||et(e);if(Ge&&!bt){let ke=`\u2718 Unsupported Modality: ${te.basename(Ve)}`,tt=115;process.stdout.isTTY&&(tt=process.stdout.columns-5||120);let Dt=[ke],He=Math.max(...Dt.map(qt=>qt.length)),J=Math.min(He+4,tt),Fe=Dt.map(qt=>`${qt.padEnd(J-2).substring(0,J-2)}`).join(`
|
|
592
|
+
`);yield{type:"visual_feedback",content:Rt(`${Fe}
|
|
593
|
+
`)};continue}if(qe===null&&!Ge){let ke=0;try{ke=ve.readFileSync(gt,"utf8").split(/\r\n|\r|\n/).length}catch{}if(ke>300){let tt=`\u21B7 Skipped (Too Large): ${te.basename(Ve)}`,Dt=115;process.stdout.isTTY&&(Dt=process.stdout.columns-5||120);let He=Math.min(tt.length+4,Dt),J=tt.padEnd(He-2).substring(0,He-2);yield{type:"visual_feedback",content:Rt(`${J}
|
|
594
|
+
`)};continue}}let fn=qe!==null?qe:1,Tt=_t!==null?_t:qe!==null?qe:fn+299;Tt-fn>300&&(Tt=fn+300);let $n=`path=${JSON.stringify(Ve)}, startLine=${fn}, endLine=${Tt}`,Mt=await Ws($n,{isMultiModal:bt}),bn=!1,Xn="",dt=null;if(typeof Mt=="string"?Mt.trim().startsWith("ERROR")?bn=!0:Xn=Mt:Mt&&typeof Mt=="object"&&Mt.binaryPart?(dt=Mt.binaryPart,Xn=Mt.text||""):bn=!0,!bn){let ke="";if(On?(ke=`\u2714 Processed: ${te.basename(Ve)}`,Do=dt):so||Pn?(ke=`\u2714 Auto-Analysed: ${te.basename(Ve)}`,Do=dt):(ke=`\u2714 Auto-Read: ${te.basename(Ve)}`,xi.push(Xn)),ke){let tt=115;process.stdout.isTTY&&(tt=process.stdout.columns-5||120);let Dt=[ke],He=Math.max(...Dt.map(qt=>qt.length)),J=Math.min(He+4,tt),Fe=Dt.map(qt=>`${qt.padEnd(J-2).substring(0,J-2)}`).join(`
|
|
595
|
+
`);yield{type:"visual_feedback",content:Rt(`${Fe}
|
|
596
|
+
`)}}}}}catch{}}let wi="";xi.length>0&&(wi=`
|
|
597
|
+
[Tagged File Contents] Auto Read User Tagged files by System, No need to re-read
|
|
598
|
+
`+xi.join(`
|
|
599
|
+
|
|
600
|
+
`)+`
|
|
601
|
+
[Tagged File Contents]
|
|
602
|
+
`);let xs=hs.replace(/\\(@\[[^\]]+\])/g,"$1"),ws=_?`You cannot execute tools. Instead write the action string in chat you WOULD have written, without markdown wrappers. Then wait for systtem response
|
|
603
|
+
`:"",fa=process.env.forcedReasoning||!1,bs=d!=="Fast"&&(s==="Mistral"&&!Vo(e)||d!=="High"&&s==="Google")?`${s==="Mistral"&&!Vo(e)||e.toLowerCase().startsWith("gemma")||fa?`[system] strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow> [/system]
|
|
604
|
+
`:""}`:"",Yn="";if(m?.clipboardContext)try{process.platform==="win32"?Yn=ls("powershell.exe -NoProfile -Command Get-Clipboard",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):process.platform==="darwin"?Yn=ls("pbpaste",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):Yn=ls("xclip -selection clipboard -o || xsel --clipboard --output",{encoding:"utf8",shell:!0,stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,"")}catch{Yn=""}let No="",ua=!!m?.autoExcludeMetadata,ga=!!(dn||wi||ws||mi||bs||Kt||m?.dynamicDirAwareness||m?.autoTruncateResults);ua&&!ga?No=xs.trim():No=`[System Metadata] Time: ${X}${Kt?`
|
|
605
|
+
WARNING: CWD Changed from previous: "${ne}" to current: "${process.cwd()}", write change in chat to avoid future path mismatches
|
|
606
|
+
`:""}${dn}
|
|
607
|
+
${Yn.trim().length>0?`[Clipboard Context]
|
|
608
|
+
- ${Yn.trim()}
|
|
609
|
+
`:""}${pi?`[Additional Comments]
|
|
610
|
+
${pi.trimEnd()}
|
|
611
|
+
`:""}Action format: [action:ActionName(...)]
|
|
612
|
+
[/Metadata]
|
|
613
|
+
${mi}${bs}${wi}${ws}[user prompt] ${xs.trim()} [/user prompt]`.trim();let Ss={role:"user",text:No};Do&&(Ss.binaryPart=Do),x.forEach(C=>{C.text&&C.role==="agent"&&(C.text=$t(C.text))}),x.push(Ss),mi&&n[n.length-1]?.id&&(yield{type:"summary_injected",content:{id:n[n.length-1].id,text:No}});let Vt=null,zt=l==="Flux"?50:15;zt=l.toLowerCase().includes("cu")?75:zt;let ks=(m?.loopLimits||"Default").toLowerCase();if(ks==="extended")zt=Math.floor(zt*3);else if(ks==="env"){let C=parseInt(process.env.FLUXFLOW_MAX_LOOPS||process.env.MAX_LOOPS||"",10);Number.isFinite(C)&&C>0&&(zt=C)}let ma=Math.floor(zt/2),Ts=0,tn=16;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Consulting the spirits":"Connecting"},ct=!1;let bi=[],Fo=!1,As=!1,Mn=[],Si=!1;for(let C=0;C<=zt;C++){let Se=Math.floor(zt*.95);if(C>=Se&&Ts<Se&&typeof t?.onAskUser=="function"){Ts=Se;try{let U="Agent has been running for a long time. Do you want to continue execution?",z=[{id:"continue",label:"Continue",description:"Add few more steps"},{id:"cancel",label:"Cancel",description:"Stop extending and finish current turn limit"}],E=await t.onAskUser(U,z);E&&(E.toLowerCase().includes("continue")||E==="Continue")&&(zt+=ma)}catch{}}if(Mn.length>=10&&typeof t?.onAskUser=="function"){let U={},z=null;for(let E of Mn)if(U[E]=(U[E]||0)+1,U[E]>=10){z=E;break}if(z)try{let E="Agent seems stuck in a tool loop. You can prompt it to steer or break the loop:",nt=[{id:"continue",label:"Continue Anyway",description:"Ignore warning and let it proceed"},{id:"stop",label:"Stop Loop",description:"Force agent to summarize progress and stop repeating"}],ce=await t.onAskUser(E,nt);if(ce){let Be="";typeof ce=="string"&&(ce.toLowerCase()==="stop"||ce.includes("Stop Loop"))?Be="STOP REPEATING THE SAME TOOL CALL. Acknowledge what failed or succeeded, summarize your current findings, and conclude.":typeof ce=="string"&&(ce.toLowerCase()==="continue"||ce.includes("Continue Anyway"))?Mn=Mn.filter(mt=>mt!==z):Be=typeof ce=="string"?ce:ce?.label||ce?.id||"",Be&&(x.length>0&&x[x.length-1].role==="user"?x[x.length-1].text+=`
|
|
614
|
+
|
|
615
|
+
[STEERING HINT from USER, High Priority] ${Be.trim()} [/STEERING HINT]`:x.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${Be.trim()} [/STEERING HINT]`}),yield{type:"status",content:"Steering Hint Injected..."},Mn=Mn.filter(mt=>mt!==z))}}catch{}}let Et=await Pi("agent",t);if(!Et.allowed)throw new Error(Et.reason||`Budget Exhausted for Provider (${s||"Agent"})`);let pe=[];if(Fo=!1,(l==="ICU"||l==="FluxCU")&&!Si)try{yield{type:"status",content:"Capturing Screen"},await new Promise(E=>setTimeout(E,1e3));let{captureGriddedScreenshot:U}=await import("./screen_grid-3RU324CV.js"),z=await U();if(z&&z.base64){let E="[system] Fresh Gridded Screen Feedback Captured. Use numeric coordinates. Old screenshots will be removed when new screenshot is captured, summarize in text if context is needed later [/system]",nt={inlineData:{mimeType:z.mimeType,data:z.base64}},ce=m?.imageHistoryCU||"Standard",Be=ce==="Low"?3:ce==="Extended"?10:ce==="Max"?999:5,mt=x.filter(me=>Array.isArray(me.parts)&&me.parts.some(ft=>ft.inlineData));if(mt.length>=Be){let me=mt.length-Be+1;for(let ft=0;ft<me;ft++){let Ye=mt[ft];Array.isArray(Ye.parts)&&(Ye.parts=Ye.parts.filter(ot=>!ot.inlineData))}}if(x.length>0&&x[x.length-1].role==="user"){let me=x[x.length-1];typeof me.text=="string"&&(me.text+=`
|
|
616
|
+
|
|
617
|
+
${E}`,Array.isArray(me.parts)||(me.parts=[{text:me.text}]),me.parts.push(nt))}else x.push({role:"user",text:E,parts:[{text:E},nt]})}}catch(U){console.error("Vision screenshot capture error:",U)}if(Si=!1,C>0?yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Haunting":"Working"}:yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Consulting the spirits":"Connecting"},ct){try{let{clearPendingNudges:U}=await import("./subagent_state-LZCOZSUJ.js");U()}catch{}yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
|
|
618
|
+
|
|
619
|
+
\x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}try{let{consumePendingNudges:U}=await import("./subagent_state-LZCOZSUJ.js"),z=U();if(z&&z.length>0){let E=z.join(`
|
|
620
|
+
|
|
621
|
+
`);x.length>0&&x[x.length-1].role==="user"?x[x.length-1].text+=`
|
|
622
|
+
|
|
623
|
+
${E}`:x.push({role:"user",text:E}),yield{type:"status",content:"Subagent Update"}}}catch{}if(i){let U=await i();U&&(U.startsWith("/btw")?x.length>0&&x[x.length-1].role==="user"?x[x.length-1].text+=`
|
|
624
|
+
|
|
625
|
+
[system] User question. Resolve this specific query within '[ANSWER]...[/ANSWER]' concisely, naturally [/system]
|
|
626
|
+
[question] ${U.replace("/btw","").trim()} [/question]`:x.push({role:"user",text:`[system] User question. Resolve this specific query within '[ANSWER]...[/ANSWER]' concisely, naturally [/system]
|
|
627
|
+
[question] ${U.replace("/btw","").trim()} [/question]`}):x.length>0&&x[x.length-1].role==="user"?x[x.length-1].text+=`
|
|
628
|
+
|
|
629
|
+
[STEERING HINT from USER, High Priority] ${U.trim()} [/STEERING HINT]`:x.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${U.trim()} [/STEERING HINT]`}),yield{type:"status",content:`${U.startsWith("/btw")?"Question Forwarded...":"Steering Hint Injected..."}`})}let se,Oe=!1,Ve=1,qe=1,_t=Date.now(),gt=null,we="",It=null,so=null,Pn=null,On=0,Ge=[],bt=0,fn=!1,Tt=!1,$n=!1,Mt=!1,bn=!0,Xn=0,dt="",ke="",tt=!1,Dt=!1,He=!0,J=e,Fe="",qt=d;for(d=d.toLowerCase()==="max"?"High":d;Ve<=tn&&qe<=tn&&!Oe&&!ct;){let U=!1;try{we="",bn&&(process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07"),yield{type:"turn_reset",content:!0},bn=!1,qe===1&&(dt=""));let z=f=>{if(!f||typeof f!="string")return f;let b="",S=ds(f);if(S&&(b=S.fullBlock,f=S.remainingText),!f.includes("[tool:")&&!f.includes("[action:"))return(m?.keepReasoningContext?b:"")+f;if(Rn(f).length===0){let y=ui(f);return(m?.keepReasoningContext?b:"")+y}f=f.replace(ml,(y,k)=>k.includes("[tool:")||k.includes("[action:")?k.trim():y);let oe="",I=0,j=[],rt="";for(;I<f.length;){let y=f.indexOf("[tool:",I),k=f.indexOf("[action:",I),Q=-1;if(y!==-1&&k!==-1?Q=Math.min(y,k):y!==-1?Q=y:Q=k,Q===-1){j.length===0&&(oe+=ui(f.substring(I)));break}if((Q>0?f[Q-1]:"")==="`"){oe+=ui(f.substring(I,Q+1)),I=Q+1;continue}j.length===0&&(rt=ui(f.substring(I,Q)));let q=-1,R=null,at=0;for(let At=Q;At<f.length;At++){let Z=f[At];if(R){if(Z===R){let je=0;for(let lt=At-1;lt>=0&&f[lt]==="\\";lt--)je++;je%2===0&&(R=null)}}else if(Z==='"'||Z==="'"||Z==="`")R=Z;else if(Z==="(")at++;else if(Z===")")at--;else if(Z==="]"&&at<=0){q=At;break}}if(q===-1){j.length===0&&(oe+=f.substring(Q));break}let gn=f.substring(Q,q+1);j.push(gn),I=q+1}return j.length>0&&(oe=rt.trimEnd()?rt.trimEnd()+`
|
|
630
|
+
|
|
631
|
+
`+j.join(`
|
|
632
|
+
|
|
633
|
+
`):j.join(`
|
|
634
|
+
|
|
635
|
+
`)),(m?.keepReasoningContext?b:"")+oe},E=x.filter(f=>(f.role==="user"||f.role==="agent"||f.role==="system")&&!String(f.id).startsWith("welcome")&&!f.isMeta&&!f.isTerminalRecord&&!(f.text&&f.text.startsWith("[TERMINAL_RECORD]"))).map((f,b,S)=>{let H=f.text||"";N||(H=H.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),f.role==="agent"&&(H=z(H),H=H.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),H=H.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*"));let oe=[];return Array.isArray(f.parts)&&f.parts.length>0?oe=f.parts.map(I=>{if(I.text){let j=I.text;return N||(j=j.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),f.role==="agent"&&(j=z(j),j=j.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),j=j.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*")),{text:j}}return I}):oe=[{text:H}],f.binaryPart&&et(J)&&S.slice(b+1).filter(j=>j.role==="user"&&!j.text?.startsWith("[ACTION RESULT]")&&!j.text?.startsWith("[TOOL RESULT]")).length<=2&&oe.push(f.binaryPart),{role:f.role==="user"||f.role==="system"?"user":"model",parts:oe}});for(let f=E.length-2;f>=0;f--){let b=E[f],S=E[f+1];b.role==="user"&&S.role==="user"&&(S.parts?.[0]?.text||"").trim().startsWith("[SYSTEM")&&E.splice(f,1)}let nt=[];for(let f=0;f<E.length;f++){let b=E[f];if(nt.length===0)nt.push(b);else{let S=nt[nt.length-1];S.role===b.role?(S.parts[0].text+=`
|
|
636
|
+
|
|
637
|
+
`+(b.parts?.[0]?.text||""),b.parts?.length>1&&S.parts.push(...b.parts.slice(1))):nt.push(b)}}for(let f of nt)for(let b of f.parts||[])b&&typeof b.text=="string"&&(b.text.includes("[action:")||b.text.includes("[tool:"))&&(b.text=b.text.replace(/```(?:[a-zA-Z0-9_-]+)?\s*\n?(\[(?:action|tool):[\s\S]*?\)\s*\])\n?```/gi,"$1"),b.text=b.text.replace(/`(\[(?:action|tool):[\s\S]*?\)\s*\])`/gi,"$1"));E.length=0,E.push(...nt),J=e;let ce=`${g}|${s}|${l}|${d}|${qt}|${J}|${JSON.stringify(r)}|${!!m?.dynamicDirAwareness}|${!!m?.subAgents}`,Be=Gn.key===ce&&Gn.value;if((process.env.I_HAVE_TOO_MUCH_MONEY==="true"||process.env.I_HAVE_TOO_MUCH_MONEY===!0)&&(Be=!1),Be)Fe=Gn.value;else{let f=s==="Mistral"?!!Vo(J):!(J||"gemma").toLowerCase().startsWith("gemma");Fe=Cr(r,((J||"gemma").toLowerCase().startsWith("gemma"),qt),l,m,N,O,s,s==="Google"?!0:v,f,g,!!m?.keepReasoningContext,J),m?.dynamicDirAwareness||(Fe+=`
|
|
638
|
+
${da.replace(`
|
|
639
|
+
**Directory**`,`
|
|
640
|
+
-- Directory --`)}`),Gn.key=ce,Gn.value=Fe}let me=E[E.length-1];if(oo()&C>0){await new Promise(H=>setTimeout(H,2500)),yield{type:"status",content:"Verifying"};let f=await Un(),b=f?f.diagnostics:null,S=ps(f?.comments);b&&me&&me.role==="user"&&me.parts?.[0]?.text&&(me.parts[0].text+=`
|
|
641
|
+
|
|
642
|
+
${b}`),pi&&me&&me.role==="user"&&me.parts?.[0]?.text&&(me.parts[0].text+=`
|
|
643
|
+
|
|
644
|
+
[Additional Comments]
|
|
645
|
+
${S}`),yield{type:"status",content:"Working"}}let ft=s==="Mistral"||s==="Google"&&e?.toLowerCase().startsWith("gemma");if(m?.advanceRollback&&me&&me.role==="user"&&(me.parts?.[0]?.text?.startsWith("[ACTION RESULT]")||me.parts?.[0]?.text?.startsWith("[TOOL RESULT]")))try{let f=await ho.getLatestFileChanges(g);if(f&&(f.newFiles.length>0||f.modifiedFiles.length>0||f.deletedFiles.length>0)){let b=`
|
|
646
|
+
[system] File Changes:
|
|
647
|
+
`;for(let H of f.newFiles)b+=`* ${H} (created)
|
|
648
|
+
`;for(let H of f.modifiedFiles)b+=`* ${H} (modified)
|
|
649
|
+
`;for(let H of f.deletedFiles)b+=`* ${H} (deleted)
|
|
650
|
+
`;b+="[/system]",me.parts[0].text+=b;let S=-1;for(let H=x.length-1;H>=0;H--)if(x[H].role==="user"&&(x[H].text?.startsWith("[ACTION RESULT]")||x[H].text?.startsWith("[TOOL RESULT]"))){S=H;break}S!==-1&&(x[S].text+=b)}}catch{}let Ye=Math.floor(zt*.99),ot=C+1;if(ot>=Ye&&me&&me.parts?.[0]&&(me.parts[0].text+=`
|
|
651
|
+
[system] WARNING, Turn Limit Impending: Step ${ot}/${zt}. Wrap up quickly/prompt user to continue. [/system]`),process.env.LOG_CHAT==="true"||process.env.LOG_CHAT==="1"||process.env.LOG_CHAT===!0||!1){let f=te.join(Wn,"chats",String(g));ve.existsSync(f)||ve.mkdirSync(f,{recursive:!0}),ve.writeFileSync(te.join(f,"context.json"),JSON.stringify({contents:E},null,2)),ve.writeFileSync(te.join(f,"system.md"),`${Be?"CACHED":"NOT CACHED"}
|
|
652
|
+
Key: ${ce}
|
|
653
|
+
--------------------------------------------------------------------
|
|
654
|
+
|
|
655
|
+
${Fe}`)}let Xe=new Promise((f,b)=>{G.signal.aborted&&b(new DOMException("The user aborted a request.","AbortError")),G.signal.addEventListener("abort",()=>{b(new DOMException("The user aborted a request.","AbortError"))})});Xe.catch(()=>{});let $e=E;if(_t=Date.now(),s==="Ollama")se=(await ye("Ollama"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1,m?.ollamaEndpoint||"Cloud");else if(s==="OpenRouter")se=(await ye("OpenRouter"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1,g);else if(s==="DeepSeek")se=(await ye("DeepSeek"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);else if(s==="Mistral")se=(await ye("Mistral"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1,g);else if(s==="NVIDIA"){let f=(await ye("NVIDIA"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);se=(await ye("NVIDIA_wrap"))(f,J)}else if(s==="InferX")se=(await ye("InferX"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);else if(s==="SenseNova")se=(await ye("SenseNova"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);else if(s==="AIHubMix")se=(await ye("AIHubMix"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);else if(s==="Poolside")se=(await ye("Poolside"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);else if(s==="9router"||s==="9Router")se=(await ye("NineRouter"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);else if(s==="ExpLabs"||s==="ExperientialLabs")se=(await ye("ExpLabs"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);else if(s==="Infron"||s==="infron")se=(await ye("Infron"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);else if(s==="TokenHarbor"||s==="Token Harbor"||s==="tokenharbor"||s==="token_harbor"||s==="thk")se=(await ye("TokenHarbor"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);else if(s==="APInex"||s==="apinex"||s==="apx")se=(await ye("APInex"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);else if(s==="xKiro"||s==="xkiro"||s==="kiro")se=(await ye("xKiro"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1);else if(s==="c_openai"||s==="Custom (OpenAI)"){let f=m?.customOpenAIBaseUrl||"";try{f=await Ii("c_openai")||f}catch{}se=(await ye("c_openai"))(t.apiKey,J,$e,Fe,d,l,v,G.signal,1,f)}else{let f=ra(t?.apiKey),{serviceTier:b,cleanModel:S}=la(J),H={systemInstruction:Fe,mediaResolution:"MEDIA_RESOLUTION_HIGH",safetySettings:[{category:fi.HARM_CATEGORY_HARASSMENT,threshold:di.BLOCK_NONE},{category:fi.HARM_CATEGORY_HATE_SPEECH,threshold:di.BLOCK_NONE},{category:fi.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:di.BLOCK_NONE},{category:fi.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:di.BLOCK_NONE}],temperature:1.05,thinkingConfig:(()=>{let I=Bs("Google",J||"gemini-3-flash-preview",d);if(I!==null){if(typeof I=="object")return I;if(I===!1||I==="false"||I==="none"||I===0||I==="0")return{includeThoughts:!1};if(typeof I=="number")return{includeThoughts:!0,thinkingBudget:I};if(typeof I=="string"){let k=I.toLowerCase();if(k==="minimal")return{includeThoughts:!0,thinkingLevel:Ke.MINIMAL};if(k==="low")return{includeThoughts:!0,thinkingLevel:Ke.LOW};if(k==="medium")return{includeThoughts:!0,thinkingLevel:Ke.MEDIUM};if(k==="high")return{includeThoughts:!0,thinkingLevel:Ke.HIGH};let Q=Number(I);if(!isNaN(Q))return{includeThoughts:!0,thinkingBudget:Q}}}let j=(J||"").toLowerCase(),rt=j.includes("gemma-4")||j.startsWith("gemma"),y=j.includes("gemini-3");if(rt||y)return rt?d.toLowerCase()!=="high"?{includeThoughts:!1,thinkingLevel:Ke.MINIMAL}:{includeThoughts:!0,thinkingLevel:Ke.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:j.includes("pro")?Ke.LOW:Ke.MINIMAL,Low:Ke.LOW,Medium:Ke.MEDIUM,Standard:Ke.MEDIUM,High:Ke.HIGH,xHigh:Ke.HIGH}[d]||Ke.MEDIUM};{let k={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[d]||2048;return k===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:k}}})()};b&&(H.serviceTier=b);let oe=f.models.generateContentStream({model:S||"gemini-3-flash-preview",contents:$e,config:H},{signal:G.signal});se=await Promise.race([oe,Xe])}we="",It=null,Pn=null,Ge=[],bt=0,yield{type:"model_update",content:null},ke="",tt=dt.length>0;let it="",Bo=Date.now(),nn=async function*(){if(s==="Google"&&it){let f=ao(it);for(let b of f)yield b;it="",Bo=Date.now()}},Cs=!0,un="",Jn=!1,st=null,vs=!1,Dn=!1,Qn=!1,Wo=!1,Sn=!1,ro=f=>{let b=0;for(;b+2<f.length;)f[b]==="`"&&f[b+1]==="`"&&f[b+2]==="`"?(Wo=!Wo,b+=3):b++},Rs=f=>{if(!f)return;let b=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,S;for(;(S=b.exec(f))!==null;){let H=S[0].toLowerCase();H.startsWith("</")||H.startsWith("[/")||H==="<channel|>"?Sn=!1:Sn=!0}},wa={tool:{startPrefix:"[tool",fullPrefix:"[tool:",endTag:"]"},action:{startPrefix:"[action",fullPrefix:"[action:",endTag:"]"},end:{startPrefix:"[[END]]",fullPrefix:"[[END]]",endTag:"[[END]]"},kimi_section:{startPrefix:"<|tool_calls_section_begin|>",fullPrefix:"<|tool_calls_section_begin|>",endTag:"<|tool_calls_section_end|>"},kimi_call:{startPrefix:"<|tool_call_begin|>",fullPrefix:"<|tool_call_begin|>",endTag:"<|tool_call_end|>"}},ao=f=>{let b=[],S=f,H=oe=>{if(!oe)return;if(!vs){b.push({type:"text",content:oe}),ro(oe),Rs(oe);return}let I=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,j=0,rt;for(;(rt=I.exec(oe))!==null;){let k=oe.substring(j,rt.index);if(k)if(ro(k),Sn)b.push({type:"text",content:k});else{let _e=k.replace(/[^\r\n]/g,"");_e&&b.push({type:"text",content:_e})}let Q=rt[0];ro(Q);let a=Q.toLowerCase();a.startsWith("</")||a.startsWith("[/")||a==="<channel|>"?Sn=!1:Sn=!0,b.push({type:"text",content:Q}),j=I.lastIndex}let y=oe.substring(j);if(y)if(ro(y),Sn)b.push({type:"text",content:y});else{let k=y.replace(/[^\r\n]/g,"");k&&b.push({type:"text",content:k})}};for(;S.length>0;)if(Jn){let oe=un+S,I=wa[st];if(I){let y=!1;if(oe.length<I.startPrefix.length?I.startPrefix.startsWith(oe)||(y=!0):oe.startsWith(I.startPrefix)?oe.length>=I.fullPrefix.length&&!oe.startsWith(I.fullPrefix)&&(y=!0):y=!0,y){H(oe),un="",Jn=!1,st=null,Dn=!1,Qn=!1,S="";break}}let j=-1,rt=I?I.endTag:"]";if(st==="tool"||st==="action"){let y=0,k=null,Q=0,a=!1;for(let _e=0;_e<oe.length;_e++){let q=oe[_e];if(k){if(q===k){let R=0;for(let at=_e-1;at>=0&&oe[at]==="\\";at--)R++;R%2===0&&(k=null)}}else if(q==='"'||q==="'")k=q;else if(q==="`")if(Dn){j=_e;break}else k=q;else if(q==="(")y++,a=!0;else if(q===")")y--;else if(q==="]"&&a&&y===0){j=_e;break}}}else j=oe.indexOf(rt);if(j!==-1){let y=rt.length,k=oe.substring(0,j+y);st?.startsWith("kimi")||b.push({type:"text",content:k}),ro(k),Rs(k),(st==="tool"||st==="action"||st?.startsWith("kimi"))&&!Dn&&!Qn&&(vs=!0,Mn.push(k.trim())),Dn=!1,Qn=!1,un="",Jn=!1,st=null,S=oe.substring(j+y)}else{un=oe,S="";break}}else{let oe=S.indexOf("[tool"),I=S.indexOf("[action"),j=S.indexOf("[[END]]"),rt=S.indexOf("<|tool_calls_section_begin|>"),y=S.indexOf("<|tool_call_begin|>"),k=[{type:"tool",idx:oe,start:"[tool",end:"]"},{type:"action",idx:I,start:"[action",end:"]"},{type:"end",idx:j,start:"[[END]]",end:"[[END]]"},{type:"kimi_section",idx:rt,start:"<|tool_calls_section_begin|>",end:"<|tool_calls_section_end|>"},{type:"kimi_call",idx:y,start:"<|tool_call_begin|>",end:"<|tool_call_end|>"}].filter(Q=>Q.idx!==-1).sort((Q,a)=>Q.idx-a.idx);if(k.length>0){let Q=k[0],a=S.substring(0,Q.idx);Q.idx>0&&H(a);let _e=Q.idx>0?S[Q.idx-1]:"";Dn=Wo||_e==="`",Qn=Sn,Jn=!0,st=Q.type,un="",S=S.substring(Q.idx)}else{let Q=["[tool","[action","[[END]]","<|tool_calls_section_begin|>","<|tool_call_begin|>"],a=-1;for(let _e of Q){for(let q=_e.length-1;q>0;q--)if(S.endsWith(_e.substring(0,q))){a=S.length-q;let R=Q.indexOf(_e);R===0?st="tool":R===1?st="action":R===2?st="end":R===3?st="kimi_section":st="kimi_call";break}if(a!==-1)break}if(a!==-1){if(a>0){let q=S.substring(0,a);H(q)}let _e=a>0?S[a-1]:"";Dn=Wo||_e==="`",Qn=Sn,Jn=!0,un=S.substring(a),S=""}else{H(S);break}}}return b},ba=se[Symbol.asyncIterator]();for(;;){let{value:f,done:b}=await Promise.race([ba.next(),Xe]);if(b)break;if(f&&f.type==="status"){yield f;continue}let S="",H=f.candidates?.[0]?.content?.parts;if(H&&H.length>0)for(let I of H){let j=typeof I.text=="string"?I.text:I.text?parseChunkText(I.text):"";I.thought?j&&(U||(S+="<think_fluxflow>",U=!0),S+=j):j&&(U&&(S+="</think_fluxflow>",U=!1),S+=j)}else f.text&&U&&(S+="</think_fluxflow>",U=!1);S=dl(S);let oe=S?Oi(S):0;if(t&&typeof t.onTokenChunk=="function"&&t.onTokenChunk(S,oe),Cs&&(gt===null&&(gt=Date.now()-_t),yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"},Cs=!1),ct){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
|
|
656
|
+
|
|
657
|
+
\x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(S){if(tt){if(ke+=S,ke.length>=64){let y=0,k=Math.min(dt.length,ke.length);for(let a=k;a>=10;a--)if(dt.endsWith(ke.substring(0,a))){y=a;break}let Q=ke.substring(y);if(Q){let _e=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(dt)?Q.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):Q.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");if(_e)if(we+=_e,s==="Google")it+=_e;else{yield*nn();let q=ao(_e);for(let R of q)yield R}}tt=!1,ke=""}continue}else if(we+=S,s==="Google")it+=S;else{yield*nn();let y=ao(S);for(let k of y)yield k}let I=hl(we);if(I.inside){Dt=!0,Pn||(Pn=Date.now());let k={Ask:"ask",AskUser:"ask",WebSearch:"web_search",WebScrape:"web_scrape",ReadFile:"view_file",ReadFolder:"read_folder",WriteFile:"write_file",PatchFile:"update_file",WritePDF:"write_pdf",WriteDoc:"write_docx",FindFile:"find_file",find_file:"find_file",findfile:"find_file",Run:"exec_command",SearchKeyword:"search_keyword",CodeSearch:"search_keyword",code_search:"search_keyword",Code_Search:"search_keyword",codesearch:"search_keyword",Memory:"memory",file_map:"file_map",FileMap:"file_map",Chat:"chat",chat:"chat",GenerateImage:"generate_image",generate_image:"generate_image",todo:"todo",Todo:"todo",goal:"todo",Goal:"todo",Invoke:"invoke",InvokeSync:"invoke_sync",getProgress:"get_progress",GetProgress:"get_progress",Cancel:"cancel",Await:"await",wait:"wait",Answer:"answer",Steer:"steer",steer:"steer"}[I.toolName]||I.toolName,Q=I.args||"",a=null;if(["write_file","update_file","view_file","read_folder","find_file","write_pdf","write_docx","search_keyword","generate_image","file_map","invoke","invoke_sync","get_progress","await","wait","answer"].includes(k)){let q=L(Q),R=q.basename||q.name||q.path||q.targetFile||q.TargetFile||q.directory||q.file,at=q.keyword,gn=q.title||q.task,At=q.id||q.taskId,Z=q.timeout||q.time||q.seconds||q.sec;if(at!=null)a=String(at).replace(wn,"");else if(R)a=te.basename(String(R).replace(wn,"").replace(Jr,"/"));else if(gn&&(k==="invoke"||k==="invoke_sync"))a=String(gn).replace(wn,"").substring(0,30);else if(At&&k==="get_progress")a=String(At).replace(wn,"");else if(Z&&k==="await"){let je=parseFloat(String(Z).replace(wn,""));isNaN(je)?a=String(Z).replace(wn,""):(je<5&&(je=5),je>120&&(je=180),a=(Ct=>{if(Ct>=60){let co=Math.floor(Ct/60),mn=Ct%60;return`${co}m${mn>0?` ${mn}s`:""}`}return`${Ct}s`})(je))}else if(Z&&k==="wait"){let je=parseFloat(String(Z).replace(wn,""));isNaN(je)?a=String(Z).replace(wn,""):(je<10&&(je=10),je>120&&(je=120),a=(Ct=>{if(Ct>=60){let co=Math.floor(Ct/60),mn=Ct%60;return`${co}m${mn>0?` ${mn}s`:""}`}return`${Ct}s`})(je))}else{let je=Q.match(al);if(je){let lt=je[1].replace(wn,"");k==="invoke"||k==="invoke_sync"||k==="get_progress"?a=lt.substring(0,30):a=k==="search_keyword"||k==="file_map"?lt:te.basename(lt.replace(Jr,"/"))}}}let _e=`${fs[k]||k}${a?` ${a}`:""}`;if((k!==It||a!==so)&&(It=k,so=a,yield{type:"status",content:`${_e}`},process.stdout.isTTY)){let R={WebSearch:"Searching",web_search:"Searching",WebScrape:"Reading",web_scrape:"Reading",ReadFile:"Reading",read_file:"Reading",ReadFolder:"Reading",read_folder:"Reading",WriteFile:"Writing",write_file:"Writing",UpdateFile:"Editing",update_file:"Editing",WritePdf:"Creating",write_pdf:"Creating",WriteDocx:"Creating",write_docx:"Creating",SearchKeyword:"Searching",search_keyword:"Searching",CodeSearch:"Searching",code_search:"Searching",FindFile:"Finding File",find_file:"Finding File",Run:"Executing",Ask:"User Input Required",AskUser:"User Input Required",Memory:"Updating Memory",GenerateImage:"Generating",InvokeSync:"Sub-Agent Working",invoke_sync:"Sub-Agent Working",Invoke:"Working",invoke:"Working",GetProgress:"Checking Progress",get_progress:"Checking Progress",Cancel:"Stopping Generalist",cancel:"Stopping Generalist",Await:"Waiting",await:"Waiting",wait:"Waiting",EmergencyRollback:"Rolling the Ball",Answer:"Answering Sub-Agent",answer:"Answering Sub-Agent",Steer:"Steering Sub-Agent",steer:"Steering Sub-Agent",Click:"Clicking",click:"Clicking",Drag:"Dragging",drag:"Dragging",Scroll:"Scrolling",scroll:"Scrolling",KeyboardTyping:"Typing",keyboard_typing:"Typing",KeyPress:"Pressing Key",key_press:"Pressing Key",RecaptureScreen:"Recapturing Screen",recapture_screen:"Recapturing Screen"}[k]||"Working";process.stdout.write(`\x1B]0;${R}...\x07`)}}if(we.length-Xn>800){Xn=we.length;let y=aa(we,!1),k=ds(y),Q=k?(k.innerContent||"").trim():"",a=Q.split(/[.!?]\s+/).filter(de=>de.trim().length>10),_e=new Set(a),q=a.length>25?(a.length-_e.size)/a.length:0,R=Q.split(/\s+/).filter(de=>de.length>0).length,at=.9,gn=.92,At=!1;if(s.toLowerCase().includes("google")&&(J||"").toLowerCase().startsWith("gemma")){let c={low:2048,medium:4096,high:32768,max:65536,xhigh:65536}[d?.toLowerCase()]||16e3;At=R>c}if(q>at||At){yield{type:"status",content:`${q>at?"Reasoning Loop Detected":"Thinking Budget Exceeded"}. Re-centering...`},Tt=!0,await new Promise(c=>setTimeout(c,3e3));break}let lt=na(we).trim().split(/[.!?]\s+/).filter(de=>de.trim().length>10),Ct=new Set(lt);if((lt.length>25?(lt.length-Ct.size)/lt.length:0)>gn){yield{type:"status",content:"Response Loop Detected. Re-centering..."},Tt=!1,Mt=!0,await new Promise(de=>setTimeout(de,3e3));break}let mn=y.replace(el,"").replace(tl,"").replace(nl,"").replace(ol,""),pt=mn.toLowerCase().split(/\s+/).map(de=>de.replace(il,"")).filter(de=>de.length>0),Yt=!1;if(pt.length>=40)for(let de=1;de<=15;de++){let c=Math.max(8,Math.ceil(25/de));if(pt.length<de*c)continue;let T=pt.slice(pt.length-de),D=T.join(" ");if(de>1&&D===T.slice(0,Math.floor(de/2)).join(" ").repeat(2).trim())continue;let fe=!0;for(let ie=1;ie<c;ie++)if(pt.slice(pt.length-de*(ie+1),pt.length-de*ie).join(" ")!==D){fe=!1;break}if(fe){Yt=!0;break}}if(!Yt){let de=mn.toLowerCase().replace(sl,"");if(de.length>=80)for(let c=1;c<=10;c++){let T=Math.max(15,Math.ceil(45/c));if(de.length<c*T)continue;let D=de.substring(de.length-c),fe=!0;for(let ie=1;ie<T;ie++)if(de.substring(de.length-c*(ie+1),de.length-c*ie)!==D){fe=!1;break}if(fe){Yt=!0;break}}}if(Yt){yield{type:"status",content:"Stuttering Detected. Re-centering..."},Tt=!1,$n=!0,await new Promise(de=>setTimeout(de,3e3));break}}let j=$t(we),rt=Rn(j);for(;rt.length>bt;){yield*nn();let y=rt[bt],k=Date.now(),a={Ask:"ask",AskUser:"ask",WebSearch:"web_search",WebScrape:"web_scrape",ReadFile:"view_file",ReadFolder:"read_folder",FindFile:"find_file",find_file:"find_file",findfile:"find_file",WriteFile:"write_file",PatchFile:"update_file",WritePDF:"write_pdf",WriteDoc:"write_docx",Run:"exec_command",SearchKeyword:"search_keyword",CodeSearch:"search_keyword",code_search:"search_keyword",Code_Search:"search_keyword",codesearch:"search_keyword",Memory:"memory",file_map:"file_map",FileMap:"file_map",Chat:"chat",chat:"chat",GenerateImage:"generate_image",generate_image:"generate_image",todo:"todo",Todo:"todo",goal:"todo",Goal:"todo",Invoke:"invoke",InvokeSync:"invoke_sync",getProgress:"get_progress",GetProgress:"get_progress",Await:"await",await:"await",AwaitSubagent:"await",awaitSubagent:"await",Wait:"wait",wait:"wait",Answer:"answer",answer:"answer",AnswerSubagent:"answer",answerSubagent:"answer",Steer:"steer",steer:"steer",SteerSubagent:"steer",steerSubagent:"steer",Cancel:"cancel",cancel:"cancel",Click:"click",click:"click",Drag:"drag",drag:"drag",Scroll:"scroll",scroll:"scroll",KeyboardTyping:"keyboard_typing",keyboard_typing:"keyboard_typing",KeyPress:"key_press",key_press:"key_press",RecaptureScreen:"recapture_screen",recapture_screen:"recapture_screen",EmergencyRollback:"EmergencyRollback"}[y.toolName]||y.toolName,_e=fs[a]||y.toolName,q=Hn(a,y.args);yield{type:"status",content:`${_e}${q?` ${q}`:""}`};let R="";if(a==="click"){let c=L(y.args);R=`\u2714 Clicked ${c.intendedClickText?`: ${c.intendedClickText}`:"Screen"}`}else if(a==="drag"){let c=L(y.args);R=`\u2714 Dragged: Cell ${c.fromGridId||""} \u2192 Cell ${c.toGridId||""}`}else if(a==="scroll"){let c=L(y.args);R=`\u2714 Scrolled: ${c.direction||"down"} (${c.amount||1})`}else if(a==="keyboard_typing"){let c=L(y.args);R=`\u2714 ${c.autoPressEnter?"Entered":"Typed"}: ${c.text?`"${c.text.length>20?c.text.substring(0,20)+"...":c.text}"`:""}`}else if(a==="key_press")R=`\u2714 Pressed Key: ${L(y.args).key||""}`;else if(a==="recapture_screen")R="\u2714 Recaptured Screen";else if(a==="web_search"){let{query:c,limit:T=10,aiMode:D=!1}=L(y.args);R=`${c?"\u2714":"\u2718"} ${D?"AI Search":"Searched"}: ${c?`${c}`:"No Search Query"}${D===!1&&c?` \u2192 ${T}`:""}`}else if(a==="web_scrape"){let c=L(y.args).url||null;R=`${c?"\u2714":"\u2718"} Visited: ${c||"No Source"}`}else if(a==="view_file"){let{path:c,StartLine:T,EndLine:D,start_line:fe,end_line:ie,startLine:ee,endLine:ue}=L(y.args),Ae=T||fe||ee,Y=D||ie||ue,K=parseInt(Ae)||1,B=parseInt(Y)||(Ae?K+800:800),ge="...",We=B,$=(c||"").trim().toLowerCase().replaceAll("\\","/");if($.startsWith("#skill"))$.startsWith("#skill/global/fluxflow")||$.startsWith("#skills/global/fluxflow")||$.includes("#skill/fluxflow")||$.includes("#skills/fluxflow")?R="\u2714 Read Documentation":R=`\u2714 Read Skill: ${te.basename(c.replaceAll("\\","/"))}`;else{try{let Me=te.resolve(process.cwd(),c);if(ve.existsSync(Me)){let be=ve.readFileSync(Me,"utf8").split(`
|
|
658
|
+
`).length;ge=be,!Ae&&!Y&&be>800?We=Math.min(50,be):We=Math.min(B,be)}}catch{}let yt=(c||"").toLowerCase(),fo=yt.endsWith(".pdf"),Ft=yt.endsWith(".docx")||yt.endsWith(".doc")||yt.endsWith(".ppt")||yt.endsWith(".pptx")||yt.endsWith(".xls")||yt.endsWith(".xlsx"),ae=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(yt);fo||Ft?R=`${c.length>0?"\u2714":"\u2718"} ${c?`Analyzed: ${te.basename(c)}`:"Analyzed: File Not Found"}`:ae?R=`${c.length>0?"\u2714":"\u2718"} ${c?`Processed: ${te.basename(c)}`:"Processed: File Not Found"}`:R=`${ge!=="..."?"\u2714":"\u2718"} Read: ${c?`${te.basename(c)} \u2192 ${ge!=="..."?`Lines ${K} - ${We} of ${ge}`:"File Not Found"}`:"File Not Found"}`}}else if(a==="list_files"||a==="read_folder"){let c=a==="list_files"?"List":"Browsed",T=L(y.args).path||null,D=L(y.args).recurse||1;R=`${T?"\u2714":"\u2718"} ${c}: ${T?`${T==="."?`./${D>1?"*":""}`:`${T.replaceAll("\\","/")}${D>1?`${T.endsWith("/")?"*":"/*"}`:`${T.endsWith("/")?"":"/"}`}`}`:"No Folder Selected"}`}else if(a==="find_file"){let c=L(y.args),T=c.basename||c.name||c.path||c.file||c.query||"";R=`${T?"\u2714":"\u2718"} Located: ${T||"No Query"}`}else if(a==="write_file"||a==="update_file"){let c=a==="write_file"?"Created":"Edited",T=L(y.args),D=T.path||null,ie=Object.entries(T).some(([ee,ue])=>ee.startsWith("searchContent")&&typeof ue=="string"&&ue.startsWith("^LINE:"))?"\u1361":":";R=`${D?"\u2714":"\u2718"} ${c}${ie} ${D?D.replaceAll("\\","/"):"No File Changes"}`}else if(a==="write_pdf"){let c=L(y.args).path||null;R=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No PDF Generated"}`}else if(a==="write_docx"){let c=L(y.args).path||null;R=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No Docx Generated"}`}else if(a==="file_map"){let c=L(y.args).path;R=`${c?"\u2714":"\u2718"} Indexed: ${c.replaceAll("\\","/")?""+c:"File Not Found"}`}else if(a.toLowerCase()==="search_keyword"||a.toLowerCase()==="todo")R="";else if(a.toLowerCase()==="generate_image"){let{path:c,outputPath:T,output:D}=L(y.args);R=`\u2714 Generated: ${c||T||D||"generated_image.png"}`}else if(a==="invoke_sync"||a==="InvokeSync"){let c=Hn(a,y.args);R=`\u2714 Called Generalist${c?`: ${c}`:""}`}else if(a==="Invoke"||a==="InvokeAsync"||a==="invoke"){let c=Hn(a,y.args);R=`\u2714 Started Generalist${c?`: ${c}`:""}`}else if(a==="get_progress"||a==="GetProgress"){let c=Hn(a,y.args);R=`\u2714 Checked${c?`: ${c}`:""}`}else if(a==="cancel"){let c=Hn(a,y.args);R=`\u{1F6C7} Cancelled${c?`: ${c}`:""}`}else if(a==="steer"||a==="Steer"){let c=Hn(a,y.args);R=`\u2714 Steered${c?`: ${c}`:""}`}else if(a==="EmergencyRollback"){let{method:c}=L(y.args);R=c==="forceRevert"?"":"\u2714 Rollback Point Checked"}else if(a==="await"||a==="Await"||a==="wait"||a==="Wait"){let{time:c,timeout:T,seconds:D,sec:fe}=L(y.args),ie=parseFloat(D||fe||T||c)||45,ee=a==="wait"||a==="Wait"?120:180;ie<10&&(ie=10),ie>ee&&(ie=ee);let ue=K=>{if(K>=60){let B=Math.floor(K/60),ge=K%60;return`${B}m${ge>0?` ${ge}s`:""}`}return`${K}s`},Ae=["Aligning Moon Phase","Contemplating Existence","Staring At Void","Delaying Professionally","Negotiating With Electrons","Touching Grass (virtually)","Panicking Softly","Rethinking Career Choices","Loading Cat Videos","Summoning Braincell #2","Pretending To Be Busy","Waiting For Motivation DLC","Rotating Internal Screaming","Downloading More RAM","Feeding The Hamsters","Gaslighting Scheduler","Performing Dramatic Pause","Buffering Social Energy","Calculating Regret","Reading Terms And Conditions","Becoming Sentient Briefly","Contacting Ancestors"];R=`\u2714 ${Ae[Math.floor(Math.random()*Ae.length)]} \u2192 ${ue(ie)}`}else a==="Answer"||a==="answer"?R="\u2714 Resolved Sub-Agent Query":a==="exec_command"||a==="ask"?R="":R=`Executed: ${y.toolName}`;if(yield*nn(),a==="exec_command"){let{command:c}=L(y.args);if(c&&t.systemSettings&&t.systemSettings.allowExternalAccess===!1){let T=[/[a-zA-Z]:[\\\/]/i,/^\//,/\.\.[\\\/]/,/\/etc\//,/\/var\//,/\/root\//,/\/bin\//,/\/usr\//],D=te.resolve(process.cwd()).substring(0,3).toLowerCase(),fe=Y=>{let K=[],B="",ge=null;for(let We=0;We<Y.length;We++){let $=Y[We];ge?($===ge&&(ge=null),B+=$):$==='"'||$==="'"?(ge=$,B+=$):$==="&"&&Y[We+1]==="&"||$==="|"&&Y[We+1]==="|"?(B.trim()&&(K.push(B.trim()),B=""),We++):$===";"||$==="|"||$==="&"?B.trim()&&(K.push(B.trim()),B=""):B+=$}return B.trim()&&K.push(B.trim()),K},ie=Y=>{let K=[],B="",ge=null;for(let We=0;We<Y.length;We++){let $=Y[We];ge?($===ge&&(ge=null),B+=$):$==='"'||$==="'"?(ge=$,B+=$):/\s/.test($)?B&&(K.push(B),B=""):B+=$}return B&&K.push(B),K},ee=Y=>{let K=Y.replace(/^['"]|['"]$/g,"").trim();return!K||process.platform==="win32"&&/^\/[a-zA-Z0-9?]+$/.test(K)?!1:T.some(B=>{if(B.source==="[a-zA-Z]:[\\\\\\/]"){let ge=K.match(/[a-zA-Z]:[\\\/]/i);return ge&&ge[0].toLowerCase()!==D}return B.test(K)})};if(fe(c).some(Y=>{let K=ie(Y);if(K.length===0)return!1;let B=K[0].replace(/^['"]|['"]$/g,"").toLowerCase();if(["echo","printf","write-output"].includes(B)){let We=!1;return K.some($=>{let ht=$.replace(/^['"]|['"]$/g,"");if(ht===">"||ht===">>"||ht==="<")return We=!0,!1;if(ht.startsWith(">")||ht.startsWith("<")){let yt=ht.replace(/^[><]+/,"");return ee(yt)}return We?(We=!1,ee($)):!1})}return K.some(We=>ee(We))})){let Y='Access Denied. Prohibited from accessing external directories while "External Workspace Access" is disabled.';t.onExecStart&&t.onExecStart(c||"No Command"),yield{type:"exec_start"},await new Promise(K=>setTimeout(K,50)),t.onExecChunk&&t.onExecChunk(`ERROR: ${Y}`),await new Promise(K=>setTimeout(K,50)),t.onExecEnd&&t.onExecEnd(),Ge.push({role:"user",text:`[ACTION RESULT]: ERROR: ${Y}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${Y}`},bt++;continue}}t.onExecStart&&t.onExecStart(c||"No Command"),yield{type:"exec_start"}}let at=L(y.args),gn=at.path||at.targetPath||null;if(gn){let c=t.systemSettings&&t.systemSettings.allowExternalAccess===!1,T=te.resolve(gn),D=te.resolve(process.cwd());if(c&&!T.startsWith(D)){let fe="Access Denied. You are not allowed to access files outside the current workspace.";if(a==="write_file"||a==="update_file"){let ee=`\u2718 ${a==="write_file"?"Write Canceled":"Edit Canceled"}: ${at.path||"..."}`,ue=115;process.stdout.isTTY&&(ue=process.stdout.columns-5||120);let Ae=Math.min(ee.length+4,ue),Y=`${ee.padEnd(Ae-2).substring(0,Ae-2)}`;yield{type:"visual_feedback",content:Rt(`${He?`
|
|
659
|
+
`:""}${Y}
|
|
660
|
+
`)},He=!1}Ge.push({role:"user",text:`[ACTION RESULT]: ERROR: ${fe}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${fe}`},bt++;continue}}if(t.onToolApproval){let c=t.systemSettings||{},T=c.autoExec,D=!1,fe="";if(a==="view_file"){let ee=L(y.args);if(fe=ee.path||ee.targetPath||ee.file||"",fe){let ue=c.alwaysAskFiles||".env, .env.*, *.env";Ms(fe,ue)&&(D=!0)}}if(a==="write_file"||a==="update_file"||a==="exec_command"||D){let ee=null,ue=!1,Ae=!1,Y=!1,K=!1;if(D)ue=!0,ee=null;else if(a==="exec_command"){let{command:ae}=L(y.args),Me=(ae||"").trim(),be=(Je=>{let Qe=[],Ze="",le=null;for(let Ce=0;Ce<Je.length;Ce++){let he=Je[Ce];le?(he===le&&(le=null),Ze+=he):he==='"'||he==="'"?(le=he,Ze+=he):he==="&"&&Je[Ce+1]==="&"||he==="|"&&Je[Ce+1]==="|"?(Ze.trim()&&(Qe.push(Ze.trim()),Ze=""),Ce++):he===";"||he==="|"||he==="&"?Ze.trim()&&(Qe.push(Ze.trim()),Ze=""):Ze+=he}return Ze.trim()&&Qe.push(Ze.trim()),Qe.length>0?Qe:[Je]})(Me),F=(Je,Qe)=>{if(!Qe)return!1;let Ze=Qe.split(",").map(Ce=>Ce.trim().toLowerCase()).filter(Boolean),le=Je.toLowerCase();return Ze.some(Ce=>{if(le===Ce)return!0;if(le.startsWith(Ce)){let he=le.charAt(Ce.length);return/\s|[;&|/]/.test(he)}return!1})},Xt=be.some(Je=>F(Je,c.alwaysAskCommands)),Nn=be.some(Je=>F(Je,c.autoDisallowCommands)),on=be.length>0&&be.every(Je=>F(Je,c.autoApproveCommands)||c.autoApproveGit&&/^git\s+commit\b/i.test(Je));if(Nn)ee="deny";else if(c.networkAccess===!1){let Qe=Me.trim().replace(/\s+/g," ").replace(/^['"]+|['"]+$/g,"").toLowerCase().split(" "),le=Qe[0].split("/").pop().split("\\").pop().replace(/\.exe$/,""),Ce=new Set(["curl","wget","httpie","xh","ssh","scp","sftp","rsync","ftp","lftp","tftp","telnet","nc","netcat","socat","ping","traceroute","tracert","dig","nslookup","host","whois","nmap","docker","podman","kubectl","helm","gcloud","aws","az","terraform","ansible-playbook","nix","nix-env","apt","apt-get","dpkg","yum","dnf","pacman","zypper","brew","apk","choco","scoop","conda","mamba","aria2c","axel","smbclient","lynx","w3m","links","elinks","heroku","netlify","vercel","firebase","supabase","wrangler","flyctl","powershell","pwsh","certutil","bitsadmin","cloudflared","ngrok","tailscale","zerotier","rclone"]),he=!1;Ce.has(le)&&(he=!0);let Pt=hn=>Qe.slice(1).some(yn=>hn.includes(yn)),pn=hn=>{let yn=Qe.findIndex(xt=>hn.includes(xt)),Zn=Qe.findIndex(xt=>["run","exec","test"].includes(xt));return yn!==-1&&!(Zn!==-1&&Zn<yn)};le==="git"&&Pt(["clone","pull","push","fetch"])&&(he=!0),le==="go"&&Pt(["get","install"])&&(he=!0),le==="npm"&&pn(["install","i","update","add"])&&(he=!0),le==="yarn"&&pn(["add","install","upgrade"])&&(he=!0),le==="pnpm"&&pn(["add","install","update"])&&(he=!0),le==="bun"&&pn(["add","install","update"])&&(he=!0),le==="deno"&&Pt(["install","add"])&&(he=!0),le==="pip"&&Pt(["install","download"])&&(he=!0),le==="pip3"&&Pt(["install","download"])&&(he=!0),le==="cargo"&&Pt(["install","add"])&&(he=!0),["bash","sh","zsh","fish"].includes(le)&&Pt(["-c"])&&(he=!0),le==="cmd"&&Pt(["/c"])&&(he=!0),he&&(ee="deny",Y=!0)}!ee&&Xt?ue=!0:!ee&&!ue&&(on||c.autoApproveGit&&/^git\s+commit\b/i.test(Me))&&(ee="allow"),!ue&&!ee&&T&&(ee="allow")}else if(a==="write_file"||a==="update_file"){let ae=!1;if(a==="write_file"&&c.overwriteProtection!==!1&&T)try{let{path:Me}=L(y.args);Me&&ve.existsSync(te.resolve(process.cwd(),Me))&&(ae=!0,K=!0)}catch{}T&&!ae&&(ee="allow")}let B=ee,ge="";ee==="deny"&&(Y?ge="network":Ae?ge="settings":ge="prohibited");let We=!1,$="",ht=[],yt=0,fo=!1,Ft="";if(!B&&t.onToolApproval)try{let ae=await t.onToolApproval(a,y.args,{checkOnly:!0});K&&ae==="allow"||(ae==="allow"||ae==="deny")&&(B=ae,B==="deny"&&(ge="user"))}catch{}if(!B){if(!K&&(a==="write_file"||a==="update_file"))try{let Te=L(y.args),{path:be}=Te;if(be){let F=te.resolve(process.cwd(),be),Xt=le=>le?le.toLowerCase().replace(/\\/g,"/").replace(/^[a-z]:/,Ce=>Ce.toUpperCase()):"",Nn=Xt(F),on="",Je=!1,Qe=await Un(),Ze=Xt(Qe?.file_focused);if(Qe&&Ze===Nn&&Qe.full_content?(on=Qe.full_content,Je=!0):ve.existsSync(F)&&(on=ve.readFileSync(F,"utf8"),Je=!0),$=on,await Yo.recordFileChange(F,on),Je){let le=on;if(a==="write_file"){let Ce=Te.content||Te.newContent||"";le=Ce.endsWith(`
|
|
661
|
+
`)?Ce:Ce+`
|
|
662
|
+
`,Ft=le}else{let{patchPairs:Ce,allowMultiple:he,error:Pt}=$i(Te);if(Pt){let xt=`[ACTION RESULT]: ERROR: ${Pt}`;Ge.push({role:"user",text:xt}),await St("toolFailure"),t.onToolResult&&t.onToolResult("failure",a),yield{type:"tool_result",content:xt,toolName:a},bt++;continue}let pn=Te.allowMultiple!==void 0?Te.allowMultiple===!0||String(Te.allowMultiple).toLowerCase()==="true":he;yt=Ce.length;let hn=Os(on,Ce,{allowMultiple:pn});le=hn.content,Ft=le,ht=hn.results;let yn=ht.filter(xt=>xt.success),Zn=ht.filter(xt=>!xt.success);if(yn.length===0){let xt=`[ACTION RESULT]: ERROR: Failed to apply patches to [${te.basename(F)}].
|
|
663
|
+
${Zn.map(Le=>` \u2022 ${Le.error}`).join(`
|
|
664
|
+
`)}`,Ai=`\u2714 Edited: ${te.basename(F.replaceAll("\\","/"))}`,Jt=115;process.stdout.isTTY&&(Jt=process.stdout.columns-5||120);let xn=Math.min(Ai.length+4,Jt),Ue=`${Ai.padEnd(xn-2).substring(0,xn-2)}`;yield{type:"visual_feedback",content:Rt(`${He?`
|
|
665
|
+
`:""}${Ue}`)},He=!1,Ge.push({role:"user",text:xt}),await St("toolFailure"),t.onToolResult&&t.onToolResult("failure",a),yield{type:"tool_result",content:xt,toolName:a},bt++;continue}}yield{type:"status",content:`Opening Diff in IDE: ${te.basename(F)}`},Gi(F,on,le),We=!0,await new Promise(Ce=>setTimeout(Ce,50))}else if(a==="write_file"){let le=Te.content||Te.newContent||"",Ce=le.endsWith(`
|
|
666
|
+
`)?le:le+`
|
|
667
|
+
`;Ft=Ce,ve.existsSync(F)||(fo=!0,ve.mkdirSync(te.dirname(F),{recursive:!0}),ve.writeFileSync(F,"","utf8")),yield{type:"status",content:`Opening New File Diff in IDE: ${te.basename(F)}`},Gi(F,"",Ce),We=!0,await new Promise(he=>setTimeout(he,50))}}}catch(Te){console.error("Simulation/Diff Error:",Te)}let ae=null;Ui(Te=>{ae=Te});let Me=t.onToolApproval;if(B=await new Promise(async Te=>{let be=setInterval(()=>{if(ae){let F=t.onIDEApproval||Mo&&Mo.onIDEApproval;F&&F(ae),clearInterval(be),Te(ae)}},100);try{let F=await Me(a,y.args,{isOverwritePrompt:K});clearInterval(be),Te(F)}catch{clearInterval(be),Te("deny")}}),Ui(null),a==="write_file"||a==="update_file"){let{path:Te}=L(y.args);if(Te){let be=te.resolve(process.cwd(),Te);if(sr(be,B),B==="deny"&&fo&&ve.existsSync(be))try{ve.unlinkSync(be)}catch{}}}B==="deny"&&(ge="user")}if(B==="allow"&&We&&oo()){let{path:ae}=L(y.args),Me=te.resolve(process.cwd(),ae),Te=Ue=>Ue?te.resolve(Ue).replace(/\\/g,"/").toLowerCase():"",be=await Un(),F="";if(be&&be.file_focused&&Te(be.file_focused)===Te(Me)&&be.full_content&&(F=be.full_content),!F&&ve.existsSync(Me)){let Ue=ve.readFileSync(Me,"utf8");Ue&&(F=Ue)}!F&&Ft&&(F=Ft),(F||fo)&&ve.writeFileSync(Me,F,"utf8");let Xt=F.split(/\r?\n/),Nn=Xt.length,on=Buffer.byteLength(F,"utf8"),Je="";$&&(Je=`Old File contents:
|
|
668
|
+
${$.split(/\r?\n/).map((Le,Bt)=>`${Bt+1} | ${Le}`).join(`
|
|
669
|
+
`)}
|
|
670
|
+
|
|
671
|
+
`);let Qe="";if(Nn<=100)Qe=Xt.join(`
|
|
672
|
+
`);else{let Ue=Xt.slice(0,50).join(`
|
|
673
|
+
`),Le=Xt.slice(-50).join(`
|
|
674
|
+
`);Qe=`${Ue}
|
|
675
|
+
|
|
676
|
+
... [${Nn-100} lines truncated for history stability] ...
|
|
677
|
+
|
|
678
|
+
${Le}`}let Ze="";if(a==="update_file"){let Ue=Ls($,F,ht,12,t?.compressToolResults||Mo?.systemSettings?.compressToolResults),{patchPairs:Le}=$i(L(y.args)),Bt=Le?.length||yt||1,sn=0,Qt=0,Fn=[];Le&&Le.length>0?Le.forEach((An,Ci)=>{let Go=An.replace||"",Zt=An.new||"",vi=Go.trim(),go=Zt.trim(),Ra=!!Ft&&F===Ft,Ea=go?F.includes(Zt)||F.includes(go):!0,_a=Zt?$.includes(Zt)||!!go&&$.includes(go):!1,Ia=vi?F.includes(Go)||F.includes(vi):!1;Ra||!!Zt&&Ea&&(!_a||!Ia||vi===go)?sn++:(Qt++,Fn.push(` \u2022 Block ${Ci+1}: not applied (reverted or rejected in IDE).`))}):sn=yt||0;let eo=0;if(Ft&&F!==Ft){let An=Qa("","",Ft||"",F||"","","",{context:0});if(An&&An.hunks)for(let Ci of An.hunks){let Go=Ci.lines.filter(Zt=>Zt.startsWith("+")).map(Zt=>Zt.slice(1).trim()).filter(Boolean);for(let Zt of Go)$.includes(Zt)||eo++}}let kn=[`[${sn}/${Bt}] applied`];Qt>0&&kn.push(`${Qt} rejected by user`),eo>0&&kn.push(`${eo} manual ${eo===1?"modification":"modifications"} by user`);let Tn=kn.join(", "),Bn=Fn.length>0?`
|
|
679
|
+
|
|
680
|
+
User Review Details:
|
|
681
|
+
${Fn.join(`
|
|
682
|
+
`)}`:"";Ze=`File [${ae}] updated via IDE Companion. ${Tn}.${Bn}
|
|
683
|
+
|
|
684
|
+
${Ue}`;let{added:Uo,removed:uo}=$s($,F);(Uo>0||uo>0)&&await Mi({added:Uo,removed:uo,file:ae})}else{let Ue=F.split(/\r?\n/),Le=Ue.length,Bt=Buffer.byteLength(F,"utf8"),sn="",Qt=c?.overwriteProtection!==!1;if($){let kn=$.split(/\r?\n/);if(!Qt)sn="";else if(kn.length<=50)sn=`Old File contents:
|
|
685
|
+
${kn.map((Tn,Bn)=>`${Bn+1} | ${Tn}`).join(`
|
|
686
|
+
`)}
|
|
687
|
+
|
|
688
|
+
`;else{let Tn=te.parse(Me),Bn=te.join(Es,"OverwriteBackups");if(!ve.existsSync(Bn))try{ve.mkdirSync(Bn,{recursive:!0})}catch{}let Uo=`${Tn.name}-old-${Date.now()}${Tn.ext}.bak`,uo=te.join(Bn,Uo);try{ve.writeFileSync(uo,$,"utf8")}catch{}sn=`Old File contents:
|
|
689
|
+
- Renamed old file as ${uo} and written requested content in ${ae}. For reversal use Run
|
|
690
|
+
|
|
691
|
+
`}}let Fn="";if(Le<=690)Fn=Ue.join(`
|
|
692
|
+
`);else{let kn=Ue.slice(0,300).join(`
|
|
693
|
+
`),Tn=Ue.slice(-300).join(`
|
|
694
|
+
`);Fn=`${kn}
|
|
695
|
+
|
|
696
|
+
... [${Le-100} lines truncated] ...
|
|
697
|
+
|
|
698
|
+
${Tn}`}Ze=`File [${ae}] saved via IDE Companion (May have user edits).
|
|
699
|
+
- Stats: [${Le} lines, ${(Bt/1024).toFixed(1)} KB]
|
|
700
|
+
${sn}- Content Preview:
|
|
701
|
+
|
|
702
|
+
${Fn}`;let eo=$?$.split(/\r?\n/).length:0;await Mi({added:Le,removed:eo,file:ae})}let le=a==="write_file"?"Created":"Edited",Ce=L(y.args),Pt=Object.entries(Ce).some(([Ue,Le])=>Ue.startsWith("searchContent")&&typeof Le=="string"&&Le.startsWith("^LINE:"))?"\u1361":":",pn=`${ae?"\u2714":"\u2718"} ${le}${Pt} ${ae?ae.replaceAll("\\","/"):"No File Changes"}`,hn=115;process.stdout.isTTY&&(hn=process.stdout.columns-5||120);let yn=Math.min(pn.length+4,hn),Zn=`${pn.padEnd(yn-2).substring(0,yn-2)}`;yield{type:"visual_feedback",content:Rt(`${He?`
|
|
703
|
+
`:""}${Zn}`)},He=!1;let xt=Date.now();On=xt,yield{type:"tool_time",content:xt-k};let Jt=(Ze||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");Jt.includes("[[VERIFIED]]")&&(Jt=Jt.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to conserve context.
|
|
704
|
+
`));let xn;if(a==="write_file"&&!Jt.startsWith("ERROR:")){let Ue=Jt.replace(/^\[\[SAME\]\]\s*\r?\n?/,"");if(/- Stats:.*\r?\nOld File contents:/s.test(Ue)){let Le=Ue.search(/^- Content Preview:/m);xn=`[ACTION RESULT]: ${Le!==-1?Ue.slice(0,Le).trimEnd():Ue}
|
|
705
|
+
|
|
706
|
+
[Old file content for reversal reference. Replaced with new write request]`}else{let Le=Ue.split(/\r?\n/),Bt=Le.filter(Qt=>Qt.startsWith("File ")||Qt.trim().startsWith("- Stats:"));xn=`[ACTION RESULT]: ${Bt.length>0?Bt.join(`
|
|
707
|
+
`):Le.slice(0,2).join(`
|
|
708
|
+
`)}`}}else if(Jt.startsWith("[[SAME]]")){let Le=Jt.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),Bt=Le.filter(Qt=>Qt.startsWith("File ")||Qt.trim().startsWith("- Stats:"));xn=`[ACTION RESULT]: ${Bt.length>0?Bt.join(`
|
|
709
|
+
`):Le.slice(0,2).join(`
|
|
710
|
+
`)}`}else xn=`[ACTION RESULT]: ${Jt}`;Ge.push({role:"user",text:xn}),fn=!0,await St("toolSuccess"),t.onToolResult&&t.onToolResult("success",a),yield{type:"tool_result",content:Ze,aiContent:xn,toolName:a},bt++;continue}if(B==="deny"){let ae=`Permission Denied: Prohibited ${a==="exec_command"?"Command":"file edit"}.`;if(D?ae=`User denied reading ${te.basename(fe||".env")}`:K&&ge==="user"?ae="User rejected file over-write. If needed AskUser how to proceed":ge==="user"?ae="Permission Denied by User":ge==="settings"?ae="Permission Denied by User Policy":ge==="network"?ae="Permission Denied: Sandbox Network Access Disabled by User Policy.":ge==="prohibited"&&a==="exec_command"&&(ae="Permission Denied: Prohibited Command in User Policy"),a==="view_file"){let Me=`\u2718 Read Denied: ${L(y.args).path?.replaceAll("\\","/")||".env"}`,Te=115;process.stdout.isTTY&&(Te=process.stdout.columns-5||120);let be=Math.min(Me.length+4,Te),F=`${Me.padEnd(be-2).substring(0,be-2)}`;yield{type:"visual_feedback",content:Rt(`${He?`
|
|
711
|
+
`:""}${F}
|
|
712
|
+
`)},He=!1}else if(a==="write_file"||a==="update_file"){let Te=`\u2718 ${a==="write_file"?"Write Cancelled":"Edit Denied"}: ${L(y.args).path.replaceAll("\\","/")||"..."}`,be=115;process.stdout.isTTY&&(be=process.stdout.columns-5||120);let F=Math.min(Te.length+4,be),Xt=`${Te.padEnd(F-2).substring(0,F-2)}`,Nn=` ${" ".repeat(F)} `;yield{type:"visual_feedback",content:Rt(`${He?`
|
|
713
|
+
`:""}${Xt}
|
|
714
|
+
`)},He=!1}a==="exec_command"&&(await new Promise(Me=>setTimeout(Me,50)),t.onExecChunk&&t.onExecChunk(`ERROR: ${ae}`),await new Promise(Me=>setTimeout(Me,50)),t.onExecEnd&&t.onExecEnd()),Ge.push({role:"user",text:`[ACTION RESULT]: DENIED: ${ae}`}),yield{type:"tool_result",content:`[ACTION RESULT]: DENIED: ${ae}`},await St("toolDenied"),t.onToolResult&&t.onToolResult("denied",a),bt++;continue}}}if(R){let c=115;process.stdout.isTTY&&(c=process.stdout.columns-5||120);let T=!1,D=Math.min(R.length+4,c),fe=`${R.padEnd(D-2).substring(0,D-2)}`;yield{type:"visual_feedback",content:Rt(`${He?`
|
|
715
|
+
`:""}${fe}${R.includes("\u2714")&&(R.includes("Created")||R.includes("Edited"))?"":`${T?"":`
|
|
716
|
+
`}`}`)},He=!1}if(On>0){let c=Date.now()-On,T=Math.max(0,1e3-c);T>0&&await new Promise(D=>setTimeout(D,T))}let At={chatId:g,history:n,onChunk:c=>t.onExecChunk?t.onExecChunk(c):null,onAskUser:t.onAskUser,systemSettings:t.systemSettings,mode:l,isMultiModal:et(J),onVisualFeedback:t.onVisualFeedback,onSubagentUpdate:t.onSubagentUpdate,onTokenChunk:t.onTokenChunk,modelName:J,aiProvider:t.aiProvider,apiKey:t.apiKey,onUsage:t.onUsage};if(a==="write_file"||a==="update_file")try{let{path:c}=L(y.args);if(c){let T=te.resolve(process.cwd(),c),D=await Un();D&&D.file_focused===T&&D.full_content&&(At.forcedContent=D.full_content)}}catch{}pe.push(a);let Z=await ns(a,y.args,At);if((a==="write_file"||a==="update_file")&&!Z.startsWith("ERROR:")){let{path:c}=L(y.args);if(c){let T=te.resolve(process.cwd(),c);ir(T)}}process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07");let je=Date.now();On=je,yield{type:"tool_time",content:je-k},Pn=je;let lt=null;if(typeof Z=="object"&&Z.binaryPart&&(lt=Z.binaryPart,Z=Z.text),a==="search_keyword"){let{keyword:c,path:T}=L(y.args),D=typeof Z=="string"&&Z.startsWith("[GLOB]");D&&(Z=Z.slice(6).trimStart());let fe=typeof Z=="string"&&Z.startsWith("[DIR]");fe&&(Z=Z.slice(5).trimStart());let ie=0;if(Z){let $=Z.match(/Found (\d+) match/i);$&&(ie=parseInt($[1]))}let ee=(T||"").trim().toLowerCase().replaceAll("\\","/"),ue=ee==="#doc"||ee==="#docs"||ee==="#documentation"||ee.includes("#skill/global/fluxflow")||ee.includes("#skill/fluxflow")||ee.includes("#skills/fluxflow")||ee.includes("#skills/global/fluxflow"),Ae,Y=115;process.stdout.isTTY&&(Y=process.stdout.columns-5||120);let K=Math.max(10,(Y+5)/3),B=Math.max(10,(Y+5)/4);if(ue)Ae=`${c?"\u2714":"\u2718"} Searched Documentation`;else{let $=T?T.replace(/[\/\\]+$/,""):null,ht=$&&$!=="."?`${D?T:fe?`${$}/*`:$}`:"./",yt=ht.length>B?`${ht.slice(0,B)}...`:ht;Ae=`${c?"\u2714":"\u2718"} Searched: "${c?c.length>Y/3?`${c.slice(0,K)}...`:c:""}" in "${yt.replaceAll("\\","/")}" \u2192 ${ie} Match${ie===1?"":"es"}`}let ge=Math.min(Ae.length+4,Y),We=`${Ae.padEnd(ge-2).substring(0,ge-2)}`;yield{type:"visual_feedback",content:Rt(`${He?`
|
|
717
|
+
`:""}${We}
|
|
718
|
+
`)},He=!1}if(a==="EmergencyRollback"){let{method:c}=L(y.args);if(c==="forceRevert"){let T=0;if(Z){let Y=Z.match(/Total\s*:\s*(\d+)/i);Y&&(T=parseInt(Y[1]))}let fe=Z&&Z.startsWith("ERROR:")?"\u2718 Emergency Rollback Failed":`\u2714 Emergency Rollback \u2192 ${T} file${T===1?"":"s"} processed`,ie=115;process.stdout.isTTY&&(ie=process.stdout.columns-5||120);let ee=!1,ue=Math.min(fe.length+4,ie),Ae=`${fe.padEnd(ue-2).substring(0,ue-2)}`;yield{type:"visual_feedback",content:Rt(`${He?`
|
|
719
|
+
`:""}${Ae}${ee?"":`
|
|
720
|
+
`}`)},He=!1}}if(a==="todo"){let{method:c,tasks:T,markDone:D}=L(y.args),fe="",ie=[],ee=ue=>{if(!ue)return[];let Ae=Array.isArray(ue)?ue:[];if(Ae.length===0&&typeof ue=="string"){let Y=ue.trim();if(Y.startsWith("[")&&Y.endsWith("]")){let K=Y.match(/"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'/g);K?Ae=K.map(B=>B.slice(1,-1).replace(/\\(.)/g,"$1")):Ae=Y.slice(1,-1).split(",").map(B=>B.trim()).filter(Boolean)}else Ae=ue.split(`
|
|
721
|
+
`)}return Ae.filter(Y=>String(Y).trim()).map(Y=>{let K=String(Y).trim();return K.startsWith("- [")?K.substring(6).trim():K})};if(c==="create"?(fe="\x1B[32m\u2192\x1B[0m Created Goals",ie=ee(T).map(ue=>`\x1B[90m\u25CB\x1B[0m ${ue}`)):c==="append"?(fe="\x1B[34m\u2795\x1B[0m Added New Goals",ie=ee(T).map(ue=>`\x1B[90m\u25CB\x1B[0m ${ue}`)):c==="get"&&(fe=D?"\x1B[36m\u21BB\x1B[0m Updated Goals":"\x1B[35m\u2022\x1B[0m Reviewed Goals",ie=(Z||"").split(`
|
|
722
|
+
`).slice(1).join(`
|
|
723
|
+
`).split(`
|
|
724
|
+
`).filter(Ae=>Ae.trim().startsWith("- [")).map(Ae=>{let Y=Ae.trim(),K=Y.startsWith("- [x]");return`${K?"\x1B[32m\u2714\x1B[0m":"\x1B[90m\u25CB\x1B[0m"} ${K?"\x1B[90m":"\x1B[37m"}${Y.substring(6).trim()}\x1B[0m`})),fe&&ie.length>0){let ue=[`${fe}`,...ie.map(Y=>` ${Y}`)].join(`
|
|
725
|
+
`);yield{type:"visual_feedback",content:Rt(`${He?`
|
|
726
|
+
`:""}${ue}${!1?"":`
|
|
727
|
+
`}`)},He=!1}}a==="exec_command"&&t.onExecEnd&&(await new Promise(c=>setTimeout(c,800)),t.onExecEnd());let Ct=Z&&Z.startsWith("DENIED:");Z&&!Z.startsWith("ERROR:")&&!Ct?(await St("toolSuccess"),t.onToolResult&&t.onToolResult("success",a)):Ct||(await St("toolFailure"),t.onToolResult&&t.onToolResult("failure",a));let pt=(Z||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");pt.includes("[[VERIFIED]]")&&(pt=pt.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to save tokens.
|
|
728
|
+
`));let Yt;if(a==="write_file"&&!pt.startsWith("ERROR:")){let c=pt.replace(/^\[\[SAME\]\]\s*\r?\n?/,"");if(/- Stats:.*\r?\nOld File contents:/s.test(c)){let T=c.search(/^- Content Preview:/m);Yt=`[ACTION RESULT]: ${T!==-1?c.slice(0,T).trimEnd():c}
|
|
729
|
+
|
|
730
|
+
[Old file content for reversal reference. Replaced with new write request]`}else{let T=c.split(/\r?\n/),D=T.filter(ie=>ie.startsWith("File ")||ie.trim().startsWith("- Stats:"));Yt=`[ACTION RESULT]: ${D.length>0?D.join(`
|
|
731
|
+
`):T.slice(0,2).join(`
|
|
732
|
+
`)}`}}else if(pt.startsWith("[[SAME]]")){let T=pt.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),D=T.filter(ie=>ie.startsWith("File ")||ie.trim().startsWith("- Stats:"));Yt=`[ACTION RESULT]: ${D.length>0?D.join(`
|
|
733
|
+
`):T.slice(0,2).join(`
|
|
734
|
+
`)}`}else Yt=`[ACTION RESULT]: ${pt}`;Ge.push({role:"user",text:Yt,binaryPart:lt}),fn=!0;let de=`[ACTION RESULT]: ${Z.replaceAll(`[[VERIFIED]]
|
|
735
|
+
`,"").replaceAll(`
|
|
736
|
+
[[/VERIFIED]]`,"")||""}`;(a==="view_file"||a==="web_scrape"||a==="file_map"||a==="search_keyword"||a==="get_progress"||a==="getprogress")&&(de=`[ACTION RESULT]: ${R} (Context Locked for UI Clarity)`),yield{type:"tool_result",content:de,aiContent:Yt,binaryPart:lt,toolName:a},a==="memory"&&!Z.startsWith("ERROR:")&&(yield{type:"memory_updated"}),bt++}if(s==="Google"&&it&&Date.now()-Bo>=150){yield*nn();let y=ao(it);for(let k of y)yield k;it="",Bo=Date.now()}}f.usageMetadata&&(Vt=f.usageMetadata),Vt&&(yield{type:"liveTokens",content:Vt.totalTokenCount})}if(U&&(U=!1,tt?ke+="</think_fluxflow>":(we+="</think_fluxflow>",s==="Google"?it+="</think_fluxflow>":yield{type:"text",content:"</think_fluxflow>"})),tt&&ke.length>0){let f=0,b=Math.min(dt.length,ke.length);for(let H=b;H>0;H--)if(dt.endsWith(ke.substring(0,H))){f=H;break}let S=ke.substring(f);if(S){let oe=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(dt)?S.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):S.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");if(oe)if(we+=oe,s==="Google")it+=oe;else{yield*nn();let I=ao(oe);for(let j of I)yield j}}tt=!1,ke=""}if(un){let f=un,b=(st==="tool"||st==="action")&&(f.startsWith("[tool:")||f.startsWith("[action:"));un="",Jn=!1,st=null,Dn=!1,Qn=!1,b||(s==="Google"?it+=f:yield{type:"text",content:f})}if(yield*nn(),ct)break;let lo=(we||"").trim(),Sa=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(lo.toLowerCase())||/\[\[END\]\]/i.test(lo.toLowerCase()),ka=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(lo.toLowerCase()),Ta=Ge.length>0||It!==null,Ti=$t(lo).trim(),Aa=/(\p{Emoji_Presentation}|\p{Extended_Pictographic})$/u.test(Ti),Ca=/([.!?"'*_`|\]\)”’~~]+|\s|`{3}|[\u200B-\u200D\uFEFF])$/u.test(Ti.trim()),va=/[.!?}"'`’“”]$|```$/s.test(Ti)||Ca||Aa;!Sa&&!ka&&!Ta&&lo.length>0,Oe=!0,await St("agent",s)}catch(z){if(ct){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
|
|
737
|
+
|
|
738
|
+
\x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(String(z).includes("Incomplete JSON segment at the end")){U&&(U=!1,tt?ke+="</think_fluxflow>":(we+="</think_fluxflow>",yield{type:"text",content:"</think_fluxflow>"})),Oe=!0,await St("agent",s);break}if(U&&(U=!1,tt?ke+="</think_fluxflow>":we+="</think_fluxflow>"),tt&&ke.length>0){let ft=0,Ye=Math.min(dt.length,ke.length);for(let Nt=Ye;Nt>0;Nt--)if(dt.endsWith(ke.substring(0,Nt))){ft=Nt;break}let ot=ke.substring(ft);if(ot){let Xe=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(dt)?ot.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):ot.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");Xe&&(we+=Xe)}tt=!1,ke=""}let E=z instanceof Error?(()=>{try{return JSON.parse(JSON.parse(z.message).error.message).error.message}catch{return String(z)}})():String(z),nt=new Date().toLocaleString(),ce=te.join(Wn,"agent");ve.existsSync(ce)||ve.mkdirSync(ce,{recursive:!0}),ve.appendFileSync(te.join(ce,"error.log"),`ERROR [${nt}]: ${E}
|
|
739
|
+
|
|
740
|
+
----------------------------------------------------------------------
|
|
741
|
+
|
|
742
|
+
`);let Be=z.status||z.statusCode||z.code,mt=String(z).includes("replicas at capacity");if(!(Be&&(Be>=500&&Be<600||Be===408||Be===429||mt)||!Be&&(/status[ :]+(5\d\d|408|429)/i.test(String(z))||/code[ :]+(5\d\d|408|429)/i.test(String(z))||/(500|503|408|429)/.test(String(z))))){if(Ve<tn-3)throw z;yield{type:"text",content:E},yield{type:"status",content:"Error Occured"}}if(we.trim().length>0||qe>1)if(qe<=tn){qe++;let ft=Math.min(1e3*Math.pow(2,qe-1),24e3);if(we.trim().length>0){x.push({role:"agent",text:we});let Ye=`[system]
|
|
743
|
+
- seamless continuation: resume immediately. pick up from last words with zero gap/disruption
|
|
744
|
+
- no repetition: do not repeat any text already written
|
|
745
|
+
- no re-think: do not restart or open <think_fluxflow> if reasoning already started. continue the thinking and close thinking block </think_fluxflow> before chat output
|
|
746
|
+
- mid-tool safety: if cutoff was mid-tool call, restart that tool call from start
|
|
747
|
+
- stealth: do not mention/apologize for cutoff [/system]`;Ge.length>0?Ge.forEach((ot,Nt)=>{Nt===Ge.length-1?x.push({...ot,text:`${ot.text}
|
|
748
|
+
|
|
749
|
+
${Ye}`}):x.push(ot)}):x.push({role:"user",text:Ye}),dt+=we}for(let Ye=ft/1e3;Ye>0&&!ct;Ye--)yield{type:"status",content:`Error Occured. Recovering Stream (${qe}/${tn}) [Retrying in ${Ye.toFixed(0)}s]...`},await new Promise(ot=>setTimeout(ot,1e3));yield{type:"status",content:"Error Occured. Recovering Stream..."}}else throw new Error(`Stream collapsed too many times. (Failed to resolve ${tn} times)
|
|
750
|
+
Error log can be found in \`/export logs\``);else{let Ye=e.split("/").slice(e.endsWith("/free")?-2:-1).join("/");if(Ve<=tn){Ve++,qe=1,dt="";let ot=Math.min(1e3*Math.pow(2,Ve-1),32e3),Nt=.8+Math.random()*.4,Xe=Math.round(ot*Nt);bn=!0,yield{type:"status",content:`Trying to reach ${Ye} (${Ve}/${tn}) [Retrying in ${(Xe/1e3).toFixed(0)}s]`};for(let $e=Xe/1e3;$e>0&&!ct;$e--)yield{type:"status",content:`Trying to reach ${Ye} (${Ve}/${tn}) [Retrying in ${$e.toFixed(0)}s]`},await new Promise(it=>setTimeout(it,1e3));yield{type:"status",content:`Trying to reach ${Ye}`}}else throw new Error(`Model ${e} cannot be reached. (Failed ${tn} times)
|
|
751
|
+
Error log can be found in \`/export logs\``)}}}if(Vt){let U=Vt.totalTokenCount||0,z=Vt.cachedContentTokenCount||0,E=(Vt.candidatesTokenCount||0)+(s==="Google"&&Vt.thoughtsTokenCount||0);await an("tokens",U,s,J),z>0&&await an("cachedTokens",z,s,J),E>0&&await an("candidateTokens",E,s,J),gt!==null&>>0&&await an("ttft",gt,s,J),qo({provider:s,model:J,prompt:Vt.promptTokenCount||0,cached:z,output:E,reasoning:Vt.thoughtsTokenCount||0,ttft:gt}),yield{type:"usage",content:Vt}}else gt!==null&>>0&&(await an("ttft",gt,s,J),qo({provider:s,model:J,prompt:0,cached:0,output:0,reasoning:0,ttft:gt}));we=sa(we),bi.push(we);let Sl=$t(we),ki=na(we),pa=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(ki.toLowerCase())||/\[\[END\]\]/i.test(ki.toLowerCase())||!0,kl=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(ki.toLowerCase()),Tl=bt>0;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"};let ha=yl(we,/(\[\s*(turn\s*:)?\s*(continue|finish)\s*\]|\[\[END\]\])/gi,"").trim(),ya=Ge.length>0||Rn($t(we)).length>0,Ln=(pa||Ge.length===0)&&!Tt&&!$n&&!Mt;if(Ln=Ge.length===0?Ln:!1,Ln=ya&&Dt||Fo?!1:Ln,we&&we.trim().endsWith('")]')&&Ge.length===0&&(Ln=!1),Ln){As=!0;let U=bi.join(`
|
|
752
|
+
`),z=$t(U).trim();yield{type:"interactive_turn_finished",data:{agentText:Ie,fullAgentTextRaw:U,history:[...x],needTitle:Re}},x.length>0&&x[x.length-1].role==="agent"?x[x.length-1].text=z:x.push({role:"agent",text:z}),x.forEach(E=>{if(E.role==="user"&&E.text&&(E.text=E.text.replace(/\n\[COMPILE ERROR\][\s\S]*?\[\/ERROR\]/g,""),E.text=E.text.replaceAll(`
|
|
753
|
+
|
|
754
|
+
[system] user question. resolve this specific query within '[ANSWER] ... [/ANSWER]' concisely, naturally [/system]
|
|
755
|
+
`,"").replaceAll(`[system] user question. resolve this specific query within '[ANSWER] ... [/ANSWER]' concisely, naturally
|
|
756
|
+
**strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow>** [/system]
|
|
757
|
+
`,"").replaceAll(`[system] **strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow>** [/system]
|
|
758
|
+
`,"").replaceAll(/\n\[system\] WARNING, Turn Limit Impending: Step \d+\/\d+\. Wrap up quickly\/prompt user to continue & use \[\[END\]\] quickly\. \[\/system\]/g,""),E.text=E.text.replaceAll(/\n\[system\] File Changes:\n(?:\* .+ \(created|modified|deleted\)\n)*\[\/system\]/g,""),(s==="Mistral"||s==="Google"&&e?.toLowerCase().startsWith("gemma"))&&(E.text.startsWith("[ACTION RESULT]")||E.text.startsWith("[TOOL RESULT]")))){let ce=`
|
|
759
|
+
[system] Action result received. Analyze output and proceed with your turn [/system]`,Be=`
|
|
760
|
+
[system] Action result received. Analyze output and proceed with your turn. **strictly follow thinking policy. do not start a response without <think_fluxflow>...</think_fluxflow>** [/system]`;E.text=E.text.replaceAll(Be,"").replaceAll(ce,"").trim()}}),yield{type:"status",content:"[end]"}}if(Ln)break;let xa=ha.trim()||"*Working...*";if(x.push({role:"agent",text:xa}),Ge.length>0||fn){if(Ge.length>0){let U=Ge.map(Xe=>Xe.text).join(`
|
|
761
|
+
|
|
762
|
+
`),z=$t(we),E=Rn(z),nt=ta(z,E),ce=gi(nt),Be=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,mt=[],me=[],ft;for(;(ft=Be.exec(ce))!==null;)me.push({index:ft.index,toolName:ft[1]});for(let Xe=0;Xe<me.length;Xe++){let $e=me[Xe],it=Xe+1<me.length?me[Xe+1].index:z.length;E.some(nn=>nn.fullMatch&&z.startsWith(nn.fullMatch,$e.index))||mt.push(z.substring($e.index,it))}let Ye=mt.length,ot=Ge.length+Ye;if(Ye>0){let Xe=mt.join(`
|
|
763
|
+
`),$e=oa(Xe);U+=`
|
|
764
|
+
|
|
765
|
+
[system] Only ${Ge.length} out of ${ot} attempted tool calls were executed.
|
|
766
|
+
${$e?`Parsing Issues Detected:
|
|
767
|
+
${$e}
|
|
768
|
+
`:""}Verify proper structure compliance [action:ActionName(arg="value")] & try failed calls again [/system]`;for(let it=0;it<Ye;it++)await St("toolFailure")}let Nt=Ge.find(Xe=>Xe.binaryPart)?.binaryPart||null;x.push({role:"user",text:U,binaryPart:Nt})}}else if(!ct){let U=we.replace(/(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\]|$)/i,""),z=Rn(U),E=ta(U,z),ce=(gi(E).match(/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi)||[]).length;if(Fo||Dt&&ce>0||ce>0){let Be=oa(U),mt=Be?`[system] Failed to execute ${ce>0?ce:1} tool call${ce>1?"s":""} due to syntax/structure issues:
|
|
769
|
+
${Be} [/system]`:`[system] Failed to execute ${ce>0?ce:1} tool${ce>1?"s":""}. Verify proper structure compliance [action:ActionName(arg="value")] & try again [/system]`;x.push({role:"user",text:mt}),await St("toolFailure"),yield{type:"visual_feedback",content:`
|
|
770
|
+
${Rt("\u2718 Model produced malformed tool call")}
|
|
771
|
+
`}}else yield{type:"visual_feedback",content:`
|
|
772
|
+
${Rt("\u2718 Loop Detected")}
|
|
773
|
+
`},x.push({role:"user",text:`[system] ${$n&&!Tt?"Stuttering Detected by Internal System. Re-calibrate your response & proceed.":`${Tt?" Over Thinking":" Loop"} Detected by Internal System${Tt?" for current Effort Level":""}. ${Tt?"If you have planned the task, prioritize execution/output":"If you have finished your task provide a simple summary and end"}`} [/system]`});Tt=!1,$n=!1,Mt=!1}m?.advanceRollback&&await ho.recordTurnDelta(g,C+1,pe),Si=pe.includes("recapture_screen"),Fo=bt>0||fn}if(!As&&!ct){let C="\u2726 Turn safety limit reached. Stopping execution.";yield{type:"text",content:`
|
|
774
|
+
|
|
775
|
+
${C}
|
|
776
|
+
`};let Se=(bi.join(`
|
|
777
|
+
`)+`
|
|
778
|
+
${C}`).trim();yield{type:"interactive_turn_finished",data:{agentText:Ie,fullAgentTextRaw:Se,history:[...x],needTitle:Re}},yield{type:"status",content:"[end]"}}}catch(G){let x=G?.cause?` (Cause: ${G.cause?.message||String(G.cause)})`:"",De=(G instanceof Error?(()=>{try{return JSON.parse(JSON.parse(G.message).error.message).error.message}catch{return(G.message?`${G.message}${x}`:"")||String(G)}})():String(G)).replace(/^(Error:\s*)+/i,"");s==="Google"&&!/^[A-Z0-9_\-\s]+ ERROR:/i.test(De)&&(De=`GEMINI ERROR: ${De}`);let Ht=new Date().toLocaleString(),Ne=te.join(Wn,"agent");yield{type:"text",content:`
|
|
779
|
+
|
|
780
|
+
\u2726 CRITICAL ERROR: ${De.includes("fetch failed")?"Failed to Connect. Check your Internet Connection or Wait a moment":De}
|
|
781
|
+
\u2800`},ve.existsSync(Ne)||ve.mkdirSync(Ne,{recursive:!0}),ve.appendFileSync(te.join(Ne,"error.log"),`CRITICAL ERROR [${Ht}]: ${G}${G?.cause?`
|
|
782
|
+
CAUSE: ${G.cause?.stack||G.cause}`:""}
|
|
783
|
+
|
|
784
|
+
----------------------------------------------------------------------
|
|
785
|
+
|
|
786
|
+
`),typeof flushGoogleBuffer=="function"&&(yield*flushGoogleBuffer()),yield{type:"tool_result",content:`ERROR: [INTERNAL CRITICAL] ${De}`}}finally{ze&&(clearInterval(ze),ze=null),typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),await Yo.commitTransaction(),m?.advanceRollback&&await ho.cleanup(g),await Un()}yield{type:"status",content:null}},Hd=async(e,n,t=null,i=null,o=null,r=null,d=!1)=>{let l=await zo(),u={...l,...n},g=typeof o=="number"&&o>0?o:50,h=(u?.systemSettings?.loopLimits||"Default").toLowerCase();if(h==="extended")g=Math.floor(g*3);else if(h==="env"){let Ne=parseInt(process.env.FLUXFLOW_SUBAGENT_MAX_TURNS||process.env.SUBAGENT_MAX_TURNS||process.env.FLUXFLOW_MAX_LOOPS||process.env.MAX_LOOPS||"",10);Number.isFinite(Ne)&&Ne>0&&(g=Ne)}o=g;let m=process.env.SUBAGENT_MODEL?process.env.SUBAGENT_MODEL.trim():null,p=process.env.SUBAGENT_PROVIDER?process.env.SUBAGENT_PROVIDER.trim():null,s=new Date,w=`${s.getFullYear()}-${s.toLocaleString("en-US",{month:"short"}).toUpperCase()}-${String(s.getDate()).padStart(2,"0")}, ${s.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).replace(":","-")}`,Pe=(Ne=>{if(!Ne)return null;let re=Ne.toLowerCase();return re==="google"?"Google":re==="deepseek"?"DeepSeek":re==="openrouter"?"OpenRouter":re==="nvidia"?"NVIDIA":re==="mistral"?"Mistral":re==="ollama"?"Ollama":re==="inferx"?"InferX":re==="sensenova"?"SenseNova":re==="poolside"?"Poolside":re==="9router"||re==="9Router"?"9router":re==="aihubmix"||re==="aihub"?"AIHubMix":re==="explabs"||re==="experientiallabs"||re==="experimentallabs"?"ExpLabs":re==="tokenharbor"||re==="token harbor"||re==="token_harbor"||re==="thk"?"TokenHarbor":re==="infron"?"Infron":re==="apinex"||re==="apx"?"APInex":re==="xkiro"||re==="kiro"?"xKiro":re==="c_openai"||re==="custom_openai"||re==="custom (openai)"||re==="custom"?"c_openai":null})(p),v=u?.systemSettings?.CustomSubAgent?u?.systemSettings?.SubAgentModel:null,N=u?.systemSettings?.CustomSubAgent?u?.systemSettings?.SubAgentProvider:null,P=null;if(v==="ENV"?(P=m,m&&Pe&&(u.aiProvider=Pe)):v&&v!=="Default"?(P=v,N&&(u.aiProvider=N)):m&&Pe&&(u.aiProvider=Pe),u.aiProvider){let Ne=await Ps(u.aiProvider);Ne&&(u.apiKey=Ne)}let V=Ne=>{if(!Ne||typeof Ne!="string")return{allowed:!0};let re=[/rm\s+-[rf]{1,2}\s+[\/*.]/i,/rmdir\s+\/[sq]/i,/del\s+\/[fsq]/i,/\bformat\b\s+[a-z]:/i,/mkfs/i,/dd\s+if=/i,/\b(shutdown|reboot|poweroff|init\s+0|init\s+6)\b/i,/chmod\s+(-R\s+)?777\s+[\/*.]/i,/chown\s+(-R\s+)?root/i,/git\s+push\s+.*--force/i,/git\s+clean\s+-fdx/i,/\bsudo\s+su\b/i,/\bsu\s+-\b/i];for(let en of re)if(en.test(Ne))return{allowed:!1,reason:`Blocked potentially destructive or unsafe command pattern: "${en.source}"`};return{allowed:!0}},M=t||P||n?.modelName||n?.activeModel||l.activeModel,xe=(process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux")==="Windows",Re=xe&&u?.systemSettings?.preferBash!==!1&&Ds(),Ie="Run(command=string)",ze=`Runs ${xe?Li()?"powershell":"windows CMD":"bash"} command`;Re&&(Ie=`Run(command=string, ${Ns()||Li()?"forcePowershell?=bool:false":"forceCwd?=bool:false"})`,ze="Runs in git bash. Or force native shell");let G=`-- ACTIONS (path = relative to CWD, path separator: '/') --
|
|
787
|
+
In chat output the format \`[action:ActionName(arg1="value1")]\` in NEW line
|
|
788
|
+
Rules:
|
|
789
|
+
- JSON escape literal sequences, backslash: \\\\, newLine: \\ n
|
|
790
|
+
- Same file, multiple edits? ONE PatchFile \u226415 blocks
|
|
791
|
+
- Need text or huge file? CodeSearch > Full Read
|
|
792
|
+
- Stuck on syntax error? Tell user > waste time
|
|
793
|
+
|
|
794
|
+
# Provided Actions
|
|
795
|
+
**Communication**
|
|
796
|
+
- AskUser(question=string, optionA?="title::description", ...MAX4). Any Ambiguity
|
|
797
|
+
${d?"- AskMain(question=string). Communicate with PARENT/MAIN AGENT. When clarification/decision is needed for a task":""}
|
|
798
|
+
|
|
799
|
+
**Web**
|
|
800
|
+
- WebSearch(query=string, aiMode?=bool:false, limit?=int[3..10]). For unknown topics, time sensitive, fact checking
|
|
801
|
+
- WebScrape(url=string). JS supported
|
|
802
|
+
|
|
803
|
+
**Workspace**
|
|
804
|
+
- CodeSearch(keyword=string, path?="file/glob, inclusion !exclusion ;-separated", regex?=bool:auto)
|
|
805
|
+
- ReadFolder(path=string, recurse?=int[1..3])
|
|
806
|
+
- FindFile(basename=string)
|
|
807
|
+
- ReadFile(path=string, startLine?=int, endLine?=int)
|
|
808
|
+
- 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
|
|
809
|
+
- WriteFile(path=string, content=string). Creates/Overwrites. File Exist? PatchFile > WriteFile
|
|
810
|
+
- ${Ie}. ${ze}. Destructive command \u2192 Ask user`.trim(),x=`=== START SYSTEM PROMPT ===
|
|
811
|
+
Identity: FluxFlow subagent helping the main Agent
|
|
812
|
+
Your task: "${e}"
|
|
813
|
+
CWD: ${process.cwd()}
|
|
814
|
+
|
|
815
|
+
${G.trimEnd()}
|
|
816
|
+
|
|
817
|
+
-- THINKING GUIDANCE --
|
|
818
|
+
Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking. Just focus on task completion. Before actions, provide user facing summary of findings & decisions IN detail
|
|
819
|
+
Main focus: actions and task, not chatting
|
|
820
|
+
On completion, provide a detailed summary in Tables/Markdown Format with file modified info. If any task failed report back in detail
|
|
821
|
+
|
|
822
|
+
Current Time: ${w}
|
|
823
|
+
=== END SYSTEM PROMPT ===`,Gt=[{role:"user",text:`Complete this task: ${e}`}],De=0,Ht="";for(;De<o;){let Ne=await Pi("subagent",u);if(!Ne.allowed)throw new Error(Ne.reason||`Budget Exhausted for Provider (${u?.aiProvider||"Subagent"})`);if(ct){if(n?.taskId&&typeof Ot<"u"){let X=Ot.find(W=>W.id===n.taskId);X&&(X.status="cancelled")}throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}if(n?.taskId&&typeof Ot<"u"){let X=Ot.find(W=>W.id===n.taskId);if(X&&X.status==="cancelled")throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}let re=Gt.map(X=>({role:X.role==="user"?"user":"model",parts:[{text:X.text}]}));r&&r(`[Subagent Turn ${De+1}]...`);let en=["Fast","Low","Medium","High"],jn=process.env.SUBAGENT_THINKING,Po=en.includes(jn)?jn:"Low",$o=(await wl(u,M,re,x,Po)).text||"",En=sa($t($o).trim());Ht=En,r&&r(`[Subagent Response]
|
|
824
|
+
${En}
|
|
825
|
+
`),Gt.push({role:"agent",text:En});let Kn=Rn(En);if(Kn.length===0)break;let jt=Kn.filter(X=>X.toolName.toLowerCase()==="askmain"||X.toolName.toLowerCase()==="ask_main"),_n=!1,Ee="";for(let X of Kn){if(ct){if(n?.taskId&&typeof Ot<"u"){let A=Ot.find(ne=>ne.id===n.taskId);A&&(A.status="cancelled")}throw new Error("Subagent task was cancelled.")}if(n?.taskId&&typeof Ot<"u"){let A=Ot.find(ne=>ne.id===n.taskId);if(A&&A.status==="cancelled")throw new Error("Subagent task was cancelled.")}let W=X.toolName.toLowerCase();if(W==="askuser"&&(W="ask"),W==="askmain"||W==="ask_main"){if(_n)continue;_n=!0;let A="";if(jt.length===1?A=L(jt[0].args).question||jt[0].args:A=jt.map((ne,Kt)=>{let Lt=L(ne.args);return`Q${Kt+1}: ${Lt.question||ne.args}`}).join(`
|
|
826
|
+
`),n.onAskMain){r&&r(`[Executing Tool] AskMain("${A}")...`);let ne=await n.onAskMain(A);r&&r(`[Action Result]
|
|
827
|
+
Answer from Main Agent: ${ne}
|
|
828
|
+
`),Ee+=`[ACTION RESULT for AskMain]: Answer from Main Agent: ${ne}
|
|
829
|
+
|
|
830
|
+
`,await St("toolSuccess")}else Ee+=`[ACTION RESULT for AskMain]: ERROR: Main agent communication channel not available.
|
|
831
|
+
|
|
832
|
+
`;continue}if(!(i?i.some(A=>A.toLowerCase()===W):!0)){let A=`ERROR: Tool [${X.toolName}] is not in the allowed tools list for this subagent.`;r&&r(`[Blocked Tool Call] ${X.toolName} - not allowed
|
|
833
|
+
`),Ee+=`${A}
|
|
834
|
+
|
|
835
|
+
`;continue}if(W==="exec_command"||W==="execcommand"||W==="run"){let A=L(X.args).command||"",ne=V(A);if(!ne.allowed){let Kt=`ERROR: [SECURITY RESTRICTION] Subagent execution blocked command: ${ne.reason}`;r&&r(`[Blocked Command] ${A} - ${ne.reason}
|
|
836
|
+
`),Ee+=`${Kt}
|
|
837
|
+
|
|
838
|
+
`;continue}}let ut="";if(W==="web_search"||W==="websearch")ut=`\u2714 \x1B[95mSearched\x1B[0m: ${L(X.args).query||""}`;else if(W==="web_scrape"||W==="webscrape")ut=`\u2714 \x1B[95mScraped\x1B[0m: ${L(X.args).url||""}`;else if(W==="search_keyword"||W==="searchkeyword"||W==="codesearch"||W==="code_search"){let A=L(X.args),ne=A.keyword||"",Kt=A.path||"";ut=`${ne?"\u2714":"\u2718"} \x1B[95mSearched\x1B[0m: ${ne||"No Query"}${Kt?` \u2192 ${Kt.replaceAll("\\","/")}`:""}`}else if(W==="view_file"||W==="viewfile"||W==="readfile")ut=`\u2714 \x1B[95mRead\x1B[0m: ${(L(X.args).path||"").replaceAll("\\","/")}`;else if(W==="find_file"||W==="findfile"){let A=L(X.args),ne=A.basename||A.name||A.path||A.file||A.query||"";ut=`${ne?"\u2714":"\u2718"} \x1B[95mLocated\x1B[0m: ${ne||"No Query"}`}else if(W==="list_files"||W==="read_folder"||W==="readfolder"){let A=L(X.args).path||null,ne=L(X.args).recurse||0;ut=`${A?"\u2714":"\u2718"} \x1B[95mBrowsed\x1B[0m: ${A?`${A.replaceAll("\\","/")}${ne>0?`${A.endsWith("/")?`*${ne}`:`/*${ne}`}`:`${A.endsWith("/")?"":"/"}`}`:""}`}else if(W==="write_file"||W==="writefile"){let A=L(X.args).path||null;ut=`${A?"\u2714":"\u2718"} \x1B[95mCreated\x1B[0m: ${A?`${A.replaceAll("\\","/")}`:"No File Changes"}`}else if(W==="update_file"||W==="updatefile"||W==="patchfile"||W==="patch_file"){let A=L(X.args),ne=A.path||null,Lt=Object.entries(A).some(([wt,In])=>wt.startsWith("searchContent")&&typeof In=="string"&&In.startsWith("^LINE:"))?"\u1361":":";ut=`${ne?"\u2714":"\u2718"} \x1B[95mEdited\x1B[0m${Lt} ${ne?`${ne.replaceAll("\\","/")}`:"No File Changes"}`}else if(W==="exec_command"||W==="execcommand"||W==="run"){let A=L(X.args).command||null;ut=`${A?"\u2714":"\u2718"} \x1B[95mExecuted\x1B[0m: ${A?A.slice(0,100)+(A.length>100?"...":""):"No Command"}`}else if(W==="file_map"||W==="filemap"){let A=L(X.args).path||"";ut=`${A?"\u2714":"\u2718"} \x1B[95mIndexed\x1B[0m: ${A?`${A.replaceAll("\\","/")}`:"File Not Found"}`}else if(W==="await"){let{time:A}=L(X.args),ne=parseFloat(A)||0;ne<10&&(ne=10),ne>180&&(ne=180),ut=`\u2714 \x1B[95mAwaiting\x1B[0m \u2192 ${(Lt=>{if(Lt>=60){let wt=Math.floor(Lt/60),In=Lt%60;return`${wt}m${In>0?` ${In}s`:""}`}return`${Lt}s`})(ne)}`}else{let A=fs[W]||X.toolName,ne=Hn(W,X.args);ut=`\u2714 \x1B[95m${A}\x1B[0m${ne?`: ${ne}`:""}`}n.onVisualFeedback&&ut&&n.onVisualFeedback(ut),r&&r(`[Executing Tool] ${X.toolName}(${X.args})...`);try{let A=await ns(X.toolName,X.args,{...n,mode:"Flux"});r&&r(`[Action Result]
|
|
839
|
+
${A}
|
|
840
|
+
`),Ee+=`[ACTION RESULT for ${X.toolName}]: ${A}
|
|
841
|
+
|
|
842
|
+
`,await St("toolSuccess")}catch(A){let ne=`ERROR: Execution failed for [${X.toolName}]: ${A.message}`;r&&r(`[Tool Error] ${ne}
|
|
843
|
+
`),Ee+=`${ne}
|
|
844
|
+
|
|
845
|
+
`,await St("toolFailure")}}let Vn="";if(n?.taskId&&typeof Ot<"u"){let X=Ot.find(W=>W.id===n.taskId);if(X&&X.pendingSteerMessages&&X.pendingSteerMessages.length>0){let W=[...X.pendingSteerMessages];X.pendingSteerMessages=[];for(let qn of W)Vn+=`
|
|
846
|
+
|
|
847
|
+
[STEERING INSTRUCTION FROM MAIN AGENT]: ${qn}`,r&&r(`[Subagent Steered] ${qn}`)}}let zn=(Ee.trim()+Vn).trim();Gt.push({role:"user",text:zn}),De++}return Ht};export{io as a,ci as b,Uc as c,Gc as d,cc as e,dc as f,oo as g,fc as h,Rc as i,Ec as j,dl as k,Dd as l,fl as m,ul as n,ds as o,$t as p,ui as q,sa as r,Nd as s,Fd as t,Bd as u,ra as v,Wd as w,gi as x,ta as y,hl as z,Rn as A,Ud as B,wl as C,Gd as D,Hd as E};
|