fluxflow-cli 4.25.1 → 4.25.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/chunks/{ai-42ZMTHOC.js → ai-OPCGIZAK.js} +1 -1
- package/dist/chunks/{app-4ENAKUXT.js → app-D33R52FZ.js} +136 -136
- package/dist/chunks/chunk-2AUIP6N5.js +5 -0
- package/dist/chunks/{chunk-ZRP6USHC.js → chunk-6NWU3ML6.js} +24 -24
- package/dist/chunks/{chunk-NQTRYK6U.js → chunk-BM3FXMTK.js} +1 -1
- package/dist/chunks/{chunk-YZ5KP5YH.js → chunk-SXRQ4ACF.js} +199 -200
- package/dist/chunks/{click-RDFFRPIN.js → click-5I5YOSNC.js} +2 -2
- package/dist/chunks/{computer_action-OQ3CWQU3.js → computer_action-RTEC7VUX.js} +1 -1
- package/dist/chunks/{drag-RLRC6JFF.js → drag-6TRBT2C3.js} +1 -1
- package/dist/chunks/{invoke-CYOAQYP6.js → invoke-G5IJ3VPK.js} +2 -2
- package/dist/chunks/{invokeSync-RR6HNW42.js → invokeSync-PAOUTNOW.js} +2 -2
- package/dist/chunks/{key_press-7F6CAPZD.js → key_press-Z3OXF74E.js} +1 -1
- package/dist/chunks/{keyboard_typing-RPPKNVTA.js → keyboard_typing-F2SAZLI2.js} +1 -1
- package/dist/chunks/{screen_grid-3F55Z22R.js → screen_grid-RAKJUJQA.js} +1 -1
- package/dist/chunks/{scroll-QVQD7I6A.js → scroll-7JYRU34H.js} +1 -1
- package/dist/chunks/{update_file-PXZHSSGS.js → update_file-KNEQRJAG.js} +1 -1
- package/dist/cli.js +2 -2
- package/dist/package.json +2 -2
- package/package.json +2 -2
- package/dist/chunks/chunk-A73HW6DI.js +0 -5
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as Vt}from"./chunk-56EJGQU3.js";import{a as lo}from"./chunk-7SFAWGE2.js";import{a as Ai,c as Ei}from"./chunk-U2NRX2PX.js";import{a as Cs,g as Ci}from"./chunk-VYTQ6J56.js";import{a as Ri}from"./chunk-RZTZPIC5.js";import{c as As,g as Ti,h as Si,i as _i,m as Es}from"./chunk-
|
|
1
|
+
import{a as Vt}from"./chunk-56EJGQU3.js";import{a as lo}from"./chunk-7SFAWGE2.js";import{a as Ai,c as Ei}from"./chunk-U2NRX2PX.js";import{a as Cs,g as Ci}from"./chunk-VYTQ6J56.js";import{a as Ri}from"./chunk-RZTZPIC5.js";import{c as As,g as Ti,h as Si,i as _i,m as Es}from"./chunk-6NWU3ML6.js";import{a as Do}from"./chunk-FQBBOFNP.js";import{a as oe}from"./chunk-Y5JU726N.js";import{b as Ss}from"./chunk-3CZWTXIR.js";import{d as Oo,i as vt,k as Bt,m as _s,n as ki}from"./chunk-4XXLWMY6.js";import{a as ao}from"./chunk-GRQ7JZZP.js";import{k as ut,l as Io,o as pe}from"./chunk-OSDQRSY6.js";import{c as Mt,d as Xn}from"./chunk-L3W2X74K.js";import{a as en,d as Cn,e as Ro,k as Wn,l as Mo,m as ks,r as Ts,v as vo,w as io,x as ro}from"./chunk-DSVLWYIT.js";import{GoogleGenAI as Kr,ThinkingLevel as Xe,HarmBlockThreshold as vn,HarmCategory as In}from"@google/genai";var Mi=(e=!0,t=!0)=>`
|
|
2
2
|
To use tools, must output exactly '[action:ActionName(arg1="value1")]' structured string in chat response \u2190 no exception
|
|
3
3
|
|
|
4
4
|
-- Chat Management Tools --
|
|
@@ -26,16 +26,16 @@ Usage Rules:
|
|
|
26
26
|
- Temporary memory is mandatory
|
|
27
27
|
- When called user memory, still use Temporary Memory
|
|
28
28
|
- Must not ignore any tool calls in given context of chat between user & agent`:""}`.trim();var Lo={xHigh:`Effort: High
|
|
29
|
-
Prefer simplest correct solution
|
|
30
|
-
|
|
31
|
-
Prefer simplest correct solution
|
|
32
|
-
|
|
33
|
-
Prefer simplest correct solution
|
|
34
|
-
|
|
35
|
-
Prefer simplest correct solution
|
|
36
|
-
|
|
29
|
+
Prefer simplest correct solution
|
|
30
|
+
Make direct deductions; avoid branching & token waste`,High:`Effort: High
|
|
31
|
+
Prefer simplest correct solution
|
|
32
|
+
Make direct deductions; avoid branching & token waste`,Medium:`Effort: Medium
|
|
33
|
+
Prefer simplest correct solution
|
|
34
|
+
Make direct deductions; avoid branching & token waste`,Minimal:`Effort: Low
|
|
35
|
+
Prefer simplest correct solution
|
|
36
|
+
Make direct deductions; avoid branching & token waste`,Off:`Effort: Lowest
|
|
37
37
|
No thinking. Immediate response
|
|
38
|
-
Verify imports, tool results & system stability`};import co from"fs";var yn=null,Rs=()=>{try{if(co.existsSync(
|
|
38
|
+
Verify imports, tool results & system stability`};import co from"fs";var yn=null,Rs=()=>{try{if(co.existsSync(vo)){let e=co.readFileSync(vo,"utf-8"),t=JSON.parse(e);if(t&&typeof t=="object")return yn=t,yn}}catch{}return yn=yn||{},yn},vi=e=>{try{return co.existsSync(en)||co.mkdirSync(en,{recursive:!0}),co.writeFileSync(vo,JSON.stringify(e,null,2),"utf-8"),yn=e,!0}catch{return!1}},He=(e,t,n)=>{if(!e||!t||!n)return null;let s=yn||Rs(),o=`${e}::${t}`,c=s[o];if(c&&typeof c=="object"){let f=n.toLowerCase();if(c[f]!==void 0&&c[f]!==null)return c[f];for(let[l,k]of Object.entries(c))if(l.toLowerCase()===f)return k}return null},ul=(e,t,n,s)=>{if(!e||!t||!n||!s)return{success:!1,reason:"Invalid arguments"};let o=yn||Rs(),c=`${e}::${t}`;return(!o[c]||typeof o[c]!="object")&&(o[c]={}),o[c][n.toLowerCase()]=s,{success:vi(o)}},gl=(e,t,n)=>{if(!e||!t)return{success:!1,reason:"Invalid arguments"};let s=yn||Rs(),o=`${e}::${t}`;return s[o]&&(n?(delete s[o][n.toLowerCase()],Object.keys(s[o]).length===0&&delete s[o]):delete s[o],vi(s)),{success:!0}};import tn from"fs";import cn from"path";import ma from"os";import ln from"fs";import Rn from"path";import Gi from"fs";import Ms from"path";import{execSync as ji}from"child_process";import{fileURLToPath as ha}from"url";var Ii=`# FluxFlow CLI Startup & Flags Reference
|
|
39
39
|
|
|
40
40
|
Launch command syntax:
|
|
41
41
|
fluxflow [options]
|
|
@@ -64,7 +64,7 @@ fluxflow [options]
|
|
|
64
64
|
* --help commands \u2192 In-chat slash commands list
|
|
65
65
|
* --playground \u2192 Launch Playground mode
|
|
66
66
|
* --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\`
|
|
67
|
-
`;var
|
|
67
|
+
`;var Oi=`# Env Variables
|
|
68
68
|
|
|
69
69
|
* Locations:
|
|
70
70
|
* Shell
|
|
@@ -93,7 +93,7 @@ fluxflow [options]
|
|
|
93
93
|
|
|
94
94
|
* 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
|
|
95
95
|
* GOOGLE_GEMMA_NONSENSE \u2192 (true|false, default: false) for the 16k TPM nonsense of gemma models on gemini API. False defaults to 256k
|
|
96
|
-
`;var
|
|
96
|
+
`;var Di=`# Fluxflow in-app /commands
|
|
97
97
|
|
|
98
98
|
Trigger in chat via /command
|
|
99
99
|
|
|
@@ -185,7 +185,7 @@ Open in chat via /settings
|
|
|
185
185
|
* Compact Large Tool Results \u2192 Compress large tool outputs to save tokens (model might miss subtle indentation/syntax errors)
|
|
186
186
|
* Context Length \u2192 Set usable context window size in FluxFlow. 16k, 32k, 64k, 128k, 256k, 512k, 1M. After Limit reached: Start new chat
|
|
187
187
|
* Auto Truncate Results \u2192 Auto-truncate tool results after task finished to save token and improve caching
|
|
188
|
-
* Image History for CU \u2192 Number of images to keep in context for Computer Use. Low (
|
|
188
|
+
* Image History for CU \u2192 Number of images to keep in context for Computer Use. Low (3 images, Low Context Accuracy, Token Efficient) / Standard (5 images, Better Accuracy, Higher Token Usage) / Extended (10 images, Better for complex tasks, Highest Token Usage) / Max (999 images, Full history kept, Maximum Accuracy, Highest Token Usage)
|
|
189
189
|
* Keep Reasoning Content \u2192 Keeps the exact reasoning of model in context for next turns. Uses more tokens. Might improve planning accuracy for very few models
|
|
190
190
|
* 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
|
|
191
191
|
* Disable Todo \u2192 Disables Todo/Goal tool for Agent. Doesnt necessarily affect modern models
|
|
@@ -195,7 +195,7 @@ Open in chat via /settings
|
|
|
195
195
|
|
|
196
196
|
- Best for General Use: Subagents (on), compact large results (off), auto exclue metadata (off), Image History (Standard), Keep reasoning content (off), Emergency Recovery (off), Auto truncate results (on), Memory (off), FluxFlow IDE Companion
|
|
197
197
|
|
|
198
|
-
- Best for Luxurious Experience: Subagents (on), compact large results (off), auto exclue metadata (off), Image History (
|
|
198
|
+
- Best for Luxurious Experience: Subagents (on), compact large results (off), auto exclue metadata (off), Image History (Max), Keep reasoning content (on), Emergency Recovery (on), Auto truncate results (off), Memory (on), Security Preset (Autonomous), FluxFlow IDE Companion
|
|
199
199
|
|
|
200
200
|
- Max Cache Hit: Subagents (off), compact large results (on), auto exclue metadata (on), Image History (Low), Keep reasoning content (off), Emergency Recovery (off), Auto truncate results (off), Memory (off), No FluxFlow IDE Companion
|
|
201
201
|
`;var Pi=`# FluxFlow Tool Reference
|
|
@@ -433,7 +433,7 @@ Instruction for this model ID across all providers.
|
|
|
433
433
|
|
|
434
434
|
* On-Demand Reference System:
|
|
435
435
|
* Reference: Offload deep/contexual specs to **/{SKILL.md,skill-reference-folder/*.md} & reference in SKILL.md. Saves tokens
|
|
436
|
-
`;var Po="v4";try{let e=
|
|
436
|
+
`;var Po="v4";try{let e=Ms.dirname(ha(import.meta.url)),t=[Ms.join(e,"../../package.json"),Ms.join(e,"../package.json")],n=!1;for(let s of t)if(Gi.existsSync(s)){let o=JSON.parse(Gi.readFileSync(s,"utf8"));if(o.version){Po=o.version,n=!0;break}}if(!n)try{let s=ji("fluxflow -v",{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"],timeout:2e3}).trim();s&&(s.startsWith("v")||/^\d+\.\d+/.test(s))&&(Po=s,n=!0)}catch{}if(!n)try{let s=ji("curl -s --max-time 3 https://raw.githubusercontent.com/KushalRoyChowdhury/fluxflow-cli/main/package.json",{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"]}),o=JSON.parse(s);o.version&&(Po=o.version)}catch{}}catch{}var vs={"SKILL.md":`---
|
|
437
437
|
name: fluxflow
|
|
438
438
|
description: System Generated Documentation. Read this if asked anything regarding FluxFlow Harness
|
|
439
439
|
---
|
|
@@ -460,40 +460,39 @@ Public Docs: https://fluxflow-cli.onrender.com
|
|
|
460
460
|
|
|
461
461
|
Default Context Length: 256k Tokens. Can be changed via ENV/In-app Settings \u2192 references/{SETTINGS,ENV}.md
|
|
462
462
|
|
|
463
|
-
Docs missing required info? Say you are not sure enough to answer. Dont give wrong info`,"references/MODES.md":Ui,"references/PROVIDERS.md":Wi,"references/PLUGINS.md":Hi,"references/STARTUP.md":Ii,"references/ENV.md":
|
|
464
|
-
`,
|
|
465
|
-
`)},Qi=()=>ho(en,["agents.md","agent.md"]),Zi=()=>ho(process.cwd(),["agents.md","agent.md"]),er=()=>ho(en,["fluxflow.md"]),tr=()=>ho(process.cwd(),["fluxflow.md"]),$o=Qi(),Ls=Zi(),
|
|
463
|
+
Docs missing required info? Say you are not sure enough to answer. Dont give wrong info`,"references/MODES.md":Ui,"references/PROVIDERS.md":Wi,"references/PLUGINS.md":Hi,"references/STARTUP.md":Ii,"references/ENV.md":Oi,"references/COMMANDS.md":Di,"references/SETTINGS.md":Li,"references/TOOLS.md":Pi,"references/ARCHITECTURE.md":$i,"references/SUB_AGENTS.md":Ni,"references/SECURITY.md":Fi,"references/IDE.md":Bi};var Ki=()=>{try{let e=Rn.join(en,"skills","fluxflow"),t=Rn.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===!0||!1){ln.existsSync(e)&&ln.rmSync(e,{recursive:!0,force:!0});return}let s=new Set(Object.keys(vs).map(o=>Rn.normalize(o)));for(let[o,c]of Object.entries(vs)){let f=Rn.join(e,o),l=Rn.dirname(f);ln.existsSync(l)||ln.mkdirSync(l,{recursive:!0});let k=c.trim()+`
|
|
464
|
+
`,p=null;ln.existsSync(f)&&(p=ln.readFileSync(f,"utf8")),p!==k&&ln.writeFileSync(f,k,"utf8")}if(ln.existsSync(t)){let o=ln.readdirSync(t);for(let c of o){let f=Rn.normalize(Rn.join("references",c));if(!s.has(f)){let l=Rn.join(t,c);try{ln.rmSync(l,{recursive:!0,force:!0})}catch{}}}}}catch{}};var ho=(e,t)=>{try{if(!tn.existsSync(e))return null;let n=Array.isArray(t)?t.map(o=>o.toLowerCase()):[t.toLowerCase()],s=tn.readdirSync(e);for(let o of n){let c=s.find(f=>f.toLowerCase()===o);if(c){let f=cn.join(e,c);if(tn.statSync(f).isFile())return f}}}catch{}return null},$s=(e,t)=>{let n=ho(e,t);if(n)try{return tn.readFileSync(n,"utf8")}catch{}return""},Vi=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"]),Ns=(e=process.cwd(),t=0,n=8)=>{let s=[];if(t>n)return s;try{if(!tn.existsSync(e))return s;let o=tn.readdirSync(e,{withFileTypes:!0});for(let c of o){let f=c.name,l=cn.join(e,f);if(c.isDirectory())!Vi.has(f)&&!Vi.has(f.toLowerCase())&&s.push(...Ns(l,t+1,n));else if(c.isFile()){let k=f.toLowerCase();(k==="agents.md"||k==="agent.md")&&s.push(l)}}}catch{}return s},Yi=(e,t=2)=>{if(!e)return"";let n=" ".repeat(t);return e.split(/\r?\n/).map(s=>n+s).join(`
|
|
465
|
+
`)},Qi=()=>ho(en,["agents.md","agent.md"]),Zi=()=>ho(process.cwd(),["agents.md","agent.md"]),er=()=>ho(en,["fluxflow.md"]),tr=()=>ho(process.cwd(),["fluxflow.md"]),$o=Qi(),Ls=Zi(),Mn=Ns(),No=er(),Fo=tr(),qi=null,Ps="",nr=!1,pa=e=>{if(!e||!/^<<<[\s\S]*?Identity:/m.test(e))return e;let t=e.match(/^<<<\s*\r?\n([\s\S]*?)\r?\n>>>\s*(?:\r?\n)?([\s\S]*)$/);if(!t)return e;let n=t[1],s=t[2],o=n.match(/^Identity:\s*([\s\S]*?)(?=\r?\n\s*(?:<><|>>>)|$)/m);return o&&(Ps=o[1].trim(),process.env.NO_INS=!0),/<><\s*NO_INS/.test(n)&&(nr=!0),s.trim()},ya=()=>($o=Qi(),$o?$s(en,["agents.md","agent.md"]).trim():""),xa=()=>{if(Mn=Ns(),Ls=Zi(),!Mn||Mn.length===0)return"";let e=process.cwd(),t=[...Mn].sort((s,o)=>{let c=cn.relative(e,s).replace(/\\/g,"/"),f=cn.relative(e,o).replace(/\\/g,"/"),l=!c.includes("/"),k=!f.includes("/");return l&&!k?-1:!l&&k?1:c.localeCompare(f)}),n=[];for(let s of t)try{let o=tn.readFileSync(s,"utf8").trim();if(!o)continue;let c=cn.relative(e,s).replace(/\\/g,"/");if(!c.includes("/"))n.push(Yi(o,2));else{let l=cn.dirname(c)+"/:";n.push(`${l}
|
|
466
466
|
${Yi(o,2)}`)}}catch{}return n.join(`
|
|
467
467
|
|
|
468
|
-
`).trim()},Fs=()=>{No=er();let e=No?$s(en,["fluxflow.md"]).trim():"";return
|
|
468
|
+
`).trim()},Fs=()=>{No=er();let e=No?$s(en,["fluxflow.md"]).trim():"";return pa(e)},Bs=()=>(Fo=tr(),Fo?$s(process.cwd(),["fluxflow.md"]).trim():""),Us=ya(),Bo=xa(),uo=Fs(),go=Bs(),zi=(e,t="",n="")=>{if(!e)return"";let s=n.toLowerCase().trim(),o=t.toLowerCase().trim(),c=cn.posix.basename(o),f=s&&o?`${s}::${o}`:"",l=s&&c?`${s}::${c}`:"",k=g=>!g||!o?!1:g===o||g===c||g===f||g===l,p=[];return e.replace(/<start_provider_([^>\r\n]+)>([\s\S]*?)<end_provider_([^>\r\n]+)>/gi,(g,T,m,i)=>{if(s&&T.trim().toLowerCase()===i.trim().toLowerCase()&&T.trim().toLowerCase()===s){let b=m.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(O,h,A,$)=>{if(h.trim().toLowerCase()===$.trim().toLowerCase()){let C=h.trim().toLowerCase();if(k(C)){let x=A.trim();x&&p.push(x)}}return""}).trim();b&&p.push(b)}return""}),e.replace(/<start_model_([^>\r\n]+::[^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+::[^>\r\n]+)>/gi,(g,T,m,i)=>{if(T.trim().toLowerCase()===i.trim().toLowerCase()){let u=T.trim().toLowerCase();if(f&&(u===f||l&&u===l)){let b=m.trim();b&&p.push(b)}}return""}),e.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(g,T,m,i)=>{if(T.includes("::"))return"";if(T.trim().toLowerCase()===i.trim().toLowerCase()){let u=T.trim().toLowerCase();if(o&&(u===o||u===c)){let b=m.trim();b&&p.push(b)}}return""}),p.join(`
|
|
469
469
|
|
|
470
470
|
`).trim()},ba=(e="",t="")=>{let n=`${e||""}::${t||""}`.toLowerCase().trim();qi!==n&&(qi=n,uo=Fs(),go=Bs())};Ki();var wa=e=>{if(!e)return null;let t=e.match(/^\s*---\r?\n([\s\S]*?)\r?\n---(?:\r?\n)?([\s\S]*)$/);if(!t)return null;let n=t[1];if((t[2]||"").trim().length===0)return null;let o="",c="",f=n.match(/^name:\s*(.+)$/m),l=n.match(/^description:\s*(.+)$/m);return f&&(o=f[1].trim().replace(/^["']|["']$/g,"")),l&&(c=l[1].trim().replace(/^["']|["']$/g,"")),o&&c?{name:o,description:c}:null},ka=e=>{let t=[];if(!e||!tn.existsSync(e))return t;let n=(s,o=0)=>{if(!(o>5))try{let c=tn.readdirSync(s,{withFileTypes:!0});for(let f of c){let l=cn.join(s,f.name),k=f.name.toLowerCase();f.isFile()?k==="skill.md"&&t.push(l):f.isDirectory()&&(o===0?(k==="skills"||k===".skills"||k==="skill"||k===".skill")&&n(l,o+1):n(l,o+1))}}catch{}};return n(e,0),t},or=e=>{let t=ka(e),n=[];for(let s of t)try{let o=tn.readFileSync(s,"utf8"),c=wa(o);c&&n.push({...c,filePath:s})}catch{}return n},sr=e=>!e||e.length===0?"":e.map(t=>`- ${t.name}: ${t.description}`).join(`
|
|
471
|
-
`),ir=or(en),rr=or(process.cwd()),Is=sr(ir),
|
|
471
|
+
`),ir=or(en),rr=or(process.cwd()),Is=sr(ir),Os=sr(rr),ar=e=>{if(!e)return!1;let t=(e.filePath||"").replace(/\\/g,"/").toLowerCase();return t.includes("/skills/fluxflow/skill.md")||t.includes("/skills/about-fluxflow/skill.md")||e.name?.toLowerCase()==="fluxflow"},lr=()=>(ir||[]).filter(e=>!ar(e)),cr=()=>(rr||[]).filter(e=>!ar(e)),ac=(Us?1:0)+(Mn?.length||(Bo?1:0))+(uo?1:0)+(go?1:0)+lr().length+cr().length,Ds=(e,t="Project")=>{if(!e)return"";let n=e.replace(/\\/g,"/");if(t==="Global"){let o=ma.homedir().replace(/\\/g,"/");return n.toLowerCase().startsWith(o.toLowerCase())?"~"+n.slice(o.length):n}let s=cn.relative(process.cwd(),e).replace(/\\/g,"/");return s.startsWith(".")?s:`./${s}`},lc=()=>{uo=Fs(),go=Bs();let e=[];$o&&Us.length>0&&e.push({scope:"Global",path:$o}),Mn&&Mn.length>0&&Bo.length>0?Mn.forEach(c=>{e.push({scope:"Project",path:c})}):Ls&&Bo.length>0&&e.push({scope:"Project",path:Ls}),No&&uo.length>0&&e.push({scope:"Global",path:No}),Fo&&go.length>0&&e.push({scope:"Project",path:Fo});let t=lr(),n=cr(),s=e.length+t.length+n.length;if(s===0)return`\u2726 Loaded Files & Instructions
|
|
472
472
|
\u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No instruction or skill files are currently loaded.
|
|
473
473
|
\u2800`;let o=[];return o.push(`\u2726 Loaded Files & Instructions (${s} ${s===1?"file":"files"} active)`),e.length>0&&(o.push(`
|
|
474
|
-
\x1B[1mInstructions:\x1B[22m`),e.forEach(c=>{o.push(` \u2022 [${c.scope}] ${
|
|
475
|
-
\x1B[1mSkills:\x1B[22m`),t?.length>0&&t.forEach(c=>{o.push(` \u2022 [Global] \x1B[36m${c.name}\x1B[39m`),o.push(` \x1B[2m\u2514\u2500 ${
|
|
476
|
-
`)},dr=!1;(async()=>{try{let e=await ao();if(Number(e?.display)===1){let{default:t}=await import("screenshot-desktop"),n=await t.listDisplays();n&&n.length>1&&(dr=!0)}}catch{}})();var Xi=null,fo=null,Ji=process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux",cc=process.env.NO_DEV||!1,Ta=(e,t)=>{if(!t)return"";if(e!==Xi||fo===null){Xi=e;try{let n=
|
|
474
|
+
\x1B[1mInstructions:\x1B[22m`),e.forEach(c=>{o.push(` \u2022 [${c.scope}] ${Ds(c.path,c.scope)}`)})),(t?.length>0||n?.length>0)&&(o.push(`
|
|
475
|
+
\x1B[1mSkills:\x1B[22m`),t?.length>0&&t.forEach(c=>{o.push(` \u2022 [Global] \x1B[36m${c.name}\x1B[39m`),o.push(` \x1B[2m\u2514\u2500 ${Ds(c.filePath,"Global")}\x1B[22m`)}),n?.length>0&&n.forEach(c=>{o.push(` \u2022 [Project] \x1B[36m${c.name}\x1B[39m`),o.push(` \x1B[2m\u2514\u2500 ${Ds(c.filePath,"Project")}\x1B[22m`)})),o.push("\u2800"),o.join(`
|
|
476
|
+
`)},dr=!1;(async()=>{try{let e=await ao();if(Number(e?.display)===1){let{default:t}=await import("screenshot-desktop"),n=await t.listDisplays();n&&n.length>1&&(dr=!0)}}catch{}})();var Xi=null,fo=null,Ji=process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux",cc=process.env.NO_DEV||!1,Ta=(e,t)=>{if(!t)return"";if(e!==Xi||fo===null){Xi=e;try{let n=Mt(Wn,[]);Array.isArray(n)&&n.length>0?fo=n.map(s=>`- ${s.memory}`).join(`
|
|
477
477
|
`):fo=""}catch(n){fo="",tn.appendFileSync(`${Cn}/memory/error.txt`,`${n.message}
|
|
478
478
|
-------------------------------------------------
|
|
479
479
|
|
|
480
|
-
`)}}return fo};var fr=(e,t,n,s,o=!0,c=!1,f="Google",l=!1,k,
|
|
480
|
+
`)}}return fo};var fr=(e,t,n,s,o=!0,c=!1,f="Google",l=!1,k,p,g=!1,T="")=>{let m=!1;process.env.forcedReasoning&&(m=!0);let i="";if(!k&&f==="Google"){let Z=t;t==="Fast"&&(Z="Off"),t==="Low"&&(Z="Minimal"),t==="Standard"&&(Z="Medium"),(t==="xHigh"||t==="Max")&&(Z="xHigh"),i=Lo[Z]||Lo.Medium}if(k||f!=="Google"){let Z={Fast:"Lowest",Low:"Low",Medium:"Medium",Standard:"Medium",High:"High",xHigh:"High",Max:"High"};i=Lo.xHigh,i=i.replace("Effort: High",`Effort: ${Z[t]}`),t==="Fast"?i=`Effort: Lowest
|
|
481
481
|
No thinking. Immediate response
|
|
482
482
|
Verify imports, tool results & system stability; avoid syntax errors`:t==="Low"&&(i=`Effort: Low
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
Verify imports, tool results & system stability; avoid syntax errors`)}let u=e.instructions&&e.instructions?.length>0?`User Preferences: ${e.instructions}
|
|
483
|
+
Prefer simplest correct solution
|
|
484
|
+
Make direct deductions; avoid branching & token waste`)}let u=e.instructions&&e.instructions?.length>0?`User Preferences: ${e.instructions}
|
|
486
485
|
|
|
487
|
-
`:"",
|
|
486
|
+
`:"",b=e.nickname&&e.nickname?.length>0?`User Nickname: ${e.nickname}
|
|
488
487
|
${u.length?"":`
|
|
489
|
-
`}`:"",
|
|
490
|
-
${
|
|
491
|
-
`}`:"",h=process.cwd(),A=Ta(
|
|
488
|
+
`}`:"",O=e.name&&e.name?.length>0?`User Name: ${e.name}
|
|
489
|
+
${b.length||u.length?"":`
|
|
490
|
+
`}`:"",h=process.cwd(),A=Ta(p,o),$=A?.length>0?`--- Saved Memories ---
|
|
492
491
|
${A}
|
|
493
492
|
|
|
494
|
-
`:"";ba(f,T);let C=zi(uo,T,f).trim(),_=[Us,C].filter(
|
|
493
|
+
`:"";ba(f,T);let C=zi(uo,T,f).trim(),_=[Us,C].filter(Z=>Z&&Z.length>0).join(`
|
|
495
494
|
|
|
496
|
-
`).trim(),
|
|
495
|
+
`).trim(),I=zi(go,T,f).trim(),a=[Bo,I].filter(Z=>Z&&Z.length>0).join(`
|
|
497
496
|
|
|
498
497
|
`).trim(),R=_.length>0||a.length>0?`--- Additional Instructions ---
|
|
499
498
|
${_.length>0?`-- Global --
|
|
@@ -502,17 +501,17 @@ ${_}`:""}${a.length>0?`${_.length>0?`
|
|
|
502
501
|
`:""}-- Project --
|
|
503
502
|
${a}`:""}
|
|
504
503
|
|
|
505
|
-
`:"",d=(()=>{let
|
|
504
|
+
`:"",d=(()=>{let Z=process.cwd().toLowerCase();if(process.platform==="win32"){let we=process.env.SystemRoot?.toLowerCase()||"c:\\windows",ce=process.env.ProgramFiles?.toLowerCase()||"c:\\program files",rt=process.env["ProgramFiles(x86)"]?.toLowerCase()||"c:\\program files (x86)";return Z.startsWith(we)||Z.startsWith(ce)||Z.startsWith(rt)}else return Z==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(ce=>Z.startsWith(ce))})(),r=new Date,E=r.getFullYear(),M=r.toLocaleString("en-US",{month:"short"}).toUpperCase(),U=String(r.getDate()).padStart(2,"0"),D=`${E}-${M}-${U}`,P=!!s?.autoExcludeMetadata,le=process.env.I_HAVE_TOO_MUCH_MONEY==="true"||process.env.I_HAVE_TOO_MUCH_MONEY===!0||!1,fe=process.env.NO_DEV==="true"||process.env.NO_DEV==="1"||process.env.NO_DEV===!0||!1;return`${le?`${" ".repeat(Math.floor(Math.random()*4)+1)}`:""}=== SYSTEM PROMPT ===
|
|
506
505
|
Identity: ${Ps.length>1?Ps.trim():"Flux Flow. Sassy, CLI Assistant"}
|
|
507
506
|
${nr?"":`${n==="Flux"?"Run Automated Tests":n==="Flow"?"Concise, Humorous, Sarcastic":n==="ICU"?"Computer Use Capabilities. Screenshot as ground truth, analyze grid ids overlapping/close to target, keyboard shortcuts > mouse clicks":"Computer Use & Workspace Capabilities. Screenshot as ground truth, analyze grid ids overlapping/close to target, keyboard shortcuts > mouse clicks. Workspace Tools if faster. Focus on Productivity"}`}${dr&&n.toLowerCase().includes("cu")?`
|
|
508
507
|
- Running on secondary screen. Opened app not visible in screenshot? Might be opened on primary. Use 'AskUser' with NO options and tell user to move app window to secondary`:""}
|
|
509
508
|
|
|
510
|
-
- OS: ${Ji}${!
|
|
511
|
-
- Model: ${cn.basename(T.trim()).replace(":free","").replace("-free","").replace("/free","").replace("_free","").replace("free_","").replaceAll("-"," ").replaceAll("_"," ").replace(/\b\w/g,
|
|
512
|
-
- Date: ${
|
|
509
|
+
- OS: ${Ji}${!fe&&T.length>1?`
|
|
510
|
+
- Model: ${cn.basename(T.trim()).replace(":free","").replace("-free","").replace("/free","").replace("_free","").replace("free_","").replaceAll("-"," ").replaceAll("_"," ").replace(/\b\w/g,Z=>Z.toUpperCase())}`.trimEnd():""}${P?`
|
|
511
|
+
- Date: ${D}`:""}
|
|
513
512
|
|
|
514
513
|
-- REASONING GUIDANCE --
|
|
515
|
-
${f==="Mistral"||f==="Google"&&!k?`${i.trimEnd()}${
|
|
514
|
+
${f==="Mistral"||f==="Google"&&!k?`${i.trimEnd()}${m||t!=="Fast"&&(f==="Mistral"&&t==="Low"&&!k||t!=="High"&&!k)?`
|
|
516
515
|
Critical Thinking Policy
|
|
517
516
|
|
|
518
517
|
Use <think>...</think> for reasoning before responding any queries
|
|
@@ -523,15 +522,15 @@ ${Ei(n,Ji,l,f,s?.advanceRollback,s?.subAgents!==!1,!!s?.autoExec,!!s?.disableTod
|
|
|
523
522
|
|
|
524
523
|
-- SECURITY POLICIES --
|
|
525
524
|
- Dont operate on ANY confidential screens`:""}
|
|
526
|
-
=== END SYSTEM PROMPT ===${(Is.length>0||
|
|
525
|
+
=== END SYSTEM PROMPT ===${(Is.length>0||Os.length>0)&&n.toLowerCase().includes("flux")?`
|
|
527
526
|
|
|
528
527
|
- Read relevant skills before tasks, scope: global/project: Use ReadFile, path="#skills/scope?/skillName". In-skill references: path="#skills/scope?/skillName/reference-folder/*.md"`:""}
|
|
529
528
|
|
|
530
|
-
${
|
|
529
|
+
${b}${u}${R}${Is.length>0&&n.toLowerCase().includes("flux")?`-- Global Skills --
|
|
531
530
|
${Is}
|
|
532
531
|
|
|
533
|
-
`:""}${
|
|
534
|
-
${
|
|
532
|
+
`:""}${Os.length>0&&n.toLowerCase().includes("flux")?`-- Project Skills --
|
|
533
|
+
${Os}
|
|
535
534
|
|
|
536
535
|
`:""}${$}`.trim()},ur=(e="",t=!0,n=!0)=>`=== SYSTEM PROMPT (strict headless logic worker: zero user-facing text policy, strictly follow) ===
|
|
537
536
|
identity: silent background system process, have no mouth, only output is valid tool calls
|
|
@@ -550,64 +549,64 @@ identity: silent background system process, have no mouth, only output is valid
|
|
|
550
549
|
YOUR JOB: Analyze the 'User prompt' and 'Agent Raws' to extract facts for long-term memory or handle system tasks
|
|
551
550
|
${t?"If user tell something that is important (like, hobbies, preferences, facts about user, hates, likes, etc) to know user better over time, use user memory tools":""}
|
|
552
551
|
|
|
553
|
-
${
|
|
552
|
+
${Mi(t,n)}
|
|
554
553
|
=== END SYSTEM PROMPT ===${e?`
|
|
555
554
|
|
|
556
555
|
-- current saved user memories --
|
|
557
|
-
${e}`:""}`.trim();var gr=()=>import("./web_search-2PFIJKIL.js").then(e=>e.web_search),hr=()=>import("./web_scrape-BHSQTMX4.js").then(e=>e.web_scrape),pr=()=>import("./memory-M7ASUB6J.js").then(e=>e.memory),mr=()=>import("./chat-MELTWDZ3.js").then(e=>e.chat),yr=()=>import("./view_file-2THVIMD6.js").then(e=>e.view_file),xr=()=>import("./write_file-7X2GQFWK.js").then(e=>e.write_file),br=()=>import("./update_file-PXZHSSGS.js").then(e=>e.update_file),wr=()=>import("./exec_command-J23EG77W.js").then(e=>e.exec_command),kr=()=>import("./read_folder-EI2CNHNS.js").then(e=>e.read_folder),Ws=()=>import("./ask_user-K2DLZF6H.js").then(e=>e.ask_user),Tr=()=>import("./write_pdf-N2Q4Z3YP.js").then(e=>e.write_pdf),Sr=()=>import("./write_docx-4Y43QJUV.js").then(e=>e.write_docx),Uo=()=>import("./search_keyword-CSRQFPHQ.js").then(e=>e.search_keyword),_r=()=>import("./generate_image-4LIDEIYO.js").then(e=>e.generate_image),Wo=()=>import("./saveSummary-UGNDVNI5.js").then(e=>e.saveSummary),po=()=>import("./addMemScore-BCPTSMKD.js").then(e=>e.addMemScore),Ar=()=>import("./file_map-KS6Y7BP3.js").then(e=>e.file_map),Ho=()=>import("./todo-GFMPH2JV.js").then(e=>e.todo),Er=()=>import("./invokeSync-RR6HNW42.js").then(e=>e.invokeSync),Sa=()=>import("./invoke-CYOAQYP6.js").then(e=>e.invoke),Cr=()=>import("./getProgress-A2TW34Q7.js").then(e=>e.getProgress),_a=()=>import("./cancel-F3ZOEBKW.js").then(e=>e.cancel),Rr=()=>import("./emergency_rollback-6X27LZE4.js").then(e=>e.emergency_rollback),mo=()=>import("./awaitSubagent-JKQ2EHVY.js").then(e=>e.awaitSubagent),yo=()=>import("./answerSubagent-BPNNJXPC.js").then(e=>e.answerSubagent),Go=()=>import("./steerSubagent-UETXH2CB.js").then(e=>e.steerSubagent),jo=()=>import("./computer_action-OQ3CWQU3.js").then(e=>e.computer_action),vr=()=>import("./click-RDFFRPIN.js").then(e=>e.click),Mr=()=>import("./drag-RLRC6JFF.js").then(e=>e.drag),Ir=()=>import("./scroll-QVQD7I6A.js").then(e=>e.scroll),Hs=()=>import("./keyboard_typing-RPPKNVTA.js").then(e=>e.keyboard_typing),Gs=()=>import("./key_press-7F6CAPZD.js").then(e=>e.key_press),js=()=>import("./recapture_screen-PPT2E3CK.js").then(e=>e.recapture_screen),Ko=()=>import("./find_file-A6NYLQJS.js").then(e=>e.find_file),Aa={web_search:gr,web_scrape:hr,memory:pr,chat:mr,view_file:yr,write_file:xr,update_file:br,exec_command:wr,read_folder:kr,write_pdf:Tr,write_docx:Sr,search_keyword:Uo,generate_image:_r,saveSummary:Wo,addMemScore:po,file_map:Ar,todo:Ho,Todo:Ho,goal:Ho,Goal:Ho,invokeSync:Er,invoke:Sa,getProgress:Cr,cancel:_a,awaitSubagent:mo,answerSubagent:yo,steerSubagent:Go,computer_action:jo,computer_use:jo,ComputerAction:jo,ComputerUse:jo,click:vr,Click:vr,drag:Mr,Drag:Mr,scroll:Ir,Scroll:Ir,keyboard_typing:Hs,KeyboardTyping:Hs,keyboardtyping:Hs,key_press:Gs,KeyPress:Gs,keypress:Gs,recapture_screen:js,RecaptureScreen:js,recapturescreen:js,invoke_sync:Er,get_progress:Cr,await_subagent:mo,answer_subagent:yo,steer_subagent:Go,steer:Go,Steer:Go,ask:Ws,Ask:Ws,AskUser:Ws,WebSearch:gr,WebScrape:hr,ReadFile:yr,ReadFolder:kr,WriteFile:xr,PatchFile:br,WritePDF:Tr,WriteDoc:Sr,Run:wr,SearchKeyword:Uo,CodeSearch:Uo,code_search:Uo,Memory:pr,Chat:mr,GenerateImage:_r,saveSumary:Wo,SaveSummary:Wo,SaveSumary:Wo,add_mem_score:po,AddMemScore:po,addMemoryScore:po,AddMemoryScore:po,FileMap:Ar,answer:yo,Answer:yo,AnswerSubagent:yo,await:mo,Await:mo,AwaitSubagent:mo,EmergencyRollback:Rr,emergency_rollback:Rr,find_file:Ko,findFile:Ko,FindFile:Ko,findfile:Ko},xo=async(e,t,n={})=>{let s=n.mode?n.mode.toLowerCase():"flux",o=e.toLowerCase(),f=["memory","chat","savesummary","addmemscore","add_mem_score","ask","web_search","web_scrape","await"].some(g=>o.includes(g))||o==="ask",k=["click","drag","scroll","keyboardtyping","keyboard_typing","keypress","key_press","recapturescreen","recapture_screen","computer"].some(g=>o.includes(g));if(!f){if(s==="flow"){if(!(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image")))return`ERROR: Action [${e}] is a Workspace Tool and NOT available in Flow mode. Tell user to switch (\`/mode flux\`) to use this tool.`}else if(s==="icu"){if(!k)return`ERROR: Action [${e}] is not available in Computer Use mode. ICU mode only supports Computer Use tools (Click, Drag, Scroll, KeyboardTyping, KeyPress, RecaptureScreen).`}else if(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image"))return`ERROR: Action [${e}] is not available in ${n.mode||"Flux"} mode. Tell user to switch (\`/mode flow\`) for document generation.`}let m=Aa[e];if(!m){let g=["ReadFile","ReadFolder","FindFile","PatchFile","WriteFile","CodeSearch","Run","Goal","AskUser","WebSearch","WebScrape","WritePDF","WriteDoc","Click","Drag","Scroll","KeyboardTyping","KeyPress","RecaptureScreen","Invoke","InvokeSync","Await","GetProgress","Steer","Cancel","EmergencyRollback","Chat","Memory"],T={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,""),i=T[p]||null;if(!i){let w=0,I=A=>{let $=new Set;for(let C=0;C<A.length-1;C++)$.add(A.slice(C,C+2));return $},h=I(p);for(let A of g){let $=A.toLowerCase().replace(/[^a-z0-9]/g,"");if(p===$){i=A;break}let C=0;($.includes(p)||p.includes($))&&(C+=.6);let x=I($),_=0;for(let y of h)x.has(y)&&_++;let M=2*_/(h.size+x.size||1);C=Math.max(C,M),C>w&&C>=.35&&(w=C,i=A)}}let u=i?` Do you mean '${i}'?`:"";return`ERROR: Action [${e}] not found in registry.${u}`}try{return await(await m())(t,n)}catch(g){let T=g instanceof Error?g.message:String(g);return`ERROR: Execution failed for [${e}]: ${T}`}};import ie from"path";import Ue from"fs";import Ea from"gradient-string";var Ks=["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 Dr=[{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"]}],bo={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"]},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"]},"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"]},"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"]},"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:void 0,diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:void 0,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"]},"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:void 0,diffAdditionHighlightColor:"#004000",diffAdditionHighlightBg:void 0,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"]},"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"]},"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"]}};var Vo=null;var Or=(e="Dark")=>{let t;e==="Mystery"||e==="Chaos"?(Vo||(Vo=Dr[Math.floor(Math.random()*Dr.length)]),t={...Vo,id:"Mystery"}):(Vo=null,bo[e]?t=bo[e]:e==="GitHub"?t=bo["GitHub Dark"]:e==="Transparent"?t=bo["Transparent Dark"]:t=bo.Dark);let n=t.codeText||t.secondary||t.info||t.logoGradient&&t.logoGradient[0]||"cyan";return{...t,codeText:n}};var Ca=()=>process.env.TERM_PROGRAM==="vscode"?"vscode":process.env.WT_SESSION?"wt":"default",yc=(e=2)=>{let t=Ca();return t==="wt"?" ".repeat(Math.max(1,e-1)):" ".repeat(e)},xc=(e="...",t="Loading...",n="Dark")=>{let s=Ks[Math.floor(Math.random()*Ks.length)],o=Or(n),c=o.logoTextAnsi,f=o.logoBodyAnsi,l=o.logoMutedAnsi,k="\x1B[0m",m=[" \u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2591 "," \u2588\u2588\u2588\u2591 "," \u2588\u2588\u2588\u2591 "," \u2591\u2591\u2591 "],g=o.logoGradient||["#0077ff","#ff00ff"],T=Ea(g).multiline(m.join(`
|
|
556
|
+
${e}`:""}`.trim();var gr=()=>import("./web_search-2PFIJKIL.js").then(e=>e.web_search),hr=()=>import("./web_scrape-BHSQTMX4.js").then(e=>e.web_scrape),mr=()=>import("./memory-M7ASUB6J.js").then(e=>e.memory),pr=()=>import("./chat-MELTWDZ3.js").then(e=>e.chat),yr=()=>import("./view_file-2THVIMD6.js").then(e=>e.view_file),xr=()=>import("./write_file-7X2GQFWK.js").then(e=>e.write_file),br=()=>import("./update_file-KNEQRJAG.js").then(e=>e.update_file),wr=()=>import("./exec_command-J23EG77W.js").then(e=>e.exec_command),kr=()=>import("./read_folder-EI2CNHNS.js").then(e=>e.read_folder),Ws=()=>import("./ask_user-K2DLZF6H.js").then(e=>e.ask_user),Tr=()=>import("./write_pdf-N2Q4Z3YP.js").then(e=>e.write_pdf),Sr=()=>import("./write_docx-4Y43QJUV.js").then(e=>e.write_docx),Uo=()=>import("./search_keyword-CSRQFPHQ.js").then(e=>e.search_keyword),_r=()=>import("./generate_image-4LIDEIYO.js").then(e=>e.generate_image),Wo=()=>import("./saveSummary-UGNDVNI5.js").then(e=>e.saveSummary),mo=()=>import("./addMemScore-BCPTSMKD.js").then(e=>e.addMemScore),Ar=()=>import("./file_map-KS6Y7BP3.js").then(e=>e.file_map),Ho=()=>import("./todo-GFMPH2JV.js").then(e=>e.todo),Er=()=>import("./invokeSync-PAOUTNOW.js").then(e=>e.invokeSync),Sa=()=>import("./invoke-G5IJ3VPK.js").then(e=>e.invoke),Cr=()=>import("./getProgress-A2TW34Q7.js").then(e=>e.getProgress),_a=()=>import("./cancel-F3ZOEBKW.js").then(e=>e.cancel),Rr=()=>import("./emergency_rollback-6X27LZE4.js").then(e=>e.emergency_rollback),po=()=>import("./awaitSubagent-JKQ2EHVY.js").then(e=>e.awaitSubagent),yo=()=>import("./answerSubagent-BPNNJXPC.js").then(e=>e.answerSubagent),Go=()=>import("./steerSubagent-UETXH2CB.js").then(e=>e.steerSubagent),jo=()=>import("./computer_action-RTEC7VUX.js").then(e=>e.computer_action),Mr=()=>import("./click-5I5YOSNC.js").then(e=>e.click),vr=()=>import("./drag-6TRBT2C3.js").then(e=>e.drag),Ir=()=>import("./scroll-7JYRU34H.js").then(e=>e.scroll),Hs=()=>import("./keyboard_typing-F2SAZLI2.js").then(e=>e.keyboard_typing),Gs=()=>import("./key_press-Z3OXF74E.js").then(e=>e.key_press),js=()=>import("./recapture_screen-PPT2E3CK.js").then(e=>e.recapture_screen),Ko=()=>import("./find_file-A6NYLQJS.js").then(e=>e.find_file),Aa={web_search:gr,web_scrape:hr,memory:mr,chat:pr,view_file:yr,write_file:xr,update_file:br,exec_command:wr,read_folder:kr,write_pdf:Tr,write_docx:Sr,search_keyword:Uo,generate_image:_r,saveSummary:Wo,addMemScore:mo,file_map:Ar,todo:Ho,Todo:Ho,goal:Ho,Goal:Ho,invokeSync:Er,invoke:Sa,getProgress:Cr,cancel:_a,awaitSubagent:po,answerSubagent:yo,steerSubagent:Go,computer_action:jo,computer_use:jo,ComputerAction:jo,ComputerUse:jo,click:Mr,Click:Mr,drag:vr,Drag:vr,scroll:Ir,Scroll:Ir,keyboard_typing:Hs,KeyboardTyping:Hs,keyboardtyping:Hs,key_press:Gs,KeyPress:Gs,keypress:Gs,recapture_screen:js,RecaptureScreen:js,recapturescreen:js,invoke_sync:Er,get_progress:Cr,await_subagent:po,answer_subagent:yo,steer_subagent:Go,steer:Go,Steer:Go,ask:Ws,Ask:Ws,AskUser:Ws,WebSearch:gr,WebScrape:hr,ReadFile:yr,ReadFolder:kr,WriteFile:xr,PatchFile:br,WritePDF:Tr,WriteDoc:Sr,Run:wr,SearchKeyword:Uo,CodeSearch:Uo,code_search:Uo,Memory:mr,Chat:pr,GenerateImage:_r,saveSumary:Wo,SaveSummary:Wo,SaveSumary:Wo,add_mem_score:mo,AddMemScore:mo,addMemoryScore:mo,AddMemoryScore:mo,FileMap:Ar,answer:yo,Answer:yo,AnswerSubagent:yo,await:po,Await:po,AwaitSubagent:po,EmergencyRollback:Rr,emergency_rollback:Rr,find_file:Ko,findFile:Ko,FindFile:Ko,findfile:Ko},xo=async(e,t,n={})=>{let s=n.mode?n.mode.toLowerCase():"flux",o=e.toLowerCase(),f=["memory","chat","savesummary","addmemscore","add_mem_score","ask","web_search","web_scrape","await"].some(g=>o.includes(g))||o==="ask",k=["click","drag","scroll","keyboardtyping","keyboard_typing","keypress","key_press","recapturescreen","recapture_screen","computer"].some(g=>o.includes(g));if(!f){if(s==="flow"){if(!(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image")))return`ERROR: Action [${e}] is a Workspace Tool and NOT available in Flow mode. Tell user to switch (\`/mode flux\`) to use this tool.`}else if(s==="icu"){if(!k)return`ERROR: Action [${e}] is not available in Computer Use mode. ICU mode only supports Computer Use tools (Click, Drag, Scroll, KeyboardTyping, KeyPress, RecaptureScreen).`}else if(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image"))return`ERROR: Action [${e}] is not available in ${n.mode||"Flux"} mode. Tell user to switch (\`/mode flow\`) for document generation.`}let p=Aa[e];if(!p){let g=["ReadFile","ReadFolder","FindFile","PatchFile","WriteFile","CodeSearch","Run","Goal","AskUser","WebSearch","WebScrape","WritePDF","WriteDoc","Click","Drag","Scroll","KeyboardTyping","KeyPress","RecaptureScreen","Invoke","InvokeSync","Await","GetProgress","Steer","Cancel","EmergencyRollback","Chat","Memory"],T={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"},m=o.replace(/[^a-z0-9]/g,""),i=T[m]||null;if(!i){let b=0,O=A=>{let $=new Set;for(let C=0;C<A.length-1;C++)$.add(A.slice(C,C+2));return $},h=O(m);for(let A of g){let $=A.toLowerCase().replace(/[^a-z0-9]/g,"");if(m===$){i=A;break}let C=0;($.includes(m)||m.includes($))&&(C+=.6);let x=O($),_=0;for(let y of h)x.has(y)&&_++;let I=2*_/(h.size+x.size||1);C=Math.max(C,I),C>b&&C>=.35&&(b=C,i=A)}}let u=i?` Do you mean '${i}'?`:"";return`ERROR: Action [${e}] not found in registry.${u}`}try{return await(await p())(t,n)}catch(g){let T=g instanceof Error?g.message:String(g);return`ERROR: Execution failed for [${e}]: ${T}`}};import ae from"path";import Ue from"fs";import Ea from"gradient-string";var Ks=["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 Or=[{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"]}],bo={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"]},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"]},"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"]},"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"]},"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:void 0,diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:void 0,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"]},"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:void 0,diffAdditionHighlightColor:"#004000",diffAdditionHighlightBg:void 0,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"]},"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"]},"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"]}};var Vo=null;var Dr=(e="Dark")=>{let t;e==="Mystery"||e==="Chaos"?(Vo||(Vo=Or[Math.floor(Math.random()*Or.length)]),t={...Vo,id:"Mystery"}):(Vo=null,bo[e]?t=bo[e]:e==="GitHub"?t=bo["GitHub Dark"]:e==="Transparent"?t=bo["Transparent Dark"]:t=bo.Dark);let n=t.codeText||t.secondary||t.info||t.logoGradient&&t.logoGradient[0]||"cyan";return{...t,codeText:n}};var Ca=()=>process.env.TERM_PROGRAM==="vscode"?"vscode":process.env.WT_SESSION?"wt":"default",yc=(e=2)=>{let t=Ca();return t==="wt"?" ".repeat(Math.max(1,e-1)):" ".repeat(e)},xc=(e="...",t="Loading...",n="Dark")=>{let s=Ks[Math.floor(Math.random()*Ks.length)],o=Dr(n),c=o.logoTextAnsi,f=o.logoBodyAnsi,l=o.logoMutedAnsi,k="\x1B[0m",p=[" \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 "],g=o.logoGradient||["#0077ff","#ff00ff"],T=Ea(g).multiline(p.join(`
|
|
558
557
|
`)).split(`
|
|
559
|
-
`),
|
|
558
|
+
`),m=i=>`${l}${i}${k}`;return`${T[0]}
|
|
560
559
|
${T[1]} ${c}Selected Provider: ${t}${k}
|
|
561
560
|
${T[2]}
|
|
562
|
-
${T[3]} ${c}FluxFlow ${
|
|
561
|
+
${T[3]} ${c}FluxFlow ${m("v"+e)}${k}
|
|
563
562
|
${T[4]}
|
|
564
563
|
${T[5]} ${f}See /help for additional commands.${k}
|
|
565
|
-
${T[6]} ${
|
|
564
|
+
${T[6]} ${m(s)}
|
|
566
565
|
${T[7]}
|
|
567
|
-
`};import{WebSocket as Yo}from"ws";var Ut=null,Jn=!1,Ra="ws://localhost:56832",Vs=[],Qn=null,Ys=null,Lr="2.0.0",kc=e=>{Lr=e,Pr()},qs=e=>{Ys=e},Pr=()=>{if(Ut||Jn)return;Jn=!0;let e=new Yo(Ra);e.on("open",()=>{for(Ut=e,Jn=!1,Ut.send(JSON.stringify({command:"version",version:Lr,pid:process.pid,ppid:process.ppid}));Vs.length>0;)Ut.send(JSON.stringify(Vs.shift()))}),e.on("message",t=>{try{let n=JSON.parse(t.toString());n.command==="contextResponse"&&Qn?(Qn(n.data),Qn=null):n.command==="securityResponse"&&Ys&&Ys(n.result)}catch{}}),e.on("error",()=>{Jn=!1,Ut=null}),e.on("close",()=>{Jn=!1,Ut=null})},qo=e=>{Ut&&Ut.readyState===Yo.OPEN?Ut.send(JSON.stringify(e)):(Vs.push(e),Jn||Pr())},zo=()=>Ut!==null&&Ut.readyState===Yo.OPEN,Tc=e=>{qo({command:"status",status:e})},Hn=()=>new Promise(e=>{if(!Ut||Ut.readyState!==Yo.OPEN){e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]});return}Qn=e,Ut.send(JSON.stringify({command:"requestContext"})),setTimeout(()=>{Qn===e&&(e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]}),Qn=null)},1e3)}),$r=e=>{qo({command:"open",filePath:e})},zs=(e,t,n)=>{qo({command:"showDiff",filePath:e,originalContent:t,modifiedContent:n})},Nr=(e,t)=>{qo({command:"closeDiff",filePath:e,result:t})};import Xs from"path";import
|
|
568
|
-
`)}else
|
|
569
|
-
`);let
|
|
570
|
-
`);for(let{displayName:x,subDirPath:_,subEntries:
|
|
571
|
-
`,
|
|
572
|
-
`),
|
|
573
|
-
`;let k="",
|
|
566
|
+
`};import{WebSocket as Yo}from"ws";var Ut=null,Jn=!1,Ra="ws://localhost:56832",Vs=[],Qn=null,Ys=null,Lr="2.0.0",kc=e=>{Lr=e,Pr()},qs=e=>{Ys=e},Pr=()=>{if(Ut||Jn)return;Jn=!0;let e=new Yo(Ra);e.on("open",()=>{for(Ut=e,Jn=!1,Ut.send(JSON.stringify({command:"version",version:Lr,pid:process.pid,ppid:process.ppid}));Vs.length>0;)Ut.send(JSON.stringify(Vs.shift()))}),e.on("message",t=>{try{let n=JSON.parse(t.toString());n.command==="contextResponse"&&Qn?(Qn(n.data),Qn=null):n.command==="securityResponse"&&Ys&&Ys(n.result)}catch{}}),e.on("error",()=>{Jn=!1,Ut=null}),e.on("close",()=>{Jn=!1,Ut=null})},qo=e=>{Ut&&Ut.readyState===Yo.OPEN?Ut.send(JSON.stringify(e)):(Vs.push(e),Jn||Pr())},zo=()=>Ut!==null&&Ut.readyState===Yo.OPEN,Tc=e=>{qo({command:"status",status:e})},Hn=()=>new Promise(e=>{if(!Ut||Ut.readyState!==Yo.OPEN){e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]});return}Qn=e,Ut.send(JSON.stringify({command:"requestContext"})),setTimeout(()=>{Qn===e&&(e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]}),Qn=null)},1e3)}),$r=e=>{qo({command:"open",filePath:e})},zs=(e,t,n)=>{qo({command:"showDiff",filePath:e,originalContent:t,modifiedContent:n})},Nr=(e,t)=>{qo({command:"closeDiff",filePath:e,result:t})};import Xs from"path";import Ma from"fs";var va=e=>{try{return Ma.readdirSync(e,{withFileTypes:!0})}catch{return[]}},Js=(e,t=4,n=1,s=va,o=[],c=null)=>{let f=c||s(e),l=" ".repeat(n-1),k=n===1?new Set([...io,...o,...ro(e),...ro(process.cwd())]):o instanceof Set?o:new Set([...io,...o]),p=x=>k.has(x),g=f.filter(x=>!p(x.name)),T=f.filter(x=>p(x.name)).length,m=g.filter(x=>!x.isDirectory()).map(x=>x.name).sort(),i=g.filter(x=>x.isDirectory()).sort((x,_)=>x.name.localeCompare(_.name)),u=x=>{let _=x.length;if(_===0)return"no files";let I=Array.from(new Set(x.map(a=>{let R=typeof a=="string"?a:a.name;return Xs.extname(R).slice(1)}).filter(Boolean))).sort(),y="*";return I.length===1?y=`*.${I[0]}`:I.length>1&&(y=`*.{${I.join(", ")}}`),_===1?y:`${y} ${_} files`},b="";if(n===1){let x=m.join(", "),_=T>0?` [${T} ignored]`:"";(x||_)&&(b+=`${l}${x?x+(_?`${_}`:""):_.trim()}
|
|
567
|
+
`)}else m.length>0&&(b+=`${l}[${u(m)}]
|
|
568
|
+
`);let O=10,h=i.slice(0,O),A=i.length>O,$=[],C=[];for(let x of h){let _=Xs.join(e,x.name),I=x.name,y=n,a=s(_),R=a.filter(M=>!p(M.name)),d=R.filter(M=>M.isDirectory()),r=R.filter(M=>!M.isDirectory());for(;r.length===0&&d.length===1&&y<t;)I=`${I}/${d[0].name}`,_=Xs.join(_,d[0].name),y++,a=s(_),R=a.filter(M=>!p(M.name)),d=R.filter(M=>M.isDirectory()),r=R.filter(M=>!M.isDirectory());let E=d.length>0;if(E&&y<t)C.push({displayName:I,subDirPath:_,subEntries:a,nextDepth:y+1});else{let M=u(r),U=E&&y>=t?" ...max scan depth":"";$.push(`${I}/${M}${U}`)}}$.length>0&&(b+=`${l}${$.join(", ")}
|
|
569
|
+
`);for(let{displayName:x,subDirPath:_,subEntries:I,nextDepth:y}of C)b+=`${l}${x}/
|
|
570
|
+
`,b+=Js(_,t,y,s,k,I);return A&&(b+=`${l}...max scan width, ReadFolder if needed
|
|
571
|
+
`),b};import Qs from"path";import Ia from"fs";var Oa=e=>{try{return Ia.readdirSync(e,{withFileTypes:!0})}catch{return[]}},Zs=(e,t,n="",s=1,o=Oa,c=[])=>{let f=o(e),l=Qs.sep;if(f.length>100)return`${n}\u2514\u2500\u2500 ${Qs.basename(e)}${l} ...100+ files...
|
|
572
|
+
`;let k="",p=c,g=f.filter(i=>!p.includes(i.name)&&!i.name.startsWith(".")),T=f.filter(i=>p.includes(i.name)||i.name.startsWith(".")).map(i=>i.name).sort();g.sort((i,u)=>i.isDirectory()&&!u.isDirectory()?-1:!i.isDirectory()&&u.isDirectory()?1:i.name.localeCompare(u.name));let m=[...g.map(i=>({name:i.name,isDir:i.isDirectory()})),...T.map(i=>({name:i,isDir:!0,isCollapsed:!0}))];return m.forEach((i,u)=>{let b=u===m.length-1,O=Qs.join(e,i.name),h=b?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",A=n+(b?" ":"\u2502 ");if(i.isCollapsed){k+=`${n}${h}${i.name}${l}...
|
|
574
573
|
`;return}i.isDir?s>t?k+=`${n}${h}${i.name}${l} ...depth exceeded...
|
|
575
|
-
`:o(
|
|
574
|
+
`:o(O).length>80?k+=`${n}${h}${i.name}${l} ...80+ files...
|
|
576
575
|
`:(k+=`${n}${h}${i.name}${l}
|
|
577
|
-
`,k+=Zs(
|
|
578
|
-
`}),k};var Ze=async(e,t,n=5,s=1e3)=>{let o=t?.signal;for(let f=0;f<n;f++){if(o?.aborted)throw new DOMException("The user aborted a request.","AbortError");try{let l=await fetch(e,t);if(typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),l.ok||l.status!==429&&l.status<500)return l}catch(l){if(typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),l.name==="AbortError"||o?.aborted||f===n-1)throw l}o?await new Promise((l,k)=>{let
|
|
579
|
-
`);h=y.pop();for(let a of y){let R=a.trim();if(!R||!R.startsWith("data: "))continue;let d=!1;if(R==="data: [DONE]")d=!0;else try{let r=JSON.parse(R.substring(6)),E=r.choices?.[0]?.delta,
|
|
580
|
-
`);$=d.pop();for(let r of d){let E=r.trim();if(!E||!E.startsWith("data: "))continue;let
|
|
581
|
-
`);
|
|
582
|
-
`);y=U.pop();for(let
|
|
583
|
-
`);for(let r of y.parts){let E=r.inlineData||r.inline_data;E&&E.data&&d.push(E.data)}}else R=y.text||"";if(R||d.length>0){let r={role:a,content:R};d.length>0&&(r.images=d),g.push(r)}}let T=
|
|
584
|
-
`:"")+r.text);else d=a.text||"";
|
|
585
|
-
`);$=d.pop();for(let r of d){let E=r.trim();if(!E||!E.startsWith("data: "))continue;let
|
|
586
|
-
`);h=y.pop();for(let a of y){let R=a.trim();if(!R||!R.startsWith("data: "))continue;let d=!1;if(R==="data: [DONE]")d=!0;else try{let r=JSON.parse(R.substring(6)),E=r.choices?.[0]?.delta,
|
|
587
|
-
`);h=y.pop();for(let a of y){let R=a.trim();if(!R||!R.startsWith("data: "))continue;let d=!1;if(R==="data: [DONE]")d=!0;else try{let r=JSON.parse(R.substring(6)),E=r.choices?.[0]?.delta,
|
|
588
|
-
`);I
|
|
589
|
-
`);C=d.pop();for(let r of d){let E=r.trim();if(!E||!E.startsWith("data: "))continue;let
|
|
590
|
-
`);C=d.pop();for(let r of d){let E=r.trim();if(!E||!E.startsWith("data: "))continue;let
|
|
591
|
-
`);C=d.pop();for(let r of d){let E=r.trim();if(!E||!E.startsWith("data: "))continue;let
|
|
592
|
-
`);C=d.pop();for(let r of d){let E=r.trim();if(!E||!E.startsWith("data: "))continue;let
|
|
593
|
-
`),
|
|
594
|
-
`),_=s.slice(0,-1).filter(L=>L.text&&!L.text.includes("[ACTION RESULT]")&&!L.text.includes("[TOOL RESULT]")&&!L.text.includes("OBSERVATION:")&&!L.text.startsWith("[TERMINAL_RECORD]")&&!L.isTerminalRecord&&!L.isMeta&&!L.isLogo&&!String(L.id).startsWith("welcome")&&!String(L.id).startsWith("logo")).slice(-14).map(L=>{let
|
|
576
|
+
`,k+=Zs(O,t,A,s+1,o,c)):k+=`${n}${h}${i.name}
|
|
577
|
+
`}),k};var Ze=async(e,t,n=5,s=1e3)=>{let o=t?.signal;for(let f=0;f<n;f++){if(o?.aborted)throw new DOMException("The user aborted a request.","AbortError");try{let l=await fetch(e,t);if(typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),l.ok||l.status!==429&&l.status<500)return l}catch(l){if(typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),l.name==="AbortError"||o?.aborted||f===n-1)throw l}o?await new Promise((l,k)=>{let p=setTimeout(()=>{o.removeEventListener("abort",g),l()},Math.min(24e3,s*Math.pow(2,f))),g=()=>{clearTimeout(p),k(new DOMException("The user aborted a request.","AbortError"))};o.addEventListener("abort",g)}):await new Promise(l=>setTimeout(l,Math.min(24e3,s*Math.pow(2,f))))}if(o?.aborted)throw new DOMException("The user aborted a request.","AbortError");let c=await fetch(e,t);return typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),c};async function Xo(e){let t=new TextEncoder().encode(e),n=await crypto.subtle.digest("SHA-256",t);return[...new Uint8Array(n).slice(0,16)].map(s=>s.toString(16).padStart(2,"0")).join("")}var xn=e=>typeof e!="string"?e:e.replace(/<\|channel>thought/gi,"<think>").replace(/<channel\|>/gi,"</think>");var Jo=async function*(e,t,n,s,o,c,f,l,k=1){let p=[];s&&p.push({role:"system",content:s});for(let _ of n){let I=_.role==="user"?"user":"assistant",y=[];if(Array.isArray(_.parts)){for(let a of _.parts)if(a.text)y.push({type:"text",text:a.text});else if((a.inlineData||a.inline_data)&&f){let R=a.inlineData||a.inline_data,d=R.mimeType||R.mime_type||"image/jpeg",r=R.data;d.startsWith("image/")&&y.push({type:"image_url",image_url:{url:`data:${d};base64,${r}`}})}}else{let a=_.text||"";a&&y.push({type:"text",text:a})}p.push({role:I,content:y.length===1&&y[0].type==="text"?y[0].text:y})}let g={model:t,messages:p,stream:!0,stream_options:{include_usage:!0},temperature:k,tools:[],tool_choice:"none"},T=He("DeepSeek",t,o),i=T!==null?T:o!=="Fast"?{Low:"low",Medium:"high",Standard:"high",High:"max",xHigh:"max"}[o]||"high":null;i&&i!=="disabled"&&i!=="none"&&i!=="false"&&i!==!1?(g.reasoning_effort=i,g.extra_body={thinking:{type:"enabled"}}):g.extra_body={thinking:{type:"disabled"}};let u=await Ze("https://api.deepseek.com/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(g),signal:l});if(!u.ok){let _=await u.json().catch(()=>({}));throw new Error(`DeepSeek Error (${u.status}): ${_.error?.message||u.statusText}`)}let b=u.body.getReader(),O=new TextDecoder,h="",A=[],$=null,C=Date.now(),x=!1;for(;;){let{done:_,value:I}=await b.read();if(_){x&&(A.length>0||$)&&(yield{candidates:A.length>0?[{content:{parts:A}}]:[],usageMetadata:$});break}h+=O.decode(I,{stream:!0});let y=h.split(`
|
|
578
|
+
`);h=y.pop();for(let a of y){let R=a.trim();if(!R||!R.startsWith("data: "))continue;let d=!1;if(R==="data: [DONE]")d=!0;else try{let r=JSON.parse(R.substring(6)),E=r.choices?.[0]?.delta,M=r.usage;if(r.choices?.[0]?.finish_reason&&(d=!0),M&&($={totalTokenCount:M.total_tokens||M.prompt_tokens+M.completion_tokens,promptTokenCount:M.prompt_tokens||0,candidatesTokenCount:M.completion_tokens||0,cachedContentTokenCount:M.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:M.completion_tokens_details?.reasoning_tokens||0},x=!0),E){let U=E.reasoning_content||null;U&&(A.push({text:U,thought:!0}),x=!0),E.content&&(A.push({text:E.content}),x=!0)}}catch{}if((d||Date.now()-C>=150)&&x&&(yield{candidates:A.length>0?[{content:{parts:[...A]}}]:[],usageMetadata:$},A=[],C=Date.now(),x=!1),d)break}Date.now()-C>=150&&x&&(yield{candidates:A.length>0?[{content:{parts:[...A]}}]:[],usageMetadata:$},A=[],C=Date.now(),x=!1)}};var Qo=async function*(e,t,n,s,o,c,f,l,k=1,p=null){let g=[];s&&g.push({role:"system",content:s});for(let a of n){let R=a.role==="user"?"user":"assistant",d=[];if(Array.isArray(a.parts)){for(let r of a.parts)if(r.text)d.push({type:"text",text:r.text});else if(r.inlineData&&f){let E=r.inlineData.mimeType,M=r.inlineData.data;E.startsWith("image/")&&d.push({type:"image_url",image_url:`data:${E};base64,${M}`})}}else{let r=a.text||"";r&&d.push({type:"text",text:r})}d.length>0&&g.push({role:R,content:d.length===1&&d[0].type==="text"?d[0].text:d})}let T={Fast:"none",Low:"none",Medium:"high",Standard:"high",High:"high",xHigh:"high"},m=`${e.slice(-5)}${p||""}${o}${t}`,i=await Xo(m),u={model:t,messages:g,stream:!0,temperature:k,prompt_cache_key:i,tools:[],tool_choice:"none"},b=He("Mistral",t,o);b!==null&&b!=="none"?b&&b!=="none"&&b!=="disabled"&&b!==!1&&(u.reasoning_effort=b):o&&T[o]!=="none"&&(u.reasoning_effort=T[o]||"high");let O=await Ze("https://api.mistral.ai/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(u),signal:l});if(!O.ok){let a=await O.text().catch(()=>""),R=O.statusText;try{let d=JSON.parse(a);R=d.error?.message||d.message||JSON.stringify(d.detail||d)}catch{a&&(R=a)}throw new Error(`Mistral Error (${O.status}): ${JSON.stringify(R)}`)}let h=O.body.getReader(),A=new TextDecoder,$="",C=[],x=null,_=Date.now(),I=!1,y=a=>a?typeof a=="string"?xn(a):Array.isArray(a)?a.map(y).filter(Boolean).join(""):typeof a=="object"&&a!==null?typeof a.text=="string"?xn(a.text):typeof a.content=="string"?xn(a.content):typeof a.thinking=="string"?xn(a.thinking):typeof a.reasoning_content=="string"?xn(a.reasoning_content):typeof a.reasoning=="string"?xn(a.reasoning):typeof a.value=="string"?xn(a.value):a.text?y(a.text):a.content?y(a.content):a.thinking?y(a.thinking):a.reasoning_content?y(a.reasoning_content):a.reasoning?y(a.reasoning):a.value?y(a.value):"":xn(String(a)):"";for(;;){let{done:a,value:R}=await h.read();if(a){I&&(C.length>0||x)&&(yield{candidates:C.length>0?[{content:{parts:C}}]:[],usageMetadata:x});break}$+=A.decode(R,{stream:!0});let d=$.split(`
|
|
579
|
+
`);$=d.pop();for(let r of d){let E=r.trim();if(!E||!E.startsWith("data: "))continue;let M=!1;if(E==="data: [DONE]")M=!0;else try{let U=JSON.parse(E.substring(6)),D=U.choices?.[0]?.delta,P=U.usage;if(U.choices?.[0]?.finish_reason&&(M=!0),P&&(x={totalTokenCount:P.total_tokens||(P.prompt_tokens||0)+(P.completion_tokens||0),promptTokenCount:P.prompt_tokens||0,candidatesTokenCount:P.completion_tokens||0,cachedContentTokenCount:P.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:P.completion_tokens_details?.reasoning_tokens||0},I=!0),D){let le=D.thinking||D.reasoning_content||D.reasoning,fe=y(le);fe&&(C.push({text:fe,thought:!0}),I=!0);let Z=D.content||(!D.thinking&&!D.reasoning_content&&!D.reasoning?D.text:null);if(Z)if(Array.isArray(Z))for(let we of Z)if(typeof we=="object"&&we!==null){let ce=we.type==="thinking"||we.type==="reasoning"||!!we.thought,rt=y(we);rt&&(C.push({text:rt,...ce?{thought:!0}:{}}),I=!0)}else{let ce=y(we);ce&&(C.push({text:ce}),I=!0)}else if(typeof Z=="object"&&Z!==null){let we=Z.type==="thinking"||Z.type==="reasoning"||!!Z.thought,ce=y(Z);ce&&(C.push({text:ce,...we?{thought:!0}:{}}),I=!0)}else{let we=y(Z);we&&(C.push({text:we}),I=!0)}}}catch{}if((M||Date.now()-_>=150)&&I&&(yield{candidates:C.length>0?[{content:{parts:[...C]}}]:[],usageMetadata:x},C=[],_=Date.now(),I=!1),M)break}Date.now()-_>=150&&I&&(yield{candidates:C.length>0?[{content:{parts:[...C]}}]:[],usageMetadata:x},C=[],_=Date.now(),I=!1)}};var Zo=async function*(e,t,n,s,o,c,f=!1,l,k=1){let p=[];s&&p.push({role:"system",content:s}),n.forEach(ce=>{let rt=ce.role==="model"?"assistant":"user",L=[];Array.isArray(ce.parts)&&ce.parts.forEach(N=>{if(N.text)L.push({type:"text",text:N.text});else if(N.inlineData&&f){let Ee=N.inlineData.mimeType,ie=N.inlineData.data;Ee.startsWith("image/")&&ut(t)&&L.push({type:"image_url",image_url:{url:`data:${Ee};base64,${ie}`}})}}),p.push({role:rt,content:L.length===1&&L[0].type==="text"?L[0].text:L})});let g=He("NVIDIA",t,o),m=g!==null?g:{Fast:"Fast",Low:"Fast",Medium:"Standard",Standard:"Standard",High:"High",xHigh:"High"}[o]||"High",i=m!=="Fast"&&m!=="none"&&m!=="disabled"&&m!==!1,u=t.includes("kimi"),b=t.includes("gemma"),O=t.includes("deepseek"),h=t.includes("glm"),A=t.includes("mistral"),$=t.includes("minimax"),C=t.includes("gpt"),x=t.includes("qwen"),_=t.includes("nemotron"),I=t.includes("llama-3"),y=t.includes("seed"),a=t.includes("poolside"),R=t.includes("thinkingmachines")||t.includes("muse"),d=I,r={Fast:"low",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"},E={Fast:"64",Low:"64",Medium:"4096",Standard:"4096",High:"16384",xHigh:"16384"},M={Fast:"none",Low:"minimal",Medium:"medium",Standard:"medium",High:"max",xHigh:"max"},U=$||O||a||R?16384:32768;U=process.env.NVIDIA_BASE_URL?1024:U;let D={model:t,messages:p,max_tokens:U,stream:!0,stream_options:{include_usage:!0},temperature:k,tools:[],tool_choice:"none",...C&&{thinking:r[o]||"high"}};if(!(process.env.NVIDIA_BASE_URL||d))if(u)D.chat_template_kwargs={thinking:i};else if(b)D.chat_template_kwargs={enable_thinking:i};else if(O)if(i){let ce=m==="High"?"max":"high";D.chat_template_kwargs={thinking:!0,reasoning_effort:ce}}else D.chat_template_kwargs={thinking:!1};else h?D.chat_template_kwargs={enable_thinking:i,clear_thinking:!i}:A?D.reasoning_effort=i?"high":"none":$&&t.includes("minimax-m3")?D.chat_template_kwargs={thinking_mode:i?"enabled":"disabled"}:x?D.chat_template_kwargs={enable_thinking:i}:_?m==="High"?D.chat_template_kwargs={enable_thinking:!0}:m==="Standard"?D.chat_template_kwargs={enable_thinking:!0,medium_effort:!0}:D.chat_template_kwargs={enable_thinking:!1}:y?i&&(D.extra_body={thinking_budget:parseInt(E[m]??"4096")}):a?D.chat_template_kwargs={enable_thinking:i}:R&&(D.reasoning_effort=M[m]||"medium");let P=0,le=6,fe=!1,Z=process.env.NVIDIA_BASE_URL||"https://integrate.api.nvidia.com/v1/chat/completions",we=process.env.NVIDIA_API_KEY&&process.env.NVIDIA_BASE_URL?process.env.NVIDIA_API_KEY:e;for(Z.endsWith("/chat/completions")||(Z=Z.replace(/\/+$/,"")+"/chat/completions");P<le;){P++;try{let ce=await Ze(Z,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${we}`},body:JSON.stringify(D),signal:l});if(!ce.ok){let ye=await ce.text().catch(()=>""),Re=ce.statusText;try{let Ie=JSON.parse(ye);Re=Ie.error?.message||Ie.message||JSON.stringify(Ie.detail||Ie)}catch{ye&&(Re=ye)}let Me=new Error(`NVIDIA API Error (${ce.status}): ${Re}`);throw Me.status=ce.status,Me}let rt=ce.body.getReader(),L=new TextDecoder,N="",Ee=[],ie=null,B=Date.now(),G=!1;for(;;){let{done:ye,value:Re}=await rt.read();if(ye){G&&(Ee.length>0||ie)&&(yield{candidates:Ee.length>0?[{content:{parts:Ee}}]:[],usageMetadata:ie},fe=!0);break}N+=L.decode(Re,{stream:!0});let Me=N.split(`
|
|
580
|
+
`);N=Me.pop();let Ie=!1;for(let On of Me){let nn=On.trim();if(nn){if(nn==="data: [DONE]"){Ie=!0;break}if(nn.startsWith("data: ")){let pt;try{pt=JSON.parse(nn.substring(6))}catch{continue}if(pt.error)throw new Error(`NVIDIA Stream Error: ${pt.error.message||JSON.stringify(pt.error)}`);try{let Tt=pt.usage;Tt&&(ie={totalTokenCount:Tt.total_tokens||Tt.prompt_tokens+Tt.completion_tokens,promptTokenCount:Tt.prompt_tokens||0,candidatesTokenCount:Tt.completion_tokens||0,cachedContentTokenCount:Tt.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:(Tt.completion_tokens_details?.reasoning_tokens||0)+(Tt.completion_tokens_details?.thoughts_tokens||0)},G=!0);let Je=pt.choices?.[0]?.delta?.reasoning||pt.choices?.[0]?.delta?.reasoning_content||"",xe=pt.choices?.[0]?.delta?.content||"";Je&&(Ee.push({text:Je,thought:!0}),G=!0),xe&&(Ee.push({text:xe}),G=!0)}catch{}}}}if((Ie||Date.now()-B>=350)&&G&&(yield{candidates:Ee.length>0?[{content:{parts:[...Ee]}}]:[],usageMetadata:ie},fe=!0,Ee=[],B=Date.now(),G=!1),Ie)break}break}catch(ce){if(fe||P>=le)throw ce;await new Promise(rt=>setTimeout(rt,3500))}}},Fr=async function*(e,t){let n=[],s=null,o=!1,c=null,f=u=>{if(n.push(u),s){let b=s;s=null,b()}},l=t.split("/").pop(),k=Array.from(new Set([l,l.replace(/\./g,"-"),l.replace(/\./g,"_")])),g=["https://buildapi.ngc.nvidia.com/v2/predict/queues/models/qc69jvmznzxy","https://api.ngc.nvidia.com/v2/predict/queues/models/qc69jvmznzxy"].flatMap(u=>k.map(b=>`${u}/${b}`)),T=!1,m=null,i=async()=>{try{let b=await(await Promise.any(g.map(async O=>{let h=await fetch(O);if(!h.ok)throw new Error(`HTTP ${h.status}`);return h}))).json();if(b&&b.queues&&b.queues[0]&&typeof b.queues[0].queueDepth=="number"){let O=b.queues[0].queueDepth;T||f({value:{type:"status",content:`Queue ${O||1}`},done:!1})}}catch{}};process.env.NVIDIA_BASE_URL||(i(),m=setInterval(i,5e3)),(async()=>{try{let u=e[Symbol.asyncIterator]();for(;;){let{value:b,done:O}=await u.next();if(O)break;T=!0,m&&(clearInterval(m),m=null),f({value:b,done:!1})}o=!0,f(null)}catch(u){if(c=u,m&&(clearInterval(m),m=null),s){let b=s;s=null,b()}}})();try{for(;;){if(c)throw c;if(n.length>0){let u=n.shift();if(u===null&&o)break;yield u.value}else{if(o)break;await new Promise(u=>{s=u})}}}finally{m&&(clearInterval(m),m=null)}};var es=async function*(e,t,n,s,o,c,f,l,k=1,p=null){let g=[];s&&g.push({role:"system",content:[{type:"text",text:s}]});for(let E of n){let M=E.role==="user"?"user":"assistant",U=[];if(Array.isArray(E.parts)){for(let D of E.parts)if(D.text)U.push({type:"text",text:D.text});else if(D.inlineData&&f){let P=D.inlineData.mimeType,le=D.inlineData.data;P.startsWith("image/")?U.push({type:"image_url",image_url:{url:`data:${P};base64,${le}`}}):U.push({type:"file",file:{filename:D.filename||"file",file_data:`data:${P};base64,${le}`}})}}else{let D=E.text||"";D&&U.push({type:"text",text:D})}g.push({role:M,content:U.length===1&&U[0].type==="text"?U[0].text:U})}let T={Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"},m=["free","nitro","floor","exacto"],i=t,u=null,b=null;if(t.includes(":")){let E=t.split(":");if(E.length>1){let M=E[E.length-1].toLowerCase().trim();(M==="flex"||M==="priority")&&(b=M,E.pop())}if(E.length>1){let M=E[E.length-1].toLowerCase().trim();if(!m.includes(M)){let U=E.pop().trim();U&&(u={only:[U],allow_fallbacks:!1})}}i=E.join(":").trim()}let O=`${e.slice(-5)}${p||""}${o}${i}${b||""}${u?JSON.stringify(u):""}`,h=await Xo(O),A={model:i,messages:g,stream:!0,temperature:k,cache_control:{type:"ephemeral"},tools:[],tool_choice:"none",session_id:h};b&&(A.service_tier=b),u&&(A.provider=u);let $=He("OpenRouter",t,o),C=$!==null?$:T[o];C&&C!=="none"&&($!==null||o!=="Fast")&&(A.reasoning_effort=C);let x=await Ze("https://openrouter.ai/api/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json","HTTP-Referer":"https://fluxflow-cli.onrender.com/","X-Title":"FluxFlow CLI","X-OpenRouter-Title":"FluxFlow CLI","X-Cache":"true","X-OpenRouter-Cache":"true"},body:JSON.stringify(A),signal:l});if(!x.ok){let E=await x.json().catch(()=>({})),M=E.error?.metadata?.raw||E.error?.message||(typeof E.error=="string"?E.error:"")||x.statusText||"Unknown error";throw new Error(`OpenRouter Error (${x.status}): ${M}`)}let _=x.body.getReader(),I=new TextDecoder,y="",a=[],R=null,d=Date.now(),r=!1;for(;;){let{done:E,value:M}=await _.read();if(E){r&&(a.length>0||R)&&(yield{candidates:a.length>0?[{content:{parts:a}}]:[],usageMetadata:R});break}y+=I.decode(M,{stream:!0});let U=y.split(`
|
|
581
|
+
`);y=U.pop();for(let D of U){let P=D.trim();if(!P||!P.startsWith("data: "))continue;let le=!1;if(P==="data: [DONE]")le=!0;else try{let fe=JSON.parse(P.substring(6));if(fe.error){let ce=fe.error.metadata?.raw||fe.error.message||JSON.stringify(fe.error);throw new Error(`OpenRouter Stream Error: ${ce}`)}let Z=fe.choices?.[0]?.delta,we=fe.usage;if(fe.choices?.[0]?.finish_reason&&(le=!0),we&&(R={totalTokenCount:we.total_tokens||(we.prompt_tokens||0)+(we.completion_tokens||0),promptTokenCount:we.prompt_tokens||0,candidatesTokenCount:we.completion_tokens||0,cachedContentTokenCount:we.prompt_tokens_details?.cached_tokens||we.prompt_tokens_details?.cache_read_input_tokens||we.cache_read_input_tokens||0,thoughtsTokenCount:we.completion_tokens_details?.reasoning_tokens||0},r=!0),Z){let ce=Z.reasoning||(Z.reasoning_details?Z.reasoning_details.map(rt=>rt.text).join(""):null);ce&&(a.push({text:ce,thought:!0}),r=!0),Z.content&&(a.push({text:Z.content}),r=!0)}}catch(fe){if(fe.message&&fe.message.startsWith("OpenRouter Stream Error:"))throw fe}if((le||Date.now()-d>=150)&&r&&(yield{candidates:a.length>0?[{content:{parts:[...a]}}]:[],usageMetadata:R},a=[],d=Date.now(),r=!1),le)break}}};import{Ollama as Da}from"ollama";var ei=async function*(e,t,n,s,o,c,f,l,k=1,p="Cloud"){let g=[];s&&g.push({role:"system",content:s});for(let y of n){let a=y.role==="user"?"user":"assistant",R="",d=[];if(Array.isArray(y.parts)){R=y.parts.map(r=>r.text||"").filter(Boolean).join(`
|
|
582
|
+
`);for(let r of y.parts){let E=r.inlineData||r.inline_data;E&&E.data&&d.push(E.data)}}else R=y.text||"";if(R||d.length>0){let r={role:a,content:R};d.length>0&&(r.images=d),g.push(r)}}let T=p==="Local"||!e||e==="LOCAL",i={host:T?process.env.OLLAMA_HOST||"http://127.0.0.1:11434":process.env.OLLAMA_HOST||"https://ollama.com"};!T&&e&&(i.headers={Authorization:"Bearer "+e});let u=new Da(i),b=[],O=null,h=Date.now(),A=!1,$=He("Ollama",t,o),C={Fast:!1,Low:"medium",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"},x=$!==null?$==="false"||$===!1?!1:$==="true"||$===!0?!0:$:C[o]!==void 0?C[o]:!0,_={model:t,messages:g,stream:!0,think:x,keep_alive:"10m",tools:[],tool_choice:"none",options:{temperature:k}},I=await u.chat(_);for await(let y of I){if(l?.aborted)throw new DOMException("The user aborted a request.","AbortError");if(y.message?.thinking&&(b.push({text:y.message.thinking,thought:!0}),A=!0),y.message?.content&&(b.push({text:y.message.content}),A=!0),y.done){let a=y.prompt_cached_count||0;if(!a&&y.prompt_eval_count){let R=y.prompt_eval_duration||0;R>0&&R<5e7&&(a=y.prompt_eval_count)}O={totalTokenCount:(y.prompt_eval_count||0)+(y.eval_count||0),promptTokenCount:y.prompt_eval_count||0,candidatesTokenCount:y.eval_count||0,cachedContentTokenCount:a,thoughtsTokenCount:0},A=!0}(y.done||Date.now()-h>=150&&A)&&(yield{candidates:b.length>0?[{content:{parts:[...b]}}]:[],usageMetadata:O},b=[],h=Date.now(),A=!1)}A&&(b.length>0||O)&&(yield{candidates:b.length>0?[{content:{parts:[...b]}}]:[],usageMetadata:O})};var ts=async function*(e,t,n,s,o,c,f,l,k=1){let p=[];s&&p.push({role:"system",content:s});for(let a of n){let R=a.role==="user"?"user":"assistant",d="";if(Array.isArray(a.parts))for(let r of a.parts)r.text&&(d+=(d?`
|
|
583
|
+
`:"")+r.text);else d=a.text||"";p.push({role:R,content:d})}let g=He("InferX",t,o),m=g!==null?g:{Fast:"low",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[o],i=t&&t.toLowerCase().includes("qwen3.8-27b")&&g===null,u=t&&(t.toLowerCase().includes("qwen3.8-27b")||t.toLowerCase().includes("qwen3.6-35b-a3b-fp8")),b={model:t,messages:p.filter(a=>a.content&&String(a.content).trim().length>0),stream:!0,stream_options:{include_usage:!0},temperature:k,tools:[],tool_choice:"none"};!i&&m&&(b.stream_options={include_usage:!0},b.reasoning_effort=m);let O=await Ze("https://model.inferx.net/endpoints/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(b),signal:l});if(!O.ok){let a=await O.text().catch(()=>""),R="";try{let d=JSON.parse(a);R=d.error?.message||d.error?.detail||d.message||d.detail||(typeof d.error=="string"?d.error:"")||(a&&a!=="{}"?a:"")}catch{R=a}throw(!R||R==="{}")&&(R=O.statusText||"Unknown error"),new Error(`InferX Error (${O.status}): ${R}`)}let h=O.body.getReader(),A=new TextDecoder,$="",C=[],x=null,_=Date.now(),I=!1,y=!0;for(;;){let{done:a,value:R}=await h.read();if(a){I&&(C.length>0||x)&&(yield{candidates:C.length>0?[{content:{parts:C}}]:[],usageMetadata:x});break}$+=A.decode(R,{stream:!0});let d=$.split(`
|
|
584
|
+
`);$=d.pop();for(let r of d){let E=r.trim();if(!E||!E.startsWith("data: "))continue;let M=!1;if(E==="data: [DONE]")M=!0;else try{let U=JSON.parse(E.substring(6)),D=U.choices?.[0]?.delta,P=U.usage;if(P&&(x={totalTokenCount:P.total_tokens||(P.prompt_tokens||0)+(P.completion_tokens||0),promptTokenCount:P.prompt_tokens||0,candidatesTokenCount:P.completion_tokens||0,cachedContentTokenCount:P.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:P.completion_tokens_details?.reasoning_tokens||P.reasoning_tokens||0},I=!0),D){let le=D.reasoning||D.reasoning_content||null;if(le&&(C.push({text:le,thought:!0}),I=!0),D.content){let fe=D.content;u&&y&&fe.length>0&&(fe="<think>"+fe,y=!1),C.push({text:fe}),I=!0}}}catch{}if((M||Date.now()-_>=150||x)&&I&&(yield{candidates:C.length>0?[{content:{parts:[...C]}}]:[],usageMetadata:x},C=[],_=Date.now(),I=!1),M)break}Date.now()-_>=150&&I&&(yield{candidates:C.length>0?[{content:{parts:[...C]}}]:[],usageMetadata:x},C=[],_=Date.now(),I=!1)}};var ns=async function*(e,t,n,s,o,c,f,l,k=1){let p=[];s&&p.push({role:"system",content:s});for(let _ of n){let I=_.role==="user"?"user":"assistant",y=[];if(Array.isArray(_.parts)){for(let a of _.parts)if(a.text)y.push({type:"text",text:a.text});else if(a.inlineData&&f){let R=a.inlineData.mimeType,d=a.inlineData.data;R.startsWith("image/")&&y.push({type:"image_url",image_url:{url:`data:${R};base64,${d}`}})}}else{let a=_.text||"";a&&y.push({type:"text",text:a})}p.push({role:I,content:y.length===1&&y[0].type==="text"?y[0].text:y})}let g=He("SenseNova",t,o),m=g!==null?g:{Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[o],i={model:t,messages:p,stream:!0,stream_options:{include_usage:!0},temperature:k,tools:[],tool_choice:"none"};m&&(i.reasoning_effort=m);let u=await Ze("https://token.sensenova.ai/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(i),signal:l});if(!u.ok){let _=await u.json().catch(()=>({}));throw new Error(`SenseNova Error (${u.status}): ${_.error?.message||u.statusText}`)}let b=u.body.getReader(),O=new TextDecoder,h="",A=[],$=null,C=Date.now(),x=!1;for(;;){let{done:_,value:I}=await b.read();if(_){x&&(A.length>0||$)&&(yield{candidates:A.length>0?[{content:{parts:A}}]:[],usageMetadata:$});break}h+=O.decode(I,{stream:!0});let y=h.split(`
|
|
585
|
+
`);h=y.pop();for(let a of y){let R=a.trim();if(!R||!R.startsWith("data: "))continue;let d=!1;if(R==="data: [DONE]")d=!0;else try{let r=JSON.parse(R.substring(6)),E=r.choices?.[0]?.delta,M=r.usage;if(M&&($={totalTokenCount:M.total_tokens||(M.prompt_tokens||0)+(M.completion_tokens||0),promptTokenCount:M.prompt_tokens||0,candidatesTokenCount:M.completion_tokens||0,cachedContentTokenCount:M.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:M.completion_tokens_details?.reasoning_tokens||M.reasoning_tokens||0},x=!0),E){let U=E.reasoning||E.reasoning_content||null;U&&(A.push({text:U,thought:!0}),x=!0),E.content&&(A.push({text:E.content}),x=!0)}}catch{}if((d||Date.now()-C>=150||$)&&x&&(yield{candidates:A.length>0?[{content:{parts:[...A]}}]:[],usageMetadata:$},A=[],C=Date.now(),x=!1),d)break}Date.now()-C>=150&&x&&(yield{candidates:A.length>0?[{content:{parts:[...A]}}]:[],usageMetadata:$},A=[],C=Date.now(),x=!1)}};var os=async function*(e,t,n,s,o,c,f,l,k=1){let p=[];s&&p.push({role:"system",content:s});for(let _ of n){let I=_.role==="user"?"user":"assistant",y=[];if(Array.isArray(_.parts)){for(let a of _.parts)if(a.text)y.push({type:"text",text:a.text});else if(a.inlineData&&f){let R=a.inlineData.mimeType,d=a.inlineData.data;R.startsWith("image/")&&y.push({type:"image_url",image_url:{url:`data:${R};base64,${d}`}})}}else{let a=_.text||"";a&&y.push({type:"text",text:a})}p.push({role:I,content:y.length===1&&y[0].type==="text"?y[0].text:y})}let g=He("AIHubMix",t,o),m=g!==null?g:{Fast:"minimal",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[o],i={model:t,messages:p,stream:!0,stream_options:{include_usage:!0},temperature:k,tools:[],tool_choice:"none"};m&&(i.reasoning_effort=m);let u=await Ze("https://aihubmix.com/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(i),signal:l});if(!u.ok){let _=await u.json().catch(()=>({}));throw new Error(`AIHubMix Error (${u.status}): ${_.error?.message||u.statusText}`)}let b=u.body.getReader(),O=new TextDecoder,h="",A=[],$=null,C=Date.now(),x=!1;for(;;){let{done:_,value:I}=await b.read();if(_){x&&(A.length>0||$)&&(yield{candidates:A.length>0?[{content:{parts:A}}]:[],usageMetadata:$});break}h+=O.decode(I,{stream:!0});let y=h.split(`
|
|
586
|
+
`);h=y.pop();for(let a of y){let R=a.trim();if(!R||!R.startsWith("data: "))continue;let d=!1;if(R==="data: [DONE]")d=!0;else try{let r=JSON.parse(R.substring(6)),E=r.choices?.[0]?.delta,M=r.usage;if(r.choices?.[0]?.finish_reason&&(d=!0),M&&($={totalTokenCount:M.total_tokens||(M.prompt_tokens||0)+(M.completion_tokens||0),promptTokenCount:M.prompt_tokens||0,candidatesTokenCount:M.completion_tokens||0,cachedContentTokenCount:M.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:M.completion_tokens_details?.reasoning_tokens||M.reasoning_tokens||0},x=!0),E){let U=E.reasoning_content||null;U&&(A.push({text:U,thought:!0}),x=!0),E.content&&(A.push({text:E.content}),x=!0)}}catch{}if((d||Date.now()-C>=150)&&x&&(yield{candidates:A.length>0?[{content:{parts:[...A]}}]:[],usageMetadata:$},A=[],C=Date.now(),x=!1),d)break}Date.now()-C>=150&&x&&(yield{candidates:A.length>0?[{content:{parts:[...A]}}]:[],usageMetadata:$},A=[],C=Date.now(),x=!1)}};var ss=async function*(e,t,n,s,o,c,f,l,k=1){let p=[];s&&p.push({role:"system",content:s});for(let x of n){let _=x.role==="user"?"user":"assistant",I=[];if(Array.isArray(x.parts)){for(let y of x.parts)if(y.text)I.push({type:"text",text:y.text});else if(y.inlineData&&f){let a=y.inlineData.mimeType,R=y.inlineData.data;a.startsWith("image/")&&I.push({type:"image_url",image_url:{url:`data:${a};base64,${R}`}})}}else{let y=x.text||"";y&&I.push({type:"text",text:y})}p.push({role:_,content:I.length===1&&I[0].type==="text"?I[0].text:I})}let g=He("Poolside",t,o),T=g!==null?g===!1||g==="false"||g==="none"||g==="Fast":o==="Fast",m={model:t,messages:p,stream:!0,stream_options:{include_usage:!0},temperature:k,tools:[],tool_choice:"none"};T?m.chat_template_kwargs={enable_thinking:!1}:g!==null&&typeof g=="object"?m.chat_template_kwargs=g:m.chat_template_kwargs={enable_thinking:!0};let i=await Ze("https://inference.poolside.ai/v1/chat/completions",{method:"POST",headers:{Authorization:`Bearer ${e}`,"Content-Type":"application/json"},body:JSON.stringify(m),signal:l});if(!i.ok){let x=await i.json().catch(()=>({}));throw new Error(`Poolside Error (${i.status}): ${x.error?.message||i.statusText}`)}let u=i.body.getReader(),b=new TextDecoder,O="",h=[],A=null,$=Date.now(),C=!1;for(;;){let{done:x,value:_}=await u.read();if(x){C&&(h.length>0||A)&&(yield{candidates:h.length>0?[{content:{parts:h}}]:[],usageMetadata:A});break}O+=b.decode(_,{stream:!0});let I=O.split(`
|
|
587
|
+
`);O=I.pop();for(let y of I){let a=y.trim();if(!a||!a.startsWith("data: "))continue;let R=!1;if(a==="data: [DONE]")R=!0;else try{let d=JSON.parse(a.substring(6)),r=d.choices?.[0]?.delta,E=d.usage;if(d.choices?.[0]?.finish_reason&&(R=!0),E&&(A={totalTokenCount:E.total_tokens||(E.prompt_tokens||0)+(E.completion_tokens||0),promptTokenCount:E.prompt_tokens||0,candidatesTokenCount:E.completion_tokens||0,cachedContentTokenCount:E.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:E.completion_tokens_details?.reasoning_tokens||E.reasoning_tokens||0},C=!0),r){let M=r.reasoning_content||r.reasoning||null;M&&(h.push({text:M,thought:!0}),C=!0),r.content&&(h.push({text:r.content}),C=!0)}}catch{}if((R||Date.now()-$>=150)&&C&&(yield{candidates:h.length>0?[{content:{parts:[...h]}}]:[],usageMetadata:A},h=[],$=Date.now(),C=!1),R)break}Date.now()-$>=150&&C&&(yield{candidates:h.length>0?[{content:{parts:[...h]}}]:[],usageMetadata:A},h=[],$=Date.now(),C=!1)}};var is=async function*(e,t,n,s,o,c,f,l,k=1){let p=[];s&&p.push({role:"system",content:s});for(let a of n){let R=a.role==="user"?"user":"assistant",d=[];if(Array.isArray(a.parts)){for(let r of a.parts)if(r.text)d.push({type:"text",text:r.text});else if(r.inlineData&&f){let E=r.inlineData.mimeType,M=r.inlineData.data;E.startsWith("image/")&&d.push({type:"image_url",image_url:{url:`data:${E};base64,${M}`}})}}else{let r=a.text||"";r&&d.push({type:"text",text:r})}p.push({role:R,content:d.length===1&&d[0].type==="text"?d[0].text:d})}let g=He("9router",t,o)||He("9Router",t,o),m=g!==null?g:{Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[o],i={model:t,messages:p,stream:!0,stream_options:{include_usage:!0},temperature:k,tools:[],tool_choice:"none"};m&&m!=="none"&&(g!==null||o!=="Fast")&&(i.reasoning_effort=m);let u=process.env["9ROUTER_URL"]||process.env.NINEROUTER_URL||"http://127.0.0.1:20128/v1/chat/completions",b={"Content-Type":"application/json"},O=e&&e!=="LOCAL"?e:process.env.NINEROUTER_KEY||"dummy-key";b.Authorization=`Bearer ${O}`;let h=await Ze(u,{method:"POST",headers:b,body:JSON.stringify(i),signal:l});if(!h.ok){let a=await h.json().catch(()=>({}));throw new Error(`9router Error (${h.status}): ${a.error?.message||h.statusText}`)}let A=h.body.getReader(),$=new TextDecoder,C="",x=[],_=null,I=Date.now(),y=!1;for(;;){let{done:a,value:R}=await A.read();if(a){y&&(x.length>0||_)&&(yield{candidates:x.length>0?[{content:{parts:x}}]:[],usageMetadata:_});break}C+=$.decode(R,{stream:!0});let d=C.split(`
|
|
588
|
+
`);C=d.pop();for(let r of d){let E=r.trim();if(!E||!E.startsWith("data: "))continue;let M=!1;if(E==="data: [DONE]")M=!0;else try{let U=JSON.parse(E.substring(6)),D=U.choices?.[0]?.delta,P=U.usage;if(U.choices?.[0]?.finish_reason&&(M=!0),P&&(_={totalTokenCount:P.total_tokens||(P.prompt_tokens||0)+(P.completion_tokens||0),promptTokenCount:P.prompt_tokens||0,candidatesTokenCount:P.completion_tokens||0,cachedContentTokenCount:P.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:P.completion_tokens_details?.reasoning_tokens||P.reasoning_tokens||0},y=!0),D){let le=D.reasoning_content||D.reasoning||D.thinking||null;!le&&Array.isArray(D.reasoning_details)&&D.reasoning_details.length>0&&(le=D.reasoning_details.map(fe=>typeof fe=="string"?fe:fe?.text||"").filter(Boolean).join("")),le&&(x.push({text:le,thought:!0}),y=!0),D.content&&(x.push({text:D.content}),y=!0)}}catch{}if((M||Date.now()-I>=150)&&y&&(yield{candidates:x.length>0?[{content:{parts:[...x]}}]:[],usageMetadata:_},x=[],I=Date.now(),y=!1),M)break}Date.now()-I>=150&&y&&(yield{candidates:x.length>0?[{content:{parts:[...x]}}]:[],usageMetadata:_},x=[],I=Date.now(),y=!1)}};var rs=async function*(e,t,n,s,o,c,f,l,k=1){let p=[];s&&p.push({role:"system",content:s});for(let a of n){let R=a.role==="user"?"user":"assistant",d=[];if(Array.isArray(a.parts)){for(let r of a.parts)if(r.text)d.push({type:"text",text:r.text});else if(r.inlineData&&f){let E=r.inlineData.mimeType,M=r.inlineData.data;E.startsWith("image/")&&d.push({type:"image_url",image_url:{url:`data:${E};base64,${M}`}})}}else{let r=a.text||"";r&&d.push({type:"text",text:r})}p.push({role:R,content:d.length===1&&d[0].type==="text"?d[0].text:d})}let g=He("ExpLabs",t,o),m=g!==null?g:{Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[o],i={model:t,messages:p,stream:!0,stream_options:{include_usage:!0},temperature:k,tools:[],tool_choice:"none"};m&&(i.reasoning_effort=m);let u=process.env.EXPLABS_URL||process.env.EXPERIENTIALLABS_URL||"https://api.experientiallabs.ai/v1/chat/completions",b={"Content-Type":"application/json"},O=e||process.env.EXPLABS_API_KEY||process.env.EXPERIENTIALLABS_API_KEY||"";b.Authorization=`Bearer ${O}`;let h=await Ze(u,{method:"POST",headers:b,body:JSON.stringify(i),signal:l});if(!h.ok){let a=await h.json().catch(()=>({}));throw new Error(`Experiential Labs Error (${h.status}): ${a.error?.message||a.message||h.statusText}`)}let A=h.body.getReader(),$=new TextDecoder,C="",x=[],_=null,I=Date.now(),y=!1;for(;;){let{done:a,value:R}=await A.read();if(a){y&&(x.length>0||_)&&(yield{candidates:x.length>0?[{content:{parts:x}}]:[],usageMetadata:_});break}C+=$.decode(R,{stream:!0});let d=C.split(`
|
|
589
|
+
`);C=d.pop();for(let r of d){let E=r.trim();if(!E||!E.startsWith("data: "))continue;let M=!1;if(E==="data: [DONE]")M=!0;else try{let U=JSON.parse(E.substring(6)),D=U.choices?.[0]?.delta,P=U.usage;if(P&&(_={totalTokenCount:P.total_tokens||(P.prompt_tokens||0)+(P.completion_tokens||0),promptTokenCount:P.prompt_tokens||0,candidatesTokenCount:P.completion_tokens||0,cachedContentTokenCount:P.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:P.completion_tokens_details?.reasoning_tokens||P.reasoning_tokens||0},y=!0),D){let le=D.reasoning_content||D.reasoning||null;!le&&Array.isArray(D.reasoning_details)&&D.reasoning_details.length>0&&(le=D.reasoning_details.map(fe=>fe.text||"").filter(Boolean).join("")),le&&(x.push({text:le,thought:!0}),y=!0),D.content&&(x.push({text:D.content}),y=!0)}}catch{}if((M||Date.now()-I>=150)&&y&&(yield{candidates:x.length>0?[{content:{parts:[...x]}}]:[],usageMetadata:_},x=[],I=Date.now(),y=!1),M)break}Date.now()-I>=150&&y&&(yield{candidates:x.length>0?[{content:{parts:[...x]}}]:[],usageMetadata:_},x=[],I=Date.now(),y=!1)}};var ti=async function*(e,t,n,s,o,c,f,l,k=1){let p=[];s&&p.push({role:"system",content:s});for(let a of n){let R=a.role==="user"?"user":"assistant",d=[];if(Array.isArray(a.parts)){for(let r of a.parts)if(r.text)d.push({type:"text",text:r.text});else if(r.inlineData&&f){let E=r.inlineData.mimeType,M=r.inlineData.data;E.startsWith("image/")&&d.push({type:"image_url",image_url:{url:`data:${E};base64,${M}`}})}}else{let r=a.text||"";r&&d.push({type:"text",text:r})}p.push({role:R,content:d.length===1&&d[0].type==="text"?d[0].text:d})}let g=He("TokenHarbor",t,o),m=g!==null?g:{Fast:"none",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[o],i={model:t,messages:p,stream:!0,stream_options:{include_usage:!0},temperature:k,tools:[],tool_choice:"none"};m&&(i.reasoning_effort=m);let u=process.env.TOKENHARBOR_URL||process.env.TOKEN_HARBOR_URL||"https://tokenharbor.ai/v1/chat/completions",b={"Content-Type":"application/json","X-Title":"Flux-Flow","User-Agent":"Flux-Flow","HTTP-Referer":"https://fluxflow-cli.onrender.com/"},O=e||process.env.TOKENHARBOR_API_KEY||process.env.TOKEN_HARBOR_API_KEY||"";b.Authorization=`Bearer ${O}`;let h=await Ze(u,{method:"POST",headers:b,body:JSON.stringify(i),signal:l});if(!h.ok){let a=await h.json().catch(()=>({}));throw new Error(`Token Harbor Error (${h.status}): ${a.error?.message||a.message||h.statusText}`)}let A=h.body.getReader(),$=new TextDecoder,C="",x=[],_=null,I=Date.now(),y=!1;for(;;){let{done:a,value:R}=await A.read();if(a){y&&(x.length>0||_)&&(yield{candidates:x.length>0?[{content:{parts:x}}]:[],usageMetadata:_});break}C+=$.decode(R,{stream:!0});let d=C.split(`
|
|
590
|
+
`);C=d.pop();for(let r of d){let E=r.trim();if(!E||!E.startsWith("data: "))continue;let M=!1;if(E==="data: [DONE]")M=!0;else try{let U=JSON.parse(E.substring(6)),D=U.choices?.[0]?.delta,P=U.usage;if(P&&(_={totalTokenCount:P.total_tokens||(P.prompt_tokens||0)+(P.completion_tokens||0),promptTokenCount:P.prompt_tokens||0,candidatesTokenCount:P.completion_tokens||0,cachedContentTokenCount:P.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:P.completion_tokens_details?.reasoning_tokens||P.reasoning_tokens||0},y=!0),D){let le=D.reasoning_content||D.reasoning||null;!le&&Array.isArray(D.reasoning_details)&&D.reasoning_details.length>0&&(le=D.reasoning_details.map(fe=>fe.text||"").filter(Boolean).join("")),le&&(x.push({text:le,thought:!0}),y=!0),D.content&&(x.push({text:D.content}),y=!0)}}catch{}if((M||Date.now()-I>=150)&&y&&(yield{candidates:x.length>0?[{content:{parts:[...x]}}]:[],usageMetadata:_},x=[],I=Date.now(),y=!1),M)break}Date.now()-I>=150&&y&&(yield{candidates:x.length>0?[{content:{parts:[...x]}}]:[],usageMetadata:_},x=[],I=Date.now(),y=!1)}};var ni=async function*(e,t,n,s,o,c,f,l,k=1){let p=[];s&&p.push({role:"system",content:s});for(let a of n){let R=a.role==="user"?"user":"assistant",d=[];if(Array.isArray(a.parts)){for(let r of a.parts)if(r.text)d.push({type:"text",text:r.text});else if(r.inlineData&&f){let E=r.inlineData.mimeType,M=r.inlineData.data;E.startsWith("image/")&&d.push({type:"image_url",image_url:{url:`data:${E};base64,${M}`}})}}else{let r=a.text||"";r&&d.push({type:"text",text:r})}p.push({role:R,content:d.length===1&&d[0].type==="text"?d[0].text:d})}let g=He("APInex",t,o),m=g!==null?g:{Fast:"low",Low:"low",Medium:"medium",Standard:"medium",High:"high",xHigh:"high"}[o],i={model:t,messages:p,stream:!0,stream_options:{include_usage:!0},temperature:k,tools:[],tool_choice:"none"};m&&(i.reasoning_effort=m);let u=process.env.APINEX_URL||"https://api.apinex.bond/v1/chat/completions",b={"Content-Type":"application/json","X-Title":"Flux-Flow","User-Agent":"Flux-Flow","HTTP-Referer":"https://fluxflow-cli.onrender.com/"},O=e||process.env.APINEX_API_KEY||"";b.Authorization=`Bearer ${O}`;let h=await Ze(u,{method:"POST",headers:b,body:JSON.stringify(i),signal:l});if(!h.ok){let a=await h.json().catch(()=>({}));throw new Error(`APInex Error (${h.status}): ${a.error?.message||a.message||h.statusText}`)}let A=h.body.getReader(),$=new TextDecoder,C="",x=[],_=null,I=Date.now(),y=!1;for(;;){let{done:a,value:R}=await A.read();if(a){y&&(x.length>0||_)&&(yield{candidates:x.length>0?[{content:{parts:x}}]:[],usageMetadata:_});break}C+=$.decode(R,{stream:!0});let d=C.split(`
|
|
591
|
+
`);C=d.pop();for(let r of d){let E=r.trim();if(!E||!E.startsWith("data: "))continue;let M=!1;if(E==="data: [DONE]")M=!0;else try{let U=JSON.parse(E.substring(6)),D=U.choices?.[0]?.delta,P=U.usage;if(P&&(_={totalTokenCount:P.total_tokens||(P.prompt_tokens||0)+(P.completion_tokens||0),promptTokenCount:P.prompt_tokens||0,candidatesTokenCount:P.completion_tokens||0,cachedContentTokenCount:P.prompt_tokens_details?.cached_tokens||0,thoughtsTokenCount:P.completion_tokens_details?.reasoning_tokens||P.reasoning_tokens||0},y=!0),D){let le=D.reasoning_content||D.reasoning||null;!le&&Array.isArray(D.reasoning_details)&&D.reasoning_details.length>0&&(le=D.reasoning_details.map(fe=>fe.text||"").filter(Boolean).join("")),le&&(x.push({text:le,thought:!0}),y=!0),D.content&&(x.push({text:D.content}),y=!0)}}catch{}if((M||Date.now()-I>=150)&&y&&(yield{candidates:x.length>0?[{content:{parts:[...x]}}]:[],usageMetadata:_},x=[],I=Date.now(),y=!1),M)break}Date.now()-I>=150&&y&&(yield{candidates:x.length>0?[{content:{parts:[...x]}}]:[],usageMetadata:_},x=[],I=Date.now(),y=!1)}};var La=/```[\s\S]*?```/g,Pa=/```[\s\S]*$/g,$a=/`[^`]+`/g,Na=/^\|.*\|$/gm,Fa=/^[^\w]+|[^\w]+$/g,Ba=/[^a-z0-9]/gi,wo=/\[\s*(?:tool|action):(?:functions\.)?([a-z0-9_]+)\s*\(/gi,Ua=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-z0-9_]+)\s*\(/gi,Wa=/(?:path|targetFile|TargetFile|directory|keyword|id|taskId|title|task)\s*=\s*\\?["']?([^\\"' \),]+)/,Gn=/["']/g,Br=/\\/g,Ha=/<\|channel>thought/gi,Ga=/<channel\|>/gi,ja=e=>typeof e!="string"?e:e.replace(Ha,"<think>").replace(Ga,"</think>"),cf=/^\s*(?:<(think|thought|thoughts)[^>]*>|<\|channel>thought|\[(think|thought|thoughts)\])[\s\S]*?(?:<\/(think|thought|thoughts)>|<channel\|>|\[\/(think|thought|thoughts)\]|$)/i,Ka=(e,t,n=1)=>{let s=t>0?e[t-1]:"",o=t+n<e.length?e[t+n]:"";return s==="`"&&o==="`"},Va=e=>{let t=/(?:<\/(think|thought|thoughts)>|<channel\|>|\[\/(think|thought|thoughts)\])/gi,n;for(;(n=t.exec(e))!==null;)if(!Ka(e,n.index,n[0].length))return{index:n.index,length:n[0].length};return{index:-1,length:0}},oi=e=>{if(!e||typeof e!="string")return null;let t=e.match(/^\s*(?:<(think|thought|thoughts)[^>]*>|<\|channel>thought|\[(think|thought|thoughts)\])/i);if(!t)return null;let n=t.index+t[0].length,s=e.substring(n),o=Va(s);if(o.index!==-1){let c=n+o.index+o.length;return{fullBlock:e.substring(0,c),innerContent:s.substring(0,o.index),remainingText:e.substring(c)}}return{fullBlock:e,innerContent:s,remainingText:""}},qt=e=>{if(!e||typeof e!="string")return e;let t=oi(e);return t?t.remainingText.trimStart():e};var Vr=/`[^`]*`/g,Yr=/`[^`]*$/,Ur=/<\|\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,Ya=/"([^"]+)"\s*:\s*(?:"([^"]*)"|(\d+)|true|false|null)/g,Wr=/<\|\s*tool_calls_section_begin\s*\|>/gi,Hr=/<\|\s*tool_calls_section_end\s*\|>/gi,qa=/```(?:tool|action|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi;var Gr=e=>!e||typeof e!="string"?e:e.replace(/(```[\s\S]*?```|`[^`]*`)|(<(?:\w+)(?:[^>]*)>\r?\n?|\r?\n?<\/\w+(?:[^>]*)>)/gi,(t,n)=>n||""),qr=e=>{if(!e||typeof e!="string")return e;let t=ko(e);if(!t||t.length===0)return e;let n=t[t.length-1];if(!n.fullMatch)return e;let s=e.lastIndexOf(n.fullMatch);if(s===-1)return e;let o=s+n.fullMatch.length;return e.substring(0,o).trimEnd()},ii=null,as={},jn={key:null,value:null},Yt=e=>e&&e.replace(/(?:(\x1b\[\d+m))?([✔✘✖🔍📖→➕↻↷•🛇])(?:(\x1b\[\d+m))?\s*\b(Clicked|Located|Dragged|Scrolled|Typed|Pressed Key|Recaptured Screen|Created|Read Skill|Read Documentation|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|Execution Error|Loop Detected|Contacting Ancestors)\b/ig,(t,n,s,o,c)=>`${n||""}${s}${o||""} \x1B[95m${c}\x1B[0m`),za=async(e,t=8,n=1e3,s=8e3,o=null)=>{let c=0;for(;;){if(o?.aborted)throw new DOMException("The user aborted a request.","AbortError");try{return await e()}catch(f){if(o?.aborted||f?.name==="AbortError"||f?.message==="Subagent task was cancelled."||(c++,c>=t))throw f;let l=Math.min(n*Math.pow(2,c-1),s);await new Promise((k,p)=>{let g=setTimeout(k,l);o&&o.addEventListener("abort",()=>{clearTimeout(g),p(new DOMException("The user aborted a request.","AbortError"))})})}}},kt=!1;var Xa=e=>{let t=e.filter(o=>(o.role==="user"||o.role==="agent"||o.role==="system")&&o.role!=="think"&&!o.isVisualFeedback&&!o.isMeta&&!o.isTerminalRecord&&!(o.text&&o.text.includes("[TERMINAL_RECORD]"))&&!String(o.id).startsWith("welcome")).map((o,c,f)=>{let l=o.fullText||o.text||"";if(o.role==="user"&&c<f.length-1)if(l.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")){let k=l.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");if(k!==-1){let g=l.substring(0,k).lastIndexOf("[SYSTEM METADATA]");g!==-1?l=l.substring(g).trim():l=l.substring(k).trim()}}else{let k=l.lastIndexOf("[USER]"),p=l.lastIndexOf("[USER PROMPT]");k!==-1?l=l.substring(k+6).trim():p!==-1&&(l=l.substring(p).trim())}return{...o,text:l}}),n=[],s=0;for(;s<t.length;){let o=t[s];if(o.role==="user")n.push(o),s++;else{let c=[];for(;s<t.length&&t[s].role!=="user";)c.push(t[s]),s++;let f=[],l=[],k=!1,p=()=>{f.length>0&&(n.push({role:"agent",text:"combined"}),f=[]),l.length>0&&(n.push({role:"system",text:"combined"}),l=[]),k=!1};c.forEach(g=>{let T=g.role==="system"&&(g.text?.startsWith("[ACTION RESULT]")||g.text?.startsWith("[TOOL RESULT]")||g.text?.startsWith("SUCCESS:")||g.text?.startsWith("ERROR:")||g.fullText?.startsWith("[ACTION RESULT]")||g.fullText?.startsWith("[TOOL RESULT]")||g.fullText?.startsWith("SUCCESS:")||g.fullText?.startsWith("ERROR:")),m=g.fullText||g.text||"",i=m.trim();if(!(!i&&!g.binaryPart)){if(T)l.push(i);else if(g.role==="agent"){!k&&l.length>0&&p();let u=m.endsWith(`
|
|
592
|
+
`),b=i.toLowerCase().includes("tool:")||i.toLowerCase().includes("action:");f.push(i),b&&u?k=!0:k=!1}}}),p()}}return n.length},Ja=e=>typeof e!="string"?e:e.replace(/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]/g,""),df=()=>{kt=!0},ff=()=>kt,si={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",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"},Kn=(e,t)=>{try{let n=oe(t),s=e.toLowerCase().replace(/_/g,"");if(s==="invokesync"||s==="invoke")return n.title||(n.task?n.task.substring(0,30):null);if(s==="getprogress"||s==="cancel"||s==="steer"||s==="steersubagent")return n.id||n.taskId;let o=n.name||n.path||n.targetFile||n.TargetFile||n.directory||n.file||n.query;return o?ae.basename(o.replace(/["']/g,"").replace(/\\/g,"/")):null}catch{return null}},ri=e=>e?new Kr({apiKey:e}):ii,uf=async(e,t,n,s,o={})=>{let{onStatus:l,onMemoryUpdated:k,onBackgroundIncrement:p}=o,{profile:g,thinkingLevel:T,mode:m,janitorModel:i,chatId:u,systemSettings:b,sessionStats:O,aiProvider:h="Google",apiKey:A}=e,$=process.env.NVIDIA_BASE_URL||h==="Ollama"||h==="InferX"||h==="SenseNova"||h==="AIHubMix"||h==="Poolside"||h==="9router"||h==="ExpLabs"||h==="ExperientialLabs"?!1:b?.memory!==!1,x=Mt(Wn,[]).map(L=>`- [${L.id}]: ${L.memory}`).join(`
|
|
593
|
+
`),_=s.slice(0,-1).filter(L=>L.text&&!L.text.includes("[ACTION RESULT]")&&!L.text.includes("[TOOL RESULT]")&&!L.text.includes("OBSERVATION:")&&!L.text.startsWith("[TERMINAL_RECORD]")&&!L.isTerminalRecord&&!L.isMeta&&!L.isLogo&&!String(L.id).startsWith("welcome")&&!String(L.id).startsWith("logo")).slice(-14).map(L=>{let N=qt(Ja(L.text)).replace(/\[(?:tool|action):(?:functions\.)?.*?\]/g,"").replace(/\[Prompted on:.*?\]/g,"").replace(/\[METADATA \(PRIORITY: DYNAMIC\)\] Time: ([^|\n]+)/g,(G,ye)=>`[METADATA (PRIORITY: DYNAMIC)] Time: ${ye.replace(/:\d{2}/g,"")}`).replace(/\[\[\s*turn\s*:\s*(continue|finish)\s*\]\]/gi,"").replace(/\[\[END\]\]/g,"").replace(/\[\[(?:TOOL|ACTION) RESULTS\]\]/gi,"").replace(/\[(?:TOOL|ACTION) RESULTS?\]/gi,"").replace(/\[(?:tool|action) results\]/gi,"").replace(/\r?\n\r?\n/g,`
|
|
595
594
|
`).replace(/\n\n/g,`
|
|
596
|
-
`).replace(/\\n\\n/g,"").trim(),Ee=L.role==="user"?8192:32768,
|
|
597
|
-
... (truncated) ...`);let B=L.role==="user"?
|
|
598
|
-
... (truncated) ...`);let
|
|
595
|
+
`).replace(/\\n\\n/g,"").trim(),Ee=L.role==="user"?8192:32768,ie=N.substring(0,Ee);N.length>Ee&&(ie+=`
|
|
596
|
+
... (truncated) ...`);let B=L.role==="user"?ie.startsWith("[USER]")?"":"[USER]: ":ie.startsWith("[AGENT]")?"":"[AGENT]: ";return{role:L.role==="user"?"user":"model",parts:[{text:`${B}${ie}`}]}}),I=s.filter(L=>L.role==="user").length===1,y=t.includes("[TITLE-UPDATE]"),a=Math.random()<.8,R=I||y||a,d=qt(n).trim(),r=ur(x,$,R),E=`${d.replace(/\[(?:tool|action):(?:functions\.)?.*?\]/g,"").replace(/\[Prompted on:.*?\]/g,"").replace(/\[\[\s*turn\s*:\s*(continue|finish)\s*\]\]/gi,"").replace(/\[\[END\]\]/g,"").replace(/\[\[(?:TOOL|ACTION) RESULTS\]\]/gi,"").replace(/\[(?:TOOL|ACTION) RESULTS?\]/gi,"").replace(/\[(?:tool|action) results\]/gi,"").substring(0,32768)}`;E.length>32768&&(E+=`
|
|
597
|
+
... (truncated) ...`);let M=t.replace(/\[Prompted on:.*?\]/g,"").trim();E=E.replace(/\r?\n\r?\n/g,`
|
|
599
598
|
`).replace(/\n\n/g,`
|
|
600
599
|
`).replace(/\\n\\n/g,"").trim();let U=new Date,P=`[METADATA] Current date and Time: ${`${U.getFullYear()}-${U.toLocaleString("en-US",{month:"short"}).toUpperCase()}-${String(U.getDate()).padStart(2,"0")}, ${U.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}`}
|
|
601
600
|
|
|
602
|
-
[USER]: ${
|
|
603
|
-
${
|
|
601
|
+
[USER]: ${M.substring(0,8192)}
|
|
602
|
+
${M.length>8192?`... (truncated) ...
|
|
604
603
|
|
|
605
604
|
`:""}
|
|
606
|
-
[AGENT (current turn)]: ${E}`;_.push({role:"user",parts:[{text:P}]});let
|
|
605
|
+
[AGENT (current turn)]: ${E}`;_.push({role:"user",parts:[{text:P}]});let le=await Ss("NVIDIA"),Z=(await ao()).quotas?.providerTiers?.NVIDIA==="Free",we="",ce=0,rt=$?12:-1;for(;ce<=rt;)try{if(!await ki("background",e))return;let L="",N=null,Ee=!1,ie=h;try{let ye=new Promise((Je,xe)=>setTimeout(()=>xe(new Error("JANITOR_TIMEOUT")),1e4)),Re=h==="Google"&&ce>=0&&ce<6&&le&&Z,Me=h==="DeepSeek"&&ce<4&&le&&Z;Ee=Re||Me,ie=Ee?"NVIDIA":h;let Ie=(async()=>{if(h==="OpenRouter"){let Je=pe("janitor_open_router"),te=es(A,Je,_,r,"Fast",m,!1,null,.7)[Symbol.asyncIterator](),Wt=await te.next();return{iterator:te,firstResult:Wt}}else if(h==="DeepSeek"&&!Ee){let xe=Jo(A,pe("deepseek_fast_fallback"),_,r,"Fast",m,!1,null,.7)[Symbol.asyncIterator](),te=await xe.next();return{iterator:xe,firstResult:te}}else if(h==="Mistral"&&!Ee){let xe=Qo(A,pe("mistral_janitor_fallback"),_,r,"Fast",m,!1,null,.7)[Symbol.asyncIterator](),te=await xe.next();return{iterator:xe,firstResult:te}}else if(h==="NVIDIA"||Ee){let xe=Zo(Ee?le:A,pe("nvidia_janitor_fallback"),_,r,"Fast",m,!1,null,.7)[Symbol.asyncIterator](),te=await xe.next();return{iterator:xe,firstResult:te}}else if(h==="InferX"){let xe=ts(A,targetModel||pe("inferx_fallback")||"deepseek-v4-flash",_,r,"Fast",m,!1,null,.7)[Symbol.asyncIterator](),te=await xe.next();return{iterator:xe,firstResult:te}}else if(h==="SenseNova"){let xe=ns(A,targetModel||pe("sensenova_fallback")||"sensenova-6.8-flash-lite",_,r,"Fast",m,!1,null,.7)[Symbol.asyncIterator](),te=await xe.next();return{iterator:xe,firstResult:te}}else if(h==="AIHubMix"){let xe=os(A,targetModel||pe("aihubmix_fallback")||"gpt-4o-mini",_,r,"Fast",m,!1,null,.7)[Symbol.asyncIterator](),te=await xe.next();return{iterator:xe,firstResult:te}}else if(h==="Poolside"){let xe=ss(A,targetModel||pe("poolside_fallback")||"poolside/laguna-s-2.1",_,r,"Fast",m,!1,null,.7)[Symbol.asyncIterator](),te=await xe.next();return{iterator:xe,firstResult:te}}else if(h==="9router"||h==="9Router"){let xe=is(A,targetModel||pe("9router_fallback")||"z-ai/glm-5.3-flash",_,r,"Fast",m,!1,null,.7)[Symbol.asyncIterator](),te=await xe.next();return{iterator:xe,firstResult:te}}else if(h==="ExpLabs"||h==="ExperientialLabs"){let xe=rs(A,targetModel||pe("explabs_fallback")||"deepseek-v4-pro-0813",_,r,"Fast",m,!1,null,.7)[Symbol.asyncIterator](),te=await xe.next();return{iterator:xe,firstResult:te}}else{let te=(await ri(A).models.generateContentStream({model:i||(ce===rt?pe("janitor_default"):pe("gemma_janitor_fallback_google")),contents:_,config:{systemInstruction:r,temperature:.7,safetySettings:[{category:In.HARM_CATEGORY_HARASSMENT,threshold:vn.BLOCK_NONE},{category:In.HARM_CATEGORY_HATE_SPEECH,threshold:vn.BLOCK_NONE},{category:In.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:vn.BLOCK_NONE},{category:In.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:vn.BLOCK_NONE}],thinkingConfig:{includeThoughts:!1,thinkingLevel:Xe.MINIMAL},serviceTier:"flex"}}))[Symbol.asyncIterator](),Wt=await te.next();return{iterator:te,firstResult:Wt}}})();if(process.stdout.isTTY){let te=(await Cs())[u]?.name||"",Wt=te&&!te.startsWith("flow-")&&!te.startsWith("Session ")?te:"FluxFlow | Idle";process.stdout.write(`\x1B]0;${Wt}\x07`),process.stdout.write(`\x1B]633;P;TerminalTitle=${Wt}\x07`)}let{iterator:On,firstResult:nn}=await Promise.race([Ie,ye]),{value:pt,done:Tt}=nn;if(!Tt&&pt){let Je=pt.candidates?.[0]?.content?.parts,xe=Je?ie==="Google"?Je[1]?.text||Je[0]?.text||"":Je.filter(te=>te.text&&!te.thought).map(te=>te.text).join(""):typeof pt.text=="function"?pt.text():"";xe&&(L+=xe),N=pt.usageMetadata;for await(let te of{[Symbol.asyncIterator]:()=>On}){let Wt=te.candidates?.[0]?.content?.parts,Dn=Wt?ie==="Google"?Wt[1]?.text||Wt[0]?.text||"":Wt.filter(Ln=>Ln.text&&!Ln.thought).map(Ln=>Ln.text).join(""):typeof te.text=="function"?te.text():"";Dn&&(L+=Dn),N=te.usageMetadata}}}catch(ye){throw ye}if(L){if(we=L,N){let ye=N.totalTokenCount||0,Re=N.cachedContentTokenCount||0,Me=(N.candidatesTokenCount||0)+(ie==="Google"&&N.thoughtsTokenCount||0),Ie=Ee?pe("nvidia_janitor_fallback"):ie==="DeepSeek"?pe("deepseek_fast_fallback"):ie==="ExpLabs"||ie==="ExperientialLabs"?pe("explabs_fallback")||"deepseek-v4-pro-0813":ie==="OpenRouter"?pe("janitor_open_router"):i||(ce===rt?pe("janitor_default"):pe("gemma_janitor_fallback_google"));await Bt("tokens",ye,ie,Ie),Re>0&&await Bt("cachedTokens",Re,ie,Ie),Me>0&&await Bt("candidateTokens",Me,ie,Ie),Oo({provider:ie,model:Ie,prompt:N.promptTokenCount||0,cached:Re,output:Me,reasoning:N.thoughtsTokenCount||0})}}else throw new Error("No synthesis generated by Janitor.");p&&(p(),await vt("background"));let B=ko(we),G=!1;for(let ye of B){let Re=ye.toolName;["addMemScore","add_mem_score","AddMemScore","addMemoryScore","AddMemoryScore"].includes(Re)&&(G=!0);let Me={chatId:u,sessionId:u,history:s},Ie=await xo(Re,ye.args,Me);Re.toLowerCase()==="memory"&&(ye.args.includes("action='user'")||ye.args.includes('action="user"'))&&!Ie.startsWith("ERROR")&&(k&&k(),process.stdout.isTTY&&(process.stdout.write("\x1B]0;Memory Updated\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=Memory Updated\x07")),await new Promise(nn=>setTimeout(nn,3e3)))}if(!G)try{let ye=Mt(Wn,[]);if(ye.length>0){let Re=[];for(let Me of ye)Me.score===void 0&&(Me.score=.5),Me.score*=.99995,Me.score<.05&&(Me.score=0),Me.score=Math.round(Me.score*1e5)/1e5,Me.score>0&&Re.push(Me);Xn(Wn,Re)}}catch{}break}catch(L){ce++;let N=new Date().toLocaleString(),Ee=L instanceof Error?(()=>{try{return JSON.parse(JSON.parse(L.message).error.message).error.message}catch{return String(L)}})():String(L);await new Promise(G=>setTimeout(G,1e3));let ie=ae.join(Cn,"janitor");if(Ue.existsSync(ie)||Ue.mkdirSync(ie,{recursive:!0}),Ue.appendFileSync(ae.join(ie,"error.log"),`ERROR [Attempt ${ce}/${rt+1}] [${N}]: ${Ee}
|
|
607
606
|
|
|
608
|
-
`),
|
|
607
|
+
`),ce>rt)break;let B=Math.min(750*Math.pow(2,ce-1),5e3);await new Promise(G=>setTimeout(G,B))}if(ce){let L=ae.join(Cn,"janitor");Ue.appendFileSync(ae.join(L,"error.log"),`-----------------------------------------------------------------------------
|
|
609
608
|
|
|
610
|
-
`)}if(process.stdout.isTTY)try{let Ee=(await Cs())[u]?.name||"",
|
|
609
|
+
`)}if(process.stdout.isTTY)try{let Ee=(await Cs())[u]?.name||"",ie=Ee&&!Ee.startsWith("flow-")&&!Ee.startsWith("Session ")?Ee:"FluxFlow | Idle";process.stdout.write(`\x1B]0;${ie}\x07`),process.stdout.write(`\x1B]633;P;TerminalTitle=${ie}\x07`)}catch{process.stdout.write("\x1B]0;FluxFlow | Idle\x07"),process.stdout.write("\x1B]633;P;TerminalTitle=FluxFlow | Idle\x07")}},Qa=e=>{let t=qt(e),n=Es?t:t.replace(Vr,o=>" ".repeat(o.length)).replace(Yr,o=>" ".repeat(o.length));wo.lastIndex=0;let s;for(;(s=wo.exec(n))!==null;){let o=s.index+s[0].length-1,c=0,f=null,l=!1,k=!1;for(let p=o;p<n.length;p++){let g=t[p];if(!f&&(g==='"'||g==="'"||g==="`")?(f=g,l=!1):f&&g===f&&!l&&(f=null),!f&&(g==="("?c++:g===")"&&c--,c===0)){let T=p+1;for(;T<n.length&&/\s/.test(n[T]);)T++;if(T<n.length&&n[T]==="]"){k=!0,wo.lastIndex=T+1;break}}g==="\\"?l=!l:l=!1}if(!k)return{inside:!0,toolName:s[1],startIndex:s.index,args:t.substring(s.index+s[0].length)}}return{inside:!1}},zr=(e,t=!0)=>{let n=wo;n.lastIndex=0;let s="",o=0,c;for(;(c=n.exec(e))!==null;){let f=e.substring(o,c.index);s+=t&&o===0?qt(f):f;let l=c.index+c[0].length-1,k=0,p=null,g=-1;for(let T=l;T<e.length;T++){let m=e[T];if(p){if(m===p){let i=0;for(let u=T-1;u>=0&&e[u]==="\\";u--)i++;i%2===0&&(p=null)}}else if(m==='"'||m==="'"||m==="`")p=m;else if(m==="(")k++;else if(m===")"&&(k--,k===0)){let i=T+1;for(;i<e.length&&/\s/.test(e[i]);)i++;if(i<e.length&&e[i]==="]"){g=i;break}}}if(g!==-1)s+="[tool:functions."+c[1]+"()]",o=g+1,n.lastIndex=o;else{s+="[tool:functions."+c[1]+"(",o=e.length;break}}return o<e.length&&(s+=t&&o===0?qt(e.substring(o)):e.substring(o)),s},Za=(e,t,n)=>{let s=wo;s.lastIndex=0;let o="",c=0,f;for(;(f=s.exec(e))!==null;){let l=e.substring(c,f.index);o+=l.replace(t,n);let k=f.index+f[0].length-1,p=0,g=null,T=-1;for(let m=k;m<e.length;m++){let i=e[m];if(g){if(i===g){let u=0;for(let b=m-1;b>=0&&e[b]==="\\";b--)u++;u%2===0&&(g=null)}}else if(i==='"'||i==="'"||i==="`")g=i;else if(i==="(")p++;else if(i===")"&&(p--,p===0)){let u=m+1;for(;u<e.length&&/\s/.test(e[u]);)u++;if(u<e.length&&e[u]==="]"){T=u;break}}}if(T!==-1)o+=e.substring(f.index,T+1),c=T+1,s.lastIndex=c;else{o+=e.substring(f.index),c=e.length;break}}return c<e.length&&(o+=e.substring(c).replace(t,n)),o},jr=e=>zr(e,!0),el=e=>{if(!e)return e;let t={patchfile:"PatchFile",writefile:"WriteFile",readfile:"ReadFile",viewfile:"ReadFile",run:"Run",execcommand:"Run",searchkeyword:"SearchKeyword",codesearch:"CodeSearch",code_search:"CodeSearch",websearch:"WebSearch",webscrape:"WebScrape",readfolder:"ReadFolder",writepdf:"WritePDF",writedoc:"WriteDoc",writedocx:"WriteDoc",filemap:"FileMap",generateimage:"GenerateImage",todo:"Todo",goal:"Goal",askuser:"AskUser",ask:"AskUser"},n=o=>o.split("_").map(c=>c.charAt(0).toUpperCase()+c.slice(1)).join("");Ur.lastIndex=0;let s=e.replace(Ur,(o,c,f)=>{let l="";try{let g=JSON.parse(f.trim());g&&typeof g=="object"&&(l=Object.entries(g).map(([m,i])=>{let u=typeof i=="string"?i:JSON.stringify(i);return`${m}=${JSON.stringify(u)}`}).join(", "))}catch{let T=[],m=Ya;m.lastIndex=0;let i;for(;(i=m.exec(f))!==null;){let u=i[1],b=i[2]!==void 0?i[2]:i[0].split(":").slice(1).join(":").trim();T.push(`${u}=${JSON.stringify(b)}`)}T.length>0?l=T.join(", "):l=f.trim()}let k=c.toLowerCase().replace(/_/g,"");return`[tool:functions.${t[k]||n(c)}(${l})]`});return Wr.lastIndex=0,Hr.lastIndex=0,s=s.replace(Wr,""),s=s.replace(Hr,""),s},tl=/(?:path|query|url|keyword|command|method|title|task|id)\s*=\s*['"`]?\s*\.\.\.\s*['"`]?/i,nl=/^['"`]?\s*\.\.\.\s*['"`]?$/,bn=e=>{if(e==null)return!1;let t=String(e).trim();return t==="..."||t==="\u2026"||nl.test(t)},ko=e=>{if(!e)return[];let t=el(e),n=qt(t),s=[],o=Es?n:n.replace(Vr,l=>" ".repeat(l.length)).replace(Yr,l=>" ".repeat(l.length)),c=Ua;c.lastIndex=0;let f;for(;(f=c.exec(o))!==null;){let l=f[1],k=f.index+f[0].length-1,p=0,g=null,T=-1,m=-1;for(let i=k;i<o.length;i++){let u=n[i];if(g){if(u===g){let b=0;for(let O=i-1;O>=0&&n[O]==="\\";O--)b++;b%2===0&&(g=null)}}else if(u==='"'||u==="'"||u==="`")g=u;else if(u==="(")p++;else if(u===")"&&(p--,p===0)){m=i;let b=i+1;for(;b<o.length&&/\s/.test(o[b]);)b++;if(b<o.length&&o[b]==="]"){T=b;break}}}if(T!==-1){let i=n.substring(k+1,m),u=n.substring(f.index,T+1),b=oe(i);bn(b.path)||bn(b.query)||bn(b.url)||bn(b.keyword)||bn(b.command)||bn(b.method)||bn(b.title)||bn(b.task)||bn(b.id)||tl.test(i)||s.push({fullMatch:u,toolName:l.trim(),args:i.trim()}),c.lastIndex=T+1}}return s},gf=(e,t={})=>{if(!e)return null;if(as=t,ii=new Kr({apiKey:e}),!globalThis.__perfCleanupInstalled){globalThis.__perfCleanupInstalled=!0,setInterval(()=>{typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks())},6e4);let n=globalThis.fetch;globalThis.fetch=async(...s)=>{try{let o=await n(...s);return typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),o}catch(o){throw typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),o}}}},Xr=e=>{if(!e)return{serviceTier:void 0,cleanModel:e};let t=e.toLowerCase();return t.endsWith(":flex")?{serviceTier:"flex",cleanModel:e.slice(0,-5)}:t.endsWith(":priority")?{serviceTier:"priority",cleanModel:e.slice(0,-9)}:{serviceTier:void 0,cleanModel:e}},ls=async(e,t,n,s,o="Fast",c=.75,f="agent")=>za(async()=>{let{aiProvider:l="Google",apiKey:k,mode:p}=e,g="",T=null,m=typeof n=="string"?[{role:"user",parts:[{text:n}]}]:n,i=new AbortController,u=i.signal,b=setInterval(()=>{kt&&(i.abort(),clearInterval(b))},100);try{let O;if(l==="Ollama")O=ei(k,t,m,s,o,p,ut(t),u,c,e.systemSettings?.ollamaEndpoint||"Cloud");else if(l==="OpenRouter")O=es(k,t,m,s,o,p,ut(t),u,c);else if(l==="DeepSeek")O=Jo(k,t,m,s,o,p,ut(t),u,c);else if(l==="Mistral")O=Qo(k,t,m,s,o,p,ut(t),u,c);else if(l==="NVIDIA")O=Zo(k,t,m,s,o,p,ut(t),u,c);else if(l==="InferX")O=ts(k,t,m,s,o,p,ut(t),u,c);else if(l==="SenseNova")O=ns(k,t,m,s,o,p,ut(t),u,c);else if(l==="AIHubMix")O=os(k,t,m,s,o,p,ut(t),u,c);else if(l==="Poolside")O=ss(k,t,m,s,o,p,ut(t),u,c);else if(l==="9router"||l==="9Router")O=is(k,t,m,s,o,p,ut(t),u,c);else if(l==="ExpLabs"||l==="ExperientialLabs")O=rs(k,t,m,s,o,p,ut(t),u,c);else if(l==="TokenHarbor"||l==="Token Harbor"||l==="tokenharbor"||l==="token_harbor"||l==="thk")O=ti(k,t,m,s,o,p,ut(t),u,c);else if(l==="APInex"||l==="apinex"||l==="apx")O=ni(k,t,m,s,o,p,ut(t),u,c);else{let h=ri(k),{serviceTier:A,cleanModel:$}=Xr(t),C={systemInstruction:s,temperature:c,thinkingConfig:(()=>{let _=(t||"").toLowerCase(),I=_.includes("gemma-4")||_.startsWith("gemma"),y=_.includes("gemini-3");if(I||y)return I?o.toLowerCase()!=="xhigh"?{includeThoughts:!1,thinkingLevel:Xe.MINIMAL}:{includeThoughts:!0,thinkingLevel:Xe.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:_.includes("pro")?Xe.LOW:Xe.MINIMAL,Low:Xe.LOW,Medium:Xe.MEDIUM,Standard:Xe.MEDIUM,High:Xe.HIGH,xHigh:Xe.HIGH}[o]||Xe.MEDIUM};{let a={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[o]||2048;return a===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:a}}})()};A&&(C.serviceTier=A),O=await h.models.generateContentStream({model:$,contents:m,config:C},{signal:u})}for await(let h of O){if(kt)throw new Error("Subagent task was cancelled.");if(e?.taskId&&typeof Vt<"u"){let C=Vt.find(x=>x.id===e.taskId);if(C&&C.status==="cancelled")throw new Error("Subagent task was cancelled.")}let A="";if(h.candidates?.[0]?.content?.parts)for(let C of h.candidates[0].content.parts)C.text&&!C.thought&&(g+=C.text,A+=C.text);let $=A?As(A):0;e&&typeof e.onTokenChunk=="function"&&e.onTokenChunk(A,$),h.usageMetadata&&(T=h.usageMetadata)}}finally{clearInterval(b)}if(T){let O=T.totalTokenCount||0,h=T.cachedContentTokenCount||0,A=(T.candidatesTokenCount||0)+(l==="Google"&&T.thoughtsTokenCount||0);await Bt("tokens",O,l,t),h>0&&await Bt("cachedTokens",h,l,t),A>0&&await Bt("candidateTokens",A,l,t),Oo({provider:l,model:t,prompt:T.promptTokenCount||0,cached:h,output:A,reasoning:T.thoughtsTokenCount||0}),e&&typeof e.onUsage=="function"&&e.onUsage({totalTokenCount:O,cachedContentTokenCount:h,candidatesTokenCount:A})}return await vt("agent",l),{text:g,usageMetadata:T}}),ol=async(e,t,n=null)=>{n=n||Mt(Mo,{});try{let{aiProvider:s="Google"}=t;if(Object.values(n).flat().length<=5)return;let c=Object.keys(n).filter(m=>m!==e&&Array.isArray(n[m])&&n[m].length>2);if(c.length===0)return;let f=`You are a silent background process for the FluxFlow CLI Agent.
|
|
611
610
|
Your task is to summarize or merge temporary context memories from one or more past conversation sessions.
|
|
612
611
|
For each Chat ID provided, you must output a tool call to save the consolidated summary.
|
|
613
612
|
|
|
@@ -622,9 +621,9 @@ Guidelines:
|
|
|
622
621
|
|
|
623
622
|
Chats to process:
|
|
624
623
|
|
|
625
|
-
`,l=
|
|
626
|
-
`),
|
|
627
|
-
`,
|
|
624
|
+
`,l=Mt(ks,{});for(let m of c){let u=n[m].map(O=>`- ${O}`).join(`
|
|
625
|
+
`),b=l[m];f+=`[Chat ID: ${m}]
|
|
626
|
+
`,b?(f+=`- Existing Summary: "${b}"
|
|
628
627
|
`,f+=`
|
|
629
628
|
-- New Memories to integrate:
|
|
630
629
|
${u}
|
|
@@ -632,10 +631,10 @@ ${u}
|
|
|
632
631
|
`):f+=`-- Individual Memories:
|
|
633
632
|
${u}
|
|
634
633
|
|
|
635
|
-
`}let k=0,
|
|
636
|
-
`)}},hf=async(e,t,n=!1)=>{let{chatId:s,aiProvider:o="Google"}=e,c=
|
|
634
|
+
`}let k=0,p=5,g=!1,T=pe("gemma_janitor_fallback_google");for(s==="OpenRouter"&&(T=pe("janitor_open_router")),s==="DeepSeek"&&(T=pe("deepseek_level_1")),s==="Mistral"&&(T=pe("mistral_level_1")),s==="NVIDIA"&&(T=pe("nvidia_janitor_fallback")),s==="InferX"&&(T=pe("inferx_fallback")),s==="SenseNova"&&(T=pe("sensenova_fallback")),s==="AIHubMix"&&(T=pe("aihubmix_fallback")),s==="Poolside"&&(T=pe("poolside_fallback")),(s==="9router"||s==="9Router")&&(T=pe("9router_fallback"));k<=p&&!g;){k++;try{let i=(await ls(t,T,f,null,"Fast",.75,"background")).text||"",u=ko(i);if(u.length===0)throw new Error("No tool calls detected in synthesis response");for(let b of u){let O=b.toolName;["saveSummary","saveSumary","SaveSummary","SaveSumary"].includes(O)&&await xo(O,b.args,{chatId:e})}g=!0}catch(m){if(k>=p)throw new Error(`Failed after ${p} attempts. Last error: ${m.message}`)}}}catch(s){let o=s instanceof Error?(()=>{try{return JSON.parse(JSON.parse(s.message).error.message).error.message}catch{return String(s)}})():String(s),c=ae.join(Cn,"janitor");Ue.existsSync(c)||Ue.mkdirSync(c,{recursive:!0}),Ue.appendFileSync(ae.join(c,"error.log"),`[${new Date().toLocaleString()}] Past memory batch consolidation error: ${o}
|
|
635
|
+
`)}},hf=async(e,t,n=!1)=>{let{chatId:s,aiProvider:o="Google"}=e,c=ae.join(Ro,"chat-summaries.json"),f=i=>i.filter(u=>(u.role==="user"||u.role==="agent"||u.role==="system")&&u.role!=="think"&&!u.isVisualFeedback&&!u.isMeta&&!u.isTerminalRecord&&!(u.text&&u.text.includes("[TERMINAL_RECORD]"))&&!String(u.id).startsWith("welcome")).map(u=>{let b=u.fullText||u.text||"",O=u.role==="system"||b.startsWith("[ACTION RESULT]:")||b.startsWith("[TOOL RESULT]:")||u.text&&(u.text.startsWith("[ACTION RESULT]:")||u.text.startsWith("[TOOL RESULT]:")),h=b;return O&&(b.includes("[ACTION RESULT]:")||b.includes("[TOOL RESULT]:")||u.text&&(u.text.includes("[ACTION RESULT]:")||u.text.includes("[TOOL RESULT]:")))?h="[ACTION RESULT]: ...truncated for summary":h=h.replace(/(\[(?:tool|action):[a-zA-Z0-9_\.]+)\([\s\S]*?\)(\])/g,"$1(...)$2"),`[${O?"ACTION":u.role==="agent"?"AGENT":"USER"}]: ${h}`}).join(`
|
|
637
636
|
|
|
638
|
-
`),l=async(i,u)=>{let
|
|
637
|
+
`),l=async(i,u)=>{let b="You are an expert context summarizer. Summarize the provided chat history (which may include previous summaries, user instructions, agent outputs, and tool results) into a detailed, coherent, and highly technical summary of 1000 to 1500 words. Focus on preserving the architectural decisions made, current system state, task progress, and critical code details, chat messages, file changes. Under no circumstances exceed MAX 2000 words.",O=u?`Here is the previous summary:
|
|
639
638
|
${u}
|
|
640
639
|
|
|
641
640
|
Here is the new conversation history:
|
|
@@ -644,40 +643,40 @@ ${i}
|
|
|
644
643
|
Provide a new consolidated summary of the entire session.`:`Here is the conversation history:
|
|
645
644
|
${i}
|
|
646
645
|
|
|
647
|
-
Provide a consolidated summary of the entire session.`,h=
|
|
648
|
-
`),L=
|
|
649
|
-
`),
|
|
646
|
+
Provide a consolidated summary of the entire session.`,h=pe("gemma_janitor_fallback_google");o==="OpenRouter"&&(h=pe("janitor_open_router")),o==="DeepSeek"&&(h=pe("deepseek_level_1")),o==="Mistral"&&(h=pe("mistral_level_1")),o==="NVIDIA"&&(h=pe("nvidia_chat_summarizer_fallback")),o==="InferX"&&(h=pe("inferx_fallback")),o==="SenseNova"&&(h=pe("sensenova_fallback")),o==="AIHubMix"&&(h=pe("aihubmix_fallback")),o==="Poolside"&&(h=pe("poolside_fallback")),(o==="9router"||o==="9Router")&&(h=pe("9router_fallback")),(o==="ExpLabs"||o==="ExperientialLabs")&&(h=pe("explabs_fallback")||"deepseek-v4-pro-0813"),(o==="TokenHarbor"||o==="Token Harbor"||o==="tokenharbor"||o==="token_harbor"||o==="thk")&&(h=pe("tokenharbor_fallback")||"deepseek-v4.1-flash:free");let A=0,$=!1,C=null;for(;A<=3&&!$;){A++;try{C=await ls(e,h,O,b,"Fast"),$=!0}catch{if(A>3){if(o==="Google")try{let _=pe("general_fallback");return(await ls(e,_,O,b,"Fast")).text||""}catch{return""}return""}}}return C&&C.text||""},k=f(t),p=Mt(c,{}),g=p[s]||{summary:"",historyLength:0};typeof g=="string"&&(g={summary:g,historyLength:0});let T=g.summary||"",m=await l(k,T);if(m){g.summary=m;let i=Xa(t);return n?g.historyLength=(g.historyLength||0)+i:g.historyLength=i,p[s]=g,Xn(c,p),m}return null},mf=e=>{try{let t=ae.join(Ro,"chat-summaries.json");if(Ue.existsSync(t)){let n=Mt(t,{});n[e]&&(delete n[e],Xn(t,n))}}catch{}},pf=async function*(e,t,n,s,o){let{profile:c,thinkingLevel:f,mode:l,janitorModel:k,chatId:p,isPlayground:g,systemSettings:T,sessionStats:m,aiProvider:i="Google",apiTier:u,wildcardTooling:b,wildercardTooling:O}=n,h=ut(e);if(!ii&&i==="Google")throw new Error("AI not initialized");let A=process.env.NVIDIA_BASE_URL||n?.aiProvider==="Ollama"||n?.aiProvider==="InferX"||n?.aiProvider==="SenseNova"||n?.aiProvider==="AIHubMix"||n?.aiProvider==="Poolside"||n?.aiProvider==="9router"||n?.aiProvider==="ExpLabs"||n?.aiProvider==="ExperientialLabs"||n?.aiProvider==="TokenHarbor"||n?.aiProvider==="Token Harbor"||n?.aiProvider==="tokenharbor"||n?.aiProvider==="token_harbor"||n?.aiProvider==="thk"||n?.aiProvider==="APInex"||n?.aiProvider==="apinex"||n?.aiProvider==="apx"?!1:T?.memory!==!1,$=t[t.length-1].text,C=ae.join(Ro,"chat-summaries.json"),x=!1,_=t.filter(d=>d.role==="user").length===1,I=$.includes("[TITLE-UPDATE]"),y=_||I,a=$.replace(/\[TITLE-UPDATE\]/g,"").trim();a=a.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),yield{type:"status",content:"[start]"},yield{type:"status",content:"Gathering Context"},await Do.startTransaction(p,a),T?.advanceRollback&&await lo.takeInitialSnapshot(p),kt=!1;let R=null;try{let d=new AbortController;R=setInterval(()=>{kt&&(d.abort(),R&&(clearInterval(R),R=null))},400);let r=[...t.slice(0,-1)];{let Ke=Mt(C,{})[p]||{summary:"",historyLength:0};if(Ke.summary&&Ke.historyLength>0){let fn=0,st=[];for(let Be=0;Be<r.length;Be++){let it=r[Be];(it.role==="user"||it.role==="agent"||it.role==="system")&&!String(it.id).startsWith("welcome")&&!it.isMeta&&fn++,fn>Ke.historyLength&&st.push(it)}r=st}}r=r.map(K=>{if(K.role==="user"&&K.text){let Ke=K.text.match(/\[USER\]([\s\S]*?)\[\/USER\]/);if(Ke)return{...K,text:Ke[1].trim()}}return{...K}});let E=process.env.HIGH_CONTEXT,M=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1,P={"16k":16e3,"32k":32e3,"64k":64e3,"128k":128e3,"256k":256e3,"512k":512e3,"1M":1e6}[T?.contextLength]||256e3;if(E&&E!=="false"){let K=parseInt(E,10);!isNaN(K)&&K>=0&&K<=1e6&&(P=K)}if((i==="NVIDIA"&&(e?.includes("gpt")||e?.includes("qwen")||e?.includes("medium")||e.includes("muse"))||i==="Mistral")&&(P=126e3),i==="Google"&&e?.includes("gemma")&&M&&(P=16e3),(m?.tokens||0)>P){yield{type:"text",content:"\u2726 Maximum Context Limit Reached. Start a new chat."};return}if(_&&A){let K=Mt(Mo,{});Object.values(K).flat().length>5&&(yield{type:"status",content:"Condensing past chat memories"},await ol(p,n,K))}let le=Mt(Mo,{}),fe=Mt(ks,{}),Z=Object.entries(le).filter(([K])=>K!==p).flatMap(([K,Ke])=>Ke),ce=[...Object.entries(fe).filter(([K])=>K!==p).slice(-20).map(([K,Ke])=>`[Chat Summary]: ${Ke}`),...Z].map(K=>`- ${K}`).join(`
|
|
647
|
+
`),L=Mt(Wn,[]).map(K=>`- ${K.memory}`).join(`
|
|
648
|
+
`),N=(m?.tokens||0)>=1e4,Ee=new Date,ie=Ee.getFullYear(),B=Ee.toLocaleString("en-US",{month:"short"}).toUpperCase(),G=String(Ee.getDate()).padStart(2,"0"),ye=Ee.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}),Re=`${ie}-${B}-${G}, ${ye}`,Me=`${ye}`,Ie=K=>{try{return Ue.readdirSync(K,{withFileTypes:!0})}catch{return[]}},On=Array.from(new Set([...io,...ro(process.cwd())])),nn=(K,Ke=4)=>T?.indentationTree!==!1?Js(K,Ke,1,Ie,On):Zs(K,Ke,"",1,Ie,On),pt=Mt(Ts,{}),Tt=pt[p],Je=Tt?Tt!==process.cwd():!1;pt[p]=process.cwd(),Xn(Ts,pt);let xe=Mt(C,{}),te=xe[p]||{summary:"",historyLength:0};typeof te=="string"&&(te={summary:te,historyLength:0});let Wt=t.filter(K=>(K.role==="user"||K.role==="agent"||K.role==="system")&&!String(K.id).startsWith("welcome")&&!K.isMeta).length;te.historyLength&&Wt<te.historyLength&&(te.summary="",te.historyLength=0,xe[p]=te,Xn(C,xe));let Dn=typeof te=="object"?te.summary||"":te||"",Ln=r.length>0;Ln&&Dn&&r[0]&&(r[0].role==="user"||r[0].role==="system")&&(r[0].text.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")||(r[0].text=`[SYSTEM METADATA]
|
|
650
649
|
**CONTEXT SUMMARY OF PREVIOUS TURNS (PRIORITY: DYNAMIC)**
|
|
651
|
-
${
|
|
650
|
+
${Dn}
|
|
652
651
|
|
|
653
|
-
[USER] ${r[0].text}`,yield{type:"summary_injected",content:{id:r[0].id,text:r[0].text}}));let cs=
|
|
652
|
+
[USER] ${r[0].text}`,yield{type:"summary_injected",content:{id:r[0].id,text:r[0].text}}));let cs=Dn&&!Ln?`
|
|
654
653
|
[SYSTEM METADATA]
|
|
655
654
|
**CONTEXT SUMMARY OF PREVIOUS TURNS**
|
|
656
|
-
${
|
|
657
|
-
`:"",ai=!!T?.dynamicDirAwareness,Jr=`${
|
|
655
|
+
${Dn}
|
|
656
|
+
`:"",ai=!!T?.dynamicDirAwareness,Jr=`${p}|${i}|${f}|${e}|${c}|${ai}`,Qr=!ai&&jn.key===Jr&&jn.value?"":`
|
|
658
657
|
**Directory**
|
|
659
658
|
CWD: `+process.cwd()+`${g?" [PLAYGROUND MODE]":""}
|
|
660
659
|
`+nn(process.cwd(),4),yt=await Hn(),dn="";if(zo()&&yt.file_focused!=="none"){dn=`
|
|
661
660
|
[Additional IDE Context]
|
|
662
|
-
`;let
|
|
661
|
+
`;let K=ae.relative(process.cwd(),yt.file_focused),Ke=(yt.opened_editors||[]).map(st=>{let Be=ae.relative(process.cwd(),st);return Be.startsWith("..")?`[External] ${ae.basename(st)}`:Be});if(dn+=`Focused File: ${K}
|
|
663
662
|
Cursor Line: ${yt.cursor_line}
|
|
664
|
-
`,yt.selected){let
|
|
665
|
-
`);
|
|
663
|
+
`,yt.selected){let st=yt.selected,Be=st.split(`
|
|
664
|
+
`);Be.length>256&&(st=Be.slice(0,240).join(`
|
|
666
665
|
`)+`
|
|
667
666
|
... [truncated] ...
|
|
668
|
-
`+
|
|
669
|
-
`)),
|
|
667
|
+
`+Be.slice(-16).join(`
|
|
668
|
+
`)),st.length>2048&&(st=st.slice(0,1920)+`
|
|
670
669
|
... [truncated] ...
|
|
671
|
-
`+
|
|
672
|
-
`}if(yt.manual_edits){let
|
|
673
|
-
`),
|
|
674
|
-
${
|
|
675
|
-
`)}`;for(;
|
|
676
|
-
${
|
|
677
|
-
`)}`;We.length>4*768?
|
|
678
|
-
`);for(;Ve.length>0&&sn.length>4*2048;){Ve[0].edits.length>0?Ve[0].edits.shift():Ve.shift();for(let
|
|
679
|
-
${
|
|
680
|
-
`)}`;We.length>4*768?
|
|
670
|
+
`+st.slice(-128)),dn+=`Current Selection: "${st}"
|
|
671
|
+
`}if(yt.manual_edits){let Be=yt.manual_edits.split(`
|
|
672
|
+
`),it=[],et=null;for(let V of Be)V.trim()&&(V.startsWith(" Line ")?et&&et.edits.push(V):(et={path:V.endsWith(":")?V.slice(0,-1):V,edits:[]},it.push(et)));for(let V of it)V.edits.length>80&&(V.edits=V.edits.slice(-80)),V.originalEditsCount=V.edits.length;let at=(V,We)=>We.reduce((ve,gt)=>{let It=yt.file_focused&&(gt.path===yt.file_focused||ae.resolve(process.cwd(),gt.path)===ae.resolve(yt.file_focused))?Math.ceil(V*1.2):V;return ve+Math.min(gt.edits.length,It)},0),ke=80;if(at(80,it)>300){let V=!1;for(let We=80;We>=10;We--)if(at(We,it)<=300){ke=We,V=!0;break}V||(ke=10)}let Ve=[...it];if(ke===10&&at(10,Ve)>500)for(;Ve.length>0&&at(10,Ve)>500;){let V=0,We=Ve[0].originalEditsCount;for(let ve=1;ve<Ve.length;ve++)Ve[ve].originalEditsCount<We&&(We=Ve[ve].originalEditsCount,V=ve);Ve.splice(V,1)}for(let V of Ve){let ve=yt.file_focused&&(V.path===yt.file_focused||ae.resolve(process.cwd(),V.path)===ae.resolve(yt.file_focused))?Math.ceil(ke*1.2):ke;V.edits.length>ve&&(V.edits=V.edits.slice(-ve))}for(let V of Ve){let We=`${V.path}:
|
|
673
|
+
${V.edits.join(`
|
|
674
|
+
`)}`;for(;V.edits.length>0&&We.length>4*768;)V.edits.shift(),We=`${V.path}:
|
|
675
|
+
${V.edits.join(`
|
|
676
|
+
`)}`;We.length>4*768?V.stringRepresentation="... "+We.slice(-(4*768-4)):V.stringRepresentation=We}let sn=Ve.map(V=>V.stringRepresentation).join(`
|
|
677
|
+
`);for(;Ve.length>0&&sn.length>4*2048;){Ve[0].edits.length>0?Ve[0].edits.shift():Ve.shift();for(let V of Ve){let We=`${V.path}:
|
|
678
|
+
${V.edits.join(`
|
|
679
|
+
`)}`;We.length>4*768?V.stringRepresentation="... "+We.slice(-(4*768-4)):V.stringRepresentation=We}sn=Ve.map(V=>V.stringRepresentation).join(`
|
|
681
680
|
`)}sn.length>4*2048&&(sn="... "+sn.slice(-(4*2048-4))),dn+=`Recent Manual Edits:
|
|
682
681
|
${sn}
|
|
683
682
|
`}Ke.length>0&&(dn+=`All Opened Editors: ${Ke.join(", ")}`),yt.diagnostics&&(dn+=`
|
|
@@ -686,10 +685,10 @@ ${yt.diagnostics}
|
|
|
686
685
|
`),(a.toLowerCase().includes("lint")||a.toLowerCase().includes("warning"))&&yt.warnings&&(dn+=`
|
|
687
686
|
**Lint Warnings**:
|
|
688
687
|
${yt.warnings}
|
|
689
|
-
`)}let li=a.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),ci=/(?:\\)?@\[([^\]]+)\]/g,ds,fs=[];for(ci.lastIndex=0;(ds=ci.exec(li))!==null;){let
|
|
688
|
+
`)}let li=a.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),ci=/(?:\\)?@\[([^\]]+)\]/g,ds,fs=[];for(ci.lastIndex=0;(ds=ci.exec(li))!==null;){let K=ds[0].startsWith("\\");fs.push({tag:ds[1],isEscaped:K})}let us=[],To=null;for(let K=0;K<fs.length;K++){let{tag:Ke,isEscaped:fn}=fs[K];if(!fn)try{let st=Ke.trim().replace(/^["']|["']$/g,""),Be=/[:#]L?(\d+)(?:-L?(\d+))?$/i,it=st.match(Be),et=st,at=null,ke=null;it&&(at=parseInt(it[1],10),ke=it[2]?parseInt(it[2],10):at,et=st.slice(0,it.index));let Ve=ae.resolve(process.cwd(),et);if(Ue.existsSync(Ve)&&Ue.statSync(Ve).isFile()){let V=et.toLowerCase(),We=V.endsWith(".pdf"),ve=V.endsWith(".docx")||V.endsWith(".doc")||V.endsWith(".ppt")||V.endsWith(".pptx")||V.endsWith(".xls")||V.endsWith(".xlsx"),gt=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(V),kn=gt||We||ve,It=i==="Google"||ut(e);if(kn&&!It){let Lt=`\u2718 Unsupported Modality: ${ae.basename(et)}`,Ye=115;process.stdout.isTTY&&(Ye=process.stdout.columns-5||120);let Te=[Lt],qe=Math.max(...Te.map(un=>un.length)),Sn=Math.min(qe+4,Ye),Pn=Te.map(un=>`${un.padEnd(Sn-2).substring(0,Sn-2)}`).join(`
|
|
690
689
|
`);yield{type:"visual_feedback",content:Yt(`${Pn}
|
|
691
|
-
`)};continue}if(
|
|
692
|
-
`)};continue}}let rn=
|
|
690
|
+
`)};continue}if(at===null&&!kn){let Lt=0;try{Lt=Ue.readFileSync(Ve,"utf8").split(/\r\n|\r|\n/).length}catch{}if(Lt>300){let Ye=`\u21B7 Skipped (Too Large): ${ae.basename(et)}`,Te=115;process.stdout.isTTY&&(Te=process.stdout.columns-5||120);let qe=Math.min(Ye.length+4,Te),Sn=Ye.padEnd(qe-2).substring(0,qe-2);yield{type:"visual_feedback",content:Yt(`${Sn}
|
|
691
|
+
`)};continue}}let rn=at!==null?at:1,Tn=ke!==null?ke:at!==null?at:rn+299;Tn-rn>300&&(Tn=rn+300);let Zn=`path=${JSON.stringify(et)}, startLine=${rn}, endLine=${Tn}`,Qt=await Ri(Zn,{isMultiModal:It}),xt=!1,Qe="",Dt=null;if(typeof Qt=="string"?Qt.trim().startsWith("ERROR")?xt=!0:Qe=Qt:Qt&&typeof Qt=="object"&&Qt.binaryPart?(Dt=Qt.binaryPart,Qe=Qt.text||""):xt=!0,!xt){let Lt="";if(gt?(Lt=`\u2714 Processed: ${ae.basename(et)}`,To=Dt):We||ve?(Lt=`\u2714 Auto-Analysed: ${ae.basename(et)}`,To=Dt):(Lt=`\u2714 Auto-Read: ${ae.basename(et)}`,us.push(Qe)),Lt){let Ye=115;process.stdout.isTTY&&(Ye=process.stdout.columns-5||120);let Te=[Lt],qe=Math.max(...Te.map(un=>un.length)),Sn=Math.min(qe+4,Ye),Pn=Te.map(un=>`${un.padEnd(Sn-2).substring(0,Sn-2)}`).join(`
|
|
693
692
|
`);yield{type:"visual_feedback",content:Yt(`${Pn}
|
|
694
693
|
`)}}}}}catch{}}let gs="";us.length>0&&(gs=`
|
|
695
694
|
[Tagged File Contents] Auto Read User Tagged files by System, No need to re-read
|
|
@@ -697,148 +696,148 @@ ${yt.warnings}
|
|
|
697
696
|
|
|
698
697
|
`)+`
|
|
699
698
|
[Tagged File Contents]
|
|
700
|
-
`);let di=li.replace(/\\(@\[[^\]]+\])/g,"$1"),fi=
|
|
699
|
+
`);let di=li.replace(/\\(@\[[^\]]+\])/g,"$1"),fi=b?`You cannot execute tools. Instead write the action string in chat you WOULD have written
|
|
701
700
|
`:"",Zr=process.env.forcedReasoning||!1,ui=f!=="Fast"&&(i==="Mistral"&&!Io(e)||f!=="High"&&i==="Google")?`${i==="Mistral"&&!Io(e)||e.toLowerCase().startsWith("gemma")||Zr?`[system] strictly follow thinking policy as high priority. do not start a response without <think>...</think> [/system]
|
|
702
701
|
`:""}`:"",So="",gi=!!T?.autoExcludeMetadata,ea=!!(dn||gs||fi||cs||ui||Je||T?.dynamicDirAwareness||T?.autoTruncateResults);gi&&!ea?So=di.trim():So=`[System Metadata]
|
|
703
|
-
Time: ${gi?
|
|
704
|
-
WARNING: CWD Changed from previous: "${
|
|
702
|
+
Time: ${gi?Me:Re}${Je?`
|
|
703
|
+
WARNING: CWD Changed from previous: "${Tt}" to current: "${process.cwd()}", write change in chat to avoid future path mismatches
|
|
705
704
|
`:""}${dn}
|
|
706
705
|
Action format: [action:ActionName(...)]
|
|
707
706
|
[/Metadata]
|
|
708
|
-
${cs}${ui}${gs}${fi}[user prompt] ${di.trim()} [/user prompt]`.trim();let hi={role:"user",text:So};To&&(hi.binaryPart=To),r.forEach(
|
|
707
|
+
${cs}${ui}${gs}${fi}[user prompt] ${di.trim()} [/user prompt]`.trim();let hi={role:"user",text:So};To&&(hi.binaryPart=To),r.forEach(K=>{K.text&&K.role==="agent"&&(K.text=qt(K.text))}),r.push(hi),cs&&t[t.length-1]?.id&&(yield{type:"summary_injected",content:{id:t[t.length-1].id,text:So}});let Jt=null,wn=l==="Flux"?50:15;wn=l.toLowerCase().includes("cu")?75:wn;let ta=Math.floor(wn/2),mi=0,on=16;yield{type:"status",content:"Connecting"},kt=!1;let hs=[],_o=!1,pi=!1;for(let K=0;K<=wn;K++){let Ke=Math.floor(wn*.95);if(K>=Ke&&mi<Ke&&typeof n?.onAskUser=="function"){mi=Ke;try{let me="Agent has been running for a long time. Do you want to continue execution?",Ae=[{id:"continue",label:"Continue",description:"Add few more steps"},{id:"cancel",label:"Cancel",description:"Stop extending and finish current turn limit"}],ee=await n.onAskUser(me,Ae);ee&&(ee.toLowerCase().includes("continue")||ee==="Continue")&&(wn+=ta)}catch{}}let fn=await _s("agent",n);if(!fn.allowed)throw new Error(fn.reason||`Budget Exhausted for Provider (${i||"Agent"})`);let st=[];if(_o=!1,l==="ICU"||l==="FluxCU")try{yield{type:"status",content:"Capturing Screen"},await new Promise(ee=>setTimeout(ee,1e3));let{captureGriddedScreenshot:me}=await import("./screen_grid-RAKJUJQA.js"),Ae=await me();if(Ae&&Ae.base64){let ee="[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]",Pt={inlineData:{mimeType:Ae.mimeType,data:Ae.base64}},Et=T?.imageHistoryCU||"Standard",Ct=Et==="Low"?3:Et==="Extended"?10:Et==="Max"?999:5,zt=r.filter(Ge=>Array.isArray(Ge.parts)&&Ge.parts.some($t=>$t.inlineData));if(zt.length>=Ct){let Ge=zt.length-Ct+1;for(let $t=0;$t<Ge;$t++){let Rt=zt[$t];Array.isArray(Rt.parts)&&(Rt.parts=Rt.parts.filter(St=>!St.inlineData))}}if(r.length>0&&r[r.length-1].role==="user"){let Ge=r[r.length-1];typeof Ge.text=="string"&&(Ge.text+=`
|
|
709
708
|
|
|
710
|
-
${ee}`,Array.isArray(Ge.parts)||(Ge.parts=[{text:Ge.text}]),Ge.parts.push(
|
|
709
|
+
${ee}`,Array.isArray(Ge.parts)||(Ge.parts=[{text:Ge.text}]),Ge.parts.push(Pt))}else r.push({role:"user",text:ee,parts:[{text:ee},Pt]})}}catch(me){console.error("Vision screenshot capture error:",me)}if(T?.compression===0&&(m?.tokens||0)>P&&(r=Ci(r,6)),K>0?yield{type:"status",content:"Working"}:yield{type:"status",content:"Connecting"},kt){try{let{clearPendingNudges:me}=await import("./subagent_state-LZCOZSUJ.js");me()}catch{}yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
|
|
711
710
|
|
|
712
|
-
\x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}try{let{consumePendingNudges:
|
|
711
|
+
\x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}try{let{consumePendingNudges:me}=await import("./subagent_state-LZCOZSUJ.js"),Ae=me();if(Ae&&Ae.length>0){let ee=Ae.join(`
|
|
713
712
|
|
|
714
713
|
`);r.length>0&&r[r.length-1].role==="user"?r[r.length-1].text+=`
|
|
715
714
|
|
|
716
|
-
${ee}`:r.push({role:"user",text:ee}),yield{type:"status",content:"Subagent Update"}}}catch{}if(s){let
|
|
715
|
+
${ee}`:r.push({role:"user",text:ee}),yield{type:"status",content:"Subagent Update"}}}catch{}if(s){let me=await s();me&&(me.startsWith("/btw")?r.length>0&&r[r.length-1].role==="user"?r[r.length-1].text+=`
|
|
717
716
|
|
|
718
717
|
[system] User question. Resolve this specific query within '[ANSWER]...[/ANSWER]' concisely, naturally [/system]
|
|
719
|
-
[question] ${
|
|
720
|
-
[question] ${
|
|
718
|
+
[question] ${me.replace("/btw","").trim()} [/question]`:r.push({role:"user",text:`[system] User question. Resolve this specific query within '[ANSWER]...[/ANSWER]' concisely, naturally [/system]
|
|
719
|
+
[question] ${me.replace("/btw","").trim()} [/question]`}):r.length>0&&r[r.length-1].role==="user"?r[r.length-1].text+=`
|
|
721
720
|
|
|
722
|
-
[STEERING HINT from USER, High Priority] ${
|
|
721
|
+
[STEERING HINT from USER, High Priority] ${me.trim()} [/STEERING HINT]`:r.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${me.trim()} [/STEERING HINT]`}),yield{type:"status",content:`${me.startsWith("/btw")?"Question Forwarded...":"Steering Hint Injected..."}`})}let Be,it=!1,et=1,at=1,ke="",Ve=null,sn=null,V=null,We=0,ve=[],gt=0,kn=!1,It=!1,rn=!1,Tn=!1,Zn=!0,Qt=0,xt="",Qe="",Dt=!1,Lt=!1,Ye=!0,Te=e,qe="";for(;et<=on&&at<=on&&!it&&!kt;){let me=!1;try{ke="",Zn&&(process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07"),yield{type:"turn_reset",content:!0},Zn=!1,at===1&&(xt=""));let Ae=v=>{if(!v||typeof v!="string")return v;let Y="",W=oi(v);if(W&&(Y=W.fullBlock,v=W.remainingText),!v.includes("[tool:")&&!v.includes("[action:"))return(T?.keepReasoningContext?Y:"")+v;v=v.replace(qa,(X,ne)=>ne.includes("[tool:")||ne.includes("[action:")?ne.trim():X);let z="",Q=0;for(;Q<v.length;){let X=v.indexOf("[tool:",Q),ne=v.indexOf("[action:",Q),tt=-1;if(X!==-1&&ne!==-1?tt=Math.min(X,ne):X!==-1?tt=X:tt=ne,tt===-1){z+=Gr(v.substring(Q));break}let F=v.substring(Q,tt);z+=Gr(F);let j=-1,Se=null,w=0;for(let Le=tt;Le<v.length;Le++){let se=v[Le];if(Se){if(se===Se){let q=0;for(let bt=Le-1;bt>=0&&v[bt]==="\\";bt--)q++;q%2===0&&(Se=null)}}else if(se==='"'||se==="'"||se==="`")Se=se;else if(se==="(")w++;else if(se===")")w--;else if(se==="]"&&w<=0){j=Le;break}}if(j===-1){z+=v.substring(tt);break}z+=v.substring(tt,j+1),Q=j+1}return(T?.keepReasoningContext?Y:"")+z},ee=r.filter(v=>(v.role==="user"||v.role==="agent"||v.role==="system")&&!String(v.id).startsWith("welcome")&&!v.isMeta&&!v.isTerminalRecord&&!(v.text&&v.text.startsWith("[TERMINAL_RECORD]"))).map((v,Y,W)=>{let z=v.text||"";A||(z=z.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),v.role==="agent"&&(z=Ae(z),z=z.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),z=z.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*"));let Q=[];return Array.isArray(v.parts)&&v.parts.length>0?Q=v.parts.map(X=>{if(X.text){let ne=X.text;return A||(ne=ne.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),v.role==="agent"&&(ne=Ae(ne),ne=ne.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),ne=ne.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*")),{text:ne}}return X}):Q=[{text:z}],v.binaryPart&&ut(Te)&&W.slice(Y+1).filter(ne=>ne.role==="user"&&!ne.text?.startsWith("[ACTION RESULT]")&&!ne.text?.startsWith("[TOOL RESULT]")).length<=2&&Q.push(v.binaryPart),{role:v.role==="user"||v.role==="system"?"user":"model",parts:Q}});for(let v=0;v<ee.length;v++){let Y=ee[v],W=Y.parts?.[0]?.text||"";if(Y.role==="model"&&/\[(?:tool|action):/i.test(W)){let z=-1;for(let Q=v+1;Q<ee.length;Q++){let X=ee[Q],ne=X.parts?.[0]?.text||"";if(X.role==="user"&&(ne.startsWith("[ACTION RESULT]")||ne.startsWith("[TOOL RESULT]"))){z=Q;break}}if(z!==-1&&z!==v+1){let[Q]=ee.splice(z,1);ee.splice(v+1,0,Q)}}}for(let v=ee.length-2;v>=0;v--){let Y=ee[v],W=ee[v+1];Y.role==="user"&&W.role==="user"&&(W.parts?.[0]?.text||"").trim().startsWith("[SYSTEM")&&ee.splice(v,1)}let Pt=[];for(let v=0;v<ee.length;v++){let Y=ee[v];if(Pt.length===0)Pt.push(Y);else{let W=Pt[Pt.length-1];W.role===Y.role?(W.parts[0].text+=`
|
|
723
722
|
|
|
724
|
-
`+(Y.parts?.[0]?.text||""),Y.parts?.length>1&&W.parts.push(...Y.parts.slice(1))):
|
|
723
|
+
`+(Y.parts?.[0]?.text||""),Y.parts?.length>1&&W.parts.push(...Y.parts.slice(1))):Pt.push(Y)}}ee.length=0,ee.push(...Pt),Te=e;let Et=`${p}|${i}|${l}|${f}|${Te}|${JSON.stringify(c)}|${!!T?.dynamicDirAwareness}|${!!T?.subAgents}`,Ct=jn.key===Et&&jn.value;if((process.env.I_HAVE_TOO_MUCH_MONEY==="true"||process.env.I_HAVE_TOO_MUCH_MONEY===!0)&&(Ct=!1),Ct)qe=jn.value;else{let v=i==="Mistral"?!!Io(Te):!(Te||"gemma").toLowerCase().startsWith("gemma");qe=fr(c,((Te||"gemma").toLowerCase().startsWith("gemma"),f),l,T,A,_,i,i==="Google"?!0:h,v,p,!!T?.keepReasoningContext,Te),T?.dynamicDirAwareness||(qe+=`
|
|
725
724
|
${Qr.replace(`
|
|
726
725
|
**Directory**`,`
|
|
727
|
-
-- Directory --`)}`),jn.key=
|
|
728
|
-
${Y} [/ERROR]`),yield{type:"status",content:"Working"}}let
|
|
726
|
+
-- Directory --`)}`),jn.key=Et,jn.value=qe}let Ge=ee[ee.length-1];if(zo()&K>0){await new Promise(W=>setTimeout(W,2500)),yield{type:"status",content:"Verifying"};let v=await Hn(),Y=v?v.diagnostics:null;Y&&Ge&&Ge.role==="user"&&Ge.parts?.[0]?.text&&(Ge.parts[0].text+=`
|
|
727
|
+
${Y} [/ERROR]`),yield{type:"status",content:"Working"}}let $t=i==="Mistral"||i==="Google"&&e?.toLowerCase().startsWith("gemma");if(T?.advanceRollback&&Ge&&Ge.role==="user"&&(Ge.parts?.[0]?.text?.startsWith("[ACTION RESULT]")||Ge.parts?.[0]?.text?.startsWith("[TOOL RESULT]")))try{let v=await lo.getLatestFileChanges(p);if(v&&(v.newFiles.length>0||v.modifiedFiles.length>0||v.deletedFiles.length>0)){let Y=`
|
|
729
728
|
[system] File Changes:
|
|
730
|
-
`;for(let
|
|
731
|
-
`;for(let
|
|
732
|
-
`;for(let
|
|
733
|
-
`;Y+="[/system]",Ge.parts[0].text+=Y;let W=-1;for(let
|
|
734
|
-
[system] WARNING, Turn Limit Impending: Step ${
|
|
735
|
-
|
|
736
|
-
\x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(W){if(Dt){if(Qe+=W,Qe.length>=64){let
|
|
737
|
-
`).length;je=
|
|
729
|
+
`;for(let z of v.newFiles)Y+=`* ${z} (created)
|
|
730
|
+
`;for(let z of v.modifiedFiles)Y+=`* ${z} (modified)
|
|
731
|
+
`;for(let z of v.deletedFiles)Y+=`* ${z} (deleted)
|
|
732
|
+
`;Y+="[/system]",Ge.parts[0].text+=Y;let W=-1;for(let z=r.length-1;z>=0;z--)if(r[z].role==="user"&&(r[z].text?.startsWith("[ACTION RESULT]")||r[z].text?.startsWith("[TOOL RESULT]"))){W=z;break}W!==-1&&(r[W].text+=Y)}}catch{}let Rt=Math.floor(wn*.99),St=K+1;St>=Rt&&Ge&&Ge.parts?.[0]&&(Ge.parts[0].text+=`
|
|
733
|
+
[system] WARNING, Turn Limit Impending: Step ${St}/${wn}. Wrap up quickly/prompt user to continue. [/system]`);let Ot=new Promise((v,Y)=>{d.signal.aborted&&Y(new DOMException("The user aborted a request.","AbortError")),d.signal.addEventListener("abort",()=>{Y(new DOMException("The user aborted a request.","AbortError"))})});Ot.catch(()=>{});let ht=ee;if(i==="Ollama")Be=ei(n.apiKey,Te,ht,qe,f,l,h,d.signal,1,T?.ollamaEndpoint||"Cloud");else if(i==="OpenRouter")Be=es(n.apiKey,Te,ht,qe,f,l,h,d.signal,1,p);else if(i==="DeepSeek")Be=Jo(n.apiKey,Te,ht,qe,f,l,h,d.signal,1);else if(i==="Mistral")Be=Qo(n.apiKey,Te,ht,qe,f,l,h,d.signal,1,p);else if(i==="NVIDIA"){let v=Zo(n.apiKey,Te,ht,qe,f,l,h,d.signal,1);Be=Fr(v,Te)}else if(i==="InferX")Be=ts(n.apiKey,Te,ht,qe,f,l,h,d.signal,1);else if(i==="SenseNova")Be=ns(n.apiKey,Te,ht,qe,f,l,h,d.signal,1);else if(i==="AIHubMix")Be=os(n.apiKey,Te,ht,qe,f,l,h,d.signal,1);else if(i==="Poolside")Be=ss(n.apiKey,Te,ht,qe,f,l,h,d.signal,1);else if(i==="9router"||i==="9Router")Be=is(n.apiKey,Te,ht,qe,f,l,h,d.signal,1);else if(i==="ExpLabs"||i==="ExperientialLabs")Be=rs(n.apiKey,Te,ht,qe,f,l,h,d.signal,1);else if(i==="TokenHarbor"||i==="Token Harbor"||i==="tokenharbor"||i==="token_harbor"||i==="thk")Be=ti(n.apiKey,Te,ht,qe,f,l,h,d.signal,1);else if(i==="APInex"||i==="apinex"||i==="apx")Be=ni(n.apiKey,Te,ht,qe,f,l,h,d.signal,1);else{let v=ri(n?.apiKey),{serviceTier:Y,cleanModel:W}=Xr(Te),z={systemInstruction:qe,mediaResolution:"MEDIA_RESOLUTION_HIGH",safetySettings:[{category:In.HARM_CATEGORY_HARASSMENT,threshold:vn.BLOCK_NONE},{category:In.HARM_CATEGORY_HATE_SPEECH,threshold:vn.BLOCK_NONE},{category:In.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:vn.BLOCK_NONE},{category:In.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:vn.BLOCK_NONE}],temperature:1.05,thinkingConfig:(()=>{let X=He("Google",Te||"gemini-3-flash-preview",f);if(X!==null){if(typeof X=="object")return X;if(X===!1||X==="false"||X==="none"||X===0||X==="0")return{includeThoughts:!1};if(typeof X=="number")return{includeThoughts:!0,thinkingBudget:X};if(typeof X=="string"){let j=X.toLowerCase();if(j==="minimal")return{includeThoughts:!0,thinkingLevel:Xe.MINIMAL};if(j==="low")return{includeThoughts:!0,thinkingLevel:Xe.LOW};if(j==="medium")return{includeThoughts:!0,thinkingLevel:Xe.MEDIUM};if(j==="high")return{includeThoughts:!0,thinkingLevel:Xe.HIGH};let Se=Number(X);if(!isNaN(Se))return{includeThoughts:!0,thinkingBudget:Se}}}let ne=(Te||"").toLowerCase(),tt=ne.includes("gemma-4")||ne.startsWith("gemma"),F=ne.includes("gemini-3");if(tt||F)return tt?f.toLowerCase()!=="high"?{includeThoughts:!1,thinkingLevel:Xe.MINIMAL}:{includeThoughts:!0,thinkingLevel:Xe.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:ne.includes("pro")?Xe.LOW:Xe.MINIMAL,Low:Xe.LOW,Medium:Xe.MEDIUM,Standard:Xe.MEDIUM,High:Xe.HIGH,xHigh:Xe.HIGH}[f]||Xe.MEDIUM};{let j={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[f]||2048;return j===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:j}}})()};Y&&(z.serviceTier=Y);let Q=v.models.generateContentStream({model:W||"gemini-3-flash-preview",contents:ht,config:z},{signal:d.signal});Be=await Promise.race([Q,Ot])}ke="",Ve=null,V=null,ve=[],gt=0,yield{type:"model_update",content:null},Qe="",Dt=xt.length>0;let an="",ms=Date.now(),Nn=async function*(){if(i==="Google"&&an){let v=to(an);for(let Y of v)yield Y;an="",ms=Date.now()}},yi=!0,Fn="",Vn=!1,_t=null,xi=!1,Yn=!1,qn=!1,Ao=!1,_n=!1,eo=v=>{let Y=0;for(;Y+2<v.length;)v[Y]==="`"&&v[Y+1]==="`"&&v[Y+2]==="`"?(Ao=!Ao,Y+=3):Y++},bi=v=>{if(!v)return;let Y=/(?:<(\/?)(?:think|thought|thoughts)[^>]*>|\[(\/?)(?:think|thought|thoughts)\]|<\/?channel\|?>|<\|channel>thought)/gi,W;for(;(W=Y.exec(v))!==null;){let z=W[0].toLowerCase();z.startsWith("</")||z.startsWith("[/")||z==="<channel|>"?_n=!1:_n=!0}},sa={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|>"}},to=v=>{let Y=[],W=v,z=Q=>{if(!Q)return;if(!xi){Y.push({type:"text",content:Q}),eo(Q),bi(Q);return}let X=/(?:<(\/?)(?:think|thought|thoughts)[^>]*>|\[(\/?)(?:think|thought|thoughts)\]|<\/?channel\|?>|<\|channel>thought)/gi,ne=0,tt;for(;(tt=X.exec(Q))!==null;){let j=Q.substring(ne,tt.index);if(j)if(eo(j),_n)Y.push({type:"text",content:j});else{let Le=j.replace(/[^\n]/g,"");Le&&Y.push({type:"text",content:Le})}let Se=tt[0];eo(Se);let w=Se.toLowerCase();w.startsWith("</")||w.startsWith("[/")||w==="<channel|>"?_n=!1:_n=!0,Y.push({type:"text",content:Se}),ne=X.lastIndex}let F=Q.substring(ne);if(F)if(eo(F),_n)Y.push({type:"text",content:F});else{let j=F.replace(/[^\n]/g,"");j&&Y.push({type:"text",content:j})}};for(;W.length>0;)if(Vn){let Q=Fn+W,X=sa[_t];if(X){let F=!1;if(Q.length<X.startPrefix.length?X.startPrefix.startsWith(Q)||(F=!0):Q.startsWith(X.startPrefix)?Q.length>=X.fullPrefix.length&&!Q.startsWith(X.fullPrefix)&&(F=!0):F=!0,F){z(Q),Fn="",Vn=!1,_t=null,Yn=!1,qn=!1,W="";break}}let ne=-1,tt=X?X.endTag:"]";if(_t==="tool"||_t==="action"){let F=0,j=null,Se=0,w=!1;for(let Le=0;Le<Q.length;Le++){let se=Q[Le];if(j){if(se===j){let q=0;for(let bt=Le-1;bt>=0&&Q[bt]==="\\";bt--)q++;q%2===0&&(j=null)}}else if(se==='"'||se==="'"||se==="`")j=se;else if(se==="(")F++,w=!0;else if(se===")")F--;else if(se==="[")Se++;else if(se==="]"){if(w&&F===0&&Se===1){ne=Le;break}Se--}}}else ne=Q.indexOf(tt);if(ne!==-1){let F=tt.length,j=Q.substring(0,ne+F);_t?.startsWith("kimi")||Y.push({type:"text",content:j}),eo(j),bi(j),(_t==="tool"||_t==="action"||_t?.startsWith("kimi"))&&!Yn&&!qn&&(xi=!0),Yn=!1,qn=!1,Fn="",Vn=!1,_t=null,W=Q.substring(ne+F)}else{let F=_t?.startsWith("kimi")?8192:512;Q.length>F?(z(Q),Fn="",Vn=!1,_t=null,Yn=!1,qn=!1):Fn=Q,W="";break}}else{let Q=W.indexOf("[tool"),X=W.indexOf("[action"),ne=W.indexOf("[[END]]"),tt=W.indexOf("<|tool_calls_section_begin|>"),F=W.indexOf("<|tool_call_begin|>"),j=[{type:"tool",idx:Q,start:"[tool",end:"]"},{type:"action",idx:X,start:"[action",end:"]"},{type:"end",idx:ne,start:"[[END]]",end:"[[END]]"},{type:"kimi_section",idx:tt,start:"<|tool_calls_section_begin|>",end:"<|tool_calls_section_end|>"},{type:"kimi_call",idx:F,start:"<|tool_call_begin|>",end:"<|tool_call_end|>"}].filter(Se=>Se.idx!==-1).sort((Se,w)=>Se.idx-w.idx);if(j.length>0){let Se=j[0],w=W.substring(0,Se.idx);Se.idx>0&&z(w);let Le=Se.idx>0?W[Se.idx-1]:"";Yn=Ao||Le==="`",qn=_n,Vn=!0,_t=Se.type,Fn="",W=W.substring(Se.idx)}else{let Se=["[tool","[action","[[END]]","<|tool_calls_section_begin|>","<|tool_call_begin|>"],w=-1;for(let Le of Se){for(let se=Le.length-1;se>0;se--)if(W.endsWith(Le.substring(0,se))){w=W.length-se;let q=Se.indexOf(Le);q===0?_t="tool":q===1?_t="action":q===2?_t="end":q===3?_t="kimi_section":_t="kimi_call";break}if(w!==-1)break}if(w!==-1){if(w>0){let se=W.substring(0,w);z(se)}let Le=w>0?W[w-1]:"";Yn=Ao||Le==="`",qn=_n,Vn=!0,Fn=W.substring(w),W=""}else{z(W);break}}}return Y},ia=Be[Symbol.asyncIterator]();for(;;){let{value:v,done:Y}=await Promise.race([ia.next(),Ot]);if(Y)break;if(v&&v.type==="status"){yield v;continue}let W="",z=v.candidates?.[0]?.content?.parts;if(z&&z.length>0)for(let X of z){let ne=typeof X.text=="string"?X.text:X.text?parseChunkText(X.text):"";X.thought?ne&&(me||(W+="<think>",me=!0),W+=ne):ne&&(me&&(W+="</think>",me=!1),W+=ne)}else v.text&&me&&(W+="</think>",me=!1);W=ja(W);let Q=W?As(W):0;if(n&&typeof n.onTokenChunk=="function"&&n.onTokenChunk(W,Q),yi&&(yield{type:"status",content:"Thinking"},yi=!1),kt){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
|
|
734
|
+
|
|
735
|
+
\x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(W){if(Dt){if(Qe+=W,Qe.length>=64){let F=0,j=Math.min(xt.length,Qe.length);for(let w=j;w>=10;w--)if(xt.endsWith(Qe.substring(0,w))){F=w;break}let Se=Qe.substring(F);if(Se){let Le=/(?:<(think|thought)>|\[(think|thought)\])(?:(?!(?:<\/(?:think|thought)>|\[\/(?:think|thought)\]))[\s\S])*$/i.test(xt)?Se.replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])\s*/gi,""):Se.replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])[\s\S]*?(?:<\/(think|thought)>|\[\/(think|thought)\])\s*/gi,"").replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])\s*/gi,"");if(Le)if(ke+=Le,i==="Google")an+=Le;else{yield*Nn();let se=to(Le);for(let q of se)yield q}}Dt=!1,Qe=""}continue}else if(ke+=W,i==="Google")an+=W;else{yield*Nn();let F=to(W);for(let j of F)yield j}let X=Qa(ke);if(X.inside){Lt=!0,V||(V=Date.now());let j={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",Answer:"answer",Steer:"steer",steer:"steer"}[X.toolName]||X.toolName,Se=X.args||"",w=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","answer"].includes(j)){let se=oe(Se),q=se.basename||se.name||se.path||se.targetFile||se.TargetFile||se.directory||se.file,bt=se.keyword,Bn=se.title||se.task,An=se.id||se.taskId,Pe=se.timeout||se.time;if(bt!=null)w=String(bt).replace(Gn,"");else if(q)w=ae.basename(String(q).replace(Gn,"").replace(Br,"/"));else if(Bn&&(j==="invoke"||j==="invoke_sync"))w=String(Bn).replace(Gn,"").substring(0,30);else if(An&&j==="get_progress")w=String(An).replace(Gn,"");else if(Pe&&j==="await"){let Nt=parseFloat(String(Pe).replace(Gn,""));isNaN(Nt)?w=String(Pe).replace(Gn,""):(Nt<5&&(Nt=5),Nt>120&&(Nt=120),w=(gn=>{if(gn>=60){let ys=Math.floor(gn/60),zn=gn%60;return`${ys}m${zn>0?` ${zn}s`:""}`}return`${gn}s`})(Nt))}else{let Nt=Se.match(Wa);if(Nt){let Ht=Nt[1].replace(Gn,"");j==="invoke"||j==="invoke_sync"||j==="get_progress"?w=Ht.substring(0,30):w=j==="search_keyword"||j==="file_map"?Ht:ae.basename(Ht.replace(Br,"/"))}}}let Le=`${si[j]||j}${w?` ${w}`:""}`;if((j!==Ve||w!==sn)&&(Ve=j,sn=w,yield{type:"status",content:`${Le}`},process.stdout.isTTY)){let q={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",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"}[j]||"Working";process.stdout.write(`\x1B]0;${q}...\x07`)}}if(ke.length-Qt>150){Qt=ke.length;let F=zr(ke,!1),j=oi(F),Se=j?(j.innerContent||"").trim():"",w=Se.split(/[.!?]\s+/),Le=new Set(w),se=w.length>10?(w.length-Le.size)/w.length:0,q=Se.split(/\s+/).filter($e=>$e.length>0).length,bt=.6,Bn=.8,An=!1;if(i.toLowerCase().includes("google")&&(Te||"").toLowerCase().startsWith("gemma")){let S={low:256,medium:1024,high:8192,max:16384,xhigh:16384}[f?.toLowerCase()]||2500;An=q>S}if(se>bt||An){yield{type:"status",content:`${se>bt?"Reasoning Loop Detected":"Thinking Budget Exceeded"}. Re-centering...`},It=!0,await new Promise(S=>setTimeout(S,3e3));break}let Ht=jr(ke).trim().split(/[.!?]\s+/),gn=new Set(Ht);if((Ht.length>10?(Ht.length-gn.size)/Ht.length:0)>Bn){yield{type:"status",content:"Response Loop Detected. Re-centering..."},It=!1,Tn=!0,await new Promise($e=>setTimeout($e,3e3));break}let zn=F.replace(La,"").replace(Pa,"").replace($a,"").replace(Na,""),Ft=zn.toLowerCase().split(/\s+/).map($e=>$e.replace(Fa,"")).filter($e=>$e.length>0),hn=!1;if(Ft.length>=10)for(let $e=1;$e<=15;$e++){let S=Math.max(3,Math.ceil(10/$e));if(Ft.length<$e*S)continue;let H=Ft.slice(Ft.length-$e),re=H.join(" ");if($e>1&&re===H.slice(0,Math.floor($e/2)).join(" ").repeat(2).trim())continue;let ge=!0;for(let be=1;be<S;be++)if(Ft.slice(Ft.length-$e*(be+1),Ft.length-$e*be).join(" ")!==re){ge=!1;break}if(ge){hn=!0;break}}if(!hn){let $e=zn.toLowerCase().replace(Ba,"");if($e.length>=20)for(let S=1;S<=10;S++){let H=Math.max(5,Math.ceil(16/S));if($e.length<S*H)continue;let re=$e.substring($e.length-S),ge=!0;for(let be=1;be<H;be++)if($e.substring($e.length-S*(be+1),$e.length-S*be)!==re){ge=!1;break}if(ge){hn=!0;break}}}if(hn){yield{type:"status",content:"Stuttering Detected. Re-centering..."},It=!1,rn=!0,await new Promise($e=>setTimeout($e,3e3));break}}let ne=qt(ke),tt=ko(ne);for(;tt.length>gt;){yield*Nn();let F=tt[gt],j=Date.now(),w={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",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"}[F.toolName]||F.toolName,Le=si[w]||F.toolName,se=Kn(w,F.args);yield{type:"status",content:`${Le}${se?` ${se}`:""}`};let q="";if(w==="click"){let S=oe(F.args);q=`\u2714 Clicked: ${S.intendedClickText?`${S.intendedClickText}`:""}`}else if(w==="drag"){let S=oe(F.args);q=`\u2714 Dragged: Cell ${S.fromGridId||""} \u2192 Cell ${S.toGridId||""}`}else if(w==="scroll"){let S=oe(F.args);q=`\u2714 Scrolled: ${S.direction||"down"} (${S.amount||1})`}else if(w==="keyboard_typing"){let S=oe(F.args);q=`\u2714 Typed: ${S.text?`"${S.text.length>20?S.text.substring(0,20)+"...":S.text}"`:""}`}else if(w==="key_press")q=`\u2714 Pressed Key: ${oe(F.args).key||""}`;else if(w==="recapture_screen")q="\u2714 Recaptured Screen";else if(w==="web_search"){let{query:S,limit:H=10,aiMode:re=!1}=oe(F.args);q=`${S?"\u2714":"\u2718"} ${re?"AI Search":"Searched"}: ${S?`${S}`:"No Search Query"}${re===!1&&S?` \u2192 ${H}`:""}`}else if(w==="web_scrape"){let S=oe(F.args).url||null;q=`${S?"\u2714":"\u2718"} Visited: ${S||"No Source"}`}else if(w==="view_file"){let{path:S,StartLine:H,EndLine:re,start_line:ge,end_line:be,startLine:Fe,endLine:Oe}=oe(F.args),Ce=H||ge||Fe,J=re||be||Oe,de=parseInt(Ce)||1,ue=parseInt(J)||(Ce?de+800:800),je="...",ze=ue,he=(S||"").trim().toLowerCase().replaceAll("\\","/");if(he.startsWith("#skill"))he.startsWith("#skill/global/fluxflow")||he.startsWith("#skills/global/fluxflow")||he.includes("#skill/fluxflow")||he.includes("#skills/fluxflow")?q="\u2714 Read Documentation":q=`\u2714 Read Skill: ${ae.basename(S.replaceAll("\\","/"))}`;else{try{let _e=ae.resolve(process.cwd(),S);if(Ue.existsSync(_e)){let wt=Ue.readFileSync(_e,"utf8").split(`
|
|
736
|
+
`).length;je=wt,!Ce&&!J&&wt>800?ze=Math.min(50,wt):ze=Math.min(ue,wt)}}catch{}let De=(S||"").toLowerCase(),mt=De.endsWith(".pdf"),Ne=De.endsWith(".docx")||De.endsWith(".doc")||De.endsWith(".ppt")||De.endsWith(".pptx")||De.endsWith(".xls")||De.endsWith(".xlsx"),nt=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(De);mt||Ne?q=`${S.length>0?"\u2714":"\u2718"} ${S?`Analyzed: ${ae.basename(S)}`:"Analyzed: File Not Found"}`:nt?q=`${S.length>0?"\u2714":"\u2718"} ${S?`Processed: ${ae.basename(S)}`:"Processed: File Not Found"}`:q=`${je!=="..."?"\u2714":"\u2718"} Read: ${S?`${ae.basename(S)} \u2192 ${je!=="..."?`Lines ${de} - ${ze} of ${je}`:"File Not Found"}`:"File Not Found"}`}}else if(w==="list_files"||w==="read_folder"){let S=w==="list_files"?"List":"Browsed",H=oe(F.args).path||null,re=oe(F.args).recurse||1;q=`${H?"\u2714":"\u2718"} ${S}: ${H?`${H==="."?`./${re>1?"*":""}`:`${H.replaceAll("\\","/")}${re>1?`${H.endsWith("/")?"*":"/*"}`:`${H.endsWith("/")?"":"/"}`}`}`:"No Folder Selected"}`}else if(w==="find_file"){let S=oe(F.args),H=S.basename||S.name||S.path||S.file||S.query||"";q=`${H?"\u2714":"\u2718"} Located: ${H||"No Query"}`}else if(w==="write_file"||w==="update_file"){let S=w==="write_file"?"Created":"Edited",H=oe(F.args),re=H.path||null,be=Object.entries(H).some(([Fe,Oe])=>Fe.startsWith("searchContent")&&typeof Oe=="string"&&Oe.startsWith("^LINE:"))?"\u1361":":";q=`${re?"\u2714":"\u2718"} ${S}${be} ${re?re.replaceAll("\\","/"):"No File Changes"}`}else if(w==="write_pdf"){let S=oe(F.args).path||null;q=`${S?"\u2714":"\u2718"} Generated: ${S.replaceAll("\\","/")||"No PDF Generated"}`}else if(w==="write_docx"){let S=oe(F.args).path||null;q=`${S?"\u2714":"\u2718"} Generated: ${S.replaceAll("\\","/")||"No Docx Generated"}`}else if(w==="file_map"){let S=oe(F.args).path;q=`${S?"\u2714":"\u2718"} Indexed: ${S.replaceAll("\\","/")?""+S:"File Not Found"}`}else if(w.toLowerCase()==="search_keyword"||w.toLowerCase()==="todo")q="";else if(w.toLowerCase()==="generate_image"){let{path:S,outputPath:H,output:re}=oe(F.args);q=`\u2714 Generated: ${S||H||re||"generated_image.png"}`}else if(w==="invoke_sync"||w==="InvokeSync"){let S=Kn(w,F.args);q=`\u2714 Called Generalist${S?`: ${S}`:""}`}else if(w==="Invoke"||w==="InvokeAsync"||w==="invoke"){let S=Kn(w,F.args);q=`\u2714 Started Generalist${S?`: ${S}`:""}`}else if(w==="get_progress"||w==="GetProgress"){let S=Kn(w,F.args);q=`\u2714 Checked${S?`: ${S}`:""}`}else if(w==="cancel"){let S=Kn(w,F.args);q=`\u{1F6C7} Cancelled${S?`: ${S}`:""}`}else if(w==="steer"||w==="Steer"){let S=Kn(w,F.args);q=`\u2714 Steered${S?`: ${S}`:""}`}else if(w==="EmergencyRollback"){let{method:S}=oe(F.args);q=S==="forceRevert"?"":"\u2714 Rollback Point Checked"}else if(w==="await"||w==="Await"){let{time:S,timeout:H}=oe(F.args),re=parseFloat(H||S)||0;re||(re=120);let ge=Oe=>{if(Oe>=60){let Ce=Math.floor(Oe/60),J=Oe%60;return`${Ce}m${J>0?` ${J}s`:""}`}return`${Oe}s`},be=["Aligning Moon Phase","Contemplating Existence","Staring At Void","Delaying Professionally","Negotiating With Electrons","Touching Grass (virtually)","Panicking Softly","Rethinking Career Choices","Loading Cat Videos","Summoning Braincell #2","Pretending To Be Busy","Waiting For Motivation DLC","Rotating Internal Screaming","Downloading More RAM","Feeding The Hamsters","Gaslighting Scheduler","Performing Dramatic Pause","Buffering Social Energy","Calculating Regret","Reading Terms And Conditions","Becoming Sentient Briefly","Contacting Ancestors"];q=`\u2714 ${be[Math.floor(Math.random()*be.length)]} \u2192 ${ge(re)}`}else w==="Answer"||w==="answer"?q="\u2714 Resolved Sub-Agent Query":w==="exec_command"||w==="ask"?q="":q=`Executed: ${F.toolName}`;if(yield*Nn(),w==="exec_command"){let{command:S}=oe(F.args);if(S&&n.systemSettings&&n.systemSettings.allowExternalAccess===!1){let H=[/[a-zA-Z]:[\\\/]/i,/^\//,/\.\.[\\\/]/,/\/etc\//,/\/var\//,/\/root\//,/\/bin\//,/\/usr\//],re=ae.resolve(process.cwd()).substring(0,3).toLowerCase(),ge=J=>{let de=[],ue="",je=null;for(let ze=0;ze<J.length;ze++){let he=J[ze];je?(he===je&&(je=null),ue+=he):he==='"'||he==="'"?(je=he,ue+=he):he==="&"&&J[ze+1]==="&"||he==="|"&&J[ze+1]==="|"?(ue.trim()&&(de.push(ue.trim()),ue=""),ze++):he===";"||he==="|"||he==="&"?ue.trim()&&(de.push(ue.trim()),ue=""):ue+=he}return ue.trim()&&de.push(ue.trim()),de},be=J=>{let de=[],ue="",je=null;for(let ze=0;ze<J.length;ze++){let he=J[ze];je?(he===je&&(je=null),ue+=he):he==='"'||he==="'"?(je=he,ue+=he):/\s/.test(he)?ue&&(de.push(ue),ue=""):ue+=he}return ue&&de.push(ue),de},Fe=J=>{let de=J.replace(/^['"]|['"]$/g,"").trim();return!de||process.platform==="win32"&&/^\/[a-zA-Z0-9?]+$/.test(de)?!1:H.some(ue=>{if(ue.source==="[a-zA-Z]:[\\\\\\/]"){let je=de.match(/[a-zA-Z]:[\\\/]/i);return je&&je[0].toLowerCase()!==re}return ue.test(de)})};if(ge(S).some(J=>{let de=be(J);if(de.length===0)return!1;let ue=de[0].replace(/^['"]|['"]$/g,"").toLowerCase();if(["echo","printf","write-output"].includes(ue)){let ze=!1;return de.some(he=>{let At=he.replace(/^['"]|['"]$/g,"");if(At===">"||At===">>"||At==="<")return ze=!0,!1;if(At.startsWith(">")||At.startsWith("<")){let De=At.replace(/^[><]+/,"");return Fe(De)}return ze?(ze=!1,Fe(he)):!1})}return de.some(ze=>Fe(ze))})){let J='Access Denied. Prohibited from accessing external directories while "External Workspace Access" is disabled.';n.onExecStart&&n.onExecStart(S||"No Command"),yield{type:"exec_start"},await new Promise(de=>setTimeout(de,50)),n.onExecChunk&&n.onExecChunk(`ERROR: ${J}`),await new Promise(de=>setTimeout(de,50)),n.onExecEnd&&n.onExecEnd(),ve.push({role:"user",text:`[ACTION RESULT]: ERROR: ${J}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${J}`},gt++;continue}}n.onExecStart&&n.onExecStart(S||"No Command"),yield{type:"exec_start"}}let bt=oe(F.args),Bn=bt.path||bt.targetPath||null;if(Bn){let S=n.systemSettings&&n.systemSettings.allowExternalAccess===!1,H=ae.resolve(Bn),re=ae.resolve(process.cwd());if(S&&!H.startsWith(re)){let ge="Access Denied. You are not allowed to access files outside the current workspace.";if(w==="write_file"||w==="update_file"){let Fe=`\u2718 ${w==="write_file"?"Write Canceled":"Edit Canceled"}: ${bt.path||"..."}`,Oe=115;process.stdout.isTTY&&(Oe=process.stdout.columns-5||120);let Ce=Math.min(Fe.length+4,Oe),J=`${Fe.padEnd(Ce-2).substring(0,Ce-2)}`;yield{type:"visual_feedback",content:Yt(`${Ye?`
|
|
738
737
|
`:""}${J}
|
|
739
|
-
`)},Ye=!1}
|
|
740
|
-
`)?
|
|
741
|
-
`,
|
|
738
|
+
`)},Ye=!1}ve.push({role:"user",text:`[ACTION RESULT]: ERROR: ${ge}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${ge}`},gt++;continue}}if(n.onToolApproval&&(w==="write_file"||w==="update_file"||w==="exec_command")){let H=n.systemSettings||{},re=H.autoExec,ge=null,be=!1,Fe=!1,Oe=!1;if(w==="exec_command"){let{command:De}=oe(F.args),mt=(De||"").trim(),Ne=(Gt,wt)=>{if(!wt)return!1;let Zt=wt.split(",").map(jt=>jt.trim().toLowerCase()).filter(Boolean),lt=Gt.toLowerCase();return Zt.some(jt=>lt.startsWith(jt))},nt=Ne(mt,H.alwaysAskCommands),_e=Ne(mt,H.autoApproveCommands);if(Fe=Ne(mt,H.autoDisallowCommands),nt?be=!0:(_e||H.autoApproveGit&&/^git\s+commit\b/i.test(mt))&&(ge="allow"),!be&&!ge){if(H.networkAccess===!1){let wt=mt.trim().replace(/\s+/g," ").replace(/^['"]+|['"]+$/g,"").toLowerCase().split(" "),lt=wt[0].split("/").pop().split("\\").pop().replace(/\.exe$/,""),jt=new Set(["curl","wget","httpie","xh","ssh","scp","sftp","rsync","ftp","lftp","tftp","telnet","nc","netcat","socat","ping","traceroute","tracert","dig","nslookup","host","whois","nmap","docker","podman","kubectl","helm","gcloud","aws","az","terraform","ansible-playbook","nix","nix-env","apt","apt-get","dpkg","yum","dnf","pacman","zypper","brew","apk","choco","scoop","conda","mamba","aria2c","axel","smbclient","lynx","w3m","links","elinks","heroku","netlify","vercel","firebase","supabase","wrangler","flyctl","powershell","pwsh","certutil","bitsadmin","cloudflared","ngrok","tailscale","zerotier","rclone"]),ct=!1;jt.has(lt)&&(ct=!0);let ot=En=>wt.slice(1).some(mn=>En.includes(mn)),dt=En=>{let mn=wt.findIndex(pn=>En.includes(pn)),Un=wt.findIndex(pn=>["run","exec","test"].includes(pn));return mn!==-1&&!(Un!==-1&&Un<mn)};lt==="git"&&ot(["clone","pull","push","fetch"])&&(ct=!0),lt==="go"&&ot(["get","install"])&&(ct=!0),lt==="npm"&&dt(["install","i","update","add"])&&(ct=!0),lt==="yarn"&&dt(["add","install","upgrade"])&&(ct=!0),lt==="pnpm"&&dt(["add","install","update"])&&(ct=!0),lt==="bun"&&dt(["add","install","update"])&&(ct=!0),lt==="deno"&&ot(["install","add"])&&(ct=!0),lt==="pip"&&ot(["install","download"])&&(ct=!0),lt==="pip3"&&ot(["install","download"])&&(ct=!0),lt==="cargo"&&ot(["install","add"])&&(ct=!0),["bash","sh","zsh","fish"].includes(lt)&&ot(["-c"])&&(ct=!0),lt==="cmd"&&ot(["/c"])&&(ct=!0),ct&&(ge="deny",Oe=!0)}!ge&&Fe&&(ge="deny")}!be&&!ge&&re&&(ge="allow")}else re&&(ge="allow");let Ce=ge,J="";ge==="deny"&&(Oe?J="network":Fe?J="settings":J="prohibited");let de=!1,ue="",je=[],ze=0,he=!1,At="";if(!Ce){if(w==="write_file"||w==="update_file")try{let Ne=oe(F.args),{path:nt}=Ne;if(nt){let _e=ae.resolve(process.cwd(),nt),Gt=ot=>ot?ot.toLowerCase().replace(/\\/g,"/").replace(/^[a-z]:/,dt=>dt.toUpperCase()):"",wt=Gt(_e),Zt="",lt=!1,jt=await Hn(),ct=Gt(jt?.file_focused);if(jt&&ct===wt&&jt.full_content?(Zt=jt.full_content,lt=!0):Ue.existsSync(_e)&&(Zt=Ue.readFileSync(_e,"utf8"),lt=!0),ue=Zt,await Do.recordFileChange(_e,Zt),lt){let ot=Zt;if(w==="write_file"){let dt=Ne.content||Ne.newContent||"";ot=dt.endsWith(`
|
|
739
|
+
`)?dt:dt+`
|
|
740
|
+
`,At=ot}else{let{patchPairs:dt,allowMultiple:En,error:mn}=Ti(Ne);if(mn){let Xt=`[ACTION RESULT]: ERROR: ${mn}`;ve.push({role:"user",text:Xt}),await vt("toolFailure"),n.onToolResult&&n.onToolResult("failure",w),yield{type:"tool_result",content:Xt,toolName:w},gt++;continue}let Un=Ne.allowMultiple!==void 0?Ne.allowMultiple===!0||String(Ne.allowMultiple).toLowerCase()==="true":En;ze=dt.length;let pn=Si(Zt,dt,{allowMultiple:Un});ot=pn.content,At=ot,je=pn.results;let Eo=je.filter(Xt=>Xt.success),xs=je.filter(Xt=>!Xt.success);if(Eo.length===0){let Xt=`[ACTION RESULT]: ERROR: Failed to apply patches to [${ae.basename(_e)}].
|
|
742
741
|
${xs.map(Co=>` \u2022 ${Co.error}`).join(`
|
|
743
|
-
`)}`,oo=`\u2714 Edited: ${
|
|
744
|
-
`:""}${so}`)},Ye=!1,
|
|
745
|
-
`)?
|
|
746
|
-
`;
|
|
742
|
+
`)}`,oo=`\u2714 Edited: ${ae.basename(_e.replaceAll("\\","/"))}`,ft=115;process.stdout.isTTY&&(ft=process.stdout.columns-5||120);let Kt=Math.min(oo.length+4,ft),so=`${oo.padEnd(Kt-2).substring(0,Kt-2)}`;yield{type:"visual_feedback",content:Yt(`${Ye?`
|
|
743
|
+
`:""}${so}`)},Ye=!1,ve.push({role:"user",text:Xt}),await vt("toolFailure"),n.onToolResult&&n.onToolResult("failure",w),yield{type:"tool_result",content:Xt,toolName:w},gt++;continue}}yield{type:"status",content:`Opening Diff in IDE: ${ae.basename(_e)}`},zs(_e,Zt,ot),de=!0,await new Promise(dt=>setTimeout(dt,50))}else if(w==="write_file"){let ot=Ne.content||Ne.newContent||"",dt=ot.endsWith(`
|
|
744
|
+
`)?ot:ot+`
|
|
745
|
+
`;At=dt,Ue.existsSync(_e)||(he=!0,Ue.mkdirSync(ae.dirname(_e),{recursive:!0}),Ue.writeFileSync(_e,"","utf8")),yield{type:"status",content:`Opening New File Diff in IDE: ${ae.basename(_e)}`},zs(_e,"",dt),de=!0,await new Promise(En=>setTimeout(En,50))}}}catch(Ne){console.error("Simulation/Diff Error:",Ne)}let De=null;qs(Ne=>{De=Ne});let mt=n.onToolApproval;if(Ce=await new Promise(async Ne=>{let nt=setInterval(()=>{De&&(as.onIDEApproval&&as.onIDEApproval(De),clearInterval(nt),Ne(De))},100);try{let _e=await mt(w,F.args);clearInterval(nt),Ne(_e)}catch{clearInterval(nt),Ne("deny")}}),qs(null),w==="write_file"||w==="update_file"){let{path:Ne}=oe(F.args);if(Ne){let nt=ae.resolve(process.cwd(),Ne);if(Nr(nt,Ce),Ce==="deny"&&he&&Ue.existsSync(nt))try{Ue.unlinkSync(nt)}catch{}}}Ce==="deny"&&(J="user")}if(Ce==="allow"&&de&&zo()){let{path:De}=oe(F.args),mt=ae.resolve(process.cwd(),De),Ne=ft=>ft?ae.resolve(ft).replace(/\\/g,"/").toLowerCase():"",nt=await Hn(),_e="";if(nt&&nt.file_focused&&Ne(nt.file_focused)===Ne(mt)&&nt.full_content&&(_e=nt.full_content),!_e&&Ue.existsSync(mt)){let ft=Ue.readFileSync(mt,"utf8");ft&&(_e=ft)}!_e&&At&&(_e=At),(_e||he)&&Ue.writeFileSync(mt,_e,"utf8");let Gt=_e.split(/\r?\n/),wt=Gt.length,Zt=Buffer.byteLength(_e,"utf8"),lt="";ue&&(lt=`Old File contents:
|
|
747
746
|
${ue.split(/\r?\n/).map((Kt,so)=>`${so+1} | ${Kt}`).join(`
|
|
748
747
|
`)}
|
|
749
748
|
|
|
750
|
-
`);let jt="";if(
|
|
751
|
-
`);else{let
|
|
749
|
+
`);let jt="";if(wt<=100)jt=Gt.join(`
|
|
750
|
+
`);else{let ft=Gt.slice(0,50).join(`
|
|
752
751
|
`),Kt=Gt.slice(-50).join(`
|
|
753
|
-
`);jt=`${
|
|
752
|
+
`);jt=`${ft}
|
|
754
753
|
|
|
755
|
-
... [${
|
|
754
|
+
... [${wt-100} lines truncated for history stability] ...
|
|
756
755
|
|
|
757
|
-
${Kt}`}let
|
|
756
|
+
${Kt}`}let ct="";if(w==="update_file"){let ft=_i(ue,_e,je,12,n?.compressToolResults||as?.systemSettings?.compressToolResults);ct=`File [${De}] updated via IDE Companion (May have user edits). [${je.length}/${ze}] blocks applied.
|
|
758
757
|
|
|
759
|
-
${
|
|
758
|
+
${ft}`}else{let ft=_e.split(/\r?\n/),Kt=ft.length,so=Buffer.byteLength(_e,"utf8"),Co="";ue&&(Co=`Old File contents:
|
|
760
759
|
${ue.split(/\r?\n/).map((ws,ua)=>`${ua+1} | ${ws}`).join(`
|
|
761
760
|
`)}
|
|
762
761
|
|
|
763
|
-
`);let bs="";if(Kt<=100)bs=
|
|
764
|
-
`);else{let wi=
|
|
765
|
-
`),ws=
|
|
762
|
+
`);let bs="";if(Kt<=100)bs=ft.join(`
|
|
763
|
+
`);else{let wi=ft.slice(0,50).join(`
|
|
764
|
+
`),ws=ft.slice(-50).join(`
|
|
766
765
|
`);bs=`${wi}
|
|
767
766
|
|
|
768
767
|
... [${Kt-100} lines truncated] ...
|
|
769
768
|
|
|
770
|
-
${ws}`}
|
|
769
|
+
${ws}`}ct=`File [${De}] saved via IDE Companion (May have user edits).
|
|
771
770
|
- Stats: [${Kt} lines, ${(so/1024).toFixed(1)} KB]
|
|
772
771
|
${Co}- Content Preview:
|
|
773
772
|
|
|
774
|
-
${bs}`}let
|
|
775
|
-
`:""}${xs}`)},Ye=!1;let Xt=Date.now();We=Xt,yield{type:"tool_time",content:Xt-
|
|
773
|
+
${bs}`}let ot=w==="write_file"?"Created":"Edited",dt=oe(F.args),mn=Object.entries(dt).some(([ft,Kt])=>ft.startsWith("searchContent")&&typeof Kt=="string"&&Kt.startsWith("^LINE:"))?"\u1361":":",Un=`${De?"\u2714":"\u2718"} ${ot}${mn} ${De?De.replaceAll("\\","/"):"No File Changes"}`,pn=115;process.stdout.isTTY&&(pn=process.stdout.columns-5||120);let Eo=Math.min(Un.length+4,pn),xs=`${Un.padEnd(Eo-2).substring(0,Eo-2)}`;yield{type:"visual_feedback",content:Yt(`${Ye?`
|
|
774
|
+
`:""}${xs}`)},Ye=!1;let Xt=Date.now();We=Xt,yield{type:"tool_time",content:Xt-j};let oo=`[ACTION RESULT]: ${ct}`;ve.push({role:"user",text:oo}),kn=!0,await vt("toolSuccess"),n.onToolResult&&n.onToolResult("success",w),yield{type:"tool_result",content:ct,aiContent:oo,toolName:w},gt++;continue}if(Ce==="deny"){let De=`Permission Denied: Prohibited ${w==="exec_command"?"Command":"file edit"}.`;if(J==="user"?De="Permission Denied by User":J==="settings"?De="Permission Denied by User Policy":J==="network"?De="Permission Denied: Sandbox Network Access Disabled by User Policy.":J==="prohibited"&&w==="exec_command"&&(De="Permission Denied: Prohibited Command in User Policy"),w==="write_file"||w==="update_file"){let Ne=`\u2718 ${w==="write_file"?"Write Cancelled":"Edit Denied"}: ${oe(F.args).path.replaceAll("\\","/")||"..."}`,nt=115;process.stdout.isTTY&&(nt=process.stdout.columns-5||120);let _e=Math.min(Ne.length+4,nt),Gt=`${Ne.padEnd(_e-2).substring(0,_e-2)}`,wt=` ${" ".repeat(_e)} `;yield{type:"visual_feedback",content:Yt(`${Ye?`
|
|
776
775
|
`:""}${Gt}
|
|
777
|
-
`)},Ye=!1}
|
|
778
|
-
`:""}${
|
|
779
|
-
`}`}`)},Ye=!1}if(We>0){let S=Date.now()-We,H=Math.max(0,1e3-S);H>0&&await new Promise(
|
|
776
|
+
`)},Ye=!1}w==="exec_command"&&(await new Promise(mt=>setTimeout(mt,50)),n.onExecChunk&&n.onExecChunk(`ERROR: ${De}`),await new Promise(mt=>setTimeout(mt,50)),n.onExecEnd&&n.onExecEnd()),ve.push({role:"user",text:`[ACTION RESULT]: DENIED: ${De}`}),yield{type:"tool_result",content:`[ACTION RESULT]: DENIED: ${De}`},await vt("toolDenied"),n.onToolResult&&n.onToolResult("denied",w),gt++;continue}}if(q){let S=115;process.stdout.isTTY&&(S=process.stdout.columns-5||120);let H=await s(),re=!1;H&&(re=H.trim().length>0);let ge=Math.min(q.length+4,S),be=`${q.padEnd(ge-2).substring(0,ge-2)}`;yield{type:"visual_feedback",content:Yt(`${Ye?`
|
|
777
|
+
`:""}${be}${q.includes("\u2714")&&(q.includes("Created")||q.includes("Edited"))?"":`${re?"":`
|
|
778
|
+
`}`}`)},Ye=!1}if(We>0){let S=Date.now()-We,H=Math.max(0,1e3-S);H>0&&await new Promise(re=>setTimeout(re,H))}let An={chatId:p,history:t,onChunk:S=>n.onExecChunk?n.onExecChunk(S):null,onAskUser:n.onAskUser,systemSettings:n.systemSettings,mode:l,isMultiModal:ut(Te),onVisualFeedback:n.onVisualFeedback,onSubagentUpdate:n.onSubagentUpdate,onTokenChunk:n.onTokenChunk,modelName:Te,aiProvider:n.aiProvider,apiKey:n.apiKey,onUsage:n.onUsage};if(w==="write_file"||w==="update_file")try{let{path:S}=oe(F.args);if(S){let H=ae.resolve(process.cwd(),S),re=await Hn();re&&re.file_focused===H&&re.full_content&&(An.forcedContent=re.full_content)}}catch{}st.push(w);let Pe=await xo(w,F.args,An);if((w==="write_file"||w==="update_file")&&!Pe.startsWith("ERROR:")){let{path:S}=oe(F.args);if(S){let H=ae.resolve(process.cwd(),S);$r(H)}}process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07");let Nt=Date.now();We=Nt,yield{type:"tool_time",content:Nt-j},V=Nt;let Ht=null;if(typeof Pe=="object"&&Pe.binaryPart&&(Ht=Pe.binaryPart,Pe=Pe.text),w==="search_keyword"){let{keyword:S,path:H}=oe(F.args),re=typeof Pe=="string"&&Pe.startsWith("[GLOB]");re&&(Pe=Pe.slice(6).trimStart());let ge=typeof Pe=="string"&&Pe.startsWith("[DIR]");ge&&(Pe=Pe.slice(5).trimStart());let be=0;if(Pe){let he=Pe.match(/Found (\d+) match/i);he&&(be=parseInt(he[1]))}let Fe=(H||"").trim().toLowerCase().replaceAll("\\","/"),Oe=Fe==="#doc"||Fe==="#docs"||Fe==="#documentation"||Fe.includes("#skill/global/fluxflow")||Fe.includes("#skill/fluxflow")||Fe.includes("#skills/fluxflow")||Fe.includes("#skills/global/fluxflow"),Ce,J=115;process.stdout.isTTY&&(J=process.stdout.columns-5||120);let de=Math.max(10,(J+5)/3),ue=Math.max(10,(J+5)/4);if(Oe)Ce=`${S?"\u2714":"\u2718"} Searched Documentation`;else{let he=H?H.replace(/[\/\\]+$/,""):null,At=he&&he!=="."?`${re?H:ge?`${he}/*`:he}`:"./",De=At.length>ue?`${At.slice(0,ue)}...`:At;Ce=`${S?"\u2714":"\u2718"} Searched: "${S?S.length>J/2?`${S.slice(0,de)}...`:S:""}" in "${De.replaceAll("\\","/")}" \u2192 ${be} Match${be===1?"":"es"}`}let je=Math.min(Ce.length+4,J),ze=`${Ce.padEnd(je-2).substring(0,je-2)}`;yield{type:"visual_feedback",content:Yt(`${Ye?`
|
|
780
779
|
`:""}${ze}
|
|
781
|
-
`)},Ye=!1}if(
|
|
782
|
-
`:""}${J}${
|
|
783
|
-
`}`)},Ye=!1}}if(
|
|
784
|
-
`)}return Ce.filter(J=>String(J).trim()).map(J=>{let
|
|
780
|
+
`)},Ye=!1}if(w==="EmergencyRollback"){let{method:S}=oe(F.args);if(S==="forceRevert"){let H=0;if(Pe){let de=Pe.match(/Total\s*:\s*(\d+)/i);de&&(H=parseInt(de[1]))}let ge=Pe&&Pe.startsWith("ERROR:")?"\u2718 Emergency Rollback Failed":`\u2714 Emergency Rollback \u2192 ${H} file${H===1?"":"s"} processed`,be=115;process.stdout.isTTY&&(be=process.stdout.columns-5||120);let Fe=await s(),Oe=!1;Fe&&(Oe=Fe.trim().length>0);let Ce=Math.min(ge.length+4,be),J=`${ge.padEnd(Ce-2).substring(0,Ce-2)}`;yield{type:"visual_feedback",content:Yt(`${Ye?`
|
|
781
|
+
`:""}${J}${Oe?"":`
|
|
782
|
+
`}`)},Ye=!1}}if(w==="todo"){let{method:S,tasks:H,markDone:re}=oe(F.args),ge="",be=[],Fe=Oe=>{if(!Oe)return[];let Ce=Array.isArray(Oe)?Oe:[];if(Ce.length===0&&typeof Oe=="string"){let J=Oe.trim();if(J.startsWith("[")&&J.endsWith("]")){let de=J.match(/"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'/g);de?Ce=de.map(ue=>ue.slice(1,-1).replace(/\\(.)/g,"$1")):Ce=J.slice(1,-1).split(",").map(ue=>ue.trim()).filter(Boolean)}else Ce=Oe.split(`
|
|
783
|
+
`)}return Ce.filter(J=>String(J).trim()).map(J=>{let de=String(J).trim();return de.startsWith("- [")?de.substring(6).trim():de})};if(S==="create"?(ge="\x1B[32m\u2192\x1B[0m Created Goals",be=Fe(H).map(Oe=>`\x1B[90m\u25CB\x1B[0m ${Oe}`)):S==="append"?(ge="\x1B[34m\u2795\x1B[0m Added New Goals",be=Fe(H).map(Oe=>`\x1B[90m\u25CB\x1B[0m ${Oe}`)):S==="get"&&(ge=re?"\x1B[36m\u21BB\x1B[0m Updated Goals":"\x1B[35m\u2022\x1B[0m Reviewed Goals",be=(Pe||"").split(`
|
|
785
784
|
`).slice(1).join(`
|
|
786
785
|
`).split(`
|
|
787
|
-
`).filter(Ce=>Ce.trim().startsWith("- [")).map(Ce=>{let J=Ce.trim(),
|
|
786
|
+
`).filter(Ce=>Ce.trim().startsWith("- [")).map(Ce=>{let J=Ce.trim(),de=J.startsWith("- [x]");return`${de?"\x1B[32m\u2714\x1B[0m":"\x1B[90m\u25CB\x1B[0m"} ${de?"\x1B[90m":"\x1B[37m"}${J.substring(6).trim()}\x1B[0m`})),ge&&be.length>0){let Oe=[`${ge}`,...be.map(de=>` ${de}`)].join(`
|
|
788
787
|
`),Ce=await s(),J=!1;Ce&&(J=Ce.trim().length>0),yield{type:"visual_feedback",content:Yt(`${Ye?`
|
|
789
|
-
`:""}${
|
|
790
|
-
`}`)},Ye=!1}}
|
|
791
|
-
`));let hn;if(Ft.startsWith("[[SAME]]")){let H=Ft.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),
|
|
788
|
+
`:""}${Oe}${J?"":`
|
|
789
|
+
`}`)},Ye=!1}}w==="exec_command"&&n.onExecEnd&&(await new Promise(S=>setTimeout(S,800)),n.onExecEnd());let gn=Pe&&Pe.startsWith("DENIED:");Pe&&!Pe.startsWith("ERROR:")&&!gn?(await vt("toolSuccess"),n.onToolResult&&n.onToolResult("success",w)):gn||(await vt("toolFailure"),n.onToolResult&&n.onToolResult("failure",w));let Ft=(Pe||"").toString().replaceAll("[UI_CONTEXT]","");Ft.includes("[[VERIFIED]]")&&(Ft=Ft.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to conserve context.
|
|
790
|
+
`));let hn;if(Ft.startsWith("[[SAME]]")){let H=Ft.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),re=H.filter(be=>be.startsWith("File ")||be.trim().startsWith("- Stats:"));hn=`[ACTION RESULT]: ${re.length>0?re.join(`
|
|
792
791
|
`):H.slice(0,2).join(`
|
|
793
792
|
`)}
|
|
794
|
-
[SYSTEM NOTE]: Content verified and persisted to disk. Full preview omitted to conserve context.`}else hn=`[ACTION RESULT]: ${Ft}`;
|
|
793
|
+
[SYSTEM NOTE]: Content verified and persisted to disk. Full preview omitted to conserve context.`}else hn=`[ACTION RESULT]: ${Ft}`;ve.push({role:"user",text:hn,binaryPart:Ht}),kn=!0;let $e=`[ACTION RESULT]: ${Pe.replaceAll(`[[VERIFIED]]
|
|
795
794
|
`,"").replaceAll(`
|
|
796
|
-
[[/VERIFIED]]`,"")||""}`;(
|
|
795
|
+
[[/VERIFIED]]`,"")||""}`;(w==="view_file"||w==="web_scrape"||w==="file_map")&&($e=`[ACTION RESULT]: ${q} (Context Locked for UI Clarity)`),yield{type:"tool_result",content:$e,aiContent:hn,binaryPart:Ht,toolName:w},w==="memory"&&!Pe.startsWith("ERROR:")&&(yield{type:"memory_updated"}),gt++}if(i==="Google"&&an&&Date.now()-ms>=150){yield*Nn();let F=to(an);for(let j of F)yield j;an="",ms=Date.now()}}v.usageMetadata&&(Jt=v.usageMetadata),Jt&&(yield{type:"liveTokens",content:Jt.totalTokenCount})}if(me&&(me=!1,Dt?Qe+="</think>":(ke+="</think>",i==="Google"?an+="</think>":yield{type:"text",content:"</think>"})),Dt&&Qe.length>0){let v=0,Y=Math.min(xt.length,Qe.length);for(let z=Y;z>0;z--)if(xt.endsWith(Qe.substring(0,z))){v=z;break}let W=Qe.substring(v);if(W){let Q=/(?:<(think|thought)>|\[(think|thought)\])(?:(?!(?:<\/(?:think|thought)>|\[\/(?:think|thought)\]))[\s\S])*$/i.test(xt)?W.replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])\s*/gi,""):W.replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])[\s\S]*?(?:<\/(think|thought)>|\[\/(think|thought)\])\s*/gi,"").replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])\s*/gi,"");if(Q)if(ke+=Q,i==="Google")an+=Q;else{yield*Nn();let X=to(Q);for(let ne of X)yield ne}}Dt=!1,Qe=""}if(yield*Nn(),kt)break;let no=(ke||"").trim(),ra=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(no.toLowerCase())||/\[\[END\]\]/i.test(no.toLowerCase()),aa=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(no.toLowerCase()),la=ve.length>0||Ve!==null,ps=qt(no).trim(),ca=/(\p{Emoji_Presentation}|\p{Extended_Pictographic})$/u.test(ps),da=/([.!?"'*_`|\]\)”’~~]+|\s|`{3}|[\u200B-\u200D\uFEFF])$/u.test(ps.trim()),fa=/[.!?}"'`’“”]$|```$/s.test(ps)||da||ca;!ra&&!aa&&!la&&no.length>0,it=!0,await vt("agent",i)}catch(Ae){if(kt){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
|
|
797
796
|
|
|
798
|
-
\x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(String(Ae).includes("Incomplete JSON segment at the end")){
|
|
797
|
+
\x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(String(Ae).includes("Incomplete JSON segment at the end")){me&&(me=!1,Dt?Qe+="</think>":(ke+="</think>",yield{type:"text",content:"</think>"})),it=!0,await vt("agent",i);break}if(me&&(me=!1,Dt?Qe+="</think>":ke+="</think>"),Dt&&Qe.length>0){let $t=0,Rt=Math.min(xt.length,Qe.length);for(let Ot=Rt;Ot>0;Ot--)if(xt.endsWith(Qe.substring(0,Ot))){$t=Ot;break}let St=Qe.substring($t);if(St){let ht=/(?:<(think|thought)>|\[(think|thought)\])(?:(?!(?:<\/(?:think|thought)>|\[\/(?:think|thought)\]))[\s\S])*$/i.test(xt)?St.replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])\s*/gi,""):St.replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])[\s\S]*?(?:<\/(think|thought)>|\[\/(think|thought)\])\s*/gi,"").replace(/^\s*(?:<(think|thought)>|\[(think|thought)\])\s*/gi,"");ht&&(ke+=ht)}Dt=!1,Qe=""}let ee=Ae instanceof Error?(()=>{try{return JSON.parse(JSON.parse(Ae.message).error.message).error.message}catch{return String(Ae)}})():String(Ae),Pt=new Date().toLocaleString(),Et=ae.join(Cn,"agent");Ue.existsSync(Et)||Ue.mkdirSync(Et,{recursive:!0}),Ue.appendFileSync(ae.join(Et,"error.log"),`ERROR [${Pt}]: ${ee}
|
|
799
798
|
|
|
800
799
|
----------------------------------------------------------------------
|
|
801
800
|
|
|
802
|
-
`);let
|
|
801
|
+
`);let Ct=Ae.status||Ae.statusCode||Ae.code,zt=String(Ae).includes("replicas at capacity");if(!(Ct&&(Ct>=500&&Ct<600||Ct===408||Ct===429||zt)||!Ct&&(/status[ :]+(5\d\d|408|429)/i.test(String(Ae))||/code[ :]+(5\d\d|408|429)/i.test(String(Ae))||/(500|503|408|429)/.test(String(Ae))))){if(et<on-3)throw Ae;yield{type:"text",content:ee},yield{type:"status",content:"Error Occured"}}if(ke.trim().length>0||at>1)if(at<=on){at++;let $t=Math.min(1e3*Math.pow(2,at-1),24e3);if(ke.trim().length>0){r.push({role:"agent",text:ke});let Rt=`[system]
|
|
803
802
|
- seamless continuation: resume immediately. pick up from last words with zero gap/disruption
|
|
804
803
|
- no repetition: do not repeat any text already written
|
|
805
804
|
- no re-think: do not restart or open <think> if reasoning already started. continue the thinking and close thinking block </think> before chat output
|
|
806
805
|
- mid-tool safety: if cutoff was mid-tool call, restart that tool call from start
|
|
807
|
-
- stealth: do not mention/apologize for cutoff [/system]`;
|
|
806
|
+
- stealth: do not mention/apologize for cutoff [/system]`;ve.length>0?ve.forEach((St,Ot)=>{Ot===ve.length-1?r.push({...St,text:`${St.text}
|
|
808
807
|
|
|
809
|
-
${
|
|
810
|
-
Error log can be found in \`/export logs\``);else if(et<=on){et++,
|
|
811
|
-
Error log can be found in \`/export logs\``)}}if(Jt){let
|
|
812
|
-
`),Ae=qt(
|
|
808
|
+
${Rt}`}):r.push(St)}):r.push({role:"user",text:Rt}),xt+=ke}for(let Rt=$t/1e3;Rt>0&&!kt;Rt--)yield{type:"status",content:`Error Occured. Recovering Stream (${at}/${on}) [Retrying in ${Rt.toFixed(0)}s]...`},await new Promise(St=>setTimeout(St,1e3));yield{type:"status",content:"Error Occured. Recovering Stream..."}}else throw new Error(`Stream collapsed too many times. (Failed to resolve ${on} times)
|
|
809
|
+
Error log can be found in \`/export logs\``);else if(et<=on){et++,at=1,xt="";let $t=Math.min(1e3*Math.pow(2,et-1),32e3),Rt=.8+Math.random()*.4,St=Math.round($t*Rt);Zn=!0,yield{type:"status",content:`Trying to reach ${e} (${et}/${on}) [Retrying in ${(St/1e3).toFixed(0)}s]`};for(let Ot=St/1e3;Ot>0&&!kt;Ot--)yield{type:"status",content:`Trying to reach ${e} (${et}/${on}) [Retrying in ${Ot.toFixed(0)}s]`},await new Promise(ht=>setTimeout(ht,1e3));yield{type:"status",content:`Trying to reach ${e}`}}else throw new Error(`Model ${e} cannot be reached. (Failed ${on} times)
|
|
810
|
+
Error log can be found in \`/export logs\``)}}if(Jt){let me=Jt.totalTokenCount||0,Ae=Jt.cachedContentTokenCount||0,ee=(Jt.candidatesTokenCount||0)+(i==="Google"&&Jt.thoughtsTokenCount||0);await Bt("tokens",me,i,Te),Ae>0&&await Bt("cachedTokens",Ae,i,Te),ee>0&&await Bt("candidateTokens",ee,i,Te),Oo({provider:i,model:Te,prompt:Jt.promptTokenCount||0,cached:Ae,output:ee,reasoning:Jt.thoughtsTokenCount||0}),yield{type:"usage",content:Jt}}ke=qr(ke),hs.push(ke);let Sn=qt(ke),Pn=jr(ke),un=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(Pn.toLowerCase())||/\[\[END\]\]/i.test(Pn.toLowerCase())||!0,il=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(Pn.toLowerCase()),rl=gt>0;yield{type:"status",content:"Thinking"};let na=Za(ke,/(\[\s*(turn\s*:)?\s*(continue|finish)\s*\]|\[\[END\]\])/gi,"").trim(),$n=(un||ve.length===0)&&!It&&!rn&&!Tn;if($n=ve.length===0?$n:!1,$n=Lt||_o?!1:$n,ke&&ke.trim().endsWith('")]')&&ve.length===0&&($n=!1),$n){pi=!0;let me=hs.join(`
|
|
811
|
+
`),Ae=qt(me).trim();yield{type:"interactive_turn_finished",data:{agentText:a,fullAgentTextRaw:me,history:[...r],needTitle:y}},r.length>0&&r[r.length-1].role==="agent"?r[r.length-1].text=Ae:r.push({role:"agent",text:Ae}),r.forEach(ee=>{if(ee.role==="user"&&ee.text&&(ee.text=ee.text.replace(/\n\[COMPILE ERROR\][\s\S]*?\[\/ERROR\]/g,""),ee.text=ee.text.replaceAll(`
|
|
813
812
|
|
|
814
813
|
[system] user question. resolve this specific query within '[ANSWER] ... [/ANSWER]' concisely, naturally [/system]
|
|
815
814
|
`,"").replaceAll(`[system] user question. resolve this specific query within '[ANSWER] ... [/ANSWER]' concisely, naturally
|
|
816
815
|
**strictly follow thinking policy as high priority. do not start a response without <think>...</think>** [/system]
|
|
817
816
|
`,"").replaceAll(`[system] **strictly follow thinking policy as high priority. do not start a response without <think>...</think>** [/system]
|
|
818
|
-
`,"").replaceAll(/\n\[system\] WARNING, Turn Limit Impending: Step \d+\/\d+\. Wrap up quickly\/prompt user to continue & use \[\[END\]\] quickly\. \[\/system\]/g,""),ee.text=ee.text.replaceAll(/\n\[system\] File Changes:\n(?:\* .+ \(created|modified|deleted\)\n)*\[\/system\]/g,""),(i==="Mistral"||i==="Google"&&e?.toLowerCase().startsWith("gemma"))&&(ee.text.startsWith("[ACTION RESULT]")||ee.text.startsWith("[TOOL RESULT]")))){let
|
|
819
|
-
[system] Action result received. Analyze output and proceed with your turn [/system]`,
|
|
820
|
-
[system] Action result received. Analyze output and proceed with your turn. **strictly follow thinking policy. do not start a response without <think>...</think>** [/system]`;ee.text=ee.text.replaceAll(
|
|
817
|
+
`,"").replaceAll(/\n\[system\] WARNING, Turn Limit Impending: Step \d+\/\d+\. Wrap up quickly\/prompt user to continue & use \[\[END\]\] quickly\. \[\/system\]/g,""),ee.text=ee.text.replaceAll(/\n\[system\] File Changes:\n(?:\* .+ \(created|modified|deleted\)\n)*\[\/system\]/g,""),(i==="Mistral"||i==="Google"&&e?.toLowerCase().startsWith("gemma"))&&(ee.text.startsWith("[ACTION RESULT]")||ee.text.startsWith("[TOOL RESULT]")))){let Et=`
|
|
818
|
+
[system] Action result received. Analyze output and proceed with your turn [/system]`,Ct=`
|
|
819
|
+
[system] Action result received. Analyze output and proceed with your turn. **strictly follow thinking policy. do not start a response without <think>...</think>** [/system]`;ee.text=ee.text.replaceAll(Ct,"").replaceAll(Et,"").trim()}}),yield{type:"status",content:"[end]"}}if($n)break;let oa=na.trim()||"*Working...*";if(r.push({role:"agent",text:oa}),ve.length>0||kn){if(ve.length>0){let me=ve.map(zt=>zt.text).join(`
|
|
821
820
|
|
|
822
|
-
`),
|
|
821
|
+
`),Pt=(qt(ke).replace(/\[{1,2}(?:tool|action):[\s\S]*?\)\s*\]{1,2}/gi,"").match(/\[(?:tool|action):/gi)||[]).length,Et=ve.length+Pt;if(ve.length<Et){me+=`
|
|
823
822
|
|
|
824
|
-
[system] Only ${
|
|
823
|
+
[system] Only ${ve.length} out of ${Et} attempted tool calls were executed. Verify proper structure compliance & try failed calls again [/system]`;let zt=Et-ve.length;for(let Ge=0;Ge<zt;Ge++)await vt("toolFailure")}let Ct=ve.find(zt=>zt.binaryPart)?.binaryPart||null;r.push({role:"user",text:me,binaryPart:Ct})}}else if(!kt){let Ae=(ke.replace(/(?:<(think|thought|thoughts)>|\[(think|thought|thoughts)\])[\s\S]*?(?:<\/(think|thought|thoughts)>|\[\/(think|thought|thoughts)\]|$)/i,"").match(/\[(?:tool|action):/gi)||[]).length;_o||Lt||Ae>0?(r.push({role:"user",text:`[system] Failed to execute ${Ae} tool${Ae>1?"s":""}. Verify proper structure compliance [action:ActionName(...)] & try again [/system]`}),await vt("toolFailure"),yield{type:"visual_feedback",content:`
|
|
825
824
|
${Yt("\u2718 Execution Error")}
|
|
826
825
|
`}):(yield{type:"visual_feedback",content:`
|
|
827
826
|
${Yt("\u2718 Loop Detected")}
|
|
828
|
-
`},r.push({role:"user",text:`[system] ${rn&&!
|
|
827
|
+
`},r.push({role:"user",text:`[system] ${rn&&!It?"Stuttering Detected by Internal System. Re-calibrate your response & proceed.":`${It?" Over Thinking":" Loop"} Detected by Internal System${It?" for current Effort Level":""}. ${It?"If you have planned the task, prioritize execution/output":"If you have finished your task provide a simple summary and end"}`} [/system]`})),It=!1,rn=!1,Tn=!1}T?.advanceRollback&&await lo.recordTurnDelta(p,K+1,st),_o=gt>0||kn}if(!pi&&!kt){let K="\u2726 Turn safety limit reached. Stopping execution.";yield{type:"text",content:`
|
|
829
828
|
|
|
830
|
-
${
|
|
829
|
+
${K}
|
|
831
830
|
`};let Ke=(hs.join(`
|
|
832
831
|
`)+`
|
|
833
|
-
${
|
|
832
|
+
${K}`).trim();yield{type:"interactive_turn_finished",data:{agentText:a,fullAgentTextRaw:Ke,history:[...r],needTitle:y}},yield{type:"status",content:"[end]"}}}catch(d){let r=d?.cause?` (Cause: ${d.cause?.message||String(d.cause)})`:"",M=(d instanceof Error?(()=>{try{return JSON.parse(JSON.parse(d.message).error.message).error.message}catch{return(d.message?`${d.message}${r}`:"")||String(d)}})():String(d)).replace(/^(Error:\s*)+/i,"");i==="Google"&&!/^[A-Z0-9_\-\s]+ ERROR:/i.test(M)&&(M=`GEMINI ERROR: ${M}`);let U=new Date().toLocaleString(),D=ae.join(Cn,"agent");yield{type:"text",content:`
|
|
834
833
|
|
|
835
|
-
\u2726 CRITICAL ERROR: ${
|
|
836
|
-
\u2800`},Ue.existsSync(
|
|
834
|
+
\u2726 CRITICAL ERROR: ${M.includes("fetch failed")?"Failed to Connect. Check your Internet Connection or Wait a moment":M}
|
|
835
|
+
\u2800`},Ue.existsSync(D)||Ue.mkdirSync(D,{recursive:!0}),Ue.appendFileSync(ae.join(D,"error.log"),`CRITICAL ERROR [${U}]: ${d}${d?.cause?`
|
|
837
836
|
CAUSE: ${d.cause?.stack||d.cause}`:""}
|
|
838
837
|
|
|
839
838
|
----------------------------------------------------------------------
|
|
840
839
|
|
|
841
|
-
`),typeof flushGoogleBuffer=="function"&&(yield*flushGoogleBuffer()),yield{type:"tool_result",content:`ERROR: [INTERNAL CRITICAL] ${
|
|
840
|
+
`),typeof flushGoogleBuffer=="function"&&(yield*flushGoogleBuffer()),yield{type:"tool_result",content:`ERROR: [INTERNAL CRITICAL] ${M}`}}finally{R&&(clearInterval(R),R=null),typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),await Do.commitTransaction(),T?.advanceRollback&&await lo.cleanup(p),await Hn()}yield{type:"status",content:null}},yf=async(e,t,n=null,s=null,o=50,c=null,f=!1)=>{let l=await ao(),k={...l,...t},p=process.env.SUBAGENT_MODEL?process.env.SUBAGENT_MODEL.trim():null,g=process.env.SUBAGENT_PROVIDER?process.env.SUBAGENT_PROVIDER.trim():null,T=new Date,m=`${T.getFullYear()}-${T.toLocaleString("en-US",{month:"short"}).toUpperCase()}-${String(T.getDate()).padStart(2,"0")}, ${T.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).replace(":","-")}`,u=(R=>{if(!R)return null;let d=R.toLowerCase();return d==="google"?"Google":d==="deepseek"?"DeepSeek":d==="openrouter"?"OpenRouter":d==="nvidia"?"NVIDIA":d==="mistral"?"Mistral":d==="ollama"?"Ollama":d==="inferx"?"InferX":d==="sensenova"?"SenseNova":d==="poolside"?"Poolside":d==="9router"||d==="9Router"?"9router":d==="aihubmix"||d==="aihub"?"AIHubMix":d==="explabs"||d==="experientiallabs"||d==="experimentallabs"?"ExpLabs":d==="tokenharbor"||d==="token harbor"||d==="token_harbor"||d==="thk"?"TokenHarbor":d==="apinex"||d==="apx"?"APInex":null})(g),b=k?.systemSettings?.CustomSubAgent?k?.systemSettings?.SubAgentModel:null,O=k?.systemSettings?.CustomSubAgent?k?.systemSettings?.SubAgentProvider:null,h=null;if(b==="ENV"?(h=p,p&&u&&(k.aiProvider=u)):b&&b!=="Default"?(h=b,O&&(k.aiProvider=O)):p&&u&&(k.aiProvider=u),k.aiProvider){let R=await Ss(k.aiProvider);R&&(k.apiKey=R)}let A=R=>{if(!R||typeof R!="string")return{allowed:!0};let d=[/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 r of d)if(r.test(R))return{allowed:!1,reason:`Blocked potentially destructive or unsafe command pattern: "${r.source}"`};return{allowed:!0}},$=n||h||t?.modelName||t?.activeModel||l.activeModel,C=process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux",x=`-- ACTIONS (path = relative to CWD, path separator: '/') --
|
|
842
841
|
In chat output the format \`[action:ActionName(arg1="value1")]\` in NEW line
|
|
843
842
|
Rules:
|
|
844
843
|
- JSON escape literal sequences, backslash: \\\\, newLine: \\ n
|
|
@@ -875,31 +874,31 @@ NO EXPLICIT THINKING REQUIRED. FOCUS ON TASK COMPLETION
|
|
|
875
874
|
Main focus: actions and task, not chatting
|
|
876
875
|
On completion, provide a detailed summary in Tables/Markdown Format with file modified info. If any task failed report back in detail
|
|
877
876
|
|
|
878
|
-
Current Time: ${
|
|
879
|
-
=== END SYSTEM PROMPT ===`,
|
|
877
|
+
Current Time: ${m}
|
|
878
|
+
=== END SYSTEM PROMPT ===`,I=[{role:"user",text:`Complete this task: ${e}`}],y=0,a="";for(;y<o;){let R=await _s("subagent",k);if(!R.allowed)throw new Error(R.reason||`Budget Exhausted for Provider (${k?.aiProvider||"Subagent"})`);if(kt){if(t?.taskId&&typeof Vt<"u"){let L=Vt.find(N=>N.id===t.taskId);L&&(L.status="cancelled")}throw c&&c("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}if(t?.taskId&&typeof Vt<"u"){let L=Vt.find(N=>N.id===t.taskId);if(L&&L.status==="cancelled")throw c&&c("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}let d=I.map(L=>({role:L.role==="user"?"user":"model",parts:[{text:L.text}]}));c&&c(`[Subagent Turn ${y+1}]...`);let r=["Fast","Low","Medium","High"],E=process.env.SUBAGENT_THINKING,M=r.includes(E)?E:"Low",D=(await ls(k,$,d,_,M)).text||"",P=qr(qt(D).trim());a=P,c&&c(`[Subagent Response]
|
|
880
879
|
${P}
|
|
881
|
-
`),
|
|
880
|
+
`),I.push({role:"agent",text:P});let le=ko(P);if(le.length===0)break;let fe=le.filter(L=>L.toolName.toLowerCase()==="askmain"||L.toolName.toLowerCase()==="ask_main"),Z=!1,we="";for(let L of le){if(kt){if(t?.taskId&&typeof Vt<"u"){let B=Vt.find(G=>G.id===t.taskId);B&&(B.status="cancelled")}throw new Error("Subagent task was cancelled.")}if(t?.taskId&&typeof Vt<"u"){let B=Vt.find(G=>G.id===t.taskId);if(B&&B.status==="cancelled")throw new Error("Subagent task was cancelled.")}let N=L.toolName.toLowerCase();if(N==="askuser"&&(N="ask"),N==="askmain"||N==="ask_main"){if(Z)continue;Z=!0;let B="";if(fe.length===1?B=oe(fe[0].args).question||fe[0].args:B=fe.map((G,ye)=>{let Re=oe(G.args);return`Q${ye+1}: ${Re.question||G.args}`}).join(`
|
|
882
881
|
`),t.onAskMain){c&&c(`[Executing Tool] AskMain("${B}")...`);let G=await t.onAskMain(B);c&&c(`[Action Result]
|
|
883
882
|
Answer from Main Agent: ${G}
|
|
884
|
-
`),
|
|
883
|
+
`),we+=`[ACTION RESULT for AskMain]: Answer from Main Agent: ${G}
|
|
885
884
|
|
|
886
|
-
`,await
|
|
885
|
+
`,await vt("toolSuccess")}else we+=`[ACTION RESULT for AskMain]: ERROR: Main agent communication channel not available.
|
|
887
886
|
|
|
888
|
-
`;continue}if(!(s?s.some(B=>B.toLowerCase()===
|
|
889
|
-
`),
|
|
887
|
+
`;continue}if(!(s?s.some(B=>B.toLowerCase()===N):!0)){let B=`ERROR: Tool [${L.toolName}] is not in the allowed tools list for this subagent.`;c&&c(`[Blocked Tool Call] ${L.toolName} - not allowed
|
|
888
|
+
`),we+=`${B}
|
|
890
889
|
|
|
891
|
-
`;continue}if(
|
|
892
|
-
`),
|
|
890
|
+
`;continue}if(N==="exec_command"||N==="execcommand"||N==="run"){let B=oe(L.args).command||"",G=A(B);if(!G.allowed){let ye=`ERROR: [SECURITY RESTRICTION] Subagent execution blocked command: ${G.reason}`;c&&c(`[Blocked Command] ${B} - ${G.reason}
|
|
891
|
+
`),we+=`${ye}
|
|
893
892
|
|
|
894
|
-
`;continue}}let
|
|
893
|
+
`;continue}}let ie="";if(N==="web_search"||N==="websearch")ie=`\u2714 \x1B[95mSearched\x1B[0m: ${oe(L.args).query||""}`;else if(N==="web_scrape"||N==="webscrape")ie=`\u2714 \x1B[95mScraped\x1B[0m: ${oe(L.args).url||""}`;else if(N==="search_keyword"||N==="searchkeyword"||N==="codesearch"||N==="code_search"){let B=oe(L.args),G=B.keyword||"",ye=B.path||"";ie=`${G?"\u2714":"\u2718"} \x1B[95mSearched\x1B[0m: ${G||"No Query"}${ye?` \u2192 ${ye.replaceAll("\\","/")}`:""}`}else if(N==="view_file"||N==="viewfile"||N==="readfile")ie=`\u2714 \x1B[95mRead\x1B[0m: ${(oe(L.args).path||"").replaceAll("\\","/")}`;else if(N==="find_file"||N==="findfile"){let B=oe(L.args),G=B.basename||B.name||B.path||B.file||B.query||"";ie=`${G?"\u2714":"\u2718"} \x1B[95mLocated\x1B[0m: ${G||"No Query"}`}else if(N==="list_files"||N==="read_folder"||N==="readfolder"){let B=oe(L.args).path||null,G=oe(L.args).recurse||0;ie=`${B?"\u2714":"\u2718"} \x1B[95mBrowsed\x1B[0m: ${B?`${B.replaceAll("\\","/")}${G>0?`${B.endsWith("/")?`*${G}`:`/*${G}`}`:`${B.endsWith("/")?"":"/"}`}`:""}`}else if(N==="write_file"||N==="writefile"){let B=oe(L.args).path||null;ie=`${B?"\u2714":"\u2718"} \x1B[95mCreated\x1B[0m: ${B?`${B.replaceAll("\\","/")}`:"No File Changes"}`}else if(N==="update_file"||N==="updatefile"||N==="patchfile"||N==="patch_file"){let B=oe(L.args),G=B.path||null,Re=Object.entries(B).some(([Me,Ie])=>Me.startsWith("searchContent")&&typeof Ie=="string"&&Ie.startsWith("^LINE:"))?"\u1361":":";ie=`${G?"\u2714":"\u2718"} \x1B[95mEdited\x1B[0m${Re} ${G?`${G.replaceAll("\\","/")}`:"No File Changes"}`}else if(N==="exec_command"||N==="execcommand"||N==="run"){let B=oe(L.args).command||null;ie=`${B?"\u2714":"\u2718"} \x1B[95mExecuted\x1B[0m: ${B?B.slice(0,100)+(B.length>100?"...":""):"No Command"}`}else if(N==="file_map"||N==="filemap"){let B=oe(L.args).path||"";ie=`${B?"\u2714":"\u2718"} \x1B[95mIndexed\x1B[0m: ${B?`${B.replaceAll("\\","/")}`:"File Not Found"}`}else if(N==="await"){let{time:B}=oe(L.args),G=parseFloat(B)||0;G<10&&(G=10),G>180&&(G=180),ie=`\u2714 \x1B[95mAwaiting\x1B[0m \u2192 ${(Re=>{if(Re>=60){let Me=Math.floor(Re/60),Ie=Re%60;return`${Me}m${Ie>0?` ${Ie}s`:""}`}return`${Re}s`})(G)}`}else{let B=si[N]||L.toolName,G=Kn(N,L.args);ie=`\u2714 \x1B[95m${B}\x1B[0m${G?`: ${G}`:""}`}t.onVisualFeedback&&ie&&t.onVisualFeedback(ie),c&&c(`[Executing Tool] ${L.toolName}(${L.args})...`);try{let B=await xo(L.toolName,L.args,{...t,mode:"Flux"});if(c&&c(`[Action Result]
|
|
895
894
|
${B}
|
|
896
|
-
`),
|
|
895
|
+
`),we+=`[ACTION RESULT for ${L.toolName}]: ${B}
|
|
897
896
|
|
|
898
|
-
`,await
|
|
899
|
-
`),ye=0,Re=0,
|
|
900
|
-
`)){if(Ie.includes("Old File contents:")){
|
|
901
|
-
`),
|
|
897
|
+
`,await vt("toolSuccess"),N==="patchfile"||N==="update_file"||N==="updatefile"||N==="patch_file"){if(B){let G=B.split(`
|
|
898
|
+
`),ye=0,Re=0,Me=!1;for(let Ie of G){if(Ie.includes("[DIFF_START]")){Me=!0;continue}if(Ie.includes("[DIFF_END]")){Me=!1;continue}Me&&(/^\+\d+/.test(Ie)?ye++:/^\-\d+/.test(Ie)&&Re++)}(ye>0||Re>0)&&(await Bt("linesAdded",ye),await Bt("linesRemoved",Re))}}else if((N==="writefile"||N==="write_file")&&B){let G=B.match(/- Stats: \[(\d+) lines/),ye=G?parseInt(G[1]):0,Re=0;if(B.includes("Old File contents:")){let Me=!1;for(let Ie of B.split(`
|
|
899
|
+
`)){if(Ie.includes("Old File contents:")){Me=!0;continue}Me&&(Ie.trim()===""?Me=!1:/^\d+ \|/.test(Ie)&&Re++)}}(ye>0||Re>0)&&(await Bt("linesAdded",ye),await Bt("linesRemoved",Re))}}catch(B){let G=`ERROR: Execution failed for [${L.toolName}]: ${B.message}`;c&&c(`[Tool Error] ${G}
|
|
900
|
+
`),we+=`${G}
|
|
902
901
|
|
|
903
|
-
`,await
|
|
902
|
+
`,await vt("toolFailure")}}let ce="";if(t?.taskId&&typeof Vt<"u"){let L=Vt.find(N=>N.id===t.taskId);if(L&&L.pendingSteerMessages&&L.pendingSteerMessages.length>0){let N=[...L.pendingSteerMessages];L.pendingSteerMessages=[];for(let Ee of N)ce+=`
|
|
904
903
|
|
|
905
|
-
[STEERING INSTRUCTION FROM MAIN AGENT]: ${Ee}`,c&&c(`[Subagent Steered] ${Ee}`)}}let
|
|
904
|
+
[STEERING INSTRUCTION FROM MAIN AGENT]: ${Ee}`,c&&c(`[Subagent Steered] ${Ee}`)}}let rt=(we.trim()+ce).trim();I.push({role:"user",text:rt}),y++}return a};export{bo as a,Dr as b,yc as c,xc as d,He as e,ul as f,gl as g,ac as h,lc as i,kc as j,zo as k,Tc as l,ja as m,cf as n,Ka as o,Va as p,oi as q,qt as r,Gr as s,qr as t,Xa as u,df as v,ff as w,ri as x,uf as y,gf as z,ls as A,hf as B,mf as C,pf as D,yf as E};
|