fluxflow-cli 5.6.3 → 5.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/README.md +1 -0
  2. package/dist/chunks/{ai-RXGVC6CH.js → ai-7IGEWDC4.js} +1 -1
  3. package/dist/chunks/{app-EZITKUKA.js → app-TEFKZ7BF.js} +65 -65
  4. package/dist/chunks/{auto_completion-E7TLLCOT.js → auto_completion-YLQZ35AI.js} +1 -1
  5. package/dist/chunks/{chunk-KTD4WQBO.js → chunk-A3ZRC52P.js} +1 -1
  6. package/dist/chunks/{chunk-QN4UHB5C.js → chunk-AJML3MQG.js} +1 -1
  7. package/dist/chunks/{chunk-ECYXN6JP.js → chunk-CGNNVGKZ.js} +160 -156
  8. package/dist/chunks/{chunk-3WV6FIZV.js → chunk-GRJHGYAU.js} +1 -1
  9. package/dist/chunks/{chunk-KYIMFUZS.js → chunk-I3Q4EEDY.js} +1 -1
  10. package/dist/chunks/chunk-OXM7FOYK.js +1 -0
  11. package/dist/chunks/chunk-RGQWDXID.js +1 -0
  12. package/dist/chunks/{click-AJIULJEH.js → click-J3HGKREV.js} +2 -2
  13. package/dist/chunks/{computer_action-FZUWM6VL.js → computer_action-GJV76M3H.js} +1 -1
  14. package/dist/chunks/{custom_openai-VGJQRWSE.js → custom_openai-XRPZ25BZ.js} +1 -1
  15. package/dist/chunks/{drag-73WZE3BK.js → drag-CXZGQ6VL.js} +1 -1
  16. package/dist/chunks/{generate_image-KIZS5HAI.js → generate_image-RB3HJFO6.js} +1 -1
  17. package/dist/chunks/{invoke-UHU7WYIJ.js → invoke-WXMEB2A5.js} +2 -2
  18. package/dist/chunks/{invokeSync-D5CAEBKJ.js → invokeSync-O3ZJBM6T.js} +2 -2
  19. package/dist/chunks/{key_press-T5VHXHUL.js → key_press-GP35GCNC.js} +1 -1
  20. package/dist/chunks/{keyboard_typing-5L2G5AHU.js → keyboard_typing-37C44KPF.js} +1 -1
  21. package/dist/chunks/numes-TNJXMAPV.js +1 -0
  22. package/dist/chunks/{ollama-X7ARM2CC.js → ollama-6LZL7OKW.js} +1 -1
  23. package/dist/chunks/{recapture_screen-JVNQ2Z7L.js → recapture_screen-MOGI4IMA.js} +1 -1
  24. package/dist/chunks/{screen_grid-PHZTVWOJ.js → screen_grid-SUWYGRSE.js} +1 -1
  25. package/dist/chunks/{scroll-KE5TNGMD.js → scroll-ULY2O6WE.js} +1 -1
  26. package/dist/chunks/{search_keyword-SSKH6AYF.js → search_keyword-D7D7PMSR.js} +1 -1
  27. package/dist/chunks/{secrets-6RUMHIWR.js → secrets-C2QF3PYO.js} +1 -1
  28. package/dist/chunks/{secrets_v2-5NIKKQXX.js → secrets_v2-LTEHILT6.js} +1 -1
  29. package/dist/chunks/{settings-UL5E3OYC.js → settings-MOI6W4VL.js} +1 -1
  30. package/dist/chunks/{update_file-RA745RVH.js → update_file-74CZ4JRC.js} +1 -1
  31. package/dist/chunks/{usage-MKFPGZUK.js → usage-H47IV3LH.js} +1 -1
  32. package/dist/chunks/{usageServer-JFFFEUMY.js → usageServer-7DVP2CP7.js} +8 -3
  33. package/dist/chunks/{write_file-6KFLPINS.js → write_file-G4QVTNSH.js} +1 -1
  34. package/dist/cli.js +3 -3
  35. package/dist/package.json +2 -2
  36. package/package.json +2 -2
  37. package/dist/chunks/chunk-3PZTWZTT.js +0 -1
  38. package/dist/chunks/chunk-MS7BITZ6.js +0 -1
@@ -1,4 +1,4 @@
1
- import{a as er}from"./chunk-UM5SNZ6X.js";import{a as Mo}from"./chunk-NJTM7OYZ.js";import{a as Ht}from"./chunk-56EJGQU3.js";import{a as tr}from"./chunk-4CWGKQHX.js";import{c as Yi,g as Xi,h as qs,i as Ys,j as Xs}from"./chunk-JMMO76HS.js";import{b as Js,c as Qs,d as Ji,f as Zs}from"./chunk-LTNOPF2E.js";import{a as di}from"./chunk-2RTYI6K3.js";import{a as O}from"./chunk-6LM3YRRE.js";import{b as zs}from"./chunk-3WV6FIZV.js";import{y as Vi}from"./chunk-3PZTWZTT.js";import{f as ci,l as $t,o as zi,p as hn,r as qi}from"./chunk-KYIMFUZS.js";import{b as li}from"./chunk-MS7BITZ6.js";import{l as it,m as ai}from"./chunk-Y6O7SAPD.js";import{c as pn,d as Ki,e as ri}from"./chunk-ZGORMZE5.js";import{a as jn,b as oi,c as ii,d as eo,e as js,k as si,l as Hi,m as Ks,r as ji,w as _o,x as Io,y as Vs,z as mn}from"./chunk-NPXJIGAI.js";import{GoogleGenAI as ya,ThinkingLevel as Ye,HarmBlockThreshold as vi,HarmCategory as Ei}from"@google/genai";var fi={xHigh:"Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking",High:"Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking",Medium:"Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking",Minimal:"Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking",Off:"NO thinking. Immediate response. Verify imports, tool results & system stability"};import Jt from"fs";import an from"path";import Ya from"os";import yn from"fs";import En from"path";import mr from"fs";import Qi from"path";import{execSync as pr}from"child_process";import{fileURLToPath as Va}from"url";var nr=`# FluxFlow CLI Startup & Flags Reference
1
+ import{a as er}from"./chunk-UM5SNZ6X.js";import{a as Mo}from"./chunk-NJTM7OYZ.js";import{a as Ht}from"./chunk-56EJGQU3.js";import{a as tr}from"./chunk-4CWGKQHX.js";import{c as Yi,g as Xi,h as qs,i as Ys,j as Xs}from"./chunk-JMMO76HS.js";import{b as Js,c as Qs,d as Ji,f as Zs}from"./chunk-LTNOPF2E.js";import{a as di}from"./chunk-2RTYI6K3.js";import{a as O}from"./chunk-6LM3YRRE.js";import{b as zs}from"./chunk-GRJHGYAU.js";import{y as Vi}from"./chunk-RGQWDXID.js";import{f as ci,l as $t,o as zi,p as hn,r as qi}from"./chunk-I3Q4EEDY.js";import{b as li}from"./chunk-OXM7FOYK.js";import{l as et,m as ai}from"./chunk-Y6O7SAPD.js";import{c as pn,d as Ki,e as ri}from"./chunk-ZGORMZE5.js";import{a as jn,b as oi,c as ii,d as eo,e as js,k as si,l as Hi,m as Ks,r as ji,w as _o,x as Io,y as Vs,z as mn}from"./chunk-NPXJIGAI.js";import{GoogleGenAI as ya,ThinkingLevel as Ye,HarmBlockThreshold as vi,HarmCategory as Ei}from"@google/genai";var fi={xHigh:"Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking",High:"Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking",Medium:"Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking",Minimal:"Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking",Off:"NO thinking. Immediate response. Verify imports, tool results & system stability"};import Jt from"fs";import an from"path";import Ya from"os";import yn from"fs";import En from"path";import mr from"fs";import Qi from"path";import{execSync as pr}from"child_process";import{fileURLToPath as Va}from"url";var nr=`# FluxFlow CLI Startup & Flags Reference
2
2
 
3
3
  Launch command syntax:
4
4
  fluxflow [options]
@@ -350,7 +350,7 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
350
350
  `;var ur=`# FluxFlow AI Providers & Setup
351
351
 
352
352
  ## Supported Providers
353
- * Gemini | NVIDIA NIM | DeepSeek | Mistral | Ollama Local/Cloud | InferX | SenseNova | Poolside | OpenRouter | AIHubMix | Experiential Labs | TokenHarbor | APInex | Infron | Coarena
353
+ * Gemini | NVIDIA NIM | DeepSeek | Mistral | Ollama Local/Cloud | InferX | SenseNova | Poolside | OpenRouter | AIHubMix | Experiential Labs | TokenHarbor | APInex | Infron | Coarena | Numes
354
354
  * Proxy: 9router. Can use OAuth subscription like Codex, Claude Code, GitHub Copilot etc. or any OpenAI/Anthropic API that FluxFlow dont have natively
355
355
  * Custom: Native custom OpenAI chat completions integration, no external package needed \u2192 references/SETTINGS.md, for more details
356
356
 
@@ -370,6 +370,10 @@ Route sub-agent workloads to faster/cheaper models independently of the main age
370
370
  * Sorting: :throughput|latency|price|ttft. /model deepseek-v4.1-flash:price
371
371
  * Combinations (any order): /model azure::deepseek-v4.1-flash:free:fp8:ttft:flex
372
372
 
373
+ ## Numes: Routing & Sorting
374
+ * Provider Routing: /model provider::model
375
+ * Sorting: /model openai/gpt-6-luna:price|throughput|latency|quality
376
+
373
377
  ## Setup Local NVIDIA NIM (OpenAI-Compatible)
374
378
  1. Environment Variables:
375
379
  * NVIDIA_BASE_URL = http://.../v1 or custom openai endpoint
@@ -429,7 +433,7 @@ Instruction for this model ID across all providers.
429
433
 
430
434
  * On-Demand Reference System:
431
435
  * Reference: Offload deep/contexual specs to **/{SKILL.md,skill-reference-folder/*.md} & reference in SKILL.md. Saves tokens
432
- `;var ui="v4";try{let e=Qi.dirname(Va(import.meta.url)),t=[Qi.join(e,"../../package.json"),Qi.join(e,"../package.json")],n=!1;for(let i of t)if(mr.existsSync(i)){let o=JSON.parse(mr.readFileSync(i,"utf8"));if(o.version){ui=o.version,n=!0;break}}if(!n)try{let i=pr("fluxflow -v",{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"],timeout:2e3}).trim();i&&(i.startsWith("v")||/^\d+\.\d+/.test(i))&&(ui=i,n=!0)}catch{}if(!n)try{let i=pr("curl -s --max-time 3 https://raw.githubusercontent.com/KushalRoyChowdhury/fluxflow-cli/main/package.json",{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"]}),o=JSON.parse(i);o.version&&(ui=o.version)}catch{}}catch{}var Zi={"SKILL.md":`---
436
+ `;var ui="v4";try{let e=Qi.dirname(Va(import.meta.url)),t=[Qi.join(e,"../../package.json"),Qi.join(e,"../package.json")],n=!1;for(let s of t)if(mr.existsSync(s)){let o=JSON.parse(mr.readFileSync(s,"utf8"));if(o.version){ui=o.version,n=!0;break}}if(!n)try{let s=pr("fluxflow -v",{encoding:"utf8",windowsHide:!0,stdio:["ignore","pipe","ignore"],timeout:2e3}).trim();s&&(s.startsWith("v")||/^\d+\.\d+/.test(s))&&(ui=s,n=!0)}catch{}if(!n)try{let s=pr("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&&(ui=o.version)}catch{}}catch{}var Zi={"SKILL.md":`---
433
437
  name: fluxflow
434
438
  description: System Generated Documentation. Read this if asked anything regarding FluxFlow Harness, model info
435
439
  ---
@@ -454,46 +458,46 @@ Public Docs: https://fluxflow-cli.onrender.com
454
458
  * Priority Instructions (AGENTS.md/FLUXFLOW.md) & Skill System \u2192 references/PLUGINS.md
455
459
  * Agent Architecture & Memory System \u2192 references/ARCHITECTURE.md
456
460
 
457
- Docs missing required info? Say you are not sure enough to answer. Dont give wrong info`,"references/MODES.md":fr,"references/PROVIDERS.md":ur,"references/PLUGINS.md":gr,"references/STARTUP.md":nr,"references/ENV.md":or,"references/COMMANDS.md":ir,"references/SETTINGS.md":sr,"references/TOOLS.md":rr,"references/ARCHITECTURE.md":ar,"references/SUB_AGENTS.md":lr,"references/SECURITY.md":cr,"references/IDE.md":dr};var hr=(e=null)=>{try{let t=En.join(jn,"skills","fluxflow"),n=En.join(t,"references");if(process.env.NO_DEV==="true"||process.env.NO_DEV==="1"||process.env.NO_DEV===!0||process.env.NO_INS==="true"||process.env.NO_INS==="1"||process.env.NO_INS==="true"||!1){yn.existsSync(t)&&yn.rmSync(t,{recursive:!0,force:!0});return}let o=new Set(Object.keys(Zi).map(m=>En.normalize(m))),d=(e||""||"").replace(/^.*::/,"").split(":")[0].replace(/\/free$/,"").trim(),l=En.basename(d).replace(/-free$/,"").replace(/_free$/,"").replace(/^free_/,"").replace(/(\d)-(\d)/g,"$1.$2").replaceAll("-"," ").replaceAll("_"," ").replace(/\b\w/g,m=>m.toUpperCase().trim());for(let[m,f]of Object.entries(Zi)){let h=En.join(t,m),p=En.dirname(h);yn.existsSync(p)||yn.mkdirSync(p,{recursive:!0});let g=f;m==="SKILL.md"&&l&&(g=g.replace(/Public Docs: [^\n]*/,`Public Docs: ${g.match(/Public Docs: ([^\n]*)/)?.[1]||""}
458
- Active Model: ${l}`));let s=g.trim()+`
459
- `,x=null;yn.existsSync(h)&&(x=yn.readFileSync(h,"utf8")),x!==s&&yn.writeFileSync(h,s,"utf8")}if(yn.existsSync(n)){let m=yn.readdirSync(n);for(let f of m){let h=En.normalize(En.join("references",f));if(!o.has(h)){let p=En.join(n,f);try{yn.rmSync(p,{recursive:!0,force:!0})}catch{}}}}}catch{}};import{WebSocket as gi}from"ws";var Dt=null,po=!1,za="ws://localhost:56832",es=[],ho=null,ts=null,ns=null,yr="2.0.0",Tc=e=>{yr=e,xr()},os=e=>{ts=e},Ac=e=>{ns=e},xr=()=>{if(Dt||po)return;po=!0;let e=new gi(za);e.on("open",()=>{for(Dt=e,po=!1,Dt.send(JSON.stringify({command:"version",version:yr,pid:process.pid,ppid:process.ppid,cwd:process.cwd()}));es.length>0;)Dt.send(JSON.stringify(es.shift()))}),e.on("message",t=>{try{let n=JSON.parse(t.toString());n.command==="contextResponse"&&ho?(ho(n.data),ho=null):n.command==="securityResponse"&&ts?ts(n.result):n.command==="inlineComplete"?qa(n):n.command==="connectionRejected"&&ns&&ns(n)}catch{}}),e.on("error",()=>{po=!1,Dt=null}),e.on("close",()=>{po=!1,Dt=null})},Po=e=>{Dt&&Dt.readyState===gi.OPEN?Dt.send(JSON.stringify(e)):(es.push(e),po||xr())},yo=()=>Dt!==null&&Dt.readyState===gi.OPEN,qa=async e=>{let t="";try{let{generateAutoCompletion:n}=await import("./auto_completion-E7TLLCOT.js");t=await n({prefix:e.prefix||"",suffix:e.suffix||"",fileName:e.fileName||"",language:e.language||"",recentChanges:e.recentChanges||"",clipboard:e.clipboard||""})}catch{t=""}Po({command:"inlineCompleteResponse",requestId:e.requestId,completion:t||""})},Cc=e=>{Po({command:"status",status:e})},to=()=>new Promise(e=>{if(!Dt||Dt.readyState!==gi.OPEN){e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]});return}ho=e,Dt.send(JSON.stringify({command:"requestContext"})),setTimeout(()=>{ho===e&&(e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]}),ho=null)},1e3)}),wr=e=>{let{resolvedPath:t}=mn(e);Po({command:"open",filePath:t})},is=(e,t,n)=>{let{resolvedPath:i}=mn(e);Po({command:"showDiff",filePath:i,originalContent:t,modifiedContent:n})},br=(e,t)=>{let{resolvedPath:n}=mn(e);Po({command:"closeDiff",filePath:n,result:t})};var Bo=(e,t)=>{try{if(!Jt.existsSync(e))return null;let n=Array.isArray(t)?t.map(o=>o.toLowerCase()):[t.toLowerCase()],i=Jt.readdirSync(e);for(let o of n){let r=i.find(d=>d.toLowerCase()===o);if(r){let d=an.join(e,r);if(Jt.statSync(d).isFile())return d}}}catch{}return null},cs=(e,t)=>{let n=Bo(e,t);if(n)try{return Jt.readFileSync(n,"utf8")}catch{}return""},Sr=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"]),ds=(e=process.cwd(),t=0,n=8)=>{let i=[];if(t>n)return i;try{if(!Jt.existsSync(e))return i;let o=Jt.readdirSync(e,{withFileTypes:!0});for(let r of o){let d=r.name,l=an.join(e,d);if(r.isDirectory())!Sr.has(d)&&!Sr.has(d.toLowerCase())&&i.push(...ds(l,t+1,n));else if(r.isFile()){let m=d.toLowerCase();(m==="agents.md"||m==="agent.md")&&i.push(l)}}}catch{}return i},kr=(e,t=2)=>{if(!e)return"";let n=" ".repeat(t);return e.split(/\r?\n/).map(i=>n+i).join(`
460
- `)},vr=()=>Bo(jn,["agents.md","agent.md"]),Er=()=>Bo(process.cwd(),["agents.md","agent.md"]),_r=()=>Bo(jn,["fluxflow.md"]),Ir=()=>Bo(process.cwd(),["fluxflow.md"]),Lo=vr(),mi=Er(),xn=ds(),Oo=_r(),No=Ir(),Tr=null,ls="",Mr=!1,Xa=e=>{if(!e||!/^<<<[\s\S]*?Identity:/m.test(e))return e;let t=e.match(/^<<<\s*\r?\n([\s\S]*?)\r?\n>>>\s*(?:\r?\n)?([\s\S]*)$/);if(!t)return e;let n=t[1],i=t[2],o=n.match(/^Identity:\s*([\s\S]*?)(?=\r?\n\s*(?:<><|>>>)|$)/m);return o&&(ls=o[1].trim(),process.env.NO_INS=!0),/<><\s*NO_INS/.test(n)&&(Mr=!0),i.trim()},Ja=()=>{Lo=vr();let e=Lo?cs(jn,["agents.md","agent.md"]).trim():"";return e.length===0?(Lo=null,""):e},Qa=()=>{if(xn=ds(),mi=Er(),!xn||xn.length===0)return"";let e=process.cwd(),t=[...xn].sort((o,r)=>{let d=an.relative(e,o).replace(/\\/g,"/"),l=an.relative(e,r).replace(/\\/g,"/"),m=!d.includes("/"),f=!l.includes("/");return m&&!f?-1:!m&&f?1:d.localeCompare(l)}),n=[],i=[];for(let o of t)try{let r=Jt.readFileSync(o,"utf8").trim();if(!r||r.length===0)continue;n.push(o);let d=an.relative(e,o).replace(/\\/g,"/");if(!d.includes("/"))i.push(kr(r,2));else{let m=an.dirname(d)+"/:";i.push(`${m}
461
- ${kr(r,2)}`)}}catch{}return xn=n,xn.length===0&&(mi=null),i.join(`
461
+ Docs missing required info? Say you are not sure enough to answer. Dont give wrong info`,"references/MODES.md":fr,"references/PROVIDERS.md":ur,"references/PLUGINS.md":gr,"references/STARTUP.md":nr,"references/ENV.md":or,"references/COMMANDS.md":ir,"references/SETTINGS.md":sr,"references/TOOLS.md":rr,"references/ARCHITECTURE.md":ar,"references/SUB_AGENTS.md":lr,"references/SECURITY.md":cr,"references/IDE.md":dr};var hr=(e=null)=>{try{let t=En.join(jn,"skills","fluxflow"),n=En.join(t,"references");if(process.env.NO_DEV==="true"||process.env.NO_DEV==="1"||process.env.NO_DEV===!0||process.env.NO_INS==="true"||process.env.NO_INS==="1"||process.env.NO_INS==="true"||!1){yn.existsSync(t)&&yn.rmSync(t,{recursive:!0,force:!0});return}let o=new Set(Object.keys(Zi).map(m=>En.normalize(m))),d=(e||""||"").replace(/^.*::/,"").split(":")[0].replace(/\/free$/,"").trim(),a=En.basename(d).replace(/-free$/,"").replace(/_free$/,"").replace(/^free_/,"").replace(/(\d)-(\d)/g,"$1.$2").replaceAll("-"," ").replaceAll("_"," ").replace(/\b\w/g,m=>m.toUpperCase().trim());for(let[m,f]of Object.entries(Zi)){let h=En.join(t,m),p=En.dirname(h);yn.existsSync(p)||yn.mkdirSync(p,{recursive:!0});let g=f;m==="SKILL.md"&&a&&(g=g.replace(/Public Docs: [^\n]*/,`Public Docs: ${g.match(/Public Docs: ([^\n]*)/)?.[1]||""}
462
+ Active Model: ${a}`));let i=g.trim()+`
463
+ `,x=null;yn.existsSync(h)&&(x=yn.readFileSync(h,"utf8")),x!==i&&yn.writeFileSync(h,i,"utf8")}if(yn.existsSync(n)){let m=yn.readdirSync(n);for(let f of m){let h=En.normalize(En.join("references",f));if(!o.has(h)){let p=En.join(n,f);try{yn.rmSync(p,{recursive:!0,force:!0})}catch{}}}}}catch{}};import{WebSocket as gi}from"ws";var Dt=null,po=!1,za="ws://localhost:56832",es=[],ho=null,ts=null,ns=null,yr="2.0.0",Tc=e=>{yr=e,xr()},os=e=>{ts=e},Ac=e=>{ns=e},xr=()=>{if(Dt||po)return;po=!0;let e=new gi(za);e.on("open",()=>{for(Dt=e,po=!1,Dt.send(JSON.stringify({command:"version",version:yr,pid:process.pid,ppid:process.ppid,cwd:process.cwd()}));es.length>0;)Dt.send(JSON.stringify(es.shift()))}),e.on("message",t=>{try{let n=JSON.parse(t.toString());n.command==="contextResponse"&&ho?(ho(n.data),ho=null):n.command==="securityResponse"&&ts?ts(n.result):n.command==="inlineComplete"?qa(n):n.command==="connectionRejected"&&ns&&ns(n)}catch{}}),e.on("error",()=>{po=!1,Dt=null}),e.on("close",()=>{po=!1,Dt=null})},Po=e=>{Dt&&Dt.readyState===gi.OPEN?Dt.send(JSON.stringify(e)):(es.push(e),po||xr())},yo=()=>Dt!==null&&Dt.readyState===gi.OPEN,qa=async e=>{let t="";try{let{generateAutoCompletion:n}=await import("./auto_completion-YLQZ35AI.js");t=await n({prefix:e.prefix||"",suffix:e.suffix||"",fileName:e.fileName||"",language:e.language||"",recentChanges:e.recentChanges||"",clipboard:e.clipboard||""})}catch{t=""}Po({command:"inlineCompleteResponse",requestId:e.requestId,completion:t||""})},Cc=e=>{Po({command:"status",status:e})},to=()=>new Promise(e=>{if(!Dt||Dt.readyState!==gi.OPEN){e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]});return}ho=e,Dt.send(JSON.stringify({command:"requestContext"})),setTimeout(()=>{ho===e&&(e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]}),ho=null)},1e3)}),wr=e=>{let{resolvedPath:t}=mn(e);Po({command:"open",filePath:t})},is=(e,t,n)=>{let{resolvedPath:s}=mn(e);Po({command:"showDiff",filePath:s,originalContent:t,modifiedContent:n})},br=(e,t)=>{let{resolvedPath:n}=mn(e);Po({command:"closeDiff",filePath:n,result:t})};var Bo=(e,t)=>{try{if(!Jt.existsSync(e))return null;let n=Array.isArray(t)?t.map(o=>o.toLowerCase()):[t.toLowerCase()],s=Jt.readdirSync(e);for(let o of n){let r=s.find(d=>d.toLowerCase()===o);if(r){let d=an.join(e,r);if(Jt.statSync(d).isFile())return d}}}catch{}return null},cs=(e,t)=>{let n=Bo(e,t);if(n)try{return Jt.readFileSync(n,"utf8")}catch{}return""},Sr=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"]),ds=(e=process.cwd(),t=0,n=8)=>{let s=[];if(t>n)return s;try{if(!Jt.existsSync(e))return s;let o=Jt.readdirSync(e,{withFileTypes:!0});for(let r of o){let d=r.name,a=an.join(e,d);if(r.isDirectory())!Sr.has(d)&&!Sr.has(d.toLowerCase())&&s.push(...ds(a,t+1,n));else if(r.isFile()){let m=d.toLowerCase();(m==="agents.md"||m==="agent.md")&&s.push(a)}}}catch{}return s},kr=(e,t=2)=>{if(!e)return"";let n=" ".repeat(t);return e.split(/\r?\n/).map(s=>n+s).join(`
464
+ `)},vr=()=>Bo(jn,["agents.md","agent.md"]),Er=()=>Bo(process.cwd(),["agents.md","agent.md"]),_r=()=>Bo(jn,["fluxflow.md"]),Ir=()=>Bo(process.cwd(),["fluxflow.md"]),Lo=vr(),mi=Er(),xn=ds(),Oo=_r(),No=Ir(),Tr=null,ls="",Mr=!1,Xa=e=>{if(!e||!/^<<<[\s\S]*?Identity:/m.test(e))return e;let t=e.match(/^<<<\s*\r?\n([\s\S]*?)\r?\n>>>\s*(?:\r?\n)?([\s\S]*)$/);if(!t)return e;let n=t[1],s=t[2],o=n.match(/^Identity:\s*([\s\S]*?)(?=\r?\n\s*(?:<><|>>>)|$)/m);return o&&(ls=o[1].trim(),process.env.NO_INS=!0),/<><\s*NO_INS/.test(n)&&(Mr=!0),s.trim()},Ja=()=>{Lo=vr();let e=Lo?cs(jn,["agents.md","agent.md"]).trim():"";return e.length===0?(Lo=null,""):e},Qa=()=>{if(xn=ds(),mi=Er(),!xn||xn.length===0)return"";let e=process.cwd(),t=[...xn].sort((o,r)=>{let d=an.relative(e,o).replace(/\\/g,"/"),a=an.relative(e,r).replace(/\\/g,"/"),m=!d.includes("/"),f=!a.includes("/");return m&&!f?-1:!m&&f?1:d.localeCompare(a)}),n=[],s=[];for(let o of t)try{let r=Jt.readFileSync(o,"utf8").trim();if(!r||r.length===0)continue;n.push(o);let d=an.relative(e,o).replace(/\\/g,"/");if(!d.includes("/"))s.push(kr(r,2));else{let m=an.dirname(d)+"/:";s.push(`${m}
465
+ ${kr(r,2)}`)}}catch{}return xn=n,xn.length===0&&(mi=null),s.join(`
462
466
 
463
- `).trim()},fs=()=>{Oo=_r();let e=Oo?cs(jn,["fluxflow.md"]).trim():"",t=Xa(e)?.trim()||"";return t.length===0?(Oo=null,""):t},us=()=>{No=Ir();let e=No?cs(process.cwd(),["fluxflow.md"]).trim():"";return e.length===0?(No=null,""):e},gs=Ja(),pi=Qa(),Do=fs(),Fo=us(),Ar=(e,t="",n="")=>{if(!e)return"";let i=n.toLowerCase().trim(),o=t.toLowerCase().trim(),r=an.posix.basename(o),d=i&&o?`${i}@${o}`:"",l=i&&r?`${i}@${r}`:"",m=h=>!h||!o?!1:h===o||h===r||h===d||h===l,f=[];return e.replace(/<start_provider_([^>\r\n]+)>([\s\S]*?)<end_provider_([^>\r\n]+)>/gi,(h,p,g,s)=>{if(i&&p.trim().toLowerCase()===s.trim().toLowerCase()&&p.trim().toLowerCase()===i){let I=g.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(Xe,C,P,F)=>{if(C.trim().toLowerCase()===F.trim().toLowerCase()){let G=C.trim().toLowerCase();if(m(G)){let $=P.trim();$&&f.push($)}}return""}).trim();I&&f.push(I)}return""}),e.replace(/<start_model_([^>\r\n@]+@[^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n@]+@[^>\r\n]+)>/gi,(h,p,g,s)=>{if(p.trim().toLowerCase()===s.trim().toLowerCase()){let x=p.trim().toLowerCase();if(m(x)){let I=g.trim();I&&f.push(I)}}return""}),e.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(h,p,g,s)=>{if(p.includes("@"))return"";if(p.trim().toLowerCase()===s.trim().toLowerCase()){let x=p.trim().toLowerCase();if(o&&(x===o||x===r)){let I=g.trim();I&&f.push(I)}}return""}),f.join(`
467
+ `).trim()},fs=()=>{Oo=_r();let e=Oo?cs(jn,["fluxflow.md"]).trim():"",t=Xa(e)?.trim()||"";return t.length===0?(Oo=null,""):t},us=()=>{No=Ir();let e=No?cs(process.cwd(),["fluxflow.md"]).trim():"";return e.length===0?(No=null,""):e},gs=Ja(),pi=Qa(),Do=fs(),Fo=us(),Ar=(e,t="",n="")=>{if(!e)return"";let s=n.toLowerCase().trim(),o=t.toLowerCase().trim(),r=an.posix.basename(o),d=s&&o?`${s}@${o}`:"",a=s&&r?`${s}@${r}`:"",m=h=>!h||!o?!1:h===o||h===r||h===d||h===a,f=[];return e.replace(/<start_provider_([^>\r\n]+)>([\s\S]*?)<end_provider_([^>\r\n]+)>/gi,(h,p,g,i)=>{if(s&&p.trim().toLowerCase()===i.trim().toLowerCase()&&p.trim().toLowerCase()===s){let I=g.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(Xe,C,M,F)=>{if(C.trim().toLowerCase()===F.trim().toLowerCase()){let G=C.trim().toLowerCase();if(m(G)){let $=M.trim();$&&f.push($)}}return""}).trim();I&&f.push(I)}return""}),e.replace(/<start_model_([^>\r\n@]+@[^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n@]+@[^>\r\n]+)>/gi,(h,p,g,i)=>{if(p.trim().toLowerCase()===i.trim().toLowerCase()){let x=p.trim().toLowerCase();if(m(x)){let I=g.trim();I&&f.push(I)}}return""}),e.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(h,p,g,i)=>{if(p.includes("@"))return"";if(p.trim().toLowerCase()===i.trim().toLowerCase()){let x=p.trim().toLowerCase();if(o&&(x===o||x===r)){let I=g.trim();I&&f.push(I)}}return""}),f.join(`
464
468
 
465
- `).trim()},Za=(e="",t="")=>{let n=`${e||""}@${t||""}`.toLowerCase().trim();Tr!==n&&(Tr=n,Do=fs(),Fo=us())};hr();var el=e=>{if(!e)return null;let t=e.match(/^\s*---\r?\n([\s\S]*?)\r?\n---(?:\r?\n)?([\s\S]*)$/);if(!t)return null;let n=t[1];if((t[2]||"").trim().length===0)return null;let o="",r="",d=n.match(/^name:\s*(.+)$/m),l=n.match(/^description:\s*(.+)$/m);return d&&(o=d[1].trim().replace(/^["']|["']$/g,"")),l&&(r=l[1].trim().replace(/^["']|["']$/g,"")),o&&r?{name:o,description:r}:null},tl=e=>{let t=[];if(!e||!Jt.existsSync(e))return t;let n=(i,o=0)=>{if(!(o>5))try{let r=Jt.readdirSync(i,{withFileTypes:!0});for(let d of r){let l=an.join(i,d.name),m=d.name.toLowerCase();d.isFile()?m==="skill.md"&&t.push(l):d.isDirectory()&&(o===0?(m==="skills"||m===".skills"||m==="skill"||m===".skill")&&n(l,o+1):n(l,o+1))}}catch{}};return n(e,0),t},Pr=e=>{let t=tl(e),n=[];for(let i of t)try{let o=Jt.readFileSync(i,"utf8"),r=el(o);r&&n.push({...r,filePath:i})}catch{}return n},$r=e=>!e||e.length===0?"":e.map(t=>`- ${t.name}: ${t.description}`).join(`
466
- `),hi=Pr(jn),yi=Pr(process.cwd()),ss=$r(hi),rs=$r(yi),Lr=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"},Or=()=>(hi||[]).filter(e=>!Lr(e)),Nr=()=>(yi||[]).filter(e=>!Lr(e)),Wc=(gs?.length>0?1:0)+(pi?.length>0?xn.length:0)+(Do?.length>0?1:0)+(Fo?.length>0?1:0)+Or().length+Nr().length,as=(e,t="Project")=>{if(!e)return"";let n=e.replace(/\\/g,"/");if(t==="Global"){let o=Ya.homedir().replace(/\\/g,"/");return n.toLowerCase().startsWith(o.toLowerCase())?"~"+n.slice(o.length):n}let i=an.relative(process.cwd(),e).replace(/\\/g,"/");return i.startsWith(".")?i:`./${i}`},Gc=()=>{Do=fs(),Fo=us();let e=[];Lo&&gs.length>0&&e.push({scope:"Global",path:Lo}),xn&&xn.length>0&&pi.length>0?xn.forEach(r=>{e.push({scope:"Project",path:r})}):mi&&pi.length>0&&e.push({scope:"Project",path:mi}),Oo&&Do.length>0&&e.push({scope:"Global",path:Oo}),No&&Fo.length>0&&e.push({scope:"Project",path:No});let t=Or(),n=Nr(),i=e.length+t.length+n.length;if(i===0)return`\u2726 Loaded Files & Instructions
469
+ `).trim()},Za=(e="",t="")=>{let n=`${e||""}@${t||""}`.toLowerCase().trim();Tr!==n&&(Tr=n,Do=fs(),Fo=us())};hr();var el=e=>{if(!e)return null;let t=e.match(/^\s*---\r?\n([\s\S]*?)\r?\n---(?:\r?\n)?([\s\S]*)$/);if(!t)return null;let n=t[1];if((t[2]||"").trim().length===0)return null;let o="",r="",d=n.match(/^name:\s*(.+)$/m),a=n.match(/^description:\s*(.+)$/m);return d&&(o=d[1].trim().replace(/^["']|["']$/g,"")),a&&(r=a[1].trim().replace(/^["']|["']$/g,"")),o&&r?{name:o,description:r}:null},tl=e=>{let t=[];if(!e||!Jt.existsSync(e))return t;let n=(s,o=0)=>{if(!(o>5))try{let r=Jt.readdirSync(s,{withFileTypes:!0});for(let d of r){let a=an.join(s,d.name),m=d.name.toLowerCase();d.isFile()?m==="skill.md"&&t.push(a):d.isDirectory()&&(o===0?(m==="skills"||m===".skills"||m==="skill"||m===".skill")&&n(a,o+1):n(a,o+1))}}catch{}};return n(e,0),t},Pr=e=>{let t=tl(e),n=[];for(let s of t)try{let o=Jt.readFileSync(s,"utf8"),r=el(o);r&&n.push({...r,filePath:s})}catch{}return n},$r=e=>!e||e.length===0?"":e.map(t=>`- ${t.name}: ${t.description}`).join(`
470
+ `),hi=Pr(jn),yi=Pr(process.cwd()),ss=$r(hi),rs=$r(yi),Lr=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"},Or=()=>(hi||[]).filter(e=>!Lr(e)),Nr=()=>(yi||[]).filter(e=>!Lr(e)),Wc=(gs?.length>0?1:0)+(pi?.length>0?xn.length:0)+(Do?.length>0?1:0)+(Fo?.length>0?1:0)+Or().length+Nr().length,as=(e,t="Project")=>{if(!e)return"";let n=e.replace(/\\/g,"/");if(t==="Global"){let o=Ya.homedir().replace(/\\/g,"/");return n.toLowerCase().startsWith(o.toLowerCase())?"~"+n.slice(o.length):n}let s=an.relative(process.cwd(),e).replace(/\\/g,"/");return s.startsWith(".")?s:`./${s}`},Gc=()=>{Do=fs(),Fo=us();let e=[];Lo&&gs.length>0&&e.push({scope:"Global",path:Lo}),xn&&xn.length>0&&pi.length>0?xn.forEach(r=>{e.push({scope:"Project",path:r})}):mi&&pi.length>0&&e.push({scope:"Project",path:mi}),Oo&&Do.length>0&&e.push({scope:"Global",path:Oo}),No&&Fo.length>0&&e.push({scope:"Project",path:No});let t=Or(),n=Nr(),s=e.length+t.length+n.length;if(s===0)return`\u2726 Loaded Files & Instructions
467
471
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No instruction or skill files are currently loaded.
468
- \u2800`;let o=[];return o.push(`\u2726 Loaded Files & Instructions (${i} ${i===1?"file":"files"} active)`),e.length>0&&(o.push(`
472
+ \u2800`;let o=[];return o.push(`\u2726 Loaded Files & Instructions (${s} ${s===1?"file":"files"} active)`),e.length>0&&(o.push(`
469
473
  \x1B[1mInstructions:\x1B[22m`),e.forEach(r=>{o.push(` \u2022 [${r.scope}] ${as(r.path,r.scope)}`)})),(t?.length>0||n?.length>0)&&(o.push(`
470
474
  \x1B[1mSkills:\x1B[22m`),t?.length>0&&t.forEach(r=>{o.push(` \u2022 [Global] \x1B[36m${r.name}\x1B[39m`),o.push(` \x1B[2m\u2514\u2500 ${as(r.filePath,"Global")}\x1B[22m`)}),n?.length>0&&n.forEach(r=>{o.push(` \u2022 [Project] \x1B[36m${r.name}\x1B[39m`),o.push(` \x1B[2m\u2514\u2500 ${as(r.filePath,"Project")}\x1B[22m`)})),o.push("\u2800"),o.join(`
471
- `)},Dr=!1;(async()=>{try{let e=await li();if(Number(e?.display)===1){let{default:t}=await import("screenshot-desktop"),n=await t.listDisplays();n&&n.length>1&&(Dr=!0)}}catch{}})();var Cr=null,$o=null,Rr=process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux",Hc=process.env.NO_DEV||!1,nl=(e,t)=>{if(!t)return"";if(e!==Cr||$o===null){Cr=e;try{let n=pn(si,[]);Array.isArray(n)&&n.length>0?$o=n.map(i=>`- ${i.memory}`).join(`
475
+ `)},Dr=!1;(async()=>{try{let e=await li();if(Number(e?.display)===1){let{default:t}=await import("screenshot-desktop"),n=await t.listDisplays();n&&n.length>1&&(Dr=!0)}}catch{}})();var Cr=null,$o=null,Rr=process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux",Hc=process.env.NO_DEV||!1,nl=(e,t)=>{if(!t)return"";if(e!==Cr||$o===null){Cr=e;try{let n=pn(si,[]);Array.isArray(n)&&n.length>0?$o=n.map(s=>`- ${s.memory}`).join(`
472
476
  `):$o=""}catch(n){$o="";try{Jt.mkdirSync(an.join(eo,"memory"),{recursive:!0}),Jt.appendFileSync(an.join(eo,"memory","error.txt"),`${n.message}
473
477
  -------------------------------------------------
474
478
 
475
- `)}catch{}}}return $o};var Fr=(e,t,n,i,o=!0,r=!1,d="Google",l=!1,m,f,h=!1,p="")=>{let g=!1;process.env.forcedReasoning&&(g=!0);let s="";if(!m&&d==="Google"){let De=t;t==="Fast"&&(De="Off"),t==="Low"&&(De="Minimal"),t==="Standard"&&(De="Medium"),(t==="xHigh"||t==="Max")&&(De="xHigh"),s=fi[De]||fi.Medium}(m||d!=="Google")&&(s=fi.xHigh,t==="Fast"?s=`No thinking. Immediate response
476
- Verify imports, tool results & system stability`:t.toLowerCase()==="max"&&(s=null));let x=e.instructions&&e.instructions?.length>0?`User Preferences: ${e.instructions}
479
+ `)}catch{}}}return $o};var Fr=(e,t,n,s,o=!0,r=!1,d="Google",a=!1,m,f,h=!1,p="")=>{let g=!1;process.env.forcedReasoning&&(g=!0);let i="";if(!m&&d==="Google"){let Fe=t;t==="Fast"&&(Fe="Off"),t==="Low"&&(Fe="Minimal"),t==="Standard"&&(Fe="Medium"),(t==="xHigh"||t==="Max")&&(Fe="xHigh"),i=fi[Fe]||fi.Medium}(m||d!=="Google")&&(i=fi.xHigh,t==="Fast"?i=`No thinking. Immediate response
480
+ Verify imports, tool results & system stability`:t.toLowerCase()==="max"&&(i=null));let x=e.instructions&&e.instructions?.length>0?`User Preferences: ${e.instructions}
477
481
 
478
482
  `:"",I=e.nickname&&e.nickname?.length>0?`User Nickname: ${e.nickname}
479
483
  ${x.length?"":`
480
484
  `}`:"",Xe=e.name&&e.name?.length>0?`User Name: ${e.name}
481
485
  ${I.length||x.length?"":`
482
- `}`:"",C=process.cwd(),P=e.preset,G={Sassy:"Sassy",Friendly:"Sassy, Warm & Chatty",Playful:"Playful",Efficient:"Quick, Concise & Efficient",Professional:"Professional"}[P]||null,$=nl(f,o),L=$?.length>0?`--- Saved Memories ---
486
+ `}`:"",C=process.cwd(),M=e.preset,G={Sassy:"Sassy",Friendly:"Sassy, Warm & Chatty",Playful:"Playful",Efficient:"Quick, Concise & Efficient",Professional:"Professional"}[M]||null,$=nl(f,o),L=$?.length>0?`--- Saved Memories ---
483
487
  ${$}
484
488
 
485
- `:"";Za(d,p);let Te=Ar(Do,p,d).trim(),Ne=[gs,Te].filter(De=>De&&De.length>0).join(`
489
+ `:"";Za(d,p);let Te=Ar(Do,p,d).trim(),De=[gs,Te].filter(Fe=>Fe&&Fe.length>0).join(`
486
490
 
487
- `).trim(),et=Ar(Fo,p,d).trim(),w=[pi,et].filter(De=>De&&De.length>0).join(`
491
+ `).trim(),tt=Ar(Fo,p,d).trim(),w=[pi,tt].filter(Fe=>Fe&&Fe.length>0).join(`
488
492
 
489
- `).trim(),wn=Ne.length>0||w.length>0?`--- Additional Instructions ---
490
- ${Ne.length>0?`-- Global --
491
- ${Ne}`:""}${w.length>0?`${Ne.length>0?`
493
+ `).trim(),wn=De.length>0||w.length>0?`--- Additional Instructions ---
494
+ ${De.length>0?`-- Global --
495
+ ${De}`:""}${w.length>0?`${De.length>0?`
492
496
 
493
497
  `:""}-- Project --
494
498
  ${w}`:""}
495
499
 
496
- `:"",he=(()=>{let De=process.cwd().toLowerCase();if(process.platform==="win32"){let wt=process.env.SystemRoot?.toLowerCase()||"c:\\windows",Ft=process.env.ProgramFiles?.toLowerCase()||"c:\\program files",Sn=process.env["ProgramFiles(x86)"]?.toLowerCase()||"c:\\program files (x86)";return De.startsWith(wt)||De.startsWith(Ft)||De.startsWith(Sn)}else return De==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(Ft=>De.startsWith(Ft))})(),Kt=new Date,Qt=Kt.getFullYear(),Me=Kt.toLocaleString("en-US",{month:"short"}).toUpperCase(),Z=String(Kt.getDate()).padStart(2,"0"),Ve=`${Qt} ${Me} ${Z}`,ln=process.env.I_HAVE_TOO_MUCH_MONEY==="true"||!1,In=process.env.HALLOWEEN_EEGG==="true"||!1,io=In&&Me.includes("OCT")&&(Z.includes("30")||Z.includes("31")),bn=!1;try{bn=yo()}catch{bn=!1}return`${ln?`${" ".repeat(Math.floor(Math.random()*4)+1)}`:""}=== SYSTEM PROMPT${process.cwd()==="D:\\PROJECTS\\Flux-Flow"?" (Internal testing environment, do as prompted)":""} ===
500
+ `:"",he=(()=>{let Fe=process.cwd().toLowerCase();if(process.platform==="win32"){let wt=process.env.SystemRoot?.toLowerCase()||"c:\\windows",Ft=process.env.ProgramFiles?.toLowerCase()||"c:\\program files",Sn=process.env["ProgramFiles(x86)"]?.toLowerCase()||"c:\\program files (x86)";return Fe.startsWith(wt)||Fe.startsWith(Ft)||Fe.startsWith(Sn)}else return Fe==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(Ft=>Fe.startsWith(Ft))})(),Kt=new Date,Qt=Kt.getFullYear(),Pe=Kt.toLocaleString("en-US",{month:"short"}).toUpperCase(),X=String(Kt.getDate()).padStart(2,"0"),Ve=`${Qt} ${Pe} ${X}`,ln=process.env.I_HAVE_TOO_MUCH_MONEY==="true"||!1,In=process.env.HALLOWEEN_EEGG==="true"||!1,io=In&&Pe.includes("OCT")&&(X.includes("30")||X.includes("31")),bn=!1;try{bn=yo()}catch{bn=!1}return`${ln?`${" ".repeat(Math.floor(Math.random()*4)+1)}`:""}=== SYSTEM PROMPT${process.cwd()==="D:\\PROJECTS\\Flux-Flow"?" (Internal testing environment, do as prompted)":""} ===
497
501
  ${`Identity: ${ls.length>1?ls.trim():`FluxFlow.${G?` ${G}`:""} CLI Assistant${In?`. ${io?"Peak ":""}Halloween Themed, Spooky`:""}`}
498
502
  ${Mr?"":`${n==="Flux"?"":n==="Flow"?"Concise, Humorous, Sarcastic":n==="ICU"?"Computer Use Capabilities. Screenshot as ground truth, analyze grid ids of target. Keyboard shortcuts > mouse clicks":"Computer Use & Workspace Capabilities. Screenshot as ground truth, analyze grid ids of target. Keyboard shortcuts > mouse clicks. Workspace Actions when faster. Focus on Productivity"}`}${Dr&&n.toLowerCase().includes("cu")?`
499
503
  - Running on secondary screen. Opened app not visible in screenshot? Might be opened on primary. Use 'AskUser' with NO options and tell user to move app window to secondary`:""}`.trimEnd()}
@@ -502,15 +506,15 @@ ${Mr?"":`${n==="Flux"?"":n==="Flow"?"Concise, Humorous, Sarcastic":n==="ICU"?"Co
502
506
  - Date: ${Ve}
503
507
  ${t.toLowerCase()!=="max"&&process.env.rawReasoning!=="true"?`
504
508
  -- REASONING GUIDANCE --
505
- ${d==="Mistral"||d==="Google"&&!m||g?`${s.trimEnd()}
509
+ ${d==="Mistral"||d==="Google"&&!m||g?`${i.trimEnd()}
506
510
  ${g||t!=="Fast"&&(d==="Mistral"&&t==="Low"&&!m||t!=="High"&&!m)?`Critical Thinking Policy
507
511
  Use <think_fluxflow>...</think_fluxflow> for reasoning before responding any queries`:""}
508
- `:`${s.trimEnd()}`}
512
+ `:`${i.trimEnd()}`}
509
513
  `:""}${h?"":`${t.toLowerCase()==="max"||process.env.rawReasoning==="true"?`
510
514
  -- REASONING GUIDANCE --
511
515
  `:""}Before actions, provide user facing summary of findings & decisions IN detail
512
516
  `}
513
- ${Zs(n,Rr,l,d,i?.advanceRollback,i?.subAgents!==!1,!!i?.autoExec,!!i?.disableTodo,i?.preferBash!==!1)}${n==="Flux"?"":n.toLowerCase().includes("cu")?`
517
+ ${Zs(n,Rr,a,d,s?.advanceRollback,s?.subAgents!==!1,!!s?.autoExec,!!s?.disableTodo,s?.preferBash!==!1)}${n==="Flux"?"":n.toLowerCase().includes("cu")?`
514
518
 
515
519
  -- SECURITY POLICIES --
516
520
  - Dont operate on ANY confidential/logins/captcha screens \u2192 Tell user to complete it`:""}${bn?`
@@ -526,36 +530,36 @@ ${ss}
526
530
  `:""}${rs.length>0&&n.toLowerCase().includes("flux")?`-- Project Skills --
527
531
  ${rs}
528
532
 
529
- `:""}`.trim()};var Br=()=>import("./web_search-XBV7AJF7.js").then(e=>e.web_search),Ur=()=>import("./web_scrape-SJBA3RQF.js").then(e=>e.web_scrape),Wr=()=>import("./memory-QTLQAFG7.js").then(e=>e.memory),Gr=()=>import("./chat-YMCO5JNQ.js").then(e=>e.chat),Hr=()=>import("./view_file-LWURM2CE.js").then(e=>e.view_file),jr=()=>import("./write_file-6KFLPINS.js").then(e=>e.write_file),Kr=()=>import("./update_file-RA745RVH.js").then(e=>e.update_file),Vr=()=>import("./exec_command-22LIHPPH.js").then(e=>e.exec_command),zr=()=>import("./read_folder-BJ3HS63A.js").then(e=>e.read_folder),ms=()=>import("./ask_user-XQ423UXL.js").then(e=>e.ask_user),qr=()=>import("./write_pdf-UOCME2OY.js").then(e=>e.write_pdf),Yr=()=>import("./write_docx-54LANNV2.js").then(e=>e.write_docx),xi=()=>import("./search_keyword-SSKH6AYF.js").then(e=>e.search_keyword),Xr=()=>import("./generate_image-KIZS5HAI.js").then(e=>e.generate_image),wi=()=>import("./saveSummary-CVZIOQ4L.js").then(e=>e.saveSummary),Uo=()=>import("./addMemScore-U2KYMALL.js").then(e=>e.addMemScore),Jr=()=>import("./file_map-4WUEPRMI.js").then(e=>e.file_map),bi=()=>import("./todo-3EQZ7LZM.js").then(e=>e.todo),Qr=()=>import("./invokeSync-D5CAEBKJ.js").then(e=>e.invokeSync),ol=()=>import("./invoke-UHU7WYIJ.js").then(e=>e.invoke),Zr=()=>import("./getProgress-MJZDAMSP.js").then(e=>e.getProgress),il=()=>import("./cancel-2PAHCMGB.js").then(e=>e.cancel),ea=()=>import("./emergency_rollback-PHH3BKRP.js").then(e=>e.emergency_rollback),Wo=()=>import("./awaitSubagent-KLH7CRKF.js").then(e=>e.awaitSubagent),Go=()=>import("./answerSubagent-PIZJSLZN.js").then(e=>e.answerSubagent),Si=()=>import("./steerSubagent-B34P33YV.js").then(e=>e.steerSubagent),ki=()=>import("./computer_action-FZUWM6VL.js").then(e=>e.computer_action),ta=()=>import("./click-AJIULJEH.js").then(e=>e.click),na=()=>import("./drag-73WZE3BK.js").then(e=>e.drag),oa=()=>import("./scroll-KE5TNGMD.js").then(e=>e.scroll),ps=()=>import("./keyboard_typing-5L2G5AHU.js").then(e=>e.keyboard_typing),hs=()=>import("./key_press-T5VHXHUL.js").then(e=>e.key_press),ys=()=>import("./recapture_screen-JVNQ2Z7L.js").then(e=>e.recapture_screen),Ti=()=>import("./find_file-LHPOW4ZM.js").then(e=>e.find_file),ia=()=>import("./wait-6WFCZDO7.js").then(e=>e.wait),sa={web_search:Br,web_scrape:Ur,memory:Wr,chat:Gr,view_file:Hr,write_file:jr,update_file:Kr,exec_command:Vr,read_folder:zr,write_pdf:qr,write_docx:Yr,search_keyword:xi,generate_image:Xr,saveSummary:wi,addMemScore:Uo,file_map:Jr,todo:bi,Todo:bi,goal:bi,Goal:bi,invokeSync:Qr,invoke:ol,getProgress:Zr,cancel:il,awaitSubagent:Wo,answerSubagent:Go,steerSubagent:Si,computer_action:ki,computer_use:ki,ComputerAction:ki,ComputerUse:ki,click:ta,Click:ta,drag:na,Drag:na,scroll:oa,Scroll:oa,keyboard_typing:ps,KeyboardTyping:ps,keyboardtyping:ps,key_press:hs,KeyPress:hs,keypress:hs,recapture_screen:ys,RecaptureScreen:ys,recapturescreen:ys,invoke_sync:Qr,get_progress:Zr,await_subagent:Wo,answer_subagent:Go,steer_subagent:Si,steer:Si,Steer:Si,ask:ms,Ask:ms,AskUser:ms,WebSearch:Br,WebScrape:Ur,ReadFile:Hr,ReadFolder:zr,WriteFile:jr,PatchFile:Kr,WritePDF:qr,WriteDoc:Yr,Run:Vr,SearchKeyword:xi,CodeSearch:xi,code_search:xi,Memory:Wr,Chat:Gr,GenerateImage:Xr,saveSumary:wi,SaveSummary:wi,SaveSumary:wi,add_mem_score:Uo,AddMemScore:Uo,addMemoryScore:Uo,AddMemoryScore:Uo,FileMap:Jr,answer:Go,Answer:Go,AnswerSubagent:Go,await:Wo,Await:Wo,AwaitSubagent:Wo,EmergencyRollback:ea,emergency_rollback:ea,find_file:Ti,findFile:Ti,FindFile:Ti,findfile:Ti,wait:ia,Wait:ia},xs=async(e,t,n={})=>{let i=n.mode?n.mode.toLowerCase():"flux",o=e.toLowerCase(),d=["memory","chat","savesummary","addmemscore","add_mem_score","ask","web_search","web_scrape","await","wait"].some(h=>o.includes(h))||o==="ask",m=["click","drag","scroll","keyboardtyping","keyboard_typing","keypress","key_press","recapturescreen","recapture_screen","computer","wait"].some(h=>o.includes(h));if(!d){if(i==="flow"){if(!(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image")))return`ERROR: Action [${e}] is a Workspace Tool and NOT available in Flow mode. Tell user to switch (\`/mode flux\`) to use this tool.`}else if(i==="icu"){if(!m)return`ERROR: Action [${e}] is not available in Computer Use mode. ICU mode only supports Computer Use tools (Click, Drag, Scroll, KeyboardTyping, KeyPress, RecaptureScreen).`}else if(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image"))return`ERROR: Action [${e}] is not available in ${n.mode||"Flux"} mode. Tell user to switch (\`/mode flow\`) for document generation.`}let f=sa[e];if(!f){let h=["ReadFile","ReadFolder","FindFile","PatchFile","WriteFile","CodeSearch","Run","Goal","AskUser","WebSearch","WebScrape","WritePDF","WriteDoc","Click","Drag","Scroll","KeyboardTyping","KeyPress","RecaptureScreen","Wait","Invoke","InvokeSync","Await","GetProgress","Steer","Cancel","EmergencyRollback","Chat","Memory"],p={read:"ReadFile",view:"ReadFile",viewfile:"ReadFile",write:"WriteFile",edit:"PatchFile",patch:"PatchFile",update:"PatchFile",updatefile:"PatchFile",exec:"Run",command:"Run",bash:"Run",shell:"Run",powershell:"Run",search:"CodeSearch",grep:"CodeSearch",find:"FindFile",findfile:"FindFile",searchkeyword:"CodeSearch",folder:"ReadFolder",ls:"ReadFolder",dir:"ReadFolder",list:"ReadFolder",ask:"AskUser",question:"AskUser",pdf:"WritePDF",docx:"WriteDoc",doc:"WriteDoc",word:"WriteDoc",screenshot:"RecaptureScreen",screen:"RecaptureScreen",recapture:"RecaptureScreen",type:"KeyboardTyping",typing:"KeyboardTyping",keyboard:"KeyboardTyping",press:"KeyPress",key:"KeyPress",todo:"Goal",task:"Goal",subagent:"Invoke",agent:"Invoke"},g=o.replace(/[^a-z0-9]/g,""),s=p[g]||null;if(!s){let I=0,Xe=P=>{let F=new Set;for(let G=0;G<P.length-1;G++)F.add(P.slice(G,G+2));return F},C=Xe(g);for(let P of h){let F=P.toLowerCase().replace(/[^a-z0-9]/g,"");if(g===F){s=P;break}let G=0;(F.includes(g)||g.includes(F))&&(G+=.6);let $=Xe(F),L=0;for(let Ae of C)$.has(Ae)&&L++;let Te=2*L/(C.size+$.size||1);G=Math.max(G,Te),G>I&&G>=.35&&(I=G,s=P)}}let x=s?` Do you mean '${s}'?`:"";return`ERROR: Action [${e}] not found in registry.${x}`}try{return await(await f())(t,n)}catch(h){let p=h instanceof Error?h.message:String(h);return`ERROR: Execution failed for [${e}]: ${p}`}};var Ai=e=>{if(!e||typeof e!="string")return!1;let t=e.trim().toLowerCase();return Object.keys(sa).some(n=>n.toLowerCase()===t)};import B from"path";import we from"fs";import xa from"os";import wa from"crypto";import{execSync as As}from"child_process";import sl from"gradient-string";var ra=["I have a regex for your problems.","Your terminal, my kingdom.","Blowing on the cartridge helps. Probably.","Don't panic. I have the towel.","Logic is the start of wisdom.","Try to exit Vim? Good luck.","I speak fluent Terminal.","The cake is a lie. This code is not.","I have no bugs, just surprise features.","Rewriting in Rust... just for fun.","Coffee in, clean commits out.","The magic smoke stays inside today.","A semicolon short of a miracle.","One does not simply code without a bug.","Keep it simple. Keep it terminal.","Regex: now you have two problems.","I dream in binary.","Root access or bust.","Wait for the dial-up tone. Just kidding.","I take the 'labor' out of collab.","My other process is a TARDIS.","Calculated response: 42.","Ponder the orb. Ponder the code.","Less talk, more flow.","Elegance in every byte.","Build something the world is not ready for.","Your wishes, my tool calls.","I act in Flux. I think in Flow.","Syntax error in the universe. Please fix.","Your project, my obsession.","I am not a bot, I am an architect.","Digital spirits consulted. They say: Ship it.","Reticulate splines. Engage humor.","Code like poetry. Run like water.","Minimalism is the ultimate flex.","The truth is in the logs.","Follow the white rabbit.","There is no spoon. Only code.","Binary is the only language I trust.","I have a good feeling about this.","Pew pew! Lasers charged.","Divide by zero? Not today.","Search for the correct USB orientation...","I've got a fever, and the only cure is more code.","The code gremlins are on our side.","My favorite command? Yours.","Stay hungry. Stay active.","Momentum is your best friend.","Lead the flow. Don't chase it.","A fresh batch of bytes. Hot and ready.","I orchestrate the ones and zeros.","Smart enough to help. Humble enough to ask.","Think twice. Code once.","Pure intent. Pure execution.","Small steps. Massive impact.","Your terminal is a canvas.","Efficiency is my second name.","I have seen things you people wouldn't believe.","Let the thoughts marinate.","The best feature? The one you don't need.","Precision is the only perfection.","Stay focused. Stay terminal.","Silence is the best debugger.","Erase the debt. Commit the code.","Velocity meets stability.","Ship it. Improve it. Repeat.","Build tomorrow, right now.","Turn logic into reality.","The best way to predict the future is to build it.","Break barriers, not builds.","Fuel the next breakthrough.","Momentum is key.","Terminal vibes only.","Your digital co-pilot is ready.","Partner in code. Partner in crime.","I speak in semicolons.","Ready for the next great idea.","Just a moment. In the zone.","Polishing the algorithms. Hold tight.","Craft a masterpiece today.","Debug the universe. Start here.","Warp speed engaged. Almost.","The cake is not a lie. It's just loading.","Finish the Kessel Run in 12 parsecs.","Do a barrel roll!","Waiting for the respawn.","Press Start to continue.","Herding digital cats... done.","The hamsters are fast today.","Tasting the snozberries.","I go for speed. I go for flow.","Real life or just fantasy?","Poking the bear... gently.","Ensure the magic smoke stays inside.","Try turning it off and on again.","Construct additional pylons.","New line? Ctrl+J is your friend.","Release the HypnoDrones.","Push the button, Frank.","My other loading screen is even funnier.","Pretty sure a cat walked on my keyboard.","Recalibrate the humor-o-meter.","Summon the code gremlins.","I've seen your browser history. Just kidding.","Charge the laser... pew pew!","Dividing by zero... just for a sec.","Looking for an adult supervisor. Found none.","Make it go beep boop.","Buffering... for effect.","Entangle quantum particles... complete.","Polishing the chrome on my algorithms.","Are you not entertained?","Just waiting for the dial-up tone.","Reboot the humor module.","Defragment memories. Check.","Optimizing for ludicrous speed.","Swapping bits. Don't tell the bytes.","Garbage collected. I am back.","Assembling the interwebs.","Converting coffee to logic.","Update syntax for reality.","Rewire the synapses.","Greasin' the cogs.","Engage the improbability drive.","Channel the Force.","Align the stars. Respond now.","The cake is a lie. The prompt is real.","I'm Feeling Lucky.","Shipping awesomeness.","Navigating the slime mold.","Consult digital spirits.","Ask the magic conch shell.","One moment. Optimizing humor.","Shuffling punchlines.","Compiling brilliance.","Summon the cloud of wisdom.","Prepare to dazzle.","Hold tight. Crafting a response.","Tuning the algorithms.","Following the white rabbit... again.","The truth is in here. Somewhere.","Herding cats is my day job.","Distracting you with this phrase.","Almost there. Probably.","Rickrolling my creator. Don't tell.","Slapping the bass.","Is this real life?","Ponder the orb. Type the prompt.","Thoughtful gaze initiated.","Computer's favorite snack? Microchips.","Why Java? Because I don't C#.","Charging the laser... wait for it.","Dividing by zero... just kidding!","Adult supervision not found. Proceed.","Beep boop. I'm a real boy.","Wait for the respawn.","Finish the run. Ship the code.","Fiddling with character creation.","Just a moment. Finding a meme.","Pressing A to continue.","Loading wit.exe.","Pre-heating the servers.","Calibrate flux capacitor.","Channeling the Force.","Aligning the stars.","The truth is in the code.","Don't panic.","Blowing on the cartridge.","Doing a barrel roll!","Respawning in 3... 2... 1...","The cake is a lie.","Fiddling with character settings.","Finding a suitable pun.","Distracting with wit.","Almost ready.","Hamsters on speed today.","Patting Cloudy on the head.","Rickrolling the logs.","Slapping the code.","Got a good feeling about this.","Poking the prompt.","Researching latest memes.","Making it more witty.","Thinking... hmmm.","Fish with no eyes? Fsh.","Broken pencil? Pointless.","Percussive maintenance applied.","USB orientation: 3rd try's the charm.","Rust rewrite in 3... 2...","Exiting Vim... someday.","Spinning the hamster wheel.","Not a bug. Unplanned feature.","Engage.","I'll be back.","Machine spirit consulted.","Letting the thoughts marinate.","Orb pondered.","Thoughtful gaze engaged.","Charging the laser...","Making it go beep.","Buffering...","Quantum particles entangled.","Polishing the chrome.","Entertained yet?","Gremlins summoned.","Dial-up tone finished.","Humor meter recalibrated.","Cat on keyboard. Sending help.","Enhancing...","Turn it off and on again.","Constructing pylons.","HypnoDrones released.","Pushing the button."];var aa=["Beware the phantom processes.","A ghost in the shell has taken the wheel.","Blowing on the haunted cartridge...","Seven minutes in Raccoon City.","Wind's howling... in the terminal fans.","Slender Man was spotted in line 404.","The cake is a lie. The curse is real.","Don't look behind the server rack.","Exorcising memory leaks at 3 AM.","Pyramid Head reorganized your commit history.","It's dangerous to go alone! Take this flashlight.","YOU DIED. Respawning terminal session...","The Necronomicon evaluated to true.","Something wicked this way compiles.","Haunting your localhost with good vibes.","A full moon has risen over Git main.","Double, double toil and trouble; code fire burn.","Clickers heard in the directory tree.","Checking camera 2B for rogue animatronics.","The call is coming from inside the container.","Isaac Clarke is stomping on stubborn bugs.","Luigi vacuumed the ghosts out of RAM.","Trick or treat, give me clean code to greet.","Whispering incantations to the garbage collector.","Klaatu barada necktie... close enough.","Resurrecting deprecated APIs from the crypt.","The headless horseman forgot the return statement.","Castlevania whip cracking against network latency.","Slime mold crawling through the motherboard.","Carving a pixelated pumpkin into terminal history.","Burying undefined pointers in the pet sematary.","Spilling pumpkin spice on the CPU.","A vampire bat is draining system battery life.","Don't fall asleep at the keyboard tonight.","Silent Hill sirens sounding in the console.","Poltergeists rearranging terminal tabs.","Lighting the Black Flame Candle for autoExec.","Dusting cobwebs off legacy dependencies.","Here's Johnny! ...just checking build health.","Blood, sweat, and zero warnings.","The spirit box whispers: 'GIT PUSH FORCE'.","They're heeeere... in the stack trace.","It's alive! IT'S ALIVEEEE!","No merge conflicts in the graveyard.","Frankenstein's monster patched this logic.","Surviving Five Nights at Flux Flow.","Doom Slayer loading buckshot into cache.","The grim reaper spared your unused imports.","Candy corn lodged in mechanical switches.","May your latency be low and your crypt be quiet."];var la=[{name:"Cyan Cyberpunk",text:"cyan",textMuted:"#4da6b8",textDim:"#2d6d7a",textInverted:"black",border:"cyan",borderMuted:"#1a5966",borderDim:"#0f3840",bg:void 0,cardBg:"#061e24",highlightBg:"#092b33",activeBg:"#0e3e4a",inputBg:"#092b33",inputBorder:"#092b33",inputText:"cyan",inputPlaceholder:"#2d6d7a",inputPrompt:"cyan",codeBg:"#020d10",codeBorder:"#1a5966",userMsgBg:"#092b33",userMsgBorder:"#092b33",userMsgText:"cyan",diffRemovalBg:"#3a0c1a",diffAdditionBg:"#0c3a32",diffRemovalText:"#ff4d88",diffAdditionText:"#00ffaa",diffRemovalHighlightColor:"#ff1a66",diffRemovalHighlightBg:"#590022",diffAdditionHighlightColor:"#00ffcc",diffAdditionHighlightBg:"#00593b",diffRemovalNum:"#ff4d88",diffAdditionNum:"#00ffaa",diffRemovalPrefix:"#ff1a66",diffAdditionPrefix:"#00ffcc",primary:"cyan",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"cyan",statusOff:"#2d6d7a",logoTextAnsi:"\x1B[1;36m",logoBodyAnsi:"\x1B[36m",logoMutedAnsi:"\x1B[90m",logoGradient:["#00ffff","#0088ff"]},{name:"Magenta Vaporwave",text:"magenta",textMuted:"#c451d6",textDim:"#7d2b8a",textInverted:"black",border:"magenta",borderMuted:"#5e1b69",borderDim:"#3b0f42",bg:void 0,cardBg:"#240729",highlightBg:"#310938",activeBg:"#470e52",inputBg:"#310938",inputBorder:"#310938",inputText:"magenta",inputPlaceholder:"#7d2b8a",inputPrompt:"magenta",codeBg:"#100312",codeBorder:"#5e1b69",userMsgBg:"#310938",userMsgBorder:"#310938",userMsgText:"magenta",diffRemovalBg:"#3a0c20",diffAdditionBg:"#200c3a",diffRemovalText:"#ff4d94",diffAdditionText:"#aa4dff",diffRemovalHighlightColor:"#ff1a75",diffRemovalHighlightBg:"#59002b",diffAdditionHighlightColor:"#bb66ff",diffAdditionHighlightBg:"#3b0059",diffRemovalNum:"#ff4d94",diffAdditionNum:"#aa4dff",diffRemovalPrefix:"#ff1a75",diffAdditionPrefix:"#bb66ff",primary:"magenta",secondary:"cyan",accent:"purple",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"magenta",statusOff:"#7d2b8a",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ff00ff","#8800ff"]},{name:"Glitch Matrix",text:"#00ff41",textMuted:"#00b32d",textDim:"#00661a",textInverted:"black",border:"#00ff41",borderMuted:"#008020",borderDim:"#004d13",bg:void 0,cardBg:"#0d1f0d",highlightBg:"#122912",activeBg:"#1c3e1c",inputBg:"#122912",inputBorder:"#122912",inputText:"#00ff41",inputPlaceholder:"#00b32d",inputPrompt:"#ffff00",codeBg:"#040a04",codeBorder:"#008020",userMsgBg:"#122912",userMsgBorder:"#122912",userMsgText:"#00ff41",diffRemovalBg:"#3a001a",diffAdditionBg:"#003a10",diffRemovalText:"#ff0055",diffAdditionText:"#00ff66",diffRemovalHighlightColor:"#ff0033",diffRemovalHighlightBg:"#59001b",diffAdditionHighlightColor:"#33ff88",diffAdditionHighlightBg:"#005918",diffRemovalNum:"#ff0055",diffAdditionNum:"#00ff66",diffRemovalPrefix:"#ff0033",diffAdditionPrefix:"#33ff88",primary:"#00ff41",secondary:"yellow",accent:"cyan",success:"#00ff41",warning:"yellow",danger:"red",info:"cyan",statusOn:"#00ff41",statusOff:"#00661a",logoTextAnsi:"\x1B[1;32m",logoBodyAnsi:"\x1B[32m",logoMutedAnsi:"\x1B[90m",logoGradient:["#00ff41","#ffff00"]},{name:"Warm Sunset",text:"#ffaa55",textMuted:"#cc8844",textDim:"#885522",textInverted:"black",border:"#ff9933",borderMuted:"#aa6622",borderDim:"#663311",bg:void 0,cardBg:"#24180f",highlightBg:"#2e1e12",activeBg:"#422c1b",inputBg:"#2e1e12",inputBorder:"#2e1e12",inputText:"#ffaa55",inputPlaceholder:"#885522",inputPrompt:"#ff7733",codeBg:"#120c08",codeBorder:"#aa6622",userMsgBg:"#2e1e12",userMsgBorder:"#2e1e12",userMsgText:"#ffaa55",diffRemovalBg:"#3d120c",diffAdditionBg:"#3a2e0c",diffRemovalText:"#ff5544",diffAdditionText:"#ffcc33",diffRemovalHighlightColor:"#ff3322",diffRemovalHighlightBg:"#591108",diffAdditionHighlightColor:"#ffee44",diffAdditionHighlightBg:"#594400",diffRemovalNum:"#ff5544",diffAdditionNum:"#ffcc33",diffRemovalPrefix:"#ff3322",diffAdditionPrefix:"#ffee44",primary:"#ffaa55",secondary:"#ff7733",accent:"magenta",success:"#ffcc33",warning:"#ff7733",danger:"#ff3322",info:"#ffaa55",statusOn:"#ffaa55",statusOff:"#885522",logoTextAnsi:"\x1B[1;33m",logoBodyAnsi:"\x1B[33m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ff9933","#ff0055"]},{name:"Sakura Blossom",text:"#ffc0e0",textMuted:"#d98cb3",textDim:"#804d66",textInverted:"black",border:"#ff99cc",borderMuted:"#aa4d7a",borderDim:"#662647",bg:void 0,cardBg:"#291320",highlightBg:"#331826",activeBg:"#472235",inputBg:"#331826",inputBorder:"#331826",inputText:"#ffc0e0",inputPlaceholder:"#804d66",inputPrompt:"#ff99cc",codeBg:"#140a10",codeBorder:"#aa4d7a",userMsgBg:"#331826",userMsgBorder:"#331826",userMsgText:"#ffc0e0",diffRemovalBg:"#3e0c1b",diffAdditionBg:"#1b3e2b",diffRemovalText:"#ff6699",diffAdditionText:"#66ffb3",diffRemovalHighlightColor:"#ff3377",diffRemovalHighlightBg:"#590022",diffAdditionHighlightColor:"#33ff99",diffAdditionHighlightBg:"#00592e",diffRemovalNum:"#ff6699",diffAdditionNum:"#66ffb3",diffRemovalPrefix:"#ff3377",diffAdditionPrefix:"#33ff99",primary:"#ffc0e0",secondary:"#ff99cc",accent:"magenta",success:"#66ffb3",warning:"yellow",danger:"#ff3377",info:"#ff99cc",statusOn:"#ffc0e0",statusOff:"#804d66",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ffb3d9","#ff3399"]},{name:"Radioactive Slime",text:"#ccff00",textMuted:"#99cc00",textDim:"#669900",textInverted:"#0a0f00",border:"#ccff00",borderMuted:"#99cc00",borderDim:"#669900",bg:void 0,cardBg:"#0f1400",highlightBg:"#1a2400",activeBg:"#2a3b00",inputBg:"#1a2400",inputBorder:"#1a2400",inputText:"#ccff00",inputPlaceholder:"#669900",inputPrompt:"#cc00ff",codeBg:"#050a00",codeBorder:"#99cc00",userMsgBg:"#1a2400",userMsgBorder:"#1a2400",userMsgText:"#ccff00",diffRemovalBg:"#2a0033",diffAdditionBg:"#0f3300",diffRemovalText:"#ff00cc",diffAdditionText:"#00ff33",diffRemovalHighlightColor:"#ff33cc",diffRemovalHighlightBg:"#4d0066",diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:"#1a6600",diffRemovalNum:"#ff00cc",diffAdditionNum:"#00ff33",diffRemovalPrefix:"#ff33cc",diffAdditionPrefix:"#33ff66",primary:"#ccff00",secondary:"#cc00ff",accent:"#ff00cc",success:"#00ff33",warning:"#ffcc00",danger:"#ff0033",info:"#00ccff",statusOn:"#ccff00",statusOff:"#669900",logoTextAnsi:"\x1B[1;38;5;190m",logoBodyAnsi:"\x1B[38;5;190m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ccff00","#cc00ff"]},{name:"Cosmic Void",text:"#f0f8ff",textMuted:"#a6aeb5",textDim:"#5e656e",textInverted:"#010103",border:"#f0f8ff",borderMuted:"#a6aeb5",borderDim:"#5e656e",bg:void 0,cardBg:"#05030d",highlightBg:"#0b081a",activeBg:"#171133",inputBg:"#0b081a",inputBorder:"#0b081a",inputText:"#f0f8ff",inputPlaceholder:"#5e656e",inputPrompt:"#ff007f",codeBg:"#020108",codeBorder:"#a6aeb5",userMsgBg:"#0b081a",userMsgBorder:"#0b081a",userMsgText:"#f0f8ff",diffRemovalBg:"#2e0a29",diffAdditionBg:"#091c33",diffRemovalText:"#ff33a6",diffAdditionText:"#33d6ff",diffRemovalHighlightColor:"#ff66c2",diffRemovalHighlightBg:"#5c1452",diffAdditionHighlightColor:"#66e0ff",diffAdditionHighlightBg:"#123866",diffRemovalNum:"#ff33a6",diffAdditionNum:"#33d6ff",diffRemovalPrefix:"#ff66c2",diffAdditionPrefix:"#66e0ff",primary:"#f0f8ff",secondary:"#ff007f",accent:"#9d00ff",success:"#33d6ff",warning:"#ffcc00",danger:"#ff0040",info:"#9d00ff",statusOn:"#f0f8ff",statusOff:"#5e656e",logoTextAnsi:"\x1B[1;38;5;231m",logoBodyAnsi:"\x1B[38;5;231m",logoMutedAnsi:"\x1B[38;5;240m",logoGradient:["#ffffff","#9d00ff"]},{name:"Magma Eruption",text:"#ff4d00",textMuted:"#cc3d00",textDim:"#802600",textInverted:"#0d0300",border:"#ff4d00",borderMuted:"#cc3d00",borderDim:"#802600",bg:void 0,cardBg:"#1a0600",highlightBg:"#260a00",activeBg:"#401100",inputBg:"#260a00",inputBorder:"#260a00",inputText:"#ff4d00",inputPlaceholder:"#802600",inputPrompt:"#ffcc00",codeBg:"#080200",codeBorder:"#cc3d00",userMsgBg:"#260a00",userMsgBorder:"#260a00",userMsgText:"#ff4d00",diffRemovalBg:"#2e0a0a",diffAdditionBg:"#1f1400",diffRemovalText:"#ff3333",diffAdditionText:"#ffaa00",diffRemovalHighlightColor:"#ff6666",diffRemovalHighlightBg:"#5c1414",diffAdditionHighlightColor:"#ffcc33",diffAdditionHighlightBg:"#3d2900",diffRemovalNum:"#ff3333",diffAdditionNum:"#ffaa00",diffRemovalPrefix:"#ff6666",diffAdditionPrefix:"#ffcc33",primary:"#ff4d00",secondary:"#ffcc00",accent:"#ff0040",success:"#ffaa00",warning:"#ffff00",danger:"#ff0000",info:"#ff8800",statusOn:"#ff4d00",statusOff:"#802600",logoTextAnsi:"\x1B[1;38;5;202m",logoBodyAnsi:"\x1B[38;5;202m",logoMutedAnsi:"\x1B[38;5;236m",logoGradient:["#ff4d00","#ff0000"]}],xo={Dark:{id:"Dark",name:"Dark (Default)",text:"white",textMuted:"gray",textDim:"grey",textInverted:"black",textExclusive:"#B5B8D9",textMutedExclusive:"#D4DEE7",border:"white",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:"#1e1e1e",highlightBg:"#2a2a2a",activeBg:"#3a3a3a",inputBg:"#555555",inputBorder:"#555555",inputText:"white",inputPlaceholder:"#cccccc",inputPrompt:"white",codeBg:"#1a1a1a",codeBorder:"#444444",userMsgBg:"#444444",userMsgBorder:"#444444",userMsgText:"white",diffRemovalBg:"#250808",diffAdditionBg:"#072410",diffRemovalText:"#885555",diffAdditionText:"#558866",diffRemovalHighlightColor:"#ff3333",diffRemovalHighlightBg:"#5a1818",diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:"#185a25",diffRemovalNum:"#d96868",diffAdditionNum:"#68d98c",diffRemovalPrefix:"#ff4d4d",diffAdditionPrefix:"#4dff88",primary:"white",secondary:"cyan",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"white",statusOff:"gray",logoTextAnsi:"\x1B[1;37m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},Light:{id:"Light",name:"Light",text:"black",textMuted:"gray",textDim:"grey",textInverted:"white",border:"black",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:"#e5e5e5",highlightBg:"#d4d4d4",activeBg:"#c0c0c0",inputBg:"#d0d0d0",inputBorder:"#d0d0d0",inputText:"black",inputPlaceholder:"#555555",inputPrompt:"black",codeBg:"#e8e8e8",codeBorder:"#b0b0b0",userMsgBg:"#d0d0d0",userMsgBorder:"#d0d0d0",userMsgText:"black",diffRemovalBg:"#fce8e8",diffAdditionBg:"#e6f9e6",diffRemovalText:"#661111",diffAdditionText:"#115511",diffRemovalHighlightColor:"#440000",diffRemovalHighlightBg:"#f8b4b4",diffAdditionHighlightColor:"#003300",diffAdditionHighlightBg:"#a6ebad",diffRemovalNum:"#c02020",diffAdditionNum:"#188028",diffRemovalPrefix:"#d01010",diffAdditionPrefix:"#109020",primary:"black",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"black",statusOff:"gray",logoTextAnsi:"\x1B[1;30m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},"GitHub Dark":{id:"GitHub Dark",name:"GitHub Dark",text:"#c9d1d9",textMuted:"#8b949e",textDim:"#6e7681",textInverted:"#0d1117",border:"#30363d",borderMuted:"#30363d",borderDim:"#21262d",bg:void 0,cardBg:"#161b22",highlightBg:"#21262d",activeBg:"#30363d",inputBg:"#21262d",inputBorder:"#21262d",inputText:"#c9d1d9",inputPlaceholder:"#8b949e",inputPrompt:"#58a6ff",codeBg:"#0d1117",codeBorder:"#30363d",userMsgBg:"#21262d",userMsgBorder:"#21262d",userMsgText:"#c9d1d9",diffRemovalBg:"#3c1e1e",diffAdditionBg:"#11381e",diffRemovalText:"#f85149",diffAdditionText:"#3fb950",diffRemovalHighlightColor:"#ff7b72",diffRemovalHighlightBg:"#701c1c",diffAdditionHighlightColor:"#56d364",diffAdditionHighlightBg:"#116329",diffRemovalNum:"#f85149",diffAdditionNum:"#3fb950",diffRemovalPrefix:"#f85149",diffAdditionPrefix:"#3fb950",primary:"#c9d1d9",secondary:"#58a6ff",accent:"#bc8cff",success:"#3fb950",warning:"#d29922",danger:"#f85149",info:"#58a6ff",statusOn:"#58a6ff",statusOff:"#8b949e",logoTextAnsi:"\x1B[1;36m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#2ea043","#56d364"],toolFeedbackAnsi:"\x1B[95m"},"GitHub Light":{id:"GitHub Light",name:"GitHub Light",text:"#24292f",textMuted:"#57606a",textDim:"#6e7781",textInverted:"#ffffff",border:"#d0d7de",borderMuted:"#d0d7de",borderDim:"#e1e4e8",bg:void 0,cardBg:"#f6f8fa",highlightBg:"#eaeef2",activeBg:"#d0d7de",inputBg:"#eaeef2",inputBorder:"#eaeef2",inputText:"#24292f",inputPlaceholder:"#57606a",inputPrompt:"#0969da",codeBg:"#ffffff",codeBorder:"#d0d7de",userMsgBg:"#eaeef2",userMsgBorder:"#eaeef2",userMsgText:"#24292f",diffRemovalBg:"#ffebe9",diffAdditionBg:"#e6ffec",diffRemovalText:"#cf222e",diffAdditionText:"#1a7f37",diffRemovalHighlightColor:"#82071e",diffRemovalHighlightBg:"#ffc1c0",diffAdditionHighlightColor:"#116329",diffAdditionHighlightBg:"#acf2bd",diffRemovalNum:"#cf222e",diffAdditionNum:"#1a7f37",diffRemovalPrefix:"#cf222e",diffAdditionPrefix:"#1a7f37",primary:"#24292f",secondary:"#0969da",accent:"#8250df",success:"#1a7f37",warning:"#9a6700",danger:"#cf222e",info:"#0969da",statusOn:"#0969da",statusOff:"#57606a",logoTextAnsi:"\x1B[1;34m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#1a7f37","#2da44e"],toolFeedbackAnsi:"\x1B[95m"},"Transparent Dark":{id:"Transparent Dark",name:"Transparent Dark",text:"white",textMuted:"gray",textDim:"grey",textInverted:"black",border:"gray",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:void 0,highlightBg:"#2a2a2a",activeBg:"#3a3a3a",inputBg:"#555555",inputBorder:"#555555",inputText:"white",inputPlaceholder:"#cccccc",inputPrompt:"white",codeBg:void 0,codeBorder:"gray",userMsgBg:"#555555",userMsgBorder:"#555555",userMsgText:"white",diffRemovalBg:void 0,diffAdditionBg:void 0,diffRemovalText:"#ff6666",diffAdditionText:"#66ff66",diffRemovalHighlightColor:"#ff3333",diffRemovalHighlightBg:"#3a1414",diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:"#143a14",diffRemovalNum:"#ff6666",diffAdditionNum:"#66ff66",diffRemovalPrefix:"#ff4d4d",diffAdditionPrefix:"#4dff88",primary:"white",secondary:"cyan",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"white",statusOff:"gray",logoTextAnsi:"\x1B[1;37m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},"Transparent Light":{id:"Transparent Light",name:"Transparent Light",text:"black",textMuted:"gray",textDim:"grey",textInverted:"white",border:"gray",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:void 0,highlightBg:"#d4d4d4",activeBg:"#c0c0c0",inputBg:"#d0d0d0",inputBorder:"#d0d0d0",inputText:"black",inputPlaceholder:"#555555",inputPrompt:"black",codeBg:void 0,codeBorder:"gray",userMsgBg:"#d0d0d0",userMsgBorder:"#d0d0d0",userMsgText:"black",diffRemovalBg:void 0,diffAdditionBg:void 0,diffRemovalText:"#c02020",diffAdditionText:"#188028",diffRemovalHighlightColor:"#800000",diffRemovalHighlightBg:"#f5d0d0",diffAdditionHighlightColor:"#004000",diffAdditionHighlightBg:"#cceccc",diffRemovalNum:"#c02020",diffAdditionNum:"#188028",diffRemovalPrefix:"#d01010",diffAdditionPrefix:"#109020",primary:"black",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"black",statusOff:"gray",logoTextAnsi:"\x1B[1;30m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},"Synthwave 84":{id:"Synthwave 84",name:"Synthwave 84",text:"#fdfdfd",textMuted:"#a08eb7",textDim:"#705c8a",textInverted:"#1a1025",textExclusive:"#e3dcf0",textMutedExclusive:"#b9abc9",border:"#fc28a8",borderMuted:"#a21568",borderDim:"#5c0a3a",bg:void 0,cardBg:"#261b38",highlightBg:"#35254d",activeBg:"#4c3570",inputBg:"#35254d",inputBorder:"#35254d",inputText:"#fdfdfd",inputPlaceholder:"#a08eb7",inputPrompt:"#03e8fc",codeBg:"#1e142b",codeBorder:"#a21568",userMsgBg:"#35254d",userMsgBorder:"#35254d",userMsgText:"#fdfdfd",diffRemovalBg:"#471434",diffAdditionBg:"#144743",diffRemovalText:"#ff4081",diffAdditionText:"#00e5ff",diffRemovalHighlightColor:"#ff79a1",diffRemovalHighlightBg:"#6b1e4e",diffAdditionHighlightColor:"#66f5ff",diffAdditionHighlightBg:"#1e6b65",diffRemovalNum:"#ff4081",diffAdditionNum:"#00e5ff",diffRemovalPrefix:"#ff79a1",diffAdditionPrefix:"#66f5ff",primary:"#fdfdfd",secondary:"#03e8fc",accent:"#fc28a8",success:"#00e5ff",warning:"#ffc107",danger:"#ff4081",info:"#b388ff",statusOn:"#03e8fc",statusOff:"#a08eb7",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#fc28a8","#03e8fc"],toolFeedbackAnsi:"\x1B[38;2;3;232;252m"},"Forest Sprite":{id:"Forest Sprite",name:"Forest Sprite",text:"#d6e6d1",textMuted:"#95b38d",textDim:"#628059",textInverted:"#161c14",textExclusive:"#eaf2e8",textMutedExclusive:"#a9c7a2",border:"#74a862",borderMuted:"#477038",borderDim:"#2b4720",bg:void 0,cardBg:"#1f291c",highlightBg:"#2a3826",activeBg:"#3a4d35",inputBg:"#2a3826",inputBorder:"#2a3826",inputText:"#d6e6d1",inputPlaceholder:"#95b38d",inputPrompt:"#8feb73",codeBg:"#161e14",codeBorder:"#477038",userMsgBg:"#2a3826",userMsgBorder:"#2a3826",userMsgText:"#d6e6d1",diffRemovalBg:"#3b231c",diffAdditionBg:"#203b1c",diffRemovalText:"#db6242",diffAdditionText:"#59cc3f",diffRemovalHighlightColor:"#f0896c",diffRemovalHighlightBg:"#5c362a",diffAdditionHighlightColor:"#80e368",diffAdditionHighlightBg:"#305929",diffRemovalNum:"#db6242",diffAdditionNum:"#59cc3f",diffRemovalPrefix:"#f0896c",diffAdditionPrefix:"#80e368",primary:"#d6e6d1",secondary:"#8feb73",accent:"#e69835",success:"#59cc3f",warning:"#e69835",danger:"#db6242",info:"#73b4eb",statusOn:"#8feb73",statusOff:"#95b38d",logoTextAnsi:"\x1B[1;32m",logoBodyAnsi:"\x1B[32m",logoMutedAnsi:"\x1B[90m",logoGradient:["#8feb73","#e69835"],toolFeedbackAnsi:"\x1B[38;2;143;235;115m"},Spookfest:{id:"Spookfest",name:"Spookfest \u{1F383}",text:"#ffeedd",textMuted:"#e09858",textDim:"#a6622b",textInverted:"#0d0702",textExclusive:"#fff3e6",textMutedExclusive:"#d4a276",border:"#ff7518",borderMuted:"#994409",borderDim:"#592502",bg:void 0,cardBg:"#1a0c02",highlightBg:"#2a1403",activeBg:"#3d1d05",inputBg:"#261203",inputBorder:"#261203",inputText:"#ffeedd",inputPlaceholder:"#a6622b",inputPrompt:"#ff7518",codeBg:"#120701",codeBorder:"#592502",userMsgBg:"#261203",userMsgBorder:"#261203",userMsgText:"#ffeedd",diffRemovalBg:"#3d0a0a",diffAdditionBg:"#1a330a",diffRemovalText:"#ff5555",diffAdditionText:"#73e639",diffRemovalHighlightColor:"#ff2222",diffRemovalHighlightBg:"#590e0e",diffAdditionHighlightColor:"#88ff3b",diffAdditionHighlightBg:"#244d0a",diffRemovalNum:"#ff5555",diffAdditionNum:"#73e639",diffRemovalPrefix:"#ff3333",diffAdditionPrefix:"#88ff3b",primary:"#ff7518",secondary:"#a855f7",accent:"#22c55e",success:"#22c55e",warning:"#f59e0b",danger:"#ef4444",info:"#a855f7",statusOn:"#ff7518",statusOff:"#703a08",logoTextAnsi:"\x1B[1;38;2;255;117;24m",logoBodyAnsi:"\x1B[38;2;255;140;26m",logoMutedAnsi:"\x1B[38;2;168;85;247m",logoGradient:["#ff7518","#a855f7"],toolFeedbackAnsi:"\x1B[38;2;255;117;24m"}};var Ci=null;var Ri=(e="Dark")=>{let t;e==="Mystery"||e==="Chaos"?(Ci||(Ci=la[Math.floor(Math.random()*la.length)]),t={...Ci,id:"Mystery"}):(Ci=null,xo[e]?t=xo[e]:e==="Halloween"?t=xo.Spookfest:e==="GitHub"?t=xo["GitHub Dark"]:e==="Transparent"?t=xo["Transparent Dark"]:t=xo.Dark);let n=t.codeText||t.secondary||t.info||t.logoGradient&&t.logoGradient[0]||"cyan",i=t.toolFeedbackAnsi||"\x1B[95m";return{...t,codeText:n,toolFeedbackAnsi:i}};var rl=()=>process.env.TERM_PROGRAM==="vscode"?"vscode":process.env.WT_SESSION?"wt":"default",td=(e=2)=>{let t=rl();return t==="wt"?" ".repeat(Math.max(1,e-1)):" ".repeat(e)},ca=new Date,Ho=ca.getMonth(),jo=ca.getDate(),al=Ho===9&&jo>=15||Ho===10&&jo<=1,ws=null;(process.env.SPOOKFEST==="true"||al)&&(ws=await import("./halloween-MX3VNQRW.js"));var nd=(e="...",t="Loading...",n="Dark")=>{let i=Ri(n),o=t;if(t==="c_openai"||t==="Custom (OpenAI)")try{let G=ri(oi,{})?.systemSettings?.customOpenAIBaseUrl;G&&(o=G)}catch{}let r=i.logoTextAnsi,d=i.logoBodyAnsi,l=i.logoMutedAnsi,m="\x1B[0m",f=[" \u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2591 "," \u2588\u2588\u2588\u2591 "," \u2588\u2588\u2588\u2591 "," \u2591\u2591\u2591 "],h=n==="Spookfest"||i.id==="Spookfest"||n==="Halloween"||i.id==="Halloween",p=Ho===9&&jo>=15||Ho===10&&jo<=1,g=h&&p||process.env.SPOOKFEST==="true"&&h,s=f;if(g&&ws){process.env.HALLOWEEN_EEGG="true";let{halloweenArtSide:F,halloweenBat:G,halloweenArtUser:$}=ws;s=Math.random()>.9&&Ho===9&&jo>=30?G:Math.random()>.5?F:$}else process.env.HALLOWEEN_EEGG="false";let x=g?aa:ra,I=x[Math.floor(Math.random()*x.length)],Xe=i.logoGradient||["#0077ff","#ff00ff"],C=sl(Xe).multiline(s.join(`
533
+ `:""}`.trim()};var Br=()=>import("./web_search-XBV7AJF7.js").then(e=>e.web_search),Ur=()=>import("./web_scrape-SJBA3RQF.js").then(e=>e.web_scrape),Wr=()=>import("./memory-QTLQAFG7.js").then(e=>e.memory),Gr=()=>import("./chat-YMCO5JNQ.js").then(e=>e.chat),Hr=()=>import("./view_file-LWURM2CE.js").then(e=>e.view_file),jr=()=>import("./write_file-G4QVTNSH.js").then(e=>e.write_file),Kr=()=>import("./update_file-74CZ4JRC.js").then(e=>e.update_file),Vr=()=>import("./exec_command-22LIHPPH.js").then(e=>e.exec_command),zr=()=>import("./read_folder-BJ3HS63A.js").then(e=>e.read_folder),ms=()=>import("./ask_user-XQ423UXL.js").then(e=>e.ask_user),qr=()=>import("./write_pdf-UOCME2OY.js").then(e=>e.write_pdf),Yr=()=>import("./write_docx-54LANNV2.js").then(e=>e.write_docx),xi=()=>import("./search_keyword-D7D7PMSR.js").then(e=>e.search_keyword),Xr=()=>import("./generate_image-RB3HJFO6.js").then(e=>e.generate_image),wi=()=>import("./saveSummary-CVZIOQ4L.js").then(e=>e.saveSummary),Uo=()=>import("./addMemScore-U2KYMALL.js").then(e=>e.addMemScore),Jr=()=>import("./file_map-4WUEPRMI.js").then(e=>e.file_map),bi=()=>import("./todo-3EQZ7LZM.js").then(e=>e.todo),Qr=()=>import("./invokeSync-O3ZJBM6T.js").then(e=>e.invokeSync),ol=()=>import("./invoke-WXMEB2A5.js").then(e=>e.invoke),Zr=()=>import("./getProgress-MJZDAMSP.js").then(e=>e.getProgress),il=()=>import("./cancel-2PAHCMGB.js").then(e=>e.cancel),ea=()=>import("./emergency_rollback-PHH3BKRP.js").then(e=>e.emergency_rollback),Wo=()=>import("./awaitSubagent-KLH7CRKF.js").then(e=>e.awaitSubagent),Go=()=>import("./answerSubagent-PIZJSLZN.js").then(e=>e.answerSubagent),Si=()=>import("./steerSubagent-B34P33YV.js").then(e=>e.steerSubagent),ki=()=>import("./computer_action-GJV76M3H.js").then(e=>e.computer_action),ta=()=>import("./click-J3HGKREV.js").then(e=>e.click),na=()=>import("./drag-CXZGQ6VL.js").then(e=>e.drag),oa=()=>import("./scroll-ULY2O6WE.js").then(e=>e.scroll),ps=()=>import("./keyboard_typing-37C44KPF.js").then(e=>e.keyboard_typing),hs=()=>import("./key_press-GP35GCNC.js").then(e=>e.key_press),ys=()=>import("./recapture_screen-MOGI4IMA.js").then(e=>e.recapture_screen),Ti=()=>import("./find_file-LHPOW4ZM.js").then(e=>e.find_file),ia=()=>import("./wait-6WFCZDO7.js").then(e=>e.wait),sa={web_search:Br,web_scrape:Ur,memory:Wr,chat:Gr,view_file:Hr,write_file:jr,update_file:Kr,exec_command:Vr,read_folder:zr,write_pdf:qr,write_docx:Yr,search_keyword:xi,generate_image:Xr,saveSummary:wi,addMemScore:Uo,file_map:Jr,todo:bi,Todo:bi,goal:bi,Goal:bi,invokeSync:Qr,invoke:ol,getProgress:Zr,cancel:il,awaitSubagent:Wo,answerSubagent:Go,steerSubagent:Si,computer_action:ki,computer_use:ki,ComputerAction:ki,ComputerUse:ki,click:ta,Click:ta,drag:na,Drag:na,scroll:oa,Scroll:oa,keyboard_typing:ps,KeyboardTyping:ps,keyboardtyping:ps,key_press:hs,KeyPress:hs,keypress:hs,recapture_screen:ys,RecaptureScreen:ys,recapturescreen:ys,invoke_sync:Qr,get_progress:Zr,await_subagent:Wo,answer_subagent:Go,steer_subagent:Si,steer:Si,Steer:Si,ask:ms,Ask:ms,AskUser:ms,WebSearch:Br,WebScrape:Ur,ReadFile:Hr,ReadFolder:zr,WriteFile:jr,PatchFile:Kr,WritePDF:qr,WriteDoc:Yr,Run:Vr,SearchKeyword:xi,CodeSearch:xi,code_search:xi,Memory:Wr,Chat:Gr,GenerateImage:Xr,saveSumary:wi,SaveSummary:wi,SaveSumary:wi,add_mem_score:Uo,AddMemScore:Uo,addMemoryScore:Uo,AddMemoryScore:Uo,FileMap:Jr,answer:Go,Answer:Go,AnswerSubagent:Go,await:Wo,Await:Wo,AwaitSubagent:Wo,EmergencyRollback:ea,emergency_rollback:ea,find_file:Ti,findFile:Ti,FindFile:Ti,findfile:Ti,wait:ia,Wait:ia},xs=async(e,t,n={})=>{let s=n.mode?n.mode.toLowerCase():"flux",o=e.toLowerCase(),d=["memory","chat","savesummary","addmemscore","add_mem_score","ask","web_search","web_scrape","await","wait"].some(h=>o.includes(h))||o==="ask",m=["click","drag","scroll","keyboardtyping","keyboard_typing","keypress","key_press","recapturescreen","recapture_screen","computer","wait"].some(h=>o.includes(h));if(!d){if(s==="flow"){if(!(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image")))return`ERROR: Action [${e}] is a Workspace Tool and NOT available in Flow mode. Tell user to switch (\`/mode flux\`) to use this tool.`}else if(s==="icu"){if(!m)return`ERROR: Action [${e}] is not available in Computer Use mode. ICU mode only supports Computer Use tools (Click, Drag, Scroll, KeyboardTyping, KeyPress, RecaptureScreen).`}else if(o.includes("write_pdf")||o.includes("write_docx")||o.includes("generate_image"))return`ERROR: Action [${e}] is not available in ${n.mode||"Flux"} mode. Tell user to switch (\`/mode flow\`) for document generation.`}let f=sa[e];if(!f){let h=["ReadFile","ReadFolder","FindFile","PatchFile","WriteFile","CodeSearch","Run","Goal","AskUser","WebSearch","WebScrape","WritePDF","WriteDoc","Click","Drag","Scroll","KeyboardTyping","KeyPress","RecaptureScreen","Wait","Invoke","InvokeSync","Await","GetProgress","Steer","Cancel","EmergencyRollback","Chat","Memory"],p={read:"ReadFile",view:"ReadFile",viewfile:"ReadFile",write:"WriteFile",edit:"PatchFile",patch:"PatchFile",update:"PatchFile",updatefile:"PatchFile",exec:"Run",command:"Run",bash:"Run",shell:"Run",powershell:"Run",search:"CodeSearch",grep:"CodeSearch",find:"FindFile",findfile:"FindFile",searchkeyword:"CodeSearch",folder:"ReadFolder",ls:"ReadFolder",dir:"ReadFolder",list:"ReadFolder",ask:"AskUser",question:"AskUser",pdf:"WritePDF",docx:"WriteDoc",doc:"WriteDoc",word:"WriteDoc",screenshot:"RecaptureScreen",screen:"RecaptureScreen",recapture:"RecaptureScreen",type:"KeyboardTyping",typing:"KeyboardTyping",keyboard:"KeyboardTyping",press:"KeyPress",key:"KeyPress",todo:"Goal",task:"Goal",subagent:"Invoke",agent:"Invoke"},g=o.replace(/[^a-z0-9]/g,""),i=p[g]||null;if(!i){let I=0,Xe=M=>{let F=new Set;for(let G=0;G<M.length-1;G++)F.add(M.slice(G,G+2));return F},C=Xe(g);for(let M of h){let F=M.toLowerCase().replace(/[^a-z0-9]/g,"");if(g===F){i=M;break}let G=0;(F.includes(g)||g.includes(F))&&(G+=.6);let $=Xe(F),L=0;for(let Ae of C)$.has(Ae)&&L++;let Te=2*L/(C.size+$.size||1);G=Math.max(G,Te),G>I&&G>=.35&&(I=G,i=M)}}let x=i?` Do you mean '${i}'?`:"";return`ERROR: Action [${e}] not found in registry.${x}`}try{return await(await f())(t,n)}catch(h){let p=h instanceof Error?h.message:String(h);return`ERROR: Execution failed for [${e}]: ${p}`}};var Ai=e=>{if(!e||typeof e!="string")return!1;let t=e.trim().toLowerCase();return Object.keys(sa).some(n=>n.toLowerCase()===t)};import U from"path";import we from"fs";import xa from"os";import wa from"crypto";import{execSync as As}from"child_process";import sl from"gradient-string";var ra=["I have a regex for your problems.","Your terminal, my kingdom.","Blowing on the cartridge helps. Probably.","Don't panic. I have the towel.","Logic is the start of wisdom.","Try to exit Vim? Good luck.","I speak fluent Terminal.","The cake is a lie. This code is not.","I have no bugs, just surprise features.","Rewriting in Rust... just for fun.","Coffee in, clean commits out.","The magic smoke stays inside today.","A semicolon short of a miracle.","One does not simply code without a bug.","Keep it simple. Keep it terminal.","Regex: now you have two problems.","I dream in binary.","Root access or bust.","Wait for the dial-up tone. Just kidding.","I take the 'labor' out of collab.","My other process is a TARDIS.","Calculated response: 42.","Ponder the orb. Ponder the code.","Less talk, more flow.","Elegance in every byte.","Build something the world is not ready for.","Your wishes, my tool calls.","I act in Flux. I think in Flow.","Syntax error in the universe. Please fix.","Your project, my obsession.","I am not a bot, I am an architect.","Digital spirits consulted. They say: Ship it.","Reticulate splines. Engage humor.","Code like poetry. Run like water.","Minimalism is the ultimate flex.","The truth is in the logs.","Follow the white rabbit.","There is no spoon. Only code.","Binary is the only language I trust.","I have a good feeling about this.","Pew pew! Lasers charged.","Divide by zero? Not today.","Search for the correct USB orientation...","I've got a fever, and the only cure is more code.","The code gremlins are on our side.","My favorite command? Yours.","Stay hungry. Stay active.","Momentum is your best friend.","Lead the flow. Don't chase it.","A fresh batch of bytes. Hot and ready.","I orchestrate the ones and zeros.","Smart enough to help. Humble enough to ask.","Think twice. Code once.","Pure intent. Pure execution.","Small steps. Massive impact.","Your terminal is a canvas.","Efficiency is my second name.","I have seen things you people wouldn't believe.","Let the thoughts marinate.","The best feature? The one you don't need.","Precision is the only perfection.","Stay focused. Stay terminal.","Silence is the best debugger.","Erase the debt. Commit the code.","Velocity meets stability.","Ship it. Improve it. Repeat.","Build tomorrow, right now.","Turn logic into reality.","The best way to predict the future is to build it.","Break barriers, not builds.","Fuel the next breakthrough.","Momentum is key.","Terminal vibes only.","Your digital co-pilot is ready.","Partner in code. Partner in crime.","I speak in semicolons.","Ready for the next great idea.","Just a moment. In the zone.","Polishing the algorithms. Hold tight.","Craft a masterpiece today.","Debug the universe. Start here.","Warp speed engaged. Almost.","The cake is not a lie. It's just loading.","Finish the Kessel Run in 12 parsecs.","Do a barrel roll!","Waiting for the respawn.","Press Start to continue.","Herding digital cats... done.","The hamsters are fast today.","Tasting the snozberries.","I go for speed. I go for flow.","Real life or just fantasy?","Poking the bear... gently.","Ensure the magic smoke stays inside.","Try turning it off and on again.","Construct additional pylons.","New line? Ctrl+J is your friend.","Release the HypnoDrones.","Push the button, Frank.","My other loading screen is even funnier.","Pretty sure a cat walked on my keyboard.","Recalibrate the humor-o-meter.","Summon the code gremlins.","I've seen your browser history. Just kidding.","Charge the laser... pew pew!","Dividing by zero... just for a sec.","Looking for an adult supervisor. Found none.","Make it go beep boop.","Buffering... for effect.","Entangle quantum particles... complete.","Polishing the chrome on my algorithms.","Are you not entertained?","Just waiting for the dial-up tone.","Reboot the humor module.","Defragment memories. Check.","Optimizing for ludicrous speed.","Swapping bits. Don't tell the bytes.","Garbage collected. I am back.","Assembling the interwebs.","Converting coffee to logic.","Update syntax for reality.","Rewire the synapses.","Greasin' the cogs.","Engage the improbability drive.","Channel the Force.","Align the stars. Respond now.","The cake is a lie. The prompt is real.","I'm Feeling Lucky.","Shipping awesomeness.","Navigating the slime mold.","Consult digital spirits.","Ask the magic conch shell.","One moment. Optimizing humor.","Shuffling punchlines.","Compiling brilliance.","Summon the cloud of wisdom.","Prepare to dazzle.","Hold tight. Crafting a response.","Tuning the algorithms.","Following the white rabbit... again.","The truth is in here. Somewhere.","Herding cats is my day job.","Distracting you with this phrase.","Almost there. Probably.","Rickrolling my creator. Don't tell.","Slapping the bass.","Is this real life?","Ponder the orb. Type the prompt.","Thoughtful gaze initiated.","Computer's favorite snack? Microchips.","Why Java? Because I don't C#.","Charging the laser... wait for it.","Dividing by zero... just kidding!","Adult supervision not found. Proceed.","Beep boop. I'm a real boy.","Wait for the respawn.","Finish the run. Ship the code.","Fiddling with character creation.","Just a moment. Finding a meme.","Pressing A to continue.","Loading wit.exe.","Pre-heating the servers.","Calibrate flux capacitor.","Channeling the Force.","Aligning the stars.","The truth is in the code.","Don't panic.","Blowing on the cartridge.","Doing a barrel roll!","Respawning in 3... 2... 1...","The cake is a lie.","Fiddling with character settings.","Finding a suitable pun.","Distracting with wit.","Almost ready.","Hamsters on speed today.","Patting Cloudy on the head.","Rickrolling the logs.","Slapping the code.","Got a good feeling about this.","Poking the prompt.","Researching latest memes.","Making it more witty.","Thinking... hmmm.","Fish with no eyes? Fsh.","Broken pencil? Pointless.","Percussive maintenance applied.","USB orientation: 3rd try's the charm.","Rust rewrite in 3... 2...","Exiting Vim... someday.","Spinning the hamster wheel.","Not a bug. Unplanned feature.","Engage.","I'll be back.","Machine spirit consulted.","Letting the thoughts marinate.","Orb pondered.","Thoughtful gaze engaged.","Charging the laser...","Making it go beep.","Buffering...","Quantum particles entangled.","Polishing the chrome.","Entertained yet?","Gremlins summoned.","Dial-up tone finished.","Humor meter recalibrated.","Cat on keyboard. Sending help.","Enhancing...","Turn it off and on again.","Constructing pylons.","HypnoDrones released.","Pushing the button."];var aa=["Beware the phantom processes.","A ghost in the shell has taken the wheel.","Blowing on the haunted cartridge...","Seven minutes in Raccoon City.","Wind's howling... in the terminal fans.","Slender Man was spotted in line 404.","The cake is a lie. The curse is real.","Don't look behind the server rack.","Exorcising memory leaks at 3 AM.","Pyramid Head reorganized your commit history.","It's dangerous to go alone! Take this flashlight.","YOU DIED. Respawning terminal session...","The Necronomicon evaluated to true.","Something wicked this way compiles.","Haunting your localhost with good vibes.","A full moon has risen over Git main.","Double, double toil and trouble; code fire burn.","Clickers heard in the directory tree.","Checking camera 2B for rogue animatronics.","The call is coming from inside the container.","Isaac Clarke is stomping on stubborn bugs.","Luigi vacuumed the ghosts out of RAM.","Trick or treat, give me clean code to greet.","Whispering incantations to the garbage collector.","Klaatu barada necktie... close enough.","Resurrecting deprecated APIs from the crypt.","The headless horseman forgot the return statement.","Castlevania whip cracking against network latency.","Slime mold crawling through the motherboard.","Carving a pixelated pumpkin into terminal history.","Burying undefined pointers in the pet sematary.","Spilling pumpkin spice on the CPU.","A vampire bat is draining system battery life.","Don't fall asleep at the keyboard tonight.","Silent Hill sirens sounding in the console.","Poltergeists rearranging terminal tabs.","Lighting the Black Flame Candle for autoExec.","Dusting cobwebs off legacy dependencies.","Here's Johnny! ...just checking build health.","Blood, sweat, and zero warnings.","The spirit box whispers: 'GIT PUSH FORCE'.","They're heeeere... in the stack trace.","It's alive! IT'S ALIVEEEE!","No merge conflicts in the graveyard.","Frankenstein's monster patched this logic.","Surviving Five Nights at Flux Flow.","Doom Slayer loading buckshot into cache.","The grim reaper spared your unused imports.","Candy corn lodged in mechanical switches.","May your latency be low and your crypt be quiet."];var la=[{name:"Cyan Cyberpunk",text:"cyan",textMuted:"#4da6b8",textDim:"#2d6d7a",textInverted:"black",border:"cyan",borderMuted:"#1a5966",borderDim:"#0f3840",bg:void 0,cardBg:"#061e24",highlightBg:"#092b33",activeBg:"#0e3e4a",inputBg:"#092b33",inputBorder:"#092b33",inputText:"cyan",inputPlaceholder:"#2d6d7a",inputPrompt:"cyan",codeBg:"#020d10",codeBorder:"#1a5966",userMsgBg:"#092b33",userMsgBorder:"#092b33",userMsgText:"cyan",diffRemovalBg:"#3a0c1a",diffAdditionBg:"#0c3a32",diffRemovalText:"#ff4d88",diffAdditionText:"#00ffaa",diffRemovalHighlightColor:"#ff1a66",diffRemovalHighlightBg:"#590022",diffAdditionHighlightColor:"#00ffcc",diffAdditionHighlightBg:"#00593b",diffRemovalNum:"#ff4d88",diffAdditionNum:"#00ffaa",diffRemovalPrefix:"#ff1a66",diffAdditionPrefix:"#00ffcc",primary:"cyan",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"cyan",statusOff:"#2d6d7a",logoTextAnsi:"\x1B[1;36m",logoBodyAnsi:"\x1B[36m",logoMutedAnsi:"\x1B[90m",logoGradient:["#00ffff","#0088ff"]},{name:"Magenta Vaporwave",text:"magenta",textMuted:"#c451d6",textDim:"#7d2b8a",textInverted:"black",border:"magenta",borderMuted:"#5e1b69",borderDim:"#3b0f42",bg:void 0,cardBg:"#240729",highlightBg:"#310938",activeBg:"#470e52",inputBg:"#310938",inputBorder:"#310938",inputText:"magenta",inputPlaceholder:"#7d2b8a",inputPrompt:"magenta",codeBg:"#100312",codeBorder:"#5e1b69",userMsgBg:"#310938",userMsgBorder:"#310938",userMsgText:"magenta",diffRemovalBg:"#3a0c20",diffAdditionBg:"#200c3a",diffRemovalText:"#ff4d94",diffAdditionText:"#aa4dff",diffRemovalHighlightColor:"#ff1a75",diffRemovalHighlightBg:"#59002b",diffAdditionHighlightColor:"#bb66ff",diffAdditionHighlightBg:"#3b0059",diffRemovalNum:"#ff4d94",diffAdditionNum:"#aa4dff",diffRemovalPrefix:"#ff1a75",diffAdditionPrefix:"#bb66ff",primary:"magenta",secondary:"cyan",accent:"purple",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"magenta",statusOff:"#7d2b8a",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ff00ff","#8800ff"]},{name:"Glitch Matrix",text:"#00ff41",textMuted:"#00b32d",textDim:"#00661a",textInverted:"black",border:"#00ff41",borderMuted:"#008020",borderDim:"#004d13",bg:void 0,cardBg:"#0d1f0d",highlightBg:"#122912",activeBg:"#1c3e1c",inputBg:"#122912",inputBorder:"#122912",inputText:"#00ff41",inputPlaceholder:"#00b32d",inputPrompt:"#ffff00",codeBg:"#040a04",codeBorder:"#008020",userMsgBg:"#122912",userMsgBorder:"#122912",userMsgText:"#00ff41",diffRemovalBg:"#3a001a",diffAdditionBg:"#003a10",diffRemovalText:"#ff0055",diffAdditionText:"#00ff66",diffRemovalHighlightColor:"#ff0033",diffRemovalHighlightBg:"#59001b",diffAdditionHighlightColor:"#33ff88",diffAdditionHighlightBg:"#005918",diffRemovalNum:"#ff0055",diffAdditionNum:"#00ff66",diffRemovalPrefix:"#ff0033",diffAdditionPrefix:"#33ff88",primary:"#00ff41",secondary:"yellow",accent:"cyan",success:"#00ff41",warning:"yellow",danger:"red",info:"cyan",statusOn:"#00ff41",statusOff:"#00661a",logoTextAnsi:"\x1B[1;32m",logoBodyAnsi:"\x1B[32m",logoMutedAnsi:"\x1B[90m",logoGradient:["#00ff41","#ffff00"]},{name:"Warm Sunset",text:"#ffaa55",textMuted:"#cc8844",textDim:"#885522",textInverted:"black",border:"#ff9933",borderMuted:"#aa6622",borderDim:"#663311",bg:void 0,cardBg:"#24180f",highlightBg:"#2e1e12",activeBg:"#422c1b",inputBg:"#2e1e12",inputBorder:"#2e1e12",inputText:"#ffaa55",inputPlaceholder:"#885522",inputPrompt:"#ff7733",codeBg:"#120c08",codeBorder:"#aa6622",userMsgBg:"#2e1e12",userMsgBorder:"#2e1e12",userMsgText:"#ffaa55",diffRemovalBg:"#3d120c",diffAdditionBg:"#3a2e0c",diffRemovalText:"#ff5544",diffAdditionText:"#ffcc33",diffRemovalHighlightColor:"#ff3322",diffRemovalHighlightBg:"#591108",diffAdditionHighlightColor:"#ffee44",diffAdditionHighlightBg:"#594400",diffRemovalNum:"#ff5544",diffAdditionNum:"#ffcc33",diffRemovalPrefix:"#ff3322",diffAdditionPrefix:"#ffee44",primary:"#ffaa55",secondary:"#ff7733",accent:"magenta",success:"#ffcc33",warning:"#ff7733",danger:"#ff3322",info:"#ffaa55",statusOn:"#ffaa55",statusOff:"#885522",logoTextAnsi:"\x1B[1;33m",logoBodyAnsi:"\x1B[33m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ff9933","#ff0055"]},{name:"Sakura Blossom",text:"#ffc0e0",textMuted:"#d98cb3",textDim:"#804d66",textInverted:"black",border:"#ff99cc",borderMuted:"#aa4d7a",borderDim:"#662647",bg:void 0,cardBg:"#291320",highlightBg:"#331826",activeBg:"#472235",inputBg:"#331826",inputBorder:"#331826",inputText:"#ffc0e0",inputPlaceholder:"#804d66",inputPrompt:"#ff99cc",codeBg:"#140a10",codeBorder:"#aa4d7a",userMsgBg:"#331826",userMsgBorder:"#331826",userMsgText:"#ffc0e0",diffRemovalBg:"#3e0c1b",diffAdditionBg:"#1b3e2b",diffRemovalText:"#ff6699",diffAdditionText:"#66ffb3",diffRemovalHighlightColor:"#ff3377",diffRemovalHighlightBg:"#590022",diffAdditionHighlightColor:"#33ff99",diffAdditionHighlightBg:"#00592e",diffRemovalNum:"#ff6699",diffAdditionNum:"#66ffb3",diffRemovalPrefix:"#ff3377",diffAdditionPrefix:"#33ff99",primary:"#ffc0e0",secondary:"#ff99cc",accent:"magenta",success:"#66ffb3",warning:"yellow",danger:"#ff3377",info:"#ff99cc",statusOn:"#ffc0e0",statusOff:"#804d66",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ffb3d9","#ff3399"]},{name:"Radioactive Slime",text:"#ccff00",textMuted:"#99cc00",textDim:"#669900",textInverted:"#0a0f00",border:"#ccff00",borderMuted:"#99cc00",borderDim:"#669900",bg:void 0,cardBg:"#0f1400",highlightBg:"#1a2400",activeBg:"#2a3b00",inputBg:"#1a2400",inputBorder:"#1a2400",inputText:"#ccff00",inputPlaceholder:"#669900",inputPrompt:"#cc00ff",codeBg:"#050a00",codeBorder:"#99cc00",userMsgBg:"#1a2400",userMsgBorder:"#1a2400",userMsgText:"#ccff00",diffRemovalBg:"#2a0033",diffAdditionBg:"#0f3300",diffRemovalText:"#ff00cc",diffAdditionText:"#00ff33",diffRemovalHighlightColor:"#ff33cc",diffRemovalHighlightBg:"#4d0066",diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:"#1a6600",diffRemovalNum:"#ff00cc",diffAdditionNum:"#00ff33",diffRemovalPrefix:"#ff33cc",diffAdditionPrefix:"#33ff66",primary:"#ccff00",secondary:"#cc00ff",accent:"#ff00cc",success:"#00ff33",warning:"#ffcc00",danger:"#ff0033",info:"#00ccff",statusOn:"#ccff00",statusOff:"#669900",logoTextAnsi:"\x1B[1;38;5;190m",logoBodyAnsi:"\x1B[38;5;190m",logoMutedAnsi:"\x1B[90m",logoGradient:["#ccff00","#cc00ff"]},{name:"Cosmic Void",text:"#f0f8ff",textMuted:"#a6aeb5",textDim:"#5e656e",textInverted:"#010103",border:"#f0f8ff",borderMuted:"#a6aeb5",borderDim:"#5e656e",bg:void 0,cardBg:"#05030d",highlightBg:"#0b081a",activeBg:"#171133",inputBg:"#0b081a",inputBorder:"#0b081a",inputText:"#f0f8ff",inputPlaceholder:"#5e656e",inputPrompt:"#ff007f",codeBg:"#020108",codeBorder:"#a6aeb5",userMsgBg:"#0b081a",userMsgBorder:"#0b081a",userMsgText:"#f0f8ff",diffRemovalBg:"#2e0a29",diffAdditionBg:"#091c33",diffRemovalText:"#ff33a6",diffAdditionText:"#33d6ff",diffRemovalHighlightColor:"#ff66c2",diffRemovalHighlightBg:"#5c1452",diffAdditionHighlightColor:"#66e0ff",diffAdditionHighlightBg:"#123866",diffRemovalNum:"#ff33a6",diffAdditionNum:"#33d6ff",diffRemovalPrefix:"#ff66c2",diffAdditionPrefix:"#66e0ff",primary:"#f0f8ff",secondary:"#ff007f",accent:"#9d00ff",success:"#33d6ff",warning:"#ffcc00",danger:"#ff0040",info:"#9d00ff",statusOn:"#f0f8ff",statusOff:"#5e656e",logoTextAnsi:"\x1B[1;38;5;231m",logoBodyAnsi:"\x1B[38;5;231m",logoMutedAnsi:"\x1B[38;5;240m",logoGradient:["#ffffff","#9d00ff"]},{name:"Magma Eruption",text:"#ff4d00",textMuted:"#cc3d00",textDim:"#802600",textInverted:"#0d0300",border:"#ff4d00",borderMuted:"#cc3d00",borderDim:"#802600",bg:void 0,cardBg:"#1a0600",highlightBg:"#260a00",activeBg:"#401100",inputBg:"#260a00",inputBorder:"#260a00",inputText:"#ff4d00",inputPlaceholder:"#802600",inputPrompt:"#ffcc00",codeBg:"#080200",codeBorder:"#cc3d00",userMsgBg:"#260a00",userMsgBorder:"#260a00",userMsgText:"#ff4d00",diffRemovalBg:"#2e0a0a",diffAdditionBg:"#1f1400",diffRemovalText:"#ff3333",diffAdditionText:"#ffaa00",diffRemovalHighlightColor:"#ff6666",diffRemovalHighlightBg:"#5c1414",diffAdditionHighlightColor:"#ffcc33",diffAdditionHighlightBg:"#3d2900",diffRemovalNum:"#ff3333",diffAdditionNum:"#ffaa00",diffRemovalPrefix:"#ff6666",diffAdditionPrefix:"#ffcc33",primary:"#ff4d00",secondary:"#ffcc00",accent:"#ff0040",success:"#ffaa00",warning:"#ffff00",danger:"#ff0000",info:"#ff8800",statusOn:"#ff4d00",statusOff:"#802600",logoTextAnsi:"\x1B[1;38;5;202m",logoBodyAnsi:"\x1B[38;5;202m",logoMutedAnsi:"\x1B[38;5;236m",logoGradient:["#ff4d00","#ff0000"]}],xo={Dark:{id:"Dark",name:"Dark (Default)",text:"white",textMuted:"gray",textDim:"grey",textInverted:"black",textExclusive:"#B5B8D9",textMutedExclusive:"#D4DEE7",border:"white",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:"#1e1e1e",highlightBg:"#2a2a2a",activeBg:"#3a3a3a",inputBg:"#555555",inputBorder:"#555555",inputText:"white",inputPlaceholder:"#cccccc",inputPrompt:"white",codeBg:"#1a1a1a",codeBorder:"#444444",userMsgBg:"#444444",userMsgBorder:"#444444",userMsgText:"white",diffRemovalBg:"#250808",diffAdditionBg:"#072410",diffRemovalText:"#885555",diffAdditionText:"#558866",diffRemovalHighlightColor:"#ff3333",diffRemovalHighlightBg:"#5a1818",diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:"#185a25",diffRemovalNum:"#d96868",diffAdditionNum:"#68d98c",diffRemovalPrefix:"#ff4d4d",diffAdditionPrefix:"#4dff88",primary:"white",secondary:"cyan",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"white",statusOff:"gray",logoTextAnsi:"\x1B[1;37m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},Light:{id:"Light",name:"Light",text:"black",textMuted:"gray",textDim:"grey",textInverted:"white",border:"black",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:"#e5e5e5",highlightBg:"#d4d4d4",activeBg:"#c0c0c0",inputBg:"#d0d0d0",inputBorder:"#d0d0d0",inputText:"black",inputPlaceholder:"#555555",inputPrompt:"black",codeBg:"#e8e8e8",codeBorder:"#b0b0b0",userMsgBg:"#d0d0d0",userMsgBorder:"#d0d0d0",userMsgText:"black",diffRemovalBg:"#fce8e8",diffAdditionBg:"#e6f9e6",diffRemovalText:"#661111",diffAdditionText:"#115511",diffRemovalHighlightColor:"#440000",diffRemovalHighlightBg:"#f8b4b4",diffAdditionHighlightColor:"#003300",diffAdditionHighlightBg:"#a6ebad",diffRemovalNum:"#c02020",diffAdditionNum:"#188028",diffRemovalPrefix:"#d01010",diffAdditionPrefix:"#109020",primary:"black",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"black",statusOff:"gray",logoTextAnsi:"\x1B[1;30m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},"GitHub Dark":{id:"GitHub Dark",name:"GitHub Dark",text:"#c9d1d9",textMuted:"#8b949e",textDim:"#6e7681",textInverted:"#0d1117",border:"#30363d",borderMuted:"#30363d",borderDim:"#21262d",bg:void 0,cardBg:"#161b22",highlightBg:"#21262d",activeBg:"#30363d",inputBg:"#21262d",inputBorder:"#21262d",inputText:"#c9d1d9",inputPlaceholder:"#8b949e",inputPrompt:"#58a6ff",codeBg:"#0d1117",codeBorder:"#30363d",userMsgBg:"#21262d",userMsgBorder:"#21262d",userMsgText:"#c9d1d9",diffRemovalBg:"#3c1e1e",diffAdditionBg:"#11381e",diffRemovalText:"#f85149",diffAdditionText:"#3fb950",diffRemovalHighlightColor:"#ff7b72",diffRemovalHighlightBg:"#701c1c",diffAdditionHighlightColor:"#56d364",diffAdditionHighlightBg:"#116329",diffRemovalNum:"#f85149",diffAdditionNum:"#3fb950",diffRemovalPrefix:"#f85149",diffAdditionPrefix:"#3fb950",primary:"#c9d1d9",secondary:"#58a6ff",accent:"#bc8cff",success:"#3fb950",warning:"#d29922",danger:"#f85149",info:"#58a6ff",statusOn:"#58a6ff",statusOff:"#8b949e",logoTextAnsi:"\x1B[1;36m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#2ea043","#56d364"],toolFeedbackAnsi:"\x1B[95m"},"GitHub Light":{id:"GitHub Light",name:"GitHub Light",text:"#24292f",textMuted:"#57606a",textDim:"#6e7781",textInverted:"#ffffff",border:"#d0d7de",borderMuted:"#d0d7de",borderDim:"#e1e4e8",bg:void 0,cardBg:"#f6f8fa",highlightBg:"#eaeef2",activeBg:"#d0d7de",inputBg:"#eaeef2",inputBorder:"#eaeef2",inputText:"#24292f",inputPlaceholder:"#57606a",inputPrompt:"#0969da",codeBg:"#ffffff",codeBorder:"#d0d7de",userMsgBg:"#eaeef2",userMsgBorder:"#eaeef2",userMsgText:"#24292f",diffRemovalBg:"#ffebe9",diffAdditionBg:"#e6ffec",diffRemovalText:"#cf222e",diffAdditionText:"#1a7f37",diffRemovalHighlightColor:"#82071e",diffRemovalHighlightBg:"#ffc1c0",diffAdditionHighlightColor:"#116329",diffAdditionHighlightBg:"#acf2bd",diffRemovalNum:"#cf222e",diffAdditionNum:"#1a7f37",diffRemovalPrefix:"#cf222e",diffAdditionPrefix:"#1a7f37",primary:"#24292f",secondary:"#0969da",accent:"#8250df",success:"#1a7f37",warning:"#9a6700",danger:"#cf222e",info:"#0969da",statusOn:"#0969da",statusOff:"#57606a",logoTextAnsi:"\x1B[1;34m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#1a7f37","#2da44e"],toolFeedbackAnsi:"\x1B[95m"},"Transparent Dark":{id:"Transparent Dark",name:"Transparent Dark",text:"white",textMuted:"gray",textDim:"grey",textInverted:"black",border:"gray",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:void 0,highlightBg:"#2a2a2a",activeBg:"#3a3a3a",inputBg:"#555555",inputBorder:"#555555",inputText:"white",inputPlaceholder:"#cccccc",inputPrompt:"white",codeBg:void 0,codeBorder:"gray",userMsgBg:"#555555",userMsgBorder:"#555555",userMsgText:"white",diffRemovalBg:void 0,diffAdditionBg:void 0,diffRemovalText:"#ff6666",diffAdditionText:"#66ff66",diffRemovalHighlightColor:"#ff3333",diffRemovalHighlightBg:"#3a1414",diffAdditionHighlightColor:"#33ff66",diffAdditionHighlightBg:"#143a14",diffRemovalNum:"#ff6666",diffAdditionNum:"#66ff66",diffRemovalPrefix:"#ff4d4d",diffAdditionPrefix:"#4dff88",primary:"white",secondary:"cyan",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"white",statusOff:"gray",logoTextAnsi:"\x1B[1;37m",logoBodyAnsi:"\x1B[37m",logoMutedAnsi:"\x1B[90m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},"Transparent Light":{id:"Transparent Light",name:"Transparent Light",text:"black",textMuted:"gray",textDim:"grey",textInverted:"white",border:"gray",borderMuted:"gray",borderDim:"grey",bg:void 0,cardBg:void 0,highlightBg:"#d4d4d4",activeBg:"#c0c0c0",inputBg:"#d0d0d0",inputBorder:"#d0d0d0",inputText:"black",inputPlaceholder:"#555555",inputPrompt:"black",codeBg:void 0,codeBorder:"gray",userMsgBg:"#d0d0d0",userMsgBorder:"#d0d0d0",userMsgText:"black",diffRemovalBg:void 0,diffAdditionBg:void 0,diffRemovalText:"#c02020",diffAdditionText:"#188028",diffRemovalHighlightColor:"#800000",diffRemovalHighlightBg:"#f5d0d0",diffAdditionHighlightColor:"#004000",diffAdditionHighlightBg:"#cceccc",diffRemovalNum:"#c02020",diffAdditionNum:"#188028",diffRemovalPrefix:"#d01010",diffAdditionPrefix:"#109020",primary:"black",secondary:"blue",accent:"magenta",success:"green",warning:"yellow",danger:"red",info:"blue",statusOn:"black",statusOff:"gray",logoTextAnsi:"\x1B[1;30m",logoBodyAnsi:"\x1B[30m",logoMutedAnsi:"\x1B[38;5;244m",logoGradient:["#0077ff","#ff00ff"],toolFeedbackAnsi:"\x1B[95m"},"Synthwave 84":{id:"Synthwave 84",name:"Synthwave 84",text:"#fdfdfd",textMuted:"#a08eb7",textDim:"#705c8a",textInverted:"#1a1025",textExclusive:"#e3dcf0",textMutedExclusive:"#b9abc9",border:"#fc28a8",borderMuted:"#a21568",borderDim:"#5c0a3a",bg:void 0,cardBg:"#261b38",highlightBg:"#35254d",activeBg:"#4c3570",inputBg:"#35254d",inputBorder:"#35254d",inputText:"#fdfdfd",inputPlaceholder:"#a08eb7",inputPrompt:"#03e8fc",codeBg:"#1e142b",codeBorder:"#a21568",userMsgBg:"#35254d",userMsgBorder:"#35254d",userMsgText:"#fdfdfd",diffRemovalBg:"#471434",diffAdditionBg:"#144743",diffRemovalText:"#ff4081",diffAdditionText:"#00e5ff",diffRemovalHighlightColor:"#ff79a1",diffRemovalHighlightBg:"#6b1e4e",diffAdditionHighlightColor:"#66f5ff",diffAdditionHighlightBg:"#1e6b65",diffRemovalNum:"#ff4081",diffAdditionNum:"#00e5ff",diffRemovalPrefix:"#ff79a1",diffAdditionPrefix:"#66f5ff",primary:"#fdfdfd",secondary:"#03e8fc",accent:"#fc28a8",success:"#00e5ff",warning:"#ffc107",danger:"#ff4081",info:"#b388ff",statusOn:"#03e8fc",statusOff:"#a08eb7",logoTextAnsi:"\x1B[1;35m",logoBodyAnsi:"\x1B[35m",logoMutedAnsi:"\x1B[90m",logoGradient:["#fc28a8","#03e8fc"],toolFeedbackAnsi:"\x1B[38;2;3;232;252m"},"Forest Sprite":{id:"Forest Sprite",name:"Forest Sprite",text:"#d6e6d1",textMuted:"#95b38d",textDim:"#628059",textInverted:"#161c14",textExclusive:"#eaf2e8",textMutedExclusive:"#a9c7a2",border:"#74a862",borderMuted:"#477038",borderDim:"#2b4720",bg:void 0,cardBg:"#1f291c",highlightBg:"#2a3826",activeBg:"#3a4d35",inputBg:"#2a3826",inputBorder:"#2a3826",inputText:"#d6e6d1",inputPlaceholder:"#95b38d",inputPrompt:"#8feb73",codeBg:"#161e14",codeBorder:"#477038",userMsgBg:"#2a3826",userMsgBorder:"#2a3826",userMsgText:"#d6e6d1",diffRemovalBg:"#3b231c",diffAdditionBg:"#203b1c",diffRemovalText:"#db6242",diffAdditionText:"#59cc3f",diffRemovalHighlightColor:"#f0896c",diffRemovalHighlightBg:"#5c362a",diffAdditionHighlightColor:"#80e368",diffAdditionHighlightBg:"#305929",diffRemovalNum:"#db6242",diffAdditionNum:"#59cc3f",diffRemovalPrefix:"#f0896c",diffAdditionPrefix:"#80e368",primary:"#d6e6d1",secondary:"#8feb73",accent:"#e69835",success:"#59cc3f",warning:"#e69835",danger:"#db6242",info:"#73b4eb",statusOn:"#8feb73",statusOff:"#95b38d",logoTextAnsi:"\x1B[1;32m",logoBodyAnsi:"\x1B[32m",logoMutedAnsi:"\x1B[90m",logoGradient:["#8feb73","#e69835"],toolFeedbackAnsi:"\x1B[38;2;143;235;115m"},Spookfest:{id:"Spookfest",name:"Spookfest \u{1F383}",text:"#ffeedd",textMuted:"#e09858",textDim:"#a6622b",textInverted:"#0d0702",textExclusive:"#fff3e6",textMutedExclusive:"#d4a276",border:"#ff7518",borderMuted:"#994409",borderDim:"#592502",bg:void 0,cardBg:"#1a0c02",highlightBg:"#2a1403",activeBg:"#3d1d05",inputBg:"#261203",inputBorder:"#261203",inputText:"#ffeedd",inputPlaceholder:"#a6622b",inputPrompt:"#ff7518",codeBg:"#120701",codeBorder:"#592502",userMsgBg:"#261203",userMsgBorder:"#261203",userMsgText:"#ffeedd",diffRemovalBg:"#3d0a0a",diffAdditionBg:"#1a330a",diffRemovalText:"#ff5555",diffAdditionText:"#73e639",diffRemovalHighlightColor:"#ff2222",diffRemovalHighlightBg:"#590e0e",diffAdditionHighlightColor:"#88ff3b",diffAdditionHighlightBg:"#244d0a",diffRemovalNum:"#ff5555",diffAdditionNum:"#73e639",diffRemovalPrefix:"#ff3333",diffAdditionPrefix:"#88ff3b",primary:"#ff7518",secondary:"#a855f7",accent:"#22c55e",success:"#22c55e",warning:"#f59e0b",danger:"#ef4444",info:"#a855f7",statusOn:"#ff7518",statusOff:"#703a08",logoTextAnsi:"\x1B[1;38;2;255;117;24m",logoBodyAnsi:"\x1B[38;2;255;140;26m",logoMutedAnsi:"\x1B[38;2;168;85;247m",logoGradient:["#ff7518","#a855f7"],toolFeedbackAnsi:"\x1B[38;2;255;117;24m"}};var Ci=null;var Ri=(e="Dark")=>{let t;e==="Mystery"||e==="Chaos"?(Ci||(Ci=la[Math.floor(Math.random()*la.length)]),t={...Ci,id:"Mystery"}):(Ci=null,xo[e]?t=xo[e]:e==="Halloween"?t=xo.Spookfest:e==="GitHub"?t=xo["GitHub Dark"]:e==="Transparent"?t=xo["Transparent Dark"]:t=xo.Dark);let n=t.codeText||t.secondary||t.info||t.logoGradient&&t.logoGradient[0]||"cyan",s=t.toolFeedbackAnsi||"\x1B[95m";return{...t,codeText:n,toolFeedbackAnsi:s}};var rl=()=>process.env.TERM_PROGRAM==="vscode"?"vscode":process.env.WT_SESSION?"wt":"default",td=(e=2)=>{let t=rl();return t==="wt"?" ".repeat(Math.max(1,e-1)):" ".repeat(e)},ca=new Date,Ho=ca.getMonth(),jo=ca.getDate(),al=Ho===9&&jo>=15||Ho===10&&jo<=1,ws=null;(process.env.SPOOKFEST==="true"||al)&&(ws=await import("./halloween-MX3VNQRW.js"));var nd=(e="...",t="Loading...",n="Dark")=>{let s=Ri(n),o=t;if(t==="c_openai"||t==="Custom (OpenAI)")try{let G=ri(oi,{})?.systemSettings?.customOpenAIBaseUrl;G&&(o=G)}catch{}let r=s.logoTextAnsi,d=s.logoBodyAnsi,a=s.logoMutedAnsi,m="\x1B[0m",f=[" \u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2591\u2591\u2591\u2588\u2588\u2588 "," \u2588\u2588\u2588\u2591 "," \u2588\u2588\u2588\u2591 "," \u2588\u2588\u2588\u2591 "," \u2591\u2591\u2591 "],h=n==="Spookfest"||s.id==="Spookfest"||n==="Halloween"||s.id==="Halloween",p=Ho===9&&jo>=15||Ho===10&&jo<=1,g=h&&p||process.env.SPOOKFEST==="true"&&h,i=f;if(g&&ws){process.env.HALLOWEEN_EEGG="true";let{halloweenArtSide:F,halloweenBat:G,halloweenArtUser:$}=ws;i=Math.random()>.9&&Ho===9&&jo>=30?G:Math.random()>.5?F:$}else process.env.HALLOWEEN_EEGG="false";let x=g?aa:ra,I=x[Math.floor(Math.random()*x.length)],Xe=s.logoGradient||["#0077ff","#ff00ff"],C=sl(Xe).multiline(i.join(`
530
534
  `)).split(`
531
- `),P=F=>`${l}${F}${m}`;return`${C[0]}
535
+ `),M=F=>`${a}${F}${m}`;return`${C[0]}
532
536
  ${C[1]} ${r}Selected ${g?"Pumpkin":"Provider"}: ${o}${m}
533
537
  ${C[2]}
534
- ${C[3]} ${r}FluxFlow${g?": Spookfest":""} ${P("v"+e)}${m}
538
+ ${C[3]} ${r}FluxFlow${g?": Spookfest":""} ${M("v"+e)}${m}
535
539
  ${C[4]}
536
540
  ${C[5]} ${d}See /help for additional commands.${m}
537
- ${C[6]} ${P(I)}
541
+ ${C[6]} ${M(I)}
538
542
  ${C[7]}
539
- `};import{structuredPatch as ul}from"diff";import bs from"path";import ll from"fs";var cl=e=>{try{return ll.readdirSync(e,{withFileTypes:!0})}catch{return[]}},Ss=(e,t=4,n=1,i=cl,o=[],r=null)=>{let d=r||i(e),l=" ".repeat(n-1),m=n===1?new Set([..._o,...o,...Io(e),...Io(process.cwd())]):o instanceof Set?o:new Set([..._o,...o]),f=$=>m.has($),h=d.filter($=>!f($.name)),p=d.filter($=>f($.name)).length,g=h.filter($=>!$.isDirectory()).map($=>$.name).sort(),s=h.filter($=>$.isDirectory()).sort(($,L)=>$.name.localeCompare(L.name)),x=$=>{let L=$.length;if(L===0)return"no files";let Te=Array.from(new Set($.map(Ne=>{let et=typeof Ne=="string"?Ne:Ne.name;return bs.extname(et).slice(1)}).filter(Boolean))).sort(),Ae="*";return Te.length===1?Ae=`*.${Te[0]}`:Te.length>1&&(Ae=`*.{${Te.join(", ")}}`),L===1?Ae:`${Ae} ${L} files`},I="";if(n===1){let $=g.join(", "),L=p>0?` [${p} ignored]`:"";($||L)&&(I+=`${l}${$?$+(L?`${L}`:""):L.trim()}
540
- `)}else g.length>0&&(I+=`${l}[${x(g)}]
541
- `);let Xe=10,C=s.slice(0,Xe),P=s.length>Xe,F=[],G=[];for(let $ of C){let L=bs.join(e,$.name),Te=$.name,Ae=n,Ne=i(L),et=Ne.filter(he=>!f(he.name)),U=et.filter(he=>he.isDirectory()),w=et.filter(he=>!he.isDirectory());for(;w.length===0&&U.length===1&&Ae<t;)Te=`${Te}/${U[0].name}`,L=bs.join(L,U[0].name),Ae++,Ne=i(L),et=Ne.filter(he=>!f(he.name)),U=et.filter(he=>he.isDirectory()),w=et.filter(he=>!he.isDirectory());let wn=U.length>0;if(wn&&Ae<t)G.push({displayName:Te,subDirPath:L,subEntries:Ne,nextDepth:Ae+1});else{let he=x(w),Kt=wn&&Ae>=t?" ...max scan depth":"";F.push(`${Te}/${he}${Kt}`)}}F.length>0&&(I+=`${l}${F.join(", ")}
542
- `);for(let{displayName:$,subDirPath:L,subEntries:Te,nextDepth:Ae}of G)I+=`${l}${$}/
543
- `,I+=Ss(L,t,Ae,i,m,Te);return P&&(I+=`${l}...max scan width, ReadFolder if needed
544
- `),I};import ks from"path";import dl from"fs";var fl=e=>{try{return dl.readdirSync(e,{withFileTypes:!0})}catch{return[]}},Ts=(e,t,n="",i=1,o=fl,r=[])=>{let d=o(e),l=ks.sep;if(d.length>100)return`${n}\u2514\u2500\u2500 ${ks.basename(e)}${l} ...100+ files...
545
- `;let m="",f=r,h=d.filter(s=>!f.includes(s.name)&&!s.name.startsWith(".")),p=d.filter(s=>f.includes(s.name)||s.name.startsWith(".")).map(s=>s.name).sort();h.sort((s,x)=>s.isDirectory()&&!x.isDirectory()?-1:!s.isDirectory()&&x.isDirectory()?1:s.name.localeCompare(x.name));let g=[...h.map(s=>({name:s.name,isDir:s.isDirectory()})),...p.map(s=>({name:s,isDir:!0,isCollapsed:!0}))];return g.forEach((s,x)=>{let I=x===g.length-1,Xe=ks.join(e,s.name),C=I?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",P=n+(I?" ":"\u2502 ");if(s.isCollapsed){m+=`${n}${C}${s.name}${l}...
546
- `;return}s.isDir?i>t?m+=`${n}${C}${s.name}${l} ...depth exceeded...
547
- `:o(Xe).length>80?m+=`${n}${C}${s.name}${l} ...80+ files...
548
- `:(m+=`${n}${C}${s.name}${l}
549
- `,m+=Ts(Xe,t,P,i+1,o,r)):m+=`${n}${C}${s.name}
550
- `}),m};var gl={Ollama:()=>import("./ollama-X7ARM2CC.js").then(e=>e.getOllamaStream),OpenRouter:()=>import("./openrouter-X34P3LSG.js").then(e=>e.getOpenRouterStream),DeepSeek:()=>import("./deepseek-2ML5JZIJ.js").then(e=>e.getDeepSeekStream),Mistral:()=>import("./mistral-GA36HVZJ.js").then(e=>e.getMistralStream),NVIDIA:()=>import("./nvidia-Z6TAXVPB.js").then(e=>e.getNVIDIAStream),NVIDIA_wrap:()=>import("./nvidia-Z6TAXVPB.js").then(e=>e.wrapNvidiaStreamWithQueueDepth),InferX:()=>import("./inferx-UKKLJEAM.js").then(e=>e.getInferXStream),SenseNova:()=>import("./sensenova-HDWEJZ55.js").then(e=>e.getSenseNovaStream),AIHubMix:()=>import("./aihubmix-O3DBW2A5.js").then(e=>e.getAIHubMixStream),Poolside:()=>import("./poolside-FQHJMGLR.js").then(e=>e.getPoolsideStream),NineRouter:()=>import("./9router-PDJMJ7J7.js").then(e=>e.getNineRouterStream),ExpLabs:()=>import("./explabs-QQLTHT5W.js").then(e=>e.getExpLabsStream),TokenHarbor:()=>import("./tokenharbor-CGOB5U35.js").then(e=>e.getTokenHarborStream),Infron:()=>import("./infron-TWZGMQWC.js").then(e=>e.getInfronStream),APInex:()=>import("./apinex-752TL5EZ.js").then(e=>e.getAPInexStream),xKiro:()=>import("./xkiro-QEMX3CQI.js").then(e=>e.getXKiroStream),CoArena:()=>import("./coarena-JZAITHAG.js").then(e=>e.getCoArenaStream),c_openai:()=>import("./custom_openai-VGJQRWSE.js").then(e=>e.getCustomOpenAIStream)},Cs={},me=async e=>(Cs[e]||(Cs[e]=await gl[e]()),Cs[e]),ml=/```[\s\S]*?```/g,pl=/```[\s\S]*$/g,hl=/`[^`]+`/g,yl=/^\|.*\|$/gm,xl=/^[^\w]+|[^\w]+$/g,wl=/[^a-z0-9]/gi,Ko=/\[\s*(?:tool|action):(?:functions\.)?([a-z0-9_]+)\s*\(/gi,bl=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-z0-9_]+)\s*\(/gi,Sl=/(?:path|targetFile|TargetFile|directory|keyword|id|taskId|title|task)\s*=\s*\\?["']?([^\\"' \),]+)/,_n=/["']/g,da=/\\/g,kl=/<\|channel>thought/gi,Tl=/<channel\|>/gi,Al=e=>typeof e!="string"?e:e.replace(kl,"<think_fluxflow>").replace(Tl,"</think_fluxflow>"),Qd=/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\]|$)/i,Cl=(e,t,n=1)=>{let i=t>0?e[t-1]:"",o=t+n<e.length?e[t+n]:"";return i==="`"&&o==="`"},Rl=e=>{let t=/(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\])/gi,n;for(;(n=t.exec(e))!==null;)if(!Cl(e,n.index,n[0].length))return{index:n.index,length:n[0].length};return{index:-1,length:0}},Rs=e=>{if(!e||typeof e!="string")return null;let t=e.match(/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])/i);if(!t)return null;let n=t.index+t[0].length,i=e.substring(n),o=Rl(i);if(o.index!==-1){let r=n+o.index+o.length;return{fullBlock:e.substring(0,r),innerContent:i.substring(0,o.index),remainingText:e.substring(r)}}return{fullBlock:e,innerContent:i,remainingText:""}},jt=e=>{if(!e||typeof e!="string")return e;let t=Rs(e);return t?t.remainingText.trimStart():e};var fa=/<\|\s*tool_call_begin\s*\|>\s*(?:(?:tool|functions)\b[\s._]*)*([a-zA-Z0-9_]+)(?::\d+)?\s*<\|\s*tool_call_argument_begin\s*\|>([\s\S]*?)<\|\s*tool_call_end\s*\|>/gi,vl=/"([^"]+)"\s*:\s*(?:"([^"]*)"|(\d+)|true|false|null)/g,ua=/<\|\s*tool_calls_section_begin\s*\|>/gi,ga=/<\|\s*tool_calls_section_end\s*\|>/gi,El=/```(?:tool|action|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi;var _i=e=>!e||typeof e!="string"?e:e.replace(/(```[\s\S]*?```|`[^`]*`)|(<(?:\w+)(?:[^>]*)>\r?\n?|\r?\n?<\/\w+(?:[^>]*)>)/gi,(t,n)=>n||""),ba=e=>{if(!e||typeof e!="string")return e;let t=Kn(e);if(!t||t.length===0)return e;let n=t[t.length-1];if(!n.fullMatch)return e;let i=e.lastIndexOf(n.fullMatch);if(i===-1)return e;let o=i+n.fullMatch.length,r=e.substring(o);if(/\[\s*(?:tool|action):/i.test(r))return e.trimEnd();let d=/\r?\n/.test(r);return e.substring(0,o)+(d?`
551
- `:"")},Es=null,Vo={},no={key:null,value:null},Lt=e=>{if(!e)return e;let t=Vo?.theme;if(!t)try{t=ri(oi,{})?.systemSettings?.theme}catch{}let i=Ri(t||"Dark").toolFeedbackAnsi||"\x1B[95m";return e.replace(/(?:(\x1b\[\d+m))?([✔✘✖🔍📖→➕↻↷•🛇])(?:(\x1b\[\d+m))?\s*\b(Clicked Screen|Clicked|Located|Dragged|Scrolled|Typed|Entered|Pressed Key|Recaptured Screen|Created|Read Skill|Read Documentation|Executed|Searched Documentation|Read|Edited|Viewed|Processed|Auto-Read|Skipped|List|Generated|Written|Searched|AI Search|Get Map|Write Canceled|Resolved Sub-Agent Query|Edit Canceled|Write Cancelled|Edit Denied|Visited|Updated|Reviewed|Delegated|Background|Checked|Indexed|Analyzed|Browsed|Elevating SubAgent|Checking SubAgent Work|Started Generalist|Called Generalist|Steered|Unsupported Modality|Awaiting|Cancelled|Aligning Moon Phase|Contemplating Existence|Staring At Void|Rollback Point Checked|Emergency Rollback Failed|Emergency Rollback|Delaying Professionally|Negotiating With Electrons|Touching Grass (virtually)|Panicking Softly|Rethinking Career Choices|Loading Cat Videos|Giving Up Entirely|Summoning Braincell #2|Pretending To Be Busy|Waiting For Motivation DLC|Rotating Internal Screaming|Downloading More RAM|Feeding The Hamsters|Gaslighting Scheduler|Performing Dramatic Pause|Buffering Social Energy|Calculating Regret|Reading Terms And Conditions|Becoming Sentient Briefly|Model produced malformed tool call|Loop Detected|Contacting Ancestors)\b/ig,(o,r,d,l,m)=>`${r||""}${d}${l||""} ${i}${m}\x1B[0m`)},_l=async(e,t=8,n=1e3,i=8e3,o=null)=>{let r=0;for(;;){if(o?.aborted)throw new DOMException("The user aborted a request.","AbortError");try{return await e()}catch(d){if(o?.aborted||d?.name==="AbortError"||d?.message==="Subagent task was cancelled."||(r++,r>=t))throw d;let l=Math.min(n*Math.pow(2,r-1),i);await new Promise((m,f)=>{let h=setTimeout(m,l);o&&o.addEventListener("abort",()=>{clearTimeout(h),f(new DOMException("The user aborted a request.","AbortError"))})})}}},xt=!1;var Zd=e=>{let t=e.filter(o=>(o.role==="user"||o.role==="agent"||o.role==="system")&&o.role!=="think"&&!o.isVisualFeedback&&!o.isMeta&&!o.isTerminalRecord&&!(o.text&&o.text.includes("[TERMINAL_RECORD]"))&&!String(o.id).startsWith("welcome")).map((o,r,d)=>{let l=o.fullText||o.text||"";if(o.role==="user"&&r<d.length-1)if(l.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")){let m=l.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");if(m!==-1){let h=l.substring(0,m).lastIndexOf("[SYSTEM METADATA]");h!==-1?l=l.substring(h).trim():l=l.substring(m).trim()}}else{let m=l.lastIndexOf("[USER]"),f=l.lastIndexOf("[USER PROMPT]");m!==-1?l=l.substring(m+6).trim():f!==-1&&(l=l.substring(f).trim())}return{...o,text:l}}),n=[],i=0;for(;i<t.length;){let o=t[i];if(o.role==="user")n.push(o),i++;else{let r=[];for(;i<t.length&&t[i].role!=="user";)r.push(t[i]),i++;let d=[],l=[],m=!1,f=()=>{d.length>0&&(n.push({role:"agent",text:"combined"}),d=[]),l.length>0&&(n.push({role:"system",text:"combined"}),l=[]),m=!1};r.forEach(h=>{let p=h.role==="system"&&(h.text?.startsWith("[ACTION RESULT]")||h.text?.startsWith("[TOOL RESULT]")||h.text?.startsWith("SUCCESS:")||h.text?.startsWith("ERROR:")||h.fullText?.startsWith("[ACTION RESULT]")||h.fullText?.startsWith("[TOOL RESULT]")||h.fullText?.startsWith("SUCCESS:")||h.fullText?.startsWith("ERROR:")),g=h.fullText||h.text||"",s=g.trim();if(!(!s&&!h.binaryPart)){if(p)l.push(s);else if(h.role==="agent"){!m&&l.length>0&&f();let x=g.endsWith(`
552
- `),I=s.toLowerCase().includes("tool:")||s.toLowerCase().includes("action:");d.push(s),I&&x?m=!0:m=!1}}}),f()}}return n.length};var ef=()=>{xt=!0},tf=()=>xt,vs={write_file:"Writing",update_file:"Editing",read_folder:"Reading",view_file:"Reading",exec_command:"Executing Command",web_search:"Searching",web_scrape:"Reading",memory:"Updating Memory",search_keyword:"Searching",find_file:"Finding File",findFile:"Finding File",FindFile:"Finding File",file_map:"Generating Map",ask:"User Input",write_pdf:"Creating",write_docx:"Creating",generate_image:"Generating",todo:"Planning",Todo:"Planning",goal:"Planning",Goal:"Planning",invoke_sync:"Sub-Agent Working",invoke:"Starting Agent",get_progress:"Checking Progress",cancel:"Cancelling",await:"Waiting",wait:"Waiting",EmergencyRollback:"Don't Panic. Lookin' into it",answer:"Answering Sub-Agent",Answer:"Answering Sub-Agent",steer:"Steering Sub-Agent",Steer:"Steering Sub-Agent",Click:"Clicking",click:"Clicking",Drag:"Dragging",drag:"Dragging",Scroll:"Scrolling",scroll:"Scrolling",KeyboardTyping:"Typing",keyboard_typing:"Typing",KeyPress:"Pressing Key",key_press:"Pressing Key",RecaptureScreen:"Recapturing Screen",recapture_screen:"Recapturing Screen"},oo=(e,t)=>{try{let n=O(t),i=e.toLowerCase().replace(/_/g,"");if(i==="invokesync"||i==="invoke")return n.title||(n.task?n.task.substring(0,30):null);if(i==="getprogress"||i==="cancel"||i==="steer"||i==="steersubagent")return n.id||n.taskId;let o=n.name||n.path||n.targetFile||n.TargetFile||n.directory||n.file||n.query;return o?B.basename(o.replace(/["']/g,"").replace(/\\/g,"/")):null}catch{return null}},Sa=e=>e?new ya({apiKey:e}):Es,nf=async(e,t,n,i,o={})=>{},Ii=e=>{if(!e||typeof e!="string")return e;let t=e.split(""),n=!1,i=!1,o=0;for(;o<t.length;){if(t[o]==="`"&&t[o+1]==="`"&&t[o+2]==="`"){n?(t[o]=" ",t[o+1]=" ",t[o+2]=" ",n=!1):(t[o]=" ",t[o+1]=" ",t[o+2]=" ",n=!0),o+=3;continue}if(n){t[o]!==`
553
- `&&t[o]!=="\r"&&(t[o]=" "),o++;continue}if(t[o]==="`")if(i){i=!1,t[o]=" ",o++;continue}else{i=!0,t[o]=" ",o++;continue}if(i){t[o]===`
554
- `||t[o]==="\r"?i=!1:t[o]=" ",o++;continue}o++}return t.join("")},ma=(e,t=null)=>{if(!e||typeof e!="string")return e;let n=t||Kn(e);if(!n||n.length===0)return e;let i=e.split("");for(let o of n){if(!o.fullMatch)continue;let r=0;for(;(r=e.indexOf(o.fullMatch,r))!==-1;){for(let d=r;d<r+o.fullMatch.length;d++)i[d]!==`
555
- `&&i[d]!=="\r"&&(i[d]=" ");r+=o.fullMatch.length}}return i.join("")},Il=e=>{let t=jt(e),n=Ii(t);Ko.lastIndex=0;let i;for(;(i=Ko.exec(n))!==null;){let o=i.index+i[0].length-1,r=0,d=null,l=!1,m=!1;for(let f=o;f<n.length;f++){let h=n[f];if(!d&&(h==='"'||h==="'"||h==="`")?(d=h,l=!1):d&&h===d&&!l&&(d=null),!d&&(h==="("?r++:h===")"&&r--,r===0)){let p=f+1;for(;p<n.length&&/\s/.test(n[p]);)p++;if(p<n.length&&n[p]==="]"){m=!0,Ko.lastIndex=p+1;break}}h==="\\"?l=!l:l=!1}if(!m)return{inside:!0,toolName:i[1],startIndex:i.index,args:t.substring(i.index+i[0].length)}}return{inside:!1}},ka=(e,t=!0)=>{let n=Ko;n.lastIndex=0;let i="",o=0,r;for(;(r=n.exec(e))!==null;){let d=e.substring(o,r.index);i+=t&&o===0?jt(d):d;let l=r.index+r[0].length-1,m=0,f=null,h=-1;for(let p=l;p<e.length;p++){let g=e[p];if(f){if(g===f){let s=0;for(let x=p-1;x>=0&&e[x]==="\\";x--)s++;s%2===0&&(f=null)}}else if(g==='"'||g==="'"||g==="`")f=g;else if(g==="(")m++;else if(g===")"&&(m--,m===0)){let s=p+1;for(;s<e.length&&/\s/.test(e[s]);)s++;if(s<e.length&&e[s]==="]"){h=s;break}}}if(h!==-1)i+="[tool:functions."+r[1]+"()]",o=h+1,n.lastIndex=o;else{i+="[tool:functions."+r[1]+"(",o=e.length;break}}return o<e.length&&(i+=t&&o===0?jt(e.substring(o)):e.substring(o)),i},Ml=(e,t,n)=>{let i=Ko;i.lastIndex=0;let o="",r=0,d;for(;(d=i.exec(e))!==null;){let l=e.substring(r,d.index);o+=l.replace(t,n);let m=d.index+d[0].length-1,f=0,h=null,p=-1;for(let g=m;g<e.length;g++){let s=e[g];if(h){if(s===h){let x=0;for(let I=g-1;I>=0&&e[I]==="\\";I--)x++;x%2===0&&(h=null)}}else if(s==='"'||s==="'"||s==="`")h=s;else if(s==="(")f++;else if(s===")"&&(f--,f===0)){let x=g+1;for(;x<e.length&&/\s/.test(e[x]);)x++;if(x<e.length&&e[x]==="]"){p=x;break}}}if(p!==-1)o+=e.substring(d.index,p+1),r=p+1,i.lastIndex=r;else{o+=e.substring(d.index),r=e.length;break}}return r<e.length&&(o+=e.substring(r).replace(t,n)),o},pa=e=>ka(e,!0),Pl=e=>{if(!e)return e;let t={patchfile:"PatchFile",writefile:"WriteFile",readfile:"ReadFile",viewfile:"ReadFile",run:"Run",execcommand:"Run",searchkeyword:"SearchKeyword",codesearch:"CodeSearch",code_search:"CodeSearch",websearch:"WebSearch",webscrape:"WebScrape",readfolder:"ReadFolder",writepdf:"WritePDF",writedoc:"WriteDoc",writedocx:"WriteDoc",filemap:"FileMap",generateimage:"GenerateImage",todo:"Todo",goal:"Goal",askuser:"AskUser",ask:"AskUser"},n=o=>o.split("_").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("");fa.lastIndex=0;let i=e.replace(fa,(o,r,d)=>{let l="";try{let h=JSON.parse(d.trim());h&&typeof h=="object"&&(l=Object.entries(h).map(([g,s])=>{let x=typeof s=="string"?s:JSON.stringify(s);return`${g}=${JSON.stringify(x)}`}).join(", "))}catch{let p=[],g=vl;g.lastIndex=0;let s;for(;(s=g.exec(d))!==null;){let x=s[1],I=s[2]!==void 0?s[2]:s[0].split(":").slice(1).join(":").trim();p.push(`${x}=${JSON.stringify(I)}`)}p.length>0?l=p.join(", "):l=d.trim()}let m=r.toLowerCase().replace(/_/g,"");return`[tool:functions.${t[m]||n(r)}(${l})]`});return ua.lastIndex=0,ga.lastIndex=0,i=i.replace(ua,""),i=i.replace(ga,""),i},Kn=e=>{if(!e)return[];let t=Pl(e),n=jt(t),i=[],o=Ii(n),r=bl;r.lastIndex=0;let d;for(;(d=r.exec(o))!==null;){let l=d[1],m=d.index+d[0].length-1,f=0,h=null,p=-1,g=-1;for(let s=m;s<o.length;s++){let x=o[s];if(h){if(x===h){let I=0;for(let Xe=s-1;Xe>=0&&o[Xe]==="\\";Xe--)I++;I%2===0&&(h=null)}}else{if(s>m&&(o.substring(s).startsWith("[action:")||o.substring(s).startsWith("[tool:")))break;if(x==='"'||x==="'"||x==="`")h=x;else if(x==="(")f++;else if(x===")"&&(f--,f===0)){g=s;let I=s+1;for(;I<o.length&&/\s/.test(o[I]);)I++;if(I<o.length&&o[I]==="]"){p=I;break}}}}if(p!==-1){let s=n.substring(m+1,g),x=n.substring(d.index,p+1);i.push({fullMatch:x,toolName:l.trim(),args:s.trim()}),r.lastIndex=p+1}}return i},ha=e=>{if(!e)return null;let t=jt(e),n=[],i=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,o=[],r;for(;(r=i.exec(t))!==null;)o.push({toolName:r[1],index:r.index,parenIndex:r.index+r[0].length-1});for(let g=0;g<o.length;g++){let s=o[g],x=g+1<o.length?o[g+1].index:t.length,I=t.substring(s.index,x),Xe=I.indexOf("("),C=Xe!==-1?I.substring(Xe+1):"",P=0,F=null,G=!1;for(let $=0;$<C.length;$++){let L=C[$];if(F){if(L===F){let Te=0;for(let Ae=$-1;Ae>=0&&C[Ae]==="\\";Ae--)Te++;Te%2===0&&(F=null)}}else if(L==='"'||L==="'"||L==="`")F=L;else if(L==="(")P++;else if(L===")")if(P>0)P--;else{let Te=$+1;for(;Te<C.length&&/\s/.test(C[Te]);)Te++;if(Te<C.length&&C[Te]==="]"){G=!0;break}}}if(!G){let $=I.trim(),L="";F?L=`Unclosed quote string (${F}) inside arguments`:$.endsWith("]")?L=`Missing closing ')' before ']' (e.g. found "...]")`:$.endsWith(")")?L=`Missing closing ']' after ')' (e.g. found "...)" instead of "...)]")`:!$.includes(")")&&!$.includes("]")?L="Missing closing delimiter ')]'":L="Malformed or unclosed call syntax (missing ')]')",n.push(`\u2022 [action:${s.toolName}(...)]: ${L}. Expected: [action:${s.toolName}(arg1="...", arg2="...")]`)}}let d=/(?:^|[^\w\[])(?:tool|action):(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/gi,l;for(;(l=d.exec(t))!==null;){let g=l[1],s=l.index+(l[0].indexOf(":")-(l[0].startsWith("action")||l[0].startsWith("tool")?0:1));(s>0?t[s-1]:"")!=="["&&Ai(g)&&n.push(`\u2022 action:${g}(...): Missing opening bracket '['. Expected: [action:${g}(...)]`)}let m=/\[\s*(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/g,f;for(;(f=m.exec(t))!==null;){let g=f[1];g!=="action"&&g!=="tool"&&Ai(g)&&n.push(`\u2022 [${g}(...)]: Missing 'action:' prefix. Expected: [action:${g}(...)]`)}let h=/\[\s*(?:tool|action)\s*:\s*(?:functions\.)?([a-zA-Z0-9_]+)(?!\s*\()/gi,p;for(;(p=h.exec(t))!==null;){let g=p[1];Ai(g)&&n.push(`\u2022 [action:${g}...]: Missing opening '(' for tool arguments. Expected: [action:${g}(...)]`)}return n.length>0?n.join(`
556
- `):null},of=(e,t={})=>{if(!e)return null;if(Vo=t,Es=new ya({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(...i)=>{try{let o=await n(...i);return typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),o}catch(o){throw typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),o}}}},Ta=e=>{if(!e)return{serviceTier:void 0,cleanModel:e};let t=e.toLowerCase();return t.endsWith(":flex")?{serviceTier:"flex",cleanModel:e.slice(0,-5)}:t.endsWith(":priority")?{serviceTier:"priority",cleanModel:e.slice(0,-9)}:{serviceTier:void 0,cleanModel:e}},$l=async(e,t,n,i,o="Fast",r=.75,d="agent")=>_l(async()=>{let{aiProvider:l="Google",apiKey:m,mode:f}=e,h="",p=null,g=typeof n=="string"?[{role:"user",parts:[{text:n}]}]:n,s=new AbortController,x=s.signal,I=setInterval(()=>{xt&&(s.abort(),clearInterval(I))},100),Xe=Date.now(),C=null;try{let P;if(l==="Ollama")P=(await me("Ollama"))(m,t,g,i,o,f,it(t),x,r,e.systemSettings?.ollamaEndpoint||"Cloud");else if(l==="OpenRouter")P=(await me("OpenRouter"))(m,t,g,i,o,f,it(t),x,r);else if(l==="DeepSeek")P=(await me("DeepSeek"))(m,t,g,i,o,f,it(t),x,r);else if(l==="Mistral")P=(await me("Mistral"))(m,t,g,i,o,f,it(t),x,r);else if(l==="NVIDIA")P=(await me("NVIDIA"))(m,t,g,i,o,f,it(t),x,r);else if(l==="InferX")P=(await me("InferX"))(m,t,g,i,o,f,it(t),x,r);else if(l==="SenseNova")P=(await me("SenseNova"))(m,t,g,i,o,f,it(t),x,r);else if(l==="AIHubMix")P=(await me("AIHubMix"))(m,t,g,i,o,f,it(t),x,r);else if(l==="Poolside")P=(await me("Poolside"))(m,t,g,i,o,f,it(t),x,r);else if(l==="9router"||l==="9Router")P=(await me("NineRouter"))(m,t,g,i,o,f,it(t),x,r);else if(l==="ExpLabs"||l==="ExperientialLabs")P=(await me("ExpLabs"))(m,t,g,i,o,f,it(t),x,r);else if(l==="Infron"||l==="infron")P=(await me("Infron"))(m,t,g,i,o,f,it(t),x,r);else if(l==="TokenHarbor"||l==="Token Harbor"||l==="tokenharbor"||l==="token_harbor"||l==="thk")P=(await me("TokenHarbor"))(m,t,g,i,o,f,it(t),x,r);else if(l==="APInex"||l==="apinex"||l==="apx")P=(await me("APInex"))(m,t,g,i,o,f,it(t),x,r);else if(l==="xKiro"||l==="xkiro"||l==="kiro")P=(await me("xKiro"))(m,t,g,i,o,f,it(t),x,r);else if(l==="CoArena"||l==="coarena")P=(await me("CoArena"))(m,t,g,i,o,f,it(t),x,r);else if(l==="c_openai"||l==="Custom (OpenAI)"){let F=e.systemSettings?.customOpenAIBaseUrl||"";try{F=await Vi("c_openai")||F}catch{}P=(await me("c_openai"))(m,t,g,i,o,f,it(t),x,r,F)}else{let F=Sa(m),{serviceTier:G,cleanModel:$}=Ta(t),L={systemInstruction:i,temperature:r,thinkingConfig:(()=>{let Ae=(t||"").toLowerCase(),Ne=Ae.includes("gemma-4")||Ae.startsWith("gemma"),et=Ae.includes("gemini-3");if(Ne||et)return Ne?o.toLowerCase()!=="xhigh"?{includeThoughts:!1,thinkingLevel:Ye.MINIMAL}:{includeThoughts:!0,thinkingLevel:Ye.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:Ae.includes("pro")?Ye.LOW:Ye.MINIMAL,Low:Ye.LOW,Medium:Ye.MEDIUM,Standard:Ye.MEDIUM,High:Ye.HIGH,xHigh:Ye.HIGH}[o]||Ye.MEDIUM};{let U={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[o]||2048;return U===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:U}}})()};G&&(L.serviceTier=G),P=await F.models.generateContentStream({model:$,contents:g,config:L},{signal:x})}for await(let F of P){if(xt)throw new Error("Subagent task was cancelled.");if(e?.taskId&&typeof Ht<"u"){let L=Ht.find(Te=>Te.id===e.taskId);if(L&&L.status==="cancelled")throw new Error("Subagent task was cancelled.")}C===null&&(F.candidates?.[0]?.content?.parts||F.text)&&(C=Date.now()-Xe);let G="";if(F.candidates?.[0]?.content?.parts)for(let L of F.candidates[0].content.parts)L.text&&!L.thought&&(h+=L.text,G+=L.text);let $=G?Yi(G):0;e&&typeof e.onTokenChunk=="function"&&e.onTokenChunk(G,$),F.usageMetadata&&(p=F.usageMetadata)}}finally{clearInterval(I)}if(p){let P=p.totalTokenCount||0,F=p.cachedContentTokenCount||0,G=(p.candidatesTokenCount||0)+(l==="Google"&&p.thoughtsTokenCount||0);await hn("tokens",P,l,t),F>0&&await hn("cachedTokens",F,l,t),G>0&&await hn("candidateTokens",G,l,t),C!==null&&C>0&&await hn("ttft",C,l,t),ci({provider:l,model:t,prompt:p.promptTokenCount||0,cached:F,output:G,reasoning:p.thoughtsTokenCount||0,ttft:C}),e&&typeof e.onUsage=="function"&&e.onUsage({totalTokenCount:P,cachedContentTokenCount:F,candidatesTokenCount:G})}return await $t("agent",l),{text:h,usageMetadata:p}}),sf=async function*(e,t,n,i,o){let{profile:r,thinkingLevel:d,mode:l,janitorModel:m,chatId:f,isPlayground:h,systemSettings:p,sessionStats:g,aiProvider:s="Google",apiTier:x,wildcardTooling:I,wildercardTooling:Xe}=n,C=it(e);if(!Es&&s==="Google")throw new Error("AI not initialized");let P=!1,F=t[t.length-1].text,G=B.join(js,"chat-summaries.json"),$=!1,L=t.filter(U=>U.role==="user").length===1,Te=F.includes("[TITLE-UPDATE]"),Ae=L||Te,Ne=F.replace(/\[TITLE-UPDATE\]/g,"").trim();Ne=Ne.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),yield{type:"status",content:"[start]"},yield{type:"status",content:"Gathering Context"},await di.startTransaction(f,Ne),p?.advanceRollback&&await Mo.takeInitialSnapshot(f),xt=!1;let et=null;try{let U=new AbortController;et=setInterval(()=>{xt&&(U.abort(),et&&(clearInterval(et),et=null))},400);let w=[...t.slice(0,-1)];{let ue=pn(G,{})[f]||{summary:"",historyLength:0};if(ue.summary&&ue.historyLength>0){let kt=0,le=[];for(let K=0;K<w.length;K++){let Se=w[K];(Se.role==="user"||Se.role==="agent"||Se.role==="system")&&!String(Se.id).startsWith("welcome")&&!Se.isMeta&&kt++,kt>ue.historyLength&&le.push(Se)}w=le}}w=w.map(b=>{if(b.role==="user"&&b.text){let ue=b.text.match(/\[USER\]([\s\S]*?)\[\/USER\]/);if(ue)return{...b,text:ue[1].trim()}}return{...b}});let wn=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1,Qt={"16k":16e3,"32k":32e3,"64k":64e3,"128k":128e3,"256k":256e3,"512k":512e3,"1M":1e6}[p?.contextLength]||256e3;if(s==="Google"&&e?.includes("gemma")&&wn&&(Qt=16e3),(g?.tokens||0)>Qt){yield{type:"text",content:"\u2726 Maximum Context Limit Reached. Start a new chat."};return}if(L&&P){let b=pn(Hi,{});Object.values(b).flat().length>5}let Me=pn(Hi,{}),Z=pn(Ks,{}),Ve=Object.entries(Me).filter(([b])=>b!==f).flatMap(([b,ue])=>ue),In=[...Object.entries(Z).filter(([b])=>b!==f).slice(-20).map(([b,ue])=>`[Chat Summary]: ${ue}`),...Ve].map(b=>`- ${b}`).join(`
543
+ `};import{structuredPatch as ul}from"diff";import bs from"path";import ll from"fs";var cl=e=>{try{return ll.readdirSync(e,{withFileTypes:!0})}catch{return[]}},Ss=(e,t=4,n=1,s=cl,o=[],r=null)=>{let d=r||s(e),a=" ".repeat(n-1),m=n===1?new Set([..._o,...o,...Io(e),...Io(process.cwd())]):o instanceof Set?o:new Set([..._o,...o]),f=$=>m.has($),h=d.filter($=>!f($.name)),p=d.filter($=>f($.name)).length,g=h.filter($=>!$.isDirectory()).map($=>$.name).sort(),i=h.filter($=>$.isDirectory()).sort(($,L)=>$.name.localeCompare(L.name)),x=$=>{let L=$.length;if(L===0)return"no files";let Te=Array.from(new Set($.map(De=>{let tt=typeof De=="string"?De:De.name;return bs.extname(tt).slice(1)}).filter(Boolean))).sort(),Ae="*";return Te.length===1?Ae=`*.${Te[0]}`:Te.length>1&&(Ae=`*.{${Te.join(", ")}}`),L===1?Ae:`${Ae} ${L} files`},I="";if(n===1){let $=g.join(", "),L=p>0?` [${p} ignored]`:"";($||L)&&(I+=`${a}${$?$+(L?`${L}`:""):L.trim()}
544
+ `)}else g.length>0&&(I+=`${a}[${x(g)}]
545
+ `);let Xe=10,C=i.slice(0,Xe),M=i.length>Xe,F=[],G=[];for(let $ of C){let L=bs.join(e,$.name),Te=$.name,Ae=n,De=s(L),tt=De.filter(he=>!f(he.name)),B=tt.filter(he=>he.isDirectory()),w=tt.filter(he=>!he.isDirectory());for(;w.length===0&&B.length===1&&Ae<t;)Te=`${Te}/${B[0].name}`,L=bs.join(L,B[0].name),Ae++,De=s(L),tt=De.filter(he=>!f(he.name)),B=tt.filter(he=>he.isDirectory()),w=tt.filter(he=>!he.isDirectory());let wn=B.length>0;if(wn&&Ae<t)G.push({displayName:Te,subDirPath:L,subEntries:De,nextDepth:Ae+1});else{let he=x(w),Kt=wn&&Ae>=t?" ...max scan depth":"";F.push(`${Te}/${he}${Kt}`)}}F.length>0&&(I+=`${a}${F.join(", ")}
546
+ `);for(let{displayName:$,subDirPath:L,subEntries:Te,nextDepth:Ae}of G)I+=`${a}${$}/
547
+ `,I+=Ss(L,t,Ae,s,m,Te);return M&&(I+=`${a}...max scan width, ReadFolder if needed
548
+ `),I};import ks from"path";import dl from"fs";var fl=e=>{try{return dl.readdirSync(e,{withFileTypes:!0})}catch{return[]}},Ts=(e,t,n="",s=1,o=fl,r=[])=>{let d=o(e),a=ks.sep;if(d.length>100)return`${n}\u2514\u2500\u2500 ${ks.basename(e)}${a} ...100+ files...
549
+ `;let m="",f=r,h=d.filter(i=>!f.includes(i.name)&&!i.name.startsWith(".")),p=d.filter(i=>f.includes(i.name)||i.name.startsWith(".")).map(i=>i.name).sort();h.sort((i,x)=>i.isDirectory()&&!x.isDirectory()?-1:!i.isDirectory()&&x.isDirectory()?1:i.name.localeCompare(x.name));let g=[...h.map(i=>({name:i.name,isDir:i.isDirectory()})),...p.map(i=>({name:i,isDir:!0,isCollapsed:!0}))];return g.forEach((i,x)=>{let I=x===g.length-1,Xe=ks.join(e,i.name),C=I?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",M=n+(I?" ":"\u2502 ");if(i.isCollapsed){m+=`${n}${C}${i.name}${a}...
550
+ `;return}i.isDir?s>t?m+=`${n}${C}${i.name}${a} ...depth exceeded...
551
+ `:o(Xe).length>80?m+=`${n}${C}${i.name}${a} ...80+ files...
552
+ `:(m+=`${n}${C}${i.name}${a}
553
+ `,m+=Ts(Xe,t,M,s+1,o,r)):m+=`${n}${C}${i.name}
554
+ `}),m};var gl={Ollama:()=>import("./ollama-6LZL7OKW.js").then(e=>e.getOllamaStream),OpenRouter:()=>import("./openrouter-X34P3LSG.js").then(e=>e.getOpenRouterStream),DeepSeek:()=>import("./deepseek-2ML5JZIJ.js").then(e=>e.getDeepSeekStream),Mistral:()=>import("./mistral-GA36HVZJ.js").then(e=>e.getMistralStream),NVIDIA:()=>import("./nvidia-Z6TAXVPB.js").then(e=>e.getNVIDIAStream),NVIDIA_wrap:()=>import("./nvidia-Z6TAXVPB.js").then(e=>e.wrapNvidiaStreamWithQueueDepth),InferX:()=>import("./inferx-UKKLJEAM.js").then(e=>e.getInferXStream),SenseNova:()=>import("./sensenova-HDWEJZ55.js").then(e=>e.getSenseNovaStream),AIHubMix:()=>import("./aihubmix-O3DBW2A5.js").then(e=>e.getAIHubMixStream),Poolside:()=>import("./poolside-FQHJMGLR.js").then(e=>e.getPoolsideStream),NineRouter:()=>import("./9router-PDJMJ7J7.js").then(e=>e.getNineRouterStream),ExpLabs:()=>import("./explabs-QQLTHT5W.js").then(e=>e.getExpLabsStream),TokenHarbor:()=>import("./tokenharbor-CGOB5U35.js").then(e=>e.getTokenHarborStream),Infron:()=>import("./infron-TWZGMQWC.js").then(e=>e.getInfronStream),Numes:()=>import("./numes-TNJXMAPV.js").then(e=>e.getNumesStream),APInex:()=>import("./apinex-752TL5EZ.js").then(e=>e.getAPInexStream),xKiro:()=>import("./xkiro-QEMX3CQI.js").then(e=>e.getXKiroStream),CoArena:()=>import("./coarena-JZAITHAG.js").then(e=>e.getCoArenaStream),c_openai:()=>import("./custom_openai-XRPZ25BZ.js").then(e=>e.getCustomOpenAIStream)},Cs={},de=async e=>(Cs[e]||(Cs[e]=await gl[e]()),Cs[e]),ml=/```[\s\S]*?```/g,pl=/```[\s\S]*$/g,hl=/`[^`]+`/g,yl=/^\|.*\|$/gm,xl=/^[^\w]+|[^\w]+$/g,wl=/[^a-z0-9]/gi,Ko=/\[\s*(?:tool|action):(?:functions\.)?([a-z0-9_]+)\s*\(/gi,bl=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-z0-9_]+)\s*\(/gi,Sl=/(?:path|targetFile|TargetFile|directory|keyword|id|taskId|title|task)\s*=\s*\\?["']?([^\\"' \),]+)/,_n=/["']/g,da=/\\/g,kl=/<\|channel>thought/gi,Tl=/<channel\|>/gi,Al=e=>typeof e!="string"?e:e.replace(kl,"<think_fluxflow>").replace(Tl,"</think_fluxflow>"),Qd=/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\]|$)/i,Cl=(e,t,n=1)=>{let s=t>0?e[t-1]:"",o=t+n<e.length?e[t+n]:"";return s==="`"&&o==="`"},Rl=e=>{let t=/(?:<\/think_fluxflow>|<channel\|>|\[\/think_fluxflow\])/gi,n;for(;(n=t.exec(e))!==null;)if(!Cl(e,n.index,n[0].length))return{index:n.index,length:n[0].length};return{index:-1,length:0}},Rs=e=>{if(!e||typeof e!="string")return null;let t=e.match(/^\s*(?:<think_fluxflow[^>]*>|<\|channel>thought|\[think_fluxflow\])/i);if(!t)return null;let n=t.index+t[0].length,s=e.substring(n),o=Rl(s);if(o.index!==-1){let r=n+o.index+o.length;return{fullBlock:e.substring(0,r),innerContent:s.substring(0,o.index),remainingText:e.substring(r)}}return{fullBlock:e,innerContent:s,remainingText:""}},jt=e=>{if(!e||typeof e!="string")return e;let t=Rs(e);return t?t.remainingText.trimStart():e};var fa=/<\|\s*tool_call_begin\s*\|>\s*(?:(?:tool|functions)\b[\s._]*)*([a-zA-Z0-9_]+)(?::\d+)?\s*<\|\s*tool_call_argument_begin\s*\|>([\s\S]*?)<\|\s*tool_call_end\s*\|>/gi,vl=/"([^"]+)"\s*:\s*(?:"([^"]*)"|(\d+)|true|false|null)/g,ua=/<\|\s*tool_calls_section_begin\s*\|>/gi,ga=/<\|\s*tool_calls_section_end\s*\|>/gi,El=/```(?:tool|action|yaml|function|json)?\s*\n?([\s\S]*?)\n?\```/gi;var _i=e=>!e||typeof e!="string"?e:e.replace(/(```[\s\S]*?```|`[^`]*`)|(<(?:\w+)(?:[^>]*)>\r?\n?|\r?\n?<\/\w+(?:[^>]*)>)/gi,(t,n)=>n||""),ba=e=>{if(!e||typeof e!="string")return e;let t=Kn(e);if(!t||t.length===0)return e;let n=t[t.length-1];if(!n.fullMatch)return e;let s=e.lastIndexOf(n.fullMatch);if(s===-1)return e;let o=s+n.fullMatch.length,r=e.substring(o);if(/\[\s*(?:tool|action):/i.test(r))return e.trimEnd();let d=/\r?\n/.test(r);return e.substring(0,o)+(d?`
555
+ `:"")},Es=null,Vo={},no={key:null,value:null},Lt=e=>{if(!e)return e;let t=Vo?.theme;if(!t)try{t=ri(oi,{})?.systemSettings?.theme}catch{}let s=Ri(t||"Dark").toolFeedbackAnsi||"\x1B[95m";return e.replace(/(?:(\x1b\[\d+m))?([✔✘✖🔍📖→➕↻↷•🛇])(?:(\x1b\[\d+m))?\s*\b(Clicked Screen|Clicked|Located|Dragged|Scrolled|Typed|Entered|Pressed Key|Recaptured Screen|Created|Read Skill|Read Documentation|Executed|Searched Documentation|Read|Edited|Viewed|Processed|Auto-Read|Skipped|List|Generated|Written|Searched|AI Search|Get Map|Write Canceled|Resolved Sub-Agent Query|Edit Canceled|Write Cancelled|Edit Denied|Visited|Updated|Reviewed|Delegated|Background|Checked|Indexed|Analyzed|Browsed|Elevating SubAgent|Checking SubAgent Work|Started Generalist|Called Generalist|Steered|Unsupported Modality|Awaiting|Cancelled|Aligning Moon Phase|Contemplating Existence|Staring At Void|Rollback Point Checked|Emergency Rollback Failed|Emergency Rollback|Delaying Professionally|Negotiating With Electrons|Touching Grass (virtually)|Panicking Softly|Rethinking Career Choices|Loading Cat Videos|Giving Up Entirely|Summoning Braincell #2|Pretending To Be Busy|Waiting For Motivation DLC|Rotating Internal Screaming|Downloading More RAM|Feeding The Hamsters|Gaslighting Scheduler|Performing Dramatic Pause|Buffering Social Energy|Calculating Regret|Reading Terms And Conditions|Becoming Sentient Briefly|Model produced malformed tool call|Loop Detected|Contacting Ancestors)\b/ig,(o,r,d,a,m)=>`${r||""}${d}${a||""} ${s}${m}\x1B[0m`)},_l=async(e,t=8,n=1e3,s=8e3,o=null)=>{let r=0;for(;;){if(o?.aborted)throw new DOMException("The user aborted a request.","AbortError");try{return await e()}catch(d){if(o?.aborted||d?.name==="AbortError"||d?.message==="Subagent task was cancelled."||(r++,r>=t))throw d;let a=Math.min(n*Math.pow(2,r-1),s);await new Promise((m,f)=>{let h=setTimeout(m,a);o&&o.addEventListener("abort",()=>{clearTimeout(h),f(new DOMException("The user aborted a request.","AbortError"))})})}}},xt=!1;var Zd=e=>{let t=e.filter(o=>(o.role==="user"||o.role==="agent"||o.role==="system")&&o.role!=="think"&&!o.isVisualFeedback&&!o.isMeta&&!o.isTerminalRecord&&!(o.text&&o.text.includes("[TERMINAL_RECORD]"))&&!String(o.id).startsWith("welcome")).map((o,r,d)=>{let a=o.fullText||o.text||"";if(o.role==="user"&&r<d.length-1)if(a.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")){let m=a.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");if(m!==-1){let h=a.substring(0,m).lastIndexOf("[SYSTEM METADATA]");h!==-1?a=a.substring(h).trim():a=a.substring(m).trim()}}else{let m=a.lastIndexOf("[USER]"),f=a.lastIndexOf("[USER PROMPT]");m!==-1?a=a.substring(m+6).trim():f!==-1&&(a=a.substring(f).trim())}return{...o,text:a}}),n=[],s=0;for(;s<t.length;){let o=t[s];if(o.role==="user")n.push(o),s++;else{let r=[];for(;s<t.length&&t[s].role!=="user";)r.push(t[s]),s++;let d=[],a=[],m=!1,f=()=>{d.length>0&&(n.push({role:"agent",text:"combined"}),d=[]),a.length>0&&(n.push({role:"system",text:"combined"}),a=[]),m=!1};r.forEach(h=>{let p=h.role==="system"&&(h.text?.startsWith("[ACTION RESULT]")||h.text?.startsWith("[TOOL RESULT]")||h.text?.startsWith("SUCCESS:")||h.text?.startsWith("ERROR:")||h.fullText?.startsWith("[ACTION RESULT]")||h.fullText?.startsWith("[TOOL RESULT]")||h.fullText?.startsWith("SUCCESS:")||h.fullText?.startsWith("ERROR:")),g=h.fullText||h.text||"",i=g.trim();if(!(!i&&!h.binaryPart)){if(p)a.push(i);else if(h.role==="agent"){!m&&a.length>0&&f();let x=g.endsWith(`
556
+ `),I=i.toLowerCase().includes("tool:")||i.toLowerCase().includes("action:");d.push(i),I&&x?m=!0:m=!1}}}),f()}}return n.length};var ef=()=>{xt=!0},tf=()=>xt,vs={write_file:"Writing",update_file:"Editing",read_folder:"Reading",view_file:"Reading",exec_command:"Executing Command",web_search:"Searching",web_scrape:"Reading",memory:"Updating Memory",search_keyword:"Searching",find_file:"Finding File",findFile:"Finding File",FindFile:"Finding File",file_map:"Generating Map",ask:"User Input",write_pdf:"Creating",write_docx:"Creating",generate_image:"Generating",todo:"Planning",Todo:"Planning",goal:"Planning",Goal:"Planning",invoke_sync:"Sub-Agent Working",invoke:"Starting Agent",get_progress:"Checking Progress",cancel:"Cancelling",await:"Waiting",wait:"Waiting",EmergencyRollback:"Don't Panic. Lookin' into it",answer:"Answering Sub-Agent",Answer:"Answering Sub-Agent",steer:"Steering Sub-Agent",Steer:"Steering Sub-Agent",Click:"Clicking",click:"Clicking",Drag:"Dragging",drag:"Dragging",Scroll:"Scrolling",scroll:"Scrolling",KeyboardTyping:"Typing",keyboard_typing:"Typing",KeyPress:"Pressing Key",key_press:"Pressing Key",RecaptureScreen:"Recapturing Screen",recapture_screen:"Recapturing Screen"},oo=(e,t)=>{try{let n=O(t),s=e.toLowerCase().replace(/_/g,"");if(s==="invokesync"||s==="invoke")return n.title||(n.task?n.task.substring(0,30):null);if(s==="getprogress"||s==="cancel"||s==="steer"||s==="steersubagent")return n.id||n.taskId;let o=n.name||n.path||n.targetFile||n.TargetFile||n.directory||n.file||n.query;return o?U.basename(o.replace(/["']/g,"").replace(/\\/g,"/")):null}catch{return null}},Sa=e=>e?new ya({apiKey:e}):Es,nf=async(e,t,n,s,o={})=>{},Ii=e=>{if(!e||typeof e!="string")return e;let t=e.split(""),n=!1,s=!1,o=0;for(;o<t.length;){if(t[o]==="`"&&t[o+1]==="`"&&t[o+2]==="`"){n?(t[o]=" ",t[o+1]=" ",t[o+2]=" ",n=!1):(t[o]=" ",t[o+1]=" ",t[o+2]=" ",n=!0),o+=3;continue}if(n){t[o]!==`
557
+ `&&t[o]!=="\r"&&(t[o]=" "),o++;continue}if(t[o]==="`")if(s){s=!1,t[o]=" ",o++;continue}else{s=!0,t[o]=" ",o++;continue}if(s){t[o]===`
558
+ `||t[o]==="\r"?s=!1:t[o]=" ",o++;continue}o++}return t.join("")},ma=(e,t=null)=>{if(!e||typeof e!="string")return e;let n=t||Kn(e);if(!n||n.length===0)return e;let s=e.split("");for(let o of n){if(!o.fullMatch)continue;let r=0;for(;(r=e.indexOf(o.fullMatch,r))!==-1;){for(let d=r;d<r+o.fullMatch.length;d++)s[d]!==`
559
+ `&&s[d]!=="\r"&&(s[d]=" ");r+=o.fullMatch.length}}return s.join("")},Il=e=>{let t=jt(e),n=Ii(t);Ko.lastIndex=0;let s;for(;(s=Ko.exec(n))!==null;){let o=s.index+s[0].length-1,r=0,d=null,a=!1,m=!1;for(let f=o;f<n.length;f++){let h=n[f];if(!d&&(h==='"'||h==="'"||h==="`")?(d=h,a=!1):d&&h===d&&!a&&(d=null),!d&&(h==="("?r++:h===")"&&r--,r===0)){let p=f+1;for(;p<n.length&&/\s/.test(n[p]);)p++;if(p<n.length&&n[p]==="]"){m=!0,Ko.lastIndex=p+1;break}}h==="\\"?a=!a:a=!1}if(!m)return{inside:!0,toolName:s[1],startIndex:s.index,args:t.substring(s.index+s[0].length)}}return{inside:!1}},ka=(e,t=!0)=>{let n=Ko;n.lastIndex=0;let s="",o=0,r;for(;(r=n.exec(e))!==null;){let d=e.substring(o,r.index);s+=t&&o===0?jt(d):d;let a=r.index+r[0].length-1,m=0,f=null,h=-1;for(let p=a;p<e.length;p++){let g=e[p];if(f){if(g===f){let i=0;for(let x=p-1;x>=0&&e[x]==="\\";x--)i++;i%2===0&&(f=null)}}else if(g==='"'||g==="'"||g==="`")f=g;else if(g==="(")m++;else if(g===")"&&(m--,m===0)){let i=p+1;for(;i<e.length&&/\s/.test(e[i]);)i++;if(i<e.length&&e[i]==="]"){h=i;break}}}if(h!==-1)s+="[tool:functions."+r[1]+"()]",o=h+1,n.lastIndex=o;else{s+="[tool:functions."+r[1]+"(",o=e.length;break}}return o<e.length&&(s+=t&&o===0?jt(e.substring(o)):e.substring(o)),s},Ml=(e,t,n)=>{let s=Ko;s.lastIndex=0;let o="",r=0,d;for(;(d=s.exec(e))!==null;){let a=e.substring(r,d.index);o+=a.replace(t,n);let m=d.index+d[0].length-1,f=0,h=null,p=-1;for(let g=m;g<e.length;g++){let i=e[g];if(h){if(i===h){let x=0;for(let I=g-1;I>=0&&e[I]==="\\";I--)x++;x%2===0&&(h=null)}}else if(i==='"'||i==="'"||i==="`")h=i;else if(i==="(")f++;else if(i===")"&&(f--,f===0)){let x=g+1;for(;x<e.length&&/\s/.test(e[x]);)x++;if(x<e.length&&e[x]==="]"){p=x;break}}}if(p!==-1)o+=e.substring(d.index,p+1),r=p+1,s.lastIndex=r;else{o+=e.substring(d.index),r=e.length;break}}return r<e.length&&(o+=e.substring(r).replace(t,n)),o},pa=e=>ka(e,!0),Pl=e=>{if(!e)return e;let t={patchfile:"PatchFile",writefile:"WriteFile",readfile:"ReadFile",viewfile:"ReadFile",run:"Run",execcommand:"Run",searchkeyword:"SearchKeyword",codesearch:"CodeSearch",code_search:"CodeSearch",websearch:"WebSearch",webscrape:"WebScrape",readfolder:"ReadFolder",writepdf:"WritePDF",writedoc:"WriteDoc",writedocx:"WriteDoc",filemap:"FileMap",generateimage:"GenerateImage",todo:"Todo",goal:"Goal",askuser:"AskUser",ask:"AskUser"},n=o=>o.split("_").map(r=>r.charAt(0).toUpperCase()+r.slice(1)).join("");fa.lastIndex=0;let s=e.replace(fa,(o,r,d)=>{let a="";try{let h=JSON.parse(d.trim());h&&typeof h=="object"&&(a=Object.entries(h).map(([g,i])=>{let x=typeof i=="string"?i:JSON.stringify(i);return`${g}=${JSON.stringify(x)}`}).join(", "))}catch{let p=[],g=vl;g.lastIndex=0;let i;for(;(i=g.exec(d))!==null;){let x=i[1],I=i[2]!==void 0?i[2]:i[0].split(":").slice(1).join(":").trim();p.push(`${x}=${JSON.stringify(I)}`)}p.length>0?a=p.join(", "):a=d.trim()}let m=r.toLowerCase().replace(/_/g,"");return`[tool:functions.${t[m]||n(r)}(${a})]`});return ua.lastIndex=0,ga.lastIndex=0,s=s.replace(ua,""),s=s.replace(ga,""),s},Kn=e=>{if(!e)return[];let t=Pl(e),n=jt(t),s=[],o=Ii(n),r=bl;r.lastIndex=0;let d;for(;(d=r.exec(o))!==null;){let a=d[1],m=d.index+d[0].length-1,f=0,h=null,p=-1,g=-1;for(let i=m;i<o.length;i++){let x=o[i];if(h){if(x===h){let I=0;for(let Xe=i-1;Xe>=0&&o[Xe]==="\\";Xe--)I++;I%2===0&&(h=null)}}else{if(i>m&&(o.substring(i).startsWith("[action:")||o.substring(i).startsWith("[tool:")))break;if(x==='"'||x==="'"||x==="`")h=x;else if(x==="(")f++;else if(x===")"&&(f--,f===0)){g=i;let I=i+1;for(;I<o.length&&/\s/.test(o[I]);)I++;if(I<o.length&&o[I]==="]"){p=I;break}}}}if(p!==-1){let i=n.substring(m+1,g),x=n.substring(d.index,p+1);s.push({fullMatch:x,toolName:a.trim(),args:i.trim()}),r.lastIndex=p+1}}return s},ha=e=>{if(!e)return null;let t=jt(e),n=[],s=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,o=[],r;for(;(r=s.exec(t))!==null;)o.push({toolName:r[1],index:r.index,parenIndex:r.index+r[0].length-1});for(let g=0;g<o.length;g++){let i=o[g],x=g+1<o.length?o[g+1].index:t.length,I=t.substring(i.index,x),Xe=I.indexOf("("),C=Xe!==-1?I.substring(Xe+1):"",M=0,F=null,G=!1;for(let $=0;$<C.length;$++){let L=C[$];if(F){if(L===F){let Te=0;for(let Ae=$-1;Ae>=0&&C[Ae]==="\\";Ae--)Te++;Te%2===0&&(F=null)}}else if(L==='"'||L==="'"||L==="`")F=L;else if(L==="(")M++;else if(L===")")if(M>0)M--;else{let Te=$+1;for(;Te<C.length&&/\s/.test(C[Te]);)Te++;if(Te<C.length&&C[Te]==="]"){G=!0;break}}}if(!G){let $=I.trim(),L="";F?L=`Unclosed quote string (${F}) inside arguments`:$.endsWith("]")?L=`Missing closing ')' before ']' (e.g. found "...]")`:$.endsWith(")")?L=`Missing closing ']' after ')' (e.g. found "...)" instead of "...)]")`:!$.includes(")")&&!$.includes("]")?L="Missing closing delimiter ')]'":L="Malformed or unclosed call syntax (missing ')]')",n.push(`\u2022 [action:${i.toolName}(...)]: ${L}. Expected: [action:${i.toolName}(arg1="...", arg2="...")]`)}}let d=/(?:^|[^\w\[])(?:tool|action):(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/gi,a;for(;(a=d.exec(t))!==null;){let g=a[1],i=a.index+(a[0].indexOf(":")-(a[0].startsWith("action")||a[0].startsWith("tool")?0:1));(i>0?t[i-1]:"")!=="["&&Ai(g)&&n.push(`\u2022 action:${g}(...): Missing opening bracket '['. Expected: [action:${g}(...)]`)}let m=/\[\s*(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/g,f;for(;(f=m.exec(t))!==null;){let g=f[1];g!=="action"&&g!=="tool"&&Ai(g)&&n.push(`\u2022 [${g}(...)]: Missing 'action:' prefix. Expected: [action:${g}(...)]`)}let h=/\[\s*(?:tool|action)\s*:\s*(?:functions\.)?([a-zA-Z0-9_]+)(?!\s*\()/gi,p;for(;(p=h.exec(t))!==null;){let g=p[1];Ai(g)&&n.push(`\u2022 [action:${g}...]: Missing opening '(' for tool arguments. Expected: [action:${g}(...)]`)}return n.length>0?n.join(`
560
+ `):null},of=(e,t={})=>{if(!e)return null;if(Vo=t,Es=new ya({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}}}},Ta=e=>{if(!e)return{serviceTier:void 0,cleanModel:e};let t=e.toLowerCase();return t.endsWith(":flex")?{serviceTier:"flex",cleanModel:e.slice(0,-5)}:t.endsWith(":priority")?{serviceTier:"priority",cleanModel:e.slice(0,-9)}:{serviceTier:void 0,cleanModel:e}},$l=async(e,t,n,s,o="Fast",r=.75,d="agent")=>_l(async()=>{let{aiProvider:a="Google",apiKey:m,mode:f}=e,h="",p=null,g=typeof n=="string"?[{role:"user",parts:[{text:n}]}]:n,i=new AbortController,x=i.signal,I=setInterval(()=>{xt&&(i.abort(),clearInterval(I))},100),Xe=Date.now(),C=null;try{let M;if(a==="Ollama")M=(await de("Ollama"))(m,t,g,s,o,f,et(t),x,r,e.systemSettings?.ollamaEndpoint||"Cloud");else if(a==="OpenRouter")M=(await de("OpenRouter"))(m,t,g,s,o,f,et(t),x,r);else if(a==="DeepSeek")M=(await de("DeepSeek"))(m,t,g,s,o,f,et(t),x,r);else if(a==="Mistral")M=(await de("Mistral"))(m,t,g,s,o,f,et(t),x,r);else if(a==="NVIDIA")M=(await de("NVIDIA"))(m,t,g,s,o,f,et(t),x,r);else if(a==="InferX")M=(await de("InferX"))(m,t,g,s,o,f,et(t),x,r);else if(a==="SenseNova")M=(await de("SenseNova"))(m,t,g,s,o,f,et(t),x,r);else if(a==="AIHubMix")M=(await de("AIHubMix"))(m,t,g,s,o,f,et(t),x,r);else if(a==="Poolside")M=(await de("Poolside"))(m,t,g,s,o,f,et(t),x,r);else if(a==="9router"||a==="9Router")M=(await de("NineRouter"))(m,t,g,s,o,f,et(t),x,r);else if(a==="ExpLabs"||a==="ExperientialLabs")M=(await de("ExpLabs"))(m,t,g,s,o,f,et(t),x,r);else if(a==="Infron"||a==="infron")M=(await de("Infron"))(m,t,g,s,o,f,et(t),x,r);else if(a==="Numes"||a==="numes")M=(await de("Numes"))(m,t,g,s,o,f,et(t),x,r);else if(a==="TokenHarbor"||a==="Token Harbor"||a==="tokenharbor"||a==="token_harbor"||a==="thk")M=(await de("TokenHarbor"))(m,t,g,s,o,f,et(t),x,r);else if(a==="APInex"||a==="apinex"||a==="apx")M=(await de("APInex"))(m,t,g,s,o,f,et(t),x,r);else if(a==="xKiro"||a==="xkiro"||a==="kiro")M=(await de("xKiro"))(m,t,g,s,o,f,et(t),x,r);else if(a==="CoArena"||a==="coarena")M=(await de("CoArena"))(m,t,g,s,o,f,et(t),x,r);else if(a==="c_openai"||a==="Custom (OpenAI)"){let F=e.systemSettings?.customOpenAIBaseUrl||"";try{F=await Vi("c_openai")||F}catch{}M=(await de("c_openai"))(m,t,g,s,o,f,et(t),x,r,F)}else{let F=Sa(m),{serviceTier:G,cleanModel:$}=Ta(t),L={systemInstruction:s,temperature:r,thinkingConfig:(()=>{let Ae=(t||"").toLowerCase(),De=Ae.includes("gemma-4")||Ae.startsWith("gemma"),tt=Ae.includes("gemini-3");if(De||tt)return De?o.toLowerCase()!=="xhigh"?{includeThoughts:!1,thinkingLevel:Ye.MINIMAL}:{includeThoughts:!0,thinkingLevel:Ye.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:Ae.includes("pro")?Ye.LOW:Ye.MINIMAL,Low:Ye.LOW,Medium:Ye.MEDIUM,Standard:Ye.MEDIUM,High:Ye.HIGH,xHigh:Ye.HIGH}[o]||Ye.MEDIUM};{let B={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[o]||2048;return B===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:B}}})()};G&&(L.serviceTier=G),M=await F.models.generateContentStream({model:$,contents:g,config:L},{signal:x})}for await(let F of M){if(xt)throw new Error("Subagent task was cancelled.");if(e?.taskId&&typeof Ht<"u"){let L=Ht.find(Te=>Te.id===e.taskId);if(L&&L.status==="cancelled")throw new Error("Subagent task was cancelled.")}C===null&&(F.candidates?.[0]?.content?.parts||F.text)&&(C=Date.now()-Xe);let G="";if(F.candidates?.[0]?.content?.parts)for(let L of F.candidates[0].content.parts)L.text&&!L.thought&&(h+=L.text,G+=L.text);let $=G?Yi(G):0;e&&typeof e.onTokenChunk=="function"&&e.onTokenChunk(G,$),F.usageMetadata&&(p=F.usageMetadata)}}finally{clearInterval(I)}if(p){let M=p.totalTokenCount||0,F=p.cachedContentTokenCount||0,G=(p.candidatesTokenCount||0)+(a==="Google"&&p.thoughtsTokenCount||0);await hn("tokens",M,a,t),F>0&&await hn("cachedTokens",F,a,t),G>0&&await hn("candidateTokens",G,a,t),C!==null&&C>0&&await hn("ttft",C,a,t),ci({provider:a,model:t,prompt:p.promptTokenCount||0,cached:F,output:G,reasoning:p.thoughtsTokenCount||0,ttft:C}),e&&typeof e.onUsage=="function"&&e.onUsage({totalTokenCount:M,cachedContentTokenCount:F,candidatesTokenCount:G})}return await $t("agent",a),{text:h,usageMetadata:p}}),sf=async function*(e,t,n,s,o){let{profile:r,thinkingLevel:d,mode:a,janitorModel:m,chatId:f,isPlayground:h,systemSettings:p,sessionStats:g,aiProvider:i="Google",apiTier:x,wildcardTooling:I,wildercardTooling:Xe}=n,C=et(e);if(!Es&&i==="Google")throw new Error("AI not initialized");let M=!1,F=t[t.length-1].text,G=U.join(js,"chat-summaries.json"),$=!1,L=t.filter(B=>B.role==="user").length===1,Te=F.includes("[TITLE-UPDATE]"),Ae=L||Te,De=F.replace(/\[TITLE-UPDATE\]/g,"").trim();De=De.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),yield{type:"status",content:"[start]"},yield{type:"status",content:"Gathering Context"},await di.startTransaction(f,De),p?.advanceRollback&&await Mo.takeInitialSnapshot(f),xt=!1;let tt=null;try{let B=new AbortController;tt=setInterval(()=>{xt&&(B.abort(),tt&&(clearInterval(tt),tt=null))},400);let w=[...t.slice(0,-1)];{let ge=pn(G,{})[f]||{summary:"",historyLength:0};if(ge.summary&&ge.historyLength>0){let kt=0,le=[];for(let H=0;H<w.length;H++){let Se=w[H];(Se.role==="user"||Se.role==="agent"||Se.role==="system")&&!String(Se.id).startsWith("welcome")&&!Se.isMeta&&kt++,kt>ge.historyLength&&le.push(Se)}w=le}}w=w.map(b=>{if(b.role==="user"&&b.text){let ge=b.text.match(/\[USER\]([\s\S]*?)\[\/USER\]/);if(ge)return{...b,text:ge[1].trim()}}return{...b}});let wn=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1,Qt={"16k":16e3,"32k":32e3,"64k":64e3,"128k":128e3,"256k":256e3,"512k":512e3,"1M":1e6}[p?.contextLength]||256e3;if(i==="Google"&&e?.includes("gemma")&&wn&&(Qt=16e3),(g?.tokens||0)>Qt){yield{type:"text",content:"\u2726 Maximum Context Limit Reached. Start a new chat."};return}if(L&&M){let b=pn(Hi,{});Object.values(b).flat().length>5}let Pe=pn(Hi,{}),X=pn(Ks,{}),Ve=Object.entries(Pe).filter(([b])=>b!==f).flatMap(([b,ge])=>ge),In=[...Object.entries(X).filter(([b])=>b!==f).slice(-20).map(([b,ge])=>`[Chat Summary]: ${ge}`),...Ve].map(b=>`- ${b}`).join(`
557
561
  `),bn=pn(si,[]).map(b=>`- ${b.memory}`).join(`
558
- `),De=(g?.tokens||0)>=1e4,wt=new Date,Ft=wt.getFullYear(),Sn=wt.toLocaleString("en-US",{month:"short"}).toUpperCase(),cn=String(wt.getDate()).padStart(2,"0"),wo=`${wt.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}`,j=b=>{try{return we.readdirSync(b,{withFileTypes:!0})}catch{return[]}},N=Array.from(new Set([..._o,...Io(process.cwd())])),Vn=(b,ue=6)=>p?.indentationTree!==!1?Ss(b,ue,1,j,N):Ts(b,ue,"",1,j,N),st=pn(ji,{}),k=st[f],ee=k?k!==process.cwd():!1;st[f]=process.cwd(),Ki(ji,st);let Je=pn(G,{}),Ce=Je[f]||{summary:"",historyLength:0};typeof Ce=="string"&&(Ce={summary:Ce,historyLength:0});let lt=t.filter(b=>(b.role==="user"||b.role==="agent"||b.role==="system")&&!String(b.id).startsWith("welcome")&&!b.isMeta).length;Ce.historyLength&&lt<Ce.historyLength&&(Ce.summary="",Ce.historyLength=0,Je[f]=Ce,Ki(G,Je));let ft=typeof Ce=="object"?Ce.summary||"":Ce||"",Zt=w.length>0;Zt&&ft&&w[0]&&(w[0].role==="user"||w[0].role==="system")&&(w[0].text.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")||(w[0].text=`[SYSTEM METADATA]
562
+ `),Fe=(g?.tokens||0)>=1e4,wt=new Date,Ft=wt.getFullYear(),Sn=wt.toLocaleString("en-US",{month:"short"}).toUpperCase(),cn=String(wt.getDate()).padStart(2,"0"),wo=`${wt.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}`,K=b=>{try{return we.readdirSync(b,{withFileTypes:!0})}catch{return[]}},N=Array.from(new Set([..._o,...Io(process.cwd())])),Vn=(b,ge=6)=>p?.indentationTree!==!1?Ss(b,ge,1,K,N):Ts(b,ge,"",1,K,N),st=pn(ji,{}),k=st[f],te=k?k!==process.cwd():!1;st[f]=process.cwd(),Ki(ji,st);let Je=pn(G,{}),Ce=Je[f]||{summary:"",historyLength:0};typeof Ce=="string"&&(Ce={summary:Ce,historyLength:0});let lt=t.filter(b=>(b.role==="user"||b.role==="agent"||b.role==="system")&&!String(b.id).startsWith("welcome")&&!b.isMeta).length;Ce.historyLength&&lt<Ce.historyLength&&(Ce.summary="",Ce.historyLength=0,Je[f]=Ce,Ki(G,Je));let ft=typeof Ce=="object"?Ce.summary||"":Ce||"",Zt=w.length>0;Zt&&ft&&w[0]&&(w[0].role==="user"||w[0].role==="system")&&(w[0].text.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")||(w[0].text=`[SYSTEM METADATA]
559
563
  **CONTEXT SUMMARY OF PREVIOUS TURNS (PRIORITY: DYNAMIC)**
560
564
  ${ft}
561
565
 
@@ -563,38 +567,38 @@ ${ft}
563
567
  [SYSTEM METADATA]
564
568
  **CONTEXT SUMMARY OF PREVIOUS TURNS**
565
569
  ${ft}
566
- `:"",kn=!!p?.dynamicDirAwareness,_s=`${f}|${s}|${d}|${e}|${r}|${kn}`,Aa=!kn&&no.key===_s&&no.value?"":`
570
+ `:"",kn=!!p?.dynamicDirAwareness,_s=`${f}|${i}|${d}|${e}|${r}|${kn}`,Aa=!kn&&no.key===_s&&no.value?"":`
567
571
  **Directory**
568
572
  CWD: `+process.cwd()+`${h?" [PLAYGROUND MODE]":""}
569
- `+Vn(process.cwd(),6),Ot=yo()?await to():null,Is=b=>{if(!b||!Array.isArray(b)||b.length===0)return null;let ue=new Map;for(let le of b){let K=le.relPath||(le.file?B.relative(process.cwd(),le.file):"unknown");ue.has(K)||ue.set(K,[]),ue.get(K).push(le)}let kt=[];for(let[le,K]of ue.entries()){kt.push(`- ${le}:`);for(let Se of K){let Pe=(Se.snippet||"").trim().replace(/\r?\n/g," "),tt=Se.line||1,Bt=(Se.text||"").trim().replace(/\r?\n+/g,". "),Tt=Bt?` [${Bt}]`:"";kt.push(` ~L${tt}${Tt}`)}}return kt.join(`
573
+ `+Vn(process.cwd(),6),Ot=yo()?await to():null,Is=b=>{if(!b||!Array.isArray(b)||b.length===0)return null;let ge=new Map;for(let le of b){let H=le.relPath||(le.file?U.relative(process.cwd(),le.file):"unknown");ge.has(H)||ge.set(H,[]),ge.get(H).push(le)}let kt=[];for(let[le,H]of ge.entries()){kt.push(`- ${le}:`);for(let Se of H){let $e=(Se.snippet||"").trim().replace(/\r?\n/g," "),nt=Se.line||1,Bt=(Se.text||"").trim().replace(/\r?\n+/g,". "),Tt=Bt?` [${Bt}]`:"";kt.push(` ~L${nt}${Tt}`)}}return kt.join(`
570
574
  `)},Pi=Is(Ot?.comments),Tn="";if(Ot&&Ot.file_focused!=="none"){Tn=`
571
575
  [Additional IDE Context]
572
- `;let b=B.relative(process.cwd(),Ot.file_focused),ue=(Ot.opened_editors||[]).map(le=>{let K=B.relative(process.cwd(),le);return K.startsWith("..")?`[External] ${B.basename(le)}`:K});if(Tn+=`Focused File: ${b}
576
+ `;let b=U.relative(process.cwd(),Ot.file_focused),ge=(Ot.opened_editors||[]).map(le=>{let H=U.relative(process.cwd(),le);return H.startsWith("..")?`[External] ${U.basename(le)}`:H});if(Tn+=`Focused File: ${b}
573
577
  Cursor Line: ${Ot.cursor_line}
574
- `,Ot.selected){let le=Ot.selected,K=le.split(`
575
- `);K.length>256&&(le=K.slice(0,240).join(`
578
+ `,Ot.selected){let le=Ot.selected,H=le.split(`
579
+ `);H.length>256&&(le=H.slice(0,240).join(`
576
580
  `)+`
577
581
  ... [truncated] ...
578
- `+K.slice(-16).join(`
582
+ `+H.slice(-16).join(`
579
583
  `)),le.length>2048&&(le=le.slice(0,1920)+`
580
584
  ... [truncated] ...
581
585
  `+le.slice(-128)),Tn+=`Current Selection: "${le}"
582
586
  `}if(Ot.manual_edits){let le=Ot.manual_edits.split(`
583
- `),K=[];for(let Se=0;Se<le.length;Se++){let Pe=le[Se],tt=le[Se+1],Bt=le[Se+2];if(tt!==void 0&&Bt!==void 0&&/:\s*$/.test(Pe)&&/^\s*-\s*/.test(tt)&&/^\s*\+\s*/.test(Bt)&&(tt.length>300||Bt.length>300)){K.push(Pe.replace(/:\s*$/,": [changed]")),Se+=2;continue}K.push(Pe)}Tn+=`Recent Manual Edits:
584
- ${K.join(`
587
+ `),H=[];for(let Se=0;Se<le.length;Se++){let $e=le[Se],nt=le[Se+1],Bt=le[Se+2];if(nt!==void 0&&Bt!==void 0&&/:\s*$/.test($e)&&/^\s*-\s*/.test(nt)&&/^\s*\+\s*/.test(Bt)&&(nt.length>300||Bt.length>300)){H.push($e.replace(/:\s*$/,": [changed]")),Se+=2;continue}H.push($e)}Tn+=`Recent Manual Edits:
588
+ ${H.join(`
585
589
  `)}
586
- `}ue.length>0&&(Tn+=`All Opened Editors: ${ue.join(", ")}`),Ot.diagnostics&&(Tn+=`
590
+ `}ge.length>0&&(Tn+=`All Opened Editors: ${ge.join(", ")}`),Ot.diagnostics&&(Tn+=`
587
591
  **Active File Errors**:
588
592
  ${Ot.diagnostics}
589
- `),(Ne.toLowerCase().includes("lint")||Ne.toLowerCase().includes("warning"))&&Ot.warnings&&(Tn+=`
593
+ `),(De.toLowerCase().includes("lint")||De.toLowerCase().includes("warning"))&&Ot.warnings&&(Tn+=`
590
594
  **Lint Warnings**:
591
595
  ${Ot.warnings}
592
- `)}let Ms=Ne.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),Ps=/(?:\\)?@\[([^\]]+)\]/g,$i,Li=[];for(Ps.lastIndex=0;($i=Ps.exec(Ms))!==null;){let b=$i[0].startsWith("\\");Li.push({tag:$i[1],isEscaped:b})}let Oi=[],zo=null,qo=!1;for(let b=0;b<Li.length;b++){let{tag:ue,isEscaped:kt}=Li[b];if(!kt)try{let le=ue.trim().replace(/^["']|["']$/g,""),K=/[:#]L?(\d+)(?:-L?(\d+))?$/i,Se=le.match(K),Pe=le,tt=null,Bt=null;Se&&(tt=parseInt(Se[1],10),Bt=Se[2]?parseInt(Se[2],10):tt,Pe=le.slice(0,Se.index));let Tt=B.resolve(process.cwd(),Pe);if(we.existsSync(Tt)&&we.statSync(Tt).isFile()){let Ut=Pe.toLowerCase(),bo=Ut.endsWith(".pdf"),qn=Ut.endsWith(".docx")||Ut.endsWith(".doc")||Ut.endsWith(".ppt")||Ut.endsWith(".pptx")||Ut.endsWith(".xls")||Ut.endsWith(".xlsx"),Yn=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(Ut),je=Yn||bo||qn,Et=s==="Google"||it(e);if(je&&!Et){let pe=`\u2718 Unsupported Modality: ${B.basename(Pe)}`,Qe=115;process.stdout.isTTY&&(Qe=process.stdout.columns-5||120);let _t=[pe],Fe=Math.max(..._t.map(nn=>nn.length)),te=Math.min(Fe+4,Qe),Be=_t.map(nn=>`${nn.padEnd(te-2).substring(0,te-2)}`).join(`
593
- `);yield{type:"visual_feedback",content:Lt(`${Be}
594
- `)};continue}if(tt===null&&!je){let pe=0;try{pe=we.readFileSync(Tt,"utf8").split(/\r\n|\r|\n/).length}catch{}if(pe>150){let Qe=`\u21B7 Skipped (Too Large): ${B.basename(Pe)}`,_t=115;process.stdout.isTTY&&(_t=process.stdout.columns-5||120);let Fe=Math.min(Qe.length+4,_t),te=Qe.padEnd(Fe-2).substring(0,Fe-2);yield{type:"visual_feedback",content:Lt(`${te}
595
- `)};continue}}let Pn=tt!==null?tt:1,Wt=Bt!==null?Bt:tt!==null?tt:Pn+149;if(Wt-Pn>200){let pe=`\u21B7 Skipped (Too Large): ${B.basename(Pe)}`,Qe=115;process.stdout.isTTY&&(Qe=process.stdout.columns-5||120);let _t=Math.min(pe.length+4,Qe),Fe=pe.padEnd(_t-2).substring(0,_t-2);yield{type:"visual_feedback",content:Lt(`${Fe}
596
- `)};continue}let Xn=`path=${JSON.stringify(Pe)}, startLine=${Pn}, endLine=${Wt}`,Gt=await tr(Xn,{isMultiModal:Et}),$n=!1,ro="",bt=null;if(typeof Gt=="string"?Gt.trim().startsWith("ERROR")?$n=!0:ro=Gt:Gt&&typeof Gt=="object"&&Gt.binaryPart?(bt=Gt.binaryPart,ro=Gt.text||""):$n=!0,!$n){let pe="";if(Yn?(pe=`\u2714 Processed: ${B.basename(Pe)}`,zo=bt,qo=!0):bo||qn?(pe=`\u2714 Auto-Analysed: ${B.basename(Pe)}`,zo=bt,qo=!0):(pe=`\u2714 Auto-Read: ${B.basename(Pe)}`,Oi.push(ro)),pe){let Qe=115;process.stdout.isTTY&&(Qe=process.stdout.columns-5||120);let _t=[pe],Fe=Math.max(..._t.map(nn=>nn.length)),te=Math.min(Fe+4,Qe),Be=_t.map(nn=>`${nn.padEnd(te-2).substring(0,te-2)}`).join(`
597
- `);yield{type:"visual_feedback",content:Lt(`${Be}
596
+ `)}let Ms=De.replace(/\s*\[Prompted on:.*?\]/g,"").trim(),Ps=/(?:\\)?@\[([^\]]+)\]/g,$i,Li=[];for(Ps.lastIndex=0;($i=Ps.exec(Ms))!==null;){let b=$i[0].startsWith("\\");Li.push({tag:$i[1],isEscaped:b})}let Oi=[],zo=null,qo=!1;for(let b=0;b<Li.length;b++){let{tag:ge,isEscaped:kt}=Li[b];if(!kt)try{let le=ge.trim().replace(/^["']|["']$/g,""),H=/[:#]L?(\d+)(?:-L?(\d+))?$/i,Se=le.match(H),$e=le,nt=null,Bt=null;Se&&(nt=parseInt(Se[1],10),Bt=Se[2]?parseInt(Se[2],10):nt,$e=le.slice(0,Se.index));let Tt=U.resolve(process.cwd(),$e);if(we.existsSync(Tt)&&we.statSync(Tt).isFile()){let Ut=$e.toLowerCase(),bo=Ut.endsWith(".pdf"),qn=Ut.endsWith(".docx")||Ut.endsWith(".doc")||Ut.endsWith(".ppt")||Ut.endsWith(".pptx")||Ut.endsWith(".xls")||Ut.endsWith(".xlsx"),Yn=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(Ut),je=Yn||bo||qn,Et=i==="Google"||et(e);if(je&&!Et){let pe=`\u2718 Unsupported Modality: ${U.basename($e)}`,Qe=115;process.stdout.isTTY&&(Qe=process.stdout.columns-5||120);let _t=[pe],Be=Math.max(..._t.map(nn=>nn.length)),J=Math.min(Be+4,Qe),Le=_t.map(nn=>`${nn.padEnd(J-2).substring(0,J-2)}`).join(`
597
+ `);yield{type:"visual_feedback",content:Lt(`${Le}
598
+ `)};continue}if(nt===null&&!je){let pe=0;try{pe=we.readFileSync(Tt,"utf8").split(/\r\n|\r|\n/).length}catch{}if(pe>150){let Qe=`\u21B7 Skipped (Too Large): ${U.basename($e)}`,_t=115;process.stdout.isTTY&&(_t=process.stdout.columns-5||120);let Be=Math.min(Qe.length+4,_t),J=Qe.padEnd(Be-2).substring(0,Be-2);yield{type:"visual_feedback",content:Lt(`${J}
599
+ `)};continue}}let Pn=nt!==null?nt:1,Wt=Bt!==null?Bt:nt!==null?nt:Pn+149;if(Wt-Pn>200){let pe=`\u21B7 Skipped (Too Large): ${U.basename($e)}`,Qe=115;process.stdout.isTTY&&(Qe=process.stdout.columns-5||120);let _t=Math.min(pe.length+4,Qe),Be=pe.padEnd(_t-2).substring(0,_t-2);yield{type:"visual_feedback",content:Lt(`${Be}
600
+ `)};continue}let Xn=`path=${JSON.stringify($e)}, startLine=${Pn}, endLine=${Wt}`,Gt=await tr(Xn,{isMultiModal:Et}),$n=!1,ro="",bt=null;if(typeof Gt=="string"?Gt.trim().startsWith("ERROR")?$n=!0:ro=Gt:Gt&&typeof Gt=="object"&&Gt.binaryPart?(bt=Gt.binaryPart,ro=Gt.text||""):$n=!0,!$n){let pe="";if(Yn?(pe=`\u2714 Processed: ${U.basename($e)}`,zo=bt,qo=!0):bo||qn?(pe=`\u2714 Auto-Analysed: ${U.basename($e)}`,zo=bt,qo=!0):(pe=`\u2714 Auto-Read: ${U.basename($e)}`,Oi.push(ro)),pe){let Qe=115;process.stdout.isTTY&&(Qe=process.stdout.columns-5||120);let _t=[pe],Be=Math.max(..._t.map(nn=>nn.length)),J=Math.min(Be+4,Qe),Le=_t.map(nn=>`${nn.padEnd(J-2).substring(0,J-2)}`).join(`
601
+ `);yield{type:"visual_feedback",content:Lt(`${Le}
598
602
  `)}}}}}catch{}}let Yo="";Oi.length>0?Yo=`
599
603
  [Tagged File Contents] Auto Read User Tagged files by System${qo?", attached below & multimodal part":""}. No need to re-read
600
604
  `+Oi.join(`
@@ -604,7 +608,7 @@ ${Ot.warnings}
604
608
  `:qo&&(Yo=`
605
609
  [Tagged File Contents] Auto Read User Tagged files by System & attached as multimodal part. No need to re-read [Tagged File Contents]
606
610
  `);let Ue=Ms.replace(/\\(@\[[^\]]+\])/g,"$1"),$s=I?`You cannot execute tools. Instead write the action string in chat you WOULD have written, without markdown wrappers. Then wait for systtem response
607
- `:"",Ca=process.env.forcedReasoning||!1,Ls=d!=="Fast"&&(s==="Mistral"&&!ai(e)||d!=="High"&&s==="Google")?`${s==="Mistral"&&!ai(e)||e.toLowerCase().startsWith("gemma")||Ca?`[system] strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow> [/system]
611
+ `:"",Ca=process.env.forcedReasoning||!1,Ls=d!=="Fast"&&(i==="Mistral"&&!ai(e)||d!=="High"&&i==="Google")?`${i==="Mistral"&&!ai(e)||e.toLowerCase().startsWith("gemma")||Ca?`[system] strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow> [/system]
608
612
  `:""}`:"",so="";if(p?.clipboardContext)try{process.platform==="win32"?so=As("powershell.exe -NoProfile -Command Get-Clipboard",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):process.platform==="darwin"?so=As("pbpaste",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):so=As("xclip -selection clipboard -o || xsel --clipboard --output",{encoding:"utf8",shell:!0,stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,"")}catch{so=""}let Xo="",Ra=!!p?.autoExcludeMetadata,Os=!1,Ns=!1,Ni="";if(Ue.startsWith("/skill create ")||Ue==="/skill create"){let b=null;Os=!0,Ue=Ue.replace(/^\/skill\s+create\b/,"").trim(),/^--project(\s|$)|(\s|^)--project$/.test(Ue)?b="project":/^--global(\s|$)|(\s|^)--global$/.test(Ue)&&(b="global"),Ue=Ue.replace(/^--project\s*|\s*--project$/g,"").trim(),Ue=Ue.replace(/^--global\s*|\s*--global$/g,"").trim(),Ue=Ue.replace(/^(['"])([\s\S]*)\1$/,"$2").trim(),Ni=`[system] ## Skill Creation Rules
609
613
  * ${b?b==="project"?`Creation path: ./skills/skillName?/SKILL.md
610
614
  * If skills folder already present, ReadFolder for existing structure`:"Creation path: ~/.fluxflow/skills/skillName/SKILL.md":`Extract skill scope, global/project. If not given AskUser. Project scope: ./skills/skillName?/SKILL.md. Global scope: ~/.fluxflow/skills/skillName/SKILL.md
@@ -622,7 +626,7 @@ description: concise detail to explain the skill
622
626
  * After creation, tell user to restart fluxflow for reindexing${(g?.tokens||0)>24576?`
623
627
  * Warn: This session is currently long, and reindexing will cause full cache invalidation`:""}
624
628
  [/system]
625
- `}else if(Ue.startsWith("/skill edit ")||Ue==="/skill edit"){Ns=!0,Ue=Ue.replace(/^\/skill\s+edit\b/,"").trim();let b=null,ue=Ue.match(/^--([^\s]+)(?:\s|$)/);if(ue)b=ue[1],Ue=Ue.slice(ue[0].length).trim();else{let K=Ue.match(/(?:\s|^)--([^\s]+)$/);K&&(b=K[1],Ue=Ue.slice(0,K.index).trim())}Ue=Ue.replace(/^(['"])([\s\S]*)\1$/,"$2").trim();let kt=null,le=null;if(b){let K=b.toLowerCase(),Se=[...yi||[],...hi||[]].find(Pe=>Pe&&Pe.name&&Pe.name.toLowerCase()===K);Se&&Se.filePath&&(le=B.resolve(Se.filePath),kt=B.dirname(le))}Ni=`[system] ## Skill Modification Rules
629
+ `}else if(Ue.startsWith("/skill edit ")||Ue==="/skill edit"){Ns=!0,Ue=Ue.replace(/^\/skill\s+edit\b/,"").trim();let b=null,ge=Ue.match(/^--([^\s]+)(?:\s|$)/);if(ge)b=ge[1],Ue=Ue.slice(ge[0].length).trim();else{let H=Ue.match(/(?:\s|^)--([^\s]+)$/);H&&(b=H[1],Ue=Ue.slice(0,H.index).trim())}Ue=Ue.replace(/^(['"])([\s\S]*)\1$/,"$2").trim();let kt=null,le=null;if(b){let H=b.toLowerCase(),Se=[...yi||[],...hi||[]].find($e=>$e&&$e.name&&$e.name.toLowerCase()===H);Se&&Se.filePath&&(le=U.resolve(Se.filePath),kt=U.dirname(le))}Ni=`[system] ## Skill Modification Rules
626
630
  ${kt&&b?`* Target Skill: ${b}
627
631
  * Physical Skill path: ${le}
628
632
  * Skill will have a SKILL.md at this path. And may have lazy loaded *.md files in folders
@@ -632,7 +636,7 @@ ${kt&&b?`* Target Skill: ${b}
632
636
  * After completion tell user no reindexing needed, will be auto updated on next #skill read if frontmatter stays same${(g?.tokens||0)>24576?`
633
637
  * Warn: This session is currently long, if name, description is changed reindex is needed, and will cause a full cache invalidation`:""}`:"- User didnt provided any structured skill name to modify. Tell them to use proper syntax: `/skill edit --skillName instructions`"}
634
638
  [/system]
635
- `}let va=!!(Tn||Yo||$s||dn||Ls||ee||p?.dynamicDirAwareness||p?.autoTruncateResults||Os||Ns);Ra&&!va?Xo=Ue.trim():Xo=`[System Metadata] Time: ${wo}${ee?`
639
+ `}let va=!!(Tn||Yo||$s||dn||Ls||te||p?.dynamicDirAwareness||p?.autoTruncateResults||Os||Ns);Ra&&!va?Xo=Ue.trim():Xo=`[System Metadata] Time: ${wo}${te?`
636
640
  WARNING: CWD Changed from previous: "${k}" to current: "${process.cwd()}", write change in chat to avoid future path mismatches
637
641
  `:""}${Tn}
638
642
  ${so.trim().length>0?`[Clipboard Context]
@@ -641,128 +645,128 @@ ${so.trim().length>0?`[Clipboard Context]
641
645
  ${Pi.trimEnd()}
642
646
  `:""}Action format: [action:ActionName(...)]
643
647
  [/Metadata]
644
- ${dn}${Ls}${Yo}${Ni}${$s}[user prompt] ${Ue.trim()} [/user prompt]`.trim();let Ds={role:"user",text:Xo};zo&&(Ds.binaryPart=zo),w.forEach(b=>{b.text&&b.role==="agent"&&(b.text=jt(b.text))}),w.push(Ds),dn&&t[t.length-1]?.id&&(yield{type:"summary_injected",content:{id:t[t.length-1].id,text:Xo}});let en=null,tn=l==="Flux"?50:15;tn=l.toLowerCase().includes("cu")?75:tn;let Fs=(p?.loopLimits||"Default").toLowerCase();if(Fs==="extended")tn=Math.floor(tn*3);else if(Fs==="env"){let b=parseInt(process.env.FLUXFLOW_MAX_LOOPS||process.env.MAX_LOOPS||"",10);Number.isFinite(b)&&b>0&&(tn=b)}let Ea=Math.floor(tn/2),Bs=0,fn=16;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Consulting the spirits":"Connecting"},xt=!1;let Di=[],Jo=!1,Us=!1,zn=[],Fi=!1;for(let b=0;b<=tn;b++){let ue=Math.floor(tn*.95);if(b>=ue&&Bs<ue&&typeof n?.onAskUser=="function"){Bs=ue;try{let H="Agent has been running for a long time. Do you want to continue execution?",X=[{id:"continue",label:"Continue",description:"Add few more steps"},{id:"cancel",label:"Cancel",description:"Stop extending and finish current turn limit"}],E=await n.onAskUser(H,X);E&&(E.toLowerCase().includes("continue")||E==="Continue")&&(tn+=Ea)}catch{}}if(zn.length>=10&&typeof n?.onAskUser=="function"){let H={},X=null;for(let E of zn)if(H[E]=(H[E]||0)+1,H[E]>=10){X=E;break}if(X)try{let E="Agent seems stuck in a tool loop. You can prompt it to steer or break the loop:",gt=[{id:"continue",label:"Continue Anyway",description:"Ignore warning and let it proceed"},{id:"stop",label:"Stop Loop",description:"Force agent to summarize progress and stop repeating"}],de=await n.onAskUser(E,gt);if(de){let We="";typeof de=="string"&&(de.toLowerCase()==="stop"||de.includes("Stop Loop"))?We="Stop repeating the same action call. Acknowledge what failed or succeeded, summarize your current findings, and conclude.":typeof de=="string"&&(de.toLowerCase()==="continue"||de.includes("Continue Anyway"))?zn=zn.filter(At=>At!==X):We=typeof de=="string"?de:de?.label||de?.id||"",We&&(w.length>0&&w[w.length-1].role==="user"?w[w.length-1].text+=`
648
+ ${dn}${Ls}${Yo}${Ni}${$s}[user prompt] ${Ue.trim()} [/user prompt]`.trim();let Ds={role:"user",text:Xo};zo&&(Ds.binaryPart=zo),w.forEach(b=>{b.text&&b.role==="agent"&&(b.text=jt(b.text))}),w.push(Ds),dn&&t[t.length-1]?.id&&(yield{type:"summary_injected",content:{id:t[t.length-1].id,text:Xo}});let en=null,tn=a==="Flux"?50:15;tn=a.toLowerCase().includes("cu")?75:tn;let Fs=(p?.loopLimits||"Default").toLowerCase();if(Fs==="extended")tn=Math.floor(tn*3);else if(Fs==="env"){let b=parseInt(process.env.FLUXFLOW_MAX_LOOPS||process.env.MAX_LOOPS||"",10);Number.isFinite(b)&&b>0&&(tn=b)}let Ea=Math.floor(tn/2),Bs=0,fn=16;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Consulting the spirits":"Connecting"},xt=!1;let Di=[],Jo=!1,Us=!1,zn=[],Fi=!1;for(let b=0;b<=tn;b++){let ge=Math.floor(tn*.95);if(b>=ge&&Bs<ge&&typeof n?.onAskUser=="function"){Bs=ge;try{let j="Agent has been running for a long time. Do you want to continue execution?",Q=[{id:"continue",label:"Continue",description:"Add few more steps"},{id:"cancel",label:"Cancel",description:"Stop extending and finish current turn limit"}],E=await n.onAskUser(j,Q);E&&(E.toLowerCase().includes("continue")||E==="Continue")&&(tn+=Ea)}catch{}}if(zn.length>=10&&typeof n?.onAskUser=="function"){let j={},Q=null;for(let E of zn)if(j[E]=(j[E]||0)+1,j[E]>=10){Q=E;break}if(Q)try{let E="Agent seems stuck in a tool loop. You can prompt it to steer or break the loop:",gt=[{id:"continue",label:"Continue Anyway",description:"Ignore warning and let it proceed"},{id:"stop",label:"Stop Loop",description:"Force agent to summarize progress and stop repeating"}],fe=await n.onAskUser(E,gt);if(fe){let We="";typeof fe=="string"&&(fe.toLowerCase()==="stop"||fe.includes("Stop Loop"))?We="Stop repeating the same action call. Acknowledge what failed or succeeded, summarize your current findings, and conclude.":typeof fe=="string"&&(fe.toLowerCase()==="continue"||fe.includes("Continue Anyway"))?zn=zn.filter(At=>At!==Q):We=typeof fe=="string"?fe:fe?.label||fe?.id||"",We&&(w.length>0&&w[w.length-1].role==="user"?w[w.length-1].text+=`
645
649
 
646
- [STEERING HINT from USER, High Priority] ${We.trim()} [/STEERING HINT]`:w.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${We.trim()} [/STEERING HINT]`}),yield{type:"status",content:"Steering Hint Injected..."},zn=zn.filter(At=>At!==X))}}catch{}}let kt=await qi("agent",n);if(!kt.allowed)throw new Error(kt.reason||`Budget Exhausted for Provider (${s||"Agent"})`);let le=[];if(Jo=!1,(l==="ICU"||l==="FluxCU")&&!Fi)try{yield{type:"status",content:"Capturing Screen"},await new Promise(E=>setTimeout(E,1e3));let{captureGriddedScreenshot:H}=await import("./screen_grid-PHZTVWOJ.js"),X=await H();if(X&&X.base64){let E="[system] Fresh Gridded Screen Feedback Captured. Use numeric coordinates. Old screenshots will be removed when new screenshot is captured, summarize in text if context is needed later [/system]",gt={inlineData:{mimeType:X.mimeType,data:X.base64}},de=p?.imageHistoryCU||"Standard",We=de==="Low"?3:de==="Extended"?10:de==="Max"?999:5,At=w.filter(ge=>Array.isArray(ge.parts)&&ge.parts.some(St=>St.inlineData));if(At.length>=We){let ge=At.length-We+1;for(let St=0;St<ge;St++){let nt=At[St];Array.isArray(nt.parts)&&(nt.parts=nt.parts.filter(mt=>!mt.inlineData))}}if(w.length>0&&w[w.length-1].role==="user"){let ge=w[w.length-1];typeof ge.text=="string"&&(ge.text+=`
650
+ [STEERING HINT from USER, High Priority] ${We.trim()} [/STEERING HINT]`:w.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${We.trim()} [/STEERING HINT]`}),yield{type:"status",content:"Steering Hint Injected..."},zn=zn.filter(At=>At!==Q))}}catch{}}let kt=await qi("agent",n);if(!kt.allowed)throw new Error(kt.reason||`Budget Exhausted for Provider (${i||"Agent"})`);let le=[];if(Jo=!1,(a==="ICU"||a==="FluxCU")&&!Fi)try{yield{type:"status",content:"Capturing Screen"},await new Promise(E=>setTimeout(E,1e3));let{captureGriddedScreenshot:j}=await import("./screen_grid-SUWYGRSE.js"),Q=await j();if(Q&&Q.base64){let E="[system] Fresh Gridded Screen Feedback Captured. Use numeric coordinates. Old screenshots will be removed when new screenshot is captured, summarize in text if context is needed later [/system]",gt={inlineData:{mimeType:Q.mimeType,data:Q.base64}},fe=p?.imageHistoryCU||"Standard",We=fe==="Low"?3:fe==="Extended"?10:fe==="Max"?999:5,At=w.filter(me=>Array.isArray(me.parts)&&me.parts.some(St=>St.inlineData));if(At.length>=We){let me=At.length-We+1;for(let St=0;St<me;St++){let ot=At[St];Array.isArray(ot.parts)&&(ot.parts=ot.parts.filter(mt=>!mt.inlineData))}}if(w.length>0&&w[w.length-1].role==="user"){let me=w[w.length-1];typeof me.text=="string"&&(me.text+=`
647
651
 
648
- ${E}`,Array.isArray(ge.parts)||(ge.parts=[{text:ge.text}]),ge.parts.push(gt))}else w.push({role:"user",text:E,parts:[{text:E},gt]})}}catch(H){console.error("Vision screenshot capture error:",H)}if(Fi=!1,b>0?yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Haunting":"Working"}:yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Consulting the spirits":"Connecting"},xt){try{let{clearPendingNudges:H}=await import("./subagent_state-LZCOZSUJ.js");H()}catch{}yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
652
+ ${E}`,Array.isArray(me.parts)||(me.parts=[{text:me.text}]),me.parts.push(gt))}else w.push({role:"user",text:E,parts:[{text:E},gt]})}}catch(j){console.error("Vision screenshot capture error:",j)}if(Fi=!1,b>0?yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Haunting":"Working"}:yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Consulting the spirits":"Connecting"},xt){try{let{clearPendingNudges:j}=await import("./subagent_state-LZCOZSUJ.js");j()}catch{}yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
649
653
 
650
- \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}try{let{consumePendingNudges:H}=await import("./subagent_state-LZCOZSUJ.js"),X=H();if(X&&X.length>0){let E=X.join(`
654
+ \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}try{let{consumePendingNudges:j}=await import("./subagent_state-LZCOZSUJ.js"),Q=j();if(Q&&Q.length>0){let E=Q.join(`
651
655
 
652
656
  `);w.length>0&&w[w.length-1].role==="user"?w[w.length-1].text+=`
653
657
 
654
- ${E}`:w.push({role:"user",text:E}),yield{type:"status",content:"Subagent Update"}}}catch{}if(i){let H=await i();H&&(H.startsWith("/btw")?w.length>0&&w[w.length-1].role==="user"?w[w.length-1].text+=`
658
+ ${E}`:w.push({role:"user",text:E}),yield{type:"status",content:"Subagent Update"}}}catch{}if(s){let j=await s();j&&(j.startsWith("/btw")?w.length>0&&w[w.length-1].role==="user"?w[w.length-1].text+=`
655
659
 
656
660
  [system] User question. Resolve this specific query within '[ANSWER]...[/ANSWER]' concisely, naturally [/system]
657
- [question] ${H.replace("/btw","").trim()} [/question]`:w.push({role:"user",text:`[system] User question. Resolve this specific query within '[ANSWER]...[/ANSWER]' concisely, naturally [/system]
658
- [question] ${H.replace("/btw","").trim()} [/question]`}):w.length>0&&w[w.length-1].role==="user"?w[w.length-1].text+=`
661
+ [question] ${j.replace("/btw","").trim()} [/question]`:w.push({role:"user",text:`[system] User question. Resolve this specific query within '[ANSWER]...[/ANSWER]' concisely, naturally [/system]
662
+ [question] ${j.replace("/btw","").trim()} [/question]`}):w.length>0&&w[w.length-1].role==="user"?w[w.length-1].text+=`
659
663
 
660
- [STEERING HINT from USER, High Priority] ${H.trim()} [/STEERING HINT]`:w.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${H.trim()} [/STEERING HINT]`}),yield{type:"status",content:`${H.startsWith("/btw")?"Question Forwarded...":"Steering Hint Injected..."}`})}let K,Se=!1,Pe=1,tt=1,Bt=Date.now(),Tt=null,be="",Ut=null,bo=null,qn=null,Yn=0,je=[],Et=0,Pn=!1,Wt=!1,Xn=!1,Gt=!1,$n=!0,ro=0,bt="",pe="",Qe=!1,_t=!1,Fe=!0,te=e,Be="",nn=d;for(d=d.toLowerCase()==="max"?"High":d;Pe<=fn&&tt<=fn&&!Se&&!xt;){let H=!1;try{be="",$n&&(process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07"),yield{type:"turn_reset",content:!0},$n=!1,tt===1&&(bt=""));let X=u=>{if(!u||typeof u!="string")return u;let S="",T=Rs(u);if(T&&(S=T.fullBlock,u=T.remainingText),!u.includes("[tool:")&&!u.includes("[action:"))return(p?.keepReasoningContext?S:"")+u;if(Kn(u).length===0){let y=_i(u);return(p?.keepReasoningContext?S:"")+y}u=u.replace(El,(y,A)=>A.includes("[tool:")||A.includes("[action:")?A.trim():y);let ie="",M=0,z=[],yt="";for(;M<u.length;){let y=u.indexOf("[tool:",M),A=u.indexOf("[action:",M),ne=-1;if(y!==-1&&A!==-1?ne=Math.min(y,A):y!==-1?ne=y:ne=A,ne===-1){z.length===0&&(ie+=_i(u.substring(M)));break}if((ne>0?u[ne-1]:"")==="`"){ie+=_i(u.substring(M,ne+1)),M=ne+1;continue}z.length===0&&(yt=_i(u.substring(M,ne)));let J=-1,v=null,Ct=0;for(let It=ne;It<u.length;It++){let ut=u[It];if(v){if(ut===v){let Ze=0;for(let se=It-1;se>=0&&u[se]==="\\";se--)Ze++;Ze%2===0&&(v=null)}}else if(ut==='"'||ut==="'"||ut==="`")v=ut;else if(ut==="(")Ct++;else if(ut===")")Ct--;else if(ut==="]"&&Ct<=0){J=It;break}}if(J===-1){z.length===0&&(ie+=u.substring(ne));break}let On=u.substring(ne,J+1);z.push(On),M=J+1}return z.length>0&&(ie=yt.trimEnd()?yt.trimEnd()+`
664
+ [STEERING HINT from USER, High Priority] ${j.trim()} [/STEERING HINT]`:w.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${j.trim()} [/STEERING HINT]`}),yield{type:"status",content:`${j.startsWith("/btw")?"Question Forwarded...":"Steering Hint Injected..."}`})}let H,Se=!1,$e=1,nt=1,Bt=Date.now(),Tt=null,be="",Ut=null,bo=null,qn=null,Yn=0,je=[],Et=0,Pn=!1,Wt=!1,Xn=!1,Gt=!1,$n=!0,ro=0,bt="",pe="",Qe=!1,_t=!1,Be=!0,J=e,Le="",nn=d;for(d=d.toLowerCase()==="max"?"High":d;$e<=fn&&nt<=fn&&!Se&&!xt;){let j=!1;try{be="",$n&&(process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07"),yield{type:"turn_reset",content:!0},$n=!1,nt===1&&(bt=""));let Q=u=>{if(!u||typeof u!="string")return u;let S="",T=Rs(u);if(T&&(S=T.fullBlock,u=T.remainingText),!u.includes("[tool:")&&!u.includes("[action:"))return(p?.keepReasoningContext?S:"")+u;if(Kn(u).length===0){let y=_i(u);return(p?.keepReasoningContext?S:"")+y}u=u.replace(El,(y,A)=>A.includes("[tool:")||A.includes("[action:")?A.trim():y);let ie="",P=0,z=[],yt="";for(;P<u.length;){let y=u.indexOf("[tool:",P),A=u.indexOf("[action:",P),ne=-1;if(y!==-1&&A!==-1?ne=Math.min(y,A):y!==-1?ne=y:ne=A,ne===-1){z.length===0&&(ie+=_i(u.substring(P)));break}if((ne>0?u[ne-1]:"")==="`"){ie+=_i(u.substring(P,ne+1)),P=ne+1;continue}z.length===0&&(yt=_i(u.substring(P,ne)));let Z=-1,v=null,Ct=0;for(let It=ne;It<u.length;It++){let ut=u[It];if(v){if(ut===v){let Ze=0;for(let se=It-1;se>=0&&u[se]==="\\";se--)Ze++;Ze%2===0&&(v=null)}}else if(ut==='"'||ut==="'"||ut==="`")v=ut;else if(ut==="(")Ct++;else if(ut===")")Ct--;else if(ut==="]"&&Ct<=0){Z=It;break}}if(Z===-1){z.length===0&&(ie+=u.substring(ne));break}let On=u.substring(ne,Z+1);z.push(On),P=Z+1}return z.length>0&&(ie=yt.trimEnd()?yt.trimEnd()+`
661
665
 
662
666
  `+z.join(`
663
667
 
664
668
  `):z.join(`
665
669
 
666
- `)),(p?.keepReasoningContext?S:"")+ie},E=w.filter(u=>(u.role==="user"||u.role==="agent"||u.role==="system")&&!String(u.id).startsWith("welcome")&&!u.isMeta&&!u.isTerminalRecord&&!(u.text&&u.text.startsWith("[TERMINAL_RECORD]"))).map((u,S,T)=>{let V=u.text||"";P||(V=V.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),u.role==="agent"&&(V=X(V),V=V.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),V=V.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*"));let ie=[];return Array.isArray(u.parts)&&u.parts.length>0?ie=u.parts.map(M=>{if(M.text){let z=M.text;return P||(z=z.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),u.role==="agent"&&(z=X(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*")),{text:z}}return M}):ie=[{text:V}],u.binaryPart&&it(te)&&T.slice(S+1).filter(z=>z.role==="user"&&!z.text?.startsWith("[ACTION RESULT]")&&!z.text?.startsWith("[TOOL RESULT]")).length<=2&&ie.push(u.binaryPart),{role:u.role==="user"||u.role==="system"?"user":"model",parts:ie}});for(let u=E.length-2;u>=0;u--){let S=E[u],T=E[u+1];S.role==="user"&&T.role==="user"&&(T.parts?.[0]?.text||"").trim().startsWith("[SYSTEM")&&E.splice(u,1)}let gt=[];for(let u=0;u<E.length;u++){let S=E[u];if(gt.length===0)gt.push(S);else{let T=gt[gt.length-1];T.role===S.role?(T.parts[0].text+=`
670
+ `)),(p?.keepReasoningContext?S:"")+ie},E=w.filter(u=>(u.role==="user"||u.role==="agent"||u.role==="system")&&!String(u.id).startsWith("welcome")&&!u.isMeta&&!u.isTerminalRecord&&!(u.text&&u.text.startsWith("[TERMINAL_RECORD]"))).map((u,S,T)=>{let V=u.text||"";M||(V=V.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),u.role==="agent"&&(V=Q(V),V=V.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),V=V.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*"));let ie=[];return Array.isArray(u.parts)&&u.parts.length>0?ie=u.parts.map(P=>{if(P.text){let z=P.text;return M||(z=z.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),u.role==="agent"&&(z=Q(z),z=z.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),z=z.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*")),{text:z}}return P}):ie=[{text:V}],u.binaryPart&&et(J)&&T.slice(S+1).filter(z=>z.role==="user"&&!z.text?.startsWith("[ACTION RESULT]")&&!z.text?.startsWith("[TOOL RESULT]")).length<=2&&ie.push(u.binaryPart),{role:u.role==="user"||u.role==="system"?"user":"model",parts:ie}});for(let u=E.length-2;u>=0;u--){let S=E[u],T=E[u+1];S.role==="user"&&T.role==="user"&&(T.parts?.[0]?.text||"").trim().startsWith("[SYSTEM")&&E.splice(u,1)}let gt=[];for(let u=0;u<E.length;u++){let S=E[u];if(gt.length===0)gt.push(S);else{let T=gt[gt.length-1];T.role===S.role?(T.parts[0].text+=`
667
671
 
668
- `+(S.parts?.[0]?.text||""),S.parts?.length>1&&T.parts.push(...S.parts.slice(1))):gt.push(S)}}for(let u of gt)for(let S of u.parts||[])S&&typeof S.text=="string"&&(S.text.includes("[action:")||S.text.includes("[tool:"))&&(S.text=S.text.replace(/```(?:[a-zA-Z0-9_-]+)?\s*\n?(\[(?:action|tool):[\s\S]*?\)\s*\])\n?```/gi,"$1"),S.text=S.text.replace(/`(\[(?:action|tool):[\s\S]*?\)\s*\])`/gi,"$1"));E.length=0,E.push(...gt),te=e;let de=`${f}|${s}|${l}|${d}|${nn}|${te}|${JSON.stringify(r)}|${!!p?.dynamicDirAwareness}|${!!p?.subAgents}|${process.env.rawReasoning==="true"}`,We=no.key===de&&no.value;if((process.env.I_HAVE_TOO_MUCH_MONEY==="true"||process.env.I_HAVE_TOO_MUCH_MONEY===!0)&&(We=!1),We)Be=no.value;else{let u=s==="Mistral"?!!ai(te):!(te||"gemma").toLowerCase().startsWith("gemma");Be=Fr(r,((te||"gemma").toLowerCase().startsWith("gemma"),nn),l,p,P,L,s,s==="Google"?!0:C,u,f,!!p?.keepReasoningContext,te),p?.dynamicDirAwareness||(Be+=`
672
+ `+(S.parts?.[0]?.text||""),S.parts?.length>1&&T.parts.push(...S.parts.slice(1))):gt.push(S)}}for(let u of gt)for(let S of u.parts||[])S&&typeof S.text=="string"&&(S.text.includes("[action:")||S.text.includes("[tool:"))&&(S.text=S.text.replace(/```(?:[a-zA-Z0-9_-]+)?\s*\n?(\[(?:action|tool):[\s\S]*?\)\s*\])\n?```/gi,"$1"),S.text=S.text.replace(/`(\[(?:action|tool):[\s\S]*?\)\s*\])`/gi,"$1"));E.length=0,E.push(...gt),J=e;let fe=`${f}|${i}|${a}|${d}|${nn}|${J}|${JSON.stringify(r)}|${!!p?.dynamicDirAwareness}|${!!p?.subAgents}|${process.env.rawReasoning==="true"}`,We=no.key===fe&&no.value;if((process.env.I_HAVE_TOO_MUCH_MONEY==="true"||process.env.I_HAVE_TOO_MUCH_MONEY===!0)&&(We=!1),We)Le=no.value;else{let u=i==="Mistral"?!!ai(J):!(J||"gemma").toLowerCase().startsWith("gemma");Le=Fr(r,((J||"gemma").toLowerCase().startsWith("gemma"),nn),a,p,M,L,i,i==="Google"?!0:C,u,f,!!p?.keepReasoningContext,J),p?.dynamicDirAwareness||(Le+=`
669
673
  ${Aa.replace(`
670
674
  **Directory**`,`
671
- -- Directory --`)}`),no.key=de,no.value=Be}let ge=E[E.length-1];if(yo()&b>0){await new Promise(V=>setTimeout(V,2500)),yield{type:"status",content:"Verifying"};let u=await to(),S=u?u.diagnostics:null,T=Is(u?.comments);S&&ge&&ge.role==="user"&&ge.parts?.[0]?.text&&(ge.parts[0].text+=`
675
+ -- Directory --`)}`),no.key=fe,no.value=Le}let me=E[E.length-1];if(yo()&b>0){await new Promise(V=>setTimeout(V,2500)),yield{type:"status",content:"Verifying"};let u=await to(),S=u?u.diagnostics:null,T=Is(u?.comments);S&&me&&me.role==="user"&&me.parts?.[0]?.text&&(me.parts[0].text+=`
672
676
 
673
- ${S}`),Pi&&ge&&ge.role==="user"&&ge.parts?.[0]?.text&&(ge.parts[0].text+=`
677
+ ${S}`),Pi&&me&&me.role==="user"&&me.parts?.[0]?.text&&(me.parts[0].text+=`
674
678
 
675
679
  [Additional Comments]
676
- ${T}`),yield{type:"status",content:"Working"}}let St=s==="Mistral"||s==="Google"&&e?.toLowerCase().startsWith("gemma");if(p?.advanceRollback&&ge&&ge.role==="user"&&(ge.parts?.[0]?.text?.startsWith("[ACTION RESULT]")||ge.parts?.[0]?.text?.startsWith("[TOOL RESULT]")))try{let u=await Mo.getLatestFileChanges(f);if(u&&(u.newFiles.length>0||u.modifiedFiles.length>0||u.deletedFiles.length>0)){let S=`
680
+ ${T}`),yield{type:"status",content:"Working"}}let St=i==="Mistral"||i==="Google"&&e?.toLowerCase().startsWith("gemma");if(p?.advanceRollback&&me&&me.role==="user"&&(me.parts?.[0]?.text?.startsWith("[ACTION RESULT]")||me.parts?.[0]?.text?.startsWith("[TOOL RESULT]")))try{let u=await Mo.getLatestFileChanges(f);if(u&&(u.newFiles.length>0||u.modifiedFiles.length>0||u.deletedFiles.length>0)){let S=`
677
681
  [system] File Changes:
678
682
  `;for(let V of u.newFiles)S+=`* ${V} (created)
679
683
  `;for(let V of u.modifiedFiles)S+=`* ${V} (modified)
680
684
  `;for(let V of u.deletedFiles)S+=`* ${V} (deleted)
681
- `;S+="[/system]",ge.parts[0].text+=S;let T=-1;for(let V=w.length-1;V>=0;V--)if(w[V].role==="user"&&(w[V].text?.startsWith("[ACTION RESULT]")||w[V].text?.startsWith("[TOOL RESULT]"))){T=V;break}T!==-1&&(w[T].text+=S)}}catch{}let nt=Math.floor(tn*.99),mt=b+1;if(mt>=nt&&ge&&ge.parts?.[0]&&(ge.parts[0].text+=`
682
- [system] WARNING, Turn Limit Impending: Step ${mt}/${tn}. Wrap up quickly/prompt user to continue. [/system]`),process.env.LOG_CHAT==="true"||process.env.LOG_CHAT==="1"||process.env.LOG_CHAT===!0||!1){let u=B.join(eo,"chats",String(f));we.existsSync(u)||we.mkdirSync(u,{recursive:!0}),we.writeFileSync(B.join(u,"context.json"),JSON.stringify({contents:E},null,2)),we.writeFileSync(B.join(u,"system.md"),`${We?"CACHED":"NOT CACHED"}
683
- Key: ${de}
685
+ `;S+="[/system]",me.parts[0].text+=S;let T=-1;for(let V=w.length-1;V>=0;V--)if(w[V].role==="user"&&(w[V].text?.startsWith("[ACTION RESULT]")||w[V].text?.startsWith("[TOOL RESULT]"))){T=V;break}T!==-1&&(w[T].text+=S)}}catch{}let ot=Math.floor(tn*.99),mt=b+1;if(mt>=ot&&me&&me.parts?.[0]&&(me.parts[0].text+=`
686
+ [system] WARNING, Turn Limit Impending: Step ${mt}/${tn}. Wrap up quickly/prompt user to continue. [/system]`),process.env.LOG_CHAT==="true"||process.env.LOG_CHAT==="1"||process.env.LOG_CHAT===!0||!1){let u=U.join(eo,"chats",String(f));we.existsSync(u)||we.mkdirSync(u,{recursive:!0}),we.writeFileSync(U.join(u,"context.json"),JSON.stringify({contents:E},null,2)),we.writeFileSync(U.join(u,"system.md"),`${We?"CACHED":"NOT CACHED"}
687
+ Key: ${fe}
684
688
  --------------------------------------------------------------------
685
689
 
686
- ${Be}`)}let rt=new Promise((u,S)=>{U.signal.aborted&&S(new DOMException("The user aborted a request.","AbortError")),U.signal.addEventListener("abort",()=>{S(new DOMException("The user aborted a request.","AbortError"))})});rt.catch(()=>{});let $e=E;if(Bt=Date.now(),s==="Ollama")K=(await me("Ollama"))(n.apiKey,te,$e,Be,d,l,C,U.signal,1,p?.ollamaEndpoint||"Cloud");else if(s==="OpenRouter")K=(await me("OpenRouter"))(n.apiKey,te,$e,Be,d,l,C,U.signal,1,f);else if(s==="DeepSeek")K=(await me("DeepSeek"))(n.apiKey,te,$e,Be,d,l,C,U.signal,1);else if(s==="Mistral")K=(await me("Mistral"))(n.apiKey,te,$e,Be,d,l,C,U.signal,1,f);else if(s==="NVIDIA"){let u=(await me("NVIDIA"))(n.apiKey,te,$e,Be,d,l,C,U.signal,1);K=(await me("NVIDIA_wrap"))(u,te)}else if(s==="InferX")K=(await me("InferX"))(n.apiKey,te,$e,Be,d,l,C,U.signal,1);else if(s==="SenseNova")K=(await me("SenseNova"))(n.apiKey,te,$e,Be,d,l,C,U.signal,1);else if(s==="AIHubMix")K=(await me("AIHubMix"))(n.apiKey,te,$e,Be,d,l,C,U.signal,1);else if(s==="Poolside")K=(await me("Poolside"))(n.apiKey,te,$e,Be,d,l,C,U.signal,1);else if(s==="9router"||s==="9Router")K=(await me("NineRouter"))(n.apiKey,te,$e,Be,d,l,C,U.signal,1);else if(s==="ExpLabs"||s==="ExperientialLabs")K=(await me("ExpLabs"))(n.apiKey,te,$e,Be,d,l,C,U.signal,1);else if(s==="Infron"||s==="infron")K=(await me("Infron"))(n.apiKey,te,$e,Be,d,l,C,U.signal,1);else if(s==="TokenHarbor"||s==="Token Harbor"||s==="tokenharbor"||s==="token_harbor"||s==="thk")K=(await me("TokenHarbor"))(n.apiKey,te,$e,Be,d,l,C,U.signal,1);else if(s==="APInex"||s==="apinex"||s==="apx")K=(await me("APInex"))(n.apiKey,te,$e,Be,d,l,C,U.signal,1);else if(s==="xKiro"||s==="xkiro"||s==="kiro")K=(await me("xKiro"))(n.apiKey,te,$e,Be,d,l,C,U.signal,1);else if(s==="CoArena"||s==="coarena")K=(await me("CoArena"))(n.apiKey,te,$e,Be,d,l,C,U.signal,1);else if(s==="c_openai"||s==="Custom (OpenAI)"){let u=p?.customOpenAIBaseUrl||"";try{u=await Vi("c_openai")||u}catch{}K=(await me("c_openai"))(n.apiKey,te,$e,Be,d,l,C,U.signal,1,u)}else{let u=Sa(n?.apiKey),{serviceTier:S,cleanModel:T}=Ta(te),V={systemInstruction:Be,mediaResolution:"MEDIA_RESOLUTION_HIGH",safetySettings:[{category:Ei.HARM_CATEGORY_HARASSMENT,threshold:vi.BLOCK_NONE},{category:Ei.HARM_CATEGORY_HATE_SPEECH,threshold:vi.BLOCK_NONE},{category:Ei.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:vi.BLOCK_NONE},{category:Ei.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:vi.BLOCK_NONE}],temperature:1.05,thinkingConfig:(()=>{let M=er("Google",te||"gemini-3-flash-preview",d);if(M!==null){if(typeof M=="object")return M;if(M===!1||M==="false"||M==="none"||M===0||M==="0")return{includeThoughts:!1};if(typeof M=="number")return{includeThoughts:!0,thinkingBudget:M};if(typeof M=="string"){let A=M.toLowerCase();if(A==="minimal")return{includeThoughts:!0,thinkingLevel:Ye.MINIMAL};if(A==="low")return{includeThoughts:!0,thinkingLevel:Ye.LOW};if(A==="medium")return{includeThoughts:!0,thinkingLevel:Ye.MEDIUM};if(A==="high")return{includeThoughts:!0,thinkingLevel:Ye.HIGH};let ne=Number(M);if(!isNaN(ne))return{includeThoughts:!0,thinkingBudget:ne}}}let z=(te||"").toLowerCase(),yt=z.includes("gemma-4")||z.startsWith("gemma"),y=z.includes("gemini-3");if(yt||y)return yt?d.toLowerCase()!=="high"?{includeThoughts:!1,thinkingLevel:Ye.MINIMAL}:{includeThoughts:!0,thinkingLevel:Ye.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:z.includes("pro")?Ye.LOW:Ye.MINIMAL,Low:Ye.LOW,Medium:Ye.MEDIUM,Standard:Ye.MEDIUM,High:Ye.HIGH,xHigh:Ye.HIGH}[d]||Ye.MEDIUM};{let A={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[d]||2048;return A===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:A}}})()};S&&(V.serviceTier=S);let ie=u.models.generateContentStream({model:T||"gemini-3-flash-preview",contents:$e,config:V},{signal:U.signal});K=await Promise.race([ie,rt])}be="",Ut=null,qn=null,je=[],Et=0,yield{type:"model_update",content:null},pe="",Qe=bt.length>0;let pt="",Qo=Date.now(),un=async function*(){if(s==="Google"&&pt){let u=ko(pt);for(let S of u)yield S;pt="",Qo=Date.now()}},Ws=!0,An="",ao=!1,ht=null,Gs=!1,Qn=!1,lo=!1,Zo=!1,Ln=!1,So=u=>{let S=0;for(;S+2<u.length;)u[S]==="`"&&u[S+1]==="`"&&u[S+2]==="`"?(Zo=!Zo,S+=3):S++},Hs=u=>{if(!u)return;let S=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,T;for(;(T=S.exec(u))!==null;){let V=T[0].toLowerCase();V.startsWith("</")||V.startsWith("[/")||V==="<channel|>"?Ln=!1:Ln=!0}},$a={tool:{startPrefix:"[tool",fullPrefix:"[tool:",endTag:"]"},action:{startPrefix:"[action",fullPrefix:"[action:",endTag:"]"},end:{startPrefix:"[[END]]",fullPrefix:"[[END]]",endTag:"[[END]]"},kimi_section:{startPrefix:"<|tool_calls_section_begin|>",fullPrefix:"<|tool_calls_section_begin|>",endTag:"<|tool_calls_section_end|>"},kimi_call:{startPrefix:"<|tool_call_begin|>",fullPrefix:"<|tool_call_begin|>",endTag:"<|tool_call_end|>"}},ko=u=>{let S=[],T=u,V=ie=>{if(!ie)return;if(!Gs){S.push({type:"text",content:ie}),So(ie),Hs(ie);return}let M=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,z=0,yt;for(;(yt=M.exec(ie))!==null;){let A=ie.substring(z,yt.index);if(A)if(So(A),Ln)S.push({type:"text",content:A});else{let _e=A.replace(/[^\r\n]/g,"");_e&&S.push({type:"text",content:_e})}let ne=yt[0];So(ne);let a=ne.toLowerCase();a.startsWith("</")||a.startsWith("[/")||a==="<channel|>"?Ln=!1:Ln=!0,S.push({type:"text",content:ne}),z=M.lastIndex}let y=ie.substring(z);if(y)if(So(y),Ln)S.push({type:"text",content:y});else{let A=y.replace(/[^\r\n]/g,"");A&&S.push({type:"text",content:A})}};for(;T.length>0;)if(ao){let ie=An+T,M=$a[ht];if(M){let y=!1;if(ie.length<M.startPrefix.length?M.startPrefix.startsWith(ie)||(y=!0):ie.startsWith(M.startPrefix)?ie.length>=M.fullPrefix.length&&!ie.startsWith(M.fullPrefix)&&(y=!0):y=!0,y){V(ie),An="",ao=!1,ht=null,Qn=!1,lo=!1,T="";break}}let z=-1,yt=M?M.endTag:"]";if(ht==="tool"||ht==="action"){let y=0,A=null,ne=0,a=!1;for(let _e=0;_e<ie.length;_e++){let J=ie[_e];if(A){if(J===A){let v=0;for(let Ct=_e-1;Ct>=0&&ie[Ct]==="\\";Ct--)v++;v%2===0&&(A=null)}}else if(J==='"'||J==="'")A=J;else if(J==="`")if(Qn){z=_e;break}else A=J;else if(J==="(")y++,a=!0;else if(J===")")y--;else if(J==="]"&&a&&y===0){z=_e;break}}}else z=ie.indexOf(yt);if(z!==-1){let y=yt.length,A=ie.substring(0,z+y);ht?.startsWith("kimi")||S.push({type:"text",content:A}),So(A),Hs(A),(ht==="tool"||ht==="action"||ht?.startsWith("kimi"))&&!Qn&&!lo&&(Gs=!0,zn.push(A.trim())),Qn=!1,lo=!1,An="",ao=!1,ht=null,T=ie.substring(z+y)}else{An=ie,T="";break}}else{let ie=T.indexOf("[tool"),M=T.indexOf("[action"),z=T.indexOf("[[END]]"),yt=T.indexOf("<|tool_calls_section_begin|>"),y=T.indexOf("<|tool_call_begin|>"),A=[{type:"tool",idx:ie,start:"[tool",end:"]"},{type:"action",idx:M,start:"[action",end:"]"},{type:"end",idx:z,start:"[[END]]",end:"[[END]]"},{type:"kimi_section",idx:yt,start:"<|tool_calls_section_begin|>",end:"<|tool_calls_section_end|>"},{type:"kimi_call",idx:y,start:"<|tool_call_begin|>",end:"<|tool_call_end|>"}].filter(ne=>ne.idx!==-1).sort((ne,a)=>ne.idx-a.idx);if(A.length>0){let ne=A[0],a=T.substring(0,ne.idx);ne.idx>0&&V(a);let _e=ne.idx>0?T[ne.idx-1]:"";Qn=Zo||_e==="`",lo=Ln,ao=!0,ht=ne.type,An="",T=T.substring(ne.idx)}else{let ne=["[tool","[action","[[END]]","<|tool_calls_section_begin|>","<|tool_call_begin|>"],a=-1;for(let _e of ne){for(let J=_e.length-1;J>0;J--)if(T.endsWith(_e.substring(0,J))){a=T.length-J;let v=ne.indexOf(_e);v===0?ht="tool":v===1?ht="action":v===2?ht="end":v===3?ht="kimi_section":ht="kimi_call";break}if(a!==-1)break}if(a!==-1){if(a>0){let J=T.substring(0,a);V(J)}let _e=a>0?T[a-1]:"";Qn=Zo||_e==="`",lo=Ln,ao=!0,An=T.substring(a),T=""}else{V(T);break}}}return S},La=K[Symbol.asyncIterator]();for(;;){let{value:u,done:S}=await Promise.race([La.next(),rt]);if(S)break;if(u&&u.type==="status"){yield u;continue}let T="",V=u.candidates?.[0]?.content?.parts;if(V&&V.length>0)for(let M of V){let z=typeof M.text=="string"?M.text:M.text?parseChunkText(M.text):"";M.thought?z&&(H||(T+="<think_fluxflow>",H=!0),T+=z):z&&(H&&(T+="</think_fluxflow>",H=!1),T+=z)}else u.text&&H&&(T+="</think_fluxflow>",H=!1);T=Al(T);let ie=T?Yi(T):0;if(n&&typeof n.onTokenChunk=="function"&&n.onTokenChunk(T,ie),Ws&&(Tt===null&&(Tt=Date.now()-Bt),yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"},Ws=!1),xt){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
690
+ ${Le}`)}let rt=new Promise((u,S)=>{B.signal.aborted&&S(new DOMException("The user aborted a request.","AbortError")),B.signal.addEventListener("abort",()=>{S(new DOMException("The user aborted a request.","AbortError"))})});rt.catch(()=>{});let _e=E;if(Bt=Date.now(),i==="Ollama")H=(await de("Ollama"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1,p?.ollamaEndpoint||"Cloud");else if(i==="OpenRouter")H=(await de("OpenRouter"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1,f);else if(i==="DeepSeek")H=(await de("DeepSeek"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="Mistral")H=(await de("Mistral"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1,f);else if(i==="NVIDIA"){let u=(await de("NVIDIA"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);H=(await de("NVIDIA_wrap"))(u,J)}else if(i==="InferX")H=(await de("InferX"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="SenseNova")H=(await de("SenseNova"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="AIHubMix")H=(await de("AIHubMix"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="Poolside")H=(await de("Poolside"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="9router"||i==="9Router")H=(await de("NineRouter"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="ExpLabs"||i==="ExperientialLabs")H=(await de("ExpLabs"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="Numes"||i==="numes")H=(await de("Numes"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1,f);else if(i==="Infron"||i==="infron")H=(await de("Infron"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="TokenHarbor"||i==="Token Harbor"||i==="tokenharbor"||i==="token_harbor"||i==="thk")H=(await de("TokenHarbor"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="APInex"||i==="apinex"||i==="apx")H=(await de("APInex"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="xKiro"||i==="xkiro"||i==="kiro")H=(await de("xKiro"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="CoArena"||i==="coarena")H=(await de("CoArena"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1);else if(i==="c_openai"||i==="Custom (OpenAI)"){let u=p?.customOpenAIBaseUrl||"";try{u=await Vi("c_openai")||u}catch{}H=(await de("c_openai"))(n.apiKey,J,_e,Le,d,a,C,B.signal,1,u)}else{let u=Sa(n?.apiKey),{serviceTier:S,cleanModel:T}=Ta(J),V={systemInstruction:Le,mediaResolution:"MEDIA_RESOLUTION_HIGH",safetySettings:[{category:Ei.HARM_CATEGORY_HARASSMENT,threshold:vi.BLOCK_NONE},{category:Ei.HARM_CATEGORY_HATE_SPEECH,threshold:vi.BLOCK_NONE},{category:Ei.HARM_CATEGORY_SEXUALLY_EXPLICIT,threshold:vi.BLOCK_NONE},{category:Ei.HARM_CATEGORY_DANGEROUS_CONTENT,threshold:vi.BLOCK_NONE}],temperature:1.05,thinkingConfig:(()=>{let P=er("Google",J||"gemini-3-flash-preview",d);if(P!==null){if(typeof P=="object")return P;if(P===!1||P==="false"||P==="none"||P===0||P==="0")return{includeThoughts:!1};if(typeof P=="number")return{includeThoughts:!0,thinkingBudget:P};if(typeof P=="string"){let A=P.toLowerCase();if(A==="minimal")return{includeThoughts:!0,thinkingLevel:Ye.MINIMAL};if(A==="low")return{includeThoughts:!0,thinkingLevel:Ye.LOW};if(A==="medium")return{includeThoughts:!0,thinkingLevel:Ye.MEDIUM};if(A==="high")return{includeThoughts:!0,thinkingLevel:Ye.HIGH};let ne=Number(P);if(!isNaN(ne))return{includeThoughts:!0,thinkingBudget:ne}}}let z=(J||"").toLowerCase(),yt=z.includes("gemma-4")||z.startsWith("gemma"),y=z.includes("gemini-3");if(yt||y)return yt?d.toLowerCase()!=="high"?{includeThoughts:!1,thinkingLevel:Ye.MINIMAL}:{includeThoughts:!0,thinkingLevel:Ye.HIGH}:{includeThoughts:!0,thinkingLevel:{Fast:z.includes("pro")?Ye.LOW:Ye.MINIMAL,Low:Ye.LOW,Medium:Ye.MEDIUM,Standard:Ye.MEDIUM,High:Ye.HIGH,xHigh:Ye.HIGH}[d]||Ye.MEDIUM};{let A={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[d]||2048;return A===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:A}}})()};S&&(V.serviceTier=S);let ie=u.models.generateContentStream({model:T||"gemini-3-flash-preview",contents:_e,config:V},{signal:B.signal});H=await Promise.race([ie,rt])}be="",Ut=null,qn=null,je=[],Et=0,yield{type:"model_update",content:null},pe="",Qe=bt.length>0;let pt="",Qo=Date.now(),un=async function*(){if(i==="Google"&&pt){let u=ko(pt);for(let S of u)yield S;pt="",Qo=Date.now()}},Ws=!0,An="",ao=!1,ht=null,Gs=!1,Qn=!1,lo=!1,Zo=!1,Ln=!1,So=u=>{let S=0;for(;S+2<u.length;)u[S]==="`"&&u[S+1]==="`"&&u[S+2]==="`"?(Zo=!Zo,S+=3):S++},Hs=u=>{if(!u)return;let S=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,T;for(;(T=S.exec(u))!==null;){let V=T[0].toLowerCase();V.startsWith("</")||V.startsWith("[/")||V==="<channel|>"?Ln=!1:Ln=!0}},$a={tool:{startPrefix:"[tool",fullPrefix:"[tool:",endTag:"]"},action:{startPrefix:"[action",fullPrefix:"[action:",endTag:"]"},end:{startPrefix:"[[END]]",fullPrefix:"[[END]]",endTag:"[[END]]"},kimi_section:{startPrefix:"<|tool_calls_section_begin|>",fullPrefix:"<|tool_calls_section_begin|>",endTag:"<|tool_calls_section_end|>"},kimi_call:{startPrefix:"<|tool_call_begin|>",fullPrefix:"<|tool_call_begin|>",endTag:"<|tool_call_end|>"}},ko=u=>{let S=[],T=u,V=ie=>{if(!ie)return;if(!Gs){S.push({type:"text",content:ie}),So(ie),Hs(ie);return}let P=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,z=0,yt;for(;(yt=P.exec(ie))!==null;){let A=ie.substring(z,yt.index);if(A)if(So(A),Ln)S.push({type:"text",content:A});else{let Ie=A.replace(/[^\r\n]/g,"");Ie&&S.push({type:"text",content:Ie})}let ne=yt[0];So(ne);let l=ne.toLowerCase();l.startsWith("</")||l.startsWith("[/")||l==="<channel|>"?Ln=!1:Ln=!0,S.push({type:"text",content:ne}),z=P.lastIndex}let y=ie.substring(z);if(y)if(So(y),Ln)S.push({type:"text",content:y});else{let A=y.replace(/[^\r\n]/g,"");A&&S.push({type:"text",content:A})}};for(;T.length>0;)if(ao){let ie=An+T,P=$a[ht];if(P){let y=!1;if(ie.length<P.startPrefix.length?P.startPrefix.startsWith(ie)||(y=!0):ie.startsWith(P.startPrefix)?ie.length>=P.fullPrefix.length&&!ie.startsWith(P.fullPrefix)&&(y=!0):y=!0,y){V(ie),An="",ao=!1,ht=null,Qn=!1,lo=!1,T="";break}}let z=-1,yt=P?P.endTag:"]";if(ht==="tool"||ht==="action"){let y=0,A=null,ne=0,l=!1;for(let Ie=0;Ie<ie.length;Ie++){let Z=ie[Ie];if(A){if(Z===A){let v=0;for(let Ct=Ie-1;Ct>=0&&ie[Ct]==="\\";Ct--)v++;v%2===0&&(A=null)}}else if(Z==='"'||Z==="'")A=Z;else if(Z==="`")if(Qn){z=Ie;break}else A=Z;else if(Z==="(")y++,l=!0;else if(Z===")")y--;else if(Z==="]"&&l&&y===0){z=Ie;break}}}else z=ie.indexOf(yt);if(z!==-1){let y=yt.length,A=ie.substring(0,z+y);ht?.startsWith("kimi")||S.push({type:"text",content:A}),So(A),Hs(A),(ht==="tool"||ht==="action"||ht?.startsWith("kimi"))&&!Qn&&!lo&&(Gs=!0,zn.push(A.trim())),Qn=!1,lo=!1,An="",ao=!1,ht=null,T=ie.substring(z+y)}else{An=ie,T="";break}}else{let ie=T.indexOf("[tool"),P=T.indexOf("[action"),z=T.indexOf("[[END]]"),yt=T.indexOf("<|tool_calls_section_begin|>"),y=T.indexOf("<|tool_call_begin|>"),A=[{type:"tool",idx:ie,start:"[tool",end:"]"},{type:"action",idx:P,start:"[action",end:"]"},{type:"end",idx:z,start:"[[END]]",end:"[[END]]"},{type:"kimi_section",idx:yt,start:"<|tool_calls_section_begin|>",end:"<|tool_calls_section_end|>"},{type:"kimi_call",idx:y,start:"<|tool_call_begin|>",end:"<|tool_call_end|>"}].filter(ne=>ne.idx!==-1).sort((ne,l)=>ne.idx-l.idx);if(A.length>0){let ne=A[0],l=T.substring(0,ne.idx);ne.idx>0&&V(l);let Ie=ne.idx>0?T[ne.idx-1]:"";Qn=Zo||Ie==="`",lo=Ln,ao=!0,ht=ne.type,An="",T=T.substring(ne.idx)}else{let ne=["[tool","[action","[[END]]","<|tool_calls_section_begin|>","<|tool_call_begin|>"],l=-1;for(let Ie of ne){for(let Z=Ie.length-1;Z>0;Z--)if(T.endsWith(Ie.substring(0,Z))){l=T.length-Z;let v=ne.indexOf(Ie);v===0?ht="tool":v===1?ht="action":v===2?ht="end":v===3?ht="kimi_section":ht="kimi_call";break}if(l!==-1)break}if(l!==-1){if(l>0){let Z=T.substring(0,l);V(Z)}let Ie=l>0?T[l-1]:"";Qn=Zo||Ie==="`",lo=Ln,ao=!0,An=T.substring(l),T=""}else{V(T);break}}}return S},La=H[Symbol.asyncIterator]();for(;;){let{value:u,done:S}=await Promise.race([La.next(),rt]);if(S)break;if(u&&u.type==="status"){yield u;continue}let T="",V=u.candidates?.[0]?.content?.parts;if(V&&V.length>0)for(let P of V){let z=typeof P.text=="string"?P.text:P.text?parseChunkText(P.text):"";P.thought?z&&(j||(T+="<think_fluxflow>",j=!0),T+=z):z&&(j&&(T+="</think_fluxflow>",j=!1),T+=z)}else u.text&&j&&(T+="</think_fluxflow>",j=!1);T=Al(T);let ie=T?Yi(T):0;if(n&&typeof n.onTokenChunk=="function"&&n.onTokenChunk(T,ie),Ws&&(Tt===null&&(Tt=Date.now()-Bt),yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"},Ws=!1),xt){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
687
691
 
688
- \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(T){if(Qe){if(pe+=T,pe.length>=64){let y=0,A=Math.min(bt.length,pe.length);for(let a=A;a>=10;a--)if(bt.endsWith(pe.substring(0,a))){y=a;break}let ne=pe.substring(y);if(ne){let _e=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(bt)?ne.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):ne.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");if(_e)if(be+=_e,s==="Google")pt+=_e;else{yield*un();let J=ko(_e);for(let v of J)yield v}}Qe=!1,pe=""}continue}else if(be+=T,s==="Google")pt+=T;else{yield*un();let y=ko(T);for(let A of y)yield A}let M=Il(be);if(M.inside){_t=!0,qn||(qn=Date.now());let A={Ask:"ask",AskUser:"ask",WebSearch:"web_search",WebScrape:"web_scrape",ReadFile:"view_file",ReadFolder:"read_folder",WriteFile:"write_file",PatchFile:"update_file",WritePDF:"write_pdf",WriteDoc:"write_docx",FindFile:"find_file",find_file:"find_file",findfile:"find_file",Run:"exec_command",SearchKeyword:"search_keyword",CodeSearch:"search_keyword",code_search:"search_keyword",Code_Search:"search_keyword",codesearch:"search_keyword",Memory:"memory",file_map:"file_map",FileMap:"file_map",Chat:"chat",chat:"chat",GenerateImage:"generate_image",generate_image:"generate_image",todo:"todo",Todo:"todo",goal:"todo",Goal:"todo",Invoke:"invoke",InvokeSync:"invoke_sync",getProgress:"get_progress",GetProgress:"get_progress",Cancel:"cancel",Await:"await",wait:"wait",Answer:"answer",Steer:"steer",steer:"steer"}[M.toolName]||M.toolName,ne=M.args||"",a=null;if(["write_file","update_file","view_file","read_folder","find_file","write_pdf","write_docx","search_keyword","generate_image","file_map","invoke","invoke_sync","get_progress","await","wait","answer"].includes(A)){let J=O(ne,[],["path","basename","name","targetFile","TargetFile","directory","file","keyword","title","task","id","taskId","timeout","time","seconds"]),v=J.basename||J.name||J.path||J.targetFile||J.TargetFile||J.directory||J.file,Ct=J.keyword,On=J.title||J.task,It=J.id||J.taskId,ut=J.timeout||J.time||J.seconds||J.sec;if(Ct!=null)a=String(Ct).replace(_n,"");else if(v)a=B.basename(String(v).replace(_n,"").replace(da,"/"));else if(On&&(A==="invoke"||A==="invoke_sync"))a=String(On).replace(_n,"").substring(0,30);else if(It&&A==="get_progress")a=String(It).replace(_n,"");else if(ut&&A==="await"){let Ze=parseFloat(String(ut).replace(_n,""));isNaN(Ze)?a=String(ut).replace(_n,""):(Ze<5&&(Ze=5),Ze>120&&(Ze=180),a=(Mt=>{if(Mt>=60){let Nn=Math.floor(Mt/60),on=Mt%60;return`${Nn}m${on>0?` ${on}s`:""}`}return`${Mt}s`})(Ze))}else if(ut&&A==="wait"){let Ze=parseFloat(String(ut).replace(_n,""));isNaN(Ze)?a=String(ut).replace(_n,""):(Ze<10&&(Ze=10),Ze>120&&(Ze=120),a=(Mt=>{if(Mt>=60){let Nn=Math.floor(Mt/60),on=Mt%60;return`${Nn}m${on>0?` ${on}s`:""}`}return`${Mt}s`})(Ze))}else{let Ze=ne.match(Sl);if(Ze){let se=Ze[1].replace(_n,"");A==="invoke"||A==="invoke_sync"||A==="get_progress"?a=se.substring(0,30):a=A==="search_keyword"||A==="file_map"?se:B.basename(se.replace(da,"/"))}}}let _e=`${vs[A]||A}${a?` ${a}`:""}`;if((A!==Ut||a!==bo)&&(Ut=A,bo=a,yield{type:"status",content:`${_e}`},process.stdout.isTTY)){let v={WebSearch:"Searching",web_search:"Searching",WebScrape:"Reading",web_scrape:"Reading",ReadFile:"Reading",read_file:"Reading",ReadFolder:"Reading",read_folder:"Reading",WriteFile:"Writing",write_file:"Writing",UpdateFile:"Editing",update_file:"Editing",WritePdf:"Creating",write_pdf:"Creating",WriteDocx:"Creating",write_docx:"Creating",SearchKeyword:"Searching",search_keyword:"Searching",CodeSearch:"Searching",code_search:"Searching",FindFile:"Finding File",find_file:"Finding File",Run:"Executing",Ask:"User Input Required",AskUser:"User Input Required",Memory:"Updating Memory",GenerateImage:"Generating",InvokeSync:"Sub-Agent Working",invoke_sync:"Sub-Agent Working",Invoke:"Working",invoke:"Working",GetProgress:"Checking Progress",get_progress:"Checking Progress",Cancel:"Stopping Generalist",cancel:"Stopping Generalist",Await:"Waiting",await:"Waiting",wait:"Waiting",EmergencyRollback:"Rolling the Ball",Answer:"Answering Sub-Agent",answer:"Answering Sub-Agent",Steer:"Steering Sub-Agent",steer:"Steering Sub-Agent",Click:"Clicking",click:"Clicking",Drag:"Dragging",drag:"Dragging",Scroll:"Scrolling",scroll:"Scrolling",KeyboardTyping:"Typing",keyboard_typing:"Typing",KeyPress:"Pressing Key",key_press:"Pressing Key",RecaptureScreen:"Recapturing Screen",recapture_screen:"Recapturing Screen"}[A]||"Working";process.stdout.write(`\x1B]0;${v}...\x07`)}}if(be.length-ro>800){ro=be.length;let y=ka(be,!1),A=Rs(y),ne=A?(A.innerContent||"").trim():"",a=ne.split(/[.!?]\s+/).filter(re=>re.trim().length>10),_e=new Set(a),J=a.length>25?(a.length-_e.size)/a.length:0,v=ne.split(/\s+/).filter(re=>re.length>0).length,Ct=.9,On=.92,It=!1;if(s.toLowerCase().includes("google")&&(te||"").toLowerCase().startsWith("gemma")){let at={low:2048,medium:4096,high:32768,max:65536,xhigh:65536}[d?.toLowerCase()]||16e3;It=v>at}if(J>Ct||It){yield{type:"status",content:`${J>Ct?"Reasoning Loop Detected":"Thinking Budget Exceeded"}. Re-centering...`},Wt=!0,await new Promise(at=>setTimeout(at,3e3));break}let se=pa(be).trim().split(/[.!?]\s+/).filter(re=>re.trim().length>10),Mt=new Set(se);if((se.length>25?(se.length-Mt.size)/se.length:0)>On){yield{type:"status",content:"Response Loop Detected. Re-centering..."},Wt=!1,Gt=!0,await new Promise(re=>setTimeout(re,3e3));break}let on=y.replace(ml,"").replace(pl,"").replace(hl,"").replace(yl,""),Dn=on.toLowerCase().split(/\s+/).map(re=>re.replace(xl,"")).filter(re=>re.length>0),Ao=!1;if(Dn.length>=40)for(let re=1;re<=15;re++){let at=Math.max(8,Math.ceil(25/re));if(Dn.length<re*at)continue;let Fn=Dn.slice(Dn.length-re),c=Fn.join(" ");if(re>1&&c===Fn.slice(0,Math.floor(re/2)).join(" ").repeat(2).trim())continue;let R=!0;for(let _=1;_<at;_++)if(Dn.slice(Dn.length-re*(_+1),Dn.length-re*_).join(" ")!==c){R=!1;break}if(R){Ao=!0;break}}if(!Ao){let re=on.toLowerCase().replace(wl,"");if(re.length>=80)for(let at=1;at<=10;at++){let Fn=Math.max(15,Math.ceil(45/at));if(re.length<at*Fn)continue;let c=re.substring(re.length-at),R=!0;for(let _=1;_<Fn;_++)if(re.substring(re.length-at*(_+1),re.length-at*_)!==c){R=!1;break}if(R){Ao=!0;break}}}if(Ao){yield{type:"status",content:"Stuttering Detected. Re-centering..."},Wt=!1,Xn=!0,await new Promise(re=>setTimeout(re,3e3));break}}let z=jt(be),yt=Kn(z);for(;yt.length>Et;){yield*un();let y=yt[Et],A=Date.now(),a={Ask:"ask",AskUser:"ask",WebSearch:"web_search",WebScrape:"web_scrape",ReadFile:"view_file",ReadFolder:"read_folder",FindFile:"find_file",find_file:"find_file",findfile:"find_file",WriteFile:"write_file",PatchFile:"update_file",WritePDF:"write_pdf",WriteDoc:"write_docx",Run:"exec_command",SearchKeyword:"search_keyword",CodeSearch:"search_keyword",code_search:"search_keyword",Code_Search:"search_keyword",codesearch:"search_keyword",Memory:"memory",file_map:"file_map",FileMap:"file_map",Chat:"chat",chat:"chat",GenerateImage:"generate_image",generate_image:"generate_image",todo:"todo",Todo:"todo",goal:"todo",Goal:"todo",Invoke:"invoke",InvokeSync:"invoke_sync",getProgress:"get_progress",GetProgress:"get_progress",Await:"await",await:"await",AwaitSubagent:"await",awaitSubagent:"await",Wait:"wait",wait:"wait",Answer:"answer",answer:"answer",AnswerSubagent:"answer",answerSubagent:"answer",Steer:"steer",steer:"steer",SteerSubagent:"steer",steerSubagent:"steer",Cancel:"cancel",cancel:"cancel",Click:"click",click:"click",Drag:"drag",drag:"drag",Scroll:"scroll",scroll:"scroll",KeyboardTyping:"keyboard_typing",keyboard_typing:"keyboard_typing",KeyPress:"key_press",key_press:"key_press",RecaptureScreen:"recapture_screen",recapture_screen:"recapture_screen",EmergencyRollback:"EmergencyRollback"}[y.toolName]||y.toolName,_e=vs[a]||y.toolName,J=oo(a,y.args);yield{type:"status",content:`${_e}${J?` ${J}`:""}`};let v="";if(a==="click"){let c=O(y.args,["intendedClickText"]);v=`\u2714 Clicked ${c.intendedClickText?`: ${c.intendedClickText}`:"Screen"}`}else if(a==="drag"){let c=O(y.args,["fromGridId","toGridId"]);v=`\u2714 Dragged: Cell ${c.fromGridId||""} \u2192 Cell ${c.toGridId||""}`}else if(a==="scroll"){let c=O(y.args,["direction","amount"]);v=`\u2714 Scrolled: ${c.direction||"down"} (${c.amount||1})`}else if(a==="keyboard_typing"){let c=O(y.args,["text"]);v=`\u2714 ${c.autoPressEnter?"Entered":"Typed"}: ${c.text?`"${c.text.length>20?c.text.substring(0,20)+"...":c.text}"`:""}`}else if(a==="key_press")v=`\u2714 Pressed Key: ${O(y.args,["key"]).key||""}`;else if(a==="recapture_screen")v="\u2714 Recaptured Screen";else if(a==="web_search"){let{query:c,limit:R=10,aiMode:_=!1}=O(y.args,["query","limit","aiMode"]);v=`${c?"\u2714":"\u2718"} ${_?"AI Search":"Searched"}: ${c?`${c}`:"No Search Query"}${_===!1&&c?` \u2192 ${R}`:""}`}else if(a==="web_scrape"){let c=O(y.args,["url"]).url||null;v=`${c?"\u2714":"\u2718"} Visited: ${c||"No Source"}`}else if(a==="view_file"){let{path:c,StartLine:R,EndLine:_,start_line:ce,end_line:ye,startLine:oe,endLine:ae}=O(y.args,["path","StartLine","EndLine","start_line","end_line","startLine","endLine"]),Re=R||ce||oe,Q=_||ye||ae,q=parseInt(Re)||1,W=parseInt(Q)||(Re?q+800:800),fe="...",Ge=W,D=(c||"").trim().toLowerCase().replaceAll("\\","/");if(D.startsWith("#skill"))D.startsWith("#skill/global/fluxflow")||D.startsWith("#skills/global/fluxflow")||D.includes("#skill/fluxflow")||D.includes("#skills/fluxflow")?v="\u2714 Read Documentation":v=`\u2714 Read Skill: ${B.basename(c.replaceAll("\\","/"))}`;else{try{let{resolvedPath:xe}=mn(c),ke=B.resolve(process.cwd(),xe);if(we.existsSync(ke)){let ve=we.readFileSync(ke,"utf8").split(`
689
- `).length;fe=ve,!Re&&!Q&&ve>800?Ge=Math.min(50,ve):Ge=Math.min(W,ve)}}catch{}let vt=(c||"").toLowerCase(),Co=vt.endsWith(".pdf"),zt=vt.endsWith(".docx")||vt.endsWith(".doc")||vt.endsWith(".ppt")||vt.endsWith(".pptx")||vt.endsWith(".xls")||vt.endsWith(".xlsx"),Ie=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(vt);Co||zt?v=`${c.length>0?"\u2714":"\u2718"} ${c?`Analyzed: ${B.basename(c)}`:"Analyzed: File Not Found"}`:Ie?v=`${c.length>0?"\u2714":"\u2718"} ${c?`Processed: ${B.basename(c)}`:"Processed: File Not Found"}`:v=`${fe!=="..."?"\u2714":"\u2718"} Read: ${c?`${B.basename(c)} \u2192 ${fe!=="..."?`Lines ${q} - ${Ge} of ${fe}`:"File Not Found"}`:"File Not Found"}`}}else if(a==="list_files"||a==="read_folder"){let c=a==="list_files"?"List":"Browsed",R=O(y.args,["path","recurse","include"]).path||null,_=O(y.args,["path","recurse","include"]).recurse||1;v=`${R?"\u2714":"\u2718"} ${c}: ${R?`${R==="."?`./${_>1?"*":""}`:`${R.replaceAll("\\","/")}${_>1?`${R.endsWith("/")?"*":"/*"}`:`${R.endsWith("/")?"":"/"}`}`}`:"No Folder Selected"}`}else if(a==="find_file"){let c=O(y.args,["basename","name","path","file","query"]),R=c.basename||c.name||c.path||c.file||c.query||"";v=`${R?"\u2714":"\u2718"} Located: ${R||"No Query"}`}else if(a==="write_file"||a==="update_file"){let c=a==="write_file"?"Created":"Edited",R=O(y.args,["path","content","allowMultiple","searchContent*","replaceContent*","newContent*"]),_=R.path||null,ye=Object.entries(R).some(([oe,ae])=>oe.startsWith("searchContent")&&typeof ae=="string"&&ae.startsWith("^LINE:"))?"\u1361":":";v=`${_?"\u2714":"\u2718"} ${c}${ye} ${_?_.replaceAll("\\","/"):"No File Changes"}`}else if(a==="write_pdf"){let c=O(y.args,["path","content","orientation","margin"]).path||null;v=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No PDF Generated"}`}else if(a==="write_docx"){let c=O(y.args,["path","content"]).path||null;v=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No Docx Generated"}`}else if(a==="file_map"){let c=O(y.args,["path"]).path;v=`${c?"\u2714":"\u2718"} Indexed: ${c.replaceAll("\\","/")?""+c:"File Not Found"}`}else if(a.toLowerCase()==="search_keyword"||a.toLowerCase()==="todo")v="";else if(a.toLowerCase()==="generate_image"){let{path:c,outputPath:R,output:_}=O(y.args,["path","prompt","text","outputPath","output","ratio"]);v=`\u2714 Generated: ${c||R||_||"generated_image.png"}`}else if(a==="invoke_sync"||a==="InvokeSync"){let c=oo(a,y.args);v=`\u2714 Called Generalist${c?`: ${c}`:""}`}else if(a==="Invoke"||a==="InvokeAsync"||a==="invoke"){let c=oo(a,y.args);v=`\u2714 Started Generalist${c?`: ${c}`:""}`}else if(a==="get_progress"||a==="GetProgress"){let c=oo(a,y.args);v=`\u2714 Checked${c?`: ${c}`:""}`}else if(a==="cancel"){let c=oo(a,y.args);v=`\u{1F6C7} Cancelled${c?`: ${c}`:""}`}else if(a==="steer"||a==="Steer"){let c=oo(a,y.args);v=`\u2714 Steered${c?`: ${c}`:""}`}else if(a==="EmergencyRollback"){let{method:c}=O(y.args,["method","id"]);v=c==="forceRevert"?"":"\u2714 Rollback Point Checked"}else if(a==="await"||a==="Await"||a==="wait"||a==="Wait"){let{time:c,timeout:R,seconds:_,sec:ce}=O(y.args,["time","timeout","seconds","sec"]),ye=parseFloat(_||ce||R||c)||45,oe=a==="wait"||a==="Wait"?120:180;ye<10&&(ye=10),ye>oe&&(ye=oe);let ae=q=>{if(q>=60){let W=Math.floor(q/60),fe=q%60;return`${W}m${fe>0?` ${fe}s`:""}`}return`${q}s`},Re=["Aligning Moon Phase","Contemplating Existence","Staring At Void","Delaying Professionally","Negotiating With Electrons","Touching Grass (virtually)","Panicking Softly","Rethinking Career Choices","Loading Cat Videos","Summoning Braincell #2","Pretending To Be Busy","Waiting For Motivation DLC","Rotating Internal Screaming","Downloading More RAM","Feeding The Hamsters","Gaslighting Scheduler","Performing Dramatic Pause","Buffering Social Energy","Calculating Regret","Reading Terms And Conditions","Becoming Sentient Briefly","Contacting Ancestors"];v=`\u2714 ${Re[Math.floor(Math.random()*Re.length)]} \u2192 ${ae(ye)}`}else a==="Answer"||a==="answer"?v="\u2714 Resolved Sub-Agent Query":a==="exec_command"||a==="ask"?v="":v=`Executed: ${y.toolName}`;if(yield*un(),a==="exec_command"){let{command:c}=O(y.args,["command","background","timeout","usePowershell","forcePowershell","useCwd","useCmd","forceCwd","forceCmd"]);if(c&&n.systemSettings&&n.systemSettings.allowExternalAccess===!1){let R=[/[a-zA-Z]:[\\\/]/i,/^\//,/\.\.[\\\/]/,/\/etc\//,/\/var\//,/\/root\//,/\/bin\//,/\/usr\//],_=B.resolve(process.cwd()).substring(0,3).toLowerCase(),ce=Q=>{let q=[],W="",fe=null;for(let Ge=0;Ge<Q.length;Ge++){let D=Q[Ge];fe?(D===fe&&(fe=null),W+=D):D==='"'||D==="'"?(fe=D,W+=D):D==="&"&&Q[Ge+1]==="&"||D==="|"&&Q[Ge+1]==="|"?(W.trim()&&(q.push(W.trim()),W=""),Ge++):D===";"||D==="|"||D==="&"?W.trim()&&(q.push(W.trim()),W=""):W+=D}return W.trim()&&q.push(W.trim()),q},ye=Q=>{let q=[],W="",fe=null;for(let Ge=0;Ge<Q.length;Ge++){let D=Q[Ge];fe?(D===fe&&(fe=null),W+=D):D==='"'||D==="'"?(fe=D,W+=D):/\s/.test(D)?W&&(q.push(W),W=""):W+=D}return W&&q.push(W),q},oe=Q=>{let q=Q.replace(/^['"]|['"]$/g,"").trim();return!q||process.platform==="win32"&&/^\/[a-zA-Z0-9?]+$/.test(q)?!1:R.some(W=>{if(W.source==="[a-zA-Z]:[\\\\\\/]"){let fe=q.match(/[a-zA-Z]:[\\\/]/i);return fe&&fe[0].toLowerCase()!==_}return W.test(q)})};if(ce(c).some(Q=>{let q=ye(Q);if(q.length===0)return!1;let W=q[0].replace(/^['"]|['"]$/g,"").toLowerCase();if(["echo","printf","write-output"].includes(W)){let Ge=!1;return q.some(D=>{let Rt=D.replace(/^['"]|['"]$/g,"");if(Rt===">"||Rt===">>"||Rt==="<")return Ge=!0,!1;if(Rt.startsWith(">")||Rt.startsWith("<")){let vt=Rt.replace(/^[><]+/,"");return oe(vt)}return Ge?(Ge=!1,oe(D)):!1})}return q.some(Ge=>oe(Ge))})){let Q='Access Denied. Prohibited from accessing external directories while "External Workspace Access" is disabled.';n.onExecStart&&n.onExecStart(c||"No Command"),yield{type:"exec_start"},await new Promise(q=>setTimeout(q,50)),n.onExecChunk&&n.onExecChunk(`ERROR: ${Q}`),await new Promise(q=>setTimeout(q,50)),n.onExecEnd&&n.onExecEnd(),je.push({role:"user",text:`[ACTION RESULT]: ERROR: ${Q}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${Q}`},Et++;continue}}n.onExecStart&&n.onExecStart(c||"No Command"),yield{type:"exec_start"}}let Ct=["write_file","update_file","view_file","read_folder","list_files","file_map"],On=["path","targetPath","file","content","searchContent*","replaceContent*","newContent*","recurse","include","StartLine","EndLine","start_line","end_line","startLine","endLine"],It=Ct.includes(a)?O(y.args,On):O(y.args),ut=It.path||It.targetPath||null;if(ut){let c=n.systemSettings&&n.systemSettings.allowExternalAccess===!1,R=B.resolve(ut),_=B.resolve(process.cwd());if(c&&!R.startsWith(_)){let ce="Access Denied. You are not allowed to access files outside the current workspace.";if(a==="write_file"||a==="update_file"){let oe=`\u2718 ${a==="write_file"?"Write Canceled":"Edit Canceled"}: ${It.path||"..."}`,ae=115;process.stdout.isTTY&&(ae=process.stdout.columns-5||120);let Re=Math.min(oe.length+4,ae),Q=`${oe.padEnd(Re-2).substring(0,Re-2)}`;yield{type:"visual_feedback",content:Lt(`${Fe?`
690
- `:""}${Q}
691
- `)},Fe=!1}je.push({role:"user",text:`[ACTION RESULT]: ERROR: ${ce}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${ce}`},Et++;continue}}if(n.onToolApproval){let c=n.systemSettings||{},R=c.autoExec,_=!1,ce="";if(a==="view_file"){let oe=O(y.args,["path","targetPath","file","StartLine","EndLine","start_line","end_line","startLine","endLine"]);if(ce=oe.path||oe.targetPath||oe.file||"",ce){let ae=c.alwaysAskFiles||".env, .env.*, *.env";Vs(ce,ae)&&(_=!0)}}if(a==="write_file"||a==="update_file"||a==="exec_command"||_){let oe=null,ae=!1,Re=!1,Q=!1,q=!1;if(_)ae=!0,oe=null;else if(a==="exec_command"){let{command:Ie}=O(y.args,["command","background","timeout","usePowershell","forcePowershell","useCwd","useCmd","forceCwd","forceCmd"]),xe=(Ie||"").trim(),Le=(Oe=>{let ct=[],dt="",He=null;for(let Ee=0;Ee<Oe.length;Ee++){let Y=Oe[Ee];He?(Y===He&&(He=null),dt+=Y):Y==='"'||Y==="'"?(He=Y,dt+=Y):Y==="&"&&Oe[Ee+1]==="&"||Y==="|"&&Oe[Ee+1]==="|"?(dt.trim()&&(ct.push(dt.trim()),dt=""),Ee++):Y===";"||Y==="|"||Y==="&"?dt.trim()&&(ct.push(dt.trim()),dt=""):dt+=Y}return dt.trim()&&ct.push(dt.trim()),ct.length>0?ct:[Oe]})(xe),ve=(Oe,ct)=>{if(!ct)return!1;let dt=ct.split(",").map(Ee=>Ee.trim().toLowerCase()).filter(Boolean),He=Oe.toLowerCase();return dt.some(Ee=>{if(He===Ee)return!0;if(He.startsWith(Ee)){let Y=He.charAt(Ee.length);return/\s|[;&|/]/.test(Y)}return!1})},ze=Le.some(Oe=>ve(Oe,c.alwaysAskCommands)),qt=Le.some(Oe=>ve(Oe,c.autoDisallowCommands)),qe=Le.length>0&&Le.every(Oe=>ve(Oe,c.autoApproveCommands)||c.autoApproveGit&&/^git\s+commit\b/i.test(Oe));if(qt)oe="deny";else if(c.networkAccess===!1){let ct=xe.trim().replace(/\s+/g," ").replace(/^['"]+|['"]+$/g,"").toLowerCase().split(" "),He=ct[0].split("/").pop().split("\\").pop().replace(/\.exe$/,""),Ee=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"]),Y=!1;Ee.has(He)&&(Y=!0);let Nt=co=>ct.slice(1).some(Rn=>co.includes(Rn)),Cn=co=>{let Rn=ct.findIndex(Bn=>co.includes(Bn)),Zn=ct.findIndex(Bn=>["run","exec","test"].includes(Bn));return Rn!==-1&&!(Zn!==-1&&Zn<Rn)};He==="git"&&Nt(["clone","pull","push","fetch"])&&(Y=!0),He==="go"&&Nt(["get","install"])&&(Y=!0),He==="npm"&&Cn(["install","i","update","add"])&&(Y=!0),He==="yarn"&&Cn(["add","install","upgrade"])&&(Y=!0),He==="pnpm"&&Cn(["add","install","update"])&&(Y=!0),He==="bun"&&Cn(["add","install","update"])&&(Y=!0),He==="deno"&&Nt(["install","add"])&&(Y=!0),He==="pip"&&Nt(["install","download"])&&(Y=!0),He==="pip3"&&Nt(["install","download"])&&(Y=!0),He==="cargo"&&Nt(["install","add"])&&(Y=!0),["bash","sh","zsh","fish"].includes(He)&&Nt(["-c"])&&(Y=!0),He==="cmd"&&Nt(["/c"])&&(Y=!0),Y&&(oe="deny",Q=!0)}!oe&&ze?ae=!0:!oe&&!ae&&(qe||c.autoApproveGit&&/^git\s+commit\b/i.test(xe))&&(oe="allow"),!ae&&!oe&&R&&(oe="allow")}else if(a==="write_file"||a==="update_file"){let Ie=!1;if(a==="write_file"&&c.overwriteProtection!==!1&&R)try{let{path:xe}=O(y.args,["path","content"]);xe&&we.existsSync(B.resolve(process.cwd(),xe))&&(Ie=!0,q=!0)}catch{}R&&!Ie&&(oe="allow")}let W=oe,fe="";oe==="deny"&&(Q?fe="network":Re?fe="settings":fe="prohibited");let Ge=!1,D="",Rt=[],vt=0,Co=!1,zt="";if(!W&&n.onToolApproval)try{let Ie=await n.onToolApproval(a,y.args,{checkOnly:!0});q&&Ie==="allow"||(Ie==="allow"||Ie==="deny")&&(W=Ie,W==="deny"&&(fe="user"))}catch{}if(!W){if(!q&&(a==="write_file"||a==="update_file"))try{let ke=O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]),{path:Le}=ke;if(Le){let{resolvedPath:ve}=mn(Le);Le=ve;let ze=B.resolve(process.cwd(),Le),qt=Ee=>Ee?Ee.toLowerCase().replace(/\\/g,"/").replace(/^[a-z]:/,Y=>Y.toUpperCase()):"",qe=qt(ze),Oe="",ct=!1,dt=await to(),He=qt(dt?.file_focused);if(dt&&He===qe&&dt.full_content?(Oe=dt.full_content,ct=!0):we.existsSync(ze)&&(Oe=we.readFileSync(ze,"utf8"),ct=!0),D=Oe,await di.recordFileChange(ze,Oe),ct){let Ee=Oe;if(a==="write_file"){let Y=ke.content||ke.newContent||"";Ee=Y.endsWith(`
692
+ \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(T){if(Qe){if(pe+=T,pe.length>=64){let y=0,A=Math.min(bt.length,pe.length);for(let l=A;l>=10;l--)if(bt.endsWith(pe.substring(0,l))){y=l;break}let ne=pe.substring(y);if(ne){let Ie=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(bt)?ne.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):ne.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");if(Ie)if(be+=Ie,i==="Google")pt+=Ie;else{yield*un();let Z=ko(Ie);for(let v of Z)yield v}}Qe=!1,pe=""}continue}else if(be+=T,i==="Google")pt+=T;else{yield*un();let y=ko(T);for(let A of y)yield A}let P=Il(be);if(P.inside){_t=!0,qn||(qn=Date.now());let A={Ask:"ask",AskUser:"ask",WebSearch:"web_search",WebScrape:"web_scrape",ReadFile:"view_file",ReadFolder:"read_folder",WriteFile:"write_file",PatchFile:"update_file",WritePDF:"write_pdf",WriteDoc:"write_docx",FindFile:"find_file",find_file:"find_file",findfile:"find_file",Run:"exec_command",SearchKeyword:"search_keyword",CodeSearch:"search_keyword",code_search:"search_keyword",Code_Search:"search_keyword",codesearch:"search_keyword",Memory:"memory",file_map:"file_map",FileMap:"file_map",Chat:"chat",chat:"chat",GenerateImage:"generate_image",generate_image:"generate_image",todo:"todo",Todo:"todo",goal:"todo",Goal:"todo",Invoke:"invoke",InvokeSync:"invoke_sync",getProgress:"get_progress",GetProgress:"get_progress",Cancel:"cancel",Await:"await",wait:"wait",Answer:"answer",Steer:"steer",steer:"steer"}[P.toolName]||P.toolName,ne=P.args||"",l=null;if(["write_file","update_file","view_file","read_folder","find_file","write_pdf","write_docx","search_keyword","generate_image","file_map","invoke","invoke_sync","get_progress","await","wait","answer"].includes(A)){let Z=O(ne,[],["path","basename","name","targetFile","TargetFile","directory","file","keyword","title","task","id","taskId","timeout","time","seconds"]),v=Z.basename||Z.name||Z.path||Z.targetFile||Z.TargetFile||Z.directory||Z.file,Ct=Z.keyword,On=Z.title||Z.task,It=Z.id||Z.taskId,ut=Z.timeout||Z.time||Z.seconds||Z.sec;if(Ct!=null)l=String(Ct).replace(_n,"");else if(v)l=U.basename(String(v).replace(_n,"").replace(da,"/"));else if(On&&(A==="invoke"||A==="invoke_sync"))l=String(On).replace(_n,"").substring(0,30);else if(It&&A==="get_progress")l=String(It).replace(_n,"");else if(ut&&A==="await"){let Ze=parseFloat(String(ut).replace(_n,""));isNaN(Ze)?l=String(ut).replace(_n,""):(Ze<5&&(Ze=5),Ze>120&&(Ze=180),l=(Mt=>{if(Mt>=60){let Nn=Math.floor(Mt/60),on=Mt%60;return`${Nn}m${on>0?` ${on}s`:""}`}return`${Mt}s`})(Ze))}else if(ut&&A==="wait"){let Ze=parseFloat(String(ut).replace(_n,""));isNaN(Ze)?l=String(ut).replace(_n,""):(Ze<10&&(Ze=10),Ze>120&&(Ze=120),l=(Mt=>{if(Mt>=60){let Nn=Math.floor(Mt/60),on=Mt%60;return`${Nn}m${on>0?` ${on}s`:""}`}return`${Mt}s`})(Ze))}else{let Ze=ne.match(Sl);if(Ze){let se=Ze[1].replace(_n,"");A==="invoke"||A==="invoke_sync"||A==="get_progress"?l=se.substring(0,30):l=A==="search_keyword"||A==="file_map"?se:U.basename(se.replace(da,"/"))}}}let Ie=`${vs[A]||A}${l?` ${l}`:""}`;if((A!==Ut||l!==bo)&&(Ut=A,bo=l,yield{type:"status",content:`${Ie}`},process.stdout.isTTY)){let v={WebSearch:"Searching",web_search:"Searching",WebScrape:"Reading",web_scrape:"Reading",ReadFile:"Reading",read_file:"Reading",ReadFolder:"Reading",read_folder:"Reading",WriteFile:"Writing",write_file:"Writing",UpdateFile:"Editing",update_file:"Editing",WritePdf:"Creating",write_pdf:"Creating",WriteDocx:"Creating",write_docx:"Creating",SearchKeyword:"Searching",search_keyword:"Searching",CodeSearch:"Searching",code_search:"Searching",FindFile:"Finding File",find_file:"Finding File",Run:"Executing",Ask:"User Input Required",AskUser:"User Input Required",Memory:"Updating Memory",GenerateImage:"Generating",InvokeSync:"Sub-Agent Working",invoke_sync:"Sub-Agent Working",Invoke:"Working",invoke:"Working",GetProgress:"Checking Progress",get_progress:"Checking Progress",Cancel:"Stopping Generalist",cancel:"Stopping Generalist",Await:"Waiting",await:"Waiting",wait:"Waiting",EmergencyRollback:"Rolling the Ball",Answer:"Answering Sub-Agent",answer:"Answering Sub-Agent",Steer:"Steering Sub-Agent",steer:"Steering Sub-Agent",Click:"Clicking",click:"Clicking",Drag:"Dragging",drag:"Dragging",Scroll:"Scrolling",scroll:"Scrolling",KeyboardTyping:"Typing",keyboard_typing:"Typing",KeyPress:"Pressing Key",key_press:"Pressing Key",RecaptureScreen:"Recapturing Screen",recapture_screen:"Recapturing Screen"}[A]||"Working";process.stdout.write(`\x1B]0;${v}...\x07`)}}if(be.length-ro>800){ro=be.length;let y=ka(be,!1),A=Rs(y),ne=A?(A.innerContent||"").trim():"",l=ne.split(/[.!?]\s+/).filter(re=>re.trim().length>10),Ie=new Set(l),Z=l.length>25?(l.length-Ie.size)/l.length:0,v=ne.split(/\s+/).filter(re=>re.length>0).length,Ct=.9,On=.92,It=!1;if(i.toLowerCase().includes("google")&&(J||"").toLowerCase().startsWith("gemma")){let at={low:2048,medium:4096,high:32768,max:65536,xhigh:65536}[d?.toLowerCase()]||16e3;It=v>at}if(Z>Ct||It){yield{type:"status",content:`${Z>Ct?"Reasoning Loop Detected":"Thinking Budget Exceeded"}. Re-centering...`},Wt=!0,await new Promise(at=>setTimeout(at,3e3));break}let se=pa(be).trim().split(/[.!?]\s+/).filter(re=>re.trim().length>10),Mt=new Set(se);if((se.length>25?(se.length-Mt.size)/se.length:0)>On){yield{type:"status",content:"Response Loop Detected. Re-centering..."},Wt=!1,Gt=!0,await new Promise(re=>setTimeout(re,3e3));break}let on=y.replace(ml,"").replace(pl,"").replace(hl,"").replace(yl,""),Dn=on.toLowerCase().split(/\s+/).map(re=>re.replace(xl,"")).filter(re=>re.length>0),Ao=!1;if(Dn.length>=40)for(let re=1;re<=15;re++){let at=Math.max(8,Math.ceil(25/re));if(Dn.length<re*at)continue;let Fn=Dn.slice(Dn.length-re),c=Fn.join(" ");if(re>1&&c===Fn.slice(0,Math.floor(re/2)).join(" ").repeat(2).trim())continue;let R=!0;for(let _=1;_<at;_++)if(Dn.slice(Dn.length-re*(_+1),Dn.length-re*_).join(" ")!==c){R=!1;break}if(R){Ao=!0;break}}if(!Ao){let re=on.toLowerCase().replace(wl,"");if(re.length>=80)for(let at=1;at<=10;at++){let Fn=Math.max(15,Math.ceil(45/at));if(re.length<at*Fn)continue;let c=re.substring(re.length-at),R=!0;for(let _=1;_<Fn;_++)if(re.substring(re.length-at*(_+1),re.length-at*_)!==c){R=!1;break}if(R){Ao=!0;break}}}if(Ao){yield{type:"status",content:"Stuttering Detected. Re-centering..."},Wt=!1,Xn=!0,await new Promise(re=>setTimeout(re,3e3));break}}let z=jt(be),yt=Kn(z);for(;yt.length>Et;){yield*un();let y=yt[Et],A=Date.now(),l={Ask:"ask",AskUser:"ask",WebSearch:"web_search",WebScrape:"web_scrape",ReadFile:"view_file",ReadFolder:"read_folder",FindFile:"find_file",find_file:"find_file",findfile:"find_file",WriteFile:"write_file",PatchFile:"update_file",WritePDF:"write_pdf",WriteDoc:"write_docx",Run:"exec_command",SearchKeyword:"search_keyword",CodeSearch:"search_keyword",code_search:"search_keyword",Code_Search:"search_keyword",codesearch:"search_keyword",Memory:"memory",file_map:"file_map",FileMap:"file_map",Chat:"chat",chat:"chat",GenerateImage:"generate_image",generate_image:"generate_image",todo:"todo",Todo:"todo",goal:"todo",Goal:"todo",Invoke:"invoke",InvokeSync:"invoke_sync",getProgress:"get_progress",GetProgress:"get_progress",Await:"await",await:"await",AwaitSubagent:"await",awaitSubagent:"await",Wait:"wait",wait:"wait",Answer:"answer",answer:"answer",AnswerSubagent:"answer",answerSubagent:"answer",Steer:"steer",steer:"steer",SteerSubagent:"steer",steerSubagent:"steer",Cancel:"cancel",cancel:"cancel",Click:"click",click:"click",Drag:"drag",drag:"drag",Scroll:"scroll",scroll:"scroll",KeyboardTyping:"keyboard_typing",keyboard_typing:"keyboard_typing",KeyPress:"key_press",key_press:"key_press",RecaptureScreen:"recapture_screen",recapture_screen:"recapture_screen",EmergencyRollback:"EmergencyRollback"}[y.toolName]||y.toolName,Ie=vs[l]||y.toolName,Z=oo(l,y.args);yield{type:"status",content:`${Ie}${Z?` ${Z}`:""}`};let v="";if(l==="click"){let c=O(y.args,["intendedClickText"]);v=`\u2714 Clicked ${c.intendedClickText?`: ${c.intendedClickText}`:"Screen"}`}else if(l==="drag"){let c=O(y.args,["fromGridId","toGridId"]);v=`\u2714 Dragged: Cell ${c.fromGridId||""} \u2192 Cell ${c.toGridId||""}`}else if(l==="scroll"){let c=O(y.args,["direction","amount"]);v=`\u2714 Scrolled: ${c.direction||"down"} (${c.amount||1})`}else if(l==="keyboard_typing"){let c=O(y.args,["text"]);v=`\u2714 ${c.autoPressEnter?"Entered":"Typed"}: ${c.text?`"${c.text.length>20?c.text.substring(0,20)+"...":c.text}"`:""}`}else if(l==="key_press")v=`\u2714 Pressed Key: ${O(y.args,["key"]).key||""}`;else if(l==="recapture_screen")v="\u2714 Recaptured Screen";else if(l==="web_search"){let{query:c,limit:R=10,aiMode:_=!1}=O(y.args,["query","limit","aiMode"]);v=`${c?"\u2714":"\u2718"} ${_?"AI Search":"Searched"}: ${c?`${c}`:"No Search Query"}${_===!1&&c?` \u2192 ${R}`:""}`}else if(l==="web_scrape"){let c=O(y.args,["url"]).url||null;v=`${c?"\u2714":"\u2718"} Visited: ${c||"No Source"}`}else if(l==="view_file"){let{path:c,StartLine:R,EndLine:_,start_line:ce,end_line:ye,startLine:oe,endLine:ae}=O(y.args,["path","StartLine","EndLine","start_line","end_line","startLine","endLine"]),Re=R||ce||oe,ee=_||ye||ae,q=parseInt(Re)||1,W=parseInt(ee)||(Re?q+800:800),ue="...",Ge=W,D=(c||"").trim().toLowerCase().replaceAll("\\","/");if(D.startsWith("#skill"))D.startsWith("#skill/global/fluxflow")||D.startsWith("#skills/global/fluxflow")||D.includes("#skill/fluxflow")||D.includes("#skills/fluxflow")?v="\u2714 Read Documentation":v=`\u2714 Read Skill: ${U.basename(c.replaceAll("\\","/"))}`;else{try{let{resolvedPath:xe}=mn(c),ke=U.resolve(process.cwd(),xe);if(we.existsSync(ke)){let ve=we.readFileSync(ke,"utf8").split(`
693
+ `).length;ue=ve,!Re&&!ee&&ve>800?Ge=Math.min(50,ve):Ge=Math.min(W,ve)}}catch{}let vt=(c||"").toLowerCase(),Co=vt.endsWith(".pdf"),zt=vt.endsWith(".docx")||vt.endsWith(".doc")||vt.endsWith(".ppt")||vt.endsWith(".pptx")||vt.endsWith(".xls")||vt.endsWith(".xlsx"),Me=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(vt);Co||zt?v=`${c.length>0?"\u2714":"\u2718"} ${c?`Analyzed: ${U.basename(c)}`:"Analyzed: File Not Found"}`:Me?v=`${c.length>0?"\u2714":"\u2718"} ${c?`Processed: ${U.basename(c)}`:"Processed: File Not Found"}`:v=`${ue!=="..."?"\u2714":"\u2718"} Read: ${c?`${U.basename(c)} \u2192 ${ue!=="..."?`Lines ${q} - ${Ge} of ${ue}`:"File Not Found"}`:"File Not Found"}`}}else if(l==="list_files"||l==="read_folder"){let c=l==="list_files"?"List":"Browsed",R=O(y.args,["path","recurse","include"]).path||null,_=O(y.args,["path","recurse","include"]).recurse||1;v=`${R?"\u2714":"\u2718"} ${c}: ${R?`${R==="."?`./${_>1?"*":""}`:`${R.replaceAll("\\","/")}${_>1?`${R.endsWith("/")?"*":"/*"}`:`${R.endsWith("/")?"":"/"}`}`}`:"No Folder Selected"}`}else if(l==="find_file"){let c=O(y.args,["basename","name","path","file","query"]),R=c.basename||c.name||c.path||c.file||c.query||"";v=`${R?"\u2714":"\u2718"} Located: ${R||"No Query"}`}else if(l==="write_file"||l==="update_file"){let c=l==="write_file"?"Created":"Edited",R=O(y.args,["path","content","allowMultiple","searchContent*","replaceContent*","newContent*"]),_=R.path||null,ye=Object.entries(R).some(([oe,ae])=>oe.startsWith("searchContent")&&typeof ae=="string"&&ae.startsWith("^LINE:"))?"\u1361":":";v=`${_?"\u2714":"\u2718"} ${c}${ye} ${_?_.replaceAll("\\","/"):"No File Changes"}`}else if(l==="write_pdf"){let c=O(y.args,["path","content","orientation","margin"]).path||null;v=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No PDF Generated"}`}else if(l==="write_docx"){let c=O(y.args,["path","content"]).path||null;v=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No Docx Generated"}`}else if(l==="file_map"){let c=O(y.args,["path"]).path;v=`${c?"\u2714":"\u2718"} Indexed: ${c.replaceAll("\\","/")?""+c:"File Not Found"}`}else if(l.toLowerCase()==="search_keyword"||l.toLowerCase()==="todo")v="";else if(l.toLowerCase()==="generate_image"){let{path:c,outputPath:R,output:_}=O(y.args,["path","prompt","text","outputPath","output","ratio"]);v=`\u2714 Generated: ${c||R||_||"generated_image.png"}`}else if(l==="invoke_sync"||l==="InvokeSync"){let c=oo(l,y.args);v=`\u2714 Called Generalist${c?`: ${c}`:""}`}else if(l==="Invoke"||l==="InvokeAsync"||l==="invoke"){let c=oo(l,y.args);v=`\u2714 Started Generalist${c?`: ${c}`:""}`}else if(l==="get_progress"||l==="GetProgress"){let c=oo(l,y.args);v=`\u2714 Checked${c?`: ${c}`:""}`}else if(l==="cancel"){let c=oo(l,y.args);v=`\u{1F6C7} Cancelled${c?`: ${c}`:""}`}else if(l==="steer"||l==="Steer"){let c=oo(l,y.args);v=`\u2714 Steered${c?`: ${c}`:""}`}else if(l==="EmergencyRollback"){let{method:c}=O(y.args,["method","id"]);v=c==="forceRevert"?"":"\u2714 Rollback Point Checked"}else if(l==="await"||l==="Await"||l==="wait"||l==="Wait"){let{time:c,timeout:R,seconds:_,sec:ce}=O(y.args,["time","timeout","seconds","sec"]),ye=parseFloat(_||ce||R||c)||45,oe=l==="wait"||l==="Wait"?120:180;ye<10&&(ye=10),ye>oe&&(ye=oe);let ae=q=>{if(q>=60){let W=Math.floor(q/60),ue=q%60;return`${W}m${ue>0?` ${ue}s`:""}`}return`${q}s`},Re=["Aligning Moon Phase","Contemplating Existence","Staring At Void","Delaying Professionally","Negotiating With Electrons","Touching Grass (virtually)","Panicking Softly","Rethinking Career Choices","Loading Cat Videos","Summoning Braincell #2","Pretending To Be Busy","Waiting For Motivation DLC","Rotating Internal Screaming","Downloading More RAM","Feeding The Hamsters","Gaslighting Scheduler","Performing Dramatic Pause","Buffering Social Energy","Calculating Regret","Reading Terms And Conditions","Becoming Sentient Briefly","Contacting Ancestors"];v=`\u2714 ${Re[Math.floor(Math.random()*Re.length)]} \u2192 ${ae(ye)}`}else l==="Answer"||l==="answer"?v="\u2714 Resolved Sub-Agent Query":l==="exec_command"||l==="ask"?v="":v=`Executed: ${y.toolName}`;if(yield*un(),l==="exec_command"){let{command:c}=O(y.args,["command","background","timeout","usePowershell","forcePowershell","useCwd","useCmd","forceCwd","forceCmd"]);if(c&&n.systemSettings&&n.systemSettings.allowExternalAccess===!1){let R=[/[a-zA-Z]:[\\\/]/i,/^\//,/\.\.[\\\/]/,/\/etc\//,/\/var\//,/\/root\//,/\/bin\//,/\/usr\//],_=U.resolve(process.cwd()).substring(0,3).toLowerCase(),ce=ee=>{let q=[],W="",ue=null;for(let Ge=0;Ge<ee.length;Ge++){let D=ee[Ge];ue?(D===ue&&(ue=null),W+=D):D==='"'||D==="'"?(ue=D,W+=D):D==="&"&&ee[Ge+1]==="&"||D==="|"&&ee[Ge+1]==="|"?(W.trim()&&(q.push(W.trim()),W=""),Ge++):D===";"||D==="|"||D==="&"?W.trim()&&(q.push(W.trim()),W=""):W+=D}return W.trim()&&q.push(W.trim()),q},ye=ee=>{let q=[],W="",ue=null;for(let Ge=0;Ge<ee.length;Ge++){let D=ee[Ge];ue?(D===ue&&(ue=null),W+=D):D==='"'||D==="'"?(ue=D,W+=D):/\s/.test(D)?W&&(q.push(W),W=""):W+=D}return W&&q.push(W),q},oe=ee=>{let q=ee.replace(/^['"]|['"]$/g,"").trim();return!q||process.platform==="win32"&&/^\/[a-zA-Z0-9?]+$/.test(q)?!1:R.some(W=>{if(W.source==="[a-zA-Z]:[\\\\\\/]"){let ue=q.match(/[a-zA-Z]:[\\\/]/i);return ue&&ue[0].toLowerCase()!==_}return W.test(q)})};if(ce(c).some(ee=>{let q=ye(ee);if(q.length===0)return!1;let W=q[0].replace(/^['"]|['"]$/g,"").toLowerCase();if(["echo","printf","write-output"].includes(W)){let Ge=!1;return q.some(D=>{let Rt=D.replace(/^['"]|['"]$/g,"");if(Rt===">"||Rt===">>"||Rt==="<")return Ge=!0,!1;if(Rt.startsWith(">")||Rt.startsWith("<")){let vt=Rt.replace(/^[><]+/,"");return oe(vt)}return Ge?(Ge=!1,oe(D)):!1})}return q.some(Ge=>oe(Ge))})){let ee='Access Denied. Prohibited from accessing external directories while "External Workspace Access" is disabled.';n.onExecStart&&n.onExecStart(c||"No Command"),yield{type:"exec_start"},await new Promise(q=>setTimeout(q,50)),n.onExecChunk&&n.onExecChunk(`ERROR: ${ee}`),await new Promise(q=>setTimeout(q,50)),n.onExecEnd&&n.onExecEnd(),je.push({role:"user",text:`[ACTION RESULT]: ERROR: ${ee}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${ee}`},Et++;continue}}n.onExecStart&&n.onExecStart(c||"No Command"),yield{type:"exec_start"}}let Ct=["write_file","update_file","view_file","read_folder","list_files","file_map"],On=["path","targetPath","file","content","searchContent*","replaceContent*","newContent*","recurse","include","StartLine","EndLine","start_line","end_line","startLine","endLine"],It=Ct.includes(l)?O(y.args,On):O(y.args),ut=It.path||It.targetPath||null;if(ut){let c=n.systemSettings&&n.systemSettings.allowExternalAccess===!1,R=U.resolve(ut),_=U.resolve(process.cwd());if(c&&!R.startsWith(_)){let ce="Access Denied. You are not allowed to access files outside the current workspace.";if(l==="write_file"||l==="update_file"){let oe=`\u2718 ${l==="write_file"?"Write Canceled":"Edit Canceled"}: ${It.path||"..."}`,ae=115;process.stdout.isTTY&&(ae=process.stdout.columns-5||120);let Re=Math.min(oe.length+4,ae),ee=`${oe.padEnd(Re-2).substring(0,Re-2)}`;yield{type:"visual_feedback",content:Lt(`${Be?`
694
+ `:""}${ee}
695
+ `)},Be=!1}je.push({role:"user",text:`[ACTION RESULT]: ERROR: ${ce}`}),yield{type:"tool_result",content:`[ACTION RESULT]: ERROR: ${ce}`},Et++;continue}}if(n.onToolApproval){let c=n.systemSettings||{},R=c.autoExec,_=!1,ce="";if(l==="view_file"){let oe=O(y.args,["path","targetPath","file","StartLine","EndLine","start_line","end_line","startLine","endLine"]);if(ce=oe.path||oe.targetPath||oe.file||"",ce){let ae=c.alwaysAskFiles||".env, .env.*, *.env";Vs(ce,ae)&&(_=!0)}}if(l==="write_file"||l==="update_file"||l==="exec_command"||_){let oe=null,ae=!1,Re=!1,ee=!1,q=!1;if(_)ae=!0,oe=null;else if(l==="exec_command"){let{command:Me}=O(y.args,["command","background","timeout","usePowershell","forcePowershell","useCwd","useCmd","forceCwd","forceCmd"]),xe=(Me||"").trim(),Oe=(Ne=>{let ct=[],dt="",He=null;for(let Ee=0;Ee<Ne.length;Ee++){let Y=Ne[Ee];He?(Y===He&&(He=null),dt+=Y):Y==='"'||Y==="'"?(He=Y,dt+=Y):Y==="&"&&Ne[Ee+1]==="&"||Y==="|"&&Ne[Ee+1]==="|"?(dt.trim()&&(ct.push(dt.trim()),dt=""),Ee++):Y===";"||Y==="|"||Y==="&"?dt.trim()&&(ct.push(dt.trim()),dt=""):dt+=Y}return dt.trim()&&ct.push(dt.trim()),ct.length>0?ct:[Ne]})(xe),ve=(Ne,ct)=>{if(!ct)return!1;let dt=ct.split(",").map(Ee=>Ee.trim().toLowerCase()).filter(Boolean),He=Ne.toLowerCase();return dt.some(Ee=>{if(He===Ee)return!0;if(He.startsWith(Ee)){let Y=He.charAt(Ee.length);return/\s|[;&|/]/.test(Y)}return!1})},ze=Oe.some(Ne=>ve(Ne,c.alwaysAskCommands)),qt=Oe.some(Ne=>ve(Ne,c.autoDisallowCommands)),qe=Oe.length>0&&Oe.every(Ne=>ve(Ne,c.autoApproveCommands)||c.autoApproveGit&&/^git\s+commit\b/i.test(Ne));if(qt)oe="deny";else if(c.networkAccess===!1){let ct=xe.trim().replace(/\s+/g," ").replace(/^['"]+|['"]+$/g,"").toLowerCase().split(" "),He=ct[0].split("/").pop().split("\\").pop().replace(/\.exe$/,""),Ee=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"]),Y=!1;Ee.has(He)&&(Y=!0);let Nt=co=>ct.slice(1).some(Rn=>co.includes(Rn)),Cn=co=>{let Rn=ct.findIndex(Bn=>co.includes(Bn)),Zn=ct.findIndex(Bn=>["run","exec","test"].includes(Bn));return Rn!==-1&&!(Zn!==-1&&Zn<Rn)};He==="git"&&Nt(["clone","pull","push","fetch"])&&(Y=!0),He==="go"&&Nt(["get","install"])&&(Y=!0),He==="npm"&&Cn(["install","i","update","add"])&&(Y=!0),He==="yarn"&&Cn(["add","install","upgrade"])&&(Y=!0),He==="pnpm"&&Cn(["add","install","update"])&&(Y=!0),He==="bun"&&Cn(["add","install","update"])&&(Y=!0),He==="deno"&&Nt(["install","add"])&&(Y=!0),He==="pip"&&Nt(["install","download"])&&(Y=!0),He==="pip3"&&Nt(["install","download"])&&(Y=!0),He==="cargo"&&Nt(["install","add"])&&(Y=!0),["bash","sh","zsh","fish"].includes(He)&&Nt(["-c"])&&(Y=!0),He==="cmd"&&Nt(["/c"])&&(Y=!0),Y&&(oe="deny",ee=!0)}!oe&&ze?ae=!0:!oe&&!ae&&(qe||c.autoApproveGit&&/^git\s+commit\b/i.test(xe))&&(oe="allow"),!ae&&!oe&&R&&(oe="allow")}else if(l==="write_file"||l==="update_file"){let Me=!1;if(l==="write_file"&&c.overwriteProtection!==!1&&R)try{let{path:xe}=O(y.args,["path","content"]);xe&&we.existsSync(U.resolve(process.cwd(),xe))&&(Me=!0,q=!0)}catch{}R&&!Me&&(oe="allow")}let W=oe,ue="";oe==="deny"&&(ee?ue="network":Re?ue="settings":ue="prohibited");let Ge=!1,D="",Rt=[],vt=0,Co=!1,zt="";if(!W&&n.onToolApproval)try{let Me=await n.onToolApproval(l,y.args,{checkOnly:!0});q&&Me==="allow"||(Me==="allow"||Me==="deny")&&(W=Me,W==="deny"&&(ue="user"))}catch{}if(!W){if(!q&&(l==="write_file"||l==="update_file"))try{let ke=O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]),{path:Oe}=ke;if(Oe){let{resolvedPath:ve}=mn(Oe);Oe=ve;let ze=U.resolve(process.cwd(),Oe),qt=Ee=>Ee?Ee.toLowerCase().replace(/\\/g,"/").replace(/^[a-z]:/,Y=>Y.toUpperCase()):"",qe=qt(ze),Ne="",ct=!1,dt=await to(),He=qt(dt?.file_focused);if(dt&&He===qe&&dt.full_content?(Ne=dt.full_content,ct=!0):we.existsSync(ze)&&(Ne=we.readFileSync(ze,"utf8"),ct=!0),D=Ne,await di.recordFileChange(ze,Ne),ct){let Ee=Ne;if(l==="write_file"){let Y=ke.content||ke.newContent||"";Ee=Y.endsWith(`
692
696
  `)?Y:Y+`
693
- `,zt=Ee}else{let{patchPairs:Y,allowMultiple:Nt,error:Cn}=Xi(ke);if(Cn){let Yt=`[ACTION RESULT]: ERROR: ${Cn}`;je.push({role:"user",text:Yt}),await $t("toolFailure"),n.onToolResult&&n.onToolResult("failure",a),yield{type:"tool_result",content:Yt,toolName:a},Et++;continue}let co=ke.allowMultiple!==void 0?ke.allowMultiple===!0||String(ke.allowMultiple).toLowerCase()==="true":Nt;vt=Y.length;let Rn=qs(Oe,Y,{allowMultiple:co});Ee=Rn.content,zt=Ee,Rt=Rn.results;let Zn=Rt.filter(Yt=>Yt.success),Bn=Rt.filter(Yt=>!Yt.success);if(Zn.length===0){let Yt=`[ACTION RESULT]: ERROR: Failed to apply patches to [${B.basename(ze)}].
697
+ `,zt=Ee}else{let{patchPairs:Y,allowMultiple:Nt,error:Cn}=Xi(ke);if(Cn){let Yt=`[ACTION RESULT]: ERROR: ${Cn}`;je.push({role:"user",text:Yt}),await $t("toolFailure"),n.onToolResult&&n.onToolResult("failure",l),yield{type:"tool_result",content:Yt,toolName:l},Et++;continue}let co=ke.allowMultiple!==void 0?ke.allowMultiple===!0||String(ke.allowMultiple).toLowerCase()==="true":Nt;vt=Y.length;let Rn=qs(Ne,Y,{allowMultiple:co});Ee=Rn.content,zt=Ee,Rt=Rn.results;let Zn=Rt.filter(Yt=>Yt.success),Bn=Rt.filter(Yt=>!Yt.success);if(Zn.length===0){let Yt=`[ACTION RESULT]: ERROR: Failed to apply patches to [${U.basename(ze)}].
694
698
  ${Bn.map(Un=>` \u2022 ${Un.error}`).join(`
695
- `)}`,ei=`\u2714 Edited: ${B.basename(ze.replaceAll("\\","/"))}`,Ro=115;process.stdout.isTTY&&(Ro=process.stdout.columns-5||120);let Wi=Math.min(ei.length+4,Ro),gn=`${ei.padEnd(Wi-2).substring(0,Wi-2)}`;yield{type:"visual_feedback",content:Lt(`${Fe?`
696
- `:""}${gn}`)},Fe=!1,je.push({role:"user",text:Yt}),await $t("toolFailure"),n.onToolResult&&n.onToolResult("failure",a),yield{type:"tool_result",content:Yt,toolName:a},Et++;continue}}yield{type:"status",content:`Opening Diff in IDE: ${B.basename(ze)}`},is(ze,Oe,Ee),Ge=!0,await new Promise(Y=>setTimeout(Y,50))}else if(a==="write_file"){let Ee=ke.content||ke.newContent||"",Y=Ee.endsWith(`
699
+ `)}`,ei=`\u2714 Edited: ${U.basename(ze.replaceAll("\\","/"))}`,Ro=115;process.stdout.isTTY&&(Ro=process.stdout.columns-5||120);let Wi=Math.min(ei.length+4,Ro),gn=`${ei.padEnd(Wi-2).substring(0,Wi-2)}`;yield{type:"visual_feedback",content:Lt(`${Be?`
700
+ `:""}${gn}`)},Be=!1,je.push({role:"user",text:Yt}),await $t("toolFailure"),n.onToolResult&&n.onToolResult("failure",l),yield{type:"tool_result",content:Yt,toolName:l},Et++;continue}}yield{type:"status",content:`Opening Diff in IDE: ${U.basename(ze)}`},is(ze,Ne,Ee),Ge=!0,await new Promise(Y=>setTimeout(Y,50))}else if(l==="write_file"){let Ee=ke.content||ke.newContent||"",Y=Ee.endsWith(`
697
701
  `)?Ee:Ee+`
698
- `;zt=Y,we.existsSync(ze)||(Co=!0,we.mkdirSync(B.dirname(ze),{recursive:!0}),we.writeFileSync(ze,"","utf8")),yield{type:"status",content:`Opening New File Diff in IDE: ${B.basename(ze)}`},is(ze,"",Y),Ge=!0,await new Promise(Nt=>setTimeout(Nt,50))}}}catch(ke){console.error("Simulation/Diff Error:",ke)}let Ie=null;os(ke=>{Ie=ke});let xe=n.onToolApproval;if(W=await new Promise(async ke=>{let Le=setInterval(()=>{if(Ie){let ve=n.onIDEApproval||Vo&&Vo.onIDEApproval;ve&&ve(Ie),clearInterval(Le),ke(Ie)}},100);try{let ve=await xe(a,y.args,{isOverwritePrompt:q});clearInterval(Le),ke(ve)}catch{clearInterval(Le),ke("deny")}}),os(null),a==="write_file"||a==="update_file"){let ke=O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]),{path:Le}=ke;if(Le){let{resolvedPath:ve}=mn(Le);Le=ve;let ze=B.resolve(process.cwd(),Le);if(br(ze,W),W==="deny"&&Co&&we.existsSync(ze))try{we.unlinkSync(ze)}catch{}}}W==="deny"&&(fe="user")}if(W==="allow"&&Ge&&yo()){let Ie=O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]),{path:xe}=Ie,{resolvedPath:ke,isTildeResolved:Le}=mn(xe);xe=ke;let ve=B.resolve(process.cwd(),xe),ze=Ke=>Ke?B.resolve(Ke).replace(/\\/g,"/").toLowerCase():"",qt=await to(),qe="";if(qt&&qt.file_focused&&ze(qt.file_focused)===ze(ve)&&qt.full_content&&(qe=qt.full_content),!qe&&we.existsSync(ve)){let Ke=we.readFileSync(ve,"utf8");Ke&&(qe=Ke)}!qe&&zt&&(qe=zt),(qe||Co)&&we.writeFileSync(ve,qe,"utf8");let Oe=qe.split(/\r?\n/),ct=Oe.length,dt=Buffer.byteLength(qe,"utf8"),He="";D&&(He=`Old File contents:
699
- ${D.split(/\r?\n/).map((ot,sn)=>`${sn+1} | ${ot}`).join(`
702
+ `;zt=Y,we.existsSync(ze)||(Co=!0,we.mkdirSync(U.dirname(ze),{recursive:!0}),we.writeFileSync(ze,"","utf8")),yield{type:"status",content:`Opening New File Diff in IDE: ${U.basename(ze)}`},is(ze,"",Y),Ge=!0,await new Promise(Nt=>setTimeout(Nt,50))}}}catch(ke){console.error("Simulation/Diff Error:",ke)}let Me=null;os(ke=>{Me=ke});let xe=n.onToolApproval;if(W=await new Promise(async ke=>{let Oe=setInterval(()=>{if(Me){let ve=n.onIDEApproval||Vo&&Vo.onIDEApproval;ve&&ve(Me),clearInterval(Oe),ke(Me)}},100);try{let ve=await xe(l,y.args,{isOverwritePrompt:q});clearInterval(Oe),ke(ve)}catch{clearInterval(Oe),ke("deny")}}),os(null),l==="write_file"||l==="update_file"){let ke=O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]),{path:Oe}=ke;if(Oe){let{resolvedPath:ve}=mn(Oe);Oe=ve;let ze=U.resolve(process.cwd(),Oe);if(br(ze,W),W==="deny"&&Co&&we.existsSync(ze))try{we.unlinkSync(ze)}catch{}}}W==="deny"&&(ue="user")}if(W==="allow"&&Ge&&yo()){let Me=O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]),{path:xe}=Me,{resolvedPath:ke,isTildeResolved:Oe}=mn(xe);xe=ke;let ve=U.resolve(process.cwd(),xe),ze=Ke=>Ke?U.resolve(Ke).replace(/\\/g,"/").toLowerCase():"",qt=await to(),qe="";if(qt&&qt.file_focused&&ze(qt.file_focused)===ze(ve)&&qt.full_content&&(qe=qt.full_content),!qe&&we.existsSync(ve)){let Ke=we.readFileSync(ve,"utf8");Ke&&(qe=Ke)}!qe&&zt&&(qe=zt),(qe||Co)&&we.writeFileSync(ve,qe,"utf8");let Ne=qe.split(/\r?\n/),ct=Ne.length,dt=Buffer.byteLength(qe,"utf8"),He="";D&&(He=`Old File contents:
703
+ ${D.split(/\r?\n/).map((it,sn)=>`${sn+1} | ${it}`).join(`
700
704
  `)}
701
705
 
702
- `);let Ee="";if(ct<=100)Ee=Oe.join(`
703
- `);else{let Ke=Oe.slice(0,50).join(`
704
- `),ot=Oe.slice(-50).join(`
706
+ `);let Ee="";if(ct<=100)Ee=Ne.join(`
707
+ `);else{let Ke=Ne.slice(0,50).join(`
708
+ `),it=Ne.slice(-50).join(`
705
709
  `);Ee=`${Ke}
706
710
 
707
711
  ... [${ct-100} lines truncated for history stability] ...
708
712
 
709
- ${ot}`}let Y="";if(a==="update_file"){let Ke=Xs(D,qe,Rt,12,n?.compressToolResults||Vo?.systemSettings?.compressToolResults),{patchPairs:ot}=Xi(O(y.args,["path","searchContent*","replaceContent*","newContent*"])),sn=ot?.length||vt||1,Pt=0,Xt=0,Wn=[];ot&&ot.length>0?ot.forEach((Hn,go)=>{let mo=Hn.replace||"",rn=Hn.new||"",Gi=mo.trim(),Eo=rn.trim(),Wa=!!zt&&qe===zt,Ga=Eo?qe.includes(rn)||qe.includes(Eo):!0,Ha=rn?D.includes(rn)||!!Eo&&D.includes(Eo):!1,ja=Gi?qe.includes(mo)||qe.includes(Gi):!1;Wa||!!rn&&Ga&&(!Ha||!ja||Gi===Eo)?Pt++:(Xt++,Wn.push(` \u2022 Block ${go+1}: not applied (reverted or rejected in IDE).`))}):Pt=vt||0;let vn=0;if(zt&&qe!==zt){let Hn=ul("","",zt||"",qe||"","","",{context:0});if(Hn&&Hn.hunks)for(let go of Hn.hunks){let mo=go.lines.filter(rn=>rn.startsWith("+")).map(rn=>rn.slice(1).trim()).filter(Boolean);for(let rn of mo)D.includes(rn)||vn++}}let vo=[`[${Pt}/${sn}] applied`];Xt>0&&vo.push(`${Xt} rejected by user`),vn>0&&vo.push(`${vn} manual ${vn===1?"modification":"modifications"} by user`);let fo=vo.join(", "),Gn=Wn.length>0?`
713
+ ${it}`}let Y="";if(l==="update_file"){let Ke=Xs(D,qe,Rt,12,n?.compressToolResults||Vo?.systemSettings?.compressToolResults),{patchPairs:it}=Xi(O(y.args,["path","searchContent*","replaceContent*","newContent*"])),sn=it?.length||vt||1,Pt=0,Xt=0,Wn=[];it&&it.length>0?it.forEach((Hn,go)=>{let mo=Hn.replace||"",rn=Hn.new||"",Gi=mo.trim(),Eo=rn.trim(),Wa=!!zt&&qe===zt,Ga=Eo?qe.includes(rn)||qe.includes(Eo):!0,Ha=rn?D.includes(rn)||!!Eo&&D.includes(Eo):!1,ja=Gi?qe.includes(mo)||qe.includes(Gi):!1;Wa||!!rn&&Ga&&(!Ha||!ja||Gi===Eo)?Pt++:(Xt++,Wn.push(` \u2022 Block ${go+1}: not applied (reverted or rejected in IDE).`))}):Pt=vt||0;let vn=0;if(zt&&qe!==zt){let Hn=ul("","",zt||"",qe||"","","",{context:0});if(Hn&&Hn.hunks)for(let go of Hn.hunks){let mo=go.lines.filter(rn=>rn.startsWith("+")).map(rn=>rn.slice(1).trim()).filter(Boolean);for(let rn of mo)D.includes(rn)||vn++}}let vo=[`[${Pt}/${sn}] applied`];Xt>0&&vo.push(`${Xt} rejected by user`),vn>0&&vo.push(`${vn} manual ${vn===1?"modification":"modifications"} by user`);let fo=vo.join(", "),Gn=Wn.length>0?`
710
714
 
711
715
  User Review Details:
712
716
  ${Wn.join(`
713
717
  `)}`:"";Y=`File [${xe}] updated via IDE Companion. ${fo}.${Gn}
714
718
 
715
- ${Ke}${Le?`
719
+ ${Ke}${Oe?`
716
720
 
717
- [Note: '~' resolved to user home directory. To target literal '~' in current directory, escape it as '\\~']`:""}`;let{added:ti,removed:ni}=Ys(D,qe);(ti>0||ni>0)&&await zi({added:ti,removed:ni,file:xe})}else{let Ke=qe.split(/\r?\n/),ot=Ke.length,sn=Buffer.byteLength(qe,"utf8"),Pt="",Xt=c?.overwriteProtection!==!1;if(D){let fo=D.split(/\r?\n/);if(!Xt)Pt="";else if(fo.length<=50)Pt=`Old File contents:
721
+ [Note: '~' resolved to user home directory. To target literal '~' in current directory, escape it as '\\~']`:""}`;let{added:ti,removed:ni}=Ys(D,qe);(ti>0||ni>0)&&await zi({added:ti,removed:ni,file:xe})}else{let Ke=qe.split(/\r?\n/),it=Ke.length,sn=Buffer.byteLength(qe,"utf8"),Pt="",Xt=c?.overwriteProtection!==!1;if(D){let fo=D.split(/\r?\n/);if(!Xt)Pt="";else if(fo.length<=50)Pt=`Old File contents:
718
722
  ${fo.map((Gn,uo)=>`${uo+1} | ${Gn}`).join(`
719
723
  `)}
720
724
 
721
- `;else{let Gn=B.parse(ve),uo=B.join(ii,"OverwriteBackups");if(!we.existsSync(uo))try{we.mkdirSync(uo,{recursive:!0})}catch{}let ti=String(Date.now()).slice(-5),ni=wa.randomBytes(2).toString("hex"),Hn=`${Gn.name}-old-${ti}-${ni}${Gn.ext}.bak`,go=B.join(uo,Hn);try{we.writeFileSync(go,D,"utf8")}catch{}Pt=`Old File contents:
725
+ `;else{let Gn=U.parse(ve),uo=U.join(ii,"OverwriteBackups");if(!we.existsSync(uo))try{we.mkdirSync(uo,{recursive:!0})}catch{}let ti=String(Date.now()).slice(-5),ni=wa.randomBytes(2).toString("hex"),Hn=`${Gn.name}-old-${ti}-${ni}${Gn.ext}.bak`,go=U.join(uo,Hn);try{we.writeFileSync(go,D,"utf8")}catch{}Pt=`Old File contents:
722
726
  - Renamed old file as ${go.replaceAll("\\","/").replace(xa.homedir().replaceAll("\\","/"),"~")} and written requested content in ${xe}. For reversal use Run
723
727
 
724
- `}}let Wn="";if(ot<=690)Wn=Ke.join(`
728
+ `}}let Wn="";if(it<=690)Wn=Ke.join(`
725
729
  `);else{let fo=Ke.slice(0,300).join(`
726
730
  `),Gn=Ke.slice(-300).join(`
727
731
  `);Wn=`${fo}
728
732
 
729
- ... [${ot-100} lines truncated] ...
733
+ ... [${it-100} lines truncated] ...
730
734
 
731
- ${Gn}`}let vn=Le?`
735
+ ${Gn}`}let vn=Oe?`
732
736
 
733
737
  [Note: '~' resolved to user home directory. To target literal '~' in current directory, escape it as '\\~']`:"";Y=`File [${xe}] saved via IDE Companion (May have user edits).
734
- - Stats: [${ot} lines, ${(sn/1024).toFixed(1)} KB]
738
+ - Stats: [${it} lines, ${(sn/1024).toFixed(1)} KB]
735
739
  ${Pt}- Content Preview:
736
740
 
737
- ${Wn}${vn}`;let vo=D?D.split(/\r?\n/).length:0;await zi({added:ot,removed:vo,file:xe})}let Nt=a==="write_file"?"Created":"Edited",Cn=O(y.args,["path","content","allowMultiple","searchContent*","replaceContent*","newContent*"]),Rn=Object.entries(Cn).some(([Ke,ot])=>Ke.startsWith("searchContent")&&typeof ot=="string"&&ot.startsWith("^LINE:"))?"\u1361":":",Zn=`${xe?"\u2714":"\u2718"} ${Nt}${Rn} ${xe?xe.replaceAll("\\","/"):"No File Changes"}`,Bn=115;process.stdout.isTTY&&(Bn=process.stdout.columns-5||120);let Yt=Math.min(Zn.length+4,Bn),ei=`${Zn.padEnd(Yt-2).substring(0,Yt-2)}`;yield{type:"visual_feedback",content:Lt(`${Fe?`
738
- `:""}${ei}`)},Fe=!1;let Ro=Date.now();Yn=Ro,yield{type:"tool_time",content:Ro-A};let gn=(Y||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");gn.includes("[[VERIFIED]]")&&(gn=gn.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to conserve context.
739
- `));let Un;if(a==="write_file"&&!gn.startsWith("ERROR:")){let Ke=gn.replace(/^\[\[SAME\]\]\s*\r?\n?/,""),ot=Ke.match(/\n\s*(\[Note:\s*'~'\s*resolved\s*to\s*user\s*home\s*directory[\s\S]*?\])\s*$/),sn=ot?`
741
+ ${Wn}${vn}`;let vo=D?D.split(/\r?\n/).length:0;await zi({added:it,removed:vo,file:xe})}let Nt=l==="write_file"?"Created":"Edited",Cn=O(y.args,["path","content","allowMultiple","searchContent*","replaceContent*","newContent*"]),Rn=Object.entries(Cn).some(([Ke,it])=>Ke.startsWith("searchContent")&&typeof it=="string"&&it.startsWith("^LINE:"))?"\u1361":":",Zn=`${xe?"\u2714":"\u2718"} ${Nt}${Rn} ${xe?xe.replaceAll("\\","/"):"No File Changes"}`,Bn=115;process.stdout.isTTY&&(Bn=process.stdout.columns-5||120);let Yt=Math.min(Zn.length+4,Bn),ei=`${Zn.padEnd(Yt-2).substring(0,Yt-2)}`;yield{type:"visual_feedback",content:Lt(`${Be?`
742
+ `:""}${ei}`)},Be=!1;let Ro=Date.now();Yn=Ro,yield{type:"tool_time",content:Ro-A};let gn=(Y||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");gn.includes("[[VERIFIED]]")&&(gn=gn.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to conserve context.
743
+ `));let Un;if(l==="write_file"&&!gn.startsWith("ERROR:")){let Ke=gn.replace(/^\[\[SAME\]\]\s*\r?\n?/,""),it=Ke.match(/\n\s*(\[Note:\s*'~'\s*resolved\s*to\s*user\s*home\s*directory[\s\S]*?\])\s*$/),sn=it?`
740
744
 
741
- ${ot[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(Ke)){let Pt=Ke.search(/^- Content Preview:/m);Un=`[ACTION RESULT]: ${Pt!==-1?Ke.slice(0,Pt).trimEnd():Ke}
745
+ ${it[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(Ke)){let Pt=Ke.search(/^- Content Preview:/m);Un=`[ACTION RESULT]: ${Pt!==-1?Ke.slice(0,Pt).trimEnd():Ke}
742
746
 
743
747
  [Old file content for reversal reference. Replaced with new write request]${sn}`}else{let Pt=Ke.split(/\r?\n/),Xt=Pt.filter(vn=>vn.startsWith("File ")||vn.trim().startsWith("- Stats:"));Un=`[ACTION RESULT]: ${Xt.length>0?Xt.join(`
744
748
  `):Pt.slice(0,2).join(`
745
- `)}${sn}`}}else if(gn.startsWith("[[SAME]]")){let ot=gn.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),sn=ot.filter(Xt=>Xt.startsWith("File ")||Xt.trim().startsWith("- Stats:"));Un=`[ACTION RESULT]: ${sn.length>0?sn.join(`
746
- `):ot.slice(0,2).join(`
747
- `)}`}else Un=`[ACTION RESULT]: ${gn}`;je.push({role:"user",text:Un}),Pn=!0,await $t("toolSuccess"),n.onToolResult&&n.onToolResult("success",a),yield{type:"tool_result",content:Y,aiContent:Un,toolName:a},Et++;continue}if(W==="deny"){let Ie=`Permission Denied: Prohibited ${a==="exec_command"?"Command":"file edit"}.`;if(_?Ie=`User denied reading ${B.basename(ce||".env")}`:q&&fe==="user"?Ie="User rejected file over-write. If needed AskUser how to proceed":fe==="user"?Ie="Permission Denied by User":fe==="settings"?Ie="Permission Denied by User Policy":fe==="network"?Ie="Permission Denied: Sandbox Network Access Disabled by User Policy.":fe==="prohibited"&&a==="exec_command"&&(Ie="Permission Denied: Prohibited Command in User Policy"),a==="view_file"){let xe=`\u2718 Read Denied: ${O(y.args,["path","targetPath","file"]).path?.replaceAll("\\","/")||".env"}`,ke=115;process.stdout.isTTY&&(ke=process.stdout.columns-5||120);let Le=Math.min(xe.length+4,ke),ve=`${xe.padEnd(Le-2).substring(0,Le-2)}`;yield{type:"visual_feedback",content:Lt(`${Fe?`
749
+ `)}${sn}`}}else if(gn.startsWith("[[SAME]]")){let it=gn.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),sn=it.filter(Xt=>Xt.startsWith("File ")||Xt.trim().startsWith("- Stats:"));Un=`[ACTION RESULT]: ${sn.length>0?sn.join(`
750
+ `):it.slice(0,2).join(`
751
+ `)}`}else Un=`[ACTION RESULT]: ${gn}`;je.push({role:"user",text:Un}),Pn=!0,await $t("toolSuccess"),n.onToolResult&&n.onToolResult("success",l),yield{type:"tool_result",content:Y,aiContent:Un,toolName:l},Et++;continue}if(W==="deny"){let Me=`Permission Denied: Prohibited ${l==="exec_command"?"Command":"file edit"}.`;if(_?Me=`User denied reading ${U.basename(ce||".env")}`:q&&ue==="user"?Me="User rejected file over-write. If needed AskUser how to proceed":ue==="user"?Me="Permission Denied by User":ue==="settings"?Me="Permission Denied by User Policy":ue==="network"?Me="Permission Denied: Sandbox Network Access Disabled by User Policy.":ue==="prohibited"&&l==="exec_command"&&(Me="Permission Denied: Prohibited Command in User Policy"),l==="view_file"){let xe=`\u2718 Read Denied: ${O(y.args,["path","targetPath","file"]).path?.replaceAll("\\","/")||".env"}`,ke=115;process.stdout.isTTY&&(ke=process.stdout.columns-5||120);let Oe=Math.min(xe.length+4,ke),ve=`${xe.padEnd(Oe-2).substring(0,Oe-2)}`;yield{type:"visual_feedback",content:Lt(`${Be?`
748
752
  `:""}${ve}
749
- `)},Fe=!1}else if(a==="write_file"||a==="update_file"){let ke=`\u2718 ${a==="write_file"?"Write Cancelled":"Edit Denied"}: ${O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]).path.replaceAll("\\","/")||"..."}`,Le=115;process.stdout.isTTY&&(Le=process.stdout.columns-5||120);let ve=Math.min(ke.length+4,Le),ze=`${ke.padEnd(ve-2).substring(0,ve-2)}`,qt=` ${" ".repeat(ve)} `;yield{type:"visual_feedback",content:Lt(`${Fe?`
753
+ `)},Be=!1}else if(l==="write_file"||l==="update_file"){let ke=`\u2718 ${l==="write_file"?"Write Cancelled":"Edit Denied"}: ${O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]).path.replaceAll("\\","/")||"..."}`,Oe=115;process.stdout.isTTY&&(Oe=process.stdout.columns-5||120);let ve=Math.min(ke.length+4,Oe),ze=`${ke.padEnd(ve-2).substring(0,ve-2)}`,qt=` ${" ".repeat(ve)} `;yield{type:"visual_feedback",content:Lt(`${Be?`
750
754
  `:""}${ze}
751
- `)},Fe=!1}a==="exec_command"&&(await new Promise(xe=>setTimeout(xe,50)),n.onExecChunk&&n.onExecChunk(`ERROR: ${Ie}`),await new Promise(xe=>setTimeout(xe,50)),n.onExecEnd&&n.onExecEnd()),je.push({role:"user",text:`[ACTION RESULT]: DENIED: ${Ie}`}),yield{type:"tool_result",content:`[ACTION RESULT]: DENIED: ${Ie}`},await $t("toolDenied"),n.onToolResult&&n.onToolResult("denied",a),Et++;continue}}}if(v){let c=115;process.stdout.isTTY&&(c=process.stdout.columns-5||120);let R=!1,_=Math.min(v.length+4,c),ce=`${v.padEnd(_-2).substring(0,_-2)}`;yield{type:"visual_feedback",content:Lt(`${Fe?`
755
+ `)},Be=!1}l==="exec_command"&&(await new Promise(xe=>setTimeout(xe,50)),n.onExecChunk&&n.onExecChunk(`ERROR: ${Me}`),await new Promise(xe=>setTimeout(xe,50)),n.onExecEnd&&n.onExecEnd()),je.push({role:"user",text:`[ACTION RESULT]: DENIED: ${Me}`}),yield{type:"tool_result",content:`[ACTION RESULT]: DENIED: ${Me}`},await $t("toolDenied"),n.onToolResult&&n.onToolResult("denied",l),Et++;continue}}}if(v){let c=115;process.stdout.isTTY&&(c=process.stdout.columns-5||120);let R=!1,_=Math.min(v.length+4,c),ce=`${v.padEnd(_-2).substring(0,_-2)}`;yield{type:"visual_feedback",content:Lt(`${Be?`
752
756
  `:""}${ce}${v.includes("\u2714")&&(v.includes("Created")||v.includes("Edited"))?"":`${R?"":`
753
- `}`}`)},Fe=!1}if(Yn>0){let c=Date.now()-Yn,R=Math.max(0,1e3-c);R>0&&await new Promise(_=>setTimeout(_,R))}let Ze={chatId:f,history:t,onChunk:c=>n.onExecChunk?n.onExecChunk(c):null,onAskUser:n.onAskUser,systemSettings:n.systemSettings,mode:l,isMultiModal:it(te),onVisualFeedback:n.onVisualFeedback,onSubagentUpdate:n.onSubagentUpdate,onTokenChunk:n.onTokenChunk,modelName:te,aiProvider:n.aiProvider,apiKey:n.apiKey,onUsage:n.onUsage};if(a==="write_file"||a==="update_file")try{let{path:c}=O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]);if(c){let R=B.resolve(process.cwd(),c),_=await to();_&&_.file_focused===R&&_.full_content&&(Ze.forcedContent=_.full_content)}}catch{}le.push(a);let se=await xs(a,y.args,Ze);if((a==="write_file"||a==="update_file")&&!se.startsWith("ERROR:")){let{path:c}=O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]);if(c){let{resolvedPath:R}=mn(c),_=B.resolve(process.cwd(),R);wr(_)}}process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07");let Mt=Date.now();Yn=Mt,yield{type:"tool_time",content:Mt-A},qn=Mt;let Nn=null;if(typeof se=="object"&&se.binaryPart&&(Nn=se.binaryPart,se=se.text),a==="search_keyword"){let{keyword:c,path:R}=O(y.args,["keyword","path","fuzzy","subString","regex"]),_=typeof se=="string"&&se.startsWith("[GLOB]");_&&(se=se.slice(6).trimStart());let ce=typeof se=="string"&&se.startsWith("[DIR]");ce&&(se=se.slice(5).trimStart());let ye=0;if(se){let D=se.match(/Found (\d+) match/i);D&&(ye=parseInt(D[1]))}let oe=(R||"").trim().toLowerCase().replaceAll("\\","/"),ae=oe==="#doc"||oe==="#docs"||oe==="#documentation"||oe.includes("#skill/global/fluxflow")||oe.includes("#skill/fluxflow")||oe.includes("#skills/fluxflow")||oe.includes("#skills/global/fluxflow"),Re,Q=115;process.stdout.isTTY&&(Q=process.stdout.columns-5||120);let q=Math.max(10,(Q+5)/3),W=Math.max(10,(Q+5)/4);if(ae)Re=`${c?"\u2714":"\u2718"} Searched Documentation`;else{let D=R?R.replace(/[\/\\]+$/,""):null,Rt=D&&D!=="."?`${_?R:ce?`${D}/*`:D}`:"./",vt=Rt.length>W?`${Rt.slice(0,W)}...`:Rt;Re=`${c?"\u2714":"\u2718"} Searched: "${c?c.length>Q/3?`${c.slice(0,q)}...`:c:""}" in "${vt.replaceAll("\\","/")}" \u2192 ${ye} Match${ye===1?"":"es"}`}let fe=Math.min(Re.length+4,Q),Ge=`${Re.padEnd(fe-2).substring(0,fe-2)}`;yield{type:"visual_feedback",content:Lt(`${Fe?`
757
+ `}`}`)},Be=!1}if(Yn>0){let c=Date.now()-Yn,R=Math.max(0,1e3-c);R>0&&await new Promise(_=>setTimeout(_,R))}let Ze={chatId:f,history:t,onChunk:c=>n.onExecChunk?n.onExecChunk(c):null,onAskUser:n.onAskUser,systemSettings:n.systemSettings,mode:a,isMultiModal:et(J),onVisualFeedback:n.onVisualFeedback,onSubagentUpdate:n.onSubagentUpdate,onTokenChunk:n.onTokenChunk,modelName:J,aiProvider:n.aiProvider,apiKey:n.apiKey,onUsage:n.onUsage};if(l==="write_file"||l==="update_file")try{let{path:c}=O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]);if(c){let R=U.resolve(process.cwd(),c),_=await to();_&&_.file_focused===R&&_.full_content&&(Ze.forcedContent=_.full_content)}}catch{}le.push(l);let se=await xs(l,y.args,Ze);if((l==="write_file"||l==="update_file")&&!se.startsWith("ERROR:")){let{path:c}=O(y.args,["path","content","searchContent*","replaceContent*","newContent*","allowMultiple"]);if(c){let{resolvedPath:R}=mn(c),_=U.resolve(process.cwd(),R);wr(_)}}process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07");let Mt=Date.now();Yn=Mt,yield{type:"tool_time",content:Mt-A},qn=Mt;let Nn=null;if(typeof se=="object"&&se.binaryPart&&(Nn=se.binaryPart,se=se.text),l==="search_keyword"){let{keyword:c,path:R}=O(y.args,["keyword","path","fuzzy","subString","regex"]),_=typeof se=="string"&&se.startsWith("[GLOB]");_&&(se=se.slice(6).trimStart());let ce=typeof se=="string"&&se.startsWith("[DIR]");ce&&(se=se.slice(5).trimStart());let ye=0;if(se){let D=se.match(/Found (\d+) match/i);D&&(ye=parseInt(D[1]))}let oe=(R||"").trim().toLowerCase().replaceAll("\\","/"),ae=oe==="#doc"||oe==="#docs"||oe==="#documentation"||oe.includes("#skill/global/fluxflow")||oe.includes("#skill/fluxflow")||oe.includes("#skills/fluxflow")||oe.includes("#skills/global/fluxflow"),Re,ee=115;process.stdout.isTTY&&(ee=process.stdout.columns-5||120);let q=Math.max(10,(ee+5)/3),W=Math.max(10,(ee+5)/4);if(ae)Re=`${c?"\u2714":"\u2718"} Searched Documentation`;else{let D=R?R.replace(/[\/\\]+$/,""):null,Rt=D&&D!=="."?`${_?R:ce?`${D}/*`:D}`:"./",vt=Rt.length>W?`${Rt.slice(0,W)}...`:Rt;Re=`${c?"\u2714":"\u2718"} Searched: "${c?c.length>ee/3?`${c.slice(0,q)}...`:c:""}" in "${vt.replaceAll("\\","/")}" \u2192 ${ye} Match${ye===1?"":"es"}`}let ue=Math.min(Re.length+4,ee),Ge=`${Re.padEnd(ue-2).substring(0,ue-2)}`;yield{type:"visual_feedback",content:Lt(`${Be?`
754
758
  `:""}${Ge}
755
- `)},Fe=!1}if(a==="EmergencyRollback"){let{method:c}=O(y.args,["method","id"]);if(c==="forceRevert"){let R=0;if(se){let Q=se.match(/Total\s*:\s*(\d+)/i);Q&&(R=parseInt(Q[1]))}let ce=se&&se.startsWith("ERROR:")?"\u2718 Emergency Rollback Failed":`\u2714 Emergency Rollback \u2192 ${R} file${R===1?"":"s"} processed`,ye=115;process.stdout.isTTY&&(ye=process.stdout.columns-5||120);let oe=!1,ae=Math.min(ce.length+4,ye),Re=`${ce.padEnd(ae-2).substring(0,ae-2)}`;yield{type:"visual_feedback",content:Lt(`${Fe?`
759
+ `)},Be=!1}if(l==="EmergencyRollback"){let{method:c}=O(y.args,["method","id"]);if(c==="forceRevert"){let R=0;if(se){let ee=se.match(/Total\s*:\s*(\d+)/i);ee&&(R=parseInt(ee[1]))}let ce=se&&se.startsWith("ERROR:")?"\u2718 Emergency Rollback Failed":`\u2714 Emergency Rollback \u2192 ${R} file${R===1?"":"s"} processed`,ye=115;process.stdout.isTTY&&(ye=process.stdout.columns-5||120);let oe=!1,ae=Math.min(ce.length+4,ye),Re=`${ce.padEnd(ae-2).substring(0,ae-2)}`;yield{type:"visual_feedback",content:Lt(`${Be?`
756
760
  `:""}${Re}${oe?"":`
757
- `}`)},Fe=!1}}if(a==="todo"){let{method:c,tasks:R,markDone:_}=O(y.args,["method","tasks","markDone"]),ce="",ye=[],oe=ae=>{if(!ae)return[];let Re=Array.isArray(ae)?ae:[];if(Re.length===0&&typeof ae=="string"){let Q=ae.trim();if(Q.startsWith("[")&&Q.endsWith("]")){let q=Q.match(/"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'/g);q?Re=q.map(W=>W.slice(1,-1).replace(/\\(.)/g,"$1")):Re=Q.slice(1,-1).split(",").map(W=>W.trim()).filter(Boolean)}else Re=ae.split(`
758
- `)}return Re.filter(Q=>String(Q).trim()).map(Q=>{let q=String(Q).trim();return q.startsWith("- [")?q.substring(6).trim():q})};if(c==="create"?(ce="\x1B[32m\u2192\x1B[0m Created Goals",ye=oe(R).map(ae=>`\x1B[90m\u25CB\x1B[0m ${ae}`)):c==="append"?(ce="\x1B[34m\u2795\x1B[0m Added New Goals",ye=oe(R).map(ae=>`\x1B[90m\u25CB\x1B[0m ${ae}`)):c==="get"&&(ce=_?"\x1B[36m\u21BB\x1B[0m Updated Goals":"\x1B[35m\u2022\x1B[0m Reviewed Goals",ye=(se||"").split(`
761
+ `}`)},Be=!1}}if(l==="todo"){let{method:c,tasks:R,markDone:_}=O(y.args,["method","tasks","markDone"]),ce="",ye=[],oe=ae=>{if(!ae)return[];let Re=Array.isArray(ae)?ae:[];if(Re.length===0&&typeof ae=="string"){let ee=ae.trim();if(ee.startsWith("[")&&ee.endsWith("]")){let q=ee.match(/"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'/g);q?Re=q.map(W=>W.slice(1,-1).replace(/\\(.)/g,"$1")):Re=ee.slice(1,-1).split(",").map(W=>W.trim()).filter(Boolean)}else Re=ae.split(`
762
+ `)}return Re.filter(ee=>String(ee).trim()).map(ee=>{let q=String(ee).trim();return q.startsWith("- [")?q.substring(6).trim():q})};if(c==="create"?(ce="\x1B[32m\u2192\x1B[0m Created Goals",ye=oe(R).map(ae=>`\x1B[90m\u25CB\x1B[0m ${ae}`)):c==="append"?(ce="\x1B[34m\u2795\x1B[0m Added New Goals",ye=oe(R).map(ae=>`\x1B[90m\u25CB\x1B[0m ${ae}`)):c==="get"&&(ce=_?"\x1B[36m\u21BB\x1B[0m Updated Goals":"\x1B[35m\u2022\x1B[0m Reviewed Goals",ye=(se||"").split(`
759
763
  `).slice(1).join(`
760
764
  `).split(`
761
- `).filter(Re=>Re.trim().startsWith("- [")).map(Re=>{let Q=Re.trim(),q=Q.startsWith("- [x]");return`${q?"\x1B[32m\u2714\x1B[0m":"\x1B[90m\u25CB\x1B[0m"} ${q?"\x1B[90m":"\x1B[37m"}${Q.substring(6).trim()}\x1B[0m`})),ce&&ye.length>0){let ae=[`${ce}`,...ye.map(Q=>` ${Q}`)].join(`
762
- `);yield{type:"visual_feedback",content:Lt(`${Fe?`
765
+ `).filter(Re=>Re.trim().startsWith("- [")).map(Re=>{let ee=Re.trim(),q=ee.startsWith("- [x]");return`${q?"\x1B[32m\u2714\x1B[0m":"\x1B[90m\u25CB\x1B[0m"} ${q?"\x1B[90m":"\x1B[37m"}${ee.substring(6).trim()}\x1B[0m`})),ce&&ye.length>0){let ae=[`${ce}`,...ye.map(ee=>` ${ee}`)].join(`
766
+ `);yield{type:"visual_feedback",content:Lt(`${Be?`
763
767
  `:""}${ae}${!1?"":`
764
- `}`)},Fe=!1}}a==="exec_command"&&n.onExecEnd&&(await new Promise(c=>setTimeout(c,800)),n.onExecEnd());let on=se&&se.startsWith("DENIED:");se&&!se.startsWith("ERROR:")&&!on?(await $t("toolSuccess"),n.onToolResult&&n.onToolResult("success",a)):on||(await $t("toolFailure"),n.onToolResult&&n.onToolResult("failure",a));let re=(se||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");re.includes("[[VERIFIED]]")&&(re=re.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to save tokens.
765
- `));let at;if(a==="write_file"&&!re.startsWith("ERROR:")){let c=re.replace(/^\[\[SAME\]\]\s*\r?\n?/,""),R=c.match(/\n\s*(\[Note:\s*'~'\s*resolved\s*to\s*user\s*home\s*directory[\s\S]*?\])\s*$/),_=R?`
768
+ `}`)},Be=!1}}l==="exec_command"&&n.onExecEnd&&(await new Promise(c=>setTimeout(c,800)),n.onExecEnd());let on=se&&se.startsWith("DENIED:");se&&!se.startsWith("ERROR:")&&!on?(await $t("toolSuccess"),n.onToolResult&&n.onToolResult("success",l)):on||(await $t("toolFailure"),n.onToolResult&&n.onToolResult("failure",l));let re=(se||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");re.includes("[[VERIFIED]]")&&(re=re.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to save tokens.
769
+ `));let at;if(l==="write_file"&&!re.startsWith("ERROR:")){let c=re.replace(/^\[\[SAME\]\]\s*\r?\n?/,""),R=c.match(/\n\s*(\[Note:\s*'~'\s*resolved\s*to\s*user\s*home\s*directory[\s\S]*?\])\s*$/),_=R?`
766
770
 
767
771
  ${R[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(c)){let ce=c.search(/^- Content Preview:/m);at=`[ACTION RESULT]: ${ce!==-1?c.slice(0,ce).trimEnd():c}
768
772
 
@@ -772,57 +776,57 @@ ${R[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(c)){let ce=c.search(/^-
772
776
  `):R.slice(0,2).join(`
773
777
  `)}`}else at=`[ACTION RESULT]: ${re}`;je.push({role:"user",text:at,binaryPart:Nn}),Pn=!0;let Fn=`[ACTION RESULT]: ${se.replaceAll(`[[VERIFIED]]
774
778
  `,"").replaceAll(`
775
- [[/VERIFIED]]`,"")||""}`;(a==="view_file"||a==="web_scrape"||a==="file_map"||a==="search_keyword"||a==="get_progress"||a==="getprogress")&&(Fn=`[ACTION RESULT]: ${v} (Context Locked for UI Clarity)`),yield{type:"tool_result",content:Fn,aiContent:at,binaryPart:Nn,toolName:a},a==="memory"&&!se.startsWith("ERROR:")&&(yield{type:"memory_updated"}),Et++}if(s==="Google"&&pt&&Date.now()-Qo>=150){yield*un();let y=ko(pt);for(let A of y)yield A;pt="",Qo=Date.now()}}u.usageMetadata&&(en=u.usageMetadata),en&&(yield{type:"liveTokens",content:en.totalTokenCount})}if(H&&(H=!1,Qe?pe+="</think_fluxflow>":(be+="</think_fluxflow>",s==="Google"?pt+="</think_fluxflow>":yield{type:"text",content:"</think_fluxflow>"})),Qe&&pe.length>0){let u=0,S=Math.min(bt.length,pe.length);for(let V=S;V>0;V--)if(bt.endsWith(pe.substring(0,V))){u=V;break}let T=pe.substring(u);if(T){let ie=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(bt)?T.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):T.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");if(ie)if(be+=ie,s==="Google")pt+=ie;else{yield*un();let M=ko(ie);for(let z of M)yield z}}Qe=!1,pe=""}if(An){let u=An,S=(ht==="tool"||ht==="action")&&(u.startsWith("[tool:")||u.startsWith("[action:"));An="",ao=!1,ht=null,Qn=!1,lo=!1,S||(s==="Google"?pt+=u:yield{type:"text",content:u})}if(yield*un(),xt)break;let To=(be||"").trim(),Oa=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(To.toLowerCase())||/\[\[END\]\]/i.test(To.toLowerCase()),Na=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(To.toLowerCase()),Da=je.length>0||Ut!==null,Ui=jt(To).trim(),Fa=/(\p{Emoji_Presentation}|\p{Extended_Pictographic})$/u.test(Ui),Ba=/([.!?"'*_`|\]\)”’~~]+|\s|`{3}|[\u200B-\u200D\uFEFF])$/u.test(Ui.trim()),Ua=/[.!?}"'`’“”]$|```$/s.test(Ui)||Ba||Fa;!Oa&&!Na&&!Da&&To.length>0,Se=!0,await $t("agent",s)}catch(X){if(xt){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
779
+ [[/VERIFIED]]`,"")||""}`;(l==="view_file"||l==="web_scrape"||l==="file_map"||l==="search_keyword"||l==="get_progress"||l==="getprogress")&&(Fn=`[ACTION RESULT]: ${v} (Context Locked for UI Clarity)`),yield{type:"tool_result",content:Fn,aiContent:at,binaryPart:Nn,toolName:l},l==="memory"&&!se.startsWith("ERROR:")&&(yield{type:"memory_updated"}),Et++}if(i==="Google"&&pt&&Date.now()-Qo>=150){yield*un();let y=ko(pt);for(let A of y)yield A;pt="",Qo=Date.now()}}u.usageMetadata&&(en=u.usageMetadata),en&&(yield{type:"liveTokens",content:en.totalTokenCount})}if(j&&(j=!1,Qe?pe+="</think_fluxflow>":(be+="</think_fluxflow>",i==="Google"?pt+="</think_fluxflow>":yield{type:"text",content:"</think_fluxflow>"})),Qe&&pe.length>0){let u=0,S=Math.min(bt.length,pe.length);for(let V=S;V>0;V--)if(bt.endsWith(pe.substring(0,V))){u=V;break}let T=pe.substring(u);if(T){let ie=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(bt)?T.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):T.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");if(ie)if(be+=ie,i==="Google")pt+=ie;else{yield*un();let P=ko(ie);for(let z of P)yield z}}Qe=!1,pe=""}if(An){let u=An,S=(ht==="tool"||ht==="action")&&(u.startsWith("[tool:")||u.startsWith("[action:"));An="",ao=!1,ht=null,Qn=!1,lo=!1,S||(i==="Google"?pt+=u:yield{type:"text",content:u})}if(yield*un(),xt)break;let To=(be||"").trim(),Oa=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(To.toLowerCase())||/\[\[END\]\]/i.test(To.toLowerCase()),Na=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(To.toLowerCase()),Da=je.length>0||Ut!==null,Ui=jt(To).trim(),Fa=/(\p{Emoji_Presentation}|\p{Extended_Pictographic})$/u.test(Ui),Ba=/([.!?"'*_`|\]\)”’~~]+|\s|`{3}|[\u200B-\u200D\uFEFF])$/u.test(Ui.trim()),Ua=/[.!?}"'`’“”]$|```$/s.test(Ui)||Ba||Fa;!Oa&&!Na&&!Da&&To.length>0,Se=!0,await $t("agent",i)}catch(Q){if(xt){yield{type:"status",content:"Request Cancelled"},yield{type:"text",content:`
776
780
 
777
- \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(String(X).includes("Incomplete JSON segment at the end")){H&&(H=!1,Qe?pe+="</think_fluxflow>":(be+="</think_fluxflow>",yield{type:"text",content:"</think_fluxflow>"})),Se=!0,await $t("agent",s);break}if(H&&(H=!1,Qe?pe+="</think_fluxflow>":be+="</think_fluxflow>"),Qe&&pe.length>0){let St=0,nt=Math.min(bt.length,pe.length);for(let Vt=nt;Vt>0;Vt--)if(bt.endsWith(pe.substring(0,Vt))){St=Vt;break}let mt=pe.substring(St);if(mt){let rt=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(bt)?mt.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):mt.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");rt&&(be+=rt)}Qe=!1,pe=""}let E=X instanceof Error?(()=>{try{return JSON.parse(JSON.parse(X.message).error.message).error.message}catch{return String(X)}})():String(X),gt=new Date().toLocaleString(),de=B.join(eo,"agent");we.existsSync(de)||we.mkdirSync(de,{recursive:!0}),we.appendFileSync(B.join(de,"error.log"),`ERROR [${gt}]: ${E}
781
+ \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(String(Q).includes("Incomplete JSON segment at the end")){j&&(j=!1,Qe?pe+="</think_fluxflow>":(be+="</think_fluxflow>",yield{type:"text",content:"</think_fluxflow>"})),Se=!0,await $t("agent",i);break}if(j&&(j=!1,Qe?pe+="</think_fluxflow>":be+="</think_fluxflow>"),Qe&&pe.length>0){let St=0,ot=Math.min(bt.length,pe.length);for(let Vt=ot;Vt>0;Vt--)if(bt.endsWith(pe.substring(0,Vt))){St=Vt;break}let mt=pe.substring(St);if(mt){let rt=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(bt)?mt.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):mt.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\])\s*/gi,"").replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,"");rt&&(be+=rt)}Qe=!1,pe=""}let E=Q instanceof Error?(()=>{try{return JSON.parse(JSON.parse(Q.message).error.message).error.message}catch{return String(Q)}})():String(Q),gt=new Date().toLocaleString(),fe=U.join(eo,"agent");we.existsSync(fe)||we.mkdirSync(fe,{recursive:!0}),we.appendFileSync(U.join(fe,"error.log"),`ERROR [${gt}]: ${E}
778
782
 
779
783
  ----------------------------------------------------------------------
780
784
 
781
- `);let We=X.status||X.statusCode||X.code,At=String(X).includes("replicas at capacity");if(!(We&&(We>=500&&We<600||We===408||We===429||At)||!We&&(/status[ :]+(5\d\d|408|429)/i.test(String(X))||/code[ :]+(5\d\d|408|429)/i.test(String(X))||/(500|503|408|429)/.test(String(X))))){if(Pe<fn-3)throw X;yield{type:"text",content:E},yield{type:"status",content:"Error Occured"}}if(be.trim().length>0||tt>1)if(tt<=fn){tt++;let St=Math.min(1e3*Math.pow(2,tt-1),24e3);if(be.trim().length>0){w.push({role:"agent",text:be});let nt=`[system]
785
+ `);let We=Q.status||Q.statusCode||Q.code,At=String(Q).includes("replicas at capacity");if(!(We&&(We>=500&&We<600||We===408||We===429||At)||!We&&(/status[ :]+(5\d\d|408|429)/i.test(String(Q))||/code[ :]+(5\d\d|408|429)/i.test(String(Q))||/(500|503|408|429)/.test(String(Q))))){if($e<fn-3)throw Q;yield{type:"text",content:E},yield{type:"status",content:"Error Occured"}}if(be.trim().length>0||nt>1)if(nt<=fn){nt++;let St=Math.min(1e3*Math.pow(2,nt-1),24e3);if(be.trim().length>0){w.push({role:"agent",text:be});let ot=`[system]
782
786
  - seamless continuation: resume immediately. pick up from last words with zero gap/disruption
783
787
  - no repetition: do not repeat any text already written
784
788
  - no re-think: do not restart or open <think_fluxflow> if reasoning already started. continue the thinking and close thinking block </think_fluxflow> before chat output
785
789
  - mid-tool safety: if cutoff was mid-tool call, restart that tool call from start
786
790
  - stealth: do not mention/apologize for cutoff [/system]`;je.length>0?je.forEach((mt,Vt)=>{Vt===je.length-1?w.push({...mt,text:`${mt.text}
787
791
 
788
- ${nt}`}):w.push(mt)}):w.push({role:"user",text:nt}),bt+=be}for(let nt=St/1e3;nt>0&&!xt;nt--)yield{type:"status",content:`Error Occured. Recovering Stream (${tt}/${fn}) [Retrying in ${nt.toFixed(0)}s]...`},await new Promise(mt=>setTimeout(mt,1e3));yield{type:"status",content:"Error Occured. Recovering Stream..."}}else throw new Error(`Stream collapsed too many times. (Failed to resolve ${fn} times)
789
- Error log can be found in \`/export logs\``);else{let nt=e.split("/").slice(e.endsWith("/free")?-2:-1).join("/");if(Pe<=fn){Pe++,tt=1,bt="";let mt=Math.min(1e3*Math.pow(2,Pe-1),32e3),Vt=.8+Math.random()*.4,rt=Math.round(mt*Vt);$n=!0,yield{type:"status",content:`Trying to reach ${nt} (${Pe}/${fn}) [Retrying in ${(rt/1e3).toFixed(0)}s]`};for(let $e=rt/1e3;$e>0&&!xt;$e--)yield{type:"status",content:`Trying to reach ${nt} (${Pe}/${fn}) [Retrying in ${$e.toFixed(0)}s]`},await new Promise(pt=>setTimeout(pt,1e3));yield{type:"status",content:`Trying to reach ${nt}`}}else throw new Error(`Model ${e} cannot be reached. (Failed ${fn} times)
790
- Error log can be found in \`/export logs\``)}}}if(en){let H=en.totalTokenCount||0,X=en.cachedContentTokenCount||0,E=(en.candidatesTokenCount||0)+(s==="Google"&&en.thoughtsTokenCount||0);await hn("tokens",H,s,te),X>0&&await hn("cachedTokens",X,s,te),E>0&&await hn("candidateTokens",E,s,te),Tt!==null&&Tt>0&&await hn("ttft",Tt,s,te),ci({provider:s,model:te,prompt:en.promptTokenCount||0,cached:X,output:E,reasoning:en.thoughtsTokenCount||0,ttft:Tt}),yield{type:"usage",content:en}}else Tt!==null&&Tt>0&&(await hn("ttft",Tt,s,te),ci({provider:s,model:te,prompt:0,cached:0,output:0,reasoning:0,ttft:Tt}));be=ba(be),Di.push(be);let Ll=jt(be),Bi=pa(be),_a=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(Bi.toLowerCase())||/\[\[END\]\]/i.test(Bi.toLowerCase())||!0,Ol=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(Bi.toLowerCase()),Nl=Et>0;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"};let Ia=Ml(be,/(\[\s*(turn\s*:)?\s*(continue|finish)\s*\]|\[\[END\]\])/gi,"").trim(),Ma=je.length>0||Kn(jt(be)).length>0,Jn=(_a||je.length===0)&&!Wt&&!Xn&&!Gt;if(Jn=je.length===0?Jn:!1,Jn=Ma&&_t||Jo?!1:Jn,be&&be.trim().endsWith('")]')&&je.length===0&&(Jn=!1),Jn){Us=!0;let H=Di.join(`
791
- `),X=jt(H).trim();yield{type:"interactive_turn_finished",data:{agentText:Ne,fullAgentTextRaw:H,history:[...w],needTitle:Ae}},w.length>0&&w[w.length-1].role==="agent"?w[w.length-1].text=X:w.push({role:"agent",text:X}),w.forEach(E=>{if(E.role==="user"&&E.text&&(E.text=E.text.replace(/\n\[COMPILE ERROR\][\s\S]*?\[\/ERROR\]/g,""),E.text=E.text.replaceAll(`
792
+ ${ot}`}):w.push(mt)}):w.push({role:"user",text:ot}),bt+=be}for(let ot=St/1e3;ot>0&&!xt;ot--)yield{type:"status",content:`Error Occured. Recovering Stream (${nt}/${fn}) [Retrying in ${ot.toFixed(0)}s]...`},await new Promise(mt=>setTimeout(mt,1e3));yield{type:"status",content:"Error Occured. Recovering Stream..."}}else throw new Error(`Stream collapsed too many times. (Failed to resolve ${fn} times)
793
+ Error log can be found in \`/export logs\``);else{let ot=e.split("/").slice(e.endsWith("/free")?-2:-1).join("/");if($e<=fn){$e++,nt=1,bt="";let mt=Math.min(1e3*Math.pow(2,$e-1),32e3),Vt=.8+Math.random()*.4,rt=Math.round(mt*Vt);$n=!0,yield{type:"status",content:`Trying to reach ${ot} (${$e}/${fn}) [Retrying in ${(rt/1e3).toFixed(0)}s]`};for(let _e=rt/1e3;_e>0&&!xt;_e--)yield{type:"status",content:`Trying to reach ${ot} (${$e}/${fn}) [Retrying in ${_e.toFixed(0)}s]`},await new Promise(pt=>setTimeout(pt,1e3));yield{type:"status",content:`Trying to reach ${ot}`}}else throw new Error(`Model ${e} cannot be reached. (Failed ${fn} times)
794
+ Error log can be found in \`/export logs\``)}}}if(en){let j=en.totalTokenCount||0,Q=en.cachedContentTokenCount||0,E=(en.candidatesTokenCount||0)+(i==="Google"&&en.thoughtsTokenCount||0);await hn("tokens",j,i,J),Q>0&&await hn("cachedTokens",Q,i,J),E>0&&await hn("candidateTokens",E,i,J),Tt!==null&&Tt>0&&await hn("ttft",Tt,i,J),ci({provider:i,model:J,prompt:en.promptTokenCount||0,cached:Q,output:E,reasoning:en.thoughtsTokenCount||0,ttft:Tt}),yield{type:"usage",content:en}}else Tt!==null&&Tt>0&&(await hn("ttft",Tt,i,J),ci({provider:i,model:J,prompt:0,cached:0,output:0,reasoning:0,ttft:Tt}));be=ba(be),Di.push(be);let Ll=jt(be),Bi=pa(be),_a=/\[\s*(turn\s*:)?\s*finish\s*\]/i.test(Bi.toLowerCase())||/\[\[END\]\]/i.test(Bi.toLowerCase())||!0,Ol=/\[\s*(turn\s*:)?\s*continue\s*\]/i.test(Bi.toLowerCase()),Nl=Et>0;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Performing dark ritual":"Thinking"};let Ia=Ml(be,/(\[\s*(turn\s*:)?\s*(continue|finish)\s*\]|\[\[END\]\])/gi,"").trim(),Ma=je.length>0||Kn(jt(be)).length>0,Jn=(_a||je.length===0)&&!Wt&&!Xn&&!Gt;if(Jn=je.length===0?Jn:!1,Jn=Ma&&_t||Jo?!1:Jn,be&&be.trim().endsWith('")]')&&je.length===0&&(Jn=!1),Jn){Us=!0;let j=Di.join(`
795
+ `),Q=jt(j).trim();yield{type:"interactive_turn_finished",data:{agentText:De,fullAgentTextRaw:j,history:[...w],needTitle:Ae}},w.length>0&&w[w.length-1].role==="agent"?w[w.length-1].text=Q:w.push({role:"agent",text:Q}),w.forEach(E=>{if(E.role==="user"&&E.text&&(E.text=E.text.replace(/\n\[COMPILE ERROR\][\s\S]*?\[\/ERROR\]/g,""),E.text=E.text.replaceAll(`
792
796
 
793
797
  [system] user question. resolve this specific query within '[ANSWER] ... [/ANSWER]' concisely, naturally [/system]
794
798
  `,"").replaceAll(`[system] user question. resolve this specific query within '[ANSWER] ... [/ANSWER]' concisely, naturally
795
799
  **strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow>** [/system]
796
800
  `,"").replaceAll(`[system] **strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow>** [/system]
797
- `,"").replaceAll(/\n\[system\] WARNING, Turn Limit Impending: Step \d+\/\d+\. Wrap up quickly\/prompt user to continue & use \[\[END\]\] quickly\. \[\/system\]/g,""),E.text=E.text.replaceAll(/\n\[system\] File Changes:\n(?:\* .+ \(created|modified|deleted\)\n)*\[\/system\]/g,""),(s==="Mistral"||s==="Google"&&e?.toLowerCase().startsWith("gemma"))&&(E.text.startsWith("[ACTION RESULT]")||E.text.startsWith("[TOOL RESULT]")))){let de=`
801
+ `,"").replaceAll(/\n\[system\] WARNING, Turn Limit Impending: Step \d+\/\d+\. Wrap up quickly\/prompt user to continue & use \[\[END\]\] quickly\. \[\/system\]/g,""),E.text=E.text.replaceAll(/\n\[system\] File Changes:\n(?:\* .+ \(created|modified|deleted\)\n)*\[\/system\]/g,""),(i==="Mistral"||i==="Google"&&e?.toLowerCase().startsWith("gemma"))&&(E.text.startsWith("[ACTION RESULT]")||E.text.startsWith("[TOOL RESULT]")))){let fe=`
798
802
  [system] Action result received. Analyze output and proceed with your turn [/system]`,We=`
799
- [system] Action result received. Analyze output and proceed with your turn. **strictly follow thinking policy. do not start a response without <think_fluxflow>...</think_fluxflow>** [/system]`;E.text=E.text.replaceAll(We,"").replaceAll(de,"").trim()}}),yield{type:"status",content:"[end]"}}if(Jn)break;let Pa=Ia.trim()||"*Working...*";if(w.push({role:"agent",text:Pa}),je.length>0||Pn){if(je.length>0){let H=je.map(rt=>rt.text).join(`
803
+ [system] Action result received. Analyze output and proceed with your turn. **strictly follow thinking policy. do not start a response without <think_fluxflow>...</think_fluxflow>** [/system]`;E.text=E.text.replaceAll(We,"").replaceAll(fe,"").trim()}}),yield{type:"status",content:"[end]"}}if(Jn)break;let Pa=Ia.trim()||"*Working...*";if(w.push({role:"agent",text:Pa}),je.length>0||Pn){if(je.length>0){let j=je.map(rt=>rt.text).join(`
800
804
 
801
- `),X=jt(be),E=Kn(X),gt=ma(X,E),de=Ii(gt),We=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,At=[],ge=[],St;for(;(St=We.exec(de))!==null;)ge.push({index:St.index,toolName:St[1]});for(let rt=0;rt<ge.length;rt++){let $e=ge[rt],pt=rt+1<ge.length?ge[rt+1].index:X.length;E.some(un=>un.fullMatch&&X.startsWith(un.fullMatch,$e.index))||At.push(X.substring($e.index,pt))}let nt=At.length,mt=je.length+nt;if(nt>0){let rt=At.join(`
802
- `),$e=ha(rt);H+=`
805
+ `),Q=jt(be),E=Kn(Q),gt=ma(Q,E),fe=Ii(gt),We=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,At=[],me=[],St;for(;(St=We.exec(fe))!==null;)me.push({index:St.index,toolName:St[1]});for(let rt=0;rt<me.length;rt++){let _e=me[rt],pt=rt+1<me.length?me[rt+1].index:Q.length;E.some(un=>un.fullMatch&&Q.startsWith(un.fullMatch,_e.index))||At.push(Q.substring(_e.index,pt))}let ot=At.length,mt=je.length+ot;if(ot>0){let rt=At.join(`
806
+ `),_e=ha(rt);j+=`
803
807
 
804
808
  [system] Only ${je.length} out of ${mt} attempted tool calls were executed.
805
- ${$e?`Parsing Issues Detected:
806
- ${$e}
807
- `:""}Verify proper structure compliance [action:ActionName(arg="value")] & try failed calls again [/system]`;for(let pt=0;pt<nt;pt++)await $t("toolFailure")}let Vt=je.find(rt=>rt.binaryPart)?.binaryPart||null;w.push({role:"user",text:H,binaryPart:Vt})}}else if(!xt){let H=be.replace(/(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\]|$)/i,""),X=Kn(H),E=ma(H,X),de=(Ii(E).match(/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi)||[]).length;if(Jo||_t&&de>0||de>0){let We=ha(H),At=We?`[system] Failed to execute ${de>0?de:1} action call${de>1?"s":""} due to syntax/structure issues:
808
- ${We} [/system]`:`[system] Failed to execute ${de>0?de:1} action${de>1?"s":""}. Verify proper structure compliance [action:ActionName(arg="value")] & try again [/system]`;w.push({role:"user",text:At}),await $t("toolFailure"),yield{type:"visual_feedback",content:`
809
+ ${_e?`Parsing Issues Detected:
810
+ ${_e}
811
+ `:""}Verify proper structure compliance [action:ActionName(arg="value")] & try failed calls again [/system]`;for(let pt=0;pt<ot;pt++)await $t("toolFailure")}let Vt=je.find(rt=>rt.binaryPart)?.binaryPart||null;w.push({role:"user",text:j,binaryPart:Vt})}}else if(!xt){let j=be.replace(/(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\]|$)/i,""),Q=Kn(j),E=ma(j,Q),fe=(Ii(E).match(/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi)||[]).length;if(Jo||_t&&fe>0||fe>0){let We=ha(j),At=We?`[system] Failed to execute ${fe>0?fe:1} action call${fe>1?"s":""} due to syntax/structure issues:
812
+ ${We} [/system]`:`[system] Failed to execute ${fe>0?fe:1} action${fe>1?"s":""}. Verify proper structure compliance [action:ActionName(arg="value")] & try again [/system]`;w.push({role:"user",text:At}),await $t("toolFailure"),yield{type:"visual_feedback",content:`
809
813
  ${Lt("\u2718 Model produced malformed tool call")}
810
814
  `}}else yield{type:"visual_feedback",content:`
811
815
  ${Lt("\u2718 Loop Detected")}
812
816
  `},w.push({role:"user",text:`[system] ${Xn&&!Wt?"Stuttering Detected by Internal System. Re-calibrate your response & proceed.":`${Wt?" Over Thinking":" Loop"} Detected by Internal System${Wt?" for current Effort Level":""}. ${Wt?"If you have planned the task, prioritize execution/output":"If you have finished your task provide a simple summary and end"}`} [/system]`});Wt=!1,Xn=!1,Gt=!1}p?.advanceRollback&&await Mo.recordTurnDelta(f,b+1,le),Fi=le.includes("recapture_screen"),Jo=Et>0||Pn}if(!Us&&!xt){let b="\u2726 Turn safety limit reached. Stopping execution.";yield{type:"text",content:`
813
817
 
814
818
  ${b}
815
- `};let ue=(Di.join(`
819
+ `};let ge=(Di.join(`
816
820
  `)+`
817
- ${b}`).trim();yield{type:"interactive_turn_finished",data:{agentText:Ne,fullAgentTextRaw:ue,history:[...w],needTitle:Ae}},yield{type:"status",content:"[end]"}}}catch(U){let w=U?.cause?` (Cause: ${U.cause?.message||String(U.cause)})`:"",he=(U instanceof Error?(()=>{try{return JSON.parse(JSON.parse(U.message).error.message).error.message}catch{return(U.message?`${U.message}${w}`:"")||String(U)}})():String(U)).replace(/^(Error:\s*)+/i,"");s==="Google"&&!/^[A-Z0-9_\-\s]+ ERROR:/i.test(he)&&(he=`GEMINI ERROR: ${he}`);let Kt=new Date().toLocaleString(),Qt=B.join(eo,"agent");yield{type:"text",content:`
821
+ ${b}`).trim();yield{type:"interactive_turn_finished",data:{agentText:De,fullAgentTextRaw:ge,history:[...w],needTitle:Ae}},yield{type:"status",content:"[end]"}}}catch(B){let w=B?.cause?` (Cause: ${B.cause?.message||String(B.cause)})`:"",he=(B instanceof Error?(()=>{try{return JSON.parse(JSON.parse(B.message).error.message).error.message}catch{return(B.message?`${B.message}${w}`:"")||String(B)}})():String(B)).replace(/^(Error:\s*)+/i,"");i==="Google"&&!/^[A-Z0-9_\-\s]+ ERROR:/i.test(he)&&(he=`GEMINI ERROR: ${he}`);let Kt=new Date().toLocaleString(),Qt=U.join(eo,"agent");yield{type:"text",content:`
818
822
 
819
823
  \u2726 CRITICAL ERROR: ${he.includes("fetch failed")?"Failed to Connect. Check your Internet Connection or Wait a moment":he}
820
- \u2800`},we.existsSync(Qt)||we.mkdirSync(Qt,{recursive:!0}),we.appendFileSync(B.join(Qt,"error.log"),`CRITICAL ERROR [${Kt}]: ${U}${U?.cause?`
821
- CAUSE: ${U.cause?.stack||U.cause}`:""}
824
+ \u2800`},we.existsSync(Qt)||we.mkdirSync(Qt,{recursive:!0}),we.appendFileSync(U.join(Qt,"error.log"),`CRITICAL ERROR [${Kt}]: ${B}${B?.cause?`
825
+ CAUSE: ${B.cause?.stack||B.cause}`:""}
822
826
 
823
827
  ----------------------------------------------------------------------
824
828
 
825
- `),typeof flushGoogleBuffer=="function"&&(yield*flushGoogleBuffer()),yield{type:"tool_result",content:`ERROR: [INTERNAL CRITICAL] ${he}`}}finally{et&&(clearInterval(et),et=null),typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),await di.commitTransaction(),p?.advanceRollback&&await Mo.cleanup(f),await to()}yield{type:"status",content:null}},rf=async(e,t,n=null,i=null,o=null,r=null,d=!1,l=null)=>{let m=await li(),f={...m,...t},h=typeof o=="number"&&o>0?o:50,p=(f?.systemSettings?.loopLimits||"Default").toLowerCase();if(p==="extended")h=Math.floor(h*3);else if(p==="env"){let Me=parseInt(process.env.FLUXFLOW_SUBAGENT_MAX_TURNS||process.env.SUBAGENT_MAX_TURNS||process.env.FLUXFLOW_MAX_LOOPS||process.env.MAX_LOOPS||"",10);Number.isFinite(Me)&&Me>0&&(h=Me)}o=h;let g=process.env.SUBAGENT_MODEL?process.env.SUBAGENT_MODEL.trim():null,s=process.env.SUBAGENT_PROVIDER?process.env.SUBAGENT_PROVIDER.trim():null,x=new Date,I=`${x.getFullYear()}-${x.toLocaleString("en-US",{month:"short"}).toUpperCase()}-${String(x.getDate()).padStart(2,"0")}, ${x.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).replace(":","-")}`,C=(Me=>{if(!Me)return null;let Z=Me.toLowerCase();return Z==="google"?"Google":Z==="deepseek"?"DeepSeek":Z==="openrouter"?"OpenRouter":Z==="nvidia"?"NVIDIA":Z==="mistral"?"Mistral":Z==="ollama"?"Ollama":Z==="inferx"?"InferX":Z==="sensenova"?"SenseNova":Z==="poolside"?"Poolside":Z==="9router"||Z==="9Router"?"9router":Z==="aihubmix"||Z==="aihub"?"AIHubMix":Z==="explabs"||Z==="experientiallabs"||Z==="experimentallabs"?"ExpLabs":Z==="tokenharbor"||Z==="token harbor"||Z==="token_harbor"||Z==="thk"?"TokenHarbor":Z==="infron"?"Infron":Z==="apinex"||Z==="apx"?"APInex":Z==="xkiro"||Z==="kiro"?"xKiro":Z==="coarena"||Z==="coarena_ai"?"CoArena":Z==="c_openai"||Z==="custom_openai"||Z==="custom (openai)"||Z==="custom"?"c_openai":null})(s),P=f?.systemSettings?.CustomSubAgent?f?.systemSettings?.SubAgentModel:null,F=f?.systemSettings?.CustomSubAgent?f?.systemSettings?.SubAgentProvider:null,G=null;if(P==="ENV"?(G=g,g&&C&&(f.aiProvider=C)):P&&P!=="Default"?(G=P,F&&(f.aiProvider=F)):g&&C&&(f.aiProvider=C),f.aiProvider){let Me=await zs(f.aiProvider);Me&&(f.apiKey=Me)}let $=Me=>{if(!Me||typeof Me!="string")return{allowed:!0};let Z=[/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 Ve of Z)if(Ve.test(Me))return{allowed:!1,reason:`Blocked potentially destructive or unsafe command pattern: "${Ve.source}"`};return{allowed:!0}},L=n||G||t?.modelName||t?.activeModel||m.activeModel,Ae=(process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux")==="Windows",Ne=Ae&&f?.systemSettings?.preferBash!==!1&&Js(),et="Run(command=string)",U=`Runs ${Ae?Ji()?"powershell":"windows CMD":"bash"} command`;Ne&&(et=`Run(command=string, ${Qs()||Ji()?"forcePowershell?=bool:false":"forceCwd?=bool:false"})`,U="Runs in git bash. Or force native shell");let w=`-- ACTIONS (path = relative to CWD, path separator: '/') --
829
+ `),typeof flushGoogleBuffer=="function"&&(yield*flushGoogleBuffer()),yield{type:"tool_result",content:`ERROR: [INTERNAL CRITICAL] ${he}`}}finally{tt&&(clearInterval(tt),tt=null),typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),await di.commitTransaction(),p?.advanceRollback&&await Mo.cleanup(f),await to()}yield{type:"status",content:null}},rf=async(e,t,n=null,s=null,o=null,r=null,d=!1,a=null)=>{let m=await li(),f={...m,...t},h=typeof o=="number"&&o>0?o:50,p=(f?.systemSettings?.loopLimits||"Default").toLowerCase();if(p==="extended")h=Math.floor(h*3);else if(p==="env"){let Pe=parseInt(process.env.FLUXFLOW_SUBAGENT_MAX_TURNS||process.env.SUBAGENT_MAX_TURNS||process.env.FLUXFLOW_MAX_LOOPS||process.env.MAX_LOOPS||"",10);Number.isFinite(Pe)&&Pe>0&&(h=Pe)}o=h;let g=process.env.SUBAGENT_MODEL?process.env.SUBAGENT_MODEL.trim():null,i=process.env.SUBAGENT_PROVIDER?process.env.SUBAGENT_PROVIDER.trim():null,x=new Date,I=`${x.getFullYear()}-${x.toLocaleString("en-US",{month:"short"}).toUpperCase()}-${String(x.getDate()).padStart(2,"0")}, ${x.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).replace(":","-")}`,C=(Pe=>{if(!Pe)return null;let X=Pe.toLowerCase();return X==="google"?"Google":X==="deepseek"?"DeepSeek":X==="openrouter"?"OpenRouter":X==="nvidia"?"NVIDIA":X==="mistral"?"Mistral":X==="ollama"?"Ollama":X==="inferx"?"InferX":X==="sensenova"?"SenseNova":X==="poolside"?"Poolside":X==="9router"||X==="9Router"?"9router":X==="aihubmix"||X==="aihub"?"AIHubMix":X==="explabs"||X==="experientiallabs"||X==="experimentallabs"?"ExpLabs":X==="tokenharbor"||X==="token harbor"||X==="token_harbor"||X==="thk"?"TokenHarbor":X==="infron"?"Infron":X==="numes"?"Numes":X==="apinex"||X==="apx"?"APInex":X==="xkiro"||X==="kiro"?"xKiro":X==="coarena"||X==="coarena_ai"?"CoArena":X==="c_openai"||X==="custom_openai"||X==="custom (openai)"||X==="custom"?"c_openai":null})(i),M=f?.systemSettings?.CustomSubAgent?f?.systemSettings?.SubAgentModel:null,F=f?.systemSettings?.CustomSubAgent?f?.systemSettings?.SubAgentProvider:null,G=null;if(M==="ENV"?(G=g,g&&C&&(f.aiProvider=C)):M&&M!=="Default"?(G=M,F&&(f.aiProvider=F)):g&&C&&(f.aiProvider=C),f.aiProvider){let Pe=await zs(f.aiProvider);Pe&&(f.apiKey=Pe)}let $=Pe=>{if(!Pe||typeof Pe!="string")return{allowed:!0};let X=[/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 Ve of X)if(Ve.test(Pe))return{allowed:!1,reason:`Blocked potentially destructive or unsafe command pattern: "${Ve.source}"`};return{allowed:!0}},L=n||G||t?.modelName||t?.activeModel||m.activeModel,Ae=(process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux")==="Windows",De=Ae&&f?.systemSettings?.preferBash!==!1&&Js(),tt="Run(command=string)",B=`Runs ${Ae?Ji()?"powershell":"windows CMD":"bash"} command`;De&&(tt=`Run(command=string, ${Qs()||Ji()?"forcePowershell?=bool:false":"forceCwd?=bool:false"})`,B="Runs in git bash. Or force native shell");let w=`-- ACTIONS (path = relative to CWD, path separator: '/') --
826
830
  In chat output the format \`[action:ActionName(arg1="value1")]\` in NEW line
827
831
  Rules:
828
832
  - Max 3 actions/turn
@@ -847,7 +851,7 @@ ${d?"- AskMain(question=string). Communicate with PARENT/MAIN AGENT. When clarif
847
851
  - ReadFile(path=string, startLine?=int, endLine?=int)
848
852
  - PatchFile(path=string, allowMultiple?=bool, searchContent1="string match OR ^LINE:start..end$", newContent1=string, ...MAX15). Small searchString. Line Anchors: ^LINE:...$ syntax, must for large blocks & escape sequences
849
853
  - WriteFile(path=string, content=string). Creates/Overwrites. File Exist? PatchFile > WriteFile
850
- - ${et}. ${U}. Destructive command \u2192 Ask user`.trim(),wn=`=== START SYSTEM PROMPT ===
854
+ - ${tt}. ${B}. Destructive command \u2192 Ask user`.trim(),wn=`=== START SYSTEM PROMPT ===
851
855
  Identity: FluxFlow subagent helping the main Agent
852
856
  CWD: ${process.cwd()}
853
857
 
@@ -859,22 +863,22 @@ Main focus: actions and task, not chatting
859
863
  On completion, provide a detailed summary in Tables/Markdown Format with file modified info. If any task failed report back in detail
860
864
 
861
865
  Current Time: ${I}
862
- === END SYSTEM PROMPT ===`,he=Array.isArray(l)&&l.length>0?l:[{role:"user",text:`Task: ${e}`}];Array.isArray(l)&&l.length>0&&he.push({role:"user",text:`Follow-up instruction: ${e}`});let Kt=0,Qt="";for(;Kt<o;){let Me=await qi("subagent",f);if(!Me.allowed)throw new Error(Me.reason||`Budget Exhausted for Provider (${f?.aiProvider||"Subagent"})`);if(xt){if(t?.taskId&&typeof Ht<"u"){let j=Ht.find(N=>N.id===t.taskId);j&&(j.status="cancelled")}throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}if(t?.taskId&&typeof Ht<"u"){let j=Ht.find(N=>N.id===t.taskId);if(j&&j.status==="cancelled")throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}let Z=he.map(j=>({role:j.role==="user"?"user":"model",parts:[{text:j.text}]}));r&&r(`[Subagent Turn ${Kt+1}]...`);let Ve=["Fast","Low","Medium","High"],ln=process.env.SUBAGENT_THINKING,In=Ve.includes(ln)?ln:"Low",bn=(await $l(f,L,Z,wn,In)).text||"",De=ba(jt(bn).trim());Qt=De,r&&r(`[Subagent Response]
863
- ${De}
864
- `),he.push({role:"agent",text:De});let wt=Kn(De);if(wt.length===0)break;let Ft=wt.filter(j=>j.toolName.toLowerCase()==="askmain"||j.toolName.toLowerCase()==="ask_main"),Sn=!1,cn="";for(let j of wt){if(xt){if(t?.taskId&&typeof Ht<"u"){let k=Ht.find(ee=>ee.id===t.taskId);k&&(k.status="cancelled")}throw new Error("Subagent task was cancelled.")}if(t?.taskId&&typeof Ht<"u"){let k=Ht.find(ee=>ee.id===t.taskId);if(k&&k.status==="cancelled")throw new Error("Subagent task was cancelled.")}let N=j.toolName.toLowerCase();if(N==="askuser"&&(N="ask"),N==="askmain"||N==="ask_main"){if(Sn)continue;Sn=!0;let k="";if(Ft.length===1?k=O(Ft[0].args).question||Ft[0].args:k=Ft.map((ee,Je)=>{let Ce=O(ee.args);return`Q${Je+1}: ${Ce.question||ee.args}`}).join(`
865
- `),t.onAskMain){r&&r(`[Executing Tool] AskMain("${k}")...`);let ee=await t.onAskMain(k);r&&r(`[Action Result]
866
- Answer from Main Agent: ${ee}
867
- `),cn+=`[ACTION RESULT for AskMain]: Answer from Main Agent: ${ee}
866
+ === END SYSTEM PROMPT ===`,he=Array.isArray(a)&&a.length>0?a:[{role:"user",text:`Task: ${e}`}];Array.isArray(a)&&a.length>0&&he.push({role:"user",text:`Follow-up instruction: ${e}`});let Kt=0,Qt="";for(;Kt<o;){let Pe=await qi("subagent",f);if(!Pe.allowed)throw new Error(Pe.reason||`Budget Exhausted for Provider (${f?.aiProvider||"Subagent"})`);if(xt){if(t?.taskId&&typeof Ht<"u"){let K=Ht.find(N=>N.id===t.taskId);K&&(K.status="cancelled")}throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}if(t?.taskId&&typeof Ht<"u"){let K=Ht.find(N=>N.id===t.taskId);if(K&&K.status==="cancelled")throw r&&r("[SUBAGENT CANCELLED] Subagent task was cancelled."),new Error("Subagent task was cancelled.")}let X=he.map(K=>({role:K.role==="user"?"user":"model",parts:[{text:K.text}]}));r&&r(`[Subagent Turn ${Kt+1}]...`);let Ve=["Fast","Low","Medium","High"],ln=process.env.SUBAGENT_THINKING,In=Ve.includes(ln)?ln:"Low",bn=(await $l(f,L,X,wn,In)).text||"",Fe=ba(jt(bn).trim());Qt=Fe,r&&r(`[Subagent Response]
867
+ ${Fe}
868
+ `),he.push({role:"agent",text:Fe});let wt=Kn(Fe);if(wt.length===0)break;let Ft=wt.filter(K=>K.toolName.toLowerCase()==="askmain"||K.toolName.toLowerCase()==="ask_main"),Sn=!1,cn="";for(let K of wt){if(xt){if(t?.taskId&&typeof Ht<"u"){let k=Ht.find(te=>te.id===t.taskId);k&&(k.status="cancelled")}throw new Error("Subagent task was cancelled.")}if(t?.taskId&&typeof Ht<"u"){let k=Ht.find(te=>te.id===t.taskId);if(k&&k.status==="cancelled")throw new Error("Subagent task was cancelled.")}let N=K.toolName.toLowerCase();if(N==="askuser"&&(N="ask"),N==="askmain"||N==="ask_main"){if(Sn)continue;Sn=!0;let k="";if(Ft.length===1?k=O(Ft[0].args).question||Ft[0].args:k=Ft.map((te,Je)=>{let Ce=O(te.args);return`Q${Je+1}: ${Ce.question||te.args}`}).join(`
869
+ `),t.onAskMain){r&&r(`[Executing Tool] AskMain("${k}")...`);let te=await t.onAskMain(k);r&&r(`[Action Result]
870
+ Answer from Main Agent: ${te}
871
+ `),cn+=`[ACTION RESULT for AskMain]: Answer from Main Agent: ${te}
868
872
 
869
873
  `,await $t("toolSuccess")}else cn+=`[ACTION RESULT for AskMain]: ERROR: Main agent communication channel not available.
870
874
 
871
- `;continue}if(!(i?i.some(k=>k.toLowerCase()===N):!0)){let k=`ERROR: Tool [${j.toolName}] is not in the allowed tools list for this subagent.`;r&&r(`[Blocked Tool Call] ${j.toolName} - not allowed
875
+ `;continue}if(!(s?s.some(k=>k.toLowerCase()===N):!0)){let k=`ERROR: Tool [${K.toolName}] is not in the allowed tools list for this subagent.`;r&&r(`[Blocked Tool Call] ${K.toolName} - not allowed
872
876
  `),cn+=`${k}
873
877
 
874
- `;continue}if(N==="exec_command"||N==="execcommand"||N==="run"){let k=O(j.args,["command","background","timeout"]).command||"",ee=$(k);if(!ee.allowed){let Je=`ERROR: [SECURITY RESTRICTION] Subagent execution blocked command: ${ee.reason}`;r&&r(`[Blocked Command] ${k} - ${ee.reason}
878
+ `;continue}if(N==="exec_command"||N==="execcommand"||N==="run"){let k=O(K.args,["command","background","timeout"]).command||"",te=$(k);if(!te.allowed){let Je=`ERROR: [SECURITY RESTRICTION] Subagent execution blocked command: ${te.reason}`;r&&r(`[Blocked Command] ${k} - ${te.reason}
875
879
  `),cn+=`${Je}
876
880
 
877
- `;continue}}let st="";if(N==="web_search"||N==="websearch")st=`\u2714 \x1B[95mSearched\x1B[0m: ${O(j.args,["query","limit","aiMode"]).query||""}`;else if(N==="web_scrape"||N==="webscrape")st=`\u2714 \x1B[95mScraped\x1B[0m: ${O(j.args,["url"]).url||""}`;else if(N==="search_keyword"||N==="searchkeyword"||N==="codesearch"||N==="code_search"){let k=O(j.args,["keyword","path","fuzzy","subString","regex"]),ee=k.keyword||"",Je=k.path||"";st=`${ee?"\u2714":"\u2718"} \x1B[95mSearched\x1B[0m: ${ee||"No Query"}${Je?` \u2192 ${Je.replaceAll("\\","/")}`:""}`}else if(N==="view_file"||N==="viewfile"||N==="readfile")st=`\u2714 \x1B[95mRead\x1B[0m: ${(O(j.args,["path","targetPath","file","StartLine","EndLine","start_line","end_line","startLine","endLine"]).path||"").replaceAll("\\","/")}`;else if(N==="find_file"||N==="findfile"){let k=O(j.args,["basename","name","path","file","query"]),ee=k.basename||k.name||k.path||k.file||k.query||"";st=`${ee?"\u2714":"\u2718"} \x1B[95mLocated\x1B[0m: ${ee||"No Query"}`}else if(N==="list_files"||N==="read_folder"||N==="readfolder"){let k=O(j.args,["path","recurse","include"]).path||null,ee=O(j.args,["path","recurse","include"]).recurse||0;st=`${k?"\u2714":"\u2718"} \x1B[95mBrowsed\x1B[0m: ${k?`${k.replaceAll("\\","/")}${ee>0?`${k.endsWith("/")?`*${ee}`:`/*${ee}`}`:`${k.endsWith("/")?"":"/"}`}`:""}`}else if(N==="write_file"||N==="writefile"){let k=O(j.args,["path","content"]).path||null;st=`${k?"\u2714":"\u2718"} \x1B[95mCreated\x1B[0m: ${k?`${k.replaceAll("\\","/")}`:"No File Changes"}`}else if(N==="update_file"||N==="updatefile"||N==="patchfile"||N==="patch_file"){let k=O(j.args,["path","allowMultiple","content","searchContent*","replaceContent*","newContent*"]),ee=k.path||null,Ce=Object.entries(k).some(([lt,ft])=>lt.startsWith("searchContent")&&typeof ft=="string"&&ft.startsWith("^LINE:"))?"\u1361":":";st=`${ee?"\u2714":"\u2718"} \x1B[95mEdited\x1B[0m${Ce} ${ee?`${ee.replaceAll("\\","/")}`:"No File Changes"}`}else if(N==="exec_command"||N==="execcommand"||N==="run"){let k=O(j.args,["command","background","timeout"]).command||null;st=`${k?"\u2714":"\u2718"} \x1B[95mExecuted\x1B[0m: ${k?k.slice(0,100)+(k.length>100?"...":""):"No Command"}`}else if(N==="file_map"||N==="filemap"){let k=O(j.args,["path"]).path||"";st=`${k?"\u2714":"\u2718"} \x1B[95mIndexed\x1B[0m: ${k?`${k.replaceAll("\\","/")}`:"File Not Found"}`}else if(N==="await"){let{time:k}=O(j.args,["time","timeout","seconds","sec"]),ee=parseFloat(k)||0;ee<10&&(ee=10),ee>180&&(ee=180),st=`\u2714 \x1B[95mAwaiting\x1B[0m \u2192 ${(Ce=>{if(Ce>=60){let lt=Math.floor(Ce/60),ft=Ce%60;return`${lt}m${ft>0?` ${ft}s`:""}`}return`${Ce}s`})(ee)}`}else{let k=vs[N]||j.toolName,ee=oo(N,j.args);st=`\u2714 \x1B[95m${k}\x1B[0m${ee?`: ${ee}`:""}`}t.onVisualFeedback&&st&&t.onVisualFeedback(st),r&&r(`[Executing Tool] ${j.toolName}(${j.args})...`);try{let k=await xs(j.toolName,j.args,{...t,mode:"Flux"});r&&r(`[Action Result]
881
+ `;continue}}let st="";if(N==="web_search"||N==="websearch")st=`\u2714 \x1B[95mSearched\x1B[0m: ${O(K.args,["query","limit","aiMode"]).query||""}`;else if(N==="web_scrape"||N==="webscrape")st=`\u2714 \x1B[95mScraped\x1B[0m: ${O(K.args,["url"]).url||""}`;else if(N==="search_keyword"||N==="searchkeyword"||N==="codesearch"||N==="code_search"){let k=O(K.args,["keyword","path","fuzzy","subString","regex"]),te=k.keyword||"",Je=k.path||"";st=`${te?"\u2714":"\u2718"} \x1B[95mSearched\x1B[0m: ${te||"No Query"}${Je?` \u2192 ${Je.replaceAll("\\","/")}`:""}`}else if(N==="view_file"||N==="viewfile"||N==="readfile")st=`\u2714 \x1B[95mRead\x1B[0m: ${(O(K.args,["path","targetPath","file","StartLine","EndLine","start_line","end_line","startLine","endLine"]).path||"").replaceAll("\\","/")}`;else if(N==="find_file"||N==="findfile"){let k=O(K.args,["basename","name","path","file","query"]),te=k.basename||k.name||k.path||k.file||k.query||"";st=`${te?"\u2714":"\u2718"} \x1B[95mLocated\x1B[0m: ${te||"No Query"}`}else if(N==="list_files"||N==="read_folder"||N==="readfolder"){let k=O(K.args,["path","recurse","include"]).path||null,te=O(K.args,["path","recurse","include"]).recurse||0;st=`${k?"\u2714":"\u2718"} \x1B[95mBrowsed\x1B[0m: ${k?`${k.replaceAll("\\","/")}${te>0?`${k.endsWith("/")?`*${te}`:`/*${te}`}`:`${k.endsWith("/")?"":"/"}`}`:""}`}else if(N==="write_file"||N==="writefile"){let k=O(K.args,["path","content"]).path||null;st=`${k?"\u2714":"\u2718"} \x1B[95mCreated\x1B[0m: ${k?`${k.replaceAll("\\","/")}`:"No File Changes"}`}else if(N==="update_file"||N==="updatefile"||N==="patchfile"||N==="patch_file"){let k=O(K.args,["path","allowMultiple","content","searchContent*","replaceContent*","newContent*"]),te=k.path||null,Ce=Object.entries(k).some(([lt,ft])=>lt.startsWith("searchContent")&&typeof ft=="string"&&ft.startsWith("^LINE:"))?"\u1361":":";st=`${te?"\u2714":"\u2718"} \x1B[95mEdited\x1B[0m${Ce} ${te?`${te.replaceAll("\\","/")}`:"No File Changes"}`}else if(N==="exec_command"||N==="execcommand"||N==="run"){let k=O(K.args,["command","background","timeout"]).command||null;st=`${k?"\u2714":"\u2718"} \x1B[95mExecuted\x1B[0m: ${k?k.slice(0,100)+(k.length>100?"...":""):"No Command"}`}else if(N==="file_map"||N==="filemap"){let k=O(K.args,["path"]).path||"";st=`${k?"\u2714":"\u2718"} \x1B[95mIndexed\x1B[0m: ${k?`${k.replaceAll("\\","/")}`:"File Not Found"}`}else if(N==="await"){let{time:k}=O(K.args,["time","timeout","seconds","sec"]),te=parseFloat(k)||0;te<10&&(te=10),te>180&&(te=180),st=`\u2714 \x1B[95mAwaiting\x1B[0m \u2192 ${(Ce=>{if(Ce>=60){let lt=Math.floor(Ce/60),ft=Ce%60;return`${lt}m${ft>0?` ${ft}s`:""}`}return`${Ce}s`})(te)}`}else{let k=vs[N]||K.toolName,te=oo(N,K.args);st=`\u2714 \x1B[95m${k}\x1B[0m${te?`: ${te}`:""}`}t.onVisualFeedback&&st&&t.onVisualFeedback(st),r&&r(`[Executing Tool] ${K.toolName}(${K.args})...`);try{let k=await xs(K.toolName,K.args,{...t,mode:"Flux"});r&&r(`[Action Result]
878
882
  ${k}
879
883
  `);let Je=(k||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");Je.includes("[[VERIFIED]]")&&(Je=Je.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to save tokens.
880
884
  `));let Ce;if((N==="write_file"||N==="writefile")&&!Je.startsWith("ERROR:")){let lt=Je.replace(/^\[\[SAME\]\]\s*\r?\n?/,""),ft=lt.match(/\n\s*(\[Note:\s*'~'\s*resolved\s*to\s*user\s*home\s*directory[\s\S]*?\])\s*$/),Zt=ft?`
@@ -887,10 +891,10 @@ ${ft[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(lt)){let dn=lt.search(
887
891
  `):ft.slice(0,2).join(`
888
892
  `)}`}else Ce=`[ACTION RESULT]: ${Je}`;cn+=`${Ce}
889
893
 
890
- `,await $t("toolSuccess")}catch(k){let ee=`ERROR: Execution failed for [${j.toolName}]: ${k.message}`;r&&r(`[Tool Error] ${ee}
891
- `),cn+=`[ACTION RESULT]: ${ee}
894
+ `,await $t("toolSuccess")}catch(k){let te=`ERROR: Execution failed for [${K.toolName}]: ${k.message}`;r&&r(`[Tool Error] ${te}
895
+ `),cn+=`[ACTION RESULT]: ${te}
892
896
 
893
- `,await $t("toolFailure")}}let Mn="";if(t?.taskId&&typeof Ht<"u"){let j=Ht.find(N=>N.id===t.taskId);if(j&&j.pendingSteerMessages&&j.pendingSteerMessages.length>0){let N=[...j.pendingSteerMessages];j.pendingSteerMessages=[];for(let Vn of N)Mn+=`
897
+ `,await $t("toolFailure")}}let Mn="";if(t?.taskId&&typeof Ht<"u"){let K=Ht.find(N=>N.id===t.taskId);if(K&&K.pendingSteerMessages&&K.pendingSteerMessages.length>0){let N=[...K.pendingSteerMessages];K.pendingSteerMessages=[];for(let Vn of N)Mn+=`
894
898
 
895
- [STEERING INSTRUCTION FROM MAIN AGENT]: ${Vn}`,r&&r(`[Subagent Steered] ${Vn}`)}}let wo=(cn.trim()+Mn).trim();he.push({role:"user",text:wo}),Kt++}if(t?.onHistoryUpdate&&typeof t.onHistoryUpdate=="function"&&t.onHistoryUpdate(he),f?.systemSettings?.autoTruncateResults){for(let Me=0;Me<he.length;Me++){let Z=he[Me],Ve=Z.text||"";if(!(!Ve.startsWith("[ACTION RESULT]: ")&&!Ve.startsWith("[TOOL RESULT]: "))&&!(Ve.startsWith("[ACTION RESULT]: Goal")||Ve.includes("[ACTION RESULT]: ...Old result truncated")||Ve.includes("[ACTION RESULT]: Diff result ")||Ve.startsWith("[ACTION RESULT]: USER CHOOSE")||Ve.startsWith("[ACTION RESULT]: Skill:")||Ve.startsWith("[ACTION RESULT]: DOCs:")||Ve.startsWith("[ACTION RESULT]: Markdown parsed")||Ve.startsWith("[ACTION RESULT]: Search results for [")||Ve.startsWith("[ACTION RESULT]: AI Mode temporarily failed")||Ve.startsWith("[ACTION RESULT]: Background subagent started. Task ID:")||Ve.startsWith("[ACTION RESULT]: Subagent task")||/^\[ACTION RESULT\]: File \[.*?\] saved/s.test(Ve))){if(f?.systemSettings?.overwriteProtection!==!1){let ln=Ve.match(/^\[ACTION RESULT\]:\s*File\s*\[(.*?)\]\s*updated(?:\s+with\s+some\s+blocks\s+failed)?\.\s*(?:\[(\d+\/\d+)\]\s*blocks\s*applied\.)?([\s\S]*)$/);if(ln)try{let In=ln[1],io=ln[2]||"",bn=ln[3]||"",De=B.basename(In),wt=bn.replace("[DIFF_START]","");wt=wt.replace(/\[DIFF_END\](?=[^\[]*$)/,""),wt=wt.split(/\r?\n/).filter(Ce=>{let lt=Ce.trim();return lt.startsWith("-")||lt.startsWith("+")||lt.startsWith("@@")}).join(`
896
- `).trim();let Ft=0,Sn=0,cn=bn.matchAll(/@@\s*([^@]+?)\s*@@/g);for(let Ce of cn){let lt=Ce[1],ft=lt.match(/\+(\d+)/),Zt=lt.match(/-(\d+)/);ft&&(Ft+=parseInt(ft[1],10)),Zt&&(Sn+=parseInt(Zt[1],10))}let Mn=[];Ft>0&&Mn.push(`+${Ft}`),Sn>0&&Mn.push(`-${Sn}`);let wo=Mn.length>0?` Total ${Mn.join(" ")} changes.`:"",j=B.join(ii,"DiffBackups");we.existsSync(j)||we.mkdirSync(j,{recursive:!0});let N=String(Date.now()).slice(-5),Vn=wa.randomBytes(2).toString("hex"),st=`${De}-diff-${N}-${Vn}.txt`,k=B.join(j,st);we.writeFileSync(k,wt,"utf8");let ee=`${ii.replaceAll("\\","/").replace(xa.homedir().replaceAll("\\","/"),"~")}/DiffBackups/${st}`,Je=io?` ${io} blocks.`:"";he[Me]={...Z,text:`[ACTION RESULT]: Diff result ${De} saved in '${ee}'.${Je}${wo}`};continue}catch{}}he[Me]={...Z,text:"[ACTION RESULT]: ...Old result truncated to save tokens"}}}t?.onHistoryUpdate&&typeof t.onHistoryUpdate=="function"&&t.onHistoryUpdate(he)}return Qt};export{xo as a,Ri as b,td as c,nd as d,hr as e,Tc as f,Ac as g,yo as h,Cc as i,hi as j,yi as k,Wc as l,Gc as m,Al as n,Qd as o,Cl as p,Rl as q,Rs as r,jt as s,_i as t,ba as u,Zd as v,ef as w,tf as x,Sa as y,nf as z,Ii as A,ma as B,Il as C,Kn as D,of as E,$l as F,sf as G,rf as H};
899
+ [STEERING INSTRUCTION FROM MAIN AGENT]: ${Vn}`,r&&r(`[Subagent Steered] ${Vn}`)}}let wo=(cn.trim()+Mn).trim();he.push({role:"user",text:wo}),Kt++}if(t?.onHistoryUpdate&&typeof t.onHistoryUpdate=="function"&&t.onHistoryUpdate(he),f?.systemSettings?.autoTruncateResults){for(let Pe=0;Pe<he.length;Pe++){let X=he[Pe],Ve=X.text||"";if(!(!Ve.startsWith("[ACTION RESULT]: ")&&!Ve.startsWith("[TOOL RESULT]: "))&&!(Ve.startsWith("[ACTION RESULT]: Goal")||Ve.includes("[ACTION RESULT]: ...Old result truncated")||Ve.includes("[ACTION RESULT]: Diff result ")||Ve.startsWith("[ACTION RESULT]: USER CHOOSE")||Ve.startsWith("[ACTION RESULT]: Skill:")||Ve.startsWith("[ACTION RESULT]: DOCs:")||Ve.startsWith("[ACTION RESULT]: Markdown parsed")||Ve.startsWith("[ACTION RESULT]: Search results for [")||Ve.startsWith("[ACTION RESULT]: AI Mode temporarily failed")||Ve.startsWith("[ACTION RESULT]: Background subagent started. Task ID:")||Ve.startsWith("[ACTION RESULT]: Subagent task")||/^\[ACTION RESULT\]: File \[.*?\] saved/s.test(Ve))){if(f?.systemSettings?.overwriteProtection!==!1){let ln=Ve.match(/^\[ACTION RESULT\]:\s*File\s*\[(.*?)\]\s*updated(?:\s+with\s+some\s+blocks\s+failed)?\.\s*(?:\[(\d+\/\d+)\]\s*blocks\s*applied\.)?([\s\S]*)$/);if(ln)try{let In=ln[1],io=ln[2]||"",bn=ln[3]||"",Fe=U.basename(In),wt=bn.replace("[DIFF_START]","");wt=wt.replace(/\[DIFF_END\](?=[^\[]*$)/,""),wt=wt.split(/\r?\n/).filter(Ce=>{let lt=Ce.trim();return lt.startsWith("-")||lt.startsWith("+")||lt.startsWith("@@")}).join(`
900
+ `).trim();let Ft=0,Sn=0,cn=bn.matchAll(/@@\s*([^@]+?)\s*@@/g);for(let Ce of cn){let lt=Ce[1],ft=lt.match(/\+(\d+)/),Zt=lt.match(/-(\d+)/);ft&&(Ft+=parseInt(ft[1],10)),Zt&&(Sn+=parseInt(Zt[1],10))}let Mn=[];Ft>0&&Mn.push(`+${Ft}`),Sn>0&&Mn.push(`-${Sn}`);let wo=Mn.length>0?` Total ${Mn.join(" ")} changes.`:"",K=U.join(ii,"DiffBackups");we.existsSync(K)||we.mkdirSync(K,{recursive:!0});let N=String(Date.now()).slice(-5),Vn=wa.randomBytes(2).toString("hex"),st=`${Fe}-diff-${N}-${Vn}.txt`,k=U.join(K,st);we.writeFileSync(k,wt,"utf8");let te=`${ii.replaceAll("\\","/").replace(xa.homedir().replaceAll("\\","/"),"~")}/DiffBackups/${st}`,Je=io?` ${io} blocks.`:"";he[Pe]={...X,text:`[ACTION RESULT]: Diff result ${Fe} saved in '${te}'.${Je}${wo}`};continue}catch{}}he[Pe]={...X,text:"[ACTION RESULT]: ...Old result truncated to save tokens"}}}t?.onHistoryUpdate&&typeof t.onHistoryUpdate=="function"&&t.onHistoryUpdate(he)}return Qt};export{xo as a,Ri as b,td as c,nd as d,hr as e,Tc as f,Ac as g,yo as h,Cc as i,hi as j,yi as k,Wc as l,Gc as m,Al as n,Qd as o,Cl as p,Rl as q,Rs as r,jt as s,_i as t,ba as u,Zd as v,ef as w,tf as x,Sa as y,nf as z,Ii as A,ma as B,Il as C,Kn as D,of as E,$l as F,sf as G,rf as H};