fluxflow-cli 5.5.0 → 5.6.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 (69) hide show
  1. package/README.md +1 -0
  2. package/dist/chunks/{ai-6AZZQUJJ.js → ai-JYNVZQOI.js} +1 -1
  3. package/dist/chunks/{answerSubagent-LFLPQQSS.js → answerSubagent-PIZJSLZN.js} +1 -1
  4. package/dist/chunks/{apinex-COGJR7W4.js → apinex-BN3E62ML.js} +1 -1
  5. package/dist/chunks/{app-SKIGDYWL.js → app-NJIF4IBP.js} +168 -168
  6. package/dist/chunks/ask_user-XQ423UXL.js +1 -0
  7. package/dist/chunks/{auto_completion-ZYVGXNQC.js → auto_completion-D5GWZ3OL.js} +1 -1
  8. package/dist/chunks/{awaitSubagent-ZXLUWTW7.js → awaitSubagent-KLH7CRKF.js} +1 -1
  9. package/dist/chunks/{cancel-C2BQ3FGV.js → cancel-2PAHCMGB.js} +1 -1
  10. package/dist/chunks/{chat-34HLGFEJ.js → chat-YMCO5JNQ.js} +1 -1
  11. package/dist/chunks/chunk-3PZTWZTT.js +1 -0
  12. package/dist/chunks/chunk-3WV6FIZV.js +1 -0
  13. package/dist/chunks/{chunk-O74INBF3.js → chunk-4CWGKQHX.js} +1 -1
  14. package/dist/chunks/chunk-6LM3YRRE.js +4 -0
  15. package/dist/chunks/{chunk-YI3O7C3D.js → chunk-DWQSI6JO.js} +1 -1
  16. package/dist/chunks/{chunk-H2EXH5PL.js → chunk-F7Y2KAVQ.js} +196 -198
  17. package/dist/chunks/{chunk-ZPSNXBWW.js → chunk-KTD4WQBO.js} +1 -1
  18. package/dist/chunks/{chunk-5MJKHQVE.js → chunk-KYIMFUZS.js} +1 -1
  19. package/dist/chunks/{chunk-5KBOEKGE.js → chunk-LTNOPF2E.js} +2 -2
  20. package/dist/chunks/chunk-MS7BITZ6.js +1 -0
  21. package/dist/chunks/{chunk-3SMC2C3F.js → chunk-QN4UHB5C.js} +1 -1
  22. package/dist/chunks/{click-M5D2RARW.js → click-AJIULJEH.js} +2 -2
  23. package/dist/chunks/coarena-SGBBHWAP.js +2 -0
  24. package/dist/chunks/{computer_action-N7WIG3L4.js → computer_action-FZUWM6VL.js} +1 -1
  25. package/dist/chunks/{custom_openai-JUCNWDKV.js → custom_openai-MM5T6QBQ.js} +1 -1
  26. package/dist/chunks/{drag-K5ITERVW.js → drag-73WZE3BK.js} +1 -1
  27. package/dist/chunks/{emergency_rollback-X55BPJ7Q.js → emergency_rollback-PHH3BKRP.js} +1 -1
  28. package/dist/chunks/{exec_command-QBBSYF2H.js → exec_command-22LIHPPH.js} +1 -1
  29. package/dist/chunks/{file_map-3YMVODEE.js → file_map-4WUEPRMI.js} +1 -1
  30. package/dist/chunks/{find_file-RBJ4LKPD.js → find_file-LHPOW4ZM.js} +1 -1
  31. package/dist/chunks/{generate_image-53KQ3EDL.js → generate_image-KIZS5HAI.js} +1 -1
  32. package/dist/chunks/{getProgress-4D67AF3H.js → getProgress-MJZDAMSP.js} +1 -1
  33. package/dist/chunks/{infron-KCX7Z3RE.js → infron-4M36NBSA.js} +1 -1
  34. package/dist/chunks/{invoke-GUW4734N.js → invoke-CUYY3T4Z.js} +2 -2
  35. package/dist/chunks/{invokeSync-2PXPUJSJ.js → invokeSync-IZESPM6H.js} +2 -2
  36. package/dist/chunks/{key_press-RQ32VDHR.js → key_press-T5VHXHUL.js} +1 -1
  37. package/dist/chunks/{keyboard_typing-BH4JHUQO.js → keyboard_typing-5L2G5AHU.js} +1 -1
  38. package/dist/chunks/{ollama-BJHC4S6H.js → ollama-X7ARM2CC.js} +1 -1
  39. package/dist/chunks/{read_folder-OJ7UWWOR.js → read_folder-BJ3HS63A.js} +1 -1
  40. package/dist/chunks/recapture_screen-JVNQ2Z7L.js +1 -0
  41. package/dist/chunks/{screen_grid-Z5JHZZKA.js → screen_grid-PHZTVWOJ.js} +1 -1
  42. package/dist/chunks/{scroll-IQUZ3QLU.js → scroll-KE5TNGMD.js} +1 -1
  43. package/dist/chunks/{search_keyword-2JQ75HEQ.js → search_keyword-SSKH6AYF.js} +1 -1
  44. package/dist/chunks/{secrets-OHIQHB63.js → secrets-6RUMHIWR.js} +1 -1
  45. package/dist/chunks/{secrets_v2-W4225MDM.js → secrets_v2-5NIKKQXX.js} +1 -1
  46. package/dist/chunks/{settings-Y7ODX5TH.js → settings-UL5E3OYC.js} +1 -1
  47. package/dist/chunks/{steerSubagent-UNAOFQZJ.js → steerSubagent-B34P33YV.js} +1 -1
  48. package/dist/chunks/{todo-OX7SMIKN.js → todo-3EQZ7LZM.js} +1 -1
  49. package/dist/chunks/{tokenharbor-2TAFOMPU.js → tokenharbor-KKGRGQXG.js} +1 -1
  50. package/dist/chunks/{update_file-2EZILIMQ.js → update_file-RA745RVH.js} +1 -1
  51. package/dist/chunks/{usage-3CNTEZUA.js → usage-MKFPGZUK.js} +1 -1
  52. package/dist/chunks/{usageServer-7NPU35BP.js → usageServer-JFFFEUMY.js} +8 -2
  53. package/dist/chunks/view_file-LWURM2CE.js +1 -0
  54. package/dist/chunks/{wait-RQSCCCXW.js → wait-6WFCZDO7.js} +1 -1
  55. package/dist/chunks/{web_search-B2XM4T5D.js → web_search-XBV7AJF7.js} +1 -1
  56. package/dist/chunks/{write_docx-BMIF6ZDY.js → write_docx-54LANNV2.js} +1 -1
  57. package/dist/chunks/{write_file-O3LLIRLR.js → write_file-6KFLPINS.js} +1 -1
  58. package/dist/chunks/{write_pdf-CTBFENCU.js → write_pdf-UOCME2OY.js} +1 -1
  59. package/dist/chunks/{xkiro-GN4FCYYQ.js → xkiro-3R4IOLSP.js} +1 -1
  60. package/dist/cli.js +5 -5
  61. package/dist/package.json +1 -1
  62. package/package.json +1 -1
  63. package/dist/chunks/ask_user-4KTNP4MZ.js +0 -1
  64. package/dist/chunks/chunk-3HGLLXBK.js +0 -1
  65. package/dist/chunks/chunk-IWIVGFAT.js +0 -1
  66. package/dist/chunks/chunk-JWNCKRN6.js +0 -4
  67. package/dist/chunks/chunk-KQNW7DK5.js +0 -1
  68. package/dist/chunks/recapture_screen-YJNK64KL.js +0 -1
  69. package/dist/chunks/view_file-XYWGDYAY.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 jt}from"./chunk-56EJGQU3.js";import{a as tr}from"./chunk-O74INBF3.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-5KBOEKGE.js";import{a as di}from"./chunk-2RTYI6K3.js";import{a as L}from"./chunk-JWNCKRN6.js";import{b as zs}from"./chunk-3HGLLXBK.js";import{y as Vi}from"./chunk-IWIVGFAT.js";import{f as ci,l as $t,o as zi,p as xn,r as qi}from"./chunk-5MJKHQVE.js";import{b as li}from"./chunk-KQNW7DK5.js";import{l as at,m as ai}from"./chunk-Y6O7SAPD.js";import{c as yn,d as Ki,e as ri}from"./chunk-ZGORMZE5.js";import{a as Gn,b as oi,c as ii,d as to,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 hn}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 en from"fs";import Zt from"path";import Ya from"os";import wn from"fs";import Hn 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-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
2
2
 
3
3
  Launch command syntax:
4
4
  fluxflow [options]
@@ -168,7 +168,7 @@ Open in chat via /settings
168
168
  ### 7. Miscellaneous
169
169
  * Directory Tree Design \u2192 Modern (Saves Tokens) | Legacy (More Tokens, No extra benefit)
170
170
  * Compact Large Tool Results \u2192 Compress large tool outputs to save tokens (model might miss subtle indentation/syntax errors)
171
- * Context Length \u2192 Set usable context window size in FluxFlow. 16k, 32k, 64k, 128k, 256k, 512k, 1M. After Limit reached: Start new chat
171
+ * Context Length \u2192 Set usable context window size in FluxFlow. 16k, 32k, 64k, 128k, 256k (default), 512k, 1M. After Limit reached: Start new chat
172
172
  * Auto Truncate Results \u2192 Auto-truncate tool results after task finished to save token and improve caching
173
173
  * Image History for CU \u2192 Number of images to keep in context for Computer Use. Low / Standard / Extended
174
174
  * Keep Reasoning Content \u2192 Keeps the exact reasoning of model in context. More tokens. Might improve planning accuracy for few models
@@ -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
353
+ * Gemini | NVIDIA NIM | DeepSeek | Mistral | Ollama Local/Cloud | InferX | SenseNova | Poolside | OpenRouter | AIHubMix | Experiential Labs | TokenHarbor | APInex | Infron | Coarena
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
 
@@ -431,7 +431,7 @@ Instruction for this model ID across all providers.
431
431
  * Reference: Offload deep/contexual specs to **/{SKILL.md,skill-reference-folder/*.md} & reference in SKILL.md. Saves tokens
432
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":`---
433
433
  name: fluxflow
434
- description: System Generated Documentation. Read this if asked anything regarding FluxFlow Harness
434
+ description: System Generated Documentation. Read this if asked anything regarding FluxFlow Harness, model info
435
435
  ---
436
436
 
437
437
  # FluxFlow, by Kushal Roy Chowdhury
@@ -454,58 +454,56 @@ Public Docs: https://fluxflow-cli.onrender.com
454
454
  * Priority Instructions (AGENTS.md/FLUXFLOW.md) & Skill System \u2192 references/PLUGINS.md
455
455
  * Agent Architecture & Memory System \u2192 references/ARCHITECTURE.md
456
456
 
457
- Default Context Length: 256k Tokens. Can be changed via ENV/In-app Settings \u2192 references/{SETTINGS,ENV}.md
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-D5GWZ3OL.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(`
458
462
 
459
- 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=()=>{try{let e=Hn.join(Gn,"skills","fluxflow"),t=Hn.join(e,"references");if(process.env.NO_DEV==="true"||process.env.NO_DEV==="1"||process.env.NO_DEV===!0||process.env.NO_INS==="true"||process.env.NO_INS==="1"||process.env.NO_INS==="true"||!1){wn.existsSync(e)&&wn.rmSync(e,{recursive:!0,force:!0});return}let i=new Set(Object.keys(Zi).map(o=>Hn.normalize(o)));for(let[o,r]of Object.entries(Zi)){let d=Hn.join(e,o),l=Hn.dirname(d);wn.existsSync(l)||wn.mkdirSync(l,{recursive:!0});let g=r.trim()+`
460
- `,u=null;wn.existsSync(d)&&(u=wn.readFileSync(d,"utf8")),u!==g&&wn.writeFileSync(d,g,"utf8")}if(wn.existsSync(t)){let o=wn.readdirSync(t);for(let r of o){let d=Hn.normalize(Hn.join("references",r));if(!i.has(d)){let l=Hn.join(t,r);try{wn.rmSync(l,{recursive:!0,force:!0})}catch{}}}}}catch{}};import{WebSocket as gi}from"ws";var Dt=null,ho=!1,za="ws://localhost:56832",es=[],yo=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||ho)return;ho=!0;let e=new gi(za);e.on("open",()=>{for(Dt=e,ho=!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"&&yo?(yo(n.data),yo=null):n.command==="securityResponse"&&ts?ts(n.result):n.command==="inlineComplete"?qa(n):n.command==="connectionRejected"&&ns&&ns(n)}catch{}}),e.on("error",()=>{ho=!1,Dt=null}),e.on("close",()=>{ho=!1,Dt=null})},Po=e=>{Dt&&Dt.readyState===gi.OPEN?Dt.send(JSON.stringify(e)):(es.push(e),ho||xr())},xo=()=>Dt!==null&&Dt.readyState===gi.OPEN,qa=async e=>{let t="";try{let{generateAutoCompletion:n}=await import("./auto_completion-ZYVGXNQC.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})},no=()=>new Promise(e=>{if(!Dt||Dt.readyState!==gi.OPEN){e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]});return}yo=e,Dt.send(JSON.stringify({command:"requestContext"})),setTimeout(()=>{yo===e&&(e({cursor_line:0,selected:0,manual_edits:"",file_focused:"none",opened_editors:[]}),yo=null)},1e3)}),wr=e=>{let{resolvedPath:t}=hn(e);Po({command:"open",filePath:t})},is=(e,t,n)=>{let{resolvedPath:i}=hn(e);Po({command:"showDiff",filePath:i,originalContent:t,modifiedContent:n})},br=(e,t)=>{let{resolvedPath:n}=hn(e);Po({command:"closeDiff",filePath:n,result:t})};var Bo=(e,t)=>{try{if(!en.existsSync(e))return null;let n=Array.isArray(t)?t.map(o=>o.toLowerCase()):[t.toLowerCase()],i=en.readdirSync(e);for(let o of n){let r=i.find(d=>d.toLowerCase()===o);if(r){let d=Zt.join(e,r);if(en.statSync(d).isFile())return d}}}catch{}return null},cs=(e,t)=>{let n=Bo(e,t);if(n)try{return en.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(!en.existsSync(e))return i;let o=en.readdirSync(e,{withFileTypes:!0});for(let r of o){let d=r.name,l=Zt.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 g=d.toLowerCase();(g==="agents.md"||g==="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(`
461
- `)},vr=()=>Bo(Gn,["agents.md","agent.md"]),Er=()=>Bo(process.cwd(),["agents.md","agent.md"]),_r=()=>Bo(Gn,["fluxflow.md"]),Ir=()=>Bo(process.cwd(),["fluxflow.md"]),Lo=vr(),mi=Er(),bn=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(Gn,["agents.md","agent.md"]).trim():"";return e.length===0?(Lo=null,""):e},Qa=()=>{if(bn=ds(),mi=Er(),!bn||bn.length===0)return"";let e=process.cwd(),t=[...bn].sort((o,r)=>{let d=Zt.relative(e,o).replace(/\\/g,"/"),l=Zt.relative(e,r).replace(/\\/g,"/"),g=!d.includes("/"),u=!l.includes("/");return g&&!u?-1:!g&&u?1:d.localeCompare(l)}),n=[],i=[];for(let o of t)try{let r=en.readFileSync(o,"utf8").trim();if(!r||r.length===0)continue;n.push(o);let d=Zt.relative(e,o).replace(/\\/g,"/");if(!d.includes("/"))i.push(kr(r,2));else{let g=Zt.dirname(d)+"/:";i.push(`${g}
462
- ${kr(r,2)}`)}}catch{}return bn=n,bn.length===0&&(mi=null),i.join(`
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(`
463
464
 
464
- `).trim()},fs=()=>{Oo=_r();let e=Oo?cs(Gn,["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=Zt.posix.basename(o),d=i&&o?`${i}@${o}`:"",l=i&&r?`${i}@${r}`:"",g=h=>!h||!o?!1:h===o||h===r||h===d||h===l,u=[];return e.replace(/<start_provider_([^>\r\n]+)>([\s\S]*?)<end_provider_([^>\r\n]+)>/gi,(h,p,m,s)=>{if(i&&p.trim().toLowerCase()===s.trim().toLowerCase()&&p.trim().toLowerCase()===i){let I=m.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(Xe,R,O,F)=>{if(R.trim().toLowerCase()===F.trim().toLowerCase()){let W=R.trim().toLowerCase();if(g(W)){let P=O.trim();P&&u.push(P)}}return""}).trim();I&&u.push(I)}return""}),e.replace(/<start_model_([^>\r\n@]+@[^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n@]+@[^>\r\n]+)>/gi,(h,p,m,s)=>{if(p.trim().toLowerCase()===s.trim().toLowerCase()){let w=p.trim().toLowerCase();if(g(w)){let I=m.trim();I&&u.push(I)}}return""}),e.replace(/<start_model_([^>\r\n]+)>([\s\S]*?)<end_model_([^>\r\n]+)>/gi,(h,p,m,s)=>{if(p.includes("@"))return"";if(p.trim().toLowerCase()===s.trim().toLowerCase()){let w=p.trim().toLowerCase();if(o&&(w===o||w===r)){let I=m.trim();I&&u.push(I)}}return""}),u.join(`
465
-
466
- `).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||!en.existsSync(e))return t;let n=(i,o=0)=>{if(!(o>5))try{let r=en.readdirSync(i,{withFileTypes:!0});for(let d of r){let l=Zt.join(i,d.name),g=d.name.toLowerCase();d.isFile()?g==="skill.md"&&t.push(l):d.isDirectory()&&(o===0?(g==="skills"||g===".skills"||g==="skill"||g===".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=en.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(`
467
- `),hi=Pr(Gn),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?bn.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=Zt.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}),bn&&bn.length>0&&pi.length>0?bn.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
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
468
467
  \u2800\u2800\x1B[2m\u2514\u2500\x1B[22m No instruction or skill files are currently loaded.
469
468
  \u2800`;let o=[];return o.push(`\u2726 Loaded Files & Instructions (${i} ${i===1?"file":"files"} active)`),e.length>0&&(o.push(`
470
469
  \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(`
471
470
  \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(`
472
- `)},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=yn(si,[]);Array.isArray(n)&&n.length>0?$o=n.map(i=>`- ${i.memory}`).join(`
473
- `):$o=""}catch(n){$o="";try{en.mkdirSync(Zt.join(to,"memory"),{recursive:!0}),en.appendFileSync(Zt.join(to,"memory","error.txt"),`${n.message}
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(`
472
+ `):$o=""}catch(n){$o="";try{Jt.mkdirSync(an.join(eo,"memory"),{recursive:!0}),Jt.appendFileSync(an.join(eo,"memory","error.txt"),`${n.message}
474
473
  -------------------------------------------------
475
474
 
476
- `)}catch{}}}return $o};var Fr=(e,t,n,i,o=!0,r=!1,d="Google",l=!1,g,u,h=!1,p="")=>{let m=!1;process.env.forcedReasoning&&(m=!0);let s="";if(!g&&d==="Google"){let Pe=t;t==="Fast"&&(Pe="Off"),t==="Low"&&(Pe="Minimal"),t==="Standard"&&(Pe="Medium"),(t==="xHigh"||t==="Max")&&(Pe="xHigh"),s=fi[Pe]||fi.Medium}(g||d!=="Google")&&(s=fi.xHigh,t==="Fast"?s=`No thinking. Immediate response
477
- Verify imports, tool results & system stability`:t.toLowerCase()==="max"&&(s=null));let w=e.instructions&&e.instructions?.length>0?`User Preferences: ${e.instructions}
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}
478
477
 
479
478
  `:"",I=e.nickname&&e.nickname?.length>0?`User Nickname: ${e.nickname}
480
- ${w.length?"":`
479
+ ${x.length?"":`
481
480
  `}`:"",Xe=e.name&&e.name?.length>0?`User Name: ${e.name}
482
- ${I.length||w.length?"":`
483
- `}`:"",R=process.cwd(),O=e.preset,W={Sassy:"Sassy",Friendly:"Sassy, Warm & Chatty",Playful:"Playful",Efficient:"Quick, Concise & Efficient",Professional:"Professional"}[O]||null,P=nl(u,o),$=P?.length>0?`--- Saved Memories ---
484
- ${P}
481
+ ${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 ---
483
+ ${$}
485
484
 
486
- `:"";Za(d,p);let Te=Ar(Do,p,d).trim(),Ne=[gs,Te].filter(Pe=>Pe&&Pe.length>0).join(`
485
+ `:"";Za(d,p);let Te=Ar(Do,p,d).trim(),Ne=[gs,Te].filter(De=>De&&De.length>0).join(`
487
486
 
488
- `).trim(),et=Ar(Fo,p,d).trim(),x=[pi,et].filter(Pe=>Pe&&Pe.length>0).join(`
487
+ `).trim(),et=Ar(Fo,p,d).trim(),w=[pi,et].filter(De=>De&&De.length>0).join(`
489
488
 
490
- `).trim(),Sn=Ne.length>0||x.length>0?`--- Additional Instructions ---
489
+ `).trim(),wn=Ne.length>0||w.length>0?`--- Additional Instructions ---
491
490
  ${Ne.length>0?`-- Global --
492
- ${Ne}`:""}${x.length>0?`${Ne.length>0?`
491
+ ${Ne}`:""}${w.length>0?`${Ne.length>0?`
493
492
 
494
493
  `:""}-- Project --
495
- ${x}`:""}
494
+ ${w}`:""}
496
495
 
497
- `:"",pe=(()=>{let Pe=process.cwd().toLowerCase();if(process.platform==="win32"){let Bt=process.env.SystemRoot?.toLowerCase()||"c:\\windows",zt=process.env.ProgramFiles?.toLowerCase()||"c:\\program files",Vn=process.env["ProgramFiles(x86)"]?.toLowerCase()||"c:\\program files (x86)";return Pe.startsWith(Bt)||Pe.startsWith(zt)||Pe.startsWith(Vn)}else return Pe==="/"||["/bin","/sbin","/etc","/usr","/var","/root"].some(zt=>Pe.startsWith(zt))})(),Vt=new Date,tn=Vt.getFullYear(),Me=Vt.toLocaleString("en-US",{month:"short"}).toUpperCase(),ne=String(Vt.getDate()).padStart(2,"0"),Ve=`${tn}-${Me}-${ne}`,dn=process.env.I_HAVE_TOO_MUCH_MONEY==="true"||!1,_n=process.env.HALLOWEEN_EEGG==="true"||!1,so=_n&&Me.includes("OCT")&&(ne.includes("30")||ne.includes("31")),Kn=(p||"").replace(/^.*::/,"").split(":")[0].replace(/\/free$/,"").trim(),fn=Zt.basename(Kn).replace(/-free$/,"").replace(/_free$/,"").replace(/^free_/,"").replaceAll("-"," ").replaceAll("_"," ").replace(/\b\w/g,Pe=>Pe.toUpperCase().trim()),St=process.env.NO_DEV==="true"||!1,Ft=!1;try{Ft=xo()}catch{Ft=!1}return`${dn?`${" ".repeat(Math.floor(Math.random()*4)+1)}`:""}=== SYSTEM PROMPT${process.cwd()==="D:\\PROJECTS\\Flux-Flow"?" (Internal testing environment, do as prompted)":""} ===
498
- ${`Identity: ${ls.length>1?ls.trim():`Flux Flow.${W?` ${W}`:""} CLI Assistant${_n?`. ${so?"Peak ":""}Halloween Themed, Spooky`:""}`}
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)":""} ===
497
+ ${`Identity: ${ls.length>1?ls.trim():`FluxFlow.${G?` ${G}`:""} CLI Assistant${In?`. ${io?"Peak ":""}Halloween Themed, Spooky`:""}`}
499
498
  ${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")?`
500
499
  - 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()}
501
500
 
502
- - OS: ${Rr}${!St&&p.length>1?`
503
- - Model: ${fn}`.trimEnd():""}
501
+ - OS: ${Rr}
504
502
  - Date: ${Ve}
505
503
  ${t.toLowerCase()!=="max"&&process.env.rawReasoning!=="true"?`
506
504
  -- REASONING GUIDANCE --
507
- ${d==="Mistral"||d==="Google"&&!g||m?`${s.trimEnd()}
508
- ${m||t!=="Fast"&&(d==="Mistral"&&t==="Low"&&!g||t!=="High"&&!g)?`Critical Thinking Policy
505
+ ${d==="Mistral"||d==="Google"&&!m||g?`${s.trimEnd()}
506
+ ${g||t!=="Fast"&&(d==="Mistral"&&t==="Low"&&!m||t!=="High"&&!m)?`Critical Thinking Policy
509
507
  Use <think_fluxflow>...</think_fluxflow> for reasoning before responding any queries`:""}
510
508
  `:`${s.trimEnd()}`}
511
509
  `:""}${h?"":`${t.toLowerCase()==="max"||process.env.rawReasoning==="true"?`
@@ -515,75 +513,75 @@ Use <think_fluxflow>...</think_fluxflow> for reasoning before responding any que
515
513
  ${Zs(n,Rr,l,d,i?.advanceRollback,i?.subAgents!==!1,!!i?.autoExec,!!i?.disableTodo,i?.preferBash!==!1)}${n==="Flux"?"":n.toLowerCase().includes("cu")?`
516
514
 
517
515
  -- SECURITY POLICIES --
518
- - Dont operate on ANY confidential/logins/captcha screens \u2192 Tell user to complete it`:""}${Ft?`
516
+ - Dont operate on ANY confidential/logins/captcha screens \u2192 Tell user to complete it`:""}${bn?`
519
517
 
520
- Reference files as ./file:start..end`:""}
518
+ Reference files as file:start..end`:""}
521
519
  === END SYSTEM PROMPT ===${(ss.length>0||rs.length>0)&&n.toLowerCase().includes("flux")?`
522
520
 
523
521
  - Read relevant skills before tasks, scope: global/project: Use ReadFile, path="#skills/scope?/skillName". In-skill references: path="#skills/scope?/skillName/reference-folder/*.md"`:""}
524
522
 
525
- ${I}${w}${Sn}${ss.length>0&&n.toLowerCase().includes("flux")?`-- Global Skills --
523
+ ${I}${x}${wn}${ss.length>0&&n.toLowerCase().includes("flux")?`-- Global Skills --
526
524
  ${ss}
527
525
 
528
526
  `:""}${rs.length>0&&n.toLowerCase().includes("flux")?`-- Project Skills --
529
527
  ${rs}
530
528
 
531
- `:""}`.trim()};var Br=()=>import("./web_search-B2XM4T5D.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-34HLGFEJ.js").then(e=>e.chat),Hr=()=>import("./view_file-XYWGDYAY.js").then(e=>e.view_file),jr=()=>import("./write_file-O3LLIRLR.js").then(e=>e.write_file),Kr=()=>import("./update_file-2EZILIMQ.js").then(e=>e.update_file),Vr=()=>import("./exec_command-QBBSYF2H.js").then(e=>e.exec_command),zr=()=>import("./read_folder-OJ7UWWOR.js").then(e=>e.read_folder),ms=()=>import("./ask_user-4KTNP4MZ.js").then(e=>e.ask_user),qr=()=>import("./write_pdf-CTBFENCU.js").then(e=>e.write_pdf),Yr=()=>import("./write_docx-BMIF6ZDY.js").then(e=>e.write_docx),xi=()=>import("./search_keyword-2JQ75HEQ.js").then(e=>e.search_keyword),Xr=()=>import("./generate_image-53KQ3EDL.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-3YMVODEE.js").then(e=>e.file_map),bi=()=>import("./todo-OX7SMIKN.js").then(e=>e.todo),Qr=()=>import("./invokeSync-2PXPUJSJ.js").then(e=>e.invokeSync),ol=()=>import("./invoke-GUW4734N.js").then(e=>e.invoke),Zr=()=>import("./getProgress-4D67AF3H.js").then(e=>e.getProgress),il=()=>import("./cancel-C2BQ3FGV.js").then(e=>e.cancel),ea=()=>import("./emergency_rollback-X55BPJ7Q.js").then(e=>e.emergency_rollback),Wo=()=>import("./awaitSubagent-ZXLUWTW7.js").then(e=>e.awaitSubagent),Go=()=>import("./answerSubagent-LFLPQQSS.js").then(e=>e.answerSubagent),Si=()=>import("./steerSubagent-UNAOFQZJ.js").then(e=>e.steerSubagent),ki=()=>import("./computer_action-N7WIG3L4.js").then(e=>e.computer_action),ta=()=>import("./click-M5D2RARW.js").then(e=>e.click),na=()=>import("./drag-K5ITERVW.js").then(e=>e.drag),oa=()=>import("./scroll-IQUZ3QLU.js").then(e=>e.scroll),ps=()=>import("./keyboard_typing-BH4JHUQO.js").then(e=>e.keyboard_typing),hs=()=>import("./key_press-RQ32VDHR.js").then(e=>e.key_press),ys=()=>import("./recapture_screen-YJNK64KL.js").then(e=>e.recapture_screen),Ti=()=>import("./find_file-RBJ4LKPD.js").then(e=>e.find_file),ia=()=>import("./wait-RQSCCCXW.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",g=["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(!g)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 u=sa[e];if(!u){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"},m=o.replace(/[^a-z0-9]/g,""),s=p[m]||null;if(!s){let I=0,Xe=O=>{let F=new Set;for(let W=0;W<O.length-1;W++)F.add(O.slice(W,W+2));return F},R=Xe(m);for(let O of h){let F=O.toLowerCase().replace(/[^a-z0-9]/g,"");if(m===F){s=O;break}let W=0;(F.includes(m)||m.includes(F))&&(W+=.6);let P=Xe(F),$=0;for(let Ae of R)P.has(Ae)&&$++;let Te=2*$/(R.size+P.size||1);W=Math.max(W,Te),W>I&&W>=.35&&(I=W,s=O)}}let w=s?` Do you mean '${s}'?`:"";return`ERROR: Action [${e}] not found in registry.${w}`}try{return await(await u())(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 xe 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"]}],wo={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,wo[e]?t=wo[e]:e==="Halloween"?t=wo.Spookfest:e==="GitHub"?t=wo["GitHub Dark"]:e==="Transparent"?t=wo["Transparent Dark"]:t=wo.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 W=ri(oi,{})?.systemSettings?.customOpenAIBaseUrl;W&&(o=W)}catch{}let r=i.logoTextAnsi,d=i.logoBodyAnsi,l=i.logoMutedAnsi,g="\x1B[0m",u=[" \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,m=h&&p||process.env.SPOOKFEST==="true"&&h,s=u;if(m&&ws){process.env.HALLOWEEN_EEGG="true";let{halloweenArtSide:F,halloweenBat:W,halloweenArtUser:P}=ws;s=Math.random()>.9&&Ho===9&&jo>=30?W:Math.random()>.5?F:P}else process.env.HALLOWEEN_EEGG="false";let w=m?aa:ra,I=w[Math.floor(Math.random()*w.length)],Xe=i.logoGradient||["#0077ff","#ff00ff"],R=sl(Xe).multiline(s.join(`
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-IZESPM6H.js").then(e=>e.invokeSync),ol=()=>import("./invoke-CUYY3T4Z.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(`
532
530
  `)).split(`
533
- `),O=F=>`${l}${F}${g}`;return`${R[0]}
534
- ${R[1]} ${r}Selected ${m?"Pumpkin":"Provider"}: ${o}${g}
535
- ${R[2]}
536
- ${R[3]} ${r}FluxFlow${m?": Spookfest":""} ${O("v"+e)}${g}
537
- ${R[4]}
538
- ${R[5]} ${d}See /help for additional commands.${g}
539
- ${R[6]} ${O(I)}
540
- ${R[7]}
541
- `};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),g=n===1?new Set([..._o,...o,...Io(e),...Io(process.cwd())]):o instanceof Set?o:new Set([..._o,...o]),u=P=>g.has(P),h=d.filter(P=>!u(P.name)),p=d.filter(P=>u(P.name)).length,m=h.filter(P=>!P.isDirectory()).map(P=>P.name).sort(),s=h.filter(P=>P.isDirectory()).sort((P,$)=>P.name.localeCompare($.name)),w=P=>{let $=P.length;if($===0)return"no files";let Te=Array.from(new Set(P.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(", ")}}`),$===1?Ae:`${Ae} ${$} files`},I="";if(n===1){let P=m.join(", "),$=p>0?` [${p} ignored]`:"";(P||$)&&(I+=`${l}${P?P+($?`${$}`:""):$.trim()}
542
- `)}else m.length>0&&(I+=`${l}[${w(m)}]
543
- `);let Xe=10,R=s.slice(0,Xe),O=s.length>Xe,F=[],W=[];for(let P of R){let $=bs.join(e,P.name),Te=P.name,Ae=n,Ne=i($),et=Ne.filter(pe=>!u(pe.name)),G=et.filter(pe=>pe.isDirectory()),x=et.filter(pe=>!pe.isDirectory());for(;x.length===0&&G.length===1&&Ae<t;)Te=`${Te}/${G[0].name}`,$=bs.join($,G[0].name),Ae++,Ne=i($),et=Ne.filter(pe=>!u(pe.name)),G=et.filter(pe=>pe.isDirectory()),x=et.filter(pe=>!pe.isDirectory());let Sn=G.length>0;if(Sn&&Ae<t)W.push({displayName:Te,subDirPath:$,subEntries:Ne,nextDepth:Ae+1});else{let pe=w(x),Vt=Sn&&Ae>=t?" ...max scan depth":"";F.push(`${Te}/${pe}${Vt}`)}}F.length>0&&(I+=`${l}${F.join(", ")}
544
- `);for(let{displayName:P,subDirPath:$,subEntries:Te,nextDepth:Ae}of W)I+=`${l}${P}/
545
- `,I+=Ss($,t,Ae,i,g,Te);return O&&(I+=`${l}...max scan width, ReadFolder if needed
531
+ `),P=F=>`${l}${F}${m}`;return`${C[0]}
532
+ ${C[1]} ${r}Selected ${g?"Pumpkin":"Provider"}: ${o}${m}
533
+ ${C[2]}
534
+ ${C[3]} ${r}FluxFlow${g?": Spookfest":""} ${P("v"+e)}${m}
535
+ ${C[4]}
536
+ ${C[5]} ${d}See /help for additional commands.${m}
537
+ ${C[6]} ${P(I)}
538
+ ${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
546
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...
547
- `;let g="",u=r,h=d.filter(s=>!u.includes(s.name)&&!s.name.startsWith(".")),p=d.filter(s=>u.includes(s.name)||s.name.startsWith(".")).map(s=>s.name).sort();h.sort((s,w)=>s.isDirectory()&&!w.isDirectory()?-1:!s.isDirectory()&&w.isDirectory()?1:s.name.localeCompare(w.name));let m=[...h.map(s=>({name:s.name,isDir:s.isDirectory()})),...p.map(s=>({name:s,isDir:!0,isCollapsed:!0}))];return m.forEach((s,w)=>{let I=w===m.length-1,Xe=ks.join(e,s.name),R=I?"\u2514\u2500\u2500 ":"\u251C\u2500\u2500 ",O=n+(I?" ":"\u2502 ");if(s.isCollapsed){g+=`${n}${R}${s.name}${l}...
548
- `;return}s.isDir?i>t?g+=`${n}${R}${s.name}${l} ...depth exceeded...
549
- `:o(Xe).length>80?g+=`${n}${R}${s.name}${l} ...80+ files...
550
- `:(g+=`${n}${R}${s.name}${l}
551
- `,g+=Ts(Xe,t,O,i+1,o,r)):g+=`${n}${R}${s.name}
552
- `}),g};var gl={Ollama:()=>import("./ollama-BJHC4S6H.js").then(e=>e.getOllamaStream),OpenRouter:()=>import("./openrouter-WKGHI2OP.js").then(e=>e.getOpenRouterStream),DeepSeek:()=>import("./deepseek-5FL3MI6P.js").then(e=>e.getDeepSeekStream),Mistral:()=>import("./mistral-WTUJY4U7.js").then(e=>e.getMistralStream),NVIDIA:()=>import("./nvidia-I35DUUDV.js").then(e=>e.getNVIDIAStream),NVIDIA_wrap:()=>import("./nvidia-I35DUUDV.js").then(e=>e.wrapNvidiaStreamWithQueueDepth),InferX:()=>import("./inferx-5Q36576Q.js").then(e=>e.getInferXStream),SenseNova:()=>import("./sensenova-QE73BOHI.js").then(e=>e.getSenseNovaStream),AIHubMix:()=>import("./aihubmix-5XK2DFNJ.js").then(e=>e.getAIHubMixStream),Poolside:()=>import("./poolside-F6QS6ZMC.js").then(e=>e.getPoolsideStream),NineRouter:()=>import("./9router-XV5L5RWA.js").then(e=>e.getNineRouterStream),ExpLabs:()=>import("./explabs-WJXK6SEY.js").then(e=>e.getExpLabsStream),TokenHarbor:()=>import("./tokenharbor-2TAFOMPU.js").then(e=>e.getTokenHarborStream),Infron:()=>import("./infron-KCX7Z3RE.js").then(e=>e.getInfronStream),APInex:()=>import("./apinex-COGJR7W4.js").then(e=>e.getAPInexStream),xKiro:()=>import("./xkiro-GN4FCYYQ.js").then(e=>e.getXKiroStream),c_openai:()=>import("./custom_openai-JUCNWDKV.js").then(e=>e.getCustomOpenAIStream)},Cs={},we=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*\\?["']?([^\\"' \),]+)/,En=/["']/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:""}},Kt=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=jn(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?`
553
- `:"")},Es=null,Vo={},oo={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,g)=>`${r||""}${d}${l||""} ${i}${g}\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((g,u)=>{let h=setTimeout(g,l);o&&o.addEventListener("abort",()=>{clearTimeout(h),u(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 g=l.indexOf("**CONTEXT SUMMARY OF PREVIOUS TURNS");if(g!==-1){let h=l.substring(0,g).lastIndexOf("[SYSTEM METADATA]");h!==-1?l=l.substring(h).trim():l=l.substring(g).trim()}}else{let g=l.lastIndexOf("[USER]"),u=l.lastIndexOf("[USER PROMPT]");g!==-1?l=l.substring(g+6).trim():u!==-1&&(l=l.substring(u).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=[],g=!1,u=()=>{d.length>0&&(n.push({role:"agent",text:"combined"}),d=[]),l.length>0&&(n.push({role:"system",text:"combined"}),l=[]),g=!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:")),m=h.fullText||h.text||"",s=m.trim();if(!(!s&&!h.binaryPart)){if(p)l.push(s);else if(h.role==="agent"){!g&&l.length>0&&u();let w=m.endsWith(`
554
- `),I=s.toLowerCase().includes("tool:")||s.toLowerCase().includes("action:");d.push(s),I&&w?g=!0:g=!1}}}),u()}}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"},io=(e,t)=>{try{let n=L(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]!==`
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-WKGHI2OP.js").then(e=>e.getOpenRouterStream),DeepSeek:()=>import("./deepseek-5FL3MI6P.js").then(e=>e.getDeepSeekStream),Mistral:()=>import("./mistral-WTUJY4U7.js").then(e=>e.getMistralStream),NVIDIA:()=>import("./nvidia-I35DUUDV.js").then(e=>e.getNVIDIAStream),NVIDIA_wrap:()=>import("./nvidia-I35DUUDV.js").then(e=>e.wrapNvidiaStreamWithQueueDepth),InferX:()=>import("./inferx-5Q36576Q.js").then(e=>e.getInferXStream),SenseNova:()=>import("./sensenova-QE73BOHI.js").then(e=>e.getSenseNovaStream),AIHubMix:()=>import("./aihubmix-5XK2DFNJ.js").then(e=>e.getAIHubMixStream),Poolside:()=>import("./poolside-F6QS6ZMC.js").then(e=>e.getPoolsideStream),NineRouter:()=>import("./9router-XV5L5RWA.js").then(e=>e.getNineRouterStream),ExpLabs:()=>import("./explabs-WJXK6SEY.js").then(e=>e.getExpLabsStream),TokenHarbor:()=>import("./tokenharbor-KKGRGQXG.js").then(e=>e.getTokenHarborStream),Infron:()=>import("./infron-4M36NBSA.js").then(e=>e.getInfronStream),APInex:()=>import("./apinex-BN3E62ML.js").then(e=>e.getAPInexStream),xKiro:()=>import("./xkiro-3R4IOLSP.js").then(e=>e.getXKiroStream),CoArena:()=>import("./coarena-SGBBHWAP.js").then(e=>e.getCoArenaStream),c_openai:()=>import("./custom_openai-MM5T6QBQ.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]!==`
555
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]===`
556
- `||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||jn(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]!==`
557
- `&&i[d]!=="\r"&&(i[d]=" ");r+=o.fullMatch.length}}return i.join("")},Il=e=>{let t=Kt(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,g=!1;for(let u=o;u<n.length;u++){let h=n[u];if(!d&&(h==='"'||h==="'"||h==="`")?(d=h,l=!1):d&&h===d&&!l&&(d=null),!d&&(h==="("?r++:h===")"&&r--,r===0)){let p=u+1;for(;p<n.length&&/\s/.test(n[p]);)p++;if(p<n.length&&n[p]==="]"){g=!0,Ko.lastIndex=p+1;break}}h==="\\"?l=!l:l=!1}if(!g)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?Kt(d):d;let l=r.index+r[0].length-1,g=0,u=null,h=-1;for(let p=l;p<e.length;p++){let m=e[p];if(u){if(m===u){let s=0;for(let w=p-1;w>=0&&e[w]==="\\";w--)s++;s%2===0&&(u=null)}}else if(m==='"'||m==="'"||m==="`")u=m;else if(m==="(")g++;else if(m===")"&&(g--,g===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?Kt(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 g=d.index+d[0].length-1,u=0,h=null,p=-1;for(let m=g;m<e.length;m++){let s=e[m];if(h){if(s===h){let w=0;for(let I=m-1;I>=0&&e[I]==="\\";I--)w++;w%2===0&&(h=null)}}else if(s==='"'||s==="'"||s==="`")h=s;else if(s==="(")u++;else if(s===")"&&(u--,u===0)){let w=m+1;for(;w<e.length&&/\s/.test(e[w]);)w++;if(w<e.length&&e[w]==="]"){p=w;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(([m,s])=>{let w=typeof s=="string"?s:JSON.stringify(s);return`${m}=${JSON.stringify(w)}`}).join(", "))}catch{let p=[],m=vl;m.lastIndex=0;let s;for(;(s=m.exec(d))!==null;){let w=s[1],I=s[2]!==void 0?s[2]:s[0].split(":").slice(1).join(":").trim();p.push(`${w}=${JSON.stringify(I)}`)}p.length>0?l=p.join(", "):l=d.trim()}let g=r.toLowerCase().replace(/_/g,"");return`[tool:functions.${t[g]||n(r)}(${l})]`});return ua.lastIndex=0,ga.lastIndex=0,i=i.replace(ua,""),i=i.replace(ga,""),i},jn=e=>{if(!e)return[];let t=Pl(e),n=Kt(t),i=[],o=Ii(n),r=bl;r.lastIndex=0;let d;for(;(d=r.exec(o))!==null;){let l=d[1],g=d.index+d[0].length-1,u=0,h=null,p=-1,m=-1;for(let s=g;s<o.length;s++){let w=o[s];if(h){if(w===h){let I=0;for(let Xe=s-1;Xe>=0&&o[Xe]==="\\";Xe--)I++;I%2===0&&(h=null)}}else{if(s>g&&(o.substring(s).startsWith("[action:")||o.substring(s).startsWith("[tool:")))break;if(w==='"'||w==="'"||w==="`")h=w;else if(w==="(")u++;else if(w===")"&&(u--,u===0)){m=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(g+1,m),w=n.substring(d.index,p+1);i.push({fullMatch:w,toolName:l.trim(),args:s.trim()}),r.lastIndex=p+1}}return i},ha=e=>{if(!e)return null;let t=Kt(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 m=0;m<o.length;m++){let s=o[m],w=m+1<o.length?o[m+1].index:t.length,I=t.substring(s.index,w),Xe=I.indexOf("("),R=Xe!==-1?I.substring(Xe+1):"",O=0,F=null,W=!1;for(let P=0;P<R.length;P++){let $=R[P];if(F){if($===F){let Te=0;for(let Ae=P-1;Ae>=0&&R[Ae]==="\\";Ae--)Te++;Te%2===0&&(F=null)}}else if($==='"'||$==="'"||$==="`")F=$;else if($==="(")O++;else if($===")")if(O>0)O--;else{let Te=P+1;for(;Te<R.length&&/\s/.test(R[Te]);)Te++;if(Te<R.length&&R[Te]==="]"){W=!0;break}}}if(!W){let P=I.trim(),$="";F?$=`Unclosed quote string (${F}) inside arguments`:P.endsWith("]")?$=`Missing closing ')' before ']' (e.g. found "...]")`:P.endsWith(")")?$=`Missing closing ']' after ')' (e.g. found "...)" instead of "...)]")`:!P.includes(")")&&!P.includes("]")?$="Missing closing delimiter ')]'":$="Malformed or unclosed call syntax (missing ')]')",n.push(`\u2022 [action:${s.toolName}(...)]: ${$}. 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 m=l[1],s=l.index+(l[0].indexOf(":")-(l[0].startsWith("action")||l[0].startsWith("tool")?0:1));(s>0?t[s-1]:"")!=="["&&Ai(m)&&n.push(`\u2022 action:${m}(...): Missing opening bracket '['. Expected: [action:${m}(...)]`)}let g=/\[\s*(?:functions\.)?([a-zA-Z0-9_]+)\s*\(/g,u;for(;(u=g.exec(t))!==null;){let m=u[1];m!=="action"&&m!=="tool"&&Ai(m)&&n.push(`\u2022 [${m}(...)]: Missing 'action:' prefix. Expected: [action:${m}(...)]`)}let h=/\[\s*(?:tool|action)\s*:\s*(?:functions\.)?([a-zA-Z0-9_]+)(?!\s*\()/gi,p;for(;(p=h.exec(t))!==null;){let m=p[1];Ai(m)&&n.push(`\u2022 [action:${m}...]: Missing opening '(' for tool arguments. Expected: [action:${m}(...)]`)}return n.length>0?n.join(`
558
- `):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:g,mode:u}=e,h="",p=null,m=typeof n=="string"?[{role:"user",parts:[{text:n}]}]:n,s=new AbortController,w=s.signal,I=setInterval(()=>{xt&&(s.abort(),clearInterval(I))},100),Xe=Date.now(),R=null;try{let O;if(l==="Ollama")O=(await we("Ollama"))(g,t,m,i,o,u,at(t),w,r,e.systemSettings?.ollamaEndpoint||"Cloud");else if(l==="OpenRouter")O=(await we("OpenRouter"))(g,t,m,i,o,u,at(t),w,r);else if(l==="DeepSeek")O=(await we("DeepSeek"))(g,t,m,i,o,u,at(t),w,r);else if(l==="Mistral")O=(await we("Mistral"))(g,t,m,i,o,u,at(t),w,r);else if(l==="NVIDIA")O=(await we("NVIDIA"))(g,t,m,i,o,u,at(t),w,r);else if(l==="InferX")O=(await we("InferX"))(g,t,m,i,o,u,at(t),w,r);else if(l==="SenseNova")O=(await we("SenseNova"))(g,t,m,i,o,u,at(t),w,r);else if(l==="AIHubMix")O=(await we("AIHubMix"))(g,t,m,i,o,u,at(t),w,r);else if(l==="Poolside")O=(await we("Poolside"))(g,t,m,i,o,u,at(t),w,r);else if(l==="9router"||l==="9Router")O=(await we("NineRouter"))(g,t,m,i,o,u,at(t),w,r);else if(l==="ExpLabs"||l==="ExperientialLabs")O=(await we("ExpLabs"))(g,t,m,i,o,u,at(t),w,r);else if(l==="Infron"||l==="infron")O=(await we("Infron"))(g,t,m,i,o,u,at(t),w,r);else if(l==="TokenHarbor"||l==="Token Harbor"||l==="tokenharbor"||l==="token_harbor"||l==="thk")O=(await we("TokenHarbor"))(g,t,m,i,o,u,at(t),w,r);else if(l==="APInex"||l==="apinex"||l==="apx")O=(await we("APInex"))(g,t,m,i,o,u,at(t),w,r);else if(l==="xKiro"||l==="xkiro"||l==="kiro")O=(await we("xKiro"))(g,t,m,i,o,u,at(t),w,r);else if(l==="c_openai"||l==="Custom (OpenAI)"){let F=e.systemSettings?.customOpenAIBaseUrl||"";try{F=await Vi("c_openai")||F}catch{}O=(await we("c_openai"))(g,t,m,i,o,u,at(t),w,r,F)}else{let F=Sa(g),{serviceTier:W,cleanModel:P}=Ta(t),$={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 G={Fast:0,Low:512,Medium:2048,Standard:2048,High:16384,xHigh:24576}[o]||2048;return G===0?{includeThoughts:!1}:{includeThoughts:!0,thinkingBudget:G}}})()};W&&($.serviceTier=W),O=await F.models.generateContentStream({model:P,contents:m,config:$},{signal:w})}for await(let F of O){if(xt)throw new Error("Subagent task was cancelled.");if(e?.taskId&&typeof jt<"u"){let $=jt.find(Te=>Te.id===e.taskId);if($&&$.status==="cancelled")throw new Error("Subagent task was cancelled.")}R===null&&(F.candidates?.[0]?.content?.parts||F.text)&&(R=Date.now()-Xe);let W="";if(F.candidates?.[0]?.content?.parts)for(let $ of F.candidates[0].content.parts)$.text&&!$.thought&&(h+=$.text,W+=$.text);let P=W?Yi(W):0;e&&typeof e.onTokenChunk=="function"&&e.onTokenChunk(W,P),F.usageMetadata&&(p=F.usageMetadata)}}finally{clearInterval(I)}if(p){let O=p.totalTokenCount||0,F=p.cachedContentTokenCount||0,W=(p.candidatesTokenCount||0)+(l==="Google"&&p.thoughtsTokenCount||0);await xn("tokens",O,l,t),F>0&&await xn("cachedTokens",F,l,t),W>0&&await xn("candidateTokens",W,l,t),R!==null&&R>0&&await xn("ttft",R,l,t),ci({provider:l,model:t,prompt:p.promptTokenCount||0,cached:F,output:W,reasoning:p.thoughtsTokenCount||0,ttft:R}),e&&typeof e.onUsage=="function"&&e.onUsage({totalTokenCount:O,cachedContentTokenCount:F,candidatesTokenCount:W})}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:g,chatId:u,isPlayground:h,systemSettings:p,sessionStats:m,aiProvider:s="Google",apiTier:w,wildcardTooling:I,wildercardTooling:Xe}=n,R=at(e);if(!Es&&s==="Google")throw new Error("AI not initialized");let O=!1,F=t[t.length-1].text,W=B.join(js,"chat-summaries.json"),P=!1,$=t.filter(G=>G.role==="user").length===1,Te=F.includes("[TITLE-UPDATE]"),Ae=$||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(u,Ne),p?.advanceRollback&&await Mo.takeInitialSnapshot(u),xt=!1;let et=null;try{let G=new AbortController;et=setInterval(()=>{xt&&(G.abort(),et&&(clearInterval(et),et=null))},400);let x=[...t.slice(0,-1)];{let ue=yn(W,{})[u]||{summary:"",historyLength:0};if(ue.summary&&ue.historyLength>0){let kt=0,le=[];for(let Y=0;Y<x.length;Y++){let Se=x[Y];(Se.role==="user"||Se.role==="agent"||Se.role==="system")&&!String(Se.id).startsWith("welcome")&&!Se.isMeta&&kt++,kt>ue.historyLength&&le.push(Se)}x=le}}x=x.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 Sn=process.env.GOOGLE_GEMMA_NONSENSE==="true"||process.env.GOOGLE_GEMMA_NONSENSE===!0||!1,tn={"16k":16e3,"32k":32e3,"64k":64e3,"128k":128e3,"256k":256e3,"512k":512e3,"1M":1e6}[p?.contextLength]||256e3;if(s==="Google"&&e?.includes("gemma")&&Sn&&(tn=16e3),(m?.tokens||0)>tn){yield{type:"text",content:"\u2726 Maximum Context Limit Reached. Start a new chat."};return}if($&&O){let b=yn(Hi,{});Object.values(b).flat().length>5}let Me=yn(Hi,{}),ne=yn(Ks,{}),Ve=Object.entries(Me).filter(([b])=>b!==u).flatMap(([b,ue])=>ue),_n=[...Object.entries(ne).filter(([b])=>b!==u).slice(-20).map(([b,ue])=>`[Chat Summary]: ${ue}`),...Ve].map(b=>`- ${b}`).join(`
559
- `),Kn=yn(si,[]).map(b=>`- ${b.memory}`).join(`
560
- `),fn=(m?.tokens||0)>=1e4,St=new Date,Ft=St.getFullYear(),Pe=St.toLocaleString("en-US",{month:"short"}).toUpperCase(),Bt=String(St.getDate()).padStart(2,"0"),Vn=`${St.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0})}`,j=b=>{try{return xe.readdirSync(b,{withFileTypes:!0})}catch{return[]}},N=Array.from(new Set([..._o,...Io(process.cwd())])),zn=(b,ue=6)=>p?.indentationTree!==!1?Ss(b,ue,1,j,N):Ts(b,ue,"",1,j,N),it=yn(ji,{}),k=it[u],Z=k?k!==process.cwd():!1;it[u]=process.cwd(),Ki(ji,it);let Je=yn(W,{}),Ce=Je[u]||{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[u]=Ce,Ki(W,Je));let ft=typeof Ce=="object"?Ce.summary||"":Ce||"",nn=x.length>0;nn&&ft&&x[0]&&(x[0].role==="user"||x[0].role==="system")&&(x[0].text.includes("**CONTEXT SUMMARY OF PREVIOUS TURNS")||(x[0].text=`[SYSTEM METADATA]
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(`
557
+ `),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]
561
559
  **CONTEXT SUMMARY OF PREVIOUS TURNS (PRIORITY: DYNAMIC)**
562
560
  ${ft}
563
561
 
564
- [USER] ${x[0].text}`,yield{type:"summary_injected",content:{id:x[0].id,text:x[0].text}}));let un=ft&&!nn?`
562
+ [USER] ${w[0].text}`,yield{type:"summary_injected",content:{id:w[0].id,text:w[0].text}}));let dn=ft&&!Zt?`
565
563
  [SYSTEM METADATA]
566
564
  **CONTEXT SUMMARY OF PREVIOUS TURNS**
567
565
  ${ft}
568
- `:"",kn=!!p?.dynamicDirAwareness,_s=`${u}|${s}|${d}|${e}|${r}|${kn}`,Aa=!kn&&oo.key===_s&&oo.value?"":`
566
+ `:"",kn=!!p?.dynamicDirAwareness,_s=`${f}|${s}|${d}|${e}|${r}|${kn}`,Aa=!kn&&no.key===_s&&no.value?"":`
569
567
  **Directory**
570
568
  CWD: `+process.cwd()+`${h?" [PLAYGROUND MODE]":""}
571
- `+zn(process.cwd(),6),Ot=xo()?await no():null,Is=b=>{if(!b||!Array.isArray(b)||b.length===0)return null;let ue=new Map;for(let le of b){let Y=le.relPath||(le.file?B.relative(process.cwd(),le.file):"unknown");ue.has(Y)||ue.set(Y,[]),ue.get(Y).push(le)}let kt=[];for(let[le,Y]of ue.entries()){kt.push(`- ${le}:`);for(let Se of Y){let $e=(Se.snippet||"").trim().replace(/\r?\n/g," "),tt=Se.line||1,Ut=(Se.text||"").trim().replace(/\r?\n+/g,". "),Tt=Ut?` [${Ut}]`:"";kt.push(` ~L${tt}${Tt}`)}}return kt.join(`
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(`
572
570
  `)},Pi=Is(Ot?.comments),Tn="";if(Ot&&Ot.file_focused!=="none"){Tn=`
573
571
  [Additional IDE Context]
574
- `;let b=B.relative(process.cwd(),Ot.file_focused),ue=(Ot.opened_editors||[]).map(le=>{let Y=B.relative(process.cwd(),le);return Y.startsWith("..")?`[External] ${B.basename(le)}`:Y});if(Tn+=`Focused File: ${b}
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}
575
573
  Cursor Line: ${Ot.cursor_line}
576
- `,Ot.selected){let le=Ot.selected,Y=le.split(`
577
- `);Y.length>256&&(le=Y.slice(0,240).join(`
574
+ `,Ot.selected){let le=Ot.selected,K=le.split(`
575
+ `);K.length>256&&(le=K.slice(0,240).join(`
578
576
  `)+`
579
577
  ... [truncated] ...
580
- `+Y.slice(-16).join(`
578
+ `+K.slice(-16).join(`
581
579
  `)),le.length>2048&&(le=le.slice(0,1920)+`
582
580
  ... [truncated] ...
583
581
  `+le.slice(-128)),Tn+=`Current Selection: "${le}"
584
582
  `}if(Ot.manual_edits){let le=Ot.manual_edits.split(`
585
- `),Y=[];for(let Se=0;Se<le.length;Se++){let $e=le[Se],tt=le[Se+1],Ut=le[Se+2];if(tt!==void 0&&Ut!==void 0&&/:\s*$/.test($e)&&/^\s*-\s*/.test(tt)&&/^\s*\+\s*/.test(Ut)&&(tt.length>300||Ut.length>300)){Y.push($e.replace(/:\s*$/,": [changed]")),Se+=2;continue}Y.push($e)}Tn+=`Recent Manual Edits:
586
- ${Y.join(`
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
585
  `)}
588
586
  `}ue.length>0&&(Tn+=`All Opened Editors: ${ue.join(", ")}`),Ot.diagnostics&&(Tn+=`
589
587
  **Active File Errors**:
@@ -591,12 +589,12 @@ ${Ot.diagnostics}
591
589
  `),(Ne.toLowerCase().includes("lint")||Ne.toLowerCase().includes("warning"))&&Ot.warnings&&(Tn+=`
592
590
  **Lint Warnings**:
593
591
  ${Ot.warnings}
594
- `)}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,""),Y=/[:#]L?(\d+)(?:-L?(\d+))?$/i,Se=le.match(Y),$e=le,tt=null,Ut=null;Se&&(tt=parseInt(Se[1],10),Ut=Se[2]?parseInt(Se[2],10):tt,$e=le.slice(0,Se.index));let Tt=B.resolve(process.cwd(),$e);if(xe.existsSync(Tt)&&xe.statSync(Tt).isFile()){let Wt=$e.toLowerCase(),bo=Wt.endsWith(".pdf"),Yn=Wt.endsWith(".docx")||Wt.endsWith(".doc")||Wt.endsWith(".ppt")||Wt.endsWith(".pptx")||Wt.endsWith(".xls")||Wt.endsWith(".xlsx"),Xn=/\.(png|jpg|jpeg|webp|gif|bmp)$/.test(Wt),je=Xn||bo||Yn,Et=s==="Google"||at(e);if(je&&!Et){let me=`\u2718 Unsupported Modality: ${B.basename($e)}`,Qe=115;process.stdout.isTTY&&(Qe=process.stdout.columns-5||120);let _t=[me],De=Math.max(..._t.map(rn=>rn.length)),ee=Math.min(De+4,Qe),Ue=_t.map(rn=>`${rn.padEnd(ee-2).substring(0,ee-2)}`).join(`
595
- `);yield{type:"visual_feedback",content:Lt(`${Ue}
596
- `)};continue}if(tt===null&&!je){let me=0;try{me=xe.readFileSync(Tt,"utf8").split(/\r\n|\r|\n/).length}catch{}if(me>150){let Qe=`\u21B7 Skipped (Too Large): ${B.basename($e)}`,_t=115;process.stdout.isTTY&&(_t=process.stdout.columns-5||120);let De=Math.min(Qe.length+4,_t),ee=Qe.padEnd(De-2).substring(0,De-2);yield{type:"visual_feedback",content:Lt(`${ee}
597
- `)};continue}}let In=tt!==null?tt:1,Gt=Ut!==null?Ut:tt!==null?tt:In+149;if(Gt-In>200){let me=`\u21B7 Skipped (Too Large): ${B.basename($e)}`,Qe=115;process.stdout.isTTY&&(Qe=process.stdout.columns-5||120);let _t=Math.min(me.length+4,Qe),De=me.padEnd(_t-2).substring(0,_t-2);yield{type:"visual_feedback",content:Lt(`${De}
598
- `)};continue}let Jn=`path=${JSON.stringify($e)}, startLine=${In}, endLine=${Gt}`,Ht=await tr(Jn,{isMultiModal:Et}),Mn=!1,ao="",wt=null;if(typeof Ht=="string"?Ht.trim().startsWith("ERROR")?Mn=!0:ao=Ht:Ht&&typeof Ht=="object"&&Ht.binaryPart?(wt=Ht.binaryPart,ao=Ht.text||""):Mn=!0,!Mn){let me="";if(Xn?(me=`\u2714 Processed: ${B.basename($e)}`,zo=wt,qo=!0):bo||Yn?(me=`\u2714 Auto-Analysed: ${B.basename($e)}`,zo=wt,qo=!0):(me=`\u2714 Auto-Read: ${B.basename($e)}`,Oi.push(ao)),me){let Qe=115;process.stdout.isTTY&&(Qe=process.stdout.columns-5||120);let _t=[me],De=Math.max(..._t.map(rn=>rn.length)),ee=Math.min(De+4,Qe),Ue=_t.map(rn=>`${rn.padEnd(ee-2).substring(0,ee-2)}`).join(`
599
- `);yield{type:"visual_feedback",content:Lt(`${Ue}
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}
600
598
  `)}}}}}catch{}}let Yo="";Oi.length>0?Yo=`
601
599
  [Tagged File Contents] Auto Read User Tagged files by System${qo?", attached below & multimodal part":""}. No need to re-read
602
600
  `+Oi.join(`
@@ -605,9 +603,9 @@ ${Ot.warnings}
605
603
  [Tagged File Contents]
606
604
  `:qo&&(Yo=`
607
605
  [Tagged File Contents] Auto Read User Tagged files by System & attached as multimodal part. No need to re-read [Tagged File Contents]
608
- `);let Be=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
606
+ `);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
609
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]
610
- `:""}`:"",ro="";if(p?.clipboardContext)try{process.platform==="win32"?ro=As("powershell.exe -NoProfile -Command Get-Clipboard",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):process.platform==="darwin"?ro=As("pbpaste",{encoding:"utf8",stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,""):ro=As("xclip -selection clipboard -o || xsel --clipboard --output",{encoding:"utf8",shell:!0,stdio:["pipe","pipe","ignore"],timeout:1500}).replace(/\r?\n$/,"")}catch{ro=""}let Xo="",Ra=!!p?.autoExcludeMetadata,Os=!1,Ns=!1,Ni="";if(Be.startsWith("/skill create ")||Be==="/skill create"){let b=null;Os=!0,Be=Be.replace(/^\/skill\s+create\b/,"").trim(),/^--project(\s|$)|(\s|^)--project$/.test(Be)?b="project":/^--global(\s|$)|(\s|^)--global$/.test(Be)&&(b="global"),Be=Be.replace(/^--project\s*|\s*--project$/g,"").trim(),Be=Be.replace(/^--global\s*|\s*--global$/g,"").trim(),Be=Be.replace(/^(['"])([\s\S]*)\1$/,"$2").trim(),Ni=`[system] ## Skill Creation Rules
608
+ `:""}`:"",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
611
609
  * ${b?b==="project"?`Creation path: ./skills/skillName?/SKILL.md
612
610
  * 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
613
611
  * If skills folder already present, ReadFolder for existing structure`}
@@ -621,84 +619,84 @@ description: concise detail to explain the skill
621
619
  - Write relative link to this .md in SKILL.md with concise description about content of that reference
622
620
  * Similar skill loaded in your prompt? AskUser & offer extending it. If agreed tell them to use \`/skill edit --skillName ...\` and end your turn
623
621
  * For any ambiguity AskUser
624
- * After creation, tell user to restart fluxflow for reindexing${(m?.tokens||0)>24576?`
622
+ * After creation, tell user to restart fluxflow for reindexing${(g?.tokens||0)>24576?`
625
623
  * Warn: This session is currently long, and reindexing will cause full cache invalidation`:""}
626
624
  [/system]
627
- `}else if(Be.startsWith("/skill edit ")||Be==="/skill edit"){Ns=!0,Be=Be.replace(/^\/skill\s+edit\b/,"").trim();let b=null,ue=Be.match(/^--([^\s]+)(?:\s|$)/);if(ue)b=ue[1],Be=Be.slice(ue[0].length).trim();else{let Y=Be.match(/(?:\s|^)--([^\s]+)$/);Y&&(b=Y[1],Be=Be.slice(0,Y.index).trim())}Be=Be.replace(/^(['"])([\s\S]*)\1$/,"$2").trim();let kt=null,le=null;if(b){let Y=b.toLowerCase(),Se=[...yi||[],...hi||[]].find($e=>$e&&$e.name&&$e.name.toLowerCase()===Y);Se&&Se.filePath&&(le=B.resolve(Se.filePath),kt=B.dirname(le))}Ni=`[system] ## Skill Modification Rules
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
628
626
  ${kt&&b?`* Target Skill: ${b}
629
627
  * Physical Skill path: ${le}
630
628
  * Skill will have a SKILL.md at this path. And may have lazy loaded *.md files in folders
631
629
  * Extract requirements, use file tools with physical disk path
632
630
  * Maintain existing conventions, and modify based on requirements
633
631
  * Any ambiguity AskUser
634
- * After completion tell user no reindexing needed, will be auto updated on next #skill read if frontmatter stays same${(m?.tokens||0)>24576?`
632
+ * After completion tell user no reindexing needed, will be auto updated on next #skill read if frontmatter stays same${(g?.tokens||0)>24576?`
635
633
  * 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`"}
636
634
  [/system]
637
- `}let va=!!(Tn||Yo||$s||un||Ls||Z||p?.dynamicDirAwareness||p?.autoTruncateResults||Os||Ns);Ra&&!va?Xo=Be.trim():Xo=`[System Metadata] Time: ${Vn}${Z?`
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?`
638
636
  WARNING: CWD Changed from previous: "${k}" to current: "${process.cwd()}", write change in chat to avoid future path mismatches
639
637
  `:""}${Tn}
640
- ${ro.trim().length>0?`[Clipboard Context]
641
- - ${ro.trim()}
638
+ ${so.trim().length>0?`[Clipboard Context]
639
+ - ${so.trim()}
642
640
  `:""}${Pi?`[Additional Comments]
643
641
  ${Pi.trimEnd()}
644
642
  `:""}Action format: [action:ActionName(...)]
645
643
  [/Metadata]
646
- ${un}${Ls}${Yo}${Ni}${$s}[user prompt] ${Be.trim()} [/user prompt]`.trim();let Ds={role:"user",text:Xo};zo&&(Ds.binaryPart=zo),x.forEach(b=>{b.text&&b.role==="agent"&&(b.text=Kt(b.text))}),x.push(Ds),un&&t[t.length-1]?.id&&(yield{type:"summary_injected",content:{id:t[t.length-1].id,text:Xo}});let on=null,sn=l==="Flux"?50:15;sn=l.toLowerCase().includes("cu")?75:sn;let Fs=(p?.loopLimits||"Default").toLowerCase();if(Fs==="extended")sn=Math.floor(sn*3);else if(Fs==="env"){let b=parseInt(process.env.FLUXFLOW_MAX_LOOPS||process.env.MAX_LOOPS||"",10);Number.isFinite(b)&&b>0&&(sn=b)}let Ea=Math.floor(sn/2),Bs=0,gn=16;yield{type:"status",content:process.env.HALLOWEEN_EEGG==="true"?"Consulting the spirits":"Connecting"},xt=!1;let Di=[],Jo=!1,Us=!1,qn=[],Fi=!1;for(let b=0;b<=sn;b++){let ue=Math.floor(sn*.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")&&(sn+=Ea)}catch{}}if(qn.length>=10&&typeof n?.onAskUser=="function"){let H={},X=null;for(let E of qn)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"))?qn=qn.filter(At=>At!==X):We=typeof de=="string"?de:de?.label||de?.id||"",We&&(x.length>0&&x[x.length-1].role==="user"?x[x.length-1].text+=`
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+=`
647
645
 
648
- [STEERING HINT from USER, High Priority] ${We.trim()} [/STEERING HINT]`:x.push({role:"user",text:`[STEERING HINT from USER, High Priority] ${We.trim()} [/STEERING HINT]`}),yield{type:"status",content:"Steering Hint Injected..."},qn=qn.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-Z5JHZZKA.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=x.filter(ge=>Array.isArray(ge.parts)&&ge.parts.some(bt=>bt.inlineData));if(At.length>=We){let ge=At.length-We+1;for(let bt=0;bt<ge;bt++){let nt=At[bt];Array.isArray(nt.parts)&&(nt.parts=nt.parts.filter(mt=>!mt.inlineData))}}if(x.length>0&&x[x.length-1].role==="user"){let ge=x[x.length-1];typeof ge.text=="string"&&(ge.text+=`
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+=`
649
647
 
650
- ${E}`,Array.isArray(ge.parts)||(ge.parts=[{text:ge.text}]),ge.parts.push(gt))}else x.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:`
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:`
651
649
 
652
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(`
653
651
 
654
- `);x.length>0&&x[x.length-1].role==="user"?x[x.length-1].text+=`
652
+ `);w.length>0&&w[w.length-1].role==="user"?w[w.length-1].text+=`
655
653
 
656
- ${E}`:x.push({role:"user",text:E}),yield{type:"status",content:"Subagent Update"}}}catch{}if(i){let H=await i();H&&(H.startsWith("/btw")?x.length>0&&x[x.length-1].role==="user"?x[x.length-1].text+=`
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+=`
657
655
 
658
656
  [system] User question. Resolve this specific query within '[ANSWER]...[/ANSWER]' concisely, naturally [/system]
659
- [question] ${H.replace("/btw","").trim()} [/question]`:x.push({role:"user",text:`[system] User question. Resolve this specific query within '[ANSWER]...[/ANSWER]' concisely, naturally [/system]
660
- [question] ${H.replace("/btw","").trim()} [/question]`}):x.length>0&&x[x.length-1].role==="user"?x[x.length-1].text+=`
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
659
 
662
- [STEERING HINT from USER, High Priority] ${H.trim()} [/STEERING HINT]`:x.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 Y,Se=!1,$e=1,tt=1,Ut=Date.now(),Tt=null,be="",Wt=null,bo=null,Yn=null,Xn=0,je=[],Et=0,In=!1,Gt=!1,Jn=!1,Ht=!1,Mn=!0,ao=0,wt="",me="",Qe=!1,_t=!1,De=!0,ee=e,Ue="",rn=d;for(d=d.toLowerCase()==="max"?"High":d;$e<=gn&&tt<=gn&&!Se&&!xt;){let H=!1;try{be="",Mn&&(process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07"),yield{type:"turn_reset",content:!0},Mn=!1,tt===1&&(wt=""));let X=f=>{if(!f||typeof f!="string")return f;let S="",T=Rs(f);if(T&&(S=T.fullBlock,f=T.remainingText),!f.includes("[tool:")&&!f.includes("[action:"))return(p?.keepReasoningContext?S:"")+f;if(jn(f).length===0){let y=_i(f);return(p?.keepReasoningContext?S:"")+y}f=f.replace(El,(y,A)=>A.includes("[tool:")||A.includes("[action:")?A.trim():y);let ie="",M=0,V=[],yt="";for(;M<f.length;){let y=f.indexOf("[tool:",M),A=f.indexOf("[action:",M),te=-1;if(y!==-1&&A!==-1?te=Math.min(y,A):y!==-1?te=y:te=A,te===-1){V.length===0&&(ie+=_i(f.substring(M)));break}if((te>0?f[te-1]:"")==="`"){ie+=_i(f.substring(M,te+1)),M=te+1;continue}V.length===0&&(yt=_i(f.substring(M,te)));let J=-1,v=null,Ct=0;for(let It=te;It<f.length;It++){let ut=f[It];if(v){if(ut===v){let Ze=0;for(let se=It-1;se>=0&&f[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){V.length===0&&(ie+=f.substring(te));break}let $n=f.substring(te,J+1);V.push($n),M=J+1}return V.length>0&&(ie=yt.trimEnd()?yt.trimEnd()+`
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()+`
663
661
 
664
- `+V.join(`
662
+ `+z.join(`
665
663
 
666
- `):V.join(`
664
+ `):z.join(`
667
665
 
668
- `)),(p?.keepReasoningContext?S:"")+ie},E=x.filter(f=>(f.role==="user"||f.role==="agent"||f.role==="system")&&!String(f.id).startsWith("welcome")&&!f.isMeta&&!f.isTerminalRecord&&!(f.text&&f.text.startsWith("[TERMINAL_RECORD]"))).map((f,S,T)=>{let K=f.text||"";O||(K=K.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),f.role==="agent"&&(K=X(K),K=K.replace(/\[turn:\s*finish\]/gi,"").replace(/\[\[END\]\]/gi,"").trim(),K=K.replaceAll("\x1B[33m\u24D8 Request Cancelled\x1B[0m","*User Cancelled Response Generation*"));let ie=[];return Array.isArray(f.parts)&&f.parts.length>0?ie=f.parts.map(M=>{if(M.text){let V=M.text;return O||(V=V.replace(/\s*\n*\s*\[Prompted on:.*?\]/gi,"").trim()),f.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*")),{text:V}}return M}):ie=[{text:K}],f.binaryPart&&at(ee)&&T.slice(S+1).filter(V=>V.role==="user"&&!V.text?.startsWith("[ACTION RESULT]")&&!V.text?.startsWith("[TOOL RESULT]")).length<=2&&ie.push(f.binaryPart),{role:f.role==="user"||f.role==="system"?"user":"model",parts:ie}});for(let f=E.length-2;f>=0;f--){let S=E[f],T=E[f+1];S.role==="user"&&T.role==="user"&&(T.parts?.[0]?.text||"").trim().startsWith("[SYSTEM")&&E.splice(f,1)}let gt=[];for(let f=0;f<E.length;f++){let S=E[f];if(gt.length===0)gt.push(S);else{let T=gt[gt.length-1];T.role===S.role?(T.parts[0].text+=`
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+=`
669
667
 
670
- `+(S.parts?.[0]?.text||""),S.parts?.length>1&&T.parts.push(...S.parts.slice(1))):gt.push(S)}}for(let f of gt)for(let S of f.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),ee=e;let de=`${u}|${s}|${l}|${d}|${rn}|${ee}|${JSON.stringify(r)}|${!!p?.dynamicDirAwareness}|${!!p?.subAgents}|${process.env.rawReasoning==="true"}`,We=oo.key===de&&oo.value;if((process.env.I_HAVE_TOO_MUCH_MONEY==="true"||process.env.I_HAVE_TOO_MUCH_MONEY===!0)&&(We=!1),We)Ue=oo.value;else{let f=s==="Mistral"?!!ai(ee):!(ee||"gemma").toLowerCase().startsWith("gemma");Ue=Fr(r,((ee||"gemma").toLowerCase().startsWith("gemma"),rn),l,p,O,$,s,s==="Google"?!0:R,f,u,!!p?.keepReasoningContext,ee),p?.dynamicDirAwareness||(Ue+=`
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+=`
671
669
  ${Aa.replace(`
672
670
  **Directory**`,`
673
- -- Directory --`)}`),oo.key=de,oo.value=Ue}let ge=E[E.length-1];if(xo()&b>0){await new Promise(K=>setTimeout(K,2500)),yield{type:"status",content:"Verifying"};let f=await no(),S=f?f.diagnostics:null,T=Is(f?.comments);S&&ge&&ge.role==="user"&&ge.parts?.[0]?.text&&(ge.parts[0].text+=`
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+=`
674
672
 
675
673
  ${S}`),Pi&&ge&&ge.role==="user"&&ge.parts?.[0]?.text&&(ge.parts[0].text+=`
676
674
 
677
675
  [Additional Comments]
678
- ${T}`),yield{type:"status",content:"Working"}}let bt=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 f=await Mo.getLatestFileChanges(u);if(f&&(f.newFiles.length>0||f.modifiedFiles.length>0||f.deletedFiles.length>0)){let S=`
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=`
679
677
  [system] File Changes:
680
- `;for(let K of f.newFiles)S+=`* ${K} (created)
681
- `;for(let K of f.modifiedFiles)S+=`* ${K} (modified)
682
- `;for(let K of f.deletedFiles)S+=`* ${K} (deleted)
683
- `;S+="[/system]",ge.parts[0].text+=S;let T=-1;for(let K=x.length-1;K>=0;K--)if(x[K].role==="user"&&(x[K].text?.startsWith("[ACTION RESULT]")||x[K].text?.startsWith("[TOOL RESULT]"))){T=K;break}T!==-1&&(x[T].text+=S)}}catch{}let nt=Math.floor(sn*.99),mt=b+1;if(mt>=nt&&ge&&ge.parts?.[0]&&(ge.parts[0].text+=`
684
- [system] WARNING, Turn Limit Impending: Step ${mt}/${sn}. Wrap up quickly/prompt user to continue. [/system]`),process.env.LOG_CHAT==="true"||process.env.LOG_CHAT==="1"||process.env.LOG_CHAT===!0||!1){let f=B.join(to,"chats",String(u));xe.existsSync(f)||xe.mkdirSync(f,{recursive:!0}),xe.writeFileSync(B.join(f,"context.json"),JSON.stringify({contents:E},null,2)),xe.writeFileSync(B.join(f,"system.md"),`${We?"CACHED":"NOT CACHED"}
678
+ `;for(let V of u.newFiles)S+=`* ${V} (created)
679
+ `;for(let V of u.modifiedFiles)S+=`* ${V} (modified)
680
+ `;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"}
685
683
  Key: ${de}
686
684
  --------------------------------------------------------------------
687
685
 
688
- ${Ue}`)}let st=new Promise((f,S)=>{G.signal.aborted&&S(new DOMException("The user aborted a request.","AbortError")),G.signal.addEventListener("abort",()=>{S(new DOMException("The user aborted a request.","AbortError"))})});st.catch(()=>{});let Fe=E;if(Ut=Date.now(),s==="Ollama")Y=(await we("Ollama"))(n.apiKey,ee,Fe,Ue,d,l,R,G.signal,1,p?.ollamaEndpoint||"Cloud");else if(s==="OpenRouter")Y=(await we("OpenRouter"))(n.apiKey,ee,Fe,Ue,d,l,R,G.signal,1,u);else if(s==="DeepSeek")Y=(await we("DeepSeek"))(n.apiKey,ee,Fe,Ue,d,l,R,G.signal,1);else if(s==="Mistral")Y=(await we("Mistral"))(n.apiKey,ee,Fe,Ue,d,l,R,G.signal,1,u);else if(s==="NVIDIA"){let f=(await we("NVIDIA"))(n.apiKey,ee,Fe,Ue,d,l,R,G.signal,1);Y=(await we("NVIDIA_wrap"))(f,ee)}else if(s==="InferX")Y=(await we("InferX"))(n.apiKey,ee,Fe,Ue,d,l,R,G.signal,1);else if(s==="SenseNova")Y=(await we("SenseNova"))(n.apiKey,ee,Fe,Ue,d,l,R,G.signal,1);else if(s==="AIHubMix")Y=(await we("AIHubMix"))(n.apiKey,ee,Fe,Ue,d,l,R,G.signal,1);else if(s==="Poolside")Y=(await we("Poolside"))(n.apiKey,ee,Fe,Ue,d,l,R,G.signal,1);else if(s==="9router"||s==="9Router")Y=(await we("NineRouter"))(n.apiKey,ee,Fe,Ue,d,l,R,G.signal,1);else if(s==="ExpLabs"||s==="ExperientialLabs")Y=(await we("ExpLabs"))(n.apiKey,ee,Fe,Ue,d,l,R,G.signal,1);else if(s==="Infron"||s==="infron")Y=(await we("Infron"))(n.apiKey,ee,Fe,Ue,d,l,R,G.signal,1);else if(s==="TokenHarbor"||s==="Token Harbor"||s==="tokenharbor"||s==="token_harbor"||s==="thk")Y=(await we("TokenHarbor"))(n.apiKey,ee,Fe,Ue,d,l,R,G.signal,1);else if(s==="APInex"||s==="apinex"||s==="apx")Y=(await we("APInex"))(n.apiKey,ee,Fe,Ue,d,l,R,G.signal,1);else if(s==="xKiro"||s==="xkiro"||s==="kiro")Y=(await we("xKiro"))(n.apiKey,ee,Fe,Ue,d,l,R,G.signal,1);else if(s==="c_openai"||s==="Custom (OpenAI)"){let f=p?.customOpenAIBaseUrl||"";try{f=await Vi("c_openai")||f}catch{}Y=(await we("c_openai"))(n.apiKey,ee,Fe,Ue,d,l,R,G.signal,1,f)}else{let f=Sa(n?.apiKey),{serviceTier:S,cleanModel:T}=Ta(ee),K={systemInstruction:Ue,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",ee||"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 te=Number(M);if(!isNaN(te))return{includeThoughts:!0,thinkingBudget:te}}}let V=(ee||"").toLowerCase(),yt=V.includes("gemma-4")||V.startsWith("gemma"),y=V.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:V.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&&(K.serviceTier=S);let ie=f.models.generateContentStream({model:T||"gemini-3-flash-preview",contents:Fe,config:K},{signal:G.signal});Y=await Promise.race([ie,st])}be="",Wt=null,Yn=null,je=[],Et=0,yield{type:"model_update",content:null},me="",Qe=wt.length>0;let pt="",Qo=Date.now(),mn=async function*(){if(s==="Google"&&pt){let f=ko(pt);for(let S of f)yield S;pt="",Qo=Date.now()}},Ws=!0,An="",lo=!1,ht=null,Gs=!1,Zn=!1,co=!1,Zo=!1,Pn=!1,So=f=>{let S=0;for(;S+2<f.length;)f[S]==="`"&&f[S+1]==="`"&&f[S+2]==="`"?(Zo=!Zo,S+=3):S++},Hs=f=>{if(!f)return;let S=/(?:<(\/?)think_fluxflow[^>]*>|\[(\/?)think_fluxflow\]|<\/?channel\|?>|<\|channel>thought)/gi,T;for(;(T=S.exec(f))!==null;){let K=T[0].toLowerCase();K.startsWith("</")||K.startsWith("[/")||K==="<channel|>"?Pn=!1:Pn=!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=f=>{let S=[],T=f,K=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,V=0,yt;for(;(yt=M.exec(ie))!==null;){let A=ie.substring(V,yt.index);if(A)if(So(A),Pn)S.push({type:"text",content:A});else{let _e=A.replace(/[^\r\n]/g,"");_e&&S.push({type:"text",content:_e})}let te=yt[0];So(te);let a=te.toLowerCase();a.startsWith("</")||a.startsWith("[/")||a==="<channel|>"?Pn=!1:Pn=!0,S.push({type:"text",content:te}),V=M.lastIndex}let y=ie.substring(V);if(y)if(So(y),Pn)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(lo){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){K(ie),An="",lo=!1,ht=null,Zn=!1,co=!1,T="";break}}let V=-1,yt=M?M.endTag:"]";if(ht==="tool"||ht==="action"){let y=0,A=null,te=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(Zn){V=_e;break}else A=J;else if(J==="(")y++,a=!0;else if(J===")")y--;else if(J==="]"&&a&&y===0){V=_e;break}}}else V=ie.indexOf(yt);if(V!==-1){let y=yt.length,A=ie.substring(0,V+y);ht?.startsWith("kimi")||S.push({type:"text",content:A}),So(A),Hs(A),(ht==="tool"||ht==="action"||ht?.startsWith("kimi"))&&!Zn&&!co&&(Gs=!0,qn.push(A.trim())),Zn=!1,co=!1,An="",lo=!1,ht=null,T=ie.substring(V+y)}else{An=ie,T="";break}}else{let ie=T.indexOf("[tool"),M=T.indexOf("[action"),V=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:V,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(te=>te.idx!==-1).sort((te,a)=>te.idx-a.idx);if(A.length>0){let te=A[0],a=T.substring(0,te.idx);te.idx>0&&K(a);let _e=te.idx>0?T[te.idx-1]:"";Zn=Zo||_e==="`",co=Pn,lo=!0,ht=te.type,An="",T=T.substring(te.idx)}else{let te=["[tool","[action","[[END]]","<|tool_calls_section_begin|>","<|tool_call_begin|>"],a=-1;for(let _e of te){for(let J=_e.length-1;J>0;J--)if(T.endsWith(_e.substring(0,J))){a=T.length-J;let v=te.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);K(J)}let _e=a>0?T[a-1]:"";Zn=Zo||_e==="`",co=Pn,lo=!0,An=T.substring(a),T=""}else{K(T);break}}}return S},La=Y[Symbol.asyncIterator]();for(;;){let{value:f,done:S}=await Promise.race([La.next(),st]);if(S)break;if(f&&f.type==="status"){yield f;continue}let T="",K=f.candidates?.[0]?.content?.parts;if(K&&K.length>0)for(let M of K){let V=typeof M.text=="string"?M.text:M.text?parseChunkText(M.text):"";M.thought?V&&(H||(T+="<think_fluxflow>",H=!0),T+=V):V&&(H&&(T+="</think_fluxflow>",H=!1),T+=V)}else f.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()-Ut),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:`
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:`
689
687
 
690
- \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(T){if(Qe){if(me+=T,me.length>=64){let y=0,A=Math.min(wt.length,me.length);for(let a=A;a>=10;a--)if(wt.endsWith(me.substring(0,a))){y=a;break}let te=me.substring(y);if(te){let _e=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(wt)?te.replace(/^\s*(?:<think_fluxflow>|\[think_fluxflow\])\s*/gi,""):te.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*mn();let J=ko(_e);for(let v of J)yield v}}Qe=!1,me=""}continue}else if(be+=T,s==="Google")pt+=T;else{yield*mn();let y=ko(T);for(let A of y)yield A}let M=Il(be);if(M.inside){_t=!0,Yn||(Yn=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,te=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=L(te,["basename","name","path","targetFile","directory","file","keyword","title","task","id","taskId","timeout","time","seconds","sec"]),v=J.basename||J.name||J.path||J.targetFile||J.TargetFile||J.directory||J.file,Ct=J.keyword,$n=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(En,"");else if(v)a=B.basename(String(v).replace(En,"").replace(da,"/"));else if($n&&(A==="invoke"||A==="invoke_sync"))a=String($n).replace(En,"").substring(0,30);else if(It&&A==="get_progress")a=String(It).replace(En,"");else if(ut&&A==="await"){let Ze=parseFloat(String(ut).replace(En,""));isNaN(Ze)?a=String(ut).replace(En,""):(Ze<5&&(Ze=5),Ze>120&&(Ze=180),a=(Mt=>{if(Mt>=60){let Ln=Math.floor(Mt/60),an=Mt%60;return`${Ln}m${an>0?` ${an}s`:""}`}return`${Mt}s`})(Ze))}else if(ut&&A==="wait"){let Ze=parseFloat(String(ut).replace(En,""));isNaN(Ze)?a=String(ut).replace(En,""):(Ze<10&&(Ze=10),Ze>120&&(Ze=120),a=(Mt=>{if(Mt>=60){let Ln=Math.floor(Mt/60),an=Mt%60;return`${Ln}m${an>0?` ${an}s`:""}`}return`${Mt}s`})(Ze))}else{let Ze=te.match(Sl);if(Ze){let se=Ze[1].replace(En,"");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!==Wt||a!==bo)&&(Wt=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-ao>800){ao=be.length;let y=ka(be,!1),A=Rs(y),te=A?(A.innerContent||"").trim():"",a=te.split(/[.!?]\s+/).filter(re=>re.trim().length>10),_e=new Set(a),J=a.length>25?(a.length-_e.size)/a.length:0,v=te.split(/\s+/).filter(re=>re.length>0).length,Ct=.9,$n=.92,It=!1;if(s.toLowerCase().includes("google")&&(ee||"").toLowerCase().startsWith("gemma")){let rt={low:2048,medium:4096,high:32768,max:65536,xhigh:65536}[d?.toLowerCase()]||16e3;It=v>rt}if(J>Ct||It){yield{type:"status",content:`${J>Ct?"Reasoning Loop Detected":"Thinking Budget Exceeded"}. Re-centering...`},Gt=!0,await new Promise(rt=>setTimeout(rt,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)>$n){yield{type:"status",content:"Response Loop Detected. Re-centering..."},Gt=!1,Ht=!0,await new Promise(re=>setTimeout(re,3e3));break}let an=y.replace(ml,"").replace(pl,"").replace(hl,"").replace(yl,""),On=an.toLowerCase().split(/\s+/).map(re=>re.replace(xl,"")).filter(re=>re.length>0),Ao=!1;if(On.length>=40)for(let re=1;re<=15;re++){let rt=Math.max(8,Math.ceil(25/re));if(On.length<re*rt)continue;let Nn=On.slice(On.length-re),c=Nn.join(" ");if(re>1&&c===Nn.slice(0,Math.floor(re/2)).join(" ").repeat(2).trim())continue;let C=!0;for(let _=1;_<rt;_++)if(On.slice(On.length-re*(_+1),On.length-re*_).join(" ")!==c){C=!1;break}if(C){Ao=!0;break}}if(!Ao){let re=an.toLowerCase().replace(wl,"");if(re.length>=80)for(let rt=1;rt<=10;rt++){let Nn=Math.max(15,Math.ceil(45/rt));if(re.length<rt*Nn)continue;let c=re.substring(re.length-rt),C=!0;for(let _=1;_<Nn;_++)if(re.substring(re.length-rt*(_+1),re.length-rt*_)!==c){C=!1;break}if(C){Ao=!0;break}}}if(Ao){yield{type:"status",content:"Stuttering Detected. Re-centering..."},Gt=!1,Jn=!0,await new Promise(re=>setTimeout(re,3e3));break}}let V=Kt(be),yt=jn(V);for(;yt.length>Et;){yield*mn();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=io(a,y.args);yield{type:"status",content:`${_e}${J?` ${J}`:""}`};let v="";if(a==="click"){let c=L(y.args,["intendedClickText"]);v=`\u2714 Clicked ${c.intendedClickText?`: ${c.intendedClickText}`:"Screen"}`}else if(a==="drag"){let c=L(y.args,["fromGridId","toGridId"]);v=`\u2714 Dragged: Cell ${c.fromGridId||""} \u2192 Cell ${c.toGridId||""}`}else if(a==="scroll"){let c=L(y.args,["direction","amount"]);v=`\u2714 Scrolled: ${c.direction||"down"} (${c.amount||1})`}else if(a==="keyboard_typing"){let c=L(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: ${L(y.args,["key"]).key||""}`;else if(a==="recapture_screen")v="\u2714 Recaptured Screen";else if(a==="web_search"){let{query:c,limit:C=10,aiMode:_=!1}=L(y.args,["query","limit","aiMode"]);v=`${c?"\u2714":"\u2718"} ${_?"AI Search":"Searched"}: ${c?`${c}`:"No Search Query"}${_===!1&&c?` \u2192 ${C}`:""}`}else if(a==="web_scrape"){let c=L(y.args,["url"]).url||null;v=`${c?"\u2714":"\u2718"} Visited: ${c||"No Source"}`}else if(a==="view_file"){let{path:c,StartLine:C,EndLine:_,start_line:ce,end_line:he,startLine:oe,endLine:ae}=L(y.args,["path","StartLine","EndLine","start_line","end_line","startLine","endLine"]),Re=C||ce||oe,Q=_||he||ae,z=parseInt(Re)||1,U=parseInt(Q)||(Re?z+800:800),fe="...",Ge=U,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:ye}=hn(c),ke=B.resolve(process.cwd(),ye);if(xe.existsSync(ke)){let ve=xe.readFileSync(ke,"utf8").split(`
691
- `).length;fe=ve,!Re&&!Q&&ve>800?Ge=Math.min(50,ve):Ge=Math.min(U,ve)}}catch{}let vt=(c||"").toLowerCase(),Co=vt.endsWith(".pdf"),Yt=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||Yt?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 ${z} - ${Ge} of ${fe}`:"File Not Found"}`:"File Not Found"}`}}else if(a==="list_files"||a==="read_folder"){let c=a==="list_files"?"List":"Browsed",C=L(y.args,["path","recurse","include"]).path||null,_=L(y.args,["path","recurse","include"]).recurse||1;v=`${C?"\u2714":"\u2718"} ${c}: ${C?`${C==="."?`./${_>1?"*":""}`:`${C.replaceAll("\\","/")}${_>1?`${C.endsWith("/")?"*":"/*"}`:`${C.endsWith("/")?"":"/"}`}`}`:"No Folder Selected"}`}else if(a==="find_file"){let c=L(y.args,["basename","name","path","file","query"]),C=c.basename||c.name||c.path||c.file||c.query||"";v=`${C?"\u2714":"\u2718"} Located: ${C||"No Query"}`}else if(a==="write_file"||a==="update_file"){let c=a==="write_file"?"Created":"Edited",C=L(y.args,["path","content","allowMultiple","searchContent*","replaceContent*","newContent*"]),_=C.path||null,he=Object.entries(C).some(([oe,ae])=>oe.startsWith("searchContent")&&typeof ae=="string"&&ae.startsWith("^LINE:"))?"\u1361":":";v=`${_?"\u2714":"\u2718"} ${c}${he} ${_?_.replaceAll("\\","/"):"No File Changes"}`}else if(a==="write_pdf"){let c=L(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=L(y.args,["path","content"]).path||null;v=`${c?"\u2714":"\u2718"} Generated: ${c.replaceAll("\\","/")||"No Docx Generated"}`}else if(a==="file_map"){let c=L(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:C,output:_}=L(y.args,["path","prompt","text","outputPath","output","ratio"]);v=`\u2714 Generated: ${c||C||_||"generated_image.png"}`}else if(a==="invoke_sync"||a==="InvokeSync"){let c=io(a,y.args);v=`\u2714 Called Generalist${c?`: ${c}`:""}`}else if(a==="Invoke"||a==="InvokeAsync"||a==="invoke"){let c=io(a,y.args);v=`\u2714 Started Generalist${c?`: ${c}`:""}`}else if(a==="get_progress"||a==="GetProgress"){let c=io(a,y.args);v=`\u2714 Checked${c?`: ${c}`:""}`}else if(a==="cancel"){let c=io(a,y.args);v=`\u{1F6C7} Cancelled${c?`: ${c}`:""}`}else if(a==="steer"||a==="Steer"){let c=io(a,y.args);v=`\u2714 Steered${c?`: ${c}`:""}`}else if(a==="EmergencyRollback"){let{method:c}=L(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:C,seconds:_,sec:ce}=L(y.args,["time","timeout","seconds","sec"]),he=parseFloat(_||ce||C||c)||45,oe=a==="wait"||a==="Wait"?120:180;he<10&&(he=10),he>oe&&(he=oe);let ae=z=>{if(z>=60){let U=Math.floor(z/60),fe=z%60;return`${U}m${fe>0?` ${fe}s`:""}`}return`${z}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(he)}`}else a==="Answer"||a==="answer"?v="\u2714 Resolved Sub-Agent Query":a==="exec_command"||a==="ask"?v="":v=`Executed: ${y.toolName}`;if(yield*mn(),a==="exec_command"){let{command:c}=L(y.args,["command","background","timeout","usePowershell","forcePowershell","useCwd","useCmd","forceCwd","forceCmd"]);if(c&&n.systemSettings&&n.systemSettings.allowExternalAccess===!1){let C=[/[a-zA-Z]:[\\\/]/i,/^\//,/\.\.[\\\/]/,/\/etc\//,/\/var\//,/\/root\//,/\/bin\//,/\/usr\//],_=B.resolve(process.cwd()).substring(0,3).toLowerCase(),ce=Q=>{let z=[],U="",fe=null;for(let Ge=0;Ge<Q.length;Ge++){let D=Q[Ge];fe?(D===fe&&(fe=null),U+=D):D==='"'||D==="'"?(fe=D,U+=D):D==="&"&&Q[Ge+1]==="&"||D==="|"&&Q[Ge+1]==="|"?(U.trim()&&(z.push(U.trim()),U=""),Ge++):D===";"||D==="|"||D==="&"?U.trim()&&(z.push(U.trim()),U=""):U+=D}return U.trim()&&z.push(U.trim()),z},he=Q=>{let z=[],U="",fe=null;for(let Ge=0;Ge<Q.length;Ge++){let D=Q[Ge];fe?(D===fe&&(fe=null),U+=D):D==='"'||D==="'"?(fe=D,U+=D):/\s/.test(D)?U&&(z.push(U),U=""):U+=D}return U&&z.push(U),z},oe=Q=>{let z=Q.replace(/^['"]|['"]$/g,"").trim();return!z||process.platform==="win32"&&/^\/[a-zA-Z0-9?]+$/.test(z)?!1:C.some(U=>{if(U.source==="[a-zA-Z]:[\\\\\\/]"){let fe=z.match(/[a-zA-Z]:[\\\/]/i);return fe&&fe[0].toLowerCase()!==_}return U.test(z)})};if(ce(c).some(Q=>{let z=he(Q);if(z.length===0)return!1;let U=z[0].replace(/^['"]|['"]$/g,"").toLowerCase();if(["echo","printf","write-output"].includes(U)){let Ge=!1;return z.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 z.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(z=>setTimeout(z,50)),n.onExecChunk&&n.onExecChunk(`ERROR: ${Q}`),await new Promise(z=>setTimeout(z,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"],$n=["path","targetPath","file","content","searchContent*","replaceContent*","newContent*","recurse","include","StartLine","EndLine","start_line","end_line","startLine","endLine"],It=Ct.includes(a)?L(y.args,$n):L(y.args),ut=It.path||It.targetPath||null;if(ut){let c=n.systemSettings&&n.systemSettings.allowExternalAccess===!1,C=B.resolve(ut),_=B.resolve(process.cwd());if(c&&!C.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(`${De?`
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?`
692
690
  `:""}${Q}
693
- `)},De=!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||{},C=c.autoExec,_=!1,ce="";if(a==="view_file"){let oe=L(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,z=!1;if(_)ae=!0,oe=null;else if(a==="exec_command"){let{command:Ie}=L(y.args,["command","background","timeout","usePowershell","forcePowershell","useCwd","useCmd","forceCwd","forceCmd"]),ye=(Ie||"").trim(),Le=(Oe=>{let ct=[],dt="",He=null;for(let Ee=0;Ee<Oe.length;Ee++){let q=Oe[Ee];He?(q===He&&(He=null),dt+=q):q==='"'||q==="'"?(He=q,dt+=q):q==="&"&&Oe[Ee+1]==="&"||q==="|"&&Oe[Ee+1]==="|"?(dt.trim()&&(ct.push(dt.trim()),dt=""),Ee++):q===";"||q==="|"||q==="&"?dt.trim()&&(ct.push(dt.trim()),dt=""):dt+=q}return dt.trim()&&ct.push(dt.trim()),ct.length>0?ct:[Oe]})(ye),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 q=He.charAt(Ee.length);return/\s|[;&|/]/.test(q)}return!1})},ze=Le.some(Oe=>ve(Oe,c.alwaysAskCommands)),Xt=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(Xt)oe="deny";else if(c.networkAccess===!1){let ct=ye.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"]),q=!1;Ee.has(He)&&(q=!0);let Nt=fo=>ct.slice(1).some(Rn=>fo.includes(Rn)),Cn=fo=>{let Rn=ct.findIndex(Dn=>fo.includes(Dn)),eo=ct.findIndex(Dn=>["run","exec","test"].includes(Dn));return Rn!==-1&&!(eo!==-1&&eo<Rn)};He==="git"&&Nt(["clone","pull","push","fetch"])&&(q=!0),He==="go"&&Nt(["get","install"])&&(q=!0),He==="npm"&&Cn(["install","i","update","add"])&&(q=!0),He==="yarn"&&Cn(["add","install","upgrade"])&&(q=!0),He==="pnpm"&&Cn(["add","install","update"])&&(q=!0),He==="bun"&&Cn(["add","install","update"])&&(q=!0),He==="deno"&&Nt(["install","add"])&&(q=!0),He==="pip"&&Nt(["install","download"])&&(q=!0),He==="pip3"&&Nt(["install","download"])&&(q=!0),He==="cargo"&&Nt(["install","add"])&&(q=!0),["bash","sh","zsh","fish"].includes(He)&&Nt(["-c"])&&(q=!0),He==="cmd"&&Nt(["/c"])&&(q=!0),q&&(oe="deny",Q=!0)}!oe&&ze?ae=!0:!oe&&!ae&&(qe||c.autoApproveGit&&/^git\s+commit\b/i.test(ye))&&(oe="allow"),!ae&&!oe&&C&&(oe="allow")}else if(a==="write_file"||a==="update_file"){let Ie=!1;if(a==="write_file"&&c.overwriteProtection!==!1&&C)try{let{path:ye}=L(y.args,["path","content"]);ye&&xe.existsSync(B.resolve(process.cwd(),ye))&&(Ie=!0,z=!0)}catch{}C&&!Ie&&(oe="allow")}let U=oe,fe="";oe==="deny"&&(Q?fe="network":Re?fe="settings":fe="prohibited");let Ge=!1,D="",Rt=[],vt=0,Co=!1,Yt="";if(!U&&n.onToolApproval)try{let Ie=await n.onToolApproval(a,y.args,{checkOnly:!0});z&&Ie==="allow"||(Ie==="allow"||Ie==="deny")&&(U=Ie,U==="deny"&&(fe="user"))}catch{}if(!U){if(!z&&(a==="write_file"||a==="update_file"))try{let ke=L(y.args,["path","content","searchContent*","replaceContent*","newContent*"]),{path:Le}=ke;if(Le){let{resolvedPath:ve}=hn(Le);Le=ve;let ze=B.resolve(process.cwd(),Le),Xt=Ee=>Ee?Ee.toLowerCase().replace(/\\/g,"/").replace(/^[a-z]:/,q=>q.toUpperCase()):"",qe=Xt(ze),Oe="",ct=!1,dt=await no(),He=Xt(dt?.file_focused);if(dt&&He===qe&&dt.full_content?(Oe=dt.full_content,ct=!0):xe.existsSync(ze)&&(Oe=xe.readFileSync(ze,"utf8"),ct=!0),D=Oe,await di.recordFileChange(ze,Oe),ct){let Ee=Oe;if(a==="write_file"){let q=ke.content||ke.newContent||"";Ee=q.endsWith(`
694
- `)?q:q+`
695
- `,Yt=Ee}else{let{patchPairs:q,allowMultiple:Nt,error:Cn}=Xi(ke);if(Cn){let Jt=`[ACTION RESULT]: ERROR: ${Cn}`;je.push({role:"user",text:Jt}),await $t("toolFailure"),n.onToolResult&&n.onToolResult("failure",a),yield{type:"tool_result",content:Jt,toolName:a},Et++;continue}let fo=ke.allowMultiple!==void 0?ke.allowMultiple===!0||String(ke.allowMultiple).toLowerCase()==="true":Nt;vt=q.length;let Rn=qs(Oe,q,{allowMultiple:fo});Ee=Rn.content,Yt=Ee,Rt=Rn.results;let eo=Rt.filter(Jt=>Jt.success),Dn=Rt.filter(Jt=>!Jt.success);if(eo.length===0){let Jt=`[ACTION RESULT]: ERROR: Failed to apply patches to [${B.basename(ze)}].
696
- ${Dn.map(Fn=>` \u2022 ${Fn.error}`).join(`
697
- `)}`,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),pn=`${ei.padEnd(Wi-2).substring(0,Wi-2)}`;yield{type:"visual_feedback",content:Lt(`${De?`
698
- `:""}${pn}`)},De=!1,je.push({role:"user",text:Jt}),await $t("toolFailure"),n.onToolResult&&n.onToolResult("failure",a),yield{type:"tool_result",content:Jt,toolName:a},Et++;continue}}yield{type:"status",content:`Opening Diff in IDE: ${B.basename(ze)}`},is(ze,Oe,Ee),Ge=!0,await new Promise(q=>setTimeout(q,50))}else if(a==="write_file"){let Ee=ke.content||ke.newContent||"",q=Ee.endsWith(`
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*"]),{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
+ `)?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)}].
694
+ ${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
697
  `)?Ee:Ee+`
700
- `;Yt=q,xe.existsSync(ze)||(Co=!0,xe.mkdirSync(B.dirname(ze),{recursive:!0}),xe.writeFileSync(ze,"","utf8")),yield{type:"status",content:`Opening New File Diff in IDE: ${B.basename(ze)}`},is(ze,"",q),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 ye=n.onToolApproval;if(U=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 ye(a,y.args,{isOverwritePrompt:z});clearInterval(Le),ke(ve)}catch{clearInterval(Le),ke("deny")}}),os(null),a==="write_file"||a==="update_file"){let ke=L(y.args,["path","content","searchContent*","replaceContent*","newContent*"]),{path:Le}=ke;if(Le){let{resolvedPath:ve}=hn(Le);Le=ve;let ze=B.resolve(process.cwd(),Le);if(br(ze,U),U==="deny"&&Co&&xe.existsSync(ze))try{xe.unlinkSync(ze)}catch{}}}U==="deny"&&(fe="user")}if(U==="allow"&&Ge&&xo()){let Ie=L(y.args,["path","content","searchContent*","replaceContent*","newContent*"]),{path:ye}=Ie,{resolvedPath:ke,isTildeResolved:Le}=hn(ye);ye=ke;let ve=B.resolve(process.cwd(),ye),ze=Ke=>Ke?B.resolve(Ke).replace(/\\/g,"/").toLowerCase():"",Xt=await no(),qe="";if(Xt&&Xt.file_focused&&ze(Xt.file_focused)===ze(ve)&&Xt.full_content&&(qe=Xt.full_content),!qe&&xe.existsSync(ve)){let Ke=xe.readFileSync(ve,"utf8");Ke&&(qe=Ke)}!qe&&Yt&&(qe=Yt),(qe||Co)&&xe.writeFileSync(ve,qe,"utf8");let Oe=qe.split(/\r?\n/),ct=Oe.length,dt=Buffer.byteLength(qe,"utf8"),He="";D&&(He=`Old File contents:
701
- ${D.split(/\r?\n/).map((ot,ln)=>`${ln+1} | ${ot}`).join(`
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*"]),{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*"]),{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
700
  `)}
703
701
 
704
702
  `);let Ee="";if(ct<=100)Ee=Oe.join(`
@@ -708,89 +706,89 @@ ${D.split(/\r?\n/).map((ot,ln)=>`${ln+1} | ${ot}`).join(`
708
706
 
709
707
  ... [${ct-100} lines truncated for history stability] ...
710
708
 
711
- ${ot}`}let q="";if(a==="update_file"){let Ke=Xs(D,qe,Rt,12,n?.compressToolResults||Vo?.systemSettings?.compressToolResults),{patchPairs:ot}=Xi(L(y.args,["path","searchContent*","replaceContent*","newContent*"])),ln=ot?.length||vt||1,Pt=0,Qt=0,Bn=[];ot&&ot.length>0?ot.forEach((Wn,mo)=>{let po=Wn.replace||"",cn=Wn.new||"",Gi=po.trim(),Eo=cn.trim(),Wa=!!Yt&&qe===Yt,Ga=Eo?qe.includes(cn)||qe.includes(Eo):!0,Ha=cn?D.includes(cn)||!!Eo&&D.includes(Eo):!1,ja=Gi?qe.includes(po)||qe.includes(Gi):!1;Wa||!!cn&&Ga&&(!Ha||!ja||Gi===Eo)?Pt++:(Qt++,Bn.push(` \u2022 Block ${mo+1}: not applied (reverted or rejected in IDE).`))}):Pt=vt||0;let vn=0;if(Yt&&qe!==Yt){let Wn=ul("","",Yt||"",qe||"","","",{context:0});if(Wn&&Wn.hunks)for(let mo of Wn.hunks){let po=mo.lines.filter(cn=>cn.startsWith("+")).map(cn=>cn.slice(1).trim()).filter(Boolean);for(let cn of po)D.includes(cn)||vn++}}let vo=[`[${Pt}/${ln}] applied`];Qt>0&&vo.push(`${Qt} rejected by user`),vn>0&&vo.push(`${vn} manual ${vn===1?"modification":"modifications"} by user`);let uo=vo.join(", "),Un=Bn.length>0?`
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?`
712
710
 
713
711
  User Review Details:
714
- ${Bn.join(`
715
- `)}`:"";q=`File [${ye}] updated via IDE Companion. ${uo}.${Un}
712
+ ${Wn.join(`
713
+ `)}`:"";Y=`File [${xe}] updated via IDE Companion. ${fo}.${Gn}
716
714
 
717
715
  ${Ke}${Le?`
718
716
 
719
- [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:ye})}else{let Ke=qe.split(/\r?\n/),ot=Ke.length,ln=Buffer.byteLength(qe,"utf8"),Pt="",Qt=c?.overwriteProtection!==!1;if(D){let uo=D.split(/\r?\n/);if(!Qt)Pt="";else if(uo.length<=50)Pt=`Old File contents:
720
- ${uo.map((Un,go)=>`${go+1} | ${Un}`).join(`
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:
718
+ ${fo.map((Gn,uo)=>`${uo+1} | ${Gn}`).join(`
721
719
  `)}
722
720
 
723
- `;else{let Un=B.parse(ve),go=B.join(ii,"OverwriteBackups");if(!xe.existsSync(go))try{xe.mkdirSync(go,{recursive:!0})}catch{}let ti=String(Date.now()).slice(-5),ni=wa.randomBytes(2).toString("hex"),Wn=`${Un.name}-old-${ti}-${ni}${Un.ext}.bak`,mo=B.join(go,Wn);try{xe.writeFileSync(mo,D,"utf8")}catch{}Pt=`Old File contents:
724
- - Renamed old file as ${mo.replaceAll("\\","/").replace(xa.homedir().replaceAll("\\","/"),"~")} and written requested content in ${ye}. For reversal use Run
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:
722
+ - Renamed old file as ${go.replaceAll("\\","/").replace(xa.homedir().replaceAll("\\","/"),"~")} and written requested content in ${xe}. For reversal use Run
725
723
 
726
- `}}let Bn="";if(ot<=690)Bn=Ke.join(`
727
- `);else{let uo=Ke.slice(0,300).join(`
728
- `),Un=Ke.slice(-300).join(`
729
- `);Bn=`${uo}
724
+ `}}let Wn="";if(ot<=690)Wn=Ke.join(`
725
+ `);else{let fo=Ke.slice(0,300).join(`
726
+ `),Gn=Ke.slice(-300).join(`
727
+ `);Wn=`${fo}
730
728
 
731
729
  ... [${ot-100} lines truncated] ...
732
730
 
733
- ${Un}`}let vn=Le?`
731
+ ${Gn}`}let vn=Le?`
734
732
 
735
- [Note: '~' resolved to user home directory. To target literal '~' in current directory, escape it as '\\~']`:"";q=`File [${ye}] saved via IDE Companion (May have user edits).
736
- - Stats: [${ot} lines, ${(ln/1024).toFixed(1)} KB]
733
+ [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]
737
735
  ${Pt}- Content Preview:
738
736
 
739
- ${Bn}${vn}`;let vo=D?D.split(/\r?\n/).length:0;await zi({added:ot,removed:vo,file:ye})}let Nt=a==="write_file"?"Created":"Edited",Cn=L(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":":",eo=`${ye?"\u2714":"\u2718"} ${Nt}${Rn} ${ye?ye.replaceAll("\\","/"):"No File Changes"}`,Dn=115;process.stdout.isTTY&&(Dn=process.stdout.columns-5||120);let Jt=Math.min(eo.length+4,Dn),ei=`${eo.padEnd(Jt-2).substring(0,Jt-2)}`;yield{type:"visual_feedback",content:Lt(`${De?`
740
- `:""}${ei}`)},De=!1;let Ro=Date.now();Xn=Ro,yield{type:"tool_time",content:Ro-A};let pn=(q||"").toString().replaceAll("\u2550".repeat(88),"=".repeat(35)).replaceAll("[UI_CONTEXT]","");pn.includes("[[VERIFIED]]")&&(pn=pn.replace(/\[\[VERIFIED\]\][\s\S]*?\[\[\/VERIFIED\]\]/g,`[SYSTEM NOTE]: Patch Block matched & applied successfully. Large Block omitted to conserve context.
741
- `));let Fn;if(a==="write_file"&&!pn.startsWith("ERROR:")){let Ke=pn.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*$/),ln=ot?`
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?`
742
740
 
743
- ${ot[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(Ke)){let Pt=Ke.search(/^- Content Preview:/m);Fn=`[ACTION RESULT]: ${Pt!==-1?Ke.slice(0,Pt).trimEnd():Ke}
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}
744
742
 
745
- [Old file content for reversal reference. Replaced with new write request]${ln}`}else{let Pt=Ke.split(/\r?\n/),Qt=Pt.filter(vn=>vn.startsWith("File ")||vn.trim().startsWith("- Stats:"));Fn=`[ACTION RESULT]: ${Qt.length>0?Qt.join(`
743
+ [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(`
746
744
  `):Pt.slice(0,2).join(`
747
- `)}${ln}`}}else if(pn.startsWith("[[SAME]]")){let ot=pn.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),ln=ot.filter(Qt=>Qt.startsWith("File ")||Qt.trim().startsWith("- Stats:"));Fn=`[ACTION RESULT]: ${ln.length>0?ln.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(`
748
746
  `):ot.slice(0,2).join(`
749
- `)}`}else Fn=`[ACTION RESULT]: ${pn}`;je.push({role:"user",text:Fn}),In=!0,await $t("toolSuccess"),n.onToolResult&&n.onToolResult("success",a),yield{type:"tool_result",content:q,aiContent:Fn,toolName:a},Et++;continue}if(U==="deny"){let Ie=`Permission Denied: Prohibited ${a==="exec_command"?"Command":"file edit"}.`;if(_?Ie=`User denied reading ${B.basename(ce||".env")}`:z&&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 ye=`\u2718 Read Denied: ${L(y.args,["path","targetPath","file"]).path?.replaceAll("\\","/")||".env"}`,ke=115;process.stdout.isTTY&&(ke=process.stdout.columns-5||120);let Le=Math.min(ye.length+4,ke),ve=`${ye.padEnd(Le-2).substring(0,Le-2)}`;yield{type:"visual_feedback",content:Lt(`${De?`
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?`
750
748
  `:""}${ve}
751
- `)},De=!1}else if(a==="write_file"||a==="update_file"){let ke=`\u2718 ${a==="write_file"?"Write Cancelled":"Edit Denied"}: ${L(y.args,["path","content","searchContent*","replaceContent*","newContent*"]).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)}`,Xt=` ${" ".repeat(ve)} `;yield{type:"visual_feedback",content:Lt(`${De?`
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*"]).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?`
752
750
  `:""}${ze}
753
- `)},De=!1}a==="exec_command"&&(await new Promise(ye=>setTimeout(ye,50)),n.onExecChunk&&n.onExecChunk(`ERROR: ${Ie}`),await new Promise(ye=>setTimeout(ye,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 C=!1,_=Math.min(v.length+4,c),ce=`${v.padEnd(_-2).substring(0,_-2)}`;yield{type:"visual_feedback",content:Lt(`${De?`
754
- `:""}${ce}${v.includes("\u2714")&&(v.includes("Created")||v.includes("Edited"))?"":`${C?"":`
755
- `}`}`)},De=!1}if(Xn>0){let c=Date.now()-Xn,C=Math.max(0,1e3-c);C>0&&await new Promise(_=>setTimeout(_,C))}let Ze={chatId:u,history:t,onChunk:c=>n.onExecChunk?n.onExecChunk(c):null,onAskUser:n.onAskUser,systemSettings:n.systemSettings,mode:l,isMultiModal:at(ee),onVisualFeedback:n.onVisualFeedback,onSubagentUpdate:n.onSubagentUpdate,onTokenChunk:n.onTokenChunk,modelName:ee,aiProvider:n.aiProvider,apiKey:n.apiKey,onUsage:n.onUsage};if(a==="write_file"||a==="update_file")try{let{path:c}=L(y.args,["path","content","searchContent*","replaceContent*","newContent*"]);if(c){let C=B.resolve(process.cwd(),c),_=await no();_&&_.file_focused===C&&_.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}=L(y.args,["path","content","searchContent*","replaceContent*","newContent*"]);if(c){let{resolvedPath:C}=hn(c),_=B.resolve(process.cwd(),C);wr(_)}}process.stdout.isTTY&&process.stdout.write("\x1B]0;Working...\x07");let Mt=Date.now();Xn=Mt,yield{type:"tool_time",content:Mt-A},Yn=Mt;let Ln=null;if(typeof se=="object"&&se.binaryPart&&(Ln=se.binaryPart,se=se.text),a==="search_keyword"){let{keyword:c,path:C}=L(y.args,["keyword","path","fuzzy","subString","regex"]),_=typeof se=="string"&&se.startsWith("[GLOB]");_&&(se=se.slice(6).trimStart());let ce=typeof se=="string"&&se.startsWith("[DIR]");ce&&(se=se.slice(5).trimStart());let he=0;if(se){let D=se.match(/Found (\d+) match/i);D&&(he=parseInt(D[1]))}let oe=(C||"").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 z=Math.max(10,(Q+5)/3),U=Math.max(10,(Q+5)/4);if(ae)Re=`${c?"\u2714":"\u2718"} Searched Documentation`;else{let D=C?C.replace(/[\/\\]+$/,""):null,Rt=D&&D!=="."?`${_?C:ce?`${D}/*`:D}`:"./",vt=Rt.length>U?`${Rt.slice(0,U)}...`:Rt;Re=`${c?"\u2714":"\u2718"} Searched: "${c?c.length>Q/3?`${c.slice(0,z)}...`:c:""}" in "${vt.replaceAll("\\","/")}" \u2192 ${he} Match${he===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(`${De?`
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?`
752
+ `:""}${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*"]);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*"]);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?`
756
754
  `:""}${Ge}
757
- `)},De=!1}if(a==="EmergencyRollback"){let{method:c}=L(y.args,["method","id"]);if(c==="forceRevert"){let C=0;if(se){let Q=se.match(/Total\s*:\s*(\d+)/i);Q&&(C=parseInt(Q[1]))}let ce=se&&se.startsWith("ERROR:")?"\u2718 Emergency Rollback Failed":`\u2714 Emergency Rollback \u2192 ${C} file${C===1?"":"s"} processed`,he=115;process.stdout.isTTY&&(he=process.stdout.columns-5||120);let oe=!1,ae=Math.min(ce.length+4,he),Re=`${ce.padEnd(ae-2).substring(0,ae-2)}`;yield{type:"visual_feedback",content:Lt(`${De?`
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?`
758
756
  `:""}${Re}${oe?"":`
759
- `}`)},De=!1}}if(a==="todo"){let{method:c,tasks:C,markDone:_}=L(y.args,["method","tasks","markDone"]),ce="",he=[],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 z=Q.match(/"([^"\\]*(?:\\.[^"\\]*)*)"|'([^'\\]*(?:\\.[^'\\]*)*)'/g);z?Re=z.map(U=>U.slice(1,-1).replace(/\\(.)/g,"$1")):Re=Q.slice(1,-1).split(",").map(U=>U.trim()).filter(Boolean)}else Re=ae.split(`
760
- `)}return Re.filter(Q=>String(Q).trim()).map(Q=>{let z=String(Q).trim();return z.startsWith("- [")?z.substring(6).trim():z})};if(c==="create"?(ce="\x1B[32m\u2192\x1B[0m Created Goals",he=oe(C).map(ae=>`\x1B[90m\u25CB\x1B[0m ${ae}`)):c==="append"?(ce="\x1B[34m\u2795\x1B[0m Added New Goals",he=oe(C).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",he=(se||"").split(`
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
759
  `).slice(1).join(`
762
760
  `).split(`
763
- `).filter(Re=>Re.trim().startsWith("- [")).map(Re=>{let Q=Re.trim(),z=Q.startsWith("- [x]");return`${z?"\x1B[32m\u2714\x1B[0m":"\x1B[90m\u25CB\x1B[0m"} ${z?"\x1B[90m":"\x1B[37m"}${Q.substring(6).trim()}\x1B[0m`})),ce&&he.length>0){let ae=[`${ce}`,...he.map(Q=>` ${Q}`)].join(`
764
- `);yield{type:"visual_feedback",content:Lt(`${De?`
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
763
  `:""}${ae}${!1?"":`
766
- `}`)},De=!1}}a==="exec_command"&&n.onExecEnd&&(await new Promise(c=>setTimeout(c,800)),n.onExecEnd());let an=se&&se.startsWith("DENIED:");se&&!se.startsWith("ERROR:")&&!an?(await $t("toolSuccess"),n.onToolResult&&n.onToolResult("success",a)):an||(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.
767
- `));let rt;if(a==="write_file"&&!re.startsWith("ERROR:")){let c=re.replace(/^\[\[SAME\]\]\s*\r?\n?/,""),C=c.match(/\n\s*(\[Note:\s*'~'\s*resolved\s*to\s*user\s*home\s*directory[\s\S]*?\])\s*$/),_=C?`
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
766
 
769
- ${C[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(c)){let ce=c.search(/^- Content Preview:/m);rt=`[ACTION RESULT]: ${ce!==-1?c.slice(0,ce).trimEnd():c}
767
+ ${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}
770
768
 
771
- [Old file content for reversal reference. Replaced with new write request]${_}`}else{let ce=c.split(/\r?\n/),he=ce.filter(ae=>ae.startsWith("File ")||ae.trim().startsWith("- Stats:"));rt=`[ACTION RESULT]: ${he.length>0?he.join(`
769
+ [Old file content for reversal reference. Replaced with new write request]${_}`}else{let ce=c.split(/\r?\n/),ye=ce.filter(ae=>ae.startsWith("File ")||ae.trim().startsWith("- Stats:"));at=`[ACTION RESULT]: ${ye.length>0?ye.join(`
772
770
  `):ce.slice(0,2).join(`
773
- `)}${_}`}}else if(re.startsWith("[[SAME]]")){let C=re.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),_=C.filter(he=>he.startsWith("File ")||he.trim().startsWith("- Stats:"));rt=`[ACTION RESULT]: ${_.length>0?_.join(`
774
- `):C.slice(0,2).join(`
775
- `)}`}else rt=`[ACTION RESULT]: ${re}`;je.push({role:"user",text:rt,binaryPart:Ln}),In=!0;let Nn=`[ACTION RESULT]: ${se.replaceAll(`[[VERIFIED]]
771
+ `)}${_}`}}else if(re.startsWith("[[SAME]]")){let R=re.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),_=R.filter(ye=>ye.startsWith("File ")||ye.trim().startsWith("- Stats:"));at=`[ACTION RESULT]: ${_.length>0?_.join(`
772
+ `):R.slice(0,2).join(`
773
+ `)}`}else at=`[ACTION RESULT]: ${re}`;je.push({role:"user",text:at,binaryPart:Nn}),Pn=!0;let Fn=`[ACTION RESULT]: ${se.replaceAll(`[[VERIFIED]]
776
774
  `,"").replaceAll(`
777
- [[/VERIFIED]]`,"")||""}`;(a==="view_file"||a==="web_scrape"||a==="file_map"||a==="search_keyword"||a==="get_progress"||a==="getprogress")&&(Nn=`[ACTION RESULT]: ${v} (Context Locked for UI Clarity)`),yield{type:"tool_result",content:Nn,aiContent:rt,binaryPart:Ln,toolName:a},a==="memory"&&!se.startsWith("ERROR:")&&(yield{type:"memory_updated"}),Et++}if(s==="Google"&&pt&&Date.now()-Qo>=150){yield*mn();let y=ko(pt);for(let A of y)yield A;pt="",Qo=Date.now()}}f.usageMetadata&&(on=f.usageMetadata),on&&(yield{type:"liveTokens",content:on.totalTokenCount})}if(H&&(H=!1,Qe?me+="</think_fluxflow>":(be+="</think_fluxflow>",s==="Google"?pt+="</think_fluxflow>":yield{type:"text",content:"</think_fluxflow>"})),Qe&&me.length>0){let f=0,S=Math.min(wt.length,me.length);for(let K=S;K>0;K--)if(wt.endsWith(me.substring(0,K))){f=K;break}let T=me.substring(f);if(T){let ie=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(wt)?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*mn();let M=ko(ie);for(let V of M)yield V}}Qe=!1,me=""}if(An){let f=An,S=(ht==="tool"||ht==="action")&&(f.startsWith("[tool:")||f.startsWith("[action:"));An="",lo=!1,ht=null,Zn=!1,co=!1,S||(s==="Google"?pt+=f:yield{type:"text",content:f})}if(yield*mn(),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||Wt!==null,Ui=Kt(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:`
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:`
778
776
 
779
- \x1B[33m\u24D8 Request Cancelled\x1B[0m`};break}if(String(X).includes("Incomplete JSON segment at the end")){H&&(H=!1,Qe?me+="</think_fluxflow>":(be+="</think_fluxflow>",yield{type:"text",content:"</think_fluxflow>"})),Se=!0,await $t("agent",s);break}if(H&&(H=!1,Qe?me+="</think_fluxflow>":be+="</think_fluxflow>"),Qe&&me.length>0){let bt=0,nt=Math.min(wt.length,me.length);for(let qt=nt;qt>0;qt--)if(wt.endsWith(me.substring(0,qt))){bt=qt;break}let mt=me.substring(bt);if(mt){let st=/(?:<think_fluxflow>|\[think_fluxflow\])(?:(?!(?:<\/think_fluxflow>|\[\/think_fluxflow\]))[\s\S])*$/i.test(wt)?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,"");st&&(be+=st)}Qe=!1,me=""}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(to,"agent");xe.existsSync(de)||xe.mkdirSync(de,{recursive:!0}),xe.appendFileSync(B.join(de,"error.log"),`ERROR [${gt}]: ${E}
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}
780
778
 
781
779
  ----------------------------------------------------------------------
782
780
 
783
- `);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($e<gn-3)throw X;yield{type:"text",content:E},yield{type:"status",content:"Error Occured"}}if(be.trim().length>0||tt>1)if(tt<=gn){tt++;let bt=Math.min(1e3*Math.pow(2,tt-1),24e3);if(be.trim().length>0){x.push({role:"agent",text:be});let nt=`[system]
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]
784
782
  - seamless continuation: resume immediately. pick up from last words with zero gap/disruption
785
783
  - no repetition: do not repeat any text already written
786
784
  - 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
787
785
  - mid-tool safety: if cutoff was mid-tool call, restart that tool call from start
788
- - stealth: do not mention/apologize for cutoff [/system]`;je.length>0?je.forEach((mt,qt)=>{qt===je.length-1?x.push({...mt,text:`${mt.text}
786
+ - 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}
789
787
 
790
- ${nt}`}):x.push(mt)}):x.push({role:"user",text:nt}),wt+=be}for(let nt=bt/1e3;nt>0&&!xt;nt--)yield{type:"status",content:`Error Occured. Recovering Stream (${tt}/${gn}) [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 ${gn} times)
791
- Error log can be found in \`/export logs\``);else{let nt=e.split("/").slice(e.endsWith("/free")?-2:-1).join("/");if($e<=gn){$e++,tt=1,wt="";let mt=Math.min(1e3*Math.pow(2,$e-1),32e3),qt=.8+Math.random()*.4,st=Math.round(mt*qt);Mn=!0,yield{type:"status",content:`Trying to reach ${nt} (${$e}/${gn}) [Retrying in ${(st/1e3).toFixed(0)}s]`};for(let Fe=st/1e3;Fe>0&&!xt;Fe--)yield{type:"status",content:`Trying to reach ${nt} (${$e}/${gn}) [Retrying in ${Fe.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 ${gn} times)
792
- Error log can be found in \`/export logs\``)}}}if(on){let H=on.totalTokenCount||0,X=on.cachedContentTokenCount||0,E=(on.candidatesTokenCount||0)+(s==="Google"&&on.thoughtsTokenCount||0);await xn("tokens",H,s,ee),X>0&&await xn("cachedTokens",X,s,ee),E>0&&await xn("candidateTokens",E,s,ee),Tt!==null&&Tt>0&&await xn("ttft",Tt,s,ee),ci({provider:s,model:ee,prompt:on.promptTokenCount||0,cached:X,output:E,reasoning:on.thoughtsTokenCount||0,ttft:Tt}),yield{type:"usage",content:on}}else Tt!==null&&Tt>0&&(await xn("ttft",Tt,s,ee),ci({provider:s,model:ee,prompt:0,cached:0,output:0,reasoning:0,ttft:Tt}));be=ba(be),Di.push(be);let Ll=Kt(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||jn(Kt(be)).length>0,Qn=(_a||je.length===0)&&!Gt&&!Jn&&!Ht;if(Qn=je.length===0?Qn:!1,Qn=Ma&&_t||Jo?!1:Qn,be&&be.trim().endsWith('")]')&&je.length===0&&(Qn=!1),Qn){Us=!0;let H=Di.join(`
793
- `),X=Kt(H).trim();yield{type:"interactive_turn_finished",data:{agentText:Ne,fullAgentTextRaw:H,history:[...x],needTitle:Ae}},x.length>0&&x[x.length-1].role==="agent"?x[x.length-1].text=X:x.push({role:"agent",text:X}),x.forEach(E=>{if(E.role==="user"&&E.text&&(E.text=E.text.replace(/\n\[COMPILE ERROR\][\s\S]*?\[\/ERROR\]/g,""),E.text=E.text.replaceAll(`
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(`
794
792
 
795
793
  [system] user question. resolve this specific query within '[ANSWER] ... [/ANSWER]' concisely, naturally [/system]
796
794
  `,"").replaceAll(`[system] user question. resolve this specific query within '[ANSWER] ... [/ANSWER]' concisely, naturally
@@ -798,35 +796,36 @@ Error log can be found in \`/export logs\``)}}}if(on){let H=on.totalTokenCount||
798
796
  `,"").replaceAll(`[system] **strictly follow thinking policy as high priority. do not start a response without <think_fluxflow>...</think_fluxflow>** [/system]
799
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=`
800
798
  [system] Action result received. Analyze output and proceed with your turn [/system]`,We=`
801
- [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(Qn)break;let Pa=Ia.trim()||"*Working...*";if(x.push({role:"agent",text:Pa}),je.length>0||In){if(je.length>0){let H=je.map(st=>st.text).join(`
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(`
802
800
 
803
- `),X=Kt(be),E=jn(X),gt=ma(X,E),de=Ii(gt),We=/\[\s*(?:tool:(?:functions\.)?|action:(?:functions\.)?|action:)([a-zA-Z0-9_]+)\s*\(/gi,At=[],ge=[],bt;for(;(bt=We.exec(de))!==null;)ge.push({index:bt.index,toolName:bt[1]});for(let st=0;st<ge.length;st++){let Fe=ge[st],pt=st+1<ge.length?ge[st+1].index:X.length;E.some(mn=>mn.fullMatch&&X.startsWith(mn.fullMatch,Fe.index))||At.push(X.substring(Fe.index,pt))}let nt=At.length,mt=je.length+nt;if(nt>0){let st=At.join(`
804
- `),Fe=ha(st);H+=`
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
803
 
806
804
  [system] Only ${je.length} out of ${mt} attempted tool calls were executed.
807
- ${Fe?`Parsing Issues Detected:
808
- ${Fe}
809
- `:""}Verify proper structure compliance [action:ActionName(arg="value")] & try failed calls again [/system]`;for(let pt=0;pt<nt;pt++)await $t("toolFailure")}let qt=je.find(st=>st.binaryPart)?.binaryPart||null;x.push({role:"user",text:H,binaryPart:qt})}}else if(!xt){let H=be.replace(/(?:<think_fluxflow>|\[think_fluxflow\])[\s\S]*?(?:<\/think_fluxflow>|\[\/think_fluxflow\]|$)/i,""),X=jn(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:
810
- ${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]`;x.push({role:"user",text:At}),await $t("toolFailure"),yield{type:"visual_feedback",content:`
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:`
811
809
  ${Lt("\u2718 Model produced malformed tool call")}
812
810
  `}}else yield{type:"visual_feedback",content:`
813
811
  ${Lt("\u2718 Loop Detected")}
814
- `},x.push({role:"user",text:`[system] ${Jn&&!Gt?"Stuttering Detected by Internal System. Re-calibrate your response & proceed.":`${Gt?" Over Thinking":" Loop"} Detected by Internal System${Gt?" for current Effort Level":""}. ${Gt?"If you have planned the task, prioritize execution/output":"If you have finished your task provide a simple summary and end"}`} [/system]`});Gt=!1,Jn=!1,Ht=!1}p?.advanceRollback&&await Mo.recordTurnDelta(u,b+1,le),Fi=le.includes("recapture_screen"),Jo=Et>0||In}if(!Us&&!xt){let b="\u2726 Turn safety limit reached. Stopping execution.";yield{type:"text",content:`
812
+ `},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:`
815
813
 
816
814
  ${b}
817
815
  `};let ue=(Di.join(`
818
816
  `)+`
819
- ${b}`).trim();yield{type:"interactive_turn_finished",data:{agentText:Ne,fullAgentTextRaw:ue,history:[...x],needTitle:Ae}},yield{type:"status",content:"[end]"}}}catch(G){let x=G?.cause?` (Cause: ${G.cause?.message||String(G.cause)})`:"",pe=(G instanceof Error?(()=>{try{return JSON.parse(JSON.parse(G.message).error.message).error.message}catch{return(G.message?`${G.message}${x}`:"")||String(G)}})():String(G)).replace(/^(Error:\s*)+/i,"");s==="Google"&&!/^[A-Z0-9_\-\s]+ ERROR:/i.test(pe)&&(pe=`GEMINI ERROR: ${pe}`);let Vt=new Date().toLocaleString(),tn=B.join(to,"agent");yield{type:"text",content:`
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:`
820
818
 
821
- \u2726 CRITICAL ERROR: ${pe.includes("fetch failed")?"Failed to Connect. Check your Internet Connection or Wait a moment":pe}
822
- \u2800`},xe.existsSync(tn)||xe.mkdirSync(tn,{recursive:!0}),xe.appendFileSync(B.join(tn,"error.log"),`CRITICAL ERROR [${Vt}]: ${G}${G?.cause?`
823
- CAUSE: ${G.cause?.stack||G.cause}`:""}
819
+ \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
822
 
825
823
  ----------------------------------------------------------------------
826
824
 
827
- `),typeof flushGoogleBuffer=="function"&&(yield*flushGoogleBuffer()),yield{type:"tool_result",content:`ERROR: [INTERNAL CRITICAL] ${pe}`}}finally{et&&(clearInterval(et),et=null),typeof performance<"u"&&performance.clearMeasures&&(performance.clearMeasures(),performance.clearMarks()),await di.commitTransaction(),p?.advanceRollback&&await Mo.cleanup(u),await no()}yield{type:"status",content:null}},rf=async(e,t,n=null,i=null,o=null,r=null,d=!1,l=null)=>{let g=await li(),u={...g,...t},h=typeof o=="number"&&o>0?o:50,p=(u?.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 m=process.env.SUBAGENT_MODEL?process.env.SUBAGENT_MODEL.trim():null,s=process.env.SUBAGENT_PROVIDER?process.env.SUBAGENT_PROVIDER.trim():null,w=new Date,I=`${w.getFullYear()}-${w.toLocaleString("en-US",{month:"short"}).toUpperCase()}-${String(w.getDate()).padStart(2,"0")}, ${w.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hour12:!0}).replace(":","-")}`,R=(Me=>{if(!Me)return null;let ne=Me.toLowerCase();return ne==="google"?"Google":ne==="deepseek"?"DeepSeek":ne==="openrouter"?"OpenRouter":ne==="nvidia"?"NVIDIA":ne==="mistral"?"Mistral":ne==="ollama"?"Ollama":ne==="inferx"?"InferX":ne==="sensenova"?"SenseNova":ne==="poolside"?"Poolside":ne==="9router"||ne==="9Router"?"9router":ne==="aihubmix"||ne==="aihub"?"AIHubMix":ne==="explabs"||ne==="experientiallabs"||ne==="experimentallabs"?"ExpLabs":ne==="tokenharbor"||ne==="token harbor"||ne==="token_harbor"||ne==="thk"?"TokenHarbor":ne==="infron"?"Infron":ne==="apinex"||ne==="apx"?"APInex":ne==="xkiro"||ne==="kiro"?"xKiro":ne==="c_openai"||ne==="custom_openai"||ne==="custom (openai)"||ne==="custom"?"c_openai":null})(s),O=u?.systemSettings?.CustomSubAgent?u?.systemSettings?.SubAgentModel:null,F=u?.systemSettings?.CustomSubAgent?u?.systemSettings?.SubAgentProvider:null,W=null;if(O==="ENV"?(W=m,m&&R&&(u.aiProvider=R)):O&&O!=="Default"?(W=O,F&&(u.aiProvider=F)):m&&R&&(u.aiProvider=R),u.aiProvider){let Me=await zs(u.aiProvider);Me&&(u.apiKey=Me)}let P=Me=>{if(!Me||typeof Me!="string")return{allowed:!0};let ne=[/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 ne)if(Ve.test(Me))return{allowed:!1,reason:`Blocked potentially destructive or unsafe command pattern: "${Ve.source}"`};return{allowed:!0}},$=n||W||t?.modelName||t?.activeModel||g.activeModel,Ae=(process.platform==="win32"?"Windows":process.platform==="darwin"?"macOS":"Linux")==="Windows",Ne=Ae&&u?.systemSettings?.preferBash!==!1&&Js(),et="Run(command=string)",G=`Runs ${Ae?Ji()?"powershell":"windows CMD":"bash"} command`;Ne&&(et=`Run(command=string, ${Qs()||Ji()?"forcePowershell?=bool:false":"forceCwd?=bool:false"})`,G="Runs in git bash. Or force native shell");let x=`-- ACTIONS (path = relative to CWD, path separator: '/') --
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: '/') --
828
826
  In chat output the format \`[action:ActionName(arg1="value1")]\` in NEW line
829
827
  Rules:
828
+ - Max 3 actions/turn
830
829
  - JSON escape literal sequences, backslash: \\\\, newLine: \\ n
831
830
  - Same file, multiple edits? ONE PatchFile \u226415 blocks
832
831
  - Need text or huge file? CodeSearch > Full Read
@@ -848,12 +847,11 @@ ${d?"- AskMain(question=string). Communicate with PARENT/MAIN AGENT. When clarif
848
847
  - ReadFile(path=string, startLine?=int, endLine?=int)
849
848
  - 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
850
849
  - WriteFile(path=string, content=string). Creates/Overwrites. File Exist? PatchFile > WriteFile
851
- - ${et}. ${G}. Destructive command \u2192 Ask user`.trim(),Sn=`=== START SYSTEM PROMPT ===
850
+ - ${et}. ${U}. Destructive command \u2192 Ask user`.trim(),wn=`=== START SYSTEM PROMPT ===
852
851
  Identity: FluxFlow subagent helping the main Agent
853
- Your task: "${e}"
854
852
  CWD: ${process.cwd()}
855
853
 
856
- ${x.trimEnd()}
854
+ ${w.trimEnd()}
857
855
 
858
856
  -- THINKING GUIDANCE --
859
857
  Use minimal reasoning. Prefer simplest path; avoid branching; waste NO tokens overthinking. Just focus on task completion. Before actions, provide user facing summary of findings & decisions IN detail
@@ -861,38 +859,38 @@ Main focus: actions and task, not chatting
861
859
  On completion, provide a detailed summary in Tables/Markdown Format with file modified info. If any task failed report back in detail
862
860
 
863
861
  Current Time: ${I}
864
- === END SYSTEM PROMPT ===`,pe=Array.isArray(l)&&l.length>0?l:[{role:"user",text:`Complete this task: ${e}`}];Array.isArray(l)&&l.length>0&&pe.push({role:"user",text:`Follow-up task / instruction: ${e}`});let Vt=0,tn="";for(;Vt<o;){let Me=await qi("subagent",u);if(!Me.allowed)throw new Error(Me.reason||`Budget Exhausted for Provider (${u?.aiProvider||"Subagent"})`);if(xt){if(t?.taskId&&typeof jt<"u"){let j=jt.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 jt<"u"){let j=jt.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 ne=pe.map(j=>({role:j.role==="user"?"user":"model",parts:[{text:j.text}]}));r&&r(`[Subagent Turn ${Vt+1}]...`);let Ve=["Fast","Low","Medium","High"],dn=process.env.SUBAGENT_THINKING,_n=Ve.includes(dn)?dn:"Low",Kn=(await $l(u,$,ne,Sn,_n)).text||"",fn=ba(Kt(Kn).trim());tn=fn,r&&r(`[Subagent Response]
865
- ${fn}
866
- `),pe.push({role:"agent",text:fn});let St=jn(fn);if(St.length===0)break;let Ft=St.filter(j=>j.toolName.toLowerCase()==="askmain"||j.toolName.toLowerCase()==="ask_main"),Pe=!1,Bt="";for(let j of St){if(xt){if(t?.taskId&&typeof jt<"u"){let k=jt.find(Z=>Z.id===t.taskId);k&&(k.status="cancelled")}throw new Error("Subagent task was cancelled.")}if(t?.taskId&&typeof jt<"u"){let k=jt.find(Z=>Z.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(Pe)continue;Pe=!0;let k="";if(Ft.length===1?k=L(Ft[0].args).question||Ft[0].args:k=Ft.map((Z,Je)=>{let Ce=L(Z.args);return`Q${Je+1}: ${Ce.question||Z.args}`}).join(`
867
- `),t.onAskMain){r&&r(`[Executing Tool] AskMain("${k}")...`);let Z=await t.onAskMain(k);r&&r(`[Action Result]
868
- Answer from Main Agent: ${Z}
869
- `),Bt+=`[ACTION RESULT for AskMain]: Answer from Main Agent: ${Z}
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}
870
868
 
871
- `,await $t("toolSuccess")}else Bt+=`[ACTION RESULT for AskMain]: ERROR: Main agent communication channel not available.
869
+ `,await $t("toolSuccess")}else cn+=`[ACTION RESULT for AskMain]: ERROR: Main agent communication channel not available.
872
870
 
873
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
874
- `),Bt+=`${k}
872
+ `),cn+=`${k}
875
873
 
876
- `;continue}if(N==="exec_command"||N==="execcommand"||N==="run"){let k=L(j.args,["command","background","timeout"]).command||"",Z=P(k);if(!Z.allowed){let Je=`ERROR: [SECURITY RESTRICTION] Subagent execution blocked command: ${Z.reason}`;r&&r(`[Blocked Command] ${k} - ${Z.reason}
877
- `),Bt+=`${Je}
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}
875
+ `),cn+=`${Je}
878
876
 
879
- `;continue}}let it="";if(N==="web_search"||N==="websearch")it=`\u2714 \x1B[95mSearched\x1B[0m: ${L(j.args,["query","limit","aiMode"]).query||""}`;else if(N==="web_scrape"||N==="webscrape")it=`\u2714 \x1B[95mScraped\x1B[0m: ${L(j.args,["url"]).url||""}`;else if(N==="search_keyword"||N==="searchkeyword"||N==="codesearch"||N==="code_search"){let k=L(j.args,["keyword","path","fuzzy","subString","regex"]),Z=k.keyword||"",Je=k.path||"";it=`${Z?"\u2714":"\u2718"} \x1B[95mSearched\x1B[0m: ${Z||"No Query"}${Je?` \u2192 ${Je.replaceAll("\\","/")}`:""}`}else if(N==="view_file"||N==="viewfile"||N==="readfile")it=`\u2714 \x1B[95mRead\x1B[0m: ${(L(j.args,["path","targetPath","file","StartLine","EndLine","start_line","end_line","startLine","endLine"]).path||"").replaceAll("\\","/")}`;else if(N==="find_file"||N==="findfile"){let k=L(j.args,["basename","name","path","file","query"]),Z=k.basename||k.name||k.path||k.file||k.query||"";it=`${Z?"\u2714":"\u2718"} \x1B[95mLocated\x1B[0m: ${Z||"No Query"}`}else if(N==="list_files"||N==="read_folder"||N==="readfolder"){let k=L(j.args,["path","recurse","include"]).path||null,Z=L(j.args,["path","recurse","include"]).recurse||0;it=`${k?"\u2714":"\u2718"} \x1B[95mBrowsed\x1B[0m: ${k?`${k.replaceAll("\\","/")}${Z>0?`${k.endsWith("/")?`*${Z}`:`/*${Z}`}`:`${k.endsWith("/")?"":"/"}`}`:""}`}else if(N==="write_file"||N==="writefile"){let k=L(j.args,["path","content"]).path||null;it=`${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=L(j.args,["path","allowMultiple","content","searchContent*","replaceContent*","newContent*"]),Z=k.path||null,Ce=Object.entries(k).some(([lt,ft])=>lt.startsWith("searchContent")&&typeof ft=="string"&&ft.startsWith("^LINE:"))?"\u1361":":";it=`${Z?"\u2714":"\u2718"} \x1B[95mEdited\x1B[0m${Ce} ${Z?`${Z.replaceAll("\\","/")}`:"No File Changes"}`}else if(N==="exec_command"||N==="execcommand"||N==="run"){let k=L(j.args,["command","background","timeout"]).command||null;it=`${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=L(j.args,["path"]).path||"";it=`${k?"\u2714":"\u2718"} \x1B[95mIndexed\x1B[0m: ${k?`${k.replaceAll("\\","/")}`:"File Not Found"}`}else if(N==="await"){let{time:k}=L(j.args,["time","timeout","seconds","sec"]),Z=parseFloat(k)||0;Z<10&&(Z=10),Z>180&&(Z=180),it=`\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`})(Z)}`}else{let k=vs[N]||j.toolName,Z=io(N,j.args);it=`\u2714 \x1B[95m${k}\x1B[0m${Z?`: ${Z}`:""}`}t.onVisualFeedback&&it&&t.onVisualFeedback(it),r&&r(`[Executing Tool] ${j.toolName}(${j.args})...`);try{let k=await xs(j.toolName,j.args,{...t,mode:"Flux"});r&&r(`[Action Result]
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]
880
878
  ${k}
881
879
  `);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.
882
- `));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*$/),nn=ft?`
880
+ `));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?`
883
881
 
884
- ${ft[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(lt)){let un=lt.search(/^- Content Preview:/m);Ce=`[ACTION RESULT]: ${un!==-1?lt.slice(0,un).trimEnd():lt}
882
+ ${ft[1]}`:"";if(/- Stats:.*\r?\nOld File contents:/s.test(lt)){let dn=lt.search(/^- Content Preview:/m);Ce=`[ACTION RESULT]: ${dn!==-1?lt.slice(0,dn).trimEnd():lt}
885
883
 
886
- [Old file content for reversal reference. Replaced with new write request]${nn}`}else{let un=lt.split(/\r?\n/),kn=un.filter(Mi=>Mi.startsWith("File ")||Mi.trim().startsWith("- Stats:"));Ce=`[ACTION RESULT]: ${kn.length>0?kn.join(`
887
- `):un.slice(0,2).join(`
888
- `)}${nn}`}}else if(Je.startsWith("[[SAME]]")){let ft=Je.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),nn=ft.filter(kn=>kn.startsWith("File ")||kn.trim().startsWith("- Stats:"));Ce=`[ACTION RESULT]: ${nn.length>0?nn.join(`
884
+ [Old file content for reversal reference. Replaced with new write request]${Zt}`}else{let dn=lt.split(/\r?\n/),kn=dn.filter(Mi=>Mi.startsWith("File ")||Mi.trim().startsWith("- Stats:"));Ce=`[ACTION RESULT]: ${kn.length>0?kn.join(`
885
+ `):dn.slice(0,2).join(`
886
+ `)}${Zt}`}}else if(Je.startsWith("[[SAME]]")){let ft=Je.replace(/^\[\[SAME\]\]\s*\r?\n?/,"").split(/\r?\n/),Zt=ft.filter(kn=>kn.startsWith("File ")||kn.trim().startsWith("- Stats:"));Ce=`[ACTION RESULT]: ${Zt.length>0?Zt.join(`
889
887
  `):ft.slice(0,2).join(`
890
- `)}`}else Ce=`[ACTION RESULT]: ${Je}`;Bt+=`${Ce}
888
+ `)}`}else Ce=`[ACTION RESULT]: ${Je}`;cn+=`${Ce}
891
889
 
892
- `,await $t("toolSuccess")}catch(k){let Z=`ERROR: Execution failed for [${j.toolName}]: ${k.message}`;r&&r(`[Tool Error] ${Z}
893
- `),Bt+=`[ACTION RESULT]: ${Z}
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
892
 
895
- `,await $t("toolFailure")}}let zt="";if(t?.taskId&&typeof jt<"u"){let j=jt.find(N=>N.id===t.taskId);if(j&&j.pendingSteerMessages&&j.pendingSteerMessages.length>0){let N=[...j.pendingSteerMessages];j.pendingSteerMessages=[];for(let zn of N)zt+=`
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+=`
896
894
 
897
- [STEERING INSTRUCTION FROM MAIN AGENT]: ${zn}`,r&&r(`[Subagent Steered] ${zn}`)}}let Vn=(Bt.trim()+zt).trim();pe.push({role:"user",text:Vn}),Vt++}if(t?.onHistoryUpdate&&typeof t.onHistoryUpdate=="function"&&t.onHistoryUpdate(pe),u?.systemSettings?.autoTruncateResults){for(let Me=0;Me<pe.length;Me++){let ne=pe[Me],Ve=ne.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(u?.systemSettings?.overwriteProtection!==!1){let dn=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(dn)try{let _n=dn[1],so=dn[2]||"",Kn=dn[3]||"",fn=B.basename(_n),St=Kn.replace("[DIFF_START]","");St=St.replace(/\[DIFF_END\](?=[^\[]*$)/,""),St=St.split(/\r?\n/).filter(Ce=>{let lt=Ce.trim();return lt.startsWith("-")||lt.startsWith("+")||lt.startsWith("@@")}).join(`
898
- `).trim();let Ft=0,Pe=0,Bt=Kn.matchAll(/@@\s*([^@]+?)\s*@@/g);for(let Ce of Bt){let lt=Ce[1],ft=lt.match(/\+(\d+)/),nn=lt.match(/-(\d+)/);ft&&(Ft+=parseInt(ft[1],10)),nn&&(Pe+=parseInt(nn[1],10))}let zt=[];Ft>0&&zt.push(`+${Ft}`),Pe>0&&zt.push(`-${Pe}`);let Vn=zt.length>0?` Total ${zt.join(" ")} changes.`:"",j=B.join(ii,"DiffBackups");xe.existsSync(j)||xe.mkdirSync(j,{recursive:!0});let N=String(Date.now()).slice(-5),zn=wa.randomBytes(2).toString("hex"),it=`${fn}-diff-${N}-${zn}.txt`,k=B.join(j,it);xe.writeFileSync(k,St,"utf8");let Z=`${ii.replaceAll("\\","/").replace(xa.homedir().replaceAll("\\","/"),"~")}/DiffBackups/${it}`,Je=so?` ${so} blocks.`:"";pe[Me]={...ne,text:`[ACTION RESULT]: Diff result ${fn} saved in '${Z}'.${Je}${Vn}`};continue}catch{}}pe[Me]={...ne,text:"[ACTION RESULT]: ...Old result truncated to save tokens"}}}t?.onHistoryUpdate&&typeof t.onHistoryUpdate=="function"&&t.onHistoryUpdate(pe)}return tn};export{wo as a,Ri as b,td as c,nd as d,Tc as e,Ac as f,xo as g,Cc as h,hi as i,yi as j,Wc as k,Gc as l,Al as m,Qd as n,Cl as o,Rl as p,Rs as q,Kt as r,_i as s,ba as t,Zd as u,ef as v,tf as w,Sa as x,nf as y,Ii as z,ma as A,Il as B,jn as C,of as D,$l as E,sf as F,rf as G};
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};